From e825206eb63ff099ed7376cfc4f977738fd4e9a3 Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Mon, 11 Apr 2011 18:05:14 -0700 Subject: [PATCH] Remove unneeded SDKs and Scripts directories --- .../Win32/HawkVoice/lib/HawkVoiceDIstatic.lib | Bin 189518 -> 0 bytes .../Win32/HawkVoice/src/BLOWFISH/Blowfish.001 | 122 - .../Win32/HawkVoice/src/BLOWFISH/Blowfish.dsp | 128 - SDKs/Win32/HawkVoice/src/BLOWFISH/COPYRIGHT | 46 - SDKs/Win32/HawkVoice/src/BLOWFISH/INSTALL | 14 - SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile | 160 - .../Win32/HawkVoice/src/BLOWFISH/Makefile.ssl | 104 - .../Win32/HawkVoice/src/BLOWFISH/Makefile.uni | 160 - SDKs/Win32/HawkVoice/src/BLOWFISH/README | 8 - .../Win32/HawkVoice/src/BLOWFISH/asm/bf586.pl | 159 - .../HawkVoice/src/BLOWFISH/asm/bx86-cpp.s | 666 - .../HawkVoice/src/BLOWFISH/asm/bx86unix.cpp | 33 - SDKs/Win32/HawkVoice/src/BLOWFISH/asm/readme | 3 - .../HawkVoice/src/BLOWFISH/asm/win32.asm | 663 - .../Win32/HawkVoice/src/BLOWFISH/asm/x86ms.pl | 249 - .../HawkVoice/src/BLOWFISH/asm/x86unix.pl | 313 - SDKs/Win32/HawkVoice/src/BLOWFISH/bf_cbc.c | 143 - SDKs/Win32/HawkVoice/src/BLOWFISH/bf_cfb64.c | 122 - SDKs/Win32/HawkVoice/src/BLOWFISH/bf_ecb.c | 91 - SDKs/Win32/HawkVoice/src/BLOWFISH/bf_enc.c | 137 - SDKs/Win32/HawkVoice/src/BLOWFISH/bf_locl.h | 236 - SDKs/Win32/HawkVoice/src/BLOWFISH/bf_locl.org | 215 - SDKs/Win32/HawkVoice/src/BLOWFISH/bf_ofb64.c | 110 - SDKs/Win32/HawkVoice/src/BLOWFISH/bf_pi.h | 325 - SDKs/Win32/HawkVoice/src/BLOWFISH/bf_skey.c | 116 - .../Win32/HawkVoice/src/BLOWFISH/blowfish.doc | 149 - SDKs/Win32/HawkVoice/src/BLOWFISH/blowfish.h | 114 - SDKs/Win32/HawkVoice/src/hvdi.h | 194 - .../Cypython-2.3.3/Grammar/.cvsignore | 3 - SDKs/XPlatform/Cypython-2.3.3/Grammar/Grammar | 107 - SDKs/XPlatform/Cypython-2.3.3/LICENSE | 262 - .../Cypython-2.3.3/Modules/.cvsignore | 9 - .../Cypython-2.3.3/Modules/Setup.config.in | 13 - .../Cypython-2.3.3/Modules/Setup.dist | 486 - .../XPlatform/Cypython-2.3.3/Modules/_bsddb.c | 4715 ------- .../Cypython-2.3.3/Modules/_codecsmodule.c | 816 -- SDKs/XPlatform/Cypython-2.3.3/Modules/_csv.c | 1556 --- .../Cypython-2.3.3/Modules/_curses_panel.c | 471 - .../Cypython-2.3.3/Modules/_cursesmodule.c | 2595 ---- .../Cypython-2.3.3/Modules/_hotshot.c | 1666 --- .../Cypython-2.3.3/Modules/_localemodule.c | 783 -- .../Cypython-2.3.3/Modules/_randommodule.c | 531 - SDKs/XPlatform/Cypython-2.3.3/Modules/_sre.c | 3166 ----- SDKs/XPlatform/Cypython-2.3.3/Modules/_ssl.c | 639 - .../Cypython-2.3.3/Modules/_testcapimodule.c | 642 - .../Cypython-2.3.3/Modules/_tkinter.c | 3203 ----- .../Cypython-2.3.3/Modules/_weakref.c | 131 - .../Cypython-2.3.3/Modules/addrinfo.h | 176 - .../Cypython-2.3.3/Modules/almodule.c | 3222 ----- SDKs/XPlatform/Cypython-2.3.3/Modules/ar_beos | 73 - .../Cypython-2.3.3/Modules/arraymodule.c | 2037 --- .../Cypython-2.3.3/Modules/audioop.c | 1381 --- .../Cypython-2.3.3/Modules/binascii.c | 1337 -- .../Cypython-2.3.3/Modules/bsddbmodule.c | 856 -- .../Cypython-2.3.3/Modules/bz2module.c | 2191 ---- .../Cypython-2.3.3/Modules/cPickle.c | 5761 --------- .../Cypython-2.3.3/Modules/cStringIO.c | 731 -- .../Cypython-2.3.3/Modules/ccpython.cc | 11 - .../Cypython-2.3.3/Modules/cdmodule.c | 794 -- SDKs/XPlatform/Cypython-2.3.3/Modules/cgen.py | 520 - .../Cypython-2.3.3/Modules/cgensupport.c | 310 - .../Cypython-2.3.3/Modules/cgensupport.h | 64 - .../Cypython-2.3.3/Modules/clmodule.c | 2557 ---- .../Cypython-2.3.3/Modules/cmathmodule.c | 404 - .../Cypython-2.3.3/Modules/config.c.in | 48 - .../Cypython-2.3.3/Modules/cryptmodule.c | 44 - SDKs/XPlatform/Cypython-2.3.3/Modules/cstubs | 1364 -- .../Cypython-2.3.3/Modules/datetimemodule.c | 4854 -------- .../Cypython-2.3.3/Modules/dbmmodule.c | 372 - .../Cypython-2.3.3/Modules/dlmodule.c | 254 - .../Cypython-2.3.3/Modules/errnomodule.c | 795 -- .../Cypython-2.3.3/Modules/expat/Makefile.in | 158 - .../Cypython-2.3.3/Modules/expat/ascii.h | 85 - .../Cypython-2.3.3/Modules/expat/asciitab.h | 36 - .../Cypython-2.3.3/Modules/expat/expat.h | 1001 -- .../Cypython-2.3.3/Modules/expat/iasciitab.h | 37 - .../Cypython-2.3.3/Modules/expat/internal.h | 73 - .../Cypython-2.3.3/Modules/expat/latin1tab.h | 36 - .../Cypython-2.3.3/Modules/expat/macconfig.h | 104 - .../Cypython-2.3.3/Modules/expat/nametab.h | 150 - .../Cypython-2.3.3/Modules/expat/utf8tab.h | 37 - .../Cypython-2.3.3/Modules/expat/winconfig.h | 30 - .../Cypython-2.3.3/Modules/expat/xmlparse.c | 5814 --------- .../Cypython-2.3.3/Modules/expat/xmlrole.c | 1323 -- .../Cypython-2.3.3/Modules/expat/xmlrole.h | 114 - .../Cypython-2.3.3/Modules/expat/xmltok.c | 1634 --- .../Cypython-2.3.3/Modules/expat/xmltok.h | 315 - .../Modules/expat/xmltok_impl.c | 1779 --- .../Modules/expat/xmltok_impl.h | 46 - .../Cypython-2.3.3/Modules/expat/xmltok_ns.c | 106 - .../Cypython-2.3.3/Modules/fcntlmodule.c | 594 - .../Cypython-2.3.3/Modules/flmodule.c | 2138 ---- .../Cypython-2.3.3/Modules/fmmodule.c | 262 - .../Cypython-2.3.3/Modules/fpectlmodule.c | 276 - .../Cypython-2.3.3/Modules/fpetestmodule.c | 184 - .../Cypython-2.3.3/Modules/gc_weakref.txt | 107 - .../Cypython-2.3.3/Modules/gcmodule.c | 1232 -- .../Cypython-2.3.3/Modules/gdbmmodule.c | 523 - .../Cypython-2.3.3/Modules/getaddrinfo.c | 638 - .../Cypython-2.3.3/Modules/getbuildinfo.c | 38 - .../Cypython-2.3.3/Modules/getnameinfo.c | 214 - .../Cypython-2.3.3/Modules/getpath.c | 650 - .../Cypython-2.3.3/Modules/glmodule.c | 7628 ------------ .../Cypython-2.3.3/Modules/grpmodule.c | 177 - .../Cypython-2.3.3/Modules/imageop.c | 708 -- .../Cypython-2.3.3/Modules/imgfile.c | 502 - .../Cypython-2.3.3/Modules/itertoolsmodule.c | 1852 --- .../Cypython-2.3.3/Modules/ld_so_aix | 183 - .../Cypython-2.3.3/Modules/ld_so_beos | 78 - .../Cypython-2.3.3/Modules/linuxaudiodev.c | 519 - SDKs/XPlatform/Cypython-2.3.3/Modules/main.c | 466 - .../Cypython-2.3.3/Modules/makesetup | 297 - .../Cypython-2.3.3/Modules/makexp_aix | 75 - .../Cypython-2.3.3/Modules/mathmodule.c | 391 - SDKs/XPlatform/Cypython-2.3.3/Modules/md5.h | 62 - SDKs/XPlatform/Cypython-2.3.3/Modules/md5c.c | 290 - .../Cypython-2.3.3/Modules/md5module.c | 268 - .../Cypython-2.3.3/Modules/mmapmodule.c | 1124 -- .../Cypython-2.3.3/Modules/mpzmodule.c | 1690 --- .../Cypython-2.3.3/Modules/nismodule.c | 382 - .../Cypython-2.3.3/Modules/operator.c | 264 - .../Cypython-2.3.3/Modules/ossaudiodev.c | 1094 -- .../Cypython-2.3.3/Modules/parsermodule.c | 2957 ----- .../Cypython-2.3.3/Modules/pcre-int.h | 303 - SDKs/XPlatform/Cypython-2.3.3/Modules/pcre.h | 84 - .../Cypython-2.3.3/Modules/pcremodule.c | 636 - .../Cypython-2.3.3/Modules/posixmodule.c | 7535 ----------- .../Cypython-2.3.3/Modules/puremodule.c | 986 -- .../Cypython-2.3.3/Modules/pwdmodule.c | 188 - .../Cypython-2.3.3/Modules/pyexpat.c | 2057 --- .../XPlatform/Cypython-2.3.3/Modules/pypcre.c | 4756 ------- .../XPlatform/Cypython-2.3.3/Modules/python.c | 24 - .../Cypython-2.3.3/Modules/readline.c | 736 -- .../Cypython-2.3.3/Modules/regexmodule.c | 689 -- .../Cypython-2.3.3/Modules/regexpr.c | 2094 ---- .../Cypython-2.3.3/Modules/regexpr.h | 155 - .../Cypython-2.3.3/Modules/resource.c | 316 - .../Cypython-2.3.3/Modules/rgbimgmodule.c | 763 -- .../Cypython-2.3.3/Modules/rotormodule.c | 627 - .../Cypython-2.3.3/Modules/selectmodule.c | 688 -- .../Cypython-2.3.3/Modules/sgimodule.c | 55 - .../Cypython-2.3.3/Modules/shamodule.c | 542 - .../Cypython-2.3.3/Modules/signalmodule.c | 674 - .../Cypython-2.3.3/Modules/socketmodule.c | 4151 ------- .../Cypython-2.3.3/Modules/socketmodule.h | 221 - SDKs/XPlatform/Cypython-2.3.3/Modules/sre.h | 91 - .../Cypython-2.3.3/Modules/sre_constants.h | 85 - .../Cypython-2.3.3/Modules/stropmodule.c | 1244 -- .../Cypython-2.3.3/Modules/structmodule.c | 1297 -- .../Cypython-2.3.3/Modules/sunaudiodev.c | 463 - .../Cypython-2.3.3/Modules/svmodule.c | 964 -- .../Cypython-2.3.3/Modules/symtablemodule.c | 79 - .../Cypython-2.3.3/Modules/syslogmodule.c | 222 - .../Cypython-2.3.3/Modules/termios.c | 924 -- .../Cypython-2.3.3/Modules/testcapi_long.h | 166 - .../Cypython-2.3.3/Modules/threadmodule.c | 406 - .../Cypython-2.3.3/Modules/timemodule.c | 944 -- .../XPlatform/Cypython-2.3.3/Modules/timing.h | 67 - .../Cypython-2.3.3/Modules/timingmodule.c | 58 - .../Cypython-2.3.3/Modules/tkappinit.c | 139 - .../Cypython-2.3.3/Modules/unicodedata.c | 899 -- .../Cypython-2.3.3/Modules/unicodedata_db.h | 3781 ------ .../Cypython-2.3.3/Modules/unicodename_db.h | 10289 ---------------- .../Cypython-2.3.3/Modules/xreadlinesmodule.c | 171 - .../Cypython-2.3.3/Modules/xxmodule.c | 374 - .../Cypython-2.3.3/Modules/xxsubtype.c | 303 - SDKs/XPlatform/Cypython-2.3.3/Modules/yuv.h | 99 - .../Cypython-2.3.3/Modules/yuvconvert.c | 118 - .../Cypython-2.3.3/Modules/zipimport.c | 1188 -- .../Cypython-2.3.3/Modules/zlibmodule.c | 907 -- .../Cypython-2.3.3/Objects/.cvsignore | 2 - .../Cypython-2.3.3/Objects/abstract.c | 2192 ---- .../Cypython-2.3.3/Objects/boolobject.c | 201 - .../Cypython-2.3.3/Objects/bufferobject.c | 568 - .../Cypython-2.3.3/Objects/cellobject.c | 114 - .../Cypython-2.3.3/Objects/classobject.c | 2516 ---- .../Cypython-2.3.3/Objects/cobject.c | 146 - .../Cypython-2.3.3/Objects/complexobject.c | 1022 -- .../Cypython-2.3.3/Objects/descrobject.c | 1255 -- .../Cypython-2.3.3/Objects/dictnotes.txt | 245 - .../Cypython-2.3.3/Objects/dictobject.c | 2086 ---- .../Cypython-2.3.3/Objects/enumobject.c | 161 - .../Cypython-2.3.3/Objects/fileobject.c | 2402 ---- .../Cypython-2.3.3/Objects/floatobject.c | 1253 -- .../Cypython-2.3.3/Objects/frameobject.c | 815 -- .../Cypython-2.3.3/Objects/funcobject.c | 875 -- .../Cypython-2.3.3/Objects/intobject.c | 1188 -- .../Cypython-2.3.3/Objects/iterobject.c | 228 - .../Cypython-2.3.3/Objects/listobject.c | 2501 ---- .../Cypython-2.3.3/Objects/listsort.txt | 667 - .../Cypython-2.3.3/Objects/longobject.c | 2912 ----- .../Cypython-2.3.3/Objects/methodobject.c | 374 - .../Cypython-2.3.3/Objects/moduleobject.c | 260 - .../XPlatform/Cypython-2.3.3/Objects/object.c | 2228 ---- .../Cypython-2.3.3/Objects/obmalloc.c | 1375 --- .../Cypython-2.3.3/Objects/rangeobject.c | 287 - .../Cypython-2.3.3/Objects/sliceobject.c | 328 - .../Cypython-2.3.3/Objects/stringobject.c | 4228 ------- .../Cypython-2.3.3/Objects/structseq.c | 395 - .../Cypython-2.3.3/Objects/tupleobject.c | 836 -- .../Cypython-2.3.3/Objects/typeobject.c | 5707 --------- .../Cypython-2.3.3/Objects/unicodectype.c | 423 - .../Cypython-2.3.3/Objects/unicodeobject.c | 6859 ---------- .../Cypython-2.3.3/Objects/unicodetype_db.h | 1090 -- .../Cypython-2.3.3/Objects/weakrefobject.c | 783 -- SDKs/XPlatform/Cypython-2.3.3/PC/.cvsignore | 2 - .../Cypython-2.3.3/PC/PlasmaPack.cpp | 17 - SDKs/XPlatform/Cypython-2.3.3/PC/PlasmaPack.h | 15 - SDKs/XPlatform/Cypython-2.3.3/PC/WinMain.c | 16 - SDKs/XPlatform/Cypython-2.3.3/PC/_winreg.c | 1526 --- .../PC/bdist_wininst/.cvsignore | 4 - .../PC/bdist_wininst/PythonPowered.bmp | Bin 2582 -> 0 bytes .../PC/bdist_wininst/README.txt | 5 - .../Cypython-2.3.3/PC/bdist_wininst/archive.h | 96 - .../Cypython-2.3.3/PC/bdist_wininst/extract.c | 312 - .../Cypython-2.3.3/PC/bdist_wininst/install.c | 2294 ---- .../PC/bdist_wininst/install.rc | 220 - .../PC/bdist_wininst/resource.h | 38 - .../PC/bdist_wininst/wininst.dsp | 128 - .../PC/bdist_wininst/wininst.dsw | 29 - SDKs/XPlatform/Cypython-2.3.3/PC/config.c | 127 - SDKs/XPlatform/Cypython-2.3.3/PC/dl_nt.c | 44 - .../Cypython-2.3.3/PC/dllbase_nt.txt | 76 - .../Cypython-2.3.3/PC/example_nt/.cvsignore | 5 - .../Cypython-2.3.3/PC/example_nt/example.c | 20 - .../Cypython-2.3.3/PC/example_nt/example.def | 2 - .../Cypython-2.3.3/PC/example_nt/example.dsp | 117 - .../Cypython-2.3.3/PC/example_nt/example.dsw | 29 - .../Cypython-2.3.3/PC/example_nt/readme.txt | 165 - .../Cypython-2.3.3/PC/frozen_dllmain.c | 134 - SDKs/XPlatform/Cypython-2.3.3/PC/getpathp.c | 686 -- SDKs/XPlatform/Cypython-2.3.3/PC/import_nt.c | 93 - .../Cypython-2.3.3/PC/make_versioninfo.c | 33 - .../Cypython-2.3.3/PC/msvcrtmodule.c | 232 - .../Cypython-2.3.3/PC/os2emx/Makefile | 671 - .../Cypython-2.3.3/PC/os2emx/README.os2emx | 671 - .../Cypython-2.3.3/PC/os2emx/config.c | 180 - .../Cypython-2.3.3/PC/os2emx/dlfcn.c | 223 - .../Cypython-2.3.3/PC/os2emx/dlfcn.h | 51 - .../Cypython-2.3.3/PC/os2emx/dllentry.c | 42 - .../Cypython-2.3.3/PC/os2emx/getpathp.c | 407 - .../Cypython-2.3.3/PC/os2emx/pyconfig.h | 327 - .../Cypython-2.3.3/PC/os2emx/python23.def | 1161 -- .../Cypython-2.3.3/PC/os2emx/pythonpm.c | 124 - .../Cypython-2.3.3/PC/os2vacpp/_tkinter.def | 8 - .../Cypython-2.3.3/PC/os2vacpp/config.c | 110 - .../Cypython-2.3.3/PC/os2vacpp/getpathp.c | 471 - .../Cypython-2.3.3/PC/os2vacpp/makefile | 1928 --- .../Cypython-2.3.3/PC/os2vacpp/makefile.omk | 1301 -- .../Cypython-2.3.3/PC/os2vacpp/pyconfig.h | 213 - .../Cypython-2.3.3/PC/os2vacpp/python.def | 480 - .../Cypython-2.3.3/PC/os2vacpp/readme.txt | 119 - SDKs/XPlatform/Cypython-2.3.3/PC/py.ico | Bin 766 -> 0 bytes SDKs/XPlatform/Cypython-2.3.3/PC/pyc.ico | Bin 766 -> 0 bytes SDKs/XPlatform/Cypython-2.3.3/PC/pycon.ico | Bin 766 -> 0 bytes SDKs/XPlatform/Cypython-2.3.3/PC/python.mk | 5 - .../XPlatform/Cypython-2.3.3/PC/python_exe.rc | 1 - SDKs/XPlatform/Cypython-2.3.3/PC/python_nt.rc | 74 - .../XPlatform/Cypython-2.3.3/PC/pythonnt_rc.h | 4 - .../Cypython-2.3.3/PC/pythonnt_rc_d.h | 4 - SDKs/XPlatform/Cypython-2.3.3/PC/readme.txt | 95 - SDKs/XPlatform/Cypython-2.3.3/PC/testpy.py | 32 - SDKs/XPlatform/Cypython-2.3.3/PC/w9xpopen.c | 112 - SDKs/XPlatform/Cypython-2.3.3/PC/winsound.c | 246 - .../Cypython-2.3.3/PCbuild/.cvsignore | 14 - .../Cypython-2.3.3/PCbuild/BUILDno.txt | 137 - .../Cypython-2.3.3/PCbuild/Uninstal.wse | 514 - .../Cypython-2.3.3/PCbuild/_bsddb.dsp | 99 - .../XPlatform/Cypython-2.3.3/PCbuild/_csv.dsp | 99 - .../Cypython-2.3.3/PCbuild/_socket.dsp | 99 - .../XPlatform/Cypython-2.3.3/PCbuild/_sre.dsp | 99 - .../Cypython-2.3.3/PCbuild/_sre_static.vcproj | 112 - .../XPlatform/Cypython-2.3.3/PCbuild/_ssl.dsp | 89 - .../XPlatform/Cypython-2.3.3/PCbuild/_ssl.mak | 21 - .../Cypython-2.3.3/PCbuild/_symtable.dsp | 99 - .../Cypython-2.3.3/PCbuild/_testcapi.dsp | 99 - .../Cypython-2.3.3/PCbuild/_tkinter.dsp | 103 - .../Cypython-2.3.3/PCbuild/build_ssl.py | 163 - SDKs/XPlatform/Cypython-2.3.3/PCbuild/bz2.dsp | 99 - .../Cypython-2.3.3/PCbuild/datetime.dsp | 99 - .../Cypython-2.3.3/PCbuild/field3.py | 35 - .../Cypython-2.3.3/PCbuild/installer.bmp | Bin 50324 -> 0 bytes .../XPlatform/Cypython-2.3.3/PCbuild/mmap.dsp | 99 - .../Cypython-2.3.3/PCbuild/parser.dsp | 99 - .../Cypython-2.3.3/PCbuild/pcbuild.dsw | 359 - .../Cypython-2.3.3/PCbuild/pyexpat.dsp | 111 - .../Cypython-2.3.3/PCbuild/python.dsp | 100 - .../Cypython-2.3.3/PCbuild/python.iss | 241 - .../Cypython-2.3.3/PCbuild/python20.wse | 3168 ----- .../Cypython-2.3.3/PCbuild/pythoncore.dsp | 592 - .../Cypython-2.3.3/PCbuild/pythoncore.vcproj | 2427 ---- .../PCbuild/pythoncore_dyn_server.vcproj | 4337 ------- .../PCbuild/pythoncore_static.vcproj | 549 - .../Cypython-2.3.3/PCbuild/pythonw.dsp | 101 - .../Cypython-2.3.3/PCbuild/readme.txt | 314 - .../XPlatform/Cypython-2.3.3/PCbuild/rmpyc.py | 25 - SDKs/XPlatform/Cypython-2.3.3/PCbuild/rt.bat | 41 - .../Cypython-2.3.3/PCbuild/select.dsp | 99 - .../Cypython-2.3.3/PCbuild/unicodedata.dsp | 99 - .../Cypython-2.3.3/PCbuild/w9xpopen.dsp | 97 - .../Cypython-2.3.3/PCbuild/winreg.dsp | 108 - .../Cypython-2.3.3/PCbuild/winsound.dsp | 99 - .../XPlatform/Cypython-2.3.3/PCbuild/zlib.dsp | 109 - .../Cypython-2.3.3/Parser/.cvsignore | 3 - .../XPlatform/Cypython-2.3.3/Parser/acceler.c | 138 - SDKs/XPlatform/Cypython-2.3.3/Parser/bitset.c | 66 - .../Cypython-2.3.3/Parser/firstsets.c | 110 - .../XPlatform/Cypython-2.3.3/Parser/grammar.c | 246 - .../Cypython-2.3.3/Parser/grammar.mak | 45 - .../Cypython-2.3.3/Parser/grammar1.c | 57 - .../Cypython-2.3.3/Parser/intrcheck.c | 193 - .../Cypython-2.3.3/Parser/listnode.c | 66 - .../Cypython-2.3.3/Parser/metagrammar.c | 159 - .../Cypython-2.3.3/Parser/myreadline.c | 191 - SDKs/XPlatform/Cypython-2.3.3/Parser/node.c | 134 - SDKs/XPlatform/Cypython-2.3.3/Parser/parser.c | 418 - SDKs/XPlatform/Cypython-2.3.3/Parser/parser.h | 42 - .../Cypython-2.3.3/Parser/parsetok.c | 222 - SDKs/XPlatform/Cypython-2.3.3/Parser/pgen.c | 706 -- .../Cypython-2.3.3/Parser/pgenmain.c | 212 - .../Cypython-2.3.3/Parser/printgrammar.c | 113 - .../Cypython-2.3.3/Parser/tokenizer.c | 1432 --- .../Cypython-2.3.3/Parser/tokenizer.h | 65 - .../Cypython-2.3.3/Parser/tokenizer_pgen.c | 2 - .../Cypython-2.3.3/Python/.cvsignore | 2 - SDKs/XPlatform/Cypython-2.3.3/Python/atof.c | 50 - .../Cypython-2.3.3/Python/bltinmodule.c | 2406 ---- SDKs/XPlatform/Cypython-2.3.3/Python/ceval.c | 4142 ------- SDKs/XPlatform/Cypython-2.3.3/Python/codecs.c | 831 -- .../XPlatform/Cypython-2.3.3/Python/compile.c | 5779 --------- SDKs/XPlatform/Cypython-2.3.3/Python/dup2.c | 30 - .../Cypython-2.3.3/Python/dynload_aix.c | 183 - .../Cypython-2.3.3/Python/dynload_atheos.c | 47 - .../Cypython-2.3.3/Python/dynload_beos.c | 254 - .../Cypython-2.3.3/Python/dynload_dl.c | 26 - .../Cypython-2.3.3/Python/dynload_hpux.c | 58 - .../Cypython-2.3.3/Python/dynload_mac.c | 113 - .../Cypython-2.3.3/Python/dynload_next.c | 114 - .../Cypython-2.3.3/Python/dynload_os2.c | 46 - .../Cypython-2.3.3/Python/dynload_shlib.c | 139 - .../Cypython-2.3.3/Python/dynload_stub.c | 11 - .../Cypython-2.3.3/Python/dynload_win.c | 252 - SDKs/XPlatform/Cypython-2.3.3/Python/errors.c | 785 -- .../Cypython-2.3.3/Python/exceptions.c | 1857 --- SDKs/XPlatform/Cypython-2.3.3/Python/fmod.c | 27 - SDKs/XPlatform/Cypython-2.3.3/Python/frozen.c | 38 - .../Cypython-2.3.3/Python/frozenmain.c | 68 - SDKs/XPlatform/Cypython-2.3.3/Python/future.c | 260 - .../XPlatform/Cypython-2.3.3/Python/getargs.c | 1562 --- .../Cypython-2.3.3/Python/getcompiler.c | 28 - .../Cypython-2.3.3/Python/getcopyright.c | 23 - SDKs/XPlatform/Cypython-2.3.3/Python/getcwd.c | 79 - .../Cypython-2.3.3/Python/getmtime.c | 21 - SDKs/XPlatform/Cypython-2.3.3/Python/getopt.c | 83 - .../Cypython-2.3.3/Python/getplatform.c | 12 - .../Cypython-2.3.3/Python/getversion.c | 15 - .../Cypython-2.3.3/Python/graminit.c | 1770 --- SDKs/XPlatform/Cypython-2.3.3/Python/hypot.c | 23 - SDKs/XPlatform/Cypython-2.3.3/Python/import.c | 2920 ----- .../Cypython-2.3.3/Python/import_pack.c | 2977 ----- .../Cypython-2.3.3/Python/importdl.c | 78 - .../Cypython-2.3.3/Python/importdl.h | 54 - .../Cypython-2.3.3/Python/mactoolboxglue.c | 621 - .../XPlatform/Cypython-2.3.3/Python/marshal.c | 882 -- .../XPlatform/Cypython-2.3.3/Python/memmove.c | 25 - .../Cypython-2.3.3/Python/modsupport.c | 551 - .../Cypython-2.3.3/Python/mysnprintf.c | 93 - .../Cypython-2.3.3/Python/mystrtoul.c | 153 - SDKs/XPlatform/Cypython-2.3.3/Python/pyfpe.c | 23 - .../XPlatform/Cypython-2.3.3/Python/pystate.c | 483 - .../Cypython-2.3.3/Python/pythonrun.c | 1724 --- .../Cypython-2.3.3/Python/sigcheck.c | 19 - SDKs/XPlatform/Cypython-2.3.3/Python/strdup.c | 14 - .../Cypython-2.3.3/Python/strerror.c | 24 - SDKs/XPlatform/Cypython-2.3.3/Python/strtod.c | 156 - .../Cypython-2.3.3/Python/structmember.c | 276 - .../Cypython-2.3.3/Python/symtable.c | 180 - .../Cypython-2.3.3/Python/sysmodule.c | 1298 -- SDKs/XPlatform/Cypython-2.3.3/Python/thread.c | 248 - .../Cypython-2.3.3/Python/thread_atheos.h | 300 - .../Cypython-2.3.3/Python/thread_beos.h | 287 - .../Cypython-2.3.3/Python/thread_cthread.h | 156 - .../Cypython-2.3.3/Python/thread_foobar.h | 115 - .../Cypython-2.3.3/Python/thread_lwp.h | 149 - .../Cypython-2.3.3/Python/thread_nt.h | 324 - .../Cypython-2.3.3/Python/thread_os2.h | 272 - .../Cypython-2.3.3/Python/thread_pth.h | 213 - .../Cypython-2.3.3/Python/thread_pthread.h | 545 - .../Cypython-2.3.3/Python/thread_sgi.h | 379 - .../Cypython-2.3.3/Python/thread_solaris.h | 174 - .../Cypython-2.3.3/Python/thread_wince.h | 171 - .../Cypython-2.3.3/Python/traceback.c | 277 - SDKs/XPlatform/Cypython-2.3.3/README | 1199 -- .../XboxBuild/_sre_static.vcproj | 212 - .../XboxBuild/pythoncore_static.vcproj | 562 - .../XPlatform/Cypython-2.3.3/include/Python.h | 157 - .../Cypython-2.3.3/include/abstract.h | 1217 -- .../XPlatform/Cypython-2.3.3/include/bitset.h | 32 - .../Cypython-2.3.3/include/boolobject.h | 32 - .../Cypython-2.3.3/include/bufferobject.h | 33 - .../Cypython-2.3.3/include/cStringIO.h | 70 - .../Cypython-2.3.3/include/cellobject.h | 28 - SDKs/XPlatform/Cypython-2.3.3/include/ceval.h | 138 - .../Cypython-2.3.3/include/classobject.h | 81 - .../Cypython-2.3.3/include/cobject.h | 51 - .../XPlatform/Cypython-2.3.3/include/codecs.h | 153 - .../Cypython-2.3.3/include/compile.h | 92 - .../Cypython-2.3.3/include/complexobject.h | 58 - .../Cypython-2.3.3/include/datetime.h | 150 - .../Cypython-2.3.3/include/descrobject.h | 91 - .../Cypython-2.3.3/include/dictobject.h | 132 - .../Cypython-2.3.3/include/enumobject.h | 16 - .../Cypython-2.3.3/include/errcode.h | 35 - SDKs/XPlatform/Cypython-2.3.3/include/eval.h | 25 - .../Cypython-2.3.3/include/fileobject.h | 70 - .../Cypython-2.3.3/include/floatobject.h | 95 - .../Cypython-2.3.3/include/frameobject.h | 76 - .../Cypython-2.3.3/include/funcobject.h | 59 - .../Cypython-2.3.3/include/graminit.h | 68 - .../Cypython-2.3.3/include/grammar.h | 93 - .../XPlatform/Cypython-2.3.3/include/import.h | 51 - .../Cypython-2.3.3/include/intobject.h | 61 - .../Cypython-2.3.3/include/intrcheck.h | 15 - .../Cypython-2.3.3/include/iterobject.h | 23 - .../Cypython-2.3.3/include/listobject.h | 52 - .../Cypython-2.3.3/include/longintrepr.h | 58 - .../Cypython-2.3.3/include/longobject.h | 109 - .../Cypython-2.3.3/include/marshal.h | 23 - .../Cypython-2.3.3/include/metagrammar.h | 18 - .../Cypython-2.3.3/include/methodobject.h | 79 - .../Cypython-2.3.3/include/modsupport.h | 101 - .../Cypython-2.3.3/include/moduleobject.h | 24 - SDKs/XPlatform/Cypython-2.3.3/include/node.h | 37 - .../XPlatform/Cypython-2.3.3/include/object.h | 783 -- .../Cypython-2.3.3/include/objimpl.h | 326 - .../XPlatform/Cypython-2.3.3/include/opcode.h | 151 - .../XPlatform/Cypython-2.3.3/include/osdefs.h | 58 - .../Cypython-2.3.3/include/parsetok.h | 48 - .../Cypython-2.3.3/include/patchlevel.h | 37 - SDKs/XPlatform/Cypython-2.3.3/include/pgen.h | 18 - .../Cypython-2.3.3/include/pgenheaders.h | 42 - .../Cypython-2.3.3/include/py_curses.h | 176 - .../Cypython-2.3.3/include/pydebug.h | 39 - .../Cypython-2.3.3/include/pyerrors.h | 233 - SDKs/XPlatform/Cypython-2.3.3/include/pyfpe.h | 176 - .../Cypython-2.3.3/include/pygetopt.h | 17 - .../Cypython-2.3.3/include/pymactoolbox.h | 204 - SDKs/XPlatform/Cypython-2.3.3/include/pymem.h | 108 - .../XPlatform/Cypython-2.3.3/include/pyport.h | 572 - .../Cypython-2.3.3/include/pystate.h | 172 - .../Cypython-2.3.3/include/pythonrun.h | 149 - .../Cypython-2.3.3/include/pythread.h | 44 - .../Cypython-2.3.3/include/rangeobject.h | 27 - .../Cypython-2.3.3/include/sliceobject.h | 42 - .../Cypython-2.3.3/include/stringobject.h | 174 - .../Cypython-2.3.3/include/structmember.h | 95 - .../Cypython-2.3.3/include/structseq.h | 41 - .../Cypython-2.3.3/include/symtable.h | 99 - .../Cypython-2.3.3/include/sysmodule.h | 30 - SDKs/XPlatform/Cypython-2.3.3/include/token.h | 82 - .../Cypython-2.3.3/include/traceback.h | 22 - .../Cypython-2.3.3/include/tupleobject.h | 49 - .../Cypython-2.3.3/include/ucnhash.h | 29 - .../Cypython-2.3.3/include/unicodeobject.h | 1138 -- .../Cypython-2.3.3/include/weakrefobject.h | 50 - .../Cypython-2.3.3/pyconfig_dyn/pyconfig.h | 596 - .../Cypython-2.3.3/pyconfig_static/pyconfig.h | 600 - Scripts/Installer/LargeMOUL.nsi | 149 - Scripts/Installer/MOUL.nsi | 147 - Scripts/Installer/MOULInstaller.exe | Bin 431262 -> 0 bytes Scripts/Max/PlasmaExport.ms | 39 - Scripts/Python/plasma/Plasma.py | 9688 --------------- Scripts/Python/plasma/PlasmaConstants.py | 256 - Scripts/Python/plasma/PlasmaControlKeys.py | 108 - Scripts/Python/plasma/PlasmaGame.py | 2615 ---- Scripts/Python/plasma/PlasmaGameConstants.py | 159 - Scripts/Python/plasma/PlasmaKITypes.py | 469 - Scripts/Python/plasma/PlasmaNetConstants.py | 34 - Scripts/Python/plasma/PlasmaTypes.py | 820 -- Scripts/Python/plasma/PlasmaVaultConstants.py | 98 - Scripts/Python/plasma/glue.py | 208 - Scripts/Python/plasma/pch.py | 286 - Scripts/Python/plasma/ptWordFilter.py | 140 - Scripts/Python/system/Bastion.py | 177 - Scripts/Python/system/ConfigParser.py | 616 - Scripts/Python/system/HTMLParser.py | 382 - Scripts/Python/system/StringIO.py | 251 - Scripts/Python/system/UserDict.py | 164 - Scripts/Python/system/__future__.py | 104 - Scripts/Python/system/ascii.py | 35 - Scripts/Python/system/atexit.py | 50 - Scripts/Python/system/bdb.py | 564 - Scripts/Python/system/bisect.py | 78 - Scripts/Python/system/calendar.py | 246 - Scripts/Python/system/cmd.py | 396 - Scripts/Python/system/codecs.py | 712 -- Scripts/Python/system/colorsys.py | 123 - Scripts/Python/system/commands.py | 84 - Scripts/Python/system/compileall.py | 155 - Scripts/Python/system/copy.py | 430 - Scripts/Python/system/copy_reg.py | 189 - Scripts/Python/system/decompyle.py | 1500 --- Scripts/Python/system/difflib.py | 1317 -- Scripts/Python/system/dircache.py | 44 - Scripts/Python/system/dis.py | 227 - Scripts/Python/system/dospath.py | 341 - Scripts/Python/system/encoding_utf_8.py | 30 - Scripts/Python/system/encodings.py | 132 - Scripts/Python/system/filecmp.py | 306 - Scripts/Python/system/fileinput.py | 359 - Scripts/Python/system/fnmatch.py | 107 - Scripts/Python/system/fpformat.py | 142 - Scripts/Python/system/getopt.py | 211 - Scripts/Python/system/gettext.py | 493 - Scripts/Python/system/glob.py | 56 - Scripts/Python/system/ihooks.py | 514 - Scripts/Python/system/imghdr.py | 154 - Scripts/Python/system/imputil.py | 719 -- Scripts/Python/system/inspect.py | 799 -- Scripts/Python/system/keyword.py | 97 - Scripts/Python/system/knee.py | 126 - Scripts/Python/system/linecache.py | 100 - Scripts/Python/system/locale.py | 778 -- Scripts/Python/system/markupbase.py | 383 - Scripts/Python/system/mutex.py | 50 - Scripts/Python/system/netrc.py | 111 - Scripts/Python/system/ntpath.py | 493 - Scripts/Python/system/opcode.py | 188 - Scripts/Python/system/os.py | 659 - Scripts/Python/system/pdb.py | 957 -- Scripts/Python/system/pickle.py | 1403 --- Scripts/Python/system/popen2.py | 202 - Scripts/Python/system/posixpath.py | 414 - Scripts/Python/system/pre.py | 656 - Scripts/Python/system/profile.py | 555 - Scripts/Python/system/pstats.py | 646 - Scripts/Python/system/py_compile.py | 164 - Scripts/Python/system/pyclbr.py | 344 - Scripts/Python/system/random.py | 843 -- Scripts/Python/system/re.py | 6 - Scripts/Python/system/regex_syntax.py | 53 - Scripts/Python/system/repr.py | 117 - Scripts/Python/system/shlex.py | 292 - Scripts/Python/system/shutil.py | 171 - Scripts/Python/system/site.py | 376 - Scripts/Python/system/spark.py | 566 - Scripts/Python/system/sre.py | 311 - Scripts/Python/system/sre_compile.py | 487 - Scripts/Python/system/sre_constants.py | 261 - Scripts/Python/system/sre_parse.py | 739 -- Scripts/Python/system/stat.py | 86 - Scripts/Python/system/statcache.py | 77 - Scripts/Python/system/string.py | 382 - Scripts/Python/system/symbol.py | 97 - Scripts/Python/system/tabnanny.py | 326 - Scripts/Python/system/token.py | 140 - Scripts/Python/system/tokenize.py | 295 - Scripts/Python/system/traceback.py | 301 - Scripts/Python/system/types.py | 90 - Scripts/Python/system/verify.py | 182 - Scripts/Python/system/warnings.py | 259 - Scripts/Python/system/weakref.py | 302 - Scripts/Python/system/webbrowser.py | 369 - Scripts/Python/system/whrandom.py | 140 - .../python/Do_Not_Load_Neighborhood.py | 486 - .../python/Do_Not_Load_RestorationGuild.py | 496 - .../python/plasma/placeholder.txt | 1 - Scripts/ServerPython/python/system/Bastion.py | 175 - .../python/system/ConfigParser.py | 472 - .../ServerPython/python/system/StringIO.py | 239 - .../ServerPython/python/system/__future__.py | 104 - Scripts/ServerPython/python/system/_sre.pyd | Bin 53340 -> 0 bytes Scripts/ServerPython/python/system/_sre_d.pyd | Bin 65630 -> 0 bytes Scripts/ServerPython/python/system/atexit.py | 50 - Scripts/ServerPython/python/system/bdb.py | 563 - Scripts/ServerPython/python/system/bisect.py | 78 - .../ServerPython/python/system/calendar.py | 246 - Scripts/ServerPython/python/system/cmd.py | 330 - Scripts/ServerPython/python/system/codecs.py | 636 - .../ServerPython/python/system/colorsys.py | 123 - .../ServerPython/python/system/commands.py | 84 - .../ServerPython/python/system/compileall.py | 148 - Scripts/ServerPython/python/system/copy.py | 378 - .../ServerPython/python/system/copy_reg.py | 72 - .../ServerPython/python/system/decompyle.py | 1500 --- Scripts/ServerPython/python/system/difflib.py | 1083 -- .../ServerPython/python/system/dircache.py | 44 - Scripts/ServerPython/python/system/dis.py | 327 - Scripts/ServerPython/python/system/dospath.py | 341 - Scripts/ServerPython/python/system/filecmp.py | 331 - .../ServerPython/python/system/fileinput.py | 349 - Scripts/ServerPython/python/system/fnmatch.py | 107 - .../ServerPython/python/system/fpformat.py | 142 - Scripts/ServerPython/python/system/getopt.py | 144 - Scripts/ServerPython/python/system/gettext.py | 304 - Scripts/ServerPython/python/system/glob.py | 56 - Scripts/ServerPython/python/system/ihooks.py | 511 - Scripts/ServerPython/python/system/imghdr.py | 154 - Scripts/ServerPython/python/system/imputil.py | 720 -- Scripts/ServerPython/python/system/inspect.py | 779 -- Scripts/ServerPython/python/system/keyword.py | 97 - Scripts/ServerPython/python/system/knee.py | 126 - .../ServerPython/python/system/linecache.py | 101 - Scripts/ServerPython/python/system/locale.py | 734 -- Scripts/ServerPython/python/system/mutex.py | 51 - Scripts/ServerPython/python/system/netrc.py | 108 - Scripts/ServerPython/python/system/ntpath.py | 481 - Scripts/ServerPython/python/system/os.py | 612 - Scripts/ServerPython/python/system/pdb.py | 957 -- Scripts/ServerPython/python/system/pickle.py | 986 -- Scripts/ServerPython/python/system/popen2.py | 199 - .../ServerPython/python/system/posixpath.py | 414 - Scripts/ServerPython/python/system/pre.py | 656 - Scripts/ServerPython/python/system/profile.py | 556 - Scripts/ServerPython/python/system/pstats.py | 641 - .../ServerPython/python/system/py_compile.py | 82 - Scripts/ServerPython/python/system/pyclbr.py | 337 - Scripts/ServerPython/python/system/random.py | 777 -- Scripts/ServerPython/python/system/re.py | 33 - .../python/system/regex_syntax.py | 53 - Scripts/ServerPython/python/system/repr.py | 95 - Scripts/ServerPython/python/system/shlex.py | 209 - Scripts/ServerPython/python/system/shutil.py | 138 - Scripts/ServerPython/python/system/site.py | 330 - Scripts/ServerPython/python/system/spark.py | 566 - Scripts/ServerPython/python/system/sre.py | 311 - .../ServerPython/python/system/sre_compile.py | 455 - .../python/system/sre_constants.py | 259 - .../ServerPython/python/system/sre_parse.py | 738 -- Scripts/ServerPython/python/system/stat.py | 86 - .../ServerPython/python/system/statcache.py | 77 - Scripts/ServerPython/python/system/string.py | 382 - Scripts/ServerPython/python/system/symbol.py | 95 - .../ServerPython/python/system/tabnanny.py | 327 - Scripts/ServerPython/python/system/token.py | 140 - .../ServerPython/python/system/tokenize.py | 286 - .../ServerPython/python/system/traceback.py | 301 - Scripts/ServerPython/python/system/types.py | 86 - Scripts/ServerPython/python/system/verify.py | 182 - .../ServerPython/python/system/warnings.py | 258 - Scripts/ServerPython/python/system/weakref.py | 284 - .../ServerPython/python/system/whrandom.py | 140 - 642 files changed, 352584 deletions(-) delete mode 100644 SDKs/Win32/HawkVoice/lib/HawkVoiceDIstatic.lib delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/Blowfish.001 delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/Blowfish.dsp delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/COPYRIGHT delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/INSTALL delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile.ssl delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile.uni delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/README delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bf586.pl delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bx86-cpp.s delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bx86unix.cpp delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/asm/readme delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/asm/win32.asm delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/asm/x86ms.pl delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/asm/x86unix.pl delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/bf_cbc.c delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/bf_cfb64.c delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/bf_ecb.c delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/bf_enc.c delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/bf_locl.h delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/bf_locl.org delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/bf_ofb64.c delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/bf_pi.h delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/bf_skey.c delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/blowfish.doc delete mode 100644 SDKs/Win32/HawkVoice/src/BLOWFISH/blowfish.h delete mode 100644 SDKs/Win32/HawkVoice/src/hvdi.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Grammar/.cvsignore delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Grammar/Grammar delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/LICENSE delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/.cvsignore delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/Setup.config.in delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/Setup.dist delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/_bsddb.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/_codecsmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/_csv.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/_curses_panel.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/_cursesmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/_hotshot.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/_localemodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/_randommodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/_sre.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/_ssl.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/_testcapimodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/_tkinter.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/_weakref.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/addrinfo.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/almodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/ar_beos delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/arraymodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/audioop.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/binascii.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/bsddbmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/bz2module.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/cPickle.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/cStringIO.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/ccpython.cc delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/cdmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/cgen.py delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/cgensupport.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/cgensupport.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/clmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/cmathmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/config.c.in delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/cryptmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/cstubs delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/datetimemodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/dbmmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/dlmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/errnomodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/Makefile.in delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/ascii.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/asciitab.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/expat.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/iasciitab.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/internal.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/latin1tab.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/macconfig.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/nametab.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/utf8tab.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/winconfig.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlparse.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlrole.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlrole.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_impl.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_impl.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_ns.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/fcntlmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/flmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/fmmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/fpectlmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/fpetestmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/gc_weakref.txt delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/gcmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/gdbmmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/getaddrinfo.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/getbuildinfo.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/getnameinfo.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/getpath.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/glmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/grpmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/imageop.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/imgfile.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/itertoolsmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/ld_so_aix delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/ld_so_beos delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/linuxaudiodev.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/main.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/makesetup delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/makexp_aix delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/mathmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/md5.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/md5c.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/md5module.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/mmapmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/mpzmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/nismodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/operator.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/ossaudiodev.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/parsermodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/pcre-int.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/pcre.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/pcremodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/posixmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/puremodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/pwdmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/pyexpat.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/pypcre.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/python.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/readline.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/regexmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/regexpr.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/regexpr.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/resource.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/rgbimgmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/rotormodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/selectmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/sgimodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/shamodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/signalmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/socketmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/socketmodule.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/sre.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/sre_constants.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/stropmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/structmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/sunaudiodev.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/svmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/symtablemodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/syslogmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/termios.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/testcapi_long.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/threadmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/timemodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/timing.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/timingmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/tkappinit.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/unicodedata.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/unicodedata_db.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/unicodename_db.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/xreadlinesmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/xxmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/xxsubtype.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/yuv.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/yuvconvert.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/zipimport.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Modules/zlibmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/.cvsignore delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/abstract.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/boolobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/bufferobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/cellobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/classobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/cobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/complexobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/descrobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/dictnotes.txt delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/dictobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/enumobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/fileobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/floatobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/frameobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/funcobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/intobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/iterobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/listobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/listsort.txt delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/longobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/methodobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/moduleobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/object.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/obmalloc.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/rangeobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/sliceobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/stringobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/structseq.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/tupleobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/typeobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/unicodectype.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/unicodeobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/unicodetype_db.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Objects/weakrefobject.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/.cvsignore delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/PlasmaPack.cpp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/PlasmaPack.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/WinMain.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/_winreg.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/.cvsignore delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/PythonPowered.bmp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/README.txt delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/archive.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/extract.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/install.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/install.rc delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/resource.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/wininst.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/wininst.dsw delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/config.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/dl_nt.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/dllbase_nt.txt delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/.cvsignore delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.def delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.dsw delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/readme.txt delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/frozen_dllmain.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/getpathp.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/import_nt.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/make_versioninfo.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/msvcrtmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/Makefile delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/README.os2emx delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/config.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/dlfcn.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/dlfcn.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/dllentry.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/getpathp.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/pyconfig.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/python23.def delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/pythonpm.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/_tkinter.def delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/config.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/getpathp.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/makefile delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/makefile.omk delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/pyconfig.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/python.def delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/readme.txt delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/py.ico delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/pyc.ico delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/pycon.ico delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/python.mk delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/python_exe.rc delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/python_nt.rc delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/pythonnt_rc.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/pythonnt_rc_d.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/readme.txt delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/testpy.py delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/w9xpopen.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PC/winsound.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/.cvsignore delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/BUILDno.txt delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/Uninstal.wse delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/_bsddb.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/_csv.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/_socket.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/_sre.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/_sre_static.vcproj delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/_ssl.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/_ssl.mak delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/_symtable.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/_testcapi.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/_tkinter.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/build_ssl.py delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/bz2.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/datetime.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/field3.py delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/installer.bmp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/mmap.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/parser.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/pcbuild.dsw delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/pyexpat.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/python.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/python.iss delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/python20.wse delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore.vcproj delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore_dyn_server.vcproj delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore_static.vcproj delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythonw.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/readme.txt delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/rmpyc.py delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/rt.bat delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/select.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/unicodedata.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/w9xpopen.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/winreg.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/winsound.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/PCbuild/zlib.dsp delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/.cvsignore delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/acceler.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/bitset.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/firstsets.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/grammar.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/grammar.mak delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/grammar1.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/intrcheck.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/listnode.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/metagrammar.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/myreadline.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/node.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/parser.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/parser.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/parsetok.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/pgen.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/pgenmain.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/printgrammar.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/tokenizer.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/tokenizer.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Parser/tokenizer_pgen.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/.cvsignore delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/atof.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/bltinmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/ceval.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/codecs.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/compile.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/dup2.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/dynload_aix.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/dynload_atheos.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/dynload_beos.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/dynload_dl.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/dynload_hpux.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/dynload_mac.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/dynload_next.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/dynload_os2.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/dynload_shlib.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/dynload_stub.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/dynload_win.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/errors.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/exceptions.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/fmod.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/frozen.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/frozenmain.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/future.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/getargs.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/getcompiler.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/getcopyright.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/getcwd.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/getmtime.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/getopt.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/getplatform.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/getversion.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/graminit.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/hypot.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/import.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/import_pack.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/importdl.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/importdl.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/mactoolboxglue.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/marshal.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/memmove.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/modsupport.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/mysnprintf.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/mystrtoul.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/pyfpe.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/pystate.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/pythonrun.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/sigcheck.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/strdup.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/strerror.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/strtod.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/structmember.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/symtable.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/sysmodule.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/thread.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/thread_atheos.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/thread_beos.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/thread_cthread.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/thread_foobar.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/thread_lwp.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/thread_nt.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/thread_os2.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/thread_pth.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/thread_pthread.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/thread_sgi.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/thread_solaris.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/thread_wince.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/Python/traceback.c delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/README delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/XboxBuild/_sre_static.vcproj delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/XboxBuild/pythoncore_static.vcproj delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/Python.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/abstract.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/bitset.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/boolobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/bufferobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/cStringIO.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/cellobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/ceval.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/classobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/cobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/codecs.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/compile.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/complexobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/datetime.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/descrobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/dictobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/enumobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/errcode.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/eval.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/fileobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/floatobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/frameobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/funcobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/graminit.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/grammar.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/import.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/intobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/intrcheck.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/iterobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/listobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/longintrepr.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/longobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/marshal.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/metagrammar.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/methodobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/modsupport.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/moduleobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/node.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/object.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/objimpl.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/opcode.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/osdefs.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/parsetok.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/patchlevel.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/pgen.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/pgenheaders.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/py_curses.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/pydebug.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/pyerrors.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/pyfpe.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/pygetopt.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/pymactoolbox.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/pymem.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/pyport.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/pystate.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/pythonrun.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/pythread.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/rangeobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/sliceobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/stringobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/structmember.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/structseq.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/symtable.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/sysmodule.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/token.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/traceback.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/tupleobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/ucnhash.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/unicodeobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/include/weakrefobject.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/pyconfig_dyn/pyconfig.h delete mode 100644 SDKs/XPlatform/Cypython-2.3.3/pyconfig_static/pyconfig.h delete mode 100644 Scripts/Installer/LargeMOUL.nsi delete mode 100644 Scripts/Installer/MOUL.nsi delete mode 100644 Scripts/Installer/MOULInstaller.exe delete mode 100644 Scripts/Max/PlasmaExport.ms delete mode 100644 Scripts/Python/plasma/Plasma.py delete mode 100644 Scripts/Python/plasma/PlasmaConstants.py delete mode 100644 Scripts/Python/plasma/PlasmaControlKeys.py delete mode 100644 Scripts/Python/plasma/PlasmaGame.py delete mode 100644 Scripts/Python/plasma/PlasmaGameConstants.py delete mode 100644 Scripts/Python/plasma/PlasmaKITypes.py delete mode 100644 Scripts/Python/plasma/PlasmaNetConstants.py delete mode 100644 Scripts/Python/plasma/PlasmaTypes.py delete mode 100644 Scripts/Python/plasma/PlasmaVaultConstants.py delete mode 100644 Scripts/Python/plasma/glue.py delete mode 100644 Scripts/Python/plasma/pch.py delete mode 100644 Scripts/Python/plasma/ptWordFilter.py delete mode 100644 Scripts/Python/system/Bastion.py delete mode 100644 Scripts/Python/system/ConfigParser.py delete mode 100644 Scripts/Python/system/HTMLParser.py delete mode 100644 Scripts/Python/system/StringIO.py delete mode 100644 Scripts/Python/system/UserDict.py delete mode 100644 Scripts/Python/system/__future__.py delete mode 100644 Scripts/Python/system/ascii.py delete mode 100644 Scripts/Python/system/atexit.py delete mode 100644 Scripts/Python/system/bdb.py delete mode 100644 Scripts/Python/system/bisect.py delete mode 100644 Scripts/Python/system/calendar.py delete mode 100644 Scripts/Python/system/cmd.py delete mode 100644 Scripts/Python/system/codecs.py delete mode 100644 Scripts/Python/system/colorsys.py delete mode 100644 Scripts/Python/system/commands.py delete mode 100644 Scripts/Python/system/compileall.py delete mode 100644 Scripts/Python/system/copy.py delete mode 100644 Scripts/Python/system/copy_reg.py delete mode 100644 Scripts/Python/system/decompyle.py delete mode 100644 Scripts/Python/system/difflib.py delete mode 100644 Scripts/Python/system/dircache.py delete mode 100644 Scripts/Python/system/dis.py delete mode 100644 Scripts/Python/system/dospath.py delete mode 100644 Scripts/Python/system/encoding_utf_8.py delete mode 100644 Scripts/Python/system/encodings.py delete mode 100644 Scripts/Python/system/filecmp.py delete mode 100644 Scripts/Python/system/fileinput.py delete mode 100644 Scripts/Python/system/fnmatch.py delete mode 100644 Scripts/Python/system/fpformat.py delete mode 100644 Scripts/Python/system/getopt.py delete mode 100644 Scripts/Python/system/gettext.py delete mode 100644 Scripts/Python/system/glob.py delete mode 100644 Scripts/Python/system/ihooks.py delete mode 100644 Scripts/Python/system/imghdr.py delete mode 100644 Scripts/Python/system/imputil.py delete mode 100644 Scripts/Python/system/inspect.py delete mode 100644 Scripts/Python/system/keyword.py delete mode 100644 Scripts/Python/system/knee.py delete mode 100644 Scripts/Python/system/linecache.py delete mode 100644 Scripts/Python/system/locale.py delete mode 100644 Scripts/Python/system/markupbase.py delete mode 100644 Scripts/Python/system/mutex.py delete mode 100644 Scripts/Python/system/netrc.py delete mode 100644 Scripts/Python/system/ntpath.py delete mode 100644 Scripts/Python/system/opcode.py delete mode 100644 Scripts/Python/system/os.py delete mode 100644 Scripts/Python/system/pdb.py delete mode 100644 Scripts/Python/system/pickle.py delete mode 100644 Scripts/Python/system/popen2.py delete mode 100644 Scripts/Python/system/posixpath.py delete mode 100644 Scripts/Python/system/pre.py delete mode 100644 Scripts/Python/system/profile.py delete mode 100644 Scripts/Python/system/pstats.py delete mode 100644 Scripts/Python/system/py_compile.py delete mode 100644 Scripts/Python/system/pyclbr.py delete mode 100644 Scripts/Python/system/random.py delete mode 100644 Scripts/Python/system/re.py delete mode 100644 Scripts/Python/system/regex_syntax.py delete mode 100644 Scripts/Python/system/repr.py delete mode 100644 Scripts/Python/system/shlex.py delete mode 100644 Scripts/Python/system/shutil.py delete mode 100644 Scripts/Python/system/site.py delete mode 100644 Scripts/Python/system/spark.py delete mode 100644 Scripts/Python/system/sre.py delete mode 100644 Scripts/Python/system/sre_compile.py delete mode 100644 Scripts/Python/system/sre_constants.py delete mode 100644 Scripts/Python/system/sre_parse.py delete mode 100644 Scripts/Python/system/stat.py delete mode 100644 Scripts/Python/system/statcache.py delete mode 100644 Scripts/Python/system/string.py delete mode 100644 Scripts/Python/system/symbol.py delete mode 100644 Scripts/Python/system/tabnanny.py delete mode 100644 Scripts/Python/system/token.py delete mode 100644 Scripts/Python/system/tokenize.py delete mode 100644 Scripts/Python/system/traceback.py delete mode 100644 Scripts/Python/system/types.py delete mode 100644 Scripts/Python/system/verify.py delete mode 100644 Scripts/Python/system/warnings.py delete mode 100644 Scripts/Python/system/weakref.py delete mode 100644 Scripts/Python/system/webbrowser.py delete mode 100644 Scripts/Python/system/whrandom.py delete mode 100644 Scripts/ServerPython/python/Do_Not_Load_Neighborhood.py delete mode 100644 Scripts/ServerPython/python/Do_Not_Load_RestorationGuild.py delete mode 100644 Scripts/ServerPython/python/plasma/placeholder.txt delete mode 100644 Scripts/ServerPython/python/system/Bastion.py delete mode 100644 Scripts/ServerPython/python/system/ConfigParser.py delete mode 100644 Scripts/ServerPython/python/system/StringIO.py delete mode 100644 Scripts/ServerPython/python/system/__future__.py delete mode 100644 Scripts/ServerPython/python/system/_sre.pyd delete mode 100644 Scripts/ServerPython/python/system/_sre_d.pyd delete mode 100644 Scripts/ServerPython/python/system/atexit.py delete mode 100644 Scripts/ServerPython/python/system/bdb.py delete mode 100644 Scripts/ServerPython/python/system/bisect.py delete mode 100644 Scripts/ServerPython/python/system/calendar.py delete mode 100644 Scripts/ServerPython/python/system/cmd.py delete mode 100644 Scripts/ServerPython/python/system/codecs.py delete mode 100644 Scripts/ServerPython/python/system/colorsys.py delete mode 100644 Scripts/ServerPython/python/system/commands.py delete mode 100644 Scripts/ServerPython/python/system/compileall.py delete mode 100644 Scripts/ServerPython/python/system/copy.py delete mode 100644 Scripts/ServerPython/python/system/copy_reg.py delete mode 100644 Scripts/ServerPython/python/system/decompyle.py delete mode 100644 Scripts/ServerPython/python/system/difflib.py delete mode 100644 Scripts/ServerPython/python/system/dircache.py delete mode 100644 Scripts/ServerPython/python/system/dis.py delete mode 100644 Scripts/ServerPython/python/system/dospath.py delete mode 100644 Scripts/ServerPython/python/system/filecmp.py delete mode 100644 Scripts/ServerPython/python/system/fileinput.py delete mode 100644 Scripts/ServerPython/python/system/fnmatch.py delete mode 100644 Scripts/ServerPython/python/system/fpformat.py delete mode 100644 Scripts/ServerPython/python/system/getopt.py delete mode 100644 Scripts/ServerPython/python/system/gettext.py delete mode 100644 Scripts/ServerPython/python/system/glob.py delete mode 100644 Scripts/ServerPython/python/system/ihooks.py delete mode 100644 Scripts/ServerPython/python/system/imghdr.py delete mode 100644 Scripts/ServerPython/python/system/imputil.py delete mode 100644 Scripts/ServerPython/python/system/inspect.py delete mode 100644 Scripts/ServerPython/python/system/keyword.py delete mode 100644 Scripts/ServerPython/python/system/knee.py delete mode 100644 Scripts/ServerPython/python/system/linecache.py delete mode 100644 Scripts/ServerPython/python/system/locale.py delete mode 100644 Scripts/ServerPython/python/system/mutex.py delete mode 100644 Scripts/ServerPython/python/system/netrc.py delete mode 100644 Scripts/ServerPython/python/system/ntpath.py delete mode 100644 Scripts/ServerPython/python/system/os.py delete mode 100644 Scripts/ServerPython/python/system/pdb.py delete mode 100644 Scripts/ServerPython/python/system/pickle.py delete mode 100644 Scripts/ServerPython/python/system/popen2.py delete mode 100644 Scripts/ServerPython/python/system/posixpath.py delete mode 100644 Scripts/ServerPython/python/system/pre.py delete mode 100644 Scripts/ServerPython/python/system/profile.py delete mode 100644 Scripts/ServerPython/python/system/pstats.py delete mode 100644 Scripts/ServerPython/python/system/py_compile.py delete mode 100644 Scripts/ServerPython/python/system/pyclbr.py delete mode 100644 Scripts/ServerPython/python/system/random.py delete mode 100644 Scripts/ServerPython/python/system/re.py delete mode 100644 Scripts/ServerPython/python/system/regex_syntax.py delete mode 100644 Scripts/ServerPython/python/system/repr.py delete mode 100644 Scripts/ServerPython/python/system/shlex.py delete mode 100644 Scripts/ServerPython/python/system/shutil.py delete mode 100644 Scripts/ServerPython/python/system/site.py delete mode 100644 Scripts/ServerPython/python/system/spark.py delete mode 100644 Scripts/ServerPython/python/system/sre.py delete mode 100644 Scripts/ServerPython/python/system/sre_compile.py delete mode 100644 Scripts/ServerPython/python/system/sre_constants.py delete mode 100644 Scripts/ServerPython/python/system/sre_parse.py delete mode 100644 Scripts/ServerPython/python/system/stat.py delete mode 100644 Scripts/ServerPython/python/system/statcache.py delete mode 100644 Scripts/ServerPython/python/system/string.py delete mode 100644 Scripts/ServerPython/python/system/symbol.py delete mode 100644 Scripts/ServerPython/python/system/tabnanny.py delete mode 100644 Scripts/ServerPython/python/system/token.py delete mode 100644 Scripts/ServerPython/python/system/tokenize.py delete mode 100644 Scripts/ServerPython/python/system/traceback.py delete mode 100644 Scripts/ServerPython/python/system/types.py delete mode 100644 Scripts/ServerPython/python/system/verify.py delete mode 100644 Scripts/ServerPython/python/system/warnings.py delete mode 100644 Scripts/ServerPython/python/system/weakref.py delete mode 100644 Scripts/ServerPython/python/system/whrandom.py diff --git a/SDKs/Win32/HawkVoice/lib/HawkVoiceDIstatic.lib b/SDKs/Win32/HawkVoice/lib/HawkVoiceDIstatic.lib deleted file mode 100644 index 16b3e0d5b1e7d243a96bb7ff2d3747342169db03..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 189518 zcmd>n34Baf`~RKHWRZjkf*=ST8bY?oY8^`=G>9drs;o1FNXTMogD|2=MpRo}ELFO^ z)vD5>mLi$N7FA86)KV3+im0L`vF87M&b^b|nao7`>ihQneg0=YckWr9^PJ~w&w0*s zmfNv+OiJ98zV=>j#wIve=@Z}`5a?~}?PhQX`1u9#LDBXc$5nD%U;zL0{h8y!vN
  • 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 b3*P)s=Edv~=0&zN_hNRDd+AhxOQGuD${^)V diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/Blowfish.001 b/SDKs/Win32/HawkVoice/src/BLOWFISH/Blowfish.001 deleted file mode 100644 index d5cbae6d..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/Blowfish.001 +++ /dev/null @@ -1,122 +0,0 @@ -# Microsoft Developer Studio Project File - Name="blowfish" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 5.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=blowfish - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "Blowfish.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "Blowfish.mak" CFG="blowfish - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "blowfish - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "blowfish - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe - -!IF "$(CFG)" == "blowfish - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /GB /Za /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "blowfish - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /GB /Za /W4 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "blowfish - Win32 Release" -# Name "blowfish - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter ".c" -# Begin Source File - -SOURCE=.\bf_cbc.c -# End Source File -# Begin Source File - -SOURCE=.\bf_cfb64.c -# End Source File -# Begin Source File - -SOURCE=.\bf_ecb.c -# End Source File -# Begin Source File - -SOURCE=.\bf_enc.c -# End Source File -# Begin Source File - -SOURCE=.\bf_ofb64.c -# End Source File -# Begin Source File - -SOURCE=.\bf_skey.c -# End Source File -# End Group -# Begin Group "Include Files" - -# PROP Default_Filter ".h" -# Begin Source File - -SOURCE=.\bf_locl.h -# End Source File -# Begin Source File - -SOURCE=.\bf_pi.h -# End Source File -# Begin Source File - -SOURCE=.\blowfish.h -# End Source File -# End Group -# End Target -# End Project diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/Blowfish.dsp b/SDKs/Win32/HawkVoice/src/BLOWFISH/Blowfish.dsp deleted file mode 100644 index f55ac27f..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/Blowfish.dsp +++ /dev/null @@ -1,128 +0,0 @@ -# Microsoft Developer Studio Project File - Name="blowfish" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=blowfish - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "Blowfish.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "Blowfish.mak" CFG="blowfish - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "blowfish - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "blowfish - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "blowfish - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /Za /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "blowfish - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /Za /W4 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "blowfish - Win32 Release" -# Name "blowfish - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter ".c" -# Begin Source File - -SOURCE=.\bf_cbc.c -# End Source File -# Begin Source File - -SOURCE=.\bf_cfb64.c -# End Source File -# Begin Source File - -SOURCE=.\bf_ecb.c -# End Source File -# Begin Source File - -SOURCE=.\bf_enc.c -# End Source File -# Begin Source File - -SOURCE=.\bf_ofb64.c -# End Source File -# Begin Source File - -SOURCE=.\bf_skey.c -# End Source File -# End Group -# Begin Group "Include Files" - -# PROP Default_Filter ".h" -# Begin Source File - -SOURCE=.\bf_locl.h -# End Source File -# Begin Source File - -SOURCE=.\bf_pi.h -# End Source File -# Begin Source File - -SOURCE=.\blowfish.h -# End Source File -# End Group -# End Target -# End Project diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/COPYRIGHT b/SDKs/Win32/HawkVoice/src/BLOWFISH/COPYRIGHT deleted file mode 100644 index 00529e75..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/COPYRIGHT +++ /dev/null @@ -1,46 +0,0 @@ -Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) -All rights reserved. - -This package is an Blowfish implementation written -by Eric Young (eay@mincom.oz.au). - -This library is free for commercial and non-commercial use as long as -the following conditions are aheared to. The following conditions -apply to all code found in this distribution. - -Copyright remains Eric Young's, and as such any Copyright notices in -the code are not to be removed. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. All advertising materials mentioning features or use of this software - must display the following acknowledgement: - This product includes software developed by Eric Young (eay@mincom.oz.au) - -THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. - -The license and distribution terms for any publically available version or -derivative of this code cannot be changed. i.e. this code cannot simply be -copied and put under another distrubution license -[including the GNU Public License.] - -The reason behind this being stated in this direct manner is past -experience in code simply being copied and the attribution removed -from it and then being distributed as part of other packages. This -implementation was a non-trivial and unpaid effort. diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/INSTALL b/SDKs/Win32/HawkVoice/src/BLOWFISH/INSTALL deleted file mode 100644 index fa86cb45..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/INSTALL +++ /dev/null @@ -1,14 +0,0 @@ -This Eric Young's blowfish implementation, taken from his SSLeay library -and made available as a separate library. - -The version number (0.7.2m) is the SSLeay version that this library was -taken from. - -To build, just unpack and type make. -If you are not using gcc, edit the Makefile. -If you are compiling for an x86 box, try the assembler (it needs improving). -There are also some compile time options that can improve performance, -these are documented in the Makefile. - -eric 15-Apr-1997 - diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile b/SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile deleted file mode 100644 index 03e910aa..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile +++ /dev/null @@ -1,160 +0,0 @@ -# Targets -# make - twidle the options yourself :-) -# make cc - standard cc options -# make gcc - standard gcc options -# make x86-elf - linux-elf etc -# make x86-out - linux-a.out, FreeBSD etc -# make x86-solaris -# make x86-bdsi - -# use BF_PTR2 for intel boxes, -# BF_PTR for sparc and MIPS/SGI -# use nothing for Alpha and HP. - -# There are 3 possible performance options, experiment :-) -#OPTS= -DBF_PTR # usr for sparc and MIPS/SGI -#OPTS= -DBF_PTR2 # use for pentium -#OPTS= # use for pentium pro, Alpha and HP - -MAKE=make -f Makefile -CC=cc -CFLAG= -O - -#CC=gcc -#CFLAG= -O4 -funroll-loops -fomit-frame-pointer -#CFLAG= -O3 -fomit-frame-pointer - -CFLAGS=$(OPTS) $(CFLAG) -CPP=$(CC) -E -AS=as - -# Assember version of bf_encrypt(). -BF_ENC=bf_enc.o # normal C version -#BF_ENC=asm/bx86-elf.o # elf format x86 -#BF_ENC=asm/bx86-out.o # a.out format x86 -#BF_ENC=asm/bx86-sol.o # solaris format x86 -#BF_ENC=asm/bx86bsdi.o # bsdi format x86 - -LIBDIR=/usr/local/lib -BINDIR=/usr/local/bin -INCDIR=/usr/local/include -MANDIR=/usr/local/man -MAN1=1 -MAN3=3 -SHELL=/bin/sh -LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cbc.o bf_cfb64.o bf_ofb64.o -LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cbc.c bf_cfb64.c bf_ofb64.c - -GENERAL=Makefile Makefile.ssl Makefile.uni asm bf_locl.org README \ - COPYRIGHT INSTALL blowfish.doc - -TESTING= bftest bfspeed -TESTING_SRC=bftest.c bfspeed.c -HEADERS=bf_locl.h blowfish.h bf_pi.h - -ALL= $(GENERAL) $(TESTING_SRC) $(LIBSRC) $(HEADERS) - -BLIB= libblowfish.a - -all: $(BLIB) $(TESTING) - -cc: - $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all - -gcc: - $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all - -x86-elf: - $(MAKE) BF_ENC='asm/bx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all - -x86-out: - $(MAKE) BF_ENC='asm/bx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all - -x86-solaris: - $(MAKE) BF_ENC='asm/bx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all - -x86-bsdi: - $(MAKE) BF_ENC='asm/bx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all - -# elf -asm/bx86-elf.o: asm/bx86-cpp.s asm/bx86unix.cpp - $(CPP) -DELF asm/bx86unix.cpp | $(AS) -o asm/bx86-elf.o - -# solaris -asm/bx86-sol.o: asm/bx86-cpp.s asm/bx86unix.cpp - $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s - as -o asm/bx86-sol.o asm/bx86-sol.s - rm -f asm/bx86-sol.s - -# a.out -asm/bx86-out.o: asm/bx86-cpp.s asm/bx86unix.cpp - $(CPP) -DOUT asm/bx86unix.cpp | $(AS) -o asm/bx86-out.o - -# bsdi -asm/bx86bsdi.o: asm/bx86-cpp.s asm/bx86unix.cpp - $(CPP) -DBSDI asm/bx86unix.cpp | $(AS) -o asm/bx86bsdi.o - -test: all - ./bftest - -$(BLIB): $(LIBOBJ) - /bin/rm -f $(BLIB) - ar cr $(BLIB) $(LIBOBJ) - -if test -s /bin/ranlib; then /bin/ranlib $(BLIB); \ - else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(BLIB); \ - else exit 0; fi; fi - -bftest: bftest.o $(BLIB) - $(CC) $(CFLAGS) -o bftest bftest.o $(BLIB) - -bfspeed: bfspeed.o $(BLIB) - $(CC) $(CFLAGS) -o bfspeed bfspeed.o $(BLIB) - -tags: - ctags $(TESTING_SRC) $(LIBBF) - -tar: - tar chf libbf.tar $(ALL) - -shar: - shar $(ALL) >libbf.shar - -depend: - makedepend $(LIBBF) $(TESTING_SRC) - -clean: - rm -f *.o tags core $(TESTING) $(BLIB) .nfs* *.old *.bak asm/*.o - -dclean: - sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new - mv -f Makefile.new Makefile - -# Eric is probably going to choke when he next looks at this --tjh -install: $(BLIB) - if test $(INSTALLTOP); then \ - echo SSL style install; \ - cp $(BLIB) $(INSTALLTOP)/lib; \ - if test -s /bin/ranlib; then \ - /bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \ - else \ - if test -s /usr/bin/ranlib; then \ - /usr/bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \ - fi; fi; \ - chmod 644 $(INSTALLTOP)/lib/$(BLIB); \ - cp blowfish.h $(INSTALLTOP)/include; \ - chmod 644 $(INSTALLTOP)/include/blowfish.h; \ - else \ - echo Standalone install; \ - cp $(BLIB) $(LIBDIR)/$(BLIB); \ - if test -s /bin/ranlib; then \ - /bin/ranlib $(LIBDIR)/$(BLIB); \ - else \ - if test -s /usr/bin/ranlib; then \ - /usr/bin/ranlib $(LIBDIR)/$(BLIB); \ - fi; \ - fi; \ - chmod 644 $(LIBDIR)/$(BLIB); \ - cp blowfish.h $(INCDIR)/blowfish.h; \ - chmod 644 $(INCDIR)/blowfish.h; \ - fi -# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile.ssl b/SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile.ssl deleted file mode 100644 index e44786bf..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile.ssl +++ /dev/null @@ -1,104 +0,0 @@ -# -# SSLeay/crypto/blowfish/Makefile -# - -DIR= bf -TOP= ../.. -CC= cc -CPP= $(CC) -E -INCLUDES= -CFLAG=-g -INSTALLTOP=/usr/local/ssl -MAKE= make -f Makefile.ssl -MAKEDEPEND= makedepend -fMakefile.ssl -MAKEFILE= Makefile.ssl - -BF_ENC= bf_enc.o -# or use -#DES_ENC= bx86-elf.o - -CFLAGS= $(INCLUDES) $(CFLAG) - -GENERAL=Makefile -TEST=bftest.c -APPS= - -LIB=$(TOP)/libcrypto.a -LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cbc.c bf_cfb64.c bf_ofb64.c -LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cbc.o bf_cfb64.o bf_ofb64.o - -SRC= $(LIBSRC) - -EXHEADER= blowfish.h -HEADER= bf_pi.h bf_locl.h $(EXHEADER) - -ALL= $(GENERAL) $(SRC) $(HEADER) - -top: - (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) - -all: lib - -lib: $(LIBOBJ) - ar r $(LIB) $(LIBOBJ) - sh $(TOP)/util/ranlib.sh $(LIB) - @touch lib - -# elf -asm/bx86-elf.o: asm/bx86-cpp.s asm/bx86unix.cpp - $(CPP) -DELF asm/bx86unix.cpp | as -o asm/bx86-elf.o - -# solaris -asm/bx86-sol.o: asm/bx86-cpp.s asm/bx86unix.cpp - $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s - as -o asm/bx86-sol.o asm/bx86-sol.s - rm -f asm/bx86-sol.s - -# a.out -asm/bx86-out.o: asm/bx86-cpp.s asm/bx86unix.cpp - $(CPP) -DOUT asm/bx86unix.cpp | as -o asm/bx86-out.o - -# bsdi -asm/bx86bsdi.o: asm/bx86-cpp.s asm/bx86unix.cpp - $(CPP) -DBSDI asm/bx86unix.cpp | as -o asm/bx86bsdi.o - -files: - perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO - -links: - /bin/rm -f Makefile - $(TOP)/util/point.sh Makefile.ssl Makefile ; - /bin/rm -f des.doc - $(TOP)/util/point.sh ../../doc/blowfish.doc blowfish.doc ; - $(TOP)/util/mklink.sh ../../include $(EXHEADER) - $(TOP)/util/mklink.sh ../../test $(TEST) - $(TOP)/util/mklink.sh ../../apps $(APPS) - -install: - @for i in $(EXHEADER) ; \ - do \ - (cp $$i $(INSTALLTOP)/include/$$i; \ - chmod 644 $(INSTALLTOP)/include/$$i ); \ - done; - -tags: - ctags $(SRC) - -tests: - -lint: - lint -DLINT $(INCLUDES) $(SRC)>fluff - -depend: - $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) - -dclean: - perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new - mv -f Makefile.new $(MAKEFILE) - -clean: - /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff - -errors: - -# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile.uni b/SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile.uni deleted file mode 100644 index b0d2e26d..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile.uni +++ /dev/null @@ -1,160 +0,0 @@ -# Targets -# make - twidle the options yourself :-) -# make cc - standard cc options -# make gcc - standard gcc options -# make x86-elf - linux-elf etc -# make x86-out - linux-a.out, FreeBSD etc -# make x86-solaris -# make x86-bdsi - -# use BF_PTR2 for intel boxes, -# BF_PTR for sparc and MIPS/SGI -# use nothing for Alpha and HP. - -# There are 3 possible performance options, experiment :-) -OPTS= -DBF_PTR # usr for sparc and MIPS/SGI -#OPTS= -DBF_PTR2 # use for pentium -#OPTS= # use for pentium pro, Alpha and HP - -MAKE=make -f Makefile -#CC=cc -#CFLAG= -O - -CC=gcc -#CFLAG= -O4 -funroll-loops -fomit-frame-pointer -CFLAG= -O3 -fomit-frame-pointer - -CFLAGS=$(OPTS) $(CFLAG) -CPP=$(CC) -E -AS=as - -# Assember version of bf_encrypt(). -BF_ENC=bf_enc.o # normal C version -#BF_ENC=asm/bx86-elf.o # elf format x86 -#BF_ENC=asm/bx86-out.o # a.out format x86 -#BF_ENC=asm/bx86-sol.o # solaris format x86 -#BF_ENC=asm/bx86bsdi.o # bsdi format x86 - -LIBDIR=/usr/local/lib -BINDIR=/usr/local/bin -INCDIR=/usr/local/include -MANDIR=/usr/local/man -MAN1=1 -MAN3=3 -SHELL=/bin/sh -LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cbc.o bf_cfb64.o bf_ofb64.o -LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cbc.c bf_cfb64.c bf_ofb64.c - -GENERAL=Makefile Makefile.ssl Makefile.uni asm bf_locl.org README \ - COPYRIGHT INSTALL blowfish.doc - -TESTING= bftest bfspeed -TESTING_SRC=bftest.c bfspeed.c -HEADERS=bf_locl.h blowfish.h bf_pi.h - -ALL= $(GENERAL) $(TESTING_SRC) $(LIBSRC) $(HEADERS) - -BLIB= libblowfish.a - -all: $(BLIB) $(TESTING) - -cc: - $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all - -gcc: - $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all - -x86-elf: - $(MAKE) BF_ENC='asm/bx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all - -x86-out: - $(MAKE) BF_ENC='asm/bx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all - -x86-solaris: - $(MAKE) BF_ENC='asm/bx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all - -x86-bsdi: - $(MAKE) BF_ENC='asm/bx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all - -# elf -asm/bx86-elf.o: asm/bx86-cpp.s asm/bx86unix.cpp - $(CPP) -DELF asm/bx86unix.cpp | $(AS) -o asm/bx86-elf.o - -# solaris -asm/bx86-sol.o: asm/bx86-cpp.s asm/bx86unix.cpp - $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s - as -o asm/bx86-sol.o asm/bx86-sol.s - rm -f asm/bx86-sol.s - -# a.out -asm/bx86-out.o: asm/bx86-cpp.s asm/bx86unix.cpp - $(CPP) -DOUT asm/bx86unix.cpp | $(AS) -o asm/bx86-out.o - -# bsdi -asm/bx86bsdi.o: asm/bx86-cpp.s asm/bx86unix.cpp - $(CPP) -DBSDI asm/bx86unix.cpp | $(AS) -o asm/bx86bsdi.o - -test: all - ./bftest - -$(BLIB): $(LIBOBJ) - /bin/rm -f $(BLIB) - ar cr $(BLIB) $(LIBOBJ) - -if test -s /bin/ranlib; then /bin/ranlib $(BLIB); \ - else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(BLIB); \ - else exit 0; fi; fi - -bftest: bftest.o $(BLIB) - $(CC) $(CFLAGS) -o bftest bftest.o $(BLIB) - -bfspeed: bfspeed.o $(BLIB) - $(CC) $(CFLAGS) -o bfspeed bfspeed.o $(BLIB) - -tags: - ctags $(TESTING_SRC) $(LIBBF) - -tar: - tar chf libbf.tar $(ALL) - -shar: - shar $(ALL) >libbf.shar - -depend: - makedepend $(LIBBF) $(TESTING_SRC) - -clean: - /bin/rm -f *.o tags core $(TESTING) $(BLIB) .nfs* *.old *.bak asm/*.o - -dclean: - sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new - mv -f Makefile.new Makefile - -# Eric is probably going to choke when he next looks at this --tjh -install: $(BLIB) - if test $(INSTALLTOP); then \ - echo SSL style install; \ - cp $(BLIB) $(INSTALLTOP)/lib; \ - if test -s /bin/ranlib; then \ - /bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \ - else \ - if test -s /usr/bin/ranlib; then \ - /usr/bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \ - fi; fi; \ - chmod 644 $(INSTALLTOP)/lib/$(BLIB); \ - cp blowfish.h $(INSTALLTOP)/include; \ - chmod 644 $(INSTALLTOP)/include/blowfish.h; \ - else \ - echo Standalone install; \ - cp $(BLIB) $(LIBDIR)/$(BLIB); \ - if test -s /bin/ranlib; then \ - /bin/ranlib $(LIBDIR)/$(BLIB); \ - else \ - if test -s /usr/bin/ranlib; then \ - /usr/bin/ranlib $(LIBDIR)/$(BLIB); \ - fi; \ - fi; \ - chmod 644 $(LIBDIR)/$(BLIB); \ - cp blowfish.h $(INCDIR)/blowfish.h; \ - chmod 644 $(INCDIR)/blowfish.h; \ - fi -# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/README b/SDKs/Win32/HawkVoice/src/BLOWFISH/README deleted file mode 100644 index 84d77a78..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/README +++ /dev/null @@ -1,8 +0,0 @@ -This is a quick packaging up of my blowfish code into a library. -It has been lifted from SSLeay. -The copyright notices seem a little harsh because I have not spent the -time to rewrite the conditions from the normal SSLeay ones. - -Basically if you just want to play with the library, not a problem. - -eric 15-Apr-1997 diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bf586.pl b/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bf586.pl deleted file mode 100644 index 67fb7ee2..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bf586.pl +++ /dev/null @@ -1,159 +0,0 @@ - -#!/usr/local/bin/perl - -$prog="bf586.pl"; - -# base code is in microsft -# op dest, source -# format. -# - -if ( ($ARGV[0] eq "elf")) - { require "x86unix.pl"; } -elsif ( ($ARGV[0] eq "a.out")) - { $aout=1; require "x86unix.pl"; } -elsif ( ($ARGV[0] eq "sol")) - { $sol=1; require "x86unix.pl"; } -elsif ( ($ARGV[0] eq "cpp")) - { $cpp=1; require "x86unix.pl"; } -elsif ( ($ARGV[0] eq "win32")) - { require "x86ms.pl"; } -else - { - print STDERR <<"EOF"; -Pick one target type from - elf - linux, FreeBSD etc - a.out - old linux - sol - x86 solaris - cpp - format so x86unix.cpp can be used - win32 - Windows 95/Windows NT -EOF - exit(1); - } - -&comment("Don't even think of reading this code"); -&comment("It was automatically generated by $prog"); -&comment("Which is a perl program used to generate the x86 assember for"); -&comment("any of elf, a.out, Win32, or Solaris"); -&comment("It can be found in SSLeay 0.7.0+"); -&comment("eric "); -&comment(""); - -&file("bfx86xxxx"); - -$BF_ROUNDS=16; -$BF_OFF=($BF_ROUNDS+2)*4; -$L="ecx"; -$R="edx"; -$P="edi"; -$tot="esi"; -$tmp1="eax"; -$tmp2="ebx"; -$tmp3="ebp"; - -&des_encrypt("BF_encrypt"); - -&file_end(); - -sub des_encrypt - { - local($name)=@_; - - &function_begin($name,3); - - &comment(""); - &comment("Load the 2 words"); - &mov("eax",&wparam(0)); - &mov($L,&DWP(0,"eax","",0)); - &mov($R,&DWP(4,"eax","",0)); - - &comment(""); - &comment("P pointer, s and enc flag"); - &mov($P,&wparam(1)); - - &xor( $tmp1, $tmp1); - &xor( $tmp2, $tmp2); - - # encrypting part - - &mov("ebp",&wparam(2)); # get encrypt flag - &cmp("ebp","0"); - &je(&label("start_decrypt")); - - &xor($L,&DWP(0,$P,"",0)); - for ($i=0; $i<$BF_ROUNDS; $i+=2) - { - &comment(""); - &comment("Round $i"); - &BF_ENCRYPT($i+1,$R,$L,$P,$tot,$tmp1,$tmp2,$tmp3); - - &comment(""); - &comment("Round ".sprintf("%d",$i+1)); - &BF_ENCRYPT($i+2,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3); - } - &xor($R,&DWP(($BF_ROUNDS+1)*4,$P,"",0)); - - &mov("eax",&wparam(0)); - &mov(&DWP(0,"eax","",0),$R); - &mov(&DWP(4,"eax","",0),$L); - &function_end_A($name); - - &set_label("start_decrypt"); - - &xor($L,&DWP(($BF_ROUNDS+1)*4,$P,"",0)); - for ($i=$BF_ROUNDS; $i>0; $i-=2) - { - &comment(""); - &comment("Round $i"); - &BF_ENCRYPT($i,$R,$L,$P,$tot,$tmp1,$tmp2,$tmp3); - &comment(""); - &comment("Round ".sprintf("%d",$i-1)); - &BF_ENCRYPT($i-1,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3); - } - &xor($R,&DWP(0,$P,"",0)); - - &mov("eax",&wparam(0)); - &mov(&DWP(0,"eax","",0),$R); - &mov(&DWP(4,"eax","",0),$L); - &function_end_A($name); - - &function_end_B($name); - } - -sub BF_ENCRYPT - { - local($i,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3)=@_; - - &rotr( $R, 16); - &mov( $tot, &DWP(&n2a($i*4),$P,"",0)); - - &movb( &LB($tmp1), &HB($R)); - &movb( &LB($tmp2), &LB($R)); - - &rotr( $R, 16); - &xor( $L, $tot); - - &mov( $tot, &DWP(&n2a($BF_OFF+0x0000),$P,$tmp1,4)); - &mov( $tmp3, &DWP(&n2a($BF_OFF+0x0400),$P,$tmp2,4)); - - &movb( &LB($tmp1), &HB($R)); - &movb( &LB($tmp2), &LB($R)); - - &add( $tot, $tmp3); - &mov( $tmp1, &DWP(&n2a($BF_OFF+0x0800),$P,$tmp1,4)); # delay - - &xor( $tot, $tmp1); - &mov( $tmp3, &DWP(&n2a($BF_OFF+0x0C00),$P,$tmp2,4)); - - &add( $tot, $tmp3); - &xor( $tmp1, $tmp1); - - &xor( $L, $tot); - # delay - } - -sub n2a - { - sprintf("%d",$_[0]); - } - diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bx86-cpp.s b/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bx86-cpp.s deleted file mode 100644 index 47babe26..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bx86-cpp.s +++ /dev/null @@ -1,666 +0,0 @@ - /* Don't even think of reading this code */ - /* It was automatically generated by bf586.pl */ - /* Which is a perl program used to generate the x86 assember for */ - /* any of elf, a.out, Win32, or Solaris */ - /* It can be found in SSLeay 0.7.0+ */ - /* eric */ - - .file "bfx86xxxx.s" - .version "01.01" -gcc2_compiled.: -.text - .align ALIGN -.globl BF_encrypt - TYPE(BF_encrypt,@function) -BF_encrypt: - pushl %ebp - pushl %ebx - pushl %esi - pushl %edi - - - /* Load the 2 words */ - movl 20(%esp), %eax - movl (%eax), %ecx - movl 4(%eax), %edx - - /* P pointer, s and enc flag */ - movl 24(%esp), %edi - xorl %eax, %eax - xorl %ebx, %ebx - movl 28(%esp), %ebp - cmpl $0, %ebp - je .L000start_decrypt - xorl (%edi), %ecx - - /* Round 0 */ - rorl $16, %ecx - movl 4(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 1 */ - rorl $16, %edx - movl 8(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - - /* Round 2 */ - rorl $16, %ecx - movl 12(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 3 */ - rorl $16, %edx - movl 16(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - - /* Round 4 */ - rorl $16, %ecx - movl 20(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 5 */ - rorl $16, %edx - movl 24(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - - /* Round 6 */ - rorl $16, %ecx - movl 28(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 7 */ - rorl $16, %edx - movl 32(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - - /* Round 8 */ - rorl $16, %ecx - movl 36(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 9 */ - rorl $16, %edx - movl 40(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - - /* Round 10 */ - rorl $16, %ecx - movl 44(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 11 */ - rorl $16, %edx - movl 48(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - - /* Round 12 */ - rorl $16, %ecx - movl 52(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 13 */ - rorl $16, %edx - movl 56(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - - /* Round 14 */ - rorl $16, %ecx - movl 60(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 15 */ - rorl $16, %edx - movl 64(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - xorl 68(%edi), %edx - movl 20(%esp), %eax - movl %edx, (%eax) - movl %ecx, 4(%eax) - popl %edi - popl %esi - popl %ebx - popl %ebp - ret -.align ALIGN -.L000start_decrypt: - xorl 68(%edi), %ecx - - /* Round 16 */ - rorl $16, %ecx - movl 64(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 15 */ - rorl $16, %edx - movl 60(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - - /* Round 14 */ - rorl $16, %ecx - movl 56(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 13 */ - rorl $16, %edx - movl 52(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - - /* Round 12 */ - rorl $16, %ecx - movl 48(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 11 */ - rorl $16, %edx - movl 44(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - - /* Round 10 */ - rorl $16, %ecx - movl 40(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 9 */ - rorl $16, %edx - movl 36(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - - /* Round 8 */ - rorl $16, %ecx - movl 32(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 7 */ - rorl $16, %edx - movl 28(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - - /* Round 6 */ - rorl $16, %ecx - movl 24(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 5 */ - rorl $16, %edx - movl 20(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - - /* Round 4 */ - rorl $16, %ecx - movl 16(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 3 */ - rorl $16, %edx - movl 12(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - - /* Round 2 */ - rorl $16, %ecx - movl 8(%edi), %esi - movb %ch, %al - movb %cl, %bl - rorl $16, %ecx - xorl %esi, %edx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %ch, %al - movb %cl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %edx - - /* Round 1 */ - rorl $16, %edx - movl 4(%edi), %esi - movb %dh, %al - movb %dl, %bl - rorl $16, %edx - xorl %esi, %ecx - movl 72(%edi,%eax,4),%esi - movl 1096(%edi,%ebx,4),%ebp - movb %dh, %al - movb %dl, %bl - addl %ebp, %esi - movl 2120(%edi,%eax,4),%eax - xorl %eax, %esi - movl 3144(%edi,%ebx,4),%ebp - addl %ebp, %esi - xorl %eax, %eax - xorl %esi, %ecx - xorl (%edi), %edx - movl 20(%esp), %eax - movl %edx, (%eax) - movl %ecx, 4(%eax) - popl %edi - popl %esi - popl %ebx - popl %ebp - ret -.BF_encrypt_end: - SIZE(BF_encrypt,.BF_encrypt_end-BF_encrypt) -.ident "desasm.pl" diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bx86unix.cpp b/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bx86unix.cpp deleted file mode 100644 index 98214534..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bx86unix.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -#define TYPE(a,b) .type a,b -#define SIZE(a,b) .size a,b - -#ifdef OUT -#define OK 1 -#define BF_encrypt _BF_encrypt -#define ALIGN 4 -#endif - -#ifdef BSDI -#define OK 1 -#define BF_encrypt _BF_encrypt -#define ALIGN 4 -#undef SIZE -#undef TYPE -#endif - -#if defined(ELF) || defined(SOL) -#define OK 1 -#define ALIGN 16 -#endif - -#ifndef OK -You need to define one of -ELF - elf systems - linux-elf, NetBSD and DG-UX -OUT - a.out systems - linux-a.out and FreeBSD -SOL - solaris systems, which are elf with strange comment lines -BSDI - a.out with a very primative version of as. -#endif - -#include "bx86-cpp.s" - diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/readme b/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/readme deleted file mode 100644 index d1b1702a..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/readme +++ /dev/null @@ -1,3 +0,0 @@ -If you want more of an idea of how this all works, -have a read of the readme file in SSLeay/crypto/des/asm. -SSLeay can be found at ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL. diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/win32.asm b/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/win32.asm deleted file mode 100644 index 42363d78..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/win32.asm +++ /dev/null @@ -1,663 +0,0 @@ - ; Don't even think of reading this code - ; It was automatically generated by bf586.pl - ; Which is a perl program used to generate the x86 assember for - ; any of elf, a.out, Win32, or Solaris - ; It can be found in SSLeay 0.7.0+ - ; eric - ; - TITLE bfx86xxxx.asm - .386 -.model FLAT -_TEXT SEGMENT -PUBLIC _BF_encrypt -EXTRN _des_SPtrans:DWORD -_BF_encrypt PROC NEAR - push ebp - push ebx - push esi - push edi - ; - ; Load the 2 words - mov eax, DWORD PTR 20[esp] - mov ecx, DWORD PTR [eax] - mov edx, DWORD PTR 4[eax] - ; - ; P pointer, s and enc flag - mov edi, DWORD PTR 24[esp] - xor eax, eax - xor ebx, ebx - mov ebp, DWORD PTR 28[esp] - cmp ebp, 0 - je $L000start_decrypt - xor ecx, DWORD PTR [edi] - ; - ; Round 0 - ror ecx, 16 - mov esi, DWORD PTR 4[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 1 - ror edx, 16 - mov esi, DWORD PTR 8[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - ; - ; Round 2 - ror ecx, 16 - mov esi, DWORD PTR 12[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 3 - ror edx, 16 - mov esi, DWORD PTR 16[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - ; - ; Round 4 - ror ecx, 16 - mov esi, DWORD PTR 20[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 5 - ror edx, 16 - mov esi, DWORD PTR 24[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - ; - ; Round 6 - ror ecx, 16 - mov esi, DWORD PTR 28[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 7 - ror edx, 16 - mov esi, DWORD PTR 32[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - ; - ; Round 8 - ror ecx, 16 - mov esi, DWORD PTR 36[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 9 - ror edx, 16 - mov esi, DWORD PTR 40[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - ; - ; Round 10 - ror ecx, 16 - mov esi, DWORD PTR 44[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 11 - ror edx, 16 - mov esi, DWORD PTR 48[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - ; - ; Round 12 - ror ecx, 16 - mov esi, DWORD PTR 52[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 13 - ror edx, 16 - mov esi, DWORD PTR 56[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - ; - ; Round 14 - ror ecx, 16 - mov esi, DWORD PTR 60[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 15 - ror edx, 16 - mov esi, DWORD PTR 64[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - xor edx, DWORD PTR 68[edi] - mov eax, DWORD PTR 20[esp] - mov DWORD PTR [eax],edx - mov DWORD PTR 4[eax],ecx - pop edi - pop esi - pop ebx - pop ebp - ret -$L000start_decrypt: - xor ecx, DWORD PTR 68[edi] - ; - ; Round 16 - ror ecx, 16 - mov esi, DWORD PTR 64[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 15 - ror edx, 16 - mov esi, DWORD PTR 60[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - ; - ; Round 14 - ror ecx, 16 - mov esi, DWORD PTR 56[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 13 - ror edx, 16 - mov esi, DWORD PTR 52[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - ; - ; Round 12 - ror ecx, 16 - mov esi, DWORD PTR 48[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 11 - ror edx, 16 - mov esi, DWORD PTR 44[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - ; - ; Round 10 - ror ecx, 16 - mov esi, DWORD PTR 40[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 9 - ror edx, 16 - mov esi, DWORD PTR 36[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - ; - ; Round 8 - ror ecx, 16 - mov esi, DWORD PTR 32[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 7 - ror edx, 16 - mov esi, DWORD PTR 28[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - ; - ; Round 6 - ror ecx, 16 - mov esi, DWORD PTR 24[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 5 - ror edx, 16 - mov esi, DWORD PTR 20[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - ; - ; Round 4 - ror ecx, 16 - mov esi, DWORD PTR 16[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 3 - ror edx, 16 - mov esi, DWORD PTR 12[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - ; - ; Round 2 - ror ecx, 16 - mov esi, DWORD PTR 8[edi] - mov al, ch - mov bl, cl - ror ecx, 16 - xor edx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, ch - mov bl, cl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor edx, esi - ; - ; Round 1 - ror edx, 16 - mov esi, DWORD PTR 4[edi] - mov al, dh - mov bl, dl - ror edx, 16 - xor ecx, esi - mov esi, DWORD PTR 72[eax*4+edi] - mov ebp, DWORD PTR 1096[ebx*4+edi] - mov al, dh - mov bl, dl - add esi, ebp - mov eax, DWORD PTR 2120[eax*4+edi] - xor esi, eax - mov ebp, DWORD PTR 3144[ebx*4+edi] - add esi, ebp - xor eax, eax - xor ecx, esi - xor edx, DWORD PTR [edi] - mov eax, DWORD PTR 20[esp] - mov DWORD PTR [eax],edx - mov DWORD PTR 4[eax],ecx - pop edi - pop esi - pop ebx - pop ebp - ret -_BF_encrypt ENDP -_TEXT ENDS -END diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/x86ms.pl b/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/x86ms.pl deleted file mode 100644 index d85bdfe8..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/x86ms.pl +++ /dev/null @@ -1,249 +0,0 @@ -#!/usr/local/bin/perl - -package x86ms; - -$label="L000"; - -%lb=( 'eax', 'al', - 'ebx', 'bl', - 'ecx', 'cl', - 'edx', 'dl', - 'ax', 'al', - 'bx', 'bl', - 'cx', 'cl', - 'dx', 'dl', - ); - -%hb=( 'eax', 'ah', - 'ebx', 'bh', - 'ecx', 'ch', - 'edx', 'dh', - 'ax', 'ah', - 'bx', 'bh', - 'cx', 'ch', - 'dx', 'dh', - ); - -sub main'LB - { - (defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n"; - return($lb{$_[0]}); - } - -sub main'HB - { - (defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n"; - return($hb{$_[0]}); - } - -sub main'DWP - { - local($addr,$reg1,$reg2,$idx)=@_; - local($t); - local($ret)="DWORD PTR "; - - $addr =~ s/^\s+//; - if ($addr =~ /^(.+)\+(.+)$/) - { - $reg2=&conv($1); - $addr="_$2"; - } - elsif ($addr =~ /^[_a-zA-Z]/) - { - $addr="_$addr"; - } - - $reg1="$regs{$reg1}" if defined($regs{$reg1}); - $reg2="$regs{$reg2}" if defined($regs{$reg2}); - $ret.=$addr if ($addr ne "") && ($addr ne 0); - if ($reg2 ne "") - { - $t=""; - $t="*$idx" if ($idx != 0); - $ret.="[$reg2$t+$reg1]"; - } - else - { - $ret.="[$reg1]" - } - return($ret); - } - -sub main'mov { &out2("mov",@_); } -sub main'movb { &out2("mov",@_); } -sub main'and { &out2("and",@_); } -sub main'or { &out2("or",@_); } -sub main'shl { &out2("shl",@_); } -sub main'shr { &out2("shr",@_); } -sub main'xor { &out2("xor",@_); } -sub main'add { &out2("add",@_); } -sub main'sub { &out2("sub",@_); } -sub main'rotl { &out2("rol",@_); } -sub main'rotr { &out2("ror",@_); } -sub main'exch { &out2("xchg",@_); } -sub main'cmp { &out2("cmp",@_); } -sub main'dec { &out1("dec",@_); } -sub main'jmp { &out1("jmp",@_); } -sub main'je { &out1("je",@_); } -sub main'jz { &out1("jz",@_); } -sub main'jnz { &out1("jnz",@_); } -sub main'push { &out1("push",@_); } -sub main'call { &out1("call",'_'.$_[0]); } - - -sub out2 - { - local($name,$p1,$p2)=@_; - local($l,$t); - - print "\t$name\t"; - $t=&conv($p1).","; - $l=length($t); - print $t; - $l=4-($l+9)/8; - print "\t" x $l; - print &conv($p2); - print "\n"; - } - -sub out1 - { - local($name,$p1)=@_; - local($l,$t); - - print "\t$name\t"; - print &conv($p1); - print "\n"; - } - -sub conv - { - local($p)=@_; - - $p =~ s/0x([0-9A-Fa-f]+)/0$1h/; - return $p; - } - -sub main'file - { - local($file)=@_; - - print <<"EOF"; - TITLE $file.asm - .386 -.model FLAT -EOF - } - -sub main'function_begin - { - local($func,$num)=@_; - - $params=$num*4; - - print <<"EOF"; -_TEXT SEGMENT -PUBLIC _$func -EXTRN _des_SPtrans:DWORD -_$func PROC NEAR - push ebp - push ebx - push esi - push edi -EOF - $stack=20; - } - -sub main'function_end - { - local($func)=@_; - - print <<"EOF"; - pop edi - pop esi - pop ebx - pop ebp - ret -_$func ENDP -_TEXT ENDS -EOF - $stack=0; - %label=(); - } - -sub main'function_end_A - { - local($func)=@_; - - print <<"EOF"; - pop edi - pop esi - pop ebx - pop ebp - ret -EOF - } - -sub main'function_end_B - { - local($func)=@_; - - print <<"EOF"; -_$func ENDP -_TEXT ENDS -EOF - $stack=0; - %label=(); - } - -sub main'file_end - { - print "END\n" - } - -sub main'wparam - { - local($num)=@_; - - return(&main'DWP($stack+$num*4,"esp","",0)); - } - -sub main'wtmp - { - local($num)=@_; - - return(&main'DWP($stack+$params+$num*4,"esp","",0)); - } - -sub main'comment - { - foreach (@_) - { - print "\t; $_\n"; - } - } - -sub main'label - { - if (!defined($label{$_[0]})) - { - $label{$_[0]}="\$${label}${_[0]}"; - $label++; - } - return($label{$_[0]}); - } - -sub main'set_label - { - if (!defined($label{$_[0]})) - { - $label{$_[0]}="${label}${_[0]}"; - $label++; - } - print "$label{$_[0]}:\n"; - } - -sub main'file_end - { - print "END\n"; - } diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/x86unix.pl b/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/x86unix.pl deleted file mode 100644 index 5c77f123..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/asm/x86unix.pl +++ /dev/null @@ -1,313 +0,0 @@ -#!/usr/local/bin/perl - -package x86ms; - -$label="L000"; - -$align=($main'aout)?"4":"16"; -$under=($main'aout)?"_":""; -$com_start=($main'sol)?"/":"#"; - -if ($main'cpp) - { - $align="ALIGN"; - $under=""; - $com_start='/*'; - $com_end='*/'; - } - -%lb=( 'eax', '%al', - 'ebx', '%bl', - 'ecx', '%cl', - 'edx', '%dl', - 'ax', '%al', - 'bx', '%bl', - 'cx', '%cl', - 'dx', '%dl', - ); - -%hb=( 'eax', '%ah', - 'ebx', '%bh', - 'ecx', '%ch', - 'edx', '%dh', - 'ax', '%ah', - 'bx', '%bh', - 'cx', '%ch', - 'dx', '%dh', - ); - -%regs=( 'eax', '%eax', - 'ebx', '%ebx', - 'ecx', '%ecx', - 'edx', '%edx', - 'esi', '%esi', - 'edi', '%edi', - 'ebp', '%ebp', - 'esp', '%esp', - ); - -sub main'LB - { - (defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n"; - return($lb{$_[0]}); - } - -sub main'HB - { - (defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n"; - return($hb{$_[0]}); - } - -sub main'DWP - { - local($addr,$reg1,$reg2,$idx)=@_; - - - $ret=""; - - $addr =~ s/(^|[+ \t])([A-Za-z_]+)($|[+ \t])/$1$under$2$3/; - - $reg1="$regs{$reg1}" if defined($regs{$reg1}); - $reg2="$regs{$reg2}" if defined($regs{$reg2}); - $ret.=$addr if ($addr ne "") && ($addr ne 0); - if ($reg2 ne "") - { - $ret.="($reg1,$reg2,$idx)"; - } - else - { - $ret.="($reg1)" - } - return($ret); - } - -sub main'BP - { - local($addr,$reg1,$reg2,$idx)=@_; - - - $ret=""; - - $addr =~ s/(^|[+ \t])([A-Za-z_]+)($|[+ \t])/$1$under$2$3/; - - $reg1="$regs{$reg1}" if defined($regs{$reg1}); - $reg2="$regs{$reg2}" if defined($regs{$reg2}); - $ret.=$addr if ($addr ne "") && ($addr ne 0); - if ($reg2 ne "") - { - $ret.="($reg1,$reg2,$idx)"; - } - else - { - $ret.="($reg1)" - } - return($ret); - } - -sub main'mov { &out2("movl",@_); } -sub main'movb { &out2("movb",@_); } -sub main'and { &out2("andl",@_); } -sub main'or { &out2("orl",@_); } -sub main'shl { &out2("sall",@_); } -sub main'shr { &out2("shrl",@_); } -sub main'xor { &out2("xorl",@_); } -sub main'add { &out2("addl",@_); } -sub main'sub { &out2("subl",@_); } -sub main'rotl { &out2("roll",@_); } -sub main'rotr { &out2("rorl",@_); } -sub main'exch { &out2("xchg",@_); } -sub main'cmp { &out2("cmpl",@_); } -sub main'jmp { &out1("jmp",@_); } -sub main'je { &out1("je",@_); } -sub main'jne { &out1("jne",@_); } -sub main'jnz { &out1("jnz",@_); } -sub main'jz { &out1("jz",@_); } -sub main'dec { &out1("decl",@_); } -sub main'push { &out1("pushl",@_); } -sub main'call { &out1("call",$under.$_[0]); } - - -sub out2 - { - local($name,$p1,$p2)=@_; - local($l,$ll,$t); - - print "\t$name\t"; - $t=&conv($p2).","; - $l=length($t); - print $t; - $ll=4-($l+9)/8; - print "\t" x $ll; - print &conv($p1); - print "\n"; - } - -sub out1 - { - local($name,$p1)=@_; - local($l,$t); - - print "\t$name\t"; - print &conv($p1); - print "\n"; - } - -sub conv - { - local($p)=@_; - -# $p =~ s/0x([0-9A-Fa-f]+)/0$1h/; - - $p=$regs{$p} if (defined($regs{$p})); - - $p =~ s/^([0-9A-Fa-f]+)$/\$$1/; - $p =~ s/^(0x[0-9A-Fa-f]+)$/\$$1/; - return $p; - } - -sub main'file - { - local($file)=@_; - - print <<"EOF"; - .file "$file.s" - .version "01.01" -gcc2_compiled.: -EOF - } - -sub main'function_begin - { - local($func,$num)=@_; - - $params=$num*4; - - $func=$under.$func; - - print <<"EOF"; -.text - .align $align -.globl $func -EOF - if ($main'cpp) - { printf("\tTYPE($func,\@function)\n"); } - else { printf("\t.type $func,\@function\n"); } - print <<"EOF"; -$func: - pushl %ebp - pushl %ebx - pushl %esi - pushl %edi - -EOF - $stack=20; - } - -sub main'function_end - { - local($func)=@_; - - $func=$under.$func; - - print <<"EOF"; - popl %edi - popl %esi - popl %ebx - popl %ebp - ret -.${func}_end: -EOF - if ($main'cpp) - { printf("\tSIZE($func,.${func}_end-$func)\n"); } - else { printf("\t.size\t$func,.${func}_end-$func\n"); } - print ".ident \"desasm.pl\"\n"; - $stack=0; - %label=(); - } - -sub main'function_end_A - { - local($func)=@_; - - print <<"EOF"; - popl %edi - popl %esi - popl %ebx - popl %ebp - ret -EOF - } - -sub main'function_end_B - { - local($func)=@_; - - $func=$under.$func; - - print <<"EOF"; -.${func}_end: -EOF - if ($main'cpp) - { printf("\tSIZE($func,.${func}_end-$func)\n"); } - else { printf("\t.size\t$func,.${func}_end-$func\n"); } - print ".ident \"desasm.pl\"\n"; - $stack=0; - %label=(); - } - -sub main'wparam - { - local($num)=@_; - - return(&main'DWP($stack+$num*4,"esp","",0)); - } - -sub main'wtmp_b - { - local($num,$b)=@_; - - return(&main'BP(-(($num+1)*4)+$b,"esp","",0)); - } - -sub main'wtmp - { - local($num)=@_; - - return(&main'DWP(-($num+1)*4,"esp","",0)); - } - -sub main'comment - { - foreach (@_) - { - if (/^\s*$/) - { print "\n"; } - else - { print "\t$com_start $_ $com_end\n"; } - } - } - -sub main'label - { - if (!defined($label{$_[0]})) - { - $label{$_[0]}=".${label}${_[0]}"; - $label++; - } - return($label{$_[0]}); - } - -sub main'set_label - { - if (!defined($label{$_[0]})) - { - $label{$_[0]}=".${label}${_[0]}"; - $label++; - } - print ".align $align\n"; - print "$label{$_[0]}:\n"; - } - -sub main'file_end - { - } diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_cbc.c b/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_cbc.c deleted file mode 100644 index b988f609..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_cbc.c +++ /dev/null @@ -1,143 +0,0 @@ -/* crypto/bf/bf_cbc.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@mincom.oz.au). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@mincom.oz.au)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@mincom.oz.au)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include "blowfish.h" -#include "bf_locl.h" - -void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length, BF_KEY *ks, - unsigned char *iv, int encrypt) -{ - register BF_LONG tin0,tin1; - register BF_LONG tout0,tout1,xor0,xor1; - register long l=length; - BF_LONG tin[2]; - - if (encrypt != 0) - { - n2l(iv,tout0); - n2l(iv,tout1); - iv-=8; - for (l-=8; l>=0; l-=8) - { - n2l(in,tin0); - n2l(in,tin1); - tin0^=tout0; - tin1^=tout1; - tin[0]=tin0; - tin[1]=tin1; - BF_encrypt(tin,ks,BF_ENCRYPT); - tout0=tin[0]; - tout1=tin[1]; - l2n(tout0,out); - l2n(tout1,out); - } - if (l != -8) - { - n2ln(in,tin0,tin1,l+8); - tin0^=tout0; - tin1^=tout1; - tin[0]=tin0; - tin[1]=tin1; - BF_encrypt(tin,ks,BF_ENCRYPT); - tout0=tin[0]; - tout1=tin[1]; - l2n(tout0,out); - l2n(tout1,out); - } - l2n(tout0,iv); - l2n(tout1,iv); - } - else - { - n2l(iv,xor0); - n2l(iv,xor1); - iv-=8; - for (l-=8; l>=0; l-=8) - { - n2l(in,tin0); - n2l(in,tin1); - tin[0]=tin0; - tin[1]=tin1; - BF_encrypt(tin,ks,BF_DECRYPT); - tout0=tin[0]^xor0; - tout1=tin[1]^xor1; - l2n(tout0,out); - l2n(tout1,out); - xor0=tin0; - xor1=tin1; - } - if (l != -8) - { - n2l(in,tin0); - n2l(in,tin1); - tin[0]=tin0; - tin[1]=tin1; - BF_encrypt(tin,ks,BF_DECRYPT); - tout0=tin[0]^xor0; - tout1=tin[1]^xor1; - l2nn(tout0,tout1,out,l+8); - xor0=tin0; - xor1=tin1; - } - l2n(xor0,iv); - l2n(xor1,iv); - } - tin0=tin1=tout0=tout1=xor0=xor1=0; - tin[0]=tin[1]=0; - } - diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_cfb64.c b/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_cfb64.c deleted file mode 100644 index 09c4cf9d..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_cfb64.c +++ /dev/null @@ -1,122 +0,0 @@ -/* crypto/bf/bf_cfb64.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@mincom.oz.au). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@mincom.oz.au)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@mincom.oz.au)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include "blowfish.h" -#include "bf_locl.h" - -/* The input and output encrypted as though 64bit cfb mode is being - * used. The extra state information to record how much of the - * 64bit block we have used is contained in *num; - */ - -void BF_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, BF_KEY *schedule, - unsigned char *ivec, int *num, int encrypt) -{ - register BF_LONG v0,v1,t; - register int n= *num; - register long l=length; - BF_LONG ti[2]; - unsigned char *iv,c,cc; - - iv=(unsigned char *)ivec; - if (encrypt != 0) - { - while (l-- != 0) - { - if (n == 0) - { - n2l(iv,v0); ti[0]=v0; - n2l(iv,v1); ti[1]=v1; - BF_encrypt((unsigned long *)ti,schedule,BF_ENCRYPT); - iv=(unsigned char *)ivec; - t=ti[0]; l2n(t,iv); - t=ti[1]; l2n(t,iv); - iv=(unsigned char *)ivec; - } - c= (unsigned char)(*(in++)^iv[n]); - *(out++)=c; - iv[n]=c; - n=(n+1)&0x07; - } - } - else - { - while (l-- != 0) - { - if (n == 0) - { - n2l(iv,v0); ti[0]=v0; - n2l(iv,v1); ti[1]=v1; - BF_encrypt((unsigned long *)ti,schedule,BF_ENCRYPT); - iv=(unsigned char *)ivec; - t=ti[0]; l2n(t,iv); - t=ti[1]; l2n(t,iv); - iv=(unsigned char *)ivec; - } - cc= *(in++); - c=iv[n]; - iv[n]=cc; - *(out++)=(unsigned char)(c^cc); - n=(n+1)&0x07; - } - } - v0=v1=ti[0]=ti[1]=t=0; - c=cc=(unsigned char)0; - *num=n; - } - diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_ecb.c b/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_ecb.c deleted file mode 100644 index 68ed7407..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_ecb.c +++ /dev/null @@ -1,91 +0,0 @@ -/* crypto/bf/bf_ecb.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@mincom.oz.au). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@mincom.oz.au)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@mincom.oz.au)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include "blowfish.h" -#include "bf_locl.h" - -/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' - * (From LECTURE NOTES IN COIMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, - * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993) - */ - -char *BF_version="BlowFish part of SSLeay 0.7.0 30-Jan-1997"; - -char *BF_options() - { -#ifdef BF_PTR - return("blowfish(ptr)"); -#elif defined(BF_PTR2) - return("blowfish(ptr2)"); -#else - return("blowfish(idx)"); -#endif - } - -void BF_ecb_encrypt(unsigned char *in, unsigned char *out, BF_KEY *ks, int encrypt) -{ - BF_LONG l,d[2]; - - n2l(in,l); d[0]=l; - n2l(in,l); d[1]=l; - BF_encrypt(d,ks,encrypt); - l=d[0]; l2n(l,out); - l=d[1]; l2n(l,out); - l=d[0]=d[1]=0; - } - diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_enc.c b/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_enc.c deleted file mode 100644 index e647a9a5..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_enc.c +++ /dev/null @@ -1,137 +0,0 @@ -/* crypto/bf/bf_enc.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@mincom.oz.au). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@mincom.oz.au)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@mincom.oz.au)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include "blowfish.h" -#include "bf_locl.h" - -/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' - * (From LECTURE NOTES IN COIMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, - * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993) - */ - -#if (BF_ROUNDS != 16) && (BF_ROUNDS != 20) -If you set BF_ROUNDS to some value other than 16 or 20, you will have -to modify the code. -#endif - -void BF_encrypt(BF_LONG *data, BF_KEY *key, int encrypt) -{ - register BF_LONG l,r,*p,*s; - - p=key->P; - s= &(key->S[0]); - l=data[0]; - r=data[1]; - - if (encrypt != 0) - { - l^=p[0]; - BF_ENC(r,l,s,p[ 1]); - BF_ENC(l,r,s,p[ 2]); - BF_ENC(r,l,s,p[ 3]); - BF_ENC(l,r,s,p[ 4]); - BF_ENC(r,l,s,p[ 5]); - BF_ENC(l,r,s,p[ 6]); - BF_ENC(r,l,s,p[ 7]); - BF_ENC(l,r,s,p[ 8]); - BF_ENC(r,l,s,p[ 9]); - BF_ENC(l,r,s,p[10]); - BF_ENC(r,l,s,p[11]); - BF_ENC(l,r,s,p[12]); - BF_ENC(r,l,s,p[13]); - BF_ENC(l,r,s,p[14]); - BF_ENC(r,l,s,p[15]); - BF_ENC(l,r,s,p[16]); -#if BF_ROUNDS == 20 - BF_ENC(r,l,s,p[17]); - BF_ENC(l,r,s,p[18]); - BF_ENC(r,l,s,p[19]); - BF_ENC(l,r,s,p[20]); -#endif - r^=p[BF_ROUNDS+1]; - } - else - { - l^=p[BF_ROUNDS+1]; -#if BF_ROUNDS == 20 - BF_ENC(r,l,s,p[20]); - BF_ENC(l,r,s,p[19]); - BF_ENC(r,l,s,p[18]); - BF_ENC(l,r,s,p[17]); -#endif - BF_ENC(r,l,s,p[16]); - BF_ENC(l,r,s,p[15]); - BF_ENC(r,l,s,p[14]); - BF_ENC(l,r,s,p[13]); - BF_ENC(r,l,s,p[12]); - BF_ENC(l,r,s,p[11]); - BF_ENC(r,l,s,p[10]); - BF_ENC(l,r,s,p[ 9]); - BF_ENC(r,l,s,p[ 8]); - BF_ENC(l,r,s,p[ 7]); - BF_ENC(r,l,s,p[ 6]); - BF_ENC(l,r,s,p[ 5]); - BF_ENC(r,l,s,p[ 4]); - BF_ENC(l,r,s,p[ 3]); - BF_ENC(r,l,s,p[ 2]); - BF_ENC(l,r,s,p[ 1]); - r^=p[0]; - } - data[1]=l&0xffffffff; - data[0]=r&0xffffffff; - } diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_locl.h b/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_locl.h deleted file mode 100644 index a03bbaf6..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_locl.h +++ /dev/null @@ -1,236 +0,0 @@ -/* crypto/bf/bf_local.h */ -/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@mincom.oz.au). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@mincom.oz.au)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@mincom.oz.au)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - * - * Always modify bf_locl.org since bf_locl.h is automatically generated from - * it during SSLeay configuration. - * - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - */ - -/* - Notwithstanding the above warning, bf_locl.h is *not* regenerated - in this stand-alone implementation. The following auto-configuration - based on compiler CPU identification was added by John Walker to - avoid having to modify the Makefile to choose the best optimisation - for an individual platform. -*/ - -#ifdef sparc -#define BF_PTR -#endif -#ifdef mips -#define BF_PTR -#endif -/* In addition, for best performance we should define BF_PTR2 for - Pentium and below x86 machines, but not define it for Pentium - Pro and above. I don't know of any compiler-independent way - to distinguish these platforms, so I'm leaving the optimisation - as best for the newer platforms. The actual performance difference - for this application is trivial in any case. */ - -#undef c2l -#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<<24L) - -/* NOTE - c is not incremented as per c2l */ -#undef c2ln -#define c2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ - case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ - case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ - case 5: l2|=((unsigned long)(*(--(c)))); \ - case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ - case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ - case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ - case 1: l1|=((unsigned long)(*(--(c)))); \ - } \ - } - -#undef l2c -#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24L)&0xff)) - -/* NOTE - c is not incremented as per l2c */ -#undef l2cn -#define l2cn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ - case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ - case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ - case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ - case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ - case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ - case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ - case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ - } \ - } - -/* NOTE - c is not incremented as per n2l */ -#define n2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c)))) ; \ - case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ - case 6: l2|=((unsigned long)(*(--(c))))<<16; \ - case 5: l2|=((unsigned long)(*(--(c))))<<24; \ - case 4: l1 =((unsigned long)(*(--(c)))) ; \ - case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ - case 2: l1|=((unsigned long)(*(--(c))))<<16; \ - case 1: l1|=((unsigned long)(*(--(c))))<<24; \ - } \ - } - -/* NOTE - c is not incremented as per l2n */ -#define l2nn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ - case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ - case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ - case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ - case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ - case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ - case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ - case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ - } \ - } - -#undef n2l -#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))) - -#undef l2n -#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) - -/* This is actually a big endian algorithm, the most significate byte - * is used to lookup array 0 */ - -/* use BF_PTR2 for intel boxes, - * BF_PTR for sparc and MIPS/SGI - * use nothing for Alpha and HP. - */ -#if !defined(BF_PTR) && !defined(BF_PTR2) -#undef BF_PTR -#endif - -#define BF_M 0x3fc -#define BF_0 22L -#define BF_1 14L -#define BF_2 6L -#define BF_3 2L /* left shift */ - -#if defined(BF_PTR2) - -/* This is basically a special pentium verson */ -#define BF_ENC(LL,R,S,P) \ - { \ - BF_LONG t,u,v; \ - u=R>>BF_0; \ - v=R>>BF_1; \ - u&=BF_M; \ - v&=BF_M; \ - t= *(BF_LONG *)((unsigned char *)&(S[ 0])+u); \ - u=R>>BF_2; \ - t+= *(BF_LONG *)((unsigned char *)&(S[256])+v); \ - v=R<>BF_0)&BF_M))+ \ - *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \ - *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \ - *(BF_LONG *)((unsigned char *)&(S[768])+((R<>24L) ] + \ - S[0x0100+((R>>16L)&0xff)])^ \ - S[0x0200+((R>> 8L)&0xff)])+ \ - S[0x0300+((R )&0xff)])&0xffffffff; -#endif diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_locl.org b/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_locl.org deleted file mode 100644 index 0a3983a6..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_locl.org +++ /dev/null @@ -1,215 +0,0 @@ -/* crypto/bf/bf_local.h */ -/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@mincom.oz.au). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@mincom.oz.au)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@mincom.oz.au)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - * - * Always modify bf_locl.org since bf_locl.h is automatically generated from - * it during SSLeay configuration. - * - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - */ - -#undef c2l -#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<<24L) - -/* NOTE - c is not incremented as per c2l */ -#undef c2ln -#define c2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ - case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ - case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ - case 5: l2|=((unsigned long)(*(--(c)))); \ - case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ - case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ - case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ - case 1: l1|=((unsigned long)(*(--(c)))); \ - } \ - } - -#undef l2c -#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24L)&0xff)) - -/* NOTE - c is not incremented as per l2c */ -#undef l2cn -#define l2cn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ - case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ - case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ - case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ - case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ - case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ - case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ - case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ - } \ - } - -/* NOTE - c is not incremented as per n2l */ -#define n2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c)))) ; \ - case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ - case 6: l2|=((unsigned long)(*(--(c))))<<16; \ - case 5: l2|=((unsigned long)(*(--(c))))<<24; \ - case 4: l1 =((unsigned long)(*(--(c)))) ; \ - case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ - case 2: l1|=((unsigned long)(*(--(c))))<<16; \ - case 1: l1|=((unsigned long)(*(--(c))))<<24; \ - } \ - } - -/* NOTE - c is not incremented as per l2n */ -#define l2nn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ - case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ - case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ - case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ - case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ - case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ - case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ - case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ - } \ - } - -#undef n2l -#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))) - -#undef l2n -#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) - -/* This is actually a big endian algorithm, the most significate byte - * is used to lookup array 0 */ - -/* use BF_PTR2 for intel boxes, - * BF_PTR for sparc and MIPS/SGI - * use nothing for Alpha and HP. - */ -#if !defined(BF_PTR) && !defined(BF_PTR2) -#undef BF_PTR -#endif - -#define BF_M 0x3fc -#define BF_0 22L -#define BF_1 14L -#define BF_2 6L -#define BF_3 2L /* left shift */ - -#if defined(BF_PTR2) - -/* This is basically a special pentium verson */ -#define BF_ENC(LL,R,S,P) \ - { \ - BF_LONG t,u,v; \ - u=R>>BF_0; \ - v=R>>BF_1; \ - u&=BF_M; \ - v&=BF_M; \ - t= *(BF_LONG *)((unsigned char *)&(S[ 0])+u); \ - u=R>>BF_2; \ - t+= *(BF_LONG *)((unsigned char *)&(S[256])+v); \ - v=R<>BF_0)&BF_M))+ \ - *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \ - *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \ - *(BF_LONG *)((unsigned char *)&(S[768])+((R<>24L) ] + \ - S[0x0100+((R>>16L)&0xff)])^ \ - S[0x0200+((R>> 8L)&0xff)])+ \ - S[0x0300+((R )&0xff)])&0xffffffff; -#endif diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_ofb64.c b/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_ofb64.c deleted file mode 100644 index f46c56d4..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_ofb64.c +++ /dev/null @@ -1,110 +0,0 @@ -/* crypto/bf/bf_ofb64.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@mincom.oz.au). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@mincom.oz.au)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@mincom.oz.au)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include "blowfish.h" -#include "bf_locl.h" - -/* The input and output encrypted as though 64bit ofb mode is being - * used. The extra state information to record how much of the - * 64bit block we have used is contained in *num; - */ -void BF_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, BF_KEY *schedule, - unsigned char *ivec, int *num) -{ - register unsigned long v0,v1,t; - register int n= *num; - register long l=length; - unsigned char d[8]; - register unsigned char *dp; - unsigned long ti[2]; - unsigned char *iv; - int save=0; - - iv=(unsigned char *)ivec; - n2l(iv,v0); - n2l(iv,v1); - ti[0]=v0; - ti[1]=v1; - dp=(unsigned char *)d; - l2n(v0,dp); - l2n(v1,dp); - while (l-- != 0) - { - if (n == 0) - { - BF_encrypt((unsigned long *)ti,schedule,BF_ENCRYPT); - dp=(unsigned char *)d; - t=ti[0]; l2n(t,dp); - t=ti[1]; l2n(t,dp); - save++; - } - *(out++)= (unsigned char)(*(in++)^d[n]); - n=(n+1)&0x07; - } - if (save != 0) - { - v0=ti[0]; - v1=ti[1]; - iv=(unsigned char *)ivec; - l2n(v0,iv); - l2n(v1,iv); - } - t=v0=v1=ti[0]=ti[1]=0; - *num=n; - } - diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_pi.h b/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_pi.h deleted file mode 100644 index cfbaf32d..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_pi.h +++ /dev/null @@ -1,325 +0,0 @@ -/* crypto/bf/bf_pi.h */ -/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@mincom.oz.au). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@mincom.oz.au)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@mincom.oz.au)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -static BF_KEY bf_init= { - { - 0x243f6a88UL, 0x85a308d3UL, 0x13198a2eUL, 0x03707344UL, - 0xa4093822UL, 0x299f31d0UL, 0x082efa98UL, 0xec4e6c89UL, - 0x452821e6UL, 0x38d01377UL, 0xbe5466cfUL, 0x34e90c6cUL, - 0xc0ac29b7UL, 0xc97c50ddUL, 0x3f84d5b5UL, 0xb5470917UL, - 0x9216d5d9UL, 0x8979fb1bUL - },{ - 0xd1310ba6UL, 0x98dfb5acUL, 0x2ffd72dbUL, 0xd01adfb7UL, - 0xb8e1afedUL, 0x6a267e96UL, 0xba7c9045UL, 0xf12c7f99UL, - 0x24a19947UL, 0xb3916cf7UL, 0x0801f2e2UL, 0x858efc16UL, - 0x636920d8UL, 0x71574e69UL, 0xa458fea3UL, 0xf4933d7eUL, - 0x0d95748fUL, 0x728eb658UL, 0x718bcd58UL, 0x82154aeeUL, - 0x7b54a41dUL, 0xc25a59b5UL, 0x9c30d539UL, 0x2af26013UL, - 0xc5d1b023UL, 0x286085f0UL, 0xca417918UL, 0xb8db38efUL, - 0x8e79dcb0UL, 0x603a180eUL, 0x6c9e0e8bUL, 0xb01e8a3eUL, - 0xd71577c1UL, 0xbd314b27UL, 0x78af2fdaUL, 0x55605c60UL, - 0xe65525f3UL, 0xaa55ab94UL, 0x57489862UL, 0x63e81440UL, - 0x55ca396aUL, 0x2aab10b6UL, 0xb4cc5c34UL, 0x1141e8ceUL, - 0xa15486afUL, 0x7c72e993UL, 0xb3ee1411UL, 0x636fbc2aUL, - 0x2ba9c55dUL, 0x741831f6UL, 0xce5c3e16UL, 0x9b87931eUL, - 0xafd6ba33UL, 0x6c24cf5cUL, 0x7a325381UL, 0x28958677UL, - 0x3b8f4898UL, 0x6b4bb9afUL, 0xc4bfe81bUL, 0x66282193UL, - 0x61d809ccUL, 0xfb21a991UL, 0x487cac60UL, 0x5dec8032UL, - 0xef845d5dUL, 0xe98575b1UL, 0xdc262302UL, 0xeb651b88UL, - 0x23893e81UL, 0xd396acc5UL, 0x0f6d6ff3UL, 0x83f44239UL, - 0x2e0b4482UL, 0xa4842004UL, 0x69c8f04aUL, 0x9e1f9b5eUL, - 0x21c66842UL, 0xf6e96c9aUL, 0x670c9c61UL, 0xabd388f0UL, - 0x6a51a0d2UL, 0xd8542f68UL, 0x960fa728UL, 0xab5133a3UL, - 0x6eef0b6cUL, 0x137a3be4UL, 0xba3bf050UL, 0x7efb2a98UL, - 0xa1f1651dUL, 0x39af0176UL, 0x66ca593eUL, 0x82430e88UL, - 0x8cee8619UL, 0x456f9fb4UL, 0x7d84a5c3UL, 0x3b8b5ebeUL, - 0xe06f75d8UL, 0x85c12073UL, 0x401a449fUL, 0x56c16aa6UL, - 0x4ed3aa62UL, 0x363f7706UL, 0x1bfedf72UL, 0x429b023dUL, - 0x37d0d724UL, 0xd00a1248UL, 0xdb0fead3UL, 0x49f1c09bUL, - 0x075372c9UL, 0x80991b7bUL, 0x25d479d8UL, 0xf6e8def7UL, - 0xe3fe501aUL, 0xb6794c3bUL, 0x976ce0bdUL, 0x04c006baUL, - 0xc1a94fb6UL, 0x409f60c4UL, 0x5e5c9ec2UL, 0x196a2463UL, - 0x68fb6fafUL, 0x3e6c53b5UL, 0x1339b2ebUL, 0x3b52ec6fUL, - 0x6dfc511fUL, 0x9b30952cUL, 0xcc814544UL, 0xaf5ebd09UL, - 0xbee3d004UL, 0xde334afdUL, 0x660f2807UL, 0x192e4bb3UL, - 0xc0cba857UL, 0x45c8740fUL, 0xd20b5f39UL, 0xb9d3fbdbUL, - 0x5579c0bdUL, 0x1a60320aUL, 0xd6a100c6UL, 0x402c7279UL, - 0x679f25feUL, 0xfb1fa3ccUL, 0x8ea5e9f8UL, 0xdb3222f8UL, - 0x3c7516dfUL, 0xfd616b15UL, 0x2f501ec8UL, 0xad0552abUL, - 0x323db5faUL, 0xfd238760UL, 0x53317b48UL, 0x3e00df82UL, - 0x9e5c57bbUL, 0xca6f8ca0UL, 0x1a87562eUL, 0xdf1769dbUL, - 0xd542a8f6UL, 0x287effc3UL, 0xac6732c6UL, 0x8c4f5573UL, - 0x695b27b0UL, 0xbbca58c8UL, 0xe1ffa35dUL, 0xb8f011a0UL, - 0x10fa3d98UL, 0xfd2183b8UL, 0x4afcb56cUL, 0x2dd1d35bUL, - 0x9a53e479UL, 0xb6f84565UL, 0xd28e49bcUL, 0x4bfb9790UL, - 0xe1ddf2daUL, 0xa4cb7e33UL, 0x62fb1341UL, 0xcee4c6e8UL, - 0xef20cadaUL, 0x36774c01UL, 0xd07e9efeUL, 0x2bf11fb4UL, - 0x95dbda4dUL, 0xae909198UL, 0xeaad8e71UL, 0x6b93d5a0UL, - 0xd08ed1d0UL, 0xafc725e0UL, 0x8e3c5b2fUL, 0x8e7594b7UL, - 0x8ff6e2fbUL, 0xf2122b64UL, 0x8888b812UL, 0x900df01cUL, - 0x4fad5ea0UL, 0x688fc31cUL, 0xd1cff191UL, 0xb3a8c1adUL, - 0x2f2f2218UL, 0xbe0e1777UL, 0xea752dfeUL, 0x8b021fa1UL, - 0xe5a0cc0fUL, 0xb56f74e8UL, 0x18acf3d6UL, 0xce89e299UL, - 0xb4a84fe0UL, 0xfd13e0b7UL, 0x7cc43b81UL, 0xd2ada8d9UL, - 0x165fa266UL, 0x80957705UL, 0x93cc7314UL, 0x211a1477UL, - 0xe6ad2065UL, 0x77b5fa86UL, 0xc75442f5UL, 0xfb9d35cfUL, - 0xebcdaf0cUL, 0x7b3e89a0UL, 0xd6411bd3UL, 0xae1e7e49UL, - 0x00250e2dUL, 0x2071b35eUL, 0x226800bbUL, 0x57b8e0afUL, - 0x2464369bUL, 0xf009b91eUL, 0x5563911dUL, 0x59dfa6aaUL, - 0x78c14389UL, 0xd95a537fUL, 0x207d5ba2UL, 0x02e5b9c5UL, - 0x83260376UL, 0x6295cfa9UL, 0x11c81968UL, 0x4e734a41UL, - 0xb3472dcaUL, 0x7b14a94aUL, 0x1b510052UL, 0x9a532915UL, - 0xd60f573fUL, 0xbc9bc6e4UL, 0x2b60a476UL, 0x81e67400UL, - 0x08ba6fb5UL, 0x571be91fUL, 0xf296ec6bUL, 0x2a0dd915UL, - 0xb6636521UL, 0xe7b9f9b6UL, 0xff34052eUL, 0xc5855664UL, - 0x53b02d5dUL, 0xa99f8fa1UL, 0x08ba4799UL, 0x6e85076aUL, - 0x4b7a70e9UL, 0xb5b32944UL, 0xdb75092eUL, 0xc4192623UL, - 0xad6ea6b0UL, 0x49a7df7dUL, 0x9cee60b8UL, 0x8fedb266UL, - 0xecaa8c71UL, 0x699a17ffUL, 0x5664526cUL, 0xc2b19ee1UL, - 0x193602a5UL, 0x75094c29UL, 0xa0591340UL, 0xe4183a3eUL, - 0x3f54989aUL, 0x5b429d65UL, 0x6b8fe4d6UL, 0x99f73fd6UL, - 0xa1d29c07UL, 0xefe830f5UL, 0x4d2d38e6UL, 0xf0255dc1UL, - 0x4cdd2086UL, 0x8470eb26UL, 0x6382e9c6UL, 0x021ecc5eUL, - 0x09686b3fUL, 0x3ebaefc9UL, 0x3c971814UL, 0x6b6a70a1UL, - 0x687f3584UL, 0x52a0e286UL, 0xb79c5305UL, 0xaa500737UL, - 0x3e07841cUL, 0x7fdeae5cUL, 0x8e7d44ecUL, 0x5716f2b8UL, - 0xb03ada37UL, 0xf0500c0dUL, 0xf01c1f04UL, 0x0200b3ffUL, - 0xae0cf51aUL, 0x3cb574b2UL, 0x25837a58UL, 0xdc0921bdUL, - 0xd19113f9UL, 0x7ca92ff6UL, 0x94324773UL, 0x22f54701UL, - 0x3ae5e581UL, 0x37c2dadcUL, 0xc8b57634UL, 0x9af3dda7UL, - 0xa9446146UL, 0x0fd0030eUL, 0xecc8c73eUL, 0xa4751e41UL, - 0xe238cd99UL, 0x3bea0e2fUL, 0x3280bba1UL, 0x183eb331UL, - 0x4e548b38UL, 0x4f6db908UL, 0x6f420d03UL, 0xf60a04bfUL, - 0x2cb81290UL, 0x24977c79UL, 0x5679b072UL, 0xbcaf89afUL, - 0xde9a771fUL, 0xd9930810UL, 0xb38bae12UL, 0xdccf3f2eUL, - 0x5512721fUL, 0x2e6b7124UL, 0x501adde6UL, 0x9f84cd87UL, - 0x7a584718UL, 0x7408da17UL, 0xbc9f9abcUL, 0xe94b7d8cUL, - 0xec7aec3aUL, 0xdb851dfaUL, 0x63094366UL, 0xc464c3d2UL, - 0xef1c1847UL, 0x3215d908UL, 0xdd433b37UL, 0x24c2ba16UL, - 0x12a14d43UL, 0x2a65c451UL, 0x50940002UL, 0x133ae4ddUL, - 0x71dff89eUL, 0x10314e55UL, 0x81ac77d6UL, 0x5f11199bUL, - 0x043556f1UL, 0xd7a3c76bUL, 0x3c11183bUL, 0x5924a509UL, - 0xf28fe6edUL, 0x97f1fbfaUL, 0x9ebabf2cUL, 0x1e153c6eUL, - 0x86e34570UL, 0xeae96fb1UL, 0x860e5e0aUL, 0x5a3e2ab3UL, - 0x771fe71cUL, 0x4e3d06faUL, 0x2965dcb9UL, 0x99e71d0fUL, - 0x803e89d6UL, 0x5266c825UL, 0x2e4cc978UL, 0x9c10b36aUL, - 0xc6150ebaUL, 0x94e2ea78UL, 0xa5fc3c53UL, 0x1e0a2df4UL, - 0xf2f74ea7UL, 0x361d2b3dUL, 0x1939260fUL, 0x19c27960UL, - 0x5223a708UL, 0xf71312b6UL, 0xebadfe6eUL, 0xeac31f66UL, - 0xe3bc4595UL, 0xa67bc883UL, 0xb17f37d1UL, 0x018cff28UL, - 0xc332ddefUL, 0xbe6c5aa5UL, 0x65582185UL, 0x68ab9802UL, - 0xeecea50fUL, 0xdb2f953bUL, 0x2aef7dadUL, 0x5b6e2f84UL, - 0x1521b628UL, 0x29076170UL, 0xecdd4775UL, 0x619f1510UL, - 0x13cca830UL, 0xeb61bd96UL, 0x0334fe1eUL, 0xaa0363cfUL, - 0xb5735c90UL, 0x4c70a239UL, 0xd59e9e0bUL, 0xcbaade14UL, - 0xeecc86bcUL, 0x60622ca7UL, 0x9cab5cabUL, 0xb2f3846eUL, - 0x648b1eafUL, 0x19bdf0caUL, 0xa02369b9UL, 0x655abb50UL, - 0x40685a32UL, 0x3c2ab4b3UL, 0x319ee9d5UL, 0xc021b8f7UL, - 0x9b540b19UL, 0x875fa099UL, 0x95f7997eUL, 0x623d7da8UL, - 0xf837889aUL, 0x97e32d77UL, 0x11ed935fUL, 0x16681281UL, - 0x0e358829UL, 0xc7e61fd6UL, 0x96dedfa1UL, 0x7858ba99UL, - 0x57f584a5UL, 0x1b227263UL, 0x9b83c3ffUL, 0x1ac24696UL, - 0xcdb30aebUL, 0x532e3054UL, 0x8fd948e4UL, 0x6dbc3128UL, - 0x58ebf2efUL, 0x34c6ffeaUL, 0xfe28ed61UL, 0xee7c3c73UL, - 0x5d4a14d9UL, 0xe864b7e3UL, 0x42105d14UL, 0x203e13e0UL, - 0x45eee2b6UL, 0xa3aaabeaUL, 0xdb6c4f15UL, 0xfacb4fd0UL, - 0xc742f442UL, 0xef6abbb5UL, 0x654f3b1dUL, 0x41cd2105UL, - 0xd81e799eUL, 0x86854dc7UL, 0xe44b476aUL, 0x3d816250UL, - 0xcf62a1f2UL, 0x5b8d2646UL, 0xfc8883a0UL, 0xc1c7b6a3UL, - 0x7f1524c3UL, 0x69cb7492UL, 0x47848a0bUL, 0x5692b285UL, - 0x095bbf00UL, 0xad19489dUL, 0x1462b174UL, 0x23820e00UL, - 0x58428d2aUL, 0x0c55f5eaUL, 0x1dadf43eUL, 0x233f7061UL, - 0x3372f092UL, 0x8d937e41UL, 0xd65fecf1UL, 0x6c223bdbUL, - 0x7cde3759UL, 0xcbee7460UL, 0x4085f2a7UL, 0xce77326eUL, - 0xa6078084UL, 0x19f8509eUL, 0xe8efd855UL, 0x61d99735UL, - 0xa969a7aaUL, 0xc50c06c2UL, 0x5a04abfcUL, 0x800bcadcUL, - 0x9e447a2eUL, 0xc3453484UL, 0xfdd56705UL, 0x0e1e9ec9UL, - 0xdb73dbd3UL, 0x105588cdUL, 0x675fda79UL, 0xe3674340UL, - 0xc5c43465UL, 0x713e38d8UL, 0x3d28f89eUL, 0xf16dff20UL, - 0x153e21e7UL, 0x8fb03d4aUL, 0xe6e39f2bUL, 0xdb83adf7UL, - 0xe93d5a68UL, 0x948140f7UL, 0xf64c261cUL, 0x94692934UL, - 0x411520f7UL, 0x7602d4f7UL, 0xbcf46b2eUL, 0xd4a20068UL, - 0xd4082471UL, 0x3320f46aUL, 0x43b7d4b7UL, 0x500061afUL, - 0x1e39f62eUL, 0x97244546UL, 0x14214f74UL, 0xbf8b8840UL, - 0x4d95fc1dUL, 0x96b591afUL, 0x70f4ddd3UL, 0x66a02f45UL, - 0xbfbc09ecUL, 0x03bd9785UL, 0x7fac6dd0UL, 0x31cb8504UL, - 0x96eb27b3UL, 0x55fd3941UL, 0xda2547e6UL, 0xabca0a9aUL, - 0x28507825UL, 0x530429f4UL, 0x0a2c86daUL, 0xe9b66dfbUL, - 0x68dc1462UL, 0xd7486900UL, 0x680ec0a4UL, 0x27a18deeUL, - 0x4f3ffea2UL, 0xe887ad8cUL, 0xb58ce006UL, 0x7af4d6b6UL, - 0xaace1e7cUL, 0xd3375fecUL, 0xce78a399UL, 0x406b2a42UL, - 0x20fe9e35UL, 0xd9f385b9UL, 0xee39d7abUL, 0x3b124e8bUL, - 0x1dc9faf7UL, 0x4b6d1856UL, 0x26a36631UL, 0xeae397b2UL, - 0x3a6efa74UL, 0xdd5b4332UL, 0x6841e7f7UL, 0xca7820fbUL, - 0xfb0af54eUL, 0xd8feb397UL, 0x454056acUL, 0xba489527UL, - 0x55533a3aUL, 0x20838d87UL, 0xfe6ba9b7UL, 0xd096954bUL, - 0x55a867bcUL, 0xa1159a58UL, 0xcca92963UL, 0x99e1db33UL, - 0xa62a4a56UL, 0x3f3125f9UL, 0x5ef47e1cUL, 0x9029317cUL, - 0xfdf8e802UL, 0x04272f70UL, 0x80bb155cUL, 0x05282ce3UL, - 0x95c11548UL, 0xe4c66d22UL, 0x48c1133fUL, 0xc70f86dcUL, - 0x07f9c9eeUL, 0x41041f0fUL, 0x404779a4UL, 0x5d886e17UL, - 0x325f51ebUL, 0xd59bc0d1UL, 0xf2bcc18fUL, 0x41113564UL, - 0x257b7834UL, 0x602a9c60UL, 0xdff8e8a3UL, 0x1f636c1bUL, - 0x0e12b4c2UL, 0x02e1329eUL, 0xaf664fd1UL, 0xcad18115UL, - 0x6b2395e0UL, 0x333e92e1UL, 0x3b240b62UL, 0xeebeb922UL, - 0x85b2a20eUL, 0xe6ba0d99UL, 0xde720c8cUL, 0x2da2f728UL, - 0xd0127845UL, 0x95b794fdUL, 0x647d0862UL, 0xe7ccf5f0UL, - 0x5449a36fUL, 0x877d48faUL, 0xc39dfd27UL, 0xf33e8d1eUL, - 0x0a476341UL, 0x992eff74UL, 0x3a6f6eabUL, 0xf4f8fd37UL, - 0xa812dc60UL, 0xa1ebddf8UL, 0x991be14cUL, 0xdb6e6b0dUL, - 0xc67b5510UL, 0x6d672c37UL, 0x2765d43bUL, 0xdcd0e804UL, - 0xf1290dc7UL, 0xcc00ffa3UL, 0xb5390f92UL, 0x690fed0bUL, - 0x667b9ffbUL, 0xcedb7d9cUL, 0xa091cf0bUL, 0xd9155ea3UL, - 0xbb132f88UL, 0x515bad24UL, 0x7b9479bfUL, 0x763bd6ebUL, - 0x37392eb3UL, 0xcc115979UL, 0x8026e297UL, 0xf42e312dUL, - 0x6842ada7UL, 0xc66a2b3bUL, 0x12754cccUL, 0x782ef11cUL, - 0x6a124237UL, 0xb79251e7UL, 0x06a1bbe6UL, 0x4bfb6350UL, - 0x1a6b1018UL, 0x11caedfaUL, 0x3d25bdd8UL, 0xe2e1c3c9UL, - 0x44421659UL, 0x0a121386UL, 0xd90cec6eUL, 0xd5abea2aUL, - 0x64af674eUL, 0xda86a85fUL, 0xbebfe988UL, 0x64e4c3feUL, - 0x9dbc8057UL, 0xf0f7c086UL, 0x60787bf8UL, 0x6003604dUL, - 0xd1fd8346UL, 0xf6381fb0UL, 0x7745ae04UL, 0xd736fcccUL, - 0x83426b33UL, 0xf01eab71UL, 0xb0804187UL, 0x3c005e5fUL, - 0x77a057beUL, 0xbde8ae24UL, 0x55464299UL, 0xbf582e61UL, - 0x4e58f48fUL, 0xf2ddfda2UL, 0xf474ef38UL, 0x8789bdc2UL, - 0x5366f9c3UL, 0xc8b38e74UL, 0xb475f255UL, 0x46fcd9b9UL, - 0x7aeb2661UL, 0x8b1ddf84UL, 0x846a0e79UL, 0x915f95e2UL, - 0x466e598eUL, 0x20b45770UL, 0x8cd55591UL, 0xc902de4cUL, - 0xb90bace1UL, 0xbb8205d0UL, 0x11a86248UL, 0x7574a99eUL, - 0xb77f19b6UL, 0xe0a9dc09UL, 0x662d09a1UL, 0xc4324633UL, - 0xe85a1f02UL, 0x09f0be8cUL, 0x4a99a025UL, 0x1d6efe10UL, - 0x1ab93d1dUL, 0x0ba5a4dfUL, 0xa186f20fUL, 0x2868f169UL, - 0xdcb7da83UL, 0x573906feUL, 0xa1e2ce9bUL, 0x4fcd7f52UL, - 0x50115e01UL, 0xa70683faUL, 0xa002b5c4UL, 0x0de6d027UL, - 0x9af88c27UL, 0x773f8641UL, 0xc3604c06UL, 0x61a806b5UL, - 0xf0177a28UL, 0xc0f586e0UL, 0x006058aaUL, 0x30dc7d62UL, - 0x11e69ed7UL, 0x2338ea63UL, 0x53c2dd94UL, 0xc2c21634UL, - 0xbbcbee56UL, 0x90bcb6deUL, 0xebfc7da1UL, 0xce591d76UL, - 0x6f05e409UL, 0x4b7c0188UL, 0x39720a3dUL, 0x7c927c24UL, - 0x86e3725fUL, 0x724d9db9UL, 0x1ac15bb4UL, 0xd39eb8fcUL, - 0xed545578UL, 0x08fca5b5UL, 0xd83d7cd3UL, 0x4dad0fc4UL, - 0x1e50ef5eUL, 0xb161e6f8UL, 0xa28514d9UL, 0x6c51133cUL, - 0x6fd5c7e7UL, 0x56e14ec4UL, 0x362abfceUL, 0xddc6c837UL, - 0xd79a3234UL, 0x92638212UL, 0x670efa8eUL, 0x406000e0UL, - 0x3a39ce37UL, 0xd3faf5cfUL, 0xabc27737UL, 0x5ac52d1bUL, - 0x5cb0679eUL, 0x4fa33742UL, 0xd3822740UL, 0x99bc9bbeUL, - 0xd5118e9dUL, 0xbf0f7315UL, 0xd62d1c7eUL, 0xc700c47bUL, - 0xb78c1b6bUL, 0x21a19045UL, 0xb26eb1beUL, 0x6a366eb4UL, - 0x5748ab2fUL, 0xbc946e79UL, 0xc6a376d2UL, 0x6549c2c8UL, - 0x530ff8eeUL, 0x468dde7dUL, 0xd5730a1dUL, 0x4cd04dc6UL, - 0x2939bbdbUL, 0xa9ba4650UL, 0xac9526e8UL, 0xbe5ee304UL, - 0xa1fad5f0UL, 0x6a2d519aUL, 0x63ef8ce2UL, 0x9a86ee22UL, - 0xc089c2b8UL, 0x43242ef6UL, 0xa51e03aaUL, 0x9cf2d0a4UL, - 0x83c061baUL, 0x9be96a4dUL, 0x8fe51550UL, 0xba645bd6UL, - 0x2826a2f9UL, 0xa73a3ae1UL, 0x4ba99586UL, 0xef5562e9UL, - 0xc72fefd3UL, 0xf752f7daUL, 0x3f046f69UL, 0x77fa0a59UL, - 0x80e4a915UL, 0x87b08601UL, 0x9b09e6adUL, 0x3b3ee593UL, - 0xe990fd5aUL, 0x9e34d797UL, 0x2cf0b7d9UL, 0x022b8b51UL, - 0x96d5ac3aUL, 0x017da67dUL, 0xd1cf3ed6UL, 0x7c7d2d28UL, - 0x1f9f25cfUL, 0xadf2b89bUL, 0x5ad6b472UL, 0x5a88f54cUL, - 0xe029ac71UL, 0xe019a5e6UL, 0x47b0acfdUL, 0xed93fa9bUL, - 0xe8d3c48dUL, 0x283b57ccUL, 0xf8d56629UL, 0x79132e28UL, - 0x785f0191UL, 0xed756055UL, 0xf7960e44UL, 0xe3d35e8cUL, - 0x15056dd4UL, 0x88f46dbaUL, 0x03a16125UL, 0x0564f0bdUL, - 0xc3eb9e15UL, 0x3c9057a2UL, 0x97271aecUL, 0xa93a072aUL, - 0x1b3f6d9bUL, 0x1e6321f5UL, 0xf59c66fbUL, 0x26dcf319UL, - 0x7533d928UL, 0xb155fdf5UL, 0x03563482UL, 0x8aba3cbbUL, - 0x28517711UL, 0xc20ad9f8UL, 0xabcc5167UL, 0xccad925fUL, - 0x4de81751UL, 0x3830dc8eUL, 0x379d5862UL, 0x9320f991UL, - 0xea7a90c2UL, 0xfb3e7bceUL, 0x5121ce64UL, 0x774fbe32UL, - 0xa8b6e37eUL, 0xc3293d46UL, 0x48de5369UL, 0x6413e680UL, - 0xa2ae0810UL, 0xdd6db224UL, 0x69852dfdUL, 0x09072166UL, - 0xb39a460aUL, 0x6445c0ddUL, 0x586cdecfUL, 0x1c20c8aeUL, - 0x5bbef7ddUL, 0x1b588d40UL, 0xccd2017fUL, 0x6bb4e3bbUL, - 0xdda26a7eUL, 0x3a59ff45UL, 0x3e350a44UL, 0xbcb4cdd5UL, - 0x72eacea8UL, 0xfa6484bbUL, 0x8d6612aeUL, 0xbf3c6f47UL, - 0xd29be463UL, 0x542f5d9eUL, 0xaec2771bUL, 0xf64e6370UL, - 0x740e0d8dUL, 0xe75b1357UL, 0xf8721671UL, 0xaf537d5dUL, - 0x4040cb08UL, 0x4eb4e2ccUL, 0x34d2466aUL, 0x0115af84UL, - 0xe1b00428UL, 0x95983a1dUL, 0x06b89fb4UL, 0xce6ea048UL, - 0x6f3f3b82UL, 0x3520ab82UL, 0x011a1d4bUL, 0x277227f8UL, - 0x611560b1UL, 0xe7933fdcUL, 0xbb3a792bUL, 0x344525bdUL, - 0xa08839e1UL, 0x51ce794bUL, 0x2f32c9b7UL, 0xa01fbac9UL, - 0xe01cc87eUL, 0xbcc7d1f6UL, 0xcf0111c3UL, 0xa1e8aac7UL, - 0x1a908749UL, 0xd44fbd9aUL, 0xd0dadecbUL, 0xd50ada38UL, - 0x0339c32aUL, 0xc6913667UL, 0x8df9317cUL, 0xe0b12b4fUL, - 0xf79e59b7UL, 0x43f5bb3aUL, 0xf2d519ffUL, 0x27d9459cUL, - 0xbf97222cUL, 0x15e6fc2aUL, 0x0f91fc71UL, 0x9b941525UL, - 0xfae59361UL, 0xceb69cebUL, 0xc2a86459UL, 0x12baa8d1UL, - 0xb6c1075eUL, 0xe3056a0cUL, 0x10d25065UL, 0xcb03a442UL, - 0xe0ec6e0eUL, 0x1698db3bUL, 0x4c98a0beUL, 0x3278e964UL, - 0x9f1f9532UL, 0xe0d392dfUL, 0xd3a0342bUL, 0x8971f21eUL, - 0x1b0a7441UL, 0x4ba3348cUL, 0xc5be7120UL, 0xc37632d8UL, - 0xdf359f8dUL, 0x9b992f2eUL, 0xe60b6f47UL, 0x0fe3f11dUL, - 0xe54cda54UL, 0x1edad891UL, 0xce6279cfUL, 0xcd3e7e6fUL, - 0x1618b166UL, 0xfd2c1d05UL, 0x848fd2c5UL, 0xf6fb2299UL, - 0xf523f357UL, 0xa6327623UL, 0x93a83531UL, 0x56cccd02UL, - 0xacf08162UL, 0x5a75ebb5UL, 0x6e163697UL, 0x88d273ccUL, - 0xde966292UL, 0x81b949d0UL, 0x4c50901bUL, 0x71c65614UL, - 0xe6c6c7bdUL, 0x327a140aUL, 0x45e1d006UL, 0xc3f27b9aUL, - 0xc9aa53fdUL, 0x62a80f00UL, 0xbb25bfe2UL, 0x35bdd2f6UL, - 0x71126905UL, 0xb2040222UL, 0xb6cbcf7cUL, 0xcd769c2bUL, - 0x53113ec0UL, 0x1640e3d3UL, 0x38abbd60UL, 0x2547adf0UL, - 0xba38209cUL, 0xf746ce76UL, 0x77afa1c5UL, 0x20756060UL, - 0x85cbfe4eUL, 0x8ae88dd8UL, 0x7aaaf9b0UL, 0x4cf9aa7eUL, - 0x1948c25cUL, 0x02fb8a8cUL, 0x01c36ae4UL, 0xd6ebe1f9UL, - 0x90d4f869UL, 0xa65cdea0UL, 0x3f09252dUL, 0xc208e69fUL, - 0xb74e6132UL, 0xce77e25bUL, 0x578fdfe3UL, 0x3ac372e6UL, - } - }; - diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_skey.c b/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_skey.c deleted file mode 100644 index 6cae059b..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/bf_skey.c +++ /dev/null @@ -1,116 +0,0 @@ -/* crypto/bf/bf_skey.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@mincom.oz.au). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@mincom.oz.au)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@mincom.oz.au)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include -#include -#include "blowfish.h" -#include "bf_locl.h" -#include "bf_pi.h" - -void BF_set_key(BF_KEY *key, int len, unsigned char *data) -{ - int i; - BF_LONG *p,ri,in[2]; - unsigned char *d,*end; - - - memcpy((char *)key,(char *)&bf_init,sizeof(BF_KEY)); - p=key->P; - - if (len > ((BF_ROUNDS+2)*4)) len=(BF_ROUNDS+2)*4; - - d=data; - end= &(data[len]); - for (i=0; i<(BF_ROUNDS+2); i++) - { - ri= (BF_LONG)*(d++); - if (d >= end) d=data; - - ri<<=8; - ri|= *(d++); - if (d >= end) d=data; - - ri<<=8; - ri|= *(d++); - if (d >= end) d=data; - - ri<<=8; - ri|= *(d++); - if (d >= end) d=data; - - p[i]^=ri; - } - - in[0]=0L; - in[1]=0L; - for (i=0; i<(BF_ROUNDS+2); i+=2) - { - BF_encrypt(in,key,BF_ENCRYPT); - p[i ]=in[0]; - p[i+1]=in[1]; - } - - p=key->S; - for (i=0; i<4*256; i+=2) - { - BF_encrypt(in,key,BF_ENCRYPT); - p[i ]=in[0]; - p[i+1]=in[1]; - } - } - diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/blowfish.doc b/SDKs/Win32/HawkVoice/src/BLOWFISH/blowfish.doc deleted file mode 100644 index ed84bf06..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/blowfish.doc +++ /dev/null @@ -1,149 +0,0 @@ -The Blowfish library. - -Blowfish is a block cipher that operates on 64bit (8 byte) quantities. It -uses variable size key, but 128bit (16 byte) key would normally be considered -good. It can be used in all the modes that DES can be used. This -library implements the ecb, cbc, cfb64, ofb64 modes. - -Blowfish is quite a bit faster that DES, and much faster than IDEA or -RC2. It is one of the faster block ciphers. - -For all calls that have an 'input' and 'output' variables, they can be the -same. - -This library requires the inclusion of 'blowfish.h'. - -All of the encryption functions take what is called an BF_KEY as an -argument. An BF_KEY is an expanded form of the Blowfish key. -For all modes of the Blowfish algorithm, the BF_KEY used for -decryption is the same one that was used for encryption. - -The define BF_ENCRYPT is passed to specify encryption for the functions -that require an encryption/decryption flag. BF_DECRYPT is passed to -specify decryption. - -Please note that any of the encryption modes specified in my DES library -could be used with Blowfish. I have only implemented ecb, cbc, cfb64 and -ofb64 for the following reasons. -- ecb is the basic Blowfish encryption. -- cbc is the normal 'chaining' form for block ciphers. -- cfb64 can be used to encrypt single characters, therefore input and output - do not need to be a multiple of 8. -- ofb64 is similar to cfb64 but is more like a stream cipher, not as - secure (not cipher feedback) but it does not have an encrypt/decrypt mode. -- If you want triple Blowfish, thats 384 bits of key and you must be totally - obsessed with security. Still, if you want it, it is simple enough to - copy the function from the DES library and change the des_encrypt to - BF_encrypt; an exercise left for the paranoid reader :-). - -The functions are as follows: - -void BF_set_key( -BF_KEY *ks; -int len; -unsigned char *key; - BF_set_key converts an 'len' byte key into a BF_KEY. - A 'ks' is an expanded form of the 'key' which is used to - perform actual encryption. It can be regenerated from the Blowfish key - so it only needs to be kept when encryption or decryption is about - to occur. Don't save or pass around BF_KEY's since they - are CPU architecture dependent, 'key's are not. Blowfish is an - interesting cipher in that it can be used with a variable length - key. 'len' is the length of 'key' to be used as the key. - A 'len' of 16 is recomended by me, but blowfish can use upto - 72 bytes. As a warning, blowfish has a very very slow set_key - function, it actually runs BF_encrypt 521 times. - -void BF_encrypt( -unsigned long *data, -BF_KEY *key, -int encrypt); - This is the Blowfish encryption function that gets called by just about - every other Blowfish routine in the library. You should not use this - function except to implement 'modes' of Blowfish. - I say this because the - functions that call this routine do the conversion from 'char *' to - long, and this needs to be done to make sure 'non-aligned' memory - access do not occur. - Data is a pointer to 2 unsigned long's and key is the - BF_KEY to use. Encryption or decryption is indicated by 'encrypt'. - which can have the values BF_ENCRYPT or BF_DECRYPT. - -void BF_ecb_encrypt( -unsigned char *in, -unsigned char *out, -BF_KEY *key, -int encrypt); - This is the basic Electronic Code Book form of Blowfish (in DES this - mode is called Electronic Code Book so I'm going to use the term - for blowfish as well. - Input is encrypted into output using the key represented by - key. Depending on the encrypt, encryption or - decryption occurs. Input is 8 bytes long and output is 8 bytes. - -void BF_cbc_encrypt( -unsigned char *in, -unsigned char *out, -long length, -BF_KEY *ks, -unsigned char *ivec, -int encrypt); - This routine implements Blowfish in Cipher Block Chaining mode. - Input, which should be a multiple of 8 bytes is encrypted - (or decrypted) to output which will also be a multiple of 8 bytes. - The number of bytes is in length (and from what I've said above, - should be a multiple of 8). If length is not a multiple of 8, bad - things will probably happen. ivec is the initialisation vector. - This function updates iv after each call so that it can be passed to - the next call to BF_cbc_encrypt(). - -void BF_cfb64_encrypt( -unsigned char *in, -unsigned char *out, -long length, -BF_KEY *schedule, -unsigned char *ivec, -int *num, -int encrypt); - This is one of the more useful functions in this Blowfish library, it - implements CFB mode of Blowfish with 64bit feedback. - This allows you to encrypt an arbitrary number of bytes, - you do not require 8 byte padding. Each call to this - routine will encrypt the input bytes to output and then update ivec - and num. Num contains 'how far' we are though ivec. - 'Encrypt' is used to indicate encryption or decryption. - CFB64 mode operates by using the cipher to generate a stream - of bytes which is used to encrypt the plain text. - The cipher text is then encrypted to generate the next 64 bits to - be xored (incrementally) with the next 64 bits of plain - text. As can be seen from this, to encrypt or decrypt, - the same 'cipher stream' needs to be generated but the way the next - block of data is gathered for encryption is different for - encryption and decryption. - -void BF_ofb64_encrypt( -unsigned char *in, -unsigned char *out, -long length, -BF_KEY *schedule, -unsigned char *ivec, -int *num); - This functions implements OFB mode of Blowfish with 64bit feedback. - This allows you to encrypt an arbitrary number of bytes, - you do not require 8 byte padding. Each call to this - routine will encrypt the input bytes to output and then update ivec - and num. Num contains 'how far' we are though ivec. - This is in effect a stream cipher, there is no encryption or - decryption mode. - -For reading passwords, I suggest using des_read_pw_string() from my DES library. -To generate a password from a text string, I suggest using MD5 (or MD2) to -produce a 16 byte message digest that can then be passed directly to -BF_set_key(). - -===== -For more information about the specific Blowfish modes in this library -(ecb, cbc, cfb and ofb), read the section entitled 'Modes of DES' from the -documentation on my DES library. What is said about DES is directly -applicable for Blowfish. - diff --git a/SDKs/Win32/HawkVoice/src/BLOWFISH/blowfish.h b/SDKs/Win32/HawkVoice/src/BLOWFISH/blowfish.h deleted file mode 100644 index 72892407..00000000 --- a/SDKs/Win32/HawkVoice/src/BLOWFISH/blowfish.h +++ /dev/null @@ -1,114 +0,0 @@ -/* crypto/bf/blowfish.h */ -/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@mincom.oz.au). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@mincom.oz.au). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@mincom.oz.au)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@mincom.oz.au)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef HEADER_BLOWFISH_H -#define HEADER_BLOWFISH_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define BF_ENCRYPT 1 -#define BF_DECRYPT 0 - -/* If you make this 'unsigned int' the pointer variants will work on - * the Alpha, otherwise they will not. Strangly using the '8 byte' - * BF_LONG and the default 'non-pointer' inner loop is the best configuration - * for the Alpha */ -#define BF_LONG unsigned long - -#define BF_ROUNDS 16 -#define BF_BLOCK 8 - -typedef struct bf_key_st - { - BF_LONG P[BF_ROUNDS+2]; - BF_LONG S[4*256]; - } BF_KEY; - -#ifndef NOPROTO - -void BF_set_key(BF_KEY *key, int len, unsigned char *data); -void BF_ecb_encrypt(unsigned char *in,unsigned char *out,BF_KEY *key, - int encrypt); -void BF_encrypt(BF_LONG *data,BF_KEY *key,int encrypt); -void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length, - BF_KEY *ks, unsigned char *iv, int encrypt); -void BF_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, - BF_KEY *schedule, unsigned char *ivec, int *num, int encrypt); -void BF_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, - BF_KEY *schedule, unsigned char *ivec, int *num); -char *BF_options(void); - -#else - -void BF_set_key(); -void BF_ecb_encrypt(); -void BF_encrypt(); -void BF_cbc_encrypt(); -void BF_cfb64_encrypt(); -void BF_ofb64_encrypt(); -char *BF_options(); - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/SDKs/Win32/HawkVoice/src/hvdi.h b/SDKs/Win32/HawkVoice/src/hvdi.h deleted file mode 100644 index c7993e09..00000000 --- a/SDKs/Win32/HawkVoice/src/hvdi.h +++ /dev/null @@ -1,194 +0,0 @@ -/* - HawkVoice Direct Interface (HVDI) cross platform network voice library - Copyright (C) 2001 Phil Frisbie, Jr. (phil@hawksoft.com) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Or go to http://www.gnu.org/copyleft/lgpl.html -*/ - -#ifndef HVDI_H -#define HVDI_H - -#include "blowfish/blowfish.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#define HVDI_MAJOR_VERSION 0 -#define HVDI_MINOR_VERSION 7 -#define HVDI_VERSION_STRING "HVDI 0.7 beta" - -/* This was copied from nl.h so that it did not need to be included */ - -#if defined WIN32 || defined WIN64 - #pragma warning (disable:4514) /* disable "unreferenced inline function has - been removed" warning */ - /* The default build for Windows is as a DLL. */ - /* If you want a static library, define WIN_STATIC_LIB. */ - #ifdef WIN_STATIC_LIB - #define NL_EXP - #else - #if defined __LCC__ - #define NL_EXP extern - #else - #define NL_EXP __declspec(dllexport) - #endif - #endif - #define NL_APIENTRY __stdcall - #define NL_CALLBACK __cdecl - #ifdef __GNUC__ - #define NL_INLINE extern __inline__ - #else - #define NL_INLINE __inline - #endif -#else - #define NL_EXP extern - #define NL_APIENTRY - #define NL_CALLBACK - #ifdef __GNUC__ - #define NL_INLINE extern __inline__ - #else - #define NL_INLINE inline /* assuming C99 compliant compiler */ - #endif /* __GNUC__ */ -#endif /* WIN32 || WIN64 */ - -#ifndef NL_INVALID -#define NL_INVALID (-1) -#define NL_FALSE (0) -#define NL_TRUE (1) -#endif - - -/* We will use HVDI or hvdi to prefix all HawkVoiceDI defines and functions */ - -/* - The internal state of the codec. This is READ ONLY! You can read hvdi_dec_state->codec - if you want to know what type of codec is being used on the other side, but DO NOT - write to this structure!! I could have hidden these structures behind an index, but - this IS low level quick and dirty ;) - - hvdi_enc_state and hvdi_dec_state are defined separately to help the compiler spot - your mistakes ;) -*/ -typedef struct -{ - unsigned char codec; /* the codec used with the last packet */ - unsigned short sequence;/* the sequence number of the last packet */ - void *state; /* the codec state */ -} hvdi_enc_state; - -typedef struct -{ - unsigned char codec; /* the codec used with the last packet */ - unsigned short sequence;/* the sequence number of the last packet */ - void *state; /* the codec state */ -} hvdi_dec_state; - -typedef struct -{ - int rate; /* HVDI_VOX_FAST, HVDI_VOX_MEDIUM, or HVDI_VOX_SLOW */ - int noisethreshold; /* 0(always pass) to 1000(never pass), 300 is a good starting point */ - int samplecount; /* init to 0; used internally by hvdiVOX */ -} hvdi_vox; - -typedef struct -{ - unsigned long lcmrate; /* least common multiple of rates */ - unsigned long inskip, outskip; /* LCM increments for I & O rates */ - unsigned long total; - unsigned long intot, outtot; /* total samples in terms of LCM rate */ - long lastsamp; -} hvdi_rate; - -typedef struct -{ - unsigned int sample_max; - int counter; - float gain; - float peak; - int silence_counter; -} hvdi_agc; - -/* The basic codecs, from hawkvoice.h */ -#define HV_2_4K_CODEC 0x0001 /* LPC-10 2.4 Kbps codec */ -#define HV_4_8K_CODEC 0x0002 /* LPC 4.8 Kbps codec */ -#define HV_13_2K_CODEC 0x0004 /* GSM 13.2 Kbps codec */ -#define HV_32K_CODEC 0x0008 /* Intel/DVI ADPCM 32 Kbps codec */ -#define HV_64K_CODEC 0x0010 /* G.711 u-law 64 Kbps codec */ -#define HV_1_4K_CODEC 0x0011 /* OpenLPC 1.4 Kbps codec */ -#define HV_1_8K_CODEC 0x0012 /* OpenLPC 1.8 Kbps codec */ - -/* Alternate codec names */ -#define HV_LPC10_CODEC HV_2_4K_CODEC -#define HV_LPC_CODEC HV_4_8K_CODEC -#define HV_GSM_CODEC HV_13_2K_CODEC -#define HV_ADPCM_32_CODEC HV_32K_CODEC -#define HV_PCM_64_CODEC HV_64K_CODEC -#define HV_G_711_CODEC HV_64K_CODEC -#define HV_ULAW_CODEC HV_64K_CODEC -#define HV_LPC_1_4_CODEC HV_1_4K_CODEC -#define HV_LPC_1_8_CODEC HV_1_8K_CODEC - -/* VOX options */ -/* how many samples of silence to wait after voice stops */ -#define HVDI_VOX_FAST 4000 /* 1/2 second */ -#define HVDI_VOX_MEDIUM 8000 /* 1 second */ -#define HVDI_VOX_SLOW 12000 /* 1 1/2 seconds */ - - -/* HawkVoiceDI API */ - -NL_EXP hvdi_enc_state* NL_APIENTRY hvdiCreateEncoderState(void); - -NL_EXP hvdi_dec_state* NL_APIENTRY hvdiCreateDecoderState(void); - -NL_EXP void NL_APIENTRY hvdiFreeEncoderState(hvdi_enc_state *state); - -NL_EXP void NL_APIENTRY hvdiFreeDecoderState(hvdi_dec_state *state); - -NL_EXP int NL_APIENTRY hvdiSetCodec(unsigned char codec, hvdi_enc_state *state); - -NL_EXP BF_KEY* NL_APIENTRY hvdiMakeEncryptionKey(const char *string); - -NL_EXP int NL_APIENTRY hvdiIsVoicePacket(unsigned char *packet, int length); - -NL_EXP int NL_APIENTRY hvdiDecodePacket(unsigned char *packet, int paclen, short *buffer, - int buflen, BF_KEY *key, hvdi_dec_state *state); - -NL_EXP int NL_APIENTRY hvdiEncodePacket(short *buffer, int buflen, unsigned char *packet, - int paclen, BF_KEY *key, hvdi_enc_state *state); - -NL_EXP int NL_APIENTRY hvdiVOX(short *buffer, int buflen, hvdi_vox *vox); - -NL_EXP void NL_APIENTRY hvdiRateInit(hvdi_rate *rate, int inrate, int outrate); - -NL_EXP void NL_APIENTRY hvdiRateFlow(hvdi_rate *rate, short *inbuf, short *outbuf, int *inlen, int *outlen); - -NL_EXP void NL_APIENTRY hvdiAGCInit(hvdi_agc *agc, float level); - -NL_EXP void NL_APIENTRY hvdiAGC(hvdi_agc *agc, short *buffer, int len); - -NL_EXP void NL_APIENTRY hvdiMix(short *outbuf, short **inbuf, int number, int inlen); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* HVDI_H */ - diff --git a/SDKs/XPlatform/Cypython-2.3.3/Grammar/.cvsignore b/SDKs/XPlatform/Cypython-2.3.3/Grammar/.cvsignore deleted file mode 100644 index 5498146d..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Grammar/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -graminit.h -graminit.c -Makefile diff --git a/SDKs/XPlatform/Cypython-2.3.3/Grammar/Grammar b/SDKs/XPlatform/Cypython-2.3.3/Grammar/Grammar deleted file mode 100644 index 05b5911f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Grammar/Grammar +++ /dev/null @@ -1,107 +0,0 @@ -# Grammar for Python - -# Note: Changing the grammar specified in this file will most likely -# require corresponding changes in the parser module -# (../Modules/parsermodule.c). If you can't make the changes to -# that module yourself, please co-ordinate the required changes -# with someone who can; ask around on python-dev for help. Fred -# Drake will probably be listening there. - -# Commands for Kees Blom's railroad program -#diagram:token NAME -#diagram:token NUMBER -#diagram:token STRING -#diagram:token NEWLINE -#diagram:token ENDMARKER -#diagram:token INDENT -#diagram:output\input python.bla -#diagram:token DEDENT -#diagram:output\textwidth 20.04cm\oddsidemargin 0.0cm\evensidemargin 0.0cm -#diagram:rules - -# Start symbols for the grammar: -# single_input is a single interactive statement; -# file_input is a module or sequence of commands read from an input file; -# eval_input is the input for the eval() and input() functions. -# NB: compound_stmt in single_input is followed by extra NEWLINE! -single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE -file_input: (NEWLINE | stmt)* ENDMARKER -eval_input: testlist NEWLINE* ENDMARKER - -funcdef: 'def' NAME parameters ':' suite -parameters: '(' [varargslist] ')' -varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [','] -fpdef: NAME | '(' fplist ')' -fplist: fpdef (',' fpdef)* [','] - -stmt: simple_stmt | compound_stmt -simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE -small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt -expr_stmt: testlist (augassign testlist | ('=' testlist)*) -augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//=' -# For normal assignments, additional restrictions enforced by the interpreter -print_stmt: 'print' ( [ test (',' test)* [','] ] | '>>' test [ (',' test)+ [','] ] ) -del_stmt: 'del' exprlist -pass_stmt: 'pass' -flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt -break_stmt: 'break' -continue_stmt: 'continue' -return_stmt: 'return' [testlist] -yield_stmt: 'yield' testlist -raise_stmt: 'raise' [test [',' test [',' test]]] -import_stmt: 'import' dotted_as_name (',' dotted_as_name)* | 'from' dotted_name 'import' ('*' | import_as_name (',' import_as_name)*) -import_as_name: NAME [NAME NAME] -dotted_as_name: dotted_name [NAME NAME] -dotted_name: NAME ('.' NAME)* -global_stmt: 'global' NAME (',' NAME)* -exec_stmt: 'exec' expr ['in' test [',' test]] -assert_stmt: 'assert' test [',' test] - -compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef -if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] -while_stmt: 'while' test ':' suite ['else' ':' suite] -for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] -try_stmt: ('try' ':' suite (except_clause ':' suite)+ #diagram:break - ['else' ':' suite] | 'try' ':' suite 'finally' ':' suite) -# NB compile.c makes sure that the default except clause is last -except_clause: 'except' [test [',' test]] -suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT - -test: and_test ('or' and_test)* | lambdef -and_test: not_test ('and' not_test)* -not_test: 'not' not_test | comparison -comparison: expr (comp_op expr)* -comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' -expr: xor_expr ('|' xor_expr)* -xor_expr: and_expr ('^' and_expr)* -and_expr: shift_expr ('&' shift_expr)* -shift_expr: arith_expr (('<<'|'>>') arith_expr)* -arith_expr: term (('+'|'-') term)* -term: factor (('*'|'/'|'%'|'//') factor)* -factor: ('+'|'-'|'~') factor | power -power: atom trailer* ['**' factor] -atom: '(' [testlist] ')' | '[' [listmaker] ']' | '{' [dictmaker] '}' | '`' testlist1 '`' | NAME | NUMBER | STRING+ -listmaker: test ( list_for | (',' test)* [','] ) -lambdef: 'lambda' [varargslist] ':' test -trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME -subscriptlist: subscript (',' subscript)* [','] -subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop] -sliceop: ':' [test] -exprlist: expr (',' expr)* [','] -testlist: test (',' test)* [','] -testlist_safe: test [(',' test)+ [',']] -dictmaker: test ':' test (',' test ':' test)* [','] - -classdef: 'class' NAME ['(' testlist ')'] ':' suite - -arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test) -argument: [test '='] test # Really [keyword '='] test - -list_iter: list_for | list_if -list_for: 'for' exprlist 'in' testlist_safe [list_iter] -list_if: 'if' test [list_iter] - -testlist1: test (',' test)* - -# not used in grammar, but may appear in "node" passed from Parser to Compiler -encoding_decl: NAME diff --git a/SDKs/XPlatform/Cypython-2.3.3/LICENSE b/SDKs/XPlatform/Cypython-2.3.3/LICENSE deleted file mode 100644 index 73ef1c4b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/LICENSE +++ /dev/null @@ -1,262 +0,0 @@ -A. HISTORY OF THE SOFTWARE -========================== - -Python was created in the early 1990s by Guido van Rossum at Stichting -Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands -as a successor of a language called ABC. Guido remains Python's -principal author, although it includes many contributions from others. - -In 1995, Guido continued his work on Python at the Corporation for -National Research Initiatives (CNRI, see http://www.cnri.reston.va.us) -in Reston, Virginia where he released several versions of the -software. - -In May 2000, Guido and the Python core development team moved to -BeOpen.com to form the BeOpen PythonLabs team. In October of the same -year, the PythonLabs team moved to Digital Creations (now Zope -Corporation, see http://www.zope.com). In 2001, the Python Software -Foundation (PSF, see http://www.python.org/psf/) was formed, a -non-profit organization created specifically to own Python-related -Intellectual Property. Zope Corporation is a sponsoring member of -the PSF. - -All Python releases are Open Source (see http://www.opensource.org for -the Open Source Definition). Historically, most, but not all, Python -releases have also been GPL-compatible; the table below summarizes -the various releases. - - Release Derived Year Owner GPL- - from compatible? (1) - - 0.9.0 thru 1.2 1991-1995 CWI yes - 1.3 thru 1.5.2 1.2 1995-1999 CNRI yes - 1.6 1.5.2 2000 CNRI no - 2.0 1.6 2000 BeOpen.com no - 1.6.1 1.6 2001 CNRI yes (2) - 2.1 2.0+1.6.1 2001 PSF no - 2.0.1 2.0+1.6.1 2001 PSF yes - 2.1.1 2.1+2.0.1 2001 PSF yes - 2.2 2.1.1 2001 PSF yes - 2.1.2 2.1.1 2002 PSF yes - 2.1.3 2.1.2 2002 PSF yes - 2.2.1 2.2 2002 PSF yes - 2.2.2 2.2.1 2002 PSF yes - 2.2.3 2.2.2 2003 PSF yes - 2.3 2.2.2 2002-2003 PSF yes - 2.3.1 2.3 2002-2003 PSF yes - 2.3.2 2.3.1 2002-2003 PSF yes - 2.3.3 2.3.2 2002-2003 PSF yes - -Footnotes: - -(1) GPL-compatible doesn't mean that we're distributing Python under - the GPL. All Python licenses, unlike the GPL, let you distribute - a modified version without making your changes open source. The - GPL-compatible licenses make it possible to combine Python with - other software that is released under the GPL; the others don't. - -(2) According to Richard Stallman, 1.6.1 is not GPL-compatible, - because its license has a choice of law clause. According to - CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1 - is "not incompatible" with the GPL. - -Thanks to the many outside volunteers who have worked under Guido's -direction to make these releases possible. - - -B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON -=============================================================== - -PSF LICENSE AGREEMENT FOR PYTHON 2.3 ------------------------------------- - -1. This LICENSE AGREEMENT is between the Python Software Foundation -("PSF"), and the Individual or Organization ("Licensee") accessing and -otherwise using Python 2.3 software in source or binary form and its -associated documentation. - -2. Subject to the terms and conditions of this License Agreement, PSF -hereby grants Licensee a nonexclusive, royalty-free, world-wide -license to reproduce, analyze, test, perform and/or display publicly, -prepare derivative works, distribute, and otherwise use Python 2.3 -alone or in any derivative version, provided, however, that PSF's -License Agreement and PSF's notice of copyright, i.e., "Copyright (c) -2001, 2002, 2003 Python Software Foundation; All Rights Reserved" are -retained in Python 2.3 alone or in any derivative version prepared by -Licensee. - -3. In the event Licensee prepares a derivative work that is based on -or incorporates Python 2.3 or any part thereof, and wants to make -the derivative work available to others as provided herein, then -Licensee hereby agrees to include in any such work a brief summary of -the changes made to Python 2.3. - -4. PSF is making Python 2.3 available to Licensee on an "AS IS" -basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR -IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND -DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS -FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.3 WILL NOT -INFRINGE ANY THIRD PARTY RIGHTS. - -5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON -2.3 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS -A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.3, -OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -6. This License Agreement will automatically terminate upon a material -breach of its terms and conditions. - -7. Nothing in this License Agreement shall be deemed to create any -relationship of agency, partnership, or joint venture between PSF and -Licensee. This License Agreement does not grant permission to use PSF -trademarks or trade name in a trademark sense to endorse or promote -products or services of Licensee, or any third party. - -8. By copying, installing or otherwise using Python 2.3, Licensee -agrees to be bound by the terms and conditions of this License -Agreement. - - -BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0 -------------------------------------------- - -BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1 - -1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an -office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the -Individual or Organization ("Licensee") accessing and otherwise using -this software in source or binary form and its associated -documentation ("the Software"). - -2. Subject to the terms and conditions of this BeOpen Python License -Agreement, BeOpen hereby grants Licensee a non-exclusive, -royalty-free, world-wide license to reproduce, analyze, test, perform -and/or display publicly, prepare derivative works, distribute, and -otherwise use the Software alone or in any derivative version, -provided, however, that the BeOpen Python License is retained in the -Software, alone or in any derivative version prepared by Licensee. - -3. BeOpen is making the Software available to Licensee on an "AS IS" -basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR -IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND -DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS -FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT -INFRINGE ANY THIRD PARTY RIGHTS. - -4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE -SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS -AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY -DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -5. This License Agreement will automatically terminate upon a material -breach of its terms and conditions. - -6. This License Agreement shall be governed by and interpreted in all -respects by the law of the State of California, excluding conflict of -law provisions. Nothing in this License Agreement shall be deemed to -create any relationship of agency, partnership, or joint venture -between BeOpen and Licensee. This License Agreement does not grant -permission to use BeOpen trademarks or trade names in a trademark -sense to endorse or promote products or services of Licensee, or any -third party. As an exception, the "BeOpen Python" logos available at -http://www.pythonlabs.com/logos.html may be used according to the -permissions granted on that web page. - -7. By copying, installing or otherwise using the software, Licensee -agrees to be bound by the terms and conditions of this License -Agreement. - - -CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1 ---------------------------------------- - -1. This LICENSE AGREEMENT is between the Corporation for National -Research Initiatives, having an office at 1895 Preston White Drive, -Reston, VA 20191 ("CNRI"), and the Individual or Organization -("Licensee") accessing and otherwise using Python 1.6.1 software in -source or binary form and its associated documentation. - -2. Subject to the terms and conditions of this License Agreement, CNRI -hereby grants Licensee a nonexclusive, royalty-free, world-wide -license to reproduce, analyze, test, perform and/or display publicly, -prepare derivative works, distribute, and otherwise use Python 1.6.1 -alone or in any derivative version, provided, however, that CNRI's -License Agreement and CNRI's notice of copyright, i.e., "Copyright (c) -1995-2001 Corporation for National Research Initiatives; All Rights -Reserved" are retained in Python 1.6.1 alone or in any derivative -version prepared by Licensee. Alternately, in lieu of CNRI's License -Agreement, Licensee may substitute the following text (omitting the -quotes): "Python 1.6.1 is made available subject to the terms and -conditions in CNRI's License Agreement. This Agreement together with -Python 1.6.1 may be located on the Internet using the following -unique, persistent identifier (known as a handle): 1895.22/1013. This -Agreement may also be obtained from a proxy server on the Internet -using the following URL: http://hdl.handle.net/1895.22/1013". - -3. In the event Licensee prepares a derivative work that is based on -or incorporates Python 1.6.1 or any part thereof, and wants to make -the derivative work available to others as provided herein, then -Licensee hereby agrees to include in any such work a brief summary of -the changes made to Python 1.6.1. - -4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS" -basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR -IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND -DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS -FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT -INFRINGE ANY THIRD PARTY RIGHTS. - -5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON -1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS -A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1, -OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -6. This License Agreement will automatically terminate upon a material -breach of its terms and conditions. - -7. This License Agreement shall be governed by the federal -intellectual property law of the United States, including without -limitation the federal copyright law, and, to the extent such -U.S. federal law does not apply, by the law of the Commonwealth of -Virginia, excluding Virginia's conflict of law provisions. -Notwithstanding the foregoing, with regard to derivative works based -on Python 1.6.1 that incorporate non-separable material that was -previously distributed under the GNU General Public License (GPL), the -law of the Commonwealth of Virginia shall govern this License -Agreement only as to issues arising under or with respect to -Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this -License Agreement shall be deemed to create any relationship of -agency, partnership, or joint venture between CNRI and Licensee. This -License Agreement does not grant permission to use CNRI trademarks or -trade name in a trademark sense to endorse or promote products or -services of Licensee, or any third party. - -8. By clicking on the "ACCEPT" button where indicated, or by copying, -installing or otherwise using Python 1.6.1, Licensee agrees to be -bound by the terms and conditions of this License Agreement. - - ACCEPT - - -CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2 --------------------------------------------------- - -Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam, -The Netherlands. All rights reserved. - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/.cvsignore b/SDKs/XPlatform/Cypython-2.3.3/Modules/.cvsignore deleted file mode 100644 index 11c89aa0..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/.cvsignore +++ /dev/null @@ -1,9 +0,0 @@ -Setup -Makefile.pre -Setup.thread -Setup.config -Setup.local -hassignal -config.c -Makefile -add2lib diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/Setup.config.in b/SDKs/XPlatform/Cypython-2.3.3/Modules/Setup.config.in deleted file mode 100644 index 9358a7bb..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/Setup.config.in +++ /dev/null @@ -1,13 +0,0 @@ -# This file is transmogrified into Setup.config by config.status. - -# The purpose of this file is to conditionally enable certain modules -# based on configure-time options. - -# Threading -@USE_THREAD_MODULE@thread threadmodule.c - -# The signal module -@USE_SIGNAL_MODULE@signal signalmodule.c - -# The rest of the modules previously listed in this file are built -# by the setup.py script in Python 2.1 and later. diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/Setup.dist b/SDKs/XPlatform/Cypython-2.3.3/Modules/Setup.dist deleted file mode 100644 index 7dada1c3..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/Setup.dist +++ /dev/null @@ -1,486 +0,0 @@ -# -*- makefile -*- -# The file Setup is used by the makesetup script to construct the files -# Makefile and config.c, from Makefile.pre and config.c.in, -# respectively. The file Setup itself is initially copied from -# Setup.dist; once it exists it will not be overwritten, so you can edit -# Setup to your heart's content. Note that Makefile.pre is created -# from Makefile.pre.in by the toplevel configure script. - -# (VPATH notes: Setup and Makefile.pre are in the build directory, as -# are Makefile and config.c; the *.in and *.dist files are in the source -# directory.) - -# Each line in this file describes one or more optional modules. -# Modules enabled here will not be compiled by the setup.py script, -# so the file can be used to override setup.py's behavior. - -# Lines have the following structure: -# -# ... [ ...] [ ...] [ ...] -# -# is anything ending in .c (.C, .cc, .c++ are C++ files) -# is anything starting with -I, -D, -U or -C -# is anything ending in .a or beginning with -l or -L -# is anything else but should be a valid Python -# identifier (letters, digits, underscores, beginning with non-digit) -# -# (As the makesetup script changes, it may recognize some other -# arguments as well, e.g. *.so and *.sl as libraries. See the big -# case statement in the makesetup script.) -# -# Lines can also have the form -# -# = -# -# which defines a Make variable definition inserted into Makefile.in -# -# Finally, if a line contains just the word "*shared*" (without the -# quotes but with the stars), then the following modules will not be -# built statically. The build process works like this: -# -# 1. Build all modules that are declared as static in Modules/Setup, -# combine them into libpythonxy.a, combine that into python. -# 2. Build all modules that are listed as shared in Modules/Setup. -# 3. Invoke setup.py. That builds all modules that -# a) are not builtin, and -# b) are not listed in Modules/Setup, and -# c) can be build on the target -# -# Therefore, modules declared to be shared will not be -# included in the config.c file, nor in the list of objects to be -# added to the library archive, and their linker options won't be -# added to the linker options. Rules to create their .o files and -# their shared libraries will still be added to the Makefile, and -# their names will be collected in the Make variable SHAREDMODS. This -# is used to build modules as shared libraries. (They can be -# installed using "make sharedinstall", which is implied by the -# toplevel "make install" target.) (For compatibility, -# *noconfig* has the same effect as *shared*.) -# -# In addition, *static* explicitly declares the following modules to -# be static. Lines containing "*static*" and "*shared*" may thus -# alternate thoughout this file. - -# NOTE: As a standard policy, as many modules as can be supported by a -# platform should be present. The distribution comes with all modules -# enabled that are supported by most platforms and don't require you -# to ftp sources from elsewhere. - - -# Some special rules to define PYTHONPATH. -# Edit the definitions below to indicate which options you are using. -# Don't add any whitespace or comments! - -# Directories where library files get installed. -# DESTLIB is for Python modules; MACHDESTLIB for shared libraries. -DESTLIB=$(LIBDEST) -MACHDESTLIB=$(BINLIBDEST) - -# NOTE: all the paths are now relative to the prefix that is computed -# at run time! - -# Standard path -- don't edit. -# No leading colon since this is the first entry. -# Empty since this is now just the runtime prefix. -DESTPATH= - -# Site specific path components -- should begin with : if non-empty -SITEPATH= - -# Standard path components for test modules -TESTPATH= - -# Path components for machine- or system-dependent modules and shared libraries -MACHDEPPATH=:plat-$(MACHDEP) -EXTRAMACHDEPPATH= - -# Path component for the Tkinter-related modules -# The TKPATH variable is always enabled, to save you the effort. -TKPATH=:lib-tk - -COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH)$(TKPATH) -PYTHONPATH=$(COREPYTHONPATH) - - -# The modules listed here can't be built as shared libraries for -# various reasons; therefore they are listed here instead of in the -# normal order. - -# This only contains the minimal set of modules required to run the -# setup.py script in the root of the Python source tree. - -posix posixmodule.c # posix (UNIX) system calls -errno errnomodule.c # posix (UNIX) errno values -_sre _sre.c # Fredrik Lundh's new regular expressions -_codecs _codecsmodule.c # access to the builtin codecs and codec registry - -# The zipimport module is always imported at startup. Having it as a -# builtin module avoids some bootstrapping problems and reduces overhead. -zipimport zipimport.c - -# The rest of the modules listed in this file are all commented out by -# default. Usually they can be detected and built as dynamically -# loaded modules by the new setup.py script added in Python 2.1. If -# you're on a platform that doesn't support dynamic loading, want to -# compile modules statically into the Python binary, or need to -# specify some odd set of compiler switches, you can uncomment the -# appropriate lines below. - -# ====================================================================== - -# The Python symtable module depends on .h files that setup.py doesn't track -_symtable symtablemodule.c - -# The SGI specific GL module: - -GLHACK=-Dclear=__GLclear -#gl glmodule.c cgensupport.c -I$(srcdir) $(GLHACK) -lgl -lX11 - -# Pure module. Cannot be linked dynamically. -# -DWITH_QUANTIFY, -DWITH_PURIFY, or -DWITH_ALL_PURE -#WHICH_PURE_PRODUCTS=-DWITH_ALL_PURE -#PURE_INCLS=-I/usr/local/include -#PURE_STUBLIBS=-L/usr/local/lib -lpurify_stubs -lquantify_stubs -#pure puremodule.c $(WHICH_PURE_PRODUCTS) $(PURE_INCLS) $(PURE_STUBLIBS) - -# Uncommenting the following line tells makesetup that all following -# modules are to be built as shared libraries (see above for more -# detail; also note that *static* reverses this effect): - -#*shared* - -# GNU readline. Unlike previous Python incarnations, GNU readline is -# now incorporated in an optional module, configured in the Setup file -# instead of by a configure script switch. You may have to insert a -# -L option pointing to the directory where libreadline.* lives, -# and you may have to change -ltermcap to -ltermlib or perhaps remove -# it, depending on your system -- see the GNU readline instructions. -# It's okay for this to be a shared library, too. - -#readline readline.c -lreadline -ltermcap - - -# Modules that should always be present (non UNIX dependent): - -#array arraymodule.c # array objects -#cmath cmathmodule.c # -lm # complex math library functions -#math mathmodule.c # -lm # math library functions, e.g. sin() -#struct structmodule.c # binary structure packing/unpacking -#time timemodule.c # -lm # time operations and variables -#operator operator.c # operator.add() and similar goodies -#_weakref _weakref.c # basic weak reference support -#_testcapi _testcapimodule.c # Python C API test module - -#unicodedata unicodedata.c # static Unicode character database - -# access to ISO C locale support -#_locale _localemodule.c # -lintl - - -# Modules with some UNIX dependencies -- on by default: -# (If you have a really backward UNIX, select and socket may not be -# supported...) - -#fcntl fcntlmodule.c # fcntl(2) and ioctl(2) -#pwd pwdmodule.c # pwd(3) -#grp grpmodule.c # grp(3) -#select selectmodule.c # select(2); not on ancient System V - -# Memory-mapped files (also works on Win32). -#mmap mmapmodule.c - -# Dynamic readlines -#xreadlines xreadlinesmodule.c - -# CSV file helper -#_csv _csv.c - -# Socket module helper for socket(2) -#_socket socketmodule.c - -# Socket module helper for SSL support; you must comment out the other -# socket line above, and possibly edit the SSL variable: -#SSL=/usr/local/ssl -#_ssl _ssl.c \ -# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -# -L$(SSL)/lib -lssl -lcrypto - -# The crypt module is now disabled by default because it breaks builds -# on many systems (where -lcrypt is needed), e.g. Linux (I believe). -# -# First, look at Setup.config; configure may have set this for you. - -#crypt cryptmodule.c # -lcrypt # crypt(3); needs -lcrypt on some systems - - -# Some more UNIX dependent modules -- off by default, since these -# are not supported by all UNIX systems: - -#nis nismodule.c -lnsl # Sun yellow pages -- not everywhere -#termios termios.c # Steen Lumholt's termios module -#resource resource.c # Jeremy Hylton's rlimit interface - - -# Multimedia modules -- off by default. -# These don't work for 64-bit platforms!!! -# These represent audio samples or images as strings: - -#audioop audioop.c # Operations on audio samples -#imageop imageop.c # Operations on images -#rgbimg rgbimgmodule.c # Read SGI RGB image files (but coded portably) - - -# The md5 module implements the RSA Data Security, Inc. MD5 -# Message-Digest Algorithm, described in RFC 1321. The necessary files -# md5c.c and md5.h are included here. - -#md5 md5module.c md5c.c - - -# The sha module implements the SHA checksum algorithm. -# (NIST's Secure Hash Algorithm.) -#sha shamodule.c - - -# The mpz module interfaces to the GNU Multiple Precision library. -# You need to ftp the GNU MP library. -# The GMP variable must point to the GMP source directory. -# This was originally written and tested against GMP 1.2 and 1.3.2. -# It has been modified by Rob Hooft to work with 2.0.2 as well, but I -# haven't tested it recently. - -# A compatible MP library unencombered by the GPL also exists. It was -# posted to comp.sources.misc in volume 40 and is widely available from -# FTP archive sites. One URL for it is: -# ftp://gatekeeper.dec.com/.b/usenet/comp.sources.misc/volume40/fgmp/part01.Z - -#GMP=/ufs/guido/src/gmp -#mpz mpzmodule.c -I$(GMP) $(GMP)/libgmp.a - - -# SGI IRIX specific modules -- off by default. - -# These module work on any SGI machine: - -# *** gl must be enabled higher up in this file *** -#fm fmmodule.c $(GLHACK) -lfm -lgl # Font Manager -#sgi sgimodule.c # sgi.nap() and a few more - -# This module requires the header file -# /usr/people/4Dgifts/iristools/include/izoom.h: -#imgfile imgfile.c -limage -lgutil -lgl -lm # Image Processing Utilities - - -# These modules require the Multimedia Development Option (I think): - -#al almodule.c -laudio # Audio Library -#cd cdmodule.c -lcdaudio -lds -lmediad # CD Audio Library -#cl clmodule.c -lcl -lawareaudio # Compression Library -#sv svmodule.c yuvconvert.c -lsvideo -lXext -lX11 # Starter Video - - -# The FORMS library, by Mark Overmars, implements user interface -# components such as dialogs and buttons using SGI's GL and FM -# libraries. You must ftp the FORMS library separately from -# ftp://ftp.cs.ruu.nl/pub/SGI/FORMS. It was tested with FORMS 2.2a. -# NOTE: if you want to be able to use FORMS and curses simultaneously -# (or both link them statically into the same binary), you must -# compile all of FORMS with the cc option "-Dclear=__GLclear". - -# The FORMS variable must point to the FORMS subdirectory of the forms -# toplevel directory: - -#FORMS=/ufs/guido/src/forms/FORMS -#fl flmodule.c -I$(FORMS) $(GLHACK) $(FORMS)/libforms.a -lfm -lgl - - -# SunOS specific modules -- off by default: - -#sunaudiodev sunaudiodev.c - - -# A Linux specific module -- off by default; this may also work on -# some *BSDs. - -#linuxaudiodev linuxaudiodev.c - - -# George Neville-Neil's timing module: - -#timing timingmodule.c - - -# The _tkinter module. -# -# The command for _tkinter is long and site specific. Please -# uncomment and/or edit those parts as indicated. If you don't have a -# specific extension (e.g. Tix or BLT), leave the corresponding line -# commented out. (Leave the trailing backslashes in! If you -# experience strange errors, you may want to join all uncommented -# lines and remove the backslashes -- the backslash interpretation is -# done by the shell's "read" command and it may not be implemented on -# every system. - -# *** Always uncomment this (leave the leading underscore in!): -# _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \ -# *** Uncomment and edit to reflect where your Tcl/Tk libraries are: -# -L/usr/local/lib \ -# *** Uncomment and edit to reflect where your Tcl/Tk headers are: -# -I/usr/local/include \ -# *** Uncomment and edit to reflect where your X11 header files are: -# -I/usr/X11R6/include \ -# *** Or uncomment this for Solaris: -# -I/usr/openwin/include \ -# *** Uncomment and edit for Tix extension only: -# -DWITH_TIX -ltix8.1.8.2 \ -# *** Uncomment and edit for BLT extension only: -# -DWITH_BLT -I/usr/local/blt/blt8.0-unoff/include -lBLT8.0 \ -# *** Uncomment and edit for PIL (TkImaging) extension only: -# (See http://www.pythonware.com/products/pil/ for more info) -# -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ -# *** Uncomment and edit for TOGL extension only: -# -DWITH_TOGL togl.c \ -# *** Uncomment and edit to reflect your Tcl/Tk versions: -# -ltk8.2 -ltcl8.2 \ -# *** Uncomment and edit to reflect where your X11 libraries are: -# -L/usr/X11R6/lib \ -# *** Or uncomment this for Solaris: -# -L/usr/openwin/lib \ -# *** Uncomment these for TOGL extension only: -# -lGL -lGLU -lXext -lXmu \ -# *** Uncomment for AIX: -# -lld \ -# *** Always uncomment this; X11 libraries to link with: -# -lX11 - -# Lance Ellinghaus's modules: - -#rotor rotormodule.c # enigma-inspired encryption -#syslog syslogmodule.c # syslog daemon interface - - -# Curses support, requring the System V version of curses, often -# provided by the ncurses library. e.g. on Linux, link with -lncurses -# instead of -lcurses; on SunOS 4.1.3, insert -I/usr/5include -# -L/usr/5lib before -lcurses). -# -# First, look at Setup.config; configure may have set this for you. - -#_curses _cursesmodule.c -lcurses -ltermcap -# Wrapper for the panel library that's part of ncurses and SYSV curses. -#_curses_panel _curses_panel.c -lpanel -lncurses - - -# Generic (SunOS / SVR4) dynamic loading module. -# This is not needed for dynamic loading of Python modules -- -# it is a highly experimental and dangerous device for calling -# *arbitrary* C functions in *arbitrary* shared libraries: - -#dl dlmodule.c - - -# Modules that provide persistent dictionary-like semantics. You will -# probably want to arrange for at least one of them to be available on -# your machine, though none are defined by default because of library -# dependencies. The Python module anydbm.py provides an -# implementation independent wrapper for these; dumbdbm.py provides -# similar functionality (but slower of course) implemented in Python. - -# The standard Unix dbm module has been moved to Setup.config so that -# it will be compiled as a shared library by default. Compiling it as -# a built-in module causes conflicts with the pybsddb3 module since it -# creates a static dependency on an out-of-date version of db.so. -# -# First, look at Setup.config; configure may have set this for you. - -#dbm dbmmodule.c # dbm(3) may require -lndbm or similar - -# Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: -# -# First, look at Setup.config; configure may have set this for you. - -#gdbm gdbmmodule.c -I/usr/local/include -L/usr/local/lib -lgdbm - - -# Sleepycat Berkeley DB interface. -# -# This requires the Sleepycat DB code, see http://www.sleepycat.com/ -# The earliest supported version of that library is 3.0, the latest -# supported version is 4.0 (4.1 is specifically not supported, as that -# changes the semantics of transactional databases). A list of available -# releases can be found at -# -# http://www.sleepycat.com/update/index.html -# -# Edit the variables DB and DBLIBVERto point to the db top directory -# and the subdirectory of PORT where you built it. -#DB=/usr/local/BerkeleyDB.4.0 -#DBLIBVER=4.0 -#DBINC=$(DB)/include -#DBLIB=$(DB)/lib -#_bsddb _bsddb.c -I$(DBINC) -L$(DBLIB) -ldb-$(DBLIBVER) - -# Historical Berkeley DB 1.85 -# -# This module is deprecated; the 1.85 version of the Berkeley DB library has -# bugs that can cause data corruption. If you can, use later versions of the -# library instead, available from . - -#DB=/depot/sundry/src/berkeley-db/db.1.85 -#DBPORT=$(DB)/PORT/irix.5.3 -#bsddb185 bsddbmodule.c -I$(DBPORT)/include -I$(DBPORT) $(DBPORT)/libdb.a - - - -# Helper module for various ascii-encoders -#binascii binascii.c - -# Fred Drake's interface to the Python parser -#parser parsermodule.c - -# cStringIO and cPickle -#cStringIO cStringIO.c -#cPickle cPickle.c - - -# Lee Busby's SIGFPE modules. -# The library to link fpectl with is platform specific. -# Choose *one* of the options below for fpectl: - -# For SGI IRIX (tested on 5.3): -#fpectl fpectlmodule.c -lfpe - -# For Solaris with SunPro compiler (tested on Solaris 2.5 with SunPro C 4.2): -# (Without the compiler you don't have -lsunmath.) -#fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm - -# For other systems: see instructions in fpectlmodule.c. -#fpectl fpectlmodule.c ... - -# Test module for fpectl. No extra libraries needed. -#fpetest fpetestmodule.c - -# Andrew Kuchling's zlib module. -# This require zlib 1.1.3 (or later). -# See http://www.cdrom.com/pub/infozip/zlib/ -#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz - -# Interface to the Expat XML parser -# -# Expat was written by James Clark and is now maintained by a group of -# developers on SourceForge; see www.libexpat.org for more -# information. The pyexpat module was written by Paul Prescod after a -# prototype by Jack Jansen. Source of Expat 1.95.2 is included in -# Modules/expat/. Usage of a system shared libexpat.so/expat.dll is -# not advised. -# -# More information on Expat can be found at www.libexpat.org. -# -#EXPAT_DIR=/usr/local/src/expat-1.95.2 -#pyexpat pyexpat.c -DHAVE_EXPAT_H -I$(EXPAT_DIR)/lib -L$(EXPAT_DIR) -lexpat - -# Example -- included for reference only: -# xx xxmodule.c - -# Another example -- the 'xxsubtype' module shows C-level subtyping in action -xxsubtype xxsubtype.c diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/_bsddb.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/_bsddb.c deleted file mode 100644 index 51923c65..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/_bsddb.c +++ /dev/null @@ -1,4715 +0,0 @@ -/*---------------------------------------------------------------------- - Copyright (c) 1999-2001, Digital Creations, Fredericksburg, VA, USA - and Andrew Kuchling. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - o Redistributions of source code must retain the above copyright - notice, this list of conditions, and the disclaimer that follows. - - o Redistributions in binary form must reproduce the above copyright - notice, this list of conditions, and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - o Neither the name of Digital Creations nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS AND CONTRIBUTORS *AS - IS* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL - CREATIONS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - DAMAGE. -------------------------------------------------------------------------*/ - - -/* - * Handwritten code to wrap version 3.x of the Berkeley DB library, - * written to replace a SWIG-generated file. It has since been updated - * to compile with BerkeleyDB versions 3.2 through 4.2. - * - * This module was started by Andrew Kuchling to remove the dependency - * on SWIG in a package by Gregory P. Smith who - * based his work on a similar package by Robin Dunn - * which wrapped Berkeley DB 2.7.x. - * - * Development of this module then returned full circle back to Robin Dunn - * who worked on behalf of Digital Creations to complete the wrapping of - * the DB 3.x API and to build a solid unit test suite. Robin has - * since gone onto other projects (wxPython). - * - * Gregory P. Smith is once again the maintainer. - * - * Use the pybsddb-users@lists.sf.net mailing list for all questions. - * Things can change faster than the header of this file is updated. This - * file is shared with the PyBSDDB project at SourceForge: - * - * http://pybsddb.sf.net - * - * This file should remain backward compatible with Python 2.1, but see PEP - * 291 for the most current backward compatibility requirements: - * - * http://www.python.org/peps/pep-0291.html - * - * This module contains 5 types: - * - * DB (Database) - * DBCursor (Database Cursor) - * DBEnv (database environment) - * DBTxn (An explicit database transaction) - * DBLock (A lock handle) - * - */ - -/* --------------------------------------------------------------------- */ - -/* - * Portions of this module, associated unit tests and build scripts are the - * result of a contract with The Written Word (http://thewrittenword.com/) - * Many thanks go out to them for causing me to raise the bar on quality and - * functionality, resulting in a better bsddb3 package for all of us to use. - * - * --Robin - */ - -/* --------------------------------------------------------------------- */ - -#include -#include - -/* --------------------------------------------------------------------- */ -/* Various macro definitions */ - -/* 40 = 4.0, 33 = 3.3; this will break if the second number is > 9 */ -#define DBVER (DB_VERSION_MAJOR * 10 + DB_VERSION_MINOR) - -#define PY_BSDDB_VERSION "4.2.0" -static char *rcs_id = "$Id: _bsddb.c,v 1.17.6.2 2003/09/21 23:10:23 greg Exp $"; - - -#ifdef WITH_THREAD - -/* These are for when calling Python --> C */ -#define MYDB_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS; -#define MYDB_END_ALLOW_THREADS Py_END_ALLOW_THREADS; - -/* For 2.3, use the PyGILState_ calls */ -#if (PY_VERSION_HEX >= 0x02030000) -#define MYDB_USE_GILSTATE -#endif - -/* and these are for calling C --> Python */ -#if defined(MYDB_USE_GILSTATE) -#define MYDB_BEGIN_BLOCK_THREADS \ - PyGILState_STATE __savestate = PyGILState_Ensure(); -#define MYDB_END_BLOCK_THREADS \ - PyGILState_Release(__savestate); -#else /* MYDB_USE_GILSTATE */ -/* Pre GILState API - do it the long old way */ -static PyInterpreterState* _db_interpreterState = NULL; -#define MYDB_BEGIN_BLOCK_THREADS { \ - PyThreadState* prevState; \ - PyThreadState* newState; \ - PyEval_AcquireLock(); \ - newState = PyThreadState_New(_db_interpreterState); \ - prevState = PyThreadState_Swap(newState); - -#define MYDB_END_BLOCK_THREADS \ - newState = PyThreadState_Swap(prevState); \ - PyThreadState_Clear(newState); \ - PyEval_ReleaseLock(); \ - PyThreadState_Delete(newState); \ - } -#endif /* MYDB_USE_GILSTATE */ - -#else -/* Compiled without threads - avoid all this cruft */ -#define MYDB_BEGIN_ALLOW_THREADS -#define MYDB_END_ALLOW_THREADS -#define MYDB_BEGIN_BLOCK_THREADS -#define MYDB_END_BLOCK_THREADS - -#endif - -/* Should DB_INCOMPLETE be turned into a warning or an exception? */ -#define INCOMPLETE_IS_WARNING 1 - -/* --------------------------------------------------------------------- */ -/* Exceptions */ - -static PyObject* DBError; /* Base class, all others derive from this */ -static PyObject* DBKeyEmptyError; /* DB_KEYEMPTY */ -static PyObject* DBKeyExistError; /* DB_KEYEXIST */ -static PyObject* DBLockDeadlockError; /* DB_LOCK_DEADLOCK */ -static PyObject* DBLockNotGrantedError; /* DB_LOCK_NOTGRANTED */ -static PyObject* DBNotFoundError; /* DB_NOTFOUND: also derives from KeyError */ -static PyObject* DBOldVersionError; /* DB_OLD_VERSION */ -static PyObject* DBRunRecoveryError; /* DB_RUNRECOVERY */ -static PyObject* DBVerifyBadError; /* DB_VERIFY_BAD */ -static PyObject* DBNoServerError; /* DB_NOSERVER */ -static PyObject* DBNoServerHomeError; /* DB_NOSERVER_HOME */ -static PyObject* DBNoServerIDError; /* DB_NOSERVER_ID */ -#if (DBVER >= 33) -static PyObject* DBPageNotFoundError; /* DB_PAGE_NOTFOUND */ -static PyObject* DBSecondaryBadError; /* DB_SECONDARY_BAD */ -#endif - -#if !INCOMPLETE_IS_WARNING -static PyObject* DBIncompleteError; /* DB_INCOMPLETE */ -#endif - -static PyObject* DBInvalidArgError; /* EINVAL */ -static PyObject* DBAccessError; /* EACCES */ -static PyObject* DBNoSpaceError; /* ENOSPC */ -static PyObject* DBNoMemoryError; /* ENOMEM */ -static PyObject* DBAgainError; /* EAGAIN */ -static PyObject* DBBusyError; /* EBUSY */ -static PyObject* DBFileExistsError; /* EEXIST */ -static PyObject* DBNoSuchFileError; /* ENOENT */ -static PyObject* DBPermissionsError; /* EPERM */ - - - -/* --------------------------------------------------------------------- */ -/* Structure definitions */ - -struct behaviourFlags { - /* What is the default behaviour when DB->get or DBCursor->get returns a - DB_NOTFOUND error? Return None or raise an exception? */ - unsigned int getReturnsNone : 1; - /* What is the default behaviour for DBCursor.set* methods when DBCursor->get - * returns a DB_NOTFOUND error? Return None or raise an exception? */ - unsigned int cursorSetReturnsNone : 1; -}; - -#define DEFAULT_GET_RETURNS_NONE 1 -#define DEFAULT_CURSOR_SET_RETURNS_NONE 0 /* 0 in pybsddb < 4.2, python < 2.4 */ - -typedef struct { - PyObject_HEAD - DB_ENV* db_env; - u_int32_t flags; /* saved flags from open() */ - int closed; - struct behaviourFlags moduleFlags; -} DBEnvObject; - - -typedef struct { - PyObject_HEAD - DB* db; - DBEnvObject* myenvobj; /* PyObject containing the DB_ENV */ - u_int32_t flags; /* saved flags from open() */ - u_int32_t setflags; /* saved flags from set_flags() */ - int haveStat; - struct behaviourFlags moduleFlags; -#if (DBVER >= 33) - PyObject* associateCallback; - int primaryDBType; -#endif -} DBObject; - - -typedef struct { - PyObject_HEAD - DBC* dbc; - DBObject* mydb; -} DBCursorObject; - - -typedef struct { - PyObject_HEAD - DB_TXN* txn; -} DBTxnObject; - - -typedef struct { - PyObject_HEAD - DB_LOCK lock; -} DBLockObject; - - - -staticforward PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type, DBTxn_Type, DBLock_Type; - -#define DBObject_Check(v) ((v)->ob_type == &DB_Type) -#define DBCursorObject_Check(v) ((v)->ob_type == &DBCursor_Type) -#define DBEnvObject_Check(v) ((v)->ob_type == &DBEnv_Type) -#define DBTxnObject_Check(v) ((v)->ob_type == &DBTxn_Type) -#define DBLockObject_Check(v) ((v)->ob_type == &DBLock_Type) - - -/* --------------------------------------------------------------------- */ -/* Utility macros and functions */ - -#define RETURN_IF_ERR() \ - if (makeDBError(err)) { \ - return NULL; \ - } - -#define RETURN_NONE() Py_INCREF(Py_None); return Py_None; - -#define CHECK_DB_NOT_CLOSED(dbobj) \ - if (dbobj->db == NULL) { \ - PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, \ - "DB object has been closed")); \ - return NULL; \ - } - -#define CHECK_ENV_NOT_CLOSED(env) \ - if (env->db_env == NULL) { \ - PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, \ - "DBEnv object has been closed"));\ - return NULL; \ - } - -#define CHECK_CURSOR_NOT_CLOSED(curs) \ - if (curs->dbc == NULL) { \ - PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, \ - "DBCursor object has been closed"));\ - return NULL; \ - } - - - -#define CHECK_DBFLAG(mydb, flag) (((mydb)->flags & (flag)) || \ - (((mydb)->myenvobj != NULL) && ((mydb)->myenvobj->flags & (flag)))) - -#define CLEAR_DBT(dbt) (memset(&(dbt), 0, sizeof(dbt))) - -#define FREE_DBT(dbt) if ((dbt.flags & (DB_DBT_MALLOC|DB_DBT_REALLOC)) && \ - dbt.data != NULL) { free(dbt.data); } - - -static int makeDBError(int err); - - -/* Return the access method type of the DBObject */ -static int _DB_get_type(DBObject* self) -{ -#if (DBVER >= 33) - DBTYPE type; - int err; - err = self->db->get_type(self->db, &type); - if (makeDBError(err)) { - return -1; - } - return type; -#else - return self->db->get_type(self->db); -#endif -} - - -/* Create a DBT structure (containing key and data values) from Python - strings. Returns 1 on success, 0 on an error. */ -static int make_dbt(PyObject* obj, DBT* dbt) -{ - CLEAR_DBT(*dbt); - if (obj == Py_None) { - /* no need to do anything, the structure has already been zeroed */ - } - else if (!PyArg_Parse(obj, "s#", &dbt->data, &dbt->size)) { - PyErr_SetString(PyExc_TypeError, - "Key and Data values must be of type string or None."); - return 0; - } - return 1; -} - - -/* Recno and Queue DBs can have integer keys. This function figures out - what's been given, verifies that it's allowed, and then makes the DBT. - - Caller should call FREE_DBT(key) when done. */ -static int -make_key_dbt(DBObject* self, PyObject* keyobj, DBT* key, int* pflags) -{ - db_recno_t recno; - int type; - - CLEAR_DBT(*key); - if (keyobj == Py_None) { /* TODO: is None really okay for keys? */ - /* no need to do anything, the structure has already been zeroed */ - } - - else if (PyString_Check(keyobj)) { - /* verify access method type */ - type = _DB_get_type(self); - if (type == -1) - return 0; - if (type == DB_RECNO || type == DB_QUEUE) { - PyErr_SetString( - PyExc_TypeError, - "String keys not allowed for Recno and Queue DB's"); - return 0; - } - - key->data = PyString_AS_STRING(keyobj); - key->size = PyString_GET_SIZE(keyobj); - } - - else if (PyInt_Check(keyobj)) { - /* verify access method type */ - type = _DB_get_type(self); - if (type == -1) - return 0; - if (type == DB_BTREE && pflags != NULL) { - /* if BTREE then an Integer key is allowed with the - * DB_SET_RECNO flag */ - *pflags |= DB_SET_RECNO; - } - else if (type != DB_RECNO && type != DB_QUEUE) { - PyErr_SetString( - PyExc_TypeError, - "Integer keys only allowed for Recno and Queue DB's"); - return 0; - } - - /* Make a key out of the requested recno, use allocated space so DB - * will be able to realloc room for the real key if needed. */ - recno = PyInt_AS_LONG(keyobj); - key->data = malloc(sizeof(db_recno_t)); - if (key->data == NULL) { - PyErr_SetString(PyExc_MemoryError, "Key memory allocation failed"); - return 0; - } - key->ulen = key->size = sizeof(db_recno_t); - memcpy(key->data, &recno, sizeof(db_recno_t)); - key->flags = DB_DBT_REALLOC; - } - else { - PyErr_Format(PyExc_TypeError, - "String or Integer object expected for key, %s found", - keyobj->ob_type->tp_name); - return 0; - } - - return 1; -} - - -/* Add partial record access to an existing DBT data struct. - If dlen and doff are set, then the DB_DBT_PARTIAL flag will be set - and the data storage/retrieval will be done using dlen and doff. */ -static int add_partial_dbt(DBT* d, int dlen, int doff) { - /* if neither were set we do nothing (-1 is the default value) */ - if ((dlen == -1) && (doff == -1)) { - return 1; - } - - if ((dlen < 0) || (doff < 0)) { - PyErr_SetString(PyExc_TypeError, "dlen and doff must both be >= 0"); - return 0; - } - - d->flags = d->flags | DB_DBT_PARTIAL; - d->dlen = (unsigned int) dlen; - d->doff = (unsigned int) doff; - return 1; -} - - -/* Callback used to save away more information about errors from the DB - * library. */ -static char _db_errmsg[1024]; -static void _db_errorCallback(const char* prefix, char* msg) -{ - strcpy(_db_errmsg, msg); -} - - -/* make a nice exception object to raise for errors. */ -static int makeDBError(int err) -{ - char errTxt[2048]; /* really big, just in case... */ - PyObject *errObj = NULL; - PyObject *errTuple = NULL; - int exceptionRaised = 0; - - switch (err) { - case 0: /* successful, no error */ break; - -#if (DBVER < 41) - case DB_INCOMPLETE: -#if INCOMPLETE_IS_WARNING - strcpy(errTxt, db_strerror(err)); - if (_db_errmsg[0]) { - strcat(errTxt, " -- "); - strcat(errTxt, _db_errmsg); - _db_errmsg[0] = 0; - } -/* if Python 2.1 or better use warning framework */ -#if PYTHON_API_VERSION >= 1010 - exceptionRaised = PyErr_Warn(PyExc_RuntimeWarning, errTxt); -#else - fprintf(stderr, errTxt); - fprintf(stderr, "\n"); -#endif - -#else /* do an exception instead */ - errObj = DBIncompleteError; -#endif - break; -#endif /* DBVER < 41 */ - - case DB_KEYEMPTY: errObj = DBKeyEmptyError; break; - case DB_KEYEXIST: errObj = DBKeyExistError; break; - case DB_LOCK_DEADLOCK: errObj = DBLockDeadlockError; break; - case DB_LOCK_NOTGRANTED: errObj = DBLockNotGrantedError; break; - case DB_NOTFOUND: errObj = DBNotFoundError; break; - case DB_OLD_VERSION: errObj = DBOldVersionError; break; - case DB_RUNRECOVERY: errObj = DBRunRecoveryError; break; - case DB_VERIFY_BAD: errObj = DBVerifyBadError; break; - case DB_NOSERVER: errObj = DBNoServerError; break; - case DB_NOSERVER_HOME: errObj = DBNoServerHomeError; break; - case DB_NOSERVER_ID: errObj = DBNoServerIDError; break; -#if (DBVER >= 33) - case DB_PAGE_NOTFOUND: errObj = DBPageNotFoundError; break; - case DB_SECONDARY_BAD: errObj = DBSecondaryBadError; break; -#endif - - case EINVAL: errObj = DBInvalidArgError; break; - case EACCES: errObj = DBAccessError; break; - case ENOSPC: errObj = DBNoSpaceError; break; - case ENOMEM: errObj = DBNoMemoryError; break; - case EAGAIN: errObj = DBAgainError; break; - case EBUSY : errObj = DBBusyError; break; - case EEXIST: errObj = DBFileExistsError; break; - case ENOENT: errObj = DBNoSuchFileError; break; - case EPERM : errObj = DBPermissionsError; break; - - default: errObj = DBError; break; - } - - if (errObj != NULL) { - /* FIXME this needs proper bounds checking on errTxt */ - strcpy(errTxt, db_strerror(err)); - if (_db_errmsg[0]) { - strcat(errTxt, " -- "); - strcat(errTxt, _db_errmsg); - _db_errmsg[0] = 0; - } - - errTuple = Py_BuildValue("(is)", err, errTxt); - PyErr_SetObject(errObj, errTuple); - Py_DECREF(errTuple); - } - - return ((errObj != NULL) || exceptionRaised); -} - - - -/* set a type exception */ -static void makeTypeError(char* expected, PyObject* found) -{ - PyErr_Format(PyExc_TypeError, "Expected %s argument, %s found.", - expected, found->ob_type->tp_name); -} - - -/* verify that an obj is either None or a DBTxn, and set the txn pointer */ -static int checkTxnObj(PyObject* txnobj, DB_TXN** txn) -{ - if (txnobj == Py_None || txnobj == NULL) { - *txn = NULL; - return 1; - } - if (DBTxnObject_Check(txnobj)) { - *txn = ((DBTxnObject*)txnobj)->txn; - return 1; - } - else - makeTypeError("DBTxn", txnobj); - return 0; -} - - -/* Delete a key from a database - Returns 0 on success, -1 on an error. */ -static int _DB_delete(DBObject* self, DB_TXN *txn, DBT *key, int flags) -{ - int err; - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->del(self->db, txn, key, 0); - MYDB_END_ALLOW_THREADS; - if (makeDBError(err)) { - return -1; - } - self->haveStat = 0; - return 0; -} - - -/* Store a key into a database - Returns 0 on success, -1 on an error. */ -static int _DB_put(DBObject* self, DB_TXN *txn, DBT *key, DBT *data, int flags) -{ - int err; - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->put(self->db, txn, key, data, flags); - MYDB_END_ALLOW_THREADS; - if (makeDBError(err)) { - return -1; - } - self->haveStat = 0; - return 0; -} - -/* Get a key/data pair from a cursor */ -static PyObject* _DBCursor_get(DBCursorObject* self, int extra_flags, - PyObject *args, PyObject *kwargs, char *format) -{ - int err; - PyObject* retval = NULL; - DBT key, data; - int dlen = -1; - int doff = -1; - int flags = 0; - char* kwnames[] = { "flags", "dlen", "doff", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, format, kwnames, - &flags, &dlen, &doff)) - return NULL; - - CHECK_CURSOR_NOT_CLOSED(self); - - flags |= extra_flags; - CLEAR_DBT(key); - CLEAR_DBT(data); - if (CHECK_DBFLAG(self->mydb, DB_THREAD)) { - /* Tell BerkeleyDB to malloc the return value (thread safe) */ - data.flags = DB_DBT_MALLOC; - key.flags = DB_DBT_MALLOC; - } - if (!add_partial_dbt(&data, dlen, doff)) - return NULL; - - MYDB_BEGIN_ALLOW_THREADS; - err = self->dbc->c_get(self->dbc, &key, &data, flags); - MYDB_END_ALLOW_THREADS; - - if ((err == DB_NOTFOUND) && self->mydb->moduleFlags.getReturnsNone) { - Py_INCREF(Py_None); - retval = Py_None; - } - else if (makeDBError(err)) { - retval = NULL; - } - else { /* otherwise, success! */ - - /* if Recno or Queue, return the key as an Int */ - switch (_DB_get_type(self->mydb)) { - case -1: - retval = NULL; - break; - - case DB_RECNO: - case DB_QUEUE: - retval = Py_BuildValue("is#", *((db_recno_t*)key.data), - data.data, data.size); - break; - case DB_HASH: - case DB_BTREE: - default: - retval = Py_BuildValue("s#s#", key.data, key.size, - data.data, data.size); - break; - } - } - if (!err) { - FREE_DBT(key); - FREE_DBT(data); - } - return retval; -} - - -/* add an integer to a dictionary using the given name as a key */ -static void _addIntToDict(PyObject* dict, char *name, int value) -{ - PyObject* v = PyInt_FromLong((long) value); - if (!v || PyDict_SetItemString(dict, name, v)) - PyErr_Clear(); - - Py_XDECREF(v); -} - - - - -/* --------------------------------------------------------------------- */ -/* Allocators and deallocators */ - -static DBObject* -newDBObject(DBEnvObject* arg, int flags) -{ - DBObject* self; - DB_ENV* db_env = NULL; - int err; - -#if PYTHON_API_VERSION <= 1007 - /* 1.5 compatibility */ - self = PyObject_NEW(DBObject, &DB_Type); -#else - self = PyObject_New(DBObject, &DB_Type); -#endif - - if (self == NULL) - return NULL; - - self->haveStat = 0; - self->flags = 0; - self->setflags = 0; - self->myenvobj = NULL; -#if (DBVER >= 33) - self->associateCallback = NULL; - self->primaryDBType = 0; -#endif - - /* keep a reference to our python DBEnv object */ - if (arg) { - Py_INCREF(arg); - self->myenvobj = arg; - db_env = arg->db_env; - } - - if (self->myenvobj) - self->moduleFlags = self->myenvobj->moduleFlags; - else - self->moduleFlags.getReturnsNone = DEFAULT_GET_RETURNS_NONE; - self->moduleFlags.cursorSetReturnsNone = DEFAULT_CURSOR_SET_RETURNS_NONE; - - MYDB_BEGIN_ALLOW_THREADS; - err = db_create(&self->db, db_env, flags); - self->db->set_errcall(self->db, _db_errorCallback); -#if (DBVER >= 33) - self->db->app_private = (void*)self; -#endif - MYDB_END_ALLOW_THREADS; - if (makeDBError(err)) { - if (self->myenvobj) { - Py_DECREF(self->myenvobj); - self->myenvobj = NULL; - } - self = NULL; - } - return self; -} - - -static void -DB_dealloc(DBObject* self) -{ - if (self->db != NULL) { - /* avoid closing a DB when its DBEnv has been closed out from under - * it */ - if (!self->myenvobj || - (self->myenvobj && self->myenvobj->db_env)) - { - MYDB_BEGIN_ALLOW_THREADS; - self->db->close(self->db, 0); - MYDB_END_ALLOW_THREADS; - /* if Python 2.1 or better use warning framework */ -#if PYTHON_API_VERSION >= 1010 - } else { - PyErr_Warn(PyExc_RuntimeWarning, - "DB could not be closed in destructor: DBEnv already closed"); -#endif - } - self->db = NULL; - } - if (self->myenvobj) { - Py_DECREF(self->myenvobj); - self->myenvobj = NULL; - } -#if (DBVER >= 33) - if (self->associateCallback != NULL) { - Py_DECREF(self->associateCallback); - self->associateCallback = NULL; - } -#endif -#if PYTHON_API_VERSION <= 1007 - PyMem_DEL(self); -#else - PyObject_Del(self); -#endif -} - - -static DBCursorObject* -newDBCursorObject(DBC* dbc, DBObject* db) -{ - DBCursorObject* self; -#if PYTHON_API_VERSION <= 1007 - self = PyObject_NEW(DBCursorObject, &DBCursor_Type); -#else - self = PyObject_New(DBCursorObject, &DBCursor_Type); -#endif - if (self == NULL) - return NULL; - - self->dbc = dbc; - self->mydb = db; - Py_INCREF(self->mydb); - return self; -} - - -static void -DBCursor_dealloc(DBCursorObject* self) -{ - int err; - if (self->dbc != NULL) { - MYDB_BEGIN_ALLOW_THREADS; - /* If the underlying database has been closed, we don't - need to do anything. If the environment has been closed - we need to leak, as BerkeleyDB will crash trying to access - the environment. There was an exception when the - user closed the environment even though there still was - a database open. */ - if (self->mydb->db && self->mydb->myenvobj && - !self->mydb->myenvobj->closed) - err = self->dbc->c_close(self->dbc); - self->dbc = NULL; - MYDB_END_ALLOW_THREADS; - } - Py_XDECREF( self->mydb ); -#if PYTHON_API_VERSION <= 1007 - PyMem_DEL(self); -#else - PyObject_Del(self); -#endif -} - - -static DBEnvObject* -newDBEnvObject(int flags) -{ - int err; - DBEnvObject* self; -#if PYTHON_API_VERSION <= 1007 - self = PyObject_NEW(DBEnvObject, &DBEnv_Type); -#else - self = PyObject_New(DBEnvObject, &DBEnv_Type); -#endif - - if (self == NULL) - return NULL; - - self->closed = 1; - self->flags = flags; - self->moduleFlags.getReturnsNone = DEFAULT_GET_RETURNS_NONE; - self->moduleFlags.cursorSetReturnsNone = DEFAULT_CURSOR_SET_RETURNS_NONE; - - MYDB_BEGIN_ALLOW_THREADS; - err = db_env_create(&self->db_env, flags); - MYDB_END_ALLOW_THREADS; - if (makeDBError(err)) { - self = NULL; - } - else { - self->db_env->set_errcall(self->db_env, _db_errorCallback); - } - return self; -} - - -static void -DBEnv_dealloc(DBEnvObject* self) -{ - if (!self->closed) { - MYDB_BEGIN_ALLOW_THREADS; - self->db_env->close(self->db_env, 0); - MYDB_END_ALLOW_THREADS; - } -#if PYTHON_API_VERSION <= 1007 - PyMem_DEL(self); -#else - PyObject_Del(self); -#endif -} - - -static DBTxnObject* -newDBTxnObject(DBEnvObject* myenv, DB_TXN *parent, int flags) -{ - int err; - DBTxnObject* self; - -#if PYTHON_API_VERSION <= 1007 - self = PyObject_NEW(DBTxnObject, &DBTxn_Type); -#else - self = PyObject_New(DBTxnObject, &DBTxn_Type); -#endif - if (self == NULL) - return NULL; - - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 40) - err = myenv->db_env->txn_begin(myenv->db_env, parent, &(self->txn), flags); -#else - err = txn_begin(myenv->db_env, parent, &(self->txn), flags); -#endif - MYDB_END_ALLOW_THREADS; - if (makeDBError(err)) { - self = NULL; - } - return self; -} - - -static void -DBTxn_dealloc(DBTxnObject* self) -{ - /* XXX nothing to do for transaction objects?!? */ - - /* TODO: if it hasn't been commited, should we abort it? */ - -#if PYTHON_API_VERSION <= 1007 - PyMem_DEL(self); -#else - PyObject_Del(self); -#endif -} - - -static DBLockObject* -newDBLockObject(DBEnvObject* myenv, u_int32_t locker, DBT* obj, - db_lockmode_t lock_mode, int flags) -{ - int err; - DBLockObject* self; - -#if PYTHON_API_VERSION <= 1007 - self = PyObject_NEW(DBLockObject, &DBLock_Type); -#else - self = PyObject_New(DBLockObject, &DBLock_Type); -#endif - if (self == NULL) - return NULL; - - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 40) - err = myenv->db_env->lock_get(myenv->db_env, locker, flags, obj, lock_mode, - &self->lock); -#else - err = lock_get(myenv->db_env, locker, flags, obj, lock_mode, &self->lock); -#endif - MYDB_END_ALLOW_THREADS; - if (makeDBError(err)) { - self = NULL; - } - - return self; -} - - -static void -DBLock_dealloc(DBLockObject* self) -{ - /* TODO: if it hasn't been released, should we do it? */ - -#if PYTHON_API_VERSION <= 1007 - PyMem_DEL(self); -#else - PyObject_Del(self); -#endif -} - - -/* --------------------------------------------------------------------- */ -/* DB methods */ - -static PyObject* -DB_append(DBObject* self, PyObject* args) -{ - PyObject* txnobj = NULL; - PyObject* dataobj; - db_recno_t recno; - DBT key, data; - DB_TXN *txn = NULL; - - if (!PyArg_ParseTuple(args, "O|O:append", &dataobj, &txnobj)) - return NULL; - - CHECK_DB_NOT_CLOSED(self); - - /* make a dummy key out of a recno */ - recno = 0; - CLEAR_DBT(key); - key.data = &recno; - key.size = sizeof(recno); - key.ulen = key.size; - key.flags = DB_DBT_USERMEM; - - if (!make_dbt(dataobj, &data)) return NULL; - if (!checkTxnObj(txnobj, &txn)) return NULL; - - if (-1 == _DB_put(self, txn, &key, &data, DB_APPEND)) - return NULL; - - return PyInt_FromLong(recno); -} - - -#if (DBVER >= 33) - -static int -_db_associateCallback(DB* db, const DBT* priKey, const DBT* priData, - DBT* secKey) -{ - int retval = DB_DONOTINDEX; - DBObject* secondaryDB = (DBObject*)db->app_private; - PyObject* callback = secondaryDB->associateCallback; - int type = secondaryDB->primaryDBType; - PyObject* key; - PyObject* data; - PyObject* args; - PyObject* result; - - - if (callback != NULL) { - MYDB_BEGIN_BLOCK_THREADS; - - if (type == DB_RECNO || type == DB_QUEUE) { - key = PyInt_FromLong( *((db_recno_t*)priKey->data)); - } - else { - key = PyString_FromStringAndSize(priKey->data, priKey->size); - } - data = PyString_FromStringAndSize(priData->data, priData->size); - args = PyTuple_New(2); - PyTuple_SET_ITEM(args, 0, key); /* steals reference */ - PyTuple_SET_ITEM(args, 1, data); /* steals reference */ - - result = PyEval_CallObject(callback, args); - - if (result == NULL) { - PyErr_Print(); - } - else if (result == Py_None) { - retval = DB_DONOTINDEX; - } - else if (PyInt_Check(result)) { - retval = PyInt_AsLong(result); - } - else if (PyString_Check(result)) { - char* data; - int size; - - CLEAR_DBT(*secKey); -#if PYTHON_API_VERSION <= 1007 - /* 1.5 compatibility */ - size = PyString_Size(result); - data = PyString_AsString(result); -#else - PyString_AsStringAndSize(result, &data, &size); -#endif - secKey->flags = DB_DBT_APPMALLOC; /* DB will free */ - secKey->data = malloc(size); /* TODO, check this */ - if (secKey->data) { - memcpy(secKey->data, data, size); - secKey->size = size; - retval = 0; - } - else { - PyErr_SetString(PyExc_MemoryError, - "malloc failed in _db_associateCallback"); - PyErr_Print(); - } - } - else { - PyErr_SetString( - PyExc_TypeError, - "DB associate callback should return DB_DONOTINDEX or string."); - PyErr_Print(); - } - - Py_DECREF(args); - if (result) { - Py_DECREF(result); - } - - MYDB_END_BLOCK_THREADS; - } - return retval; -} - - -static PyObject* -DB_associate(DBObject* self, PyObject* args, PyObject* kwargs) -{ - int err, flags=0; - DBObject* secondaryDB; - PyObject* callback; -#if (DBVER >= 41) - PyObject *txnobj = NULL; - DB_TXN *txn = NULL; - char* kwnames[] = {"secondaryDB", "callback", "flags", "txn", NULL}; -#else - char* kwnames[] = {"secondaryDB", "callback", "flags", NULL}; -#endif - -#if (DBVER >= 41) - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|iO:associate", kwnames, - &secondaryDB, &callback, &flags, - &txnobj)) { -#else - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|i:associate", kwnames, - &secondaryDB, &callback, &flags)) { -#endif - return NULL; - } - -#if (DBVER >= 41) - if (!checkTxnObj(txnobj, &txn)) return NULL; -#endif - - CHECK_DB_NOT_CLOSED(self); - if (!DBObject_Check(secondaryDB)) { - makeTypeError("DB", (PyObject*)secondaryDB); - return NULL; - } - if (callback == Py_None) { - callback = NULL; - } - else if (!PyCallable_Check(callback)) { - makeTypeError("Callable", callback); - return NULL; - } - - /* Save a reference to the callback in the secondary DB. */ - if (self->associateCallback != NULL) { - Py_DECREF(self->associateCallback); - } - Py_INCREF(callback); - secondaryDB->associateCallback = callback; - secondaryDB->primaryDBType = _DB_get_type(self); - - /* PyEval_InitThreads is called here due to a quirk in python 1.5 - * - 2.2.1 (at least) according to Russell Williamson : - * The global interepreter lock is not initialized until the first - * thread is created using thread.start_new_thread() or fork() is - * called. that would cause the ALLOW_THREADS here to segfault due - * to a null pointer reference if no threads or child processes - * have been created. This works around that and is a no-op if - * threads have already been initialized. - * (see pybsddb-users mailing list post on 2002-08-07) - */ -#ifdef WITH_THREAD - PyEval_InitThreads(); -#endif - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 41) - err = self->db->associate(self->db, - txn, - secondaryDB->db, - _db_associateCallback, - flags); -#else - err = self->db->associate(self->db, - secondaryDB->db, - _db_associateCallback, - flags); -#endif - MYDB_END_ALLOW_THREADS; - - if (err) { - Py_DECREF(self->associateCallback); - self->associateCallback = NULL; - secondaryDB->primaryDBType = 0; - } - - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -#endif - - -static PyObject* -DB_close(DBObject* self, PyObject* args) -{ - int err, flags=0; - if (!PyArg_ParseTuple(args,"|i:close", &flags)) - return NULL; - if (self->db != NULL) { - if (self->myenvobj) - CHECK_ENV_NOT_CLOSED(self->myenvobj); - err = self->db->close(self->db, flags); - self->db = NULL; - RETURN_IF_ERR(); - } - RETURN_NONE(); -} - - -#if (DBVER >= 32) -static PyObject* -_DB_consume(DBObject* self, PyObject* args, PyObject* kwargs, int consume_flag) -{ - int err, flags=0, type; - PyObject* txnobj = NULL; - PyObject* retval = NULL; - DBT key, data; - DB_TXN *txn = NULL; - char* kwnames[] = { "txn", "flags", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Oi:consume", kwnames, - &txnobj, &flags)) - return NULL; - - CHECK_DB_NOT_CLOSED(self); - type = _DB_get_type(self); - if (type == -1) - return NULL; - if (type != DB_QUEUE) { - PyErr_SetString(PyExc_TypeError, - "Consume methods only allowed for Queue DB's"); - return NULL; - } - if (!checkTxnObj(txnobj, &txn)) - return NULL; - - CLEAR_DBT(key); - CLEAR_DBT(data); - if (CHECK_DBFLAG(self, DB_THREAD)) { - /* Tell BerkeleyDB to malloc the return value (thread safe) */ - data.flags = DB_DBT_MALLOC; - key.flags = DB_DBT_MALLOC; - } - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->get(self->db, txn, &key, &data, flags|consume_flag); - MYDB_END_ALLOW_THREADS; - - if ((err == DB_NOTFOUND) && self->moduleFlags.getReturnsNone) { - err = 0; - Py_INCREF(Py_None); - retval = Py_None; - } - else if (!err) { - retval = Py_BuildValue("s#s#", key.data, key.size, data.data, - data.size); - FREE_DBT(key); - FREE_DBT(data); - } - - RETURN_IF_ERR(); - return retval; -} - -static PyObject* -DB_consume(DBObject* self, PyObject* args, PyObject* kwargs, int consume_flag) -{ - return _DB_consume(self, args, kwargs, DB_CONSUME); -} - -static PyObject* -DB_consume_wait(DBObject* self, PyObject* args, PyObject* kwargs, - int consume_flag) -{ - return _DB_consume(self, args, kwargs, DB_CONSUME_WAIT); -} -#endif - - - -static PyObject* -DB_cursor(DBObject* self, PyObject* args, PyObject* kwargs) -{ - int err, flags=0; - DBC* dbc; - PyObject* txnobj = NULL; - DB_TXN *txn = NULL; - char* kwnames[] = { "txn", "flags", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Oi:cursor", kwnames, - &txnobj, &flags)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - if (!checkTxnObj(txnobj, &txn)) - return NULL; - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->cursor(self->db, txn, &dbc, flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - return (PyObject*) newDBCursorObject(dbc, self); -} - - -static PyObject* -DB_delete(DBObject* self, PyObject* args, PyObject* kwargs) -{ - PyObject* txnobj = NULL; - int flags = 0; - PyObject* keyobj; - DBT key; - DB_TXN *txn = NULL; - char* kwnames[] = { "key", "txn", "flags", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Oi:delete", kwnames, - &keyobj, &txnobj, &flags)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - if (!make_key_dbt(self, keyobj, &key, NULL)) - return NULL; - if (!checkTxnObj(txnobj, &txn)) - return NULL; - - if (-1 == _DB_delete(self, txn, &key, 0)) - return NULL; - - FREE_DBT(key); - RETURN_NONE(); -} - - -static PyObject* -DB_fd(DBObject* self, PyObject* args) -{ - int err, the_fd; - - if (!PyArg_ParseTuple(args,":fd")) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->fd(self->db, &the_fd); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - return PyInt_FromLong(the_fd); -} - - -static PyObject* -DB_get(DBObject* self, PyObject* args, PyObject* kwargs) -{ - int err, flags=0; - PyObject* txnobj = NULL; - PyObject* keyobj; - PyObject* dfltobj = NULL; - PyObject* retval = NULL; - int dlen = -1; - int doff = -1; - DBT key, data; - DB_TXN *txn = NULL; - char* kwnames[] = {"key", "default", "txn", "flags", "dlen", "doff", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOiii:get", kwnames, - &keyobj, &dfltobj, &txnobj, &flags, &dlen, - &doff)) - return NULL; - - CHECK_DB_NOT_CLOSED(self); - if (!make_key_dbt(self, keyobj, &key, &flags)) - return NULL; - if (!checkTxnObj(txnobj, &txn)) - return NULL; - - CLEAR_DBT(data); - if (CHECK_DBFLAG(self, DB_THREAD)) { - /* Tell BerkeleyDB to malloc the return value (thread safe) */ - data.flags = DB_DBT_MALLOC; - } - if (!add_partial_dbt(&data, dlen, doff)) - return NULL; - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->get(self->db, txn, &key, &data, flags); - MYDB_END_ALLOW_THREADS; - - if ((err == DB_NOTFOUND) && (dfltobj != NULL)) { - err = 0; - Py_INCREF(dfltobj); - retval = dfltobj; - } - else if ((err == DB_NOTFOUND) && self->moduleFlags.getReturnsNone) { - err = 0; - Py_INCREF(Py_None); - retval = Py_None; - } - else if (!err) { - if (flags & DB_SET_RECNO) /* return both key and data */ - retval = Py_BuildValue("s#s#", key.data, key.size, data.data, - data.size); - else /* return just the data */ - retval = PyString_FromStringAndSize((char*)data.data, data.size); - FREE_DBT(key); - FREE_DBT(data); - } - - RETURN_IF_ERR(); - return retval; -} - - -/* Return size of entry */ -static PyObject* -DB_get_size(DBObject* self, PyObject* args, PyObject* kwargs) -{ - int err, flags=0; - PyObject* txnobj = NULL; - PyObject* keyobj; - PyObject* retval = NULL; - DBT key, data; - DB_TXN *txn = NULL; - char* kwnames[] = { "key", "txn", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:get_size", kwnames, - &keyobj, &txnobj)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - if (!make_key_dbt(self, keyobj, &key, &flags)) - return NULL; - if (!checkTxnObj(txnobj, &txn)) - return NULL; - CLEAR_DBT(data); - - /* We don't allocate any memory, forcing a ENOMEM error and thus - getting the record size. */ - data.flags = DB_DBT_USERMEM; - data.ulen = 0; - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->get(self->db, txn, &key, &data, flags); - MYDB_END_ALLOW_THREADS; - if (err == ENOMEM) { - retval = PyInt_FromLong((long)data.size); - err = 0; - } - - FREE_DBT(key); - FREE_DBT(data); - RETURN_IF_ERR(); - return retval; -} - - -static PyObject* -DB_get_both(DBObject* self, PyObject* args, PyObject* kwargs) -{ - int err, flags=0; - PyObject* txnobj = NULL; - PyObject* keyobj; - PyObject* dataobj; - PyObject* retval = NULL; - DBT key, data; - DB_TXN *txn = NULL; - char* kwnames[] = { "key", "data", "txn", "flags", NULL }; - - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|Oi:get_both", kwnames, - &keyobj, &dataobj, &txnobj, &flags)) - return NULL; - - CHECK_DB_NOT_CLOSED(self); - if (!make_key_dbt(self, keyobj, &key, NULL)) - return NULL; - if (!make_dbt(dataobj, &data)) - return NULL; - if (!checkTxnObj(txnobj, &txn)) - return NULL; - - flags |= DB_GET_BOTH; - - if (CHECK_DBFLAG(self, DB_THREAD)) { - /* Tell BerkeleyDB to malloc the return value (thread safe) */ - data.flags = DB_DBT_MALLOC; - /* TODO: Is this flag needed? We're passing a data object that should - match what's in the DB, so there should be no need to malloc. - We run the risk of freeing something twice! Check this. */ - } - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->get(self->db, txn, &key, &data, flags); - MYDB_END_ALLOW_THREADS; - - if ((err == DB_NOTFOUND) && self->moduleFlags.getReturnsNone) { - err = 0; - Py_INCREF(Py_None); - retval = Py_None; - } - else if (!err) { - retval = PyString_FromStringAndSize((char*)data.data, data.size); - FREE_DBT(data); /* Only if retrieval was successful */ - } - - FREE_DBT(key); - RETURN_IF_ERR(); - return retval; -} - - -static PyObject* -DB_get_byteswapped(DBObject* self, PyObject* args) -{ -#if (DBVER >= 33) - int err = 0; -#endif - int retval = -1; - - if (!PyArg_ParseTuple(args,":get_byteswapped")) - return NULL; - CHECK_DB_NOT_CLOSED(self); - -#if (DBVER >= 33) - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->get_byteswapped(self->db, &retval); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); -#else - MYDB_BEGIN_ALLOW_THREADS; - retval = self->db->get_byteswapped(self->db); - MYDB_END_ALLOW_THREADS; -#endif - return PyInt_FromLong(retval); -} - - -static PyObject* -DB_get_type(DBObject* self, PyObject* args) -{ - int type; - - if (!PyArg_ParseTuple(args,":get_type")) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - type = _DB_get_type(self); - MYDB_END_ALLOW_THREADS; - if (type == -1) - return NULL; - return PyInt_FromLong(type); -} - - -static PyObject* -DB_join(DBObject* self, PyObject* args) -{ - int err, flags=0; - int length, x; - PyObject* cursorsObj; - DBC** cursors; - DBC* dbc; - - - if (!PyArg_ParseTuple(args,"O|i:join", &cursorsObj, &flags)) - return NULL; - - CHECK_DB_NOT_CLOSED(self); - - if (!PySequence_Check(cursorsObj)) { - PyErr_SetString(PyExc_TypeError, - "Sequence of DBCursor objects expected"); - return NULL; - } - - length = PyObject_Length(cursorsObj); - cursors = malloc((length+1) * sizeof(DBC*)); - cursors[length] = NULL; - for (x=0; xdbc; - } - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->join(self->db, cursors, &dbc, flags); - MYDB_END_ALLOW_THREADS; - free(cursors); - RETURN_IF_ERR(); - - // FIXME: this is a buggy interface. The returned cursor - // contains internal references to the passed in cursors - // but does not hold python references to them or prevent - // them from being closed prematurely. This can cause - // python to crash when things are done in the wrong order. - return (PyObject*) newDBCursorObject(dbc, self); -} - - -static PyObject* -DB_key_range(DBObject* self, PyObject* args, PyObject* kwargs) -{ - int err, flags=0; - PyObject* txnobj = NULL; - PyObject* keyobj; - DBT key; - DB_TXN *txn = NULL; - DB_KEY_RANGE range; - char* kwnames[] = { "key", "txn", "flags", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Oi:key_range", kwnames, - &keyobj, &txnobj, &flags)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - if (!make_dbt(keyobj, &key)) - /* BTree only, don't need to allow for an int key */ - return NULL; - if (!checkTxnObj(txnobj, &txn)) - return NULL; - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->key_range(self->db, txn, &key, &range, flags); - MYDB_END_ALLOW_THREADS; - - RETURN_IF_ERR(); - return Py_BuildValue("ddd", range.less, range.equal, range.greater); -} - - -static PyObject* -DB_open(DBObject* self, PyObject* args, PyObject* kwargs) -{ - int err, type = DB_UNKNOWN, flags=0, mode=0660; - char* filename = NULL; - char* dbname = NULL; -#if (DBVER >= 41) - PyObject *txnobj = NULL; - DB_TXN *txn = NULL; - /* with dbname */ - char* kwnames[] = { - "filename", "dbname", "dbtype", "flags", "mode", "txn", NULL}; - /* without dbname */ - char* kwnames_basic[] = { - "filename", "dbtype", "flags", "mode", "txn", NULL}; -#else - /* with dbname */ - char* kwnames[] = { - "filename", "dbname", "dbtype", "flags", "mode", NULL}; - /* without dbname */ - char* kwnames_basic[] = { - "filename", "dbtype", "flags", "mode", NULL}; -#endif - -#if (DBVER >= 41) - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "z|ziiiO:open", kwnames, - &filename, &dbname, &type, &flags, &mode, - &txnobj)) -#else - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "z|ziii:open", kwnames, - &filename, &dbname, &type, &flags, - &mode)) -#endif - { - PyErr_Clear(); - type = DB_UNKNOWN; flags = 0; mode = 0660; - filename = NULL; dbname = NULL; -#if (DBVER >= 41) - if (!PyArg_ParseTupleAndKeywords(args, kwargs,"z|iiiO:open", - kwnames_basic, - &filename, &type, &flags, &mode, - &txnobj)) - return NULL; -#else - if (!PyArg_ParseTupleAndKeywords(args, kwargs,"z|iii:open", - kwnames_basic, - &filename, &type, &flags, &mode)) - return NULL; -#endif - } - -#if (DBVER >= 41) - if (!checkTxnObj(txnobj, &txn)) return NULL; -#endif - - if (NULL == self->db) { - PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, - "Cannot call open() twice for DB object")); - return NULL; - } - -#if 0 && (DBVER >= 41) - if ((!txn) && (txnobj != Py_None) && self->myenvobj - && (self->myenvobj->flags & DB_INIT_TXN)) - { - /* If no 'txn' parameter was supplied (no DbTxn object and None was not - * explicitly passed) but we are in a transaction ready environment: - * add DB_AUTO_COMMIT to allow for older pybsddb apps using transactions - * to work on BerkeleyDB 4.1 without needing to modify their - * DBEnv or DB open calls. - * TODO make this behaviour of the library configurable. - */ - flags |= DB_AUTO_COMMIT; - } -#endif - - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 41) - err = self->db->open(self->db, txn, filename, dbname, type, flags, mode); -#else - err = self->db->open(self->db, filename, dbname, type, flags, mode); -#endif - MYDB_END_ALLOW_THREADS; - if (makeDBError(err)) { - self->db->close(self->db, 0); - self->db = NULL; - return NULL; - } - - self->flags = flags; - RETURN_NONE(); -} - - -static PyObject* -DB_put(DBObject* self, PyObject* args, PyObject* kwargs) -{ - int flags=0; - PyObject* txnobj = NULL; - int dlen = -1; - int doff = -1; - PyObject* keyobj, *dataobj, *retval; - DBT key, data; - DB_TXN *txn = NULL; - char* kwnames[] = { "key", "data", "txn", "flags", "dlen", "doff", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|Oiii:put", kwnames, - &keyobj, &dataobj, &txnobj, &flags, &dlen, &doff)) - return NULL; - - CHECK_DB_NOT_CLOSED(self); - if (!make_key_dbt(self, keyobj, &key, NULL)) return NULL; - if (!make_dbt(dataobj, &data)) return NULL; - if (!add_partial_dbt(&data, dlen, doff)) return NULL; - if (!checkTxnObj(txnobj, &txn)) return NULL; - - if (-1 == _DB_put(self, txn, &key, &data, flags)) { - FREE_DBT(key); - return NULL; - } - - if (flags & DB_APPEND) - retval = PyInt_FromLong(*((db_recno_t*)key.data)); - else { - retval = Py_None; - Py_INCREF(retval); - } - FREE_DBT(key); - return retval; -} - - - -static PyObject* -DB_remove(DBObject* self, PyObject* args, PyObject* kwargs) -{ - char* filename; - char* database = NULL; - int err, flags=0; - char* kwnames[] = { "filename", "dbname", "flags", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|zi:remove", kwnames, - &filename, &database, &flags)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - err = self->db->remove(self->db, filename, database, flags); - self->db = NULL; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - - -static PyObject* -DB_rename(DBObject* self, PyObject* args) -{ - char* filename; - char* database; - char* newname; - int err, flags=0; - - if (!PyArg_ParseTuple(args, "sss|i:rename", &filename, &database, &newname, - &flags)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->rename(self->db, filename, database, newname, flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DB_set_bt_minkey(DBObject* self, PyObject* args) -{ - int err, minkey; - - if (!PyArg_ParseTuple(args,"i:set_bt_minkey", &minkey )) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_bt_minkey(self->db, minkey); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DB_set_cachesize(DBObject* self, PyObject* args) -{ - int err; - int gbytes = 0, bytes = 0, ncache = 0; - - if (!PyArg_ParseTuple(args,"ii|i:set_cachesize", - &gbytes,&bytes,&ncache)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_cachesize(self->db, gbytes, bytes, ncache); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DB_set_flags(DBObject* self, PyObject* args) -{ - int err, flags; - - if (!PyArg_ParseTuple(args,"i:set_flags", &flags)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_flags(self->db, flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - - self->setflags |= flags; - RETURN_NONE(); -} - - -static PyObject* -DB_set_h_ffactor(DBObject* self, PyObject* args) -{ - int err, ffactor; - - if (!PyArg_ParseTuple(args,"i:set_h_ffactor", &ffactor)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_h_ffactor(self->db, ffactor); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DB_set_h_nelem(DBObject* self, PyObject* args) -{ - int err, nelem; - - if (!PyArg_ParseTuple(args,"i:set_h_nelem", &nelem)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_h_nelem(self->db, nelem); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DB_set_lorder(DBObject* self, PyObject* args) -{ - int err, lorder; - - if (!PyArg_ParseTuple(args,"i:set_lorder", &lorder)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_lorder(self->db, lorder); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DB_set_pagesize(DBObject* self, PyObject* args) -{ - int err, pagesize; - - if (!PyArg_ParseTuple(args,"i:set_pagesize", &pagesize)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_pagesize(self->db, pagesize); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DB_set_re_delim(DBObject* self, PyObject* args) -{ - int err; - char delim; - - if (!PyArg_ParseTuple(args,"b:set_re_delim", &delim)) { - PyErr_Clear(); - if (!PyArg_ParseTuple(args,"c:set_re_delim", &delim)) - return NULL; - } - - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_re_delim(self->db, delim); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - -static PyObject* -DB_set_re_len(DBObject* self, PyObject* args) -{ - int err, len; - - if (!PyArg_ParseTuple(args,"i:set_re_len", &len)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_re_len(self->db, len); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DB_set_re_pad(DBObject* self, PyObject* args) -{ - int err; - char pad; - - if (!PyArg_ParseTuple(args,"b:set_re_pad", &pad)) { - PyErr_Clear(); - if (!PyArg_ParseTuple(args,"c:set_re_pad", &pad)) - return NULL; - } - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_re_pad(self->db, pad); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DB_set_re_source(DBObject* self, PyObject* args) -{ - int err; - char *re_source; - - if (!PyArg_ParseTuple(args,"s:set_re_source", &re_source)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_re_source(self->db, re_source); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -#if (DBVER >= 32) -static PyObject* -DB_set_q_extentsize(DBObject* self, PyObject* args) -{ - int err; - int extentsize; - - if (!PyArg_ParseTuple(args,"i:set_q_extentsize", &extentsize)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_q_extentsize(self->db, extentsize); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} -#endif - -static PyObject* -DB_stat(DBObject* self, PyObject* args) -{ - int err, flags = 0, type; - void* sp; - PyObject* d; - - - if (!PyArg_ParseTuple(args, "|i:stat", &flags)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 33) - err = self->db->stat(self->db, &sp, flags); -#else - err = self->db->stat(self->db, &sp, NULL, flags); -#endif - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - - self->haveStat = 1; - - /* Turn the stat structure into a dictionary */ - type = _DB_get_type(self); - if ((type == -1) || ((d = PyDict_New()) == NULL)) { - free(sp); - return NULL; - } - -#define MAKE_HASH_ENTRY(name) _addIntToDict(d, #name, ((DB_HASH_STAT*)sp)->hash_##name) -#define MAKE_BT_ENTRY(name) _addIntToDict(d, #name, ((DB_BTREE_STAT*)sp)->bt_##name) -#define MAKE_QUEUE_ENTRY(name) _addIntToDict(d, #name, ((DB_QUEUE_STAT*)sp)->qs_##name) - - switch (type) { - case DB_HASH: - MAKE_HASH_ENTRY(magic); - MAKE_HASH_ENTRY(version); - MAKE_HASH_ENTRY(nkeys); - MAKE_HASH_ENTRY(ndata); - MAKE_HASH_ENTRY(pagesize); -#if (DBVER < 41) - MAKE_HASH_ENTRY(nelem); -#endif - MAKE_HASH_ENTRY(ffactor); - MAKE_HASH_ENTRY(buckets); - MAKE_HASH_ENTRY(free); - MAKE_HASH_ENTRY(bfree); - MAKE_HASH_ENTRY(bigpages); - MAKE_HASH_ENTRY(big_bfree); - MAKE_HASH_ENTRY(overflows); - MAKE_HASH_ENTRY(ovfl_free); - MAKE_HASH_ENTRY(dup); - MAKE_HASH_ENTRY(dup_free); - break; - - case DB_BTREE: - case DB_RECNO: - MAKE_BT_ENTRY(magic); - MAKE_BT_ENTRY(version); - MAKE_BT_ENTRY(nkeys); - MAKE_BT_ENTRY(ndata); - MAKE_BT_ENTRY(pagesize); - MAKE_BT_ENTRY(minkey); - MAKE_BT_ENTRY(re_len); - MAKE_BT_ENTRY(re_pad); - MAKE_BT_ENTRY(levels); - MAKE_BT_ENTRY(int_pg); - MAKE_BT_ENTRY(leaf_pg); - MAKE_BT_ENTRY(dup_pg); - MAKE_BT_ENTRY(over_pg); - MAKE_BT_ENTRY(free); - MAKE_BT_ENTRY(int_pgfree); - MAKE_BT_ENTRY(leaf_pgfree); - MAKE_BT_ENTRY(dup_pgfree); - MAKE_BT_ENTRY(over_pgfree); - break; - - case DB_QUEUE: - MAKE_QUEUE_ENTRY(magic); - MAKE_QUEUE_ENTRY(version); - MAKE_QUEUE_ENTRY(nkeys); - MAKE_QUEUE_ENTRY(ndata); - MAKE_QUEUE_ENTRY(pagesize); - MAKE_QUEUE_ENTRY(pages); - MAKE_QUEUE_ENTRY(re_len); - MAKE_QUEUE_ENTRY(re_pad); - MAKE_QUEUE_ENTRY(pgfree); -#if (DBVER == 31) - MAKE_QUEUE_ENTRY(start); -#endif - MAKE_QUEUE_ENTRY(first_recno); - MAKE_QUEUE_ENTRY(cur_recno); - break; - - default: - PyErr_SetString(PyExc_TypeError, "Unknown DB type, unable to stat"); - Py_DECREF(d); - d = NULL; - } - -#undef MAKE_HASH_ENTRY -#undef MAKE_BT_ENTRY -#undef MAKE_QUEUE_ENTRY - - free(sp); - return d; -} - -static PyObject* -DB_sync(DBObject* self, PyObject* args) -{ - int err; - int flags = 0; - - if (!PyArg_ParseTuple(args,"|i:sync", &flags )) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->sync(self->db, flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -#if (DBVER >= 33) -static PyObject* -DB_truncate(DBObject* self, PyObject* args, PyObject* kwargs) -{ - int err, flags=0; - u_int32_t count=0; - PyObject* txnobj = NULL; - DB_TXN *txn = NULL; - char* kwnames[] = { "txn", "flags", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Oi:cursor", kwnames, - &txnobj, &flags)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - if (!checkTxnObj(txnobj, &txn)) - return NULL; - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->truncate(self->db, txn, &count, flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - return PyInt_FromLong(count); -} -#endif - - -static PyObject* -DB_upgrade(DBObject* self, PyObject* args) -{ - int err, flags=0; - char *filename; - - if (!PyArg_ParseTuple(args,"s|i:upgrade", &filename, &flags)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->upgrade(self->db, filename, flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DB_verify(DBObject* self, PyObject* args, PyObject* kwargs) -{ - int err, flags=0; - char* fileName; - char* dbName=NULL; - char* outFileName=NULL; - FILE* outFile=NULL; - char* kwnames[] = { "filename", "dbname", "outfile", "flags", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|zzi:verify", kwnames, - &fileName, &dbName, &outFileName, &flags)) - return NULL; - - CHECK_DB_NOT_CLOSED(self); - if (outFileName) - outFile = fopen(outFileName, "w"); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->verify(self->db, fileName, dbName, outFile, flags); - MYDB_END_ALLOW_THREADS; - if (outFileName) - fclose(outFile); - - /* DB.verify acts as a DB handle destructor (like close); this was - * documented in BerkeleyDB 4.2 but had the undocumented effect - * of not being safe in prior versions while still requiring an explicit - * DB.close call afterwards. Lets call close for the user to emulate - * the safe 4.2 behaviour. */ -#if (DBVER <= 41) - self->db->close(self->db, 0); -#endif - self->db = NULL; - - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DB_set_get_returns_none(DBObject* self, PyObject* args) -{ - int flags=0; - int oldValue=0; - - if (!PyArg_ParseTuple(args,"i:set_get_returns_none", &flags)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - if (self->moduleFlags.getReturnsNone) - ++oldValue; - if (self->moduleFlags.cursorSetReturnsNone) - ++oldValue; - self->moduleFlags.getReturnsNone = (flags >= 1); - self->moduleFlags.cursorSetReturnsNone = (flags >= 2); - return PyInt_FromLong(oldValue); -} - -#if (DBVER >= 41) -static PyObject* -DB_set_encrypt(DBObject* self, PyObject* args, PyObject* kwargs) -{ - int err; - u_int32_t flags=0; - char *passwd = NULL; - char* kwnames[] = { "passwd", "flags", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|i:set_encrypt", kwnames, - &passwd, &flags)) { - return NULL; - } - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_encrypt(self->db, passwd, flags); - MYDB_END_ALLOW_THREADS; - - RETURN_IF_ERR(); - RETURN_NONE(); -} -#endif /* DBVER >= 41 */ - - -/*-------------------------------------------------------------- */ -/* Mapping and Dictionary-like access routines */ - -int DB_length(DBObject* self) -{ - int err; - long size = 0; - int flags = 0; - void* sp; - - if (self->db == NULL) { - PyErr_SetObject(DBError, - Py_BuildValue("(is)", 0, "DB object has been closed")); - return -1; - } - - if (self->haveStat) { /* Has the stat function been called recently? If - so, we can use the cached value. */ - flags = DB_CACHED_COUNTS; - } - - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 33) - err = self->db->stat(self->db, &sp, flags); -#else - err = self->db->stat(self->db, &sp, NULL, flags); -#endif - MYDB_END_ALLOW_THREADS; - - if (err) - return -1; - - self->haveStat = 1; - - /* All the stat structures have matching fields upto the ndata field, - so we can use any of them for the type cast */ - size = ((DB_BTREE_STAT*)sp)->bt_ndata; - free(sp); - return size; -} - - -PyObject* DB_subscript(DBObject* self, PyObject* keyobj) -{ - int err; - PyObject* retval; - DBT key; - DBT data; - - CHECK_DB_NOT_CLOSED(self); - if (!make_key_dbt(self, keyobj, &key, NULL)) - return NULL; - - CLEAR_DBT(data); - if (CHECK_DBFLAG(self, DB_THREAD)) { - /* Tell BerkeleyDB to malloc the return value (thread safe) */ - data.flags = DB_DBT_MALLOC; - } - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->get(self->db, NULL, &key, &data, 0); - MYDB_END_ALLOW_THREADS; - if (err == DB_NOTFOUND || err == DB_KEYEMPTY) { - PyErr_SetObject(PyExc_KeyError, keyobj); - retval = NULL; - } - else if (makeDBError(err)) { - retval = NULL; - } - else { - retval = PyString_FromStringAndSize((char*)data.data, data.size); - FREE_DBT(data); - } - - FREE_DBT(key); - return retval; -} - - -static int -DB_ass_sub(DBObject* self, PyObject* keyobj, PyObject* dataobj) -{ - DBT key, data; - int retval; - int flags = 0; - - if (self->db == NULL) { - PyErr_SetObject(DBError, - Py_BuildValue("(is)", 0, "DB object has been closed")); - return -1; - } - - if (!make_key_dbt(self, keyobj, &key, NULL)) - return -1; - - if (dataobj != NULL) { - if (!make_dbt(dataobj, &data)) - retval = -1; - else { - if (self->setflags & (DB_DUP|DB_DUPSORT)) - /* dictionaries shouldn't have duplicate keys */ - flags = DB_NOOVERWRITE; - retval = _DB_put(self, NULL, &key, &data, flags); - - if ((retval == -1) && (self->setflags & (DB_DUP|DB_DUPSORT))) { - /* try deleting any old record that matches and then PUT it - * again... */ - _DB_delete(self, NULL, &key, 0); - PyErr_Clear(); - retval = _DB_put(self, NULL, &key, &data, flags); - } - } - } - else { - /* dataobj == NULL, so delete the key */ - retval = _DB_delete(self, NULL, &key, 0); - } - FREE_DBT(key); - return retval; -} - - -static PyObject* -DB_has_key(DBObject* self, PyObject* args) -{ - int err; - PyObject* keyobj; - DBT key, data; - PyObject* txnobj = NULL; - DB_TXN *txn = NULL; - - if (!PyArg_ParseTuple(args,"O|O:has_key", &keyobj, &txnobj)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - if (!make_key_dbt(self, keyobj, &key, NULL)) - return NULL; - if (!checkTxnObj(txnobj, &txn)) - return NULL; - - /* This causes ENOMEM to be returned when the db has the key because - it has a record but can't allocate a buffer for the data. This saves - having to deal with data we won't be using. - */ - CLEAR_DBT(data); - data.flags = DB_DBT_USERMEM; - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->get(self->db, NULL, &key, &data, 0); - MYDB_END_ALLOW_THREADS; - FREE_DBT(key); - return PyInt_FromLong((err == ENOMEM) || (err == 0)); -} - - -#define _KEYS_LIST 1 -#define _VALUES_LIST 2 -#define _ITEMS_LIST 3 - -static PyObject* -_DB_make_list(DBObject* self, DB_TXN* txn, int type) -{ - int err, dbtype; - DBT key; - DBT data; - DBC *cursor; - PyObject* list; - PyObject* item = NULL; - - CHECK_DB_NOT_CLOSED(self); - CLEAR_DBT(key); - CLEAR_DBT(data); - - dbtype = _DB_get_type(self); - if (dbtype == -1) - return NULL; - - list = PyList_New(0); - if (list == NULL) { - PyErr_SetString(PyExc_MemoryError, "PyList_New failed"); - return NULL; - } - - /* get a cursor */ - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->cursor(self->db, NULL, &cursor, 0); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - - if (CHECK_DBFLAG(self, DB_THREAD)) { - key.flags = DB_DBT_REALLOC; - data.flags = DB_DBT_REALLOC; - } - - while (1) { /* use the cursor to traverse the DB, collecting items */ - MYDB_BEGIN_ALLOW_THREADS; - err = cursor->c_get(cursor, &key, &data, DB_NEXT); - MYDB_END_ALLOW_THREADS; - - if (err) { - /* for any error, break out of the loop */ - break; - } - - switch (type) { - case _KEYS_LIST: - switch(dbtype) { - case DB_BTREE: - case DB_HASH: - default: - item = PyString_FromStringAndSize((char*)key.data, key.size); - break; - case DB_RECNO: - case DB_QUEUE: - item = PyInt_FromLong(*((db_recno_t*)key.data)); - break; - } - break; - - case _VALUES_LIST: - item = PyString_FromStringAndSize((char*)data.data, data.size); - break; - - case _ITEMS_LIST: - switch(dbtype) { - case DB_BTREE: - case DB_HASH: - default: - item = Py_BuildValue("s#s#", key.data, key.size, data.data, - data.size); - break; - case DB_RECNO: - case DB_QUEUE: - item = Py_BuildValue("is#", *((db_recno_t*)key.data), - data.data, data.size); - break; - } - break; - } - if (item == NULL) { - Py_DECREF(list); - PyErr_SetString(PyExc_MemoryError, "List item creation failed"); - list = NULL; - goto done; - } - PyList_Append(list, item); - Py_DECREF(item); - } - - /* DB_NOTFOUND is okay, it just means we got to the end */ - if (err != DB_NOTFOUND && makeDBError(err)) { - Py_DECREF(list); - list = NULL; - } - - done: - FREE_DBT(key); - FREE_DBT(data); - MYDB_BEGIN_ALLOW_THREADS; - cursor->c_close(cursor); - MYDB_END_ALLOW_THREADS; - return list; -} - - -static PyObject* -DB_keys(DBObject* self, PyObject* args) -{ - PyObject* txnobj = NULL; - DB_TXN *txn = NULL; - - if (!PyArg_ParseTuple(args,"|O:keys", &txnobj)) - return NULL; - if (!checkTxnObj(txnobj, &txn)) - return NULL; - return _DB_make_list(self, txn, _KEYS_LIST); -} - - -static PyObject* -DB_items(DBObject* self, PyObject* args) -{ - PyObject* txnobj = NULL; - DB_TXN *txn = NULL; - - if (!PyArg_ParseTuple(args,"|O:items", &txnobj)) - return NULL; - if (!checkTxnObj(txnobj, &txn)) - return NULL; - return _DB_make_list(self, txn, _ITEMS_LIST); -} - - -static PyObject* -DB_values(DBObject* self, PyObject* args) -{ - PyObject* txnobj = NULL; - DB_TXN *txn = NULL; - - if (!PyArg_ParseTuple(args,"|O:values", &txnobj)) - return NULL; - if (!checkTxnObj(txnobj, &txn)) - return NULL; - return _DB_make_list(self, txn, _VALUES_LIST); -} - -/* --------------------------------------------------------------------- */ -/* DBCursor methods */ - - -static PyObject* -DBC_close(DBCursorObject* self, PyObject* args) -{ - int err = 0; - - if (!PyArg_ParseTuple(args, ":close")) - return NULL; - - if (self->dbc != NULL) { - MYDB_BEGIN_ALLOW_THREADS; - err = self->dbc->c_close(self->dbc); - self->dbc = NULL; - MYDB_END_ALLOW_THREADS; - } - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DBC_count(DBCursorObject* self, PyObject* args) -{ - int err = 0; - db_recno_t count; - int flags = 0; - - if (!PyArg_ParseTuple(args, "|i:count", &flags)) - return NULL; - - CHECK_CURSOR_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->dbc->c_count(self->dbc, &count, flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - - return PyInt_FromLong(count); -} - - -static PyObject* -DBC_current(DBCursorObject* self, PyObject* args, PyObject *kwargs) -{ - return _DBCursor_get(self,DB_CURRENT,args,kwargs,"|iii:current"); -} - - -static PyObject* -DBC_delete(DBCursorObject* self, PyObject* args) -{ - int err, flags=0; - - if (!PyArg_ParseTuple(args, "|i:delete", &flags)) - return NULL; - - CHECK_CURSOR_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->dbc->c_del(self->dbc, flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - - self->mydb->haveStat = 0; - RETURN_NONE(); -} - - -static PyObject* -DBC_dup(DBCursorObject* self, PyObject* args) -{ - int err, flags =0; - DBC* dbc = NULL; - - if (!PyArg_ParseTuple(args, "|i:dup", &flags)) - return NULL; - - CHECK_CURSOR_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->dbc->c_dup(self->dbc, &dbc, flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - - return (PyObject*) newDBCursorObject(dbc, self->mydb); -} - -static PyObject* -DBC_first(DBCursorObject* self, PyObject* args, PyObject* kwargs) -{ - return _DBCursor_get(self,DB_FIRST,args,kwargs,"|iii:first"); -} - - -static PyObject* -DBC_get(DBCursorObject* self, PyObject* args, PyObject *kwargs) -{ - int err, flags=0; - PyObject* keyobj = NULL; - PyObject* dataobj = NULL; - PyObject* retval = NULL; - int dlen = -1; - int doff = -1; - DBT key, data; - char* kwnames[] = { "key","data", "flags", "dlen", "doff", NULL }; - - CLEAR_DBT(key); - CLEAR_DBT(data); - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|ii:get", &kwnames[2], - &flags, &dlen, &doff)) - { - PyErr_Clear(); - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi|ii:get", - &kwnames[1], - &keyobj, &flags, &dlen, &doff)) - { - PyErr_Clear(); - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOi|ii:get", - kwnames, &keyobj, &dataobj, - &flags, &dlen, &doff)) - { - return NULL; - } - } - } - - CHECK_CURSOR_NOT_CLOSED(self); - - if (keyobj && !make_key_dbt(self->mydb, keyobj, &key, NULL)) - return NULL; - if (dataobj && !make_dbt(dataobj, &data)) - return NULL; - if (!add_partial_dbt(&data, dlen, doff)) - return NULL; - - if (CHECK_DBFLAG(self->mydb, DB_THREAD)) { - data.flags = DB_DBT_MALLOC; - key.flags = DB_DBT_MALLOC; - } - - MYDB_BEGIN_ALLOW_THREADS; - err = self->dbc->c_get(self->dbc, &key, &data, flags); - MYDB_END_ALLOW_THREADS; - - - if ((err == DB_NOTFOUND) && self->mydb->moduleFlags.getReturnsNone) { - Py_INCREF(Py_None); - retval = Py_None; - } - else if (makeDBError(err)) { - retval = NULL; - } - else { - switch (_DB_get_type(self->mydb)) { - case -1: - retval = NULL; - break; - case DB_BTREE: - case DB_HASH: - default: - retval = Py_BuildValue("s#s#", key.data, key.size, - data.data, data.size); - break; - case DB_RECNO: - case DB_QUEUE: - retval = Py_BuildValue("is#", *((db_recno_t*)key.data), - data.data, data.size); - break; - } - FREE_DBT(key); - FREE_DBT(data); - } - return retval; -} - - -static PyObject* -DBC_get_recno(DBCursorObject* self, PyObject* args) -{ - int err; - db_recno_t recno; - DBT key; - DBT data; - - if (!PyArg_ParseTuple(args, ":get_recno")) - return NULL; - - CHECK_CURSOR_NOT_CLOSED(self); - - CLEAR_DBT(key); - CLEAR_DBT(data); - if (CHECK_DBFLAG(self->mydb, DB_THREAD)) { - /* Tell BerkeleyDB to malloc the return value (thread safe) */ - data.flags = DB_DBT_MALLOC; - key.flags = DB_DBT_MALLOC; - } - - MYDB_BEGIN_ALLOW_THREADS; - err = self->dbc->c_get(self->dbc, &key, &data, DB_GET_RECNO); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - - recno = *((db_recno_t*)data.data); - FREE_DBT(key); - FREE_DBT(data); - return PyInt_FromLong(recno); -} - - -static PyObject* -DBC_last(DBCursorObject* self, PyObject* args, PyObject *kwargs) -{ - return _DBCursor_get(self,DB_LAST,args,kwargs,"|iii:last"); -} - - -static PyObject* -DBC_next(DBCursorObject* self, PyObject* args, PyObject *kwargs) -{ - return _DBCursor_get(self,DB_NEXT,args,kwargs,"|iii:next"); -} - - -static PyObject* -DBC_prev(DBCursorObject* self, PyObject* args, PyObject *kwargs) -{ - return _DBCursor_get(self,DB_PREV,args,kwargs,"|iii:prev"); -} - - -static PyObject* -DBC_put(DBCursorObject* self, PyObject* args, PyObject* kwargs) -{ - int err, flags = 0; - PyObject* keyobj, *dataobj; - DBT key, data; - char* kwnames[] = { "key", "data", "flags", "dlen", "doff", NULL }; - int dlen = -1; - int doff = -1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|iii:put", kwnames, - &keyobj, &dataobj, &flags, &dlen, &doff)) - return NULL; - - CHECK_CURSOR_NOT_CLOSED(self); - - if (!make_key_dbt(self->mydb, keyobj, &key, NULL)) - return NULL; - if (!make_dbt(dataobj, &data)) - return NULL; - if (!add_partial_dbt(&data, dlen, doff)) return NULL; - - MYDB_BEGIN_ALLOW_THREADS; - err = self->dbc->c_put(self->dbc, &key, &data, flags); - MYDB_END_ALLOW_THREADS; - FREE_DBT(key); - RETURN_IF_ERR(); - self->mydb->haveStat = 0; - RETURN_NONE(); -} - - -static PyObject* -DBC_set(DBCursorObject* self, PyObject* args, PyObject *kwargs) -{ - int err, flags = 0; - DBT key, data; - PyObject* retval, *keyobj; - char* kwnames[] = { "key", "flags", "dlen", "doff", NULL }; - int dlen = -1; - int doff = -1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|iii:set", kwnames, - &keyobj, &flags, &dlen, &doff)) - return NULL; - - CHECK_CURSOR_NOT_CLOSED(self); - - if (!make_key_dbt(self->mydb, keyobj, &key, NULL)) - return NULL; - - CLEAR_DBT(data); - if (CHECK_DBFLAG(self->mydb, DB_THREAD)) { - /* Tell BerkeleyDB to malloc the return value (thread safe) */ - data.flags = DB_DBT_MALLOC; - } - if (!add_partial_dbt(&data, dlen, doff)) - return NULL; - - MYDB_BEGIN_ALLOW_THREADS; - err = self->dbc->c_get(self->dbc, &key, &data, flags|DB_SET); - MYDB_END_ALLOW_THREADS; - if ((err == DB_NOTFOUND) && self->mydb->moduleFlags.cursorSetReturnsNone) { - Py_INCREF(Py_None); - retval = Py_None; - } - else if (makeDBError(err)) { - retval = NULL; - } - else { - switch (_DB_get_type(self->mydb)) { - case -1: - retval = NULL; - break; - case DB_BTREE: - case DB_HASH: - default: - retval = Py_BuildValue("s#s#", key.data, key.size, - data.data, data.size); - break; - case DB_RECNO: - case DB_QUEUE: - retval = Py_BuildValue("is#", *((db_recno_t*)key.data), - data.data, data.size); - break; - } - FREE_DBT(key); - FREE_DBT(data); - } - - return retval; -} - - -static PyObject* -DBC_set_range(DBCursorObject* self, PyObject* args, PyObject* kwargs) -{ - int err, flags = 0; - DBT key, data; - PyObject* retval, *keyobj; - char* kwnames[] = { "key", "flags", "dlen", "doff", NULL }; - int dlen = -1; - int doff = -1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|iii:set_range", kwnames, - &keyobj, &flags, &dlen, &doff)) - return NULL; - - CHECK_CURSOR_NOT_CLOSED(self); - - if (!make_key_dbt(self->mydb, keyobj, &key, NULL)) - return NULL; - - CLEAR_DBT(data); - if (CHECK_DBFLAG(self->mydb, DB_THREAD)) { - /* Tell BerkeleyDB to malloc the return value (thread safe) */ - data.flags = DB_DBT_MALLOC; - key.flags = DB_DBT_MALLOC; - } - if (!add_partial_dbt(&data, dlen, doff)) - return NULL; - MYDB_BEGIN_ALLOW_THREADS; - err = self->dbc->c_get(self->dbc, &key, &data, flags|DB_SET_RANGE); - MYDB_END_ALLOW_THREADS; - if ((err == DB_NOTFOUND) && self->mydb->moduleFlags.cursorSetReturnsNone) { - Py_INCREF(Py_None); - retval = Py_None; - } - else if (makeDBError(err)) { - retval = NULL; - } - else { - switch (_DB_get_type(self->mydb)) { - case -1: - retval = NULL; - break; - case DB_BTREE: - case DB_HASH: - default: - retval = Py_BuildValue("s#s#", key.data, key.size, - data.data, data.size); - break; - case DB_RECNO: - case DB_QUEUE: - retval = Py_BuildValue("is#", *((db_recno_t*)key.data), - data.data, data.size); - break; - } - FREE_DBT(key); - FREE_DBT(data); - } - - return retval; -} - -static PyObject* -_DBC_get_set_both(DBCursorObject* self, PyObject* keyobj, PyObject* dataobj, - int flags, unsigned int returnsNone) -{ - int err; - DBT key, data; - PyObject* retval; - - // the caller did this: CHECK_CURSOR_NOT_CLOSED(self); - if (!make_key_dbt(self->mydb, keyobj, &key, NULL)) - return NULL; - if (!make_dbt(dataobj, &data)) - return NULL; - - MYDB_BEGIN_ALLOW_THREADS; - err = self->dbc->c_get(self->dbc, &key, &data, flags|DB_GET_BOTH); - MYDB_END_ALLOW_THREADS; - if ((err == DB_NOTFOUND) && returnsNone) { - Py_INCREF(Py_None); - retval = Py_None; - } - else if (makeDBError(err)) { - retval = NULL; - } - else { - switch (_DB_get_type(self->mydb)) { - case -1: - retval = NULL; - break; - case DB_BTREE: - case DB_HASH: - default: - retval = Py_BuildValue("s#s#", key.data, key.size, - data.data, data.size); - break; - case DB_RECNO: - case DB_QUEUE: - retval = Py_BuildValue("is#", *((db_recno_t*)key.data), - data.data, data.size); - break; - } - } - - FREE_DBT(key); - return retval; -} - -static PyObject* -DBC_get_both(DBCursorObject* self, PyObject* args) -{ - int flags=0; - PyObject *keyobj, *dataobj; - - if (!PyArg_ParseTuple(args, "OO|i:get_both", &keyobj, &dataobj, &flags)) - return NULL; - - // if the cursor is closed, self->mydb may be invalid - CHECK_CURSOR_NOT_CLOSED(self); - - return _DBC_get_set_both(self, keyobj, dataobj, flags, - self->mydb->moduleFlags.getReturnsNone); -} - -static PyObject* -DBC_set_both(DBCursorObject* self, PyObject* args) -{ - int flags=0; - PyObject *keyobj, *dataobj; - - if (!PyArg_ParseTuple(args, "OO|i:set_both", &keyobj, &dataobj, &flags)) - return NULL; - - // if the cursor is closed, self->mydb may be invalid - CHECK_CURSOR_NOT_CLOSED(self); - - return _DBC_get_set_both(self, keyobj, dataobj, flags, - self->mydb->moduleFlags.cursorSetReturnsNone); -} - - -static PyObject* -DBC_set_recno(DBCursorObject* self, PyObject* args, PyObject *kwargs) -{ - int err, irecno, flags=0; - db_recno_t recno; - DBT key, data; - PyObject* retval; - int dlen = -1; - int doff = -1; - char* kwnames[] = { "recno","flags", "dlen", "doff", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|iii:set_recno", kwnames, - &irecno, &flags, &dlen, &doff)) - return NULL; - - CHECK_CURSOR_NOT_CLOSED(self); - - CLEAR_DBT(key); - recno = (db_recno_t) irecno; - /* use allocated space so DB will be able to realloc room for the real - * key */ - key.data = malloc(sizeof(db_recno_t)); - if (key.data == NULL) { - PyErr_SetString(PyExc_MemoryError, "Key memory allocation failed"); - return NULL; - } - key.size = sizeof(db_recno_t); - key.ulen = key.size; - memcpy(key.data, &recno, sizeof(db_recno_t)); - key.flags = DB_DBT_REALLOC; - - CLEAR_DBT(data); - if (CHECK_DBFLAG(self->mydb, DB_THREAD)) { - /* Tell BerkeleyDB to malloc the return value (thread safe) */ - data.flags = DB_DBT_MALLOC; - } - if (!add_partial_dbt(&data, dlen, doff)) - return NULL; - - MYDB_BEGIN_ALLOW_THREADS; - err = self->dbc->c_get(self->dbc, &key, &data, flags|DB_SET_RECNO); - MYDB_END_ALLOW_THREADS; - if ((err == DB_NOTFOUND) && self->mydb->moduleFlags.cursorSetReturnsNone) { - Py_INCREF(Py_None); - retval = Py_None; - } - else if (makeDBError(err)) { - retval = NULL; - } - else { /* Can only be used for BTrees, so no need to return int key */ - retval = Py_BuildValue("s#s#", key.data, key.size, - data.data, data.size); - FREE_DBT(key); - FREE_DBT(data); - } - - return retval; -} - - -static PyObject* -DBC_consume(DBCursorObject* self, PyObject* args, PyObject *kwargs) -{ - return _DBCursor_get(self,DB_CONSUME,args,kwargs,"|iii:consume"); -} - - -static PyObject* -DBC_next_dup(DBCursorObject* self, PyObject* args, PyObject *kwargs) -{ - return _DBCursor_get(self,DB_NEXT_DUP,args,kwargs,"|iii:next_dup"); -} - - -static PyObject* -DBC_next_nodup(DBCursorObject* self, PyObject* args, PyObject *kwargs) -{ - return _DBCursor_get(self,DB_NEXT_NODUP,args,kwargs,"|iii:next_nodup"); -} - - -static PyObject* -DBC_prev_nodup(DBCursorObject* self, PyObject* args, PyObject *kwargs) -{ - return _DBCursor_get(self,DB_PREV_NODUP,args,kwargs,"|iii:prev_nodup"); -} - - -static PyObject* -DBC_join_item(DBCursorObject* self, PyObject* args) -{ - int err, flags=0; - DBT key, data; - PyObject* retval; - - if (!PyArg_ParseTuple(args, "|i:join_item", &flags)) - return NULL; - - CHECK_CURSOR_NOT_CLOSED(self); - - CLEAR_DBT(key); - CLEAR_DBT(data); - if (CHECK_DBFLAG(self->mydb, DB_THREAD)) { - /* Tell BerkeleyDB to malloc the return value (thread safe) */ - key.flags = DB_DBT_MALLOC; - } - - MYDB_BEGIN_ALLOW_THREADS; - err = self->dbc->c_get(self->dbc, &key, &data, flags | DB_JOIN_ITEM); - MYDB_END_ALLOW_THREADS; - if ((err == DB_NOTFOUND) && self->mydb->moduleFlags.getReturnsNone) { - Py_INCREF(Py_None); - retval = Py_None; - } - else if (makeDBError(err)) { - retval = NULL; - } - else { - retval = Py_BuildValue("s#", key.data, key.size); - FREE_DBT(key); - } - - return retval; -} - - - -/* --------------------------------------------------------------------- */ -/* DBEnv methods */ - - -static PyObject* -DBEnv_close(DBEnvObject* self, PyObject* args) -{ - int err, flags = 0; - - if (!PyArg_ParseTuple(args, "|i:close", &flags)) - return NULL; - if (!self->closed) { /* Don't close more than once */ - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->close(self->db_env, flags); - MYDB_END_ALLOW_THREADS; - /* after calling DBEnv->close, regardless of error, this DBEnv - * may not be accessed again (BerkeleyDB docs). */ - self->closed = 1; - self->db_env = NULL; - RETURN_IF_ERR(); - } - RETURN_NONE(); -} - - -static PyObject* -DBEnv_open(DBEnvObject* self, PyObject* args) -{ - int err, flags=0, mode=0660; - char *db_home; - - if (!PyArg_ParseTuple(args, "z|ii:open", &db_home, &flags, &mode)) - return NULL; - - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->open(self->db_env, db_home, flags, mode); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - self->closed = 0; - self->flags = flags; - RETURN_NONE(); -} - - -static PyObject* -DBEnv_remove(DBEnvObject* self, PyObject* args) -{ - int err, flags=0; - char *db_home; - - if (!PyArg_ParseTuple(args, "s|i:remove", &db_home, &flags)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->remove(self->db_env, db_home, flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - -#if (DBVER >= 41) -static PyObject* -DBEnv_dbremove(DBEnvObject* self, PyObject* args, PyObject* kwargs) -{ - int err; - u_int32_t flags=0; - char *file = NULL; - char *database = NULL; - PyObject *txnobj = NULL; - DB_TXN *txn = NULL; - char* kwnames[] = { "file", "database", "txn", "flags", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ss|Oi:dbremove", kwnames, - &file, &database, &txnobj, &flags)) { - return NULL; - } - if (!checkTxnObj(txnobj, &txn)) { - return NULL; - } - CHECK_ENV_NOT_CLOSED(self); - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->dbremove(self->db_env, txn, file, database, flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - -static PyObject* -DBEnv_dbrename(DBEnvObject* self, PyObject* args, PyObject* kwargs) -{ - int err; - u_int32_t flags=0; - char *file = NULL; - char *database = NULL; - char *newname = NULL; - PyObject *txnobj = NULL; - DB_TXN *txn = NULL; - char* kwnames[] = { "file", "database", "newname", "txn", "flags", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sss|Oi:dbrename", kwnames, - &file, &database, &newname, &txnobj, &flags)) { - return NULL; - } - if (!checkTxnObj(txnobj, &txn)) { - return NULL; - } - CHECK_ENV_NOT_CLOSED(self); - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->dbrename(self->db_env, txn, file, database, newname, - flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - -static PyObject* -DBEnv_set_encrypt(DBEnvObject* self, PyObject* args, PyObject* kwargs) -{ - int err; - u_int32_t flags=0; - char *passwd = NULL; - char* kwnames[] = { "passwd", "flags", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|i:set_encrypt", kwnames, - &passwd, &flags)) { - return NULL; - } - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_encrypt(self->db_env, passwd, flags); - MYDB_END_ALLOW_THREADS; - - RETURN_IF_ERR(); - RETURN_NONE(); -} -#endif /* DBVER >= 41 */ - -#if (DBVER >= 40) -static PyObject* -DBEnv_set_timeout(DBEnvObject* self, PyObject* args, PyObject* kwargs) -{ - int err; - u_int32_t flags=0; - u_int32_t timeout = 0; - char* kwnames[] = { "timeout", "flags", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:set_timeout", kwnames, - &timeout, &flags)) { - return NULL; - } - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_timeout(self->db_env, (db_timeout_t)timeout, flags); - MYDB_END_ALLOW_THREADS; - - RETURN_IF_ERR(); - RETURN_NONE(); -} -#endif /* DBVER >= 40 */ - -static PyObject* -DBEnv_set_shm_key(DBEnvObject* self, PyObject* args) -{ - int err; - long shm_key = 0; - - if (!PyArg_ParseTuple(args, "l:set_shm_key", &shm_key)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - err = self->db_env->set_shm_key(self->db_env, shm_key); - RETURN_IF_ERR(); - RETURN_NONE(); -} - -static PyObject* -DBEnv_set_cachesize(DBEnvObject* self, PyObject* args) -{ - int err, gbytes=0, bytes=0, ncache=0; - - if (!PyArg_ParseTuple(args, "ii|i:set_cachesize", - &gbytes, &bytes, &ncache)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_cachesize(self->db_env, gbytes, bytes, ncache); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -#if (DBVER >= 32) -static PyObject* -DBEnv_set_flags(DBEnvObject* self, PyObject* args) -{ - int err, flags=0, onoff=0; - - if (!PyArg_ParseTuple(args, "ii:set_flags", - &flags, &onoff)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_flags(self->db_env, flags, onoff); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} -#endif - - -static PyObject* -DBEnv_set_data_dir(DBEnvObject* self, PyObject* args) -{ - int err; - char *dir; - - if (!PyArg_ParseTuple(args, "s:set_data_dir", &dir)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_data_dir(self->db_env, dir); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DBEnv_set_lg_bsize(DBEnvObject* self, PyObject* args) -{ - int err, lg_bsize; - - if (!PyArg_ParseTuple(args, "i:set_lg_bsize", &lg_bsize)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_lg_bsize(self->db_env, lg_bsize); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DBEnv_set_lg_dir(DBEnvObject* self, PyObject* args) -{ - int err; - char *dir; - - if (!PyArg_ParseTuple(args, "s:set_lg_dir", &dir)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_lg_dir(self->db_env, dir); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - -static PyObject* -DBEnv_set_lg_max(DBEnvObject* self, PyObject* args) -{ - int err, lg_max; - - if (!PyArg_ParseTuple(args, "i:set_lg_max", &lg_max)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_lg_max(self->db_env, lg_max); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DBEnv_set_lk_detect(DBEnvObject* self, PyObject* args) -{ - int err, lk_detect; - - if (!PyArg_ParseTuple(args, "i:set_lk_detect", &lk_detect)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_lk_detect(self->db_env, lk_detect); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DBEnv_set_lk_max(DBEnvObject* self, PyObject* args) -{ - int err, max; - - if (!PyArg_ParseTuple(args, "i:set_lk_max", &max)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_lk_max(self->db_env, max); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -#if (DBVER >= 32) - -static PyObject* -DBEnv_set_lk_max_locks(DBEnvObject* self, PyObject* args) -{ - int err, max; - - if (!PyArg_ParseTuple(args, "i:set_lk_max_locks", &max)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_lk_max_locks(self->db_env, max); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DBEnv_set_lk_max_lockers(DBEnvObject* self, PyObject* args) -{ - int err, max; - - if (!PyArg_ParseTuple(args, "i:set_lk_max_lockers", &max)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_lk_max_lockers(self->db_env, max); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DBEnv_set_lk_max_objects(DBEnvObject* self, PyObject* args) -{ - int err, max; - - if (!PyArg_ParseTuple(args, "i:set_lk_max_objects", &max)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_lk_max_objects(self->db_env, max); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - -#endif - - -static PyObject* -DBEnv_set_mp_mmapsize(DBEnvObject* self, PyObject* args) -{ - int err, mp_mmapsize; - - if (!PyArg_ParseTuple(args, "i:set_mp_mmapsize", &mp_mmapsize)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_mp_mmapsize(self->db_env, mp_mmapsize); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DBEnv_set_tmp_dir(DBEnvObject* self, PyObject* args) -{ - int err; - char *dir; - - if (!PyArg_ParseTuple(args, "s:set_tmp_dir", &dir)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_tmp_dir(self->db_env, dir); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DBEnv_txn_begin(DBEnvObject* self, PyObject* args, PyObject* kwargs) -{ - int flags = 0; - PyObject* txnobj = NULL; - DB_TXN *txn = NULL; - char* kwnames[] = { "parent", "flags", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Oi:txn_begin", kwnames, - &txnobj, &flags)) - return NULL; - - if (!checkTxnObj(txnobj, &txn)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - return (PyObject*)newDBTxnObject(self, txn, flags); -} - - -static PyObject* -DBEnv_txn_checkpoint(DBEnvObject* self, PyObject* args) -{ - int err, kbyte=0, min=0, flags=0; - - if (!PyArg_ParseTuple(args, "|iii:txn_checkpoint", &kbyte, &min, &flags)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 40) - err = self->db_env->txn_checkpoint(self->db_env, kbyte, min, flags); -#else - err = txn_checkpoint(self->db_env, kbyte, min, flags); -#endif - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DBEnv_set_tx_max(DBEnvObject* self, PyObject* args) -{ - int err, max; - - if (!PyArg_ParseTuple(args, "i:set_tx_max", &max)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_tx_max(self->db_env, max); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DBEnv_lock_detect(DBEnvObject* self, PyObject* args) -{ - int err, atype, flags=0; - int aborted = 0; - - if (!PyArg_ParseTuple(args, "i|i:lock_detect", &atype, &flags)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 40) - err = self->db_env->lock_detect(self->db_env, flags, atype, &aborted); -#else - err = lock_detect(self->db_env, flags, atype, &aborted); -#endif - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - return PyInt_FromLong(aborted); -} - - -static PyObject* -DBEnv_lock_get(DBEnvObject* self, PyObject* args) -{ - int flags=0; - int locker, lock_mode; - DBT obj; - PyObject* objobj; - - if (!PyArg_ParseTuple(args, "iOi|i:lock_get", &locker, &objobj, &lock_mode, &flags)) - return NULL; - - - if (!make_dbt(objobj, &obj)) - return NULL; - - return (PyObject*)newDBLockObject(self, locker, &obj, lock_mode, flags); -} - - -static PyObject* -DBEnv_lock_id(DBEnvObject* self, PyObject* args) -{ - int err; - u_int32_t theID; - - if (!PyArg_ParseTuple(args, ":lock_id")) - return NULL; - - CHECK_ENV_NOT_CLOSED(self); - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 40) - err = self->db_env->lock_id(self->db_env, &theID); -#else - err = lock_id(self->db_env, &theID); -#endif - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - - return PyInt_FromLong((long)theID); -} - - -static PyObject* -DBEnv_lock_put(DBEnvObject* self, PyObject* args) -{ - int err; - DBLockObject* dblockobj; - - if (!PyArg_ParseTuple(args, "O!:lock_put", &DBLock_Type, &dblockobj)) - return NULL; - - CHECK_ENV_NOT_CLOSED(self); - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 40) - err = self->db_env->lock_put(self->db_env, &dblockobj->lock); -#else - err = lock_put(self->db_env, &dblockobj->lock); -#endif - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DBEnv_lock_stat(DBEnvObject* self, PyObject* args) -{ - int err; - DB_LOCK_STAT* sp; - PyObject* d = NULL; - u_int32_t flags = 0; - - if (!PyArg_ParseTuple(args, "|i:lock_stat", &flags)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 40) - err = self->db_env->lock_stat(self->db_env, &sp, flags); -#else -#if (DBVER >= 33) - err = lock_stat(self->db_env, &sp); -#else - err = lock_stat(self->db_env, &sp, NULL); -#endif -#endif - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - - /* Turn the stat structure into a dictionary */ - d = PyDict_New(); - if (d == NULL) { - free(sp); - return NULL; - } - -#define MAKE_ENTRY(name) _addIntToDict(d, #name, sp->st_##name) - -#if (DBVER < 41) - MAKE_ENTRY(lastid); -#endif - MAKE_ENTRY(nmodes); -#if (DBVER >= 32) - MAKE_ENTRY(maxlocks); - MAKE_ENTRY(maxlockers); - MAKE_ENTRY(maxobjects); - MAKE_ENTRY(nlocks); - MAKE_ENTRY(maxnlocks); -#endif - MAKE_ENTRY(nlockers); - MAKE_ENTRY(maxnlockers); -#if (DBVER >= 32) - MAKE_ENTRY(nobjects); - MAKE_ENTRY(maxnobjects); -#endif - MAKE_ENTRY(nrequests); - MAKE_ENTRY(nreleases); - MAKE_ENTRY(nnowaits); - MAKE_ENTRY(nconflicts); - MAKE_ENTRY(ndeadlocks); - MAKE_ENTRY(regsize); - MAKE_ENTRY(region_wait); - MAKE_ENTRY(region_nowait); - -#undef MAKE_ENTRY - free(sp); - return d; -} - - -static PyObject* -DBEnv_log_archive(DBEnvObject* self, PyObject* args) -{ - int flags=0; - int err; - char **log_list_start, **log_list; - PyObject* list; - PyObject* item = NULL; - - if (!PyArg_ParseTuple(args, "|i:log_archive", &flags)) - return NULL; - - CHECK_ENV_NOT_CLOSED(self); - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 40) - err = self->db_env->log_archive(self->db_env, &log_list, flags); -#elif (DBVER == 33) - err = log_archive(self->db_env, &log_list, flags); -#else - err = log_archive(self->db_env, &log_list, flags, NULL); -#endif - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - - list = PyList_New(0); - if (list == NULL) { - PyErr_SetString(PyExc_MemoryError, "PyList_New failed"); - return NULL; - } - - if (log_list) { - for (log_list_start = log_list; *log_list != NULL; ++log_list) { - item = PyString_FromString (*log_list); - if (item == NULL) { - Py_DECREF(list); - PyErr_SetString(PyExc_MemoryError, - "List item creation failed"); - list = NULL; - break; - } - PyList_Append(list, item); - Py_DECREF(item); - } - free(log_list_start); - } - return list; -} - - -static PyObject* -DBEnv_txn_stat(DBEnvObject* self, PyObject* args) -{ - int err; - DB_TXN_STAT* sp; - PyObject* d = NULL; - u_int32_t flags=0; - - if (!PyArg_ParseTuple(args, "|i:txn_stat", &flags)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 40) - err = self->db_env->txn_stat(self->db_env, &sp, flags); -#elif (DBVER == 33) - err = txn_stat(self->db_env, &sp); -#else - err = txn_stat(self->db_env, &sp, NULL); -#endif - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - - /* Turn the stat structure into a dictionary */ - d = PyDict_New(); - if (d == NULL) { - free(sp); - return NULL; - } - -#define MAKE_ENTRY(name) _addIntToDict(d, #name, sp->st_##name) - - MAKE_ENTRY(time_ckp); - MAKE_ENTRY(last_txnid); - MAKE_ENTRY(maxtxns); - MAKE_ENTRY(nactive); - MAKE_ENTRY(maxnactive); - MAKE_ENTRY(nbegins); - MAKE_ENTRY(naborts); - MAKE_ENTRY(ncommits); - MAKE_ENTRY(regsize); - MAKE_ENTRY(region_wait); - MAKE_ENTRY(region_nowait); - -#undef MAKE_ENTRY - free(sp); - return d; -} - - -static PyObject* -DBEnv_set_get_returns_none(DBEnvObject* self, PyObject* args) -{ - int flags=0; - int oldValue=0; - - if (!PyArg_ParseTuple(args,"i:set_get_returns_none", &flags)) - return NULL; - CHECK_ENV_NOT_CLOSED(self); - - if (self->moduleFlags.getReturnsNone) - ++oldValue; - if (self->moduleFlags.cursorSetReturnsNone) - ++oldValue; - self->moduleFlags.getReturnsNone = (flags >= 1); - self->moduleFlags.cursorSetReturnsNone = (flags >= 2); - return PyInt_FromLong(oldValue); -} - - -/* --------------------------------------------------------------------- */ -/* DBTxn methods */ - - -static PyObject* -DBTxn_commit(DBTxnObject* self, PyObject* args) -{ - int flags=0, err; - DB_TXN *txn; - - if (!PyArg_ParseTuple(args, "|i:commit", &flags)) - return NULL; - - if (!self->txn) { - PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, - "DBTxn must not be used after txn_commit or txn_abort")); - return NULL; - } - txn = self->txn; - self->txn = NULL; /* this DB_TXN is no longer valid after this call */ - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 40) - err = txn->commit(txn, flags); -#else - err = txn_commit(txn, flags); -#endif - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - -static PyObject* -DBTxn_prepare(DBTxnObject* self, PyObject* args) -{ -#if (DBVER >= 33) - int err; - char* gid=NULL; - int gid_size=0; - - if (!PyArg_ParseTuple(args, "s#:prepare", &gid, &gid_size)) - return NULL; - - if (gid_size != DB_XIDDATASIZE) { - PyErr_SetString(PyExc_TypeError, - "gid must be DB_XIDDATASIZE bytes long"); - return NULL; - } - - if (!self->txn) { - PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, - "DBTxn must not be used after txn_commit or txn_abort")); - return NULL; - } - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 40) - err = self->txn->prepare(self->txn, (u_int8_t*)gid); -#else - err = txn_prepare(self->txn, (u_int8_t*)gid); -#endif - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -#else - int err; - - if (!PyArg_ParseTuple(args, ":prepare")) - return NULL; - - if (!self->txn) { - PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, - "DBTxn must not be used after txn_commit or txn_abort")); - return NULL; - } - MYDB_BEGIN_ALLOW_THREADS; - err = txn_prepare(self->txn); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -#endif -} - - -static PyObject* -DBTxn_abort(DBTxnObject* self, PyObject* args) -{ - int err; - DB_TXN *txn; - - if (!PyArg_ParseTuple(args, ":abort")) - return NULL; - - if (!self->txn) { - PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, - "DBTxn must not be used after txn_commit or txn_abort")); - return NULL; - } - txn = self->txn; - self->txn = NULL; /* this DB_TXN is no longer valid after this call */ - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 40) - err = txn->abort(txn); -#else - err = txn_abort(txn); -#endif - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - - -static PyObject* -DBTxn_id(DBTxnObject* self, PyObject* args) -{ - int id; - - if (!PyArg_ParseTuple(args, ":id")) - return NULL; - - if (!self->txn) { - PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, - "DBTxn must not be used after txn_commit or txn_abort")); - return NULL; - } - MYDB_BEGIN_ALLOW_THREADS; -#if (DBVER >= 40) - id = self->txn->id(self->txn); -#else - id = txn_id(self->txn); -#endif - MYDB_END_ALLOW_THREADS; - return PyInt_FromLong(id); -} - -/* --------------------------------------------------------------------- */ -/* Method definition tables and type objects */ - -static PyMethodDef DB_methods[] = { - {"append", (PyCFunction)DB_append, METH_VARARGS}, -#if (DBVER >= 33) - {"associate", (PyCFunction)DB_associate, METH_VARARGS|METH_KEYWORDS}, -#endif - {"close", (PyCFunction)DB_close, METH_VARARGS}, -#if (DBVER >= 32) - {"consume", (PyCFunction)DB_consume, METH_VARARGS|METH_KEYWORDS}, - {"consume_wait", (PyCFunction)DB_consume_wait, METH_VARARGS|METH_KEYWORDS}, -#endif - {"cursor", (PyCFunction)DB_cursor, METH_VARARGS|METH_KEYWORDS}, - {"delete", (PyCFunction)DB_delete, METH_VARARGS|METH_KEYWORDS}, - {"fd", (PyCFunction)DB_fd, METH_VARARGS}, - {"get", (PyCFunction)DB_get, METH_VARARGS|METH_KEYWORDS}, - {"get_both", (PyCFunction)DB_get_both, METH_VARARGS|METH_KEYWORDS}, - {"get_byteswapped", (PyCFunction)DB_get_byteswapped,METH_VARARGS}, - {"get_size", (PyCFunction)DB_get_size, METH_VARARGS|METH_KEYWORDS}, - {"get_type", (PyCFunction)DB_get_type, METH_VARARGS}, - {"join", (PyCFunction)DB_join, METH_VARARGS}, - {"key_range", (PyCFunction)DB_key_range, METH_VARARGS|METH_KEYWORDS}, - {"has_key", (PyCFunction)DB_has_key, METH_VARARGS}, - {"items", (PyCFunction)DB_items, METH_VARARGS}, - {"keys", (PyCFunction)DB_keys, METH_VARARGS}, - {"open", (PyCFunction)DB_open, METH_VARARGS|METH_KEYWORDS}, - {"put", (PyCFunction)DB_put, METH_VARARGS|METH_KEYWORDS}, - {"remove", (PyCFunction)DB_remove, METH_VARARGS|METH_KEYWORDS}, - {"rename", (PyCFunction)DB_rename, METH_VARARGS}, - {"set_bt_minkey", (PyCFunction)DB_set_bt_minkey, METH_VARARGS}, - {"set_cachesize", (PyCFunction)DB_set_cachesize, METH_VARARGS}, -#if (DBVER >= 41) - {"set_encrypt", (PyCFunction)DB_set_encrypt, METH_VARARGS|METH_KEYWORDS}, -#endif - {"set_flags", (PyCFunction)DB_set_flags, METH_VARARGS}, - {"set_h_ffactor", (PyCFunction)DB_set_h_ffactor, METH_VARARGS}, - {"set_h_nelem", (PyCFunction)DB_set_h_nelem, METH_VARARGS}, - {"set_lorder", (PyCFunction)DB_set_lorder, METH_VARARGS}, - {"set_pagesize", (PyCFunction)DB_set_pagesize, METH_VARARGS}, - {"set_re_delim", (PyCFunction)DB_set_re_delim, METH_VARARGS}, - {"set_re_len", (PyCFunction)DB_set_re_len, METH_VARARGS}, - {"set_re_pad", (PyCFunction)DB_set_re_pad, METH_VARARGS}, - {"set_re_source", (PyCFunction)DB_set_re_source, METH_VARARGS}, -#if (DBVER >= 32) - {"set_q_extentsize",(PyCFunction)DB_set_q_extentsize,METH_VARARGS}, -#endif - {"stat", (PyCFunction)DB_stat, METH_VARARGS}, - {"sync", (PyCFunction)DB_sync, METH_VARARGS}, -#if (DBVER >= 33) - {"truncate", (PyCFunction)DB_truncate, METH_VARARGS|METH_KEYWORDS}, -#endif - {"type", (PyCFunction)DB_get_type, METH_VARARGS}, - {"upgrade", (PyCFunction)DB_upgrade, METH_VARARGS}, - {"values", (PyCFunction)DB_values, METH_VARARGS}, - {"verify", (PyCFunction)DB_verify, METH_VARARGS|METH_KEYWORDS}, - {"set_get_returns_none",(PyCFunction)DB_set_get_returns_none, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - - -static PyMappingMethods DB_mapping = { - (inquiry)DB_length, /*mp_length*/ - (binaryfunc)DB_subscript, /*mp_subscript*/ - (objobjargproc)DB_ass_sub, /*mp_ass_subscript*/ -}; - - -static PyMethodDef DBCursor_methods[] = { - {"close", (PyCFunction)DBC_close, METH_VARARGS}, - {"count", (PyCFunction)DBC_count, METH_VARARGS}, - {"current", (PyCFunction)DBC_current, METH_VARARGS|METH_KEYWORDS}, - {"delete", (PyCFunction)DBC_delete, METH_VARARGS}, - {"dup", (PyCFunction)DBC_dup, METH_VARARGS}, - {"first", (PyCFunction)DBC_first, METH_VARARGS|METH_KEYWORDS}, - {"get", (PyCFunction)DBC_get, METH_VARARGS|METH_KEYWORDS}, - {"get_recno", (PyCFunction)DBC_get_recno, METH_VARARGS}, - {"last", (PyCFunction)DBC_last, METH_VARARGS|METH_KEYWORDS}, - {"next", (PyCFunction)DBC_next, METH_VARARGS|METH_KEYWORDS}, - {"prev", (PyCFunction)DBC_prev, METH_VARARGS|METH_KEYWORDS}, - {"put", (PyCFunction)DBC_put, METH_VARARGS|METH_KEYWORDS}, - {"set", (PyCFunction)DBC_set, METH_VARARGS|METH_KEYWORDS}, - {"set_range", (PyCFunction)DBC_set_range, METH_VARARGS|METH_KEYWORDS}, - {"get_both", (PyCFunction)DBC_get_both, METH_VARARGS}, - {"set_both", (PyCFunction)DBC_set_both, METH_VARARGS}, - {"set_recno", (PyCFunction)DBC_set_recno, METH_VARARGS|METH_KEYWORDS}, - {"consume", (PyCFunction)DBC_consume, METH_VARARGS|METH_KEYWORDS}, - {"next_dup", (PyCFunction)DBC_next_dup, METH_VARARGS|METH_KEYWORDS}, - {"next_nodup", (PyCFunction)DBC_next_nodup, METH_VARARGS|METH_KEYWORDS}, - {"prev_nodup", (PyCFunction)DBC_prev_nodup, METH_VARARGS|METH_KEYWORDS}, - {"join_item", (PyCFunction)DBC_join_item, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - - -static PyMethodDef DBEnv_methods[] = { - {"close", (PyCFunction)DBEnv_close, METH_VARARGS}, - {"open", (PyCFunction)DBEnv_open, METH_VARARGS}, - {"remove", (PyCFunction)DBEnv_remove, METH_VARARGS}, -#if (DBVER >= 41) - {"dbremove", (PyCFunction)DBEnv_dbremove, METH_VARARGS|METH_KEYWORDS}, - {"dbrename", (PyCFunction)DBEnv_dbrename, METH_VARARGS|METH_KEYWORDS}, - {"set_encrypt", (PyCFunction)DBEnv_set_encrypt, METH_VARARGS|METH_KEYWORDS}, -#endif -#if (DBVER >= 40) - {"set_timeout", (PyCFunction)DBEnv_set_timeout, METH_VARARGS|METH_KEYWORDS}, -#endif - {"set_shm_key", (PyCFunction)DBEnv_set_shm_key, METH_VARARGS}, - {"set_cachesize", (PyCFunction)DBEnv_set_cachesize, METH_VARARGS}, - {"set_data_dir", (PyCFunction)DBEnv_set_data_dir, METH_VARARGS}, -#if (DBVER >= 32) - {"set_flags", (PyCFunction)DBEnv_set_flags, METH_VARARGS}, -#endif - {"set_lg_bsize", (PyCFunction)DBEnv_set_lg_bsize, METH_VARARGS}, - {"set_lg_dir", (PyCFunction)DBEnv_set_lg_dir, METH_VARARGS}, - {"set_lg_max", (PyCFunction)DBEnv_set_lg_max, METH_VARARGS}, - {"set_lk_detect", (PyCFunction)DBEnv_set_lk_detect, METH_VARARGS}, - {"set_lk_max", (PyCFunction)DBEnv_set_lk_max, METH_VARARGS}, -#if (DBVER >= 32) - {"set_lk_max_locks", (PyCFunction)DBEnv_set_lk_max_locks, METH_VARARGS}, - {"set_lk_max_lockers", (PyCFunction)DBEnv_set_lk_max_lockers, METH_VARARGS}, - {"set_lk_max_objects", (PyCFunction)DBEnv_set_lk_max_objects, METH_VARARGS}, -#endif - {"set_mp_mmapsize", (PyCFunction)DBEnv_set_mp_mmapsize, METH_VARARGS}, - {"set_tmp_dir", (PyCFunction)DBEnv_set_tmp_dir, METH_VARARGS}, - {"txn_begin", (PyCFunction)DBEnv_txn_begin, METH_VARARGS|METH_KEYWORDS}, - {"txn_checkpoint", (PyCFunction)DBEnv_txn_checkpoint, METH_VARARGS}, - {"txn_stat", (PyCFunction)DBEnv_txn_stat, METH_VARARGS}, - {"set_tx_max", (PyCFunction)DBEnv_set_tx_max, METH_VARARGS}, - {"lock_detect", (PyCFunction)DBEnv_lock_detect, METH_VARARGS}, - {"lock_get", (PyCFunction)DBEnv_lock_get, METH_VARARGS}, - {"lock_id", (PyCFunction)DBEnv_lock_id, METH_VARARGS}, - {"lock_put", (PyCFunction)DBEnv_lock_put, METH_VARARGS}, - {"lock_stat", (PyCFunction)DBEnv_lock_stat, METH_VARARGS}, - {"log_archive", (PyCFunction)DBEnv_log_archive, METH_VARARGS}, - {"set_get_returns_none",(PyCFunction)DBEnv_set_get_returns_none, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - - -static PyMethodDef DBTxn_methods[] = { - {"commit", (PyCFunction)DBTxn_commit, METH_VARARGS}, - {"prepare", (PyCFunction)DBTxn_prepare, METH_VARARGS}, - {"abort", (PyCFunction)DBTxn_abort, METH_VARARGS}, - {"id", (PyCFunction)DBTxn_id, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - - -static PyObject* -DB_getattr(DBObject* self, char *name) -{ - return Py_FindMethod(DB_methods, (PyObject* )self, name); -} - - -static PyObject* -DBEnv_getattr(DBEnvObject* self, char *name) -{ - if (!strcmp(name, "db_home")) { - CHECK_ENV_NOT_CLOSED(self); - if (self->db_env->db_home == NULL) { - RETURN_NONE(); - } - return PyString_FromString(self->db_env->db_home); - } - - return Py_FindMethod(DBEnv_methods, (PyObject* )self, name); -} - - -static PyObject* -DBCursor_getattr(DBCursorObject* self, char *name) -{ - return Py_FindMethod(DBCursor_methods, (PyObject* )self, name); -} - -static PyObject* -DBTxn_getattr(DBTxnObject* self, char *name) -{ - return Py_FindMethod(DBTxn_methods, (PyObject* )self, name); -} - -static PyObject* -DBLock_getattr(DBLockObject* self, char *name) -{ - return NULL; -} - -statichere PyTypeObject DB_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "DB", /*tp_name*/ - sizeof(DBObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)DB_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)DB_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - &DB_mapping,/*tp_as_mapping*/ - 0, /*tp_hash*/ -}; - - -statichere PyTypeObject DBCursor_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "DBCursor", /*tp_name*/ - sizeof(DBCursorObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)DBCursor_dealloc,/*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)DBCursor_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ -}; - - -statichere PyTypeObject DBEnv_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "DBEnv", /*tp_name*/ - sizeof(DBEnvObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)DBEnv_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)DBEnv_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ -}; - -statichere PyTypeObject DBTxn_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "DBTxn", /*tp_name*/ - sizeof(DBTxnObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)DBTxn_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)DBTxn_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ -}; - - -statichere PyTypeObject DBLock_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "DBLock", /*tp_name*/ - sizeof(DBLockObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)DBLock_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)DBLock_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ -}; - - -/* --------------------------------------------------------------------- */ -/* Module-level functions */ - -static PyObject* -DB_construct(PyObject* self, PyObject* args, PyObject* kwargs) -{ - PyObject* dbenvobj = NULL; - int flags = 0; - char* kwnames[] = { "dbEnv", "flags", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Oi:DB", kwnames, - &dbenvobj, &flags)) - return NULL; - if (dbenvobj == Py_None) - dbenvobj = NULL; - else if (dbenvobj && !DBEnvObject_Check(dbenvobj)) { - makeTypeError("DBEnv", dbenvobj); - return NULL; - } - - return (PyObject* )newDBObject((DBEnvObject*)dbenvobj, flags); -} - - -static PyObject* -DBEnv_construct(PyObject* self, PyObject* args) -{ - int flags = 0; - if (!PyArg_ParseTuple(args, "|i:DbEnv", &flags)) return NULL; - return (PyObject* )newDBEnvObject(flags); -} - - -static char bsddb_version_doc[] = -"Returns a tuple of major, minor, and patch release numbers of the\n\ -underlying DB library."; - -static PyObject* -bsddb_version(PyObject* self, PyObject* args) -{ - int major, minor, patch; - - if (!PyArg_ParseTuple(args, ":version")) - return NULL; - db_version(&major, &minor, &patch); - return Py_BuildValue("(iii)", major, minor, patch); -} - - -/* List of functions defined in the module */ - -static PyMethodDef bsddb_methods[] = { - {"DB", (PyCFunction)DB_construct, METH_VARARGS | METH_KEYWORDS }, - {"DBEnv", (PyCFunction)DBEnv_construct, METH_VARARGS}, - {"version", (PyCFunction)bsddb_version, METH_VARARGS, bsddb_version_doc}, - {NULL, NULL} /* sentinel */ -}; - - -/* --------------------------------------------------------------------- */ -/* Module initialization */ - - -/* Convenience routine to export an integer value. - * Errors are silently ignored, for better or for worse... - */ -#define ADD_INT(dict, NAME) _addIntToDict(dict, #NAME, NAME) - -DL_EXPORT(void) init_bsddb(void) -{ - PyObject* m; - PyObject* d; - PyObject* pybsddb_version_s = PyString_FromString( PY_BSDDB_VERSION ); - PyObject* db_version_s = PyString_FromString( DB_VERSION_STRING ); - PyObject* cvsid_s = PyString_FromString( rcs_id ); - - /* Initialize the type of the new type objects here; doing it here - is required for portability to Windows without requiring C++. */ - DB_Type.ob_type = &PyType_Type; - DBCursor_Type.ob_type = &PyType_Type; - DBEnv_Type.ob_type = &PyType_Type; - DBTxn_Type.ob_type = &PyType_Type; - DBLock_Type.ob_type = &PyType_Type; - - -#if defined(WITH_THREAD) && !defined(MYDB_USE_GILSTATE) - /* Save the current interpreter, so callbacks can do the right thing. */ - _db_interpreterState = PyThreadState_Get()->interp; -#endif - - /* Create the module and add the functions */ - m = Py_InitModule("_bsddb", bsddb_methods); - - /* Add some symbolic constants to the module */ - d = PyModule_GetDict(m); - PyDict_SetItemString(d, "__version__", pybsddb_version_s); - PyDict_SetItemString(d, "cvsid", cvsid_s); - PyDict_SetItemString(d, "DB_VERSION_STRING", db_version_s); - Py_DECREF(pybsddb_version_s); - pybsddb_version_s = NULL; - Py_DECREF(cvsid_s); - cvsid_s = NULL; - Py_DECREF(db_version_s); - db_version_s = NULL; - - ADD_INT(d, DB_VERSION_MAJOR); - ADD_INT(d, DB_VERSION_MINOR); - ADD_INT(d, DB_VERSION_PATCH); - - ADD_INT(d, DB_MAX_PAGES); - ADD_INT(d, DB_MAX_RECORDS); - -#if (DBVER >= 42) - ADD_INT(d, DB_RPCCLIENT); -#else - ADD_INT(d, DB_CLIENT); - /* allow apps to be written using DB_RPCCLIENT on older BerkeleyDB */ - _addIntToDict(d, "DB_RPCCLIENT", DB_CLIENT); -#endif - ADD_INT(d, DB_XA_CREATE); - - ADD_INT(d, DB_CREATE); - ADD_INT(d, DB_NOMMAP); - ADD_INT(d, DB_THREAD); - - ADD_INT(d, DB_FORCE); - ADD_INT(d, DB_INIT_CDB); - ADD_INT(d, DB_INIT_LOCK); - ADD_INT(d, DB_INIT_LOG); - ADD_INT(d, DB_INIT_MPOOL); - ADD_INT(d, DB_INIT_TXN); -#if (DBVER >= 32) - ADD_INT(d, DB_JOINENV); -#endif - - ADD_INT(d, DB_RECOVER); - ADD_INT(d, DB_RECOVER_FATAL); - ADD_INT(d, DB_TXN_NOSYNC); - ADD_INT(d, DB_USE_ENVIRON); - ADD_INT(d, DB_USE_ENVIRON_ROOT); - - ADD_INT(d, DB_LOCKDOWN); - ADD_INT(d, DB_PRIVATE); - ADD_INT(d, DB_SYSTEM_MEM); - - ADD_INT(d, DB_TXN_SYNC); - ADD_INT(d, DB_TXN_NOWAIT); - - ADD_INT(d, DB_EXCL); - ADD_INT(d, DB_FCNTL_LOCKING); - ADD_INT(d, DB_ODDFILESIZE); - ADD_INT(d, DB_RDWRMASTER); - ADD_INT(d, DB_RDONLY); - ADD_INT(d, DB_TRUNCATE); -#if (DBVER >= 32) - ADD_INT(d, DB_EXTENT); - ADD_INT(d, DB_CDB_ALLDB); - ADD_INT(d, DB_VERIFY); -#endif - ADD_INT(d, DB_UPGRADE); - - ADD_INT(d, DB_AGGRESSIVE); - ADD_INT(d, DB_NOORDERCHK); - ADD_INT(d, DB_ORDERCHKONLY); - ADD_INT(d, DB_PR_PAGE); -#if ! (DBVER >= 33) - ADD_INT(d, DB_VRFY_FLAGMASK); - ADD_INT(d, DB_PR_HEADERS); -#endif - ADD_INT(d, DB_PR_RECOVERYTEST); - ADD_INT(d, DB_SALVAGE); - - ADD_INT(d, DB_LOCK_NORUN); - ADD_INT(d, DB_LOCK_DEFAULT); - ADD_INT(d, DB_LOCK_OLDEST); - ADD_INT(d, DB_LOCK_RANDOM); - ADD_INT(d, DB_LOCK_YOUNGEST); -#if (DBVER >= 33) - ADD_INT(d, DB_LOCK_MAXLOCKS); - ADD_INT(d, DB_LOCK_MINLOCKS); - ADD_INT(d, DB_LOCK_MINWRITE); -#endif - - -#if (DBVER >= 33) - /* docs say to use zero instead */ - _addIntToDict(d, "DB_LOCK_CONFLICT", 0); -#else - ADD_INT(d, DB_LOCK_CONFLICT); -#endif - - ADD_INT(d, DB_LOCK_DUMP); - ADD_INT(d, DB_LOCK_GET); - ADD_INT(d, DB_LOCK_INHERIT); - ADD_INT(d, DB_LOCK_PUT); - ADD_INT(d, DB_LOCK_PUT_ALL); - ADD_INT(d, DB_LOCK_PUT_OBJ); - - ADD_INT(d, DB_LOCK_NG); - ADD_INT(d, DB_LOCK_READ); - ADD_INT(d, DB_LOCK_WRITE); - ADD_INT(d, DB_LOCK_NOWAIT); -#if (DBVER >= 32) - ADD_INT(d, DB_LOCK_WAIT); -#endif - ADD_INT(d, DB_LOCK_IWRITE); - ADD_INT(d, DB_LOCK_IREAD); - ADD_INT(d, DB_LOCK_IWR); -#if (DBVER >= 33) - ADD_INT(d, DB_LOCK_DIRTY); - ADD_INT(d, DB_LOCK_WWRITE); -#endif - - ADD_INT(d, DB_LOCK_RECORD); - ADD_INT(d, DB_LOCK_UPGRADE); -#if (DBVER >= 32) - ADD_INT(d, DB_LOCK_SWITCH); -#endif -#if (DBVER >= 33) - ADD_INT(d, DB_LOCK_UPGRADE_WRITE); -#endif - - ADD_INT(d, DB_LOCK_NOWAIT); - ADD_INT(d, DB_LOCK_RECORD); - ADD_INT(d, DB_LOCK_UPGRADE); - -#if (DBVER >= 33) - ADD_INT(d, DB_LSTAT_ABORTED); - ADD_INT(d, DB_LSTAT_ERR); - ADD_INT(d, DB_LSTAT_FREE); - ADD_INT(d, DB_LSTAT_HELD); -#if (DBVER == 33) - ADD_INT(d, DB_LSTAT_NOGRANT); -#endif - ADD_INT(d, DB_LSTAT_PENDING); - ADD_INT(d, DB_LSTAT_WAITING); -#endif - - ADD_INT(d, DB_ARCH_ABS); - ADD_INT(d, DB_ARCH_DATA); - ADD_INT(d, DB_ARCH_LOG); - - ADD_INT(d, DB_BTREE); - ADD_INT(d, DB_HASH); - ADD_INT(d, DB_RECNO); - ADD_INT(d, DB_QUEUE); - ADD_INT(d, DB_UNKNOWN); - - ADD_INT(d, DB_DUP); - ADD_INT(d, DB_DUPSORT); - ADD_INT(d, DB_RECNUM); - ADD_INT(d, DB_RENUMBER); - ADD_INT(d, DB_REVSPLITOFF); - ADD_INT(d, DB_SNAPSHOT); - - ADD_INT(d, DB_JOIN_NOSORT); - - ADD_INT(d, DB_AFTER); - ADD_INT(d, DB_APPEND); - ADD_INT(d, DB_BEFORE); - ADD_INT(d, DB_CACHED_COUNTS); -#if (DBVER >= 41) - _addIntToDict(d, "DB_CHECKPOINT", 0); -#else - ADD_INT(d, DB_CHECKPOINT); - ADD_INT(d, DB_CURLSN); -#endif -#if ((DBVER >= 33) && (DBVER <= 41)) - ADD_INT(d, DB_COMMIT); -#endif - ADD_INT(d, DB_CONSUME); -#if (DBVER >= 32) - ADD_INT(d, DB_CONSUME_WAIT); -#endif - ADD_INT(d, DB_CURRENT); -#if (DBVER >= 33) - ADD_INT(d, DB_FAST_STAT); -#endif - ADD_INT(d, DB_FIRST); - ADD_INT(d, DB_FLUSH); - ADD_INT(d, DB_GET_BOTH); - ADD_INT(d, DB_GET_RECNO); - ADD_INT(d, DB_JOIN_ITEM); - ADD_INT(d, DB_KEYFIRST); - ADD_INT(d, DB_KEYLAST); - ADD_INT(d, DB_LAST); - ADD_INT(d, DB_NEXT); - ADD_INT(d, DB_NEXT_DUP); - ADD_INT(d, DB_NEXT_NODUP); - ADD_INT(d, DB_NODUPDATA); - ADD_INT(d, DB_NOOVERWRITE); - ADD_INT(d, DB_NOSYNC); - ADD_INT(d, DB_POSITION); - ADD_INT(d, DB_PREV); - ADD_INT(d, DB_PREV_NODUP); - ADD_INT(d, DB_RECORDCOUNT); - ADD_INT(d, DB_SET); - ADD_INT(d, DB_SET_RANGE); - ADD_INT(d, DB_SET_RECNO); - ADD_INT(d, DB_WRITECURSOR); - - ADD_INT(d, DB_OPFLAGS_MASK); - ADD_INT(d, DB_RMW); -#if (DBVER >= 33) - ADD_INT(d, DB_DIRTY_READ); - ADD_INT(d, DB_MULTIPLE); - ADD_INT(d, DB_MULTIPLE_KEY); -#endif - -#if (DBVER >= 33) - ADD_INT(d, DB_DONOTINDEX); -#endif - -#if (DBVER >= 41) - _addIntToDict(d, "DB_INCOMPLETE", 0); -#else - ADD_INT(d, DB_INCOMPLETE); -#endif - ADD_INT(d, DB_KEYEMPTY); - ADD_INT(d, DB_KEYEXIST); - ADD_INT(d, DB_LOCK_DEADLOCK); - ADD_INT(d, DB_LOCK_NOTGRANTED); - ADD_INT(d, DB_NOSERVER); - ADD_INT(d, DB_NOSERVER_HOME); - ADD_INT(d, DB_NOSERVER_ID); - ADD_INT(d, DB_NOTFOUND); - ADD_INT(d, DB_OLD_VERSION); - ADD_INT(d, DB_RUNRECOVERY); - ADD_INT(d, DB_VERIFY_BAD); -#if (DBVER >= 33) - ADD_INT(d, DB_PAGE_NOTFOUND); - ADD_INT(d, DB_SECONDARY_BAD); -#endif -#if (DBVER >= 40) - ADD_INT(d, DB_STAT_CLEAR); - ADD_INT(d, DB_REGION_INIT); - ADD_INT(d, DB_NOLOCKING); - ADD_INT(d, DB_YIELDCPU); - ADD_INT(d, DB_PANIC_ENVIRONMENT); - ADD_INT(d, DB_NOPANIC); -#endif - -#if (DBVER >= 42) - ADD_INT(d, DB_TIME_NOTGRANTED); - ADD_INT(d, DB_TXN_NOT_DURABLE); - ADD_INT(d, DB_TXN_WRITE_NOSYNC); - ADD_INT(d, DB_LOG_AUTOREMOVE); - ADD_INT(d, DB_DIRECT_LOG); - ADD_INT(d, DB_DIRECT_DB); - ADD_INT(d, DB_INIT_REP); - ADD_INT(d, DB_ENCRYPT); - ADD_INT(d, DB_CHKSUM); -#endif - -#if (DBVER >= 41) - ADD_INT(d, DB_ENCRYPT_AES); - ADD_INT(d, DB_AUTO_COMMIT); -#else - /* allow berkeleydb 4.1 aware apps to run on older versions */ - _addIntToDict(d, "DB_AUTO_COMMIT", 0); -#endif - - ADD_INT(d, EINVAL); - ADD_INT(d, EACCES); - ADD_INT(d, ENOSPC); - ADD_INT(d, ENOMEM); - ADD_INT(d, EAGAIN); - ADD_INT(d, EBUSY); - ADD_INT(d, EEXIST); - ADD_INT(d, ENOENT); - ADD_INT(d, EPERM); - -#if (DBVER >= 40) - ADD_INT(d, DB_SET_LOCK_TIMEOUT); - ADD_INT(d, DB_SET_TXN_TIMEOUT); -#endif - - /* The base exception class is DBError */ - DBError = PyErr_NewException("bsddb._db.DBError", NULL, NULL); - PyDict_SetItemString(d, "DBError", DBError); - - /* Some magic to make DBNotFoundError derive from both DBError and - KeyError, since the API only supports using one base class. */ - PyDict_SetItemString(d, "KeyError", PyExc_KeyError); - PyRun_String("class DBNotFoundError(DBError, KeyError): pass", - Py_file_input, d, d); - DBNotFoundError = PyDict_GetItemString(d, "DBNotFoundError"); - PyDict_DelItemString(d, "KeyError"); - - - /* All the rest of the exceptions derive only from DBError */ -#define MAKE_EX(name) name = PyErr_NewException("bsddb._db." #name, DBError, NULL); \ - PyDict_SetItemString(d, #name, name) - -#if !INCOMPLETE_IS_WARNING - MAKE_EX(DBIncompleteError); -#endif - MAKE_EX(DBKeyEmptyError); - MAKE_EX(DBKeyExistError); - MAKE_EX(DBLockDeadlockError); - MAKE_EX(DBLockNotGrantedError); - MAKE_EX(DBOldVersionError); - MAKE_EX(DBRunRecoveryError); - MAKE_EX(DBVerifyBadError); - MAKE_EX(DBNoServerError); - MAKE_EX(DBNoServerHomeError); - MAKE_EX(DBNoServerIDError); -#if (DBVER >= 33) - MAKE_EX(DBPageNotFoundError); - MAKE_EX(DBSecondaryBadError); -#endif - - MAKE_EX(DBInvalidArgError); - MAKE_EX(DBAccessError); - MAKE_EX(DBNoSpaceError); - MAKE_EX(DBNoMemoryError); - MAKE_EX(DBAgainError); - MAKE_EX(DBBusyError); - MAKE_EX(DBFileExistsError); - MAKE_EX(DBNoSuchFileError); - MAKE_EX(DBPermissionsError); - -#undef MAKE_EX - - /* Check for errors */ - if (PyErr_Occurred()) { - PyErr_Print(); - Py_FatalError("can't initialize module _bsddb"); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/_codecsmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/_codecsmodule.c deleted file mode 100644 index 5a45bafb..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/_codecsmodule.c +++ /dev/null @@ -1,816 +0,0 @@ -/* ------------------------------------------------------------------------ - - _codecs -- Provides access to the codec registry and the builtin - codecs. - - This module should never be imported directly. The standard library - module "codecs" wraps this builtin module for use within Python. - - The codec registry is accessible via: - - register(search_function) -> None - - lookup(encoding) -> (encoder, decoder, stream_reader, stream_writer) - - The builtin Unicode codecs use the following interface: - - _encode(Unicode_object[,errors='strict']) -> - (string object, bytes consumed) - - _decode(char_buffer_obj[,errors='strict']) -> - (Unicode object, bytes consumed) - - _encode() interfaces also accept non-Unicode object as - input. The objects are then converted to Unicode using - PyUnicode_FromObject() prior to applying the conversion. - - These s are available: utf_8, unicode_escape, - raw_unicode_escape, unicode_internal, latin_1, ascii (7-bit), - mbcs (on win32). - - -Written by Marc-Andre Lemburg (mal@lemburg.com). - -Copyright (c) Corporation for National Research Initiatives. - - ------------------------------------------------------------------------ */ - -#include "Python.h" - -/* --- Registry ----------------------------------------------------------- */ - -PyDoc_STRVAR(register__doc__, -"register(search_function)\n\ -\n\ -Register a codec search function. Search functions are expected to take\n\ -one argument, the encoding name in all lower case letters, and return\n\ -a tuple of functions (encoder, decoder, stream_reader, stream_writer)."); - -static -PyObject *codecregister(PyObject *self, PyObject *args) -{ - PyObject *search_function; - - if (!PyArg_ParseTuple(args, "O:register", &search_function)) - goto onError; - - if (PyCodec_Register(search_function)) - goto onError; - - Py_INCREF(Py_None); - return Py_None; - - onError: - return NULL; -} - -PyDoc_STRVAR(lookup__doc__, -"lookup(encoding) -> (encoder, decoder, stream_reader, stream_writer)\n\ -\n\ -Looks up a codec tuple in the Python codec registry and returns\n\ -a tuple of functions."); - -static -PyObject *codeclookup(PyObject *self, PyObject *args) -{ - char *encoding; - - if (!PyArg_ParseTuple(args, "s:lookup", &encoding)) - goto onError; - - return _PyCodec_Lookup(encoding); - - onError: - return NULL; -} - -/* --- Helpers ------------------------------------------------------------ */ - -static -PyObject *codec_tuple(PyObject *unicode, - int len) -{ - PyObject *v,*w; - - if (unicode == NULL) - return NULL; - v = PyTuple_New(2); - if (v == NULL) { - Py_DECREF(unicode); - return NULL; - } - PyTuple_SET_ITEM(v,0,unicode); - w = PyInt_FromLong(len); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyTuple_SET_ITEM(v,1,w); - return v; -} - -/* --- String codecs ------------------------------------------------------ */ -static PyObject * -escape_decode(PyObject *self, - PyObject *args) -{ - const char *errors = NULL; - const char *data; - int size; - - if (!PyArg_ParseTuple(args, "s#|z:escape_decode", - &data, &size, &errors)) - return NULL; - return codec_tuple(PyString_DecodeEscape(data, size, errors, 0, NULL), - size); -} - -static PyObject * -escape_encode(PyObject *self, - PyObject *args) -{ - PyObject *str; - const char *errors = NULL; - char *buf; - int len; - - if (!PyArg_ParseTuple(args, "O!|z:escape_encode", - &PyString_Type, &str, &errors)) - return NULL; - - str = PyString_Repr(str, 0); - if (!str) - return NULL; - - /* The string will be quoted. Unquote, similar to unicode-escape. */ - buf = PyString_AS_STRING (str); - len = PyString_GET_SIZE (str); - memmove(buf, buf+1, len-2); - _PyString_Resize(&str, len-2); - - return codec_tuple(str, PyString_Size(str)); -} - -#ifdef Py_USING_UNICODE -/* --- Decoder ------------------------------------------------------------ */ - -static PyObject * -unicode_internal_decode(PyObject *self, - PyObject *args) -{ - PyObject *obj; - const char *errors = NULL; - const char *data; - int size; - - if (!PyArg_ParseTuple(args, "O|z:unicode_internal_decode", - &obj, &errors)) - return NULL; - - if (PyUnicode_Check(obj)) { - Py_INCREF(obj); - return codec_tuple(obj, PyUnicode_GET_SIZE(obj)); - } - else { - if (PyObject_AsReadBuffer(obj, (const void **)&data, &size)) - return NULL; - return codec_tuple(PyUnicode_FromUnicode((Py_UNICODE *)data, - size / sizeof(Py_UNICODE)), - size); - } -} - -static PyObject * -utf_7_decode(PyObject *self, - PyObject *args) -{ - const char *data; - int size; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "t#|z:utf_7_decode", - &data, &size, &errors)) - return NULL; - - return codec_tuple(PyUnicode_DecodeUTF7(data, size, errors), - size); -} - -static PyObject * -utf_8_decode(PyObject *self, - PyObject *args) -{ - const char *data; - int size; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "t#|z:utf_8_decode", - &data, &size, &errors)) - return NULL; - - return codec_tuple(PyUnicode_DecodeUTF8(data, size, errors), - size); -} - -static PyObject * -utf_16_decode(PyObject *self, - PyObject *args) -{ - const char *data; - int size; - const char *errors = NULL; - int byteorder = 0; - - if (!PyArg_ParseTuple(args, "t#|z:utf_16_decode", - &data, &size, &errors)) - return NULL; - return codec_tuple(PyUnicode_DecodeUTF16(data, size, errors, &byteorder), - size); -} - -static PyObject * -utf_16_le_decode(PyObject *self, - PyObject *args) -{ - const char *data; - int size; - const char *errors = NULL; - int byteorder = -1; - - if (!PyArg_ParseTuple(args, "t#|z:utf_16_le_decode", - &data, &size, &errors)) - return NULL; - return codec_tuple(PyUnicode_DecodeUTF16(data, size, errors, &byteorder), - size); -} - -static PyObject * -utf_16_be_decode(PyObject *self, - PyObject *args) -{ - const char *data; - int size; - const char *errors = NULL; - int byteorder = 1; - - if (!PyArg_ParseTuple(args, "t#|z:utf_16_be_decode", - &data, &size, &errors)) - return NULL; - return codec_tuple(PyUnicode_DecodeUTF16(data, size, errors, &byteorder), - size); -} - -/* This non-standard version also provides access to the byteorder - parameter of the builtin UTF-16 codec. - - It returns a tuple (unicode, bytesread, byteorder) with byteorder - being the value in effect at the end of data. - -*/ - -static PyObject * -utf_16_ex_decode(PyObject *self, - PyObject *args) -{ - const char *data; - int size; - const char *errors = NULL; - int byteorder = 0; - PyObject *unicode, *tuple; - - if (!PyArg_ParseTuple(args, "t#|zi:utf_16_ex_decode", - &data, &size, &errors, &byteorder)) - return NULL; - - unicode = PyUnicode_DecodeUTF16(data, size, errors, &byteorder); - if (unicode == NULL) - return NULL; - tuple = Py_BuildValue("Oii", unicode, size, byteorder); - Py_DECREF(unicode); - return tuple; -} - -static PyObject * -unicode_escape_decode(PyObject *self, - PyObject *args) -{ - const char *data; - int size; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "t#|z:unicode_escape_decode", - &data, &size, &errors)) - return NULL; - - return codec_tuple(PyUnicode_DecodeUnicodeEscape(data, size, errors), - size); -} - -static PyObject * -raw_unicode_escape_decode(PyObject *self, - PyObject *args) -{ - const char *data; - int size; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "t#|z:raw_unicode_escape_decode", - &data, &size, &errors)) - return NULL; - - return codec_tuple(PyUnicode_DecodeRawUnicodeEscape(data, size, errors), - size); -} - -static PyObject * -latin_1_decode(PyObject *self, - PyObject *args) -{ - const char *data; - int size; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "t#|z:latin_1_decode", - &data, &size, &errors)) - return NULL; - - return codec_tuple(PyUnicode_DecodeLatin1(data, size, errors), - size); -} - -static PyObject * -ascii_decode(PyObject *self, - PyObject *args) -{ - const char *data; - int size; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "t#|z:ascii_decode", - &data, &size, &errors)) - return NULL; - - return codec_tuple(PyUnicode_DecodeASCII(data, size, errors), - size); -} - -static PyObject * -charmap_decode(PyObject *self, - PyObject *args) -{ - const char *data; - int size; - const char *errors = NULL; - PyObject *mapping = NULL; - - if (!PyArg_ParseTuple(args, "t#|zO:charmap_decode", - &data, &size, &errors, &mapping)) - return NULL; - if (mapping == Py_None) - mapping = NULL; - - return codec_tuple(PyUnicode_DecodeCharmap(data, size, mapping, errors), - size); -} - -#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) - -static PyObject * -mbcs_decode(PyObject *self, - PyObject *args) -{ - const char *data; - int size; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "t#|z:mbcs_decode", - &data, &size, &errors)) - return NULL; - - return codec_tuple(PyUnicode_DecodeMBCS(data, size, errors), - size); -} - -#endif /* MS_WINDOWS */ - -/* --- Encoder ------------------------------------------------------------ */ - -static PyObject * -readbuffer_encode(PyObject *self, - PyObject *args) -{ - const char *data; - int size; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "s#|z:readbuffer_encode", - &data, &size, &errors)) - return NULL; - - return codec_tuple(PyString_FromStringAndSize(data, size), - size); -} - -static PyObject * -charbuffer_encode(PyObject *self, - PyObject *args) -{ - const char *data; - int size; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "t#|z:charbuffer_encode", - &data, &size, &errors)) - return NULL; - - return codec_tuple(PyString_FromStringAndSize(data, size), - size); -} - -static PyObject * -unicode_internal_encode(PyObject *self, - PyObject *args) -{ - PyObject *obj; - const char *errors = NULL; - const char *data; - int size; - - if (!PyArg_ParseTuple(args, "O|z:unicode_internal_encode", - &obj, &errors)) - return NULL; - - if (PyUnicode_Check(obj)) { - data = PyUnicode_AS_DATA(obj); - size = PyUnicode_GET_DATA_SIZE(obj); - return codec_tuple(PyString_FromStringAndSize(data, size), - size); - } - else { - if (PyObject_AsReadBuffer(obj, (const void **)&data, &size)) - return NULL; - return codec_tuple(PyString_FromStringAndSize(data, size), - size); - } -} - -static PyObject * -utf_7_encode(PyObject *self, - PyObject *args) -{ - PyObject *str, *v; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "O|z:utf_7_encode", - &str, &errors)) - return NULL; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return NULL; - v = codec_tuple(PyUnicode_EncodeUTF7(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - 0, - 0, - errors), - PyUnicode_GET_SIZE(str)); - Py_DECREF(str); - return v; -} - -static PyObject * -utf_8_encode(PyObject *self, - PyObject *args) -{ - PyObject *str, *v; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "O|z:utf_8_encode", - &str, &errors)) - return NULL; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return NULL; - v = codec_tuple(PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors), - PyUnicode_GET_SIZE(str)); - Py_DECREF(str); - return v; -} - -/* This version provides access to the byteorder parameter of the - builtin UTF-16 codecs as optional third argument. It defaults to 0 - which means: use the native byte order and prepend the data with a - BOM mark. - -*/ - -static PyObject * -utf_16_encode(PyObject *self, - PyObject *args) -{ - PyObject *str, *v; - const char *errors = NULL; - int byteorder = 0; - - if (!PyArg_ParseTuple(args, "O|zi:utf_16_encode", - &str, &errors, &byteorder)) - return NULL; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return NULL; - v = codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors, - byteorder), - PyUnicode_GET_SIZE(str)); - Py_DECREF(str); - return v; -} - -static PyObject * -utf_16_le_encode(PyObject *self, - PyObject *args) -{ - PyObject *str, *v; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "O|z:utf_16_le_encode", - &str, &errors)) - return NULL; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return NULL; - v = codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors, - -1), - PyUnicode_GET_SIZE(str)); - Py_DECREF(str); - return v; -} - -static PyObject * -utf_16_be_encode(PyObject *self, - PyObject *args) -{ - PyObject *str, *v; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "O|z:utf_16_be_encode", - &str, &errors)) - return NULL; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return NULL; - v = codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors, - +1), - PyUnicode_GET_SIZE(str)); - Py_DECREF(str); - return v; -} - -static PyObject * -unicode_escape_encode(PyObject *self, - PyObject *args) -{ - PyObject *str, *v; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "O|z:unicode_escape_encode", - &str, &errors)) - return NULL; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return NULL; - v = codec_tuple(PyUnicode_EncodeUnicodeEscape(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str)), - PyUnicode_GET_SIZE(str)); - Py_DECREF(str); - return v; -} - -static PyObject * -raw_unicode_escape_encode(PyObject *self, - PyObject *args) -{ - PyObject *str, *v; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "O|z:raw_unicode_escape_encode", - &str, &errors)) - return NULL; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return NULL; - v = codec_tuple(PyUnicode_EncodeRawUnicodeEscape( - PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str)), - PyUnicode_GET_SIZE(str)); - Py_DECREF(str); - return v; -} - -static PyObject * -latin_1_encode(PyObject *self, - PyObject *args) -{ - PyObject *str, *v; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "O|z:latin_1_encode", - &str, &errors)) - return NULL; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return NULL; - v = codec_tuple(PyUnicode_EncodeLatin1( - PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors), - PyUnicode_GET_SIZE(str)); - Py_DECREF(str); - return v; -} - -static PyObject * -ascii_encode(PyObject *self, - PyObject *args) -{ - PyObject *str, *v; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "O|z:ascii_encode", - &str, &errors)) - return NULL; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return NULL; - v = codec_tuple(PyUnicode_EncodeASCII( - PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors), - PyUnicode_GET_SIZE(str)); - Py_DECREF(str); - return v; -} - -static PyObject * -charmap_encode(PyObject *self, - PyObject *args) -{ - PyObject *str, *v; - const char *errors = NULL; - PyObject *mapping = NULL; - - if (!PyArg_ParseTuple(args, "O|zO:charmap_encode", - &str, &errors, &mapping)) - return NULL; - if (mapping == Py_None) - mapping = NULL; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return NULL; - v = codec_tuple(PyUnicode_EncodeCharmap( - PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - mapping, - errors), - PyUnicode_GET_SIZE(str)); - Py_DECREF(str); - return v; -} - -#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) - -static PyObject * -mbcs_encode(PyObject *self, - PyObject *args) -{ - PyObject *str, *v; - const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "O|z:mbcs_encode", - &str, &errors)) - return NULL; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return NULL; - v = codec_tuple(PyUnicode_EncodeMBCS( - PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors), - PyUnicode_GET_SIZE(str)); - Py_DECREF(str); - return v; -} - -#endif /* MS_WINDOWS */ -#endif /* Py_USING_UNICODE */ - -/* --- Error handler registry --------------------------------------------- */ - -PyDoc_STRVAR(register_error__doc__, -"register_error(errors, handler)\n\ -\n\ -Register the specified error handler under the name\n\ -errors. handler must be a callable object, that\n\ -will be called with an exception instance containing\n\ -information about the location of the encoding/decoding\n\ -error and must return a (replacement, new position) tuple."); - -static PyObject *register_error(PyObject *self, PyObject *args) -{ - const char *name; - PyObject *handler; - - if (!PyArg_ParseTuple(args, "sO:register_error", - &name, &handler)) - return NULL; - if (PyCodec_RegisterError(name, handler)) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(lookup_error__doc__, -"lookup_error(errors) -> handler\n\ -\n\ -Return the error handler for the specified error handling name\n\ -or raise a LookupError, if no handler exists under this name."); - -static PyObject *lookup_error(PyObject *self, PyObject *args) -{ - const char *name; - - if (!PyArg_ParseTuple(args, "s:lookup_error", - &name)) - return NULL; - return PyCodec_LookupError(name); -} - -/* --- Module API --------------------------------------------------------- */ - -static PyMethodDef _codecs_functions[] = { - {"register", codecregister, METH_VARARGS, - register__doc__}, - {"lookup", codeclookup, METH_VARARGS, - lookup__doc__}, - {"escape_encode", escape_encode, METH_VARARGS}, - {"escape_decode", escape_decode, METH_VARARGS}, -#ifdef Py_USING_UNICODE - {"utf_8_encode", utf_8_encode, METH_VARARGS}, - {"utf_8_decode", utf_8_decode, METH_VARARGS}, - {"utf_7_encode", utf_7_encode, METH_VARARGS}, - {"utf_7_decode", utf_7_decode, METH_VARARGS}, - {"utf_16_encode", utf_16_encode, METH_VARARGS}, - {"utf_16_le_encode", utf_16_le_encode, METH_VARARGS}, - {"utf_16_be_encode", utf_16_be_encode, METH_VARARGS}, - {"utf_16_decode", utf_16_decode, METH_VARARGS}, - {"utf_16_le_decode", utf_16_le_decode, METH_VARARGS}, - {"utf_16_be_decode", utf_16_be_decode, METH_VARARGS}, - {"utf_16_ex_decode", utf_16_ex_decode, METH_VARARGS}, - {"unicode_escape_encode", unicode_escape_encode, METH_VARARGS}, - {"unicode_escape_decode", unicode_escape_decode, METH_VARARGS}, - {"unicode_internal_encode", unicode_internal_encode, METH_VARARGS}, - {"unicode_internal_decode", unicode_internal_decode, METH_VARARGS}, - {"raw_unicode_escape_encode", raw_unicode_escape_encode, METH_VARARGS}, - {"raw_unicode_escape_decode", raw_unicode_escape_decode, METH_VARARGS}, - {"latin_1_encode", latin_1_encode, METH_VARARGS}, - {"latin_1_decode", latin_1_decode, METH_VARARGS}, - {"ascii_encode", ascii_encode, METH_VARARGS}, - {"ascii_decode", ascii_decode, METH_VARARGS}, - {"charmap_encode", charmap_encode, METH_VARARGS}, - {"charmap_decode", charmap_decode, METH_VARARGS}, - {"readbuffer_encode", readbuffer_encode, METH_VARARGS}, - {"charbuffer_encode", charbuffer_encode, METH_VARARGS}, -#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) - {"mbcs_encode", mbcs_encode, METH_VARARGS}, - {"mbcs_decode", mbcs_decode, METH_VARARGS}, -#endif -#endif /* Py_USING_UNICODE */ - {"register_error", register_error, METH_VARARGS, - register_error__doc__}, - {"lookup_error", lookup_error, METH_VARARGS, - lookup_error__doc__}, - {NULL, NULL} /* sentinel */ -}; - -PyMODINIT_FUNC -init_codecs(void) -{ - Py_InitModule("_codecs", _codecs_functions); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/_csv.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/_csv.c deleted file mode 100644 index 0462ef2e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/_csv.c +++ /dev/null @@ -1,1556 +0,0 @@ -/* csv module */ - -/* - -This module provides the low-level underpinnings of a CSV reading/writing -module. Users should not use this module directly, but import the csv.py -module instead. - -**** For people modifying this code, please note that as of this writing -**** (2003-03-23), it is intended that this code should work with Python -**** 2.2. - -*/ - -#define MODULE_VERSION "1.0" - -#include "Python.h" -#include "structmember.h" - - -/* begin 2.2 compatibility macros */ -#ifndef PyDoc_STRVAR -/* Define macros for inline documentation. */ -#define PyDoc_VAR(name) static char name[] -#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) -#ifdef WITH_DOC_STRINGS -#define PyDoc_STR(str) str -#else -#define PyDoc_STR(str) "" -#endif -#endif /* ifndef PyDoc_STRVAR */ - -#ifndef PyMODINIT_FUNC -# if defined(__cplusplus) -# define PyMODINIT_FUNC extern "C" void -# else /* __cplusplus */ -# define PyMODINIT_FUNC void -# endif /* __cplusplus */ -#endif -/* end 2.2 compatibility macros */ - -static PyObject *error_obj; /* CSV exception */ -static PyObject *dialects; /* Dialect registry */ - -typedef enum { - START_RECORD, START_FIELD, ESCAPED_CHAR, IN_FIELD, - IN_QUOTED_FIELD, ESCAPE_IN_QUOTED_FIELD, QUOTE_IN_QUOTED_FIELD -} ParserState; - -typedef enum { - QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONNUMERIC, QUOTE_NONE -} QuoteStyle; - -typedef struct { - QuoteStyle style; - char *name; -} StyleDesc; - -static StyleDesc quote_styles[] = { - { QUOTE_MINIMAL, "QUOTE_MINIMAL" }, - { QUOTE_ALL, "QUOTE_ALL" }, - { QUOTE_NONNUMERIC, "QUOTE_NONNUMERIC" }, - { QUOTE_NONE, "QUOTE_NONE" }, - { 0 } -}; - -typedef struct { - PyObject_HEAD - - int doublequote; /* is " represented by ""? */ - char delimiter; /* field separator */ - char quotechar; /* quote character */ - char escapechar; /* escape character */ - int skipinitialspace; /* ignore spaces following delimiter? */ - PyObject *lineterminator; /* string to write between records */ - QuoteStyle quoting; /* style of quoting to write */ - - int strict; /* raise exception on bad CSV */ -} DialectObj; - -staticforward PyTypeObject Dialect_Type; - -typedef struct { - PyObject_HEAD - - PyObject *input_iter; /* iterate over this for input lines */ - - DialectObj *dialect; /* parsing dialect */ - - PyObject *fields; /* field list for current record */ - ParserState state; /* current CSV parse state */ - char *field; /* build current field in here */ - int field_size; /* size of allocated buffer */ - int field_len; /* length of current field */ - int had_parse_error; /* did we have a parse error? */ -} ReaderObj; - -staticforward PyTypeObject Reader_Type; - -#define ReaderObject_Check(v) ((v)->ob_type == &Reader_Type) - -typedef struct { - PyObject_HEAD - - PyObject *writeline; /* write output lines to this file */ - - DialectObj *dialect; /* parsing dialect */ - - char *rec; /* buffer for parser.join */ - int rec_size; /* size of allocated record */ - int rec_len; /* length of record */ - int num_fields; /* number of fields in record */ -} WriterObj; - -staticforward PyTypeObject Writer_Type; - -/* - * DIALECT class - */ - -static PyObject * -get_dialect_from_registry(PyObject * name_obj) -{ - PyObject *dialect_obj; - - dialect_obj = PyDict_GetItem(dialects, name_obj); - if (dialect_obj == NULL) - return PyErr_Format(error_obj, "unknown dialect"); - Py_INCREF(dialect_obj); - return dialect_obj; -} - -static int -check_delattr(PyObject *v) -{ - if (v == NULL) { - PyErr_SetString(PyExc_TypeError, - "Cannot delete attribute"); - return -1; - } - return 0; -} - -static PyObject * -get_string(PyObject *str) -{ - Py_XINCREF(str); - return str; -} - -static int -set_string(PyObject **str, PyObject *v) -{ - if (check_delattr(v) < 0) - return -1; - if (!PyString_Check(v) -#ifdef Py_USING_UNICODE -&& !PyUnicode_Check(v) -#endif -) { - PyErr_BadArgument(); - return -1; - } - Py_XDECREF(*str); - Py_INCREF(v); - *str = v; - return 0; -} - -static PyObject * -get_nullchar_as_None(char c) -{ - if (c == '\0') { - Py_INCREF(Py_None); - return Py_None; - } - else - return PyString_FromStringAndSize((char*)&c, 1); -} - -static int -set_None_as_nullchar(char * addr, PyObject *v) -{ - if (check_delattr(v) < 0) - return -1; - if (v == Py_None) - *addr = '\0'; - else if (!PyString_Check(v) || PyString_Size(v) != 1) { - PyErr_BadArgument(); - return -1; - } - else { - char *s = PyString_AsString(v); - if (s == NULL) - return -1; - *addr = s[0]; - } - return 0; -} - -static PyObject * -Dialect_get_lineterminator(DialectObj *self) -{ - return get_string(self->lineterminator); -} - -static int -Dialect_set_lineterminator(DialectObj *self, PyObject *value) -{ - return set_string(&self->lineterminator, value); -} - -static PyObject * -Dialect_get_escapechar(DialectObj *self) -{ - return get_nullchar_as_None(self->escapechar); -} - -static int -Dialect_set_escapechar(DialectObj *self, PyObject *value) -{ - return set_None_as_nullchar(&self->escapechar, value); -} - -static PyObject * -Dialect_get_quoting(DialectObj *self) -{ - return PyInt_FromLong(self->quoting); -} - -static int -Dialect_set_quoting(DialectObj *self, PyObject *v) -{ - int quoting; - StyleDesc *qs = quote_styles; - - if (check_delattr(v) < 0) - return -1; - if (!PyInt_Check(v)) { - PyErr_BadArgument(); - return -1; - } - quoting = PyInt_AsLong(v); - for (qs = quote_styles; qs->name; qs++) { - if (qs->style == quoting) { - self->quoting = quoting; - return 0; - } - } - PyErr_BadArgument(); - return -1; -} - -static struct PyMethodDef Dialect_methods[] = { - { NULL, NULL } -}; - -#define D_OFF(x) offsetof(DialectObj, x) - -static struct PyMemberDef Dialect_memberlist[] = { - { "quotechar", T_CHAR, D_OFF(quotechar) }, - { "delimiter", T_CHAR, D_OFF(delimiter) }, - { "skipinitialspace", T_INT, D_OFF(skipinitialspace) }, - { "doublequote", T_INT, D_OFF(doublequote) }, - { "strict", T_INT, D_OFF(strict) }, - { NULL } -}; - -static PyGetSetDef Dialect_getsetlist[] = { - { "escapechar", (getter)Dialect_get_escapechar, - (setter)Dialect_set_escapechar }, - { "lineterminator", (getter)Dialect_get_lineterminator, - (setter)Dialect_set_lineterminator }, - { "quoting", (getter)Dialect_get_quoting, - (setter)Dialect_set_quoting }, - {NULL}, -}; - -static void -Dialect_dealloc(DialectObj *self) -{ - Py_XDECREF(self->lineterminator); - self->ob_type->tp_free((PyObject *)self); -} - -static int -dialect_init(DialectObj * self, PyObject * args, PyObject * kwargs) -{ - PyObject *dialect = NULL, *name_obj, *value_obj; - - self->quotechar = '"'; - self->delimiter = ','; - self->escapechar = '\0'; - self->skipinitialspace = 0; - Py_XDECREF(self->lineterminator); - self->lineterminator = PyString_FromString("\r\n"); - if (self->lineterminator == NULL) - return -1; - self->quoting = QUOTE_MINIMAL; - self->doublequote = 1; - self->strict = 0; - - if (!PyArg_ParseTuple(args, "|O", &dialect)) - return -1; - Py_XINCREF(dialect); - if (kwargs != NULL) { - PyObject * key = PyString_FromString("dialect"); - PyObject * d; - - d = PyDict_GetItem(kwargs, key); - if (d) { - Py_INCREF(d); - Py_XDECREF(dialect); - PyDict_DelItem(kwargs, key); - dialect = d; - } - Py_DECREF(key); - } - if (dialect != NULL) { - int i; - PyObject * dir_list; - - /* If dialect is a string, look it up in our registry */ - if (PyString_Check(dialect) -#ifdef Py_USING_UNICODE - || PyUnicode_Check(dialect) -#endif - ) { - PyObject * new_dia; - new_dia = get_dialect_from_registry(dialect); - Py_DECREF(dialect); - if (new_dia == NULL) - return -1; - dialect = new_dia; - } - /* A class rather than an instance? Instantiate */ - if (PyObject_TypeCheck(dialect, &PyClass_Type)) { - PyObject * new_dia; - new_dia = PyObject_CallFunction(dialect, ""); - Py_DECREF(dialect); - if (new_dia == NULL) - return -1; - dialect = new_dia; - } - /* Make sure we finally have an instance */ - if (!PyInstance_Check(dialect) || - (dir_list = PyObject_Dir(dialect)) == NULL) { - PyErr_SetString(PyExc_TypeError, - "dialect must be an instance"); - Py_DECREF(dialect); - return -1; - } - /* And extract the attributes */ - for (i = 0; i < PyList_GET_SIZE(dir_list); ++i) { - char *s; - name_obj = PyList_GET_ITEM(dir_list, i); - s = PyString_AsString(name_obj); - if (s == NULL) - return -1; - if (s[0] == '_') - continue; - value_obj = PyObject_GetAttr(dialect, name_obj); - if (value_obj) { - if (PyObject_SetAttr((PyObject *)self, - name_obj, value_obj)) { - Py_DECREF(value_obj); - Py_DECREF(dir_list); - Py_DECREF(dialect); - return -1; - } - Py_DECREF(value_obj); - } - } - Py_DECREF(dir_list); - Py_DECREF(dialect); - } - if (kwargs != NULL) { - int pos = 0; - - while (PyDict_Next(kwargs, &pos, &name_obj, &value_obj)) { - if (PyObject_SetAttr((PyObject *)self, - name_obj, value_obj)) - return -1; - } - } - return 0; -} - -static PyObject * -dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - DialectObj *self; - self = (DialectObj *)type->tp_alloc(type, 0); - if (self != NULL) { - self->lineterminator = NULL; - } - return (PyObject *)self; -} - - -PyDoc_STRVAR(Dialect_Type_doc, -"CSV dialect\n" -"\n" -"The Dialect type records CSV parsing and generation options.\n"); - -static PyTypeObject Dialect_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "_csv.Dialect", /* tp_name */ - sizeof(DialectObj), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)Dialect_dealloc, /* tp_dealloc */ - (printfunc)0, /* tp_print */ - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)0, /* tp_compare */ - (reprfunc)0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - Dialect_Type_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - Dialect_methods, /* tp_methods */ - Dialect_memberlist, /* tp_members */ - Dialect_getsetlist, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)dialect_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - dialect_new, /* tp_new */ - 0, /* tp_free */ -}; - -static void -parse_save_field(ReaderObj *self) -{ - PyObject *field; - - field = PyString_FromStringAndSize(self->field, self->field_len); - if (field != NULL) { - PyList_Append(self->fields, field); - Py_XDECREF(field); - } - self->field_len = 0; -} - -static int -parse_grow_buff(ReaderObj *self) -{ - if (self->field_size == 0) { - self->field_size = 4096; - if (self->field != NULL) - PyMem_Free(self->field); - self->field = PyMem_Malloc(self->field_size); - } - else { - self->field_size *= 2; - self->field = PyMem_Realloc(self->field, self->field_size); - } - if (self->field == NULL) { - PyErr_NoMemory(); - return 0; - } - return 1; -} - -static void -parse_add_char(ReaderObj *self, char c) -{ - if (self->field_len == self->field_size && !parse_grow_buff(self)) - return; - self->field[self->field_len++] = c; -} - -static void -parse_process_char(ReaderObj *self, char c) -{ - DialectObj *dialect = self->dialect; - - switch (self->state) { - case START_RECORD: - /* start of record */ - if (c == '\n') - /* empty line - return [] */ - break; - /* normal character - handle as START_FIELD */ - self->state = START_FIELD; - /* fallthru */ - case START_FIELD: - /* expecting field */ - if (c == '\n') { - /* save empty field - return [fields] */ - parse_save_field(self); - self->state = START_RECORD; - } - else if (c == dialect->quotechar) { - /* start quoted field */ - self->state = IN_QUOTED_FIELD; - } - else if (c == dialect->escapechar) { - /* possible escaped character */ - self->state = ESCAPED_CHAR; - } - else if (c == ' ' && dialect->skipinitialspace) - /* ignore space at start of field */ - ; - else if (c == dialect->delimiter) { - /* save empty field */ - parse_save_field(self); - } - else { - /* begin new unquoted field */ - parse_add_char(self, c); - self->state = IN_FIELD; - } - break; - - case ESCAPED_CHAR: - if (c != dialect->escapechar && - c != dialect->delimiter && - c != dialect->quotechar) - parse_add_char(self, dialect->escapechar); - parse_add_char(self, c); - self->state = IN_FIELD; - break; - - case IN_FIELD: - /* in unquoted field */ - if (c == '\n') { - /* end of line - return [fields] */ - parse_save_field(self); - self->state = START_RECORD; - } - else if (c == dialect->escapechar) { - /* possible escaped character */ - self->state = ESCAPED_CHAR; - } - else if (c == dialect->delimiter) { - /* save field - wait for new field */ - parse_save_field(self); - self->state = START_FIELD; - } - else { - /* normal character - save in field */ - parse_add_char(self, c); - } - break; - - case IN_QUOTED_FIELD: - /* in quoted field */ - if (c == '\n') { - /* end of line - save '\n' in field */ - parse_add_char(self, '\n'); - } - else if (c == dialect->escapechar) { - /* Possible escape character */ - self->state = ESCAPE_IN_QUOTED_FIELD; - } - else if (c == dialect->quotechar) { - if (dialect->doublequote) { - /* doublequote; " represented by "" */ - self->state = QUOTE_IN_QUOTED_FIELD; - } - else { - /* end of quote part of field */ - self->state = IN_FIELD; - } - } - else { - /* normal character - save in field */ - parse_add_char(self, c); - } - break; - - case ESCAPE_IN_QUOTED_FIELD: - if (c != dialect->escapechar && - c != dialect->delimiter && - c != dialect->quotechar) - parse_add_char(self, dialect->escapechar); - parse_add_char(self, c); - self->state = IN_QUOTED_FIELD; - break; - - case QUOTE_IN_QUOTED_FIELD: - /* doublequote - seen a quote in an quoted field */ - if (dialect->quoting != QUOTE_NONE && - c == dialect->quotechar) { - /* save "" as " */ - parse_add_char(self, c); - self->state = IN_QUOTED_FIELD; - } - else if (c == dialect->delimiter) { - /* save field - wait for new field */ - parse_save_field(self); - self->state = START_FIELD; - } - else if (c == '\n') { - /* end of line - return [fields] */ - parse_save_field(self); - self->state = START_RECORD; - } - else if (!dialect->strict) { - parse_add_char(self, c); - self->state = IN_FIELD; - } - else { - /* illegal */ - self->had_parse_error = 1; - PyErr_Format(error_obj, "%c expected after %c", - dialect->delimiter, - dialect->quotechar); - } - break; - - } -} - -/* - * READER - */ -#define R_OFF(x) offsetof(ReaderObj, x) - -static struct PyMemberDef Reader_memberlist[] = { - { "dialect", T_OBJECT, R_OFF(dialect), RO }, - { NULL } -}; - -static PyObject * -Reader_getiter(ReaderObj *self) -{ - Py_INCREF(self); - return (PyObject *)self; -} - -static PyObject * -Reader_iternext(ReaderObj *self) -{ - PyObject *lineobj; - PyObject *fields; - char *line; - - do { - lineobj = PyIter_Next(self->input_iter); - if (lineobj == NULL) { - /* End of input OR exception */ - if (!PyErr_Occurred() && self->field_len != 0) - return PyErr_Format(error_obj, - "newline inside string"); - return NULL; - } - - if (self->had_parse_error) { - if (self->fields) { - Py_XDECREF(self->fields); - } - self->fields = PyList_New(0); - self->field_len = 0; - self->state = START_RECORD; - self->had_parse_error = 0; - } - line = PyString_AsString(lineobj); - - if (line == NULL) { - Py_DECREF(lineobj); - return NULL; - } - if (strlen(line) < (size_t)PyString_GET_SIZE(lineobj)) { - self->had_parse_error = 1; - Py_DECREF(lineobj); - return PyErr_Format(error_obj, - "string with NUL bytes"); - } - - /* Process line of text - send '\n' to processing code to - represent end of line. End of line which is not at end of - string is an error. */ - while (*line) { - char c; - - c = *line++; - if (c == '\r') { - c = *line++; - if (c == '\0') - /* macintosh end of line */ - break; - if (c == '\n') { - c = *line++; - if (c == '\0') - /* DOS end of line */ - break; - } - self->had_parse_error = 1; - Py_DECREF(lineobj); - return PyErr_Format(error_obj, - "newline inside string"); - } - if (c == '\n') { - c = *line++; - if (c == '\0') - /* unix end of line */ - break; - self->had_parse_error = 1; - Py_DECREF(lineobj); - return PyErr_Format(error_obj, - "newline inside string"); - } - parse_process_char(self, c); - if (PyErr_Occurred()) { - Py_DECREF(lineobj); - return NULL; - } - } - parse_process_char(self, '\n'); - Py_DECREF(lineobj); - } while (self->state != START_RECORD); - - fields = self->fields; - self->fields = PyList_New(0); - return fields; -} - -static void -Reader_dealloc(ReaderObj *self) -{ - Py_XDECREF(self->dialect); - Py_XDECREF(self->input_iter); - Py_XDECREF(self->fields); - if (self->field != NULL) - PyMem_Free(self->field); - PyObject_GC_Del(self); -} - -static int -Reader_traverse(ReaderObj *self, visitproc visit, void *arg) -{ - int err; -#define VISIT(SLOT) \ - if (SLOT) { \ - err = visit((PyObject *)(SLOT), arg); \ - if (err) \ - return err; \ - } - VISIT(self->dialect); - VISIT(self->input_iter); - VISIT(self->fields); - return 0; -} - -static int -Reader_clear(ReaderObj *self) -{ - Py_XDECREF(self->dialect); - Py_XDECREF(self->input_iter); - Py_XDECREF(self->fields); - self->dialect = NULL; - self->input_iter = NULL; - self->fields = NULL; - return 0; -} - -PyDoc_STRVAR(Reader_Type_doc, -"CSV reader\n" -"\n" -"Reader objects are responsible for reading and parsing tabular data\n" -"in CSV format.\n" -); - -static struct PyMethodDef Reader_methods[] = { - { NULL, NULL } -}; - -static PyTypeObject Reader_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "_csv.reader", /*tp_name*/ - sizeof(ReaderObj), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)Reader_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - (getattrfunc)0, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ - (reprfunc)0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - Reader_Type_doc, /*tp_doc*/ - (traverseproc)Reader_traverse, /*tp_traverse*/ - (inquiry)Reader_clear, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - (getiterfunc)Reader_getiter, /*tp_iter*/ - (getiterfunc)Reader_iternext, /*tp_iternext*/ - Reader_methods, /*tp_methods*/ - Reader_memberlist, /*tp_members*/ - 0, /*tp_getset*/ - -}; - -static PyObject * -csv_reader(PyObject *module, PyObject *args, PyObject *keyword_args) -{ - PyObject * iterator, * dialect = NULL, *ctor_args; - ReaderObj * self = PyObject_GC_New(ReaderObj, &Reader_Type); - - if (!self) - return NULL; - - self->dialect = NULL; - self->input_iter = self->fields = NULL; - - self->fields = NULL; - self->input_iter = NULL; - self->had_parse_error = 0; - self->field = NULL; - self->field_size = 0; - self->field_len = 0; - self->state = START_RECORD; - - if (!PyArg_ParseTuple(args, "O|O", &iterator, &dialect)) { - Py_DECREF(self); - return NULL; - } - self->input_iter = PyObject_GetIter(iterator); - if (self->input_iter == NULL) { - PyErr_SetString(PyExc_TypeError, - "argument 1 must be an iterator"); - Py_DECREF(self); - return NULL; - } - ctor_args = Py_BuildValue(dialect ? "(O)" : "()", dialect); - if (ctor_args == NULL) { - Py_DECREF(self); - return NULL; - } - self->dialect = (DialectObj *)PyObject_Call((PyObject *)&Dialect_Type, - ctor_args, keyword_args); - Py_DECREF(ctor_args); - if (self->dialect == NULL) { - Py_DECREF(self); - return NULL; - } - self->fields = PyList_New(0); - if (self->fields == NULL) { - Py_DECREF(self); - return NULL; - } - - return (PyObject *)self; -} - -/* - * WRITER - */ -/* ---------------------------------------------------------------- */ -static void -join_reset(WriterObj *self) -{ - self->rec_len = 0; - self->num_fields = 0; -} - -#define MEM_INCR 32768 - -/* Calculate new record length or append field to record. Return new - * record length. - */ -static int -join_append_data(WriterObj *self, char *field, int quote_empty, - int *quoted, int copy_phase) -{ - DialectObj *dialect = self->dialect; - int i, rec_len; - - rec_len = self->rec_len; - - /* If this is not the first field we need a field separator. - */ - if (self->num_fields > 0) { - if (copy_phase) - self->rec[rec_len] = dialect->delimiter; - rec_len++; - } - /* Handle preceding quote. - */ - switch (dialect->quoting) { - case QUOTE_ALL: - *quoted = 1; - if (copy_phase) - self->rec[rec_len] = dialect->quotechar; - rec_len++; - break; - case QUOTE_MINIMAL: - case QUOTE_NONNUMERIC: - /* We only know about quoted in the copy phase. - */ - if (copy_phase && *quoted) { - self->rec[rec_len] = dialect->quotechar; - rec_len++; - } - break; - case QUOTE_NONE: - break; - } - /* Copy/count field data. - */ - for (i = 0;; i++) { - char c = field[i]; - - if (c == '\0') - break; - /* If in doublequote mode we escape quote chars with a - * quote. - */ - if (dialect->quoting != QUOTE_NONE && - c == dialect->quotechar && dialect->doublequote) { - if (copy_phase) - self->rec[rec_len] = dialect->quotechar; - *quoted = 1; - rec_len++; - } - - /* Some special characters need to be escaped. If we have a - * quote character switch to quoted field instead of escaping - * individual characters. - */ - if (!*quoted - && (c == dialect->delimiter || - c == dialect->escapechar || - c == '\n' || c == '\r')) { - if (dialect->quoting != QUOTE_NONE) - *quoted = 1; - else if (dialect->escapechar) { - if (copy_phase) - self->rec[rec_len] = dialect->escapechar; - rec_len++; - } - else { - PyErr_Format(error_obj, - "delimiter must be quoted or escaped"); - return -1; - } - } - /* Copy field character into record buffer. - */ - if (copy_phase) - self->rec[rec_len] = c; - rec_len++; - } - - /* If field is empty check if it needs to be quoted. - */ - if (i == 0 && quote_empty) { - if (dialect->quoting == QUOTE_NONE) { - PyErr_Format(error_obj, - "single empty field record must be quoted"); - return -1; - } else - *quoted = 1; - } - - /* Handle final quote character on field. - */ - if (*quoted) { - if (copy_phase) - self->rec[rec_len] = dialect->quotechar; - else - /* Didn't know about leading quote until we found it - * necessary in field data - compensate for it now. - */ - rec_len++; - rec_len++; - } - - return rec_len; -} - -static int -join_check_rec_size(WriterObj *self, int rec_len) -{ - if (rec_len > self->rec_size) { - if (self->rec_size == 0) { - self->rec_size = (rec_len / MEM_INCR + 1) * MEM_INCR; - if (self->rec != NULL) - PyMem_Free(self->rec); - self->rec = PyMem_Malloc(self->rec_size); - } - else { - char *old_rec = self->rec; - - self->rec_size = (rec_len / MEM_INCR + 1) * MEM_INCR; - self->rec = PyMem_Realloc(self->rec, self->rec_size); - if (self->rec == NULL) - PyMem_Free(old_rec); - } - if (self->rec == NULL) { - PyErr_NoMemory(); - return 0; - } - } - return 1; -} - -static int -join_append(WriterObj *self, char *field, int *quoted, int quote_empty) -{ - int rec_len; - - rec_len = join_append_data(self, field, quote_empty, quoted, 0); - if (rec_len < 0) - return 0; - - /* grow record buffer if necessary */ - if (!join_check_rec_size(self, rec_len)) - return 0; - - self->rec_len = join_append_data(self, field, quote_empty, quoted, 1); - self->num_fields++; - - return 1; -} - -static int -join_append_lineterminator(WriterObj *self) -{ - int terminator_len; - - terminator_len = PyString_Size(self->dialect->lineterminator); - - /* grow record buffer if necessary */ - if (!join_check_rec_size(self, self->rec_len + terminator_len)) - return 0; - - memmove(self->rec + self->rec_len, - /* should not be NULL */ - PyString_AsString(self->dialect->lineterminator), - terminator_len); - self->rec_len += terminator_len; - - return 1; -} - -PyDoc_STRVAR(csv_writerow_doc, -"writerow(sequence)\n" -"\n" -"Construct and write a CSV record from a sequence of fields. Non-string\n" -"elements will be converted to string."); - -static PyObject * -csv_writerow(WriterObj *self, PyObject *seq) -{ - DialectObj *dialect = self->dialect; - int len, i; - - if (!PySequence_Check(seq)) - return PyErr_Format(error_obj, "sequence expected"); - - len = PySequence_Length(seq); - if (len < 0) - return NULL; - - /* Join all fields in internal buffer. - */ - join_reset(self); - for (i = 0; i < len; i++) { - PyObject *field; - int append_ok; - int quoted; - - field = PySequence_GetItem(seq, i); - if (field == NULL) - return NULL; - - quoted = 0; - if (dialect->quoting == QUOTE_NONNUMERIC) { - PyObject *num; - - num = PyNumber_Float(field); - if (num == NULL) { - quoted = 1; - PyErr_Clear(); - } - else { - Py_DECREF(num); - } - } - - if (PyString_Check(field)) { - append_ok = join_append(self, - PyString_AS_STRING(field), - "ed, len == 1); - Py_DECREF(field); - } - else if (field == Py_None) { - append_ok = join_append(self, "", "ed, len == 1); - Py_DECREF(field); - } - else { - PyObject *str; - - str = PyObject_Str(field); - Py_DECREF(field); - if (str == NULL) - return NULL; - - append_ok = join_append(self, PyString_AS_STRING(str), - "ed, len == 1); - Py_DECREF(str); - } - if (!append_ok) - return NULL; - } - - /* Add line terminator. - */ - if (!join_append_lineterminator(self)) - return 0; - - return PyObject_CallFunction(self->writeline, - "(s#)", self->rec, self->rec_len); -} - -PyDoc_STRVAR(csv_writerows_doc, -"writerows(sequence of sequences)\n" -"\n" -"Construct and write a series of sequences to a csv file. Non-string\n" -"elements will be converted to string."); - -static PyObject * -csv_writerows(WriterObj *self, PyObject *seqseq) -{ - PyObject *row_iter, *row_obj, *result; - - row_iter = PyObject_GetIter(seqseq); - if (row_iter == NULL) { - PyErr_SetString(PyExc_TypeError, - "writerows() argument must be iterable"); - return NULL; - } - while ((row_obj = PyIter_Next(row_iter))) { - result = csv_writerow(self, row_obj); - Py_DECREF(row_obj); - if (!result) { - Py_DECREF(row_iter); - return NULL; - } - else - Py_DECREF(result); - } - Py_DECREF(row_iter); - if (PyErr_Occurred()) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static struct PyMethodDef Writer_methods[] = { - { "writerow", (PyCFunction)csv_writerow, METH_O, csv_writerow_doc}, - { "writerows", (PyCFunction)csv_writerows, METH_O, csv_writerows_doc}, - { NULL, NULL } -}; - -#define W_OFF(x) offsetof(WriterObj, x) - -static struct PyMemberDef Writer_memberlist[] = { - { "dialect", T_OBJECT, W_OFF(dialect), RO }, - { NULL } -}; - -static void -Writer_dealloc(WriterObj *self) -{ - Py_XDECREF(self->dialect); - Py_XDECREF(self->writeline); - if (self->rec != NULL) - PyMem_Free(self->rec); - PyObject_GC_Del(self); -} - -static int -Writer_traverse(WriterObj *self, visitproc visit, void *arg) -{ - int err; -#define VISIT(SLOT) \ - if (SLOT) { \ - err = visit((PyObject *)(SLOT), arg); \ - if (err) \ - return err; \ - } - VISIT(self->dialect); - VISIT(self->writeline); - return 0; -} - -static int -Writer_clear(WriterObj *self) -{ - Py_XDECREF(self->dialect); - Py_XDECREF(self->writeline); - self->dialect = NULL; - self->writeline = NULL; - return 0; -} - -PyDoc_STRVAR(Writer_Type_doc, -"CSV writer\n" -"\n" -"Writer objects are responsible for generating tabular data\n" -"in CSV format from sequence input.\n" -); - -static PyTypeObject Writer_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "_csv.writer", /*tp_name*/ - sizeof(WriterObj), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)Writer_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - (getattrfunc)0, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ - (reprfunc)0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - Writer_Type_doc, - (traverseproc)Writer_traverse, /*tp_traverse*/ - (inquiry)Writer_clear, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - (getiterfunc)0, /*tp_iter*/ - (getiterfunc)0, /*tp_iternext*/ - Writer_methods, /*tp_methods*/ - Writer_memberlist, /*tp_members*/ - 0, /*tp_getset*/ -}; - -static PyObject * -csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args) -{ - PyObject * output_file, * dialect = NULL, *ctor_args; - WriterObj * self = PyObject_GC_New(WriterObj, &Writer_Type); - - if (!self) - return NULL; - - self->dialect = NULL; - self->writeline = NULL; - - self->rec = NULL; - self->rec_size = 0; - self->rec_len = 0; - self->num_fields = 0; - - if (!PyArg_ParseTuple(args, "O|O", &output_file, &dialect)) { - Py_DECREF(self); - return NULL; - } - self->writeline = PyObject_GetAttrString(output_file, "write"); - if (self->writeline == NULL || !PyCallable_Check(self->writeline)) { - PyErr_SetString(PyExc_TypeError, - "argument 1 must be an instance with a write method"); - Py_DECREF(self); - return NULL; - } - ctor_args = Py_BuildValue(dialect ? "(O)" : "()", dialect); - if (ctor_args == NULL) { - Py_DECREF(self); - return NULL; - } - self->dialect = (DialectObj *)PyObject_Call((PyObject *)&Dialect_Type, - ctor_args, keyword_args); - Py_DECREF(ctor_args); - if (self->dialect == NULL) { - Py_DECREF(self); - return NULL; - } - return (PyObject *)self; -} - -/* - * DIALECT REGISTRY - */ -static PyObject * -csv_list_dialects(PyObject *module, PyObject *args) -{ - return PyDict_Keys(dialects); -} - -static PyObject * -csv_register_dialect(PyObject *module, PyObject *args) -{ - PyObject *name_obj, *dialect_obj; - - if (!PyArg_ParseTuple(args, "OO", &name_obj, &dialect_obj)) - return NULL; - if (!PyString_Check(name_obj) -#ifdef Py_USING_UNICODE -&& !PyUnicode_Check(name_obj) -#endif -) { - PyErr_SetString(PyExc_TypeError, - "dialect name must be a string or unicode"); - return NULL; - } - Py_INCREF(dialect_obj); - /* A class rather than an instance? Instanciate */ - if (PyObject_TypeCheck(dialect_obj, &PyClass_Type)) { - PyObject * new_dia; - new_dia = PyObject_CallFunction(dialect_obj, ""); - Py_DECREF(dialect_obj); - if (new_dia == NULL) - return NULL; - dialect_obj = new_dia; - } - /* Make sure we finally have an instance */ - if (!PyInstance_Check(dialect_obj)) { - PyErr_SetString(PyExc_TypeError, "dialect must be an instance"); - Py_DECREF(dialect_obj); - return NULL; - } - if (PyObject_SetAttrString(dialect_obj, "_name", name_obj) < 0) { - Py_DECREF(dialect_obj); - return NULL; - } - if (PyDict_SetItem(dialects, name_obj, dialect_obj) < 0) { - Py_DECREF(dialect_obj); - return NULL; - } - Py_DECREF(dialect_obj); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -csv_unregister_dialect(PyObject *module, PyObject *name_obj) -{ - if (PyDict_DelItem(dialects, name_obj) < 0) - return PyErr_Format(error_obj, "unknown dialect"); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -csv_get_dialect(PyObject *module, PyObject *name_obj) -{ - return get_dialect_from_registry(name_obj); -} - -/* - * MODULE - */ - -PyDoc_STRVAR(csv_module_doc, -"CSV parsing and writing.\n" -"\n" -"This module provides classes that assist in the reading and writing\n" -"of Comma Separated Value (CSV) files, and implements the interface\n" -"described by PEP 305. Although many CSV files are simple to parse,\n" -"the format is not formally defined by a stable specification and\n" -"is subtle enough that parsing lines of a CSV file with something\n" -"like line.split(\",\") is bound to fail. The module supports three\n" -"basic APIs: reading, writing, and registration of dialects.\n" -"\n" -"\n" -"DIALECT REGISTRATION:\n" -"\n" -"Readers and writers support a dialect argument, which is a convenient\n" -"handle on a group of settings. When the dialect argument is a string,\n" -"it identifies one of the dialects previously registered with the module.\n" -"If it is a class or instance, the attributes of the argument are used as\n" -"the settings for the reader or writer:\n" -"\n" -" class excel:\n" -" delimiter = ','\n" -" quotechar = '\"'\n" -" escapechar = None\n" -" doublequote = True\n" -" skipinitialspace = False\n" -" lineterminator = '\r\n'\n" -" quoting = QUOTE_MINIMAL\n" -"\n" -"SETTINGS:\n" -"\n" -" * quotechar - specifies a one-character string to use as the \n" -" quoting character. It defaults to '\"'.\n" -" * delimiter - specifies a one-character string to use as the \n" -" field separator. It defaults to ','.\n" -" * skipinitialspace - specifies how to interpret whitespace which\n" -" immediately follows a delimiter. It defaults to False, which\n" -" means that whitespace immediately following a delimiter is part\n" -" of the following field.\n" -" * lineterminator - specifies the character sequence which should \n" -" terminate rows.\n" -" * quoting - controls when quotes should be generated by the writer.\n" -" It can take on any of the following module constants:\n" -"\n" -" csv.QUOTE_MINIMAL means only when required, for example, when a\n" -" field contains either the quotechar or the delimiter\n" -" csv.QUOTE_ALL means that quotes are always placed around fields.\n" -" csv.QUOTE_NONNUMERIC means that quotes are always placed around\n" -" fields which do not parse as integers or floating point\n" -" numbers.\n" -" csv.QUOTE_NONE means that quotes are never placed around fields.\n" -" * escapechar - specifies a one-character string used to escape \n" -" the delimiter when quoting is set to QUOTE_NONE.\n" -" * doublequote - controls the handling of quotes inside fields. When\n" -" True, two consecutive quotes are interpreted as one during read,\n" -" and when writing, each quote character embedded in the data is\n" -" written as two quotes\n"); - -PyDoc_STRVAR(csv_reader_doc, -" csv_reader = reader(iterable [, dialect='excel']\n" -" [optional keyword args])\n" -" for row in csv_reader:\n" -" process(row)\n" -"\n" -"The \"iterable\" argument can be any object that returns a line\n" -"of input for each iteration, such as a file object or a list. The\n" -"optional \"dialect\" parameter is discussed below. The function\n" -"also accepts optional keyword arguments which override settings\n" -"provided by the dialect.\n" -"\n" -"The returned object is an iterator. Each iteration returns a row\n" - "of the CSV file (which can span multiple input lines):\n"); - -PyDoc_STRVAR(csv_writer_doc, -" csv_writer = csv.writer(fileobj [, dialect='excel']\n" -" [optional keyword args])\n" -" for row in csv_writer:\n" -" csv_writer.writerow(row)\n" -"\n" -" [or]\n" -"\n" -" csv_writer = csv.writer(fileobj [, dialect='excel']\n" -" [optional keyword args])\n" -" csv_writer.writerows(rows)\n" -"\n" -"The \"fileobj\" argument can be any object that supports the file API.\n"); - -PyDoc_STRVAR(csv_list_dialects_doc, -"Return a list of all know dialect names.\n" -" names = csv.list_dialects()"); - -PyDoc_STRVAR(csv_get_dialect_doc, -"Return the dialect instance associated with name.\n" -" dialect = csv.get_dialect(name)"); - -PyDoc_STRVAR(csv_register_dialect_doc, -"Create a mapping from a string name to a dialect class.\n" -" dialect = csv.register_dialect(name, dialect)"); - -PyDoc_STRVAR(csv_unregister_dialect_doc, -"Delete the name/dialect mapping associated with a string name.\n" -" csv.unregister_dialect(name)"); - -static struct PyMethodDef csv_methods[] = { - { "reader", (PyCFunction)csv_reader, - METH_VARARGS | METH_KEYWORDS, csv_reader_doc}, - { "writer", (PyCFunction)csv_writer, - METH_VARARGS | METH_KEYWORDS, csv_writer_doc}, - { "list_dialects", (PyCFunction)csv_list_dialects, - METH_NOARGS, csv_list_dialects_doc}, - { "register_dialect", (PyCFunction)csv_register_dialect, - METH_VARARGS, csv_register_dialect_doc}, - { "unregister_dialect", (PyCFunction)csv_unregister_dialect, - METH_O, csv_unregister_dialect_doc}, - { "get_dialect", (PyCFunction)csv_get_dialect, - METH_O, csv_get_dialect_doc}, - { NULL, NULL } -}; - -PyMODINIT_FUNC -init_csv(void) -{ - PyObject *module; - StyleDesc *style; - - if (PyType_Ready(&Dialect_Type) < 0) - return; - - if (PyType_Ready(&Reader_Type) < 0) - return; - - if (PyType_Ready(&Writer_Type) < 0) - return; - - /* Create the module and add the functions */ - module = Py_InitModule3("_csv", csv_methods, csv_module_doc); - if (module == NULL) - return; - - /* Add version to the module. */ - if (PyModule_AddStringConstant(module, "__version__", - MODULE_VERSION) == -1) - return; - - /* Add _dialects dictionary */ - dialects = PyDict_New(); - if (dialects == NULL) - return; - if (PyModule_AddObject(module, "_dialects", dialects)) - return; - - /* Add quote styles into dictionary */ - for (style = quote_styles; style->name; style++) { - if (PyModule_AddIntConstant(module, style->name, - style->style) == -1) - return; - } - - /* Add the Dialect type */ - if (PyModule_AddObject(module, "Dialect", (PyObject *)&Dialect_Type)) - return; - - /* Add the CSV exception object to the module. */ - error_obj = PyErr_NewException("_csv.Error", NULL, NULL); - if (error_obj == NULL) - return; - PyModule_AddObject(module, "Error", error_obj); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/_curses_panel.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/_curses_panel.c deleted file mode 100644 index d665f22b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/_curses_panel.c +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Interface to the ncurses panel library - * - * Original version by Thomas Gellekum - */ - -/* Release Number */ - -static char *PyCursesVersion = "2.1"; - -/* Includes */ - -#include "Python.h" - -#include "py_curses.h" - -#include - -static PyObject *PyCursesError; - - -/* Utility Functions */ - -/* - * Check the return code from a curses function and return None - * or raise an exception as appropriate. - */ - -static PyObject * -PyCursesCheckERR(int code, char *fname) -{ - if (code != ERR) { - Py_INCREF(Py_None); - return Py_None; - } else { - if (fname == NULL) { - PyErr_SetString(PyCursesError, catchall_ERR); - } else { - PyErr_Format(PyCursesError, "%s() returned ERR", fname); - } - return NULL; - } -} - -/***************************************************************************** - The Panel Object -******************************************************************************/ - -/* Definition of the panel object and panel type */ - -typedef struct { - PyObject_HEAD - PANEL *pan; - PyCursesWindowObject *wo; /* for reference counts */ -} PyCursesPanelObject; - -PyTypeObject PyCursesPanel_Type; - -#define PyCursesPanel_Check(v) ((v)->ob_type == &PyCursesPanel_Type) - -/* Some helper functions. The problem is that there's always a window - associated with a panel. To ensure that Python's GC doesn't pull - this window from under our feet we need to keep track of references - to the corresponding window object within Python. We can't use - dupwin(oldwin) to keep a copy of the curses WINDOW because the - contents of oldwin is copied only once; code like - - win = newwin(...) - pan = win.panel() - win.addstr(some_string) - pan.window().addstr(other_string) - - will fail. */ - -/* We keep a linked list of PyCursesPanelObjects, lop. A list should - suffice, I don't expect more than a handful or at most a few - dozens of panel objects within a typical program. */ -typedef struct _list_of_panels { - PyCursesPanelObject *po; - struct _list_of_panels *next; -} list_of_panels; - -/* list anchor */ -static list_of_panels *lop; - -/* Insert a new panel object into lop */ -static int -insert_lop(PyCursesPanelObject *po) -{ - list_of_panels *new; - - if ((new = (list_of_panels *)malloc(sizeof(list_of_panels))) == NULL) { - PyErr_NoMemory(); - return -1; - } - new->po = po; - new->next = lop; - lop = new; - return 0; -} - -/* Remove the panel object from lop */ -static void -remove_lop(PyCursesPanelObject *po) -{ - list_of_panels *temp, *n; - - temp = lop; - if (temp->po == po) { - lop = temp->next; - free(temp); - return; - } - while (temp->next->po != po) { - if (temp->next == NULL) - PyErr_SetString(PyExc_RuntimeError, - "remove_lop: can't find Panel Object"); - temp = temp->next; - } - n = temp->next->next; - free(temp->next); - temp->next = n; - return; -} - -/* Return the panel object that corresponds to pan */ -static PyCursesPanelObject * -find_po(PANEL *pan) -{ - list_of_panels *temp; - for (temp = lop; temp->po->pan != pan; temp = temp->next) - if (temp->next == NULL) return NULL; /* not found!? */ - return temp->po; -} - -/* Function Prototype Macros - They are ugly but very, very useful. ;-) - - X - function name - TYPE - parameter Type - ERGSTR - format string for construction of the return value - PARSESTR - format string for argument parsing */ - -#define Panel_NoArgNoReturnFunction(X) \ -static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \ -{ return PyCursesCheckERR(X(self->pan), # X); } - -#define Panel_NoArgTrueFalseFunction(X) \ -static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \ -{ \ - if (X (self->pan) == FALSE) { Py_INCREF(Py_False); return Py_False; } \ - else { Py_INCREF(Py_True); return Py_True; } } - -#define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \ -static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \ -{ \ - TYPE arg1, arg2; \ - if (!PyArg_ParseTuple(args, PARSESTR, &arg1, &arg2)) return NULL; \ - return PyCursesCheckERR(X(self->pan, arg1, arg2), # X); } - -/* ------------- PANEL routines --------------- */ - -Panel_NoArgNoReturnFunction(bottom_panel) -Panel_NoArgNoReturnFunction(hide_panel) -Panel_NoArgNoReturnFunction(show_panel) -Panel_NoArgNoReturnFunction(top_panel) -Panel_NoArgTrueFalseFunction(panel_hidden) -Panel_TwoArgNoReturnFunction(move_panel, int, "ii;y,x") - -/* Allocation and deallocation of Panel Objects */ - -static PyObject * -PyCursesPanel_New(PANEL *pan, PyCursesWindowObject *wo) -{ - PyCursesPanelObject *po; - - po = PyObject_NEW(PyCursesPanelObject, &PyCursesPanel_Type); - if (po == NULL) return NULL; - po->pan = pan; - po->wo = wo; - Py_INCREF(wo); - if (insert_lop(po) < 0) { - PyObject_DEL(po); - return NULL; - } - return (PyObject *)po; -} - -static void -PyCursesPanel_Dealloc(PyCursesPanelObject *po) -{ - (void)del_panel(po->pan); - Py_DECREF(po->wo); - remove_lop(po); - PyObject_DEL(po); -} - -/* panel_above(NULL) returns the bottom panel in the stack. To get - this behaviour we use curses.panel.bottom_panel(). */ -static PyObject * -PyCursesPanel_above(PyCursesPanelObject *self) -{ - PANEL *pan; - PyCursesPanelObject *po; - - pan = panel_above(self->pan); - - if (pan == NULL) { /* valid output, it means the calling panel - is on top of the stack */ - Py_INCREF(Py_None); - return Py_None; - } - po = find_po(pan); - if (po == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "panel_above: can't find Panel Object"); - return NULL; - } - Py_INCREF(po); - return (PyObject *)po; -} - -/* panel_below(NULL) returns the top panel in the stack. To get - this behaviour we use curses.panel.top_panel(). */ -static PyObject * -PyCursesPanel_below(PyCursesPanelObject *self) -{ - PANEL *pan; - PyCursesPanelObject *po; - - pan = panel_below(self->pan); - - if (pan == NULL) { /* valid output, it means the calling panel - is on the bottom of the stack */ - Py_INCREF(Py_None); - return Py_None; - } - po = find_po(pan); - if (po == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "panel_below: can't find Panel Object"); - return NULL; - } - Py_INCREF(po); - return (PyObject *)po; -} - -static PyObject * -PyCursesPanel_window(PyCursesPanelObject *self) -{ - Py_INCREF(self->wo); - return (PyObject *)self->wo; -} - -static PyObject * -PyCursesPanel_replace_panel(PyCursesPanelObject *self, PyObject *args) -{ - PyCursesPanelObject *po; - PyCursesWindowObject *temp; - int rtn; - - if (PyTuple_Size(args) != 1) { - PyErr_SetString(PyExc_TypeError, "replace requires one argument"); - return NULL; - } - if (!PyArg_ParseTuple(args, "O!;window object", - &PyCursesWindow_Type, &temp)) - return NULL; - - po = find_po(self->pan); - if (po == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "replace_panel: can't find Panel Object"); - return NULL; - } - - rtn = replace_panel(self->pan, temp->win); - if (rtn == ERR) { - PyErr_SetString(PyCursesError, "replace_panel() returned ERR"); - return NULL; - } - Py_DECREF(po->wo); - po->wo = temp; - Py_INCREF(po->wo); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -PyCursesPanel_set_panel_userptr(PyCursesPanelObject *self, PyObject *obj) -{ - Py_INCREF(obj); - return PyCursesCheckERR(set_panel_userptr(self->pan, (void*)obj), - "set_panel_userptr"); -} - -static PyObject * -PyCursesPanel_userptr(PyCursesPanelObject *self) -{ - PyObject *obj; - PyCursesInitialised; - obj = (PyObject *) panel_userptr(self->pan); - Py_INCREF(obj); - return obj; -} - - -/* Module interface */ - -static PyMethodDef PyCursesPanel_Methods[] = { - {"above", (PyCFunction)PyCursesPanel_above, METH_NOARGS}, - {"below", (PyCFunction)PyCursesPanel_below, METH_NOARGS}, - {"bottom", (PyCFunction)PyCursesPanel_bottom_panel, METH_NOARGS}, - {"hidden", (PyCFunction)PyCursesPanel_panel_hidden, METH_NOARGS}, - {"hide", (PyCFunction)PyCursesPanel_hide_panel, METH_NOARGS}, - {"move", (PyCFunction)PyCursesPanel_move_panel, METH_VARARGS}, - {"replace", (PyCFunction)PyCursesPanel_replace_panel, METH_VARARGS}, - {"set_userptr", (PyCFunction)PyCursesPanel_set_panel_userptr, METH_O}, - {"show", (PyCFunction)PyCursesPanel_show_panel, METH_NOARGS}, - {"top", (PyCFunction)PyCursesPanel_top_panel, METH_NOARGS}, - {"userptr", (PyCFunction)PyCursesPanel_userptr, METH_NOARGS}, - {"window", (PyCFunction)PyCursesPanel_window, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -PyCursesPanel_GetAttr(PyCursesPanelObject *self, char *name) -{ - return Py_FindMethod(PyCursesPanel_Methods, (PyObject *)self, name); -} - -/* -------------------------------------------------------*/ - -PyTypeObject PyCursesPanel_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "_curses_panel.curses panel", /*tp_name*/ - sizeof(PyCursesPanelObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)PyCursesPanel_Dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)PyCursesPanel_GetAttr, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ -}; - -/* Wrapper for panel_above(NULL). This function returns the bottom - panel of the stack, so it's renamed to bottom_panel(). - panel.above() *requires* a panel object in the first place which - may be undesirable. */ -static PyObject * -PyCurses_bottom_panel(PyObject *self) -{ - PANEL *pan; - PyCursesPanelObject *po; - - PyCursesInitialised; - - pan = panel_above(NULL); - - if (pan == NULL) { /* valid output, it means - there's no panel at all */ - Py_INCREF(Py_None); - return Py_None; - } - po = find_po(pan); - if (po == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "panel_above: can't find Panel Object"); - return NULL; - } - Py_INCREF(po); - return (PyObject *)po; -} - -static PyObject * -PyCurses_new_panel(PyObject *self, PyObject *args) -{ - PyCursesWindowObject *win; - PANEL *pan; - - if (!PyArg_ParseTuple(args, "O!", &PyCursesWindow_Type, &win)) - return NULL; - pan = new_panel(win->win); - if (pan == NULL) { - PyErr_SetString(PyCursesError, catchall_NULL); - return NULL; - } - return (PyObject *)PyCursesPanel_New(pan, win); -} - - -/* Wrapper for panel_below(NULL). This function returns the top panel - of the stack, so it's renamed to top_panel(). panel.below() - *requires* a panel object in the first place which may be - undesirable. */ -static PyObject * -PyCurses_top_panel(PyObject *self) -{ - PANEL *pan; - PyCursesPanelObject *po; - - PyCursesInitialised; - - pan = panel_below(NULL); - - if (pan == NULL) { /* valid output, it means - there's no panel at all */ - Py_INCREF(Py_None); - return Py_None; - } - po = find_po(pan); - if (po == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "panel_below: can't find Panel Object"); - return NULL; - } - Py_INCREF(po); - return (PyObject *)po; -} - -static PyObject *PyCurses_update_panels(PyObject *self) -{ - PyCursesInitialised; - update_panels(); - Py_INCREF(Py_None); - return Py_None; -} - - -/* List of functions defined in the module */ - -static PyMethodDef PyCurses_methods[] = { - {"bottom_panel", (PyCFunction)PyCurses_bottom_panel, METH_NOARGS}, - {"new_panel", (PyCFunction)PyCurses_new_panel, METH_VARARGS}, - {"top_panel", (PyCFunction)PyCurses_top_panel, METH_NOARGS}, - {"update_panels", (PyCFunction)PyCurses_update_panels, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - -/* Initialization function for the module */ - -PyMODINIT_FUNC -init_curses_panel(void) -{ - PyObject *m, *d, *v; - - /* Initialize object type */ - PyCursesPanel_Type.ob_type = &PyType_Type; - - import_curses(); - - /* Create the module and add the functions */ - m = Py_InitModule("_curses_panel", PyCurses_methods); - d = PyModule_GetDict(m); - - /* For exception _curses_panel.error */ - PyCursesError = PyErr_NewException("_curses_panel.error", NULL, NULL); - PyDict_SetItemString(d, "error", PyCursesError); - - /* Make the version available */ - v = PyString_FromString(PyCursesVersion); - PyDict_SetItemString(d, "version", v); - PyDict_SetItemString(d, "__version__", v); - Py_DECREF(v); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/_cursesmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/_cursesmodule.c deleted file mode 100644 index 0f493462..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/_cursesmodule.c +++ /dev/null @@ -1,2595 +0,0 @@ -/* - * This is a curses module for Python. - * - * Based on prior work by Lance Ellinghaus and Oliver Andrich - * Version 1.2 of this module: Copyright 1994 by Lance Ellinghouse, - * Cathedral City, California Republic, United States of America. - * - * Version 1.5b1, heavily extended for ncurses by Oliver Andrich: - * Copyright 1996,1997 by Oliver Andrich, Koblenz, Germany. - * - * Tidied for Python 1.6, and currently maintained by . - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this source file to use, copy, modify, merge, or publish it - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or in any new file that contains a substantial portion of - * this file. - * - * THE AUTHOR MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF - * THE SOFTWARE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT - * EXPRESS OR IMPLIED WARRANTY. THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE - * AUTHOR BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE, STRICT LIABILITY OR - * ANY OTHER ACTION ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* CVS: $Id: _cursesmodule.c,v 2.71 2002/11/21 14:17:51 mwh Exp $ */ - -/* - -A number of SysV or ncurses functions don't have wrappers yet; if you need -a given function, add it and send a patch. Here's a list of currently -unsupported functions: - - addchnstr addchstr chgat color_set define_key - del_curterm delscreen dupwin inchnstr inchstr innstr keyok - mcprint mvaddchnstr mvaddchstr mvchgat mvcur mvinchnstr - mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwchgat - mvwgetnstr mvwinchnstr mvwinchstr mvwinnstr newterm - resizeterm restartterm ripoffline scr_dump - scr_init scr_restore scr_set scrl set_curterm set_term setterm - tgetent tgetflag tgetnum tgetstr tgoto timeout tputs - use_default_colors vidattr vidputs waddchnstr waddchstr wchgat - wcolor_set winchnstr winchstr winnstr wmouse_trafo wscrl - -Low-priority: - slk_attr slk_attr_off slk_attr_on slk_attr_set slk_attroff - slk_attron slk_attrset slk_clear slk_color slk_init slk_label - slk_noutrefresh slk_refresh slk_restore slk_set slk_touch - -Menu extension (ncurses and probably SYSV): - current_item free_item free_menu item_count item_description - item_index item_init item_name item_opts item_opts_off - item_opts_on item_term item_userptr item_value item_visible - menu_back menu_driver menu_fore menu_format menu_grey - menu_init menu_items menu_mark menu_opts menu_opts_off - menu_opts_on menu_pad menu_pattern menu_request_by_name - menu_request_name menu_spacing menu_sub menu_term menu_userptr - menu_win new_item new_menu pos_menu_cursor post_menu - scale_menu set_current_item set_item_init set_item_opts - set_item_term set_item_userptr set_item_value set_menu_back - set_menu_fore set_menu_format set_menu_grey set_menu_init - set_menu_items set_menu_mark set_menu_opts set_menu_pad - set_menu_pattern set_menu_spacing set_menu_sub set_menu_term - set_menu_userptr set_menu_win set_top_row top_row unpost_menu - -Form extension (ncurses and probably SYSV): - current_field data_ahead data_behind dup_field - dynamic_fieldinfo field_arg field_back field_buffer - field_count field_fore field_index field_info field_init - field_just field_opts field_opts_off field_opts_on field_pad - field_status field_term field_type field_userptr form_driver - form_fields form_init form_opts form_opts_off form_opts_on - form_page form_request_by_name form_request_name form_sub - form_term form_userptr form_win free_field free_form - link_field link_fieldtype move_field new_field new_form - new_page pos_form_cursor post_form scale_form - set_current_field set_field_back set_field_buffer - set_field_fore set_field_init set_field_just set_field_opts - set_field_pad set_field_status set_field_term set_field_type - set_field_userptr set_fieldtype_arg set_fieldtype_choice - set_form_fields set_form_init set_form_opts set_form_page - set_form_sub set_form_term set_form_userptr set_form_win - set_max_field set_new_page unpost_form - - - */ - -/* Release Number */ - -char *PyCursesVersion = "2.2"; - -/* Includes */ - -#include "Python.h" - -#ifdef __osf__ -#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ -#endif - -#ifdef __hpux -#define STRICT_SYSV_CURSES -#endif - -#define CURSES_MODULE -#include "py_curses.h" - -/* These prototypes are in , but including this header - #defines many common symbols (such as "lines") which breaks the - curses module in other ways. So the code will just specify - explicit prototypes here. */ -extern int setupterm(char *,int,int *); -#ifdef __sgi -#include -#endif - -#if !defined(HAVE_NCURSES_H) && (defined(sgi) || defined(__sun) || defined(SCO5)) -#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ -typedef chtype attr_t; /* No attr_t type is available */ -#endif - -#if defined(_AIX) -#define STRICT_SYSV_CURSES -#endif - -/* Definition of exception curses.error */ - -static PyObject *PyCursesError; - -/* Tells whether setupterm() has been called to initialise terminfo. */ -static int initialised_setupterm = FALSE; - -/* Tells whether initscr() has been called to initialise curses. */ -static int initialised = FALSE; - -/* Tells whether start_color() has been called to initialise color usage. */ -static int initialisedcolors = FALSE; - -/* Utility Macros */ -#define PyCursesSetupTermCalled \ - if (initialised_setupterm != TRUE) { \ - PyErr_SetString(PyCursesError, \ - "must call (at least) setupterm() first"); \ - return 0; } - -#define PyCursesInitialised \ - if (initialised != TRUE) { \ - PyErr_SetString(PyCursesError, \ - "must call initscr() first"); \ - return 0; } - -#define PyCursesInitialisedColor \ - if (initialisedcolors != TRUE) { \ - PyErr_SetString(PyCursesError, \ - "must call start_color() first"); \ - return 0; } - -/* Utility Functions */ - -/* - * Check the return code from a curses function and return None - * or raise an exception as appropriate. These are exported using the - * CObject API. - */ - -static PyObject * -PyCursesCheckERR(int code, char *fname) -{ - if (code != ERR) { - Py_INCREF(Py_None); - return Py_None; - } else { - if (fname == NULL) { - PyErr_SetString(PyCursesError, catchall_ERR); - } else { - PyErr_Format(PyCursesError, "%s() returned ERR", fname); - } - return NULL; - } -} - -static int -PyCurses_ConvertToChtype(PyObject *obj, chtype *ch) -{ - if (PyInt_Check(obj)) { - *ch = (chtype) PyInt_AsLong(obj); - } else if(PyString_Check(obj) - && (PyString_Size(obj) == 1)) { - *ch = (chtype) *PyString_AsString(obj); - } else { - return 0; - } - return 1; -} - -/* Function versions of the 3 functions for tested whether curses has been - initialised or not. */ - -static int func_PyCursesSetupTermCalled(void) -{ - PyCursesSetupTermCalled; - return 1; -} - -static int func_PyCursesInitialised(void) -{ - PyCursesInitialised; - return 1; -} - -static int func_PyCursesInitialisedColor(void) -{ - PyCursesInitialisedColor; - return 1; -} - -/***************************************************************************** - The Window Object -******************************************************************************/ - -/* Definition of the window type */ - -PyTypeObject PyCursesWindow_Type; - -/* Function prototype macros for Window object - - X - function name - TYPE - parameter Type - ERGSTR - format string for construction of the return value - PARSESTR - format string for argument parsing - */ - -#define Window_NoArgNoReturnFunction(X) \ -static PyObject *PyCursesWindow_ ## X (PyCursesWindowObject *self, PyObject *args) \ -{ return PyCursesCheckERR(X(self->win), # X); } - -#define Window_NoArgTrueFalseFunction(X) \ -static PyObject * PyCursesWindow_ ## X (PyCursesWindowObject *self) \ -{ \ - if (X (self->win) == FALSE) { Py_INCREF(Py_False); return Py_False; } \ - else { Py_INCREF(Py_True); return Py_True; } } - -#define Window_NoArgNoReturnVoidFunction(X) \ -static PyObject * PyCursesWindow_ ## X (PyCursesWindowObject *self) \ -{ \ - X(self->win); Py_INCREF(Py_None); return Py_None; } - -#define Window_NoArg2TupleReturnFunction(X, TYPE, ERGSTR) \ -static PyObject * PyCursesWindow_ ## X (PyCursesWindowObject *self) \ -{ \ - TYPE arg1, arg2; \ - X(self->win,arg1,arg2); return Py_BuildValue(ERGSTR, arg1, arg2); } - -#define Window_OneArgNoReturnVoidFunction(X, TYPE, PARSESTR) \ -static PyObject * PyCursesWindow_ ## X (PyCursesWindowObject *self, PyObject *args) \ -{ \ - TYPE arg1; \ - if (!PyArg_ParseTuple(args, PARSESTR, &arg1)) return NULL; \ - X(self->win,arg1); Py_INCREF(Py_None); return Py_None; } - -#define Window_OneArgNoReturnFunction(X, TYPE, PARSESTR) \ -static PyObject * PyCursesWindow_ ## X (PyCursesWindowObject *self, PyObject *args) \ -{ \ - TYPE arg1; \ - if (!PyArg_ParseTuple(args,PARSESTR, &arg1)) return NULL; \ - return PyCursesCheckERR(X(self->win, arg1), # X); } - -#define Window_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \ -static PyObject * PyCursesWindow_ ## X (PyCursesWindowObject *self, PyObject *args) \ -{ \ - TYPE arg1, arg2; \ - if (!PyArg_ParseTuple(args,PARSESTR, &arg1, &arg2)) return NULL; \ - return PyCursesCheckERR(X(self->win, arg1, arg2), # X); } - -/* ------------- WINDOW routines --------------- */ - -Window_NoArgNoReturnFunction(untouchwin) -Window_NoArgNoReturnFunction(touchwin) -Window_NoArgNoReturnFunction(redrawwin) -Window_NoArgNoReturnFunction(winsertln) -Window_NoArgNoReturnFunction(werase) -Window_NoArgNoReturnFunction(wdeleteln) - -Window_NoArgTrueFalseFunction(is_wintouched) - -Window_NoArgNoReturnVoidFunction(wsyncup) -Window_NoArgNoReturnVoidFunction(wsyncdown) -Window_NoArgNoReturnVoidFunction(wstandend) -Window_NoArgNoReturnVoidFunction(wstandout) -Window_NoArgNoReturnVoidFunction(wcursyncup) -Window_NoArgNoReturnVoidFunction(wclrtoeol) -Window_NoArgNoReturnVoidFunction(wclrtobot) -Window_NoArgNoReturnVoidFunction(wclear) - -Window_OneArgNoReturnVoidFunction(idcok, int, "i;True(1) or False(0)") -Window_OneArgNoReturnVoidFunction(immedok, int, "i;True(1) or False(0)") -Window_OneArgNoReturnVoidFunction(wtimeout, int, "i;delay") - -Window_NoArg2TupleReturnFunction(getyx, int, "ii") -Window_NoArg2TupleReturnFunction(getbegyx, int, "ii") -Window_NoArg2TupleReturnFunction(getmaxyx, int, "ii") -Window_NoArg2TupleReturnFunction(getparyx, int, "ii") - -Window_OneArgNoReturnFunction(wattron, attr_t, "l;attr") -Window_OneArgNoReturnFunction(wattroff, attr_t, "l;attr") -Window_OneArgNoReturnFunction(wattrset, attr_t, "l;attr") -Window_OneArgNoReturnFunction(clearok, int, "i;True(1) or False(0)") -Window_OneArgNoReturnFunction(idlok, int, "i;True(1) or False(0)") -#if defined(__NetBSD__) -Window_OneArgNoReturnVoidFunction(keypad, int, "i;True(1) or False(0)") -#else -Window_OneArgNoReturnFunction(keypad, int, "i;True(1) or False(0)") -#endif -Window_OneArgNoReturnFunction(leaveok, int, "i;True(1) or False(0)") -#if defined(__NetBSD__) -Window_OneArgNoReturnVoidFunction(nodelay, int, "i;True(1) or False(0)") -#else -Window_OneArgNoReturnFunction(nodelay, int, "i;True(1) or False(0)") -#endif -Window_OneArgNoReturnFunction(notimeout, int, "i;True(1) or False(0)") -Window_OneArgNoReturnFunction(scrollok, int, "i;True(1) or False(0)") -Window_OneArgNoReturnFunction(winsdelln, int, "i;nlines") -Window_OneArgNoReturnFunction(syncok, int, "i;True(1) or False(0)") - -Window_TwoArgNoReturnFunction(mvwin, int, "ii;y,x") -Window_TwoArgNoReturnFunction(mvderwin, int, "ii;y,x") -Window_TwoArgNoReturnFunction(wmove, int, "ii;y,x") -#ifndef STRICT_SYSV_CURSES -Window_TwoArgNoReturnFunction(wresize, int, "ii;lines,columns") -#endif - -/* Allocation and deallocation of Window Objects */ - -static PyObject * -PyCursesWindow_New(WINDOW *win) -{ - PyCursesWindowObject *wo; - - wo = PyObject_NEW(PyCursesWindowObject, &PyCursesWindow_Type); - if (wo == NULL) return NULL; - wo->win = win; - return (PyObject *)wo; -} - -static void -PyCursesWindow_Dealloc(PyCursesWindowObject *wo) -{ - if (wo->win != stdscr) delwin(wo->win); - PyObject_DEL(wo); -} - -/* Addch, Addstr, Addnstr */ - -static PyObject * -PyCursesWindow_AddCh(PyCursesWindowObject *self, PyObject *args) -{ - int rtn, x, y, use_xy = FALSE; - PyObject *temp; - chtype ch = 0; - attr_t attr = A_NORMAL; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O;ch or int", &temp)) - return NULL; - break; - case 2: - if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &attr)) - return NULL; - break; - case 3: - if (!PyArg_ParseTuple(args,"iiO;y,x,ch or int", &y, &x, &temp)) - return NULL; - use_xy = TRUE; - break; - case 4: - if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr", - &y, &x, &temp, &attr)) - return NULL; - use_xy = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, "addch requires 1 to 4 arguments"); - return NULL; - } - - if (!PyCurses_ConvertToChtype(temp, &ch)) { - PyErr_SetString(PyExc_TypeError, "argument 1 or 3 must be a ch or an int"); - return NULL; - } - - if (use_xy == TRUE) - rtn = mvwaddch(self->win,y,x, ch | attr); - else { - rtn = waddch(self->win, ch | attr); - } - return PyCursesCheckERR(rtn, "addch"); -} - -static PyObject * -PyCursesWindow_AddStr(PyCursesWindowObject *self, PyObject *args) -{ - int rtn; - int x, y; - char *str; - attr_t attr = A_NORMAL , attr_old = A_NORMAL; - int use_xy = FALSE, use_attr = FALSE; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args,"s;str", &str)) - return NULL; - break; - case 2: - if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &attr)) - return NULL; - use_attr = TRUE; - break; - case 3: - if (!PyArg_ParseTuple(args,"iis;int,int,str", &y, &x, &str)) - return NULL; - use_xy = TRUE; - break; - case 4: - if (!PyArg_ParseTuple(args,"iisl;int,int,str,attr", &y, &x, &str, &attr)) - return NULL; - use_xy = use_attr = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, "addstr requires 1 to 4 arguments"); - return NULL; - } - - if (use_attr == TRUE) { - attr_old = getattrs(self->win); - wattrset(self->win,attr); - } - if (use_xy == TRUE) - rtn = mvwaddstr(self->win,y,x,str); - else - rtn = waddstr(self->win,str); - if (use_attr == TRUE) - wattrset(self->win,attr_old); - return PyCursesCheckERR(rtn, "addstr"); -} - -static PyObject * -PyCursesWindow_AddNStr(PyCursesWindowObject *self, PyObject *args) -{ - int rtn, x, y, n; - char *str; - attr_t attr = A_NORMAL , attr_old = A_NORMAL; - int use_xy = FALSE, use_attr = FALSE; - - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args,"si;str,n", &str, &n)) - return NULL; - break; - case 3: - if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &attr)) - return NULL; - use_attr = TRUE; - break; - case 4: - if (!PyArg_ParseTuple(args,"iisi;y,x,str,n", &y, &x, &str, &n)) - return NULL; - use_xy = TRUE; - break; - case 5: - if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &attr)) - return NULL; - use_xy = use_attr = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, "addnstr requires 2 to 5 arguments"); - return NULL; - } - - if (use_attr == TRUE) { - attr_old = getattrs(self->win); - wattrset(self->win,attr); - } - if (use_xy == TRUE) - rtn = mvwaddnstr(self->win,y,x,str,n); - else - rtn = waddnstr(self->win,str,n); - if (use_attr == TRUE) - wattrset(self->win,attr_old); - return PyCursesCheckERR(rtn, "addnstr"); -} - -static PyObject * -PyCursesWindow_Bkgd(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *temp; - chtype bkgd; - attr_t attr = A_NORMAL; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O;ch or int", &temp)) - return NULL; - break; - case 2: - if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &attr)) - return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "bkgd requires 1 or 2 arguments"); - return NULL; - } - - if (!PyCurses_ConvertToChtype(temp, &bkgd)) { - PyErr_SetString(PyExc_TypeError, "argument 1 or 3 must be a ch or an int"); - return NULL; - } - - return PyCursesCheckERR(wbkgd(self->win, bkgd | attr), "bkgd"); -} - -static PyObject * -PyCursesWindow_BkgdSet(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *temp; - chtype bkgd; - attr_t attr = A_NORMAL; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O;ch or int", &temp)) - return NULL; - break; - case 2: - if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &attr)) - return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "bkgdset requires 1 or 2 arguments"); - return NULL; - } - - if (!PyCurses_ConvertToChtype(temp, &bkgd)) { - PyErr_SetString(PyExc_TypeError, "argument 1 must be a ch or an int"); - return NULL; - } - - wbkgdset(self->win, bkgd | attr); - return PyCursesCheckERR(0, "bkgdset"); -} - -static PyObject * -PyCursesWindow_Border(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *temp[8]; - chtype ch[8]; - int i; - - /* Clear the array of parameters */ - for(i=0; i<8; i++) { - temp[i] = NULL; - ch[i] = 0; - } - - if (!PyArg_ParseTuple(args,"|OOOOOOOO;ls,rs,ts,bs,tl,tr,bl,br", - &temp[0], &temp[1], &temp[2], &temp[3], - &temp[4], &temp[5], &temp[6], &temp[7])) - return NULL; - - for(i=0; i<8; i++) { - if (temp[i] != NULL && !PyCurses_ConvertToChtype(temp[i], &ch[i])) { - PyErr_Format(PyExc_TypeError, - "argument %i must be a ch or an int", i+1); - return NULL; - } - } - - wborder(self->win, - ch[0], ch[1], ch[2], ch[3], - ch[4], ch[5], ch[6], ch[7]); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -PyCursesWindow_Box(PyCursesWindowObject *self, PyObject *args) -{ - chtype ch1=0,ch2=0; - switch(PyTuple_Size(args)){ - case 0: break; - default: - if (!PyArg_ParseTuple(args,"ll;vertint,horint", &ch1, &ch2)) - return NULL; - } - box(self->win,ch1,ch2); - Py_INCREF(Py_None); - return Py_None; -} - -#if defined(HAVE_NCURSES_H) || defined(MVWDELCH_IS_EXPRESSION) -#define py_mvwdelch mvwdelch -#else -int py_mvwdelch(WINDOW *w, int y, int x) -{ - mvwdelch(w,y,x); - /* On HP/UX, mvwdelch already returns. On other systems, - we may well run into this return statement. */ - return 0; -} -#endif - - -static PyObject * -PyCursesWindow_DelCh(PyCursesWindowObject *self, PyObject *args) -{ - int rtn; - int x, y; - - switch (PyTuple_Size(args)) { - case 0: - rtn = wdelch(self->win); - break; - case 2: - if (!PyArg_ParseTuple(args,"ii;y,x", &y, &x)) - return NULL; - rtn = py_mvwdelch(self->win,y,x); - break; - default: - PyErr_SetString(PyExc_TypeError, "delch requires 0 or 2 arguments"); - return NULL; - } - return PyCursesCheckERR(rtn, "[mv]wdelch"); -} - -static PyObject * -PyCursesWindow_DerWin(PyCursesWindowObject *self, PyObject *args) -{ - WINDOW *win; - int nlines, ncols, begin_y, begin_x; - - nlines = 0; - ncols = 0; - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args,"ii;begin_y,begin_x",&begin_y,&begin_x)) - return NULL; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiii;nlines,ncols,begin_y,begin_x", - &nlines,&ncols,&begin_y,&begin_x)) - return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "derwin requires 2 or 4 arguments"); - return NULL; - } - - win = derwin(self->win,nlines,ncols,begin_y,begin_x); - - if (win == NULL) { - PyErr_SetString(PyCursesError, catchall_NULL); - return NULL; - } - - return (PyObject *)PyCursesWindow_New(win); -} - -static PyObject * -PyCursesWindow_EchoChar(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *temp; - chtype ch; - attr_t attr = A_NORMAL; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args,"O;ch or int", &temp)) - return NULL; - break; - case 2: - if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &attr)) - return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "echochar requires 1 or 2 arguments"); - - - return NULL; - } - - if (!PyCurses_ConvertToChtype(temp, &ch)) { - PyErr_SetString(PyExc_TypeError, "argument 1 must be a ch or an int"); - return NULL; - } - -#ifdef WINDOW_HAS_FLAGS - if (self->win->_flags & _ISPAD) - return PyCursesCheckERR(pechochar(self->win, ch | attr), - "echochar"); - else -#endif - return PyCursesCheckERR(wechochar(self->win, ch | attr), - "echochar"); -} - -#ifdef NCURSES_MOUSE_VERSION -static PyObject * -PyCursesWindow_Enclose(PyCursesWindowObject *self, PyObject *args) -{ - int x, y; - if (!PyArg_ParseTuple(args,"ii;y,x", &y, &x)) - return NULL; - - return PyInt_FromLong( wenclose(self->win,y,x) ); -} -#endif - -static PyObject * -PyCursesWindow_GetBkgd(PyCursesWindowObject *self) -{ - return PyInt_FromLong((long) getbkgd(self->win)); -} - -static PyObject * -PyCursesWindow_GetCh(PyCursesWindowObject *self, PyObject *args) -{ - int x, y; - int rtn; - - switch (PyTuple_Size(args)) { - case 0: - Py_BEGIN_ALLOW_THREADS - rtn = wgetch(self->win); - Py_END_ALLOW_THREADS - break; - case 2: - if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x)) - return NULL; - Py_BEGIN_ALLOW_THREADS - rtn = mvwgetch(self->win,y,x); - Py_END_ALLOW_THREADS - break; - default: - PyErr_SetString(PyExc_TypeError, "getch requires 0 or 2 arguments"); - return NULL; - } - return PyInt_FromLong((long)rtn); -} - -static PyObject * -PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args) -{ - int x, y; - int rtn; - - switch (PyTuple_Size(args)) { - case 0: - Py_BEGIN_ALLOW_THREADS - rtn = wgetch(self->win); - Py_END_ALLOW_THREADS - break; - case 2: - if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x)) - return NULL; - Py_BEGIN_ALLOW_THREADS - rtn = mvwgetch(self->win,y,x); - Py_END_ALLOW_THREADS - break; - default: - PyErr_SetString(PyExc_TypeError, "getkey requires 0 or 2 arguments"); - return NULL; - } - if (rtn == ERR) { - /* getch() returns ERR in nodelay mode */ - PyErr_SetString(PyCursesError, "no input"); - return NULL; - } else if (rtn<=255) - return Py_BuildValue("c", rtn); - else -#if defined(__NetBSD__) - return PyString_FromString(unctrl(rtn)); -#else - return PyString_FromString((char *)keyname(rtn)); -#endif -} - -static PyObject * -PyCursesWindow_GetStr(PyCursesWindowObject *self, PyObject *args) -{ - int x, y, n; - char rtn[1024]; /* This should be big enough.. I hope */ - int rtn2; - - switch (PyTuple_Size(args)) { - case 0: - Py_BEGIN_ALLOW_THREADS - rtn2 = wgetstr(self->win,rtn); - Py_END_ALLOW_THREADS - break; - case 1: - if (!PyArg_ParseTuple(args,"i;n", &n)) - return NULL; - Py_BEGIN_ALLOW_THREADS - rtn2 = wgetnstr(self->win,rtn,n); - Py_END_ALLOW_THREADS - break; - case 2: - if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x)) - return NULL; - Py_BEGIN_ALLOW_THREADS - rtn2 = mvwgetstr(self->win,y,x,rtn); - Py_END_ALLOW_THREADS - break; - case 3: - if (!PyArg_ParseTuple(args,"iii;y,x,n", &y, &x, &n)) - return NULL; -#ifdef STRICT_SYSV_CURSES - /* Untested */ - Py_BEGIN_ALLOW_THREADS - rtn2 = wmove(self->win,y,x)==ERR ? ERR : - wgetnstr(self->win, rtn, n); - Py_END_ALLOW_THREADS -#else - Py_BEGIN_ALLOW_THREADS - rtn2 = mvwgetnstr(self->win, y, x, rtn, n); - Py_END_ALLOW_THREADS -#endif - break; - default: - PyErr_SetString(PyExc_TypeError, "getstr requires 0 to 2 arguments"); - return NULL; - } - if (rtn2 == ERR) - rtn[0] = 0; - return PyString_FromString(rtn); -} - -static PyObject * -PyCursesWindow_Hline(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *temp; - chtype ch; - int n, x, y, code = OK; - attr_t attr = A_NORMAL; - - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args, "Oi;ch or int,n", &temp, &n)) - return NULL; - break; - case 3: - if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &attr)) - return NULL; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOi;y,x,ch or int,n", &y, &x, &temp, &n)) - return NULL; - code = wmove(self->win, y, x); - break; - case 5: - if (!PyArg_ParseTuple(args, "iiOil; y,x,ch or int,n,attr", - &y, &x, &temp, &n, &attr)) - return NULL; - code = wmove(self->win, y, x); - break; - default: - PyErr_SetString(PyExc_TypeError, "hline requires 2 to 5 arguments"); - return NULL; - } - - if (code != ERR) { - if (!PyCurses_ConvertToChtype(temp, &ch)) { - PyErr_SetString(PyExc_TypeError, - "argument 1 or 3 must be a ch or an int"); - return NULL; - } - return PyCursesCheckERR(whline(self->win, ch | attr, n), "hline"); - } else - return PyCursesCheckERR(code, "wmove"); -} - -static PyObject * -PyCursesWindow_InsCh(PyCursesWindowObject *self, PyObject *args) -{ - int rtn, x, y, use_xy = FALSE; - PyObject *temp; - chtype ch = 0; - attr_t attr = A_NORMAL; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O;ch or int", &temp)) - return NULL; - break; - case 2: - if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &attr)) - return NULL; - break; - case 3: - if (!PyArg_ParseTuple(args,"iiO;y,x,ch or int", &y, &x, &temp)) - return NULL; - use_xy = TRUE; - break; - case 4: - if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr", &y, &x, &temp, &attr)) - return NULL; - use_xy = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, "insch requires 1 or 4 arguments"); - return NULL; - } - - if (!PyCurses_ConvertToChtype(temp, &ch)) { - PyErr_SetString(PyExc_TypeError, - "argument 1 or 3 must be a ch or an int"); - return NULL; - } - - if (use_xy == TRUE) - rtn = mvwinsch(self->win,y,x, ch | attr); - else { - rtn = winsch(self->win, ch | attr); - } - return PyCursesCheckERR(rtn, "insch"); -} - -static PyObject * -PyCursesWindow_InCh(PyCursesWindowObject *self, PyObject *args) -{ - int x, y, rtn; - - switch (PyTuple_Size(args)) { - case 0: - rtn = winch(self->win); - break; - case 2: - if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x)) - return NULL; - rtn = mvwinch(self->win,y,x); - break; - default: - PyErr_SetString(PyExc_TypeError, "inch requires 0 or 2 arguments"); - return NULL; - } - return PyInt_FromLong((long) rtn); -} - -static PyObject * -PyCursesWindow_InStr(PyCursesWindowObject *self, PyObject *args) -{ - int x, y, n; - char rtn[1024]; /* This should be big enough.. I hope */ - int rtn2; - - switch (PyTuple_Size(args)) { - case 0: - rtn2 = winstr(self->win,rtn); - break; - case 1: - if (!PyArg_ParseTuple(args,"i;n", &n)) - return NULL; - rtn2 = winnstr(self->win,rtn,n); - break; - case 2: - if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x)) - return NULL; - rtn2 = mvwinstr(self->win,y,x,rtn); - break; - case 3: - if (!PyArg_ParseTuple(args, "iii;y,x,n", &y, &x, &n)) - return NULL; - rtn2 = mvwinnstr(self->win, y, x, rtn, n); - break; - default: - PyErr_SetString(PyExc_TypeError, "instr requires 0 or 3 arguments"); - return NULL; - } - if (rtn2 == ERR) - rtn[0] = 0; - return PyString_FromString(rtn); -} - -static PyObject * -PyCursesWindow_InsStr(PyCursesWindowObject *self, PyObject *args) -{ - int rtn; - int x, y; - char *str; - attr_t attr = A_NORMAL , attr_old = A_NORMAL; - int use_xy = FALSE, use_attr = FALSE; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args,"s;str", &str)) - return NULL; - break; - case 2: - if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &attr)) - return NULL; - use_attr = TRUE; - break; - case 3: - if (!PyArg_ParseTuple(args,"iis;y,x,str", &y, &x, &str)) - return NULL; - use_xy = TRUE; - break; - case 4: - if (!PyArg_ParseTuple(args,"iisl;y,x,str,attr", &y, &x, &str, &attr)) - return NULL; - use_xy = use_attr = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, "insstr requires 1 to 4 arguments"); - return NULL; - } - - if (use_attr == TRUE) { - attr_old = getattrs(self->win); - wattrset(self->win,attr); - } - if (use_xy == TRUE) - rtn = mvwinsstr(self->win,y,x,str); - else - rtn = winsstr(self->win,str); - if (use_attr == TRUE) - wattrset(self->win,attr_old); - return PyCursesCheckERR(rtn, "insstr"); -} - -static PyObject * -PyCursesWindow_InsNStr(PyCursesWindowObject *self, PyObject *args) -{ - int rtn, x, y, n; - char *str; - attr_t attr = A_NORMAL , attr_old = A_NORMAL; - int use_xy = FALSE, use_attr = FALSE; - - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args,"si;str,n", &str, &n)) - return NULL; - break; - case 3: - if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &attr)) - return NULL; - use_attr = TRUE; - break; - case 4: - if (!PyArg_ParseTuple(args,"iisi;y,x,str,n", &y, &x, &str, &n)) - return NULL; - use_xy = TRUE; - break; - case 5: - if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &attr)) - return NULL; - use_xy = use_attr = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, "insnstr requires 2 to 5 arguments"); - return NULL; - } - - if (use_attr == TRUE) { - attr_old = getattrs(self->win); - wattrset(self->win,attr); - } - if (use_xy == TRUE) - rtn = mvwinsnstr(self->win,y,x,str,n); - else - rtn = winsnstr(self->win,str,n); - if (use_attr == TRUE) - wattrset(self->win,attr_old); - return PyCursesCheckERR(rtn, "insnstr"); -} - -static PyObject * -PyCursesWindow_Is_LineTouched(PyCursesWindowObject *self, PyObject *args) -{ - int line, erg; - if (!PyArg_ParseTuple(args,"i;line", &line)) - return NULL; - erg = is_linetouched(self->win, line); - if (erg == ERR) { - PyErr_SetString(PyExc_TypeError, - "is_linetouched: line number outside of boundaries"); - return NULL; - } else - if (erg == FALSE) { - Py_INCREF(Py_False); - return Py_False; - } else { - Py_INCREF(Py_True); - return Py_True; - } -} - -static PyObject * -PyCursesWindow_NoOutRefresh(PyCursesWindowObject *self, PyObject *args) -{ - int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol; - int rtn; - -#ifndef WINDOW_HAS_FLAGS - if (0) { -#else - if (self->win->_flags & _ISPAD) { -#endif - switch(PyTuple_Size(args)) { - case 6: - if (!PyArg_ParseTuple(args, - "iiiiii;" \ - "pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol", - &pminrow, &pmincol, &sminrow, - &smincol, &smaxrow, &smaxcol)) - return NULL; - Py_BEGIN_ALLOW_THREADS - rtn = pnoutrefresh(self->win, - pminrow, pmincol, sminrow, - smincol, smaxrow, smaxcol); - Py_END_ALLOW_THREADS - return PyCursesCheckERR(rtn, "pnoutrefresh"); - default: - PyErr_SetString(PyCursesError, - "noutrefresh() called for a pad " - "requires 6 arguments"); - return NULL; - } - } else { - if (!PyArg_ParseTuple(args, ":noutrefresh")) - return NULL; - - Py_BEGIN_ALLOW_THREADS - rtn = wnoutrefresh(self->win); - Py_END_ALLOW_THREADS - return PyCursesCheckERR(rtn, "wnoutrefresh"); - } -} - -static PyObject * -PyCursesWindow_Overlay(PyCursesWindowObject *self, PyObject *args) -{ - PyCursesWindowObject *temp; - int use_copywin = FALSE; - int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol; - int rtn; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O!;window object", - &PyCursesWindow_Type, &temp)) - return NULL; - break; - case 7: - if (!PyArg_ParseTuple(args, "(O!iiiiii);window object, int, int, int, int, int, int", - &PyCursesWindow_Type, &temp, &sminrow, &smincol, - &dminrow, &dmincol, &dmaxrow, &dmaxcol)) - return NULL; - use_copywin = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, - "overlay requires one or seven arguments"); - return NULL; - } - - if (use_copywin == TRUE) { - rtn = copywin(self->win, temp->win, sminrow, smincol, - dminrow, dmincol, dmaxrow, dmaxcol, TRUE); - return PyCursesCheckERR(rtn, "copywin"); - } - else { - rtn = overlay(self->win, temp->win); - return PyCursesCheckERR(rtn, "overlay"); - } -} - -static PyObject * -PyCursesWindow_Overwrite(PyCursesWindowObject *self, PyObject *args) -{ - PyCursesWindowObject *temp; - int use_copywin = FALSE; - int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol; - int rtn; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O!;window object", - &PyCursesWindow_Type, &temp)) - return NULL; - break; - case 7: - if (!PyArg_ParseTuple(args, "(O!iiiiii);window object, int, int, int, int, int, int", - &PyCursesWindow_Type, &temp, &sminrow, &smincol, - &dminrow, &dmincol, &dmaxrow, &dmaxcol)) - return NULL; - use_copywin = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, - "overwrite requires one or seven arguments"); - return NULL; - } - - if (use_copywin == TRUE) { - rtn = copywin(self->win, temp->win, sminrow, smincol, - dminrow, dmincol, dmaxrow, dmaxcol, FALSE); - return PyCursesCheckERR(rtn, "copywin"); - } - else { - rtn = overwrite(self->win, temp->win); - return PyCursesCheckERR(rtn, "overwrite"); - } -} - -static PyObject * -PyCursesWindow_PutWin(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *temp; - - if (!PyArg_ParseTuple(args, "O;fileobj", &temp)) - return NULL; - if (!PyFile_Check(temp)) { - PyErr_SetString(PyExc_TypeError, "argument must be a file object"); - return NULL; - } - return PyCursesCheckERR(putwin(self->win, PyFile_AsFile(temp)), - "putwin"); -} - -static PyObject * -PyCursesWindow_RedrawLine(PyCursesWindowObject *self, PyObject *args) -{ - int beg, num; - if (!PyArg_ParseTuple(args,"ii;beg,num", &beg, &num)) - return NULL; - return PyCursesCheckERR(wredrawln(self->win,beg,num), "redrawln"); -} - -static PyObject * -PyCursesWindow_Refresh(PyCursesWindowObject *self, PyObject *args) -{ - int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol; - int rtn; - -#ifndef WINDOW_HAS_FLAGS - if (0) { -#else - if (self->win->_flags & _ISPAD) { -#endif - switch(PyTuple_Size(args)) { - case 6: - if (!PyArg_ParseTuple(args, - "iiiiii;" \ - "pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol", - &pminrow, &pmincol, &sminrow, - &smincol, &smaxrow, &smaxcol)) - return NULL; - - Py_BEGIN_ALLOW_THREADS - rtn = prefresh(self->win, - pminrow, pmincol, sminrow, - smincol, smaxrow, smaxcol); - Py_END_ALLOW_THREADS - return PyCursesCheckERR(rtn, "prefresh"); - default: - PyErr_SetString(PyCursesError, - "refresh() for a pad requires 6 arguments"); - return NULL; - } - } else { - if (!PyArg_ParseTuple(args, ":refresh")) - return NULL; - Py_BEGIN_ALLOW_THREADS - rtn = wrefresh(self->win); - Py_END_ALLOW_THREADS - return PyCursesCheckERR(rtn, "prefresh"); - } -} - -static PyObject * -PyCursesWindow_SetScrollRegion(PyCursesWindowObject *self, PyObject *args) -{ - int x, y; - if (!PyArg_ParseTuple(args,"ii;top, bottom",&y,&x)) - return NULL; - return PyCursesCheckERR(wsetscrreg(self->win,y,x), "wsetscrreg"); -} - -static PyObject * -PyCursesWindow_SubWin(PyCursesWindowObject *self, PyObject *args) -{ - WINDOW *win; - int nlines, ncols, begin_y, begin_x; - - nlines = 0; - ncols = 0; - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args,"ii;begin_y,begin_x",&begin_y,&begin_x)) - return NULL; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiii;nlines,ncols,begin_y,begin_x", - &nlines,&ncols,&begin_y,&begin_x)) - return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "subwin requires 2 or 4 arguments"); - return NULL; - } - - /* printf("Subwin: %i %i %i %i \n", nlines, ncols, begin_y, begin_x); */ -#ifdef WINDOW_HAS_FLAGS - if (self->win->_flags & _ISPAD) - win = subpad(self->win, nlines, ncols, begin_y, begin_x); - else -#endif - win = subwin(self->win, nlines, ncols, begin_y, begin_x); - - if (win == NULL) { - PyErr_SetString(PyCursesError, catchall_NULL); - return NULL; - } - - return (PyObject *)PyCursesWindow_New(win); -} - -static PyObject * -PyCursesWindow_Scroll(PyCursesWindowObject *self, PyObject *args) -{ - int nlines; - switch(PyTuple_Size(args)) { - case 0: - return PyCursesCheckERR(scroll(self->win), "scroll"); - case 1: - if (!PyArg_ParseTuple(args, "i;nlines", &nlines)) - return NULL; - return PyCursesCheckERR(wscrl(self->win, nlines), "scroll"); - default: - PyErr_SetString(PyExc_TypeError, "scroll requires 0 or 1 arguments"); - return NULL; - } -} - -static PyObject * -PyCursesWindow_TouchLine(PyCursesWindowObject *self, PyObject *args) -{ - int st, cnt, val; - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args,"ii;start,count",&st,&cnt)) - return NULL; - return PyCursesCheckERR(touchline(self->win,st,cnt), "touchline"); - case 3: - if (!PyArg_ParseTuple(args, "iii;start,count,val", &st, &cnt, &val)) - return NULL; - return PyCursesCheckERR(wtouchln(self->win, st, cnt, val), "touchline"); - default: - PyErr_SetString(PyExc_TypeError, "touchline requires 2 or 3 arguments"); - return NULL; - } -} - -static PyObject * -PyCursesWindow_Vline(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *temp; - chtype ch; - int n, x, y, code = OK; - attr_t attr = A_NORMAL; - - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args, "Oi;ch or int,n", &temp, &n)) - return NULL; - break; - case 3: - if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &attr)) - return NULL; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOi;y,x,ch or int,n", &y, &x, &temp, &n)) - return NULL; - code = wmove(self->win, y, x); - break; - case 5: - if (!PyArg_ParseTuple(args, "iiOil; y,x,ch or int,n,attr", - &y, &x, &temp, &n, &attr)) - return NULL; - code = wmove(self->win, y, x); - break; - default: - PyErr_SetString(PyExc_TypeError, "vline requires 2 to 5 arguments"); - return NULL; - } - - if (code != ERR) { - if (!PyCurses_ConvertToChtype(temp, &ch)) { - PyErr_SetString(PyExc_TypeError, - "argument 1 or 3 must be a ch or an int"); - return NULL; - } - return PyCursesCheckERR(wvline(self->win, ch | attr, n), "vline"); - } else - return PyCursesCheckERR(code, "wmove"); -} - -static PyMethodDef PyCursesWindow_Methods[] = { - {"addch", (PyCFunction)PyCursesWindow_AddCh, METH_VARARGS}, - {"addnstr", (PyCFunction)PyCursesWindow_AddNStr, METH_VARARGS}, - {"addstr", (PyCFunction)PyCursesWindow_AddStr, METH_VARARGS}, - {"attroff", (PyCFunction)PyCursesWindow_wattroff, METH_VARARGS}, - {"attron", (PyCFunction)PyCursesWindow_wattron, METH_VARARGS}, - {"attrset", (PyCFunction)PyCursesWindow_wattrset, METH_VARARGS}, - {"bkgd", (PyCFunction)PyCursesWindow_Bkgd, METH_VARARGS}, - {"bkgdset", (PyCFunction)PyCursesWindow_BkgdSet, METH_VARARGS}, - {"border", (PyCFunction)PyCursesWindow_Border, METH_VARARGS}, - {"box", (PyCFunction)PyCursesWindow_Box, METH_VARARGS}, - {"clear", (PyCFunction)PyCursesWindow_wclear, METH_NOARGS}, - {"clearok", (PyCFunction)PyCursesWindow_clearok, METH_VARARGS}, - {"clrtobot", (PyCFunction)PyCursesWindow_wclrtobot, METH_NOARGS}, - {"clrtoeol", (PyCFunction)PyCursesWindow_wclrtoeol, METH_NOARGS}, - {"cursyncup", (PyCFunction)PyCursesWindow_wcursyncup, METH_NOARGS}, - {"delch", (PyCFunction)PyCursesWindow_DelCh, METH_VARARGS}, - {"deleteln", (PyCFunction)PyCursesWindow_wdeleteln, METH_NOARGS}, - {"derwin", (PyCFunction)PyCursesWindow_DerWin, METH_VARARGS}, - {"echochar", (PyCFunction)PyCursesWindow_EchoChar, METH_VARARGS}, -#ifdef NCURSES_MOUSE_VERSION - {"enclose", (PyCFunction)PyCursesWindow_Enclose, METH_VARARGS}, -#endif - {"erase", (PyCFunction)PyCursesWindow_werase, METH_NOARGS}, - {"getbegyx", (PyCFunction)PyCursesWindow_getbegyx, METH_NOARGS}, - {"getbkgd", (PyCFunction)PyCursesWindow_GetBkgd, METH_NOARGS}, - {"getch", (PyCFunction)PyCursesWindow_GetCh, METH_VARARGS}, - {"getkey", (PyCFunction)PyCursesWindow_GetKey, METH_VARARGS}, - {"getmaxyx", (PyCFunction)PyCursesWindow_getmaxyx, METH_NOARGS}, - {"getparyx", (PyCFunction)PyCursesWindow_getparyx, METH_NOARGS}, - {"getstr", (PyCFunction)PyCursesWindow_GetStr, METH_VARARGS}, - {"getyx", (PyCFunction)PyCursesWindow_getyx, METH_NOARGS}, - {"hline", (PyCFunction)PyCursesWindow_Hline, METH_VARARGS}, - {"idcok", (PyCFunction)PyCursesWindow_idcok, METH_VARARGS}, - {"idlok", (PyCFunction)PyCursesWindow_idlok, METH_VARARGS}, - {"immedok", (PyCFunction)PyCursesWindow_immedok, METH_VARARGS}, - {"inch", (PyCFunction)PyCursesWindow_InCh, METH_VARARGS}, - {"insch", (PyCFunction)PyCursesWindow_InsCh, METH_VARARGS}, - {"insdelln", (PyCFunction)PyCursesWindow_winsdelln, METH_VARARGS}, - {"insertln", (PyCFunction)PyCursesWindow_winsertln, METH_NOARGS}, - {"insnstr", (PyCFunction)PyCursesWindow_InsNStr, METH_VARARGS}, - {"insstr", (PyCFunction)PyCursesWindow_InsStr, METH_VARARGS}, - {"instr", (PyCFunction)PyCursesWindow_InStr, METH_VARARGS}, - {"is_linetouched", (PyCFunction)PyCursesWindow_Is_LineTouched, METH_VARARGS}, - {"is_wintouched", (PyCFunction)PyCursesWindow_is_wintouched, METH_NOARGS}, - {"keypad", (PyCFunction)PyCursesWindow_keypad, METH_VARARGS}, - {"leaveok", (PyCFunction)PyCursesWindow_leaveok, METH_VARARGS}, - {"move", (PyCFunction)PyCursesWindow_wmove, METH_VARARGS}, - {"mvderwin", (PyCFunction)PyCursesWindow_mvderwin, METH_VARARGS}, - {"mvwin", (PyCFunction)PyCursesWindow_mvwin, METH_VARARGS}, - {"nodelay", (PyCFunction)PyCursesWindow_nodelay, METH_VARARGS}, - {"notimeout", (PyCFunction)PyCursesWindow_notimeout, METH_VARARGS}, - {"noutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh, METH_VARARGS}, - /* Backward compatibility alias -- remove in Python 2.3 */ - {"nooutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh, METH_VARARGS}, - {"overlay", (PyCFunction)PyCursesWindow_Overlay, METH_VARARGS}, - {"overwrite", (PyCFunction)PyCursesWindow_Overwrite, - METH_VARARGS}, - {"putwin", (PyCFunction)PyCursesWindow_PutWin, METH_VARARGS}, - {"redrawln", (PyCFunction)PyCursesWindow_RedrawLine}, - {"redrawwin", (PyCFunction)PyCursesWindow_redrawwin, METH_NOARGS}, - {"refresh", (PyCFunction)PyCursesWindow_Refresh, METH_VARARGS}, -#ifndef STRICT_SYSV_CURSES - {"resize", (PyCFunction)PyCursesWindow_wresize, METH_VARARGS}, -#endif - {"scroll", (PyCFunction)PyCursesWindow_Scroll, METH_VARARGS}, - {"scrollok", (PyCFunction)PyCursesWindow_scrollok, METH_VARARGS}, - {"setscrreg", (PyCFunction)PyCursesWindow_SetScrollRegion, METH_VARARGS}, - {"standend", (PyCFunction)PyCursesWindow_wstandend, METH_NOARGS}, - {"standout", (PyCFunction)PyCursesWindow_wstandout, METH_NOARGS}, - {"subpad", (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS}, - {"subwin", (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS}, - {"syncdown", (PyCFunction)PyCursesWindow_wsyncdown, METH_NOARGS}, - {"syncok", (PyCFunction)PyCursesWindow_syncok, METH_VARARGS}, - {"syncup", (PyCFunction)PyCursesWindow_wsyncup, METH_NOARGS}, - {"timeout", (PyCFunction)PyCursesWindow_wtimeout, METH_VARARGS}, - {"touchline", (PyCFunction)PyCursesWindow_TouchLine, METH_VARARGS}, - {"touchwin", (PyCFunction)PyCursesWindow_touchwin, METH_NOARGS}, - {"untouchwin", (PyCFunction)PyCursesWindow_untouchwin, METH_NOARGS}, - {"vline", (PyCFunction)PyCursesWindow_Vline, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -PyCursesWindow_GetAttr(PyCursesWindowObject *self, char *name) -{ - return Py_FindMethod(PyCursesWindow_Methods, (PyObject *)self, name); -} - -/* -------------------------------------------------------*/ - -PyTypeObject PyCursesWindow_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "_curses.curses window", /*tp_name*/ - sizeof(PyCursesWindowObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)PyCursesWindow_Dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)PyCursesWindow_GetAttr, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ -}; - -/********************************************************************* - Global Functions -**********************************************************************/ - -NoArgNoReturnFunction(beep) -NoArgNoReturnFunction(def_prog_mode) -NoArgNoReturnFunction(def_shell_mode) -NoArgNoReturnFunction(doupdate) -NoArgNoReturnFunction(endwin) -NoArgNoReturnFunction(flash) -NoArgNoReturnFunction(nocbreak) -NoArgNoReturnFunction(noecho) -NoArgNoReturnFunction(nonl) -NoArgNoReturnFunction(noraw) -NoArgNoReturnFunction(reset_prog_mode) -NoArgNoReturnFunction(reset_shell_mode) -NoArgNoReturnFunction(resetty) -NoArgNoReturnFunction(savetty) - -NoArgOrFlagNoReturnFunction(cbreak) -NoArgOrFlagNoReturnFunction(echo) -NoArgOrFlagNoReturnFunction(nl) -NoArgOrFlagNoReturnFunction(raw) - -NoArgReturnIntFunction(baudrate) -NoArgReturnIntFunction(termattrs) - -NoArgReturnStringFunction(termname) -NoArgReturnStringFunction(longname) - -NoArgTrueFalseFunction(can_change_color) -NoArgTrueFalseFunction(has_colors) -NoArgTrueFalseFunction(has_ic) -NoArgTrueFalseFunction(has_il) -NoArgTrueFalseFunction(isendwin) -NoArgNoReturnVoidFunction(filter) -NoArgNoReturnVoidFunction(flushinp) -NoArgNoReturnVoidFunction(noqiflush) - -static PyObject * -PyCurses_Color_Content(PyObject *self, PyObject *args) -{ - short color,r,g,b; - - PyCursesInitialised - PyCursesInitialisedColor - - if (!PyArg_ParseTuple(args, "h:color_content", &color)) return NULL; - - if (color_content(color, &r, &g, &b) != ERR) - return Py_BuildValue("(iii)", r, g, b); - else { - PyErr_SetString(PyCursesError, - "Argument 1 was out of range. Check value of COLORS."); - return NULL; - } -} - -static PyObject * -PyCurses_color_pair(PyObject *self, PyObject *args) -{ - int n; - - PyCursesInitialised - PyCursesInitialisedColor - - if (!PyArg_ParseTuple(args, "i:color_pair", &n)) return NULL; - return PyInt_FromLong((long) (n << 8)); -} - -static PyObject * -PyCurses_Curs_Set(PyObject *self, PyObject *args) -{ - int vis,erg; - - PyCursesInitialised - - if (!PyArg_ParseTuple(args, "i:curs_set", &vis)) return NULL; - - erg = curs_set(vis); - if (erg == ERR) return PyCursesCheckERR(erg, "curs_set"); - - return PyInt_FromLong((long) erg); -} - -static PyObject * -PyCurses_Delay_Output(PyObject *self, PyObject *args) -{ - int ms; - - PyCursesInitialised - - if (!PyArg_ParseTuple(args, "i:delay_output", &ms)) return NULL; - - return PyCursesCheckERR(delay_output(ms), "delay_output"); -} - -static PyObject * -PyCurses_EraseChar(PyObject *self) -{ - char ch; - - PyCursesInitialised - - ch = erasechar(); - - return PyString_FromStringAndSize(&ch, 1); -} - -static PyObject * -PyCurses_getsyx(PyObject *self) -{ - int x,y; - - PyCursesInitialised - - getsyx(y, x); - - return Py_BuildValue("(ii)", y, x); -} - -#ifdef NCURSES_MOUSE_VERSION -static PyObject * -PyCurses_GetMouse(PyObject *self) -{ - int rtn; - MEVENT event; - - PyCursesInitialised - - rtn = getmouse( &event ); - if (rtn == ERR) { - PyErr_SetString(PyCursesError, "getmouse() returned ERR"); - return NULL; - } - return Py_BuildValue("(hiiil)", - (short)event.id, - event.x, event.y, event.z, - (long) event.bstate); -} - -static PyObject * -PyCurses_UngetMouse(PyObject *self, PyObject *args) -{ - MEVENT event; - - PyCursesInitialised - if (!PyArg_ParseTuple(args, "(hiiil)", - &event.id, - &event.x, &event.y, &event.z, - (int *) &event.bstate)) - return NULL; - - return PyCursesCheckERR(ungetmouse(&event), "ungetmouse"); -} -#endif - -static PyObject * -PyCurses_GetWin(PyCursesWindowObject *self, PyObject *temp) -{ - WINDOW *win; - - PyCursesInitialised - - if (!PyFile_Check(temp)) { - PyErr_SetString(PyExc_TypeError, "argument must be a file object"); - return NULL; - } - - win = getwin(PyFile_AsFile(temp)); - - if (win == NULL) { - PyErr_SetString(PyCursesError, catchall_NULL); - return NULL; - } - - return PyCursesWindow_New(win); -} - -static PyObject * -PyCurses_HalfDelay(PyObject *self, PyObject *args) -{ - unsigned char tenths; - - PyCursesInitialised - - if (!PyArg_ParseTuple(args, "b:halfdelay", &tenths)) return NULL; - - return PyCursesCheckERR(halfdelay(tenths), "halfdelay"); -} - -#ifndef STRICT_SYSV_CURSES - /* No has_key! */ -static PyObject * PyCurses_has_key(PyObject *self, PyObject *args) -{ - int ch; - - PyCursesInitialised - - if (!PyArg_ParseTuple(args,"i",&ch)) return NULL; - - if (has_key(ch) == FALSE) { - Py_INCREF(Py_False); - return Py_False; - } - Py_INCREF(Py_True); - return Py_True; -} -#endif /* STRICT_SYSV_CURSES */ - -static PyObject * -PyCurses_Init_Color(PyObject *self, PyObject *args) -{ - short color, r, g, b; - - PyCursesInitialised - PyCursesInitialisedColor - - switch(PyTuple_Size(args)) { - case 4: - if (!PyArg_ParseTuple(args, "hhhh;color,r,g,b", &color, &r, &g, &b)) return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "init_color requires 4 arguments"); - return NULL; - } - - return PyCursesCheckERR(init_color(color, r, g, b), "init_color"); -} - -static PyObject * -PyCurses_Init_Pair(PyObject *self, PyObject *args) -{ - short pair, f, b; - - PyCursesInitialised - PyCursesInitialisedColor - - if (PyTuple_Size(args) != 3) { - PyErr_SetString(PyExc_TypeError, "init_pair requires 3 arguments"); - return NULL; - } - - if (!PyArg_ParseTuple(args, "hhh;pair, f, b", &pair, &f, &b)) return NULL; - - return PyCursesCheckERR(init_pair(pair, f, b), "init_pair"); -} - -static PyObject *ModDict; - -static PyObject * -PyCurses_InitScr(PyObject *self) -{ - WINDOW *win; - PyObject *nlines, *cols; - - if (initialised == TRUE) { - wrefresh(stdscr); - return (PyObject *)PyCursesWindow_New(stdscr); - } - - win = initscr(); - - if (win == NULL) { - PyErr_SetString(PyCursesError, catchall_NULL); - return NULL; - } - - initialised = initialised_setupterm = TRUE; - -/* This was moved from initcurses() because it core dumped on SGI, - where they're not defined until you've called initscr() */ -#define SetDictInt(string,ch) \ - PyDict_SetItemString(ModDict,string,PyInt_FromLong((long) (ch))); - - /* Here are some graphic symbols you can use */ - SetDictInt("ACS_ULCORNER", (ACS_ULCORNER)); - SetDictInt("ACS_LLCORNER", (ACS_LLCORNER)); - SetDictInt("ACS_URCORNER", (ACS_URCORNER)); - SetDictInt("ACS_LRCORNER", (ACS_LRCORNER)); - SetDictInt("ACS_LTEE", (ACS_LTEE)); - SetDictInt("ACS_RTEE", (ACS_RTEE)); - SetDictInt("ACS_BTEE", (ACS_BTEE)); - SetDictInt("ACS_TTEE", (ACS_TTEE)); - SetDictInt("ACS_HLINE", (ACS_HLINE)); - SetDictInt("ACS_VLINE", (ACS_VLINE)); - SetDictInt("ACS_PLUS", (ACS_PLUS)); -#if !defined(__hpux) || defined(HAVE_NCURSES_H) - /* On HP/UX 11, these are of type cchar_t, which is not an - integral type. If this is a problem on more platforms, a - configure test should be added to determine whether ACS_S1 - is of integral type. */ - SetDictInt("ACS_S1", (ACS_S1)); - SetDictInt("ACS_S9", (ACS_S9)); - SetDictInt("ACS_DIAMOND", (ACS_DIAMOND)); - SetDictInt("ACS_CKBOARD", (ACS_CKBOARD)); - SetDictInt("ACS_DEGREE", (ACS_DEGREE)); - SetDictInt("ACS_PLMINUS", (ACS_PLMINUS)); - SetDictInt("ACS_BULLET", (ACS_BULLET)); - SetDictInt("ACS_LARROW", (ACS_LARROW)); - SetDictInt("ACS_RARROW", (ACS_RARROW)); - SetDictInt("ACS_DARROW", (ACS_DARROW)); - SetDictInt("ACS_UARROW", (ACS_UARROW)); - SetDictInt("ACS_BOARD", (ACS_BOARD)); - SetDictInt("ACS_LANTERN", (ACS_LANTERN)); - SetDictInt("ACS_BLOCK", (ACS_BLOCK)); -#endif - SetDictInt("ACS_BSSB", (ACS_ULCORNER)); - SetDictInt("ACS_SSBB", (ACS_LLCORNER)); - SetDictInt("ACS_BBSS", (ACS_URCORNER)); - SetDictInt("ACS_SBBS", (ACS_LRCORNER)); - SetDictInt("ACS_SBSS", (ACS_RTEE)); - SetDictInt("ACS_SSSB", (ACS_LTEE)); - SetDictInt("ACS_SSBS", (ACS_BTEE)); - SetDictInt("ACS_BSSS", (ACS_TTEE)); - SetDictInt("ACS_BSBS", (ACS_HLINE)); - SetDictInt("ACS_SBSB", (ACS_VLINE)); - SetDictInt("ACS_SSSS", (ACS_PLUS)); - - /* The following are never available with strict SYSV curses */ -#ifdef ACS_S3 - SetDictInt("ACS_S3", (ACS_S3)); -#endif -#ifdef ACS_S7 - SetDictInt("ACS_S7", (ACS_S7)); -#endif -#ifdef ACS_LEQUAL - SetDictInt("ACS_LEQUAL", (ACS_LEQUAL)); -#endif -#ifdef ACS_GEQUAL - SetDictInt("ACS_GEQUAL", (ACS_GEQUAL)); -#endif -#ifdef ACS_PI - SetDictInt("ACS_PI", (ACS_PI)); -#endif -#ifdef ACS_NEQUAL - SetDictInt("ACS_NEQUAL", (ACS_NEQUAL)); -#endif -#ifdef ACS_STERLING - SetDictInt("ACS_STERLING", (ACS_STERLING)); -#endif - - nlines = PyInt_FromLong((long) LINES); - PyDict_SetItemString(ModDict, "LINES", nlines); - Py_DECREF(nlines); - cols = PyInt_FromLong((long) COLS); - PyDict_SetItemString(ModDict, "COLS", cols); - Py_DECREF(cols); - - return (PyObject *)PyCursesWindow_New(win); -} - -static PyObject * -PyCurses_setupterm(PyObject* self, PyObject *args, PyObject* keywds) -{ - int fd = -1; - int err; - char* termstr = NULL; - - static char *kwlist[] = {"term", "fd", NULL}; - - if (!PyArg_ParseTupleAndKeywords( - args,keywds,"|zi:setupterm",kwlist,&termstr,&fd)) { - return NULL; - } - - if (fd == -1) { - PyObject* sys_stdout; - - sys_stdout = PySys_GetObject("stdout"); - - if (sys_stdout == NULL) { - PyErr_SetString( - PyCursesError, - "lost sys.stdout"); - return NULL; - } - - fd = PyObject_AsFileDescriptor(sys_stdout); - - if (fd == -1) { - return NULL; - } - } - - if (setupterm(termstr,fd,&err) == ERR) { - char* s = "setupterm: unknown error"; - - if (err == 0) { - s = "setupterm: could not find terminal"; - } else if (err == -1) { - s = "setupterm: could not find terminfo database"; - } - - PyErr_SetString(PyCursesError,s); - return NULL; - } - - initialised_setupterm = TRUE; - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -PyCurses_IntrFlush(PyObject *self, PyObject *args) -{ - int ch; - - PyCursesInitialised - - switch(PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args,"i;True(1), False(0)",&ch)) return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "intrflush requires 1 argument"); - return NULL; - } - - return PyCursesCheckERR(intrflush(NULL,ch), "intrflush"); -} - -#if !defined(__NetBSD__) -static PyObject * -PyCurses_KeyName(PyObject *self, PyObject *args) -{ - const char *knp; - int ch; - - PyCursesInitialised - - if (!PyArg_ParseTuple(args,"i",&ch)) return NULL; - - if (ch < 0) { - PyErr_SetString(PyExc_ValueError, "invalid key number"); - return NULL; - } - knp = keyname(ch); - - return PyString_FromString((knp == NULL) ? "" : (char *)knp); -} -#endif - -static PyObject * -PyCurses_KillChar(PyObject *self) -{ - char ch; - - ch = killchar(); - - return PyString_FromStringAndSize(&ch, 1); -} - -static PyObject * -PyCurses_Meta(PyObject *self, PyObject *args) -{ - int ch; - - PyCursesInitialised - - switch(PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args,"i;True(1), False(0)",&ch)) return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "meta requires 1 argument"); - return NULL; - } - - return PyCursesCheckERR(meta(stdscr, ch), "meta"); -} - -#ifdef NCURSES_MOUSE_VERSION -static PyObject * -PyCurses_MouseInterval(PyObject *self, PyObject *args) -{ - int interval; - PyCursesInitialised - - if (!PyArg_ParseTuple(args,"i;interval",&interval)) - return NULL; - return PyCursesCheckERR(mouseinterval(interval), "mouseinterval"); -} - -static PyObject * -PyCurses_MouseMask(PyObject *self, PyObject *args) -{ - int newmask; - mmask_t oldmask, availmask; - - PyCursesInitialised - if (!PyArg_ParseTuple(args,"i;mousemask",&newmask)) - return NULL; - availmask = mousemask(newmask, &oldmask); - return Py_BuildValue("(ll)", (long)availmask, (long)oldmask); -} -#endif - -static PyObject * -PyCurses_Napms(PyObject *self, PyObject *args) -{ - int ms; - - PyCursesInitialised - if (!PyArg_ParseTuple(args, "i;ms", &ms)) return NULL; - - return Py_BuildValue("i", napms(ms)); -} - - -static PyObject * -PyCurses_NewPad(PyObject *self, PyObject *args) -{ - WINDOW *win; - int nlines, ncols; - - PyCursesInitialised - - if (!PyArg_ParseTuple(args,"ii;nlines,ncols",&nlines,&ncols)) return NULL; - - win = newpad(nlines, ncols); - - if (win == NULL) { - PyErr_SetString(PyCursesError, catchall_NULL); - return NULL; - } - - return (PyObject *)PyCursesWindow_New(win); -} - -static PyObject * -PyCurses_NewWindow(PyObject *self, PyObject *args) -{ - WINDOW *win; - int nlines, ncols, begin_y=0, begin_x=0; - - PyCursesInitialised - - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args,"ii;nlines,ncols",&nlines,&ncols)) - return NULL; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiii;nlines,ncols,begin_y,begin_x", - &nlines,&ncols,&begin_y,&begin_x)) - return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "newwin requires 2 or 4 arguments"); - return NULL; - } - - win = newwin(nlines,ncols,begin_y,begin_x); - if (win == NULL) { - PyErr_SetString(PyCursesError, catchall_NULL); - return NULL; - } - - return (PyObject *)PyCursesWindow_New(win); -} - -static PyObject * -PyCurses_Pair_Content(PyObject *self, PyObject *args) -{ - short pair,f,b; - - PyCursesInitialised - PyCursesInitialisedColor - - switch(PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "h;pair", &pair)) return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "pair_content requires 1 argument"); - return NULL; - } - - if (!pair_content(pair, &f, &b)) { - PyErr_SetString(PyCursesError, - "Argument 1 was out of range. (1..COLOR_PAIRS-1)"); - return NULL; - } - - return Py_BuildValue("(ii)", f, b); -} - -static PyObject * -PyCurses_pair_number(PyObject *self, PyObject *args) -{ - int n; - - PyCursesInitialised - PyCursesInitialisedColor - - switch(PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "i;pairvalue", &n)) return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, - "pair_number requires 1 argument"); - return NULL; - } - - return PyInt_FromLong((long) ((n & A_COLOR) >> 8)); -} - -static PyObject * -PyCurses_Putp(PyObject *self, PyObject *args) -{ - char *str; - - if (!PyArg_ParseTuple(args,"s;str", &str)) return NULL; - return PyCursesCheckERR(putp(str), "putp"); -} - -static PyObject * -PyCurses_QiFlush(PyObject *self, PyObject *args) -{ - int flag = 0; - - PyCursesInitialised - - switch(PyTuple_Size(args)) { - case 0: - qiflush(); - Py_INCREF(Py_None); - return Py_None; - case 1: - if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL; - if (flag) qiflush(); - else noqiflush(); - Py_INCREF(Py_None); - return Py_None; - default: - PyErr_SetString(PyExc_TypeError, "qiflush requires 0 or 1 arguments"); - return NULL; - } -} - -static PyObject * -PyCurses_setsyx(PyObject *self, PyObject *args) -{ - int y,x; - - PyCursesInitialised - - if (PyTuple_Size(args)!=2) { - PyErr_SetString(PyExc_TypeError, "setsyx requires 2 arguments"); - return NULL; - } - - if (!PyArg_ParseTuple(args, "ii;y, x", &y, &x)) return NULL; - - setsyx(y,x); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -PyCurses_Start_Color(PyObject *self) -{ - int code; - PyObject *c, *cp; - - PyCursesInitialised - - code = start_color(); - if (code != ERR) { - initialisedcolors = TRUE; - c = PyInt_FromLong((long) COLORS); - PyDict_SetItemString(ModDict, "COLORS", c); - Py_DECREF(c); - cp = PyInt_FromLong((long) COLOR_PAIRS); - PyDict_SetItemString(ModDict, "COLOR_PAIRS", cp); - Py_DECREF(cp); - Py_INCREF(Py_None); - return Py_None; - } else { - PyErr_SetString(PyCursesError, "start_color() returned ERR"); - return NULL; - } -} - -static PyObject * -PyCurses_tigetflag(PyObject *self, PyObject *args) -{ - char *capname; - - PyCursesSetupTermCalled; - - if (!PyArg_ParseTuple(args, "z", &capname)) - return NULL; - - return PyInt_FromLong( (long) tigetflag( capname ) ); -} - -static PyObject * -PyCurses_tigetnum(PyObject *self, PyObject *args) -{ - char *capname; - - PyCursesSetupTermCalled; - - if (!PyArg_ParseTuple(args, "z", &capname)) - return NULL; - - return PyInt_FromLong( (long) tigetnum( capname ) ); -} - -static PyObject * -PyCurses_tigetstr(PyObject *self, PyObject *args) -{ - char *capname; - - PyCursesSetupTermCalled; - - if (!PyArg_ParseTuple(args, "z", &capname)) - return NULL; - - capname = tigetstr( capname ); - if (capname == 0 || capname == (char*) -1) { - Py_INCREF(Py_None); - return Py_None; - } - return PyString_FromString( capname ); -} - -static PyObject * -PyCurses_tparm(PyObject *self, PyObject *args) -{ - char* fmt; - char* result = NULL; - int i1=0,i2=0,i3=0,i4=0,i5=0,i6=0,i7=0,i8=0,i9=0; - - PyCursesSetupTermCalled; - - if (!PyArg_ParseTuple(args, "s|iiiiiiiii:tparm", - &fmt, &i1, &i2, &i3, &i4, - &i5, &i6, &i7, &i8, &i9)) { - return NULL; - } - - result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9); - - return PyString_FromString(result); -} - -static PyObject * -PyCurses_TypeAhead(PyObject *self, PyObject *args) -{ - int fd; - - PyCursesInitialised - - if (!PyArg_ParseTuple(args,"i;fd",&fd)) return NULL; - - PyCursesCheckERR(typeahead( fd ), "typeahead"); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -PyCurses_UnCtrl(PyObject *self, PyObject *args) -{ - PyObject *temp; - chtype ch; - - PyCursesInitialised - - if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL; - - if (PyInt_Check(temp)) - ch = (chtype) PyInt_AsLong(temp); - else if (PyString_Check(temp)) - ch = (chtype) *PyString_AsString(temp); - else { - PyErr_SetString(PyExc_TypeError, "argument must be a ch or an int"); - return NULL; - } - - return PyString_FromString(unctrl(ch)); -} - -static PyObject * -PyCurses_UngetCh(PyObject *self, PyObject *args) -{ - PyObject *temp; - int ch; - - PyCursesInitialised - - if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL; - - if (PyInt_Check(temp)) - ch = (int) PyInt_AsLong(temp); - else if (PyString_Check(temp)) - ch = (int) *PyString_AsString(temp); - else { - PyErr_SetString(PyExc_TypeError, "argument must be a ch or an int"); - return NULL; - } - - return PyCursesCheckERR(ungetch(ch), "ungetch"); -} - -static PyObject * -PyCurses_Use_Env(PyObject *self, PyObject *args) -{ - int flag; - - PyCursesInitialised - - switch(PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args,"i;True(1), False(0)",&flag)) - return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "use_env requires 1 argument"); - return NULL; - } - use_env(flag); - Py_INCREF(Py_None); - return Py_None; -} - -/* List of functions defined in the module */ - -static PyMethodDef PyCurses_methods[] = { - {"baudrate", (PyCFunction)PyCurses_baudrate, METH_NOARGS}, - {"beep", (PyCFunction)PyCurses_beep, METH_NOARGS}, - {"can_change_color", (PyCFunction)PyCurses_can_change_color, METH_NOARGS}, - {"cbreak", (PyCFunction)PyCurses_cbreak, METH_VARARGS}, - {"color_content", (PyCFunction)PyCurses_Color_Content, METH_VARARGS}, - {"color_pair", (PyCFunction)PyCurses_color_pair, METH_VARARGS}, - {"curs_set", (PyCFunction)PyCurses_Curs_Set, METH_VARARGS}, - {"def_prog_mode", (PyCFunction)PyCurses_def_prog_mode, METH_NOARGS}, - {"def_shell_mode", (PyCFunction)PyCurses_def_shell_mode, METH_NOARGS}, - {"delay_output", (PyCFunction)PyCurses_Delay_Output, METH_VARARGS}, - {"doupdate", (PyCFunction)PyCurses_doupdate, METH_NOARGS}, - {"echo", (PyCFunction)PyCurses_echo, METH_VARARGS}, - {"endwin", (PyCFunction)PyCurses_endwin, METH_NOARGS}, - {"erasechar", (PyCFunction)PyCurses_EraseChar, METH_NOARGS}, - {"filter", (PyCFunction)PyCurses_filter, METH_NOARGS}, - {"flash", (PyCFunction)PyCurses_flash, METH_NOARGS}, - {"flushinp", (PyCFunction)PyCurses_flushinp, METH_NOARGS}, -#ifdef NCURSES_MOUSE_VERSION - {"getmouse", (PyCFunction)PyCurses_GetMouse, METH_NOARGS}, - {"ungetmouse", (PyCFunction)PyCurses_UngetMouse, METH_VARARGS}, -#endif - {"getsyx", (PyCFunction)PyCurses_getsyx, METH_NOARGS}, - {"getwin", (PyCFunction)PyCurses_GetWin, METH_O}, - {"has_colors", (PyCFunction)PyCurses_has_colors, METH_NOARGS}, - {"has_ic", (PyCFunction)PyCurses_has_ic, METH_NOARGS}, - {"has_il", (PyCFunction)PyCurses_has_il, METH_NOARGS}, -#ifndef STRICT_SYSV_CURSES - {"has_key", (PyCFunction)PyCurses_has_key, METH_VARARGS}, -#endif - {"halfdelay", (PyCFunction)PyCurses_HalfDelay, METH_VARARGS}, - {"init_color", (PyCFunction)PyCurses_Init_Color, METH_VARARGS}, - {"init_pair", (PyCFunction)PyCurses_Init_Pair, METH_VARARGS}, - {"initscr", (PyCFunction)PyCurses_InitScr, METH_NOARGS}, - {"intrflush", (PyCFunction)PyCurses_IntrFlush, METH_VARARGS}, - {"isendwin", (PyCFunction)PyCurses_isendwin, METH_NOARGS}, -#if !defined(__NetBSD__) - {"keyname", (PyCFunction)PyCurses_KeyName, METH_VARARGS}, -#endif - {"killchar", (PyCFunction)PyCurses_KillChar, METH_NOARGS}, - {"longname", (PyCFunction)PyCurses_longname, METH_NOARGS}, - {"meta", (PyCFunction)PyCurses_Meta, METH_VARARGS}, -#ifdef NCURSES_MOUSE_VERSION - {"mouseinterval", (PyCFunction)PyCurses_MouseInterval, METH_VARARGS}, - {"mousemask", (PyCFunction)PyCurses_MouseMask, METH_VARARGS}, -#endif - {"napms", (PyCFunction)PyCurses_Napms, METH_VARARGS}, - {"newpad", (PyCFunction)PyCurses_NewPad, METH_VARARGS}, - {"newwin", (PyCFunction)PyCurses_NewWindow, METH_VARARGS}, - {"nl", (PyCFunction)PyCurses_nl, METH_VARARGS}, - {"nocbreak", (PyCFunction)PyCurses_nocbreak, METH_NOARGS}, - {"noecho", (PyCFunction)PyCurses_noecho, METH_NOARGS}, - {"nonl", (PyCFunction)PyCurses_nonl, METH_NOARGS}, - {"noqiflush", (PyCFunction)PyCurses_noqiflush, METH_NOARGS}, - {"noraw", (PyCFunction)PyCurses_noraw, METH_NOARGS}, - {"pair_content", (PyCFunction)PyCurses_Pair_Content, METH_VARARGS}, - {"pair_number", (PyCFunction)PyCurses_pair_number, METH_VARARGS}, - {"putp", (PyCFunction)PyCurses_Putp, METH_VARARGS}, - {"qiflush", (PyCFunction)PyCurses_QiFlush, METH_VARARGS}, - {"raw", (PyCFunction)PyCurses_raw, METH_VARARGS}, - {"reset_prog_mode", (PyCFunction)PyCurses_reset_prog_mode, METH_NOARGS}, - {"reset_shell_mode", (PyCFunction)PyCurses_reset_shell_mode, METH_NOARGS}, - {"resetty", (PyCFunction)PyCurses_resetty, METH_NOARGS}, - {"savetty", (PyCFunction)PyCurses_savetty, METH_NOARGS}, - {"setsyx", (PyCFunction)PyCurses_setsyx, METH_VARARGS}, - {"setupterm", (PyCFunction)PyCurses_setupterm, - METH_VARARGS|METH_KEYWORDS}, - {"start_color", (PyCFunction)PyCurses_Start_Color, METH_NOARGS}, - {"termattrs", (PyCFunction)PyCurses_termattrs, METH_NOARGS}, - {"termname", (PyCFunction)PyCurses_termname, METH_NOARGS}, - {"tigetflag", (PyCFunction)PyCurses_tigetflag, METH_VARARGS}, - {"tigetnum", (PyCFunction)PyCurses_tigetnum, METH_VARARGS}, - {"tigetstr", (PyCFunction)PyCurses_tigetstr, METH_VARARGS}, - {"tparm", (PyCFunction)PyCurses_tparm, METH_VARARGS}, - {"typeahead", (PyCFunction)PyCurses_TypeAhead, METH_VARARGS}, - {"unctrl", (PyCFunction)PyCurses_UnCtrl, METH_VARARGS}, - {"ungetch", (PyCFunction)PyCurses_UngetCh, METH_VARARGS}, - {"use_env", (PyCFunction)PyCurses_Use_Env, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - -/* Initialization function for the module */ - -PyMODINIT_FUNC -init_curses(void) -{ - PyObject *m, *d, *v, *c_api_object; - static void *PyCurses_API[PyCurses_API_pointers]; - - /* Initialize object type */ - PyCursesWindow_Type.ob_type = &PyType_Type; - - /* Initialize the C API pointer array */ - PyCurses_API[0] = (void *)&PyCursesWindow_Type; - PyCurses_API[1] = (void *)func_PyCursesSetupTermCalled; - PyCurses_API[2] = (void *)func_PyCursesInitialised; - PyCurses_API[3] = (void *)func_PyCursesInitialisedColor; - - /* Create the module and add the functions */ - m = Py_InitModule("_curses", PyCurses_methods); - - /* Add some symbolic constants to the module */ - d = PyModule_GetDict(m); - ModDict = d; /* For PyCurses_InitScr to use later */ - - /* Add a CObject for the C API */ - c_api_object = PyCObject_FromVoidPtr((void *)PyCurses_API, NULL); - PyDict_SetItemString(d, "_C_API", c_api_object); - Py_DECREF(c_api_object); - - /* For exception curses.error */ - PyCursesError = PyErr_NewException("_curses.error", NULL, NULL); - PyDict_SetItemString(d, "error", PyCursesError); - - /* Make the version available */ - v = PyString_FromString(PyCursesVersion); - PyDict_SetItemString(d, "version", v); - PyDict_SetItemString(d, "__version__", v); - Py_DECREF(v); - - SetDictInt("ERR", ERR); - SetDictInt("OK", OK); - - /* Here are some attributes you can add to chars to print */ - - SetDictInt("A_ATTRIBUTES", A_ATTRIBUTES); - SetDictInt("A_NORMAL", A_NORMAL); - SetDictInt("A_STANDOUT", A_STANDOUT); - SetDictInt("A_UNDERLINE", A_UNDERLINE); - SetDictInt("A_REVERSE", A_REVERSE); - SetDictInt("A_BLINK", A_BLINK); - SetDictInt("A_DIM", A_DIM); - SetDictInt("A_BOLD", A_BOLD); - SetDictInt("A_ALTCHARSET", A_ALTCHARSET); -#if !defined(__NetBSD__) - SetDictInt("A_INVIS", A_INVIS); -#endif - SetDictInt("A_PROTECT", A_PROTECT); - SetDictInt("A_CHARTEXT", A_CHARTEXT); - SetDictInt("A_COLOR", A_COLOR); - - /* The following are never available with strict SYSV curses */ -#ifdef A_HORIZONTAL - SetDictInt("A_HORIZONTAL", A_HORIZONTAL); -#endif -#ifdef A_LEFT - SetDictInt("A_LEFT", A_LEFT); -#endif -#ifdef A_LOW - SetDictInt("A_LOW", A_LOW); -#endif -#ifdef A_RIGHT - SetDictInt("A_RIGHT", A_RIGHT); -#endif -#ifdef A_TOP - SetDictInt("A_TOP", A_TOP); -#endif -#ifdef A_VERTICAL - SetDictInt("A_VERTICAL", A_VERTICAL); -#endif - - SetDictInt("COLOR_BLACK", COLOR_BLACK); - SetDictInt("COLOR_RED", COLOR_RED); - SetDictInt("COLOR_GREEN", COLOR_GREEN); - SetDictInt("COLOR_YELLOW", COLOR_YELLOW); - SetDictInt("COLOR_BLUE", COLOR_BLUE); - SetDictInt("COLOR_MAGENTA", COLOR_MAGENTA); - SetDictInt("COLOR_CYAN", COLOR_CYAN); - SetDictInt("COLOR_WHITE", COLOR_WHITE); - -#ifdef NCURSES_MOUSE_VERSION - /* Mouse-related constants */ - SetDictInt("BUTTON1_PRESSED", BUTTON1_PRESSED); - SetDictInt("BUTTON1_RELEASED", BUTTON1_RELEASED); - SetDictInt("BUTTON1_CLICKED", BUTTON1_CLICKED); - SetDictInt("BUTTON1_DOUBLE_CLICKED", BUTTON1_DOUBLE_CLICKED); - SetDictInt("BUTTON1_TRIPLE_CLICKED", BUTTON1_TRIPLE_CLICKED); - - SetDictInt("BUTTON2_PRESSED", BUTTON2_PRESSED); - SetDictInt("BUTTON2_RELEASED", BUTTON2_RELEASED); - SetDictInt("BUTTON2_CLICKED", BUTTON2_CLICKED); - SetDictInt("BUTTON2_DOUBLE_CLICKED", BUTTON2_DOUBLE_CLICKED); - SetDictInt("BUTTON2_TRIPLE_CLICKED", BUTTON2_TRIPLE_CLICKED); - - SetDictInt("BUTTON3_PRESSED", BUTTON3_PRESSED); - SetDictInt("BUTTON3_RELEASED", BUTTON3_RELEASED); - SetDictInt("BUTTON3_CLICKED", BUTTON3_CLICKED); - SetDictInt("BUTTON3_DOUBLE_CLICKED", BUTTON3_DOUBLE_CLICKED); - SetDictInt("BUTTON3_TRIPLE_CLICKED", BUTTON3_TRIPLE_CLICKED); - - SetDictInt("BUTTON4_PRESSED", BUTTON4_PRESSED); - SetDictInt("BUTTON4_RELEASED", BUTTON4_RELEASED); - SetDictInt("BUTTON4_CLICKED", BUTTON4_CLICKED); - SetDictInt("BUTTON4_DOUBLE_CLICKED", BUTTON4_DOUBLE_CLICKED); - SetDictInt("BUTTON4_TRIPLE_CLICKED", BUTTON4_TRIPLE_CLICKED); - - SetDictInt("BUTTON_SHIFT", BUTTON_SHIFT); - SetDictInt("BUTTON_CTRL", BUTTON_CTRL); - SetDictInt("BUTTON_ALT", BUTTON_ALT); - - SetDictInt("ALL_MOUSE_EVENTS", ALL_MOUSE_EVENTS); - SetDictInt("REPORT_MOUSE_POSITION", REPORT_MOUSE_POSITION); -#endif - /* Now set everything up for KEY_ variables */ - { - int key; - char *key_n; - char *key_n2; -#if !defined(__NetBSD__) - for (key=KEY_MIN;key < KEY_MAX; key++) { - key_n = (char *)keyname(key); - if (key_n == NULL || strcmp(key_n,"UNKNOWN KEY")==0) - continue; - if (strncmp(key_n,"KEY_F(",6)==0) { - char *p1, *p2; - key_n2 = malloc(strlen(key_n)+1); - p1 = key_n; - p2 = key_n2; - while (*p1) { - if (*p1 != '(' && *p1 != ')') { - *p2 = *p1; - p2++; - } - p1++; - } - *p2 = (char)0; - } else - key_n2 = key_n; - PyDict_SetItemString(d,key_n2,PyInt_FromLong((long) key)); - if (key_n2 != key_n) - free(key_n2); - } -#endif - SetDictInt("KEY_MIN", KEY_MIN); - SetDictInt("KEY_MAX", KEY_MAX); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/_hotshot.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/_hotshot.c deleted file mode 100644 index 9fad9b06..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/_hotshot.c +++ /dev/null @@ -1,1666 +0,0 @@ -/* - * This is the High Performance Python Profiler portion of HotShot. - */ - -#include "Python.h" -#include "compile.h" -#include "eval.h" -#include "frameobject.h" -#include "structmember.h" - -/* - * Which timer to use should be made more configurable, but that should not - * be difficult. This will do for now. - */ -#ifdef MS_WINDOWS -#ifdef MS_XBOX -#include -#else -#include -#endif -#include /* for getcwd() */ -typedef __int64 hs_time; -#define GETTIMEOFDAY(P_HS_TIME) \ - { LARGE_INTEGER _temp; \ - QueryPerformanceCounter(&_temp); \ - *(P_HS_TIME) = _temp.QuadPart; } - - -#else -#ifndef HAVE_GETTIMEOFDAY -#error "This module requires gettimeofday() on non-Windows platforms!" -#endif -#if defined(macintosh) || (defined(PYOS_OS2) && defined(PYCC_GCC)) -#include -#else -#include -#include -#endif -typedef struct timeval hs_time; -#endif - -#if !defined(__cplusplus) && !defined(inline) -#ifdef __GNUC__ -#define inline __inline -#endif -#endif - -#ifndef inline -#define inline -#endif - -#define BUFFERSIZE 10240 - -#ifdef macintosh -#define PATH_MAX 254 -#endif - -#if defined(PYOS_OS2) && defined(PYCC_GCC) -#define PATH_MAX 260 -#endif - -#if defined(__sgi) && _COMPILER_VERSION>700 && !defined(PATH_MAX) -/* fix PATH_MAX not being defined with MIPSPro 7.x - if mode is ANSI C (default) */ -#define PATH_MAX 1024 -#endif - -#ifndef PATH_MAX -# ifdef MAX_PATH -# define PATH_MAX MAX_PATH -# elif defined (_POSIX_PATH_MAX) -# define PATH_MAX _POSIX_PATH_MAX -# else -# error "Need a defn. for PATH_MAX in _hotshot.c" -# endif -#endif - -typedef struct { - PyObject_HEAD - PyObject *filemap; - PyObject *logfilename; - int index; - unsigned char buffer[BUFFERSIZE]; - FILE *logfp; - int lineevents; - int linetimings; - int frametimings; - /* size_t filled; */ - int active; - int next_fileno; - hs_time prev_timeofday; -} ProfilerObject; - -typedef struct { - PyObject_HEAD - PyObject *info; - FILE *logfp; - int linetimings; - int frametimings; -} LogReaderObject; - -static PyObject * ProfilerError = NULL; - - -#ifndef MS_WINDOWS -#ifdef GETTIMEOFDAY_NO_TZ -#define GETTIMEOFDAY(ptv) gettimeofday((ptv)) -#else -#define GETTIMEOFDAY(ptv) gettimeofday((ptv), (struct timezone *)NULL) -#endif -#endif - - -/* The log reader... */ - -PyDoc_STRVAR(logreader_close__doc__, -"close()\n" -"Close the log file, preventing additional records from being read."); - -static PyObject * -logreader_close(LogReaderObject *self, PyObject *args) -{ - if (self->logfp != NULL) { - fclose(self->logfp); - self->logfp = NULL; - } - Py_INCREF(Py_None); - - return Py_None; -} - -PyDoc_STRVAR(logreader_fileno__doc__, -"fileno() -> file descriptor\n" -"Returns the file descriptor for the log file, if open.\n" -"Raises ValueError if the log file is closed."); - -static PyObject * -logreader_fileno(LogReaderObject *self) -{ - if (self->logfp == NULL) { - PyErr_SetString(PyExc_ValueError, - "logreader's file object already closed"); - return NULL; - } - return PyInt_FromLong(fileno(self->logfp)); -} - - -/* Log File Format - * --------------- - * - * The log file consists of a sequence of variable-length records. - * Each record is identified with a record type identifier in two - * bits of the first byte. The two bits are the "least significant" - * bits of the byte. - * - * Low bits: Opcode: Meaning: - * 0x00 ENTER enter a frame - * 0x01 EXIT exit a frame - * 0x02 LINENO execution moved onto a different line - * 0x03 OTHER more bits are needed to deecode - * - * If the type is OTHER, the record is not packed so tightly, and the - * remaining bits are used to disambiguate the record type. These - * records are not used as frequently so compaction is not an issue. - * Each of the first three record types has a highly tailored - * structure that allows it to be packed tightly. - * - * The OTHER records have the following identifiers: - * - * First byte: Opcode: Meaning: - * 0x13 ADD_INFO define a key/value pair - * 0x23 DEFINE_FILE define an int->filename mapping - * 0x33 LINE_TIMES indicates if LINENO events have tdeltas - * 0x43 DEFINE_FUNC define a (fileno,lineno)->funcname mapping - * 0x53 FRAME_TIMES indicates if ENTER/EXIT events have tdeltas - * - * Packed Integers - * - * "Packed integers" are non-negative integer values encoded as a - * sequence of bytes. Each byte is encoded such that the most - * significant bit is set if the next byte is also part of the - * integer. Each byte provides bits to the least-significant end of - * the result; the accumulated value must be shifted up to place the - * new bits into the result. - * - * "Modified packed integers" are packed integers where only a portion - * of the first byte is used. In the rest of the specification, these - * are referred to as "MPI(n,name)", where "n" is the number of bits - * discarded from the least-signicant positions of the byte, and - * "name" is a name being given to those "discarded" bits, since they - * are a field themselves. - * - * ENTER records: - * - * MPI(2,type) fileno -- type is 0x00 - * PI lineno - * PI tdelta -- iff frame times are enabled - * - * EXIT records - * - * MPI(2,type) tdelta -- type is 0x01; tdelta will be 0 - * if frame times are disabled - * - * LINENO records - * - * MPI(2,type) lineno -- type is 0x02 - * PI tdelta -- iff LINENO includes it - * - * ADD_INFO records - * - * BYTE type -- always 0x13 - * PI len1 -- length of first string - * BYTE string1[len1] -- len1 bytes of string data - * PI len2 -- length of second string - * BYTE string2[len2] -- len2 bytes of string data - * - * DEFINE_FILE records - * - * BYTE type -- always 0x23 - * PI fileno - * PI len -- length of filename - * BYTE filename[len] -- len bytes of string data - * - * DEFINE_FUNC records - * - * BYTE type -- always 0x43 - * PI fileno - * PI lineno - * PI len -- length of funcname - * BYTE funcname[len] -- len bytes of string data - * - * LINE_TIMES records - * - * This record can be used only before the start of ENTER/EXIT/LINENO - * records. If have_tdelta is true, LINENO records will include the - * tdelta field, otherwise it will be omitted. If this record is not - * given, LINENO records will not contain the tdelta field. - * - * BYTE type -- always 0x33 - * BYTE have_tdelta -- 0 if LINENO does *not* have - * timing information - * FRAME_TIMES records - * - * This record can be used only before the start of ENTER/EXIT/LINENO - * records. If have_tdelta is true, ENTER and EXIT records will - * include the tdelta field, otherwise it will be omitted. If this - * record is not given, ENTER and EXIT records will contain the tdelta - * field. - * - * BYTE type -- always 0x53 - * BYTE have_tdelta -- 0 if ENTER/EXIT do *not* have - * timing information - */ - -#define WHAT_ENTER 0x00 -#define WHAT_EXIT 0x01 -#define WHAT_LINENO 0x02 -#define WHAT_OTHER 0x03 /* only used in decoding */ -#define WHAT_ADD_INFO 0x13 -#define WHAT_DEFINE_FILE 0x23 -#define WHAT_LINE_TIMES 0x33 -#define WHAT_DEFINE_FUNC 0x43 -#define WHAT_FRAME_TIMES 0x53 - -#define ERR_NONE 0 -#define ERR_EOF -1 -#define ERR_EXCEPTION -2 -#define ERR_BAD_RECTYPE -3 - -#define PISIZE (sizeof(int) + 1) -#define MPISIZE (PISIZE + 1) - -/* Maximum size of "normal" events -- nothing that contains string data */ -#define MAXEVENTSIZE (MPISIZE + PISIZE*2) - - -/* Unpack a packed integer; if "discard" is non-zero, unpack a modified - * packed integer with "discard" discarded bits. - */ -static int -unpack_packed_int(LogReaderObject *self, int *pvalue, int discard) -{ - int c; - int accum = 0; - int bits = 0; - int cont; - - do { - /* read byte */ - if ((c = fgetc(self->logfp)) == EOF) - return ERR_EOF; - accum |= ((c & 0x7F) >> discard) << bits; - bits += (7 - discard); - cont = c & 0x80; - discard = 0; - } while (cont); - - *pvalue = accum; - - return 0; -} - -/* Unpack a string, which is encoded as a packed integer giving the - * length of the string, followed by the string data. - */ -static int -unpack_string(LogReaderObject *self, PyObject **pvalue) -{ - int i; - int len; - int err; - int ch; - char *buf; - - if ((err = unpack_packed_int(self, &len, 0))) - return err; - - buf = malloc(len); - for (i=0; i < len; i++) { - ch = fgetc(self->logfp); - buf[i] = ch; - if (ch == EOF) { - free(buf); - return ERR_EOF; - } - } - *pvalue = PyString_FromStringAndSize(buf, len); - free(buf); - if (*pvalue == NULL) { - return ERR_EXCEPTION; - } - return 0; -} - - -static int -unpack_add_info(LogReaderObject *self) -{ - PyObject *key; - PyObject *value = NULL; - int err; - - err = unpack_string(self, &key); - if (!err) { - err = unpack_string(self, &value); - if (err) - Py_DECREF(key); - else { - PyObject *list = PyDict_GetItem(self->info, key); - if (list == NULL) { - list = PyList_New(0); - if (list == NULL) { - err = ERR_EXCEPTION; - goto finally; - } - if (PyDict_SetItem(self->info, key, list)) { - err = ERR_EXCEPTION; - goto finally; - } - } - if (PyList_Append(list, value)) - err = ERR_EXCEPTION; - } - } - finally: - Py_XDECREF(key); - Py_XDECREF(value); - return err; -} - - -static void -eof_error(LogReaderObject *self) -{ - fclose(self->logfp); - self->logfp = NULL; - PyErr_SetString(PyExc_EOFError, - "end of file with incomplete profile record"); -} - -static PyObject * -logreader_tp_iternext(LogReaderObject *self) -{ - int c; - int what; - int err = ERR_NONE; - int lineno = -1; - int fileno = -1; - int tdelta = -1; - PyObject *s1 = NULL, *s2 = NULL; - PyObject *result = NULL; -#if 0 - unsigned char b0, b1; -#endif - - if (self->logfp == NULL) { - PyErr_SetString(ProfilerError, - "cannot iterate over closed LogReader object"); - return NULL; - } - -restart: - /* decode the record type */ - if ((c = fgetc(self->logfp)) == EOF) { - fclose(self->logfp); - self->logfp = NULL; - return NULL; - } - what = c & WHAT_OTHER; - if (what == WHAT_OTHER) - what = c; /* need all the bits for type */ - else - ungetc(c, self->logfp); /* type byte includes packed int */ - - switch (what) { - case WHAT_ENTER: - err = unpack_packed_int(self, &fileno, 2); - if (!err) { - err = unpack_packed_int(self, &lineno, 0); - if (self->frametimings && !err) - err = unpack_packed_int(self, &tdelta, 0); - } - break; - case WHAT_EXIT: - err = unpack_packed_int(self, &tdelta, 2); - break; - case WHAT_LINENO: - err = unpack_packed_int(self, &lineno, 2); - if (self->linetimings && !err) - err = unpack_packed_int(self, &tdelta, 0); - break; - case WHAT_ADD_INFO: - err = unpack_add_info(self); - break; - case WHAT_DEFINE_FILE: - err = unpack_packed_int(self, &fileno, 0); - if (!err) { - err = unpack_string(self, &s1); - if (!err) { - Py_INCREF(Py_None); - s2 = Py_None; - } - } - break; - case WHAT_DEFINE_FUNC: - err = unpack_packed_int(self, &fileno, 0); - if (!err) { - err = unpack_packed_int(self, &lineno, 0); - if (!err) - err = unpack_string(self, &s1); - } - break; - case WHAT_LINE_TIMES: - if ((c = fgetc(self->logfp)) == EOF) - err = ERR_EOF; - else { - self->linetimings = c ? 1 : 0; - goto restart; - } - break; - case WHAT_FRAME_TIMES: - if ((c = fgetc(self->logfp)) == EOF) - err = ERR_EOF; - else { - self->frametimings = c ? 1 : 0; - goto restart; - } - break; - default: - err = ERR_BAD_RECTYPE; - } - if (err == ERR_BAD_RECTYPE) { - PyErr_SetString(PyExc_ValueError, - "unknown record type in log file"); - } - else if (err == ERR_EOF) { - eof_error(self); - } - else if (!err) { - result = PyTuple_New(4); - PyTuple_SET_ITEM(result, 0, PyInt_FromLong(what)); - PyTuple_SET_ITEM(result, 2, PyInt_FromLong(fileno)); - if (s1 == NULL) - PyTuple_SET_ITEM(result, 1, PyInt_FromLong(tdelta)); - else - PyTuple_SET_ITEM(result, 1, s1); - if (s2 == NULL) - PyTuple_SET_ITEM(result, 3, PyInt_FromLong(lineno)); - else - PyTuple_SET_ITEM(result, 3, s2); - } - /* The only other case is err == ERR_EXCEPTION, in which case the - * exception is already set. - */ -#if 0 - b0 = self->buffer[self->index]; - b1 = self->buffer[self->index + 1]; - if (b0 & 1) { - /* This is a line-number event. */ - what = PyTrace_LINE; - lineno = ((b0 & ~1) << 7) + b1; - self->index += 2; - } - else { - what = (b0 & 0x0E) >> 1; - tdelta = ((b0 & 0xF0) << 4) + b1; - if (what == PyTrace_CALL) { - /* we know there's a 2-byte file ID & 2-byte line number */ - fileno = ((self->buffer[self->index + 2] << 8) - + self->buffer[self->index + 3]); - lineno = ((self->buffer[self->index + 4] << 8) - + self->buffer[self->index + 5]); - self->index += 6; - } - else - self->index += 2; - } -#endif - return result; -} - -static void -logreader_dealloc(LogReaderObject *self) -{ - if (self->logfp != NULL) { - fclose(self->logfp); - self->logfp = NULL; - } - PyObject_Del(self); -} - -static PyObject * -logreader_sq_item(LogReaderObject *self, int index) -{ - PyObject *result = logreader_tp_iternext(self); - if (result == NULL && !PyErr_Occurred()) { - PyErr_SetString(PyExc_IndexError, "no more events in log"); - return NULL; - } - return result; -} - -static void -do_stop(ProfilerObject *self); - -static int -flush_data(ProfilerObject *self) -{ - /* Need to dump data to the log file... */ - size_t written = fwrite(self->buffer, 1, self->index, self->logfp); - if (written == (size_t)self->index) - self->index = 0; - else { - memmove(self->buffer, &self->buffer[written], - self->index - written); - self->index -= written; - if (written == 0) { - char *s = PyString_AsString(self->logfilename); - PyErr_SetFromErrnoWithFilename(PyExc_IOError, s); - do_stop(self); - return -1; - } - } - if (written > 0) { - if (fflush(self->logfp)) { - char *s = PyString_AsString(self->logfilename); - PyErr_SetFromErrnoWithFilename(PyExc_IOError, s); - do_stop(self); - return -1; - } - } - return 0; -} - -static inline int -pack_packed_int(ProfilerObject *self, int value) -{ - unsigned char partial; - - do { - partial = value & 0x7F; - value >>= 7; - if (value) - partial |= 0x80; - self->buffer[self->index] = partial; - self->index++; - } while (value); - return 0; -} - -/* Encode a modified packed integer, with a subfield of modsize bits - * containing the value "subfield". The value of subfield is not - * checked to ensure it actually fits in modsize bits. - */ -static inline int -pack_modified_packed_int(ProfilerObject *self, int value, - int modsize, int subfield) -{ - const int maxvalues[] = {-1, 1, 3, 7, 15, 31, 63, 127}; - - int bits = 7 - modsize; - int partial = value & maxvalues[bits]; - unsigned char b = subfield | (partial << modsize); - - if (partial != value) { - b |= 0x80; - self->buffer[self->index] = b; - self->index++; - return pack_packed_int(self, value >> bits); - } - self->buffer[self->index] = b; - self->index++; - return 0; -} - -static int -pack_string(ProfilerObject *self, const char *s, int len) -{ - if (len + PISIZE + self->index >= BUFFERSIZE) { - if (flush_data(self) < 0) - return -1; - } - if (pack_packed_int(self, len) < 0) - return -1; - memcpy(self->buffer + self->index, s, len); - self->index += len; - return 0; -} - -static int -pack_add_info(ProfilerObject *self, const char *s1, const char *s2) -{ - int len1 = strlen(s1); - int len2 = strlen(s2); - - if (len1 + len2 + PISIZE*2 + 1 + self->index >= BUFFERSIZE) { - if (flush_data(self) < 0) - return -1; - } - self->buffer[self->index] = WHAT_ADD_INFO; - self->index++; - if (pack_string(self, s1, len1) < 0) - return -1; - return pack_string(self, s2, len2); -} - -static int -pack_define_file(ProfilerObject *self, int fileno, const char *filename) -{ - int len = strlen(filename); - - if (len + PISIZE*2 + 1 + self->index >= BUFFERSIZE) { - if (flush_data(self) < 0) - return -1; - } - self->buffer[self->index] = WHAT_DEFINE_FILE; - self->index++; - if (pack_packed_int(self, fileno) < 0) - return -1; - return pack_string(self, filename, len); -} - -static int -pack_define_func(ProfilerObject *self, int fileno, int lineno, - const char *funcname) -{ - int len = strlen(funcname); - - if (len + PISIZE*3 + 1 + self->index >= BUFFERSIZE) { - if (flush_data(self) < 0) - return -1; - } - self->buffer[self->index] = WHAT_DEFINE_FUNC; - self->index++; - if (pack_packed_int(self, fileno) < 0) - return -1; - if (pack_packed_int(self, lineno) < 0) - return -1; - return pack_string(self, funcname, len); -} - -static int -pack_line_times(ProfilerObject *self) -{ - if (2 + self->index >= BUFFERSIZE) { - if (flush_data(self) < 0) - return -1; - } - self->buffer[self->index] = WHAT_LINE_TIMES; - self->buffer[self->index + 1] = self->linetimings ? 1 : 0; - self->index += 2; - return 0; -} - -static int -pack_frame_times(ProfilerObject *self) -{ - if (2 + self->index >= BUFFERSIZE) { - if (flush_data(self) < 0) - return -1; - } - self->buffer[self->index] = WHAT_FRAME_TIMES; - self->buffer[self->index + 1] = self->frametimings ? 1 : 0; - self->index += 2; - return 0; -} - -static inline int -pack_enter(ProfilerObject *self, int fileno, int tdelta, int lineno) -{ - if (MPISIZE + PISIZE*2 + self->index >= BUFFERSIZE) { - if (flush_data(self) < 0) - return -1; - } - pack_modified_packed_int(self, fileno, 2, WHAT_ENTER); - pack_packed_int(self, lineno); - if (self->frametimings) - return pack_packed_int(self, tdelta); - else - return 0; -} - -static inline int -pack_exit(ProfilerObject *self, int tdelta) -{ - if (MPISIZE + self->index >= BUFFERSIZE) { - if (flush_data(self) < 0) - return -1; - } - if (self->frametimings) - return pack_modified_packed_int(self, tdelta, 2, WHAT_EXIT); - self->buffer[self->index] = WHAT_EXIT; - self->index++; - return 0; -} - -static inline int -pack_lineno(ProfilerObject *self, int lineno) -{ - if (MPISIZE + self->index >= BUFFERSIZE) { - if (flush_data(self) < 0) - return -1; - } - return pack_modified_packed_int(self, lineno, 2, WHAT_LINENO); -} - -static inline int -pack_lineno_tdelta(ProfilerObject *self, int lineno, int tdelta) -{ - if (MPISIZE + PISIZE + self->index >= BUFFERSIZE) { - if (flush_data(self) < 0) - return 0; - } - if (pack_modified_packed_int(self, lineno, 2, WHAT_LINENO) < 0) - return -1; - return pack_packed_int(self, tdelta); -} - -static inline int -get_fileno(ProfilerObject *self, PyCodeObject *fcode) -{ - /* This is only used for ENTER events. */ - - PyObject *obj; - PyObject *dict; - int fileno; - - obj = PyDict_GetItem(self->filemap, fcode->co_filename); - if (obj == NULL) { - /* first sighting of this file */ - dict = PyDict_New(); - if (dict == NULL) { - return -1; - } - fileno = self->next_fileno; - obj = Py_BuildValue("iN", fileno, dict); - if (obj == NULL) { - return -1; - } - if (PyDict_SetItem(self->filemap, fcode->co_filename, obj)) { - Py_DECREF(obj); - return -1; - } - self->next_fileno++; - Py_DECREF(obj); - if (pack_define_file(self, fileno, - PyString_AS_STRING(fcode->co_filename)) < 0) - return -1; - } - else { - /* already know this ID */ - fileno = PyInt_AS_LONG(PyTuple_GET_ITEM(obj, 0)); - dict = PyTuple_GET_ITEM(obj, 1); - } - /* make sure we save a function name for this (fileno, lineno) */ - obj = PyInt_FromLong(fcode->co_firstlineno); - if (obj == NULL) { - /* We just won't have it saved; too bad. */ - PyErr_Clear(); - } - else { - PyObject *name = PyDict_GetItem(dict, obj); - if (name == NULL) { - if (pack_define_func(self, fileno, fcode->co_firstlineno, - PyString_AS_STRING(fcode->co_name)) < 0) - return -1; - if (PyDict_SetItem(dict, obj, fcode->co_name)) - return -1; - } - } - return fileno; -} - -static inline int -get_tdelta(ProfilerObject *self) -{ - int tdelta; -#ifdef MS_WINDOWS - hs_time tv; - hs_time diff; - - GETTIMEOFDAY(&tv); - diff = tv - self->prev_timeofday; - tdelta = (int)diff; -#else - struct timeval tv; - - GETTIMEOFDAY(&tv); - - if (tv.tv_sec == self->prev_timeofday.tv_sec) - tdelta = tv.tv_usec - self->prev_timeofday.tv_usec; - else - tdelta = ((tv.tv_sec - self->prev_timeofday.tv_sec) * 1000000 - + tv.tv_usec); -#endif - self->prev_timeofday = tv; - return tdelta; -} - - -/* The workhorse: the profiler callback function. */ - -static int -profiler_callback(ProfilerObject *self, PyFrameObject *frame, int what, - PyObject *arg) -{ - int tdelta = -1; - int fileno; - - if (self->frametimings) - tdelta = get_tdelta(self); - switch (what) { - case PyTrace_CALL: - fileno = get_fileno(self, frame->f_code); - if (fileno < 0) - return -1; - if (pack_enter(self, fileno, tdelta, - frame->f_code->co_firstlineno) < 0) - return -1; - break; - case PyTrace_RETURN: - if (pack_exit(self, tdelta) < 0) - return -1; - break; - default: - /* should never get here */ - break; - } - return 0; -} - - -/* Alternate callback when we want PyTrace_LINE events */ - -static int -tracer_callback(ProfilerObject *self, PyFrameObject *frame, int what, - PyObject *arg) -{ - int fileno; - - switch (what) { - case PyTrace_CALL: - fileno = get_fileno(self, frame->f_code); - if (fileno < 0) - return -1; - return pack_enter(self, fileno, - self->frametimings ? get_tdelta(self) : -1, - frame->f_code->co_firstlineno); - - case PyTrace_RETURN: - return pack_exit(self, get_tdelta(self)); - - case PyTrace_LINE: - if (self->linetimings) - return pack_lineno_tdelta(self, frame->f_lineno, - get_tdelta(self)); - else - return pack_lineno(self, frame->f_lineno); - - default: - /* ignore PyTrace_EXCEPTION */ - break; - } - return 0; -} - - -/* A couple of useful helper functions. */ - -#ifdef MS_WINDOWS -static LARGE_INTEGER frequency = {0, 0}; -#endif - -static unsigned long timeofday_diff = 0; -static unsigned long rusage_diff = 0; - -static void -calibrate(void) -{ - hs_time tv1, tv2; - -#ifdef MS_WINDOWS - hs_time diff; - QueryPerformanceFrequency(&frequency); -#endif - - GETTIMEOFDAY(&tv1); - while (1) { - GETTIMEOFDAY(&tv2); -#ifdef MS_WINDOWS - diff = tv2 - tv1; - if (diff != 0) { - timeofday_diff = (unsigned long)diff; - break; - } -#else - if (tv1.tv_sec != tv2.tv_sec || tv1.tv_usec != tv2.tv_usec) { - if (tv1.tv_sec == tv2.tv_sec) - timeofday_diff = tv2.tv_usec - tv1.tv_usec; - else - timeofday_diff = (1000000 - tv1.tv_usec) + tv2.tv_usec; - break; - } -#endif - } -#if defined(MS_WINDOWS) || defined(macintosh) || defined(PYOS_OS2) || \ - defined(__VMS) - rusage_diff = -1; -#else - { - struct rusage ru1, ru2; - - getrusage(RUSAGE_SELF, &ru1); - while (1) { - getrusage(RUSAGE_SELF, &ru2); - if (ru1.ru_utime.tv_sec != ru2.ru_utime.tv_sec) { - rusage_diff = ((1000000 - ru1.ru_utime.tv_usec) - + ru2.ru_utime.tv_usec); - break; - } - else if (ru1.ru_utime.tv_usec != ru2.ru_utime.tv_usec) { - rusage_diff = ru2.ru_utime.tv_usec - ru1.ru_utime.tv_usec; - break; - } - else if (ru1.ru_stime.tv_sec != ru2.ru_stime.tv_sec) { - rusage_diff = ((1000000 - ru1.ru_stime.tv_usec) - + ru2.ru_stime.tv_usec); - break; - } - else if (ru1.ru_stime.tv_usec != ru2.ru_stime.tv_usec) { - rusage_diff = ru2.ru_stime.tv_usec - ru1.ru_stime.tv_usec; - break; - } - } - } -#endif -} - -static void -do_start(ProfilerObject *self) -{ - self->active = 1; - GETTIMEOFDAY(&self->prev_timeofday); - if (self->lineevents) - PyEval_SetTrace((Py_tracefunc) tracer_callback, (PyObject *)self); - else - PyEval_SetProfile((Py_tracefunc) profiler_callback, (PyObject *)self); -} - -static void -do_stop(ProfilerObject *self) -{ - if (self->active) { - self->active = 0; - if (self->lineevents) - PyEval_SetTrace(NULL, NULL); - else - PyEval_SetProfile(NULL, NULL); - } - if (self->index > 0) { - /* Best effort to dump out any remaining data. */ - flush_data(self); - } -} - -static int -is_available(ProfilerObject *self) -{ - if (self->active) { - PyErr_SetString(ProfilerError, "profiler already active"); - return 0; - } - if (self->logfp == NULL) { - PyErr_SetString(ProfilerError, "profiler already closed"); - return 0; - } - return 1; -} - - -/* Profiler object interface methods. */ - -PyDoc_STRVAR(addinfo__doc__, -"addinfo(key, value)\n" -"Insert an ADD_INFO record into the log."); - -static PyObject * -profiler_addinfo(ProfilerObject *self, PyObject *args) -{ - PyObject *result = NULL; - char *key, *value; - - if (PyArg_ParseTuple(args, "ss:addinfo", &key, &value)) { - if (self->logfp == NULL) - PyErr_SetString(ProfilerError, "profiler already closed"); - else { - if (pack_add_info(self, key, value) == 0) { - result = Py_None; - Py_INCREF(result); - } - } - } - return result; -} - -PyDoc_STRVAR(close__doc__, -"close()\n" -"Shut down this profiler and close the log files, even if its active."); - -static PyObject * -profiler_close(ProfilerObject *self) -{ - do_stop(self); - if (self->logfp != NULL) { - fclose(self->logfp); - self->logfp = NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -#define fileno__doc__ logreader_fileno__doc__ - -static PyObject * -profiler_fileno(ProfilerObject *self) -{ - if (self->logfp == NULL) { - PyErr_SetString(PyExc_ValueError, - "profiler's file object already closed"); - return NULL; - } - return PyInt_FromLong(fileno(self->logfp)); -} - -PyDoc_STRVAR(runcall__doc__, -"runcall(callable[, args[, kw]]) -> callable()\n" -"Profile a specific function call, returning the result of that call."); - -static PyObject * -profiler_runcall(ProfilerObject *self, PyObject *args) -{ - PyObject *result = NULL; - PyObject *callargs = NULL; - PyObject *callkw = NULL; - PyObject *callable; - - if (PyArg_ParseTuple(args, "O|OO:runcall", - &callable, &callargs, &callkw)) { - if (is_available(self)) { - do_start(self); - result = PyEval_CallObjectWithKeywords(callable, callargs, callkw); - do_stop(self); - } - } - return result; -} - -PyDoc_STRVAR(runcode__doc__, -"runcode(code, globals[, locals])\n" -"Execute a code object while collecting profile data. If locals is\n" -"omitted, globals is used for the locals as well."); - -static PyObject * -profiler_runcode(ProfilerObject *self, PyObject *args) -{ - PyObject *result = NULL; - PyCodeObject *code; - PyObject *globals; - PyObject *locals = NULL; - - if (PyArg_ParseTuple(args, "O!O!|O:runcode", - &PyCode_Type, &code, - &PyDict_Type, &globals, - &locals)) { - if (is_available(self)) { - if (locals == NULL || locals == Py_None) - locals = globals; - else if (!PyDict_Check(locals)) { - PyErr_SetString(PyExc_TypeError, - "locals must be a dictionary or None"); - return NULL; - } - do_start(self); - result = PyEval_EvalCode(code, globals, locals); - do_stop(self); -#if 0 - if (!PyErr_Occurred()) { - result = Py_None; - Py_INCREF(result); - } -#endif - } - } - return result; -} - -PyDoc_STRVAR(start__doc__, -"start()\n" -"Install this profiler for the current thread."); - -static PyObject * -profiler_start(ProfilerObject *self, PyObject *args) -{ - PyObject *result = NULL; - - if (is_available(self)) { - do_start(self); - result = Py_None; - Py_INCREF(result); - } - return result; -} - -PyDoc_STRVAR(stop__doc__, -"stop()\n" -"Remove this profiler from the current thread."); - -static PyObject * -profiler_stop(ProfilerObject *self, PyObject *args) -{ - PyObject *result = NULL; - - if (!self->active) - PyErr_SetString(ProfilerError, "profiler not active"); - else { - do_stop(self); - result = Py_None; - Py_INCREF(result); - } - return result; -} - - -/* Python API support. */ - -static void -profiler_dealloc(ProfilerObject *self) -{ - do_stop(self); - if (self->logfp != NULL) - fclose(self->logfp); - Py_XDECREF(self->filemap); - Py_XDECREF(self->logfilename); - PyObject_Del((PyObject *)self); -} - -static PyMethodDef profiler_methods[] = { - {"addinfo", (PyCFunction)profiler_addinfo, METH_VARARGS, addinfo__doc__}, - {"close", (PyCFunction)profiler_close, METH_NOARGS, close__doc__}, - {"fileno", (PyCFunction)profiler_fileno, METH_NOARGS, fileno__doc__}, - {"runcall", (PyCFunction)profiler_runcall, METH_VARARGS, runcall__doc__}, - {"runcode", (PyCFunction)profiler_runcode, METH_VARARGS, runcode__doc__}, - {"start", (PyCFunction)profiler_start, METH_NOARGS, start__doc__}, - {"stop", (PyCFunction)profiler_stop, METH_NOARGS, stop__doc__}, - {NULL, NULL} -}; - -static PyMemberDef profiler_members[] = { - {"frametimings", T_LONG, offsetof(ProfilerObject, linetimings), READONLY}, - {"lineevents", T_LONG, offsetof(ProfilerObject, lineevents), READONLY}, - {"linetimings", T_LONG, offsetof(ProfilerObject, linetimings), READONLY}, - {NULL} -}; - -static PyObject * -profiler_get_closed(ProfilerObject *self, void *closure) -{ - PyObject *result = (self->logfp == NULL) ? Py_True : Py_False; - Py_INCREF(result); - return result; -} - -static PyGetSetDef profiler_getsets[] = { - {"closed", (getter)profiler_get_closed, NULL, - PyDoc_STR("True if the profiler's output file has already been closed.")}, - {NULL} -}; - - -PyDoc_STRVAR(profiler_object__doc__, -"High-performance profiler object.\n" -"\n" -"Methods:\n" -"\n" -"close(): Stop the profiler and close the log files.\n" -"fileno(): Returns the file descriptor of the log file.\n" -"runcall(): Run a single function call with profiling enabled.\n" -"runcode(): Execute a code object with profiling enabled.\n" -"start(): Install the profiler and return.\n" -"stop(): Remove the profiler.\n" -"\n" -"Attributes (read-only):\n" -"\n" -"closed: True if the profiler has already been closed.\n" -"frametimings: True if ENTER/EXIT events collect timing information.\n" -"lineevents: True if line events are reported to the profiler.\n" -"linetimings: True if line events collect timing information."); - -static PyTypeObject ProfilerType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "_hotshot.ProfilerType", /* tp_name */ - (int) sizeof(ProfilerObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)profiler_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - profiler_object__doc__, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - profiler_methods, /* tp_methods */ - profiler_members, /* tp_members */ - profiler_getsets, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -}; - - -static PyMethodDef logreader_methods[] = { - {"close", (PyCFunction)logreader_close, METH_NOARGS, - logreader_close__doc__}, - {"fileno", (PyCFunction)logreader_fileno, METH_NOARGS, - logreader_fileno__doc__}, - {NULL, NULL} -}; - -static PyMemberDef logreader_members[] = { - {"info", T_OBJECT, offsetof(LogReaderObject, info), RO, - PyDoc_STR("Dictionary mapping informational keys to lists of values.")}, - {NULL} -}; - - -PyDoc_STRVAR(logreader__doc__, -"logreader(filename) --> log-iterator\n\ -Create a log-reader for the timing information file."); - -static PySequenceMethods logreader_as_sequence = { - 0, /* sq_length */ - 0, /* sq_concat */ - 0, /* sq_repeat */ - (intargfunc)logreader_sq_item, /* sq_item */ - 0, /* sq_slice */ - 0, /* sq_ass_item */ - 0, /* sq_ass_slice */ - 0, /* sq_contains */ - 0, /* sq_inplace_concat */ - 0, /* sq_inplace_repeat */ -}; - -static PyObject * -logreader_get_closed(LogReaderObject *self, void *closure) -{ - PyObject *result = (self->logfp == NULL) ? Py_True : Py_False; - Py_INCREF(result); - return result; -} - -static PyGetSetDef logreader_getsets[] = { - {"closed", (getter)logreader_get_closed, NULL, - PyDoc_STR("True if the logreader's input file has already been closed.")}, - {NULL} -}; - -static PyTypeObject LogReaderType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "_hotshot.LogReaderType", /* tp_name */ - (int) sizeof(LogReaderObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)logreader_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - &logreader_as_sequence, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - logreader__doc__, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)logreader_tp_iternext,/* tp_iternext */ - logreader_methods, /* tp_methods */ - logreader_members, /* tp_members */ - logreader_getsets, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -}; - -static PyObject * -hotshot_logreader(PyObject *unused, PyObject *args) -{ - LogReaderObject *self = NULL; - char *filename; - int c; - int err = 0; - - if (PyArg_ParseTuple(args, "s:logreader", &filename)) { - self = PyObject_New(LogReaderObject, &LogReaderType); - if (self != NULL) { - self->frametimings = 1; - self->linetimings = 0; - self->info = NULL; - self->logfp = fopen(filename, "rb"); - if (self->logfp == NULL) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, filename); - Py_DECREF(self); - self = NULL; - goto finally; - } - self->info = PyDict_New(); - if (self->info == NULL) { - Py_DECREF(self); - goto finally; - } - /* read initial info */ - for (;;) { - if ((c = fgetc(self->logfp)) == EOF) { - eof_error(self); - break; - } - if (c != WHAT_ADD_INFO) { - ungetc(c, self->logfp); - break; - } - err = unpack_add_info(self); - if (err) { - if (err == ERR_EOF) - eof_error(self); - else - PyErr_SetString(PyExc_RuntimeError, - "unexpected error"); - break; - } - } - } - } - finally: - return (PyObject *) self; -} - - -/* Return a Python string that represents the version number without the - * extra cruft added by revision control, even if the right options were - * given to the "cvs export" command to make it not include the extra - * cruft. - */ -static char * -get_version_string(void) -{ - static char *rcsid = "$Revision: 1.34 $"; - char *rev = rcsid; - char *buffer; - int i = 0; - - while (*rev && !isdigit((int)*rev)) - ++rev; - while (rev[i] != ' ' && rev[i] != '\0') - ++i; - buffer = malloc(i + 1); - if (buffer != NULL) { - memmove(buffer, rev, i); - buffer[i] = '\0'; - } - return buffer; -} - -/* Write out a RFC 822-style header with various useful bits of - * information to make the output easier to manage. - */ -static int -write_header(ProfilerObject *self) -{ - char *buffer; - char cwdbuffer[PATH_MAX]; - PyObject *temp; - int i, len; - - buffer = get_version_string(); - if (buffer == NULL) { - PyErr_NoMemory(); - return -1; - } - pack_add_info(self, "hotshot-version", buffer); - pack_add_info(self, "requested-frame-timings", - (self->frametimings ? "yes" : "no")); - pack_add_info(self, "requested-line-events", - (self->lineevents ? "yes" : "no")); - pack_add_info(self, "requested-line-timings", - (self->linetimings ? "yes" : "no")); - pack_add_info(self, "platform", Py_GetPlatform()); - pack_add_info(self, "executable", Py_GetProgramFullPath()); - free(buffer); - buffer = (char *) Py_GetVersion(); - if (buffer == NULL) - PyErr_Clear(); - else - pack_add_info(self, "executable-version", buffer); - -#ifdef MS_WINDOWS - PyOS_snprintf(cwdbuffer, sizeof(cwdbuffer), "%I64d", frequency.QuadPart); - pack_add_info(self, "reported-performance-frequency", cwdbuffer); -#else - PyOS_snprintf(cwdbuffer, sizeof(cwdbuffer), "%lu", rusage_diff); - pack_add_info(self, "observed-interval-getrusage", cwdbuffer); - PyOS_snprintf(cwdbuffer, sizeof(cwdbuffer), "%lu", timeofday_diff); - pack_add_info(self, "observed-interval-gettimeofday", cwdbuffer); -#endif - -#ifndef MS_XBOX - pack_add_info(self, "current-directory", - getcwd(cwdbuffer, sizeof cwdbuffer)); -#endif - - temp = PySys_GetObject("path"); - len = PyList_GET_SIZE(temp); - for (i = 0; i < len; ++i) { - PyObject *item = PyList_GET_ITEM(temp, i); - buffer = PyString_AsString(item); - if (buffer == NULL) { - pack_add_info(self, "sys-path-entry", ""); - PyErr_Clear(); - } - else { - pack_add_info(self, "sys-path-entry", buffer); - } - } - pack_frame_times(self); - pack_line_times(self); - - return 0; -} - -PyDoc_STRVAR(profiler__doc__, -"profiler(logfilename[, lineevents[, linetimes]]) -> profiler\n\ -Create a new profiler object."); - -static PyObject * -hotshot_profiler(PyObject *unused, PyObject *args) -{ - char *logfilename; - ProfilerObject *self = NULL; - int lineevents = 0; - int linetimings = 1; - - if (PyArg_ParseTuple(args, "s|ii:profiler", &logfilename, - &lineevents, &linetimings)) { - self = PyObject_New(ProfilerObject, &ProfilerType); - if (self == NULL) - return NULL; - self->frametimings = 1; - self->lineevents = lineevents ? 1 : 0; - self->linetimings = (lineevents && linetimings) ? 1 : 0; - self->index = 0; - self->active = 0; - self->next_fileno = 0; - self->logfp = NULL; - self->logfilename = PyTuple_GET_ITEM(args, 0); - Py_INCREF(self->logfilename); - self->filemap = PyDict_New(); - if (self->filemap == NULL) { - Py_DECREF(self); - return NULL; - } - self->logfp = fopen(logfilename, "wb"); - if (self->logfp == NULL) { - Py_DECREF(self); - PyErr_SetFromErrnoWithFilename(PyExc_IOError, logfilename); - return NULL; - } - if (timeofday_diff == 0) { - /* Run this several times since sometimes the first - * doesn't give the lowest values, and we're really trying - * to determine the lowest. - */ - calibrate(); - calibrate(); - calibrate(); - } - if (write_header(self)) - /* some error occurred, exception has been set */ - self = NULL; - } - return (PyObject *) self; -} - -PyDoc_STRVAR(coverage__doc__, -"coverage(logfilename) -> profiler\n\ -Returns a profiler that doesn't collect any timing information, which is\n\ -useful in building a coverage analysis tool."); - -static PyObject * -hotshot_coverage(PyObject *unused, PyObject *args) -{ - char *logfilename; - PyObject *result = NULL; - - if (PyArg_ParseTuple(args, "s:coverage", &logfilename)) { - result = hotshot_profiler(unused, args); - if (result != NULL) { - ProfilerObject *self = (ProfilerObject *) result; - self->frametimings = 0; - self->linetimings = 0; - self->lineevents = 1; - } - } - return result; -} - -PyDoc_VAR(resolution__doc__) = -#ifdef MS_WINDOWS -PyDoc_STR( -"resolution() -> (performance-counter-ticks, update-frequency)\n" -"Return the resolution of the timer provided by the QueryPerformanceCounter()\n" -"function. The first value is the smallest observed change, and the second\n" -"is the result of QueryPerformanceFrequency()." -) -#else -PyDoc_STR( -"resolution() -> (gettimeofday-usecs, getrusage-usecs)\n" -"Return the resolution of the timers provided by the gettimeofday() and\n" -"getrusage() system calls, or -1 if the call is not supported." -) -#endif -; - -static PyObject * -hotshot_resolution(PyObject *unused, PyObject *args) -{ - PyObject *result = NULL; - - if (PyArg_ParseTuple(args, ":resolution")) { - if (timeofday_diff == 0) { - calibrate(); - calibrate(); - calibrate(); - } -#ifdef MS_WINDOWS - result = Py_BuildValue("ii", timeofday_diff, frequency.LowPart); -#else - result = Py_BuildValue("ii", timeofday_diff, rusage_diff); -#endif - } - return result; -} - - -static PyMethodDef functions[] = { - {"coverage", hotshot_coverage, METH_VARARGS, coverage__doc__}, - {"profiler", hotshot_profiler, METH_VARARGS, profiler__doc__}, - {"logreader", hotshot_logreader, METH_VARARGS, logreader__doc__}, - {"resolution", hotshot_resolution, METH_VARARGS, resolution__doc__}, - {NULL, NULL} -}; - - -void -init_hotshot(void) -{ - PyObject *module; - - LogReaderType.ob_type = &PyType_Type; - ProfilerType.ob_type = &PyType_Type; - module = Py_InitModule("_hotshot", functions); - if (module != NULL) { - char *s = get_version_string(); - - PyModule_AddStringConstant(module, "__version__", s); - free(s); - Py_INCREF(&LogReaderType); - PyModule_AddObject(module, "LogReaderType", - (PyObject *)&LogReaderType); - Py_INCREF(&ProfilerType); - PyModule_AddObject(module, "ProfilerType", - (PyObject *)&ProfilerType); - - if (ProfilerError == NULL) - ProfilerError = PyErr_NewException("hotshot.ProfilerError", - NULL, NULL); - if (ProfilerError != NULL) { - Py_INCREF(ProfilerError); - PyModule_AddObject(module, "ProfilerError", ProfilerError); - } - PyModule_AddIntConstant(module, "WHAT_ENTER", WHAT_ENTER); - PyModule_AddIntConstant(module, "WHAT_EXIT", WHAT_EXIT); - PyModule_AddIntConstant(module, "WHAT_LINENO", WHAT_LINENO); - PyModule_AddIntConstant(module, "WHAT_OTHER", WHAT_OTHER); - PyModule_AddIntConstant(module, "WHAT_ADD_INFO", WHAT_ADD_INFO); - PyModule_AddIntConstant(module, "WHAT_DEFINE_FILE", WHAT_DEFINE_FILE); - PyModule_AddIntConstant(module, "WHAT_DEFINE_FUNC", WHAT_DEFINE_FUNC); - PyModule_AddIntConstant(module, "WHAT_LINE_TIMES", WHAT_LINE_TIMES); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/_localemodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/_localemodule.c deleted file mode 100644 index 7e7bd9dd..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/_localemodule.c +++ /dev/null @@ -1,783 +0,0 @@ -/*********************************************************** -Copyright (C) 1997, 2002, 2003 Martin von Loewis - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies. - -This software comes with no warranty. Use at your own risk. - -******************************************************************/ - -#include "Python.h" - -#include -#include -#include -#include -#include - -#ifdef HAVE_LANGINFO_H -#include -#endif - -#ifdef HAVE_LIBINTL_H -#include -#endif - -#ifdef HAVE_WCHAR_H -#include -#endif - -#if defined(MS_WINDOWS) -#ifdef MS_XBOX -#include -#else -#define WIN32_LEAN_AND_MEAN -#include -#endif -#endif - -#if defined(__APPLE__) || defined(__MWERKS__) -#include "macglue.h" -#endif - -#ifdef RISCOS -char *strdup(const char *); -#endif - -PyDoc_STRVAR(locale__doc__, "Support for POSIX locales."); - -static PyObject *Error; - -/* support functions for formatting floating point numbers */ - -PyDoc_STRVAR(setlocale__doc__, -"(integer,string=None) -> string. Activates/queries locale processing."); - -/* to record the LC_NUMERIC settings */ -static PyObject* grouping = NULL; -static PyObject* thousands_sep = NULL; -static PyObject* decimal_point = NULL; -/* if non-null, indicates that LC_NUMERIC is different from "C" */ -static char* saved_numeric = NULL; - -/* the grouping is terminated by either 0 or CHAR_MAX */ -static PyObject* -copy_grouping(char* s) -{ - int i; - PyObject *result, *val = NULL; - - if (s[0] == '\0') - /* empty string: no grouping at all */ - return PyList_New(0); - - for (i = 0; s[i] != '\0' && s[i] != CHAR_MAX; i++) - ; /* nothing */ - - result = PyList_New(i+1); - if (!result) - return NULL; - - i = -1; - do { - i++; - val = PyInt_FromLong(s[i]); - if (!val) - break; - if (PyList_SetItem(result, i, val)) { - Py_DECREF(val); - val = NULL; - break; - } - } while (s[i] != '\0' && s[i] != CHAR_MAX); - - if (!val) { - Py_DECREF(result); - return NULL; - } - - return result; -} - -static void -fixup_ulcase(void) -{ - PyObject *mods, *strop, *string, *ulo; - unsigned char ul[256]; - int n, c; - - /* find the string and strop modules */ - mods = PyImport_GetModuleDict(); - if (!mods) - return; - string = PyDict_GetItemString(mods, "string"); - if (string) - string = PyModule_GetDict(string); - strop=PyDict_GetItemString(mods, "strop"); - if (strop) - strop = PyModule_GetDict(strop); - if (!string && !strop) - return; - - /* create uppercase map string */ - n = 0; - for (c = 0; c < 256; c++) { - if (isupper(c)) - ul[n++] = c; - } - ulo = PyString_FromStringAndSize((const char *)ul, n); - if (!ulo) - return; - if (string) - PyDict_SetItemString(string, "uppercase", ulo); - if (strop) - PyDict_SetItemString(strop, "uppercase", ulo); - Py_DECREF(ulo); - - /* create lowercase string */ - n = 0; - for (c = 0; c < 256; c++) { - if (islower(c)) - ul[n++] = c; - } - ulo = PyString_FromStringAndSize((const char *)ul, n); - if (!ulo) - return; - if (string) - PyDict_SetItemString(string, "lowercase", ulo); - if (strop) - PyDict_SetItemString(strop, "lowercase", ulo); - Py_DECREF(ulo); - - /* create letters string */ - n = 0; - for (c = 0; c < 256; c++) { - if (isalpha(c)) - ul[n++] = c; - } - ulo = PyString_FromStringAndSize((const char *)ul, n); - if (!ulo) - return; - if (string) - PyDict_SetItemString(string, "letters", ulo); - Py_DECREF(ulo); -} - -static PyObject* -PyLocale_setlocale(PyObject* self, PyObject* args) -{ - int category; - char *locale = NULL, *result; - PyObject *result_object; - struct lconv *lc; - - if (!PyArg_ParseTuple(args, "i|z:setlocale", &category, &locale)) - return NULL; - - if (locale) { - /* set locale */ - result = setlocale(category, locale); - if (!result) { - /* operation failed, no setting was changed */ - PyErr_SetString(Error, "unsupported locale setting"); - return NULL; - } - result_object = PyString_FromString(result); - if (!result_object) - return NULL; - /* record changes to LC_NUMERIC */ - if (category == LC_NUMERIC || category == LC_ALL) { - if (strcmp(locale, "C") == 0 || strcmp(locale, "POSIX") == 0) { - /* user just asked for default numeric locale */ - if (saved_numeric) - free(saved_numeric); - saved_numeric = NULL; - } else { - /* remember values */ - lc = localeconv(); - Py_XDECREF(grouping); - grouping = copy_grouping(lc->grouping); - Py_XDECREF(thousands_sep); - thousands_sep = PyString_FromString(lc->thousands_sep); - Py_XDECREF(decimal_point); - decimal_point = PyString_FromString(lc->decimal_point); - if (saved_numeric) - free(saved_numeric); - saved_numeric = strdup(locale); - /* restore to "C" */ - setlocale(LC_NUMERIC, "C"); - } - } - /* record changes to LC_CTYPE */ - if (category == LC_CTYPE || category == LC_ALL) - fixup_ulcase(); - /* things that got wrong up to here are ignored */ - PyErr_Clear(); - } else { - /* get locale */ - /* restore LC_NUMERIC first, if appropriate */ - if (saved_numeric) - setlocale(LC_NUMERIC, saved_numeric); - result = setlocale(category, NULL); - if (!result) { - PyErr_SetString(Error, "locale query failed"); - return NULL; - } - result_object = PyString_FromString(result); - /* restore back to "C" */ - if (saved_numeric) - setlocale(LC_NUMERIC, "C"); - } - return result_object; -} - -PyDoc_STRVAR(localeconv__doc__, -"() -> dict. Returns numeric and monetary locale-specific parameters."); - -static PyObject* -PyLocale_localeconv(PyObject* self) -{ - PyObject* result; - struct lconv *l; - PyObject *x; - - result = PyDict_New(); - if (!result) - return NULL; - - /* if LC_NUMERIC is different in the C library, use saved value */ - l = localeconv(); - - /* hopefully, the localeconv result survives the C library calls - involved herein */ - -#define RESULT_STRING(s)\ - x = PyString_FromString(l->s);\ - if (!x) goto failed;\ - PyDict_SetItemString(result, #s, x);\ - Py_XDECREF(x) - -#define RESULT_INT(i)\ - x = PyInt_FromLong(l->i);\ - if (!x) goto failed;\ - PyDict_SetItemString(result, #i, x);\ - Py_XDECREF(x) - - /* Numeric information */ - if (saved_numeric){ - /* cannot use localeconv results */ - PyDict_SetItemString(result, "decimal_point", decimal_point); - PyDict_SetItemString(result, "grouping", grouping); - PyDict_SetItemString(result, "thousands_sep", thousands_sep); - } else { - RESULT_STRING(decimal_point); - RESULT_STRING(thousands_sep); - x = copy_grouping(l->grouping); - if (!x) - goto failed; - PyDict_SetItemString(result, "grouping", x); - Py_XDECREF(x); - } - - /* Monetary information */ - RESULT_STRING(int_curr_symbol); - RESULT_STRING(currency_symbol); - RESULT_STRING(mon_decimal_point); - RESULT_STRING(mon_thousands_sep); - x = copy_grouping(l->mon_grouping); - if (!x) - goto failed; - PyDict_SetItemString(result, "mon_grouping", x); - Py_XDECREF(x); - RESULT_STRING(positive_sign); - RESULT_STRING(negative_sign); - RESULT_INT(int_frac_digits); - RESULT_INT(frac_digits); - RESULT_INT(p_cs_precedes); - RESULT_INT(p_sep_by_space); - RESULT_INT(n_cs_precedes); - RESULT_INT(n_sep_by_space); - RESULT_INT(p_sign_posn); - RESULT_INT(n_sign_posn); - return result; - - failed: - Py_XDECREF(result); - Py_XDECREF(x); - return NULL; -} - -PyDoc_STRVAR(strcoll__doc__, -"string,string -> int. Compares two strings according to the locale."); - -static PyObject* -PyLocale_strcoll(PyObject* self, PyObject* args) -{ -#if !defined(HAVE_WCSCOLL) || !defined(Py_USING_UNICODE) - char *s1,*s2; - - if (!PyArg_ParseTuple(args, "ss:strcoll", &s1, &s2)) - return NULL; - return PyInt_FromLong(strcoll(s1, s2)); -#else - PyObject *os1, *os2, *result = NULL; - wchar_t *ws1 = NULL, *ws2 = NULL; - int rel1 = 0, rel2 = 0, len1, len2; - - if (!PyArg_ParseTuple(args, "OO:strcoll", &os1, &os2)) - return NULL; - /* If both arguments are byte strings, use strcoll. */ - if (PyString_Check(os1) && PyString_Check(os2)) - return PyInt_FromLong(strcoll(PyString_AS_STRING(os1), - PyString_AS_STRING(os2))); - /* If neither argument is unicode, it's an error. */ - if (!PyUnicode_Check(os1) && !PyUnicode_Check(os2)) { - PyErr_SetString(PyExc_ValueError, "strcoll arguments must be strings"); - } - /* Convert the non-unicode argument to unicode. */ - if (!PyUnicode_Check(os1)) { - os1 = PyUnicode_FromObject(os1); - if (!os1) - return NULL; - rel1 = 1; - } - if (!PyUnicode_Check(os2)) { - os2 = PyUnicode_FromObject(os2); - if (!os2) { - Py_DECREF(os1); - return NULL; - } - rel2 = 1; - } - /* Convert the unicode strings to wchar[]. */ - len1 = PyUnicode_GET_SIZE(os1) + 1; - len2 = PyUnicode_GET_SIZE(os2) + 1; - ws1 = PyMem_MALLOC(len1 * sizeof(wchar_t)); - if (!ws1) { - PyErr_NoMemory(); - goto done; - } - if (PyUnicode_AsWideChar((PyUnicodeObject*)os1, ws1, len1) == -1) - goto done; - ws2 = PyMem_MALLOC(len2 * sizeof(wchar_t)); - if (!ws2) { - PyErr_NoMemory(); - goto done; - } - if (PyUnicode_AsWideChar((PyUnicodeObject*)os2, ws2, len2) == -1) - goto done; - /* Collate the strings. */ - result = PyInt_FromLong(wcscoll(ws1, ws2)); - done: - /* Deallocate everything. */ - if (ws1) PyMem_FREE(ws1); - if (ws2) PyMem_FREE(ws2); - if (rel1) { - Py_DECREF(os1); - } - if (rel2) { - Py_DECREF(os2); - } - return result; -#endif -} - - -PyDoc_STRVAR(strxfrm__doc__, -"string -> string. Returns a string that behaves for cmp locale-aware."); - -static PyObject* -PyLocale_strxfrm(PyObject* self, PyObject* args) -{ - char *s, *buf; - size_t n1, n2; - PyObject *result; - - if (!PyArg_ParseTuple(args, "s:strxfrm", &s)) - return NULL; - - /* assume no change in size, first */ - n1 = strlen(s) + 1; - buf = PyMem_Malloc(n1); - if (!buf) - return PyErr_NoMemory(); - n2 = strxfrm(buf, s, n1); - if (n2 > n1) { - /* more space needed */ - buf = PyMem_Realloc(buf, n2); - if (!buf) - return PyErr_NoMemory(); - strxfrm(buf, s, n2); - } - result = PyString_FromString(buf); - PyMem_Free(buf); - return result; -} - -#if defined(MS_WINDOWS) && !defined(MS_XBOX) -static PyObject* -PyLocale_getdefaultlocale(PyObject* self) -{ - char encoding[100]; - char locale[100]; - - PyOS_snprintf(encoding, sizeof(encoding), "cp%d", GetACP()); - - if (GetLocaleInfo(LOCALE_USER_DEFAULT, - LOCALE_SISO639LANGNAME, - locale, sizeof(locale))) { - int i = strlen(locale); - locale[i++] = '_'; - if (GetLocaleInfo(LOCALE_USER_DEFAULT, - LOCALE_SISO3166CTRYNAME, - locale+i, sizeof(locale)-i)) - return Py_BuildValue("ss", locale, encoding); - } - - /* If we end up here, this windows version didn't know about - ISO639/ISO3166 names (it's probably Windows 95). Return the - Windows language identifier instead (a hexadecimal number) */ - - locale[0] = '0'; - locale[1] = 'x'; - if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTLANGUAGE, - locale+2, sizeof(locale)-2)) { - return Py_BuildValue("ss", locale, encoding); - } - - /* cannot determine the language code (very unlikely) */ - Py_INCREF(Py_None); - return Py_BuildValue("Os", Py_None, encoding); -} -#endif - -#if defined(__APPLE__) -static PyObject* -PyLocale_getdefaultlocale(PyObject* self) -{ - return Py_BuildValue("Os", Py_None, PyMac_getscript()); -} -#endif - -#ifdef HAVE_LANGINFO_H -#define LANGINFO(X) {#X, X} -struct langinfo_constant{ - char* name; - int value; -} langinfo_constants[] = -{ - /* These constants should exist on any langinfo implementation */ - LANGINFO(DAY_1), - LANGINFO(DAY_2), - LANGINFO(DAY_3), - LANGINFO(DAY_4), - LANGINFO(DAY_5), - LANGINFO(DAY_6), - LANGINFO(DAY_7), - - LANGINFO(ABDAY_1), - LANGINFO(ABDAY_2), - LANGINFO(ABDAY_3), - LANGINFO(ABDAY_4), - LANGINFO(ABDAY_5), - LANGINFO(ABDAY_6), - LANGINFO(ABDAY_7), - - LANGINFO(MON_1), - LANGINFO(MON_2), - LANGINFO(MON_3), - LANGINFO(MON_4), - LANGINFO(MON_5), - LANGINFO(MON_6), - LANGINFO(MON_7), - LANGINFO(MON_8), - LANGINFO(MON_9), - LANGINFO(MON_10), - LANGINFO(MON_11), - LANGINFO(MON_12), - - LANGINFO(ABMON_1), - LANGINFO(ABMON_2), - LANGINFO(ABMON_3), - LANGINFO(ABMON_4), - LANGINFO(ABMON_5), - LANGINFO(ABMON_6), - LANGINFO(ABMON_7), - LANGINFO(ABMON_8), - LANGINFO(ABMON_9), - LANGINFO(ABMON_10), - LANGINFO(ABMON_11), - LANGINFO(ABMON_12), - -#ifdef RADIXCHAR - /* The following are not available with glibc 2.0 */ - LANGINFO(RADIXCHAR), - LANGINFO(THOUSEP), - /* YESSTR and NOSTR are deprecated in glibc, since they are - a special case of message translation, which should be rather - done using gettext. So we don't expose it to Python in the - first place. - LANGINFO(YESSTR), - LANGINFO(NOSTR), - */ - LANGINFO(CRNCYSTR), -#endif - - LANGINFO(D_T_FMT), - LANGINFO(D_FMT), - LANGINFO(T_FMT), - LANGINFO(AM_STR), - LANGINFO(PM_STR), - - /* The following constants are available only with XPG4, but... - AIX 3.2. only has CODESET. - OpenBSD doesn't have CODESET but has T_FMT_AMPM, and doesn't have - a few of the others. - Solution: ifdef-test them all. */ -#ifdef CODESET - LANGINFO(CODESET), -#endif -#ifdef T_FMT_AMPM - LANGINFO(T_FMT_AMPM), -#endif -#ifdef ERA - LANGINFO(ERA), -#endif -#ifdef ERA_D_FMT - LANGINFO(ERA_D_FMT), -#endif -#ifdef ERA_D_T_FMT - LANGINFO(ERA_D_T_FMT), -#endif -#ifdef ERA_T_FMT - LANGINFO(ERA_T_FMT), -#endif -#ifdef ALT_DIGITS - LANGINFO(ALT_DIGITS), -#endif -#ifdef YESEXPR - LANGINFO(YESEXPR), -#endif -#ifdef NOEXPR - LANGINFO(NOEXPR), -#endif -#ifdef _DATE_FMT - /* This is not available in all glibc versions that have CODESET. */ - LANGINFO(_DATE_FMT), -#endif - {0, 0} -}; - -PyDoc_STRVAR(nl_langinfo__doc__, -"nl_langinfo(key) -> string\n" -"Return the value for the locale information associated with key."); - -static PyObject* -PyLocale_nl_langinfo(PyObject* self, PyObject* args) -{ - int item, i; - if (!PyArg_ParseTuple(args, "i:nl_langinfo", &item)) - return NULL; - /* Check whether this is a supported constant. GNU libc sometimes - returns numeric values in the char* return value, which would - crash PyString_FromString. */ -#ifdef RADIXCHAR - if (saved_numeric) { - if(item == RADIXCHAR) { - Py_INCREF(decimal_point); - return decimal_point; - } - if(item == THOUSEP) { - Py_INCREF(thousands_sep); - return thousands_sep; - } - } -#endif - for (i = 0; langinfo_constants[i].name; i++) - if (langinfo_constants[i].value == item) - return PyString_FromString(nl_langinfo(item)); - PyErr_SetString(PyExc_ValueError, "unsupported langinfo constant"); - return NULL; -} -#endif /* HAVE_LANGINFO_H */ - -#ifdef HAVE_LIBINTL_H - -PyDoc_STRVAR(gettext__doc__, -"gettext(msg) -> string\n" -"Return translation of msg."); - -static PyObject* -PyIntl_gettext(PyObject* self, PyObject *args) -{ - char *in; - if (!PyArg_ParseTuple(args, "z", &in)) - return 0; - return PyString_FromString(gettext(in)); -} - -PyDoc_STRVAR(dgettext__doc__, -"dgettext(domain, msg) -> string\n" -"Return translation of msg in domain."); - -static PyObject* -PyIntl_dgettext(PyObject* self, PyObject *args) -{ - char *domain, *in; - if (!PyArg_ParseTuple(args, "zz", &domain, &in)) - return 0; - return PyString_FromString(dgettext(domain, in)); -} - -PyDoc_STRVAR(dcgettext__doc__, -"dcgettext(domain, msg, category) -> string\n" -"Return translation of msg in domain and category."); - -static PyObject* -PyIntl_dcgettext(PyObject *self, PyObject *args) -{ - char *domain, *msgid; - int category; - if (!PyArg_ParseTuple(args, "zzi", &domain, &msgid, &category)) - return 0; - return PyString_FromString(dcgettext(domain,msgid,category)); -} - -PyDoc_STRVAR(textdomain__doc__, -"textdomain(domain) -> string\n" -"Set the C library's textdmain to domain, returning the new domain."); - -static PyObject* -PyIntl_textdomain(PyObject* self, PyObject* args) -{ - char *domain; - if (!PyArg_ParseTuple(args, "z", &domain)) - return 0; - domain = textdomain(domain); - if (!domain) { - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - return PyString_FromString(domain); -} - -PyDoc_STRVAR(bindtextdomain__doc__, -"bindtextdomain(domain, dir) -> string\n" -"Bind the C library's domain to dir."); - -static PyObject* -PyIntl_bindtextdomain(PyObject* self,PyObject*args) -{ - char *domain,*dirname; - if (!PyArg_ParseTuple(args, "zz", &domain, &dirname)) - return 0; - dirname = bindtextdomain(domain, dirname); - if (!dirname) { - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - return PyString_FromString(dirname); -} - -#endif - -static struct PyMethodDef PyLocale_Methods[] = { - {"setlocale", (PyCFunction) PyLocale_setlocale, - METH_VARARGS, setlocale__doc__}, - {"localeconv", (PyCFunction) PyLocale_localeconv, - METH_NOARGS, localeconv__doc__}, - {"strcoll", (PyCFunction) PyLocale_strcoll, - METH_VARARGS, strcoll__doc__}, - {"strxfrm", (PyCFunction) PyLocale_strxfrm, - METH_VARARGS, strxfrm__doc__}, -#if (defined(MS_WINDOWS) && !defined(MS_XBOX)) || defined(__APPLE__) - {"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, METH_NOARGS}, -#endif -#ifdef HAVE_LANGINFO_H - {"nl_langinfo", (PyCFunction) PyLocale_nl_langinfo, - METH_VARARGS, nl_langinfo__doc__}, -#endif -#ifdef HAVE_LIBINTL_H - {"gettext",(PyCFunction)PyIntl_gettext,METH_VARARGS, - gettext__doc__}, - {"dgettext",(PyCFunction)PyIntl_dgettext,METH_VARARGS, - dgettext__doc__}, - {"dcgettext",(PyCFunction)PyIntl_dcgettext,METH_VARARGS, - dcgettext__doc__}, - {"textdomain",(PyCFunction)PyIntl_textdomain,METH_VARARGS, - textdomain__doc__}, - {"bindtextdomain",(PyCFunction)PyIntl_bindtextdomain,METH_VARARGS, - bindtextdomain__doc__}, -#endif - {NULL, NULL} -}; - -PyMODINIT_FUNC -init_locale(void) -{ - PyObject *m, *d, *x; -#ifdef HAVE_LANGINFO_H - int i; -#endif - - m = Py_InitModule("_locale", PyLocale_Methods); - - d = PyModule_GetDict(m); - - x = PyInt_FromLong(LC_CTYPE); - PyDict_SetItemString(d, "LC_CTYPE", x); - Py_XDECREF(x); - - x = PyInt_FromLong(LC_TIME); - PyDict_SetItemString(d, "LC_TIME", x); - Py_XDECREF(x); - - x = PyInt_FromLong(LC_COLLATE); - PyDict_SetItemString(d, "LC_COLLATE", x); - Py_XDECREF(x); - - x = PyInt_FromLong(LC_MONETARY); - PyDict_SetItemString(d, "LC_MONETARY", x); - Py_XDECREF(x); - -#ifdef LC_MESSAGES - x = PyInt_FromLong(LC_MESSAGES); - PyDict_SetItemString(d, "LC_MESSAGES", x); - Py_XDECREF(x); -#endif /* LC_MESSAGES */ - - x = PyInt_FromLong(LC_NUMERIC); - PyDict_SetItemString(d, "LC_NUMERIC", x); - Py_XDECREF(x); - - x = PyInt_FromLong(LC_ALL); - PyDict_SetItemString(d, "LC_ALL", x); - Py_XDECREF(x); - - x = PyInt_FromLong(CHAR_MAX); - PyDict_SetItemString(d, "CHAR_MAX", x); - Py_XDECREF(x); - - Error = PyErr_NewException("locale.Error", NULL, NULL); - PyDict_SetItemString(d, "Error", Error); - - x = PyString_FromString(locale__doc__); - PyDict_SetItemString(d, "__doc__", x); - Py_XDECREF(x); - -#ifdef HAVE_LANGINFO_H - for (i = 0; langinfo_constants[i].name; i++) { - PyModule_AddIntConstant(m, langinfo_constants[i].name, - langinfo_constants[i].value); - } -#endif -} - -/* -Local variables: -c-basic-offset: 4 -indent-tabs-mode: nil -End: -*/ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/_randommodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/_randommodule.c deleted file mode 100644 index d59b316c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/_randommodule.c +++ /dev/null @@ -1,531 +0,0 @@ -/* Random objects */ - -/* ------------------------------------------------------------------ - The code in this module was based on a download from: - http://www.math.keio.ac.jp/~matumoto/MT2002/emt19937ar.html - - It was modified in 2002 by Raymond Hettinger as follows: - - * the principal computational lines untouched except for tabbing. - - * renamed genrand_res53() to random_random() and wrapped - in python calling/return code. - - * genrand_int32() and the helper functions, init_genrand() - and init_by_array(), were declared static, wrapped in - Python calling/return code. also, their global data - references were replaced with structure references. - - * unused functions from the original were deleted. - new, original C python code was added to implement the - Random() interface. - - The following are the verbatim comments from the original code: - - A C-program for MT19937, with initialization improved 2002/1/26. - Coded by Takuji Nishimura and Makoto Matsumoto. - - Before using, initialize the state by using init_genrand(seed) - or init_by_array(init_key, key_length). - - Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The names of its contributors may not be used to endorse or promote - products derived from this software without specific prior written - permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - Any feedback is very welcome. - http://www.math.keio.ac.jp/matumoto/emt.html - email: matumoto@math.keio.ac.jp -*/ - -/* ---------------------------------------------------------------*/ - -#include "Python.h" -#include /* for seeding to current time */ - -/* Period parameters -- These are all magic. Don't change. */ -#define N 624 -#define M 397 -#define MATRIX_A 0x9908b0dfUL /* constant vector a */ -#define UPPER_MASK 0x80000000UL /* most significant w-r bits */ -#define LOWER_MASK 0x7fffffffUL /* least significant r bits */ - -typedef struct { - PyObject_HEAD - unsigned long state[N]; - int index; -} RandomObject; - -static PyTypeObject Random_Type; - -#define RandomObject_Check(v) ((v)->ob_type == &Random_Type) - - -/* Random methods */ - - -/* generates a random number on [0,0xffffffff]-interval */ -static unsigned long -genrand_int32(RandomObject *self) -{ - unsigned long y; - static unsigned long mag01[2]={0x0UL, MATRIX_A}; - /* mag01[x] = x * MATRIX_A for x=0,1 */ - unsigned long *mt; - - mt = self->state; - if (self->index >= N) { /* generate N words at one time */ - int kk; - - for (kk=0;kk> 1) ^ mag01[y & 0x1UL]; - } - for (;kk> 1) ^ mag01[y & 0x1UL]; - } - y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL]; - - self->index = 0; - } - - y = mt[self->index++]; - y ^= (y >> 11); - y ^= (y << 7) & 0x9d2c5680UL; - y ^= (y << 15) & 0xefc60000UL; - y ^= (y >> 18); - return y; -} - -/* random_random is the function named genrand_res53 in the original code; - * generates a random number on [0,1) with 53-bit resolution; note that - * 9007199254740992 == 2**53; I assume they're spelling "/2**53" as - * multiply-by-reciprocal in the (likely vain) hope that the compiler will - * optimize the division away at compile-time. 67108864 is 2**26. In - * effect, a contains 27 random bits shifted left 26, and b fills in the - * lower 26 bits of the 53-bit numerator. - * The orginal code credited Isaku Wada for this algorithm, 2002/01/09. - */ -static PyObject * -random_random(RandomObject *self) -{ - unsigned long a=genrand_int32(self)>>5, b=genrand_int32(self)>>6; - return PyFloat_FromDouble((a*67108864.0+b)*(1.0/9007199254740992.0)); -} - -/* initializes mt[N] with a seed */ -static void -init_genrand(RandomObject *self, unsigned long s) -{ - int mti; - unsigned long *mt; - - mt = self->state; - mt[0]= s & 0xffffffffUL; - for (mti=1; mti> 30)) + mti); - /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ - /* In the previous versions, MSBs of the seed affect */ - /* only MSBs of the array mt[]. */ - /* 2002/01/09 modified by Makoto Matsumoto */ - mt[mti] &= 0xffffffffUL; - /* for >32 bit machines */ - } - self->index = mti; - return; -} - -/* initialize by an array with array-length */ -/* init_key is the array for initializing keys */ -/* key_length is its length */ -static PyObject * -init_by_array(RandomObject *self, unsigned long init_key[], unsigned long key_length) -{ - unsigned int i, j, k; /* was signed in the original code. RDH 12/16/2002 */ - unsigned long *mt; - - mt = self->state; - init_genrand(self, 19650218UL); - i=1; j=0; - k = (N>key_length ? N : key_length); - for (; k; k--) { - mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL)) - + init_key[j] + j; /* non linear */ - mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ - i++; j++; - if (i>=N) { mt[0] = mt[N-1]; i=1; } - if (j>=key_length) j=0; - } - for (k=N-1; k; k--) { - mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL)) - - i; /* non linear */ - mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ - i++; - if (i>=N) { mt[0] = mt[N-1]; i=1; } - } - - mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ - Py_INCREF(Py_None); - return Py_None; -} - -/* - * The rest is Python-specific code, neither part of, nor derived from, the - * Twister download. - */ - -static PyObject * -random_seed(RandomObject *self, PyObject *args) -{ - PyObject *result = NULL; /* guilty until proved innocent */ - PyObject *masklower = NULL; - PyObject *thirtytwo = NULL; - PyObject *n = NULL; - unsigned long *key = NULL; - unsigned long keymax; /* # of allocated slots in key */ - unsigned long keyused; /* # of used slots in key */ - int err; - - PyObject *arg = NULL; - - if (!PyArg_UnpackTuple(args, "seed", 0, 1, &arg)) - return NULL; - - if (arg == NULL || arg == Py_None) { - time_t now; - - time(&now); - init_genrand(self, (unsigned long)now); - Py_INCREF(Py_None); - return Py_None; - } - /* If the arg is an int or long, use its absolute value; else use - * the absolute value of its hash code. - */ - if (PyInt_Check(arg) || PyLong_Check(arg)) - n = PyNumber_Absolute(arg); - else { - long hash = PyObject_Hash(arg); - if (hash == -1) - goto Done; - n = PyLong_FromUnsignedLong((unsigned long)hash); - } - if (n == NULL) - goto Done; - - /* Now split n into 32-bit chunks, from the right. Each piece is - * stored into key, which has a capacity of keymax chunks, of which - * keyused are filled. Alas, the repeated shifting makes this a - * quadratic-time algorithm; we'd really like to use - * _PyLong_AsByteArray here, but then we'd have to break into the - * long representation to figure out how big an array was needed - * in advance. - */ - keymax = 8; /* arbitrary; grows later if needed */ - keyused = 0; - key = (unsigned long *)PyMem_Malloc(keymax * sizeof(*key)); - if (key == NULL) - goto Done; - - masklower = PyLong_FromUnsignedLong(0xffffffffU); - if (masklower == NULL) - goto Done; - thirtytwo = PyInt_FromLong(32L); - if (thirtytwo == NULL) - goto Done; - while ((err=PyObject_IsTrue(n))) { - PyObject *newn; - PyObject *pychunk; - unsigned long chunk; - - if (err == -1) - goto Done; - pychunk = PyNumber_And(n, masklower); - if (pychunk == NULL) - goto Done; - chunk = PyLong_AsUnsignedLong(pychunk); - Py_DECREF(pychunk); - if (chunk == (unsigned long)-1 && PyErr_Occurred()) - goto Done; - newn = PyNumber_Rshift(n, thirtytwo); - if (newn == NULL) - goto Done; - Py_DECREF(n); - n = newn; - if (keyused >= keymax) { - unsigned long bigger = keymax << 1; - if ((bigger >> 1) != keymax) { - PyErr_NoMemory(); - goto Done; - } - key = (unsigned long *)PyMem_Realloc(key, - bigger * sizeof(*key)); - if (key == NULL) - goto Done; - keymax = bigger; - } - assert(keyused < keymax); - key[keyused++] = chunk; - } - - if (keyused == 0) - key[keyused++] = 0UL; - result = init_by_array(self, key, keyused); -Done: - Py_XDECREF(masklower); - Py_XDECREF(thirtytwo); - Py_XDECREF(n); - PyMem_Free(key); - return result; -} - -static PyObject * -random_getstate(RandomObject *self) -{ - PyObject *state; - PyObject *element; - int i; - - state = PyTuple_New(N+1); - if (state == NULL) - return NULL; - for (i=0; istate[i])); - if (element == NULL) - goto Fail; - PyTuple_SET_ITEM(state, i, element); - } - element = PyInt_FromLong((long)(self->index)); - if (element == NULL) - goto Fail; - PyTuple_SET_ITEM(state, i, element); - return state; - -Fail: - Py_DECREF(state); - return NULL; -} - -static PyObject * -random_setstate(RandomObject *self, PyObject *state) -{ - int i; - long element; - - if (!PyTuple_Check(state)) { - PyErr_SetString(PyExc_TypeError, - "state vector must be a tuple"); - return NULL; - } - if (PyTuple_Size(state) != N+1) { - PyErr_SetString(PyExc_ValueError, - "state vector is the wrong size"); - return NULL; - } - - for (i=0; istate[i] = (unsigned long)element; - } - - element = PyInt_AsLong(PyTuple_GET_ITEM(state, i)); - if (element == -1 && PyErr_Occurred()) - return NULL; - self->index = (int)element; - - Py_INCREF(Py_None); - return Py_None; -} - -/* -Jumpahead should be a fast way advance the generator n-steps ahead, but -lacking a formula for that, the next best is to use n and the existing -state to create a new state far away from the original. - -The generator uses constant spaced additive feedback, so shuffling the -state elements ought to produce a state which would not be encountered -(in the near term) by calls to random(). Shuffling is normally -implemented by swapping the ith element with another element ranging -from 0 to i inclusive. That allows the element to have the possibility -of not being moved. Since the goal is to produce a new, different -state, the swap element is ranged from 0 to i-1 inclusive. This assures -that each element gets moved at least once. - -To make sure that consecutive calls to jumpahead(n) produce different -states (even in the rare case of involutory shuffles), i+1 is added to -each element at position i. Successive calls are then guaranteed to -have changing (growing) values as well as shuffled positions. - -Finally, the self->index value is set to N so that the generator itself -kicks in on the next call to random(). This assures that all results -have been through the generator and do not just reflect alterations to -the underlying state. -*/ - -static PyObject * -random_jumpahead(RandomObject *self, PyObject *n) -{ - long i, j; - PyObject *iobj; - PyObject *remobj; - unsigned long *mt, tmp; - - if (!PyInt_Check(n) && !PyLong_Check(n)) { - PyErr_Format(PyExc_TypeError, "jumpahead requires an " - "integer, not '%s'", - n->ob_type->tp_name); - return NULL; - } - - mt = self->state; - for (i = N-1; i > 1; i--) { - iobj = PyInt_FromLong(i); - if (iobj == NULL) - return NULL; - remobj = PyNumber_Remainder(n, iobj); - Py_DECREF(iobj); - if (remobj == NULL) - return NULL; - j = PyInt_AsLong(remobj); - Py_DECREF(remobj); - if (j == -1L && PyErr_Occurred()) - return NULL; - tmp = mt[i]; - mt[i] = mt[j]; - mt[j] = tmp; - } - - for (i = 0; i < N; i++) - mt[i] += i+1; - - self->index = N; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -random_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - RandomObject *self; - PyObject *tmp; - - self = (RandomObject *)type->tp_alloc(type, 0); - if (self == NULL) - return NULL; - tmp = random_seed(self, args); - if (tmp == NULL) { - Py_DECREF(self); - return NULL; - } - Py_DECREF(tmp); - return (PyObject *)self; -} - -static PyMethodDef random_methods[] = { - {"random", (PyCFunction)random_random, METH_NOARGS, - PyDoc_STR("random() -> x in the interval [0, 1).")}, - {"seed", (PyCFunction)random_seed, METH_VARARGS, - PyDoc_STR("seed([n]) -> None. Defaults to current time.")}, - {"getstate", (PyCFunction)random_getstate, METH_NOARGS, - PyDoc_STR("getstate() -> tuple containing the current state.")}, - {"setstate", (PyCFunction)random_setstate, METH_O, - PyDoc_STR("setstate(state) -> None. Restores generator state.")}, - {"jumpahead", (PyCFunction)random_jumpahead, METH_O, - PyDoc_STR("jumpahead(int) -> None. Create new state from " - "existing state and integer.")}, - {NULL, NULL} /* sentinel */ -}; - -PyDoc_STRVAR(random_doc, -"Random() -> create a random number generator with its own internal state."); - -static PyTypeObject Random_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "_random.Random", /*tp_name*/ - sizeof(RandomObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - 0, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - PyObject_GenericGetAttr, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - random_doc, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - random_methods, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - random_new, /*tp_new*/ - _PyObject_Del, /*tp_free*/ - 0, /*tp_is_gc*/ -}; - -PyDoc_STRVAR(module_doc, -"Module implements the Mersenne Twister random number generator."); - -PyMODINIT_FUNC -init_random(void) -{ - PyObject *m; - - if (PyType_Ready(&Random_Type) < 0) - return; - m = Py_InitModule3("_random", NULL, module_doc); - Py_INCREF(&Random_Type); - PyModule_AddObject(m, "Random", (PyObject *)&Random_Type); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/_sre.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/_sre.c deleted file mode 100644 index 14bdeedf..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/_sre.c +++ /dev/null @@ -1,3166 +0,0 @@ -/* - * Secret Labs' Regular Expression Engine - * - * regular expression matching engine - * - * partial history: - * 1999-10-24 fl created (based on existing template matcher code) - * 2000-03-06 fl first alpha, sort of - * 2000-08-01 fl fixes for 1.6b1 - * 2000-08-07 fl use PyOS_CheckStack() if available - * 2000-09-20 fl added expand method - * 2001-03-20 fl lots of fixes for 2.1b2 - * 2001-04-15 fl export copyright as Python attribute, not global - * 2001-04-28 fl added __copy__ methods (work in progress) - * 2001-05-14 fl fixes for 1.5.2 compatibility - * 2001-07-01 fl added BIGCHARSET support (from Martin von Loewis) - * 2001-10-18 fl fixed group reset issue (from Matthew Mueller) - * 2001-10-20 fl added split primitive; reenable unicode for 1.6/2.0/2.1 - * 2001-10-21 fl added sub/subn primitive - * 2001-10-24 fl added finditer primitive (for 2.2 only) - * 2001-12-07 fl fixed memory leak in sub/subn (Guido van Rossum) - * 2002-11-09 fl fixed empty sub/subn return type - * 2003-04-18 mvl fully support 4-byte codes - * - * Copyright (c) 1997-2001 by Secret Labs AB. All rights reserved. - * - * This version of the SRE library can be redistributed under CNRI's - * Python 1.6 license. For any other use, please contact Secret Labs - * AB (info@pythonware.com). - * - * Portions of this engine have been developed in cooperation with - * CNRI. Hewlett-Packard provided funding for 1.6 integration and - * other compatibility work. - */ - -#ifndef SRE_RECURSIVE - -static char copyright[] = - " SRE 2.2.2 Copyright (c) 1997-2002 by Secret Labs AB "; - -#include "Python.h" -#include "structmember.h" /* offsetof */ - -#include "sre.h" - -#include - -/* name of this module, minus the leading underscore */ -#if !defined(SRE_MODULE) -#define SRE_MODULE "sre" -#endif - -/* defining this one enables tracing */ -#undef VERBOSE - -#if PY_VERSION_HEX >= 0x01060000 -#if PY_VERSION_HEX < 0x02020000 || defined(Py_USING_UNICODE) -/* defining this enables unicode support (default under 1.6a1 and later) */ -#define HAVE_UNICODE -#endif -#endif - -/* -------------------------------------------------------------------- */ -/* optional features */ - -/* prevent run-away recursion (bad patterns on long strings) */ - -#ifndef USE_STACKCHECK - #if defined(MS_WIN64) || defined(__LP64__) || defined(_LP64) - /* require smaller recursion limit for a number of 64-bit platforms: - * Win64 (MS_WIN64), Linux64 (__LP64__), Monterey (64-bit AIX) (_LP64) - */ - /* FIXME: maybe the limit should be 40000 / sizeof(void*) ? */ - #define USE_RECURSION_LIMIT 7500 - - #elif defined(__FreeBSD__) - /* FreeBSD/amd64 and /sparc64 require even smaller limits */ - #if defined(__amd64__) - #define USE_RECURSION_LIMIT 6000 - #elif defined(__sparc64__) - #define USE_RECURSION_LIMIT 3000 - #elif defined(__GNUC__) && defined(WITH_THREAD) - /* the pthreads library on FreeBSD has a fixed 1MB stack size for - * the initial (or "primary") thread, which is insufficient for - * the default recursion limit. gcc 3.x at the default - * optimisation level (-O3) uses stack space more aggressively - * than gcc 2.95. - */ - #if (__GNUC__ > 2) - #define USE_RECURSION_LIMIT 6500 - #else - #define USE_RECURSION_LIMIT 7500 - #endif - #endif - #endif /* special cases for USE_RECURSION_LIMIT */ - - #ifndef USE_RECURSION_LIMIT /* default if not overriden above */ - #define USE_RECURSION_LIMIT 10000 - #endif -#endif /* !USE_STACKCHECK */ - -/* enables fast searching */ -#define USE_FAST_SEARCH - -/* enables aggressive inlining (always on for Visual C) */ -#undef USE_INLINE - -/* enables copy/deepcopy handling (work in progress) */ -#undef USE_BUILTIN_COPY - -#if PY_VERSION_HEX < 0x01060000 -#define PyObject_DEL(op) PyMem_DEL((op)) -#endif - -/* -------------------------------------------------------------------- */ - -#if defined(_MSC_VER) -#pragma optimize("agtw", on) /* doesn't seem to make much difference... */ -#pragma warning(disable: 4710) /* who cares if functions are not inlined ;-) */ -/* fastest possible local call under MSVC */ -#define LOCAL(type) static __inline type __fastcall -#elif defined(USE_INLINE) -#define LOCAL(type) static inline type -#else -#define LOCAL(type) static type -#endif - -/* error codes */ -#define SRE_ERROR_ILLEGAL -1 /* illegal opcode */ -#define SRE_ERROR_STATE -2 /* illegal state */ -#define SRE_ERROR_RECURSION_LIMIT -3 /* runaway recursion */ -#define SRE_ERROR_MEMORY -9 /* out of memory */ - -#if defined(VERBOSE) -#define TRACE(v) printf v -#else -#define TRACE(v) -#endif - -/* -------------------------------------------------------------------- */ -/* search engine state */ - -/* default character predicates (run sre_chars.py to regenerate tables) */ - -#define SRE_DIGIT_MASK 1 -#define SRE_SPACE_MASK 2 -#define SRE_LINEBREAK_MASK 4 -#define SRE_ALNUM_MASK 8 -#define SRE_WORD_MASK 16 - -/* FIXME: this assumes ASCII. create tables in init_sre() instead */ - -static char sre_char_info[128] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 2, -2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, -25, 25, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, -0, 0, 16, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0 }; - -static char sre_char_lower[128] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, -27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, -44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, -61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, -108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, -122, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, -106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, -120, 121, 122, 123, 124, 125, 126, 127 }; - -#define SRE_IS_DIGIT(ch)\ - ((ch) < 128 ? (sre_char_info[(ch)] & SRE_DIGIT_MASK) : 0) -#define SRE_IS_SPACE(ch)\ - ((ch) < 128 ? (sre_char_info[(ch)] & SRE_SPACE_MASK) : 0) -#define SRE_IS_LINEBREAK(ch)\ - ((ch) < 128 ? (sre_char_info[(ch)] & SRE_LINEBREAK_MASK) : 0) -#define SRE_IS_ALNUM(ch)\ - ((ch) < 128 ? (sre_char_info[(ch)] & SRE_ALNUM_MASK) : 0) -#define SRE_IS_WORD(ch)\ - ((ch) < 128 ? (sre_char_info[(ch)] & SRE_WORD_MASK) : 0) - -static unsigned int sre_lower(unsigned int ch) -{ - return ((ch) < 128 ? sre_char_lower[ch] : ch); -} - -/* locale-specific character predicates */ - -#define SRE_LOC_IS_DIGIT(ch) ((ch) < 256 ? isdigit((ch)) : 0) -#define SRE_LOC_IS_SPACE(ch) ((ch) < 256 ? isspace((ch)) : 0) -#define SRE_LOC_IS_LINEBREAK(ch) ((ch) == '\n') -#define SRE_LOC_IS_ALNUM(ch) ((ch) < 256 ? isalnum((ch)) : 0) -#define SRE_LOC_IS_WORD(ch) (SRE_LOC_IS_ALNUM((ch)) || (ch) == '_') - -static unsigned int sre_lower_locale(unsigned int ch) -{ - return ((ch) < 256 ? tolower((ch)) : ch); -} - -/* unicode-specific character predicates */ - -#if defined(HAVE_UNICODE) - -#define SRE_UNI_IS_DIGIT(ch) Py_UNICODE_ISDIGIT((Py_UNICODE)(ch)) -#define SRE_UNI_IS_SPACE(ch) Py_UNICODE_ISSPACE((Py_UNICODE)(ch)) -#define SRE_UNI_IS_LINEBREAK(ch) Py_UNICODE_ISLINEBREAK((Py_UNICODE)(ch)) -#define SRE_UNI_IS_ALNUM(ch) Py_UNICODE_ISALNUM((Py_UNICODE)(ch)) -#define SRE_UNI_IS_WORD(ch) (SRE_UNI_IS_ALNUM((ch)) || (ch) == '_') - -static unsigned int sre_lower_unicode(unsigned int ch) -{ - return (unsigned int) Py_UNICODE_TOLOWER((Py_UNICODE)(ch)); -} - -#endif /* HAVE_UNICODE */ - -LOCAL(int) -sre_category(SRE_CODE category, unsigned int ch) -{ - switch (category) { - - case SRE_CATEGORY_DIGIT: - return SRE_IS_DIGIT(ch); - case SRE_CATEGORY_NOT_DIGIT: - return !SRE_IS_DIGIT(ch); - case SRE_CATEGORY_SPACE: - return SRE_IS_SPACE(ch); - case SRE_CATEGORY_NOT_SPACE: - return !SRE_IS_SPACE(ch); - case SRE_CATEGORY_WORD: - return SRE_IS_WORD(ch); - case SRE_CATEGORY_NOT_WORD: - return !SRE_IS_WORD(ch); - case SRE_CATEGORY_LINEBREAK: - return SRE_IS_LINEBREAK(ch); - case SRE_CATEGORY_NOT_LINEBREAK: - return !SRE_IS_LINEBREAK(ch); - - case SRE_CATEGORY_LOC_WORD: - return SRE_LOC_IS_WORD(ch); - case SRE_CATEGORY_LOC_NOT_WORD: - return !SRE_LOC_IS_WORD(ch); - -#if defined(HAVE_UNICODE) - case SRE_CATEGORY_UNI_DIGIT: - return SRE_UNI_IS_DIGIT(ch); - case SRE_CATEGORY_UNI_NOT_DIGIT: - return !SRE_UNI_IS_DIGIT(ch); - case SRE_CATEGORY_UNI_SPACE: - return SRE_UNI_IS_SPACE(ch); - case SRE_CATEGORY_UNI_NOT_SPACE: - return !SRE_UNI_IS_SPACE(ch); - case SRE_CATEGORY_UNI_WORD: - return SRE_UNI_IS_WORD(ch); - case SRE_CATEGORY_UNI_NOT_WORD: - return !SRE_UNI_IS_WORD(ch); - case SRE_CATEGORY_UNI_LINEBREAK: - return SRE_UNI_IS_LINEBREAK(ch); - case SRE_CATEGORY_UNI_NOT_LINEBREAK: - return !SRE_UNI_IS_LINEBREAK(ch); -#else - case SRE_CATEGORY_UNI_DIGIT: - return SRE_IS_DIGIT(ch); - case SRE_CATEGORY_UNI_NOT_DIGIT: - return !SRE_IS_DIGIT(ch); - case SRE_CATEGORY_UNI_SPACE: - return SRE_IS_SPACE(ch); - case SRE_CATEGORY_UNI_NOT_SPACE: - return !SRE_IS_SPACE(ch); - case SRE_CATEGORY_UNI_WORD: - return SRE_LOC_IS_WORD(ch); - case SRE_CATEGORY_UNI_NOT_WORD: - return !SRE_LOC_IS_WORD(ch); - case SRE_CATEGORY_UNI_LINEBREAK: - return SRE_IS_LINEBREAK(ch); - case SRE_CATEGORY_UNI_NOT_LINEBREAK: - return !SRE_IS_LINEBREAK(ch); -#endif - } - return 0; -} - -/* helpers */ - -static void -mark_fini(SRE_STATE* state) -{ - if (state->mark_stack) { - free(state->mark_stack); - state->mark_stack = NULL; - } - state->mark_stack_size = state->mark_stack_base = 0; -} - -static int -mark_save(SRE_STATE* state, int lo, int hi, int *mark_stack_base) -{ - void* stack; - int size; - int minsize, newsize; - - if (hi <= lo) - return 0; - - size = (hi - lo) + 1; - - newsize = state->mark_stack_size; - minsize = state->mark_stack_base + size; - - if (newsize < minsize) { - /* create new stack */ - if (!newsize) { - newsize = 512; - if (newsize < minsize) - newsize = minsize; - TRACE(("allocate stack %d\n", newsize)); - stack = malloc(sizeof(void*) * newsize); - } else { - /* grow the stack */ - while (newsize < minsize) - newsize += newsize; - TRACE(("grow stack to %d\n", newsize)); - stack = realloc(state->mark_stack, sizeof(void*) * newsize); - } - if (!stack) { - mark_fini(state); - return SRE_ERROR_MEMORY; - } - state->mark_stack = stack; - state->mark_stack_size = newsize; - } - - TRACE(("copy %d:%d to %d (%d)\n", lo, hi, state->mark_stack_base, size)); - - memcpy(state->mark_stack + state->mark_stack_base, state->mark + lo, - size * sizeof(void*)); - - state->mark_stack_base += size; - - *mark_stack_base = state->mark_stack_base; - - return 0; -} - -static int -mark_restore(SRE_STATE* state, int lo, int hi, int *mark_stack_base) -{ - int size; - - if (hi <= lo) - return 0; - - size = (hi - lo) + 1; - - state->mark_stack_base = *mark_stack_base - size; - - TRACE(("copy %d:%d from %d\n", lo, hi, state->mark_stack_base)); - - memcpy(state->mark + lo, state->mark_stack + state->mark_stack_base, - size * sizeof(void*)); - - return 0; -} - -/* generate 8-bit version */ - -#define SRE_CHAR unsigned char -#define SRE_AT sre_at -#define SRE_COUNT sre_count -#define SRE_CHARSET sre_charset -#define SRE_INFO sre_info -#define SRE_MATCH sre_match -#define SRE_SEARCH sre_search -#define SRE_LITERAL_TEMPLATE sre_literal_template - -#if defined(HAVE_UNICODE) - -#define SRE_RECURSIVE -#include "_sre.c" -#undef SRE_RECURSIVE - -#undef SRE_LITERAL_TEMPLATE -#undef SRE_SEARCH -#undef SRE_MATCH -#undef SRE_INFO -#undef SRE_CHARSET -#undef SRE_COUNT -#undef SRE_AT -#undef SRE_CHAR - -/* generate 16-bit unicode version */ - -#define SRE_CHAR Py_UNICODE -#define SRE_AT sre_uat -#define SRE_COUNT sre_ucount -#define SRE_CHARSET sre_ucharset -#define SRE_INFO sre_uinfo -#define SRE_MATCH sre_umatch -#define SRE_SEARCH sre_usearch -#define SRE_LITERAL_TEMPLATE sre_uliteral_template -#endif - -#endif /* SRE_RECURSIVE */ - -/* -------------------------------------------------------------------- */ -/* String matching engine */ - -/* the following section is compiled twice, with different character - settings */ - -LOCAL(int) -SRE_AT(SRE_STATE* state, SRE_CHAR* ptr, SRE_CODE at) -{ - /* check if pointer is at given position */ - - int this, that; - - switch (at) { - - case SRE_AT_BEGINNING: - case SRE_AT_BEGINNING_STRING: - return ((void*) ptr == state->beginning); - - case SRE_AT_BEGINNING_LINE: - return ((void*) ptr == state->beginning || - SRE_IS_LINEBREAK((int) ptr[-1])); - - case SRE_AT_END: - return (((void*) (ptr+1) == state->end && - SRE_IS_LINEBREAK((int) ptr[0])) || - ((void*) ptr == state->end)); - - case SRE_AT_END_LINE: - return ((void*) ptr == state->end || - SRE_IS_LINEBREAK((int) ptr[0])); - - case SRE_AT_END_STRING: - return ((void*) ptr == state->end); - - case SRE_AT_BOUNDARY: - if (state->beginning == state->end) - return 0; - that = ((void*) ptr > state->beginning) ? - SRE_IS_WORD((int) ptr[-1]) : 0; - this = ((void*) ptr < state->end) ? - SRE_IS_WORD((int) ptr[0]) : 0; - return this != that; - - case SRE_AT_NON_BOUNDARY: - if (state->beginning == state->end) - return 0; - that = ((void*) ptr > state->beginning) ? - SRE_IS_WORD((int) ptr[-1]) : 0; - this = ((void*) ptr < state->end) ? - SRE_IS_WORD((int) ptr[0]) : 0; - return this == that; - - case SRE_AT_LOC_BOUNDARY: - if (state->beginning == state->end) - return 0; - that = ((void*) ptr > state->beginning) ? - SRE_LOC_IS_WORD((int) ptr[-1]) : 0; - this = ((void*) ptr < state->end) ? - SRE_LOC_IS_WORD((int) ptr[0]) : 0; - return this != that; - - case SRE_AT_LOC_NON_BOUNDARY: - if (state->beginning == state->end) - return 0; - that = ((void*) ptr > state->beginning) ? - SRE_LOC_IS_WORD((int) ptr[-1]) : 0; - this = ((void*) ptr < state->end) ? - SRE_LOC_IS_WORD((int) ptr[0]) : 0; - return this == that; - -#if defined(HAVE_UNICODE) - case SRE_AT_UNI_BOUNDARY: - if (state->beginning == state->end) - return 0; - that = ((void*) ptr > state->beginning) ? - SRE_UNI_IS_WORD((int) ptr[-1]) : 0; - this = ((void*) ptr < state->end) ? - SRE_UNI_IS_WORD((int) ptr[0]) : 0; - return this != that; - - case SRE_AT_UNI_NON_BOUNDARY: - if (state->beginning == state->end) - return 0; - that = ((void*) ptr > state->beginning) ? - SRE_UNI_IS_WORD((int) ptr[-1]) : 0; - this = ((void*) ptr < state->end) ? - SRE_UNI_IS_WORD((int) ptr[0]) : 0; - return this == that; -#endif - - } - - return 0; -} - -LOCAL(int) -SRE_CHARSET(SRE_CODE* set, SRE_CODE ch) -{ - /* check if character is a member of the given set */ - - int ok = 1; - - for (;;) { - switch (*set++) { - - case SRE_OP_LITERAL: - /* */ - if (ch == set[0]) - return ok; - set++; - break; - - case SRE_OP_RANGE: - /* */ - if (set[0] <= ch && ch <= set[1]) - return ok; - set += 2; - break; - - case SRE_OP_CHARSET: - if (sizeof(SRE_CODE) == 2) { - /* (16 bits per code word) */ - if (ch < 256 && (set[ch >> 4] & (1 << (ch & 15)))) - return ok; - set += 16; - } - else { - /* (32 bits per code word) */ - if (ch < 256 && (set[ch >> 5] & (1 << (ch & 31)))) - return ok; - set += 8; - } - break; - - case SRE_OP_BIGCHARSET: - /* <256 blockindices> */ - { - int count, block; - count = *(set++); - - if (sizeof(SRE_CODE) == 2) { - block = ((unsigned char*)set)[ch >> 8]; - set += 128; - if (set[block*16 + ((ch & 255)>>4)] & (1 << (ch & 15))) - return ok; - set += count*16; - } - else { - if (ch < 65536) - block = ((unsigned char*)set)[ch >> 8]; - else - block = -1; - set += 64; - if (block >=0 && - (set[block*8 + ((ch & 255)>>5)] & (1 << (ch & 31)))) - return ok; - set += count*8; - } - break; - } - - case SRE_OP_CATEGORY: - /* */ - if (sre_category(set[0], (int) ch)) - return ok; - set += 1; - break; - - case SRE_OP_NEGATE: - ok = !ok; - break; - - case SRE_OP_FAILURE: - return !ok; - - default: - /* internal error -- there's not much we can do about it - here, so let's just pretend it didn't match... */ - return 0; - } - } -} - -LOCAL(int) SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern, int level); - -LOCAL(int) -SRE_COUNT(SRE_STATE* state, SRE_CODE* pattern, int maxcount, int level) -{ - SRE_CODE chr; - SRE_CHAR* ptr = state->ptr; - SRE_CHAR* end = state->end; - int i; - - /* adjust end */ - if (maxcount < end - ptr && maxcount != 65535) - end = ptr + maxcount; - - switch (pattern[0]) { - - case SRE_OP_ANY: - /* repeated dot wildcard. */ - TRACE(("|%p|%p|COUNT ANY\n", pattern, ptr)); - while (ptr < end && !SRE_IS_LINEBREAK(*ptr)) - ptr++; - break; - - case SRE_OP_ANY_ALL: - /* repeated dot wildcare. skip to the end of the target - string, and backtrack from there */ - TRACE(("|%p|%p|COUNT ANY_ALL\n", pattern, ptr)); - ptr = end; - break; - - case SRE_OP_LITERAL: - /* repeated literal */ - chr = pattern[1]; - TRACE(("|%p|%p|COUNT LITERAL %d\n", pattern, ptr, chr)); - while (ptr < end && (SRE_CODE) *ptr == chr) - ptr++; - break; - - case SRE_OP_LITERAL_IGNORE: - /* repeated literal */ - chr = pattern[1]; - TRACE(("|%p|%p|COUNT LITERAL_IGNORE %d\n", pattern, ptr, chr)); - while (ptr < end && (SRE_CODE) state->lower(*ptr) == chr) - ptr++; - break; - - case SRE_OP_NOT_LITERAL: - /* repeated non-literal */ - chr = pattern[1]; - TRACE(("|%p|%p|COUNT NOT_LITERAL %d\n", pattern, ptr, chr)); - while (ptr < end && (SRE_CODE) *ptr != chr) - ptr++; - break; - - case SRE_OP_NOT_LITERAL_IGNORE: - /* repeated non-literal */ - chr = pattern[1]; - TRACE(("|%p|%p|COUNT NOT_LITERAL_IGNORE %d\n", pattern, ptr, chr)); - while (ptr < end && (SRE_CODE) state->lower(*ptr) != chr) - ptr++; - break; - - case SRE_OP_IN: - /* repeated set */ - TRACE(("|%p|%p|COUNT IN\n", pattern, ptr)); - while (ptr < end && SRE_CHARSET(pattern + 2, *ptr)) - ptr++; - break; - - default: - /* repeated single character pattern */ - TRACE(("|%p|%p|COUNT SUBPATTERN\n", pattern, ptr)); - while ((SRE_CHAR*) state->ptr < end) { - i = SRE_MATCH(state, pattern, level); - if (i < 0) - return i; - if (!i) - break; - } - TRACE(("|%p|%p|COUNT %d\n", pattern, ptr, - (SRE_CHAR*) state->ptr - ptr)); - return (SRE_CHAR*) state->ptr - ptr; - } - - TRACE(("|%p|%p|COUNT %d\n", pattern, ptr, ptr - (SRE_CHAR*) state->ptr)); - return ptr - (SRE_CHAR*) state->ptr; -} - -#if 0 /* not used in this release */ -LOCAL(int) -SRE_INFO(SRE_STATE* state, SRE_CODE* pattern) -{ - /* check if an SRE_OP_INFO block matches at the current position. - returns the number of SRE_CODE objects to skip if successful, 0 - if no match */ - - SRE_CHAR* end = state->end; - SRE_CHAR* ptr = state->ptr; - int i; - - /* check minimal length */ - if (pattern[3] && (end - ptr) < pattern[3]) - return 0; - - /* check known prefix */ - if (pattern[2] & SRE_INFO_PREFIX && pattern[5] > 1) { - /* */ - for (i = 0; i < pattern[5]; i++) - if ((SRE_CODE) ptr[i] != pattern[7 + i]) - return 0; - return pattern[0] + 2 * pattern[6]; - } - return pattern[0]; -} -#endif - -/* The macros below should be used to protect recursive SRE_MATCH() - * calls that *failed* and do *not* return immediately (IOW, those - * that will backtrack). Explaining: - * - * - Recursive SRE_MATCH() returned true: that's usually a success - * (besides atypical cases like ASSERT_NOT), therefore there's no - * reason to restore lastmark; - * - * - Recursive SRE_MATCH() returned false but the current SRE_MATCH() - * is returning to the caller: If the current SRE_MATCH() is the - * top function of the recursion, returning false will be a matching - * failure, and it doesn't matter where lastmark is pointing to. - * If it's *not* the top function, it will be a recursive SRE_MATCH() - * failure by itself, and the calling SRE_MATCH() will have to deal - * with the failure by the same rules explained here (it will restore - * lastmark by itself if necessary); - * - * - Recursive SRE_MATCH() returned false, and will continue the - * outside 'for' loop: must be protected when breaking, since the next - * OP could potentially depend on lastmark; - * - * - Recursive SRE_MATCH() returned false, and will be called again - * inside a local for/while loop: must be protected between each - * loop iteration, since the recursive SRE_MATCH() could do anything, - * and could potentially depend on lastmark. - * - * For more information, check the discussion at SF patch #712900. - */ -#define LASTMARK_SAVE() \ - do { \ - lastmark = state->lastmark; \ - lastindex = state->lastindex; \ - } while (0) -#define LASTMARK_RESTORE() \ - do { \ - if (state->lastmark > lastmark) { \ - memset(state->mark + lastmark + 1, 0, \ - (state->lastmark - lastmark) * sizeof(void*)); \ - state->lastmark = lastmark; \ - state->lastindex = lastindex; \ - } \ - } while (0) - -LOCAL(int) -SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern, int level) -{ - /* check if string matches the given pattern. returns <0 for - error, 0 for failure, and 1 for success */ - - SRE_CHAR* end = state->end; - SRE_CHAR* ptr = state->ptr; - int i, count; - SRE_REPEAT* rp; - int lastmark, lastindex, mark_stack_base; - SRE_CODE chr; - - SRE_REPEAT rep; /* FIXME: allocate in STATE instead */ - - TRACE(("|%p|%p|ENTER %d\n", pattern, ptr, level)); - -#if defined(USE_STACKCHECK) - if (level % 10 == 0 && PyOS_CheckStack()) - return SRE_ERROR_RECURSION_LIMIT; -#endif - -#if defined(USE_RECURSION_LIMIT) - if (level > USE_RECURSION_LIMIT) - return SRE_ERROR_RECURSION_LIMIT; -#endif - - if (pattern[0] == SRE_OP_INFO) { - /* optimization info block */ - /* <1=skip> <2=flags> <3=min> ... */ - if (pattern[3] && (end - ptr) < pattern[3]) { - TRACE(("reject (got %d chars, need %d)\n", - (end - ptr), pattern[3])); - return 0; - } - pattern += pattern[1] + 1; - } - - for (;;) { - - switch (*pattern++) { - - case SRE_OP_FAILURE: - /* immediate failure */ - TRACE(("|%p|%p|FAILURE\n", pattern, ptr)); - return 0; - - case SRE_OP_SUCCESS: - /* end of pattern */ - TRACE(("|%p|%p|SUCCESS\n", pattern, ptr)); - state->ptr = ptr; - return 1; - - case SRE_OP_AT: - /* match at given position */ - /* */ - TRACE(("|%p|%p|AT %d\n", pattern, ptr, *pattern)); - if (!SRE_AT(state, ptr, *pattern)) - return 0; - pattern++; - break; - - case SRE_OP_CATEGORY: - /* match at given category */ - /* */ - TRACE(("|%p|%p|CATEGORY %d\n", pattern, ptr, *pattern)); - if (ptr >= end || !sre_category(pattern[0], ptr[0])) - return 0; - pattern++; - ptr++; - break; - - case SRE_OP_LITERAL: - /* match literal string */ - /* */ - TRACE(("|%p|%p|LITERAL %d\n", pattern, ptr, *pattern)); - if (ptr >= end || (SRE_CODE) ptr[0] != pattern[0]) - return 0; - pattern++; - ptr++; - break; - - case SRE_OP_NOT_LITERAL: - /* match anything that is not literal character */ - /* */ - TRACE(("|%p|%p|NOT_LITERAL %d\n", pattern, ptr, *pattern)); - if (ptr >= end || (SRE_CODE) ptr[0] == pattern[0]) - return 0; - pattern++; - ptr++; - break; - - case SRE_OP_ANY: - /* match anything (except a newline) */ - /* */ - TRACE(("|%p|%p|ANY\n", pattern, ptr)); - if (ptr >= end || SRE_IS_LINEBREAK(ptr[0])) - return 0; - ptr++; - break; - - case SRE_OP_ANY_ALL: - /* match anything */ - /* */ - TRACE(("|%p|%p|ANY_ALL\n", pattern, ptr)); - if (ptr >= end) - return 0; - ptr++; - break; - - case SRE_OP_IN: - /* match set member (or non_member) */ - /* */ - TRACE(("|%p|%p|IN\n", pattern, ptr)); - if (ptr >= end || !SRE_CHARSET(pattern + 1, *ptr)) - return 0; - pattern += pattern[0]; - ptr++; - break; - - case SRE_OP_GROUPREF: - /* match backreference */ - TRACE(("|%p|%p|GROUPREF %d\n", pattern, ptr, pattern[0])); - i = pattern[0]; - { - SRE_CHAR* p = (SRE_CHAR*) state->mark[i+i]; - SRE_CHAR* e = (SRE_CHAR*) state->mark[i+i+1]; - if (!p || !e || e < p) - return 0; - while (p < e) { - if (ptr >= end || *ptr != *p) - return 0; - p++; ptr++; - } - } - pattern++; - break; - - case SRE_OP_GROUPREF_IGNORE: - /* match backreference */ - TRACE(("|%p|%p|GROUPREF_IGNORE %d\n", pattern, ptr, pattern[0])); - i = pattern[0]; - { - SRE_CHAR* p = (SRE_CHAR*) state->mark[i+i]; - SRE_CHAR* e = (SRE_CHAR*) state->mark[i+i+1]; - if (!p || !e || e < p) - return 0; - while (p < e) { - if (ptr >= end || - state->lower(*ptr) != state->lower(*p)) - return 0; - p++; ptr++; - } - } - pattern++; - break; - - case SRE_OP_LITERAL_IGNORE: - TRACE(("|%p|%p|LITERAL_IGNORE %d\n", pattern, ptr, pattern[0])); - if (ptr >= end || - state->lower(*ptr) != state->lower(*pattern)) - return 0; - pattern++; - ptr++; - break; - - case SRE_OP_NOT_LITERAL_IGNORE: - TRACE(("|%p|%p|NOT_LITERAL_IGNORE %d\n", pattern, ptr, *pattern)); - if (ptr >= end || - state->lower(*ptr) == state->lower(*pattern)) - return 0; - pattern++; - ptr++; - break; - - case SRE_OP_IN_IGNORE: - TRACE(("|%p|%p|IN_IGNORE\n", pattern, ptr)); - if (ptr >= end - || !SRE_CHARSET(pattern + 1, (SRE_CODE) state->lower(*ptr))) - return 0; - pattern += pattern[0]; - ptr++; - break; - - case SRE_OP_MARK: - /* set mark */ - /* */ - TRACE(("|%p|%p|MARK %d\n", pattern, ptr, pattern[0])); - i = pattern[0]; - if (i & 1) - state->lastindex = i/2 + 1; - if (i > state->lastmark) - state->lastmark = i; - state->mark[i] = ptr; - pattern++; - break; - - case SRE_OP_JUMP: - case SRE_OP_INFO: - /* jump forward */ - /* */ - TRACE(("|%p|%p|JUMP %d\n", pattern, ptr, pattern[0])); - pattern += pattern[0]; - break; - - case SRE_OP_ASSERT: - /* assert subpattern */ - /* */ - TRACE(("|%p|%p|ASSERT %d\n", pattern, ptr, pattern[1])); - state->ptr = ptr - pattern[1]; - if (state->ptr < state->beginning) - return 0; - i = SRE_MATCH(state, pattern + 2, level + 1); - if (i <= 0) - return i; - pattern += pattern[0]; - break; - - case SRE_OP_ASSERT_NOT: - /* assert not subpattern */ - /* */ - TRACE(("|%p|%p|ASSERT_NOT %d\n", pattern, ptr, pattern[1])); - state->ptr = ptr - pattern[1]; - if (state->ptr >= state->beginning) { - i = SRE_MATCH(state, pattern + 2, level + 1); - if (i < 0) - return i; - if (i) - return 0; - } - pattern += pattern[0]; - break; - - case SRE_OP_BRANCH: - /* alternation */ - /* <0=skip> code ... */ - TRACE(("|%p|%p|BRANCH\n", pattern, ptr)); - LASTMARK_SAVE(); - if (state->repeat) { - i = mark_save(state, 0, lastmark, &mark_stack_base); - if (i < 0) - return i; - } - for (; pattern[0]; pattern += pattern[0]) { - if (pattern[1] == SRE_OP_LITERAL && - (ptr >= end || (SRE_CODE) *ptr != pattern[2])) - continue; - if (pattern[1] == SRE_OP_IN && - (ptr >= end || !SRE_CHARSET(pattern + 3, (SRE_CODE) *ptr))) - continue; - state->ptr = ptr; - i = SRE_MATCH(state, pattern + 1, level + 1); - if (i) - return i; - if (state->repeat) { - i = mark_restore(state, 0, lastmark, &mark_stack_base); - if (i < 0) - return i; - } - LASTMARK_RESTORE(); - } - return 0; - - case SRE_OP_REPEAT_ONE: - /* match repeated sequence (maximizing regexp) */ - - /* this operator only works if the repeated item is - exactly one character wide, and we're not already - collecting backtracking points. for other cases, - use the MAX_REPEAT operator */ - - /* <1=min> <2=max> item tail */ - - TRACE(("|%p|%p|REPEAT_ONE %d %d\n", pattern, ptr, - pattern[1], pattern[2])); - - if (ptr + pattern[1] > end) - return 0; /* cannot match */ - - state->ptr = ptr; - - count = SRE_COUNT(state, pattern + 3, pattern[2], level + 1); - if (count < 0) - return count; - - ptr += count; - - /* when we arrive here, count contains the number of - matches, and ptr points to the tail of the target - string. check if the rest of the pattern matches, - and backtrack if not. */ - - if (count < (int) pattern[1]) - return 0; - - if (pattern[pattern[0]] == SRE_OP_SUCCESS) { - /* tail is empty. we're finished */ - state->ptr = ptr; - return 1; - } - - LASTMARK_SAVE(); - - if (pattern[pattern[0]] == SRE_OP_LITERAL) { - /* tail starts with a literal. skip positions where - the rest of the pattern cannot possibly match */ - chr = pattern[pattern[0]+1]; - for (;;) { - while (count >= (int) pattern[1] && - (ptr >= end || *ptr != chr)) { - ptr--; - count--; - } - if (count < (int) pattern[1]) - break; - state->ptr = ptr; - i = SRE_MATCH(state, pattern + pattern[0], level + 1); - if (i) - return i; - ptr--; - count--; - LASTMARK_RESTORE(); - } - - } else { - /* general case */ - while (count >= (int) pattern[1]) { - state->ptr = ptr; - i = SRE_MATCH(state, pattern + pattern[0], level + 1); - if (i) - return i; - ptr--; - count--; - LASTMARK_RESTORE(); - } - } - return 0; - - case SRE_OP_MIN_REPEAT_ONE: - /* match repeated sequence (minimizing regexp) */ - - /* this operator only works if the repeated item is - exactly one character wide, and we're not already - collecting backtracking points. for other cases, - use the MIN_REPEAT operator */ - - /* <1=min> <2=max> item tail */ - - TRACE(("|%p|%p|MIN_REPEAT_ONE %d %d\n", pattern, ptr, - pattern[1], pattern[2])); - - if (ptr + pattern[1] > end) - return 0; /* cannot match */ - - state->ptr = ptr; - - if (pattern[1] == 0) - count = 0; - else { - /* count using pattern min as the maximum */ - count = SRE_COUNT(state, pattern + 3, pattern[1], level + 1); - - if (count < 0) - return count; /* exception */ - if (count < (int) pattern[1]) - return 0; /* did not match minimum number of times */ - ptr += count; /* advance past minimum matches of repeat */ - } - - if (pattern[pattern[0]] == SRE_OP_SUCCESS) { - /* tail is empty. we're finished */ - state->ptr = ptr; - return 1; - - } else { - /* general case */ - int matchmax = ((int)pattern[2] == 65535); - int c; - LASTMARK_SAVE(); - while (matchmax || count <= (int) pattern[2]) { - state->ptr = ptr; - i = SRE_MATCH(state, pattern + pattern[0], level + 1); - if (i) - return i; - state->ptr = ptr; - c = SRE_COUNT(state, pattern+3, 1, level+1); - if (c < 0) - return c; - if (c == 0) - break; - assert(c == 1); - ptr++; - count++; - LASTMARK_RESTORE(); - } - } - return 0; - - case SRE_OP_REPEAT: - /* create repeat context. all the hard work is done - by the UNTIL operator (MAX_UNTIL, MIN_UNTIL) */ - /* <1=min> <2=max> item tail */ - TRACE(("|%p|%p|REPEAT %d %d\n", pattern, ptr, - pattern[1], pattern[2])); - - rep.count = -1; - rep.pattern = pattern; - - /* install new repeat context */ - rep.prev = state->repeat; - state->repeat = &rep; - - state->ptr = ptr; - i = SRE_MATCH(state, pattern + pattern[0], level + 1); - - state->repeat = rep.prev; - - return i; - - case SRE_OP_MAX_UNTIL: - /* maximizing repeat */ - /* <1=min> <2=max> item tail */ - - /* FIXME: we probably need to deal with zero-width - matches in here... */ - - rp = state->repeat; - if (!rp) - return SRE_ERROR_STATE; - - state->ptr = ptr; - - count = rp->count + 1; - - TRACE(("|%p|%p|MAX_UNTIL %d\n", pattern, ptr, count)); - - if (count < rp->pattern[1]) { - /* not enough matches */ - rp->count = count; - /* RECURSIVE */ - i = SRE_MATCH(state, rp->pattern + 3, level + 1); - if (i) - return i; - rp->count = count - 1; - state->ptr = ptr; - return 0; - } - - if (count < rp->pattern[2] || rp->pattern[2] == 65535) { - /* we may have enough matches, but if we can - match another item, do so */ - rp->count = count; - LASTMARK_SAVE(); - i = mark_save(state, 0, lastmark, &mark_stack_base); - if (i < 0) - return i; - /* RECURSIVE */ - i = SRE_MATCH(state, rp->pattern + 3, level + 1); - if (i) - return i; - i = mark_restore(state, 0, lastmark, &mark_stack_base); - if (i < 0) - return i; - LASTMARK_RESTORE(); - rp->count = count - 1; - state->ptr = ptr; - } - - /* cannot match more repeated items here. make sure the - tail matches */ - state->repeat = rp->prev; - i = SRE_MATCH(state, pattern, level + 1); - if (i) - return i; - state->repeat = rp; - state->ptr = ptr; - return 0; - - case SRE_OP_MIN_UNTIL: - /* minimizing repeat */ - /* <1=min> <2=max> item tail */ - - rp = state->repeat; - if (!rp) - return SRE_ERROR_STATE; - - state->ptr = ptr; - - count = rp->count + 1; - - TRACE(("|%p|%p|MIN_UNTIL %d %p\n", pattern, ptr, count, - rp->pattern)); - - if (count < rp->pattern[1]) { - /* not enough matches */ - rp->count = count; - /* RECURSIVE */ - i = SRE_MATCH(state, rp->pattern + 3, level + 1); - if (i) - return i; - rp->count = count-1; - state->ptr = ptr; - return 0; - } - - LASTMARK_SAVE(); - - /* see if the tail matches */ - state->repeat = rp->prev; - i = SRE_MATCH(state, pattern, level + 1); - if (i) - return i; - - state->ptr = ptr; - state->repeat = rp; - - if (count >= rp->pattern[2] && rp->pattern[2] != 65535) - return 0; - - LASTMARK_RESTORE(); - - rp->count = count; - /* RECURSIVE */ - i = SRE_MATCH(state, rp->pattern + 3, level + 1); - if (i) - return i; - rp->count = count - 1; - state->ptr = ptr; - - return 0; - - default: - TRACE(("|%p|%p|UNKNOWN %d\n", pattern, ptr, pattern[-1])); - return SRE_ERROR_ILLEGAL; - } - } - - /* can't end up here */ - /* return SRE_ERROR_ILLEGAL; -- see python-dev discussion */ -} - -LOCAL(int) -SRE_SEARCH(SRE_STATE* state, SRE_CODE* pattern) -{ - SRE_CHAR* ptr = state->start; - SRE_CHAR* end = state->end; - int status = 0; - int prefix_len = 0; - int prefix_skip = 0; - SRE_CODE* prefix = NULL; - SRE_CODE* charset = NULL; - SRE_CODE* overlap = NULL; - int flags = 0; - - if (pattern[0] == SRE_OP_INFO) { - /* optimization info block */ - /* <1=skip> <2=flags> <3=min> <4=max> <5=prefix info> */ - - flags = pattern[2]; - - if (pattern[3] > 1) { - /* adjust end point (but make sure we leave at least one - character in there, so literal search will work) */ - end -= pattern[3]-1; - if (end <= ptr) - end = ptr+1; - } - - if (flags & SRE_INFO_PREFIX) { - /* pattern starts with a known prefix */ - /* */ - prefix_len = pattern[5]; - prefix_skip = pattern[6]; - prefix = pattern + 7; - overlap = prefix + prefix_len - 1; - } else if (flags & SRE_INFO_CHARSET) - /* pattern starts with a character from a known set */ - /* */ - charset = pattern + 5; - - pattern += 1 + pattern[1]; - } - - TRACE(("prefix = %p %d %d\n", prefix, prefix_len, prefix_skip)); - TRACE(("charset = %p\n", charset)); - -#if defined(USE_FAST_SEARCH) - if (prefix_len > 1) { - /* pattern starts with a known prefix. use the overlap - table to skip forward as fast as we possibly can */ - int i = 0; - end = state->end; - while (ptr < end) { - for (;;) { - if ((SRE_CODE) ptr[0] != prefix[i]) { - if (!i) - break; - else - i = overlap[i]; - } else { - if (++i == prefix_len) { - /* found a potential match */ - TRACE(("|%p|%p|SEARCH SCAN\n", pattern, ptr)); - state->start = ptr + 1 - prefix_len; - state->ptr = ptr + 1 - prefix_len + prefix_skip; - if (flags & SRE_INFO_LITERAL) - return 1; /* we got all of it */ - status = SRE_MATCH(state, pattern + 2*prefix_skip, 1); - if (status != 0) - return status; - /* close but no cigar -- try again */ - i = overlap[i]; - } - break; - } - - } - ptr++; - } - return 0; - } -#endif - - if (pattern[0] == SRE_OP_LITERAL) { - /* pattern starts with a literal character. this is used - for short prefixes, and if fast search is disabled */ - SRE_CODE chr = pattern[1]; - end = state->end; - for (;;) { - while (ptr < end && (SRE_CODE) ptr[0] != chr) - ptr++; - if (ptr >= end) - return 0; - TRACE(("|%p|%p|SEARCH LITERAL\n", pattern, ptr)); - state->start = ptr; - state->ptr = ++ptr; - if (flags & SRE_INFO_LITERAL) - return 1; /* we got all of it */ - status = SRE_MATCH(state, pattern + 2, 1); - if (status != 0) - break; - } - } else if (charset) { - /* pattern starts with a character from a known set */ - end = state->end; - for (;;) { - while (ptr < end && !SRE_CHARSET(charset, ptr[0])) - ptr++; - if (ptr >= end) - return 0; - TRACE(("|%p|%p|SEARCH CHARSET\n", pattern, ptr)); - state->start = ptr; - state->ptr = ptr; - status = SRE_MATCH(state, pattern, 1); - if (status != 0) - break; - ptr++; - } - } else - /* general case */ - while (ptr <= end) { - TRACE(("|%p|%p|SEARCH\n", pattern, ptr)); - state->start = state->ptr = ptr++; - status = SRE_MATCH(state, pattern, 1); - if (status != 0) - break; - } - - return status; -} - -LOCAL(int) -SRE_LITERAL_TEMPLATE(SRE_CHAR* ptr, int len) -{ - /* check if given string is a literal template (i.e. no escapes) */ - while (len-- > 0) - if (*ptr++ == '\\') - return 0; - return 1; -} - -#if !defined(SRE_RECURSIVE) - -/* -------------------------------------------------------------------- */ -/* factories and destructors */ - -/* see sre.h for object declarations */ - -static PyTypeObject Pattern_Type; -static PyTypeObject Match_Type; -static PyTypeObject Scanner_Type; - -static PyObject * -_compile(PyObject* self_, PyObject* args) -{ - /* "compile" pattern descriptor to pattern object */ - - PatternObject* self; - int i, n; - - PyObject* pattern; - int flags = 0; - PyObject* code; - int groups = 0; - PyObject* groupindex = NULL; - PyObject* indexgroup = NULL; - if (!PyArg_ParseTuple(args, "OiO!|iOO", &pattern, &flags, - &PyList_Type, &code, &groups, - &groupindex, &indexgroup)) - return NULL; - - n = PyList_GET_SIZE(code); - - self = PyObject_NEW_VAR(PatternObject, &Pattern_Type, n); - if (!self) - return NULL; - - self->codesize = n; - - for (i = 0; i < n; i++) { - PyObject *o = PyList_GET_ITEM(code, i); - if (PyInt_Check(o)) - self->code[i] = (SRE_CODE) PyInt_AsLong(o); - else - self->code[i] = (SRE_CODE) PyLong_AsUnsignedLong(o); - } - - if (PyErr_Occurred()) { - PyObject_DEL(self); - return NULL; - } - - Py_INCREF(pattern); - self->pattern = pattern; - - self->flags = flags; - - self->groups = groups; - - Py_XINCREF(groupindex); - self->groupindex = groupindex; - - Py_XINCREF(indexgroup); - self->indexgroup = indexgroup; - - return (PyObject*) self; -} - -static PyObject * -sre_codesize(PyObject* self, PyObject* args) -{ - return Py_BuildValue("i", sizeof(SRE_CODE)); -} - -static PyObject * -sre_getlower(PyObject* self, PyObject* args) -{ - int character, flags; - if (!PyArg_ParseTuple(args, "ii", &character, &flags)) - return NULL; - if (flags & SRE_FLAG_LOCALE) - return Py_BuildValue("i", sre_lower_locale(character)); - if (flags & SRE_FLAG_UNICODE) -#if defined(HAVE_UNICODE) - return Py_BuildValue("i", sre_lower_unicode(character)); -#else - return Py_BuildValue("i", sre_lower_locale(character)); -#endif - return Py_BuildValue("i", sre_lower(character)); -} - -LOCAL(void) -state_reset(SRE_STATE* state) -{ - state->lastmark = 0; - - /* FIXME: dynamic! */ - memset(state->mark, 0, sizeof(*state->mark) * SRE_MARK_SIZE); - - state->lastindex = -1; - - state->repeat = NULL; - - mark_fini(state); -} - -static void* -getstring(PyObject* string, int* p_length, int* p_charsize) -{ - /* given a python object, return a data pointer, a length (in - characters), and a character size. return NULL if the object - is not a string (or not compatible) */ - - PyBufferProcs *buffer; - int size, bytes, charsize; - void* ptr; - -#if defined(HAVE_UNICODE) - if (PyUnicode_Check(string)) { - /* unicode strings doesn't always support the buffer interface */ - ptr = (void*) PyUnicode_AS_DATA(string); - bytes = PyUnicode_GET_DATA_SIZE(string); - size = PyUnicode_GET_SIZE(string); - charsize = sizeof(Py_UNICODE); - - } else { -#endif - - /* get pointer to string buffer */ - buffer = string->ob_type->tp_as_buffer; - if (!buffer || !buffer->bf_getreadbuffer || !buffer->bf_getsegcount || - buffer->bf_getsegcount(string, NULL) != 1) { - PyErr_SetString(PyExc_TypeError, "expected string or buffer"); - return NULL; - } - - /* determine buffer size */ - bytes = buffer->bf_getreadbuffer(string, 0, &ptr); - if (bytes < 0) { - PyErr_SetString(PyExc_TypeError, "buffer has negative size"); - return NULL; - } - - /* determine character size */ -#if PY_VERSION_HEX >= 0x01060000 - size = PyObject_Size(string); -#else - size = PyObject_Length(string); -#endif - - if (PyString_Check(string) || bytes == size) - charsize = 1; -#if defined(HAVE_UNICODE) - else if (bytes == (int) (size * sizeof(Py_UNICODE))) - charsize = sizeof(Py_UNICODE); -#endif - else { - PyErr_SetString(PyExc_TypeError, "buffer size mismatch"); - return NULL; - } - -#if defined(HAVE_UNICODE) - } -#endif - - *p_length = size; - *p_charsize = charsize; - - return ptr; -} - -LOCAL(PyObject*) -state_init(SRE_STATE* state, PatternObject* pattern, PyObject* string, - int start, int end) -{ - /* prepare state object */ - - int length; - int charsize; - void* ptr; - - memset(state, 0, sizeof(SRE_STATE)); - - state->lastindex = -1; - - ptr = getstring(string, &length, &charsize); - if (!ptr) - return NULL; - - /* adjust boundaries */ - if (start < 0) - start = 0; - else if (start > length) - start = length; - - if (end < 0) - end = 0; - else if (end > length) - end = length; - - state->charsize = charsize; - - state->beginning = ptr; - - state->start = (void*) ((char*) ptr + start * state->charsize); - state->end = (void*) ((char*) ptr + end * state->charsize); - - Py_INCREF(string); - state->string = string; - state->pos = start; - state->endpos = end; - - if (pattern->flags & SRE_FLAG_LOCALE) - state->lower = sre_lower_locale; - else if (pattern->flags & SRE_FLAG_UNICODE) -#if defined(HAVE_UNICODE) - state->lower = sre_lower_unicode; -#else - state->lower = sre_lower_locale; -#endif - else - state->lower = sre_lower; - - return string; -} - -LOCAL(void) -state_fini(SRE_STATE* state) -{ - Py_XDECREF(state->string); - mark_fini(state); -} - -/* calculate offset from start of string */ -#define STATE_OFFSET(state, member)\ - (((char*)(member) - (char*)(state)->beginning) / (state)->charsize) - -LOCAL(PyObject*) -state_getslice(SRE_STATE* state, int index, PyObject* string, int empty) -{ - int i, j; - - index = (index - 1) * 2; - - if (string == Py_None || !state->mark[index] || !state->mark[index+1]) { - if (empty) - /* want empty string */ - i = j = 0; - else { - Py_INCREF(Py_None); - return Py_None; - } - } else { - i = STATE_OFFSET(state, state->mark[index]); - j = STATE_OFFSET(state, state->mark[index+1]); - } - - return PySequence_GetSlice(string, i, j); -} - -static void -pattern_error(int status) -{ - switch (status) { - case SRE_ERROR_RECURSION_LIMIT: - PyErr_SetString( - PyExc_RuntimeError, - "maximum recursion limit exceeded" - ); - break; - case SRE_ERROR_MEMORY: - PyErr_NoMemory(); - break; - default: - /* other error codes indicate compiler/engine bugs */ - PyErr_SetString( - PyExc_RuntimeError, - "internal error in regular expression engine" - ); - } -} - -static PyObject* -pattern_new_match(PatternObject* pattern, SRE_STATE* state, int status) -{ - /* create match object (from state object) */ - - MatchObject* match; - int i, j; - char* base; - int n; - - if (status > 0) { - - /* create match object (with room for extra group marks) */ - match = PyObject_NEW_VAR(MatchObject, &Match_Type, - 2*(pattern->groups+1)); - if (!match) - return NULL; - - Py_INCREF(pattern); - match->pattern = pattern; - - Py_INCREF(state->string); - match->string = state->string; - - match->regs = NULL; - match->groups = pattern->groups+1; - - /* fill in group slices */ - - base = (char*) state->beginning; - n = state->charsize; - - match->mark[0] = ((char*) state->start - base) / n; - match->mark[1] = ((char*) state->ptr - base) / n; - - for (i = j = 0; i < pattern->groups; i++, j+=2) - if (j+1 <= state->lastmark && state->mark[j] && state->mark[j+1]) { - match->mark[j+2] = ((char*) state->mark[j] - base) / n; - match->mark[j+3] = ((char*) state->mark[j+1] - base) / n; - } else - match->mark[j+2] = match->mark[j+3] = -1; /* undefined */ - - match->pos = state->pos; - match->endpos = state->endpos; - - match->lastindex = state->lastindex; - - return (PyObject*) match; - - } else if (status == 0) { - - /* no match */ - Py_INCREF(Py_None); - return Py_None; - - } - - /* internal error */ - pattern_error(status); - return NULL; -} - -static PyObject* -pattern_scanner(PatternObject* pattern, PyObject* args) -{ - /* create search state object */ - - ScannerObject* self; - - PyObject* string; - int start = 0; - int end = INT_MAX; - if (!PyArg_ParseTuple(args, "O|ii:scanner", &string, &start, &end)) - return NULL; - - /* create scanner object */ - self = PyObject_NEW(ScannerObject, &Scanner_Type); - if (!self) - return NULL; - - string = state_init(&self->state, pattern, string, start, end); - if (!string) { - PyObject_DEL(self); - return NULL; - } - - Py_INCREF(pattern); - self->pattern = (PyObject*) pattern; - - return (PyObject*) self; -} - -static void -pattern_dealloc(PatternObject* self) -{ - Py_XDECREF(self->pattern); - Py_XDECREF(self->groupindex); - Py_XDECREF(self->indexgroup); - PyObject_DEL(self); -} - -static PyObject* -pattern_match(PatternObject* self, PyObject* args, PyObject* kw) -{ - SRE_STATE state; - int status; - - PyObject* string; - int start = 0; - int end = INT_MAX; - static char* kwlist[] = { "pattern", "pos", "endpos", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kw, "O|ii:match", kwlist, - &string, &start, &end)) - return NULL; - - string = state_init(&state, self, string, start, end); - if (!string) - return NULL; - - state.ptr = state.start; - - TRACE(("|%p|%p|MATCH\n", PatternObject_GetCode(self), state.ptr)); - - if (state.charsize == 1) { - status = sre_match(&state, PatternObject_GetCode(self), 1); - } else { -#if defined(HAVE_UNICODE) - status = sre_umatch(&state, PatternObject_GetCode(self), 1); -#endif - } - - TRACE(("|%p|%p|END\n", PatternObject_GetCode(self), state.ptr)); - - state_fini(&state); - - return pattern_new_match(self, &state, status); -} - -static PyObject* -pattern_search(PatternObject* self, PyObject* args, PyObject* kw) -{ - SRE_STATE state; - int status; - - PyObject* string; - int start = 0; - int end = INT_MAX; - static char* kwlist[] = { "pattern", "pos", "endpos", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kw, "O|ii:search", kwlist, - &string, &start, &end)) - return NULL; - - string = state_init(&state, self, string, start, end); - if (!string) - return NULL; - - TRACE(("|%p|%p|SEARCH\n", PatternObject_GetCode(self), state.ptr)); - - if (state.charsize == 1) { - status = sre_search(&state, PatternObject_GetCode(self)); - } else { -#if defined(HAVE_UNICODE) - status = sre_usearch(&state, PatternObject_GetCode(self)); -#endif - } - - TRACE(("|%p|%p|END\n", PatternObject_GetCode(self), state.ptr)); - - state_fini(&state); - - return pattern_new_match(self, &state, status); -} - -static PyObject* -call(char* module, char* function, PyObject* args) -{ - PyObject* name; - PyObject* mod; - PyObject* func; - PyObject* result; - - if (!args) - return NULL; - name = PyString_FromString(module); - if (!name) - return NULL; - mod = PyImport_Import(name); - Py_DECREF(name); - if (!mod) - return NULL; - func = PyObject_GetAttrString(mod, function); - Py_DECREF(mod); - if (!func) - return NULL; - result = PyObject_CallObject(func, args); - Py_DECREF(func); - Py_DECREF(args); - return result; -} - -#ifdef USE_BUILTIN_COPY -static int -deepcopy(PyObject** object, PyObject* memo) -{ - PyObject* copy; - - copy = call( - "copy", "deepcopy", - Py_BuildValue("OO", *object, memo) - ); - if (!copy) - return 0; - - Py_DECREF(*object); - *object = copy; - - return 1; /* success */ -} -#endif - -static PyObject* -join_list(PyObject* list, PyObject* pattern) -{ - /* join list elements */ - - PyObject* joiner; -#if PY_VERSION_HEX >= 0x01060000 - PyObject* function; - PyObject* args; -#endif - PyObject* result; - - switch (PyList_GET_SIZE(list)) { - case 0: - Py_DECREF(list); - return PySequence_GetSlice(pattern, 0, 0); - case 1: - result = PyList_GET_ITEM(list, 0); - Py_INCREF(result); - Py_DECREF(list); - return result; - } - - /* two or more elements: slice out a suitable separator from the - first member, and use that to join the entire list */ - - joiner = PySequence_GetSlice(pattern, 0, 0); - if (!joiner) - return NULL; - -#if PY_VERSION_HEX >= 0x01060000 - function = PyObject_GetAttrString(joiner, "join"); - if (!function) { - Py_DECREF(joiner); - return NULL; - } - args = PyTuple_New(1); - if (!args) { - Py_DECREF(function); - Py_DECREF(joiner); - return NULL; - } - PyTuple_SET_ITEM(args, 0, list); - result = PyObject_CallObject(function, args); - Py_DECREF(args); /* also removes list */ - Py_DECREF(function); -#else - result = call( - "string", "join", - Py_BuildValue("OO", list, joiner) - ); -#endif - Py_DECREF(joiner); - - return result; -} - -static PyObject* -pattern_findall(PatternObject* self, PyObject* args, PyObject* kw) -{ - SRE_STATE state; - PyObject* list; - int status; - int i, b, e; - - PyObject* string; - int start = 0; - int end = INT_MAX; - static char* kwlist[] = { "source", "pos", "endpos", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kw, "O|ii:findall", kwlist, - &string, &start, &end)) - return NULL; - - string = state_init(&state, self, string, start, end); - if (!string) - return NULL; - - list = PyList_New(0); - if (!list) { - state_fini(&state); - return NULL; - } - - while (state.start <= state.end) { - - PyObject* item; - - state_reset(&state); - - state.ptr = state.start; - - if (state.charsize == 1) { - status = sre_search(&state, PatternObject_GetCode(self)); - } else { -#if defined(HAVE_UNICODE) - status = sre_usearch(&state, PatternObject_GetCode(self)); -#endif - } - - if (status <= 0) { - if (status == 0) - break; - pattern_error(status); - goto error; - } - - /* don't bother to build a match object */ - switch (self->groups) { - case 0: - b = STATE_OFFSET(&state, state.start); - e = STATE_OFFSET(&state, state.ptr); - item = PySequence_GetSlice(string, b, e); - if (!item) - goto error; - break; - case 1: - item = state_getslice(&state, 1, string, 1); - if (!item) - goto error; - break; - default: - item = PyTuple_New(self->groups); - if (!item) - goto error; - for (i = 0; i < self->groups; i++) { - PyObject* o = state_getslice(&state, i+1, string, 1); - if (!o) { - Py_DECREF(item); - goto error; - } - PyTuple_SET_ITEM(item, i, o); - } - break; - } - - status = PyList_Append(list, item); - Py_DECREF(item); - if (status < 0) - goto error; - - if (state.ptr == state.start) - state.start = (void*) ((char*) state.ptr + state.charsize); - else - state.start = state.ptr; - - } - - state_fini(&state); - return list; - -error: - Py_DECREF(list); - state_fini(&state); - return NULL; - -} - -#if PY_VERSION_HEX >= 0x02020000 -static PyObject* -pattern_finditer(PatternObject* pattern, PyObject* args) -{ - PyObject* scanner; - PyObject* search; - PyObject* iterator; - - scanner = pattern_scanner(pattern, args); - if (!scanner) - return NULL; - - search = PyObject_GetAttrString(scanner, "search"); - Py_DECREF(scanner); - if (!search) - return NULL; - - iterator = PyCallIter_New(search, Py_None); - Py_DECREF(search); - - return iterator; -} -#endif - -static PyObject* -pattern_split(PatternObject* self, PyObject* args, PyObject* kw) -{ - SRE_STATE state; - PyObject* list; - PyObject* item; - int status; - int n; - int i; - void* last; - - PyObject* string; - int maxsplit = 0; - static char* kwlist[] = { "source", "maxsplit", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kw, "O|i:split", kwlist, - &string, &maxsplit)) - return NULL; - - string = state_init(&state, self, string, 0, INT_MAX); - if (!string) - return NULL; - - list = PyList_New(0); - if (!list) { - state_fini(&state); - return NULL; - } - - n = 0; - last = state.start; - - while (!maxsplit || n < maxsplit) { - - state_reset(&state); - - state.ptr = state.start; - - if (state.charsize == 1) { - status = sre_search(&state, PatternObject_GetCode(self)); - } else { -#if defined(HAVE_UNICODE) - status = sre_usearch(&state, PatternObject_GetCode(self)); -#endif - } - - if (status <= 0) { - if (status == 0) - break; - pattern_error(status); - goto error; - } - - if (state.start == state.ptr) { - if (last == state.end) - break; - /* skip one character */ - state.start = (void*) ((char*) state.ptr + state.charsize); - continue; - } - - /* get segment before this match */ - item = PySequence_GetSlice( - string, STATE_OFFSET(&state, last), - STATE_OFFSET(&state, state.start) - ); - if (!item) - goto error; - status = PyList_Append(list, item); - Py_DECREF(item); - if (status < 0) - goto error; - - /* add groups (if any) */ - for (i = 0; i < self->groups; i++) { - item = state_getslice(&state, i+1, string, 0); - if (!item) - goto error; - status = PyList_Append(list, item); - Py_DECREF(item); - if (status < 0) - goto error; - } - - n = n + 1; - - last = state.start = state.ptr; - - } - - /* get segment following last match (even if empty) */ - item = PySequence_GetSlice( - string, STATE_OFFSET(&state, last), state.endpos - ); - if (!item) - goto error; - status = PyList_Append(list, item); - Py_DECREF(item); - if (status < 0) - goto error; - - state_fini(&state); - return list; - -error: - Py_DECREF(list); - state_fini(&state); - return NULL; - -} - -static PyObject* -pattern_subx(PatternObject* self, PyObject* template, PyObject* string, - int count, int subn) -{ - SRE_STATE state; - PyObject* list; - PyObject* item; - PyObject* filter; - PyObject* args; - PyObject* match; - void* ptr; - int status; - int n; - int i, b, e; - int filter_is_callable; - - if (PyCallable_Check(template)) { - /* sub/subn takes either a function or a template */ - filter = template; - Py_INCREF(filter); - filter_is_callable = 1; - } else { - /* if not callable, check if it's a literal string */ - int literal; - ptr = getstring(template, &n, &b); - if (ptr) { - if (b == 1) { - literal = sre_literal_template(ptr, n); - } else { -#if defined(HAVE_UNICODE) - literal = sre_uliteral_template(ptr, n); -#endif - } - } else { - PyErr_Clear(); - literal = 0; - } - if (literal) { - filter = template; - Py_INCREF(filter); - filter_is_callable = 0; - } else { - /* not a literal; hand it over to the template compiler */ - filter = call( - SRE_MODULE, "_subx", - Py_BuildValue("OO", self, template) - ); - if (!filter) - return NULL; - filter_is_callable = PyCallable_Check(filter); - } - } - - string = state_init(&state, self, string, 0, INT_MAX); - if (!string) { - Py_DECREF(filter); - return NULL; - } - - list = PyList_New(0); - if (!list) { - Py_DECREF(filter); - state_fini(&state); - return NULL; - } - - n = i = 0; - - while (!count || n < count) { - - state_reset(&state); - - state.ptr = state.start; - - if (state.charsize == 1) { - status = sre_search(&state, PatternObject_GetCode(self)); - } else { -#if defined(HAVE_UNICODE) - status = sre_usearch(&state, PatternObject_GetCode(self)); -#endif - } - - if (status <= 0) { - if (status == 0) - break; - pattern_error(status); - goto error; - } - - b = STATE_OFFSET(&state, state.start); - e = STATE_OFFSET(&state, state.ptr); - - if (i < b) { - /* get segment before this match */ - item = PySequence_GetSlice(string, i, b); - if (!item) - goto error; - status = PyList_Append(list, item); - Py_DECREF(item); - if (status < 0) - goto error; - - } else if (i == b && i == e && n > 0) - /* ignore empty match on latest position */ - goto next; - - if (filter_is_callable) { - /* pass match object through filter */ - match = pattern_new_match(self, &state, 1); - if (!match) - goto error; - args = Py_BuildValue("(O)", match); - if (!args) { - Py_DECREF(match); - goto error; - } - item = PyObject_CallObject(filter, args); - Py_DECREF(args); - Py_DECREF(match); - if (!item) - goto error; - } else { - /* filter is literal string */ - item = filter; - Py_INCREF(item); - } - - /* add to list */ - if (item != Py_None) { - status = PyList_Append(list, item); - Py_DECREF(item); - if (status < 0) - goto error; - } - - i = e; - n = n + 1; - -next: - /* move on */ - if (state.ptr == state.start) - state.start = (void*) ((char*) state.ptr + state.charsize); - else - state.start = state.ptr; - - } - - /* get segment following last match */ - if (i < state.endpos) { - item = PySequence_GetSlice(string, i, state.endpos); - if (!item) - goto error; - status = PyList_Append(list, item); - Py_DECREF(item); - if (status < 0) - goto error; - } - - state_fini(&state); - - Py_DECREF(filter); - - /* convert list to single string (also removes list) */ - item = join_list(list, self->pattern); - - if (!item) - return NULL; - - if (subn) - return Py_BuildValue("Ni", item, n); - - return item; - -error: - Py_DECREF(list); - state_fini(&state); - Py_DECREF(filter); - return NULL; - -} - -static PyObject* -pattern_sub(PatternObject* self, PyObject* args, PyObject* kw) -{ - PyObject* template; - PyObject* string; - int count = 0; - static char* kwlist[] = { "repl", "string", "count", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|i:sub", kwlist, - &template, &string, &count)) - return NULL; - - return pattern_subx(self, template, string, count, 0); -} - -static PyObject* -pattern_subn(PatternObject* self, PyObject* args, PyObject* kw) -{ - PyObject* template; - PyObject* string; - int count = 0; - static char* kwlist[] = { "repl", "string", "count", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|i:subn", kwlist, - &template, &string, &count)) - return NULL; - - return pattern_subx(self, template, string, count, 1); -} - -static PyObject* -pattern_copy(PatternObject* self, PyObject* args) -{ -#ifdef USE_BUILTIN_COPY - PatternObject* copy; - int offset; - - if (args != Py_None && !PyArg_ParseTuple(args, ":__copy__")) - return NULL; - - copy = PyObject_NEW_VAR(PatternObject, &Pattern_Type, self->codesize); - if (!copy) - return NULL; - - offset = offsetof(PatternObject, groups); - - Py_XINCREF(self->groupindex); - Py_XINCREF(self->indexgroup); - Py_XINCREF(self->pattern); - - memcpy((char*) copy + offset, (char*) self + offset, - sizeof(PatternObject) + self->codesize * sizeof(SRE_CODE) - offset); - - return (PyObject*) copy; -#else - PyErr_SetString(PyExc_TypeError, "cannot copy this pattern object"); - return NULL; -#endif -} - -static PyObject* -pattern_deepcopy(PatternObject* self, PyObject* args) -{ -#ifdef USE_BUILTIN_COPY - PatternObject* copy; - - PyObject* memo; - if (!PyArg_ParseTuple(args, "O:__deepcopy__", &memo)) - return NULL; - - copy = (PatternObject*) pattern_copy(self, Py_None); - if (!copy) - return NULL; - - if (!deepcopy(©->groupindex, memo) || - !deepcopy(©->indexgroup, memo) || - !deepcopy(©->pattern, memo)) { - Py_DECREF(copy); - return NULL; - } - -#else - PyErr_SetString(PyExc_TypeError, "cannot deepcopy this pattern object"); - return NULL; -#endif -} - -static PyMethodDef pattern_methods[] = { - {"match", (PyCFunction) pattern_match, METH_VARARGS|METH_KEYWORDS}, - {"search", (PyCFunction) pattern_search, METH_VARARGS|METH_KEYWORDS}, - {"sub", (PyCFunction) pattern_sub, METH_VARARGS|METH_KEYWORDS}, - {"subn", (PyCFunction) pattern_subn, METH_VARARGS|METH_KEYWORDS}, - {"split", (PyCFunction) pattern_split, METH_VARARGS|METH_KEYWORDS}, - {"findall", (PyCFunction) pattern_findall, METH_VARARGS|METH_KEYWORDS}, -#if PY_VERSION_HEX >= 0x02020000 - {"finditer", (PyCFunction) pattern_finditer, METH_VARARGS}, -#endif - {"scanner", (PyCFunction) pattern_scanner, METH_VARARGS}, - {"__copy__", (PyCFunction) pattern_copy, METH_VARARGS}, - {"__deepcopy__", (PyCFunction) pattern_deepcopy, METH_VARARGS}, - {NULL, NULL} -}; - -static PyObject* -pattern_getattr(PatternObject* self, char* name) -{ - PyObject* res; - - res = Py_FindMethod(pattern_methods, (PyObject*) self, name); - - if (res) - return res; - - PyErr_Clear(); - - /* attributes */ - if (!strcmp(name, "pattern")) { - Py_INCREF(self->pattern); - return self->pattern; - } - - if (!strcmp(name, "flags")) - return Py_BuildValue("i", self->flags); - - if (!strcmp(name, "groups")) - return Py_BuildValue("i", self->groups); - - if (!strcmp(name, "groupindex") && self->groupindex) { - Py_INCREF(self->groupindex); - return self->groupindex; - } - - PyErr_SetString(PyExc_AttributeError, name); - return NULL; -} - -statichere PyTypeObject Pattern_Type = { - PyObject_HEAD_INIT(NULL) - 0, "_" SRE_MODULE ".SRE_Pattern", - sizeof(PatternObject), sizeof(SRE_CODE), - (destructor)pattern_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)pattern_getattr /*tp_getattr*/ -}; - -/* -------------------------------------------------------------------- */ -/* match methods */ - -static void -match_dealloc(MatchObject* self) -{ - Py_XDECREF(self->regs); - Py_XDECREF(self->string); - Py_DECREF(self->pattern); - PyObject_DEL(self); -} - -static PyObject* -match_getslice_by_index(MatchObject* self, int index, PyObject* def) -{ - if (index < 0 || index >= self->groups) { - /* raise IndexError if we were given a bad group number */ - PyErr_SetString( - PyExc_IndexError, - "no such group" - ); - return NULL; - } - - index *= 2; - - if (self->string == Py_None || self->mark[index] < 0) { - /* return default value if the string or group is undefined */ - Py_INCREF(def); - return def; - } - - return PySequence_GetSlice( - self->string, self->mark[index], self->mark[index+1] - ); -} - -static int -match_getindex(MatchObject* self, PyObject* index) -{ - int i; - - if (PyInt_Check(index)) - return (int) PyInt_AS_LONG(index); - - i = -1; - - if (self->pattern->groupindex) { - index = PyObject_GetItem(self->pattern->groupindex, index); - if (index) { - if (PyInt_Check(index)) - i = (int) PyInt_AS_LONG(index); - Py_DECREF(index); - } else - PyErr_Clear(); - } - - return i; -} - -static PyObject* -match_getslice(MatchObject* self, PyObject* index, PyObject* def) -{ - return match_getslice_by_index(self, match_getindex(self, index), def); -} - -static PyObject* -match_expand(MatchObject* self, PyObject* args) -{ - PyObject* template; - if (!PyArg_ParseTuple(args, "O:expand", &template)) - return NULL; - - /* delegate to Python code */ - return call( - SRE_MODULE, "_expand", - Py_BuildValue("OOO", self->pattern, self, template) - ); -} - -static PyObject* -match_group(MatchObject* self, PyObject* args) -{ - PyObject* result; - int i, size; - - size = PyTuple_GET_SIZE(args); - - switch (size) { - case 0: - result = match_getslice(self, Py_False, Py_None); - break; - case 1: - result = match_getslice(self, PyTuple_GET_ITEM(args, 0), Py_None); - break; - default: - /* fetch multiple items */ - result = PyTuple_New(size); - if (!result) - return NULL; - for (i = 0; i < size; i++) { - PyObject* item = match_getslice( - self, PyTuple_GET_ITEM(args, i), Py_None - ); - if (!item) { - Py_DECREF(result); - return NULL; - } - PyTuple_SET_ITEM(result, i, item); - } - break; - } - return result; -} - -static PyObject* -match_groups(MatchObject* self, PyObject* args, PyObject* kw) -{ - PyObject* result; - int index; - - PyObject* def = Py_None; - static char* kwlist[] = { "default", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kw, "|O:groups", kwlist, &def)) - return NULL; - - result = PyTuple_New(self->groups-1); - if (!result) - return NULL; - - for (index = 1; index < self->groups; index++) { - PyObject* item; - item = match_getslice_by_index(self, index, def); - if (!item) { - Py_DECREF(result); - return NULL; - } - PyTuple_SET_ITEM(result, index-1, item); - } - - return result; -} - -static PyObject* -match_groupdict(MatchObject* self, PyObject* args, PyObject* kw) -{ - PyObject* result; - PyObject* keys; - int index; - - PyObject* def = Py_None; - static char* kwlist[] = { "default", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kw, "|O:groupdict", kwlist, &def)) - return NULL; - - result = PyDict_New(); - if (!result || !self->pattern->groupindex) - return result; - - keys = PyMapping_Keys(self->pattern->groupindex); - if (!keys) - goto failed; - - for (index = 0; index < PyList_GET_SIZE(keys); index++) { - int status; - PyObject* key; - PyObject* value; - key = PyList_GET_ITEM(keys, index); - if (!key) - goto failed; - value = match_getslice(self, key, def); - if (!value) { - Py_DECREF(key); - goto failed; - } - status = PyDict_SetItem(result, key, value); - Py_DECREF(value); - if (status < 0) - goto failed; - } - - Py_DECREF(keys); - - return result; - -failed: - Py_DECREF(keys); - Py_DECREF(result); - return NULL; -} - -static PyObject* -match_start(MatchObject* self, PyObject* args) -{ - int index; - - PyObject* index_ = Py_False; /* zero */ - if (!PyArg_ParseTuple(args, "|O:start", &index_)) - return NULL; - - index = match_getindex(self, index_); - - if (index < 0 || index >= self->groups) { - PyErr_SetString( - PyExc_IndexError, - "no such group" - ); - return NULL; - } - - /* mark is -1 if group is undefined */ - return Py_BuildValue("i", self->mark[index*2]); -} - -static PyObject* -match_end(MatchObject* self, PyObject* args) -{ - int index; - - PyObject* index_ = Py_False; /* zero */ - if (!PyArg_ParseTuple(args, "|O:end", &index_)) - return NULL; - - index = match_getindex(self, index_); - - if (index < 0 || index >= self->groups) { - PyErr_SetString( - PyExc_IndexError, - "no such group" - ); - return NULL; - } - - /* mark is -1 if group is undefined */ - return Py_BuildValue("i", self->mark[index*2+1]); -} - -LOCAL(PyObject*) -_pair(int i1, int i2) -{ - PyObject* pair; - PyObject* item; - - pair = PyTuple_New(2); - if (!pair) - return NULL; - - item = PyInt_FromLong(i1); - if (!item) - goto error; - PyTuple_SET_ITEM(pair, 0, item); - - item = PyInt_FromLong(i2); - if (!item) - goto error; - PyTuple_SET_ITEM(pair, 1, item); - - return pair; - - error: - Py_DECREF(pair); - return NULL; -} - -static PyObject* -match_span(MatchObject* self, PyObject* args) -{ - int index; - - PyObject* index_ = Py_False; /* zero */ - if (!PyArg_ParseTuple(args, "|O:span", &index_)) - return NULL; - - index = match_getindex(self, index_); - - if (index < 0 || index >= self->groups) { - PyErr_SetString( - PyExc_IndexError, - "no such group" - ); - return NULL; - } - - /* marks are -1 if group is undefined */ - return _pair(self->mark[index*2], self->mark[index*2+1]); -} - -static PyObject* -match_regs(MatchObject* self) -{ - PyObject* regs; - PyObject* item; - int index; - - regs = PyTuple_New(self->groups); - if (!regs) - return NULL; - - for (index = 0; index < self->groups; index++) { - item = _pair(self->mark[index*2], self->mark[index*2+1]); - if (!item) { - Py_DECREF(regs); - return NULL; - } - PyTuple_SET_ITEM(regs, index, item); - } - - Py_INCREF(regs); - self->regs = regs; - - return regs; -} - -static PyObject* -match_copy(MatchObject* self, PyObject* args) -{ -#ifdef USE_BUILTIN_COPY - MatchObject* copy; - int slots, offset; - - if (args != Py_None && !PyArg_ParseTuple(args, ":__copy__")) - return NULL; - - slots = 2 * (self->pattern->groups+1); - - copy = PyObject_NEW_VAR(MatchObject, &Match_Type, slots); - if (!copy) - return NULL; - - /* this value a constant, but any compiler should be able to - figure that out all by itself */ - offset = offsetof(MatchObject, string); - - Py_XINCREF(self->pattern); - Py_XINCREF(self->string); - Py_XINCREF(self->regs); - - memcpy((char*) copy + offset, (char*) self + offset, - sizeof(MatchObject) + slots * sizeof(int) - offset); - - return (PyObject*) copy; -#else - PyErr_SetString(PyExc_TypeError, "cannot copy this match object"); - return NULL; -#endif -} - -static PyObject* -match_deepcopy(MatchObject* self, PyObject* args) -{ -#ifdef USE_BUILTIN_COPY - MatchObject* copy; - - PyObject* memo; - if (!PyArg_ParseTuple(args, "O:__deepcopy__", &memo)) - return NULL; - - copy = (MatchObject*) match_copy(self, Py_None); - if (!copy) - return NULL; - - if (!deepcopy((PyObject**) ©->pattern, memo) || - !deepcopy(©->string, memo) || - !deepcopy(©->regs, memo)) { - Py_DECREF(copy); - return NULL; - } - -#else - PyErr_SetString(PyExc_TypeError, "cannot deepcopy this match object"); - return NULL; -#endif -} - -static PyMethodDef match_methods[] = { - {"group", (PyCFunction) match_group, METH_VARARGS}, - {"start", (PyCFunction) match_start, METH_VARARGS}, - {"end", (PyCFunction) match_end, METH_VARARGS}, - {"span", (PyCFunction) match_span, METH_VARARGS}, - {"groups", (PyCFunction) match_groups, METH_VARARGS|METH_KEYWORDS}, - {"groupdict", (PyCFunction) match_groupdict, METH_VARARGS|METH_KEYWORDS}, - {"expand", (PyCFunction) match_expand, METH_VARARGS}, - {"__copy__", (PyCFunction) match_copy, METH_VARARGS}, - {"__deepcopy__", (PyCFunction) match_deepcopy, METH_VARARGS}, - {NULL, NULL} -}; - -static PyObject* -match_getattr(MatchObject* self, char* name) -{ - PyObject* res; - - res = Py_FindMethod(match_methods, (PyObject*) self, name); - if (res) - return res; - - PyErr_Clear(); - - if (!strcmp(name, "lastindex")) { - if (self->lastindex >= 0) - return Py_BuildValue("i", self->lastindex); - Py_INCREF(Py_None); - return Py_None; - } - - if (!strcmp(name, "lastgroup")) { - if (self->pattern->indexgroup && self->lastindex >= 0) { - PyObject* result = PySequence_GetItem( - self->pattern->indexgroup, self->lastindex - ); - if (result) - return result; - PyErr_Clear(); - } - Py_INCREF(Py_None); - return Py_None; - } - - if (!strcmp(name, "string")) { - if (self->string) { - Py_INCREF(self->string); - return self->string; - } else { - Py_INCREF(Py_None); - return Py_None; - } - } - - if (!strcmp(name, "regs")) { - if (self->regs) { - Py_INCREF(self->regs); - return self->regs; - } else - return match_regs(self); - } - - if (!strcmp(name, "re")) { - Py_INCREF(self->pattern); - return (PyObject*) self->pattern; - } - - if (!strcmp(name, "pos")) - return Py_BuildValue("i", self->pos); - - if (!strcmp(name, "endpos")) - return Py_BuildValue("i", self->endpos); - - PyErr_SetString(PyExc_AttributeError, name); - return NULL; -} - -/* FIXME: implement setattr("string", None) as a special case (to - detach the associated string, if any */ - -statichere PyTypeObject Match_Type = { - PyObject_HEAD_INIT(NULL) - 0, "_" SRE_MODULE ".SRE_Match", - sizeof(MatchObject), sizeof(int), - (destructor)match_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)match_getattr /*tp_getattr*/ -}; - -/* -------------------------------------------------------------------- */ -/* scanner methods (experimental) */ - -static void -scanner_dealloc(ScannerObject* self) -{ - state_fini(&self->state); - Py_DECREF(self->pattern); - PyObject_DEL(self); -} - -static PyObject* -scanner_match(ScannerObject* self, PyObject* args) -{ - SRE_STATE* state = &self->state; - PyObject* match; - int status; - - state_reset(state); - - state->ptr = state->start; - - if (state->charsize == 1) { - status = sre_match(state, PatternObject_GetCode(self->pattern), 1); - } else { -#if defined(HAVE_UNICODE) - status = sre_umatch(state, PatternObject_GetCode(self->pattern), 1); -#endif - } - - match = pattern_new_match((PatternObject*) self->pattern, - state, status); - - if ((status == 0 || state->ptr == state->start) && - state->ptr < state->end) - state->start = (void*) ((char*) state->ptr + state->charsize); - else - state->start = state->ptr; - - return match; -} - - -static PyObject* -scanner_search(ScannerObject* self, PyObject* args) -{ - SRE_STATE* state = &self->state; - PyObject* match; - int status; - - state_reset(state); - - state->ptr = state->start; - - if (state->charsize == 1) { - status = sre_search(state, PatternObject_GetCode(self->pattern)); - } else { -#if defined(HAVE_UNICODE) - status = sre_usearch(state, PatternObject_GetCode(self->pattern)); -#endif - } - - match = pattern_new_match((PatternObject*) self->pattern, - state, status); - - if ((status == 0 || state->ptr == state->start) && - state->ptr < state->end) - state->start = (void*) ((char*) state->ptr + state->charsize); - else - state->start = state->ptr; - - return match; -} - -static PyMethodDef scanner_methods[] = { - /* FIXME: use METH_OLDARGS instead of 0 or fix to use METH_VARARGS */ - /* METH_OLDARGS is not in Python 1.5.2 */ - {"match", (PyCFunction) scanner_match, 0}, - {"search", (PyCFunction) scanner_search, 0}, - {NULL, NULL} -}; - -static PyObject* -scanner_getattr(ScannerObject* self, char* name) -{ - PyObject* res; - - res = Py_FindMethod(scanner_methods, (PyObject*) self, name); - if (res) - return res; - - PyErr_Clear(); - - /* attributes */ - if (!strcmp(name, "pattern")) { - Py_INCREF(self->pattern); - return self->pattern; - } - - PyErr_SetString(PyExc_AttributeError, name); - return NULL; -} - -statichere PyTypeObject Scanner_Type = { - PyObject_HEAD_INIT(NULL) - 0, "_" SRE_MODULE ".SRE_Scanner", - sizeof(ScannerObject), 0, - (destructor)scanner_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)scanner_getattr, /*tp_getattr*/ -}; - -static PyMethodDef _functions[] = { - {"compile", _compile, METH_VARARGS}, - {"getcodesize", sre_codesize, METH_VARARGS}, - {"getlower", sre_getlower, METH_VARARGS}, - {NULL, NULL} -}; - -#if PY_VERSION_HEX < 0x02030000 -DL_EXPORT(void) init_sre(void) -#else -PyMODINIT_FUNC init_sre(void) -#endif -{ - PyObject* m; - PyObject* d; - PyObject* x; - - /* Patch object types */ - Pattern_Type.ob_type = Match_Type.ob_type = - Scanner_Type.ob_type = &PyType_Type; - - m = Py_InitModule("_" SRE_MODULE, _functions); - d = PyModule_GetDict(m); - - x = PyInt_FromLong(SRE_MAGIC); - if (x) { - PyDict_SetItemString(d, "MAGIC", x); - Py_DECREF(x); - } - - x = PyInt_FromLong(sizeof(SRE_CODE)); - if (x) { - PyDict_SetItemString(d, "CODESIZE", x); - Py_DECREF(x); - } - - x = PyString_FromString(copyright); - if (x) { - PyDict_SetItemString(d, "copyright", x); - Py_DECREF(x); - } -} - -#endif /* !defined(SRE_RECURSIVE) */ - -/* vim:ts=4:sw=4:et -*/ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/_ssl.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/_ssl.c deleted file mode 100644 index 9d26f32c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/_ssl.c +++ /dev/null @@ -1,639 +0,0 @@ -/* SSL socket module - - SSL support based on patches by Brian E Gallew and Laszlo Kovacs. - - This module is imported by socket.py. It should *not* be used - directly. - -*/ - -#include "Python.h" -enum py_ssl_error { - /* these mirror ssl.h */ - PY_SSL_ERROR_NONE, - PY_SSL_ERROR_SSL, - PY_SSL_ERROR_WANT_READ, - PY_SSL_ERROR_WANT_WRITE, - PY_SSL_ERROR_WANT_X509_LOOKUP, - PY_SSL_ERROR_SYSCALL, /* look at error stack/return value/errno */ - PY_SSL_ERROR_ZERO_RETURN, - PY_SSL_ERROR_WANT_CONNECT, - /* start of non ssl.h errorcodes */ - PY_SSL_ERROR_EOF, /* special case of SSL_ERROR_SYSCALL */ - PY_SSL_ERROR_INVALID_ERROR_CODE -}; - -/* Include symbols from _socket module */ -#include "socketmodule.h" - -/* Include OpenSSL header files */ -#include "openssl/rsa.h" -#include "openssl/crypto.h" -#include "openssl/x509.h" -#include "openssl/pem.h" -#include "openssl/ssl.h" -#include "openssl/err.h" -#include "openssl/rand.h" - -/* SSL error object */ -static PyObject *PySSLErrorObject; - -/* SSL socket object */ - -#define X509_NAME_MAXLEN 256 - -/* RAND_* APIs got added to OpenSSL in 0.9.5 */ -#if OPENSSL_VERSION_NUMBER >= 0x0090500fL -# define HAVE_OPENSSL_RAND 1 -#else -# undef HAVE_OPENSSL_RAND -#endif - -typedef struct { - PyObject_HEAD - PySocketSockObject *Socket; /* Socket on which we're layered */ - SSL_CTX* ctx; - SSL* ssl; - X509* server_cert; - BIO* sbio; - char server[X509_NAME_MAXLEN]; - char issuer[X509_NAME_MAXLEN]; - -} PySSLObject; - -static PyTypeObject PySSL_Type; -static PyObject *PySSL_SSLwrite(PySSLObject *self, PyObject *args); -static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args); -static int wait_for_timeout(PySocketSockObject *s, int writing); - -#define PySSLObject_Check(v) ((v)->ob_type == &PySSL_Type) - -/* XXX It might be helpful to augment the error message generated - below with the name of the SSL function that generated the error. - I expect it's obvious most of the time. -*/ - -static PyObject * -PySSL_SetError(PySSLObject *obj, int ret) -{ - PyObject *v, *n, *s; - char *errstr; - int err; - enum py_ssl_error p; - - assert(ret <= 0); - - err = SSL_get_error(obj->ssl, ret); - - switch (err) { - case SSL_ERROR_ZERO_RETURN: - errstr = "TLS/SSL connection has been closed"; - p = PY_SSL_ERROR_ZERO_RETURN; - break; - case SSL_ERROR_WANT_READ: - errstr = "The operation did not complete (read)"; - p = PY_SSL_ERROR_WANT_READ; - break; - case SSL_ERROR_WANT_WRITE: - p = PY_SSL_ERROR_WANT_WRITE; - errstr = "The operation did not complete (write)"; - break; - case SSL_ERROR_WANT_X509_LOOKUP: - p = PY_SSL_ERROR_WANT_X509_LOOKUP; - errstr = "The operation did not complete (X509 lookup)"; - break; - case SSL_ERROR_WANT_CONNECT: - p = PY_SSL_ERROR_WANT_CONNECT; - errstr = "The operation did not complete (connect)"; - break; - case SSL_ERROR_SYSCALL: - { - unsigned long e = ERR_get_error(); - if (e == 0) { - if (ret == 0 || !obj->Socket) { - p = PY_SSL_ERROR_EOF; - errstr = "EOF occurred in violation of protocol"; - } else if (ret == -1) { - /* the underlying BIO reported an I/O error */ - return obj->Socket->errorhandler(); - } else { /* possible? */ - p = PY_SSL_ERROR_SYSCALL; - errstr = "Some I/O error occurred"; - } - } else { - p = PY_SSL_ERROR_SYSCALL; - /* XXX Protected by global interpreter lock */ - errstr = ERR_error_string(e, NULL); - } - break; - } - case SSL_ERROR_SSL: - { - unsigned long e = ERR_get_error(); - p = PY_SSL_ERROR_SSL; - if (e != 0) - /* XXX Protected by global interpreter lock */ - errstr = ERR_error_string(e, NULL); - else { /* possible? */ - errstr = "A failure in the SSL library occurred"; - } - break; - } - default: - p = PY_SSL_ERROR_INVALID_ERROR_CODE; - errstr = "Invalid error code"; - } - n = PyInt_FromLong((long) p); - if (n == NULL) - return NULL; - v = PyTuple_New(2); - if (v == NULL) { - Py_DECREF(n); - return NULL; - } - - s = PyString_FromString(errstr); - if (s == NULL) { - Py_DECREF(v); - Py_DECREF(n); - } - PyTuple_SET_ITEM(v, 0, n); - PyTuple_SET_ITEM(v, 1, s); - PyErr_SetObject(PySSLErrorObject, v); - return NULL; -} - -static PySSLObject * -newPySSLObject(PySocketSockObject *Sock, char *key_file, char *cert_file) -{ - PySSLObject *self; - char *errstr = NULL; - int ret; - int err; - int timedout; - - self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new object */ - if (self == NULL){ - errstr = "newPySSLObject error"; - goto fail; - } - memset(self->server, '\0', sizeof(char) * X509_NAME_MAXLEN); - memset(self->issuer, '\0', sizeof(char) * X509_NAME_MAXLEN); - self->server_cert = NULL; - self->ssl = NULL; - self->ctx = NULL; - self->Socket = NULL; - - if ((key_file && !cert_file) || (!key_file && cert_file)) { - errstr = "Both the key & certificate files must be specified"; - goto fail; - } - - Py_BEGIN_ALLOW_THREADS - self->ctx = SSL_CTX_new(SSLv23_method()); /* Set up context */ - Py_END_ALLOW_THREADS - if (self->ctx == NULL) { - errstr = "SSL_CTX_new error"; - goto fail; - } - - if (key_file) { - Py_BEGIN_ALLOW_THREADS - ret = SSL_CTX_use_PrivateKey_file(self->ctx, key_file, - SSL_FILETYPE_PEM); - Py_END_ALLOW_THREADS - if (ret < 1) { - errstr = "SSL_CTX_use_PrivateKey_file error"; - goto fail; - } - - Py_BEGIN_ALLOW_THREADS - ret = SSL_CTX_use_certificate_chain_file(self->ctx, - cert_file); - Py_END_ALLOW_THREADS - if (ret < 1) { - errstr = "SSL_CTX_use_certificate_chain_file error"; - goto fail; - } - } - - Py_BEGIN_ALLOW_THREADS - SSL_CTX_set_verify(self->ctx, - SSL_VERIFY_NONE, NULL); /* set verify lvl */ - self->ssl = SSL_new(self->ctx); /* New ssl struct */ - Py_END_ALLOW_THREADS - SSL_set_fd(self->ssl, Sock->sock_fd); /* Set the socket for SSL */ - - /* If the socket is in non-blocking mode or timeout mode, set the BIO - * to non-blocking mode (blocking is the default) - */ - if (Sock->sock_timeout >= 0.0) { - /* Set both the read and write BIO's to non-blocking mode */ - BIO_set_nbio(SSL_get_rbio(self->ssl), 1); - BIO_set_nbio(SSL_get_wbio(self->ssl), 1); - } - - Py_BEGIN_ALLOW_THREADS - SSL_set_connect_state(self->ssl); - Py_END_ALLOW_THREADS - - /* Actually negotiate SSL connection */ - /* XXX If SSL_connect() returns 0, it's also a failure. */ - timedout = 0; - do { - Py_BEGIN_ALLOW_THREADS - ret = SSL_connect(self->ssl); - err = SSL_get_error(self->ssl, ret); - Py_END_ALLOW_THREADS - if(PyErr_CheckSignals()) { - goto fail; - } - if (err == SSL_ERROR_WANT_READ) { - timedout = wait_for_timeout(Sock, 0); - } else if (err == SSL_ERROR_WANT_WRITE) { - timedout = wait_for_timeout(Sock, 1); - } - if (timedout) { - errstr = "The connect operation timed out"; - goto fail; - } - } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE); - if (ret <= 0) { - PySSL_SetError(self, ret); - goto fail; - } - self->ssl->debug = 1; - - Py_BEGIN_ALLOW_THREADS - if ((self->server_cert = SSL_get_peer_certificate(self->ssl))) { - X509_NAME_oneline(X509_get_subject_name(self->server_cert), - self->server, X509_NAME_MAXLEN); - X509_NAME_oneline(X509_get_issuer_name(self->server_cert), - self->issuer, X509_NAME_MAXLEN); - } - Py_END_ALLOW_THREADS - self->Socket = Sock; - Py_INCREF(self->Socket); - return self; - fail: - if (errstr) - PyErr_SetString(PySSLErrorObject, errstr); - Py_DECREF(self); - return NULL; -} - -static PyObject * -PySocket_ssl(PyObject *self, PyObject *args) -{ - PySSLObject *rv; - PySocketSockObject *Sock; - char *key_file = NULL; - char *cert_file = NULL; - - if (!PyArg_ParseTuple(args, "O!|zz:ssl", - PySocketModule.Sock_Type, - (PyObject*)&Sock, - &key_file, &cert_file)) - return NULL; - - rv = newPySSLObject(Sock, key_file, cert_file); - if (rv == NULL) - return NULL; - return (PyObject *)rv; -} - -PyDoc_STRVAR(ssl_doc, -"ssl(socket, [keyfile, certfile]) -> sslobject"); - -/* SSL object methods */ - -static PyObject * -PySSL_server(PySSLObject *self) -{ - return PyString_FromString(self->server); -} - -static PyObject * -PySSL_issuer(PySSLObject *self) -{ - return PyString_FromString(self->issuer); -} - - -static void PySSL_dealloc(PySSLObject *self) -{ - if (self->server_cert) /* Possible not to have one? */ - X509_free (self->server_cert); - if (self->ssl) - SSL_free(self->ssl); - if (self->ctx) - SSL_CTX_free(self->ctx); - Py_XDECREF(self->Socket); - PyObject_Del(self); -} - -/* If the socket has a timeout, do a select() on the socket. - The argument writing indicates the direction. - Return non-zero if the socket timed out, zero otherwise. - */ -static int -wait_for_timeout(PySocketSockObject *s, int writing) -{ - fd_set fds; - struct timeval tv; - int rc; - - /* Nothing to do unless we're in timeout mode (not non-blocking) */ - if (s->sock_timeout <= 0.0) - return 0; - - /* Guard against closed socket */ - if (s->sock_fd < 0) - return 0; - - /* Construct the arguments to select */ - tv.tv_sec = (int)s->sock_timeout; - tv.tv_usec = (int)((s->sock_timeout - tv.tv_sec) * 1e6); - FD_ZERO(&fds); - FD_SET(s->sock_fd, &fds); - - /* See if the socket is ready */ - Py_BEGIN_ALLOW_THREADS - if (writing) - rc = select(s->sock_fd+1, NULL, &fds, NULL, &tv); - else - rc = select(s->sock_fd+1, &fds, NULL, NULL, &tv); - Py_END_ALLOW_THREADS - - /* Return 1 on timeout, 0 otherwise */ - return rc == 0; -} - -static PyObject *PySSL_SSLwrite(PySSLObject *self, PyObject *args) -{ - char *data; - int len; - int count; - int timedout; - int err; - - if (!PyArg_ParseTuple(args, "s#:write", &data, &count)) - return NULL; - - timedout = wait_for_timeout(self->Socket, 1); - if (timedout) { - PyErr_SetString(PySSLErrorObject, "The write operation timed out"); - return NULL; - } - do { - err = 0; - Py_BEGIN_ALLOW_THREADS - len = SSL_write(self->ssl, data, count); - err = SSL_get_error(self->ssl, len); - Py_END_ALLOW_THREADS - if(PyErr_CheckSignals()) { - return NULL; - } - if (err == SSL_ERROR_WANT_READ) { - timedout = wait_for_timeout(self->Socket, 0); - } else if (err == SSL_ERROR_WANT_WRITE) { - timedout = wait_for_timeout(self->Socket, 1); - } - if (timedout) { - PyErr_SetString(PySSLErrorObject, "The write operation timed out"); - return NULL; - } - } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE); - if (len > 0) - return PyInt_FromLong(len); - else - return PySSL_SetError(self, len); -} - -PyDoc_STRVAR(PySSL_SSLwrite_doc, -"write(s) -> len\n\ -\n\ -Writes the string s into the SSL object. Returns the number\n\ -of bytes written."); - -static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args) -{ - PyObject *buf; - int count = 0; - int len = 1024; - int timedout; - int err; - - if (!PyArg_ParseTuple(args, "|i:read", &len)) - return NULL; - - if (!(buf = PyString_FromStringAndSize((char *) 0, len))) - return NULL; - - timedout = wait_for_timeout(self->Socket, 0); - if (timedout) { - PyErr_SetString(PySSLErrorObject, "The read operation timed out"); - Py_DECREF(buf); - return NULL; - } - do { - err = 0; - Py_BEGIN_ALLOW_THREADS - count = SSL_read(self->ssl, PyString_AsString(buf), len); - err = SSL_get_error(self->ssl, count); - Py_END_ALLOW_THREADS - if(PyErr_CheckSignals()) { - Py_DECREF(buf); - return NULL; - } - if (err == SSL_ERROR_WANT_READ) { - timedout = wait_for_timeout(self->Socket, 0); - } else if (err == SSL_ERROR_WANT_WRITE) { - timedout = wait_for_timeout(self->Socket, 1); - } - if (timedout) { - PyErr_SetString(PySSLErrorObject, "The read operation timed out"); - Py_DECREF(buf); - return NULL; - } - } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE); - if (count <= 0) { - Py_DECREF(buf); - return PySSL_SetError(self, count); - } - if (count != len) - _PyString_Resize(&buf, count); - return buf; -} - -PyDoc_STRVAR(PySSL_SSLread_doc, -"read([len]) -> string\n\ -\n\ -Read up to len bytes from the SSL socket."); - -static PyMethodDef PySSLMethods[] = { - {"write", (PyCFunction)PySSL_SSLwrite, METH_VARARGS, - PySSL_SSLwrite_doc}, - {"read", (PyCFunction)PySSL_SSLread, METH_VARARGS, - PySSL_SSLread_doc}, - {"server", (PyCFunction)PySSL_server, METH_NOARGS}, - {"issuer", (PyCFunction)PySSL_issuer, METH_NOARGS}, - {NULL, NULL} -}; - -static PyObject *PySSL_getattr(PySSLObject *self, char *name) -{ - return Py_FindMethod(PySSLMethods, (PyObject *)self, name); -} - -static PyTypeObject PySSL_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "socket.SSL", /*tp_name*/ - sizeof(PySSLObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)PySSL_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)PySSL_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ -}; - -#ifdef HAVE_OPENSSL_RAND - -/* helper routines for seeding the SSL PRNG */ -static PyObject * -PySSL_RAND_add(PyObject *self, PyObject *args) -{ - char *buf; - int len; - double entropy; - - if (!PyArg_ParseTuple(args, "s#d:RAND_add", &buf, &len, &entropy)) - return NULL; - RAND_add(buf, len, entropy); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(PySSL_RAND_add_doc, -"RAND_add(string, entropy)\n\ -\n\ -Mix string into the OpenSSL PRNG state. entropy (a float) is a lower\n\ -bound on the entropy contained in string."); - -static PyObject * -PySSL_RAND_status(PyObject *self) -{ - return PyInt_FromLong(RAND_status()); -} - -PyDoc_STRVAR(PySSL_RAND_status_doc, -"RAND_status() -> 0 or 1\n\ -\n\ -Returns 1 if the OpenSSL PRNG has been seeded with enough data and 0 if not.\n\ -It is necessary to seed the PRNG with RAND_add() on some platforms before\n\ -using the ssl() function."); - -static PyObject * -PySSL_RAND_egd(PyObject *self, PyObject *arg) -{ - int bytes; - - if (!PyString_Check(arg)) - return PyErr_Format(PyExc_TypeError, - "RAND_egd() expected string, found %s", - arg->ob_type->tp_name); - bytes = RAND_egd(PyString_AS_STRING(arg)); - if (bytes == -1) { - PyErr_SetString(PySSLErrorObject, - "EGD connection failed or EGD did not return " - "enough data to seed the PRNG"); - return NULL; - } - return PyInt_FromLong(bytes); -} - -PyDoc_STRVAR(PySSL_RAND_egd_doc, -"RAND_egd(path) -> bytes\n\ -\n\ -Queries the entropy gather daemon (EGD) on socket path. Returns number\n\ -of bytes read. Raises socket.sslerror if connection to EGD fails or\n\ -if it does provide enough data to seed PRNG."); - -#endif - -/* List of functions exported by this module. */ - -static PyMethodDef PySSL_methods[] = { - {"ssl", PySocket_ssl, - METH_VARARGS, ssl_doc}, -#ifdef HAVE_OPENSSL_RAND - {"RAND_add", PySSL_RAND_add, METH_VARARGS, - PySSL_RAND_add_doc}, - {"RAND_egd", PySSL_RAND_egd, METH_O, - PySSL_RAND_egd_doc}, - {"RAND_status", (PyCFunction)PySSL_RAND_status, METH_NOARGS, - PySSL_RAND_status_doc}, -#endif - {NULL, NULL} /* Sentinel */ -}; - - -PyDoc_STRVAR(module_doc, -"Implementation module for SSL socket operations. See the socket module\n\ -for documentation."); - -PyMODINIT_FUNC -init_ssl(void) -{ - PyObject *m, *d; - - PySSL_Type.ob_type = &PyType_Type; - - m = Py_InitModule3("_ssl", PySSL_methods, module_doc); - d = PyModule_GetDict(m); - - /* Load _socket module and its C API */ - if (PySocketModule_ImportModuleAndAPI()) - return; - - /* Init OpenSSL */ - SSL_load_error_strings(); - SSLeay_add_ssl_algorithms(); - - /* Add symbols to module dict */ - PySSLErrorObject = PyErr_NewException("socket.sslerror", NULL, NULL); - if (PySSLErrorObject == NULL) - return; - PyDict_SetItemString(d, "sslerror", PySSLErrorObject); - if (PyDict_SetItemString(d, "SSLType", - (PyObject *)&PySSL_Type) != 0) - return; - PyModule_AddIntConstant(m, "SSL_ERROR_ZERO_RETURN", - PY_SSL_ERROR_ZERO_RETURN); - PyModule_AddIntConstant(m, "SSL_ERROR_WANT_READ", - PY_SSL_ERROR_WANT_READ); - PyModule_AddIntConstant(m, "SSL_ERROR_WANT_WRITE", - PY_SSL_ERROR_WANT_WRITE); - PyModule_AddIntConstant(m, "SSL_ERROR_WANT_X509_LOOKUP", - PY_SSL_ERROR_WANT_X509_LOOKUP); - PyModule_AddIntConstant(m, "SSL_ERROR_SYSCALL", - PY_SSL_ERROR_SYSCALL); - PyModule_AddIntConstant(m, "SSL_ERROR_SSL", - PY_SSL_ERROR_SSL); - PyModule_AddIntConstant(m, "SSL_ERROR_WANT_CONNECT", - PY_SSL_ERROR_WANT_CONNECT); - /* non ssl.h errorcodes */ - PyModule_AddIntConstant(m, "SSL_ERROR_EOF", - PY_SSL_ERROR_EOF); - PyModule_AddIntConstant(m, "SSL_ERROR_INVALID_ERROR_CODE", - PY_SSL_ERROR_INVALID_ERROR_CODE); - -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/_testcapimodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/_testcapimodule.c deleted file mode 100644 index caae20b6..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/_testcapimodule.c +++ /dev/null @@ -1,642 +0,0 @@ -/* - * C Extension module to test Python interpreter C APIs. - * - * The 'test_*' functions exported by this module are run as part of the - * standard Python regression test, via Lib/test/test_capi.py. - */ - -#include "Python.h" - -#ifdef WITH_THREAD -#include "pythread.h" -#endif /* WITH_THREAD */ - -static PyObject *TestError; /* set to exception object in init */ - -/* Raise TestError with test_name + ": " + msg, and return NULL. */ - -static PyObject * -raiseTestError(const char* test_name, const char* msg) -{ - char buf[2048]; - - if (strlen(test_name) + strlen(msg) > sizeof(buf) - 50) - PyErr_SetString(TestError, "internal error msg too large"); - else { - PyOS_snprintf(buf, sizeof(buf), "%s: %s", test_name, msg); - PyErr_SetString(TestError, buf); - } - return NULL; -} - -/* Test #defines from pyconfig.h (particularly the SIZEOF_* defines). - - The ones derived from autoconf on the UNIX-like OSes can be relied - upon (in the absence of sloppy cross-compiling), but the Windows - platforms have these hardcoded. Better safe than sorry. -*/ -static PyObject* -sizeof_error(const char* fatname, const char* typename, - int expected, int got) -{ - char buf[1024]; - PyOS_snprintf(buf, sizeof(buf), - "%.200s #define == %d but sizeof(%.200s) == %d", - fatname, expected, typename, got); - PyErr_SetString(TestError, buf); - return (PyObject*)NULL; -} - -static PyObject* -test_config(PyObject *self) -{ -#define CHECK_SIZEOF(FATNAME, TYPE) \ - if (FATNAME != sizeof(TYPE)) \ - return sizeof_error(#FATNAME, #TYPE, FATNAME, sizeof(TYPE)) - - CHECK_SIZEOF(SIZEOF_SHORT, short); - CHECK_SIZEOF(SIZEOF_INT, int); - CHECK_SIZEOF(SIZEOF_LONG, long); - CHECK_SIZEOF(SIZEOF_VOID_P, void*); - CHECK_SIZEOF(SIZEOF_TIME_T, time_t); -#ifdef HAVE_LONG_LONG - CHECK_SIZEOF(SIZEOF_LONG_LONG, PY_LONG_LONG); -#endif - -#undef CHECK_SIZEOF - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject* -test_list_api(PyObject *self) -{ - PyObject* list; - int i; - - /* SF bug 132008: PyList_Reverse segfaults */ -#define NLIST 30 - list = PyList_New(NLIST); - if (list == (PyObject*)NULL) - return (PyObject*)NULL; - /* list = range(NLIST) */ - for (i = 0; i < NLIST; ++i) { - PyObject* anint = PyInt_FromLong(i); - if (anint == (PyObject*)NULL) { - Py_DECREF(list); - return (PyObject*)NULL; - } - PyList_SET_ITEM(list, i, anint); - } - /* list.reverse(), via PyList_Reverse() */ - i = PyList_Reverse(list); /* should not blow up! */ - if (i != 0) { - Py_DECREF(list); - return (PyObject*)NULL; - } - /* Check that list == range(29, -1, -1) now */ - for (i = 0; i < NLIST; ++i) { - PyObject* anint = PyList_GET_ITEM(list, i); - if (PyInt_AS_LONG(anint) != NLIST-1-i) { - PyErr_SetString(TestError, - "test_list_api: reverse screwed up"); - Py_DECREF(list); - return (PyObject*)NULL; - } - } - Py_DECREF(list); -#undef NLIST - - Py_INCREF(Py_None); - return Py_None; -} - -static int -test_dict_inner(int count) -{ - int pos = 0, iterations = 0, i; - PyObject *dict = PyDict_New(); - PyObject *v, *k; - - if (dict == NULL) - return -1; - - for (i = 0; i < count; i++) { - v = PyInt_FromLong(i); - PyDict_SetItem(dict, v, v); - Py_DECREF(v); - } - - while (PyDict_Next(dict, &pos, &k, &v)) { - PyObject *o; - iterations++; - - i = PyInt_AS_LONG(v) + 1; - o = PyInt_FromLong(i); - if (o == NULL) - return -1; - if (PyDict_SetItem(dict, k, o) < 0) { - Py_DECREF(o); - return -1; - } - Py_DECREF(o); - } - - Py_DECREF(dict); - - if (iterations != count) { - PyErr_SetString( - TestError, - "test_dict_iteration: dict iteration went wrong "); - return -1; - } else { - return 0; - } -} - -static PyObject* -test_dict_iteration(PyObject* self) -{ - int i; - - for (i = 0; i < 200; i++) { - if (test_dict_inner(i) < 0) { - return NULL; - } - } - - Py_INCREF(Py_None); - return Py_None; -} - - -/* Tests of PyLong_{As, From}{Unsigned,}Long(), and (#ifdef HAVE_LONG_LONG) - PyLong_{As, From}{Unsigned,}LongLong(). - - Note that the meat of the test is contained in testcapi_long.h. - This is revolting, but delicate code duplication is worse: "almost - exactly the same" code is needed to test PY_LONG_LONG, but the ubiquitous - dependence on type names makes it impossible to use a parameterized - function. A giant macro would be even worse than this. A C++ template - would be perfect. - - The "report an error" functions are deliberately not part of the #include - file: if the test fails, you can set a breakpoint in the appropriate - error function directly, and crawl back from there in the debugger. -*/ - -#define UNBIND(X) Py_DECREF(X); (X) = NULL - -static PyObject * -raise_test_long_error(const char* msg) -{ - return raiseTestError("test_long_api", msg); -} - -#define TESTNAME test_long_api_inner -#define TYPENAME long -#define F_S_TO_PY PyLong_FromLong -#define F_PY_TO_S PyLong_AsLong -#define F_U_TO_PY PyLong_FromUnsignedLong -#define F_PY_TO_U PyLong_AsUnsignedLong - -#include "testcapi_long.h" - -static PyObject * -test_long_api(PyObject* self) -{ - return TESTNAME(raise_test_long_error); -} - -#undef TESTNAME -#undef TYPENAME -#undef F_S_TO_PY -#undef F_PY_TO_S -#undef F_U_TO_PY -#undef F_PY_TO_U - -#ifdef HAVE_LONG_LONG - -static PyObject * -raise_test_longlong_error(const char* msg) -{ - return raiseTestError("test_longlong_api", msg); -} - -#define TESTNAME test_longlong_api_inner -#define TYPENAME PY_LONG_LONG -#define F_S_TO_PY PyLong_FromLongLong -#define F_PY_TO_S PyLong_AsLongLong -#define F_U_TO_PY PyLong_FromUnsignedLongLong -#define F_PY_TO_U PyLong_AsUnsignedLongLong - -#include "testcapi_long.h" - -static PyObject * -test_longlong_api(PyObject* self) -{ - return TESTNAME(raise_test_longlong_error); -} - -#undef TESTNAME -#undef TYPENAME -#undef F_S_TO_PY -#undef F_PY_TO_S -#undef F_U_TO_PY -#undef F_PY_TO_U - -/* Test the L code for PyArg_ParseTuple. This should deliver a PY_LONG_LONG - for both long and int arguments. The test may leak a little memory if - it fails. -*/ -static PyObject * -test_L_code(PyObject *self) -{ - PyObject *tuple, *num; - PY_LONG_LONG value; - - tuple = PyTuple_New(1); - if (tuple == NULL) - return NULL; - - num = PyLong_FromLong(42); - if (num == NULL) - return NULL; - - PyTuple_SET_ITEM(tuple, 0, num); - - value = -1; - if (PyArg_ParseTuple(tuple, "L:test_L_code", &value) < 0) - return NULL; - if (value != 42) - return raiseTestError("test_L_code", - "L code returned wrong value for long 42"); - - Py_DECREF(num); - num = PyInt_FromLong(42); - if (num == NULL) - return NULL; - - PyTuple_SET_ITEM(tuple, 0, num); - - value = -1; - if (PyArg_ParseTuple(tuple, "L:test_L_code", &value) < 0) - return NULL; - if (value != 42) - return raiseTestError("test_L_code", - "L code returned wrong value for int 42"); - - Py_DECREF(tuple); - Py_INCREF(Py_None); - return Py_None; -} - -#endif /* ifdef HAVE_LONG_LONG */ - -/* Functions to call PyArg_ParseTuple with integer format codes, - and return the result. -*/ -static PyObject * -getargs_b(PyObject *self, PyObject *args) -{ - unsigned char value; - if (!PyArg_ParseTuple(args, "b", &value)) - return NULL; - return PyLong_FromUnsignedLong((unsigned long)value); -} - -static PyObject * -getargs_B(PyObject *self, PyObject *args) -{ - unsigned char value; - if (!PyArg_ParseTuple(args, "B", &value)) - return NULL; - return PyLong_FromUnsignedLong((unsigned long)value); -} - -static PyObject * -getargs_H(PyObject *self, PyObject *args) -{ - unsigned short value; - if (!PyArg_ParseTuple(args, "H", &value)) - return NULL; - return PyLong_FromUnsignedLong((unsigned long)value); -} - -static PyObject * -getargs_I(PyObject *self, PyObject *args) -{ - unsigned int value; - if (!PyArg_ParseTuple(args, "I", &value)) - return NULL; - return PyLong_FromUnsignedLong((unsigned long)value); -} - -static PyObject * -getargs_k(PyObject *self, PyObject *args) -{ - unsigned long value; - if (!PyArg_ParseTuple(args, "k", &value)) - return NULL; - return PyLong_FromUnsignedLong(value); -} - -static PyObject * -getargs_i(PyObject *self, PyObject *args) -{ - int value; - if (!PyArg_ParseTuple(args, "i", &value)) - return NULL; - return PyLong_FromLong((long)value); -} - -static PyObject * -getargs_l(PyObject *self, PyObject *args) -{ - long value; - if (!PyArg_ParseTuple(args, "l", &value)) - return NULL; - return PyLong_FromLong(value); -} - -#ifdef HAVE_LONG_LONG -static PyObject * -getargs_L(PyObject *self, PyObject *args) -{ - PY_LONG_LONG value; - if (!PyArg_ParseTuple(args, "L", &value)) - return NULL; - return PyLong_FromLongLong(value); -} - -static PyObject * -getargs_K(PyObject *self, PyObject *args) -{ - unsigned PY_LONG_LONG value; - if (!PyArg_ParseTuple(args, "K", &value)) - return NULL; - return PyLong_FromUnsignedLongLong(value); -} -#endif - -/* This function not only tests the 'k' getargs code, but also the - PyInt_AsUnsignedLongMask() and PyInt_AsUnsignedLongMask() functions. */ -static PyObject * -test_k_code(PyObject *self) -{ - PyObject *tuple, *num; - unsigned long value; - - tuple = PyTuple_New(1); - if (tuple == NULL) - return NULL; - - /* a number larger than ULONG_MAX even on 64-bit platforms */ - num = PyLong_FromString("FFFFFFFFFFFFFFFFFFFFFFFF", NULL, 16); - if (num == NULL) - return NULL; - - value = PyInt_AsUnsignedLongMask(num); - if (value != ULONG_MAX) - return raiseTestError("test_k_code", - "PyInt_AsUnsignedLongMask() returned wrong value for long 0xFFF...FFF"); - - PyTuple_SET_ITEM(tuple, 0, num); - - value = -1; - if (PyArg_ParseTuple(tuple, "k:test_k_code", &value) < 0) - return NULL; - if (value != ULONG_MAX) - return raiseTestError("test_k_code", - "k code returned wrong value for long 0xFFF...FFF"); - - Py_DECREF(num); - num = PyLong_FromString("-FFFFFFFF000000000000000042", NULL, 16); - if (num == NULL) - return NULL; - - value = PyInt_AsUnsignedLongMask(num); - if (value != (unsigned long)-0x42) - return raiseTestError("test_k_code", - "PyInt_AsUnsignedLongMask() returned wrong value for long 0xFFF...FFF"); - - PyTuple_SET_ITEM(tuple, 0, num); - - value = -1; - if (PyArg_ParseTuple(tuple, "k:test_k_code", &value) < 0) - return NULL; - if (value != (unsigned long)-0x42) - return raiseTestError("test_k_code", - "k code returned wrong value for long -0xFFF..000042"); - - Py_DECREF(tuple); - Py_INCREF(Py_None); - return Py_None; -} - -#ifdef Py_USING_UNICODE - -/* Test the u and u# codes for PyArg_ParseTuple. May leak memory in case - of an error. -*/ -static PyObject * -test_u_code(PyObject *self) -{ - PyObject *tuple, *obj; - Py_UNICODE *value; - int len; - - tuple = PyTuple_New(1); - if (tuple == NULL) - return NULL; - - obj = PyUnicode_Decode("test", strlen("test"), - "ascii", NULL); - if (obj == NULL) - return NULL; - - PyTuple_SET_ITEM(tuple, 0, obj); - - value = 0; - if (PyArg_ParseTuple(tuple, "u:test_u_code", &value) < 0) - return NULL; - if (value != PyUnicode_AS_UNICODE(obj)) - return raiseTestError("test_u_code", - "u code returned wrong value for u'test'"); - value = 0; - if (PyArg_ParseTuple(tuple, "u#:test_u_code", &value, &len) < 0) - return NULL; - if (value != PyUnicode_AS_UNICODE(obj) || - len != PyUnicode_GET_SIZE(obj)) - return raiseTestError("test_u_code", - "u# code returned wrong values for u'test'"); - - Py_DECREF(tuple); - Py_INCREF(Py_None); - return Py_None; -} - -#endif - -/* Simple test of _PyLong_NumBits and _PyLong_Sign. */ -static PyObject * -test_long_numbits(PyObject *self) -{ - struct triple { - long input; - size_t nbits; - int sign; - } testcases[] = {{0, 0, 0}, - {1L, 1, 1}, - {-1L, 1, -1}, - {2L, 2, 1}, - {-2L, 2, -1}, - {3L, 2, 1}, - {-3L, 2, -1}, - {4L, 3, 1}, - {-4L, 3, -1}, - {0x7fffL, 15, 1}, /* one Python long digit */ - {-0x7fffL, 15, -1}, - {0xffffL, 16, 1}, - {-0xffffL, 16, -1}, - {0xfffffffL, 28, 1}, - {-0xfffffffL, 28, -1}}; - int i; - - for (i = 0; i < sizeof(testcases) / sizeof(struct triple); ++i) { - PyObject *plong = PyLong_FromLong(testcases[i].input); - size_t nbits = _PyLong_NumBits(plong); - int sign = _PyLong_Sign(plong); - - Py_DECREF(plong); - if (nbits != testcases[i].nbits) - return raiseTestError("test_long_numbits", - "wrong result for _PyLong_NumBits"); - if (sign != testcases[i].sign) - return raiseTestError("test_long_numbits", - "wrong result for _PyLong_Sign"); - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -raise_exception(PyObject *self, PyObject *args) -{ - PyObject *exc; - PyObject *exc_args, *v; - int num_args, i; - - if (!PyArg_ParseTuple(args, "Oi:raise_exception", - &exc, &num_args)) - return NULL; - - exc_args = PyTuple_New(num_args); - if (exc_args == NULL) - return NULL; - for (i = 0; i < num_args; ++i) { - v = PyInt_FromLong(i); - if (v == NULL) { - Py_DECREF(exc_args); - return NULL; - } - PyTuple_SET_ITEM(exc_args, i, v); - } - PyErr_SetObject(exc, exc_args); - return NULL; -} - -#ifdef WITH_THREAD - -void _make_call(void *callable) -{ - PyObject *rc; - PyGILState_STATE s = PyGILState_Ensure(); - rc = PyObject_CallFunction(callable, ""); - Py_XDECREF(rc); - PyGILState_Release(s); -} - -static PyObject * -test_thread_state(PyObject *self, PyObject *args) -{ - PyObject *fn; - if (!PyArg_ParseTuple(args, "O:test_thread_state", &fn)) - return NULL; - /* Ensure Python is setup for threading */ - PyEval_InitThreads(); - /* Start a new thread for our callback. */ - PyThread_start_new_thread( _make_call, fn); - /* Make the callback with the thread lock held by this thread */ - _make_call(fn); - /* Do it all again, but this time with the thread-lock released */ - Py_BEGIN_ALLOW_THREADS - _make_call(fn); - Py_END_ALLOW_THREADS - /* And once more with and without a thread - XXX - should use a lock and work out exactly what we are trying - to test - */ - Py_BEGIN_ALLOW_THREADS - PyThread_start_new_thread( _make_call, fn); - _make_call(fn); - Py_END_ALLOW_THREADS - Py_INCREF(Py_None); - return Py_None; -} -#endif - -static PyMethodDef TestMethods[] = { - {"raise_exception", raise_exception, METH_VARARGS}, - {"test_config", (PyCFunction)test_config, METH_NOARGS}, - {"test_list_api", (PyCFunction)test_list_api, METH_NOARGS}, - {"test_dict_iteration", (PyCFunction)test_dict_iteration,METH_NOARGS}, - {"test_long_api", (PyCFunction)test_long_api, METH_NOARGS}, - {"test_long_numbits", (PyCFunction)test_long_numbits, METH_NOARGS}, - {"test_k_code", (PyCFunction)test_k_code, METH_NOARGS}, - - {"getargs_b", (PyCFunction)getargs_b, METH_VARARGS}, - {"getargs_B", (PyCFunction)getargs_B, METH_VARARGS}, - {"getargs_H", (PyCFunction)getargs_H, METH_VARARGS}, - {"getargs_I", (PyCFunction)getargs_I, METH_VARARGS}, - {"getargs_k", (PyCFunction)getargs_k, METH_VARARGS}, - {"getargs_i", (PyCFunction)getargs_i, METH_VARARGS}, - {"getargs_l", (PyCFunction)getargs_l, METH_VARARGS}, -#ifdef HAVE_LONG_LONG - {"getargs_L", (PyCFunction)getargs_L, METH_VARARGS}, - {"getargs_K", (PyCFunction)getargs_K, METH_VARARGS}, - {"test_longlong_api", (PyCFunction)test_longlong_api, METH_NOARGS}, - {"test_L_code", (PyCFunction)test_L_code, METH_NOARGS}, -#endif -#ifdef Py_USING_UNICODE - {"test_u_code", (PyCFunction)test_u_code, METH_NOARGS}, -#endif -#ifdef WITH_THREAD - {"_test_thread_state", (PyCFunction)test_thread_state, METH_VARARGS}, -#endif - {NULL, NULL} /* sentinel */ -}; - -#define AddSym(d, n, f, v) {PyObject *o = f(v); PyDict_SetItemString(d, n, o); Py_DECREF(o);} - -PyMODINIT_FUNC -init_testcapi(void) -{ - PyObject *m; - - m = Py_InitModule("_testcapi", TestMethods); - - PyModule_AddObject(m, "UCHAR_MAX", PyInt_FromLong(UCHAR_MAX)); - PyModule_AddObject(m, "USHRT_MAX", PyInt_FromLong(USHRT_MAX)); - PyModule_AddObject(m, "UINT_MAX", PyLong_FromUnsignedLong(UINT_MAX)); - PyModule_AddObject(m, "ULONG_MAX", PyLong_FromUnsignedLong(ULONG_MAX)); - PyModule_AddObject(m, "INT_MIN", PyInt_FromLong(INT_MIN)); - PyModule_AddObject(m, "LONG_MIN", PyInt_FromLong(LONG_MIN)); - PyModule_AddObject(m, "INT_MAX", PyInt_FromLong(INT_MAX)); - PyModule_AddObject(m, "LONG_MAX", PyInt_FromLong(LONG_MAX)); - - TestError = PyErr_NewException("_testcapi.error", NULL, NULL); - Py_INCREF(TestError); - PyModule_AddObject(m, "error", TestError); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/_tkinter.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/_tkinter.c deleted file mode 100644 index 772fe110..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/_tkinter.c +++ /dev/null @@ -1,3203 +0,0 @@ -/*********************************************************** -Copyright (C) 1994 Steen Lumholt. - - All Rights Reserved - -******************************************************************/ - -/* _tkinter.c -- Interface to libtk.a and libtcl.a. */ - -/* TCL/TK VERSION INFO: - - Only Tcl/Tk 8.2 and later are supported. Older versions are not - supported. (Use Python 2.2 if you cannot upgrade your Tcl/Tk - libraries.) -*/ - -/* XXX Further speed-up ideas, involving Tcl 8.0 features: - - - Register a new Tcl type, "Python callable", which can be called more - efficiently and passed to Tcl_EvalObj() directly (if this is possible). - -*/ - - -#include "Python.h" -#include - -#ifdef WITH_THREAD -#include "pythread.h" -#endif - -#ifdef MS_WINDOWS -#include -#endif - -#ifdef macintosh -#define MAC_TCL -#endif - -/* Allow using this code in Python 2.[12] */ -#ifndef PyDoc_STRVAR -#define PyDoc_STRVAR(name,str) static char name[] = str -#endif - -#ifndef PyMODINIT_FUNC -#define PyMODINIT_FUNC void -#endif - -#ifndef PyBool_Check -#define PyBool_Check(o) 0 -#define PyBool_FromLong PyInt_FromLong -#endif - -/* Starting with Tcl 8.4, many APIs offer const-correctness. Unfortunately, - making _tkinter correct for this API means to break earlier - versions. USE_COMPAT_CONST allows to make _tkinter work with both 8.4 and - earlier versions. Once Tcl releases before 8.4 don't need to be supported - anymore, this should go. */ -#define USE_COMPAT_CONST - -/* If Tcl is compiled for threads, we must also define TCL_THREAD. We define - it always; if Tcl is not threaded, the thread functions in - Tcl are empty. */ -#define TCL_THREADS - -#ifdef TK_FRAMEWORK -#include -#include -#else -#include -#include -#endif - -/* For Tcl 8.2 and 8.3, CONST* is not defined (except on Cygwin). */ -#ifndef CONST84_RETURN -#define CONST84_RETURN -#undef CONST -#define CONST -#endif - -#define TKMAJORMINOR (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION) - -#if TKMAJORMINOR < 8002 -#error "Tk older than 8.2 not supported" -#endif - -/* Unicode conversion assumes that Tcl_UniChar is two bytes. - We cannot test this directly, so we test UTF-8 size instead, - expecting that TCL_UTF_MAX is changed if Tcl ever supports - either UTF-16 or UCS-4. - Redhat 8 sets TCL_UTF_MAX to 6, and uses wchar_t for - Tcl_Unichar. This is also ok as long as Python uses UCS-4, - as well. -*/ -#if TCL_UTF_MAX != 3 && !(defined(Py_UNICODE_WIDE) && TCL_UTF_MAX==6) -#error "unsupported Tcl configuration" -#endif - -#if defined(macintosh) -/* Sigh, we have to include this to get at the tcl qd pointer */ -#include -/* And this one we need to clear the menu bar */ -#include -#endif - -#if !(defined(MS_WINDOWS) || defined(__CYGWIN__) || defined(macintosh)) -/* Mac has it, but it doesn't really work:-( */ -#define HAVE_CREATEFILEHANDLER -#endif - -#ifdef HAVE_CREATEFILEHANDLER - -/* Tcl_CreateFileHandler() changed several times; these macros deal with the - messiness. In Tcl 8.0 and later, it is not available on Windows (and on - Unix, only because Jack added it back); when available on Windows, it only - applies to sockets. */ - -#ifdef MS_WINDOWS -#define FHANDLETYPE TCL_WIN_SOCKET -#else -#define FHANDLETYPE TCL_UNIX_FD -#endif - -/* If Tcl can wait for a Unix file descriptor, define the EventHook() routine - which uses this to handle Tcl events while the user is typing commands. */ - -#if FHANDLETYPE == TCL_UNIX_FD -#define WAIT_FOR_STDIN -#endif - -#endif /* HAVE_CREATEFILEHANDLER */ - -#ifdef MS_WINDOWS -#include -#define WAIT_FOR_STDIN -#endif - -#ifdef WITH_THREAD - -/* The threading situation is complicated. Tcl is not thread-safe, except - when configured with --enable-threads. - So we need to use a lock around all uses of Tcl. Previously, the Python - interpreter lock was used for this. However, this causes problems when - other Python threads need to run while Tcl is blocked waiting for events. - - To solve this problem, a separate lock for Tcl is introduced. Holding it - is incompatible with holding Python's interpreter lock. The following four - macros manipulate both locks together. - - ENTER_TCL and LEAVE_TCL are brackets, just like Py_BEGIN_ALLOW_THREADS and - Py_END_ALLOW_THREADS. They should be used whenever a call into Tcl is made - that could call an event handler, or otherwise affect the state of a Tcl - interpreter. These assume that the surrounding code has the Python - interpreter lock; inside the brackets, the Python interpreter lock has been - released and the lock for Tcl has been acquired. - - Sometimes, it is necessary to have both the Python lock and the Tcl lock. - (For example, when transferring data from the Tcl interpreter result to a - Python string object.) This can be done by using different macros to close - the ENTER_TCL block: ENTER_OVERLAP reacquires the Python lock (and restores - the thread state) but doesn't release the Tcl lock; LEAVE_OVERLAP_TCL - releases the Tcl lock. - - By contrast, ENTER_PYTHON and LEAVE_PYTHON are used in Tcl event - handlers when the handler needs to use Python. Such event handlers are - entered while the lock for Tcl is held; the event handler presumably needs - to use Python. ENTER_PYTHON releases the lock for Tcl and acquires - the Python interpreter lock, restoring the appropriate thread state, and - LEAVE_PYTHON releases the Python interpreter lock and re-acquires the lock - for Tcl. It is okay for ENTER_TCL/LEAVE_TCL pairs to be contained inside - the code between ENTER_PYTHON and LEAVE_PYTHON. - - These locks expand to several statements and brackets; they should not be - used in branches of if statements and the like. - - If Tcl is threaded, this approach won't work anymore. The Tcl interpreter is - only valid in the thread that created it, and all Tk activity must happen in this - thread, also. That means that the mainloop must be invoked in the thread that - created the interpreter. Invoking commands from other threads is possible; - _tkinter will queue an event for the interpreter thread, which will then - execute the command and pass back the result. If the main thread is not in the - mainloop, and invoking commands causes an exception; if the main loop is running - but not processing events, the command invocation will block. - - In addition, for a threaded Tcl, a single global tcl_tstate won't be sufficient - anymore, since multiple Tcl interpreters may simultaneously dispatch in different - threads. So we use the Tcl TLS API. - -*/ - -static PyThread_type_lock tcl_lock = 0; - -#ifdef TCL_THREADS -static Tcl_ThreadDataKey state_key; -typedef PyThreadState *ThreadSpecificData; -#define tcl_tstate (*(PyThreadState**)Tcl_GetThreadData(&state_key, sizeof(PyThreadState*))) -#else -static PyThreadState *tcl_tstate = NULL; -#endif - -#define ENTER_TCL \ - { PyThreadState *tstate = PyThreadState_Get(); Py_BEGIN_ALLOW_THREADS \ - if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate; - -#define LEAVE_TCL \ - tcl_tstate = NULL; if(tcl_lock)PyThread_release_lock(tcl_lock); Py_END_ALLOW_THREADS} - -#define ENTER_OVERLAP \ - Py_END_ALLOW_THREADS - -#define LEAVE_OVERLAP_TCL \ - tcl_tstate = NULL; if(tcl_lock)PyThread_release_lock(tcl_lock); } - -#define ENTER_PYTHON \ - { PyThreadState *tstate = tcl_tstate; tcl_tstate = NULL; \ - if(tcl_lock)PyThread_release_lock(tcl_lock); PyEval_RestoreThread((tstate)); } - -#define LEAVE_PYTHON \ - { PyThreadState *tstate = PyEval_SaveThread(); \ - if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate; } - -#define CHECK_TCL_APPARTMENT \ - if (((TkappObject *)self)->threaded && \ - ((TkappObject *)self)->thread_id != Tcl_GetCurrentThread()) { \ - PyErr_SetString(PyExc_RuntimeError, "Calling Tcl from different appartment"); \ - return 0; \ - } - -#else - -#define ENTER_TCL -#define LEAVE_TCL -#define ENTER_OVERLAP -#define LEAVE_OVERLAP_TCL -#define ENTER_PYTHON -#define LEAVE_PYTHON -#define CHECK_TCL_APPARTMENT - -#endif - -#ifdef macintosh - -/* -** Additional cruft needed by Tcl/Tk on the Mac. -** This is for Tcl 7.5 and Tk 4.1 (patch release 1). -*/ - -/* ckfree() expects a char* */ -#define FREECAST (char *) - -#include /* For EventRecord */ - -typedef int (*TclMacConvertEventPtr) (EventRecord *eventPtr); -void Tcl_MacSetEventProc(TclMacConvertEventPtr procPtr); -int TkMacConvertEvent(EventRecord *eventPtr); - -static int PyMacConvertEvent(EventRecord *eventPtr); - -#include -extern int SIOUXIsAppWindow(WindowPtr); - -#endif /* macintosh */ - -#ifndef FREECAST -#define FREECAST (char *) -#endif - -/**** Tkapp Object Declaration ****/ - -static PyTypeObject Tkapp_Type; - -typedef struct { - PyObject_HEAD - Tcl_Interp *interp; - int wantobjects; - int threaded; /* True if tcl_platform[threaded] */ - Tcl_ThreadId thread_id; - int dispatching; - /* We cannot include tclInt.h, as this is internal. - So we cache interesting types here. */ - Tcl_ObjType *BooleanType; - Tcl_ObjType *ByteArrayType; - Tcl_ObjType *DoubleType; - Tcl_ObjType *IntType; - Tcl_ObjType *ListType; - Tcl_ObjType *ProcBodyType; - Tcl_ObjType *StringType; -} TkappObject; - -#define Tkapp_Check(v) ((v)->ob_type == &Tkapp_Type) -#define Tkapp_Interp(v) (((TkappObject *) (v))->interp) -#define Tkapp_Result(v) Tcl_GetStringResult(Tkapp_Interp(v)) - -#define DEBUG_REFCNT(v) (printf("DEBUG: id=%p, refcnt=%i\n", \ -(void *) v, ((PyObject *) v)->ob_refcnt)) - - - -/**** Error Handling ****/ - -static PyObject *Tkinter_TclError; -static int quitMainLoop = 0; -static int errorInCmd = 0; -static PyObject *excInCmd; -static PyObject *valInCmd; -static PyObject *trbInCmd; - - - -static PyObject * -Tkinter_Error(PyObject *v) -{ - PyErr_SetString(Tkinter_TclError, Tkapp_Result(v)); - return NULL; -} - - - -/**** Utils ****/ - -static int Tkinter_busywaitinterval = 20; - -#ifdef WITH_THREAD -#ifndef MS_WINDOWS - -/* Millisecond sleep() for Unix platforms. */ - -static void -Sleep(int milli) -{ - /* XXX Too bad if you don't have select(). */ - struct timeval t; - t.tv_sec = milli/1000; - t.tv_usec = (milli%1000) * 1000; - select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t); -} -#endif /* MS_WINDOWS */ - -/* Wait up to 1s for the mainloop to come up. */ - -static int -WaitForMainloop(TkappObject* self) -{ - int i; - for (i = 0; i < 10; i++) { - if (self->dispatching) - return 1; - Py_BEGIN_ALLOW_THREADS - Sleep(100); - Py_END_ALLOW_THREADS - } - if (self->dispatching) - return 1; - PyErr_SetString(PyExc_RuntimeError, "main thread is not in main loop"); - return 0; -} -#endif /* WITH_THREAD */ - - -static char * -AsString(PyObject *value, PyObject *tmp) -{ - if (PyString_Check(value)) - return PyString_AsString(value); -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(value)) { - PyObject *v = PyUnicode_AsUTF8String(value); - if (v == NULL) - return NULL; - if (PyList_Append(tmp, v) != 0) { - Py_DECREF(v); - return NULL; - } - Py_DECREF(v); - return PyString_AsString(v); - } -#endif - else { - PyObject *v = PyObject_Str(value); - if (v == NULL) - return NULL; - if (PyList_Append(tmp, v) != 0) { - Py_DECREF(v); - return NULL; - } - Py_DECREF(v); - return PyString_AsString(v); - } -} - - - -#define ARGSZ 64 - -static char * -Merge(PyObject *args) -{ - PyObject *tmp = NULL; - char *argvStore[ARGSZ]; - char **argv = NULL; - int fvStore[ARGSZ]; - int *fv = NULL; - int argc = 0, fvc = 0, i; - char *res = NULL; - - if (!(tmp = PyList_New(0))) - return NULL; - - argv = argvStore; - fv = fvStore; - - if (args == NULL) - argc = 0; - - else if (!PyTuple_Check(args)) { - argc = 1; - fv[0] = 0; - if (!(argv[0] = AsString(args, tmp))) - goto finally; - } - else { - argc = PyTuple_Size(args); - - if (argc > ARGSZ) { - argv = (char **)ckalloc(argc * sizeof(char *)); - fv = (int *)ckalloc(argc * sizeof(int)); - if (argv == NULL || fv == NULL) { - PyErr_NoMemory(); - goto finally; - } - } - - for (i = 0; i < argc; i++) { - PyObject *v = PyTuple_GetItem(args, i); - if (PyTuple_Check(v)) { - fv[i] = 1; - if (!(argv[i] = Merge(v))) - goto finally; - fvc++; - } - else if (v == Py_None) { - argc = i; - break; - } - else { - fv[i] = 0; - if (!(argv[i] = AsString(v, tmp))) - goto finally; - fvc++; - } - } - } - res = Tcl_Merge(argc, argv); - if (res == NULL) - PyErr_SetString(Tkinter_TclError, "merge failed"); - - finally: - for (i = 0; i < fvc; i++) - if (fv[i]) { - ckfree(argv[i]); - } - if (argv != argvStore) - ckfree(FREECAST argv); - if (fv != fvStore) - ckfree(FREECAST fv); - - Py_DECREF(tmp); - return res; -} - - - -static PyObject * -Split(char *list) -{ - int argc; - char **argv; - PyObject *v; - - if (list == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - - if (Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) { - /* Not a list. - * Could be a quoted string containing funnies, e.g. {"}. - * Return the string itself. - */ - return PyString_FromString(list); - } - - if (argc == 0) - v = PyString_FromString(""); - else if (argc == 1) - v = PyString_FromString(argv[0]); - else if ((v = PyTuple_New(argc)) != NULL) { - int i; - PyObject *w; - - for (i = 0; i < argc; i++) { - if ((w = Split(argv[i])) == NULL) { - Py_DECREF(v); - v = NULL; - break; - } - PyTuple_SetItem(v, i, w); - } - } - Tcl_Free(FREECAST argv); - return v; -} - -/* In some cases, Tcl will still return strings that are supposed to be - lists. SplitObj walks through a nested tuple, finding string objects that - need to be split. */ - -PyObject * -SplitObj(PyObject *arg) -{ - if (PyTuple_Check(arg)) { - int i, size; - PyObject *elem, *newelem, *result; - - size = PyTuple_Size(arg); - result = NULL; - /* Recursively invoke SplitObj for all tuple items. - If this does not return a new object, no action is - needed. */ - for(i = 0; i < size; i++) { - elem = PyTuple_GetItem(arg, i); - newelem = SplitObj(elem); - if (!newelem) { - Py_XDECREF(result); - return NULL; - } - if (!result) { - int k; - if (newelem == elem) { - Py_DECREF(newelem); - continue; - } - result = PyTuple_New(size); - if (!result) - return NULL; - for(k = 0; k < i; k++) { - elem = PyTuple_GetItem(arg, k); - Py_INCREF(elem); - PyTuple_SetItem(result, k, elem); - } - } - PyTuple_SetItem(result, i, newelem); - } - if (result) - return result; - /* Fall through, returning arg. */ - } - else if (PyString_Check(arg)) { - int argc; - char **argv; - char *list = PyString_AsString(arg); - - if (Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) { - Py_INCREF(arg); - return arg; - } - Tcl_Free(FREECAST argv); - if (argc > 1) - return Split(PyString_AsString(arg)); - /* Fall through, returning arg. */ - } - Py_INCREF(arg); - return arg; -} - - -/**** Tkapp Object ****/ - -#ifndef WITH_APPINIT -int -Tcl_AppInit(Tcl_Interp *interp) -{ - Tk_Window main; - - main = Tk_MainWindow(interp); - if (Tcl_Init(interp) == TCL_ERROR) { - PySys_WriteStderr("Tcl_Init error: %s\n", Tcl_GetStringResult(interp)); - return TCL_ERROR; - } - if (Tk_Init(interp) == TCL_ERROR) { - PySys_WriteStderr("Tk_Init error: %s\n", Tcl_GetStringResult(interp)); - return TCL_ERROR; - } - return TCL_OK; -} -#endif /* !WITH_APPINIT */ - - - - -/* Initialize the Tk application; see the `main' function in - * `tkMain.c'. - */ - -static void EnableEventHook(void); /* Forward */ -static void DisableEventHook(void); /* Forward */ - -static TkappObject * -Tkapp_New(char *screenName, char *baseName, char *className, - int interactive, int wantobjects) -{ - TkappObject *v; - char *argv0; - - v = PyObject_New(TkappObject, &Tkapp_Type); - if (v == NULL) - return NULL; - - v->interp = Tcl_CreateInterp(); - v->wantobjects = wantobjects; - v->threaded = Tcl_GetVar2Ex(v->interp, "tcl_platform", "threaded", - TCL_GLOBAL_ONLY) != NULL; - v->thread_id = Tcl_GetCurrentThread(); - v->dispatching = 0; - -#ifndef TCL_THREADS - if (v->threaded) { - PyErr_SetString(PyExc_RuntimeError, "Tcl is threaded but _tkinter is not"); - Py_DECREF(v); - return 0; - } -#endif -#ifdef WITH_THREAD - if (v->threaded && tcl_lock) { - /* If Tcl is threaded, we don't need the lock. */ - PyThread_free_lock(tcl_lock); - tcl_lock = NULL; - } -#endif - - v->BooleanType = Tcl_GetObjType("boolean"); - v->ByteArrayType = Tcl_GetObjType("bytearray"); - v->DoubleType = Tcl_GetObjType("double"); - v->IntType = Tcl_GetObjType("int"); - v->ListType = Tcl_GetObjType("list"); - v->ProcBodyType = Tcl_GetObjType("procbody"); - v->StringType = Tcl_GetObjType("string"); - -#if defined(macintosh) - /* This seems to be needed */ - ClearMenuBar(); - TkMacInitMenus(v->interp); -#endif - - /* Delete the 'exit' command, which can screw things up */ - Tcl_DeleteCommand(v->interp, "exit"); - - if (screenName != NULL) - Tcl_SetVar2(v->interp, "env", "DISPLAY", - screenName, TCL_GLOBAL_ONLY); - - if (interactive) - Tcl_SetVar(v->interp, "tcl_interactive", "1", TCL_GLOBAL_ONLY); - else - Tcl_SetVar(v->interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); - - /* This is used to get the application class for Tk 4.1 and up */ - argv0 = (char*)ckalloc(strlen(className) + 1); - if (!argv0) { - PyErr_NoMemory(); - Py_DECREF(v); - return NULL; - } - - strcpy(argv0, className); - if (isupper((int)(argv0[0]))) - argv0[0] = tolower(argv0[0]); - Tcl_SetVar(v->interp, "argv0", argv0, TCL_GLOBAL_ONLY); - ckfree(argv0); - - if (Tcl_AppInit(v->interp) != TCL_OK) - return (TkappObject *)Tkinter_Error((PyObject *)v); - - EnableEventHook(); - - return v; -} - - -static void -Tkapp_ThreadSend(TkappObject *self, Tcl_Event *ev, - Tcl_Condition *cond, Tcl_Mutex *mutex) -{ - Py_BEGIN_ALLOW_THREADS; - Tcl_MutexLock(mutex); - Tcl_ThreadQueueEvent(self->thread_id, ev, TCL_QUEUE_TAIL); - Tcl_ThreadAlert(self->thread_id); - Tcl_ConditionWait(cond, mutex, NULL); - Tcl_MutexUnlock(mutex); - Py_END_ALLOW_THREADS -} - - -/** Tcl Eval **/ - -typedef struct { - PyObject_HEAD - Tcl_Obj *value; - PyObject *string; /* This cannot cause cycles. */ -} PyTclObject; - -staticforward PyTypeObject PyTclObject_Type; -#define PyTclObject_Check(v) ((v)->ob_type == &PyTclObject_Type) - -static PyObject * -newPyTclObject(Tcl_Obj *arg) -{ - PyTclObject *self; - self = PyObject_New(PyTclObject, &PyTclObject_Type); - if (self == NULL) - return NULL; - Tcl_IncrRefCount(arg); - self->value = arg; - self->string = NULL; - return (PyObject*)self; -} - -static void -PyTclObject_dealloc(PyTclObject *self) -{ - Tcl_DecrRefCount(self->value); - Py_XDECREF(self->string); - PyObject_Del(self); -} - -static PyObject * -PyTclObject_str(PyTclObject *self) -{ - if (self->string && PyString_Check(self->string)) { - Py_INCREF(self->string); - return self->string; - } - /* XXX Could cache value if it is an ASCII string. */ - return PyString_FromString(Tcl_GetString(self->value)); -} - -static char* -PyTclObject_TclString(PyObject *self) -{ - return Tcl_GetString(((PyTclObject*)self)->value); -} - -/* Like _str, but create Unicode if necessary. */ -PyDoc_STRVAR(PyTclObject_string__doc__, -"the string representation of this object, either as string or Unicode"); - -static PyObject * -PyTclObject_string(PyTclObject *self, void *ignored) -{ - char *s; - int i, len; - if (!self->string) { - s = Tcl_GetStringFromObj(self->value, &len); - for (i = 0; i < len; i++) - if (s[i] & 0x80) - break; -#ifdef Py_USING_UNICODE - if (i == len) - /* It is an ASCII string. */ - self->string = PyString_FromStringAndSize(s, len); - else { - self->string = PyUnicode_DecodeUTF8(s, len, "strict"); - if (!self->string) { - PyErr_Clear(); - self->string = PyString_FromStringAndSize(s, len); - } - } -#else - self->string = PyString_FromStringAndSize(s, len); -#endif - if (!self->string) - return NULL; - } - Py_INCREF(self->string); - return self->string; -} - -#ifdef Py_USING_UNICODE -PyDoc_STRVAR(PyTclObject_unicode__doc__, "convert argument to unicode"); - -static PyObject * -PyTclObject_unicode(PyTclObject *self, void *ignored) -{ - char *s; - int len; - if (self->string && PyUnicode_Check(self->string)) { - Py_INCREF(self->string); - return self->string; - } - /* XXX Could chache result if it is non-ASCII. */ - s = Tcl_GetStringFromObj(self->value, &len); - return PyUnicode_DecodeUTF8(s, len, "strict"); -} -#endif - -static PyObject * -PyTclObject_repr(PyTclObject *self) -{ - char buf[50]; - PyOS_snprintf(buf, 50, "<%s object at 0x%.8x>", - self->value->typePtr->name, (int)self->value); - return PyString_FromString(buf); -} - -static int -PyTclObject_cmp(PyTclObject *self, PyTclObject *other) -{ - int res; - res = strcmp(Tcl_GetString(self->value), - Tcl_GetString(other->value)); - if (res < 0) return -1; - if (res > 0) return 1; - return 0; -} - -PyDoc_STRVAR(get_typename__doc__, "name of the Tcl type"); - -static PyObject* -get_typename(PyTclObject* obj, void* ignored) -{ - return PyString_FromString(obj->value->typePtr->name); -} - - -static PyGetSetDef PyTclObject_getsetlist[] = { - {"typename", (getter)get_typename, NULL, get_typename__doc__}, - {"string", (getter)PyTclObject_string, NULL, - PyTclObject_string__doc__}, - {0}, -}; - -static PyMethodDef PyTclObject_methods[] = { - {"__unicode__", (PyCFunction)PyTclObject_unicode, METH_NOARGS, - PyTclObject_unicode__doc__}, - {0} -}; - -statichere PyTypeObject PyTclObject_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "_tkinter.Tcl_Obj", /*tp_name*/ - sizeof(PyTclObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)PyTclObject_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - (cmpfunc)PyTclObject_cmp, /*tp_compare*/ - (reprfunc)PyTclObject_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - (reprfunc)PyTclObject_str, /*tp_str*/ - PyObject_GenericGetAttr,/*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - PyTclObject_methods, /*tp_methods*/ - 0, /*tp_members*/ - PyTclObject_getsetlist, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - 0, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ -}; - -static Tcl_Obj* -AsObj(PyObject *value) -{ - Tcl_Obj *result; - - if (PyString_Check(value)) - return Tcl_NewStringObj(PyString_AS_STRING(value), - PyString_GET_SIZE(value)); - else if (PyBool_Check(value)) - return Tcl_NewBooleanObj(PyObject_IsTrue(value)); - else if (PyInt_Check(value)) - return Tcl_NewLongObj(PyInt_AS_LONG(value)); - else if (PyFloat_Check(value)) - return Tcl_NewDoubleObj(PyFloat_AS_DOUBLE(value)); - else if (PyTuple_Check(value)) { - Tcl_Obj **argv = (Tcl_Obj**) - ckalloc(PyTuple_Size(value)*sizeof(Tcl_Obj*)); - int i; - if(!argv) - return 0; - for(i=0;i= 0x10000) { - /* Tcl doesn't do UTF-16, yet. */ - PyErr_SetString(PyExc_ValueError, - "unsupported character"); - ckfree(FREECAST outbuf); - return NULL; - } - outbuf[i] = inbuf[i]; - } - result = Tcl_NewUnicodeObj(outbuf, size); - ckfree(FREECAST outbuf); - return result; -#else - return Tcl_NewUnicodeObj(inbuf, size); -#endif - - } -#endif - else if(PyTclObject_Check(value)) { - Tcl_Obj *v = ((PyTclObject*)value)->value; - Tcl_IncrRefCount(v); - return v; - } - else { - PyObject *v = PyObject_Str(value); - if (!v) - return 0; - result = AsObj(v); - Py_DECREF(v); - return result; - } -} - -static PyObject* -FromObj(PyObject* tkapp, Tcl_Obj *value) -{ - PyObject *result = NULL; - TkappObject *app = (TkappObject*)tkapp; - - if (value->typePtr == NULL) { - /* If the result contains any bytes with the top bit set, - it's UTF-8 and we should decode it to Unicode */ -#ifdef Py_USING_UNICODE - int i; - char *s = value->bytes; - int len = value->length; - for (i = 0; i < len; i++) { - if (value->bytes[i] & 0x80) - break; - } - - if (i == value->length) - result = PyString_FromStringAndSize(s, len); - else { - /* Convert UTF-8 to Unicode string */ - result = PyUnicode_DecodeUTF8(s, len, "strict"); - if (result == NULL) { - PyErr_Clear(); - result = PyString_FromStringAndSize(s, len); - } - } -#else - res = PyString_FromStringAndSize(value->bytes, value->length); -#endif - return result; - } - - if (value->typePtr == app->BooleanType) { - result = value->internalRep.longValue ? Py_True : Py_False; - Py_INCREF(result); - return result; - } - - if (value->typePtr == app->ByteArrayType) { - int size; - char *data = (char*)Tcl_GetByteArrayFromObj(value, &size); - return PyString_FromStringAndSize(data, size); - } - - if (value->typePtr == app->DoubleType) { - return PyFloat_FromDouble(value->internalRep.doubleValue); - } - - if (value->typePtr == app->IntType) { - return PyInt_FromLong(value->internalRep.longValue); - } - - if (value->typePtr == app->ListType) { - int size; - int i, status; - PyObject *elem; - Tcl_Obj *tcl_elem; - - status = Tcl_ListObjLength(Tkapp_Interp(tkapp), value, &size); - if (status == TCL_ERROR) - return Tkinter_Error(tkapp); - result = PyTuple_New(size); - if (!result) - return NULL; - for (i = 0; i < size; i++) { - status = Tcl_ListObjIndex(Tkapp_Interp(tkapp), - value, i, &tcl_elem); - if (status == TCL_ERROR) { - Py_DECREF(result); - return Tkinter_Error(tkapp); - } - elem = FromObj(tkapp, tcl_elem); - if (!elem) { - Py_DECREF(result); - return NULL; - } - PyTuple_SetItem(result, i, elem); - } - return result; - } - - if (value->typePtr == app->ProcBodyType) { - /* fall through: return tcl object. */ - } - - if (value->typePtr == app->StringType) { -#ifdef Py_USING_UNICODE -#if defined(Py_UNICODE_WIDE) && TCL_UTF_MAX==3 - PyObject *result; - int size; - Tcl_UniChar *input; - Py_UNICODE *output; - - size = Tcl_GetCharLength(value); - result = PyUnicode_FromUnicode(NULL, size); - if (!result) - return NULL; - input = Tcl_GetUnicode(value); - output = PyUnicode_AS_UNICODE(result); - while (size--) - *output++ = *input++; - return result; -#else - return PyUnicode_FromUnicode(Tcl_GetUnicode(value), - Tcl_GetCharLength(value)); -#endif -#else - int size; - char *c; - c = Tcl_GetStringFromObj(value, &size); - return PyString_FromStringAndSize(c, size); -#endif - } - - return newPyTclObject(value); -} - -/* This mutex synchronizes inter-thread command calls. */ - -TCL_DECLARE_MUTEX(call_mutex) - -typedef struct Tkapp_CallEvent { - Tcl_Event ev; /* Must be first */ - TkappObject *self; - PyObject *args; - int flags; - PyObject **res; - PyObject **exc_type, **exc_value, **exc_tb; - Tcl_Condition done; -} Tkapp_CallEvent; - -void -Tkapp_CallDeallocArgs(Tcl_Obj** objv, Tcl_Obj** objStore, int objc) -{ - int i; - for (i = 0; i < objc; i++) - Tcl_DecrRefCount(objv[i]); - if (objv != objStore) - ckfree(FREECAST objv); -} - -/* Convert Python objects to Tcl objects. This must happen in the - interpreter thread, which may or may not be the calling thread. */ - -static Tcl_Obj** -Tkapp_CallArgs(PyObject *args, Tcl_Obj** objStore, int *pobjc) -{ - Tcl_Obj **objv = objStore; - int objc = 0, i; - if (args == NULL) - /* do nothing */; - - else if (!PyTuple_Check(args)) { - objv[0] = AsObj(args); - if (objv[0] == 0) - goto finally; - objc = 1; - Tcl_IncrRefCount(objv[0]); - } - else { - objc = PyTuple_Size(args); - - if (objc > ARGSZ) { - objv = (Tcl_Obj **)ckalloc(objc * sizeof(char *)); - if (objv == NULL) { - PyErr_NoMemory(); - objc = 0; - goto finally; - } - } - - for (i = 0; i < objc; i++) { - PyObject *v = PyTuple_GetItem(args, i); - if (v == Py_None) { - objc = i; - break; - } - objv[i] = AsObj(v); - if (!objv[i]) { - /* Reset objc, so it attempts to clear - objects only up to i. */ - objc = i; - goto finally; - } - Tcl_IncrRefCount(objv[i]); - } - } - *pobjc = objc; - return objv; -finally: - Tkapp_CallDeallocArgs(objv, objStore, objc); - return NULL; -} - -/* Convert the results of a command call into a Python objects. */ - -static PyObject* -Tkapp_CallResult(TkappObject *self) -{ - PyObject *res = NULL; - if(self->wantobjects) { - Tcl_Obj *value = Tcl_GetObjResult(self->interp); - /* Not sure whether the IncrRef is necessary, but something - may overwrite the interpreter result while we are - converting it. */ - Tcl_IncrRefCount(value); - res = FromObj((PyObject*)self, value); - Tcl_DecrRefCount(value); - } else { - const char *s = Tcl_GetStringResult(self->interp); - const char *p = s; - - /* If the result contains any bytes with the top bit set, - it's UTF-8 and we should decode it to Unicode */ -#ifdef Py_USING_UNICODE - while (*p != '\0') { - if (*p & 0x80) - break; - p++; - } - - if (*p == '\0') - res = PyString_FromStringAndSize(s, (int)(p-s)); - else { - /* Convert UTF-8 to Unicode string */ - p = strchr(p, '\0'); - res = PyUnicode_DecodeUTF8(s, (int)(p-s), "strict"); - if (res == NULL) { - PyErr_Clear(); - res = PyString_FromStringAndSize(s, (int)(p-s)); - } - } -#else - p = strchr(p, '\0'); - res = PyString_FromStringAndSize(s, (int)(p-s)); -#endif - } - return res; -} - -/* Tkapp_CallProc is the event procedure that is executed in the context of - the Tcl interpreter thread. Initially, it holds the Tcl lock, and doesn't - hold the Python lock. */ - -static int -Tkapp_CallProc(Tkapp_CallEvent *e, int flags) -{ - Tcl_Obj *objStore[ARGSZ]; - Tcl_Obj **objv; - int objc; - int i; - ENTER_PYTHON - objv = Tkapp_CallArgs(e->args, objStore, &objc); - if (!objv) { - PyErr_Fetch(e->exc_type, e->exc_value, e->exc_tb); - *(e->res) = NULL; - } - LEAVE_PYTHON - if (!objv) - goto done; - i = Tcl_EvalObjv(e->self->interp, objc, objv, e->flags); - ENTER_PYTHON - if (i == TCL_ERROR) { - *(e->res) = NULL; - *(e->exc_type) = NULL; - *(e->exc_tb) = NULL; - *(e->exc_value) = PyObject_CallFunction( - Tkinter_TclError, "s", - Tcl_GetStringResult(e->self->interp)); - } - else { - *(e->res) = Tkapp_CallResult(e->self); - } - LEAVE_PYTHON - done: - /* Wake up calling thread. */ - Tcl_MutexLock(&call_mutex); - Tcl_ConditionNotify(&e->done); - Tcl_MutexUnlock(&call_mutex); - return 1; -} - -/* This is the main entry point for calling a Tcl command. - It supports three cases, with regard to threading: - 1. Tcl is not threaded: Must have the Tcl lock, then can invoke command in - the context of the calling thread. - 2. Tcl is threaded, caller of the command is in the interpreter thread: - Execute the command in the calling thread. Since the Tcl lock will - not be used, we can merge that with case 1. - 3. Tcl is threaded, caller is in a different thread: Must queue an event to - the interpreter thread. Allocation of Tcl objects needs to occur in the - interpreter thread, so we ship the PyObject* args to the target thread, - and perform processing there. */ - -static PyObject * -Tkapp_Call(PyObject *_self, PyObject *args) -{ - Tcl_Obj *objStore[ARGSZ]; - Tcl_Obj **objv = NULL; - int objc, i; - PyObject *res = NULL; - TkappObject *self = (TkappObject*)_self; - /* Could add TCL_EVAL_GLOBAL if wrapped by GlobalCall... */ - int flags = TCL_EVAL_DIRECT; - -#ifdef WITH_THREAD - if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) { - /* We cannot call the command directly. Instead, we must - marshal the parameters to the interpreter thread. */ - Tkapp_CallEvent *ev; - PyObject *exc_type, *exc_value, *exc_tb; - if (!WaitForMainloop(self)) - return NULL; - ev = (Tkapp_CallEvent*)ckalloc(sizeof(Tkapp_CallEvent)); - ev->ev.proc = (Tcl_EventProc*)Tkapp_CallProc; - ev->self = self; - ev->args = args; - ev->res = &res; - ev->exc_type = &exc_type; - ev->exc_value = &exc_value; - ev->exc_tb = &exc_tb; - ev->done = (Tcl_Condition)0; - - Tkapp_ThreadSend(self, (Tcl_Event*)ev, &ev->done, &call_mutex); - - if (res == NULL) { - if (exc_type) - PyErr_Restore(exc_type, exc_value, exc_tb); - else - PyErr_SetObject(Tkinter_TclError, exc_value); - } - } - else -#endif - { - - objv = Tkapp_CallArgs(args, objStore, &objc); - if (!objv) - return NULL; - - ENTER_TCL - - i = Tcl_EvalObjv(self->interp, objc, objv, flags); - - ENTER_OVERLAP - - if (i == TCL_ERROR) - Tkinter_Error(_self); - else - res = Tkapp_CallResult(self); - - LEAVE_OVERLAP_TCL - - Tkapp_CallDeallocArgs(objv, objStore, objc); - } - return res; -} - - -static PyObject * -Tkapp_GlobalCall(PyObject *self, PyObject *args) -{ - /* Could do the same here as for Tkapp_Call(), but this is not used - much, so I can't be bothered. Unfortunately Tcl doesn't export a - way for the user to do what all its Global* variants do (save and - reset the scope pointer, call the local version, restore the saved - scope pointer). */ - - char *cmd; - PyObject *res = NULL; - - CHECK_TCL_APPARTMENT; - - cmd = Merge(args); - if (cmd) { - int err; - ENTER_TCL - err = Tcl_GlobalEval(Tkapp_Interp(self), cmd); - ENTER_OVERLAP - if (err == TCL_ERROR) - res = Tkinter_Error(self); - else - res = PyString_FromString(Tkapp_Result(self)); - LEAVE_OVERLAP_TCL - ckfree(cmd); - } - - return res; -} - -static PyObject * -Tkapp_Eval(PyObject *self, PyObject *args) -{ - char *script; - PyObject *res = NULL; - int err; - - if (!PyArg_ParseTuple(args, "s:eval", &script)) - return NULL; - - CHECK_TCL_APPARTMENT; - - ENTER_TCL - err = Tcl_Eval(Tkapp_Interp(self), script); - ENTER_OVERLAP - if (err == TCL_ERROR) - res = Tkinter_Error(self); - else - res = PyString_FromString(Tkapp_Result(self)); - LEAVE_OVERLAP_TCL - return res; -} - -static PyObject * -Tkapp_GlobalEval(PyObject *self, PyObject *args) -{ - char *script; - PyObject *res = NULL; - int err; - - if (!PyArg_ParseTuple(args, "s:globaleval", &script)) - return NULL; - - CHECK_TCL_APPARTMENT; - - ENTER_TCL - err = Tcl_GlobalEval(Tkapp_Interp(self), script); - ENTER_OVERLAP - if (err == TCL_ERROR) - res = Tkinter_Error(self); - else - res = PyString_FromString(Tkapp_Result(self)); - LEAVE_OVERLAP_TCL - return res; -} - -static PyObject * -Tkapp_EvalFile(PyObject *self, PyObject *args) -{ - char *fileName; - PyObject *res = NULL; - int err; - - if (!PyArg_ParseTuple(args, "s:evalfile", &fileName)) - return NULL; - - CHECK_TCL_APPARTMENT; - - ENTER_TCL - err = Tcl_EvalFile(Tkapp_Interp(self), fileName); - ENTER_OVERLAP - if (err == TCL_ERROR) - res = Tkinter_Error(self); - - else - res = PyString_FromString(Tkapp_Result(self)); - LEAVE_OVERLAP_TCL - return res; -} - -static PyObject * -Tkapp_Record(PyObject *self, PyObject *args) -{ - char *script; - PyObject *res = NULL; - int err; - - if (!PyArg_ParseTuple(args, "s", &script)) - return NULL; - - CHECK_TCL_APPARTMENT; - - ENTER_TCL - err = Tcl_RecordAndEval(Tkapp_Interp(self), script, TCL_NO_EVAL); - ENTER_OVERLAP - if (err == TCL_ERROR) - res = Tkinter_Error(self); - else - res = PyString_FromString(Tkapp_Result(self)); - LEAVE_OVERLAP_TCL - return res; -} - -static PyObject * -Tkapp_AddErrorInfo(PyObject *self, PyObject *args) -{ - char *msg; - - if (!PyArg_ParseTuple(args, "s:adderrorinfo", &msg)) - return NULL; - CHECK_TCL_APPARTMENT; - - ENTER_TCL - Tcl_AddErrorInfo(Tkapp_Interp(self), msg); - LEAVE_TCL - - Py_INCREF(Py_None); - return Py_None; -} - - - -/** Tcl Variable **/ - -TCL_DECLARE_MUTEX(var_mutex) - -typedef PyObject* (*EventFunc)(PyObject*, PyObject *args, int flags); -typedef struct VarEvent { - Tcl_Event ev; /* must be first */ - PyObject *self; - PyObject *args; - int flags; - EventFunc func; - PyObject **res; - PyObject **exc_type; - PyObject **exc_val; - Tcl_Condition cond; -} VarEvent; - -static int -varname_converter(PyObject *in, void *_out) -{ - char **out = (char**)_out; - if (PyString_Check(in)) { - *out = PyString_AsString(in); - return 1; - } - if (PyTclObject_Check(in)) { - *out = PyTclObject_TclString(in); - return 1; - } - /* XXX: Should give diagnostics. */ - return 0; -} - -void -var_perform(VarEvent *ev) -{ - *(ev->res) = ev->func(ev->self, ev->args, ev->flags); - if (!*(ev->res)) { - PyObject *exc, *val, *tb; - PyErr_Fetch(&exc, &val, &tb); - PyErr_NormalizeException(&exc, &val, &tb); - *(ev->exc_type) = exc; - *(ev->exc_val) = val; - Py_DECREF(tb); - } - -} - -static int -var_proc(VarEvent* ev, int flags) -{ - ENTER_PYTHON - var_perform(ev); - Tcl_MutexLock(&var_mutex); - Tcl_ConditionNotify(&ev->cond); - Tcl_MutexUnlock(&var_mutex); - LEAVE_PYTHON - return 1; -} - -static PyObject* -var_invoke(EventFunc func, PyObject *_self, PyObject *args, int flags) -{ - TkappObject *self = (TkappObject*)_self; -#ifdef WITH_THREAD - if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) { - TkappObject *self = (TkappObject*)_self; - VarEvent *ev; - PyObject *res, *exc_type, *exc_val; - - /* The current thread is not the interpreter thread. Marshal - the call to the interpreter thread, then wait for - completion. */ - if (!WaitForMainloop(self)) - return NULL; - - ev = (VarEvent*)ckalloc(sizeof(VarEvent)); - - ev->self = _self; - ev->args = args; - ev->flags = flags; - ev->func = func; - ev->res = &res; - ev->exc_type = &exc_type; - ev->exc_val = &exc_val; - ev->cond = NULL; - ev->ev.proc = (Tcl_EventProc*)var_proc; - Tkapp_ThreadSend(self, (Tcl_Event*)ev, &ev->cond, &var_mutex); - if (!res) { - PyErr_SetObject(exc_type, exc_val); - Py_DECREF(exc_type); - Py_DECREF(exc_val); - return NULL; - } - return res; - } -#endif - /* Tcl is not threaded, or this is the interpreter thread. */ - return func(_self, args, flags); -} - -static PyObject * -SetVar(PyObject *self, PyObject *args, int flags) -{ - char *name1, *name2; - PyObject *newValue; - PyObject *res = NULL; - Tcl_Obj *newval, *ok; - - if (PyArg_ParseTuple(args, "O&O:setvar", - varname_converter, &name1, &newValue)) { - /* XXX Acquire tcl lock??? */ - newval = AsObj(newValue); - if (newval == NULL) - return NULL; - ENTER_TCL - ok = Tcl_SetVar2Ex(Tkapp_Interp(self), name1, NULL, - newval, flags); - ENTER_OVERLAP - if (!ok) - Tkinter_Error(self); - else { - res = Py_None; - Py_INCREF(res); - } - LEAVE_OVERLAP_TCL - } - else { - PyErr_Clear(); - if (PyArg_ParseTuple(args, "ssO:setvar", - &name1, &name2, &newValue)) { - /* XXX must hold tcl lock already??? */ - newval = AsObj(newValue); - ENTER_TCL - ok = Tcl_SetVar2Ex(Tkapp_Interp(self), name1, name2, newval, flags); - ENTER_OVERLAP - if (!ok) - Tkinter_Error(self); - else { - res = Py_None; - Py_INCREF(res); - } - LEAVE_OVERLAP_TCL - } - else { - return NULL; - } - } - return res; -} - -static PyObject * -Tkapp_SetVar(PyObject *self, PyObject *args) -{ - return var_invoke(SetVar, self, args, TCL_LEAVE_ERR_MSG); -} - -static PyObject * -Tkapp_GlobalSetVar(PyObject *self, PyObject *args) -{ - return var_invoke(SetVar, self, args, TCL_LEAVE_ERR_MSG | TCL_GLOBAL_ONLY); -} - - - -static PyObject * -GetVar(PyObject *self, PyObject *args, int flags) -{ - char *name1, *name2=NULL; - PyObject *res = NULL; - Tcl_Obj *tres; - - if (!PyArg_ParseTuple(args, "O&|s:getvar", - varname_converter, &name1, &name2)) - return NULL; - - ENTER_TCL - tres = Tcl_GetVar2Ex(Tkapp_Interp(self), name1, name2, flags); - ENTER_OVERLAP - if (tres == NULL) { - PyErr_SetString(Tkinter_TclError, Tcl_GetStringResult(Tkapp_Interp(self))); - } else { - if (((TkappObject*)self)->wantobjects) { - res = FromObj(self, tres); - } - else { - res = PyString_FromString(Tcl_GetString(tres)); - } - } - LEAVE_OVERLAP_TCL - return res; -} - -static PyObject * -Tkapp_GetVar(PyObject *self, PyObject *args) -{ - return var_invoke(GetVar, self, args, TCL_LEAVE_ERR_MSG); -} - -static PyObject * -Tkapp_GlobalGetVar(PyObject *self, PyObject *args) -{ - return var_invoke(GetVar, self, args, TCL_LEAVE_ERR_MSG | TCL_GLOBAL_ONLY); -} - - - -static PyObject * -UnsetVar(PyObject *self, PyObject *args, int flags) -{ - char *name1, *name2=NULL; - int code; - PyObject *res = NULL; - - if (!PyArg_ParseTuple(args, "s|s:unsetvar", &name1, &name2)) - return NULL; - - ENTER_TCL - code = Tcl_UnsetVar2(Tkapp_Interp(self), name1, name2, flags); - ENTER_OVERLAP - if (code == TCL_ERROR) - res = Tkinter_Error(self); - else { - Py_INCREF(Py_None); - res = Py_None; - } - LEAVE_OVERLAP_TCL - return res; -} - -static PyObject * -Tkapp_UnsetVar(PyObject *self, PyObject *args) -{ - return var_invoke(UnsetVar, self, args, TCL_LEAVE_ERR_MSG); -} - -static PyObject * -Tkapp_GlobalUnsetVar(PyObject *self, PyObject *args) -{ - return var_invoke(UnsetVar, self, args, TCL_LEAVE_ERR_MSG | TCL_GLOBAL_ONLY); -} - - - -/** Tcl to Python **/ - -static PyObject * -Tkapp_GetInt(PyObject *self, PyObject *args) -{ - char *s; - int v; - - if (PyTuple_Size(args) == 1) { - PyObject* o = PyTuple_GetItem(args, 0); - if (PyInt_Check(o)) { - Py_INCREF(o); - return o; - } - } - if (!PyArg_ParseTuple(args, "s:getint", &s)) - return NULL; - if (Tcl_GetInt(Tkapp_Interp(self), s, &v) == TCL_ERROR) - return Tkinter_Error(self); - return Py_BuildValue("i", v); -} - -static PyObject * -Tkapp_GetDouble(PyObject *self, PyObject *args) -{ - char *s; - double v; - - if (PyTuple_Size(args) == 1) { - PyObject *o = PyTuple_GetItem(args, 0); - if (PyFloat_Check(o)) { - Py_INCREF(o); - return o; - } - } - if (!PyArg_ParseTuple(args, "s:getdouble", &s)) - return NULL; - if (Tcl_GetDouble(Tkapp_Interp(self), s, &v) == TCL_ERROR) - return Tkinter_Error(self); - return Py_BuildValue("d", v); -} - -static PyObject * -Tkapp_GetBoolean(PyObject *self, PyObject *args) -{ - char *s; - int v; - - if (PyTuple_Size(args) == 1) { - PyObject *o = PyTuple_GetItem(args, 0); - if (PyInt_Check(o)) { - Py_INCREF(o); - return o; - } - } - if (!PyArg_ParseTuple(args, "s:getboolean", &s)) - return NULL; - if (Tcl_GetBoolean(Tkapp_Interp(self), s, &v) == TCL_ERROR) - return Tkinter_Error(self); - return PyBool_FromLong(v); -} - -static PyObject * -Tkapp_ExprString(PyObject *self, PyObject *args) -{ - char *s; - PyObject *res = NULL; - int retval; - - if (!PyArg_ParseTuple(args, "s:exprstring", &s)) - return NULL; - - CHECK_TCL_APPARTMENT; - - ENTER_TCL - retval = Tcl_ExprString(Tkapp_Interp(self), s); - ENTER_OVERLAP - if (retval == TCL_ERROR) - res = Tkinter_Error(self); - else - res = Py_BuildValue("s", Tkapp_Result(self)); - LEAVE_OVERLAP_TCL - return res; -} - -static PyObject * -Tkapp_ExprLong(PyObject *self, PyObject *args) -{ - char *s; - PyObject *res = NULL; - int retval; - long v; - - if (!PyArg_ParseTuple(args, "s:exprlong", &s)) - return NULL; - - CHECK_TCL_APPARTMENT; - - ENTER_TCL - retval = Tcl_ExprLong(Tkapp_Interp(self), s, &v); - ENTER_OVERLAP - if (retval == TCL_ERROR) - res = Tkinter_Error(self); - else - res = Py_BuildValue("l", v); - LEAVE_OVERLAP_TCL - return res; -} - -static PyObject * -Tkapp_ExprDouble(PyObject *self, PyObject *args) -{ - char *s; - PyObject *res = NULL; - double v; - int retval; - - if (!PyArg_ParseTuple(args, "s:exprdouble", &s)) - return NULL; - CHECK_TCL_APPARTMENT; - PyFPE_START_PROTECT("Tkapp_ExprDouble", return 0) - ENTER_TCL - retval = Tcl_ExprDouble(Tkapp_Interp(self), s, &v); - ENTER_OVERLAP - PyFPE_END_PROTECT(retval) - if (retval == TCL_ERROR) - res = Tkinter_Error(self); - else - res = Py_BuildValue("d", v); - LEAVE_OVERLAP_TCL - return res; -} - -static PyObject * -Tkapp_ExprBoolean(PyObject *self, PyObject *args) -{ - char *s; - PyObject *res = NULL; - int retval; - int v; - - if (!PyArg_ParseTuple(args, "s:exprboolean", &s)) - return NULL; - CHECK_TCL_APPARTMENT; - ENTER_TCL - retval = Tcl_ExprBoolean(Tkapp_Interp(self), s, &v); - ENTER_OVERLAP - if (retval == TCL_ERROR) - res = Tkinter_Error(self); - else - res = Py_BuildValue("i", v); - LEAVE_OVERLAP_TCL - return res; -} - - - -static PyObject * -Tkapp_SplitList(PyObject *self, PyObject *args) -{ - char *list; - int argc; - char **argv; - PyObject *v; - int i; - - if (PyTuple_Size(args) == 1) { - v = PyTuple_GetItem(args, 0); - if (PyTuple_Check(v)) { - Py_INCREF(v); - return v; - } - } - if (!PyArg_ParseTuple(args, "et:splitlist", "utf-8", &list)) - return NULL; - - if (Tcl_SplitList(Tkapp_Interp(self), list, - &argc, &argv) == TCL_ERROR) { - PyMem_Free(list); - return Tkinter_Error(self); - } - - if (!(v = PyTuple_New(argc))) - goto finally; - - for (i = 0; i < argc; i++) { - PyObject *s = PyString_FromString(argv[i]); - if (!s || PyTuple_SetItem(v, i, s)) { - Py_DECREF(v); - v = NULL; - goto finally; - } - } - - finally: - ckfree(FREECAST argv); - PyMem_Free(list); - return v; -} - -static PyObject * -Tkapp_Split(PyObject *self, PyObject *args) -{ - PyObject *v; - char *list; - - if (PyTuple_Size(args) == 1) { - PyObject* o = PyTuple_GetItem(args, 0); - if (PyTuple_Check(o)) { - o = SplitObj(o); - return o; - } - } - if (!PyArg_ParseTuple(args, "et:split", "utf-8", &list)) - return NULL; - v = Split(list); - PyMem_Free(list); - return v; -} - -static PyObject * -Tkapp_Merge(PyObject *self, PyObject *args) -{ - char *s = Merge(args); - PyObject *res = NULL; - - if (s) { - res = PyString_FromString(s); - ckfree(s); - } - - return res; -} - - - -/** Tcl Command **/ - -/* Client data struct */ -typedef struct { - PyObject *self; - PyObject *func; -} PythonCmd_ClientData; - -static int -PythonCmd_Error(Tcl_Interp *interp) -{ - errorInCmd = 1; - PyErr_Fetch(&excInCmd, &valInCmd, &trbInCmd); - LEAVE_PYTHON - return TCL_ERROR; -} - -/* This is the Tcl command that acts as a wrapper for Python - * function or method. - */ -static int -PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) -{ - PythonCmd_ClientData *data = (PythonCmd_ClientData *)clientData; - PyObject *self, *func, *arg, *res, *tmp; - int i, rv; - char *s; - - ENTER_PYTHON - - /* TBD: no error checking here since we know, via the - * Tkapp_CreateCommand() that the client data is a two-tuple - */ - self = data->self; - func = data->func; - - /* Create argument list (argv1, ..., argvN) */ - if (!(arg = PyTuple_New(argc - 1))) - return PythonCmd_Error(interp); - - for (i = 0; i < (argc - 1); i++) { - PyObject *s = PyString_FromString(argv[i + 1]); - if (!s || PyTuple_SetItem(arg, i, s)) { - Py_DECREF(arg); - return PythonCmd_Error(interp); - } - } - res = PyEval_CallObject(func, arg); - Py_DECREF(arg); - - if (res == NULL) - return PythonCmd_Error(interp); - - if (!(tmp = PyList_New(0))) { - Py_DECREF(res); - return PythonCmd_Error(interp); - } - - s = AsString(res, tmp); - if (s == NULL) { - rv = PythonCmd_Error(interp); - } - else { - Tcl_SetResult(Tkapp_Interp(self), s, TCL_VOLATILE); - rv = TCL_OK; - } - - Py_DECREF(res); - Py_DECREF(tmp); - - LEAVE_PYTHON - - return rv; -} - -static void -PythonCmdDelete(ClientData clientData) -{ - PythonCmd_ClientData *data = (PythonCmd_ClientData *)clientData; - - ENTER_PYTHON - Py_XDECREF(data->self); - Py_XDECREF(data->func); - PyMem_DEL(data); - LEAVE_PYTHON -} - - - - -TCL_DECLARE_MUTEX(command_mutex) - -typedef struct CommandEvent{ - Tcl_Event ev; - Tcl_Interp* interp; - char *name; - int create; - int *status; - ClientData *data; - Tcl_Condition done; -} CommandEvent; - -static int -Tkapp_CommandProc(CommandEvent *ev, int flags) -{ - if (ev->create) - *ev->status = Tcl_CreateCommand( - ev->interp, ev->name, PythonCmd, - ev->data, PythonCmdDelete) == NULL; - else - *ev->status = Tcl_DeleteCommand(ev->interp, ev->name); - Tcl_MutexLock(&command_mutex); - Tcl_ConditionNotify(&ev->done); - Tcl_MutexUnlock(&command_mutex); - return 1; -} - -static PyObject * -Tkapp_CreateCommand(PyObject *_self, PyObject *args) -{ - TkappObject *self = (TkappObject*)_self; - PythonCmd_ClientData *data; - char *cmdName; - PyObject *func; - int err; - - if (!PyArg_ParseTuple(args, "sO:createcommand", &cmdName, &func)) - return NULL; - if (!PyCallable_Check(func)) { - PyErr_SetString(PyExc_TypeError, "command not callable"); - return NULL; - } - -#ifdef WITH_THREAD - if (self->threaded && self->thread_id != Tcl_GetCurrentThread() && - !WaitForMainloop(self)) - return NULL; -#endif - - data = PyMem_NEW(PythonCmd_ClientData, 1); - if (!data) - return PyErr_NoMemory(); - Py_XINCREF(self); - Py_XINCREF(func); - data->self = _self; - data->func = func; - - if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) { - CommandEvent *ev = (CommandEvent*)ckalloc(sizeof(CommandEvent)); - ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc; - ev->interp = self->interp; - ev->create = 1; - ev->name = cmdName; - ev->data = (ClientData)data; - ev->status = &err; - ev->done = NULL; - Tkapp_ThreadSend(self, (Tcl_Event*)ev, &ev->done, &command_mutex); - } - else { - ENTER_TCL - err = Tcl_CreateCommand( - Tkapp_Interp(self), cmdName, PythonCmd, - (ClientData)data, PythonCmdDelete) == NULL; - LEAVE_TCL - } - if (err) { - PyErr_SetString(Tkinter_TclError, "can't create Tcl command"); - PyMem_DEL(data); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - - - -static PyObject * -Tkapp_DeleteCommand(PyObject *_self, PyObject *args) -{ - TkappObject *self = (TkappObject*)_self; - char *cmdName; - int err; - - if (!PyArg_ParseTuple(args, "s:deletecommand", &cmdName)) - return NULL; - if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) { - CommandEvent *ev; - ev = (CommandEvent*)ckalloc(sizeof(CommandEvent)); - ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc; - ev->interp = self->interp; - ev->create = 0; - ev->name = cmdName; - ev->status = &err; - ev->done = NULL; - Tkapp_ThreadSend(self, (Tcl_Event*)ev, &ev->done, - &command_mutex); - } - else { - ENTER_TCL - err = Tcl_DeleteCommand(self->interp, cmdName); - LEAVE_TCL - } - if (err == -1) { - PyErr_SetString(Tkinter_TclError, "can't delete Tcl command"); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - - - -#ifdef HAVE_CREATEFILEHANDLER -/** File Handler **/ - -typedef struct _fhcdata { - PyObject *func; - PyObject *file; - int id; - struct _fhcdata *next; -} FileHandler_ClientData; - -static FileHandler_ClientData *HeadFHCD; - -static FileHandler_ClientData * -NewFHCD(PyObject *func, PyObject *file, int id) -{ - FileHandler_ClientData *p; - p = PyMem_NEW(FileHandler_ClientData, 1); - if (p != NULL) { - Py_XINCREF(func); - Py_XINCREF(file); - p->func = func; - p->file = file; - p->id = id; - p->next = HeadFHCD; - HeadFHCD = p; - } - return p; -} - -static void -DeleteFHCD(int id) -{ - FileHandler_ClientData *p, **pp; - - pp = &HeadFHCD; - while ((p = *pp) != NULL) { - if (p->id == id) { - *pp = p->next; - Py_XDECREF(p->func); - Py_XDECREF(p->file); - PyMem_DEL(p); - } - else - pp = &p->next; - } -} - -static void -FileHandler(ClientData clientData, int mask) -{ - FileHandler_ClientData *data = (FileHandler_ClientData *)clientData; - PyObject *func, *file, *arg, *res; - - ENTER_PYTHON - func = data->func; - file = data->file; - - arg = Py_BuildValue("(Oi)", file, (long) mask); - res = PyEval_CallObject(func, arg); - Py_DECREF(arg); - - if (res == NULL) { - errorInCmd = 1; - PyErr_Fetch(&excInCmd, &valInCmd, &trbInCmd); - } - Py_XDECREF(res); - LEAVE_PYTHON -} - -static PyObject * -Tkapp_CreateFileHandler(PyObject *self, PyObject *args) - /* args is (file, mask, func) */ -{ - FileHandler_ClientData *data; - PyObject *file, *func; - int mask, tfile; - - if (!PyArg_ParseTuple(args, "OiO:createfilehandler", - &file, &mask, &func)) - return NULL; - -#ifdef WITH_THREAD - if (!self && !tcl_lock) { - /* We don't have the Tcl lock since Tcl is threaded. */ - PyErr_SetString(PyExc_RuntimeError, - "_tkinter.createfilehandler not supported " - "for threaded Tcl"); - return NULL; - } -#endif - - if (self) { - CHECK_TCL_APPARTMENT; - } - - tfile = PyObject_AsFileDescriptor(file); - if (tfile < 0) - return NULL; - if (!PyCallable_Check(func)) { - PyErr_SetString(PyExc_TypeError, "bad argument list"); - return NULL; - } - - data = NewFHCD(func, file, tfile); - if (data == NULL) - return NULL; - - /* Ought to check for null Tcl_File object... */ - ENTER_TCL - Tcl_CreateFileHandler(tfile, mask, FileHandler, (ClientData) data); - LEAVE_TCL - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -Tkapp_DeleteFileHandler(PyObject *self, PyObject *args) -{ - PyObject *file; - int tfile; - - if (!PyArg_ParseTuple(args, "O:deletefilehandler", &file)) - return NULL; - -#ifdef WITH_THREAD - if (!self && !tcl_lock) { - /* We don't have the Tcl lock since Tcl is threaded. */ - PyErr_SetString(PyExc_RuntimeError, - "_tkinter.deletefilehandler not supported " - "for threaded Tcl"); - return NULL; - } -#endif - - if (self) { - CHECK_TCL_APPARTMENT; - } - - tfile = PyObject_AsFileDescriptor(file); - if (tfile < 0) - return NULL; - - DeleteFHCD(tfile); - - /* Ought to check for null Tcl_File object... */ - ENTER_TCL - Tcl_DeleteFileHandler(tfile); - LEAVE_TCL - Py_INCREF(Py_None); - return Py_None; -} -#endif /* HAVE_CREATEFILEHANDLER */ - - -/**** Tktt Object (timer token) ****/ - -static PyTypeObject Tktt_Type; - -typedef struct { - PyObject_HEAD - Tcl_TimerToken token; - PyObject *func; -} TkttObject; - -static PyObject * -Tktt_DeleteTimerHandler(PyObject *self, PyObject *args) -{ - TkttObject *v = (TkttObject *)self; - PyObject *func = v->func; - - if (!PyArg_ParseTuple(args, ":deletetimerhandler")) - return NULL; - if (v->token != NULL) { - Tcl_DeleteTimerHandler(v->token); - v->token = NULL; - } - if (func != NULL) { - v->func = NULL; - Py_DECREF(func); - Py_DECREF(v); /* See Tktt_New() */ - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyMethodDef Tktt_methods[] = -{ - {"deletetimerhandler", Tktt_DeleteTimerHandler, METH_VARARGS}, - {NULL, NULL} -}; - -static TkttObject * -Tktt_New(PyObject *func) -{ - TkttObject *v; - - v = PyObject_New(TkttObject, &Tktt_Type); - if (v == NULL) - return NULL; - - Py_INCREF(func); - v->token = NULL; - v->func = func; - - /* Extra reference, deleted when called or when handler is deleted */ - Py_INCREF(v); - return v; -} - -static void -Tktt_Dealloc(PyObject *self) -{ - TkttObject *v = (TkttObject *)self; - PyObject *func = v->func; - - Py_XDECREF(func); - - PyObject_Del(self); -} - -static PyObject * -Tktt_Repr(PyObject *self) -{ - TkttObject *v = (TkttObject *)self; - char buf[100]; - - PyOS_snprintf(buf, sizeof(buf), "", v, - v->func == NULL ? ", handler deleted" : ""); - return PyString_FromString(buf); -} - -static PyObject * -Tktt_GetAttr(PyObject *self, char *name) -{ - return Py_FindMethod(Tktt_methods, self, name); -} - -static PyTypeObject Tktt_Type = -{ - PyObject_HEAD_INIT(NULL) - 0, /*ob_size */ - "tktimertoken", /*tp_name */ - sizeof(TkttObject), /*tp_basicsize */ - 0, /*tp_itemsize */ - Tktt_Dealloc, /*tp_dealloc */ - 0, /*tp_print */ - Tktt_GetAttr, /*tp_getattr */ - 0, /*tp_setattr */ - 0, /*tp_compare */ - Tktt_Repr, /*tp_repr */ - 0, /*tp_as_number */ - 0, /*tp_as_sequence */ - 0, /*tp_as_mapping */ - 0, /*tp_hash */ -}; - - - -/** Timer Handler **/ - -static void -TimerHandler(ClientData clientData) -{ - TkttObject *v = (TkttObject *)clientData; - PyObject *func = v->func; - PyObject *res; - - if (func == NULL) - return; - - v->func = NULL; - - ENTER_PYTHON - - res = PyEval_CallObject(func, NULL); - Py_DECREF(func); - Py_DECREF(v); /* See Tktt_New() */ - - if (res == NULL) { - errorInCmd = 1; - PyErr_Fetch(&excInCmd, &valInCmd, &trbInCmd); - } - else - Py_DECREF(res); - - LEAVE_PYTHON -} - -static PyObject * -Tkapp_CreateTimerHandler(PyObject *self, PyObject *args) -{ - int milliseconds; - PyObject *func; - TkttObject *v; - - if (!PyArg_ParseTuple(args, "iO:createtimerhandler", - &milliseconds, &func)) - return NULL; - if (!PyCallable_Check(func)) { - PyErr_SetString(PyExc_TypeError, "bad argument list"); - return NULL; - } - -#ifdef WITH_THREAD - if (!self && !tcl_lock) { - /* We don't have the Tcl lock since Tcl is threaded. */ - PyErr_SetString(PyExc_RuntimeError, - "_tkinter.createtimerhandler not supported " - "for threaded Tcl"); - return NULL; - } -#endif - - if (self) { - CHECK_TCL_APPARTMENT; - } - - v = Tktt_New(func); - v->token = Tcl_CreateTimerHandler(milliseconds, TimerHandler, - (ClientData)v); - - return (PyObject *) v; -} - - -/** Event Loop **/ - -static PyObject * -Tkapp_MainLoop(PyObject *_self, PyObject *args) -{ - int threshold = 0; - TkappObject *self = (TkappObject*)_self; -#ifdef WITH_THREAD - PyThreadState *tstate = PyThreadState_Get(); -#endif - - if (!PyArg_ParseTuple(args, "|i:mainloop", &threshold)) - return NULL; - -#ifdef WITH_THREAD - if (!self && !tcl_lock) { - /* We don't have the Tcl lock since Tcl is threaded. */ - PyErr_SetString(PyExc_RuntimeError, - "_tkinter.mainloop not supported " - "for threaded Tcl"); - return NULL; - } -#endif - - if (self) { - CHECK_TCL_APPARTMENT; - self->dispatching = 1; - } - - quitMainLoop = 0; - while (Tk_GetNumMainWindows() > threshold && - !quitMainLoop && - !errorInCmd) - { - int result; - -#ifdef WITH_THREAD - if (self && self->threaded) { - /* Allow other Python threads to run. */ - ENTER_TCL - result = Tcl_DoOneEvent(0); - LEAVE_TCL - } - else { - Py_BEGIN_ALLOW_THREADS - if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); - tcl_tstate = tstate; - result = Tcl_DoOneEvent(TCL_DONT_WAIT); - tcl_tstate = NULL; - if(tcl_lock)PyThread_release_lock(tcl_lock); - if (result == 0) - Sleep(Tkinter_busywaitinterval); - Py_END_ALLOW_THREADS - } -#else - result = Tcl_DoOneEvent(0); -#endif - - if (PyErr_CheckSignals() != 0) { - if (self) - self->dispatching = 0; - return NULL; - } - if (result < 0) - break; - } - if (self) - self->dispatching = 0; - quitMainLoop = 0; - - if (errorInCmd) { - errorInCmd = 0; - PyErr_Restore(excInCmd, valInCmd, trbInCmd); - excInCmd = valInCmd = trbInCmd = NULL; - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -Tkapp_DoOneEvent(PyObject *self, PyObject *args) -{ - int flags = 0; - int rv; - - if (!PyArg_ParseTuple(args, "|i:dooneevent", &flags)) - return NULL; - - ENTER_TCL - rv = Tcl_DoOneEvent(flags); - LEAVE_TCL - return Py_BuildValue("i", rv); -} - -static PyObject * -Tkapp_Quit(PyObject *self, PyObject *args) -{ - - if (!PyArg_ParseTuple(args, ":quit")) - return NULL; - - quitMainLoop = 1; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -Tkapp_InterpAddr(PyObject *self, PyObject *args) -{ - - if (!PyArg_ParseTuple(args, ":interpaddr")) - return NULL; - - return PyInt_FromLong((long)Tkapp_Interp(self)); -} - - -static PyObject * -Tkapp_WantObjects(PyObject *self, PyObject *args) -{ - - int wantobjects = -1; - if (!PyArg_ParseTuple(args, "|i:wantobjects", &wantobjects)) - return NULL; - if (wantobjects == -1) - return PyBool_FromLong(((TkappObject*)self)->wantobjects); - ((TkappObject*)self)->wantobjects = wantobjects; - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -Tkapp_WillDispatch(PyObject *self, PyObject *args) -{ - - ((TkappObject*)self)->dispatching = 1; - - Py_INCREF(Py_None); - return Py_None; -} - - -/**** Tkapp Method List ****/ - -static PyMethodDef Tkapp_methods[] = -{ - {"willdispatch", Tkapp_WillDispatch, METH_NOARGS}, - {"wantobjects", Tkapp_WantObjects, METH_VARARGS}, - {"call", Tkapp_Call, METH_OLDARGS}, - {"globalcall", Tkapp_GlobalCall, METH_OLDARGS}, - {"eval", Tkapp_Eval, METH_VARARGS}, - {"globaleval", Tkapp_GlobalEval, METH_VARARGS}, - {"evalfile", Tkapp_EvalFile, METH_VARARGS}, - {"record", Tkapp_Record, METH_VARARGS}, - {"adderrorinfo", Tkapp_AddErrorInfo, METH_VARARGS}, - {"setvar", Tkapp_SetVar, METH_VARARGS}, - {"globalsetvar", Tkapp_GlobalSetVar, METH_VARARGS}, - {"getvar", Tkapp_GetVar, METH_VARARGS}, - {"globalgetvar", Tkapp_GlobalGetVar, METH_VARARGS}, - {"unsetvar", Tkapp_UnsetVar, METH_VARARGS}, - {"globalunsetvar", Tkapp_GlobalUnsetVar, METH_VARARGS}, - {"getint", Tkapp_GetInt, METH_VARARGS}, - {"getdouble", Tkapp_GetDouble, METH_VARARGS}, - {"getboolean", Tkapp_GetBoolean, METH_VARARGS}, - {"exprstring", Tkapp_ExprString, METH_VARARGS}, - {"exprlong", Tkapp_ExprLong, METH_VARARGS}, - {"exprdouble", Tkapp_ExprDouble, METH_VARARGS}, - {"exprboolean", Tkapp_ExprBoolean, METH_VARARGS}, - {"splitlist", Tkapp_SplitList, METH_VARARGS}, - {"split", Tkapp_Split, METH_VARARGS}, - {"merge", Tkapp_Merge, METH_OLDARGS}, - {"createcommand", Tkapp_CreateCommand, METH_VARARGS}, - {"deletecommand", Tkapp_DeleteCommand, METH_VARARGS}, -#ifdef HAVE_CREATEFILEHANDLER - {"createfilehandler", Tkapp_CreateFileHandler, METH_VARARGS}, - {"deletefilehandler", Tkapp_DeleteFileHandler, METH_VARARGS}, -#endif - {"createtimerhandler", Tkapp_CreateTimerHandler, METH_VARARGS}, - {"mainloop", Tkapp_MainLoop, METH_VARARGS}, - {"dooneevent", Tkapp_DoOneEvent, METH_VARARGS}, - {"quit", Tkapp_Quit, METH_VARARGS}, - {"interpaddr", Tkapp_InterpAddr, METH_VARARGS}, - {NULL, NULL} -}; - - - -/**** Tkapp Type Methods ****/ - -static void -Tkapp_Dealloc(PyObject *self) -{ - /*CHECK_TCL_APPARTMENT;*/ - ENTER_TCL - Tcl_DeleteInterp(Tkapp_Interp(self)); - LEAVE_TCL - PyObject_Del(self); - DisableEventHook(); -} - -static PyObject * -Tkapp_GetAttr(PyObject *self, char *name) -{ - return Py_FindMethod(Tkapp_methods, self, name); -} - -static PyTypeObject Tkapp_Type = -{ - PyObject_HEAD_INIT(NULL) - 0, /*ob_size */ - "tkapp", /*tp_name */ - sizeof(TkappObject), /*tp_basicsize */ - 0, /*tp_itemsize */ - Tkapp_Dealloc, /*tp_dealloc */ - 0, /*tp_print */ - Tkapp_GetAttr, /*tp_getattr */ - 0, /*tp_setattr */ - 0, /*tp_compare */ - 0, /*tp_repr */ - 0, /*tp_as_number */ - 0, /*tp_as_sequence */ - 0, /*tp_as_mapping */ - 0, /*tp_hash */ -}; - - - -/**** Tkinter Module ****/ - -typedef struct { - PyObject* tuple; - int size; /* current size */ - int maxsize; /* allocated size */ -} FlattenContext; - -static int -_bump(FlattenContext* context, int size) -{ - /* expand tuple to hold (at least) size new items. - return true if successful, false if an exception was raised */ - - int maxsize = context->maxsize * 2; - - if (maxsize < context->size + size) - maxsize = context->size + size; - - context->maxsize = maxsize; - - return _PyTuple_Resize(&context->tuple, maxsize) >= 0; -} - -static int -_flatten1(FlattenContext* context, PyObject* item, int depth) -{ - /* add tuple or list to argument tuple (recursively) */ - - int i, size; - - if (depth > 1000) { - PyErr_SetString(PyExc_ValueError, - "nesting too deep in _flatten"); - return 0; - } else if (PyList_Check(item)) { - size = PyList_GET_SIZE(item); - /* preallocate (assume no nesting) */ - if (context->size + size > context->maxsize && - !_bump(context, size)) - return 0; - /* copy items to output tuple */ - for (i = 0; i < size; i++) { - PyObject *o = PyList_GET_ITEM(item, i); - if (PyList_Check(o) || PyTuple_Check(o)) { - if (!_flatten1(context, o, depth + 1)) - return 0; - } else if (o != Py_None) { - if (context->size + 1 > context->maxsize && - !_bump(context, 1)) - return 0; - Py_INCREF(o); - PyTuple_SET_ITEM(context->tuple, - context->size++, o); - } - } - } else if (PyTuple_Check(item)) { - /* same, for tuples */ - size = PyTuple_GET_SIZE(item); - if (context->size + size > context->maxsize && - !_bump(context, size)) - return 0; - for (i = 0; i < size; i++) { - PyObject *o = PyTuple_GET_ITEM(item, i); - if (PyList_Check(o) || PyTuple_Check(o)) { - if (!_flatten1(context, o, depth + 1)) - return 0; - } else if (o != Py_None) { - if (context->size + 1 > context->maxsize && - !_bump(context, 1)) - return 0; - Py_INCREF(o); - PyTuple_SET_ITEM(context->tuple, - context->size++, o); - } - } - } else { - PyErr_SetString(PyExc_TypeError, "argument must be sequence"); - return 0; - } - return 1; -} - -static PyObject * -Tkinter_Flatten(PyObject* self, PyObject* args) -{ - FlattenContext context; - PyObject* item; - - if (!PyArg_ParseTuple(args, "O:_flatten", &item)) - return NULL; - - context.maxsize = PySequence_Size(item); - if (context.maxsize <= 0) - return PyTuple_New(0); - - context.tuple = PyTuple_New(context.maxsize); - if (!context.tuple) - return NULL; - - context.size = 0; - - if (!_flatten1(&context, item,0)) - return NULL; - - if (_PyTuple_Resize(&context.tuple, context.size)) - return NULL; - - return context.tuple; -} - -static PyObject * -Tkinter_Create(PyObject *self, PyObject *args) -{ - char *screenName = NULL; - char *baseName = NULL; - char *className = NULL; - int interactive = 0; - int wantobjects = 0; - - baseName = strrchr(Py_GetProgramName(), '/'); - if (baseName != NULL) - baseName++; - else - baseName = Py_GetProgramName(); - className = "Tk"; - - if (!PyArg_ParseTuple(args, "|zssii:create", - &screenName, &baseName, &className, - &interactive, &wantobjects)) - return NULL; - - return (PyObject *) Tkapp_New(screenName, baseName, className, - interactive, wantobjects); -} - -static PyObject * -Tkinter_setbusywaitinterval(PyObject *self, PyObject *args) -{ - int new_val; - if (!PyArg_ParseTuple(args, "i:setbusywaitinterval", &new_val)) - return NULL; - if (new_val < 0) { - PyErr_SetString(PyExc_ValueError, - "busywaitinterval must be >= 0"); - return NULL; - } - Tkinter_busywaitinterval = new_val; - Py_INCREF(Py_None); - return Py_None; -} - -static char setbusywaitinterval_doc[] = -"setbusywaitinterval(n) -> None\n\ -\n\ -Set the busy-wait interval in milliseconds between successive\n\ -calls to Tcl_DoOneEvent in a threaded Python interpreter.\n\ -It should be set to a divisor of the maximum time between\n\ -frames in an animation."; - -static PyObject * -Tkinter_getbusywaitinterval(PyObject *self, PyObject *args) -{ - return PyInt_FromLong(Tkinter_busywaitinterval); -} - -static char getbusywaitinterval_doc[] = -"getbusywaitinterval() -> int\n\ -\n\ -Return the current busy-wait interval between successive\n\ -calls to Tcl_DoOneEvent in a threaded Python interpreter."; - -static PyMethodDef moduleMethods[] = -{ - {"_flatten", Tkinter_Flatten, METH_VARARGS}, - {"create", Tkinter_Create, METH_VARARGS}, -#ifdef HAVE_CREATEFILEHANDLER - {"createfilehandler", Tkapp_CreateFileHandler, METH_VARARGS}, - {"deletefilehandler", Tkapp_DeleteFileHandler, METH_VARARGS}, -#endif - {"createtimerhandler", Tkapp_CreateTimerHandler, METH_VARARGS}, - {"mainloop", Tkapp_MainLoop, METH_VARARGS}, - {"dooneevent", Tkapp_DoOneEvent, METH_VARARGS}, - {"quit", Tkapp_Quit, METH_VARARGS}, - {"setbusywaitinterval",Tkinter_setbusywaitinterval, METH_VARARGS, - setbusywaitinterval_doc}, - {"getbusywaitinterval",(PyCFunction)Tkinter_getbusywaitinterval, - METH_NOARGS, getbusywaitinterval_doc}, - {NULL, NULL} -}; - -#ifdef WAIT_FOR_STDIN - -static int stdin_ready = 0; - -#ifndef MS_WINDOWS -static void -MyFileProc(void *clientData, int mask) -{ - stdin_ready = 1; -} -#endif - -#ifdef WITH_THREAD -static PyThreadState *event_tstate = NULL; -#endif - -static int -EventHook(void) -{ -#ifndef MS_WINDOWS - int tfile; -#endif -#ifdef WITH_THREAD - PyEval_RestoreThread(event_tstate); -#endif - stdin_ready = 0; - errorInCmd = 0; -#ifndef MS_WINDOWS - tfile = fileno(stdin); - Tcl_CreateFileHandler(tfile, TCL_READABLE, MyFileProc, NULL); -#endif - while (!errorInCmd && !stdin_ready) { - int result; -#ifdef MS_WINDOWS - if (_kbhit()) { - stdin_ready = 1; - break; - } -#endif -#if defined(WITH_THREAD) || defined(MS_WINDOWS) - Py_BEGIN_ALLOW_THREADS - if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); - tcl_tstate = event_tstate; - - result = Tcl_DoOneEvent(TCL_DONT_WAIT); - - tcl_tstate = NULL; - if(tcl_lock)PyThread_release_lock(tcl_lock); - if (result == 0) - Sleep(Tkinter_busywaitinterval); - Py_END_ALLOW_THREADS -#else - result = Tcl_DoOneEvent(0); -#endif - - if (result < 0) - break; - } -#ifndef MS_WINDOWS - Tcl_DeleteFileHandler(tfile); -#endif - if (errorInCmd) { - errorInCmd = 0; - PyErr_Restore(excInCmd, valInCmd, trbInCmd); - excInCmd = valInCmd = trbInCmd = NULL; - PyErr_Print(); - } -#ifdef WITH_THREAD - PyEval_SaveThread(); -#endif - return 0; -} - -#endif - -static void -EnableEventHook(void) -{ -#ifdef WAIT_FOR_STDIN - if (PyOS_InputHook == NULL) { -#ifdef WITH_THREAD - event_tstate = PyThreadState_Get(); -#endif - PyOS_InputHook = EventHook; - } -#endif -} - -static void -DisableEventHook(void) -{ -#ifdef WAIT_FOR_STDIN - if (Tk_GetNumMainWindows() == 0 && PyOS_InputHook == EventHook) { - PyOS_InputHook = NULL; - } -#endif -} - - -/* all errors will be checked in one fell swoop in init_tkinter() */ -static void -ins_long(PyObject *d, char *name, long val) -{ - PyObject *v = PyInt_FromLong(val); - if (v) { - PyDict_SetItemString(d, name, v); - Py_DECREF(v); - } -} -static void -ins_string(PyObject *d, char *name, char *val) -{ - PyObject *v = PyString_FromString(val); - if (v) { - PyDict_SetItemString(d, name, v); - Py_DECREF(v); - } -} - - -PyMODINIT_FUNC -init_tkinter(void) -{ - PyObject *m, *d; - - Tkapp_Type.ob_type = &PyType_Type; - -#ifdef WITH_THREAD - tcl_lock = PyThread_allocate_lock(); -#endif - - m = Py_InitModule("_tkinter", moduleMethods); - - d = PyModule_GetDict(m); - Tkinter_TclError = PyErr_NewException("_tkinter.TclError", NULL, NULL); - PyDict_SetItemString(d, "TclError", Tkinter_TclError); - - ins_long(d, "READABLE", TCL_READABLE); - ins_long(d, "WRITABLE", TCL_WRITABLE); - ins_long(d, "EXCEPTION", TCL_EXCEPTION); - ins_long(d, "WINDOW_EVENTS", TCL_WINDOW_EVENTS); - ins_long(d, "FILE_EVENTS", TCL_FILE_EVENTS); - ins_long(d, "TIMER_EVENTS", TCL_TIMER_EVENTS); - ins_long(d, "IDLE_EVENTS", TCL_IDLE_EVENTS); - ins_long(d, "ALL_EVENTS", TCL_ALL_EVENTS); - ins_long(d, "DONT_WAIT", TCL_DONT_WAIT); - ins_string(d, "TK_VERSION", TK_VERSION); - ins_string(d, "TCL_VERSION", TCL_VERSION); - - PyDict_SetItemString(d, "TkappType", (PyObject *)&Tkapp_Type); - - Tktt_Type.ob_type = &PyType_Type; - PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type); - - PyTclObject_Type.ob_type = &PyType_Type; - PyDict_SetItemString(d, "Tcl_Obj", (PyObject *)&PyTclObject_Type); - -#ifdef TK_AQUA - /* Tk_MacOSXSetupTkNotifier must be called before Tcl's subsystems - * start waking up. Note that Tcl_FindExecutable will do this, this - * code must be above it! The original warning from - * tkMacOSXAppInit.c is copied below. - * - * NB - You have to swap in the Tk Notifier BEFORE you start up the - * Tcl interpreter for now. It probably should work to do this - * in the other order, but for now it doesn't seem to. - * - */ - Tk_MacOSXSetupTkNotifier(); -#endif - - - /* This helps the dynamic loader; in Unicode aware Tcl versions - it also helps Tcl find its encodings. */ - Tcl_FindExecutable(Py_GetProgramName()); - - if (PyErr_Occurred()) - return; - -#if 0 - /* This was not a good idea; through bindings, - Tcl_Finalize() may invoke Python code but at that point the - interpreter and thread state have already been destroyed! */ - Py_AtExit(Tcl_Finalize); -#endif - -#ifdef macintosh - /* - ** Part of this code is stolen from MacintoshInit in tkMacAppInit. - ** Most of the initializations in that routine (toolbox init calls and - ** such) have already been done for us, so we only need these. - */ - tcl_macQdPtr = &qd; - - Tcl_MacSetEventProc(PyMacConvertEvent); -#if GENERATINGCFM - mac_addlibresources(); -#endif /* GENERATINGCFM */ -#endif /* macintosh */ -} - - - -#ifdef macintosh - -/* -** Anyone who embeds Tcl/Tk on the Mac must define panic(). -*/ - -void -panic(char * format, ...) -{ - va_list varg; - - va_start(varg, format); - - vfprintf(stderr, format, varg); - (void) fflush(stderr); - - va_end(varg); - - Py_FatalError("Tcl/Tk panic"); -} - -/* -** Pass events to SIOUX before passing them to Tk. -*/ - -static int -PyMacConvertEvent(EventRecord *eventPtr) -{ - WindowPtr frontwin; - /* - ** Sioux eats too many events, so we don't pass it everything. We - ** always pass update events to Sioux, and we only pass other events if - ** the Sioux window is frontmost. This means that Tk menus don't work - ** in that case, but at least we can scroll the sioux window. - ** Note that the SIOUXIsAppWindow() routine we use here is not really - ** part of the external interface of Sioux... - */ - frontwin = FrontWindow(); - if ( eventPtr->what == updateEvt || SIOUXIsAppWindow(frontwin) ) { - if (SIOUXHandleOneEvent(eventPtr)) - return 0; /* Nothing happened to the Tcl event queue */ - } - return TkMacConvertEvent(eventPtr); -} - -#if GENERATINGCFM - -/* -** Additional Mac specific code for dealing with shared libraries. -*/ - -#include -#include - -static int loaded_from_shlib = 0; -static FSSpec library_fss; - -/* -** If this module is dynamically loaded the following routine should -** be the init routine. It takes care of adding the shared library to -** the resource-file chain, so that the tk routines can find their -** resources. -*/ -OSErr pascal -init_tkinter_shlib(CFragInitBlockPtr data) -{ - __initialize(); - if ( data == nil ) return noErr; - if ( data->fragLocator.where == kDataForkCFragLocator ) { - library_fss = *data->fragLocator.u.onDisk.fileSpec; - loaded_from_shlib = 1; - } else if ( data->fragLocator.where == kResourceCFragLocator ) { - library_fss = *data->fragLocator.u.inSegs.fileSpec; - loaded_from_shlib = 1; - } - return noErr; -} - -/* -** Insert the library resources into the search path. Put them after -** the resources from the application. Again, we ignore errors. -*/ -static -mac_addlibresources(void) -{ - if ( !loaded_from_shlib ) - return; - (void)FSpOpenResFile(&library_fss, fsRdPerm); -} - -#endif /* GENERATINGCFM */ -#endif /* macintosh */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/_weakref.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/_weakref.c deleted file mode 100644 index 40d716e5..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/_weakref.c +++ /dev/null @@ -1,131 +0,0 @@ -#include "Python.h" - - -#define GET_WEAKREFS_LISTPTR(o) \ - ((PyWeakReference **) PyObject_GET_WEAKREFS_LISTPTR(o)) - - -PyDoc_STRVAR(weakref_getweakrefcount__doc__, -"getweakrefcount(object) -- return the number of weak references\n" -"to 'object'."); - -static PyObject * -weakref_getweakrefcount(PyObject *self, PyObject *object) -{ - PyObject *result = NULL; - - if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) { - PyWeakReference **list = GET_WEAKREFS_LISTPTR(object); - - result = PyInt_FromLong(_PyWeakref_GetWeakrefCount(*list)); - } - else - result = PyInt_FromLong(0); - - return result; -} - - -PyDoc_STRVAR(weakref_getweakrefs__doc__, -"getweakrefs(object) -- return a list of all weak reference objects\n" -"that point to 'object'."); - -static PyObject * -weakref_getweakrefs(PyObject *self, PyObject *object) -{ - PyObject *result = NULL; - - if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) { - PyWeakReference **list = GET_WEAKREFS_LISTPTR(object); - long count = _PyWeakref_GetWeakrefCount(*list); - - result = PyList_New(count); - if (result != NULL) { - PyWeakReference *current = *list; - long i; - for (i = 0; i < count; ++i) { - PyList_SET_ITEM(result, i, (PyObject *) current); - Py_INCREF(current); - current = current->wr_next; - } - } - } - else { - result = PyList_New(0); - } - return result; -} - - -PyDoc_STRVAR(weakref_ref__doc__, -"ref(object[, callback]) -- create a weak reference to 'object';\n" -"when 'object' is finalized, 'callback' will be called and passed\n" -"a reference to the weak reference object when 'object' is about\n" -"to be finalized."); - -static PyObject * -weakref_ref(PyObject *self, PyObject *args) -{ - PyObject *object; - PyObject *callback = NULL; - PyObject *result = NULL; - - if (PyArg_UnpackTuple(args, "ref", 1, 2, &object, &callback)) { - result = PyWeakref_NewRef(object, callback); - } - return result; -} - - -PyDoc_STRVAR(weakref_proxy__doc__, -"proxy(object[, callback]) -- create a proxy object that weakly\n" -"references 'object'. 'callback', if given, is called with a\n" -"reference to the proxy when 'object' is about to be finalized."); - -static PyObject * -weakref_proxy(PyObject *self, PyObject *args) -{ - PyObject *object; - PyObject *callback = NULL; - PyObject *result = NULL; - - if (PyArg_UnpackTuple(args, "proxy", 1, 2, &object, &callback)) { - result = PyWeakref_NewProxy(object, callback); - } - return result; -} - - -static PyMethodDef -weakref_functions[] = { - {"getweakrefcount", weakref_getweakrefcount, METH_O, - weakref_getweakrefcount__doc__}, - {"getweakrefs", weakref_getweakrefs, METH_O, - weakref_getweakrefs__doc__}, - {"proxy", weakref_proxy, METH_VARARGS, - weakref_proxy__doc__}, - {"ref", weakref_ref, METH_VARARGS, - weakref_ref__doc__}, - {NULL, NULL, 0, NULL} -}; - - -PyMODINIT_FUNC -init_weakref(void) -{ - PyObject *m; - - m = Py_InitModule3("_weakref", weakref_functions, - "Weak-reference support module."); - if (m != NULL) { - Py_INCREF(&_PyWeakref_RefType); - PyModule_AddObject(m, "ReferenceType", - (PyObject *) &_PyWeakref_RefType); - Py_INCREF(&_PyWeakref_ProxyType); - PyModule_AddObject(m, "ProxyType", - (PyObject *) &_PyWeakref_ProxyType); - Py_INCREF(&_PyWeakref_CallableProxyType); - PyModule_AddObject(m, "CallableProxyType", - (PyObject *) &_PyWeakref_CallableProxyType); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/addrinfo.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/addrinfo.h deleted file mode 100644 index 6b528c08..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/addrinfo.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef HAVE_GETADDRINFO - -/* - * Error return codes from getaddrinfo() - */ -#ifdef EAI_ADDRFAMILY -/* If this is defined, there is a conflicting implementation - in the C library, which can't be used for some reason. - Make sure it won't interfere with this emulation. */ - -#undef EAI_ADDRFAMILY -#undef EAI_AGAIN -#undef EAI_BADFLAGS -#undef EAI_FAIL -#undef EAI_FAMILY -#undef EAI_MEMORY -#undef EAI_NODATA -#undef EAI_NONAME -#undef EAI_SERVICE -#undef EAI_SOCKTYPE -#undef EAI_SYSTEM -#undef EAI_BADHINTS -#undef EAI_PROTOCOL -#undef EAI_MAX -#undef getaddrinfo -#define getaddrinfo fake_getaddrinfo -#endif - -#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ -#define EAI_AGAIN 2 /* temporary failure in name resolution */ -#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ -#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ -#define EAI_FAMILY 5 /* ai_family not supported */ -#define EAI_MEMORY 6 /* memory allocation failure */ -#define EAI_NODATA 7 /* no address associated with hostname */ -#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ -#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ -#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ -#define EAI_SYSTEM 11 /* system error returned in errno */ -#define EAI_BADHINTS 12 -#define EAI_PROTOCOL 13 -#define EAI_MAX 14 - -/* - * Flag values for getaddrinfo() - */ -#ifdef AI_PASSIVE -#undef AI_PASSIVE -#undef AI_CANONNAME -#undef AI_NUMERICHOST -#undef AI_MASK -#undef AI_ALL -#undef AI_V4MAPPED_CFG -#undef AI_ADDRCONFIG -#undef AI_V4MAPPED -#undef AI_DEFAULT -#endif - -#define AI_PASSIVE 0x00000001 /* get address to use bind() */ -#define AI_CANONNAME 0x00000002 /* fill ai_canonname */ -#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ -/* valid flags for addrinfo */ -#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST) - -#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */ -#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */ -#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ -#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */ -/* special recommended flags for getipnodebyname */ -#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) - -#endif /* HAVE_GETADDRINFO */ - -#ifndef HAVE_GETNAMEINFO - -/* - * Constants for getnameinfo() - */ -#ifndef NI_MAXHOST -#define NI_MAXHOST 1025 -#define NI_MAXSERV 32 -#endif - -/* - * Flag values for getnameinfo() - */ -#ifndef NI_NOFQDN -#define NI_NOFQDN 0x00000001 -#define NI_NUMERICHOST 0x00000002 -#define NI_NAMEREQD 0x00000004 -#define NI_NUMERICSERV 0x00000008 -#define NI_DGRAM 0x00000010 -#endif - -#endif /* HAVE_GETNAMEINFO */ - -#ifndef HAVE_ADDRINFO -struct addrinfo { - int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ - int ai_family; /* PF_xxx */ - int ai_socktype; /* SOCK_xxx */ - int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ - size_t ai_addrlen; /* length of ai_addr */ - char *ai_canonname; /* canonical name for hostname */ - struct sockaddr *ai_addr; /* binary address */ - struct addrinfo *ai_next; /* next structure in linked list */ -}; -#endif - -#ifndef HAVE_SOCKADDR_STORAGE -/* - * RFC 2553: protocol-independent placeholder for socket addresses - */ -#define _SS_MAXSIZE 128 -#ifdef HAVE_LONG_LONG -#define _SS_ALIGNSIZE (sizeof(PY_LONG_LONG)) -#else -#define _SS_ALIGNSIZE (sizeof(double)) -#endif -#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_char) * 2) -#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) * 2 - \ - _SS_PAD1SIZE - _SS_ALIGNSIZE) - -struct sockaddr_storage { -#ifdef HAVE_SOCKADDR_SA_LEN - unsigned char ss_len; /* address length */ - unsigned char ss_family; /* address family */ -#else - unsigned short ss_family; /* address family */ -#endif - char __ss_pad1[_SS_PAD1SIZE]; -#ifdef HAVE_LONG_LONG - PY_LONG_LONG __ss_align; /* force desired structure storage alignment */ -#else - double __ss_align; /* force desired structure storage alignment */ -#endif - char __ss_pad2[_SS_PAD2SIZE]; -}; -#endif - -#ifdef __cplusplus -extern "C" { -#endif -extern void freehostent Py_PROTO((struct hostent *)); -#ifdef __cplusplus -} -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/almodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/almodule.c deleted file mode 100644 index 1cf9d9e9..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/almodule.c +++ /dev/null @@ -1,3222 +0,0 @@ - -#define OLD_INTERFACE /* define for pre-Irix 6 interface */ - -#include "Python.h" -#include "stringobject.h" -#include -#include - -#ifndef AL_NO_ELEM -#ifndef OLD_INTERFACE -#define OLD_INTERFACE -#endif /* OLD_INTERFACE */ -#endif /* AL_NO_ELEM */ - -static PyObject *ErrorObject; - -/* ----------------------------------------------------- */ - -/* Declarations for objects of type port */ - -typedef struct { - PyObject_HEAD - /* XXXX Add your own stuff here */ - ALport port; -} alpobject; - -static PyTypeObject Alptype; - - - -/* ---------------------------------------------------------------- */ - -/* Declarations for objects of type config */ - -typedef struct { - PyObject_HEAD - /* XXXX Add your own stuff here */ - ALconfig config; -} alcobject; - -static PyTypeObject Alctype; - - -static void -ErrorHandler(long code, const char *fmt, ...) -{ - va_list args; - char buf[128]; - - va_start(args, fmt); - vsprintf(buf, fmt, args); - va_end(args); - PyErr_SetString(ErrorObject, buf); -} - -#ifdef AL_NO_ELEM /* IRIX 6 */ - -static PyObject * -param2python(int resource, int param, ALvalue value, ALparamInfo *pinfo) -{ - ALparamInfo info; - - if (pinfo == NULL) { - pinfo = &info; - if (alGetParamInfo(resource, param, &info) < 0) - return NULL; - } - switch (pinfo->elementType) { - case AL_PTR_ELEM: - /* XXXX don't know how to handle this */ - case AL_NO_ELEM: - Py_INCREF(Py_None); - return Py_None; - case AL_INT32_ELEM: - case AL_RESOURCE_ELEM: - case AL_ENUM_ELEM: - return PyInt_FromLong((long) value.i); - case AL_INT64_ELEM: - return PyLong_FromLongLong(value.ll); - case AL_FIXED_ELEM: - return PyFloat_FromDouble(alFixedToDouble(value.ll)); - case AL_CHAR_ELEM: - if (value.ptr == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyString_FromString((char *) value.ptr); - default: - PyErr_SetString(ErrorObject, "unknown element type"); - return NULL; - } -} - -static int -python2elem(PyObject *item, void *ptr, int elementType) -{ - switch (elementType) { - case AL_INT32_ELEM: - case AL_RESOURCE_ELEM: - case AL_ENUM_ELEM: - if (!PyInt_Check(item)) { - PyErr_BadArgument(); - return -1; - } - *((int *) ptr) = PyInt_AsLong(item); - break; - case AL_INT64_ELEM: - if (PyInt_Check(item)) - *((long long *) ptr) = PyInt_AsLong(item); - else if (PyLong_Check(item)) - *((long long *) ptr) = PyLong_AsLongLong(item); - else { - PyErr_BadArgument(); - return -1; - } - break; - case AL_FIXED_ELEM: - if (PyInt_Check(item)) - *((long long *) ptr) = alDoubleToFixed((double) PyInt_AsLong(item)); - else if (PyFloat_Check(item)) - *((long long *) ptr) = alDoubleToFixed(PyFloat_AsDouble(item)); - else { - PyErr_BadArgument(); - return -1; - } - break; - default: - PyErr_SetString(ErrorObject, "unknown element type"); - return -1; - } - return 0; -} - -static int -python2param(int resource, ALpv *param, PyObject *value, ALparamInfo *pinfo) -{ - ALparamInfo info; - int i, stepsize; - PyObject *item; - - if (pinfo == NULL) { - pinfo = &info; - if (alGetParamInfo(resource, param->param, &info) < 0) - return -1; - } - switch (pinfo->valueType) { - case AL_STRING_VAL: - if (pinfo->elementType != AL_CHAR_ELEM) { - PyErr_SetString(ErrorObject, "unknown element type"); - return -1; - } - if (!PyString_Check(value)) { - PyErr_BadArgument(); - return -1; - } - param->value.ptr = PyString_AS_STRING(value); - param->sizeIn = PyString_GET_SIZE(value)+1; /*account for NUL*/ - break; - case AL_SET_VAL: - case AL_VECTOR_VAL: - if (!PyList_Check(value) && !PyTuple_Check(value)) { - PyErr_BadArgument(); - return -1; - } - switch (pinfo->elementType) { - case AL_INT32_ELEM: - case AL_RESOURCE_ELEM: - case AL_ENUM_ELEM: - param->sizeIn = PySequence_Size(value); - param->value.ptr = PyMem_NEW(int, param->sizeIn); - stepsize = sizeof(int); - break; - case AL_INT64_ELEM: - case AL_FIXED_ELEM: - param->sizeIn = PySequence_Size(value); - param->value.ptr = PyMem_NEW(long long, param->sizeIn); - stepsize = sizeof(long long); - break; - } - for (i = 0; i < param->sizeIn; i++) { - item = PySequence_GetItem(value, i); - if (python2elem(item, (void *) ((char *) param->value.ptr + i*stepsize), pinfo->elementType) < 0) { - PyMem_DEL(param->value.ptr); - return -1; - } - } - break; - case AL_SCALAR_VAL: - switch (pinfo->elementType) { - case AL_INT32_ELEM: - case AL_RESOURCE_ELEM: - case AL_ENUM_ELEM: - return python2elem(value, (void *) ¶m->value.i, - pinfo->elementType); - case AL_INT64_ELEM: - case AL_FIXED_ELEM: - return python2elem(value, (void *) ¶m->value.ll, - pinfo->elementType); - default: - PyErr_SetString(ErrorObject, "unknown element type"); - return -1; - } - } - return 0; -} - -static int -python2params(int resource1, int resource2, PyObject *list, ALpv **pvsp, ALparamInfo **pinfop) -{ - PyObject *item; - ALpv *pvs; - ALparamInfo *pinfo; - int npvs, i; - - npvs = PyList_Size(list); - pvs = PyMem_NEW(ALpv, npvs); - pinfo = PyMem_NEW(ALparamInfo, npvs); - for (i = 0; i < npvs; i++) { - item = PyList_GetItem(list, i); - if (!PyArg_ParseTuple(item, "iO", &pvs[i].param, &item)) - goto error; - if (alGetParamInfo(resource1, pvs[i].param, &pinfo[i]) < 0 && - alGetParamInfo(resource2, pvs[i].param, &pinfo[i]) < 0) - goto error; - if (python2param(resource1, &pvs[i], item, &pinfo[i]) < 0) - goto error; - } - - *pvsp = pvs; - *pinfop = pinfo; - return npvs; - - error: - /* XXXX we should clean up everything */ - if (pvs) - PyMem_DEL(pvs); - if (pinfo) - PyMem_DEL(pinfo); - return -1; -} - -/* -------------------------------------------------------- */ - - -static PyObject * -SetConfig(alcobject *self, PyObject *args, int (*func)(ALconfig, int)) -{ - int par; - - if (!PyArg_ParseTuple(args, "i:SetConfig", &par)) - return NULL; - - if ((*func)(self->config, par) == -1) - return NULL; - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -GetConfig(alcobject *self, PyObject *args, int (*func)(ALconfig)) -{ - int par; - - if (!PyArg_ParseTuple(args, ":GetConfig")) - return NULL; - - if ((par = (*func)(self->config)) == -1) - return NULL; - - return PyInt_FromLong((long) par); -} - -PyDoc_STRVAR(alc_SetWidth__doc__, -"alSetWidth: set the wordsize for integer audio data."); - -static PyObject * -alc_SetWidth(alcobject *self, PyObject *args) -{ - return SetConfig(self, args, alSetWidth); -} - - -PyDoc_STRVAR(alc_GetWidth__doc__, -"alGetWidth: get the wordsize for integer audio data."); - -static PyObject * -alc_GetWidth(alcobject *self, PyObject *args) -{ - return GetConfig(self, args, alGetWidth); -} - - -PyDoc_STRVAR(alc_SetSampFmt__doc__, -"alSetSampFmt: set the sample format setting in an audio ALconfig " -"structure."); - -static PyObject * -alc_SetSampFmt(alcobject *self, PyObject *args) -{ - return SetConfig(self, args, alSetSampFmt); -} - - -PyDoc_STRVAR(alc_GetSampFmt__doc__, -"alGetSampFmt: get the sample format setting in an audio ALconfig " -"structure."); - -static PyObject * -alc_GetSampFmt(alcobject *self, PyObject *args) -{ - return GetConfig(self, args, alGetSampFmt); -} - - -PyDoc_STRVAR(alc_SetChannels__doc__, -"alSetChannels: set the channel settings in an audio ALconfig."); - -static PyObject * -alc_SetChannels(alcobject *self, PyObject *args) -{ - return SetConfig(self, args, alSetChannels); -} - - -PyDoc_STRVAR(alc_GetChannels__doc__, -"alGetChannels: get the channel settings in an audio ALconfig."); - -static PyObject * -alc_GetChannels(alcobject *self, PyObject *args) -{ - return GetConfig(self, args, alGetChannels); -} - - -PyDoc_STRVAR(alc_SetFloatMax__doc__, -"alSetFloatMax: set the maximum value of floating point sample data."); - -static PyObject * -alc_SetFloatMax(alcobject *self, PyObject *args) -{ - double maximum_value; - - if (!PyArg_ParseTuple(args, "d:SetFloatMax", &maximum_value)) - return NULL; - if (alSetFloatMax(self->config, maximum_value) < 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - - -PyDoc_STRVAR(alc_GetFloatMax__doc__, -"alGetFloatMax: get the maximum value of floating point sample data."); - -static PyObject * -alc_GetFloatMax(alcobject *self, PyObject *args) -{ - double maximum_value; - - if (!PyArg_ParseTuple(args, ":GetFloatMax")) - return NULL; - if ((maximum_value = alGetFloatMax(self->config)) == 0) - return NULL; - return PyFloat_FromDouble(maximum_value); -} - - -PyDoc_STRVAR(alc_SetDevice__doc__, -"alSetDevice: set the device setting in an audio ALconfig structure."); - -static PyObject * -alc_SetDevice(alcobject *self, PyObject *args) -{ - return SetConfig(self, args, alSetDevice); -} - - -PyDoc_STRVAR(alc_GetDevice__doc__, -"alGetDevice: get the device setting in an audio ALconfig structure."); - -static PyObject * -alc_GetDevice(alcobject *self, PyObject *args) -{ - return GetConfig(self, args, alGetDevice); -} - - -PyDoc_STRVAR(alc_SetQueueSize__doc__, -"alSetQueueSize: set audio port buffer size."); - -static PyObject * -alc_SetQueueSize(alcobject *self, PyObject *args) -{ - return SetConfig(self, args, alSetQueueSize); -} - - -PyDoc_STRVAR(alc_GetQueueSize__doc__, -"alGetQueueSize: get audio port buffer size."); - -static PyObject * -alc_GetQueueSize(alcobject *self, PyObject *args) -{ - return GetConfig(self, args, alGetQueueSize); -} - -#endif /* AL_NO_ELEM */ - -static PyObject * -setconfig(alcobject *self, PyObject *args, int (*func)(ALconfig, long)) -{ - long par; - - if (!PyArg_ParseTuple(args, "l:SetConfig", &par)) - return NULL; - - if ((*func)(self->config, par) == -1) - return NULL; - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -getconfig(alcobject *self, PyObject *args, long (*func)(ALconfig)) -{ - long par; - - if (!PyArg_ParseTuple(args, ":GetConfig")) - return NULL; - - if ((par = (*func)(self->config)) == -1) - return NULL; - - return PyInt_FromLong((long) par); -} - -static PyObject * -alc_setqueuesize (alcobject *self, PyObject *args) -{ - return setconfig(self, args, ALsetqueuesize); -} - -static PyObject * -alc_getqueuesize (alcobject *self, PyObject *args) -{ - return getconfig(self, args, ALgetqueuesize); -} - -static PyObject * -alc_setwidth (alcobject *self, PyObject *args) -{ - return setconfig(self, args, ALsetwidth); -} - -static PyObject * -alc_getwidth (alcobject *self, PyObject *args) -{ - return getconfig(self, args, ALgetwidth); -} - -static PyObject * -alc_getchannels (alcobject *self, PyObject *args) -{ - return getconfig(self, args, ALgetchannels); -} - -static PyObject * -alc_setchannels (alcobject *self, PyObject *args) -{ - return setconfig(self, args, ALsetchannels); -} - -#ifdef AL_405 - -static PyObject * -alc_getsampfmt (alcobject *self, PyObject *args) -{ - return getconfig(self, args, ALgetsampfmt); -} - -static PyObject * -alc_setsampfmt (alcobject *self, PyObject *args) -{ - return setconfig(self, args, ALsetsampfmt); -} - -static PyObject * -alc_getfloatmax(alcobject *self, PyObject *args) -{ - double arg; - - if (!PyArg_ParseTuple(args, ":GetFloatMax")) - return 0; - if ((arg = ALgetfloatmax(self->config)) == 0) - return NULL; - return PyFloat_FromDouble(arg); -} - -static PyObject * -alc_setfloatmax(alcobject *self, PyObject *args) -{ - double arg; - - if (!PyArg_ParseTuple(args, "d:SetFloatMax", &arg)) - return 0; - if (ALsetfloatmax(self->config, arg) == -1) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} -#endif /* AL_405 */ - -static struct PyMethodDef alc_methods[] = { -#ifdef AL_NO_ELEM /* IRIX 6 */ - {"SetWidth", (PyCFunction)alc_SetWidth, METH_VARARGS, alc_SetWidth__doc__}, - {"GetWidth", (PyCFunction)alc_GetWidth, METH_VARARGS, alc_GetWidth__doc__}, - {"SetSampFmt", (PyCFunction)alc_SetSampFmt, METH_VARARGS, alc_SetSampFmt__doc__}, - {"GetSampFmt", (PyCFunction)alc_GetSampFmt, METH_VARARGS, alc_GetSampFmt__doc__}, - {"SetChannels", (PyCFunction)alc_SetChannels, METH_VARARGS, alc_SetChannels__doc__}, - {"GetChannels", (PyCFunction)alc_GetChannels, METH_VARARGS, alc_GetChannels__doc__}, - {"SetFloatMax", (PyCFunction)alc_SetFloatMax, METH_VARARGS, alc_SetFloatMax__doc__}, - {"GetFloatMax", (PyCFunction)alc_GetFloatMax, METH_VARARGS, alc_GetFloatMax__doc__}, - {"SetDevice", (PyCFunction)alc_SetDevice, METH_VARARGS, alc_SetDevice__doc__}, - {"GetDevice", (PyCFunction)alc_GetDevice, METH_VARARGS, alc_GetDevice__doc__}, - {"SetQueueSize", (PyCFunction)alc_SetQueueSize, METH_VARARGS, alc_SetQueueSize__doc__}, - {"GetQueueSize", (PyCFunction)alc_GetQueueSize, METH_VARARGS, alc_GetQueueSize__doc__}, -#endif /* AL_NO_ELEM */ - {"getqueuesize", (PyCFunction)alc_getqueuesize, METH_VARARGS}, - {"setqueuesize", (PyCFunction)alc_setqueuesize, METH_VARARGS}, - {"getwidth", (PyCFunction)alc_getwidth, METH_VARARGS}, - {"setwidth", (PyCFunction)alc_setwidth, METH_VARARGS}, - {"getchannels", (PyCFunction)alc_getchannels, METH_VARARGS}, - {"setchannels", (PyCFunction)alc_setchannels, METH_VARARGS}, -#ifdef AL_405 - {"getsampfmt", (PyCFunction)alc_getsampfmt, METH_VARARGS}, - {"setsampfmt", (PyCFunction)alc_setsampfmt, METH_VARARGS}, - {"getfloatmax", (PyCFunction)alc_getfloatmax, METH_VARARGS}, - {"setfloatmax", (PyCFunction)alc_setfloatmax, METH_VARARGS}, -#endif /* AL_405 */ - - {NULL, NULL} /* sentinel */ -}; - -/* ---------- */ - - -static PyObject * -newalcobject(ALconfig config) -{ - alcobject *self; - - self = PyObject_New(alcobject, &Alctype); - if (self == NULL) - return NULL; - /* XXXX Add your own initializers here */ - self->config = config; - return (PyObject *) self; -} - - -static void -alc_dealloc(alcobject *self) -{ - /* XXXX Add your own cleanup code here */ -#ifdef AL_NO_ELEM /* IRIX 6 */ - (void) alFreeConfig(self->config); /* ignore errors */ -#else - (void) ALfreeconfig(self->config); /* ignore errors */ -#endif - PyObject_Del(self); -} - -static PyObject * -alc_getattr(alcobject *self, char *name) -{ - /* XXXX Add your own getattr code here */ - return Py_FindMethod(alc_methods, (PyObject *)self, name); -} - -PyDoc_STRVAR(Alctype__doc__, ""); - -static PyTypeObject Alctype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "al.config", /*tp_name*/ - sizeof(alcobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)alc_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - (getattrfunc)alc_getattr, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ - (reprfunc)0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)0, /*tp_str*/ - - /* Space for future expansion */ - 0L,0L,0L,0L, - Alctype__doc__ /* Documentation string */ -}; - -/* End of code for config objects */ -/* ---------------------------------------------------------------- */ - -#ifdef AL_NO_ELEM /* IRIX 6 */ - -PyDoc_STRVAR(alp_SetConfig__doc__, -"alSetConfig: set the ALconfig of an audio ALport."); - -static PyObject * -alp_SetConfig(alpobject *self, PyObject *args) -{ - alcobject *config; - if (!PyArg_ParseTuple(args, "O!:SetConfig", &Alctype, &config)) - return NULL; - if (alSetConfig(self->port, config->config) < 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - - -PyDoc_STRVAR(alp_GetConfig__doc__, -"alGetConfig: get the ALconfig of an audio ALport."); - -static PyObject * -alp_GetConfig(alpobject *self, PyObject *args) -{ - ALconfig config; - if (!PyArg_ParseTuple(args, ":GetConfig")) - return NULL; - if ((config = alGetConfig(self->port)) == NULL) - return NULL; - return newalcobject(config); -} - - -PyDoc_STRVAR(alp_GetResource__doc__, -"alGetResource: get the resource associated with an audio port."); - -static PyObject * -alp_GetResource(alpobject *self, PyObject *args) -{ - int resource; - - if (!PyArg_ParseTuple(args, ":GetResource")) - return NULL; - if ((resource = alGetResource(self->port)) == 0) - return NULL; - return PyInt_FromLong((long) resource); -} - - -PyDoc_STRVAR(alp_GetFD__doc__, -"alGetFD: get the file descriptor for an audio port."); - -static PyObject * -alp_GetFD(alpobject *self, PyObject *args) -{ - int fd; - - if (!PyArg_ParseTuple(args, ":GetFD")) - return NULL; - - if ((fd = alGetFD(self->port)) < 0) - return NULL; - - return PyInt_FromLong((long) fd); -} - - -PyDoc_STRVAR(alp_GetFilled__doc__, -"alGetFilled: return the number of filled sample frames in " -"an audio port."); - -static PyObject * -alp_GetFilled(alpobject *self, PyObject *args) -{ - int filled; - - if (!PyArg_ParseTuple(args, ":GetFilled")) - return NULL; - if ((filled = alGetFilled(self->port)) < 0) - return NULL; - return PyInt_FromLong((long) filled); -} - - -PyDoc_STRVAR(alp_GetFillable__doc__, -"alGetFillable: report the number of unfilled sample frames " -"in an audio port."); - -static PyObject * -alp_GetFillable(alpobject *self, PyObject *args) -{ - int fillable; - - if (!PyArg_ParseTuple(args, ":GetFillable")) - return NULL; - if ((fillable = alGetFillable(self->port)) < 0) - return NULL; - return PyInt_FromLong((long) fillable); -} - - -PyDoc_STRVAR(alp_ReadFrames__doc__, -"alReadFrames: read sample frames from an audio port."); - -static PyObject * -alp_ReadFrames(alpobject *self, PyObject *args) -{ - int framecount; - PyObject *v; - int size; - int ch; - ALconfig c; - - if (!PyArg_ParseTuple(args, "i:ReadFrames", &framecount)) - return NULL; - if (framecount < 0) { - PyErr_SetString(ErrorObject, "negative framecount"); - return NULL; - } - c = alGetConfig(self->port); - switch (alGetSampFmt(c)) { - case AL_SAMPFMT_TWOSCOMP: - switch (alGetWidth(c)) { - case AL_SAMPLE_8: - size = 1; - break; - case AL_SAMPLE_16: - size = 2; - break; - case AL_SAMPLE_24: - size = 4; - break; - default: - PyErr_SetString(ErrorObject, "can't determine width"); - alFreeConfig(c); - return NULL; - } - break; - case AL_SAMPFMT_FLOAT: - size = 4; - break; - case AL_SAMPFMT_DOUBLE: - size = 8; - break; - default: - PyErr_SetString(ErrorObject, "can't determine format"); - alFreeConfig(c); - return NULL; - } - ch = alGetChannels(c); - alFreeConfig(c); - if (ch < 0) { - PyErr_SetString(ErrorObject, "can't determine # of channels"); - return NULL; - } - size *= ch; - v = PyString_FromStringAndSize((char *) NULL, size * framecount); - if (v == NULL) - return NULL; - - Py_BEGIN_ALLOW_THREADS - alReadFrames(self->port, (void *) PyString_AS_STRING(v), framecount); - Py_END_ALLOW_THREADS - - return v; -} - - -PyDoc_STRVAR(alp_DiscardFrames__doc__, -"alDiscardFrames: discard audio from an audio port."); - -static PyObject * -alp_DiscardFrames(alpobject *self, PyObject *args) -{ - int framecount; - - if (!PyArg_ParseTuple(args, "i:DiscardFrames", &framecount)) - return NULL; - - Py_BEGIN_ALLOW_THREADS - framecount = alDiscardFrames(self->port, framecount); - Py_END_ALLOW_THREADS - - if (framecount < 0) - return NULL; - - return PyInt_FromLong((long) framecount); -} - - -PyDoc_STRVAR(alp_ZeroFrames__doc__, -"alZeroFrames: write zero-valued sample frames to an audio port."); - -static PyObject * -alp_ZeroFrames(alpobject *self, PyObject *args) -{ - int framecount; - - if (!PyArg_ParseTuple(args, "i:ZeroFrames", &framecount)) - return NULL; - - if (framecount < 0) { - PyErr_SetString(ErrorObject, "negative framecount"); - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - alZeroFrames(self->port, framecount); - Py_END_ALLOW_THREADS - - Py_INCREF(Py_None); - return Py_None; -} - - -PyDoc_STRVAR(alp_SetFillPoint__doc__, -"alSetFillPoint: set low- or high-water mark for an audio port."); - -static PyObject * -alp_SetFillPoint(alpobject *self, PyObject *args) -{ - int fillpoint; - - if (!PyArg_ParseTuple(args, "i:SetFillPoint", &fillpoint)) - return NULL; - - if (alSetFillPoint(self->port, fillpoint) < 0) - return NULL; - - Py_INCREF(Py_None); - return Py_None; -} - - -PyDoc_STRVAR(alp_GetFillPoint__doc__, -"alGetFillPoint: get low- or high-water mark for an audio port."); - -static PyObject * -alp_GetFillPoint(alpobject *self, PyObject *args) -{ - int fillpoint; - - if (!PyArg_ParseTuple(args, ":GetFillPoint")) - return NULL; - - if ((fillpoint = alGetFillPoint(self->port)) < 0) - return NULL; - - return PyInt_FromLong((long) fillpoint); -} - - -PyDoc_STRVAR(alp_GetFrameNumber__doc__, -"alGetFrameNumber: get the absolute sample frame number " -"associated with a port."); - -static PyObject * -alp_GetFrameNumber(alpobject *self, PyObject *args) -{ - stamp_t fnum; - - if (!PyArg_ParseTuple(args, ":GetFrameNumber")) - return NULL; - - if (alGetFrameNumber(self->port, &fnum) < 0) - return NULL; - - return PyLong_FromLongLong((long long) fnum); -} - - -PyDoc_STRVAR(alp_GetFrameTime__doc__, -"alGetFrameTime: get the time at which a sample frame came " -"in or will go out."); - -static PyObject * -alp_GetFrameTime(alpobject *self, PyObject *args) -{ - stamp_t fnum, time; - PyObject *ret, *v0, *v1; - - if (!PyArg_ParseTuple(args, ":GetFrameTime")) - return NULL; - if (alGetFrameTime(self->port, &fnum, &time) < 0) - return NULL; - v0 = PyLong_FromLongLong((long long) fnum); - v1 = PyLong_FromLongLong((long long) time); - if (PyErr_Occurred()) { - Py_XDECREF(v0); - Py_XDECREF(v1); - return NULL; - } - ret = Py_BuildValue("(OO)", v0, v1); - Py_DECREF(v0); - Py_DECREF(v1); - return ret; -} - - -PyDoc_STRVAR(alp_WriteFrames__doc__, -"alWriteFrames: write sample frames to an audio port."); - -static PyObject * -alp_WriteFrames(alpobject *self, PyObject *args) -{ - char *samples; - int length; - int size, ch; - ALconfig c; - - if (!PyArg_ParseTuple(args, "s#:WriteFrames", &samples, &length)) - return NULL; - c = alGetConfig(self->port); - switch (alGetSampFmt(c)) { - case AL_SAMPFMT_TWOSCOMP: - switch (alGetWidth(c)) { - case AL_SAMPLE_8: - size = 1; - break; - case AL_SAMPLE_16: - size = 2; - break; - case AL_SAMPLE_24: - size = 4; - break; - default: - PyErr_SetString(ErrorObject, "can't determine width"); - alFreeConfig(c); - return NULL; - } - break; - case AL_SAMPFMT_FLOAT: - size = 4; - break; - case AL_SAMPFMT_DOUBLE: - size = 8; - break; - default: - PyErr_SetString(ErrorObject, "can't determine format"); - alFreeConfig(c); - return NULL; - } - ch = alGetChannels(c); - alFreeConfig(c); - if (ch < 0) { - PyErr_SetString(ErrorObject, "can't determine # of channels"); - return NULL; - } - size *= ch; - if (length % size != 0) { - PyErr_SetString(ErrorObject, - "buffer length not whole number of frames"); - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - alWriteFrames(self->port, (void *) samples, length / size); - Py_END_ALLOW_THREADS - - Py_INCREF(Py_None); - return Py_None; -} - - -PyDoc_STRVAR(alp_ClosePort__doc__, "alClosePort: close an audio port."); - -static PyObject * -alp_ClosePort(alpobject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":ClosePort")) - return NULL; - if (alClosePort(self->port) < 0) - return NULL; - self->port = NULL; - Py_INCREF(Py_None); - return Py_None; -} - -#endif /* AL_NO_ELEM */ - -#ifdef OLD_INTERFACE -static PyObject * -alp_closeport(alpobject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":ClosePort")) - return NULL; - if (ALcloseport(self->port) < 0) - return NULL; - self->port = NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -alp_getfd(alpobject *self, PyObject *args) -{ - int fd; - - if (!PyArg_ParseTuple(args, ":GetFD")) - return NULL; - if ((fd = ALgetfd(self-> port)) == -1) - return NULL; - return PyInt_FromLong(fd); -} - -static PyObject * -alp_getfilled(alpobject *self, PyObject *args) -{ - long count; - - if (!PyArg_ParseTuple(args, ":GetFilled")) - return NULL; - if ((count = ALgetfilled(self-> port)) == -1) - return NULL; - return PyInt_FromLong(count); -} - -static PyObject * -alp_getfillable(alpobject *self, PyObject *args) -{ - long count; - - if (!PyArg_ParseTuple(args, ":GetFillable")) - return NULL; - if ((count = ALgetfillable(self-> port)) == -1) - return NULL; - return PyInt_FromLong (count); -} - -static PyObject * -alp_readsamps(alpobject *self, PyObject *args) -{ - long count; - PyObject *v; - ALconfig c; - int width; - int ret; - - if (!PyArg_ParseTuple(args, "l:readsamps", &count)) - return NULL; - - if (count <= 0) { - PyErr_SetString(ErrorObject, "al.readsamps : arg <= 0"); - return NULL; - } - - c = ALgetconfig(self->port); -#ifdef AL_405 - width = ALgetsampfmt(c); - if (width == AL_SAMPFMT_FLOAT) - width = sizeof(float); - else if (width == AL_SAMPFMT_DOUBLE) - width = sizeof(double); - else - width = ALgetwidth(c); -#else - width = ALgetwidth(c); -#endif /* AL_405 */ - ALfreeconfig(c); - v = PyString_FromStringAndSize((char *)NULL, width * count); - if (v == NULL) - return NULL; - - Py_BEGIN_ALLOW_THREADS - ret = ALreadsamps(self->port, (void *) PyString_AsString(v), count); - Py_END_ALLOW_THREADS - if (ret == -1) { - Py_DECREF(v); - return NULL; - } - - return (v); -} - -static PyObject * -alp_writesamps(alpobject *self, PyObject *args) -{ - char *buf; - int size, width; - ALconfig c; - int ret; - - if (!PyArg_ParseTuple(args, "s#:writesamps", &buf, &size)) - return NULL; - - c = ALgetconfig(self->port); -#ifdef AL_405 - width = ALgetsampfmt(c); - if (width == AL_SAMPFMT_FLOAT) - width = sizeof(float); - else if (width == AL_SAMPFMT_DOUBLE) - width = sizeof(double); - else - width = ALgetwidth(c); -#else - width = ALgetwidth(c); -#endif /* AL_405 */ - ALfreeconfig(c); - Py_BEGIN_ALLOW_THREADS - ret = ALwritesamps (self->port, (void *) buf, (long) size / width); - Py_END_ALLOW_THREADS - if (ret == -1) - return NULL; - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -alp_getfillpoint(alpobject *self, PyObject *args) -{ - long count; - - if (!PyArg_ParseTuple(args, ":GetFillPoint")) - return NULL; - if ((count = ALgetfillpoint(self->port)) == -1) - return NULL; - return PyInt_FromLong(count); -} - -static PyObject * -alp_setfillpoint(alpobject *self, PyObject *args) -{ - long count; - - if (!PyArg_ParseTuple(args, "l:SetFillPoint", &count)) - return NULL; - if (ALsetfillpoint(self->port, count) == -1) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -alp_setconfig(alpobject *self, PyObject *args) -{ - alcobject *config; - - if (!PyArg_ParseTuple(args, "O!:SetConfig", &Alctype, &config)) - return NULL; - if (ALsetconfig(self->port, config->config) == -1) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -alp_getconfig(alpobject *self, PyObject *args) -{ - ALconfig config; - - if (!PyArg_ParseTuple(args, ":GetConfig")) - return NULL; - config = ALgetconfig(self->port); - if (config == NULL) - return NULL; - return newalcobject(config); -} - -#ifdef AL_405 -static PyObject * -alp_getstatus(alpobject *self, PyObject *args) -{ - PyObject *list, *v; - long *PVbuffer; - long length; - int i; - - if (!PyArg_ParseTuple(args, "O!", &PyList_Type, &list)) - return NULL; - length = PyList_Size(list); - PVbuffer = PyMem_NEW(long, length); - if (PVbuffer == NULL) - return PyErr_NoMemory(); - for (i = 0; i < length; i++) { - v = PyList_GetItem(list, i); - if (!PyInt_Check(v)) { - PyMem_DEL(PVbuffer); - PyErr_BadArgument(); - return NULL; - } - PVbuffer[i] = PyInt_AsLong(v); - } - - if (ALgetstatus(self->port, PVbuffer, length) == -1) - return NULL; - - for (i = 0; i < length; i++) - PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i])); - - PyMem_DEL(PVbuffer); - - Py_INCREF(Py_None); - return Py_None; -} -#endif /* AL_405 */ - -#endif /* OLD_INTERFACE */ - -static struct PyMethodDef alp_methods[] = { -#ifdef AL_NO_ELEM /* IRIX 6 */ - {"SetConfig", (PyCFunction)alp_SetConfig, METH_VARARGS, alp_SetConfig__doc__}, - {"GetConfig", (PyCFunction)alp_GetConfig, METH_VARARGS, alp_GetConfig__doc__}, - {"GetResource", (PyCFunction)alp_GetResource, METH_VARARGS, alp_GetResource__doc__}, - {"GetFD", (PyCFunction)alp_GetFD, METH_VARARGS, alp_GetFD__doc__}, - {"GetFilled", (PyCFunction)alp_GetFilled, METH_VARARGS, alp_GetFilled__doc__}, - {"GetFillable", (PyCFunction)alp_GetFillable, METH_VARARGS, alp_GetFillable__doc__}, - {"ReadFrames", (PyCFunction)alp_ReadFrames, METH_VARARGS, alp_ReadFrames__doc__}, - {"DiscardFrames", (PyCFunction)alp_DiscardFrames, METH_VARARGS, alp_DiscardFrames__doc__}, - {"ZeroFrames", (PyCFunction)alp_ZeroFrames, METH_VARARGS, alp_ZeroFrames__doc__}, - {"SetFillPoint", (PyCFunction)alp_SetFillPoint, METH_VARARGS, alp_SetFillPoint__doc__}, - {"GetFillPoint", (PyCFunction)alp_GetFillPoint, METH_VARARGS, alp_GetFillPoint__doc__}, - {"GetFrameNumber", (PyCFunction)alp_GetFrameNumber, METH_VARARGS, alp_GetFrameNumber__doc__}, - {"GetFrameTime", (PyCFunction)alp_GetFrameTime, METH_VARARGS, alp_GetFrameTime__doc__}, - {"WriteFrames", (PyCFunction)alp_WriteFrames, METH_VARARGS, alp_WriteFrames__doc__}, - {"ClosePort", (PyCFunction)alp_ClosePort, METH_VARARGS, alp_ClosePort__doc__}, -#endif /* AL_NO_ELEM */ -#ifdef OLD_INTERFACE - {"closeport", (PyCFunction)alp_closeport, METH_VARARGS}, - {"getfd", (PyCFunction)alp_getfd, METH_VARARGS}, - {"fileno", (PyCFunction)alp_getfd, METH_VARARGS}, - {"getfilled", (PyCFunction)alp_getfilled, METH_VARARGS}, - {"getfillable", (PyCFunction)alp_getfillable, METH_VARARGS}, - {"readsamps", (PyCFunction)alp_readsamps, METH_VARARGS}, - {"writesamps", (PyCFunction)alp_writesamps, METH_VARARGS}, - {"setfillpoint", (PyCFunction)alp_setfillpoint, METH_VARARGS}, - {"getfillpoint", (PyCFunction)alp_getfillpoint, METH_VARARGS}, - {"setconfig", (PyCFunction)alp_setconfig, METH_VARARGS}, - {"getconfig", (PyCFunction)alp_getconfig, METH_VARARGS}, -#ifdef AL_405 - {"getstatus", (PyCFunction)alp_getstatus, METH_VARARGS}, -#endif /* AL_405 */ -#endif /* OLD_INTERFACE */ - - {NULL, NULL} /* sentinel */ -}; - -/* ---------- */ - - -static PyObject * -newalpobject(ALport port) -{ - alpobject *self; - - self = PyObject_New(alpobject, &Alptype); - if (self == NULL) - return NULL; - /* XXXX Add your own initializers here */ - self->port = port; - return (PyObject *) self; -} - - -static void -alp_dealloc(alpobject *self) -{ - /* XXXX Add your own cleanup code here */ - if (self->port) { -#ifdef AL_NO_ELEM /* IRIX 6 */ - alClosePort(self->port); -#else - ALcloseport(self->port); -#endif - } - PyObject_Del(self); -} - -static PyObject * -alp_getattr(alpobject *self, char *name) -{ - /* XXXX Add your own getattr code here */ - if (self->port == NULL) { - PyErr_SetString(ErrorObject, "port already closed"); - return NULL; - } - return Py_FindMethod(alp_methods, (PyObject *)self, name); -} - -PyDoc_STRVAR(Alptype__doc__, ""); - -static PyTypeObject Alptype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "al.port", /*tp_name*/ - sizeof(alpobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)alp_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - (getattrfunc)alp_getattr, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ - (reprfunc)0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)0, /*tp_str*/ - - /* Space for future expansion */ - 0L,0L,0L,0L, - Alptype__doc__ /* Documentation string */ -}; - -/* End of code for port objects */ -/* -------------------------------------------------------- */ - - -#ifdef AL_NO_ELEM /* IRIX 6 */ - -PyDoc_STRVAR(al_NewConfig__doc__, -"alNewConfig: create and initialize an audio ALconfig structure."); - -static PyObject * -al_NewConfig(PyObject *self, PyObject *args) -{ - ALconfig config; - - if (!PyArg_ParseTuple(args, ":NewConfig")) - return NULL; - if ((config = alNewConfig()) == NULL) - return NULL; - return newalcobject(config); -} - -PyDoc_STRVAR(al_OpenPort__doc__, -"alOpenPort: open an audio port."); - -static PyObject * -al_OpenPort(PyObject *self, PyObject *args) -{ - ALport port; - char *name, *dir; - alcobject *config = NULL; - - if (!PyArg_ParseTuple(args, "ss|O!:OpenPort", &name, &dir, &Alctype, &config)) - return NULL; - if ((port = alOpenPort(name, dir, config ? config->config : NULL)) == NULL) - return NULL; - return newalpobject(port); -} - -PyDoc_STRVAR(al_Connect__doc__, -"alConnect: connect two audio I/O resources."); - -static PyObject * -al_Connect(PyObject *self, PyObject *args) -{ - int source, dest, nprops = 0, id, i; - ALpv *props = NULL; - ALparamInfo *propinfo = NULL; - PyObject *propobj = NULL; - - if (!PyArg_ParseTuple(args, "ii|O!:Connect", &source, &dest, &PyList_Type, &propobj)) - return NULL; - if (propobj != NULL) { - nprops = python2params(source, dest, propobj, &props, &propinfo); - if (nprops < 0) - return NULL; - } - - id = alConnect(source, dest, props, nprops); - - if (props) { - for (i = 0; i < nprops; i++) { - switch (propinfo[i].valueType) { - case AL_SET_VAL: - case AL_VECTOR_VAL: - PyMem_DEL(props[i].value.ptr); - break; - } - } - PyMem_DEL(props); - PyMem_DEL(propinfo); - } - - if (id < 0) - return NULL; - return PyInt_FromLong((long) id); -} - -PyDoc_STRVAR(al_Disconnect__doc__, -"alDisconnect: delete a connection between two audio I/O resources."); - -static PyObject * -al_Disconnect(PyObject *self, PyObject *args) -{ - int res; - - if (!PyArg_ParseTuple(args, "i:Disconnect", &res)) - return NULL; - if (alDisconnect(res) < 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(al_GetParams__doc__, -"alGetParams: get the values of audio resource parameters."); - -static PyObject * -al_GetParams(PyObject *self, PyObject *args) -{ - int resource; - PyObject *pvslist, *item = NULL, *v = NULL; - ALpv *pvs; - int i, j, npvs; - ALparamInfo *pinfo; - - if (!PyArg_ParseTuple(args, "iO!:GetParams", &resource, &PyList_Type, &pvslist)) - return NULL; - npvs = PyList_Size(pvslist); - pvs = PyMem_NEW(ALpv, npvs); - pinfo = PyMem_NEW(ALparamInfo, npvs); - for (i = 0; i < npvs; i++) { - item = PyList_GetItem(pvslist, i); - if (!PyInt_Check(item)) { - item = NULL; - PyErr_SetString(ErrorObject, "list of integers expected"); - goto error; - } - pvs[i].param = (int) PyInt_AsLong(item); - item = NULL; /* not needed anymore */ - if (alGetParamInfo(resource, pvs[i].param, &pinfo[i]) < 0) - goto error; - switch (pinfo[i].valueType) { - case AL_NO_VAL: - break; - case AL_MATRIX_VAL: - pinfo[i].maxElems *= pinfo[i].maxElems2; - /* fall through */ - case AL_STRING_VAL: - case AL_SET_VAL: - case AL_VECTOR_VAL: - switch (pinfo[i].elementType) { - case AL_INT32_ELEM: - case AL_RESOURCE_ELEM: - case AL_ENUM_ELEM: - pvs[i].value.ptr = PyMem_NEW(int, pinfo[i].maxElems); - pvs[i].sizeIn = pinfo[i].maxElems; - break; - case AL_INT64_ELEM: - case AL_FIXED_ELEM: - pvs[i].value.ptr = PyMem_NEW(long long, pinfo[i].maxElems); - pvs[i].sizeIn = pinfo[i].maxElems; - break; - case AL_CHAR_ELEM: - pvs[i].value.ptr = PyMem_NEW(char, 32); - pvs[i].sizeIn = 32; - break; - case AL_NO_ELEM: - case AL_PTR_ELEM: - default: - PyErr_SetString(ErrorObject, "internal error"); - goto error; - } - break; - case AL_SCALAR_VAL: - break; - default: - PyErr_SetString(ErrorObject, "internal error"); - goto error; - } - if (pinfo[i].valueType == AL_MATRIX_VAL) { - pinfo[i].maxElems /= pinfo[i].maxElems2; - pvs[i].sizeIn /= pinfo[i].maxElems2; - pvs[i].size2In = pinfo[i].maxElems2; - } - } - if (alGetParams(resource, pvs, npvs) < 0) - goto error; - v = PyList_New(npvs); - for (i = 0; i < npvs; i++) { - if (pvs[i].sizeOut < 0) { - char buf[32]; - PyOS_snprintf(buf, sizeof(buf), - "problem with param %d", i); - PyErr_SetString(ErrorObject, buf); - goto error; - } - switch (pinfo[i].valueType) { - case AL_NO_VAL: - item = Py_None; - Py_INCREF(item); - break; - case AL_STRING_VAL: - item = PyString_FromString(pvs[i].value.ptr); - PyMem_DEL(pvs[i].value.ptr); - break; - case AL_MATRIX_VAL: - /* XXXX this is not right */ - pvs[i].sizeOut *= pvs[i].size2Out; - /* fall through */ - case AL_SET_VAL: - case AL_VECTOR_VAL: - item = PyList_New(pvs[i].sizeOut); - for (j = 0; j < pvs[i].sizeOut; j++) { - switch (pinfo[i].elementType) { - case AL_INT32_ELEM: - case AL_RESOURCE_ELEM: - case AL_ENUM_ELEM: - PyList_SetItem(item, j, PyInt_FromLong((long) ((int *) pvs[i].value.ptr)[j])); - break; - case AL_INT64_ELEM: - PyList_SetItem(item, j, PyLong_FromLongLong(((long long *) pvs[i].value.ptr)[j])); - break; - case AL_FIXED_ELEM: - PyList_SetItem(item, j, PyFloat_FromDouble(alFixedToDouble(((long long *) pvs[i].value.ptr)[j]))); - break; - default: - PyErr_SetString(ErrorObject, "internal error"); - goto error; - } - } - PyMem_DEL(pvs[i].value.ptr); - break; - case AL_SCALAR_VAL: - item = param2python(resource, pvs[i].param, pvs[i].value, &pinfo[i]); - break; - } - if (PyErr_Occurred() || - PyList_SetItem(v, i, Py_BuildValue("(iO)", pvs[i].param, - item)) < 0 || - PyErr_Occurred()) - goto error; - Py_DECREF(item); - } - PyMem_DEL(pvs); - PyMem_DEL(pinfo); - return v; - - error: - Py_XDECREF(v); - Py_XDECREF(item); - if (pvs) - PyMem_DEL(pvs); - if (pinfo) - PyMem_DEL(pinfo); - return NULL; -} - -PyDoc_STRVAR(al_SetParams__doc__, -"alSetParams: set the values of audio resource parameters."); - -static PyObject * -al_SetParams(PyObject *self, PyObject *args) -{ - int resource; - PyObject *pvslist; - ALpv *pvs; - ALparamInfo *pinfo; - int npvs, i; - - if (!PyArg_ParseTuple(args, "iO!:SetParams", &resource, &PyList_Type, &pvslist)) - return NULL; - npvs = python2params(resource, -1, pvslist, &pvs, &pinfo); - if (npvs < 0) - return NULL; - - if (alSetParams(resource, pvs, npvs) < 0) - goto error; - - /* cleanup */ - for (i = 0; i < npvs; i++) { - switch (pinfo[i].valueType) { - case AL_SET_VAL: - case AL_VECTOR_VAL: - PyMem_DEL(pvs[i].value.ptr); - break; - } - } - PyMem_DEL(pvs); - PyMem_DEL(pinfo); - - Py_INCREF(Py_None); - return Py_None; - - error: - /* XXXX we should clean up everything */ - if (pvs) - PyMem_DEL(pvs); - if (pinfo) - PyMem_DEL(pinfo); - return NULL; -} - -PyDoc_STRVAR(al_QueryValues__doc__, -"alQueryValues: get the set of possible values for a parameter."); - -static PyObject * -al_QueryValues(PyObject *self, PyObject *args) -{ - int resource, param; - ALvalue *return_set = NULL; - int setsize = 32, qualsize = 0, nvals, i; - ALpv *quals = NULL; - ALparamInfo pinfo; - ALparamInfo *qualinfo = NULL; - PyObject *qualobj = NULL; - PyObject *res = NULL, *item; - - if (!PyArg_ParseTuple(args, "ii|O!:QueryValues", &resource, ¶m, - &PyList_Type, &qualobj)) - return NULL; - if (qualobj != NULL) { - qualsize = python2params(resource, param, qualobj, &quals, &qualinfo); - if (qualsize < 0) - return NULL; - } - setsize = 32; - return_set = PyMem_NEW(ALvalue, setsize); - if (return_set == NULL) { - PyErr_NoMemory(); - goto cleanup; - } - - retry: - nvals = alQueryValues(resource, param, return_set, setsize, quals, qualsize); - if (nvals < 0) - goto cleanup; - if (nvals > setsize) { - setsize = nvals; - PyMem_RESIZE(return_set, ALvalue, setsize); - if (return_set == NULL) { - PyErr_NoMemory(); - goto cleanup; - } - goto retry; - } - - if (alGetParamInfo(resource, param, &pinfo) < 0) - goto cleanup; - - res = PyList_New(nvals); - if (res == NULL) - goto cleanup; - for (i = 0; i < nvals; i++) { - item = param2python(resource, param, return_set[i], &pinfo); - if (item == NULL || - PyList_SetItem(res, i, item) < 0) { - Py_DECREF(res); - res = NULL; - goto cleanup; - } - } - - cleanup: - if (return_set) - PyMem_DEL(return_set); - if (quals) { - for (i = 0; i < qualsize; i++) { - switch (qualinfo[i].valueType) { - case AL_SET_VAL: - case AL_VECTOR_VAL: - PyMem_DEL(quals[i].value.ptr); - break; - } - } - PyMem_DEL(quals); - PyMem_DEL(qualinfo); - } - - return res; -} - -PyDoc_STRVAR(al_GetParamInfo__doc__, -"alGetParamInfo: get information about a parameter on " -"a particular audio resource."); - -static PyObject * -al_GetParamInfo(PyObject *self, PyObject *args) -{ - int res, param; - ALparamInfo pinfo; - PyObject *v, *item;; - - if (!PyArg_ParseTuple(args, "ii:GetParamInfo", &res, ¶m)) - return NULL; - if (alGetParamInfo(res, param, &pinfo) < 0) - return NULL; - v = PyDict_New(); - - item = PyInt_FromLong((long) pinfo.resource); - PyDict_SetItemString(v, "resource", item); - Py_DECREF(item); - - item = PyInt_FromLong((long) pinfo.param); - PyDict_SetItemString(v, "param", item); - Py_DECREF(item); - - item = PyInt_FromLong((long) pinfo.valueType); - PyDict_SetItemString(v, "valueType", item); - Py_DECREF(item); - - if (pinfo.valueType != AL_NO_VAL && pinfo.valueType != AL_SCALAR_VAL) { - /* multiple values */ - item = PyInt_FromLong((long) pinfo.maxElems); - PyDict_SetItemString(v, "maxElems", item); - Py_DECREF(item); - - if (pinfo.valueType == AL_MATRIX_VAL) { - /* 2 dimensional */ - item = PyInt_FromLong((long) pinfo.maxElems2); - PyDict_SetItemString(v, "maxElems2", item); - Py_DECREF(item); - } - } - - item = PyInt_FromLong((long) pinfo.elementType); - PyDict_SetItemString(v, "elementType", item); - Py_DECREF(item); - - item = PyString_FromString(pinfo.name); - PyDict_SetItemString(v, "name", item); - Py_DECREF(item); - - item = param2python(res, param, pinfo.initial, &pinfo); - PyDict_SetItemString(v, "initial", item); - Py_DECREF(item); - - if (pinfo.elementType != AL_ENUM_ELEM && - pinfo.elementType != AL_RESOURCE_ELEM && - pinfo.elementType != AL_CHAR_ELEM) { - /* range param */ - item = param2python(res, param, pinfo.min, &pinfo); - PyDict_SetItemString(v, "min", item); - Py_DECREF(item); - - item = param2python(res, param, pinfo.max, &pinfo); - PyDict_SetItemString(v, "max", item); - Py_DECREF(item); - - item = param2python(res, param, pinfo.minDelta, &pinfo); - PyDict_SetItemString(v, "minDelta", item); - Py_DECREF(item); - - item = param2python(res, param, pinfo.maxDelta, &pinfo); - PyDict_SetItemString(v, "maxDelta", item); - Py_DECREF(item); - - item = PyInt_FromLong((long) pinfo.specialVals); - PyDict_SetItemString(v, "specialVals", item); - Py_DECREF(item); - } - - return v; -} - -PyDoc_STRVAR(al_GetResourceByName__doc__, -"alGetResourceByName: find an audio resource by name."); - -static PyObject * -al_GetResourceByName(PyObject *self, PyObject *args) -{ - int res, start_res, type; - char *name; - - if (!PyArg_ParseTuple(args, "isi:GetResourceByName", &start_res, &name, &type)) - return NULL; - if ((res = alGetResourceByName(start_res, name, type)) == 0) - return NULL; - return PyInt_FromLong((long) res); -} - -PyDoc_STRVAR(al_IsSubtype__doc__, -"alIsSubtype: indicate if one resource type is a subtype of another."); - -static PyObject * -al_IsSubtype(PyObject *self, PyObject *args) -{ - int type, subtype; - - if (!PyArg_ParseTuple(args, "ii:IsSubtype", &type, &subtype)) - return NULL; - return PyInt_FromLong((long) alIsSubtype(type, subtype)); -} - -PyDoc_STRVAR(al_SetErrorHandler__doc__, ""); - -static PyObject * -al_SetErrorHandler(PyObject *self, PyObject *args) -{ - - if (!PyArg_ParseTuple(args, ":SetErrorHandler")) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -#endif /* AL_NO_ELEM */ - -#ifdef OLD_INTERFACE - -static PyObject * -al_openport(PyObject *self, PyObject *args) -{ - char *name, *dir; - ALport port; - alcobject *config = NULL; - - if (!PyArg_ParseTuple(args, "ss|O!:OpenPort", &name, &dir, &Alctype, &config)) - return NULL; - if ((port = ALopenport(name, dir, config ? config->config : NULL)) == NULL) - return NULL; - return newalpobject(port); -} - -static PyObject * -al_newconfig(PyObject *self, PyObject *args) -{ - ALconfig config; - - if (!PyArg_ParseTuple(args, ":NewConfig")) - return NULL; - if ((config = ALnewconfig ()) == NULL) - return NULL; - return newalcobject(config); -} - -static PyObject * -al_queryparams(PyObject *self, PyObject *args) -{ - long device; - long length; - long *PVbuffer; - long PVdummy[2]; - PyObject *v = NULL; - int i; - - if (!PyArg_ParseTuple(args, "l:queryparams", &device)) - return NULL; - if ((length = ALqueryparams(device, PVdummy, 2L)) == -1) - return NULL; - if ((PVbuffer = PyMem_NEW(long, length)) == NULL) - return PyErr_NoMemory(); - if (ALqueryparams(device, PVbuffer, length) >= 0 && - (v = PyList_New((int)length)) != NULL) { - for (i = 0; i < length; i++) - PyList_SetItem(v, i, PyInt_FromLong(PVbuffer[i])); - } - PyMem_DEL(PVbuffer); - return v; -} - -static PyObject * -doParams(PyObject *args, int (*func)(long, long *, long), int modified) -{ - long device; - PyObject *list, *v; - long *PVbuffer; - long length; - int i; - - if (!PyArg_ParseTuple(args, "lO!", &device, &PyList_Type, &list)) - return NULL; - length = PyList_Size(list); - PVbuffer = PyMem_NEW(long, length); - if (PVbuffer == NULL) - return PyErr_NoMemory(); - for (i = 0; i < length; i++) { - v = PyList_GetItem(list, i); - if (!PyInt_Check(v)) { - PyMem_DEL(PVbuffer); - PyErr_BadArgument(); - return NULL; - } - PVbuffer[i] = PyInt_AsLong(v); - } - - if ((*func)(device, PVbuffer, length) == -1) { - PyMem_DEL(PVbuffer); - return NULL; - } - - if (modified) { - for (i = 0; i < length; i++) - PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i])); - } - - PyMem_DEL(PVbuffer); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -al_getparams(PyObject *self, PyObject *args) -{ - return doParams(args, ALgetparams, 1); -} - -static PyObject * -al_setparams(PyObject *self, PyObject *args) -{ - return doParams(args, ALsetparams, 0); -} - -static PyObject * -al_getname(PyObject *self, PyObject *args) -{ - long device, descriptor; - char *name; - - if (!PyArg_ParseTuple(args, "ll:getname", &device, &descriptor)) - return NULL; - if ((name = ALgetname(device, descriptor)) == NULL) - return NULL; - return PyString_FromString(name); -} - -static PyObject * -al_getdefault(PyObject *self, PyObject *args) -{ - long device, descriptor, value; - - if (!PyArg_ParseTuple(args, "ll:getdefault", &device, &descriptor)) - return NULL; - if ((value = ALgetdefault(device, descriptor)) == -1) - return NULL; - return PyLong_FromLong(value); -} - -static PyObject * -al_getminmax(PyObject *self, PyObject *args) -{ - long device, descriptor, min, max; - - if (!PyArg_ParseTuple(args, "ll:getminmax", &device, &descriptor)) - return NULL; - min = -1; - max = -1; - if (ALgetminmax(device, descriptor, &min, &max) == -1) - return NULL; - return Py_BuildValue("ll", min, max); -} - -#endif /* OLD_INTERFACE */ - -/* List of methods defined in the module */ - -static struct PyMethodDef al_methods[] = { -#ifdef AL_NO_ELEM /* IRIX 6 */ - {"NewConfig", (PyCFunction)al_NewConfig, METH_VARARGS, al_NewConfig__doc__}, - {"OpenPort", (PyCFunction)al_OpenPort, METH_VARARGS, al_OpenPort__doc__}, - {"Connect", (PyCFunction)al_Connect, METH_VARARGS, al_Connect__doc__}, - {"Disconnect", (PyCFunction)al_Disconnect, METH_VARARGS, al_Disconnect__doc__}, - {"GetParams", (PyCFunction)al_GetParams, METH_VARARGS, al_GetParams__doc__}, - {"SetParams", (PyCFunction)al_SetParams, METH_VARARGS, al_SetParams__doc__}, - {"QueryValues", (PyCFunction)al_QueryValues, METH_VARARGS, al_QueryValues__doc__}, - {"GetParamInfo", (PyCFunction)al_GetParamInfo, METH_VARARGS, al_GetParamInfo__doc__}, - {"GetResourceByName", (PyCFunction)al_GetResourceByName, METH_VARARGS, al_GetResourceByName__doc__}, - {"IsSubtype", (PyCFunction)al_IsSubtype, METH_VARARGS, al_IsSubtype__doc__}, -#if 0 - /* this one not supported */ - {"SetErrorHandler", (PyCFunction)al_SetErrorHandler, METH_VARARGS, al_SetErrorHandler__doc__}, -#endif -#endif /* AL_NO_ELEM */ -#ifdef OLD_INTERFACE - {"openport", (PyCFunction)al_openport, METH_VARARGS}, - {"newconfig", (PyCFunction)al_newconfig, METH_VARARGS}, - {"queryparams", (PyCFunction)al_queryparams, METH_VARARGS}, - {"getparams", (PyCFunction)al_getparams, METH_VARARGS}, - {"setparams", (PyCFunction)al_setparams, METH_VARARGS}, - {"getname", (PyCFunction)al_getname, METH_VARARGS}, - {"getdefault", (PyCFunction)al_getdefault, METH_VARARGS}, - {"getminmax", (PyCFunction)al_getminmax, METH_VARARGS}, -#endif /* OLD_INTERFACE */ - - {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */ -}; - - -/* Initialization function for the module (*must* be called inital) */ - -PyDoc_STRVAR(al_module_documentation, ""); - -void -inital(void) -{ - PyObject *m, *d, *x; - - /* Create the module and add the functions */ - m = Py_InitModule4("al", al_methods, - al_module_documentation, - (PyObject*)NULL,PYTHON_API_VERSION); - - /* Add some symbolic constants to the module */ - d = PyModule_GetDict(m); - ErrorObject = PyErr_NewException("al.error", NULL, NULL); - PyDict_SetItemString(d, "error", ErrorObject); - - /* XXXX Add constants here */ -#ifdef AL_4CHANNEL - x = PyInt_FromLong((long) AL_4CHANNEL); - if (x == NULL || PyDict_SetItemString(d, "FOURCHANNEL", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_ADAT_IF_TYPE - x = PyInt_FromLong((long) AL_ADAT_IF_TYPE); - if (x == NULL || PyDict_SetItemString(d, "ADAT_IF_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_ADAT_MCLK_TYPE - x = PyInt_FromLong((long) AL_ADAT_MCLK_TYPE); - if (x == NULL || PyDict_SetItemString(d, "ADAT_MCLK_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_AES_IF_TYPE - x = PyInt_FromLong((long) AL_AES_IF_TYPE); - if (x == NULL || PyDict_SetItemString(d, "AES_IF_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_AES_MCLK_TYPE - x = PyInt_FromLong((long) AL_AES_MCLK_TYPE); - if (x == NULL || PyDict_SetItemString(d, "AES_MCLK_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_ANALOG_IF_TYPE - x = PyInt_FromLong((long) AL_ANALOG_IF_TYPE); - if (x == NULL || PyDict_SetItemString(d, "ANALOG_IF_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_ASSOCIATE - x = PyInt_FromLong((long) AL_ASSOCIATE); - if (x == NULL || PyDict_SetItemString(d, "ASSOCIATE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_BUFFER_NULL - x = PyInt_FromLong((long) AL_BAD_BUFFER_NULL); - if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFER_NULL", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_BUFFERLENGTH - x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH); - if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_BUFFERLENGTH_NEG - x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH_NEG); - if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_NEG", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_BUFFERLENGTH_ODD - x = PyInt_FromLong((long) AL_BAD_BUFFERLENGTH_ODD); - if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_ODD", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_CHANNELS - x = PyInt_FromLong((long) AL_BAD_CHANNELS); - if (x == NULL || PyDict_SetItemString(d, "BAD_CHANNELS", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_CONFIG - x = PyInt_FromLong((long) AL_BAD_CONFIG); - if (x == NULL || PyDict_SetItemString(d, "BAD_CONFIG", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_COUNT_NEG - x = PyInt_FromLong((long) AL_BAD_COUNT_NEG); - if (x == NULL || PyDict_SetItemString(d, "BAD_COUNT_NEG", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_DEVICE - x = PyInt_FromLong((long) AL_BAD_DEVICE); - if (x == NULL || PyDict_SetItemString(d, "BAD_DEVICE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_DEVICE_ACCESS - x = PyInt_FromLong((long) AL_BAD_DEVICE_ACCESS); - if (x == NULL || PyDict_SetItemString(d, "BAD_DEVICE_ACCESS", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_DIRECTION - x = PyInt_FromLong((long) AL_BAD_DIRECTION); - if (x == NULL || PyDict_SetItemString(d, "BAD_DIRECTION", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_FILLPOINT - x = PyInt_FromLong((long) AL_BAD_FILLPOINT); - if (x == NULL || PyDict_SetItemString(d, "BAD_FILLPOINT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_FLOATMAX - x = PyInt_FromLong((long) AL_BAD_FLOATMAX); - if (x == NULL || PyDict_SetItemString(d, "BAD_FLOATMAX", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_ILLEGAL_STATE - x = PyInt_FromLong((long) AL_BAD_ILLEGAL_STATE); - if (x == NULL || PyDict_SetItemString(d, "BAD_ILLEGAL_STATE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_NO_PORTS - x = PyInt_FromLong((long) AL_BAD_NO_PORTS); - if (x == NULL || PyDict_SetItemString(d, "BAD_NO_PORTS", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_NOT_FOUND - x = PyInt_FromLong((long) AL_BAD_NOT_FOUND); - if (x == NULL || PyDict_SetItemString(d, "BAD_NOT_FOUND", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_NOT_IMPLEMENTED - x = PyInt_FromLong((long) AL_BAD_NOT_IMPLEMENTED); - if (x == NULL || PyDict_SetItemString(d, "BAD_NOT_IMPLEMENTED", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_OUT_OF_MEM - x = PyInt_FromLong((long) AL_BAD_OUT_OF_MEM); - if (x == NULL || PyDict_SetItemString(d, "BAD_OUT_OF_MEM", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_PARAM - x = PyInt_FromLong((long) AL_BAD_PARAM); - if (x == NULL || PyDict_SetItemString(d, "BAD_PARAM", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_PERMISSIONS - x = PyInt_FromLong((long) AL_BAD_PERMISSIONS); - if (x == NULL || PyDict_SetItemString(d, "BAD_PERMISSIONS", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_PORT - x = PyInt_FromLong((long) AL_BAD_PORT); - if (x == NULL || PyDict_SetItemString(d, "BAD_PORT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_PORTSTYLE - x = PyInt_FromLong((long) AL_BAD_PORTSTYLE); - if (x == NULL || PyDict_SetItemString(d, "BAD_PORTSTYLE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_PVBUFFER - x = PyInt_FromLong((long) AL_BAD_PVBUFFER); - if (x == NULL || PyDict_SetItemString(d, "BAD_PVBUFFER", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_QSIZE - x = PyInt_FromLong((long) AL_BAD_QSIZE); - if (x == NULL || PyDict_SetItemString(d, "BAD_QSIZE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_RATE - x = PyInt_FromLong((long) AL_BAD_RATE); - if (x == NULL || PyDict_SetItemString(d, "BAD_RATE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_RESOURCE - x = PyInt_FromLong((long) AL_BAD_RESOURCE); - if (x == NULL || PyDict_SetItemString(d, "BAD_RESOURCE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_SAMPFMT - x = PyInt_FromLong((long) AL_BAD_SAMPFMT); - if (x == NULL || PyDict_SetItemString(d, "BAD_SAMPFMT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_TRANSFER_SIZE - x = PyInt_FromLong((long) AL_BAD_TRANSFER_SIZE); - if (x == NULL || PyDict_SetItemString(d, "BAD_TRANSFER_SIZE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_BAD_WIDTH - x = PyInt_FromLong((long) AL_BAD_WIDTH); - if (x == NULL || PyDict_SetItemString(d, "BAD_WIDTH", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_CHANNEL_MODE - x = PyInt_FromLong((long) AL_CHANNEL_MODE); - if (x == NULL || PyDict_SetItemString(d, "CHANNEL_MODE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_CHANNELS - x = PyInt_FromLong((long) AL_CHANNELS); - if (x == NULL || PyDict_SetItemString(d, "CHANNELS", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_CHAR_ELEM - x = PyInt_FromLong((long) AL_CHAR_ELEM); - if (x == NULL || PyDict_SetItemString(d, "CHAR_ELEM", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_CLOCK_GEN - x = PyInt_FromLong((long) AL_CLOCK_GEN); - if (x == NULL || PyDict_SetItemString(d, "CLOCK_GEN", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_CLOCKGEN_TYPE - x = PyInt_FromLong((long) AL_CLOCKGEN_TYPE); - if (x == NULL || PyDict_SetItemString(d, "CLOCKGEN_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_CONNECT - x = PyInt_FromLong((long) AL_CONNECT); - if (x == NULL || PyDict_SetItemString(d, "CONNECT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_CONNECTION_TYPE - x = PyInt_FromLong((long) AL_CONNECTION_TYPE); - if (x == NULL || PyDict_SetItemString(d, "CONNECTION_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_CONNECTIONS - x = PyInt_FromLong((long) AL_CONNECTIONS); - if (x == NULL || PyDict_SetItemString(d, "CONNECTIONS", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_CRYSTAL_MCLK_TYPE - x = PyInt_FromLong((long) AL_CRYSTAL_MCLK_TYPE); - if (x == NULL || PyDict_SetItemString(d, "CRYSTAL_MCLK_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_DEFAULT_DEVICE - x = PyInt_FromLong((long) AL_DEFAULT_DEVICE); - if (x == NULL || PyDict_SetItemString(d, "DEFAULT_DEVICE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_DEFAULT_INPUT - x = PyInt_FromLong((long) AL_DEFAULT_INPUT); - if (x == NULL || PyDict_SetItemString(d, "DEFAULT_INPUT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_DEFAULT_OUTPUT - x = PyInt_FromLong((long) AL_DEFAULT_OUTPUT); - if (x == NULL || PyDict_SetItemString(d, "DEFAULT_OUTPUT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_DEST - x = PyInt_FromLong((long) AL_DEST); - if (x == NULL || PyDict_SetItemString(d, "DEST", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_DEVICE_TYPE - x = PyInt_FromLong((long) AL_DEVICE_TYPE); - if (x == NULL || PyDict_SetItemString(d, "DEVICE_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_DEVICES - x = PyInt_FromLong((long) AL_DEVICES); - if (x == NULL || PyDict_SetItemString(d, "DEVICES", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_DIGITAL_IF_TYPE - x = PyInt_FromLong((long) AL_DIGITAL_IF_TYPE); - if (x == NULL || PyDict_SetItemString(d, "DIGITAL_IF_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_DIGITAL_INPUT_RATE - x = PyInt_FromLong((long) AL_DIGITAL_INPUT_RATE); - if (x == NULL || PyDict_SetItemString(d, "DIGITAL_INPUT_RATE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_DISCONNECT - x = PyInt_FromLong((long) AL_DISCONNECT); - if (x == NULL || PyDict_SetItemString(d, "DISCONNECT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_ENUM_ELEM - x = PyInt_FromLong((long) AL_ENUM_ELEM); - if (x == NULL || PyDict_SetItemString(d, "ENUM_ELEM", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_ENUM_VALUE - x = PyInt_FromLong((long) AL_ENUM_VALUE); - if (x == NULL || PyDict_SetItemString(d, "ENUM_VALUE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_ERROR_INPUT_OVERFLOW - x = PyInt_FromLong((long) AL_ERROR_INPUT_OVERFLOW); - if (x == NULL || PyDict_SetItemString(d, "ERROR_INPUT_OVERFLOW", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_ERROR_LENGTH - x = PyInt_FromLong((long) AL_ERROR_LENGTH); - if (x == NULL || PyDict_SetItemString(d, "ERROR_LENGTH", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_ERROR_LOCATION_LSP - x = PyInt_FromLong((long) AL_ERROR_LOCATION_LSP); - if (x == NULL || PyDict_SetItemString(d, "ERROR_LOCATION_LSP", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_ERROR_LOCATION_MSP - x = PyInt_FromLong((long) AL_ERROR_LOCATION_MSP); - if (x == NULL || PyDict_SetItemString(d, "ERROR_LOCATION_MSP", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_ERROR_NUMBER - x = PyInt_FromLong((long) AL_ERROR_NUMBER); - if (x == NULL || PyDict_SetItemString(d, "ERROR_NUMBER", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_ERROR_OUTPUT_UNDERFLOW - x = PyInt_FromLong((long) AL_ERROR_OUTPUT_UNDERFLOW); - if (x == NULL || PyDict_SetItemString(d, "ERROR_OUTPUT_UNDERFLOW", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_ERROR_TYPE - x = PyInt_FromLong((long) AL_ERROR_TYPE); - if (x == NULL || PyDict_SetItemString(d, "ERROR_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_FIXED_ELEM - x = PyInt_FromLong((long) AL_FIXED_ELEM); - if (x == NULL || PyDict_SetItemString(d, "FIXED_ELEM", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_FIXED_MCLK_TYPE - x = PyInt_FromLong((long) AL_FIXED_MCLK_TYPE); - if (x == NULL || PyDict_SetItemString(d, "FIXED_MCLK_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_GAIN - x = PyInt_FromLong((long) AL_GAIN); - if (x == NULL || PyDict_SetItemString(d, "GAIN", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_GAIN_REF - x = PyInt_FromLong((long) AL_GAIN_REF); - if (x == NULL || PyDict_SetItemString(d, "GAIN_REF", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_HRB_TYPE - x = PyInt_FromLong((long) AL_HRB_TYPE); - if (x == NULL || PyDict_SetItemString(d, "HRB_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INPUT_COUNT - x = PyInt_FromLong((long) AL_INPUT_COUNT); - if (x == NULL || PyDict_SetItemString(d, "INPUT_COUNT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INPUT_DEVICE_TYPE - x = PyInt_FromLong((long) AL_INPUT_DEVICE_TYPE); - if (x == NULL || PyDict_SetItemString(d, "INPUT_DEVICE_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INPUT_DIGITAL - x = PyInt_FromLong((long) AL_INPUT_DIGITAL); - if (x == NULL || PyDict_SetItemString(d, "INPUT_DIGITAL", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INPUT_HRB_TYPE - x = PyInt_FromLong((long) AL_INPUT_HRB_TYPE); - if (x == NULL || PyDict_SetItemString(d, "INPUT_HRB_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INPUT_LINE - x = PyInt_FromLong((long) AL_INPUT_LINE); - if (x == NULL || PyDict_SetItemString(d, "INPUT_LINE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INPUT_MIC - x = PyInt_FromLong((long) AL_INPUT_MIC); - if (x == NULL || PyDict_SetItemString(d, "INPUT_MIC", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INPUT_PORT_TYPE - x = PyInt_FromLong((long) AL_INPUT_PORT_TYPE); - if (x == NULL || PyDict_SetItemString(d, "INPUT_PORT_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INPUT_RATE - x = PyInt_FromLong((long) AL_INPUT_RATE); - if (x == NULL || PyDict_SetItemString(d, "INPUT_RATE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INPUT_SOURCE - x = PyInt_FromLong((long) AL_INPUT_SOURCE); - if (x == NULL || PyDict_SetItemString(d, "INPUT_SOURCE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INT32_ELEM - x = PyInt_FromLong((long) AL_INT32_ELEM); - if (x == NULL || PyDict_SetItemString(d, "INT32_ELEM", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INT64_ELEM - x = PyInt_FromLong((long) AL_INT64_ELEM); - if (x == NULL || PyDict_SetItemString(d, "INT64_ELEM", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INTERFACE - x = PyInt_FromLong((long) AL_INTERFACE); - if (x == NULL || PyDict_SetItemString(d, "INTERFACE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INTERFACE_TYPE - x = PyInt_FromLong((long) AL_INTERFACE_TYPE); - if (x == NULL || PyDict_SetItemString(d, "INTERFACE_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INVALID_PARAM - x = PyInt_FromLong((long) AL_INVALID_PARAM); - if (x == NULL || PyDict_SetItemString(d, "INVALID_PARAM", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_INVALID_VALUE - x = PyInt_FromLong((long) AL_INVALID_VALUE); - if (x == NULL || PyDict_SetItemString(d, "INVALID_VALUE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_JITTER - x = PyInt_FromLong((long) AL_JITTER); - if (x == NULL || PyDict_SetItemString(d, "JITTER", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_LABEL - x = PyInt_FromLong((long) AL_LABEL); - if (x == NULL || PyDict_SetItemString(d, "LABEL", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_LEFT_INPUT_ATTEN - x = PyInt_FromLong((long) AL_LEFT_INPUT_ATTEN); - if (x == NULL || PyDict_SetItemString(d, "LEFT_INPUT_ATTEN", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_LEFT_MONITOR_ATTEN - x = PyInt_FromLong((long) AL_LEFT_MONITOR_ATTEN); - if (x == NULL || PyDict_SetItemString(d, "LEFT_MONITOR_ATTEN", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_LEFT_SPEAKER_GAIN - x = PyInt_FromLong((long) AL_LEFT_SPEAKER_GAIN); - if (x == NULL || PyDict_SetItemString(d, "LEFT_SPEAKER_GAIN", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_LEFT1_INPUT_ATTEN - x = PyInt_FromLong((long) AL_LEFT1_INPUT_ATTEN); - if (x == NULL || PyDict_SetItemString(d, "LEFT1_INPUT_ATTEN", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_LEFT2_INPUT_ATTEN - x = PyInt_FromLong((long) AL_LEFT2_INPUT_ATTEN); - if (x == NULL || PyDict_SetItemString(d, "LEFT2_INPUT_ATTEN", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_LINE_IF_TYPE - x = PyInt_FromLong((long) AL_LINE_IF_TYPE); - if (x == NULL || PyDict_SetItemString(d, "LINE_IF_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_LOCKED - x = PyInt_FromLong((long) AL_LOCKED); - if (x == NULL || PyDict_SetItemString(d, "LOCKED", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MASTER_CLOCK - x = PyInt_FromLong((long) AL_MASTER_CLOCK); - if (x == NULL || PyDict_SetItemString(d, "MASTER_CLOCK", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MATRIX_VAL - x = PyInt_FromLong((long) AL_MATRIX_VAL); - if (x == NULL || PyDict_SetItemString(d, "MATRIX_VAL", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MAX_ERROR - x = PyInt_FromLong((long) AL_MAX_ERROR); - if (x == NULL || PyDict_SetItemString(d, "MAX_ERROR", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MAX_EVENT_PARAM - x = PyInt_FromLong((long) AL_MAX_EVENT_PARAM); - if (x == NULL || PyDict_SetItemString(d, "MAX_EVENT_PARAM", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MAX_PBUFSIZE - x = PyInt_FromLong((long) AL_MAX_PBUFSIZE); - if (x == NULL || PyDict_SetItemString(d, "MAX_PBUFSIZE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MAX_PORTS - x = PyInt_FromLong((long) AL_MAX_PORTS); - if (x == NULL || PyDict_SetItemString(d, "MAX_PORTS", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MAX_RESOURCE_ID - x = PyInt_FromLong((long) AL_MAX_RESOURCE_ID); - if (x == NULL || PyDict_SetItemString(d, "MAX_RESOURCE_ID", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MAX_SETSIZE - x = PyInt_FromLong((long) AL_MAX_SETSIZE); - if (x == NULL || PyDict_SetItemString(d, "MAX_SETSIZE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MAX_STRLEN - x = PyInt_FromLong((long) AL_MAX_STRLEN); - if (x == NULL || PyDict_SetItemString(d, "MAX_STRLEN", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MCLK_TYPE - x = PyInt_FromLong((long) AL_MCLK_TYPE); - if (x == NULL || PyDict_SetItemString(d, "MCLK_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MIC_IF_TYPE - x = PyInt_FromLong((long) AL_MIC_IF_TYPE); - if (x == NULL || PyDict_SetItemString(d, "MIC_IF_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MONITOR_CTL - x = PyInt_FromLong((long) AL_MONITOR_CTL); - if (x == NULL || PyDict_SetItemString(d, "MONITOR_CTL", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MONITOR_OFF - x = PyInt_FromLong((long) AL_MONITOR_OFF); - if (x == NULL || PyDict_SetItemString(d, "MONITOR_OFF", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MONITOR_ON - x = PyInt_FromLong((long) AL_MONITOR_ON); - if (x == NULL || PyDict_SetItemString(d, "MONITOR_ON", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MONO - x = PyInt_FromLong((long) AL_MONO); - if (x == NULL || PyDict_SetItemString(d, "MONO", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_MUTE - x = PyInt_FromLong((long) AL_MUTE); - if (x == NULL || PyDict_SetItemString(d, "MUTE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_NAME - x = PyInt_FromLong((long) AL_NAME); - if (x == NULL || PyDict_SetItemString(d, "NAME", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_NEG_INFINITY - x = PyInt_FromLong((long) AL_NEG_INFINITY); - if (x == NULL || PyDict_SetItemString(d, "NEG_INFINITY", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_NEG_INFINITY_BIT - x = PyInt_FromLong((long) AL_NEG_INFINITY_BIT); - if (x == NULL || PyDict_SetItemString(d, "NEG_INFINITY_BIT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_NO_CHANGE - x = PyInt_FromLong((long) AL_NO_CHANGE); - if (x == NULL || PyDict_SetItemString(d, "NO_CHANGE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_NO_CHANGE_BIT - x = PyInt_FromLong((long) AL_NO_CHANGE_BIT); - if (x == NULL || PyDict_SetItemString(d, "NO_CHANGE_BIT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_NO_ELEM - x = PyInt_FromLong((long) AL_NO_ELEM); - if (x == NULL || PyDict_SetItemString(d, "NO_ELEM", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_NO_ERRORS - x = PyInt_FromLong((long) AL_NO_ERRORS); - if (x == NULL || PyDict_SetItemString(d, "NO_ERRORS", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_NO_OP - x = PyInt_FromLong((long) AL_NO_OP); - if (x == NULL || PyDict_SetItemString(d, "NO_OP", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_NO_VAL - x = PyInt_FromLong((long) AL_NO_VAL); - if (x == NULL || PyDict_SetItemString(d, "NO_VAL", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_NULL_INTERFACE - x = PyInt_FromLong((long) AL_NULL_INTERFACE); - if (x == NULL || PyDict_SetItemString(d, "NULL_INTERFACE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_NULL_RESOURCE - x = PyInt_FromLong((long) AL_NULL_RESOURCE); - if (x == NULL || PyDict_SetItemString(d, "NULL_RESOURCE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_OPTICAL_IF_TYPE - x = PyInt_FromLong((long) AL_OPTICAL_IF_TYPE); - if (x == NULL || PyDict_SetItemString(d, "OPTICAL_IF_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_OUTPUT_COUNT - x = PyInt_FromLong((long) AL_OUTPUT_COUNT); - if (x == NULL || PyDict_SetItemString(d, "OUTPUT_COUNT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_OUTPUT_DEVICE_TYPE - x = PyInt_FromLong((long) AL_OUTPUT_DEVICE_TYPE); - if (x == NULL || PyDict_SetItemString(d, "OUTPUT_DEVICE_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_OUTPUT_HRB_TYPE - x = PyInt_FromLong((long) AL_OUTPUT_HRB_TYPE); - if (x == NULL || PyDict_SetItemString(d, "OUTPUT_HRB_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_OUTPUT_PORT_TYPE - x = PyInt_FromLong((long) AL_OUTPUT_PORT_TYPE); - if (x == NULL || PyDict_SetItemString(d, "OUTPUT_PORT_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_OUTPUT_RATE - x = PyInt_FromLong((long) AL_OUTPUT_RATE); - if (x == NULL || PyDict_SetItemString(d, "OUTPUT_RATE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_PARAM_BIT - x = PyInt_FromLong((long) AL_PARAM_BIT); - if (x == NULL || PyDict_SetItemString(d, "PARAM_BIT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_PARAMS - x = PyInt_FromLong((long) AL_PARAMS); - if (x == NULL || PyDict_SetItemString(d, "PARAMS", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_PORT_COUNT - x = PyInt_FromLong((long) AL_PORT_COUNT); - if (x == NULL || PyDict_SetItemString(d, "PORT_COUNT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_PORT_TYPE - x = PyInt_FromLong((long) AL_PORT_TYPE); - if (x == NULL || PyDict_SetItemString(d, "PORT_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_PORTS - x = PyInt_FromLong((long) AL_PORTS); - if (x == NULL || PyDict_SetItemString(d, "PORTS", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_PORTSTYLE_DIRECT - x = PyInt_FromLong((long) AL_PORTSTYLE_DIRECT); - if (x == NULL || PyDict_SetItemString(d, "PORTSTYLE_DIRECT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_PORTSTYLE_SERIAL - x = PyInt_FromLong((long) AL_PORTSTYLE_SERIAL); - if (x == NULL || PyDict_SetItemString(d, "PORTSTYLE_SERIAL", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_PRINT_ERRORS - x = PyInt_FromLong((long) AL_PRINT_ERRORS); - if (x == NULL || PyDict_SetItemString(d, "PRINT_ERRORS", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_PTR_ELEM - x = PyInt_FromLong((long) AL_PTR_ELEM); - if (x == NULL || PyDict_SetItemString(d, "PTR_ELEM", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RANGE_VALUE - x = PyInt_FromLong((long) AL_RANGE_VALUE); - if (x == NULL || PyDict_SetItemString(d, "RANGE_VALUE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE - x = PyInt_FromLong((long) AL_RATE); - if (x == NULL || PyDict_SetItemString(d, "RATE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_11025 - x = PyInt_FromLong((long) AL_RATE_11025); - if (x == NULL || PyDict_SetItemString(d, "RATE_11025", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_16000 - x = PyInt_FromLong((long) AL_RATE_16000); - if (x == NULL || PyDict_SetItemString(d, "RATE_16000", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_22050 - x = PyInt_FromLong((long) AL_RATE_22050); - if (x == NULL || PyDict_SetItemString(d, "RATE_22050", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_32000 - x = PyInt_FromLong((long) AL_RATE_32000); - if (x == NULL || PyDict_SetItemString(d, "RATE_32000", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_44100 - x = PyInt_FromLong((long) AL_RATE_44100); - if (x == NULL || PyDict_SetItemString(d, "RATE_44100", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_48000 - x = PyInt_FromLong((long) AL_RATE_48000); - if (x == NULL || PyDict_SetItemString(d, "RATE_48000", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_8000 - x = PyInt_FromLong((long) AL_RATE_8000); - if (x == NULL || PyDict_SetItemString(d, "RATE_8000", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_AES_1 - x = PyInt_FromLong((long) AL_RATE_AES_1); - if (x == NULL || PyDict_SetItemString(d, "RATE_AES_1", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_AES_1s - x = PyInt_FromLong((long) AL_RATE_AES_1s); - if (x == NULL || PyDict_SetItemString(d, "RATE_AES_1s", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_AES_2 - x = PyInt_FromLong((long) AL_RATE_AES_2); - if (x == NULL || PyDict_SetItemString(d, "RATE_AES_2", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_AES_3 - x = PyInt_FromLong((long) AL_RATE_AES_3); - if (x == NULL || PyDict_SetItemString(d, "RATE_AES_3", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_AES_4 - x = PyInt_FromLong((long) AL_RATE_AES_4); - if (x == NULL || PyDict_SetItemString(d, "RATE_AES_4", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_AES_6 - x = PyInt_FromLong((long) AL_RATE_AES_6); - if (x == NULL || PyDict_SetItemString(d, "RATE_AES_6", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_FRACTION_D - x = PyInt_FromLong((long) AL_RATE_FRACTION_D); - if (x == NULL || PyDict_SetItemString(d, "RATE_FRACTION_D", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_FRACTION_N - x = PyInt_FromLong((long) AL_RATE_FRACTION_N); - if (x == NULL || PyDict_SetItemString(d, "RATE_FRACTION_N", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_INPUTRATE - x = PyInt_FromLong((long) AL_RATE_INPUTRATE); - if (x == NULL || PyDict_SetItemString(d, "RATE_INPUTRATE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_NO_DIGITAL_INPUT - x = PyInt_FromLong((long) AL_RATE_NO_DIGITAL_INPUT); - if (x == NULL || PyDict_SetItemString(d, "RATE_NO_DIGITAL_INPUT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_UNACQUIRED - x = PyInt_FromLong((long) AL_RATE_UNACQUIRED); - if (x == NULL || PyDict_SetItemString(d, "RATE_UNACQUIRED", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RATE_UNDEFINED - x = PyInt_FromLong((long) AL_RATE_UNDEFINED); - if (x == NULL || PyDict_SetItemString(d, "RATE_UNDEFINED", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_REF_0DBV - x = PyInt_FromLong((long) AL_REF_0DBV); - if (x == NULL || PyDict_SetItemString(d, "REF_0DBV", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_REF_NONE - x = PyInt_FromLong((long) AL_REF_NONE); - if (x == NULL || PyDict_SetItemString(d, "REF_NONE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RESERVED1_TYPE - x = PyInt_FromLong((long) AL_RESERVED1_TYPE); - if (x == NULL || PyDict_SetItemString(d, "RESERVED1_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RESERVED2_TYPE - x = PyInt_FromLong((long) AL_RESERVED2_TYPE); - if (x == NULL || PyDict_SetItemString(d, "RESERVED2_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RESERVED3_TYPE - x = PyInt_FromLong((long) AL_RESERVED3_TYPE); - if (x == NULL || PyDict_SetItemString(d, "RESERVED3_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RESERVED4_TYPE - x = PyInt_FromLong((long) AL_RESERVED4_TYPE); - if (x == NULL || PyDict_SetItemString(d, "RESERVED4_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RESOURCE - x = PyInt_FromLong((long) AL_RESOURCE); - if (x == NULL || PyDict_SetItemString(d, "RESOURCE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RESOURCE_ELEM - x = PyInt_FromLong((long) AL_RESOURCE_ELEM); - if (x == NULL || PyDict_SetItemString(d, "RESOURCE_ELEM", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RESOURCE_TYPE - x = PyInt_FromLong((long) AL_RESOURCE_TYPE); - if (x == NULL || PyDict_SetItemString(d, "RESOURCE_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RIGHT_INPUT_ATTEN - x = PyInt_FromLong((long) AL_RIGHT_INPUT_ATTEN); - if (x == NULL || PyDict_SetItemString(d, "RIGHT_INPUT_ATTEN", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RIGHT_MONITOR_ATTEN - x = PyInt_FromLong((long) AL_RIGHT_MONITOR_ATTEN); - if (x == NULL || PyDict_SetItemString(d, "RIGHT_MONITOR_ATTEN", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RIGHT_SPEAKER_GAIN - x = PyInt_FromLong((long) AL_RIGHT_SPEAKER_GAIN); - if (x == NULL || PyDict_SetItemString(d, "RIGHT_SPEAKER_GAIN", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RIGHT1_INPUT_ATTEN - x = PyInt_FromLong((long) AL_RIGHT1_INPUT_ATTEN); - if (x == NULL || PyDict_SetItemString(d, "RIGHT1_INPUT_ATTEN", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_RIGHT2_INPUT_ATTEN - x = PyInt_FromLong((long) AL_RIGHT2_INPUT_ATTEN); - if (x == NULL || PyDict_SetItemString(d, "RIGHT2_INPUT_ATTEN", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SAMPFMT_DOUBLE - x = PyInt_FromLong((long) AL_SAMPFMT_DOUBLE); - if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_DOUBLE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SAMPFMT_FLOAT - x = PyInt_FromLong((long) AL_SAMPFMT_FLOAT); - if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_FLOAT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SAMPFMT_TWOSCOMP - x = PyInt_FromLong((long) AL_SAMPFMT_TWOSCOMP); - if (x == NULL || PyDict_SetItemString(d, "SAMPFMT_TWOSCOMP", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SAMPLE_16 - x = PyInt_FromLong((long) AL_SAMPLE_16); - if (x == NULL || PyDict_SetItemString(d, "SAMPLE_16", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SAMPLE_24 - x = PyInt_FromLong((long) AL_SAMPLE_24); - if (x == NULL || PyDict_SetItemString(d, "SAMPLE_24", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SAMPLE_8 - x = PyInt_FromLong((long) AL_SAMPLE_8); - if (x == NULL || PyDict_SetItemString(d, "SAMPLE_8", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SCALAR_VAL - x = PyInt_FromLong((long) AL_SCALAR_VAL); - if (x == NULL || PyDict_SetItemString(d, "SCALAR_VAL", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SET_VAL - x = PyInt_FromLong((long) AL_SET_VAL); - if (x == NULL || PyDict_SetItemString(d, "SET_VAL", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SHORT_NAME - x = PyInt_FromLong((long) AL_SHORT_NAME); - if (x == NULL || PyDict_SetItemString(d, "SHORT_NAME", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SMPTE272M_IF_TYPE - x = PyInt_FromLong((long) AL_SMPTE272M_IF_TYPE); - if (x == NULL || PyDict_SetItemString(d, "SMPTE272M_IF_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SOURCE - x = PyInt_FromLong((long) AL_SOURCE); - if (x == NULL || PyDict_SetItemString(d, "SOURCE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SPEAKER_IF_TYPE - x = PyInt_FromLong((long) AL_SPEAKER_IF_TYPE); - if (x == NULL || PyDict_SetItemString(d, "SPEAKER_IF_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SPEAKER_MUTE_CTL - x = PyInt_FromLong((long) AL_SPEAKER_MUTE_CTL); - if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_CTL", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SPEAKER_MUTE_OFF - x = PyInt_FromLong((long) AL_SPEAKER_MUTE_OFF); - if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_OFF", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SPEAKER_MUTE_ON - x = PyInt_FromLong((long) AL_SPEAKER_MUTE_ON); - if (x == NULL || PyDict_SetItemString(d, "SPEAKER_MUTE_ON", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SPEAKER_PLUS_LINE_IF_TYPE - x = PyInt_FromLong((long) AL_SPEAKER_PLUS_LINE_IF_TYPE); - if (x == NULL || PyDict_SetItemString(d, "SPEAKER_PLUS_LINE_IF_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_STEREO - x = PyInt_FromLong((long) AL_STEREO); - if (x == NULL || PyDict_SetItemString(d, "STEREO", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_STRING_VAL - x = PyInt_FromLong((long) AL_STRING_VAL); - if (x == NULL || PyDict_SetItemString(d, "STRING_VAL", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SUBSYSTEM - x = PyInt_FromLong((long) AL_SUBSYSTEM); - if (x == NULL || PyDict_SetItemString(d, "SUBSYSTEM", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SUBSYSTEM_TYPE - x = PyInt_FromLong((long) AL_SUBSYSTEM_TYPE); - if (x == NULL || PyDict_SetItemString(d, "SUBSYSTEM_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SYNC_INPUT_TO_AES - x = PyInt_FromLong((long) AL_SYNC_INPUT_TO_AES); - if (x == NULL || PyDict_SetItemString(d, "SYNC_INPUT_TO_AES", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SYNC_OUTPUT_TO_AES - x = PyInt_FromLong((long) AL_SYNC_OUTPUT_TO_AES); - if (x == NULL || PyDict_SetItemString(d, "SYNC_OUTPUT_TO_AES", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SYSTEM - x = PyInt_FromLong((long) AL_SYSTEM); - if (x == NULL || PyDict_SetItemString(d, "SYSTEM", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_SYSTEM_TYPE - x = PyInt_FromLong((long) AL_SYSTEM_TYPE); - if (x == NULL || PyDict_SetItemString(d, "SYSTEM_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_TEST_IF_TYPE - x = PyInt_FromLong((long) AL_TEST_IF_TYPE); - if (x == NULL || PyDict_SetItemString(d, "TEST_IF_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_TYPE - x = PyInt_FromLong((long) AL_TYPE); - if (x == NULL || PyDict_SetItemString(d, "TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_TYPE_BIT - x = PyInt_FromLong((long) AL_TYPE_BIT); - if (x == NULL || PyDict_SetItemString(d, "TYPE_BIT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_UNUSED_COUNT - x = PyInt_FromLong((long) AL_UNUSED_COUNT); - if (x == NULL || PyDict_SetItemString(d, "UNUSED_COUNT", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_UNUSED_PORTS - x = PyInt_FromLong((long) AL_UNUSED_PORTS); - if (x == NULL || PyDict_SetItemString(d, "UNUSED_PORTS", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_VARIABLE_MCLK_TYPE - x = PyInt_FromLong((long) AL_VARIABLE_MCLK_TYPE); - if (x == NULL || PyDict_SetItemString(d, "VARIABLE_MCLK_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_VECTOR_VAL - x = PyInt_FromLong((long) AL_VECTOR_VAL); - if (x == NULL || PyDict_SetItemString(d, "VECTOR_VAL", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_VIDEO_MCLK_TYPE - x = PyInt_FromLong((long) AL_VIDEO_MCLK_TYPE); - if (x == NULL || PyDict_SetItemString(d, "VIDEO_MCLK_TYPE", x) < 0) - goto error; - Py_DECREF(x); -#endif -#ifdef AL_WORDSIZE - x = PyInt_FromLong((long) AL_WORDSIZE); - if (x == NULL || PyDict_SetItemString(d, "WORDSIZE", x) < 0) - goto error; - Py_DECREF(x); -#endif - -#ifdef AL_NO_ELEM /* IRIX 6 */ - (void) alSetErrorHandler(ErrorHandler); -#endif /* AL_NO_ELEM */ -#ifdef OLD_INTERFACE - (void) ALseterrorhandler(ErrorHandler); -#endif /* OLD_INTERFACE */ - - error: - return; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/ar_beos b/SDKs/XPlatform/Cypython-2.3.3/Modules/ar_beos deleted file mode 100644 index 40a6b3da..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/ar_beos +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -# -# Truly fake ar, using a directory to store object files. -# -# Donn Cave, donn@oz.net - -usage='Usage: ar-fake cr libpython.dir obj.o ... - ar-fake d libpython.dir obj.o ... - ar-fake so libpython.dir libpython.so' - -case $# in -0|1|2) - echo "$usage" >&2 - exit 1 - ;; -esac - -command=$1 -library=$2 -shift 2 - -case $command in -cr) - if test -d $library - then : - else - mkdir $library - fi - if cp -p $* $library - then - # To force directory modify date, create or delete a file. - if test -e $library/.tch - then rm $library/.tch - else echo tch > $library/.tch - fi - exit 0 - fi - ;; -d) - if test -d $library - then - cd $library - rm -f $* - fi - ;; -so) - case $BE_HOST_CPU in - ppc) - # In case your libpython.a refers to any exotic libraries, - # mwld needs to know that here. The following hack makes - # a couple of assumptions about Modules/Makefile. If it - # doesn't work, you may as well add the necessary libraries - # here explicitly instead. - extralibs=$( - (cd Modules; make -f Makefile -n link) | - sed -n 's/.*\.so \(.*\) -o python.*/\1/p' - ) - mwld -xms -export pragma -nodup -o $1 $library/* $extralibs - ;; - x86) - ld -shared -soname $(basename $1) -o $1 $library/* - ;; - esac - status=$? - cd $(dirname $1) - ln -sf $PWD lib - exit $status - ;; -*) - echo "$usage" >&2 - exit 1 - ;; -esac diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/arraymodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/arraymodule.c deleted file mode 100644 index 8a96022e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/arraymodule.c +++ /dev/null @@ -1,2037 +0,0 @@ -/* Array object implementation */ - -/* An array is a uniform list -- all items have the same type. - The item type is restricted to simple C types like int or float */ - -#include "Python.h" - -#ifdef STDC_HEADERS -#include -#else /* !STDC_HEADERS */ -#ifndef DONT_HAVE_SYS_TYPES_H -#include /* For size_t */ -#endif /* DONT_HAVE_SYS_TYPES_H */ -#endif /* !STDC_HEADERS */ - -/* Shamelessy stolen from listobject.c */ -static int -roundupsize(int n) -{ - unsigned int nbits = 0; - unsigned int n2 = (unsigned int)n >> 5; - - /* Round up: - * If n < 256, to a multiple of 8. - * If n < 2048, to a multiple of 64. - * If n < 16384, to a multiple of 512. - * If n < 131072, to a multiple of 4096. - * If n < 1048576, to a multiple of 32768. - * If n < 8388608, to a multiple of 262144. - * If n < 67108864, to a multiple of 2097152. - * If n < 536870912, to a multiple of 16777216. - * ... - * If n < 2**(5+3*i), to a multiple of 2**(3*i). - * - * This over-allocates proportional to the list size, making room - * for additional growth. The over-allocation is mild, but is - * enough to give linear-time amortized behavior over a long - * sequence of appends() in the presence of a poorly-performing - * system realloc() (which is a reality, e.g., across all flavors - * of Windows, with Win9x behavior being particularly bad -- and - * we've still got address space fragmentation problems on Win9x - * even with this scheme, although it requires much longer lists to - * provoke them than it used to). - */ - do { - n2 >>= 3; - nbits += 3; - } while (n2); - return ((n >> nbits) + 1) << nbits; - } - -#define NRESIZE(var, type, nitems) \ -do { \ - size_t _new_size = roundupsize(nitems); \ - if (_new_size <= ((~(size_t)0) / sizeof(type))) \ - PyMem_RESIZE(var, type, _new_size); \ - else \ - var = NULL; \ -} while (0) -/* END SHAMELESSLY STOLEN CODE */ - -struct arrayobject; /* Forward */ - -/* All possible arraydescr values are defined in the vector "descriptors" - * below. That's defined later because the appropriate get and set - * functions aren't visible yet. - */ -struct arraydescr { - int typecode; - int itemsize; - PyObject * (*getitem)(struct arrayobject *, int); - int (*setitem)(struct arrayobject *, int, PyObject *); -}; - -typedef struct arrayobject { - PyObject_HEAD - int ob_size; - char *ob_item; - struct arraydescr *ob_descr; -} arrayobject; - -static PyTypeObject Arraytype; - -#define array_Check(op) PyObject_TypeCheck(op, &Arraytype) -#define array_CheckExact(op) ((op)->ob_type == &Arraytype) - -/**************************************************************************** -Get and Set functions for each type. -A Get function takes an arrayobject* and an integer index, returning the -array value at that index wrapped in an appropriate PyObject*. -A Set function takes an arrayobject, integer index, and PyObject*; sets -the array value at that index to the raw C data extracted from the PyObject*, -and returns 0 if successful, else nonzero on failure (PyObject* not of an -appropriate type or value). -Note that the basic Get and Set functions do NOT check that the index is -in bounds; that's the responsibility of the caller. -****************************************************************************/ - -static PyObject * -c_getitem(arrayobject *ap, int i) -{ - return PyString_FromStringAndSize(&((char *)ap->ob_item)[i], 1); -} - -static int -c_setitem(arrayobject *ap, int i, PyObject *v) -{ - char x; - if (!PyArg_Parse(v, "c;array item must be char", &x)) - return -1; - if (i >= 0) - ((char *)ap->ob_item)[i] = x; - return 0; -} - -static PyObject * -b_getitem(arrayobject *ap, int i) -{ - long x = ((char *)ap->ob_item)[i]; - if (x >= 128) - x -= 256; - return PyInt_FromLong(x); -} - -static int -b_setitem(arrayobject *ap, int i, PyObject *v) -{ - short x; - /* PyArg_Parse's 'b' formatter is for an unsigned char, therefore - must use the next size up that is signed ('h') and manually do - the overflow checking */ - if (!PyArg_Parse(v, "h;array item must be integer", &x)) - return -1; - else if (x < -128) { - PyErr_SetString(PyExc_OverflowError, - "signed char is less than minimum"); - return -1; - } - else if (x > 127) { - PyErr_SetString(PyExc_OverflowError, - "signed char is greater than maximum"); - return -1; - } - if (i >= 0) - ((char *)ap->ob_item)[i] = (char)x; - return 0; -} - -static PyObject * -BB_getitem(arrayobject *ap, int i) -{ - long x = ((unsigned char *)ap->ob_item)[i]; - return PyInt_FromLong(x); -} - -static int -BB_setitem(arrayobject *ap, int i, PyObject *v) -{ - unsigned char x; - /* 'B' == unsigned char, maps to PyArg_Parse's 'b' formatter */ - if (!PyArg_Parse(v, "b;array item must be integer", &x)) - return -1; - if (i >= 0) - ((char *)ap->ob_item)[i] = x; - return 0; -} - -#ifdef Py_USING_UNICODE -static PyObject * -u_getitem(arrayobject *ap, int i) -{ - return PyUnicode_FromUnicode(&((Py_UNICODE *) ap->ob_item)[i], 1); -} - -static int -u_setitem(arrayobject *ap, int i, PyObject *v) -{ - Py_UNICODE *p; - int len; - - if (!PyArg_Parse(v, "u#;array item must be unicode character", &p, &len)) - return -1; - if (len != 1) { - PyErr_SetString(PyExc_TypeError, "array item must be unicode character"); - return -1; - } - if (i >= 0) - ((Py_UNICODE *)ap->ob_item)[i] = p[0]; - return 0; -} -#endif - -static PyObject * -h_getitem(arrayobject *ap, int i) -{ - return PyInt_FromLong((long) ((short *)ap->ob_item)[i]); -} - -static int -h_setitem(arrayobject *ap, int i, PyObject *v) -{ - short x; - /* 'h' == signed short, maps to PyArg_Parse's 'h' formatter */ - if (!PyArg_Parse(v, "h;array item must be integer", &x)) - return -1; - if (i >= 0) - ((short *)ap->ob_item)[i] = x; - return 0; -} - -static PyObject * -HH_getitem(arrayobject *ap, int i) -{ - return PyInt_FromLong((long) ((unsigned short *)ap->ob_item)[i]); -} - -static int -HH_setitem(arrayobject *ap, int i, PyObject *v) -{ - int x; - /* PyArg_Parse's 'h' formatter is for a signed short, therefore - must use the next size up and manually do the overflow checking */ - if (!PyArg_Parse(v, "i;array item must be integer", &x)) - return -1; - else if (x < 0) { - PyErr_SetString(PyExc_OverflowError, - "unsigned short is less than minimum"); - return -1; - } - else if (x > USHRT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "unsigned short is greater than maximum"); - return -1; - } - if (i >= 0) - ((short *)ap->ob_item)[i] = (short)x; - return 0; -} - -static PyObject * -i_getitem(arrayobject *ap, int i) -{ - return PyInt_FromLong((long) ((int *)ap->ob_item)[i]); -} - -static int -i_setitem(arrayobject *ap, int i, PyObject *v) -{ - int x; - /* 'i' == signed int, maps to PyArg_Parse's 'i' formatter */ - if (!PyArg_Parse(v, "i;array item must be integer", &x)) - return -1; - if (i >= 0) - ((int *)ap->ob_item)[i] = x; - return 0; -} - -static PyObject * -II_getitem(arrayobject *ap, int i) -{ - return PyLong_FromUnsignedLong( - (unsigned long) ((unsigned int *)ap->ob_item)[i]); -} - -static int -II_setitem(arrayobject *ap, int i, PyObject *v) -{ - unsigned long x; - if (PyLong_Check(v)) { - x = PyLong_AsUnsignedLong(v); - if (x == (unsigned long) -1 && PyErr_Occurred()) - return -1; - } - else { - long y; - if (!PyArg_Parse(v, "l;array item must be integer", &y)) - return -1; - if (y < 0) { - PyErr_SetString(PyExc_OverflowError, - "unsigned int is less than minimum"); - return -1; - } - x = (unsigned long)y; - - } - if (x > UINT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "unsigned int is greater than maximum"); - return -1; - } - - if (i >= 0) - ((unsigned int *)ap->ob_item)[i] = (unsigned int)x; - return 0; -} - -static PyObject * -l_getitem(arrayobject *ap, int i) -{ - return PyInt_FromLong(((long *)ap->ob_item)[i]); -} - -static int -l_setitem(arrayobject *ap, int i, PyObject *v) -{ - long x; - if (!PyArg_Parse(v, "l;array item must be integer", &x)) - return -1; - if (i >= 0) - ((long *)ap->ob_item)[i] = x; - return 0; -} - -static PyObject * -LL_getitem(arrayobject *ap, int i) -{ - return PyLong_FromUnsignedLong(((unsigned long *)ap->ob_item)[i]); -} - -static int -LL_setitem(arrayobject *ap, int i, PyObject *v) -{ - unsigned long x; - if (PyLong_Check(v)) { - x = PyLong_AsUnsignedLong(v); - if (x == (unsigned long) -1 && PyErr_Occurred()) - return -1; - } - else { - long y; - if (!PyArg_Parse(v, "l;array item must be integer", &y)) - return -1; - if (y < 0) { - PyErr_SetString(PyExc_OverflowError, - "unsigned long is less than minimum"); - return -1; - } - x = (unsigned long)y; - - } - if (x > ULONG_MAX) { - PyErr_SetString(PyExc_OverflowError, - "unsigned long is greater than maximum"); - return -1; - } - - if (i >= 0) - ((unsigned long *)ap->ob_item)[i] = x; - return 0; -} - -static PyObject * -f_getitem(arrayobject *ap, int i) -{ - return PyFloat_FromDouble((double) ((float *)ap->ob_item)[i]); -} - -static int -f_setitem(arrayobject *ap, int i, PyObject *v) -{ - float x; - if (!PyArg_Parse(v, "f;array item must be float", &x)) - return -1; - if (i >= 0) - ((float *)ap->ob_item)[i] = x; - return 0; -} - -static PyObject * -d_getitem(arrayobject *ap, int i) -{ - return PyFloat_FromDouble(((double *)ap->ob_item)[i]); -} - -static int -d_setitem(arrayobject *ap, int i, PyObject *v) -{ - double x; - if (!PyArg_Parse(v, "d;array item must be float", &x)) - return -1; - if (i >= 0) - ((double *)ap->ob_item)[i] = x; - return 0; -} - -/* Description of types */ -static struct arraydescr descriptors[] = { - {'c', sizeof(char), c_getitem, c_setitem}, - {'b', sizeof(char), b_getitem, b_setitem}, - {'B', sizeof(char), BB_getitem, BB_setitem}, -#ifdef Py_USING_UNICODE - {'u', sizeof(Py_UNICODE), u_getitem, u_setitem}, -#endif - {'h', sizeof(short), h_getitem, h_setitem}, - {'H', sizeof(short), HH_getitem, HH_setitem}, - {'i', sizeof(int), i_getitem, i_setitem}, - {'I', sizeof(int), II_getitem, II_setitem}, - {'l', sizeof(long), l_getitem, l_setitem}, - {'L', sizeof(long), LL_getitem, LL_setitem}, - {'f', sizeof(float), f_getitem, f_setitem}, - {'d', sizeof(double), d_getitem, d_setitem}, - {'\0', 0, 0, 0} /* Sentinel */ -}; - -/**************************************************************************** -Implementations of array object methods. -****************************************************************************/ - -static PyObject * -newarrayobject(PyTypeObject *type, int size, struct arraydescr *descr) -{ - arrayobject *op; - size_t nbytes; - - if (size < 0) { - PyErr_BadInternalCall(); - return NULL; - } - - nbytes = size * descr->itemsize; - /* Check for overflow */ - if (nbytes / descr->itemsize != (size_t)size) { - return PyErr_NoMemory(); - } - op = (arrayobject *) type->tp_alloc(type, 0); - if (op == NULL) { - return NULL; - } - op->ob_size = size; - if (size <= 0) { - op->ob_item = NULL; - } - else { - op->ob_item = PyMem_NEW(char, nbytes); - if (op->ob_item == NULL) { - PyObject_Del(op); - return PyErr_NoMemory(); - } - } - op->ob_descr = descr; - return (PyObject *) op; -} - -static PyObject * -getarrayitem(PyObject *op, int i) -{ - register arrayobject *ap; - assert(array_Check(op)); - ap = (arrayobject *)op; - assert(i>=0 && iob_size); - return (*ap->ob_descr->getitem)(ap, i); -} - -static int -ins1(arrayobject *self, int where, PyObject *v) -{ - char *items; - if (v == NULL) { - PyErr_BadInternalCall(); - return -1; - } - if ((*self->ob_descr->setitem)(self, -1, v) < 0) - return -1; - items = self->ob_item; - NRESIZE(items, char, (self->ob_size+1) * self->ob_descr->itemsize); - if (items == NULL) { - PyErr_NoMemory(); - return -1; - } - if (where < 0) { - where += self->ob_size; - if (where < 0) - where = 0; - } - if (where > self->ob_size) - where = self->ob_size; - memmove(items + (where+1)*self->ob_descr->itemsize, - items + where*self->ob_descr->itemsize, - (self->ob_size-where)*self->ob_descr->itemsize); - self->ob_item = items; - self->ob_size++; - return (*self->ob_descr->setitem)(self, where, v); -} - -/* Methods */ - -static void -array_dealloc(arrayobject *op) -{ - if (op->ob_item != NULL) - PyMem_DEL(op->ob_item); - op->ob_type->tp_free((PyObject *)op); -} - -static PyObject * -array_richcompare(PyObject *v, PyObject *w, int op) -{ - arrayobject *va, *wa; - PyObject *vi = NULL; - PyObject *wi = NULL; - int i, k; - PyObject *res; - - if (!array_Check(v) || !array_Check(w)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - - va = (arrayobject *)v; - wa = (arrayobject *)w; - - if (va->ob_size != wa->ob_size && (op == Py_EQ || op == Py_NE)) { - /* Shortcut: if the lengths differ, the arrays differ */ - if (op == Py_EQ) - res = Py_False; - else - res = Py_True; - Py_INCREF(res); - return res; - } - - /* Search for the first index where items are different */ - k = 1; - for (i = 0; i < va->ob_size && i < wa->ob_size; i++) { - vi = getarrayitem(v, i); - wi = getarrayitem(w, i); - if (vi == NULL || wi == NULL) { - Py_XDECREF(vi); - Py_XDECREF(wi); - return NULL; - } - k = PyObject_RichCompareBool(vi, wi, Py_EQ); - if (k == 0) - break; /* Keeping vi and wi alive! */ - Py_DECREF(vi); - Py_DECREF(wi); - if (k < 0) - return NULL; - } - - if (k) { - /* No more items to compare -- compare sizes */ - int vs = va->ob_size; - int ws = wa->ob_size; - int cmp; - switch (op) { - case Py_LT: cmp = vs < ws; break; - case Py_LE: cmp = vs <= ws; break; - case Py_EQ: cmp = vs == ws; break; - case Py_NE: cmp = vs != ws; break; - case Py_GT: cmp = vs > ws; break; - case Py_GE: cmp = vs >= ws; break; - default: return NULL; /* cannot happen */ - } - if (cmp) - res = Py_True; - else - res = Py_False; - Py_INCREF(res); - return res; - } - - /* We have an item that differs. First, shortcuts for EQ/NE */ - if (op == Py_EQ) { - Py_INCREF(Py_False); - res = Py_False; - } - else if (op == Py_NE) { - Py_INCREF(Py_True); - res = Py_True; - } - else { - /* Compare the final item again using the proper operator */ - res = PyObject_RichCompare(vi, wi, op); - } - Py_DECREF(vi); - Py_DECREF(wi); - return res; -} - -static int -array_length(arrayobject *a) -{ - return a->ob_size; -} - -static PyObject * -array_item(arrayobject *a, int i) -{ - if (i < 0 || i >= a->ob_size) { - PyErr_SetString(PyExc_IndexError, "array index out of range"); - return NULL; - } - return getarrayitem((PyObject *)a, i); -} - -static PyObject * -array_slice(arrayobject *a, int ilow, int ihigh) -{ - arrayobject *np; - if (ilow < 0) - ilow = 0; - else if (ilow > a->ob_size) - ilow = a->ob_size; - if (ihigh < 0) - ihigh = 0; - if (ihigh < ilow) - ihigh = ilow; - else if (ihigh > a->ob_size) - ihigh = a->ob_size; - np = (arrayobject *) newarrayobject(&Arraytype, ihigh - ilow, a->ob_descr); - if (np == NULL) - return NULL; - memcpy(np->ob_item, a->ob_item + ilow * a->ob_descr->itemsize, - (ihigh-ilow) * a->ob_descr->itemsize); - return (PyObject *)np; -} - -static PyObject * -array_concat(arrayobject *a, PyObject *bb) -{ - int size; - arrayobject *np; - if (!array_Check(bb)) { - PyErr_Format(PyExc_TypeError, - "can only append array (not \"%.200s\") to array", - bb->ob_type->tp_name); - return NULL; - } -#define b ((arrayobject *)bb) - if (a->ob_descr != b->ob_descr) { - PyErr_BadArgument(); - return NULL; - } - size = a->ob_size + b->ob_size; - np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr); - if (np == NULL) { - return NULL; - } - memcpy(np->ob_item, a->ob_item, a->ob_size*a->ob_descr->itemsize); - memcpy(np->ob_item + a->ob_size*a->ob_descr->itemsize, - b->ob_item, b->ob_size*b->ob_descr->itemsize); - return (PyObject *)np; -#undef b -} - -static PyObject * -array_repeat(arrayobject *a, int n) -{ - int i; - int size; - arrayobject *np; - char *p; - int nbytes; - if (n < 0) - n = 0; - size = a->ob_size * n; - np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr); - if (np == NULL) - return NULL; - p = np->ob_item; - nbytes = a->ob_size * a->ob_descr->itemsize; - for (i = 0; i < n; i++) { - memcpy(p, a->ob_item, nbytes); - p += nbytes; - } - return (PyObject *) np; -} - -static int -array_ass_slice(arrayobject *a, int ilow, int ihigh, PyObject *v) -{ - char *item; - int n; /* Size of replacement array */ - int d; /* Change in size */ -#define b ((arrayobject *)v) - if (v == NULL) - n = 0; - else if (array_Check(v)) { - n = b->ob_size; - if (a == b) { - /* Special case "a[i:j] = a" -- copy b first */ - int ret; - v = array_slice(b, 0, n); - ret = array_ass_slice(a, ilow, ihigh, v); - Py_DECREF(v); - return ret; - } - if (b->ob_descr != a->ob_descr) { - PyErr_BadArgument(); - return -1; - } - } - else { - PyErr_Format(PyExc_TypeError, - "can only assign array (not \"%.200s\") to array slice", - v->ob_type->tp_name); - return -1; - } - if (ilow < 0) - ilow = 0; - else if (ilow > a->ob_size) - ilow = a->ob_size; - if (ihigh < 0) - ihigh = 0; - if (ihigh < ilow) - ihigh = ilow; - else if (ihigh > a->ob_size) - ihigh = a->ob_size; - item = a->ob_item; - d = n - (ihigh-ilow); - if (d < 0) { /* Delete -d items */ - memmove(item + (ihigh+d)*a->ob_descr->itemsize, - item + ihigh*a->ob_descr->itemsize, - (a->ob_size-ihigh)*a->ob_descr->itemsize); - a->ob_size += d; - PyMem_RESIZE(item, char, a->ob_size*a->ob_descr->itemsize); - /* Can't fail */ - a->ob_item = item; - } - else if (d > 0) { /* Insert d items */ - PyMem_RESIZE(item, char, - (a->ob_size + d)*a->ob_descr->itemsize); - if (item == NULL) { - PyErr_NoMemory(); - return -1; - } - memmove(item + (ihigh+d)*a->ob_descr->itemsize, - item + ihigh*a->ob_descr->itemsize, - (a->ob_size-ihigh)*a->ob_descr->itemsize); - a->ob_item = item; - a->ob_size += d; - } - if (n > 0) - memcpy(item + ilow*a->ob_descr->itemsize, b->ob_item, - n*b->ob_descr->itemsize); - return 0; -#undef b -} - -static int -array_ass_item(arrayobject *a, int i, PyObject *v) -{ - if (i < 0 || i >= a->ob_size) { - PyErr_SetString(PyExc_IndexError, - "array assignment index out of range"); - return -1; - } - if (v == NULL) - return array_ass_slice(a, i, i+1, v); - return (*a->ob_descr->setitem)(a, i, v); -} - -static int -setarrayitem(PyObject *a, int i, PyObject *v) -{ - assert(array_Check(a)); - return array_ass_item((arrayobject *)a, i, v); -} - -static int -array_do_extend(arrayobject *self, PyObject *bb) -{ - int size; - - if (!array_Check(bb)) { - PyErr_Format(PyExc_TypeError, - "can only extend array with array (not \"%.200s\")", - bb->ob_type->tp_name); - return -1; - } -#define b ((arrayobject *)bb) - if (self->ob_descr != b->ob_descr) { - PyErr_SetString(PyExc_TypeError, - "can only extend with array of same kind"); - return -1; - } - size = self->ob_size + b->ob_size; - PyMem_RESIZE(self->ob_item, char, size*self->ob_descr->itemsize); - if (self->ob_item == NULL) { - PyObject_Del(self); - PyErr_NoMemory(); - return -1; - } - memcpy(self->ob_item + self->ob_size*self->ob_descr->itemsize, - b->ob_item, b->ob_size*b->ob_descr->itemsize); - self->ob_size = size; - - return 0; -#undef b -} - -static PyObject * -array_inplace_concat(arrayobject *self, PyObject *bb) -{ - if (array_do_extend(self, bb) == -1) - return NULL; - Py_INCREF(self); - return (PyObject *)self; -} - -static PyObject * -array_inplace_repeat(arrayobject *self, int n) -{ - char *items, *p; - int size, i; - - if (self->ob_size > 0) { - if (n < 0) - n = 0; - items = self->ob_item; - size = self->ob_size * self->ob_descr->itemsize; - if (n == 0) { - PyMem_FREE(items); - self->ob_item = NULL; - self->ob_size = 0; - } - else { - PyMem_Resize(items, char, n * size); - if (items == NULL) - return PyErr_NoMemory(); - p = items; - for (i = 1; i < n; i++) { - p += size; - memcpy(p, items, size); - } - self->ob_item = items; - self->ob_size *= n; - } - } - Py_INCREF(self); - return (PyObject *)self; -} - - -static PyObject * -ins(arrayobject *self, int where, PyObject *v) -{ - if (ins1(self, where, v) != 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -array_count(arrayobject *self, PyObject *v) -{ - int count = 0; - int i; - - for (i = 0; i < self->ob_size; i++) { - PyObject *selfi = getarrayitem((PyObject *)self, i); - int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); - Py_DECREF(selfi); - if (cmp > 0) - count++; - else if (cmp < 0) - return NULL; - } - return PyInt_FromLong((long)count); -} - -PyDoc_STRVAR(count_doc, -"count(x)\n\ -\n\ -Return number of occurences of x in the array."); - -static PyObject * -array_index(arrayobject *self, PyObject *v) -{ - int i; - - for (i = 0; i < self->ob_size; i++) { - PyObject *selfi = getarrayitem((PyObject *)self, i); - int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); - Py_DECREF(selfi); - if (cmp > 0) { - return PyInt_FromLong((long)i); - } - else if (cmp < 0) - return NULL; - } - PyErr_SetString(PyExc_ValueError, "array.index(x): x not in list"); - return NULL; -} - -PyDoc_STRVAR(index_doc, -"index(x)\n\ -\n\ -Return index of first occurence of x in the array."); - -static int -array_contains(arrayobject *self, PyObject *v) -{ - int i, cmp; - - for (i = 0, cmp = 0 ; cmp == 0 && i < self->ob_size; i++) { - PyObject *selfi = getarrayitem((PyObject *)self, i); - cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); - Py_DECREF(selfi); - } - return cmp; -} - -static PyObject * -array_remove(arrayobject *self, PyObject *v) -{ - int i; - - for (i = 0; i < self->ob_size; i++) { - PyObject *selfi = getarrayitem((PyObject *)self,i); - int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); - Py_DECREF(selfi); - if (cmp > 0) { - if (array_ass_slice(self, i, i+1, - (PyObject *)NULL) != 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; - } - else if (cmp < 0) - return NULL; - } - PyErr_SetString(PyExc_ValueError, "array.remove(x): x not in list"); - return NULL; -} - -PyDoc_STRVAR(remove_doc, -"remove(x)\n\ -\n\ -Remove the first occurence of x in the array."); - -static PyObject * -array_pop(arrayobject *self, PyObject *args) -{ - int i = -1; - PyObject *v; - if (!PyArg_ParseTuple(args, "|i:pop", &i)) - return NULL; - if (self->ob_size == 0) { - /* Special-case most common failure cause */ - PyErr_SetString(PyExc_IndexError, "pop from empty array"); - return NULL; - } - if (i < 0) - i += self->ob_size; - if (i < 0 || i >= self->ob_size) { - PyErr_SetString(PyExc_IndexError, "pop index out of range"); - return NULL; - } - v = getarrayitem((PyObject *)self,i); - if (array_ass_slice(self, i, i+1, (PyObject *)NULL) != 0) { - Py_DECREF(v); - return NULL; - } - return v; -} - -PyDoc_STRVAR(pop_doc, -"pop([i])\n\ -\n\ -Return the i-th element and delete it from the array. i defaults to -1."); - -static PyObject * -array_extend(arrayobject *self, PyObject *bb) -{ - if (array_do_extend(self, bb) == -1) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(extend_doc, -"extend(array)\n\ -\n\ - Append array items to the end of the array."); - -static PyObject * -array_insert(arrayobject *self, PyObject *args) -{ - int i; - PyObject *v; - if (!PyArg_ParseTuple(args, "iO:insert", &i, &v)) - return NULL; - return ins(self, i, v); -} - -PyDoc_STRVAR(insert_doc, -"insert(i,x)\n\ -\n\ -Insert a new item x into the array before position i."); - - -static PyObject * -array_buffer_info(arrayobject *self, PyObject *unused) -{ - PyObject* retval = NULL; - retval = PyTuple_New(2); - if (!retval) - return NULL; - - PyTuple_SET_ITEM(retval, 0, PyLong_FromVoidPtr(self->ob_item)); - PyTuple_SET_ITEM(retval, 1, PyInt_FromLong((long)(self->ob_size))); - - return retval; -} - -PyDoc_STRVAR(buffer_info_doc, -"buffer_info() -> (address, length)\n\ -\n\ -Return a tuple (address, length) giving the current memory address and\n\ -the length in items of the buffer used to hold array's contents\n\ -The length should be multiplied by the itemsize attribute to calculate\n\ -the buffer length in bytes."); - - -static PyObject * -array_append(arrayobject *self, PyObject *v) -{ - return ins(self, (int) self->ob_size, v); -} - -PyDoc_STRVAR(append_doc, -"append(x)\n\ -\n\ -Append new value x to the end of the array."); - - -static PyObject * -array_byteswap(arrayobject *self, PyObject *unused) -{ - char *p; - int i; - - switch (self->ob_descr->itemsize) { - case 1: - break; - case 2: - for (p = self->ob_item, i = self->ob_size; --i >= 0; p += 2) { - char p0 = p[0]; - p[0] = p[1]; - p[1] = p0; - } - break; - case 4: - for (p = self->ob_item, i = self->ob_size; --i >= 0; p += 4) { - char p0 = p[0]; - char p1 = p[1]; - p[0] = p[3]; - p[1] = p[2]; - p[2] = p1; - p[3] = p0; - } - break; - case 8: - for (p = self->ob_item, i = self->ob_size; --i >= 0; p += 8) { - char p0 = p[0]; - char p1 = p[1]; - char p2 = p[2]; - char p3 = p[3]; - p[0] = p[7]; - p[1] = p[6]; - p[2] = p[5]; - p[3] = p[4]; - p[4] = p3; - p[5] = p2; - p[6] = p1; - p[7] = p0; - } - break; - default: - PyErr_SetString(PyExc_RuntimeError, - "don't know how to byteswap this array type"); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(byteswap_doc, -"byteswap()\n\ -\n\ -Byteswap all items of the array. If the items in the array are not 1, 2,\n\ -4, or 8 bytes in size, RuntimeError is raised."); - -static PyObject * -array_reverse(arrayobject *self, PyObject *unused) -{ - register int itemsize = self->ob_descr->itemsize; - register char *p, *q; - /* little buffer to hold items while swapping */ - char tmp[256]; /* 8 is probably enough -- but why skimp */ - assert(itemsize <= sizeof(tmp)); - - if (self->ob_size > 1) { - for (p = self->ob_item, - q = self->ob_item + (self->ob_size - 1)*itemsize; - p < q; - p += itemsize, q -= itemsize) { - /* memory areas guaranteed disjoint, so memcpy - * is safe (& memmove may be slower). - */ - memcpy(tmp, p, itemsize); - memcpy(p, q, itemsize); - memcpy(q, tmp, itemsize); - } - } - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(reverse_doc, -"reverse()\n\ -\n\ -Reverse the order of the items in the array."); - -static PyObject * -array_fromfile(arrayobject *self, PyObject *args) -{ - PyObject *f; - int n; - FILE *fp; - if (!PyArg_ParseTuple(args, "Oi:fromfile", &f, &n)) - return NULL; - fp = PyFile_AsFile(f); - if (fp == NULL) { - PyErr_SetString(PyExc_TypeError, "arg1 must be open file"); - return NULL; - } - if (n > 0) { - char *item = self->ob_item; - int itemsize = self->ob_descr->itemsize; - size_t nread; - int newlength; - size_t newbytes; - /* Be careful here about overflow */ - if ((newlength = self->ob_size + n) <= 0 || - (newbytes = newlength * itemsize) / itemsize != - (size_t)newlength) - goto nomem; - PyMem_RESIZE(item, char, newbytes); - if (item == NULL) { - nomem: - PyErr_NoMemory(); - return NULL; - } - self->ob_item = item; - self->ob_size += n; - nread = fread(item + (self->ob_size - n) * itemsize, - itemsize, n, fp); - if (nread < (size_t)n) { - self->ob_size -= (n - nread); - PyMem_RESIZE(item, char, self->ob_size*itemsize); - self->ob_item = item; - PyErr_SetString(PyExc_EOFError, - "not enough items in file"); - return NULL; - } - } - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(fromfile_doc, -"fromfile(f, n)\n\ -\n\ -Read n objects from the file object f and append them to the end of the\n\ -array. Also called as read."); - - -static PyObject * -array_tofile(arrayobject *self, PyObject *f) -{ - FILE *fp; - - fp = PyFile_AsFile(f); - if (fp == NULL) { - PyErr_SetString(PyExc_TypeError, "arg must be open file"); - return NULL; - } - if (self->ob_size > 0) { - if (fwrite(self->ob_item, self->ob_descr->itemsize, - self->ob_size, fp) != (size_t)self->ob_size) { - PyErr_SetFromErrno(PyExc_IOError); - clearerr(fp); - return NULL; - } - } - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(tofile_doc, -"tofile(f)\n\ -\n\ -Write all items (as machine values) to the file object f. Also called as\n\ -write."); - - -static PyObject * -array_fromlist(arrayobject *self, PyObject *list) -{ - int n; - int itemsize = self->ob_descr->itemsize; - - if (!PyList_Check(list)) { - PyErr_SetString(PyExc_TypeError, "arg must be list"); - return NULL; - } - n = PyList_Size(list); - if (n > 0) { - char *item = self->ob_item; - int i; - PyMem_RESIZE(item, char, (self->ob_size + n) * itemsize); - if (item == NULL) { - PyErr_NoMemory(); - return NULL; - } - self->ob_item = item; - self->ob_size += n; - for (i = 0; i < n; i++) { - PyObject *v = PyList_GetItem(list, i); - if ((*self->ob_descr->setitem)(self, - self->ob_size - n + i, v) != 0) { - self->ob_size -= n; - PyMem_RESIZE(item, char, - self->ob_size * itemsize); - self->ob_item = item; - return NULL; - } - } - } - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(fromlist_doc, -"fromlist(list)\n\ -\n\ -Append items to array from list."); - - -static PyObject * -array_tolist(arrayobject *self, PyObject *unused) -{ - PyObject *list = PyList_New(self->ob_size); - int i; - - if (list == NULL) - return NULL; - for (i = 0; i < self->ob_size; i++) { - PyObject *v = getarrayitem((PyObject *)self, i); - if (v == NULL) { - Py_DECREF(list); - return NULL; - } - PyList_SetItem(list, i, v); - } - return list; -} - -PyDoc_STRVAR(tolist_doc, -"tolist() -> list\n\ -\n\ -Convert array to an ordinary list with the same items."); - - -static PyObject * -array_fromstring(arrayobject *self, PyObject *args) -{ - char *str; - int n; - int itemsize = self->ob_descr->itemsize; - if (!PyArg_ParseTuple(args, "s#:fromstring", &str, &n)) - return NULL; - if (n % itemsize != 0) { - PyErr_SetString(PyExc_ValueError, - "string length not a multiple of item size"); - return NULL; - } - n = n / itemsize; - if (n > 0) { - char *item = self->ob_item; - PyMem_RESIZE(item, char, (self->ob_size + n) * itemsize); - if (item == NULL) { - PyErr_NoMemory(); - return NULL; - } - self->ob_item = item; - self->ob_size += n; - memcpy(item + (self->ob_size - n) * itemsize, - str, itemsize*n); - } - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(fromstring_doc, -"fromstring(string)\n\ -\n\ -Appends items from the string, interpreting it as an array of machine\n\ -values,as if it had been read from a file using the fromfile() method)."); - - -static PyObject * -array_tostring(arrayobject *self, PyObject *unused) -{ - return PyString_FromStringAndSize(self->ob_item, - self->ob_size * self->ob_descr->itemsize); -} - -PyDoc_STRVAR(tostring_doc, -"tostring() -> string\n\ -\n\ -Convert the array to an array of machine values and return the string\n\ -representation."); - - - -#ifdef Py_USING_UNICODE -static PyObject * -array_fromunicode(arrayobject *self, PyObject *args) -{ - Py_UNICODE *ustr; - int n; - - if (!PyArg_ParseTuple(args, "u#:fromunicode", &ustr, &n)) - return NULL; - if (self->ob_descr->typecode != 'u') { - PyErr_SetString(PyExc_ValueError, - "fromunicode() may only be called on " - "type 'u' arrays"); - return NULL; - } - if (n > 0) { - Py_UNICODE *item = (Py_UNICODE *) self->ob_item; - PyMem_RESIZE(item, Py_UNICODE, self->ob_size + n); - if (item == NULL) { - PyErr_NoMemory(); - return NULL; - } - self->ob_item = (char *) item; - self->ob_size += n; - memcpy(item + self->ob_size - n, - ustr, n * sizeof(Py_UNICODE)); - } - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(fromunicode_doc, -"fromunicode(ustr)\n\ -\n\ -Extends this array with data from the unicode string ustr.\n\ -The array must be a type 'u' array; otherwise a ValueError\n\ -is raised. Use array.fromstring(ustr.decode(...)) to\n\ -append Unicode data to an array of some other type."); - - -static PyObject * -array_tounicode(arrayobject *self, PyObject *unused) -{ - if (self->ob_descr->typecode != 'u') { - PyErr_SetString(PyExc_ValueError, - "tounicode() may only be called on type 'u' arrays"); - return NULL; - } - return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, self->ob_size); -} - -PyDoc_STRVAR(tounicode_doc, -"tounicode() -> unicode\n\ -\n\ -Convert the array to a unicode string. The array must be\n\ -a type 'u' array; otherwise a ValueError is raised. Use\n\ -array.tostring().decode() to obtain a unicode string from\n\ -an array of some other type."); - -#endif /* Py_USING_UNICODE */ - - -static PyObject * -array_get_typecode(arrayobject *a, void *closure) -{ - char tc = a->ob_descr->typecode; - return PyString_FromStringAndSize(&tc, 1); -} - -static PyObject * -array_get_itemsize(arrayobject *a, void *closure) -{ - return PyInt_FromLong((long)a->ob_descr->itemsize); -} - -static PyGetSetDef array_getsets [] = { - {"typecode", (getter) array_get_typecode, NULL, - "the typecode character used to create the array"}, - {"itemsize", (getter) array_get_itemsize, NULL, - "the size, in bytes, of one array item"}, - {NULL} -}; - -PyMethodDef array_methods[] = { - {"append", (PyCFunction)array_append, METH_O, - append_doc}, - {"buffer_info", (PyCFunction)array_buffer_info, METH_NOARGS, - buffer_info_doc}, - {"byteswap", (PyCFunction)array_byteswap, METH_NOARGS, - byteswap_doc}, - {"count", (PyCFunction)array_count, METH_O, - count_doc}, - {"extend", (PyCFunction)array_extend, METH_O, - extend_doc}, - {"fromfile", (PyCFunction)array_fromfile, METH_VARARGS, - fromfile_doc}, - {"fromlist", (PyCFunction)array_fromlist, METH_O, - fromlist_doc}, - {"fromstring", (PyCFunction)array_fromstring, METH_VARARGS, - fromstring_doc}, -#ifdef Py_USING_UNICODE - {"fromunicode", (PyCFunction)array_fromunicode, METH_VARARGS, - fromunicode_doc}, -#endif - {"index", (PyCFunction)array_index, METH_O, - index_doc}, - {"insert", (PyCFunction)array_insert, METH_VARARGS, - insert_doc}, - {"pop", (PyCFunction)array_pop, METH_VARARGS, - pop_doc}, - {"read", (PyCFunction)array_fromfile, METH_VARARGS, - fromfile_doc}, - {"remove", (PyCFunction)array_remove, METH_O, - remove_doc}, - {"reverse", (PyCFunction)array_reverse, METH_NOARGS, - reverse_doc}, -/* {"sort", (PyCFunction)array_sort, METH_VARARGS, - sort_doc},*/ - {"tofile", (PyCFunction)array_tofile, METH_O, - tofile_doc}, - {"tolist", (PyCFunction)array_tolist, METH_NOARGS, - tolist_doc}, - {"tostring", (PyCFunction)array_tostring, METH_NOARGS, - tostring_doc}, -#ifdef Py_USING_UNICODE - {"tounicode", (PyCFunction)array_tounicode, METH_NOARGS, - tounicode_doc}, -#endif - {"write", (PyCFunction)array_tofile, METH_O, - tofile_doc}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -array_repr(arrayobject *a) -{ - char buf[256], typecode; - PyObject *s, *t, *v = NULL; - int len; - - len = a->ob_size; - typecode = a->ob_descr->typecode; - if (len == 0) { - PyOS_snprintf(buf, sizeof(buf), "array('%c')", typecode); - return PyString_FromString(buf); - } - - if (typecode == 'c') - v = array_tostring(a, NULL); -#ifdef Py_USING_UNICODE - else if (typecode == 'u') - v = array_tounicode(a, NULL); -#endif - else - v = array_tolist(a, NULL); - t = PyObject_Repr(v); - Py_XDECREF(v); - - PyOS_snprintf(buf, sizeof(buf), "array('%c', ", typecode); - s = PyString_FromString(buf); - PyString_ConcatAndDel(&s, t); - PyString_ConcatAndDel(&s, PyString_FromString(")")); - return s; -} - -static PyObject* -array_subscr(arrayobject* self, PyObject* item) -{ - if (PyInt_Check(item)) { - long i = PyInt_AS_LONG(item); - if (i < 0) - i += self->ob_size; - return array_item(self, i); - } - else if (PyLong_Check(item)) { - long i = PyLong_AsLong(item); - if (i == -1 && PyErr_Occurred()) - return NULL; - if (i < 0) - i += self->ob_size; - return array_item(self, i); - } - else if (PySlice_Check(item)) { - int start, stop, step, slicelength, cur, i; - PyObject* result; - arrayobject* ar; - int itemsize = self->ob_descr->itemsize; - - if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size, - &start, &stop, &step, &slicelength) < 0) { - return NULL; - } - - if (slicelength <= 0) { - return newarrayobject(&Arraytype, 0, self->ob_descr); - } - else { - result = newarrayobject(&Arraytype, slicelength, self->ob_descr); - if (!result) return NULL; - - ar = (arrayobject*)result; - - for (cur = start, i = 0; i < slicelength; - cur += step, i++) { - memcpy(ar->ob_item + i*itemsize, - self->ob_item + cur*itemsize, - itemsize); - } - - return result; - } - } - else { - PyErr_SetString(PyExc_TypeError, - "list indices must be integers"); - return NULL; - } -} - -static int -array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) -{ - if (PyInt_Check(item)) { - long i = PyInt_AS_LONG(item); - if (i < 0) - i += self->ob_size; - return array_ass_item(self, i, value); - } - else if (PyLong_Check(item)) { - long i = PyLong_AsLong(item); - if (i == -1 && PyErr_Occurred()) - return -1; - if (i < 0) - i += self->ob_size; - return array_ass_item(self, i, value); - } - else if (PySlice_Check(item)) { - int start, stop, step, slicelength; - int itemsize = self->ob_descr->itemsize; - - if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size, - &start, &stop, &step, &slicelength) < 0) { - return -1; - } - - /* treat A[slice(a,b)] = v _exactly_ like A[a:b] = v */ - if (step == 1 && ((PySliceObject*)item)->step == Py_None) - return array_ass_slice(self, start, stop, value); - - if (value == NULL) { - /* delete slice */ - int cur, i, extra; - - if (slicelength <= 0) - return 0; - - if (step < 0) { - stop = start + 1; - start = stop + step*(slicelength - 1) - 1; - step = -step; - } - - for (cur = start, i = 0; i < slicelength - 1; - cur += step, i++) { - memmove(self->ob_item + (cur - i)*itemsize, - self->ob_item + (cur + 1)*itemsize, - (step - 1) * itemsize); - } - extra = self->ob_size - (cur + 1); - if (extra > 0) { - memmove(self->ob_item + (cur - i)*itemsize, - self->ob_item + (cur + 1)*itemsize, - extra*itemsize); - } - - self->ob_size -= slicelength; - self->ob_item = PyMem_REALLOC(self->ob_item, itemsize*self->ob_size); - - - return 0; - } - else { - /* assign slice */ - int cur, i; - arrayobject* av; - - if (!array_Check(value)) { - PyErr_Format(PyExc_TypeError, - "must assign array (not \"%.200s\") to slice", - value->ob_type->tp_name); - return -1; - } - - av = (arrayobject*)value; - - if (av->ob_size != slicelength) { - PyErr_Format(PyExc_ValueError, - "attempt to assign array of size %d to extended slice of size %d", - av->ob_size, slicelength); - return -1; - } - - if (!slicelength) - return 0; - - /* protect against a[::-1] = a */ - if (self == av) { - value = array_slice(av, 0, av->ob_size); - av = (arrayobject*)value; - } - else { - Py_INCREF(value); - } - - for (cur = start, i = 0; i < slicelength; - cur += step, i++) { - memcpy(self->ob_item + cur*itemsize, - av->ob_item + i*itemsize, - itemsize); - } - - Py_DECREF(value); - - return 0; - } - } - else { - PyErr_SetString(PyExc_TypeError, - "list indices must be integers"); - return -1; - } -} - -static PyMappingMethods array_as_mapping = { - (inquiry)array_length, - (binaryfunc)array_subscr, - (objobjargproc)array_ass_subscr -}; - -static int -array_buffer_getreadbuf(arrayobject *self, int index, const void **ptr) -{ - if ( index != 0 ) { - PyErr_SetString(PyExc_SystemError, - "Accessing non-existent array segment"); - return -1; - } - *ptr = (void *)self->ob_item; - return self->ob_size*self->ob_descr->itemsize; -} - -static int -array_buffer_getwritebuf(arrayobject *self, int index, const void **ptr) -{ - if ( index != 0 ) { - PyErr_SetString(PyExc_SystemError, - "Accessing non-existent array segment"); - return -1; - } - *ptr = (void *)self->ob_item; - return self->ob_size*self->ob_descr->itemsize; -} - -static int -array_buffer_getsegcount(arrayobject *self, int *lenp) -{ - if ( lenp ) - *lenp = self->ob_size*self->ob_descr->itemsize; - return 1; -} - -static PySequenceMethods array_as_sequence = { - (inquiry)array_length, /*sq_length*/ - (binaryfunc)array_concat, /*sq_concat*/ - (intargfunc)array_repeat, /*sq_repeat*/ - (intargfunc)array_item, /*sq_item*/ - (intintargfunc)array_slice, /*sq_slice*/ - (intobjargproc)array_ass_item, /*sq_ass_item*/ - (intintobjargproc)array_ass_slice, /*sq_ass_slice*/ - (objobjproc)array_contains, /*sq_contains*/ - (binaryfunc)array_inplace_concat, /*sq_inplace_concat*/ - (intargfunc)array_inplace_repeat /*sq_inplace_repeat*/ -}; - -static PyBufferProcs array_as_buffer = { - (getreadbufferproc)array_buffer_getreadbuf, - (getwritebufferproc)array_buffer_getwritebuf, - (getsegcountproc)array_buffer_getsegcount, -}; - -static PyObject * -array_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - char c; - PyObject *initial = NULL; - struct arraydescr *descr; - - if (kwds != NULL) { - int i = PyObject_Length(kwds); - if (i < 0) - return NULL; - else if (i > 0) { - PyErr_SetString(PyExc_TypeError, - "array.array constructor takes " - "no keyword arguments"); - return NULL; - } - } - - if (!PyArg_ParseTuple(args, "c|O:array", &c, &initial)) - return NULL; - - if (!(initial == NULL || PyList_Check(initial) - || PyString_Check(initial) || PyTuple_Check(initial) - || (c == 'u' && PyUnicode_Check(initial)))) { - PyErr_SetString(PyExc_TypeError, - "array initializer must be list or string"); - return NULL; - } - for (descr = descriptors; descr->typecode != '\0'; descr++) { - if (descr->typecode == c) { - PyObject *a; - int len; - - if (initial == NULL || !(PyList_Check(initial) - || PyTuple_Check(initial))) - len = 0; - else - len = PySequence_Size(initial); - - a = newarrayobject(type, len, descr); - if (a == NULL) - return NULL; - - if (len > 0) { - int i; - for (i = 0; i < len; i++) { - PyObject *v = - PySequence_GetItem(initial, i); - if (v == NULL) { - Py_DECREF(a); - return NULL; - } - if (setarrayitem(a, i, v) != 0) { - Py_DECREF(v); - Py_DECREF(a); - return NULL; - } - Py_DECREF(v); - } - } else if (initial != NULL && PyString_Check(initial)) { - PyObject *t_initial = Py_BuildValue("(O)", - initial); - PyObject *v = - array_fromstring((arrayobject *)a, - t_initial); - Py_DECREF(t_initial); - if (v == NULL) { - Py_DECREF(a); - return NULL; - } - Py_DECREF(v); -#ifdef Py_USING_UNICODE - } else if (initial != NULL && PyUnicode_Check(initial)) { - int n = PyUnicode_GET_DATA_SIZE(initial); - if (n > 0) { - arrayobject *self = (arrayobject *)a; - char *item = self->ob_item; - item = PyMem_Realloc(item, n); - if (item == NULL) { - PyErr_NoMemory(); - Py_DECREF(a); - return NULL; - } - self->ob_item = item; - self->ob_size = n / sizeof(Py_UNICODE); - memcpy(item, PyUnicode_AS_DATA(initial), n); - } -#endif - } - return a; - } - } - PyErr_SetString(PyExc_ValueError, - "bad typecode (must be c, b, B, u, h, H, i, I, l, L, f or d)"); - return NULL; -} - - -PyDoc_STRVAR(module_doc, -"This module defines an object type which can efficiently represent\n\ -an array of basic values: characters, integers, floating point\n\ -numbers. Arrays are sequence types and behave very much like lists,\n\ -except that the type of objects stored in them is constrained. The\n\ -type is specified at object creation time by using a type code, which\n\ -is a single character. The following type codes are defined:\n\ -\n\ - Type code C Type Minimum size in bytes \n\ - 'c' character 1 \n\ - 'b' signed integer 1 \n\ - 'B' unsigned integer 1 \n\ - 'u' Unicode character 2 \n\ - 'h' signed integer 2 \n\ - 'H' unsigned integer 2 \n\ - 'i' signed integer 2 \n\ - 'I' unsigned integer 2 \n\ - 'l' signed integer 4 \n\ - 'L' unsigned integer 4 \n\ - 'f' floating point 4 \n\ - 'd' floating point 8 \n\ -\n\ -The constructor is:\n\ -\n\ -array(typecode [, initializer]) -- create a new array\n\ -"); - -PyDoc_STRVAR(arraytype_doc, -"array(typecode [, initializer]) -> array\n\ -\n\ -Return a new array whose items are restricted by typecode, and\n\ -initialized from the optional initializer value, which must be a list\n\ -or a string.\n\ -\n\ -Arrays represent basic values and behave very much like lists, except\n\ -the type of objects stored in them is constrained.\n\ -\n\ -Methods:\n\ -\n\ -append() -- append a new item to the end of the array\n\ -buffer_info() -- return information giving the current memory info\n\ -byteswap() -- byteswap all the items of the array\n\ -count() -- return number of occurences of an object\n\ -extend() -- extend array by appending array elements\n\ -fromfile() -- read items from a file object\n\ -fromlist() -- append items from the list\n\ -fromstring() -- append items from the string\n\ -index() -- return index of first occurence of an object\n\ -insert() -- insert a new item into the array at a provided position\n\ -pop() -- remove and return item (default last)\n\ -read() -- DEPRECATED, use fromfile()\n\ -remove() -- remove first occurence of an object\n\ -reverse() -- reverse the order of the items in the array\n\ -tofile() -- write all items to a file object\n\ -tolist() -- return the array converted to an ordinary list\n\ -tostring() -- return the array converted to a string\n\ -write() -- DEPRECATED, use tofile()\n\ -\n\ -Attributes:\n\ -\n\ -typecode -- the typecode character used to create the array\n\ -itemsize -- the length in bytes of one array item\n\ -"); - -static PyObject *array_iter(arrayobject *ao); - -static PyTypeObject Arraytype = { - PyObject_HEAD_INIT(NULL) - 0, - "array.array", - sizeof(arrayobject), - 0, - (destructor)array_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)array_repr, /* tp_repr */ - 0, /* tp_as _number*/ - &array_as_sequence, /* tp_as _sequence*/ - &array_as_mapping, /* tp_as _mapping*/ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - &array_as_buffer, /* tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - arraytype_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - array_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc)array_iter, /* tp_iter */ - 0, /* tp_iternext */ - array_methods, /* tp_methods */ - 0, /* tp_members */ - array_getsets, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - array_new, /* tp_new */ - PyObject_Del, /* tp_free */ -}; - - -/*********************** Array Iterator **************************/ - -typedef struct { - PyObject_HEAD - long index; - arrayobject *ao; - PyObject * (*getitem)(struct arrayobject *, int); -} arrayiterobject; - -static PyTypeObject PyArrayIter_Type; - -#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type) - -static PyObject * -array_iter(arrayobject *ao) -{ - arrayiterobject *it; - - if (!array_Check(ao)) { - PyErr_BadInternalCall(); - return NULL; - } - - it = PyObject_GC_New(arrayiterobject, &PyArrayIter_Type); - if (it == NULL) - return NULL; - - Py_INCREF(ao); - it->ao = ao; - it->index = 0; - it->getitem = ao->ob_descr->getitem; - PyObject_GC_Track(it); - return (PyObject *)it; -} - -static PyObject * -arrayiter_next(arrayiterobject *it) -{ - assert(PyArrayIter_Check(it)); - if (it->index < it->ao->ob_size) - return (*it->getitem)(it->ao, it->index++); - return NULL; -} - -static void -arrayiter_dealloc(arrayiterobject *it) -{ - PyObject_GC_UnTrack(it); - Py_XDECREF(it->ao); - PyObject_GC_Del(it); -} - -static int -arrayiter_traverse(arrayiterobject *it, visitproc visit, void *arg) -{ - if (it->ao != NULL) - return visit((PyObject *)(it->ao), arg); - return 0; -} - -static PyTypeObject PyArrayIter_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "arrayiterator", /* tp_name */ - sizeof(arrayiterobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)arrayiter_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - 0, /* tp_doc */ - (traverseproc)arrayiter_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)arrayiter_next, /* tp_iternext */ - 0, /* tp_methods */ -}; - - -/*********************** Install Module **************************/ - -/* No functions in array module. */ -static PyMethodDef a_methods[] = { - {NULL, NULL, 0, NULL} /* Sentinel */ -}; - - -PyMODINIT_FUNC -initarray(void) -{ - PyObject *m; - - Arraytype.ob_type = &PyType_Type; - PyArrayIter_Type.ob_type = &PyType_Type; - m = Py_InitModule3("array", a_methods, module_doc); - - Py_INCREF((PyObject *)&Arraytype); - PyModule_AddObject(m, "ArrayType", (PyObject *)&Arraytype); - Py_INCREF((PyObject *)&Arraytype); - PyModule_AddObject(m, "array", (PyObject *)&Arraytype); - /* No need to check the error here, the caller will do that */ -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/audioop.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/audioop.c deleted file mode 100644 index e270f618..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/audioop.c +++ /dev/null @@ -1,1381 +0,0 @@ - -/* audioopmodule - Module to detect peak values in arrays */ - -#include "Python.h" - -#if SIZEOF_INT == 4 -typedef int Py_Int32; -typedef unsigned int Py_UInt32; -#else -#if SIZEOF_LONG == 4 -typedef long Py_Int32; -typedef unsigned long Py_UInt32; -#else -#error "No 4-byte integral type" -#endif -#endif - -#if defined(__CHAR_UNSIGNED__) -#if defined(signed) -/* This module currently does not work on systems where only unsigned - characters are available. Take it out of Setup. Sorry. */ -#endif -#endif - -/* Code shamelessly stolen from sox, -** (c) Craig Reese, Joe Campbell and Jeff Poskanzer 1989 */ - -#define MINLIN -32768 -#define MAXLIN 32767 -#define LINCLIP(x) do { if ( x < MINLIN ) x = MINLIN ; \ - else if ( x > MAXLIN ) x = MAXLIN; \ - } while ( 0 ) - -static unsigned char st_linear_to_ulaw(int sample); - -/* -** This macro converts from ulaw to 16 bit linear, faster. -** -** Jef Poskanzer -** 23 October 1989 -** -** Input: 8 bit ulaw sample -** Output: signed 16 bit linear sample -*/ -#define st_ulaw_to_linear(ulawbyte) ulaw_table[ulawbyte] - -static int ulaw_table[256] = { - -32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956, - -23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764, - -15996, -15484, -14972, -14460, -13948, -13436, -12924, -12412, - -11900, -11388, -10876, -10364, -9852, -9340, -8828, -8316, - -7932, -7676, -7420, -7164, -6908, -6652, -6396, -6140, - -5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092, - -3900, -3772, -3644, -3516, -3388, -3260, -3132, -3004, - -2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980, - -1884, -1820, -1756, -1692, -1628, -1564, -1500, -1436, - -1372, -1308, -1244, -1180, -1116, -1052, -988, -924, - -876, -844, -812, -780, -748, -716, -684, -652, - -620, -588, -556, -524, -492, -460, -428, -396, - -372, -356, -340, -324, -308, -292, -276, -260, - -244, -228, -212, -196, -180, -164, -148, -132, - -120, -112, -104, -96, -88, -80, -72, -64, - -56, -48, -40, -32, -24, -16, -8, 0, - 32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956, - 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764, - 15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412, - 11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316, - 7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140, - 5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092, - 3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004, - 2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980, - 1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436, - 1372, 1308, 1244, 1180, 1116, 1052, 988, 924, - 876, 844, 812, 780, 748, 716, 684, 652, - 620, 588, 556, 524, 492, 460, 428, 396, - 372, 356, 340, 324, 308, 292, 276, 260, - 244, 228, 212, 196, 180, 164, 148, 132, - 120, 112, 104, 96, 88, 80, 72, 64, - 56, 48, 40, 32, 24, 16, 8, 0 }; - -/* #define ZEROTRAP */ /* turn on the trap as per the MIL-STD */ -#define BIAS 0x84 /* define the add-in bias for 16 bit samples */ -#define CLIP 32635 - -static unsigned char -st_linear_to_ulaw(int sample) -{ - static int exp_lut[256] = {0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}; - int sign, exponent, mantissa; - unsigned char ulawbyte; - - /* Get the sample into sign-magnitude. */ - sign = (sample >> 8) & 0x80; /* set aside the sign */ - if ( sign != 0 ) sample = -sample; /* get magnitude */ - if ( sample > CLIP ) sample = CLIP; /* clip the magnitude */ - - /* Convert from 16 bit linear to ulaw. */ - sample = sample + BIAS; - exponent = exp_lut[( sample >> 7 ) & 0xFF]; - mantissa = ( sample >> ( exponent + 3 ) ) & 0x0F; - ulawbyte = ~ ( sign | ( exponent << 4 ) | mantissa ); -#ifdef ZEROTRAP - if ( ulawbyte == 0 ) ulawbyte = 0x02; /* optional CCITT trap */ -#endif - - return ulawbyte; -} -/* End of code taken from sox */ - -/* Intel ADPCM step variation table */ -static int indexTable[16] = { - -1, -1, -1, -1, 2, 4, 6, 8, - -1, -1, -1, -1, 2, 4, 6, 8, -}; - -static int stepsizeTable[89] = { - 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, - 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, - 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, - 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, - 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, - 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, - 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 -}; - -#define CHARP(cp, i) ((signed char *)(cp+i)) -#define SHORTP(cp, i) ((short *)(cp+i)) -#define LONGP(cp, i) ((Py_Int32 *)(cp+i)) - - - -static PyObject *AudioopError; - -static PyObject * -audioop_getsample(PyObject *self, PyObject *args) -{ - signed char *cp; - int len, size, val = 0; - int i; - - if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &size, &i) ) - return 0; - if ( size != 1 && size != 2 && size != 4 ) { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - if ( i < 0 || i >= len/size ) { - PyErr_SetString(AudioopError, "Index out of range"); - return 0; - } - if ( size == 1 ) val = (int)*CHARP(cp, i); - else if ( size == 2 ) val = (int)*SHORTP(cp, i*2); - else if ( size == 4 ) val = (int)*LONGP(cp, i*4); - return PyInt_FromLong(val); -} - -static PyObject * -audioop_max(PyObject *self, PyObject *args) -{ - signed char *cp; - int len, size, val = 0; - int i; - int max = 0; - - if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) ) - return 0; - if ( size != 1 && size != 2 && size != 4 ) { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - for ( i=0; i max ) max = val; - } - return PyInt_FromLong(max); -} - -static PyObject * -audioop_minmax(PyObject *self, PyObject *args) -{ - signed char *cp; - int len, size, val = 0; - int i; - int min = 0x7fffffff, max = -0x7fffffff; - - if (!PyArg_Parse(args, "(s#i)", &cp, &len, &size)) - return NULL; - if (size != 1 && size != 2 && size != 4) { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return NULL; - } - for (i = 0; i < len; i += size) { - if (size == 1) val = (int) *CHARP(cp, i); - else if (size == 2) val = (int) *SHORTP(cp, i); - else if (size == 4) val = (int) *LONGP(cp, i); - if (val > max) max = val; - if (val < min) min = val; - } - return Py_BuildValue("(ii)", min, max); -} - -static PyObject * -audioop_avg(PyObject *self, PyObject *args) -{ - signed char *cp; - int len, size, val = 0; - int i; - double avg = 0.0; - - if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) ) - return 0; - if ( size != 1 && size != 2 && size != 4 ) { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - for ( i=0; i n, and let all sums be over i from 0 to n-1. -** -** Now, for each j in {0..N-n} we compute a factor fj so that -fj*R matches A -** as good as possible, i.e. sum( (A[j+i]+fj*R[i])^2 ) is minimal. This -** equation gives fj = sum( A[j+i]R[i] ) / sum(R[i]^2). -** -** Next, we compute the relative distance between the original signal and -** the modified signal and minimize that over j: -** vj = sum( (A[j+i]-fj*R[i])^2 ) / sum( A[j+i]^2 ) => -** vj = ( sum(A[j+i]^2)*sum(R[i]^2) - sum(A[j+i]R[i])^2 ) / sum( A[j+i]^2 ) -** -** In the code variables correspond as follows: -** cp1 A -** cp2 R -** len1 N -** len2 n -** aj_m1 A[j-1] -** aj_lm1 A[j+n-1] -** sum_ri_2 sum(R[i]^2) -** sum_aij_2 sum(A[i+j]^2) -** sum_aij_ri sum(A[i+j]R[i]) -** -** sum_ri is calculated once, sum_aij_2 is updated each step and sum_aij_ri -** is completely recalculated each step. -*/ -static PyObject * -audioop_findfit(PyObject *self, PyObject *args) -{ - short *cp1, *cp2; - int len1, len2; - int j, best_j; - double aj_m1, aj_lm1; - double sum_ri_2, sum_aij_2, sum_aij_ri, result, best_result, factor; - - if ( !PyArg_Parse(args, "(s#s#)", &cp1, &len1, &cp2, &len2) ) - return 0; - if ( len1 & 1 || len2 & 1 ) { - PyErr_SetString(AudioopError, "Strings should be even-sized"); - return 0; - } - len1 >>= 1; - len2 >>= 1; - - if ( len1 < len2 ) { - PyErr_SetString(AudioopError, "First sample should be longer"); - return 0; - } - sum_ri_2 = _sum2(cp2, cp2, len2); - sum_aij_2 = _sum2(cp1, cp1, len2); - sum_aij_ri = _sum2(cp1, cp2, len2); - - result = (sum_ri_2*sum_aij_2 - sum_aij_ri*sum_aij_ri) / sum_aij_2; - - best_result = result; - best_j = 0; - j = 0; - - for ( j=1; j<=len1-len2; j++) { - aj_m1 = (double)cp1[j-1]; - aj_lm1 = (double)cp1[j+len2-1]; - - sum_aij_2 = sum_aij_2 + aj_lm1*aj_lm1 - aj_m1*aj_m1; - sum_aij_ri = _sum2(cp1+j, cp2, len2); - - result = (sum_ri_2*sum_aij_2 - sum_aij_ri*sum_aij_ri) - / sum_aij_2; - - if ( result < best_result ) { - best_result = result; - best_j = j; - } - - } - - factor = _sum2(cp1+best_j, cp2, len2) / sum_ri_2; - - return Py_BuildValue("(if)", best_j, factor); -} - -/* -** findfactor finds a factor f so that the energy in A-fB is minimal. -** See the comment for findfit for details. -*/ -static PyObject * -audioop_findfactor(PyObject *self, PyObject *args) -{ - short *cp1, *cp2; - int len1, len2; - double sum_ri_2, sum_aij_ri, result; - - if ( !PyArg_Parse(args, "(s#s#)", &cp1, &len1, &cp2, &len2) ) - return 0; - if ( len1 & 1 || len2 & 1 ) { - PyErr_SetString(AudioopError, "Strings should be even-sized"); - return 0; - } - if ( len1 != len2 ) { - PyErr_SetString(AudioopError, "Samples should be same size"); - return 0; - } - len2 >>= 1; - sum_ri_2 = _sum2(cp2, cp2, len2); - sum_aij_ri = _sum2(cp1, cp2, len2); - - result = sum_aij_ri / sum_ri_2; - - return PyFloat_FromDouble(result); -} - -/* -** findmax returns the index of the n-sized segment of the input sample -** that contains the most energy. -*/ -static PyObject * -audioop_findmax(PyObject *self, PyObject *args) -{ - short *cp1; - int len1, len2; - int j, best_j; - double aj_m1, aj_lm1; - double result, best_result; - - if ( !PyArg_Parse(args, "(s#i)", &cp1, &len1, &len2) ) - return 0; - if ( len1 & 1 ) { - PyErr_SetString(AudioopError, "Strings should be even-sized"); - return 0; - } - len1 >>= 1; - - if ( len1 < len2 ) { - PyErr_SetString(AudioopError, "Input sample should be longer"); - return 0; - } - - result = _sum2(cp1, cp1, len2); - - best_result = result; - best_j = 0; - j = 0; - - for ( j=1; j<=len1-len2; j++) { - aj_m1 = (double)cp1[j-1]; - aj_lm1 = (double)cp1[j+len2-1]; - - result = result + aj_lm1*aj_lm1 - aj_m1*aj_m1; - - if ( result > best_result ) { - best_result = result; - best_j = j; - } - - } - - return PyInt_FromLong(best_j); -} - -static PyObject * -audioop_avgpp(PyObject *self, PyObject *args) -{ - signed char *cp; - int len, size, val = 0, prevval = 0, prevextremevalid = 0, - prevextreme = 0; - int i; - double avg = 0.0; - int diff, prevdiff, extremediff, nextreme = 0; - - if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) ) - return 0; - if ( size != 1 && size != 2 && size != 4 ) { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - /* Compute first delta value ahead. Also automatically makes us - ** skip the first extreme value - */ - if ( size == 1 ) prevval = (int)*CHARP(cp, 0); - else if ( size == 2 ) prevval = (int)*SHORTP(cp, 0); - else if ( size == 4 ) prevval = (int)*LONGP(cp, 0); - if ( size == 1 ) val = (int)*CHARP(cp, size); - else if ( size == 2 ) val = (int)*SHORTP(cp, size); - else if ( size == 4 ) val = (int)*LONGP(cp, size); - prevdiff = val - prevval; - - for ( i=size; i max ) - max = extremediff; - } - prevextremevalid = 1; - prevextreme = prevval; - } - prevval = val; - if ( diff != 0 ) - prevdiff = diff; - } - return PyInt_FromLong(max); -} - -static PyObject * -audioop_cross(PyObject *self, PyObject *args) -{ - signed char *cp; - int len, size, val = 0; - int i; - int prevval, ncross; - - if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) ) - return 0; - if ( size != 1 && size != 2 && size != 4 ) { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - ncross = -1; - prevval = 17; /* Anything <> 0,1 */ - for ( i=0; i> 7; - else if ( size == 2 ) val = ((int)*SHORTP(cp, i)) >> 15; - else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 31; - val = val & 1; - if ( val != prevval ) ncross++; - prevval = val; - } - return PyInt_FromLong(ncross); -} - -static PyObject * -audioop_mul(PyObject *self, PyObject *args) -{ - signed char *cp, *ncp; - int len, size, val = 0; - double factor, fval, maxval; - PyObject *rv; - int i; - - if ( !PyArg_Parse(args, "(s#id)", &cp, &len, &size, &factor ) ) - return 0; - - if ( size == 1 ) maxval = (double) 0x7f; - else if ( size == 2 ) maxval = (double) 0x7fff; - else if ( size == 4 ) maxval = (double) 0x7fffffff; - else { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, len); - if ( rv == 0 ) - return 0; - ncp = (signed char *)PyString_AsString(rv); - - - for ( i=0; i < len; i += size ) { - if ( size == 1 ) val = (int)*CHARP(cp, i); - else if ( size == 2 ) val = (int)*SHORTP(cp, i); - else if ( size == 4 ) val = (int)*LONGP(cp, i); - fval = (double)val*factor; - if ( fval > maxval ) fval = maxval; - else if ( fval < -maxval ) fval = -maxval; - val = (int)fval; - if ( size == 1 ) *CHARP(ncp, i) = (signed char)val; - else if ( size == 2 ) *SHORTP(ncp, i) = (short)val; - else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)val; - } - return rv; -} - -static PyObject * -audioop_tomono(PyObject *self, PyObject *args) -{ - signed char *cp, *ncp; - int len, size, val1 = 0, val2 = 0; - double fac1, fac2, fval, maxval; - PyObject *rv; - int i; - - if ( !PyArg_Parse(args, "(s#idd)", &cp, &len, &size, &fac1, &fac2 ) ) - return 0; - - if ( size == 1 ) maxval = (double) 0x7f; - else if ( size == 2 ) maxval = (double) 0x7fff; - else if ( size == 4 ) maxval = (double) 0x7fffffff; - else { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, len/2); - if ( rv == 0 ) - return 0; - ncp = (signed char *)PyString_AsString(rv); - - - for ( i=0; i < len; i += size*2 ) { - if ( size == 1 ) val1 = (int)*CHARP(cp, i); - else if ( size == 2 ) val1 = (int)*SHORTP(cp, i); - else if ( size == 4 ) val1 = (int)*LONGP(cp, i); - if ( size == 1 ) val2 = (int)*CHARP(cp, i+1); - else if ( size == 2 ) val2 = (int)*SHORTP(cp, i+2); - else if ( size == 4 ) val2 = (int)*LONGP(cp, i+4); - fval = (double)val1*fac1 + (double)val2*fac2; - if ( fval > maxval ) fval = maxval; - else if ( fval < -maxval ) fval = -maxval; - val1 = (int)fval; - if ( size == 1 ) *CHARP(ncp, i/2) = (signed char)val1; - else if ( size == 2 ) *SHORTP(ncp, i/2) = (short)val1; - else if ( size == 4 ) *LONGP(ncp, i/2)= (Py_Int32)val1; - } - return rv; -} - -static PyObject * -audioop_tostereo(PyObject *self, PyObject *args) -{ - signed char *cp, *ncp; - int len, size, val1, val2, val = 0; - double fac1, fac2, fval, maxval; - PyObject *rv; - int i; - - if ( !PyArg_Parse(args, "(s#idd)", &cp, &len, &size, &fac1, &fac2 ) ) - return 0; - - if ( size == 1 ) maxval = (double) 0x7f; - else if ( size == 2 ) maxval = (double) 0x7fff; - else if ( size == 4 ) maxval = (double) 0x7fffffff; - else { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, len*2); - if ( rv == 0 ) - return 0; - ncp = (signed char *)PyString_AsString(rv); - - - for ( i=0; i < len; i += size ) { - if ( size == 1 ) val = (int)*CHARP(cp, i); - else if ( size == 2 ) val = (int)*SHORTP(cp, i); - else if ( size == 4 ) val = (int)*LONGP(cp, i); - - fval = (double)val*fac1; - if ( fval > maxval ) fval = maxval; - else if ( fval < -maxval ) fval = -maxval; - val1 = (int)fval; - - fval = (double)val*fac2; - if ( fval > maxval ) fval = maxval; - else if ( fval < -maxval ) fval = -maxval; - val2 = (int)fval; - - if ( size == 1 ) *CHARP(ncp, i*2) = (signed char)val1; - else if ( size == 2 ) *SHORTP(ncp, i*2) = (short)val1; - else if ( size == 4 ) *LONGP(ncp, i*2) = (Py_Int32)val1; - - if ( size == 1 ) *CHARP(ncp, i*2+1) = (signed char)val2; - else if ( size == 2 ) *SHORTP(ncp, i*2+2) = (short)val2; - else if ( size == 4 ) *LONGP(ncp, i*2+4) = (Py_Int32)val2; - } - return rv; -} - -static PyObject * -audioop_add(PyObject *self, PyObject *args) -{ - signed char *cp1, *cp2, *ncp; - int len1, len2, size, val1 = 0, val2 = 0, maxval, newval; - PyObject *rv; - int i; - - if ( !PyArg_Parse(args, "(s#s#i)", - &cp1, &len1, &cp2, &len2, &size ) ) - return 0; - - if ( len1 != len2 ) { - PyErr_SetString(AudioopError, "Lengths should be the same"); - return 0; - } - - if ( size == 1 ) maxval = 0x7f; - else if ( size == 2 ) maxval = 0x7fff; - else if ( size == 4 ) maxval = 0x7fffffff; - else { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, len1); - if ( rv == 0 ) - return 0; - ncp = (signed char *)PyString_AsString(rv); - - for ( i=0; i < len1; i += size ) { - if ( size == 1 ) val1 = (int)*CHARP(cp1, i); - else if ( size == 2 ) val1 = (int)*SHORTP(cp1, i); - else if ( size == 4 ) val1 = (int)*LONGP(cp1, i); - - if ( size == 1 ) val2 = (int)*CHARP(cp2, i); - else if ( size == 2 ) val2 = (int)*SHORTP(cp2, i); - else if ( size == 4 ) val2 = (int)*LONGP(cp2, i); - - newval = val1 + val2; - /* truncate in case of overflow */ - if (newval > maxval) newval = maxval; - else if (newval < -maxval) newval = -maxval; - else if (size == 4 && (newval^val1) < 0 && (newval^val2) < 0) - newval = val1 > 0 ? maxval : - maxval; - - if ( size == 1 ) *CHARP(ncp, i) = (signed char)newval; - else if ( size == 2 ) *SHORTP(ncp, i) = (short)newval; - else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)newval; - } - return rv; -} - -static PyObject * -audioop_bias(PyObject *self, PyObject *args) -{ - signed char *cp, *ncp; - int len, size, val = 0; - PyObject *rv; - int i; - int bias; - - if ( !PyArg_Parse(args, "(s#ii)", - &cp, &len, &size , &bias) ) - return 0; - - if ( size != 1 && size != 2 && size != 4) { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, len); - if ( rv == 0 ) - return 0; - ncp = (signed char *)PyString_AsString(rv); - - - for ( i=0; i < len; i += size ) { - if ( size == 1 ) val = (int)*CHARP(cp, i); - else if ( size == 2 ) val = (int)*SHORTP(cp, i); - else if ( size == 4 ) val = (int)*LONGP(cp, i); - - if ( size == 1 ) *CHARP(ncp, i) = (signed char)(val+bias); - else if ( size == 2 ) *SHORTP(ncp, i) = (short)(val+bias); - else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)(val+bias); - } - return rv; -} - -static PyObject * -audioop_reverse(PyObject *self, PyObject *args) -{ - signed char *cp; - unsigned char *ncp; - int len, size, val = 0; - PyObject *rv; - int i, j; - - if ( !PyArg_Parse(args, "(s#i)", - &cp, &len, &size) ) - return 0; - - if ( size != 1 && size != 2 && size != 4 ) { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, len); - if ( rv == 0 ) - return 0; - ncp = (unsigned char *)PyString_AsString(rv); - - for ( i=0; i < len; i += size ) { - if ( size == 1 ) val = ((int)*CHARP(cp, i)) << 8; - else if ( size == 2 ) val = (int)*SHORTP(cp, i); - else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 16; - - j = len - i - size; - - if ( size == 1 ) *CHARP(ncp, j) = (signed char)(val >> 8); - else if ( size == 2 ) *SHORTP(ncp, j) = (short)(val); - else if ( size == 4 ) *LONGP(ncp, j) = (Py_Int32)(val<<16); - } - return rv; -} - -static PyObject * -audioop_lin2lin(PyObject *self, PyObject *args) -{ - signed char *cp; - unsigned char *ncp; - int len, size, size2, val = 0; - PyObject *rv; - int i, j; - - if ( !PyArg_Parse(args, "(s#ii)", - &cp, &len, &size, &size2) ) - return 0; - - if ( (size != 1 && size != 2 && size != 4) || - (size2 != 1 && size2 != 2 && size2 != 4)) { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, (len/size)*size2); - if ( rv == 0 ) - return 0; - ncp = (unsigned char *)PyString_AsString(rv); - - for ( i=0, j=0; i < len; i += size, j += size2 ) { - if ( size == 1 ) val = ((int)*CHARP(cp, i)) << 8; - else if ( size == 2 ) val = (int)*SHORTP(cp, i); - else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 16; - - if ( size2 == 1 ) *CHARP(ncp, j) = (signed char)(val >> 8); - else if ( size2 == 2 ) *SHORTP(ncp, j) = (short)(val); - else if ( size2 == 4 ) *LONGP(ncp, j) = (Py_Int32)(val<<16); - } - return rv; -} - -static int -gcd(int a, int b) -{ - while (b > 0) { - int tmp = a % b; - a = b; - b = tmp; - } - return a; -} - -static PyObject * -audioop_ratecv(PyObject *self, PyObject *args) -{ - char *cp, *ncp; - int len, size, nchannels, inrate, outrate, weightA, weightB; - int chan, d, *prev_i, *cur_i, cur_o; - PyObject *state, *samps, *str, *rv = NULL; - int bytes_per_frame; - - weightA = 1; - weightB = 0; - if (!PyArg_ParseTuple(args, "s#iiiiO|ii:ratecv", &cp, &len, &size, &nchannels, - &inrate, &outrate, &state, &weightA, &weightB)) - return NULL; - if (size != 1 && size != 2 && size != 4) { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return NULL; - } - if (nchannels < 1) { - PyErr_SetString(AudioopError, "# of channels should be >= 1"); - return NULL; - } - bytes_per_frame = size * nchannels; - if (bytes_per_frame / nchannels != size) { - /* This overflow test is rigorously correct because - both multiplicands are >= 1. Use the argument names - from the docs for the error msg. */ - PyErr_SetString(PyExc_OverflowError, - "width * nchannels too big for a C int"); - return NULL; - } - if (weightA < 1 || weightB < 0) { - PyErr_SetString(AudioopError, - "weightA should be >= 1, weightB should be >= 0"); - return NULL; - } - if (len % bytes_per_frame != 0) { - PyErr_SetString(AudioopError, "not a whole number of frames"); - return NULL; - } - if (inrate <= 0 || outrate <= 0) { - PyErr_SetString(AudioopError, "sampling rate not > 0"); - return NULL; - } - /* divide inrate and outrate by their greatest common divisor */ - d = gcd(inrate, outrate); - inrate /= d; - outrate /= d; - - prev_i = (int *) malloc(nchannels * sizeof(int)); - cur_i = (int *) malloc(nchannels * sizeof(int)); - if (prev_i == NULL || cur_i == NULL) { - (void) PyErr_NoMemory(); - goto exit; - } - - len /= bytes_per_frame; /* # of frames */ - - if (state == Py_None) { - d = -outrate; - for (chan = 0; chan < nchannels; chan++) - prev_i[chan] = cur_i[chan] = 0; - } - else { - if (!PyArg_ParseTuple(state, - "iO!;audioop.ratecv: illegal state argument", - &d, &PyTuple_Type, &samps)) - goto exit; - if (PyTuple_Size(samps) != nchannels) { - PyErr_SetString(AudioopError, - "illegal state argument"); - goto exit; - } - for (chan = 0; chan < nchannels; chan++) { - if (!PyArg_ParseTuple(PyTuple_GetItem(samps, chan), - "ii:ratecv",&prev_i[chan],&cur_i[chan])) - goto exit; - } - } - - /* str <- Space for the output buffer. */ - { - /* There are len input frames, so we need (mathematically) - ceiling(len*outrate/inrate) output frames, and each frame - requires bytes_per_frame bytes. Computing this - without spurious overflow is the challenge; we can - settle for a reasonable upper bound, though. */ - int ceiling; /* the number of output frames */ - int nbytes; /* the number of output bytes needed */ - int q = len / inrate; - /* Now len = q * inrate + r exactly (with r = len % inrate), - and this is less than q * inrate + inrate = (q+1)*inrate. - So a reasonable upper bound on len*outrate/inrate is - ((q+1)*inrate)*outrate/inrate = - (q+1)*outrate. - */ - ceiling = (q+1) * outrate; - nbytes = ceiling * bytes_per_frame; - /* See whether anything overflowed; if not, get the space. */ - if (q+1 < 0 || - ceiling / outrate != q+1 || - nbytes / bytes_per_frame != ceiling) - str = NULL; - else - str = PyString_FromStringAndSize(NULL, nbytes); - - if (str == NULL) { - PyErr_SetString(PyExc_MemoryError, - "not enough memory for output buffer"); - goto exit; - } - } - ncp = PyString_AsString(str); - - for (;;) { - while (d < 0) { - if (len == 0) { - samps = PyTuple_New(nchannels); - for (chan = 0; chan < nchannels; chan++) - PyTuple_SetItem(samps, chan, - Py_BuildValue("(ii)", - prev_i[chan], - cur_i[chan])); - if (PyErr_Occurred()) - goto exit; - len = ncp - PyString_AsString(str); - if (len == 0) { - /*don't want to resize to zero length*/ - rv = PyString_FromStringAndSize("", 0); - Py_DECREF(str); - str = rv; - } else if (_PyString_Resize(&str, len) < 0) - goto exit; - rv = Py_BuildValue("(O(iO))", str, d, samps); - Py_DECREF(samps); - Py_DECREF(str); - goto exit; /* return rv */ - } - for (chan = 0; chan < nchannels; chan++) { - prev_i[chan] = cur_i[chan]; - if (size == 1) - cur_i[chan] = ((int)*CHARP(cp, 0)) << 8; - else if (size == 2) - cur_i[chan] = (int)*SHORTP(cp, 0); - else if (size == 4) - cur_i[chan] = ((int)*LONGP(cp, 0)) >> 16; - cp += size; - /* implements a simple digital filter */ - cur_i[chan] = - (weightA * cur_i[chan] + - weightB * prev_i[chan]) / - (weightA + weightB); - } - len--; - d += outrate; - } - while (d >= 0) { - for (chan = 0; chan < nchannels; chan++) { - cur_o = (prev_i[chan] * d + - cur_i[chan] * (outrate - d)) / - outrate; - if (size == 1) - *CHARP(ncp, 0) = (signed char)(cur_o >> 8); - else if (size == 2) - *SHORTP(ncp, 0) = (short)(cur_o); - else if (size == 4) - *LONGP(ncp, 0) = (Py_Int32)(cur_o<<16); - ncp += size; - } - d -= inrate; - } - } - exit: - if (prev_i != NULL) - free(prev_i); - if (cur_i != NULL) - free(cur_i); - return rv; -} - -static PyObject * -audioop_lin2ulaw(PyObject *self, PyObject *args) -{ - signed char *cp; - unsigned char *ncp; - int len, size, val = 0; - PyObject *rv; - int i; - - if ( !PyArg_Parse(args, "(s#i)", - &cp, &len, &size) ) - return 0; - - if ( size != 1 && size != 2 && size != 4) { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, len/size); - if ( rv == 0 ) - return 0; - ncp = (unsigned char *)PyString_AsString(rv); - - for ( i=0; i < len; i += size ) { - if ( size == 1 ) val = ((int)*CHARP(cp, i)) << 8; - else if ( size == 2 ) val = (int)*SHORTP(cp, i); - else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 16; - - *ncp++ = st_linear_to_ulaw(val); - } - return rv; -} - -static PyObject * -audioop_ulaw2lin(PyObject *self, PyObject *args) -{ - unsigned char *cp; - unsigned char cval; - signed char *ncp; - int len, size, val; - PyObject *rv; - int i; - - if ( !PyArg_Parse(args, "(s#i)", - &cp, &len, &size) ) - return 0; - - if ( size != 1 && size != 2 && size != 4) { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, len*size); - if ( rv == 0 ) - return 0; - ncp = (signed char *)PyString_AsString(rv); - - for ( i=0; i < len*size; i += size ) { - cval = *cp++; - val = st_ulaw_to_linear(cval); - - if ( size == 1 ) *CHARP(ncp, i) = (signed char)(val >> 8); - else if ( size == 2 ) *SHORTP(ncp, i) = (short)(val); - else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)(val<<16); - } - return rv; -} - -static PyObject * -audioop_lin2adpcm(PyObject *self, PyObject *args) -{ - signed char *cp; - signed char *ncp; - int len, size, val = 0, step, valpred, delta, - index, sign, vpdiff, diff; - PyObject *rv, *state, *str; - int i, outputbuffer = 0, bufferstep; - - if ( !PyArg_Parse(args, "(s#iO)", - &cp, &len, &size, &state) ) - return 0; - - - if ( size != 1 && size != 2 && size != 4) { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - - str = PyString_FromStringAndSize(NULL, len/(size*2)); - if ( str == 0 ) - return 0; - ncp = (signed char *)PyString_AsString(str); - - /* Decode state, should have (value, step) */ - if ( state == Py_None ) { - /* First time, it seems. Set defaults */ - valpred = 0; - step = 7; - index = 0; - } else if ( !PyArg_Parse(state, "(ii)", &valpred, &index) ) - return 0; - - step = stepsizeTable[index]; - bufferstep = 1; - - for ( i=0; i < len; i += size ) { - if ( size == 1 ) val = ((int)*CHARP(cp, i)) << 8; - else if ( size == 2 ) val = (int)*SHORTP(cp, i); - else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 16; - - /* Step 1 - compute difference with previous value */ - diff = val - valpred; - sign = (diff < 0) ? 8 : 0; - if ( sign ) diff = (-diff); - - /* Step 2 - Divide and clamp */ - /* Note: - ** This code *approximately* computes: - ** delta = diff*4/step; - ** vpdiff = (delta+0.5)*step/4; - ** but in shift step bits are dropped. The net result of this - ** is that even if you have fast mul/div hardware you cannot - ** put it to good use since the fixup would be too expensive. - */ - delta = 0; - vpdiff = (step >> 3); - - if ( diff >= step ) { - delta = 4; - diff -= step; - vpdiff += step; - } - step >>= 1; - if ( diff >= step ) { - delta |= 2; - diff -= step; - vpdiff += step; - } - step >>= 1; - if ( diff >= step ) { - delta |= 1; - vpdiff += step; - } - - /* Step 3 - Update previous value */ - if ( sign ) - valpred -= vpdiff; - else - valpred += vpdiff; - - /* Step 4 - Clamp previous value to 16 bits */ - if ( valpred > 32767 ) - valpred = 32767; - else if ( valpred < -32768 ) - valpred = -32768; - - /* Step 5 - Assemble value, update index and step values */ - delta |= sign; - - index += indexTable[delta]; - if ( index < 0 ) index = 0; - if ( index > 88 ) index = 88; - step = stepsizeTable[index]; - - /* Step 6 - Output value */ - if ( bufferstep ) { - outputbuffer = (delta << 4) & 0xf0; - } else { - *ncp++ = (delta & 0x0f) | outputbuffer; - } - bufferstep = !bufferstep; - } - rv = Py_BuildValue("(O(ii))", str, valpred, index); - Py_DECREF(str); - return rv; -} - -static PyObject * -audioop_adpcm2lin(PyObject *self, PyObject *args) -{ - signed char *cp; - signed char *ncp; - int len, size, valpred, step, delta, index, sign, vpdiff; - PyObject *rv, *str, *state; - int i, inputbuffer = 0, bufferstep; - - if ( !PyArg_Parse(args, "(s#iO)", - &cp, &len, &size, &state) ) - return 0; - - if ( size != 1 && size != 2 && size != 4) { - PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); - return 0; - } - - /* Decode state, should have (value, step) */ - if ( state == Py_None ) { - /* First time, it seems. Set defaults */ - valpred = 0; - step = 7; - index = 0; - } else if ( !PyArg_Parse(state, "(ii)", &valpred, &index) ) - return 0; - - str = PyString_FromStringAndSize(NULL, len*size*2); - if ( str == 0 ) - return 0; - ncp = (signed char *)PyString_AsString(str); - - step = stepsizeTable[index]; - bufferstep = 0; - - for ( i=0; i < len*size*2; i += size ) { - /* Step 1 - get the delta value and compute next index */ - if ( bufferstep ) { - delta = inputbuffer & 0xf; - } else { - inputbuffer = *cp++; - delta = (inputbuffer >> 4) & 0xf; - } - - bufferstep = !bufferstep; - - /* Step 2 - Find new index value (for later) */ - index += indexTable[delta]; - if ( index < 0 ) index = 0; - if ( index > 88 ) index = 88; - - /* Step 3 - Separate sign and magnitude */ - sign = delta & 8; - delta = delta & 7; - - /* Step 4 - Compute difference and new predicted value */ - /* - ** Computes 'vpdiff = (delta+0.5)*step/4', but see comment - ** in adpcm_coder. - */ - vpdiff = step >> 3; - if ( delta & 4 ) vpdiff += step; - if ( delta & 2 ) vpdiff += step>>1; - if ( delta & 1 ) vpdiff += step>>2; - - if ( sign ) - valpred -= vpdiff; - else - valpred += vpdiff; - - /* Step 5 - clamp output value */ - if ( valpred > 32767 ) - valpred = 32767; - else if ( valpred < -32768 ) - valpred = -32768; - - /* Step 6 - Update step value */ - step = stepsizeTable[index]; - - /* Step 6 - Output value */ - if ( size == 1 ) *CHARP(ncp, i) = (signed char)(valpred >> 8); - else if ( size == 2 ) *SHORTP(ncp, i) = (short)(valpred); - else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)(valpred<<16); - } - - rv = Py_BuildValue("(O(ii))", str, valpred, index); - Py_DECREF(str); - return rv; -} - -static PyMethodDef audioop_methods[] = { - { "max", audioop_max, METH_OLDARGS }, - { "minmax", audioop_minmax, METH_OLDARGS }, - { "avg", audioop_avg, METH_OLDARGS }, - { "maxpp", audioop_maxpp, METH_OLDARGS }, - { "avgpp", audioop_avgpp, METH_OLDARGS }, - { "rms", audioop_rms, METH_OLDARGS }, - { "findfit", audioop_findfit, METH_OLDARGS }, - { "findmax", audioop_findmax, METH_OLDARGS }, - { "findfactor", audioop_findfactor, METH_OLDARGS }, - { "cross", audioop_cross, METH_OLDARGS }, - { "mul", audioop_mul, METH_OLDARGS }, - { "add", audioop_add, METH_OLDARGS }, - { "bias", audioop_bias, METH_OLDARGS }, - { "ulaw2lin", audioop_ulaw2lin, METH_OLDARGS }, - { "lin2ulaw", audioop_lin2ulaw, METH_OLDARGS }, - { "lin2lin", audioop_lin2lin, METH_OLDARGS }, - { "adpcm2lin", audioop_adpcm2lin, METH_OLDARGS }, - { "lin2adpcm", audioop_lin2adpcm, METH_OLDARGS }, - { "tomono", audioop_tomono, METH_OLDARGS }, - { "tostereo", audioop_tostereo, METH_OLDARGS }, - { "getsample", audioop_getsample, METH_OLDARGS }, - { "reverse", audioop_reverse, METH_OLDARGS }, - { "ratecv", audioop_ratecv, METH_VARARGS }, - { 0, 0 } -}; - -PyMODINIT_FUNC -initaudioop(void) -{ - PyObject *m, *d; - m = Py_InitModule("audioop", audioop_methods); - d = PyModule_GetDict(m); - AudioopError = PyErr_NewException("audioop.error", NULL, NULL); - if (AudioopError != NULL) - PyDict_SetItemString(d,"error",AudioopError); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/binascii.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/binascii.c deleted file mode 100644 index 15d5e785..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/binascii.c +++ /dev/null @@ -1,1337 +0,0 @@ -/* -** Routines to represent binary data in ASCII and vice-versa -** -** This module currently supports the following encodings: -** uuencode: -** each line encodes 45 bytes (except possibly the last) -** First char encodes (binary) length, rest data -** each char encodes 6 bits, as follows: -** binary: 01234567 abcdefgh ijklmnop -** ascii: 012345 67abcd efghij klmnop -** ASCII encoding method is "excess-space": 000000 is encoded as ' ', etc. -** short binary data is zero-extended (so the bits are always in the -** right place), this does *not* reflect in the length. -** base64: -** Line breaks are insignificant, but lines are at most 76 chars -** each char encodes 6 bits, in similar order as uucode/hqx. Encoding -** is done via a table. -** Short binary data is filled (in ASCII) with '='. -** hqx: -** File starts with introductory text, real data starts and ends -** with colons. -** Data consists of three similar parts: info, datafork, resourcefork. -** Each part is protected (at the end) with a 16-bit crc -** The binary data is run-length encoded, and then ascii-fied: -** binary: 01234567 abcdefgh ijklmnop -** ascii: 012345 67abcd efghij klmnop -** ASCII encoding is table-driven, see the code. -** Short binary data results in the runt ascii-byte being output with -** the bits in the right place. -** -** While I was reading dozens of programs that encode or decode the formats -** here (documentation? hihi:-) I have formulated Jansen's Observation: -** -** Programs that encode binary data in ASCII are written in -** such a style that they are as unreadable as possible. Devices used -** include unnecessary global variables, burying important tables -** in unrelated sourcefiles, putting functions in include files, -** using seemingly-descriptive variable names for different purposes, -** calls to empty subroutines and a host of others. -** -** I have attempted to break with this tradition, but I guess that that -** does make the performance sub-optimal. Oh well, too bad... -** -** Jack Jansen, CWI, July 1995. -** -** Added support for quoted-printable encoding, based on rfc 1521 et al -** quoted-printable encoding specifies that non printable characters (anything -** below 32 and above 126) be encoded as =XX where XX is the hexadecimal value -** of the character. It also specifies some other behavior to enable 8bit data -** in a mail message with little difficulty (maximum line sizes, protecting -** some cases of whitespace, etc). -** -** Brandon Long, September 2001. -*/ - - -#include "Python.h" - -static PyObject *Error; -static PyObject *Incomplete; - -/* -** hqx lookup table, ascii->binary. -*/ - -#define RUNCHAR 0x90 - -#define DONE 0x7F -#define SKIP 0x7E -#define FAIL 0x7D - -static unsigned char table_a2b_hqx[256] = { -/* ^@ ^A ^B ^C ^D ^E ^F ^G */ -/* 0*/ FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, -/* \b \t \n ^K ^L \r ^N ^O */ -/* 1*/ FAIL, FAIL, SKIP, FAIL, FAIL, SKIP, FAIL, FAIL, -/* ^P ^Q ^R ^S ^T ^U ^V ^W */ -/* 2*/ FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, -/* ^X ^Y ^Z ^[ ^\ ^] ^^ ^_ */ -/* 3*/ FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, -/* ! " # $ % & ' */ -/* 4*/ FAIL, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, -/* ( ) * + , - . / */ -/* 5*/ 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, FAIL, FAIL, -/* 0 1 2 3 4 5 6 7 */ -/* 6*/ 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, FAIL, -/* 8 9 : ; < = > ? */ -/* 7*/ 0x14, 0x15, DONE, FAIL, FAIL, FAIL, FAIL, FAIL, -/* @ A B C D E F G */ -/* 8*/ 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, -/* H I J K L M N O */ -/* 9*/ 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, FAIL, -/* P Q R S T U V W */ -/*10*/ 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, FAIL, -/* X Y Z [ \ ] ^ _ */ -/*11*/ 0x2C, 0x2D, 0x2E, 0x2F, FAIL, FAIL, FAIL, FAIL, -/* ` a b c d e f g */ -/*12*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, FAIL, -/* h i j k l m n o */ -/*13*/ 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, FAIL, FAIL, -/* p q r s t u v w */ -/*14*/ 0x3D, 0x3E, 0x3F, FAIL, FAIL, FAIL, FAIL, FAIL, -/* x y z { | } ~ ^? */ -/*15*/ FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, -/*16*/ FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, - FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, -}; - -static unsigned char table_b2a_hqx[] = -"!\"#$%&'()*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr"; - -static char table_a2b_base64[] = { - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63, - 52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1, 0,-1,-1, /* Note PAD->0 */ - -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14, - 15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1, - -1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40, - 41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1 -}; - -#define BASE64_PAD '=' - -/* Max binary chunk size; limited only by available memory */ -#define BASE64_MAXBIN (INT_MAX/2 - sizeof(PyStringObject) - 3) - -static unsigned char table_b2a_base64[] = -"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - - -static unsigned short crctab_hqx[256] = { - 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, - 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, - 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, - 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, - 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, - 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, - 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, - 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, - 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, - 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, - 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, - 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, - 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, - 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, - 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, - 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, - 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, - 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, - 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, - 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, - 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, - 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, - 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, - 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, - 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, - 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, - 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, - 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, - 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, - 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, - 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, - 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0, -}; - -PyDoc_STRVAR(doc_a2b_uu, "(ascii) -> bin. Decode a line of uuencoded data"); - -static PyObject * -binascii_a2b_uu(PyObject *self, PyObject *args) -{ - unsigned char *ascii_data, *bin_data; - int leftbits = 0; - unsigned char this_ch; - unsigned int leftchar = 0; - PyObject *rv; - int ascii_len, bin_len; - - if ( !PyArg_ParseTuple(args, "t#:a2b_uu", &ascii_data, &ascii_len) ) - return NULL; - - /* First byte: binary data length (in bytes) */ - bin_len = (*ascii_data++ - ' ') & 077; - ascii_len--; - - /* Allocate the buffer */ - if ( (rv=PyString_FromStringAndSize(NULL, bin_len)) == NULL ) - return NULL; - bin_data = (unsigned char *)PyString_AsString(rv); - - for( ; bin_len > 0 ; ascii_len--, ascii_data++ ) { - this_ch = *ascii_data; - if ( this_ch == '\n' || this_ch == '\r' || ascii_len <= 0) { - /* - ** Whitespace. Assume some spaces got eaten at - ** end-of-line. (We check this later) - */ - this_ch = 0; - } else { - /* Check the character for legality - ** The 64 in stead of the expected 63 is because - ** there are a few uuencodes out there that use - ** '`' as zero instead of space. - */ - if ( this_ch < ' ' || this_ch > (' ' + 64)) { - PyErr_SetString(Error, "Illegal char"); - Py_DECREF(rv); - return NULL; - } - this_ch = (this_ch - ' ') & 077; - } - /* - ** Shift it in on the low end, and see if there's - ** a byte ready for output. - */ - leftchar = (leftchar << 6) | (this_ch); - leftbits += 6; - if ( leftbits >= 8 ) { - leftbits -= 8; - *bin_data++ = (leftchar >> leftbits) & 0xff; - leftchar &= ((1 << leftbits) - 1); - bin_len--; - } - } - /* - ** Finally, check that if there's anything left on the line - ** that it's whitespace only. - */ - while( ascii_len-- > 0 ) { - this_ch = *ascii_data++; - /* Extra '`' may be written as padding in some cases */ - if ( this_ch != ' ' && this_ch != ' '+64 && - this_ch != '\n' && this_ch != '\r' ) { - PyErr_SetString(Error, "Trailing garbage"); - Py_DECREF(rv); - return NULL; - } - } - return rv; -} - -PyDoc_STRVAR(doc_b2a_uu, "(bin) -> ascii. Uuencode line of data"); - -static PyObject * -binascii_b2a_uu(PyObject *self, PyObject *args) -{ - unsigned char *ascii_data, *bin_data; - int leftbits = 0; - unsigned char this_ch; - unsigned int leftchar = 0; - PyObject *rv; - int bin_len; - - if ( !PyArg_ParseTuple(args, "s#:b2a_uu", &bin_data, &bin_len) ) - return NULL; - if ( bin_len > 45 ) { - /* The 45 is a limit that appears in all uuencode's */ - PyErr_SetString(Error, "At most 45 bytes at once"); - return NULL; - } - - /* We're lazy and allocate to much (fixed up later) */ - if ( (rv=PyString_FromStringAndSize(NULL, bin_len*2)) == NULL ) - return NULL; - ascii_data = (unsigned char *)PyString_AsString(rv); - - /* Store the length */ - *ascii_data++ = ' ' + (bin_len & 077); - - for( ; bin_len > 0 || leftbits != 0 ; bin_len--, bin_data++ ) { - /* Shift the data (or padding) into our buffer */ - if ( bin_len > 0 ) /* Data */ - leftchar = (leftchar << 8) | *bin_data; - else /* Padding */ - leftchar <<= 8; - leftbits += 8; - - /* See if there are 6-bit groups ready */ - while ( leftbits >= 6 ) { - this_ch = (leftchar >> (leftbits-6)) & 0x3f; - leftbits -= 6; - *ascii_data++ = this_ch + ' '; - } - } - *ascii_data++ = '\n'; /* Append a courtesy newline */ - - _PyString_Resize(&rv, (ascii_data - - (unsigned char *)PyString_AsString(rv))); - return rv; -} - - -static int -binascii_find_valid(unsigned char *s, int slen, int num) -{ - /* Finds & returns the (num+1)th - ** valid character for base64, or -1 if none. - */ - - int ret = -1; - unsigned char c, b64val; - - while ((slen > 0) && (ret == -1)) { - c = *s; - b64val = table_a2b_base64[c & 0x7f]; - if ( ((c <= 0x7f) && (b64val != (unsigned char)-1)) ) { - if (num == 0) - ret = *s; - num--; - } - - s++; - slen--; - } - return ret; -} - -PyDoc_STRVAR(doc_a2b_base64, "(ascii) -> bin. Decode a line of base64 data"); - -static PyObject * -binascii_a2b_base64(PyObject *self, PyObject *args) -{ - unsigned char *ascii_data, *bin_data; - int leftbits = 0; - unsigned char this_ch; - unsigned int leftchar = 0; - PyObject *rv; - int ascii_len, bin_len; - int quad_pos = 0; - - if ( !PyArg_ParseTuple(args, "t#:a2b_base64", &ascii_data, &ascii_len) ) - return NULL; - - bin_len = ((ascii_len+3)/4)*3; /* Upper bound, corrected later */ - - /* Allocate the buffer */ - if ( (rv=PyString_FromStringAndSize(NULL, bin_len)) == NULL ) - return NULL; - bin_data = (unsigned char *)PyString_AsString(rv); - bin_len = 0; - - for( ; ascii_len > 0; ascii_len--, ascii_data++) { - this_ch = *ascii_data; - - if (this_ch > 0x7f || - this_ch == '\r' || this_ch == '\n' || this_ch == ' ') - continue; - - /* Check for pad sequences and ignore - ** the invalid ones. - */ - if (this_ch == BASE64_PAD) { - if ( (quad_pos < 2) || - ((quad_pos == 2) && - (binascii_find_valid(ascii_data, ascii_len, 1) - != BASE64_PAD)) ) - { - continue; - } - else { - /* A pad sequence means no more input. - ** We've already interpreted the data - ** from the quad at this point. - */ - leftbits = 0; - break; - } - } - - this_ch = table_a2b_base64[*ascii_data]; - if ( this_ch == (unsigned char) -1 ) - continue; - - /* - ** Shift it in on the low end, and see if there's - ** a byte ready for output. - */ - quad_pos = (quad_pos + 1) & 0x03; - leftchar = (leftchar << 6) | (this_ch); - leftbits += 6; - - if ( leftbits >= 8 ) { - leftbits -= 8; - *bin_data++ = (leftchar >> leftbits) & 0xff; - bin_len++; - leftchar &= ((1 << leftbits) - 1); - } - } - - if (leftbits != 0) { - PyErr_SetString(Error, "Incorrect padding"); - Py_DECREF(rv); - return NULL; - } - - /* And set string size correctly. If the result string is empty - ** (because the input was all invalid) return the shared empty - ** string instead; _PyString_Resize() won't do this for us. - */ - if (bin_len > 0) - _PyString_Resize(&rv, bin_len); - else { - Py_DECREF(rv); - rv = PyString_FromString(""); - } - return rv; -} - -PyDoc_STRVAR(doc_b2a_base64, "(bin) -> ascii. Base64-code line of data"); - -static PyObject * -binascii_b2a_base64(PyObject *self, PyObject *args) -{ - unsigned char *ascii_data, *bin_data; - int leftbits = 0; - unsigned char this_ch; - unsigned int leftchar = 0; - PyObject *rv; - int bin_len; - - if ( !PyArg_ParseTuple(args, "s#:b2a_base64", &bin_data, &bin_len) ) - return NULL; - if ( bin_len > BASE64_MAXBIN ) { - PyErr_SetString(Error, "Too much data for base64 line"); - return NULL; - } - - /* We're lazy and allocate too much (fixed up later). - "+3" leaves room for up to two pad characters and a trailing - newline. Note that 'b' gets encoded as 'Yg==\n' (1 in, 5 out). */ - if ( (rv=PyString_FromStringAndSize(NULL, bin_len*2 + 3)) == NULL ) - return NULL; - ascii_data = (unsigned char *)PyString_AsString(rv); - - for( ; bin_len > 0 ; bin_len--, bin_data++ ) { - /* Shift the data into our buffer */ - leftchar = (leftchar << 8) | *bin_data; - leftbits += 8; - - /* See if there are 6-bit groups ready */ - while ( leftbits >= 6 ) { - this_ch = (leftchar >> (leftbits-6)) & 0x3f; - leftbits -= 6; - *ascii_data++ = table_b2a_base64[this_ch]; - } - } - if ( leftbits == 2 ) { - *ascii_data++ = table_b2a_base64[(leftchar&3) << 4]; - *ascii_data++ = BASE64_PAD; - *ascii_data++ = BASE64_PAD; - } else if ( leftbits == 4 ) { - *ascii_data++ = table_b2a_base64[(leftchar&0xf) << 2]; - *ascii_data++ = BASE64_PAD; - } - *ascii_data++ = '\n'; /* Append a courtesy newline */ - - _PyString_Resize(&rv, (ascii_data - - (unsigned char *)PyString_AsString(rv))); - return rv; -} - -PyDoc_STRVAR(doc_a2b_hqx, "ascii -> bin, done. Decode .hqx coding"); - -static PyObject * -binascii_a2b_hqx(PyObject *self, PyObject *args) -{ - unsigned char *ascii_data, *bin_data; - int leftbits = 0; - unsigned char this_ch; - unsigned int leftchar = 0; - PyObject *rv; - int len; - int done = 0; - - if ( !PyArg_ParseTuple(args, "t#:a2b_hqx", &ascii_data, &len) ) - return NULL; - - /* Allocate a string that is too big (fixed later) */ - if ( (rv=PyString_FromStringAndSize(NULL, len)) == NULL ) - return NULL; - bin_data = (unsigned char *)PyString_AsString(rv); - - for( ; len > 0 ; len--, ascii_data++ ) { - /* Get the byte and look it up */ - this_ch = table_a2b_hqx[*ascii_data]; - if ( this_ch == SKIP ) - continue; - if ( this_ch == FAIL ) { - PyErr_SetString(Error, "Illegal char"); - Py_DECREF(rv); - return NULL; - } - if ( this_ch == DONE ) { - /* The terminating colon */ - done = 1; - break; - } - - /* Shift it into the buffer and see if any bytes are ready */ - leftchar = (leftchar << 6) | (this_ch); - leftbits += 6; - if ( leftbits >= 8 ) { - leftbits -= 8; - *bin_data++ = (leftchar >> leftbits) & 0xff; - leftchar &= ((1 << leftbits) - 1); - } - } - - if ( leftbits && !done ) { - PyErr_SetString(Incomplete, - "String has incomplete number of bytes"); - Py_DECREF(rv); - return NULL; - } - _PyString_Resize( - &rv, (bin_data - (unsigned char *)PyString_AsString(rv))); - if (rv) { - PyObject *rrv = Py_BuildValue("Oi", rv, done); - Py_DECREF(rv); - return rrv; - } - - return NULL; -} - -PyDoc_STRVAR(doc_rlecode_hqx, "Binhex RLE-code binary data"); - -static PyObject * -binascii_rlecode_hqx(PyObject *self, PyObject *args) -{ - unsigned char *in_data, *out_data; - PyObject *rv; - unsigned char ch; - int in, inend, len; - - if ( !PyArg_ParseTuple(args, "s#:rlecode_hqx", &in_data, &len) ) - return NULL; - - /* Worst case: output is twice as big as input (fixed later) */ - if ( (rv=PyString_FromStringAndSize(NULL, len*2)) == NULL ) - return NULL; - out_data = (unsigned char *)PyString_AsString(rv); - - for( in=0; in 3 ) { - /* More than 3 in a row. Output RLE. */ - *out_data++ = ch; - *out_data++ = RUNCHAR; - *out_data++ = inend-in; - in = inend-1; - } else { - /* Less than 3. Output the byte itself */ - *out_data++ = ch; - } - } - } - _PyString_Resize(&rv, (out_data - - (unsigned char *)PyString_AsString(rv))); - return rv; -} - -PyDoc_STRVAR(doc_b2a_hqx, "Encode .hqx data"); - -static PyObject * -binascii_b2a_hqx(PyObject *self, PyObject *args) -{ - unsigned char *ascii_data, *bin_data; - int leftbits = 0; - unsigned char this_ch; - unsigned int leftchar = 0; - PyObject *rv; - int len; - - if ( !PyArg_ParseTuple(args, "s#:b2a_hqx", &bin_data, &len) ) - return NULL; - - /* Allocate a buffer that is at least large enough */ - if ( (rv=PyString_FromStringAndSize(NULL, len*2)) == NULL ) - return NULL; - ascii_data = (unsigned char *)PyString_AsString(rv); - - for( ; len > 0 ; len--, bin_data++ ) { - /* Shift into our buffer, and output any 6bits ready */ - leftchar = (leftchar << 8) | *bin_data; - leftbits += 8; - while ( leftbits >= 6 ) { - this_ch = (leftchar >> (leftbits-6)) & 0x3f; - leftbits -= 6; - *ascii_data++ = table_b2a_hqx[this_ch]; - } - } - /* Output a possible runt byte */ - if ( leftbits ) { - leftchar <<= (6-leftbits); - *ascii_data++ = table_b2a_hqx[leftchar & 0x3f]; - } - _PyString_Resize(&rv, (ascii_data - - (unsigned char *)PyString_AsString(rv))); - return rv; -} - -PyDoc_STRVAR(doc_rledecode_hqx, "Decode hexbin RLE-coded string"); - -static PyObject * -binascii_rledecode_hqx(PyObject *self, PyObject *args) -{ - unsigned char *in_data, *out_data; - unsigned char in_byte, in_repeat; - PyObject *rv; - int in_len, out_len, out_len_left; - - if ( !PyArg_ParseTuple(args, "s#:rledecode_hqx", &in_data, &in_len) ) - return NULL; - - /* Empty string is a special case */ - if ( in_len == 0 ) - return Py_BuildValue("s", ""); - - /* Allocate a buffer of reasonable size. Resized when needed */ - out_len = in_len*2; - if ( (rv=PyString_FromStringAndSize(NULL, out_len)) == NULL ) - return NULL; - out_len_left = out_len; - out_data = (unsigned char *)PyString_AsString(rv); - - /* - ** We need two macros here to get/put bytes and handle - ** end-of-buffer for input and output strings. - */ -#define INBYTE(b) \ - do { \ - if ( --in_len < 0 ) { \ - PyErr_SetString(Incomplete, ""); \ - Py_DECREF(rv); \ - return NULL; \ - } \ - b = *in_data++; \ - } while(0) - -#define OUTBYTE(b) \ - do { \ - if ( --out_len_left < 0 ) { \ - _PyString_Resize(&rv, 2*out_len); \ - if ( rv == NULL ) return NULL; \ - out_data = (unsigned char *)PyString_AsString(rv) \ - + out_len; \ - out_len_left = out_len-1; \ - out_len = out_len * 2; \ - } \ - *out_data++ = b; \ - } while(0) - - /* - ** Handle first byte separately (since we have to get angry - ** in case of an orphaned RLE code). - */ - INBYTE(in_byte); - - if (in_byte == RUNCHAR) { - INBYTE(in_repeat); - if (in_repeat != 0) { - /* Note Error, not Incomplete (which is at the end - ** of the string only). This is a programmer error. - */ - PyErr_SetString(Error, "Orphaned RLE code at start"); - Py_DECREF(rv); - return NULL; - } - OUTBYTE(RUNCHAR); - } else { - OUTBYTE(in_byte); - } - - while( in_len > 0 ) { - INBYTE(in_byte); - - if (in_byte == RUNCHAR) { - INBYTE(in_repeat); - if ( in_repeat == 0 ) { - /* Just an escaped RUNCHAR value */ - OUTBYTE(RUNCHAR); - } else { - /* Pick up value and output a sequence of it */ - in_byte = out_data[-1]; - while ( --in_repeat > 0 ) - OUTBYTE(in_byte); - } - } else { - /* Normal byte */ - OUTBYTE(in_byte); - } - } - _PyString_Resize(&rv, (out_data - - (unsigned char *)PyString_AsString(rv))); - return rv; -} - -PyDoc_STRVAR(doc_crc_hqx, -"(data, oldcrc) -> newcrc. Compute hqx CRC incrementally"); - -static PyObject * -binascii_crc_hqx(PyObject *self, PyObject *args) -{ - unsigned char *bin_data; - unsigned int crc; - int len; - - if ( !PyArg_ParseTuple(args, "s#i:crc_hqx", &bin_data, &len, &crc) ) - return NULL; - - while(len--) { - crc=((crc<<8)&0xff00)^crctab_hqx[((crc>>8)&0xff)^*bin_data++]; - } - - return Py_BuildValue("i", crc); -} - -PyDoc_STRVAR(doc_crc32, -"(data, oldcrc = 0) -> newcrc. Compute CRC-32 incrementally"); - -/* Crc - 32 BIT ANSI X3.66 CRC checksum files - Also known as: ISO 3307 -**********************************************************************| -* *| -* Demonstration program to compute the 32-bit CRC used as the frame *| -* check sequence in ADCCP (ANSI X3.66, also known as FIPS PUB 71 *| -* and FED-STD-1003, the U.S. versions of CCITT's X.25 link-level *| -* protocol). The 32-bit FCS was added via the Federal Register, *| -* 1 June 1982, p.23798. I presume but don't know for certain that *| -* this polynomial is or will be included in CCITT V.41, which *| -* defines the 16-bit CRC (often called CRC-CCITT) polynomial. FIPS *| -* PUB 78 says that the 32-bit FCS reduces otherwise undetected *| -* errors by a factor of 10^-5 over 16-bit FCS. *| -* *| -**********************************************************************| - - Copyright (C) 1986 Gary S. Brown. You may use this program, or - code or tables extracted from it, as desired without restriction. - - First, the polynomial itself and its table of feedback terms. The - polynomial is - X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 - Note that we take it "backwards" and put the highest-order term in - the lowest-order bit. The X^32 term is "implied"; the LSB is the - X^31 term, etc. The X^0 term (usually shown as "+1") results in - the MSB being 1. - - Note that the usual hardware shift register implementation, which - is what we're using (we're merely optimizing it by doing eight-bit - chunks at a time) shifts bits into the lowest-order term. In our - implementation, that means shifting towards the right. Why do we - do it this way? Because the calculated CRC must be transmitted in - order from highest-order term to lowest-order term. UARTs transmit - characters in order from LSB to MSB. By storing the CRC this way, - we hand it to the UART in the order low-byte to high-byte; the UART - sends each low-bit to hight-bit; and the result is transmission bit - by bit from highest- to lowest-order term without requiring any bit - shuffling on our part. Reception works similarly. - - The feedback terms table consists of 256, 32-bit entries. Notes: - - 1. The table can be generated at runtime if desired; code to do so - is shown later. It might not be obvious, but the feedback - terms simply represent the results of eight shift/xor opera- - tions for all combinations of data and CRC register values. - - 2. The CRC accumulation logic is the same for all CRC polynomials, - be they sixteen or thirty-two bits wide. You simply choose the - appropriate table. Alternatively, because the table can be - generated at runtime, you can start by generating the table for - the polynomial in question and use exactly the same "updcrc", - if your application needn't simultaneously handle two CRC - polynomials. (Note, however, that XMODEM is strange.) - - 3. For 16-bit CRCs, the table entries need be only 16 bits wide; - of course, 32-bit entries work OK if the high 16 bits are zero. - - 4. The values must be right-shifted by eight bits by the "updcrc" - logic; the shift must be unsigned (bring in zeroes). On some - hardware you could probably optimize the shift in assembler by - using byte-swap instructions. -********************************************************************/ - -static unsigned long crc_32_tab[256] = { -0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, -0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, -0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, -0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, -0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, -0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, -0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, -0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, -0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, -0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, -0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, -0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, -0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, -0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, -0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, -0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, -0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, -0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, -0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, -0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, -0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, -0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, -0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, -0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, -0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, -0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, -0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, -0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, -0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, -0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, -0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, -0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, -0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, -0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, -0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, -0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, -0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, -0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, -0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, -0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, -0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, -0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, -0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, -0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, -0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, -0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, -0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, -0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, -0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, -0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, -0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, -0x2d02ef8dUL -}; - -static PyObject * -binascii_crc32(PyObject *self, PyObject *args) -{ /* By Jim Ahlstrom; All rights transferred to CNRI */ - unsigned char *bin_data; - unsigned long crc = 0UL; /* initial value of CRC */ - int len; - long result; - - if ( !PyArg_ParseTuple(args, "s#|l:crc32", &bin_data, &len, &crc) ) - return NULL; - - crc = ~ crc; -#if SIZEOF_LONG > 4 - /* only want the trailing 32 bits */ - crc &= 0xFFFFFFFFUL; -#endif - while (len--) - crc = crc_32_tab[(crc ^ *bin_data++) & 0xffUL] ^ (crc >> 8); - /* Note: (crc >> 8) MUST zero fill on left */ - - result = (long)(crc ^ 0xFFFFFFFFUL); -#if SIZEOF_LONG > 4 - /* Extend the sign bit. This is one way to ensure the result is the - * same across platforms. The other way would be to return an - * unbounded unsigned long, but the evidence suggests that lots of - * code outside this treats the result as if it were a signed 4-byte - * integer. - */ - result |= -(result & (1L << 31)); -#endif - return PyInt_FromLong(result); -} - - -static PyObject * -binascii_hexlify(PyObject *self, PyObject *args) -{ - char* argbuf; - int arglen; - PyObject *retval; - char* retbuf; - int i, j; - - if (!PyArg_ParseTuple(args, "t#:b2a_hex", &argbuf, &arglen)) - return NULL; - - retval = PyString_FromStringAndSize(NULL, arglen*2); - if (!retval) - return NULL; - retbuf = PyString_AsString(retval); - if (!retbuf) - goto finally; - - /* make hex version of string, taken from shamodule.c */ - for (i=j=0; i < arglen; i++) { - char c; - c = (argbuf[i] >> 4) & 0xf; - c = (c>9) ? c+'a'-10 : c + '0'; - retbuf[j++] = c; - c = argbuf[i] & 0xf; - c = (c>9) ? c+'a'-10 : c + '0'; - retbuf[j++] = c; - } - return retval; - - finally: - Py_DECREF(retval); - return NULL; -} - -PyDoc_STRVAR(doc_hexlify, -"b2a_hex(data) -> s; Hexadecimal representation of binary data.\n\ -\n\ -This function is also available as \"hexlify()\"."); - - -static int -to_int(int c) -{ - if (isdigit(c)) - return c - '0'; - else { - if (isupper(c)) - c = tolower(c); - if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - } - return -1; -} - - -static PyObject * -binascii_unhexlify(PyObject *self, PyObject *args) -{ - char* argbuf; - int arglen; - PyObject *retval; - char* retbuf; - int i, j; - - if (!PyArg_ParseTuple(args, "s#:a2b_hex", &argbuf, &arglen)) - return NULL; - - /* XXX What should we do about strings with an odd length? Should - * we add an implicit leading zero, or a trailing zero? For now, - * raise an exception. - */ - if (arglen % 2) { - PyErr_SetString(PyExc_TypeError, "Odd-length string"); - return NULL; - } - - retval = PyString_FromStringAndSize(NULL, (arglen/2)); - if (!retval) - return NULL; - retbuf = PyString_AsString(retval); - if (!retbuf) - goto finally; - - for (i=j=0; i < arglen; i += 2) { - int top = to_int(Py_CHARMASK(argbuf[i])); - int bot = to_int(Py_CHARMASK(argbuf[i+1])); - if (top == -1 || bot == -1) { - PyErr_SetString(PyExc_TypeError, - "Non-hexadecimal digit found"); - goto finally; - } - retbuf[j++] = (top << 4) + bot; - } - return retval; - - finally: - Py_DECREF(retval); - return NULL; -} - -PyDoc_STRVAR(doc_unhexlify, -"a2b_hex(hexstr) -> s; Binary data of hexadecimal representation.\n\ -\n\ -hexstr must contain an even number of hex digits (upper or lower case).\n\ -This function is also available as \"unhexlify()\""); - -static int table_hex[128] = { - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1, -1,-1,-1,-1, - -1,10,11,12, 13,14,15,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,10,11,12, 13,14,15,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1 -}; - -#define hexval(c) table_hex[(unsigned int)(c)] - -#define MAXLINESIZE 76 - -PyDoc_STRVAR(doc_a2b_qp, "Decode a string of qp-encoded data"); - -static PyObject* -binascii_a2b_qp(PyObject *self, PyObject *args, PyObject *kwargs) -{ - unsigned int in, out; - char ch; - unsigned char *data, *odata; - unsigned int datalen = 0; - PyObject *rv; - static char *kwlist[] = {"data", "header", NULL}; - int header = 0; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|i", kwlist, &data, - &datalen, &header)) - return NULL; - - /* We allocate the output same size as input, this is overkill */ - odata = (unsigned char *) calloc(1, datalen); - - if (odata == NULL) { - PyErr_NoMemory(); - return NULL; - } - - in = out = 0; - while (in < datalen) { - if (data[in] == '=') { - in++; - if (in >= datalen) break; - /* Soft line breaks */ - if ((data[in] == '\n') || (data[in] == '\r') || - (data[in] == ' ') || (data[in] == '\t')) { - if (data[in] != '\n') { - while (in < datalen && data[in] != '\n') in++; - } - if (in < datalen) in++; - } - else if (data[in] == '=') { - /* broken case from broken python qp */ - odata[out++] = '='; - in++; - } - else if (((data[in] >= 'A' && data[in] <= 'F') || - (data[in] >= 'a' && data[in] <= 'f') || - (data[in] >= '0' && data[in] <= '9')) && - ((data[in+1] >= 'A' && data[in+1] <= 'F') || - (data[in+1] >= 'a' && data[in+1] <= 'f') || - (data[in+1] >= '0' && data[in+1] <= '9'))) { - /* hexval */ - ch = hexval(data[in]) << 4; - in++; - ch |= hexval(data[in]); - in++; - odata[out++] = ch; - } - else { - odata[out++] = '='; - } - } - else if (header && data[in] == '_') { - odata[out++] = ' '; - in++; - } - else { - odata[out] = data[in]; - in++; - out++; - } - } - if ((rv = PyString_FromStringAndSize((char *)odata, out)) == NULL) { - free (odata); - return NULL; - } - free (odata); - return rv; -} - -static int -to_hex (unsigned char ch, unsigned char *s) -{ - unsigned int uvalue = ch; - - s[1] = "0123456789ABCDEF"[uvalue % 16]; - uvalue = (uvalue / 16); - s[0] = "0123456789ABCDEF"[uvalue % 16]; - return 0; -} - -PyDoc_STRVAR(doc_b2a_qp, -"b2a_qp(data, quotetabs=0, istext=1, header=0) -> s; \n\ - Encode a string using quoted-printable encoding. \n\ -\n\ -On encoding, when istext is set, newlines are not encoded, and white \n\ -space at end of lines is. When istext is not set, \\r and \\n (CR/LF) are \n\ -both encoded. When quotetabs is set, space and tabs are encoded."); - -/* XXX: This is ridiculously complicated to be backward compatible - * (mostly) with the quopri module. It doesn't re-create the quopri - * module bug where text ending in CRLF has the CR encoded */ -static PyObject* -binascii_b2a_qp (PyObject *self, PyObject *args, PyObject *kwargs) -{ - unsigned int in, out; - unsigned char *data, *odata; - unsigned int datalen = 0, odatalen = 0; - PyObject *rv; - unsigned int linelen = 0; - static char *kwlist[] = {"data", "quotetabs", "istext", "header", NULL}; - int istext = 1; - int quotetabs = 0; - int header = 0; - unsigned char ch; - int crlf = 0; - unsigned char *p; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|iii", kwlist, &data, - &datalen, "etabs, &istext, &header)) - return NULL; - - /* See if this string is using CRLF line ends */ - /* XXX: this function has the side effect of converting all of - * the end of lines to be the same depending on this detection - * here */ - p = (unsigned char *) strchr((char *)data, '\n'); - if ((p != NULL) && (p > data) && (*(p-1) == '\r')) - crlf = 1; - - /* First, scan to see how many characters need to be encoded */ - in = 0; - while (in < datalen) { - if ((data[in] > 126) || - (data[in] == '=') || - (header && data[in] == '_') || - ((data[in] == '.') && (linelen == 1)) || - (!istext && ((data[in] == '\r') || (data[in] == '\n'))) || - ((data[in] == '\t' || data[in] == ' ') && (in + 1 == datalen)) || - ((data[in] < 33) && - (data[in] != '\r') && (data[in] != '\n') && - (quotetabs && ((data[in] != '\t') || (data[in] != ' '))))) - { - if ((linelen + 3) >= MAXLINESIZE) { - linelen = 0; - if (crlf) - odatalen += 3; - else - odatalen += 2; - } - linelen += 3; - odatalen += 3; - in++; - } - else { - if (istext && - ((data[in] == '\n') || - ((in+1 < datalen) && (data[in] == '\r') && - (data[in+1] == '\n')))) - { - linelen = 0; - /* Protect against whitespace on end of line */ - if (in && ((data[in-1] == ' ') || (data[in-1] == '\t'))) - odatalen += 2; - if (crlf) - odatalen += 2; - else - odatalen += 1; - if (data[in] == '\r') - in += 2; - else - in++; - } - else { - if ((in + 1 != datalen) && - (data[in+1] != '\n') && - (linelen + 1) >= MAXLINESIZE) { - linelen = 0; - if (crlf) - odatalen += 3; - else - odatalen += 2; - } - linelen++; - odatalen++; - in++; - } - } - } - - odata = (unsigned char *) calloc(1, odatalen); - - if (odata == NULL) { - PyErr_NoMemory(); - return NULL; - } - - in = out = linelen = 0; - while (in < datalen) { - if ((data[in] > 126) || - (data[in] == '=') || - (header && data[in] == '_') || - ((data[in] == '.') && (linelen == 1)) || - (!istext && ((data[in] == '\r') || (data[in] == '\n'))) || - ((data[in] == '\t' || data[in] == ' ') && (in + 1 == datalen)) || - ((data[in] < 33) && - (data[in] != '\r') && (data[in] != '\n') && - (quotetabs && ((data[in] != '\t') || (data[in] != ' '))))) - { - if ((linelen + 3 )>= MAXLINESIZE) { - odata[out++] = '='; - if (crlf) odata[out++] = '\r'; - odata[out++] = '\n'; - linelen = 0; - } - odata[out++] = '='; - to_hex(data[in], &odata[out]); - out += 2; - in++; - linelen += 3; - } - else { - if (istext && - ((data[in] == '\n') || - ((in+1 < datalen) && (data[in] == '\r') && - (data[in+1] == '\n')))) - { - linelen = 0; - /* Protect against whitespace on end of line */ - if (out && ((odata[out-1] == ' ') || (odata[out-1] == '\t'))) { - ch = odata[out-1]; - odata[out-1] = '='; - to_hex(ch, &odata[out]); - out += 2; - } - - if (crlf) odata[out++] = '\r'; - odata[out++] = '\n'; - if (data[in] == '\r') - in += 2; - else - in++; - } - else { - if ((in + 1 != datalen) && - (data[in+1] != '\n') && - (linelen + 1) >= MAXLINESIZE) { - odata[out++] = '='; - if (crlf) odata[out++] = '\r'; - odata[out++] = '\n'; - linelen = 0; - } - linelen++; - if (header && data[in] == ' ') { - odata[out++] = '_'; - in++; - } - else { - odata[out++] = data[in++]; - } - } - } - } - if ((rv = PyString_FromStringAndSize((char *)odata, out)) == NULL) { - free (odata); - return NULL; - } - free (odata); - return rv; -} - -/* List of functions defined in the module */ - -static struct PyMethodDef binascii_module_methods[] = { - {"a2b_uu", binascii_a2b_uu, METH_VARARGS, doc_a2b_uu}, - {"b2a_uu", binascii_b2a_uu, METH_VARARGS, doc_b2a_uu}, - {"a2b_base64", binascii_a2b_base64, METH_VARARGS, doc_a2b_base64}, - {"b2a_base64", binascii_b2a_base64, METH_VARARGS, doc_b2a_base64}, - {"a2b_hqx", binascii_a2b_hqx, METH_VARARGS, doc_a2b_hqx}, - {"b2a_hqx", binascii_b2a_hqx, METH_VARARGS, doc_b2a_hqx}, - {"b2a_hex", binascii_hexlify, METH_VARARGS, doc_hexlify}, - {"a2b_hex", binascii_unhexlify, METH_VARARGS, doc_unhexlify}, - {"hexlify", binascii_hexlify, METH_VARARGS, doc_hexlify}, - {"unhexlify", binascii_unhexlify, METH_VARARGS, doc_unhexlify}, - {"rlecode_hqx", binascii_rlecode_hqx, METH_VARARGS, doc_rlecode_hqx}, - {"rledecode_hqx", binascii_rledecode_hqx, METH_VARARGS, - doc_rledecode_hqx}, - {"crc_hqx", binascii_crc_hqx, METH_VARARGS, doc_crc_hqx}, - {"crc32", binascii_crc32, METH_VARARGS, doc_crc32}, - {"a2b_qp", (PyCFunction)binascii_a2b_qp, METH_VARARGS | METH_KEYWORDS, - doc_a2b_qp}, - {"b2a_qp", (PyCFunction)binascii_b2a_qp, METH_VARARGS | METH_KEYWORDS, - doc_b2a_qp}, - {NULL, NULL} /* sentinel */ -}; - - -/* Initialization function for the module (*must* be called initbinascii) */ -PyDoc_STRVAR(doc_binascii, "Conversion between binary data and ASCII"); - -PyMODINIT_FUNC -initbinascii(void) -{ - PyObject *m, *d, *x; - - /* Create the module and add the functions */ - m = Py_InitModule("binascii", binascii_module_methods); - - d = PyModule_GetDict(m); - x = PyString_FromString(doc_binascii); - PyDict_SetItemString(d, "__doc__", x); - Py_XDECREF(x); - - Error = PyErr_NewException("binascii.Error", NULL, NULL); - PyDict_SetItemString(d, "Error", Error); - Incomplete = PyErr_NewException("binascii.Incomplete", NULL, NULL); - PyDict_SetItemString(d, "Incomplete", Incomplete); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/bsddbmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/bsddbmodule.c deleted file mode 100644 index 2a52212f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/bsddbmodule.c +++ /dev/null @@ -1,856 +0,0 @@ -/* Berkeley DB interface. - Author: Michael McLay - Hacked: Guido van Rossum - Btree and Recno additions plus sequence methods: David Ely - Hacked by Gustavo Niemeyer fixing recno - support. - - XXX To do: - - provide a way to access the various hash functions - - support more open flags - - The windows port of the Berkeley DB code is hard to find on the web: - www.nightmare.com/software.html -*/ - -#include "Python.h" -#ifdef WITH_THREAD -#include "pythread.h" -#endif - -#include -#include -#include -#ifdef HAVE_DB_185_H -#include -#else -#include -#endif -/* Please don't include internal header files of the Berkeley db package - (it messes up the info required in the Setup file) */ - -typedef struct { - PyObject_HEAD - DB *di_bsddb; - int di_size; /* -1 means recompute */ - int di_type; -#ifdef WITH_THREAD - PyThread_type_lock di_lock; -#endif -} bsddbobject; - -static PyTypeObject Bsddbtype; - -#define is_bsddbobject(v) ((v)->ob_type == &Bsddbtype) -#define check_bsddbobject_open(v, r) if ((v)->di_bsddb == NULL) \ - { PyErr_SetString(BsddbError, \ - "BSDDB object has already been closed"); \ - return r; } - -static PyObject *BsddbError; - -static PyObject * -newdbhashobject(char *file, int flags, int mode, - int bsize, int ffactor, int nelem, int cachesize, - int hash, int lorder) -{ - bsddbobject *dp; - HASHINFO info; - - if ((dp = PyObject_New(bsddbobject, &Bsddbtype)) == NULL) - return NULL; - - info.bsize = bsize; - info.ffactor = ffactor; - info.nelem = nelem; - info.cachesize = cachesize; - info.hash = NULL; /* XXX should derive from hash argument */ - info.lorder = lorder; - -#ifdef O_BINARY - flags |= O_BINARY; -#endif - Py_BEGIN_ALLOW_THREADS - dp->di_bsddb = dbopen(file, flags, mode, DB_HASH, &info); - Py_END_ALLOW_THREADS - if (dp->di_bsddb == NULL) { - PyErr_SetFromErrno(BsddbError); -#ifdef WITH_THREAD - dp->di_lock = NULL; -#endif - Py_DECREF(dp); - return NULL; - } - - dp->di_size = -1; - dp->di_type = DB_HASH; - -#ifdef WITH_THREAD - dp->di_lock = PyThread_allocate_lock(); - if (dp->di_lock == NULL) { - PyErr_SetString(BsddbError, "can't allocate lock"); - Py_DECREF(dp); - return NULL; - } -#endif - - return (PyObject *)dp; -} - -static PyObject * -newdbbtobject(char *file, int flags, int mode, - int btflags, int cachesize, int maxkeypage, - int minkeypage, int psize, int lorder) -{ - bsddbobject *dp; - BTREEINFO info; - - if ((dp = PyObject_New(bsddbobject, &Bsddbtype)) == NULL) - return NULL; - - info.flags = btflags; - info.cachesize = cachesize; - info.maxkeypage = maxkeypage; - info.minkeypage = minkeypage; - info.psize = psize; - info.lorder = lorder; - info.compare = 0; /* Use default comparison functions, for now..*/ - info.prefix = 0; - -#ifdef O_BINARY - flags |= O_BINARY; -#endif - Py_BEGIN_ALLOW_THREADS - dp->di_bsddb = dbopen(file, flags, mode, DB_BTREE, &info); - Py_END_ALLOW_THREADS - if (dp->di_bsddb == NULL) { - PyErr_SetFromErrno(BsddbError); -#ifdef WITH_THREAD - dp->di_lock = NULL; -#endif - Py_DECREF(dp); - return NULL; - } - - dp->di_size = -1; - dp->di_type = DB_BTREE; - -#ifdef WITH_THREAD - dp->di_lock = PyThread_allocate_lock(); - if (dp->di_lock == NULL) { - PyErr_SetString(BsddbError, "can't allocate lock"); - Py_DECREF(dp); - return NULL; - } -#endif - - return (PyObject *)dp; -} - -static PyObject * -newdbrnobject(char *file, int flags, int mode, - int rnflags, int cachesize, int psize, int lorder, - size_t reclen, u_char bval, char *bfname) -{ - bsddbobject *dp; - RECNOINFO info; - int fd; - - if ((dp = PyObject_New(bsddbobject, &Bsddbtype)) == NULL) - return NULL; - - info.flags = rnflags; - info.cachesize = cachesize; - info.psize = psize; - info.lorder = lorder; - info.reclen = reclen; - info.bval = bval; - info.bfname = bfname; - -#ifdef O_BINARY - flags |= O_BINARY; -#endif - /* This is a hack to avoid a dbopen() bug that happens when - * it fails. */ - fd = open(file, flags); - if (fd == -1) { - dp->di_bsddb = NULL; - } - else { - close(fd); - Py_BEGIN_ALLOW_THREADS - dp->di_bsddb = dbopen(file, flags, mode, DB_RECNO, &info); - Py_END_ALLOW_THREADS - } - if (dp->di_bsddb == NULL) { - PyErr_SetFromErrno(BsddbError); -#ifdef WITH_THREAD - dp->di_lock = NULL; -#endif - Py_DECREF(dp); - return NULL; - } - - dp->di_size = -1; - dp->di_type = DB_RECNO; - -#ifdef WITH_THREAD - dp->di_lock = PyThread_allocate_lock(); - if (dp->di_lock == NULL) { - PyErr_SetString(BsddbError, "can't allocate lock"); - Py_DECREF(dp); - return NULL; - } -#endif - - return (PyObject *)dp; -} - -static void -bsddb_dealloc(bsddbobject *dp) -{ -#ifdef WITH_THREAD - if (dp->di_lock) { - PyThread_acquire_lock(dp->di_lock, 0); - PyThread_release_lock(dp->di_lock); - PyThread_free_lock(dp->di_lock); - dp->di_lock = NULL; - } -#endif - if (dp->di_bsddb != NULL) { - int status; - Py_BEGIN_ALLOW_THREADS - status = (dp->di_bsddb->close)(dp->di_bsddb); - Py_END_ALLOW_THREADS - if (status != 0) - fprintf(stderr, - "Python bsddb: close errno %d in dealloc\n", - errno); - } - PyObject_Del(dp); -} - -#ifdef WITH_THREAD -#define BSDDB_BGN_SAVE(_dp) \ - Py_BEGIN_ALLOW_THREADS PyThread_acquire_lock(_dp->di_lock,1); -#define BSDDB_END_SAVE(_dp) \ - PyThread_release_lock(_dp->di_lock); Py_END_ALLOW_THREADS -#else -#define BSDDB_BGN_SAVE(_dp) Py_BEGIN_ALLOW_THREADS -#define BSDDB_END_SAVE(_dp) Py_END_ALLOW_THREADS -#endif - -static int -bsddb_length(bsddbobject *dp) -{ - check_bsddbobject_open(dp, -1); - if (dp->di_size < 0) { - DBT krec, drec; - int status; - int size = 0; - BSDDB_BGN_SAVE(dp) - for (status = (dp->di_bsddb->seq)(dp->di_bsddb, - &krec, &drec,R_FIRST); - status == 0; - status = (dp->di_bsddb->seq)(dp->di_bsddb, - &krec, &drec, R_NEXT)) - size++; - BSDDB_END_SAVE(dp) - if (status < 0) { - PyErr_SetFromErrno(BsddbError); - return -1; - } - dp->di_size = size; - } - return dp->di_size; -} - -static PyObject * -bsddb_subscript(bsddbobject *dp, PyObject *key) -{ - int status; - DBT krec, drec; - char *data,buf[4096]; - int size; - PyObject *result; - recno_t recno; - - if (dp->di_type == DB_RECNO) { - if (!PyArg_Parse(key, "i", &recno)) { - PyErr_SetString(PyExc_TypeError, - "key type must be integer"); - return NULL; - } - krec.data = &recno; - krec.size = sizeof(recno); - } - else { - if (!PyArg_Parse(key, "s#", &data, &size)) { - PyErr_SetString(PyExc_TypeError, - "key type must be string"); - return NULL; - } - krec.data = data; - krec.size = size; - } - check_bsddbobject_open(dp, NULL); - - BSDDB_BGN_SAVE(dp) - status = (dp->di_bsddb->get)(dp->di_bsddb, &krec, &drec, 0); - if (status == 0) { - if (drec.size > sizeof(buf)) data = malloc(drec.size); - else data = buf; - if (data!=NULL) memcpy(data,drec.data,drec.size); - } - BSDDB_END_SAVE(dp) - if (data==NULL) return PyErr_NoMemory(); - if (status != 0) { - if (status < 0) - PyErr_SetFromErrno(BsddbError); - else - PyErr_SetObject(PyExc_KeyError, key); - return NULL; - } - - result = PyString_FromStringAndSize(data, (int)drec.size); - if (data != buf) free(data); - return result; -} - -static int -bsddb_ass_sub(bsddbobject *dp, PyObject *key, PyObject *value) -{ - int status; - DBT krec, drec; - char *data; - int size; - recno_t recno; - - if (dp->di_type == DB_RECNO) { - if (!PyArg_Parse(key, "i", &recno)) { - PyErr_SetString(PyExc_TypeError, - "bsddb key type must be integer"); - return -1; - } - krec.data = &recno; - krec.size = sizeof(recno); - } - else { - if (!PyArg_Parse(key, "s#", &data, &size)) { - PyErr_SetString(PyExc_TypeError, - "bsddb key type must be string"); - return -1; - } - krec.data = data; - krec.size = size; - } - check_bsddbobject_open(dp, -1); - dp->di_size = -1; - if (value == NULL) { - BSDDB_BGN_SAVE(dp) - status = (dp->di_bsddb->del)(dp->di_bsddb, &krec, 0); - BSDDB_END_SAVE(dp) - } - else { - if (!PyArg_Parse(value, "s#", &data, &size)) { - PyErr_SetString(PyExc_TypeError, - "bsddb value type must be string"); - return -1; - } - drec.data = data; - drec.size = size; - BSDDB_BGN_SAVE(dp) - status = (dp->di_bsddb->put)(dp->di_bsddb, &krec, &drec, 0); - BSDDB_END_SAVE(dp) - } - if (status != 0) { - if (status < 0) - PyErr_SetFromErrno(BsddbError); - else - PyErr_SetObject(PyExc_KeyError, key); - return -1; - } - return 0; -} - -static PyMappingMethods bsddb_as_mapping = { - (inquiry)bsddb_length, /*mp_length*/ - (binaryfunc)bsddb_subscript, /*mp_subscript*/ - (objobjargproc)bsddb_ass_sub, /*mp_ass_subscript*/ -}; - -static PyObject * -bsddb_close(bsddbobject *dp) -{ - if (dp->di_bsddb != NULL) { - int status; - BSDDB_BGN_SAVE(dp) - status = (dp->di_bsddb->close)(dp->di_bsddb); - BSDDB_END_SAVE(dp) - if (status != 0) { - dp->di_bsddb = NULL; - PyErr_SetFromErrno(BsddbError); - return NULL; - } - } - dp->di_bsddb = NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -bsddb_keys(bsddbobject *dp) -{ - PyObject *list, *item=NULL; - DBT krec, drec; - char *data=NULL,buf[4096]; - int status; - int err; - - check_bsddbobject_open(dp, NULL); - list = PyList_New(0); - if (list == NULL) - return NULL; - BSDDB_BGN_SAVE(dp) - status = (dp->di_bsddb->seq)(dp->di_bsddb, &krec, &drec, R_FIRST); - if (status == 0) { - if (krec.size > sizeof(buf)) data = malloc(krec.size); - else data = buf; - if (data != NULL) memcpy(data,krec.data,krec.size); - } - BSDDB_END_SAVE(dp) - if (status == 0 && data==NULL) return PyErr_NoMemory(); - while (status == 0) { - if (dp->di_type == DB_RECNO) - item = PyInt_FromLong(*((int*)data)); - else - item = PyString_FromStringAndSize(data, - (int)krec.size); - if (data != buf) free(data); - if (item == NULL) { - Py_DECREF(list); - return NULL; - } - err = PyList_Append(list, item); - Py_DECREF(item); - if (err != 0) { - Py_DECREF(list); - return NULL; - } - BSDDB_BGN_SAVE(dp) - status = (dp->di_bsddb->seq) - (dp->di_bsddb, &krec, &drec, R_NEXT); - if (status == 0) { - if (krec.size > sizeof(buf)) - data = malloc(krec.size); - else data = buf; - if (data != NULL) - memcpy(data,krec.data,krec.size); - } - BSDDB_END_SAVE(dp) - if (data == NULL) return PyErr_NoMemory(); - } - if (status < 0) { - PyErr_SetFromErrno(BsddbError); - Py_DECREF(list); - return NULL; - } - if (dp->di_size < 0) - dp->di_size = PyList_Size(list); /* We just did the work */ - return list; -} - -static PyObject * -bsddb_has_key(bsddbobject *dp, PyObject *args) -{ - DBT krec, drec; - int status; - char *data; - int size; - recno_t recno; - - if (dp->di_type == DB_RECNO) { - if (!PyArg_ParseTuple(args, "i;key type must be integer", - &recno)) { - return NULL; - } - krec.data = &recno; - krec.size = sizeof(recno); - } - else { - if (!PyArg_ParseTuple(args, "s#;key type must be string", - &data, &size)) { - return NULL; - } - krec.data = data; - krec.size = size; - } - check_bsddbobject_open(dp, NULL); - - BSDDB_BGN_SAVE(dp) - status = (dp->di_bsddb->get)(dp->di_bsddb, &krec, &drec, 0); - BSDDB_END_SAVE(dp) - if (status < 0) { - PyErr_SetFromErrno(BsddbError); - return NULL; - } - - return PyInt_FromLong(status == 0); -} - -static PyObject * -bsddb_set_location(bsddbobject *dp, PyObject *key) -{ - int status; - DBT krec, drec; - char *data,buf[4096]; - int size; - PyObject *result; - recno_t recno; - - if (dp->di_type == DB_RECNO) { - if (!PyArg_ParseTuple(key, "i;key type must be integer", - &recno)) { - return NULL; - } - krec.data = &recno; - krec.size = sizeof(recno); - } - else { - if (!PyArg_ParseTuple(key, "s#;key type must be string", - &data, &size)) { - return NULL; - } - krec.data = data; - krec.size = size; - } - check_bsddbobject_open(dp, NULL); - - BSDDB_BGN_SAVE(dp) - status = (dp->di_bsddb->seq)(dp->di_bsddb, &krec, &drec, R_CURSOR); - if (status == 0) { - if (drec.size > sizeof(buf)) data = malloc(drec.size); - else data = buf; - if (data!=NULL) memcpy(data,drec.data,drec.size); - } - BSDDB_END_SAVE(dp) - if (data==NULL) return PyErr_NoMemory(); - if (status != 0) { - if (status < 0) - PyErr_SetFromErrno(BsddbError); - else - PyErr_SetObject(PyExc_KeyError, key); - return NULL; - } - - if (dp->di_type == DB_RECNO) - result = Py_BuildValue("is#", *((int*)krec.data), - data, drec.size); - else - result = Py_BuildValue("s#s#", krec.data, krec.size, - data, drec.size); - if (data != buf) free(data); - return result; -} - -static PyObject * -bsddb_seq(bsddbobject *dp, int sequence_request) -{ - int status; - DBT krec, drec; - char *kdata=NULL,kbuf[4096]; - char *ddata=NULL,dbuf[4096]; - PyObject *result; - - check_bsddbobject_open(dp, NULL); - krec.data = 0; - krec.size = 0; - - BSDDB_BGN_SAVE(dp) - status = (dp->di_bsddb->seq)(dp->di_bsddb, &krec, - &drec, sequence_request); - if (status == 0) { - if (krec.size > sizeof(kbuf)) kdata = malloc(krec.size); - else kdata = kbuf; - if (kdata != NULL) memcpy(kdata,krec.data,krec.size); - if (drec.size > sizeof(dbuf)) ddata = malloc(drec.size); - else ddata = dbuf; - if (ddata != NULL) memcpy(ddata,drec.data,drec.size); - } - BSDDB_END_SAVE(dp) - if (status == 0) { - if ((kdata == NULL) || (ddata == NULL)) - return PyErr_NoMemory(); - } - else { - /* (status != 0) */ - if (status < 0) - PyErr_SetFromErrno(BsddbError); - else - PyErr_SetString(PyExc_KeyError, "no key/data pairs"); - return NULL; - } - - if (dp->di_type == DB_RECNO) - result = Py_BuildValue("is#", *((int*)kdata), - ddata, drec.size); - else - result = Py_BuildValue("s#s#", kdata, krec.size, - ddata, drec.size); - if (kdata != kbuf) free(kdata); - if (ddata != dbuf) free(ddata); - return result; -} - -static PyObject * -bsddb_next(bsddbobject *dp) -{ - return bsddb_seq(dp, R_NEXT); -} -static PyObject * -bsddb_previous(bsddbobject *dp) -{ - return bsddb_seq(dp, R_PREV); -} -static PyObject * -bsddb_first(bsddbobject *dp) -{ - return bsddb_seq(dp, R_FIRST); -} -static PyObject * -bsddb_last(bsddbobject *dp) -{ - return bsddb_seq(dp, R_LAST); -} -static PyObject * -bsddb_sync(bsddbobject *dp) -{ - int status; - - check_bsddbobject_open(dp, NULL); - BSDDB_BGN_SAVE(dp) - status = (dp->di_bsddb->sync)(dp->di_bsddb, 0); - BSDDB_END_SAVE(dp) - if (status != 0) { - PyErr_SetFromErrno(BsddbError); - return NULL; - } - return PyInt_FromLong(status = 0); -} -static PyMethodDef bsddb_methods[] = { - {"close", (PyCFunction)bsddb_close, METH_NOARGS}, - {"keys", (PyCFunction)bsddb_keys, METH_NOARGS}, - {"has_key", (PyCFunction)bsddb_has_key, METH_VARARGS}, - {"set_location", (PyCFunction)bsddb_set_location, METH_VARARGS}, - {"next", (PyCFunction)bsddb_next, METH_NOARGS}, - {"previous", (PyCFunction)bsddb_previous, METH_NOARGS}, - {"first", (PyCFunction)bsddb_first, METH_NOARGS}, - {"last", (PyCFunction)bsddb_last, METH_NOARGS}, - {"sync", (PyCFunction)bsddb_sync, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -bsddb_getattr(PyObject *dp, char *name) -{ - return Py_FindMethod(bsddb_methods, dp, name); -} - -static PyTypeObject Bsddbtype = { - PyObject_HEAD_INIT(NULL) - 0, - "bsddb.bsddb", - sizeof(bsddbobject), - 0, - (destructor)bsddb_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)bsddb_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - &bsddb_as_mapping, /*tp_as_mapping*/ -}; - -static PyObject * -bsdhashopen(PyObject *self, PyObject *args) -{ - char *file; - char *flag = NULL; - int flags = O_RDONLY; - int mode = 0666; - int bsize = 0; - int ffactor = 0; - int nelem = 0; - int cachesize = 0; - int hash = 0; /* XXX currently ignored */ - int lorder = 0; - - if (!PyArg_ParseTuple(args, "z|siiiiiii:hashopen", - &file, &flag, &mode, - &bsize, &ffactor, &nelem, &cachesize, - &hash, &lorder)) - return NULL; - if (flag != NULL) { - /* XXX need to pass O_EXCL, O_EXLOCK, O_NONBLOCK, O_SHLOCK */ - if (flag[0] == 'r') - flags = O_RDONLY; - else if (flag[0] == 'w') - flags = O_RDWR; - else if (flag[0] == 'c') - flags = O_RDWR|O_CREAT; - else if (flag[0] == 'n') - flags = O_RDWR|O_CREAT|O_TRUNC; - else { - PyErr_SetString(BsddbError, - "Flag should begin with 'r', 'w', 'c' or 'n'"); - return NULL; - } - if (flag[1] == 'l') { -#if defined(O_EXLOCK) && defined(O_SHLOCK) - if (flag[0] == 'r') - flags |= O_SHLOCK; - else - flags |= O_EXLOCK; -#else - PyErr_SetString(BsddbError, - "locking not supported on this platform"); - return NULL; -#endif - } - } - return newdbhashobject(file, flags, mode, - bsize, ffactor, nelem, cachesize, hash, lorder); -} - -static PyObject * -bsdbtopen(PyObject *self, PyObject *args) -{ - char *file; - char *flag = NULL; - int flags = O_RDONLY; - int mode = 0666; - int cachesize = 0; - int maxkeypage = 0; - int minkeypage = 0; - int btflags = 0; - unsigned int psize = 0; - int lorder = 0; - - if (!PyArg_ParseTuple(args, "z|siiiiiii:btopen", - &file, &flag, &mode, - &btflags, &cachesize, &maxkeypage, &minkeypage, - &psize, &lorder)) - return NULL; - if (flag != NULL) { - /* XXX need to pass O_EXCL, O_EXLOCK, O_NONBLOCK, O_SHLOCK */ - if (flag[0] == 'r') - flags = O_RDONLY; - else if (flag[0] == 'w') - flags = O_RDWR; - else if (flag[0] == 'c') - flags = O_RDWR|O_CREAT; - else if (flag[0] == 'n') - flags = O_RDWR|O_CREAT|O_TRUNC; - else { - PyErr_SetString(BsddbError, - "Flag should begin with 'r', 'w', 'c' or 'n'"); - return NULL; - } - if (flag[1] == 'l') { -#if defined(O_EXLOCK) && defined(O_SHLOCK) - if (flag[0] == 'r') - flags |= O_SHLOCK; - else - flags |= O_EXLOCK; -#else - PyErr_SetString(BsddbError, - "locking not supported on this platform"); - return NULL; -#endif - } - } - return newdbbtobject(file, flags, mode, - btflags, cachesize, maxkeypage, minkeypage, - psize, lorder); -} - -static PyObject * -bsdrnopen(PyObject *self, PyObject *args) -{ - char *file; - char *flag = NULL; - int flags = O_RDONLY; - int mode = 0666; - int cachesize = 0; - int rnflags = 0; - unsigned int psize = 0; - int lorder = 0; - size_t reclen = 0; - char *bval = ""; - char *bfname = NULL; - - if (!PyArg_ParseTuple(args, "z|siiiiiiss:rnopen", - &file, &flag, &mode, - &rnflags, &cachesize, &psize, &lorder, - &reclen, &bval, &bfname)) - return NULL; - - if (flag != NULL) { - /* XXX need to pass O_EXCL, O_EXLOCK, O_NONBLOCK, O_SHLOCK */ - if (flag[0] == 'r') - flags = O_RDONLY; - else if (flag[0] == 'w') - flags = O_RDWR; - else if (flag[0] == 'c') - flags = O_RDWR|O_CREAT; - else if (flag[0] == 'n') - flags = O_RDWR|O_CREAT|O_TRUNC; - else { - PyErr_SetString(BsddbError, - "Flag should begin with 'r', 'w', 'c' or 'n'"); - return NULL; - } - if (flag[1] == 'l') { -#if defined(O_EXLOCK) && defined(O_SHLOCK) - if (flag[0] == 'r') - flags |= O_SHLOCK; - else - flags |= O_EXLOCK; -#else - PyErr_SetString(BsddbError, - "locking not supported on this platform"); - return NULL; -#endif - } - else if (flag[1] != '\0') { - PyErr_SetString(BsddbError, - "Flag char 2 should be 'l' or absent"); - return NULL; - } - } - return newdbrnobject(file, flags, mode, rnflags, cachesize, - psize, lorder, reclen, bval[0], bfname); -} - -static PyMethodDef bsddbmodule_methods[] = { - {"hashopen", (PyCFunction)bsdhashopen, METH_VARARGS}, - {"btopen", (PyCFunction)bsdbtopen, METH_VARARGS}, - {"rnopen", (PyCFunction)bsdrnopen, METH_VARARGS}, - /* strictly for use by dbhhash!!! */ - {"open", (PyCFunction)bsdhashopen, METH_VARARGS}, - {0, 0}, -}; - -PyMODINIT_FUNC -initbsddb185(void) { - PyObject *m, *d; - - Bsddbtype.ob_type = &PyType_Type; - m = Py_InitModule("bsddb185", bsddbmodule_methods); - d = PyModule_GetDict(m); - BsddbError = PyErr_NewException("bsddb.error", NULL, NULL); - if (BsddbError != NULL) - PyDict_SetItemString(d, "error", BsddbError); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/bz2module.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/bz2module.c deleted file mode 100644 index 2b609aec..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/bz2module.c +++ /dev/null @@ -1,2191 +0,0 @@ -/* - -python-bz2 - python bz2 library interface - -Copyright (c) 2002 Gustavo Niemeyer -Copyright (c) 2002 Python Software Foundation; All Rights Reserved - -*/ - -#include "Python.h" -#include -#include -#include "structmember.h" - -#ifdef WITH_THREAD -#include "pythread.h" -#endif - -static char __author__[] = -"The bz2 python module was written by:\n\ -\n\ - Gustavo Niemeyer \n\ -"; - -#define BUF(v) PyString_AS_STRING((PyStringObject *)v) - -#define MODE_CLOSED 0 -#define MODE_READ 1 -#define MODE_READ_EOF 2 -#define MODE_WRITE 3 - -#define BZ2FileObject_Check(v) ((v)->ob_type == &BZ2File_Type) - - -#ifdef BZ_CONFIG_ERROR - -#if SIZEOF_LONG >= 8 -#define BZS_TOTAL_OUT(bzs) \ - (((long)bzs->total_out_hi32 << 32) + bzs->total_out_lo32) -#elif SIZEOF_LONG_LONG >= 8 -#define BZS_TOTAL_OUT(bzs) \ - (((PY_LONG_LONG)bzs->total_out_hi32 << 32) + bzs->total_out_lo32) -#else -#define BZS_TOTAL_OUT(bzs) \ - bzs->total_out_lo32; -#endif - -#else /* ! BZ_CONFIG_ERROR */ - -#define BZ2_bzRead bzRead -#define BZ2_bzReadOpen bzReadOpen -#define BZ2_bzReadClose bzReadClose -#define BZ2_bzWrite bzWrite -#define BZ2_bzWriteOpen bzWriteOpen -#define BZ2_bzWriteClose bzWriteClose -#define BZ2_bzCompress bzCompress -#define BZ2_bzCompressInit bzCompressInit -#define BZ2_bzCompressEnd bzCompressEnd -#define BZ2_bzDecompress bzDecompress -#define BZ2_bzDecompressInit bzDecompressInit -#define BZ2_bzDecompressEnd bzDecompressEnd - -#define BZS_TOTAL_OUT(bzs) bzs->total_out - -#endif /* ! BZ_CONFIG_ERROR */ - - -#ifdef WITH_THREAD -#define ACQUIRE_LOCK(obj) PyThread_acquire_lock(obj->lock, 1) -#define RELEASE_LOCK(obj) PyThread_release_lock(obj->lock) -#else -#define ACQUIRE_LOCK(obj) -#define RELEASE_LOCK(obj) -#endif - -#ifdef WITH_UNIVERSAL_NEWLINES -/* Bits in f_newlinetypes */ -#define NEWLINE_UNKNOWN 0 /* No newline seen, yet */ -#define NEWLINE_CR 1 /* \r newline seen */ -#define NEWLINE_LF 2 /* \n newline seen */ -#define NEWLINE_CRLF 4 /* \r\n newline seen */ -#endif - -/* ===================================================================== */ -/* Structure definitions. */ - -typedef struct { - PyObject_HEAD - PyObject *file; - - char* f_buf; /* Allocated readahead buffer */ - char* f_bufend; /* Points after last occupied position */ - char* f_bufptr; /* Current buffer position */ - - int f_softspace; /* Flag used by 'print' command */ - -#ifdef WITH_UNIVERSAL_NEWLINES - int f_univ_newline; /* Handle any newline convention */ - int f_newlinetypes; /* Types of newlines seen */ - int f_skipnextlf; /* Skip next \n */ -#endif - - BZFILE *fp; - int mode; - long pos; - long size; -#ifdef WITH_THREAD - PyThread_type_lock lock; -#endif -} BZ2FileObject; - -typedef struct { - PyObject_HEAD - bz_stream bzs; - int running; -#ifdef WITH_THREAD - PyThread_type_lock lock; -#endif -} BZ2CompObject; - -typedef struct { - PyObject_HEAD - bz_stream bzs; - int running; - PyObject *unused_data; -#ifdef WITH_THREAD - PyThread_type_lock lock; -#endif -} BZ2DecompObject; - -/* ===================================================================== */ -/* Utility functions. */ - -static int -Util_CatchBZ2Error(int bzerror) -{ - int ret = 0; - switch(bzerror) { - case BZ_OK: - case BZ_STREAM_END: - break; - -#ifdef BZ_CONFIG_ERROR - case BZ_CONFIG_ERROR: - PyErr_SetString(PyExc_SystemError, - "the bz2 library was not compiled " - "correctly"); - ret = 1; - break; -#endif - - case BZ_PARAM_ERROR: - PyErr_SetString(PyExc_ValueError, - "the bz2 library has received wrong " - "parameters"); - ret = 1; - break; - - case BZ_MEM_ERROR: - PyErr_NoMemory(); - ret = 1; - break; - - case BZ_DATA_ERROR: - case BZ_DATA_ERROR_MAGIC: - PyErr_SetString(PyExc_IOError, "invalid data stream"); - ret = 1; - break; - - case BZ_IO_ERROR: - PyErr_SetString(PyExc_IOError, "unknown IO error"); - ret = 1; - break; - - case BZ_UNEXPECTED_EOF: - PyErr_SetString(PyExc_EOFError, - "compressed file ended before the " - "logical end-of-stream was detected"); - ret = 1; - break; - - case BZ_SEQUENCE_ERROR: - PyErr_SetString(PyExc_RuntimeError, - "wrong sequence of bz2 library " - "commands used"); - ret = 1; - break; - } - return ret; -} - -#if BUFSIZ < 8192 -#define SMALLCHUNK 8192 -#else -#define SMALLCHUNK BUFSIZ -#endif - -#if SIZEOF_INT < 4 -#define BIGCHUNK (512 * 32) -#else -#define BIGCHUNK (512 * 1024) -#endif - -/* This is a hacked version of Python's fileobject.c:new_buffersize(). */ -static size_t -Util_NewBufferSize(size_t currentsize) -{ - if (currentsize > SMALLCHUNK) { - /* Keep doubling until we reach BIGCHUNK; - then keep adding BIGCHUNK. */ - if (currentsize <= BIGCHUNK) - return currentsize + currentsize; - else - return currentsize + BIGCHUNK; - } - return currentsize + SMALLCHUNK; -} - -/* This is a hacked version of Python's fileobject.c:get_line(). */ -static PyObject * -Util_GetLine(BZ2FileObject *f, int n) -{ - char c; - char *buf, *end; - size_t total_v_size; /* total # of slots in buffer */ - size_t used_v_size; /* # used slots in buffer */ - size_t increment; /* amount to increment the buffer */ - PyObject *v; - int bzerror; -#ifdef WITH_UNIVERSAL_NEWLINES - int newlinetypes = f->f_newlinetypes; - int skipnextlf = f->f_skipnextlf; - int univ_newline = f->f_univ_newline; -#endif - - total_v_size = n > 0 ? n : 100; - v = PyString_FromStringAndSize((char *)NULL, total_v_size); - if (v == NULL) - return NULL; - - buf = BUF(v); - end = buf + total_v_size; - - for (;;) { - Py_BEGIN_ALLOW_THREADS -#ifdef WITH_UNIVERSAL_NEWLINES - if (univ_newline) { - while (1) { - BZ2_bzRead(&bzerror, f->fp, &c, 1); - f->pos++; - if (bzerror != BZ_OK || buf == end) - break; - if (skipnextlf) { - skipnextlf = 0; - if (c == '\n') { - /* Seeing a \n here with - * skipnextlf true means we - * saw a \r before. - */ - newlinetypes |= NEWLINE_CRLF; - BZ2_bzRead(&bzerror, f->fp, - &c, 1); - if (bzerror != BZ_OK) - break; - } else { - newlinetypes |= NEWLINE_CR; - } - } - if (c == '\r') { - skipnextlf = 1; - c = '\n'; - } else if ( c == '\n') - newlinetypes |= NEWLINE_LF; - *buf++ = c; - if (c == '\n') break; - } - if (bzerror == BZ_STREAM_END && skipnextlf) - newlinetypes |= NEWLINE_CR; - } else /* If not universal newlines use the normal loop */ -#endif - do { - BZ2_bzRead(&bzerror, f->fp, &c, 1); - f->pos++; - *buf++ = c; - } while (bzerror == BZ_OK && c != '\n' && buf != end); - Py_END_ALLOW_THREADS -#ifdef WITH_UNIVERSAL_NEWLINES - f->f_newlinetypes = newlinetypes; - f->f_skipnextlf = skipnextlf; -#endif - if (bzerror == BZ_STREAM_END) { - f->size = f->pos; - f->mode = MODE_READ_EOF; - break; - } else if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - Py_DECREF(v); - return NULL; - } - if (c == '\n') - break; - /* Must be because buf == end */ - if (n > 0) - break; - used_v_size = total_v_size; - increment = total_v_size >> 2; /* mild exponential growth */ - total_v_size += increment; - if (total_v_size > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "line is longer than a Python string can hold"); - Py_DECREF(v); - return NULL; - } - if (_PyString_Resize(&v, total_v_size) < 0) - return NULL; - buf = BUF(v) + used_v_size; - end = BUF(v) + total_v_size; - } - - used_v_size = buf - BUF(v); - if (used_v_size != total_v_size) - _PyString_Resize(&v, used_v_size); - return v; -} - -#ifndef WITH_UNIVERSAL_NEWLINES -#define Util_UnivNewlineRead(a,b,c,d,e) BZ2_bzRead(a,b,c,d) -#else -/* This is a hacked version of Python's - * fileobject.c:Py_UniversalNewlineFread(). */ -size_t -Util_UnivNewlineRead(int *bzerror, BZFILE *stream, - char* buf, size_t n, BZ2FileObject *f) -{ - char *dst = buf; - int newlinetypes, skipnextlf; - - assert(buf != NULL); - assert(stream != NULL); - - if (!f->f_univ_newline) - return BZ2_bzRead(bzerror, stream, buf, n); - - newlinetypes = f->f_newlinetypes; - skipnextlf = f->f_skipnextlf; - - /* Invariant: n is the number of bytes remaining to be filled - * in the buffer. - */ - while (n) { - size_t nread; - int shortread; - char *src = dst; - - nread = BZ2_bzRead(bzerror, stream, dst, n); - assert(nread <= n); - n -= nread; /* assuming 1 byte out for each in; will adjust */ - shortread = n != 0; /* true iff EOF or error */ - while (nread--) { - char c = *src++; - if (c == '\r') { - /* Save as LF and set flag to skip next LF. */ - *dst++ = '\n'; - skipnextlf = 1; - } - else if (skipnextlf && c == '\n') { - /* Skip LF, and remember we saw CR LF. */ - skipnextlf = 0; - newlinetypes |= NEWLINE_CRLF; - ++n; - } - else { - /* Normal char to be stored in buffer. Also - * update the newlinetypes flag if either this - * is an LF or the previous char was a CR. - */ - if (c == '\n') - newlinetypes |= NEWLINE_LF; - else if (skipnextlf) - newlinetypes |= NEWLINE_CR; - *dst++ = c; - skipnextlf = 0; - } - } - if (shortread) { - /* If this is EOF, update type flags. */ - if (skipnextlf && *bzerror == BZ_STREAM_END) - newlinetypes |= NEWLINE_CR; - break; - } - } - f->f_newlinetypes = newlinetypes; - f->f_skipnextlf = skipnextlf; - return dst - buf; -} -#endif - -/* This is a hacked version of Python's fileobject.c:drop_readahead(). */ -static void -Util_DropReadAhead(BZ2FileObject *f) -{ - if (f->f_buf != NULL) { - PyMem_Free(f->f_buf); - f->f_buf = NULL; - } -} - -/* This is a hacked version of Python's fileobject.c:readahead(). */ -static int -Util_ReadAhead(BZ2FileObject *f, int bufsize) -{ - int chunksize; - int bzerror; - - if (f->f_buf != NULL) { - if((f->f_bufend - f->f_bufptr) >= 1) - return 0; - else - Util_DropReadAhead(f); - } - if (f->mode == MODE_READ_EOF) { - return -1; - } - if ((f->f_buf = PyMem_Malloc(bufsize)) == NULL) { - return -1; - } - Py_BEGIN_ALLOW_THREADS - chunksize = Util_UnivNewlineRead(&bzerror, f->fp, f->f_buf, - bufsize, f); - Py_END_ALLOW_THREADS - f->pos += chunksize; - if (bzerror == BZ_STREAM_END) { - f->size = f->pos; - f->mode = MODE_READ_EOF; - } else if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - Util_DropReadAhead(f); - return -1; - } - f->f_bufptr = f->f_buf; - f->f_bufend = f->f_buf + chunksize; - return 0; -} - -/* This is a hacked version of Python's - * fileobject.c:readahead_get_line_skip(). */ -static PyStringObject * -Util_ReadAheadGetLineSkip(BZ2FileObject *f, int skip, int bufsize) -{ - PyStringObject* s; - char *bufptr; - char *buf; - int len; - - if (f->f_buf == NULL) - if (Util_ReadAhead(f, bufsize) < 0) - return NULL; - - len = f->f_bufend - f->f_bufptr; - if (len == 0) - return (PyStringObject *) - PyString_FromStringAndSize(NULL, skip); - bufptr = memchr(f->f_bufptr, '\n', len); - if (bufptr != NULL) { - bufptr++; /* Count the '\n' */ - len = bufptr - f->f_bufptr; - s = (PyStringObject *) - PyString_FromStringAndSize(NULL, skip+len); - if (s == NULL) - return NULL; - memcpy(PyString_AS_STRING(s)+skip, f->f_bufptr, len); - f->f_bufptr = bufptr; - if (bufptr == f->f_bufend) - Util_DropReadAhead(f); - } else { - bufptr = f->f_bufptr; - buf = f->f_buf; - f->f_buf = NULL; /* Force new readahead buffer */ - s = Util_ReadAheadGetLineSkip(f, skip+len, - bufsize + (bufsize>>2)); - if (s == NULL) { - PyMem_Free(buf); - return NULL; - } - memcpy(PyString_AS_STRING(s)+skip, bufptr, len); - PyMem_Free(buf); - } - return s; -} - -/* ===================================================================== */ -/* Methods of BZ2File. */ - -PyDoc_STRVAR(BZ2File_read__doc__, -"read([size]) -> string\n\ -\n\ -Read at most size uncompressed bytes, returned as a string. If the size\n\ -argument is negative or omitted, read until EOF is reached.\n\ -"); - -/* This is a hacked version of Python's fileobject.c:file_read(). */ -static PyObject * -BZ2File_read(BZ2FileObject *self, PyObject *args) -{ - long bytesrequested = -1; - size_t bytesread, buffersize, chunksize; - int bzerror; - PyObject *ret = NULL; - - if (!PyArg_ParseTuple(args, "|l:read", &bytesrequested)) - return NULL; - - ACQUIRE_LOCK(self); - switch (self->mode) { - case MODE_READ: - break; - case MODE_READ_EOF: - ret = PyString_FromString(""); - goto cleanup; - case MODE_CLOSED: - PyErr_SetString(PyExc_ValueError, - "I/O operation on closed file"); - goto cleanup; - default: - PyErr_SetString(PyExc_IOError, - "file is not ready for reading"); - goto cleanup; - } - - if (bytesrequested < 0) - buffersize = Util_NewBufferSize((size_t)0); - else - buffersize = bytesrequested; - if (buffersize > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "requested number of bytes is " - "more than a Python string can hold"); - goto cleanup; - } - ret = PyString_FromStringAndSize((char *)NULL, buffersize); - if (ret == NULL) - goto cleanup; - bytesread = 0; - - for (;;) { - Py_BEGIN_ALLOW_THREADS - chunksize = Util_UnivNewlineRead(&bzerror, self->fp, - BUF(ret)+bytesread, - buffersize-bytesread, - self); - self->pos += chunksize; - Py_END_ALLOW_THREADS - bytesread += chunksize; - if (bzerror == BZ_STREAM_END) { - self->size = self->pos; - self->mode = MODE_READ_EOF; - break; - } else if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - Py_DECREF(ret); - ret = NULL; - goto cleanup; - } - if (bytesrequested < 0) { - buffersize = Util_NewBufferSize(buffersize); - if (_PyString_Resize(&ret, buffersize) < 0) - goto cleanup; - } else { - break; - } - } - if (bytesread != buffersize) - _PyString_Resize(&ret, bytesread); - -cleanup: - RELEASE_LOCK(self); - return ret; -} - -PyDoc_STRVAR(BZ2File_readline__doc__, -"readline([size]) -> string\n\ -\n\ -Return the next line from the file, as a string, retaining newline.\n\ -A non-negative size argument will limit the maximum number of bytes to\n\ -return (an incomplete line may be returned then). Return an empty\n\ -string at EOF.\n\ -"); - -static PyObject * -BZ2File_readline(BZ2FileObject *self, PyObject *args) -{ - PyObject *ret = NULL; - int sizehint = -1; - - if (!PyArg_ParseTuple(args, "|i:readline", &sizehint)) - return NULL; - - ACQUIRE_LOCK(self); - switch (self->mode) { - case MODE_READ: - break; - case MODE_READ_EOF: - ret = PyString_FromString(""); - goto cleanup; - case MODE_CLOSED: - PyErr_SetString(PyExc_ValueError, - "I/O operation on closed file"); - goto cleanup; - default: - PyErr_SetString(PyExc_IOError, - "file is not ready for reading"); - goto cleanup; - } - - if (sizehint == 0) - ret = PyString_FromString(""); - else - ret = Util_GetLine(self, (sizehint < 0) ? 0 : sizehint); - -cleanup: - RELEASE_LOCK(self); - return ret; -} - -PyDoc_STRVAR(BZ2File_readlines__doc__, -"readlines([size]) -> list\n\ -\n\ -Call readline() repeatedly and return a list of lines read.\n\ -The optional size argument, if given, is an approximate bound on the\n\ -total number of bytes in the lines returned.\n\ -"); - -/* This is a hacked version of Python's fileobject.c:file_readlines(). */ -static PyObject * -BZ2File_readlines(BZ2FileObject *self, PyObject *args) -{ - long sizehint = 0; - PyObject *list = NULL; - PyObject *line; - char small_buffer[SMALLCHUNK]; - char *buffer = small_buffer; - size_t buffersize = SMALLCHUNK; - PyObject *big_buffer = NULL; - size_t nfilled = 0; - size_t nread; - size_t totalread = 0; - char *p, *q, *end; - int err; - int shortread = 0; - int bzerror; - - if (!PyArg_ParseTuple(args, "|l:readlines", &sizehint)) - return NULL; - - ACQUIRE_LOCK(self); - switch (self->mode) { - case MODE_READ: - break; - case MODE_READ_EOF: - list = PyList_New(0); - goto cleanup; - case MODE_CLOSED: - PyErr_SetString(PyExc_ValueError, - "I/O operation on closed file"); - goto cleanup; - default: - PyErr_SetString(PyExc_IOError, - "file is not ready for reading"); - goto cleanup; - } - - if ((list = PyList_New(0)) == NULL) - goto cleanup; - - for (;;) { - Py_BEGIN_ALLOW_THREADS - nread = Util_UnivNewlineRead(&bzerror, self->fp, - buffer+nfilled, - buffersize-nfilled, self); - self->pos += nread; - Py_END_ALLOW_THREADS - if (bzerror == BZ_STREAM_END) { - self->size = self->pos; - self->mode = MODE_READ_EOF; - if (nread == 0) { - sizehint = 0; - break; - } - shortread = 1; - } else if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - error: - Py_DECREF(list); - list = NULL; - goto cleanup; - } - totalread += nread; - p = memchr(buffer+nfilled, '\n', nread); - if (p == NULL) { - /* Need a larger buffer to fit this line */ - nfilled += nread; - buffersize *= 2; - if (buffersize > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "line is longer than a Python string can hold"); - goto error; - } - if (big_buffer == NULL) { - /* Create the big buffer */ - big_buffer = PyString_FromStringAndSize( - NULL, buffersize); - if (big_buffer == NULL) - goto error; - buffer = PyString_AS_STRING(big_buffer); - memcpy(buffer, small_buffer, nfilled); - } - else { - /* Grow the big buffer */ - _PyString_Resize(&big_buffer, buffersize); - buffer = PyString_AS_STRING(big_buffer); - } - continue; - } - end = buffer+nfilled+nread; - q = buffer; - do { - /* Process complete lines */ - p++; - line = PyString_FromStringAndSize(q, p-q); - if (line == NULL) - goto error; - err = PyList_Append(list, line); - Py_DECREF(line); - if (err != 0) - goto error; - q = p; - p = memchr(q, '\n', end-q); - } while (p != NULL); - /* Move the remaining incomplete line to the start */ - nfilled = end-q; - memmove(buffer, q, nfilled); - if (sizehint > 0) - if (totalread >= (size_t)sizehint) - break; - if (shortread) { - sizehint = 0; - break; - } - } - if (nfilled != 0) { - /* Partial last line */ - line = PyString_FromStringAndSize(buffer, nfilled); - if (line == NULL) - goto error; - if (sizehint > 0) { - /* Need to complete the last line */ - PyObject *rest = Util_GetLine(self, 0); - if (rest == NULL) { - Py_DECREF(line); - goto error; - } - PyString_Concat(&line, rest); - Py_DECREF(rest); - if (line == NULL) - goto error; - } - err = PyList_Append(list, line); - Py_DECREF(line); - if (err != 0) - goto error; - } - - cleanup: - RELEASE_LOCK(self); - if (big_buffer) { - Py_DECREF(big_buffer); - } - return list; -} - -PyDoc_STRVAR(BZ2File_xreadlines__doc__, -"xreadlines() -> self\n\ -\n\ -For backward compatibility. BZ2File objects now include the performance\n\ -optimizations previously implemented in the xreadlines module.\n\ -"); - -PyDoc_STRVAR(BZ2File_write__doc__, -"write(data) -> None\n\ -\n\ -Write the 'data' string to file. Note that due to buffering, close() may\n\ -be needed before the file on disk reflects the data written.\n\ -"); - -/* This is a hacked version of Python's fileobject.c:file_write(). */ -static PyObject * -BZ2File_write(BZ2FileObject *self, PyObject *args) -{ - PyObject *ret = NULL; - char *buf; - int len; - int bzerror; - - if (!PyArg_ParseTuple(args, "s#", &buf, &len)) - return NULL; - - ACQUIRE_LOCK(self); - switch (self->mode) { - case MODE_WRITE: - break; - - case MODE_CLOSED: - PyErr_SetString(PyExc_ValueError, - "I/O operation on closed file"); - goto cleanup;; - - default: - PyErr_SetString(PyExc_IOError, - "file is not ready for writing"); - goto cleanup;; - } - - self->f_softspace = 0; - - Py_BEGIN_ALLOW_THREADS - BZ2_bzWrite (&bzerror, self->fp, buf, len); - self->pos += len; - Py_END_ALLOW_THREADS - - if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - goto cleanup; - } - - Py_INCREF(Py_None); - ret = Py_None; - -cleanup: - RELEASE_LOCK(self); - return ret; -} - -PyDoc_STRVAR(BZ2File_writelines__doc__, -"writelines(sequence_of_strings) -> None\n\ -\n\ -Write the sequence of strings to the file. Note that newlines are not\n\ -added. The sequence can be any iterable object producing strings. This is\n\ -equivalent to calling write() for each string.\n\ -"); - -/* This is a hacked version of Python's fileobject.c:file_writelines(). */ -static PyObject * -BZ2File_writelines(BZ2FileObject *self, PyObject *seq) -{ -#define CHUNKSIZE 1000 - PyObject *list = NULL; - PyObject *iter = NULL; - PyObject *ret = NULL; - PyObject *line; - int i, j, index, len, islist; - int bzerror; - - ACQUIRE_LOCK(self); - islist = PyList_Check(seq); - if (!islist) { - iter = PyObject_GetIter(seq); - if (iter == NULL) { - PyErr_SetString(PyExc_TypeError, - "writelines() requires an iterable argument"); - goto error; - } - list = PyList_New(CHUNKSIZE); - if (list == NULL) - goto error; - } - - /* Strategy: slurp CHUNKSIZE lines into a private list, - checking that they are all strings, then write that list - without holding the interpreter lock, then come back for more. */ - for (index = 0; ; index += CHUNKSIZE) { - if (islist) { - Py_XDECREF(list); - list = PyList_GetSlice(seq, index, index+CHUNKSIZE); - if (list == NULL) - goto error; - j = PyList_GET_SIZE(list); - } - else { - for (j = 0; j < CHUNKSIZE; j++) { - line = PyIter_Next(iter); - if (line == NULL) { - if (PyErr_Occurred()) - goto error; - break; - } - PyList_SetItem(list, j, line); - } - } - if (j == 0) - break; - - /* Check that all entries are indeed strings. If not, - apply the same rules as for file.write() and - convert the rets to strings. This is slow, but - seems to be the only way since all conversion APIs - could potentially execute Python code. */ - for (i = 0; i < j; i++) { - PyObject *v = PyList_GET_ITEM(list, i); - if (!PyString_Check(v)) { - const char *buffer; - int len; - if (PyObject_AsCharBuffer(v, &buffer, &len)) { - PyErr_SetString(PyExc_TypeError, - "writelines() " - "argument must be " - "a sequence of " - "strings"); - goto error; - } - line = PyString_FromStringAndSize(buffer, - len); - if (line == NULL) - goto error; - Py_DECREF(v); - PyList_SET_ITEM(list, i, line); - } - } - - self->f_softspace = 0; - - /* Since we are releasing the global lock, the - following code may *not* execute Python code. */ - Py_BEGIN_ALLOW_THREADS - for (i = 0; i < j; i++) { - line = PyList_GET_ITEM(list, i); - len = PyString_GET_SIZE(line); - BZ2_bzWrite (&bzerror, self->fp, - PyString_AS_STRING(line), len); - if (bzerror != BZ_OK) { - Py_BLOCK_THREADS - Util_CatchBZ2Error(bzerror); - goto error; - } - } - Py_END_ALLOW_THREADS - - if (j < CHUNKSIZE) - break; - } - - Py_INCREF(Py_None); - ret = Py_None; - - error: - RELEASE_LOCK(self); - Py_XDECREF(list); - Py_XDECREF(iter); - return ret; -#undef CHUNKSIZE -} - -PyDoc_STRVAR(BZ2File_seek__doc__, -"seek(offset [, whence]) -> None\n\ -\n\ -Move to new file position. Argument offset is a byte count. Optional\n\ -argument whence defaults to 0 (offset from start of file, offset\n\ -should be >= 0); other values are 1 (move relative to current position,\n\ -positive or negative), and 2 (move relative to end of file, usually\n\ -negative, although many platforms allow seeking beyond the end of a file).\n\ -\n\ -Note that seeking of bz2 files is emulated, and depending on the parameters\n\ -the operation may be extremely slow.\n\ -"); - -static PyObject * -BZ2File_seek(BZ2FileObject *self, PyObject *args) -{ - int where = 0; - long offset; - char small_buffer[SMALLCHUNK]; - char *buffer = small_buffer; - size_t buffersize = SMALLCHUNK; - int bytesread = 0; - int readsize; - int chunksize; - int bzerror; - int rewind = 0; - PyObject *ret = NULL; - - if (!PyArg_ParseTuple(args, "l|i:seek", &offset, &where)) - return NULL; - - ACQUIRE_LOCK(self); - Util_DropReadAhead(self); - switch (self->mode) { - case MODE_READ: - case MODE_READ_EOF: - break; - - case MODE_CLOSED: - PyErr_SetString(PyExc_ValueError, - "I/O operation on closed file"); - goto cleanup;; - - default: - PyErr_SetString(PyExc_IOError, - "seek works only while reading"); - goto cleanup;; - } - - if (offset < 0) { - if (where == 1) { - offset = self->pos + offset; - rewind = 1; - } else if (where == 2) { - if (self->size == -1) { - assert(self->mode != MODE_READ_EOF); - for (;;) { - Py_BEGIN_ALLOW_THREADS - chunksize = Util_UnivNewlineRead( - &bzerror, self->fp, - buffer, buffersize, - self); - self->pos += chunksize; - Py_END_ALLOW_THREADS - - bytesread += chunksize; - if (bzerror == BZ_STREAM_END) { - break; - } else if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - goto cleanup; - } - } - self->mode = MODE_READ_EOF; - self->size = self->pos; - bytesread = 0; - } - offset = self->size + offset; - if (offset >= self->pos) - offset -= self->pos; - else - rewind = 1; - } - if (offset < 0) - offset = 0; - } else if (where == 0) { - if (offset >= self->pos) - offset -= self->pos; - else - rewind = 1; - } - - if (rewind) { - BZ2_bzReadClose(&bzerror, self->fp); - if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - goto cleanup; - } - ret = PyObject_CallMethod(self->file, "seek", "(i)", 0); - if (!ret) - goto cleanup; - Py_DECREF(ret); - ret = NULL; - self->pos = 0; - self->fp = BZ2_bzReadOpen(&bzerror, PyFile_AsFile(self->file), - 0, 0, NULL, 0); - if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - goto cleanup; - } - self->mode = MODE_READ; - } else if (self->mode == MODE_READ_EOF) { - goto exit; - } - - if (offset == 0) - goto exit; - - /* Before getting here, offset must be set to the number of bytes - * to walk forward. */ - for (;;) { - if ((size_t)offset-bytesread > buffersize) - readsize = buffersize; - else - readsize = offset-bytesread; - Py_BEGIN_ALLOW_THREADS - chunksize = Util_UnivNewlineRead(&bzerror, self->fp, - buffer, readsize, self); - self->pos += chunksize; - Py_END_ALLOW_THREADS - bytesread += chunksize; - if (bzerror == BZ_STREAM_END) { - self->size = self->pos; - self->mode = MODE_READ_EOF; - break; - } else if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - goto cleanup; - } - if (bytesread == offset) - break; - } - -exit: - Py_INCREF(Py_None); - ret = Py_None; - -cleanup: - RELEASE_LOCK(self); - return ret; -} - -PyDoc_STRVAR(BZ2File_tell__doc__, -"tell() -> int\n\ -\n\ -Return the current file position, an integer (may be a long integer).\n\ -"); - -static PyObject * -BZ2File_tell(BZ2FileObject *self, PyObject *args) -{ - PyObject *ret = NULL; - - if (self->mode == MODE_CLOSED) { - PyErr_SetString(PyExc_ValueError, - "I/O operation on closed file"); - goto cleanup; - } - - ret = PyInt_FromLong(self->pos); - -cleanup: - return ret; -} - -PyDoc_STRVAR(BZ2File_close__doc__, -"close() -> None or (perhaps) an integer\n\ -\n\ -Close the file. Sets data attribute .closed to true. A closed file\n\ -cannot be used for further I/O operations. close() may be called more\n\ -than once without error.\n\ -"); - -static PyObject * -BZ2File_close(BZ2FileObject *self) -{ - PyObject *ret = NULL; - int bzerror = BZ_OK; - - ACQUIRE_LOCK(self); - switch (self->mode) { - case MODE_READ: - case MODE_READ_EOF: - BZ2_bzReadClose(&bzerror, self->fp); - break; - case MODE_WRITE: - BZ2_bzWriteClose(&bzerror, self->fp, - 0, NULL, NULL); - break; - } - self->mode = MODE_CLOSED; - ret = PyObject_CallMethod(self->file, "close", NULL); - if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - Py_XDECREF(ret); - ret = NULL; - } - - RELEASE_LOCK(self); - return ret; -} - -static PyObject *BZ2File_getiter(BZ2FileObject *self); - -static PyMethodDef BZ2File_methods[] = { - {"read", (PyCFunction)BZ2File_read, METH_VARARGS, BZ2File_read__doc__}, - {"readline", (PyCFunction)BZ2File_readline, METH_VARARGS, BZ2File_readline__doc__}, - {"readlines", (PyCFunction)BZ2File_readlines, METH_VARARGS, BZ2File_readlines__doc__}, - {"xreadlines", (PyCFunction)BZ2File_getiter, METH_VARARGS, BZ2File_xreadlines__doc__}, - {"write", (PyCFunction)BZ2File_write, METH_VARARGS, BZ2File_write__doc__}, - {"writelines", (PyCFunction)BZ2File_writelines, METH_O, BZ2File_writelines__doc__}, - {"seek", (PyCFunction)BZ2File_seek, METH_VARARGS, BZ2File_seek__doc__}, - {"tell", (PyCFunction)BZ2File_tell, METH_NOARGS, BZ2File_tell__doc__}, - {"close", (PyCFunction)BZ2File_close, METH_NOARGS, BZ2File_close__doc__}, - {NULL, NULL} /* sentinel */ -}; - - -/* ===================================================================== */ -/* Getters and setters of BZ2File. */ - -#ifdef WITH_UNIVERSAL_NEWLINES -/* This is a hacked version of Python's fileobject.c:get_newlines(). */ -static PyObject * -BZ2File_get_newlines(BZ2FileObject *self, void *closure) -{ - switch (self->f_newlinetypes) { - case NEWLINE_UNKNOWN: - Py_INCREF(Py_None); - return Py_None; - case NEWLINE_CR: - return PyString_FromString("\r"); - case NEWLINE_LF: - return PyString_FromString("\n"); - case NEWLINE_CR|NEWLINE_LF: - return Py_BuildValue("(ss)", "\r", "\n"); - case NEWLINE_CRLF: - return PyString_FromString("\r\n"); - case NEWLINE_CR|NEWLINE_CRLF: - return Py_BuildValue("(ss)", "\r", "\r\n"); - case NEWLINE_LF|NEWLINE_CRLF: - return Py_BuildValue("(ss)", "\n", "\r\n"); - case NEWLINE_CR|NEWLINE_LF|NEWLINE_CRLF: - return Py_BuildValue("(sss)", "\r", "\n", "\r\n"); - default: - PyErr_Format(PyExc_SystemError, - "Unknown newlines value 0x%x\n", - self->f_newlinetypes); - return NULL; - } -} -#endif - -static PyObject * -BZ2File_get_closed(BZ2FileObject *self, void *closure) -{ - return PyInt_FromLong(self->mode == MODE_CLOSED); -} - -static PyObject * -BZ2File_get_mode(BZ2FileObject *self, void *closure) -{ - return PyObject_GetAttrString(self->file, "mode"); -} - -static PyObject * -BZ2File_get_name(BZ2FileObject *self, void *closure) -{ - return PyObject_GetAttrString(self->file, "name"); -} - -static PyGetSetDef BZ2File_getset[] = { - {"closed", (getter)BZ2File_get_closed, NULL, - "True if the file is closed"}, -#ifdef WITH_UNIVERSAL_NEWLINES - {"newlines", (getter)BZ2File_get_newlines, NULL, - "end-of-line convention used in this file"}, -#endif - {"mode", (getter)BZ2File_get_mode, NULL, - "file mode ('r', 'w', or 'U')"}, - {"name", (getter)BZ2File_get_name, NULL, - "file name"}, - {NULL} /* Sentinel */ -}; - - -/* ===================================================================== */ -/* Members of BZ2File_Type. */ - -#undef OFF -#define OFF(x) offsetof(BZ2FileObject, x) - -static PyMemberDef BZ2File_members[] = { - {"softspace", T_INT, OFF(f_softspace), 0, - "flag indicating that a space needs to be printed; used by print"}, - {NULL} /* Sentinel */ -}; - -/* ===================================================================== */ -/* Slot definitions for BZ2File_Type. */ - -static int -BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = {"filename", "mode", "buffering", - "compresslevel", 0}; - PyObject *name; - char *mode = "r"; - int buffering = -1; - int compresslevel = 9; - int bzerror; - int mode_char = 0; - - self->size = -1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|sii:BZ2File", - kwlist, &name, &mode, &buffering, - &compresslevel)) - return -1; - - if (compresslevel < 1 || compresslevel > 9) { - PyErr_SetString(PyExc_ValueError, - "compresslevel must be between 1 and 9"); - return -1; - } - - for (;;) { - int error = 0; - switch (*mode) { - case 'r': - case 'w': - if (mode_char) - error = 1; - mode_char = *mode; - break; - - case 'b': - break; - - case 'U': -#ifdef WITH_UNIVERSAL_NEWLINES - self->f_univ_newline = 1; -#endif - break; - - default: - error = 1; - break; - } - if (error) { - PyErr_Format(PyExc_ValueError, - "invalid mode char %c", *mode); - return -1; - } - mode++; - if (*mode == '\0') - break; - } - - mode = (mode_char == 'r') ? "rb" : "wb"; - - self->file = PyObject_CallFunction((PyObject*)&PyFile_Type, "(Osi)", - name, mode, buffering); - if (self->file == NULL) - return -1; - - /* From now on, we have stuff to dealloc, so jump to error label - * instead of returning */ - -#ifdef WITH_THREAD - self->lock = PyThread_allocate_lock(); - if (!self->lock) - goto error; -#endif - - if (mode_char == 'r') - self->fp = BZ2_bzReadOpen(&bzerror, - PyFile_AsFile(self->file), - 0, 0, NULL, 0); - else - self->fp = BZ2_bzWriteOpen(&bzerror, - PyFile_AsFile(self->file), - compresslevel, 0, 0); - - if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - goto error; - } - - self->mode = (mode_char == 'r') ? MODE_READ : MODE_WRITE; - - return 0; - -error: - Py_DECREF(self->file); -#ifdef WITH_THREAD - if (self->lock) - PyThread_free_lock(self->lock); -#endif - return -1; -} - -static void -BZ2File_dealloc(BZ2FileObject *self) -{ - int bzerror; -#ifdef WITH_THREAD - if (self->lock) - PyThread_free_lock(self->lock); -#endif - switch (self->mode) { - case MODE_READ: - case MODE_READ_EOF: - BZ2_bzReadClose(&bzerror, self->fp); - break; - case MODE_WRITE: - BZ2_bzWriteClose(&bzerror, self->fp, - 0, NULL, NULL); - break; - } - Util_DropReadAhead(self); - Py_XDECREF(self->file); - self->ob_type->tp_free((PyObject *)self); -} - -/* This is a hacked version of Python's fileobject.c:file_getiter(). */ -static PyObject * -BZ2File_getiter(BZ2FileObject *self) -{ - if (self->mode == MODE_CLOSED) { - PyErr_SetString(PyExc_ValueError, - "I/O operation on closed file"); - return NULL; - } - Py_INCREF((PyObject*)self); - return (PyObject *)self; -} - -/* This is a hacked version of Python's fileobject.c:file_iternext(). */ -#define READAHEAD_BUFSIZE 8192 -static PyObject * -BZ2File_iternext(BZ2FileObject *self) -{ - PyStringObject* ret; - ACQUIRE_LOCK(self); - if (self->mode == MODE_CLOSED) { - PyErr_SetString(PyExc_ValueError, - "I/O operation on closed file"); - return NULL; - } - ret = Util_ReadAheadGetLineSkip(self, 0, READAHEAD_BUFSIZE); - RELEASE_LOCK(self); - if (ret == NULL || PyString_GET_SIZE(ret) == 0) { - Py_XDECREF(ret); - return NULL; - } - return (PyObject *)ret; -} - -/* ===================================================================== */ -/* BZ2File_Type definition. */ - -PyDoc_VAR(BZ2File__doc__) = -PyDoc_STR( -"BZ2File(name [, mode='r', buffering=0, compresslevel=9]) -> file object\n\ -\n\ -Open a bz2 file. The mode can be 'r' or 'w', for reading (default) or\n\ -writing. When opened for writing, the file will be created if it doesn't\n\ -exist, and truncated otherwise. If the buffering argument is given, 0 means\n\ -unbuffered, and larger numbers specify the buffer size. If compresslevel\n\ -is given, must be a number between 1 and 9.\n\ -") -#ifdef WITH_UNIVERSAL_NEWLINES -PyDoc_STR( -"\n\ -Add a 'U' to mode to open the file for input with universal newline\n\ -support. Any line ending in the input file will be seen as a '\\n' in\n\ -Python. Also, a file so opened gains the attribute 'newlines'; the value\n\ -for this attribute is one of None (no newline read yet), '\\r', '\\n',\n\ -'\\r\\n' or a tuple containing all the newline types seen. Universal\n\ -newlines are available only when reading.\n\ -") -#endif -; - -static PyTypeObject BZ2File_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "bz2.BZ2File", /*tp_name*/ - sizeof(BZ2FileObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)BZ2File_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - PyObject_GenericGetAttr,/*tp_getattro*/ - PyObject_GenericSetAttr,/*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - BZ2File__doc__, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - (getiterfunc)BZ2File_getiter, /*tp_iter*/ - (iternextfunc)BZ2File_iternext, /*tp_iternext*/ - BZ2File_methods, /*tp_methods*/ - BZ2File_members, /*tp_members*/ - BZ2File_getset, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - (initproc)BZ2File_init, /*tp_init*/ - PyType_GenericAlloc, /*tp_alloc*/ - PyType_GenericNew, /*tp_new*/ - _PyObject_Del, /*tp_free*/ - 0, /*tp_is_gc*/ -}; - - -/* ===================================================================== */ -/* Methods of BZ2Comp. */ - -PyDoc_STRVAR(BZ2Comp_compress__doc__, -"compress(data) -> string\n\ -\n\ -Provide more data to the compressor object. It will return chunks of\n\ -compressed data whenever possible. When you've finished providing data\n\ -to compress, call the flush() method to finish the compression process,\n\ -and return what is left in the internal buffers.\n\ -"); - -static PyObject * -BZ2Comp_compress(BZ2CompObject *self, PyObject *args) -{ - char *data; - int datasize; - int bufsize = SMALLCHUNK; - PY_LONG_LONG totalout; - PyObject *ret = NULL; - bz_stream *bzs = &self->bzs; - int bzerror; - - if (!PyArg_ParseTuple(args, "s#", &data, &datasize)) - return NULL; - - ACQUIRE_LOCK(self); - if (!self->running) { - PyErr_SetString(PyExc_ValueError, - "this object was already flushed"); - goto error; - } - - ret = PyString_FromStringAndSize(NULL, bufsize); - if (!ret) - goto error; - - bzs->next_in = data; - bzs->avail_in = datasize; - bzs->next_out = BUF(ret); - bzs->avail_out = bufsize; - - totalout = BZS_TOTAL_OUT(bzs); - - for (;;) { - Py_BEGIN_ALLOW_THREADS - bzerror = BZ2_bzCompress(bzs, BZ_RUN); - Py_END_ALLOW_THREADS - if (bzerror != BZ_RUN_OK) { - Util_CatchBZ2Error(bzerror); - goto error; - } - if (bzs->avail_out == 0) { - bufsize = Util_NewBufferSize(bufsize); - if (_PyString_Resize(&ret, bufsize) < 0) { - BZ2_bzCompressEnd(bzs); - goto error; - } - bzs->next_out = BUF(ret) + (BZS_TOTAL_OUT(bzs) - - totalout); - bzs->avail_out = bufsize - (bzs->next_out - BUF(ret)); - } else if (bzs->avail_in == 0) { - break; - } - } - - _PyString_Resize(&ret, (int)(BZS_TOTAL_OUT(bzs) - totalout)); - - RELEASE_LOCK(self); - return ret; - -error: - RELEASE_LOCK(self); - Py_XDECREF(ret); - return NULL; -} - -PyDoc_STRVAR(BZ2Comp_flush__doc__, -"flush() -> string\n\ -\n\ -Finish the compression process and return what is left in internal buffers.\n\ -You must not use the compressor object after calling this method.\n\ -"); - -static PyObject * -BZ2Comp_flush(BZ2CompObject *self) -{ - int bufsize = SMALLCHUNK; - PyObject *ret = NULL; - bz_stream *bzs = &self->bzs; - PY_LONG_LONG totalout; - int bzerror; - - ACQUIRE_LOCK(self); - if (!self->running) { - PyErr_SetString(PyExc_ValueError, "object was already " - "flushed"); - goto error; - } - self->running = 0; - - ret = PyString_FromStringAndSize(NULL, bufsize); - if (!ret) - goto error; - - bzs->next_out = BUF(ret); - bzs->avail_out = bufsize; - - totalout = BZS_TOTAL_OUT(bzs); - - for (;;) { - Py_BEGIN_ALLOW_THREADS - bzerror = BZ2_bzCompress(bzs, BZ_FINISH); - Py_END_ALLOW_THREADS - if (bzerror == BZ_STREAM_END) { - break; - } else if (bzerror != BZ_FINISH_OK) { - Util_CatchBZ2Error(bzerror); - goto error; - } - if (bzs->avail_out == 0) { - bufsize = Util_NewBufferSize(bufsize); - if (_PyString_Resize(&ret, bufsize) < 0) - goto error; - bzs->next_out = BUF(ret); - bzs->next_out = BUF(ret) + (BZS_TOTAL_OUT(bzs) - - totalout); - bzs->avail_out = bufsize - (bzs->next_out - BUF(ret)); - } - } - - if (bzs->avail_out != 0) - _PyString_Resize(&ret, (int)(BZS_TOTAL_OUT(bzs) - totalout)); - - RELEASE_LOCK(self); - return ret; - -error: - RELEASE_LOCK(self); - Py_XDECREF(ret); - return NULL; -} - -static PyMethodDef BZ2Comp_methods[] = { - {"compress", (PyCFunction)BZ2Comp_compress, METH_VARARGS, - BZ2Comp_compress__doc__}, - {"flush", (PyCFunction)BZ2Comp_flush, METH_NOARGS, - BZ2Comp_flush__doc__}, - {NULL, NULL} /* sentinel */ -}; - - -/* ===================================================================== */ -/* Slot definitions for BZ2Comp_Type. */ - -static int -BZ2Comp_init(BZ2CompObject *self, PyObject *args, PyObject *kwargs) -{ - int compresslevel = 9; - int bzerror; - static char *kwlist[] = {"compresslevel", 0}; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:BZ2Compressor", - kwlist, &compresslevel)) - return -1; - - if (compresslevel < 1 || compresslevel > 9) { - PyErr_SetString(PyExc_ValueError, - "compresslevel must be between 1 and 9"); - goto error; - } - -#ifdef WITH_THREAD - self->lock = PyThread_allocate_lock(); - if (!self->lock) - goto error; -#endif - - memset(&self->bzs, 0, sizeof(bz_stream)); - bzerror = BZ2_bzCompressInit(&self->bzs, compresslevel, 0, 0); - if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - goto error; - } - - self->running = 1; - - return 0; -error: -#ifdef WITH_THREAD - if (self->lock) - PyThread_free_lock(self->lock); -#endif - return -1; -} - -static void -BZ2Comp_dealloc(BZ2CompObject *self) -{ -#ifdef WITH_THREAD - if (self->lock) - PyThread_free_lock(self->lock); -#endif - BZ2_bzCompressEnd(&self->bzs); - self->ob_type->tp_free((PyObject *)self); -} - - -/* ===================================================================== */ -/* BZ2Comp_Type definition. */ - -PyDoc_STRVAR(BZ2Comp__doc__, -"BZ2Compressor([compresslevel=9]) -> compressor object\n\ -\n\ -Create a new compressor object. This object may be used to compress\n\ -data sequentially. If you want to compress data in one shot, use the\n\ -compress() function instead. The compresslevel parameter, if given,\n\ -must be a number between 1 and 9.\n\ -"); - -static PyTypeObject BZ2Comp_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "bz2.BZ2Compressor", /*tp_name*/ - sizeof(BZ2CompObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)BZ2Comp_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - PyObject_GenericGetAttr,/*tp_getattro*/ - PyObject_GenericSetAttr,/*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - BZ2Comp__doc__, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - BZ2Comp_methods, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - (initproc)BZ2Comp_init, /*tp_init*/ - PyType_GenericAlloc, /*tp_alloc*/ - PyType_GenericNew, /*tp_new*/ - _PyObject_Del, /*tp_free*/ - 0, /*tp_is_gc*/ -}; - - -/* ===================================================================== */ -/* Members of BZ2Decomp. */ - -#undef OFF -#define OFF(x) offsetof(BZ2DecompObject, x) - -static PyMemberDef BZ2Decomp_members[] = { - {"unused_data", T_OBJECT, OFF(unused_data), RO}, - {NULL} /* Sentinel */ -}; - - -/* ===================================================================== */ -/* Methods of BZ2Decomp. */ - -PyDoc_STRVAR(BZ2Decomp_decompress__doc__, -"decompress(data) -> string\n\ -\n\ -Provide more data to the decompressor object. It will return chunks\n\ -of decompressed data whenever possible. If you try to decompress data\n\ -after the end of stream is found, EOFError will be raised. If any data\n\ -was found after the end of stream, it'll be ignored and saved in\n\ -unused_data attribute.\n\ -"); - -static PyObject * -BZ2Decomp_decompress(BZ2DecompObject *self, PyObject *args) -{ - char *data; - int datasize; - int bufsize = SMALLCHUNK; - PY_LONG_LONG totalout; - PyObject *ret = NULL; - bz_stream *bzs = &self->bzs; - int bzerror; - - if (!PyArg_ParseTuple(args, "s#", &data, &datasize)) - return NULL; - - ACQUIRE_LOCK(self); - if (!self->running) { - PyErr_SetString(PyExc_EOFError, "end of stream was " - "already found"); - goto error; - } - - ret = PyString_FromStringAndSize(NULL, bufsize); - if (!ret) - goto error; - - bzs->next_in = data; - bzs->avail_in = datasize; - bzs->next_out = BUF(ret); - bzs->avail_out = bufsize; - - totalout = BZS_TOTAL_OUT(bzs); - - for (;;) { - Py_BEGIN_ALLOW_THREADS - bzerror = BZ2_bzDecompress(bzs); - Py_END_ALLOW_THREADS - if (bzerror == BZ_STREAM_END) { - if (bzs->avail_in != 0) { - Py_DECREF(self->unused_data); - self->unused_data = - PyString_FromStringAndSize(bzs->next_in, - bzs->avail_in); - } - self->running = 0; - break; - } - if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - goto error; - } - if (bzs->avail_out == 0) { - bufsize = Util_NewBufferSize(bufsize); - if (_PyString_Resize(&ret, bufsize) < 0) { - BZ2_bzDecompressEnd(bzs); - goto error; - } - bzs->next_out = BUF(ret); - bzs->next_out = BUF(ret) + (BZS_TOTAL_OUT(bzs) - - totalout); - bzs->avail_out = bufsize - (bzs->next_out - BUF(ret)); - } else if (bzs->avail_in == 0) { - break; - } - } - - if (bzs->avail_out != 0) - _PyString_Resize(&ret, (int)(BZS_TOTAL_OUT(bzs) - totalout)); - - RELEASE_LOCK(self); - return ret; - -error: - RELEASE_LOCK(self); - Py_XDECREF(ret); - return NULL; -} - -static PyMethodDef BZ2Decomp_methods[] = { - {"decompress", (PyCFunction)BZ2Decomp_decompress, METH_VARARGS, BZ2Decomp_decompress__doc__}, - {NULL, NULL} /* sentinel */ -}; - - -/* ===================================================================== */ -/* Slot definitions for BZ2Decomp_Type. */ - -static int -BZ2Decomp_init(BZ2DecompObject *self, PyObject *args, PyObject *kwargs) -{ - int bzerror; - - if (!PyArg_ParseTuple(args, ":BZ2Decompressor")) - return -1; - -#ifdef WITH_THREAD - self->lock = PyThread_allocate_lock(); - if (!self->lock) - goto error; -#endif - - self->unused_data = PyString_FromString(""); - if (!self->unused_data) - goto error; - - memset(&self->bzs, 0, sizeof(bz_stream)); - bzerror = BZ2_bzDecompressInit(&self->bzs, 0, 0); - if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - goto error; - } - - self->running = 1; - - return 0; - -error: -#ifdef WITH_THREAD - if (self->lock) - PyThread_free_lock(self->lock); -#endif - Py_XDECREF(self->unused_data); - return -1; -} - -static void -BZ2Decomp_dealloc(BZ2DecompObject *self) -{ -#ifdef WITH_THREAD - if (self->lock) - PyThread_free_lock(self->lock); -#endif - Py_XDECREF(self->unused_data); - BZ2_bzDecompressEnd(&self->bzs); - self->ob_type->tp_free((PyObject *)self); -} - - -/* ===================================================================== */ -/* BZ2Decomp_Type definition. */ - -PyDoc_STRVAR(BZ2Decomp__doc__, -"BZ2Decompressor() -> decompressor object\n\ -\n\ -Create a new decompressor object. This object may be used to decompress\n\ -data sequentially. If you want to decompress data in one shot, use the\n\ -decompress() function instead.\n\ -"); - -static PyTypeObject BZ2Decomp_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "bz2.BZ2Decompressor", /*tp_name*/ - sizeof(BZ2DecompObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)BZ2Decomp_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - PyObject_GenericGetAttr,/*tp_getattro*/ - PyObject_GenericSetAttr,/*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - BZ2Decomp__doc__, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - BZ2Decomp_methods, /*tp_methods*/ - BZ2Decomp_members, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - (initproc)BZ2Decomp_init, /*tp_init*/ - PyType_GenericAlloc, /*tp_alloc*/ - PyType_GenericNew, /*tp_new*/ - _PyObject_Del, /*tp_free*/ - 0, /*tp_is_gc*/ -}; - - -/* ===================================================================== */ -/* Module functions. */ - -PyDoc_STRVAR(bz2_compress__doc__, -"compress(data [, compresslevel=9]) -> string\n\ -\n\ -Compress data in one shot. If you want to compress data sequentially,\n\ -use an instance of BZ2Compressor instead. The compresslevel parameter, if\n\ -given, must be a number between 1 and 9.\n\ -"); - -static PyObject * -bz2_compress(PyObject *self, PyObject *args, PyObject *kwargs) -{ - int compresslevel=9; - char *data; - int datasize; - int bufsize; - PyObject *ret = NULL; - bz_stream _bzs; - bz_stream *bzs = &_bzs; - int bzerror; - static char *kwlist[] = {"data", "compresslevel", 0}; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|i", - kwlist, &data, &datasize, - &compresslevel)) - return NULL; - - if (compresslevel < 1 || compresslevel > 9) { - PyErr_SetString(PyExc_ValueError, - "compresslevel must be between 1 and 9"); - return NULL; - } - - /* Conforming to bz2 manual, this is large enough to fit compressed - * data in one shot. We will check it later anyway. */ - bufsize = datasize + (datasize/100+1) + 600; - - ret = PyString_FromStringAndSize(NULL, bufsize); - if (!ret) - return NULL; - - memset(bzs, 0, sizeof(bz_stream)); - - bzs->next_in = data; - bzs->avail_in = datasize; - bzs->next_out = BUF(ret); - bzs->avail_out = bufsize; - - bzerror = BZ2_bzCompressInit(bzs, compresslevel, 0, 0); - if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - Py_DECREF(ret); - return NULL; - } - - for (;;) { - Py_BEGIN_ALLOW_THREADS - bzerror = BZ2_bzCompress(bzs, BZ_FINISH); - Py_END_ALLOW_THREADS - if (bzerror == BZ_STREAM_END) { - break; - } else if (bzerror != BZ_FINISH_OK) { - BZ2_bzCompressEnd(bzs); - Util_CatchBZ2Error(bzerror); - Py_DECREF(ret); - return NULL; - } - if (bzs->avail_out == 0) { - bufsize = Util_NewBufferSize(bufsize); - if (_PyString_Resize(&ret, bufsize) < 0) { - BZ2_bzCompressEnd(bzs); - Py_DECREF(ret); - return NULL; - } - bzs->next_out = BUF(ret) + BZS_TOTAL_OUT(bzs); - bzs->avail_out = bufsize - (bzs->next_out - BUF(ret)); - } - } - - if (bzs->avail_out != 0) - _PyString_Resize(&ret, (int)BZS_TOTAL_OUT(bzs)); - BZ2_bzCompressEnd(bzs); - - return ret; -} - -PyDoc_STRVAR(bz2_decompress__doc__, -"decompress(data) -> decompressed data\n\ -\n\ -Decompress data in one shot. If you want to decompress data sequentially,\n\ -use an instance of BZ2Decompressor instead.\n\ -"); - -static PyObject * -bz2_decompress(PyObject *self, PyObject *args) -{ - char *data; - int datasize; - int bufsize = SMALLCHUNK; - PyObject *ret; - bz_stream _bzs; - bz_stream *bzs = &_bzs; - int bzerror; - - if (!PyArg_ParseTuple(args, "s#", &data, &datasize)) - return NULL; - - if (datasize == 0) - return PyString_FromString(""); - - ret = PyString_FromStringAndSize(NULL, bufsize); - if (!ret) - return NULL; - - memset(bzs, 0, sizeof(bz_stream)); - - bzs->next_in = data; - bzs->avail_in = datasize; - bzs->next_out = BUF(ret); - bzs->avail_out = bufsize; - - bzerror = BZ2_bzDecompressInit(bzs, 0, 0); - if (bzerror != BZ_OK) { - Util_CatchBZ2Error(bzerror); - Py_DECREF(ret); - return NULL; - } - - for (;;) { - Py_BEGIN_ALLOW_THREADS - bzerror = BZ2_bzDecompress(bzs); - Py_END_ALLOW_THREADS - if (bzerror == BZ_STREAM_END) { - break; - } else if (bzerror != BZ_OK) { - BZ2_bzDecompressEnd(bzs); - Util_CatchBZ2Error(bzerror); - Py_DECREF(ret); - return NULL; - } - if (bzs->avail_out == 0) { - bufsize = Util_NewBufferSize(bufsize); - if (_PyString_Resize(&ret, bufsize) < 0) { - BZ2_bzDecompressEnd(bzs); - Py_DECREF(ret); - return NULL; - } - bzs->next_out = BUF(ret) + BZS_TOTAL_OUT(bzs); - bzs->avail_out = bufsize - (bzs->next_out - BUF(ret)); - } else if (bzs->avail_in == 0) { - BZ2_bzDecompressEnd(bzs); - PyErr_SetString(PyExc_ValueError, - "couldn't find end of stream"); - Py_DECREF(ret); - return NULL; - } - } - - if (bzs->avail_out != 0) - _PyString_Resize(&ret, (int)BZS_TOTAL_OUT(bzs)); - BZ2_bzDecompressEnd(bzs); - - return ret; -} - -static PyMethodDef bz2_methods[] = { - {"compress", (PyCFunction) bz2_compress, METH_VARARGS|METH_KEYWORDS, - bz2_compress__doc__}, - {"decompress", (PyCFunction) bz2_decompress, METH_VARARGS, - bz2_decompress__doc__}, - {NULL, NULL} /* sentinel */ -}; - -/* ===================================================================== */ -/* Initialization function. */ - -PyDoc_STRVAR(bz2__doc__, -"The python bz2 module provides a comprehensive interface for\n\ -the bz2 compression library. It implements a complete file\n\ -interface, one shot (de)compression functions, and types for\n\ -sequential (de)compression.\n\ -"); - -PyMODINIT_FUNC -initbz2(void) -{ - PyObject *m; - - BZ2File_Type.ob_type = &PyType_Type; - BZ2Comp_Type.ob_type = &PyType_Type; - BZ2Decomp_Type.ob_type = &PyType_Type; - - m = Py_InitModule3("bz2", bz2_methods, bz2__doc__); - - PyModule_AddObject(m, "__author__", PyString_FromString(__author__)); - - Py_INCREF(&BZ2File_Type); - PyModule_AddObject(m, "BZ2File", (PyObject *)&BZ2File_Type); - - Py_INCREF(&BZ2Comp_Type); - PyModule_AddObject(m, "BZ2Compressor", (PyObject *)&BZ2Comp_Type); - - Py_INCREF(&BZ2Decomp_Type); - PyModule_AddObject(m, "BZ2Decompressor", (PyObject *)&BZ2Decomp_Type); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/cPickle.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/cPickle.c deleted file mode 100644 index 3adaa11a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/cPickle.c +++ /dev/null @@ -1,5761 +0,0 @@ -#include "Python.h" -#include "cStringIO.h" -#include "structmember.h" - -PyDoc_STRVAR(cPickle_module_documentation, -"C implementation and optimization of the Python pickle module."); - -#ifndef Py_eval_input -#include -#define Py_eval_input eval_input -#endif /* Py_eval_input */ - -#define DEL_LIST_SLICE(list, from, to) (PyList_SetSlice(list, from, to, NULL)) - -#define WRITE_BUF_SIZE 256 - -/* Bump this when new opcodes are added to the pickle protocol. */ -#define HIGHEST_PROTOCOL 2 - -/* - * Pickle opcodes. These must be kept in synch with pickle.py. Extensive - * docs are in pickletools.py. - */ -#define MARK '(' -#define STOP '.' -#define POP '0' -#define POP_MARK '1' -#define DUP '2' -#define FLOAT 'F' -#define BINFLOAT 'G' -#define INT 'I' -#define BININT 'J' -#define BININT1 'K' -#define LONG 'L' -#define BININT2 'M' -#define NONE 'N' -#define PERSID 'P' -#define BINPERSID 'Q' -#define REDUCE 'R' -#define STRING 'S' -#define BINSTRING 'T' -#define SHORT_BINSTRING 'U' -#define UNICODE 'V' -#define BINUNICODE 'X' -#define APPEND 'a' -#define BUILD 'b' -#define GLOBAL 'c' -#define DICT 'd' -#define EMPTY_DICT '}' -#define APPENDS 'e' -#define GET 'g' -#define BINGET 'h' -#define INST 'i' -#define LONG_BINGET 'j' -#define LIST 'l' -#define EMPTY_LIST ']' -#define OBJ 'o' -#define PUT 'p' -#define BINPUT 'q' -#define LONG_BINPUT 'r' -#define SETITEM 's' -#define TUPLE 't' -#define EMPTY_TUPLE ')' -#define SETITEMS 'u' - -/* Protocol 2. */ -#define PROTO '\x80' /* identify pickle protocol */ -#define NEWOBJ '\x81' /* build object by applying cls.__new__ to argtuple */ -#define EXT1 '\x82' /* push object from extension registry; 1-byte index */ -#define EXT2 '\x83' /* ditto, but 2-byte index */ -#define EXT4 '\x84' /* ditto, but 4-byte index */ -#define TUPLE1 '\x85' /* build 1-tuple from stack top */ -#define TUPLE2 '\x86' /* build 2-tuple from two topmost stack items */ -#define TUPLE3 '\x87' /* build 3-tuple from three topmost stack items */ -#define NEWTRUE '\x88' /* push True */ -#define NEWFALSE '\x89' /* push False */ -#define LONG1 '\x8a' /* push long from < 256 bytes */ -#define LONG4 '\x8b' /* push really big long */ - -/* There aren't opcodes -- they're ways to pickle bools before protocol 2, - * so that unpicklers written before bools were introduced unpickle them - * as ints, but unpicklers after can recognize that bools were intended. - * Note that protocol 2 added direct ways to pickle bools. - */ -#undef TRUE -#define TRUE "I01\n" -#undef FALSE -#define FALSE "I00\n" - -/* Keep in synch with pickle.Pickler._BATCHSIZE. This is how many elements - * batch_list/dict() pumps out before doing APPENDS/SETITEMS. Nothing will - * break if this gets out of synch with pickle.py, but it's unclear that - * would help anything either. - */ -#define BATCHSIZE 1000 - -static char MARKv = MARK; - -static PyObject *PickleError; -static PyObject *PicklingError; -static PyObject *UnpickleableError; -static PyObject *UnpicklingError; -static PyObject *BadPickleGet; - -/* As the name says, an empty tuple. */ -static PyObject *empty_tuple; - -/* copy_reg.dispatch_table, {type_object: pickling_function} */ -static PyObject *dispatch_table; - -/* For EXT[124] opcodes. */ -/* copy_reg._extension_registry, {(module_name, function_name): code} */ -static PyObject *extension_registry; -/* copy_reg._inverted_registry, {code: (module_name, function_name)} */ -static PyObject *inverted_registry; -/* copy_reg._extension_cache, {code: object} */ -static PyObject *extension_cache; - -/* For looking up name pairs in copy_reg._extension_registry. */ -static PyObject *two_tuple; - -static PyObject *__class___str, *__getinitargs___str, *__dict___str, - *__getstate___str, *__setstate___str, *__name___str, *__reduce___str, - *__reduce_ex___str, - *write_str, *append_str, - *read_str, *readline_str, *__main___str, *__basicnew___str, - *copy_reg_str, *dispatch_table_str; - -/************************************************************************* - Internal Data type for pickle data. */ - -typedef struct { - PyObject_HEAD - int length; /* number of initial slots in data currently used */ - int size; /* number of slots in data allocated */ - PyObject **data; -} Pdata; - -static void -Pdata_dealloc(Pdata *self) -{ - int i; - PyObject **p; - - for (i = self->length, p = self->data; --i >= 0; p++) { - Py_DECREF(*p); - } - if (self->data) - free(self->data); - PyObject_Del(self); -} - -static PyTypeObject PdataType = { - PyObject_HEAD_INIT(NULL) 0, "cPickle.Pdata", sizeof(Pdata), 0, - (destructor)Pdata_dealloc, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0L,0L,0L,0L, "" -}; - -#define Pdata_Check(O) ((O)->ob_type == &PdataType) - -static PyObject * -Pdata_New(void) -{ - Pdata *self; - - if (!(self = PyObject_New(Pdata, &PdataType))) - return NULL; - self->size = 8; - self->length = 0; - self->data = malloc(self->size * sizeof(PyObject*)); - if (self->data) - return (PyObject*)self; - Py_DECREF(self); - return PyErr_NoMemory(); -} - -static int -stackUnderflow(void) -{ - PyErr_SetString(UnpicklingError, "unpickling stack underflow"); - return -1; -} - -/* Retain only the initial clearto items. If clearto >= the current - * number of items, this is a (non-erroneous) NOP. - */ -static int -Pdata_clear(Pdata *self, int clearto) -{ - int i; - PyObject **p; - - if (clearto < 0) return stackUnderflow(); - if (clearto >= self->length) return 0; - - for (i = self->length, p = self->data + clearto; - --i >= clearto; - p++) { - Py_DECREF(*p); - } - self->length = clearto; - - return 0; -} - -static int -Pdata_grow(Pdata *self) -{ - int bigger; - size_t nbytes; - - bigger = self->size << 1; - if (bigger <= 0) /* was 0, or new value overflows */ - goto nomemory; - if ((int)(size_t)bigger != bigger) - goto nomemory; - nbytes = (size_t)bigger * sizeof(PyObject *); - if (nbytes / sizeof(PyObject *) != (size_t)bigger) - goto nomemory; - self->data = realloc(self->data, nbytes); - if (self->data == NULL) - goto nomemory; - self->size = bigger; - return 0; - - nomemory: - self->size = 0; - PyErr_NoMemory(); - return -1; -} - -/* D is a Pdata*. Pop the topmost element and store it into V, which - * must be an lvalue holding PyObject*. On stack underflow, UnpicklingError - * is raised and V is set to NULL. D and V may be evaluated several times. - */ -#define PDATA_POP(D, V) { \ - if ((D)->length) \ - (V) = (D)->data[--((D)->length)]; \ - else { \ - PyErr_SetString(UnpicklingError, "bad pickle data"); \ - (V) = NULL; \ - } \ -} - -/* PDATA_PUSH and PDATA_APPEND both push rvalue PyObject* O on to Pdata* - * D. If the Pdata stack can't be grown to hold the new value, both - * raise MemoryError and execute "return ER". The difference is in ownership - * of O after: _PUSH transfers ownership of O from the caller to the stack - * (no incref of O is done, and in case of error O is decrefed), while - * _APPEND pushes a new reference. - */ - -/* Push O on stack D, giving ownership of O to the stack. */ -#define PDATA_PUSH(D, O, ER) { \ - if (((Pdata*)(D))->length == ((Pdata*)(D))->size && \ - Pdata_grow((Pdata*)(D)) < 0) { \ - Py_DECREF(O); \ - return ER; \ - } \ - ((Pdata*)(D))->data[((Pdata*)(D))->length++] = (O); \ -} - -/* Push O on stack D, pushing a new reference. */ -#define PDATA_APPEND(D, O, ER) { \ - if (((Pdata*)(D))->length == ((Pdata*)(D))->size && \ - Pdata_grow((Pdata*)(D)) < 0) \ - return ER; \ - Py_INCREF(O); \ - ((Pdata*)(D))->data[((Pdata*)(D))->length++] = (O); \ -} - - -static PyObject * -Pdata_popTuple(Pdata *self, int start) -{ - PyObject *r; - int i, j, l; - - l = self->length-start; - r = PyTuple_New(l); - if (r == NULL) - return NULL; - for (i = start, j = 0 ; j < l; i++, j++) - PyTuple_SET_ITEM(r, j, self->data[i]); - - self->length = start; - return r; -} - -static PyObject * -Pdata_popList(Pdata *self, int start) -{ - PyObject *r; - int i, j, l; - - l=self->length-start; - if (!( r=PyList_New(l))) return NULL; - for (i=start, j=0 ; j < l; i++, j++) - PyList_SET_ITEM(r, j, self->data[i]); - - self->length=start; - return r; -} - -/*************************************************************************/ - -#define ARG_TUP(self, o) { \ - if (self->arg || (self->arg=PyTuple_New(1))) { \ - Py_XDECREF(PyTuple_GET_ITEM(self->arg,0)); \ - PyTuple_SET_ITEM(self->arg,0,o); \ - } \ - else { \ - Py_DECREF(o); \ - } \ -} - -#define FREE_ARG_TUP(self) { \ - if (self->arg->ob_refcnt > 1) { \ - Py_DECREF(self->arg); \ - self->arg=NULL; \ - } \ - } - -typedef struct Picklerobject { - PyObject_HEAD - FILE *fp; - PyObject *write; - PyObject *file; - PyObject *memo; - PyObject *arg; - PyObject *pers_func; - PyObject *inst_pers_func; - - /* pickle protocol number, >= 0 */ - int proto; - - /* bool, true if proto > 0 */ - int bin; - - int fast; /* Fast mode doesn't save in memo, don't use if circ ref */ - int nesting; - int (*write_func)(struct Picklerobject *, char *, int); - char *write_buf; - int buf_size; - PyObject *dispatch_table; - int fast_container; /* count nested container dumps */ - PyObject *fast_memo; -} Picklerobject; - -#ifndef PY_CPICKLE_FAST_LIMIT -#define PY_CPICKLE_FAST_LIMIT 50 -#endif - -static PyTypeObject Picklertype; - -typedef struct Unpicklerobject { - PyObject_HEAD - FILE *fp; - PyObject *file; - PyObject *readline; - PyObject *read; - PyObject *memo; - PyObject *arg; - Pdata *stack; - PyObject *mark; - PyObject *pers_func; - PyObject *last_string; - int *marks; - int num_marks; - int marks_size; - int (*read_func)(struct Unpicklerobject *, char **, int); - int (*readline_func)(struct Unpicklerobject *, char **); - int buf_size; - char *buf; - PyObject *find_class; -} Unpicklerobject; - -static PyTypeObject Unpicklertype; - -/* Forward decls that need the above structs */ -static int save(Picklerobject *, PyObject *, int); -static int put2(Picklerobject *, PyObject *); - -static -PyObject * -cPickle_ErrFormat(PyObject *ErrType, char *stringformat, char *format, ...) -{ - va_list va; - PyObject *args=0, *retval=0; - va_start(va, format); - - if (format) args = Py_VaBuildValue(format, va); - va_end(va); - if (format && ! args) return NULL; - if (stringformat && !(retval=PyString_FromString(stringformat))) - return NULL; - - if (retval) { - if (args) { - PyObject *v; - v=PyString_Format(retval, args); - Py_DECREF(retval); - Py_DECREF(args); - if (! v) return NULL; - retval=v; - } - } - else - if (args) retval=args; - else { - PyErr_SetObject(ErrType,Py_None); - return NULL; - } - PyErr_SetObject(ErrType,retval); - Py_DECREF(retval); - return NULL; -} - -static int -write_file(Picklerobject *self, char *s, int n) -{ - size_t nbyteswritten; - - if (s == NULL) { - return 0; - } - - Py_BEGIN_ALLOW_THREADS - nbyteswritten = fwrite(s, sizeof(char), n, self->fp); - Py_END_ALLOW_THREADS - if (nbyteswritten != (size_t)n) { - PyErr_SetFromErrno(PyExc_IOError); - return -1; - } - - return n; -} - -static int -write_cStringIO(Picklerobject *self, char *s, int n) -{ - if (s == NULL) { - return 0; - } - - if (PycStringIO->cwrite((PyObject *)self->file, s, n) != n) { - return -1; - } - - return n; -} - -static int -write_none(Picklerobject *self, char *s, int n) -{ - if (s == NULL) return 0; - return n; -} - -static int -write_other(Picklerobject *self, char *s, int n) -{ - PyObject *py_str = 0, *junk = 0; - - if (s == NULL) { - if (!( self->buf_size )) return 0; - py_str = PyString_FromStringAndSize(self->write_buf, - self->buf_size); - if (!py_str) - return -1; - } - else { - if (self->buf_size && (n + self->buf_size) > WRITE_BUF_SIZE) { - if (write_other(self, NULL, 0) < 0) - return -1; - } - - if (n > WRITE_BUF_SIZE) { - if (!( py_str = - PyString_FromStringAndSize(s, n))) - return -1; - } - else { - memcpy(self->write_buf + self->buf_size, s, n); - self->buf_size += n; - return n; - } - } - - if (self->write) { - /* object with write method */ - ARG_TUP(self, py_str); - if (self->arg) { - junk = PyObject_Call(self->write, self->arg, NULL); - FREE_ARG_TUP(self); - } - if (junk) Py_DECREF(junk); - else return -1; - } - else - PDATA_PUSH(self->file, py_str, -1); - - self->buf_size = 0; - return n; -} - - -static int -read_file(Unpicklerobject *self, char **s, int n) -{ - size_t nbytesread; - - if (self->buf_size == 0) { - int size; - - size = ((n < 32) ? 32 : n); - if (!( self->buf = (char *)malloc(size))) { - PyErr_NoMemory(); - return -1; - } - - self->buf_size = size; - } - else if (n > self->buf_size) { - self->buf = (char *)realloc(self->buf, n); - if (!self->buf) { - PyErr_NoMemory(); - return -1; - } - self->buf_size = n; - } - - Py_BEGIN_ALLOW_THREADS - nbytesread = fread(self->buf, sizeof(char), n, self->fp); - Py_END_ALLOW_THREADS - if (nbytesread != (size_t)n) { - if (feof(self->fp)) { - PyErr_SetNone(PyExc_EOFError); - return -1; - } - - PyErr_SetFromErrno(PyExc_IOError); - return -1; - } - - *s = self->buf; - - return n; -} - - -static int -readline_file(Unpicklerobject *self, char **s) -{ - int i; - - if (self->buf_size == 0) { - if (!( self->buf = (char *)malloc(40))) { - PyErr_NoMemory(); - return -1; - } - self->buf_size = 40; - } - - i = 0; - while (1) { - int bigger; - for (; i < (self->buf_size - 1); i++) { - if (feof(self->fp) || - (self->buf[i] = getc(self->fp)) == '\n') { - self->buf[i + 1] = '\0'; - *s = self->buf; - return i + 1; - } - } - bigger = self->buf_size << 1; - if (bigger <= 0) { /* overflow */ - PyErr_NoMemory(); - return -1; - } - self->buf = (char *)realloc(self->buf, bigger); - if (!self->buf) { - PyErr_NoMemory(); - return -1; - } - self->buf_size = bigger; - } -} - - -static int -read_cStringIO(Unpicklerobject *self, char **s, int n) -{ - char *ptr; - - if (PycStringIO->cread((PyObject *)self->file, &ptr, n) != n) { - PyErr_SetNone(PyExc_EOFError); - return -1; - } - - *s = ptr; - - return n; -} - - -static int -readline_cStringIO(Unpicklerobject *self, char **s) -{ - int n; - char *ptr; - - if ((n = PycStringIO->creadline((PyObject *)self->file, &ptr)) < 0) { - return -1; - } - - *s = ptr; - - return n; -} - - -static int -read_other(Unpicklerobject *self, char **s, int n) -{ - PyObject *bytes, *str=0; - - if (!( bytes = PyInt_FromLong(n))) return -1; - - ARG_TUP(self, bytes); - if (self->arg) { - str = PyObject_Call(self->read, self->arg, NULL); - FREE_ARG_TUP(self); - } - if (! str) return -1; - - Py_XDECREF(self->last_string); - self->last_string = str; - - if (! (*s = PyString_AsString(str))) return -1; - return n; -} - - -static int -readline_other(Unpicklerobject *self, char **s) -{ - PyObject *str; - int str_size; - - if (!( str = PyObject_CallObject(self->readline, empty_tuple))) { - return -1; - } - - if ((str_size = PyString_Size(str)) < 0) - return -1; - - Py_XDECREF(self->last_string); - self->last_string = str; - - if (! (*s = PyString_AsString(str))) - return -1; - - return str_size; -} - -/* Copy the first n bytes from s into newly malloc'ed memory, plus a - * trailing 0 byte. Return a pointer to that, or NULL if out of memory. - * The caller is responsible for free()'ing the return value. - */ -static char * -pystrndup(char *s, int n) -{ - char *r = (char *)malloc(n+1); - if (r == NULL) - return (char*)PyErr_NoMemory(); - memcpy(r, s, n); - r[n] = 0; - return r; -} - - -static int -get(Picklerobject *self, PyObject *id) -{ - PyObject *value, *mv; - long c_value; - char s[30]; - size_t len; - - if (!( mv = PyDict_GetItem(self->memo, id))) { - PyErr_SetObject(PyExc_KeyError, id); - return -1; - } - - if (!( value = PyTuple_GetItem(mv, 0))) - return -1; - - if (!( PyInt_Check(value))) { - PyErr_SetString(PicklingError, "no int where int expected in memo"); - return -1; - } - c_value = PyInt_AS_LONG((PyIntObject*)value); - - if (!self->bin) { - s[0] = GET; - PyOS_snprintf(s + 1, sizeof(s) - 1, "%ld\n", c_value); - len = strlen(s); - } - else if (Pdata_Check(self->file)) { - if (write_other(self, NULL, 0) < 0) return -1; - PDATA_APPEND(self->file, mv, -1); - return 0; - } - else { - if (c_value < 256) { - s[0] = BINGET; - s[1] = (int)(c_value & 0xff); - len = 2; - } - else { - s[0] = LONG_BINGET; - s[1] = (int)(c_value & 0xff); - s[2] = (int)((c_value >> 8) & 0xff); - s[3] = (int)((c_value >> 16) & 0xff); - s[4] = (int)((c_value >> 24) & 0xff); - len = 5; - } - } - - if (self->write_func(self, s, len) < 0) - return -1; - - return 0; -} - - -static int -put(Picklerobject *self, PyObject *ob) -{ - if (ob->ob_refcnt < 2 || self->fast) - return 0; - - return put2(self, ob); -} - - -static int -put2(Picklerobject *self, PyObject *ob) -{ - char c_str[30]; - int p; - size_t len; - int res = -1; - PyObject *py_ob_id = 0, *memo_len = 0, *t = 0; - - if (self->fast) - return 0; - - if ((p = PyDict_Size(self->memo)) < 0) - goto finally; - - /* Make sure memo keys are positive! */ - /* XXX Why? - * XXX And does "positive" really mean non-negative? - * XXX pickle.py starts with PUT index 0, not 1. This makes for - * XXX gratuitous differences between the pickling modules. - */ - p++; - - if (!( py_ob_id = PyLong_FromVoidPtr(ob))) - goto finally; - - if (!( memo_len = PyInt_FromLong(p))) - goto finally; - - if (!( t = PyTuple_New(2))) - goto finally; - - PyTuple_SET_ITEM(t, 0, memo_len); - Py_INCREF(memo_len); - PyTuple_SET_ITEM(t, 1, ob); - Py_INCREF(ob); - - if (PyDict_SetItem(self->memo, py_ob_id, t) < 0) - goto finally; - - if (!self->bin) { - c_str[0] = PUT; - PyOS_snprintf(c_str + 1, sizeof(c_str) - 1, "%d\n", p); - len = strlen(c_str); - } - else if (Pdata_Check(self->file)) { - if (write_other(self, NULL, 0) < 0) return -1; - PDATA_APPEND(self->file, memo_len, -1); - res=0; /* Job well done ;) */ - goto finally; - } - else { - if (p >= 256) { - c_str[0] = LONG_BINPUT; - c_str[1] = (int)(p & 0xff); - c_str[2] = (int)((p >> 8) & 0xff); - c_str[3] = (int)((p >> 16) & 0xff); - c_str[4] = (int)((p >> 24) & 0xff); - len = 5; - } - else { - c_str[0] = BINPUT; - c_str[1] = p; - len = 2; - } - } - - if (self->write_func(self, c_str, len) < 0) - goto finally; - - res = 0; - - finally: - Py_XDECREF(py_ob_id); - Py_XDECREF(memo_len); - Py_XDECREF(t); - - return res; -} - -static PyObject * -whichmodule(PyObject *global, PyObject *global_name) -{ - int i, j; - PyObject *module = 0, *modules_dict = 0, - *global_name_attr = 0, *name = 0; - - module = PyObject_GetAttrString(global, "__module__"); - if (module) - return module; - if (PyErr_ExceptionMatches(PyExc_AttributeError)) - PyErr_Clear(); - else - return NULL; - - if (!( modules_dict = PySys_GetObject("modules"))) - return NULL; - - i = 0; - while ((j = PyDict_Next(modules_dict, &i, &name, &module))) { - - if (PyObject_Compare(name, __main___str)==0) continue; - - global_name_attr = PyObject_GetAttr(module, global_name); - if (!global_name_attr) { - if (PyErr_ExceptionMatches(PyExc_AttributeError)) - PyErr_Clear(); - else - return NULL; - continue; - } - - if (global_name_attr != global) { - Py_DECREF(global_name_attr); - continue; - } - - Py_DECREF(global_name_attr); - - break; - } - - /* The following implements the rule in pickle.py added in 1.5 - that used __main__ if no module is found. I don't actually - like this rule. jlf - */ - if (!j) { - j=1; - name=__main___str; - } - - Py_INCREF(name); - return name; -} - - -static int -fast_save_enter(Picklerobject *self, PyObject *obj) -{ - /* if fast_container < 0, we're doing an error exit. */ - if (++self->fast_container >= PY_CPICKLE_FAST_LIMIT) { - PyObject *key = NULL; - if (self->fast_memo == NULL) { - self->fast_memo = PyDict_New(); - if (self->fast_memo == NULL) { - self->fast_container = -1; - return 0; - } - } - key = PyLong_FromVoidPtr(obj); - if (key == NULL) - return 0; - if (PyDict_GetItem(self->fast_memo, key)) { - Py_DECREF(key); - PyErr_Format(PyExc_ValueError, - "fast mode: can't pickle cyclic objects " - "including object type %s at %p", - obj->ob_type->tp_name, obj); - self->fast_container = -1; - return 0; - } - if (PyDict_SetItem(self->fast_memo, key, Py_None) < 0) { - Py_DECREF(key); - self->fast_container = -1; - return 0; - } - Py_DECREF(key); - } - return 1; -} - -int -fast_save_leave(Picklerobject *self, PyObject *obj) -{ - if (self->fast_container-- >= PY_CPICKLE_FAST_LIMIT) { - PyObject *key = PyLong_FromVoidPtr(obj); - if (key == NULL) - return 0; - if (PyDict_DelItem(self->fast_memo, key) < 0) { - Py_DECREF(key); - return 0; - } - Py_DECREF(key); - } - return 1; -} - -static int -save_none(Picklerobject *self, PyObject *args) -{ - static char none = NONE; - if (self->write_func(self, &none, 1) < 0) - return -1; - - return 0; -} - -static int -save_bool(Picklerobject *self, PyObject *args) -{ - static char *buf[2] = {FALSE, TRUE}; - static char len[2] = {sizeof(FALSE)-1, sizeof(TRUE)-1}; - long l = PyInt_AS_LONG((PyIntObject *)args); - - if (self->proto >= 2) { - char opcode = l ? NEWTRUE : NEWFALSE; - if (self->write_func(self, &opcode, 1) < 0) - return -1; - } - else if (self->write_func(self, buf[l], len[l]) < 0) - return -1; - return 0; -} - -static int -save_int(Picklerobject *self, PyObject *args) -{ - char c_str[32]; - long l = PyInt_AS_LONG((PyIntObject *)args); - int len = 0; - - if (!self->bin -#if SIZEOF_LONG > 4 - || l > 0x7fffffffL - || l < -0x80000000L -#endif - ) { - /* Text-mode pickle, or long too big to fit in the 4-byte - * signed BININT format: store as a string. - */ - c_str[0] = INT; - PyOS_snprintf(c_str + 1, sizeof(c_str) - 1, "%ld\n", l); - if (self->write_func(self, c_str, strlen(c_str)) < 0) - return -1; - } - else { - /* Binary pickle and l fits in a signed 4-byte int. */ - c_str[1] = (int)( l & 0xff); - c_str[2] = (int)((l >> 8) & 0xff); - c_str[3] = (int)((l >> 16) & 0xff); - c_str[4] = (int)((l >> 24) & 0xff); - - if ((c_str[4] == 0) && (c_str[3] == 0)) { - if (c_str[2] == 0) { - c_str[0] = BININT1; - len = 2; - } - else { - c_str[0] = BININT2; - len = 3; - } - } - else { - c_str[0] = BININT; - len = 5; - } - - if (self->write_func(self, c_str, len) < 0) - return -1; - } - - return 0; -} - - -static int -save_long(Picklerobject *self, PyObject *args) -{ - int size; - int res = -1; - PyObject *repr = NULL; - - static char l = LONG; - - if (self->proto >= 2) { - /* Linear-time pickling. */ - size_t nbits; - size_t nbytes; - unsigned char *pdata; - char c_str[5]; - int i; - int sign = _PyLong_Sign(args); - - if (sign == 0) { - /* It's 0 -- an empty bytestring. */ - c_str[0] = LONG1; - c_str[1] = 0; - i = self->write_func(self, c_str, 2); - if (i < 0) goto finally; - res = 0; - goto finally; - } - nbits = _PyLong_NumBits(args); - if (nbits == (size_t)-1 && PyErr_Occurred()) - goto finally; - /* How many bytes do we need? There are nbits >> 3 full - * bytes of data, and nbits & 7 leftover bits. If there - * are any leftover bits, then we clearly need another - * byte. Wnat's not so obvious is that we *probably* - * need another byte even if there aren't any leftovers: - * the most-significant bit of the most-significant byte - * acts like a sign bit, and it's usually got a sense - * opposite of the one we need. The exception is longs - * of the form -(2**(8*j-1)) for j > 0. Such a long is - * its own 256's-complement, so has the right sign bit - * even without the extra byte. That's a pain to check - * for in advance, though, so we always grab an extra - * byte at the start, and cut it back later if possible. - */ - nbytes = (nbits >> 3) + 1; - if ((int)nbytes < 0 || (size_t)(int)nbytes != nbytes) { - PyErr_SetString(PyExc_OverflowError, "long too large " - "to pickle"); - goto finally; - } - repr = PyString_FromStringAndSize(NULL, (int)nbytes); - if (repr == NULL) goto finally; - pdata = (unsigned char *)PyString_AS_STRING(repr); - i = _PyLong_AsByteArray((PyLongObject *)args, - pdata, nbytes, - 1 /* little endian */, 1 /* signed */); - if (i < 0) goto finally; - /* If the long is negative, this may be a byte more than - * needed. This is so iff the MSB is all redundant sign - * bits. - */ - if (sign < 0 && nbytes > 1 && pdata[nbytes - 1] == 0xff && - (pdata[nbytes - 2] & 0x80) != 0) - --nbytes; - - if (nbytes < 256) { - c_str[0] = LONG1; - c_str[1] = (char)nbytes; - size = 2; - } - else { - c_str[0] = LONG4; - size = (int)nbytes; - for (i = 1; i < 5; i++) { - c_str[i] = (char)(size & 0xff); - size >>= 8; - } - size = 5; - } - i = self->write_func(self, c_str, size); - if (i < 0) goto finally; - i = self->write_func(self, (char *)pdata, (int)nbytes); - if (i < 0) goto finally; - res = 0; - goto finally; - } - - /* proto < 2: write the repr and newline. This is quadratic-time - * (in the number of digits), in both directions. - */ - if (!( repr = PyObject_Repr(args))) - goto finally; - - if ((size = PyString_Size(repr)) < 0) - goto finally; - - if (self->write_func(self, &l, 1) < 0) - goto finally; - - if (self->write_func(self, - PyString_AS_STRING((PyStringObject *)repr), - size) < 0) - goto finally; - - if (self->write_func(self, "\n", 1) < 0) - goto finally; - - res = 0; - - finally: - Py_XDECREF(repr); - return res; -} - - -static int -save_float(Picklerobject *self, PyObject *args) -{ - double x = PyFloat_AS_DOUBLE((PyFloatObject *)args); - - if (self->bin) { - char str[9]; - str[0] = BINFLOAT; - if (_PyFloat_Pack8(x, (unsigned char *)&str[1], 0) < 0) - return -1; - if (self->write_func(self, str, 9) < 0) - return -1; - } - else { - char c_str[250]; - c_str[0] = FLOAT; - PyOS_snprintf(c_str + 1, sizeof(c_str) - 1, "%.17g\n", x); - - if (self->write_func(self, c_str, strlen(c_str)) < 0) - return -1; - } - - return 0; -} - - -static int -save_string(Picklerobject *self, PyObject *args, int doput) -{ - int size, len; - PyObject *repr=0; - - if ((size = PyString_Size(args)) < 0) - return -1; - - if (!self->bin) { - char *repr_str; - - static char string = STRING; - - if (!( repr = PyObject_Repr(args))) - return -1; - - if ((len = PyString_Size(repr)) < 0) - goto err; - repr_str = PyString_AS_STRING((PyStringObject *)repr); - - if (self->write_func(self, &string, 1) < 0) - goto err; - - if (self->write_func(self, repr_str, len) < 0) - goto err; - - if (self->write_func(self, "\n", 1) < 0) - goto err; - - Py_XDECREF(repr); - } - else { - int i; - char c_str[5]; - - if ((size = PyString_Size(args)) < 0) - return -1; - - if (size < 256) { - c_str[0] = SHORT_BINSTRING; - c_str[1] = size; - len = 2; - } - else { - c_str[0] = BINSTRING; - for (i = 1; i < 5; i++) - c_str[i] = (int)(size >> ((i - 1) * 8)); - len = 5; - } - - if (self->write_func(self, c_str, len) < 0) - return -1; - - if (size > 128 && Pdata_Check(self->file)) { - if (write_other(self, NULL, 0) < 0) return -1; - PDATA_APPEND(self->file, args, -1); - } - else { - if (self->write_func(self, - PyString_AS_STRING( - (PyStringObject *)args), - size) < 0) - return -1; - } - } - - if (doput) - if (put(self, args) < 0) - return -1; - - return 0; - - err: - Py_XDECREF(repr); - return -1; -} - - -#ifdef Py_USING_UNICODE -/* A copy of PyUnicode_EncodeRawUnicodeEscape() that also translates - backslash and newline characters to \uXXXX escapes. */ -static PyObject * -modified_EncodeRawUnicodeEscape(const Py_UNICODE *s, int size) -{ - PyObject *repr; - char *p; - char *q; - - static const char *hexdigit = "0123456789ABCDEF"; - - repr = PyString_FromStringAndSize(NULL, 6 * size); - if (repr == NULL) - return NULL; - if (size == 0) - return repr; - - p = q = PyString_AS_STRING(repr); - while (size-- > 0) { - Py_UNICODE ch = *s++; - /* Map 16-bit characters to '\uxxxx' */ - if (ch >= 256 || ch == '\\' || ch == '\n') { - *p++ = '\\'; - *p++ = 'u'; - *p++ = hexdigit[(ch >> 12) & 0xf]; - *p++ = hexdigit[(ch >> 8) & 0xf]; - *p++ = hexdigit[(ch >> 4) & 0xf]; - *p++ = hexdigit[ch & 15]; - } - /* Copy everything else as-is */ - else - *p++ = (char) ch; - } - *p = '\0'; - _PyString_Resize(&repr, p - q); - return repr; -} - - -static int -save_unicode(Picklerobject *self, PyObject *args, int doput) -{ - int size, len; - PyObject *repr=0; - - if (!PyUnicode_Check(args)) - return -1; - - if (!self->bin) { - char *repr_str; - static char string = UNICODE; - - repr = modified_EncodeRawUnicodeEscape( - PyUnicode_AS_UNICODE(args), PyUnicode_GET_SIZE(args)); - if (!repr) - return -1; - - if ((len = PyString_Size(repr)) < 0) - goto err; - repr_str = PyString_AS_STRING((PyStringObject *)repr); - - if (self->write_func(self, &string, 1) < 0) - goto err; - - if (self->write_func(self, repr_str, len) < 0) - goto err; - - if (self->write_func(self, "\n", 1) < 0) - goto err; - - Py_XDECREF(repr); - } - else { - int i; - char c_str[5]; - - if (!( repr = PyUnicode_AsUTF8String(args))) - return -1; - - if ((size = PyString_Size(repr)) < 0) - goto err; - - c_str[0] = BINUNICODE; - for (i = 1; i < 5; i++) - c_str[i] = (int)(size >> ((i - 1) * 8)); - len = 5; - - if (self->write_func(self, c_str, len) < 0) - goto err; - - if (size > 128 && Pdata_Check(self->file)) { - if (write_other(self, NULL, 0) < 0) - goto err; - PDATA_APPEND(self->file, repr, -1); - } - else { - if (self->write_func(self, PyString_AS_STRING(repr), - size) < 0) - goto err; - } - - Py_DECREF(repr); - } - - if (doput) - if (put(self, args) < 0) - return -1; - - return 0; - - err: - Py_XDECREF(repr); - return -1; -} -#endif - -/* A helper for save_tuple. Push the len elements in tuple t on the stack. */ -static int -store_tuple_elements(Picklerobject *self, PyObject *t, int len) -{ - int i; - int res = -1; /* guilty until proved innocent */ - - assert(PyTuple_Size(t) == len); - - for (i = 0; i < len; i++) { - PyObject *element = PyTuple_GET_ITEM(t, i); - - if (element == NULL) - goto finally; - if (save(self, element, 0) < 0) - goto finally; - } - res = 0; - - finally: - return res; -} - -/* Tuples are ubiquitous in the pickle protocols, so many techniques are - * used across protocols to minimize the space needed to pickle them. - * Tuples are also the only builtin immutable type that can be recursive - * (a tuple can be reached from itself), and that requires some subtle - * magic so that it works in all cases. IOW, this is a long routine. - */ -static int -save_tuple(Picklerobject *self, PyObject *args) -{ - PyObject *py_tuple_id = NULL; - int len, i; - int res = -1; - - static char tuple = TUPLE; - static char pop = POP; - static char pop_mark = POP_MARK; - static char len2opcode[] = {EMPTY_TUPLE, TUPLE1, TUPLE2, TUPLE3}; - - if ((len = PyTuple_Size(args)) < 0) - goto finally; - - if (len == 0) { - char c_str[2]; - - if (self->proto) { - c_str[0] = EMPTY_TUPLE; - len = 1; - } - else { - c_str[0] = MARK; - c_str[1] = TUPLE; - len = 2; - } - if (self->write_func(self, c_str, len) >= 0) - res = 0; - /* Don't memoize an empty tuple. */ - goto finally; - } - - /* A non-empty tuple. */ - - /* id(tuple) isn't in the memo now. If it shows up there after - * saving the tuple elements, the tuple must be recursive, in - * which case we'll pop everything we put on the stack, and fetch - * its value from the memo. - */ - py_tuple_id = PyLong_FromVoidPtr(args); - if (py_tuple_id == NULL) - goto finally; - - if (len <= 3 && self->proto >= 2) { - /* Use TUPLE{1,2,3} opcodes. */ - if (store_tuple_elements(self, args, len) < 0) - goto finally; - if (PyDict_GetItem(self->memo, py_tuple_id)) { - /* pop the len elements */ - for (i = 0; i < len; ++i) - if (self->write_func(self, &pop, 1) < 0) - goto finally; - /* fetch from memo */ - if (get(self, py_tuple_id) < 0) - goto finally; - res = 0; - goto finally; - } - /* Not recursive. */ - if (self->write_func(self, len2opcode + len, 1) < 0) - goto finally; - goto memoize; - } - - /* proto < 2 and len > 0, or proto >= 2 and len > 3. - * Generate MARK elt1 elt2 ... TUPLE - */ - if (self->write_func(self, &MARKv, 1) < 0) - goto finally; - - if (store_tuple_elements(self, args, len) < 0) - goto finally; - - if (PyDict_GetItem(self->memo, py_tuple_id)) { - /* pop the stack stuff we pushed */ - if (self->bin) { - if (self->write_func(self, &pop_mark, 1) < 0) - goto finally; - } - else { - /* Note that we pop one more than len, to remove - * the MARK too. - */ - for (i = 0; i <= len; i++) - if (self->write_func(self, &pop, 1) < 0) - goto finally; - } - /* fetch from memo */ - if (get(self, py_tuple_id) >= 0) - res = 0; - goto finally; - } - - /* Not recursive. */ - if (self->write_func(self, &tuple, 1) < 0) - goto finally; - - memoize: - if (put(self, args) >= 0) - res = 0; - - finally: - Py_XDECREF(py_tuple_id); - return res; -} - -/* iter is an iterator giving items, and we batch up chunks of - * MARK item item ... item APPENDS - * opcode sequences. Calling code should have arranged to first create an - * empty list, or list-like object, for the APPENDS to operate on. - * Returns 0 on success, <0 on error. - */ -static int -batch_list(Picklerobject *self, PyObject *iter) -{ - PyObject *obj; - PyObject *slice[BATCHSIZE]; - int i, n; - - static char append = APPEND; - static char appends = APPENDS; - - assert(iter != NULL); - - if (self->proto == 0) { - /* APPENDS isn't available; do one at a time. */ - for (;;) { - obj = PyIter_Next(iter); - if (obj == NULL) { - if (PyErr_Occurred()) - return -1; - break; - } - i = save(self, obj, 0); - Py_DECREF(obj); - if (i < 0) - return -1; - if (self->write_func(self, &append, 1) < 0) - return -1; - } - return 0; - } - - /* proto > 0: write in batches of BATCHSIZE. */ - do { - /* Get next group of (no more than) BATCHSIZE elements. */ - for (n = 0; n < BATCHSIZE; ++n) { - obj = PyIter_Next(iter); - if (obj == NULL) { - if (PyErr_Occurred()) - goto BatchFailed; - break; - } - slice[n] = obj; - } - - if (n > 1) { - /* Pump out MARK, slice[0:n], APPENDS. */ - if (self->write_func(self, &MARKv, 1) < 0) - goto BatchFailed; - for (i = 0; i < n; ++i) { - if (save(self, slice[i], 0) < 0) - goto BatchFailed; - } - if (self->write_func(self, &appends, 1) < 0) - goto BatchFailed; - } - else if (n == 1) { - if (save(self, slice[0], 0) < 0) - goto BatchFailed; - if (self->write_func(self, &append, 1) < 0) - goto BatchFailed; - } - - for (i = 0; i < n; ++i) { - Py_DECREF(slice[i]); - } - } while (n == BATCHSIZE); - return 0; - -BatchFailed: - while (--n >= 0) { - Py_DECREF(slice[n]); - } - return -1; -} - -static int -save_list(Picklerobject *self, PyObject *args) -{ - int res = -1; - char s[3]; - int len; - PyObject *iter; - - if (self->fast && !fast_save_enter(self, args)) - goto finally; - - /* Create an empty list. */ - if (self->bin) { - s[0] = EMPTY_LIST; - len = 1; - } - else { - s[0] = MARK; - s[1] = LIST; - len = 2; - } - - if (self->write_func(self, s, len) < 0) - goto finally; - - /* Get list length, and bow out early if empty. */ - if ((len = PyList_Size(args)) < 0) - goto finally; - - /* Memoize. */ - if (len == 0) { - if (put(self, args) >= 0) - res = 0; - goto finally; - } - if (put2(self, args) < 0) - goto finally; - - /* Materialize the list elements. */ - iter = PyObject_GetIter(args); - if (iter == NULL) - goto finally; - res = batch_list(self, iter); - Py_DECREF(iter); - - finally: - if (self->fast && !fast_save_leave(self, args)) - res = -1; - - return res; -} - - -/* iter is an iterator giving (key, value) pairs, and we batch up chunks of - * MARK key value ... key value SETITEMS - * opcode sequences. Calling code should have arranged to first create an - * empty dict, or dict-like object, for the SETITEMS to operate on. - * Returns 0 on success, <0 on error. - * - * This is very much like batch_list(). The difference between saving - * elements directly, and picking apart two-tuples, is so long-winded at - * the C level, though, that attempts to combine these routines were too - * ugly to bear. - */ -static int -batch_dict(Picklerobject *self, PyObject *iter) -{ - PyObject *p; - PyObject *slice[BATCHSIZE]; - int i, n; - - static char setitem = SETITEM; - static char setitems = SETITEMS; - - assert(iter != NULL); - - if (self->proto == 0) { - /* SETITEMS isn't available; do one at a time. */ - for (;;) { - p = PyIter_Next(iter); - if (p == NULL) { - if (PyErr_Occurred()) - return -1; - break; - } - if (!PyTuple_Check(p) || PyTuple_Size(p) != 2) { - PyErr_SetString(PyExc_TypeError, "dict items " - "iterator must return 2-tuples"); - return -1; - } - i = save(self, PyTuple_GET_ITEM(p, 0), 0); - if (i >= 0) - i = save(self, PyTuple_GET_ITEM(p, 1), 0); - Py_DECREF(p); - if (i < 0) - return -1; - if (self->write_func(self, &setitem, 1) < 0) - return -1; - } - return 0; - } - - /* proto > 0: write in batches of BATCHSIZE. */ - do { - /* Get next group of (no more than) BATCHSIZE elements. */ - for (n = 0; n < BATCHSIZE; ++n) { - p = PyIter_Next(iter); - if (p == NULL) { - if (PyErr_Occurred()) - goto BatchFailed; - break; - } - if (!PyTuple_Check(p) || PyTuple_Size(p) != 2) { - PyErr_SetString(PyExc_TypeError, "dict items " - "iterator must return 2-tuples"); - goto BatchFailed; - } - slice[n] = p; - } - - if (n > 1) { - /* Pump out MARK, slice[0:n], SETITEMS. */ - if (self->write_func(self, &MARKv, 1) < 0) - goto BatchFailed; - for (i = 0; i < n; ++i) { - p = slice[i]; - if (save(self, PyTuple_GET_ITEM(p, 0), 0) < 0) - goto BatchFailed; - if (save(self, PyTuple_GET_ITEM(p, 1), 0) < 0) - goto BatchFailed; - } - if (self->write_func(self, &setitems, 1) < 0) - goto BatchFailed; - } - else if (n == 1) { - p = slice[0]; - if (save(self, PyTuple_GET_ITEM(p, 0), 0) < 0) - goto BatchFailed; - if (save(self, PyTuple_GET_ITEM(p, 1), 0) < 0) - goto BatchFailed; - if (self->write_func(self, &setitem, 1) < 0) - goto BatchFailed; - } - - for (i = 0; i < n; ++i) { - Py_DECREF(slice[i]); - } - } while (n == BATCHSIZE); - return 0; - -BatchFailed: - while (--n >= 0) { - Py_DECREF(slice[n]); - } - return -1; -} - -static int -save_dict(Picklerobject *self, PyObject *args) -{ - int res = -1; - char s[3]; - int len; - PyObject *iter; - - if (self->fast && !fast_save_enter(self, args)) - goto finally; - - /* Create an empty dict. */ - if (self->bin) { - s[0] = EMPTY_DICT; - len = 1; - } - else { - s[0] = MARK; - s[1] = DICT; - len = 2; - } - - if (self->write_func(self, s, len) < 0) - goto finally; - - /* Get dict size, and bow out early if empty. */ - if ((len = PyDict_Size(args)) < 0) - goto finally; - - if (len == 0) { - if (put(self, args) >= 0) - res = 0; - goto finally; - } - if (put2(self, args) < 0) - goto finally; - - /* Materialize the dict items. */ - iter = PyObject_CallMethod(args, "iteritems", "()"); - if (iter == NULL) - goto finally; - res = batch_dict(self, iter); - Py_DECREF(iter); - - finally: - if (self->fast && !fast_save_leave(self, args)) - res = -1; - - return res; -} - - -static int -save_inst(Picklerobject *self, PyObject *args) -{ - PyObject *class = 0, *module = 0, *name = 0, *state = 0, - *getinitargs_func = 0, *getstate_func = 0, *class_args = 0; - char *module_str, *name_str; - int module_size, name_size, res = -1; - - static char inst = INST, obj = OBJ, build = BUILD; - - if (self->fast && !fast_save_enter(self, args)) - goto finally; - - if (self->write_func(self, &MARKv, 1) < 0) - goto finally; - - if (!( class = PyObject_GetAttr(args, __class___str))) - goto finally; - - if (self->bin) { - if (save(self, class, 0) < 0) - goto finally; - } - - if ((getinitargs_func = PyObject_GetAttr(args, __getinitargs___str))) { - PyObject *element = 0; - int i, len; - - if (!( class_args = - PyObject_Call(getinitargs_func, empty_tuple, NULL))) - goto finally; - - if ((len = PyObject_Size(class_args)) < 0) - goto finally; - - for (i = 0; i < len; i++) { - if (!( element = PySequence_GetItem(class_args, i))) - goto finally; - - if (save(self, element, 0) < 0) { - Py_DECREF(element); - goto finally; - } - - Py_DECREF(element); - } - } - else { - if (PyErr_ExceptionMatches(PyExc_AttributeError)) - PyErr_Clear(); - else - goto finally; - } - - if (!self->bin) { - if (!( name = ((PyClassObject *)class)->cl_name )) { - PyErr_SetString(PicklingError, "class has no name"); - goto finally; - } - - if (!( module = whichmodule(class, name))) - goto finally; - - - if ((module_size = PyString_Size(module)) < 0 || - (name_size = PyString_Size(name)) < 0) - goto finally; - - module_str = PyString_AS_STRING((PyStringObject *)module); - name_str = PyString_AS_STRING((PyStringObject *)name); - - if (self->write_func(self, &inst, 1) < 0) - goto finally; - - if (self->write_func(self, module_str, module_size) < 0) - goto finally; - - if (self->write_func(self, "\n", 1) < 0) - goto finally; - - if (self->write_func(self, name_str, name_size) < 0) - goto finally; - - if (self->write_func(self, "\n", 1) < 0) - goto finally; - } - else if (self->write_func(self, &obj, 1) < 0) { - goto finally; - } - - if ((getstate_func = PyObject_GetAttr(args, __getstate___str))) { - state = PyObject_Call(getstate_func, empty_tuple, NULL); - if (!state) - goto finally; - } - else { - if (PyErr_ExceptionMatches(PyExc_AttributeError)) - PyErr_Clear(); - else - goto finally; - - if (!( state = PyObject_GetAttr(args, __dict___str))) { - if (PyErr_ExceptionMatches(PyExc_AttributeError)) - PyErr_Clear(); - else - goto finally; - res = 0; - goto finally; - } - } - - if (!PyDict_Check(state)) { - if (put2(self, args) < 0) - goto finally; - } - else { - if (put(self, args) < 0) - goto finally; - } - - if (save(self, state, 0) < 0) - goto finally; - - if (self->write_func(self, &build, 1) < 0) - goto finally; - - res = 0; - - finally: - if (self->fast && !fast_save_leave(self, args)) - res = -1; - - Py_XDECREF(module); - Py_XDECREF(class); - Py_XDECREF(state); - Py_XDECREF(getinitargs_func); - Py_XDECREF(getstate_func); - Py_XDECREF(class_args); - - return res; -} - - -static int -save_global(Picklerobject *self, PyObject *args, PyObject *name) -{ - PyObject *global_name = 0, *module = 0, *mod = 0, *klass = 0; - char *name_str, *module_str; - int module_size, name_size, res = -1; - - static char global = GLOBAL; - - if (name) { - global_name = name; - Py_INCREF(global_name); - } - else { - if (!( global_name = PyObject_GetAttr(args, __name___str))) - goto finally; - } - - if (!( module = whichmodule(args, global_name))) - goto finally; - - if ((module_size = PyString_Size(module)) < 0 || - (name_size = PyString_Size(global_name)) < 0) - goto finally; - - module_str = PyString_AS_STRING((PyStringObject *)module); - name_str = PyString_AS_STRING((PyStringObject *)global_name); - - /* XXX This can be doing a relative import. Clearly it shouldn't, - but I don't know how to stop it. :-( */ - mod = PyImport_ImportModule(module_str); - if (mod == NULL) { - cPickle_ErrFormat(PicklingError, - "Can't pickle %s: import of module %s " - "failed", - "OS", args, module); - goto finally; - } - klass = PyObject_GetAttrString(mod, name_str); - if (klass == NULL) { - cPickle_ErrFormat(PicklingError, - "Can't pickle %s: attribute lookup %s.%s " - "failed", - "OSS", args, module, global_name); - goto finally; - } - if (klass != args) { - Py_DECREF(klass); - cPickle_ErrFormat(PicklingError, - "Can't pickle %s: it's not the same object " - "as %s.%s", - "OSS", args, module, global_name); - goto finally; - } - Py_DECREF(klass); - - if (self->proto >= 2) { - /* See whether this is in the extension registry, and if - * so generate an EXT opcode. - */ - PyObject *py_code; /* extension code as Python object */ - long code; /* extension code as C value */ - char c_str[5]; - int n; - - PyTuple_SET_ITEM(two_tuple, 0, module); - PyTuple_SET_ITEM(two_tuple, 1, global_name); - py_code = PyDict_GetItem(extension_registry, two_tuple); - if (py_code == NULL) - goto gen_global; /* not registered */ - - /* Verify py_code has the right type and value. */ - if (!PyInt_Check(py_code)) { - cPickle_ErrFormat(PicklingError, "Can't pickle %s: " - "extension code %s isn't an integer", - "OO", args, py_code); - goto finally; - } - code = PyInt_AS_LONG(py_code); - if (code <= 0 || code > 0x7fffffffL) { - cPickle_ErrFormat(PicklingError, "Can't pickle %s: " - "extension code %ld is out of range", - "Ol", args, code); - goto finally; - } - - /* Generate an EXT opcode. */ - if (code <= 0xff) { - c_str[0] = EXT1; - c_str[1] = (char)code; - n = 2; - } - else if (code <= 0xffff) { - c_str[0] = EXT2; - c_str[1] = (char)(code & 0xff); - c_str[2] = (char)((code >> 8) & 0xff); - n = 3; - } - else { - c_str[0] = EXT4; - c_str[1] = (char)(code & 0xff); - c_str[2] = (char)((code >> 8) & 0xff); - c_str[3] = (char)((code >> 16) & 0xff); - c_str[4] = (char)((code >> 24) & 0xff); - n = 5; - } - - if (self->write_func(self, c_str, n) >= 0) - res = 0; - goto finally; /* and don't memoize */ - } - - gen_global: - if (self->write_func(self, &global, 1) < 0) - goto finally; - - if (self->write_func(self, module_str, module_size) < 0) - goto finally; - - if (self->write_func(self, "\n", 1) < 0) - goto finally; - - if (self->write_func(self, name_str, name_size) < 0) - goto finally; - - if (self->write_func(self, "\n", 1) < 0) - goto finally; - - if (put(self, args) < 0) - goto finally; - - res = 0; - - finally: - Py_XDECREF(module); - Py_XDECREF(global_name); - Py_XDECREF(mod); - - return res; -} - -static int -save_pers(Picklerobject *self, PyObject *args, PyObject *f) -{ - PyObject *pid = 0; - int size, res = -1; - - static char persid = PERSID, binpersid = BINPERSID; - - Py_INCREF(args); - ARG_TUP(self, args); - if (self->arg) { - pid = PyObject_Call(f, self->arg, NULL); - FREE_ARG_TUP(self); - } - if (! pid) return -1; - - if (pid != Py_None) { - if (!self->bin) { - if (!PyString_Check(pid)) { - PyErr_SetString(PicklingError, - "persistent id must be string"); - goto finally; - } - - if (self->write_func(self, &persid, 1) < 0) - goto finally; - - if ((size = PyString_Size(pid)) < 0) - goto finally; - - if (self->write_func(self, - PyString_AS_STRING( - (PyStringObject *)pid), - size) < 0) - goto finally; - - if (self->write_func(self, "\n", 1) < 0) - goto finally; - - res = 1; - goto finally; - } - else if (save(self, pid, 1) >= 0) { - if (self->write_func(self, &binpersid, 1) < 0) - res = -1; - else - res = 1; - } - - goto finally; - } - - res = 0; - - finally: - Py_XDECREF(pid); - - return res; -} - -/* We're saving ob, and args is the 2-thru-5 tuple returned by the - * appropriate __reduce__ method for ob. - */ -static int -save_reduce(Picklerobject *self, PyObject *args, PyObject *ob) -{ - PyObject *callable; - PyObject *argtup; - PyObject *state = NULL; - PyObject *listitems = NULL; - PyObject *dictitems = NULL; - - int use_newobj = self->proto >= 2; - - static char reduce = REDUCE; - static char build = BUILD; - static char newobj = NEWOBJ; - - if (! PyArg_UnpackTuple(args, "save_reduce", 2, 5, - &callable, - &argtup, - &state, - &listitems, - &dictitems)) - return -1; - - if (state == Py_None) - state = NULL; - if (listitems == Py_None) - listitems = NULL; - if (dictitems == Py_None) - dictitems = NULL; - - /* Protocol 2 special case: if callable's name is __newobj__, use - * NEWOBJ. This consumes a lot of code. - */ - if (use_newobj) { - PyObject *temp = PyObject_GetAttr(callable, __name___str); - - if (temp == NULL) { - if (PyErr_ExceptionMatches(PyExc_AttributeError)) - PyErr_Clear(); - else - return -1; - use_newobj = 0; - } - else { - use_newobj = PyString_Check(temp) && - strcmp(PyString_AS_STRING(temp), - "__newobj__") == 0; - Py_DECREF(temp); - } - } - if (use_newobj) { - PyObject *cls; - PyObject *newargtup; - int n, i; - - /* Sanity checks. */ - n = PyTuple_Size(argtup); - if (n < 1) { - PyErr_SetString(PicklingError, "__newobj__ arglist " - "is empty"); - return -1; - } - - cls = PyTuple_GET_ITEM(argtup, 0); - if (! PyObject_HasAttrString(cls, "__new__")) { - PyErr_SetString(PicklingError, "args[0] from " - "__newobj__ args has no __new__"); - return -1; - } - - /* XXX How could ob be NULL? */ - if (ob != NULL) { - PyObject *ob_dot_class; - - ob_dot_class = PyObject_GetAttr(ob, __class___str); - if (ob_dot_class == NULL) { - if (PyErr_ExceptionMatches( - PyExc_AttributeError)) - PyErr_Clear(); - else - return -1; - } - i = ob_dot_class != cls; /* true iff a problem */ - Py_XDECREF(ob_dot_class); - if (i) { - PyErr_SetString(PicklingError, "args[0] from " - "__newobj__ args has the wrong class"); - return -1; - } - } - - /* Save the class and its __new__ arguments. */ - if (save(self, cls, 0) < 0) - return -1; - - newargtup = PyTuple_New(n-1); /* argtup[1:] */ - if (newargtup == NULL) - return -1; - for (i = 1; i < n; ++i) { - PyObject *temp = PyTuple_GET_ITEM(argtup, i); - Py_INCREF(temp); - PyTuple_SET_ITEM(newargtup, i-1, temp); - } - i = save(self, newargtup, 0) < 0; - Py_DECREF(newargtup); - if (i < 0) - return -1; - - /* Add NEWOBJ opcode. */ - if (self->write_func(self, &newobj, 1) < 0) - return -1; - } - else { - /* Not using NEWOBJ. */ - if (save(self, callable, 0) < 0 || - save(self, argtup, 0) < 0 || - self->write_func(self, &reduce, 1) < 0) - return -1; - } - - /* Memoize. */ - /* XXX How can ob be NULL? */ - if (ob != NULL) { - if (state && !PyDict_Check(state)) { - if (put2(self, ob) < 0) - return -1; - } - else if (put(self, ob) < 0) - return -1; - } - - - if (listitems && batch_list(self, listitems) < 0) - return -1; - - if (dictitems && batch_dict(self, dictitems) < 0) - return -1; - - if (state) { - if (save(self, state, 0) < 0 || - self->write_func(self, &build, 1) < 0) - return -1; - } - - return 0; -} - -static int -save(Picklerobject *self, PyObject *args, int pers_save) -{ - PyTypeObject *type; - PyObject *py_ob_id = 0, *__reduce__ = 0, *t = 0; - PyObject *arg_tup; - int res = -1; - int tmp, size; - - if (self->nesting++ > Py_GetRecursionLimit()){ - PyErr_SetString(PyExc_RuntimeError, - "maximum recursion depth exceeded"); - goto finally; - } - - if (!pers_save && self->pers_func) { - if ((tmp = save_pers(self, args, self->pers_func)) != 0) { - res = tmp; - goto finally; - } - } - - if (args == Py_None) { - res = save_none(self, args); - goto finally; - } - - type = args->ob_type; - - switch (type->tp_name[0]) { - case 'b': - if (args == Py_False || args == Py_True) { - res = save_bool(self, args); - goto finally; - } - break; - case 'i': - if (type == &PyInt_Type) { - res = save_int(self, args); - goto finally; - } - break; - - case 'l': - if (type == &PyLong_Type) { - res = save_long(self, args); - goto finally; - } - break; - - case 'f': - if (type == &PyFloat_Type) { - res = save_float(self, args); - goto finally; - } - break; - - case 't': - if (type == &PyTuple_Type && PyTuple_Size(args) == 0) { - res = save_tuple(self, args); - goto finally; - } - break; - - case 's': - if ((type == &PyString_Type) && (PyString_GET_SIZE(args) < 2)) { - res = save_string(self, args, 0); - goto finally; - } - -#ifdef Py_USING_UNICODE - case 'u': - if ((type == &PyUnicode_Type) && (PyString_GET_SIZE(args) < 2)) { - res = save_unicode(self, args, 0); - goto finally; - } -#endif - } - - if (args->ob_refcnt > 1) { - if (!( py_ob_id = PyLong_FromVoidPtr(args))) - goto finally; - - if (PyDict_GetItem(self->memo, py_ob_id)) { - if (get(self, py_ob_id) < 0) - goto finally; - - res = 0; - goto finally; - } - } - - switch (type->tp_name[0]) { - case 's': - if (type == &PyString_Type) { - res = save_string(self, args, 1); - goto finally; - } - break; - -#ifdef Py_USING_UNICODE - case 'u': - if (type == &PyUnicode_Type) { - res = save_unicode(self, args, 1); - goto finally; - } - break; -#endif - - case 't': - if (type == &PyTuple_Type) { - res = save_tuple(self, args); - goto finally; - } - if (type == &PyType_Type) { - res = save_global(self, args, NULL); - goto finally; - } - break; - - case 'l': - if (type == &PyList_Type) { - res = save_list(self, args); - goto finally; - } - break; - - case 'd': - if (type == &PyDict_Type) { - res = save_dict(self, args); - goto finally; - } - break; - - case 'i': - if (type == &PyInstance_Type) { - res = save_inst(self, args); - goto finally; - } - break; - - case 'c': - if (type == &PyClass_Type) { - res = save_global(self, args, NULL); - goto finally; - } - break; - - case 'f': - if (type == &PyFunction_Type) { - res = save_global(self, args, NULL); - goto finally; - } - break; - - case 'b': - if (type == &PyCFunction_Type) { - res = save_global(self, args, NULL); - goto finally; - } - } - - if (!pers_save && self->inst_pers_func) { - if ((tmp = save_pers(self, args, self->inst_pers_func)) != 0) { - res = tmp; - goto finally; - } - } - - if (PyType_IsSubtype(type, &PyType_Type)) { - res = save_global(self, args, NULL); - goto finally; - } - - /* Get a reduction callable, and call it. This may come from - * copy_reg.dispatch_table, the object's __reduce_ex__ method, - * or the object's __reduce__ method. - */ - __reduce__ = PyDict_GetItem(dispatch_table, (PyObject *)type); - if (__reduce__ != NULL) { - Py_INCREF(__reduce__); - Py_INCREF(args); - ARG_TUP(self, args); - if (self->arg) { - t = PyObject_Call(__reduce__, self->arg, NULL); - FREE_ARG_TUP(self); - } - } - else { - /* Check for a __reduce_ex__ method. */ - __reduce__ = PyObject_GetAttr(args, __reduce_ex___str); - if (__reduce__ != NULL) { - t = PyInt_FromLong(self->proto); - if (t != NULL) { - ARG_TUP(self, t); - t = NULL; - if (self->arg) { - t = PyObject_Call(__reduce__, - self->arg, NULL); - FREE_ARG_TUP(self); - } - } - } - else { - if (PyErr_ExceptionMatches(PyExc_AttributeError)) - PyErr_Clear(); - else - goto finally; - /* Check for a __reduce__ method. */ - __reduce__ = PyObject_GetAttr(args, __reduce___str); - if (__reduce__ != NULL) { - t = PyObject_Call(__reduce__, - empty_tuple, NULL); - } - else { - PyErr_SetObject(UnpickleableError, args); - goto finally; - } - } - } - - if (t == NULL) - goto finally; - - if (PyString_Check(t)) { - res = save_global(self, args, t); - goto finally; - } - - if (! PyTuple_Check(t)) { - cPickle_ErrFormat(PicklingError, "Value returned by " - "%s must be string or tuple", - "O", __reduce__); - goto finally; - } - - size = PyTuple_Size(t); - if (size < 2 || size > 5) { - cPickle_ErrFormat(PicklingError, "tuple returned by " - "%s must contain 2 through 5 elements", - "O", __reduce__); - goto finally; - } - - arg_tup = PyTuple_GET_ITEM(t, 1); - if (!(PyTuple_Check(arg_tup) || arg_tup == Py_None)) { - cPickle_ErrFormat(PicklingError, "Second element of " - "tuple returned by %s must be a tuple", - "O", __reduce__); - goto finally; - } - - res = save_reduce(self, t, args); - - finally: - self->nesting--; - Py_XDECREF(py_ob_id); - Py_XDECREF(__reduce__); - Py_XDECREF(t); - - return res; -} - - -static int -dump(Picklerobject *self, PyObject *args) -{ - static char stop = STOP; - - if (self->proto >= 2) { - char bytes[2]; - - bytes[0] = PROTO; - assert(self->proto >= 0 && self->proto < 256); - bytes[1] = (char)self->proto; - if (self->write_func(self, bytes, 2) < 0) - return -1; - } - - if (save(self, args, 0) < 0) - return -1; - - if (self->write_func(self, &stop, 1) < 0) - return -1; - - if (self->write_func(self, NULL, 0) < 0) - return -1; - - return 0; -} - -static PyObject * -Pickle_clear_memo(Picklerobject *self, PyObject *args) -{ - if (self->memo) - PyDict_Clear(self->memo); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -Pickle_getvalue(Picklerobject *self, PyObject *args) -{ - int l, i, rsize, ssize, clear=1, lm; - long ik; - PyObject *k, *r; - char *s, *p, *have_get; - Pdata *data; - - /* Can be called by Python code or C code */ - if (args && !PyArg_ParseTuple(args, "|i:getvalue", &clear)) - return NULL; - - /* Check to make sure we are based on a list */ - if (! Pdata_Check(self->file)) { - PyErr_SetString(PicklingError, - "Attempt to getvalue() a non-list-based pickler"); - return NULL; - } - - /* flush write buffer */ - if (write_other(self, NULL, 0) < 0) return NULL; - - data=(Pdata*)self->file; - l=data->length; - - /* set up an array to hold get/put status */ - lm = PyDict_Size(self->memo); - if (lm < 0) return NULL; - lm++; - have_get = malloc(lm); - if (have_get == NULL) return PyErr_NoMemory(); - memset(have_get, 0, lm); - - /* Scan for gets. */ - for (rsize = 0, i = l; --i >= 0; ) { - k = data->data[i]; - - if (PyString_Check(k)) - rsize += PyString_GET_SIZE(k); - - else if (PyInt_Check(k)) { /* put */ - ik = PyInt_AS_LONG((PyIntObject*)k); - if (ik >= lm || ik == 0) { - PyErr_SetString(PicklingError, - "Invalid get data"); - return NULL; - } - if (have_get[ik]) /* with matching get */ - rsize += ik < 256 ? 2 : 5; - } - - else if (! (PyTuple_Check(k) && - PyTuple_GET_SIZE(k) == 2 && - PyInt_Check((k = PyTuple_GET_ITEM(k, 0)))) - ) { - PyErr_SetString(PicklingError, - "Unexpected data in internal list"); - return NULL; - } - - else { /* put */ - ik = PyInt_AS_LONG((PyIntObject *)k); - if (ik >= lm || ik == 0) { - PyErr_SetString(PicklingError, - "Invalid get data"); - return NULL; - } - have_get[ik] = 1; - rsize += ik < 256 ? 2 : 5; - } - } - - /* Now generate the result */ - r = PyString_FromStringAndSize(NULL, rsize); - if (r == NULL) goto err; - s = PyString_AS_STRING((PyStringObject *)r); - - for (i = 0; i < l; i++) { - k = data->data[i]; - - if (PyString_Check(k)) { - ssize = PyString_GET_SIZE(k); - if (ssize) { - p=PyString_AS_STRING((PyStringObject *)k); - while (--ssize >= 0) - *s++ = *p++; - } - } - - else if (PyTuple_Check(k)) { /* get */ - ik = PyInt_AS_LONG((PyIntObject *) - PyTuple_GET_ITEM(k, 0)); - if (ik < 256) { - *s++ = BINGET; - *s++ = (int)(ik & 0xff); - } - else { - *s++ = LONG_BINGET; - *s++ = (int)(ik & 0xff); - *s++ = (int)((ik >> 8) & 0xff); - *s++ = (int)((ik >> 16) & 0xff); - *s++ = (int)((ik >> 24) & 0xff); - } - } - - else { /* put */ - ik = PyInt_AS_LONG((PyIntObject*)k); - - if (have_get[ik]) { /* with matching get */ - if (ik < 256) { - *s++ = BINPUT; - *s++ = (int)(ik & 0xff); - } - else { - *s++ = LONG_BINPUT; - *s++ = (int)(ik & 0xff); - *s++ = (int)((ik >> 8) & 0xff); - *s++ = (int)((ik >> 16) & 0xff); - *s++ = (int)((ik >> 24) & 0xff); - } - } - } - } - - if (clear) { - PyDict_Clear(self->memo); - Pdata_clear(data, 0); - } - - free(have_get); - return r; - err: - free(have_get); - return NULL; -} - -static PyObject * -Pickler_dump(Picklerobject *self, PyObject *args) -{ - PyObject *ob; - int get=0; - - if (!( PyArg_ParseTuple(args, "O|i:dump", &ob, &get))) - return NULL; - - if (dump(self, ob) < 0) - return NULL; - - if (get) return Pickle_getvalue(self, NULL); - - /* XXX Why does dump() return self? */ - Py_INCREF(self); - return (PyObject*)self; -} - - -static struct PyMethodDef Pickler_methods[] = -{ - {"dump", (PyCFunction)Pickler_dump, METH_VARARGS, - PyDoc_STR("dump(object) -- " - "Write an object in pickle format to the object's pickle stream")}, - {"clear_memo", (PyCFunction)Pickle_clear_memo, METH_NOARGS, - PyDoc_STR("clear_memo() -- Clear the picklers memo")}, - {"getvalue", (PyCFunction)Pickle_getvalue, METH_VARARGS, - PyDoc_STR("getvalue() -- Finish picking a list-based pickle")}, - {NULL, NULL} /* sentinel */ -}; - - -static Picklerobject * -newPicklerobject(PyObject *file, int proto) -{ - Picklerobject *self; - - if (proto < 0) - proto = HIGHEST_PROTOCOL; - if (proto > HIGHEST_PROTOCOL) { - PyErr_Format(PyExc_ValueError, "pickle protocol %d asked for; " - "the highest available protocol is %d", - proto, HIGHEST_PROTOCOL); - return NULL; - } - - self = PyObject_GC_New(Picklerobject, &Picklertype); - if (self == NULL) - return NULL; - self->proto = proto; - self->bin = proto > 0; - self->fp = NULL; - self->write = NULL; - self->memo = NULL; - self->arg = NULL; - self->pers_func = NULL; - self->inst_pers_func = NULL; - self->write_buf = NULL; - self->fast = 0; - self->nesting = 0; - self->fast_container = 0; - self->fast_memo = NULL; - self->buf_size = 0; - self->dispatch_table = NULL; - - self->file = NULL; - if (file) - Py_INCREF(file); - else { - file = Pdata_New(); - if (file == NULL) - goto err; - } - self->file = file; - - if (!( self->memo = PyDict_New())) - goto err; - - if (PyFile_Check(file)) { - self->fp = PyFile_AsFile(file); - if (self->fp == NULL) { - PyErr_SetString(PyExc_ValueError, - "I/O operation on closed file"); - goto err; - } - self->write_func = write_file; - } - else if (PycStringIO_OutputCheck(file)) { - self->write_func = write_cStringIO; - } - else if (file == Py_None) { - self->write_func = write_none; - } - else { - self->write_func = write_other; - - if (! Pdata_Check(file)) { - self->write = PyObject_GetAttr(file, write_str); - if (!self->write) { - PyErr_Clear(); - PyErr_SetString(PyExc_TypeError, - "argument must have 'write' " - "attribute"); - goto err; - } - } - - self->write_buf = (char *)PyMem_Malloc(WRITE_BUF_SIZE); - if (self->write_buf == NULL) { - PyErr_NoMemory(); - goto err; - } - } - - if (PyEval_GetRestricted()) { - /* Restricted execution, get private tables */ - PyObject *m = PyImport_Import(copy_reg_str); - - if (m == NULL) - goto err; - self->dispatch_table = PyObject_GetAttr(m, dispatch_table_str); - Py_DECREF(m); - if (self->dispatch_table == NULL) - goto err; - } - else { - self->dispatch_table = dispatch_table; - Py_INCREF(dispatch_table); - } - PyObject_GC_Track(self); - - return self; - - err: - Py_DECREF(self); - return NULL; -} - - -static PyObject * -get_Pickler(PyObject *self, PyObject *args) -{ - PyObject *file = NULL; - int proto = 0; - - /* XXX - * The documented signature is Pickler(file, proto=0), but this - * accepts Pickler() and Pickler(integer) too. The meaning then - * is clear as mud, undocumented, and not supported by pickle.py. - * I'm told Zope uses this, but I haven't traced into this code - * far enough to figure out what it means. - */ - if (!PyArg_ParseTuple(args, "|i:Pickler", &proto)) { - PyErr_Clear(); - proto = 0; - if (!PyArg_ParseTuple(args, "O|i:Pickler", &file, &proto)) - return NULL; - } - return (PyObject *)newPicklerobject(file, proto); -} - - -static void -Pickler_dealloc(Picklerobject *self) -{ - PyObject_GC_UnTrack(self); - Py_XDECREF(self->write); - Py_XDECREF(self->memo); - Py_XDECREF(self->fast_memo); - Py_XDECREF(self->arg); - Py_XDECREF(self->file); - Py_XDECREF(self->pers_func); - Py_XDECREF(self->inst_pers_func); - Py_XDECREF(self->dispatch_table); - PyMem_Free(self->write_buf); - self->ob_type->tp_free((PyObject *)self); -} - -static int -Pickler_traverse(Picklerobject *self, visitproc visit, void *arg) -{ - int err; -#define VISIT(SLOT) \ - if (SLOT) { \ - err = visit((PyObject *)(SLOT), arg); \ - if (err) \ - return err; \ - } - VISIT(self->write); - VISIT(self->memo); - VISIT(self->fast_memo); - VISIT(self->arg); - VISIT(self->file); - VISIT(self->pers_func); - VISIT(self->inst_pers_func); - VISIT(self->dispatch_table); -#undef VISIT - return 0; -} - -static int -Pickler_clear(Picklerobject *self) -{ -#define CLEAR(SLOT) Py_XDECREF(SLOT); SLOT = NULL; - CLEAR(self->write); - CLEAR(self->memo); - CLEAR(self->fast_memo); - CLEAR(self->arg); - CLEAR(self->file); - CLEAR(self->pers_func); - CLEAR(self->inst_pers_func); - CLEAR(self->dispatch_table); -#undef CLEAR - return 0; -} - -static PyObject * -Pickler_get_pers_func(Picklerobject *p) -{ - if (p->pers_func == NULL) - PyErr_SetString(PyExc_AttributeError, "persistent_id"); - else - Py_INCREF(p->pers_func); - return p->pers_func; -} - -static int -Pickler_set_pers_func(Picklerobject *p, PyObject *v) -{ - if (v == NULL) { - PyErr_SetString(PyExc_TypeError, - "attribute deletion is not supported"); - return -1; - } - Py_XDECREF(p->pers_func); - Py_INCREF(v); - p->pers_func = v; - return 0; -} - -static int -Pickler_set_inst_pers_func(Picklerobject *p, PyObject *v) -{ - if (v == NULL) { - PyErr_SetString(PyExc_TypeError, - "attribute deletion is not supported"); - return -1; - } - Py_XDECREF(p->inst_pers_func); - Py_INCREF(v); - p->inst_pers_func = v; - return 0; -} - -static PyObject * -Pickler_get_memo(Picklerobject *p) -{ - if (p->memo == NULL) - PyErr_SetString(PyExc_AttributeError, "memo"); - else - Py_INCREF(p->memo); - return p->memo; -} - -static int -Pickler_set_memo(Picklerobject *p, PyObject *v) -{ - if (v == NULL) { - PyErr_SetString(PyExc_TypeError, - "attribute deletion is not supported"); - return -1; - } - if (!PyDict_Check(v)) { - PyErr_SetString(PyExc_TypeError, "memo must be a dictionary"); - return -1; - } - Py_XDECREF(p->memo); - Py_INCREF(v); - p->memo = v; - return 0; -} - -static PyObject * -Pickler_get_error(Picklerobject *p) -{ - /* why is this an attribute on the Pickler? */ - Py_INCREF(PicklingError); - return PicklingError; -} - -static PyMemberDef Pickler_members[] = { - {"binary", T_INT, offsetof(Picklerobject, bin)}, - {"fast", T_INT, offsetof(Picklerobject, fast)}, - {NULL} -}; - -static PyGetSetDef Pickler_getsets[] = { - {"persistent_id", (getter)Pickler_get_pers_func, - (setter)Pickler_set_pers_func}, - {"inst_persistent_id", NULL, (setter)Pickler_set_inst_pers_func}, - {"memo", (getter)Pickler_get_memo, (setter)Pickler_set_memo}, - {"PicklingError", (getter)Pickler_get_error, NULL}, - {NULL} -}; - -PyDoc_STRVAR(Picklertype__doc__, -"Objects that know how to pickle objects\n"); - -static PyTypeObject Picklertype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "cPickle.Pickler", /*tp_name*/ - sizeof(Picklerobject), /*tp_basicsize*/ - 0, - (destructor)Pickler_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - PyObject_GenericSetAttr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, - Picklertype__doc__, /* tp_doc */ - (traverseproc)Pickler_traverse, /* tp_traverse */ - (inquiry)Pickler_clear, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - Pickler_methods, /* tp_methods */ - Pickler_members, /* tp_members */ - Pickler_getsets, /* tp_getset */ -}; - -static PyObject * -find_class(PyObject *py_module_name, PyObject *py_global_name, PyObject *fc) -{ - PyObject *global = 0, *module; - - if (fc) { - if (fc==Py_None) { - PyErr_SetString(UnpicklingError, "Global and instance " - "pickles are not supported."); - return NULL; - } - return PyObject_CallFunction(fc, "OO", py_module_name, - py_global_name); - } - - module = PySys_GetObject("modules"); - if (module == NULL) - return NULL; - - module = PyDict_GetItem(module, py_module_name); - if (module == NULL) { - module = PyImport_Import(py_module_name); - if (!module) - return NULL; - global = PyObject_GetAttr(module, py_global_name); - Py_DECREF(module); - } - else - global = PyObject_GetAttr(module, py_global_name); - return global; -} - -static int -marker(Unpicklerobject *self) -{ - if (self->num_marks < 1) { - PyErr_SetString(UnpicklingError, "could not find MARK"); - return -1; - } - - return self->marks[--self->num_marks]; -} - - -static int -load_none(Unpicklerobject *self) -{ - PDATA_APPEND(self->stack, Py_None, -1); - return 0; -} - -static int -bad_readline(void) -{ - PyErr_SetString(UnpicklingError, "pickle data was truncated"); - return -1; -} - -static int -load_int(Unpicklerobject *self) -{ - PyObject *py_int = 0; - char *endptr, *s; - int len, res = -1; - long l; - - if ((len = self->readline_func(self, &s)) < 0) return -1; - if (len < 2) return bad_readline(); - if (!( s=pystrndup(s,len))) return -1; - - errno = 0; - l = strtol(s, &endptr, 0); - - if (errno || (*endptr != '\n') || (endptr[1] != '\0')) { - /* Hm, maybe we've got something long. Let's try reading - it as a Python long object. */ - errno = 0; - py_int = PyLong_FromString(s, NULL, 0); - if (py_int == NULL) { - PyErr_SetString(PyExc_ValueError, - "could not convert string to int"); - goto finally; - } - } - else { - if (len == 3 && (l == 0 || l == 1)) { - if (!( py_int = PyBool_FromLong(l))) goto finally; - } - else { - if (!( py_int = PyInt_FromLong(l))) goto finally; - } - } - - free(s); - PDATA_PUSH(self->stack, py_int, -1); - return 0; - - finally: - free(s); - - return res; -} - -static int -load_bool(Unpicklerobject *self, PyObject *boolean) -{ - assert(boolean == Py_True || boolean == Py_False); - PDATA_APPEND(self->stack, boolean, -1); - return 0; -} - -/* s contains x bytes of a little-endian integer. Return its value as a - * C int. Obscure: when x is 1 or 2, this is an unsigned little-endian - * int, but when x is 4 it's a signed one. This is an historical source - * of x-platform bugs. - */ -static long -calc_binint(char *s, int x) -{ - unsigned char c; - int i; - long l; - - for (i = 0, l = 0L; i < x; i++) { - c = (unsigned char)s[i]; - l |= (long)c << (i * 8); - } -#if SIZEOF_LONG > 4 - /* Unlike BININT1 and BININT2, BININT (more accurately BININT4) - * is signed, so on a box with longs bigger than 4 bytes we need - * to extend a BININT's sign bit to the full width. - */ - if (x == 4 && l & (1L << 31)) - l |= (~0L) << 32; -#endif - return l; -} - - -static int -load_binintx(Unpicklerobject *self, char *s, int x) -{ - PyObject *py_int = 0; - long l; - - l = calc_binint(s, x); - - if (!( py_int = PyInt_FromLong(l))) - return -1; - - PDATA_PUSH(self->stack, py_int, -1); - return 0; -} - - -static int -load_binint(Unpicklerobject *self) -{ - char *s; - - if (self->read_func(self, &s, 4) < 0) - return -1; - - return load_binintx(self, s, 4); -} - - -static int -load_binint1(Unpicklerobject *self) -{ - char *s; - - if (self->read_func(self, &s, 1) < 0) - return -1; - - return load_binintx(self, s, 1); -} - - -static int -load_binint2(Unpicklerobject *self) -{ - char *s; - - if (self->read_func(self, &s, 2) < 0) - return -1; - - return load_binintx(self, s, 2); -} - -static int -load_long(Unpicklerobject *self) -{ - PyObject *l = 0; - char *end, *s; - int len, res = -1; - - if ((len = self->readline_func(self, &s)) < 0) return -1; - if (len < 2) return bad_readline(); - if (!( s=pystrndup(s,len))) return -1; - - if (!( l = PyLong_FromString(s, &end, 0))) - goto finally; - - free(s); - PDATA_PUSH(self->stack, l, -1); - return 0; - - finally: - free(s); - - return res; -} - -/* 'size' bytes contain the # of bytes of little-endian 256's-complement - * data following. - */ -static int -load_counted_long(Unpicklerobject *self, int size) -{ - int i; - char *nbytes; - unsigned char *pdata; - PyObject *along; - - assert(size == 1 || size == 4); - i = self->read_func(self, &nbytes, size); - if (i < 0) return -1; - - size = calc_binint(nbytes, size); - if (size < 0) { - /* Corrupt or hostile pickle -- we never write one like - * this. - */ - PyErr_SetString(UnpicklingError, "LONG pickle has negative " - "byte count"); - return -1; - } - - if (size == 0) - along = PyLong_FromLong(0L); - else { - /* Read the raw little-endian bytes & convert. */ - i = self->read_func(self, (char **)&pdata, size); - if (i < 0) return -1; - along = _PyLong_FromByteArray(pdata, (size_t)size, - 1 /* little endian */, 1 /* signed */); - } - if (along == NULL) - return -1; - PDATA_PUSH(self->stack, along, -1); - return 0; -} - -static int -load_float(Unpicklerobject *self) -{ - PyObject *py_float = 0; - char *endptr, *s; - int len, res = -1; - double d; - - if ((len = self->readline_func(self, &s)) < 0) return -1; - if (len < 2) return bad_readline(); - if (!( s=pystrndup(s,len))) return -1; - - errno = 0; - d = strtod(s, &endptr); - - if (errno || (endptr[0] != '\n') || (endptr[1] != '\0')) { - PyErr_SetString(PyExc_ValueError, - "could not convert string to float"); - goto finally; - } - - if (!( py_float = PyFloat_FromDouble(d))) - goto finally; - - free(s); - PDATA_PUSH(self->stack, py_float, -1); - return 0; - - finally: - free(s); - - return res; -} - -static int -load_binfloat(Unpicklerobject *self) -{ - PyObject *py_float; - double x; - char *p; - - if (self->read_func(self, &p, 8) < 0) - return -1; - - x = _PyFloat_Unpack8((unsigned char *)p, 0); - if (x == -1.0 && PyErr_Occurred()) - return -1; - - py_float = PyFloat_FromDouble(x); - if (py_float == NULL) - return -1; - - PDATA_PUSH(self->stack, py_float, -1); - return 0; -} - -static int -load_string(Unpicklerobject *self) -{ - PyObject *str = 0; - int len, res = -1; - char *s, *p; - - if ((len = self->readline_func(self, &s)) < 0) return -1; - if (len < 2) return bad_readline(); - if (!( s=pystrndup(s,len))) return -1; - - - /* Strip outermost quotes */ - while (s[len-1] <= ' ') - len--; - if(s[0]=='"' && s[len-1]=='"'){ - s[len-1] = '\0'; - p = s + 1 ; - len -= 2; - } else if(s[0]=='\'' && s[len-1]=='\''){ - s[len-1] = '\0'; - p = s + 1 ; - len -= 2; - } else - goto insecure; - /********************************************/ - - str = PyString_DecodeEscape(p, len, NULL, 0, NULL); - if (str) { - PDATA_PUSH(self->stack, str, -1); - res = 0; - } - free(s); - return res; - - insecure: - free(s); - PyErr_SetString(PyExc_ValueError,"insecure string pickle"); - return -1; -} - - -static int -load_binstring(Unpicklerobject *self) -{ - PyObject *py_string = 0; - long l; - char *s; - - if (self->read_func(self, &s, 4) < 0) return -1; - - l = calc_binint(s, 4); - - if (self->read_func(self, &s, l) < 0) - return -1; - - if (!( py_string = PyString_FromStringAndSize(s, l))) - return -1; - - PDATA_PUSH(self->stack, py_string, -1); - return 0; -} - - -static int -load_short_binstring(Unpicklerobject *self) -{ - PyObject *py_string = 0; - unsigned char l; - char *s; - - if (self->read_func(self, &s, 1) < 0) - return -1; - - l = (unsigned char)s[0]; - - if (self->read_func(self, &s, l) < 0) return -1; - - if (!( py_string = PyString_FromStringAndSize(s, l))) return -1; - - PDATA_PUSH(self->stack, py_string, -1); - return 0; -} - - -#ifdef Py_USING_UNICODE -static int -load_unicode(Unpicklerobject *self) -{ - PyObject *str = 0; - int len, res = -1; - char *s; - - if ((len = self->readline_func(self, &s)) < 0) return -1; - if (len < 1) return bad_readline(); - - if (!( str = PyUnicode_DecodeRawUnicodeEscape(s, len - 1, NULL))) - goto finally; - - PDATA_PUSH(self->stack, str, -1); - return 0; - - finally: - return res; -} -#endif - - -#ifdef Py_USING_UNICODE -static int -load_binunicode(Unpicklerobject *self) -{ - PyObject *unicode; - long l; - char *s; - - if (self->read_func(self, &s, 4) < 0) return -1; - - l = calc_binint(s, 4); - - if (self->read_func(self, &s, l) < 0) - return -1; - - if (!( unicode = PyUnicode_DecodeUTF8(s, l, NULL))) - return -1; - - PDATA_PUSH(self->stack, unicode, -1); - return 0; -} -#endif - - -static int -load_tuple(Unpicklerobject *self) -{ - PyObject *tup; - int i; - - if ((i = marker(self)) < 0) return -1; - if (!( tup=Pdata_popTuple(self->stack, i))) return -1; - PDATA_PUSH(self->stack, tup, -1); - return 0; -} - -static int -load_counted_tuple(Unpicklerobject *self, int len) -{ - PyObject *tup = PyTuple_New(len); - - if (tup == NULL) - return -1; - - while (--len >= 0) { - PyObject *element; - - PDATA_POP(self->stack, element); - if (element == NULL) - return -1; - PyTuple_SET_ITEM(tup, len, element); - } - PDATA_PUSH(self->stack, tup, -1); - return 0; -} - -static int -load_empty_list(Unpicklerobject *self) -{ - PyObject *list; - - if (!( list=PyList_New(0))) return -1; - PDATA_PUSH(self->stack, list, -1); - return 0; -} - -static int -load_empty_dict(Unpicklerobject *self) -{ - PyObject *dict; - - if (!( dict=PyDict_New())) return -1; - PDATA_PUSH(self->stack, dict, -1); - return 0; -} - - -static int -load_list(Unpicklerobject *self) -{ - PyObject *list = 0; - int i; - - if ((i = marker(self)) < 0) return -1; - if (!( list=Pdata_popList(self->stack, i))) return -1; - PDATA_PUSH(self->stack, list, -1); - return 0; -} - -static int -load_dict(Unpicklerobject *self) -{ - PyObject *dict, *key, *value; - int i, j, k; - - if ((i = marker(self)) < 0) return -1; - j=self->stack->length; - - if (!( dict = PyDict_New())) return -1; - - for (k = i+1; k < j; k += 2) { - key =self->stack->data[k-1]; - value=self->stack->data[k ]; - if (PyDict_SetItem(dict, key, value) < 0) { - Py_DECREF(dict); - return -1; - } - } - Pdata_clear(self->stack, i); - PDATA_PUSH(self->stack, dict, -1); - return 0; -} - -static PyObject * -Instance_New(PyObject *cls, PyObject *args) -{ - PyObject *r = 0; - - if (PyClass_Check(cls)) { - int l; - - if ((l=PyObject_Size(args)) < 0) goto err; - if (!( l )) { - PyObject *__getinitargs__; - - __getinitargs__ = PyObject_GetAttr(cls, - __getinitargs___str); - if (!__getinitargs__) { - /* We have a class with no __getinitargs__, - so bypass usual construction */ - PyObject *inst; - - PyErr_Clear(); - if (!( inst=PyInstance_NewRaw(cls, NULL))) - goto err; - return inst; - } - Py_DECREF(__getinitargs__); - } - - if ((r=PyInstance_New(cls, args, NULL))) return r; - else goto err; - } - - if (args==Py_None) { - /* Special case, call cls.__basicnew__() */ - PyObject *basicnew; - - basicnew = PyObject_GetAttr(cls, __basicnew___str); - if (!basicnew) return NULL; - r=PyObject_CallObject(basicnew, NULL); - Py_DECREF(basicnew); - if (r) return r; - } - - if ((r=PyObject_CallObject(cls, args))) return r; - - err: - { - PyObject *tp, *v, *tb; - - PyErr_Fetch(&tp, &v, &tb); - if ((r=Py_BuildValue("OOO",v,cls,args))) { - Py_XDECREF(v); - v=r; - } - PyErr_Restore(tp,v,tb); - } - return NULL; -} - - -static int -load_obj(Unpicklerobject *self) -{ - PyObject *class, *tup, *obj=0; - int i; - - if ((i = marker(self)) < 0) return -1; - if (!( tup=Pdata_popTuple(self->stack, i+1))) return -1; - PDATA_POP(self->stack, class); - if (class) { - obj = Instance_New(class, tup); - Py_DECREF(class); - } - Py_DECREF(tup); - - if (! obj) return -1; - PDATA_PUSH(self->stack, obj, -1); - return 0; -} - - -static int -load_inst(Unpicklerobject *self) -{ - PyObject *tup, *class=0, *obj=0, *module_name, *class_name; - int i, len; - char *s; - - if ((i = marker(self)) < 0) return -1; - - if ((len = self->readline_func(self, &s)) < 0) return -1; - if (len < 2) return bad_readline(); - module_name = PyString_FromStringAndSize(s, len - 1); - if (!module_name) return -1; - - if ((len = self->readline_func(self, &s)) >= 0) { - if (len < 2) return bad_readline(); - if ((class_name = PyString_FromStringAndSize(s, len - 1))) { - class = find_class(module_name, class_name, - self->find_class); - Py_DECREF(class_name); - } - } - Py_DECREF(module_name); - - if (! class) return -1; - - if ((tup=Pdata_popTuple(self->stack, i))) { - obj = Instance_New(class, tup); - Py_DECREF(tup); - } - Py_DECREF(class); - - if (! obj) return -1; - - PDATA_PUSH(self->stack, obj, -1); - return 0; -} - -static int -load_newobj(Unpicklerobject *self) -{ - PyObject *args = NULL; - PyObject *clsraw = NULL; - PyTypeObject *cls; /* clsraw cast to its true type */ - PyObject *obj; - - /* Stack is ... cls argtuple, and we want to call - * cls.__new__(cls, *argtuple). - */ - PDATA_POP(self->stack, args); - if (args == NULL) goto Fail; - if (! PyTuple_Check(args)) { - PyErr_SetString(UnpicklingError, "NEWOBJ expected an arg " - "tuple."); - goto Fail; - } - - PDATA_POP(self->stack, clsraw); - cls = (PyTypeObject *)clsraw; - if (cls == NULL) goto Fail; - if (! PyType_Check(cls)) { - PyErr_SetString(UnpicklingError, "NEWOBJ class argument " - "isn't a type object"); - goto Fail; - } - if (cls->tp_new == NULL) { - PyErr_SetString(UnpicklingError, "NEWOBJ class argument " - "has NULL tp_new"); - goto Fail; - } - - /* Call __new__. */ - obj = cls->tp_new(cls, args, NULL); - if (obj == NULL) goto Fail; - - Py_DECREF(args); - Py_DECREF(clsraw); - PDATA_PUSH(self->stack, obj, -1); - return 0; - - Fail: - Py_XDECREF(args); - Py_XDECREF(clsraw); - return -1; -} - -static int -load_global(Unpicklerobject *self) -{ - PyObject *class = 0, *module_name = 0, *class_name = 0; - int len; - char *s; - - if ((len = self->readline_func(self, &s)) < 0) return -1; - if (len < 2) return bad_readline(); - module_name = PyString_FromStringAndSize(s, len - 1); - if (!module_name) return -1; - - if ((len = self->readline_func(self, &s)) >= 0) { - if (len < 2) { - Py_DECREF(module_name); - return bad_readline(); - } - if ((class_name = PyString_FromStringAndSize(s, len - 1))) { - class = find_class(module_name, class_name, - self->find_class); - Py_DECREF(class_name); - } - } - Py_DECREF(module_name); - - if (! class) return -1; - PDATA_PUSH(self->stack, class, -1); - return 0; -} - - -static int -load_persid(Unpicklerobject *self) -{ - PyObject *pid = 0; - int len; - char *s; - - if (self->pers_func) { - if ((len = self->readline_func(self, &s)) < 0) return -1; - if (len < 2) return bad_readline(); - - pid = PyString_FromStringAndSize(s, len - 1); - if (!pid) return -1; - - if (PyList_Check(self->pers_func)) { - if (PyList_Append(self->pers_func, pid) < 0) { - Py_DECREF(pid); - return -1; - } - } - else { - ARG_TUP(self, pid); - if (self->arg) { - pid = PyObject_Call(self->pers_func, self->arg, - NULL); - FREE_ARG_TUP(self); - } - } - - if (! pid) return -1; - - PDATA_PUSH(self->stack, pid, -1); - return 0; - } - else { - PyErr_SetString(UnpicklingError, - "A load persistent id instruction was encountered,\n" - "but no persistent_load function was specified."); - return -1; - } -} - -static int -load_binpersid(Unpicklerobject *self) -{ - PyObject *pid = 0; - - if (self->pers_func) { - PDATA_POP(self->stack, pid); - if (! pid) return -1; - - if (PyList_Check(self->pers_func)) { - if (PyList_Append(self->pers_func, pid) < 0) { - Py_DECREF(pid); - return -1; - } - } - else { - ARG_TUP(self, pid); - if (self->arg) { - pid = PyObject_Call(self->pers_func, self->arg, - NULL); - FREE_ARG_TUP(self); - } - if (! pid) return -1; - } - - PDATA_PUSH(self->stack, pid, -1); - return 0; - } - else { - PyErr_SetString(UnpicklingError, - "A load persistent id instruction was encountered,\n" - "but no persistent_load function was specified."); - return -1; - } -} - - -static int -load_pop(Unpicklerobject *self) -{ - int len; - - if (!( (len=self->stack->length) > 0 )) return stackUnderflow(); - - /* Note that we split the (pickle.py) stack into two stacks, - an object stack and a mark stack. We have to be clever and - pop the right one. We do this by looking at the top of the - mark stack. - */ - - if ((self->num_marks > 0) && - (self->marks[self->num_marks - 1] == len)) - self->num_marks--; - else { - len--; - Py_DECREF(self->stack->data[len]); - self->stack->length=len; - } - - return 0; -} - - -static int -load_pop_mark(Unpicklerobject *self) -{ - int i; - - if ((i = marker(self)) < 0) - return -1; - - Pdata_clear(self->stack, i); - - return 0; -} - - -static int -load_dup(Unpicklerobject *self) -{ - PyObject *last; - int len; - - if ((len = self->stack->length) <= 0) return stackUnderflow(); - last=self->stack->data[len-1]; - Py_INCREF(last); - PDATA_PUSH(self->stack, last, -1); - return 0; -} - - -static int -load_get(Unpicklerobject *self) -{ - PyObject *py_str = 0, *value = 0; - int len; - char *s; - int rc; - - if ((len = self->readline_func(self, &s)) < 0) return -1; - if (len < 2) return bad_readline(); - - if (!( py_str = PyString_FromStringAndSize(s, len - 1))) return -1; - - value = PyDict_GetItem(self->memo, py_str); - if (! value) { - PyErr_SetObject(BadPickleGet, py_str); - rc = -1; - } - else { - PDATA_APPEND(self->stack, value, -1); - rc = 0; - } - - Py_DECREF(py_str); - return rc; -} - - -static int -load_binget(Unpicklerobject *self) -{ - PyObject *py_key = 0, *value = 0; - unsigned char key; - char *s; - int rc; - - if (self->read_func(self, &s, 1) < 0) return -1; - - key = (unsigned char)s[0]; - if (!( py_key = PyInt_FromLong((long)key))) return -1; - - value = PyDict_GetItem(self->memo, py_key); - if (! value) { - PyErr_SetObject(BadPickleGet, py_key); - rc = -1; - } - else { - PDATA_APPEND(self->stack, value, -1); - rc = 0; - } - - Py_DECREF(py_key); - return rc; -} - - -static int -load_long_binget(Unpicklerobject *self) -{ - PyObject *py_key = 0, *value = 0; - unsigned char c; - char *s; - long key; - int rc; - - if (self->read_func(self, &s, 4) < 0) return -1; - - c = (unsigned char)s[0]; - key = (long)c; - c = (unsigned char)s[1]; - key |= (long)c << 8; - c = (unsigned char)s[2]; - key |= (long)c << 16; - c = (unsigned char)s[3]; - key |= (long)c << 24; - - if (!( py_key = PyInt_FromLong((long)key))) return -1; - - value = PyDict_GetItem(self->memo, py_key); - if (! value) { - PyErr_SetObject(BadPickleGet, py_key); - rc = -1; - } - else { - PDATA_APPEND(self->stack, value, -1); - rc = 0; - } - - Py_DECREF(py_key); - return rc; -} - -/* Push an object from the extension registry (EXT[124]). nbytes is - * the number of bytes following the opcode, holding the index (code) value. - */ -static int -load_extension(Unpicklerobject *self, int nbytes) -{ - char *codebytes; /* the nbytes bytes after the opcode */ - long code; /* calc_binint returns long */ - PyObject *py_code; /* code as a Python int */ - PyObject *obj; /* the object to push */ - PyObject *pair; /* (module_name, class_name) */ - PyObject *module_name, *class_name; - - assert(nbytes == 1 || nbytes == 2 || nbytes == 4); - if (self->read_func(self, &codebytes, nbytes) < 0) return -1; - code = calc_binint(codebytes, nbytes); - if (code <= 0) { /* note that 0 is forbidden */ - /* Corrupt or hostile pickle. */ - PyErr_SetString(UnpicklingError, "EXT specifies code <= 0"); - return -1; - } - - /* Look for the code in the cache. */ - py_code = PyInt_FromLong(code); - if (py_code == NULL) return -1; - obj = PyDict_GetItem(extension_cache, py_code); - if (obj != NULL) { - /* Bingo. */ - Py_DECREF(py_code); - PDATA_APPEND(self->stack, obj, -1); - return 0; - } - - /* Look up the (module_name, class_name) pair. */ - pair = PyDict_GetItem(inverted_registry, py_code); - if (pair == NULL) { - Py_DECREF(py_code); - PyErr_Format(PyExc_ValueError, "unregistered extension " - "code %ld", code); - return -1; - } - /* Since the extension registry is manipulable via Python code, - * confirm that pair is really a 2-tuple of strings. - */ - if (!PyTuple_Check(pair) || PyTuple_Size(pair) != 2 || - !PyString_Check(module_name = PyTuple_GET_ITEM(pair, 0)) || - !PyString_Check(class_name = PyTuple_GET_ITEM(pair, 1))) { - Py_DECREF(py_code); - PyErr_Format(PyExc_ValueError, "_inverted_registry[%ld] " - "isn't a 2-tuple of strings", code); - return -1; - } - /* Load the object. */ - obj = find_class(module_name, class_name, self->find_class); - if (obj == NULL) { - Py_DECREF(py_code); - return -1; - } - /* Cache code -> obj. */ - code = PyDict_SetItem(extension_cache, py_code, obj); - Py_DECREF(py_code); - if (code < 0) { - Py_DECREF(obj); - return -1; - } - PDATA_PUSH(self->stack, obj, -1); - return 0; -} - -static int -load_put(Unpicklerobject *self) -{ - PyObject *py_str = 0, *value = 0; - int len, l; - char *s; - - if ((l = self->readline_func(self, &s)) < 0) return -1; - if (l < 2) return bad_readline(); - if (!( len=self->stack->length )) return stackUnderflow(); - if (!( py_str = PyString_FromStringAndSize(s, l - 1))) return -1; - value=self->stack->data[len-1]; - l=PyDict_SetItem(self->memo, py_str, value); - Py_DECREF(py_str); - return l; -} - - -static int -load_binput(Unpicklerobject *self) -{ - PyObject *py_key = 0, *value = 0; - unsigned char key; - char *s; - int len; - - if (self->read_func(self, &s, 1) < 0) return -1; - if (!( (len=self->stack->length) > 0 )) return stackUnderflow(); - - key = (unsigned char)s[0]; - - if (!( py_key = PyInt_FromLong((long)key))) return -1; - value=self->stack->data[len-1]; - len=PyDict_SetItem(self->memo, py_key, value); - Py_DECREF(py_key); - return len; -} - - -static int -load_long_binput(Unpicklerobject *self) -{ - PyObject *py_key = 0, *value = 0; - long key; - unsigned char c; - char *s; - int len; - - if (self->read_func(self, &s, 4) < 0) return -1; - if (!( len=self->stack->length )) return stackUnderflow(); - - c = (unsigned char)s[0]; - key = (long)c; - c = (unsigned char)s[1]; - key |= (long)c << 8; - c = (unsigned char)s[2]; - key |= (long)c << 16; - c = (unsigned char)s[3]; - key |= (long)c << 24; - - if (!( py_key = PyInt_FromLong(key))) return -1; - value=self->stack->data[len-1]; - len=PyDict_SetItem(self->memo, py_key, value); - Py_DECREF(py_key); - return len; -} - - -static int -do_append(Unpicklerobject *self, int x) -{ - PyObject *value = 0, *list = 0, *append_method = 0; - int len, i; - - len=self->stack->length; - if (!( len >= x && x > 0 )) return stackUnderflow(); - /* nothing to do */ - if (len==x) return 0; - - list=self->stack->data[x-1]; - - if (PyList_Check(list)) { - PyObject *slice; - int list_len; - - slice=Pdata_popList(self->stack, x); - list_len = PyList_GET_SIZE(list); - i=PyList_SetSlice(list, list_len, list_len, slice); - Py_DECREF(slice); - return i; - } - else { - - if (!( append_method = PyObject_GetAttr(list, append_str))) - return -1; - - for (i = x; i < len; i++) { - PyObject *junk; - - value=self->stack->data[i]; - junk=0; - ARG_TUP(self, value); - if (self->arg) { - junk = PyObject_Call(append_method, self->arg, - NULL); - FREE_ARG_TUP(self); - } - if (! junk) { - Pdata_clear(self->stack, i+1); - self->stack->length=x; - Py_DECREF(append_method); - return -1; - } - Py_DECREF(junk); - } - self->stack->length=x; - Py_DECREF(append_method); - } - - return 0; -} - - -static int -load_append(Unpicklerobject *self) -{ - return do_append(self, self->stack->length - 1); -} - - -static int -load_appends(Unpicklerobject *self) -{ - return do_append(self, marker(self)); -} - - -static int -do_setitems(Unpicklerobject *self, int x) -{ - PyObject *value = 0, *key = 0, *dict = 0; - int len, i, r=0; - - if (!( (len=self->stack->length) >= x - && x > 0 )) return stackUnderflow(); - - dict=self->stack->data[x-1]; - - for (i = x+1; i < len; i += 2) { - key =self->stack->data[i-1]; - value=self->stack->data[i ]; - if (PyObject_SetItem(dict, key, value) < 0) { - r=-1; - break; - } - } - - Pdata_clear(self->stack, x); - - return r; -} - - -static int -load_setitem(Unpicklerobject *self) -{ - return do_setitems(self, self->stack->length - 2); -} - -static int -load_setitems(Unpicklerobject *self) -{ - return do_setitems(self, marker(self)); -} - - -static int -load_build(Unpicklerobject *self) -{ - PyObject *state, *inst, *slotstate; - PyObject *__setstate__; - PyObject *d_key, *d_value; - int i; - int res = -1; - - /* Stack is ... instance, state. We want to leave instance at - * the stack top, possibly mutated via instance.__setstate__(state). - */ - if (self->stack->length < 2) - return stackUnderflow(); - PDATA_POP(self->stack, state); - if (state == NULL) - return -1; - inst = self->stack->data[self->stack->length - 1]; - - __setstate__ = PyObject_GetAttr(inst, __setstate___str); - if (__setstate__ != NULL) { - PyObject *junk = NULL; - - /* The explicit __setstate__ is responsible for everything. */ - ARG_TUP(self, state); - if (self->arg) { - junk = PyObject_Call(__setstate__, self->arg, NULL); - FREE_ARG_TUP(self); - } - Py_DECREF(__setstate__); - if (junk == NULL) - return -1; - Py_DECREF(junk); - return 0; - } - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return -1; - PyErr_Clear(); - - /* A default __setstate__. First see whether state embeds a - * slot state dict too (a proto 2 addition). - */ - if (PyTuple_Check(state) && PyTuple_Size(state) == 2) { - PyObject *temp = state; - state = PyTuple_GET_ITEM(temp, 0); - slotstate = PyTuple_GET_ITEM(temp, 1); - Py_INCREF(state); - Py_INCREF(slotstate); - Py_DECREF(temp); - } - else - slotstate = NULL; - - /* Set inst.__dict__ from the state dict (if any). */ - if (state != Py_None) { - PyObject *dict; - if (! PyDict_Check(state)) { - PyErr_SetString(UnpicklingError, "state is not a " - "dictionary"); - goto finally; - } - dict = PyObject_GetAttr(inst, __dict___str); - if (dict == NULL) - goto finally; - - i = 0; - while (PyDict_Next(state, &i, &d_key, &d_value)) { - if (PyObject_SetItem(dict, d_key, d_value) < 0) - goto finally; - } - Py_DECREF(dict); - } - - /* Also set instance attributes from the slotstate dict (if any). */ - if (slotstate != NULL) { - if (! PyDict_Check(slotstate)) { - PyErr_SetString(UnpicklingError, "slot state is not " - "a dictionary"); - goto finally; - } - i = 0; - while (PyDict_Next(slotstate, &i, &d_key, &d_value)) { - if (PyObject_SetAttr(inst, d_key, d_value) < 0) - goto finally; - } - } - res = 0; - - finally: - Py_DECREF(state); - Py_XDECREF(slotstate); - return res; -} - - -static int -load_mark(Unpicklerobject *self) -{ - int s; - - /* Note that we split the (pickle.py) stack into two stacks, an - object stack and a mark stack. Here we push a mark onto the - mark stack. - */ - - if ((self->num_marks + 1) >= self->marks_size) { - s=self->marks_size+20; - if (s <= self->num_marks) s=self->num_marks + 1; - if (self->marks == NULL) - self->marks=(int *)malloc(s * sizeof(int)); - else - self->marks=(int *)realloc(self->marks, - s * sizeof(int)); - if (! self->marks) { - PyErr_NoMemory(); - return -1; - } - self->marks_size = s; - } - - self->marks[self->num_marks++] = self->stack->length; - - return 0; -} - -static int -load_reduce(Unpicklerobject *self) -{ - PyObject *callable = 0, *arg_tup = 0, *ob = 0; - - PDATA_POP(self->stack, arg_tup); - if (! arg_tup) return -1; - PDATA_POP(self->stack, callable); - if (callable) { - ob = Instance_New(callable, arg_tup); - Py_DECREF(callable); - } - Py_DECREF(arg_tup); - - if (! ob) return -1; - - PDATA_PUSH(self->stack, ob, -1); - return 0; -} - -/* Just raises an error if we don't know the protocol specified. PROTO - * is the first opcode for protocols >= 2. - */ -static int -load_proto(Unpicklerobject *self) -{ - int i; - char *protobyte; - - i = self->read_func(self, &protobyte, 1); - if (i < 0) - return -1; - - i = calc_binint(protobyte, 1); - /* No point checking for < 0, since calc_binint returns an unsigned - * int when chewing on 1 byte. - */ - assert(i >= 0); - if (i <= HIGHEST_PROTOCOL) - return 0; - - PyErr_Format(PyExc_ValueError, "unsupported pickle protocol: %d", i); - return -1; -} - -static PyObject * -load(Unpicklerobject *self) -{ - PyObject *err = 0, *val = 0; - char *s; - - self->num_marks = 0; - if (self->stack->length) Pdata_clear(self->stack, 0); - - while (1) { - if (self->read_func(self, &s, 1) < 0) - break; - - switch (s[0]) { - case NONE: - if (load_none(self) < 0) - break; - continue; - - case BININT: - if (load_binint(self) < 0) - break; - continue; - - case BININT1: - if (load_binint1(self) < 0) - break; - continue; - - case BININT2: - if (load_binint2(self) < 0) - break; - continue; - - case INT: - if (load_int(self) < 0) - break; - continue; - - case LONG: - if (load_long(self) < 0) - break; - continue; - - case LONG1: - if (load_counted_long(self, 1) < 0) - break; - continue; - - case LONG4: - if (load_counted_long(self, 4) < 0) - break; - continue; - - case FLOAT: - if (load_float(self) < 0) - break; - continue; - - case BINFLOAT: - if (load_binfloat(self) < 0) - break; - continue; - - case BINSTRING: - if (load_binstring(self) < 0) - break; - continue; - - case SHORT_BINSTRING: - if (load_short_binstring(self) < 0) - break; - continue; - - case STRING: - if (load_string(self) < 0) - break; - continue; - -#ifdef Py_USING_UNICODE - case UNICODE: - if (load_unicode(self) < 0) - break; - continue; - - case BINUNICODE: - if (load_binunicode(self) < 0) - break; - continue; -#endif - - case EMPTY_TUPLE: - if (load_counted_tuple(self, 0) < 0) - break; - continue; - - case TUPLE1: - if (load_counted_tuple(self, 1) < 0) - break; - continue; - - case TUPLE2: - if (load_counted_tuple(self, 2) < 0) - break; - continue; - - case TUPLE3: - if (load_counted_tuple(self, 3) < 0) - break; - continue; - - case TUPLE: - if (load_tuple(self) < 0) - break; - continue; - - case EMPTY_LIST: - if (load_empty_list(self) < 0) - break; - continue; - - case LIST: - if (load_list(self) < 0) - break; - continue; - - case EMPTY_DICT: - if (load_empty_dict(self) < 0) - break; - continue; - - case DICT: - if (load_dict(self) < 0) - break; - continue; - - case OBJ: - if (load_obj(self) < 0) - break; - continue; - - case INST: - if (load_inst(self) < 0) - break; - continue; - - case NEWOBJ: - if (load_newobj(self) < 0) - break; - continue; - - case GLOBAL: - if (load_global(self) < 0) - break; - continue; - - case APPEND: - if (load_append(self) < 0) - break; - continue; - - case APPENDS: - if (load_appends(self) < 0) - break; - continue; - - case BUILD: - if (load_build(self) < 0) - break; - continue; - - case DUP: - if (load_dup(self) < 0) - break; - continue; - - case BINGET: - if (load_binget(self) < 0) - break; - continue; - - case LONG_BINGET: - if (load_long_binget(self) < 0) - break; - continue; - - case GET: - if (load_get(self) < 0) - break; - continue; - - case EXT1: - if (load_extension(self, 1) < 0) - break; - continue; - - case EXT2: - if (load_extension(self, 2) < 0) - break; - continue; - - case EXT4: - if (load_extension(self, 4) < 0) - break; - continue; - case MARK: - if (load_mark(self) < 0) - break; - continue; - - case BINPUT: - if (load_binput(self) < 0) - break; - continue; - - case LONG_BINPUT: - if (load_long_binput(self) < 0) - break; - continue; - - case PUT: - if (load_put(self) < 0) - break; - continue; - - case POP: - if (load_pop(self) < 0) - break; - continue; - - case POP_MARK: - if (load_pop_mark(self) < 0) - break; - continue; - - case SETITEM: - if (load_setitem(self) < 0) - break; - continue; - - case SETITEMS: - if (load_setitems(self) < 0) - break; - continue; - - case STOP: - break; - - case PERSID: - if (load_persid(self) < 0) - break; - continue; - - case BINPERSID: - if (load_binpersid(self) < 0) - break; - continue; - - case REDUCE: - if (load_reduce(self) < 0) - break; - continue; - - case PROTO: - if (load_proto(self) < 0) - break; - continue; - - case NEWTRUE: - if (load_bool(self, Py_True) < 0) - break; - continue; - - case NEWFALSE: - if (load_bool(self, Py_False) < 0) - break; - continue; - - case '\0': - /* end of file */ - PyErr_SetNone(PyExc_EOFError); - break; - - default: - cPickle_ErrFormat(UnpicklingError, - "invalid load key, '%s'.", - "c", s[0]); - return NULL; - } - - break; - } - - if ((err = PyErr_Occurred())) { - if (err == PyExc_EOFError) { - PyErr_SetNone(PyExc_EOFError); - } - return NULL; - } - - PDATA_POP(self->stack, val); - return val; -} - - -/* No-load functions to support noload, which is used to - find persistent references. */ - -static int -noload_obj(Unpicklerobject *self) -{ - int i; - - if ((i = marker(self)) < 0) return -1; - return Pdata_clear(self->stack, i+1); -} - - -static int -noload_inst(Unpicklerobject *self) -{ - int i; - char *s; - - if ((i = marker(self)) < 0) return -1; - Pdata_clear(self->stack, i); - if (self->readline_func(self, &s) < 0) return -1; - if (self->readline_func(self, &s) < 0) return -1; - PDATA_APPEND(self->stack, Py_None, -1); - return 0; -} - -static int -noload_newobj(Unpicklerobject *self) -{ - PyObject *obj; - - PDATA_POP(self->stack, obj); /* pop argtuple */ - if (obj == NULL) return -1; - Py_DECREF(obj); - - PDATA_POP(self->stack, obj); /* pop cls */ - if (obj == NULL) return -1; - Py_DECREF(obj); - - PDATA_APPEND(self->stack, Py_None, -1); - return 0; -} - -static int -noload_global(Unpicklerobject *self) -{ - char *s; - - if (self->readline_func(self, &s) < 0) return -1; - if (self->readline_func(self, &s) < 0) return -1; - PDATA_APPEND(self->stack, Py_None,-1); - return 0; -} - -static int -noload_reduce(Unpicklerobject *self) -{ - - if (self->stack->length < 2) return stackUnderflow(); - Pdata_clear(self->stack, self->stack->length-2); - PDATA_APPEND(self->stack, Py_None,-1); - return 0; -} - -static int -noload_build(Unpicklerobject *self) { - - if (self->stack->length < 1) return stackUnderflow(); - Pdata_clear(self->stack, self->stack->length-1); - return 0; -} - -static int -noload_extension(Unpicklerobject *self, int nbytes) -{ - char *codebytes; - - assert(nbytes == 1 || nbytes == 2 || nbytes == 4); - if (self->read_func(self, &codebytes, nbytes) < 0) return -1; - PDATA_APPEND(self->stack, Py_None, -1); - return 0; -} - - -static PyObject * -noload(Unpicklerobject *self) -{ - PyObject *err = 0, *val = 0; - char *s; - - self->num_marks = 0; - Pdata_clear(self->stack, 0); - - while (1) { - if (self->read_func(self, &s, 1) < 0) - break; - - switch (s[0]) { - case NONE: - if (load_none(self) < 0) - break; - continue; - - case BININT: - if (load_binint(self) < 0) - break; - continue; - - case BININT1: - if (load_binint1(self) < 0) - break; - continue; - - case BININT2: - if (load_binint2(self) < 0) - break; - continue; - - case INT: - if (load_int(self) < 0) - break; - continue; - - case LONG: - if (load_long(self) < 0) - break; - continue; - - case LONG1: - if (load_counted_long(self, 1) < 0) - break; - continue; - - case LONG4: - if (load_counted_long(self, 4) < 0) - break; - continue; - - case FLOAT: - if (load_float(self) < 0) - break; - continue; - - case BINFLOAT: - if (load_binfloat(self) < 0) - break; - continue; - - case BINSTRING: - if (load_binstring(self) < 0) - break; - continue; - - case SHORT_BINSTRING: - if (load_short_binstring(self) < 0) - break; - continue; - - case STRING: - if (load_string(self) < 0) - break; - continue; - -#ifdef Py_USING_UNICODE - case UNICODE: - if (load_unicode(self) < 0) - break; - continue; - - case BINUNICODE: - if (load_binunicode(self) < 0) - break; - continue; -#endif - - case EMPTY_TUPLE: - if (load_counted_tuple(self, 0) < 0) - break; - continue; - - case TUPLE1: - if (load_counted_tuple(self, 1) < 0) - break; - continue; - - case TUPLE2: - if (load_counted_tuple(self, 2) < 0) - break; - continue; - - case TUPLE3: - if (load_counted_tuple(self, 3) < 0) - break; - continue; - - case TUPLE: - if (load_tuple(self) < 0) - break; - continue; - - case EMPTY_LIST: - if (load_empty_list(self) < 0) - break; - continue; - - case LIST: - if (load_list(self) < 0) - break; - continue; - - case EMPTY_DICT: - if (load_empty_dict(self) < 0) - break; - continue; - - case DICT: - if (load_dict(self) < 0) - break; - continue; - - case OBJ: - if (noload_obj(self) < 0) - break; - continue; - - case INST: - if (noload_inst(self) < 0) - break; - continue; - - case NEWOBJ: - if (noload_newobj(self) < 0) - break; - continue; - - case GLOBAL: - if (noload_global(self) < 0) - break; - continue; - - case APPEND: - if (load_append(self) < 0) - break; - continue; - - case APPENDS: - if (load_appends(self) < 0) - break; - continue; - - case BUILD: - if (noload_build(self) < 0) - break; - continue; - - case DUP: - if (load_dup(self) < 0) - break; - continue; - - case BINGET: - if (load_binget(self) < 0) - break; - continue; - - case LONG_BINGET: - if (load_long_binget(self) < 0) - break; - continue; - - case GET: - if (load_get(self) < 0) - break; - continue; - - case EXT1: - if (noload_extension(self, 1) < 0) - break; - continue; - - case EXT2: - if (noload_extension(self, 2) < 0) - break; - continue; - - case EXT4: - if (noload_extension(self, 4) < 0) - break; - continue; - - case MARK: - if (load_mark(self) < 0) - break; - continue; - - case BINPUT: - if (load_binput(self) < 0) - break; - continue; - - case LONG_BINPUT: - if (load_long_binput(self) < 0) - break; - continue; - - case PUT: - if (load_put(self) < 0) - break; - continue; - - case POP: - if (load_pop(self) < 0) - break; - continue; - - case POP_MARK: - if (load_pop_mark(self) < 0) - break; - continue; - - case SETITEM: - if (load_setitem(self) < 0) - break; - continue; - - case SETITEMS: - if (load_setitems(self) < 0) - break; - continue; - - case STOP: - break; - - case PERSID: - if (load_persid(self) < 0) - break; - continue; - - case BINPERSID: - if (load_binpersid(self) < 0) - break; - continue; - - case REDUCE: - if (noload_reduce(self) < 0) - break; - continue; - - case PROTO: - if (load_proto(self) < 0) - break; - continue; - - case NEWTRUE: - if (load_bool(self, Py_True) < 0) - break; - continue; - - case NEWFALSE: - if (load_bool(self, Py_False) < 0) - break; - continue; - default: - cPickle_ErrFormat(UnpicklingError, - "invalid load key, '%s'.", - "c", s[0]); - return NULL; - } - - break; - } - - if ((err = PyErr_Occurred())) { - if (err == PyExc_EOFError) { - PyErr_SetNone(PyExc_EOFError); - } - return NULL; - } - - PDATA_POP(self->stack, val); - return val; -} - - -static PyObject * -Unpickler_load(Unpicklerobject *self, PyObject *args) -{ - if (!( PyArg_ParseTuple(args, ":load"))) - return NULL; - - return load(self); -} - -static PyObject * -Unpickler_noload(Unpicklerobject *self, PyObject *args) -{ - if (!( PyArg_ParseTuple(args, ":noload"))) - return NULL; - - return noload(self); -} - - -static struct PyMethodDef Unpickler_methods[] = { - {"load", (PyCFunction)Unpickler_load, METH_VARARGS, - PyDoc_STR("load() -- Load a pickle") - }, - {"noload", (PyCFunction)Unpickler_noload, METH_VARARGS, - PyDoc_STR( - "noload() -- not load a pickle, but go through most of the motions\n" - "\n" - "This function can be used to read past a pickle without instantiating\n" - "any objects or importing any modules. It can also be used to find all\n" - "persistent references without instantiating any objects or importing\n" - "any modules.\n") - }, - {NULL, NULL} /* sentinel */ -}; - - -static Unpicklerobject * -newUnpicklerobject(PyObject *f) -{ - Unpicklerobject *self; - - if (!( self = PyObject_GC_New(Unpicklerobject, &Unpicklertype))) - return NULL; - - self->file = NULL; - self->arg = NULL; - self->stack = (Pdata*)Pdata_New(); - self->pers_func = NULL; - self->last_string = NULL; - self->marks = NULL; - self->num_marks = 0; - self->marks_size = 0; - self->buf_size = 0; - self->read = NULL; - self->readline = NULL; - self->find_class = NULL; - - if (!( self->memo = PyDict_New())) - goto err; - - Py_INCREF(f); - self->file = f; - - /* Set read, readline based on type of f */ - if (PyFile_Check(f)) { - self->fp = PyFile_AsFile(f); - if (self->fp == NULL) { - PyErr_SetString(PyExc_ValueError, - "I/O operation on closed file"); - goto err; - } - self->read_func = read_file; - self->readline_func = readline_file; - } - else if (PycStringIO_InputCheck(f)) { - self->fp = NULL; - self->read_func = read_cStringIO; - self->readline_func = readline_cStringIO; - } - else { - - self->fp = NULL; - self->read_func = read_other; - self->readline_func = readline_other; - - if (!( (self->readline = PyObject_GetAttr(f, readline_str)) && - (self->read = PyObject_GetAttr(f, read_str)))) { - PyErr_Clear(); - PyErr_SetString( PyExc_TypeError, - "argument must have 'read' and " - "'readline' attributes" ); - goto err; - } - } - PyObject_GC_Track(self); - - return self; - - err: - Py_DECREF((PyObject *)self); - return NULL; -} - - -static PyObject * -get_Unpickler(PyObject *self, PyObject *args) -{ - PyObject *file; - - if (!( PyArg_ParseTuple(args, "O:Unpickler", &file))) - return NULL; - return (PyObject *)newUnpicklerobject(file); -} - - -static void -Unpickler_dealloc(Unpicklerobject *self) -{ - PyObject_GC_UnTrack((PyObject *)self); - Py_XDECREF(self->readline); - Py_XDECREF(self->read); - Py_XDECREF(self->file); - Py_XDECREF(self->memo); - Py_XDECREF(self->stack); - Py_XDECREF(self->pers_func); - Py_XDECREF(self->arg); - Py_XDECREF(self->last_string); - Py_XDECREF(self->find_class); - - if (self->marks) { - free(self->marks); - } - - if (self->buf_size) { - free(self->buf); - } - - self->ob_type->tp_free((PyObject *)self); -} - -static int -Unpickler_traverse(Unpicklerobject *self, visitproc visit, void *arg) -{ - int err; - -#define VISIT(SLOT) \ - if (SLOT) { \ - err = visit((PyObject *)(SLOT), arg); \ - if (err) \ - return err; \ - } - VISIT(self->readline); - VISIT(self->read); - VISIT(self->file); - VISIT(self->memo); - VISIT(self->stack); - VISIT(self->pers_func); - VISIT(self->arg); - VISIT(self->last_string); - VISIT(self->find_class); -#undef VISIT - return 0; -} - -static int -Unpickler_clear(Unpicklerobject *self) -{ -#define CLEAR(SLOT) Py_XDECREF(SLOT); SLOT = NULL - CLEAR(self->readline); - CLEAR(self->read); - CLEAR(self->file); - CLEAR(self->memo); - CLEAR(self->stack); - CLEAR(self->pers_func); - CLEAR(self->arg); - CLEAR(self->last_string); - CLEAR(self->find_class); -#undef CLEAR - return 0; -} - -static PyObject * -Unpickler_getattr(Unpicklerobject *self, char *name) -{ - if (!strcmp(name, "persistent_load")) { - if (!self->pers_func) { - PyErr_SetString(PyExc_AttributeError, name); - return NULL; - } - - Py_INCREF(self->pers_func); - return self->pers_func; - } - - if (!strcmp(name, "find_global")) { - if (!self->find_class) { - PyErr_SetString(PyExc_AttributeError, name); - return NULL; - } - - Py_INCREF(self->find_class); - return self->find_class; - } - - if (!strcmp(name, "memo")) { - if (!self->memo) { - PyErr_SetString(PyExc_AttributeError, name); - return NULL; - } - - Py_INCREF(self->memo); - return self->memo; - } - - if (!strcmp(name, "UnpicklingError")) { - Py_INCREF(UnpicklingError); - return UnpicklingError; - } - - return Py_FindMethod(Unpickler_methods, (PyObject *)self, name); -} - - -static int -Unpickler_setattr(Unpicklerobject *self, char *name, PyObject *value) -{ - - if (!strcmp(name, "persistent_load")) { - Py_XDECREF(self->pers_func); - self->pers_func = value; - Py_XINCREF(value); - return 0; - } - - if (!strcmp(name, "find_global")) { - Py_XDECREF(self->find_class); - self->find_class = value; - Py_XINCREF(value); - return 0; - } - - if (! value) { - PyErr_SetString(PyExc_TypeError, - "attribute deletion is not supported"); - return -1; - } - - if (strcmp(name, "memo") == 0) { - if (!PyDict_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "memo must be a dictionary"); - return -1; - } - Py_XDECREF(self->memo); - self->memo = value; - Py_INCREF(value); - return 0; - } - - PyErr_SetString(PyExc_AttributeError, name); - return -1; -} - -/* --------------------------------------------------------------------------- - * Module-level functions. - */ - -/* dump(obj, file, proto=0). */ -static PyObject * -cpm_dump(PyObject *self, PyObject *args) -{ - PyObject *ob, *file, *res = NULL; - Picklerobject *pickler = 0; - int proto = 0; - - if (!( PyArg_ParseTuple(args, "OO|i", &ob, &file, &proto))) - goto finally; - - if (!( pickler = newPicklerobject(file, proto))) - goto finally; - - if (dump(pickler, ob) < 0) - goto finally; - - Py_INCREF(Py_None); - res = Py_None; - - finally: - Py_XDECREF(pickler); - - return res; -} - - -/* dumps(obj, proto=0). */ -static PyObject * -cpm_dumps(PyObject *self, PyObject *args) -{ - PyObject *ob, *file = 0, *res = NULL; - Picklerobject *pickler = 0; - int proto = 0; - - if (!( PyArg_ParseTuple(args, "O|i:dumps", &ob, &proto))) - goto finally; - - if (!( file = PycStringIO->NewOutput(128))) - goto finally; - - if (!( pickler = newPicklerobject(file, proto))) - goto finally; - - if (dump(pickler, ob) < 0) - goto finally; - - res = PycStringIO->cgetvalue(file); - - finally: - Py_XDECREF(pickler); - Py_XDECREF(file); - - return res; -} - - -/* load(fileobj). */ -static PyObject * -cpm_load(PyObject *self, PyObject *args) -{ - Unpicklerobject *unpickler = 0; - PyObject *ob, *res = NULL; - - if (!( PyArg_ParseTuple(args, "O:load", &ob))) - goto finally; - - if (!( unpickler = newUnpicklerobject(ob))) - goto finally; - - res = load(unpickler); - - finally: - Py_XDECREF(unpickler); - - return res; -} - - -/* loads(string) */ -static PyObject * -cpm_loads(PyObject *self, PyObject *args) -{ - PyObject *ob, *file = 0, *res = NULL; - Unpicklerobject *unpickler = 0; - - if (!( PyArg_ParseTuple(args, "S:loads", &ob))) - goto finally; - - if (!( file = PycStringIO->NewInput(ob))) - goto finally; - - if (!( unpickler = newUnpicklerobject(file))) - goto finally; - - res = load(unpickler); - - finally: - Py_XDECREF(file); - Py_XDECREF(unpickler); - - return res; -} - - -PyDoc_STRVAR(Unpicklertype__doc__, -"Objects that know how to unpickle"); - -static PyTypeObject Unpicklertype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "cPickle.Unpickler", /*tp_name*/ - sizeof(Unpicklerobject), /*tp_basicsize*/ - 0, - (destructor)Unpickler_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - (getattrfunc)Unpickler_getattr, /* tp_getattr */ - (setattrfunc)Unpickler_setattr, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, - Unpicklertype__doc__, /* tp_doc */ - (traverseproc)Unpickler_traverse, /* tp_traverse */ - (inquiry)Unpickler_clear, /* tp_clear */ -}; - -static struct PyMethodDef cPickle_methods[] = { - {"dump", (PyCFunction)cpm_dump, METH_VARARGS, - PyDoc_STR("dump(object, file, proto=0) -- " - "Write an object in pickle format to the given file.\n" - "\n" - "See the Pickler docstring for the meaning of optional argument proto.") - }, - - {"dumps", (PyCFunction)cpm_dumps, METH_VARARGS, - PyDoc_STR("dumps(object, proto=0) -- " - "Return a string containing an object in pickle format.\n" - "\n" - "See the Pickler docstring for the meaning of optional argument proto.") - }, - - {"load", (PyCFunction)cpm_load, METH_VARARGS, - PyDoc_STR("load(file) -- Load a pickle from the given file")}, - - {"loads", (PyCFunction)cpm_loads, METH_VARARGS, - PyDoc_STR("loads(string) -- Load a pickle from the given string")}, - - {"Pickler", (PyCFunction)get_Pickler, METH_VARARGS, - PyDoc_STR("Pickler(file, proto=0) -- Create a pickler.\n" - "\n" - "This takes a file-like object for writing a pickle data stream.\n" - "The optional proto argument tells the pickler to use the given\n" - "protocol; supported protocols are 0, 1, 2. The default\n" - "protocol is 0, to be backwards compatible. (Protocol 0 is the\n" - "only protocol that can be written to a file opened in text\n" - "mode and read back successfully. When using a protocol higher\n" - "than 0, make sure the file is opened in binary mode, both when\n" - "pickling and unpickling.)\n" - "\n" - "Protocol 1 is more efficient than protocol 0; protocol 2 is\n" - "more efficient than protocol 1.\n" - "\n" - "Specifying a negative protocol version selects the highest\n" - "protocol version supported. The higher the protocol used, the\n" - "more recent the version of Python needed to read the pickle\n" - "produced.\n" - "\n" - "The file parameter must have a write() method that accepts a single\n" - "string argument. It can thus be an open file object, a StringIO\n" - "object, or any other custom object that meets this interface.\n") - }, - - {"Unpickler", (PyCFunction)get_Unpickler, METH_VARARGS, - PyDoc_STR("Unpickler(file) -- Create an unpickler.")}, - - { NULL, NULL } -}; - -static int -init_stuff(PyObject *module_dict) -{ - PyObject *copy_reg, *t, *r; - -#define INIT_STR(S) if (!( S ## _str=PyString_InternFromString(#S))) return -1; - - if (PyType_Ready(&Unpicklertype) < 0) - return -1; - if (PyType_Ready(&Picklertype) < 0) - return -1; - - INIT_STR(__class__); - INIT_STR(__getinitargs__); - INIT_STR(__dict__); - INIT_STR(__getstate__); - INIT_STR(__setstate__); - INIT_STR(__name__); - INIT_STR(__main__); - INIT_STR(__reduce__); - INIT_STR(__reduce_ex__); - INIT_STR(write); - INIT_STR(append); - INIT_STR(read); - INIT_STR(readline); - INIT_STR(copy_reg); - INIT_STR(dispatch_table); - INIT_STR(__basicnew__); - - if (!( copy_reg = PyImport_ImportModule("copy_reg"))) - return -1; - - /* This is special because we want to use a different - one in restricted mode. */ - dispatch_table = PyObject_GetAttr(copy_reg, dispatch_table_str); - if (!dispatch_table) return -1; - - extension_registry = PyObject_GetAttrString(copy_reg, - "_extension_registry"); - if (!extension_registry) return -1; - - inverted_registry = PyObject_GetAttrString(copy_reg, - "_inverted_registry"); - if (!inverted_registry) return -1; - - extension_cache = PyObject_GetAttrString(copy_reg, - "_extension_cache"); - if (!extension_cache) return -1; - - Py_DECREF(copy_reg); - - if (!(empty_tuple = PyTuple_New(0))) - return -1; - - two_tuple = PyTuple_New(2); - if (two_tuple == NULL) - return -1; - /* We use this temp container with no regard to refcounts, or to - * keeping containees alive. Exempt from GC, because we don't - * want anything looking at two_tuple() by magic. - */ - PyObject_GC_UnTrack(two_tuple); - - /* Ugh */ - if (!( t=PyImport_ImportModule("__builtin__"))) return -1; - if (PyDict_SetItemString(module_dict, "__builtins__", t) < 0) - return -1; - - if (!( t=PyDict_New())) return -1; - if (!( r=PyRun_String( - "def __init__(self, *args): self.args=args\n\n" - "def __str__(self):\n" - " return self.args and ('%s' % self.args[0]) or '(what)'\n", - Py_file_input, - module_dict, t) )) return -1; - Py_DECREF(r); - - PickleError = PyErr_NewException("cPickle.PickleError", NULL, t); - if (!PickleError) - return -1; - - Py_DECREF(t); - - PicklingError = PyErr_NewException("cPickle.PicklingError", - PickleError, NULL); - if (!PicklingError) - return -1; - - if (!( t=PyDict_New())) return -1; - if (!( r=PyRun_String( - "def __init__(self, *args): self.args=args\n\n" - "def __str__(self):\n" - " a=self.args\n" - " a=a and type(a[0]) or '(what)'\n" - " return 'Cannot pickle %s objects' % a\n" - , Py_file_input, - module_dict, t) )) return -1; - Py_DECREF(r); - - if (!( UnpickleableError = PyErr_NewException( - "cPickle.UnpickleableError", PicklingError, t))) - return -1; - - Py_DECREF(t); - - if (!( UnpicklingError = PyErr_NewException("cPickle.UnpicklingError", - PickleError, NULL))) - return -1; - - if (!( BadPickleGet = PyErr_NewException("cPickle.BadPickleGet", - UnpicklingError, NULL))) - return -1; - - if (PyDict_SetItemString(module_dict, "PickleError", - PickleError) < 0) - return -1; - - if (PyDict_SetItemString(module_dict, "PicklingError", - PicklingError) < 0) - return -1; - - if (PyDict_SetItemString(module_dict, "UnpicklingError", - UnpicklingError) < 0) - return -1; - - if (PyDict_SetItemString(module_dict, "UnpickleableError", - UnpickleableError) < 0) - return -1; - - if (PyDict_SetItemString(module_dict, "BadPickleGet", - BadPickleGet) < 0) - return -1; - - PycString_IMPORT; - - return 0; -} - -#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */ -#define PyMODINIT_FUNC void -#endif -PyMODINIT_FUNC -initcPickle(void) -{ - PyObject *m, *d, *di, *v, *k; - int i; - char *rev = "1.71"; /* XXX when does this change? */ - PyObject *format_version; - PyObject *compatible_formats; - - Picklertype.ob_type = &PyType_Type; - Unpicklertype.ob_type = &PyType_Type; - PdataType.ob_type = &PyType_Type; - - /* Initialize some pieces. We need to do this before module creation, - * so we're forced to use a temporary dictionary. :( - */ - di = PyDict_New(); - if (!di) return; - if (init_stuff(di) < 0) return; - - /* Create the module and add the functions */ - m = Py_InitModule4("cPickle", cPickle_methods, - cPickle_module_documentation, - (PyObject*)NULL,PYTHON_API_VERSION); - - /* Add some symbolic constants to the module */ - d = PyModule_GetDict(m); - v = PyString_FromString(rev); - PyDict_SetItemString(d, "__version__", v); - Py_XDECREF(v); - - /* Copy data from di. Waaa. */ - for (i=0; PyDict_Next(di, &i, &k, &v); ) { - if (PyObject_SetItem(d, k, v) < 0) { - Py_DECREF(di); - return; - } - } - Py_DECREF(di); - - i = PyModule_AddIntConstant(m, "HIGHEST_PROTOCOL", HIGHEST_PROTOCOL); - if (i < 0) - return; - - /* These are purely informational; no code uses them. */ - /* File format version we write. */ - format_version = PyString_FromString("2.0"); - /* Format versions we can read. */ - compatible_formats = Py_BuildValue("[sssss]", - "1.0", /* Original protocol 0 */ - "1.1", /* Protocol 0 + INST */ - "1.2", /* Original protocol 1 */ - "1.3", /* Protocol 1 + BINFLOAT */ - "2.0"); /* Original protocol 2 */ - PyDict_SetItemString(d, "format_version", format_version); - PyDict_SetItemString(d, "compatible_formats", compatible_formats); - Py_XDECREF(format_version); - Py_XDECREF(compatible_formats); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/cStringIO.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/cStringIO.c deleted file mode 100644 index ba2bfa97..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/cStringIO.c +++ /dev/null @@ -1,731 +0,0 @@ - -#include "Python.h" -#include "import.h" -#include "cStringIO.h" -#include "structmember.h" - -PyDoc_STRVAR(cStringIO_module_documentation, -"A simple fast partial StringIO replacement.\n" -"\n" -"This module provides a simple useful replacement for\n" -"the StringIO module that is written in C. It does not provide the\n" -"full generality of StringIO, but it provides enough for most\n" -"applications and is especially useful in conjunction with the\n" -"pickle module.\n" -"\n" -"Usage:\n" -"\n" -" from cStringIO import StringIO\n" -"\n" -" an_output_stream=StringIO()\n" -" an_output_stream.write(some_stuff)\n" -" ...\n" -" value=an_output_stream.getvalue()\n" -"\n" -" an_input_stream=StringIO(a_string)\n" -" spam=an_input_stream.readline()\n" -" spam=an_input_stream.read(5)\n" -" an_input_stream.seek(0) # OK, start over\n" -" spam=an_input_stream.read() # and read it all\n" -" \n" -"If someone else wants to provide a more complete implementation,\n" -"go for it. :-) \n" -"\n" -"cStringIO.c,v 1.29 1999/06/15 14:10:27 jim Exp\n"); - -#define UNLESS(E) if (!(E)) - - -/* Declaration for file-like objects that manage data as strings - - The IOobject type should be though of as a common base type for - Iobjects, which provide input (read-only) StringIO objects and - Oobjects, which provide read-write objects. Most of the methods - depend only on common data. -*/ - -typedef struct { - PyObject_HEAD - char *buf; - int pos, string_size; -} IOobject; - -#define IOOOBJECT(O) ((IOobject*)(O)) - -/* Declarations for objects of type StringO */ - -typedef struct { /* Subtype of IOobject */ - PyObject_HEAD - char *buf; - int pos, string_size; - - int buf_size, softspace; -} Oobject; - -/* Declarations for objects of type StringI */ - -typedef struct { /* Subtype of IOobject */ - PyObject_HEAD - char *buf; - int pos, string_size; - /* We store a reference to the object here in order to keep - the buffer alive during the lifetime of the Iobject. */ - PyObject *pbuf; -} Iobject; - -/* IOobject (common) methods */ - -PyDoc_STRVAR(IO_flush__doc__, "flush(): does nothing."); - -static int -IO__opencheck(IOobject *self) { - UNLESS (self->buf) { - PyErr_SetString(PyExc_ValueError, - "I/O operation on closed file"); - return 0; - } - return 1; -} - -static PyObject * -IO_get_closed(IOobject *self, void *closure) -{ - PyObject *result = Py_False; - - if (self->buf == NULL) - result = Py_True; - Py_INCREF(result); - return result; -} - -static PyGetSetDef file_getsetlist[] = { - {"closed", (getter)IO_get_closed, NULL, "True if the file is closed"}, - {0}, -}; - -static PyObject * -IO_flush(IOobject *self, PyObject *unused) { - - UNLESS (IO__opencheck(self)) return NULL; - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(IO_getval__doc__, -"getvalue([use_pos]) -- Get the string value." -"\n" -"If use_pos is specified and is a true value, then the string returned\n" -"will include only the text up to the current file position.\n"); - -static PyObject * -IO_cgetval(PyObject *self) { - UNLESS (IO__opencheck(IOOOBJECT(self))) return NULL; - return PyString_FromStringAndSize(((IOobject*)self)->buf, - ((IOobject*)self)->pos); -} - -static PyObject * -IO_getval(IOobject *self, PyObject *args) { - PyObject *use_pos=Py_None; - int s; - - UNLESS (IO__opencheck(self)) return NULL; - UNLESS (PyArg_UnpackTuple(args,"getval", 0, 1,&use_pos)) return NULL; - - if (PyObject_IsTrue(use_pos)) { - s=self->pos; - if (s > self->string_size) s=self->string_size; - } - else - s=self->string_size; - return PyString_FromStringAndSize(self->buf, s); -} - -PyDoc_STRVAR(IO_isatty__doc__, "isatty(): always returns 0"); - -static PyObject * -IO_isatty(IOobject *self, PyObject *unused) { - Py_INCREF(Py_False); - return Py_False; -} - -PyDoc_STRVAR(IO_read__doc__, -"read([s]) -- Read s characters, or the rest of the string"); - -static int -IO_cread(PyObject *self, char **output, int n) { - int l; - - UNLESS (IO__opencheck(IOOOBJECT(self))) return -1; - l = ((IOobject*)self)->string_size - ((IOobject*)self)->pos; - if (n < 0 || n > l) { - n = l; - if (n < 0) n=0; - } - - *output=((IOobject*)self)->buf + ((IOobject*)self)->pos; - ((IOobject*)self)->pos += n; - return n; -} - -static PyObject * -IO_read(IOobject *self, PyObject *args) { - int n = -1; - char *output; - - UNLESS (PyArg_ParseTuple(args, "|i:read", &n)) return NULL; - - if ( (n=IO_cread((PyObject*)self,&output,n)) < 0) return NULL; - - return PyString_FromStringAndSize(output, n); -} - -PyDoc_STRVAR(IO_readline__doc__, "readline() -- Read one line"); - -static int -IO_creadline(PyObject *self, char **output) { - char *n, *s; - int l; - - UNLESS (IO__opencheck(IOOOBJECT(self))) return -1; - - for (n = ((IOobject*)self)->buf + ((IOobject*)self)->pos, - s = ((IOobject*)self)->buf + ((IOobject*)self)->string_size; - n < s && *n != '\n'; n++); - if (n < s) n++; - - *output=((IOobject*)self)->buf + ((IOobject*)self)->pos; - l = n - ((IOobject*)self)->buf - ((IOobject*)self)->pos; - ((IOobject*)self)->pos += l; - return l; -} - -static PyObject * -IO_readline(IOobject *self, PyObject *args) { - int n, m=-1; - char *output; - - if (args) - UNLESS (PyArg_ParseTuple(args, "|i:readline", &m)) return NULL; - - if( (n=IO_creadline((PyObject*)self,&output)) < 0) return NULL; - if (m >= 0 && m < n) { - m = n - m; - n -= m; - self->pos -= m; - } - return PyString_FromStringAndSize(output, n); -} - -PyDoc_STRVAR(IO_readlines__doc__, "readlines() -- Read all lines"); - -static PyObject * -IO_readlines(IOobject *self, PyObject *args) { - int n; - char *output; - PyObject *result, *line; - int hint = 0, length = 0; - - UNLESS (PyArg_ParseTuple(args, "|i:readlines", &hint)) return NULL; - - result = PyList_New(0); - if (!result) - return NULL; - - while (1){ - if ( (n = IO_creadline((PyObject*)self,&output)) < 0) - goto err; - if (n == 0) - break; - line = PyString_FromStringAndSize (output, n); - if (!line) - goto err; - PyList_Append (result, line); - Py_DECREF (line); - length += n; - if (hint > 0 && length >= hint) - break; - } - return result; - err: - Py_DECREF(result); - return NULL; -} - -PyDoc_STRVAR(IO_reset__doc__, -"reset() -- Reset the file position to the beginning"); - -static PyObject * -IO_reset(IOobject *self, PyObject *unused) { - - UNLESS (IO__opencheck(self)) return NULL; - - self->pos = 0; - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(IO_tell__doc__, "tell() -- get the current position."); - -static PyObject * -IO_tell(IOobject *self, PyObject *unused) { - - UNLESS (IO__opencheck(self)) return NULL; - - return PyInt_FromLong(self->pos); -} - -PyDoc_STRVAR(IO_truncate__doc__, -"truncate(): truncate the file at the current position."); - -static PyObject * -IO_truncate(IOobject *self, PyObject *args) { - int pos = -1; - - UNLESS (IO__opencheck(self)) return NULL; - UNLESS (PyArg_ParseTuple(args, "|i:truncate", &pos)) return NULL; - if (pos < 0) pos = self->pos; - - if (self->string_size > pos) self->string_size = pos; - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -IO_iternext(Iobject *self) -{ - PyObject *next; - next = IO_readline((IOobject *)self, NULL); - if (!next) - return NULL; - if (!PyString_GET_SIZE(next)) { - Py_DECREF(next); - PyErr_SetNone(PyExc_StopIteration); - return NULL; - } - return next; -} - - - - -/* Read-write object methods */ - -PyDoc_STRVAR(O_seek__doc__, -"seek(position) -- set the current position\n" -"seek(position, mode) -- mode 0: absolute; 1: relative; 2: relative to EOF"); - -static PyObject * -O_seek(Oobject *self, PyObject *args) { - int position, mode = 0; - - UNLESS (IO__opencheck(IOOOBJECT(self))) return NULL; - UNLESS (PyArg_ParseTuple(args, "i|i:seek", &position, &mode)) - return NULL; - - if (mode == 2) { - position += self->string_size; - } - else if (mode == 1) { - position += self->pos; - } - - if (position > self->buf_size) { - self->buf_size*=2; - if (self->buf_size <= position) self->buf_size=position+1; - UNLESS (self->buf=(char*) - realloc(self->buf,self->buf_size*sizeof(char))) { - self->buf_size=self->pos=0; - return PyErr_NoMemory(); - } - } - else if (position < 0) position=0; - - self->pos=position; - - while (--position >= self->string_size) self->buf[position]=0; - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(O_write__doc__, -"write(s) -- Write a string to the file" -"\n\nNote (hack:) writing None resets the buffer"); - - -static int -O_cwrite(PyObject *self, char *c, int l) { - int newl; - Oobject *oself; - - UNLESS (IO__opencheck(IOOOBJECT(self))) return -1; - oself = (Oobject *)self; - - newl = oself->pos+l; - if (newl >= oself->buf_size) { - oself->buf_size *= 2; - if (oself->buf_size <= newl) - oself->buf_size = newl+1; - UNLESS (oself->buf = - (char*)realloc(oself->buf, - (oself->buf_size) * sizeof(char))) { - PyErr_SetString(PyExc_MemoryError,"out of memory"); - oself->buf_size = oself->pos = 0; - return -1; - } - } - - memcpy(oself->buf+oself->pos,c,l); - - oself->pos += l; - - if (oself->string_size < oself->pos) { - oself->string_size = oself->pos; - } - - return l; -} - -static PyObject * -O_write(Oobject *self, PyObject *args) { - char *c; - int l; - - UNLESS (PyArg_ParseTuple(args, "t#:write", &c, &l)) return NULL; - - if (O_cwrite((PyObject*)self,c,l) < 0) return NULL; - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(O_close__doc__, "close(): explicitly release resources held."); - -static PyObject * -O_close(Oobject *self, PyObject *unused) { - if (self->buf != NULL) free(self->buf); - self->buf = NULL; - - self->pos = self->string_size = self->buf_size = 0; - - Py_INCREF(Py_None); - return Py_None; -} - - -PyDoc_STRVAR(O_writelines__doc__, -"writelines(sequence_of_strings): write each string"); -static PyObject * -O_writelines(Oobject *self, PyObject *args) { - PyObject *tmp = 0; - static PyObject *joiner = NULL; - - if (!joiner) { - PyObject *empty_string = PyString_FromString(""); - if (empty_string == NULL) - return NULL; - joiner = PyObject_GetAttrString(empty_string, "join"); - Py_DECREF(empty_string); - if (joiner == NULL) - return NULL; - } - - if (PyObject_Size(args) < 0) return NULL; - - tmp = PyObject_CallFunction(joiner, "O", args); - UNLESS (tmp) return NULL; - - args = Py_BuildValue("(O)", tmp); - Py_DECREF(tmp); - UNLESS (args) return NULL; - - tmp = O_write(self, args); - Py_DECREF(args); - return tmp; -} - -static struct PyMethodDef O_methods[] = { - /* Common methods: */ - {"flush", (PyCFunction)IO_flush, METH_NOARGS, IO_flush__doc__}, - {"getvalue", (PyCFunction)IO_getval, METH_VARARGS, IO_getval__doc__}, - {"isatty", (PyCFunction)IO_isatty, METH_NOARGS, IO_isatty__doc__}, - {"read", (PyCFunction)IO_read, METH_VARARGS, IO_read__doc__}, - {"readline", (PyCFunction)IO_readline, METH_VARARGS, IO_readline__doc__}, - {"readlines", (PyCFunction)IO_readlines,METH_VARARGS, IO_readlines__doc__}, - {"reset", (PyCFunction)IO_reset, METH_NOARGS, IO_reset__doc__}, - {"tell", (PyCFunction)IO_tell, METH_NOARGS, IO_tell__doc__}, - {"truncate", (PyCFunction)IO_truncate, METH_VARARGS, IO_truncate__doc__}, - - /* Read-write StringIO specific methods: */ - {"close", (PyCFunction)O_close, METH_NOARGS, O_close__doc__}, - {"seek", (PyCFunction)O_seek, METH_VARARGS, O_seek__doc__}, - {"write", (PyCFunction)O_write, METH_VARARGS, O_write__doc__}, - {"writelines", (PyCFunction)O_writelines, METH_O, O_writelines__doc__}, - {NULL, NULL} /* sentinel */ -}; - -static PyMemberDef O_memberlist[] = { - {"softspace", T_INT, offsetof(Oobject, softspace), 0, - "flag indicating that a space needs to be printed; used by print"}, - /* getattr(f, "closed") is implemented without this table */ - {NULL} /* Sentinel */ -}; - -static void -O_dealloc(Oobject *self) { - if (self->buf != NULL) - free(self->buf); - PyObject_Del(self); -} - -PyDoc_STRVAR(Otype__doc__, "Simple type for output to strings."); - -static PyTypeObject Otype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "cStringIO.StringO", /*tp_name*/ - sizeof(Oobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)O_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - 0, /*tp_getattr */ - 0, /*tp_setattr */ - (cmpfunc)0, /*tp_compare*/ - (reprfunc)0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)0, /*tp_str*/ - 0, /*tp_getattro */ - 0, /*tp_setattro */ - 0, /*tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - Otype__doc__, /*tp_doc */ - 0, /*tp_traverse */ - 0, /*tp_clear */ - 0, /*tp_richcompare */ - 0, /*tp_weaklistoffset */ - PyObject_SelfIter, /*tp_iter */ - (iternextfunc)IO_iternext, /*tp_iternext */ - O_methods, /*tp_methods */ - O_memberlist, /*tp_members */ - file_getsetlist, /*tp_getset */ -}; - -static PyObject * -newOobject(int size) { - Oobject *self; - - self = PyObject_New(Oobject, &Otype); - if (self == NULL) - return NULL; - self->pos=0; - self->string_size = 0; - self->softspace = 0; - - UNLESS (self->buf=malloc(size*sizeof(char))) { - PyErr_SetString(PyExc_MemoryError,"out of memory"); - self->buf_size = 0; - return NULL; - } - - self->buf_size=size; - return (PyObject*)self; -} - -/* End of code for StringO objects */ -/* -------------------------------------------------------- */ - -static PyObject * -I_close(Iobject *self, PyObject *unused) { - Py_XDECREF(self->pbuf); - self->pbuf = NULL; - self->buf = NULL; - - self->pos = self->string_size = 0; - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -I_seek(Iobject *self, PyObject *args) { - int position, mode = 0; - - UNLESS (IO__opencheck(IOOOBJECT(self))) return NULL; - UNLESS (PyArg_ParseTuple(args, "i|i:seek", &position, &mode)) - return NULL; - - if (mode == 2) position += self->string_size; - else if (mode == 1) position += self->pos; - - if (position < 0) position=0; - - self->pos=position; - - Py_INCREF(Py_None); - return Py_None; -} - -static struct PyMethodDef I_methods[] = { - /* Common methods: */ - {"flush", (PyCFunction)IO_flush, METH_NOARGS, IO_flush__doc__}, - {"getvalue", (PyCFunction)IO_getval, METH_VARARGS, IO_getval__doc__}, - {"isatty", (PyCFunction)IO_isatty, METH_NOARGS, IO_isatty__doc__}, - {"read", (PyCFunction)IO_read, METH_VARARGS, IO_read__doc__}, - {"readline", (PyCFunction)IO_readline, METH_VARARGS, IO_readline__doc__}, - {"readlines", (PyCFunction)IO_readlines,METH_VARARGS, IO_readlines__doc__}, - {"reset", (PyCFunction)IO_reset, METH_NOARGS, IO_reset__doc__}, - {"tell", (PyCFunction)IO_tell, METH_NOARGS, IO_tell__doc__}, - {"truncate", (PyCFunction)IO_truncate, METH_VARARGS, IO_truncate__doc__}, - - /* Read-only StringIO specific methods: */ - {"close", (PyCFunction)I_close, METH_NOARGS, O_close__doc__}, - {"seek", (PyCFunction)I_seek, METH_VARARGS, O_seek__doc__}, - {NULL, NULL} -}; - -static void -I_dealloc(Iobject *self) { - Py_XDECREF(self->pbuf); - PyObject_Del(self); -} - - -PyDoc_STRVAR(Itype__doc__, -"Simple type for treating strings as input file streams"); - -static PyTypeObject Itype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "cStringIO.StringI", /*tp_name*/ - sizeof(Iobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)I_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - 0, /* tp_getattr */ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ - (reprfunc)0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)0, /*tp_str*/ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - Itype__doc__, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)IO_iternext, /* tp_iternext */ - I_methods, /* tp_methods */ - 0, /* tp_members */ - file_getsetlist, /* tp_getset */ -}; - -static PyObject * -newIobject(PyObject *s) { - Iobject *self; - char *buf; - int size; - - if (PyObject_AsReadBuffer(s, (const void **)&buf, &size)) { - PyErr_Format(PyExc_TypeError, "expected read buffer, %.200s found", - s->ob_type->tp_name); - return NULL; - } - UNLESS (self = PyObject_New(Iobject, &Itype)) return NULL; - Py_INCREF(s); - self->buf=buf; - self->string_size=size; - self->pbuf=s; - self->pos=0; - - return (PyObject*)self; -} - -/* End of code for StringI objects */ -/* -------------------------------------------------------- */ - - -PyDoc_STRVAR(IO_StringIO__doc__, -"StringIO([s]) -- Return a StringIO-like stream for reading or writing"); - -static PyObject * -IO_StringIO(PyObject *self, PyObject *args) { - PyObject *s=0; - - if (!PyArg_UnpackTuple(args, "StringIO", 0, 1, &s)) return NULL; - - if (s) return newIobject(s); - return newOobject(128); -} - -/* List of methods defined in the module */ - -static struct PyMethodDef IO_methods[] = { - {"StringIO", (PyCFunction)IO_StringIO, - METH_VARARGS, IO_StringIO__doc__}, - {NULL, NULL} /* sentinel */ -}; - - -/* Initialization function for the module (*must* be called initcStringIO) */ - -static struct PycStringIO_CAPI CAPI = { - IO_cread, - IO_creadline, - O_cwrite, - IO_cgetval, - newOobject, - newIobject, - &Itype, - &Otype, -}; - -#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */ -#define PyMODINIT_FUNC void -#endif -PyMODINIT_FUNC -initcStringIO(void) { - PyObject *m, *d, *v; - - - /* Create the module and add the functions */ - m = Py_InitModule4("cStringIO", IO_methods, - cStringIO_module_documentation, - (PyObject*)NULL,PYTHON_API_VERSION); - - /* Add some symbolic constants to the module */ - d = PyModule_GetDict(m); - - /* Export C API */ - Itype.ob_type=&PyType_Type; - Otype.ob_type=&PyType_Type; - if (PyType_Ready(&Otype) < 0) return; - if (PyType_Ready(&Itype) < 0) return; - PyDict_SetItemString(d,"cStringIO_CAPI", - v = PyCObject_FromVoidPtr(&CAPI,NULL)); - Py_XDECREF(v); - - /* Export Types */ - PyDict_SetItemString(d,"InputType", (PyObject*)&Itype); - PyDict_SetItemString(d,"OutputType", (PyObject*)&Otype); - - /* Maybe make certain warnings go away */ - if (0) PycString_IMPORT; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/ccpython.cc b/SDKs/XPlatform/Cypython-2.3.3/Modules/ccpython.cc deleted file mode 100644 index 6f5fb159..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/ccpython.cc +++ /dev/null @@ -1,11 +0,0 @@ -/* Minimal main program -- everything is loaded from the library */ - -#include "Python.h" - -extern "C" -DL_EXPORT(int) Py_Main( int argc, char *argv[] ); - -int main( int argc, char *argv[] ) -{ - return Py_Main(argc, argv); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/cdmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/cdmodule.c deleted file mode 100644 index a39f92ae..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/cdmodule.c +++ /dev/null @@ -1,794 +0,0 @@ -/* CD module -- interface to Mark Callow's and Roger Chickering's */ - /* CD Audio Library (CD). */ - -#include -#include -#include "Python.h" - -#define NCALLBACKS 8 - -typedef struct { - PyObject_HEAD - CDPLAYER *ob_cdplayer; -} cdplayerobject; - -static PyObject *CdError; /* exception cd.error */ - -static PyObject * -CD_allowremoval(cdplayerobject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":allowremoval")) - return NULL; - - CDallowremoval(self->ob_cdplayer); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -CD_preventremoval(cdplayerobject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":preventremoval")) - return NULL; - - CDpreventremoval(self->ob_cdplayer); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -CD_bestreadsize(cdplayerobject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":bestreadsize")) - return NULL; - - return PyInt_FromLong((long) CDbestreadsize(self->ob_cdplayer)); -} - -static PyObject * -CD_close(cdplayerobject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":close")) - return NULL; - - if (!CDclose(self->ob_cdplayer)) { - PyErr_SetFromErrno(CdError); /* XXX - ??? */ - return NULL; - } - self->ob_cdplayer = NULL; - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -CD_eject(cdplayerobject *self, PyObject *args) -{ - CDSTATUS status; - - if (!PyArg_ParseTuple(args, ":eject")) - return NULL; - - if (!CDeject(self->ob_cdplayer)) { - if (CDgetstatus(self->ob_cdplayer, &status) && - status.state == CD_NODISC) - PyErr_SetString(CdError, "no disc in player"); - else - PyErr_SetString(CdError, "eject failed"); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -CD_getstatus(cdplayerobject *self, PyObject *args) -{ - CDSTATUS status; - - if (!PyArg_ParseTuple(args, ":getstatus")) - return NULL; - - if (!CDgetstatus(self->ob_cdplayer, &status)) { - PyErr_SetFromErrno(CdError); /* XXX - ??? */ - return NULL; - } - - return Py_BuildValue("(ii(iii)(iii)(iii)iiii)", status.state, - status.track, status.min, status.sec, status.frame, - status.abs_min, status.abs_sec, status.abs_frame, - status.total_min, status.total_sec, status.total_frame, - status.first, status.last, status.scsi_audio, - status.cur_block); -} - -static PyObject * -CD_gettrackinfo(cdplayerobject *self, PyObject *args) -{ - int track; - CDTRACKINFO info; - CDSTATUS status; - - if (!PyArg_ParseTuple(args, "i:gettrackinfo", &track)) - return NULL; - - if (!CDgettrackinfo(self->ob_cdplayer, track, &info)) { - if (CDgetstatus(self->ob_cdplayer, &status) && - status.state == CD_NODISC) - PyErr_SetString(CdError, "no disc in player"); - else - PyErr_SetString(CdError, "gettrackinfo failed"); - return NULL; - } - - return Py_BuildValue("((iii)(iii))", - info.start_min, info.start_sec, info.start_frame, - info.total_min, info.total_sec, info.total_frame); -} - -static PyObject * -CD_msftoblock(cdplayerobject *self, PyObject *args) -{ - int min, sec, frame; - - if (!PyArg_ParseTuple(args, "iii:msftoblock", &min, &sec, &frame)) - return NULL; - - return PyInt_FromLong((long) CDmsftoblock(self->ob_cdplayer, - min, sec, frame)); -} - -static PyObject * -CD_play(cdplayerobject *self, PyObject *args) -{ - int start, play; - CDSTATUS status; - - if (!PyArg_ParseTuple(args, "ii:play", &start, &play)) - return NULL; - - if (!CDplay(self->ob_cdplayer, start, play)) { - if (CDgetstatus(self->ob_cdplayer, &status) && - status.state == CD_NODISC) - PyErr_SetString(CdError, "no disc in player"); - else - PyErr_SetString(CdError, "play failed"); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -CD_playabs(cdplayerobject *self, PyObject *args) -{ - int min, sec, frame, play; - CDSTATUS status; - - if (!PyArg_ParseTuple(args, "iiii:playabs", &min, &sec, &frame, &play)) - return NULL; - - if (!CDplayabs(self->ob_cdplayer, min, sec, frame, play)) { - if (CDgetstatus(self->ob_cdplayer, &status) && - status.state == CD_NODISC) - PyErr_SetString(CdError, "no disc in player"); - else - PyErr_SetString(CdError, "playabs failed"); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -CD_playtrack(cdplayerobject *self, PyObject *args) -{ - int start, play; - CDSTATUS status; - - if (!PyArg_ParseTuple(args, "ii:playtrack", &start, &play)) - return NULL; - - if (!CDplaytrack(self->ob_cdplayer, start, play)) { - if (CDgetstatus(self->ob_cdplayer, &status) && - status.state == CD_NODISC) - PyErr_SetString(CdError, "no disc in player"); - else - PyErr_SetString(CdError, "playtrack failed"); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -CD_playtrackabs(cdplayerobject *self, PyObject *args) -{ - int track, min, sec, frame, play; - CDSTATUS status; - - if (!PyArg_ParseTuple(args, "iiiii:playtrackabs", &track, &min, &sec, - &frame, &play)) - return NULL; - - if (!CDplaytrackabs(self->ob_cdplayer, track, min, sec, frame, play)) { - if (CDgetstatus(self->ob_cdplayer, &status) && - status.state == CD_NODISC) - PyErr_SetString(CdError, "no disc in player"); - else - PyErr_SetString(CdError, "playtrackabs failed"); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -CD_readda(cdplayerobject *self, PyObject *args) -{ - int numframes, n; - PyObject *result; - - if (!PyArg_ParseTuple(args, "i:readda", &numframes)) - return NULL; - - result = PyString_FromStringAndSize(NULL, numframes * sizeof(CDFRAME)); - if (result == NULL) - return NULL; - - n = CDreadda(self->ob_cdplayer, - (CDFRAME *) PyString_AsString(result), numframes); - if (n == -1) { - Py_DECREF(result); - PyErr_SetFromErrno(CdError); - return NULL; - } - if (n < numframes) - _PyString_Resize(&result, n * sizeof(CDFRAME)); - - return result; -} - -static PyObject * -CD_seek(cdplayerobject *self, PyObject *args) -{ - int min, sec, frame; - long PyTryBlock; - - if (!PyArg_ParseTuple(args, "iii:seek", &min, &sec, &frame)) - return NULL; - - PyTryBlock = CDseek(self->ob_cdplayer, min, sec, frame); - if (PyTryBlock == -1) { - PyErr_SetFromErrno(CdError); - return NULL; - } - - return PyInt_FromLong(PyTryBlock); -} - -static PyObject * -CD_seektrack(cdplayerobject *self, PyObject *args) -{ - int track; - long PyTryBlock; - - if (!PyArg_ParseTuple(args, "i:seektrack", &track)) - return NULL; - - PyTryBlock = CDseektrack(self->ob_cdplayer, track); - if (PyTryBlock == -1) { - PyErr_SetFromErrno(CdError); - return NULL; - } - - return PyInt_FromLong(PyTryBlock); -} - -static PyObject * -CD_seekblock(cdplayerobject *self, PyObject *args) -{ - unsigned long PyTryBlock; - - if (!PyArg_ParseTuple(args, "l:seekblock", &PyTryBlock)) - return NULL; - - PyTryBlock = CDseekblock(self->ob_cdplayer, PyTryBlock); - if (PyTryBlock == (unsigned long) -1) { - PyErr_SetFromErrno(CdError); - return NULL; - } - - return PyInt_FromLong(PyTryBlock); -} - -static PyObject * -CD_stop(cdplayerobject *self, PyObject *args) -{ - CDSTATUS status; - - if (!PyArg_ParseTuple(args, ":stop")) - return NULL; - - if (!CDstop(self->ob_cdplayer)) { - if (CDgetstatus(self->ob_cdplayer, &status) && - status.state == CD_NODISC) - PyErr_SetString(CdError, "no disc in player"); - else - PyErr_SetString(CdError, "stop failed"); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -CD_togglepause(cdplayerobject *self, PyObject *args) -{ - CDSTATUS status; - - if (!PyArg_ParseTuple(args, ":togglepause")) - return NULL; - - if (!CDtogglepause(self->ob_cdplayer)) { - if (CDgetstatus(self->ob_cdplayer, &status) && - status.state == CD_NODISC) - PyErr_SetString(CdError, "no disc in player"); - else - PyErr_SetString(CdError, "togglepause failed"); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -static PyMethodDef cdplayer_methods[] = { - {"allowremoval", (PyCFunction)CD_allowremoval, METH_VARARGS}, - {"bestreadsize", (PyCFunction)CD_bestreadsize, METH_VARARGS}, - {"close", (PyCFunction)CD_close, METH_VARARGS}, - {"eject", (PyCFunction)CD_eject, METH_VARARGS}, - {"getstatus", (PyCFunction)CD_getstatus, METH_VARARGS}, - {"gettrackinfo", (PyCFunction)CD_gettrackinfo, METH_VARARGS}, - {"msftoblock", (PyCFunction)CD_msftoblock, METH_VARARGS}, - {"play", (PyCFunction)CD_play, METH_VARARGS}, - {"playabs", (PyCFunction)CD_playabs, METH_VARARGS}, - {"playtrack", (PyCFunction)CD_playtrack, METH_VARARGS}, - {"playtrackabs", (PyCFunction)CD_playtrackabs, METH_VARARGS}, - {"preventremoval", (PyCFunction)CD_preventremoval, METH_VARARGS}, - {"readda", (PyCFunction)CD_readda, METH_VARARGS}, - {"seek", (PyCFunction)CD_seek, METH_VARARGS}, - {"seekblock", (PyCFunction)CD_seekblock, METH_VARARGS}, - {"seektrack", (PyCFunction)CD_seektrack, METH_VARARGS}, - {"stop", (PyCFunction)CD_stop, METH_VARARGS}, - {"togglepause", (PyCFunction)CD_togglepause, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - -static void -cdplayer_dealloc(cdplayerobject *self) -{ - if (self->ob_cdplayer != NULL) - CDclose(self->ob_cdplayer); - PyObject_Del(self); -} - -static PyObject * -cdplayer_getattr(cdplayerobject *self, char *name) -{ - if (self->ob_cdplayer == NULL) { - PyErr_SetString(PyExc_RuntimeError, "no player active"); - return NULL; - } - return Py_FindMethod(cdplayer_methods, (PyObject *)self, name); -} - -PyTypeObject CdPlayertype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "cd.cdplayer", /*tp_name*/ - sizeof(cdplayerobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)cdplayer_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)cdplayer_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ -}; - -static PyObject * -newcdplayerobject(CDPLAYER *cdp) -{ - cdplayerobject *p; - - p = PyObject_New(cdplayerobject, &CdPlayertype); - if (p == NULL) - return NULL; - p->ob_cdplayer = cdp; - return (PyObject *) p; -} - -static PyObject * -CD_open(PyObject *self, PyObject *args) -{ - char *dev, *direction; - CDPLAYER *cdp; - - /* - * Variable number of args. - * First defaults to "None", second defaults to "r". - */ - dev = NULL; - direction = "r"; - if (!PyArg_ParseTuple(args, "|zs:open", &dev, &direction)) - return NULL; - - cdp = CDopen(dev, direction); - if (cdp == NULL) { - PyErr_SetFromErrno(CdError); - return NULL; - } - - return newcdplayerobject(cdp); -} - -typedef struct { - PyObject_HEAD - CDPARSER *ob_cdparser; - struct { - PyObject *ob_cdcallback; - PyObject *ob_cdcallbackarg; - } ob_cdcallbacks[NCALLBACKS]; -} cdparserobject; - -static void -CD_callback(void *arg, CDDATATYPES type, void *data) -{ - PyObject *result, *args, *v = NULL; - char *p; - int i; - cdparserobject *self; - - self = (cdparserobject *) arg; - args = PyTuple_New(3); - if (args == NULL) - return; - Py_INCREF(self->ob_cdcallbacks[type].ob_cdcallbackarg); - PyTuple_SetItem(args, 0, self->ob_cdcallbacks[type].ob_cdcallbackarg); - PyTuple_SetItem(args, 1, PyInt_FromLong((long) type)); - switch (type) { - case cd_audio: - v = PyString_FromStringAndSize(data, CDDA_DATASIZE); - break; - case cd_pnum: - case cd_index: - v = PyInt_FromLong(((CDPROGNUM *) data)->value); - break; - case cd_ptime: - case cd_atime: -#define ptr ((struct cdtimecode *) data) - v = Py_BuildValue("(iii)", - ptr->mhi * 10 + ptr->mlo, - ptr->shi * 10 + ptr->slo, - ptr->fhi * 10 + ptr->flo); -#undef ptr - break; - case cd_catalog: - v = PyString_FromStringAndSize(NULL, 13); - p = PyString_AsString(v); - for (i = 0; i < 13; i++) - *p++ = ((char *) data)[i] + '0'; - break; - case cd_ident: -#define ptr ((struct cdident *) data) - v = PyString_FromStringAndSize(NULL, 12); - p = PyString_AsString(v); - CDsbtoa(p, ptr->country, 2); - p += 2; - CDsbtoa(p, ptr->owner, 3); - p += 3; - *p++ = ptr->year[0] + '0'; - *p++ = ptr->year[1] + '0'; - *p++ = ptr->serial[0] + '0'; - *p++ = ptr->serial[1] + '0'; - *p++ = ptr->serial[2] + '0'; - *p++ = ptr->serial[3] + '0'; - *p++ = ptr->serial[4] + '0'; -#undef ptr - break; - case cd_control: - v = PyInt_FromLong((long) *((unchar *) data)); - break; - } - PyTuple_SetItem(args, 2, v); - if (PyErr_Occurred()) { - Py_DECREF(args); - return; - } - - result = PyEval_CallObject(self->ob_cdcallbacks[type].ob_cdcallback, - args); - Py_DECREF(args); - Py_XDECREF(result); -} - -static PyObject * -CD_deleteparser(cdparserobject *self, PyObject *args) -{ - int i; - - if (!PyArg_ParseTuple(args, ":deleteparser")) - return NULL; - - CDdeleteparser(self->ob_cdparser); - self->ob_cdparser = NULL; - - /* no sense in keeping the callbacks, so remove them */ - for (i = 0; i < NCALLBACKS; i++) { - Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallback); - self->ob_cdcallbacks[i].ob_cdcallback = NULL; - Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallbackarg); - self->ob_cdcallbacks[i].ob_cdcallbackarg = NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -CD_parseframe(cdparserobject *self, PyObject *args) -{ - char *cdfp; - int length; - CDFRAME *p; - - if (!PyArg_ParseTuple(args, "s#:parseframe", &cdfp, &length)) - return NULL; - - if (length % sizeof(CDFRAME) != 0) { - PyErr_SetString(PyExc_TypeError, "bad length"); - return NULL; - } - - p = (CDFRAME *) cdfp; - while (length > 0) { - CDparseframe(self->ob_cdparser, p); - length -= sizeof(CDFRAME); - p++; - if (PyErr_Occurred()) - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -CD_removecallback(cdparserobject *self, PyObject *args) -{ - int type; - - if (!PyArg_ParseTuple(args, "i:removecallback", &type)) - return NULL; - - if (type < 0 || type >= NCALLBACKS) { - PyErr_SetString(PyExc_TypeError, "bad type"); - return NULL; - } - - CDremovecallback(self->ob_cdparser, (CDDATATYPES) type); - - Py_XDECREF(self->ob_cdcallbacks[type].ob_cdcallback); - self->ob_cdcallbacks[type].ob_cdcallback = NULL; - - Py_XDECREF(self->ob_cdcallbacks[type].ob_cdcallbackarg); - self->ob_cdcallbacks[type].ob_cdcallbackarg = NULL; - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -CD_resetparser(cdparserobject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":resetparser")) - return NULL; - - CDresetparser(self->ob_cdparser); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -CD_addcallback(cdparserobject *self, PyObject *args) -{ - int type; - PyObject *func, *funcarg; - - /* XXX - more work here */ - if (!PyArg_ParseTuple(args, "iOO:addcallback", &type, &func, &funcarg)) - return NULL; - - if (type < 0 || type >= NCALLBACKS) { - PyErr_SetString(PyExc_TypeError, "argument out of range"); - return NULL; - } - -#ifdef CDsetcallback - CDaddcallback(self->ob_cdparser, (CDDATATYPES) type, CD_callback, - (void *) self); -#else - CDsetcallback(self->ob_cdparser, (CDDATATYPES) type, CD_callback, - (void *) self); -#endif - Py_XDECREF(self->ob_cdcallbacks[type].ob_cdcallback); - Py_INCREF(func); - self->ob_cdcallbacks[type].ob_cdcallback = func; - Py_XDECREF(self->ob_cdcallbacks[type].ob_cdcallbackarg); - Py_INCREF(funcarg); - self->ob_cdcallbacks[type].ob_cdcallbackarg = funcarg; - -/* - if (type == cd_audio) { - sigfpe_[_UNDERFL].repls = _ZERO; - handle_sigfpes(_ON, _EN_UNDERFL, NULL, - _ABORT_ON_ERROR, NULL); - } -*/ - - Py_INCREF(Py_None); - return Py_None; -} - -static PyMethodDef cdparser_methods[] = { - {"addcallback", (PyCFunction)CD_addcallback, METH_VARARGS}, - {"deleteparser", (PyCFunction)CD_deleteparser, METH_VARARGS}, - {"parseframe", (PyCFunction)CD_parseframe, METH_VARARGS}, - {"removecallback", (PyCFunction)CD_removecallback, METH_VARARGS}, - {"resetparser", (PyCFunction)CD_resetparser, METH_VARARGS}, - /* backward compatibility */ - {"setcallback", (PyCFunction)CD_addcallback, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - -static void -cdparser_dealloc(cdparserobject *self) -{ - int i; - - for (i = 0; i < NCALLBACKS; i++) { - Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallback); - self->ob_cdcallbacks[i].ob_cdcallback = NULL; - Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallbackarg); - self->ob_cdcallbacks[i].ob_cdcallbackarg = NULL; - } - CDdeleteparser(self->ob_cdparser); - PyObject_Del(self); -} - -static PyObject * -cdparser_getattr(cdparserobject *self, char *name) -{ - if (self->ob_cdparser == NULL) { - PyErr_SetString(PyExc_RuntimeError, "no parser active"); - return NULL; - } - - return Py_FindMethod(cdparser_methods, (PyObject *)self, name); -} - -PyTypeObject CdParsertype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "cd.cdparser", /*tp_name*/ - sizeof(cdparserobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)cdparser_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)cdparser_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ -}; - -static PyObject * -newcdparserobject(CDPARSER *cdp) -{ - cdparserobject *p; - int i; - - p = PyObject_New(cdparserobject, &CdParsertype); - if (p == NULL) - return NULL; - p->ob_cdparser = cdp; - for (i = 0; i < NCALLBACKS; i++) { - p->ob_cdcallbacks[i].ob_cdcallback = NULL; - p->ob_cdcallbacks[i].ob_cdcallbackarg = NULL; - } - return (PyObject *) p; -} - -static PyObject * -CD_createparser(PyObject *self, PyObject *args) -{ - CDPARSER *cdp; - - if (!PyArg_ParseTuple(args, ":createparser")) - return NULL; - cdp = CDcreateparser(); - if (cdp == NULL) { - PyErr_SetString(CdError, "createparser failed"); - return NULL; - } - - return newcdparserobject(cdp); -} - -static PyObject * -CD_msftoframe(PyObject *self, PyObject *args) -{ - int min, sec, frame; - - if (!PyArg_ParseTuple(args, "iii:msftoframe", &min, &sec, &frame)) - return NULL; - - return PyInt_FromLong((long) CDmsftoframe(min, sec, frame)); -} - -static PyMethodDef CD_methods[] = { - {"open", (PyCFunction)CD_open, METH_VARARGS}, - {"createparser", (PyCFunction)CD_createparser, METH_VARARGS}, - {"msftoframe", (PyCFunction)CD_msftoframe, METH_VARARGS}, - {NULL, NULL} /* Sentinel */ -}; - -void -initcd(void) -{ - PyObject *m, *d; - - m = Py_InitModule("cd", CD_methods); - d = PyModule_GetDict(m); - - CdError = PyErr_NewException("cd.error", NULL, NULL); - PyDict_SetItemString(d, "error", CdError); - - /* Identifiers for the different types of callbacks from the parser */ - PyDict_SetItemString(d, "audio", PyInt_FromLong((long) cd_audio)); - PyDict_SetItemString(d, "pnum", PyInt_FromLong((long) cd_pnum)); - PyDict_SetItemString(d, "index", PyInt_FromLong((long) cd_index)); - PyDict_SetItemString(d, "ptime", PyInt_FromLong((long) cd_ptime)); - PyDict_SetItemString(d, "atime", PyInt_FromLong((long) cd_atime)); - PyDict_SetItemString(d, "catalog", PyInt_FromLong((long) cd_catalog)); - PyDict_SetItemString(d, "ident", PyInt_FromLong((long) cd_ident)); - PyDict_SetItemString(d, "control", PyInt_FromLong((long) cd_control)); - - /* Block size information for digital audio data */ - PyDict_SetItemString(d, "DATASIZE", - PyInt_FromLong((long) CDDA_DATASIZE)); - PyDict_SetItemString(d, "BLOCKSIZE", - PyInt_FromLong((long) CDDA_BLOCKSIZE)); - - /* Possible states for the cd player */ - PyDict_SetItemString(d, "ERROR", PyInt_FromLong((long) CD_ERROR)); - PyDict_SetItemString(d, "NODISC", PyInt_FromLong((long) CD_NODISC)); - PyDict_SetItemString(d, "READY", PyInt_FromLong((long) CD_READY)); - PyDict_SetItemString(d, "PLAYING", PyInt_FromLong((long) CD_PLAYING)); - PyDict_SetItemString(d, "PAUSED", PyInt_FromLong((long) CD_PAUSED)); - PyDict_SetItemString(d, "STILL", PyInt_FromLong((long) CD_STILL)); -#ifdef CD_CDROM /* only newer versions of the library */ - PyDict_SetItemString(d, "CDROM", PyInt_FromLong((long) CD_CDROM)); -#endif -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/cgen.py b/SDKs/XPlatform/Cypython-2.3.3/Modules/cgen.py deleted file mode 100644 index 5ec01535..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/cgen.py +++ /dev/null @@ -1,520 +0,0 @@ -######################################################################## -# Copyright (c) 2000, BeOpen.com. -# Copyright (c) 1995-2000, Corporation for National Research Initiatives. -# Copyright (c) 1990-1995, Stichting Mathematisch Centrum. -# All rights reserved. -# -# See the file "Misc/COPYRIGHT" for information on usage and -# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. -######################################################################## - -# Python script to parse cstubs file for gl and generate C stubs. -# usage: python cgen.py glmodule.c -# -# NOTE: You must first make a python binary without the "GL" option -# before you can run this, when building Python for the first time. -# See comments in the Makefile. -# -# XXX BUG return arrays generate wrong code -# XXX need to change error returns into gotos to free mallocked arrays - - -import string -import sys - - -# Function to print to stderr -# -def err(*args): - savestdout = sys.stdout - try: - sys.stdout = sys.stderr - for i in args: - print i, - print - finally: - sys.stdout = savestdout - - -# The set of digits that form a number -# -digits = '0123456789' - - -# Function to extract a string of digits from the front of the string. -# Returns the leading string of digits and the remaining string. -# If no number is found, returns '' and the original string. -# -def getnum(s): - n = '' - while s and s[0] in digits: - n = n + s[0] - s = s[1:] - return n, s - - -# Function to check if a string is a number -# -def isnum(s): - if not s: return False - for c in s: - if not c in digits: return False - return True - - -# Allowed function return types -# -return_types = ['void', 'short', 'long'] - - -# Allowed function argument types -# -arg_types = ['char', 'string', 'short', 'u_short', 'float', 'long', 'double'] - - -# Need to classify arguments as follows -# simple input variable -# simple output variable -# input array -# output array -# input giving size of some array -# -# Array dimensions can be specified as follows -# constant -# argN -# constant * argN -# retval -# constant * retval -# -# The dimensions given as constants * something are really -# arrays of points where points are 2- 3- or 4-tuples -# -# We have to consider three lists: -# python input arguments -# C stub arguments (in & out) -# python output arguments (really return values) -# -# There is a mapping from python input arguments to the input arguments -# of the C stub, and a further mapping from C stub arguments to the -# python return values - - -# Exception raised by checkarg() and generate() -# -arg_error = 'bad arg' - - -# Function to check one argument. -# Arguments: the type and the arg "name" (really mode plus subscript). -# Raises arg_error if something's wrong. -# Return type, mode, factor, rest of subscript; factor and rest may be empty. -# -def checkarg(type, arg): - # - # Turn "char *x" into "string x". - # - if type == 'char' and arg[0] == '*': - type = 'string' - arg = arg[1:] - # - # Check that the type is supported. - # - if type not in arg_types: - raise arg_error, ('bad type', type) - if type[:2] == 'u_': - type = 'unsigned ' + type[2:] - # - # Split it in the mode (first character) and the rest. - # - mode, rest = arg[:1], arg[1:] - # - # The mode must be 's' for send (= input) or 'r' for return argument. - # - if mode not in ('r', 's'): - raise arg_error, ('bad arg mode', mode) - # - # Is it a simple argument: if so, we are done. - # - if not rest: - return type, mode, '', '' - # - # Not a simple argument; must be an array. - # The 'rest' must be a subscript enclosed in [ and ]. - # The subscript must be one of the following forms, - # otherwise we don't handle it (where N is a number): - # N - # argN - # retval - # N*argN - # N*retval - # - if rest[:1] <> '[' or rest[-1:] <> ']': - raise arg_error, ('subscript expected', rest) - sub = rest[1:-1] - # - # Is there a leading number? - # - num, sub = getnum(sub) - if num: - # There is a leading number - if not sub: - # The subscript is just a number - return type, mode, num, '' - if sub[:1] == '*': - # There is a factor prefix - sub = sub[1:] - else: - raise arg_error, ('\'*\' expected', sub) - if sub == 'retval': - # size is retval -- must be a reply argument - if mode <> 'r': - raise arg_error, ('non-r mode with [retval]', mode) - elif not isnum(sub) and (sub[:3] <> 'arg' or not isnum(sub[3:])): - raise arg_error, ('bad subscript', sub) - # - return type, mode, num, sub - - -# List of functions for which we have generated stubs -# -functions = [] - - -# Generate the stub for the given function, using the database of argument -# information build by successive calls to checkarg() -# -def generate(type, func, database): - # - # Check that we can handle this case: - # no variable size reply arrays yet - # - n_in_args = 0 - n_out_args = 0 - # - for a_type, a_mode, a_factor, a_sub in database: - if a_mode == 's': - n_in_args = n_in_args + 1 - elif a_mode == 'r': - n_out_args = n_out_args + 1 - else: - # Can't happen - raise arg_error, ('bad a_mode', a_mode) - if (a_mode == 'r' and a_sub) or a_sub == 'retval': - err('Function', func, 'too complicated:', - a_type, a_mode, a_factor, a_sub) - print '/* XXX Too complicated to generate code for */' - return - # - functions.append(func) - # - # Stub header - # - print - print 'static PyObject *' - print 'gl_' + func + '(self, args)' - print '\tPyObject *self;' - print '\tPyObject *args;' - print '{' - # - # Declare return value if any - # - if type <> 'void': - print '\t' + type, 'retval;' - # - # Declare arguments - # - for i in range(len(database)): - a_type, a_mode, a_factor, a_sub = database[i] - print '\t' + a_type, - brac = ket = '' - if a_sub and not isnum(a_sub): - if a_factor: - brac = '(' - ket = ')' - print brac + '*', - print 'arg' + `i+1` + ket, - if a_sub and isnum(a_sub): - print '[', a_sub, ']', - if a_factor: - print '[', a_factor, ']', - print ';' - # - # Find input arguments derived from array sizes - # - for i in range(len(database)): - a_type, a_mode, a_factor, a_sub = database[i] - if a_mode == 's' and a_sub[:3] == 'arg' and isnum(a_sub[3:]): - # Sending a variable-length array - n = eval(a_sub[3:]) - if 1 <= n <= len(database): - b_type, b_mode, b_factor, b_sub = database[n-1] - if b_mode == 's': - database[n-1] = b_type, 'i', a_factor, `i` - n_in_args = n_in_args - 1 - # - # Assign argument positions in the Python argument list - # - in_pos = [] - i_in = 0 - for i in range(len(database)): - a_type, a_mode, a_factor, a_sub = database[i] - if a_mode == 's': - in_pos.append(i_in) - i_in = i_in + 1 - else: - in_pos.append(-1) - # - # Get input arguments - # - for i in range(len(database)): - a_type, a_mode, a_factor, a_sub = database[i] - if a_type[:9] == 'unsigned ': - xtype = a_type[9:] - else: - xtype = a_type - if a_mode == 'i': - # - # Implicit argument; - # a_factor is divisor if present, - # a_sub indicates which arg (`database index`) - # - j = eval(a_sub) - print '\tif', - print '(!geti' + xtype + 'arraysize(args,', - print `n_in_args` + ',', - print `in_pos[j]` + ',', - if xtype <> a_type: - print '('+xtype+' *)', - print '&arg' + `i+1` + '))' - print '\t\treturn NULL;' - if a_factor: - print '\targ' + `i+1`, - print '= arg' + `i+1`, - print '/', a_factor + ';' - elif a_mode == 's': - if a_sub and not isnum(a_sub): - # Allocate memory for varsize array - print '\tif ((arg' + `i+1`, '=', - if a_factor: - print '('+a_type+'(*)['+a_factor+'])', - print 'PyMem_NEW(' + a_type, ',', - if a_factor: - print a_factor, '*', - print a_sub, ')) == NULL)' - print '\t\treturn PyErr_NoMemory();' - print '\tif', - if a_factor or a_sub: # Get a fixed-size array array - print '(!geti' + xtype + 'array(args,', - print `n_in_args` + ',', - print `in_pos[i]` + ',', - if a_factor: print a_factor, - if a_factor and a_sub: print '*', - if a_sub: print a_sub, - print ',', - if (a_sub and a_factor) or xtype <> a_type: - print '('+xtype+' *)', - print 'arg' + `i+1` + '))' - else: # Get a simple variable - print '(!geti' + xtype + 'arg(args,', - print `n_in_args` + ',', - print `in_pos[i]` + ',', - if xtype <> a_type: - print '('+xtype+' *)', - print '&arg' + `i+1` + '))' - print '\t\treturn NULL;' - # - # Begin of function call - # - if type <> 'void': - print '\tretval =', func + '(', - else: - print '\t' + func + '(', - # - # Argument list - # - for i in range(len(database)): - if i > 0: print ',', - a_type, a_mode, a_factor, a_sub = database[i] - if a_mode == 'r' and not a_factor: - print '&', - print 'arg' + `i+1`, - # - # End of function call - # - print ');' - # - # Free varsize arrays - # - for i in range(len(database)): - a_type, a_mode, a_factor, a_sub = database[i] - if a_mode == 's' and a_sub and not isnum(a_sub): - print '\tPyMem_DEL(arg' + `i+1` + ');' - # - # Return - # - if n_out_args: - # - # Multiple return values -- construct a tuple - # - if type <> 'void': - n_out_args = n_out_args + 1 - if n_out_args == 1: - for i in range(len(database)): - a_type, a_mode, a_factor, a_sub = database[i] - if a_mode == 'r': - break - else: - raise arg_error, 'expected r arg not found' - print '\treturn', - print mkobject(a_type, 'arg' + `i+1`) + ';' - else: - print '\t{ PyObject *v = PyTuple_New(', - print n_out_args, ');' - print '\t if (v == NULL) return NULL;' - i_out = 0 - if type <> 'void': - print '\t PyTuple_SetItem(v,', - print `i_out` + ',', - print mkobject(type, 'retval') + ');' - i_out = i_out + 1 - for i in range(len(database)): - a_type, a_mode, a_factor, a_sub = database[i] - if a_mode == 'r': - print '\t PyTuple_SetItem(v,', - print `i_out` + ',', - s = mkobject(a_type, 'arg' + `i+1`) - print s + ');' - i_out = i_out + 1 - print '\t return v;' - print '\t}' - else: - # - # Simple function return - # Return None or return value - # - if type == 'void': - print '\tPy_INCREF(Py_None);' - print '\treturn Py_None;' - else: - print '\treturn', mkobject(type, 'retval') + ';' - # - # Stub body closing brace - # - print '}' - - -# Subroutine to return a function call to mknewobject() -# -def mkobject(type, arg): - if type[:9] == 'unsigned ': - type = type[9:] - return 'mknew' + type + 'object((' + type + ') ' + arg + ')' - return 'mknew' + type + 'object(' + arg + ')' - - -defined_archs = [] - -# usage: cgen [ -Dmach ... ] [ file ] -for arg in sys.argv[1:]: - if arg[:2] == '-D': - defined_archs.append(arg[2:]) - else: - # Open optional file argument - sys.stdin = open(arg, 'r') - - -# Input line number -lno = 0 - - -# Input is divided in two parts, separated by a line containing '%%'. -# -- literally copied to stdout -# -- stub definitions - -# Variable indicating the current input part. -# -part = 1 - -# Main loop over the input -# -while 1: - try: - line = raw_input() - except EOFError: - break - # - lno = lno+1 - words = string.split(line) - # - if part == 1: - # - # In part 1, copy everything literally - # except look for a line of just '%%' - # - if words == ['%%']: - part = part + 1 - else: - # - # Look for names of manually written - # stubs: a single percent followed by the name - # of the function in Python. - # The stub name is derived by prefixing 'gl_'. - # - if words and words[0][0] == '%': - func = words[0][1:] - if (not func) and words[1:]: - func = words[1] - if func: - functions.append(func) - else: - print line - continue - if not words: - continue # skip empty line - elif words[0] == 'if': - # if XXX rest - # if !XXX rest - if words[1][0] == '!': - if words[1][1:] in defined_archs: - continue - elif words[1] not in defined_archs: - continue - words = words[2:] - if words[0] == '#include': - print line - elif words[0][:1] == '#': - pass # ignore comment - elif words[0] not in return_types: - err('Line', lno, ': bad return type :', words[0]) - elif len(words) < 2: - err('Line', lno, ': no funcname :', line) - else: - if len(words) % 2 <> 0: - err('Line', lno, ': odd argument list :', words[2:]) - else: - database = [] - try: - for i in range(2, len(words), 2): - x = checkarg(words[i], words[i+1]) - database.append(x) - print - print '/*', - for w in words: print w, - print '*/' - generate(words[0], words[1], database) - except arg_error, msg: - err('Line', lno, ':', msg) - - -print -print 'static struct PyMethodDef gl_methods[] = {' -for func in functions: - print '\t{"' + func + '", gl_' + func + '},' -print '\t{NULL, NULL} /* Sentinel */' -print '};' -print -print 'void' -print 'initgl()' -print '{' -print '\t(void) Py_InitModule("gl", gl_methods);' -print '}' diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/cgensupport.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/cgensupport.c deleted file mode 100644 index b66ec8b9..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/cgensupport.c +++ /dev/null @@ -1,310 +0,0 @@ - -/* Functions used by cgen output */ - -#include "Python.h" -#include "cgensupport.h" - - -/* Functions to extract arguments. - These needs to know the total number of arguments supplied, - since the argument list is a tuple only of there is more than - one argument. */ - -int -PyArg_GetObject(register PyObject *args, int nargs, int i, PyObject **p_arg) -{ - if (nargs != 1) { - if (args == NULL || !PyTuple_Check(args) || - nargs != PyTuple_Size(args) || - i < 0 || i >= nargs) { - return PyErr_BadArgument(); - } - else { - args = PyTuple_GetItem(args, i); - } - } - if (args == NULL) { - return PyErr_BadArgument(); - } - *p_arg = args; - return 1; -} - -int -PyArg_GetLong(register PyObject *args, int nargs, int i, long *p_arg) -{ - if (nargs != 1) { - if (args == NULL || !PyTuple_Check(args) || - nargs != PyTuple_Size(args) || - i < 0 || i >= nargs) { - return PyErr_BadArgument(); - } - args = PyTuple_GetItem(args, i); - } - if (args == NULL || !PyInt_Check(args)) { - return PyErr_BadArgument(); - } - *p_arg = PyInt_AsLong(args); - return 1; -} - -int -PyArg_GetShort(register PyObject *args, int nargs, int i, short *p_arg) -{ - long x; - if (!PyArg_GetLong(args, nargs, i, &x)) - return 0; - *p_arg = (short) x; - return 1; -} - -static int -extractdouble(register PyObject *v, double *p_arg) -{ - if (v == NULL) { - /* Fall through to error return at end of function */ - } - else if (PyFloat_Check(v)) { - *p_arg = PyFloat_AS_DOUBLE((PyFloatObject *)v); - return 1; - } - else if (PyInt_Check(v)) { - *p_arg = PyInt_AS_LONG((PyIntObject *)v); - return 1; - } - else if (PyLong_Check(v)) { - *p_arg = PyLong_AsDouble(v); - return 1; - } - return PyErr_BadArgument(); -} - -static int -extractfloat(register PyObject *v, float *p_arg) -{ - if (v == NULL) { - /* Fall through to error return at end of function */ - } - else if (PyFloat_Check(v)) { - *p_arg = (float) PyFloat_AS_DOUBLE((PyFloatObject *)v); - return 1; - } - else if (PyInt_Check(v)) { - *p_arg = (float) PyInt_AS_LONG((PyIntObject *)v); - return 1; - } - else if (PyLong_Check(v)) { - *p_arg = (float) PyLong_AsDouble(v); - return 1; - } - return PyErr_BadArgument(); -} - -int -PyArg_GetFloat(register PyObject *args, int nargs, int i, float *p_arg) -{ - PyObject *v; - float x; - if (!PyArg_GetObject(args, nargs, i, &v)) - return 0; - if (!extractfloat(v, &x)) - return 0; - *p_arg = x; - return 1; -} - -int -PyArg_GetString(PyObject *args, int nargs, int i, string *p_arg) -{ - PyObject *v; - if (!PyArg_GetObject(args, nargs, i, &v)) - return 0; - if (!PyString_Check(v)) { - return PyErr_BadArgument(); - } - *p_arg = PyString_AsString(v); - return 1; -} - -int -PyArg_GetChar(PyObject *args, int nargs, int i, char *p_arg) -{ - string x; - if (!PyArg_GetString(args, nargs, i, &x)) - return 0; - if (x[0] == '\0' || x[1] != '\0') { - /* Not exactly one char */ - return PyErr_BadArgument(); - } - *p_arg = x[0]; - return 1; -} - -int -PyArg_GetLongArraySize(PyObject *args, int nargs, int i, long *p_arg) -{ - PyObject *v; - if (!PyArg_GetObject(args, nargs, i, &v)) - return 0; - if (PyTuple_Check(v)) { - *p_arg = PyTuple_Size(v); - return 1; - } - if (PyList_Check(v)) { - *p_arg = PyList_Size(v); - return 1; - } - return PyErr_BadArgument(); -} - -int -PyArg_GetShortArraySize(PyObject *args, int nargs, int i, short *p_arg) -{ - long x; - if (!PyArg_GetLongArraySize(args, nargs, i, &x)) - return 0; - *p_arg = (short) x; - return 1; -} - -/* XXX The following four are too similar. Should share more code. */ - -int -PyArg_GetLongArray(PyObject *args, int nargs, int i, int n, long *p_arg) -{ - PyObject *v, *w; - if (!PyArg_GetObject(args, nargs, i, &v)) - return 0; - if (PyTuple_Check(v)) { - if (PyTuple_Size(v) != n) { - return PyErr_BadArgument(); - } - for (i = 0; i < n; i++) { - w = PyTuple_GetItem(v, i); - if (!PyInt_Check(w)) { - return PyErr_BadArgument(); - } - p_arg[i] = PyInt_AsLong(w); - } - return 1; - } - else if (PyList_Check(v)) { - if (PyList_Size(v) != n) { - return PyErr_BadArgument(); - } - for (i = 0; i < n; i++) { - w = PyList_GetItem(v, i); - if (!PyInt_Check(w)) { - return PyErr_BadArgument(); - } - p_arg[i] = PyInt_AsLong(w); - } - return 1; - } - else { - return PyErr_BadArgument(); - } -} - -int -PyArg_GetShortArray(PyObject *args, int nargs, int i, int n, short *p_arg) -{ - PyObject *v, *w; - if (!PyArg_GetObject(args, nargs, i, &v)) - return 0; - if (PyTuple_Check(v)) { - if (PyTuple_Size(v) != n) { - return PyErr_BadArgument(); - } - for (i = 0; i < n; i++) { - w = PyTuple_GetItem(v, i); - if (!PyInt_Check(w)) { - return PyErr_BadArgument(); - } - p_arg[i] = (short) PyInt_AsLong(w); - } - return 1; - } - else if (PyList_Check(v)) { - if (PyList_Size(v) != n) { - return PyErr_BadArgument(); - } - for (i = 0; i < n; i++) { - w = PyList_GetItem(v, i); - if (!PyInt_Check(w)) { - return PyErr_BadArgument(); - } - p_arg[i] = (short) PyInt_AsLong(w); - } - return 1; - } - else { - return PyErr_BadArgument(); - } -} - -int -PyArg_GetDoubleArray(PyObject *args, int nargs, int i, int n, double *p_arg) -{ - PyObject *v, *w; - if (!PyArg_GetObject(args, nargs, i, &v)) - return 0; - if (PyTuple_Check(v)) { - if (PyTuple_Size(v) != n) { - return PyErr_BadArgument(); - } - for (i = 0; i < n; i++) { - w = PyTuple_GetItem(v, i); - if (!extractdouble(w, &p_arg[i])) - return 0; - } - return 1; - } - else if (PyList_Check(v)) { - if (PyList_Size(v) != n) { - return PyErr_BadArgument(); - } - for (i = 0; i < n; i++) { - w = PyList_GetItem(v, i); - if (!extractdouble(w, &p_arg[i])) - return 0; - } - return 1; - } - else { - return PyErr_BadArgument(); - } -} - -int -PyArg_GetFloatArray(PyObject *args, int nargs, int i, int n, float *p_arg) -{ - PyObject *v, *w; - if (!PyArg_GetObject(args, nargs, i, &v)) - return 0; - if (PyTuple_Check(v)) { - if (PyTuple_Size(v) != n) { - return PyErr_BadArgument(); - } - for (i = 0; i < n; i++) { - w = PyTuple_GetItem(v, i); - if (!extractfloat(w, &p_arg[i])) - return 0; - } - return 1; - } - else if (PyList_Check(v)) { - if (PyList_Size(v) != n) { - return PyErr_BadArgument(); - } - for (i = 0; i < n; i++) { - w = PyList_GetItem(v, i); - if (!extractfloat(w, &p_arg[i])) - return 0; - } - return 1; - } - else { - return PyErr_BadArgument(); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/cgensupport.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/cgensupport.h deleted file mode 100644 index 23404661..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/cgensupport.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef Py_CGENSUPPORT_H -#define Py_CGENSUPPORT_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Definitions used by cgen output */ - -/* XXX This file is obsolete. It is *only* used by glmodule.c. */ - -typedef char *string; - -#define mknewlongobject(x) PyInt_FromLong(x) -#define mknewshortobject(x) PyInt_FromLong((long)x) -#define mknewfloatobject(x) PyFloat_FromDouble(x) -#define mknewcharobject(ch) Py_BuildValue("c", ch) - -#define getichararg PyArg_GetChar -#define getidoublearray PyArg_GetDoubleArray -#define getifloatarg PyArg_GetFloat -#define getifloatarray PyArg_GetFloatArray -#define getilongarg PyArg_GetLong -#define getilongarray PyArg_GetLongArray -#define getilongarraysize PyArg_GetLongArraySize -#define getiobjectarg PyArg_GetObject -#define getishortarg PyArg_GetShort -#define getishortarray PyArg_GetShortArray -#define getishortarraysize PyArg_GetShortArraySize -#define getistringarg PyArg_GetString - -extern int PyArg_GetObject(PyObject *args, int nargs, - int i, PyObject **p_a); -extern int PyArg_GetLong(PyObject *args, int nargs, - int i, long *p_a); -extern int PyArg_GetShort(PyObject *args, int nargs, - int i, short *p_a); -extern int PyArg_GetFloat(PyObject *args, int nargs, - int i, float *p_a); -extern int PyArg_GetString(PyObject *args, int nargs, - int i, string *p_a); -extern int PyArg_GetChar(PyObject *args, int nargs, - int i, char *p_a); -extern int PyArg_GetLongArray(PyObject *args, int nargs, - int i, int n, long *p_a); -extern int PyArg_GetShortArray(PyObject *args, int nargs, - int i, int n, short *p_a); -extern int PyArg_GetDoubleArray(PyObject *args, int nargs, - int i, int n, double *p_a); -extern int PyArg_GetFloatArray(PyObject *args, int nargs, - int i, int n, float *p_a); -extern int PyArg_GetLongArraySize(PyObject *args, int nargs, - int i, long *p_a); -extern int PyArg_GetShortArraySize(PyObject *args, int nargs, - int i, short *p_a); -extern int PyArg_GetDoubleArraySize(PyObject *args, int nargs, - int i, double *p_a); -extern int PyArg_GetFloatArraySize(PyObject *args, int nargs, - int i, float *p_a); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_CGENSUPPORT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/clmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/clmodule.c deleted file mode 100644 index 54343866..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/clmodule.c +++ /dev/null @@ -1,2557 +0,0 @@ - - -/* Cl objects */ - -#define CLDEBUG - -#include -#include -#if defined(CL_JPEG_SOFTWARE) && !defined(CL_JPEG_COSMO) -#include -#endif -#include "Python.h" - -typedef struct { - PyObject_HEAD - int ob_isCompressor; /* Compressor or Decompressor */ - CL_Handle ob_compressorHdl; - int *ob_paramtypes; - int ob_nparams; -} clobject; - -static PyObject *ClError; /* exception cl.error */ - -static int error_handler_called = 0; - -/* - * We want to use the function prototypes that are available in the C - * compiler on the SGI. Because of that, we need to declare the first - * argument of the compressor and decompressor methods as "object *", - * even though they are really "clobject *". Therefore we cast the - * argument to the proper type using this macro. - */ -#define SELF ((clobject *) self) - -/******************************************************************** - Utility routines. -********************************************************************/ -static void -cl_ErrorHandler(CL_Handle handle, int code, const char *fmt, ...) -{ - va_list ap; - char errbuf[BUFSIZ]; /* hopefully big enough */ - char *p; - - if (PyErr_Occurred()) /* don't change existing error */ - return; - error_handler_called = 1; - va_start(ap, fmt); - vsprintf(errbuf, fmt, ap); - va_end(ap); - p = &errbuf[strlen(errbuf) - 1]; /* swat the line feed */ - if (*p == '\n') - *p = 0; - PyErr_SetString(ClError, errbuf); -} - -/* - * This assumes that params are always in the range 0 to some maximum. - */ -static int -param_type_is_float(clobject *self, int param) -{ - int bufferlength; - - if (self->ob_paramtypes == NULL) { - error_handler_called = 0; - bufferlength = clQueryParams(self->ob_compressorHdl, 0, 0); - if (error_handler_called) - return -1; - - self->ob_paramtypes = PyMem_NEW(int, bufferlength); - if (self->ob_paramtypes == NULL) - return -1; - self->ob_nparams = bufferlength / 2; - - (void) clQueryParams(self->ob_compressorHdl, - self->ob_paramtypes, bufferlength); - if (error_handler_called) { - PyMem_DEL(self->ob_paramtypes); - self->ob_paramtypes = NULL; - return -1; - } - } - - if (param < 0 || param >= self->ob_nparams) - return -1; - - if (self->ob_paramtypes[param*2 + 1] == CL_FLOATING_ENUM_VALUE || - self->ob_paramtypes[param*2 + 1] == CL_FLOATING_RANGE_VALUE) - return 1; - else - return 0; -} - -/******************************************************************** - Single image compression/decompression. -********************************************************************/ -static PyObject * -cl_CompressImage(PyObject *self, PyObject *args) -{ - int compressionScheme, width, height, originalFormat; - float compressionRatio; - int frameBufferSize, compressedBufferSize; - char *frameBuffer; - PyObject *compressedBuffer; - - if (!PyArg_ParseTuple(args, "iiiifs#", &compressionScheme, - &width, &height, - &originalFormat, &compressionRatio, &frameBuffer, - &frameBufferSize)) - return NULL; - - retry: - compressedBuffer = PyString_FromStringAndSize(NULL, frameBufferSize); - if (compressedBuffer == NULL) - return NULL; - - compressedBufferSize = frameBufferSize; - error_handler_called = 0; - if (clCompressImage(compressionScheme, width, height, originalFormat, - compressionRatio, (void *) frameBuffer, - &compressedBufferSize, - (void *) PyString_AsString(compressedBuffer)) - == FAILURE || error_handler_called) { - Py_DECREF(compressedBuffer); - if (!error_handler_called) - PyErr_SetString(ClError, "clCompressImage failed"); - return NULL; - } - - if (compressedBufferSize > frameBufferSize) { - frameBufferSize = compressedBufferSize; - Py_DECREF(compressedBuffer); - goto retry; - } - - if (compressedBufferSize < frameBufferSize) - _PyString_Resize(&compressedBuffer, compressedBufferSize); - - return compressedBuffer; -} - -static PyObject * -cl_DecompressImage(PyObject *self, PyObject *args) -{ - int compressionScheme, width, height, originalFormat; - char *compressedBuffer; - int compressedBufferSize, frameBufferSize; - PyObject *frameBuffer; - - if (!PyArg_ParseTuple(args, "iiiis#", &compressionScheme, &width, &height, - &originalFormat, &compressedBuffer, - &compressedBufferSize)) - return NULL; - - frameBufferSize = width * height * CL_BytesPerPixel(originalFormat); - - frameBuffer = PyString_FromStringAndSize(NULL, frameBufferSize); - if (frameBuffer == NULL) - return NULL; - - error_handler_called = 0; - if (clDecompressImage(compressionScheme, width, height, originalFormat, - compressedBufferSize, compressedBuffer, - (void *) PyString_AsString(frameBuffer)) - == FAILURE || error_handler_called) { - Py_DECREF(frameBuffer); - if (!error_handler_called) - PyErr_SetString(ClError, "clDecompressImage failed"); - return NULL; - } - - return frameBuffer; -} - -/******************************************************************** - Sequential compression/decompression. -********************************************************************/ -#define CheckCompressor(self) if ((self)->ob_compressorHdl == NULL) { \ - PyErr_SetString(PyExc_RuntimeError, "(de)compressor not active"); \ - return NULL; \ -} - -static PyObject * -doClose(clobject *self, int (*close_func)(CL_Handle)) -{ - CheckCompressor(self); - - error_handler_called = 0; - if ((*close_func)(self->ob_compressorHdl) == FAILURE || - error_handler_called) { - if (!error_handler_called) - PyErr_SetString(ClError, "close failed"); - return NULL; - } - - self->ob_compressorHdl = NULL; - - if (self->ob_paramtypes) - PyMem_DEL(self->ob_paramtypes); - self->ob_paramtypes = NULL; - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -clm_CloseCompressor(PyObject *self) -{ - return doClose(SELF, clCloseCompressor); -} - -static PyObject * -clm_CloseDecompressor(PyObject *self) -{ - return doClose(SELF, clCloseDecompressor); -} - -static PyObject * -clm_Compress(PyObject *self, PyObject *args) -{ - int numberOfFrames; - int frameBufferSize, compressedBufferSize, size; - char *frameBuffer; - PyObject *data; - - CheckCompressor(SELF); - - if (!PyArg_Parse(args, "(is#)", &numberOfFrames, - &frameBuffer, &frameBufferSize)) - return NULL; - - error_handler_called = 0; - size = clGetParam(SELF->ob_compressorHdl, CL_COMPRESSED_BUFFER_SIZE); - compressedBufferSize = size; - if (error_handler_called) - return NULL; - - data = PyString_FromStringAndSize(NULL, size); - if (data == NULL) - return NULL; - - error_handler_called = 0; - if (clCompress(SELF->ob_compressorHdl, numberOfFrames, - (void *) frameBuffer, &compressedBufferSize, - (void *) PyString_AsString(data)) == FAILURE || - error_handler_called) { - Py_DECREF(data); - if (!error_handler_called) - PyErr_SetString(ClError, "compress failed"); - return NULL; - } - - if (compressedBufferSize < size) - if (_PyString_Resize(&data, compressedBufferSize)) - return NULL; - - if (compressedBufferSize > size) { - /* we didn't get all "compressed" data */ - Py_DECREF(data); - PyErr_SetString(ClError, - "compressed data is more than fitted"); - return NULL; - } - - return data; -} - -static PyObject * -clm_Decompress(PyObject *self, PyObject *args) -{ - PyObject *data; - int numberOfFrames; - char *compressedData; - int compressedDataSize, dataSize; - - CheckCompressor(SELF); - - if (!PyArg_Parse(args, "(is#)", &numberOfFrames, &compressedData, - &compressedDataSize)) - return NULL; - - error_handler_called = 0; - dataSize = clGetParam(SELF->ob_compressorHdl, CL_FRAME_BUFFER_SIZE); - if (error_handler_called) - return NULL; - - data = PyString_FromStringAndSize(NULL, dataSize); - if (data == NULL) - return NULL; - - error_handler_called = 0; - if (clDecompress(SELF->ob_compressorHdl, numberOfFrames, - compressedDataSize, (void *) compressedData, - (void *) PyString_AsString(data)) == FAILURE || - error_handler_called) { - Py_DECREF(data); - if (!error_handler_called) - PyErr_SetString(ClError, "decompress failed"); - return NULL; - } - - return data; -} - -static PyObject * -doParams(clobject *self, PyObject *args, int (*func)(CL_Handle, int *, int), - int modified) -{ - PyObject *list, *v; - int *PVbuffer; - int length; - int i; - float number; - - CheckCompressor(self); - - if (!PyArg_Parse(args, "O", &list)) - return NULL; - if (!PyList_Check(list)) { - PyErr_BadArgument(); - return NULL; - } - length = PyList_Size(list); - PVbuffer = PyMem_NEW(int, length); - if (PVbuffer == NULL) - return PyErr_NoMemory(); - for (i = 0; i < length; i++) { - v = PyList_GetItem(list, i); - if (PyFloat_Check(v)) { - number = PyFloat_AsDouble(v); - PVbuffer[i] = CL_TypeIsInt(number); - } else if (PyInt_Check(v)) { - PVbuffer[i] = PyInt_AsLong(v); - if ((i & 1) && - param_type_is_float(self, PVbuffer[i-1]) > 0) { - number = PVbuffer[i]; - PVbuffer[i] = CL_TypeIsInt(number); - } - } else { - PyMem_DEL(PVbuffer); - PyErr_BadArgument(); - return NULL; - } - } - - error_handler_called = 0; - (*func)(self->ob_compressorHdl, PVbuffer, length); - if (error_handler_called) { - PyMem_DEL(PVbuffer); - return NULL; - } - - if (modified) { - for (i = 0; i < length; i++) { - if ((i & 1) && - param_type_is_float(self, PVbuffer[i-1]) > 0) { - number = CL_TypeIsFloat(PVbuffer[i]); - v = PyFloat_FromDouble(number); - } else - v = PyInt_FromLong(PVbuffer[i]); - PyList_SetItem(list, i, v); - } - } - - PyMem_DEL(PVbuffer); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -clm_GetParams(PyObject *self, PyObject *args) -{ - return doParams(SELF, args, clGetParams, 1); -} - -static PyObject * -clm_SetParams(PyObject *self, PyObject *args) -{ - return doParams(SELF, args, clSetParams, 0); -} - -static PyObject * -do_get(clobject *self, PyObject *args, int (*func)(CL_Handle, int)) -{ - int paramID, value; - float fvalue; - - CheckCompressor(self); - - if (!PyArg_Parse(args, "i", ¶mID)) - return NULL; - - error_handler_called = 0; - value = (*func)(self->ob_compressorHdl, paramID); - if (error_handler_called) - return NULL; - - if (param_type_is_float(self, paramID) > 0) { - fvalue = CL_TypeIsFloat(value); - return PyFloat_FromDouble(fvalue); - } - - return PyInt_FromLong(value); -} - -static PyObject * -clm_GetParam(PyObject *self, PyObject *args) -{ - return do_get(SELF, args, clGetParam); -} - -static PyObject * -clm_GetDefault(PyObject *self, PyObject *args) -{ - return do_get(SELF, args, clGetDefault); -} - -static PyObject * -clm_SetParam(PyObject *self, PyObject *args) -{ - int paramID, value; - float fvalue; - - CheckCompressor(SELF); - - if (!PyArg_Parse(args, "(ii)", ¶mID, &value)) { - PyErr_Clear(); - if (!PyArg_Parse(args, "(if)", ¶mID, &fvalue)) { - PyErr_Clear(); - PyErr_SetString(PyExc_TypeError, - "bad argument list (format '(ii)' or '(if)')"); - return NULL; - } - value = CL_TypeIsInt(fvalue); - } else { - if (param_type_is_float(SELF, paramID) > 0) { - fvalue = value; - value = CL_TypeIsInt(fvalue); - } - } - - error_handler_called = 0; - value = clSetParam(SELF->ob_compressorHdl, paramID, value); - if (error_handler_called) - return NULL; - - if (param_type_is_float(SELF, paramID) > 0) - return PyFloat_FromDouble(CL_TypeIsFloat(value)); - else - return PyInt_FromLong(value); -} - -static PyObject * -clm_GetParamID(PyObject *self, PyObject *args) -{ - char *name; - int value; - - CheckCompressor(SELF); - - if (!PyArg_Parse(args, "s", &name)) - return NULL; - - error_handler_called = 0; - value = clGetParamID(SELF->ob_compressorHdl, name); - if (value == FAILURE || error_handler_called) { - if (!error_handler_called) - PyErr_SetString(ClError, "getparamid failed"); - return NULL; - } - - return PyInt_FromLong(value); -} - -static PyObject * -clm_QueryParams(PyObject *self) -{ - int bufferlength; - int *PVbuffer; - PyObject *list; - int i; - - CheckCompressor(SELF); - - error_handler_called = 0; - bufferlength = clQueryParams(SELF->ob_compressorHdl, 0, 0); - if (error_handler_called) - return NULL; - - PVbuffer = PyMem_NEW(int, bufferlength); - if (PVbuffer == NULL) - return PyErr_NoMemory(); - - bufferlength = clQueryParams(SELF->ob_compressorHdl, PVbuffer, - bufferlength); - if (error_handler_called) { - PyMem_DEL(PVbuffer); - return NULL; - } - - list = PyList_New(bufferlength); - if (list == NULL) { - PyMem_DEL(PVbuffer); - return NULL; - } - - for (i = 0; i < bufferlength; i++) { - if (i & 1) - PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i])); - else if (PVbuffer[i] == 0) { - Py_INCREF(Py_None); - PyList_SetItem(list, i, Py_None); - } else - PyList_SetItem(list, i, - PyString_FromString((char *) PVbuffer[i])); - } - - PyMem_DEL(PVbuffer); - - return list; -} - -static PyObject * -clm_GetMinMax(PyObject *self, PyObject *args) -{ - int param, min, max; - float fmin, fmax; - - CheckCompressor(SELF); - - if (!PyArg_Parse(args, "i", ¶m)) - return NULL; - - clGetMinMax(SELF->ob_compressorHdl, param, &min, &max); - - if (param_type_is_float(SELF, param) > 0) { - fmin = CL_TypeIsFloat(min); - fmax = CL_TypeIsFloat(max); - return Py_BuildValue("(ff)", fmin, fmax); - } - - return Py_BuildValue("(ii)", min, max); -} - -static PyObject * -clm_GetName(PyObject *self, PyObject *args) -{ - int param; - char *name; - - CheckCompressor(SELF); - - if (!PyArg_Parse(args, "i", ¶m)) - return NULL; - - error_handler_called = 0; - name = clGetName(SELF->ob_compressorHdl, param); - if (name == NULL || error_handler_called) { - if (!error_handler_called) - PyErr_SetString(ClError, "getname failed"); - return NULL; - } - - return PyString_FromString(name); -} - -static PyObject * -clm_QuerySchemeFromHandle(PyObject *self) -{ - CheckCompressor(SELF); - return PyInt_FromLong(clQuerySchemeFromHandle(SELF->ob_compressorHdl)); -} - -static PyObject * -clm_ReadHeader(PyObject *self, PyObject *args) -{ - char *header; - int headerSize; - - CheckCompressor(SELF); - - if (!PyArg_Parse(args, "s#", &header, &headerSize)) - return NULL; - - return PyInt_FromLong(clReadHeader(SELF->ob_compressorHdl, - headerSize, header)); -} - -static PyMethodDef compressor_methods[] = { - {"close", clm_CloseCompressor, METH_NOARGS}, /* alias */ - {"CloseCompressor", clm_CloseCompressor, METH_NOARGS}, - {"Compress", clm_Compress, METH_OLDARGS}, - {"GetDefault", clm_GetDefault, METH_OLDARGS}, - {"GetMinMax", clm_GetMinMax, METH_OLDARGS}, - {"GetName", clm_GetName, METH_OLDARGS}, - {"GetParam", clm_GetParam, METH_OLDARGS}, - {"GetParamID", clm_GetParamID, METH_OLDARGS}, - {"GetParams", clm_GetParams, METH_OLDARGS}, - {"QueryParams", clm_QueryParams, METH_NOARGS}, - {"QuerySchemeFromHandle",clm_QuerySchemeFromHandle, METH_NOARGS}, - {"SetParam", clm_SetParam, METH_OLDARGS}, - {"SetParams", clm_SetParams, METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - -static PyMethodDef decompressor_methods[] = { - {"close", clm_CloseDecompressor, METH_NOARGS}, /* alias */ - {"CloseDecompressor", clm_CloseDecompressor, METH_NOARGS}, - {"Decompress", clm_Decompress, METH_OLDARGS}, - {"GetDefault", clm_GetDefault, METH_OLDARGS}, - {"GetMinMax", clm_GetMinMax, METH_OLDARGS}, - {"GetName", clm_GetName, METH_OLDARGS}, - {"GetParam", clm_GetParam, METH_OLDARGS}, - {"GetParamID", clm_GetParamID, METH_OLDARGS}, - {"GetParams", clm_GetParams, METH_OLDARGS}, - {"ReadHeader", clm_ReadHeader, METH_OLDARGS}, - {"QueryParams", clm_QueryParams, METH_NOARGS}, - {"QuerySchemeFromHandle",clm_QuerySchemeFromHandle, METH_NOARGS}, - {"SetParam", clm_SetParam, METH_OLDARGS}, - {"SetParams", clm_SetParams, METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - -static void -cl_dealloc(PyObject *self) -{ - if (SELF->ob_compressorHdl) { - if (SELF->ob_isCompressor) - clCloseCompressor(SELF->ob_compressorHdl); - else - clCloseDecompressor(SELF->ob_compressorHdl); - } - PyObject_Del(self); -} - -static PyObject * -cl_getattr(PyObject *self, char *name) -{ - if (SELF->ob_isCompressor) - return Py_FindMethod(compressor_methods, self, name); - else - return Py_FindMethod(decompressor_methods, self, name); -} - -static PyTypeObject Cltype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "cl.cl", /*tp_name*/ - sizeof(clobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)cl_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)cl_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ -}; - -static PyObject * -doOpen(PyObject *self, PyObject *args, int (*open_func)(int, CL_Handle *), - int iscompressor) -{ - int scheme; - clobject *new; - - if (!PyArg_ParseTuple(args, "i", &scheme)) - return NULL; - - new = PyObject_New(clobject, &Cltype); - if (new == NULL) - return NULL; - - new->ob_compressorHdl = NULL; - new->ob_isCompressor = iscompressor; - new->ob_paramtypes = NULL; - - error_handler_called = 0; - if ((*open_func)(scheme, &new->ob_compressorHdl) == FAILURE || - error_handler_called) { - Py_DECREF(new); - if (!error_handler_called) - PyErr_SetString(ClError, "Open(De)Compressor failed"); - return NULL; - } - return (PyObject *)new; -} - -static PyObject * -cl_OpenCompressor(PyObject *self, PyObject *args) -{ - return doOpen(self, args, clOpenCompressor, 1); -} - -static PyObject * -cl_OpenDecompressor(PyObject *self, PyObject *args) -{ - return doOpen(self, args, clOpenDecompressor, 0); -} - -static PyObject * -cl_QueryScheme(PyObject *self, PyObject *args) -{ - char *header; - int headerlen; - int scheme; - - if (!PyArg_ParseTuple(args, "s#", &header, &headerlen)) - return NULL; - - scheme = clQueryScheme(header); - if (scheme < 0) { - PyErr_SetString(ClError, "unknown compression scheme"); - return NULL; - } - - return PyInt_FromLong(scheme); -} - -static PyObject * -cl_QueryMaxHeaderSize(PyObject *self, PyObject *args) -{ - int scheme; - - if (!PyArg_ParseTuple(args, "i", &scheme)) - return NULL; - - return PyInt_FromLong(clQueryMaxHeaderSize(scheme)); -} - -static PyObject * -cl_QueryAlgorithms(PyObject *self, PyObject *args) -{ - int algorithmMediaType; - int bufferlength; - int *PVbuffer; - PyObject *list; - int i; - - if (!PyArg_ParseTuple(args, "i", &algorithmMediaType)) - return NULL; - - error_handler_called = 0; - bufferlength = clQueryAlgorithms(algorithmMediaType, 0, 0); - if (error_handler_called) - return NULL; - - PVbuffer = PyMem_NEW(int, bufferlength); - if (PVbuffer == NULL) - return PyErr_NoMemory(); - - bufferlength = clQueryAlgorithms(algorithmMediaType, PVbuffer, - bufferlength); - if (error_handler_called) { - PyMem_DEL(PVbuffer); - return NULL; - } - - list = PyList_New(bufferlength); - if (list == NULL) { - PyMem_DEL(PVbuffer); - return NULL; - } - - for (i = 0; i < bufferlength; i++) { - if (i & 1) - PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i])); - else if (PVbuffer[i] == 0) { - Py_INCREF(Py_None); - PyList_SetItem(list, i, Py_None); - } else - PyList_SetItem(list, i, - PyString_FromString((char *) PVbuffer[i])); - } - - PyMem_DEL(PVbuffer); - - return list; -} - -static PyObject * -cl_QuerySchemeFromName(PyObject *self, PyObject *args) -{ - int algorithmMediaType; - char *name; - int scheme; - - if (!PyArg_ParseTuple(args, "is", &algorithmMediaType, &name)) - return NULL; - - error_handler_called = 0; - scheme = clQuerySchemeFromName(algorithmMediaType, name); - if (error_handler_called) { - PyErr_SetString(ClError, "unknown compression scheme"); - return NULL; - } - - return PyInt_FromLong(scheme); -} - -static PyObject * -cl_GetAlgorithmName(PyObject *self, PyObject *args) -{ - int scheme; - char *name; - - if (!PyArg_ParseTuple(args, "i", &scheme)) - return NULL; - - name = clGetAlgorithmName(scheme); - if (name == 0) { - PyErr_SetString(ClError, "unknown compression scheme"); - return NULL; - } - - return PyString_FromString(name); -} - -static PyObject * -do_set(PyObject *self, PyObject *args, int (*func)(int, int, int)) -{ - int scheme, paramID, value; - float fvalue; - int is_float = 0; - - if (!PyArg_ParseTuple(args, "iii", &scheme, ¶mID, &value)) { - PyErr_Clear(); - if (!PyArg_ParseTuple(args, "iif", &scheme, ¶mID, &fvalue)) { - PyErr_Clear(); - PyErr_SetString(PyExc_TypeError, - "bad argument list (format '(iii)' or '(iif)')"); - return NULL; - } - value = CL_TypeIsInt(fvalue); - is_float = 1; - } else { - /* check some parameters which we know to be floats */ - switch (scheme) { - case CL_COMPRESSION_RATIO: - case CL_SPEED: - fvalue = value; - value = CL_TypeIsInt(fvalue); - is_float = 1; - break; - } - } - - error_handler_called = 0; - value = (*func)(scheme, paramID, value); - if (error_handler_called) - return NULL; - - if (is_float) - return PyFloat_FromDouble(CL_TypeIsFloat(value)); - else - return PyInt_FromLong(value); -} - -static PyObject * -cl_SetDefault(PyObject *self, PyObject *args) -{ - return do_set(self, args, clSetDefault); -} - -static PyObject * -cl_SetMin(PyObject *self, PyObject *args) -{ - return do_set(self, args, clSetMin); -} - -static PyObject * -cl_SetMax(PyObject *self, PyObject *args) -{ - return do_set(self, args, clSetMax); -} - -#define func(name, handler) \ -static PyObject *cl_##name(PyObject *self, PyObject *args) \ -{ \ - int x; \ - if (!PyArg_ParseTuple(args, "i", &x)) return NULL; \ - return Py##handler(CL_##name(x)); \ -} - -#define func2(name, handler) \ -static PyObject *cl_##name(PyObject *self, PyObject *args) \ -{ \ - int a1, a2; \ - if (!PyArg_ParseTuple(args, "ii", &a1, &a2)) return NULL; \ - return Py##handler(CL_##name(a1, a2)); \ -} - -func(BytesPerSample, Int_FromLong) -func(BytesPerPixel, Int_FromLong) -func(AudioFormatName, String_FromString) -func(VideoFormatName, String_FromString) -func(AlgorithmNumber, Int_FromLong) -func(AlgorithmType, Int_FromLong) -func2(Algorithm, Int_FromLong) -func(ParamNumber, Int_FromLong) -func(ParamType, Int_FromLong) -func2(ParamID, Int_FromLong) - -#ifdef CLDEBUG - static PyObject * -cvt_type(PyObject *self, PyObject *args) -{ - int number; - float fnumber; - - if (PyArg_Parse(args, "i", &number)) - return PyFloat_FromDouble(CL_TypeIsFloat(number)); - else { - PyErr_Clear(); - if (PyArg_Parse(args, "f", &fnumber)) - return PyInt_FromLong(CL_TypeIsInt(fnumber)); - return NULL; - } -} -#endif - -static PyMethodDef cl_methods[] = { - {"CompressImage", cl_CompressImage, METH_VARARGS}, - {"DecompressImage", cl_DecompressImage, METH_VARARGS}, - {"GetAlgorithmName", cl_GetAlgorithmName, METH_VARARGS}, - {"OpenCompressor", cl_OpenCompressor, METH_VARARGS}, - {"OpenDecompressor", cl_OpenDecompressor, METH_VARARGS}, - {"QueryAlgorithms", cl_QueryAlgorithms, METH_VARARGS}, - {"QueryMaxHeaderSize", cl_QueryMaxHeaderSize, METH_VARARGS}, - {"QueryScheme", cl_QueryScheme, METH_VARARGS}, - {"QuerySchemeFromName", cl_QuerySchemeFromName, METH_VARARGS}, - {"SetDefault", cl_SetDefault, METH_VARARGS}, - {"SetMax", cl_SetMax, METH_VARARGS}, - {"SetMin", cl_SetMin, METH_VARARGS}, - {"BytesPerSample", cl_BytesPerSample, METH_VARARGS}, - {"BytesPerPixel", cl_BytesPerPixel, METH_VARARGS}, - {"AudioFormatName", cl_AudioFormatName, METH_VARARGS}, - {"VideoFormatName", cl_VideoFormatName, METH_VARARGS}, - {"AlgorithmNumber", cl_AlgorithmNumber, METH_VARARGS}, - {"AlgorithmType", cl_AlgorithmType, METH_VARARGS}, - {"Algorithm", cl_Algorithm, METH_VARARGS}, - {"ParamNumber", cl_ParamNumber, METH_VARARGS}, - {"ParamType", cl_ParamType, METH_VARARGS}, - {"ParamID", cl_ParamID, METH_VARARGS}, -#ifdef CLDEBUG - {"cvt_type", cvt_type, METH_VARARGS}, -#endif - {NULL, NULL} /* Sentinel */ -}; - -#ifdef CL_JPEG_SOFTWARE -#define IRIX_5_3_LIBRARY -#endif - -void -initcl(void) -{ - PyObject *m, *d, *x; - - m = Py_InitModule("cl", cl_methods); - d = PyModule_GetDict(m); - - ClError = PyErr_NewException("cl.error", NULL, NULL); - (void) PyDict_SetItemString(d, "error", ClError); - -#ifdef CL_ADDED_ALGORITHM_ERROR - x = PyInt_FromLong(CL_ADDED_ALGORITHM_ERROR); - if (x == NULL || PyDict_SetItemString(d, "ADDED_ALGORITHM_ERROR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_ALAW - x = PyInt_FromLong(CL_ALAW); - if (x == NULL || PyDict_SetItemString(d, "ALAW", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_ALGORITHM_ID - x = PyInt_FromLong(CL_ALGORITHM_ID); - if (x == NULL || PyDict_SetItemString(d, "ALGORITHM_ID", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_ALGORITHM_TABLE_FULL - x = PyInt_FromLong(CL_ALGORITHM_TABLE_FULL); - if (x == NULL || PyDict_SetItemString(d, "ALGORITHM_TABLE_FULL", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_ALGORITHM_VERSION - x = PyInt_FromLong(CL_ALGORITHM_VERSION); - if (x == NULL || PyDict_SetItemString(d, "ALGORITHM_VERSION", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_ALG_AUDIO - x = PyInt_FromLong(CL_ALG_AUDIO); - if (x == NULL || PyDict_SetItemString(d, "ALG_AUDIO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_ALG_VIDEO - x = PyInt_FromLong(CL_ALG_VIDEO); - if (x == NULL || PyDict_SetItemString(d, "ALG_VIDEO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AUDIO - x = PyInt_FromLong(CL_AUDIO); - if (x == NULL || PyDict_SetItemString(d, "AUDIO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_BITRATE_POLICY - x = PyInt_FromLong(CL_AWARE_BITRATE_POLICY); - if (x == NULL || PyDict_SetItemString(d, "AWARE_BITRATE_POLICY", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_BITRATE_TARGET - x = PyInt_FromLong(CL_AWARE_BITRATE_TARGET); - if (x == NULL || PyDict_SetItemString(d, "AWARE_BITRATE_TARGET", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_CHANNEL_POLICY - x = PyInt_FromLong(CL_AWARE_CHANNEL_POLICY); - if (x == NULL || PyDict_SetItemString(d, "AWARE_CHANNEL_POLICY", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_CONST_QUAL - x = PyInt_FromLong(CL_AWARE_CONST_QUAL); - if (x == NULL || PyDict_SetItemString(d, "AWARE_CONST_QUAL", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_ERROR - x = PyInt_FromLong(CL_AWARE_ERROR); - if (x == NULL || PyDict_SetItemString(d, "AWARE_ERROR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_FIXED_RATE - x = PyInt_FromLong(CL_AWARE_FIXED_RATE); - if (x == NULL || PyDict_SetItemString(d, "AWARE_FIXED_RATE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_INDEPENDENT - x = PyInt_FromLong(CL_AWARE_INDEPENDENT); - if (x == NULL || PyDict_SetItemString(d, "AWARE_INDEPENDENT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_JOINT_STEREO - x = PyInt_FromLong(CL_AWARE_JOINT_STEREO); - if (x == NULL || PyDict_SetItemString(d, "AWARE_JOINT_STEREO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_LAYER - x = PyInt_FromLong(CL_AWARE_LAYER); - if (x == NULL || PyDict_SetItemString(d, "AWARE_LAYER", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_LOSSLESS - x = PyInt_FromLong(CL_AWARE_LOSSLESS); - if (x == NULL || PyDict_SetItemString(d, "AWARE_LOSSLESS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_MPEG_AUDIO - x = PyInt_FromLong(CL_AWARE_MPEG_AUDIO); - if (x == NULL || PyDict_SetItemString(d, "AWARE_MPEG_AUDIO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_MPEG_LAYER_I - x = PyInt_FromLong(CL_AWARE_MPEG_LAYER_I); - if (x == NULL || PyDict_SetItemString(d, "AWARE_MPEG_LAYER_I", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_MPEG_LAYER_II - x = PyInt_FromLong(CL_AWARE_MPEG_LAYER_II); - if (x == NULL || PyDict_SetItemString(d, "AWARE_MPEG_LAYER_II", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_MULTIRATE - x = PyInt_FromLong(CL_AWARE_MULTIRATE); - if (x == NULL || PyDict_SetItemString(d, "AWARE_MULTIRATE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_NOISE_MARGIN - x = PyInt_FromLong(CL_AWARE_NOISE_MARGIN); - if (x == NULL || PyDict_SetItemString(d, "AWARE_NOISE_MARGIN", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_AWARE_STEREO - x = PyInt_FromLong(CL_AWARE_STEREO); - if (x == NULL || PyDict_SetItemString(d, "AWARE_STEREO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_ALGORITHM_NAME - x = PyInt_FromLong(CL_BAD_ALGORITHM_NAME); - if (x == NULL || PyDict_SetItemString(d, "BAD_ALGORITHM_NAME", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_ALGORITHM_TYPE - x = PyInt_FromLong(CL_BAD_ALGORITHM_TYPE); - if (x == NULL || PyDict_SetItemString(d, "BAD_ALGORITHM_TYPE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_BLOCK_SIZE - x = PyInt_FromLong(CL_BAD_BLOCK_SIZE); - if (x == NULL || PyDict_SetItemString(d, "BAD_BLOCK_SIZE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_BOARD - x = PyInt_FromLong(CL_BAD_BOARD); - if (x == NULL || PyDict_SetItemString(d, "BAD_BOARD", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_BUFFERING - x = PyInt_FromLong(CL_BAD_BUFFERING); - if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERING", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_BUFFERLENGTH_NEG - x = PyInt_FromLong(CL_BAD_BUFFERLENGTH_NEG); - if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_NEG", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_BUFFERLENGTH_ODD - x = PyInt_FromLong(CL_BAD_BUFFERLENGTH_ODD); - if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFERLENGTH_ODD", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_BUFFER_EXISTS - x = PyInt_FromLong(CL_BAD_BUFFER_EXISTS); - if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFER_EXISTS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_BUFFER_HANDLE - x = PyInt_FromLong(CL_BAD_BUFFER_HANDLE); - if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFER_HANDLE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_BUFFER_POINTER - x = PyInt_FromLong(CL_BAD_BUFFER_POINTER); - if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFER_POINTER", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_BUFFER_QUERY_SIZE - x = PyInt_FromLong(CL_BAD_BUFFER_QUERY_SIZE); - if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFER_QUERY_SIZE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_BUFFER_SIZE - x = PyInt_FromLong(CL_BAD_BUFFER_SIZE); - if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFER_SIZE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_BUFFER_SIZE_POINTER - x = PyInt_FromLong(CL_BAD_BUFFER_SIZE_POINTER); - if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFER_SIZE_POINTER", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_BUFFER_TYPE - x = PyInt_FromLong(CL_BAD_BUFFER_TYPE); - if (x == NULL || PyDict_SetItemString(d, "BAD_BUFFER_TYPE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_COMPRESSION_SCHEME - x = PyInt_FromLong(CL_BAD_COMPRESSION_SCHEME); - if (x == NULL || PyDict_SetItemString(d, "BAD_COMPRESSION_SCHEME", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_COMPRESSOR_HANDLE - x = PyInt_FromLong(CL_BAD_COMPRESSOR_HANDLE); - if (x == NULL || PyDict_SetItemString(d, "BAD_COMPRESSOR_HANDLE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_COMPRESSOR_HANDLE_POINTER - x = PyInt_FromLong(CL_BAD_COMPRESSOR_HANDLE_POINTER); - if (x == NULL || PyDict_SetItemString(d, "BAD_COMPRESSOR_HANDLE_POINTER", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_FRAME_SIZE - x = PyInt_FromLong(CL_BAD_FRAME_SIZE); - if (x == NULL || PyDict_SetItemString(d, "BAD_FRAME_SIZE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_FUNCTIONALITY - x = PyInt_FromLong(CL_BAD_FUNCTIONALITY); - if (x == NULL || PyDict_SetItemString(d, "BAD_FUNCTIONALITY", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_FUNCTION_POINTER - x = PyInt_FromLong(CL_BAD_FUNCTION_POINTER); - if (x == NULL || PyDict_SetItemString(d, "BAD_FUNCTION_POINTER", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_HEADER_SIZE - x = PyInt_FromLong(CL_BAD_HEADER_SIZE); - if (x == NULL || PyDict_SetItemString(d, "BAD_HEADER_SIZE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_INITIAL_VALUE - x = PyInt_FromLong(CL_BAD_INITIAL_VALUE); - if (x == NULL || PyDict_SetItemString(d, "BAD_INITIAL_VALUE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_INTERNAL_FORMAT - x = PyInt_FromLong(CL_BAD_INTERNAL_FORMAT); - if (x == NULL || PyDict_SetItemString(d, "BAD_INTERNAL_FORMAT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_LICENSE - x = PyInt_FromLong(CL_BAD_LICENSE); - if (x == NULL || PyDict_SetItemString(d, "BAD_LICENSE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_MIN_GT_MAX - x = PyInt_FromLong(CL_BAD_MIN_GT_MAX); - if (x == NULL || PyDict_SetItemString(d, "BAD_MIN_GT_MAX", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_NO_BUFFERSPACE - x = PyInt_FromLong(CL_BAD_NO_BUFFERSPACE); - if (x == NULL || PyDict_SetItemString(d, "BAD_NO_BUFFERSPACE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_NUMBER_OF_BLOCKS - x = PyInt_FromLong(CL_BAD_NUMBER_OF_BLOCKS); - if (x == NULL || PyDict_SetItemString(d, "BAD_NUMBER_OF_BLOCKS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_PARAM - x = PyInt_FromLong(CL_BAD_PARAM); - if (x == NULL || PyDict_SetItemString(d, "BAD_PARAM", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_PARAM_ID_POINTER - x = PyInt_FromLong(CL_BAD_PARAM_ID_POINTER); - if (x == NULL || PyDict_SetItemString(d, "BAD_PARAM_ID_POINTER", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_PARAM_TYPE - x = PyInt_FromLong(CL_BAD_PARAM_TYPE); - if (x == NULL || PyDict_SetItemString(d, "BAD_PARAM_TYPE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_POINTER - x = PyInt_FromLong(CL_BAD_POINTER); - if (x == NULL || PyDict_SetItemString(d, "BAD_POINTER", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_PVBUFFER - x = PyInt_FromLong(CL_BAD_PVBUFFER); - if (x == NULL || PyDict_SetItemString(d, "BAD_PVBUFFER", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_SCHEME_POINTER - x = PyInt_FromLong(CL_BAD_SCHEME_POINTER); - if (x == NULL || PyDict_SetItemString(d, "BAD_SCHEME_POINTER", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_STREAM_HEADER - x = PyInt_FromLong(CL_BAD_STREAM_HEADER); - if (x == NULL || PyDict_SetItemString(d, "BAD_STREAM_HEADER", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_STRING_POINTER - x = PyInt_FromLong(CL_BAD_STRING_POINTER); - if (x == NULL || PyDict_SetItemString(d, "BAD_STRING_POINTER", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BAD_TEXT_STRING_PTR - x = PyInt_FromLong(CL_BAD_TEXT_STRING_PTR); - if (x == NULL || PyDict_SetItemString(d, "BAD_TEXT_STRING_PTR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BEST_FIT - x = PyInt_FromLong(CL_BEST_FIT); - if (x == NULL || PyDict_SetItemString(d, "BEST_FIT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BIDIRECTIONAL - x = PyInt_FromLong(CL_BIDIRECTIONAL); - if (x == NULL || PyDict_SetItemString(d, "BIDIRECTIONAL", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BITRATE - x = PyInt_FromLong(CL_BITRATE); - if (x == NULL || PyDict_SetItemString(d, "BITRATE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BITRATE_POLICY - x = PyInt_FromLong(CL_BITRATE_POLICY); - if (x == NULL || PyDict_SetItemString(d, "BITRATE_POLICY", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BITRATE_TARGET - x = PyInt_FromLong(CL_BITRATE_TARGET); - if (x == NULL || PyDict_SetItemString(d, "BITRATE_TARGET", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BITS_PER_COMPONENT - x = PyInt_FromLong(CL_BITS_PER_COMPONENT); - if (x == NULL || PyDict_SetItemString(d, "BITS_PER_COMPONENT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BLENDING - x = PyInt_FromLong(CL_BLENDING); - if (x == NULL || PyDict_SetItemString(d, "BLENDING", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BLOCK_SIZE - x = PyInt_FromLong(CL_BLOCK_SIZE); - if (x == NULL || PyDict_SetItemString(d, "BLOCK_SIZE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BOTTOM_UP - x = PyInt_FromLong(CL_BOTTOM_UP); - if (x == NULL || PyDict_SetItemString(d, "BOTTOM_UP", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BUFFER_NOT_CREATED - x = PyInt_FromLong(CL_BUFFER_NOT_CREATED); - if (x == NULL || PyDict_SetItemString(d, "BUFFER_NOT_CREATED", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BUF_COMPRESSED - x = PyInt_FromLong(CL_BUF_COMPRESSED); - if (x == NULL || PyDict_SetItemString(d, "BUF_COMPRESSED", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BUF_DATA - x = PyInt_FromLong(CL_BUF_DATA); - if (x == NULL || PyDict_SetItemString(d, "BUF_DATA", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_BUF_FRAME - x = PyInt_FromLong(CL_BUF_FRAME); - if (x == NULL || PyDict_SetItemString(d, "BUF_FRAME", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_CHANNEL_POLICY - x = PyInt_FromLong(CL_CHANNEL_POLICY); - if (x == NULL || PyDict_SetItemString(d, "CHANNEL_POLICY", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_CHROMA_THRESHOLD - x = PyInt_FromLong(CL_CHROMA_THRESHOLD); - if (x == NULL || PyDict_SetItemString(d, "CHROMA_THRESHOLD", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_CODEC - x = PyInt_FromLong(CL_CODEC); - if (x == NULL || PyDict_SetItemString(d, "CODEC", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_COMPONENTS - x = PyInt_FromLong(CL_COMPONENTS); - if (x == NULL || PyDict_SetItemString(d, "COMPONENTS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_COMPRESSED_BUFFER_SIZE - x = PyInt_FromLong(CL_COMPRESSED_BUFFER_SIZE); - if (x == NULL || PyDict_SetItemString(d, "COMPRESSED_BUFFER_SIZE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_COMPRESSION_RATIO - x = PyInt_FromLong(CL_COMPRESSION_RATIO); - if (x == NULL || PyDict_SetItemString(d, "COMPRESSION_RATIO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_COMPRESSOR - x = PyInt_FromLong(CL_COMPRESSOR); - if (x == NULL || PyDict_SetItemString(d, "COMPRESSOR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_CONTINUOUS_BLOCK - x = PyInt_FromLong(CL_CONTINUOUS_BLOCK); - if (x == NULL || PyDict_SetItemString(d, "CONTINUOUS_BLOCK", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_CONTINUOUS_NONBLOCK - x = PyInt_FromLong(CL_CONTINUOUS_NONBLOCK); - if (x == NULL || PyDict_SetItemString(d, "CONTINUOUS_NONBLOCK", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_COSMO_CODEC_CONTROL - x = PyInt_FromLong(CL_COSMO_CODEC_CONTROL); - if (x == NULL || PyDict_SetItemString(d, "COSMO_CODEC_CONTROL", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_COSMO_NUM_PARAMS - x = PyInt_FromLong(CL_COSMO_NUM_PARAMS); - if (x == NULL || PyDict_SetItemString(d, "COSMO_NUM_PARAMS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_COSMO_VALUE_BASE - x = PyInt_FromLong(CL_COSMO_VALUE_BASE); - if (x == NULL || PyDict_SetItemString(d, "COSMO_VALUE_BASE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_COSMO_VIDEO_MANUAL_CONTROL - x = PyInt_FromLong(CL_COSMO_VIDEO_MANUAL_CONTROL); - if (x == NULL || PyDict_SetItemString(d, "COSMO_VIDEO_MANUAL_CONTROL", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_COSMO_VIDEO_TRANSFER_MODE - x = PyInt_FromLong(CL_COSMO_VIDEO_TRANSFER_MODE); - if (x == NULL || PyDict_SetItemString(d, "COSMO_VIDEO_TRANSFER_MODE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_DATA - x = PyInt_FromLong(CL_DATA); - if (x == NULL || PyDict_SetItemString(d, "DATA", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_DECOMPRESSOR - x = PyInt_FromLong(CL_DECOMPRESSOR); - if (x == NULL || PyDict_SetItemString(d, "DECOMPRESSOR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_DSO_ERROR - x = PyInt_FromLong(CL_DSO_ERROR); - if (x == NULL || PyDict_SetItemString(d, "DSO_ERROR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_EDGE_THRESHOLD - x = PyInt_FromLong(CL_EDGE_THRESHOLD); - if (x == NULL || PyDict_SetItemString(d, "EDGE_THRESHOLD", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_ENABLE_IMAGEINFO - x = PyInt_FromLong(CL_ENABLE_IMAGEINFO); - if (x == NULL || PyDict_SetItemString(d, "ENABLE_IMAGEINFO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_END_OF_SEQUENCE - x = PyInt_FromLong(CL_END_OF_SEQUENCE); - if (x == NULL || PyDict_SetItemString(d, "END_OF_SEQUENCE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_ENUM_VALUE - x = PyInt_FromLong(CL_ENUM_VALUE); - if (x == NULL || PyDict_SetItemString(d, "ENUM_VALUE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_EXACT_COMPRESSION_RATIO - x = PyInt_FromLong(CL_EXACT_COMPRESSION_RATIO); - if (x == NULL || PyDict_SetItemString(d, "EXACT_COMPRESSION_RATIO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_EXTERNAL_DEVICE - x = PyInt_FromLong((long) CL_EXTERNAL_DEVICE); - if (x == NULL || PyDict_SetItemString(d, "EXTERNAL_DEVICE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FLOATING_ENUM_VALUE - x = PyInt_FromLong(CL_FLOATING_ENUM_VALUE); - if (x == NULL || PyDict_SetItemString(d, "FLOATING_ENUM_VALUE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FLOATING_RANGE_VALUE - x = PyInt_FromLong(CL_FLOATING_RANGE_VALUE); - if (x == NULL || PyDict_SetItemString(d, "FLOATING_RANGE_VALUE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FORMAT - x = PyInt_FromLong(CL_FORMAT); - if (x == NULL || PyDict_SetItemString(d, "FORMAT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FORMAT_ABGR - x = PyInt_FromLong(CL_FORMAT_ABGR); - if (x == NULL || PyDict_SetItemString(d, "FORMAT_ABGR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FORMAT_BGR - x = PyInt_FromLong(CL_FORMAT_BGR); - if (x == NULL || PyDict_SetItemString(d, "FORMAT_BGR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FORMAT_BGR233 - x = PyInt_FromLong(CL_FORMAT_BGR233); - if (x == NULL || PyDict_SetItemString(d, "FORMAT_BGR233", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FORMAT_GRAYSCALE - x = PyInt_FromLong(CL_FORMAT_GRAYSCALE); - if (x == NULL || PyDict_SetItemString(d, "FORMAT_GRAYSCALE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FORMAT_MONO - x = PyInt_FromLong(CL_FORMAT_MONO); - if (x == NULL || PyDict_SetItemString(d, "FORMAT_MONO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FORMAT_RBG323 - x = PyInt_FromLong(CL_FORMAT_RBG323); - if (x == NULL || PyDict_SetItemString(d, "FORMAT_RBG323", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FORMAT_STEREO_INTERLEAVED - x = PyInt_FromLong(CL_FORMAT_STEREO_INTERLEAVED); - if (x == NULL || PyDict_SetItemString(d, "FORMAT_STEREO_INTERLEAVED", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FORMAT_XBGR - x = PyInt_FromLong(CL_FORMAT_XBGR); - if (x == NULL || PyDict_SetItemString(d, "FORMAT_XBGR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FORMAT_YCbCr - x = PyInt_FromLong(CL_FORMAT_YCbCr); - if (x == NULL || PyDict_SetItemString(d, "FORMAT_YCbCr", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FORMAT_YCbCr422 - x = PyInt_FromLong(CL_FORMAT_YCbCr422); - if (x == NULL || PyDict_SetItemString(d, "FORMAT_YCbCr422", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FORMAT_YCbCr422DC - x = PyInt_FromLong(CL_FORMAT_YCbCr422DC); - if (x == NULL || PyDict_SetItemString(d, "FORMAT_YCbCr422DC", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FRAME - x = PyInt_FromLong(CL_FRAME); - if (x == NULL || PyDict_SetItemString(d, "FRAME", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FRAMES_PER_CHUNK - x = PyInt_FromLong(CL_FRAMES_PER_CHUNK); - if (x == NULL || PyDict_SetItemString(d, "FRAMES_PER_CHUNK", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FRAME_BUFFER_SIZE - x = PyInt_FromLong(CL_FRAME_BUFFER_SIZE); - if (x == NULL || PyDict_SetItemString(d, "FRAME_BUFFER_SIZE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FRAME_BUFFER_SIZE_ZERO - x = PyInt_FromLong(CL_FRAME_BUFFER_SIZE_ZERO); - if (x == NULL || PyDict_SetItemString(d, "FRAME_BUFFER_SIZE_ZERO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FRAME_INDEX - x = PyInt_FromLong(CL_FRAME_INDEX); - if (x == NULL || PyDict_SetItemString(d, "FRAME_INDEX", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FRAME_RATE - x = PyInt_FromLong(CL_FRAME_RATE); - if (x == NULL || PyDict_SetItemString(d, "FRAME_RATE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FRAME_SIZE - x = PyInt_FromLong(CL_FRAME_SIZE); - if (x == NULL || PyDict_SetItemString(d, "FRAME_SIZE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_FRAME_TYPE - x = PyInt_FromLong(CL_FRAME_TYPE); - if (x == NULL || PyDict_SetItemString(d, "FRAME_TYPE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_G711_ALAW - x = PyInt_FromLong(CL_G711_ALAW); - if (x == NULL || PyDict_SetItemString(d, "G711_ALAW", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_G711_ALAW_SOFTWARE - x = PyInt_FromLong(CL_G711_ALAW_SOFTWARE); - if (x == NULL || PyDict_SetItemString(d, "G711_ALAW_SOFTWARE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_G711_ULAW - x = PyInt_FromLong(CL_G711_ULAW); - if (x == NULL || PyDict_SetItemString(d, "G711_ULAW", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_G711_ULAW_SOFTWARE - x = PyInt_FromLong(CL_G711_ULAW_SOFTWARE); - if (x == NULL || PyDict_SetItemString(d, "G711_ULAW_SOFTWARE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_GRAYSCALE - x = PyInt_FromLong(CL_GRAYSCALE); - if (x == NULL || PyDict_SetItemString(d, "GRAYSCALE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_HDCC - x = PyInt_FromLong(CL_HDCC); - if (x == NULL || PyDict_SetItemString(d, "HDCC", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_HDCC_SAMPLES_PER_TILE - x = PyInt_FromLong(CL_HDCC_SAMPLES_PER_TILE); - if (x == NULL || PyDict_SetItemString(d, "HDCC_SAMPLES_PER_TILE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_HDCC_SOFTWARE - x = PyInt_FromLong(CL_HDCC_SOFTWARE); - if (x == NULL || PyDict_SetItemString(d, "HDCC_SOFTWARE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_HDCC_TILE_THRESHOLD - x = PyInt_FromLong(CL_HDCC_TILE_THRESHOLD); - if (x == NULL || PyDict_SetItemString(d, "HDCC_TILE_THRESHOLD", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_HEADER_START_CODE - x = PyInt_FromLong(CL_HEADER_START_CODE); - if (x == NULL || PyDict_SetItemString(d, "HEADER_START_CODE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_IMAGEINFO_FIELDMASK - x = PyInt_FromLong(CL_IMAGEINFO_FIELDMASK); - if (x == NULL || PyDict_SetItemString(d, "IMAGEINFO_FIELDMASK", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_IMAGE_CROP_BOTTOM - x = PyInt_FromLong(CL_IMAGE_CROP_BOTTOM); - if (x == NULL || PyDict_SetItemString(d, "IMAGE_CROP_BOTTOM", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_IMAGE_CROP_LEFT - x = PyInt_FromLong(CL_IMAGE_CROP_LEFT); - if (x == NULL || PyDict_SetItemString(d, "IMAGE_CROP_LEFT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_IMAGE_CROP_RIGHT - x = PyInt_FromLong(CL_IMAGE_CROP_RIGHT); - if (x == NULL || PyDict_SetItemString(d, "IMAGE_CROP_RIGHT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_IMAGE_CROP_TOP - x = PyInt_FromLong(CL_IMAGE_CROP_TOP); - if (x == NULL || PyDict_SetItemString(d, "IMAGE_CROP_TOP", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_IMAGE_HEIGHT - x = PyInt_FromLong(CL_IMAGE_HEIGHT); - if (x == NULL || PyDict_SetItemString(d, "IMAGE_HEIGHT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_IMAGE_WIDTH - x = PyInt_FromLong(CL_IMAGE_WIDTH); - if (x == NULL || PyDict_SetItemString(d, "IMAGE_WIDTH", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_IMPACT_CODEC_CONTROL - x = PyInt_FromLong(CL_IMPACT_CODEC_CONTROL); - if (x == NULL || PyDict_SetItemString(d, "IMPACT_CODEC_CONTROL", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_IMPACT_FRAME_INTERLEAVE - x = PyInt_FromLong(CL_IMPACT_FRAME_INTERLEAVE); - if (x == NULL || PyDict_SetItemString(d, "IMPACT_FRAME_INTERLEAVE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_IMPACT_NUM_PARAMS - x = PyInt_FromLong(CL_IMPACT_NUM_PARAMS); - if (x == NULL || PyDict_SetItemString(d, "IMPACT_NUM_PARAMS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_INTERNAL_FORMAT - x = PyInt_FromLong(CL_INTERNAL_FORMAT); - if (x == NULL || PyDict_SetItemString(d, "INTERNAL_FORMAT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_INTERNAL_IMAGE_HEIGHT - x = PyInt_FromLong(CL_INTERNAL_IMAGE_HEIGHT); - if (x == NULL || PyDict_SetItemString(d, "INTERNAL_IMAGE_HEIGHT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_INTERNAL_IMAGE_WIDTH - x = PyInt_FromLong(CL_INTERNAL_IMAGE_WIDTH); - if (x == NULL || PyDict_SetItemString(d, "INTERNAL_IMAGE_WIDTH", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_INTRA - x = PyInt_FromLong(CL_INTRA); - if (x == NULL || PyDict_SetItemString(d, "INTRA", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_JPEG - x = PyInt_FromLong(CL_JPEG); - if (x == NULL || PyDict_SetItemString(d, "JPEG", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_JPEG_COSMO - x = PyInt_FromLong(CL_JPEG_COSMO); - if (x == NULL || PyDict_SetItemString(d, "JPEG_COSMO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_JPEG_ERROR - x = PyInt_FromLong(CL_JPEG_ERROR); - if (x == NULL || PyDict_SetItemString(d, "JPEG_ERROR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_JPEG_IMPACT - x = PyInt_FromLong(CL_JPEG_IMPACT); - if (x == NULL || PyDict_SetItemString(d, "JPEG_IMPACT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_JPEG_NUM_PARAMS - x = PyInt_FromLong(CL_JPEG_NUM_PARAMS); - if (x == NULL || PyDict_SetItemString(d, "JPEG_NUM_PARAMS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_JPEG_QUALITY_FACTOR - x = PyInt_FromLong(CL_JPEG_QUALITY_FACTOR); - if (x == NULL || PyDict_SetItemString(d, "JPEG_QUALITY_FACTOR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_JPEG_QUANTIZATION_TABLES - x = PyInt_FromLong(CL_JPEG_QUANTIZATION_TABLES); - if (x == NULL || PyDict_SetItemString(d, "JPEG_QUANTIZATION_TABLES", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_JPEG_SOFTWARE - x = PyInt_FromLong(CL_JPEG_SOFTWARE); - if (x == NULL || PyDict_SetItemString(d, "JPEG_SOFTWARE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_JPEG_STREAM_HEADERS - x = PyInt_FromLong(CL_JPEG_STREAM_HEADERS); - if (x == NULL || PyDict_SetItemString(d, "JPEG_STREAM_HEADERS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_KEYFRAME - x = PyInt_FromLong(CL_KEYFRAME); - if (x == NULL || PyDict_SetItemString(d, "KEYFRAME", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_KEYFRAME_DISTANCE - x = PyInt_FromLong(CL_KEYFRAME_DISTANCE); - if (x == NULL || PyDict_SetItemString(d, "KEYFRAME_DISTANCE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_LAST_FRAME_INDEX - x = PyInt_FromLong(CL_LAST_FRAME_INDEX); - if (x == NULL || PyDict_SetItemString(d, "LAST_FRAME_INDEX", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_LAYER - x = PyInt_FromLong(CL_LAYER); - if (x == NULL || PyDict_SetItemString(d, "LAYER", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_LUMA_THRESHOLD - x = PyInt_FromLong(CL_LUMA_THRESHOLD); - if (x == NULL || PyDict_SetItemString(d, "LUMA_THRESHOLD", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MAX_NUMBER_OF_AUDIO_ALGORITHMS - x = PyInt_FromLong(CL_MAX_NUMBER_OF_AUDIO_ALGORITHMS); - if (x == NULL || PyDict_SetItemString(d, "MAX_NUMBER_OF_AUDIO_ALGORITHMS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MAX_NUMBER_OF_FORMATS - x = PyInt_FromLong(CL_MAX_NUMBER_OF_FORMATS); - if (x == NULL || PyDict_SetItemString(d, "MAX_NUMBER_OF_FORMATS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MAX_NUMBER_OF_ORIGINAL_FORMATS - x = PyInt_FromLong(CL_MAX_NUMBER_OF_ORIGINAL_FORMATS); - if (x == NULL || PyDict_SetItemString(d, "MAX_NUMBER_OF_ORIGINAL_FORMATS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MAX_NUMBER_OF_PARAMS - x = PyInt_FromLong(CL_MAX_NUMBER_OF_PARAMS); - if (x == NULL || PyDict_SetItemString(d, "MAX_NUMBER_OF_PARAMS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MAX_NUMBER_OF_VIDEO_ALGORITHMS - x = PyInt_FromLong(CL_MAX_NUMBER_OF_VIDEO_ALGORITHMS); - if (x == NULL || PyDict_SetItemString(d, "MAX_NUMBER_OF_VIDEO_ALGORITHMS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MONO - x = PyInt_FromLong(CL_MONO); - if (x == NULL || PyDict_SetItemString(d, "MONO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_AUDIO_AWARE - x = PyInt_FromLong(CL_MPEG1_AUDIO_AWARE); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_AUDIO_AWARE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_AUDIO_LAYER - x = PyInt_FromLong(CL_MPEG1_AUDIO_LAYER); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_AUDIO_LAYER", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_AUDIO_LAYER_I - x = PyInt_FromLong(CL_MPEG1_AUDIO_LAYER_I); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_AUDIO_LAYER_I", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_AUDIO_LAYER_II - x = PyInt_FromLong(CL_MPEG1_AUDIO_LAYER_II); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_AUDIO_LAYER_II", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_AUDIO_MODE - x = PyInt_FromLong(CL_MPEG1_AUDIO_MODE); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_AUDIO_MODE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_AUDIO_MODE_DUAL - x = PyInt_FromLong(CL_MPEG1_AUDIO_MODE_DUAL); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_AUDIO_MODE_DUAL", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_AUDIO_MODE_JOINT - x = PyInt_FromLong(CL_MPEG1_AUDIO_MODE_JOINT); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_AUDIO_MODE_JOINT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_AUDIO_MODE_SINGLE - x = PyInt_FromLong(CL_MPEG1_AUDIO_MODE_SINGLE); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_AUDIO_MODE_SINGLE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_AUDIO_MODE_STEREO - x = PyInt_FromLong(CL_MPEG1_AUDIO_MODE_STEREO); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_AUDIO_MODE_STEREO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_AUDIO_SOFTWARE - x = PyInt_FromLong(CL_MPEG1_AUDIO_SOFTWARE); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_AUDIO_SOFTWARE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_END_OF_STREAM - x = PyInt_FromLong(CL_MPEG1_END_OF_STREAM); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_END_OF_STREAM", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_ERROR - x = PyInt_FromLong(CL_MPEG1_ERROR); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_ERROR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_NUM_PARAMS - x = PyInt_FromLong(CL_MPEG1_NUM_PARAMS); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_NUM_PARAMS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_VIDEO_M - x = PyInt_FromLong(CL_MPEG1_VIDEO_M); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_VIDEO_M", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_VIDEO_MAX_MOTION_VECTOR_LENGTH_B_X - x = PyInt_FromLong(CL_MPEG1_VIDEO_MAX_MOTION_VECTOR_LENGTH_B_X); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_VIDEO_MAX_MOTION_VECTOR_LENGTH_B_X", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_VIDEO_MAX_MOTION_VECTOR_LENGTH_B_Y - x = PyInt_FromLong(CL_MPEG1_VIDEO_MAX_MOTION_VECTOR_LENGTH_B_Y); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_VIDEO_MAX_MOTION_VECTOR_LENGTH_B_Y", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_VIDEO_MAX_MOTION_VECTOR_LENGTH_P_X - x = PyInt_FromLong(CL_MPEG1_VIDEO_MAX_MOTION_VECTOR_LENGTH_P_X); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_VIDEO_MAX_MOTION_VECTOR_LENGTH_P_X", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_VIDEO_MAX_MOTION_VECTOR_LENGTH_P_Y - x = PyInt_FromLong(CL_MPEG1_VIDEO_MAX_MOTION_VECTOR_LENGTH_P_Y); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_VIDEO_MAX_MOTION_VECTOR_LENGTH_P_Y", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_VIDEO_N - x = PyInt_FromLong(CL_MPEG1_VIDEO_N); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_VIDEO_N", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_VIDEO_SOFTNESS - x = PyInt_FromLong(CL_MPEG1_VIDEO_SOFTNESS); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_VIDEO_SOFTNESS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_VIDEO_SOFTNESS_MAXIMUM - x = PyInt_FromLong(CL_MPEG1_VIDEO_SOFTNESS_MAXIMUM); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_VIDEO_SOFTNESS_MAXIMUM", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_VIDEO_SOFTNESS_MEDIUM - x = PyInt_FromLong(CL_MPEG1_VIDEO_SOFTNESS_MEDIUM); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_VIDEO_SOFTNESS_MEDIUM", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_VIDEO_SOFTNESS_NONE - x = PyInt_FromLong(CL_MPEG1_VIDEO_SOFTNESS_NONE); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_VIDEO_SOFTNESS_NONE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG1_VIDEO_SOFTWARE - x = PyInt_FromLong(CL_MPEG1_VIDEO_SOFTWARE); - if (x == NULL || PyDict_SetItemString(d, "MPEG1_VIDEO_SOFTWARE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MPEG_VIDEO - x = PyInt_FromLong(CL_MPEG_VIDEO); - if (x == NULL || PyDict_SetItemString(d, "MPEG_VIDEO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MULTIRATE_AWARE - x = PyInt_FromLong(CL_MULTIRATE_AWARE); - if (x == NULL || PyDict_SetItemString(d, "MULTIRATE_AWARE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MVC1 - x = PyInt_FromLong(CL_MVC1); - if (x == NULL || PyDict_SetItemString(d, "MVC1", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MVC1_SOFTWARE - x = PyInt_FromLong(CL_MVC1_SOFTWARE); - if (x == NULL || PyDict_SetItemString(d, "MVC1_SOFTWARE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MVC2 - x = PyInt_FromLong(CL_MVC2); - if (x == NULL || PyDict_SetItemString(d, "MVC2", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MVC2_BLENDING - x = PyInt_FromLong(CL_MVC2_BLENDING); - if (x == NULL || PyDict_SetItemString(d, "MVC2_BLENDING", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MVC2_BLENDING_OFF - x = PyInt_FromLong(CL_MVC2_BLENDING_OFF); - if (x == NULL || PyDict_SetItemString(d, "MVC2_BLENDING_OFF", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MVC2_BLENDING_ON - x = PyInt_FromLong(CL_MVC2_BLENDING_ON); - if (x == NULL || PyDict_SetItemString(d, "MVC2_BLENDING_ON", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MVC2_CHROMA_THRESHOLD - x = PyInt_FromLong(CL_MVC2_CHROMA_THRESHOLD); - if (x == NULL || PyDict_SetItemString(d, "MVC2_CHROMA_THRESHOLD", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MVC2_EDGE_THRESHOLD - x = PyInt_FromLong(CL_MVC2_EDGE_THRESHOLD); - if (x == NULL || PyDict_SetItemString(d, "MVC2_EDGE_THRESHOLD", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MVC2_ERROR - x = PyInt_FromLong(CL_MVC2_ERROR); - if (x == NULL || PyDict_SetItemString(d, "MVC2_ERROR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MVC2_LUMA_THRESHOLD - x = PyInt_FromLong(CL_MVC2_LUMA_THRESHOLD); - if (x == NULL || PyDict_SetItemString(d, "MVC2_LUMA_THRESHOLD", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MVC2_SOFTWARE - x = PyInt_FromLong(CL_MVC2_SOFTWARE); - if (x == NULL || PyDict_SetItemString(d, "MVC2_SOFTWARE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MVC3_QUALITY_LEVEL - x = PyInt_FromLong(CL_MVC3_QUALITY_LEVEL); - if (x == NULL || PyDict_SetItemString(d, "MVC3_QUALITY_LEVEL", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_MVC3_SOFTWARE - x = PyInt_FromLong(CL_MVC3_SOFTWARE); - if (x == NULL || PyDict_SetItemString(d, "MVC3_SOFTWARE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_NEXT_NOT_AVAILABLE - x = PyInt_FromLong(CL_NEXT_NOT_AVAILABLE); - if (x == NULL || PyDict_SetItemString(d, "NEXT_NOT_AVAILABLE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_NOISE_MARGIN - x = PyInt_FromLong(CL_NOISE_MARGIN); - if (x == NULL || PyDict_SetItemString(d, "NOISE_MARGIN", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_NONE - x = PyInt_FromLong(CL_NONE); - if (x == NULL || PyDict_SetItemString(d, "NONE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_NUMBER_OF_FORMATS - x = PyInt_FromLong(CL_NUMBER_OF_FORMATS); - if (x == NULL || PyDict_SetItemString(d, "NUMBER_OF_FORMATS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_NUMBER_OF_FRAMES - x = PyInt_FromLong(CL_NUMBER_OF_FRAMES); - if (x == NULL || PyDict_SetItemString(d, "NUMBER_OF_FRAMES", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_NUMBER_OF_PARAMS - x = PyInt_FromLong(CL_NUMBER_OF_PARAMS); - if (x == NULL || PyDict_SetItemString(d, "NUMBER_OF_PARAMS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_NUMBER_OF_PARAMS_FREEZE - x = PyInt_FromLong(CL_NUMBER_OF_PARAMS_FREEZE); - if (x == NULL || PyDict_SetItemString(d, "NUMBER_OF_PARAMS_FREEZE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_NUMBER_OF_VIDEO_FORMATS - x = PyInt_FromLong(CL_NUMBER_OF_VIDEO_FORMATS); - if (x == NULL || PyDict_SetItemString(d, "NUMBER_OF_VIDEO_FORMATS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_ORIENTATION - x = PyInt_FromLong(CL_ORIENTATION); - if (x == NULL || PyDict_SetItemString(d, "ORIENTATION", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_ORIGINAL_FORMAT - x = PyInt_FromLong(CL_ORIGINAL_FORMAT); - if (x == NULL || PyDict_SetItemString(d, "ORIGINAL_FORMAT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_PARAM_OUT_OF_RANGE - x = PyInt_FromLong(CL_PARAM_OUT_OF_RANGE); - if (x == NULL || PyDict_SetItemString(d, "PARAM_OUT_OF_RANGE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_PIXEL_ASPECT - x = PyInt_FromLong(CL_PIXEL_ASPECT); - if (x == NULL || PyDict_SetItemString(d, "PIXEL_ASPECT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_PREDICTED - x = PyInt_FromLong(CL_PREDICTED); - if (x == NULL || PyDict_SetItemString(d, "PREDICTED", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_PREROLL - x = PyInt_FromLong(CL_PREROLL); - if (x == NULL || PyDict_SetItemString(d, "PREROLL", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_QUALITY_FACTOR - x = PyInt_FromLong(CL_QUALITY_FACTOR); - if (x == NULL || PyDict_SetItemString(d, "QUALITY_FACTOR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_QUALITY_LEVEL - x = PyInt_FromLong(CL_QUALITY_LEVEL); - if (x == NULL || PyDict_SetItemString(d, "QUALITY_LEVEL", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_QUALITY_SPATIAL - x = PyInt_FromLong(CL_QUALITY_SPATIAL); - if (x == NULL || PyDict_SetItemString(d, "QUALITY_SPATIAL", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_QUALITY_TEMPORAL - x = PyInt_FromLong(CL_QUALITY_TEMPORAL); - if (x == NULL || PyDict_SetItemString(d, "QUALITY_TEMPORAL", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_QUANTIZATION_TABLES - x = PyInt_FromLong(CL_QUANTIZATION_TABLES); - if (x == NULL || PyDict_SetItemString(d, "QUANTIZATION_TABLES", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_RANGE_VALUE - x = PyInt_FromLong(CL_RANGE_VALUE); - if (x == NULL || PyDict_SetItemString(d, "RANGE_VALUE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_RGB - x = PyInt_FromLong(CL_RGB); - if (x == NULL || PyDict_SetItemString(d, "RGB", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_RGB332 - x = PyInt_FromLong(CL_RGB332); - if (x == NULL || PyDict_SetItemString(d, "RGB332", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_RGB8 - x = PyInt_FromLong(CL_RGB8); - if (x == NULL || PyDict_SetItemString(d, "RGB8", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_RGBA - x = PyInt_FromLong(CL_RGBA); - if (x == NULL || PyDict_SetItemString(d, "RGBA", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_RGBX - x = PyInt_FromLong(CL_RGBX); - if (x == NULL || PyDict_SetItemString(d, "RGBX", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_RLE - x = PyInt_FromLong(CL_RLE); - if (x == NULL || PyDict_SetItemString(d, "RLE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_RLE24 - x = PyInt_FromLong(CL_RLE24); - if (x == NULL || PyDict_SetItemString(d, "RLE24", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_RLE24_SOFTWARE - x = PyInt_FromLong(CL_RLE24_SOFTWARE); - if (x == NULL || PyDict_SetItemString(d, "RLE24_SOFTWARE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_RLE_SOFTWARE - x = PyInt_FromLong(CL_RLE_SOFTWARE); - if (x == NULL || PyDict_SetItemString(d, "RLE_SOFTWARE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_RTR - x = PyInt_FromLong(CL_RTR); - if (x == NULL || PyDict_SetItemString(d, "RTR", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_RTR1 - x = PyInt_FromLong(CL_RTR1); - if (x == NULL || PyDict_SetItemString(d, "RTR1", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_RTR_QUALITY_LEVEL - x = PyInt_FromLong(CL_RTR_QUALITY_LEVEL); - if (x == NULL || PyDict_SetItemString(d, "RTR_QUALITY_LEVEL", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_SAMPLES_PER_TILE - x = PyInt_FromLong(CL_SAMPLES_PER_TILE); - if (x == NULL || PyDict_SetItemString(d, "SAMPLES_PER_TILE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_SCHEME_BUSY - x = PyInt_FromLong(CL_SCHEME_BUSY); - if (x == NULL || PyDict_SetItemString(d, "SCHEME_BUSY", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_SCHEME_NOT_AVAILABLE - x = PyInt_FromLong(CL_SCHEME_NOT_AVAILABLE); - if (x == NULL || PyDict_SetItemString(d, "SCHEME_NOT_AVAILABLE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_SPEED - x = PyInt_FromLong(CL_SPEED); - if (x == NULL || PyDict_SetItemString(d, "SPEED", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_STEREO_INTERLEAVED - x = PyInt_FromLong(CL_STEREO_INTERLEAVED); - if (x == NULL || PyDict_SetItemString(d, "STEREO_INTERLEAVED", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_STREAM_HEADERS - x = PyInt_FromLong(CL_STREAM_HEADERS); - if (x == NULL || PyDict_SetItemString(d, "STREAM_HEADERS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_TILE_THRESHOLD - x = PyInt_FromLong(CL_TILE_THRESHOLD); - if (x == NULL || PyDict_SetItemString(d, "TILE_THRESHOLD", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_TOP_DOWN - x = PyInt_FromLong(CL_TOP_DOWN); - if (x == NULL || PyDict_SetItemString(d, "TOP_DOWN", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_ULAW - x = PyInt_FromLong(CL_ULAW); - if (x == NULL || PyDict_SetItemString(d, "ULAW", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_UNCOMPRESSED - x = PyInt_FromLong(CL_UNCOMPRESSED); - if (x == NULL || PyDict_SetItemString(d, "UNCOMPRESSED", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_UNCOMPRESSED_AUDIO - x = PyInt_FromLong(CL_UNCOMPRESSED_AUDIO); - if (x == NULL || PyDict_SetItemString(d, "UNCOMPRESSED_AUDIO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_UNCOMPRESSED_VIDEO - x = PyInt_FromLong(CL_UNCOMPRESSED_VIDEO); - if (x == NULL || PyDict_SetItemString(d, "UNCOMPRESSED_VIDEO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_UNKNOWN_SCHEME - x = PyInt_FromLong(CL_UNKNOWN_SCHEME); - if (x == NULL || PyDict_SetItemString(d, "UNKNOWN_SCHEME", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_VIDEO - x = PyInt_FromLong(CL_VIDEO); - if (x == NULL || PyDict_SetItemString(d, "VIDEO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_Y - x = PyInt_FromLong(CL_Y); - if (x == NULL || PyDict_SetItemString(d, "Y", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_YCbCr - x = PyInt_FromLong(CL_YCbCr); - if (x == NULL || PyDict_SetItemString(d, "YCbCr", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_YCbCr422 - x = PyInt_FromLong(CL_YCbCr422); - if (x == NULL || PyDict_SetItemString(d, "YCbCr422", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_YCbCr422DC - x = PyInt_FromLong(CL_YCbCr422DC); - if (x == NULL || PyDict_SetItemString(d, "YCbCr422DC", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_YCbCr422HC - x = PyInt_FromLong(CL_YCbCr422HC); - if (x == NULL || PyDict_SetItemString(d, "YCbCr422HC", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_YUV - x = PyInt_FromLong(CL_YUV); - if (x == NULL || PyDict_SetItemString(d, "YUV", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_YUV422 - x = PyInt_FromLong(CL_YUV422); - if (x == NULL || PyDict_SetItemString(d, "YUV422", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_YUV422DC - x = PyInt_FromLong(CL_YUV422DC); - if (x == NULL || PyDict_SetItemString(d, "YUV422DC", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef CL_YUV422HC - x = PyInt_FromLong(CL_YUV422HC); - if (x == NULL || PyDict_SetItemString(d, "YUV422HC", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef AWCMP_STEREO - x = PyInt_FromLong(AWCMP_STEREO); - if (x == NULL || PyDict_SetItemString(d, "AWCMP_STEREO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef AWCMP_JOINT_STEREO - x = PyInt_FromLong(AWCMP_JOINT_STEREO); - if (x == NULL || PyDict_SetItemString(d, "AWCMP_JOINT_STEREO", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef AWCMP_INDEPENDENT - x = PyInt_FromLong(AWCMP_INDEPENDENT); - if (x == NULL || PyDict_SetItemString(d, "AWCMP_INDEPENDENT", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef AWCMP_FIXED_RATE - x = PyInt_FromLong(AWCMP_FIXED_RATE); - if (x == NULL || PyDict_SetItemString(d, "AWCMP_FIXED_RATE", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef AWCMP_CONST_QUAL - x = PyInt_FromLong(AWCMP_CONST_QUAL); - if (x == NULL || PyDict_SetItemString(d, "AWCMP_CONST_QUAL", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef AWCMP_LOSSLESS - x = PyInt_FromLong(AWCMP_LOSSLESS); - if (x == NULL || PyDict_SetItemString(d, "AWCMP_LOSSLESS", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef AWCMP_MPEG_LAYER_I - x = PyInt_FromLong(AWCMP_MPEG_LAYER_I); - if (x == NULL || PyDict_SetItemString(d, "AWCMP_MPEG_LAYER_I", x) < 0) - return; - Py_DECREF(x); -#endif -#ifdef AWCMP_MPEG_LAYER_II - x = PyInt_FromLong(AWCMP_MPEG_LAYER_II); - if (x == NULL || PyDict_SetItemString(d, "AWCMP_MPEG_LAYER_II", x) < 0) - return; - Py_DECREF(x); -#endif - - (void) clSetErrorHandler(cl_ErrorHandler); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/cmathmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/cmathmodule.c deleted file mode 100644 index 9d767ab0..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/cmathmodule.c +++ /dev/null @@ -1,404 +0,0 @@ -/* Complex math module */ - -/* much code borrowed from mathmodule.c */ - -#include "Python.h" - -#ifndef M_PI -#define M_PI (3.141592653589793239) -#endif - -/* First, the C functions that do the real work */ - -/* constants */ -static Py_complex c_one = {1., 0.}; -static Py_complex c_half = {0.5, 0.}; -static Py_complex c_i = {0., 1.}; -static Py_complex c_halfi = {0., 0.5}; - -/* forward declarations */ -static Py_complex c_log(Py_complex); -static Py_complex c_prodi(Py_complex); -static Py_complex c_sqrt(Py_complex); - - -static Py_complex -c_acos(Py_complex x) -{ - return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i, - c_sqrt(c_diff(c_one,c_prod(x,x)))))))); -} - -PyDoc_STRVAR(c_acos_doc, -"acos(x)\n" -"\n" -"Return the arc cosine of x."); - - -static Py_complex -c_acosh(Py_complex x) -{ - Py_complex z; - z = c_sqrt(c_half); - z = c_log(c_prod(z, c_sum(c_sqrt(c_sum(x,c_one)), - c_sqrt(c_diff(x,c_one))))); - return c_sum(z, z); -} - -PyDoc_STRVAR(c_acosh_doc, -"acosh(x)\n" -"\n" -"Return the hyperbolic arccosine of x."); - - -static Py_complex -c_asin(Py_complex x) -{ - /* -i * log[(sqrt(1-x**2) + i*x] */ - const Py_complex squared = c_prod(x, x); - const Py_complex sqrt_1_minus_x_sq = c_sqrt(c_diff(c_one, squared)); - return c_neg(c_prodi(c_log( - c_sum(sqrt_1_minus_x_sq, c_prodi(x)) - ) ) ); -} - -PyDoc_STRVAR(c_asin_doc, -"asin(x)\n" -"\n" -"Return the arc sine of x."); - - -static Py_complex -c_asinh(Py_complex x) -{ - Py_complex z; - z = c_sqrt(c_half); - z = c_log(c_prod(z, c_sum(c_sqrt(c_sum(x, c_i)), - c_sqrt(c_diff(x, c_i))))); - return c_sum(z, z); -} - -PyDoc_STRVAR(c_asinh_doc, -"asinh(x)\n" -"\n" -"Return the hyperbolic arc sine of x."); - - -static Py_complex -c_atan(Py_complex x) -{ - return c_prod(c_halfi,c_log(c_quot(c_sum(c_i,x),c_diff(c_i,x)))); -} - -PyDoc_STRVAR(c_atan_doc, -"atan(x)\n" -"\n" -"Return the arc tangent of x."); - - -static Py_complex -c_atanh(Py_complex x) -{ - return c_prod(c_half,c_log(c_quot(c_sum(c_one,x),c_diff(c_one,x)))); -} - -PyDoc_STRVAR(c_atanh_doc, -"atanh(x)\n" -"\n" -"Return the hyperbolic arc tangent of x."); - - -static Py_complex -c_cos(Py_complex x) -{ - Py_complex r; - r.real = cos(x.real)*cosh(x.imag); - r.imag = -sin(x.real)*sinh(x.imag); - return r; -} - -PyDoc_STRVAR(c_cos_doc, -"cos(x)\n" -"n" -"Return the cosine of x."); - - -static Py_complex -c_cosh(Py_complex x) -{ - Py_complex r; - r.real = cos(x.imag)*cosh(x.real); - r.imag = sin(x.imag)*sinh(x.real); - return r; -} - -PyDoc_STRVAR(c_cosh_doc, -"cosh(x)\n" -"n" -"Return the hyperbolic cosine of x."); - - -static Py_complex -c_exp(Py_complex x) -{ - Py_complex r; - double l = exp(x.real); - r.real = l*cos(x.imag); - r.imag = l*sin(x.imag); - return r; -} - -PyDoc_STRVAR(c_exp_doc, -"exp(x)\n" -"\n" -"Return the exponential value e**x."); - - -static Py_complex -c_log(Py_complex x) -{ - Py_complex r; - double l = hypot(x.real,x.imag); - r.imag = atan2(x.imag, x.real); - r.real = log(l); - return r; -} - -PyDoc_STRVAR(c_log_doc, -"log(x)\n" -"\n" -"Return the natural logarithm of x."); - - -static Py_complex -c_log10(Py_complex x) -{ - Py_complex r; - double l = hypot(x.real,x.imag); - r.imag = atan2(x.imag, x.real)/log(10.); - r.real = log10(l); - return r; -} - -PyDoc_STRVAR(c_log10_doc, -"log10(x)\n" -"\n" -"Return the base-10 logarithm of x."); - - -/* internal function not available from Python */ -static Py_complex -c_prodi(Py_complex x) -{ - Py_complex r; - r.real = -x.imag; - r.imag = x.real; - return r; -} - - -static Py_complex -c_sin(Py_complex x) -{ - Py_complex r; - r.real = sin(x.real) * cosh(x.imag); - r.imag = cos(x.real) * sinh(x.imag); - return r; -} - -PyDoc_STRVAR(c_sin_doc, -"sin(x)\n" -"\n" -"Return the sine of x."); - - -static Py_complex -c_sinh(Py_complex x) -{ - Py_complex r; - r.real = cos(x.imag) * sinh(x.real); - r.imag = sin(x.imag) * cosh(x.real); - return r; -} - -PyDoc_STRVAR(c_sinh_doc, -"sinh(x)\n" -"\n" -"Return the hyperbolic sine of x."); - - -static Py_complex -c_sqrt(Py_complex x) -{ - Py_complex r; - double s,d; - if (x.real == 0. && x.imag == 0.) - r = x; - else { - s = sqrt(0.5*(fabs(x.real) + hypot(x.real,x.imag))); - d = 0.5*x.imag/s; - if (x.real > 0.) { - r.real = s; - r.imag = d; - } - else if (x.imag >= 0.) { - r.real = d; - r.imag = s; - } - else { - r.real = -d; - r.imag = -s; - } - } - return r; -} - -PyDoc_STRVAR(c_sqrt_doc, -"sqrt(x)\n" -"\n" -"Return the square root of x."); - - -static Py_complex -c_tan(Py_complex x) -{ - Py_complex r; - double sr,cr,shi,chi; - double rs,is,rc,ic; - double d; - sr = sin(x.real); - cr = cos(x.real); - shi = sinh(x.imag); - chi = cosh(x.imag); - rs = sr * chi; - is = cr * shi; - rc = cr * chi; - ic = -sr * shi; - d = rc*rc + ic * ic; - r.real = (rs*rc + is*ic) / d; - r.imag = (is*rc - rs*ic) / d; - return r; -} - -PyDoc_STRVAR(c_tan_doc, -"tan(x)\n" -"\n" -"Return the tangent of x."); - - -static Py_complex -c_tanh(Py_complex x) -{ - Py_complex r; - double si,ci,shr,chr; - double rs,is,rc,ic; - double d; - si = sin(x.imag); - ci = cos(x.imag); - shr = sinh(x.real); - chr = cosh(x.real); - rs = ci * shr; - is = si * chr; - rc = ci * chr; - ic = si * shr; - d = rc*rc + ic*ic; - r.real = (rs*rc + is*ic) / d; - r.imag = (is*rc - rs*ic) / d; - return r; -} - -PyDoc_STRVAR(c_tanh_doc, -"tanh(x)\n" -"\n" -"Return the hyperbolic tangent of x."); - - -/* And now the glue to make them available from Python: */ - -static PyObject * -math_error(void) -{ - if (errno == EDOM) - PyErr_SetString(PyExc_ValueError, "math domain error"); - else if (errno == ERANGE) - PyErr_SetString(PyExc_OverflowError, "math range error"); - else /* Unexpected math error */ - PyErr_SetFromErrno(PyExc_ValueError); - return NULL; -} - -static PyObject * -math_1(PyObject *args, Py_complex (*func)(Py_complex)) -{ - Py_complex x; - if (!PyArg_ParseTuple(args, "D", &x)) - return NULL; - errno = 0; - PyFPE_START_PROTECT("complex function", return 0) - x = (*func)(x); - PyFPE_END_PROTECT(x) - Py_ADJUST_ERANGE2(x.real, x.imag); - if (errno != 0) - return math_error(); - else - return PyComplex_FromCComplex(x); -} - -#define FUNC1(stubname, func) \ - static PyObject * stubname(PyObject *self, PyObject *args) { \ - return math_1(args, func); \ - } - -FUNC1(cmath_acos, c_acos) -FUNC1(cmath_acosh, c_acosh) -FUNC1(cmath_asin, c_asin) -FUNC1(cmath_asinh, c_asinh) -FUNC1(cmath_atan, c_atan) -FUNC1(cmath_atanh, c_atanh) -FUNC1(cmath_cos, c_cos) -FUNC1(cmath_cosh, c_cosh) -FUNC1(cmath_exp, c_exp) -FUNC1(cmath_log, c_log) -FUNC1(cmath_log10, c_log10) -FUNC1(cmath_sin, c_sin) -FUNC1(cmath_sinh, c_sinh) -FUNC1(cmath_sqrt, c_sqrt) -FUNC1(cmath_tan, c_tan) -FUNC1(cmath_tanh, c_tanh) - - -PyDoc_STRVAR(module_doc, -"This module is always available. It provides access to mathematical\n" -"functions for complex numbers."); - -static PyMethodDef cmath_methods[] = { - {"acos", cmath_acos, METH_VARARGS, c_acos_doc}, - {"acosh", cmath_acosh, METH_VARARGS, c_acosh_doc}, - {"asin", cmath_asin, METH_VARARGS, c_asin_doc}, - {"asinh", cmath_asinh, METH_VARARGS, c_asinh_doc}, - {"atan", cmath_atan, METH_VARARGS, c_atan_doc}, - {"atanh", cmath_atanh, METH_VARARGS, c_atanh_doc}, - {"cos", cmath_cos, METH_VARARGS, c_cos_doc}, - {"cosh", cmath_cosh, METH_VARARGS, c_cosh_doc}, - {"exp", cmath_exp, METH_VARARGS, c_exp_doc}, - {"log", cmath_log, METH_VARARGS, c_log_doc}, - {"log10", cmath_log10, METH_VARARGS, c_log10_doc}, - {"sin", cmath_sin, METH_VARARGS, c_sin_doc}, - {"sinh", cmath_sinh, METH_VARARGS, c_sinh_doc}, - {"sqrt", cmath_sqrt, METH_VARARGS, c_sqrt_doc}, - {"tan", cmath_tan, METH_VARARGS, c_tan_doc}, - {"tanh", cmath_tanh, METH_VARARGS, c_tanh_doc}, - {NULL, NULL} /* sentinel */ -}; - -PyMODINIT_FUNC -initcmath(void) -{ - PyObject *m; - - m = Py_InitModule3("cmath", cmath_methods, module_doc); - - PyModule_AddObject(m, "pi", - PyFloat_FromDouble(atan(1.0) * 4.0)); - PyModule_AddObject(m, "e", PyFloat_FromDouble(exp(1.0))); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/config.c.in b/SDKs/XPlatform/Cypython-2.3.3/Modules/config.c.in deleted file mode 100644 index 0b782021..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/config.c.in +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- C -*- *********************************************** -Copyright (c) 2000, BeOpen.com. -Copyright (c) 1995-2000, Corporation for National Research Initiatives. -Copyright (c) 1990-1995, Stichting Mathematisch Centrum. -All rights reserved. - -See the file "Misc/COPYRIGHT" for information on usage and -redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. -******************************************************************/ - -/* Module configuration */ - -/* !!! !!! !!! This file is edited by the makesetup script !!! !!! !!! */ - -/* This file contains the table of built-in modules. - See init_builtin() in import.c. */ - -#include "Python.h" - - -/* -- ADDMODULE MARKER 1 -- */ - -extern void PyMarshal_Init(void); -extern void initimp(void); -extern void initgc(void); - -struct _inittab _PyImport_Inittab[] = { - -/* -- ADDMODULE MARKER 2 -- */ - - /* This module lives in marshal.c */ - {"marshal", PyMarshal_Init}, - - /* This lives in import.c */ - {"imp", initimp}, - - /* These entries are here for sys.builtin_module_names */ - {"__main__", NULL}, - {"__builtin__", NULL}, - {"sys", NULL}, - {"exceptions", NULL}, - - /* This lives in gcmodule.c */ - {"gc", initgc}, - - /* Sentinel */ - {0, 0} -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/cryptmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/cryptmodule.c deleted file mode 100644 index 757166d7..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/cryptmodule.c +++ /dev/null @@ -1,44 +0,0 @@ -/* cryptmodule.c - by Steve Majewski - */ - -#include "Python.h" - -#include - - -/* Module crypt */ - - -static PyObject *crypt_crypt(PyObject *self, PyObject *args) -{ - char *word, *salt; - extern char * crypt(const char *, const char *); - - if (!PyArg_ParseTuple(args, "ss:crypt", &word, &salt)) { - return NULL; - } - /* On some platforms (AtheOS) crypt returns NULL for an invalid - salt. Return None in that case. XXX Maybe raise an exception? */ - return Py_BuildValue("s", crypt(word, salt)); - -} - -PyDoc_STRVAR(crypt_crypt__doc__, -"crypt(word, salt) -> string\n\ -word will usually be a user's password. salt is a 2-character string\n\ -which will be used to select one of 4096 variations of DES. The characters\n\ -in salt must be either \".\", \"/\", or an alphanumeric character. Returns\n\ -the hashed password as a string, which will be composed of characters from\n\ -the same alphabet as the salt."); - - -static PyMethodDef crypt_methods[] = { - {"crypt", crypt_crypt, METH_VARARGS, crypt_crypt__doc__}, - {NULL, NULL} /* sentinel */ -}; - -PyMODINIT_FUNC -initcrypt(void) -{ - Py_InitModule("crypt", crypt_methods); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/cstubs b/SDKs/XPlatform/Cypython-2.3.3/Modules/cstubs deleted file mode 100644 index 8448ae24..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/cstubs +++ /dev/null @@ -1,1364 +0,0 @@ - -/* -Input used to generate the Python module "glmodule.c". -The stub generator is a Python script called "cgen.py". - -Each definition must be contained on one line: - - - - can be: void, short, long (XXX maybe others?) - - can be: char, string, short, float, long, or double - string indicates a null terminated string; - if is char and begins with a *, the * is stripped - and is changed into string - - has the form or [] - where can be - s: arg is sent - r: arg is received (arg is a pointer) - and can be (N and I are numbers): - N - argI - retval - N*argI - N*I - N*retval - In the case where the subscript consists of two parts - separated by *, the first part is the width of the matrix, and - the second part is the length of the matrix. This order is - opposite from the order used in C to declare a two-dimensional - matrix. -*/ - -/* - * An attempt has been made to make this module switch threads on qread - * calls. It is far from safe, though. - */ - -#include -#include - -#ifdef __sgi -extern int devport(); -extern int textwritemask(); -extern int pagewritemask(); -extern int gewrite(); -extern int gettp(); -#endif - -#include "Python.h" -#include "cgensupport.h" - -/* -Some stubs are too complicated for the stub generator. -We can include manually written versions of them here. -A line starting with '%' gives the name of the function so the stub -generator can include it in the table of functions. -*/ - -% qread - -static PyObject * -gl_qread(self, args) - PyObject *self; - PyObject *args; -{ - long retval; - short arg1 ; - Py_BEGIN_ALLOW_THREADS - retval = qread( & arg1 ); - Py_END_ALLOW_THREADS - { PyObject *v = PyTuple_New( 2 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewlongobject(retval)); - PyTuple_SetItem(v, 1, mknewshortobject(arg1)); - return v; - } -} - - -/* -varray -- an array of v.. calls. -The argument is an array (maybe list or tuple) of points. -Each point must be a tuple or list of coordinates (x, y, z). -The points may be 2- or 3-dimensional but must all have the -same dimension. Float and int values may be mixed however. -The points are always converted to 3D double precision points -by assuming z=0.0 if necessary (as indicated in the man page), -and for each point v3d() is called. -*/ - -% varray - -static PyObject * -gl_varray(self, args) - PyObject *self; - PyObject *args; -{ - PyObject *v, *w=NULL; - int i, n, width; - double vec[3]; - PyObject * (*getitem)(PyObject *, int); - - if (!PyArg_GetObject(args, 1, 0, &v)) - return NULL; - - if (PyList_Check(v)) { - n = PyList_Size(v); - getitem = PyList_GetItem; - } - else if (PyTuple_Check(v)) { - n = PyTuple_Size(v); - getitem = PyTuple_GetItem; - } - else { - PyErr_BadArgument(); - return NULL; - } - - if (n == 0) { - Py_INCREF(Py_None); - return Py_None; - } - if (n > 0) - w = (*getitem)(v, 0); - - width = 0; - if (w == NULL) { - } - else if (PyList_Check(w)) { - width = PyList_Size(w); - } - else if (PyTuple_Check(w)) { - width = PyTuple_Size(w); - } - - switch (width) { - case 2: - vec[2] = 0.0; - /* Fall through */ - case 3: - break; - default: - PyErr_BadArgument(); - return NULL; - } - - for (i = 0; i < n; i++) { - w = (*getitem)(v, i); - if (!PyArg_GetDoubleArray(w, 1, 0, width, vec)) - return NULL; - v3d(vec); - } - - Py_INCREF(Py_None); - return Py_None; -} - -/* -vnarray, nvarray -- an array of n3f and v3f calls. -The argument is an array (list or tuple) of pairs of points and normals. -Each pair is a tuple (NOT a list) of a point and a normal for that point. -Each point or normal must be a tuple (NOT a list) of coordinates (x, y, z). -Three coordinates must be given. Float and int values may be mixed. -For each pair, n3f() is called for the normal, and then v3f() is called -for the vector. - -vnarray and nvarray differ only in the order of the vector and normal in -the pair: vnarray expects (v, n) while nvarray expects (n, v). -*/ - -static PyObject *gen_nvarray(); /* Forward */ - -% nvarray - -static PyObject * -gl_nvarray(self, args) - PyObject *self; - PyObject *args; -{ - return gen_nvarray(args, 0); -} - -% vnarray - -static PyObject * -gl_vnarray(self, args) - PyObject *self; - PyObject *args; -{ - return gen_nvarray(args, 1); -} - -/* Generic, internal version of {nv,nv}array: inorm indicates the - argument order, 0: normal first, 1: vector first. */ - -static PyObject * -gen_nvarray(args, inorm) - PyObject *args; - int inorm; -{ - PyObject *v, *w, *wnorm, *wvec; - int i, n; - float norm[3], vec[3]; - PyObject * (*getitem)(PyObject *, int); - - if (!PyArg_GetObject(args, 1, 0, &v)) - return NULL; - - if (PyList_Check(v)) { - n = PyList_Size(v); - getitem = PyList_GetItem; - } - else if (PyTuple_Check(v)) { - n = PyTuple_Size(v); - getitem = PyTuple_GetItem; - } - else { - PyErr_BadArgument(); - return NULL; - } - - for (i = 0; i < n; i++) { - w = (*getitem)(v, i); - if (!PyTuple_Check(w) || PyTuple_Size(w) != 2) { - PyErr_BadArgument(); - return NULL; - } - wnorm = PyTuple_GetItem(w, inorm); - wvec = PyTuple_GetItem(w, 1 - inorm); - if (!PyArg_GetFloatArray(wnorm, 1, 0, 3, norm) || - !PyArg_GetFloatArray(wvec, 1, 0, 3, vec)) - return NULL; - n3f(norm); - v3f(vec); - } - - Py_INCREF(Py_None); - return Py_None; -} - -/* nurbssurface(s_knots[], t_knots[], ctl[][], s_order, t_order, type). - The dimensions of ctl[] are computed as follows: - [len(s_knots) - s_order], [len(t_knots) - t_order] -*/ - -% nurbssurface - -static PyObject * -gl_nurbssurface(self, args) - PyObject *self; - PyObject *args; -{ - long arg1 ; - double * arg2 ; - long arg3 ; - double * arg4 ; - double *arg5 ; - long arg6 ; - long arg7 ; - long arg8 ; - long ncoords; - long s_byte_stride, t_byte_stride; - long s_nctl, t_nctl; - long s, t; - PyObject *v, *w, *pt; - double *pnext; - if (!PyArg_GetLongArraySize(args, 6, 0, &arg1)) - return NULL; - if ((arg2 = PyMem_NEW(double, arg1 )) == NULL) { - return PyErr_NoMemory(); - } - if (!PyArg_GetDoubleArray(args, 6, 0, arg1 , arg2)) - return NULL; - if (!PyArg_GetLongArraySize(args, 6, 1, &arg3)) - return NULL; - if ((arg4 = PyMem_NEW(double, arg3 )) == NULL) { - return PyErr_NoMemory(); - } - if (!PyArg_GetDoubleArray(args, 6, 1, arg3 , arg4)) - return NULL; - if (!PyArg_GetLong(args, 6, 3, &arg6)) - return NULL; - if (!PyArg_GetLong(args, 6, 4, &arg7)) - return NULL; - if (!PyArg_GetLong(args, 6, 5, &arg8)) - return NULL; - if (arg8 == N_XYZ) - ncoords = 3; - else if (arg8 == N_XYZW) - ncoords = 4; - else { - PyErr_BadArgument(); - return NULL; - } - s_nctl = arg1 - arg6; - t_nctl = arg3 - arg7; - if (!PyArg_GetObject(args, 6, 2, &v)) - return NULL; - if (!PyList_Check(v) || PyList_Size(v) != s_nctl) { - PyErr_BadArgument(); - return NULL; - } - if ((arg5 = PyMem_NEW(double, s_nctl*t_nctl*ncoords )) == NULL) { - return PyErr_NoMemory(); - } - pnext = arg5; - for (s = 0; s < s_nctl; s++) { - w = PyList_GetItem(v, s); - if (w == NULL || !PyList_Check(w) || - PyList_Size(w) != t_nctl) { - PyErr_BadArgument(); - return NULL; - } - for (t = 0; t < t_nctl; t++) { - pt = PyList_GetItem(w, t); - if (!PyArg_GetDoubleArray(pt, 1, 0, ncoords, pnext)) - return NULL; - pnext += ncoords; - } - } - s_byte_stride = sizeof(double) * ncoords; - t_byte_stride = s_byte_stride * s_nctl; - nurbssurface( arg1 , arg2 , arg3 , arg4 , - s_byte_stride , t_byte_stride , arg5 , arg6 , arg7 , arg8 ); - PyMem_DEL(arg2); - PyMem_DEL(arg4); - PyMem_DEL(arg5); - Py_INCREF(Py_None); - return Py_None; -} - -/* nurbscurve(knots, ctlpoints, order, type). - The length of ctlpoints is len(knots)-order. */ - -%nurbscurve - -static PyObject * -gl_nurbscurve(self, args) - PyObject *self; - PyObject *args; -{ - long arg1 ; - double * arg2 ; - long arg3 ; - double * arg4 ; - long arg5 ; - long arg6 ; - int ncoords, npoints; - int i; - PyObject *v; - double *pnext; - if (!PyArg_GetLongArraySize(args, 4, 0, &arg1)) - return NULL; - if ((arg2 = PyMem_NEW(double, arg1 )) == NULL) { - return PyErr_NoMemory(); - } - if (!PyArg_GetDoubleArray(args, 4, 0, arg1 , arg2)) - return NULL; - if (!PyArg_GetLong(args, 4, 2, &arg5)) - return NULL; - if (!PyArg_GetLong(args, 4, 3, &arg6)) - return NULL; - if (arg6 == N_ST) - ncoords = 2; - else if (arg6 == N_STW) - ncoords = 3; - else { - PyErr_BadArgument(); - return NULL; - } - npoints = arg1 - arg5; - if (!PyArg_GetObject(args, 4, 1, &v)) - return NULL; - if (!PyList_Check(v) || PyList_Size(v) != npoints) { - PyErr_BadArgument(); - return NULL; - } - if ((arg4 = PyMem_NEW(double, npoints*ncoords )) == NULL) { - return PyErr_NoMemory(); - } - pnext = arg4; - for (i = 0; i < npoints; i++) { - if (!PyArg_GetDoubleArray(PyList_GetItem(v, i), 1, 0, ncoords, pnext)) - return NULL; - pnext += ncoords; - } - arg3 = (sizeof(double)) * ncoords; - nurbscurve( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 ); - PyMem_DEL(arg2); - PyMem_DEL(arg4); - Py_INCREF(Py_None); - return Py_None; -} - -/* pwlcurve(points, type). - Points is a list of points. Type must be N_ST. */ - -%pwlcurve - -static PyObject * -gl_pwlcurve(self, args) - PyObject *self; - PyObject *args; -{ - PyObject *v; - long type; - double *data, *pnext; - long npoints, ncoords; - int i; - if (!PyArg_GetObject(args, 2, 0, &v)) - return NULL; - if (!PyArg_GetLong(args, 2, 1, &type)) - return NULL; - if (!PyList_Check(v)) { - PyErr_BadArgument(); - return NULL; - } - npoints = PyList_Size(v); - if (type == N_ST) - ncoords = 2; - else { - PyErr_BadArgument(); - return NULL; - } - if ((data = PyMem_NEW(double, npoints*ncoords)) == NULL) { - return PyErr_NoMemory(); - } - pnext = data; - for (i = 0; i < npoints; i++) { - if (!PyArg_GetDoubleArray(PyList_GetItem(v, i), 1, 0, ncoords, pnext)) - return NULL; - pnext += ncoords; - } - pwlcurve(npoints, data, sizeof(double)*ncoords, type); - PyMem_DEL(data); - Py_INCREF(Py_None); - return Py_None; -} - - -/* Picking and Selecting */ - -static short *pickbuffer = NULL; -static long pickbuffersize; - -static PyObject * -pick_select(args, func) - PyObject *args; - void (*func)(); -{ - if (!PyArg_GetLong(args, 1, 0, &pickbuffersize)) - return NULL; - if (pickbuffer != NULL) { - PyErr_SetString(PyExc_RuntimeError, - "pick/gselect: already picking/selecting"); - return NULL; - } - if ((pickbuffer = PyMem_NEW(short, pickbuffersize)) == NULL) { - return PyErr_NoMemory(); - } - (*func)(pickbuffer, pickbuffersize); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -endpick_select(args, func) - PyObject *args; - long (*func)(); -{ - PyObject *v, *w; - int i, nhits, n; - if (!PyArg_NoArgs(args)) - return NULL; - if (pickbuffer == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "endpick/endselect: not in pick/select mode"); - return NULL; - } - nhits = (*func)(pickbuffer); - if (nhits < 0) { - nhits = -nhits; /* How to report buffer overflow otherwise? */ - } - /* Scan the buffer to see how many integers */ - n = 0; - for (; nhits > 0; nhits--) { - n += 1 + pickbuffer[n]; - } - v = PyList_New(n); - if (v == NULL) - return NULL; - /* XXX Could do it nicer and interpret the data structure here, - returning a list of lists. But this can be done in Python... */ - for (i = 0; i < n; i++) { - w = PyInt_FromLong((long)pickbuffer[i]); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyList_SetItem(v, i, w); - } - PyMem_DEL(pickbuffer); - pickbuffer = NULL; - return v; -} - -extern void pick(), gselect(); -extern long endpick(), endselect(); - -%pick -static PyObject *gl_pick(self, args) PyObject *self, *args; { - return pick_select(args, pick); -} - -%endpick -static PyObject *gl_endpick(self, args) PyObject *self, *args; { - return endpick_select(args, endpick); -} - -%gselect -static PyObject *gl_gselect(self, args) PyObject *self, *args; { - return pick_select(args, gselect); -} - -%endselect -static PyObject *gl_endselect(self, args) PyObject *self, *args; { - return endpick_select(args, endselect); -} - - -/* XXX The generator botches this one. Here's a quick hack to fix it. */ - -/* XXX The generator botches this one. Here's a quick hack to fix it. */ - -% getmatrix float r[16] - -static PyObject * -gl_getmatrix(self, args) - PyObject *self; - PyObject *args; -{ - Matrix arg1; - PyObject *v, *w; - int i, j; - getmatrix( arg1 ); - v = PyList_New(16); - if (v == NULL) { - return PyErr_NoMemory(); - } - for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) { - w = mknewfloatobject(arg1[i][j]); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyList_SetItem(v, i*4+j, w); - } - return v; -} - -/* Here's an alternate version that returns a 4x4 matrix instead of - a vector. Unfortunately it is incompatible with loadmatrix and - multmatrix... */ - -% altgetmatrix float r[4][4] - -static PyObject * -gl_altgetmatrix(self, args) - PyObject *self; - PyObject *args; -{ - Matrix arg1; - PyObject *v, *w; - int i, j; - getmatrix( arg1 ); - v = PyList_New(4); - if (v == NULL) { - return NULL; - } - for (i = 0; i < 4; i++) { - w = PyList_New(4); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyList_SetItem(v, i, w); - } - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - w = mknewfloatobject(arg1[i][j]); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyList_SetItem(PyList_GetItem(v, i), j, w); - } - } - return v; -} - -% lrectwrite - -static PyObject * -gl_lrectwrite(self, args) - PyObject *self; - PyObject *args; -{ - short x1 ; - short y1 ; - short x2 ; - short y2 ; - string parray ; - PyObject *s; -#if 0 - int pixcount; -#endif - if (!PyArg_GetShort(args, 5, 0, &x1)) - return NULL; - if (!PyArg_GetShort(args, 5, 1, &y1)) - return NULL; - if (!PyArg_GetShort(args, 5, 2, &x2)) - return NULL; - if (!PyArg_GetShort(args, 5, 3, &y2)) - return NULL; - if (!PyArg_GetString(args, 5, 4, &parray)) - return NULL; - if (!PyArg_GetObject(args, 5, 4, &s)) - return NULL; -#if 0 -/* Don't check this, it breaks experiments with pixmode(PM_SIZE, ...) */ - pixcount = (long)(x2+1-x1) * (long)(y2+1-y1); - if (!PyString_Check(s) || PyString_Size(s) != pixcount*sizeof(long)) { - PyErr_SetString(PyExc_RuntimeError, - "string arg to lrectwrite has wrong size"); - return NULL; - } -#endif - lrectwrite( x1 , y1 , x2 , y2 , (unsigned long *) parray ); - Py_INCREF(Py_None); - return Py_None; -} - -% lrectread - -static PyObject * -gl_lrectread(self, args) - PyObject *self; - PyObject *args; -{ - short x1 ; - short y1 ; - short x2 ; - short y2 ; - PyObject *parray; - int pixcount; - if (!PyArg_GetShort(args, 4, 0, &x1)) - return NULL; - if (!PyArg_GetShort(args, 4, 1, &y1)) - return NULL; - if (!PyArg_GetShort(args, 4, 2, &x2)) - return NULL; - if (!PyArg_GetShort(args, 4, 3, &y2)) - return NULL; - pixcount = (long)(x2+1-x1) * (long)(y2+1-y1); - parray = PyString_FromStringAndSize((char *)NULL, pixcount*sizeof(long)); - if (parray == NULL) - return NULL; /* No memory */ - lrectread(x1, y1, x2, y2, (unsigned long *) PyString_AsString(parray)); - return parray; -} - -% readdisplay - -static PyObject * -gl_readdisplay(self, args) - PyObject *self; - PyObject *args; -{ - short x1, y1, x2, y2; - unsigned long *parray, hints; - long size, size_ret; - PyObject *rv; - - if ( !PyArg_Parse(args, "hhhhl", &x1, &y1, &x2, &y2, &hints) ) - return 0; - size = (long)(x2+1-x1) * (long)(y2+1-y1); - rv = PyString_FromStringAndSize((char *)NULL, size*sizeof(long)); - if ( rv == NULL ) - return NULL; - parray = (unsigned long *)PyString_AsString(rv); - size_ret = readdisplay(x1, y1, x2, y2, parray, hints); - if ( size_ret != size ) { - printf("gl_readdisplay: got %ld pixels, expected %ld\n", - size_ret, size); - PyErr_SetString(PyExc_RuntimeError, "readdisplay returned unexpected length"); - return NULL; - } - return rv; -} - -/* Desperately needed, here are tools to compress and decompress - the data manipulated by lrectread/lrectwrite. - - gl.packrect(width, height, packfactor, bigdata) --> smalldata - makes 'bigdata' 4*(packfactor**2) times smaller by: - - turning it into B/W (a factor 4) - - replacing squares of size pacfactor by one - representative - - gl.unpackrect(width, height, packfactor, smalldata) --> bigdata - is the inverse; the numeric arguments must be *the same*. - - Both work best if width and height are multiples of packfactor - (in fact unpackrect will leave garbage bytes). -*/ - -% packrect - -static PyObject * -gl_packrect(self, args) - PyObject *self; - PyObject *args; -{ - long width, height, packfactor; - char *s; - PyObject *unpacked, *packed; - int pixcount, packedcount, x, y, r, g, b; - unsigned long pixel; - unsigned char *p; - unsigned long *parray; - if (!PyArg_GetLong(args, 4, 0, &width)) - return NULL; - if (!PyArg_GetLong(args, 4, 1, &height)) - return NULL; - if (!PyArg_GetLong(args, 4, 2, &packfactor)) - return NULL; - if (!PyArg_GetString(args, 4, 3, &s)) /* For type checking only */ - return NULL; - if (!PyArg_GetObject(args, 4, 3, &unpacked)) - return NULL; - if (width <= 0 || height <= 0 || packfactor <= 0) { - PyErr_SetString(PyExc_RuntimeError, "packrect args must be > 0"); - return NULL; - } - pixcount = width*height; - packedcount = ((width+packfactor-1)/packfactor) * - ((height+packfactor-1)/packfactor); - if (PyString_Size(unpacked) != pixcount*sizeof(long)) { - PyErr_SetString(PyExc_RuntimeError, - "string arg to packrect has wrong size"); - return NULL; - } - packed = PyString_FromStringAndSize((char *)NULL, packedcount); - if (packed == NULL) - return NULL; - parray = (unsigned long *) PyString_AsString(unpacked); - p = (unsigned char *) PyString_AsString(packed); - for (y = 0; y < height; y += packfactor, parray += packfactor*width) { - for (x = 0; x < width; x += packfactor) { - pixel = parray[x]; - r = pixel & 0xff; - g = (pixel >> 8) & 0xff; - b = (pixel >> 16) & 0xff; - *p++ = (30*r+59*g+11*b) / 100; - } - } - return packed; -} - -% unpackrect - -static unsigned long unpacktab[256]; -static int unpacktab_inited = 0; - -static PyObject * -gl_unpackrect(self, args) - PyObject *self; - PyObject *args; -{ - long width, height, packfactor; - char *s; - PyObject *unpacked, *packed; - int pixcount, packedcount; - register unsigned char *p; - register unsigned long *parray; - if (!unpacktab_inited) { - register int white; - for (white = 256; --white >= 0; ) - unpacktab[white] = white * 0x010101L; - unpacktab_inited++; - } - if (!PyArg_GetLong(args, 4, 0, &width)) - return NULL; - if (!PyArg_GetLong(args, 4, 1, &height)) - return NULL; - if (!PyArg_GetLong(args, 4, 2, &packfactor)) - return NULL; - if (!PyArg_GetString(args, 4, 3, &s)) /* For type checking only */ - return NULL; - if (!PyArg_GetObject(args, 4, 3, &packed)) - return NULL; - if (width <= 0 || height <= 0 || packfactor <= 0) { - PyErr_SetString(PyExc_RuntimeError, "packrect args must be > 0"); - return NULL; - } - pixcount = width*height; - packedcount = ((width+packfactor-1)/packfactor) * - ((height+packfactor-1)/packfactor); - if (PyString_Size(packed) != packedcount) { - PyErr_SetString(PyExc_RuntimeError, - "string arg to unpackrect has wrong size"); - return NULL; - } - unpacked = PyString_FromStringAndSize((char *)NULL, pixcount*sizeof(long)); - if (unpacked == NULL) - return NULL; - parray = (unsigned long *) PyString_AsString(unpacked); - p = (unsigned char *) PyString_AsString(packed); - if (packfactor == 1 && width*height > 0) { - /* Just expand bytes to longs */ - register int x = width * height; - do { - *parray++ = unpacktab[*p++]; - } while (--x >= 0); - } - else { - register int y; - for (y = 0; y < height-packfactor+1; - y += packfactor, parray += packfactor*width) { - register int x; - for (x = 0; x < width-packfactor+1; x += packfactor) { - register unsigned long pixel = unpacktab[*p++]; - register int i; - for (i = packfactor*width; (i-=width) >= 0;) { - register int j; - for (j = packfactor; --j >= 0; ) - parray[i+x+j] = pixel; - } - } - } - } - return unpacked; -} - -% gversion -static PyObject * -gl_gversion(self, args) - PyObject *self; - PyObject *args; -{ - char buf[20]; - gversion(buf); - return PyString_FromString(buf); -} - - -/* void clear - Manual because of clash with termcap */ -%clear -static PyObject * -gl_clear(self, args) - PyObject *self; - PyObject *args; -{ - __GLclear( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* End of manually written stubs */ - -%% - -long getshade -if !solaris void devport short s long s -void rdr2i long s long s -void rectfs short s short s short s short s -void rects short s short s short s short s -void rmv2i long s long s -void noport -void popviewport -void clearhitcode -void closeobj -void cursoff -void curson -void doublebuffer -void finish -void gconfig -void ginit -void greset -void multimap -void onemap -void popattributes -void popmatrix -void pushattributes -void pushmatrix -void pushviewport -void qreset -void RGBmode -void singlebuffer -void swapbuffers -void gsync -void gflush -void tpon -void tpoff -void clkon -void clkoff -void ringbell -#void callfunc -void gbegin -void textinit -void initnames -void pclos -void popname -if !solaris void spclos -void zclear -void screenspace -void reshapeviewport -void winpush -void winpop -void foreground -void endfullscrn -if !solaris void endpupmode -void fullscrn -if !solaris void pupmode -void winconstraints -void pagecolor short s -void textcolor short s -void color short s -void curveit short s -void font short s -void linewidth short s -void setlinestyle short s -void setmap short s -void swapinterval short s -void writemask short s -if !solaris void textwritemask short s -void qdevice short s -void unqdevice short s -void curvebasis short s -void curveprecision short s -void loadname short s -void passthrough short s -void pushname short s -void setmonitor short s -if !solaris void setshade short s -void setpattern short s -if !solaris void pagewritemask short s -# -void callobj long s -void delobj long s -void editobj long s -void makeobj long s -void maketag long s -void chunksize long s -void compactify long s -void deltag long s -void lsrepeat long s -void objinsert long s -void objreplace long s -void winclose long s -void blanktime long s -void freepup long s -# This is not in the library!? -###void pupcolor long s -# -void backbuffer long s -void frontbuffer long s -if !solaris void lsbackup long s -void resetls long s -void lampon long s -void lampoff long s -void setbell long s -void blankscreen long s -void depthcue long s -void zbuffer long s -void backface long s -# -void cmov2i long s long s -void draw2i long s long s -void move2i long s long s -void pnt2i long s long s -void patchbasis long s long s -void patchprecision long s long s -void pdr2i long s long s -void pmv2i long s long s -void rpdr2i long s long s -void rpmv2i long s long s -void xfpt2i long s long s -void objdelete long s long s -void patchcurves long s long s -void minsize long s long s -void maxsize long s long s -void keepaspect long s long s -void prefsize long s long s -void stepunit long s long s -void fudge long s long s -void winmove long s long s -# -void attachcursor short s short s -void deflinestyle short s short s -void noise short s short s -void picksize short s short s -void qenter short s short s -void setdepth short s short s -void cmov2s short s short s -void draw2s short s short s -void move2s short s short s -void pdr2s short s short s -void pmv2s short s short s -void pnt2s short s short s -void rdr2s short s short s -void rmv2s short s short s -void rpdr2s short s short s -void rpmv2s short s short s -void xfpt2s short s short s -# -void cmov2 float s float s -void draw2 float s float s -void move2 float s float s -void pnt2 float s float s -void pdr2 float s float s -void pmv2 float s float s -void rdr2 float s float s -void rmv2 float s float s -void rpdr2 float s float s -void rpmv2 float s float s -void xfpt2 float s float s -# -void loadmatrix float s[4*4] -# Really [4][4] -void multmatrix float s[4*4] -# Really [4][4] -void crv float s[3*4] -# Really [4][3] -void rcrv float s[4*4] -# Really [4][4] -# -# Methods that have strings. -# -void addtopup long s char *s long s -void charstr char *s -void getport char *s -long strwidth char *s -long winopen char *s -void wintitle char *s -# -# Methods that have 1 long (# of elements) and an array -# -void polf long s float s[3*arg1] -void polf2 long s float s[2*arg1] -void poly long s float s[3*arg1] -void poly2 long s float s[2*arg1] -void crvn long s float s[3*arg1] -void rcrvn long s float s[4*arg1] -# -void polf2i long s long s[2*arg1] -void polfi long s long s[3*arg1] -void poly2i long s long s[2*arg1] -void polyi long s long s[3*arg1] -# -void polf2s long s short s[2*arg1] -void polfs long s short s[3*arg1] -void polys long s short s[3*arg1] -void poly2s long s short s[2*arg1] -# -void defcursor short s u_short s[128] -# Is this useful? -void writepixels short s u_short s[arg1] -# Should be unsigned short... -void defbasis long s float s[4*4] -if !solaris void gewrite short s short s[arg1] -# -void rotate short s char s -# This is not in the library!? -###void setbutton short s char s -void rot float s char s -# -void circfi long s long s long s -void circi long s long s long s -void cmovi long s long s long s -void drawi long s long s long s -void movei long s long s long s -void pnti long s long s long s -void newtag long s long s long s -void pdri long s long s long s -void pmvi long s long s long s -void rdri long s long s long s -void rmvi long s long s long s -void rpdri long s long s long s -void rpmvi long s long s long s -void xfpti long s long s long s -# -void circ float s float s float s -void circf float s float s float s -void cmov float s float s float s -void draw float s float s float s -void move float s float s float s -void pnt float s float s float s -void scale float s float s float s -void translate float s float s float s -void pdr float s float s float s -void pmv float s float s float s -void rdr float s float s float s -void rmv float s float s float s -void rpdr float s float s float s -void rpmv float s float s float s -void xfpt float s float s float s -# -void RGBcolor short s short s short s -void RGBwritemask short s short s short s -void setcursor short s short s short s -void tie short s short s short s -void circfs short s short s short s -void circs short s short s short s -void cmovs short s short s short s -void draws short s short s short s -void moves short s short s short s -void pdrs short s short s short s -void pmvs short s short s short s -void pnts short s short s short s -void rdrs short s short s short s -void rmvs short s short s short s -void rpdrs short s short s short s -void rpmvs short s short s short s -void xfpts short s short s short s -void curorigin short s short s short s -void cyclemap short s short s short s -# -void patch float s[4*4] float s[4*4] float s[4*4] -void splf long s float s[3*arg1] u_short s[arg1] -void splf2 long s float s[2*arg1] u_short s[arg1] -void splfi long s long s[3*arg1] u_short s[arg1] -void splf2i long s long s[2*arg1] u_short s[arg1] -void splfs long s short s[3*arg1] u_short s[arg1] -void splf2s long s short s[2*arg1] u_short s[arg1] -###void defpattern short s short s u_short s[arg2*arg2/16] -# -void rpatch float s[4*4] float s[4*4] float s[4*4] float s[4*4] -# -# routines that send 4 floats -# -void ortho2 float s float s float s float s -void rect float s float s float s float s -void rectf float s float s float s float s -void xfpt4 float s float s float s float s -# -void textport short s short s short s short s -void mapcolor short s short s short s short s -void scrmask short s short s short s short s -void setvaluator short s short s short s short s -void viewport short s short s short s short s -void shaderange short s short s short s short s -void xfpt4s short s short s short s short s -void rectfi long s long s long s long s -void recti long s long s long s long s -void xfpt4i long s long s long s long s -void prefposition long s long s long s long s -# -void arc float s float s float s short s short s -void arcf float s float s float s short s short s -void arcfi long s long s long s short s short s -void arci long s long s long s short s short s -# -void bbox2 short s short s float s float s float s float s -void bbox2i short s short s long s long s long s long s -void bbox2s short s short s short s short s short s short s -void blink short s short s short s short s short s -void ortho float s float s float s float s float s float s -void window float s float s float s float s float s float s -void lookat float s float s float s float s float s float s short s -# -void perspective short s float s float s float s -void polarview float s short s short s short s -# XXX getichararray not supported -#void writeRGB short s char s[arg1] char s[arg1] char s[arg1] -# -void arcfs short s short s short s short s short s -void arcs short s short s short s short s short s -void rectcopy short s short s short s short s short s short s -if !solaris void RGBcursor short s short s short s short s short s short s short s -# -long getbutton short s -long getcmmode -long getlsbackup -long getresetls -long getdcm -long getzbuffer -long ismex -long isobj long s -long isqueued short s -long istag long s -# -long genobj -long gentag -long getbuffer -long getcolor -long getdisplaymode -long getfont -long getheight -long gethitcode -long getlstyle -long getlwidth -long getmap -long getplanes -long getwritemask -long qtest -long getlsrepeat -long getmonitor -long getopenobj -long getpattern -long winget -long winattach -long getothermonitor -long newpup -# -long getvaluator short s -void winset long s -long dopup long s -void getdepth short r short r -void getcpos short r short r -void getsize long r long r -void getorigin long r long r -void getviewport short r short r short r short r -if !solaris void gettp short r short r short r short r -void getgpos float r float r float r float r -void winposition long s long s long s long s -void gRGBcolor short r short r short r -void gRGBmask short r short r short r -void getscrmask short r short r short r short r -###void gRGBcursor short r short r short r short r short r short r short r short r -void getmcolor short s short r short r short r -void mapw long s short s short s float r float r float r float r float r float r -void mapw2 long s short s short s float r float r -###void defrasterfont short s short s short s Fontchar s[arg3] short s short s[4*arg5] -###long qread short r -void getcursor short r u_short r u_short r long r -# -# For these we receive arrays of stuff -# -###void getdev long s short s[arg1] short r[arg1] -#XXX not generated correctly yet -#void getmatrix float r[16] -###long readpixels short s short r[retval] -###long readRGB short s char r[retval] char r[retval] char r[retval] -###long blkqread short s short r[arg1] -# -# New 4D routines -# -void cmode -void concave long s -void curstype long s -void drawmode long s -void gammaramp short s[256] short s[256] short s[256] -long getbackface -long getdescender -long getdrawmode -long getmmode -long getsm -long getvideo long s -void imakebackground -void lmbind short s short s -void lmdef long s long s long s float s[arg3] -void mmode long s -void normal float s[3] -void overlay long s -void RGBrange short s short s short s short s short s short s short s short s -if !solaris void setvideo long s long s -void shademodel long s -void underlay long s -# -# New Personal Iris/GT Routines -# -void bgnclosedline -void bgnline -void bgnpoint -void bgnpolygon -void bgnsurface -void bgntmesh -void bgntrim -void endclosedline -void endline -void endpoint -void endpolygon -void endsurface -void endtmesh -void endtrim -void blendfunction long s long s -void c3f float s[3] -void c3i long s[3] -void c3s short s[3] -void c4f float s[4] -void c4i long s[4] -void c4s short s[4] -void colorf float s -void cpack long s -void czclear long s long s -void dglclose long s -long dglopen char *s long s -long getgdesc long s -void getnurbsproperty long s float r -void glcompat long s long s -void iconsize long s long s -void icontitle char *s -void lRGBrange short s short s short s short s short s short s long s long s -void linesmooth long s -void lmcolor long s -void logicop long s -###long lrectread short s short s short s short s long r[retval] -###void lrectwrite short s short s short s short s long s[(arg2-arg1+1)*(arg4-arg3+1)] -### Now manual, with string last arg -###long rectread short s short s short s short s short r[retval] -###void rectwrite short s short s short s short s short s[(arg2-arg1+1)*(arg4-arg3+1)] -void lsetdepth long s long s -void lshaderange short s short s long s long s -void n3f float s[3] -void noborder -void pntsmooth long s -void readsource long s -void rectzoom float s float s -void sbox float s float s float s float s -void sboxi long s long s long s long s -void sboxs short s short s short s short s -void sboxf float s float s float s float s -void sboxfi long s long s long s long s -void sboxfs short s short s short s short s -void setnurbsproperty long s float s -void setpup long s long s long s -void smoothline long s -void subpixel long s -void swaptmesh -long swinopen long s -void v2f float s[2] -void v2i long s[2] -void v2s short s[2] -void v3f float s[3] -void v3i long s[3] -void v3s short s[3] -void v4f float s[4] -void v4i long s[4] -void v4s short s[4] -void videocmd long s -long windepth long s -void wmpack long s -void zdraw long s -void zfunction long s -void zsource long s -void zwritemask long s -# -# uses doubles -# -void v2d double s[2] -void v3d double s[3] -void v4d double s[4] -# -# Why isn't this here? -# -void pixmode long s long s -# -# New in IRIX 4.0 -# -long qgetfd -void dither long s diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/datetimemodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/datetimemodule.c deleted file mode 100644 index e09cbbba..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/datetimemodule.c +++ /dev/null @@ -1,4854 +0,0 @@ -/* C implementation for the date/time type documented at - * http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage - */ - -#include "Python.h" -#include "modsupport.h" -#include "structmember.h" - -#include - -#include "datetime.h" - -/* We require that C int be at least 32 bits, and use int virtually - * everywhere. In just a few cases we use a temp long, where a Python - * API returns a C long. In such cases, we have to ensure that the - * final result fits in a C int (this can be an issue on 64-bit boxes). - */ -#if SIZEOF_INT < 4 -# error "datetime.c requires that C int have at least 32 bits" -#endif - -#define MINYEAR 1 -#define MAXYEAR 9999 - -/* Nine decimal digits is easy to communicate, and leaves enough room - * so that two delta days can be added w/o fear of overflowing a signed - * 32-bit int, and with plenty of room left over to absorb any possible - * carries from adding seconds. - */ -#define MAX_DELTA_DAYS 999999999 - -/* Rename the long macros in datetime.h to more reasonable short names. */ -#define GET_YEAR PyDateTime_GET_YEAR -#define GET_MONTH PyDateTime_GET_MONTH -#define GET_DAY PyDateTime_GET_DAY -#define DATE_GET_HOUR PyDateTime_DATE_GET_HOUR -#define DATE_GET_MINUTE PyDateTime_DATE_GET_MINUTE -#define DATE_GET_SECOND PyDateTime_DATE_GET_SECOND -#define DATE_GET_MICROSECOND PyDateTime_DATE_GET_MICROSECOND - -/* Date accessors for date and datetime. */ -#define SET_YEAR(o, v) (((o)->data[0] = ((v) & 0xff00) >> 8), \ - ((o)->data[1] = ((v) & 0x00ff))) -#define SET_MONTH(o, v) (PyDateTime_GET_MONTH(o) = (v)) -#define SET_DAY(o, v) (PyDateTime_GET_DAY(o) = (v)) - -/* Date/Time accessors for datetime. */ -#define DATE_SET_HOUR(o, v) (PyDateTime_DATE_GET_HOUR(o) = (v)) -#define DATE_SET_MINUTE(o, v) (PyDateTime_DATE_GET_MINUTE(o) = (v)) -#define DATE_SET_SECOND(o, v) (PyDateTime_DATE_GET_SECOND(o) = (v)) -#define DATE_SET_MICROSECOND(o, v) \ - (((o)->data[7] = ((v) & 0xff0000) >> 16), \ - ((o)->data[8] = ((v) & 0x00ff00) >> 8), \ - ((o)->data[9] = ((v) & 0x0000ff))) - -/* Time accessors for time. */ -#define TIME_GET_HOUR PyDateTime_TIME_GET_HOUR -#define TIME_GET_MINUTE PyDateTime_TIME_GET_MINUTE -#define TIME_GET_SECOND PyDateTime_TIME_GET_SECOND -#define TIME_GET_MICROSECOND PyDateTime_TIME_GET_MICROSECOND -#define TIME_SET_HOUR(o, v) (PyDateTime_TIME_GET_HOUR(o) = (v)) -#define TIME_SET_MINUTE(o, v) (PyDateTime_TIME_GET_MINUTE(o) = (v)) -#define TIME_SET_SECOND(o, v) (PyDateTime_TIME_GET_SECOND(o) = (v)) -#define TIME_SET_MICROSECOND(o, v) \ - (((o)->data[3] = ((v) & 0xff0000) >> 16), \ - ((o)->data[4] = ((v) & 0x00ff00) >> 8), \ - ((o)->data[5] = ((v) & 0x0000ff))) - -/* Delta accessors for timedelta. */ -#define GET_TD_DAYS(o) (((PyDateTime_Delta *)(o))->days) -#define GET_TD_SECONDS(o) (((PyDateTime_Delta *)(o))->seconds) -#define GET_TD_MICROSECONDS(o) (((PyDateTime_Delta *)(o))->microseconds) - -#define SET_TD_DAYS(o, v) ((o)->days = (v)) -#define SET_TD_SECONDS(o, v) ((o)->seconds = (v)) -#define SET_TD_MICROSECONDS(o, v) ((o)->microseconds = (v)) - -/* p is a pointer to a time or a datetime object; HASTZINFO(p) returns - * p->hastzinfo. - */ -#define HASTZINFO(p) (((_PyDateTime_BaseTZInfo *)(p))->hastzinfo) - -/* Forward declarations. */ -static PyTypeObject PyDateTime_DateType; -static PyTypeObject PyDateTime_DateTimeType; -static PyTypeObject PyDateTime_DeltaType; -static PyTypeObject PyDateTime_TimeType; -static PyTypeObject PyDateTime_TZInfoType; - -/* --------------------------------------------------------------------------- - * Math utilities. - */ - -/* k = i+j overflows iff k differs in sign from both inputs, - * iff k^i has sign bit set and k^j has sign bit set, - * iff (k^i)&(k^j) has sign bit set. - */ -#define SIGNED_ADD_OVERFLOWED(RESULT, I, J) \ - ((((RESULT) ^ (I)) & ((RESULT) ^ (J))) < 0) - -/* Compute Python divmod(x, y), returning the quotient and storing the - * remainder into *r. The quotient is the floor of x/y, and that's - * the real point of this. C will probably truncate instead (C99 - * requires truncation; C89 left it implementation-defined). - * Simplification: we *require* that y > 0 here. That's appropriate - * for all the uses made of it. This simplifies the code and makes - * the overflow case impossible (divmod(LONG_MIN, -1) is the only - * overflow case). - */ -static int -divmod(int x, int y, int *r) -{ - int quo; - - assert(y > 0); - quo = x / y; - *r = x - quo * y; - if (*r < 0) { - --quo; - *r += y; - } - assert(0 <= *r && *r < y); - return quo; -} - -/* Round a double to the nearest long. |x| must be small enough to fit - * in a C long; this is not checked. - */ -static long -round_to_long(double x) -{ - if (x >= 0.0) - x = floor(x + 0.5); - else - x = ceil(x - 0.5); - return (long)x; -} - -/* --------------------------------------------------------------------------- - * General calendrical helper functions - */ - -/* For each month ordinal in 1..12, the number of days in that month, - * and the number of days before that month in the same year. These - * are correct for non-leap years only. - */ -static int _days_in_month[] = { - 0, /* unused; this vector uses 1-based indexing */ - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -}; - -static int _days_before_month[] = { - 0, /* unused; this vector uses 1-based indexing */ - 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 -}; - -/* year -> 1 if leap year, else 0. */ -static int -is_leap(int year) -{ - /* Cast year to unsigned. The result is the same either way, but - * C can generate faster code for unsigned mod than for signed - * mod (especially for % 4 -- a good compiler should just grab - * the last 2 bits when the LHS is unsigned). - */ - const unsigned int ayear = (unsigned int)year; - return ayear % 4 == 0 && (ayear % 100 != 0 || ayear % 400 == 0); -} - -/* year, month -> number of days in that month in that year */ -static int -days_in_month(int year, int month) -{ - assert(month >= 1); - assert(month <= 12); - if (month == 2 && is_leap(year)) - return 29; - else - return _days_in_month[month]; -} - -/* year, month -> number of days in year preceeding first day of month */ -static int -days_before_month(int year, int month) -{ - int days; - - assert(month >= 1); - assert(month <= 12); - days = _days_before_month[month]; - if (month > 2 && is_leap(year)) - ++days; - return days; -} - -/* year -> number of days before January 1st of year. Remember that we - * start with year 1, so days_before_year(1) == 0. - */ -static int -days_before_year(int year) -{ - int y = year - 1; - /* This is incorrect if year <= 0; we really want the floor - * here. But so long as MINYEAR is 1, the smallest year this - * can see is 0 (this can happen in some normalization endcases), - * so we'll just special-case that. - */ - assert (year >= 0); - if (y >= 0) - return y*365 + y/4 - y/100 + y/400; - else { - assert(y == -1); - return -366; - } -} - -/* Number of days in 4, 100, and 400 year cycles. That these have - * the correct values is asserted in the module init function. - */ -#define DI4Y 1461 /* days_before_year(5); days in 4 years */ -#define DI100Y 36524 /* days_before_year(101); days in 100 years */ -#define DI400Y 146097 /* days_before_year(401); days in 400 years */ - -/* ordinal -> year, month, day, considering 01-Jan-0001 as day 1. */ -static void -ord_to_ymd(int ordinal, int *year, int *month, int *day) -{ - int n, n1, n4, n100, n400, leapyear, preceding; - - /* ordinal is a 1-based index, starting at 1-Jan-1. The pattern of - * leap years repeats exactly every 400 years. The basic strategy is - * to find the closest 400-year boundary at or before ordinal, then - * work with the offset from that boundary to ordinal. Life is much - * clearer if we subtract 1 from ordinal first -- then the values - * of ordinal at 400-year boundaries are exactly those divisible - * by DI400Y: - * - * D M Y n n-1 - * -- --- ---- ---------- ---------------- - * 31 Dec -400 -DI400Y -DI400Y -1 - * 1 Jan -399 -DI400Y +1 -DI400Y 400-year boundary - * ... - * 30 Dec 000 -1 -2 - * 31 Dec 000 0 -1 - * 1 Jan 001 1 0 400-year boundary - * 2 Jan 001 2 1 - * 3 Jan 001 3 2 - * ... - * 31 Dec 400 DI400Y DI400Y -1 - * 1 Jan 401 DI400Y +1 DI400Y 400-year boundary - */ - assert(ordinal >= 1); - --ordinal; - n400 = ordinal / DI400Y; - n = ordinal % DI400Y; - *year = n400 * 400 + 1; - - /* Now n is the (non-negative) offset, in days, from January 1 of - * year, to the desired date. Now compute how many 100-year cycles - * precede n. - * Note that it's possible for n100 to equal 4! In that case 4 full - * 100-year cycles precede the desired day, which implies the - * desired day is December 31 at the end of a 400-year cycle. - */ - n100 = n / DI100Y; - n = n % DI100Y; - - /* Now compute how many 4-year cycles precede it. */ - n4 = n / DI4Y; - n = n % DI4Y; - - /* And now how many single years. Again n1 can be 4, and again - * meaning that the desired day is December 31 at the end of the - * 4-year cycle. - */ - n1 = n / 365; - n = n % 365; - - *year += n100 * 100 + n4 * 4 + n1; - if (n1 == 4 || n100 == 4) { - assert(n == 0); - *year -= 1; - *month = 12; - *day = 31; - return; - } - - /* Now the year is correct, and n is the offset from January 1. We - * find the month via an estimate that's either exact or one too - * large. - */ - leapyear = n1 == 3 && (n4 != 24 || n100 == 3); - assert(leapyear == is_leap(*year)); - *month = (n + 50) >> 5; - preceding = (_days_before_month[*month] + (*month > 2 && leapyear)); - if (preceding > n) { - /* estimate is too large */ - *month -= 1; - preceding -= days_in_month(*year, *month); - } - n -= preceding; - assert(0 <= n); - assert(n < days_in_month(*year, *month)); - - *day = n + 1; -} - -/* year, month, day -> ordinal, considering 01-Jan-0001 as day 1. */ -static int -ymd_to_ord(int year, int month, int day) -{ - return days_before_year(year) + days_before_month(year, month) + day; -} - -/* Day of week, where Monday==0, ..., Sunday==6. 1/1/1 was a Monday. */ -static int -weekday(int year, int month, int day) -{ - return (ymd_to_ord(year, month, day) + 6) % 7; -} - -/* Ordinal of the Monday starting week 1 of the ISO year. Week 1 is the - * first calendar week containing a Thursday. - */ -static int -iso_week1_monday(int year) -{ - int first_day = ymd_to_ord(year, 1, 1); /* ord of 1/1 */ - /* 0 if 1/1 is a Monday, 1 if a Tue, etc. */ - int first_weekday = (first_day + 6) % 7; - /* ordinal of closest Monday at or before 1/1 */ - int week1_monday = first_day - first_weekday; - - if (first_weekday > 3) /* if 1/1 was Fri, Sat, Sun */ - week1_monday += 7; - return week1_monday; -} - -/* --------------------------------------------------------------------------- - * Range checkers. - */ - -/* Check that -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS. If so, return 0. - * If not, raise OverflowError and return -1. - */ -static int -check_delta_day_range(int days) -{ - if (-MAX_DELTA_DAYS <= days && days <= MAX_DELTA_DAYS) - return 0; - PyErr_Format(PyExc_OverflowError, - "days=%d; must have magnitude <= %d", - days, MAX_DELTA_DAYS); - return -1; -} - -/* Check that date arguments are in range. Return 0 if they are. If they - * aren't, raise ValueError and return -1. - */ -static int -check_date_args(int year, int month, int day) -{ - - if (year < MINYEAR || year > MAXYEAR) { - PyErr_SetString(PyExc_ValueError, - "year is out of range"); - return -1; - } - if (month < 1 || month > 12) { - PyErr_SetString(PyExc_ValueError, - "month must be in 1..12"); - return -1; - } - if (day < 1 || day > days_in_month(year, month)) { - PyErr_SetString(PyExc_ValueError, - "day is out of range for month"); - return -1; - } - return 0; -} - -/* Check that time arguments are in range. Return 0 if they are. If they - * aren't, raise ValueError and return -1. - */ -static int -check_time_args(int h, int m, int s, int us) -{ - if (h < 0 || h > 23) { - PyErr_SetString(PyExc_ValueError, - "hour must be in 0..23"); - return -1; - } - if (m < 0 || m > 59) { - PyErr_SetString(PyExc_ValueError, - "minute must be in 0..59"); - return -1; - } - if (s < 0 || s > 59) { - PyErr_SetString(PyExc_ValueError, - "second must be in 0..59"); - return -1; - } - if (us < 0 || us > 999999) { - PyErr_SetString(PyExc_ValueError, - "microsecond must be in 0..999999"); - return -1; - } - return 0; -} - -/* --------------------------------------------------------------------------- - * Normalization utilities. - */ - -/* One step of a mixed-radix conversion. A "hi" unit is equivalent to - * factor "lo" units. factor must be > 0. If *lo is less than 0, or - * at least factor, enough of *lo is converted into "hi" units so that - * 0 <= *lo < factor. The input values must be such that int overflow - * is impossible. - */ -static void -normalize_pair(int *hi, int *lo, int factor) -{ - assert(factor > 0); - assert(lo != hi); - if (*lo < 0 || *lo >= factor) { - const int num_hi = divmod(*lo, factor, lo); - const int new_hi = *hi + num_hi; - assert(! SIGNED_ADD_OVERFLOWED(new_hi, *hi, num_hi)); - *hi = new_hi; - } - assert(0 <= *lo && *lo < factor); -} - -/* Fiddle days (d), seconds (s), and microseconds (us) so that - * 0 <= *s < 24*3600 - * 0 <= *us < 1000000 - * The input values must be such that the internals don't overflow. - * The way this routine is used, we don't get close. - */ -static void -normalize_d_s_us(int *d, int *s, int *us) -{ - if (*us < 0 || *us >= 1000000) { - normalize_pair(s, us, 1000000); - /* |s| can't be bigger than about - * |original s| + |original us|/1000000 now. - */ - - } - if (*s < 0 || *s >= 24*3600) { - normalize_pair(d, s, 24*3600); - /* |d| can't be bigger than about - * |original d| + - * (|original s| + |original us|/1000000) / (24*3600) now. - */ - } - assert(0 <= *s && *s < 24*3600); - assert(0 <= *us && *us < 1000000); -} - -/* Fiddle years (y), months (m), and days (d) so that - * 1 <= *m <= 12 - * 1 <= *d <= days_in_month(*y, *m) - * The input values must be such that the internals don't overflow. - * The way this routine is used, we don't get close. - */ -static void -normalize_y_m_d(int *y, int *m, int *d) -{ - int dim; /* # of days in month */ - - /* This gets muddy: the proper range for day can't be determined - * without knowing the correct month and year, but if day is, e.g., - * plus or minus a million, the current month and year values make - * no sense (and may also be out of bounds themselves). - * Saying 12 months == 1 year should be non-controversial. - */ - if (*m < 1 || *m > 12) { - --*m; - normalize_pair(y, m, 12); - ++*m; - /* |y| can't be bigger than about - * |original y| + |original m|/12 now. - */ - } - assert(1 <= *m && *m <= 12); - - /* Now only day can be out of bounds (year may also be out of bounds - * for a datetime object, but we don't care about that here). - * If day is out of bounds, what to do is arguable, but at least the - * method here is principled and explainable. - */ - dim = days_in_month(*y, *m); - if (*d < 1 || *d > dim) { - /* Move day-1 days from the first of the month. First try to - * get off cheap if we're only one day out of range - * (adjustments for timezone alone can't be worse than that). - */ - if (*d == 0) { - --*m; - if (*m > 0) - *d = days_in_month(*y, *m); - else { - --*y; - *m = 12; - *d = 31; - } - } - else if (*d == dim + 1) { - /* move forward a day */ - ++*m; - *d = 1; - if (*m > 12) { - *m = 1; - ++*y; - } - } - else { - int ordinal = ymd_to_ord(*y, *m, 1) + - *d - 1; - ord_to_ymd(ordinal, y, m, d); - } - } - assert(*m > 0); - assert(*d > 0); -} - -/* Fiddle out-of-bounds months and days so that the result makes some kind - * of sense. The parameters are both inputs and outputs. Returns < 0 on - * failure, where failure means the adjusted year is out of bounds. - */ -static int -normalize_date(int *year, int *month, int *day) -{ - int result; - - normalize_y_m_d(year, month, day); - if (MINYEAR <= *year && *year <= MAXYEAR) - result = 0; - else { - PyErr_SetString(PyExc_OverflowError, - "date value out of range"); - result = -1; - } - return result; -} - -/* Force all the datetime fields into range. The parameters are both - * inputs and outputs. Returns < 0 on error. - */ -static int -normalize_datetime(int *year, int *month, int *day, - int *hour, int *minute, int *second, - int *microsecond) -{ - normalize_pair(second, microsecond, 1000000); - normalize_pair(minute, second, 60); - normalize_pair(hour, minute, 60); - normalize_pair(day, hour, 24); - return normalize_date(year, month, day); -} - -/* --------------------------------------------------------------------------- - * Basic object allocation: tp_alloc implementations. These allocate - * Python objects of the right size and type, and do the Python object- - * initialization bit. If there's not enough memory, they return NULL after - * setting MemoryError. All data members remain uninitialized trash. - * - * We abuse the tp_alloc "nitems" argument to communicate whether a tzinfo - * member is needed. This is ugly, imprecise, and possibly insecure. - * tp_basicsize for the time and datetime types is set to the size of the - * struct that has room for the tzinfo member, so subclasses in Python will - * allocate enough space for a tzinfo member whether or not one is actually - * needed. That's the "ugly and imprecise" parts. The "possibly insecure" - * part is that PyType_GenericAlloc() (which subclasses in Python end up - * using) just happens today to effectively ignore the nitems argument - * when tp_itemsize is 0, which it is for these type objects. If that - * changes, perhaps the callers of tp_alloc slots in this file should - * be changed to force a 0 nitems argument unless the type being allocated - * is a base type implemented in this file (so that tp_alloc is time_alloc - * or datetime_alloc below, which know about the nitems abuse). - */ - -static PyObject * -time_alloc(PyTypeObject *type, int aware) -{ - PyObject *self; - - self = (PyObject *) - PyObject_MALLOC(aware ? - sizeof(PyDateTime_Time) : - sizeof(_PyDateTime_BaseTime)); - if (self == NULL) - return (PyObject *)PyErr_NoMemory(); - PyObject_INIT(self, type); - return self; -} - -static PyObject * -datetime_alloc(PyTypeObject *type, int aware) -{ - PyObject *self; - - self = (PyObject *) - PyObject_MALLOC(aware ? - sizeof(PyDateTime_DateTime) : - sizeof(_PyDateTime_BaseDateTime)); - if (self == NULL) - return (PyObject *)PyErr_NoMemory(); - PyObject_INIT(self, type); - return self; -} - -/* --------------------------------------------------------------------------- - * Helpers for setting object fields. These work on pointers to the - * appropriate base class. - */ - -/* For date and datetime. */ -static void -set_date_fields(PyDateTime_Date *self, int y, int m, int d) -{ - self->hashcode = -1; - SET_YEAR(self, y); - SET_MONTH(self, m); - SET_DAY(self, d); -} - -/* --------------------------------------------------------------------------- - * Create various objects, mostly without range checking. - */ - -/* Create a date instance with no range checking. */ -static PyObject * -new_date_ex(int year, int month, int day, PyTypeObject *type) -{ - PyDateTime_Date *self; - - self = (PyDateTime_Date *) (type->tp_alloc(type, 0)); - if (self != NULL) - set_date_fields(self, year, month, day); - return (PyObject *) self; -} - -#define new_date(year, month, day) \ - new_date_ex(year, month, day, &PyDateTime_DateType) - -/* Create a datetime instance with no range checking. */ -static PyObject * -new_datetime_ex(int year, int month, int day, int hour, int minute, - int second, int usecond, PyObject *tzinfo, PyTypeObject *type) -{ - PyDateTime_DateTime *self; - char aware = tzinfo != Py_None; - - self = (PyDateTime_DateTime *) (type->tp_alloc(type, aware)); - if (self != NULL) { - self->hastzinfo = aware; - set_date_fields((PyDateTime_Date *)self, year, month, day); - DATE_SET_HOUR(self, hour); - DATE_SET_MINUTE(self, minute); - DATE_SET_SECOND(self, second); - DATE_SET_MICROSECOND(self, usecond); - if (aware) { - Py_INCREF(tzinfo); - self->tzinfo = tzinfo; - } - } - return (PyObject *)self; -} - -#define new_datetime(y, m, d, hh, mm, ss, us, tzinfo) \ - new_datetime_ex(y, m, d, hh, mm, ss, us, tzinfo, \ - &PyDateTime_DateTimeType) - -/* Create a time instance with no range checking. */ -static PyObject * -new_time_ex(int hour, int minute, int second, int usecond, - PyObject *tzinfo, PyTypeObject *type) -{ - PyDateTime_Time *self; - char aware = tzinfo != Py_None; - - self = (PyDateTime_Time *) (type->tp_alloc(type, aware)); - if (self != NULL) { - self->hastzinfo = aware; - self->hashcode = -1; - TIME_SET_HOUR(self, hour); - TIME_SET_MINUTE(self, minute); - TIME_SET_SECOND(self, second); - TIME_SET_MICROSECOND(self, usecond); - if (aware) { - Py_INCREF(tzinfo); - self->tzinfo = tzinfo; - } - } - return (PyObject *)self; -} - -#define new_time(hh, mm, ss, us, tzinfo) \ - new_time_ex(hh, mm, ss, us, tzinfo, &PyDateTime_TimeType) - -/* Create a timedelta instance. Normalize the members iff normalize is - * true. Passing false is a speed optimization, if you know for sure - * that seconds and microseconds are already in their proper ranges. In any - * case, raises OverflowError and returns NULL if the normalized days is out - * of range). - */ -static PyObject * -new_delta_ex(int days, int seconds, int microseconds, int normalize, - PyTypeObject *type) -{ - PyDateTime_Delta *self; - - if (normalize) - normalize_d_s_us(&days, &seconds, µseconds); - assert(0 <= seconds && seconds < 24*3600); - assert(0 <= microseconds && microseconds < 1000000); - - if (check_delta_day_range(days) < 0) - return NULL; - - self = (PyDateTime_Delta *) (type->tp_alloc(type, 0)); - if (self != NULL) { - self->hashcode = -1; - SET_TD_DAYS(self, days); - SET_TD_SECONDS(self, seconds); - SET_TD_MICROSECONDS(self, microseconds); - } - return (PyObject *) self; -} - -#define new_delta(d, s, us, normalize) \ - new_delta_ex(d, s, us, normalize, &PyDateTime_DeltaType) - -/* --------------------------------------------------------------------------- - * tzinfo helpers. - */ - -/* Ensure that p is None or of a tzinfo subclass. Return 0 if OK; if not - * raise TypeError and return -1. - */ -static int -check_tzinfo_subclass(PyObject *p) -{ - if (p == Py_None || PyTZInfo_Check(p)) - return 0; - PyErr_Format(PyExc_TypeError, - "tzinfo argument must be None or of a tzinfo subclass, " - "not type '%s'", - p->ob_type->tp_name); - return -1; -} - -/* Return tzinfo.methname(tzinfoarg), without any checking of results. - * If tzinfo is None, returns None. - */ -static PyObject * -call_tzinfo_method(PyObject *tzinfo, char *methname, PyObject *tzinfoarg) -{ - PyObject *result; - - assert(tzinfo && methname && tzinfoarg); - assert(check_tzinfo_subclass(tzinfo) >= 0); - if (tzinfo == Py_None) { - result = Py_None; - Py_INCREF(result); - } - else - result = PyObject_CallMethod(tzinfo, methname, "O", tzinfoarg); - return result; -} - -/* If self has a tzinfo member, return a BORROWED reference to it. Else - * return NULL, which is NOT AN ERROR. There are no error returns here, - * and the caller must not decref the result. - */ -static PyObject * -get_tzinfo_member(PyObject *self) -{ - PyObject *tzinfo = NULL; - - if (PyDateTime_Check(self) && HASTZINFO(self)) - tzinfo = ((PyDateTime_DateTime *)self)->tzinfo; - else if (PyTime_Check(self) && HASTZINFO(self)) - tzinfo = ((PyDateTime_Time *)self)->tzinfo; - - return tzinfo; -} - -/* Call getattr(tzinfo, name)(tzinfoarg), and extract an int from the - * result. tzinfo must be an instance of the tzinfo class. If the method - * returns None, this returns 0 and sets *none to 1. If the method doesn't - * return None or timedelta, TypeError is raised and this returns -1. If it - * returnsa timedelta and the value is out of range or isn't a whole number - * of minutes, ValueError is raised and this returns -1. - * Else *none is set to 0 and the integer method result is returned. - */ -static int -call_utc_tzinfo_method(PyObject *tzinfo, char *name, PyObject *tzinfoarg, - int *none) -{ - PyObject *u; - int result = -1; - - assert(tzinfo != NULL); - assert(PyTZInfo_Check(tzinfo)); - assert(tzinfoarg != NULL); - - *none = 0; - u = call_tzinfo_method(tzinfo, name, tzinfoarg); - if (u == NULL) - return -1; - - else if (u == Py_None) { - result = 0; - *none = 1; - } - else if (PyDelta_Check(u)) { - const int days = GET_TD_DAYS(u); - if (days < -1 || days > 0) - result = 24*60; /* trigger ValueError below */ - else { - /* next line can't overflow because we know days - * is -1 or 0 now - */ - int ss = days * 24 * 3600 + GET_TD_SECONDS(u); - result = divmod(ss, 60, &ss); - if (ss || GET_TD_MICROSECONDS(u)) { - PyErr_Format(PyExc_ValueError, - "tzinfo.%s() must return a " - "whole number of minutes", - name); - result = -1; - } - } - } - else { - PyErr_Format(PyExc_TypeError, - "tzinfo.%s() must return None or " - "timedelta, not '%s'", - name, u->ob_type->tp_name); - } - - Py_DECREF(u); - if (result < -1439 || result > 1439) { - PyErr_Format(PyExc_ValueError, - "tzinfo.%s() returned %d; must be in " - "-1439 .. 1439", - name, result); - result = -1; - } - return result; -} - -/* Call tzinfo.utcoffset(tzinfoarg), and extract an integer from the - * result. tzinfo must be an instance of the tzinfo class. If utcoffset() - * returns None, call_utcoffset returns 0 and sets *none to 1. If uctoffset() - * doesn't return None or timedelta, TypeError is raised and this returns -1. - * If utcoffset() returns an invalid timedelta (out of range, or not a whole - * # of minutes), ValueError is raised and this returns -1. Else *none is - * set to 0 and the offset is returned (as int # of minutes east of UTC). - */ -static int -call_utcoffset(PyObject *tzinfo, PyObject *tzinfoarg, int *none) -{ - return call_utc_tzinfo_method(tzinfo, "utcoffset", tzinfoarg, none); -} - -/* Call tzinfo.name(tzinfoarg), and return the offset as a timedelta or None. - */ -static PyObject * -offset_as_timedelta(PyObject *tzinfo, char *name, PyObject *tzinfoarg) { - PyObject *result; - - assert(tzinfo && name && tzinfoarg); - if (tzinfo == Py_None) { - result = Py_None; - Py_INCREF(result); - } - else { - int none; - int offset = call_utc_tzinfo_method(tzinfo, name, tzinfoarg, - &none); - if (offset < 0 && PyErr_Occurred()) - return NULL; - if (none) { - result = Py_None; - Py_INCREF(result); - } - else - result = new_delta(0, offset * 60, 0, 1); - } - return result; -} - -/* Call tzinfo.dst(tzinfoarg), and extract an integer from the - * result. tzinfo must be an instance of the tzinfo class. If dst() - * returns None, call_dst returns 0 and sets *none to 1. If dst() - & doesn't return None or timedelta, TypeError is raised and this - * returns -1. If dst() returns an invalid timedelta for a UTC offset, - * ValueError is raised and this returns -1. Else *none is set to 0 and - * the offset is returned (as an int # of minutes east of UTC). - */ -static int -call_dst(PyObject *tzinfo, PyObject *tzinfoarg, int *none) -{ - return call_utc_tzinfo_method(tzinfo, "dst", tzinfoarg, none); -} - -/* Call tzinfo.tzname(tzinfoarg), and return the result. tzinfo must be - * an instance of the tzinfo class or None. If tzinfo isn't None, and - * tzname() doesn't return None or a string, TypeError is raised and this - * returns NULL. - */ -static PyObject * -call_tzname(PyObject *tzinfo, PyObject *tzinfoarg) -{ - PyObject *result; - - assert(tzinfo != NULL); - assert(check_tzinfo_subclass(tzinfo) >= 0); - assert(tzinfoarg != NULL); - - if (tzinfo == Py_None) { - result = Py_None; - Py_INCREF(result); - } - else - result = PyObject_CallMethod(tzinfo, "tzname", "O", tzinfoarg); - - if (result != NULL && result != Py_None && ! PyString_Check(result)) { - PyErr_Format(PyExc_TypeError, "tzinfo.tzname() must " - "return None or a string, not '%s'", - result->ob_type->tp_name); - Py_DECREF(result); - result = NULL; - } - return result; -} - -typedef enum { - /* an exception has been set; the caller should pass it on */ - OFFSET_ERROR, - - /* type isn't date, datetime, or time subclass */ - OFFSET_UNKNOWN, - - /* date, - * datetime with !hastzinfo - * datetime with None tzinfo, - * datetime where utcoffset() returns None - * time with !hastzinfo - * time with None tzinfo, - * time where utcoffset() returns None - */ - OFFSET_NAIVE, - - /* time or datetime where utcoffset() doesn't return None */ - OFFSET_AWARE, -} naivety; - -/* Classify an object as to whether it's naive or offset-aware. See - * the "naivety" typedef for details. If the type is aware, *offset is set - * to minutes east of UTC (as returned by the tzinfo.utcoffset() method). - * If the type is offset-naive (or unknown, or error), *offset is set to 0. - * tzinfoarg is the argument to pass to the tzinfo.utcoffset() method. - */ -static naivety -classify_utcoffset(PyObject *op, PyObject *tzinfoarg, int *offset) -{ - int none; - PyObject *tzinfo; - - assert(tzinfoarg != NULL); - *offset = 0; - tzinfo = get_tzinfo_member(op); /* NULL means no tzinfo, not error */ - if (tzinfo == Py_None) - return OFFSET_NAIVE; - if (tzinfo == NULL) { - /* note that a datetime passes the PyDate_Check test */ - return (PyTime_Check(op) || PyDate_Check(op)) ? - OFFSET_NAIVE : OFFSET_UNKNOWN; - } - *offset = call_utcoffset(tzinfo, tzinfoarg, &none); - if (*offset == -1 && PyErr_Occurred()) - return OFFSET_ERROR; - return none ? OFFSET_NAIVE : OFFSET_AWARE; -} - -/* Classify two objects as to whether they're naive or offset-aware. - * This isn't quite the same as calling classify_utcoffset() twice: for - * binary operations (comparison and subtraction), we generally want to - * ignore the tzinfo members if they're identical. This is by design, - * so that results match "naive" expectations when mixing objects from a - * single timezone. So in that case, this sets both offsets to 0 and - * both naiveties to OFFSET_NAIVE. - * The function returns 0 if everything's OK, and -1 on error. - */ -static int -classify_two_utcoffsets(PyObject *o1, int *offset1, naivety *n1, - PyObject *tzinfoarg1, - PyObject *o2, int *offset2, naivety *n2, - PyObject *tzinfoarg2) -{ - if (get_tzinfo_member(o1) == get_tzinfo_member(o2)) { - *offset1 = *offset2 = 0; - *n1 = *n2 = OFFSET_NAIVE; - } - else { - *n1 = classify_utcoffset(o1, tzinfoarg1, offset1); - if (*n1 == OFFSET_ERROR) - return -1; - *n2 = classify_utcoffset(o2, tzinfoarg2, offset2); - if (*n2 == OFFSET_ERROR) - return -1; - } - return 0; -} - -/* repr is like "someclass(arg1, arg2)". If tzinfo isn't None, - * stuff - * ", tzinfo=" + repr(tzinfo) - * before the closing ")". - */ -static PyObject * -append_keyword_tzinfo(PyObject *repr, PyObject *tzinfo) -{ - PyObject *temp; - - assert(PyString_Check(repr)); - assert(tzinfo); - if (tzinfo == Py_None) - return repr; - /* Get rid of the trailing ')'. */ - assert(PyString_AsString(repr)[PyString_Size(repr)-1] == ')'); - temp = PyString_FromStringAndSize(PyString_AsString(repr), - PyString_Size(repr) - 1); - Py_DECREF(repr); - if (temp == NULL) - return NULL; - repr = temp; - - /* Append ", tzinfo=". */ - PyString_ConcatAndDel(&repr, PyString_FromString(", tzinfo=")); - - /* Append repr(tzinfo). */ - PyString_ConcatAndDel(&repr, PyObject_Repr(tzinfo)); - - /* Add a closing paren. */ - PyString_ConcatAndDel(&repr, PyString_FromString(")")); - return repr; -} - -/* --------------------------------------------------------------------------- - * String format helpers. - */ - -static PyObject * -format_ctime(PyDateTime_Date *date, int hours, int minutes, int seconds) -{ - static char *DayNames[] = { - "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" - }; - static char *MonthNames[] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; - - char buffer[128]; - int wday = weekday(GET_YEAR(date), GET_MONTH(date), GET_DAY(date)); - - PyOS_snprintf(buffer, sizeof(buffer), "%s %s %2d %02d:%02d:%02d %04d", - DayNames[wday], MonthNames[GET_MONTH(date) - 1], - GET_DAY(date), hours, minutes, seconds, - GET_YEAR(date)); - return PyString_FromString(buffer); -} - -/* Add an hours & minutes UTC offset string to buf. buf has no more than - * buflen bytes remaining. The UTC offset is gotten by calling - * tzinfo.uctoffset(tzinfoarg). If that returns None, \0 is stored into - * *buf, and that's all. Else the returned value is checked for sanity (an - * integer in range), and if that's OK it's converted to an hours & minutes - * string of the form - * sign HH sep MM - * Returns 0 if everything is OK. If the return value from utcoffset() is - * bogus, an appropriate exception is set and -1 is returned. - */ -static int -format_utcoffset(char *buf, size_t buflen, const char *sep, - PyObject *tzinfo, PyObject *tzinfoarg) -{ - int offset; - int hours; - int minutes; - char sign; - int none; - - offset = call_utcoffset(tzinfo, tzinfoarg, &none); - if (offset == -1 && PyErr_Occurred()) - return -1; - if (none) { - *buf = '\0'; - return 0; - } - sign = '+'; - if (offset < 0) { - sign = '-'; - offset = - offset; - } - hours = divmod(offset, 60, &minutes); - PyOS_snprintf(buf, buflen, "%c%02d%s%02d", sign, hours, sep, minutes); - return 0; -} - -/* I sure don't want to reproduce the strftime code from the time module, - * so this imports the module and calls it. All the hair is due to - * giving special meanings to the %z and %Z format codes via a preprocessing - * step on the format string. - * tzinfoarg is the argument to pass to the object's tzinfo method, if - * needed. - */ -static PyObject * -wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple, - PyObject *tzinfoarg) -{ - PyObject *result = NULL; /* guilty until proved innocent */ - - PyObject *zreplacement = NULL; /* py string, replacement for %z */ - PyObject *Zreplacement = NULL; /* py string, replacement for %Z */ - - char *pin; /* pointer to next char in input format */ - char ch; /* next char in input format */ - - PyObject *newfmt = NULL; /* py string, the output format */ - char *pnew; /* pointer to available byte in output format */ - char totalnew; /* number bytes total in output format buffer, - exclusive of trailing \0 */ - char usednew; /* number bytes used so far in output format buffer */ - - char *ptoappend; /* pointer to string to append to output buffer */ - int ntoappend; /* # of bytes to append to output buffer */ - - assert(object && format && timetuple); - assert(PyString_Check(format)); - - /* Give up if the year is before 1900. - * Python strftime() plays games with the year, and different - * games depending on whether envar PYTHON2K is set. This makes - * years before 1900 a nightmare, even if the platform strftime - * supports them (and not all do). - * We could get a lot farther here by avoiding Python's strftime - * wrapper and calling the C strftime() directly, but that isn't - * an option in the Python implementation of this module. - */ - { - long year; - PyObject *pyyear = PySequence_GetItem(timetuple, 0); - if (pyyear == NULL) return NULL; - assert(PyInt_Check(pyyear)); - year = PyInt_AsLong(pyyear); - Py_DECREF(pyyear); - if (year < 1900) { - PyErr_Format(PyExc_ValueError, "year=%ld is before " - "1900; the datetime strftime() " - "methods require year >= 1900", - year); - return NULL; - } - } - - /* Scan the input format, looking for %z and %Z escapes, building - * a new format. Since computing the replacements for those codes - * is expensive, don't unless they're actually used. - */ - totalnew = PyString_Size(format) + 1; /* realistic if no %z/%Z */ - newfmt = PyString_FromStringAndSize(NULL, totalnew); - if (newfmt == NULL) goto Done; - pnew = PyString_AsString(newfmt); - usednew = 0; - - pin = PyString_AsString(format); - while ((ch = *pin++) != '\0') { - if (ch != '%') { - ptoappend = pin - 1; - ntoappend = 1; - } - else if ((ch = *pin++) == '\0') { - /* There's a lone trailing %; doesn't make sense. */ - PyErr_SetString(PyExc_ValueError, "strftime format " - "ends with raw %"); - goto Done; - } - /* A % has been seen and ch is the character after it. */ - else if (ch == 'z') { - if (zreplacement == NULL) { - /* format utcoffset */ - char buf[100]; - PyObject *tzinfo = get_tzinfo_member(object); - zreplacement = PyString_FromString(""); - if (zreplacement == NULL) goto Done; - if (tzinfo != Py_None && tzinfo != NULL) { - assert(tzinfoarg != NULL); - if (format_utcoffset(buf, - sizeof(buf), - "", - tzinfo, - tzinfoarg) < 0) - goto Done; - Py_DECREF(zreplacement); - zreplacement = PyString_FromString(buf); - if (zreplacement == NULL) goto Done; - } - } - assert(zreplacement != NULL); - ptoappend = PyString_AsString(zreplacement); - ntoappend = PyString_Size(zreplacement); - } - else if (ch == 'Z') { - /* format tzname */ - if (Zreplacement == NULL) { - PyObject *tzinfo = get_tzinfo_member(object); - Zreplacement = PyString_FromString(""); - if (Zreplacement == NULL) goto Done; - if (tzinfo != Py_None && tzinfo != NULL) { - PyObject *temp; - assert(tzinfoarg != NULL); - temp = call_tzname(tzinfo, tzinfoarg); - if (temp == NULL) goto Done; - if (temp != Py_None) { - assert(PyString_Check(temp)); - /* Since the tzname is getting - * stuffed into the format, we - * have to double any % signs - * so that strftime doesn't - * treat them as format codes. - */ - Py_DECREF(Zreplacement); - Zreplacement = PyObject_CallMethod( - temp, "replace", - "ss", "%", "%%"); - Py_DECREF(temp); - if (Zreplacement == NULL) - goto Done; - } - else - Py_DECREF(temp); - } - } - assert(Zreplacement != NULL); - ptoappend = PyString_AsString(Zreplacement); - ntoappend = PyString_Size(Zreplacement); - } - else { - /* percent followed by neither z nor Z */ - ptoappend = pin - 2; - ntoappend = 2; - } - - /* Append the ntoappend chars starting at ptoappend to - * the new format. - */ - assert(ntoappend >= 0); - if (ntoappend == 0) - continue; - while (usednew + ntoappend > totalnew) { - int bigger = totalnew << 1; - if ((bigger >> 1) != totalnew) { /* overflow */ - PyErr_NoMemory(); - goto Done; - } - if (_PyString_Resize(&newfmt, bigger) < 0) - goto Done; - totalnew = bigger; - pnew = PyString_AsString(newfmt) + usednew; - } - memcpy(pnew, ptoappend, ntoappend); - pnew += ntoappend; - usednew += ntoappend; - assert(usednew <= totalnew); - } /* end while() */ - - if (_PyString_Resize(&newfmt, usednew) < 0) - goto Done; - { - PyObject *time = PyImport_ImportModule("time"); - if (time == NULL) - goto Done; - result = PyObject_CallMethod(time, "strftime", "OO", - newfmt, timetuple); - Py_DECREF(time); - } - Done: - Py_XDECREF(zreplacement); - Py_XDECREF(Zreplacement); - Py_XDECREF(newfmt); - return result; -} - -static char * -isoformat_date(PyDateTime_Date *dt, char buffer[], int bufflen) -{ - int x; - x = PyOS_snprintf(buffer, bufflen, - "%04d-%02d-%02d", - GET_YEAR(dt), GET_MONTH(dt), GET_DAY(dt)); - return buffer + x; -} - -static void -isoformat_time(PyDateTime_DateTime *dt, char buffer[], int bufflen) -{ - int us = DATE_GET_MICROSECOND(dt); - - PyOS_snprintf(buffer, bufflen, - "%02d:%02d:%02d", /* 8 characters */ - DATE_GET_HOUR(dt), - DATE_GET_MINUTE(dt), - DATE_GET_SECOND(dt)); - if (us) - PyOS_snprintf(buffer + 8, bufflen - 8, ".%06d", us); -} - -/* --------------------------------------------------------------------------- - * Wrap functions from the time module. These aren't directly available - * from C. Perhaps they should be. - */ - -/* Call time.time() and return its result (a Python float). */ -static PyObject * -time_time(void) -{ - PyObject *result = NULL; - PyObject *time = PyImport_ImportModule("time"); - - if (time != NULL) { - result = PyObject_CallMethod(time, "time", "()"); - Py_DECREF(time); - } - return result; -} - -/* Build a time.struct_time. The weekday and day number are automatically - * computed from the y,m,d args. - */ -static PyObject * -build_struct_time(int y, int m, int d, int hh, int mm, int ss, int dstflag) -{ - PyObject *time; - PyObject *result = NULL; - - time = PyImport_ImportModule("time"); - if (time != NULL) { - result = PyObject_CallMethod(time, "struct_time", - "((iiiiiiiii))", - y, m, d, - hh, mm, ss, - weekday(y, m, d), - days_before_month(y, m) + d, - dstflag); - Py_DECREF(time); - } - return result; -} - -/* --------------------------------------------------------------------------- - * Miscellaneous helpers. - */ - -/* For obscure reasons, we need to use tp_richcompare instead of tp_compare. - * The comparisons here all most naturally compute a cmp()-like result. - * This little helper turns that into a bool result for rich comparisons. - */ -static PyObject * -diff_to_bool(int diff, int op) -{ - PyObject *result; - int istrue; - - switch (op) { - case Py_EQ: istrue = diff == 0; break; - case Py_NE: istrue = diff != 0; break; - case Py_LE: istrue = diff <= 0; break; - case Py_GE: istrue = diff >= 0; break; - case Py_LT: istrue = diff < 0; break; - case Py_GT: istrue = diff > 0; break; - default: - assert(! "op unknown"); - istrue = 0; /* To shut up compiler */ - } - result = istrue ? Py_True : Py_False; - Py_INCREF(result); - return result; -} - -/* Raises a "can't compare" TypeError and returns NULL. */ -static PyObject * -cmperror(PyObject *a, PyObject *b) -{ - PyErr_Format(PyExc_TypeError, - "can't compare %s to %s", - a->ob_type->tp_name, b->ob_type->tp_name); - return NULL; -} - -/* --------------------------------------------------------------------------- - * Cached Python objects; these are set by the module init function. - */ - -/* Conversion factors. */ -static PyObject *us_per_us = NULL; /* 1 */ -static PyObject *us_per_ms = NULL; /* 1000 */ -static PyObject *us_per_second = NULL; /* 1000000 */ -static PyObject *us_per_minute = NULL; /* 1e6 * 60 as Python int */ -static PyObject *us_per_hour = NULL; /* 1e6 * 3600 as Python long */ -static PyObject *us_per_day = NULL; /* 1e6 * 3600 * 24 as Python long */ -static PyObject *us_per_week = NULL; /* 1e6*3600*24*7 as Python long */ -static PyObject *seconds_per_day = NULL; /* 3600*24 as Python int */ - -/* --------------------------------------------------------------------------- - * Class implementations. - */ - -/* - * PyDateTime_Delta implementation. - */ - -/* Convert a timedelta to a number of us, - * (24*3600*self.days + self.seconds)*1000000 + self.microseconds - * as a Python int or long. - * Doing mixed-radix arithmetic by hand instead is excruciating in C, - * due to ubiquitous overflow possibilities. - */ -static PyObject * -delta_to_microseconds(PyDateTime_Delta *self) -{ - PyObject *x1 = NULL; - PyObject *x2 = NULL; - PyObject *x3 = NULL; - PyObject *result = NULL; - - x1 = PyInt_FromLong(GET_TD_DAYS(self)); - if (x1 == NULL) - goto Done; - x2 = PyNumber_Multiply(x1, seconds_per_day); /* days in seconds */ - if (x2 == NULL) - goto Done; - Py_DECREF(x1); - x1 = NULL; - - /* x2 has days in seconds */ - x1 = PyInt_FromLong(GET_TD_SECONDS(self)); /* seconds */ - if (x1 == NULL) - goto Done; - x3 = PyNumber_Add(x1, x2); /* days and seconds in seconds */ - if (x3 == NULL) - goto Done; - Py_DECREF(x1); - Py_DECREF(x2); - x1 = x2 = NULL; - - /* x3 has days+seconds in seconds */ - x1 = PyNumber_Multiply(x3, us_per_second); /* us */ - if (x1 == NULL) - goto Done; - Py_DECREF(x3); - x3 = NULL; - - /* x1 has days+seconds in us */ - x2 = PyInt_FromLong(GET_TD_MICROSECONDS(self)); - if (x2 == NULL) - goto Done; - result = PyNumber_Add(x1, x2); - -Done: - Py_XDECREF(x1); - Py_XDECREF(x2); - Py_XDECREF(x3); - return result; -} - -/* Convert a number of us (as a Python int or long) to a timedelta. - */ -static PyObject * -microseconds_to_delta_ex(PyObject *pyus, PyTypeObject *type) -{ - int us; - int s; - int d; - long temp; - - PyObject *tuple = NULL; - PyObject *num = NULL; - PyObject *result = NULL; - - tuple = PyNumber_Divmod(pyus, us_per_second); - if (tuple == NULL) - goto Done; - - num = PyTuple_GetItem(tuple, 1); /* us */ - if (num == NULL) - goto Done; - temp = PyLong_AsLong(num); - num = NULL; - if (temp == -1 && PyErr_Occurred()) - goto Done; - assert(0 <= temp && temp < 1000000); - us = (int)temp; - if (us < 0) { - /* The divisor was positive, so this must be an error. */ - assert(PyErr_Occurred()); - goto Done; - } - - num = PyTuple_GetItem(tuple, 0); /* leftover seconds */ - if (num == NULL) - goto Done; - Py_INCREF(num); - Py_DECREF(tuple); - - tuple = PyNumber_Divmod(num, seconds_per_day); - if (tuple == NULL) - goto Done; - Py_DECREF(num); - - num = PyTuple_GetItem(tuple, 1); /* seconds */ - if (num == NULL) - goto Done; - temp = PyLong_AsLong(num); - num = NULL; - if (temp == -1 && PyErr_Occurred()) - goto Done; - assert(0 <= temp && temp < 24*3600); - s = (int)temp; - - if (s < 0) { - /* The divisor was positive, so this must be an error. */ - assert(PyErr_Occurred()); - goto Done; - } - - num = PyTuple_GetItem(tuple, 0); /* leftover days */ - if (num == NULL) - goto Done; - Py_INCREF(num); - temp = PyLong_AsLong(num); - if (temp == -1 && PyErr_Occurred()) - goto Done; - d = (int)temp; - if ((long)d != temp) { - PyErr_SetString(PyExc_OverflowError, "normalized days too " - "large to fit in a C int"); - goto Done; - } - result = new_delta_ex(d, s, us, 0, type); - -Done: - Py_XDECREF(tuple); - Py_XDECREF(num); - return result; -} - -#define microseconds_to_delta(pymicros) \ - microseconds_to_delta_ex(pymicros, &PyDateTime_DeltaType) - -static PyObject * -multiply_int_timedelta(PyObject *intobj, PyDateTime_Delta *delta) -{ - PyObject *pyus_in; - PyObject *pyus_out; - PyObject *result; - - pyus_in = delta_to_microseconds(delta); - if (pyus_in == NULL) - return NULL; - - pyus_out = PyNumber_Multiply(pyus_in, intobj); - Py_DECREF(pyus_in); - if (pyus_out == NULL) - return NULL; - - result = microseconds_to_delta(pyus_out); - Py_DECREF(pyus_out); - return result; -} - -static PyObject * -divide_timedelta_int(PyDateTime_Delta *delta, PyObject *intobj) -{ - PyObject *pyus_in; - PyObject *pyus_out; - PyObject *result; - - pyus_in = delta_to_microseconds(delta); - if (pyus_in == NULL) - return NULL; - - pyus_out = PyNumber_FloorDivide(pyus_in, intobj); - Py_DECREF(pyus_in); - if (pyus_out == NULL) - return NULL; - - result = microseconds_to_delta(pyus_out); - Py_DECREF(pyus_out); - return result; -} - -static PyObject * -delta_add(PyObject *left, PyObject *right) -{ - PyObject *result = Py_NotImplemented; - - if (PyDelta_Check(left) && PyDelta_Check(right)) { - /* delta + delta */ - /* The C-level additions can't overflow because of the - * invariant bounds. - */ - int days = GET_TD_DAYS(left) + GET_TD_DAYS(right); - int seconds = GET_TD_SECONDS(left) + GET_TD_SECONDS(right); - int microseconds = GET_TD_MICROSECONDS(left) + - GET_TD_MICROSECONDS(right); - result = new_delta(days, seconds, microseconds, 1); - } - - if (result == Py_NotImplemented) - Py_INCREF(result); - return result; -} - -static PyObject * -delta_negative(PyDateTime_Delta *self) -{ - return new_delta(-GET_TD_DAYS(self), - -GET_TD_SECONDS(self), - -GET_TD_MICROSECONDS(self), - 1); -} - -static PyObject * -delta_positive(PyDateTime_Delta *self) -{ - /* Could optimize this (by returning self) if this isn't a - * subclass -- but who uses unary + ? Approximately nobody. - */ - return new_delta(GET_TD_DAYS(self), - GET_TD_SECONDS(self), - GET_TD_MICROSECONDS(self), - 0); -} - -static PyObject * -delta_abs(PyDateTime_Delta *self) -{ - PyObject *result; - - assert(GET_TD_MICROSECONDS(self) >= 0); - assert(GET_TD_SECONDS(self) >= 0); - - if (GET_TD_DAYS(self) < 0) - result = delta_negative(self); - else - result = delta_positive(self); - - return result; -} - -static PyObject * -delta_subtract(PyObject *left, PyObject *right) -{ - PyObject *result = Py_NotImplemented; - - if (PyDelta_Check(left) && PyDelta_Check(right)) { - /* delta - delta */ - PyObject *minus_right = PyNumber_Negative(right); - if (minus_right) { - result = delta_add(left, minus_right); - Py_DECREF(minus_right); - } - else - result = NULL; - } - - if (result == Py_NotImplemented) - Py_INCREF(result); - return result; -} - -/* This is more natural as a tp_compare, but doesn't work then: for whatever - * reason, Python's try_3way_compare ignores tp_compare unless - * PyInstance_Check returns true, but these aren't old-style classes. - */ -static PyObject * -delta_richcompare(PyDateTime_Delta *self, PyObject *other, int op) -{ - int diff = 42; /* nonsense */ - - if (PyDelta_Check(other)) { - diff = GET_TD_DAYS(self) - GET_TD_DAYS(other); - if (diff == 0) { - diff = GET_TD_SECONDS(self) - GET_TD_SECONDS(other); - if (diff == 0) - diff = GET_TD_MICROSECONDS(self) - - GET_TD_MICROSECONDS(other); - } - } - else if (op == Py_EQ || op == Py_NE) - diff = 1; /* any non-zero value will do */ - - else /* stop this from falling back to address comparison */ - return cmperror((PyObject *)self, other); - - return diff_to_bool(diff, op); -} - -static PyObject *delta_getstate(PyDateTime_Delta *self); - -static long -delta_hash(PyDateTime_Delta *self) -{ - if (self->hashcode == -1) { - PyObject *temp = delta_getstate(self); - if (temp != NULL) { - self->hashcode = PyObject_Hash(temp); - Py_DECREF(temp); - } - } - return self->hashcode; -} - -static PyObject * -delta_multiply(PyObject *left, PyObject *right) -{ - PyObject *result = Py_NotImplemented; - - if (PyDelta_Check(left)) { - /* delta * ??? */ - if (PyInt_Check(right) || PyLong_Check(right)) - result = multiply_int_timedelta(right, - (PyDateTime_Delta *) left); - } - else if (PyInt_Check(left) || PyLong_Check(left)) - result = multiply_int_timedelta(left, - (PyDateTime_Delta *) right); - - if (result == Py_NotImplemented) - Py_INCREF(result); - return result; -} - -static PyObject * -delta_divide(PyObject *left, PyObject *right) -{ - PyObject *result = Py_NotImplemented; - - if (PyDelta_Check(left)) { - /* delta * ??? */ - if (PyInt_Check(right) || PyLong_Check(right)) - result = divide_timedelta_int( - (PyDateTime_Delta *)left, - right); - } - - if (result == Py_NotImplemented) - Py_INCREF(result); - return result; -} - -/* Fold in the value of the tag ("seconds", "weeks", etc) component of a - * timedelta constructor. sofar is the # of microseconds accounted for - * so far, and there are factor microseconds per current unit, the number - * of which is given by num. num * factor is added to sofar in a - * numerically careful way, and that's the result. Any fractional - * microseconds left over (this can happen if num is a float type) are - * added into *leftover. - * Note that there are many ways this can give an error (NULL) return. - */ -static PyObject * -accum(const char* tag, PyObject *sofar, PyObject *num, PyObject *factor, - double *leftover) -{ - PyObject *prod; - PyObject *sum; - - assert(num != NULL); - - if (PyInt_Check(num) || PyLong_Check(num)) { - prod = PyNumber_Multiply(num, factor); - if (prod == NULL) - return NULL; - sum = PyNumber_Add(sofar, prod); - Py_DECREF(prod); - return sum; - } - - if (PyFloat_Check(num)) { - double dnum; - double fracpart; - double intpart; - PyObject *x; - PyObject *y; - - /* The Plan: decompose num into an integer part and a - * fractional part, num = intpart + fracpart. - * Then num * factor == - * intpart * factor + fracpart * factor - * and the LHS can be computed exactly in long arithmetic. - * The RHS is again broken into an int part and frac part. - * and the frac part is added into *leftover. - */ - dnum = PyFloat_AsDouble(num); - if (dnum == -1.0 && PyErr_Occurred()) - return NULL; - fracpart = modf(dnum, &intpart); - x = PyLong_FromDouble(intpart); - if (x == NULL) - return NULL; - - prod = PyNumber_Multiply(x, factor); - Py_DECREF(x); - if (prod == NULL) - return NULL; - - sum = PyNumber_Add(sofar, prod); - Py_DECREF(prod); - if (sum == NULL) - return NULL; - - if (fracpart == 0.0) - return sum; - /* So far we've lost no information. Dealing with the - * fractional part requires float arithmetic, and may - * lose a little info. - */ - assert(PyInt_Check(factor) || PyLong_Check(factor)); - if (PyInt_Check(factor)) - dnum = (double)PyInt_AsLong(factor); - else - dnum = PyLong_AsDouble(factor); - - dnum *= fracpart; - fracpart = modf(dnum, &intpart); - x = PyLong_FromDouble(intpart); - if (x == NULL) { - Py_DECREF(sum); - return NULL; - } - - y = PyNumber_Add(sum, x); - Py_DECREF(sum); - Py_DECREF(x); - *leftover += fracpart; - return y; - } - - PyErr_Format(PyExc_TypeError, - "unsupported type for timedelta %s component: %s", - tag, num->ob_type->tp_name); - return NULL; -} - -static PyObject * -delta_new(PyTypeObject *type, PyObject *args, PyObject *kw) -{ - PyObject *self = NULL; - - /* Argument objects. */ - PyObject *day = NULL; - PyObject *second = NULL; - PyObject *us = NULL; - PyObject *ms = NULL; - PyObject *minute = NULL; - PyObject *hour = NULL; - PyObject *week = NULL; - - PyObject *x = NULL; /* running sum of microseconds */ - PyObject *y = NULL; /* temp sum of microseconds */ - double leftover_us = 0.0; - - static char *keywords[] = { - "days", "seconds", "microseconds", "milliseconds", - "minutes", "hours", "weeks", NULL - }; - - if (PyArg_ParseTupleAndKeywords(args, kw, "|OOOOOOO:__new__", - keywords, - &day, &second, &us, - &ms, &minute, &hour, &week) == 0) - goto Done; - - x = PyInt_FromLong(0); - if (x == NULL) - goto Done; - -#define CLEANUP \ - Py_DECREF(x); \ - x = y; \ - if (x == NULL) \ - goto Done - - if (us) { - y = accum("microseconds", x, us, us_per_us, &leftover_us); - CLEANUP; - } - if (ms) { - y = accum("milliseconds", x, ms, us_per_ms, &leftover_us); - CLEANUP; - } - if (second) { - y = accum("seconds", x, second, us_per_second, &leftover_us); - CLEANUP; - } - if (minute) { - y = accum("minutes", x, minute, us_per_minute, &leftover_us); - CLEANUP; - } - if (hour) { - y = accum("hours", x, hour, us_per_hour, &leftover_us); - CLEANUP; - } - if (day) { - y = accum("days", x, day, us_per_day, &leftover_us); - CLEANUP; - } - if (week) { - y = accum("weeks", x, week, us_per_week, &leftover_us); - CLEANUP; - } - if (leftover_us) { - /* Round to nearest whole # of us, and add into x. */ - PyObject *temp = PyLong_FromLong(round_to_long(leftover_us)); - if (temp == NULL) { - Py_DECREF(x); - goto Done; - } - y = PyNumber_Add(x, temp); - Py_DECREF(temp); - CLEANUP; - } - - self = microseconds_to_delta_ex(x, type); - Py_DECREF(x); -Done: - return self; - -#undef CLEANUP -} - -static int -delta_nonzero(PyDateTime_Delta *self) -{ - return (GET_TD_DAYS(self) != 0 - || GET_TD_SECONDS(self) != 0 - || GET_TD_MICROSECONDS(self) != 0); -} - -static PyObject * -delta_repr(PyDateTime_Delta *self) -{ - if (GET_TD_MICROSECONDS(self) != 0) - return PyString_FromFormat("%s(%d, %d, %d)", - self->ob_type->tp_name, - GET_TD_DAYS(self), - GET_TD_SECONDS(self), - GET_TD_MICROSECONDS(self)); - if (GET_TD_SECONDS(self) != 0) - return PyString_FromFormat("%s(%d, %d)", - self->ob_type->tp_name, - GET_TD_DAYS(self), - GET_TD_SECONDS(self)); - - return PyString_FromFormat("%s(%d)", - self->ob_type->tp_name, - GET_TD_DAYS(self)); -} - -static PyObject * -delta_str(PyDateTime_Delta *self) -{ - int days = GET_TD_DAYS(self); - int seconds = GET_TD_SECONDS(self); - int us = GET_TD_MICROSECONDS(self); - int hours; - int minutes; - char buf[100]; - char *pbuf = buf; - size_t buflen = sizeof(buf); - int n; - - minutes = divmod(seconds, 60, &seconds); - hours = divmod(minutes, 60, &minutes); - - if (days) { - n = PyOS_snprintf(pbuf, buflen, "%d day%s, ", days, - (days == 1 || days == -1) ? "" : "s"); - if (n < 0 || (size_t)n >= buflen) - goto Fail; - pbuf += n; - buflen -= (size_t)n; - } - - n = PyOS_snprintf(pbuf, buflen, "%d:%02d:%02d", - hours, minutes, seconds); - if (n < 0 || (size_t)n >= buflen) - goto Fail; - pbuf += n; - buflen -= (size_t)n; - - if (us) { - n = PyOS_snprintf(pbuf, buflen, ".%06d", us); - if (n < 0 || (size_t)n >= buflen) - goto Fail; - pbuf += n; - } - - return PyString_FromStringAndSize(buf, pbuf - buf); - - Fail: - PyErr_SetString(PyExc_SystemError, "goofy result from PyOS_snprintf"); - return NULL; -} - -/* Pickle support, a simple use of __reduce__. */ - -/* __getstate__ isn't exposed */ -static PyObject * -delta_getstate(PyDateTime_Delta *self) -{ - return Py_BuildValue("iii", GET_TD_DAYS(self), - GET_TD_SECONDS(self), - GET_TD_MICROSECONDS(self)); -} - -static PyObject * -delta_reduce(PyDateTime_Delta* self) -{ - return Py_BuildValue("ON", self->ob_type, delta_getstate(self)); -} - -#define OFFSET(field) offsetof(PyDateTime_Delta, field) - -static PyMemberDef delta_members[] = { - - {"days", T_INT, OFFSET(days), READONLY, - PyDoc_STR("Number of days.")}, - - {"seconds", T_INT, OFFSET(seconds), READONLY, - PyDoc_STR("Number of seconds (>= 0 and less than 1 day).")}, - - {"microseconds", T_INT, OFFSET(microseconds), READONLY, - PyDoc_STR("Number of microseconds (>= 0 and less than 1 second).")}, - {NULL} -}; - -static PyMethodDef delta_methods[] = { - {"__reduce__", (PyCFunction)delta_reduce, METH_NOARGS, - PyDoc_STR("__reduce__() -> (cls, state)")}, - - {NULL, NULL}, -}; - -static char delta_doc[] = -PyDoc_STR("Difference between two datetime values."); - -static PyNumberMethods delta_as_number = { - delta_add, /* nb_add */ - delta_subtract, /* nb_subtract */ - delta_multiply, /* nb_multiply */ - delta_divide, /* nb_divide */ - 0, /* nb_remainder */ - 0, /* nb_divmod */ - 0, /* nb_power */ - (unaryfunc)delta_negative, /* nb_negative */ - (unaryfunc)delta_positive, /* nb_positive */ - (unaryfunc)delta_abs, /* nb_absolute */ - (inquiry)delta_nonzero, /* nb_nonzero */ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - 0, /*nb_coerce*/ - 0, /*nb_int*/ - 0, /*nb_long*/ - 0, /*nb_float*/ - 0, /*nb_oct*/ - 0, /*nb_hex*/ - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - 0, /*nb_inplace_divide*/ - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - delta_divide, /* nb_floor_divide */ - 0, /* nb_true_divide */ - 0, /* nb_inplace_floor_divide */ - 0, /* nb_inplace_true_divide */ -}; - -static PyTypeObject PyDateTime_DeltaType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "datetime.timedelta", /* tp_name */ - sizeof(PyDateTime_Delta), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)delta_repr, /* tp_repr */ - &delta_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)delta_hash, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)delta_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - delta_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)delta_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - delta_methods, /* tp_methods */ - delta_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - delta_new, /* tp_new */ - 0, /* tp_free */ -}; - -/* - * PyDateTime_Date implementation. - */ - -/* Accessor properties. */ - -static PyObject * -date_year(PyDateTime_Date *self, void *unused) -{ - return PyInt_FromLong(GET_YEAR(self)); -} - -static PyObject * -date_month(PyDateTime_Date *self, void *unused) -{ - return PyInt_FromLong(GET_MONTH(self)); -} - -static PyObject * -date_day(PyDateTime_Date *self, void *unused) -{ - return PyInt_FromLong(GET_DAY(self)); -} - -static PyGetSetDef date_getset[] = { - {"year", (getter)date_year}, - {"month", (getter)date_month}, - {"day", (getter)date_day}, - {NULL} -}; - -/* Constructors. */ - -static char *date_kws[] = {"year", "month", "day", NULL}; - -static PyObject * -date_new(PyTypeObject *type, PyObject *args, PyObject *kw) -{ - PyObject *self = NULL; - PyObject *state; - int year; - int month; - int day; - - /* Check for invocation from pickle with __getstate__ state */ - if (PyTuple_GET_SIZE(args) == 1 && - PyString_Check(state = PyTuple_GET_ITEM(args, 0)) && - PyString_GET_SIZE(state) == _PyDateTime_DATE_DATASIZE) - { - PyDateTime_Date *me; - - me = PyObject_New(PyDateTime_Date, type); - if (me != NULL) { - char *pdata = PyString_AS_STRING(state); - memcpy(me->data, pdata, _PyDateTime_DATE_DATASIZE); - me->hashcode = -1; - } - return (PyObject *)me; - } - - if (PyArg_ParseTupleAndKeywords(args, kw, "iii", date_kws, - &year, &month, &day)) { - if (check_date_args(year, month, day) < 0) - return NULL; - self = new_date_ex(year, month, day, type); - } - return self; -} - -/* Return new date from localtime(t). */ -static PyObject * -date_local_from_time_t(PyObject *cls, time_t t) -{ - struct tm *tm; - PyObject *result = NULL; - - tm = localtime(&t); - if (tm) - result = PyObject_CallFunction(cls, "iii", - tm->tm_year + 1900, - tm->tm_mon + 1, - tm->tm_mday); - else - PyErr_SetString(PyExc_ValueError, - "timestamp out of range for " - "platform localtime() function"); - return result; -} - -/* Return new date from current time. - * We say this is equivalent to fromtimestamp(time.time()), and the - * only way to be sure of that is to *call* time.time(). That's not - * generally the same as calling C's time. - */ -static PyObject * -date_today(PyObject *cls, PyObject *dummy) -{ - PyObject *time; - PyObject *result; - - time = time_time(); - if (time == NULL) - return NULL; - - /* Note well: today() is a class method, so this may not call - * date.fromtimestamp. For example, it may call - * datetime.fromtimestamp. That's why we need all the accuracy - * time.time() delivers; if someone were gonzo about optimization, - * date.today() could get away with plain C time(). - */ - result = PyObject_CallMethod(cls, "fromtimestamp", "O", time); - Py_DECREF(time); - return result; -} - -/* Return new date from given timestamp (Python timestamp -- a double). */ -static PyObject * -date_fromtimestamp(PyObject *cls, PyObject *args) -{ - double timestamp; - PyObject *result = NULL; - - if (PyArg_ParseTuple(args, "d:fromtimestamp", ×tamp)) - result = date_local_from_time_t(cls, (time_t)timestamp); - return result; -} - -/* Return new date from proleptic Gregorian ordinal. Raises ValueError if - * the ordinal is out of range. - */ -static PyObject * -date_fromordinal(PyObject *cls, PyObject *args) -{ - PyObject *result = NULL; - int ordinal; - - if (PyArg_ParseTuple(args, "i:fromordinal", &ordinal)) { - int year; - int month; - int day; - - if (ordinal < 1) - PyErr_SetString(PyExc_ValueError, "ordinal must be " - ">= 1"); - else { - ord_to_ymd(ordinal, &year, &month, &day); - result = PyObject_CallFunction(cls, "iii", - year, month, day); - } - } - return result; -} - -/* - * Date arithmetic. - */ - -/* date + timedelta -> date. If arg negate is true, subtract the timedelta - * instead. - */ -static PyObject * -add_date_timedelta(PyDateTime_Date *date, PyDateTime_Delta *delta, int negate) -{ - PyObject *result = NULL; - int year = GET_YEAR(date); - int month = GET_MONTH(date); - int deltadays = GET_TD_DAYS(delta); - /* C-level overflow is impossible because |deltadays| < 1e9. */ - int day = GET_DAY(date) + (negate ? -deltadays : deltadays); - - if (normalize_date(&year, &month, &day) >= 0) - result = new_date(year, month, day); - return result; -} - -static PyObject * -date_add(PyObject *left, PyObject *right) -{ - if (PyDateTime_Check(left) || PyDateTime_Check(right)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - if (PyDate_Check(left)) { - /* date + ??? */ - if (PyDelta_Check(right)) - /* date + delta */ - return add_date_timedelta((PyDateTime_Date *) left, - (PyDateTime_Delta *) right, - 0); - } - else { - /* ??? + date - * 'right' must be one of us, or we wouldn't have been called - */ - if (PyDelta_Check(left)) - /* delta + date */ - return add_date_timedelta((PyDateTime_Date *) right, - (PyDateTime_Delta *) left, - 0); - } - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; -} - -static PyObject * -date_subtract(PyObject *left, PyObject *right) -{ - if (PyDateTime_Check(left) || PyDateTime_Check(right)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - if (PyDate_Check(left)) { - if (PyDate_Check(right)) { - /* date - date */ - int left_ord = ymd_to_ord(GET_YEAR(left), - GET_MONTH(left), - GET_DAY(left)); - int right_ord = ymd_to_ord(GET_YEAR(right), - GET_MONTH(right), - GET_DAY(right)); - return new_delta(left_ord - right_ord, 0, 0, 0); - } - if (PyDelta_Check(right)) { - /* date - delta */ - return add_date_timedelta((PyDateTime_Date *) left, - (PyDateTime_Delta *) right, - 1); - } - } - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; -} - - -/* Various ways to turn a date into a string. */ - -static PyObject * -date_repr(PyDateTime_Date *self) -{ - char buffer[1028]; - char *typename; - - typename = self->ob_type->tp_name; - PyOS_snprintf(buffer, sizeof(buffer), "%s(%d, %d, %d)", - typename, - GET_YEAR(self), GET_MONTH(self), GET_DAY(self)); - - return PyString_FromString(buffer); -} - -static PyObject * -date_isoformat(PyDateTime_Date *self) -{ - char buffer[128]; - - isoformat_date(self, buffer, sizeof(buffer)); - return PyString_FromString(buffer); -} - -/* str() calls the appropriate isoformat() method. */ -static PyObject * -date_str(PyDateTime_Date *self) -{ - return PyObject_CallMethod((PyObject *)self, "isoformat", "()"); -} - - -static PyObject * -date_ctime(PyDateTime_Date *self) -{ - return format_ctime(self, 0, 0, 0); -} - -static PyObject * -date_strftime(PyDateTime_Date *self, PyObject *args, PyObject *kw) -{ - /* This method can be inherited, and needs to call the - * timetuple() method appropriate to self's class. - */ - PyObject *result; - PyObject *format; - PyObject *tuple; - static char *keywords[] = {"format", NULL}; - - if (! PyArg_ParseTupleAndKeywords(args, kw, "O!:strftime", keywords, - &PyString_Type, &format)) - return NULL; - - tuple = PyObject_CallMethod((PyObject *)self, "timetuple", "()"); - if (tuple == NULL) - return NULL; - result = wrap_strftime((PyObject *)self, format, tuple, - (PyObject *)self); - Py_DECREF(tuple); - return result; -} - -/* ISO methods. */ - -static PyObject * -date_isoweekday(PyDateTime_Date *self) -{ - int dow = weekday(GET_YEAR(self), GET_MONTH(self), GET_DAY(self)); - - return PyInt_FromLong(dow + 1); -} - -static PyObject * -date_isocalendar(PyDateTime_Date *self) -{ - int year = GET_YEAR(self); - int week1_monday = iso_week1_monday(year); - int today = ymd_to_ord(year, GET_MONTH(self), GET_DAY(self)); - int week; - int day; - - week = divmod(today - week1_monday, 7, &day); - if (week < 0) { - --year; - week1_monday = iso_week1_monday(year); - week = divmod(today - week1_monday, 7, &day); - } - else if (week >= 52 && today >= iso_week1_monday(year + 1)) { - ++year; - week = 0; - } - return Py_BuildValue("iii", year, week + 1, day + 1); -} - -/* Miscellaneous methods. */ - -/* This is more natural as a tp_compare, but doesn't work then: for whatever - * reason, Python's try_3way_compare ignores tp_compare unless - * PyInstance_Check returns true, but these aren't old-style classes. - */ -static PyObject * -date_richcompare(PyDateTime_Date *self, PyObject *other, int op) -{ - int diff = 42; /* nonsense */ - - if (PyDate_Check(other)) - diff = memcmp(self->data, ((PyDateTime_Date *)other)->data, - _PyDateTime_DATE_DATASIZE); - - else if (PyObject_HasAttrString(other, "timetuple")) { - /* A hook for other kinds of date objects. */ - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - else if (op == Py_EQ || op == Py_NE) - diff = 1; /* any non-zero value will do */ - - else /* stop this from falling back to address comparison */ - return cmperror((PyObject *)self, other); - - return diff_to_bool(diff, op); -} - -static PyObject * -date_timetuple(PyDateTime_Date *self) -{ - return build_struct_time(GET_YEAR(self), - GET_MONTH(self), - GET_DAY(self), - 0, 0, 0, -1); -} - -static PyObject * -date_replace(PyDateTime_Date *self, PyObject *args, PyObject *kw) -{ - PyObject *clone; - PyObject *tuple; - int year = GET_YEAR(self); - int month = GET_MONTH(self); - int day = GET_DAY(self); - - if (! PyArg_ParseTupleAndKeywords(args, kw, "|iii:replace", date_kws, - &year, &month, &day)) - return NULL; - tuple = Py_BuildValue("iii", year, month, day); - if (tuple == NULL) - return NULL; - clone = date_new(self->ob_type, tuple, NULL); - Py_DECREF(tuple); - return clone; -} - -static PyObject *date_getstate(PyDateTime_Date *self); - -static long -date_hash(PyDateTime_Date *self) -{ - if (self->hashcode == -1) { - PyObject *temp = date_getstate(self); - if (temp != NULL) { - self->hashcode = PyObject_Hash(temp); - Py_DECREF(temp); - } - } - return self->hashcode; -} - -static PyObject * -date_toordinal(PyDateTime_Date *self) -{ - return PyInt_FromLong(ymd_to_ord(GET_YEAR(self), GET_MONTH(self), - GET_DAY(self))); -} - -static PyObject * -date_weekday(PyDateTime_Date *self) -{ - int dow = weekday(GET_YEAR(self), GET_MONTH(self), GET_DAY(self)); - - return PyInt_FromLong(dow); -} - -/* Pickle support, a simple use of __reduce__. */ - -/* __getstate__ isn't exposed */ -static PyObject * -date_getstate(PyDateTime_Date *self) -{ - return Py_BuildValue( - "(N)", - PyString_FromStringAndSize((char *)self->data, - _PyDateTime_DATE_DATASIZE)); -} - -static PyObject * -date_reduce(PyDateTime_Date *self, PyObject *arg) -{ - return Py_BuildValue("(ON)", self->ob_type, date_getstate(self)); -} - -static PyMethodDef date_methods[] = { - - /* Class methods: */ - - {"fromtimestamp", (PyCFunction)date_fromtimestamp, METH_VARARGS | - METH_CLASS, - PyDoc_STR("timestamp -> local date from a POSIX timestamp (like " - "time.time()).")}, - - {"fromordinal", (PyCFunction)date_fromordinal, METH_VARARGS | - METH_CLASS, - PyDoc_STR("int -> date corresponding to a proleptic Gregorian " - "ordinal.")}, - - {"today", (PyCFunction)date_today, METH_NOARGS | METH_CLASS, - PyDoc_STR("Current date or datetime: same as " - "self.__class__.fromtimestamp(time.time()).")}, - - /* Instance methods: */ - - {"ctime", (PyCFunction)date_ctime, METH_NOARGS, - PyDoc_STR("Return ctime() style string.")}, - - {"strftime", (PyCFunction)date_strftime, METH_KEYWORDS, - PyDoc_STR("format -> strftime() style string.")}, - - {"timetuple", (PyCFunction)date_timetuple, METH_NOARGS, - PyDoc_STR("Return time tuple, compatible with time.localtime().")}, - - {"isocalendar", (PyCFunction)date_isocalendar, METH_NOARGS, - PyDoc_STR("Return a 3-tuple containing ISO year, week number, and " - "weekday.")}, - - {"isoformat", (PyCFunction)date_isoformat, METH_NOARGS, - PyDoc_STR("Return string in ISO 8601 format, YYYY-MM-DD.")}, - - {"isoweekday", (PyCFunction)date_isoweekday, METH_NOARGS, - PyDoc_STR("Return the day of the week represented by the date.\n" - "Monday == 1 ... Sunday == 7")}, - - {"toordinal", (PyCFunction)date_toordinal, METH_NOARGS, - PyDoc_STR("Return proleptic Gregorian ordinal. January 1 of year " - "1 is day 1.")}, - - {"weekday", (PyCFunction)date_weekday, METH_NOARGS, - PyDoc_STR("Return the day of the week represented by the date.\n" - "Monday == 0 ... Sunday == 6")}, - - {"replace", (PyCFunction)date_replace, METH_KEYWORDS, - PyDoc_STR("Return date with new specified fields.")}, - - {"__reduce__", (PyCFunction)date_reduce, METH_NOARGS, - PyDoc_STR("__reduce__() -> (cls, state)")}, - - {NULL, NULL} -}; - -static char date_doc[] = -PyDoc_STR("Basic date type."); - -static PyNumberMethods date_as_number = { - date_add, /* nb_add */ - date_subtract, /* nb_subtract */ - 0, /* nb_multiply */ - 0, /* nb_divide */ - 0, /* nb_remainder */ - 0, /* nb_divmod */ - 0, /* nb_power */ - 0, /* nb_negative */ - 0, /* nb_positive */ - 0, /* nb_absolute */ - 0, /* nb_nonzero */ -}; - -static PyTypeObject PyDateTime_DateType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "datetime.date", /* tp_name */ - sizeof(PyDateTime_Date), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)date_repr, /* tp_repr */ - &date_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)date_hash, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)date_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - date_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)date_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - date_methods, /* tp_methods */ - 0, /* tp_members */ - date_getset, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - date_new, /* tp_new */ - 0, /* tp_free */ -}; - -/* - * PyDateTime_TZInfo implementation. - */ - -/* This is a pure abstract base class, so doesn't do anything beyond - * raising NotImplemented exceptions. Real tzinfo classes need - * to derive from this. This is mostly for clarity, and for efficiency in - * datetime and time constructors (their tzinfo arguments need to - * be subclasses of this tzinfo class, which is easy and quick to check). - * - * Note: For reasons having to do with pickling of subclasses, we have - * to allow tzinfo objects to be instantiated. This wasn't an issue - * in the Python implementation (__init__() could raise NotImplementedError - * there without ill effect), but doing so in the C implementation hit a - * brick wall. - */ - -static PyObject * -tzinfo_nogo(const char* methodname) -{ - PyErr_Format(PyExc_NotImplementedError, - "a tzinfo subclass must implement %s()", - methodname); - return NULL; -} - -/* Methods. A subclass must implement these. */ - -static PyObject * -tzinfo_tzname(PyDateTime_TZInfo *self, PyObject *dt) -{ - return tzinfo_nogo("tzname"); -} - -static PyObject * -tzinfo_utcoffset(PyDateTime_TZInfo *self, PyObject *dt) -{ - return tzinfo_nogo("utcoffset"); -} - -static PyObject * -tzinfo_dst(PyDateTime_TZInfo *self, PyObject *dt) -{ - return tzinfo_nogo("dst"); -} - -static PyObject * -tzinfo_fromutc(PyDateTime_TZInfo *self, PyDateTime_DateTime *dt) -{ - int y, m, d, hh, mm, ss, us; - - PyObject *result; - int off, dst; - int none; - int delta; - - if (! PyDateTime_Check(dt)) { - PyErr_SetString(PyExc_TypeError, - "fromutc: argument must be a datetime"); - return NULL; - } - if (! HASTZINFO(dt) || dt->tzinfo != (PyObject *)self) { - PyErr_SetString(PyExc_ValueError, "fromutc: dt.tzinfo " - "is not self"); - return NULL; - } - - off = call_utcoffset(dt->tzinfo, (PyObject *)dt, &none); - if (off == -1 && PyErr_Occurred()) - return NULL; - if (none) { - PyErr_SetString(PyExc_ValueError, "fromutc: non-None " - "utcoffset() result required"); - return NULL; - } - - dst = call_dst(dt->tzinfo, (PyObject *)dt, &none); - if (dst == -1 && PyErr_Occurred()) - return NULL; - if (none) { - PyErr_SetString(PyExc_ValueError, "fromutc: non-None " - "dst() result required"); - return NULL; - } - - y = GET_YEAR(dt); - m = GET_MONTH(dt); - d = GET_DAY(dt); - hh = DATE_GET_HOUR(dt); - mm = DATE_GET_MINUTE(dt); - ss = DATE_GET_SECOND(dt); - us = DATE_GET_MICROSECOND(dt); - - delta = off - dst; - mm += delta; - if ((mm < 0 || mm >= 60) && - normalize_datetime(&y, &m, &d, &hh, &mm, &ss, &us) < 0) - return NULL; - result = new_datetime(y, m, d, hh, mm, ss, us, dt->tzinfo); - if (result == NULL) - return result; - - dst = call_dst(dt->tzinfo, result, &none); - if (dst == -1 && PyErr_Occurred()) - goto Fail; - if (none) - goto Inconsistent; - if (dst == 0) - return result; - - mm += dst; - if ((mm < 0 || mm >= 60) && - normalize_datetime(&y, &m, &d, &hh, &mm, &ss, &us) < 0) - goto Fail; - Py_DECREF(result); - result = new_datetime(y, m, d, hh, mm, ss, us, dt->tzinfo); - return result; - -Inconsistent: - PyErr_SetString(PyExc_ValueError, "fromutc: tz.dst() gave" - "inconsistent results; cannot convert"); - - /* fall thru to failure */ -Fail: - Py_DECREF(result); - return NULL; -} - -/* - * Pickle support. This is solely so that tzinfo subclasses can use - * pickling -- tzinfo itself is supposed to be uninstantiable. - */ - -static PyObject * -tzinfo_reduce(PyObject *self) -{ - PyObject *args, *state, *tmp; - PyObject *getinitargs, *getstate; - - tmp = PyTuple_New(0); - if (tmp == NULL) - return NULL; - - getinitargs = PyObject_GetAttrString(self, "__getinitargs__"); - if (getinitargs != NULL) { - args = PyObject_CallObject(getinitargs, tmp); - Py_DECREF(getinitargs); - if (args == NULL) { - Py_DECREF(tmp); - return NULL; - } - } - else { - PyErr_Clear(); - args = tmp; - Py_INCREF(args); - } - - getstate = PyObject_GetAttrString(self, "__getstate__"); - if (getstate != NULL) { - state = PyObject_CallObject(getstate, tmp); - Py_DECREF(getstate); - if (state == NULL) { - Py_DECREF(args); - Py_DECREF(tmp); - return NULL; - } - } - else { - PyObject **dictptr; - PyErr_Clear(); - state = Py_None; - dictptr = _PyObject_GetDictPtr(self); - if (dictptr && *dictptr && PyDict_Size(*dictptr)) - state = *dictptr; - Py_INCREF(state); - } - - Py_DECREF(tmp); - - if (state == Py_None) { - Py_DECREF(state); - return Py_BuildValue("(ON)", self->ob_type, args); - } - else - return Py_BuildValue("(ONN)", self->ob_type, args, state); -} - -static PyMethodDef tzinfo_methods[] = { - - {"tzname", (PyCFunction)tzinfo_tzname, METH_O, - PyDoc_STR("datetime -> string name of time zone.")}, - - {"utcoffset", (PyCFunction)tzinfo_utcoffset, METH_O, - PyDoc_STR("datetime -> minutes east of UTC (negative for " - "west of UTC).")}, - - {"dst", (PyCFunction)tzinfo_dst, METH_O, - PyDoc_STR("datetime -> DST offset in minutes east of UTC.")}, - - {"fromutc", (PyCFunction)tzinfo_fromutc, METH_O, - PyDoc_STR("datetime in UTC -> datetime in local time.")}, - - {"__reduce__", (PyCFunction)tzinfo_reduce, METH_NOARGS, - PyDoc_STR("-> (cls, state)")}, - - {NULL, NULL} -}; - -static char tzinfo_doc[] = -PyDoc_STR("Abstract base class for time zone info objects."); - -statichere PyTypeObject PyDateTime_TZInfoType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "datetime.tzinfo", /* tp_name */ - sizeof(PyDateTime_TZInfo), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - tzinfo_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - tzinfo_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - 0, /* tp_free */ -}; - -/* - * PyDateTime_Time implementation. - */ - -/* Accessor properties. - */ - -static PyObject * -time_hour(PyDateTime_Time *self, void *unused) -{ - return PyInt_FromLong(TIME_GET_HOUR(self)); -} - -static PyObject * -time_minute(PyDateTime_Time *self, void *unused) -{ - return PyInt_FromLong(TIME_GET_MINUTE(self)); -} - -/* The name time_second conflicted with some platform header file. */ -static PyObject * -py_time_second(PyDateTime_Time *self, void *unused) -{ - return PyInt_FromLong(TIME_GET_SECOND(self)); -} - -static PyObject * -time_microsecond(PyDateTime_Time *self, void *unused) -{ - return PyInt_FromLong(TIME_GET_MICROSECOND(self)); -} - -static PyObject * -time_tzinfo(PyDateTime_Time *self, void *unused) -{ - PyObject *result = HASTZINFO(self) ? self->tzinfo : Py_None; - Py_INCREF(result); - return result; -} - -static PyGetSetDef time_getset[] = { - {"hour", (getter)time_hour}, - {"minute", (getter)time_minute}, - {"second", (getter)py_time_second}, - {"microsecond", (getter)time_microsecond}, - {"tzinfo", (getter)time_tzinfo}, - {NULL} -}; - -/* - * Constructors. - */ - -static char *time_kws[] = {"hour", "minute", "second", "microsecond", - "tzinfo", NULL}; - -static PyObject * -time_new(PyTypeObject *type, PyObject *args, PyObject *kw) -{ - PyObject *self = NULL; - PyObject *state; - int hour = 0; - int minute = 0; - int second = 0; - int usecond = 0; - PyObject *tzinfo = Py_None; - - /* Check for invocation from pickle with __getstate__ state */ - if (PyTuple_GET_SIZE(args) >= 1 && - PyTuple_GET_SIZE(args) <= 2 && - PyString_Check(state = PyTuple_GET_ITEM(args, 0)) && - PyString_GET_SIZE(state) == _PyDateTime_TIME_DATASIZE) - { - PyDateTime_Time *me; - char aware; - - if (PyTuple_GET_SIZE(args) == 2) { - tzinfo = PyTuple_GET_ITEM(args, 1); - if (check_tzinfo_subclass(tzinfo) < 0) { - PyErr_SetString(PyExc_TypeError, "bad " - "tzinfo state arg"); - return NULL; - } - } - aware = (char)(tzinfo != Py_None); - me = (PyDateTime_Time *) time_alloc(&PyDateTime_TimeType, - aware); - if (me != NULL) { - char *pdata = PyString_AS_STRING(state); - - memcpy(me->data, pdata, _PyDateTime_TIME_DATASIZE); - me->hashcode = -1; - me->hastzinfo = aware; - if (aware) { - Py_INCREF(tzinfo); - me->tzinfo = tzinfo; - } - } - return (PyObject *)me; - } - - if (PyArg_ParseTupleAndKeywords(args, kw, "|iiiiO", time_kws, - &hour, &minute, &second, &usecond, - &tzinfo)) { - if (check_time_args(hour, minute, second, usecond) < 0) - return NULL; - if (check_tzinfo_subclass(tzinfo) < 0) - return NULL; - self = new_time_ex(hour, minute, second, usecond, tzinfo, - type); - } - return self; -} - -/* - * Destructor. - */ - -static void -time_dealloc(PyDateTime_Time *self) -{ - if (HASTZINFO(self)) { - Py_XDECREF(self->tzinfo); - } - self->ob_type->tp_free((PyObject *)self); -} - -/* - * Indirect access to tzinfo methods. - */ - -/* These are all METH_NOARGS, so don't need to check the arglist. */ -static PyObject * -time_utcoffset(PyDateTime_Time *self, PyObject *unused) { - return offset_as_timedelta(HASTZINFO(self) ? self->tzinfo : Py_None, - "utcoffset", Py_None); -} - -static PyObject * -time_dst(PyDateTime_Time *self, PyObject *unused) { - return offset_as_timedelta(HASTZINFO(self) ? self->tzinfo : Py_None, - "dst", Py_None); -} - -static PyObject * -time_tzname(PyDateTime_Time *self, PyObject *unused) { - return call_tzname(HASTZINFO(self) ? self->tzinfo : Py_None, - Py_None); -} - -/* - * Various ways to turn a time into a string. - */ - -static PyObject * -time_repr(PyDateTime_Time *self) -{ - char buffer[100]; - char *typename = self->ob_type->tp_name; - int h = TIME_GET_HOUR(self); - int m = TIME_GET_MINUTE(self); - int s = TIME_GET_SECOND(self); - int us = TIME_GET_MICROSECOND(self); - PyObject *result = NULL; - - if (us) - PyOS_snprintf(buffer, sizeof(buffer), - "%s(%d, %d, %d, %d)", typename, h, m, s, us); - else if (s) - PyOS_snprintf(buffer, sizeof(buffer), - "%s(%d, %d, %d)", typename, h, m, s); - else - PyOS_snprintf(buffer, sizeof(buffer), - "%s(%d, %d)", typename, h, m); - result = PyString_FromString(buffer); - if (result != NULL && HASTZINFO(self)) - result = append_keyword_tzinfo(result, self->tzinfo); - return result; -} - -static PyObject * -time_str(PyDateTime_Time *self) -{ - return PyObject_CallMethod((PyObject *)self, "isoformat", "()"); -} - -static PyObject * -time_isoformat(PyDateTime_Time *self) -{ - char buf[100]; - PyObject *result; - /* Reuse the time format code from the datetime type. */ - PyDateTime_DateTime datetime; - PyDateTime_DateTime *pdatetime = &datetime; - - /* Copy over just the time bytes. */ - memcpy(pdatetime->data + _PyDateTime_DATE_DATASIZE, - self->data, - _PyDateTime_TIME_DATASIZE); - - isoformat_time(pdatetime, buf, sizeof(buf)); - result = PyString_FromString(buf); - if (result == NULL || ! HASTZINFO(self) || self->tzinfo == Py_None) - return result; - - /* We need to append the UTC offset. */ - if (format_utcoffset(buf, sizeof(buf), ":", self->tzinfo, - Py_None) < 0) { - Py_DECREF(result); - return NULL; - } - PyString_ConcatAndDel(&result, PyString_FromString(buf)); - return result; -} - -static PyObject * -time_strftime(PyDateTime_Time *self, PyObject *args, PyObject *kw) -{ - PyObject *result; - PyObject *format; - PyObject *tuple; - static char *keywords[] = {"format", NULL}; - - if (! PyArg_ParseTupleAndKeywords(args, kw, "O!:strftime", keywords, - &PyString_Type, &format)) - return NULL; - - /* Python's strftime does insane things with the year part of the - * timetuple. The year is forced to (the otherwise nonsensical) - * 1900 to worm around that. - */ - tuple = Py_BuildValue("iiiiiiiii", - 1900, 0, 0, /* year, month, day */ - TIME_GET_HOUR(self), - TIME_GET_MINUTE(self), - TIME_GET_SECOND(self), - 0, 0, -1); /* weekday, daynum, dst */ - if (tuple == NULL) - return NULL; - assert(PyTuple_Size(tuple) == 9); - result = wrap_strftime((PyObject *)self, format, tuple, Py_None); - Py_DECREF(tuple); - return result; -} - -/* - * Miscellaneous methods. - */ - -/* This is more natural as a tp_compare, but doesn't work then: for whatever - * reason, Python's try_3way_compare ignores tp_compare unless - * PyInstance_Check returns true, but these aren't old-style classes. - */ -static PyObject * -time_richcompare(PyDateTime_Time *self, PyObject *other, int op) -{ - int diff; - naivety n1, n2; - int offset1, offset2; - - if (! PyTime_Check(other)) { - if (op == Py_EQ || op == Py_NE) { - PyObject *result = op == Py_EQ ? Py_False : Py_True; - Py_INCREF(result); - return result; - } - /* Stop this from falling back to address comparison. */ - return cmperror((PyObject *)self, other); - } - if (classify_two_utcoffsets((PyObject *)self, &offset1, &n1, Py_None, - other, &offset2, &n2, Py_None) < 0) - return NULL; - assert(n1 != OFFSET_UNKNOWN && n2 != OFFSET_UNKNOWN); - /* If they're both naive, or both aware and have the same offsets, - * we get off cheap. Note that if they're both naive, offset1 == - * offset2 == 0 at this point. - */ - if (n1 == n2 && offset1 == offset2) { - diff = memcmp(self->data, ((PyDateTime_Time *)other)->data, - _PyDateTime_TIME_DATASIZE); - return diff_to_bool(diff, op); - } - - if (n1 == OFFSET_AWARE && n2 == OFFSET_AWARE) { - assert(offset1 != offset2); /* else last "if" handled it */ - /* Convert everything except microseconds to seconds. These - * can't overflow (no more than the # of seconds in 2 days). - */ - offset1 = TIME_GET_HOUR(self) * 3600 + - (TIME_GET_MINUTE(self) - offset1) * 60 + - TIME_GET_SECOND(self); - offset2 = TIME_GET_HOUR(other) * 3600 + - (TIME_GET_MINUTE(other) - offset2) * 60 + - TIME_GET_SECOND(other); - diff = offset1 - offset2; - if (diff == 0) - diff = TIME_GET_MICROSECOND(self) - - TIME_GET_MICROSECOND(other); - return diff_to_bool(diff, op); - } - - assert(n1 != n2); - PyErr_SetString(PyExc_TypeError, - "can't compare offset-naive and " - "offset-aware times"); - return NULL; -} - -static long -time_hash(PyDateTime_Time *self) -{ - if (self->hashcode == -1) { - naivety n; - int offset; - PyObject *temp; - - n = classify_utcoffset((PyObject *)self, Py_None, &offset); - assert(n != OFFSET_UNKNOWN); - if (n == OFFSET_ERROR) - return -1; - - /* Reduce this to a hash of another object. */ - if (offset == 0) - temp = PyString_FromStringAndSize((char *)self->data, - _PyDateTime_TIME_DATASIZE); - else { - int hour; - int minute; - - assert(n == OFFSET_AWARE); - assert(HASTZINFO(self)); - hour = divmod(TIME_GET_HOUR(self) * 60 + - TIME_GET_MINUTE(self) - offset, - 60, - &minute); - if (0 <= hour && hour < 24) - temp = new_time(hour, minute, - TIME_GET_SECOND(self), - TIME_GET_MICROSECOND(self), - Py_None); - else - temp = Py_BuildValue("iiii", - hour, minute, - TIME_GET_SECOND(self), - TIME_GET_MICROSECOND(self)); - } - if (temp != NULL) { - self->hashcode = PyObject_Hash(temp); - Py_DECREF(temp); - } - } - return self->hashcode; -} - -static PyObject * -time_replace(PyDateTime_Time *self, PyObject *args, PyObject *kw) -{ - PyObject *clone; - PyObject *tuple; - int hh = TIME_GET_HOUR(self); - int mm = TIME_GET_MINUTE(self); - int ss = TIME_GET_SECOND(self); - int us = TIME_GET_MICROSECOND(self); - PyObject *tzinfo = HASTZINFO(self) ? self->tzinfo : Py_None; - - if (! PyArg_ParseTupleAndKeywords(args, kw, "|iiiiO:replace", - time_kws, - &hh, &mm, &ss, &us, &tzinfo)) - return NULL; - tuple = Py_BuildValue("iiiiO", hh, mm, ss, us, tzinfo); - if (tuple == NULL) - return NULL; - clone = time_new(self->ob_type, tuple, NULL); - Py_DECREF(tuple); - return clone; -} - -static int -time_nonzero(PyDateTime_Time *self) -{ - int offset; - int none; - - if (TIME_GET_SECOND(self) || TIME_GET_MICROSECOND(self)) { - /* Since utcoffset is in whole minutes, nothing can - * alter the conclusion that this is nonzero. - */ - return 1; - } - offset = 0; - if (HASTZINFO(self) && self->tzinfo != Py_None) { - offset = call_utcoffset(self->tzinfo, Py_None, &none); - if (offset == -1 && PyErr_Occurred()) - return -1; - } - return (TIME_GET_MINUTE(self) - offset + TIME_GET_HOUR(self)*60) != 0; -} - -/* Pickle support, a simple use of __reduce__. */ - -/* Let basestate be the non-tzinfo data string. - * If tzinfo is None, this returns (basestate,), else (basestate, tzinfo). - * So it's a tuple in any (non-error) case. - * __getstate__ isn't exposed. - */ -static PyObject * -time_getstate(PyDateTime_Time *self) -{ - PyObject *basestate; - PyObject *result = NULL; - - basestate = PyString_FromStringAndSize((char *)self->data, - _PyDateTime_TIME_DATASIZE); - if (basestate != NULL) { - if (! HASTZINFO(self) || self->tzinfo == Py_None) - result = Py_BuildValue("(O)", basestate); - else - result = Py_BuildValue("OO", basestate, self->tzinfo); - Py_DECREF(basestate); - } - return result; -} - -static PyObject * -time_reduce(PyDateTime_Time *self, PyObject *arg) -{ - return Py_BuildValue("(ON)", self->ob_type, time_getstate(self)); -} - -static PyMethodDef time_methods[] = { - - {"isoformat", (PyCFunction)time_isoformat, METH_KEYWORDS, - PyDoc_STR("Return string in ISO 8601 format, HH:MM:SS[.mmmmmm]" - "[+HH:MM].")}, - - {"strftime", (PyCFunction)time_strftime, METH_KEYWORDS, - PyDoc_STR("format -> strftime() style string.")}, - - {"utcoffset", (PyCFunction)time_utcoffset, METH_NOARGS, - PyDoc_STR("Return self.tzinfo.utcoffset(self).")}, - - {"tzname", (PyCFunction)time_tzname, METH_NOARGS, - PyDoc_STR("Return self.tzinfo.tzname(self).")}, - - {"dst", (PyCFunction)time_dst, METH_NOARGS, - PyDoc_STR("Return self.tzinfo.dst(self).")}, - - {"replace", (PyCFunction)time_replace, METH_KEYWORDS, - PyDoc_STR("Return time with new specified fields.")}, - - {"__reduce__", (PyCFunction)time_reduce, METH_NOARGS, - PyDoc_STR("__reduce__() -> (cls, state)")}, - - {NULL, NULL} -}; - -static char time_doc[] = -PyDoc_STR("Time type."); - -static PyNumberMethods time_as_number = { - 0, /* nb_add */ - 0, /* nb_subtract */ - 0, /* nb_multiply */ - 0, /* nb_divide */ - 0, /* nb_remainder */ - 0, /* nb_divmod */ - 0, /* nb_power */ - 0, /* nb_negative */ - 0, /* nb_positive */ - 0, /* nb_absolute */ - (inquiry)time_nonzero, /* nb_nonzero */ -}; - -statichere PyTypeObject PyDateTime_TimeType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "datetime.time", /* tp_name */ - sizeof(PyDateTime_Time), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)time_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)time_repr, /* tp_repr */ - &time_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)time_hash, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)time_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - time_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)time_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - time_methods, /* tp_methods */ - 0, /* tp_members */ - time_getset, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - time_alloc, /* tp_alloc */ - time_new, /* tp_new */ - 0, /* tp_free */ -}; - -/* - * PyDateTime_DateTime implementation. - */ - -/* Accessor properties. Properties for day, month, and year are inherited - * from date. - */ - -static PyObject * -datetime_hour(PyDateTime_DateTime *self, void *unused) -{ - return PyInt_FromLong(DATE_GET_HOUR(self)); -} - -static PyObject * -datetime_minute(PyDateTime_DateTime *self, void *unused) -{ - return PyInt_FromLong(DATE_GET_MINUTE(self)); -} - -static PyObject * -datetime_second(PyDateTime_DateTime *self, void *unused) -{ - return PyInt_FromLong(DATE_GET_SECOND(self)); -} - -static PyObject * -datetime_microsecond(PyDateTime_DateTime *self, void *unused) -{ - return PyInt_FromLong(DATE_GET_MICROSECOND(self)); -} - -static PyObject * -datetime_tzinfo(PyDateTime_DateTime *self, void *unused) -{ - PyObject *result = HASTZINFO(self) ? self->tzinfo : Py_None; - Py_INCREF(result); - return result; -} - -static PyGetSetDef datetime_getset[] = { - {"hour", (getter)datetime_hour}, - {"minute", (getter)datetime_minute}, - {"second", (getter)datetime_second}, - {"microsecond", (getter)datetime_microsecond}, - {"tzinfo", (getter)datetime_tzinfo}, - {NULL} -}; - -/* - * Constructors. - */ - -static char *datetime_kws[] = { - "year", "month", "day", "hour", "minute", "second", - "microsecond", "tzinfo", NULL -}; - -static PyObject * -datetime_new(PyTypeObject *type, PyObject *args, PyObject *kw) -{ - PyObject *self = NULL; - PyObject *state; - int year; - int month; - int day; - int hour = 0; - int minute = 0; - int second = 0; - int usecond = 0; - PyObject *tzinfo = Py_None; - - /* Check for invocation from pickle with __getstate__ state */ - if (PyTuple_GET_SIZE(args) >= 1 && - PyTuple_GET_SIZE(args) <= 2 && - PyString_Check(state = PyTuple_GET_ITEM(args, 0)) && - PyString_GET_SIZE(state) == _PyDateTime_DATETIME_DATASIZE) - { - PyDateTime_DateTime *me; - char aware; - - if (PyTuple_GET_SIZE(args) == 2) { - tzinfo = PyTuple_GET_ITEM(args, 1); - if (check_tzinfo_subclass(tzinfo) < 0) { - PyErr_SetString(PyExc_TypeError, "bad " - "tzinfo state arg"); - return NULL; - } - } - aware = (char)(tzinfo != Py_None); - me = (PyDateTime_DateTime *) datetime_alloc( - &PyDateTime_DateTimeType, - aware); - if (me != NULL) { - char *pdata = PyString_AS_STRING(state); - - memcpy(me->data, pdata, _PyDateTime_DATETIME_DATASIZE); - me->hashcode = -1; - me->hastzinfo = aware; - if (aware) { - Py_INCREF(tzinfo); - me->tzinfo = tzinfo; - } - } - return (PyObject *)me; - } - - if (PyArg_ParseTupleAndKeywords(args, kw, "iii|iiiiO", datetime_kws, - &year, &month, &day, &hour, &minute, - &second, &usecond, &tzinfo)) { - if (check_date_args(year, month, day) < 0) - return NULL; - if (check_time_args(hour, minute, second, usecond) < 0) - return NULL; - if (check_tzinfo_subclass(tzinfo) < 0) - return NULL; - self = new_datetime_ex(year, month, day, - hour, minute, second, usecond, - tzinfo, type); - } - return self; -} - -/* TM_FUNC is the shared type of localtime() and gmtime(). */ -typedef struct tm *(*TM_FUNC)(const time_t *timer); - -/* Internal helper. - * Build datetime from a time_t and a distinct count of microseconds. - * Pass localtime or gmtime for f, to control the interpretation of timet. - */ -static PyObject * -datetime_from_timet_and_us(PyObject *cls, TM_FUNC f, time_t timet, int us, - PyObject *tzinfo) -{ - struct tm *tm; - PyObject *result = NULL; - - tm = f(&timet); - if (tm) { - /* The platform localtime/gmtime may insert leap seconds, - * indicated by tm->tm_sec > 59. We don't care about them, - * except to the extent that passing them on to the datetime - * constructor would raise ValueError for a reason that - * made no sense to the user. - */ - if (tm->tm_sec > 59) - tm->tm_sec = 59; - result = PyObject_CallFunction(cls, "iiiiiiiO", - tm->tm_year + 1900, - tm->tm_mon + 1, - tm->tm_mday, - tm->tm_hour, - tm->tm_min, - tm->tm_sec, - us, - tzinfo); - } - else - PyErr_SetString(PyExc_ValueError, - "timestamp out of range for " - "platform localtime()/gmtime() function"); - return result; -} - -/* Internal helper. - * Build datetime from a Python timestamp. Pass localtime or gmtime for f, - * to control the interpretation of the timestamp. Since a double doesn't - * have enough bits to cover a datetime's full range of precision, it's - * better to call datetime_from_timet_and_us provided you have a way - * to get that much precision (e.g., C time() isn't good enough). - */ -static PyObject * -datetime_from_timestamp(PyObject *cls, TM_FUNC f, double timestamp, - PyObject *tzinfo) -{ - time_t timet = (time_t)timestamp; - double fraction = timestamp - (double)timet; - int us = (int)round_to_long(fraction * 1e6); - - return datetime_from_timet_and_us(cls, f, timet, us, tzinfo); -} - -/* Internal helper. - * Build most accurate possible datetime for current time. Pass localtime or - * gmtime for f as appropriate. - */ -static PyObject * -datetime_best_possible(PyObject *cls, TM_FUNC f, PyObject *tzinfo) -{ -#ifdef HAVE_GETTIMEOFDAY - struct timeval t; - -#ifdef GETTIMEOFDAY_NO_TZ - gettimeofday(&t); -#else - gettimeofday(&t, (struct timezone *)NULL); -#endif - return datetime_from_timet_and_us(cls, f, t.tv_sec, (int)t.tv_usec, - tzinfo); - -#else /* ! HAVE_GETTIMEOFDAY */ - /* No flavor of gettimeofday exists on this platform. Python's - * time.time() does a lot of other platform tricks to get the - * best time it can on the platform, and we're not going to do - * better than that (if we could, the better code would belong - * in time.time()!) We're limited by the precision of a double, - * though. - */ - PyObject *time; - double dtime; - - time = time_time(); - if (time == NULL) - return NULL; - dtime = PyFloat_AsDouble(time); - Py_DECREF(time); - if (dtime == -1.0 && PyErr_Occurred()) - return NULL; - return datetime_from_timestamp(cls, f, dtime, tzinfo); -#endif /* ! HAVE_GETTIMEOFDAY */ -} - -/* Return best possible local time -- this isn't constrained by the - * precision of a timestamp. - */ -static PyObject * -datetime_now(PyObject *cls, PyObject *args, PyObject *kw) -{ - PyObject *self; - PyObject *tzinfo = Py_None; - static char *keywords[] = {"tz", NULL}; - - if (! PyArg_ParseTupleAndKeywords(args, kw, "|O:now", keywords, - &tzinfo)) - return NULL; - if (check_tzinfo_subclass(tzinfo) < 0) - return NULL; - - self = datetime_best_possible(cls, - tzinfo == Py_None ? localtime : gmtime, - tzinfo); - if (self != NULL && tzinfo != Py_None) { - /* Convert UTC to tzinfo's zone. */ - PyObject *temp = self; - self = PyObject_CallMethod(tzinfo, "fromutc", "O", self); - Py_DECREF(temp); - } - return self; -} - -/* Return best possible UTC time -- this isn't constrained by the - * precision of a timestamp. - */ -static PyObject * -datetime_utcnow(PyObject *cls, PyObject *dummy) -{ - return datetime_best_possible(cls, gmtime, Py_None); -} - -/* Return new local datetime from timestamp (Python timestamp -- a double). */ -static PyObject * -datetime_fromtimestamp(PyObject *cls, PyObject *args, PyObject *kw) -{ - PyObject *self; - double timestamp; - PyObject *tzinfo = Py_None; - static char *keywords[] = {"timestamp", "tz", NULL}; - - if (! PyArg_ParseTupleAndKeywords(args, kw, "d|O:fromtimestamp", - keywords, ×tamp, &tzinfo)) - return NULL; - if (check_tzinfo_subclass(tzinfo) < 0) - return NULL; - - self = datetime_from_timestamp(cls, - tzinfo == Py_None ? localtime : gmtime, - timestamp, - tzinfo); - if (self != NULL && tzinfo != Py_None) { - /* Convert UTC to tzinfo's zone. */ - PyObject *temp = self; - self = PyObject_CallMethod(tzinfo, "fromutc", "O", self); - Py_DECREF(temp); - } - return self; -} - -/* Return new UTC datetime from timestamp (Python timestamp -- a double). */ -static PyObject * -datetime_utcfromtimestamp(PyObject *cls, PyObject *args) -{ - double timestamp; - PyObject *result = NULL; - - if (PyArg_ParseTuple(args, "d:utcfromtimestamp", ×tamp)) - result = datetime_from_timestamp(cls, gmtime, timestamp, - Py_None); - return result; -} - -/* Return new datetime from date/datetime and time arguments. */ -static PyObject * -datetime_combine(PyObject *cls, PyObject *args, PyObject *kw) -{ - static char *keywords[] = {"date", "time", NULL}; - PyObject *date; - PyObject *time; - PyObject *result = NULL; - - if (PyArg_ParseTupleAndKeywords(args, kw, "O!O!:combine", keywords, - &PyDateTime_DateType, &date, - &PyDateTime_TimeType, &time)) { - PyObject *tzinfo = Py_None; - - if (HASTZINFO(time)) - tzinfo = ((PyDateTime_Time *)time)->tzinfo; - result = PyObject_CallFunction(cls, "iiiiiiiO", - GET_YEAR(date), - GET_MONTH(date), - GET_DAY(date), - TIME_GET_HOUR(time), - TIME_GET_MINUTE(time), - TIME_GET_SECOND(time), - TIME_GET_MICROSECOND(time), - tzinfo); - } - return result; -} - -/* - * Destructor. - */ - -static void -datetime_dealloc(PyDateTime_DateTime *self) -{ - if (HASTZINFO(self)) { - Py_XDECREF(self->tzinfo); - } - self->ob_type->tp_free((PyObject *)self); -} - -/* - * Indirect access to tzinfo methods. - */ - -/* These are all METH_NOARGS, so don't need to check the arglist. */ -static PyObject * -datetime_utcoffset(PyDateTime_DateTime *self, PyObject *unused) { - return offset_as_timedelta(HASTZINFO(self) ? self->tzinfo : Py_None, - "utcoffset", (PyObject *)self); -} - -static PyObject * -datetime_dst(PyDateTime_DateTime *self, PyObject *unused) { - return offset_as_timedelta(HASTZINFO(self) ? self->tzinfo : Py_None, - "dst", (PyObject *)self); -} - -static PyObject * -datetime_tzname(PyDateTime_DateTime *self, PyObject *unused) { - return call_tzname(HASTZINFO(self) ? self->tzinfo : Py_None, - (PyObject *)self); -} - -/* - * datetime arithmetic. - */ - -/* factor must be 1 (to add) or -1 (to subtract). The result inherits - * the tzinfo state of date. - */ -static PyObject * -add_datetime_timedelta(PyDateTime_DateTime *date, PyDateTime_Delta *delta, - int factor) -{ - /* Note that the C-level additions can't overflow, because of - * invariant bounds on the member values. - */ - int year = GET_YEAR(date); - int month = GET_MONTH(date); - int day = GET_DAY(date) + GET_TD_DAYS(delta) * factor; - int hour = DATE_GET_HOUR(date); - int minute = DATE_GET_MINUTE(date); - int second = DATE_GET_SECOND(date) + GET_TD_SECONDS(delta) * factor; - int microsecond = DATE_GET_MICROSECOND(date) + - GET_TD_MICROSECONDS(delta) * factor; - - assert(factor == 1 || factor == -1); - if (normalize_datetime(&year, &month, &day, - &hour, &minute, &second, µsecond) < 0) - return NULL; - else - return new_datetime(year, month, day, - hour, minute, second, microsecond, - HASTZINFO(date) ? date->tzinfo : Py_None); -} - -static PyObject * -datetime_add(PyObject *left, PyObject *right) -{ - if (PyDateTime_Check(left)) { - /* datetime + ??? */ - if (PyDelta_Check(right)) - /* datetime + delta */ - return add_datetime_timedelta( - (PyDateTime_DateTime *)left, - (PyDateTime_Delta *)right, - 1); - } - else if (PyDelta_Check(left)) { - /* delta + datetime */ - return add_datetime_timedelta((PyDateTime_DateTime *) right, - (PyDateTime_Delta *) left, - 1); - } - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; -} - -static PyObject * -datetime_subtract(PyObject *left, PyObject *right) -{ - PyObject *result = Py_NotImplemented; - - if (PyDateTime_Check(left)) { - /* datetime - ??? */ - if (PyDateTime_Check(right)) { - /* datetime - datetime */ - naivety n1, n2; - int offset1, offset2; - int delta_d, delta_s, delta_us; - - if (classify_two_utcoffsets(left, &offset1, &n1, left, - right, &offset2, &n2, - right) < 0) - return NULL; - assert(n1 != OFFSET_UNKNOWN && n2 != OFFSET_UNKNOWN); - if (n1 != n2) { - PyErr_SetString(PyExc_TypeError, - "can't subtract offset-naive and " - "offset-aware datetimes"); - return NULL; - } - delta_d = ymd_to_ord(GET_YEAR(left), - GET_MONTH(left), - GET_DAY(left)) - - ymd_to_ord(GET_YEAR(right), - GET_MONTH(right), - GET_DAY(right)); - /* These can't overflow, since the values are - * normalized. At most this gives the number of - * seconds in one day. - */ - delta_s = (DATE_GET_HOUR(left) - - DATE_GET_HOUR(right)) * 3600 + - (DATE_GET_MINUTE(left) - - DATE_GET_MINUTE(right)) * 60 + - (DATE_GET_SECOND(left) - - DATE_GET_SECOND(right)); - delta_us = DATE_GET_MICROSECOND(left) - - DATE_GET_MICROSECOND(right); - /* (left - offset1) - (right - offset2) = - * (left - right) + (offset2 - offset1) - */ - delta_s += (offset2 - offset1) * 60; - result = new_delta(delta_d, delta_s, delta_us, 1); - } - else if (PyDelta_Check(right)) { - /* datetime - delta */ - result = add_datetime_timedelta( - (PyDateTime_DateTime *)left, - (PyDateTime_Delta *)right, - -1); - } - } - - if (result == Py_NotImplemented) - Py_INCREF(result); - return result; -} - -/* Various ways to turn a datetime into a string. */ - -static PyObject * -datetime_repr(PyDateTime_DateTime *self) -{ - char buffer[1000]; - char *typename = self->ob_type->tp_name; - PyObject *baserepr; - - if (DATE_GET_MICROSECOND(self)) { - PyOS_snprintf(buffer, sizeof(buffer), - "%s(%d, %d, %d, %d, %d, %d, %d)", - typename, - GET_YEAR(self), GET_MONTH(self), GET_DAY(self), - DATE_GET_HOUR(self), DATE_GET_MINUTE(self), - DATE_GET_SECOND(self), - DATE_GET_MICROSECOND(self)); - } - else if (DATE_GET_SECOND(self)) { - PyOS_snprintf(buffer, sizeof(buffer), - "%s(%d, %d, %d, %d, %d, %d)", - typename, - GET_YEAR(self), GET_MONTH(self), GET_DAY(self), - DATE_GET_HOUR(self), DATE_GET_MINUTE(self), - DATE_GET_SECOND(self)); - } - else { - PyOS_snprintf(buffer, sizeof(buffer), - "%s(%d, %d, %d, %d, %d)", - typename, - GET_YEAR(self), GET_MONTH(self), GET_DAY(self), - DATE_GET_HOUR(self), DATE_GET_MINUTE(self)); - } - baserepr = PyString_FromString(buffer); - if (baserepr == NULL || ! HASTZINFO(self)) - return baserepr; - return append_keyword_tzinfo(baserepr, self->tzinfo); -} - -static PyObject * -datetime_str(PyDateTime_DateTime *self) -{ - return PyObject_CallMethod((PyObject *)self, "isoformat", "(s)", " "); -} - -static PyObject * -datetime_isoformat(PyDateTime_DateTime *self, PyObject *args, PyObject *kw) -{ - char sep = 'T'; - static char *keywords[] = {"sep", NULL}; - char buffer[100]; - char *cp; - PyObject *result; - - if (!PyArg_ParseTupleAndKeywords(args, kw, "|c:isoformat", keywords, - &sep)) - return NULL; - cp = isoformat_date((PyDateTime_Date *)self, buffer, sizeof(buffer)); - assert(cp != NULL); - *cp++ = sep; - isoformat_time(self, cp, sizeof(buffer) - (cp - buffer)); - result = PyString_FromString(buffer); - if (result == NULL || ! HASTZINFO(self)) - return result; - - /* We need to append the UTC offset. */ - if (format_utcoffset(buffer, sizeof(buffer), ":", self->tzinfo, - (PyObject *)self) < 0) { - Py_DECREF(result); - return NULL; - } - PyString_ConcatAndDel(&result, PyString_FromString(buffer)); - return result; -} - -static PyObject * -datetime_ctime(PyDateTime_DateTime *self) -{ - return format_ctime((PyDateTime_Date *)self, - DATE_GET_HOUR(self), - DATE_GET_MINUTE(self), - DATE_GET_SECOND(self)); -} - -/* Miscellaneous methods. */ - -/* This is more natural as a tp_compare, but doesn't work then: for whatever - * reason, Python's try_3way_compare ignores tp_compare unless - * PyInstance_Check returns true, but these aren't old-style classes. - */ -static PyObject * -datetime_richcompare(PyDateTime_DateTime *self, PyObject *other, int op) -{ - int diff; - naivety n1, n2; - int offset1, offset2; - - if (! PyDateTime_Check(other)) { - if (PyObject_HasAttrString(other, "timetuple")) { - /* A hook for other kinds of datetime objects. */ - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - if (op == Py_EQ || op == Py_NE) { - PyObject *result = op == Py_EQ ? Py_False : Py_True; - Py_INCREF(result); - return result; - } - /* Stop this from falling back to address comparison. */ - return cmperror((PyObject *)self, other); - } - - if (classify_two_utcoffsets((PyObject *)self, &offset1, &n1, - (PyObject *)self, - other, &offset2, &n2, - other) < 0) - return NULL; - assert(n1 != OFFSET_UNKNOWN && n2 != OFFSET_UNKNOWN); - /* If they're both naive, or both aware and have the same offsets, - * we get off cheap. Note that if they're both naive, offset1 == - * offset2 == 0 at this point. - */ - if (n1 == n2 && offset1 == offset2) { - diff = memcmp(self->data, ((PyDateTime_DateTime *)other)->data, - _PyDateTime_DATETIME_DATASIZE); - return diff_to_bool(diff, op); - } - - if (n1 == OFFSET_AWARE && n2 == OFFSET_AWARE) { - PyDateTime_Delta *delta; - - assert(offset1 != offset2); /* else last "if" handled it */ - delta = (PyDateTime_Delta *)datetime_subtract((PyObject *)self, - other); - if (delta == NULL) - return NULL; - diff = GET_TD_DAYS(delta); - if (diff == 0) - diff = GET_TD_SECONDS(delta) | - GET_TD_MICROSECONDS(delta); - Py_DECREF(delta); - return diff_to_bool(diff, op); - } - - assert(n1 != n2); - PyErr_SetString(PyExc_TypeError, - "can't compare offset-naive and " - "offset-aware datetimes"); - return NULL; -} - -static long -datetime_hash(PyDateTime_DateTime *self) -{ - if (self->hashcode == -1) { - naivety n; - int offset; - PyObject *temp; - - n = classify_utcoffset((PyObject *)self, (PyObject *)self, - &offset); - assert(n != OFFSET_UNKNOWN); - if (n == OFFSET_ERROR) - return -1; - - /* Reduce this to a hash of another object. */ - if (n == OFFSET_NAIVE) - temp = PyString_FromStringAndSize( - (char *)self->data, - _PyDateTime_DATETIME_DATASIZE); - else { - int days; - int seconds; - - assert(n == OFFSET_AWARE); - assert(HASTZINFO(self)); - days = ymd_to_ord(GET_YEAR(self), - GET_MONTH(self), - GET_DAY(self)); - seconds = DATE_GET_HOUR(self) * 3600 + - (DATE_GET_MINUTE(self) - offset) * 60 + - DATE_GET_SECOND(self); - temp = new_delta(days, - seconds, - DATE_GET_MICROSECOND(self), - 1); - } - if (temp != NULL) { - self->hashcode = PyObject_Hash(temp); - Py_DECREF(temp); - } - } - return self->hashcode; -} - -static PyObject * -datetime_replace(PyDateTime_DateTime *self, PyObject *args, PyObject *kw) -{ - PyObject *clone; - PyObject *tuple; - int y = GET_YEAR(self); - int m = GET_MONTH(self); - int d = GET_DAY(self); - int hh = DATE_GET_HOUR(self); - int mm = DATE_GET_MINUTE(self); - int ss = DATE_GET_SECOND(self); - int us = DATE_GET_MICROSECOND(self); - PyObject *tzinfo = HASTZINFO(self) ? self->tzinfo : Py_None; - - if (! PyArg_ParseTupleAndKeywords(args, kw, "|iiiiiiiO:replace", - datetime_kws, - &y, &m, &d, &hh, &mm, &ss, &us, - &tzinfo)) - return NULL; - tuple = Py_BuildValue("iiiiiiiO", y, m, d, hh, mm, ss, us, tzinfo); - if (tuple == NULL) - return NULL; - clone = datetime_new(self->ob_type, tuple, NULL); - Py_DECREF(tuple); - return clone; -} - -static PyObject * -datetime_astimezone(PyDateTime_DateTime *self, PyObject *args, PyObject *kw) -{ - int y, m, d, hh, mm, ss, us; - PyObject *result; - int offset, none; - - PyObject *tzinfo; - static char *keywords[] = {"tz", NULL}; - - if (! PyArg_ParseTupleAndKeywords(args, kw, "O!:astimezone", keywords, - &PyDateTime_TZInfoType, &tzinfo)) - return NULL; - - if (!HASTZINFO(self) || self->tzinfo == Py_None) - goto NeedAware; - - /* Conversion to self's own time zone is a NOP. */ - if (self->tzinfo == tzinfo) { - Py_INCREF(self); - return (PyObject *)self; - } - - /* Convert self to UTC. */ - offset = call_utcoffset(self->tzinfo, (PyObject *)self, &none); - if (offset == -1 && PyErr_Occurred()) - return NULL; - if (none) - goto NeedAware; - - y = GET_YEAR(self); - m = GET_MONTH(self); - d = GET_DAY(self); - hh = DATE_GET_HOUR(self); - mm = DATE_GET_MINUTE(self); - ss = DATE_GET_SECOND(self); - us = DATE_GET_MICROSECOND(self); - - mm -= offset; - if ((mm < 0 || mm >= 60) && - normalize_datetime(&y, &m, &d, &hh, &mm, &ss, &us) < 0) - return NULL; - - /* Attach new tzinfo and let fromutc() do the rest. */ - result = new_datetime(y, m, d, hh, mm, ss, us, tzinfo); - if (result != NULL) { - PyObject *temp = result; - - result = PyObject_CallMethod(tzinfo, "fromutc", "O", temp); - Py_DECREF(temp); - } - return result; - -NeedAware: - PyErr_SetString(PyExc_ValueError, "astimezone() cannot be applied to " - "a naive datetime"); - return NULL; -} - -static PyObject * -datetime_timetuple(PyDateTime_DateTime *self) -{ - int dstflag = -1; - - if (HASTZINFO(self) && self->tzinfo != Py_None) { - int none; - - dstflag = call_dst(self->tzinfo, (PyObject *)self, &none); - if (dstflag == -1 && PyErr_Occurred()) - return NULL; - - if (none) - dstflag = -1; - else if (dstflag != 0) - dstflag = 1; - - } - return build_struct_time(GET_YEAR(self), - GET_MONTH(self), - GET_DAY(self), - DATE_GET_HOUR(self), - DATE_GET_MINUTE(self), - DATE_GET_SECOND(self), - dstflag); -} - -static PyObject * -datetime_getdate(PyDateTime_DateTime *self) -{ - return new_date(GET_YEAR(self), - GET_MONTH(self), - GET_DAY(self)); -} - -static PyObject * -datetime_gettime(PyDateTime_DateTime *self) -{ - return new_time(DATE_GET_HOUR(self), - DATE_GET_MINUTE(self), - DATE_GET_SECOND(self), - DATE_GET_MICROSECOND(self), - Py_None); -} - -static PyObject * -datetime_gettimetz(PyDateTime_DateTime *self) -{ - return new_time(DATE_GET_HOUR(self), - DATE_GET_MINUTE(self), - DATE_GET_SECOND(self), - DATE_GET_MICROSECOND(self), - HASTZINFO(self) ? self->tzinfo : Py_None); -} - -static PyObject * -datetime_utctimetuple(PyDateTime_DateTime *self) -{ - int y = GET_YEAR(self); - int m = GET_MONTH(self); - int d = GET_DAY(self); - int hh = DATE_GET_HOUR(self); - int mm = DATE_GET_MINUTE(self); - int ss = DATE_GET_SECOND(self); - int us = 0; /* microseconds are ignored in a timetuple */ - int offset = 0; - - if (HASTZINFO(self) && self->tzinfo != Py_None) { - int none; - - offset = call_utcoffset(self->tzinfo, (PyObject *)self, &none); - if (offset == -1 && PyErr_Occurred()) - return NULL; - } - /* Even if offset is 0, don't call timetuple() -- tm_isdst should be - * 0 in a UTC timetuple regardless of what dst() says. - */ - if (offset) { - /* Subtract offset minutes & normalize. */ - int stat; - - mm -= offset; - stat = normalize_datetime(&y, &m, &d, &hh, &mm, &ss, &us); - if (stat < 0) { - /* At the edges, it's possible we overflowed - * beyond MINYEAR or MAXYEAR. - */ - if (PyErr_ExceptionMatches(PyExc_OverflowError)) - PyErr_Clear(); - else - return NULL; - } - } - return build_struct_time(y, m, d, hh, mm, ss, 0); -} - -/* Pickle support, a simple use of __reduce__. */ - -/* Let basestate be the non-tzinfo data string. - * If tzinfo is None, this returns (basestate,), else (basestate, tzinfo). - * So it's a tuple in any (non-error) case. - * __getstate__ isn't exposed. - */ -static PyObject * -datetime_getstate(PyDateTime_DateTime *self) -{ - PyObject *basestate; - PyObject *result = NULL; - - basestate = PyString_FromStringAndSize((char *)self->data, - _PyDateTime_DATETIME_DATASIZE); - if (basestate != NULL) { - if (! HASTZINFO(self) || self->tzinfo == Py_None) - result = Py_BuildValue("(O)", basestate); - else - result = Py_BuildValue("OO", basestate, self->tzinfo); - Py_DECREF(basestate); - } - return result; -} - -static PyObject * -datetime_reduce(PyDateTime_DateTime *self, PyObject *arg) -{ - return Py_BuildValue("(ON)", self->ob_type, datetime_getstate(self)); -} - -static PyMethodDef datetime_methods[] = { - - /* Class methods: */ - - {"now", (PyCFunction)datetime_now, - METH_KEYWORDS | METH_CLASS, - PyDoc_STR("[tz] -> new datetime with tz's local day and time.")}, - - {"utcnow", (PyCFunction)datetime_utcnow, - METH_NOARGS | METH_CLASS, - PyDoc_STR("Return a new datetime representing UTC day and time.")}, - - {"fromtimestamp", (PyCFunction)datetime_fromtimestamp, - METH_KEYWORDS | METH_CLASS, - PyDoc_STR("timestamp[, tz] -> tz's local time from POSIX timestamp.")}, - - {"utcfromtimestamp", (PyCFunction)datetime_utcfromtimestamp, - METH_VARARGS | METH_CLASS, - PyDoc_STR("timestamp -> UTC datetime from a POSIX timestamp " - "(like time.time()).")}, - - {"combine", (PyCFunction)datetime_combine, - METH_VARARGS | METH_KEYWORDS | METH_CLASS, - PyDoc_STR("date, time -> datetime with same date and time fields")}, - - /* Instance methods: */ - - {"date", (PyCFunction)datetime_getdate, METH_NOARGS, - PyDoc_STR("Return date object with same year, month and day.")}, - - {"time", (PyCFunction)datetime_gettime, METH_NOARGS, - PyDoc_STR("Return time object with same time but with tzinfo=None.")}, - - {"timetz", (PyCFunction)datetime_gettimetz, METH_NOARGS, - PyDoc_STR("Return time object with same time and tzinfo.")}, - - {"ctime", (PyCFunction)datetime_ctime, METH_NOARGS, - PyDoc_STR("Return ctime() style string.")}, - - {"timetuple", (PyCFunction)datetime_timetuple, METH_NOARGS, - PyDoc_STR("Return time tuple, compatible with time.localtime().")}, - - {"utctimetuple", (PyCFunction)datetime_utctimetuple, METH_NOARGS, - PyDoc_STR("Return UTC time tuple, compatible with time.localtime().")}, - - {"isoformat", (PyCFunction)datetime_isoformat, METH_KEYWORDS, - PyDoc_STR("[sep] -> string in ISO 8601 format, " - "YYYY-MM-DDTHH:MM:SS[.mmmmmm][+HH:MM].\n\n" - "sep is used to separate the year from the time, and " - "defaults to 'T'.")}, - - {"utcoffset", (PyCFunction)datetime_utcoffset, METH_NOARGS, - PyDoc_STR("Return self.tzinfo.utcoffset(self).")}, - - {"tzname", (PyCFunction)datetime_tzname, METH_NOARGS, - PyDoc_STR("Return self.tzinfo.tzname(self).")}, - - {"dst", (PyCFunction)datetime_dst, METH_NOARGS, - PyDoc_STR("Return self.tzinfo.dst(self).")}, - - {"replace", (PyCFunction)datetime_replace, METH_KEYWORDS, - PyDoc_STR("Return datetime with new specified fields.")}, - - {"astimezone", (PyCFunction)datetime_astimezone, METH_KEYWORDS, - PyDoc_STR("tz -> convert to local time in new timezone tz\n")}, - - {"__reduce__", (PyCFunction)datetime_reduce, METH_NOARGS, - PyDoc_STR("__reduce__() -> (cls, state)")}, - - {NULL, NULL} -}; - -static char datetime_doc[] = -PyDoc_STR("date/time type."); - -static PyNumberMethods datetime_as_number = { - datetime_add, /* nb_add */ - datetime_subtract, /* nb_subtract */ - 0, /* nb_multiply */ - 0, /* nb_divide */ - 0, /* nb_remainder */ - 0, /* nb_divmod */ - 0, /* nb_power */ - 0, /* nb_negative */ - 0, /* nb_positive */ - 0, /* nb_absolute */ - 0, /* nb_nonzero */ -}; - -statichere PyTypeObject PyDateTime_DateTimeType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "datetime.datetime", /* tp_name */ - sizeof(PyDateTime_DateTime), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)datetime_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)datetime_repr, /* tp_repr */ - &datetime_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)datetime_hash, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)datetime_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - datetime_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)datetime_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - datetime_methods, /* tp_methods */ - 0, /* tp_members */ - datetime_getset, /* tp_getset */ - &PyDateTime_DateType, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - datetime_alloc, /* tp_alloc */ - datetime_new, /* tp_new */ - 0, /* tp_free */ -}; - -/* --------------------------------------------------------------------------- - * Module methods and initialization. - */ - -static PyMethodDef module_methods[] = { - {NULL, NULL} -}; - -PyMODINIT_FUNC -initdatetime(void) -{ - PyObject *m; /* a module object */ - PyObject *d; /* its dict */ - PyObject *x; - - m = Py_InitModule3("datetime", module_methods, - "Fast implementation of the datetime type."); - - if (PyType_Ready(&PyDateTime_DateType) < 0) - return; - if (PyType_Ready(&PyDateTime_DateTimeType) < 0) - return; - if (PyType_Ready(&PyDateTime_DeltaType) < 0) - return; - if (PyType_Ready(&PyDateTime_TimeType) < 0) - return; - if (PyType_Ready(&PyDateTime_TZInfoType) < 0) - return; - - /* timedelta values */ - d = PyDateTime_DeltaType.tp_dict; - - x = new_delta(0, 0, 1, 0); - if (x == NULL || PyDict_SetItemString(d, "resolution", x) < 0) - return; - Py_DECREF(x); - - x = new_delta(-MAX_DELTA_DAYS, 0, 0, 0); - if (x == NULL || PyDict_SetItemString(d, "min", x) < 0) - return; - Py_DECREF(x); - - x = new_delta(MAX_DELTA_DAYS, 24*3600-1, 1000000-1, 0); - if (x == NULL || PyDict_SetItemString(d, "max", x) < 0) - return; - Py_DECREF(x); - - /* date values */ - d = PyDateTime_DateType.tp_dict; - - x = new_date(1, 1, 1); - if (x == NULL || PyDict_SetItemString(d, "min", x) < 0) - return; - Py_DECREF(x); - - x = new_date(MAXYEAR, 12, 31); - if (x == NULL || PyDict_SetItemString(d, "max", x) < 0) - return; - Py_DECREF(x); - - x = new_delta(1, 0, 0, 0); - if (x == NULL || PyDict_SetItemString(d, "resolution", x) < 0) - return; - Py_DECREF(x); - - /* time values */ - d = PyDateTime_TimeType.tp_dict; - - x = new_time(0, 0, 0, 0, Py_None); - if (x == NULL || PyDict_SetItemString(d, "min", x) < 0) - return; - Py_DECREF(x); - - x = new_time(23, 59, 59, 999999, Py_None); - if (x == NULL || PyDict_SetItemString(d, "max", x) < 0) - return; - Py_DECREF(x); - - x = new_delta(0, 0, 1, 0); - if (x == NULL || PyDict_SetItemString(d, "resolution", x) < 0) - return; - Py_DECREF(x); - - /* datetime values */ - d = PyDateTime_DateTimeType.tp_dict; - - x = new_datetime(1, 1, 1, 0, 0, 0, 0, Py_None); - if (x == NULL || PyDict_SetItemString(d, "min", x) < 0) - return; - Py_DECREF(x); - - x = new_datetime(MAXYEAR, 12, 31, 23, 59, 59, 999999, Py_None); - if (x == NULL || PyDict_SetItemString(d, "max", x) < 0) - return; - Py_DECREF(x); - - x = new_delta(0, 0, 1, 0); - if (x == NULL || PyDict_SetItemString(d, "resolution", x) < 0) - return; - Py_DECREF(x); - - /* module initialization */ - PyModule_AddIntConstant(m, "MINYEAR", MINYEAR); - PyModule_AddIntConstant(m, "MAXYEAR", MAXYEAR); - - Py_INCREF(&PyDateTime_DateType); - PyModule_AddObject(m, "date", (PyObject *) &PyDateTime_DateType); - - Py_INCREF(&PyDateTime_DateTimeType); - PyModule_AddObject(m, "datetime", - (PyObject *)&PyDateTime_DateTimeType); - - Py_INCREF(&PyDateTime_TimeType); - PyModule_AddObject(m, "time", (PyObject *) &PyDateTime_TimeType); - - Py_INCREF(&PyDateTime_DeltaType); - PyModule_AddObject(m, "timedelta", (PyObject *) &PyDateTime_DeltaType); - - Py_INCREF(&PyDateTime_TZInfoType); - PyModule_AddObject(m, "tzinfo", (PyObject *) &PyDateTime_TZInfoType); - - /* A 4-year cycle has an extra leap day over what we'd get from - * pasting together 4 single years. - */ - assert(DI4Y == 4 * 365 + 1); - assert(DI4Y == days_before_year(4+1)); - - /* Similarly, a 400-year cycle has an extra leap day over what we'd - * get from pasting together 4 100-year cycles. - */ - assert(DI400Y == 4 * DI100Y + 1); - assert(DI400Y == days_before_year(400+1)); - - /* OTOH, a 100-year cycle has one fewer leap day than we'd get from - * pasting together 25 4-year cycles. - */ - assert(DI100Y == 25 * DI4Y - 1); - assert(DI100Y == days_before_year(100+1)); - - us_per_us = PyInt_FromLong(1); - us_per_ms = PyInt_FromLong(1000); - us_per_second = PyInt_FromLong(1000000); - us_per_minute = PyInt_FromLong(60000000); - seconds_per_day = PyInt_FromLong(24 * 3600); - if (us_per_us == NULL || us_per_ms == NULL || us_per_second == NULL || - us_per_minute == NULL || seconds_per_day == NULL) - return; - - /* The rest are too big for 32-bit ints, but even - * us_per_week fits in 40 bits, so doubles should be exact. - */ - us_per_hour = PyLong_FromDouble(3600000000.0); - us_per_day = PyLong_FromDouble(86400000000.0); - us_per_week = PyLong_FromDouble(604800000000.0); - if (us_per_hour == NULL || us_per_day == NULL || us_per_week == NULL) - return; -} - -/* --------------------------------------------------------------------------- -Some time zone algebra. For a datetime x, let - x.n = x stripped of its timezone -- its naive time. - x.o = x.utcoffset(), and assuming that doesn't raise an exception or - return None - x.d = x.dst(), and assuming that doesn't raise an exception or - return None - x.s = x's standard offset, x.o - x.d - -Now some derived rules, where k is a duration (timedelta). - -1. x.o = x.s + x.d - This follows from the definition of x.s. - -2. If x and y have the same tzinfo member, x.s = y.s. - This is actually a requirement, an assumption we need to make about - sane tzinfo classes. - -3. The naive UTC time corresponding to x is x.n - x.o. - This is again a requirement for a sane tzinfo class. - -4. (x+k).s = x.s - This follows from #2, and that datimetimetz+timedelta preserves tzinfo. - -5. (x+k).n = x.n + k - Again follows from how arithmetic is defined. - -Now we can explain tz.fromutc(x). Let's assume it's an interesting case -(meaning that the various tzinfo methods exist, and don't blow up or return -None when called). - -The function wants to return a datetime y with timezone tz, equivalent to x. -x is already in UTC. - -By #3, we want - - y.n - y.o = x.n [1] - -The algorithm starts by attaching tz to x.n, and calling that y. So -x.n = y.n at the start. Then it wants to add a duration k to y, so that [1] -becomes true; in effect, we want to solve [2] for k: - - (y+k).n - (y+k).o = x.n [2] - -By #1, this is the same as - - (y+k).n - ((y+k).s + (y+k).d) = x.n [3] - -By #5, (y+k).n = y.n + k, which equals x.n + k because x.n=y.n at the start. -Substituting that into [3], - - x.n + k - (y+k).s - (y+k).d = x.n; the x.n terms cancel, leaving - k - (y+k).s - (y+k).d = 0; rearranging, - k = (y+k).s - (y+k).d; by #4, (y+k).s == y.s, so - k = y.s - (y+k).d - -On the RHS, (y+k).d can't be computed directly, but y.s can be, and we -approximate k by ignoring the (y+k).d term at first. Note that k can't be -very large, since all offset-returning methods return a duration of magnitude -less than 24 hours. For that reason, if y is firmly in std time, (y+k).d must -be 0, so ignoring it has no consequence then. - -In any case, the new value is - - z = y + y.s [4] - -It's helpful to step back at look at [4] from a higher level: it's simply -mapping from UTC to tz's standard time. - -At this point, if - - z.n - z.o = x.n [5] - -we have an equivalent time, and are almost done. The insecurity here is -at the start of daylight time. Picture US Eastern for concreteness. The wall -time jumps from 1:59 to 3:00, and wall hours of the form 2:MM don't make good -sense then. The docs ask that an Eastern tzinfo class consider such a time to -be EDT (because it's "after 2"), which is a redundant spelling of 1:MM EST -on the day DST starts. We want to return the 1:MM EST spelling because that's -the only spelling that makes sense on the local wall clock. - -In fact, if [5] holds at this point, we do have the standard-time spelling, -but that takes a bit of proof. We first prove a stronger result. What's the -difference between the LHS and RHS of [5]? Let - - diff = x.n - (z.n - z.o) [6] - -Now - z.n = by [4] - (y + y.s).n = by #5 - y.n + y.s = since y.n = x.n - x.n + y.s = since z and y are have the same tzinfo member, - y.s = z.s by #2 - x.n + z.s - -Plugging that back into [6] gives - - diff = - x.n - ((x.n + z.s) - z.o) = expanding - x.n - x.n - z.s + z.o = cancelling - - z.s + z.o = by #2 - z.d - -So diff = z.d. - -If [5] is true now, diff = 0, so z.d = 0 too, and we have the standard-time -spelling we wanted in the endcase described above. We're done. Contrarily, -if z.d = 0, then we have a UTC equivalent, and are also done. - -If [5] is not true now, diff = z.d != 0, and z.d is the offset we need to -add to z (in effect, z is in tz's standard time, and we need to shift the -local clock into tz's daylight time). - -Let - - z' = z + z.d = z + diff [7] - -and we can again ask whether - - z'.n - z'.o = x.n [8] - -If so, we're done. If not, the tzinfo class is insane, according to the -assumptions we've made. This also requires a bit of proof. As before, let's -compute the difference between the LHS and RHS of [8] (and skipping some of -the justifications for the kinds of substitutions we've done several times -already): - - diff' = x.n - (z'.n - z'.o) = replacing z'.n via [7] - x.n - (z.n + diff - z'.o) = replacing diff via [6] - x.n - (z.n + x.n - (z.n - z.o) - z'.o) = - x.n - z.n - x.n + z.n - z.o + z'.o = cancel x.n - - z.n + z.n - z.o + z'.o = cancel z.n - - z.o + z'.o = #1 twice - -z.s - z.d + z'.s + z'.d = z and z' have same tzinfo - z'.d - z.d - -So z' is UTC-equivalent to x iff z'.d = z.d at this point. If they are equal, -we've found the UTC-equivalent so are done. In fact, we stop with [7] and -return z', not bothering to compute z'.d. - -How could z.d and z'd differ? z' = z + z.d [7], so merely moving z' by -a dst() offset, and starting *from* a time already in DST (we know z.d != 0), -would have to change the result dst() returns: we start in DST, and moving -a little further into it takes us out of DST. - -There isn't a sane case where this can happen. The closest it gets is at -the end of DST, where there's an hour in UTC with no spelling in a hybrid -tzinfo class. In US Eastern, that's 5:MM UTC = 0:MM EST = 1:MM EDT. During -that hour, on an Eastern clock 1:MM is taken as being in standard time (6:MM -UTC) because the docs insist on that, but 0:MM is taken as being in daylight -time (4:MM UTC). There is no local time mapping to 5:MM UTC. The local -clock jumps from 1:59 back to 1:00 again, and repeats the 1:MM hour in -standard time. Since that's what the local clock *does*, we want to map both -UTC hours 5:MM and 6:MM to 1:MM Eastern. The result is ambiguous -in local time, but so it goes -- it's the way the local clock works. - -When x = 5:MM UTC is the input to this algorithm, x.o=0, y.o=-5 and y.d=0, -so z=0:MM. z.d=60 (minutes) then, so [5] doesn't hold and we keep going. -z' = z + z.d = 1:MM then, and z'.d=0, and z'.d - z.d = -60 != 0 so [8] -(correctly) concludes that z' is not UTC-equivalent to x. - -Because we know z.d said z was in daylight time (else [5] would have held and -we would have stopped then), and we know z.d != z'.d (else [8] would have held -and we would have stopped then), and there are only 2 possible values dst() can -return in Eastern, it follows that z'.d must be 0 (which it is in the example, -but the reasoning doesn't depend on the example -- it depends on there being -two possible dst() outcomes, one zero and the other non-zero). Therefore -z' must be in standard time, and is the spelling we want in this case. - -Note again that z' is not UTC-equivalent as far as the hybrid tzinfo class is -concerned (because it takes z' as being in standard time rather than the -daylight time we intend here), but returning it gives the real-life "local -clock repeats an hour" behavior when mapping the "unspellable" UTC hour into -tz. - -When the input is 6:MM, z=1:MM and z.d=0, and we stop at once, again with -the 1:MM standard time spelling we want. - -So how can this break? One of the assumptions must be violated. Two -possibilities: - -1) [2] effectively says that y.s is invariant across all y belong to a given - time zone. This isn't true if, for political reasons or continental drift, - a region decides to change its base offset from UTC. - -2) There may be versions of "double daylight" time where the tail end of - the analysis gives up a step too early. I haven't thought about that - enough to say. - -In any case, it's clear that the default fromutc() is strong enough to handle -"almost all" time zones: so long as the standard offset is invariant, it -doesn't matter if daylight time transition points change from year to year, or -if daylight time is skipped in some years; it doesn't matter how large or -small dst() may get within its bounds; and it doesn't even matter if some -perverse time zone returns a negative dst()). So a breaking case must be -pretty bizarre, and a tzinfo subclass can override fromutc() if it is. ---------------------------------------------------------------------------- */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/dbmmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/dbmmodule.c deleted file mode 100644 index 691a292c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/dbmmodule.c +++ /dev/null @@ -1,372 +0,0 @@ - -/* DBM module using dictionary interface */ - - -#include "Python.h" - -#include -#include -#include - -/* Some Linux systems install gdbm/ndbm.h, but not ndbm.h. This supports - * whichever configure was able to locate. - */ -#if defined(HAVE_NDBM_H) -#include -#if defined(PYOS_OS2) && !defined(PYCC_GCC) -static char *which_dbm = "ndbm"; -#else -static char *which_dbm = "GNU gdbm"; /* EMX port of GDBM */ -#endif -#elif defined(HAVE_GDBM_NDBM_H) -#include -static char *which_dbm = "GNU gdbm"; -#elif defined(HAVE_BERKDB_H) -#include -static char *which_dbm = "Berkeley DB"; -#else -#error "No ndbm.h available!" -#endif - -typedef struct { - PyObject_HEAD - int di_size; /* -1 means recompute */ - DBM *di_dbm; -} dbmobject; - -static PyTypeObject Dbmtype; - -#define is_dbmobject(v) ((v)->ob_type == &Dbmtype) -#define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \ - { PyErr_SetString(DbmError, "DBM object has already been closed"); \ - return NULL; } - -static PyObject *DbmError; - -static PyObject * -newdbmobject(char *file, int flags, int mode) -{ - dbmobject *dp; - - dp = PyObject_New(dbmobject, &Dbmtype); - if (dp == NULL) - return NULL; - dp->di_size = -1; - if ( (dp->di_dbm = dbm_open(file, flags, mode)) == 0 ) { - PyErr_SetFromErrno(DbmError); - Py_DECREF(dp); - return NULL; - } - return (PyObject *)dp; -} - -/* Methods */ - -static void -dbm_dealloc(register dbmobject *dp) -{ - if ( dp->di_dbm ) - dbm_close(dp->di_dbm); - PyObject_Del(dp); -} - -static int -dbm_length(dbmobject *dp) -{ - if (dp->di_dbm == NULL) { - PyErr_SetString(DbmError, "DBM object has already been closed"); - return -1; - } - if ( dp->di_size < 0 ) { - datum key; - int size; - - size = 0; - for ( key=dbm_firstkey(dp->di_dbm); key.dptr; - key = dbm_nextkey(dp->di_dbm)) - size++; - dp->di_size = size; - } - return dp->di_size; -} - -static PyObject * -dbm_subscript(dbmobject *dp, register PyObject *key) -{ - datum drec, krec; - int tmp_size; - - if (!PyArg_Parse(key, "s#", &krec.dptr, &tmp_size) ) - return NULL; - - krec.dsize = tmp_size; - check_dbmobject_open(dp); - drec = dbm_fetch(dp->di_dbm, krec); - if ( drec.dptr == 0 ) { - PyErr_SetString(PyExc_KeyError, - PyString_AS_STRING((PyStringObject *)key)); - return NULL; - } - if ( dbm_error(dp->di_dbm) ) { - dbm_clearerr(dp->di_dbm); - PyErr_SetString(DbmError, ""); - return NULL; - } - return PyString_FromStringAndSize(drec.dptr, drec.dsize); -} - -static int -dbm_ass_sub(dbmobject *dp, PyObject *v, PyObject *w) -{ - datum krec, drec; - int tmp_size; - - if ( !PyArg_Parse(v, "s#", &krec.dptr, &tmp_size) ) { - PyErr_SetString(PyExc_TypeError, - "dbm mappings have string indices only"); - return -1; - } - krec.dsize = tmp_size; - if (dp->di_dbm == NULL) { - PyErr_SetString(DbmError, "DBM object has already been closed"); - return -1; - } - dp->di_size = -1; - if (w == NULL) { - if ( dbm_delete(dp->di_dbm, krec) < 0 ) { - dbm_clearerr(dp->di_dbm); - PyErr_SetString(PyExc_KeyError, - PyString_AS_STRING((PyStringObject *)v)); - return -1; - } - } else { - if ( !PyArg_Parse(w, "s#", &drec.dptr, &tmp_size) ) { - PyErr_SetString(PyExc_TypeError, - "dbm mappings have string elements only"); - return -1; - } - drec.dsize = tmp_size; - if ( dbm_store(dp->di_dbm, krec, drec, DBM_REPLACE) < 0 ) { - dbm_clearerr(dp->di_dbm); - PyErr_SetString(DbmError, - "cannot add item to database"); - return -1; - } - } - if ( dbm_error(dp->di_dbm) ) { - dbm_clearerr(dp->di_dbm); - PyErr_SetString(DbmError, ""); - return -1; - } - return 0; -} - -static PyMappingMethods dbm_as_mapping = { - (inquiry)dbm_length, /*mp_length*/ - (binaryfunc)dbm_subscript, /*mp_subscript*/ - (objobjargproc)dbm_ass_sub, /*mp_ass_subscript*/ -}; - -static PyObject * -dbm__close(register dbmobject *dp, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":close")) - return NULL; - if (dp->di_dbm) - dbm_close(dp->di_dbm); - dp->di_dbm = NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -dbm_keys(register dbmobject *dp, PyObject *args) -{ - register PyObject *v, *item; - datum key; - int err; - - if (!PyArg_ParseTuple(args, ":keys")) - return NULL; - check_dbmobject_open(dp); - v = PyList_New(0); - if (v == NULL) - return NULL; - for (key = dbm_firstkey(dp->di_dbm); key.dptr; - key = dbm_nextkey(dp->di_dbm)) { - item = PyString_FromStringAndSize(key.dptr, key.dsize); - if (item == NULL) { - Py_DECREF(v); - return NULL; - } - err = PyList_Append(v, item); - Py_DECREF(item); - if (err != 0) { - Py_DECREF(v); - return NULL; - } - } - return v; -} - -static PyObject * -dbm_has_key(register dbmobject *dp, PyObject *args) -{ - datum key, val; - int tmp_size; - - if (!PyArg_ParseTuple(args, "s#:has_key", &key.dptr, &tmp_size)) - return NULL; - key.dsize = tmp_size; - check_dbmobject_open(dp); - val = dbm_fetch(dp->di_dbm, key); - return PyInt_FromLong(val.dptr != NULL); -} - -static PyObject * -dbm_get(register dbmobject *dp, PyObject *args) -{ - datum key, val; - PyObject *defvalue = Py_None; - int tmp_size; - - if (!PyArg_ParseTuple(args, "s#|O:get", - &key.dptr, &tmp_size, &defvalue)) - return NULL; - key.dsize = tmp_size; - check_dbmobject_open(dp); - val = dbm_fetch(dp->di_dbm, key); - if (val.dptr != NULL) - return PyString_FromStringAndSize(val.dptr, val.dsize); - else { - Py_INCREF(defvalue); - return defvalue; - } -} - -static PyObject * -dbm_setdefault(register dbmobject *dp, PyObject *args) -{ - datum key, val; - PyObject *defvalue = NULL; - int tmp_size; - - if (!PyArg_ParseTuple(args, "s#|S:setdefault", - &key.dptr, &tmp_size, &defvalue)) - return NULL; - key.dsize = tmp_size; - check_dbmobject_open(dp); - val = dbm_fetch(dp->di_dbm, key); - if (val.dptr != NULL) - return PyString_FromStringAndSize(val.dptr, val.dsize); - if (defvalue == NULL) { - defvalue = PyString_FromStringAndSize(NULL, 0); - if (defvalue == NULL) - return NULL; - } - else - Py_INCREF(defvalue); - val.dptr = PyString_AS_STRING(defvalue); - val.dsize = PyString_GET_SIZE(defvalue); - if (dbm_store(dp->di_dbm, key, val, DBM_INSERT) < 0) { - dbm_clearerr(dp->di_dbm); - PyErr_SetString(DbmError, "cannot add item to database"); - return NULL; - } - return defvalue; -} - -static PyMethodDef dbm_methods[] = { - {"close", (PyCFunction)dbm__close, METH_VARARGS, - "close()\nClose the database."}, - {"keys", (PyCFunction)dbm_keys, METH_VARARGS, - "keys() -> list\nReturn a list of all keys in the database."}, - {"has_key", (PyCFunction)dbm_has_key, METH_VARARGS, - "has_key(key} -> boolean\nReturn true iff key is in the database."}, - {"get", (PyCFunction)dbm_get, METH_VARARGS, - "get(key[, default]) -> value\n" - "Return the value for key if present, otherwise default."}, - {"setdefault", (PyCFunction)dbm_setdefault, METH_VARARGS, - "setdefault(key[, default]) -> value\n" - "Return the value for key if present, otherwise default. If key\n" - "is not in the database, it is inserted with default as the value."}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -dbm_getattr(dbmobject *dp, char *name) -{ - return Py_FindMethod(dbm_methods, (PyObject *)dp, name); -} - -static PyTypeObject Dbmtype = { - PyObject_HEAD_INIT(NULL) - 0, - "dbm.dbm", - sizeof(dbmobject), - 0, - (destructor)dbm_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)dbm_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - &dbm_as_mapping, /*tp_as_mapping*/ -}; - -/* ----------------------------------------------------------------- */ - -static PyObject * -dbmopen(PyObject *self, PyObject *args) -{ - char *name; - char *flags = "r"; - int iflags; - int mode = 0666; - - if ( !PyArg_ParseTuple(args, "s|si:open", &name, &flags, &mode) ) - return NULL; - if ( strcmp(flags, "r") == 0 ) - iflags = O_RDONLY; - else if ( strcmp(flags, "w") == 0 ) - iflags = O_RDWR; - else if ( strcmp(flags, "rw") == 0 ) /* B/W compat */ - iflags = O_RDWR|O_CREAT; - else if ( strcmp(flags, "c") == 0 ) - iflags = O_RDWR|O_CREAT; - else if ( strcmp(flags, "n") == 0 ) - iflags = O_RDWR|O_CREAT|O_TRUNC; - else { - PyErr_SetString(DbmError, - "arg 2 to open should be 'r', 'w', 'c', or 'n'"); - return NULL; - } - return newdbmobject(name, iflags, mode); -} - -static PyMethodDef dbmmodule_methods[] = { - { "open", (PyCFunction)dbmopen, METH_VARARGS, - "open(path[, flag[, mode]]) -> mapping\n" - "Return a database object."}, - { 0, 0 }, -}; - -PyMODINIT_FUNC -initdbm(void) { - PyObject *m, *d, *s; - - Dbmtype.ob_type = &PyType_Type; - m = Py_InitModule("dbm", dbmmodule_methods); - d = PyModule_GetDict(m); - if (DbmError == NULL) - DbmError = PyErr_NewException("dbm.error", NULL, NULL); - s = PyString_FromString(which_dbm); - if (s != NULL) { - PyDict_SetItemString(d, "library", s); - Py_DECREF(s); - } - if (DbmError != NULL) - PyDict_SetItemString(d, "error", DbmError); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/dlmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/dlmodule.c deleted file mode 100644 index bf66eb52..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/dlmodule.c +++ /dev/null @@ -1,254 +0,0 @@ - -/* dl module */ - -#include "Python.h" - -#include - -#ifndef RTLD_LAZY -#define RTLD_LAZY 1 -#endif - -typedef void *PyUnivPtr; -typedef struct { - PyObject_HEAD - PyUnivPtr *dl_handle; -} dlobject; - -static PyTypeObject Dltype; - -static PyObject *Dlerror; - -static PyObject * -newdlobject(PyUnivPtr *handle) -{ - dlobject *xp; - xp = PyObject_New(dlobject, &Dltype); - if (xp == NULL) - return NULL; - xp->dl_handle = handle; - return (PyObject *)xp; -} - -static void -dl_dealloc(dlobject *xp) -{ - if (xp->dl_handle != NULL) - dlclose(xp->dl_handle); - PyObject_Del(xp); -} - -static PyObject * -dl_close(dlobject *xp) -{ - if (xp->dl_handle != NULL) { - dlclose(xp->dl_handle); - xp->dl_handle = NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -dl_sym(dlobject *xp, PyObject *args) -{ - char *name; - PyUnivPtr *func; - if (PyString_Check(args)) { - name = PyString_AS_STRING(args); - } else { - PyErr_Format(PyExc_TypeError, "expected string, found %.200s", - args->ob_type->tp_name); - return NULL; - } - func = dlsym(xp->dl_handle, name); - if (func == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyInt_FromLong((long)func); -} - -static PyObject * -dl_call(dlobject *xp, PyObject *args) -{ - PyObject *name; - long (*func)(long, long, long, long, long, - long, long, long, long, long); - long alist[10]; - long res; - int i; - int n = PyTuple_Size(args); - if (n < 1) { - PyErr_SetString(PyExc_TypeError, "at least a name is needed"); - return NULL; - } - name = PyTuple_GetItem(args, 0); - if (!PyString_Check(name)) { - PyErr_SetString(PyExc_TypeError, - "function name must be a string"); - return NULL; - } - func = (long (*)(long, long, long, long, long, - long, long, long, long, long)) - dlsym(xp->dl_handle, PyString_AsString(name)); - if (func == NULL) { - PyErr_SetString(PyExc_ValueError, dlerror()); - return NULL; - } - if (n-1 > 10) { - PyErr_SetString(PyExc_TypeError, - "too many arguments (max 10)"); - return NULL; - } - for (i = 1; i < n; i++) { - PyObject *v = PyTuple_GetItem(args, i); - if (PyInt_Check(v)) - alist[i-1] = PyInt_AsLong(v); - else if (PyString_Check(v)) - alist[i-1] = (long)PyString_AsString(v); - else if (v == Py_None) - alist[i-1] = (long) ((char *)NULL); - else { - PyErr_SetString(PyExc_TypeError, - "arguments must be int, string or None"); - return NULL; - } - } - for (; i <= 10; i++) - alist[i-1] = 0; - res = (*func)(alist[0], alist[1], alist[2], alist[3], alist[4], - alist[5], alist[6], alist[7], alist[8], alist[9]); - return PyInt_FromLong(res); -} - -static PyMethodDef dlobject_methods[] = { - {"call", (PyCFunction)dl_call, METH_VARARGS}, - {"sym", (PyCFunction)dl_sym, METH_O}, - {"close", (PyCFunction)dl_close, METH_NOARGS}, - {NULL, NULL} /* Sentinel */ -}; - -static PyObject * -dl_getattr(dlobject *xp, char *name) -{ - return Py_FindMethod(dlobject_methods, (PyObject *)xp, name); -} - - -static PyTypeObject Dltype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "dl.dl", /*tp_name*/ - sizeof(dlobject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)dl_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)dl_getattr,/*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ -}; - -static PyObject * -dl_open(PyObject *self, PyObject *args) -{ - char *name; - int mode; - PyUnivPtr *handle; - if (sizeof(int) != sizeof(long) || - sizeof(long) != sizeof(char *)) { - PyErr_SetString(PyExc_SystemError, - "module dl requires sizeof(int) == sizeof(long) == sizeof(char*)"); - return NULL; - } - - if (PyArg_ParseTuple(args, "z:open", &name)) - mode = RTLD_LAZY; - else { - PyErr_Clear(); - if (!PyArg_ParseTuple(args, "zi:open", &name, &mode)) - return NULL; -#ifndef RTLD_NOW - if (mode != RTLD_LAZY) { - PyErr_SetString(PyExc_ValueError, "mode must be 1"); - return NULL; - } -#endif - } - handle = dlopen(name, mode); - if (handle == NULL) { - PyErr_SetString(Dlerror, dlerror()); - return NULL; - } - return newdlobject(handle); -} - -static PyMethodDef dl_methods[] = { - {"open", dl_open, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - -/* From socketmodule.c - * Convenience routine to export an integer value. - * - * Errors are silently ignored, for better or for worse... - */ -static void -insint(PyObject *d, char *name, int value) -{ - PyObject *v = PyInt_FromLong((long) value); - if (!v || PyDict_SetItemString(d, name, v)) - PyErr_Clear(); - - Py_XDECREF(v); -} - -PyMODINIT_FUNC -initdl(void) -{ - PyObject *m, *d, *x; - - /* Initialize object type */ - Dltype.ob_type = &PyType_Type; - - /* Create the module and add the functions */ - m = Py_InitModule("dl", dl_methods); - - /* Add some symbolic constants to the module */ - d = PyModule_GetDict(m); - Dlerror = x = PyErr_NewException("dl.error", NULL, NULL); - PyDict_SetItemString(d, "error", x); - x = PyInt_FromLong((long)RTLD_LAZY); - PyDict_SetItemString(d, "RTLD_LAZY", x); -#define INSINT(X) insint(d,#X,X) -#ifdef RTLD_NOW - INSINT(RTLD_NOW); -#endif -#ifdef RTLD_NOLOAD - INSINT(RTLD_NOLOAD); -#endif -#ifdef RTLD_GLOBAL - INSINT(RTLD_GLOBAL); -#endif -#ifdef RTLD_LOCAL - INSINT(RTLD_LOCAL); -#endif -#ifdef RTLD_PARENT - INSINT(RTLD_PARENT); -#endif -#ifdef RTLD_GROUP - INSINT(RTLD_GROUP); -#endif -#ifdef RTLD_WORLD - INSINT(RTLD_WORLD); -#endif -#ifdef RTLD_NODELETE - INSINT(RTLD_NODELETE); -#endif -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/errnomodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/errnomodule.c deleted file mode 100644 index 67379124..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/errnomodule.c +++ /dev/null @@ -1,795 +0,0 @@ - -/* Errno module */ - -#include "Python.h" - -/* Mac with GUSI has more errors than those in errno.h */ -#ifdef USE_GUSI -#include -#endif - -/* Windows socket errors (WSA*) */ -#ifdef MS_WINDOWS -#ifdef MS_XBOX -#include -#else -#include -#endif -#endif - -/* - * Pull in the system error definitions - */ - -static PyMethodDef errno_methods[] = { - {NULL, NULL} -}; - -/* Helper function doing the dictionary inserting */ - -static void -_inscode(PyObject *d, PyObject *de, char *name, int code) -{ - PyObject *u = PyString_FromString(name); - PyObject *v = PyInt_FromLong((long) code); - - /* Don't bother checking for errors; they'll be caught at the end - * of the module initialization function by the caller of - * initerrno(). - */ - if (u && v) { - /* insert in modules dict */ - PyDict_SetItem(d, u, v); - /* insert in errorcode dict */ - PyDict_SetItem(de, v, u); - } - Py_XDECREF(u); - Py_XDECREF(v); -} - -PyDoc_STRVAR(errno__doc__, -"This module makes available standard errno system symbols.\n\ -\n\ -The value of each symbol is the corresponding integer value,\n\ -e.g., on most systems, errno.ENOENT equals the integer 2.\n\ -\n\ -The dictionary errno.errorcode maps numeric codes to symbol names,\n\ -e.g., errno.errorcode[2] could be the string 'ENOENT'.\n\ -\n\ -Symbols that are not relevant to the underlying system are not defined.\n\ -\n\ -To map error codes to error messages, use the function os.strerror(),\n\ -e.g. os.strerror(2) could return 'No such file or directory'."); - -PyMODINIT_FUNC -initerrno(void) -{ - PyObject *m, *d, *de; - m = Py_InitModule3("errno", errno_methods, errno__doc__); - d = PyModule_GetDict(m); - de = PyDict_New(); - if (!d || !de || PyDict_SetItemString(d, "errorcode", de) < 0) - return; - -/* Macro so I don't have to edit each and every line below... */ -#define inscode(d, ds, de, name, code, comment) _inscode(d, de, name, code) - - /* - * The names and comments are borrowed from linux/include/errno.h, - * which should be pretty all-inclusive - */ - -#ifdef ENODEV - inscode(d, ds, de, "ENODEV", ENODEV, "No such device"); -#endif -#ifdef ENOCSI - inscode(d, ds, de, "ENOCSI", ENOCSI, "No CSI structure available"); -#endif -#ifdef EHOSTUNREACH - inscode(d, ds, de, "EHOSTUNREACH", EHOSTUNREACH, "No route to host"); -#else -#ifdef WSAEHOSTUNREACH - inscode(d, ds, de, "EHOSTUNREACH", WSAEHOSTUNREACH, "No route to host"); -#endif -#endif -#ifdef ENOMSG - inscode(d, ds, de, "ENOMSG", ENOMSG, "No message of desired type"); -#endif -#ifdef EUCLEAN - inscode(d, ds, de, "EUCLEAN", EUCLEAN, "Structure needs cleaning"); -#endif -#ifdef EL2NSYNC - inscode(d, ds, de, "EL2NSYNC", EL2NSYNC, "Level 2 not synchronized"); -#endif -#ifdef EL2HLT - inscode(d, ds, de, "EL2HLT", EL2HLT, "Level 2 halted"); -#endif -#ifdef ENODATA - inscode(d, ds, de, "ENODATA", ENODATA, "No data available"); -#endif -#ifdef ENOTBLK - inscode(d, ds, de, "ENOTBLK", ENOTBLK, "Block device required"); -#endif -#ifdef ENOSYS - inscode(d, ds, de, "ENOSYS", ENOSYS, "Function not implemented"); -#endif -#ifdef EPIPE - inscode(d, ds, de, "EPIPE", EPIPE, "Broken pipe"); -#endif -#ifdef EINVAL - inscode(d, ds, de, "EINVAL", EINVAL, "Invalid argument"); -#else -#ifdef WSAEINVAL - inscode(d, ds, de, "EINVAL", WSAEINVAL, "Invalid argument"); -#endif -#endif -#ifdef EOVERFLOW - inscode(d, ds, de, "EOVERFLOW", EOVERFLOW, "Value too large for defined data type"); -#endif -#ifdef EADV - inscode(d, ds, de, "EADV", EADV, "Advertise error"); -#endif -#ifdef EINTR - inscode(d, ds, de, "EINTR", EINTR, "Interrupted system call"); -#else -#ifdef WSAEINTR - inscode(d, ds, de, "EINTR", WSAEINTR, "Interrupted system call"); -#endif -#endif -#ifdef EUSERS - inscode(d, ds, de, "EUSERS", EUSERS, "Too many users"); -#else -#ifdef WSAEUSERS - inscode(d, ds, de, "EUSERS", WSAEUSERS, "Too many users"); -#endif -#endif -#ifdef ENOTEMPTY - inscode(d, ds, de, "ENOTEMPTY", ENOTEMPTY, "Directory not empty"); -#else -#ifdef WSAENOTEMPTY - inscode(d, ds, de, "ENOTEMPTY", WSAENOTEMPTY, "Directory not empty"); -#endif -#endif -#ifdef ENOBUFS - inscode(d, ds, de, "ENOBUFS", ENOBUFS, "No buffer space available"); -#else -#ifdef WSAENOBUFS - inscode(d, ds, de, "ENOBUFS", WSAENOBUFS, "No buffer space available"); -#endif -#endif -#ifdef EPROTO - inscode(d, ds, de, "EPROTO", EPROTO, "Protocol error"); -#endif -#ifdef EREMOTE - inscode(d, ds, de, "EREMOTE", EREMOTE, "Object is remote"); -#else -#ifdef WSAEREMOTE - inscode(d, ds, de, "EREMOTE", WSAEREMOTE, "Object is remote"); -#endif -#endif -#ifdef ENAVAIL - inscode(d, ds, de, "ENAVAIL", ENAVAIL, "No XENIX semaphores available"); -#endif -#ifdef ECHILD - inscode(d, ds, de, "ECHILD", ECHILD, "No child processes"); -#endif -#ifdef ELOOP - inscode(d, ds, de, "ELOOP", ELOOP, "Too many symbolic links encountered"); -#else -#ifdef WSAELOOP - inscode(d, ds, de, "ELOOP", WSAELOOP, "Too many symbolic links encountered"); -#endif -#endif -#ifdef EXDEV - inscode(d, ds, de, "EXDEV", EXDEV, "Cross-device link"); -#endif -#ifdef E2BIG - inscode(d, ds, de, "E2BIG", E2BIG, "Arg list too long"); -#endif -#ifdef ESRCH - inscode(d, ds, de, "ESRCH", ESRCH, "No such process"); -#endif -#ifdef EMSGSIZE - inscode(d, ds, de, "EMSGSIZE", EMSGSIZE, "Message too long"); -#else -#ifdef WSAEMSGSIZE - inscode(d, ds, de, "EMSGSIZE", WSAEMSGSIZE, "Message too long"); -#endif -#endif -#ifdef EAFNOSUPPORT - inscode(d, ds, de, "EAFNOSUPPORT", EAFNOSUPPORT, "Address family not supported by protocol"); -#else -#ifdef WSAEAFNOSUPPORT - inscode(d, ds, de, "EAFNOSUPPORT", WSAEAFNOSUPPORT, "Address family not supported by protocol"); -#endif -#endif -#ifdef EBADR - inscode(d, ds, de, "EBADR", EBADR, "Invalid request descriptor"); -#endif -#ifdef EHOSTDOWN - inscode(d, ds, de, "EHOSTDOWN", EHOSTDOWN, "Host is down"); -#else -#ifdef WSAEHOSTDOWN - inscode(d, ds, de, "EHOSTDOWN", WSAEHOSTDOWN, "Host is down"); -#endif -#endif -#ifdef EPFNOSUPPORT - inscode(d, ds, de, "EPFNOSUPPORT", EPFNOSUPPORT, "Protocol family not supported"); -#else -#ifdef WSAEPFNOSUPPORT - inscode(d, ds, de, "EPFNOSUPPORT", WSAEPFNOSUPPORT, "Protocol family not supported"); -#endif -#endif -#ifdef ENOPROTOOPT - inscode(d, ds, de, "ENOPROTOOPT", ENOPROTOOPT, "Protocol not available"); -#else -#ifdef WSAENOPROTOOPT - inscode(d, ds, de, "ENOPROTOOPT", WSAENOPROTOOPT, "Protocol not available"); -#endif -#endif -#ifdef EBUSY - inscode(d, ds, de, "EBUSY", EBUSY, "Device or resource busy"); -#endif -#ifdef EWOULDBLOCK - inscode(d, ds, de, "EWOULDBLOCK", EWOULDBLOCK, "Operation would block"); -#else -#ifdef WSAEWOULDBLOCK - inscode(d, ds, de, "EWOULDBLOCK", WSAEWOULDBLOCK, "Operation would block"); -#endif -#endif -#ifdef EBADFD - inscode(d, ds, de, "EBADFD", EBADFD, "File descriptor in bad state"); -#endif -#ifdef EDOTDOT - inscode(d, ds, de, "EDOTDOT", EDOTDOT, "RFS specific error"); -#endif -#ifdef EISCONN - inscode(d, ds, de, "EISCONN", EISCONN, "Transport endpoint is already connected"); -#else -#ifdef WSAEISCONN - inscode(d, ds, de, "EISCONN", WSAEISCONN, "Transport endpoint is already connected"); -#endif -#endif -#ifdef ENOANO - inscode(d, ds, de, "ENOANO", ENOANO, "No anode"); -#endif -#ifdef ESHUTDOWN - inscode(d, ds, de, "ESHUTDOWN", ESHUTDOWN, "Cannot send after transport endpoint shutdown"); -#else -#ifdef WSAESHUTDOWN - inscode(d, ds, de, "ESHUTDOWN", WSAESHUTDOWN, "Cannot send after transport endpoint shutdown"); -#endif -#endif -#ifdef ECHRNG - inscode(d, ds, de, "ECHRNG", ECHRNG, "Channel number out of range"); -#endif -#ifdef ELIBBAD - inscode(d, ds, de, "ELIBBAD", ELIBBAD, "Accessing a corrupted shared library"); -#endif -#ifdef ENONET - inscode(d, ds, de, "ENONET", ENONET, "Machine is not on the network"); -#endif -#ifdef EBADE - inscode(d, ds, de, "EBADE", EBADE, "Invalid exchange"); -#endif -#ifdef EBADF - inscode(d, ds, de, "EBADF", EBADF, "Bad file number"); -#else -#ifdef WSAEBADF - inscode(d, ds, de, "EBADF", WSAEBADF, "Bad file number"); -#endif -#endif -#ifdef EMULTIHOP - inscode(d, ds, de, "EMULTIHOP", EMULTIHOP, "Multihop attempted"); -#endif -#ifdef EIO - inscode(d, ds, de, "EIO", EIO, "I/O error"); -#endif -#ifdef EUNATCH - inscode(d, ds, de, "EUNATCH", EUNATCH, "Protocol driver not attached"); -#endif -#ifdef EPROTOTYPE - inscode(d, ds, de, "EPROTOTYPE", EPROTOTYPE, "Protocol wrong type for socket"); -#else -#ifdef WSAEPROTOTYPE - inscode(d, ds, de, "EPROTOTYPE", WSAEPROTOTYPE, "Protocol wrong type for socket"); -#endif -#endif -#ifdef ENOSPC - inscode(d, ds, de, "ENOSPC", ENOSPC, "No space left on device"); -#endif -#ifdef ENOEXEC - inscode(d, ds, de, "ENOEXEC", ENOEXEC, "Exec format error"); -#endif -#ifdef EALREADY - inscode(d, ds, de, "EALREADY", EALREADY, "Operation already in progress"); -#else -#ifdef WSAEALREADY - inscode(d, ds, de, "EALREADY", WSAEALREADY, "Operation already in progress"); -#endif -#endif -#ifdef ENETDOWN - inscode(d, ds, de, "ENETDOWN", ENETDOWN, "Network is down"); -#else -#ifdef WSAENETDOWN - inscode(d, ds, de, "ENETDOWN", WSAENETDOWN, "Network is down"); -#endif -#endif -#ifdef ENOTNAM - inscode(d, ds, de, "ENOTNAM", ENOTNAM, "Not a XENIX named type file"); -#endif -#ifdef EACCES - inscode(d, ds, de, "EACCES", EACCES, "Permission denied"); -#else -#ifdef WSAEACCES - inscode(d, ds, de, "EACCES", WSAEACCES, "Permission denied"); -#endif -#endif -#ifdef ELNRNG - inscode(d, ds, de, "ELNRNG", ELNRNG, "Link number out of range"); -#endif -#ifdef EILSEQ - inscode(d, ds, de, "EILSEQ", EILSEQ, "Illegal byte sequence"); -#endif -#ifdef ENOTDIR - inscode(d, ds, de, "ENOTDIR", ENOTDIR, "Not a directory"); -#endif -#ifdef ENOTUNIQ - inscode(d, ds, de, "ENOTUNIQ", ENOTUNIQ, "Name not unique on network"); -#endif -#ifdef EPERM - inscode(d, ds, de, "EPERM", EPERM, "Operation not permitted"); -#endif -#ifdef EDOM - inscode(d, ds, de, "EDOM", EDOM, "Math argument out of domain of func"); -#endif -#ifdef EXFULL - inscode(d, ds, de, "EXFULL", EXFULL, "Exchange full"); -#endif -#ifdef ECONNREFUSED - inscode(d, ds, de, "ECONNREFUSED", ECONNREFUSED, "Connection refused"); -#else -#ifdef WSAECONNREFUSED - inscode(d, ds, de, "ECONNREFUSED", WSAECONNREFUSED, "Connection refused"); -#endif -#endif -#ifdef EISDIR - inscode(d, ds, de, "EISDIR", EISDIR, "Is a directory"); -#endif -#ifdef EPROTONOSUPPORT - inscode(d, ds, de, "EPROTONOSUPPORT", EPROTONOSUPPORT, "Protocol not supported"); -#else -#ifdef WSAEPROTONOSUPPORT - inscode(d, ds, de, "EPROTONOSUPPORT", WSAEPROTONOSUPPORT, "Protocol not supported"); -#endif -#endif -#ifdef EROFS - inscode(d, ds, de, "EROFS", EROFS, "Read-only file system"); -#endif -#ifdef EADDRNOTAVAIL - inscode(d, ds, de, "EADDRNOTAVAIL", EADDRNOTAVAIL, "Cannot assign requested address"); -#else -#ifdef WSAEADDRNOTAVAIL - inscode(d, ds, de, "EADDRNOTAVAIL", WSAEADDRNOTAVAIL, "Cannot assign requested address"); -#endif -#endif -#ifdef EIDRM - inscode(d, ds, de, "EIDRM", EIDRM, "Identifier removed"); -#endif -#ifdef ECOMM - inscode(d, ds, de, "ECOMM", ECOMM, "Communication error on send"); -#endif -#ifdef ESRMNT - inscode(d, ds, de, "ESRMNT", ESRMNT, "Srmount error"); -#endif -#ifdef EREMOTEIO - inscode(d, ds, de, "EREMOTEIO", EREMOTEIO, "Remote I/O error"); -#endif -#ifdef EL3RST - inscode(d, ds, de, "EL3RST", EL3RST, "Level 3 reset"); -#endif -#ifdef EBADMSG - inscode(d, ds, de, "EBADMSG", EBADMSG, "Not a data message"); -#endif -#ifdef ENFILE - inscode(d, ds, de, "ENFILE", ENFILE, "File table overflow"); -#endif -#ifdef ELIBMAX - inscode(d, ds, de, "ELIBMAX", ELIBMAX, "Attempting to link in too many shared libraries"); -#endif -#ifdef ESPIPE - inscode(d, ds, de, "ESPIPE", ESPIPE, "Illegal seek"); -#endif -#ifdef ENOLINK - inscode(d, ds, de, "ENOLINK", ENOLINK, "Link has been severed"); -#endif -#ifdef ENETRESET - inscode(d, ds, de, "ENETRESET", ENETRESET, "Network dropped connection because of reset"); -#else -#ifdef WSAENETRESET - inscode(d, ds, de, "ENETRESET", WSAENETRESET, "Network dropped connection because of reset"); -#endif -#endif -#ifdef ETIMEDOUT - inscode(d, ds, de, "ETIMEDOUT", ETIMEDOUT, "Connection timed out"); -#else -#ifdef WSAETIMEDOUT - inscode(d, ds, de, "ETIMEDOUT", WSAETIMEDOUT, "Connection timed out"); -#endif -#endif -#ifdef ENOENT - inscode(d, ds, de, "ENOENT", ENOENT, "No such file or directory"); -#endif -#ifdef EEXIST - inscode(d, ds, de, "EEXIST", EEXIST, "File exists"); -#endif -#ifdef EDQUOT - inscode(d, ds, de, "EDQUOT", EDQUOT, "Quota exceeded"); -#else -#ifdef WSAEDQUOT - inscode(d, ds, de, "EDQUOT", WSAEDQUOT, "Quota exceeded"); -#endif -#endif -#ifdef ENOSTR - inscode(d, ds, de, "ENOSTR", ENOSTR, "Device not a stream"); -#endif -#ifdef EBADSLT - inscode(d, ds, de, "EBADSLT", EBADSLT, "Invalid slot"); -#endif -#ifdef EBADRQC - inscode(d, ds, de, "EBADRQC", EBADRQC, "Invalid request code"); -#endif -#ifdef ELIBACC - inscode(d, ds, de, "ELIBACC", ELIBACC, "Can not access a needed shared library"); -#endif -#ifdef EFAULT - inscode(d, ds, de, "EFAULT", EFAULT, "Bad address"); -#else -#ifdef WSAEFAULT - inscode(d, ds, de, "EFAULT", WSAEFAULT, "Bad address"); -#endif -#endif -#ifdef EFBIG - inscode(d, ds, de, "EFBIG", EFBIG, "File too large"); -#endif -#ifdef EDEADLK - inscode(d, ds, de, "EDEADLK", EDEADLK, "Resource deadlock would occur"); -#endif -#ifdef ENOTCONN - inscode(d, ds, de, "ENOTCONN", ENOTCONN, "Transport endpoint is not connected"); -#else -#ifdef WSAENOTCONN - inscode(d, ds, de, "ENOTCONN", WSAENOTCONN, "Transport endpoint is not connected"); -#endif -#endif -#ifdef EDESTADDRREQ - inscode(d, ds, de, "EDESTADDRREQ", EDESTADDRREQ, "Destination address required"); -#else -#ifdef WSAEDESTADDRREQ - inscode(d, ds, de, "EDESTADDRREQ", WSAEDESTADDRREQ, "Destination address required"); -#endif -#endif -#ifdef ELIBSCN - inscode(d, ds, de, "ELIBSCN", ELIBSCN, ".lib section in a.out corrupted"); -#endif -#ifdef ENOLCK - inscode(d, ds, de, "ENOLCK", ENOLCK, "No record locks available"); -#endif -#ifdef EISNAM - inscode(d, ds, de, "EISNAM", EISNAM, "Is a named type file"); -#endif -#ifdef ECONNABORTED - inscode(d, ds, de, "ECONNABORTED", ECONNABORTED, "Software caused connection abort"); -#else -#ifdef WSAECONNABORTED - inscode(d, ds, de, "ECONNABORTED", WSAECONNABORTED, "Software caused connection abort"); -#endif -#endif -#ifdef ENETUNREACH - inscode(d, ds, de, "ENETUNREACH", ENETUNREACH, "Network is unreachable"); -#else -#ifdef WSAENETUNREACH - inscode(d, ds, de, "ENETUNREACH", WSAENETUNREACH, "Network is unreachable"); -#endif -#endif -#ifdef ESTALE - inscode(d, ds, de, "ESTALE", ESTALE, "Stale NFS file handle"); -#else -#ifdef WSAESTALE - inscode(d, ds, de, "ESTALE", WSAESTALE, "Stale NFS file handle"); -#endif -#endif -#ifdef ENOSR - inscode(d, ds, de, "ENOSR", ENOSR, "Out of streams resources"); -#endif -#ifdef ENOMEM - inscode(d, ds, de, "ENOMEM", ENOMEM, "Out of memory"); -#endif -#ifdef ENOTSOCK - inscode(d, ds, de, "ENOTSOCK", ENOTSOCK, "Socket operation on non-socket"); -#else -#ifdef WSAENOTSOCK - inscode(d, ds, de, "ENOTSOCK", WSAENOTSOCK, "Socket operation on non-socket"); -#endif -#endif -#ifdef ESTRPIPE - inscode(d, ds, de, "ESTRPIPE", ESTRPIPE, "Streams pipe error"); -#endif -#ifdef EMLINK - inscode(d, ds, de, "EMLINK", EMLINK, "Too many links"); -#endif -#ifdef ERANGE - inscode(d, ds, de, "ERANGE", ERANGE, "Math result not representable"); -#endif -#ifdef ELIBEXEC - inscode(d, ds, de, "ELIBEXEC", ELIBEXEC, "Cannot exec a shared library directly"); -#endif -#ifdef EL3HLT - inscode(d, ds, de, "EL3HLT", EL3HLT, "Level 3 halted"); -#endif -#ifdef ECONNRESET - inscode(d, ds, de, "ECONNRESET", ECONNRESET, "Connection reset by peer"); -#else -#ifdef WSAECONNRESET - inscode(d, ds, de, "ECONNRESET", WSAECONNRESET, "Connection reset by peer"); -#endif -#endif -#ifdef EADDRINUSE - inscode(d, ds, de, "EADDRINUSE", EADDRINUSE, "Address already in use"); -#else -#ifdef WSAEADDRINUSE - inscode(d, ds, de, "EADDRINUSE", WSAEADDRINUSE, "Address already in use"); -#endif -#endif -#ifdef EOPNOTSUPP - inscode(d, ds, de, "EOPNOTSUPP", EOPNOTSUPP, "Operation not supported on transport endpoint"); -#else -#ifdef WSAEOPNOTSUPP - inscode(d, ds, de, "EOPNOTSUPP", WSAEOPNOTSUPP, "Operation not supported on transport endpoint"); -#endif -#endif -#ifdef EREMCHG - inscode(d, ds, de, "EREMCHG", EREMCHG, "Remote address changed"); -#endif -#ifdef EAGAIN - inscode(d, ds, de, "EAGAIN", EAGAIN, "Try again"); -#endif -#ifdef ENAMETOOLONG - inscode(d, ds, de, "ENAMETOOLONG", ENAMETOOLONG, "File name too long"); -#else -#ifdef WSAENAMETOOLONG - inscode(d, ds, de, "ENAMETOOLONG", WSAENAMETOOLONG, "File name too long"); -#endif -#endif -#ifdef ENOTTY - inscode(d, ds, de, "ENOTTY", ENOTTY, "Not a typewriter"); -#endif -#ifdef ERESTART - inscode(d, ds, de, "ERESTART", ERESTART, "Interrupted system call should be restarted"); -#endif -#ifdef ESOCKTNOSUPPORT - inscode(d, ds, de, "ESOCKTNOSUPPORT", ESOCKTNOSUPPORT, "Socket type not supported"); -#else -#ifdef WSAESOCKTNOSUPPORT - inscode(d, ds, de, "ESOCKTNOSUPPORT", WSAESOCKTNOSUPPORT, "Socket type not supported"); -#endif -#endif -#ifdef ETIME - inscode(d, ds, de, "ETIME", ETIME, "Timer expired"); -#endif -#ifdef EBFONT - inscode(d, ds, de, "EBFONT", EBFONT, "Bad font file format"); -#endif -#ifdef EDEADLOCK - inscode(d, ds, de, "EDEADLOCK", EDEADLOCK, "Error EDEADLOCK"); -#endif -#ifdef ETOOMANYREFS - inscode(d, ds, de, "ETOOMANYREFS", ETOOMANYREFS, "Too many references: cannot splice"); -#else -#ifdef WSAETOOMANYREFS - inscode(d, ds, de, "ETOOMANYREFS", WSAETOOMANYREFS, "Too many references: cannot splice"); -#endif -#endif -#ifdef EMFILE - inscode(d, ds, de, "EMFILE", EMFILE, "Too many open files"); -#else -#ifdef WSAEMFILE - inscode(d, ds, de, "EMFILE", WSAEMFILE, "Too many open files"); -#endif -#endif -#ifdef ETXTBSY - inscode(d, ds, de, "ETXTBSY", ETXTBSY, "Text file busy"); -#endif -#ifdef EINPROGRESS - inscode(d, ds, de, "EINPROGRESS", EINPROGRESS, "Operation now in progress"); -#else -#ifdef WSAEINPROGRESS - inscode(d, ds, de, "EINPROGRESS", WSAEINPROGRESS, "Operation now in progress"); -#endif -#endif -#ifdef ENXIO - inscode(d, ds, de, "ENXIO", ENXIO, "No such device or address"); -#endif -#ifdef ENOPKG - inscode(d, ds, de, "ENOPKG", ENOPKG, "Package not installed"); -#endif -#ifdef WSASY - inscode(d, ds, de, "WSASY", WSASY, "Error WSASY"); -#endif -#ifdef WSAEHOSTDOWN - inscode(d, ds, de, "WSAEHOSTDOWN", WSAEHOSTDOWN, "Host is down"); -#endif -#ifdef WSAENETDOWN - inscode(d, ds, de, "WSAENETDOWN", WSAENETDOWN, "Network is down"); -#endif -#ifdef WSAENOTSOCK - inscode(d, ds, de, "WSAENOTSOCK", WSAENOTSOCK, "Socket operation on non-socket"); -#endif -#ifdef WSAEHOSTUNREACH - inscode(d, ds, de, "WSAEHOSTUNREACH", WSAEHOSTUNREACH, "No route to host"); -#endif -#ifdef WSAELOOP - inscode(d, ds, de, "WSAELOOP", WSAELOOP, "Too many symbolic links encountered"); -#endif -#ifdef WSAEMFILE - inscode(d, ds, de, "WSAEMFILE", WSAEMFILE, "Too many open files"); -#endif -#ifdef WSAESTALE - inscode(d, ds, de, "WSAESTALE", WSAESTALE, "Stale NFS file handle"); -#endif -#ifdef WSAVERNOTSUPPORTED - inscode(d, ds, de, "WSAVERNOTSUPPORTED", WSAVERNOTSUPPORTED, "Error WSAVERNOTSUPPORTED"); -#endif -#ifdef WSAENETUNREACH - inscode(d, ds, de, "WSAENETUNREACH", WSAENETUNREACH, "Network is unreachable"); -#endif -#ifdef WSAEPROCLIM - inscode(d, ds, de, "WSAEPROCLIM", WSAEPROCLIM, "Error WSAEPROCLIM"); -#endif -#ifdef WSAEFAULT - inscode(d, ds, de, "WSAEFAULT", WSAEFAULT, "Bad address"); -#endif -#ifdef WSANOTINITIALISED - inscode(d, ds, de, "WSANOTINITIALISED", WSANOTINITIALISED, "Error WSANOTINITIALISED"); -#endif -#ifdef WSAEUSERS - inscode(d, ds, de, "WSAEUSERS", WSAEUSERS, "Too many users"); -#endif -#ifdef WSAMAKEASYNCREPL - inscode(d, ds, de, "WSAMAKEASYNCREPL", WSAMAKEASYNCREPL, "Error WSAMAKEASYNCREPL"); -#endif -#ifdef WSAENOPROTOOPT - inscode(d, ds, de, "WSAENOPROTOOPT", WSAENOPROTOOPT, "Protocol not available"); -#endif -#ifdef WSAECONNABORTED - inscode(d, ds, de, "WSAECONNABORTED", WSAECONNABORTED, "Software caused connection abort"); -#endif -#ifdef WSAENAMETOOLONG - inscode(d, ds, de, "WSAENAMETOOLONG", WSAENAMETOOLONG, "File name too long"); -#endif -#ifdef WSAENOTEMPTY - inscode(d, ds, de, "WSAENOTEMPTY", WSAENOTEMPTY, "Directory not empty"); -#endif -#ifdef WSAESHUTDOWN - inscode(d, ds, de, "WSAESHUTDOWN", WSAESHUTDOWN, "Cannot send after transport endpoint shutdown"); -#endif -#ifdef WSAEAFNOSUPPORT - inscode(d, ds, de, "WSAEAFNOSUPPORT", WSAEAFNOSUPPORT, "Address family not supported by protocol"); -#endif -#ifdef WSAETOOMANYREFS - inscode(d, ds, de, "WSAETOOMANYREFS", WSAETOOMANYREFS, "Too many references: cannot splice"); -#endif -#ifdef WSAEACCES - inscode(d, ds, de, "WSAEACCES", WSAEACCES, "Permission denied"); -#endif -#ifdef WSATR - inscode(d, ds, de, "WSATR", WSATR, "Error WSATR"); -#endif -#ifdef WSABASEERR - inscode(d, ds, de, "WSABASEERR", WSABASEERR, "Error WSABASEERR"); -#endif -#ifdef WSADESCRIPTIO - inscode(d, ds, de, "WSADESCRIPTIO", WSADESCRIPTIO, "Error WSADESCRIPTIO"); -#endif -#ifdef WSAEMSGSIZE - inscode(d, ds, de, "WSAEMSGSIZE", WSAEMSGSIZE, "Message too long"); -#endif -#ifdef WSAEBADF - inscode(d, ds, de, "WSAEBADF", WSAEBADF, "Bad file number"); -#endif -#ifdef WSAECONNRESET - inscode(d, ds, de, "WSAECONNRESET", WSAECONNRESET, "Connection reset by peer"); -#endif -#ifdef WSAGETSELECTERRO - inscode(d, ds, de, "WSAGETSELECTERRO", WSAGETSELECTERRO, "Error WSAGETSELECTERRO"); -#endif -#ifdef WSAETIMEDOUT - inscode(d, ds, de, "WSAETIMEDOUT", WSAETIMEDOUT, "Connection timed out"); -#endif -#ifdef WSAENOBUFS - inscode(d, ds, de, "WSAENOBUFS", WSAENOBUFS, "No buffer space available"); -#endif -#ifdef WSAEDISCON - inscode(d, ds, de, "WSAEDISCON", WSAEDISCON, "Error WSAEDISCON"); -#endif -#ifdef WSAEINTR - inscode(d, ds, de, "WSAEINTR", WSAEINTR, "Interrupted system call"); -#endif -#ifdef WSAEPROTOTYPE - inscode(d, ds, de, "WSAEPROTOTYPE", WSAEPROTOTYPE, "Protocol wrong type for socket"); -#endif -#ifdef WSAHOS - inscode(d, ds, de, "WSAHOS", WSAHOS, "Error WSAHOS"); -#endif -#ifdef WSAEADDRINUSE - inscode(d, ds, de, "WSAEADDRINUSE", WSAEADDRINUSE, "Address already in use"); -#endif -#ifdef WSAEADDRNOTAVAIL - inscode(d, ds, de, "WSAEADDRNOTAVAIL", WSAEADDRNOTAVAIL, "Cannot assign requested address"); -#endif -#ifdef WSAEALREADY - inscode(d, ds, de, "WSAEALREADY", WSAEALREADY, "Operation already in progress"); -#endif -#ifdef WSAEPROTONOSUPPORT - inscode(d, ds, de, "WSAEPROTONOSUPPORT", WSAEPROTONOSUPPORT, "Protocol not supported"); -#endif -#ifdef WSASYSNOTREADY - inscode(d, ds, de, "WSASYSNOTREADY", WSASYSNOTREADY, "Error WSASYSNOTREADY"); -#endif -#ifdef WSAEWOULDBLOCK - inscode(d, ds, de, "WSAEWOULDBLOCK", WSAEWOULDBLOCK, "Operation would block"); -#endif -#ifdef WSAEPFNOSUPPORT - inscode(d, ds, de, "WSAEPFNOSUPPORT", WSAEPFNOSUPPORT, "Protocol family not supported"); -#endif -#ifdef WSAEOPNOTSUPP - inscode(d, ds, de, "WSAEOPNOTSUPP", WSAEOPNOTSUPP, "Operation not supported on transport endpoint"); -#endif -#ifdef WSAEISCONN - inscode(d, ds, de, "WSAEISCONN", WSAEISCONN, "Transport endpoint is already connected"); -#endif -#ifdef WSAEDQUOT - inscode(d, ds, de, "WSAEDQUOT", WSAEDQUOT, "Quota exceeded"); -#endif -#ifdef WSAENOTCONN - inscode(d, ds, de, "WSAENOTCONN", WSAENOTCONN, "Transport endpoint is not connected"); -#endif -#ifdef WSAEREMOTE - inscode(d, ds, de, "WSAEREMOTE", WSAEREMOTE, "Object is remote"); -#endif -#ifdef WSAEINVAL - inscode(d, ds, de, "WSAEINVAL", WSAEINVAL, "Invalid argument"); -#endif -#ifdef WSAEINPROGRESS - inscode(d, ds, de, "WSAEINPROGRESS", WSAEINPROGRESS, "Operation now in progress"); -#endif -#ifdef WSAGETSELECTEVEN - inscode(d, ds, de, "WSAGETSELECTEVEN", WSAGETSELECTEVEN, "Error WSAGETSELECTEVEN"); -#endif -#ifdef WSAESOCKTNOSUPPORT - inscode(d, ds, de, "WSAESOCKTNOSUPPORT", WSAESOCKTNOSUPPORT, "Socket type not supported"); -#endif -#ifdef WSAGETASYNCERRO - inscode(d, ds, de, "WSAGETASYNCERRO", WSAGETASYNCERRO, "Error WSAGETASYNCERRO"); -#endif -#ifdef WSAMAKESELECTREPL - inscode(d, ds, de, "WSAMAKESELECTREPL", WSAMAKESELECTREPL, "Error WSAMAKESELECTREPL"); -#endif -#ifdef WSAGETASYNCBUFLE - inscode(d, ds, de, "WSAGETASYNCBUFLE", WSAGETASYNCBUFLE, "Error WSAGETASYNCBUFLE"); -#endif -#ifdef WSAEDESTADDRREQ - inscode(d, ds, de, "WSAEDESTADDRREQ", WSAEDESTADDRREQ, "Destination address required"); -#endif -#ifdef WSAECONNREFUSED - inscode(d, ds, de, "WSAECONNREFUSED", WSAECONNREFUSED, "Connection refused"); -#endif -#ifdef WSAENETRESET - inscode(d, ds, de, "WSAENETRESET", WSAENETRESET, "Network dropped connection because of reset"); -#endif -#ifdef WSAN - inscode(d, ds, de, "WSAN", WSAN, "Error WSAN"); -#endif - - Py_DECREF(de); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/Makefile.in b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/Makefile.in deleted file mode 100644 index d6851844..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/Makefile.in +++ /dev/null @@ -1,158 +0,0 @@ -################################################################ -# Process this file with top-level configure script to produce Makefile -# -# Copyright 2000 Clark Cooper -# -# This file is part of EXPAT. -# -# EXPAT is free software; you can redistribute it and/or modify it -# under the terms of the License (based on the MIT/X license) contained -# in the file COPYING that comes with this distribution. -# -# EXPAT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN EXPAT. -# - - -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include - -subdir = lib - -top_builddir = .. - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_DATA = @INSTALL_DATA@ - -host_alias = @host_alias@ -host_triplet = @host@ -AS = @AS@ -CC = @CC@ -DLLTOOL = @DLLTOOL@ -LIBTOOL = @LIBTOOL@ -LN_S = @LN_S@ -OBJDUMP = @OBJDUMP@ -PACKAGE = @PACKAGE@ -RANLIB = @RANLIB@ -VERSION = @VERSION@ - -LIBRARY = libexpat.la -SOURCES = xmlparse.c xmltok.c xmlrole.c -OBJECTS = $(SOURCES:.c=.o) -LTOBJECTS = $(SOURCES:.c=.lo) - -TEMPLATES = xmltok_impl.c xmltok_ns.c -APIHEADER = expat.h -HEADERS = ascii.h iasciitab.h utf8tab.h xmltok.h asciitab.h latin1tab.h \ - nametab.h xmldef.h xmlrole.h xmltok_impl.h - -mkinstalldirs = $(SHELL) $(top_srcdir)/conftools/mkinstalldirs -CONFIG_HEADER = ../config.h -CONFIG_CLEAN_FILES = - -INCLUDES = -I$(srcdir) -I. -I.. -DEFS = @DEFS@ -DPACKAGE='"$(PACKAGE)"' -DVERSION='"$(PACKAGE)_$(VERSION)"' - -CPPFLAGS = @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ -CFLAGS = @CFLAGS@ - -LIBREVISION = @LIBREVISION@ -LIBCURRENT = @LIBCURRENT@ -LIBAGE = @LIBAGE@ - -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) -version-info $(LIBCURRENT):$(LIBREVISION):$(LIBAGE) $(CFLAGS) $(LDFLAGS) -o $@ -DIST_COMMON = Makefile.in - - -DISTFILES = $(DIST_COMMON) $(SOURCES) $(TEMPLATES) $(APIHEADER) $(HEADERS) - -TAR = gtar -GZIP_ENV = --best - -all: $(LIBRARY) - -.SUFFIXES: .c .lo .o -.PHONY: all clean distclean maintainer-clean - -.c.o: - $(COMPILE) -c $< - -.c.lo: - $(LTCOMPILE) -c $< - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status - -$(top_builddir)/config.status: $(top_builddir)/configure - cd $(top_builddir) && $(MAKE) config.status - -$(top_builddir)/config.h: $(top_builddir)/config.h.in - cd $(top_builddir) && $(MAKE) config.h - -clean: - rm -f $(LIBRARY) *.o *.lo *~ - rm -rf .libs _libs - -distclean: clean - rm -f Makefile - -maintainer-clean: distclean - -check: $(SUBDIRS) - @echo - @echo This package does not yet have a regression test. - @echo - -install: $(LIBRARY) $(APIHEADER) - $(mkinstalldirs) $(libdir) $(includedir) - $(LIBTOOL) --mode=install $(INSTALL) $(LIBRARY) $(libdir)/$(LIBRARY) - $(INSTALL_DATA) $(APIHEADER) $(includedir) - -uninstall: - $(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(LIBRARY); - rm -f $(libdir)/$(APIHEADER) - -$(LIBRARY): $(LTOBJECTS) - $(LINK) -rpath $(libdir) $(LDFLAGS) $(LTOBJECTS) - -xmlparse.o \ -xmlparse.lo: xmlparse.c expat.h xmlrole.h xmltok.h $(top_builddir)/config.h - -xmlrole.o \ -xmlrole.lo: xmlrole.c ascii.h xmlrole.h $(top_builddir)/config.h - -xmltok.o \ -xmltok.lo: xmltok.c xmltok_impl.c xmltok_ns.c \ - ascii.h asciitab.h iasciitab.h latin1tab.h nametab.h utf8tab.h \ - xmltok.h xmltok_impl.h $(top_builddir)/config.h diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/ascii.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/ascii.h deleted file mode 100644 index 035cd39a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/ascii.h +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#define ASCII_A 0x41 -#define ASCII_B 0x42 -#define ASCII_C 0x43 -#define ASCII_D 0x44 -#define ASCII_E 0x45 -#define ASCII_F 0x46 -#define ASCII_G 0x47 -#define ASCII_H 0x48 -#define ASCII_I 0x49 -#define ASCII_J 0x4A -#define ASCII_K 0x4B -#define ASCII_L 0x4C -#define ASCII_M 0x4D -#define ASCII_N 0x4E -#define ASCII_O 0x4F -#define ASCII_P 0x50 -#define ASCII_Q 0x51 -#define ASCII_R 0x52 -#define ASCII_S 0x53 -#define ASCII_T 0x54 -#define ASCII_U 0x55 -#define ASCII_V 0x56 -#define ASCII_W 0x57 -#define ASCII_X 0x58 -#define ASCII_Y 0x59 -#define ASCII_Z 0x5A - -#define ASCII_a 0x61 -#define ASCII_b 0x62 -#define ASCII_c 0x63 -#define ASCII_d 0x64 -#define ASCII_e 0x65 -#define ASCII_f 0x66 -#define ASCII_g 0x67 -#define ASCII_h 0x68 -#define ASCII_i 0x69 -#define ASCII_j 0x6A -#define ASCII_k 0x6B -#define ASCII_l 0x6C -#define ASCII_m 0x6D -#define ASCII_n 0x6E -#define ASCII_o 0x6F -#define ASCII_p 0x70 -#define ASCII_q 0x71 -#define ASCII_r 0x72 -#define ASCII_s 0x73 -#define ASCII_t 0x74 -#define ASCII_u 0x75 -#define ASCII_v 0x76 -#define ASCII_w 0x77 -#define ASCII_x 0x78 -#define ASCII_y 0x79 -#define ASCII_z 0x7A - -#define ASCII_0 0x30 -#define ASCII_1 0x31 -#define ASCII_2 0x32 -#define ASCII_3 0x33 -#define ASCII_4 0x34 -#define ASCII_5 0x35 -#define ASCII_6 0x36 -#define ASCII_7 0x37 -#define ASCII_8 0x38 -#define ASCII_9 0x39 - -#define ASCII_TAB 0x09 -#define ASCII_SPACE 0x20 -#define ASCII_EXCL 0x21 -#define ASCII_QUOT 0x22 -#define ASCII_AMP 0x26 -#define ASCII_APOS 0x27 -#define ASCII_MINUS 0x2D -#define ASCII_PERIOD 0x2E -#define ASCII_COLON 0x3A -#define ASCII_SEMI 0x3B -#define ASCII_LT 0x3C -#define ASCII_EQUALS 0x3D -#define ASCII_GT 0x3E -#define ASCII_LSQB 0x5B -#define ASCII_RSQB 0x5D -#define ASCII_UNDERSCORE 0x5F diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/asciitab.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/asciitab.h deleted file mode 100644 index 2ef65c79..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/asciitab.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML, -/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML, -/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM, -/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS, -/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS, -/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL, -/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, -/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, -/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI, -/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST, -/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, -/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, -/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB, -/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT, -/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, -/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, -/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, -/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER, diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/expat.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/expat.h deleted file mode 100644 index 4e8f32e6..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/expat.h +++ /dev/null @@ -1,1001 +0,0 @@ -/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#ifndef XmlParse_INCLUDED -#define XmlParse_INCLUDED 1 - -#ifdef __VMS -/* 0 1 2 3 0 1 2 3 - 1234567890123456789012345678901 1234567890123456789012345678901 */ -#define XML_SetProcessingInstructionHandler XML_SetProcessingInstrHandler -#define XML_SetUnparsedEntityDeclHandler XML_SetUnparsedEntDeclHandler -#define XML_SetStartNamespaceDeclHandler XML_SetStartNamespcDeclHandler -#define XML_SetExternalEntityRefHandlerArg XML_SetExternalEntRefHandlerArg -#endif - -#include - -#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__) -#define XML_USE_MSC_EXTENSIONS 1 -#endif - -/* Expat tries very hard to make the API boundary very specifically - defined. There are two macros defined to control this boundary; - each of these can be defined before including this header to - achieve some different behavior, but doing so it not recommended or - tested frequently. - - XMLCALL - The calling convention to use for all calls across the - "library boundary." This will default to cdecl, and - try really hard to tell the compiler that's what we - want. - - XMLIMPORT - Whatever magic is needed to note that a function is - to be imported from a dynamically loaded library - (.dll, .so, or .sl, depending on your platform). - - The XMLCALL macro was added in Expat 1.95.7. The only one which is - expected to be directly useful in client code is XMLCALL. - - Note that on at least some Unix versions, the Expat library must be - compiled with the cdecl calling convention as the default since - system headers may assume the cdecl convention. -*/ -#ifndef XMLCALL -#if defined(XML_USE_MSC_EXTENSIONS) -#define XMLCALL __cdecl -#elif defined(__GNUC__) -#define XMLCALL __attribute__((cdecl)) -#else -/* For any platform which uses this definition and supports more than - one calling convention, we need to extend this definition to - declare the convention used on that platform, if it's possible to - do so. - - If this is the case for your platform, please file a bug report - with information on how to identify your platform via the C - pre-processor and how to specify the same calling convention as the - platform's malloc() implementation. -*/ -#define XMLCALL -#endif -#endif /* not defined XMLCALL */ - - -#if !defined(XML_STATIC) && !defined(XMLIMPORT) -#ifndef XML_BUILDING_EXPAT -/* using Expat from an application */ - -#ifdef XML_USE_MSC_EXTENSIONS -#define XMLIMPORT __declspec(dllimport) -#endif - -#endif -#endif /* not defined XML_STATIC */ - -/* If we didn't define it above, define it away: */ -#ifndef XMLIMPORT -#define XMLIMPORT -#endif - - -#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef XML_UNICODE_WCHAR_T -#define XML_UNICODE -#endif - -struct XML_ParserStruct; -typedef struct XML_ParserStruct *XML_Parser; - -#ifdef XML_UNICODE /* Information is UTF-16 encoded. */ -#ifdef XML_UNICODE_WCHAR_T -typedef wchar_t XML_Char; -typedef wchar_t XML_LChar; -#else -typedef unsigned short XML_Char; -typedef char XML_LChar; -#endif /* XML_UNICODE_WCHAR_T */ -#else /* Information is UTF-8 encoded. */ -typedef char XML_Char; -typedef char XML_LChar; -#endif /* XML_UNICODE */ - -/* Should this be defined using stdbool.h when C99 is available? */ -typedef unsigned char XML_Bool; -#define XML_TRUE ((XML_Bool) 1) -#define XML_FALSE ((XML_Bool) 0) - -/* The XML_Status enum gives the possible return values for several - API functions. The preprocessor #defines are included so this - stanza can be added to code that still needs to support older - versions of Expat 1.95.x: - - #ifndef XML_STATUS_OK - #define XML_STATUS_OK 1 - #define XML_STATUS_ERROR 0 - #endif - - Otherwise, the #define hackery is quite ugly and would have been - dropped. -*/ -enum XML_Status { - XML_STATUS_ERROR = 0, -#define XML_STATUS_ERROR XML_STATUS_ERROR - XML_STATUS_OK = 1 -#define XML_STATUS_OK XML_STATUS_OK -}; - -enum XML_Error { - XML_ERROR_NONE, - XML_ERROR_NO_MEMORY, - XML_ERROR_SYNTAX, - XML_ERROR_NO_ELEMENTS, - XML_ERROR_INVALID_TOKEN, - XML_ERROR_UNCLOSED_TOKEN, - XML_ERROR_PARTIAL_CHAR, - XML_ERROR_TAG_MISMATCH, - XML_ERROR_DUPLICATE_ATTRIBUTE, - XML_ERROR_JUNK_AFTER_DOC_ELEMENT, - XML_ERROR_PARAM_ENTITY_REF, - XML_ERROR_UNDEFINED_ENTITY, - XML_ERROR_RECURSIVE_ENTITY_REF, - XML_ERROR_ASYNC_ENTITY, - XML_ERROR_BAD_CHAR_REF, - XML_ERROR_BINARY_ENTITY_REF, - XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, - XML_ERROR_MISPLACED_XML_PI, - XML_ERROR_UNKNOWN_ENCODING, - XML_ERROR_INCORRECT_ENCODING, - XML_ERROR_UNCLOSED_CDATA_SECTION, - XML_ERROR_EXTERNAL_ENTITY_HANDLING, - XML_ERROR_NOT_STANDALONE, - XML_ERROR_UNEXPECTED_STATE, - XML_ERROR_ENTITY_DECLARED_IN_PE, - XML_ERROR_FEATURE_REQUIRES_XML_DTD, - XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING, - XML_ERROR_UNBOUND_PREFIX -}; - -enum XML_Content_Type { - XML_CTYPE_EMPTY = 1, - XML_CTYPE_ANY, - XML_CTYPE_MIXED, - XML_CTYPE_NAME, - XML_CTYPE_CHOICE, - XML_CTYPE_SEQ -}; - -enum XML_Content_Quant { - XML_CQUANT_NONE, - XML_CQUANT_OPT, - XML_CQUANT_REP, - XML_CQUANT_PLUS -}; - -/* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be - XML_CQUANT_NONE, and the other fields will be zero or NULL. - If type == XML_CTYPE_MIXED, then quant will be NONE or REP and - numchildren will contain number of elements that may be mixed in - and children point to an array of XML_Content cells that will be - all of XML_CTYPE_NAME type with no quantification. - - If type == XML_CTYPE_NAME, then the name points to the name, and - the numchildren field will be zero and children will be NULL. The - quant fields indicates any quantifiers placed on the name. - - CHOICE and SEQ will have name NULL, the number of children in - numchildren and children will point, recursively, to an array - of XML_Content cells. - - The EMPTY, ANY, and MIXED types will only occur at top level. -*/ - -typedef struct XML_cp XML_Content; - -struct XML_cp { - enum XML_Content_Type type; - enum XML_Content_Quant quant; - XML_Char * name; - unsigned int numchildren; - XML_Content * children; -}; - - -/* This is called for an element declaration. See above for - description of the model argument. It's the caller's responsibility - to free model when finished with it. -*/ -typedef void (XMLCALL *XML_ElementDeclHandler) (void *userData, - const XML_Char *name, - XML_Content *model); - -XMLPARSEAPI(void) -XML_SetElementDeclHandler(XML_Parser parser, - XML_ElementDeclHandler eldecl); - -/* The Attlist declaration handler is called for *each* attribute. So - a single Attlist declaration with multiple attributes declared will - generate multiple calls to this handler. The "default" parameter - may be NULL in the case of the "#IMPLIED" or "#REQUIRED" - keyword. The "isrequired" parameter will be true and the default - value will be NULL in the case of "#REQUIRED". If "isrequired" is - true and default is non-NULL, then this is a "#FIXED" default. -*/ -typedef void (XMLCALL *XML_AttlistDeclHandler) ( - void *userData, - const XML_Char *elname, - const XML_Char *attname, - const XML_Char *att_type, - const XML_Char *dflt, - int isrequired); - -XMLPARSEAPI(void) -XML_SetAttlistDeclHandler(XML_Parser parser, - XML_AttlistDeclHandler attdecl); - -/* The XML declaration handler is called for *both* XML declarations - and text declarations. The way to distinguish is that the version - parameter will be NULL for text declarations. The encoding - parameter may be NULL for XML declarations. The standalone - parameter will be -1, 0, or 1 indicating respectively that there - was no standalone parameter in the declaration, that it was given - as no, or that it was given as yes. -*/ -typedef void (XMLCALL *XML_XmlDeclHandler) (void *userData, - const XML_Char *version, - const XML_Char *encoding, - int standalone); - -XMLPARSEAPI(void) -XML_SetXmlDeclHandler(XML_Parser parser, - XML_XmlDeclHandler xmldecl); - - -typedef struct { - void *(XMLCALL *malloc_fcn)(size_t size); - void *(XMLCALL *realloc_fcn)(void *ptr, size_t size); - void (XMLCALL *free_fcn)(void *ptr); -} XML_Memory_Handling_Suite; - -/* Constructs a new parser; encoding is the encoding specified by the - external protocol or NULL if there is none specified. -*/ -XMLPARSEAPI(XML_Parser) -XML_ParserCreate(const XML_Char *encoding); - -/* Constructs a new parser and namespace processor. Element type - names and attribute names that belong to a namespace will be - expanded; unprefixed attribute names are never expanded; unprefixed - element type names are expanded only if there is a default - namespace. The expanded name is the concatenation of the namespace - URI, the namespace separator character, and the local part of the - name. If the namespace separator is '\0' then the namespace URI - and the local part will be concatenated without any separator. - When a namespace is not declared, the name and prefix will be - passed through without expansion. -*/ -XMLPARSEAPI(XML_Parser) -XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator); - - -/* Constructs a new parser using the memory management suite referred to - by memsuite. If memsuite is NULL, then use the standard library memory - suite. If namespaceSeparator is non-NULL it creates a parser with - namespace processing as described above. The character pointed at - will serve as the namespace separator. - - All further memory operations used for the created parser will come from - the given suite. -*/ -XMLPARSEAPI(XML_Parser) -XML_ParserCreate_MM(const XML_Char *encoding, - const XML_Memory_Handling_Suite *memsuite, - const XML_Char *namespaceSeparator); - -/* Prepare a parser object to be re-used. This is particularly - valuable when memory allocation overhead is disproportionatly high, - such as when a large number of small documnents need to be parsed. - All handlers are cleared from the parser, except for the - unknownEncodingHandler. The parser's external state is re-initialized - except for the values of ns and ns_triplets. - - Added in Expat 1.95.3. -*/ -XMLPARSEAPI(XML_Bool) -XML_ParserReset(XML_Parser parser, const XML_Char *encoding); - -/* atts is array of name/value pairs, terminated by 0; - names and values are 0 terminated. -*/ -typedef void (XMLCALL *XML_StartElementHandler) (void *userData, - const XML_Char *name, - const XML_Char **atts); - -typedef void (XMLCALL *XML_EndElementHandler) (void *userData, - const XML_Char *name); - - -/* s is not 0 terminated. */ -typedef void (XMLCALL *XML_CharacterDataHandler) (void *userData, - const XML_Char *s, - int len); - -/* target and data are 0 terminated */ -typedef void (XMLCALL *XML_ProcessingInstructionHandler) ( - void *userData, - const XML_Char *target, - const XML_Char *data); - -/* data is 0 terminated */ -typedef void (XMLCALL *XML_CommentHandler) (void *userData, - const XML_Char *data); - -typedef void (XMLCALL *XML_StartCdataSectionHandler) (void *userData); -typedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData); - -/* This is called for any characters in the XML document for which - there is no applicable handler. This includes both characters that - are part of markup which is of a kind that is not reported - (comments, markup declarations), or characters that are part of a - construct which could be reported but for which no handler has been - supplied. The characters are passed exactly as they were in the XML - document except that they will be encoded in UTF-8 or UTF-16. - Line boundaries are not normalized. Note that a byte order mark - character is not passed to the default handler. There are no - guarantees about how characters are divided between calls to the - default handler: for example, a comment might be split between - multiple calls. -*/ -typedef void (XMLCALL *XML_DefaultHandler) (void *userData, - const XML_Char *s, - int len); - -/* This is called for the start of the DOCTYPE declaration, before - any DTD or internal subset is parsed. -*/ -typedef void (XMLCALL *XML_StartDoctypeDeclHandler) ( - void *userData, - const XML_Char *doctypeName, - const XML_Char *sysid, - const XML_Char *pubid, - int has_internal_subset); - -/* This is called for the start of the DOCTYPE declaration when the - closing > is encountered, but after processing any external - subset. -*/ -typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData); - -/* This is called for entity declarations. The is_parameter_entity - argument will be non-zero if the entity is a parameter entity, zero - otherwise. - - For internal entities (), value will - be non-NULL and systemId, publicID, and notationName will be NULL. - The value string is NOT nul-terminated; the length is provided in - the value_length argument. Since it is legal to have zero-length - values, do not use this argument to test for internal entities. - - For external entities, value will be NULL and systemId will be - non-NULL. The publicId argument will be NULL unless a public - identifier was provided. The notationName argument will have a - non-NULL value only for unparsed entity declarations. - - Note that is_parameter_entity can't be changed to XML_Bool, since - that would break binary compatibility. -*/ -typedef void (XMLCALL *XML_EntityDeclHandler) ( - void *userData, - const XML_Char *entityName, - int is_parameter_entity, - const XML_Char *value, - int value_length, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId, - const XML_Char *notationName); - -XMLPARSEAPI(void) -XML_SetEntityDeclHandler(XML_Parser parser, - XML_EntityDeclHandler handler); - -/* OBSOLETE -- OBSOLETE -- OBSOLETE - This handler has been superceded by the EntityDeclHandler above. - It is provided here for backward compatibility. - - This is called for a declaration of an unparsed (NDATA) entity. - The base argument is whatever was set by XML_SetBase. The - entityName, systemId and notationName arguments will never be - NULL. The other arguments may be. -*/ -typedef void (XMLCALL *XML_UnparsedEntityDeclHandler) ( - void *userData, - const XML_Char *entityName, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId, - const XML_Char *notationName); - -/* This is called for a declaration of notation. The base argument is - whatever was set by XML_SetBase. The notationName will never be - NULL. The other arguments can be. -*/ -typedef void (XMLCALL *XML_NotationDeclHandler) ( - void *userData, - const XML_Char *notationName, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId); - -/* When namespace processing is enabled, these are called once for - each namespace declaration. The call to the start and end element - handlers occur between the calls to the start and end namespace - declaration handlers. For an xmlns attribute, prefix will be - NULL. For an xmlns="" attribute, uri will be NULL. -*/ -typedef void (XMLCALL *XML_StartNamespaceDeclHandler) ( - void *userData, - const XML_Char *prefix, - const XML_Char *uri); - -typedef void (XMLCALL *XML_EndNamespaceDeclHandler) ( - void *userData, - const XML_Char *prefix); - -/* This is called if the document is not standalone, that is, it has an - external subset or a reference to a parameter entity, but does not - have standalone="yes". If this handler returns XML_STATUS_ERROR, - then processing will not continue, and the parser will return a - XML_ERROR_NOT_STANDALONE error. - If parameter entity parsing is enabled, then in addition to the - conditions above this handler will only be called if the referenced - entity was actually read. -*/ -typedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData); - -/* This is called for a reference to an external parsed general - entity. The referenced entity is not automatically parsed. The - application can parse it immediately or later using - XML_ExternalEntityParserCreate. - - The parser argument is the parser parsing the entity containing the - reference; it can be passed as the parser argument to - XML_ExternalEntityParserCreate. The systemId argument is the - system identifier as specified in the entity declaration; it will - not be NULL. - - The base argument is the system identifier that should be used as - the base for resolving systemId if systemId was relative; this is - set by XML_SetBase; it may be NULL. - - The publicId argument is the public identifier as specified in the - entity declaration, or NULL if none was specified; the whitespace - in the public identifier will have been normalized as required by - the XML spec. - - The context argument specifies the parsing context in the format - expected by the context argument to XML_ExternalEntityParserCreate; - context is valid only until the handler returns, so if the - referenced entity is to be parsed later, it must be copied. - context is NULL only when the entity is a parameter entity. - - The handler should return XML_STATUS_ERROR if processing should not - continue because of a fatal error in the handling of the external - entity. In this case the calling parser will return an - XML_ERROR_EXTERNAL_ENTITY_HANDLING error. - - Note that unlike other handlers the first argument is the parser, - not userData. -*/ -typedef int (XMLCALL *XML_ExternalEntityRefHandler) ( - XML_Parser parser, - const XML_Char *context, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId); - -/* This is called in two situations: - 1) An entity reference is encountered for which no declaration - has been read *and* this is not an error. - 2) An internal entity reference is read, but not expanded, because - XML_SetDefaultHandler has been called. - Note: skipped parameter entities in declarations and skipped general - entities in attribute values cannot be reported, because - the event would be out of sync with the reporting of the - declarations or attribute values -*/ -typedef void (XMLCALL *XML_SkippedEntityHandler) ( - void *userData, - const XML_Char *entityName, - int is_parameter_entity); - -/* This structure is filled in by the XML_UnknownEncodingHandler to - provide information to the parser about encodings that are unknown - to the parser. - - The map[b] member gives information about byte sequences whose - first byte is b. - - If map[b] is c where c is >= 0, then b by itself encodes the - Unicode scalar value c. - - If map[b] is -1, then the byte sequence is malformed. - - If map[b] is -n, where n >= 2, then b is the first byte of an - n-byte sequence that encodes a single Unicode scalar value. - - The data member will be passed as the first argument to the convert - function. - - The convert function is used to convert multibyte sequences; s will - point to a n-byte sequence where map[(unsigned char)*s] == -n. The - convert function must return the Unicode scalar value represented - by this byte sequence or -1 if the byte sequence is malformed. - - The convert function may be NULL if the encoding is a single-byte - encoding, that is if map[b] >= -1 for all bytes b. - - When the parser is finished with the encoding, then if release is - not NULL, it will call release passing it the data member; once - release has been called, the convert function will not be called - again. - - Expat places certain restrictions on the encodings that are supported - using this mechanism. - - 1. Every ASCII character that can appear in a well-formed XML document, - other than the characters - - $@\^`{}~ - - must be represented by a single byte, and that byte must be the - same byte that represents that character in ASCII. - - 2. No character may require more than 4 bytes to encode. - - 3. All characters encoded must have Unicode scalar values <= - 0xFFFF, (i.e., characters that would be encoded by surrogates in - UTF-16 are not allowed). Note that this restriction doesn't - apply to the built-in support for UTF-8 and UTF-16. - - 4. No Unicode character may be encoded by more than one distinct - sequence of bytes. -*/ -typedef struct { - int map[256]; - void *data; - int (XMLCALL *convert)(void *data, const char *s); - void (XMLCALL *release)(void *data); -} XML_Encoding; - -/* This is called for an encoding that is unknown to the parser. - - The encodingHandlerData argument is that which was passed as the - second argument to XML_SetUnknownEncodingHandler. - - The name argument gives the name of the encoding as specified in - the encoding declaration. - - If the callback can provide information about the encoding, it must - fill in the XML_Encoding structure, and return XML_STATUS_OK. - Otherwise it must return XML_STATUS_ERROR. - - If info does not describe a suitable encoding, then the parser will - return an XML_UNKNOWN_ENCODING error. -*/ -typedef int (XMLCALL *XML_UnknownEncodingHandler) ( - void *encodingHandlerData, - const XML_Char *name, - XML_Encoding *info); - -XMLPARSEAPI(void) -XML_SetElementHandler(XML_Parser parser, - XML_StartElementHandler start, - XML_EndElementHandler end); - -XMLPARSEAPI(void) -XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler); - -XMLPARSEAPI(void) -XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler); - -XMLPARSEAPI(void) -XML_SetCharacterDataHandler(XML_Parser parser, - XML_CharacterDataHandler handler); - -XMLPARSEAPI(void) -XML_SetProcessingInstructionHandler(XML_Parser parser, - XML_ProcessingInstructionHandler handler); -XMLPARSEAPI(void) -XML_SetCommentHandler(XML_Parser parser, - XML_CommentHandler handler); - -XMLPARSEAPI(void) -XML_SetCdataSectionHandler(XML_Parser parser, - XML_StartCdataSectionHandler start, - XML_EndCdataSectionHandler end); - -XMLPARSEAPI(void) -XML_SetStartCdataSectionHandler(XML_Parser parser, - XML_StartCdataSectionHandler start); - -XMLPARSEAPI(void) -XML_SetEndCdataSectionHandler(XML_Parser parser, - XML_EndCdataSectionHandler end); - -/* This sets the default handler and also inhibits expansion of - internal entities. These entity references will be passed to the - default handler, or to the skipped entity handler, if one is set. -*/ -XMLPARSEAPI(void) -XML_SetDefaultHandler(XML_Parser parser, - XML_DefaultHandler handler); - -/* This sets the default handler but does not inhibit expansion of - internal entities. The entity reference will not be passed to the - default handler. -*/ -XMLPARSEAPI(void) -XML_SetDefaultHandlerExpand(XML_Parser parser, - XML_DefaultHandler handler); - -XMLPARSEAPI(void) -XML_SetDoctypeDeclHandler(XML_Parser parser, - XML_StartDoctypeDeclHandler start, - XML_EndDoctypeDeclHandler end); - -XMLPARSEAPI(void) -XML_SetStartDoctypeDeclHandler(XML_Parser parser, - XML_StartDoctypeDeclHandler start); - -XMLPARSEAPI(void) -XML_SetEndDoctypeDeclHandler(XML_Parser parser, - XML_EndDoctypeDeclHandler end); - -XMLPARSEAPI(void) -XML_SetUnparsedEntityDeclHandler(XML_Parser parser, - XML_UnparsedEntityDeclHandler handler); - -XMLPARSEAPI(void) -XML_SetNotationDeclHandler(XML_Parser parser, - XML_NotationDeclHandler handler); - -XMLPARSEAPI(void) -XML_SetNamespaceDeclHandler(XML_Parser parser, - XML_StartNamespaceDeclHandler start, - XML_EndNamespaceDeclHandler end); - -XMLPARSEAPI(void) -XML_SetStartNamespaceDeclHandler(XML_Parser parser, - XML_StartNamespaceDeclHandler start); - -XMLPARSEAPI(void) -XML_SetEndNamespaceDeclHandler(XML_Parser parser, - XML_EndNamespaceDeclHandler end); - -XMLPARSEAPI(void) -XML_SetNotStandaloneHandler(XML_Parser parser, - XML_NotStandaloneHandler handler); - -XMLPARSEAPI(void) -XML_SetExternalEntityRefHandler(XML_Parser parser, - XML_ExternalEntityRefHandler handler); - -/* If a non-NULL value for arg is specified here, then it will be - passed as the first argument to the external entity ref handler - instead of the parser object. -*/ -XMLPARSEAPI(void) -XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg); - -XMLPARSEAPI(void) -XML_SetSkippedEntityHandler(XML_Parser parser, - XML_SkippedEntityHandler handler); - -XMLPARSEAPI(void) -XML_SetUnknownEncodingHandler(XML_Parser parser, - XML_UnknownEncodingHandler handler, - void *encodingHandlerData); - -/* This can be called within a handler for a start element, end - element, processing instruction or character data. It causes the - corresponding markup to be passed to the default handler. -*/ -XMLPARSEAPI(void) -XML_DefaultCurrent(XML_Parser parser); - -/* If do_nst is non-zero, and namespace processing is in effect, and - a name has a prefix (i.e. an explicit namespace qualifier) then - that name is returned as a triplet in a single string separated by - the separator character specified when the parser was created: URI - + sep + local_name + sep + prefix. - - If do_nst is zero, then namespace information is returned in the - default manner (URI + sep + local_name) whether or not the name - has a prefix. - - Note: Calling XML_SetReturnNSTriplet after XML_Parse or - XML_ParseBuffer has no effect. -*/ - -XMLPARSEAPI(void) -XML_SetReturnNSTriplet(XML_Parser parser, int do_nst); - -/* This value is passed as the userData argument to callbacks. */ -XMLPARSEAPI(void) -XML_SetUserData(XML_Parser parser, void *userData); - -/* Returns the last value set by XML_SetUserData or NULL. */ -#define XML_GetUserData(parser) (*(void **)(parser)) - -/* This is equivalent to supplying an encoding argument to - XML_ParserCreate. On success XML_SetEncoding returns non-zero, - zero otherwise. - Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer - has no effect and returns XML_STATUS_ERROR. -*/ -XMLPARSEAPI(enum XML_Status) -XML_SetEncoding(XML_Parser parser, const XML_Char *encoding); - -/* If this function is called, then the parser will be passed as the - first argument to callbacks instead of userData. The userData will - still be accessible using XML_GetUserData. -*/ -XMLPARSEAPI(void) -XML_UseParserAsHandlerArg(XML_Parser parser); - -/* If useDTD == XML_TRUE is passed to this function, then the parser - will assume that there is an external subset, even if none is - specified in the document. In such a case the parser will call the - externalEntityRefHandler with a value of NULL for the systemId - argument (the publicId and context arguments will be NULL as well). - Note: If this function is called, then this must be done before - the first call to XML_Parse or XML_ParseBuffer, since it will - have no effect after that. Returns - XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING. - Note: If the document does not have a DOCTYPE declaration at all, - then startDoctypeDeclHandler and endDoctypeDeclHandler will not - be called, despite an external subset being parsed. - Note: If XML_DTD is not defined when Expat is compiled, returns - XML_ERROR_FEATURE_REQUIRES_XML_DTD. -*/ -XMLPARSEAPI(enum XML_Error) -XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD); - - -/* Sets the base to be used for resolving relative URIs in system - identifiers in declarations. Resolving relative identifiers is - left to the application: this value will be passed through as the - base argument to the XML_ExternalEntityRefHandler, - XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base - argument will be copied. Returns XML_STATUS_ERROR if out of memory, - XML_STATUS_OK otherwise. -*/ -XMLPARSEAPI(enum XML_Status) -XML_SetBase(XML_Parser parser, const XML_Char *base); - -XMLPARSEAPI(const XML_Char *) -XML_GetBase(XML_Parser parser); - -/* Returns the number of the attribute/value pairs passed in last call - to the XML_StartElementHandler that were specified in the start-tag - rather than defaulted. Each attribute/value pair counts as 2; thus - this correspondds to an index into the atts array passed to the - XML_StartElementHandler. -*/ -XMLPARSEAPI(int) -XML_GetSpecifiedAttributeCount(XML_Parser parser); - -/* Returns the index of the ID attribute passed in the last call to - XML_StartElementHandler, or -1 if there is no ID attribute. Each - attribute/value pair counts as 2; thus this correspondds to an - index into the atts array passed to the XML_StartElementHandler. -*/ -XMLPARSEAPI(int) -XML_GetIdAttributeIndex(XML_Parser parser); - -/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is - detected. The last call to XML_Parse must have isFinal true; len - may be zero for this call (or any other). - - Though the return values for these functions has always been - described as a Boolean value, the implementation, at least for the - 1.95.x series, has always returned exactly one of the XML_Status - values. -*/ -XMLPARSEAPI(enum XML_Status) -XML_Parse(XML_Parser parser, const char *s, int len, int isFinal); - -XMLPARSEAPI(void *) -XML_GetBuffer(XML_Parser parser, int len); - -XMLPARSEAPI(enum XML_Status) -XML_ParseBuffer(XML_Parser parser, int len, int isFinal); - -/* Creates an XML_Parser object that can parse an external general - entity; context is a '\0'-terminated string specifying the parse - context; encoding is a '\0'-terminated string giving the name of - the externally specified encoding, or NULL if there is no - externally specified encoding. The context string consists of a - sequence of tokens separated by formfeeds (\f); a token consisting - of a name specifies that the general entity of the name is open; a - token of the form prefix=uri specifies the namespace for a - particular prefix; a token of the form =uri specifies the default - namespace. This can be called at any point after the first call to - an ExternalEntityRefHandler so longer as the parser has not yet - been freed. The new parser is completely independent and may - safely be used in a separate thread. The handlers and userData are - initialized from the parser argument. Returns NULL if out of memory. - Otherwise returns a new XML_Parser object. -*/ -XMLPARSEAPI(XML_Parser) -XML_ExternalEntityParserCreate(XML_Parser parser, - const XML_Char *context, - const XML_Char *encoding); - -enum XML_ParamEntityParsing { - XML_PARAM_ENTITY_PARSING_NEVER, - XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE, - XML_PARAM_ENTITY_PARSING_ALWAYS -}; - -/* Controls parsing of parameter entities (including the external DTD - subset). If parsing of parameter entities is enabled, then - references to external parameter entities (including the external - DTD subset) will be passed to the handler set with - XML_SetExternalEntityRefHandler. The context passed will be 0. - - Unlike external general entities, external parameter entities can - only be parsed synchronously. If the external parameter entity is - to be parsed, it must be parsed during the call to the external - entity ref handler: the complete sequence of - XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and - XML_ParserFree calls must be made during this call. After - XML_ExternalEntityParserCreate has been called to create the parser - for the external parameter entity (context must be 0 for this - call), it is illegal to make any calls on the old parser until - XML_ParserFree has been called on the newly created parser. - If the library has been compiled without support for parameter - entity parsing (ie without XML_DTD being defined), then - XML_SetParamEntityParsing will return 0 if parsing of parameter - entities is requested; otherwise it will return non-zero. - Note: If XML_SetParamEntityParsing is called after XML_Parse or - XML_ParseBuffer, then it has no effect and will always return 0. -*/ -XMLPARSEAPI(int) -XML_SetParamEntityParsing(XML_Parser parser, - enum XML_ParamEntityParsing parsing); - -/* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then - XML_GetErrorCode returns information about the error. -*/ -XMLPARSEAPI(enum XML_Error) -XML_GetErrorCode(XML_Parser parser); - -/* These functions return information about the current parse - location. They may be called from any callback called to report - some parse event; in this case the location is the location of the - first of the sequence of characters that generated the event. When - called from callbacks generated by declarations in the document - prologue, the location identified isn't as neatly defined, but will - be within the relevant markup. When called outside of the callback - functions, the position indicated will be just past the last parse - event (regardless of whether there was an associated callback). - - They may also be called after returning from a call to XML_Parse - or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then - the location is the location of the character at which the error - was detected; otherwise the location is the location of the last - parse event, as described above. -*/ -XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser); -XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser); -XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser); - -/* Return the number of bytes in the current event. - Returns 0 if the event is in an internal entity. -*/ -XMLPARSEAPI(int) -XML_GetCurrentByteCount(XML_Parser parser); - -/* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets - the integer pointed to by offset to the offset within this buffer - of the current parse position, and sets the integer pointed to by size - to the size of this buffer (the number of input bytes). Otherwise - returns a NULL pointer. Also returns a NULL pointer if a parse isn't - active. - - NOTE: The character pointer returned should not be used outside - the handler that makes the call. -*/ -XMLPARSEAPI(const char *) -XML_GetInputContext(XML_Parser parser, - int *offset, - int *size); - -/* For backwards compatibility with previous versions. */ -#define XML_GetErrorLineNumber XML_GetCurrentLineNumber -#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber -#define XML_GetErrorByteIndex XML_GetCurrentByteIndex - -/* Frees the content model passed to the element declaration handler */ -XMLPARSEAPI(void) -XML_FreeContentModel(XML_Parser parser, XML_Content *model); - -/* Exposing the memory handling functions used in Expat */ -XMLPARSEAPI(void *) -XML_MemMalloc(XML_Parser parser, size_t size); - -XMLPARSEAPI(void *) -XML_MemRealloc(XML_Parser parser, void *ptr, size_t size); - -XMLPARSEAPI(void) -XML_MemFree(XML_Parser parser, void *ptr); - -/* Frees memory used by the parser. */ -XMLPARSEAPI(void) -XML_ParserFree(XML_Parser parser); - -/* Returns a string describing the error. */ -XMLPARSEAPI(const XML_LChar *) -XML_ErrorString(enum XML_Error code); - -/* Return a string containing the version number of this expat */ -XMLPARSEAPI(const XML_LChar *) -XML_ExpatVersion(void); - -typedef struct { - int major; - int minor; - int micro; -} XML_Expat_Version; - -/* Return an XML_Expat_Version structure containing numeric version - number information for this version of expat. -*/ -XMLPARSEAPI(XML_Expat_Version) -XML_ExpatVersionInfo(void); - -/* Added in Expat 1.95.5. */ -enum XML_FeatureEnum { - XML_FEATURE_END = 0, - XML_FEATURE_UNICODE, - XML_FEATURE_UNICODE_WCHAR_T, - XML_FEATURE_DTD, - XML_FEATURE_CONTEXT_BYTES, - XML_FEATURE_MIN_SIZE, - XML_FEATURE_SIZEOF_XML_CHAR, - XML_FEATURE_SIZEOF_XML_LCHAR - /* Additional features must be added to the end of this enum. */ -}; - -typedef struct { - enum XML_FeatureEnum feature; - const XML_LChar *name; - long int value; -} XML_Feature; - -XMLPARSEAPI(const XML_Feature *) -XML_GetFeatureList(void); - - -/* Expat follows the GNU/Linux convention of odd number minor version for - beta/development releases and even number minor version for stable - releases. Micro is bumped with each release, and set to 0 with each - change to major or minor version. -*/ -#define XML_MAJOR_VERSION 1 -#define XML_MINOR_VERSION 95 -#define XML_MICRO_VERSION 7 - -#ifdef __cplusplus -} -#endif - -#endif /* not XmlParse_INCLUDED */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/iasciitab.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/iasciitab.h deleted file mode 100644 index 980686f1..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/iasciitab.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */ -/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML, -/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML, -/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM, -/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS, -/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS, -/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL, -/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, -/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, -/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI, -/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST, -/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, -/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, -/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB, -/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT, -/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, -/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, -/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, -/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER, diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/internal.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/internal.h deleted file mode 100644 index 09dbaf46..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/internal.h +++ /dev/null @@ -1,73 +0,0 @@ -/* internal.h - - Internal definitions used by Expat. This is not needed to compile - client code. - - The following calling convention macros are defined for frequently - called functions: - - FASTCALL - Used for those internal functions that have a simple - body and a low number of arguments and local variables. - - PTRCALL - Used for functions called though function pointers. - - PTRFASTCALL - Like PTRCALL, but for low number of arguments. - - inline - Used for selected internal functions for which inlining - may improve performance on some platforms. - - Note: Use of these macros is based on judgement, not hard rules, - and therefore subject to change. -*/ - -#if defined(__GNUC__) && defined(__i386__) -/* We'll use this version by default only where we know it helps. - - regparm() generates warnings on Solaris boxes. See SF bug #692878. - - Instability reported with egcs on a RedHat Linux 7.3. - Let's comment out: - #define FASTCALL __attribute__((stdcall, regparm(3))) - and let's try this: -*/ -#define FASTCALL __attribute__((regparm(3))) -#define PTRFASTCALL __attribute__((regparm(3))) -#endif - -/* Using __fastcall seems to have an unexpected negative effect under - MS VC++, especially for function pointers, so we won't use it for - now on that platform. It may be reconsidered for a future release - if it can be made more effective. - Likely reason: __fastcall on Windows is like stdcall, therefore - the compiler cannot perform stack optimizations for call clusters. -*/ - -/* Make sure all of these are defined if they aren't already. */ - -#ifndef FASTCALL -#define FASTCALL -#endif - -#ifndef PTRCALL -#define PTRCALL -#endif - -#ifndef PTRFASTCALL -#define PTRFASTCALL -#endif - -#ifndef XML_MIN_SIZE -#if !defined(__cplusplus) && !defined(inline) -#ifdef __GNUC__ -#define inline __inline -#endif /* __GNUC__ */ -#endif -#endif /* XML_MIN_SIZE */ - -#ifdef __cplusplus -#define inline inline -#else -#ifndef inline -#define inline -#endif -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/latin1tab.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/latin1tab.h deleted file mode 100644 index 0c5b1ca0..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/latin1tab.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER, -/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME, -/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER, -/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, -/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, -/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, -/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, -/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/macconfig.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/macconfig.h deleted file mode 100644 index 5c44c25b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/macconfig.h +++ /dev/null @@ -1,104 +0,0 @@ -/*================================================================ -** Copyright 2000, Clark Cooper -** All rights reserved. -** -** This is free software. You are permitted to copy, distribute, or modify -** it under the terms of the MIT/X license (contained in the COPYING file -** with this distribution.) -** -*/ - -#ifndef MACCONFIG_H -#define MACCONFIG_H - - -/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */ -#define BYTEORDER 4321 - -/* Define to 1 if you have the `bcopy' function. */ -#undef HAVE_BCOPY - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if you have the `getpagesize' function. */ -#undef HAVE_GETPAGESIZE - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have a working `mmap' system call. */ -#undef HAVE_MMAP - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS - -/* whether byteorder is bigendian */ -#define WORDS_BIGENDIAN - -/* Define to specify how much context to retain around the current parse - point. */ -#undef XML_CONTEXT_BYTES - -/* Define to make parameter entity parsing functionality available. */ -#define XML_DTD - -/* Define to make XML Namespaces functionality available. */ -#define XML_NS - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to `long' if does not define. */ -#define off_t long - -/* Define to `unsigned' if does not define. */ -#undef size_t - - -#endif /* ifndef MACCONFIG_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/nametab.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/nametab.h deleted file mode 100644 index adea34c5..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/nametab.h +++ /dev/null @@ -1,150 +0,0 @@ -static const unsigned namingBitmap[] = { -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE, -0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF, -0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF, -0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, -0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD, -0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, -0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, -0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE, -0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF, -0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000, -0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060, -0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003, -0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003, -0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000, -0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001, -0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003, -0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000, -0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003, -0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003, -0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000, -0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000, -0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF, -0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB, -0x40000000, 0xF580C900, 0x00000007, 0x02010800, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF, -0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF, -0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF, -0x00000000, 0x00004C40, 0x00000000, 0x00000000, -0x00000007, 0x00000000, 0x00000000, 0x00000000, -0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF, -0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF, -0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000, -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000, -0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE, -0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF, -0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, -0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000, -0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003, -0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD, -0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, -0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, -0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE, -0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF, -0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF, -0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF, -0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF, -0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF, -0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0, -0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1, -0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3, -0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80, -0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3, -0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3, -0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000, -0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000, -0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF, -0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x1FFF0000, 0x00000002, -0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF, -0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF, -}; -static const unsigned char nmstrtPages[] = { -0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, -0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, -0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, -0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -static const unsigned char namePages[] = { -0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00, -0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, -0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, -0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/utf8tab.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/utf8tab.h deleted file mode 100644 index 34196013..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/utf8tab.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - - -/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, -/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, -/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, -/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, -/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, -/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, -/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4, -/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, -/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM, diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/winconfig.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/winconfig.h deleted file mode 100644 index 922ba106..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/winconfig.h +++ /dev/null @@ -1,30 +0,0 @@ -/*================================================================ -** Copyright 2000, Clark Cooper -** All rights reserved. -** -** This is free software. You are permitted to copy, distribute, or modify -** it under the terms of the MIT/X license (contained in the COPYING file -** with this distribution.) -*/ - -#ifndef WINCONFIG_H -#define WINCONFIG_H - -#define WIN32_LEAN_AND_MEAN -#include -#undef WIN32_LEAN_AND_MEAN - -#include -#include - -#define XML_NS 1 -#define XML_DTD 1 -#define XML_CONTEXT_BYTES 1024 - -/* we will assume all Windows platforms are little endian */ -#define BYTEORDER 1234 - -/* Windows has memmove() available. */ -#define HAVE_MEMMOVE - -#endif /* ndef WINCONFIG_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlparse.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlparse.c deleted file mode 100644 index 24cb8705..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlparse.c +++ /dev/null @@ -1,5814 +0,0 @@ -/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#include -#include /* memset(), memcpy() */ - -#define XML_BUILDING_EXPAT 1 - -#ifdef COMPILED_FROM_DSP -#include "winconfig.h" -#elif defined(MACOS_CLASSIC) -#include "macconfig.h" -#else -#ifdef HAVE_EXPAT_CONFIG_H -#include -#endif -#endif /* ndef COMPILED_FROM_DSP */ - -#include "expat.h" - -#ifdef XML_UNICODE -#define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX -#define XmlConvert XmlUtf16Convert -#define XmlGetInternalEncoding XmlGetUtf16InternalEncoding -#define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS -#define XmlEncode XmlUtf16Encode -#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((unsigned long)s) & 1)) -typedef unsigned short ICHAR; -#else -#define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX -#define XmlConvert XmlUtf8Convert -#define XmlGetInternalEncoding XmlGetUtf8InternalEncoding -#define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS -#define XmlEncode XmlUtf8Encode -#define MUST_CONVERT(enc, s) (!(enc)->isUtf8) -typedef char ICHAR; -#endif - - -#ifndef XML_NS - -#define XmlInitEncodingNS XmlInitEncoding -#define XmlInitUnknownEncodingNS XmlInitUnknownEncoding -#undef XmlGetInternalEncodingNS -#define XmlGetInternalEncodingNS XmlGetInternalEncoding -#define XmlParseXmlDeclNS XmlParseXmlDecl - -#endif - -#ifdef XML_UNICODE - -#ifdef XML_UNICODE_WCHAR_T -#define XML_T(x) (const wchar_t)x -#define XML_L(x) L ## x -#else -#define XML_T(x) (const unsigned short)x -#define XML_L(x) x -#endif - -#else - -#define XML_T(x) x -#define XML_L(x) x - -#endif - -/* Round up n to be a multiple of sz, where sz is a power of 2. */ -#define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1)) - -/* Handle the case where memmove() doesn't exist. */ -#ifndef HAVE_MEMMOVE -#ifdef HAVE_BCOPY -#define memmove(d,s,l) bcopy((s),(d),(l)) -#else -#error memmove does not exist on this platform, nor is a substitute available -#endif /* HAVE_BCOPY */ -#endif /* HAVE_MEMMOVE */ - -#include "internal.h" -#include "xmltok.h" -#include "xmlrole.h" - -typedef const XML_Char *KEY; - -typedef struct { - KEY name; -} NAMED; - -typedef struct { - NAMED **v; - unsigned char power; - size_t size; - size_t used; - const XML_Memory_Handling_Suite *mem; -} HASH_TABLE; - -/* Basic character hash algorithm, taken from Python's string hash: - h = h * 1000003 ^ character, the constant being a prime number. - -*/ -#ifdef XML_UNICODE -#define CHAR_HASH(h, c) \ - (((h) * 0xF4243) ^ (unsigned short)(c)) -#else -#define CHAR_HASH(h, c) \ - (((h) * 0xF4243) ^ (unsigned char)(c)) -#endif - -/* For probing (after a collision) we need a step size relative prime - to the hash table size, which is a power of 2. We use double-hashing, - since we can calculate a second hash value cheaply by taking those bits - of the first hash value that were discarded (masked out) when the table - index was calculated: index = hash & mask, where mask = table->size - 1. - We limit the maximum step size to table->size / 4 (mask >> 2) and make - it odd, since odd numbers are always relative prime to a power of 2. -*/ -#define SECOND_HASH(hash, mask, power) \ - ((((hash) & ~(mask)) >> ((power) - 1)) & ((mask) >> 2)) -#define PROBE_STEP(hash, mask, power) \ - ((unsigned char)((SECOND_HASH(hash, mask, power)) | 1)) - -typedef struct { - NAMED **p; - NAMED **end; -} HASH_TABLE_ITER; - -#define INIT_TAG_BUF_SIZE 32 /* must be a multiple of sizeof(XML_Char) */ -#define INIT_DATA_BUF_SIZE 1024 -#define INIT_ATTS_SIZE 16 -#define INIT_ATTS_VERSION 0xFFFFFFFF -#define INIT_BLOCK_SIZE 1024 -#define INIT_BUFFER_SIZE 1024 - -#define EXPAND_SPARE 24 - -typedef struct binding { - struct prefix *prefix; - struct binding *nextTagBinding; - struct binding *prevPrefixBinding; - const struct attribute_id *attId; - XML_Char *uri; - int uriLen; - int uriAlloc; -} BINDING; - -typedef struct prefix { - const XML_Char *name; - BINDING *binding; -} PREFIX; - -typedef struct { - const XML_Char *str; - const XML_Char *localPart; - const XML_Char *prefix; - int strLen; - int uriLen; - int prefixLen; -} TAG_NAME; - -/* TAG represents an open element. - The name of the element is stored in both the document and API - encodings. The memory buffer 'buf' is a separately-allocated - memory area which stores the name. During the XML_Parse()/ - XMLParseBuffer() when the element is open, the memory for the 'raw' - version of the name (in the document encoding) is shared with the - document buffer. If the element is open across calls to - XML_Parse()/XML_ParseBuffer(), the buffer is re-allocated to - contain the 'raw' name as well. - - A parser re-uses these structures, maintaining a list of allocated - TAG objects in a free list. -*/ -typedef struct tag { - struct tag *parent; /* parent of this element */ - const char *rawName; /* tagName in the original encoding */ - int rawNameLength; - TAG_NAME name; /* tagName in the API encoding */ - char *buf; /* buffer for name components */ - char *bufEnd; /* end of the buffer */ - BINDING *bindings; -} TAG; - -typedef struct { - const XML_Char *name; - const XML_Char *textPtr; - int textLen; - const XML_Char *systemId; - const XML_Char *base; - const XML_Char *publicId; - const XML_Char *notation; - XML_Bool open; - XML_Bool is_param; - XML_Bool is_internal; /* true if declared in internal subset outside PE */ -} ENTITY; - -typedef struct { - enum XML_Content_Type type; - enum XML_Content_Quant quant; - const XML_Char * name; - int firstchild; - int lastchild; - int childcnt; - int nextsib; -} CONTENT_SCAFFOLD; - -#define INIT_SCAFFOLD_ELEMENTS 32 - -typedef struct block { - struct block *next; - int size; - XML_Char s[1]; -} BLOCK; - -typedef struct { - BLOCK *blocks; - BLOCK *freeBlocks; - const XML_Char *end; - XML_Char *ptr; - XML_Char *start; - const XML_Memory_Handling_Suite *mem; -} STRING_POOL; - -/* The XML_Char before the name is used to determine whether - an attribute has been specified. */ -typedef struct attribute_id { - XML_Char *name; - PREFIX *prefix; - XML_Bool maybeTokenized; - XML_Bool xmlns; -} ATTRIBUTE_ID; - -typedef struct { - const ATTRIBUTE_ID *id; - XML_Bool isCdata; - const XML_Char *value; -} DEFAULT_ATTRIBUTE; - -typedef struct { - unsigned long version; - unsigned long hash; - const XML_Char *uriName; -} NS_ATT; - -typedef struct { - const XML_Char *name; - PREFIX *prefix; - const ATTRIBUTE_ID *idAtt; - int nDefaultAtts; - int allocDefaultAtts; - DEFAULT_ATTRIBUTE *defaultAtts; -} ELEMENT_TYPE; - -typedef struct { - HASH_TABLE generalEntities; - HASH_TABLE elementTypes; - HASH_TABLE attributeIds; - HASH_TABLE prefixes; - STRING_POOL pool; - STRING_POOL entityValuePool; - /* false once a parameter entity reference has been skipped */ - XML_Bool keepProcessing; - /* true once an internal or external PE reference has been encountered; - this includes the reference to an external subset */ - XML_Bool hasParamEntityRefs; - XML_Bool standalone; -#ifdef XML_DTD - /* indicates if external PE has been read */ - XML_Bool paramEntityRead; - HASH_TABLE paramEntities; -#endif /* XML_DTD */ - PREFIX defaultPrefix; - /* === scaffolding for building content model === */ - XML_Bool in_eldecl; - CONTENT_SCAFFOLD *scaffold; - unsigned contentStringLen; - unsigned scaffSize; - unsigned scaffCount; - int scaffLevel; - int *scaffIndex; -} DTD; - -typedef struct open_internal_entity { - const char *internalEventPtr; - const char *internalEventEndPtr; - struct open_internal_entity *next; - ENTITY *entity; -} OPEN_INTERNAL_ENTITY; - -typedef enum XML_Error PTRCALL Processor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr); - -static Processor prologProcessor; -static Processor prologInitProcessor; -static Processor contentProcessor; -static Processor cdataSectionProcessor; -#ifdef XML_DTD -static Processor ignoreSectionProcessor; -static Processor externalParEntProcessor; -static Processor externalParEntInitProcessor; -static Processor entityValueProcessor; -static Processor entityValueInitProcessor; -#endif /* XML_DTD */ -static Processor epilogProcessor; -static Processor errorProcessor; -static Processor externalEntityInitProcessor; -static Processor externalEntityInitProcessor2; -static Processor externalEntityInitProcessor3; -static Processor externalEntityContentProcessor; - -static enum XML_Error -handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName); -static enum XML_Error -processXmlDecl(XML_Parser parser, int isGeneralTextEntity, - const char *, const char *); -static enum XML_Error -initializeEncoding(XML_Parser parser); -static enum XML_Error -doProlog(XML_Parser parser, const ENCODING *enc, const char *s, - const char *end, int tok, const char *next, const char **nextPtr); -static enum XML_Error -processInternalParamEntity(XML_Parser parser, ENTITY *entity); -static enum XML_Error -doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, - const char *start, const char *end, const char **endPtr); -static enum XML_Error -doCdataSection(XML_Parser parser, const ENCODING *, const char **startPtr, - const char *end, const char **nextPtr); -#ifdef XML_DTD -static enum XML_Error -doIgnoreSection(XML_Parser parser, const ENCODING *, const char **startPtr, - const char *end, const char **nextPtr); -#endif /* XML_DTD */ - -static enum XML_Error -storeAtts(XML_Parser parser, const ENCODING *, const char *s, - TAG_NAME *tagNamePtr, BINDING **bindingsPtr); -static enum XML_Error -addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, - const XML_Char *uri, BINDING **bindingsPtr); -static int -defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, - XML_Bool isCdata, XML_Bool isId, const XML_Char *dfltValue, - XML_Parser parser); -static enum XML_Error -storeAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata, - const char *, const char *, STRING_POOL *); -static enum XML_Error -appendAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata, - const char *, const char *, STRING_POOL *); -static ATTRIBUTE_ID * -getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, - const char *end); -static int -setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *); -static enum XML_Error -storeEntityValue(XML_Parser parser, const ENCODING *enc, const char *start, - const char *end); -static int -reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, - const char *start, const char *end); -static int -reportComment(XML_Parser parser, const ENCODING *enc, const char *start, - const char *end); -static void -reportDefault(XML_Parser parser, const ENCODING *enc, const char *start, - const char *end); - -static const XML_Char * getContext(XML_Parser parser); -static XML_Bool -setContext(XML_Parser parser, const XML_Char *context); - -static void FASTCALL normalizePublicId(XML_Char *s); - -static DTD * dtdCreate(const XML_Memory_Handling_Suite *ms); -/* do not call if parentParser != NULL */ -static void dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms); -static void -dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms); -static int -dtdCopy(DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms); -static int -copyEntityTable(HASH_TABLE *, STRING_POOL *, const HASH_TABLE *); - -static NAMED * -lookup(HASH_TABLE *table, KEY name, size_t createSize); -static void FASTCALL -hashTableInit(HASH_TABLE *, const XML_Memory_Handling_Suite *ms); -static void FASTCALL hashTableClear(HASH_TABLE *); -static void FASTCALL hashTableDestroy(HASH_TABLE *); -static void FASTCALL -hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *); -static NAMED * FASTCALL hashTableIterNext(HASH_TABLE_ITER *); - -static void FASTCALL -poolInit(STRING_POOL *, const XML_Memory_Handling_Suite *ms); -static void FASTCALL poolClear(STRING_POOL *); -static void FASTCALL poolDestroy(STRING_POOL *); -static XML_Char * -poolAppend(STRING_POOL *pool, const ENCODING *enc, - const char *ptr, const char *end); -static XML_Char * -poolStoreString(STRING_POOL *pool, const ENCODING *enc, - const char *ptr, const char *end); -static XML_Bool FASTCALL poolGrow(STRING_POOL *pool); -static const XML_Char * FASTCALL -poolCopyString(STRING_POOL *pool, const XML_Char *s); -static const XML_Char * -poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n); -static const XML_Char * FASTCALL -poolAppendString(STRING_POOL *pool, const XML_Char *s); - -static int FASTCALL nextScaffoldPart(XML_Parser parser); -static XML_Content * build_model(XML_Parser parser); -static ELEMENT_TYPE * -getElementType(XML_Parser parser, const ENCODING *enc, - const char *ptr, const char *end); - -static XML_Parser -parserCreate(const XML_Char *encodingName, - const XML_Memory_Handling_Suite *memsuite, - const XML_Char *nameSep, - DTD *dtd); -static void -parserInit(XML_Parser parser, const XML_Char *encodingName); - -#define poolStart(pool) ((pool)->start) -#define poolEnd(pool) ((pool)->ptr) -#define poolLength(pool) ((pool)->ptr - (pool)->start) -#define poolChop(pool) ((void)--(pool->ptr)) -#define poolLastChar(pool) (((pool)->ptr)[-1]) -#define poolDiscard(pool) ((pool)->ptr = (pool)->start) -#define poolFinish(pool) ((pool)->start = (pool)->ptr) -#define poolAppendChar(pool, c) \ - (((pool)->ptr == (pool)->end && !poolGrow(pool)) \ - ? 0 \ - : ((*((pool)->ptr)++ = c), 1)) - -struct XML_ParserStruct { - /* The first member must be userData so that the XML_GetUserData - macro works. */ - void *m_userData; - void *m_handlerArg; - char *m_buffer; - const XML_Memory_Handling_Suite m_mem; - /* first character to be parsed */ - const char *m_bufferPtr; - /* past last character to be parsed */ - char *m_bufferEnd; - /* allocated end of buffer */ - const char *m_bufferLim; - long m_parseEndByteIndex; - const char *m_parseEndPtr; - XML_Char *m_dataBuf; - XML_Char *m_dataBufEnd; - XML_StartElementHandler m_startElementHandler; - XML_EndElementHandler m_endElementHandler; - XML_CharacterDataHandler m_characterDataHandler; - XML_ProcessingInstructionHandler m_processingInstructionHandler; - XML_CommentHandler m_commentHandler; - XML_StartCdataSectionHandler m_startCdataSectionHandler; - XML_EndCdataSectionHandler m_endCdataSectionHandler; - XML_DefaultHandler m_defaultHandler; - XML_StartDoctypeDeclHandler m_startDoctypeDeclHandler; - XML_EndDoctypeDeclHandler m_endDoctypeDeclHandler; - XML_UnparsedEntityDeclHandler m_unparsedEntityDeclHandler; - XML_NotationDeclHandler m_notationDeclHandler; - XML_StartNamespaceDeclHandler m_startNamespaceDeclHandler; - XML_EndNamespaceDeclHandler m_endNamespaceDeclHandler; - XML_NotStandaloneHandler m_notStandaloneHandler; - XML_ExternalEntityRefHandler m_externalEntityRefHandler; - XML_Parser m_externalEntityRefHandlerArg; - XML_SkippedEntityHandler m_skippedEntityHandler; - XML_UnknownEncodingHandler m_unknownEncodingHandler; - XML_ElementDeclHandler m_elementDeclHandler; - XML_AttlistDeclHandler m_attlistDeclHandler; - XML_EntityDeclHandler m_entityDeclHandler; - XML_XmlDeclHandler m_xmlDeclHandler; - const ENCODING *m_encoding; - INIT_ENCODING m_initEncoding; - const ENCODING *m_internalEncoding; - const XML_Char *m_protocolEncodingName; - XML_Bool m_ns; - XML_Bool m_ns_triplets; - void *m_unknownEncodingMem; - void *m_unknownEncodingData; - void *m_unknownEncodingHandlerData; - void (*m_unknownEncodingRelease)(void *); - PROLOG_STATE m_prologState; - Processor *m_processor; - enum XML_Error m_errorCode; - const char *m_eventPtr; - const char *m_eventEndPtr; - const char *m_positionPtr; - OPEN_INTERNAL_ENTITY *m_openInternalEntities; - XML_Bool m_defaultExpandInternalEntities; - int m_tagLevel; - ENTITY *m_declEntity; - const XML_Char *m_doctypeName; - const XML_Char *m_doctypeSysid; - const XML_Char *m_doctypePubid; - const XML_Char *m_declAttributeType; - const XML_Char *m_declNotationName; - const XML_Char *m_declNotationPublicId; - ELEMENT_TYPE *m_declElementType; - ATTRIBUTE_ID *m_declAttributeId; - XML_Bool m_declAttributeIsCdata; - XML_Bool m_declAttributeIsId; - DTD *m_dtd; - const XML_Char *m_curBase; - TAG *m_tagStack; - TAG *m_freeTagList; - BINDING *m_inheritedBindings; - BINDING *m_freeBindingList; - int m_attsSize; - int m_nSpecifiedAtts; - int m_idAttIndex; - ATTRIBUTE *m_atts; - NS_ATT *m_nsAtts; - unsigned long m_nsAttsVersion; - unsigned char m_nsAttsPower; - POSITION m_position; - STRING_POOL m_tempPool; - STRING_POOL m_temp2Pool; - char *m_groupConnector; - unsigned int m_groupSize; - XML_Char m_namespaceSeparator; - XML_Parser m_parentParser; -#ifdef XML_DTD - XML_Bool m_isParamEntity; - XML_Bool m_useForeignDTD; - enum XML_ParamEntityParsing m_paramEntityParsing; -#endif -}; - -#define MALLOC(s) (parser->m_mem.malloc_fcn((s))) -#define REALLOC(p,s) (parser->m_mem.realloc_fcn((p),(s))) -#define FREE(p) (parser->m_mem.free_fcn((p))) - -#define userData (parser->m_userData) -#define handlerArg (parser->m_handlerArg) -#define startElementHandler (parser->m_startElementHandler) -#define endElementHandler (parser->m_endElementHandler) -#define characterDataHandler (parser->m_characterDataHandler) -#define processingInstructionHandler \ - (parser->m_processingInstructionHandler) -#define commentHandler (parser->m_commentHandler) -#define startCdataSectionHandler \ - (parser->m_startCdataSectionHandler) -#define endCdataSectionHandler (parser->m_endCdataSectionHandler) -#define defaultHandler (parser->m_defaultHandler) -#define startDoctypeDeclHandler (parser->m_startDoctypeDeclHandler) -#define endDoctypeDeclHandler (parser->m_endDoctypeDeclHandler) -#define unparsedEntityDeclHandler \ - (parser->m_unparsedEntityDeclHandler) -#define notationDeclHandler (parser->m_notationDeclHandler) -#define startNamespaceDeclHandler \ - (parser->m_startNamespaceDeclHandler) -#define endNamespaceDeclHandler (parser->m_endNamespaceDeclHandler) -#define notStandaloneHandler (parser->m_notStandaloneHandler) -#define externalEntityRefHandler \ - (parser->m_externalEntityRefHandler) -#define externalEntityRefHandlerArg \ - (parser->m_externalEntityRefHandlerArg) -#define internalEntityRefHandler \ - (parser->m_internalEntityRefHandler) -#define skippedEntityHandler (parser->m_skippedEntityHandler) -#define unknownEncodingHandler (parser->m_unknownEncodingHandler) -#define elementDeclHandler (parser->m_elementDeclHandler) -#define attlistDeclHandler (parser->m_attlistDeclHandler) -#define entityDeclHandler (parser->m_entityDeclHandler) -#define xmlDeclHandler (parser->m_xmlDeclHandler) -#define encoding (parser->m_encoding) -#define initEncoding (parser->m_initEncoding) -#define internalEncoding (parser->m_internalEncoding) -#define unknownEncodingMem (parser->m_unknownEncodingMem) -#define unknownEncodingData (parser->m_unknownEncodingData) -#define unknownEncodingHandlerData \ - (parser->m_unknownEncodingHandlerData) -#define unknownEncodingRelease (parser->m_unknownEncodingRelease) -#define protocolEncodingName (parser->m_protocolEncodingName) -#define ns (parser->m_ns) -#define ns_triplets (parser->m_ns_triplets) -#define prologState (parser->m_prologState) -#define processor (parser->m_processor) -#define errorCode (parser->m_errorCode) -#define eventPtr (parser->m_eventPtr) -#define eventEndPtr (parser->m_eventEndPtr) -#define positionPtr (parser->m_positionPtr) -#define position (parser->m_position) -#define openInternalEntities (parser->m_openInternalEntities) -#define defaultExpandInternalEntities \ - (parser->m_defaultExpandInternalEntities) -#define tagLevel (parser->m_tagLevel) -#define buffer (parser->m_buffer) -#define bufferPtr (parser->m_bufferPtr) -#define bufferEnd (parser->m_bufferEnd) -#define parseEndByteIndex (parser->m_parseEndByteIndex) -#define parseEndPtr (parser->m_parseEndPtr) -#define bufferLim (parser->m_bufferLim) -#define dataBuf (parser->m_dataBuf) -#define dataBufEnd (parser->m_dataBufEnd) -#define _dtd (parser->m_dtd) -#define curBase (parser->m_curBase) -#define declEntity (parser->m_declEntity) -#define doctypeName (parser->m_doctypeName) -#define doctypeSysid (parser->m_doctypeSysid) -#define doctypePubid (parser->m_doctypePubid) -#define declAttributeType (parser->m_declAttributeType) -#define declNotationName (parser->m_declNotationName) -#define declNotationPublicId (parser->m_declNotationPublicId) -#define declElementType (parser->m_declElementType) -#define declAttributeId (parser->m_declAttributeId) -#define declAttributeIsCdata (parser->m_declAttributeIsCdata) -#define declAttributeIsId (parser->m_declAttributeIsId) -#define freeTagList (parser->m_freeTagList) -#define freeBindingList (parser->m_freeBindingList) -#define inheritedBindings (parser->m_inheritedBindings) -#define tagStack (parser->m_tagStack) -#define atts (parser->m_atts) -#define attsSize (parser->m_attsSize) -#define nSpecifiedAtts (parser->m_nSpecifiedAtts) -#define idAttIndex (parser->m_idAttIndex) -#define nsAtts (parser->m_nsAtts) -#define nsAttsVersion (parser->m_nsAttsVersion) -#define nsAttsPower (parser->m_nsAttsPower) -#define tempPool (parser->m_tempPool) -#define temp2Pool (parser->m_temp2Pool) -#define groupConnector (parser->m_groupConnector) -#define groupSize (parser->m_groupSize) -#define namespaceSeparator (parser->m_namespaceSeparator) -#define parentParser (parser->m_parentParser) -#ifdef XML_DTD -#define isParamEntity (parser->m_isParamEntity) -#define useForeignDTD (parser->m_useForeignDTD) -#define paramEntityParsing (parser->m_paramEntityParsing) -#endif /* XML_DTD */ - -#ifdef XML_DTD -#define parsing \ - (parentParser \ - ? \ - (isParamEntity \ - ? \ - (processor != externalParEntInitProcessor) \ - : \ - (processor != externalEntityInitProcessor)) \ - : \ - (processor != prologInitProcessor)) -#else -#define parsing \ - (parentParser \ - ? \ - (processor != externalEntityInitProcessor) \ - : \ - (processor != prologInitProcessor)) -#endif /* XML_DTD */ - -XML_Parser XMLCALL -XML_ParserCreate(const XML_Char *encodingName) -{ - return XML_ParserCreate_MM(encodingName, NULL, NULL); -} - -XML_Parser XMLCALL -XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) -{ - XML_Char tmp[2]; - *tmp = nsSep; - return XML_ParserCreate_MM(encodingName, NULL, tmp); -} - -static const XML_Char implicitContext[] = { - 'x', 'm', 'l', '=', 'h', 't', 't', 'p', ':', '/', '/', - 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', - 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', - 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' -}; - -XML_Parser XMLCALL -XML_ParserCreate_MM(const XML_Char *encodingName, - const XML_Memory_Handling_Suite *memsuite, - const XML_Char *nameSep) -{ - XML_Parser parser = parserCreate(encodingName, memsuite, nameSep, NULL); - if (parser != NULL && ns) { - /* implicit context only set for root parser, since child - parsers (i.e. external entity parsers) will inherit it - */ - if (!setContext(parser, implicitContext)) { - XML_ParserFree(parser); - return NULL; - } - } - return parser; -} - -static XML_Parser -parserCreate(const XML_Char *encodingName, - const XML_Memory_Handling_Suite *memsuite, - const XML_Char *nameSep, - DTD *dtd) -{ - XML_Parser parser; - - if (memsuite) { - XML_Memory_Handling_Suite *mtemp; - parser = (XML_Parser) - memsuite->malloc_fcn(sizeof(struct XML_ParserStruct)); - if (parser != NULL) { - mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem); - mtemp->malloc_fcn = memsuite->malloc_fcn; - mtemp->realloc_fcn = memsuite->realloc_fcn; - mtemp->free_fcn = memsuite->free_fcn; - } - } - else { - XML_Memory_Handling_Suite *mtemp; - parser = (XML_Parser)malloc(sizeof(struct XML_ParserStruct)); - if (parser != NULL) { - mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem); - mtemp->malloc_fcn = malloc; - mtemp->realloc_fcn = realloc; - mtemp->free_fcn = free; - } - } - - if (!parser) - return parser; - - buffer = NULL; - bufferLim = NULL; - - attsSize = INIT_ATTS_SIZE; - atts = (ATTRIBUTE *)MALLOC(attsSize * sizeof(ATTRIBUTE)); - if (atts == NULL) { - FREE(parser); - return NULL; - } - dataBuf = (XML_Char *)MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char)); - if (dataBuf == NULL) { - FREE(atts); - FREE(parser); - return NULL; - } - dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE; - - if (dtd) - _dtd = dtd; - else { - _dtd = dtdCreate(&parser->m_mem); - if (_dtd == NULL) { - FREE(dataBuf); - FREE(atts); - FREE(parser); - return NULL; - } - } - - freeBindingList = NULL; - freeTagList = NULL; - - groupSize = 0; - groupConnector = NULL; - - unknownEncodingHandler = NULL; - unknownEncodingHandlerData = NULL; - - namespaceSeparator = '!'; - ns = XML_FALSE; - ns_triplets = XML_FALSE; - - nsAtts = NULL; - nsAttsVersion = 0; - nsAttsPower = 0; - - poolInit(&tempPool, &(parser->m_mem)); - poolInit(&temp2Pool, &(parser->m_mem)); - parserInit(parser, encodingName); - - if (encodingName && !protocolEncodingName) { - XML_ParserFree(parser); - return NULL; - } - - if (nameSep) { - ns = XML_TRUE; - internalEncoding = XmlGetInternalEncodingNS(); - namespaceSeparator = *nameSep; - } - else { - internalEncoding = XmlGetInternalEncoding(); - } - - return parser; -} - -static void -parserInit(XML_Parser parser, const XML_Char *encodingName) -{ - processor = prologInitProcessor; - XmlPrologStateInit(&prologState); - protocolEncodingName = (encodingName != NULL - ? poolCopyString(&tempPool, encodingName) - : NULL); - curBase = NULL; - XmlInitEncoding(&initEncoding, &encoding, 0); - userData = NULL; - handlerArg = NULL; - startElementHandler = NULL; - endElementHandler = NULL; - characterDataHandler = NULL; - processingInstructionHandler = NULL; - commentHandler = NULL; - startCdataSectionHandler = NULL; - endCdataSectionHandler = NULL; - defaultHandler = NULL; - startDoctypeDeclHandler = NULL; - endDoctypeDeclHandler = NULL; - unparsedEntityDeclHandler = NULL; - notationDeclHandler = NULL; - startNamespaceDeclHandler = NULL; - endNamespaceDeclHandler = NULL; - notStandaloneHandler = NULL; - externalEntityRefHandler = NULL; - externalEntityRefHandlerArg = parser; - skippedEntityHandler = NULL; - elementDeclHandler = NULL; - attlistDeclHandler = NULL; - entityDeclHandler = NULL; - xmlDeclHandler = NULL; - bufferPtr = buffer; - bufferEnd = buffer; - parseEndByteIndex = 0; - parseEndPtr = NULL; - declElementType = NULL; - declAttributeId = NULL; - declEntity = NULL; - doctypeName = NULL; - doctypeSysid = NULL; - doctypePubid = NULL; - declAttributeType = NULL; - declNotationName = NULL; - declNotationPublicId = NULL; - declAttributeIsCdata = XML_FALSE; - declAttributeIsId = XML_FALSE; - memset(&position, 0, sizeof(POSITION)); - errorCode = XML_ERROR_NONE; - eventPtr = NULL; - eventEndPtr = NULL; - positionPtr = NULL; - openInternalEntities = 0; - defaultExpandInternalEntities = XML_TRUE; - tagLevel = 0; - tagStack = NULL; - inheritedBindings = NULL; - nSpecifiedAtts = 0; - unknownEncodingMem = NULL; - unknownEncodingRelease = NULL; - unknownEncodingData = NULL; - parentParser = NULL; -#ifdef XML_DTD - isParamEntity = XML_FALSE; - useForeignDTD = XML_FALSE; - paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; -#endif -} - -/* moves list of bindings to freeBindingList */ -static void FASTCALL -moveToFreeBindingList(XML_Parser parser, BINDING *bindings) -{ - while (bindings) { - BINDING *b = bindings; - bindings = bindings->nextTagBinding; - b->nextTagBinding = freeBindingList; - freeBindingList = b; - } -} - -XML_Bool XMLCALL -XML_ParserReset(XML_Parser parser, const XML_Char *encodingName) -{ - TAG *tStk; - if (parentParser) - return XML_FALSE; - /* move tagStack to freeTagList */ - tStk = tagStack; - while (tStk) { - TAG *tag = tStk; - tStk = tStk->parent; - tag->parent = freeTagList; - moveToFreeBindingList(parser, tag->bindings); - tag->bindings = NULL; - freeTagList = tag; - } - moveToFreeBindingList(parser, inheritedBindings); - FREE(unknownEncodingMem); - if (unknownEncodingRelease) - unknownEncodingRelease(unknownEncodingData); - poolClear(&tempPool); - poolClear(&temp2Pool); - parserInit(parser, encodingName); - dtdReset(_dtd, &parser->m_mem); - return setContext(parser, implicitContext); -} - -enum XML_Status XMLCALL -XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName) -{ - /* Block after XML_Parse()/XML_ParseBuffer() has been called. - XXX There's no way for the caller to determine which of the - XXX possible error cases caused the XML_STATUS_ERROR return. - */ - if (parsing) - return XML_STATUS_ERROR; - if (encodingName == NULL) - protocolEncodingName = NULL; - else { - protocolEncodingName = poolCopyString(&tempPool, encodingName); - if (!protocolEncodingName) - return XML_STATUS_ERROR; - } - return XML_STATUS_OK; -} - -XML_Parser XMLCALL -XML_ExternalEntityParserCreate(XML_Parser oldParser, - const XML_Char *context, - const XML_Char *encodingName) -{ - XML_Parser parser = oldParser; - DTD *newDtd = NULL; - DTD *oldDtd = _dtd; - XML_StartElementHandler oldStartElementHandler = startElementHandler; - XML_EndElementHandler oldEndElementHandler = endElementHandler; - XML_CharacterDataHandler oldCharacterDataHandler = characterDataHandler; - XML_ProcessingInstructionHandler oldProcessingInstructionHandler - = processingInstructionHandler; - XML_CommentHandler oldCommentHandler = commentHandler; - XML_StartCdataSectionHandler oldStartCdataSectionHandler - = startCdataSectionHandler; - XML_EndCdataSectionHandler oldEndCdataSectionHandler - = endCdataSectionHandler; - XML_DefaultHandler oldDefaultHandler = defaultHandler; - XML_UnparsedEntityDeclHandler oldUnparsedEntityDeclHandler - = unparsedEntityDeclHandler; - XML_NotationDeclHandler oldNotationDeclHandler = notationDeclHandler; - XML_StartNamespaceDeclHandler oldStartNamespaceDeclHandler - = startNamespaceDeclHandler; - XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler - = endNamespaceDeclHandler; - XML_NotStandaloneHandler oldNotStandaloneHandler = notStandaloneHandler; - XML_ExternalEntityRefHandler oldExternalEntityRefHandler - = externalEntityRefHandler; - XML_SkippedEntityHandler oldSkippedEntityHandler = skippedEntityHandler; - XML_UnknownEncodingHandler oldUnknownEncodingHandler - = unknownEncodingHandler; - XML_ElementDeclHandler oldElementDeclHandler = elementDeclHandler; - XML_AttlistDeclHandler oldAttlistDeclHandler = attlistDeclHandler; - XML_EntityDeclHandler oldEntityDeclHandler = entityDeclHandler; - XML_XmlDeclHandler oldXmlDeclHandler = xmlDeclHandler; - ELEMENT_TYPE * oldDeclElementType = declElementType; - - void *oldUserData = userData; - void *oldHandlerArg = handlerArg; - XML_Bool oldDefaultExpandInternalEntities = defaultExpandInternalEntities; - XML_Parser oldExternalEntityRefHandlerArg = externalEntityRefHandlerArg; -#ifdef XML_DTD - enum XML_ParamEntityParsing oldParamEntityParsing = paramEntityParsing; - int oldInEntityValue = prologState.inEntityValue; -#endif - XML_Bool oldns_triplets = ns_triplets; - -#ifdef XML_DTD - if (!context) - newDtd = oldDtd; -#endif /* XML_DTD */ - - /* Note that the magical uses of the pre-processor to make field - access look more like C++ require that `parser' be overwritten - here. This makes this function more painful to follow than it - would be otherwise. - */ - if (ns) { - XML_Char tmp[2]; - *tmp = namespaceSeparator; - parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd); - } - else { - parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd); - } - - if (!parser) - return NULL; - - startElementHandler = oldStartElementHandler; - endElementHandler = oldEndElementHandler; - characterDataHandler = oldCharacterDataHandler; - processingInstructionHandler = oldProcessingInstructionHandler; - commentHandler = oldCommentHandler; - startCdataSectionHandler = oldStartCdataSectionHandler; - endCdataSectionHandler = oldEndCdataSectionHandler; - defaultHandler = oldDefaultHandler; - unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler; - notationDeclHandler = oldNotationDeclHandler; - startNamespaceDeclHandler = oldStartNamespaceDeclHandler; - endNamespaceDeclHandler = oldEndNamespaceDeclHandler; - notStandaloneHandler = oldNotStandaloneHandler; - externalEntityRefHandler = oldExternalEntityRefHandler; - skippedEntityHandler = oldSkippedEntityHandler; - unknownEncodingHandler = oldUnknownEncodingHandler; - elementDeclHandler = oldElementDeclHandler; - attlistDeclHandler = oldAttlistDeclHandler; - entityDeclHandler = oldEntityDeclHandler; - xmlDeclHandler = oldXmlDeclHandler; - declElementType = oldDeclElementType; - userData = oldUserData; - if (oldUserData == oldHandlerArg) - handlerArg = userData; - else - handlerArg = parser; - if (oldExternalEntityRefHandlerArg != oldParser) - externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg; - defaultExpandInternalEntities = oldDefaultExpandInternalEntities; - ns_triplets = oldns_triplets; - parentParser = oldParser; -#ifdef XML_DTD - paramEntityParsing = oldParamEntityParsing; - prologState.inEntityValue = oldInEntityValue; - if (context) { -#endif /* XML_DTD */ - if (!dtdCopy(_dtd, oldDtd, &parser->m_mem) - || !setContext(parser, context)) { - XML_ParserFree(parser); - return NULL; - } - processor = externalEntityInitProcessor; -#ifdef XML_DTD - } - else { - /* The DTD instance referenced by _dtd is shared between the document's - root parser and external PE parsers, therefore one does not need to - call setContext. In addition, one also *must* not call setContext, - because this would overwrite existing prefix->binding pointers in - _dtd with ones that get destroyed with the external PE parser. - This would leave those prefixes with dangling pointers. - */ - isParamEntity = XML_TRUE; - XmlPrologStateInitExternalEntity(&prologState); - processor = externalParEntInitProcessor; - } -#endif /* XML_DTD */ - return parser; -} - -static void FASTCALL -destroyBindings(BINDING *bindings, XML_Parser parser) -{ - for (;;) { - BINDING *b = bindings; - if (!b) - break; - bindings = b->nextTagBinding; - FREE(b->uri); - FREE(b); - } -} - -void XMLCALL -XML_ParserFree(XML_Parser parser) -{ - for (;;) { - TAG *p; - if (tagStack == NULL) { - if (freeTagList == NULL) - break; - tagStack = freeTagList; - freeTagList = NULL; - } - p = tagStack; - tagStack = tagStack->parent; - FREE(p->buf); - destroyBindings(p->bindings, parser); - FREE(p); - } - destroyBindings(freeBindingList, parser); - destroyBindings(inheritedBindings, parser); - poolDestroy(&tempPool); - poolDestroy(&temp2Pool); -#ifdef XML_DTD - /* external parameter entity parsers share the DTD structure - parser->m_dtd with the root parser, so we must not destroy it - */ - if (!isParamEntity && _dtd) -#else - if (_dtd) -#endif /* XML_DTD */ - dtdDestroy(_dtd, (XML_Bool)!parentParser, &parser->m_mem); - FREE((void *)atts); - FREE(groupConnector); - FREE(buffer); - FREE(dataBuf); - FREE(nsAtts); - FREE(unknownEncodingMem); - if (unknownEncodingRelease) - unknownEncodingRelease(unknownEncodingData); - FREE(parser); -} - -void XMLCALL -XML_UseParserAsHandlerArg(XML_Parser parser) -{ - handlerArg = parser; -} - -enum XML_Error XMLCALL -XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD) -{ -#ifdef XML_DTD - /* block after XML_Parse()/XML_ParseBuffer() has been called */ - if (parsing) - return XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING; - useForeignDTD = useDTD; - return XML_ERROR_NONE; -#else - return XML_ERROR_FEATURE_REQUIRES_XML_DTD; -#endif -} - -void XMLCALL -XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) -{ - /* block after XML_Parse()/XML_ParseBuffer() has been called */ - if (parsing) - return; - ns_triplets = do_nst ? XML_TRUE : XML_FALSE; -} - -void XMLCALL -XML_SetUserData(XML_Parser parser, void *p) -{ - if (handlerArg == userData) - handlerArg = userData = p; - else - userData = p; -} - -enum XML_Status XMLCALL -XML_SetBase(XML_Parser parser, const XML_Char *p) -{ - if (p) { - p = poolCopyString(&_dtd->pool, p); - if (!p) - return XML_STATUS_ERROR; - curBase = p; - } - else - curBase = NULL; - return XML_STATUS_OK; -} - -const XML_Char * XMLCALL -XML_GetBase(XML_Parser parser) -{ - return curBase; -} - -int XMLCALL -XML_GetSpecifiedAttributeCount(XML_Parser parser) -{ - return nSpecifiedAtts; -} - -int XMLCALL -XML_GetIdAttributeIndex(XML_Parser parser) -{ - return idAttIndex; -} - -void XMLCALL -XML_SetElementHandler(XML_Parser parser, - XML_StartElementHandler start, - XML_EndElementHandler end) -{ - startElementHandler = start; - endElementHandler = end; -} - -void XMLCALL -XML_SetStartElementHandler(XML_Parser parser, - XML_StartElementHandler start) { - startElementHandler = start; -} - -void XMLCALL -XML_SetEndElementHandler(XML_Parser parser, - XML_EndElementHandler end) { - endElementHandler = end; -} - -void XMLCALL -XML_SetCharacterDataHandler(XML_Parser parser, - XML_CharacterDataHandler handler) -{ - characterDataHandler = handler; -} - -void XMLCALL -XML_SetProcessingInstructionHandler(XML_Parser parser, - XML_ProcessingInstructionHandler handler) -{ - processingInstructionHandler = handler; -} - -void XMLCALL -XML_SetCommentHandler(XML_Parser parser, - XML_CommentHandler handler) -{ - commentHandler = handler; -} - -void XMLCALL -XML_SetCdataSectionHandler(XML_Parser parser, - XML_StartCdataSectionHandler start, - XML_EndCdataSectionHandler end) -{ - startCdataSectionHandler = start; - endCdataSectionHandler = end; -} - -void XMLCALL -XML_SetStartCdataSectionHandler(XML_Parser parser, - XML_StartCdataSectionHandler start) { - startCdataSectionHandler = start; -} - -void XMLCALL -XML_SetEndCdataSectionHandler(XML_Parser parser, - XML_EndCdataSectionHandler end) { - endCdataSectionHandler = end; -} - -void XMLCALL -XML_SetDefaultHandler(XML_Parser parser, - XML_DefaultHandler handler) -{ - defaultHandler = handler; - defaultExpandInternalEntities = XML_FALSE; -} - -void XMLCALL -XML_SetDefaultHandlerExpand(XML_Parser parser, - XML_DefaultHandler handler) -{ - defaultHandler = handler; - defaultExpandInternalEntities = XML_TRUE; -} - -void XMLCALL -XML_SetDoctypeDeclHandler(XML_Parser parser, - XML_StartDoctypeDeclHandler start, - XML_EndDoctypeDeclHandler end) -{ - startDoctypeDeclHandler = start; - endDoctypeDeclHandler = end; -} - -void XMLCALL -XML_SetStartDoctypeDeclHandler(XML_Parser parser, - XML_StartDoctypeDeclHandler start) { - startDoctypeDeclHandler = start; -} - -void XMLCALL -XML_SetEndDoctypeDeclHandler(XML_Parser parser, - XML_EndDoctypeDeclHandler end) { - endDoctypeDeclHandler = end; -} - -void XMLCALL -XML_SetUnparsedEntityDeclHandler(XML_Parser parser, - XML_UnparsedEntityDeclHandler handler) -{ - unparsedEntityDeclHandler = handler; -} - -void XMLCALL -XML_SetNotationDeclHandler(XML_Parser parser, - XML_NotationDeclHandler handler) -{ - notationDeclHandler = handler; -} - -void XMLCALL -XML_SetNamespaceDeclHandler(XML_Parser parser, - XML_StartNamespaceDeclHandler start, - XML_EndNamespaceDeclHandler end) -{ - startNamespaceDeclHandler = start; - endNamespaceDeclHandler = end; -} - -void XMLCALL -XML_SetStartNamespaceDeclHandler(XML_Parser parser, - XML_StartNamespaceDeclHandler start) { - startNamespaceDeclHandler = start; -} - -void XMLCALL -XML_SetEndNamespaceDeclHandler(XML_Parser parser, - XML_EndNamespaceDeclHandler end) { - endNamespaceDeclHandler = end; -} - -void XMLCALL -XML_SetNotStandaloneHandler(XML_Parser parser, - XML_NotStandaloneHandler handler) -{ - notStandaloneHandler = handler; -} - -void XMLCALL -XML_SetExternalEntityRefHandler(XML_Parser parser, - XML_ExternalEntityRefHandler handler) -{ - externalEntityRefHandler = handler; -} - -void XMLCALL -XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg) -{ - if (arg) - externalEntityRefHandlerArg = (XML_Parser)arg; - else - externalEntityRefHandlerArg = parser; -} - -void XMLCALL -XML_SetSkippedEntityHandler(XML_Parser parser, - XML_SkippedEntityHandler handler) -{ - skippedEntityHandler = handler; -} - -void XMLCALL -XML_SetUnknownEncodingHandler(XML_Parser parser, - XML_UnknownEncodingHandler handler, - void *data) -{ - unknownEncodingHandler = handler; - unknownEncodingHandlerData = data; -} - -void XMLCALL -XML_SetElementDeclHandler(XML_Parser parser, - XML_ElementDeclHandler eldecl) -{ - elementDeclHandler = eldecl; -} - -void XMLCALL -XML_SetAttlistDeclHandler(XML_Parser parser, - XML_AttlistDeclHandler attdecl) -{ - attlistDeclHandler = attdecl; -} - -void XMLCALL -XML_SetEntityDeclHandler(XML_Parser parser, - XML_EntityDeclHandler handler) -{ - entityDeclHandler = handler; -} - -void XMLCALL -XML_SetXmlDeclHandler(XML_Parser parser, - XML_XmlDeclHandler handler) { - xmlDeclHandler = handler; -} - -int XMLCALL -XML_SetParamEntityParsing(XML_Parser parser, - enum XML_ParamEntityParsing peParsing) -{ - /* block after XML_Parse()/XML_ParseBuffer() has been called */ - if (parsing) - return 0; -#ifdef XML_DTD - paramEntityParsing = peParsing; - return 1; -#else - return peParsing == XML_PARAM_ENTITY_PARSING_NEVER; -#endif -} - -enum XML_Status XMLCALL -XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) -{ - if (len == 0) { - if (!isFinal) - return XML_STATUS_OK; - positionPtr = bufferPtr; - errorCode = processor(parser, bufferPtr, parseEndPtr = bufferEnd, 0); - if (errorCode == XML_ERROR_NONE) - return XML_STATUS_OK; - eventEndPtr = eventPtr; - processor = errorProcessor; - return XML_STATUS_ERROR; - } -#ifndef XML_CONTEXT_BYTES - else if (bufferPtr == bufferEnd) { - const char *end; - int nLeftOver; - parseEndByteIndex += len; - positionPtr = s; - if (isFinal) { - errorCode = processor(parser, s, parseEndPtr = s + len, 0); - if (errorCode == XML_ERROR_NONE) - return XML_STATUS_OK; - eventEndPtr = eventPtr; - processor = errorProcessor; - return XML_STATUS_ERROR; - } - errorCode = processor(parser, s, parseEndPtr = s + len, &end); - if (errorCode != XML_ERROR_NONE) { - eventEndPtr = eventPtr; - processor = errorProcessor; - return XML_STATUS_ERROR; - } - XmlUpdatePosition(encoding, positionPtr, end, &position); - positionPtr = end; - nLeftOver = s + len - end; - if (nLeftOver) { - if (buffer == NULL || nLeftOver > bufferLim - buffer) { - /* FIXME avoid integer overflow */ - char *temp; - temp = (buffer == NULL - ? (char *)MALLOC(len * 2) - : (char *)REALLOC(buffer, len * 2)); - if (temp == NULL) { - errorCode = XML_ERROR_NO_MEMORY; - return XML_STATUS_ERROR; - } - buffer = temp; - if (!buffer) { - errorCode = XML_ERROR_NO_MEMORY; - eventPtr = eventEndPtr = NULL; - processor = errorProcessor; - return XML_STATUS_ERROR; - } - bufferLim = buffer + len * 2; - } - memcpy(buffer, end, nLeftOver); - bufferPtr = buffer; - bufferEnd = buffer + nLeftOver; - } - return XML_STATUS_OK; - } -#endif /* not defined XML_CONTEXT_BYTES */ - else { - void *buff = XML_GetBuffer(parser, len); - if (buff == NULL) - return XML_STATUS_ERROR; - else { - memcpy(buff, s, len); - return XML_ParseBuffer(parser, len, isFinal); - } - } -} - -enum XML_Status XMLCALL -XML_ParseBuffer(XML_Parser parser, int len, int isFinal) -{ - const char *start = bufferPtr; - positionPtr = start; - bufferEnd += len; - parseEndByteIndex += len; - errorCode = processor(parser, start, parseEndPtr = bufferEnd, - isFinal ? (const char **)NULL : &bufferPtr); - if (errorCode == XML_ERROR_NONE) { - if (!isFinal) { - XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); - positionPtr = bufferPtr; - } - return XML_STATUS_OK; - } - else { - eventEndPtr = eventPtr; - processor = errorProcessor; - return XML_STATUS_ERROR; - } -} - -void * XMLCALL -XML_GetBuffer(XML_Parser parser, int len) -{ - if (len > bufferLim - bufferEnd) { - /* FIXME avoid integer overflow */ - int neededSize = len + (bufferEnd - bufferPtr); -#ifdef XML_CONTEXT_BYTES - int keep = bufferPtr - buffer; - - if (keep > XML_CONTEXT_BYTES) - keep = XML_CONTEXT_BYTES; - neededSize += keep; -#endif /* defined XML_CONTEXT_BYTES */ - if (neededSize <= bufferLim - buffer) { -#ifdef XML_CONTEXT_BYTES - if (keep < bufferPtr - buffer) { - int offset = (bufferPtr - buffer) - keep; - memmove(buffer, &buffer[offset], bufferEnd - bufferPtr + keep); - bufferEnd -= offset; - bufferPtr -= offset; - } -#else - memmove(buffer, bufferPtr, bufferEnd - bufferPtr); - bufferEnd = buffer + (bufferEnd - bufferPtr); - bufferPtr = buffer; -#endif /* not defined XML_CONTEXT_BYTES */ - } - else { - char *newBuf; - int bufferSize = bufferLim - bufferPtr; - if (bufferSize == 0) - bufferSize = INIT_BUFFER_SIZE; - do { - bufferSize *= 2; - } while (bufferSize < neededSize); - newBuf = (char *)MALLOC(bufferSize); - if (newBuf == 0) { - errorCode = XML_ERROR_NO_MEMORY; - return NULL; - } - bufferLim = newBuf + bufferSize; -#ifdef XML_CONTEXT_BYTES - if (bufferPtr) { - int keep = bufferPtr - buffer; - if (keep > XML_CONTEXT_BYTES) - keep = XML_CONTEXT_BYTES; - memcpy(newBuf, &bufferPtr[-keep], bufferEnd - bufferPtr + keep); - FREE(buffer); - buffer = newBuf; - bufferEnd = buffer + (bufferEnd - bufferPtr) + keep; - bufferPtr = buffer + keep; - } - else { - bufferEnd = newBuf + (bufferEnd - bufferPtr); - bufferPtr = buffer = newBuf; - } -#else - if (bufferPtr) { - memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr); - FREE(buffer); - } - bufferEnd = newBuf + (bufferEnd - bufferPtr); - bufferPtr = buffer = newBuf; -#endif /* not defined XML_CONTEXT_BYTES */ - } - } - return bufferEnd; -} - -enum XML_Error XMLCALL -XML_GetErrorCode(XML_Parser parser) -{ - return errorCode; -} - -long XMLCALL -XML_GetCurrentByteIndex(XML_Parser parser) -{ - if (eventPtr) - return parseEndByteIndex - (parseEndPtr - eventPtr); - return -1; -} - -int XMLCALL -XML_GetCurrentByteCount(XML_Parser parser) -{ - if (eventEndPtr && eventPtr) - return eventEndPtr - eventPtr; - return 0; -} - -const char * XMLCALL -XML_GetInputContext(XML_Parser parser, int *offset, int *size) -{ -#ifdef XML_CONTEXT_BYTES - if (eventPtr && buffer) { - *offset = eventPtr - buffer; - *size = bufferEnd - buffer; - return buffer; - } -#endif /* defined XML_CONTEXT_BYTES */ - return (char *) 0; -} - -int XMLCALL -XML_GetCurrentLineNumber(XML_Parser parser) -{ - if (eventPtr) { - XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); - positionPtr = eventPtr; - } - return position.lineNumber + 1; -} - -int XMLCALL -XML_GetCurrentColumnNumber(XML_Parser parser) -{ - if (eventPtr) { - XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); - positionPtr = eventPtr; - } - return position.columnNumber; -} - -void XMLCALL -XML_FreeContentModel(XML_Parser parser, XML_Content *model) -{ - FREE(model); -} - -void * XMLCALL -XML_MemMalloc(XML_Parser parser, size_t size) -{ - return MALLOC(size); -} - -void * XMLCALL -XML_MemRealloc(XML_Parser parser, void *ptr, size_t size) -{ - return REALLOC(ptr, size); -} - -void XMLCALL -XML_MemFree(XML_Parser parser, void *ptr) -{ - FREE(ptr); -} - -void XMLCALL -XML_DefaultCurrent(XML_Parser parser) -{ - if (defaultHandler) { - if (openInternalEntities) - reportDefault(parser, - internalEncoding, - openInternalEntities->internalEventPtr, - openInternalEntities->internalEventEndPtr); - else - reportDefault(parser, encoding, eventPtr, eventEndPtr); - } -} - -const XML_LChar * XMLCALL -XML_ErrorString(enum XML_Error code) -{ - static const XML_LChar *message[] = { - 0, - XML_L("out of memory"), - XML_L("syntax error"), - XML_L("no element found"), - XML_L("not well-formed (invalid token)"), - XML_L("unclosed token"), - XML_L("partial character"), - XML_L("mismatched tag"), - XML_L("duplicate attribute"), - XML_L("junk after document element"), - XML_L("illegal parameter entity reference"), - XML_L("undefined entity"), - XML_L("recursive entity reference"), - XML_L("asynchronous entity"), - XML_L("reference to invalid character number"), - XML_L("reference to binary entity"), - XML_L("reference to external entity in attribute"), - XML_L("xml declaration not at start of external entity"), - XML_L("unknown encoding"), - XML_L("encoding specified in XML declaration is incorrect"), - XML_L("unclosed CDATA section"), - XML_L("error in processing external entity reference"), - XML_L("document is not standalone"), - XML_L("unexpected parser state - please send a bug report"), - XML_L("entity declared in parameter entity"), - XML_L("requested feature requires XML_DTD support in Expat"), - XML_L("cannot change setting once parsing has begun"), - XML_L("unbound prefix") - }; - if (code > 0 && code < sizeof(message)/sizeof(message[0])) - return message[code]; - return NULL; -} - -const XML_LChar * XMLCALL -XML_ExpatVersion(void) { - - /* V1 is used to string-ize the version number. However, it would - string-ize the actual version macro *names* unless we get them - substituted before being passed to V1. CPP is defined to expand - a macro, then rescan for more expansions. Thus, we use V2 to expand - the version macros, then CPP will expand the resulting V1() macro - with the correct numerals. */ - /* ### I'm assuming cpp is portable in this respect... */ - -#define V1(a,b,c) XML_L(#a)XML_L(".")XML_L(#b)XML_L(".")XML_L(#c) -#define V2(a,b,c) XML_L("expat_")V1(a,b,c) - - return V2(XML_MAJOR_VERSION, XML_MINOR_VERSION, XML_MICRO_VERSION); - -#undef V1 -#undef V2 -} - -XML_Expat_Version XMLCALL -XML_ExpatVersionInfo(void) -{ - XML_Expat_Version version; - - version.major = XML_MAJOR_VERSION; - version.minor = XML_MINOR_VERSION; - version.micro = XML_MICRO_VERSION; - - return version; -} - -const XML_Feature * XMLCALL -XML_GetFeatureList(void) -{ - static XML_Feature features[] = { - {XML_FEATURE_SIZEOF_XML_CHAR, XML_L("sizeof(XML_Char)"), 0}, - {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)"), 0}, -#ifdef XML_UNICODE - {XML_FEATURE_UNICODE, XML_L("XML_UNICODE"), 0}, -#endif -#ifdef XML_UNICODE_WCHAR_T - {XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T"), 0}, -#endif -#ifdef XML_DTD - {XML_FEATURE_DTD, XML_L("XML_DTD"), 0}, -#endif -#ifdef XML_CONTEXT_BYTES - {XML_FEATURE_CONTEXT_BYTES, XML_L("XML_CONTEXT_BYTES"), - XML_CONTEXT_BYTES}, -#endif -#ifdef XML_MIN_SIZE - {XML_FEATURE_MIN_SIZE, XML_L("XML_MIN_SIZE"), 0}, -#endif - {XML_FEATURE_END, NULL, 0} - }; - - features[0].value = sizeof(XML_Char); - features[1].value = sizeof(XML_LChar); - return features; -} - -/* Initially tag->rawName always points into the parse buffer; - for those TAG instances opened while the current parse buffer was - processed, and not yet closed, we need to store tag->rawName in a more - permanent location, since the parse buffer is about to be discarded. -*/ -static XML_Bool -storeRawNames(XML_Parser parser) -{ - TAG *tag = tagStack; - while (tag) { - int bufSize; - int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1); - char *rawNameBuf = tag->buf + nameLen; - /* Stop if already stored. Since tagStack is a stack, we can stop - at the first entry that has already been copied; everything - below it in the stack is already been accounted for in a - previous call to this function. - */ - if (tag->rawName == rawNameBuf) - break; - /* For re-use purposes we need to ensure that the - size of tag->buf is a multiple of sizeof(XML_Char). - */ - bufSize = nameLen + ROUND_UP(tag->rawNameLength, sizeof(XML_Char)); - if (bufSize > tag->bufEnd - tag->buf) { - char *temp = (char *)REALLOC(tag->buf, bufSize); - if (temp == NULL) - return XML_FALSE; - /* if tag->name.str points to tag->buf (only when namespace - processing is off) then we have to update it - */ - if (tag->name.str == (XML_Char *)tag->buf) - tag->name.str = (XML_Char *)temp; - /* if tag->name.localPart is set (when namespace processing is on) - then update it as well, since it will always point into tag->buf - */ - if (tag->name.localPart) - tag->name.localPart = (XML_Char *)temp + (tag->name.localPart - - (XML_Char *)tag->buf); - tag->buf = temp; - tag->bufEnd = temp + bufSize; - rawNameBuf = temp + nameLen; - } - memcpy(rawNameBuf, tag->rawName, tag->rawNameLength); - tag->rawName = rawNameBuf; - tag = tag->parent; - } - return XML_TRUE; -} - -static enum XML_Error PTRCALL -contentProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - enum XML_Error result = - doContent(parser, 0, encoding, start, end, endPtr); - if (result != XML_ERROR_NONE) - return result; - if (!storeRawNames(parser)) - return XML_ERROR_NO_MEMORY; - return result; -} - -static enum XML_Error PTRCALL -externalEntityInitProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - enum XML_Error result = initializeEncoding(parser); - if (result != XML_ERROR_NONE) - return result; - processor = externalEntityInitProcessor2; - return externalEntityInitProcessor2(parser, start, end, endPtr); -} - -static enum XML_Error PTRCALL -externalEntityInitProcessor2(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - const char *next = start; /* XmlContentTok doesn't always set the last arg */ - int tok = XmlContentTok(encoding, start, end, &next); - switch (tok) { - case XML_TOK_BOM: - /* If we are at the end of the buffer, this would cause the next stage, - i.e. externalEntityInitProcessor3, to pass control directly to - doContent (by detecting XML_TOK_NONE) without processing any xml text - declaration - causing the error XML_ERROR_MISPLACED_XML_PI in doContent. - */ - if (next == end && endPtr) { - *endPtr = next; - return XML_ERROR_NONE; - } - start = next; - break; - case XML_TOK_PARTIAL: - if (endPtr) { - *endPtr = start; - return XML_ERROR_NONE; - } - eventPtr = start; - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (endPtr) { - *endPtr = start; - return XML_ERROR_NONE; - } - eventPtr = start; - return XML_ERROR_PARTIAL_CHAR; - } - processor = externalEntityInitProcessor3; - return externalEntityInitProcessor3(parser, start, end, endPtr); -} - -static enum XML_Error PTRCALL -externalEntityInitProcessor3(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - const char *next = start; /* XmlContentTok doesn't always set the last arg */ - int tok = XmlContentTok(encoding, start, end, &next); - switch (tok) { - case XML_TOK_XML_DECL: - { - enum XML_Error result = processXmlDecl(parser, 1, start, next); - if (result != XML_ERROR_NONE) - return result; - start = next; - } - break; - case XML_TOK_PARTIAL: - if (endPtr) { - *endPtr = start; - return XML_ERROR_NONE; - } - eventPtr = start; - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (endPtr) { - *endPtr = start; - return XML_ERROR_NONE; - } - eventPtr = start; - return XML_ERROR_PARTIAL_CHAR; - } - processor = externalEntityContentProcessor; - tagLevel = 1; - return externalEntityContentProcessor(parser, start, end, endPtr); -} - -static enum XML_Error PTRCALL -externalEntityContentProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - enum XML_Error result = - doContent(parser, 1, encoding, start, end, endPtr); - if (result != XML_ERROR_NONE) - return result; - if (!storeRawNames(parser)) - return XML_ERROR_NO_MEMORY; - return result; -} - -static enum XML_Error -doContent(XML_Parser parser, - int startTagLevel, - const ENCODING *enc, - const char *s, - const char *end, - const char **nextPtr) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - const char **eventPP; - const char **eventEndPP; - if (enc == encoding) { - eventPP = &eventPtr; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - *eventPP = s; - for (;;) { - const char *next = s; /* XmlContentTok doesn't always set the last arg */ - int tok = XmlContentTok(enc, s, end, &next); - *eventEndPP = next; - switch (tok) { - case XML_TOK_TRAILING_CR: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - *eventEndPP = end; - if (characterDataHandler) { - XML_Char c = 0xA; - characterDataHandler(handlerArg, &c, 1); - } - else if (defaultHandler) - reportDefault(parser, enc, s, end); - if (startTagLevel == 0) - return XML_ERROR_NO_ELEMENTS; - if (tagLevel != startTagLevel) - return XML_ERROR_ASYNC_ENTITY; - return XML_ERROR_NONE; - case XML_TOK_NONE: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - if (startTagLevel > 0) { - if (tagLevel != startTagLevel) - return XML_ERROR_ASYNC_ENTITY; - return XML_ERROR_NONE; - } - return XML_ERROR_NO_ELEMENTS; - case XML_TOK_INVALID: - *eventPP = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_ENTITY_REF: - { - const XML_Char *name; - ENTITY *entity; - XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (ch) { - if (characterDataHandler) - characterDataHandler(handlerArg, &ch, 1); - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } - name = poolStoreString(&dtd->pool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!name) - return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(&dtd->generalEntities, name, 0); - poolDiscard(&dtd->pool); - /* First, determine if a check for an existing declaration is needed; - if yes, check that the entity exists, and that it is internal, - otherwise call the skipped entity or default handler. - */ - if (!dtd->hasParamEntityRefs || dtd->standalone) { - if (!entity) - return XML_ERROR_UNDEFINED_ENTITY; - else if (!entity->is_internal) - return XML_ERROR_ENTITY_DECLARED_IN_PE; - } - else if (!entity) { - if (skippedEntityHandler) - skippedEntityHandler(handlerArg, name, 0); - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } - if (entity->open) - return XML_ERROR_RECURSIVE_ENTITY_REF; - if (entity->notation) - return XML_ERROR_BINARY_ENTITY_REF; - if (entity->textPtr) { - enum XML_Error result; - OPEN_INTERNAL_ENTITY openEntity; - if (!defaultExpandInternalEntities) { - if (skippedEntityHandler) - skippedEntityHandler(handlerArg, entity->name, 0); - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } - entity->open = XML_TRUE; - openEntity.next = openInternalEntities; - openInternalEntities = &openEntity; - openEntity.entity = entity; - openEntity.internalEventPtr = NULL; - openEntity.internalEventEndPtr = NULL; - result = doContent(parser, - tagLevel, - internalEncoding, - (char *)entity->textPtr, - (char *)(entity->textPtr + entity->textLen), - 0); - entity->open = XML_FALSE; - openInternalEntities = openEntity.next; - if (result) - return result; - } - else if (externalEntityRefHandler) { - const XML_Char *context; - entity->open = XML_TRUE; - context = getContext(parser); - entity->open = XML_FALSE; - if (!context) - return XML_ERROR_NO_MEMORY; - if (!externalEntityRefHandler((XML_Parser)externalEntityRefHandlerArg, - context, - entity->base, - entity->systemId, - entity->publicId)) - return XML_ERROR_EXTERNAL_ENTITY_HANDLING; - poolDiscard(&tempPool); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } - case XML_TOK_START_TAG_NO_ATTS: - /* fall through */ - case XML_TOK_START_TAG_WITH_ATTS: - { - TAG *tag; - enum XML_Error result; - XML_Char *toPtr; - if (freeTagList) { - tag = freeTagList; - freeTagList = freeTagList->parent; - } - else { - tag = (TAG *)MALLOC(sizeof(TAG)); - if (!tag) - return XML_ERROR_NO_MEMORY; - tag->buf = (char *)MALLOC(INIT_TAG_BUF_SIZE); - if (!tag->buf) { - FREE(tag); - return XML_ERROR_NO_MEMORY; - } - tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE; - } - tag->bindings = NULL; - tag->parent = tagStack; - tagStack = tag; - tag->name.localPart = NULL; - tag->name.prefix = NULL; - tag->rawName = s + enc->minBytesPerChar; - tag->rawNameLength = XmlNameLength(enc, tag->rawName); - ++tagLevel; - { - const char *rawNameEnd = tag->rawName + tag->rawNameLength; - const char *fromPtr = tag->rawName; - toPtr = (XML_Char *)tag->buf; - for (;;) { - int bufSize; - int convLen; - XmlConvert(enc, - &fromPtr, rawNameEnd, - (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1); - convLen = toPtr - (XML_Char *)tag->buf; - if (fromPtr == rawNameEnd) { - tag->name.strLen = convLen; - break; - } - bufSize = (tag->bufEnd - tag->buf) << 1; - { - char *temp = (char *)REALLOC(tag->buf, bufSize); - if (temp == NULL) - return XML_ERROR_NO_MEMORY; - tag->buf = temp; - tag->bufEnd = temp + bufSize; - toPtr = (XML_Char *)temp + convLen; - } - } - } - tag->name.str = (XML_Char *)tag->buf; - *toPtr = XML_T('\0'); - result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings)); - if (result) - return result; - if (startElementHandler) - startElementHandler(handlerArg, tag->name.str, - (const XML_Char **)atts); - else if (defaultHandler) - reportDefault(parser, enc, s, next); - poolClear(&tempPool); - break; - } - case XML_TOK_EMPTY_ELEMENT_NO_ATTS: - /* fall through */ - case XML_TOK_EMPTY_ELEMENT_WITH_ATTS: - { - const char *rawName = s + enc->minBytesPerChar; - enum XML_Error result; - BINDING *bindings = NULL; - XML_Bool noElmHandlers = XML_TRUE; - TAG_NAME name; - name.str = poolStoreString(&tempPool, enc, rawName, - rawName + XmlNameLength(enc, rawName)); - if (!name.str) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - result = storeAtts(parser, enc, s, &name, &bindings); - if (result) - return result; - poolFinish(&tempPool); - if (startElementHandler) { - startElementHandler(handlerArg, name.str, (const XML_Char **)atts); - noElmHandlers = XML_FALSE; - } - if (endElementHandler) { - if (startElementHandler) - *eventPP = *eventEndPP; - endElementHandler(handlerArg, name.str); - noElmHandlers = XML_FALSE; - } - if (noElmHandlers && defaultHandler) - reportDefault(parser, enc, s, next); - poolClear(&tempPool); - while (bindings) { - BINDING *b = bindings; - if (endNamespaceDeclHandler) - endNamespaceDeclHandler(handlerArg, b->prefix->name); - bindings = bindings->nextTagBinding; - b->nextTagBinding = freeBindingList; - freeBindingList = b; - b->prefix->binding = b->prevPrefixBinding; - } - } - if (tagLevel == 0) - return epilogProcessor(parser, next, end, nextPtr); - break; - case XML_TOK_END_TAG: - if (tagLevel == startTagLevel) - return XML_ERROR_ASYNC_ENTITY; - else { - int len; - const char *rawName; - TAG *tag = tagStack; - tagStack = tag->parent; - tag->parent = freeTagList; - freeTagList = tag; - rawName = s + enc->minBytesPerChar*2; - len = XmlNameLength(enc, rawName); - if (len != tag->rawNameLength - || memcmp(tag->rawName, rawName, len) != 0) { - *eventPP = rawName; - return XML_ERROR_TAG_MISMATCH; - } - --tagLevel; - if (endElementHandler) { - const XML_Char *localPart; - const XML_Char *prefix; - XML_Char *uri; - localPart = tag->name.localPart; - if (ns && localPart) { - /* localPart and prefix may have been overwritten in - tag->name.str, since this points to the binding->uri - buffer which gets re-used; so we have to add them again - */ - uri = (XML_Char *)tag->name.str + tag->name.uriLen; - /* don't need to check for space - already done in storeAtts() */ - while (*localPart) *uri++ = *localPart++; - prefix = (XML_Char *)tag->name.prefix; - if (ns_triplets && prefix) { - *uri++ = namespaceSeparator; - while (*prefix) *uri++ = *prefix++; - } - *uri = XML_T('\0'); - } - endElementHandler(handlerArg, tag->name.str); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - while (tag->bindings) { - BINDING *b = tag->bindings; - if (endNamespaceDeclHandler) - endNamespaceDeclHandler(handlerArg, b->prefix->name); - tag->bindings = tag->bindings->nextTagBinding; - b->nextTagBinding = freeBindingList; - freeBindingList = b; - b->prefix->binding = b->prevPrefixBinding; - } - if (tagLevel == 0) - return epilogProcessor(parser, next, end, nextPtr); - } - break; - case XML_TOK_CHAR_REF: - { - int n = XmlCharRefNumber(enc, s); - if (n < 0) - return XML_ERROR_BAD_CHAR_REF; - if (characterDataHandler) { - XML_Char buf[XML_ENCODE_MAX]; - characterDataHandler(handlerArg, buf, XmlEncode(n, (ICHAR *)buf)); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - } - break; - case XML_TOK_XML_DECL: - return XML_ERROR_MISPLACED_XML_PI; - case XML_TOK_DATA_NEWLINE: - if (characterDataHandler) { - XML_Char c = 0xA; - characterDataHandler(handlerArg, &c, 1); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - case XML_TOK_CDATA_SECT_OPEN: - { - enum XML_Error result; - if (startCdataSectionHandler) - startCdataSectionHandler(handlerArg); -#if 0 - /* Suppose you doing a transformation on a document that involves - changing only the character data. You set up a defaultHandler - and a characterDataHandler. The defaultHandler simply copies - characters through. The characterDataHandler does the - transformation and writes the characters out escaping them as - necessary. This case will fail to work if we leave out the - following two lines (because & and < inside CDATA sections will - be incorrectly escaped). - - However, now we have a start/endCdataSectionHandler, so it seems - easier to let the user deal with this. - */ - else if (characterDataHandler) - characterDataHandler(handlerArg, dataBuf, 0); -#endif - else if (defaultHandler) - reportDefault(parser, enc, s, next); - result = doCdataSection(parser, enc, &next, end, nextPtr); - if (!next) { - processor = cdataSectionProcessor; - return result; - } - } - break; - case XML_TOK_TRAILING_RSQB: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - if (characterDataHandler) { - if (MUST_CONVERT(enc, s)) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); - characterDataHandler(handlerArg, dataBuf, - dataPtr - (ICHAR *)dataBuf); - } - else - characterDataHandler(handlerArg, - (XML_Char *)s, - (XML_Char *)end - (XML_Char *)s); - } - else if (defaultHandler) - reportDefault(parser, enc, s, end); - if (startTagLevel == 0) { - *eventPP = end; - return XML_ERROR_NO_ELEMENTS; - } - if (tagLevel != startTagLevel) { - *eventPP = end; - return XML_ERROR_ASYNC_ENTITY; - } - return XML_ERROR_NONE; - case XML_TOK_DATA_CHARS: - if (characterDataHandler) { - if (MUST_CONVERT(enc, s)) { - for (;;) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = s; - characterDataHandler(handlerArg, dataBuf, - dataPtr - (ICHAR *)dataBuf); - if (s == next) - break; - *eventPP = s; - } - } - else - characterDataHandler(handlerArg, - (XML_Char *)s, - (XML_Char *)next - (XML_Char *)s); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - case XML_TOK_PI: - if (!reportProcessingInstruction(parser, enc, s, next)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_COMMENT: - if (!reportComment(parser, enc, s, next)) - return XML_ERROR_NO_MEMORY; - break; - default: - if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - } - *eventPP = s = next; - } - /* not reached */ -} - -/* Precondition: all arguments must be non-NULL; - Purpose: - - normalize attributes - - check attributes for well-formedness - - generate namespace aware attribute names (URI, prefix) - - build list of attributes for startElementHandler - - default attributes - - process namespace declarations (check and report them) - - generate namespace aware element name (URI, prefix) -*/ -static enum XML_Error -storeAtts(XML_Parser parser, const ENCODING *enc, - const char *attStr, TAG_NAME *tagNamePtr, - BINDING **bindingsPtr) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - ELEMENT_TYPE *elementType; - int nDefaultAtts; - const XML_Char **appAtts; /* the attribute list for the application */ - int attIndex = 0; - int prefixLen; - int i; - int n; - XML_Char *uri; - int nPrefixes = 0; - BINDING *binding; - const XML_Char *localPart; - - /* lookup the element type name */ - elementType = (ELEMENT_TYPE *)lookup(&dtd->elementTypes, tagNamePtr->str,0); - if (!elementType) { - const XML_Char *name = poolCopyString(&dtd->pool, tagNamePtr->str); - if (!name) - return XML_ERROR_NO_MEMORY; - elementType = (ELEMENT_TYPE *)lookup(&dtd->elementTypes, name, - sizeof(ELEMENT_TYPE)); - if (!elementType) - return XML_ERROR_NO_MEMORY; - if (ns && !setElementTypePrefix(parser, elementType)) - return XML_ERROR_NO_MEMORY; - } - nDefaultAtts = elementType->nDefaultAtts; - - /* get the attributes from the tokenizer */ - n = XmlGetAttributes(enc, attStr, attsSize, atts); - if (n + nDefaultAtts > attsSize) { - int oldAttsSize = attsSize; - ATTRIBUTE *temp; - attsSize = n + nDefaultAtts + INIT_ATTS_SIZE; - temp = (ATTRIBUTE *)REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE)); - if (temp == NULL) - return XML_ERROR_NO_MEMORY; - atts = temp; - if (n > oldAttsSize) - XmlGetAttributes(enc, attStr, n, atts); - } - - appAtts = (const XML_Char **)atts; - for (i = 0; i < n; i++) { - /* add the name and value to the attribute list */ - ATTRIBUTE_ID *attId = getAttributeId(parser, enc, atts[i].name, - atts[i].name - + XmlNameLength(enc, atts[i].name)); - if (!attId) - return XML_ERROR_NO_MEMORY; - /* Detect duplicate attributes by their QNames. This does not work when - namespace processing is turned on and different prefixes for the same - namespace are used. For this case we have a check further down. - */ - if ((attId->name)[-1]) { - if (enc == encoding) - eventPtr = atts[i].name; - return XML_ERROR_DUPLICATE_ATTRIBUTE; - } - (attId->name)[-1] = 1; - appAtts[attIndex++] = attId->name; - if (!atts[i].normalized) { - enum XML_Error result; - XML_Bool isCdata = XML_TRUE; - - /* figure out whether declared as other than CDATA */ - if (attId->maybeTokenized) { - int j; - for (j = 0; j < nDefaultAtts; j++) { - if (attId == elementType->defaultAtts[j].id) { - isCdata = elementType->defaultAtts[j].isCdata; - break; - } - } - } - - /* normalize the attribute value */ - result = storeAttributeValue(parser, enc, isCdata, - atts[i].valuePtr, atts[i].valueEnd, - &tempPool); - if (result) - return result; - appAtts[attIndex] = poolStart(&tempPool); - poolFinish(&tempPool); - } - else { - /* the value did not need normalizing */ - appAtts[attIndex] = poolStoreString(&tempPool, enc, atts[i].valuePtr, - atts[i].valueEnd); - if (appAtts[attIndex] == 0) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - } - /* handle prefixed attribute names */ - if (attId->prefix) { - if (attId->xmlns) { - /* deal with namespace declarations here */ - enum XML_Error result = addBinding(parser, attId->prefix, attId, - appAtts[attIndex], bindingsPtr); - if (result) - return result; - --attIndex; - } - else { - /* deal with other prefixed names later */ - attIndex++; - nPrefixes++; - (attId->name)[-1] = 2; - } - } - else - attIndex++; - } - - /* set-up for XML_GetSpecifiedAttributeCount and XML_GetIdAttributeIndex */ - nSpecifiedAtts = attIndex; - if (elementType->idAtt && (elementType->idAtt->name)[-1]) { - for (i = 0; i < attIndex; i += 2) - if (appAtts[i] == elementType->idAtt->name) { - idAttIndex = i; - break; - } - } - else - idAttIndex = -1; - - /* do attribute defaulting */ - for (i = 0; i < nDefaultAtts; i++) { - const DEFAULT_ATTRIBUTE *da = elementType->defaultAtts + i; - if (!(da->id->name)[-1] && da->value) { - if (da->id->prefix) { - if (da->id->xmlns) { - enum XML_Error result = addBinding(parser, da->id->prefix, da->id, - da->value, bindingsPtr); - if (result) - return result; - } - else { - (da->id->name)[-1] = 2; - nPrefixes++; - appAtts[attIndex++] = da->id->name; - appAtts[attIndex++] = da->value; - } - } - else { - (da->id->name)[-1] = 1; - appAtts[attIndex++] = da->id->name; - appAtts[attIndex++] = da->value; - } - } - } - appAtts[attIndex] = 0; - - /* expand prefixed attribute names, check for duplicates, - and clear flags that say whether attributes were specified */ - i = 0; - if (nPrefixes) { - int j; /* hash table index */ - unsigned long version = nsAttsVersion; - int nsAttsSize = (int)1 << nsAttsPower; - /* size of hash table must be at least 2 * (# of prefixed attributes) */ - if ((nPrefixes << 1) >> nsAttsPower) { /* true for nsAttsPower = 0 */ - NS_ATT *temp; - /* hash table size must also be a power of 2 and >= 8 */ - while (nPrefixes >> nsAttsPower++); - if (nsAttsPower < 3) - nsAttsPower = 3; - nsAttsSize = (int)1 << nsAttsPower; - temp = (NS_ATT *)REALLOC(nsAtts, nsAttsSize * sizeof(NS_ATT)); - if (!temp) - return XML_ERROR_NO_MEMORY; - nsAtts = temp; - version = 0; /* force re-initialization of nsAtts hash table */ - } - /* using a version flag saves us from initializing nsAtts every time */ - if (!version) { /* initialize version flags when version wraps around */ - version = INIT_ATTS_VERSION; - for (j = nsAttsSize; j != 0; ) - nsAtts[--j].version = version; - } - nsAttsVersion = --version; - - /* expand prefixed names and check for duplicates */ - for (; i < attIndex; i += 2) { - const XML_Char *s = appAtts[i]; - if (s[-1] == 2) { /* prefixed */ - ATTRIBUTE_ID *id; - const BINDING *b; - unsigned long uriHash = 0; - ((XML_Char *)s)[-1] = 0; /* clear flag */ - id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, s, 0); - b = id->prefix->binding; - if (!b) - return XML_ERROR_UNBOUND_PREFIX; - - /* as we expand the name we also calculate its hash value */ - for (j = 0; j < b->uriLen; j++) { - const XML_Char c = b->uri[j]; - if (!poolAppendChar(&tempPool, c)) - return XML_ERROR_NO_MEMORY; - uriHash = CHAR_HASH(uriHash, c); - } - while (*s++ != XML_T(':')) - ; - do { /* copies null terminator */ - const XML_Char c = *s; - if (!poolAppendChar(&tempPool, *s)) - return XML_ERROR_NO_MEMORY; - uriHash = CHAR_HASH(uriHash, c); - } while (*s++); - - { /* Check hash table for duplicate of expanded name (uriName). - Derived from code in lookup(HASH_TABLE *table, ...). - */ - unsigned char step = 0; - unsigned long mask = nsAttsSize - 1; - j = uriHash & mask; /* index into hash table */ - while (nsAtts[j].version == version) { - /* for speed we compare stored hash values first */ - if (uriHash == nsAtts[j].hash) { - const XML_Char *s1 = poolStart(&tempPool); - const XML_Char *s2 = nsAtts[j].uriName; - /* s1 is null terminated, but not s2 */ - for (; *s1 == *s2 && *s1 != 0; s1++, s2++); - if (*s1 == 0) - return XML_ERROR_DUPLICATE_ATTRIBUTE; - } - if (!step) - step = PROBE_STEP(uriHash, mask, nsAttsPower); - j < step ? ( j += nsAttsSize - step) : (j -= step); - } - } - - if (ns_triplets) { /* append namespace separator and prefix */ - tempPool.ptr[-1] = namespaceSeparator; - s = b->prefix->name; - do { - if (!poolAppendChar(&tempPool, *s)) - return XML_ERROR_NO_MEMORY; - } while (*s++); - } - - /* store expanded name in attribute list */ - s = poolStart(&tempPool); - poolFinish(&tempPool); - appAtts[i] = s; - - /* fill empty slot with new version, uriName and hash value */ - nsAtts[j].version = version; - nsAtts[j].hash = uriHash; - nsAtts[j].uriName = s; - - if (!--nPrefixes) - break; - } - else /* not prefixed */ - ((XML_Char *)s)[-1] = 0; /* clear flag */ - } - } - /* clear flags for the remaining attributes */ - for (; i < attIndex; i += 2) - ((XML_Char *)(appAtts[i]))[-1] = 0; - for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding) - binding->attId->name[-1] = 0; - - if (!ns) - return XML_ERROR_NONE; - - /* expand the element type name */ - if (elementType->prefix) { - binding = elementType->prefix->binding; - if (!binding) - return XML_ERROR_UNBOUND_PREFIX; - localPart = tagNamePtr->str; - while (*localPart++ != XML_T(':')) - ; - } - else if (dtd->defaultPrefix.binding) { - binding = dtd->defaultPrefix.binding; - localPart = tagNamePtr->str; - } - else - return XML_ERROR_NONE; - prefixLen = 0; - if (ns_triplets && binding->prefix->name) { - for (; binding->prefix->name[prefixLen++];) - ; - } - tagNamePtr->localPart = localPart; - tagNamePtr->uriLen = binding->uriLen; - tagNamePtr->prefix = binding->prefix->name; - tagNamePtr->prefixLen = prefixLen; - for (i = 0; localPart[i++];) - ; - n = i + binding->uriLen + prefixLen; - if (n > binding->uriAlloc) { - TAG *p; - uri = (XML_Char *)MALLOC((n + EXPAND_SPARE) * sizeof(XML_Char)); - if (!uri) - return XML_ERROR_NO_MEMORY; - binding->uriAlloc = n + EXPAND_SPARE; - memcpy(uri, binding->uri, binding->uriLen * sizeof(XML_Char)); - for (p = tagStack; p; p = p->parent) - if (p->name.str == binding->uri) - p->name.str = uri; - FREE(binding->uri); - binding->uri = uri; - } - uri = binding->uri + binding->uriLen; - memcpy(uri, localPart, i * sizeof(XML_Char)); - if (prefixLen) { - uri = uri + (i - 1); - if (namespaceSeparator) - *uri = namespaceSeparator; - memcpy(uri + 1, binding->prefix->name, prefixLen * sizeof(XML_Char)); - } - tagNamePtr->str = binding->uri; - return XML_ERROR_NONE; -} - -/* addBinding() overwrites the value of prefix->binding without checking. - Therefore one must keep track of the old value outside of addBinding(). -*/ -static enum XML_Error -addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, - const XML_Char *uri, BINDING **bindingsPtr) -{ - BINDING *b; - int len; - - /* empty string is only valid when there is no prefix per XML NS 1.0 */ - if (*uri == XML_T('\0') && prefix->name) - return XML_ERROR_SYNTAX; - - for (len = 0; uri[len]; len++) - ; - if (namespaceSeparator) - len++; - if (freeBindingList) { - b = freeBindingList; - if (len > b->uriAlloc) { - XML_Char *temp = (XML_Char *)REALLOC(b->uri, - sizeof(XML_Char) * (len + EXPAND_SPARE)); - if (temp == NULL) - return XML_ERROR_NO_MEMORY; - b->uri = temp; - b->uriAlloc = len + EXPAND_SPARE; - } - freeBindingList = b->nextTagBinding; - } - else { - b = (BINDING *)MALLOC(sizeof(BINDING)); - if (!b) - return XML_ERROR_NO_MEMORY; - b->uri = (XML_Char *)MALLOC(sizeof(XML_Char) * (len + EXPAND_SPARE)); - if (!b->uri) { - FREE(b); - return XML_ERROR_NO_MEMORY; - } - b->uriAlloc = len + EXPAND_SPARE; - } - b->uriLen = len; - memcpy(b->uri, uri, len * sizeof(XML_Char)); - if (namespaceSeparator) - b->uri[len - 1] = namespaceSeparator; - b->prefix = prefix; - b->attId = attId; - b->prevPrefixBinding = prefix->binding; - /* NULL binding when default namespace undeclared */ - if (*uri == XML_T('\0') && prefix == &_dtd->defaultPrefix) - prefix->binding = NULL; - else - prefix->binding = b; - b->nextTagBinding = *bindingsPtr; - *bindingsPtr = b; - if (startNamespaceDeclHandler) - startNamespaceDeclHandler(handlerArg, prefix->name, - prefix->binding ? uri : 0); - return XML_ERROR_NONE; -} - -/* The idea here is to avoid using stack for each CDATA section when - the whole file is parsed with one call. -*/ -static enum XML_Error PTRCALL -cdataSectionProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - enum XML_Error result = doCdataSection(parser, encoding, &start, - end, endPtr); - if (start) { - if (parentParser) { /* we are parsing an external entity */ - processor = externalEntityContentProcessor; - return externalEntityContentProcessor(parser, start, end, endPtr); - } - else { - processor = contentProcessor; - return contentProcessor(parser, start, end, endPtr); - } - } - return result; -} - -/* startPtr gets set to non-null is the section is closed, and to null if - the section is not yet closed. -*/ -static enum XML_Error -doCdataSection(XML_Parser parser, - const ENCODING *enc, - const char **startPtr, - const char *end, - const char **nextPtr) -{ - const char *s = *startPtr; - const char **eventPP; - const char **eventEndPP; - if (enc == encoding) { - eventPP = &eventPtr; - *eventPP = s; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - *eventPP = s; - *startPtr = NULL; - for (;;) { - const char *next; - int tok = XmlCdataSectionTok(enc, s, end, &next); - *eventEndPP = next; - switch (tok) { - case XML_TOK_CDATA_SECT_CLOSE: - if (endCdataSectionHandler) - endCdataSectionHandler(handlerArg); -#if 0 - /* see comment under XML_TOK_CDATA_SECT_OPEN */ - else if (characterDataHandler) - characterDataHandler(handlerArg, dataBuf, 0); -#endif - else if (defaultHandler) - reportDefault(parser, enc, s, next); - *startPtr = next; - return XML_ERROR_NONE; - case XML_TOK_DATA_NEWLINE: - if (characterDataHandler) { - XML_Char c = 0xA; - characterDataHandler(handlerArg, &c, 1); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - case XML_TOK_DATA_CHARS: - if (characterDataHandler) { - if (MUST_CONVERT(enc, s)) { - for (;;) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = next; - characterDataHandler(handlerArg, dataBuf, - dataPtr - (ICHAR *)dataBuf); - if (s == next) - break; - *eventPP = s; - } - } - else - characterDataHandler(handlerArg, - (XML_Char *)s, - (XML_Char *)next - (XML_Char *)s); - } - else if (defaultHandler) - reportDefault(parser, enc, s, next); - break; - case XML_TOK_INVALID: - *eventPP = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_PARTIAL: - case XML_TOK_NONE: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_UNCLOSED_CDATA_SECTION; - default: - *eventPP = next; - return XML_ERROR_UNEXPECTED_STATE; - } - *eventPP = s = next; - } - /* not reached */ -} - -#ifdef XML_DTD - -/* The idea here is to avoid using stack for each IGNORE section when - the whole file is parsed with one call. -*/ -static enum XML_Error PTRCALL -ignoreSectionProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) -{ - enum XML_Error result = doIgnoreSection(parser, encoding, &start, - end, endPtr); - if (start) { - processor = prologProcessor; - return prologProcessor(parser, start, end, endPtr); - } - return result; -} - -/* startPtr gets set to non-null is the section is closed, and to null - if the section is not yet closed. -*/ -static enum XML_Error -doIgnoreSection(XML_Parser parser, - const ENCODING *enc, - const char **startPtr, - const char *end, - const char **nextPtr) -{ - const char *next; - int tok; - const char *s = *startPtr; - const char **eventPP; - const char **eventEndPP; - if (enc == encoding) { - eventPP = &eventPtr; - *eventPP = s; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - *eventPP = s; - *startPtr = NULL; - tok = XmlIgnoreSectionTok(enc, s, end, &next); - *eventEndPP = next; - switch (tok) { - case XML_TOK_IGNORE_SECT: - if (defaultHandler) - reportDefault(parser, enc, s, next); - *startPtr = next; - return XML_ERROR_NONE; - case XML_TOK_INVALID: - *eventPP = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_PARTIAL: - case XML_TOK_NONE: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_SYNTAX; /* XML_ERROR_UNCLOSED_IGNORE_SECTION */ - default: - *eventPP = next; - return XML_ERROR_UNEXPECTED_STATE; - } - /* not reached */ -} - -#endif /* XML_DTD */ - -static enum XML_Error -initializeEncoding(XML_Parser parser) -{ - const char *s; -#ifdef XML_UNICODE - char encodingBuf[128]; - if (!protocolEncodingName) - s = NULL; - else { - int i; - for (i = 0; protocolEncodingName[i]; i++) { - if (i == sizeof(encodingBuf) - 1 - || (protocolEncodingName[i] & ~0x7f) != 0) { - encodingBuf[0] = '\0'; - break; - } - encodingBuf[i] = (char)protocolEncodingName[i]; - } - encodingBuf[i] = '\0'; - s = encodingBuf; - } -#else - s = protocolEncodingName; -#endif - if ((ns ? XmlInitEncodingNS : XmlInitEncoding)(&initEncoding, &encoding, s)) - return XML_ERROR_NONE; - return handleUnknownEncoding(parser, protocolEncodingName); -} - -static enum XML_Error -processXmlDecl(XML_Parser parser, int isGeneralTextEntity, - const char *s, const char *next) -{ - const char *encodingName = NULL; - const XML_Char *storedEncName = NULL; - const ENCODING *newEncoding = NULL; - const char *version = NULL; - const char *versionend; - const XML_Char *storedversion = NULL; - int standalone = -1; - if (!(ns - ? XmlParseXmlDeclNS - : XmlParseXmlDecl)(isGeneralTextEntity, - encoding, - s, - next, - &eventPtr, - &version, - &versionend, - &encodingName, - &newEncoding, - &standalone)) - return XML_ERROR_SYNTAX; - if (!isGeneralTextEntity && standalone == 1) { - _dtd->standalone = XML_TRUE; -#ifdef XML_DTD - if (paramEntityParsing == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) - paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; -#endif /* XML_DTD */ - } - if (xmlDeclHandler) { - if (encodingName != NULL) { - storedEncName = poolStoreString(&temp2Pool, - encoding, - encodingName, - encodingName - + XmlNameLength(encoding, encodingName)); - if (!storedEncName) - return XML_ERROR_NO_MEMORY; - poolFinish(&temp2Pool); - } - if (version) { - storedversion = poolStoreString(&temp2Pool, - encoding, - version, - versionend - encoding->minBytesPerChar); - if (!storedversion) - return XML_ERROR_NO_MEMORY; - } - xmlDeclHandler(handlerArg, storedversion, storedEncName, standalone); - } - else if (defaultHandler) - reportDefault(parser, encoding, s, next); - if (protocolEncodingName == NULL) { - if (newEncoding) { - if (newEncoding->minBytesPerChar != encoding->minBytesPerChar) { - eventPtr = encodingName; - return XML_ERROR_INCORRECT_ENCODING; - } - encoding = newEncoding; - } - else if (encodingName) { - enum XML_Error result; - if (!storedEncName) { - storedEncName = poolStoreString( - &temp2Pool, encoding, encodingName, - encodingName + XmlNameLength(encoding, encodingName)); - if (!storedEncName) - return XML_ERROR_NO_MEMORY; - } - result = handleUnknownEncoding(parser, storedEncName); - poolClear(&temp2Pool); - if (result == XML_ERROR_UNKNOWN_ENCODING) - eventPtr = encodingName; - return result; - } - } - - if (storedEncName || storedversion) - poolClear(&temp2Pool); - - return XML_ERROR_NONE; -} - -static enum XML_Error -handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) -{ - if (unknownEncodingHandler) { - XML_Encoding info; - int i; - for (i = 0; i < 256; i++) - info.map[i] = -1; - info.convert = NULL; - info.data = NULL; - info.release = NULL; - if (unknownEncodingHandler(unknownEncodingHandlerData, encodingName, - &info)) { - ENCODING *enc; - unknownEncodingMem = MALLOC(XmlSizeOfUnknownEncoding()); - if (!unknownEncodingMem) { - if (info.release) - info.release(info.data); - return XML_ERROR_NO_MEMORY; - } - enc = (ns - ? XmlInitUnknownEncodingNS - : XmlInitUnknownEncoding)(unknownEncodingMem, - info.map, - info.convert, - info.data); - if (enc) { - unknownEncodingData = info.data; - unknownEncodingRelease = info.release; - encoding = enc; - return XML_ERROR_NONE; - } - } - if (info.release != NULL) - info.release(info.data); - } - return XML_ERROR_UNKNOWN_ENCODING; -} - -static enum XML_Error PTRCALL -prologInitProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - enum XML_Error result = initializeEncoding(parser); - if (result != XML_ERROR_NONE) - return result; - processor = prologProcessor; - return prologProcessor(parser, s, end, nextPtr); -} - -#ifdef XML_DTD - -static enum XML_Error PTRCALL -externalParEntInitProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - enum XML_Error result = initializeEncoding(parser); - if (result != XML_ERROR_NONE) - return result; - - /* we know now that XML_Parse(Buffer) has been called, - so we consider the external parameter entity read */ - _dtd->paramEntityRead = XML_TRUE; - - if (prologState.inEntityValue) { - processor = entityValueInitProcessor; - return entityValueInitProcessor(parser, s, end, nextPtr); - } - else { - processor = externalParEntProcessor; - return externalParEntProcessor(parser, s, end, nextPtr); - } -} - -static enum XML_Error PTRCALL -entityValueInitProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - const char *start = s; - const char *next = s; - int tok; - - for (;;) { - tok = XmlPrologTok(encoding, start, end, &next); - if (tok <= 0) { - if (nextPtr != 0 && tok != XML_TOK_INVALID) { - *nextPtr = s; - return XML_ERROR_NONE; - } - switch (tok) { - case XML_TOK_INVALID: - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_NONE: /* start == end */ - default: - break; - } - return storeEntityValue(parser, encoding, s, end); - } - else if (tok == XML_TOK_XML_DECL) { - enum XML_Error result = processXmlDecl(parser, 0, start, next); - if (result != XML_ERROR_NONE) - return result; - if (nextPtr) *nextPtr = next; - /* stop scanning for text declaration - we found one */ - processor = entityValueProcessor; - return entityValueProcessor(parser, next, end, nextPtr); - } - /* If we are at the end of the buffer, this would cause XmlPrologTok to - return XML_TOK_NONE on the next call, which would then cause the - function to exit with *nextPtr set to s - that is what we want for other - tokens, but not for the BOM - we would rather like to skip it; - then, when this routine is entered the next time, XmlPrologTok will - return XML_TOK_INVALID, since the BOM is still in the buffer - */ - else if (tok == XML_TOK_BOM && next == end && nextPtr) { - *nextPtr = next; - return XML_ERROR_NONE; - } - start = next; - } -} - -static enum XML_Error PTRCALL -externalParEntProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - const char *start = s; - const char *next = s; - int tok; - - tok = XmlPrologTok(encoding, start, end, &next); - if (tok <= 0) { - if (nextPtr != 0 && tok != XML_TOK_INVALID) { - *nextPtr = s; - return XML_ERROR_NONE; - } - switch (tok) { - case XML_TOK_INVALID: - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_NONE: /* start == end */ - default: - break; - } - } - /* This would cause the next stage, i.e. doProlog to be passed XML_TOK_BOM. - However, when parsing an external subset, doProlog will not accept a BOM - as valid, and report a syntax error, so we have to skip the BOM - */ - else if (tok == XML_TOK_BOM) { - s = next; - tok = XmlPrologTok(encoding, s, end, &next); - } - - processor = prologProcessor; - return doProlog(parser, encoding, s, end, tok, next, nextPtr); -} - -static enum XML_Error PTRCALL -entityValueProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - const char *start = s; - const char *next = s; - const ENCODING *enc = encoding; - int tok; - - for (;;) { - tok = XmlPrologTok(enc, start, end, &next); - if (tok <= 0) { - if (nextPtr != 0 && tok != XML_TOK_INVALID) { - *nextPtr = s; - return XML_ERROR_NONE; - } - switch (tok) { - case XML_TOK_INVALID: - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_NONE: /* start == end */ - default: - break; - } - return storeEntityValue(parser, enc, s, end); - } - start = next; - } -} - -#endif /* XML_DTD */ - -static enum XML_Error PTRCALL -prologProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - const char *next = s; - int tok = XmlPrologTok(encoding, s, end, &next); - return doProlog(parser, encoding, s, end, tok, next, nextPtr); -} - -static enum XML_Error -doProlog(XML_Parser parser, - const ENCODING *enc, - const char *s, - const char *end, - int tok, - const char *next, - const char **nextPtr) -{ -#ifdef XML_DTD - static const XML_Char externalSubsetName[] = { '#' , '\0' }; -#endif /* XML_DTD */ - static const XML_Char atypeCDATA[] = { 'C', 'D', 'A', 'T', 'A', '\0' }; - static const XML_Char atypeID[] = { 'I', 'D', '\0' }; - static const XML_Char atypeIDREF[] = { 'I', 'D', 'R', 'E', 'F', '\0' }; - static const XML_Char atypeIDREFS[] = { 'I', 'D', 'R', 'E', 'F', 'S', '\0' }; - static const XML_Char atypeENTITY[] = { 'E', 'N', 'T', 'I', 'T', 'Y', '\0' }; - static const XML_Char atypeENTITIES[] = - { 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S', '\0' }; - static const XML_Char atypeNMTOKEN[] = { - 'N', 'M', 'T', 'O', 'K', 'E', 'N', '\0' }; - static const XML_Char atypeNMTOKENS[] = { - 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S', '\0' }; - static const XML_Char notationPrefix[] = { - 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N', '(', '\0' }; - static const XML_Char enumValueSep[] = { '|', '\0' }; - static const XML_Char enumValueStart[] = { '(', '\0' }; - - DTD * const dtd = _dtd; /* save one level of indirection */ - - const char **eventPP; - const char **eventEndPP; - enum XML_Content_Quant quant; - - if (enc == encoding) { - eventPP = &eventPtr; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - for (;;) { - int role; - XML_Bool handleDefault = XML_TRUE; - *eventPP = s; - *eventEndPP = next; - if (tok <= 0) { - if (nextPtr != 0 && tok != XML_TOK_INVALID) { - *nextPtr = s; - return XML_ERROR_NONE; - } - switch (tok) { - case XML_TOK_INVALID: - *eventPP = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - return XML_ERROR_PARTIAL_CHAR; - case XML_TOK_NONE: -#ifdef XML_DTD - if (enc != encoding) - return XML_ERROR_NONE; - if (isParamEntity) { - if (XmlTokenRole(&prologState, XML_TOK_NONE, end, end, enc) - == XML_ROLE_ERROR) - return XML_ERROR_SYNTAX; - return XML_ERROR_NONE; - } -#endif /* XML_DTD */ - return XML_ERROR_NO_ELEMENTS; - default: - tok = -tok; - next = end; - break; - } - } - role = XmlTokenRole(&prologState, tok, s, next, enc); - switch (role) { - case XML_ROLE_XML_DECL: - { - enum XML_Error result = processXmlDecl(parser, 0, s, next); - if (result != XML_ERROR_NONE) - return result; - enc = encoding; - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_DOCTYPE_NAME: - if (startDoctypeDeclHandler) { - doctypeName = poolStoreString(&tempPool, enc, s, next); - if (!doctypeName) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - doctypePubid = NULL; - handleDefault = XML_FALSE; - } - doctypeSysid = NULL; /* always initialize to NULL */ - break; - case XML_ROLE_DOCTYPE_INTERNAL_SUBSET: - if (startDoctypeDeclHandler) { - startDoctypeDeclHandler(handlerArg, doctypeName, doctypeSysid, - doctypePubid, 1); - doctypeName = NULL; - poolClear(&tempPool); - handleDefault = XML_FALSE; - } - break; -#ifdef XML_DTD - case XML_ROLE_TEXT_DECL: - { - enum XML_Error result = processXmlDecl(parser, 1, s, next); - if (result != XML_ERROR_NONE) - return result; - enc = encoding; - handleDefault = XML_FALSE; - } - break; -#endif /* XML_DTD */ - case XML_ROLE_DOCTYPE_PUBLIC_ID: -#ifdef XML_DTD - useForeignDTD = XML_FALSE; -#endif /* XML_DTD */ - dtd->hasParamEntityRefs = XML_TRUE; - if (startDoctypeDeclHandler) { - doctypePubid = poolStoreString(&tempPool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!doctypePubid) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - handleDefault = XML_FALSE; - } -#ifdef XML_DTD - declEntity = (ENTITY *)lookup(&dtd->paramEntities, - externalSubsetName, - sizeof(ENTITY)); - if (!declEntity) - return XML_ERROR_NO_MEMORY; -#endif /* XML_DTD */ - /* fall through */ - case XML_ROLE_ENTITY_PUBLIC_ID: - if (!XmlIsPublicId(enc, s, next, eventPP)) - return XML_ERROR_SYNTAX; - if (dtd->keepProcessing && declEntity) { - XML_Char *tem = poolStoreString(&dtd->pool, - enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!tem) - return XML_ERROR_NO_MEMORY; - normalizePublicId(tem); - declEntity->publicId = tem; - poolFinish(&dtd->pool); - if (entityDeclHandler) - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_DOCTYPE_CLOSE: - if (doctypeName) { - startDoctypeDeclHandler(handlerArg, doctypeName, - doctypeSysid, doctypePubid, 0); - poolClear(&tempPool); - handleDefault = XML_FALSE; - } - /* doctypeSysid will be non-NULL in the case of a previous - XML_ROLE_DOCTYPE_SYSTEM_ID, even if startDoctypeDeclHandler - was not set, indicating an external subset - */ -#ifdef XML_DTD - if (doctypeSysid || useForeignDTD) { - dtd->hasParamEntityRefs = XML_TRUE; /* when docTypeSysid == NULL */ - if (paramEntityParsing && externalEntityRefHandler) { - ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, - externalSubsetName, - sizeof(ENTITY)); - if (!entity) - return XML_ERROR_NO_MEMORY; - if (useForeignDTD) - entity->base = curBase; - dtd->paramEntityRead = XML_FALSE; - if (!externalEntityRefHandler(externalEntityRefHandlerArg, - 0, - entity->base, - entity->systemId, - entity->publicId)) - return XML_ERROR_EXTERNAL_ENTITY_HANDLING; - if (dtd->paramEntityRead && - !dtd->standalone && - notStandaloneHandler && - !notStandaloneHandler(handlerArg)) - return XML_ERROR_NOT_STANDALONE; - /* end of DTD - no need to update dtd->keepProcessing */ - } - useForeignDTD = XML_FALSE; - } -#endif /* XML_DTD */ - if (endDoctypeDeclHandler) { - endDoctypeDeclHandler(handlerArg); - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_INSTANCE_START: -#ifdef XML_DTD - /* if there is no DOCTYPE declaration then now is the - last chance to read the foreign DTD - */ - if (useForeignDTD) { - dtd->hasParamEntityRefs = XML_TRUE; - if (paramEntityParsing && externalEntityRefHandler) { - ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, - externalSubsetName, - sizeof(ENTITY)); - if (!entity) - return XML_ERROR_NO_MEMORY; - entity->base = curBase; - dtd->paramEntityRead = XML_FALSE; - if (!externalEntityRefHandler(externalEntityRefHandlerArg, - 0, - entity->base, - entity->systemId, - entity->publicId)) - return XML_ERROR_EXTERNAL_ENTITY_HANDLING; - if (dtd->paramEntityRead && - !dtd->standalone && - notStandaloneHandler && - !notStandaloneHandler(handlerArg)) - return XML_ERROR_NOT_STANDALONE; - /* end of DTD - no need to update dtd->keepProcessing */ - } - } -#endif /* XML_DTD */ - processor = contentProcessor; - return contentProcessor(parser, s, end, nextPtr); - case XML_ROLE_ATTLIST_ELEMENT_NAME: - declElementType = getElementType(parser, enc, s, next); - if (!declElementType) - return XML_ERROR_NO_MEMORY; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_NAME: - declAttributeId = getAttributeId(parser, enc, s, next); - if (!declAttributeId) - return XML_ERROR_NO_MEMORY; - declAttributeIsCdata = XML_FALSE; - declAttributeType = NULL; - declAttributeIsId = XML_FALSE; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_CDATA: - declAttributeIsCdata = XML_TRUE; - declAttributeType = atypeCDATA; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_ID: - declAttributeIsId = XML_TRUE; - declAttributeType = atypeID; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_IDREF: - declAttributeType = atypeIDREF; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_IDREFS: - declAttributeType = atypeIDREFS; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_ENTITY: - declAttributeType = atypeENTITY; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES: - declAttributeType = atypeENTITIES; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN: - declAttributeType = atypeNMTOKEN; - goto checkAttListDeclHandler; - case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS: - declAttributeType = atypeNMTOKENS; - checkAttListDeclHandler: - if (dtd->keepProcessing && attlistDeclHandler) - handleDefault = XML_FALSE; - break; - case XML_ROLE_ATTRIBUTE_ENUM_VALUE: - case XML_ROLE_ATTRIBUTE_NOTATION_VALUE: - if (dtd->keepProcessing && attlistDeclHandler) { - const XML_Char *prefix; - if (declAttributeType) { - prefix = enumValueSep; - } - else { - prefix = (role == XML_ROLE_ATTRIBUTE_NOTATION_VALUE - ? notationPrefix - : enumValueStart); - } - if (!poolAppendString(&tempPool, prefix)) - return XML_ERROR_NO_MEMORY; - if (!poolAppend(&tempPool, enc, s, next)) - return XML_ERROR_NO_MEMORY; - declAttributeType = tempPool.start; - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE: - case XML_ROLE_REQUIRED_ATTRIBUTE_VALUE: - if (dtd->keepProcessing) { - if (!defineAttribute(declElementType, declAttributeId, - declAttributeIsCdata, declAttributeIsId, - 0, parser)) - return XML_ERROR_NO_MEMORY; - if (attlistDeclHandler && declAttributeType) { - if (*declAttributeType == XML_T('(') - || (*declAttributeType == XML_T('N') - && declAttributeType[1] == XML_T('O'))) { - /* Enumerated or Notation type */ - if (!poolAppendChar(&tempPool, XML_T(')')) - || !poolAppendChar(&tempPool, XML_T('\0'))) - return XML_ERROR_NO_MEMORY; - declAttributeType = tempPool.start; - poolFinish(&tempPool); - } - *eventEndPP = s; - attlistDeclHandler(handlerArg, declElementType->name, - declAttributeId->name, declAttributeType, - 0, role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE); - poolClear(&tempPool); - handleDefault = XML_FALSE; - } - } - break; - case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE: - case XML_ROLE_FIXED_ATTRIBUTE_VALUE: - if (dtd->keepProcessing) { - const XML_Char *attVal; - enum XML_Error result = - storeAttributeValue(parser, enc, declAttributeIsCdata, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar, - &dtd->pool); - if (result) - return result; - attVal = poolStart(&dtd->pool); - poolFinish(&dtd->pool); - /* ID attributes aren't allowed to have a default */ - if (!defineAttribute(declElementType, declAttributeId, - declAttributeIsCdata, XML_FALSE, attVal, parser)) - return XML_ERROR_NO_MEMORY; - if (attlistDeclHandler && declAttributeType) { - if (*declAttributeType == XML_T('(') - || (*declAttributeType == XML_T('N') - && declAttributeType[1] == XML_T('O'))) { - /* Enumerated or Notation type */ - if (!poolAppendChar(&tempPool, XML_T(')')) - || !poolAppendChar(&tempPool, XML_T('\0'))) - return XML_ERROR_NO_MEMORY; - declAttributeType = tempPool.start; - poolFinish(&tempPool); - } - *eventEndPP = s; - attlistDeclHandler(handlerArg, declElementType->name, - declAttributeId->name, declAttributeType, - attVal, - role == XML_ROLE_FIXED_ATTRIBUTE_VALUE); - poolClear(&tempPool); - handleDefault = XML_FALSE; - } - } - break; - case XML_ROLE_ENTITY_VALUE: - if (dtd->keepProcessing) { - enum XML_Error result = storeEntityValue(parser, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (declEntity) { - declEntity->textPtr = poolStart(&dtd->entityValuePool); - declEntity->textLen = poolLength(&dtd->entityValuePool); - poolFinish(&dtd->entityValuePool); - if (entityDeclHandler) { - *eventEndPP = s; - entityDeclHandler(handlerArg, - declEntity->name, - declEntity->is_param, - declEntity->textPtr, - declEntity->textLen, - curBase, 0, 0, 0); - handleDefault = XML_FALSE; - } - } - else - poolDiscard(&dtd->entityValuePool); - if (result != XML_ERROR_NONE) - return result; - } - break; - case XML_ROLE_DOCTYPE_SYSTEM_ID: -#ifdef XML_DTD - useForeignDTD = XML_FALSE; -#endif /* XML_DTD */ - dtd->hasParamEntityRefs = XML_TRUE; - if (startDoctypeDeclHandler) { - doctypeSysid = poolStoreString(&tempPool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (doctypeSysid == NULL) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - handleDefault = XML_FALSE; - } -#ifdef XML_DTD - else - /* use externalSubsetName to make doctypeSysid non-NULL - for the case where no startDoctypeDeclHandler is set */ - doctypeSysid = externalSubsetName; -#endif /* XML_DTD */ - if (!dtd->standalone -#ifdef XML_DTD - && !paramEntityParsing -#endif /* XML_DTD */ - && notStandaloneHandler - && !notStandaloneHandler(handlerArg)) - return XML_ERROR_NOT_STANDALONE; -#ifndef XML_DTD - break; -#else /* XML_DTD */ - if (!declEntity) { - declEntity = (ENTITY *)lookup(&dtd->paramEntities, - externalSubsetName, - sizeof(ENTITY)); - if (!declEntity) - return XML_ERROR_NO_MEMORY; - declEntity->publicId = NULL; - } - /* fall through */ -#endif /* XML_DTD */ - case XML_ROLE_ENTITY_SYSTEM_ID: - if (dtd->keepProcessing && declEntity) { - declEntity->systemId = poolStoreString(&dtd->pool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!declEntity->systemId) - return XML_ERROR_NO_MEMORY; - declEntity->base = curBase; - poolFinish(&dtd->pool); - if (entityDeclHandler) - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_ENTITY_COMPLETE: - if (dtd->keepProcessing && declEntity && entityDeclHandler) { - *eventEndPP = s; - entityDeclHandler(handlerArg, - declEntity->name, - declEntity->is_param, - 0,0, - declEntity->base, - declEntity->systemId, - declEntity->publicId, - 0); - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_ENTITY_NOTATION_NAME: - if (dtd->keepProcessing && declEntity) { - declEntity->notation = poolStoreString(&dtd->pool, enc, s, next); - if (!declEntity->notation) - return XML_ERROR_NO_MEMORY; - poolFinish(&dtd->pool); - if (unparsedEntityDeclHandler) { - *eventEndPP = s; - unparsedEntityDeclHandler(handlerArg, - declEntity->name, - declEntity->base, - declEntity->systemId, - declEntity->publicId, - declEntity->notation); - handleDefault = XML_FALSE; - } - else if (entityDeclHandler) { - *eventEndPP = s; - entityDeclHandler(handlerArg, - declEntity->name, - 0,0,0, - declEntity->base, - declEntity->systemId, - declEntity->publicId, - declEntity->notation); - handleDefault = XML_FALSE; - } - } - break; - case XML_ROLE_GENERAL_ENTITY_NAME: - { - if (XmlPredefinedEntityName(enc, s, next)) { - declEntity = NULL; - break; - } - if (dtd->keepProcessing) { - const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); - if (!name) - return XML_ERROR_NO_MEMORY; - declEntity = (ENTITY *)lookup(&dtd->generalEntities, name, - sizeof(ENTITY)); - if (!declEntity) - return XML_ERROR_NO_MEMORY; - if (declEntity->name != name) { - poolDiscard(&dtd->pool); - declEntity = NULL; - } - else { - poolFinish(&dtd->pool); - declEntity->publicId = NULL; - declEntity->is_param = XML_FALSE; - /* if we have a parent parser or are reading an internal parameter - entity, then the entity declaration is not considered "internal" - */ - declEntity->is_internal = !(parentParser || openInternalEntities); - if (entityDeclHandler) - handleDefault = XML_FALSE; - } - } - else { - poolDiscard(&dtd->pool); - declEntity = NULL; - } - } - break; - case XML_ROLE_PARAM_ENTITY_NAME: -#ifdef XML_DTD - if (dtd->keepProcessing) { - const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); - if (!name) - return XML_ERROR_NO_MEMORY; - declEntity = (ENTITY *)lookup(&dtd->paramEntities, - name, sizeof(ENTITY)); - if (!declEntity) - return XML_ERROR_NO_MEMORY; - if (declEntity->name != name) { - poolDiscard(&dtd->pool); - declEntity = NULL; - } - else { - poolFinish(&dtd->pool); - declEntity->publicId = NULL; - declEntity->is_param = XML_TRUE; - /* if we have a parent parser or are reading an internal parameter - entity, then the entity declaration is not considered "internal" - */ - declEntity->is_internal = !(parentParser || openInternalEntities); - if (entityDeclHandler) - handleDefault = XML_FALSE; - } - } - else { - poolDiscard(&dtd->pool); - declEntity = NULL; - } -#else /* not XML_DTD */ - declEntity = NULL; -#endif /* XML_DTD */ - break; - case XML_ROLE_NOTATION_NAME: - declNotationPublicId = NULL; - declNotationName = NULL; - if (notationDeclHandler) { - declNotationName = poolStoreString(&tempPool, enc, s, next); - if (!declNotationName) - return XML_ERROR_NO_MEMORY; - poolFinish(&tempPool); - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_NOTATION_PUBLIC_ID: - if (!XmlIsPublicId(enc, s, next, eventPP)) - return XML_ERROR_SYNTAX; - if (declNotationName) { /* means notationDeclHandler != NULL */ - XML_Char *tem = poolStoreString(&tempPool, - enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!tem) - return XML_ERROR_NO_MEMORY; - normalizePublicId(tem); - declNotationPublicId = tem; - poolFinish(&tempPool); - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_NOTATION_SYSTEM_ID: - if (declNotationName && notationDeclHandler) { - const XML_Char *systemId - = poolStoreString(&tempPool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!systemId) - return XML_ERROR_NO_MEMORY; - *eventEndPP = s; - notationDeclHandler(handlerArg, - declNotationName, - curBase, - systemId, - declNotationPublicId); - handleDefault = XML_FALSE; - } - poolClear(&tempPool); - break; - case XML_ROLE_NOTATION_NO_SYSTEM_ID: - if (declNotationPublicId && notationDeclHandler) { - *eventEndPP = s; - notationDeclHandler(handlerArg, - declNotationName, - curBase, - 0, - declNotationPublicId); - handleDefault = XML_FALSE; - } - poolClear(&tempPool); - break; - case XML_ROLE_ERROR: - switch (tok) { - case XML_TOK_PARAM_ENTITY_REF: - return XML_ERROR_PARAM_ENTITY_REF; - case XML_TOK_XML_DECL: - return XML_ERROR_MISPLACED_XML_PI; - default: - return XML_ERROR_SYNTAX; - } -#ifdef XML_DTD - case XML_ROLE_IGNORE_SECT: - { - enum XML_Error result; - if (defaultHandler) - reportDefault(parser, enc, s, next); - handleDefault = XML_FALSE; - result = doIgnoreSection(parser, enc, &next, end, nextPtr); - if (!next) { - processor = ignoreSectionProcessor; - return result; - } - } - break; -#endif /* XML_DTD */ - case XML_ROLE_GROUP_OPEN: - if (prologState.level >= groupSize) { - if (groupSize) { - char *temp = (char *)REALLOC(groupConnector, groupSize *= 2); - if (temp == NULL) - return XML_ERROR_NO_MEMORY; - groupConnector = temp; - if (dtd->scaffIndex) { - int *temp = (int *)REALLOC(dtd->scaffIndex, - groupSize * sizeof(int)); - if (temp == NULL) - return XML_ERROR_NO_MEMORY; - dtd->scaffIndex = temp; - } - } - else { - groupConnector = (char *)MALLOC(groupSize = 32); - if (!groupConnector) - return XML_ERROR_NO_MEMORY; - } - } - groupConnector[prologState.level] = 0; - if (dtd->in_eldecl) { - int myindex = nextScaffoldPart(parser); - if (myindex < 0) - return XML_ERROR_NO_MEMORY; - dtd->scaffIndex[dtd->scaffLevel] = myindex; - dtd->scaffLevel++; - dtd->scaffold[myindex].type = XML_CTYPE_SEQ; - if (elementDeclHandler) - handleDefault = XML_FALSE; - } - break; - case XML_ROLE_GROUP_SEQUENCE: - if (groupConnector[prologState.level] == '|') - return XML_ERROR_SYNTAX; - groupConnector[prologState.level] = ','; - if (dtd->in_eldecl && elementDeclHandler) - handleDefault = XML_FALSE; - break; - case XML_ROLE_GROUP_CHOICE: - if (groupConnector[prologState.level] == ',') - return XML_ERROR_SYNTAX; - if (dtd->in_eldecl - && !groupConnector[prologState.level] - && (dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type - != XML_CTYPE_MIXED) - ) { - dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type - = XML_CTYPE_CHOICE; - if (elementDeclHandler) - handleDefault = XML_FALSE; - } - groupConnector[prologState.level] = '|'; - break; - case XML_ROLE_PARAM_ENTITY_REF: -#ifdef XML_DTD - case XML_ROLE_INNER_PARAM_ENTITY_REF: - /* PE references in internal subset are - not allowed within declarations */ - if (prologState.documentEntity && - role == XML_ROLE_INNER_PARAM_ENTITY_REF) - return XML_ERROR_PARAM_ENTITY_REF; - dtd->hasParamEntityRefs = XML_TRUE; - if (!paramEntityParsing) - dtd->keepProcessing = dtd->standalone; - else { - const XML_Char *name; - ENTITY *entity; - name = poolStoreString(&dtd->pool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!name) - return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(&dtd->paramEntities, name, 0); - poolDiscard(&dtd->pool); - /* first, determine if a check for an existing declaration is needed; - if yes, check that the entity exists, and that it is internal, - otherwise call the skipped entity handler - */ - if (prologState.documentEntity && - (dtd->standalone - ? !openInternalEntities - : !dtd->hasParamEntityRefs)) { - if (!entity) - return XML_ERROR_UNDEFINED_ENTITY; - else if (!entity->is_internal) - return XML_ERROR_ENTITY_DECLARED_IN_PE; - } - else if (!entity) { - dtd->keepProcessing = dtd->standalone; - /* cannot report skipped entities in declarations */ - if ((role == XML_ROLE_PARAM_ENTITY_REF) && skippedEntityHandler) { - skippedEntityHandler(handlerArg, name, 1); - handleDefault = XML_FALSE; - } - break; - } - if (entity->open) - return XML_ERROR_RECURSIVE_ENTITY_REF; - if (entity->textPtr) { - enum XML_Error result; - result = processInternalParamEntity(parser, entity); - if (result != XML_ERROR_NONE) - return result; - handleDefault = XML_FALSE; - break; - } - if (externalEntityRefHandler) { - dtd->paramEntityRead = XML_FALSE; - entity->open = XML_TRUE; - if (!externalEntityRefHandler(externalEntityRefHandlerArg, - 0, - entity->base, - entity->systemId, - entity->publicId)) { - entity->open = XML_FALSE; - return XML_ERROR_EXTERNAL_ENTITY_HANDLING; - } - entity->open = XML_FALSE; - handleDefault = XML_FALSE; - if (!dtd->paramEntityRead) { - dtd->keepProcessing = dtd->standalone; - break; - } - } - else { - dtd->keepProcessing = dtd->standalone; - break; - } - } -#endif /* XML_DTD */ - if (!dtd->standalone && - notStandaloneHandler && - !notStandaloneHandler(handlerArg)) - return XML_ERROR_NOT_STANDALONE; - break; - - /* Element declaration stuff */ - - case XML_ROLE_ELEMENT_NAME: - if (elementDeclHandler) { - declElementType = getElementType(parser, enc, s, next); - if (!declElementType) - return XML_ERROR_NO_MEMORY; - dtd->scaffLevel = 0; - dtd->scaffCount = 0; - dtd->in_eldecl = XML_TRUE; - handleDefault = XML_FALSE; - } - break; - - case XML_ROLE_CONTENT_ANY: - case XML_ROLE_CONTENT_EMPTY: - if (dtd->in_eldecl) { - if (elementDeclHandler) { - XML_Content * content = (XML_Content *) MALLOC(sizeof(XML_Content)); - if (!content) - return XML_ERROR_NO_MEMORY; - content->quant = XML_CQUANT_NONE; - content->name = NULL; - content->numchildren = 0; - content->children = NULL; - content->type = ((role == XML_ROLE_CONTENT_ANY) ? - XML_CTYPE_ANY : - XML_CTYPE_EMPTY); - *eventEndPP = s; - elementDeclHandler(handlerArg, declElementType->name, content); - handleDefault = XML_FALSE; - } - dtd->in_eldecl = XML_FALSE; - } - break; - - case XML_ROLE_CONTENT_PCDATA: - if (dtd->in_eldecl) { - dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type - = XML_CTYPE_MIXED; - if (elementDeclHandler) - handleDefault = XML_FALSE; - } - break; - - case XML_ROLE_CONTENT_ELEMENT: - quant = XML_CQUANT_NONE; - goto elementContent; - case XML_ROLE_CONTENT_ELEMENT_OPT: - quant = XML_CQUANT_OPT; - goto elementContent; - case XML_ROLE_CONTENT_ELEMENT_REP: - quant = XML_CQUANT_REP; - goto elementContent; - case XML_ROLE_CONTENT_ELEMENT_PLUS: - quant = XML_CQUANT_PLUS; - elementContent: - if (dtd->in_eldecl) { - ELEMENT_TYPE *el; - const XML_Char *name; - int nameLen; - const char *nxt = (quant == XML_CQUANT_NONE - ? next - : next - enc->minBytesPerChar); - int myindex = nextScaffoldPart(parser); - if (myindex < 0) - return XML_ERROR_NO_MEMORY; - dtd->scaffold[myindex].type = XML_CTYPE_NAME; - dtd->scaffold[myindex].quant = quant; - el = getElementType(parser, enc, s, nxt); - if (!el) - return XML_ERROR_NO_MEMORY; - name = el->name; - dtd->scaffold[myindex].name = name; - nameLen = 0; - for (; name[nameLen++]; ); - dtd->contentStringLen += nameLen; - if (elementDeclHandler) - handleDefault = XML_FALSE; - } - break; - - case XML_ROLE_GROUP_CLOSE: - quant = XML_CQUANT_NONE; - goto closeGroup; - case XML_ROLE_GROUP_CLOSE_OPT: - quant = XML_CQUANT_OPT; - goto closeGroup; - case XML_ROLE_GROUP_CLOSE_REP: - quant = XML_CQUANT_REP; - goto closeGroup; - case XML_ROLE_GROUP_CLOSE_PLUS: - quant = XML_CQUANT_PLUS; - closeGroup: - if (dtd->in_eldecl) { - if (elementDeclHandler) - handleDefault = XML_FALSE; - dtd->scaffLevel--; - dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel]].quant = quant; - if (dtd->scaffLevel == 0) { - if (!handleDefault) { - XML_Content *model = build_model(parser); - if (!model) - return XML_ERROR_NO_MEMORY; - *eventEndPP = s; - elementDeclHandler(handlerArg, declElementType->name, model); - } - dtd->in_eldecl = XML_FALSE; - dtd->contentStringLen = 0; - } - } - break; - /* End element declaration stuff */ - - case XML_ROLE_PI: - if (!reportProcessingInstruction(parser, enc, s, next)) - return XML_ERROR_NO_MEMORY; - handleDefault = XML_FALSE; - break; - case XML_ROLE_COMMENT: - if (!reportComment(parser, enc, s, next)) - return XML_ERROR_NO_MEMORY; - handleDefault = XML_FALSE; - break; - case XML_ROLE_NONE: - switch (tok) { - case XML_TOK_BOM: - handleDefault = XML_FALSE; - break; - } - break; - case XML_ROLE_DOCTYPE_NONE: - if (startDoctypeDeclHandler) - handleDefault = XML_FALSE; - break; - case XML_ROLE_ENTITY_NONE: - if (dtd->keepProcessing && entityDeclHandler) - handleDefault = XML_FALSE; - break; - case XML_ROLE_NOTATION_NONE: - if (notationDeclHandler) - handleDefault = XML_FALSE; - break; - case XML_ROLE_ATTLIST_NONE: - if (dtd->keepProcessing && attlistDeclHandler) - handleDefault = XML_FALSE; - break; - case XML_ROLE_ELEMENT_NONE: - if (elementDeclHandler) - handleDefault = XML_FALSE; - break; - } /* end of big switch */ - - if (handleDefault && defaultHandler) - reportDefault(parser, enc, s, next); - - s = next; - tok = XmlPrologTok(enc, s, end, &next); - } - /* not reached */ -} - -static enum XML_Error PTRCALL -epilogProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - processor = epilogProcessor; - eventPtr = s; - for (;;) { - const char *next = NULL; - int tok = XmlPrologTok(encoding, s, end, &next); - eventEndPtr = next; - switch (tok) { - /* report partial linebreak - it might be the last token */ - case -XML_TOK_PROLOG_S: - if (defaultHandler) { - eventEndPtr = next; - reportDefault(parser, encoding, s, next); - } - if (nextPtr) - *nextPtr = next; - return XML_ERROR_NONE; - case XML_TOK_NONE: - if (nextPtr) - *nextPtr = s; - return XML_ERROR_NONE; - case XML_TOK_PROLOG_S: - if (defaultHandler) - reportDefault(parser, encoding, s, next); - break; - case XML_TOK_PI: - if (!reportProcessingInstruction(parser, encoding, s, next)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_COMMENT: - if (!reportComment(parser, encoding, s, next)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_INVALID: - eventPtr = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_UNCLOSED_TOKEN; - case XML_TOK_PARTIAL_CHAR: - if (nextPtr) { - *nextPtr = s; - return XML_ERROR_NONE; - } - return XML_ERROR_PARTIAL_CHAR; - default: - return XML_ERROR_JUNK_AFTER_DOC_ELEMENT; - } - eventPtr = s = next; - } -} - -#ifdef XML_DTD - -static enum XML_Error -processInternalParamEntity(XML_Parser parser, ENTITY *entity) -{ - const char *s, *end, *next; - int tok; - enum XML_Error result; - OPEN_INTERNAL_ENTITY openEntity; - entity->open = XML_TRUE; - openEntity.next = openInternalEntities; - openInternalEntities = &openEntity; - openEntity.entity = entity; - openEntity.internalEventPtr = NULL; - openEntity.internalEventEndPtr = NULL; - s = (char *)entity->textPtr; - end = (char *)(entity->textPtr + entity->textLen); - tok = XmlPrologTok(internalEncoding, s, end, &next); - result = doProlog(parser, internalEncoding, s, end, tok, next, 0); - entity->open = XML_FALSE; - openInternalEntities = openEntity.next; - return result; -} - -#endif /* XML_DTD */ - -static enum XML_Error PTRCALL -errorProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) -{ - return errorCode; -} - -static enum XML_Error -storeAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, - const char *ptr, const char *end, - STRING_POOL *pool) -{ - enum XML_Error result = appendAttributeValue(parser, enc, isCdata, ptr, - end, pool); - if (result) - return result; - if (!isCdata && poolLength(pool) && poolLastChar(pool) == 0x20) - poolChop(pool); - if (!poolAppendChar(pool, XML_T('\0'))) - return XML_ERROR_NO_MEMORY; - return XML_ERROR_NONE; -} - -static enum XML_Error -appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, - const char *ptr, const char *end, - STRING_POOL *pool) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - for (;;) { - const char *next; - int tok = XmlAttributeValueTok(enc, ptr, end, &next); - switch (tok) { - case XML_TOK_NONE: - return XML_ERROR_NONE; - case XML_TOK_INVALID: - if (enc == encoding) - eventPtr = next; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_PARTIAL: - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_INVALID_TOKEN; - case XML_TOK_CHAR_REF: - { - XML_Char buf[XML_ENCODE_MAX]; - int i; - int n = XmlCharRefNumber(enc, ptr); - if (n < 0) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_BAD_CHAR_REF; - } - if (!isCdata - && n == 0x20 /* space */ - && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) - break; - n = XmlEncode(n, (ICHAR *)buf); - if (!n) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_BAD_CHAR_REF; - } - for (i = 0; i < n; i++) { - if (!poolAppendChar(pool, buf[i])) - return XML_ERROR_NO_MEMORY; - } - } - break; - case XML_TOK_DATA_CHARS: - if (!poolAppend(pool, enc, ptr, next)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_TRAILING_CR: - next = ptr + enc->minBytesPerChar; - /* fall through */ - case XML_TOK_ATTRIBUTE_VALUE_S: - case XML_TOK_DATA_NEWLINE: - if (!isCdata && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) - break; - if (!poolAppendChar(pool, 0x20)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_ENTITY_REF: - { - const XML_Char *name; - ENTITY *entity; - char checkEntityDecl; - XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc, - ptr + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (ch) { - if (!poolAppendChar(pool, ch)) - return XML_ERROR_NO_MEMORY; - break; - } - name = poolStoreString(&temp2Pool, enc, - ptr + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!name) - return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(&dtd->generalEntities, name, 0); - poolDiscard(&temp2Pool); - /* first, determine if a check for an existing declaration is needed; - if yes, check that the entity exists, and that it is internal, - otherwise call the default handler (if called from content) - */ - if (pool == &dtd->pool) /* are we called from prolog? */ - checkEntityDecl = -#ifdef XML_DTD - prologState.documentEntity && -#endif /* XML_DTD */ - (dtd->standalone - ? !openInternalEntities - : !dtd->hasParamEntityRefs); - else /* if (pool == &tempPool): we are called from content */ - checkEntityDecl = !dtd->hasParamEntityRefs || dtd->standalone; - if (checkEntityDecl) { - if (!entity) - return XML_ERROR_UNDEFINED_ENTITY; - else if (!entity->is_internal) - return XML_ERROR_ENTITY_DECLARED_IN_PE; - } - else if (!entity) { - /* cannot report skipped entity here - see comments on - skippedEntityHandler - if (skippedEntityHandler) - skippedEntityHandler(handlerArg, name, 0); - */ - if ((pool == &tempPool) && defaultHandler) - reportDefault(parser, enc, ptr, next); - break; - } - if (entity->open) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_RECURSIVE_ENTITY_REF; - } - if (entity->notation) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_BINARY_ENTITY_REF; - } - if (!entity->textPtr) { - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF; - } - else { - enum XML_Error result; - const XML_Char *textEnd = entity->textPtr + entity->textLen; - entity->open = XML_TRUE; - result = appendAttributeValue(parser, internalEncoding, isCdata, - (char *)entity->textPtr, - (char *)textEnd, pool); - entity->open = XML_FALSE; - if (result) - return result; - } - } - break; - default: - if (enc == encoding) - eventPtr = ptr; - return XML_ERROR_UNEXPECTED_STATE; - } - ptr = next; - } - /* not reached */ -} - -static enum XML_Error -storeEntityValue(XML_Parser parser, - const ENCODING *enc, - const char *entityTextPtr, - const char *entityTextEnd) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - STRING_POOL *pool = &(dtd->entityValuePool); - enum XML_Error result = XML_ERROR_NONE; -#ifdef XML_DTD - int oldInEntityValue = prologState.inEntityValue; - prologState.inEntityValue = 1; -#endif /* XML_DTD */ - /* never return Null for the value argument in EntityDeclHandler, - since this would indicate an external entity; therefore we - have to make sure that entityValuePool.start is not null */ - if (!pool->blocks) { - if (!poolGrow(pool)) - return XML_ERROR_NO_MEMORY; - } - - for (;;) { - const char *next; - int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next); - switch (tok) { - case XML_TOK_PARAM_ENTITY_REF: -#ifdef XML_DTD - if (isParamEntity || enc != encoding) { - const XML_Char *name; - ENTITY *entity; - name = poolStoreString(&tempPool, enc, - entityTextPtr + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!name) { - result = XML_ERROR_NO_MEMORY; - goto endEntityValue; - } - entity = (ENTITY *)lookup(&dtd->paramEntities, name, 0); - poolDiscard(&tempPool); - if (!entity) { - /* not a well-formedness error - see XML 1.0: WFC Entity Declared */ - /* cannot report skipped entity here - see comments on - skippedEntityHandler - if (skippedEntityHandler) - skippedEntityHandler(handlerArg, name, 0); - */ - dtd->keepProcessing = dtd->standalone; - goto endEntityValue; - } - if (entity->open) { - if (enc == encoding) - eventPtr = entityTextPtr; - result = XML_ERROR_RECURSIVE_ENTITY_REF; - goto endEntityValue; - } - if (entity->systemId) { - if (externalEntityRefHandler) { - dtd->paramEntityRead = XML_FALSE; - entity->open = XML_TRUE; - if (!externalEntityRefHandler(externalEntityRefHandlerArg, - 0, - entity->base, - entity->systemId, - entity->publicId)) { - entity->open = XML_FALSE; - result = XML_ERROR_EXTERNAL_ENTITY_HANDLING; - goto endEntityValue; - } - entity->open = XML_FALSE; - if (!dtd->paramEntityRead) - dtd->keepProcessing = dtd->standalone; - } - else - dtd->keepProcessing = dtd->standalone; - } - else { - entity->open = XML_TRUE; - result = storeEntityValue(parser, - internalEncoding, - (char *)entity->textPtr, - (char *)(entity->textPtr - + entity->textLen)); - entity->open = XML_FALSE; - if (result) - goto endEntityValue; - } - break; - } -#endif /* XML_DTD */ - /* in the internal subset, PE references are not legal - within markup declarations, e.g entity values in this case */ - eventPtr = entityTextPtr; - result = XML_ERROR_PARAM_ENTITY_REF; - goto endEntityValue; - case XML_TOK_NONE: - result = XML_ERROR_NONE; - goto endEntityValue; - case XML_TOK_ENTITY_REF: - case XML_TOK_DATA_CHARS: - if (!poolAppend(pool, enc, entityTextPtr, next)) { - result = XML_ERROR_NO_MEMORY; - goto endEntityValue; - } - break; - case XML_TOK_TRAILING_CR: - next = entityTextPtr + enc->minBytesPerChar; - /* fall through */ - case XML_TOK_DATA_NEWLINE: - if (pool->end == pool->ptr && !poolGrow(pool)) { - result = XML_ERROR_NO_MEMORY; - goto endEntityValue; - } - *(pool->ptr)++ = 0xA; - break; - case XML_TOK_CHAR_REF: - { - XML_Char buf[XML_ENCODE_MAX]; - int i; - int n = XmlCharRefNumber(enc, entityTextPtr); - if (n < 0) { - if (enc == encoding) - eventPtr = entityTextPtr; - result = XML_ERROR_BAD_CHAR_REF; - goto endEntityValue; - } - n = XmlEncode(n, (ICHAR *)buf); - if (!n) { - if (enc == encoding) - eventPtr = entityTextPtr; - result = XML_ERROR_BAD_CHAR_REF; - goto endEntityValue; - } - for (i = 0; i < n; i++) { - if (pool->end == pool->ptr && !poolGrow(pool)) { - result = XML_ERROR_NO_MEMORY; - goto endEntityValue; - } - *(pool->ptr)++ = buf[i]; - } - } - break; - case XML_TOK_PARTIAL: - if (enc == encoding) - eventPtr = entityTextPtr; - result = XML_ERROR_INVALID_TOKEN; - goto endEntityValue; - case XML_TOK_INVALID: - if (enc == encoding) - eventPtr = next; - result = XML_ERROR_INVALID_TOKEN; - goto endEntityValue; - default: - if (enc == encoding) - eventPtr = entityTextPtr; - result = XML_ERROR_UNEXPECTED_STATE; - goto endEntityValue; - } - entityTextPtr = next; - } -endEntityValue: -#ifdef XML_DTD - prologState.inEntityValue = oldInEntityValue; -#endif /* XML_DTD */ - return result; -} - -static void FASTCALL -normalizeLines(XML_Char *s) -{ - XML_Char *p; - for (;; s++) { - if (*s == XML_T('\0')) - return; - if (*s == 0xD) - break; - } - p = s; - do { - if (*s == 0xD) { - *p++ = 0xA; - if (*++s == 0xA) - s++; - } - else - *p++ = *s++; - } while (*s); - *p = XML_T('\0'); -} - -static int -reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, - const char *start, const char *end) -{ - const XML_Char *target; - XML_Char *data; - const char *tem; - if (!processingInstructionHandler) { - if (defaultHandler) - reportDefault(parser, enc, start, end); - return 1; - } - start += enc->minBytesPerChar * 2; - tem = start + XmlNameLength(enc, start); - target = poolStoreString(&tempPool, enc, start, tem); - if (!target) - return 0; - poolFinish(&tempPool); - data = poolStoreString(&tempPool, enc, - XmlSkipS(enc, tem), - end - enc->minBytesPerChar*2); - if (!data) - return 0; - normalizeLines(data); - processingInstructionHandler(handlerArg, target, data); - poolClear(&tempPool); - return 1; -} - -static int -reportComment(XML_Parser parser, const ENCODING *enc, - const char *start, const char *end) -{ - XML_Char *data; - if (!commentHandler) { - if (defaultHandler) - reportDefault(parser, enc, start, end); - return 1; - } - data = poolStoreString(&tempPool, - enc, - start + enc->minBytesPerChar * 4, - end - enc->minBytesPerChar * 3); - if (!data) - return 0; - normalizeLines(data); - commentHandler(handlerArg, data); - poolClear(&tempPool); - return 1; -} - -static void -reportDefault(XML_Parser parser, const ENCODING *enc, - const char *s, const char *end) -{ - if (MUST_CONVERT(enc, s)) { - const char **eventPP; - const char **eventEndPP; - if (enc == encoding) { - eventPP = &eventPtr; - eventEndPP = &eventEndPtr; - } - else { - eventPP = &(openInternalEntities->internalEventPtr); - eventEndPP = &(openInternalEntities->internalEventEndPtr); - } - do { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = s; - defaultHandler(handlerArg, dataBuf, dataPtr - (ICHAR *)dataBuf); - *eventPP = s; - } while (s != end); - } - else - defaultHandler(handlerArg, (XML_Char *)s, (XML_Char *)end - (XML_Char *)s); -} - - -static int -defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata, - XML_Bool isId, const XML_Char *value, XML_Parser parser) -{ - DEFAULT_ATTRIBUTE *att; - if (value || isId) { - /* The handling of default attributes gets messed up if we have - a default which duplicates a non-default. */ - int i; - for (i = 0; i < type->nDefaultAtts; i++) - if (attId == type->defaultAtts[i].id) - return 1; - if (isId && !type->idAtt && !attId->xmlns) - type->idAtt = attId; - } - if (type->nDefaultAtts == type->allocDefaultAtts) { - if (type->allocDefaultAtts == 0) { - type->allocDefaultAtts = 8; - type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(type->allocDefaultAtts - * sizeof(DEFAULT_ATTRIBUTE)); - if (!type->defaultAtts) - return 0; - } - else { - DEFAULT_ATTRIBUTE *temp; - int count = type->allocDefaultAtts * 2; - temp = (DEFAULT_ATTRIBUTE *) - REALLOC(type->defaultAtts, (count * sizeof(DEFAULT_ATTRIBUTE))); - if (temp == NULL) - return 0; - type->allocDefaultAtts = count; - type->defaultAtts = temp; - } - } - att = type->defaultAtts + type->nDefaultAtts; - att->id = attId; - att->value = value; - att->isCdata = isCdata; - if (!isCdata) - attId->maybeTokenized = XML_TRUE; - type->nDefaultAtts += 1; - return 1; -} - -static int -setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - const XML_Char *name; - for (name = elementType->name; *name; name++) { - if (*name == XML_T(':')) { - PREFIX *prefix; - const XML_Char *s; - for (s = elementType->name; s != name; s++) { - if (!poolAppendChar(&dtd->pool, *s)) - return 0; - } - if (!poolAppendChar(&dtd->pool, XML_T('\0'))) - return 0; - prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&dtd->pool), - sizeof(PREFIX)); - if (!prefix) - return 0; - if (prefix->name == poolStart(&dtd->pool)) - poolFinish(&dtd->pool); - else - poolDiscard(&dtd->pool); - elementType->prefix = prefix; - - } - } - return 1; -} - -static ATTRIBUTE_ID * -getAttributeId(XML_Parser parser, const ENCODING *enc, - const char *start, const char *end) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - ATTRIBUTE_ID *id; - const XML_Char *name; - if (!poolAppendChar(&dtd->pool, XML_T('\0'))) - return NULL; - name = poolStoreString(&dtd->pool, enc, start, end); - if (!name) - return NULL; - /* skip quotation mark - its storage will be re-used (like in name[-1]) */ - ++name; - id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, name, sizeof(ATTRIBUTE_ID)); - if (!id) - return NULL; - if (id->name != name) - poolDiscard(&dtd->pool); - else { - poolFinish(&dtd->pool); - if (!ns) - ; - else if (name[0] == XML_T('x') - && name[1] == XML_T('m') - && name[2] == XML_T('l') - && name[3] == XML_T('n') - && name[4] == XML_T('s') - && (name[5] == XML_T('\0') || name[5] == XML_T(':'))) { - if (name[5] == XML_T('\0')) - id->prefix = &dtd->defaultPrefix; - else - id->prefix = (PREFIX *)lookup(&dtd->prefixes, name + 6, sizeof(PREFIX)); - id->xmlns = XML_TRUE; - } - else { - int i; - for (i = 0; name[i]; i++) { - /* attributes without prefix are *not* in the default namespace */ - if (name[i] == XML_T(':')) { - int j; - for (j = 0; j < i; j++) { - if (!poolAppendChar(&dtd->pool, name[j])) - return NULL; - } - if (!poolAppendChar(&dtd->pool, XML_T('\0'))) - return NULL; - id->prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&dtd->pool), - sizeof(PREFIX)); - if (id->prefix->name == poolStart(&dtd->pool)) - poolFinish(&dtd->pool); - else - poolDiscard(&dtd->pool); - break; - } - } - } - } - return id; -} - -#define CONTEXT_SEP XML_T('\f') - -static const XML_Char * -getContext(XML_Parser parser) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - HASH_TABLE_ITER iter; - XML_Bool needSep = XML_FALSE; - - if (dtd->defaultPrefix.binding) { - int i; - int len; - if (!poolAppendChar(&tempPool, XML_T('='))) - return NULL; - len = dtd->defaultPrefix.binding->uriLen; - if (namespaceSeparator != XML_T('\0')) - len--; - for (i = 0; i < len; i++) - if (!poolAppendChar(&tempPool, dtd->defaultPrefix.binding->uri[i])) - return NULL; - needSep = XML_TRUE; - } - - hashTableIterInit(&iter, &(dtd->prefixes)); - for (;;) { - int i; - int len; - const XML_Char *s; - PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter); - if (!prefix) - break; - if (!prefix->binding) - continue; - if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP)) - return NULL; - for (s = prefix->name; *s; s++) - if (!poolAppendChar(&tempPool, *s)) - return NULL; - if (!poolAppendChar(&tempPool, XML_T('='))) - return NULL; - len = prefix->binding->uriLen; - if (namespaceSeparator != XML_T('\0')) - len--; - for (i = 0; i < len; i++) - if (!poolAppendChar(&tempPool, prefix->binding->uri[i])) - return NULL; - needSep = XML_TRUE; - } - - - hashTableIterInit(&iter, &(dtd->generalEntities)); - for (;;) { - const XML_Char *s; - ENTITY *e = (ENTITY *)hashTableIterNext(&iter); - if (!e) - break; - if (!e->open) - continue; - if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP)) - return NULL; - for (s = e->name; *s; s++) - if (!poolAppendChar(&tempPool, *s)) - return 0; - needSep = XML_TRUE; - } - - if (!poolAppendChar(&tempPool, XML_T('\0'))) - return NULL; - return tempPool.start; -} - -static XML_Bool -setContext(XML_Parser parser, const XML_Char *context) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - const XML_Char *s = context; - - while (*context != XML_T('\0')) { - if (*s == CONTEXT_SEP || *s == XML_T('\0')) { - ENTITY *e; - if (!poolAppendChar(&tempPool, XML_T('\0'))) - return XML_FALSE; - e = (ENTITY *)lookup(&dtd->generalEntities, poolStart(&tempPool), 0); - if (e) - e->open = XML_TRUE; - if (*s != XML_T('\0')) - s++; - context = s; - poolDiscard(&tempPool); - } - else if (*s == XML_T('=')) { - PREFIX *prefix; - if (poolLength(&tempPool) == 0) - prefix = &dtd->defaultPrefix; - else { - if (!poolAppendChar(&tempPool, XML_T('\0'))) - return XML_FALSE; - prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&tempPool), - sizeof(PREFIX)); - if (!prefix) - return XML_FALSE; - if (prefix->name == poolStart(&tempPool)) { - prefix->name = poolCopyString(&dtd->pool, prefix->name); - if (!prefix->name) - return XML_FALSE; - } - poolDiscard(&tempPool); - } - for (context = s + 1; - *context != CONTEXT_SEP && *context != XML_T('\0'); - context++) - if (!poolAppendChar(&tempPool, *context)) - return XML_FALSE; - if (!poolAppendChar(&tempPool, XML_T('\0'))) - return XML_FALSE; - if (addBinding(parser, prefix, 0, poolStart(&tempPool), - &inheritedBindings) != XML_ERROR_NONE) - return XML_FALSE; - poolDiscard(&tempPool); - if (*context != XML_T('\0')) - ++context; - s = context; - } - else { - if (!poolAppendChar(&tempPool, *s)) - return XML_FALSE; - s++; - } - } - return XML_TRUE; -} - -static void FASTCALL -normalizePublicId(XML_Char *publicId) -{ - XML_Char *p = publicId; - XML_Char *s; - for (s = publicId; *s; s++) { - switch (*s) { - case 0x20: - case 0xD: - case 0xA: - if (p != publicId && p[-1] != 0x20) - *p++ = 0x20; - break; - default: - *p++ = *s; - } - } - if (p != publicId && p[-1] == 0x20) - --p; - *p = XML_T('\0'); -} - -static DTD * -dtdCreate(const XML_Memory_Handling_Suite *ms) -{ - DTD *p = (DTD *)ms->malloc_fcn(sizeof(DTD)); - if (p == NULL) - return p; - poolInit(&(p->pool), ms); -#ifdef XML_DTD - poolInit(&(p->entityValuePool), ms); -#endif /* XML_DTD */ - hashTableInit(&(p->generalEntities), ms); - hashTableInit(&(p->elementTypes), ms); - hashTableInit(&(p->attributeIds), ms); - hashTableInit(&(p->prefixes), ms); -#ifdef XML_DTD - p->paramEntityRead = XML_FALSE; - hashTableInit(&(p->paramEntities), ms); -#endif /* XML_DTD */ - p->defaultPrefix.name = NULL; - p->defaultPrefix.binding = NULL; - - p->in_eldecl = XML_FALSE; - p->scaffIndex = NULL; - p->scaffold = NULL; - p->scaffLevel = 0; - p->scaffSize = 0; - p->scaffCount = 0; - p->contentStringLen = 0; - - p->keepProcessing = XML_TRUE; - p->hasParamEntityRefs = XML_FALSE; - p->standalone = XML_FALSE; - return p; -} - -static void -dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms) -{ - HASH_TABLE_ITER iter; - hashTableIterInit(&iter, &(p->elementTypes)); - for (;;) { - ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); - if (!e) - break; - if (e->allocDefaultAtts != 0) - ms->free_fcn(e->defaultAtts); - } - hashTableClear(&(p->generalEntities)); -#ifdef XML_DTD - p->paramEntityRead = XML_FALSE; - hashTableClear(&(p->paramEntities)); -#endif /* XML_DTD */ - hashTableClear(&(p->elementTypes)); - hashTableClear(&(p->attributeIds)); - hashTableClear(&(p->prefixes)); - poolClear(&(p->pool)); -#ifdef XML_DTD - poolClear(&(p->entityValuePool)); -#endif /* XML_DTD */ - p->defaultPrefix.name = NULL; - p->defaultPrefix.binding = NULL; - - p->in_eldecl = XML_FALSE; - - ms->free_fcn(p->scaffIndex); - p->scaffIndex = NULL; - ms->free_fcn(p->scaffold); - p->scaffold = NULL; - - p->scaffLevel = 0; - p->scaffSize = 0; - p->scaffCount = 0; - p->contentStringLen = 0; - - p->keepProcessing = XML_TRUE; - p->hasParamEntityRefs = XML_FALSE; - p->standalone = XML_FALSE; -} - -static void -dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms) -{ - HASH_TABLE_ITER iter; - hashTableIterInit(&iter, &(p->elementTypes)); - for (;;) { - ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); - if (!e) - break; - if (e->allocDefaultAtts != 0) - ms->free_fcn(e->defaultAtts); - } - hashTableDestroy(&(p->generalEntities)); -#ifdef XML_DTD - hashTableDestroy(&(p->paramEntities)); -#endif /* XML_DTD */ - hashTableDestroy(&(p->elementTypes)); - hashTableDestroy(&(p->attributeIds)); - hashTableDestroy(&(p->prefixes)); - poolDestroy(&(p->pool)); -#ifdef XML_DTD - poolDestroy(&(p->entityValuePool)); -#endif /* XML_DTD */ - if (isDocEntity) { - ms->free_fcn(p->scaffIndex); - ms->free_fcn(p->scaffold); - } - ms->free_fcn(p); -} - -/* Do a deep copy of the DTD. Return 0 for out of memory, non-zero otherwise. - The new DTD has already been initialized. -*/ -static int -dtdCopy(DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms) -{ - HASH_TABLE_ITER iter; - - /* Copy the prefix table. */ - - hashTableIterInit(&iter, &(oldDtd->prefixes)); - for (;;) { - const XML_Char *name; - const PREFIX *oldP = (PREFIX *)hashTableIterNext(&iter); - if (!oldP) - break; - name = poolCopyString(&(newDtd->pool), oldP->name); - if (!name) - return 0; - if (!lookup(&(newDtd->prefixes), name, sizeof(PREFIX))) - return 0; - } - - hashTableIterInit(&iter, &(oldDtd->attributeIds)); - - /* Copy the attribute id table. */ - - for (;;) { - ATTRIBUTE_ID *newA; - const XML_Char *name; - const ATTRIBUTE_ID *oldA = (ATTRIBUTE_ID *)hashTableIterNext(&iter); - - if (!oldA) - break; - /* Remember to allocate the scratch byte before the name. */ - if (!poolAppendChar(&(newDtd->pool), XML_T('\0'))) - return 0; - name = poolCopyString(&(newDtd->pool), oldA->name); - if (!name) - return 0; - ++name; - newA = (ATTRIBUTE_ID *)lookup(&(newDtd->attributeIds), name, - sizeof(ATTRIBUTE_ID)); - if (!newA) - return 0; - newA->maybeTokenized = oldA->maybeTokenized; - if (oldA->prefix) { - newA->xmlns = oldA->xmlns; - if (oldA->prefix == &oldDtd->defaultPrefix) - newA->prefix = &newDtd->defaultPrefix; - else - newA->prefix = (PREFIX *)lookup(&(newDtd->prefixes), - oldA->prefix->name, 0); - } - } - - /* Copy the element type table. */ - - hashTableIterInit(&iter, &(oldDtd->elementTypes)); - - for (;;) { - int i; - ELEMENT_TYPE *newE; - const XML_Char *name; - const ELEMENT_TYPE *oldE = (ELEMENT_TYPE *)hashTableIterNext(&iter); - if (!oldE) - break; - name = poolCopyString(&(newDtd->pool), oldE->name); - if (!name) - return 0; - newE = (ELEMENT_TYPE *)lookup(&(newDtd->elementTypes), name, - sizeof(ELEMENT_TYPE)); - if (!newE) - return 0; - if (oldE->nDefaultAtts) { - newE->defaultAtts = (DEFAULT_ATTRIBUTE *) - ms->malloc_fcn(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE)); - if (!newE->defaultAtts) { - ms->free_fcn(newE); - return 0; - } - } - if (oldE->idAtt) - newE->idAtt = (ATTRIBUTE_ID *) - lookup(&(newDtd->attributeIds), oldE->idAtt->name, 0); - newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts; - if (oldE->prefix) - newE->prefix = (PREFIX *)lookup(&(newDtd->prefixes), - oldE->prefix->name, 0); - for (i = 0; i < newE->nDefaultAtts; i++) { - newE->defaultAtts[i].id = (ATTRIBUTE_ID *) - lookup(&(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0); - newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata; - if (oldE->defaultAtts[i].value) { - newE->defaultAtts[i].value - = poolCopyString(&(newDtd->pool), oldE->defaultAtts[i].value); - if (!newE->defaultAtts[i].value) - return 0; - } - else - newE->defaultAtts[i].value = NULL; - } - } - - /* Copy the entity tables. */ - if (!copyEntityTable(&(newDtd->generalEntities), - &(newDtd->pool), - &(oldDtd->generalEntities))) - return 0; - -#ifdef XML_DTD - if (!copyEntityTable(&(newDtd->paramEntities), - &(newDtd->pool), - &(oldDtd->paramEntities))) - return 0; - newDtd->paramEntityRead = oldDtd->paramEntityRead; -#endif /* XML_DTD */ - - newDtd->keepProcessing = oldDtd->keepProcessing; - newDtd->hasParamEntityRefs = oldDtd->hasParamEntityRefs; - newDtd->standalone = oldDtd->standalone; - - /* Don't want deep copying for scaffolding */ - newDtd->in_eldecl = oldDtd->in_eldecl; - newDtd->scaffold = oldDtd->scaffold; - newDtd->contentStringLen = oldDtd->contentStringLen; - newDtd->scaffSize = oldDtd->scaffSize; - newDtd->scaffLevel = oldDtd->scaffLevel; - newDtd->scaffIndex = oldDtd->scaffIndex; - - return 1; -} /* End dtdCopy */ - -static int -copyEntityTable(HASH_TABLE *newTable, - STRING_POOL *newPool, - const HASH_TABLE *oldTable) -{ - HASH_TABLE_ITER iter; - const XML_Char *cachedOldBase = NULL; - const XML_Char *cachedNewBase = NULL; - - hashTableIterInit(&iter, oldTable); - - for (;;) { - ENTITY *newE; - const XML_Char *name; - const ENTITY *oldE = (ENTITY *)hashTableIterNext(&iter); - if (!oldE) - break; - name = poolCopyString(newPool, oldE->name); - if (!name) - return 0; - newE = (ENTITY *)lookup(newTable, name, sizeof(ENTITY)); - if (!newE) - return 0; - if (oldE->systemId) { - const XML_Char *tem = poolCopyString(newPool, oldE->systemId); - if (!tem) - return 0; - newE->systemId = tem; - if (oldE->base) { - if (oldE->base == cachedOldBase) - newE->base = cachedNewBase; - else { - cachedOldBase = oldE->base; - tem = poolCopyString(newPool, cachedOldBase); - if (!tem) - return 0; - cachedNewBase = newE->base = tem; - } - } - if (oldE->publicId) { - tem = poolCopyString(newPool, oldE->publicId); - if (!tem) - return 0; - newE->publicId = tem; - } - } - else { - const XML_Char *tem = poolCopyStringN(newPool, oldE->textPtr, - oldE->textLen); - if (!tem) - return 0; - newE->textPtr = tem; - newE->textLen = oldE->textLen; - } - if (oldE->notation) { - const XML_Char *tem = poolCopyString(newPool, oldE->notation); - if (!tem) - return 0; - newE->notation = tem; - } - newE->is_param = oldE->is_param; - newE->is_internal = oldE->is_internal; - } - return 1; -} - -#define INIT_POWER 6 - -static XML_Bool FASTCALL -keyeq(KEY s1, KEY s2) -{ - for (; *s1 == *s2; s1++, s2++) - if (*s1 == 0) - return XML_TRUE; - return XML_FALSE; -} - -static unsigned long FASTCALL -hash(KEY s) -{ - unsigned long h = 0; - while (*s) - h = CHAR_HASH(h, *s++); - return h; -} - -static NAMED * -lookup(HASH_TABLE *table, KEY name, size_t createSize) -{ - size_t i; - if (table->size == 0) { - size_t tsize; - if (!createSize) - return NULL; - table->power = INIT_POWER; - /* table->size is a power of 2 */ - table->size = (size_t)1 << INIT_POWER; - tsize = table->size * sizeof(NAMED *); - table->v = (NAMED **)table->mem->malloc_fcn(tsize); - if (!table->v) - return NULL; - memset(table->v, 0, tsize); - i = hash(name) & ((unsigned long)table->size - 1); - } - else { - unsigned long h = hash(name); - unsigned long mask = (unsigned long)table->size - 1; - unsigned char step = 0; - i = h & mask; - while (table->v[i]) { - if (keyeq(name, table->v[i]->name)) - return table->v[i]; - if (!step) - step = PROBE_STEP(h, mask, table->power); - i < step ? (i += table->size - step) : (i -= step); - } - if (!createSize) - return NULL; - - /* check for overflow (table is half full) */ - if (table->used >> (table->power - 1)) { - unsigned char newPower = table->power + 1; - size_t newSize = (size_t)1 << newPower; - unsigned long newMask = (unsigned long)newSize - 1; - size_t tsize = newSize * sizeof(NAMED *); - NAMED **newV = (NAMED **)table->mem->malloc_fcn(tsize); - if (!newV) - return NULL; - memset(newV, 0, tsize); - for (i = 0; i < table->size; i++) - if (table->v[i]) { - unsigned long newHash = hash(table->v[i]->name); - size_t j = newHash & newMask; - step = 0; - while (newV[j]) { - if (!step) - step = PROBE_STEP(newHash, newMask, newPower); - j < step ? (j += newSize - step) : (j -= step); - } - newV[j] = table->v[i]; - } - table->mem->free_fcn(table->v); - table->v = newV; - table->power = newPower; - table->size = newSize; - i = h & newMask; - step = 0; - while (table->v[i]) { - if (!step) - step = PROBE_STEP(h, newMask, newPower); - i < step ? (i += newSize - step) : (i -= step); - } - } - } - table->v[i] = (NAMED *)table->mem->malloc_fcn(createSize); - if (!table->v[i]) - return NULL; - memset(table->v[i], 0, createSize); - table->v[i]->name = name; - (table->used)++; - return table->v[i]; -} - -static void FASTCALL -hashTableClear(HASH_TABLE *table) -{ - size_t i; - for (i = 0; i < table->size; i++) { - table->mem->free_fcn(table->v[i]); - table->v[i] = NULL; - } - table->used = 0; -} - -static void FASTCALL -hashTableDestroy(HASH_TABLE *table) -{ - size_t i; - for (i = 0; i < table->size; i++) - table->mem->free_fcn(table->v[i]); - table->mem->free_fcn(table->v); -} - -static void FASTCALL -hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms) -{ - p->power = 0; - p->size = 0; - p->used = 0; - p->v = NULL; - p->mem = ms; -} - -static void FASTCALL -hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table) -{ - iter->p = table->v; - iter->end = iter->p + table->size; -} - -static NAMED * FASTCALL -hashTableIterNext(HASH_TABLE_ITER *iter) -{ - while (iter->p != iter->end) { - NAMED *tem = *(iter->p)++; - if (tem) - return tem; - } - return NULL; -} - -static void FASTCALL -poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms) -{ - pool->blocks = NULL; - pool->freeBlocks = NULL; - pool->start = NULL; - pool->ptr = NULL; - pool->end = NULL; - pool->mem = ms; -} - -static void FASTCALL -poolClear(STRING_POOL *pool) -{ - if (!pool->freeBlocks) - pool->freeBlocks = pool->blocks; - else { - BLOCK *p = pool->blocks; - while (p) { - BLOCK *tem = p->next; - p->next = pool->freeBlocks; - pool->freeBlocks = p; - p = tem; - } - } - pool->blocks = NULL; - pool->start = NULL; - pool->ptr = NULL; - pool->end = NULL; -} - -static void FASTCALL -poolDestroy(STRING_POOL *pool) -{ - BLOCK *p = pool->blocks; - while (p) { - BLOCK *tem = p->next; - pool->mem->free_fcn(p); - p = tem; - } - p = pool->freeBlocks; - while (p) { - BLOCK *tem = p->next; - pool->mem->free_fcn(p); - p = tem; - } -} - -static XML_Char * -poolAppend(STRING_POOL *pool, const ENCODING *enc, - const char *ptr, const char *end) -{ - if (!pool->ptr && !poolGrow(pool)) - return NULL; - for (;;) { - XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end); - if (ptr == end) - break; - if (!poolGrow(pool)) - return NULL; - } - return pool->start; -} - -static const XML_Char * FASTCALL -poolCopyString(STRING_POOL *pool, const XML_Char *s) -{ - do { - if (!poolAppendChar(pool, *s)) - return NULL; - } while (*s++); - s = pool->start; - poolFinish(pool); - return s; -} - -static const XML_Char * -poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) -{ - if (!pool->ptr && !poolGrow(pool)) - return NULL; - for (; n > 0; --n, s++) { - if (!poolAppendChar(pool, *s)) - return NULL; - } - s = pool->start; - poolFinish(pool); - return s; -} - -static const XML_Char * FASTCALL -poolAppendString(STRING_POOL *pool, const XML_Char *s) -{ - while (*s) { - if (!poolAppendChar(pool, *s)) - return NULL; - s++; - } - return pool->start; -} - -static XML_Char * -poolStoreString(STRING_POOL *pool, const ENCODING *enc, - const char *ptr, const char *end) -{ - if (!poolAppend(pool, enc, ptr, end)) - return NULL; - if (pool->ptr == pool->end && !poolGrow(pool)) - return NULL; - *(pool->ptr)++ = 0; - return pool->start; -} - -static XML_Bool FASTCALL -poolGrow(STRING_POOL *pool) -{ - if (pool->freeBlocks) { - if (pool->start == 0) { - pool->blocks = pool->freeBlocks; - pool->freeBlocks = pool->freeBlocks->next; - pool->blocks->next = NULL; - pool->start = pool->blocks->s; - pool->end = pool->start + pool->blocks->size; - pool->ptr = pool->start; - return XML_TRUE; - } - if (pool->end - pool->start < pool->freeBlocks->size) { - BLOCK *tem = pool->freeBlocks->next; - pool->freeBlocks->next = pool->blocks; - pool->blocks = pool->freeBlocks; - pool->freeBlocks = tem; - memcpy(pool->blocks->s, pool->start, - (pool->end - pool->start) * sizeof(XML_Char)); - pool->ptr = pool->blocks->s + (pool->ptr - pool->start); - pool->start = pool->blocks->s; - pool->end = pool->start + pool->blocks->size; - return XML_TRUE; - } - } - if (pool->blocks && pool->start == pool->blocks->s) { - int blockSize = (pool->end - pool->start)*2; - pool->blocks = (BLOCK *) - pool->mem->realloc_fcn(pool->blocks, - (offsetof(BLOCK, s) - + blockSize * sizeof(XML_Char))); - if (pool->blocks == NULL) - return XML_FALSE; - pool->blocks->size = blockSize; - pool->ptr = pool->blocks->s + (pool->ptr - pool->start); - pool->start = pool->blocks->s; - pool->end = pool->start + blockSize; - } - else { - BLOCK *tem; - int blockSize = pool->end - pool->start; - if (blockSize < INIT_BLOCK_SIZE) - blockSize = INIT_BLOCK_SIZE; - else - blockSize *= 2; - tem = (BLOCK *)pool->mem->malloc_fcn(offsetof(BLOCK, s) - + blockSize * sizeof(XML_Char)); - if (!tem) - return XML_FALSE; - tem->size = blockSize; - tem->next = pool->blocks; - pool->blocks = tem; - if (pool->ptr != pool->start) - memcpy(tem->s, pool->start, - (pool->ptr - pool->start) * sizeof(XML_Char)); - pool->ptr = tem->s + (pool->ptr - pool->start); - pool->start = tem->s; - pool->end = tem->s + blockSize; - } - return XML_TRUE; -} - -static int FASTCALL -nextScaffoldPart(XML_Parser parser) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - CONTENT_SCAFFOLD * me; - int next; - - if (!dtd->scaffIndex) { - dtd->scaffIndex = (int *)MALLOC(groupSize * sizeof(int)); - if (!dtd->scaffIndex) - return -1; - dtd->scaffIndex[0] = 0; - } - - if (dtd->scaffCount >= dtd->scaffSize) { - CONTENT_SCAFFOLD *temp; - if (dtd->scaffold) { - temp = (CONTENT_SCAFFOLD *) - REALLOC(dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD)); - if (temp == NULL) - return -1; - dtd->scaffSize *= 2; - } - else { - temp = (CONTENT_SCAFFOLD *)MALLOC(INIT_SCAFFOLD_ELEMENTS - * sizeof(CONTENT_SCAFFOLD)); - if (temp == NULL) - return -1; - dtd->scaffSize = INIT_SCAFFOLD_ELEMENTS; - } - dtd->scaffold = temp; - } - next = dtd->scaffCount++; - me = &dtd->scaffold[next]; - if (dtd->scaffLevel) { - CONTENT_SCAFFOLD *parent = &dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel-1]]; - if (parent->lastchild) { - dtd->scaffold[parent->lastchild].nextsib = next; - } - if (!parent->childcnt) - parent->firstchild = next; - parent->lastchild = next; - parent->childcnt++; - } - me->firstchild = me->lastchild = me->childcnt = me->nextsib = 0; - return next; -} - -static void -build_node(XML_Parser parser, - int src_node, - XML_Content *dest, - XML_Content **contpos, - XML_Char **strpos) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - dest->type = dtd->scaffold[src_node].type; - dest->quant = dtd->scaffold[src_node].quant; - if (dest->type == XML_CTYPE_NAME) { - const XML_Char *src; - dest->name = *strpos; - src = dtd->scaffold[src_node].name; - for (;;) { - *(*strpos)++ = *src; - if (!*src) - break; - src++; - } - dest->numchildren = 0; - dest->children = NULL; - } - else { - unsigned int i; - int cn; - dest->numchildren = dtd->scaffold[src_node].childcnt; - dest->children = *contpos; - *contpos += dest->numchildren; - for (i = 0, cn = dtd->scaffold[src_node].firstchild; - i < dest->numchildren; - i++, cn = dtd->scaffold[cn].nextsib) { - build_node(parser, cn, &(dest->children[i]), contpos, strpos); - } - dest->name = NULL; - } -} - -static XML_Content * -build_model (XML_Parser parser) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - XML_Content *ret; - XML_Content *cpos; - XML_Char * str; - int allocsize = (dtd->scaffCount * sizeof(XML_Content) - + (dtd->contentStringLen * sizeof(XML_Char))); - - ret = (XML_Content *)MALLOC(allocsize); - if (!ret) - return NULL; - - str = (XML_Char *) (&ret[dtd->scaffCount]); - cpos = &ret[1]; - - build_node(parser, 0, ret, &cpos, &str); - return ret; -} - -static ELEMENT_TYPE * -getElementType(XML_Parser parser, - const ENCODING *enc, - const char *ptr, - const char *end) -{ - DTD * const dtd = _dtd; /* save one level of indirection */ - const XML_Char *name = poolStoreString(&dtd->pool, enc, ptr, end); - ELEMENT_TYPE *ret; - - if (!name) - return NULL; - ret = (ELEMENT_TYPE *) lookup(&dtd->elementTypes, name, sizeof(ELEMENT_TYPE)); - if (!ret) - return NULL; - if (ret->name != name) - poolDiscard(&dtd->pool); - else { - poolFinish(&dtd->pool); - if (!setElementTypePrefix(parser, ret)) - return NULL; - } - return ret; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlrole.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlrole.c deleted file mode 100644 index da6bc35e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlrole.c +++ /dev/null @@ -1,1323 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#ifdef COMPILED_FROM_DSP -#include "winconfig.h" -#elif defined(MACOS_CLASSIC) -#include "macconfig.h" -#else -#ifdef HAVE_EXPAT_CONFIG_H -#include -#endif -#endif /* ndef COMPILED_FROM_DSP */ - -#include "internal.h" -#include "xmlrole.h" -#include "ascii.h" - -/* Doesn't check: - - that ,| are not mixed in a model group - content of literals - -*/ - -static const char KW_ANY[] = { - ASCII_A, ASCII_N, ASCII_Y, '\0' }; -static const char KW_ATTLIST[] = { - ASCII_A, ASCII_T, ASCII_T, ASCII_L, ASCII_I, ASCII_S, ASCII_T, '\0' }; -static const char KW_CDATA[] = { - ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; -static const char KW_DOCTYPE[] = { - ASCII_D, ASCII_O, ASCII_C, ASCII_T, ASCII_Y, ASCII_P, ASCII_E, '\0' }; -static const char KW_ELEMENT[] = { - ASCII_E, ASCII_L, ASCII_E, ASCII_M, ASCII_E, ASCII_N, ASCII_T, '\0' }; -static const char KW_EMPTY[] = { - ASCII_E, ASCII_M, ASCII_P, ASCII_T, ASCII_Y, '\0' }; -static const char KW_ENTITIES[] = { - ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, - '\0' }; -static const char KW_ENTITY[] = { - ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' }; -static const char KW_FIXED[] = { - ASCII_F, ASCII_I, ASCII_X, ASCII_E, ASCII_D, '\0' }; -static const char KW_ID[] = { - ASCII_I, ASCII_D, '\0' }; -static const char KW_IDREF[] = { - ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' }; -static const char KW_IDREFS[] = { - ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; -static const char KW_IGNORE[] = { - ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' }; -static const char KW_IMPLIED[] = { - ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' }; -static const char KW_INCLUDE[] = { - ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' }; -static const char KW_NDATA[] = { - ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; -static const char KW_NMTOKEN[] = { - ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' }; -static const char KW_NMTOKENS[] = { - ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, - '\0' }; -static const char KW_NOTATION[] = - { ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, - '\0' }; -static const char KW_PCDATA[] = { - ASCII_P, ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; -static const char KW_PUBLIC[] = { - ASCII_P, ASCII_U, ASCII_B, ASCII_L, ASCII_I, ASCII_C, '\0' }; -static const char KW_REQUIRED[] = { - ASCII_R, ASCII_E, ASCII_Q, ASCII_U, ASCII_I, ASCII_R, ASCII_E, ASCII_D, - '\0' }; -static const char KW_SYSTEM[] = { - ASCII_S, ASCII_Y, ASCII_S, ASCII_T, ASCII_E, ASCII_M, '\0' }; - -#ifndef MIN_BYTES_PER_CHAR -#define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar) -#endif - -#ifdef XML_DTD -#define setTopLevel(state) \ - ((state)->handler = ((state)->documentEntity \ - ? internalSubset \ - : externalSubset1)) -#else /* not XML_DTD */ -#define setTopLevel(state) ((state)->handler = internalSubset) -#endif /* not XML_DTD */ - -typedef int PTRCALL PROLOG_HANDLER(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc); - -static PROLOG_HANDLER - prolog0, prolog1, prolog2, - doctype0, doctype1, doctype2, doctype3, doctype4, doctype5, - internalSubset, - entity0, entity1, entity2, entity3, entity4, entity5, entity6, - entity7, entity8, entity9, entity10, - notation0, notation1, notation2, notation3, notation4, - attlist0, attlist1, attlist2, attlist3, attlist4, attlist5, attlist6, - attlist7, attlist8, attlist9, - element0, element1, element2, element3, element4, element5, element6, - element7, -#ifdef XML_DTD - externalSubset0, externalSubset1, - condSect0, condSect1, condSect2, -#endif /* XML_DTD */ - declClose, - error; - -static int FASTCALL common(PROLOG_STATE *state, int tok); - -static int PTRCALL -prolog0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - state->handler = prolog1; - return XML_ROLE_NONE; - case XML_TOK_XML_DECL: - state->handler = prolog1; - return XML_ROLE_XML_DECL; - case XML_TOK_PI: - state->handler = prolog1; - return XML_ROLE_PI; - case XML_TOK_COMMENT: - state->handler = prolog1; - return XML_ROLE_COMMENT; - case XML_TOK_BOM: - return XML_ROLE_NONE; - case XML_TOK_DECL_OPEN: - if (!XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_DOCTYPE)) - break; - state->handler = doctype0; - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_INSTANCE_START: - state->handler = error; - return XML_ROLE_INSTANCE_START; - } - return common(state, tok); -} - -static int PTRCALL -prolog1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_PI: - return XML_ROLE_PI; - case XML_TOK_COMMENT: - return XML_ROLE_COMMENT; - case XML_TOK_BOM: - return XML_ROLE_NONE; - case XML_TOK_DECL_OPEN: - if (!XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_DOCTYPE)) - break; - state->handler = doctype0; - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_INSTANCE_START: - state->handler = error; - return XML_ROLE_INSTANCE_START; - } - return common(state, tok); -} - -static int PTRCALL -prolog2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_PI: - return XML_ROLE_PI; - case XML_TOK_COMMENT: - return XML_ROLE_COMMENT; - case XML_TOK_INSTANCE_START: - state->handler = error; - return XML_ROLE_INSTANCE_START; - } - return common(state, tok); -} - -static int PTRCALL -doctype0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = doctype1; - return XML_ROLE_DOCTYPE_NAME; - } - return common(state, tok); -} - -static int PTRCALL -doctype1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_OPEN_BRACKET: - state->handler = internalSubset; - return XML_ROLE_DOCTYPE_INTERNAL_SUBSET; - case XML_TOK_DECL_CLOSE: - state->handler = prolog2; - return XML_ROLE_DOCTYPE_CLOSE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { - state->handler = doctype3; - return XML_ROLE_DOCTYPE_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { - state->handler = doctype2; - return XML_ROLE_DOCTYPE_NONE; - } - break; - } - return common(state, tok); -} - -static int PTRCALL -doctype2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_LITERAL: - state->handler = doctype3; - return XML_ROLE_DOCTYPE_PUBLIC_ID; - } - return common(state, tok); -} - -static int PTRCALL -doctype3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_LITERAL: - state->handler = doctype4; - return XML_ROLE_DOCTYPE_SYSTEM_ID; - } - return common(state, tok); -} - -static int PTRCALL -doctype4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_OPEN_BRACKET: - state->handler = internalSubset; - return XML_ROLE_DOCTYPE_INTERNAL_SUBSET; - case XML_TOK_DECL_CLOSE: - state->handler = prolog2; - return XML_ROLE_DOCTYPE_CLOSE; - } - return common(state, tok); -} - -static int PTRCALL -doctype5(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_DOCTYPE_NONE; - case XML_TOK_DECL_CLOSE: - state->handler = prolog2; - return XML_ROLE_DOCTYPE_CLOSE; - } - return common(state, tok); -} - -static int PTRCALL -internalSubset(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_DECL_OPEN: - if (XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_ENTITY)) { - state->handler = entity0; - return XML_ROLE_ENTITY_NONE; - } - if (XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_ATTLIST)) { - state->handler = attlist0; - return XML_ROLE_ATTLIST_NONE; - } - if (XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_ELEMENT)) { - state->handler = element0; - return XML_ROLE_ELEMENT_NONE; - } - if (XmlNameMatchesAscii(enc, - ptr + 2 * MIN_BYTES_PER_CHAR(enc), - end, - KW_NOTATION)) { - state->handler = notation0; - return XML_ROLE_NOTATION_NONE; - } - break; - case XML_TOK_PI: - return XML_ROLE_PI; - case XML_TOK_COMMENT: - return XML_ROLE_COMMENT; - case XML_TOK_PARAM_ENTITY_REF: - return XML_ROLE_PARAM_ENTITY_REF; - case XML_TOK_CLOSE_BRACKET: - state->handler = doctype5; - return XML_ROLE_DOCTYPE_NONE; - } - return common(state, tok); -} - -#ifdef XML_DTD - -static int PTRCALL -externalSubset0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - state->handler = externalSubset1; - if (tok == XML_TOK_XML_DECL) - return XML_ROLE_TEXT_DECL; - return externalSubset1(state, tok, ptr, end, enc); -} - -static int PTRCALL -externalSubset1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_COND_SECT_OPEN: - state->handler = condSect0; - return XML_ROLE_NONE; - case XML_TOK_COND_SECT_CLOSE: - if (state->includeLevel == 0) - break; - state->includeLevel -= 1; - return XML_ROLE_NONE; - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_CLOSE_BRACKET: - break; - case XML_TOK_NONE: - if (state->includeLevel) - break; - return XML_ROLE_NONE; - default: - return internalSubset(state, tok, ptr, end, enc); - } - return common(state, tok); -} - -#endif /* XML_DTD */ - -static int PTRCALL -entity0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_PERCENT: - state->handler = entity1; - return XML_ROLE_ENTITY_NONE; - case XML_TOK_NAME: - state->handler = entity2; - return XML_ROLE_GENERAL_ENTITY_NAME; - } - return common(state, tok); -} - -static int PTRCALL -entity1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_NAME: - state->handler = entity7; - return XML_ROLE_PARAM_ENTITY_NAME; - } - return common(state, tok); -} - -static int PTRCALL -entity2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { - state->handler = entity4; - return XML_ROLE_ENTITY_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { - state->handler = entity3; - return XML_ROLE_ENTITY_NONE; - } - break; - case XML_TOK_LITERAL: - state->handler = declClose; - state->role_none = XML_ROLE_ENTITY_NONE; - return XML_ROLE_ENTITY_VALUE; - } - return common(state, tok); -} - -static int PTRCALL -entity3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_LITERAL: - state->handler = entity4; - return XML_ROLE_ENTITY_PUBLIC_ID; - } - return common(state, tok); -} - -static int PTRCALL -entity4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_LITERAL: - state->handler = entity5; - return XML_ROLE_ENTITY_SYSTEM_ID; - } - return common(state, tok); -} - -static int PTRCALL -entity5(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_DECL_CLOSE: - setTopLevel(state); - return XML_ROLE_ENTITY_COMPLETE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_NDATA)) { - state->handler = entity6; - return XML_ROLE_ENTITY_NONE; - } - break; - } - return common(state, tok); -} - -static int PTRCALL -entity6(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_NAME: - state->handler = declClose; - state->role_none = XML_ROLE_ENTITY_NONE; - return XML_ROLE_ENTITY_NOTATION_NAME; - } - return common(state, tok); -} - -static int PTRCALL -entity7(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { - state->handler = entity9; - return XML_ROLE_ENTITY_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { - state->handler = entity8; - return XML_ROLE_ENTITY_NONE; - } - break; - case XML_TOK_LITERAL: - state->handler = declClose; - state->role_none = XML_ROLE_ENTITY_NONE; - return XML_ROLE_ENTITY_VALUE; - } - return common(state, tok); -} - -static int PTRCALL -entity8(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_LITERAL: - state->handler = entity9; - return XML_ROLE_ENTITY_PUBLIC_ID; - } - return common(state, tok); -} - -static int PTRCALL -entity9(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_LITERAL: - state->handler = entity10; - return XML_ROLE_ENTITY_SYSTEM_ID; - } - return common(state, tok); -} - -static int PTRCALL -entity10(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ENTITY_NONE; - case XML_TOK_DECL_CLOSE: - setTopLevel(state); - return XML_ROLE_ENTITY_COMPLETE; - } - return common(state, tok); -} - -static int PTRCALL -notation0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NOTATION_NONE; - case XML_TOK_NAME: - state->handler = notation1; - return XML_ROLE_NOTATION_NAME; - } - return common(state, tok); -} - -static int PTRCALL -notation1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NOTATION_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { - state->handler = notation3; - return XML_ROLE_NOTATION_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { - state->handler = notation2; - return XML_ROLE_NOTATION_NONE; - } - break; - } - return common(state, tok); -} - -static int PTRCALL -notation2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NOTATION_NONE; - case XML_TOK_LITERAL: - state->handler = notation4; - return XML_ROLE_NOTATION_PUBLIC_ID; - } - return common(state, tok); -} - -static int PTRCALL -notation3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NOTATION_NONE; - case XML_TOK_LITERAL: - state->handler = declClose; - state->role_none = XML_ROLE_NOTATION_NONE; - return XML_ROLE_NOTATION_SYSTEM_ID; - } - return common(state, tok); -} - -static int PTRCALL -notation4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NOTATION_NONE; - case XML_TOK_LITERAL: - state->handler = declClose; - state->role_none = XML_ROLE_NOTATION_NONE; - return XML_ROLE_NOTATION_SYSTEM_ID; - case XML_TOK_DECL_CLOSE: - setTopLevel(state); - return XML_ROLE_NOTATION_NO_SYSTEM_ID; - } - return common(state, tok); -} - -static int PTRCALL -attlist0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = attlist1; - return XML_ROLE_ATTLIST_ELEMENT_NAME; - } - return common(state, tok); -} - -static int PTRCALL -attlist1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_DECL_CLOSE: - setTopLevel(state); - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = attlist2; - return XML_ROLE_ATTRIBUTE_NAME; - } - return common(state, tok); -} - -static int PTRCALL -attlist2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_NAME: - { - static const char *types[] = { - KW_CDATA, - KW_ID, - KW_IDREF, - KW_IDREFS, - KW_ENTITY, - KW_ENTITIES, - KW_NMTOKEN, - KW_NMTOKENS, - }; - int i; - for (i = 0; i < (int)(sizeof(types)/sizeof(types[0])); i++) - if (XmlNameMatchesAscii(enc, ptr, end, types[i])) { - state->handler = attlist8; - return XML_ROLE_ATTRIBUTE_TYPE_CDATA + i; - } - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_NOTATION)) { - state->handler = attlist5; - return XML_ROLE_ATTLIST_NONE; - } - break; - case XML_TOK_OPEN_PAREN: - state->handler = attlist3; - return XML_ROLE_ATTLIST_NONE; - } - return common(state, tok); -} - -static int PTRCALL -attlist3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_NMTOKEN: - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = attlist4; - return XML_ROLE_ATTRIBUTE_ENUM_VALUE; - } - return common(state, tok); -} - -static int PTRCALL -attlist4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_CLOSE_PAREN: - state->handler = attlist8; - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_OR: - state->handler = attlist3; - return XML_ROLE_ATTLIST_NONE; - } - return common(state, tok); -} - -static int PTRCALL -attlist5(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_OPEN_PAREN: - state->handler = attlist6; - return XML_ROLE_ATTLIST_NONE; - } - return common(state, tok); -} - -static int PTRCALL -attlist6(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_NAME: - state->handler = attlist7; - return XML_ROLE_ATTRIBUTE_NOTATION_VALUE; - } - return common(state, tok); -} - -static int PTRCALL -attlist7(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_CLOSE_PAREN: - state->handler = attlist8; - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_OR: - state->handler = attlist6; - return XML_ROLE_ATTLIST_NONE; - } - return common(state, tok); -} - -/* default value */ -static int PTRCALL -attlist8(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_POUND_NAME: - if (XmlNameMatchesAscii(enc, - ptr + MIN_BYTES_PER_CHAR(enc), - end, - KW_IMPLIED)) { - state->handler = attlist1; - return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE; - } - if (XmlNameMatchesAscii(enc, - ptr + MIN_BYTES_PER_CHAR(enc), - end, - KW_REQUIRED)) { - state->handler = attlist1; - return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE; - } - if (XmlNameMatchesAscii(enc, - ptr + MIN_BYTES_PER_CHAR(enc), - end, - KW_FIXED)) { - state->handler = attlist9; - return XML_ROLE_ATTLIST_NONE; - } - break; - case XML_TOK_LITERAL: - state->handler = attlist1; - return XML_ROLE_DEFAULT_ATTRIBUTE_VALUE; - } - return common(state, tok); -} - -static int PTRCALL -attlist9(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ATTLIST_NONE; - case XML_TOK_LITERAL: - state->handler = attlist1; - return XML_ROLE_FIXED_ATTRIBUTE_VALUE; - } - return common(state, tok); -} - -static int PTRCALL -element0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = element1; - return XML_ROLE_ELEMENT_NAME; - } - return common(state, tok); -} - -static int PTRCALL -element1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_EMPTY)) { - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - return XML_ROLE_CONTENT_EMPTY; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_ANY)) { - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - return XML_ROLE_CONTENT_ANY; - } - break; - case XML_TOK_OPEN_PAREN: - state->handler = element2; - state->level = 1; - return XML_ROLE_GROUP_OPEN; - } - return common(state, tok); -} - -static int PTRCALL -element2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_POUND_NAME: - if (XmlNameMatchesAscii(enc, - ptr + MIN_BYTES_PER_CHAR(enc), - end, - KW_PCDATA)) { - state->handler = element3; - return XML_ROLE_CONTENT_PCDATA; - } - break; - case XML_TOK_OPEN_PAREN: - state->level = 2; - state->handler = element6; - return XML_ROLE_GROUP_OPEN; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT; - case XML_TOK_NAME_QUESTION: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_OPT; - case XML_TOK_NAME_ASTERISK: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_REP; - case XML_TOK_NAME_PLUS: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_PLUS; - } - return common(state, tok); -} - -static int PTRCALL -element3(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_CLOSE_PAREN: - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - return XML_ROLE_GROUP_CLOSE; - case XML_TOK_CLOSE_PAREN_ASTERISK: - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - return XML_ROLE_GROUP_CLOSE_REP; - case XML_TOK_OR: - state->handler = element4; - return XML_ROLE_ELEMENT_NONE; - } - return common(state, tok); -} - -static int PTRCALL -element4(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = element5; - return XML_ROLE_CONTENT_ELEMENT; - } - return common(state, tok); -} - -static int PTRCALL -element5(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_CLOSE_PAREN_ASTERISK: - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - return XML_ROLE_GROUP_CLOSE_REP; - case XML_TOK_OR: - state->handler = element4; - return XML_ROLE_ELEMENT_NONE; - } - return common(state, tok); -} - -static int PTRCALL -element6(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_OPEN_PAREN: - state->level += 1; - return XML_ROLE_GROUP_OPEN; - case XML_TOK_NAME: - case XML_TOK_PREFIXED_NAME: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT; - case XML_TOK_NAME_QUESTION: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_OPT; - case XML_TOK_NAME_ASTERISK: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_REP; - case XML_TOK_NAME_PLUS: - state->handler = element7; - return XML_ROLE_CONTENT_ELEMENT_PLUS; - } - return common(state, tok); -} - -static int PTRCALL -element7(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_ELEMENT_NONE; - case XML_TOK_CLOSE_PAREN: - state->level -= 1; - if (state->level == 0) { - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - } - return XML_ROLE_GROUP_CLOSE; - case XML_TOK_CLOSE_PAREN_ASTERISK: - state->level -= 1; - if (state->level == 0) { - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - } - return XML_ROLE_GROUP_CLOSE_REP; - case XML_TOK_CLOSE_PAREN_QUESTION: - state->level -= 1; - if (state->level == 0) { - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - } - return XML_ROLE_GROUP_CLOSE_OPT; - case XML_TOK_CLOSE_PAREN_PLUS: - state->level -= 1; - if (state->level == 0) { - state->handler = declClose; - state->role_none = XML_ROLE_ELEMENT_NONE; - } - return XML_ROLE_GROUP_CLOSE_PLUS; - case XML_TOK_COMMA: - state->handler = element6; - return XML_ROLE_GROUP_SEQUENCE; - case XML_TOK_OR: - state->handler = element6; - return XML_ROLE_GROUP_CHOICE; - } - return common(state, tok); -} - -#ifdef XML_DTD - -static int PTRCALL -condSect0(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_NAME: - if (XmlNameMatchesAscii(enc, ptr, end, KW_INCLUDE)) { - state->handler = condSect1; - return XML_ROLE_NONE; - } - if (XmlNameMatchesAscii(enc, ptr, end, KW_IGNORE)) { - state->handler = condSect2; - return XML_ROLE_NONE; - } - break; - } - return common(state, tok); -} - -static int PTRCALL -condSect1(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_OPEN_BRACKET: - state->handler = externalSubset1; - state->includeLevel += 1; - return XML_ROLE_NONE; - } - return common(state, tok); -} - -static int PTRCALL -condSect2(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; - case XML_TOK_OPEN_BRACKET: - state->handler = externalSubset1; - return XML_ROLE_IGNORE_SECT; - } - return common(state, tok); -} - -#endif /* XML_DTD */ - -static int PTRCALL -declClose(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - switch (tok) { - case XML_TOK_PROLOG_S: - return state->role_none; - case XML_TOK_DECL_CLOSE: - setTopLevel(state); - return state->role_none; - } - return common(state, tok); -} - -static int PTRCALL -error(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc) -{ - return XML_ROLE_NONE; -} - -static int FASTCALL -common(PROLOG_STATE *state, int tok) -{ -#ifdef XML_DTD - if (!state->documentEntity && tok == XML_TOK_PARAM_ENTITY_REF) - return XML_ROLE_INNER_PARAM_ENTITY_REF; -#endif - state->handler = error; - return XML_ROLE_ERROR; -} - -void -XmlPrologStateInit(PROLOG_STATE *state) -{ - state->handler = prolog0; -#ifdef XML_DTD - state->documentEntity = 1; - state->includeLevel = 0; - state->inEntityValue = 0; -#endif /* XML_DTD */ -} - -#ifdef XML_DTD - -void -XmlPrologStateInitExternalEntity(PROLOG_STATE *state) -{ - state->handler = externalSubset0; - state->documentEntity = 0; - state->includeLevel = 0; -} - -#endif /* XML_DTD */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlrole.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlrole.h deleted file mode 100644 index 25be6b02..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlrole.h +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#ifndef XmlRole_INCLUDED -#define XmlRole_INCLUDED 1 - -#ifdef __VMS -/* 0 1 2 3 0 1 2 3 - 1234567890123456789012345678901 1234567890123456789012345678901 */ -#define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt -#endif - -#include "xmltok.h" - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - XML_ROLE_ERROR = -1, - XML_ROLE_NONE = 0, - XML_ROLE_XML_DECL, - XML_ROLE_INSTANCE_START, - XML_ROLE_DOCTYPE_NONE, - XML_ROLE_DOCTYPE_NAME, - XML_ROLE_DOCTYPE_SYSTEM_ID, - XML_ROLE_DOCTYPE_PUBLIC_ID, - XML_ROLE_DOCTYPE_INTERNAL_SUBSET, - XML_ROLE_DOCTYPE_CLOSE, - XML_ROLE_GENERAL_ENTITY_NAME, - XML_ROLE_PARAM_ENTITY_NAME, - XML_ROLE_ENTITY_NONE, - XML_ROLE_ENTITY_VALUE, - XML_ROLE_ENTITY_SYSTEM_ID, - XML_ROLE_ENTITY_PUBLIC_ID, - XML_ROLE_ENTITY_COMPLETE, - XML_ROLE_ENTITY_NOTATION_NAME, - XML_ROLE_NOTATION_NONE, - XML_ROLE_NOTATION_NAME, - XML_ROLE_NOTATION_SYSTEM_ID, - XML_ROLE_NOTATION_NO_SYSTEM_ID, - XML_ROLE_NOTATION_PUBLIC_ID, - XML_ROLE_ATTRIBUTE_NAME, - XML_ROLE_ATTRIBUTE_TYPE_CDATA, - XML_ROLE_ATTRIBUTE_TYPE_ID, - XML_ROLE_ATTRIBUTE_TYPE_IDREF, - XML_ROLE_ATTRIBUTE_TYPE_IDREFS, - XML_ROLE_ATTRIBUTE_TYPE_ENTITY, - XML_ROLE_ATTRIBUTE_TYPE_ENTITIES, - XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN, - XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS, - XML_ROLE_ATTRIBUTE_ENUM_VALUE, - XML_ROLE_ATTRIBUTE_NOTATION_VALUE, - XML_ROLE_ATTLIST_NONE, - XML_ROLE_ATTLIST_ELEMENT_NAME, - XML_ROLE_IMPLIED_ATTRIBUTE_VALUE, - XML_ROLE_REQUIRED_ATTRIBUTE_VALUE, - XML_ROLE_DEFAULT_ATTRIBUTE_VALUE, - XML_ROLE_FIXED_ATTRIBUTE_VALUE, - XML_ROLE_ELEMENT_NONE, - XML_ROLE_ELEMENT_NAME, - XML_ROLE_CONTENT_ANY, - XML_ROLE_CONTENT_EMPTY, - XML_ROLE_CONTENT_PCDATA, - XML_ROLE_GROUP_OPEN, - XML_ROLE_GROUP_CLOSE, - XML_ROLE_GROUP_CLOSE_REP, - XML_ROLE_GROUP_CLOSE_OPT, - XML_ROLE_GROUP_CLOSE_PLUS, - XML_ROLE_GROUP_CHOICE, - XML_ROLE_GROUP_SEQUENCE, - XML_ROLE_CONTENT_ELEMENT, - XML_ROLE_CONTENT_ELEMENT_REP, - XML_ROLE_CONTENT_ELEMENT_OPT, - XML_ROLE_CONTENT_ELEMENT_PLUS, - XML_ROLE_PI, - XML_ROLE_COMMENT, -#ifdef XML_DTD - XML_ROLE_TEXT_DECL, - XML_ROLE_IGNORE_SECT, - XML_ROLE_INNER_PARAM_ENTITY_REF, -#endif /* XML_DTD */ - XML_ROLE_PARAM_ENTITY_REF -}; - -typedef struct prolog_state { - int (PTRCALL *handler) (struct prolog_state *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc); - unsigned level; - int role_none; -#ifdef XML_DTD - unsigned includeLevel; - int documentEntity; - int inEntityValue; -#endif /* XML_DTD */ -} PROLOG_STATE; - -void XmlPrologStateInit(PROLOG_STATE *); -#ifdef XML_DTD -void XmlPrologStateInitExternalEntity(PROLOG_STATE *); -#endif /* XML_DTD */ - -#define XmlTokenRole(state, tok, ptr, end, enc) \ - (((state)->handler)(state, tok, ptr, end, enc)) - -#ifdef __cplusplus -} -#endif - -#endif /* not XmlRole_INCLUDED */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok.c deleted file mode 100644 index b1b1ee6d..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok.c +++ /dev/null @@ -1,1634 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#ifdef COMPILED_FROM_DSP -#include "winconfig.h" -#elif defined(MACOS_CLASSIC) -#include "macconfig.h" -#else -#ifdef HAVE_EXPAT_CONFIG_H -#include -#endif -#endif /* ndef COMPILED_FROM_DSP */ - -#include "internal.h" -#include "xmltok.h" -#include "nametab.h" - -#ifdef XML_DTD -#define IGNORE_SECTION_TOK_VTABLE , PREFIX(ignoreSectionTok) -#else -#define IGNORE_SECTION_TOK_VTABLE /* as nothing */ -#endif - -#define VTABLE1 \ - { PREFIX(prologTok), PREFIX(contentTok), \ - PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE }, \ - { PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \ - PREFIX(sameName), \ - PREFIX(nameMatchesAscii), \ - PREFIX(nameLength), \ - PREFIX(skipS), \ - PREFIX(getAtts), \ - PREFIX(charRefNumber), \ - PREFIX(predefinedEntityName), \ - PREFIX(updatePosition), \ - PREFIX(isPublicId) - -#define VTABLE VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16) - -#define UCS2_GET_NAMING(pages, hi, lo) \ - (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1 << ((lo) & 0x1F))) - -/* A 2 byte UTF-8 representation splits the characters 11 bits between - the bottom 5 and 6 bits of the bytes. We need 8 bits to index into - pages, 3 bits to add to that index and 5 bits to generate the mask. -*/ -#define UTF8_GET_NAMING2(pages, byte) \ - (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \ - + ((((byte)[0]) & 3) << 1) \ - + ((((byte)[1]) >> 5) & 1)] \ - & (1 << (((byte)[1]) & 0x1F))) - -/* A 3 byte UTF-8 representation splits the characters 16 bits between - the bottom 4, 6 and 6 bits of the bytes. We need 8 bits to index - into pages, 3 bits to add to that index and 5 bits to generate the - mask. -*/ -#define UTF8_GET_NAMING3(pages, byte) \ - (namingBitmap[((pages)[((((byte)[0]) & 0xF) << 4) \ - + ((((byte)[1]) >> 2) & 0xF)] \ - << 3) \ - + ((((byte)[1]) & 3) << 1) \ - + ((((byte)[2]) >> 5) & 1)] \ - & (1 << (((byte)[2]) & 0x1F))) - -#define UTF8_GET_NAMING(pages, p, n) \ - ((n) == 2 \ - ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \ - : ((n) == 3 \ - ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) \ - : 0)) - -/* Detection of invalid UTF-8 sequences is based on Table 3.1B - of Unicode 3.2: http://www.unicode.org/unicode/reports/tr28/ - with the additional restriction of not allowing the Unicode - code points 0xFFFF and 0xFFFE (sequences EF,BF,BF and EF,BF,BE). - Implementation details: - (A & 0x80) == 0 means A < 0x80 - and - (A & 0xC0) == 0xC0 means A > 0xBF -*/ - -#define UTF8_INVALID2(p) \ - ((*p) < 0xC2 || ((p)[1] & 0x80) == 0 || ((p)[1] & 0xC0) == 0xC0) - -#define UTF8_INVALID3(p) \ - (((p)[2] & 0x80) == 0 \ - || \ - ((*p) == 0xEF && (p)[1] == 0xBF \ - ? \ - (p)[2] > 0xBD \ - : \ - ((p)[2] & 0xC0) == 0xC0) \ - || \ - ((*p) == 0xE0 \ - ? \ - (p)[1] < 0xA0 || ((p)[1] & 0xC0) == 0xC0 \ - : \ - ((p)[1] & 0x80) == 0 \ - || \ - ((*p) == 0xED ? (p)[1] > 0x9F : ((p)[1] & 0xC0) == 0xC0))) - -#define UTF8_INVALID4(p) \ - (((p)[3] & 0x80) == 0 || ((p)[3] & 0xC0) == 0xC0 \ - || \ - ((p)[2] & 0x80) == 0 || ((p)[2] & 0xC0) == 0xC0 \ - || \ - ((*p) == 0xF0 \ - ? \ - (p)[1] < 0x90 || ((p)[1] & 0xC0) == 0xC0 \ - : \ - ((p)[1] & 0x80) == 0 \ - || \ - ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0))) - -static int PTRFASTCALL -isNever(const ENCODING *enc, const char *p) -{ - return 0; -} - -static int PTRFASTCALL -utf8_isName2(const ENCODING *enc, const char *p) -{ - return UTF8_GET_NAMING2(namePages, (const unsigned char *)p); -} - -static int PTRFASTCALL -utf8_isName3(const ENCODING *enc, const char *p) -{ - return UTF8_GET_NAMING3(namePages, (const unsigned char *)p); -} - -#define utf8_isName4 isNever - -static int PTRFASTCALL -utf8_isNmstrt2(const ENCODING *enc, const char *p) -{ - return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p); -} - -static int PTRFASTCALL -utf8_isNmstrt3(const ENCODING *enc, const char *p) -{ - return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p); -} - -#define utf8_isNmstrt4 isNever - -static int PTRFASTCALL -utf8_isInvalid2(const ENCODING *enc, const char *p) -{ - return UTF8_INVALID2((const unsigned char *)p); -} - -static int PTRFASTCALL -utf8_isInvalid3(const ENCODING *enc, const char *p) -{ - return UTF8_INVALID3((const unsigned char *)p); -} - -static int PTRFASTCALL -utf8_isInvalid4(const ENCODING *enc, const char *p) -{ - return UTF8_INVALID4((const unsigned char *)p); -} - -struct normal_encoding { - ENCODING enc; - unsigned char type[256]; -#ifdef XML_MIN_SIZE - int (PTRFASTCALL *byteType)(const ENCODING *, const char *); - int (PTRFASTCALL *isNameMin)(const ENCODING *, const char *); - int (PTRFASTCALL *isNmstrtMin)(const ENCODING *, const char *); - int (PTRFASTCALL *byteToAscii)(const ENCODING *, const char *); - int (PTRCALL *charMatches)(const ENCODING *, const char *, int); -#endif /* XML_MIN_SIZE */ - int (PTRFASTCALL *isName2)(const ENCODING *, const char *); - int (PTRFASTCALL *isName3)(const ENCODING *, const char *); - int (PTRFASTCALL *isName4)(const ENCODING *, const char *); - int (PTRFASTCALL *isNmstrt2)(const ENCODING *, const char *); - int (PTRFASTCALL *isNmstrt3)(const ENCODING *, const char *); - int (PTRFASTCALL *isNmstrt4)(const ENCODING *, const char *); - int (PTRFASTCALL *isInvalid2)(const ENCODING *, const char *); - int (PTRFASTCALL *isInvalid3)(const ENCODING *, const char *); - int (PTRFASTCALL *isInvalid4)(const ENCODING *, const char *); -}; - -#define AS_NORMAL_ENCODING(enc) ((const struct normal_encoding *) (enc)) - -#ifdef XML_MIN_SIZE - -#define STANDARD_VTABLE(E) \ - E ## byteType, \ - E ## isNameMin, \ - E ## isNmstrtMin, \ - E ## byteToAscii, \ - E ## charMatches, - -#else - -#define STANDARD_VTABLE(E) /* as nothing */ - -#endif - -#define NORMAL_VTABLE(E) \ - E ## isName2, \ - E ## isName3, \ - E ## isName4, \ - E ## isNmstrt2, \ - E ## isNmstrt3, \ - E ## isNmstrt4, \ - E ## isInvalid2, \ - E ## isInvalid3, \ - E ## isInvalid4 - -static int FASTCALL checkCharRefNumber(int); - -#include "xmltok_impl.h" -#include "ascii.h" - -#ifdef XML_MIN_SIZE -#define sb_isNameMin isNever -#define sb_isNmstrtMin isNever -#endif - -#ifdef XML_MIN_SIZE -#define MINBPC(enc) ((enc)->minBytesPerChar) -#else -/* minimum bytes per character */ -#define MINBPC(enc) 1 -#endif - -#define SB_BYTE_TYPE(enc, p) \ - (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)]) - -#ifdef XML_MIN_SIZE -static int PTRFASTCALL -sb_byteType(const ENCODING *enc, const char *p) -{ - return SB_BYTE_TYPE(enc, p); -} -#define BYTE_TYPE(enc, p) \ - (AS_NORMAL_ENCODING(enc)->byteType(enc, p)) -#else -#define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p) -#endif - -#ifdef XML_MIN_SIZE -#define BYTE_TO_ASCII(enc, p) \ - (AS_NORMAL_ENCODING(enc)->byteToAscii(enc, p)) -static int PTRFASTCALL -sb_byteToAscii(const ENCODING *enc, const char *p) -{ - return *p; -} -#else -#define BYTE_TO_ASCII(enc, p) (*(p)) -#endif - -#define IS_NAME_CHAR(enc, p, n) \ - (AS_NORMAL_ENCODING(enc)->isName ## n(enc, p)) -#define IS_NMSTRT_CHAR(enc, p, n) \ - (AS_NORMAL_ENCODING(enc)->isNmstrt ## n(enc, p)) -#define IS_INVALID_CHAR(enc, p, n) \ - (AS_NORMAL_ENCODING(enc)->isInvalid ## n(enc, p)) - -#ifdef XML_MIN_SIZE -#define IS_NAME_CHAR_MINBPC(enc, p) \ - (AS_NORMAL_ENCODING(enc)->isNameMin(enc, p)) -#define IS_NMSTRT_CHAR_MINBPC(enc, p) \ - (AS_NORMAL_ENCODING(enc)->isNmstrtMin(enc, p)) -#else -#define IS_NAME_CHAR_MINBPC(enc, p) (0) -#define IS_NMSTRT_CHAR_MINBPC(enc, p) (0) -#endif - -#ifdef XML_MIN_SIZE -#define CHAR_MATCHES(enc, p, c) \ - (AS_NORMAL_ENCODING(enc)->charMatches(enc, p, c)) -static int PTRCALL -sb_charMatches(const ENCODING *enc, const char *p, int c) -{ - return *p == c; -} -#else -/* c is an ASCII character */ -#define CHAR_MATCHES(enc, p, c) (*(p) == c) -#endif - -#define PREFIX(ident) normal_ ## ident -#include "xmltok_impl.c" - -#undef MINBPC -#undef BYTE_TYPE -#undef BYTE_TO_ASCII -#undef CHAR_MATCHES -#undef IS_NAME_CHAR -#undef IS_NAME_CHAR_MINBPC -#undef IS_NMSTRT_CHAR -#undef IS_NMSTRT_CHAR_MINBPC -#undef IS_INVALID_CHAR - -enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */ - UTF8_cval1 = 0x00, - UTF8_cval2 = 0xc0, - UTF8_cval3 = 0xe0, - UTF8_cval4 = 0xf0 -}; - -static void PTRCALL -utf8_toUtf8(const ENCODING *enc, - const char **fromP, const char *fromLim, - char **toP, const char *toLim) -{ - char *to; - const char *from; - if (fromLim - *fromP > toLim - *toP) { - /* Avoid copying partial characters. */ - for (fromLim = *fromP + (toLim - *toP); fromLim > *fromP; fromLim--) - if (((unsigned char)fromLim[-1] & 0xc0) != 0x80) - break; - } - for (to = *toP, from = *fromP; from != fromLim; from++, to++) - *to = *from; - *fromP = from; - *toP = to; -} - -static void PTRCALL -utf8_toUtf16(const ENCODING *enc, - const char **fromP, const char *fromLim, - unsigned short **toP, const unsigned short *toLim) -{ - unsigned short *to = *toP; - const char *from = *fromP; - while (from != fromLim && to != toLim) { - switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) { - case BT_LEAD2: - *to++ = (unsigned short)(((from[0] & 0x1f) << 6) | (from[1] & 0x3f)); - from += 2; - break; - case BT_LEAD3: - *to++ = (unsigned short)(((from[0] & 0xf) << 12) - | ((from[1] & 0x3f) << 6) | (from[2] & 0x3f)); - from += 3; - break; - case BT_LEAD4: - { - unsigned long n; - if (to + 1 == toLim) - goto after; - n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12) - | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f); - n -= 0x10000; - to[0] = (unsigned short)((n >> 10) | 0xD800); - to[1] = (unsigned short)((n & 0x3FF) | 0xDC00); - to += 2; - from += 4; - } - break; - default: - *to++ = *from++; - break; - } - } -after: - *fromP = from; - *toP = to; -} - -#ifdef XML_NS -static const struct normal_encoding utf8_encoding_ns = { - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, - { -#include "asciitab.h" -#include "utf8tab.h" - }, - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) -}; -#endif - -static const struct normal_encoding utf8_encoding = { - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -#include "utf8tab.h" - }, - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) -}; - -#ifdef XML_NS - -static const struct normal_encoding internal_utf8_encoding_ns = { - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, - { -#include "iasciitab.h" -#include "utf8tab.h" - }, - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) -}; - -#endif - -static const struct normal_encoding internal_utf8_encoding = { - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, - { -#define BT_COLON BT_NMSTRT -#include "iasciitab.h" -#undef BT_COLON -#include "utf8tab.h" - }, - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) -}; - -static void PTRCALL -latin1_toUtf8(const ENCODING *enc, - const char **fromP, const char *fromLim, - char **toP, const char *toLim) -{ - for (;;) { - unsigned char c; - if (*fromP == fromLim) - break; - c = (unsigned char)**fromP; - if (c & 0x80) { - if (toLim - *toP < 2) - break; - *(*toP)++ = (char)((c >> 6) | UTF8_cval2); - *(*toP)++ = (char)((c & 0x3f) | 0x80); - (*fromP)++; - } - else { - if (*toP == toLim) - break; - *(*toP)++ = *(*fromP)++; - } - } -} - -static void PTRCALL -latin1_toUtf16(const ENCODING *enc, - const char **fromP, const char *fromLim, - unsigned short **toP, const unsigned short *toLim) -{ - while (*fromP != fromLim && *toP != toLim) - *(*toP)++ = (unsigned char)*(*fromP)++; -} - -#ifdef XML_NS - -static const struct normal_encoding latin1_encoding_ns = { - { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 }, - { -#include "asciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(sb_) -}; - -#endif - -static const struct normal_encoding latin1_encoding = { - { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(sb_) -}; - -static void PTRCALL -ascii_toUtf8(const ENCODING *enc, - const char **fromP, const char *fromLim, - char **toP, const char *toLim) -{ - while (*fromP != fromLim && *toP != toLim) - *(*toP)++ = *(*fromP)++; -} - -#ifdef XML_NS - -static const struct normal_encoding ascii_encoding_ns = { - { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 }, - { -#include "asciitab.h" -/* BT_NONXML == 0 */ - }, - STANDARD_VTABLE(sb_) -}; - -#endif - -static const struct normal_encoding ascii_encoding = { - { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -/* BT_NONXML == 0 */ - }, - STANDARD_VTABLE(sb_) -}; - -static int PTRFASTCALL -unicode_byte_type(char hi, char lo) -{ - switch ((unsigned char)hi) { - case 0xD8: case 0xD9: case 0xDA: case 0xDB: - return BT_LEAD4; - case 0xDC: case 0xDD: case 0xDE: case 0xDF: - return BT_TRAIL; - case 0xFF: - switch ((unsigned char)lo) { - case 0xFF: - case 0xFE: - return BT_NONXML; - } - break; - } - return BT_NONASCII; -} - -#define DEFINE_UTF16_TO_UTF8(E) \ -static void PTRCALL \ -E ## toUtf8(const ENCODING *enc, \ - const char **fromP, const char *fromLim, \ - char **toP, const char *toLim) \ -{ \ - const char *from; \ - for (from = *fromP; from != fromLim; from += 2) { \ - int plane; \ - unsigned char lo2; \ - unsigned char lo = GET_LO(from); \ - unsigned char hi = GET_HI(from); \ - switch (hi) { \ - case 0: \ - if (lo < 0x80) { \ - if (*toP == toLim) { \ - *fromP = from; \ - return; \ - } \ - *(*toP)++ = lo; \ - break; \ - } \ - /* fall through */ \ - case 0x1: case 0x2: case 0x3: \ - case 0x4: case 0x5: case 0x6: case 0x7: \ - if (toLim - *toP < 2) { \ - *fromP = from; \ - return; \ - } \ - *(*toP)++ = ((lo >> 6) | (hi << 2) | UTF8_cval2); \ - *(*toP)++ = ((lo & 0x3f) | 0x80); \ - break; \ - default: \ - if (toLim - *toP < 3) { \ - *fromP = from; \ - return; \ - } \ - /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \ - *(*toP)++ = ((hi >> 4) | UTF8_cval3); \ - *(*toP)++ = (((hi & 0xf) << 2) | (lo >> 6) | 0x80); \ - *(*toP)++ = ((lo & 0x3f) | 0x80); \ - break; \ - case 0xD8: case 0xD9: case 0xDA: case 0xDB: \ - if (toLim - *toP < 4) { \ - *fromP = from; \ - return; \ - } \ - plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \ - *(*toP)++ = ((plane >> 2) | UTF8_cval4); \ - *(*toP)++ = (((lo >> 2) & 0xF) | ((plane & 0x3) << 4) | 0x80); \ - from += 2; \ - lo2 = GET_LO(from); \ - *(*toP)++ = (((lo & 0x3) << 4) \ - | ((GET_HI(from) & 0x3) << 2) \ - | (lo2 >> 6) \ - | 0x80); \ - *(*toP)++ = ((lo2 & 0x3f) | 0x80); \ - break; \ - } \ - } \ - *fromP = from; \ -} - -#define DEFINE_UTF16_TO_UTF16(E) \ -static void PTRCALL \ -E ## toUtf16(const ENCODING *enc, \ - const char **fromP, const char *fromLim, \ - unsigned short **toP, const unsigned short *toLim) \ -{ \ - /* Avoid copying first half only of surrogate */ \ - if (fromLim - *fromP > ((toLim - *toP) << 1) \ - && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) \ - fromLim -= 2; \ - for (; *fromP != fromLim && *toP != toLim; *fromP += 2) \ - *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \ -} - -#define SET2(ptr, ch) \ - (((ptr)[0] = ((ch) & 0xff)), ((ptr)[1] = ((ch) >> 8))) -#define GET_LO(ptr) ((unsigned char)(ptr)[0]) -#define GET_HI(ptr) ((unsigned char)(ptr)[1]) - -DEFINE_UTF16_TO_UTF8(little2_) -DEFINE_UTF16_TO_UTF16(little2_) - -#undef SET2 -#undef GET_LO -#undef GET_HI - -#define SET2(ptr, ch) \ - (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch) & 0xFF))) -#define GET_LO(ptr) ((unsigned char)(ptr)[1]) -#define GET_HI(ptr) ((unsigned char)(ptr)[0]) - -DEFINE_UTF16_TO_UTF8(big2_) -DEFINE_UTF16_TO_UTF16(big2_) - -#undef SET2 -#undef GET_LO -#undef GET_HI - -#define LITTLE2_BYTE_TYPE(enc, p) \ - ((p)[1] == 0 \ - ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \ - : unicode_byte_type((p)[1], (p)[0])) -#define LITTLE2_BYTE_TO_ASCII(enc, p) ((p)[1] == 0 ? (p)[0] : -1) -#define LITTLE2_CHAR_MATCHES(enc, p, c) ((p)[1] == 0 && (p)[0] == c) -#define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) \ - UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0]) -#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) \ - UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0]) - -#ifdef XML_MIN_SIZE - -static int PTRFASTCALL -little2_byteType(const ENCODING *enc, const char *p) -{ - return LITTLE2_BYTE_TYPE(enc, p); -} - -static int PTRFASTCALL -little2_byteToAscii(const ENCODING *enc, const char *p) -{ - return LITTLE2_BYTE_TO_ASCII(enc, p); -} - -static int PTRCALL -little2_charMatches(const ENCODING *enc, const char *p, int c) -{ - return LITTLE2_CHAR_MATCHES(enc, p, c); -} - -static int PTRFASTCALL -little2_isNameMin(const ENCODING *enc, const char *p) -{ - return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p); -} - -static int PTRFASTCALL -little2_isNmstrtMin(const ENCODING *enc, const char *p) -{ - return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p); -} - -#undef VTABLE -#define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16 - -#else /* not XML_MIN_SIZE */ - -#undef PREFIX -#define PREFIX(ident) little2_ ## ident -#define MINBPC(enc) 2 -/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ -#define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p) -#define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p) -#define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c) -#define IS_NAME_CHAR(enc, p, n) 0 -#define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) -#define IS_NMSTRT_CHAR(enc, p, n) (0) -#define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) - -#include "xmltok_impl.c" - -#undef MINBPC -#undef BYTE_TYPE -#undef BYTE_TO_ASCII -#undef CHAR_MATCHES -#undef IS_NAME_CHAR -#undef IS_NAME_CHAR_MINBPC -#undef IS_NMSTRT_CHAR -#undef IS_NMSTRT_CHAR_MINBPC -#undef IS_INVALID_CHAR - -#endif /* not XML_MIN_SIZE */ - -#ifdef XML_NS - -static const struct normal_encoding little2_encoding_ns = { - { VTABLE, 2, 0, -#if BYTEORDER == 1234 - 1 -#else - 0 -#endif - }, - { -#include "asciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(little2_) -}; - -#endif - -static const struct normal_encoding little2_encoding = { - { VTABLE, 2, 0, -#if BYTEORDER == 1234 - 1 -#else - 0 -#endif - }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(little2_) -}; - -#if BYTEORDER != 4321 - -#ifdef XML_NS - -static const struct normal_encoding internal_little2_encoding_ns = { - { VTABLE, 2, 0, 1 }, - { -#include "iasciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(little2_) -}; - -#endif - -static const struct normal_encoding internal_little2_encoding = { - { VTABLE, 2, 0, 1 }, - { -#define BT_COLON BT_NMSTRT -#include "iasciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(little2_) -}; - -#endif - - -#define BIG2_BYTE_TYPE(enc, p) \ - ((p)[0] == 0 \ - ? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \ - : unicode_byte_type((p)[0], (p)[1])) -#define BIG2_BYTE_TO_ASCII(enc, p) ((p)[0] == 0 ? (p)[1] : -1) -#define BIG2_CHAR_MATCHES(enc, p, c) ((p)[0] == 0 && (p)[1] == c) -#define BIG2_IS_NAME_CHAR_MINBPC(enc, p) \ - UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1]) -#define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) \ - UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1]) - -#ifdef XML_MIN_SIZE - -static int PTRFASTCALL -big2_byteType(const ENCODING *enc, const char *p) -{ - return BIG2_BYTE_TYPE(enc, p); -} - -static int PTRFASTCALL -big2_byteToAscii(const ENCODING *enc, const char *p) -{ - return BIG2_BYTE_TO_ASCII(enc, p); -} - -static int PTRCALL -big2_charMatches(const ENCODING *enc, const char *p, int c) -{ - return BIG2_CHAR_MATCHES(enc, p, c); -} - -static int PTRFASTCALL -big2_isNameMin(const ENCODING *enc, const char *p) -{ - return BIG2_IS_NAME_CHAR_MINBPC(enc, p); -} - -static int PTRFASTCALL -big2_isNmstrtMin(const ENCODING *enc, const char *p) -{ - return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p); -} - -#undef VTABLE -#define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16 - -#else /* not XML_MIN_SIZE */ - -#undef PREFIX -#define PREFIX(ident) big2_ ## ident -#define MINBPC(enc) 2 -/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ -#define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p) -#define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p) -#define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c) -#define IS_NAME_CHAR(enc, p, n) 0 -#define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p) -#define IS_NMSTRT_CHAR(enc, p, n) (0) -#define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) - -#include "xmltok_impl.c" - -#undef MINBPC -#undef BYTE_TYPE -#undef BYTE_TO_ASCII -#undef CHAR_MATCHES -#undef IS_NAME_CHAR -#undef IS_NAME_CHAR_MINBPC -#undef IS_NMSTRT_CHAR -#undef IS_NMSTRT_CHAR_MINBPC -#undef IS_INVALID_CHAR - -#endif /* not XML_MIN_SIZE */ - -#ifdef XML_NS - -static const struct normal_encoding big2_encoding_ns = { - { VTABLE, 2, 0, -#if BYTEORDER == 4321 - 1 -#else - 0 -#endif - }, - { -#include "asciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(big2_) -}; - -#endif - -static const struct normal_encoding big2_encoding = { - { VTABLE, 2, 0, -#if BYTEORDER == 4321 - 1 -#else - 0 -#endif - }, - { -#define BT_COLON BT_NMSTRT -#include "asciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(big2_) -}; - -#if BYTEORDER != 1234 - -#ifdef XML_NS - -static const struct normal_encoding internal_big2_encoding_ns = { - { VTABLE, 2, 0, 1 }, - { -#include "iasciitab.h" -#include "latin1tab.h" - }, - STANDARD_VTABLE(big2_) -}; - -#endif - -static const struct normal_encoding internal_big2_encoding = { - { VTABLE, 2, 0, 1 }, - { -#define BT_COLON BT_NMSTRT -#include "iasciitab.h" -#undef BT_COLON -#include "latin1tab.h" - }, - STANDARD_VTABLE(big2_) -}; - -#endif - -#undef PREFIX - -static int FASTCALL -streqci(const char *s1, const char *s2) -{ - for (;;) { - char c1 = *s1++; - char c2 = *s2++; - if (ASCII_a <= c1 && c1 <= ASCII_z) - c1 += ASCII_A - ASCII_a; - if (ASCII_a <= c2 && c2 <= ASCII_z) - c2 += ASCII_A - ASCII_a; - if (c1 != c2) - return 0; - if (!c1) - break; - } - return 1; -} - -static void PTRCALL -initUpdatePosition(const ENCODING *enc, const char *ptr, - const char *end, POSITION *pos) -{ - normal_updatePosition(&utf8_encoding.enc, ptr, end, pos); -} - -static int -toAscii(const ENCODING *enc, const char *ptr, const char *end) -{ - char buf[1]; - char *p = buf; - XmlUtf8Convert(enc, &ptr, end, &p, p + 1); - if (p == buf) - return -1; - else - return buf[0]; -} - -static int FASTCALL -isSpace(int c) -{ - switch (c) { - case 0x20: - case 0xD: - case 0xA: - case 0x9: - return 1; - } - return 0; -} - -/* Return 1 if there's just optional white space or there's an S - followed by name=val. -*/ -static int -parsePseudoAttribute(const ENCODING *enc, - const char *ptr, - const char *end, - const char **namePtr, - const char **nameEndPtr, - const char **valPtr, - const char **nextTokPtr) -{ - int c; - char open; - if (ptr == end) { - *namePtr = NULL; - return 1; - } - if (!isSpace(toAscii(enc, ptr, end))) { - *nextTokPtr = ptr; - return 0; - } - do { - ptr += enc->minBytesPerChar; - } while (isSpace(toAscii(enc, ptr, end))); - if (ptr == end) { - *namePtr = NULL; - return 1; - } - *namePtr = ptr; - for (;;) { - c = toAscii(enc, ptr, end); - if (c == -1) { - *nextTokPtr = ptr; - return 0; - } - if (c == ASCII_EQUALS) { - *nameEndPtr = ptr; - break; - } - if (isSpace(c)) { - *nameEndPtr = ptr; - do { - ptr += enc->minBytesPerChar; - } while (isSpace(c = toAscii(enc, ptr, end))); - if (c != ASCII_EQUALS) { - *nextTokPtr = ptr; - return 0; - } - break; - } - ptr += enc->minBytesPerChar; - } - if (ptr == *namePtr) { - *nextTokPtr = ptr; - return 0; - } - ptr += enc->minBytesPerChar; - c = toAscii(enc, ptr, end); - while (isSpace(c)) { - ptr += enc->minBytesPerChar; - c = toAscii(enc, ptr, end); - } - if (c != ASCII_QUOT && c != ASCII_APOS) { - *nextTokPtr = ptr; - return 0; - } - open = (char)c; - ptr += enc->minBytesPerChar; - *valPtr = ptr; - for (;; ptr += enc->minBytesPerChar) { - c = toAscii(enc, ptr, end); - if (c == open) - break; - if (!(ASCII_a <= c && c <= ASCII_z) - && !(ASCII_A <= c && c <= ASCII_Z) - && !(ASCII_0 <= c && c <= ASCII_9) - && c != ASCII_PERIOD - && c != ASCII_MINUS - && c != ASCII_UNDERSCORE) { - *nextTokPtr = ptr; - return 0; - } - } - *nextTokPtr = ptr + enc->minBytesPerChar; - return 1; -} - -static const char KW_version[] = { - ASCII_v, ASCII_e, ASCII_r, ASCII_s, ASCII_i, ASCII_o, ASCII_n, '\0' -}; - -static const char KW_encoding[] = { - ASCII_e, ASCII_n, ASCII_c, ASCII_o, ASCII_d, ASCII_i, ASCII_n, ASCII_g, '\0' -}; - -static const char KW_standalone[] = { - ASCII_s, ASCII_t, ASCII_a, ASCII_n, ASCII_d, ASCII_a, ASCII_l, ASCII_o, - ASCII_n, ASCII_e, '\0' -}; - -static const char KW_yes[] = { - ASCII_y, ASCII_e, ASCII_s, '\0' -}; - -static const char KW_no[] = { - ASCII_n, ASCII_o, '\0' -}; - -static int -doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *, - const char *, - const char *), - int isGeneralTextEntity, - const ENCODING *enc, - const char *ptr, - const char *end, - const char **badPtr, - const char **versionPtr, - const char **versionEndPtr, - const char **encodingName, - const ENCODING **encoding, - int *standalone) -{ - const char *val = NULL; - const char *name = NULL; - const char *nameEnd = NULL; - ptr += 5 * enc->minBytesPerChar; - end -= 2 * enc->minBytesPerChar; - if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr) - || !name) { - *badPtr = ptr; - return 0; - } - if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_version)) { - if (!isGeneralTextEntity) { - *badPtr = name; - return 0; - } - } - else { - if (versionPtr) - *versionPtr = val; - if (versionEndPtr) - *versionEndPtr = ptr; - if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) { - *badPtr = ptr; - return 0; - } - if (!name) { - if (isGeneralTextEntity) { - /* a TextDecl must have an EncodingDecl */ - *badPtr = ptr; - return 0; - } - return 1; - } - } - if (XmlNameMatchesAscii(enc, name, nameEnd, KW_encoding)) { - int c = toAscii(enc, val, end); - if (!(ASCII_a <= c && c <= ASCII_z) && !(ASCII_A <= c && c <= ASCII_Z)) { - *badPtr = val; - return 0; - } - if (encodingName) - *encodingName = val; - if (encoding) - *encoding = encodingFinder(enc, val, ptr - enc->minBytesPerChar); - if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) { - *badPtr = ptr; - return 0; - } - if (!name) - return 1; - } - if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_standalone) - || isGeneralTextEntity) { - *badPtr = name; - return 0; - } - if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_yes)) { - if (standalone) - *standalone = 1; - } - else if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_no)) { - if (standalone) - *standalone = 0; - } - else { - *badPtr = val; - return 0; - } - while (isSpace(toAscii(enc, ptr, end))) - ptr += enc->minBytesPerChar; - if (ptr != end) { - *badPtr = ptr; - return 0; - } - return 1; -} - -static int FASTCALL -checkCharRefNumber(int result) -{ - switch (result >> 8) { - case 0xD8: case 0xD9: case 0xDA: case 0xDB: - case 0xDC: case 0xDD: case 0xDE: case 0xDF: - return -1; - case 0: - if (latin1_encoding.type[result] == BT_NONXML) - return -1; - break; - case 0xFF: - if (result == 0xFFFE || result == 0xFFFF) - return -1; - break; - } - return result; -} - -int FASTCALL -XmlUtf8Encode(int c, char *buf) -{ - enum { - /* minN is minimum legal resulting value for N byte sequence */ - min2 = 0x80, - min3 = 0x800, - min4 = 0x10000 - }; - - if (c < 0) - return 0; - if (c < min2) { - buf[0] = (char)(c | UTF8_cval1); - return 1; - } - if (c < min3) { - buf[0] = (char)((c >> 6) | UTF8_cval2); - buf[1] = (char)((c & 0x3f) | 0x80); - return 2; - } - if (c < min4) { - buf[0] = (char)((c >> 12) | UTF8_cval3); - buf[1] = (char)(((c >> 6) & 0x3f) | 0x80); - buf[2] = (char)((c & 0x3f) | 0x80); - return 3; - } - if (c < 0x110000) { - buf[0] = (char)((c >> 18) | UTF8_cval4); - buf[1] = (char)(((c >> 12) & 0x3f) | 0x80); - buf[2] = (char)(((c >> 6) & 0x3f) | 0x80); - buf[3] = (char)((c & 0x3f) | 0x80); - return 4; - } - return 0; -} - -int FASTCALL -XmlUtf16Encode(int charNum, unsigned short *buf) -{ - if (charNum < 0) - return 0; - if (charNum < 0x10000) { - buf[0] = (unsigned short)charNum; - return 1; - } - if (charNum < 0x110000) { - charNum -= 0x10000; - buf[0] = (unsigned short)((charNum >> 10) + 0xD800); - buf[1] = (unsigned short)((charNum & 0x3FF) + 0xDC00); - return 2; - } - return 0; -} - -struct unknown_encoding { - struct normal_encoding normal; - int (*convert)(void *userData, const char *p); - void *userData; - unsigned short utf16[256]; - char utf8[256][4]; -}; - -#define AS_UNKNOWN_ENCODING(enc) ((const struct unknown_encoding *) (enc)) - -int -XmlSizeOfUnknownEncoding(void) -{ - return sizeof(struct unknown_encoding); -} - -static int PTRFASTCALL -unknown_isName(const ENCODING *enc, const char *p) -{ - const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); - int c = uenc->convert(uenc->userData, p); - if (c & ~0xFFFF) - return 0; - return UCS2_GET_NAMING(namePages, c >> 8, c & 0xFF); -} - -static int PTRFASTCALL -unknown_isNmstrt(const ENCODING *enc, const char *p) -{ - const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); - int c = uenc->convert(uenc->userData, p); - if (c & ~0xFFFF) - return 0; - return UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xFF); -} - -static int PTRFASTCALL -unknown_isInvalid(const ENCODING *enc, const char *p) -{ - const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); - int c = uenc->convert(uenc->userData, p); - return (c & ~0xFFFF) || checkCharRefNumber(c) < 0; -} - -static void PTRCALL -unknown_toUtf8(const ENCODING *enc, - const char **fromP, const char *fromLim, - char **toP, const char *toLim) -{ - const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); - char buf[XML_UTF8_ENCODE_MAX]; - for (;;) { - const char *utf8; - int n; - if (*fromP == fromLim) - break; - utf8 = uenc->utf8[(unsigned char)**fromP]; - n = *utf8++; - if (n == 0) { - int c = uenc->convert(uenc->userData, *fromP); - n = XmlUtf8Encode(c, buf); - if (n > toLim - *toP) - break; - utf8 = buf; - *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] - - (BT_LEAD2 - 2)); - } - else { - if (n > toLim - *toP) - break; - (*fromP)++; - } - do { - *(*toP)++ = *utf8++; - } while (--n != 0); - } -} - -static void PTRCALL -unknown_toUtf16(const ENCODING *enc, - const char **fromP, const char *fromLim, - unsigned short **toP, const unsigned short *toLim) -{ - const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); - while (*fromP != fromLim && *toP != toLim) { - unsigned short c = uenc->utf16[(unsigned char)**fromP]; - if (c == 0) { - c = (unsigned short) - uenc->convert(uenc->userData, *fromP); - *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] - - (BT_LEAD2 - 2)); - } - else - (*fromP)++; - *(*toP)++ = c; - } -} - -ENCODING * -XmlInitUnknownEncoding(void *mem, - int *table, - CONVERTER convert, - void *userData) -{ - int i; - struct unknown_encoding *e = (struct unknown_encoding *)mem; - for (i = 0; i < (int)sizeof(struct normal_encoding); i++) - ((char *)mem)[i] = ((char *)&latin1_encoding)[i]; - for (i = 0; i < 128; i++) - if (latin1_encoding.type[i] != BT_OTHER - && latin1_encoding.type[i] != BT_NONXML - && table[i] != i) - return 0; - for (i = 0; i < 256; i++) { - int c = table[i]; - if (c == -1) { - e->normal.type[i] = BT_MALFORM; - /* This shouldn't really get used. */ - e->utf16[i] = 0xFFFF; - e->utf8[i][0] = 1; - e->utf8[i][1] = 0; - } - else if (c < 0) { - if (c < -4) - return 0; - e->normal.type[i] = (unsigned char)(BT_LEAD2 - (c + 2)); - e->utf8[i][0] = 0; - e->utf16[i] = 0; - } - else if (c < 0x80) { - if (latin1_encoding.type[c] != BT_OTHER - && latin1_encoding.type[c] != BT_NONXML - && c != i) - return 0; - e->normal.type[i] = latin1_encoding.type[c]; - e->utf8[i][0] = 1; - e->utf8[i][1] = (char)c; - e->utf16[i] = (unsigned short)(c == 0 ? 0xFFFF : c); - } - else if (checkCharRefNumber(c) < 0) { - e->normal.type[i] = BT_NONXML; - /* This shouldn't really get used. */ - e->utf16[i] = 0xFFFF; - e->utf8[i][0] = 1; - e->utf8[i][1] = 0; - } - else { - if (c > 0xFFFF) - return 0; - if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff)) - e->normal.type[i] = BT_NMSTRT; - else if (UCS2_GET_NAMING(namePages, c >> 8, c & 0xff)) - e->normal.type[i] = BT_NAME; - else - e->normal.type[i] = BT_OTHER; - e->utf8[i][0] = (char)XmlUtf8Encode(c, e->utf8[i] + 1); - e->utf16[i] = (unsigned short)c; - } - } - e->userData = userData; - e->convert = convert; - if (convert) { - e->normal.isName2 = unknown_isName; - e->normal.isName3 = unknown_isName; - e->normal.isName4 = unknown_isName; - e->normal.isNmstrt2 = unknown_isNmstrt; - e->normal.isNmstrt3 = unknown_isNmstrt; - e->normal.isNmstrt4 = unknown_isNmstrt; - e->normal.isInvalid2 = unknown_isInvalid; - e->normal.isInvalid3 = unknown_isInvalid; - e->normal.isInvalid4 = unknown_isInvalid; - } - e->normal.enc.utf8Convert = unknown_toUtf8; - e->normal.enc.utf16Convert = unknown_toUtf16; - return &(e->normal.enc); -} - -/* If this enumeration is changed, getEncodingIndex and encodings -must also be changed. */ -enum { - UNKNOWN_ENC = -1, - ISO_8859_1_ENC = 0, - US_ASCII_ENC, - UTF_8_ENC, - UTF_16_ENC, - UTF_16BE_ENC, - UTF_16LE_ENC, - /* must match encodingNames up to here */ - NO_ENC -}; - -static const char KW_ISO_8859_1[] = { - ASCII_I, ASCII_S, ASCII_O, ASCII_MINUS, ASCII_8, ASCII_8, ASCII_5, ASCII_9, - ASCII_MINUS, ASCII_1, '\0' -}; -static const char KW_US_ASCII[] = { - ASCII_U, ASCII_S, ASCII_MINUS, ASCII_A, ASCII_S, ASCII_C, ASCII_I, ASCII_I, - '\0' -}; -static const char KW_UTF_8[] = { - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_8, '\0' -}; -static const char KW_UTF_16[] = { - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, '\0' -}; -static const char KW_UTF_16BE[] = { - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_B, ASCII_E, - '\0' -}; -static const char KW_UTF_16LE[] = { - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_L, ASCII_E, - '\0' -}; - -static int FASTCALL -getEncodingIndex(const char *name) -{ - static const char *encodingNames[] = { - KW_ISO_8859_1, - KW_US_ASCII, - KW_UTF_8, - KW_UTF_16, - KW_UTF_16BE, - KW_UTF_16LE, - }; - int i; - if (name == NULL) - return NO_ENC; - for (i = 0; i < (int)(sizeof(encodingNames)/sizeof(encodingNames[0])); i++) - if (streqci(name, encodingNames[i])) - return i; - return UNKNOWN_ENC; -} - -/* For binary compatibility, we store the index of the encoding - specified at initialization in the isUtf16 member. -*/ - -#define INIT_ENC_INDEX(enc) ((int)(enc)->initEnc.isUtf16) -#define SET_INIT_ENC_INDEX(enc, i) ((enc)->initEnc.isUtf16 = (char)i) - -/* This is what detects the encoding. encodingTable maps from - encoding indices to encodings; INIT_ENC_INDEX(enc) is the index of - the external (protocol) specified encoding; state is - XML_CONTENT_STATE if we're parsing an external text entity, and - XML_PROLOG_STATE otherwise. -*/ - - -static int -initScan(const ENCODING **encodingTable, - const INIT_ENCODING *enc, - int state, - const char *ptr, - const char *end, - const char **nextTokPtr) -{ - const ENCODING **encPtr; - - if (ptr == end) - return XML_TOK_NONE; - encPtr = enc->encPtr; - if (ptr + 1 == end) { - /* only a single byte available for auto-detection */ -#ifndef XML_DTD /* FIXME */ - /* a well-formed document entity must have more than one byte */ - if (state != XML_CONTENT_STATE) - return XML_TOK_PARTIAL; -#endif - /* so we're parsing an external text entity... */ - /* if UTF-16 was externally specified, then we need at least 2 bytes */ - switch (INIT_ENC_INDEX(enc)) { - case UTF_16_ENC: - case UTF_16LE_ENC: - case UTF_16BE_ENC: - return XML_TOK_PARTIAL; - } - switch ((unsigned char)*ptr) { - case 0xFE: - case 0xFF: - case 0xEF: /* possibly first byte of UTF-8 BOM */ - if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC - && state == XML_CONTENT_STATE) - break; - /* fall through */ - case 0x00: - case 0x3C: - return XML_TOK_PARTIAL; - } - } - else { - switch (((unsigned char)ptr[0] << 8) | (unsigned char)ptr[1]) { - case 0xFEFF: - if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC - && state == XML_CONTENT_STATE) - break; - *nextTokPtr = ptr + 2; - *encPtr = encodingTable[UTF_16BE_ENC]; - return XML_TOK_BOM; - /* 00 3C is handled in the default case */ - case 0x3C00: - if ((INIT_ENC_INDEX(enc) == UTF_16BE_ENC - || INIT_ENC_INDEX(enc) == UTF_16_ENC) - && state == XML_CONTENT_STATE) - break; - *encPtr = encodingTable[UTF_16LE_ENC]; - return XmlTok(*encPtr, state, ptr, end, nextTokPtr); - case 0xFFFE: - if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC - && state == XML_CONTENT_STATE) - break; - *nextTokPtr = ptr + 2; - *encPtr = encodingTable[UTF_16LE_ENC]; - return XML_TOK_BOM; - case 0xEFBB: - /* Maybe a UTF-8 BOM (EF BB BF) */ - /* If there's an explicitly specified (external) encoding - of ISO-8859-1 or some flavour of UTF-16 - and this is an external text entity, - don't look for the BOM, - because it might be a legal data. - */ - if (state == XML_CONTENT_STATE) { - int e = INIT_ENC_INDEX(enc); - if (e == ISO_8859_1_ENC || e == UTF_16BE_ENC - || e == UTF_16LE_ENC || e == UTF_16_ENC) - break; - } - if (ptr + 2 == end) - return XML_TOK_PARTIAL; - if ((unsigned char)ptr[2] == 0xBF) { - *nextTokPtr = ptr + 3; - *encPtr = encodingTable[UTF_8_ENC]; - return XML_TOK_BOM; - } - break; - default: - if (ptr[0] == '\0') { - /* 0 isn't a legal data character. Furthermore a document - entity can only start with ASCII characters. So the only - way this can fail to be big-endian UTF-16 if it it's an - external parsed general entity that's labelled as - UTF-16LE. - */ - if (state == XML_CONTENT_STATE && INIT_ENC_INDEX(enc) == UTF_16LE_ENC) - break; - *encPtr = encodingTable[UTF_16BE_ENC]; - return XmlTok(*encPtr, state, ptr, end, nextTokPtr); - } - else if (ptr[1] == '\0') { - /* We could recover here in the case: - - parsing an external entity - - second byte is 0 - - no externally specified encoding - - no encoding declaration - by assuming UTF-16LE. But we don't, because this would mean when - presented just with a single byte, we couldn't reliably determine - whether we needed further bytes. - */ - if (state == XML_CONTENT_STATE) - break; - *encPtr = encodingTable[UTF_16LE_ENC]; - return XmlTok(*encPtr, state, ptr, end, nextTokPtr); - } - break; - } - } - *encPtr = encodingTable[INIT_ENC_INDEX(enc)]; - return XmlTok(*encPtr, state, ptr, end, nextTokPtr); -} - - -#define NS(x) x -#define ns(x) x -#include "xmltok_ns.c" -#undef NS -#undef ns - -#ifdef XML_NS - -#define NS(x) x ## NS -#define ns(x) x ## _ns - -#include "xmltok_ns.c" - -#undef NS -#undef ns - -ENCODING * -XmlInitUnknownEncodingNS(void *mem, - int *table, - CONVERTER convert, - void *userData) -{ - ENCODING *enc = XmlInitUnknownEncoding(mem, table, convert, userData); - if (enc) - ((struct normal_encoding *)enc)->type[ASCII_COLON] = BT_COLON; - return enc; -} - -#endif /* XML_NS */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok.h deleted file mode 100644 index 811e3f26..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok.h +++ /dev/null @@ -1,315 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#ifndef XmlTok_INCLUDED -#define XmlTok_INCLUDED 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* The following token may be returned by XmlContentTok */ -#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be - start of illegal ]]> sequence */ -/* The following tokens may be returned by both XmlPrologTok and - XmlContentTok. -*/ -#define XML_TOK_NONE -4 /* The string to be scanned is empty */ -#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan; - might be part of CRLF sequence */ -#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */ -#define XML_TOK_PARTIAL -1 /* only part of a token */ -#define XML_TOK_INVALID 0 - -/* The following tokens are returned by XmlContentTok; some are also - returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok. -*/ -#define XML_TOK_START_TAG_WITH_ATTS 1 -#define XML_TOK_START_TAG_NO_ATTS 2 -#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag */ -#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4 -#define XML_TOK_END_TAG 5 -#define XML_TOK_DATA_CHARS 6 -#define XML_TOK_DATA_NEWLINE 7 -#define XML_TOK_CDATA_SECT_OPEN 8 -#define XML_TOK_ENTITY_REF 9 -#define XML_TOK_CHAR_REF 10 /* numeric character reference */ - -/* The following tokens may be returned by both XmlPrologTok and - XmlContentTok. -*/ -#define XML_TOK_PI 11 /* processing instruction */ -#define XML_TOK_XML_DECL 12 /* XML decl or text decl */ -#define XML_TOK_COMMENT 13 -#define XML_TOK_BOM 14 /* Byte order mark */ - -/* The following tokens are returned only by XmlPrologTok */ -#define XML_TOK_PROLOG_S 15 -#define XML_TOK_DECL_OPEN 16 /* */ -#define XML_TOK_NAME 18 -#define XML_TOK_NMTOKEN 19 -#define XML_TOK_POUND_NAME 20 /* #name */ -#define XML_TOK_OR 21 /* | */ -#define XML_TOK_PERCENT 22 -#define XML_TOK_OPEN_PAREN 23 -#define XML_TOK_CLOSE_PAREN 24 -#define XML_TOK_OPEN_BRACKET 25 -#define XML_TOK_CLOSE_BRACKET 26 -#define XML_TOK_LITERAL 27 -#define XML_TOK_PARAM_ENTITY_REF 28 -#define XML_TOK_INSTANCE_START 29 - -/* The following occur only in element type declarations */ -#define XML_TOK_NAME_QUESTION 30 /* name? */ -#define XML_TOK_NAME_ASTERISK 31 /* name* */ -#define XML_TOK_NAME_PLUS 32 /* name+ */ -#define XML_TOK_COND_SECT_OPEN 33 /* */ -#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */ -#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */ -#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */ -#define XML_TOK_COMMA 38 - -/* The following token is returned only by XmlAttributeValueTok */ -#define XML_TOK_ATTRIBUTE_VALUE_S 39 - -/* The following token is returned only by XmlCdataSectionTok */ -#define XML_TOK_CDATA_SECT_CLOSE 40 - -/* With namespace processing this is returned by XmlPrologTok for a - name with a colon. -*/ -#define XML_TOK_PREFIXED_NAME 41 - -#ifdef XML_DTD -#define XML_TOK_IGNORE_SECT 42 -#endif /* XML_DTD */ - -#ifdef XML_DTD -#define XML_N_STATES 4 -#else /* not XML_DTD */ -#define XML_N_STATES 3 -#endif /* not XML_DTD */ - -#define XML_PROLOG_STATE 0 -#define XML_CONTENT_STATE 1 -#define XML_CDATA_SECTION_STATE 2 -#ifdef XML_DTD -#define XML_IGNORE_SECTION_STATE 3 -#endif /* XML_DTD */ - -#define XML_N_LITERAL_TYPES 2 -#define XML_ATTRIBUTE_VALUE_LITERAL 0 -#define XML_ENTITY_VALUE_LITERAL 1 - -/* The size of the buffer passed to XmlUtf8Encode must be at least this. */ -#define XML_UTF8_ENCODE_MAX 4 -/* The size of the buffer passed to XmlUtf16Encode must be at least this. */ -#define XML_UTF16_ENCODE_MAX 2 - -typedef struct position { - /* first line and first column are 0 not 1 */ - unsigned long lineNumber; - unsigned long columnNumber; -} POSITION; - -typedef struct { - const char *name; - const char *valuePtr; - const char *valueEnd; - char normalized; -} ATTRIBUTE; - -struct encoding; -typedef struct encoding ENCODING; - -typedef int (PTRCALL *SCANNER)(const ENCODING *, - const char *, - const char *, - const char **); - -struct encoding { - SCANNER scanners[XML_N_STATES]; - SCANNER literalScanners[XML_N_LITERAL_TYPES]; - int (PTRCALL *sameName)(const ENCODING *, - const char *, - const char *); - int (PTRCALL *nameMatchesAscii)(const ENCODING *, - const char *, - const char *, - const char *); - int (PTRFASTCALL *nameLength)(const ENCODING *, const char *); - const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *); - int (PTRCALL *getAtts)(const ENCODING *enc, - const char *ptr, - int attsMax, - ATTRIBUTE *atts); - int (PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr); - int (PTRCALL *predefinedEntityName)(const ENCODING *, - const char *, - const char *); - void (PTRCALL *updatePosition)(const ENCODING *, - const char *ptr, - const char *end, - POSITION *); - int (PTRCALL *isPublicId)(const ENCODING *enc, - const char *ptr, - const char *end, - const char **badPtr); - void (PTRCALL *utf8Convert)(const ENCODING *enc, - const char **fromP, - const char *fromLim, - char **toP, - const char *toLim); - void (PTRCALL *utf16Convert)(const ENCODING *enc, - const char **fromP, - const char *fromLim, - unsigned short **toP, - const unsigned short *toLim); - int minBytesPerChar; - char isUtf8; - char isUtf16; -}; - -/* Scan the string starting at ptr until the end of the next complete - token, but do not scan past eptr. Return an integer giving the - type of token. - - Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set. - - Return XML_TOK_PARTIAL when the string does not contain a complete - token; nextTokPtr will not be set. - - Return XML_TOK_INVALID when the string does not start a valid - token; nextTokPtr will be set to point to the character which made - the token invalid. - - Otherwise the string starts with a valid token; nextTokPtr will be - set to point to the character following the end of that token. - - Each data character counts as a single token, but adjacent data - characters may be returned together. Similarly for characters in - the prolog outside literals, comments and processing instructions. -*/ - - -#define XmlTok(enc, state, ptr, end, nextTokPtr) \ - (((enc)->scanners[state])(enc, ptr, end, nextTokPtr)) - -#define XmlPrologTok(enc, ptr, end, nextTokPtr) \ - XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr) - -#define XmlContentTok(enc, ptr, end, nextTokPtr) \ - XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr) - -#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \ - XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr) - -#ifdef XML_DTD - -#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \ - XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr) - -#endif /* XML_DTD */ - -/* This is used for performing a 2nd-level tokenization on the content - of a literal that has already been returned by XmlTok. -*/ -#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \ - (((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr)) - -#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \ - XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr) - -#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \ - XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr) - -#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2)) - -#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \ - (((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2)) - -#define XmlNameLength(enc, ptr) \ - (((enc)->nameLength)(enc, ptr)) - -#define XmlSkipS(enc, ptr) \ - (((enc)->skipS)(enc, ptr)) - -#define XmlGetAttributes(enc, ptr, attsMax, atts) \ - (((enc)->getAtts)(enc, ptr, attsMax, atts)) - -#define XmlCharRefNumber(enc, ptr) \ - (((enc)->charRefNumber)(enc, ptr)) - -#define XmlPredefinedEntityName(enc, ptr, end) \ - (((enc)->predefinedEntityName)(enc, ptr, end)) - -#define XmlUpdatePosition(enc, ptr, end, pos) \ - (((enc)->updatePosition)(enc, ptr, end, pos)) - -#define XmlIsPublicId(enc, ptr, end, badPtr) \ - (((enc)->isPublicId)(enc, ptr, end, badPtr)) - -#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \ - (((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim)) - -#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \ - (((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim)) - -typedef struct { - ENCODING initEnc; - const ENCODING **encPtr; -} INIT_ENCODING; - -int XmlParseXmlDecl(int isGeneralTextEntity, - const ENCODING *enc, - const char *ptr, - const char *end, - const char **badPtr, - const char **versionPtr, - const char **versionEndPtr, - const char **encodingNamePtr, - const ENCODING **namedEncodingPtr, - int *standalonePtr); - -int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name); -const ENCODING *XmlGetUtf8InternalEncoding(void); -const ENCODING *XmlGetUtf16InternalEncoding(void); -int FASTCALL XmlUtf8Encode(int charNumber, char *buf); -int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf); -int XmlSizeOfUnknownEncoding(void); - -typedef int (*CONVERTER)(void *userData, const char *p); - -ENCODING * -XmlInitUnknownEncoding(void *mem, - int *table, - CONVERTER convert, - void *userData); - -int XmlParseXmlDeclNS(int isGeneralTextEntity, - const ENCODING *enc, - const char *ptr, - const char *end, - const char **badPtr, - const char **versionPtr, - const char **versionEndPtr, - const char **encodingNamePtr, - const ENCODING **namedEncodingPtr, - int *standalonePtr); - -int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name); -const ENCODING *XmlGetUtf8InternalEncodingNS(void); -const ENCODING *XmlGetUtf16InternalEncodingNS(void); -ENCODING * -XmlInitUnknownEncodingNS(void *mem, - int *table, - CONVERTER convert, - void *userData); -#ifdef __cplusplus -} -#endif - -#endif /* not XmlTok_INCLUDED */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_impl.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_impl.c deleted file mode 100644 index 9d13be3b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_impl.c +++ /dev/null @@ -1,1779 +0,0 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -#ifndef IS_INVALID_CHAR -#define IS_INVALID_CHAR(enc, ptr, n) (0) -#endif - -#define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \ - case BT_LEAD ## n: \ - if (end - ptr < n) \ - return XML_TOK_PARTIAL_CHAR; \ - if (IS_INVALID_CHAR(enc, ptr, n)) { \ - *(nextTokPtr) = (ptr); \ - return XML_TOK_INVALID; \ - } \ - ptr += n; \ - break; - -#define INVALID_CASES(ptr, nextTokPtr) \ - INVALID_LEAD_CASE(2, ptr, nextTokPtr) \ - INVALID_LEAD_CASE(3, ptr, nextTokPtr) \ - INVALID_LEAD_CASE(4, ptr, nextTokPtr) \ - case BT_NONXML: \ - case BT_MALFORM: \ - case BT_TRAIL: \ - *(nextTokPtr) = (ptr); \ - return XML_TOK_INVALID; - -#define CHECK_NAME_CASE(n, enc, ptr, end, nextTokPtr) \ - case BT_LEAD ## n: \ - if (end - ptr < n) \ - return XML_TOK_PARTIAL_CHAR; \ - if (!IS_NAME_CHAR(enc, ptr, n)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; \ - } \ - ptr += n; \ - break; - -#define CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) \ - case BT_NONASCII: \ - if (!IS_NAME_CHAR_MINBPC(enc, ptr)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; \ - } \ - case BT_NMSTRT: \ - case BT_HEX: \ - case BT_DIGIT: \ - case BT_NAME: \ - case BT_MINUS: \ - ptr += MINBPC(enc); \ - break; \ - CHECK_NAME_CASE(2, enc, ptr, end, nextTokPtr) \ - CHECK_NAME_CASE(3, enc, ptr, end, nextTokPtr) \ - CHECK_NAME_CASE(4, enc, ptr, end, nextTokPtr) - -#define CHECK_NMSTRT_CASE(n, enc, ptr, end, nextTokPtr) \ - case BT_LEAD ## n: \ - if (end - ptr < n) \ - return XML_TOK_PARTIAL_CHAR; \ - if (!IS_NMSTRT_CHAR(enc, ptr, n)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; \ - } \ - ptr += n; \ - break; - -#define CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) \ - case BT_NONASCII: \ - if (!IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; \ - } \ - case BT_NMSTRT: \ - case BT_HEX: \ - ptr += MINBPC(enc); \ - break; \ - CHECK_NMSTRT_CASE(2, enc, ptr, end, nextTokPtr) \ - CHECK_NMSTRT_CASE(3, enc, ptr, end, nextTokPtr) \ - CHECK_NMSTRT_CASE(4, enc, ptr, end, nextTokPtr) - -#ifndef PREFIX -#define PREFIX(ident) ident -#endif - -/* ptr points to character following " */ - switch (BYTE_TYPE(enc, ptr + MINBPC(enc))) { - case BT_S: case BT_CR: case BT_LF: case BT_PERCNT: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - /* fall through */ - case BT_S: case BT_CR: case BT_LF: - *nextTokPtr = ptr; - return XML_TOK_DECL_OPEN; - case BT_NMSTRT: - case BT_HEX: - ptr += MINBPC(enc); - break; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - } - return XML_TOK_PARTIAL; -} - -static int PTRCALL -PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, - const char *end, int *tokPtr) -{ - int upper = 0; - *tokPtr = XML_TOK_PI; - if (end - ptr != MINBPC(enc)*3) - return 1; - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_x: - break; - case ASCII_X: - upper = 1; - break; - default: - return 1; - } - ptr += MINBPC(enc); - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_m: - break; - case ASCII_M: - upper = 1; - break; - default: - return 1; - } - ptr += MINBPC(enc); - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_l: - break; - case ASCII_L: - upper = 1; - break; - default: - return 1; - } - if (upper) - return 0; - *tokPtr = XML_TOK_XML_DECL; - return 1; -} - -/* ptr points to character following " 1) { - size_t n = end - ptr; - if (n & (MINBPC(enc) - 1)) { - n &= ~(MINBPC(enc) - 1); - if (n == 0) - return XML_TOK_PARTIAL; - end = ptr + n; - } - } - switch (BYTE_TYPE(enc, ptr)) { - case BT_RSQB: - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_PARTIAL; - if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB)) - break; - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_PARTIAL; - if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) { - ptr -= MINBPC(enc); - break; - } - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_CDATA_SECT_CLOSE; - case BT_CR: - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_PARTIAL; - if (BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - *nextTokPtr = ptr; - return XML_TOK_DATA_NEWLINE; - case BT_LF: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DATA_NEWLINE; - INVALID_CASES(ptr, nextTokPtr) - default: - ptr += MINBPC(enc); - break; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_DATA_CHARS; \ - } \ - ptr += n; \ - break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_NONXML: - case BT_MALFORM: - case BT_TRAIL: - case BT_CR: - case BT_LF: - case BT_RSQB: - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - default: - ptr += MINBPC(enc); - break; - } - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; -} - -/* ptr points to character following " 1) { - size_t n = end - ptr; - if (n & (MINBPC(enc) - 1)) { - n &= ~(MINBPC(enc) - 1); - if (n == 0) - return XML_TOK_PARTIAL; - end = ptr + n; - } - } - switch (BYTE_TYPE(enc, ptr)) { - case BT_LT: - return PREFIX(scanLt)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_AMP: - return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_CR: - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_CR; - if (BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - *nextTokPtr = ptr; - return XML_TOK_DATA_NEWLINE; - case BT_LF: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DATA_NEWLINE; - case BT_RSQB: - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_RSQB; - if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB)) - break; - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_RSQB; - if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) { - ptr -= MINBPC(enc); - break; - } - *nextTokPtr = ptr; - return XML_TOK_INVALID; - INVALID_CASES(ptr, nextTokPtr) - default: - ptr += MINBPC(enc); - break; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \ - *nextTokPtr = ptr; \ - return XML_TOK_DATA_CHARS; \ - } \ - ptr += n; \ - break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_RSQB: - if (ptr + MINBPC(enc) != end) { - if (!CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_RSQB)) { - ptr += MINBPC(enc); - break; - } - if (ptr + 2*MINBPC(enc) != end) { - if (!CHAR_MATCHES(enc, ptr + 2*MINBPC(enc), ASCII_GT)) { - ptr += MINBPC(enc); - break; - } - *nextTokPtr = ptr + 2*MINBPC(enc); - return XML_TOK_INVALID; - } - } - /* fall through */ - case BT_AMP: - case BT_LT: - case BT_NONXML: - case BT_MALFORM: - case BT_TRAIL: - case BT_CR: - case BT_LF: - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - default: - ptr += MINBPC(enc); - break; - } - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; -} - -/* ptr points to character following "%" */ - -static int PTRCALL -PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - if (ptr == end) - return -XML_TOK_PERCENT; - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) - case BT_S: case BT_LF: case BT_CR: case BT_PERCNT: - *nextTokPtr = ptr; - return XML_TOK_PERCENT; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) - case BT_SEMI: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_PARAM_ENTITY_REF; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - } - return XML_TOK_PARTIAL; -} - -static int PTRCALL -PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - if (ptr == end) - return XML_TOK_PARTIAL; - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) - case BT_CR: case BT_LF: case BT_S: - case BT_RPAR: case BT_GT: case BT_PERCNT: case BT_VERBAR: - *nextTokPtr = ptr; - return XML_TOK_POUND_NAME; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - } - return -XML_TOK_POUND_NAME; -} - -static int PTRCALL -PREFIX(scanLit)(int open, const ENCODING *enc, - const char *ptr, const char *end, - const char **nextTokPtr) -{ - while (ptr != end) { - int t = BYTE_TYPE(enc, ptr); - switch (t) { - INVALID_CASES(ptr, nextTokPtr) - case BT_QUOT: - case BT_APOS: - ptr += MINBPC(enc); - if (t != open) - break; - if (ptr == end) - return -XML_TOK_LITERAL; - *nextTokPtr = ptr; - switch (BYTE_TYPE(enc, ptr)) { - case BT_S: case BT_CR: case BT_LF: - case BT_GT: case BT_PERCNT: case BT_LSQB: - return XML_TOK_LITERAL; - default: - return XML_TOK_INVALID; - } - default: - ptr += MINBPC(enc); - break; - } - } - return XML_TOK_PARTIAL; -} - -static int PTRCALL -PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - int tok; - if (ptr == end) - return XML_TOK_NONE; - if (MINBPC(enc) > 1) { - size_t n = end - ptr; - if (n & (MINBPC(enc) - 1)) { - n &= ~(MINBPC(enc) - 1); - if (n == 0) - return XML_TOK_PARTIAL; - end = ptr + n; - } - } - switch (BYTE_TYPE(enc, ptr)) { - case BT_QUOT: - return PREFIX(scanLit)(BT_QUOT, enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_APOS: - return PREFIX(scanLit)(BT_APOS, enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_LT: - { - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_PARTIAL; - switch (BYTE_TYPE(enc, ptr)) { - case BT_EXCL: - return PREFIX(scanDecl)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_QUEST: - return PREFIX(scanPi)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_NMSTRT: - case BT_HEX: - case BT_NONASCII: - case BT_LEAD2: - case BT_LEAD3: - case BT_LEAD4: - *nextTokPtr = ptr - MINBPC(enc); - return XML_TOK_INSTANCE_START; - } - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - case BT_CR: - if (ptr + MINBPC(enc) == end) { - *nextTokPtr = end; - /* indicate that this might be part of a CR/LF pair */ - return -XML_TOK_PROLOG_S; - } - /* fall through */ - case BT_S: case BT_LF: - for (;;) { - ptr += MINBPC(enc); - if (ptr == end) - break; - switch (BYTE_TYPE(enc, ptr)) { - case BT_S: case BT_LF: - break; - case BT_CR: - /* don't split CR/LF pair */ - if (ptr + MINBPC(enc) != end) - break; - /* fall through */ - default: - *nextTokPtr = ptr; - return XML_TOK_PROLOG_S; - } - } - *nextTokPtr = ptr; - return XML_TOK_PROLOG_S; - case BT_PERCNT: - return PREFIX(scanPercent)(enc, ptr + MINBPC(enc), end, nextTokPtr); - case BT_COMMA: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_COMMA; - case BT_LSQB: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_OPEN_BRACKET; - case BT_RSQB: - ptr += MINBPC(enc); - if (ptr == end) - return -XML_TOK_CLOSE_BRACKET; - if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) { - if (ptr + MINBPC(enc) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_GT)) { - *nextTokPtr = ptr + 2*MINBPC(enc); - return XML_TOK_COND_SECT_CLOSE; - } - } - *nextTokPtr = ptr; - return XML_TOK_CLOSE_BRACKET; - case BT_LPAR: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_OPEN_PAREN; - case BT_RPAR: - ptr += MINBPC(enc); - if (ptr == end) - return -XML_TOK_CLOSE_PAREN; - switch (BYTE_TYPE(enc, ptr)) { - case BT_AST: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_CLOSE_PAREN_ASTERISK; - case BT_QUEST: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_CLOSE_PAREN_QUESTION; - case BT_PLUS: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_CLOSE_PAREN_PLUS; - case BT_CR: case BT_LF: case BT_S: - case BT_GT: case BT_COMMA: case BT_VERBAR: - case BT_RPAR: - *nextTokPtr = ptr; - return XML_TOK_CLOSE_PAREN; - } - *nextTokPtr = ptr; - return XML_TOK_INVALID; - case BT_VERBAR: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_OR; - case BT_GT: - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DECL_CLOSE; - case BT_NUM: - return PREFIX(scanPoundName)(enc, ptr + MINBPC(enc), end, nextTokPtr); -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - if (end - ptr < n) \ - return XML_TOK_PARTIAL_CHAR; \ - if (IS_NMSTRT_CHAR(enc, ptr, n)) { \ - ptr += n; \ - tok = XML_TOK_NAME; \ - break; \ - } \ - if (IS_NAME_CHAR(enc, ptr, n)) { \ - ptr += n; \ - tok = XML_TOK_NMTOKEN; \ - break; \ - } \ - *nextTokPtr = ptr; \ - return XML_TOK_INVALID; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_NMSTRT: - case BT_HEX: - tok = XML_TOK_NAME; - ptr += MINBPC(enc); - break; - case BT_DIGIT: - case BT_NAME: - case BT_MINUS: -#ifdef XML_NS - case BT_COLON: -#endif - tok = XML_TOK_NMTOKEN; - ptr += MINBPC(enc); - break; - case BT_NONASCII: - if (IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { - ptr += MINBPC(enc); - tok = XML_TOK_NAME; - break; - } - if (IS_NAME_CHAR_MINBPC(enc, ptr)) { - ptr += MINBPC(enc); - tok = XML_TOK_NMTOKEN; - break; - } - /* fall through */ - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) - case BT_GT: case BT_RPAR: case BT_COMMA: - case BT_VERBAR: case BT_LSQB: case BT_PERCNT: - case BT_S: case BT_CR: case BT_LF: - *nextTokPtr = ptr; - return tok; -#ifdef XML_NS - case BT_COLON: - ptr += MINBPC(enc); - switch (tok) { - case XML_TOK_NAME: - if (ptr == end) - return XML_TOK_PARTIAL; - tok = XML_TOK_PREFIXED_NAME; - switch (BYTE_TYPE(enc, ptr)) { - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) - default: - tok = XML_TOK_NMTOKEN; - break; - } - break; - case XML_TOK_PREFIXED_NAME: - tok = XML_TOK_NMTOKEN; - break; - } - break; -#endif - case BT_PLUS: - if (tok == XML_TOK_NMTOKEN) { - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_NAME_PLUS; - case BT_AST: - if (tok == XML_TOK_NMTOKEN) { - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_NAME_ASTERISK; - case BT_QUEST: - if (tok == XML_TOK_NMTOKEN) { - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_NAME_QUESTION; - default: - *nextTokPtr = ptr; - return XML_TOK_INVALID; - } - } - return -tok; -} - -static int PTRCALL -PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, - const char *end, const char **nextTokPtr) -{ - const char *start; - if (ptr == end) - return XML_TOK_NONE; - start = ptr; - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: ptr += n; break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_AMP: - if (ptr == start) - return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_LT: - /* this is for inside entity references */ - *nextTokPtr = ptr; - return XML_TOK_INVALID; - case BT_LF: - if (ptr == start) { - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DATA_NEWLINE; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_CR: - if (ptr == start) { - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_CR; - if (BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - *nextTokPtr = ptr; - return XML_TOK_DATA_NEWLINE; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_S: - if (ptr == start) { - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_ATTRIBUTE_VALUE_S; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - default: - ptr += MINBPC(enc); - break; - } - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; -} - -static int PTRCALL -PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, - const char *end, const char **nextTokPtr) -{ - const char *start; - if (ptr == end) - return XML_TOK_NONE; - start = ptr; - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: ptr += n; break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_AMP: - if (ptr == start) - return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_PERCNT: - if (ptr == start) { - int tok = PREFIX(scanPercent)(enc, ptr + MINBPC(enc), - end, nextTokPtr); - return (tok == XML_TOK_PERCENT) ? XML_TOK_INVALID : tok; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_LF: - if (ptr == start) { - *nextTokPtr = ptr + MINBPC(enc); - return XML_TOK_DATA_NEWLINE; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - case BT_CR: - if (ptr == start) { - ptr += MINBPC(enc); - if (ptr == end) - return XML_TOK_TRAILING_CR; - if (BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - *nextTokPtr = ptr; - return XML_TOK_DATA_NEWLINE; - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; - default: - ptr += MINBPC(enc); - break; - } - } - *nextTokPtr = ptr; - return XML_TOK_DATA_CHARS; -} - -#ifdef XML_DTD - -static int PTRCALL -PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, - const char *end, const char **nextTokPtr) -{ - int level = 0; - if (MINBPC(enc) > 1) { - size_t n = end - ptr; - if (n & (MINBPC(enc) - 1)) { - n &= ~(MINBPC(enc) - 1); - end = ptr + n; - } - } - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { - INVALID_CASES(ptr, nextTokPtr) - case BT_LT: - if ((ptr += MINBPC(enc)) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr, ASCII_EXCL)) { - if ((ptr += MINBPC(enc)) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr, ASCII_LSQB)) { - ++level; - ptr += MINBPC(enc); - } - } - break; - case BT_RSQB: - if ((ptr += MINBPC(enc)) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) { - if ((ptr += MINBPC(enc)) == end) - return XML_TOK_PARTIAL; - if (CHAR_MATCHES(enc, ptr, ASCII_GT)) { - ptr += MINBPC(enc); - if (level == 0) { - *nextTokPtr = ptr; - return XML_TOK_IGNORE_SECT; - } - --level; - } - } - break; - default: - ptr += MINBPC(enc); - break; - } - } - return XML_TOK_PARTIAL; -} - -#endif /* XML_DTD */ - -static int PTRCALL -PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end, - const char **badPtr) -{ - ptr += MINBPC(enc); - end -= MINBPC(enc); - for (; ptr != end; ptr += MINBPC(enc)) { - switch (BYTE_TYPE(enc, ptr)) { - case BT_DIGIT: - case BT_HEX: - case BT_MINUS: - case BT_APOS: - case BT_LPAR: - case BT_RPAR: - case BT_PLUS: - case BT_COMMA: - case BT_SOL: - case BT_EQUALS: - case BT_QUEST: - case BT_CR: - case BT_LF: - case BT_SEMI: - case BT_EXCL: - case BT_AST: - case BT_PERCNT: - case BT_NUM: -#ifdef XML_NS - case BT_COLON: -#endif - break; - case BT_S: - if (CHAR_MATCHES(enc, ptr, ASCII_TAB)) { - *badPtr = ptr; - return 0; - } - break; - case BT_NAME: - case BT_NMSTRT: - if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f)) - break; - default: - switch (BYTE_TO_ASCII(enc, ptr)) { - case 0x24: /* $ */ - case 0x40: /* @ */ - break; - default: - *badPtr = ptr; - return 0; - } - break; - } - } - return 1; -} - -/* This must only be called for a well-formed start-tag or empty - element tag. Returns the number of attributes. Pointers to the - first attsMax attributes are stored in atts. -*/ - -static int PTRCALL -PREFIX(getAtts)(const ENCODING *enc, const char *ptr, - int attsMax, ATTRIBUTE *atts) -{ - enum { other, inName, inValue } state = inName; - int nAtts = 0; - int open = 0; /* defined when state == inValue; - initialization just to shut up compilers */ - - for (ptr += MINBPC(enc);; ptr += MINBPC(enc)) { - switch (BYTE_TYPE(enc, ptr)) { -#define START_NAME \ - if (state == other) { \ - if (nAtts < attsMax) { \ - atts[nAtts].name = ptr; \ - atts[nAtts].normalized = 1; \ - } \ - state = inName; \ - } -#define LEAD_CASE(n) \ - case BT_LEAD ## n: START_NAME ptr += (n - MINBPC(enc)); break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_NONASCII: - case BT_NMSTRT: - case BT_HEX: - START_NAME - break; -#undef START_NAME - case BT_QUOT: - if (state != inValue) { - if (nAtts < attsMax) - atts[nAtts].valuePtr = ptr + MINBPC(enc); - state = inValue; - open = BT_QUOT; - } - else if (open == BT_QUOT) { - state = other; - if (nAtts < attsMax) - atts[nAtts].valueEnd = ptr; - nAtts++; - } - break; - case BT_APOS: - if (state != inValue) { - if (nAtts < attsMax) - atts[nAtts].valuePtr = ptr + MINBPC(enc); - state = inValue; - open = BT_APOS; - } - else if (open == BT_APOS) { - state = other; - if (nAtts < attsMax) - atts[nAtts].valueEnd = ptr; - nAtts++; - } - break; - case BT_AMP: - if (nAtts < attsMax) - atts[nAtts].normalized = 0; - break; - case BT_S: - if (state == inName) - state = other; - else if (state == inValue - && nAtts < attsMax - && atts[nAtts].normalized - && (ptr == atts[nAtts].valuePtr - || BYTE_TO_ASCII(enc, ptr) != ASCII_SPACE - || BYTE_TO_ASCII(enc, ptr + MINBPC(enc)) == ASCII_SPACE - || BYTE_TYPE(enc, ptr + MINBPC(enc)) == open)) - atts[nAtts].normalized = 0; - break; - case BT_CR: case BT_LF: - /* This case ensures that the first attribute name is counted - Apart from that we could just change state on the quote. */ - if (state == inName) - state = other; - else if (state == inValue && nAtts < attsMax) - atts[nAtts].normalized = 0; - break; - case BT_GT: - case BT_SOL: - if (state != inValue) - return nAtts; - break; - default: - break; - } - } - /* not reached */ -} - -static int PTRFASTCALL -PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr) -{ - int result = 0; - /* skip &# */ - ptr += 2*MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_x)) { - for (ptr += MINBPC(enc); - !CHAR_MATCHES(enc, ptr, ASCII_SEMI); - ptr += MINBPC(enc)) { - int c = BYTE_TO_ASCII(enc, ptr); - switch (c) { - case ASCII_0: case ASCII_1: case ASCII_2: case ASCII_3: case ASCII_4: - case ASCII_5: case ASCII_6: case ASCII_7: case ASCII_8: case ASCII_9: - result <<= 4; - result |= (c - ASCII_0); - break; - case ASCII_A: case ASCII_B: case ASCII_C: - case ASCII_D: case ASCII_E: case ASCII_F: - result <<= 4; - result += 10 + (c - ASCII_A); - break; - case ASCII_a: case ASCII_b: case ASCII_c: - case ASCII_d: case ASCII_e: case ASCII_f: - result <<= 4; - result += 10 + (c - ASCII_a); - break; - } - if (result >= 0x110000) - return -1; - } - } - else { - for (; !CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) { - int c = BYTE_TO_ASCII(enc, ptr); - result *= 10; - result += (c - ASCII_0); - if (result >= 0x110000) - return -1; - } - } - return checkCharRefNumber(result); -} - -static int PTRCALL -PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr, - const char *end) -{ - switch ((end - ptr)/MINBPC(enc)) { - case 2: - if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_t)) { - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_l: - return ASCII_LT; - case ASCII_g: - return ASCII_GT; - } - } - break; - case 3: - if (CHAR_MATCHES(enc, ptr, ASCII_a)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_m)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_p)) - return ASCII_AMP; - } - } - break; - case 4: - switch (BYTE_TO_ASCII(enc, ptr)) { - case ASCII_q: - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_u)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_o)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_t)) - return ASCII_QUOT; - } - } - break; - case ASCII_a: - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_p)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_o)) { - ptr += MINBPC(enc); - if (CHAR_MATCHES(enc, ptr, ASCII_s)) - return ASCII_APOS; - } - } - break; - } - } - return 0; -} - -static int PTRCALL -PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2) -{ - for (;;) { - switch (BYTE_TYPE(enc, ptr1)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - if (*ptr1++ != *ptr2++) \ - return 0; - LEAD_CASE(4) LEAD_CASE(3) LEAD_CASE(2) -#undef LEAD_CASE - /* fall through */ - if (*ptr1++ != *ptr2++) - return 0; - break; - case BT_NONASCII: - case BT_NMSTRT: -#ifdef XML_NS - case BT_COLON: -#endif - case BT_HEX: - case BT_DIGIT: - case BT_NAME: - case BT_MINUS: - if (*ptr2++ != *ptr1++) - return 0; - if (MINBPC(enc) > 1) { - if (*ptr2++ != *ptr1++) - return 0; - if (MINBPC(enc) > 2) { - if (*ptr2++ != *ptr1++) - return 0; - if (MINBPC(enc) > 3) { - if (*ptr2++ != *ptr1++) - return 0; - } - } - } - break; - default: - if (MINBPC(enc) == 1 && *ptr1 == *ptr2) - return 1; - switch (BYTE_TYPE(enc, ptr2)) { - case BT_LEAD2: - case BT_LEAD3: - case BT_LEAD4: - case BT_NONASCII: - case BT_NMSTRT: -#ifdef XML_NS - case BT_COLON: -#endif - case BT_HEX: - case BT_DIGIT: - case BT_NAME: - case BT_MINUS: - return 0; - default: - return 1; - } - } - } - /* not reached */ -} - -static int PTRCALL -PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1, - const char *end1, const char *ptr2) -{ - for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) { - if (ptr1 == end1) - return 0; - if (!CHAR_MATCHES(enc, ptr1, *ptr2)) - return 0; - } - return ptr1 == end1; -} - -static int PTRFASTCALL -PREFIX(nameLength)(const ENCODING *enc, const char *ptr) -{ - const char *start = ptr; - for (;;) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: ptr += n; break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_NONASCII: - case BT_NMSTRT: -#ifdef XML_NS - case BT_COLON: -#endif - case BT_HEX: - case BT_DIGIT: - case BT_NAME: - case BT_MINUS: - ptr += MINBPC(enc); - break; - default: - return ptr - start; - } - } -} - -static const char * PTRFASTCALL -PREFIX(skipS)(const ENCODING *enc, const char *ptr) -{ - for (;;) { - switch (BYTE_TYPE(enc, ptr)) { - case BT_LF: - case BT_CR: - case BT_S: - ptr += MINBPC(enc); - break; - default: - return ptr; - } - } -} - -static void PTRCALL -PREFIX(updatePosition)(const ENCODING *enc, - const char *ptr, - const char *end, - POSITION *pos) -{ - while (ptr != end) { - switch (BYTE_TYPE(enc, ptr)) { -#define LEAD_CASE(n) \ - case BT_LEAD ## n: \ - ptr += n; \ - break; - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) -#undef LEAD_CASE - case BT_LF: - pos->columnNumber = (unsigned)-1; - pos->lineNumber++; - ptr += MINBPC(enc); - break; - case BT_CR: - pos->lineNumber++; - ptr += MINBPC(enc); - if (ptr != end && BYTE_TYPE(enc, ptr) == BT_LF) - ptr += MINBPC(enc); - pos->columnNumber = (unsigned)-1; - break; - default: - ptr += MINBPC(enc); - break; - } - pos->columnNumber++; - } -} - -#undef DO_LEAD_CASE -#undef MULTIBYTE_CASES -#undef INVALID_CASES -#undef CHECK_NAME_CASE -#undef CHECK_NAME_CASES -#undef CHECK_NMSTRT_CASE -#undef CHECK_NMSTRT_CASES - diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_impl.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_impl.h deleted file mode 100644 index 94c7db61..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_impl.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. -*/ - -enum { - BT_NONXML, - BT_MALFORM, - BT_LT, - BT_AMP, - BT_RSQB, - BT_LEAD2, - BT_LEAD3, - BT_LEAD4, - BT_TRAIL, - BT_CR, - BT_LF, - BT_GT, - BT_QUOT, - BT_APOS, - BT_EQUALS, - BT_QUEST, - BT_EXCL, - BT_SOL, - BT_SEMI, - BT_NUM, - BT_LSQB, - BT_S, - BT_NMSTRT, - BT_COLON, - BT_HEX, - BT_DIGIT, - BT_NAME, - BT_MINUS, - BT_OTHER, /* known not to be a name or name start character */ - BT_NONASCII, /* might be a name or name start character */ - BT_PERCNT, - BT_LPAR, - BT_RPAR, - BT_AST, - BT_PLUS, - BT_COMMA, - BT_VERBAR -}; - -#include diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_ns.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_ns.c deleted file mode 100644 index b8d02219..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_ns.c +++ /dev/null @@ -1,106 +0,0 @@ -const ENCODING * -NS(XmlGetUtf8InternalEncoding)(void) -{ - return &ns(internal_utf8_encoding).enc; -} - -const ENCODING * -NS(XmlGetUtf16InternalEncoding)(void) -{ -#if BYTEORDER == 1234 - return &ns(internal_little2_encoding).enc; -#elif BYTEORDER == 4321 - return &ns(internal_big2_encoding).enc; -#else - const short n = 1; - return (*(const char *)&n - ? &ns(internal_little2_encoding).enc - : &ns(internal_big2_encoding).enc); -#endif -} - -static const ENCODING *NS(encodings)[] = { - &ns(latin1_encoding).enc, - &ns(ascii_encoding).enc, - &ns(utf8_encoding).enc, - &ns(big2_encoding).enc, - &ns(big2_encoding).enc, - &ns(little2_encoding).enc, - &ns(utf8_encoding).enc /* NO_ENC */ -}; - -static int PTRCALL -NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - return initScan(NS(encodings), (const INIT_ENCODING *)enc, - XML_PROLOG_STATE, ptr, end, nextTokPtr); -} - -static int PTRCALL -NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) -{ - return initScan(NS(encodings), (const INIT_ENCODING *)enc, - XML_CONTENT_STATE, ptr, end, nextTokPtr); -} - -int -NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, - const char *name) -{ - int i = getEncodingIndex(name); - if (i == UNKNOWN_ENC) - return 0; - SET_INIT_ENC_INDEX(p, i); - p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog); - p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent); - p->initEnc.updatePosition = initUpdatePosition; - p->encPtr = encPtr; - *encPtr = &(p->initEnc); - return 1; -} - -static const ENCODING * -NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) -{ -#define ENCODING_MAX 128 - char buf[ENCODING_MAX]; - char *p = buf; - int i; - XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1); - if (ptr != end) - return 0; - *p = 0; - if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2) - return enc; - i = getEncodingIndex(buf); - if (i == UNKNOWN_ENC) - return 0; - return NS(encodings)[i]; -} - -int -NS(XmlParseXmlDecl)(int isGeneralTextEntity, - const ENCODING *enc, - const char *ptr, - const char *end, - const char **badPtr, - const char **versionPtr, - const char **versionEndPtr, - const char **encodingName, - const ENCODING **encoding, - int *standalone) -{ - return doParseXmlDecl(NS(findEncoding), - isGeneralTextEntity, - enc, - ptr, - end, - badPtr, - versionPtr, - versionEndPtr, - encodingName, - encoding, - standalone); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/fcntlmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/fcntlmodule.c deleted file mode 100644 index b96f4363..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/fcntlmodule.c +++ /dev/null @@ -1,594 +0,0 @@ - -/* fcntl module */ - -#include "Python.h" - -#ifdef HAVE_SYS_FILE_H -#include -#endif - -#include -#include -#ifdef HAVE_STROPTS_H -#include -#endif - -static int -conv_descriptor(PyObject *object, int *target) -{ - int fd = PyObject_AsFileDescriptor(object); - - if (fd < 0) - return 0; - *target = fd; - return 1; -} - - -/* fcntl(fd, opt, [arg]) */ - -static PyObject * -fcntl_fcntl(PyObject *self, PyObject *args) -{ - int fd; - int code; - int arg; - int ret; - char *str; - int len; - char buf[1024]; - - if (PyArg_ParseTuple(args, "O&is#:fcntl", - conv_descriptor, &fd, &code, &str, &len)) { - if (len > sizeof buf) { - PyErr_SetString(PyExc_ValueError, - "fcntl string arg too long"); - return NULL; - } - memcpy(buf, str, len); - Py_BEGIN_ALLOW_THREADS - ret = fcntl(fd, code, buf); - Py_END_ALLOW_THREADS - if (ret < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - return PyString_FromStringAndSize(buf, len); - } - - PyErr_Clear(); - arg = 0; - if (!PyArg_ParseTuple(args, - "O&i|i;fcntl requires a file or file descriptor," - " an integer and optionally a third integer or a string", - conv_descriptor, &fd, &code, &arg)) { - return NULL; - } - Py_BEGIN_ALLOW_THREADS - ret = fcntl(fd, code, arg); - Py_END_ALLOW_THREADS - if (ret < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - return PyInt_FromLong((long)ret); -} - -PyDoc_STRVAR(fcntl_doc, -"fcntl(fd, opt, [arg])\n\ -\n\ -Perform the requested operation on file descriptor fd. The operation\n\ -is defined by op and is operating system dependent. These constants are\n\ -available from the fcntl module. The argument arg is optional, and\n\ -defaults to 0; it may be an int or a string. If arg is given as a string,\n\ -the return value of fcntl is a string of that length, containing the\n\ -resulting value put in the arg buffer by the operating system.The length\n\ -of the arg string is not allowed to exceed 1024 bytes. If the arg given\n\ -is an integer or if none is specified, the result value is an integer\n\ -corresponding to the return value of the fcntl call in the C code."); - - -/* ioctl(fd, opt, [arg]) */ - -static PyObject * -fcntl_ioctl(PyObject *self, PyObject *args) -{ - int fd; - int code; - int arg; - int ret; - char *str; - int len; - int mutate_arg = 0; - char buf[1024]; - - if (PyArg_ParseTuple(args, "O&iw#|i:ioctl", - conv_descriptor, &fd, &code, - &str, &len, &mutate_arg)) { - char *arg; - - if (PyTuple_Size(args) == 3) { - /* warning goes here in 2.4 */ - mutate_arg = 0; - } - if (mutate_arg) { - if (len <= sizeof buf) { - memcpy(buf, str, len); - arg = buf; - } - else { - arg = str; - } - } - else { - if (len > sizeof buf) { - PyErr_SetString(PyExc_ValueError, - "ioctl string arg too long"); - return NULL; - } - else { - memcpy(buf, str, len); - arg = buf; - } - } - if (buf == arg) { - Py_BEGIN_ALLOW_THREADS /* think array.resize() */ - ret = ioctl(fd, code, arg); - Py_END_ALLOW_THREADS - } - else { - ret = ioctl(fd, code, arg); - } - if (mutate_arg && (len < sizeof buf)) { - memcpy(str, buf, len); - } - if (ret < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - if (mutate_arg) { - return PyInt_FromLong(ret); - } - else { - return PyString_FromStringAndSize(buf, len); - } - } - - PyErr_Clear(); - if (PyArg_ParseTuple(args, "O&is#:ioctl", - conv_descriptor, &fd, &code, &str, &len)) { - if (len > sizeof buf) { - PyErr_SetString(PyExc_ValueError, - "ioctl string arg too long"); - return NULL; - } - memcpy(buf, str, len); - Py_BEGIN_ALLOW_THREADS - ret = ioctl(fd, code, buf); - Py_END_ALLOW_THREADS - if (ret < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - return PyString_FromStringAndSize(buf, len); - } - - PyErr_Clear(); - arg = 0; - if (!PyArg_ParseTuple(args, - "O&i|i;ioctl requires a file or file descriptor," - " an integer and optionally a integer or buffer argument", - conv_descriptor, &fd, &code, &arg)) { - return NULL; - } - Py_BEGIN_ALLOW_THREADS -#ifdef __VMS - ret = ioctl(fd, code, (void *)arg); -#else - ret = ioctl(fd, code, arg); -#endif - Py_END_ALLOW_THREADS - if (ret < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - return PyInt_FromLong((long)ret); -} - -PyDoc_STRVAR(ioctl_doc, -"ioctl(fd, opt[, arg[, mutate_flag]])\n\ -\n\ -Perform the requested operation on file descriptor fd. The operation is\n\ -defined by opt and is operating system dependent. Typically these codes are\n\ -retrieved from the fcntl or termios library modules.\n\ -\n\ -The argument arg is optional, and defaults to 0; it may be an int or a\n\ -buffer containing character data (most likely a string or an array). \n\ -\n\ -If the argument is a mutable buffer (such as an array) and if the\n\ -mutate_flag argument (which is only allowed in this case) is true then the\n\ -buffer is (in effect) passed to the operating system and changes made by\n\ -the OS will be reflected in the contents of the buffer after the call has\n\ -returned. The return value is the integer returned by the ioctl system\n\ -call.\n\ -\n\ -If the argument is a mutable buffer and the mutable_flag argument is not\n\ -passed or is false, the behavior is as if a string had been passed. This\n\ -behavior will change in future releases of Python.\n\ -\n\ -If the argument is an immutable buffer (most likely a string) then a copy\n\ -of the buffer is passed to the operating system and the return value is a\n\ -string of the same length containing whatever the operating system put in\n\ -the buffer. The length of the arg buffer in this case is not allowed to\n\ -exceed 1024 bytes.\n\ -\n\ -If the arg given is an integer or if none is specified, the result value is\n\ -an integer corresponding to the return value of the ioctl call in the C\n\ -code."); - - -/* flock(fd, operation) */ - -static PyObject * -fcntl_flock(PyObject *self, PyObject *args) -{ - int fd; - int code; - int ret; - - if (!PyArg_ParseTuple(args, "O&i:flock", - conv_descriptor, &fd, &code)) - return NULL; - -#ifdef HAVE_FLOCK - Py_BEGIN_ALLOW_THREADS - ret = flock(fd, code); - Py_END_ALLOW_THREADS -#else - -#ifndef LOCK_SH -#define LOCK_SH 1 /* shared lock */ -#define LOCK_EX 2 /* exclusive lock */ -#define LOCK_NB 4 /* don't block when locking */ -#define LOCK_UN 8 /* unlock */ -#endif - { - struct flock l; - if (code == LOCK_UN) - l.l_type = F_UNLCK; - else if (code & LOCK_SH) - l.l_type = F_RDLCK; - else if (code & LOCK_EX) - l.l_type = F_WRLCK; - else { - PyErr_SetString(PyExc_ValueError, - "unrecognized flock argument"); - return NULL; - } - l.l_whence = l.l_start = l.l_len = 0; - Py_BEGIN_ALLOW_THREADS - ret = fcntl(fd, (code & LOCK_NB) ? F_SETLK : F_SETLKW, &l); - Py_END_ALLOW_THREADS - } -#endif /* HAVE_FLOCK */ - if (ret < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(flock_doc, -"flock(fd, operation)\n\ -\n\ -Perform the lock operation op on file descriptor fd. See the Unix \n\ -manual flock(3) for details. (On some systems, this function is\n\ -emulated using fcntl().)"); - - -/* lockf(fd, operation) */ -static PyObject * -fcntl_lockf(PyObject *self, PyObject *args) -{ - int fd, code, ret, whence = 0; - PyObject *lenobj = NULL, *startobj = NULL; - - if (!PyArg_ParseTuple(args, "O&i|OOi:lockf", - conv_descriptor, &fd, &code, - &lenobj, &startobj, &whence)) - return NULL; - -#if defined(PYOS_OS2) && defined(PYCC_GCC) - PyErr_SetString(PyExc_NotImplementedError, - "lockf not supported on OS/2 (EMX)"); - return NULL; -#else -#ifndef LOCK_SH -#define LOCK_SH 1 /* shared lock */ -#define LOCK_EX 2 /* exclusive lock */ -#define LOCK_NB 4 /* don't block when locking */ -#define LOCK_UN 8 /* unlock */ -#endif /* LOCK_SH */ - { - struct flock l; - if (code == LOCK_UN) - l.l_type = F_UNLCK; - else if (code & LOCK_SH) - l.l_type = F_RDLCK; - else if (code & LOCK_EX) - l.l_type = F_WRLCK; - else { - PyErr_SetString(PyExc_ValueError, - "unrecognized flock argument"); - return NULL; - } - l.l_start = l.l_len = 0; - if (startobj != NULL) { -#if !defined(HAVE_LARGEFILE_SUPPORT) - l.l_start = PyInt_AsLong(startobj); -#else - l.l_start = PyLong_Check(startobj) ? - PyLong_AsLongLong(startobj) : - PyInt_AsLong(startobj); -#endif - if (PyErr_Occurred()) - return NULL; - } - if (lenobj != NULL) { -#if !defined(HAVE_LARGEFILE_SUPPORT) - l.l_len = PyInt_AsLong(lenobj); -#else - l.l_len = PyLong_Check(lenobj) ? - PyLong_AsLongLong(lenobj) : - PyInt_AsLong(lenobj); -#endif - if (PyErr_Occurred()) - return NULL; - } - l.l_whence = whence; - Py_BEGIN_ALLOW_THREADS - ret = fcntl(fd, (code & LOCK_NB) ? F_SETLK : F_SETLKW, &l); - Py_END_ALLOW_THREADS - } - if (ret < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -#endif /* defined(PYOS_OS2) && defined(PYCC_GCC) */ -} - -PyDoc_STRVAR(lockf_doc, -"lockf (fd, operation, length=0, start=0, whence=0)\n\ -\n\ -This is essentially a wrapper around the fcntl() locking calls. fd is the\n\ -file descriptor of the file to lock or unlock, and operation is one of the\n\ -following values:\n\ -\n\ - LOCK_UN - unlock\n\ - LOCK_SH - acquire a shared lock\n\ - LOCK_EX - acquire an exclusive lock\n\ -\n\ -When operation is LOCK_SH or LOCK_EX, it can also be bit-wise OR'd with\n\ -LOCK_NB to avoid blocking on lock acquisition. If LOCK_NB is used and the\n\ -lock cannot be acquired, an IOError will be raised and the exception will\n\ -have an errno attribute set to EACCES or EAGAIN (depending on the operating\n\ -system -- for portability, check for either value).\n\ -\n\ -length is the number of bytes to lock, with the default meaning to lock to\n\ -EOF. start is the byte offset, relative to whence, to that the lock\n\ -starts. whence is as with fileobj.seek(), specifically:\n\ -\n\ - 0 - relative to the start of the file (SEEK_SET)\n\ - 1 - relative to the current buffer position (SEEK_CUR)\n\ - 2 - relative to the end of the file (SEEK_END)"); - -/* List of functions */ - -static PyMethodDef fcntl_methods[] = { - {"fcntl", fcntl_fcntl, METH_VARARGS, fcntl_doc}, - {"ioctl", fcntl_ioctl, METH_VARARGS, ioctl_doc}, - {"flock", fcntl_flock, METH_VARARGS, flock_doc}, - {"lockf", fcntl_lockf, METH_VARARGS, lockf_doc}, - {NULL, NULL} /* sentinel */ -}; - - -PyDoc_STRVAR(module_doc, -"This module performs file control and I/O control on file \n\ -descriptors. It is an interface to the fcntl() and ioctl() Unix\n\ -routines. File descriptors can be obtained with the fileno() method of\n\ -a file or socket object."); - -/* Module initialisation */ - -static int -ins(PyObject* d, char* symbol, long value) -{ - PyObject* v = PyInt_FromLong(value); - if (!v || PyDict_SetItemString(d, symbol, v) < 0) - return -1; - - Py_DECREF(v); - return 0; -} - -#define INS(x) if (ins(d, #x, (long)x)) return -1 - -static int -all_ins(PyObject* d) -{ - if (ins(d, "LOCK_SH", (long)LOCK_SH)) return -1; - if (ins(d, "LOCK_EX", (long)LOCK_EX)) return -1; - if (ins(d, "LOCK_NB", (long)LOCK_NB)) return -1; - if (ins(d, "LOCK_UN", (long)LOCK_UN)) return -1; -/* GNU extensions, as of glibc 2.2.4 */ -#ifdef LOCK_MAND - if (ins(d, "LOCK_MAND", (long)LOCK_MAND)) return -1; -#endif -#ifdef LOCK_READ - if (ins(d, "LOCK_READ", (long)LOCK_READ)) return -1; -#endif -#ifdef LOCK_WRITE - if (ins(d, "LOCK_WRITE", (long)LOCK_WRITE)) return -1; -#endif -#ifdef LOCK_RW - if (ins(d, "LOCK_RW", (long)LOCK_RW)) return -1; -#endif - -#ifdef F_DUPFD - if (ins(d, "F_DUPFD", (long)F_DUPFD)) return -1; -#endif -#ifdef F_GETFD - if (ins(d, "F_GETFD", (long)F_GETFD)) return -1; -#endif -#ifdef F_SETFD - if (ins(d, "F_SETFD", (long)F_SETFD)) return -1; -#endif -#ifdef F_GETFL - if (ins(d, "F_GETFL", (long)F_GETFL)) return -1; -#endif -#ifdef F_SETFL - if (ins(d, "F_SETFL", (long)F_SETFL)) return -1; -#endif -#ifdef F_GETLK - if (ins(d, "F_GETLK", (long)F_GETLK)) return -1; -#endif -#ifdef F_SETLK - if (ins(d, "F_SETLK", (long)F_SETLK)) return -1; -#endif -#ifdef F_SETLKW - if (ins(d, "F_SETLKW", (long)F_SETLKW)) return -1; -#endif -#ifdef F_GETOWN - if (ins(d, "F_GETOWN", (long)F_GETOWN)) return -1; -#endif -#ifdef F_SETOWN - if (ins(d, "F_SETOWN", (long)F_SETOWN)) return -1; -#endif -#ifdef F_GETSIG - if (ins(d, "F_GETSIG", (long)F_GETSIG)) return -1; -#endif -#ifdef F_SETSIG - if (ins(d, "F_SETSIG", (long)F_SETSIG)) return -1; -#endif -#ifdef F_RDLCK - if (ins(d, "F_RDLCK", (long)F_RDLCK)) return -1; -#endif -#ifdef F_WRLCK - if (ins(d, "F_WRLCK", (long)F_WRLCK)) return -1; -#endif -#ifdef F_UNLCK - if (ins(d, "F_UNLCK", (long)F_UNLCK)) return -1; -#endif -/* LFS constants */ -#ifdef F_GETLK64 - if (ins(d, "F_GETLK64", (long)F_GETLK64)) return -1; -#endif -#ifdef F_SETLK64 - if (ins(d, "F_SETLK64", (long)F_SETLK64)) return -1; -#endif -#ifdef F_SETLKW64 - if (ins(d, "F_SETLKW64", (long)F_SETLKW64)) return -1; -#endif -/* GNU extensions, as of glibc 2.2.4. */ -#ifdef F_SETLEASE - if (ins(d, "F_SETLEASE", (long)F_SETLEASE)) return -1; -#endif -#ifdef F_GETLEASE - if (ins(d, "F_GETLEASE", (long)F_GETLEASE)) return -1; -#endif -#ifdef F_NOTIFY - if (ins(d, "F_NOTIFY", (long)F_NOTIFY)) return -1; -#endif -/* Old BSD flock(). */ -#ifdef F_EXLCK - if (ins(d, "F_EXLCK", (long)F_EXLCK)) return -1; -#endif -#ifdef F_SHLCK - if (ins(d, "F_SHLCK", (long)F_SHLCK)) return -1; -#endif - -/* For F_{GET|SET}FL */ -#ifdef FD_CLOEXEC - if (ins(d, "FD_CLOEXEC", (long)FD_CLOEXEC)) return -1; -#endif - -/* For F_NOTIFY */ -#ifdef DN_ACCESS - if (ins(d, "DN_ACCESS", (long)DN_ACCESS)) return -1; -#endif -#ifdef DN_MODIFY - if (ins(d, "DN_MODIFY", (long)DN_MODIFY)) return -1; -#endif -#ifdef DN_CREATE - if (ins(d, "DN_CREATE", (long)DN_CREATE)) return -1; -#endif -#ifdef DN_DELETE - if (ins(d, "DN_DELETE", (long)DN_DELETE)) return -1; -#endif -#ifdef DN_RENAME - if (ins(d, "DN_RENAME", (long)DN_RENAME)) return -1; -#endif -#ifdef DN_ATTRIB - if (ins(d, "DN_ATTRIB", (long)DN_ATTRIB)) return -1; -#endif -#ifdef DN_MULTISHOT - if (ins(d, "DN_MULTISHOT", (long)DN_MULTISHOT)) return -1; -#endif - -#ifdef HAVE_STROPTS_H - /* Unix 98 guarantees that these are in stropts.h. */ - INS(I_PUSH); - INS(I_POP); - INS(I_LOOK); - INS(I_FLUSH); - INS(I_FLUSHBAND); - INS(I_SETSIG); - INS(I_GETSIG); - INS(I_FIND); - INS(I_PEEK); - INS(I_SRDOPT); - INS(I_GRDOPT); - INS(I_NREAD); - INS(I_FDINSERT); - INS(I_STR); - INS(I_SWROPT); -#ifdef I_GWROPT - /* despite the comment above, old-ish glibcs miss a couple... */ - INS(I_GWROPT); -#endif - INS(I_SENDFD); - INS(I_RECVFD); - INS(I_LIST); - INS(I_ATMARK); - INS(I_CKBAND); - INS(I_GETBAND); - INS(I_CANPUT); - INS(I_SETCLTIME); -#ifdef I_GETCLTIME - INS(I_GETCLTIME); -#endif - INS(I_LINK); - INS(I_UNLINK); - INS(I_PLINK); - INS(I_PUNLINK); -#endif - - return 0; -} - -PyMODINIT_FUNC -initfcntl(void) -{ - PyObject *m, *d; - - /* Create the module and add the functions and documentation */ - m = Py_InitModule3("fcntl", fcntl_methods, module_doc); - - /* Add some symbolic constants to the module */ - d = PyModule_GetDict(m); - all_ins(d); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/flmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/flmodule.c deleted file mode 100644 index d84834eb..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/flmodule.c +++ /dev/null @@ -1,2138 +0,0 @@ -/* FL module -- interface to Mark Overmars' FORMS Library. */ - -/* This code works with FORMS version 2.2 (if you defined - OBSOLETE_FORMS_CALLS), and 2.3. - FORMS can be ftp'ed from ftp.cs.ruu.nl (131.211.80.17), directory - /pub/SGI/FORMS. */ - -/* A half-hearted attempt has been made to allow programs using this - * module to exploit parallelism (through the threads module). No provisions - * have been made for multiple threads to use this module at the same time, - * though. So, a program with a forms thread and a non-forms thread will work - * fine but a program with two threads using forms will probably crash (unless - * the program takes precaution to ensure that only one thread can be in - * this module at any time). This will have to be fixed some time. - * (A fix will probably also have to synchronize with the gl module). - */ - -#include "Python.h" -#include "forms.h" -#include "structmember.h" - -/* Generic Forms Objects */ - -typedef struct { - PyObject_HEAD - FL_OBJECT *ob_generic; - PyMethodDef *ob_methods; - PyObject *ob_callback; - PyObject *ob_callback_arg; -} genericobject; - -static PyTypeObject GenericObjecttype; - -#define is_genericobject(g) ((g)->ob_type == &GenericObjecttype) - -/* List of all objects (XXX this should be a hash table on address...) */ - -static PyObject *allgenerics = NULL; -static int nfreeslots = 0; - -/* Add an object to the list of known objects */ - -static void -knowgeneric(genericobject *g) -{ - int i, n; - /* Create the list if it doesn't already exist */ - if (allgenerics == NULL) { - allgenerics = PyList_New(0); - if (allgenerics == NULL) { - PyErr_Clear(); - return; /* Too bad, live without allgenerics... */ - } - } - if (nfreeslots > 0) { - /* Search the list for reusable slots (NULL items) */ - /* XXX This can be made faster! */ - n = PyList_Size(allgenerics); - for (i = 0; i < n; i++) { - if (PyList_GetItem(allgenerics, i) == NULL) { - Py_INCREF(g); - PyList_SetItem(allgenerics, i, (PyObject *)g); - nfreeslots--; - return; - } - } - /* Strange... no free slots found... */ - nfreeslots = 0; - } - /* No free entries, append new item to the end */ - PyList_Append(allgenerics, (PyObject *)g); -} - -/* Find an object in the list of known objects */ - -static genericobject * -findgeneric(FL_OBJECT *generic) -{ - int i, n; - genericobject *g; - - if (allgenerics == NULL) - return NULL; /* No objects known yet */ - n = PyList_Size(allgenerics); - for (i = 0; i < n; i++) { - g = (genericobject *)PyList_GetItem(allgenerics, i); - if (g != NULL && g->ob_generic == generic) - return g; - } - return NULL; /* Unknown object */ -} - -/* Remove an object from the list of known objects */ - -static void -forgetgeneric(genericobject *g) -{ - int i, n; - - Py_XDECREF(g->ob_callback); - g->ob_callback = NULL; - Py_XDECREF(g->ob_callback_arg); - g->ob_callback_arg = NULL; - if (allgenerics == NULL) - return; /* No objects known yet */ - n = PyList_Size(allgenerics); - for (i = 0; i < n; i++) { - if (g == (genericobject *)PyList_GetItem(allgenerics, i)) { - PyList_SetItem(allgenerics, i, (PyObject *)NULL); - nfreeslots++; - break; - } - } -} - -/* Called when a form is about to be freed -- - remove all the objects that we know about from it. */ - -static void -releaseobjects(FL_FORM *form) -{ - int i, n; - genericobject *g; - - if (allgenerics == NULL) - return; /* No objects known yet */ - n = PyList_Size(allgenerics); - for (i = 0; i < n; i++) { - g = (genericobject *)PyList_GetItem(allgenerics, i); - if (g != NULL && g->ob_generic->form == form) { - fl_delete_object(g->ob_generic); - /* The object is now unreachable for - do_forms and check_forms, so - delete it from the list of known objects */ - Py_XDECREF(g->ob_callback); - g->ob_callback = NULL; - Py_XDECREF(g->ob_callback_arg); - g->ob_callback_arg = NULL; - PyList_SetItem(allgenerics, i, (PyObject *)NULL); - nfreeslots++; - } - } -} - - -/* Methods of generic objects */ - -static PyObject * -generic_set_call_back(genericobject *g, PyObject *args) -{ - if (args == NULL) { - Py_XDECREF(g->ob_callback); - Py_XDECREF(g->ob_callback_arg); - g->ob_callback = NULL; - g->ob_callback_arg = NULL; - } - else { - if (!PyTuple_Check(args) || PyTuple_Size(args) != 2) { - PyErr_BadArgument(); - return NULL; - } - Py_XDECREF(g->ob_callback); - Py_XDECREF(g->ob_callback_arg); - g->ob_callback = PyTuple_GetItem(args, 0); - Py_INCREF(g->ob_callback); - g->ob_callback_arg = PyTuple_GetItem(args, 1); - Py_INCREF(g->ob_callback_arg); - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -generic_call(genericobject *g, void (*func)(FL_OBJECT *)) -{ - (*func)(g->ob_generic); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -generic_delete_object(genericobject *g) -{ - PyObject *res; - res = generic_call(g, fl_delete_object); - if (res != NULL) - forgetgeneric(g); - return res; -} - -static PyObject * -generic_show_object(genericobject *g) -{ - return generic_call(g, fl_show_object); -} - -static PyObject * -generic_hide_object(genericobject *g) -{ - return generic_call(g, fl_hide_object); -} - -static PyObject * -generic_redraw_object(genericobject *g) -{ - return generic_call(g, fl_redraw_object); -} - -#ifdef OBSOLETE_FORMS_CALLS - - /* (un)freeze_object() are obsolete in FORMS 2.2 and unsupported - in 2.3. Since there's no foolproof way to tell which version we're - using, we omit them unconditionally. */ - -static PyObject * -generic_freeze_object(genericobject *g) -{ - return generic_call(g, fl_freeze_object); -} - -static PyObject * -generic_unfreeze_object(genericobject *g) -{ - return generic_call(g, fl_unfreeze_object); -} - -#endif /* OBSOLETE_FORMS_CALLS */ - -static PyObject * -generic_activate_object(genericobject *g) -{ - return generic_call(g, fl_activate_object); -} - -static PyObject * -generic_deactivate_object(genericobject *g) -{ - return generic_call(g, fl_deactivate_object); -} - -static PyObject * -generic_set_object_shortcut(genericobject *g, PyObject *args) -{ - char *str; - if (!PyArg_ParseTuple(args, "s:set_object_shortcut", &str)) - return NULL; - fl_set_object_shortcut(g->ob_generic, str); - Py_INCREF(Py_None); - return Py_None; -} - -static PyMethodDef generic_methods[] = { - {"set_call_back", (PyCFunction)generic_set_call_back, METH_OLDARGS}, - {"delete_object", (PyCFunction)generic_delete_object, METH_NOARGS}, - {"show_object", (PyCFunction)generic_show_object, METH_NOARGS}, - {"hide_object", (PyCFunction)generic_hide_object, METH_NOARGS}, - {"redraw_object", (PyCFunction)generic_redraw_object, METH_NOARGS}, -#ifdef OBSOLETE_FORMS_CALLS - {"freeze_object", (PyCFunction)generic_freeze_object, METH_NOARGS}, - {"unfreeze_object", (PyCFunction)generic_unfreeze_object, METH_NOARGS}, -#endif - {"activate_object", (PyCFunction)generic_activate_object, METH_NOARGS}, - {"deactivate_object", (PyCFunction)generic_deactivate_object, METH_NOARGS}, - {"set_object_shortcut", (PyCFunction)generic_set_object_shortcut, METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - -static void -generic_dealloc(genericobject *g) -{ - fl_free_object(g->ob_generic); - Py_XDECREF(g->ob_callback); - Py_XDECREF(g->ob_callback_arg); - PyObject_Del(g); -} - -#define OFF(x) offsetof(FL_OBJECT, x) - -static struct memberlist generic_memberlist[] = { - {"objclass", T_INT, OFF(objclass), RO}, - {"type", T_INT, OFF(type), RO}, - {"boxtype", T_INT, OFF(boxtype)}, - {"x", T_FLOAT, OFF(x)}, - {"y", T_FLOAT, OFF(y)}, - {"w", T_FLOAT, OFF(w)}, - {"h", T_FLOAT, OFF(h)}, - {"col1", T_INT, OFF(col1)}, - {"col2", T_INT, OFF(col2)}, - {"align", T_INT, OFF(align)}, - {"lcol", T_INT, OFF(lcol)}, - {"lsize", T_FLOAT, OFF(lsize)}, - /* "label" is treated specially! */ - {"lstyle", T_INT, OFF(lstyle)}, - {"pushed", T_INT, OFF(pushed), RO}, - {"focus", T_INT, OFF(focus), RO}, - {"belowmouse", T_INT, OFF(belowmouse),RO}, -/* {"frozen", T_INT, OFF(frozen), RO}, */ - {"active", T_INT, OFF(active)}, - {"input", T_INT, OFF(input)}, - {"visible", T_INT, OFF(visible), RO}, - {"radio", T_INT, OFF(radio)}, - {"automatic", T_INT, OFF(automatic)}, - {NULL} /* Sentinel */ -}; - -#undef OFF - -static PyObject * -generic_getattr(genericobject *g, char *name) -{ - PyObject *meth; - - /* XXX Ought to special-case name "__methods__" */ - if (g-> ob_methods) { - meth = Py_FindMethod(g->ob_methods, (PyObject *)g, name); - if (meth != NULL) return meth; - PyErr_Clear(); - } - - meth = Py_FindMethod(generic_methods, (PyObject *)g, name); - if (meth != NULL) - return meth; - PyErr_Clear(); - - /* "label" is an exception, getmember only works for char pointers, - not for char arrays */ - if (strcmp(name, "label") == 0) - return PyString_FromString(g->ob_generic->label); - - return PyMember_Get((char *)g->ob_generic, generic_memberlist, name); -} - -static int -generic_setattr(genericobject *g, char *name, PyObject *v) -{ - int ret; - - if (v == NULL) { - PyErr_SetString(PyExc_TypeError, - "can't delete forms object attributes"); - return -1; - } - - /* "label" is an exception: setmember doesn't set strings; - and FORMS wants you to call a function to set the label */ - if (strcmp(name, "label") == 0) { - if (!PyString_Check(v)) { - PyErr_SetString(PyExc_TypeError, - "label attr must be string"); - return -1; - } - fl_set_object_label(g->ob_generic, PyString_AsString(v)); - return 0; - } - - ret = PyMember_Set((char *)g->ob_generic, generic_memberlist, name, v); - - /* Rather than calling all the various set_object_* functions, - we call fl_redraw_object here. This is sometimes redundant - but I doubt that's a big problem */ - if (ret == 0) - fl_redraw_object(g->ob_generic); - - return ret; -} - -static PyObject * -generic_repr(genericobject *g) -{ - char buf[100]; - PyOS_snprintf(buf, sizeof(buf), "", - g, g->ob_generic->objclass); - return PyString_FromString(buf); -} - -static PyTypeObject GenericObjecttype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "fl.FORMS_object", /*tp_name*/ - sizeof(genericobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)generic_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)generic_getattr, /*tp_getattr*/ - (setattrfunc)generic_setattr, /*tp_setattr*/ - 0, /*tp_compare*/ - (reprfunc)generic_repr, /*tp_repr*/ -}; - -static PyObject * -newgenericobject(FL_OBJECT *generic, PyMethodDef *methods) -{ - genericobject *g; - g = PyObject_New(genericobject, &GenericObjecttype); - if (g == NULL) - return NULL; - g-> ob_generic = generic; - g->ob_methods = methods; - g->ob_callback = NULL; - g->ob_callback_arg = NULL; - knowgeneric(g); - return (PyObject *)g; -} - -/**********************************************************************/ -/* Some common calling sequences */ - -/* void func (object, float) */ -static PyObject * -call_forms_INf (void (*func)(FL_OBJECT *, float), FL_OBJECT *obj, PyObject *args) -{ - float parameter; - - if (!PyArg_Parse(args, "f", ¶meter)) return NULL; - - (*func) (obj, parameter); - - Py_INCREF(Py_None); - return Py_None; -} - -/* void func (object, float) */ -static PyObject * -call_forms_INfINf (void (*func)(FL_OBJECT *, float, float), FL_OBJECT *obj, PyObject *args) -{ - float par1, par2; - - if (!PyArg_Parse(args, "(ff)", &par1, &par2)) return NULL; - - (*func) (obj, par1, par2); - - Py_INCREF(Py_None); - return Py_None; -} - -/* void func (object, int) */ -static PyObject * -call_forms_INi (void (*func)(FL_OBJECT *, int), FL_OBJECT *obj, PyObject *args) -{ - int parameter; - - if (!PyArg_Parse(args, "i", ¶meter)) return NULL; - - (*func) (obj, parameter); - - Py_INCREF(Py_None); - return Py_None; -} - -/* void func (object, char) */ -static PyObject * -call_forms_INc (void (*func)(FL_OBJECT *, int), FL_OBJECT *obj, PyObject *args) -{ - char *a; - - if (!PyArg_Parse(args, "s", &a)) return NULL; - - (*func) (obj, a[0]); - - Py_INCREF(Py_None); - return Py_None; -} - -/* void func (object, string) */ -static PyObject * -call_forms_INstr (void (*func)(FL_OBJECT *, char *), FL_OBJECT *obj, PyObject *args) -{ - char *a; - - if (!PyArg_Parse(args, "s", &a)) return NULL; - - (*func) (obj, a); - - Py_INCREF(Py_None); - return Py_None; -} - - -/* void func (object, int, string) */ -static PyObject * -call_forms_INiINstr (void (*func)(FL_OBJECT *, int, char *), FL_OBJECT *obj, PyObject *args) -{ - char *b; - int a; - - if (!PyArg_Parse(args, "(is)", &a, &b)) return NULL; - - (*func) (obj, a, b); - - Py_INCREF(Py_None); - return Py_None; -} - -#ifdef UNUSED -/* void func (object, int, int) */ -static PyObject * -call_forms_INiINi (void (*func)(FL_OBJECT *, int, int), FL_OBJECT *obj, PyObject *args) -{ - int par1, par2; - - if (!PyArg_Parse(args, "(ii)", &par1, &par2)) return NULL; - - (*func) (obj, par1, par2); - - Py_INCREF(Py_None); - return Py_None; -} -#endif - -/* int func (object) */ -static PyObject * -call_forms_Ri (int (*func)(FL_OBJECT *), FL_OBJECT *obj) -{ - int retval; - - retval = (*func) (obj); - - return PyInt_FromLong ((long) retval); -} - -/* char * func (object) */ -static PyObject * -call_forms_Rstr (char * (*func)(FL_OBJECT *), FL_OBJECT *obj) -{ - char *str; - - str = (*func) (obj); - - if (str == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyString_FromString (str); -} - -/* int func (object) */ -static PyObject * -call_forms_Rf (float (*func)(FL_OBJECT *), FL_OBJECT *obj) -{ - float retval; - - retval = (*func) (obj); - - return PyFloat_FromDouble (retval); -} - -static PyObject * -call_forms_OUTfOUTf (void (*func)(FL_OBJECT *, float *, float *), FL_OBJECT *obj) -{ - float f1, f2; - - (*func) (obj, &f1, &f2); - - return Py_BuildValue("(ff)", f1, f2); -} - -#ifdef UNUSED -static PyObject * -call_forms_OUTf (void (*func)(FL_OBJECT *, float *), FL_OBJECT *obj) -{ - float f; - - (*func) (obj, &f); - - return PyFloat_FromDouble (f); -} -#endif - -/**********************************************************************/ -/* Class : browser */ - -static PyObject * -set_browser_topline(genericobject *g, PyObject *args) -{ - return call_forms_INi (fl_set_browser_topline, g-> ob_generic, args); -} - -static PyObject * -clear_browser(genericobject *g) -{ - return generic_call (g, fl_clear_browser); -} - -static PyObject * -add_browser_line (genericobject *g, PyObject *args) -{ - return call_forms_INstr (fl_add_browser_line, g-> ob_generic, args); -} - -static PyObject * -addto_browser (genericobject *g, PyObject *args) -{ - return call_forms_INstr (fl_addto_browser, g-> ob_generic, args); -} - -static PyObject * -insert_browser_line (genericobject *g, PyObject *args) -{ - return call_forms_INiINstr (fl_insert_browser_line, - g-> ob_generic, args); -} - -static PyObject * -delete_browser_line (genericobject *g, PyObject *args) -{ - return call_forms_INi (fl_delete_browser_line, g-> ob_generic, args); -} - -static PyObject * -replace_browser_line (genericobject *g, PyObject *args) -{ - return call_forms_INiINstr (fl_replace_browser_line, - g-> ob_generic, args); -} - -static PyObject * -get_browser_line(genericobject *g, PyObject *args) -{ - int i; - char *str; - - if (!PyArg_Parse(args, "i", &i)) - return NULL; - - str = fl_get_browser_line (g->ob_generic, i); - - if (str == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyString_FromString (str); -} - -static PyObject * -load_browser (genericobject *g, PyObject *args) -{ - /* XXX strictly speaking this is wrong since fl_load_browser - XXX returns int, not void */ - return call_forms_INstr (fl_load_browser, g-> ob_generic, args); -} - -static PyObject * -get_browser_maxline(genericobject *g) -{ - return call_forms_Ri (fl_get_browser_maxline, g-> ob_generic); -} - -static PyObject * -select_browser_line (genericobject *g, PyObject *args) -{ - return call_forms_INi (fl_select_browser_line, g-> ob_generic, args); -} - -static PyObject * -deselect_browser_line (genericobject *g, PyObject *args) -{ - return call_forms_INi (fl_deselect_browser_line, g-> ob_generic, args); -} - -static PyObject * -deselect_browser (genericobject *g) -{ - return generic_call (g, fl_deselect_browser); -} - -static PyObject * -isselected_browser_line (genericobject *g, PyObject *args) -{ - int i, j; - - if (!PyArg_Parse(args, "i", &i)) - return NULL; - - j = fl_isselected_browser_line (g->ob_generic, i); - - return PyInt_FromLong (j); -} - -static PyObject * -get_browser (genericobject *g) -{ - return call_forms_Ri (fl_get_browser, g-> ob_generic); -} - -static PyObject * -set_browser_fontsize (genericobject *g, PyObject *args) -{ - return call_forms_INf (fl_set_browser_fontsize, g-> ob_generic, args); -} - -static PyObject * -set_browser_fontstyle (genericobject *g, PyObject *args) -{ - return call_forms_INi (fl_set_browser_fontstyle, g-> ob_generic, args); -} - -static PyObject * -set_browser_specialkey (genericobject *g, PyObject *args) -{ - return call_forms_INc(fl_set_browser_specialkey, g-> ob_generic, args); -} - -static PyMethodDef browser_methods[] = { - {"set_browser_topline", (PyCFunction)set_browser_topline, - METH_OLDARGS}, - {"clear_browser", (PyCFunction)clear_browser, - METH_NOARGS}, - {"add_browser_line", (PyCFunction)add_browser_line, - METH_OLDARGS}, - {"addto_browser", (PyCFunction)addto_browser, - METH_OLDARGS}, - {"insert_browser_line", (PyCFunction)insert_browser_line, - METH_OLDARGS}, - {"delete_browser_line", (PyCFunction)delete_browser_line, - METH_OLDARGS}, - {"replace_browser_line", (PyCFunction)replace_browser_line, - METH_OLDARGS}, - {"get_browser_line", (PyCFunction)get_browser_line, - METH_OLDARGS}, - {"load_browser", (PyCFunction)load_browser, - METH_OLDARGS}, - {"get_browser_maxline", (PyCFunction)get_browser_maxline, - METH_NOARGS,} - {"select_browser_line", (PyCFunction)select_browser_line, - METH_OLDARGS}, - {"deselect_browser_line", (PyCFunction)deselect_browser_line, - METH_OLDARGS}, - {"deselect_browser", (PyCFunction)deselect_browser, - METH_NOARGS,} - {"isselected_browser_line", (PyCFunction)isselected_browser_line, - METH_OLDARGS}, - {"get_browser", (PyCFunction)get_browser, - METH_NOARGS,} - {"set_browser_fontsize", (PyCFunction)set_browser_fontsize, - METH_OLDARGS}, - {"set_browser_fontstyle", (PyCFunction)set_browser_fontstyle, - METH_OLDARGS}, - {"set_browser_specialkey", (PyCFunction)set_browser_specialkey, - METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - -/* Class: button */ - -static PyObject * -set_button(genericobject *g, PyObject *args) -{ - return call_forms_INi (fl_set_button, g-> ob_generic, args); -} - -static PyObject * -get_button(genericobject *g) -{ - return call_forms_Ri (fl_get_button, g-> ob_generic); -} - -static PyObject * -get_button_numb(genericobject *g) -{ - return call_forms_Ri (fl_get_button_numb, g-> ob_generic); -} - -static PyObject * -set_button_shortcut(genericobject *g, PyObject *args) -{ - return call_forms_INstr (fl_set_button_shortcut, g-> ob_generic, args); -} - -static PyMethodDef button_methods[] = { - {"set_button", (PyCFunction)set_button, METH_OLDARGS}, - {"get_button", (PyCFunction)get_button, METH_NOARGS}, - {"get_button_numb", (PyCFunction)get_button_numb, METH_NOARGS}, - {"set_button_shortcut", (PyCFunction)set_button_shortcut, METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - -/* Class: choice */ - -static PyObject * -set_choice(genericobject *g, PyObject *args) -{ - return call_forms_INi (fl_set_choice, g-> ob_generic, args); -} - -static PyObject * -get_choice(genericobject *g) -{ - return call_forms_Ri (fl_get_choice, g-> ob_generic); -} - -static PyObject * -clear_choice (genericobject *g) -{ - return generic_call (g, fl_clear_choice); -} - -static PyObject * -addto_choice (genericobject *g, PyObject *args) -{ - return call_forms_INstr (fl_addto_choice, g-> ob_generic, args); -} - -static PyObject * -replace_choice (genericobject *g, PyObject *args) -{ - return call_forms_INiINstr (fl_replace_choice, g-> ob_generic, args); -} - -static PyObject * -delete_choice (genericobject *g, PyObject *args) -{ - return call_forms_INi (fl_delete_choice, g-> ob_generic, args); -} - -static PyObject * -get_choice_text (genericobject *g) -{ - return call_forms_Rstr (fl_get_choice_text, g-> ob_generic); -} - -static PyObject * -set_choice_fontsize (genericobject *g, PyObject *args) -{ - return call_forms_INf (fl_set_choice_fontsize, g-> ob_generic, args); -} - -static PyObject * -set_choice_fontstyle (genericobject *g, PyObject *args) -{ - return call_forms_INi (fl_set_choice_fontstyle, g-> ob_generic, args); -} - -static PyMethodDef choice_methods[] = { - {"set_choice", (PyCFunction)set_choice, METH_OLDARGS}, - {"get_choice", (PyCFunction)get_choice, METH_NOARGS}, - {"clear_choice", (PyCFunction)clear_choice, METH_NOARGS}, - {"addto_choice", (PyCFunction)addto_choice, METH_OLDARGS}, - {"replace_choice", (PyCFunction)replace_choice, METH_OLDARGS}, - {"delete_choice", (PyCFunction)delete_choice, METH_OLDARGS}, - {"get_choice_text", (PyCFunction)get_choice_text, METH_NOARGS}, - {"set_choice_fontsize", (PyCFunction)set_choice_fontsize, METH_OLDARGS}, - {"set_choice_fontstyle",(PyCFunction)set_choice_fontstyle, METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - -/* Class : Clock */ - -static PyObject * -get_clock(genericobject *g) -{ - int i0, i1, i2; - - fl_get_clock (g->ob_generic, &i0, &i1, &i2); - - return Py_BuildValue("(iii)", i0, i1, i2); -} - -static PyMethodDef clock_methods[] = { - {"get_clock", (PyCFunction)get_clock, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - -/* CLass : Counters */ - -static PyObject * -get_counter_value(genericobject *g) -{ - return call_forms_Rf (fl_get_counter_value, g-> ob_generic); -} - -static PyObject * -set_counter_value (genericobject *g, PyObject *args) -{ - return call_forms_INf (fl_set_counter_value, g-> ob_generic, args); -} - -static PyObject * -set_counter_precision (genericobject *g, PyObject *args) -{ - return call_forms_INi (fl_set_counter_precision, g-> ob_generic, args); -} - -static PyObject * -set_counter_bounds (genericobject *g, PyObject *args) -{ - return call_forms_INfINf (fl_set_counter_bounds, g-> ob_generic, args); -} - -static PyObject * -set_counter_step (genericobject *g, PyObject *args) -{ - return call_forms_INfINf (fl_set_counter_step, g-> ob_generic, args); -} - -static PyObject * -set_counter_return (genericobject *g, PyObject *args) -{ - return call_forms_INi (fl_set_counter_return, g-> ob_generic, args); -} - -static PyMethodDef counter_methods[] = { - {"set_counter_value", (PyCFunction)set_counter_value, - METH_OLDARGS}, - {"get_counter_value", (PyCFunction)get_counter_value, - METH_NOARGS}, - {"set_counter_bounds", (PyCFunction)set_counter_bounds, - METH_OLDARGS}, - {"set_counter_step", (PyCFunction)set_counter_step, - METH_OLDARGS}, - {"set_counter_precision", (PyCFunction)set_counter_precision, - METH_OLDARGS}, - {"set_counter_return", (PyCFunction)set_counter_return, - METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - - -/* Class: Dials */ - -static PyObject * -get_dial_value(genericobject *g) -{ - return call_forms_Rf (fl_get_dial_value, g-> ob_generic); -} - -static PyObject * -set_dial_value (genericobject *g, PyObject *args) -{ - return call_forms_INf (fl_set_dial_value, g-> ob_generic, args); -} - -static PyObject * -set_dial_bounds (genericobject *g, PyObject *args) -{ - return call_forms_INfINf (fl_set_dial_bounds, g-> ob_generic, args); -} - -static PyObject * -get_dial_bounds (genericobject *g) -{ - return call_forms_OUTfOUTf (fl_get_dial_bounds, g-> ob_generic); -} - -static PyObject * -set_dial_step (genericobject *g, PyObject *args) -{ - return call_forms_INf (fl_set_dial_step, g-> ob_generic, args); -} - -static PyMethodDef dial_methods[] = { - {"set_dial_value", (PyCFunction)set_dial_value, METH_OLDARGS}, - {"get_dial_value", (PyCFunction)get_dial_value, METH_NOARGS}, - {"set_dial_bounds", (PyCFunction)set_dial_bounds, METH_OLDARGS}, - {"get_dial_bounds", (PyCFunction)get_dial_bounds, METH_NOARGS}, - {"set_dial_step", (PyCFunction)set_dial_step, METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - -/* Class : Input */ - -static PyObject * -set_input (genericobject *g, PyObject *args) -{ - return call_forms_INstr (fl_set_input, g-> ob_generic, args); -} - -static PyObject * -get_input (genericobject *g) -{ - return call_forms_Rstr (fl_get_input, g-> ob_generic); -} - -static PyObject * -set_input_color (genericobject *g, PyObject *args) -{ - return call_forms_INfINf (fl_set_input_color, g-> ob_generic, args); -} - -static PyObject * -set_input_return (genericobject *g, PyObject *args) -{ - return call_forms_INi (fl_set_input_return, g-> ob_generic, args); -} - -static PyMethodDef input_methods[] = { - {"set_input", (PyCFunction)set_input, METH_OLDARGS}, - {"get_input", (PyCFunction)get_input, METH_NOARGS}, - {"set_input_color", (PyCFunction)set_input_color, METH_OLDARGS}, - {"set_input_return", (PyCFunction)set_input_return, METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - - -/* Class : Menu */ - -static PyObject * -set_menu (genericobject *g, PyObject *args) -{ - return call_forms_INstr (fl_set_menu, g-> ob_generic, args); -} - -static PyObject * -get_menu (genericobject *g) -{ - /* XXX strictly speaking this is wrong since fl_get_menu - XXX returns long, not int */ - return call_forms_Ri (fl_get_menu, g-> ob_generic); -} - -static PyObject * -get_menu_text (genericobject *g) -{ - return call_forms_Rstr (fl_get_menu_text, g-> ob_generic); -} - -static PyObject * -addto_menu (genericobject *g, PyObject *args) -{ - return call_forms_INstr (fl_addto_menu, g-> ob_generic, args); -} - -static PyMethodDef menu_methods[] = { - {"set_menu", (PyCFunction)set_menu, METH_OLDARGS}, - {"get_menu", (PyCFunction)get_menu, METH_NOARGS}, - {"get_menu_text", (PyCFunction)get_menu_text, METH_NOARGS}, - {"addto_menu", (PyCFunction)addto_menu, METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - - -/* Class: Sliders */ - -static PyObject * -get_slider_value(genericobject *g) -{ - return call_forms_Rf (fl_get_slider_value, g-> ob_generic); -} - -static PyObject * -set_slider_value (genericobject *g, PyObject *args) -{ - return call_forms_INf (fl_set_slider_value, g-> ob_generic, args); -} - -static PyObject * -set_slider_bounds (genericobject *g, PyObject *args) -{ - return call_forms_INfINf (fl_set_slider_bounds, g-> ob_generic, args); -} - -static PyObject * -get_slider_bounds (genericobject *g) -{ - return call_forms_OUTfOUTf(fl_get_slider_bounds, g-> ob_generic); -} - -static PyObject * -set_slider_return (genericobject *g, PyObject *args) -{ - return call_forms_INf (fl_set_slider_return, g-> ob_generic, args); -} - -static PyObject * -set_slider_size (genericobject *g, PyObject *args) -{ - return call_forms_INf (fl_set_slider_size, g-> ob_generic, args); -} - -static PyObject * -set_slider_precision (genericobject *g, PyObject *args) -{ - return call_forms_INi (fl_set_slider_precision, g-> ob_generic, args); -} - -static PyObject * -set_slider_step (genericobject *g, PyObject *args) -{ - return call_forms_INf (fl_set_slider_step, g-> ob_generic, args); -} - - -static PyMethodDef slider_methods[] = { - {"set_slider_value", (PyCFunction)set_slider_value, METH_OLDARGS}, - {"get_slider_value", (PyCFunction)get_slider_value, METH_NOARGS}, - {"set_slider_bounds", (PyCFunction)set_slider_bounds, METH_OLDARGS}, - {"get_slider_bounds", (PyCFunction)get_slider_bounds, METH_NOARGS}, - {"set_slider_return", (PyCFunction)set_slider_return, METH_OLDARGS}, - {"set_slider_size", (PyCFunction)set_slider_size, METH_OLDARGS}, - {"set_slider_precision",(PyCFunction)set_slider_precision, METH_OLDARGS}, - {"set_slider_step", (PyCFunction)set_slider_step, METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -set_positioner_xvalue (genericobject *g, PyObject *args) -{ - return call_forms_INf (fl_set_positioner_xvalue, g-> ob_generic, args); -} - -static PyObject * -set_positioner_xbounds (genericobject *g, PyObject *args) -{ - return call_forms_INfINf (fl_set_positioner_xbounds, - g-> ob_generic, args); -} - -static PyObject * -set_positioner_yvalue (genericobject *g, PyObject *args) -{ - return call_forms_INf (fl_set_positioner_yvalue, g-> ob_generic, args); -} - -static PyObject * -set_positioner_ybounds (genericobject *g, PyObject *args) -{ - return call_forms_INfINf (fl_set_positioner_ybounds, - g-> ob_generic, args); -} - -static PyObject * -get_positioner_xvalue (genericobject *g) -{ - return call_forms_Rf (fl_get_positioner_xvalue, g-> ob_generic); -} - -static PyObject * -get_positioner_xbounds (genericobject *g) -{ - return call_forms_OUTfOUTf (fl_get_positioner_xbounds, g-> ob_generic); -} - -static PyObject * -get_positioner_yvalue (genericobject *g) -{ - return call_forms_Rf (fl_get_positioner_yvalue, g-> ob_generic); -} - -static PyObject * -get_positioner_ybounds (genericobject *g) -{ - return call_forms_OUTfOUTf (fl_get_positioner_ybounds, g-> ob_generic); -} - -static PyMethodDef positioner_methods[] = { - {"set_positioner_xvalue", (PyCFunction)set_positioner_xvalue, - METH_OLDARGS}, - {"set_positioner_yvalue", (PyCFunction)set_positioner_yvalue, - METH_OLDARGS}, - {"set_positioner_xbounds", (PyCFunction)set_positioner_xbounds, - METH_OLDARGS}, - {"set_positioner_ybounds", (PyCFunction)set_positioner_ybounds, - METH_OLDARGS}, - {"get_positioner_xvalue", (PyCFunction)get_positioner_xvalue, - METH_NOARGS}, - {"get_positioner_yvalue", (PyCFunction)get_positioner_yvalue, - METH_NOARGS}, - {"get_positioner_xbounds", (PyCFunction)get_positioner_xbounds, - METH_NOARGS}, - {"get_positioner_ybounds", (PyCFunction)get_positioner_ybounds, - METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - -/* Class timer */ - -static PyObject * -set_timer (genericobject *g, PyObject *args) -{ - return call_forms_INf (fl_set_timer, g-> ob_generic, args); -} - -static PyObject * -get_timer (genericobject *g) -{ - return call_forms_Rf (fl_get_timer, g-> ob_generic); -} - -static PyMethodDef timer_methods[] = { - {"set_timer", (PyCFunction)set_timer, METH_OLDARGS}, - {"get_timer", (PyCFunction)get_timer, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - -/* Form objects */ - -typedef struct { - PyObject_HEAD - FL_FORM *ob_form; -} formobject; - -static PyTypeObject Formtype; - -#define is_formobject(v) ((v)->ob_type == &Formtype) - -static PyObject * -form_show_form(formobject *f, PyObject *args) -{ - int place, border; - char *name; - if (!PyArg_Parse(args, "(iis)", &place, &border, &name)) - return NULL; - fl_show_form(f->ob_form, place, border, name); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -form_call(void (*func)(FL_FORM *), FL_FORM *f) -{ - (*func)(f); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -form_call_INiINi(void (*func)(FL_FORM *, int, int), FL_FORM *f, PyObject *args) -{ - int a, b; - - if (!PyArg_Parse(args, "(ii)", &a, &b)) return NULL; - - (*func)(f, a, b); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -form_call_INfINf(void (*func)(FL_FORM *, float, float), FL_FORM *f, PyObject *args) -{ - float a, b; - - if (!PyArg_Parse(args, "(ff)", &a, &b)) return NULL; - - (*func)(f, a, b); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -form_hide_form(formobject *f) -{ - return form_call(fl_hide_form, f-> ob_form); -} - -static PyObject * -form_redraw_form(formobject *f) -{ - return form_call(fl_redraw_form, f-> ob_form); -} - -static PyObject * -form_set_form_position(formobject *f, PyObject *args) -{ - return form_call_INiINi(fl_set_form_position, f-> ob_form, args); -} - -static PyObject * -form_set_form_size(formobject *f, PyObject *args) -{ - return form_call_INiINi(fl_set_form_size, f-> ob_form, args); -} - -static PyObject * -form_scale_form(formobject *f, PyObject *args) -{ - return form_call_INfINf(fl_scale_form, f-> ob_form, args); -} - -static PyObject * -generic_add_object(formobject *f, PyObject *args, FL_OBJECT *(*func)(int, float, float, float, float, char*), PyMethodDef *internal_methods) -{ - int type; - float x, y, w, h; - char *name; - FL_OBJECT *obj; - - if (!PyArg_Parse(args,"(iffffs)", &type,&x,&y,&w,&h,&name)) - return NULL; - - fl_addto_form (f-> ob_form); - - obj = (*func) (type, x, y, w, h, name); - - fl_end_form(); - - if (obj == NULL) { - PyErr_NoMemory(); - return NULL; - } - - return newgenericobject (obj, internal_methods); -} - -static PyObject * -form_add_button(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_button, button_methods); -} - -static PyObject * -form_add_lightbutton(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_lightbutton, button_methods); -} - -static PyObject * -form_add_roundbutton(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_roundbutton, button_methods); -} - -static PyObject * -form_add_menu (formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_menu, menu_methods); -} - -static PyObject * -form_add_slider(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_slider, slider_methods); -} - -static PyObject * -form_add_valslider(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_valslider, slider_methods); -} - -static PyObject * -form_add_dial(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_dial, dial_methods); -} - -static PyObject * -form_add_counter(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_counter, counter_methods); -} - -static PyObject * -form_add_clock(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_clock, clock_methods); -} - -static PyObject * -form_add_box(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_box, - (PyMethodDef *)NULL); -} - -static PyObject * -form_add_choice(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_choice, choice_methods); -} - -static PyObject * -form_add_browser(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_browser, browser_methods); -} - -static PyObject * -form_add_positioner(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_positioner, - positioner_methods); -} - -static PyObject * -form_add_input(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_input, input_methods); -} - -static PyObject * -form_add_text(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_text, - (PyMethodDef *)NULL); -} - -static PyObject * -form_add_timer(formobject *f, PyObject *args) -{ - return generic_add_object(f, args, fl_add_timer, timer_methods); -} - -static PyObject * -form_freeze_form(formobject *f) -{ - return form_call(fl_freeze_form, f-> ob_form); -} - -static PyObject * -form_unfreeze_form(formobject *f) -{ - return form_call(fl_unfreeze_form, f-> ob_form); -} - -static PyObject * -form_activate_form(formobject *f) -{ - return form_call(fl_activate_form, f-> ob_form); -} - -static PyObject * -form_deactivate_form(formobject *f) -{ - return form_call(fl_deactivate_form, f-> ob_form); -} - -static PyObject * -form_bgn_group(formobject *f, PyObject *args) -{ - FL_OBJECT *obj; - - fl_addto_form(f-> ob_form); - obj = fl_bgn_group(); - fl_end_form(); - - if (obj == NULL) { - PyErr_NoMemory(); - return NULL; - } - - return newgenericobject (obj, (PyMethodDef *) NULL); -} - -static PyObject * -form_end_group(formobject *f, PyObject *args) -{ - fl_addto_form(f-> ob_form); - fl_end_group(); - fl_end_form(); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -forms_find_first_or_last(FL_OBJECT *(*func)(FL_FORM *, int, float, float), formobject *f, PyObject *args) -{ - int type; - float mx, my; - FL_OBJECT *generic; - genericobject *g; - - if (!PyArg_Parse(args, "(iff)", &type, &mx, &my)) return NULL; - - generic = (*func) (f-> ob_form, type, mx, my); - - if (generic == NULL) - { - Py_INCREF(Py_None); - return Py_None; - } - - g = findgeneric(generic); - if (g == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "forms_find_{first|last} returns unknown object"); - return NULL; - } - Py_INCREF(g); - return (PyObject *) g; -} - -static PyObject * -form_find_first(formobject *f, PyObject *args) -{ - return forms_find_first_or_last(fl_find_first, f, args); -} - -static PyObject * -form_find_last(formobject *f, PyObject *args) -{ - return forms_find_first_or_last(fl_find_last, f, args); -} - -static PyObject * -form_set_object_focus(formobject *f, PyObject *args) -{ - genericobject *g; - if (args == NULL || !is_genericobject(args)) { - PyErr_BadArgument(); - return NULL; - } - g = (genericobject *)args; - fl_set_object_focus(f->ob_form, g->ob_generic); - Py_INCREF(Py_None); - return Py_None; -} - -static PyMethodDef form_methods[] = { -/* adm */ - {"show_form", (PyCFunction)form_show_form, METH_OLDARGS}, - {"hide_form", (PyCFunction)form_hide_form, METH_NOARGS}, - {"redraw_form", (PyCFunction)form_redraw_form, METH_NOARGS}, - {"set_form_position", (PyCFunction)form_set_form_position, METH_OLDARGS}, - {"set_form_size", (PyCFunction)form_set_form_size, METH_OLDARGS}, - {"scale_form", (PyCFunction)form_scale_form, METH_OLDARGS}, - {"freeze_form", (PyCFunction)form_freeze_form, METH_NOARGS}, - {"unfreeze_form", (PyCFunction)form_unfreeze_form, METH_NOARGS}, - {"activate_form", (PyCFunction)form_activate_form, METH_NOARGS}, - {"deactivate_form", (PyCFunction)form_deactivate_form, METH_NOARGS}, - {"bgn_group", (PyCFunction)form_bgn_group, METH_OLDARGS}, - {"end_group", (PyCFunction)form_end_group, METH_OLDARGS}, - {"find_first", (PyCFunction)form_find_first, METH_OLDARGS}, - {"find_last", (PyCFunction)form_find_last, METH_OLDARGS}, - {"set_object_focus", (PyCFunction)form_set_object_focus, METH_OLDARGS}, - -/* basic objects */ - {"add_button", (PyCFunction)form_add_button, METH_OLDARGS}, -/* {"add_bitmap", (method)form_add_bitmap, METH_OLDARGS}, */ - {"add_lightbutton", (PyCFunction)form_add_lightbutton, METH_OLDARGS}, - {"add_roundbutton", (PyCFunction)form_add_roundbutton, METH_OLDARGS}, - {"add_menu", (PyCFunction)form_add_menu, METH_OLDARGS}, - {"add_slider", (PyCFunction)form_add_slider, METH_OLDARGS}, - {"add_positioner", (PyCFunction)form_add_positioner, METH_OLDARGS}, - {"add_valslider", (PyCFunction)form_add_valslider, METH_OLDARGS}, - {"add_dial", (PyCFunction)form_add_dial, METH_OLDARGS}, - {"add_counter", (PyCFunction)form_add_counter, METH_OLDARGS}, - {"add_box", (PyCFunction)form_add_box, METH_OLDARGS}, - {"add_clock", (PyCFunction)form_add_clock, METH_OLDARGS}, - {"add_choice", (PyCFunction)form_add_choice, METH_OLDARGS}, - {"add_browser", (PyCFunction)form_add_browser, METH_OLDARGS}, - {"add_input", (PyCFunction)form_add_input, METH_OLDARGS}, - {"add_timer", (PyCFunction)form_add_timer, METH_OLDARGS}, - {"add_text", (PyCFunction)form_add_text, METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - -static void -form_dealloc(formobject *f) -{ - releaseobjects(f->ob_form); - if (f->ob_form->visible) - fl_hide_form(f->ob_form); - fl_free_form(f->ob_form); - PyObject_Del(f); -} - -#define OFF(x) offsetof(FL_FORM, x) - -static struct memberlist form_memberlist[] = { - {"window", T_LONG, OFF(window), RO}, - {"w", T_FLOAT, OFF(w)}, - {"h", T_FLOAT, OFF(h)}, - {"x", T_FLOAT, OFF(x), RO}, - {"y", T_FLOAT, OFF(y), RO}, - {"deactivated", T_INT, OFF(deactivated)}, - {"visible", T_INT, OFF(visible), RO}, - {"frozen", T_INT, OFF(frozen), RO}, - {"doublebuf", T_INT, OFF(doublebuf)}, - {NULL} /* Sentinel */ -}; - -#undef OFF - -static PyObject * -form_getattr(formobject *f, char *name) -{ - PyObject *meth; - - meth = Py_FindMethod(form_methods, (PyObject *)f, name); - if (meth != NULL) - return meth; - PyErr_Clear(); - return PyMember_Get((char *)f->ob_form, form_memberlist, name); -} - -static int -form_setattr(formobject *f, char *name, PyObject *v) -{ - if (v == NULL) { - PyErr_SetString(PyExc_TypeError, - "can't delete form attributes"); - return -1; - } - - return PyMember_Set((char *)f->ob_form, form_memberlist, name, v); -} - -static PyObject * -form_repr(formobject *f) -{ - char buf[100]; - PyOS_snprintf(buf, sizeof(buf), "", - f, f->ob_form->window); - return PyString_FromString(buf); -} - -static PyTypeObject Formtype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "fl.FORMS_form", /*tp_name*/ - sizeof(formobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)form_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)form_getattr, /*tp_getattr*/ - (setattrfunc)form_setattr, /*tp_setattr*/ - 0, /*tp_compare*/ - (reprfunc)form_repr, /*tp_repr*/ -}; - -static PyObject * -newformobject(FL_FORM *form) -{ - formobject *f; - f = PyObject_New(formobject, &Formtype); - if (f == NULL) - return NULL; - f->ob_form = form; - return (PyObject *)f; -} - - -/* The "fl" module */ - -static PyObject * -forms_make_form(PyObject *dummy, PyObject *args) -{ - int type; - float w, h; - FL_FORM *form; - if (!PyArg_Parse(args, "(iff)", &type, &w, &h)) - return NULL; - form = fl_bgn_form(type, w, h); - if (form == NULL) { - /* XXX Actually, cannot happen! */ - PyErr_NoMemory(); - return NULL; - } - fl_end_form(); - return newformobject(form); -} - -static PyObject * -forms_activate_all_forms(PyObject *f, PyObject *args) -{ - fl_activate_all_forms(); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -forms_deactivate_all_forms(PyObject *f, PyObject *args) -{ - fl_deactivate_all_forms(); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *my_event_callback = NULL; - -static PyObject * -forms_set_event_call_back(PyObject *dummy, PyObject *args) -{ - if (args == Py_None) - args = NULL; - my_event_callback = args; - Py_XINCREF(args); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -forms_do_or_check_forms(PyObject *dummy, FL_OBJECT *(*func)(void)) -{ - FL_OBJECT *generic; - genericobject *g; - PyObject *arg, *res; - - for (;;) { - Py_BEGIN_ALLOW_THREADS - generic = (*func)(); - Py_END_ALLOW_THREADS - if (generic == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - if (generic == FL_EVENT) { - int dev; - short val; - if (my_event_callback == NULL) - return PyInt_FromLong(-1L); - dev = fl_qread(&val); - arg = Py_BuildValue("(ih)", dev, val); - if (arg == NULL) - return NULL; - res = PyEval_CallObject(my_event_callback, arg); - Py_XDECREF(res); - Py_DECREF(arg); - if (res == NULL) - return NULL; /* Callback raised exception */ - continue; - } - g = findgeneric(generic); - if (g == NULL) { - /* Object not known to us (some dialogs cause this) */ - continue; /* Ignore it */ - } - if (g->ob_callback == NULL) { - Py_INCREF(g); - return ((PyObject *) g); - } - arg = Py_BuildValue("(OO)", (PyObject *)g, g->ob_callback_arg); - if (arg == NULL) - return NULL; - res = PyEval_CallObject(g->ob_callback, arg); - Py_XDECREF(res); - Py_DECREF(arg); - if (res == NULL) - return NULL; /* Callback raised exception */ - } -} - -static PyObject * -forms_do_forms(PyObject *dummy) -{ - return forms_do_or_check_forms(dummy, fl_do_forms); -} - -static PyObject * -forms_check_forms(PyObject *dummy) -{ - return forms_do_or_check_forms(dummy, fl_check_forms); -} - -static PyObject * -forms_do_only_forms(PyObject *dummy) -{ - return forms_do_or_check_forms(dummy, fl_do_only_forms); -} - -static PyObject * -forms_check_only_forms(PyObject *dummy) -{ - return forms_do_or_check_forms(dummy, fl_check_only_forms); -} - -#ifdef UNUSED -static PyObject * -fl_call(void (*func)(void)) -{ - (*func)(); - Py_INCREF(Py_None); - return Py_None; -} -#endif - -static PyObject * -forms_set_graphics_mode(PyObject *dummy, PyObject *args) -{ - int rgbmode, doublebuf; - - if (!PyArg_Parse(args, "(ii)", &rgbmode, &doublebuf)) - return NULL; - fl_set_graphics_mode(rgbmode,doublebuf); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -forms_get_rgbmode(PyObject *dummy, PyObject *args) -{ - extern int fl_rgbmode; - - if (args != NULL) { - PyErr_BadArgument(); - return NULL; - } - return PyInt_FromLong((long)fl_rgbmode); -} - -static PyObject * -forms_show_errors(PyObject *dummy, PyObject *args) -{ - int show; - if (!PyArg_Parse(args, "i", &show)) - return NULL; - fl_show_errors(show); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -forms_set_font_name(PyObject *dummy, PyObject *args) -{ - int numb; - char *name; - if (!PyArg_Parse(args, "(is)", &numb, &name)) - return NULL; - fl_set_font_name(numb, name); - Py_INCREF(Py_None); - return Py_None; -} - - -static PyObject * -forms_qdevice(PyObject *self, PyObject *args) -{ - short arg1; - if (!PyArg_Parse(args, "h", &arg1)) - return NULL; - fl_qdevice(arg1); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -forms_unqdevice(PyObject *self, PyObject *args) -{ - short arg1; - if (!PyArg_Parse(args, "h", &arg1)) - return NULL; - fl_unqdevice(arg1); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -forms_isqueued(PyObject *self, PyObject *args) -{ - long retval; - short arg1; - if (!PyArg_Parse(args, "h", &arg1)) - return NULL; - retval = fl_isqueued(arg1); - - return PyInt_FromLong(retval); -} - -static PyObject * -forms_qtest(PyObject *self, PyObject *args) -{ - long retval; - retval = fl_qtest(); - return PyInt_FromLong(retval); -} - - -static PyObject * -forms_qread(PyObject *self, PyObject *args) -{ - int dev; - short val; - Py_BEGIN_ALLOW_THREADS - dev = fl_qread(&val); - Py_END_ALLOW_THREADS - return Py_BuildValue("(ih)", dev, val); -} - -static PyObject * -forms_qreset(PyObject *self) -{ - fl_qreset(); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -forms_qenter(PyObject *self, PyObject *args) -{ - short arg1, arg2; - if (!PyArg_Parse(args, "(hh)", &arg1, &arg2)) - return NULL; - fl_qenter(arg1, arg2); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -forms_color(PyObject *self, PyObject *args) -{ - int arg; - - if (!PyArg_Parse(args, "i", &arg)) return NULL; - - fl_color((short) arg); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -forms_mapcolor(PyObject *self, PyObject *args) -{ - int arg0, arg1, arg2, arg3; - - if (!PyArg_Parse(args, "(iiii)", &arg0, &arg1, &arg2, &arg3)) - return NULL; - - fl_mapcolor(arg0, (short) arg1, (short) arg2, (short) arg3); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -forms_getmcolor(PyObject *self, PyObject *args) -{ - int arg; - short r, g, b; - - if (!PyArg_Parse(args, "i", &arg)) return NULL; - - fl_getmcolor(arg, &r, &g, &b); - - return Py_BuildValue("(hhh)", r, g, b); -} - -static PyObject * -forms_get_mouse(PyObject *self) -{ - float x, y; - - fl_get_mouse(&x, &y); - - return Py_BuildValue("(ff)", x, y); -} - -static PyObject * -forms_tie(PyObject *self, PyObject *args) -{ - short arg1, arg2, arg3; - if (!PyArg_Parse(args, "(hhh)", &arg1, &arg2, &arg3)) - return NULL; - fl_tie(arg1, arg2, arg3); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -forms_show_message(PyObject *f, PyObject *args) -{ - char *a, *b, *c; - - if (!PyArg_Parse(args, "(sss)", &a, &b, &c)) return NULL; - - Py_BEGIN_ALLOW_THREADS - fl_show_message(a, b, c); - Py_END_ALLOW_THREADS - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -forms_show_choice(PyObject *f, PyObject *args) -{ - char *m1, *m2, *m3, *b1, *b2, *b3; - int nb; - char *format; - long rv; - - if (args == NULL || !PyTuple_Check(args)) { - PyErr_BadArgument(); - return NULL; - } - nb = PyTuple_Size(args) - 3; - if (nb <= 0) { - PyErr_SetString(PyExc_TypeError, - "need at least one button label"); - return NULL; - } - if (PyInt_Check(PyTuple_GetItem(args, 3))) { - PyErr_SetString(PyExc_TypeError, - "'number-of-buttons' argument not needed"); - return NULL; - } - switch (nb) { - case 1: format = "(ssss)"; break; - case 2: format = "(sssss)"; break; - case 3: format = "(ssssss)"; break; - default: - PyErr_SetString(PyExc_TypeError, "too many button labels"); - return NULL; - } - - if (!PyArg_Parse(args, format, &m1, &m2, &m3, &b1, &b2, &b3)) - return NULL; - - Py_BEGIN_ALLOW_THREADS - rv = fl_show_choice(m1, m2, m3, nb, b1, b2, b3); - Py_END_ALLOW_THREADS - return PyInt_FromLong(rv); -} - -static PyObject * -forms_show_question(PyObject *f, PyObject *args) -{ - int ret; - char *a, *b, *c; - - if (!PyArg_Parse(args, "(sss)", &a, &b, &c)) return NULL; - - Py_BEGIN_ALLOW_THREADS - ret = fl_show_question(a, b, c); - Py_END_ALLOW_THREADS - - return PyInt_FromLong((long) ret); -} - -static PyObject * -forms_show_input(PyObject *f, PyObject *args) -{ - char *str; - char *a, *b; - - if (!PyArg_Parse(args, "(ss)", &a, &b)) return NULL; - - Py_BEGIN_ALLOW_THREADS - str = fl_show_input(a, b); - Py_END_ALLOW_THREADS - - if (str == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyString_FromString(str); -} - -static PyObject * -forms_file_selector(PyObject *f, PyObject *args) -{ - char *str; - char *a, *b, *c, *d; - - if (!PyArg_Parse(args, "(ssss)", &a, &b, &c, &d)) return NULL; - - Py_BEGIN_ALLOW_THREADS - str = fl_show_file_selector(a, b, c, d); - Py_END_ALLOW_THREADS - - if (str == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyString_FromString(str); -} - - -static PyObject * -forms_file_selector_func(PyObject *args, char *(*func)(void)) -{ - char *str; - - str = (*func) (); - - if (str == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyString_FromString(str); -} - -static PyObject * -forms_get_directory(PyObject *f, PyObject *args) -{ - return forms_file_selector_func(args, fl_get_directory); -} - -static PyObject * -forms_get_pattern(PyObject *f, PyObject *args) -{ - return forms_file_selector_func(args, fl_get_pattern); -} - -static PyObject * -forms_get_filename(PyObject *f, PyObject *args) -{ - return forms_file_selector_func(args, fl_get_filename); -} - -static PyMethodDef forms_methods[] = { -/* adm */ - {"make_form", forms_make_form, METH_OLDARGS}, - {"activate_all_forms", forms_activate_all_forms, METH_OLDARGS}, - {"deactivate_all_forms",forms_deactivate_all_forms, METH_OLDARGS}, -/* gl support wrappers */ - {"qdevice", forms_qdevice, METH_OLDARGS}, - {"unqdevice", forms_unqdevice, METH_OLDARGS}, - {"isqueued", forms_isqueued, METH_OLDARGS}, - {"qtest", forms_qtest, METH_OLDARGS}, - {"qread", forms_qread, METH_OLDARGS}, -/* {"blkqread", forms_blkqread, METH_OLDARGS}, */ - {"qreset", forms_qreset, METH_NOARGS}, - {"qenter", forms_qenter, METH_OLDARGS}, - {"get_mouse", forms_get_mouse, METH_NOARGS}, - {"tie", forms_tie, METH_OLDARGS}, -/* {"new_events", forms_new_events, METH_OLDARGS}, */ - {"color", forms_color, METH_OLDARGS}, - {"mapcolor", forms_mapcolor, METH_OLDARGS}, - {"getmcolor", forms_getmcolor, METH_OLDARGS}, -/* interaction */ - {"do_forms", forms_do_forms, METH_NOARGS}, - {"do_only_forms", forms_do_only_forms, METH_NOARGS}, - {"check_forms", forms_check_forms, METH_NOARGS}, - {"check_only_forms", forms_check_only_forms, METH_NOARGS}, - {"set_event_call_back", forms_set_event_call_back, METH_OLDARGS}, -/* goodies */ - {"show_message", forms_show_message, METH_OLDARGS}, - {"show_question", forms_show_question, METH_OLDARGS}, - {"show_choice", forms_show_choice, METH_OLDARGS}, - {"show_input", forms_show_input, METH_OLDARGS}, - {"show_file_selector", forms_file_selector, METH_OLDARGS}, - {"file_selector", forms_file_selector, METH_OLDARGS}, /* BW compat */ - {"get_directory", forms_get_directory, METH_OLDARGS}, - {"get_pattern", forms_get_pattern, METH_OLDARGS}, - {"get_filename", forms_get_filename, METH_OLDARGS}, - {"set_graphics_mode", forms_set_graphics_mode, METH_OLDARGS}, - {"get_rgbmode", forms_get_rgbmode, METH_OLDARGS}, - {"show_errors", forms_show_errors, METH_OLDARGS}, - {"set_font_name", forms_set_font_name, METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - -PyMODINIT_FUNC -initfl(void) -{ - Py_InitModule("fl", forms_methods); - foreground(); - fl_init(); -} - - - diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/fmmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/fmmodule.c deleted file mode 100644 index e8710840..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/fmmodule.c +++ /dev/null @@ -1,262 +0,0 @@ - -/* Font Manager module */ - -#include "Python.h" - -#include -#include -#include - - -/* Font Handle object implementation */ - -typedef struct { - PyObject_HEAD - fmfonthandle fh_fh; -} fhobject; - -static PyTypeObject Fhtype; - -#define is_fhobject(v) ((v)->ob_type == &Fhtype) - -static PyObject * -newfhobject(fmfonthandle fh) -{ - fhobject *fhp; - if (fh == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "error creating new font handle"); - return NULL; - } - fhp = PyObject_New(fhobject, &Fhtype); - if (fhp == NULL) - return NULL; - fhp->fh_fh = fh; - return (PyObject *)fhp; -} - -/* Font Handle methods */ - -static PyObject * -fh_scalefont(fhobject *self, PyObject *args) -{ - double size; - if (!PyArg_Parse(args, "d", &size)) - return NULL; - return newfhobject(fmscalefont(self->fh_fh, size)); -} - -/* XXX fmmakefont */ - -static PyObject * -fh_setfont(fhobject *self) -{ - fmsetfont(self->fh_fh); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -fh_getfontname(fhobject *self) -{ - char fontname[256]; - int len; - len = fmgetfontname(self->fh_fh, sizeof fontname, fontname); - if (len < 0) { - PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontname"); - return NULL; - } - return PyString_FromStringAndSize(fontname, len); -} - -static PyObject * -fh_getcomment(fhobject *self) -{ - char comment[256]; - int len; - len = fmgetcomment(self->fh_fh, sizeof comment, comment); - if (len < 0) { - PyErr_SetString(PyExc_RuntimeError, "error in fmgetcomment"); - return NULL; - } - return PyString_FromStringAndSize(comment, len); -} - -static PyObject * -fh_getfontinfo(fhobject *self) -{ - fmfontinfo info; - if (fmgetfontinfo(self->fh_fh, &info) < 0) { - PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontinfo"); - return NULL; - } - return Py_BuildValue("(llllllll)", - info.printermatched, - info.fixed_width, - info.xorig, - info.yorig, - info.xsize, - info.ysize, - info.height, - info.nglyphs); -} - -#if 0 -static PyObject * -fh_getwholemetrics(fhobject *self, PyObject *args) -{ -} -#endif - -static PyObject * -fh_getstrwidth(fhobject *self, PyObject *args) -{ - char *str; - if (!PyArg_Parse(args, "s", &str)) - return NULL; - return PyInt_FromLong(fmgetstrwidth(self->fh_fh, str)); -} - -static PyMethodDef fh_methods[] = { - {"scalefont", (PyCFunction)fh_scalefont, METH_OLDARGS}, - {"setfont", (PyCFunction)fh_setfont, METH_NOARGS}, - {"getfontname", (PyCFunction)fh_getfontname, METH_NOARGS}, - {"getcomment", (PyCFunction)fh_getcomment, METH_NOARGS}, - {"getfontinfo", (PyCFunction)fh_getfontinfo, METH_NOARGS}, -#if 0 - {"getwholemetrics", (PyCFunction)fh_getwholemetrics, METH_OLDARGS}, -#endif - {"getstrwidth", (PyCFunction)fh_getstrwidth, METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -fh_getattr(fhobject *fhp, char *name) -{ - return Py_FindMethod(fh_methods, (PyObject *)fhp, name); -} - -static void -fh_dealloc(fhobject *fhp) -{ - fmfreefont(fhp->fh_fh); - PyObject_Del(fhp); -} - -static PyTypeObject Fhtype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "fm.font handle", /*tp_name*/ - sizeof(fhobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)fh_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)fh_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ -}; - - -/* Font Manager functions */ - -static PyObject * -fm_init(PyObject *self) -{ - fminit(); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -fm_findfont(PyObject *self, PyObject *args) -{ - char *str; - if (!PyArg_Parse(args, "s", &str)) - return NULL; - return newfhobject(fmfindfont(str)); -} - -static PyObject * -fm_prstr(PyObject *self, PyObject *args) -{ - char *str; - if (!PyArg_Parse(args, "s", &str)) - return NULL; - fmprstr(str); - Py_INCREF(Py_None); - return Py_None; -} - -/* XXX This uses a global variable as temporary! Not re-entrant! */ - -static PyObject *fontlist; - -static void -clientproc(char *fontname) -{ - int err; - PyObject *v; - if (fontlist == NULL) - return; - v = PyString_FromString(fontname); - if (v == NULL) - err = -1; - else { - err = PyList_Append(fontlist, v); - Py_DECREF(v); - } - if (err != 0) { - Py_DECREF(fontlist); - fontlist = NULL; - } -} - -static PyObject * -fm_enumerate(PyObject *self) -{ - PyObject *res; - fontlist = PyList_New(0); - if (fontlist == NULL) - return NULL; - fmenumerate(clientproc); - res = fontlist; - fontlist = NULL; - return res; -} - -static PyObject * -fm_setpath(PyObject *self, PyObject *args) -{ - char *str; - if (!PyArg_Parse(args, "s", &str)) - return NULL; - fmsetpath(str); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -fm_fontpath(PyObject *self) -{ - return PyString_FromString(fmfontpath()); -} - -static PyMethodDef fm_methods[] = { - {"init", fm_init, METH_NOARGS}, - {"findfont", fm_findfont, METH_OLDARGS}, - {"enumerate", fm_enumerate, METH_NOARGS}, - {"prstr", fm_prstr, METH_OLDARGS}, - {"setpath", fm_setpath, METH_OLDARGS}, - {"fontpath", fm_fontpath, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - - -void -initfm(void) -{ - Py_InitModule("fm", fm_methods); - fminit(); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/fpectlmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/fpectlmodule.c deleted file mode 100644 index 57466b58..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/fpectlmodule.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - --------------------------------------------------------------------- - / Copyright (c) 1996. \ - | The Regents of the University of California. | - | All rights reserved. | - | | - | Permission to use, copy, modify, and distribute this software for | - | any purpose without fee is hereby granted, provided that this en- | - | tire notice is included in all copies of any software which is or | - | includes a copy or modification of this software and in all | - | copies of the supporting documentation for such software. | - | | - | This work was produced at the University of California, Lawrence | - | Livermore National Laboratory under contract no. W-7405-ENG-48 | - | between the U.S. Department of Energy and The Regents of the | - | University of California for the operation of UC LLNL. | - | | - | DISCLAIMER | - | | - | This software was prepared as an account of work sponsored by an | - | agency of the United States Government. Neither the United States | - | Government nor the University of California nor any of their em- | - | ployees, makes any warranty, express or implied, or assumes any | - | liability or responsibility for the accuracy, completeness, or | - | usefulness of any information, apparatus, product, or process | - | disclosed, or represents that its use would not infringe | - | privately-owned rights. Reference herein to any specific commer- | - | cial products, process, or service by trade name, trademark, | - | manufacturer, or otherwise, does not necessarily constitute or | - | imply its endorsement, recommendation, or favoring by the United | - | States Government or the University of California. The views and | - | opinions of authors expressed herein do not necessarily state or | - | reflect those of the United States Government or the University | - | of California, and shall not be used for advertising or product | - \ endorsement purposes. / - --------------------------------------------------------------------- -*/ - -/* - Floating point exception control module. - - This Python module provides bare-bones control over floating point - units from several hardware manufacturers. Specifically, it allows - the user to turn on the generation of SIGFPE whenever any of the - three serious IEEE 754 exceptions (Division by Zero, Overflow, - Invalid Operation) occurs. We currently ignore Underflow and - Inexact Result exceptions, although those could certainly be added - if desired. - - The module also establishes a signal handler for SIGFPE during - initialization. This builds on code found in the Python - distribution at Include/pyfpe.h and Python/pyfpe.c. If those files - are not in your Python distribution, find them in a patch at - ftp://icf.llnl.gov/pub/python/busby/patches.961108.tgz. - - This module is only useful to you if it happens to include code - specific for your hardware and software environment. If you can - contribute OS-specific code for new platforms, or corrections for - the code provided, it will be greatly appreciated. - - ** Version 1.0: September 20, 1996. Lee Busby, LLNL. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "Python.h" -#include - -#if defined(__FreeBSD__) -# include -#endif - -#ifndef WANT_SIGFPE_HANDLER -/* Define locally if they are not defined in Python. This gives only - * the limited control to induce a core dump in case of an exception. - */ -#include -static jmp_buf PyFPE_jbuf; -static int PyFPE_counter = 0; -#endif - -typedef void Sigfunc(int); -static Sigfunc sigfpe_handler; -static void fpe_reset(Sigfunc *); - -static PyObject *fpe_error; -PyMODINIT_FUNC initfpectl(void); -static PyObject *turnon_sigfpe (PyObject *self,PyObject *args); -static PyObject *turnoff_sigfpe (PyObject *self,PyObject *args); - -static PyMethodDef fpectl_methods[] = { - {"turnon_sigfpe", (PyCFunction) turnon_sigfpe, METH_VARARGS}, - {"turnoff_sigfpe", (PyCFunction) turnoff_sigfpe, METH_VARARGS}, - {0,0} -}; - -static PyObject *turnon_sigfpe(PyObject *self,PyObject *args) -{ - /* Do any architecture-specific one-time only initialization here. */ - - fpe_reset(sigfpe_handler); - Py_INCREF (Py_None); - return Py_None; -} - -static void fpe_reset(Sigfunc *handler) -{ - /* Reset the exception handling machinery, and reset the signal - * handler for SIGFPE to the given handler. - */ - -/*-- IRIX -----------------------------------------------------------------*/ -#if defined(sgi) - /* See man page on handle_sigfpes -- must link with -lfpe - * My usage doesn't follow the man page exactly. Maybe somebody - * else can explain handle_sigfpes to me.... - * cc -c -I/usr/local/python/include fpectlmodule.c - * ld -shared -o fpectlmodule.so fpectlmodule.o -lfpe - */ -#include - typedef void user_routine (unsigned[5], int[2]); - typedef void abort_routine (unsigned long); - handle_sigfpes(_OFF, 0, - (user_routine *)0, - _TURN_OFF_HANDLER_ON_ERROR, - NULL); - handle_sigfpes(_ON, _EN_OVERFL | _EN_DIVZERO | _EN_INVALID, - (user_routine *)0, - _ABORT_ON_ERROR, - NULL); - PyOS_setsig(SIGFPE, handler); - -/*-- SunOS and Solaris ----------------------------------------------------*/ -#elif defined(sun) - /* References: ieee_handler, ieee_sun, ieee_functions, and ieee_flags - man pages (SunOS or Solaris) - cc -c -I/usr/local/python/include fpectlmodule.c - ld -G -o fpectlmodule.so -L/opt/SUNWspro/lib fpectlmodule.o -lsunmath -lm - */ -#include -#ifndef _SUNMATH_H - extern void nonstandard_arithmetic(void); - extern int ieee_flags(const char*, const char*, const char*, char **); - extern long ieee_handler(const char*, const char*, sigfpe_handler_type); -#endif - - char *mode="exception", *in="all", *out; - (void) nonstandard_arithmetic(); - (void) ieee_flags("clearall",mode,in,&out); - (void) ieee_handler("set","common",(sigfpe_handler_type)handler); - PyOS_setsig(SIGFPE, handler); - -/*-- HPUX -----------------------------------------------------------------*/ -#elif defined(__hppa) || defined(hppa) - /* References: fpsetmask man page */ - /* cc -Aa +z -c -I/usr/local/python/include fpectlmodule.c */ - /* ld -b -o fpectlmodule.sl fpectlmodule.o -lm */ -#include - fpsetdefaults(); - PyOS_setsig(SIGFPE, handler); - -/*-- IBM AIX --------------------------------------------------------------*/ -#elif defined(__AIX) || defined(_AIX) - /* References: fp_trap, fp_enable man pages */ -#include - fp_trap(FP_TRAP_SYNC); - fp_enable(TRP_INVALID | TRP_DIV_BY_ZERO | TRP_OVERFLOW); - PyOS_setsig(SIGFPE, handler); - -/*-- DEC ALPHA OSF --------------------------------------------------------*/ -#elif defined(__alpha) && defined(__osf__) - /* References: exception_intro, ieee man pages */ - /* cc -c -I/usr/local/python/include fpectlmodule.c */ - /* ld -shared -o fpectlmodule.so fpectlmodule.o */ -#include - unsigned long fp_control = - IEEE_TRAP_ENABLE_INV | IEEE_TRAP_ENABLE_DZE | IEEE_TRAP_ENABLE_OVF; - ieee_set_fp_control(fp_control); - PyOS_setsig(SIGFPE, handler); - -/*-- DEC ALPHA LINUX ------------------------------------------------------*/ -#elif defined(__alpha) && defined(linux) -#include - unsigned long fp_control = - IEEE_TRAP_ENABLE_INV | IEEE_TRAP_ENABLE_DZE | IEEE_TRAP_ENABLE_OVF; - ieee_set_fp_control(fp_control); - PyOS_setsig(SIGFPE, handler); - -/*-- DEC ALPHA VMS --------------------------------------------------------*/ -#elif defined(__ALPHA) && defined(__VMS) - PyOS_setsig(SIGFPE, handler); - -/*-- Cray Unicos ----------------------------------------------------------*/ -#elif defined(cray) - /* UNICOS delivers SIGFPE by default, but no matherr */ -#ifdef HAS_LIBMSET - libmset(-1); -#endif - PyOS_setsig(SIGFPE, handler); - -/*-- FreeBSD ----------------------------------------------------------------*/ -#elif defined(__FreeBSD__) - fpresetsticky(fpgetsticky()); - fpsetmask(FP_X_INV | FP_X_DZ | FP_X_OFL); - PyOS_setsig(SIGFPE, handler); - -/*-- Linux ----------------------------------------------------------------*/ -#elif defined(linux) -#ifdef __GLIBC__ -#include -#else -#include -#endif -#ifdef _FPU_SETCW - { - fpu_control_t cw = 0x1372; - _FPU_SETCW(cw); - } -#else - __setfpucw(0x1372); -#endif - PyOS_setsig(SIGFPE, handler); - -/*-- Microsoft Windows, NT ------------------------------------------------*/ -#elif defined(_MSC_VER) - /* Reference: Visual C++ Books Online 4.2, - Run-Time Library Reference, _control87, _controlfp */ -#include - unsigned int cw = _EM_INVALID | _EM_ZERODIVIDE | _EM_OVERFLOW; - (void)_controlfp(0, cw); - PyOS_setsig(SIGFPE, handler); - -/*-- Give Up --------------------------------------------------------------*/ -#else - fputs("Operation not implemented\n", stderr); -#endif - -} - -static PyObject *turnoff_sigfpe(PyObject *self,PyObject *args) -{ -#ifdef __FreeBSD__ - fpresetsticky(fpgetsticky()); - fpsetmask(0); -#else - fputs("Operation not implemented\n", stderr); -#endif - Py_INCREF(Py_None); - return Py_None; -} - -static void sigfpe_handler(int signo) -{ - fpe_reset(sigfpe_handler); - if(PyFPE_counter) { - longjmp(PyFPE_jbuf, 1); - } else { - Py_FatalError("Unprotected floating point exception"); - } -} - -PyMODINIT_FUNC initfpectl(void) -{ - PyObject *m, *d; - m = Py_InitModule("fpectl", fpectl_methods); - d = PyModule_GetDict(m); - fpe_error = PyErr_NewException("fpectl.error", NULL, NULL); - if (fpe_error != NULL) - PyDict_SetItemString(d, "error", fpe_error); -} - -#ifdef __cplusplus -} -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/fpetestmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/fpetestmodule.c deleted file mode 100644 index 5932bb12..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/fpetestmodule.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - --------------------------------------------------------------------- - / Copyright (c) 1996. \ - | The Regents of the University of California. | - | All rights reserved. | - | | - | Permission to use, copy, modify, and distribute this software for | - | any purpose without fee is hereby granted, provided that this en- | - | tire notice is included in all copies of any software which is or | - | includes a copy or modification of this software and in all | - | copies of the supporting documentation for such software. | - | | - | This work was produced at the University of California, Lawrence | - | Livermore National Laboratory under contract no. W-7405-ENG-48 | - | between the U.S. Department of Energy and The Regents of the | - | University of California for the operation of UC LLNL. | - | | - | DISCLAIMER | - | | - | This software was prepared as an account of work sponsored by an | - | agency of the United States Government. Neither the United States | - | Government nor the University of California nor any of their em- | - | ployees, makes any warranty, express or implied, or assumes any | - | liability or responsibility for the accuracy, completeness, or | - | usefulness of any information, apparatus, product, or process | - | disclosed, or represents that its use would not infringe | - | privately-owned rights. Reference herein to any specific commer- | - | cial products, process, or service by trade name, trademark, | - | manufacturer, or otherwise, does not necessarily constitute or | - | imply its endorsement, recommendation, or favoring by the United | - | States Government or the University of California. The views and | - | opinions of authors expressed herein do not necessarily state or | - | reflect those of the United States Government or the University | - | of California, and shall not be used for advertising or product | - \ endorsement purposes. / - --------------------------------------------------------------------- -*/ - -/* - Floating point exception test module. - - */ - -#include "Python.h" - -static PyObject *fpe_error; -PyMODINIT_FUNC initfpetest(void); -static PyObject *test(PyObject *self,PyObject *args); -static double db0(double); -static double overflow(double); -static double nest1(int, double); -static double nest2(int, double); -static double nest3(double); -static void printerr(double); - -static PyMethodDef fpetest_methods[] = { - {"test", (PyCFunction) test, METH_VARARGS}, - {0,0} -}; - -static PyObject *test(PyObject *self,PyObject *args) -{ - double r; - - fprintf(stderr,"overflow"); - r = overflow(1.e160); - printerr(r); - - fprintf(stderr,"\ndiv by 0"); - r = db0(0.0); - printerr(r); - - fprintf(stderr,"\nnested outer"); - r = nest1(0, 0.0); - printerr(r); - - fprintf(stderr,"\nnested inner"); - r = nest1(1, 1.0); - printerr(r); - - fprintf(stderr,"\ntrailing outer"); - r = nest1(2, 2.0); - printerr(r); - - fprintf(stderr,"\nnested prior"); - r = nest2(0, 0.0); - printerr(r); - - fprintf(stderr,"\nnested interior"); - r = nest2(1, 1.0); - printerr(r); - - fprintf(stderr,"\nnested trailing"); - r = nest2(2, 2.0); - printerr(r); - - Py_INCREF (Py_None); - return Py_None; -} - -static void printerr(double r) -{ - if(r == 3.1416){ - fprintf(stderr,"\tPASS\n"); - PyErr_Print(); - }else{ - fprintf(stderr,"\tFAIL\n"); - } - PyErr_Clear(); -} - -static double nest1(int i, double x) -{ - double a = 1.0; - - PyFPE_START_PROTECT("Division by zero, outer zone", return 3.1416) - if(i == 0){ - a = 1./x; - }else if(i == 1){ - /* This (following) message is never seen. */ - PyFPE_START_PROTECT("Division by zero, inner zone", return 3.1416) - a = 1./(1. - x); - PyFPE_END_PROTECT(a) - }else if(i == 2){ - a = 1./(2. - x); - } - PyFPE_END_PROTECT(a) - - return a; -} - -static double nest2(int i, double x) -{ - double a = 1.0; - PyFPE_START_PROTECT("Division by zero, prior error", return 3.1416) - if(i == 0){ - a = 1./x; - }else if(i == 1){ - a = nest3(x); - }else if(i == 2){ - a = 1./(2. - x); - } - PyFPE_END_PROTECT(a) - return a; -} - -static double nest3(double x) -{ - double result; - /* This (following) message is never seen. */ - PyFPE_START_PROTECT("Division by zero, nest3 error", return 3.1416) - result = 1./(1. - x); - PyFPE_END_PROTECT(result) - return result; -} - -static double db0(double x) -{ - double a; - PyFPE_START_PROTECT("Division by zero", return 3.1416) - a = 1./x; - PyFPE_END_PROTECT(a) - return a; -} - -static double overflow(double b) -{ - double a; - PyFPE_START_PROTECT("Overflow", return 3.1416) - a = b*b; - PyFPE_END_PROTECT(a) - return a; -} - -PyMODINIT_FUNC initfpetest(void) -{ - PyObject *m, *d; - - m = Py_InitModule("fpetest", fpetest_methods); - d = PyModule_GetDict(m); - fpe_error = PyErr_NewException("fpetest.error", NULL, NULL); - if (fpe_error != NULL) - PyDict_SetItemString(d, "error", fpe_error); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/gc_weakref.txt b/SDKs/XPlatform/Cypython-2.3.3/Modules/gc_weakref.txt deleted file mode 100644 index c6f71e7a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/gc_weakref.txt +++ /dev/null @@ -1,107 +0,0 @@ -Before 2.3.3, Python's cyclic gc didn't pay any attention to weakrefs. -Segfaults in Zope3 resulted. - -weakrefs in Python are designed to, at worst, let *other* objects learn -that a given object has died, via a callback function. The weakly -referenced object itself is not passed to the callback, and the presumption -is that the weakly referenced object is unreachable trash at the time the -callback is invoked. - -That's usually true, but not always. Suppose a weakly referenced object -becomes part of a clump of cyclic trash. When enough cycles are broken by -cyclic gc that the object is reclaimed, the callback is invoked. If it's -possible for the callback to get at objects in the cycle(s), then it may be -possible for those objects to access (via strong references in the cycle) -the weakly referenced object being torn down, or other objects in the cycle -that have already suffered a tp_clear() call. There's no guarantee that an -object is in a sane state after tp_clear(). Bad things (including -segfaults) can happen right then, during the callback's execution, or can -happen at any later time if the callback manages to resurrect an insane -object. - -Note that if it's possible for the callback to get at objects in the trash -cycles, it must also be the case that the callback itself is part of the -trash cycles. Else the callback would have acted as an external root to -the current collection, and nothing reachable from it would be in cyclic -trash either. - -More, if the callback itself is in cyclic trash, then the weakref to which -the callback is attached must also be trash, and for the same kind of -reason: if the weakref acted as an external root, then the callback could -not have been cyclic trash. - -So a problem here requires that a weakref, that weakref's callback, and the -weakly referenced object, all be in cyclic trash at the same time. This -isn't easy to stumble into by accident while Python is running, and, indeed, -it took quite a while to dream up failing test cases. Zope3 saw segfaults -during shutdown, during the second call of gc in Py_Finalize, after most -modules had been torn down. That creates many trash cycles (esp. those -involving new-style classes), making the problem much more likely. Once you -know what's required to provoke the problem, though, it's easy to create -tests that segfault before shutdown. - -In 2.3.3, before breaking cycles, we first clear all the weakrefs with -callbacks in cyclic trash. Since the weakrefs *are* trash, and there's no -defined-- or even predictable --order in which tp_clear() gets called on -cyclic trash, it's defensible to first clear weakrefs with callbacks. It's -a feature of Python's weakrefs too that when a weakref goes away, the -callback (if any) associated with it is thrown away too, unexecuted. - -Just that much is almost enough to prevent problems, by throwing away -*almost* all the weakref callbacks that could get triggered by gc. The -problem remaining is that clearing a weakref with a callback decrefs the -callback object, and the callback object may *itself* be weakly referenced, -via another weakref with another callback. So the process of clearing -weakrefs can trigger callbacks attached to other weakrefs, and those -latter weakrefs may or may not be part of cyclic trash. - -So, to prevent any Python code from running while gc is invoking tp_clear() -on all the objects in cyclic trash, it's not quite enough just to invoke -tp_clear() on weakrefs with callbacks first. Instead the weakref module -grew a new private function (_PyWeakref_ClearRef) that does only part of -tp_clear(): it removes the weakref from the weakly-referenced object's list -of weakrefs, but does not decref the callback object. So calling -_PyWeakref_ClearRef(wr) ensures that wr's callback object will never -trigger, and (unlike weakref's tp_clear()) also prevents any callback -associated *with* wr's callback object from triggering. - -Then we can call tp_clear on all the cyclic objects and never trigger -Python code. - -After we do that, the callback objects still need to be decref'ed. Callbacks -(if any) *on* the callback objects that were also part of cyclic trash won't -get invoked, because we cleared all trash weakrefs with callbacks at the -start. Callbacks on the callback objects that were not part of cyclic trash -acted as external roots to everything reachable from them, so nothing -reachable from them was part of cyclic trash, so gc didn't do any damage to -objects reachable from them, and it's safe to call them at the end of gc. - -An alternative would have been to treat objects with callbacks like objects -with __del__ methods, refusing to collect them, appending them to gc.garbage -instead. That would have been much easier. Jim Fulton gave a strong -argument against that (on Python-Dev): - - There's a big difference between __del__ and weakref callbacks. - The __del__ method is "internal" to a design. When you design a - class with a del method, you know you have to avoid including the - class in cycles. - - Now, suppose you have a design that makes has no __del__ methods but - that does use cyclic data structures. You reason about the design, - run tests, and convince yourself you don't have a leak. - - Now, suppose some external code creates a weakref to one of your - objects. All of a sudden, you start leaking. You can look at your - code all you want and you won't find a reason for the leak. - -IOW, a class designer can out-think __del__ problems, but has no control -over who creates weakrefs to his classes or class instances. The class -user has little chance either of predicting when the weakrefs he creates -may end up in cycles. - -Callbacks on weakref callbacks are executed in an arbitrary order, and -that's not good (a primary reason not to collect cycles with objects with -__del__ methods is to avoid running finalizers in an arbitrary order). -However, a weakref callback on a weakref callback has got to be rare. -It's possible to do such a thing, so gc has to be robust against it, but -I doubt anyone has done it outside the test case I wrote for it. diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/gcmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/gcmodule.c deleted file mode 100644 index a3fcc9b1..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/gcmodule.c +++ /dev/null @@ -1,1232 +0,0 @@ -/* - - Reference Cycle Garbage Collection - ================================== - - Neil Schemenauer - - Based on a post on the python-dev list. Ideas from Guido van Rossum, - Eric Tiedemann, and various others. - - http://www.arctrix.com/nas/python/gc/ - http://www.python.org/pipermail/python-dev/2000-March/003869.html - http://www.python.org/pipermail/python-dev/2000-March/004010.html - http://www.python.org/pipermail/python-dev/2000-March/004022.html - - For a highlevel view of the collection process, read the collect - function. - -*/ - -#include "Python.h" - -/* Get an object's GC head */ -#define AS_GC(o) ((PyGC_Head *)(o)-1) - -/* Get the object given the GC head */ -#define FROM_GC(g) ((PyObject *)(((PyGC_Head *)g)+1)) - -/*** Global GC state ***/ - -struct gc_generation { - PyGC_Head head; - int threshold; /* collection threshold */ - int count; /* count of allocations or collections of younger - generations */ -}; - -#define NUM_GENERATIONS 3 -#define GEN_HEAD(n) (&generations[n].head) - -/* linked lists of container objects */ -static struct gc_generation generations[NUM_GENERATIONS] = { - /* PyGC_Head, threshold, count */ - {{{GEN_HEAD(0), GEN_HEAD(0), 0}}, 700, 0}, - {{{GEN_HEAD(1), GEN_HEAD(1), 0}}, 10, 0}, - {{{GEN_HEAD(2), GEN_HEAD(2), 0}}, 10, 0}, -}; - -PyGC_Head *_PyGC_generation0 = GEN_HEAD(0); - -static int enabled = 1; /* automatic collection enabled? */ - -/* true if we are currently running the collector */ -static int collecting = 0; - -/* list of uncollectable objects */ -static PyObject *garbage = NULL; - -/* Python string to use if unhandled exception occurs */ -static PyObject *gc_str = NULL; - -/* Python string used to look for __del__ attribute. */ -static PyObject *delstr = NULL; - -/* set for debugging information */ -#define DEBUG_STATS (1<<0) /* print collection statistics */ -#define DEBUG_COLLECTABLE (1<<1) /* print collectable objects */ -#define DEBUG_UNCOLLECTABLE (1<<2) /* print uncollectable objects */ -#define DEBUG_INSTANCES (1<<3) /* print instances */ -#define DEBUG_OBJECTS (1<<4) /* print other objects */ -#define DEBUG_SAVEALL (1<<5) /* save all garbage in gc.garbage */ -#define DEBUG_LEAK DEBUG_COLLECTABLE | \ - DEBUG_UNCOLLECTABLE | \ - DEBUG_INSTANCES | \ - DEBUG_OBJECTS | \ - DEBUG_SAVEALL -static int debug; - -/*-------------------------------------------------------------------------- -gc_refs values. - -Between collections, every gc'ed object has one of two gc_refs values: - -GC_UNTRACKED - The initial state; objects returned by PyObject_GC_Malloc are in this - state. The object doesn't live in any generation list, and its - tp_traverse slot must not be called. - -GC_REACHABLE - The object lives in some generation list, and its tp_traverse is safe to - call. An object transitions to GC_REACHABLE when PyObject_GC_Track - is called. - -During a collection, gc_refs can temporarily take on other states: - ->= 0 - At the start of a collection, update_refs() copies the true refcount - to gc_refs, for each object in the generation being collected. - subtract_refs() then adjusts gc_refs so that it equals the number of - times an object is referenced directly from outside the generation - being collected. - gc_refs remains >= 0 throughout these steps. - -GC_TENTATIVELY_UNREACHABLE - move_unreachable() then moves objects not reachable (whether directly or - indirectly) from outside the generation into an "unreachable" set. - Objects that are found to be reachable have gc_refs set to GC_REACHABLE - again. Objects that are found to be unreachable have gc_refs set to - GC_TENTATIVELY_UNREACHABLE. It's "tentatively" because the pass doing - this can't be sure until it ends, and GC_TENTATIVELY_UNREACHABLE may - transition back to GC_REACHABLE. - - Only objects with GC_TENTATIVELY_UNREACHABLE still set are candidates - for collection. If it's decided not to collect such an object (e.g., - it has a __del__ method), its gc_refs is restored to GC_REACHABLE again. ----------------------------------------------------------------------------- -*/ -#define GC_UNTRACKED _PyGC_REFS_UNTRACKED -#define GC_REACHABLE _PyGC_REFS_REACHABLE -#define GC_TENTATIVELY_UNREACHABLE _PyGC_REFS_TENTATIVELY_UNREACHABLE - -#define IS_TRACKED(o) ((AS_GC(o))->gc.gc_refs != GC_UNTRACKED) -#define IS_REACHABLE(o) ((AS_GC(o))->gc.gc_refs == GC_REACHABLE) -#define IS_TENTATIVELY_UNREACHABLE(o) ( \ - (AS_GC(o))->gc.gc_refs == GC_TENTATIVELY_UNREACHABLE) - -/*** list functions ***/ - -static void -gc_list_init(PyGC_Head *list) -{ - list->gc.gc_prev = list; - list->gc.gc_next = list; -} - -static int -gc_list_is_empty(PyGC_Head *list) -{ - return (list->gc.gc_next == list); -} - -static void -gc_list_append(PyGC_Head *node, PyGC_Head *list) -{ - node->gc.gc_next = list; - node->gc.gc_prev = list->gc.gc_prev; - node->gc.gc_prev->gc.gc_next = node; - list->gc.gc_prev = node; -} - -static void -gc_list_remove(PyGC_Head *node) -{ - node->gc.gc_prev->gc.gc_next = node->gc.gc_next; - node->gc.gc_next->gc.gc_prev = node->gc.gc_prev; - node->gc.gc_next = NULL; /* object is not currently tracked */ -} - -/* append a list onto another list, from becomes an empty list */ -static void -gc_list_merge(PyGC_Head *from, PyGC_Head *to) -{ - PyGC_Head *tail; - if (!gc_list_is_empty(from)) { - tail = to->gc.gc_prev; - tail->gc.gc_next = from->gc.gc_next; - tail->gc.gc_next->gc.gc_prev = tail; - to->gc.gc_prev = from->gc.gc_prev; - to->gc.gc_prev->gc.gc_next = to; - } - gc_list_init(from); -} - -static long -gc_list_size(PyGC_Head *list) -{ - PyGC_Head *gc; - long n = 0; - for (gc = list->gc.gc_next; gc != list; gc = gc->gc.gc_next) { - n++; - } - return n; -} - -/* Append objects in a GC list to a Python list. - * Return 0 if all OK, < 0 if error (out of memory for list). - */ -static int -append_objects(PyObject *py_list, PyGC_Head *gc_list) -{ - PyGC_Head *gc; - for (gc = gc_list->gc.gc_next; gc != gc_list; gc = gc->gc.gc_next) { - PyObject *op = FROM_GC(gc); - if (op != py_list) { - if (PyList_Append(py_list, op)) { - return -1; /* exception */ - } - } - } - return 0; -} - -/*** end of list stuff ***/ - - -/* Set all gc_refs = ob_refcnt. After this, gc_refs is > 0 for all objects - * in containers, and is GC_REACHABLE for all tracked gc objects not in - * containers. - */ -static void -update_refs(PyGC_Head *containers) -{ - PyGC_Head *gc = containers->gc.gc_next; - for (; gc != containers; gc = gc->gc.gc_next) { - assert(gc->gc.gc_refs == GC_REACHABLE); - gc->gc.gc_refs = FROM_GC(gc)->ob_refcnt; - } -} - -/* A traversal callback for subtract_refs. */ -static int -visit_decref(PyObject *op, void *data) -{ - assert(op != NULL); - if (PyObject_IS_GC(op)) { - PyGC_Head *gc = AS_GC(op); - /* We're only interested in gc_refs for objects in the - * generation being collected, which can be recognized - * because only they have positive gc_refs. - */ - assert(gc->gc.gc_refs != 0); /* else refcount was too small */ - if (gc->gc.gc_refs > 0) - gc->gc.gc_refs--; - } - return 0; -} - -/* Subtract internal references from gc_refs. After this, gc_refs is >= 0 - * for all objects in containers, and is GC_REACHABLE for all tracked gc - * objects not in containers. The ones with gc_refs > 0 are directly - * reachable from outside containers, and so can't be collected. - */ -static void -subtract_refs(PyGC_Head *containers) -{ - traverseproc traverse; - PyGC_Head *gc = containers->gc.gc_next; - for (; gc != containers; gc=gc->gc.gc_next) { - traverse = FROM_GC(gc)->ob_type->tp_traverse; - (void) traverse(FROM_GC(gc), - (visitproc)visit_decref, - NULL); - } -} - -/* A traversal callback for move_unreachable. */ -static int -visit_reachable(PyObject *op, PyGC_Head *reachable) -{ - if (PyObject_IS_GC(op)) { - PyGC_Head *gc = AS_GC(op); - const int gc_refs = gc->gc.gc_refs; - - if (gc_refs == 0) { - /* This is in move_unreachable's 'young' list, but - * the traversal hasn't yet gotten to it. All - * we need to do is tell move_unreachable that it's - * reachable. - */ - gc->gc.gc_refs = 1; - } - else if (gc_refs == GC_TENTATIVELY_UNREACHABLE) { - /* This had gc_refs = 0 when move_unreachable got - * to it, but turns out it's reachable after all. - * Move it back to move_unreachable's 'young' list, - * and move_unreachable will eventually get to it - * again. - */ - gc_list_remove(gc); - gc_list_append(gc, reachable); - gc->gc.gc_refs = 1; - } - /* Else there's nothing to do. - * If gc_refs > 0, it must be in move_unreachable's 'young' - * list, and move_unreachable will eventually get to it. - * If gc_refs == GC_REACHABLE, it's either in some other - * generation so we don't care about it, or move_unreachable - * already dealt with it. - * If gc_refs == GC_UNTRACKED, it must be ignored. - */ - else { - assert(gc_refs > 0 - || gc_refs == GC_REACHABLE - || gc_refs == GC_UNTRACKED); - } - } - return 0; -} - -/* Move the unreachable objects from young to unreachable. After this, - * all objects in young have gc_refs = GC_REACHABLE, and all objects in - * unreachable have gc_refs = GC_TENTATIVELY_UNREACHABLE. All tracked - * gc objects not in young or unreachable still have gc_refs = GC_REACHABLE. - * All objects in young after this are directly or indirectly reachable - * from outside the original young; and all objects in unreachable are - * not. - */ -static void -move_unreachable(PyGC_Head *young, PyGC_Head *unreachable) -{ - PyGC_Head *gc = young->gc.gc_next; - - /* Invariants: all objects "to the left" of us in young have gc_refs - * = GC_REACHABLE, and are indeed reachable (directly or indirectly) - * from outside the young list as it was at entry. All other objects - * from the original young "to the left" of us are in unreachable now, - * and have gc_refs = GC_TENTATIVELY_UNREACHABLE. All objects to the - * left of us in 'young' now have been scanned, and no objects here - * or to the right have been scanned yet. - */ - - while (gc != young) { - PyGC_Head *next; - - if (gc->gc.gc_refs) { - /* gc is definitely reachable from outside the - * original 'young'. Mark it as such, and traverse - * its pointers to find any other objects that may - * be directly reachable from it. Note that the - * call to tp_traverse may append objects to young, - * so we have to wait until it returns to determine - * the next object to visit. - */ - PyObject *op = FROM_GC(gc); - traverseproc traverse = op->ob_type->tp_traverse; - assert(gc->gc.gc_refs > 0); - gc->gc.gc_refs = GC_REACHABLE; - (void) traverse(op, - (visitproc)visit_reachable, - (void *)young); - next = gc->gc.gc_next; - } - else { - /* This *may* be unreachable. To make progress, - * assume it is. gc isn't directly reachable from - * any object we've already traversed, but may be - * reachable from an object we haven't gotten to yet. - * visit_reachable will eventually move gc back into - * young if that's so, and we'll see it again. - */ - next = gc->gc.gc_next; - gc_list_remove(gc); - gc_list_append(gc, unreachable); - gc->gc.gc_refs = GC_TENTATIVELY_UNREACHABLE; - } - gc = next; - } -} - -/* Return true if object has a finalization method. - * CAUTION: An instance of an old-style class has to be checked for a - *__del__ method, and earlier versions of this used to call PyObject_HasAttr, - * which in turn could call the class's __getattr__ hook (if any). That - * could invoke arbitrary Python code, mutating the object graph in arbitrary - * ways, and that was the source of some excruciatingly subtle bugs. - */ -static int -has_finalizer(PyObject *op) -{ - if (PyInstance_Check(op)) { - assert(delstr != NULL); - return _PyInstance_Lookup(op, delstr) != NULL; - } - else if (PyType_HasFeature(op->ob_type, Py_TPFLAGS_HEAPTYPE)) - return op->ob_type->tp_del != NULL; - else - return 0; -} - -/* Move the objects in unreachable with __del__ methods into finalizers, - * and weakrefs with callbacks into wr_callbacks. - * The objects remaining in unreachable do not have __del__ methods, and are - * not weakrefs with callbacks. - * The objects moved have gc_refs changed to GC_REACHABLE; the objects - * remaining in unreachable are left at GC_TENTATIVELY_UNREACHABLE. - */ -static void -move_troublemakers(PyGC_Head *unreachable, - PyGC_Head *finalizers, - PyGC_Head *wr_callbacks) -{ - PyGC_Head *gc = unreachable->gc.gc_next; - - while (gc != unreachable) { - PyObject *op = FROM_GC(gc); - PyGC_Head *next = gc->gc.gc_next; - - assert(IS_TENTATIVELY_UNREACHABLE(op)); - - if (has_finalizer(op)) { - gc_list_remove(gc); - gc_list_append(gc, finalizers); - gc->gc.gc_refs = GC_REACHABLE; - } - else if (PyWeakref_Check(op) && - ((PyWeakReference *)op)->wr_callback) { - gc_list_remove(gc); - gc_list_append(gc, wr_callbacks); - gc->gc.gc_refs = GC_REACHABLE; - } - gc = next; - } -} - -/* A traversal callback for move_finalizer_reachable. */ -static int -visit_move(PyObject *op, PyGC_Head *tolist) -{ - if (PyObject_IS_GC(op)) { - if (IS_TENTATIVELY_UNREACHABLE(op)) { - PyGC_Head *gc = AS_GC(op); - gc_list_remove(gc); - gc_list_append(gc, tolist); - gc->gc.gc_refs = GC_REACHABLE; - } - } - return 0; -} - -/* Move objects that are reachable from finalizers, from the unreachable set - * into finalizers set. - */ -static void -move_finalizer_reachable(PyGC_Head *finalizers) -{ - traverseproc traverse; - PyGC_Head *gc = finalizers->gc.gc_next; - for (; gc != finalizers; gc = gc->gc.gc_next) { - /* Note that the finalizers list may grow during this. */ - traverse = FROM_GC(gc)->ob_type->tp_traverse; - (void) traverse(FROM_GC(gc), - (visitproc)visit_move, - (void *)finalizers); - } -} - -/* Clear all trash weakrefs with callbacks. This clears weakrefs first, - * which has the happy result of disabling the callbacks without executing - * them. A nasty technical complication: a weakref callback can itself be - * the target of a weakref, in which case decrefing the callback can cause - * another callback to trigger. But we can't allow arbitrary Python code to - * get executed at this point (the callback on the callback may try to muck - * with other cyclic trash we're trying to collect, even resurrecting it - * while we're in the middle of doing tp_clear() on the trash). - * - * The private _PyWeakref_ClearRef() function exists so that we can clear - * the reference in a weakref without triggering a callback on the callback. - * - * We have to save the callback objects and decref them later. But we can't - * allocate new memory to save them (if we can't get new memory, we're dead). - * So we grab a new reference on the clear'ed weakref, which prevents the - * rest of gc from reclaiming it. _PyWeakref_ClearRef() leaves the - * weakref's wr_callback member intact. - * - * In the end, then, wr_callbacks consists of cleared weakrefs that are - * immune from collection. Near the end of gc, after collecting all the - * cyclic trash, we call release_weakrefs(). That releases our references - * to the cleared weakrefs, which in turn may trigger callbacks on their - * callbacks. - */ -static void -clear_weakrefs(PyGC_Head *wr_callbacks) -{ - PyGC_Head *gc = wr_callbacks->gc.gc_next; - - for (; gc != wr_callbacks; gc = gc->gc.gc_next) { - PyObject *op = FROM_GC(gc); - PyWeakReference *wr; - - assert(IS_REACHABLE(op)); - assert(PyWeakref_Check(op)); - wr = (PyWeakReference *)op; - assert(wr->wr_callback != NULL); - Py_INCREF(op); - _PyWeakref_ClearRef(wr); - } -} - -/* Called near the end of gc. This gives up the references we own to - * cleared weakrefs, allowing them to get collected, and in turn decref'ing - * their callbacks. - * - * If a callback object is itself the target of a weakref callback, - * decref'ing the callback object may trigger that other callback. If - * that other callback was part of the cyclic trash in this generation, - * that won't happen, since we cleared *all* trash-weakref callbacks near - * the start of gc. If that other callback was not part of the cyclic trash - * in this generation, then it acted like an external root to this round - * of gc, so all the objects reachable from that callback are still alive. - * - * Giving up the references to the weakref objects will probably make - * them go away too. However, if a weakref is reachable from finalizers, - * it won't go away. We move it to the old generation then. Since a - * weakref object doesn't have a finalizer, that's the right thing to do (it - * doesn't belong in gc.garbage). - * - * We return the number of weakref objects freed (those not appended to old). - */ -static int -release_weakrefs(PyGC_Head *wr_callbacks, PyGC_Head *old) -{ - int num_freed = 0; - - while (! gc_list_is_empty(wr_callbacks)) { - PyGC_Head *gc = wr_callbacks->gc.gc_next; - PyObject *op = FROM_GC(gc); - - assert(IS_REACHABLE(op)); - assert(PyWeakref_Check(op)); - assert(((PyWeakReference *)op)->wr_callback != NULL); - Py_DECREF(op); - if (wr_callbacks->gc.gc_next == gc) { - /* object is still alive -- move it */ - gc_list_remove(gc); - gc_list_append(gc, old); - } - else - ++num_freed; - } - return num_freed; -} - -static void -debug_instance(char *msg, PyInstanceObject *inst) -{ - char *cname; - /* simple version of instance_repr */ - PyObject *classname = inst->in_class->cl_name; - if (classname != NULL && PyString_Check(classname)) - cname = PyString_AsString(classname); - else - cname = "?"; - PySys_WriteStderr("gc: %.100s <%.100s instance at %p>\n", - msg, cname, inst); -} - -static void -debug_cycle(char *msg, PyObject *op) -{ - if ((debug & DEBUG_INSTANCES) && PyInstance_Check(op)) { - debug_instance(msg, (PyInstanceObject *)op); - } - else if (debug & DEBUG_OBJECTS) { - PySys_WriteStderr("gc: %.100s <%.100s %p>\n", - msg, op->ob_type->tp_name, op); - } -} - -/* Handle uncollectable garbage (cycles with finalizers, and stuff reachable - * only from such cycles). - * If DEBUG_SAVEALL, all objects in finalizers are appended to the module - * garbage list (a Python list), else only the objects in finalizers with - * __del__ methods are appended to garbage. All objects in finalizers are - * merged into the old list regardless. - * Returns 0 if all OK, <0 on error (out of memory to grow the garbage list). - * The finalizers list is made empty on a successful return. - */ -static int -handle_finalizers(PyGC_Head *finalizers, PyGC_Head *old) -{ - PyGC_Head *gc = finalizers->gc.gc_next; - - if (garbage == NULL) { - garbage = PyList_New(0); - if (garbage == NULL) - Py_FatalError("gc couldn't create gc.garbage list"); - } - for (; gc != finalizers; gc = gc->gc.gc_next) { - PyObject *op = FROM_GC(gc); - - if ((debug & DEBUG_SAVEALL) || has_finalizer(op)) { - if (PyList_Append(garbage, op) < 0) - return -1; - } - } - - gc_list_merge(finalizers, old); - return 0; -} - -/* Break reference cycles by clearing the containers involved. This is - * tricky business as the lists can be changing and we don't know which - * objects may be freed. It is possible I screwed something up here. - */ -static void -delete_garbage(PyGC_Head *collectable, PyGC_Head *old) -{ - inquiry clear; - - while (!gc_list_is_empty(collectable)) { - PyGC_Head *gc = collectable->gc.gc_next; - PyObject *op = FROM_GC(gc); - - assert(IS_TENTATIVELY_UNREACHABLE(op)); - if (debug & DEBUG_SAVEALL) { - PyList_Append(garbage, op); - } - else { - if ((clear = op->ob_type->tp_clear) != NULL) { - Py_INCREF(op); - clear(op); - Py_DECREF(op); - } - } - if (collectable->gc.gc_next == gc) { - /* object is still alive, move it, it may die later */ - gc_list_remove(gc); - gc_list_append(gc, old); - gc->gc.gc_refs = GC_REACHABLE; - } - } -} - -/* This is the main function. Read this to understand how the - * collection process works. */ -static long -collect(int generation) -{ - int i; - long m = 0; /* # objects collected */ - long n = 0; /* # unreachable objects that couldn't be collected */ - PyGC_Head *young; /* the generation we are examining */ - PyGC_Head *old; /* next older generation */ - PyGC_Head unreachable; /* non-problematic unreachable trash */ - PyGC_Head finalizers; /* objects with, & reachable from, __del__ */ - PyGC_Head wr_callbacks; /* weakrefs with callbacks */ - PyGC_Head *gc; - - if (delstr == NULL) { - delstr = PyString_InternFromString("__del__"); - if (delstr == NULL) - Py_FatalError("gc couldn't allocate \"__del__\""); - } - - if (debug & DEBUG_STATS) { - PySys_WriteStderr("gc: collecting generation %d...\n", - generation); - PySys_WriteStderr("gc: objects in each generation:"); - for (i = 0; i < NUM_GENERATIONS; i++) { - PySys_WriteStderr(" %ld", gc_list_size(GEN_HEAD(i))); - } - PySys_WriteStderr("\n"); - } - - /* update collection and allocation counters */ - if (generation+1 < NUM_GENERATIONS) - generations[generation+1].count += 1; - for (i = 0; i <= generation; i++) - generations[i].count = 0; - - /* merge younger generations with one we are currently collecting */ - for (i = 0; i < generation; i++) { - gc_list_merge(GEN_HEAD(i), GEN_HEAD(generation)); - } - - /* handy references */ - young = GEN_HEAD(generation); - if (generation < NUM_GENERATIONS-1) - old = GEN_HEAD(generation+1); - else - old = young; - - /* Using ob_refcnt and gc_refs, calculate which objects in the - * container set are reachable from outside the set (ie. have a - * refcount greater than 0 when all the references within the - * set are taken into account - */ - update_refs(young); - subtract_refs(young); - - /* Leave everything reachable from outside young in young, and move - * everything else (in young) to unreachable. - * NOTE: This used to move the reachable objects into a reachable - * set instead. But most things usually turn out to be reachable, - * so it's more efficient to move the unreachable things. - */ - gc_list_init(&unreachable); - move_unreachable(young, &unreachable); - - /* Move reachable objects to next generation. */ - if (young != old) - gc_list_merge(young, old); - - /* All objects in unreachable are trash, but objects reachable from - * finalizers can't safely be deleted. Python programmers should take - * care not to create such things. For Python, finalizers means - * instance objects with __del__ methods. Weakrefs with callbacks - * can call arbitrary Python code, so those are special-cased too. - * - * Move unreachable objects with finalizers, and weakrefs with - * callbacks, into different lists. - */ - gc_list_init(&finalizers); - gc_list_init(&wr_callbacks); - move_troublemakers(&unreachable, &finalizers, &wr_callbacks); - /* Clear the trash weakrefs with callbacks. This prevents their - * callbacks from getting invoked (when a weakref goes away, so does - * its callback). - * We do this even if the weakrefs are reachable from finalizers. - * If we didn't, breaking cycles in unreachable later could trigger - * deallocation of objects in finalizers, which could in turn - * cause callbacks to trigger. This may not be ideal behavior. - */ - clear_weakrefs(&wr_callbacks); - /* finalizers contains the unreachable objects with a finalizer; - * unreachable objects reachable *from* those are also uncollectable, - * and we move those into the finalizers list too. - */ - move_finalizer_reachable(&finalizers); - - /* Collect statistics on collectable objects found and print - * debugging information. - */ - for (gc = unreachable.gc.gc_next; gc != &unreachable; - gc = gc->gc.gc_next) { - m++; - if (debug & DEBUG_COLLECTABLE) { - debug_cycle("collectable", FROM_GC(gc)); - } - } - /* Call tp_clear on objects in the unreachable set. This will cause - * the reference cycles to be broken. It may also cause some objects - * in finalizers to be freed. - */ - delete_garbage(&unreachable, old); - - /* Now that we're done analyzing stuff and breaking cycles, let - * delayed weakref callbacks run. - */ - m += release_weakrefs(&wr_callbacks, old); - - /* Collect statistics on uncollectable objects found and print - * debugging information. */ - for (gc = finalizers.gc.gc_next; - gc != &finalizers; - gc = gc->gc.gc_next) { - n++; - if (debug & DEBUG_UNCOLLECTABLE) - debug_cycle("uncollectable", FROM_GC(gc)); - } - if (debug & DEBUG_STATS) { - if (m == 0 && n == 0) { - PySys_WriteStderr("gc: done.\n"); - } - else { - PySys_WriteStderr( - "gc: done, %ld unreachable, %ld uncollectable.\n", - n+m, n); - } - } - - /* Append instances in the uncollectable set to a Python - * reachable list of garbage. The programmer has to deal with - * this if they insist on creating this type of structure. - */ - (void)handle_finalizers(&finalizers, old); - - if (PyErr_Occurred()) { - if (gc_str == NULL) - gc_str = PyString_FromString("garbage collection"); - PyErr_WriteUnraisable(gc_str); - Py_FatalError("unexpected exception during garbage collection"); - } - return n+m; -} - -static long -collect_generations(void) -{ - int i; - long n = 0; - - /* Find the oldest generation (higest numbered) where the count - * exceeds the threshold. Objects in the that generation and - * generations younger than it will be collected. */ - for (i = NUM_GENERATIONS-1; i >= 0; i--) { - if (generations[i].count > generations[i].threshold) { - n = collect(i); - break; - } - } - return n; -} - -PyDoc_STRVAR(gc_enable__doc__, -"enable() -> None\n" -"\n" -"Enable automatic garbage collection.\n"); - -static PyObject * -gc_enable(PyObject *self, PyObject *noargs) -{ - enabled = 1; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(gc_disable__doc__, -"disable() -> None\n" -"\n" -"Disable automatic garbage collection.\n"); - -static PyObject * -gc_disable(PyObject *self, PyObject *noargs) -{ - enabled = 0; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(gc_isenabled__doc__, -"isenabled() -> status\n" -"\n" -"Returns true if automatic garbage collection is enabled.\n"); - -static PyObject * -gc_isenabled(PyObject *self, PyObject *noargs) -{ - return Py_BuildValue("i", enabled); -} - -PyDoc_STRVAR(gc_collect__doc__, -"collect() -> n\n" -"\n" -"Run a full collection. The number of unreachable objects is returned.\n"); - -static PyObject * -gc_collect(PyObject *self, PyObject *noargs) -{ - long n; - - if (collecting) - n = 0; /* already collecting, don't do anything */ - else { - collecting = 1; - n = collect(NUM_GENERATIONS - 1); - collecting = 0; - } - - return Py_BuildValue("l", n); -} - -PyDoc_STRVAR(gc_set_debug__doc__, -"set_debug(flags) -> None\n" -"\n" -"Set the garbage collection debugging flags. Debugging information is\n" -"written to sys.stderr.\n" -"\n" -"flags is an integer and can have the following bits turned on:\n" -"\n" -" DEBUG_STATS - Print statistics during collection.\n" -" DEBUG_COLLECTABLE - Print collectable objects found.\n" -" DEBUG_UNCOLLECTABLE - Print unreachable but uncollectable objects found.\n" -" DEBUG_INSTANCES - Print instance objects.\n" -" DEBUG_OBJECTS - Print objects other than instances.\n" -" DEBUG_SAVEALL - Save objects to gc.garbage rather than freeing them.\n" -" DEBUG_LEAK - Debug leaking programs (everything but STATS).\n"); - -static PyObject * -gc_set_debug(PyObject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, "i:set_debug", &debug)) - return NULL; - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(gc_get_debug__doc__, -"get_debug() -> flags\n" -"\n" -"Get the garbage collection debugging flags.\n"); - -static PyObject * -gc_get_debug(PyObject *self, PyObject *noargs) -{ - return Py_BuildValue("i", debug); -} - -PyDoc_STRVAR(gc_set_thresh__doc__, -"set_threshold(threshold0, [threshold1, threshold2]) -> None\n" -"\n" -"Sets the collection thresholds. Setting threshold0 to zero disables\n" -"collection.\n"); - -static PyObject * -gc_set_thresh(PyObject *self, PyObject *args) -{ - int i; - if (!PyArg_ParseTuple(args, "i|ii:set_threshold", - &generations[0].threshold, - &generations[1].threshold, - &generations[2].threshold)) - return NULL; - for (i = 2; i < NUM_GENERATIONS; i++) { - /* generations higher than 2 get the same threshold */ - generations[i].threshold = generations[2].threshold; - } - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(gc_get_thresh__doc__, -"get_threshold() -> (threshold0, threshold1, threshold2)\n" -"\n" -"Return the current collection thresholds\n"); - -static PyObject * -gc_get_thresh(PyObject *self, PyObject *noargs) -{ - return Py_BuildValue("(iii)", - generations[0].threshold, - generations[1].threshold, - generations[2].threshold); -} - -static int -referrersvisit(PyObject* obj, PyObject *objs) -{ - int i; - for (i = 0; i < PyTuple_GET_SIZE(objs); i++) - if (PyTuple_GET_ITEM(objs, i) == obj) - return 1; - return 0; -} - -static int -gc_referrers_for(PyObject *objs, PyGC_Head *list, PyObject *resultlist) -{ - PyGC_Head *gc; - PyObject *obj; - traverseproc traverse; - for (gc = list->gc.gc_next; gc != list; gc = gc->gc.gc_next) { - obj = FROM_GC(gc); - traverse = obj->ob_type->tp_traverse; - if (obj == objs || obj == resultlist) - continue; - if (traverse(obj, (visitproc)referrersvisit, objs)) { - if (PyList_Append(resultlist, obj) < 0) - return 0; /* error */ - } - } - return 1; /* no error */ -} - -PyDoc_STRVAR(gc_get_referrers__doc__, -"get_referrers(*objs) -> list\n\ -Return the list of objects that directly refer to any of objs."); - -static PyObject * -gc_get_referrers(PyObject *self, PyObject *args) -{ - int i; - PyObject *result = PyList_New(0); - for (i = 0; i < NUM_GENERATIONS; i++) { - if (!(gc_referrers_for(args, GEN_HEAD(i), result))) { - Py_DECREF(result); - return NULL; - } - } - return result; -} - -/* Append obj to list; return true if error (out of memory), false if OK. */ -static int -referentsvisit(PyObject *obj, PyObject *list) -{ - return PyList_Append(list, obj) < 0; -} - -PyDoc_STRVAR(gc_get_referents__doc__, -"get_referents(*objs) -> list\n\ -Return the list of objects that are directly referred to by objs."); - -static PyObject * -gc_get_referents(PyObject *self, PyObject *args) -{ - int i; - PyObject *result = PyList_New(0); - - if (result == NULL) - return NULL; - - for (i = 0; i < PyTuple_GET_SIZE(args); i++) { - traverseproc traverse; - PyObject *obj = PyTuple_GET_ITEM(args, i); - - if (! PyObject_IS_GC(obj)) - continue; - traverse = obj->ob_type->tp_traverse; - if (! traverse) - continue; - if (traverse(obj, (visitproc)referentsvisit, result)) { - Py_DECREF(result); - return NULL; - } - } - return result; -} - -PyDoc_STRVAR(gc_get_objects__doc__, -"get_objects() -> [...]\n" -"\n" -"Return a list of objects tracked by the collector (excluding the list\n" -"returned).\n"); - -static PyObject * -gc_get_objects(PyObject *self, PyObject *noargs) -{ - int i; - PyObject* result; - - result = PyList_New(0); - if (result == NULL) - return NULL; - for (i = 0; i < NUM_GENERATIONS; i++) { - if (append_objects(result, GEN_HEAD(i))) { - Py_DECREF(result); - return NULL; - } - } - return result; -} - - -PyDoc_STRVAR(gc__doc__, -"This module provides access to the garbage collector for reference cycles.\n" -"\n" -"enable() -- Enable automatic garbage collection.\n" -"disable() -- Disable automatic garbage collection.\n" -"isenabled() -- Returns true if automatic collection is enabled.\n" -"collect() -- Do a full collection right now.\n" -"set_debug() -- Set debugging flags.\n" -"get_debug() -- Get debugging flags.\n" -"set_threshold() -- Set the collection thresholds.\n" -"get_threshold() -- Return the current the collection thresholds.\n" -"get_objects() -- Return a list of all objects tracked by the collector.\n" -"get_referrers() -- Return the list of objects that refer to an object.\n" -"get_referents() -- Return the list of objects that an object refers to.\n"); - -static PyMethodDef GcMethods[] = { - {"enable", gc_enable, METH_NOARGS, gc_enable__doc__}, - {"disable", gc_disable, METH_NOARGS, gc_disable__doc__}, - {"isenabled", gc_isenabled, METH_NOARGS, gc_isenabled__doc__}, - {"set_debug", gc_set_debug, METH_VARARGS, gc_set_debug__doc__}, - {"get_debug", gc_get_debug, METH_NOARGS, gc_get_debug__doc__}, - {"set_threshold", gc_set_thresh, METH_VARARGS, gc_set_thresh__doc__}, - {"get_threshold", gc_get_thresh, METH_NOARGS, gc_get_thresh__doc__}, - {"collect", gc_collect, METH_NOARGS, gc_collect__doc__}, - {"get_objects", gc_get_objects,METH_NOARGS, gc_get_objects__doc__}, - {"get_referrers", gc_get_referrers, METH_VARARGS, - gc_get_referrers__doc__}, - {"get_referents", gc_get_referents, METH_VARARGS, - gc_get_referents__doc__}, - {NULL, NULL} /* Sentinel */ -}; - -void -initgc(void) -{ - PyObject *m; - - m = Py_InitModule4("gc", - GcMethods, - gc__doc__, - NULL, - PYTHON_API_VERSION); - - if (garbage == NULL) { - garbage = PyList_New(0); - if (garbage == NULL) - return; - } - if (PyModule_AddObject(m, "garbage", garbage) < 0) - return; -#define ADD_INT(NAME) if (PyModule_AddIntConstant(m, #NAME, NAME) < 0) return - ADD_INT(DEBUG_STATS); - ADD_INT(DEBUG_COLLECTABLE); - ADD_INT(DEBUG_UNCOLLECTABLE); - ADD_INT(DEBUG_INSTANCES); - ADD_INT(DEBUG_OBJECTS); - ADD_INT(DEBUG_SAVEALL); - ADD_INT(DEBUG_LEAK); -#undef ADD_INT -} - -/* API to invoke gc.collect() from C */ -long -PyGC_Collect(void) -{ - long n; - - if (collecting) - n = 0; /* already collecting, don't do anything */ - else { - collecting = 1; - n = collect(NUM_GENERATIONS - 1); - collecting = 0; - } - - return n; -} - -/* for debugging */ -void -_PyGC_Dump(PyGC_Head *g) -{ - _PyObject_Dump(FROM_GC(g)); -} - -/* extension modules might be compiled with GC support so these - functions must always be available */ - -#undef PyObject_GC_Track -#undef PyObject_GC_UnTrack -#undef PyObject_GC_Del -#undef _PyObject_GC_Malloc - -void -PyObject_GC_Track(void *op) -{ - _PyObject_GC_TRACK(op); -} - -/* for binary compatibility with 2.2 */ -void -_PyObject_GC_Track(PyObject *op) -{ - PyObject_GC_Track(op); -} - -void -PyObject_GC_UnTrack(void *op) -{ - /* Obscure: the Py_TRASHCAN mechanism requires that we be able to - * call PyObject_GC_UnTrack twice on an object. - */ - if (IS_TRACKED(op)) - _PyObject_GC_UNTRACK(op); -} - -/* for binary compatibility with 2.2 */ -void -_PyObject_GC_UnTrack(PyObject *op) -{ - PyObject_GC_UnTrack(op); -} - -PyObject * -_PyObject_GC_Malloc(size_t basicsize) -{ - PyObject *op; - PyGC_Head *g = PyObject_MALLOC(sizeof(PyGC_Head) + basicsize); - if (g == NULL) - return PyErr_NoMemory(); - g->gc.gc_refs = GC_UNTRACKED; - generations[0].count++; /* number of allocated GC objects */ - if (generations[0].count > generations[0].threshold && - enabled && - generations[0].threshold && - !collecting && - !PyErr_Occurred()) { - collecting = 1; - collect_generations(); - collecting = 0; - } - op = FROM_GC(g); - return op; -} - -PyObject * -_PyObject_GC_New(PyTypeObject *tp) -{ - PyObject *op = _PyObject_GC_Malloc(_PyObject_SIZE(tp)); - if (op != NULL) - op = PyObject_INIT(op, tp); - return op; -} - -PyVarObject * -_PyObject_GC_NewVar(PyTypeObject *tp, int nitems) -{ - const size_t size = _PyObject_VAR_SIZE(tp, nitems); - PyVarObject *op = (PyVarObject *) _PyObject_GC_Malloc(size); - if (op != NULL) - op = PyObject_INIT_VAR(op, tp, nitems); - return op; -} - -PyVarObject * -_PyObject_GC_Resize(PyVarObject *op, int nitems) -{ - const size_t basicsize = _PyObject_VAR_SIZE(op->ob_type, nitems); - PyGC_Head *g = AS_GC(op); - g = PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize); - if (g == NULL) - return (PyVarObject *)PyErr_NoMemory(); - op = (PyVarObject *) FROM_GC(g); - op->ob_size = nitems; - return op; -} - -void -PyObject_GC_Del(void *op) -{ - PyGC_Head *g = AS_GC(op); - if (IS_TRACKED(op)) - gc_list_remove(g); - if (generations[0].count > 0) { - generations[0].count--; - } - PyObject_FREE(g); -} - -/* for binary compatibility with 2.2 */ -#undef _PyObject_GC_Del -void -_PyObject_GC_Del(PyObject *op) -{ - PyObject_GC_Del(op); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/gdbmmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/gdbmmodule.c deleted file mode 100644 index e4bbd1f1..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/gdbmmodule.c +++ /dev/null @@ -1,523 +0,0 @@ - -/* DBM module using dictionary interface */ -/* Author: Anthony Baxter, after dbmmodule.c */ -/* Doc strings: Mitch Chapman */ - - -#include "Python.h" - -#include -#include -#include -#include "gdbm.h" - -#if defined(WIN32) && !defined(__CYGWIN__) -#include "gdbmerrno.h" -extern const char * gdbm_strerror(gdbm_error); -#endif - -PyDoc_STRVAR(gdbmmodule__doc__, -"This module provides an interface to the GNU DBM (GDBM) library.\n\ -\n\ -This module is quite similar to the dbm module, but uses GDBM instead to\n\ -provide some additional functionality. Please note that the file formats\n\ -created by GDBM and dbm are incompatible. \n\ -\n\ -GDBM objects behave like mappings (dictionaries), except that keys and\n\ -values are always strings. Printing a GDBM object doesn't print the\n\ -keys and values, and the items() and values() methods are not\n\ -supported."); - -typedef struct { - PyObject_HEAD - int di_size; /* -1 means recompute */ - GDBM_FILE di_dbm; -} dbmobject; - -static PyTypeObject Dbmtype; - -#define is_dbmobject(v) ((v)->ob_type == &Dbmtype) -#define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \ - { PyErr_SetString(DbmError, "GDBM object has already been closed"); \ - return NULL; } - - - -static PyObject *DbmError; - -PyDoc_STRVAR(gdbm_object__doc__, -"This object represents a GDBM database.\n\ -GDBM objects behave like mappings (dictionaries), except that keys and\n\ -values are always strings. Printing a GDBM object doesn't print the\n\ -keys and values, and the items() and values() methods are not\n\ -supported.\n\ -\n\ -GDBM objects also support additional operations such as firstkey,\n\ -nextkey, reorganize, and sync."); - -static PyObject * -newdbmobject(char *file, int flags, int mode) -{ - dbmobject *dp; - - dp = PyObject_New(dbmobject, &Dbmtype); - if (dp == NULL) - return NULL; - dp->di_size = -1; - errno = 0; - if ((dp->di_dbm = gdbm_open(file, 0, flags, mode, NULL)) == 0) { - if (errno != 0) - PyErr_SetFromErrno(DbmError); - else - PyErr_SetString(DbmError, gdbm_strerror(gdbm_errno)); - Py_DECREF(dp); - return NULL; - } - return (PyObject *)dp; -} - -/* Methods */ - -static void -dbm_dealloc(register dbmobject *dp) -{ - if (dp->di_dbm) - gdbm_close(dp->di_dbm); - PyObject_Del(dp); -} - -static int -dbm_length(dbmobject *dp) -{ - if (dp->di_dbm == NULL) { - PyErr_SetString(DbmError, "GDBM object has already been closed"); - return -1; - } - if (dp->di_size < 0) { - datum key,okey; - int size; - okey.dsize=0; - - size = 0; - for (key=gdbm_firstkey(dp->di_dbm); key.dptr; - key = gdbm_nextkey(dp->di_dbm,okey)) { - size++; - if(okey.dsize) free(okey.dptr); - okey=key; - } - dp->di_size = size; - } - return dp->di_size; -} - -static PyObject * -dbm_subscript(dbmobject *dp, register PyObject *key) -{ - PyObject *v; - datum drec, krec; - - if (!PyArg_Parse(key, "s#", &krec.dptr, &krec.dsize) ) - return NULL; - - if (dp->di_dbm == NULL) { - PyErr_SetString(DbmError, - "GDBM object has already been closed"); - return NULL; - } - drec = gdbm_fetch(dp->di_dbm, krec); - if (drec.dptr == 0) { - PyErr_SetString(PyExc_KeyError, - PyString_AS_STRING((PyStringObject *)key)); - return NULL; - } - v = PyString_FromStringAndSize(drec.dptr, drec.dsize); - free(drec.dptr); - return v; -} - -static int -dbm_ass_sub(dbmobject *dp, PyObject *v, PyObject *w) -{ - datum krec, drec; - - if (!PyArg_Parse(v, "s#", &krec.dptr, &krec.dsize) ) { - PyErr_SetString(PyExc_TypeError, - "gdbm mappings have string indices only"); - return -1; - } - if (dp->di_dbm == NULL) { - PyErr_SetString(DbmError, - "GDBM object has already been closed"); - return -1; - } - dp->di_size = -1; - if (w == NULL) { - if (gdbm_delete(dp->di_dbm, krec) < 0) { - PyErr_SetString(PyExc_KeyError, - PyString_AS_STRING((PyStringObject *)v)); - return -1; - } - } - else { - if (!PyArg_Parse(w, "s#", &drec.dptr, &drec.dsize)) { - PyErr_SetString(PyExc_TypeError, - "gdbm mappings have string elements only"); - return -1; - } - errno = 0; - if (gdbm_store(dp->di_dbm, krec, drec, GDBM_REPLACE) < 0) { - if (errno != 0) - PyErr_SetFromErrno(DbmError); - else - PyErr_SetString(DbmError, - gdbm_strerror(gdbm_errno)); - return -1; - } - } - return 0; -} - -static PyMappingMethods dbm_as_mapping = { - (inquiry)dbm_length, /*mp_length*/ - (binaryfunc)dbm_subscript, /*mp_subscript*/ - (objobjargproc)dbm_ass_sub, /*mp_ass_subscript*/ -}; - -PyDoc_STRVAR(dbm_close__doc__, -"close() -> None\n\ -Closes the database."); - -static PyObject * -dbm_close(register dbmobject *dp, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":close")) - return NULL; - if (dp->di_dbm) - gdbm_close(dp->di_dbm); - dp->di_dbm = NULL; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(dbm_keys__doc__, -"keys() -> list_of_keys\n\ -Get a list of all keys in the database."); - -static PyObject * -dbm_keys(register dbmobject *dp, PyObject *args) -{ - register PyObject *v, *item; - datum key, nextkey; - int err; - - if (dp == NULL || !is_dbmobject(dp)) { - PyErr_BadInternalCall(); - return NULL; - } - if (!PyArg_ParseTuple(args, ":keys")) - return NULL; - - check_dbmobject_open(dp); - - v = PyList_New(0); - if (v == NULL) - return NULL; - - key = gdbm_firstkey(dp->di_dbm); - while (key.dptr) { - item = PyString_FromStringAndSize(key.dptr, key.dsize); - if (item == NULL) { - free(key.dptr); - Py_DECREF(v); - return NULL; - } - err = PyList_Append(v, item); - Py_DECREF(item); - if (err != 0) { - free(key.dptr); - Py_DECREF(v); - return NULL; - } - nextkey = gdbm_nextkey(dp->di_dbm, key); - free(key.dptr); - key = nextkey; - } - return v; -} - -PyDoc_STRVAR(dbm_has_key__doc__, -"has_key(key) -> boolean\n\ -Find out whether or not the database contains a given key."); - -static PyObject * -dbm_has_key(register dbmobject *dp, PyObject *args) -{ - datum key; - - if (!PyArg_ParseTuple(args, "s#:has_key", &key.dptr, &key.dsize)) - return NULL; - check_dbmobject_open(dp); - return PyInt_FromLong((long) gdbm_exists(dp->di_dbm, key)); -} - -PyDoc_STRVAR(dbm_firstkey__doc__, -"firstkey() -> key\n\ -It's possible to loop over every key in the database using this method\n\ -and the nextkey() method. The traversal is ordered by GDBM's internal\n\ -hash values, and won't be sorted by the key values. This method\n\ -returns the starting key."); - -static PyObject * -dbm_firstkey(register dbmobject *dp, PyObject *args) -{ - register PyObject *v; - datum key; - - if (!PyArg_ParseTuple(args, ":firstkey")) - return NULL; - check_dbmobject_open(dp); - key = gdbm_firstkey(dp->di_dbm); - if (key.dptr) { - v = PyString_FromStringAndSize(key.dptr, key.dsize); - free(key.dptr); - return v; - } - else { - Py_INCREF(Py_None); - return Py_None; - } -} - -PyDoc_STRVAR(dbm_nextkey__doc__, -"nextkey(key) -> next_key\n\ -Returns the key that follows key in the traversal.\n\ -The following code prints every key in the database db, without having\n\ -to create a list in memory that contains them all:\n\ -\n\ - k = db.firstkey()\n\ - while k != None:\n\ - print k\n\ - k = db.nextkey(k)"); - -static PyObject * -dbm_nextkey(register dbmobject *dp, PyObject *args) -{ - register PyObject *v; - datum key, nextkey; - - if (!PyArg_ParseTuple(args, "s#:nextkey", &key.dptr, &key.dsize)) - return NULL; - check_dbmobject_open(dp); - nextkey = gdbm_nextkey(dp->di_dbm, key); - if (nextkey.dptr) { - v = PyString_FromStringAndSize(nextkey.dptr, nextkey.dsize); - free(nextkey.dptr); - return v; - } - else { - Py_INCREF(Py_None); - return Py_None; - } -} - -PyDoc_STRVAR(dbm_reorganize__doc__, -"reorganize() -> None\n\ -If you have carried out a lot of deletions and would like to shrink\n\ -the space used by the GDBM file, this routine will reorganize the\n\ -database. GDBM will not shorten the length of a database file except\n\ -by using this reorganization; otherwise, deleted file space will be\n\ -kept and reused as new (key,value) pairs are added."); - -static PyObject * -dbm_reorganize(register dbmobject *dp, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":reorganize")) - return NULL; - check_dbmobject_open(dp); - errno = 0; - if (gdbm_reorganize(dp->di_dbm) < 0) { - if (errno != 0) - PyErr_SetFromErrno(DbmError); - else - PyErr_SetString(DbmError, gdbm_strerror(gdbm_errno)); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(dbm_sync__doc__, -"sync() -> None\n\ -When the database has been opened in fast mode, this method forces\n\ -any unwritten data to be written to the disk."); - -static PyObject * -dbm_sync(register dbmobject *dp, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":sync")) - return NULL; - check_dbmobject_open(dp); - gdbm_sync(dp->di_dbm); - Py_INCREF(Py_None); - return Py_None; -} - -static PyMethodDef dbm_methods[] = { - {"close", (PyCFunction)dbm_close, METH_VARARGS, dbm_close__doc__}, - {"keys", (PyCFunction)dbm_keys, METH_VARARGS, dbm_keys__doc__}, - {"has_key", (PyCFunction)dbm_has_key, METH_VARARGS, dbm_has_key__doc__}, - {"firstkey", (PyCFunction)dbm_firstkey,METH_VARARGS, dbm_firstkey__doc__}, - {"nextkey", (PyCFunction)dbm_nextkey, METH_VARARGS, dbm_nextkey__doc__}, - {"reorganize",(PyCFunction)dbm_reorganize,METH_VARARGS, dbm_reorganize__doc__}, - {"sync", (PyCFunction)dbm_sync, METH_VARARGS, dbm_sync__doc__}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -dbm_getattr(dbmobject *dp, char *name) -{ - return Py_FindMethod(dbm_methods, (PyObject *)dp, name); -} - -static PyTypeObject Dbmtype = { - PyObject_HEAD_INIT(0) - 0, - "gdbm.gdbm", - sizeof(dbmobject), - 0, - (destructor)dbm_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)dbm_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - &dbm_as_mapping, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - 0, /*tp_xxx4*/ - gdbm_object__doc__, /*tp_doc*/ -}; - -/* ----------------------------------------------------------------- */ - -PyDoc_STRVAR(dbmopen__doc__, -"open(filename, [flags, [mode]]) -> dbm_object\n\ -Open a dbm database and return a dbm object. The filename argument is\n\ -the name of the database file.\n\ -\n\ -The optional flags argument can be 'r' (to open an existing database\n\ -for reading only -- default), 'w' (to open an existing database for\n\ -reading and writing), 'c' (which creates the database if it doesn't\n\ -exist), or 'n' (which always creates a new empty database).\n\ -\n\ -Some versions of gdbm support additional flags which must be\n\ -appended to one of the flags described above. The module constant\n\ -'open_flags' is a string of valid additional flags. The 'f' flag\n\ -opens the database in fast mode; altered data will not automatically\n\ -be written to the disk after every change. This results in faster\n\ -writes to the database, but may result in an inconsistent database\n\ -if the program crashes while the database is still open. Use the\n\ -sync() method to force any unwritten data to be written to the disk.\n\ -The 's' flag causes all database operations to be synchronized to\n\ -disk. The 'u' flag disables locking of the database file.\n\ -\n\ -The optional mode argument is the Unix mode of the file, used only\n\ -when the database has to be created. It defaults to octal 0666. "); - -static PyObject * -dbmopen(PyObject *self, PyObject *args) -{ - char *name; - char *flags = "r "; - int iflags; - int mode = 0666; - - if (!PyArg_ParseTuple(args, "s|si:open", &name, &flags, &mode)) - return NULL; - switch (flags[0]) { - case 'r': - iflags = GDBM_READER; - break; - case 'w': - iflags = GDBM_WRITER; - break; - case 'c': - iflags = GDBM_WRCREAT; - break; - case 'n': - iflags = GDBM_NEWDB; - break; - default: - PyErr_SetString(DbmError, - "First flag must be one of 'r', 'w', 'c' or 'n'"); - return NULL; - } - for (flags++; *flags != '\0'; flags++) { - char buf[40]; - switch (*flags) { -#ifdef GDBM_FAST - case 'f': - iflags |= GDBM_FAST; - break; -#endif -#ifdef GDBM_SYNC - case 's': - iflags |= GDBM_SYNC; - break; -#endif -#ifdef GDBM_NOLOCK - case 'u': - iflags |= GDBM_NOLOCK; - break; -#endif - default: - PyOS_snprintf(buf, sizeof(buf), "Flag '%c' is not supported.", - *flags); - PyErr_SetString(DbmError, buf); - return NULL; - } - } - - return newdbmobject(name, iflags, mode); -} - -static char dbmmodule_open_flags[] = "rwcn" -#ifdef GDBM_FAST - "f" -#endif -#ifdef GDBM_SYNC - "s" -#endif -#ifdef GDBM_NOLOCK - "u" -#endif - ; - -static PyMethodDef dbmmodule_methods[] = { - { "open", (PyCFunction)dbmopen, METH_VARARGS, dbmopen__doc__}, - { 0, 0 }, -}; - -PyMODINIT_FUNC -initgdbm(void) { - PyObject *m, *d, *s; - - Dbmtype.ob_type = &PyType_Type; - m = Py_InitModule4("gdbm", dbmmodule_methods, - gdbmmodule__doc__, (PyObject *)NULL, - PYTHON_API_VERSION); - d = PyModule_GetDict(m); - DbmError = PyErr_NewException("gdbm.error", NULL, NULL); - if (DbmError != NULL) { - PyDict_SetItemString(d, "error", DbmError); - s = PyString_FromString(dbmmodule_open_flags); - PyDict_SetItemString(d, "open_flags", s); - Py_DECREF(s); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/getaddrinfo.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/getaddrinfo.c deleted file mode 100644 index 438dd6b5..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/getaddrinfo.c +++ /dev/null @@ -1,638 +0,0 @@ -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * GAI_ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR GAI_ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON GAI_ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN GAI_ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * "#ifdef FAITH" part is local hack for supporting IPv4-v6 translator. - * - * Issues to be discussed: - * - Thread safe-ness must be checked. - * - Return values. There are nonstandard return values defined and used - * in the source code. This is because RFC2133 is silent about which error - * code must be returned for which situation. - * - PF_UNSPEC case would be handled in getipnodebyname() with the AI_ALL flag. - */ - -#if 0 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "addrinfo.h" -#endif - -#if defined(__KAME__) && defined(ENABLE_IPV6) -# define FAITH -#endif - -#define SUCCESS 0 -#define GAI_ANY 0 -#define YES 1 -#define NO 0 - -#ifdef FAITH -static int translate = NO; -static struct in6_addr faith_prefix = IN6ADDR_GAI_ANY_INIT; -#endif - -static const char in_addrany[] = { 0, 0, 0, 0 }; -static const char in6_addrany[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; -static const char in_loopback[] = { 127, 0, 0, 1 }; -static const char in6_loopback[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 -}; - -struct sockinet { - u_char si_len; - u_char si_family; - u_short si_port; -}; - -static struct gai_afd { - int a_af; - int a_addrlen; - int a_socklen; - int a_off; - const char *a_addrany; - const char *a_loopback; -} gai_afdl [] = { -#ifdef ENABLE_IPV6 -#define N_INET6 0 - {PF_INET6, sizeof(struct in6_addr), - sizeof(struct sockaddr_in6), - offsetof(struct sockaddr_in6, sin6_addr), - in6_addrany, in6_loopback}, -#define N_INET 1 -#else -#define N_INET 0 -#endif - {PF_INET, sizeof(struct in_addr), - sizeof(struct sockaddr_in), - offsetof(struct sockaddr_in, sin_addr), - in_addrany, in_loopback}, - {0, 0, 0, 0, NULL, NULL}, -}; - -#ifdef ENABLE_IPV6 -#define PTON_MAX 16 -#else -#define PTON_MAX 4 -#endif - -#ifndef IN_MULTICAST -#define IN_MULTICAST(i) (((i) & 0xf0000000U) == 0xe0000000U) -#endif - -#ifndef IN_EXPERIMENTAL -#define IN_EXPERIMENTAL(i) (((i) & 0xe0000000U) == 0xe0000000U) -#endif - -#ifndef IN_LOOPBACKNET -#define IN_LOOPBACKNET 127 -#endif - -static int get_name Py_PROTO((const char *, struct gai_afd *, - struct addrinfo **, char *, struct addrinfo *, - int)); -static int get_addr Py_PROTO((const char *, int, struct addrinfo **, - struct addrinfo *, int)); -static int str_isnumber Py_PROTO((const char *)); - -static char *ai_errlist[] = { - "success.", - "address family for hostname not supported.", /* EAI_ADDRFAMILY */ - "temporary failure in name resolution.", /* EAI_AGAIN */ - "invalid value for ai_flags.", /* EAI_BADFLAGS */ - "non-recoverable failure in name resolution.", /* EAI_FAIL */ - "ai_family not supported.", /* EAI_FAMILY */ - "memory allocation failure.", /* EAI_MEMORY */ - "no address associated with hostname.", /* EAI_NODATA */ - "hostname nor servname provided, or not known.",/* EAI_NONAME */ - "servname not supported for ai_socktype.", /* EAI_SERVICE */ - "ai_socktype not supported.", /* EAI_SOCKTYPE */ - "system error returned in errno.", /* EAI_SYSTEM */ - "invalid value for hints.", /* EAI_BADHINTS */ - "resolved protocol is unknown.", /* EAI_PROTOCOL */ - "unknown error.", /* EAI_MAX */ -}; - -#define GET_CANONNAME(ai, str) \ -if (pai->ai_flags & AI_CANONNAME) {\ - if (((ai)->ai_canonname = (char *)malloc(strlen(str) + 1)) != NULL) {\ - strcpy((ai)->ai_canonname, (str));\ - } else {\ - error = EAI_MEMORY;\ - goto free;\ - }\ -} - -#ifdef HAVE_SOCKADDR_SA_LEN -#define GET_AI(ai, gai_afd, addr, port) {\ - char *p;\ - if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\ - ((gai_afd)->a_socklen)))\ - == NULL) goto free;\ - memcpy(ai, pai, sizeof(struct addrinfo));\ - (ai)->ai_addr = (struct sockaddr *)((ai) + 1);\ - memset((ai)->ai_addr, 0, (gai_afd)->a_socklen);\ - (ai)->ai_addr->sa_len = (ai)->ai_addrlen = (gai_afd)->a_socklen;\ - (ai)->ai_addr->sa_family = (ai)->ai_family = (gai_afd)->a_af;\ - ((struct sockinet *)(ai)->ai_addr)->si_port = port;\ - p = (char *)((ai)->ai_addr);\ - memcpy(p + (gai_afd)->a_off, (addr), (gai_afd)->a_addrlen);\ -} -#else -#define GET_AI(ai, gai_afd, addr, port) {\ - char *p;\ - if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\ - ((gai_afd)->a_socklen)))\ - == NULL) goto free;\ - memcpy(ai, pai, sizeof(struct addrinfo));\ - (ai)->ai_addr = (struct sockaddr *)((ai) + 1);\ - memset((ai)->ai_addr, 0, (gai_afd)->a_socklen);\ - (ai)->ai_addrlen = (gai_afd)->a_socklen;\ - (ai)->ai_addr->sa_family = (ai)->ai_family = (gai_afd)->a_af;\ - ((struct sockinet *)(ai)->ai_addr)->si_port = port;\ - p = (char *)((ai)->ai_addr);\ - memcpy(p + (gai_afd)->a_off, (addr), (gai_afd)->a_addrlen);\ -} -#endif - -#define ERR(err) { error = (err); goto bad; } - -char * -gai_strerror(int ecode) -{ - if (ecode < 0 || ecode > EAI_MAX) - ecode = EAI_MAX; - return ai_errlist[ecode]; -} - -void -freeaddrinfo(struct addrinfo *ai) -{ - struct addrinfo *next; - - do { - next = ai->ai_next; - if (ai->ai_canonname) - free(ai->ai_canonname); - /* no need to free(ai->ai_addr) */ - free(ai); - } while ((ai = next) != NULL); -} - -static int -str_isnumber(const char *p) -{ - unsigned char *q = (unsigned char *)p; - while (*q) { - if (! isdigit(*q)) - return NO; - q++; - } - return YES; -} - -int -getaddrinfo(const char*hostname, const char*servname, - const struct addrinfo *hints, struct addrinfo **res) -{ - struct addrinfo sentinel; - struct addrinfo *top = NULL; - struct addrinfo *cur; - int i, error = 0; - char pton[PTON_MAX]; - struct addrinfo ai; - struct addrinfo *pai; - u_short port; - -#ifdef FAITH - static int firsttime = 1; - - if (firsttime) { - /* translator hack */ - { - char *q = getenv("GAI"); - if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1) - translate = YES; - } - firsttime = 0; - } -#endif - - /* initialize file static vars */ - sentinel.ai_next = NULL; - cur = &sentinel; - pai = &ai; - pai->ai_flags = 0; - pai->ai_family = PF_UNSPEC; - pai->ai_socktype = GAI_ANY; - pai->ai_protocol = GAI_ANY; - pai->ai_addrlen = 0; - pai->ai_canonname = NULL; - pai->ai_addr = NULL; - pai->ai_next = NULL; - port = GAI_ANY; - - if (hostname == NULL && servname == NULL) - return EAI_NONAME; - if (hints) { - /* error check for hints */ - if (hints->ai_addrlen || hints->ai_canonname || - hints->ai_addr || hints->ai_next) - ERR(EAI_BADHINTS); /* xxx */ - if (hints->ai_flags & ~AI_MASK) - ERR(EAI_BADFLAGS); - switch (hints->ai_family) { - case PF_UNSPEC: - case PF_INET: -#ifdef ENABLE_IPV6 - case PF_INET6: -#endif - break; - default: - ERR(EAI_FAMILY); - } - memcpy(pai, hints, sizeof(*pai)); - switch (pai->ai_socktype) { - case GAI_ANY: - switch (pai->ai_protocol) { - case GAI_ANY: - break; - case IPPROTO_UDP: - pai->ai_socktype = SOCK_DGRAM; - break; - case IPPROTO_TCP: - pai->ai_socktype = SOCK_STREAM; - break; - default: - pai->ai_socktype = SOCK_RAW; - break; - } - break; - case SOCK_RAW: - break; - case SOCK_DGRAM: - if (pai->ai_protocol != IPPROTO_UDP && - pai->ai_protocol != GAI_ANY) - ERR(EAI_BADHINTS); /*xxx*/ - pai->ai_protocol = IPPROTO_UDP; - break; - case SOCK_STREAM: - if (pai->ai_protocol != IPPROTO_TCP && - pai->ai_protocol != GAI_ANY) - ERR(EAI_BADHINTS); /*xxx*/ - pai->ai_protocol = IPPROTO_TCP; - break; - default: - ERR(EAI_SOCKTYPE); - /* unreachable */ - } - } - - /* - * service port - */ - if (servname) { - if (str_isnumber(servname)) { - if (pai->ai_socktype == GAI_ANY) { - /* caller accept *GAI_ANY* socktype */ - pai->ai_socktype = SOCK_DGRAM; - pai->ai_protocol = IPPROTO_UDP; - } - port = htons((u_short)atoi(servname)); - } else { - struct servent *sp; - char *proto; - - proto = NULL; - switch (pai->ai_socktype) { - case GAI_ANY: - proto = NULL; - break; - case SOCK_DGRAM: - proto = "udp"; - break; - case SOCK_STREAM: - proto = "tcp"; - break; - default: - fprintf(stderr, "panic!\n"); - break; - } - if ((sp = getservbyname(servname, proto)) == NULL) - ERR(EAI_SERVICE); - port = sp->s_port; - if (pai->ai_socktype == GAI_ANY) { - if (strcmp(sp->s_proto, "udp") == 0) { - pai->ai_socktype = SOCK_DGRAM; - pai->ai_protocol = IPPROTO_UDP; - } else if (strcmp(sp->s_proto, "tcp") == 0) { - pai->ai_socktype = SOCK_STREAM; - pai->ai_protocol = IPPROTO_TCP; - } else - ERR(EAI_PROTOCOL); /*xxx*/ - } - } - } - - /* - * hostname == NULL. - * passive socket -> anyaddr (0.0.0.0 or ::) - * non-passive socket -> localhost (127.0.0.1 or ::1) - */ - if (hostname == NULL) { - struct gai_afd *gai_afd; - - for (gai_afd = &gai_afdl[0]; gai_afd->a_af; gai_afd++) { - if (!(pai->ai_family == PF_UNSPEC - || pai->ai_family == gai_afd->a_af)) { - continue; - } - - if (pai->ai_flags & AI_PASSIVE) { - GET_AI(cur->ai_next, gai_afd, gai_afd->a_addrany, port); - /* xxx meaningless? - * GET_CANONNAME(cur->ai_next, "anyaddr"); - */ - } else { - GET_AI(cur->ai_next, gai_afd, gai_afd->a_loopback, - port); - /* xxx meaningless? - * GET_CANONNAME(cur->ai_next, "localhost"); - */ - } - cur = cur->ai_next; - } - top = sentinel.ai_next; - if (top) - goto good; - else - ERR(EAI_FAMILY); - } - - /* hostname as numeric name */ - for (i = 0; gai_afdl[i].a_af; i++) { - if (inet_pton(gai_afdl[i].a_af, hostname, pton)) { - u_long v4a; -#ifdef ENABLE_IPV6 - u_char pfx; -#endif - - switch (gai_afdl[i].a_af) { - case AF_INET: - v4a = ((struct in_addr *)pton)->s_addr; - v4a = ntohl(v4a); - if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) - pai->ai_flags &= ~AI_CANONNAME; - v4a >>= IN_CLASSA_NSHIFT; - if (v4a == 0 || v4a == IN_LOOPBACKNET) - pai->ai_flags &= ~AI_CANONNAME; - break; -#ifdef ENABLE_IPV6 - case AF_INET6: - pfx = ((struct in6_addr *)pton)->s6_addr8[0]; - if (pfx == 0 || pfx == 0xfe || pfx == 0xff) - pai->ai_flags &= ~AI_CANONNAME; - break; -#endif - } - - if (pai->ai_family == gai_afdl[i].a_af || - pai->ai_family == PF_UNSPEC) { - if (! (pai->ai_flags & AI_CANONNAME)) { - GET_AI(top, &gai_afdl[i], pton, port); - goto good; - } - /* - * if AI_CANONNAME and if reverse lookup - * fail, return ai anyway to pacify - * calling application. - * - * XXX getaddrinfo() is a name->address - * translation function, and it looks strange - * that we do addr->name translation here. - */ - get_name(pton, &gai_afdl[i], &top, pton, pai, port); - goto good; - } else - ERR(EAI_FAMILY); /*xxx*/ - } - } - - if (pai->ai_flags & AI_NUMERICHOST) - ERR(EAI_NONAME); - - /* hostname as alphabetical name */ - error = get_addr(hostname, pai->ai_family, &top, pai, port); - if (error == 0) { - if (top) { - good: - *res = top; - return SUCCESS; - } else - error = EAI_FAIL; - } - free: - if (top) - freeaddrinfo(top); - bad: - *res = NULL; - return error; -} - -static int -get_name(addr, gai_afd, res, numaddr, pai, port0) - const char *addr; - struct gai_afd *gai_afd; - struct addrinfo **res; - char *numaddr; - struct addrinfo *pai; - int port0; -{ - u_short port = port0 & 0xffff; - struct hostent *hp; - struct addrinfo *cur; - int error = 0; -#ifdef ENABLE_IPV6 - int h_error; -#endif - -#ifdef ENABLE_IPV6 - hp = getipnodebyaddr(addr, gai_afd->a_addrlen, gai_afd->a_af, &h_error); -#else - hp = gethostbyaddr(addr, gai_afd->a_addrlen, AF_INET); -#endif - if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { - GET_AI(cur, gai_afd, hp->h_addr_list[0], port); - GET_CANONNAME(cur, hp->h_name); - } else - GET_AI(cur, gai_afd, numaddr, port); - -#ifdef ENABLE_IPV6 - if (hp) - freehostent(hp); -#endif - *res = cur; - return SUCCESS; - free: - if (cur) - freeaddrinfo(cur); -#ifdef ENABLE_IPV6 - if (hp) - freehostent(hp); -#endif - /* bad: */ - *res = NULL; - return error; -} - -static int -get_addr(hostname, af, res, pai, port0) - const char *hostname; - int af; - struct addrinfo **res; - struct addrinfo *pai; - int port0; -{ - u_short port = port0 & 0xffff; - struct addrinfo sentinel; - struct hostent *hp; - struct addrinfo *top, *cur; - struct gai_afd *gai_afd; - int i, error = 0, h_error; - char *ap; - - top = NULL; - sentinel.ai_next = NULL; - cur = &sentinel; -#ifdef ENABLE_IPV6 - if (af == AF_UNSPEC) { - hp = getipnodebyname(hostname, AF_INET6, - AI_ADDRCONFIG|AI_ALL|AI_V4MAPPED, &h_error); - } else - hp = getipnodebyname(hostname, af, AI_ADDRCONFIG, &h_error); -#else - hp = gethostbyname(hostname); - h_error = h_errno; -#endif - if (hp == NULL) { - switch (h_error) { - case HOST_NOT_FOUND: - case NO_DATA: - error = EAI_NODATA; - break; - case TRY_AGAIN: - error = EAI_AGAIN; - break; - case NO_RECOVERY: - default: - error = EAI_FAIL; - break; - } - goto free; - } - - if ((hp->h_name == NULL) || (hp->h_name[0] == 0) || - (hp->h_addr_list[0] == NULL)) { - error = EAI_FAIL; - goto free; - } - - for (i = 0; (ap = hp->h_addr_list[i]) != NULL; i++) { - switch (af) { -#ifdef ENABLE_IPV6 - case AF_INET6: - gai_afd = &gai_afdl[N_INET6]; - break; -#endif -#ifndef ENABLE_IPV6 - default: /* AF_UNSPEC */ -#endif - case AF_INET: - gai_afd = &gai_afdl[N_INET]; - break; -#ifdef ENABLE_IPV6 - default: /* AF_UNSPEC */ - if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) { - ap += sizeof(struct in6_addr) - - sizeof(struct in_addr); - gai_afd = &gai_afdl[N_INET]; - } else - gai_afd = &gai_afdl[N_INET6]; - break; -#endif - } -#ifdef FAITH - if (translate && gai_afd->a_af == AF_INET) { - struct in6_addr *in6; - - GET_AI(cur->ai_next, &gai_afdl[N_INET6], ap, port); - in6 = &((struct sockaddr_in6 *)cur->ai_next->ai_addr)->sin6_addr; - memcpy(&in6->s6_addr32[0], &faith_prefix, - sizeof(struct in6_addr) - sizeof(struct in_addr)); - memcpy(&in6->s6_addr32[3], ap, sizeof(struct in_addr)); - } else -#endif /* FAITH */ - GET_AI(cur->ai_next, gai_afd, ap, port); - if (cur == &sentinel) { - top = cur->ai_next; - GET_CANONNAME(top, hp->h_name); - } - cur = cur->ai_next; - } -#ifdef ENABLE_IPV6 - freehostent(hp); -#endif - *res = top; - return SUCCESS; - free: - if (top) - freeaddrinfo(top); -#ifdef ENABLE_IPV6 - if (hp) - freehostent(hp); -#endif -/* bad: */ - *res = NULL; - return error; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/getbuildinfo.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/getbuildinfo.c deleted file mode 100644 index 0c61ab2f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/getbuildinfo.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "Python.h" - -#ifdef macintosh -#include "macbuildno.h" -#endif - -#ifndef DONT_HAVE_STDIO_H -#include -#endif - -#ifndef DATE -#ifdef __DATE__ -#define DATE __DATE__ -#else -#define DATE "xx/xx/xx" -#endif -#endif - -#ifndef TIME -#ifdef __TIME__ -#define TIME __TIME__ -#else -#define TIME "xx:xx:xx" -#endif -#endif - -#ifndef BUILD -#define BUILD 0 -#endif - -const char * -Py_GetBuildInfo(void) -{ - static char buildinfo[50]; - PyOS_snprintf(buildinfo, sizeof(buildinfo), - "#%d, %.20s, %.9s", BUILD, DATE, TIME); - return buildinfo; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/getnameinfo.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/getnameinfo.c deleted file mode 100644 index af947508..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/getnameinfo.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Issues to be discussed: - * - Thread safe-ness must be checked - * - Return values. There seems to be no standard for return value (RFC2133) - * but INRIA implementation returns EAI_xxx defined for getaddrinfo(). - */ - -#if 0 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "addrinfo.h" -#endif - -#define SUCCESS 0 -#define YES 1 -#define NO 0 - -static struct gni_afd { - int a_af; - int a_addrlen; - int a_socklen; - int a_off; -} gni_afdl [] = { -#ifdef ENABLE_IPV6 - {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6), - offsetof(struct sockaddr_in6, sin6_addr)}, -#endif - {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in), - offsetof(struct sockaddr_in, sin_addr)}, - {0, 0, 0}, -}; - -struct gni_sockinet { - u_char si_len; - u_char si_family; - u_short si_port; -}; - -#define ENI_NOSOCKET 0 -#define ENI_NOSERVNAME 1 -#define ENI_NOHOSTNAME 2 -#define ENI_MEMORY 3 -#define ENI_SYSTEM 4 -#define ENI_FAMILY 5 -#define ENI_SALEN 6 - -/* forward declaration to make gcc happy */ -int getnameinfo Py_PROTO((const struct sockaddr *, size_t, char *, size_t, - char *, size_t, int)); - -int -getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) - const struct sockaddr *sa; - size_t salen; - char *host; - size_t hostlen; - char *serv; - size_t servlen; - int flags; -{ - struct gni_afd *gni_afd; - struct servent *sp; - struct hostent *hp; - u_short port; - int family, len, i; - char *addr, *p; - u_long v4a; -#ifdef ENABLE_IPV6 - u_char pfx; -#endif - int h_error; - char numserv[512]; - char numaddr[512]; - - if (sa == NULL) - return ENI_NOSOCKET; - -#ifdef HAVE_SOCKADDR_SA_LEN - len = sa->sa_len; - if (len != salen) return ENI_SALEN; -#else - len = salen; -#endif - - family = sa->sa_family; - for (i = 0; gni_afdl[i].a_af; i++) - if (gni_afdl[i].a_af == family) { - gni_afd = &gni_afdl[i]; - goto found; - } - return ENI_FAMILY; - - found: - if (len != gni_afd->a_socklen) return ENI_SALEN; - - port = ((struct gni_sockinet *)sa)->si_port; /* network byte order */ - addr = (char *)sa + gni_afd->a_off; - - if (serv == NULL || servlen == 0) { - /* what we should do? */ - } else if (flags & NI_NUMERICSERV) { - sprintf(numserv, "%d", ntohs(port)); - if (strlen(numserv) > servlen) - return ENI_MEMORY; - strcpy(serv, numserv); - } else { - sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp"); - if (sp) { - if (strlen(sp->s_name) > servlen) - return ENI_MEMORY; - strcpy(serv, sp->s_name); - } else - return ENI_NOSERVNAME; - } - - switch (sa->sa_family) { - case AF_INET: - v4a = ((struct sockaddr_in *)sa)->sin_addr.s_addr; - if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) - flags |= NI_NUMERICHOST; - v4a >>= IN_CLASSA_NSHIFT; - if (v4a == 0 || v4a == IN_LOOPBACKNET) - flags |= NI_NUMERICHOST; - break; -#ifdef ENABLE_IPV6 - case AF_INET6: - pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr8[0]; - if (pfx == 0 || pfx == 0xfe || pfx == 0xff) - flags |= NI_NUMERICHOST; - break; -#endif - } - if (host == NULL || hostlen == 0) { - /* what should we do? */ - } else if (flags & NI_NUMERICHOST) { - if (inet_ntop(gni_afd->a_af, addr, numaddr, sizeof(numaddr)) - == NULL) - return ENI_SYSTEM; - if (strlen(numaddr) > hostlen) - return ENI_MEMORY; - strcpy(host, numaddr); - } else { -#ifdef ENABLE_IPV6 - hp = getipnodebyaddr(addr, gni_afd->a_addrlen, gni_afd->a_af, &h_error); -#else - hp = gethostbyaddr(addr, gni_afd->a_addrlen, gni_afd->a_af); - h_error = h_errno; -#endif - - if (hp) { - if (flags & NI_NOFQDN) { - p = strchr(hp->h_name, '.'); - if (p) *p = '\0'; - } - if (strlen(hp->h_name) > hostlen) { -#ifdef ENABLE_IPV6 - freehostent(hp); -#endif - return ENI_MEMORY; - } - strcpy(host, hp->h_name); -#ifdef ENABLE_IPV6 - freehostent(hp); -#endif - } else { - if (flags & NI_NAMEREQD) - return ENI_NOHOSTNAME; - if (inet_ntop(gni_afd->a_af, addr, numaddr, sizeof(numaddr)) - == NULL) - return ENI_NOHOSTNAME; - if (strlen(numaddr) > hostlen) - return ENI_MEMORY; - strcpy(host, numaddr); - } - } - return SUCCESS; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/getpath.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/getpath.c deleted file mode 100644 index c1c3e630..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/getpath.c +++ /dev/null @@ -1,650 +0,0 @@ -/* Return the initial module search path. */ - -#include "Python.h" -#include "osdefs.h" - -#include -#include - -#ifdef WITH_NEXT_FRAMEWORK -#include -#endif - -/* Search in some common locations for the associated Python libraries. - * - * Two directories must be found, the platform independent directory - * (prefix), containing the common .py and .pyc files, and the platform - * dependent directory (exec_prefix), containing the shared library - * modules. Note that prefix and exec_prefix can be the same directory, - * but for some installations, they are different. - * - * Py_GetPath() carries out separate searches for prefix and exec_prefix. - * Each search tries a number of different locations until a ``landmark'' - * file or directory is found. If no prefix or exec_prefix is found, a - * warning message is issued and the preprocessor defined PREFIX and - * EXEC_PREFIX are used (even though they will not work); python carries on - * as best as is possible, but most imports will fail. - * - * Before any searches are done, the location of the executable is - * determined. If argv[0] has one or more slashs in it, it is used - * unchanged. Otherwise, it must have been invoked from the shell's path, - * so we search $PATH for the named executable and use that. If the - * executable was not found on $PATH (or there was no $PATH environment - * variable), the original argv[0] string is used. - * - * Next, the executable location is examined to see if it is a symbolic - * link. If so, the link is chased (correctly interpreting a relative - * pathname if one is found) and the directory of the link target is used. - * - * Finally, argv0_path is set to the directory containing the executable - * (i.e. the last component is stripped). - * - * With argv0_path in hand, we perform a number of steps. The same steps - * are performed for prefix and for exec_prefix, but with a different - * landmark. - * - * Step 1. Are we running python out of the build directory? This is - * checked by looking for a different kind of landmark relative to - * argv0_path. For prefix, the landmark's path is derived from the VPATH - * preprocessor variable (taking into account that its value is almost, but - * not quite, what we need). For exec_prefix, the landmark is - * Modules/Setup. If the landmark is found, we're done. - * - * For the remaining steps, the prefix landmark will always be - * lib/python$VERSION/os.py and the exec_prefix will always be - * lib/python$VERSION/lib-dynload, where $VERSION is Python's version - * number as supplied by the Makefile. Note that this means that no more - * build directory checking is performed; if the first step did not find - * the landmarks, the assumption is that python is running from an - * installed setup. - * - * Step 2. See if the $PYTHONHOME environment variable points to the - * installed location of the Python libraries. If $PYTHONHOME is set, then - * it points to prefix and exec_prefix. $PYTHONHOME can be a single - * directory, which is used for both, or the prefix and exec_prefix - * directories separated by a colon. - * - * Step 3. Try to find prefix and exec_prefix relative to argv0_path, - * backtracking up the path until it is exhausted. This is the most common - * step to succeed. Note that if prefix and exec_prefix are different, - * exec_prefix is more likely to be found; however if exec_prefix is a - * subdirectory of prefix, both will be found. - * - * Step 4. Search the directories pointed to by the preprocessor variables - * PREFIX and EXEC_PREFIX. These are supplied by the Makefile but can be - * passed in as options to the configure script. - * - * That's it! - * - * Well, almost. Once we have determined prefix and exec_prefix, the - * preprocessor variable PYTHONPATH is used to construct a path. Each - * relative path on PYTHONPATH is prefixed with prefix. Then the directory - * containing the shared library modules is appended. The environment - * variable $PYTHONPATH is inserted in front of it all. Finally, the - * prefix and exec_prefix globals are tweaked so they reflect the values - * expected by other code, by stripping the "lib/python$VERSION/..." stuff - * off. If either points to the build directory, the globals are reset to - * the corresponding preprocessor variables (so sys.prefix will reflect the - * installation location, even though sys.path points into the build - * directory). This seems to make more sense given that currently the only - * known use of sys.prefix and sys.exec_prefix is for the ILU installation - * process to find the installed Python tree. - */ - -#ifndef VERSION -#if defined(__VMS) -#define VERSION "2_1" -#else -#define VERSION "2.1" -#endif -#endif - -#ifndef VPATH -#define VPATH "." -#endif - -#ifndef PREFIX -#define PREFIX "/usr/local" -#endif - -#ifndef EXEC_PREFIX -#define EXEC_PREFIX PREFIX -#endif - -#ifndef PYTHONPATH -#define PYTHONPATH PREFIX "/lib/python" VERSION ":" \ - EXEC_PREFIX "/lib/python" VERSION "/lib-dynload" -#endif - -#ifndef LANDMARK -#define LANDMARK "os.py" -#endif - -static char prefix[MAXPATHLEN+1]; -static char exec_prefix[MAXPATHLEN+1]; -static char progpath[MAXPATHLEN+1]; -static char *module_search_path = NULL; -static char lib_python[] = "lib/python" VERSION; - -static void -reduce(char *dir) -{ - size_t i = strlen(dir); - while (i > 0 && dir[i] != SEP) - --i; - dir[i] = '\0'; -} - - -static int -isfile(char *filename) /* Is file, not directory */ -{ - struct stat buf; - if (stat(filename, &buf) != 0) - return 0; - if (!S_ISREG(buf.st_mode)) - return 0; - return 1; -} - - -static int -ismodule(char *filename) /* Is module -- check for .pyc/.pyo too */ -{ - if (isfile(filename)) - return 1; - - /* Check for the compiled version of prefix. */ - if (strlen(filename) < MAXPATHLEN) { - strcat(filename, Py_OptimizeFlag ? "o" : "c"); - if (isfile(filename)) - return 1; - } - return 0; -} - - -static int -isxfile(char *filename) /* Is executable file */ -{ - struct stat buf; - if (stat(filename, &buf) != 0) - return 0; - if (!S_ISREG(buf.st_mode)) - return 0; - if ((buf.st_mode & 0111) == 0) - return 0; - return 1; -} - - -static int -isdir(char *filename) /* Is directory */ -{ - struct stat buf; - if (stat(filename, &buf) != 0) - return 0; - if (!S_ISDIR(buf.st_mode)) - return 0; - return 1; -} - - -/* joinpath requires that any buffer argument passed to it has at - least MAXPATHLEN + 1 bytes allocated. If this requirement is met, - it guarantees that it will never overflow the buffer. If stuff - is too long, buffer will contain a truncated copy of stuff. -*/ -static void -joinpath(char *buffer, char *stuff) -{ - size_t n, k; - if (stuff[0] == SEP) - n = 0; - else { - n = strlen(buffer); - if (n > 0 && buffer[n-1] != SEP && n < MAXPATHLEN) - buffer[n++] = SEP; - } - k = strlen(stuff); - if (n + k > MAXPATHLEN) - k = MAXPATHLEN - n; - strncpy(buffer+n, stuff, k); - buffer[n+k] = '\0'; -} - -/* copy_absolute requires that path be allocated at least - MAXPATHLEN + 1 bytes and that p be no more than MAXPATHLEN bytes. */ -static void -copy_absolute(char *path, char *p) -{ - if (p[0] == SEP) - strcpy(path, p); - else { - getcwd(path, MAXPATHLEN); - if (p[0] == '.' && p[1] == SEP) - p += 2; - joinpath(path, p); - } -} - -/* absolutize() requires that path be allocated at least MAXPATHLEN+1 bytes. */ -static void -absolutize(char *path) -{ - char buffer[MAXPATHLEN + 1]; - - if (path[0] == SEP) - return; - copy_absolute(buffer, path); - strcpy(path, buffer); -} - -/* search_for_prefix requires that argv0_path be no more than MAXPATHLEN - bytes long. -*/ -static int -search_for_prefix(char *argv0_path, char *home) -{ - size_t n; - char *vpath; - - /* If PYTHONHOME is set, we believe it unconditionally */ - if (home) { - char *delim; - strncpy(prefix, home, MAXPATHLEN); - delim = strchr(prefix, DELIM); - if (delim) - *delim = '\0'; - joinpath(prefix, lib_python); - joinpath(prefix, LANDMARK); - return 1; - } - - /* Check to see if argv[0] is in the build directory */ - strcpy(prefix, argv0_path); - joinpath(prefix, "Modules/Setup"); - if (isfile(prefix)) { - /* Check VPATH to see if argv0_path is in the build directory. */ - vpath = VPATH; - strcpy(prefix, argv0_path); - joinpath(prefix, vpath); - joinpath(prefix, "Lib"); - joinpath(prefix, LANDMARK); - if (ismodule(prefix)) - return -1; - } - - /* Search from argv0_path, until root is found */ - copy_absolute(prefix, argv0_path); - do { - n = strlen(prefix); - joinpath(prefix, lib_python); - joinpath(prefix, LANDMARK); - if (ismodule(prefix)) - return 1; - prefix[n] = '\0'; - reduce(prefix); - } while (prefix[0]); - - /* Look at configure's PREFIX */ - strncpy(prefix, PREFIX, MAXPATHLEN); - joinpath(prefix, lib_python); - joinpath(prefix, LANDMARK); - if (ismodule(prefix)) - return 1; - - /* Fail */ - return 0; -} - - -/* search_for_exec_prefix requires that argv0_path be no more than - MAXPATHLEN bytes long. -*/ -static int -search_for_exec_prefix(char *argv0_path, char *home) -{ - size_t n; - - /* If PYTHONHOME is set, we believe it unconditionally */ - if (home) { - char *delim; - delim = strchr(home, DELIM); - if (delim) - strncpy(exec_prefix, delim+1, MAXPATHLEN); - else - strncpy(exec_prefix, home, MAXPATHLEN); - joinpath(exec_prefix, lib_python); - joinpath(exec_prefix, "lib-dynload"); - return 1; - } - - /* Check to see if argv[0] is in the build directory */ - strcpy(exec_prefix, argv0_path); - joinpath(exec_prefix, "Modules/Setup"); - if (isfile(exec_prefix)) { - reduce(exec_prefix); - return -1; - } - - /* Search from argv0_path, until root is found */ - copy_absolute(exec_prefix, argv0_path); - do { - n = strlen(exec_prefix); - joinpath(exec_prefix, lib_python); - joinpath(exec_prefix, "lib-dynload"); - if (isdir(exec_prefix)) - return 1; - exec_prefix[n] = '\0'; - reduce(exec_prefix); - } while (exec_prefix[0]); - - /* Look at configure's EXEC_PREFIX */ - strncpy(exec_prefix, EXEC_PREFIX, MAXPATHLEN); - joinpath(exec_prefix, lib_python); - joinpath(exec_prefix, "lib-dynload"); - if (isdir(exec_prefix)) - return 1; - - /* Fail */ - return 0; -} - - -static void -calculate_path(void) -{ - extern char *Py_GetProgramName(void); - - static char delimiter[2] = {DELIM, '\0'}; - static char separator[2] = {SEP, '\0'}; - char *pythonpath = PYTHONPATH; - char *rtpypath = Py_GETENV("PYTHONPATH"); - char *home = Py_GetPythonHome(); - char *path = getenv("PATH"); - char *prog = Py_GetProgramName(); - char argv0_path[MAXPATHLEN+1]; - char zip_path[MAXPATHLEN+1]; - int pfound, efound; /* 1 if found; -1 if found build directory */ - char *buf; - size_t bufsz; - size_t prefixsz; - char *defpath = pythonpath; -#ifdef WITH_NEXT_FRAMEWORK - NSModule pythonModule; -#endif - - /* If there is no slash in the argv0 path, then we have to - * assume python is on the user's $PATH, since there's no - * other way to find a directory to start the search from. If - * $PATH isn't exported, you lose. - */ - if (strchr(prog, SEP)) - strncpy(progpath, prog, MAXPATHLEN); - else if (path) { - while (1) { - char *delim = strchr(path, DELIM); - - if (delim) { - size_t len = delim - path; - if (len > MAXPATHLEN) - len = MAXPATHLEN; - strncpy(progpath, path, len); - *(progpath + len) = '\0'; - } - else - strncpy(progpath, path, MAXPATHLEN); - - joinpath(progpath, prog); - if (isxfile(progpath)) - break; - - if (!delim) { - progpath[0] = '\0'; - break; - } - path = delim + 1; - } - } - else - progpath[0] = '\0'; - if (progpath[0] != SEP) - absolutize(progpath); - strncpy(argv0_path, progpath, MAXPATHLEN); - argv0_path[MAXPATHLEN] = '\0'; - -#ifdef WITH_NEXT_FRAMEWORK - /* On Mac OS X we have a special case if we're running from a framework. - ** This is because the python home should be set relative to the library, - ** which is in the framework, not relative to the executable, which may - ** be outside of the framework. Except when we're in the build directory... - */ - pythonModule = NSModuleForSymbol(NSLookupAndBindSymbol("_Py_Initialize")); - /* Use dylib functions to find out where the framework was loaded from */ - buf = (char *)NSLibraryNameForModule(pythonModule); - if (buf != NULL) { - /* We're in a framework. */ - /* See if we might be in the build directory. The framework in the - ** build directory is incomplete, it only has the .dylib and a few - ** needed symlinks, it doesn't have the Lib directories and such. - ** If we're running with the framework from the build directory we must - ** be running the interpreter in the build directory, so we use the - ** build-directory-specific logic to find Lib and such. - */ - strncpy(argv0_path, buf, MAXPATHLEN); - reduce(argv0_path); - joinpath(argv0_path, lib_python); - joinpath(argv0_path, LANDMARK); - if (!ismodule(argv0_path)) { - /* We are in the build directory so use the name of the - executable - we know that the absolute path is passed */ - strncpy(argv0_path, prog, MAXPATHLEN); - } - else { - /* Use the location of the library as the progpath */ - strncpy(argv0_path, buf, MAXPATHLEN); - } - } -#endif - -#if HAVE_READLINK - { - char tmpbuffer[MAXPATHLEN+1]; - int linklen = readlink(progpath, tmpbuffer, MAXPATHLEN); - while (linklen != -1) { - /* It's not null terminated! */ - tmpbuffer[linklen] = '\0'; - if (tmpbuffer[0] == SEP) - /* tmpbuffer should never be longer than MAXPATHLEN, - but extra check does not hurt */ - strncpy(argv0_path, tmpbuffer, MAXPATHLEN); - else { - /* Interpret relative to progpath */ - reduce(argv0_path); - joinpath(argv0_path, tmpbuffer); - } - linklen = readlink(argv0_path, tmpbuffer, MAXPATHLEN); - } - } -#endif /* HAVE_READLINK */ - - reduce(argv0_path); - /* At this point, argv0_path is guaranteed to be less than - MAXPATHLEN bytes long. - */ - - if (!(pfound = search_for_prefix(argv0_path, home))) { - if (!Py_FrozenFlag) - fprintf(stderr, - "Could not find platform independent libraries \n"); - strncpy(prefix, PREFIX, MAXPATHLEN); - joinpath(prefix, lib_python); - } - else - reduce(prefix); - - strncpy(zip_path, prefix, MAXPATHLEN); - zip_path[MAXPATHLEN] = '\0'; - if (pfound > 0) { /* Use the reduced prefix returned by Py_GetPrefix() */ - reduce(zip_path); - reduce(zip_path); - } - else - strncpy(zip_path, PREFIX, MAXPATHLEN); - joinpath(zip_path, "lib/python00.zip"); - bufsz = strlen(zip_path); /* Replace "00" with version */ - zip_path[bufsz - 6] = VERSION[0]; - zip_path[bufsz - 5] = VERSION[2]; - - if (!(efound = search_for_exec_prefix(argv0_path, home))) { - if (!Py_FrozenFlag) - fprintf(stderr, - "Could not find platform dependent libraries \n"); - strncpy(exec_prefix, EXEC_PREFIX, MAXPATHLEN); - joinpath(exec_prefix, "lib/lib-dynload"); - } - /* If we found EXEC_PREFIX do *not* reduce it! (Yet.) */ - - if ((!pfound || !efound) && !Py_FrozenFlag) - fprintf(stderr, - "Consider setting $PYTHONHOME to [:]\n"); - - /* Calculate size of return buffer. - */ - bufsz = 0; - - if (rtpypath) - bufsz += strlen(rtpypath) + 1; - - prefixsz = strlen(prefix) + 1; - - while (1) { - char *delim = strchr(defpath, DELIM); - - if (defpath[0] != SEP) - /* Paths are relative to prefix */ - bufsz += prefixsz; - - if (delim) - bufsz += delim - defpath + 1; - else { - bufsz += strlen(defpath) + 1; - break; - } - defpath = delim + 1; - } - - bufsz += strlen(zip_path) + 1; - bufsz += strlen(exec_prefix) + 1; - - /* This is the only malloc call in this file */ - buf = PyMem_Malloc(bufsz); - - if (buf == NULL) { - /* We can't exit, so print a warning and limp along */ - fprintf(stderr, "Not enough memory for dynamic PYTHONPATH.\n"); - fprintf(stderr, "Using default static PYTHONPATH.\n"); - module_search_path = PYTHONPATH; - } - else { - /* Run-time value of $PYTHONPATH goes first */ - if (rtpypath) { - strcpy(buf, rtpypath); - strcat(buf, delimiter); - } - else - buf[0] = '\0'; - - /* Next is the default zip path */ - strcat(buf, zip_path); - strcat(buf, delimiter); - - /* Next goes merge of compile-time $PYTHONPATH with - * dynamically located prefix. - */ - defpath = pythonpath; - while (1) { - char *delim = strchr(defpath, DELIM); - - if (defpath[0] != SEP) { - strcat(buf, prefix); - strcat(buf, separator); - } - - if (delim) { - size_t len = delim - defpath + 1; - size_t end = strlen(buf) + len; - strncat(buf, defpath, len); - *(buf + end) = '\0'; - } - else { - strcat(buf, defpath); - break; - } - defpath = delim + 1; - } - strcat(buf, delimiter); - - /* Finally, on goes the directory for dynamic-load modules */ - strcat(buf, exec_prefix); - - /* And publish the results */ - module_search_path = buf; - } - - /* Reduce prefix and exec_prefix to their essence, - * e.g. /usr/local/lib/python1.5 is reduced to /usr/local. - * If we're loading relative to the build directory, - * return the compiled-in defaults instead. - */ - if (pfound > 0) { - reduce(prefix); - reduce(prefix); - } - else - strncpy(prefix, PREFIX, MAXPATHLEN); - - if (efound > 0) { - reduce(exec_prefix); - reduce(exec_prefix); - reduce(exec_prefix); - } - else - strncpy(exec_prefix, EXEC_PREFIX, MAXPATHLEN); -} - - -/* External interface */ - -char * -Py_GetPath(void) -{ - if (!module_search_path) - calculate_path(); - return module_search_path; -} - -char * -Py_GetPrefix(void) -{ - if (!module_search_path) - calculate_path(); - return prefix; -} - -char * -Py_GetExecPrefix(void) -{ - if (!module_search_path) - calculate_path(); - return exec_prefix; -} - -char * -Py_GetProgramFullPath(void) -{ - if (!module_search_path) - calculate_path(); - return progpath; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/glmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/glmodule.c deleted file mode 100644 index 6bee1156..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/glmodule.c +++ /dev/null @@ -1,7628 +0,0 @@ - -/* -Input used to generate the Python module "glmodule.c". -The stub generator is a Python script called "cgen.py". - -Each definition must be contained on one line: - - - - can be: void, short, long (XXX maybe others?) - - can be: char, string, short, float, long, or double - string indicates a null terminated string; - if is char and begins with a *, the * is stripped - and is changed into string - - has the form or [] - where can be - s: arg is sent - r: arg is received (arg is a pointer) - and can be (N and I are numbers): - N - argI - retval - N*argI - N*I - N*retval - In the case where the subscript consists of two parts - separated by *, the first part is the width of the matrix, and - the second part is the length of the matrix. This order is - opposite from the order used in C to declare a two-dimensional - matrix. -*/ - -/* - * An attempt has been made to make this module switch threads on qread - * calls. It is far from safe, though. - */ - -#include -#include - -#ifdef __sgi -extern int devport(); -extern int textwritemask(); -extern int pagewritemask(); -extern int gewrite(); -extern int gettp(); -#endif - -#include "Python.h" -#include "cgensupport.h" - -/* -Some stubs are too complicated for the stub generator. -We can include manually written versions of them here. -A line starting with '%' gives the name of the function so the stub -generator can include it in the table of functions. -*/ - - -static PyObject * -gl_qread(PyObject *self, PyObject *args) -{ - long retval; - short arg1 ; - Py_BEGIN_ALLOW_THREADS - retval = qread( & arg1 ); - Py_END_ALLOW_THREADS - { PyObject *v = PyTuple_New( 2 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewlongobject(retval)); - PyTuple_SetItem(v, 1, mknewshortobject(arg1)); - return v; - } -} - - -/* -varray -- an array of v.. calls. -The argument is an array (maybe list or tuple) of points. -Each point must be a tuple or list of coordinates (x, y, z). -The points may be 2- or 3-dimensional but must all have the -same dimension. Float and int values may be mixed however. -The points are always converted to 3D double precision points -by assuming z=0.0 if necessary (as indicated in the man page), -and for each point v3d() is called. -*/ - - -static PyObject * -gl_varray(PyObject *self, PyObject *args) -{ - PyObject *v, *w=NULL; - int i, n, width; - double vec[3]; - PyObject * (*getitem)(PyObject *, int); - - if (!PyArg_GetObject(args, 1, 0, &v)) - return NULL; - - if (PyList_Check(v)) { - n = PyList_Size(v); - getitem = PyList_GetItem; - } - else if (PyTuple_Check(v)) { - n = PyTuple_Size(v); - getitem = PyTuple_GetItem; - } - else { - PyErr_BadArgument(); - return NULL; - } - - if (n == 0) { - Py_INCREF(Py_None); - return Py_None; - } - if (n > 0) - w = (*getitem)(v, 0); - - width = 0; - if (w == NULL) { - } - else if (PyList_Check(w)) { - width = PyList_Size(w); - } - else if (PyTuple_Check(w)) { - width = PyTuple_Size(w); - } - - switch (width) { - case 2: - vec[2] = 0.0; - /* Fall through */ - case 3: - break; - default: - PyErr_BadArgument(); - return NULL; - } - - for (i = 0; i < n; i++) { - w = (*getitem)(v, i); - if (!PyArg_GetDoubleArray(w, 1, 0, width, vec)) - return NULL; - v3d(vec); - } - - Py_INCREF(Py_None); - return Py_None; -} - -/* -vnarray, nvarray -- an array of n3f and v3f calls. -The argument is an array (list or tuple) of pairs of points and normals. -Each pair is a tuple (NOT a list) of a point and a normal for that point. -Each point or normal must be a tuple (NOT a list) of coordinates (x, y, z). -Three coordinates must be given. Float and int values may be mixed. -For each pair, n3f() is called for the normal, and then v3f() is called -for the vector. - -vnarray and nvarray differ only in the order of the vector and normal in -the pair: vnarray expects (v, n) while nvarray expects (n, v). -*/ - -static PyObject *gen_nvarray(); /* Forward */ - - -static PyObject * -gl_nvarray(PyObject *self, PyObject *args) -{ - return gen_nvarray(args, 0); -} - - -static PyObject * -gl_vnarray(PyObject *self, PyObject *args) -{ - return gen_nvarray(args, 1); -} - -/* Generic, internal version of {nv,nv}array: inorm indicates the - argument order, 0: normal first, 1: vector first. */ - -static PyObject * -gen_nvarray(PyObject *args, int inorm) -{ - PyObject *v, *w, *wnorm, *wvec; - int i, n; - float norm[3], vec[3]; - PyObject * (*getitem)(PyObject *, int); - - if (!PyArg_GetObject(args, 1, 0, &v)) - return NULL; - - if (PyList_Check(v)) { - n = PyList_Size(v); - getitem = PyList_GetItem; - } - else if (PyTuple_Check(v)) { - n = PyTuple_Size(v); - getitem = PyTuple_GetItem; - } - else { - PyErr_BadArgument(); - return NULL; - } - - for (i = 0; i < n; i++) { - w = (*getitem)(v, i); - if (!PyTuple_Check(w) || PyTuple_Size(w) != 2) { - PyErr_BadArgument(); - return NULL; - } - wnorm = PyTuple_GetItem(w, inorm); - wvec = PyTuple_GetItem(w, 1 - inorm); - if (!PyArg_GetFloatArray(wnorm, 1, 0, 3, norm) || - !PyArg_GetFloatArray(wvec, 1, 0, 3, vec)) - return NULL; - n3f(norm); - v3f(vec); - } - - Py_INCREF(Py_None); - return Py_None; -} - -/* nurbssurface(s_knots[], t_knots[], ctl[][], s_order, t_order, type). - The dimensions of ctl[] are computed as follows: - [len(s_knots) - s_order], [len(t_knots) - t_order] -*/ - - -static PyObject * -gl_nurbssurface(PyObject *self, PyObject *args) -{ - long arg1 ; - double * arg2 ; - long arg3 ; - double * arg4 ; - double *arg5 ; - long arg6 ; - long arg7 ; - long arg8 ; - long ncoords; - long s_byte_stride, t_byte_stride; - long s_nctl, t_nctl; - long s, t; - PyObject *v, *w, *pt; - double *pnext; - if (!PyArg_GetLongArraySize(args, 6, 0, &arg1)) - return NULL; - if ((arg2 = PyMem_NEW(double, arg1 )) == NULL) { - return PyErr_NoMemory(); - } - if (!PyArg_GetDoubleArray(args, 6, 0, arg1 , arg2)) - return NULL; - if (!PyArg_GetLongArraySize(args, 6, 1, &arg3)) - return NULL; - if ((arg4 = PyMem_NEW(double, arg3 )) == NULL) { - return PyErr_NoMemory(); - } - if (!PyArg_GetDoubleArray(args, 6, 1, arg3 , arg4)) - return NULL; - if (!PyArg_GetLong(args, 6, 3, &arg6)) - return NULL; - if (!PyArg_GetLong(args, 6, 4, &arg7)) - return NULL; - if (!PyArg_GetLong(args, 6, 5, &arg8)) - return NULL; - if (arg8 == N_XYZ) - ncoords = 3; - else if (arg8 == N_XYZW) - ncoords = 4; - else { - PyErr_BadArgument(); - return NULL; - } - s_nctl = arg1 - arg6; - t_nctl = arg3 - arg7; - if (!PyArg_GetObject(args, 6, 2, &v)) - return NULL; - if (!PyList_Check(v) || PyList_Size(v) != s_nctl) { - PyErr_BadArgument(); - return NULL; - } - if ((arg5 = PyMem_NEW(double, s_nctl*t_nctl*ncoords )) == NULL) { - return PyErr_NoMemory(); - } - pnext = arg5; - for (s = 0; s < s_nctl; s++) { - w = PyList_GetItem(v, s); - if (w == NULL || !PyList_Check(w) || - PyList_Size(w) != t_nctl) { - PyErr_BadArgument(); - return NULL; - } - for (t = 0; t < t_nctl; t++) { - pt = PyList_GetItem(w, t); - if (!PyArg_GetDoubleArray(pt, 1, 0, ncoords, pnext)) - return NULL; - pnext += ncoords; - } - } - s_byte_stride = sizeof(double) * ncoords; - t_byte_stride = s_byte_stride * s_nctl; - nurbssurface( arg1 , arg2 , arg3 , arg4 , - s_byte_stride , t_byte_stride , arg5 , arg6 , arg7 , arg8 ); - PyMem_DEL(arg2); - PyMem_DEL(arg4); - PyMem_DEL(arg5); - Py_INCREF(Py_None); - return Py_None; -} - -/* nurbscurve(knots, ctlpoints, order, type). - The length of ctlpoints is len(knots)-order. */ - - -static PyObject * -gl_nurbscurve(PyObject *self, PyObject *args) -{ - long arg1 ; - double * arg2 ; - long arg3 ; - double * arg4 ; - long arg5 ; - long arg6 ; - int ncoords, npoints; - int i; - PyObject *v; - double *pnext; - if (!PyArg_GetLongArraySize(args, 4, 0, &arg1)) - return NULL; - if ((arg2 = PyMem_NEW(double, arg1 )) == NULL) { - return PyErr_NoMemory(); - } - if (!PyArg_GetDoubleArray(args, 4, 0, arg1 , arg2)) - return NULL; - if (!PyArg_GetLong(args, 4, 2, &arg5)) - return NULL; - if (!PyArg_GetLong(args, 4, 3, &arg6)) - return NULL; - if (arg6 == N_ST) - ncoords = 2; - else if (arg6 == N_STW) - ncoords = 3; - else { - PyErr_BadArgument(); - return NULL; - } - npoints = arg1 - arg5; - if (!PyArg_GetObject(args, 4, 1, &v)) - return NULL; - if (!PyList_Check(v) || PyList_Size(v) != npoints) { - PyErr_BadArgument(); - return NULL; - } - if ((arg4 = PyMem_NEW(double, npoints*ncoords )) == NULL) { - return PyErr_NoMemory(); - } - pnext = arg4; - for (i = 0; i < npoints; i++) { - if (!PyArg_GetDoubleArray(PyList_GetItem(v, i), 1, 0, ncoords, pnext)) - return NULL; - pnext += ncoords; - } - arg3 = (sizeof(double)) * ncoords; - nurbscurve( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 ); - PyMem_DEL(arg2); - PyMem_DEL(arg4); - Py_INCREF(Py_None); - return Py_None; -} - -/* pwlcurve(points, type). - Points is a list of points. Type must be N_ST. */ - - -static PyObject * -gl_pwlcurve(PyObject *self, PyObject *args) -{ - PyObject *v; - long type; - double *data, *pnext; - long npoints, ncoords; - int i; - if (!PyArg_GetObject(args, 2, 0, &v)) - return NULL; - if (!PyArg_GetLong(args, 2, 1, &type)) - return NULL; - if (!PyList_Check(v)) { - PyErr_BadArgument(); - return NULL; - } - npoints = PyList_Size(v); - if (type == N_ST) - ncoords = 2; - else { - PyErr_BadArgument(); - return NULL; - } - if ((data = PyMem_NEW(double, npoints*ncoords)) == NULL) { - return PyErr_NoMemory(); - } - pnext = data; - for (i = 0; i < npoints; i++) { - if (!PyArg_GetDoubleArray(PyList_GetItem(v, i), 1, 0, ncoords, pnext)) - return NULL; - pnext += ncoords; - } - pwlcurve(npoints, data, sizeof(double)*ncoords, type); - PyMem_DEL(data); - Py_INCREF(Py_None); - return Py_None; -} - - -/* Picking and Selecting */ - -static short *pickbuffer = NULL; -static long pickbuffersize; - -static PyObject * -pick_select(PyObject *args, void (*func)()) -{ - if (!PyArg_GetLong(args, 1, 0, &pickbuffersize)) - return NULL; - if (pickbuffer != NULL) { - PyErr_SetString(PyExc_RuntimeError, - "pick/gselect: already picking/selecting"); - return NULL; - } - if ((pickbuffer = PyMem_NEW(short, pickbuffersize)) == NULL) { - return PyErr_NoMemory(); - } - (*func)(pickbuffer, pickbuffersize); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -endpick_select(long (*func)()) -{ - PyObject *v, *w; - int i, nhits, n; - if (pickbuffer == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "endpick/endselect: not in pick/select mode"); - return NULL; - } - nhits = (*func)(pickbuffer); - if (nhits < 0) { - nhits = -nhits; /* How to report buffer overflow otherwise? */ - } - /* Scan the buffer to see how many integers */ - n = 0; - for (; nhits > 0; nhits--) { - n += 1 + pickbuffer[n]; - } - v = PyList_New(n); - if (v == NULL) - return NULL; - /* XXX Could do it nicer and interpret the data structure here, - returning a list of lists. But this can be done in Python... */ - for (i = 0; i < n; i++) { - w = PyInt_FromLong((long)pickbuffer[i]); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyList_SetItem(v, i, w); - } - PyMem_DEL(pickbuffer); - pickbuffer = NULL; - return v; -} - -extern void pick(), gselect(); -extern long endpick(), endselect(); - -static PyObject *gl_pick(PyObject *self, PyObject *args) -{ - return pick_select(args, pick); -} - -static PyObject *gl_endpick(PyObject *self) -{ - return endpick_select(endpick); -} - -static PyObject *gl_gselect(PyObject *self, PyObject *args) -{ - return pick_select(args, gselect); -} - -static PyObject *gl_endselect(PyObject *self) -{ - return endpick_select(endselect); -} - - -/* XXX The generator botches this one. Here's a quick hack to fix it. */ - -/* XXX The generator botches this one. Here's a quick hack to fix it. */ - - -static PyObject * -gl_getmatrix(PyObject *self, PyObject *args) -{ - Matrix arg1; - PyObject *v, *w; - int i, j; - getmatrix( arg1 ); - v = PyList_New(16); - if (v == NULL) { - return PyErr_NoMemory(); - } - for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) { - w = mknewfloatobject(arg1[i][j]); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyList_SetItem(v, i*4+j, w); - } - return v; -} - -/* Here's an alternate version that returns a 4x4 matrix instead of - a vector. Unfortunately it is incompatible with loadmatrix and - multmatrix... */ - - -static PyObject * -gl_altgetmatrix(PyObject *self, PyObject *args) -{ - Matrix arg1; - PyObject *v, *w; - int i, j; - getmatrix( arg1 ); - v = PyList_New(4); - if (v == NULL) { - return NULL; - } - for (i = 0; i < 4; i++) { - w = PyList_New(4); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyList_SetItem(v, i, w); - } - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - w = mknewfloatobject(arg1[i][j]); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyList_SetItem(PyList_GetItem(v, i), j, w); - } - } - return v; -} - - -static PyObject * -gl_lrectwrite(PyObject *self, PyObject *args) -{ - short x1 ; - short y1 ; - short x2 ; - short y2 ; - string parray ; - PyObject *s; -#if 0 - int pixcount; -#endif - if (!PyArg_GetShort(args, 5, 0, &x1)) - return NULL; - if (!PyArg_GetShort(args, 5, 1, &y1)) - return NULL; - if (!PyArg_GetShort(args, 5, 2, &x2)) - return NULL; - if (!PyArg_GetShort(args, 5, 3, &y2)) - return NULL; - if (!PyArg_GetString(args, 5, 4, &parray)) - return NULL; - if (!PyArg_GetObject(args, 5, 4, &s)) - return NULL; -#if 0 -/* Don't check this, it breaks experiments with pixmode(PM_SIZE, ...) */ - pixcount = (long)(x2+1-x1) * (long)(y2+1-y1); - if (!PyString_Check(s) || PyString_Size(s) != pixcount*sizeof(long)) { - PyErr_SetString(PyExc_RuntimeError, - "string arg to lrectwrite has wrong size"); - return NULL; - } -#endif - lrectwrite( x1 , y1 , x2 , y2 , (unsigned long *) parray ); - Py_INCREF(Py_None); - return Py_None; -} - - -static PyObject * -gl_lrectread(PyObject *self, PyObject *args) -{ - short x1 ; - short y1 ; - short x2 ; - short y2 ; - PyObject *parray; - int pixcount; - if (!PyArg_GetShort(args, 4, 0, &x1)) - return NULL; - if (!PyArg_GetShort(args, 4, 1, &y1)) - return NULL; - if (!PyArg_GetShort(args, 4, 2, &x2)) - return NULL; - if (!PyArg_GetShort(args, 4, 3, &y2)) - return NULL; - pixcount = (long)(x2+1-x1) * (long)(y2+1-y1); - parray = PyString_FromStringAndSize((char *)NULL, pixcount*sizeof(long)); - if (parray == NULL) - return NULL; /* No memory */ - lrectread(x1, y1, x2, y2, (unsigned long *) PyString_AsString(parray)); - return parray; -} - - -static PyObject * -gl_readdisplay(PyObject *self, PyObject *args) -{ - short x1, y1, x2, y2; - unsigned long *parray, hints; - long size, size_ret; - PyObject *rv; - - if ( !PyArg_Parse(args, "hhhhl", &x1, &y1, &x2, &y2, &hints) ) - return 0; - size = (long)(x2+1-x1) * (long)(y2+1-y1); - rv = PyString_FromStringAndSize((char *)NULL, size*sizeof(long)); - if ( rv == NULL ) - return NULL; - parray = (unsigned long *)PyString_AsString(rv); - size_ret = readdisplay(x1, y1, x2, y2, parray, hints); - if ( size_ret != size ) { - printf("gl_readdisplay: got %ld pixels, expected %ld\n", - size_ret, size); - PyErr_SetString(PyExc_RuntimeError, "readdisplay returned unexpected length"); - return NULL; - } - return rv; -} - -/* Desperately needed, here are tools to compress and decompress - the data manipulated by lrectread/lrectwrite. - - gl.packrect(width, height, packfactor, bigdata) --> smalldata - makes 'bigdata' 4*(packfactor**2) times smaller by: - - turning it into B/W (a factor 4) - - replacing squares of size pacfactor by one - representative - - gl.unpackrect(width, height, packfactor, smalldata) --> bigdata - is the inverse; the numeric arguments must be *the same*. - - Both work best if width and height are multiples of packfactor - (in fact unpackrect will leave garbage bytes). -*/ - - -static PyObject * -gl_packrect(PyObject *self, PyObject *args) -{ - long width, height, packfactor; - char *s; - PyObject *unpacked, *packed; - int pixcount, packedcount, x, y, r, g, b; - unsigned long pixel; - unsigned char *p; - unsigned long *parray; - if (!PyArg_GetLong(args, 4, 0, &width)) - return NULL; - if (!PyArg_GetLong(args, 4, 1, &height)) - return NULL; - if (!PyArg_GetLong(args, 4, 2, &packfactor)) - return NULL; - if (!PyArg_GetString(args, 4, 3, &s)) /* For type checking only */ - return NULL; - if (!PyArg_GetObject(args, 4, 3, &unpacked)) - return NULL; - if (width <= 0 || height <= 0 || packfactor <= 0) { - PyErr_SetString(PyExc_RuntimeError, "packrect args must be > 0"); - return NULL; - } - pixcount = width*height; - packedcount = ((width+packfactor-1)/packfactor) * - ((height+packfactor-1)/packfactor); - if (PyString_Size(unpacked) != pixcount*sizeof(long)) { - PyErr_SetString(PyExc_RuntimeError, - "string arg to packrect has wrong size"); - return NULL; - } - packed = PyString_FromStringAndSize((char *)NULL, packedcount); - if (packed == NULL) - return NULL; - parray = (unsigned long *) PyString_AsString(unpacked); - p = (unsigned char *) PyString_AsString(packed); - for (y = 0; y < height; y += packfactor, parray += packfactor*width) { - for (x = 0; x < width; x += packfactor) { - pixel = parray[x]; - r = pixel & 0xff; - g = (pixel >> 8) & 0xff; - b = (pixel >> 16) & 0xff; - *p++ = (30*r+59*g+11*b) / 100; - } - } - return packed; -} - - -static unsigned long unpacktab[256]; -static int unpacktab_inited = 0; - -static PyObject * -gl_unpackrect(PyObject *self, PyObject *args) -{ - long width, height, packfactor; - char *s; - PyObject *unpacked, *packed; - int pixcount, packedcount; - register unsigned char *p; - register unsigned long *parray; - if (!unpacktab_inited) { - register int white; - for (white = 256; --white >= 0; ) - unpacktab[white] = white * 0x010101L; - unpacktab_inited++; - } - if (!PyArg_GetLong(args, 4, 0, &width)) - return NULL; - if (!PyArg_GetLong(args, 4, 1, &height)) - return NULL; - if (!PyArg_GetLong(args, 4, 2, &packfactor)) - return NULL; - if (!PyArg_GetString(args, 4, 3, &s)) /* For type checking only */ - return NULL; - if (!PyArg_GetObject(args, 4, 3, &packed)) - return NULL; - if (width <= 0 || height <= 0 || packfactor <= 0) { - PyErr_SetString(PyExc_RuntimeError, "packrect args must be > 0"); - return NULL; - } - pixcount = width*height; - packedcount = ((width+packfactor-1)/packfactor) * - ((height+packfactor-1)/packfactor); - if (PyString_Size(packed) != packedcount) { - PyErr_SetString(PyExc_RuntimeError, - "string arg to unpackrect has wrong size"); - return NULL; - } - unpacked = PyString_FromStringAndSize((char *)NULL, pixcount*sizeof(long)); - if (unpacked == NULL) - return NULL; - parray = (unsigned long *) PyString_AsString(unpacked); - p = (unsigned char *) PyString_AsString(packed); - if (packfactor == 1 && width*height > 0) { - /* Just expand bytes to longs */ - register int x = width * height; - do { - *parray++ = unpacktab[*p++]; - } while (--x >= 0); - } - else { - register int y; - for (y = 0; y < height-packfactor+1; - y += packfactor, parray += packfactor*width) { - register int x; - for (x = 0; x < width-packfactor+1; x += packfactor) { - register unsigned long pixel = unpacktab[*p++]; - register int i; - for (i = packfactor*width; (i-=width) >= 0;) { - register int j; - for (j = packfactor; --j >= 0; ) - parray[i+x+j] = pixel; - } - } - } - } - return unpacked; -} - -static PyObject * -gl_gversion(PyObject *self, PyObject *args) -{ - char buf[20]; - gversion(buf); - return PyString_FromString(buf); -} - - -/* void clear - Manual because of clash with termcap */ -static PyObject * -gl_clear(PyObject *self, PyObject *args) -{ - __GLclear( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* End of manually written stubs */ - - -/* long getshade */ - -static PyObject * -gl_getshade(PyObject *self, PyObject *args) -{ - long retval; - retval = getshade( ); - return mknewlongobject(retval); -} - -/* void devport short s long s */ - -static PyObject * -gl_devport(PyObject *self, PyObject *args) -{ - short arg1 ; - long arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - devport( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rdr2i long s long s */ - -static PyObject * -gl_rdr2i(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - rdr2i( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rectfs short s short s short s short s */ - -static PyObject * -gl_rectfs(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - if (!getishortarg(args, 4, 0, &arg1)) - return NULL; - if (!getishortarg(args, 4, 1, &arg2)) - return NULL; - if (!getishortarg(args, 4, 2, &arg3)) - return NULL; - if (!getishortarg(args, 4, 3, &arg4)) - return NULL; - rectfs( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rects short s short s short s short s */ - -static PyObject * -gl_rects(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - if (!getishortarg(args, 4, 0, &arg1)) - return NULL; - if (!getishortarg(args, 4, 1, &arg2)) - return NULL; - if (!getishortarg(args, 4, 2, &arg3)) - return NULL; - if (!getishortarg(args, 4, 3, &arg4)) - return NULL; - rects( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rmv2i long s long s */ - -static PyObject * -gl_rmv2i(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - rmv2i( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void noport */ - -static PyObject * -gl_noport(PyObject *self, PyObject *args) -{ - noport( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void popviewport */ - -static PyObject * -gl_popviewport(PyObject *self, PyObject *args) -{ - popviewport( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void clearhitcode */ - -static PyObject * -gl_clearhitcode(PyObject *self, PyObject *args) -{ - clearhitcode( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void closeobj */ - -static PyObject * -gl_closeobj(PyObject *self, PyObject *args) -{ - closeobj( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void cursoff */ - -static PyObject * -gl_cursoff(PyObject *self, PyObject *args) -{ - cursoff( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void curson */ - -static PyObject * -gl_curson(PyObject *self, PyObject *args) -{ - curson( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void doublebuffer */ - -static PyObject * -gl_doublebuffer(PyObject *self, PyObject *args) -{ - doublebuffer( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void finish */ - -static PyObject * -gl_finish(PyObject *self, PyObject *args) -{ - finish( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void gconfig */ - -static PyObject * -gl_gconfig(PyObject *self, PyObject *args) -{ - gconfig( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void ginit */ - -static PyObject * -gl_ginit(PyObject *self, PyObject *args) -{ - ginit( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void greset */ - -static PyObject * -gl_greset(PyObject *self, PyObject *args) -{ - greset( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void multimap */ - -static PyObject * -gl_multimap(PyObject *self, PyObject *args) -{ - multimap( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void onemap */ - -static PyObject * -gl_onemap(PyObject *self, PyObject *args) -{ - onemap( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void popattributes */ - -static PyObject * -gl_popattributes(PyObject *self, PyObject *args) -{ - popattributes( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void popmatrix */ - -static PyObject * -gl_popmatrix(PyObject *self, PyObject *args) -{ - popmatrix( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pushattributes */ - -static PyObject * -gl_pushattributes(PyObject *self, PyObject *args) -{ - pushattributes( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pushmatrix */ - -static PyObject * -gl_pushmatrix(PyObject *self, PyObject *args) -{ - pushmatrix( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pushviewport */ - -static PyObject * -gl_pushviewport(PyObject *self, PyObject *args) -{ - pushviewport( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void qreset */ - -static PyObject * -gl_qreset(PyObject *self, PyObject *args) -{ - qreset( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void RGBmode */ - -static PyObject * -gl_RGBmode(PyObject *self, PyObject *args) -{ - RGBmode( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void singlebuffer */ - -static PyObject * -gl_singlebuffer(PyObject *self, PyObject *args) -{ - singlebuffer( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void swapbuffers */ - -static PyObject * -gl_swapbuffers(PyObject *self, PyObject *args) -{ - swapbuffers( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void gsync */ - -static PyObject * -gl_gsync(PyObject *self, PyObject *args) -{ - gsync( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void gflush */ - -static PyObject * -gl_gflush(PyObject *self, PyObject *args) -{ - gflush( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void tpon */ - -static PyObject * -gl_tpon(PyObject *self, PyObject *args) -{ - tpon( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void tpoff */ - -static PyObject * -gl_tpoff(PyObject *self, PyObject *args) -{ - tpoff( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void clkon */ - -static PyObject * -gl_clkon(PyObject *self, PyObject *args) -{ - clkon( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void clkoff */ - -static PyObject * -gl_clkoff(PyObject *self, PyObject *args) -{ - clkoff( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void ringbell */ - -static PyObject * -gl_ringbell(PyObject *self, PyObject *args) -{ - ringbell( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void gbegin */ - -static PyObject * -gl_gbegin(PyObject *self, PyObject *args) -{ - gbegin( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void textinit */ - -static PyObject * -gl_textinit(PyObject *self, PyObject *args) -{ - textinit( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void initnames */ - -static PyObject * -gl_initnames(PyObject *self, PyObject *args) -{ - initnames( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pclos */ - -static PyObject * -gl_pclos(PyObject *self, PyObject *args) -{ - pclos( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void popname */ - -static PyObject * -gl_popname(PyObject *self, PyObject *args) -{ - popname( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void spclos */ - -static PyObject * -gl_spclos(PyObject *self, PyObject *args) -{ - spclos( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void zclear */ - -static PyObject * -gl_zclear(PyObject *self, PyObject *args) -{ - zclear( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void screenspace */ - -static PyObject * -gl_screenspace(PyObject *self, PyObject *args) -{ - screenspace( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void reshapeviewport */ - -static PyObject * -gl_reshapeviewport(PyObject *self, PyObject *args) -{ - reshapeviewport( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void winpush */ - -static PyObject * -gl_winpush(PyObject *self, PyObject *args) -{ - winpush( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void winpop */ - -static PyObject * -gl_winpop(PyObject *self, PyObject *args) -{ - winpop( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void foreground */ - -static PyObject * -gl_foreground(PyObject *self, PyObject *args) -{ - foreground( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void endfullscrn */ - -static PyObject * -gl_endfullscrn(PyObject *self, PyObject *args) -{ - endfullscrn( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void endpupmode */ - -static PyObject * -gl_endpupmode(PyObject *self, PyObject *args) -{ - endpupmode( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void fullscrn */ - -static PyObject * -gl_fullscrn(PyObject *self, PyObject *args) -{ - fullscrn( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pupmode */ - -static PyObject * -gl_pupmode(PyObject *self, PyObject *args) -{ - pupmode( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void winconstraints */ - -static PyObject * -gl_winconstraints(PyObject *self, PyObject *args) -{ - winconstraints( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pagecolor short s */ - -static PyObject * -gl_pagecolor(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - pagecolor( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void textcolor short s */ - -static PyObject * -gl_textcolor(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - textcolor( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void color short s */ - -static PyObject * -gl_color(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - color( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void curveit short s */ - -static PyObject * -gl_curveit(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - curveit( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void font short s */ - -static PyObject * -gl_font(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - font( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void linewidth short s */ - -static PyObject * -gl_linewidth(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - linewidth( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void setlinestyle short s */ - -static PyObject * -gl_setlinestyle(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - setlinestyle( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void setmap short s */ - -static PyObject * -gl_setmap(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - setmap( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void swapinterval short s */ - -static PyObject * -gl_swapinterval(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - swapinterval( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void writemask short s */ - -static PyObject * -gl_writemask(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - writemask( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void textwritemask short s */ - -static PyObject * -gl_textwritemask(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - textwritemask( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void qdevice short s */ - -static PyObject * -gl_qdevice(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - qdevice( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void unqdevice short s */ - -static PyObject * -gl_unqdevice(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - unqdevice( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void curvebasis short s */ - -static PyObject * -gl_curvebasis(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - curvebasis( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void curveprecision short s */ - -static PyObject * -gl_curveprecision(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - curveprecision( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void loadname short s */ - -static PyObject * -gl_loadname(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - loadname( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void passthrough short s */ - -static PyObject * -gl_passthrough(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - passthrough( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pushname short s */ - -static PyObject * -gl_pushname(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - pushname( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void setmonitor short s */ - -static PyObject * -gl_setmonitor(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - setmonitor( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void setshade short s */ - -static PyObject * -gl_setshade(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - setshade( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void setpattern short s */ - -static PyObject * -gl_setpattern(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - setpattern( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pagewritemask short s */ - -static PyObject * -gl_pagewritemask(PyObject *self, PyObject *args) -{ - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - pagewritemask( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void callobj long s */ - -static PyObject * -gl_callobj(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - callobj( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void delobj long s */ - -static PyObject * -gl_delobj(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - delobj( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void editobj long s */ - -static PyObject * -gl_editobj(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - editobj( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void makeobj long s */ - -static PyObject * -gl_makeobj(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - makeobj( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void maketag long s */ - -static PyObject * -gl_maketag(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - maketag( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void chunksize long s */ - -static PyObject * -gl_chunksize(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - chunksize( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void compactify long s */ - -static PyObject * -gl_compactify(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - compactify( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void deltag long s */ - -static PyObject * -gl_deltag(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - deltag( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void lsrepeat long s */ - -static PyObject * -gl_lsrepeat(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - lsrepeat( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void objinsert long s */ - -static PyObject * -gl_objinsert(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - objinsert( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void objreplace long s */ - -static PyObject * -gl_objreplace(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - objreplace( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void winclose long s */ - -static PyObject * -gl_winclose(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - winclose( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void blanktime long s */ - -static PyObject * -gl_blanktime(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - blanktime( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void freepup long s */ - -static PyObject * -gl_freepup(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - freepup( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void backbuffer long s */ - -static PyObject * -gl_backbuffer(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - backbuffer( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void frontbuffer long s */ - -static PyObject * -gl_frontbuffer(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - frontbuffer( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void lsbackup long s */ - -static PyObject * -gl_lsbackup(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - lsbackup( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void resetls long s */ - -static PyObject * -gl_resetls(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - resetls( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void lampon long s */ - -static PyObject * -gl_lampon(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - lampon( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void lampoff long s */ - -static PyObject * -gl_lampoff(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - lampoff( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void setbell long s */ - -static PyObject * -gl_setbell(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - setbell( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void blankscreen long s */ - -static PyObject * -gl_blankscreen(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - blankscreen( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void depthcue long s */ - -static PyObject * -gl_depthcue(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - depthcue( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void zbuffer long s */ - -static PyObject * -gl_zbuffer(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - zbuffer( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void backface long s */ - -static PyObject * -gl_backface(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - backface( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void cmov2i long s long s */ - -static PyObject * -gl_cmov2i(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - cmov2i( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void draw2i long s long s */ - -static PyObject * -gl_draw2i(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - draw2i( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void move2i long s long s */ - -static PyObject * -gl_move2i(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - move2i( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pnt2i long s long s */ - -static PyObject * -gl_pnt2i(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - pnt2i( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void patchbasis long s long s */ - -static PyObject * -gl_patchbasis(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - patchbasis( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void patchprecision long s long s */ - -static PyObject * -gl_patchprecision(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - patchprecision( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pdr2i long s long s */ - -static PyObject * -gl_pdr2i(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - pdr2i( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pmv2i long s long s */ - -static PyObject * -gl_pmv2i(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - pmv2i( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rpdr2i long s long s */ - -static PyObject * -gl_rpdr2i(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - rpdr2i( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rpmv2i long s long s */ - -static PyObject * -gl_rpmv2i(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - rpmv2i( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void xfpt2i long s long s */ - -static PyObject * -gl_xfpt2i(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - xfpt2i( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void objdelete long s long s */ - -static PyObject * -gl_objdelete(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - objdelete( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void patchcurves long s long s */ - -static PyObject * -gl_patchcurves(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - patchcurves( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void minsize long s long s */ - -static PyObject * -gl_minsize(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - minsize( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void maxsize long s long s */ - -static PyObject * -gl_maxsize(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - maxsize( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void keepaspect long s long s */ - -static PyObject * -gl_keepaspect(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - keepaspect( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void prefsize long s long s */ - -static PyObject * -gl_prefsize(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - prefsize( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void stepunit long s long s */ - -static PyObject * -gl_stepunit(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - stepunit( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void fudge long s long s */ - -static PyObject * -gl_fudge(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - fudge( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void winmove long s long s */ - -static PyObject * -gl_winmove(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - winmove( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void attachcursor short s short s */ - -static PyObject * -gl_attachcursor(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - attachcursor( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void deflinestyle short s short s */ - -static PyObject * -gl_deflinestyle(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - deflinestyle( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void noise short s short s */ - -static PyObject * -gl_noise(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - noise( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void picksize short s short s */ - -static PyObject * -gl_picksize(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - picksize( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void qenter short s short s */ - -static PyObject * -gl_qenter(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - qenter( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void setdepth short s short s */ - -static PyObject * -gl_setdepth(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - setdepth( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void cmov2s short s short s */ - -static PyObject * -gl_cmov2s(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - cmov2s( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void draw2s short s short s */ - -static PyObject * -gl_draw2s(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - draw2s( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void move2s short s short s */ - -static PyObject * -gl_move2s(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - move2s( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pdr2s short s short s */ - -static PyObject * -gl_pdr2s(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - pdr2s( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pmv2s short s short s */ - -static PyObject * -gl_pmv2s(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - pmv2s( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pnt2s short s short s */ - -static PyObject * -gl_pnt2s(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - pnt2s( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rdr2s short s short s */ - -static PyObject * -gl_rdr2s(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - rdr2s( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rmv2s short s short s */ - -static PyObject * -gl_rmv2s(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - rmv2s( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rpdr2s short s short s */ - -static PyObject * -gl_rpdr2s(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - rpdr2s( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rpmv2s short s short s */ - -static PyObject * -gl_rpmv2s(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - rpmv2s( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void xfpt2s short s short s */ - -static PyObject * -gl_xfpt2s(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - xfpt2s( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void cmov2 float s float s */ - -static PyObject * -gl_cmov2(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - if (!getifloatarg(args, 2, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 2, 1, &arg2)) - return NULL; - cmov2( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void draw2 float s float s */ - -static PyObject * -gl_draw2(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - if (!getifloatarg(args, 2, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 2, 1, &arg2)) - return NULL; - draw2( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void move2 float s float s */ - -static PyObject * -gl_move2(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - if (!getifloatarg(args, 2, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 2, 1, &arg2)) - return NULL; - move2( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pnt2 float s float s */ - -static PyObject * -gl_pnt2(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - if (!getifloatarg(args, 2, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 2, 1, &arg2)) - return NULL; - pnt2( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pdr2 float s float s */ - -static PyObject * -gl_pdr2(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - if (!getifloatarg(args, 2, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 2, 1, &arg2)) - return NULL; - pdr2( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pmv2 float s float s */ - -static PyObject * -gl_pmv2(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - if (!getifloatarg(args, 2, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 2, 1, &arg2)) - return NULL; - pmv2( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rdr2 float s float s */ - -static PyObject * -gl_rdr2(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - if (!getifloatarg(args, 2, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 2, 1, &arg2)) - return NULL; - rdr2( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rmv2 float s float s */ - -static PyObject * -gl_rmv2(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - if (!getifloatarg(args, 2, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 2, 1, &arg2)) - return NULL; - rmv2( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rpdr2 float s float s */ - -static PyObject * -gl_rpdr2(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - if (!getifloatarg(args, 2, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 2, 1, &arg2)) - return NULL; - rpdr2( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rpmv2 float s float s */ - -static PyObject * -gl_rpmv2(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - if (!getifloatarg(args, 2, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 2, 1, &arg2)) - return NULL; - rpmv2( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void xfpt2 float s float s */ - -static PyObject * -gl_xfpt2(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - if (!getifloatarg(args, 2, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 2, 1, &arg2)) - return NULL; - xfpt2( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void loadmatrix float s[4*4] */ - -static PyObject * -gl_loadmatrix(PyObject *self, PyObject *args) -{ - float arg1 [ 4 ] [ 4 ] ; - if (!getifloatarray(args, 1, 0, 4 * 4 , (float *) arg1)) - return NULL; - loadmatrix( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void multmatrix float s[4*4] */ - -static PyObject * -gl_multmatrix(PyObject *self, PyObject *args) -{ - float arg1 [ 4 ] [ 4 ] ; - if (!getifloatarray(args, 1, 0, 4 * 4 , (float *) arg1)) - return NULL; - multmatrix( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void crv float s[3*4] */ - -static PyObject * -gl_crv(PyObject *self, PyObject *args) -{ - float arg1 [ 4 ] [ 3 ] ; - if (!getifloatarray(args, 1, 0, 3 * 4 , (float *) arg1)) - return NULL; - crv( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rcrv float s[4*4] */ - -static PyObject * -gl_rcrv(PyObject *self, PyObject *args) -{ - float arg1 [ 4 ] [ 4 ] ; - if (!getifloatarray(args, 1, 0, 4 * 4 , (float *) arg1)) - return NULL; - rcrv( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void addtopup long s char *s long s */ - -static PyObject * -gl_addtopup(PyObject *self, PyObject *args) -{ - long arg1 ; - string arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getistringarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - addtopup( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void charstr char *s */ - -static PyObject * -gl_charstr(PyObject *self, PyObject *args) -{ - string arg1 ; - if (!getistringarg(args, 1, 0, &arg1)) - return NULL; - charstr( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void getport char *s */ - -static PyObject * -gl_getport(PyObject *self, PyObject *args) -{ - string arg1 ; - if (!getistringarg(args, 1, 0, &arg1)) - return NULL; - getport( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* long strwidth char *s */ - -static PyObject * -gl_strwidth(PyObject *self, PyObject *args) -{ - long retval; - string arg1 ; - if (!getistringarg(args, 1, 0, &arg1)) - return NULL; - retval = strwidth( arg1 ); - return mknewlongobject(retval); -} - -/* long winopen char *s */ - -static PyObject * -gl_winopen(PyObject *self, PyObject *args) -{ - long retval; - string arg1 ; - if (!getistringarg(args, 1, 0, &arg1)) - return NULL; - retval = winopen( arg1 ); - return mknewlongobject(retval); -} - -/* void wintitle char *s */ - -static PyObject * -gl_wintitle(PyObject *self, PyObject *args) -{ - string arg1 ; - if (!getistringarg(args, 1, 0, &arg1)) - return NULL; - wintitle( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void polf long s float s[3*arg1] */ - -static PyObject * -gl_polf(PyObject *self, PyObject *args) -{ - long arg1 ; - float (* arg2) [ 3 ] ; - if (!getilongarraysize(args, 1, 0, &arg1)) - return NULL; - arg1 = arg1 / 3; - if ((arg2 = (float(*)[3]) PyMem_NEW(float , 3 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getifloatarray(args, 1, 0, 3 * arg1 , (float *) arg2)) - return NULL; - polf( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void polf2 long s float s[2*arg1] */ - -static PyObject * -gl_polf2(PyObject *self, PyObject *args) -{ - long arg1 ; - float (* arg2) [ 2 ] ; - if (!getilongarraysize(args, 1, 0, &arg1)) - return NULL; - arg1 = arg1 / 2; - if ((arg2 = (float(*)[2]) PyMem_NEW(float , 2 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getifloatarray(args, 1, 0, 2 * arg1 , (float *) arg2)) - return NULL; - polf2( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void poly long s float s[3*arg1] */ - -static PyObject * -gl_poly(PyObject *self, PyObject *args) -{ - long arg1 ; - float (* arg2) [ 3 ] ; - if (!getilongarraysize(args, 1, 0, &arg1)) - return NULL; - arg1 = arg1 / 3; - if ((arg2 = (float(*)[3]) PyMem_NEW(float , 3 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getifloatarray(args, 1, 0, 3 * arg1 , (float *) arg2)) - return NULL; - poly( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void poly2 long s float s[2*arg1] */ - -static PyObject * -gl_poly2(PyObject *self, PyObject *args) -{ - long arg1 ; - float (* arg2) [ 2 ] ; - if (!getilongarraysize(args, 1, 0, &arg1)) - return NULL; - arg1 = arg1 / 2; - if ((arg2 = (float(*)[2]) PyMem_NEW(float , 2 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getifloatarray(args, 1, 0, 2 * arg1 , (float *) arg2)) - return NULL; - poly2( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void crvn long s float s[3*arg1] */ - -static PyObject * -gl_crvn(PyObject *self, PyObject *args) -{ - long arg1 ; - float (* arg2) [ 3 ] ; - if (!getilongarraysize(args, 1, 0, &arg1)) - return NULL; - arg1 = arg1 / 3; - if ((arg2 = (float(*)[3]) PyMem_NEW(float , 3 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getifloatarray(args, 1, 0, 3 * arg1 , (float *) arg2)) - return NULL; - crvn( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rcrvn long s float s[4*arg1] */ - -static PyObject * -gl_rcrvn(PyObject *self, PyObject *args) -{ - long arg1 ; - float (* arg2) [ 4 ] ; - if (!getilongarraysize(args, 1, 0, &arg1)) - return NULL; - arg1 = arg1 / 4; - if ((arg2 = (float(*)[4]) PyMem_NEW(float , 4 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getifloatarray(args, 1, 0, 4 * arg1 , (float *) arg2)) - return NULL; - rcrvn( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void polf2i long s long s[2*arg1] */ - -static PyObject * -gl_polf2i(PyObject *self, PyObject *args) -{ - long arg1 ; - long (* arg2) [ 2 ] ; - if (!getilongarraysize(args, 1, 0, &arg1)) - return NULL; - arg1 = arg1 / 2; - if ((arg2 = (long(*)[2]) PyMem_NEW(long , 2 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getilongarray(args, 1, 0, 2 * arg1 , (long *) arg2)) - return NULL; - polf2i( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void polfi long s long s[3*arg1] */ - -static PyObject * -gl_polfi(PyObject *self, PyObject *args) -{ - long arg1 ; - long (* arg2) [ 3 ] ; - if (!getilongarraysize(args, 1, 0, &arg1)) - return NULL; - arg1 = arg1 / 3; - if ((arg2 = (long(*)[3]) PyMem_NEW(long , 3 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getilongarray(args, 1, 0, 3 * arg1 , (long *) arg2)) - return NULL; - polfi( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void poly2i long s long s[2*arg1] */ - -static PyObject * -gl_poly2i(PyObject *self, PyObject *args) -{ - long arg1 ; - long (* arg2) [ 2 ] ; - if (!getilongarraysize(args, 1, 0, &arg1)) - return NULL; - arg1 = arg1 / 2; - if ((arg2 = (long(*)[2]) PyMem_NEW(long , 2 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getilongarray(args, 1, 0, 2 * arg1 , (long *) arg2)) - return NULL; - poly2i( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void polyi long s long s[3*arg1] */ - -static PyObject * -gl_polyi(PyObject *self, PyObject *args) -{ - long arg1 ; - long (* arg2) [ 3 ] ; - if (!getilongarraysize(args, 1, 0, &arg1)) - return NULL; - arg1 = arg1 / 3; - if ((arg2 = (long(*)[3]) PyMem_NEW(long , 3 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getilongarray(args, 1, 0, 3 * arg1 , (long *) arg2)) - return NULL; - polyi( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void polf2s long s short s[2*arg1] */ - -static PyObject * -gl_polf2s(PyObject *self, PyObject *args) -{ - long arg1 ; - short (* arg2) [ 2 ] ; - if (!getilongarraysize(args, 1, 0, &arg1)) - return NULL; - arg1 = arg1 / 2; - if ((arg2 = (short(*)[2]) PyMem_NEW(short , 2 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getishortarray(args, 1, 0, 2 * arg1 , (short *) arg2)) - return NULL; - polf2s( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void polfs long s short s[3*arg1] */ - -static PyObject * -gl_polfs(PyObject *self, PyObject *args) -{ - long arg1 ; - short (* arg2) [ 3 ] ; - if (!getilongarraysize(args, 1, 0, &arg1)) - return NULL; - arg1 = arg1 / 3; - if ((arg2 = (short(*)[3]) PyMem_NEW(short , 3 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getishortarray(args, 1, 0, 3 * arg1 , (short *) arg2)) - return NULL; - polfs( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void polys long s short s[3*arg1] */ - -static PyObject * -gl_polys(PyObject *self, PyObject *args) -{ - long arg1 ; - short (* arg2) [ 3 ] ; - if (!getilongarraysize(args, 1, 0, &arg1)) - return NULL; - arg1 = arg1 / 3; - if ((arg2 = (short(*)[3]) PyMem_NEW(short , 3 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getishortarray(args, 1, 0, 3 * arg1 , (short *) arg2)) - return NULL; - polys( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void poly2s long s short s[2*arg1] */ - -static PyObject * -gl_poly2s(PyObject *self, PyObject *args) -{ - long arg1 ; - short (* arg2) [ 2 ] ; - if (!getilongarraysize(args, 1, 0, &arg1)) - return NULL; - arg1 = arg1 / 2; - if ((arg2 = (short(*)[2]) PyMem_NEW(short , 2 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getishortarray(args, 1, 0, 2 * arg1 , (short *) arg2)) - return NULL; - poly2s( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void defcursor short s u_short s[128] */ - -static PyObject * -gl_defcursor(PyObject *self, PyObject *args) -{ - short arg1 ; - unsigned short arg2 [ 128 ] ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarray(args, 2, 1, 128 , (short *) arg2)) - return NULL; - defcursor( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void writepixels short s u_short s[arg1] */ - -static PyObject * -gl_writepixels(PyObject *self, PyObject *args) -{ - short arg1 ; - unsigned short * arg2 ; - if (!getishortarraysize(args, 1, 0, &arg1)) - return NULL; - if ((arg2 = PyMem_NEW(unsigned short , arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getishortarray(args, 1, 0, arg1 , (short *) arg2)) - return NULL; - writepixels( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void defbasis long s float s[4*4] */ - -static PyObject * -gl_defbasis(PyObject *self, PyObject *args) -{ - long arg1 ; - float arg2 [ 4 ] [ 4 ] ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getifloatarray(args, 2, 1, 4 * 4 , (float *) arg2)) - return NULL; - defbasis( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void gewrite short s short s[arg1] */ - -static PyObject * -gl_gewrite(PyObject *self, PyObject *args) -{ - short arg1 ; - short * arg2 ; - if (!getishortarraysize(args, 1, 0, &arg1)) - return NULL; - if ((arg2 = PyMem_NEW(short , arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getishortarray(args, 1, 0, arg1 , arg2)) - return NULL; - gewrite( arg1 , arg2 ); - PyMem_DEL(arg2); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rotate short s char s */ - -static PyObject * -gl_rotate(PyObject *self, PyObject *args) -{ - short arg1 ; - char arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getichararg(args, 2, 1, &arg2)) - return NULL; - rotate( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rot float s char s */ - -static PyObject * -gl_rot(PyObject *self, PyObject *args) -{ - float arg1 ; - char arg2 ; - if (!getifloatarg(args, 2, 0, &arg1)) - return NULL; - if (!getichararg(args, 2, 1, &arg2)) - return NULL; - rot( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void circfi long s long s long s */ - -static PyObject * -gl_circfi(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - circfi( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void circi long s long s long s */ - -static PyObject * -gl_circi(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - circi( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void cmovi long s long s long s */ - -static PyObject * -gl_cmovi(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - cmovi( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void drawi long s long s long s */ - -static PyObject * -gl_drawi(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - drawi( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void movei long s long s long s */ - -static PyObject * -gl_movei(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - movei( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pnti long s long s long s */ - -static PyObject * -gl_pnti(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - pnti( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void newtag long s long s long s */ - -static PyObject * -gl_newtag(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - newtag( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pdri long s long s long s */ - -static PyObject * -gl_pdri(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - pdri( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pmvi long s long s long s */ - -static PyObject * -gl_pmvi(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - pmvi( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rdri long s long s long s */ - -static PyObject * -gl_rdri(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - rdri( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rmvi long s long s long s */ - -static PyObject * -gl_rmvi(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - rmvi( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rpdri long s long s long s */ - -static PyObject * -gl_rpdri(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - rpdri( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rpmvi long s long s long s */ - -static PyObject * -gl_rpmvi(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - rpmvi( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void xfpti long s long s long s */ - -static PyObject * -gl_xfpti(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - xfpti( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void circ float s float s float s */ - -static PyObject * -gl_circ(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - circ( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void circf float s float s float s */ - -static PyObject * -gl_circf(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - circf( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void cmov float s float s float s */ - -static PyObject * -gl_cmov(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - cmov( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void draw float s float s float s */ - -static PyObject * -gl_draw(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - draw( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void move float s float s float s */ - -static PyObject * -gl_move(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - move( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pnt float s float s float s */ - -static PyObject * -gl_pnt(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - pnt( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void scale float s float s float s */ - -static PyObject * -gl_scale(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - scale( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void translate float s float s float s */ - -static PyObject * -gl_translate(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - translate( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pdr float s float s float s */ - -static PyObject * -gl_pdr(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - pdr( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pmv float s float s float s */ - -static PyObject * -gl_pmv(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - pmv( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rdr float s float s float s */ - -static PyObject * -gl_rdr(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - rdr( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rmv float s float s float s */ - -static PyObject * -gl_rmv(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - rmv( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rpdr float s float s float s */ - -static PyObject * -gl_rpdr(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - rpdr( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rpmv float s float s float s */ - -static PyObject * -gl_rpmv(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - rpmv( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void xfpt float s float s float s */ - -static PyObject * -gl_xfpt(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - if (!getifloatarg(args, 3, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 3, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 3, 2, &arg3)) - return NULL; - xfpt( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void RGBcolor short s short s short s */ - -static PyObject * -gl_RGBcolor(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - RGBcolor( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void RGBwritemask short s short s short s */ - -static PyObject * -gl_RGBwritemask(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - RGBwritemask( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void setcursor short s short s short s */ - -static PyObject * -gl_setcursor(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - setcursor( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void tie short s short s short s */ - -static PyObject * -gl_tie(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - tie( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void circfs short s short s short s */ - -static PyObject * -gl_circfs(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - circfs( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void circs short s short s short s */ - -static PyObject * -gl_circs(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - circs( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void cmovs short s short s short s */ - -static PyObject * -gl_cmovs(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - cmovs( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void draws short s short s short s */ - -static PyObject * -gl_draws(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - draws( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void moves short s short s short s */ - -static PyObject * -gl_moves(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - moves( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pdrs short s short s short s */ - -static PyObject * -gl_pdrs(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - pdrs( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pmvs short s short s short s */ - -static PyObject * -gl_pmvs(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - pmvs( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pnts short s short s short s */ - -static PyObject * -gl_pnts(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - pnts( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rdrs short s short s short s */ - -static PyObject * -gl_rdrs(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - rdrs( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rmvs short s short s short s */ - -static PyObject * -gl_rmvs(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - rmvs( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rpdrs short s short s short s */ - -static PyObject * -gl_rpdrs(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - rpdrs( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rpmvs short s short s short s */ - -static PyObject * -gl_rpmvs(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - rpmvs( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void xfpts short s short s short s */ - -static PyObject * -gl_xfpts(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - xfpts( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void curorigin short s short s short s */ - -static PyObject * -gl_curorigin(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - curorigin( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void cyclemap short s short s short s */ - -static PyObject * -gl_cyclemap(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - if (!getishortarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - cyclemap( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void patch float s[4*4] float s[4*4] float s[4*4] */ - -static PyObject * -gl_patch(PyObject *self, PyObject *args) -{ - float arg1 [ 4 ] [ 4 ] ; - float arg2 [ 4 ] [ 4 ] ; - float arg3 [ 4 ] [ 4 ] ; - if (!getifloatarray(args, 3, 0, 4 * 4 , (float *) arg1)) - return NULL; - if (!getifloatarray(args, 3, 1, 4 * 4 , (float *) arg2)) - return NULL; - if (!getifloatarray(args, 3, 2, 4 * 4 , (float *) arg3)) - return NULL; - patch( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void splf long s float s[3*arg1] u_short s[arg1] */ - -static PyObject * -gl_splf(PyObject *self, PyObject *args) -{ - long arg1 ; - float (* arg2) [ 3 ] ; - unsigned short * arg3 ; - if (!getilongarraysize(args, 2, 0, &arg1)) - return NULL; - arg1 = arg1 / 3; - if ((arg2 = (float(*)[3]) PyMem_NEW(float , 3 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getifloatarray(args, 2, 0, 3 * arg1 , (float *) arg2)) - return NULL; - if ((arg3 = PyMem_NEW(unsigned short , arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getishortarray(args, 2, 1, arg1 , (short *) arg3)) - return NULL; - splf( arg1 , arg2 , arg3 ); - PyMem_DEL(arg2); - PyMem_DEL(arg3); - Py_INCREF(Py_None); - return Py_None; -} - -/* void splf2 long s float s[2*arg1] u_short s[arg1] */ - -static PyObject * -gl_splf2(PyObject *self, PyObject *args) -{ - long arg1 ; - float (* arg2) [ 2 ] ; - unsigned short * arg3 ; - if (!getilongarraysize(args, 2, 0, &arg1)) - return NULL; - arg1 = arg1 / 2; - if ((arg2 = (float(*)[2]) PyMem_NEW(float , 2 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getifloatarray(args, 2, 0, 2 * arg1 , (float *) arg2)) - return NULL; - if ((arg3 = PyMem_NEW(unsigned short , arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getishortarray(args, 2, 1, arg1 , (short *) arg3)) - return NULL; - splf2( arg1 , arg2 , arg3 ); - PyMem_DEL(arg2); - PyMem_DEL(arg3); - Py_INCREF(Py_None); - return Py_None; -} - -/* void splfi long s long s[3*arg1] u_short s[arg1] */ - -static PyObject * -gl_splfi(PyObject *self, PyObject *args) -{ - long arg1 ; - long (* arg2) [ 3 ] ; - unsigned short * arg3 ; - if (!getilongarraysize(args, 2, 0, &arg1)) - return NULL; - arg1 = arg1 / 3; - if ((arg2 = (long(*)[3]) PyMem_NEW(long , 3 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getilongarray(args, 2, 0, 3 * arg1 , (long *) arg2)) - return NULL; - if ((arg3 = PyMem_NEW(unsigned short , arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getishortarray(args, 2, 1, arg1 , (short *) arg3)) - return NULL; - splfi( arg1 , arg2 , arg3 ); - PyMem_DEL(arg2); - PyMem_DEL(arg3); - Py_INCREF(Py_None); - return Py_None; -} - -/* void splf2i long s long s[2*arg1] u_short s[arg1] */ - -static PyObject * -gl_splf2i(PyObject *self, PyObject *args) -{ - long arg1 ; - long (* arg2) [ 2 ] ; - unsigned short * arg3 ; - if (!getilongarraysize(args, 2, 0, &arg1)) - return NULL; - arg1 = arg1 / 2; - if ((arg2 = (long(*)[2]) PyMem_NEW(long , 2 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getilongarray(args, 2, 0, 2 * arg1 , (long *) arg2)) - return NULL; - if ((arg3 = PyMem_NEW(unsigned short , arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getishortarray(args, 2, 1, arg1 , (short *) arg3)) - return NULL; - splf2i( arg1 , arg2 , arg3 ); - PyMem_DEL(arg2); - PyMem_DEL(arg3); - Py_INCREF(Py_None); - return Py_None; -} - -/* void splfs long s short s[3*arg1] u_short s[arg1] */ - -static PyObject * -gl_splfs(PyObject *self, PyObject *args) -{ - long arg1 ; - short (* arg2) [ 3 ] ; - unsigned short * arg3 ; - if (!getilongarraysize(args, 2, 0, &arg1)) - return NULL; - arg1 = arg1 / 3; - if ((arg2 = (short(*)[3]) PyMem_NEW(short , 3 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getishortarray(args, 2, 0, 3 * arg1 , (short *) arg2)) - return NULL; - if ((arg3 = PyMem_NEW(unsigned short , arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getishortarray(args, 2, 1, arg1 , (short *) arg3)) - return NULL; - splfs( arg1 , arg2 , arg3 ); - PyMem_DEL(arg2); - PyMem_DEL(arg3); - Py_INCREF(Py_None); - return Py_None; -} - -/* void splf2s long s short s[2*arg1] u_short s[arg1] */ - -static PyObject * -gl_splf2s(PyObject *self, PyObject *args) -{ - long arg1 ; - short (* arg2) [ 2 ] ; - unsigned short * arg3 ; - if (!getilongarraysize(args, 2, 0, &arg1)) - return NULL; - arg1 = arg1 / 2; - if ((arg2 = (short(*)[2]) PyMem_NEW(short , 2 * arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getishortarray(args, 2, 0, 2 * arg1 , (short *) arg2)) - return NULL; - if ((arg3 = PyMem_NEW(unsigned short , arg1 )) == NULL) - return PyErr_NoMemory(); - if (!getishortarray(args, 2, 1, arg1 , (short *) arg3)) - return NULL; - splf2s( arg1 , arg2 , arg3 ); - PyMem_DEL(arg2); - PyMem_DEL(arg3); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rpatch float s[4*4] float s[4*4] float s[4*4] float s[4*4] */ - -static PyObject * -gl_rpatch(PyObject *self, PyObject *args) -{ - float arg1 [ 4 ] [ 4 ] ; - float arg2 [ 4 ] [ 4 ] ; - float arg3 [ 4 ] [ 4 ] ; - float arg4 [ 4 ] [ 4 ] ; - if (!getifloatarray(args, 4, 0, 4 * 4 , (float *) arg1)) - return NULL; - if (!getifloatarray(args, 4, 1, 4 * 4 , (float *) arg2)) - return NULL; - if (!getifloatarray(args, 4, 2, 4 * 4 , (float *) arg3)) - return NULL; - if (!getifloatarray(args, 4, 3, 4 * 4 , (float *) arg4)) - return NULL; - rpatch( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void ortho2 float s float s float s float s */ - -static PyObject * -gl_ortho2(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - float arg4 ; - if (!getifloatarg(args, 4, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 4, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 4, 2, &arg3)) - return NULL; - if (!getifloatarg(args, 4, 3, &arg4)) - return NULL; - ortho2( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rect float s float s float s float s */ - -static PyObject * -gl_rect(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - float arg4 ; - if (!getifloatarg(args, 4, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 4, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 4, 2, &arg3)) - return NULL; - if (!getifloatarg(args, 4, 3, &arg4)) - return NULL; - rect( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rectf float s float s float s float s */ - -static PyObject * -gl_rectf(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - float arg4 ; - if (!getifloatarg(args, 4, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 4, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 4, 2, &arg3)) - return NULL; - if (!getifloatarg(args, 4, 3, &arg4)) - return NULL; - rectf( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void xfpt4 float s float s float s float s */ - -static PyObject * -gl_xfpt4(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - float arg4 ; - if (!getifloatarg(args, 4, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 4, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 4, 2, &arg3)) - return NULL; - if (!getifloatarg(args, 4, 3, &arg4)) - return NULL; - xfpt4( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void textport short s short s short s short s */ - -static PyObject * -gl_textport(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - if (!getishortarg(args, 4, 0, &arg1)) - return NULL; - if (!getishortarg(args, 4, 1, &arg2)) - return NULL; - if (!getishortarg(args, 4, 2, &arg3)) - return NULL; - if (!getishortarg(args, 4, 3, &arg4)) - return NULL; - textport( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void mapcolor short s short s short s short s */ - -static PyObject * -gl_mapcolor(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - if (!getishortarg(args, 4, 0, &arg1)) - return NULL; - if (!getishortarg(args, 4, 1, &arg2)) - return NULL; - if (!getishortarg(args, 4, 2, &arg3)) - return NULL; - if (!getishortarg(args, 4, 3, &arg4)) - return NULL; - mapcolor( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void scrmask short s short s short s short s */ - -static PyObject * -gl_scrmask(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - if (!getishortarg(args, 4, 0, &arg1)) - return NULL; - if (!getishortarg(args, 4, 1, &arg2)) - return NULL; - if (!getishortarg(args, 4, 2, &arg3)) - return NULL; - if (!getishortarg(args, 4, 3, &arg4)) - return NULL; - scrmask( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void setvaluator short s short s short s short s */ - -static PyObject * -gl_setvaluator(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - if (!getishortarg(args, 4, 0, &arg1)) - return NULL; - if (!getishortarg(args, 4, 1, &arg2)) - return NULL; - if (!getishortarg(args, 4, 2, &arg3)) - return NULL; - if (!getishortarg(args, 4, 3, &arg4)) - return NULL; - setvaluator( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void viewport short s short s short s short s */ - -static PyObject * -gl_viewport(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - if (!getishortarg(args, 4, 0, &arg1)) - return NULL; - if (!getishortarg(args, 4, 1, &arg2)) - return NULL; - if (!getishortarg(args, 4, 2, &arg3)) - return NULL; - if (!getishortarg(args, 4, 3, &arg4)) - return NULL; - viewport( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void shaderange short s short s short s short s */ - -static PyObject * -gl_shaderange(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - if (!getishortarg(args, 4, 0, &arg1)) - return NULL; - if (!getishortarg(args, 4, 1, &arg2)) - return NULL; - if (!getishortarg(args, 4, 2, &arg3)) - return NULL; - if (!getishortarg(args, 4, 3, &arg4)) - return NULL; - shaderange( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void xfpt4s short s short s short s short s */ - -static PyObject * -gl_xfpt4s(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - if (!getishortarg(args, 4, 0, &arg1)) - return NULL; - if (!getishortarg(args, 4, 1, &arg2)) - return NULL; - if (!getishortarg(args, 4, 2, &arg3)) - return NULL; - if (!getishortarg(args, 4, 3, &arg4)) - return NULL; - xfpt4s( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rectfi long s long s long s long s */ - -static PyObject * -gl_rectfi(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - long arg4 ; - if (!getilongarg(args, 4, 0, &arg1)) - return NULL; - if (!getilongarg(args, 4, 1, &arg2)) - return NULL; - if (!getilongarg(args, 4, 2, &arg3)) - return NULL; - if (!getilongarg(args, 4, 3, &arg4)) - return NULL; - rectfi( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void recti long s long s long s long s */ - -static PyObject * -gl_recti(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - long arg4 ; - if (!getilongarg(args, 4, 0, &arg1)) - return NULL; - if (!getilongarg(args, 4, 1, &arg2)) - return NULL; - if (!getilongarg(args, 4, 2, &arg3)) - return NULL; - if (!getilongarg(args, 4, 3, &arg4)) - return NULL; - recti( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void xfpt4i long s long s long s long s */ - -static PyObject * -gl_xfpt4i(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - long arg4 ; - if (!getilongarg(args, 4, 0, &arg1)) - return NULL; - if (!getilongarg(args, 4, 1, &arg2)) - return NULL; - if (!getilongarg(args, 4, 2, &arg3)) - return NULL; - if (!getilongarg(args, 4, 3, &arg4)) - return NULL; - xfpt4i( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void prefposition long s long s long s long s */ - -static PyObject * -gl_prefposition(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - long arg4 ; - if (!getilongarg(args, 4, 0, &arg1)) - return NULL; - if (!getilongarg(args, 4, 1, &arg2)) - return NULL; - if (!getilongarg(args, 4, 2, &arg3)) - return NULL; - if (!getilongarg(args, 4, 3, &arg4)) - return NULL; - prefposition( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void arc float s float s float s short s short s */ - -static PyObject * -gl_arc(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - short arg4 ; - short arg5 ; - if (!getifloatarg(args, 5, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 5, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 5, 2, &arg3)) - return NULL; - if (!getishortarg(args, 5, 3, &arg4)) - return NULL; - if (!getishortarg(args, 5, 4, &arg5)) - return NULL; - arc( arg1 , arg2 , arg3 , arg4 , arg5 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void arcf float s float s float s short s short s */ - -static PyObject * -gl_arcf(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - short arg4 ; - short arg5 ; - if (!getifloatarg(args, 5, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 5, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 5, 2, &arg3)) - return NULL; - if (!getishortarg(args, 5, 3, &arg4)) - return NULL; - if (!getishortarg(args, 5, 4, &arg5)) - return NULL; - arcf( arg1 , arg2 , arg3 , arg4 , arg5 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void arcfi long s long s long s short s short s */ - -static PyObject * -gl_arcfi(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - short arg4 ; - short arg5 ; - if (!getilongarg(args, 5, 0, &arg1)) - return NULL; - if (!getilongarg(args, 5, 1, &arg2)) - return NULL; - if (!getilongarg(args, 5, 2, &arg3)) - return NULL; - if (!getishortarg(args, 5, 3, &arg4)) - return NULL; - if (!getishortarg(args, 5, 4, &arg5)) - return NULL; - arcfi( arg1 , arg2 , arg3 , arg4 , arg5 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void arci long s long s long s short s short s */ - -static PyObject * -gl_arci(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - short arg4 ; - short arg5 ; - if (!getilongarg(args, 5, 0, &arg1)) - return NULL; - if (!getilongarg(args, 5, 1, &arg2)) - return NULL; - if (!getilongarg(args, 5, 2, &arg3)) - return NULL; - if (!getishortarg(args, 5, 3, &arg4)) - return NULL; - if (!getishortarg(args, 5, 4, &arg5)) - return NULL; - arci( arg1 , arg2 , arg3 , arg4 , arg5 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void bbox2 short s short s float s float s float s float s */ - -static PyObject * -gl_bbox2(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - float arg3 ; - float arg4 ; - float arg5 ; - float arg6 ; - if (!getishortarg(args, 6, 0, &arg1)) - return NULL; - if (!getishortarg(args, 6, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 6, 2, &arg3)) - return NULL; - if (!getifloatarg(args, 6, 3, &arg4)) - return NULL; - if (!getifloatarg(args, 6, 4, &arg5)) - return NULL; - if (!getifloatarg(args, 6, 5, &arg6)) - return NULL; - bbox2( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void bbox2i short s short s long s long s long s long s */ - -static PyObject * -gl_bbox2i(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - long arg3 ; - long arg4 ; - long arg5 ; - long arg6 ; - if (!getishortarg(args, 6, 0, &arg1)) - return NULL; - if (!getishortarg(args, 6, 1, &arg2)) - return NULL; - if (!getilongarg(args, 6, 2, &arg3)) - return NULL; - if (!getilongarg(args, 6, 3, &arg4)) - return NULL; - if (!getilongarg(args, 6, 4, &arg5)) - return NULL; - if (!getilongarg(args, 6, 5, &arg6)) - return NULL; - bbox2i( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void bbox2s short s short s short s short s short s short s */ - -static PyObject * -gl_bbox2s(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - short arg5 ; - short arg6 ; - if (!getishortarg(args, 6, 0, &arg1)) - return NULL; - if (!getishortarg(args, 6, 1, &arg2)) - return NULL; - if (!getishortarg(args, 6, 2, &arg3)) - return NULL; - if (!getishortarg(args, 6, 3, &arg4)) - return NULL; - if (!getishortarg(args, 6, 4, &arg5)) - return NULL; - if (!getishortarg(args, 6, 5, &arg6)) - return NULL; - bbox2s( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void blink short s short s short s short s short s */ - -static PyObject * -gl_blink(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - short arg5 ; - if (!getishortarg(args, 5, 0, &arg1)) - return NULL; - if (!getishortarg(args, 5, 1, &arg2)) - return NULL; - if (!getishortarg(args, 5, 2, &arg3)) - return NULL; - if (!getishortarg(args, 5, 3, &arg4)) - return NULL; - if (!getishortarg(args, 5, 4, &arg5)) - return NULL; - blink( arg1 , arg2 , arg3 , arg4 , arg5 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void ortho float s float s float s float s float s float s */ - -static PyObject * -gl_ortho(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - float arg4 ; - float arg5 ; - float arg6 ; - if (!getifloatarg(args, 6, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 6, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 6, 2, &arg3)) - return NULL; - if (!getifloatarg(args, 6, 3, &arg4)) - return NULL; - if (!getifloatarg(args, 6, 4, &arg5)) - return NULL; - if (!getifloatarg(args, 6, 5, &arg6)) - return NULL; - ortho( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void window float s float s float s float s float s float s */ - -static PyObject * -gl_window(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - float arg4 ; - float arg5 ; - float arg6 ; - if (!getifloatarg(args, 6, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 6, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 6, 2, &arg3)) - return NULL; - if (!getifloatarg(args, 6, 3, &arg4)) - return NULL; - if (!getifloatarg(args, 6, 4, &arg5)) - return NULL; - if (!getifloatarg(args, 6, 5, &arg6)) - return NULL; - window( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void lookat float s float s float s float s float s float s short s */ - -static PyObject * -gl_lookat(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - float arg4 ; - float arg5 ; - float arg6 ; - short arg7 ; - if (!getifloatarg(args, 7, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 7, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 7, 2, &arg3)) - return NULL; - if (!getifloatarg(args, 7, 3, &arg4)) - return NULL; - if (!getifloatarg(args, 7, 4, &arg5)) - return NULL; - if (!getifloatarg(args, 7, 5, &arg6)) - return NULL; - if (!getishortarg(args, 7, 6, &arg7)) - return NULL; - lookat( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void perspective short s float s float s float s */ - -static PyObject * -gl_perspective(PyObject *self, PyObject *args) -{ - short arg1 ; - float arg2 ; - float arg3 ; - float arg4 ; - if (!getishortarg(args, 4, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 4, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 4, 2, &arg3)) - return NULL; - if (!getifloatarg(args, 4, 3, &arg4)) - return NULL; - perspective( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void polarview float s short s short s short s */ - -static PyObject * -gl_polarview(PyObject *self, PyObject *args) -{ - float arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - if (!getifloatarg(args, 4, 0, &arg1)) - return NULL; - if (!getishortarg(args, 4, 1, &arg2)) - return NULL; - if (!getishortarg(args, 4, 2, &arg3)) - return NULL; - if (!getishortarg(args, 4, 3, &arg4)) - return NULL; - polarview( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void arcfs short s short s short s short s short s */ - -static PyObject * -gl_arcfs(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - short arg5 ; - if (!getishortarg(args, 5, 0, &arg1)) - return NULL; - if (!getishortarg(args, 5, 1, &arg2)) - return NULL; - if (!getishortarg(args, 5, 2, &arg3)) - return NULL; - if (!getishortarg(args, 5, 3, &arg4)) - return NULL; - if (!getishortarg(args, 5, 4, &arg5)) - return NULL; - arcfs( arg1 , arg2 , arg3 , arg4 , arg5 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void arcs short s short s short s short s short s */ - -static PyObject * -gl_arcs(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - short arg5 ; - if (!getishortarg(args, 5, 0, &arg1)) - return NULL; - if (!getishortarg(args, 5, 1, &arg2)) - return NULL; - if (!getishortarg(args, 5, 2, &arg3)) - return NULL; - if (!getishortarg(args, 5, 3, &arg4)) - return NULL; - if (!getishortarg(args, 5, 4, &arg5)) - return NULL; - arcs( arg1 , arg2 , arg3 , arg4 , arg5 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rectcopy short s short s short s short s short s short s */ - -static PyObject * -gl_rectcopy(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - short arg5 ; - short arg6 ; - if (!getishortarg(args, 6, 0, &arg1)) - return NULL; - if (!getishortarg(args, 6, 1, &arg2)) - return NULL; - if (!getishortarg(args, 6, 2, &arg3)) - return NULL; - if (!getishortarg(args, 6, 3, &arg4)) - return NULL; - if (!getishortarg(args, 6, 4, &arg5)) - return NULL; - if (!getishortarg(args, 6, 5, &arg6)) - return NULL; - rectcopy( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void RGBcursor short s short s short s short s short s short s short s */ - -static PyObject * -gl_RGBcursor(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - short arg5 ; - short arg6 ; - short arg7 ; - if (!getishortarg(args, 7, 0, &arg1)) - return NULL; - if (!getishortarg(args, 7, 1, &arg2)) - return NULL; - if (!getishortarg(args, 7, 2, &arg3)) - return NULL; - if (!getishortarg(args, 7, 3, &arg4)) - return NULL; - if (!getishortarg(args, 7, 4, &arg5)) - return NULL; - if (!getishortarg(args, 7, 5, &arg6)) - return NULL; - if (!getishortarg(args, 7, 6, &arg7)) - return NULL; - RGBcursor( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* long getbutton short s */ - -static PyObject * -gl_getbutton(PyObject *self, PyObject *args) -{ - long retval; - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - retval = getbutton( arg1 ); - return mknewlongobject(retval); -} - -/* long getcmmode */ - -static PyObject * -gl_getcmmode(PyObject *self, PyObject *args) -{ - long retval; - retval = getcmmode( ); - return mknewlongobject(retval); -} - -/* long getlsbackup */ - -static PyObject * -gl_getlsbackup(PyObject *self, PyObject *args) -{ - long retval; - retval = getlsbackup( ); - return mknewlongobject(retval); -} - -/* long getresetls */ - -static PyObject * -gl_getresetls(PyObject *self, PyObject *args) -{ - long retval; - retval = getresetls( ); - return mknewlongobject(retval); -} - -/* long getdcm */ - -static PyObject * -gl_getdcm(PyObject *self, PyObject *args) -{ - long retval; - retval = getdcm( ); - return mknewlongobject(retval); -} - -/* long getzbuffer */ - -static PyObject * -gl_getzbuffer(PyObject *self, PyObject *args) -{ - long retval; - retval = getzbuffer( ); - return mknewlongobject(retval); -} - -/* long ismex */ - -static PyObject * -gl_ismex(PyObject *self, PyObject *args) -{ - long retval; - retval = ismex( ); - return mknewlongobject(retval); -} - -/* long isobj long s */ - -static PyObject * -gl_isobj(PyObject *self, PyObject *args) -{ - long retval; - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - retval = isobj( arg1 ); - return mknewlongobject(retval); -} - -/* long isqueued short s */ - -static PyObject * -gl_isqueued(PyObject *self, PyObject *args) -{ - long retval; - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - retval = isqueued( arg1 ); - return mknewlongobject(retval); -} - -/* long istag long s */ - -static PyObject * -gl_istag(PyObject *self, PyObject *args) -{ - long retval; - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - retval = istag( arg1 ); - return mknewlongobject(retval); -} - -/* long genobj */ - -static PyObject * -gl_genobj(PyObject *self, PyObject *args) -{ - long retval; - retval = genobj( ); - return mknewlongobject(retval); -} - -/* long gentag */ - -static PyObject * -gl_gentag(PyObject *self, PyObject *args) -{ - long retval; - retval = gentag( ); - return mknewlongobject(retval); -} - -/* long getbuffer */ - -static PyObject * -gl_getbuffer(PyObject *self, PyObject *args) -{ - long retval; - retval = getbuffer( ); - return mknewlongobject(retval); -} - -/* long getcolor */ - -static PyObject * -gl_getcolor(PyObject *self, PyObject *args) -{ - long retval; - retval = getcolor( ); - return mknewlongobject(retval); -} - -/* long getdisplaymode */ - -static PyObject * -gl_getdisplaymode(PyObject *self, PyObject *args) -{ - long retval; - retval = getdisplaymode( ); - return mknewlongobject(retval); -} - -/* long getfont */ - -static PyObject * -gl_getfont(PyObject *self, PyObject *args) -{ - long retval; - retval = getfont( ); - return mknewlongobject(retval); -} - -/* long getheight */ - -static PyObject * -gl_getheight(PyObject *self, PyObject *args) -{ - long retval; - retval = getheight( ); - return mknewlongobject(retval); -} - -/* long gethitcode */ - -static PyObject * -gl_gethitcode(PyObject *self, PyObject *args) -{ - long retval; - retval = gethitcode( ); - return mknewlongobject(retval); -} - -/* long getlstyle */ - -static PyObject * -gl_getlstyle(PyObject *self, PyObject *args) -{ - long retval; - retval = getlstyle( ); - return mknewlongobject(retval); -} - -/* long getlwidth */ - -static PyObject * -gl_getlwidth(PyObject *self, PyObject *args) -{ - long retval; - retval = getlwidth( ); - return mknewlongobject(retval); -} - -/* long getmap */ - -static PyObject * -gl_getmap(PyObject *self, PyObject *args) -{ - long retval; - retval = getmap( ); - return mknewlongobject(retval); -} - -/* long getplanes */ - -static PyObject * -gl_getplanes(PyObject *self, PyObject *args) -{ - long retval; - retval = getplanes( ); - return mknewlongobject(retval); -} - -/* long getwritemask */ - -static PyObject * -gl_getwritemask(PyObject *self, PyObject *args) -{ - long retval; - retval = getwritemask( ); - return mknewlongobject(retval); -} - -/* long qtest */ - -static PyObject * -gl_qtest(PyObject *self, PyObject *args) -{ - long retval; - retval = qtest( ); - return mknewlongobject(retval); -} - -/* long getlsrepeat */ - -static PyObject * -gl_getlsrepeat(PyObject *self, PyObject *args) -{ - long retval; - retval = getlsrepeat( ); - return mknewlongobject(retval); -} - -/* long getmonitor */ - -static PyObject * -gl_getmonitor(PyObject *self, PyObject *args) -{ - long retval; - retval = getmonitor( ); - return mknewlongobject(retval); -} - -/* long getopenobj */ - -static PyObject * -gl_getopenobj(PyObject *self, PyObject *args) -{ - long retval; - retval = getopenobj( ); - return mknewlongobject(retval); -} - -/* long getpattern */ - -static PyObject * -gl_getpattern(PyObject *self, PyObject *args) -{ - long retval; - retval = getpattern( ); - return mknewlongobject(retval); -} - -/* long winget */ - -static PyObject * -gl_winget(PyObject *self, PyObject *args) -{ - long retval; - retval = winget( ); - return mknewlongobject(retval); -} - -/* long winattach */ - -static PyObject * -gl_winattach(PyObject *self, PyObject *args) -{ - long retval; - retval = winattach( ); - return mknewlongobject(retval); -} - -/* long getothermonitor */ - -static PyObject * -gl_getothermonitor(PyObject *self, PyObject *args) -{ - long retval; - retval = getothermonitor( ); - return mknewlongobject(retval); -} - -/* long newpup */ - -static PyObject * -gl_newpup(PyObject *self, PyObject *args) -{ - long retval; - retval = newpup( ); - return mknewlongobject(retval); -} - -/* long getvaluator short s */ - -static PyObject * -gl_getvaluator(PyObject *self, PyObject *args) -{ - long retval; - short arg1 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - retval = getvaluator( arg1 ); - return mknewlongobject(retval); -} - -/* void winset long s */ - -static PyObject * -gl_winset(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - winset( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* long dopup long s */ - -static PyObject * -gl_dopup(PyObject *self, PyObject *args) -{ - long retval; - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - retval = dopup( arg1 ); - return mknewlongobject(retval); -} - -/* void getdepth short r short r */ - -static PyObject * -gl_getdepth(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - getdepth( & arg1 , & arg2 ); - { PyObject *v = PyTuple_New( 2 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewshortobject(arg1)); - PyTuple_SetItem(v, 1, mknewshortobject(arg2)); - return v; - } -} - -/* void getcpos short r short r */ - -static PyObject * -gl_getcpos(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - getcpos( & arg1 , & arg2 ); - { PyObject *v = PyTuple_New( 2 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewshortobject(arg1)); - PyTuple_SetItem(v, 1, mknewshortobject(arg2)); - return v; - } -} - -/* void getsize long r long r */ - -static PyObject * -gl_getsize(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - getsize( & arg1 , & arg2 ); - { PyObject *v = PyTuple_New( 2 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewlongobject(arg1)); - PyTuple_SetItem(v, 1, mknewlongobject(arg2)); - return v; - } -} - -/* void getorigin long r long r */ - -static PyObject * -gl_getorigin(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - getorigin( & arg1 , & arg2 ); - { PyObject *v = PyTuple_New( 2 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewlongobject(arg1)); - PyTuple_SetItem(v, 1, mknewlongobject(arg2)); - return v; - } -} - -/* void getviewport short r short r short r short r */ - -static PyObject * -gl_getviewport(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - getviewport( & arg1 , & arg2 , & arg3 , & arg4 ); - { PyObject *v = PyTuple_New( 4 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewshortobject(arg1)); - PyTuple_SetItem(v, 1, mknewshortobject(arg2)); - PyTuple_SetItem(v, 2, mknewshortobject(arg3)); - PyTuple_SetItem(v, 3, mknewshortobject(arg4)); - return v; - } -} - -/* void gettp short r short r short r short r */ - -static PyObject * -gl_gettp(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - gettp( & arg1 , & arg2 , & arg3 , & arg4 ); - { PyObject *v = PyTuple_New( 4 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewshortobject(arg1)); - PyTuple_SetItem(v, 1, mknewshortobject(arg2)); - PyTuple_SetItem(v, 2, mknewshortobject(arg3)); - PyTuple_SetItem(v, 3, mknewshortobject(arg4)); - return v; - } -} - -/* void getgpos float r float r float r float r */ - -static PyObject * -gl_getgpos(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - float arg4 ; - getgpos( & arg1 , & arg2 , & arg3 , & arg4 ); - { PyObject *v = PyTuple_New( 4 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewfloatobject(arg1)); - PyTuple_SetItem(v, 1, mknewfloatobject(arg2)); - PyTuple_SetItem(v, 2, mknewfloatobject(arg3)); - PyTuple_SetItem(v, 3, mknewfloatobject(arg4)); - return v; - } -} - -/* void winposition long s long s long s long s */ - -static PyObject * -gl_winposition(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - long arg4 ; - if (!getilongarg(args, 4, 0, &arg1)) - return NULL; - if (!getilongarg(args, 4, 1, &arg2)) - return NULL; - if (!getilongarg(args, 4, 2, &arg3)) - return NULL; - if (!getilongarg(args, 4, 3, &arg4)) - return NULL; - winposition( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void gRGBcolor short r short r short r */ - -static PyObject * -gl_gRGBcolor(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - gRGBcolor( & arg1 , & arg2 , & arg3 ); - { PyObject *v = PyTuple_New( 3 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewshortobject(arg1)); - PyTuple_SetItem(v, 1, mknewshortobject(arg2)); - PyTuple_SetItem(v, 2, mknewshortobject(arg3)); - return v; - } -} - -/* void gRGBmask short r short r short r */ - -static PyObject * -gl_gRGBmask(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - gRGBmask( & arg1 , & arg2 , & arg3 ); - { PyObject *v = PyTuple_New( 3 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewshortobject(arg1)); - PyTuple_SetItem(v, 1, mknewshortobject(arg2)); - PyTuple_SetItem(v, 2, mknewshortobject(arg3)); - return v; - } -} - -/* void getscrmask short r short r short r short r */ - -static PyObject * -gl_getscrmask(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - getscrmask( & arg1 , & arg2 , & arg3 , & arg4 ); - { PyObject *v = PyTuple_New( 4 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewshortobject(arg1)); - PyTuple_SetItem(v, 1, mknewshortobject(arg2)); - PyTuple_SetItem(v, 2, mknewshortobject(arg3)); - PyTuple_SetItem(v, 3, mknewshortobject(arg4)); - return v; - } -} - -/* void getmcolor short s short r short r short r */ - -static PyObject * -gl_getmcolor(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - if (!getishortarg(args, 1, 0, &arg1)) - return NULL; - getmcolor( arg1 , & arg2 , & arg3 , & arg4 ); - { PyObject *v = PyTuple_New( 3 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewshortobject(arg2)); - PyTuple_SetItem(v, 1, mknewshortobject(arg3)); - PyTuple_SetItem(v, 2, mknewshortobject(arg4)); - return v; - } -} - -/* void mapw long s short s short s float r float r float r float r float r float r */ - -static PyObject * -gl_mapw(PyObject *self, PyObject *args) -{ - long arg1 ; - short arg2 ; - short arg3 ; - float arg4 ; - float arg5 ; - float arg6 ; - float arg7 ; - float arg8 ; - float arg9 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - mapw( arg1 , arg2 , arg3 , & arg4 , & arg5 , & arg6 , & arg7 , & arg8 , & arg9 ); - { PyObject *v = PyTuple_New( 6 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewfloatobject(arg4)); - PyTuple_SetItem(v, 1, mknewfloatobject(arg5)); - PyTuple_SetItem(v, 2, mknewfloatobject(arg6)); - PyTuple_SetItem(v, 3, mknewfloatobject(arg7)); - PyTuple_SetItem(v, 4, mknewfloatobject(arg8)); - PyTuple_SetItem(v, 5, mknewfloatobject(arg9)); - return v; - } -} - -/* void mapw2 long s short s short s float r float r */ - -static PyObject * -gl_mapw2(PyObject *self, PyObject *args) -{ - long arg1 ; - short arg2 ; - short arg3 ; - float arg4 ; - float arg5 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getishortarg(args, 3, 1, &arg2)) - return NULL; - if (!getishortarg(args, 3, 2, &arg3)) - return NULL; - mapw2( arg1 , arg2 , arg3 , & arg4 , & arg5 ); - { PyObject *v = PyTuple_New( 2 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewfloatobject(arg4)); - PyTuple_SetItem(v, 1, mknewfloatobject(arg5)); - return v; - } -} - -/* void getcursor short r u_short r u_short r long r */ - -static PyObject * -gl_getcursor(PyObject *self, PyObject *args) -{ - short arg1 ; - unsigned short arg2 ; - unsigned short arg3 ; - long arg4 ; - getcursor( & arg1 , & arg2 , & arg3 , & arg4 ); - { PyObject *v = PyTuple_New( 4 ); - if (v == NULL) return NULL; - PyTuple_SetItem(v, 0, mknewshortobject(arg1)); - PyTuple_SetItem(v, 1, mknewshortobject((short) arg2)); - PyTuple_SetItem(v, 2, mknewshortobject((short) arg3)); - PyTuple_SetItem(v, 3, mknewlongobject(arg4)); - return v; - } -} - -/* void cmode */ - -static PyObject * -gl_cmode(PyObject *self, PyObject *args) -{ - cmode( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void concave long s */ - -static PyObject * -gl_concave(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - concave( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void curstype long s */ - -static PyObject * -gl_curstype(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - curstype( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void drawmode long s */ - -static PyObject * -gl_drawmode(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - drawmode( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void gammaramp short s[256] short s[256] short s[256] */ - -static PyObject * -gl_gammaramp(PyObject *self, PyObject *args) -{ - short arg1 [ 256 ] ; - short arg2 [ 256 ] ; - short arg3 [ 256 ] ; - if (!getishortarray(args, 3, 0, 256 , arg1)) - return NULL; - if (!getishortarray(args, 3, 1, 256 , arg2)) - return NULL; - if (!getishortarray(args, 3, 2, 256 , arg3)) - return NULL; - gammaramp( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* long getbackface */ - -static PyObject * -gl_getbackface(PyObject *self, PyObject *args) -{ - long retval; - retval = getbackface( ); - return mknewlongobject(retval); -} - -/* long getdescender */ - -static PyObject * -gl_getdescender(PyObject *self, PyObject *args) -{ - long retval; - retval = getdescender( ); - return mknewlongobject(retval); -} - -/* long getdrawmode */ - -static PyObject * -gl_getdrawmode(PyObject *self, PyObject *args) -{ - long retval; - retval = getdrawmode( ); - return mknewlongobject(retval); -} - -/* long getmmode */ - -static PyObject * -gl_getmmode(PyObject *self, PyObject *args) -{ - long retval; - retval = getmmode( ); - return mknewlongobject(retval); -} - -/* long getsm */ - -static PyObject * -gl_getsm(PyObject *self, PyObject *args) -{ - long retval; - retval = getsm( ); - return mknewlongobject(retval); -} - -/* long getvideo long s */ - -static PyObject * -gl_getvideo(PyObject *self, PyObject *args) -{ - long retval; - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - retval = getvideo( arg1 ); - return mknewlongobject(retval); -} - -/* void imakebackground */ - -static PyObject * -gl_imakebackground(PyObject *self, PyObject *args) -{ - imakebackground( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void lmbind short s short s */ - -static PyObject * -gl_lmbind(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - if (!getishortarg(args, 2, 0, &arg1)) - return NULL; - if (!getishortarg(args, 2, 1, &arg2)) - return NULL; - lmbind( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void lmdef long s long s long s float s[arg3] */ - -static PyObject * -gl_lmdef(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - float * arg4 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarraysize(args, 3, 2, &arg3)) - return NULL; - if ((arg4 = PyMem_NEW(float , arg3 )) == NULL) - return PyErr_NoMemory(); - if (!getifloatarray(args, 3, 2, arg3 , arg4)) - return NULL; - lmdef( arg1 , arg2 , arg3 , arg4 ); - PyMem_DEL(arg4); - Py_INCREF(Py_None); - return Py_None; -} - -/* void mmode long s */ - -static PyObject * -gl_mmode(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - mmode( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void normal float s[3] */ - -static PyObject * -gl_normal(PyObject *self, PyObject *args) -{ - float arg1 [ 3 ] ; - if (!getifloatarray(args, 1, 0, 3 , arg1)) - return NULL; - normal( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void overlay long s */ - -static PyObject * -gl_overlay(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - overlay( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void RGBrange short s short s short s short s short s short s short s short s */ - -static PyObject * -gl_RGBrange(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - short arg5 ; - short arg6 ; - short arg7 ; - short arg8 ; - if (!getishortarg(args, 8, 0, &arg1)) - return NULL; - if (!getishortarg(args, 8, 1, &arg2)) - return NULL; - if (!getishortarg(args, 8, 2, &arg3)) - return NULL; - if (!getishortarg(args, 8, 3, &arg4)) - return NULL; - if (!getishortarg(args, 8, 4, &arg5)) - return NULL; - if (!getishortarg(args, 8, 5, &arg6)) - return NULL; - if (!getishortarg(args, 8, 6, &arg7)) - return NULL; - if (!getishortarg(args, 8, 7, &arg8)) - return NULL; - RGBrange( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void setvideo long s long s */ - -static PyObject * -gl_setvideo(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - setvideo( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void shademodel long s */ - -static PyObject * -gl_shademodel(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - shademodel( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void underlay long s */ - -static PyObject * -gl_underlay(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - underlay( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void bgnclosedline */ - -static PyObject * -gl_bgnclosedline(PyObject *self, PyObject *args) -{ - bgnclosedline( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void bgnline */ - -static PyObject * -gl_bgnline(PyObject *self, PyObject *args) -{ - bgnline( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void bgnpoint */ - -static PyObject * -gl_bgnpoint(PyObject *self, PyObject *args) -{ - bgnpoint( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void bgnpolygon */ - -static PyObject * -gl_bgnpolygon(PyObject *self, PyObject *args) -{ - bgnpolygon( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void bgnsurface */ - -static PyObject * -gl_bgnsurface(PyObject *self, PyObject *args) -{ - bgnsurface( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void bgntmesh */ - -static PyObject * -gl_bgntmesh(PyObject *self, PyObject *args) -{ - bgntmesh( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void bgntrim */ - -static PyObject * -gl_bgntrim(PyObject *self, PyObject *args) -{ - bgntrim( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void endclosedline */ - -static PyObject * -gl_endclosedline(PyObject *self, PyObject *args) -{ - endclosedline( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void endline */ - -static PyObject * -gl_endline(PyObject *self, PyObject *args) -{ - endline( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void endpoint */ - -static PyObject * -gl_endpoint(PyObject *self, PyObject *args) -{ - endpoint( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void endpolygon */ - -static PyObject * -gl_endpolygon(PyObject *self, PyObject *args) -{ - endpolygon( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void endsurface */ - -static PyObject * -gl_endsurface(PyObject *self, PyObject *args) -{ - endsurface( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void endtmesh */ - -static PyObject * -gl_endtmesh(PyObject *self, PyObject *args) -{ - endtmesh( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void endtrim */ - -static PyObject * -gl_endtrim(PyObject *self, PyObject *args) -{ - endtrim( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void blendfunction long s long s */ - -static PyObject * -gl_blendfunction(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - blendfunction( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void c3f float s[3] */ - -static PyObject * -gl_c3f(PyObject *self, PyObject *args) -{ - float arg1 [ 3 ] ; - if (!getifloatarray(args, 1, 0, 3 , arg1)) - return NULL; - c3f( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void c3i long s[3] */ - -static PyObject * -gl_c3i(PyObject *self, PyObject *args) -{ - long arg1 [ 3 ] ; - if (!getilongarray(args, 1, 0, 3 , arg1)) - return NULL; - c3i( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void c3s short s[3] */ - -static PyObject * -gl_c3s(PyObject *self, PyObject *args) -{ - short arg1 [ 3 ] ; - if (!getishortarray(args, 1, 0, 3 , arg1)) - return NULL; - c3s( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void c4f float s[4] */ - -static PyObject * -gl_c4f(PyObject *self, PyObject *args) -{ - float arg1 [ 4 ] ; - if (!getifloatarray(args, 1, 0, 4 , arg1)) - return NULL; - c4f( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void c4i long s[4] */ - -static PyObject * -gl_c4i(PyObject *self, PyObject *args) -{ - long arg1 [ 4 ] ; - if (!getilongarray(args, 1, 0, 4 , arg1)) - return NULL; - c4i( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void c4s short s[4] */ - -static PyObject * -gl_c4s(PyObject *self, PyObject *args) -{ - short arg1 [ 4 ] ; - if (!getishortarray(args, 1, 0, 4 , arg1)) - return NULL; - c4s( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void colorf float s */ - -static PyObject * -gl_colorf(PyObject *self, PyObject *args) -{ - float arg1 ; - if (!getifloatarg(args, 1, 0, &arg1)) - return NULL; - colorf( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void cpack long s */ - -static PyObject * -gl_cpack(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - cpack( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void czclear long s long s */ - -static PyObject * -gl_czclear(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - czclear( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void dglclose long s */ - -static PyObject * -gl_dglclose(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - dglclose( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* long dglopen char *s long s */ - -static PyObject * -gl_dglopen(PyObject *self, PyObject *args) -{ - long retval; - string arg1 ; - long arg2 ; - if (!getistringarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - retval = dglopen( arg1 , arg2 ); - return mknewlongobject(retval); -} - -/* long getgdesc long s */ - -static PyObject * -gl_getgdesc(PyObject *self, PyObject *args) -{ - long retval; - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - retval = getgdesc( arg1 ); - return mknewlongobject(retval); -} - -/* void getnurbsproperty long s float r */ - -static PyObject * -gl_getnurbsproperty(PyObject *self, PyObject *args) -{ - long arg1 ; - float arg2 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - getnurbsproperty( arg1 , & arg2 ); - return mknewfloatobject(arg2); -} - -/* void glcompat long s long s */ - -static PyObject * -gl_glcompat(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - glcompat( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void iconsize long s long s */ - -static PyObject * -gl_iconsize(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - iconsize( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void icontitle char *s */ - -static PyObject * -gl_icontitle(PyObject *self, PyObject *args) -{ - string arg1 ; - if (!getistringarg(args, 1, 0, &arg1)) - return NULL; - icontitle( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void lRGBrange short s short s short s short s short s short s long s long s */ - -static PyObject * -gl_lRGBrange(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - short arg5 ; - short arg6 ; - long arg7 ; - long arg8 ; - if (!getishortarg(args, 8, 0, &arg1)) - return NULL; - if (!getishortarg(args, 8, 1, &arg2)) - return NULL; - if (!getishortarg(args, 8, 2, &arg3)) - return NULL; - if (!getishortarg(args, 8, 3, &arg4)) - return NULL; - if (!getishortarg(args, 8, 4, &arg5)) - return NULL; - if (!getishortarg(args, 8, 5, &arg6)) - return NULL; - if (!getilongarg(args, 8, 6, &arg7)) - return NULL; - if (!getilongarg(args, 8, 7, &arg8)) - return NULL; - lRGBrange( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void linesmooth long s */ - -static PyObject * -gl_linesmooth(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - linesmooth( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void lmcolor long s */ - -static PyObject * -gl_lmcolor(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - lmcolor( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void logicop long s */ - -static PyObject * -gl_logicop(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - logicop( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void lsetdepth long s long s */ - -static PyObject * -gl_lsetdepth(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - lsetdepth( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void lshaderange short s short s long s long s */ - -static PyObject * -gl_lshaderange(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - long arg3 ; - long arg4 ; - if (!getishortarg(args, 4, 0, &arg1)) - return NULL; - if (!getishortarg(args, 4, 1, &arg2)) - return NULL; - if (!getilongarg(args, 4, 2, &arg3)) - return NULL; - if (!getilongarg(args, 4, 3, &arg4)) - return NULL; - lshaderange( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void n3f float s[3] */ - -static PyObject * -gl_n3f(PyObject *self, PyObject *args) -{ - float arg1 [ 3 ] ; - if (!getifloatarray(args, 1, 0, 3 , arg1)) - return NULL; - n3f( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void noborder */ - -static PyObject * -gl_noborder(PyObject *self, PyObject *args) -{ - noborder( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pntsmooth long s */ - -static PyObject * -gl_pntsmooth(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - pntsmooth( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void readsource long s */ - -static PyObject * -gl_readsource(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - readsource( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void rectzoom float s float s */ - -static PyObject * -gl_rectzoom(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - if (!getifloatarg(args, 2, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 2, 1, &arg2)) - return NULL; - rectzoom( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void sbox float s float s float s float s */ - -static PyObject * -gl_sbox(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - float arg4 ; - if (!getifloatarg(args, 4, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 4, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 4, 2, &arg3)) - return NULL; - if (!getifloatarg(args, 4, 3, &arg4)) - return NULL; - sbox( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void sboxi long s long s long s long s */ - -static PyObject * -gl_sboxi(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - long arg4 ; - if (!getilongarg(args, 4, 0, &arg1)) - return NULL; - if (!getilongarg(args, 4, 1, &arg2)) - return NULL; - if (!getilongarg(args, 4, 2, &arg3)) - return NULL; - if (!getilongarg(args, 4, 3, &arg4)) - return NULL; - sboxi( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void sboxs short s short s short s short s */ - -static PyObject * -gl_sboxs(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - if (!getishortarg(args, 4, 0, &arg1)) - return NULL; - if (!getishortarg(args, 4, 1, &arg2)) - return NULL; - if (!getishortarg(args, 4, 2, &arg3)) - return NULL; - if (!getishortarg(args, 4, 3, &arg4)) - return NULL; - sboxs( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void sboxf float s float s float s float s */ - -static PyObject * -gl_sboxf(PyObject *self, PyObject *args) -{ - float arg1 ; - float arg2 ; - float arg3 ; - float arg4 ; - if (!getifloatarg(args, 4, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 4, 1, &arg2)) - return NULL; - if (!getifloatarg(args, 4, 2, &arg3)) - return NULL; - if (!getifloatarg(args, 4, 3, &arg4)) - return NULL; - sboxf( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void sboxfi long s long s long s long s */ - -static PyObject * -gl_sboxfi(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - long arg4 ; - if (!getilongarg(args, 4, 0, &arg1)) - return NULL; - if (!getilongarg(args, 4, 1, &arg2)) - return NULL; - if (!getilongarg(args, 4, 2, &arg3)) - return NULL; - if (!getilongarg(args, 4, 3, &arg4)) - return NULL; - sboxfi( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void sboxfs short s short s short s short s */ - -static PyObject * -gl_sboxfs(PyObject *self, PyObject *args) -{ - short arg1 ; - short arg2 ; - short arg3 ; - short arg4 ; - if (!getishortarg(args, 4, 0, &arg1)) - return NULL; - if (!getishortarg(args, 4, 1, &arg2)) - return NULL; - if (!getishortarg(args, 4, 2, &arg3)) - return NULL; - if (!getishortarg(args, 4, 3, &arg4)) - return NULL; - sboxfs( arg1 , arg2 , arg3 , arg4 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void setnurbsproperty long s float s */ - -static PyObject * -gl_setnurbsproperty(PyObject *self, PyObject *args) -{ - long arg1 ; - float arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getifloatarg(args, 2, 1, &arg2)) - return NULL; - setnurbsproperty( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void setpup long s long s long s */ - -static PyObject * -gl_setpup(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - long arg3 ; - if (!getilongarg(args, 3, 0, &arg1)) - return NULL; - if (!getilongarg(args, 3, 1, &arg2)) - return NULL; - if (!getilongarg(args, 3, 2, &arg3)) - return NULL; - setpup( arg1 , arg2 , arg3 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void smoothline long s */ - -static PyObject * -gl_smoothline(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - smoothline( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void subpixel long s */ - -static PyObject * -gl_subpixel(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - subpixel( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void swaptmesh */ - -static PyObject * -gl_swaptmesh(PyObject *self, PyObject *args) -{ - swaptmesh( ); - Py_INCREF(Py_None); - return Py_None; -} - -/* long swinopen long s */ - -static PyObject * -gl_swinopen(PyObject *self, PyObject *args) -{ - long retval; - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - retval = swinopen( arg1 ); - return mknewlongobject(retval); -} - -/* void v2f float s[2] */ - -static PyObject * -gl_v2f(PyObject *self, PyObject *args) -{ - float arg1 [ 2 ] ; - if (!getifloatarray(args, 1, 0, 2 , arg1)) - return NULL; - v2f( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void v2i long s[2] */ - -static PyObject * -gl_v2i(PyObject *self, PyObject *args) -{ - long arg1 [ 2 ] ; - if (!getilongarray(args, 1, 0, 2 , arg1)) - return NULL; - v2i( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void v2s short s[2] */ - -static PyObject * -gl_v2s(PyObject *self, PyObject *args) -{ - short arg1 [ 2 ] ; - if (!getishortarray(args, 1, 0, 2 , arg1)) - return NULL; - v2s( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void v3f float s[3] */ - -static PyObject * -gl_v3f(PyObject *self, PyObject *args) -{ - float arg1 [ 3 ] ; - if (!getifloatarray(args, 1, 0, 3 , arg1)) - return NULL; - v3f( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void v3i long s[3] */ - -static PyObject * -gl_v3i(PyObject *self, PyObject *args) -{ - long arg1 [ 3 ] ; - if (!getilongarray(args, 1, 0, 3 , arg1)) - return NULL; - v3i( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void v3s short s[3] */ - -static PyObject * -gl_v3s(PyObject *self, PyObject *args) -{ - short arg1 [ 3 ] ; - if (!getishortarray(args, 1, 0, 3 , arg1)) - return NULL; - v3s( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void v4f float s[4] */ - -static PyObject * -gl_v4f(PyObject *self, PyObject *args) -{ - float arg1 [ 4 ] ; - if (!getifloatarray(args, 1, 0, 4 , arg1)) - return NULL; - v4f( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void v4i long s[4] */ - -static PyObject * -gl_v4i(PyObject *self, PyObject *args) -{ - long arg1 [ 4 ] ; - if (!getilongarray(args, 1, 0, 4 , arg1)) - return NULL; - v4i( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void v4s short s[4] */ - -static PyObject * -gl_v4s(PyObject *self, PyObject *args) -{ - short arg1 [ 4 ] ; - if (!getishortarray(args, 1, 0, 4 , arg1)) - return NULL; - v4s( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void videocmd long s */ - -static PyObject * -gl_videocmd(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - videocmd( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* long windepth long s */ - -static PyObject * -gl_windepth(PyObject *self, PyObject *args) -{ - long retval; - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - retval = windepth( arg1 ); - return mknewlongobject(retval); -} - -/* void wmpack long s */ - -static PyObject * -gl_wmpack(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - wmpack( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void zdraw long s */ - -static PyObject * -gl_zdraw(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - zdraw( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void zfunction long s */ - -static PyObject * -gl_zfunction(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - zfunction( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void zsource long s */ - -static PyObject * -gl_zsource(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - zsource( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void zwritemask long s */ - -static PyObject * -gl_zwritemask(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - zwritemask( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void v2d double s[2] */ - -static PyObject * -gl_v2d(PyObject *self, PyObject *args) -{ - double arg1 [ 2 ] ; - if (!getidoublearray(args, 1, 0, 2 , arg1)) - return NULL; - v2d( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void v3d double s[3] */ - -static PyObject * -gl_v3d(PyObject *self, PyObject *args) -{ - double arg1 [ 3 ] ; - if (!getidoublearray(args, 1, 0, 3 , arg1)) - return NULL; - v3d( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void v4d double s[4] */ - -static PyObject * -gl_v4d(PyObject *self, PyObject *args) -{ - double arg1 [ 4 ] ; - if (!getidoublearray(args, 1, 0, 4 , arg1)) - return NULL; - v4d( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* void pixmode long s long s */ - -static PyObject * -gl_pixmode(PyObject *self, PyObject *args) -{ - long arg1 ; - long arg2 ; - if (!getilongarg(args, 2, 0, &arg1)) - return NULL; - if (!getilongarg(args, 2, 1, &arg2)) - return NULL; - pixmode( arg1 , arg2 ); - Py_INCREF(Py_None); - return Py_None; -} - -/* long qgetfd */ - -static PyObject * -gl_qgetfd(PyObject *self, PyObject *args) -{ - long retval; - retval = qgetfd( ); - return mknewlongobject(retval); -} - -/* void dither long s */ - -static PyObject * -gl_dither(PyObject *self, PyObject *args) -{ - long arg1 ; - if (!getilongarg(args, 1, 0, &arg1)) - return NULL; - dither( arg1 ); - Py_INCREF(Py_None); - return Py_None; -} - -static struct PyMethodDef gl_methods[] = { - {"qread", gl_qread, METH_OLDARGS}, - {"varray", gl_varray, METH_OLDARGS}, - {"nvarray", gl_nvarray, METH_OLDARGS}, - {"vnarray", gl_vnarray, METH_OLDARGS}, - {"nurbssurface", gl_nurbssurface, METH_OLDARGS}, - {"nurbscurve", gl_nurbscurve, METH_OLDARGS}, - {"pwlcurve", gl_pwlcurve, METH_OLDARGS}, - {"pick", gl_pick, METH_OLDARGS}, - {"endpick", gl_endpick, METH_NOARGS}, - {"gselect", gl_gselect, METH_OLDARGS}, - {"endselect", gl_endselect, METH_NOARGS}, - {"getmatrix", gl_getmatrix, METH_OLDARGS}, - {"altgetmatrix", gl_altgetmatrix, METH_OLDARGS}, - {"lrectwrite", gl_lrectwrite, METH_OLDARGS}, - {"lrectread", gl_lrectread, METH_OLDARGS}, - {"readdisplay", gl_readdisplay, METH_OLDARGS}, - {"packrect", gl_packrect, METH_OLDARGS}, - {"unpackrect", gl_unpackrect, METH_OLDARGS}, - {"gversion", gl_gversion, METH_OLDARGS}, - {"clear", gl_clear, METH_OLDARGS}, - {"getshade", gl_getshade, METH_OLDARGS}, - {"devport", gl_devport, METH_OLDARGS}, - {"rdr2i", gl_rdr2i, METH_OLDARGS}, - {"rectfs", gl_rectfs, METH_OLDARGS}, - {"rects", gl_rects, METH_OLDARGS}, - {"rmv2i", gl_rmv2i, METH_OLDARGS}, - {"noport", gl_noport, METH_OLDARGS}, - {"popviewport", gl_popviewport, METH_OLDARGS}, - {"clearhitcode", gl_clearhitcode, METH_OLDARGS}, - {"closeobj", gl_closeobj, METH_OLDARGS}, - {"cursoff", gl_cursoff, METH_OLDARGS}, - {"curson", gl_curson, METH_OLDARGS}, - {"doublebuffer", gl_doublebuffer, METH_OLDARGS}, - {"finish", gl_finish, METH_OLDARGS}, - {"gconfig", gl_gconfig, METH_OLDARGS}, - {"ginit", gl_ginit, METH_OLDARGS}, - {"greset", gl_greset, METH_OLDARGS}, - {"multimap", gl_multimap, METH_OLDARGS}, - {"onemap", gl_onemap, METH_OLDARGS}, - {"popattributes", gl_popattributes, METH_OLDARGS}, - {"popmatrix", gl_popmatrix, METH_OLDARGS}, - {"pushattributes", gl_pushattributes,METH_OLDARGS}, - {"pushmatrix", gl_pushmatrix, METH_OLDARGS}, - {"pushviewport", gl_pushviewport, METH_OLDARGS}, - {"qreset", gl_qreset, METH_OLDARGS}, - {"RGBmode", gl_RGBmode, METH_OLDARGS}, - {"singlebuffer", gl_singlebuffer, METH_OLDARGS}, - {"swapbuffers", gl_swapbuffers, METH_OLDARGS}, - {"gsync", gl_gsync, METH_OLDARGS}, - {"gflush", gl_gflush, METH_OLDARGS}, - {"tpon", gl_tpon, METH_OLDARGS}, - {"tpoff", gl_tpoff, METH_OLDARGS}, - {"clkon", gl_clkon, METH_OLDARGS}, - {"clkoff", gl_clkoff, METH_OLDARGS}, - {"ringbell", gl_ringbell, METH_OLDARGS}, - {"gbegin", gl_gbegin, METH_OLDARGS}, - {"textinit", gl_textinit, METH_OLDARGS}, - {"initnames", gl_initnames, METH_OLDARGS}, - {"pclos", gl_pclos, METH_OLDARGS}, - {"popname", gl_popname, METH_OLDARGS}, - {"spclos", gl_spclos, METH_OLDARGS}, - {"zclear", gl_zclear, METH_OLDARGS}, - {"screenspace", gl_screenspace, METH_OLDARGS}, - {"reshapeviewport", gl_reshapeviewport, METH_OLDARGS}, - {"winpush", gl_winpush, METH_OLDARGS}, - {"winpop", gl_winpop, METH_OLDARGS}, - {"foreground", gl_foreground, METH_OLDARGS}, - {"endfullscrn", gl_endfullscrn, METH_OLDARGS}, - {"endpupmode", gl_endpupmode, METH_OLDARGS}, - {"fullscrn", gl_fullscrn, METH_OLDARGS}, - {"pupmode", gl_pupmode, METH_OLDARGS}, - {"winconstraints", gl_winconstraints, METH_OLDARGS}, - {"pagecolor", gl_pagecolor, METH_OLDARGS}, - {"textcolor", gl_textcolor, METH_OLDARGS}, - {"color", gl_color, METH_OLDARGS}, - {"curveit", gl_curveit, METH_OLDARGS}, - {"font", gl_font, METH_OLDARGS}, - {"linewidth", gl_linewidth, METH_OLDARGS}, - {"setlinestyle", gl_setlinestyle, METH_OLDARGS}, - {"setmap", gl_setmap, METH_OLDARGS}, - {"swapinterval", gl_swapinterval, METH_OLDARGS}, - {"writemask", gl_writemask, METH_OLDARGS}, - {"textwritemask", gl_textwritemask, METH_OLDARGS}, - {"qdevice", gl_qdevice, METH_OLDARGS}, - {"unqdevice", gl_unqdevice, METH_OLDARGS}, - {"curvebasis", gl_curvebasis, METH_OLDARGS}, - {"curveprecision", gl_curveprecision,METH_OLDARGS}, - {"loadname", gl_loadname, METH_OLDARGS}, - {"passthrough", gl_passthrough, METH_OLDARGS}, - {"pushname", gl_pushname, METH_OLDARGS}, - {"setmonitor", gl_setmonitor, METH_OLDARGS}, - {"setshade", gl_setshade, METH_OLDARGS}, - {"setpattern", gl_setpattern, METH_OLDARGS}, - {"pagewritemask", gl_pagewritemask, METH_OLDARGS}, - {"callobj", gl_callobj, METH_OLDARGS}, - {"delobj", gl_delobj, METH_OLDARGS}, - {"editobj", gl_editobj, METH_OLDARGS}, - {"makeobj", gl_makeobj, METH_OLDARGS}, - {"maketag", gl_maketag, METH_OLDARGS}, - {"chunksize", gl_chunksize, METH_OLDARGS}, - {"compactify", gl_compactify, METH_OLDARGS}, - {"deltag", gl_deltag, METH_OLDARGS}, - {"lsrepeat", gl_lsrepeat, METH_OLDARGS}, - {"objinsert", gl_objinsert, METH_OLDARGS}, - {"objreplace", gl_objreplace, METH_OLDARGS}, - {"winclose", gl_winclose, METH_OLDARGS}, - {"blanktime", gl_blanktime, METH_OLDARGS}, - {"freepup", gl_freepup, METH_OLDARGS}, - {"backbuffer", gl_backbuffer, METH_OLDARGS}, - {"frontbuffer", gl_frontbuffer, METH_OLDARGS}, - {"lsbackup", gl_lsbackup, METH_OLDARGS}, - {"resetls", gl_resetls, METH_OLDARGS}, - {"lampon", gl_lampon, METH_OLDARGS}, - {"lampoff", gl_lampoff, METH_OLDARGS}, - {"setbell", gl_setbell, METH_OLDARGS}, - {"blankscreen", gl_blankscreen, METH_OLDARGS}, - {"depthcue", gl_depthcue, METH_OLDARGS}, - {"zbuffer", gl_zbuffer, METH_OLDARGS}, - {"backface", gl_backface, METH_OLDARGS}, - {"cmov2i", gl_cmov2i, METH_OLDARGS}, - {"draw2i", gl_draw2i, METH_OLDARGS}, - {"move2i", gl_move2i, METH_OLDARGS}, - {"pnt2i", gl_pnt2i, METH_OLDARGS}, - {"patchbasis", gl_patchbasis, METH_OLDARGS}, - {"patchprecision", gl_patchprecision, METH_OLDARGS}, - {"pdr2i", gl_pdr2i, METH_OLDARGS}, - {"pmv2i", gl_pmv2i, METH_OLDARGS}, - {"rpdr2i", gl_rpdr2i, METH_OLDARGS}, - {"rpmv2i", gl_rpmv2i, METH_OLDARGS}, - {"xfpt2i", gl_xfpt2i, METH_OLDARGS}, - {"objdelete", gl_objdelete, METH_OLDARGS}, - {"patchcurves", gl_patchcurves, METH_OLDARGS}, - {"minsize", gl_minsize, METH_OLDARGS}, - {"maxsize", gl_maxsize, METH_OLDARGS}, - {"keepaspect", gl_keepaspect, METH_OLDARGS}, - {"prefsize", gl_prefsize, METH_OLDARGS}, - {"stepunit", gl_stepunit, METH_OLDARGS}, - {"fudge", gl_fudge, METH_OLDARGS}, - {"winmove", gl_winmove, METH_OLDARGS}, - {"attachcursor", gl_attachcursor, METH_OLDARGS}, - {"deflinestyle", gl_deflinestyle, METH_OLDARGS}, - {"noise", gl_noise, METH_OLDARGS}, - {"picksize", gl_picksize, METH_OLDARGS}, - {"qenter", gl_qenter, METH_OLDARGS}, - {"setdepth", gl_setdepth, METH_OLDARGS}, - {"cmov2s", gl_cmov2s, METH_OLDARGS}, - {"draw2s", gl_draw2s, METH_OLDARGS}, - {"move2s", gl_move2s, METH_OLDARGS}, - {"pdr2s", gl_pdr2s, METH_OLDARGS}, - {"pmv2s", gl_pmv2s, METH_OLDARGS}, - {"pnt2s", gl_pnt2s, METH_OLDARGS}, - {"rdr2s", gl_rdr2s, METH_OLDARGS}, - {"rmv2s", gl_rmv2s, METH_OLDARGS}, - {"rpdr2s", gl_rpdr2s, METH_OLDARGS}, - {"rpmv2s", gl_rpmv2s, METH_OLDARGS}, - {"xfpt2s", gl_xfpt2s, METH_OLDARGS}, - {"cmov2", gl_cmov2, METH_OLDARGS}, - {"draw2", gl_draw2, METH_OLDARGS}, - {"move2", gl_move2, METH_OLDARGS}, - {"pnt2", gl_pnt2, METH_OLDARGS}, - {"pdr2", gl_pdr2, METH_OLDARGS}, - {"pmv2", gl_pmv2, METH_OLDARGS}, - {"rdr2", gl_rdr2, METH_OLDARGS}, - {"rmv2", gl_rmv2, METH_OLDARGS}, - {"rpdr2", gl_rpdr2, METH_OLDARGS}, - {"rpmv2", gl_rpmv2, METH_OLDARGS}, - {"xfpt2", gl_xfpt2, METH_OLDARGS}, - {"loadmatrix", gl_loadmatrix, METH_OLDARGS}, - {"multmatrix", gl_multmatrix, METH_OLDARGS}, - {"crv", gl_crv, METH_OLDARGS}, - {"rcrv", gl_rcrv, METH_OLDARGS}, - {"addtopup", gl_addtopup, METH_OLDARGS}, - {"charstr", gl_charstr, METH_OLDARGS}, - {"getport", gl_getport, METH_OLDARGS}, - {"strwidth", gl_strwidth, METH_OLDARGS}, - {"winopen", gl_winopen, METH_OLDARGS}, - {"wintitle", gl_wintitle, METH_OLDARGS}, - {"polf", gl_polf, METH_OLDARGS}, - {"polf2", gl_polf2, METH_OLDARGS}, - {"poly", gl_poly, METH_OLDARGS}, - {"poly2", gl_poly2, METH_OLDARGS}, - {"crvn", gl_crvn, METH_OLDARGS}, - {"rcrvn", gl_rcrvn, METH_OLDARGS}, - {"polf2i", gl_polf2i, METH_OLDARGS}, - {"polfi", gl_polfi, METH_OLDARGS}, - {"poly2i", gl_poly2i, METH_OLDARGS}, - {"polyi", gl_polyi, METH_OLDARGS}, - {"polf2s", gl_polf2s, METH_OLDARGS}, - {"polfs", gl_polfs, METH_OLDARGS}, - {"polys", gl_polys, METH_OLDARGS}, - {"poly2s", gl_poly2s, METH_OLDARGS}, - {"defcursor", gl_defcursor, METH_OLDARGS}, - {"writepixels", gl_writepixels, METH_OLDARGS}, - {"defbasis", gl_defbasis, METH_OLDARGS}, - {"gewrite", gl_gewrite, METH_OLDARGS}, - {"rotate", gl_rotate, METH_OLDARGS}, - {"rot", gl_rot, METH_OLDARGS}, - {"circfi", gl_circfi, METH_OLDARGS}, - {"circi", gl_circi, METH_OLDARGS}, - {"cmovi", gl_cmovi, METH_OLDARGS}, - {"drawi", gl_drawi, METH_OLDARGS}, - {"movei", gl_movei, METH_OLDARGS}, - {"pnti", gl_pnti, METH_OLDARGS}, - {"newtag", gl_newtag, METH_OLDARGS}, - {"pdri", gl_pdri, METH_OLDARGS}, - {"pmvi", gl_pmvi, METH_OLDARGS}, - {"rdri", gl_rdri, METH_OLDARGS}, - {"rmvi", gl_rmvi, METH_OLDARGS}, - {"rpdri", gl_rpdri, METH_OLDARGS}, - {"rpmvi", gl_rpmvi, METH_OLDARGS}, - {"xfpti", gl_xfpti, METH_OLDARGS}, - {"circ", gl_circ, METH_OLDARGS}, - {"circf", gl_circf, METH_OLDARGS}, - {"cmov", gl_cmov, METH_OLDARGS}, - {"draw", gl_draw, METH_OLDARGS}, - {"move", gl_move, METH_OLDARGS}, - {"pnt", gl_pnt, METH_OLDARGS}, - {"scale", gl_scale, METH_OLDARGS}, - {"translate", gl_translate, METH_OLDARGS}, - {"pdr", gl_pdr, METH_OLDARGS}, - {"pmv", gl_pmv, METH_OLDARGS}, - {"rdr", gl_rdr, METH_OLDARGS}, - {"rmv", gl_rmv, METH_OLDARGS}, - {"rpdr", gl_rpdr, METH_OLDARGS}, - {"rpmv", gl_rpmv, METH_OLDARGS}, - {"xfpt", gl_xfpt, METH_OLDARGS}, - {"RGBcolor", gl_RGBcolor, METH_OLDARGS}, - {"RGBwritemask", gl_RGBwritemask, METH_OLDARGS}, - {"setcursor", gl_setcursor, METH_OLDARGS}, - {"tie", gl_tie, METH_OLDARGS}, - {"circfs", gl_circfs, METH_OLDARGS}, - {"circs", gl_circs, METH_OLDARGS}, - {"cmovs", gl_cmovs, METH_OLDARGS}, - {"draws", gl_draws, METH_OLDARGS}, - {"moves", gl_moves, METH_OLDARGS}, - {"pdrs", gl_pdrs, METH_OLDARGS}, - {"pmvs", gl_pmvs, METH_OLDARGS}, - {"pnts", gl_pnts, METH_OLDARGS}, - {"rdrs", gl_rdrs, METH_OLDARGS}, - {"rmvs", gl_rmvs, METH_OLDARGS}, - {"rpdrs", gl_rpdrs, METH_OLDARGS}, - {"rpmvs", gl_rpmvs, METH_OLDARGS}, - {"xfpts", gl_xfpts, METH_OLDARGS}, - {"curorigin", gl_curorigin, METH_OLDARGS}, - {"cyclemap", gl_cyclemap, METH_OLDARGS}, - {"patch", gl_patch, METH_OLDARGS}, - {"splf", gl_splf, METH_OLDARGS}, - {"splf2", gl_splf2, METH_OLDARGS}, - {"splfi", gl_splfi, METH_OLDARGS}, - {"splf2i", gl_splf2i, METH_OLDARGS}, - {"splfs", gl_splfs, METH_OLDARGS}, - {"splf2s", gl_splf2s, METH_OLDARGS}, - {"rpatch", gl_rpatch, METH_OLDARGS}, - {"ortho2", gl_ortho2, METH_OLDARGS}, - {"rect", gl_rect, METH_OLDARGS}, - {"rectf", gl_rectf, METH_OLDARGS}, - {"xfpt4", gl_xfpt4, METH_OLDARGS}, - {"textport", gl_textport, METH_OLDARGS}, - {"mapcolor", gl_mapcolor, METH_OLDARGS}, - {"scrmask", gl_scrmask, METH_OLDARGS}, - {"setvaluator", gl_setvaluator, METH_OLDARGS}, - {"viewport", gl_viewport, METH_OLDARGS}, - {"shaderange", gl_shaderange, METH_OLDARGS}, - {"xfpt4s", gl_xfpt4s, METH_OLDARGS}, - {"rectfi", gl_rectfi, METH_OLDARGS}, - {"recti", gl_recti, METH_OLDARGS}, - {"xfpt4i", gl_xfpt4i, METH_OLDARGS}, - {"prefposition", gl_prefposition, METH_OLDARGS}, - {"arc", gl_arc, METH_OLDARGS}, - {"arcf", gl_arcf, METH_OLDARGS}, - {"arcfi", gl_arcfi, METH_OLDARGS}, - {"arci", gl_arci, METH_OLDARGS}, - {"bbox2", gl_bbox2, METH_OLDARGS}, - {"bbox2i", gl_bbox2i, METH_OLDARGS}, - {"bbox2s", gl_bbox2s, METH_OLDARGS}, - {"blink", gl_blink, METH_OLDARGS}, - {"ortho", gl_ortho, METH_OLDARGS}, - {"window", gl_window, METH_OLDARGS}, - {"lookat", gl_lookat, METH_OLDARGS}, - {"perspective", gl_perspective, METH_OLDARGS}, - {"polarview", gl_polarview, METH_OLDARGS}, - {"arcfs", gl_arcfs, METH_OLDARGS}, - {"arcs", gl_arcs, METH_OLDARGS}, - {"rectcopy", gl_rectcopy, METH_OLDARGS}, - {"RGBcursor", gl_RGBcursor, METH_OLDARGS}, - {"getbutton", gl_getbutton, METH_OLDARGS}, - {"getcmmode", gl_getcmmode, METH_OLDARGS}, - {"getlsbackup", gl_getlsbackup, METH_OLDARGS}, - {"getresetls", gl_getresetls, METH_OLDARGS}, - {"getdcm", gl_getdcm, METH_OLDARGS}, - {"getzbuffer", gl_getzbuffer, METH_OLDARGS}, - {"ismex", gl_ismex, METH_OLDARGS}, - {"isobj", gl_isobj, METH_OLDARGS}, - {"isqueued", gl_isqueued, METH_OLDARGS}, - {"istag", gl_istag, METH_OLDARGS}, - {"genobj", gl_genobj, METH_OLDARGS}, - {"gentag", gl_gentag, METH_OLDARGS}, - {"getbuffer", gl_getbuffer, METH_OLDARGS}, - {"getcolor", gl_getcolor, METH_OLDARGS}, - {"getdisplaymode", gl_getdisplaymode, METH_OLDARGS}, - {"getfont", gl_getfont, METH_OLDARGS}, - {"getheight", gl_getheight, METH_OLDARGS}, - {"gethitcode", gl_gethitcode, METH_OLDARGS}, - {"getlstyle", gl_getlstyle, METH_OLDARGS}, - {"getlwidth", gl_getlwidth, METH_OLDARGS}, - {"getmap", gl_getmap, METH_OLDARGS}, - {"getplanes", gl_getplanes, METH_OLDARGS}, - {"getwritemask", gl_getwritemask, METH_OLDARGS}, - {"qtest", gl_qtest, METH_OLDARGS}, - {"getlsrepeat", gl_getlsrepeat, METH_OLDARGS}, - {"getmonitor", gl_getmonitor, METH_OLDARGS}, - {"getopenobj", gl_getopenobj, METH_OLDARGS}, - {"getpattern", gl_getpattern, METH_OLDARGS}, - {"winget", gl_winget, METH_OLDARGS}, - {"winattach", gl_winattach, METH_OLDARGS}, - {"getothermonitor", gl_getothermonitor, METH_OLDARGS}, - {"newpup", gl_newpup, METH_OLDARGS}, - {"getvaluator", gl_getvaluator, METH_OLDARGS}, - {"winset", gl_winset, METH_OLDARGS}, - {"dopup", gl_dopup, METH_OLDARGS}, - {"getdepth", gl_getdepth, METH_OLDARGS}, - {"getcpos", gl_getcpos, METH_OLDARGS}, - {"getsize", gl_getsize, METH_OLDARGS}, - {"getorigin", gl_getorigin, METH_OLDARGS}, - {"getviewport", gl_getviewport, METH_OLDARGS}, - {"gettp", gl_gettp, METH_OLDARGS}, - {"getgpos", gl_getgpos, METH_OLDARGS}, - {"winposition", gl_winposition, METH_OLDARGS}, - {"gRGBcolor", gl_gRGBcolor, METH_OLDARGS}, - {"gRGBmask", gl_gRGBmask, METH_OLDARGS}, - {"getscrmask", gl_getscrmask, METH_OLDARGS}, - {"getmcolor", gl_getmcolor, METH_OLDARGS}, - {"mapw", gl_mapw, METH_OLDARGS}, - {"mapw2", gl_mapw2, METH_OLDARGS}, - {"getcursor", gl_getcursor, METH_OLDARGS}, - {"cmode", gl_cmode, METH_OLDARGS}, - {"concave", gl_concave, METH_OLDARGS}, - {"curstype", gl_curstype, METH_OLDARGS}, - {"drawmode", gl_drawmode, METH_OLDARGS}, - {"gammaramp", gl_gammaramp, METH_OLDARGS}, - {"getbackface", gl_getbackface, METH_OLDARGS}, - {"getdescender", gl_getdescender, METH_OLDARGS}, - {"getdrawmode", gl_getdrawmode, METH_OLDARGS}, - {"getmmode", gl_getmmode, METH_OLDARGS}, - {"getsm", gl_getsm, METH_OLDARGS}, - {"getvideo", gl_getvideo, METH_OLDARGS}, - {"imakebackground", gl_imakebackground, METH_OLDARGS}, - {"lmbind", gl_lmbind, METH_OLDARGS}, - {"lmdef", gl_lmdef, METH_OLDARGS}, - {"mmode", gl_mmode, METH_OLDARGS}, - {"normal", gl_normal, METH_OLDARGS}, - {"overlay", gl_overlay, METH_OLDARGS}, - {"RGBrange", gl_RGBrange, METH_OLDARGS}, - {"setvideo", gl_setvideo, METH_OLDARGS}, - {"shademodel", gl_shademodel, METH_OLDARGS}, - {"underlay", gl_underlay, METH_OLDARGS}, - {"bgnclosedline", gl_bgnclosedline, METH_OLDARGS}, - {"bgnline", gl_bgnline, METH_OLDARGS}, - {"bgnpoint", gl_bgnpoint, METH_OLDARGS}, - {"bgnpolygon", gl_bgnpolygon, METH_OLDARGS}, - {"bgnsurface", gl_bgnsurface, METH_OLDARGS}, - {"bgntmesh", gl_bgntmesh, METH_OLDARGS}, - {"bgntrim", gl_bgntrim, METH_OLDARGS}, - {"endclosedline", gl_endclosedline, METH_OLDARGS}, - {"endline", gl_endline, METH_OLDARGS}, - {"endpoint", gl_endpoint, METH_OLDARGS}, - {"endpolygon", gl_endpolygon, METH_OLDARGS}, - {"endsurface", gl_endsurface, METH_OLDARGS}, - {"endtmesh", gl_endtmesh, METH_OLDARGS}, - {"endtrim", gl_endtrim, METH_OLDARGS}, - {"blendfunction", gl_blendfunction, METH_OLDARGS}, - {"c3f", gl_c3f, METH_OLDARGS}, - {"c3i", gl_c3i, METH_OLDARGS}, - {"c3s", gl_c3s, METH_OLDARGS}, - {"c4f", gl_c4f, METH_OLDARGS}, - {"c4i", gl_c4i, METH_OLDARGS}, - {"c4s", gl_c4s, METH_OLDARGS}, - {"colorf", gl_colorf, METH_OLDARGS}, - {"cpack", gl_cpack, METH_OLDARGS}, - {"czclear", gl_czclear, METH_OLDARGS}, - {"dglclose", gl_dglclose, METH_OLDARGS}, - {"dglopen", gl_dglopen, METH_OLDARGS}, - {"getgdesc", gl_getgdesc, METH_OLDARGS}, - {"getnurbsproperty", gl_getnurbsproperty, METH_OLDARGS}, - {"glcompat", gl_glcompat, METH_OLDARGS}, - {"iconsize", gl_iconsize, METH_OLDARGS}, - {"icontitle", gl_icontitle, METH_OLDARGS}, - {"lRGBrange", gl_lRGBrange, METH_OLDARGS}, - {"linesmooth", gl_linesmooth, METH_OLDARGS}, - {"lmcolor", gl_lmcolor, METH_OLDARGS}, - {"logicop", gl_logicop, METH_OLDARGS}, - {"lsetdepth", gl_lsetdepth, METH_OLDARGS}, - {"lshaderange", gl_lshaderange, METH_OLDARGS}, - {"n3f", gl_n3f, METH_OLDARGS}, - {"noborder", gl_noborder, METH_OLDARGS}, - {"pntsmooth", gl_pntsmooth, METH_OLDARGS}, - {"readsource", gl_readsource, METH_OLDARGS}, - {"rectzoom", gl_rectzoom, METH_OLDARGS}, - {"sbox", gl_sbox, METH_OLDARGS}, - {"sboxi", gl_sboxi, METH_OLDARGS}, - {"sboxs", gl_sboxs, METH_OLDARGS}, - {"sboxf", gl_sboxf, METH_OLDARGS}, - {"sboxfi", gl_sboxfi, METH_OLDARGS}, - {"sboxfs", gl_sboxfs, METH_OLDARGS}, - {"setnurbsproperty", gl_setnurbsproperty, METH_OLDARGS}, - {"setpup", gl_setpup, METH_OLDARGS}, - {"smoothline", gl_smoothline, METH_OLDARGS}, - {"subpixel", gl_subpixel, METH_OLDARGS}, - {"swaptmesh", gl_swaptmesh, METH_OLDARGS}, - {"swinopen", gl_swinopen, METH_OLDARGS}, - {"v2f", gl_v2f, METH_OLDARGS}, - {"v2i", gl_v2i, METH_OLDARGS}, - {"v2s", gl_v2s, METH_OLDARGS}, - {"v3f", gl_v3f, METH_OLDARGS}, - {"v3i", gl_v3i, METH_OLDARGS}, - {"v3s", gl_v3s, METH_OLDARGS}, - {"v4f", gl_v4f, METH_OLDARGS}, - {"v4i", gl_v4i, METH_OLDARGS}, - {"v4s", gl_v4s, METH_OLDARGS}, - {"videocmd", gl_videocmd, METH_OLDARGS}, - {"windepth", gl_windepth, METH_OLDARGS}, - {"wmpack", gl_wmpack, METH_OLDARGS}, - {"zdraw", gl_zdraw, METH_OLDARGS}, - {"zfunction", gl_zfunction, METH_OLDARGS}, - {"zsource", gl_zsource, METH_OLDARGS}, - {"zwritemask", gl_zwritemask, METH_OLDARGS}, - {"v2d", gl_v2d, METH_OLDARGS}, - {"v3d", gl_v3d, METH_OLDARGS}, - {"v4d", gl_v4d, METH_OLDARGS}, - {"pixmode", gl_pixmode, METH_OLDARGS}, - {"qgetfd", gl_qgetfd, METH_OLDARGS}, - {"dither", gl_dither, METH_OLDARGS}, - {NULL, NULL} /* Sentinel */ -}; - -void -initgl(void) -{ - (void) Py_InitModule("gl", gl_methods); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/grpmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/grpmodule.c deleted file mode 100644 index 576b8c68..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/grpmodule.c +++ /dev/null @@ -1,177 +0,0 @@ - -/* UNIX group file access module */ - -#include "Python.h" -#include "structseq.h" - -#include -#include - -static PyStructSequence_Field struct_group_type_fields[] = { - {"gr_name", "group name"}, - {"gr_passwd", "password"}, - {"gr_gid", "group id"}, - {"gr_mem", "group memebers"}, - {0} -}; - -PyDoc_STRVAR(struct_group__doc__, -"grp.struct_group: Results from getgr*() routines.\n\n\ -This object may be accessed either as a tuple of\n\ - (gr_name,gr_passwd,gr_gid,gr_mem)\n\ -or via the object attributes as named in the above tuple.\n"); - -static PyStructSequence_Desc struct_group_type_desc = { - "grp.struct_group", - struct_group__doc__, - struct_group_type_fields, - 4, -}; - - -static PyTypeObject StructGrpType; - -static PyObject * -mkgrent(struct group *p) -{ - int setIndex = 0; - PyObject *v = PyStructSequence_New(&StructGrpType), *w; - char **member; - - if (v == NULL) - return NULL; - - if ((w = PyList_New(0)) == NULL) { - Py_DECREF(v); - return NULL; - } - for (member = p->gr_mem; *member != NULL; member++) { - PyObject *x = PyString_FromString(*member); - if (x == NULL || PyList_Append(w, x) != 0) { - Py_XDECREF(x); - Py_DECREF(w); - Py_DECREF(v); - return NULL; - } - Py_DECREF(x); - } - -#define SET(i,val) PyStructSequence_SET_ITEM(v, i, val) - SET(setIndex++, PyString_FromString(p->gr_name)); -#ifdef __VMS - SET(setIndex++, Py_None); - Py_INCREF(Py_None); -#else - if (p->gr_passwd) - SET(setIndex++, PyString_FromString(p->gr_passwd)); - else { - SET(setIndex++, Py_None); - Py_INCREF(Py_None); - } -#endif - SET(setIndex++, PyInt_FromLong((long) p->gr_gid)); - SET(setIndex++, w); -#undef SET - - if (PyErr_Occurred()) { - Py_DECREF(v); - Py_DECREF(w); - return NULL; - } - - return v; -} - -static PyObject * -grp_getgrgid(PyObject *self, PyObject *args) -{ - int gid; - struct group *p; - if (!PyArg_ParseTuple(args, "i:getgrgid", &gid)) - return NULL; - if ((p = getgrgid(gid)) == NULL) { - PyErr_SetString(PyExc_KeyError, "getgrgid(): gid not found"); - return NULL; - } - return mkgrent(p); -} - -static PyObject * -grp_getgrnam(PyObject *self, PyObject *args) -{ - char *name; - struct group *p; - if (!PyArg_ParseTuple(args, "s:getgrnam", &name)) - return NULL; - if ((p = getgrnam(name)) == NULL) { - PyErr_SetString(PyExc_KeyError, "getgrnam(): name not found"); - return NULL; - } - return mkgrent(p); -} - -static PyObject * -grp_getgrall(PyObject *self, PyObject *args) -{ - PyObject *d; - struct group *p; - - if (!PyArg_ParseTuple(args, ":getgrall")) - return NULL; - if ((d = PyList_New(0)) == NULL) - return NULL; - setgrent(); - while ((p = getgrent()) != NULL) { - PyObject *v = mkgrent(p); - if (v == NULL || PyList_Append(d, v) != 0) { - Py_XDECREF(v); - Py_DECREF(d); - return NULL; - } - Py_DECREF(v); - } - endgrent(); - return d; -} - -static PyMethodDef grp_methods[] = { - {"getgrgid", grp_getgrgid, METH_VARARGS, - "getgrgid(id) -> tuple\n\ -Return the group database entry for the given numeric group ID. If\n\ -id is not valid, raise KeyError."}, - {"getgrnam", grp_getgrnam, METH_VARARGS, - "getgrnam(name) -> tuple\n\ -Return the group database entry for the given group name. If\n\ -name is not valid, raise KeyError."}, - {"getgrall", grp_getgrall, METH_VARARGS, - "getgrall() -> list of tuples\n\ -Return a list of all available group entries, in arbitrary order."}, - {NULL, NULL} /* sentinel */ -}; - -PyDoc_STRVAR(grp__doc__, -"Access to the Unix group database.\n\ -\n\ -Group entries are reported as 4-tuples containing the following fields\n\ -from the group database, in order:\n\ -\n\ - name - name of the group\n\ - passwd - group password (encrypted); often empty\n\ - gid - numeric ID of the group\n\ - mem - list of members\n\ -\n\ -The gid is an integer, name and password are strings. (Note that most\n\ -users are not explicitly listed as members of the groups they are in\n\ -according to the password database. Check both databases to get\n\ -complete membership information.)"); - - -PyMODINIT_FUNC -initgrp(void) -{ - PyObject *m, *d; - m = Py_InitModule3("grp", grp_methods, grp__doc__); - d = PyModule_GetDict(m); - PyStructSequence_InitType(&StructGrpType, &struct_group_type_desc); - PyDict_SetItemString(d, "struct_group", (PyObject *) &StructGrpType); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/imageop.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/imageop.c deleted file mode 100644 index dd103ee4..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/imageop.c +++ /dev/null @@ -1,708 +0,0 @@ - -/* imageopmodule - Various operations on pictures */ - -#ifdef sun -#define signed -#endif - -#include "Python.h" - -#if SIZEOF_INT == 4 -typedef int Py_Int32; -typedef unsigned int Py_UInt32; -#else -#if SIZEOF_LONG == 4 -typedef long Py_Int32; -typedef unsigned long Py_UInt32; -#else -#error "No 4-byte integral type" -#endif -#endif - -#define CHARP(cp, xmax, x, y) ((char *)(cp+y*xmax+x)) -#define SHORTP(cp, xmax, x, y) ((short *)(cp+2*(y*xmax+x))) -#define LONGP(cp, xmax, x, y) ((Py_Int32 *)(cp+4*(y*xmax+x))) - -static PyObject *ImageopError; - -static PyObject * -imageop_crop(PyObject *self, PyObject *args) -{ - char *cp, *ncp; - short *nsp; - Py_Int32 *nlp; - int len, size, x, y, newx1, newx2, newy1, newy2; - int ix, iy, xstep, ystep; - PyObject *rv; - - if ( !PyArg_ParseTuple(args, "s#iiiiiii", &cp, &len, &size, &x, &y, - &newx1, &newy1, &newx2, &newy2) ) - return 0; - - if ( size != 1 && size != 2 && size != 4 ) { - PyErr_SetString(ImageopError, "Size should be 1, 2 or 4"); - return 0; - } - if ( len != size*x*y ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - xstep = (newx1 < newx2)? 1 : -1; - ystep = (newy1 < newy2)? 1 : -1; - - rv = PyString_FromStringAndSize(NULL, - (abs(newx2-newx1)+1)*(abs(newy2-newy1)+1)*size); - if ( rv == 0 ) - return 0; - ncp = (char *)PyString_AsString(rv); - nsp = (short *)ncp; - nlp = (Py_Int32 *)ncp; - newy2 += ystep; - newx2 += xstep; - for( iy = newy1; iy != newy2; iy+=ystep ) { - for ( ix = newx1; ix != newx2; ix+=xstep ) { - if ( iy < 0 || iy >= y || ix < 0 || ix >= x ) { - if ( size == 1 ) - *ncp++ = 0; - else - *nlp++ = 0; - } else { - if ( size == 1 ) - *ncp++ = *CHARP(cp, x, ix, iy); - else if ( size == 2 ) - *nsp++ = *SHORTP(cp, x, ix, iy); - else - *nlp++ = *LONGP(cp, x, ix, iy); - } - } - } - return rv; -} - -static PyObject * -imageop_scale(PyObject *self, PyObject *args) -{ - char *cp, *ncp; - short *nsp; - Py_Int32 *nlp; - int len, size, x, y, newx, newy; - int ix, iy; - int oix, oiy; - PyObject *rv; - - if ( !PyArg_ParseTuple(args, "s#iiiii", - &cp, &len, &size, &x, &y, &newx, &newy) ) - return 0; - - if ( size != 1 && size != 2 && size != 4 ) { - PyErr_SetString(ImageopError, "Size should be 1, 2 or 4"); - return 0; - } - if ( len != size*x*y ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, newx*newy*size); - if ( rv == 0 ) - return 0; - ncp = (char *)PyString_AsString(rv); - nsp = (short *)ncp; - nlp = (Py_Int32 *)ncp; - for( iy = 0; iy < newy; iy++ ) { - for ( ix = 0; ix < newx; ix++ ) { - oix = ix * x / newx; - oiy = iy * y / newy; - if ( size == 1 ) - *ncp++ = *CHARP(cp, x, oix, oiy); - else if ( size == 2 ) - *nsp++ = *SHORTP(cp, x, oix, oiy); - else - *nlp++ = *LONGP(cp, x, oix, oiy); - } - } - return rv; -} - -/* Note: this routine can use a bit of optimizing */ - -static PyObject * -imageop_tovideo(PyObject *self, PyObject *args) -{ - int maxx, maxy, x, y, len; - int i; - unsigned char *cp, *ncp; - int width; - PyObject *rv; - - - if ( !PyArg_ParseTuple(args, "s#iii", &cp, &len, &width, &maxx, &maxy) ) - return 0; - - if ( width != 1 && width != 4 ) { - PyErr_SetString(ImageopError, "Size should be 1 or 4"); - return 0; - } - if ( maxx*maxy*width != len ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, len); - if ( rv == 0 ) - return 0; - ncp = (unsigned char *)PyString_AsString(rv); - - if ( width == 1 ) { - memcpy(ncp, cp, maxx); /* Copy first line */ - ncp += maxx; - for (y=1; y> 1; - } - } - } else { - memcpy(ncp, cp, maxx*4); /* Copy first line */ - ncp += maxx*4; - for (y=1; y> 1; - i++; - *ncp++ = ((int)cp[i] + (int)cp[i-4*maxx]) >> 1; - i++; - *ncp++ = ((int)cp[i] + (int)cp[i-4*maxx]) >> 1; - } - } - } - return rv; -} - -static PyObject * -imageop_grey2mono(PyObject *self, PyObject *args) -{ - int tres, x, y, len; - unsigned char *cp, *ncp; - unsigned char ovalue; - PyObject *rv; - int i, bit; - - - if ( !PyArg_ParseTuple(args, "s#iii", &cp, &len, &x, &y, &tres) ) - return 0; - - if ( x*y != len ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, (len+7)/8); - if ( rv == 0 ) - return 0; - ncp = (unsigned char *)PyString_AsString(rv); - - bit = 0x80; - ovalue = 0; - for ( i=0; i < len; i++ ) { - if ( (int)cp[i] > tres ) - ovalue |= bit; - bit >>= 1; - if ( bit == 0 ) { - *ncp++ = ovalue; - bit = 0x80; - ovalue = 0; - } - } - if ( bit != 0x80 ) - *ncp++ = ovalue; - return rv; -} - -static PyObject * -imageop_grey2grey4(PyObject *self, PyObject *args) -{ - int x, y, len; - unsigned char *cp, *ncp; - unsigned char ovalue; - PyObject *rv; - int i; - int pos; - - - if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) ) - return 0; - - if ( x*y != len ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, (len+1)/2); - if ( rv == 0 ) - return 0; - ncp = (unsigned char *)PyString_AsString(rv); - pos = 0; - ovalue = 0; - for ( i=0; i < len; i++ ) { - ovalue |= ((int)cp[i] & 0xf0) >> pos; - pos += 4; - if ( pos == 8 ) { - *ncp++ = ovalue; - ovalue = 0; - pos = 0; - } - } - if ( pos != 0 ) - *ncp++ = ovalue; - return rv; -} - -static PyObject * -imageop_grey2grey2(PyObject *self, PyObject *args) -{ - int x, y, len; - unsigned char *cp, *ncp; - unsigned char ovalue; - PyObject *rv; - int i; - int pos; - - - if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) ) - return 0; - - if ( x*y != len ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, (len+3)/4); - if ( rv == 0 ) - return 0; - ncp = (unsigned char *)PyString_AsString(rv); - pos = 0; - ovalue = 0; - for ( i=0; i < len; i++ ) { - ovalue |= ((int)cp[i] & 0xc0) >> pos; - pos += 2; - if ( pos == 8 ) { - *ncp++ = ovalue; - ovalue = 0; - pos = 0; - } - } - if ( pos != 0 ) - *ncp++ = ovalue; - return rv; -} - -static PyObject * -imageop_dither2mono(PyObject *self, PyObject *args) -{ - int sum, x, y, len; - unsigned char *cp, *ncp; - unsigned char ovalue; - PyObject *rv; - int i, bit; - - - if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) ) - return 0; - - if ( x*y != len ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, (len+7)/8); - if ( rv == 0 ) - return 0; - ncp = (unsigned char *)PyString_AsString(rv); - - bit = 0x80; - ovalue = 0; - sum = 0; - for ( i=0; i < len; i++ ) { - sum += cp[i]; - if ( sum >= 256 ) { - sum -= 256; - ovalue |= bit; - } - bit >>= 1; - if ( bit == 0 ) { - *ncp++ = ovalue; - bit = 0x80; - ovalue = 0; - } - } - if ( bit != 0x80 ) - *ncp++ = ovalue; - return rv; -} - -static PyObject * -imageop_dither2grey2(PyObject *self, PyObject *args) -{ - int x, y, len; - unsigned char *cp, *ncp; - unsigned char ovalue; - PyObject *rv; - int i; - int pos; - int sum = 0, nvalue; - - - if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) ) - return 0; - - if ( x*y != len ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, (len+3)/4); - if ( rv == 0 ) - return 0; - ncp = (unsigned char *)PyString_AsString(rv); - pos = 1; - ovalue = 0; - for ( i=0; i < len; i++ ) { - sum += cp[i]; - nvalue = sum & 0x180; - sum -= nvalue; - ovalue |= nvalue >> pos; - pos += 2; - if ( pos == 9 ) { - *ncp++ = ovalue; - ovalue = 0; - pos = 1; - } - } - if ( pos != 0 ) - *ncp++ = ovalue; - return rv; -} - -static PyObject * -imageop_mono2grey(PyObject *self, PyObject *args) -{ - int v0, v1, x, y, len, nlen; - unsigned char *cp, *ncp; - PyObject *rv; - int i, bit; - - if ( !PyArg_ParseTuple(args, "s#iiii", &cp, &len, &x, &y, &v0, &v1) ) - return 0; - - nlen = x*y; - if ( (nlen+7)/8 != len ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, nlen); - if ( rv == 0 ) - return 0; - ncp = (unsigned char *)PyString_AsString(rv); - - bit = 0x80; - for ( i=0; i < nlen; i++ ) { - if ( *cp & bit ) - *ncp++ = v1; - else - *ncp++ = v0; - bit >>= 1; - if ( bit == 0 ) { - bit = 0x80; - cp++; - } - } - return rv; -} - -static PyObject * -imageop_grey22grey(PyObject *self, PyObject *args) -{ - int x, y, len, nlen; - unsigned char *cp, *ncp; - PyObject *rv; - int i, pos, value = 0, nvalue; - - if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) ) - return 0; - - nlen = x*y; - if ( (nlen+3)/4 != len ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, nlen); - if ( rv == 0 ) - return 0; - ncp = (unsigned char *)PyString_AsString(rv); - - pos = 0; - for ( i=0; i < nlen; i++ ) { - if ( pos == 0 ) { - value = *cp++; - pos = 8; - } - pos -= 2; - nvalue = (value >> pos) & 0x03; - *ncp++ = nvalue | (nvalue << 2) | - (nvalue << 4) | (nvalue << 6); - } - return rv; -} - -static PyObject * -imageop_grey42grey(PyObject *self, PyObject *args) -{ - int x, y, len, nlen; - unsigned char *cp, *ncp; - PyObject *rv; - int i, pos, value = 0, nvalue; - - if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) ) - return 0; - - nlen = x*y; - if ( (nlen+1)/2 != len ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, nlen); - if ( rv == 0 ) - return 0; - ncp = (unsigned char *)PyString_AsString(rv); - - pos = 0; - for ( i=0; i < nlen; i++ ) { - if ( pos == 0 ) { - value = *cp++; - pos = 8; - } - pos -= 4; - nvalue = (value >> pos) & 0x0f; - *ncp++ = nvalue | (nvalue << 4); - } - return rv; -} - -static PyObject * -imageop_rgb2rgb8(PyObject *self, PyObject *args) -{ - int x, y, len, nlen; - Py_UInt32 *cp; - unsigned char *ncp; - PyObject *rv; - int i, r, g, b; - Py_UInt32 value, nvalue; - - if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) ) - return 0; - - nlen = x*y; - if ( nlen*4 != len ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, nlen); - if ( rv == 0 ) - return 0; - ncp = (unsigned char *)PyString_AsString(rv); - - for ( i=0; i < nlen; i++ ) { - /* Bits in source: aaaaaaaa BBbbbbbb GGGggggg RRRrrrrr */ - value = *cp++; -#if 0 - r = (value >> 5) & 7; - g = (value >> 13) & 7; - b = (value >> 22) & 3; -#else - r = (int) ((value & 0xff) / 255. * 7. + .5); - g = (int) (((value >> 8) & 0xff) / 255. * 7. + .5); - b = (int) (((value >> 16) & 0xff) / 255. * 3. + .5); -#endif - nvalue = (r<<5) | (b<<3) | g; - *ncp++ = (unsigned char)nvalue; - } - return rv; -} - -static PyObject * -imageop_rgb82rgb(PyObject *self, PyObject *args) -{ - int x, y, len, nlen; - unsigned char *cp; - Py_UInt32 *ncp; - PyObject *rv; - int i, r, g, b; - Py_UInt32 value, nvalue; - - if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) ) - return 0; - - nlen = x*y; - if ( nlen != len ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, nlen*4); - if ( rv == 0 ) - return 0; - ncp = (Py_UInt32 *)PyString_AsString(rv); - - for ( i=0; i < nlen; i++ ) { - /* Bits in source: RRRBBGGG - ** Red and Green are multiplied by 36.5, Blue by 85 - */ - value = *cp++; - r = (value >> 5) & 7; - g = (value ) & 7; - b = (value >> 3) & 3; - r = (r<<5) | (r<<3) | (r>>1); - g = (g<<5) | (g<<3) | (g>>1); - b = (b<<6) | (b<<4) | (b<<2) | b; - nvalue = r | (g<<8) | (b<<16); - *ncp++ = nvalue; - } - return rv; -} - -static PyObject * -imageop_rgb2grey(PyObject *self, PyObject *args) -{ - int x, y, len, nlen; - Py_UInt32 *cp; - unsigned char *ncp; - PyObject *rv; - int i, r, g, b; - Py_UInt32 value, nvalue; - - if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) ) - return 0; - - nlen = x*y; - if ( nlen*4 != len ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, nlen); - if ( rv == 0 ) - return 0; - ncp = (unsigned char *)PyString_AsString(rv); - - for ( i=0; i < nlen; i++ ) { - value = *cp++; - r = (value ) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - nvalue = (int)(0.30*r + 0.59*g + 0.11*b); - if ( nvalue > 255 ) nvalue = 255; - *ncp++ = (unsigned char)nvalue; - } - return rv; -} - -static PyObject * -imageop_grey2rgb(PyObject *self, PyObject *args) -{ - int x, y, len, nlen; - unsigned char *cp; - Py_UInt32 *ncp; - PyObject *rv; - int i; - Py_UInt32 value; - - if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) ) - return 0; - - nlen = x*y; - if ( nlen != len ) { - PyErr_SetString(ImageopError, "String has incorrect length"); - return 0; - } - - rv = PyString_FromStringAndSize(NULL, nlen*4); - if ( rv == 0 ) - return 0; - ncp = (Py_UInt32 *)PyString_AsString(rv); - - for ( i=0; i < nlen; i++ ) { - value = *cp++; - *ncp++ = value | (value << 8 ) | (value << 16); - } - return rv; -} - -/* -static object * -imageop_mul(object *self, object *args) -{ - char *cp, *ncp; - int len, size, x, y; - object *rv; - int i; - - if ( !getargs(args, "(s#iii)", &cp, &len, &size, &x, &y) ) - return 0; - - if ( size != 1 && size != 4 ) { - err_setstr(ImageopError, "Size should be 1 or 4"); - return 0; - } - if ( len != size*x*y ) { - err_setstr(ImageopError, "String has incorrect length"); - return 0; - } - - rv = newsizedstringobject(NULL, XXXX); - if ( rv == 0 ) - return 0; - ncp = (char *)getstringvalue(rv); - - - for ( i=0; i < len; i += size ) { - } - return rv; -} -*/ - -static PyMethodDef imageop_methods[] = { - { "crop", imageop_crop, METH_VARARGS }, - { "scale", imageop_scale, METH_VARARGS }, - { "grey2mono", imageop_grey2mono, METH_VARARGS }, - { "grey2grey2", imageop_grey2grey2, METH_VARARGS }, - { "grey2grey4", imageop_grey2grey4, METH_VARARGS }, - { "dither2mono", imageop_dither2mono, METH_VARARGS }, - { "dither2grey2", imageop_dither2grey2, METH_VARARGS }, - { "mono2grey", imageop_mono2grey, METH_VARARGS }, - { "grey22grey", imageop_grey22grey, METH_VARARGS }, - { "grey42grey", imageop_grey42grey, METH_VARARGS }, - { "tovideo", imageop_tovideo, METH_VARARGS }, - { "rgb2rgb8", imageop_rgb2rgb8, METH_VARARGS }, - { "rgb82rgb", imageop_rgb82rgb, METH_VARARGS }, - { "rgb2grey", imageop_rgb2grey, METH_VARARGS }, - { "grey2rgb", imageop_grey2rgb, METH_VARARGS }, - { 0, 0 } -}; - - -PyMODINIT_FUNC -initimageop(void) -{ - PyObject *m, *d; - m = Py_InitModule("imageop", imageop_methods); - d = PyModule_GetDict(m); - ImageopError = PyErr_NewException("imageop.error", NULL, NULL); - if (ImageopError != NULL) - PyDict_SetItemString(d, "error", ImageopError); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/imgfile.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/imgfile.c deleted file mode 100644 index d68af005..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/imgfile.c +++ /dev/null @@ -1,502 +0,0 @@ - -/* IMGFILE module - Interface to sgi libimage */ - -/* XXX This module should be done better at some point. It should return -** an object of image file class, and have routines to manipulate these -** image files in a neater way (so you can get rgb images off a greyscale -** file, for instance, or do a straight display without having to get the -** image bits into python, etc). -** -** Warning: this module is very non-reentrant (esp. the readscaled stuff) -*/ - -#include "Python.h" - -#include - -#include "/usr/people/4Dgifts/iristools/include/izoom.h" - -/* Bunch of missing extern decls; keep gcc -Wall happy... */ -extern void i_seterror(); -extern void iclose(); -extern void filterzoom(); -extern void putrow(); -extern void getrow(); - -static PyObject * ImgfileError; /* Exception we raise for various trouble */ - -static int top_to_bottom; /* True if we want top-to-bottom images */ - -/* The image library does not always call the error hander :-(, - therefore we have a global variable indicating that it was called. - It is cleared by imgfile_open(). */ - -static int error_called; - - -/* The error handler */ - -static void -imgfile_error(char *str) -{ - PyErr_SetString(ImgfileError, str); - error_called = 1; - return; /* To imglib, which will return a failure indicator */ -} - - -/* Open an image file and return a pointer to it. - Make sure we raise an exception if we fail. */ - -static IMAGE * -imgfile_open(char *fname) -{ - IMAGE *image; - i_seterror(imgfile_error); - error_called = 0; - errno = 0; - if ( (image = iopen(fname, "r")) == NULL ) { - /* Error may already be set by imgfile_error */ - if ( !error_called ) { - if (errno) - PyErr_SetFromErrno(ImgfileError); - else - PyErr_SetString(ImgfileError, - "Can't open image file"); - } - return NULL; - } - return image; -} - -static PyObject * -imgfile_ttob(PyObject *self, PyObject *args) -{ - int newval; - PyObject *rv; - - if (!PyArg_ParseTuple(args, "i:ttob", &newval)) - return NULL; - rv = PyInt_FromLong(top_to_bottom); - top_to_bottom = newval; - return rv; -} - -static PyObject * -imgfile_read(PyObject *self, PyObject *args) -{ - char *fname; - PyObject *rv; - int xsize, ysize, zsize; - char *cdatap; - long *idatap; - static short rs[8192], gs[8192], bs[8192]; - int x, y; - IMAGE *image; - int yfirst, ylast, ystep; - - if ( !PyArg_ParseTuple(args, "s:read", &fname) ) - return NULL; - - if ( (image = imgfile_open(fname)) == NULL ) - return NULL; - - if ( image->colormap != CM_NORMAL ) { - iclose(image); - PyErr_SetString(ImgfileError, - "Can only handle CM_NORMAL images"); - return NULL; - } - if ( BPP(image->type) != 1 ) { - iclose(image); - PyErr_SetString(ImgfileError, - "Can't handle imgfiles with bpp!=1"); - return NULL; - } - xsize = image->xsize; - ysize = image->ysize; - zsize = image->zsize; - if ( zsize != 1 && zsize != 3) { - iclose(image); - PyErr_SetString(ImgfileError, - "Can only handle 1 or 3 byte pixels"); - return NULL; - } - if ( xsize > 8192 ) { - iclose(image); - PyErr_SetString(ImgfileError, - "Can't handle image with > 8192 columns"); - return NULL; - } - - if ( zsize == 3 ) zsize = 4; - rv = PyString_FromStringAndSize((char *)NULL, xsize*ysize*zsize); - if ( rv == NULL ) { - iclose(image); - return NULL; - } - cdatap = PyString_AsString(rv); - idatap = (long *)cdatap; - - if (top_to_bottom) { - yfirst = ysize-1; - ylast = -1; - ystep = -1; - } else { - yfirst = 0; - ylast = ysize; - ystep = 1; - } - for ( y=yfirst; y != ylast && !error_called; y += ystep ) { - if ( zsize == 1 ) { - getrow(image, rs, y, 0); - for(x=0; x= 4; - if ( !PyArg_ParseTuple(args, "sii|sd", - &fname, &xwtd, &ywtd, &filter, &blur) ) - return NULL; - - /* - ** Check parameters, open file and check type, rows, etc. - */ - if ( extended ) { - if ( strcmp(filter, "impulse") == 0 ) - fmode = IMPULSE; - else if ( strcmp( filter, "box") == 0 ) - fmode = BOX; - else if ( strcmp( filter, "triangle") == 0 ) - fmode = TRIANGLE; - else if ( strcmp( filter, "quadratic") == 0 ) - fmode = QUADRATIC; - else if ( strcmp( filter, "gaussian") == 0 ) - fmode = GAUSSIAN; - else { - PyErr_SetString(ImgfileError, "Unknown filter type"); - return NULL; - } - } - - if ( (image = imgfile_open(fname)) == NULL ) - return NULL; - - if ( image->colormap != CM_NORMAL ) { - iclose(image); - PyErr_SetString(ImgfileError, - "Can only handle CM_NORMAL images"); - return NULL; - } - if ( BPP(image->type) != 1 ) { - iclose(image); - PyErr_SetString(ImgfileError, - "Can't handle imgfiles with bpp!=1"); - return NULL; - } - xsize = image->xsize; - ysize = image->ysize; - zsize = image->zsize; - if ( zsize != 1 && zsize != 3) { - iclose(image); - PyErr_SetString(ImgfileError, - "Can only handle 1 or 3 byte pixels"); - return NULL; - } - if ( xsize > 8192 ) { - iclose(image); - PyErr_SetString(ImgfileError, - "Can't handle image with > 8192 columns"); - return NULL; - } - - if ( zsize == 3 ) zsize = 4; - rv = PyString_FromStringAndSize(NULL, xwtd*ywtd*zsize); - if ( rv == NULL ) { - iclose(image); - return NULL; - } - PyFPE_START_PROTECT("readscaled", return 0) - xfac = (float)xsize/(float)xwtd; - yfac = (float)ysize/(float)ywtd; - PyFPE_END_PROTECT(yfac) - cdatap = PyString_AsString(rv); - idatap = (long *)cdatap; - - if ( extended ) { - xscale(image, xsize, ysize, zsize, - idatap, xwtd, ywtd, fmode, blur); - } else { - if (top_to_bottom) { - yfirst = ywtd-1; - ylast = -1; - ystep = -1; - } else { - yfirst = 0; - ylast = ywtd; - ystep = 1; - } - for ( y=yfirst; y != ylast && !error_called; y += ystep ) { - yorig = (int)(y*yfac); - if ( zsize == 1 ) { - getrow(image, rs, yorig, 0); - for(x=0; xxsize, image->ysize, image->zsize); - iclose(image); - return rv; -} - -static PyObject * -imgfile_write(PyObject *self, PyObject *args) -{ - IMAGE *image; - char *fname; - int xsize, ysize, zsize, len; - char *cdatap; - long *idatap; - short rs[8192], gs[8192], bs[8192]; - short r, g, b; - long rgb; - int x, y; - int yfirst, ylast, ystep; - - - if ( !PyArg_ParseTuple(args, "ss#iii:write", - &fname, &cdatap, &len, &xsize, &ysize, &zsize) ) - return NULL; - - if ( zsize != 1 && zsize != 3 ) { - PyErr_SetString(ImgfileError, - "Can only handle 1 or 3 byte pixels"); - return NULL; - } - if ( len != xsize * ysize * (zsize == 1 ? 1 : 4) ) { - PyErr_SetString(ImgfileError, "Data does not match sizes"); - return NULL; - } - if ( xsize > 8192 ) { - PyErr_SetString(ImgfileError, - "Can't handle image with > 8192 columns"); - return NULL; - } - - error_called = 0; - errno = 0; - image =iopen(fname, "w", RLE(1), 3, xsize, ysize, zsize); - if ( image == 0 ) { - if ( ! error_called ) { - if (errno) - PyErr_SetFromErrno(ImgfileError); - else - PyErr_SetString(ImgfileError, - "Can't create image file"); - } - return NULL; - } - - idatap = (long *)cdatap; - - if (top_to_bottom) { - yfirst = ysize-1; - ylast = -1; - ystep = -1; - } else { - yfirst = 0; - ylast = ysize; - ystep = 1; - } - for ( y=yfirst; y != ylast && !error_called; y += ystep ) { - if ( zsize == 1 ) { - for( x=0; x> 8 ) & 0xff; - b = (rgb >> 16 ) & 0xff; - rs[x] = r; - gs[x] = g; - bs[x] = b; - } - putrow(image, rs, y, 0); - putrow(image, gs, y, 1); - putrow(image, bs, y, 2); - } - } - iclose(image); - if ( error_called ) - return NULL; - Py_INCREF(Py_None); - return Py_None; - -} - - -static PyMethodDef imgfile_methods[] = { - { "getsizes", imgfile_getsizes, METH_VARARGS }, - { "read", imgfile_read, METH_VARARGS }, - { "readscaled", imgfile_readscaled, METH_VARARGS}, - { "write", imgfile_write, METH_VARARGS }, - { "ttob", imgfile_ttob, METH_VARARGS }, - { NULL, NULL } /* Sentinel */ -}; - - -void -initimgfile(void) -{ - PyObject *m, *d; - m = Py_InitModule("imgfile", imgfile_methods); - d = PyModule_GetDict(m); - ImgfileError = PyErr_NewException("imgfile.error", NULL, NULL); - if (ImgfileError != NULL) - PyDict_SetItemString(d, "error", ImgfileError); -} - - - diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/itertoolsmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/itertoolsmodule.c deleted file mode 100644 index 3a12c2a4..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/itertoolsmodule.c +++ /dev/null @@ -1,1852 +0,0 @@ - -#include "Python.h" - -/* Itertools module written and maintained - by Raymond D. Hettinger - Copyright (c) 2003 Python Software Foundation. - All rights reserved. -*/ - -/* cycle object **********************************************************/ - -typedef struct { - PyObject_HEAD - PyObject *it; - PyObject *saved; - int firstpass; -} cycleobject; - -static PyTypeObject cycle_type; - -static PyObject * -cycle_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *it; - PyObject *iterable; - PyObject *saved; - cycleobject *lz; - - if (!PyArg_UnpackTuple(args, "cycle", 1, 1, &iterable)) - return NULL; - - /* Get iterator. */ - it = PyObject_GetIter(iterable); - if (it == NULL) - return NULL; - - saved = PyList_New(0); - if (saved == NULL) { - Py_DECREF(it); - return NULL; - } - - /* create cycleobject structure */ - lz = (cycleobject *)type->tp_alloc(type, 0); - if (lz == NULL) { - Py_DECREF(it); - Py_DECREF(saved); - return NULL; - } - lz->it = it; - lz->saved = saved; - lz->firstpass = 0; - - return (PyObject *)lz; -} - -static void -cycle_dealloc(cycleobject *lz) -{ - PyObject_GC_UnTrack(lz); - Py_XDECREF(lz->saved); - Py_XDECREF(lz->it); - lz->ob_type->tp_free(lz); -} - -static int -cycle_traverse(cycleobject *lz, visitproc visit, void *arg) -{ - int err; - - if (lz->it) { - err = visit(lz->it, arg); - if (err) - return err; - } - if (lz->saved) { - err = visit(lz->saved, arg); - if (err) - return err; - } - return 0; -} - -static PyObject * -cycle_next(cycleobject *lz) -{ - PyObject *item; - PyObject *it; - - while (1) { - item = PyIter_Next(lz->it); - if (item != NULL) { - if (!lz->firstpass) - PyList_Append(lz->saved, item); - return item; - } - if (PyList_Size(lz->saved) == 0) - return NULL; - it = PyObject_GetIter(lz->saved); - if (it == NULL) - return NULL; - Py_DECREF(lz->it); - lz->it = it; - lz->firstpass = 1; - } -} - -PyDoc_STRVAR(cycle_doc, -"cycle(iterable) --> cycle object\n\ -\n\ -Return elements from the iterable until it is exhausted.\n\ -Then repeat the sequence indefinitely."); - -static PyTypeObject cycle_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "itertools.cycle", /* tp_name */ - sizeof(cycleobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)cycle_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - cycle_doc, /* tp_doc */ - (traverseproc)cycle_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)cycle_next, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - cycle_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - - -/* dropwhile object **********************************************************/ - -typedef struct { - PyObject_HEAD - PyObject *func; - PyObject *it; - long start; -} dropwhileobject; - -static PyTypeObject dropwhile_type; - -static PyObject * -dropwhile_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *func, *seq; - PyObject *it; - dropwhileobject *lz; - - if (!PyArg_UnpackTuple(args, "dropwhile", 2, 2, &func, &seq)) - return NULL; - - /* Get iterator. */ - it = PyObject_GetIter(seq); - if (it == NULL) - return NULL; - - /* create dropwhileobject structure */ - lz = (dropwhileobject *)type->tp_alloc(type, 0); - if (lz == NULL) { - Py_DECREF(it); - return NULL; - } - Py_INCREF(func); - lz->func = func; - lz->it = it; - lz->start = 0; - - return (PyObject *)lz; -} - -static void -dropwhile_dealloc(dropwhileobject *lz) -{ - PyObject_GC_UnTrack(lz); - Py_XDECREF(lz->func); - Py_XDECREF(lz->it); - lz->ob_type->tp_free(lz); -} - -static int -dropwhile_traverse(dropwhileobject *lz, visitproc visit, void *arg) -{ - int err; - - if (lz->it) { - err = visit(lz->it, arg); - if (err) - return err; - } - if (lz->func) { - err = visit(lz->func, arg); - if (err) - return err; - } - return 0; -} - -static PyObject * -dropwhile_next(dropwhileobject *lz) -{ - PyObject *item, *good; - PyObject *it = lz->it; - long ok; - - for (;;) { - assert(PyIter_Check(it)); - item = (*it->ob_type->tp_iternext)(it); - if (item == NULL) - return NULL; - if (lz->start == 1) - return item; - - good = PyObject_CallFunctionObjArgs(lz->func, item, NULL); - if (good == NULL) { - Py_DECREF(item); - return NULL; - } - ok = PyObject_IsTrue(good); - Py_DECREF(good); - if (!ok) { - lz->start = 1; - return item; - } - Py_DECREF(item); - } -} - -PyDoc_STRVAR(dropwhile_doc, -"dropwhile(predicate, iterable) --> dropwhile object\n\ -\n\ -Drop items from the iterable while predicate(item) is true.\n\ -Afterwards, return every element until the iterable is exhausted."); - -static PyTypeObject dropwhile_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "itertools.dropwhile", /* tp_name */ - sizeof(dropwhileobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)dropwhile_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - dropwhile_doc, /* tp_doc */ - (traverseproc)dropwhile_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)dropwhile_next, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - dropwhile_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - - -/* takewhile object **********************************************************/ - -typedef struct { - PyObject_HEAD - PyObject *func; - PyObject *it; - long stop; -} takewhileobject; - -static PyTypeObject takewhile_type; - -static PyObject * -takewhile_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *func, *seq; - PyObject *it; - takewhileobject *lz; - - if (!PyArg_UnpackTuple(args, "takewhile", 2, 2, &func, &seq)) - return NULL; - - /* Get iterator. */ - it = PyObject_GetIter(seq); - if (it == NULL) - return NULL; - - /* create takewhileobject structure */ - lz = (takewhileobject *)type->tp_alloc(type, 0); - if (lz == NULL) { - Py_DECREF(it); - return NULL; - } - Py_INCREF(func); - lz->func = func; - lz->it = it; - lz->stop = 0; - - return (PyObject *)lz; -} - -static void -takewhile_dealloc(takewhileobject *lz) -{ - PyObject_GC_UnTrack(lz); - Py_XDECREF(lz->func); - Py_XDECREF(lz->it); - lz->ob_type->tp_free(lz); -} - -static int -takewhile_traverse(takewhileobject *lz, visitproc visit, void *arg) -{ - int err; - - if (lz->it) { - err = visit(lz->it, arg); - if (err) - return err; - } - if (lz->func) { - err = visit(lz->func, arg); - if (err) - return err; - } - return 0; -} - -static PyObject * -takewhile_next(takewhileobject *lz) -{ - PyObject *item, *good; - PyObject *it = lz->it; - long ok; - - if (lz->stop == 1) - return NULL; - - assert(PyIter_Check(it)); - item = (*it->ob_type->tp_iternext)(it); - if (item == NULL) - return NULL; - - good = PyObject_CallFunctionObjArgs(lz->func, item, NULL); - if (good == NULL) { - Py_DECREF(item); - return NULL; - } - ok = PyObject_IsTrue(good); - Py_DECREF(good); - if (ok) - return item; - Py_DECREF(item); - lz->stop = 1; - return NULL; -} - -PyDoc_STRVAR(takewhile_doc, -"takewhile(predicate, iterable) --> takewhile object\n\ -\n\ -Return successive entries from an iterable as long as the \n\ -predicate evaluates to true for each entry."); - -static PyTypeObject takewhile_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "itertools.takewhile", /* tp_name */ - sizeof(takewhileobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)takewhile_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - takewhile_doc, /* tp_doc */ - (traverseproc)takewhile_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)takewhile_next, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - takewhile_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - - -/* islice object ************************************************************/ - -typedef struct { - PyObject_HEAD - PyObject *it; - long next; - long stop; - long step; - long cnt; -} isliceobject; - -static PyTypeObject islice_type; - -static PyObject * -islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *seq; - long start=0, stop=-1, step=1; - PyObject *it, *a1=NULL, *a2=NULL; - int numargs; - isliceobject *lz; - - numargs = PyTuple_Size(args); - if (!PyArg_ParseTuple(args, "OO|Ol:islice", &seq, &a1, &a2, &step)) - return NULL; - - if (numargs == 2) { - if (a1 != Py_None) { - stop = PyInt_AsLong(a1); - if (stop == -1) { - if (PyErr_Occurred()) - PyErr_Clear(); - PyErr_SetString(PyExc_ValueError, - "Stop argument must be an integer or None."); - return NULL; - } - } - } else { - start = PyInt_AsLong(a1); - if (start == -1 && PyErr_Occurred()) { - PyErr_Clear(); - PyErr_SetString(PyExc_ValueError, - "Start argument must be an integer."); - return NULL; - } - if (a2 != Py_None) { - stop = PyInt_AsLong(a2); - if (stop == -1) { - if (PyErr_Occurred()) - PyErr_Clear(); - PyErr_SetString(PyExc_ValueError, - "Stop argument must be an integer or None."); - return NULL; - } - } - } - - if (start<0 || stop<-1) { - PyErr_SetString(PyExc_ValueError, - "Indices for islice() must be positive."); - return NULL; - } - - if (step<1) { - PyErr_SetString(PyExc_ValueError, - "Step must be one or larger for islice()."); - return NULL; - } - - /* Get iterator. */ - it = PyObject_GetIter(seq); - if (it == NULL) - return NULL; - - /* create isliceobject structure */ - lz = (isliceobject *)type->tp_alloc(type, 0); - if (lz == NULL) { - Py_DECREF(it); - return NULL; - } - lz->it = it; - lz->next = start; - lz->stop = stop; - lz->step = step; - lz->cnt = 0L; - - return (PyObject *)lz; -} - -static void -islice_dealloc(isliceobject *lz) -{ - PyObject_GC_UnTrack(lz); - Py_XDECREF(lz->it); - lz->ob_type->tp_free(lz); -} - -static int -islice_traverse(isliceobject *lz, visitproc visit, void *arg) -{ - if (lz->it) - return visit(lz->it, arg); - return 0; -} - -static PyObject * -islice_next(isliceobject *lz) -{ - PyObject *item; - PyObject *it = lz->it; - long oldnext; - - while (lz->cnt < lz->next) { - assert(PyIter_Check(it)); - item = (*it->ob_type->tp_iternext)(it); - if (item == NULL) - return NULL; - Py_DECREF(item); - lz->cnt++; - } - if (lz->stop != -1 && lz->cnt >= lz->stop) - return NULL; - assert(PyIter_Check(it)); - item = (*it->ob_type->tp_iternext)(it); - if (item == NULL) - return NULL; - lz->cnt++; - oldnext = lz->next; - lz->next += lz->step; - if (lz->next < oldnext) /* Check for overflow */ - lz->next = lz->stop; - return item; -} - -PyDoc_STRVAR(islice_doc, -"islice(iterable, [start,] stop [, step]) --> islice object\n\ -\n\ -Return an iterator whose next() method returns selected values from an\n\ -iterable. If start is specified, will skip all preceding elements;\n\ -otherwise, start defaults to zero. Step defaults to one. If\n\ -specified as another value, step determines how many values are \n\ -skipped between successive calls. Works like a slice() on a list\n\ -but returns an iterator."); - -static PyTypeObject islice_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "itertools.islice", /* tp_name */ - sizeof(isliceobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)islice_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - islice_doc, /* tp_doc */ - (traverseproc)islice_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)islice_next, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - islice_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - - -/* starmap object ************************************************************/ - -typedef struct { - PyObject_HEAD - PyObject *func; - PyObject *it; -} starmapobject; - -static PyTypeObject starmap_type; - -static PyObject * -starmap_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *func, *seq; - PyObject *it; - starmapobject *lz; - - if (!PyArg_UnpackTuple(args, "starmap", 2, 2, &func, &seq)) - return NULL; - - /* Get iterator. */ - it = PyObject_GetIter(seq); - if (it == NULL) - return NULL; - - /* create starmapobject structure */ - lz = (starmapobject *)type->tp_alloc(type, 0); - if (lz == NULL) { - Py_DECREF(it); - return NULL; - } - Py_INCREF(func); - lz->func = func; - lz->it = it; - - return (PyObject *)lz; -} - -static void -starmap_dealloc(starmapobject *lz) -{ - PyObject_GC_UnTrack(lz); - Py_XDECREF(lz->func); - Py_XDECREF(lz->it); - lz->ob_type->tp_free(lz); -} - -static int -starmap_traverse(starmapobject *lz, visitproc visit, void *arg) -{ - int err; - - if (lz->it) { - err = visit(lz->it, arg); - if (err) - return err; - } - if (lz->func) { - err = visit(lz->func, arg); - if (err) - return err; - } - return 0; -} - -static PyObject * -starmap_next(starmapobject *lz) -{ - PyObject *args; - PyObject *result; - PyObject *it = lz->it; - - assert(PyIter_Check(it)); - args = (*it->ob_type->tp_iternext)(it); - if (args == NULL) - return NULL; - if (!PyTuple_CheckExact(args)) { - Py_DECREF(args); - PyErr_SetString(PyExc_TypeError, - "iterator must return a tuple"); - return NULL; - } - result = PyObject_Call(lz->func, args, NULL); - Py_DECREF(args); - return result; -} - -PyDoc_STRVAR(starmap_doc, -"starmap(function, sequence) --> starmap object\n\ -\n\ -Return an iterator whose values are returned from the function evaluated\n\ -with a argument tuple taken from the given sequence."); - -static PyTypeObject starmap_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "itertools.starmap", /* tp_name */ - sizeof(starmapobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)starmap_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - starmap_doc, /* tp_doc */ - (traverseproc)starmap_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)starmap_next, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - starmap_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - - -/* imap object ************************************************************/ - -typedef struct { - PyObject_HEAD - PyObject *iters; - PyObject *func; -} imapobject; - -static PyTypeObject imap_type; - -static PyObject * -imap_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *it, *iters, *func; - imapobject *lz; - int numargs, i; - - numargs = PyTuple_Size(args); - if (numargs < 2) { - PyErr_SetString(PyExc_TypeError, - "imap() must have at least two arguments."); - return NULL; - } - - iters = PyTuple_New(numargs-1); - if (iters == NULL) - return NULL; - - for (i=1 ; itp_alloc(type, 0); - if (lz == NULL) { - Py_DECREF(iters); - return NULL; - } - lz->iters = iters; - func = PyTuple_GET_ITEM(args, 0); - Py_INCREF(func); - lz->func = func; - - return (PyObject *)lz; -} - -static void -imap_dealloc(imapobject *lz) -{ - PyObject_GC_UnTrack(lz); - Py_XDECREF(lz->iters); - Py_XDECREF(lz->func); - lz->ob_type->tp_free(lz); -} - -static int -imap_traverse(imapobject *lz, visitproc visit, void *arg) -{ - int err; - - if (lz->iters) { - err = visit(lz->iters, arg); - if (err) - return err; - } - if (lz->func) { - err = visit(lz->func, arg); - if (err) - return err; - } - return 0; -} - -/* -imap() is an iterator version of __builtins__.map() except that it does -not have the None fill-in feature. That was intentionally left out for -the following reasons: - - 1) Itertools are designed to be easily combined and chained together. - Having all tools stop with the shortest input is a unifying principle - that makes it easier to combine finite iterators (supplying data) with - infinite iterators like count() and repeat() (for supplying sequential - or constant arguments to a function). - - 2) In typical use cases for combining itertools, having one finite data - supplier run out before another is likely to be an error condition which - should not pass silently by automatically supplying None. - - 3) The use cases for automatic None fill-in are rare -- not many functions - do something useful when a parameter suddenly switches type and becomes - None. - - 4) If a need does arise, it can be met by __builtins__.map() or by - writing: chain(iterable, repeat(None)). - - 5) Similar toolsets in Haskell and SML do not have automatic None fill-in. -*/ - -static PyObject * -imap_next(imapobject *lz) -{ - PyObject *val; - PyObject *argtuple; - PyObject *result; - int numargs, i; - - numargs = PyTuple_Size(lz->iters); - argtuple = PyTuple_New(numargs); - if (argtuple == NULL) - return NULL; - - for (i=0 ; iiters, i)); - if (val == NULL) { - Py_DECREF(argtuple); - return NULL; - } - PyTuple_SET_ITEM(argtuple, i, val); - } - if (lz->func == Py_None) - return argtuple; - result = PyObject_Call(lz->func, argtuple, NULL); - Py_DECREF(argtuple); - return result; -} - -PyDoc_STRVAR(imap_doc, -"imap(func, *iterables) --> imap object\n\ -\n\ -Make an iterator that computes the function using arguments from\n\ -each of the iterables. Like map() except that it returns\n\ -an iterator instead of a list and that it stops when the shortest\n\ -iterable is exhausted instead of filling in None for shorter\n\ -iterables."); - -static PyTypeObject imap_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "itertools.imap", /* tp_name */ - sizeof(imapobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)imap_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - imap_doc, /* tp_doc */ - (traverseproc)imap_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)imap_next, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - imap_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - - -/* chain object ************************************************************/ - -typedef struct { - PyObject_HEAD - long tuplesize; - long iternum; /* which iterator is active */ - PyObject *ittuple; /* tuple of iterators */ -} chainobject; - -static PyTypeObject chain_type; - -static PyObject * -chain_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - chainobject *lz; - int tuplesize = PySequence_Length(args); - int i; - PyObject *ittuple; - - /* obtain iterators */ - assert(PyTuple_Check(args)); - ittuple = PyTuple_New(tuplesize); - if(ittuple == NULL) - return NULL; - for (i=0; i < tuplesize; ++i) { - PyObject *item = PyTuple_GET_ITEM(args, i); - PyObject *it = PyObject_GetIter(item); - if (it == NULL) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_Format(PyExc_TypeError, - "chain argument #%d must support iteration", - i+1); - Py_DECREF(ittuple); - return NULL; - } - PyTuple_SET_ITEM(ittuple, i, it); - } - - /* create chainobject structure */ - lz = (chainobject *)type->tp_alloc(type, 0); - if (lz == NULL) { - Py_DECREF(ittuple); - return NULL; - } - - lz->ittuple = ittuple; - lz->iternum = 0; - lz->tuplesize = tuplesize; - - return (PyObject *)lz; -} - -static void -chain_dealloc(chainobject *lz) -{ - PyObject_GC_UnTrack(lz); - Py_XDECREF(lz->ittuple); - lz->ob_type->tp_free(lz); -} - -static int -chain_traverse(chainobject *lz, visitproc visit, void *arg) -{ - if (lz->ittuple) - return visit(lz->ittuple, arg); - return 0; -} - -static PyObject * -chain_next(chainobject *lz) -{ - PyObject *it; - PyObject *item; - - while (lz->iternum < lz->tuplesize) { - it = PyTuple_GET_ITEM(lz->ittuple, lz->iternum); - item = PyIter_Next(it); - if (item != NULL) - return item; - lz->iternum++; - } - return NULL; -} - -PyDoc_STRVAR(chain_doc, -"chain(*iterables) --> chain object\n\ -\n\ -Return a chain object whose .next() method returns elements from the\n\ -first iterable until it is exhausted, then elements from the next\n\ -iterable, until all of the iterables are exhausted."); - -static PyTypeObject chain_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "itertools.chain", /* tp_name */ - sizeof(chainobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)chain_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - chain_doc, /* tp_doc */ - (traverseproc)chain_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)chain_next, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - chain_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - - -/* ifilter object ************************************************************/ - -typedef struct { - PyObject_HEAD - PyObject *func; - PyObject *it; -} ifilterobject; - -static PyTypeObject ifilter_type; - -static PyObject * -ifilter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *func, *seq; - PyObject *it; - ifilterobject *lz; - - if (!PyArg_UnpackTuple(args, "ifilter", 2, 2, &func, &seq)) - return NULL; - - /* Get iterator. */ - it = PyObject_GetIter(seq); - if (it == NULL) - return NULL; - - /* create ifilterobject structure */ - lz = (ifilterobject *)type->tp_alloc(type, 0); - if (lz == NULL) { - Py_DECREF(it); - return NULL; - } - Py_INCREF(func); - lz->func = func; - lz->it = it; - - return (PyObject *)lz; -} - -static void -ifilter_dealloc(ifilterobject *lz) -{ - PyObject_GC_UnTrack(lz); - Py_XDECREF(lz->func); - Py_XDECREF(lz->it); - lz->ob_type->tp_free(lz); -} - -static int -ifilter_traverse(ifilterobject *lz, visitproc visit, void *arg) -{ - int err; - - if (lz->it) { - err = visit(lz->it, arg); - if (err) - return err; - } - if (lz->func) { - err = visit(lz->func, arg); - if (err) - return err; - } - return 0; -} - -static PyObject * -ifilter_next(ifilterobject *lz) -{ - PyObject *item; - PyObject *it = lz->it; - long ok; - - for (;;) { - assert(PyIter_Check(it)); - item = (*it->ob_type->tp_iternext)(it); - if (item == NULL) - return NULL; - - if (lz->func == Py_None) { - ok = PyObject_IsTrue(item); - } else { - PyObject *good; - good = PyObject_CallFunctionObjArgs(lz->func, - item, NULL); - if (good == NULL) { - Py_DECREF(item); - return NULL; - } - ok = PyObject_IsTrue(good); - Py_DECREF(good); - } - if (ok) - return item; - Py_DECREF(item); - } -} - -PyDoc_STRVAR(ifilter_doc, -"ifilter(function or None, sequence) --> ifilter object\n\ -\n\ -Return those items of sequence for which function(item) is true.\n\ -If function is None, return the items that are true."); - -static PyTypeObject ifilter_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "itertools.ifilter", /* tp_name */ - sizeof(ifilterobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)ifilter_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - ifilter_doc, /* tp_doc */ - (traverseproc)ifilter_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)ifilter_next, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - ifilter_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - - -/* ifilterfalse object ************************************************************/ - -typedef struct { - PyObject_HEAD - PyObject *func; - PyObject *it; -} ifilterfalseobject; - -static PyTypeObject ifilterfalse_type; - -static PyObject * -ifilterfalse_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *func, *seq; - PyObject *it; - ifilterfalseobject *lz; - - if (!PyArg_UnpackTuple(args, "ifilterfalse", 2, 2, &func, &seq)) - return NULL; - - /* Get iterator. */ - it = PyObject_GetIter(seq); - if (it == NULL) - return NULL; - - /* create ifilterfalseobject structure */ - lz = (ifilterfalseobject *)type->tp_alloc(type, 0); - if (lz == NULL) { - Py_DECREF(it); - return NULL; - } - Py_INCREF(func); - lz->func = func; - lz->it = it; - - return (PyObject *)lz; -} - -static void -ifilterfalse_dealloc(ifilterfalseobject *lz) -{ - PyObject_GC_UnTrack(lz); - Py_XDECREF(lz->func); - Py_XDECREF(lz->it); - lz->ob_type->tp_free(lz); -} - -static int -ifilterfalse_traverse(ifilterfalseobject *lz, visitproc visit, void *arg) -{ - int err; - - if (lz->it) { - err = visit(lz->it, arg); - if (err) - return err; - } - if (lz->func) { - err = visit(lz->func, arg); - if (err) - return err; - } - return 0; -} - -static PyObject * -ifilterfalse_next(ifilterfalseobject *lz) -{ - PyObject *item; - PyObject *it = lz->it; - long ok; - - for (;;) { - assert(PyIter_Check(it)); - item = (*it->ob_type->tp_iternext)(it); - if (item == NULL) - return NULL; - - if (lz->func == Py_None) { - ok = PyObject_IsTrue(item); - } else { - PyObject *good; - good = PyObject_CallFunctionObjArgs(lz->func, - item, NULL); - if (good == NULL) { - Py_DECREF(item); - return NULL; - } - ok = PyObject_IsTrue(good); - Py_DECREF(good); - } - if (!ok) - return item; - Py_DECREF(item); - } -} - -PyDoc_STRVAR(ifilterfalse_doc, -"ifilterfalse(function or None, sequence) --> ifilterfalse object\n\ -\n\ -Return those items of sequence for which function(item) is false.\n\ -If function is None, return the items that are false."); - -static PyTypeObject ifilterfalse_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "itertools.ifilterfalse", /* tp_name */ - sizeof(ifilterfalseobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)ifilterfalse_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - ifilterfalse_doc, /* tp_doc */ - (traverseproc)ifilterfalse_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)ifilterfalse_next, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - ifilterfalse_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - - -/* count object ************************************************************/ - -typedef struct { - PyObject_HEAD - long cnt; -} countobject; - -static PyTypeObject count_type; - -static PyObject * -count_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - countobject *lz; - long cnt = 0; - - if (!PyArg_ParseTuple(args, "|l:count", &cnt)) - return NULL; - - /* create countobject structure */ - lz = (countobject *)PyObject_New(countobject, &count_type); - if (lz == NULL) - return NULL; - lz->cnt = cnt; - - return (PyObject *)lz; -} - -static PyObject * -count_next(countobject *lz) -{ - return PyInt_FromLong(lz->cnt++); -} - -PyDoc_STRVAR(count_doc, -"count([firstval]) --> count object\n\ -\n\ -Return a count object whose .next() method returns consecutive\n\ -integers starting from zero or, if specified, from firstval."); - -static PyTypeObject count_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "itertools.count", /* tp_name */ - sizeof(countobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)PyObject_Del, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - count_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)count_next, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - count_new, /* tp_new */ -}; - - -/* izip object ************************************************************/ - -#include "Python.h" - -typedef struct { - PyObject_HEAD - long tuplesize; - PyObject *ittuple; /* tuple of iterators */ - PyObject *result; -} izipobject; - -static PyTypeObject izip_type; - -static PyObject * -izip_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - izipobject *lz; - int i; - PyObject *ittuple; /* tuple of iterators */ - PyObject *result; - int tuplesize = PySequence_Length(args); - - /* args must be a tuple */ - assert(PyTuple_Check(args)); - - /* obtain iterators */ - ittuple = PyTuple_New(tuplesize); - if(ittuple == NULL) - return NULL; - for (i=0; i < tuplesize; ++i) { - PyObject *item = PyTuple_GET_ITEM(args, i); - PyObject *it = PyObject_GetIter(item); - if (it == NULL) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_Format(PyExc_TypeError, - "izip argument #%d must support iteration", - i+1); - Py_DECREF(ittuple); - return NULL; - } - PyTuple_SET_ITEM(ittuple, i, it); - } - - /* create a result holder */ - result = PyTuple_New(tuplesize); - if (result == NULL) { - Py_DECREF(ittuple); - return NULL; - } - for (i=0 ; i < tuplesize ; i++) { - Py_INCREF(Py_None); - PyTuple_SET_ITEM(result, i, Py_None); - } - - /* create izipobject structure */ - lz = (izipobject *)type->tp_alloc(type, 0); - if (lz == NULL) { - Py_DECREF(ittuple); - Py_DECREF(result); - return NULL; - } - lz->ittuple = ittuple; - lz->tuplesize = tuplesize; - lz->result = result; - - return (PyObject *)lz; -} - -static void -izip_dealloc(izipobject *lz) -{ - PyObject_GC_UnTrack(lz); - Py_XDECREF(lz->ittuple); - Py_XDECREF(lz->result); - lz->ob_type->tp_free(lz); -} - -static int -izip_traverse(izipobject *lz, visitproc visit, void *arg) -{ - int err; - - if (lz->ittuple) { - err = visit(lz->ittuple, arg); - if (err) - return err; - } - if (lz->result) { - err = visit(lz->result, arg); - if (err) - return err; - } - return 0; -} - -static PyObject * -izip_next(izipobject *lz) -{ - int i; - long tuplesize = lz->tuplesize; - PyObject *result = lz->result; - PyObject *it; - PyObject *item; - PyObject *olditem; - - if (tuplesize == 0) - return NULL; - if (result->ob_refcnt == 1) { - Py_INCREF(result); - for (i=0 ; i < tuplesize ; i++) { - it = PyTuple_GET_ITEM(lz->ittuple, i); - assert(PyIter_Check(it)); - item = (*it->ob_type->tp_iternext)(it); - if (item == NULL) { - Py_DECREF(result); - return NULL; - } - olditem = PyTuple_GET_ITEM(result, i); - PyTuple_SET_ITEM(result, i, item); - Py_DECREF(olditem); - } - } else { - result = PyTuple_New(tuplesize); - if (result == NULL) - return NULL; - for (i=0 ; i < tuplesize ; i++) { - it = PyTuple_GET_ITEM(lz->ittuple, i); - assert(PyIter_Check(it)); - item = (*it->ob_type->tp_iternext)(it); - if (item == NULL) { - Py_DECREF(result); - return NULL; - } - PyTuple_SET_ITEM(result, i, item); - } - } - return result; -} - -PyDoc_STRVAR(izip_doc, -"izip(iter1 [,iter2 [...]]) --> izip object\n\ -\n\ -Return a izip object whose .next() method returns a tuple where\n\ -the i-th element comes from the i-th iterable argument. The .next()\n\ -method continues until the shortest iterable in the argument sequence\n\ -is exhausted and then it raises StopIteration. Works like the zip()\n\ -function but consumes less memory by returning an iterator instead of\n\ -a list."); - -static PyTypeObject izip_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "itertools.izip", /* tp_name */ - sizeof(izipobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)izip_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - izip_doc, /* tp_doc */ - (traverseproc)izip_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)izip_next, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - izip_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - - -/* repeat object ************************************************************/ - -typedef struct { - PyObject_HEAD - PyObject *element; - long cnt; -} repeatobject; - -static PyTypeObject repeat_type; - -static PyObject * -repeat_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - repeatobject *ro; - PyObject *element; - long cnt = -1; - - if (!PyArg_ParseTuple(args, "O|l:repeat", &element, &cnt)) - return NULL; - - if (PyTuple_Size(args) == 2 && cnt < 0) - cnt = 0; - - ro = (repeatobject *)type->tp_alloc(type, 0); - if (ro == NULL) - return NULL; - Py_INCREF(element); - ro->element = element; - ro->cnt = cnt; - return (PyObject *)ro; -} - -static void -repeat_dealloc(repeatobject *ro) -{ - PyObject_GC_UnTrack(ro); - Py_XDECREF(ro->element); - ro->ob_type->tp_free(ro); -} - -static int -repeat_traverse(repeatobject *ro, visitproc visit, void *arg) -{ - if (ro->element) - return visit(ro->element, arg); - return 0; -} - -static PyObject * -repeat_next(repeatobject *ro) -{ - if (ro->cnt == 0) - return NULL; - if (ro->cnt > 0) - ro->cnt--; - Py_INCREF(ro->element); - return ro->element; -} - -PyDoc_STRVAR(repeat_doc, -"repeat(element [,times]) -> create an iterator which returns the element\n\ -for the specified number of times. If not specified, returns the element\n\ -endlessly."); - -static PyTypeObject repeat_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "itertools.repeat", /* tp_name */ - sizeof(repeatobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)repeat_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - repeat_doc, /* tp_doc */ - (traverseproc)repeat_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)repeat_next, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - repeat_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - - -/* module level code ********************************************************/ - -PyDoc_STRVAR(module_doc, -"Functional tools for creating and using iterators.\n\ -\n\ -Infinite iterators:\n\ -count([n]) --> n, n+1, n+2, ...\n\ -cycle(p) --> p0, p1, ... plast, p0, p1, ...\n\ -repeat(elem [,n]) --> elem, elem, elem, ... endlessly or up to n times\n\ -\n\ -Iterators terminating on the shortest input sequence:\n\ -izip(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ... \n\ -ifilter(pred, seq) --> elements of seq where pred(elem) is True\n\ -ifilterfalse(pred, seq) --> elements of seq where pred(elem) is False\n\ -islice(seq, [start,] stop [, step]) --> elements from\n\ - seq[start:stop:step]\n\ -imap(fun, p, q, ...) --> fun(p0, q0), fun(p1, q1), ...\n\ -starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...\n\ -chain(p, q, ...) --> p0, p1, ... plast, q0, q1, ... \n\ -takewhile(pred, seq) --> seq[0], seq[1], until pred fails\n\ -dropwhile(pred, seq) --> seq[n], seq[n+1], starting when pred fails\n\ -"); - - -PyMODINIT_FUNC -inititertools(void) -{ - int i; - PyObject *m; - char *name; - PyTypeObject *typelist[] = { - &cycle_type, - &dropwhile_type, - &takewhile_type, - &islice_type, - &starmap_type, - &imap_type, - &chain_type, - &ifilter_type, - &ifilterfalse_type, - &count_type, - &izip_type, - &repeat_type, - NULL - }; - - m = Py_InitModule3("itertools", NULL, module_doc); - - for (i=0 ; typelist[i] != NULL ; i++) { - if (PyType_Ready(typelist[i]) < 0) - return; - name = strchr(typelist[i]->tp_name, '.'); - assert (name != NULL); - Py_INCREF(typelist[i]); - PyModule_AddObject(m, name+1, (PyObject *)typelist[i]); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/ld_so_aix b/SDKs/XPlatform/Cypython-2.3.3/Modules/ld_so_aix deleted file mode 100644 index 0a2a599b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/ld_so_aix +++ /dev/null @@ -1,183 +0,0 @@ -#!/bin/sh -# -# ======================================================================== -# FILE: ld_so_aix -# TYPE: executable, uses makexp_aix -# SYSTEM: AIX -# -# DESCRIPTION: Creates a shareable .o from a set of pre-compiled -# (unshared) .o files -# -# USAGE: ld_so_aix [CC] [arguments] -# -# ARGUMENTS: Same as for "ld". The following arguments are processed -# or supplied by this script (those marked with an asterisk -# can be overriden from command line): -# -# Argument Default value -# (*) -o [OutputFileName] -o shr.o -# (*) -e [EntryPointLabel] -e init[OutputBaseName] -# (*) -bE:[ExportFile] -bE:[OutputBaseName].exp -# (*) -bI:[ImportFile] -bI:./python.exp -# -bM:[ModuleType] -bM:SRE -# -bhalt:[Number] -bhalt:4 -# -T[Number] -T512 -# -H[Number] -H512 -# -lm -# -# The compiler specific ("-lc" or "-lc_r", "-lpthreads",...) -# arguments will be automatically passed to "ld" according -# to the CC command provided as a first argument to this -# script. Usually, the same CC command was used to produce -# the pre-compiled .o file(s). -# -# NOTES: 1. Since "ld_so_aix" was originally written for building -# shared modules for the Python interpreter, the -e and -# -bI default values match Python's conventions. In -# Python, the entry point for a shared module is based -# on the module's name (e.g., the "mathmodule" will -# expect an entry point of "initmath"). -# 2. The script accepts multiple .o or .a input files and -# creates a single (shared) output file. The export list -# that is created is based on the output file's basename -# with the suffix ".exp". -# 3. The resulting shared object file is left in the -# current directory. -# 4. Uncommenting the "echo" lines gives detailed output -# about the commands executed in the script. -# -# -# HISTORY: Oct-1996 -- Support added for multiple .o files -- -# -- and optional arguments processing. -- -# Chris Myers (myers@tc.cornell.edu), Keith Kwok -# (kkwok@tc.cornell.edu) and Vladimir Marangozov -# -# Aug-6-1996 -- Take care of the compiler specific -- -# -- args by leaving CC to invoke "ld". -- -# Vladimir Marangozov -# -# Jul-1-1996 -- Make sure to use /usr/ccs/bin/ld -- -# -- Use makexp_aix for the export list. -- -# Vladimir Marangozov (Vladimir.Marangozov@imag.fr) -# -# Manus Hand (mhand@csn.net) -- Initial code -- 6/24/96 -# ======================================================================== -# - -usage="Usage: ld_so_aix [CC command] [ld arguments]" -if test ! -n "$*"; then - echo $usage; exit 2 -fi - -makexp=`dirname $0`/makexp_aix - -# Check for existence of compiler. -CC=$1; shift -whichcc=`which $CC` - -if test ! -x "$whichcc"; then - echo "ld_so_aix: Compiler '$CC' not found; exiting." - exit 2 -fi - -if test ! -n "$*"; then - echo $usage; exit 2 -fi - -# Default import file for Python -# Can be overriden by providing a -bI: argument. -impfile="./python.exp" - -# Parse arguments -while test -n "$1" -do - case "$1" in - -e | -Wl,-e) - if test -z "$2"; then - echo "ld_so_aix: The -e flag needs a parameter; exiting."; exit 2 - else - shift; entry=$1 - fi - ;; - -e* | -Wl,-e*) - entry=`echo $1 | sed -e "s/-Wl,//" -e "s/-e//"` - ;; - -o) - if test -z "$2"; then - echo "ld_so_aix: The -o flag needs a parameter; exiting."; exit 2 - else - shift; objfile=$1 - fi - ;; - -o*) - objfile=`echo $1 | sed "s/-o//"` - ;; - -bI:* | -Wl,-bI:*) - impfile=`echo $1 | sed -e "s/-Wl,//" -e "s/-bI://"` - ;; - -bE:* | -Wl,-bE:*) - expfile=`echo $1 | sed -e "s/-Wl,//" -e "s/-bE://"` - ;; - *.o | *.a) - objs="$objs $1" - args="$args $1" - ;; - -bM:* | -Wl,-bM:* | -H* | -Wl,-H* | -T* | -Wl,-T* | -lm) - ;; - *) - args="$args $1" - ;; - esac - shift -done - - -if test -z "$objs"; then - echo "ld_so_aix: No input files; exiting." - exit 2 -elif test ! -r "$impfile"; then - echo "ld_so_aix: Import file '$impfile' not found or not readable; exiting." - exit 2 -fi - -# If -o wasn't specified, assume "-o shr.o" -if test -z "$objfile"; then - objfile=shr.o -fi - -filename=`basename $objfile | sed "s/\.[^.]*$//"` - -# If -bE: wasn't specified, assume "-bE:$filename.exp" -if test -z "$expfile"; then - expfile="$filename.exp" -fi - -# Default entry symbol for Python modules = init[modulename] -# Can be overriden by providing a -e argument. -if test -z "$entry"; then - entry=init`echo $filename | sed "s/module.*//"` -fi - -#echo "ld_so_aix: Debug info section" -#echo " -> output file : $objfile" -#echo " -> import file : $impfile" -#echo " -> export file : $expfile" -#echo " -> entry point : $entry" -#echo " -> object files: $objs" -#echo " -> CC arguments: $args" - -CCOPT="-Wl,-e$entry -Wl,-bE:$expfile -Wl,-bI:$impfile -Wl,-bhalt:4" -CCOPT="$CCOPT -Wl,-bM:SRE -Wl,-T512 -Wl,-H512 -lm -o $objfile" -CCARGS="$args" - -# Export list generation. -#echo $makexp $expfile "$objfile" $objs -$makexp $expfile "$objfile" $objs - -# Perform the link. -#echo $CC $CCOPT $CCARGS -$CC $CCOPT $CCARGS - -# Delete the module's export list file. -# Comment this line if you need it. -rm -f $expfile diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/ld_so_beos b/SDKs/XPlatform/Cypython-2.3.3/Modules/ld_so_beos deleted file mode 100644 index a252c4e8..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/ld_so_beos +++ /dev/null @@ -1,78 +0,0 @@ -#! /bin/sh -# -# linkmodule for Python -# Chris Herborth (chrish@qnx.com) -# -# This is covered by the same copyright/licensing terms as the rest of -# Python. -# -# Shell script to build shared library versions of the modules; since -# the change to the *ahem* "proper" import/export mechanism, this script -# is much simpler. It handles PowerPC and x86, too. -# -# This is called by the Modules/Makefile as $(LDSHARED): -# -# $(LDSHARED) foomodule.o -o foomodule$(SO) -# -# Could also be called as: -# -# $(LDSHARED) readline.o -L/boot/home/config/lib -lreadline -ltermcap \ -# -o readline$(SO) -# -# so we need to preserve the arguments, sort of. - -# Make sure we got reasonable arguments. -TARGET="" -ARGS="" - -while [ "$#" != "0" ]; do - case "$1" in - -o) TARGET="$2"; shift; shift;; - *) ARGS="$ARGS $1"; shift;; - esac -done - -if [ "$TARGET" = "" ] ; then - echo "Usage:" - echo - echo " $0 [args] -o foomodule.so [args] foomodule.o [args]" - echo - echo "Where:" - echo - echo " [args] normal compiler arguments" - exit 1 -fi - -# The shared libraries and glue objects we need to link against; these -# libs are overkill for most of the standard modules, but it makes life -# in this shell script easier. -LIBS="-lbe -lnet -lroot" - -case $BE_HOST_CPU in - ppc) - # Boy, do we need a lot of crap... - GLUE_LOC=/boot/develop/lib/ppc - GLUE="${GLUE_LOC}/glue-noinit.a ${GLUE_LOC}/init_term_dyn.o" - case $(uname -r) in - 4.0*) CC="mwcc -xms -export pragma -nodup" ;; - *) CC="mwcc -shared -export pragma -nodup" ;; - esac - ;; - - x86) - # We don't need as much crap here... - GLUE="" - CC="gcc -nostart -Wl,-soname=${TARGET}" - ;; - - *) - # What the?!? - echo "$0 doesn't support $BE_HOST_CPU systems..." - echo "You're on your own... I'd be surprised if this works." - GLUE="" - CC="cc" - ;; -esac - -# Now link that shared lib... -$CC -o $TARGET $ARGS $GLUE $LIBS diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/linuxaudiodev.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/linuxaudiodev.c deleted file mode 100644 index 8cfab357..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/linuxaudiodev.c +++ /dev/null @@ -1,519 +0,0 @@ -/* Hey Emacs, this is -*-C-*- - ****************************************************************************** - * linuxaudiodev.c -- Linux audio device for python. - * - * Author : Peter Bosch - * Created On : Thu Mar 2 21:10:33 2000 - * Status : Unknown, Use with caution! - * - * Unless other notices are present in any part of this file - * explicitly claiming copyrights for other people and/or - * organizations, the contents of this file is fully copyright - * (C) 2000 Peter Bosch, all rights reserved. - ****************************************************************************** - */ - -#include "Python.h" -#include "structmember.h" - -#ifdef HAVE_FCNTL_H -#include -#else -#define O_RDONLY 00 -#define O_WRONLY 01 -#endif - - -#include -#if defined(linux) -#include - -typedef unsigned long uint32_t; - -#elif defined(__FreeBSD__) -#include - -#ifndef SNDCTL_DSP_CHANNELS -#define SNDCTL_DSP_CHANNELS SOUND_PCM_WRITE_CHANNELS -#endif - -#endif - -typedef struct { - PyObject_HEAD; - int x_fd; /* The open file */ - int x_mode; /* file mode */ - int x_icount; /* Input count */ - int x_ocount; /* Output count */ - uint32_t x_afmts; /* Audio formats supported by hardware*/ -} lad_t; - -/* XXX several format defined in soundcard.h are not supported, - including _NE (native endian) options and S32 options -*/ - -static struct { - int a_bps; - uint32_t a_fmt; - char *a_name; -} audio_types[] = { - { 8, AFMT_MU_LAW, "logarithmic mu-law 8-bit audio" }, - { 8, AFMT_A_LAW, "logarithmic A-law 8-bit audio" }, - { 8, AFMT_U8, "linear unsigned 8-bit audio" }, - { 8, AFMT_S8, "linear signed 8-bit audio" }, - { 16, AFMT_U16_BE, "linear unsigned 16-bit big-endian audio" }, - { 16, AFMT_U16_LE, "linear unsigned 16-bit little-endian audio" }, - { 16, AFMT_S16_BE, "linear signed 16-bit big-endian audio" }, - { 16, AFMT_S16_LE, "linear signed 16-bit little-endian audio" }, - { 16, AFMT_S16_NE, "linear signed 16-bit native-endian audio" }, -}; - -static int n_audio_types = sizeof(audio_types) / sizeof(audio_types[0]); - -static PyTypeObject Ladtype; - -static PyObject *LinuxAudioError; - -static lad_t * -newladobject(PyObject *arg) -{ - lad_t *xp; - int fd, afmts, imode; - char *basedev = NULL; - char *mode = NULL; - - /* Two ways to call linuxaudiodev.open(): - open(device, mode) (for consistency with builtin open()) - open(mode) (for backwards compatibility) - because the *first* argument is optional, parsing args is - a wee bit tricky. */ - if (!PyArg_ParseTuple(arg, "s|s:open", &basedev, &mode)) - return NULL; - if (mode == NULL) { /* only one arg supplied */ - mode = basedev; - basedev = NULL; - } - - if (strcmp(mode, "r") == 0) - imode = O_RDONLY; - else if (strcmp(mode, "w") == 0) - imode = O_WRONLY; - else { - PyErr_SetString(LinuxAudioError, "mode should be 'r' or 'w'"); - return NULL; - } - - /* Open the correct device. The base device name comes from the - * AUDIODEV environment variable first, then /dev/dsp. The - * control device tacks "ctl" onto the base device name. - * - * Note that the only difference between /dev/audio and /dev/dsp - * is that the former uses logarithmic mu-law encoding and the - * latter uses 8-bit unsigned encoding. - */ - - if (basedev == NULL) { /* called with one arg */ - basedev = getenv("AUDIODEV"); - if (basedev == NULL) /* $AUDIODEV not set */ - basedev = "/dev/dsp"; - } - - if ((fd = open(basedev, imode)) == -1) { - PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev); - return NULL; - } - if (imode == O_WRONLY && ioctl(fd, SNDCTL_DSP_NONBLOCK, NULL) == -1) { - PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev); - return NULL; - } - if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) { - PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev); - return NULL; - } - /* Create and initialize the object */ - if ((xp = PyObject_New(lad_t, &Ladtype)) == NULL) { - close(fd); - return NULL; - } - xp->x_fd = fd; - xp->x_mode = imode; - xp->x_icount = xp->x_ocount = 0; - xp->x_afmts = afmts; - return xp; -} - -static void -lad_dealloc(lad_t *xp) -{ - /* if already closed, don't reclose it */ - if (xp->x_fd != -1) - close(xp->x_fd); - PyObject_Del(xp); -} - -static PyObject * -lad_read(lad_t *self, PyObject *args) -{ - int size, count; - char *cp; - PyObject *rv; - - if (!PyArg_ParseTuple(args, "i:read", &size)) - return NULL; - rv = PyString_FromStringAndSize(NULL, size); - if (rv == NULL) - return NULL; - cp = PyString_AS_STRING(rv); - if ((count = read(self->x_fd, cp, size)) < 0) { - PyErr_SetFromErrno(LinuxAudioError); - Py_DECREF(rv); - return NULL; - } - self->x_icount += count; - _PyString_Resize(&rv, count); - return rv; -} - -static PyObject * -lad_write(lad_t *self, PyObject *args) -{ - char *cp; - int rv, size; - fd_set write_set_fds; - struct timeval tv; - int select_retval; - - if (!PyArg_ParseTuple(args, "s#:write", &cp, &size)) - return NULL; - - /* use select to wait for audio device to be available */ - FD_ZERO(&write_set_fds); - FD_SET(self->x_fd, &write_set_fds); - tv.tv_sec = 4; /* timeout values */ - tv.tv_usec = 0; - - while (size > 0) { - select_retval = select(self->x_fd+1, NULL, &write_set_fds, NULL, &tv); - tv.tv_sec = 1; tv.tv_usec = 0; /* willing to wait this long next time*/ - if (select_retval) { - if ((rv = write(self->x_fd, cp, size)) == -1) { - if (errno != EAGAIN) { - PyErr_SetFromErrno(LinuxAudioError); - return NULL; - } else { - errno = 0; /* EAGAIN: buffer is full, try again */ - } - } else { - self->x_ocount += rv; - size -= rv; - cp += rv; - } - } else { - /* printf("Not able to write to linux audio device within %ld seconds\n", tv.tv_sec); */ - PyErr_SetFromErrno(LinuxAudioError); - return NULL; - } - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -lad_close(lad_t *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":close")) - return NULL; - - if (self->x_fd >= 0) { - close(self->x_fd); - self->x_fd = -1; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -lad_fileno(lad_t *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":fileno")) - return NULL; - return PyInt_FromLong(self->x_fd); -} - -static PyObject * -lad_setparameters(lad_t *self, PyObject *args) -{ - int rate, ssize, nchannels, n, fmt, emulate=0; - - if (!PyArg_ParseTuple(args, "iiii|i:setparameters", - &rate, &ssize, &nchannels, &fmt, &emulate)) - return NULL; - - if (rate < 0) { - PyErr_Format(PyExc_ValueError, "expected rate >= 0, not %d", - rate); - return NULL; - } - if (ssize < 0) { - PyErr_Format(PyExc_ValueError, "expected sample size >= 0, not %d", - ssize); - return NULL; - } - if (nchannels != 1 && nchannels != 2) { - PyErr_Format(PyExc_ValueError, "nchannels must be 1 or 2, not %d", - nchannels); - return NULL; - } - - for (n = 0; n < n_audio_types; n++) - if (fmt == audio_types[n].a_fmt) - break; - if (n == n_audio_types) { - PyErr_Format(PyExc_ValueError, "unknown audio encoding: %d", fmt); - return NULL; - } - if (audio_types[n].a_bps != ssize) { - PyErr_Format(PyExc_ValueError, - "for %s, expected sample size %d, not %d", - audio_types[n].a_name, audio_types[n].a_bps, ssize); - return NULL; - } - - if (emulate == 0) { - if ((self->x_afmts & audio_types[n].a_fmt) == 0) { - PyErr_Format(PyExc_ValueError, - "%s format not supported by device", - audio_types[n].a_name); - return NULL; - } - } - if (ioctl(self->x_fd, SNDCTL_DSP_SETFMT, - &audio_types[n].a_fmt) == -1) { - PyErr_SetFromErrno(LinuxAudioError); - return NULL; - } - if (ioctl(self->x_fd, SNDCTL_DSP_CHANNELS, &nchannels) == -1) { - PyErr_SetFromErrno(LinuxAudioError); - return NULL; - } - if (ioctl(self->x_fd, SNDCTL_DSP_SPEED, &rate) == -1) { - PyErr_SetFromErrno(LinuxAudioError); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -static int -_ssize(lad_t *self, int *nchannels, int *ssize) -{ - int fmt; - - fmt = 0; - if (ioctl(self->x_fd, SNDCTL_DSP_SETFMT, &fmt) < 0) - return -errno; - - switch (fmt) { - case AFMT_MU_LAW: - case AFMT_A_LAW: - case AFMT_U8: - case AFMT_S8: - *ssize = sizeof(char); - break; - case AFMT_S16_LE: - case AFMT_S16_BE: - case AFMT_U16_LE: - case AFMT_U16_BE: - *ssize = sizeof(short); - break; - case AFMT_MPEG: - case AFMT_IMA_ADPCM: - default: - return -EOPNOTSUPP; - } - *nchannels = 0; - if (ioctl(self->x_fd, SNDCTL_DSP_CHANNELS, nchannels) < 0) - return -errno; - return 0; -} - - -/* bufsize returns the size of the hardware audio buffer in number - of samples */ -static PyObject * -lad_bufsize(lad_t *self, PyObject *args) -{ - audio_buf_info ai; - int nchannels, ssize; - - if (!PyArg_ParseTuple(args, ":bufsize")) return NULL; - - if (_ssize(self, &nchannels, &ssize) < 0) { - PyErr_SetFromErrno(LinuxAudioError); - return NULL; - } - if (ioctl(self->x_fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { - PyErr_SetFromErrno(LinuxAudioError); - return NULL; - } - return PyInt_FromLong((ai.fragstotal * ai.fragsize) / (nchannels * ssize)); -} - -/* obufcount returns the number of samples that are available in the - hardware for playing */ -static PyObject * -lad_obufcount(lad_t *self, PyObject *args) -{ - audio_buf_info ai; - int nchannels, ssize; - - if (!PyArg_ParseTuple(args, ":obufcount")) - return NULL; - - if (_ssize(self, &nchannels, &ssize) < 0) { - PyErr_SetFromErrno(LinuxAudioError); - return NULL; - } - if (ioctl(self->x_fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { - PyErr_SetFromErrno(LinuxAudioError); - return NULL; - } - return PyInt_FromLong((ai.fragstotal * ai.fragsize - ai.bytes) / - (ssize * nchannels)); -} - -/* obufcount returns the number of samples that can be played without - blocking */ -static PyObject * -lad_obuffree(lad_t *self, PyObject *args) -{ - audio_buf_info ai; - int nchannels, ssize; - - if (!PyArg_ParseTuple(args, ":obuffree")) - return NULL; - - if (_ssize(self, &nchannels, &ssize) < 0) { - PyErr_SetFromErrno(LinuxAudioError); - return NULL; - } - if (ioctl(self->x_fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { - PyErr_SetFromErrno(LinuxAudioError); - return NULL; - } - return PyInt_FromLong(ai.bytes / (ssize * nchannels)); -} - -/* Flush the device */ -static PyObject * -lad_flush(lad_t *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":flush")) return NULL; - - if (ioctl(self->x_fd, SNDCTL_DSP_SYNC, NULL) == -1) { - PyErr_SetFromErrno(LinuxAudioError); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -lad_getptr(lad_t *self, PyObject *args) -{ - count_info info; - int req; - - if (!PyArg_ParseTuple(args, ":getptr")) - return NULL; - - if (self->x_mode == O_RDONLY) - req = SNDCTL_DSP_GETIPTR; - else - req = SNDCTL_DSP_GETOPTR; - if (ioctl(self->x_fd, req, &info) == -1) { - PyErr_SetFromErrno(LinuxAudioError); - return NULL; - } - return Py_BuildValue("iii", info.bytes, info.blocks, info.ptr); -} - -static PyMethodDef lad_methods[] = { - { "read", (PyCFunction)lad_read, METH_VARARGS }, - { "write", (PyCFunction)lad_write, METH_VARARGS }, - { "setparameters", (PyCFunction)lad_setparameters, METH_VARARGS }, - { "bufsize", (PyCFunction)lad_bufsize, METH_VARARGS }, - { "obufcount", (PyCFunction)lad_obufcount, METH_VARARGS }, - { "obuffree", (PyCFunction)lad_obuffree, METH_VARARGS }, - { "flush", (PyCFunction)lad_flush, METH_VARARGS }, - { "close", (PyCFunction)lad_close, METH_VARARGS }, - { "fileno", (PyCFunction)lad_fileno, METH_VARARGS }, - { "getptr", (PyCFunction)lad_getptr, METH_VARARGS }, - { NULL, NULL} /* sentinel */ -}; - -static PyObject * -lad_getattr(lad_t *xp, char *name) -{ - return Py_FindMethod(lad_methods, (PyObject *)xp, name); -} - -static PyTypeObject Ladtype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "linuxaudiodev.linux_audio_device", /*tp_name*/ - sizeof(lad_t), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)lad_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)lad_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ -}; - -static PyObject * -ladopen(PyObject *self, PyObject *args) -{ - return (PyObject *)newladobject(args); -} - -static PyMethodDef linuxaudiodev_methods[] = { - { "open", ladopen, METH_VARARGS }, - { 0, 0 }, -}; - -void -initlinuxaudiodev(void) -{ - PyObject *m; - - m = Py_InitModule("linuxaudiodev", linuxaudiodev_methods); - - LinuxAudioError = PyErr_NewException("linuxaudiodev.error", NULL, NULL); - if (LinuxAudioError) - PyModule_AddObject(m, "error", LinuxAudioError); - - if (PyModule_AddIntConstant(m, "AFMT_MU_LAW", (long)AFMT_MU_LAW) == -1) - return; - if (PyModule_AddIntConstant(m, "AFMT_A_LAW", (long)AFMT_A_LAW) == -1) - return; - if (PyModule_AddIntConstant(m, "AFMT_U8", (long)AFMT_U8) == -1) - return; - if (PyModule_AddIntConstant(m, "AFMT_S8", (long)AFMT_S8) == -1) - return; - if (PyModule_AddIntConstant(m, "AFMT_U16_BE", (long)AFMT_U16_BE) == -1) - return; - if (PyModule_AddIntConstant(m, "AFMT_U16_LE", (long)AFMT_U16_LE) == -1) - return; - if (PyModule_AddIntConstant(m, "AFMT_S16_BE", (long)AFMT_S16_BE) == -1) - return; - if (PyModule_AddIntConstant(m, "AFMT_S16_LE", (long)AFMT_S16_LE) == -1) - return; - if (PyModule_AddIntConstant(m, "AFMT_S16_NE", (long)AFMT_S16_NE) == -1) - return; - - return; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/main.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/main.c deleted file mode 100644 index 1175f01b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/main.c +++ /dev/null @@ -1,466 +0,0 @@ -/* Python interpreter main program */ - -#include "Python.h" -#include "osdefs.h" -#include "compile.h" /* For CO_FUTURE_DIVISION */ - -#ifdef __VMS -#include -#endif - -#if defined(MS_WINDOWS) || defined(__CYGWIN__) -#include -#endif - -#if (defined(PYOS_OS2) && !defined(PYCC_GCC)) || defined(MS_WINDOWS) -#define PYTHONHOMEHELP "\\lib" -#else -#if defined(PYOS_OS2) && defined(PYCC_GCC) -#define PYTHONHOMEHELP "/Lib" -#else -#define PYTHONHOMEHELP "/pythonX.X" -#endif -#endif - -#include "pygetopt.h" - -#define COPYRIGHT \ - "Type \"help\", \"copyright\", \"credits\" or \"license\" " \ - "for more information." - -/* For Py_GetArgcArgv(); set by main() */ -static char **orig_argv; -static int orig_argc; - -/* command line options */ -#define BASE_OPTS "c:dEhiOQ:StuUvVW:xX" - -#ifndef RISCOS -#define PROGRAM_OPTS BASE_OPTS -#else /*RISCOS*/ -/* extra option saying that we are running under a special task window - frontend; especially my_readline will behave different */ -#define PROGRAM_OPTS BASE_OPTS "w" -/* corresponding flag */ -extern int Py_RISCOSWimpFlag; -#endif /*RISCOS*/ - -/* Short usage message (with %s for argv0) */ -static char *usage_line = -"usage: %s [option] ... [-c cmd | file | -] [arg] ...\n"; - -/* Long usage message, split into parts < 512 bytes */ -static char *usage_1 = "\ -Options and arguments (and corresponding environment variables):\n\ --c cmd : program passed in as string (terminates option list)\n\ --d : debug output from parser (also PYTHONDEBUG=x)\n\ --E : ignore environment variables (such as PYTHONPATH)\n\ --h : print this help message and exit\n\ --i : inspect interactively after running script, (also PYTHONINSPECT=x)\n\ - and force prompts, even if stdin does not appear to be a terminal\n\ -"; -static char *usage_2 = "\ --O : optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x)\n\ --OO : remove doc-strings in addition to the -O optimizations\n\ --Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n\ --S : don't imply 'import site' on initialization\n\ --t : issue warnings about inconsistent tab usage (-tt: issue errors)\n\ --u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)\n\ - see man page for details on internal buffering relating to '-u'\n\ -"; -static char *usage_3 = "\ --v : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\ --V : print the Python version number and exit\n\ --W arg : warning control (arg is action:message:category:module:lineno)\n\ --x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\ -file : program read from script file\n\ -- : program read from stdin (default; interactive mode if a tty)\n\ -"; -static char *usage_4 = "\ -arg ...: arguments passed to program in sys.argv[1:]\n\ -Other environment variables:\n\ -PYTHONSTARTUP: file executed on interactive startup (no default)\n\ -PYTHONPATH : '%c'-separated list of directories prefixed to the\n\ - default module search path. The result is sys.path.\n\ -PYTHONHOME : alternate directory (or %c).\n\ - The default module search path uses %s.\n\ -PYTHONCASEOK : ignore case in 'import' statements (Windows).\n\ -"; - - -static int -usage(int exitcode, char* program) -{ - FILE *f = exitcode ? stderr : stdout; - - fprintf(f, usage_line, program); - if (exitcode) - fprintf(f, "Try `python -h' for more information.\n"); - else { - fprintf(f, usage_1); - fprintf(f, usage_2); - fprintf(f, usage_3); - fprintf(f, usage_4, DELIM, DELIM, PYTHONHOMEHELP); - } -#if defined(__VMS) - if (exitcode == 0) { - /* suppress 'error' message */ - return 1; - } - else { - /* STS$M_INHIB_MSG + SS$_ABORT */ - return 0x1000002c; - } -#else - return exitcode; -#endif - /*NOTREACHED*/ -} - - -/* Main program */ - -int -Py_Main(int argc, char **argv) -{ - int c; - int sts; - char *command = NULL; - char *filename = NULL; - FILE *fp = stdin; - char *p; - int inspect = 0; - int unbuffered = 0; - int skipfirstline = 0; - int stdin_is_interactive = 0; - int help = 0; - int version = 0; - int saw_inspect_flag = 0; - int saw_unbuffered_flag = 0; - PyCompilerFlags cf; - - cf.cf_flags = 0; - - orig_argc = argc; /* For Py_GetArgcArgv() */ - orig_argv = argv; - -#ifdef RISCOS - Py_RISCOSWimpFlag = 0; -#endif - - PySys_ResetWarnOptions(); - - while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) { - if (c == 'c') { - /* -c is the last option; following arguments - that look like options are left for the - command to interpret. */ - command = malloc(strlen(_PyOS_optarg) + 2); - if (command == NULL) - Py_FatalError( - "not enough memory to copy -c argument"); - strcpy(command, _PyOS_optarg); - strcat(command, "\n"); - break; - } - - switch (c) { - - case 'd': - Py_DebugFlag++; - break; - - case 'Q': - if (strcmp(_PyOS_optarg, "old") == 0) { - Py_DivisionWarningFlag = 0; - break; - } - if (strcmp(_PyOS_optarg, "warn") == 0) { - Py_DivisionWarningFlag = 1; - break; - } - if (strcmp(_PyOS_optarg, "warnall") == 0) { - Py_DivisionWarningFlag = 2; - break; - } - if (strcmp(_PyOS_optarg, "new") == 0) { - /* This only affects __main__ */ - cf.cf_flags |= CO_FUTURE_DIVISION; - /* And this tells the eval loop to treat - BINARY_DIVIDE as BINARY_TRUE_DIVIDE */ - _Py_QnewFlag = 1; - break; - } - fprintf(stderr, - "-Q option should be `-Qold', " - "`-Qwarn', `-Qwarnall', or `-Qnew' only\n"); - return usage(2, argv[0]); - /* NOTREACHED */ - - case 'i': - inspect++; - saw_inspect_flag = 1; - Py_InteractiveFlag++; - break; - - case 'O': - Py_OptimizeFlag++; - break; - - case 'S': - Py_NoSiteFlag++; - break; - - case 'E': - Py_IgnoreEnvironmentFlag++; - break; - - case 't': - Py_TabcheckFlag++; - break; - - case 'u': - unbuffered++; - saw_unbuffered_flag = 1; - break; - - case 'v': - Py_VerboseFlag++; - break; - -#ifdef RISCOS - case 'w': - Py_RISCOSWimpFlag = 1; - break; -#endif - - case 'x': - skipfirstline = 1; - break; - - case 'U': - Py_UnicodeFlag++; - break; - case 'h': - help++; - break; - case 'V': - version++; - break; - - case 'W': - PySys_AddWarnOption(_PyOS_optarg); - break; - - /* This space reserved for other options */ - - default: - return usage(2, argv[0]); - /*NOTREACHED*/ - - } - } - - if (help) - return usage(0, argv[0]); - - if (version) { - fprintf(stderr, "Python %s\n", PY_VERSION); - return 0; - } - - if (!saw_inspect_flag && - (p = Py_GETENV("PYTHONINSPECT")) && *p != '\0') - inspect = 1; - if (!saw_unbuffered_flag && - (p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0') - unbuffered = 1; - - if (command == NULL && _PyOS_optind < argc && - strcmp(argv[_PyOS_optind], "-") != 0) - { -#ifdef __VMS - filename = decc$translate_vms(argv[_PyOS_optind]); - if (filename == (char *)0 || filename == (char *)-1) - filename = argv[_PyOS_optind]; - -#else - filename = argv[_PyOS_optind]; -#endif - if (filename != NULL) { - if ((fp = fopen(filename, "r")) == NULL) { - fprintf(stderr, "%s: can't open file '%s'\n", - argv[0], filename); - return 2; - } - else if (skipfirstline) { - int ch; - /* Push back first newline so line numbers - remain the same */ - while ((ch = getc(fp)) != EOF) { - if (ch == '\n') { - (void)ungetc(ch, fp); - break; - } - } - } - } - } - - stdin_is_interactive = Py_FdIsInteractive(stdin, (char *)0); - - if (unbuffered) { -#if defined(MS_WINDOWS) || defined(__CYGWIN__) - _setmode(fileno(stdin), O_BINARY); - _setmode(fileno(stdout), O_BINARY); -#endif -#ifndef MPW -#ifdef HAVE_SETVBUF - setvbuf(stdin, (char *)NULL, _IONBF, BUFSIZ); - setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ); - setvbuf(stderr, (char *)NULL, _IONBF, BUFSIZ); -#else /* !HAVE_SETVBUF */ - setbuf(stdin, (char *)NULL); - setbuf(stdout, (char *)NULL); - setbuf(stderr, (char *)NULL); -#endif /* !HAVE_SETVBUF */ -#else /* MPW */ - /* On MPW (3.2) unbuffered seems to hang */ - setvbuf(stdin, (char *)NULL, _IOLBF, BUFSIZ); - setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ); - setvbuf(stderr, (char *)NULL, _IOLBF, BUFSIZ); -#endif /* MPW */ - } - else if (Py_InteractiveFlag) { -#ifdef MS_WINDOWS - /* Doesn't have to have line-buffered -- use unbuffered */ - /* Any set[v]buf(stdin, ...) screws up Tkinter :-( */ - setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ); -#else /* !MS_WINDOWS */ -#ifdef HAVE_SETVBUF - setvbuf(stdin, (char *)NULL, _IOLBF, BUFSIZ); - setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ); -#endif /* HAVE_SETVBUF */ -#endif /* !MS_WINDOWS */ - /* Leave stderr alone - it should be unbuffered anyway. */ - } -#ifdef __VMS - else { - setvbuf (stdout, (char *)NULL, _IOLBF, BUFSIZ); - } -#endif /* __VMS */ - -#ifdef __APPLE__ - /* On MacOS X, when the Python interpreter is embedded in an - application bundle, it gets executed by a bootstrapping script - that does os.execve() with an argv[0] that's different from the - actual Python executable. This is needed to keep the Finder happy, - or rather, to work around Apple's overly strict requirements of - the process name. However, we still need a usable sys.executable, - so the actual executable path is passed in an environment variable. - See Lib/plat-mac/bundlebuiler.py for details about the bootstrap - script. */ - if ((p = Py_GETENV("PYTHONEXECUTABLE")) && *p != '\0') - Py_SetProgramName(p); - else - Py_SetProgramName(argv[0]); -#else - Py_SetProgramName(argv[0]); -#endif - Py_Initialize(); - - if (Py_VerboseFlag || - (command == NULL && filename == NULL && stdin_is_interactive)) { - fprintf(stderr, "Python %s on %s\n", - Py_GetVersion(), Py_GetPlatform()); - if (!Py_NoSiteFlag) - fprintf(stderr, "%s\n", COPYRIGHT); - } - - if (command != NULL) { - /* Backup _PyOS_optind and force sys.argv[0] = '-c' */ - _PyOS_optind--; - argv[_PyOS_optind] = "-c"; - } - - PySys_SetArgv(argc-_PyOS_optind, argv+_PyOS_optind); - - if ((inspect || (command == NULL && filename == NULL)) && - isatty(fileno(stdin))) { - PyObject *v; - v = PyImport_ImportModule("readline"); - if (v == NULL) - PyErr_Clear(); - else - Py_DECREF(v); - } - - if (command) { - sts = PyRun_SimpleStringFlags(command, &cf) != 0; - free(command); - } - else { - if (filename == NULL && stdin_is_interactive) { - char *startup = Py_GETENV("PYTHONSTARTUP"); - if (startup != NULL && startup[0] != '\0') { - FILE *fp = fopen(startup, "r"); - if (fp != NULL) { - (void) PyRun_SimpleFile(fp, startup); - PyErr_Clear(); - fclose(fp); - } - } - } - /* XXX */ - sts = PyRun_AnyFileExFlags( - fp, - filename == NULL ? "" : filename, - filename != NULL, &cf) != 0; - } - - /* Check this environment variable at the end, to give programs the - * opportunity to set it from Python. - */ - if (!saw_inspect_flag && - (p = Py_GETENV("PYTHONINSPECT")) && *p != '\0') - { - inspect = 1; - } - - if (inspect && stdin_is_interactive && - (filename != NULL || command != NULL)) - /* XXX */ - sts = PyRun_AnyFileFlags(stdin, "", &cf) != 0; - - Py_Finalize(); -#ifdef RISCOS - if (Py_RISCOSWimpFlag) - fprintf(stderr, "\x0cq\x0c"); /* make frontend quit */ -#endif - -#ifdef __INSURE__ - /* Insure++ is a memory analysis tool that aids in discovering - * memory leaks and other memory problems. On Python exit, the - * interned string dictionary is flagged as being in use at exit - * (which it is). Under normal circumstances, this is fine because - * the memory will be automatically reclaimed by the system. Under - * memory debugging, it's a huge source of useless noise, so we - * trade off slower shutdown for less distraction in the memory - * reports. -baw - */ - _Py_ReleaseInternedStrings(); -#endif /* __INSURE__ */ - - return sts; -} - - -/* Make the *original* argc/argv available to other modules. - This is rare, but it is needed by the secureware extension. */ - -void -Py_GetArgcArgv(int *argc, char ***argv) -{ - *argc = orig_argc; - *argv = orig_argv; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/makesetup b/SDKs/XPlatform/Cypython-2.3.3/Modules/makesetup deleted file mode 100644 index 50edc232..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/makesetup +++ /dev/null @@ -1,297 +0,0 @@ -#! /bin/sh - -# Convert templates into Makefile and config.c, based on the module -# definitions found in the file Setup. -# -# Usage: makesetup [-s dir] [-c file] [-m file] [Setup] ... [-n [Setup] ...] -# -# Options: -# -s directory: alternative source directory (default .) -# -l directory: library source directory (default derived from $0) -# -c file: alternative config.c template (default $libdir/config.c.in) -# -c -: don't write config.c -# -m file: alternative Makefile template (default ./Makefile.pre) -# -m -: don't write Makefile -# -# Remaining arguments are one or more Setup files (default ./Setup). -# Setup files after a -n option are used for their variables, modules -# and libraries but not for their .o files. -# -# See Setup.dist for a description of the format of the Setup file. -# -# The following edits are made: -# -# Copying config.c.in to config.c: -# - insert an identifying comment at the start -# - for each mentioned in Setup before *noconfig*: -# + insert 'extern void init(void);' before MARKER 1 -# + insert '{"", initmodule},' before MARKER 2 -# -# Copying Makefile.pre to Makefile: -# - insert an identifying comment at the start -# - replace _MODOBJS_ by the list of objects from Setup (except for -# Setup files after a -n option) -# - replace _MODLIBS_ by the list of libraries from Setup -# - for each object file mentioned in Setup, append a rule -# '.o: .c; ' to the end of the Makefile -# - for each module mentioned in Setup, append a rule -# which creates a shared library version to the end of the Makefile -# - for each variable definition found in Setup, insert the definition -# before the comment 'Definitions added by makesetup' - -# Loop over command line options -usage=' -usage: makesetup [-s srcdir] [-l libdir] [-c config.c.in] [-m Makefile.pre] - [Setup] ... [-n [Setup] ...]' -srcdir='.' -libdir='' -config='' -makepre='' -noobjects='' -doconfig=yes -while : -do - case $1 in - -s) shift; srcdir=$1; shift;; - -l) shift; libdir=$1; shift;; - -c) shift; config=$1; shift;; - -m) shift; makepre=$1; shift;; - --) shift; break;; - -n) noobjects=yes;; - -*) echo "$usage" 1>&2; exit 2;; - *) break;; - esac -done - -# Set default libdir and config if not set by command line -# (Not all systems have dirname) -case $libdir in -'') case $0 in - */*) libdir=`echo $0 | sed 's,/[^/]*$,,'`;; - *) libdir=.;; - esac;; -esac -case $config in -'') config=$libdir/config.c.in;; -esac -case $makepre in -'') makepre=Makefile.pre;; -esac - -# Newline for sed i and a commands -NL='\ -' - -# Setup to link with extra libraries when makeing shared extensions. -# Currently, only Cygwin needs this baggage. -case `uname -s` in -CYGWIN*) if test $libdir = . - then - ExtraLibDir=. - else - ExtraLibDir='$(LIBPL)' - fi - ExtraLibs="-L$ExtraLibDir -lpython\$(VERSION)";; -esac - -# Main loop -for i in ${*-Setup} -do - case $i in - -n) echo '*noobjects*';; - *) echo '*doconfig*'; cat "$i";; - esac -done | -sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | -( - rulesf="@rules.$$" - trap 'rm -f $rulesf' 0 1 2 3 - echo " -# Rules appended by makedepend -" >$rulesf - DEFS= - MODS= - SHAREDMODS= - OBJS= - LIBS= - LOCALLIBS= - BASELIBS= - while read line - do - # to handle backslashes for sh's that don't automatically - # continue a read when the last char is a backslash - while echo $line | grep '\\$' > /dev/null - do - read extraline - line=`echo $line| sed s/.$//`$extraline - done - - # Output DEFS in reverse order so first definition overrides - case $line in - *=*) DEFS="$line$NL$DEFS"; continue;; - 'include '*) DEFS="$line$NL$DEFS"; continue;; - '*noobjects*') - case $noobjects in - yes) ;; - *) LOCALLIBS=$LIBS; LIBS=;; - esac - noobjects=yes; - continue;; - '*doconfig*') doconfig=yes; continue;; - '*static*') doconfig=yes; continue;; - '*noconfig*') doconfig=no; continue;; - '*shared*') doconfig=no; continue;; - esac - srcs= - cpps= - libs= - mods= - skip= - for arg in $line - do - case $skip in - libs) libs="$libs $arg"; skip=; continue;; - cpps) cpps="$cpps $arg"; skip=; continue;; - srcs) srcs="$srcs $arg"; skip=; continue;; - esac - case $arg in - -framework) libs="$libs $arg"; skip=libs; - # OSX/OSXS/Darwin framework link cmd - ;; - -[IDUCfF]*) cpps="$cpps $arg";; - -Xcompiler) skip=cpps;; - -Xlinker) libs="$libs $arg"; skip=libs;; - -rpath) libs="$libs $arg"; skip=libs;; - --rpath) libs="$libs $arg"; skip=libs;; - -[A-Zl]*) libs="$libs $arg";; - *.a) libs="$libs $arg";; - *.so) libs="$libs $arg";; - *.sl) libs="$libs $arg";; - /*.o) libs="$libs $arg";; - *.def) libs="$libs $arg";; - *.o) srcs="$srcs `basename $arg .o`.c";; - *.[cC]) srcs="$srcs $arg";; - *.m) srcs="$srcs $arg";; # Objective-C src - *.cc) srcs="$srcs $arg";; - *.c++) srcs="$srcs $arg";; - *.cxx) srcs="$srcs $arg";; - *.cpp) srcs="$srcs $arg";; - \$*) libs="$libs $arg" - cpps="$cpps $arg";; - *.*) echo 1>&2 "bad word $arg in $line" - exit 1;; - -u) skip=libs; libs="$libs -u";; - [a-zA-Z_]*) mods="$mods $arg";; - *) echo 1>&2 "bad word $arg in $line" - exit 1;; - esac - done - case $doconfig in - yes) - LIBS="$LIBS $libs" - MODS="$MODS $mods" - ;; - esac - case $noobjects in - yes) continue;; - esac - objs='' - for src in $srcs - do - case $src in - *.c) obj=`basename $src .c`.o; cc='$(CC)';; - *.cc) obj=`basename $src .cc`.o; cc='$(CXX)';; - *.c++) obj=`basename $src .c++`.o; cc='$(CXX)';; - *.C) obj=`basename $src .C`.o; cc='$(CXX)';; - *.cxx) obj=`basename $src .cxx`.o; cc='$(CXX)';; - *.cpp) obj=`basename $src .cpp`.o; cc='$(CXX)';; - *.m) obj=`basename $src .m`.o; cc='$(CC)';; # Obj-C - *) continue;; - esac - obj="$srcdir/$obj" - objs="$objs $obj" - case $src in - glmodule.c) ;; - /*) ;; - \$*) ;; - *) src='$(srcdir)/'"$srcdir/$src";; - esac - case $doconfig in - no) cc="$cc \$(CCSHARED) \$(CFLAGS) \$(CPPFLAGS)";; - *) - cc="$cc \$(PY_CFLAGS)";; - esac - rule="$obj: $src; $cc $cpps -c $src -o $obj" - echo "$rule" >>$rulesf - done - case $doconfig in - yes) OBJS="$OBJS $objs";; - esac - for mod in $mods - do - case $objs in - *$mod.o*) base=$mod;; - *) base=${mod}module;; - esac - file="$srcdir/$base\$(SO)" - case $doconfig in - no) SHAREDMODS="$SHAREDMODS $file";; - esac - rule="$file: $objs" - rule="$rule; \$(LDSHARED) $objs $libs $ExtraLibs -o $file" - echo "$rule" >>$rulesf - done - done - - case $SHAREDMODS in - '') ;; - *) DEFS="SHAREDMODS=$SHAREDMODS$NL$DEFS";; - esac - - case $noobjects in - yes) BASELIBS=$LIBS;; - *) LOCALLIBS=$LIBS;; - esac - LIBS='$(LOCALMODLIBS) $(BASEMODLIBS)' - DEFS="BASEMODLIBS=$BASELIBS$NL$DEFS" - DEFS="LOCALMODLIBS=$LOCALLIBS$NL$DEFS" - - EXTDECLS= - INITBITS= - for mod in $MODS - do - EXTDECLS="${EXTDECLS}extern void init$mod(void);$NL" - INITBITS="${INITBITS} {\"$mod\", init$mod},$NL" - done - - - case $config in - -) ;; - *) sed -e " - 1i$NL/* Generated automatically from $config by makesetup. */ - /MARKER 1/i$NL$EXTDECLS - - /MARKER 2/i$NL$INITBITS - - " $config >config.c - ;; - esac - - case $makepre in - -) ;; - *) sedf="@sed.in.$$" - trap 'rm -f $sedf' 0 1 2 3 - echo "1i\\" >$sedf - str="# Generated automatically from $makepre by makesetup." - echo "$str" >>$sedf - echo "s%_MODOBJS_%$OBJS%" >>$sedf - echo "s%_MODLIBS_%$LIBS%" >>$sedf - echo "/Definitions added by makesetup/a$NL$NL$DEFS" >>$sedf - sed -f $sedf $makepre >Makefile - cat $rulesf >>Makefile - rm -f $sedf - ;; - esac - - rm -f $rulesf -) diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/makexp_aix b/SDKs/XPlatform/Cypython-2.3.3/Modules/makexp_aix deleted file mode 100644 index 10f680a9..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/makexp_aix +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh -# -# =========================================================================== -# FILE: makexp_aix -# TYPE: standalone executable -# SYSTEM: AIX 3.2.5 and AIX 4 -# -# DESCRIPTION: This script creates an export list of ALL global symbols -# from a list of object or archive files. -# -# USAGE: makexp_aix "" ... -# -# where: -# is the target export list filename. -# is the path/file string to be appended -# after the "#!" symbols in the first line of the -# export file. Passing "" means deferred resolution. -# is an object (.o) or an archive file (.a). -# -# HISTORY: -# 3-Apr-1998 -- remove C++ entries of the form Class::method -# Vladimir Marangozov -# -# 1-Jul-1996 -- added header information -# Vladimir Marangozov -# -# 28-Jun-1996 -- initial code -# Vladimir Marangozov (Vladimir.Marangozov@imag.fr) -# ========================================================================== - -# Variables -expFileName=$1 -toAppendStr=$2 -shift; shift; -inputFiles=$* -automsg="Generated automatically by makexp_aix" -notemsg="NOTE: lists _all_ global symbols defined in the above file(s)." -curwdir=`pwd` - -# Create the export file and setup the header info -echo "#!"$toAppendStr > $expFileName -echo "*" >> $expFileName -echo "* $automsg (`date -u`)" >> $expFileName -echo "*" >> $expFileName -echo "* Base Directory: $curwdir" >> $expFileName -echo "* Input File(s) : $inputFiles" >> $expFileName -echo "*" >> $expFileName -echo "* $notemsg" >> $expFileName -echo "*" >> $expFileName - -# Extract the symbol list using 'nm' which produces quite -# different output under AIX 4 than under AIX 3.2.5. -# The following handles both versions by using a common flagset. -# Here are some hidden tricks: -# 1. Use /usr/ccs/bin/nm. Relevant to AIX 3.2.5 which has -# another version under /usr/ucb/bin/nm. -# 2. Use the -B flag to have a standard BSD representation -# of the symbol list on both AIX 3.2.5 and AIX 4. The "-B" -# flag is missing in the AIX 3.2.5 online usage help of 'nm'. -# 3. Use the -x flag to have a hex representation of the symbol -# values. This fills the leading whitespaces on AIX 4, -# thus simplifying the sed statement. -# 4. Eliminate all entries except those with either "B", "D" -# or "T" key letters. We are interested only in the global -# (extern) BSS, DATA and TEXT symbols. With the same statement -# we eliminate object member lines relevant to AIX 4. -# 5. Eliminate entries containing a dot. We can have a dot only -# as a symbol prefix, but such symbols are undefined externs. -# 6. Eliminate everything including the key letter, so that we're -# left with just the symbol name. -# 7. Eliminate all entries containing two colons, like Class::method -# -/usr/ccs/bin/nm -Bex $inputFiles \ -| sed -e '/ [^BDT] /d' -e '/\./d' -e 's/.* [BDT] //' -e '/::/d' \ -| sort | uniq >> $expFileName diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/mathmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/mathmodule.c deleted file mode 100644 index 251db130..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/mathmodule.c +++ /dev/null @@ -1,391 +0,0 @@ -/* Math module -- standard C math library functions, pi and e */ - -#include "Python.h" -#include "longintrepr.h" - -#ifndef _MSC_VER -#ifndef __STDC__ -extern double fmod (double, double); -extern double frexp (double, int *); -extern double ldexp (double, int); -extern double modf (double, double *); -#endif /* __STDC__ */ -#endif /* _MSC_VER */ - -/* Call is_error when errno != 0, and where x is the result libm - * returned. is_error will usually set up an exception and return - * true (1), but may return false (0) without setting up an exception. - */ -static int -is_error(double x) -{ - int result = 1; /* presumption of guilt */ - assert(errno); /* non-zero errno is a precondition for calling */ - if (errno == EDOM) - PyErr_SetString(PyExc_ValueError, "math domain error"); - - else if (errno == ERANGE) { - /* ANSI C generally requires libm functions to set ERANGE - * on overflow, but also generally *allows* them to set - * ERANGE on underflow too. There's no consistency about - * the latter across platforms. - * Alas, C99 never requires that errno be set. - * Here we suppress the underflow errors (libm functions - * should return a zero on underflow, and +- HUGE_VAL on - * overflow, so testing the result for zero suffices to - * distinguish the cases). - */ - if (x) - PyErr_SetString(PyExc_OverflowError, - "math range error"); - else - result = 0; - } - else - /* Unexpected math error */ - PyErr_SetFromErrno(PyExc_ValueError); - return result; -} - -static PyObject * -math_1(PyObject *args, double (*func) (double), char *argsfmt) -{ - double x; - if (! PyArg_ParseTuple(args, argsfmt, &x)) - return NULL; - errno = 0; - PyFPE_START_PROTECT("in math_1", return 0) - x = (*func)(x); - PyFPE_END_PROTECT(x) - Py_SET_ERANGE_IF_OVERFLOW(x); - if (errno && is_error(x)) - return NULL; - else - return PyFloat_FromDouble(x); -} - -static PyObject * -math_2(PyObject *args, double (*func) (double, double), char *argsfmt) -{ - double x, y; - if (! PyArg_ParseTuple(args, argsfmt, &x, &y)) - return NULL; - errno = 0; - PyFPE_START_PROTECT("in math_2", return 0) - x = (*func)(x, y); - PyFPE_END_PROTECT(x) - Py_SET_ERANGE_IF_OVERFLOW(x); - if (errno && is_error(x)) - return NULL; - else - return PyFloat_FromDouble(x); -} - -#define FUNC1(funcname, func, docstring) \ - static PyObject * math_##funcname(PyObject *self, PyObject *args) { \ - return math_1(args, func, "d:" #funcname); \ - }\ - PyDoc_STRVAR(math_##funcname##_doc, docstring); - -#define FUNC2(funcname, func, docstring) \ - static PyObject * math_##funcname(PyObject *self, PyObject *args) { \ - return math_2(args, func, "dd:" #funcname); \ - }\ - PyDoc_STRVAR(math_##funcname##_doc, docstring); - -FUNC1(acos, acos, - "acos(x)\n\nReturn the arc cosine (measured in radians) of x.") -FUNC1(asin, asin, - "asin(x)\n\nReturn the arc sine (measured in radians) of x.") -FUNC1(atan, atan, - "atan(x)\n\nReturn the arc tangent (measured in radians) of x.") -FUNC2(atan2, atan2, - "atan2(y, x)\n\nReturn the arc tangent (measured in radians) of y/x.\n" - "Unlike atan(y/x), the signs of both x and y are considered.") -FUNC1(ceil, ceil, - "ceil(x)\n\nReturn the ceiling of x as a float.\n" - "This is the smallest integral value >= x.") -FUNC1(cos, cos, - "cos(x)\n\nReturn the cosine of x (measured in radians).") -FUNC1(cosh, cosh, - "cosh(x)\n\nReturn the hyperbolic cosine of x.") -FUNC1(exp, exp, - "exp(x)\n\nReturn e raised to the power of x.") -FUNC1(fabs, fabs, - "fabs(x)\n\nReturn the absolute value of the float x.") -FUNC1(floor, floor, - "floor(x)\n\nReturn the floor of x as a float.\n" - "This is the largest integral value <= x.") -FUNC2(fmod, fmod, - "fmod(x,y)\n\nReturn fmod(x, y), according to platform C." - " x % y may differ.") -FUNC2(hypot, hypot, - "hypot(x,y)\n\nReturn the Euclidean distance, sqrt(x*x + y*y).") -#ifdef MPW_3_1 /* This hack is needed for MPW 3.1 but not for 3.2 ... */ -FUNC2(pow, power, - "pow(x,y)\n\nReturn x**y (x to the power of y).") -#else -FUNC2(pow, pow, - "pow(x,y)\n\nReturn x**y (x to the power of y).") -#endif -FUNC1(sin, sin, - "sin(x)\n\nReturn the sine of x (measured in radians).") -FUNC1(sinh, sinh, - "sinh(x)\n\nReturn the hyperbolic sine of x.") -FUNC1(sqrt, sqrt, - "sqrt(x)\n\nReturn the square root of x.") -FUNC1(tan, tan, - "tan(x)\n\nReturn the tangent of x (measured in radians).") -FUNC1(tanh, tanh, - "tanh(x)\n\nReturn the hyperbolic tangent of x.") - -static PyObject * -math_frexp(PyObject *self, PyObject *args) -{ - double x; - int i; - if (! PyArg_ParseTuple(args, "d:frexp", &x)) - return NULL; - errno = 0; - x = frexp(x, &i); - Py_SET_ERANGE_IF_OVERFLOW(x); - if (errno && is_error(x)) - return NULL; - else - return Py_BuildValue("(di)", x, i); -} - -PyDoc_STRVAR(math_frexp_doc, -"frexp(x)\n" -"\n" -"Return the mantissa and exponent of x, as pair (m, e).\n" -"m is a float and e is an int, such that x = m * 2.**e.\n" -"If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0."); - -static PyObject * -math_ldexp(PyObject *self, PyObject *args) -{ - double x; - int exp; - if (! PyArg_ParseTuple(args, "di:ldexp", &x, &exp)) - return NULL; - errno = 0; - PyFPE_START_PROTECT("ldexp", return 0) - x = ldexp(x, exp); - PyFPE_END_PROTECT(x) - Py_SET_ERANGE_IF_OVERFLOW(x); - if (errno && is_error(x)) - return NULL; - else - return PyFloat_FromDouble(x); -} - -PyDoc_STRVAR(math_ldexp_doc, -"ldexp(x, i) -> x * (2**i)"); - -static PyObject * -math_modf(PyObject *self, PyObject *args) -{ - double x, y; - if (! PyArg_ParseTuple(args, "d:modf", &x)) - return NULL; - errno = 0; -#ifdef MPW /* MPW C modf expects pointer to extended as second argument */ - { - extended e; - x = modf(x, &e); - y = e; - } -#else - x = modf(x, &y); -#endif - Py_SET_ERANGE_IF_OVERFLOW(x); - if (errno && is_error(x)) - return NULL; - else - return Py_BuildValue("(dd)", x, y); -} - -PyDoc_STRVAR(math_modf_doc, -"modf(x)\n" -"\n" -"Return the fractional and integer parts of x. Both results carry the sign\n" -"of x. The integer part is returned as a real."); - -/* A decent logarithm is easy to compute even for huge longs, but libm can't - do that by itself -- loghelper can. func is log or log10, and name is - "log" or "log10". Note that overflow isn't possible: a long can contain - no more than INT_MAX * SHIFT bits, so has value certainly less than - 2**(2**64 * 2**16) == 2**2**80, and log2 of that is 2**80, which is - small enough to fit in an IEEE single. log and log10 are even smaller. -*/ - -static PyObject* -loghelper(PyObject* args, double (*func)(double), char *format, PyObject *arg) -{ - /* If it is long, do it ourselves. */ - if (PyLong_Check(arg)) { - double x; - int e; - x = _PyLong_AsScaledDouble(arg, &e); - if (x <= 0.0) { - PyErr_SetString(PyExc_ValueError, - "math domain error"); - return NULL; - } - /* Value is ~= x * 2**(e*SHIFT), so the log ~= - log(x) + log(2) * e * SHIFT. - CAUTION: e*SHIFT may overflow using int arithmetic, - so force use of double. */ - x = func(x) + (e * (double)SHIFT) * func(2.0); - return PyFloat_FromDouble(x); - } - - /* Else let libm handle it by itself. */ - return math_1(args, func, format); -} - -static PyObject * -math_log(PyObject *self, PyObject *args) -{ - PyObject *arg; - PyObject *base = NULL; - PyObject *num, *den; - PyObject *ans; - PyObject *newargs; - - if (!PyArg_UnpackTuple(args, "log", 1, 2, &arg, &base)) - return NULL; - if (base == NULL) - return loghelper(args, log, "d:log", arg); - - newargs = PyTuple_New(1); - if (newargs == NULL) - return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(newargs, 0, arg); - num = loghelper(newargs, log, "d:log", arg); - Py_DECREF(newargs); - if (num == NULL) - return NULL; - - newargs = PyTuple_New(1); - if (newargs == NULL) { - Py_DECREF(num); - return NULL; - } - Py_INCREF(base); - PyTuple_SET_ITEM(newargs, 0, base); - den = loghelper(newargs, log, "d:log", base); - Py_DECREF(newargs); - if (den == NULL) { - Py_DECREF(num); - return NULL; - } - - ans = PyNumber_Divide(num, den); - Py_DECREF(num); - Py_DECREF(den); - return ans; -} - -PyDoc_STRVAR(math_log_doc, -"log(x[, base]) -> the logarithm of x to the given base.\n\ -If the base not specified, returns the natural logarithm (base e) of x."); - -static PyObject * -math_log10(PyObject *self, PyObject *args) -{ - PyObject *arg; - - if (!PyArg_UnpackTuple(args, "log10", 1, 1, &arg)) - return NULL; - return loghelper(args, log10, "d:log10", arg); -} - -PyDoc_STRVAR(math_log10_doc, -"log10(x) -> the base 10 logarithm of x."); - -static const double degToRad = 3.141592653589793238462643383 / 180.0; - -static PyObject * -math_degrees(PyObject *self, PyObject *args) -{ - double x; - if (! PyArg_ParseTuple(args, "d:degrees", &x)) - return NULL; - return PyFloat_FromDouble(x / degToRad); -} - -PyDoc_STRVAR(math_degrees_doc, -"degrees(x) -> converts angle x from radians to degrees"); - -static PyObject * -math_radians(PyObject *self, PyObject *args) -{ - double x; - if (! PyArg_ParseTuple(args, "d:radians", &x)) - return NULL; - return PyFloat_FromDouble(x * degToRad); -} - -PyDoc_STRVAR(math_radians_doc, -"radians(x) -> converts angle x from degrees to radians"); - -static PyMethodDef math_methods[] = { - {"acos", math_acos, METH_VARARGS, math_acos_doc}, - {"asin", math_asin, METH_VARARGS, math_asin_doc}, - {"atan", math_atan, METH_VARARGS, math_atan_doc}, - {"atan2", math_atan2, METH_VARARGS, math_atan2_doc}, - {"ceil", math_ceil, METH_VARARGS, math_ceil_doc}, - {"cos", math_cos, METH_VARARGS, math_cos_doc}, - {"cosh", math_cosh, METH_VARARGS, math_cosh_doc}, - {"degrees", math_degrees, METH_VARARGS, math_degrees_doc}, - {"exp", math_exp, METH_VARARGS, math_exp_doc}, - {"fabs", math_fabs, METH_VARARGS, math_fabs_doc}, - {"floor", math_floor, METH_VARARGS, math_floor_doc}, - {"fmod", math_fmod, METH_VARARGS, math_fmod_doc}, - {"frexp", math_frexp, METH_VARARGS, math_frexp_doc}, - {"hypot", math_hypot, METH_VARARGS, math_hypot_doc}, - {"ldexp", math_ldexp, METH_VARARGS, math_ldexp_doc}, - {"log", math_log, METH_VARARGS, math_log_doc}, - {"log10", math_log10, METH_VARARGS, math_log10_doc}, - {"modf", math_modf, METH_VARARGS, math_modf_doc}, - {"pow", math_pow, METH_VARARGS, math_pow_doc}, - {"radians", math_radians, METH_VARARGS, math_radians_doc}, - {"sin", math_sin, METH_VARARGS, math_sin_doc}, - {"sinh", math_sinh, METH_VARARGS, math_sinh_doc}, - {"sqrt", math_sqrt, METH_VARARGS, math_sqrt_doc}, - {"tan", math_tan, METH_VARARGS, math_tan_doc}, - {"tanh", math_tanh, METH_VARARGS, math_tanh_doc}, - {NULL, NULL} /* sentinel */ -}; - - -PyDoc_STRVAR(module_doc, -"This module is always available. It provides access to the\n" -"mathematical functions defined by the C standard."); - -PyMODINIT_FUNC -initmath(void) -{ - PyObject *m, *d, *v; - - m = Py_InitModule3("math", math_methods, module_doc); - d = PyModule_GetDict(m); - - if (!(v = PyFloat_FromDouble(atan(1.0) * 4.0))) - goto finally; - if (PyDict_SetItemString(d, "pi", v) < 0) - goto finally; - Py_DECREF(v); - - if (!(v = PyFloat_FromDouble(exp(1.0)))) - goto finally; - if (PyDict_SetItemString(d, "e", v) < 0) - goto finally; - Py_DECREF(v); - - finally: - return; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/md5.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/md5.h deleted file mode 100644 index a2cee425..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/md5.h +++ /dev/null @@ -1,62 +0,0 @@ -/* MD5.H - header file for MD5C.C - */ - -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. - */ - -/* ========== include global.h ========== */ -/* GLOBAL.H - RSAREF types and constants - */ - -/* POINTER defines a generic pointer type */ -typedef unsigned char *POINTER; - -/* UINT4 defines a four byte word */ -#if SIZEOF_LONG == 4 -typedef unsigned long int UINT4; -#elif SIZEOF_SHORT == 4 -typedef unsigned short int UINT4; -#elif INT_MAX == 2147483647 -typedef unsigned int UINT4; -#else -#error "Can't find a 4-byte integral type" -#endif - -/* ========== End global.h; continue md5.h ========== */ - -/* MD5 context. */ -typedef struct { - UINT4 state[4]; /* state (ABCD) */ - UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ - unsigned char buffer[64]; /* input buffer */ -} MD5_CTX; - -/* Rename all exported symbols to avoid conflicts with similarly named - symbols in some systems' standard C libraries... */ - -#define MD5Init _Py_MD5Init -#define MD5Update _Py_MD5Update -#define MD5Final _Py_MD5Final - -void MD5Init(MD5_CTX *); -void MD5Update(MD5_CTX *, unsigned char *, unsigned int); -void MD5Final(unsigned char [16], MD5_CTX *); diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/md5c.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/md5c.c deleted file mode 100644 index 02919367..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/md5c.c +++ /dev/null @@ -1,290 +0,0 @@ -/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm - */ - -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. - */ - -#include "Python.h" -#include "md5.h" - -/* Constants for MD5Transform routine. */ - -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - -static void MD5Transform(UINT4[4], unsigned char[64]); -static void Encode(unsigned char *, UINT4 *, unsigned int); -static void Decode(UINT4 *, unsigned char *, unsigned int); - -static unsigned char PADDING[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/* F, G, H and I are basic MD5 functions. */ -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | (~z))) - -/* ROTATE_LEFT rotates x left n bits. */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. - Rotation is separate from addition to prevent recomputation. - */ -#define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } - - -/* MD5 initialization. Begins an MD5 operation, writing a new context. */ -void -MD5Init(MD5_CTX *context) -{ - context->count[0] = context->count[1] = 0; - /* Load magic initialization constants. */ - context->state[0] = 0x67452301; - context->state[1] = 0xefcdab89; - context->state[2] = 0x98badcfe; - context->state[3] = 0x10325476; -} - - -/* MD5 block update operation. Continues an MD5 message-digest - operation, processing another message block, and updating the - context. - */ -void -MD5Update(MD5_CTX *context, unsigned char *input, unsigned int inputLen) -{ - unsigned int i, index, partLen; - - /* Compute number of bytes mod 64 */ - index = (unsigned int)((context->count[0] >> 3) & 0x3F); - - /* Update number of bits */ - if ((context->count[0] += ((UINT4)inputLen << 3)) - < ((UINT4)inputLen << 3)) - context->count[1]++; - context->count[1] += ((UINT4)inputLen >> 29); - - partLen = 64 - index; - - /* Transform as many times as possible. */ - if (inputLen >= partLen) { - memcpy((POINTER)&context->buffer[index], (POINTER)input, partLen); - MD5Transform(context->state, context->buffer); - - for (i = partLen; i + 63 < inputLen; i += 64) - MD5Transform(context->state, &input[i]); - - index = 0; - } - else - i = 0; - - /* Buffer remaining input */ - memcpy((POINTER)&context->buffer[index], - (POINTER)&input[i], inputLen-i); -} - -/* MD5 finalization. Ends an MD5 message-digest operation, writing the - message digest and zeroing the context. - */ -void -MD5Final(unsigned char digest[16], MD5_CTX *context) -{ - unsigned char bits[8]; - unsigned int index, padLen; - - /* Save number of bits */ - Encode (bits, context->count, 8); - - /* Pad out to 56 mod 64. */ - index = (unsigned int)((context->count[0] >> 3) & 0x3f); - padLen = (index < 56) ? (56 - index) : (120 - index); - MD5Update(context, PADDING, padLen); - - /* Append length (before padding) */ - MD5Update(context, bits, 8); - - /* Store state in digest */ - Encode(digest, context->state, 16); - - /* Zeroize sensitive information. */ - memset((POINTER)context, 0, sizeof (*context)); -} - - -/* MD5 basic transformation. Transforms state based on block. */ -static void -MD5Transform(UINT4 state[4], unsigned char block[64]) -{ - UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; - - Decode (x, block, 64); - - /* Round 1 */ - FF(a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ - FF(d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ - FF(c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ - FF(b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ - FF(a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ - FF(d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ - FF(c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ - FF(b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ - FF(a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ - FF(d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ - FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ - FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ - FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ - FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ - FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ - FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ - - /* Round 2 */ - GG(a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ - GG(d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ - GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ - GG(b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ - GG(a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ - GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */ - GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ - GG(b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ - GG(a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ - GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ - GG(c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ - GG(b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ - GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ - GG(d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ - GG(c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ - GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - HH(a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ - HH(d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ - HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ - HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ - HH(a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ - HH(d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ - HH(c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ - HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ - HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ - HH(d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ - HH(c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ - HH(b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ - HH(a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ - HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ - HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ - HH(b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - II(a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ - II(d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ - II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ - II(b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ - II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ - II(d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ - II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ - II(b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ - II(a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ - II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ - II(c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ - II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ - II(a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ - II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ - II(c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ - II(b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - /* Zeroize sensitive information. */ - memset((POINTER)x, 0, sizeof (x)); -} - - -/* Encodes input (UINT4) into output (unsigned char). Assumes len is - a multiple of 4. - */ -static void -Encode(unsigned char *output, UINT4 *input, unsigned int len) -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) { - output[j] = (unsigned char)(input[i] & 0xff); - output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); - output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); - output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); - } -} - - -/* Decodes input (unsigned char) into output (UINT4). Assumes len is - a multiple of 4. - */ -static void -Decode(UINT4 *output, unsigned char *input, unsigned int len) -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) { - output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | - (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/md5module.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/md5module.c deleted file mode 100644 index 587fefe3..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/md5module.c +++ /dev/null @@ -1,268 +0,0 @@ - -/* MD5 module */ - -/* This module provides an interface to the RSA Data Security, - Inc. MD5 Message-Digest Algorithm, described in RFC 1321. - It requires the files md5c.c and md5.h (which are slightly changed - from the versions in the RFC to avoid the "global.h" file.) */ - - -/* MD5 objects */ - -#include "Python.h" -#include "md5.h" - -typedef struct { - PyObject_HEAD - MD5_CTX md5; /* the context holder */ -} md5object; - -static PyTypeObject MD5type; - -#define is_md5object(v) ((v)->ob_type == &MD5type) - -static md5object * -newmd5object(void) -{ - md5object *md5p; - - md5p = PyObject_New(md5object, &MD5type); - if (md5p == NULL) - return NULL; - - MD5Init(&md5p->md5); /* actual initialisation */ - return md5p; -} - - -/* MD5 methods */ - -static void -md5_dealloc(md5object *md5p) -{ - PyObject_Del(md5p); -} - - -/* MD5 methods-as-attributes */ - -static PyObject * -md5_update(md5object *self, PyObject *args) -{ - unsigned char *cp; - int len; - - if (!PyArg_ParseTuple(args, "s#:update", &cp, &len)) - return NULL; - - MD5Update(&self->md5, cp, len); - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(update_doc, -"update (arg)\n\ -\n\ -Update the md5 object with the string arg. Repeated calls are\n\ -equivalent to a single call with the concatenation of all the\n\ -arguments."); - - -static PyObject * -md5_digest(md5object *self) -{ - MD5_CTX mdContext; - unsigned char aDigest[16]; - - /* make a temporary copy, and perform the final */ - mdContext = self->md5; - MD5Final(aDigest, &mdContext); - - return PyString_FromStringAndSize((char *)aDigest, 16); -} - -PyDoc_STRVAR(digest_doc, -"digest() -> string\n\ -\n\ -Return the digest of the strings passed to the update() method so\n\ -far. This is a 16-byte string which may contain non-ASCII characters,\n\ -including null bytes."); - - -static PyObject * -md5_hexdigest(md5object *self) -{ - MD5_CTX mdContext; - unsigned char digest[16]; - unsigned char hexdigest[32]; - int i, j; - - /* make a temporary copy, and perform the final */ - mdContext = self->md5; - MD5Final(digest, &mdContext); - - /* Make hex version of the digest */ - for(i=j=0; i<16; i++) { - char c; - c = (digest[i] >> 4) & 0xf; - c = (c>9) ? c+'a'-10 : c + '0'; - hexdigest[j++] = c; - c = (digest[i] & 0xf); - c = (c>9) ? c+'a'-10 : c + '0'; - hexdigest[j++] = c; - } - return PyString_FromStringAndSize((char*)hexdigest, 32); -} - - -PyDoc_STRVAR(hexdigest_doc, -"hexdigest() -> string\n\ -\n\ -Like digest(), but returns the digest as a string of hexadecimal digits."); - - -static PyObject * -md5_copy(md5object *self) -{ - md5object *md5p; - - if ((md5p = newmd5object()) == NULL) - return NULL; - - md5p->md5 = self->md5; - - return (PyObject *)md5p; -} - -PyDoc_STRVAR(copy_doc, -"copy() -> md5 object\n\ -\n\ -Return a copy (``clone'') of the md5 object."); - - -static PyMethodDef md5_methods[] = { - {"update", (PyCFunction)md5_update, METH_VARARGS, update_doc}, - {"digest", (PyCFunction)md5_digest, METH_NOARGS, digest_doc}, - {"hexdigest", (PyCFunction)md5_hexdigest, METH_NOARGS, hexdigest_doc}, - {"copy", (PyCFunction)md5_copy, METH_NOARGS, copy_doc}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -md5_getattr(md5object *self, char *name) -{ - if (strcmp(name, "digest_size") == 0) { - return PyInt_FromLong(16); - } - - return Py_FindMethod(md5_methods, (PyObject *)self, name); -} - -PyDoc_STRVAR(module_doc, -"This module implements the interface to RSA's MD5 message digest\n\ -algorithm (see also Internet RFC 1321). Its use is quite\n\ -straightforward: use the new() to create an md5 object. You can now\n\ -feed this object with arbitrary strings using the update() method, and\n\ -at any point you can ask it for the digest (a strong kind of 128-bit\n\ -checksum, a.k.a. ``fingerprint'') of the concatenation of the strings\n\ -fed to it so far using the digest() method.\n\ -\n\ -Functions:\n\ -\n\ -new([arg]) -- return a new md5 object, initialized with arg if provided\n\ -md5([arg]) -- DEPRECATED, same as new, but for compatibility\n\ -\n\ -Special Objects:\n\ -\n\ -MD5Type -- type object for md5 objects"); - -PyDoc_STRVAR(md5type_doc, -"An md5 represents the object used to calculate the MD5 checksum of a\n\ -string of information.\n\ -\n\ -Methods:\n\ -\n\ -update() -- updates the current digest with an additional string\n\ -digest() -- return the current digest value\n\ -hexdigest() -- return the current digest as a string of hexadecimal digits\n\ -copy() -- return a copy of the current md5 object"); - -static PyTypeObject MD5type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "md5.md5", /*tp_name*/ - sizeof(md5object), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)md5_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)md5_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - 0, /*tp_xxx4*/ - md5type_doc, /*tp_doc*/ -}; - - -/* MD5 functions */ - -static PyObject * -MD5_new(PyObject *self, PyObject *args) -{ - md5object *md5p; - unsigned char *cp = NULL; - int len = 0; - - if (!PyArg_ParseTuple(args, "|s#:new", &cp, &len)) - return NULL; - - if ((md5p = newmd5object()) == NULL) - return NULL; - - if (cp) - MD5Update(&md5p->md5, cp, len); - - return (PyObject *)md5p; -} - -PyDoc_STRVAR(new_doc, -"new([arg]) -> md5 object\n\ -\n\ -Return a new md5 object. If arg is present, the method call update(arg)\n\ -is made."); - - -/* List of functions exported by this module */ - -static PyMethodDef md5_functions[] = { - {"new", (PyCFunction)MD5_new, METH_VARARGS, new_doc}, - {"md5", (PyCFunction)MD5_new, METH_VARARGS, new_doc}, /* Backward compatibility */ - {NULL, NULL} /* Sentinel */ -}; - - -/* Initialize this module. */ - -PyMODINIT_FUNC -initmd5(void) -{ - PyObject *m, *d; - - MD5type.ob_type = &PyType_Type; - m = Py_InitModule3("md5", md5_functions, module_doc); - d = PyModule_GetDict(m); - PyDict_SetItemString(d, "MD5Type", (PyObject *)&MD5type); - PyModule_AddIntConstant(m, "digest_size", 16); - /* No need to check the error here, the caller will do that */ -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/mmapmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/mmapmodule.c deleted file mode 100644 index df3773aa..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/mmapmodule.c +++ /dev/null @@ -1,1124 +0,0 @@ -/* - / Author: Sam Rushing - / Hacked for Unix by AMK - / $Id: mmapmodule.c,v 2.46 2003/07/15 12:37:46 akuchling Exp $ - - / mmapmodule.cpp -- map a view of a file into memory - / - / todo: need permission flags, perhaps a 'chsize' analog - / not all functions check range yet!!! - / - / - / Note: This module currently only deals with 32-bit file - / sizes. - / - / This version of mmapmodule.c has been changed significantly - / from the original mmapfile.c on which it was based. - / The original version of mmapfile is maintained by Sam at - / ftp://squirl.nightmare.com/pub/python/python-ext. -*/ - -#include - -#ifndef MS_WINDOWS -#define UNIX -#endif - -#ifdef MS_WINDOWS -#include -static int -my_getpagesize(void) -{ - SYSTEM_INFO si; - GetSystemInfo(&si); - return si.dwPageSize; -} -#endif - -#ifdef UNIX -#include -#include - -#ifndef MS_SYNC -/* This is missing e.g. on SunOS 4.1.4 */ -#define MS_SYNC 0 -#endif - -#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE) -static int -my_getpagesize(void) -{ - return sysconf(_SC_PAGESIZE); -} -#else -#define my_getpagesize getpagesize -#endif - -#endif /* UNIX */ - -#include -#include - -static PyObject *mmap_module_error; - -typedef enum -{ - ACCESS_DEFAULT, - ACCESS_READ, - ACCESS_WRITE, - ACCESS_COPY -} access_mode; - -typedef struct { - PyObject_HEAD - char * data; - size_t size; - size_t pos; - -#ifdef MS_WINDOWS - HANDLE map_handle; - HANDLE file_handle; - char * tagname; -#endif - -#ifdef UNIX - int fd; -#endif - - access_mode access; -} mmap_object; - - -static void -mmap_object_dealloc(mmap_object *m_obj) -{ -#ifdef MS_WINDOWS - if (m_obj->data != NULL) - UnmapViewOfFile (m_obj->data); - if (m_obj->map_handle != INVALID_HANDLE_VALUE) - CloseHandle (m_obj->map_handle); - if (m_obj->file_handle != INVALID_HANDLE_VALUE) - CloseHandle (m_obj->file_handle); - if (m_obj->tagname) - PyMem_Free(m_obj->tagname); -#endif /* MS_WINDOWS */ - -#ifdef UNIX - if (m_obj->data!=NULL) { - msync(m_obj->data, m_obj->size, MS_SYNC); - munmap(m_obj->data, m_obj->size); - } -#endif /* UNIX */ - - PyObject_Del(m_obj); -} - -static PyObject * -mmap_close_method(mmap_object *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":close")) - return NULL; -#ifdef MS_WINDOWS - /* For each resource we maintain, we need to check - the value is valid, and if so, free the resource - and set the member value to an invalid value so - the dealloc does not attempt to resource clearing - again. - TODO - should we check for errors in the close operations??? - */ - if (self->data != NULL) { - UnmapViewOfFile (self->data); - self->data = NULL; - } - if (self->map_handle != INVALID_HANDLE_VALUE) { - CloseHandle (self->map_handle); - self->map_handle = INVALID_HANDLE_VALUE; - } - if (self->file_handle != INVALID_HANDLE_VALUE) { - CloseHandle (self->file_handle); - self->file_handle = INVALID_HANDLE_VALUE; - } -#endif /* MS_WINDOWS */ - -#ifdef UNIX - if (self->data != NULL) { - munmap(self->data, self->size); - self->data = NULL; - } -#endif - - Py_INCREF (Py_None); - return (Py_None); -} - -#ifdef MS_WINDOWS -#define CHECK_VALID(err) \ -do { \ - if (self->map_handle == INVALID_HANDLE_VALUE) { \ - PyErr_SetString (PyExc_ValueError, "mmap closed or invalid"); \ - return err; \ - } \ -} while (0) -#endif /* MS_WINDOWS */ - -#ifdef UNIX -#define CHECK_VALID(err) \ -do { \ - if (self->data == NULL) { \ - PyErr_SetString (PyExc_ValueError, "mmap closed or invalid"); \ - return err; \ - } \ -} while (0) -#endif /* UNIX */ - -static PyObject * -mmap_read_byte_method(mmap_object *self, - PyObject *args) -{ - CHECK_VALID(NULL); - if (!PyArg_ParseTuple(args, ":read_byte")) - return NULL; - if (self->pos < self->size) { - char value = self->data[self->pos]; - self->pos += 1; - return Py_BuildValue("c", value); - } else { - PyErr_SetString (PyExc_ValueError, "read byte out of range"); - return NULL; - } -} - -static PyObject * -mmap_read_line_method(mmap_object *self, - PyObject *args) -{ - char *start = self->data+self->pos; - char *eof = self->data+self->size; - char *eol; - PyObject *result; - - CHECK_VALID(NULL); - if (!PyArg_ParseTuple(args, ":readline")) - return NULL; - - eol = memchr(start, '\n', self->size - self->pos); - if (!eol) - eol = eof; - else - ++eol; /* we're interested in the position after the - newline. */ - result = PyString_FromStringAndSize(start, (eol - start)); - self->pos += (eol - start); - return (result); -} - -static PyObject * -mmap_read_method(mmap_object *self, - PyObject *args) -{ - long num_bytes; - PyObject *result; - - CHECK_VALID(NULL); - if (!PyArg_ParseTuple(args, "l:read", &num_bytes)) - return(NULL); - - /* silently 'adjust' out-of-range requests */ - if ((self->pos + num_bytes) > self->size) { - num_bytes -= (self->pos+num_bytes) - self->size; - } - result = Py_BuildValue("s#", self->data+self->pos, num_bytes); - self->pos += num_bytes; - return (result); -} - -static PyObject * -mmap_find_method(mmap_object *self, - PyObject *args) -{ - long start = self->pos; - char *needle; - int len; - - CHECK_VALID(NULL); - if (!PyArg_ParseTuple (args, "s#|l:find", &needle, &len, &start)) { - return NULL; - } else { - char *p; - char *e = self->data + self->size; - - if (start < 0) - start += self->size; - if (start < 0) - start = 0; - else if ((size_t)start > self->size) - start = self->size; - - for (p = self->data + start; p + len <= e; ++p) { - int i; - for (i = 0; i < len && needle[i] == p[i]; ++i) - /* nothing */; - if (i == len) { - return Py_BuildValue ( - "l", - (long) (p - self->data)); - } - } - return Py_BuildValue ("l", (long) -1); - } -} - -static int -is_writeable(mmap_object *self) -{ - if (self->access != ACCESS_READ) - return 1; - PyErr_Format(PyExc_TypeError, "mmap can't modify a readonly memory map."); - return 0; -} - -static int -is_resizeable(mmap_object *self) -{ - if ((self->access == ACCESS_WRITE) || (self->access == ACCESS_DEFAULT)) - return 1; - PyErr_Format(PyExc_TypeError, - "mmap can't resize a readonly or copy-on-write memory map."); - return 0; -} - - -static PyObject * -mmap_write_method(mmap_object *self, - PyObject *args) -{ - int length; - char *data; - - CHECK_VALID(NULL); - if (!PyArg_ParseTuple (args, "s#:write", &data, &length)) - return(NULL); - - if (!is_writeable(self)) - return NULL; - - if ((self->pos + length) > self->size) { - PyErr_SetString (PyExc_ValueError, "data out of range"); - return NULL; - } - memcpy (self->data+self->pos, data, length); - self->pos = self->pos+length; - Py_INCREF (Py_None); - return (Py_None); -} - -static PyObject * -mmap_write_byte_method(mmap_object *self, - PyObject *args) -{ - char value; - - CHECK_VALID(NULL); - if (!PyArg_ParseTuple (args, "c:write_byte", &value)) - return(NULL); - - if (!is_writeable(self)) - return NULL; - *(self->data+self->pos) = value; - self->pos += 1; - Py_INCREF (Py_None); - return (Py_None); -} - -static PyObject * -mmap_size_method(mmap_object *self, - PyObject *args) -{ - CHECK_VALID(NULL); - if (!PyArg_ParseTuple(args, ":size")) - return NULL; - -#ifdef MS_WINDOWS - if (self->file_handle != INVALID_HANDLE_VALUE) { - return (Py_BuildValue ( - "l", (long) - GetFileSize (self->file_handle, NULL))); - } else { - return (Py_BuildValue ("l", (long) self->size) ); - } -#endif /* MS_WINDOWS */ - -#ifdef UNIX - { - struct stat buf; - if (-1 == fstat(self->fd, &buf)) { - PyErr_SetFromErrno(mmap_module_error); - return NULL; - } - return (Py_BuildValue ("l", (long) buf.st_size) ); - } -#endif /* UNIX */ -} - -/* This assumes that you want the entire file mapped, - / and when recreating the map will make the new file - / have the new size - / - / Is this really necessary? This could easily be done - / from python by just closing and re-opening with the - / new size? - */ - -static PyObject * -mmap_resize_method(mmap_object *self, - PyObject *args) -{ - unsigned long new_size; - CHECK_VALID(NULL); - if (!PyArg_ParseTuple (args, "l:resize", &new_size) || - !is_resizeable(self)) { - return NULL; -#ifdef MS_WINDOWS - } else { - DWORD dwErrCode = 0; - /* First, unmap the file view */ - UnmapViewOfFile (self->data); - /* Close the mapping object */ - CloseHandle (self->map_handle); - /* Move to the desired EOF position */ - SetFilePointer (self->file_handle, - new_size, NULL, FILE_BEGIN); - /* Change the size of the file */ - SetEndOfFile (self->file_handle); - /* Create another mapping object and remap the file view */ - self->map_handle = CreateFileMapping ( - self->file_handle, - NULL, - PAGE_READWRITE, - 0, - new_size, - self->tagname); - if (self->map_handle != NULL) { - self->data = (char *) MapViewOfFile (self->map_handle, - FILE_MAP_WRITE, - 0, - 0, - 0); - if (self->data != NULL) { - self->size = new_size; - Py_INCREF (Py_None); - return Py_None; - } else { - dwErrCode = GetLastError(); - } - } else { - dwErrCode = GetLastError(); - } - PyErr_SetFromWindowsErr(dwErrCode); - return (NULL); -#endif /* MS_WINDOWS */ - -#ifdef UNIX -#ifndef HAVE_MREMAP - } else { - PyErr_SetString(PyExc_SystemError, - "mmap: resizing not available--no mremap()"); - return NULL; -#else - } else { - void *newmap; - -#ifdef MREMAP_MAYMOVE - newmap = mremap(self->data, self->size, new_size, MREMAP_MAYMOVE); -#else - newmap = mremap(self->data, self->size, new_size, 0); -#endif - if (newmap == (void *)-1) - { - PyErr_SetFromErrno(mmap_module_error); - return NULL; - } - self->data = newmap; - self->size = new_size; - Py_INCREF(Py_None); - return Py_None; -#endif /* HAVE_MREMAP */ -#endif /* UNIX */ - } -} - -static PyObject * -mmap_tell_method(mmap_object *self, PyObject *args) -{ - CHECK_VALID(NULL); - if (!PyArg_ParseTuple(args, ":tell")) - return NULL; - return (Py_BuildValue ("l", (long) self->pos) ); -} - -static PyObject * -mmap_flush_method(mmap_object *self, PyObject *args) -{ - size_t offset = 0; - size_t size = self->size; - CHECK_VALID(NULL); - if (!PyArg_ParseTuple (args, "|ll:flush", &offset, &size)) { - return NULL; - } else if ((offset + size) > self->size) { - PyErr_SetString (PyExc_ValueError, - "flush values out of range"); - return NULL; - } else { -#ifdef MS_WINDOWS - return (Py_BuildValue("l", (long) - FlushViewOfFile(self->data+offset, size))); -#endif /* MS_WINDOWS */ -#ifdef UNIX - /* XXX semantics of return value? */ - /* XXX flags for msync? */ - if (-1 == msync(self->data + offset, size, - MS_SYNC)) - { - PyErr_SetFromErrno(mmap_module_error); - return NULL; - } - return Py_BuildValue ("l", (long) 0); -#endif /* UNIX */ - } -} - -static PyObject * -mmap_seek_method(mmap_object *self, PyObject *args) -{ - int dist; - int how=0; - CHECK_VALID(NULL); - if (!PyArg_ParseTuple (args, "i|i:seek", &dist, &how)) { - return(NULL); - } else { - size_t where; - switch (how) { - case 0: /* relative to start */ - if (dist < 0) - goto onoutofrange; - where = dist; - break; - case 1: /* relative to current position */ - if ((int)self->pos + dist < 0) - goto onoutofrange; - where = self->pos + dist; - break; - case 2: /* relative to end */ - if ((int)self->size + dist < 0) - goto onoutofrange; - where = self->size + dist; - break; - default: - PyErr_SetString (PyExc_ValueError, - "unknown seek type"); - return NULL; - } - if (where > self->size) - goto onoutofrange; - self->pos = where; - Py_INCREF (Py_None); - return (Py_None); - } - - onoutofrange: - PyErr_SetString (PyExc_ValueError, "seek out of range"); - return NULL; -} - -static PyObject * -mmap_move_method(mmap_object *self, PyObject *args) -{ - unsigned long dest, src, count; - CHECK_VALID(NULL); - if (!PyArg_ParseTuple (args, "iii:move", &dest, &src, &count) || - !is_writeable(self)) { - return NULL; - } else { - /* bounds check the values */ - if (/* end of source after end of data?? */ - ((src+count) > self->size) - /* dest will fit? */ - || (dest+count > self->size)) { - PyErr_SetString (PyExc_ValueError, - "source or destination out of range"); - return NULL; - } else { - memmove (self->data+dest, self->data+src, count); - Py_INCREF (Py_None); - return Py_None; - } - } -} - -static struct PyMethodDef mmap_object_methods[] = { - {"close", (PyCFunction) mmap_close_method, METH_VARARGS}, - {"find", (PyCFunction) mmap_find_method, METH_VARARGS}, - {"flush", (PyCFunction) mmap_flush_method, METH_VARARGS}, - {"move", (PyCFunction) mmap_move_method, METH_VARARGS}, - {"read", (PyCFunction) mmap_read_method, METH_VARARGS}, - {"read_byte", (PyCFunction) mmap_read_byte_method, METH_VARARGS}, - {"readline", (PyCFunction) mmap_read_line_method, METH_VARARGS}, - {"resize", (PyCFunction) mmap_resize_method, METH_VARARGS}, - {"seek", (PyCFunction) mmap_seek_method, METH_VARARGS}, - {"size", (PyCFunction) mmap_size_method, METH_VARARGS}, - {"tell", (PyCFunction) mmap_tell_method, METH_VARARGS}, - {"write", (PyCFunction) mmap_write_method, METH_VARARGS}, - {"write_byte", (PyCFunction) mmap_write_byte_method, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - -/* Functions for treating an mmap'ed file as a buffer */ - -static int -mmap_buffer_getreadbuf(mmap_object *self, int index, const void **ptr) -{ - CHECK_VALID(-1); - if ( index != 0 ) { - PyErr_SetString(PyExc_SystemError, - "Accessing non-existent mmap segment"); - return -1; - } - *ptr = self->data; - return self->size; -} - -static int -mmap_buffer_getwritebuf(mmap_object *self, int index, const void **ptr) -{ - CHECK_VALID(-1); - if ( index != 0 ) { - PyErr_SetString(PyExc_SystemError, - "Accessing non-existent mmap segment"); - return -1; - } - if (!is_writeable(self)) - return -1; - *ptr = self->data; - return self->size; -} - -static int -mmap_buffer_getsegcount(mmap_object *self, int *lenp) -{ - CHECK_VALID(-1); - if (lenp) - *lenp = self->size; - return 1; -} - -static int -mmap_buffer_getcharbuffer(mmap_object *self, int index, const void **ptr) -{ - if ( index != 0 ) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent buffer segment"); - return -1; - } - *ptr = (const char *)self->data; - return self->size; -} - -static PyObject * -mmap_object_getattr(mmap_object *self, char *name) -{ - return Py_FindMethod (mmap_object_methods, (PyObject *)self, name); -} - -static int -mmap_length(mmap_object *self) -{ - CHECK_VALID(-1); - return self->size; -} - -static PyObject * -mmap_item(mmap_object *self, int i) -{ - CHECK_VALID(NULL); - if (i < 0 || (size_t)i >= self->size) { - PyErr_SetString(PyExc_IndexError, "mmap index out of range"); - return NULL; - } - return PyString_FromStringAndSize(self->data + i, 1); -} - -static PyObject * -mmap_slice(mmap_object *self, int ilow, int ihigh) -{ - CHECK_VALID(NULL); - if (ilow < 0) - ilow = 0; - else if ((size_t)ilow > self->size) - ilow = self->size; - if (ihigh < 0) - ihigh = 0; - if (ihigh < ilow) - ihigh = ilow; - else if ((size_t)ihigh > self->size) - ihigh = self->size; - - return PyString_FromStringAndSize(self->data + ilow, ihigh-ilow); -} - -static PyObject * -mmap_concat(mmap_object *self, PyObject *bb) -{ - CHECK_VALID(NULL); - PyErr_SetString(PyExc_SystemError, - "mmaps don't support concatenation"); - return NULL; -} - -static PyObject * -mmap_repeat(mmap_object *self, int n) -{ - CHECK_VALID(NULL); - PyErr_SetString(PyExc_SystemError, - "mmaps don't support repeat operation"); - return NULL; -} - -static int -mmap_ass_slice(mmap_object *self, int ilow, int ihigh, PyObject *v) -{ - const char *buf; - - CHECK_VALID(-1); - if (ilow < 0) - ilow = 0; - else if ((size_t)ilow > self->size) - ilow = self->size; - if (ihigh < 0) - ihigh = 0; - if (ihigh < ilow) - ihigh = ilow; - else if ((size_t)ihigh > self->size) - ihigh = self->size; - - if (v == NULL) { - PyErr_SetString(PyExc_TypeError, - "mmap object doesn't support slice deletion"); - return -1; - } - if (! (PyString_Check(v)) ) { - PyErr_SetString(PyExc_IndexError, - "mmap slice assignment must be a string"); - return -1; - } - if ( PyString_Size(v) != (ihigh - ilow) ) { - PyErr_SetString(PyExc_IndexError, - "mmap slice assignment is wrong size"); - return -1; - } - if (!is_writeable(self)) - return -1; - buf = PyString_AsString(v); - memcpy(self->data + ilow, buf, ihigh-ilow); - return 0; -} - -static int -mmap_ass_item(mmap_object *self, int i, PyObject *v) -{ - const char *buf; - - CHECK_VALID(-1); - if (i < 0 || (size_t)i >= self->size) { - PyErr_SetString(PyExc_IndexError, "mmap index out of range"); - return -1; - } - if (v == NULL) { - PyErr_SetString(PyExc_TypeError, - "mmap object doesn't support item deletion"); - return -1; - } - if (! (PyString_Check(v) && PyString_Size(v)==1) ) { - PyErr_SetString(PyExc_IndexError, - "mmap assignment must be single-character string"); - return -1; - } - if (!is_writeable(self)) - return -1; - buf = PyString_AsString(v); - self->data[i] = buf[0]; - return 0; -} - -static PySequenceMethods mmap_as_sequence = { - (inquiry)mmap_length, /*sq_length*/ - (binaryfunc)mmap_concat, /*sq_concat*/ - (intargfunc)mmap_repeat, /*sq_repeat*/ - (intargfunc)mmap_item, /*sq_item*/ - (intintargfunc)mmap_slice, /*sq_slice*/ - (intobjargproc)mmap_ass_item, /*sq_ass_item*/ - (intintobjargproc)mmap_ass_slice, /*sq_ass_slice*/ -}; - -static PyBufferProcs mmap_as_buffer = { - (getreadbufferproc)mmap_buffer_getreadbuf, - (getwritebufferproc)mmap_buffer_getwritebuf, - (getsegcountproc)mmap_buffer_getsegcount, - (getcharbufferproc)mmap_buffer_getcharbuffer, -}; - -static PyTypeObject mmap_object_type = { - PyObject_HEAD_INIT(0) /* patched in module init */ - 0, /* ob_size */ - "mmap.mmap", /* tp_name */ - sizeof(mmap_object), /* tp_size */ - 0, /* tp_itemsize */ - /* methods */ - (destructor) mmap_object_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - (getattrfunc) mmap_object_getattr, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - &mmap_as_sequence, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &mmap_as_buffer, /*tp_as_buffer*/ - Py_TPFLAGS_HAVE_GETCHARBUFFER, /*tp_flags*/ - 0, /*tp_doc*/ -}; - - -/* extract the map size from the given PyObject - - The map size is restricted to [0, INT_MAX] because this is the current - Python limitation on object sizes. Although the mmap object *could* handle - a larger map size, there is no point because all the useful operations - (len(), slicing(), sequence indexing) are limited by a C int. - - Returns -1 on error, with an appropriate Python exception raised. On - success, the map size is returned. */ -static int -_GetMapSize(PyObject *o) -{ - if (PyInt_Check(o)) { - long i = PyInt_AsLong(o); - if (PyErr_Occurred()) - return -1; - if (i < 0) - goto onnegoverflow; - if (i > INT_MAX) - goto onposoverflow; - return (int)i; - } - else if (PyLong_Check(o)) { - long i = PyLong_AsLong(o); - if (PyErr_Occurred()) { - /* yes negative overflow is mistaken for positive overflow - but not worth the trouble to check sign of 'i' */ - if (PyErr_ExceptionMatches(PyExc_OverflowError)) - goto onposoverflow; - else - return -1; - } - if (i < 0) - goto onnegoverflow; - if (i > INT_MAX) - goto onposoverflow; - return (int)i; - } - else { - PyErr_SetString(PyExc_TypeError, - "map size must be an integral value"); - return -1; - } - - onnegoverflow: - PyErr_SetString(PyExc_OverflowError, - "memory mapped size must be positive"); - return -1; - - onposoverflow: - PyErr_SetString(PyExc_OverflowError, - "memory mapped size is too large (limited by C int)"); - return -1; -} - -#ifdef UNIX -static PyObject * -new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict) -{ -#ifdef HAVE_FSTAT - struct stat st; -#endif - mmap_object *m_obj; - PyObject *map_size_obj = NULL; - int map_size; - int fd, flags = MAP_SHARED, prot = PROT_WRITE | PROT_READ; - access_mode access = ACCESS_DEFAULT; - char *keywords[] = {"fileno", "length", - "flags", "prot", - "access", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|iii", keywords, - &fd, &map_size_obj, &flags, &prot, &access)) - return NULL; - map_size = _GetMapSize(map_size_obj); - if (map_size < 0) - return NULL; - - if ((access != ACCESS_DEFAULT) && - ((flags != MAP_SHARED) || ( prot != (PROT_WRITE | PROT_READ)))) - return PyErr_Format(PyExc_ValueError, - "mmap can't specify both access and flags, prot."); - switch(access) { - case ACCESS_READ: - flags = MAP_SHARED; - prot = PROT_READ; - break; - case ACCESS_WRITE: - flags = MAP_SHARED; - prot = PROT_READ | PROT_WRITE; - break; - case ACCESS_COPY: - flags = MAP_PRIVATE; - prot = PROT_READ | PROT_WRITE; - break; - case ACCESS_DEFAULT: - /* use the specified or default values of flags and prot */ - break; - default: - return PyErr_Format(PyExc_ValueError, - "mmap invalid access parameter."); - } - -#ifdef HAVE_FSTAT -# ifdef __VMS - /* on OpenVMS we must ensure that all bytes are written to the file */ - fsync(fd); -# endif - if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode) && - (size_t)map_size > st.st_size) { - PyErr_SetString(PyExc_ValueError, - "mmap length is greater than file size"); - return NULL; - } -#endif - m_obj = PyObject_New (mmap_object, &mmap_object_type); - if (m_obj == NULL) {return NULL;} - m_obj->size = (size_t) map_size; - m_obj->pos = (size_t) 0; - m_obj->fd = fd; - m_obj->data = mmap(NULL, map_size, - prot, flags, - fd, 0); - if (m_obj->data == (char *)-1) { - Py_DECREF(m_obj); - PyErr_SetFromErrno(mmap_module_error); - return NULL; - } - m_obj->access = access; - return (PyObject *)m_obj; -} -#endif /* UNIX */ - -#ifdef MS_WINDOWS -static PyObject * -new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict) -{ - mmap_object *m_obj; - PyObject *map_size_obj = NULL; - int map_size; - char *tagname = ""; - DWORD dwErr = 0; - int fileno; - HANDLE fh = 0; - access_mode access = ACCESS_DEFAULT; - DWORD flProtect, dwDesiredAccess; - char *keywords[] = { "fileno", "length", - "tagname", - "access", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|zi", keywords, - &fileno, &map_size_obj, - &tagname, &access)) { - return NULL; - } - - switch(access) { - case ACCESS_READ: - flProtect = PAGE_READONLY; - dwDesiredAccess = FILE_MAP_READ; - break; - case ACCESS_DEFAULT: case ACCESS_WRITE: - flProtect = PAGE_READWRITE; - dwDesiredAccess = FILE_MAP_WRITE; - break; - case ACCESS_COPY: - flProtect = PAGE_WRITECOPY; - dwDesiredAccess = FILE_MAP_COPY; - break; - default: - return PyErr_Format(PyExc_ValueError, - "mmap invalid access parameter."); - } - - map_size = _GetMapSize(map_size_obj); - if (map_size < 0) - return NULL; - - /* if an actual filename has been specified */ - if (fileno != 0) { - fh = (HANDLE)_get_osfhandle(fileno); - if (fh==(HANDLE)-1) { - PyErr_SetFromErrno(mmap_module_error); - return NULL; - } - /* Win9x appears to need us seeked to zero */ - lseek(fileno, 0, SEEK_SET); - } - - m_obj = PyObject_New (mmap_object, &mmap_object_type); - if (m_obj==NULL) - return NULL; - /* Set every field to an invalid marker, so we can safely - destruct the object in the face of failure */ - m_obj->data = NULL; - m_obj->file_handle = INVALID_HANDLE_VALUE; - m_obj->map_handle = INVALID_HANDLE_VALUE; - m_obj->tagname = NULL; - - if (fh) { - /* It is necessary to duplicate the handle, so the - Python code can close it on us */ - if (!DuplicateHandle( - GetCurrentProcess(), /* source process handle */ - fh, /* handle to be duplicated */ - GetCurrentProcess(), /* target proc handle */ - (LPHANDLE)&m_obj->file_handle, /* result */ - 0, /* access - ignored due to options value */ - FALSE, /* inherited by child processes? */ - DUPLICATE_SAME_ACCESS)) { /* options */ - dwErr = GetLastError(); - Py_DECREF(m_obj); - PyErr_SetFromWindowsErr(dwErr); - return NULL; - } - if (!map_size) { - m_obj->size = GetFileSize (fh, NULL); - } else { - m_obj->size = map_size; - } - } - else { - m_obj->size = map_size; - } - - /* set the initial position */ - m_obj->pos = (size_t) 0; - - /* set the tag name */ - if (tagname != NULL && *tagname != '\0') { - m_obj->tagname = PyMem_Malloc(strlen(tagname)+1); - if (m_obj->tagname == NULL) { - PyErr_NoMemory(); - Py_DECREF(m_obj); - return NULL; - } - strcpy(m_obj->tagname, tagname); - } - else - m_obj->tagname = NULL; - - m_obj->access = access; - m_obj->map_handle = CreateFileMapping (m_obj->file_handle, - NULL, - flProtect, - 0, - m_obj->size, - m_obj->tagname); - if (m_obj->map_handle != NULL) { - m_obj->data = (char *) MapViewOfFile (m_obj->map_handle, - dwDesiredAccess, - 0, - 0, - 0); - if (m_obj->data != NULL) { - return ((PyObject *) m_obj); - } else { - dwErr = GetLastError(); - } - } else { - dwErr = GetLastError(); - } - Py_DECREF(m_obj); - PyErr_SetFromWindowsErr(dwErr); - return (NULL); -} -#endif /* MS_WINDOWS */ - -/* List of functions exported by this module */ -static struct PyMethodDef mmap_functions[] = { - {"mmap", (PyCFunction) new_mmap_object, - METH_VARARGS|METH_KEYWORDS}, - {NULL, NULL} /* Sentinel */ -}; - -PyMODINIT_FUNC - initmmap(void) -{ - PyObject *dict, *module; - - /* Patch the object type */ - mmap_object_type.ob_type = &PyType_Type; - - module = Py_InitModule ("mmap", mmap_functions); - dict = PyModule_GetDict (module); - mmap_module_error = PyExc_EnvironmentError; - Py_INCREF(mmap_module_error); - PyDict_SetItemString (dict, "error", mmap_module_error); -#ifdef PROT_EXEC - PyDict_SetItemString (dict, "PROT_EXEC", PyInt_FromLong(PROT_EXEC) ); -#endif -#ifdef PROT_READ - PyDict_SetItemString (dict, "PROT_READ", PyInt_FromLong(PROT_READ) ); -#endif -#ifdef PROT_WRITE - PyDict_SetItemString (dict, "PROT_WRITE", PyInt_FromLong(PROT_WRITE) ); -#endif - -#ifdef MAP_SHARED - PyDict_SetItemString (dict, "MAP_SHARED", PyInt_FromLong(MAP_SHARED) ); -#endif -#ifdef MAP_PRIVATE - PyDict_SetItemString (dict, "MAP_PRIVATE", - PyInt_FromLong(MAP_PRIVATE) ); -#endif -#ifdef MAP_DENYWRITE - PyDict_SetItemString (dict, "MAP_DENYWRITE", - PyInt_FromLong(MAP_DENYWRITE) ); -#endif -#ifdef MAP_EXECUTABLE - PyDict_SetItemString (dict, "MAP_EXECUTABLE", - PyInt_FromLong(MAP_EXECUTABLE) ); -#endif -#ifdef MAP_ANON - PyDict_SetItemString (dict, "MAP_ANON", PyInt_FromLong(MAP_ANON) ); - PyDict_SetItemString (dict, "MAP_ANONYMOUS", - PyInt_FromLong(MAP_ANON) ); -#endif - - PyDict_SetItemString (dict, "PAGESIZE", - PyInt_FromLong( (long)my_getpagesize() ) ); - - PyDict_SetItemString (dict, "ACCESS_READ", - PyInt_FromLong(ACCESS_READ)); - PyDict_SetItemString (dict, "ACCESS_WRITE", - PyInt_FromLong(ACCESS_WRITE)); - PyDict_SetItemString (dict, "ACCESS_COPY", - PyInt_FromLong(ACCESS_COPY)); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/mpzmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/mpzmodule.c deleted file mode 100644 index 95e2ca63..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/mpzmodule.c +++ /dev/null @@ -1,1690 +0,0 @@ - -/* MPZ module */ - -/* This module provides an interface to an alternate Multi-Precision - library, GNU MP in this case */ - -/* XXX note: everywhere where mpz_size is called, - sizeof (limb) == sizeof (long) has been assumed. */ - - -/* MPZ objects */ - -#include "Python.h" - -#include /* For size_t */ - -/* -** These are the cpp-flags used in this file... -** -** -** MPZ_MDIV_BUG works around the mpz_m{div,mod,...} routines. -** This bug has been fixed in a later release of -** GMP. -** -** MPZ_GET_STR_BUG mpz_get_str corrupts memory, seems to be fixed -** in a later release -** -** MPZ_DEBUG generates a bunch of diagnostic messages -** -** MPZ_SPARE_MALLOC if set, results in extra code that tries to -** minimize the creation of extra objects. -** -** MPZ_TEST_DIV extra diagnostic output on stderr, when division -** routines are involved -** -** MPZ_LIB_DOES_CHECKING if set, assumes that mpz library doesn't call -** alloca with arg < 0 (when casted to a signed -** integral type). -** -** MPZ_CONVERSIONS_AS_METHODS if set, presents the conversions as -** methods. e.g., `mpz(5).long() == 5L' -** Later, Guido provided an interface to the -** standard functions. So this flag has no been -** cleared, and `long(mpz(5)) == 5L' -** -** MP_TEST_ALLOC If set, you would discover why MPZ_GET_STR_BUG -** is needed -** -** MAKEDUMMYINT Must be set if dynamic linking will be used -*/ - - -/* -** IMHO, mpz_m{div,mod,divmod}() do the wrong things when the denominator < 0 -** This has been fixed with gmp release 2.0 -*/ -/*#define MPZ_MDIV_BUG fixed the (for me) nexessary parts in libgmp.a */ -/* -** IMO, mpz_get_str() assumes a bit too large target space, if he doesn't -** allocate it himself -*/ - -#include "gmp.h" - -#if __GNU_MP__ + 0 >= 2 -#define GMP2 -#define BITS_PER_MP_LIMB mp_bits_per_limb -#else -#define MPZ_GET_STR_BUG -#include "gmp-mparam.h" -#endif - -typedef struct { - PyObject_HEAD - MP_INT mpz; /* the actual number */ -} mpzobject; - -static PyTypeObject MPZtype; - -#define is_mpzobject(v) ((v)->ob_type == &MPZtype) - -static const char initialiser_name[] = "mpz"; - -/* #define MPZ_DEBUG */ - -static mpzobject * -newmpzobject(void) -{ - mpzobject *mpzp; - - -#ifdef MPZ_DEBUG - fputs( "mpz_object() called...\n", stderr ); -#endif /* def MPZ_DEBUG */ - mpzp = PyObject_New(mpzobject, &MPZtype); - if (mpzp == NULL) - return NULL; - - mpz_init(&mpzp->mpz); /* actual initialisation */ - return mpzp; -} /* newmpzobject() */ - -#ifdef MPZ_GET_STR_BUG -#include "longlong.h" -#endif /* def MPZ_GET_STR_BUG */ - -static PyObject * -mpz_format(PyObject *objp, int base, unsigned char withname) -{ - mpzobject *mpzp = (mpzobject *)objp; - PyStringObject *strobjp; - size_t i; - int cmpres; - int taglong; - char *cp; - char prefix[5], *tcp; - - - tcp = &prefix[0]; - - if (mpzp == NULL || !is_mpzobject(mpzp)) { - PyErr_BadInternalCall(); - return NULL; - } - - assert(base >= 2 && base <= 36); - - if (withname) - i = strlen(initialiser_name) + 2; /* e.g. 'mpz(' + ')' */ - else - i = 0; - - if ((cmpres = mpz_cmp_si(&mpzp->mpz, 0L)) == 0) - base = 10; /* '0' in every base, right */ - else if (cmpres < 0) { - *tcp++ = '-'; - i += 1; /* space to hold '-' */ - } - -#ifdef MPZ_DEBUG - fprintf(stderr, "mpz_format: mpz_sizeinbase %d\n", - (int)mpz_sizeinbase(&mpzp->mpz, base)); -#endif /* def MPZ_DEBUG */ -#ifdef MPZ_GET_STR_BUG -#ifdef GMP2 - i += ((size_t) abs(mpzp->mpz._mp_size) * BITS_PER_MP_LIMB - * __mp_bases[base].chars_per_bit_exactly) + 1; -#else - i += ((size_t) abs(mpzp->mpz.size) * BITS_PER_MP_LIMB - * __mp_bases[base].chars_per_bit_exactly) + 1; -#endif -#else /* def MPZ_GET_STR_BUG */ - i += (int)mpz_sizeinbase(&mpzp->mpz, base); -#endif /* def MPZ_GET_STR_BUG else */ - - if (base == 16) { - *tcp++ = '0'; - *tcp++ = 'x'; - i += 2; /* space to hold '0x' */ - } - else if (base == 8) { - *tcp++ = '0'; - i += 1; /* space to hold the extra '0' */ - } - else if (base > 10) { - *tcp++ = '0' + base / 10; - *tcp++ = '0' + base % 10; - *tcp++ = '#'; - i += 3; /* space to hold e.g. '12#' */ - } - else if (base < 10) { - *tcp++ = '0' + base; - *tcp++ = '#'; - i += 2; /* space to hold e.g. '6#' */ - } - - /* - ** the following code looks if we need a 'L' attached to the number - ** it will also attach an 'L' to the value -0x80000000 - */ - taglong = 0; - if (mpz_size(&mpzp->mpz) > 1 - || (long)mpz_get_ui(&mpzp->mpz) < 0L) { - taglong = 1; - i += 1; /* space to hold 'L' */ - } - -#ifdef MPZ_DEBUG - fprintf(stderr, "mpz_format: requesting string size %d\n", i); -#endif /* def MPZ_DEBUG */ - if ((strobjp = - (PyStringObject *)PyString_FromStringAndSize((char *)0, i)) - == NULL) - return NULL; - - /* get the beginning of the string memory and start copying things */ - cp = PyString_AS_STRING(strobjp); - if (withname) { - strcpy(cp, initialiser_name); - cp += strlen(initialiser_name); - *cp++ = '('; /*')'*/ - } - - /* copy the already prepared prefix; e.g. sign and base indicator */ - *tcp = '\0'; - strcpy(cp, prefix); - cp += tcp - prefix; - - /* since' we have the sign already, let the lib think it's a positive - number */ - if (cmpres < 0) - mpz_neg(&mpzp->mpz,&mpzp->mpz); /* hack Hack HAck HACk HACK */ - (void)mpz_get_str(cp, base, &mpzp->mpz); - if (cmpres < 0) - mpz_neg(&mpzp->mpz,&mpzp->mpz); /* hack Hack HAck HACk HACK */ -#ifdef MPZ_DEBUG - fprintf(stderr, "mpz_format: base (ultim) %d, mpz_get_str: %s\n", - base, cp); -#endif /* def MPZ_DEBUG */ - cp += strlen(cp); - - if (taglong) - *cp++ = 'L'; - if (withname) - *cp++ = /*'('*/ ')'; - - *cp = '\0'; - -#ifdef MPZ_DEBUG - fprintf(stderr, - "mpz_format: cp (str end) %p, begin %p, diff %d, i %d\n", - cp, PyString_AS_STRING(strobjp), - cp - PyString_AS_STRING(strobjp), i); -#endif /* def MPZ_DEBUG */ - assert(cp - PyString_AS_STRING(strobjp) <= i); - - if (cp - PyString_AS_STRING(strobjp) != i) { - strobjp->ob_size -= i - (cp - PyString_AS_STRING(strobjp)); - } - - return (PyObject *)strobjp; -} /* mpz_format() */ - -/* MPZ methods */ - -static void -mpz_dealloc(mpzobject *mpzp) -{ -#ifdef MPZ_DEBUG - fputs( "mpz_dealloc() called...\n", stderr ); -#endif /* def MPZ_DEBUG */ - mpz_clear(&mpzp->mpz); - PyObject_Del(mpzp); -} /* mpz_dealloc() */ - - -/* pointers to frequently used values 0, 1 and -1 */ -static mpzobject *mpz_value_zero, *mpz_value_one, *mpz_value_mone; - -static int -mpz_compare(mpzobject *a, mpzobject *b) -{ - int cmpres; - - - /* guido sez it's better to return -1, 0 or 1 */ - return (cmpres = mpz_cmp( &a->mpz, &b->mpz )) == 0 ? 0 - : cmpres > 0 ? 1 : -1; -} /* mpz_compare() */ - -static PyObject * -mpz_addition(mpzobject *a, mpzobject *b) -{ - mpzobject *z; - - -#ifdef MPZ_SPARE_MALLOC - if (mpz_cmp_ui(&a->mpz, (unsigned long int)0) == 0) { - Py_INCREF(b); - return (PyObject *)b; - } - - if (mpz_cmp_ui(&b->mpz, (unsigned long int)0) == 0) { - Py_INCREF(a); - return (PyObject *)a; - } -#endif /* def MPZ_SPARE_MALLOC */ - - if ((z = newmpzobject()) == NULL) - return NULL; - - mpz_add(&z->mpz, &a->mpz, &b->mpz); - return (PyObject *)z; -} /* mpz_addition() */ - -static PyObject * -mpz_substract(mpzobject *a, mpzobject *b) -{ - mpzobject *z; - - -#ifdef MPZ_SPARE_MALLOC - if (mpz_cmp_ui(&b->mpz, (unsigned long int)0) == 0) { - Py_INCREF(a); - return (PyObject *)a; - } -#endif /* MPZ_SPARE_MALLOC */ - - if ((z = newmpzobject()) == NULL) - return NULL; - - mpz_sub(&z->mpz, &a->mpz, &b->mpz); - return (PyObject *)z; -} /* mpz_substract() */ - -static PyObject * -mpz_multiply(mpzobject *a, mpzobject *b) -{ -#ifdef MPZ_SPARE_MALLOC - int cmpres; -#endif /* def MPZ_SPARE_MALLOC */ - mpzobject *z; - - -#ifdef MPZ_SPARE_MALLOC - if ((cmpres = mpz_cmp_ui(&a->mpz, (unsigned long int)0)) == 0) { - Py_INCREF(mpz_value_zero); - return (PyObject *)mpz_value_zero; - } - if (cmpres > 0 && mpz_cmp_ui(&a->mpz, (unsigned long int)1) == 0) { - Py_INCREF(b); - return (PyObject *)b; - } - - if ((cmpres = mpz_cmp_ui(&b->mpz, (unsigned long_int)0)) == 0) { - Py_INCREF(mpz_value_zero); - return (PyObject *)mpz_value_zero; - } - if (cmpres > 0 && mpz_cmp_ui(&b->mpz, (unsigned long int)1) == 0) { - Py_INCREF(a); - return (PyObject *)a; - } -#endif /* MPZ_SPARE_MALLOC */ - - if ((z = newmpzobject()) == NULL) - return NULL; - - mpz_mul( &z->mpz, &a->mpz, &b->mpz ); - return (PyObject *)z; - -} /* mpz_multiply() */ - -static PyObject * -mpz_divide(mpzobject *a, mpzobject *b) -{ -#ifdef MPZ_SPARE_MALLOC - int cmpres; -#endif /* def MPZ_SPARE_MALLOC */ - mpzobject *z; - - - if (( -#ifdef MPZ_SPARE_MALLOC - cmpres = -#endif /* def MPZ_SPARE_MALLOC */ - mpz_cmp_ui(&b->mpz, (unsigned long int)0)) == 0) { - PyErr_SetString(PyExc_ZeroDivisionError, "mpz./ by zero"); - return NULL; - } -#ifdef MPZ_SPARE_MALLOC - if (cmpres > 0 && mpz_cmp_ui(&b->mpz(unsigned long int)1) == 0) { - Py_INCREF(a); - return (PyObject *)a; - } -#endif /* def MPZ_SPARE_MALLOC */ - - if ((z = newmpzobject()) == NULL) - return NULL; - -#ifdef MPZ_TEST_DIV - fputs("mpz_divide: div result", stderr); - mpz_div(&z->mpz, &a->mpz, &b->mpz); - mpz_out_str(stderr, 10, &z->mpz); - putc('\n', stderr); -#endif /* def MPZ_TEST_DIV */ -#ifdef MPZ_MDIV_BUG - if ((mpz_cmp_ui(&a->mpz, (unsigned long int)0) < 0) - != (mpz_cmp_ui(&b->mpz, (unsigned long int)0) < 0)) { - /* - ** numerator has other sign than denominator: we have - ** to look at the remainder for a correction, since mpz_mdiv - ** also calls mpz_divmod, I can as well do it myself - */ - MP_INT tmpmpz; - - - mpz_init(&tmpmpz); - mpz_divmod(&z->mpz, &tmpmpz, &a->mpz, &b->mpz); - - if (mpz_cmp_ui(&tmpmpz, (unsigned long int)0) != 0) - mpz_sub_ui(&z->mpz, &z->mpz, (unsigned long int)1); - - mpz_clear(&tmpmpz); - } - else - mpz_div(&z->mpz, &a->mpz, &b->mpz); - /* the ``naive'' implementation does it right for operands - having the same sign */ - -#else /* def MPZ_MDIV_BUG */ - mpz_mdiv(&z->mpz, &a->mpz, &b->mpz); -#endif /* def MPZ_MDIV_BUG else */ -#ifdef MPZ_TEST_DIV - fputs("mpz_divide: mdiv result", stderr); - mpz_out_str(stderr, 10, &z->mpz); - putc('\n', stderr); -#endif /* def MPZ_TEST_DIV */ - return (PyObject *)z; - -} /* mpz_divide() */ - -static PyObject * -mpz_remainder(mpzobject *a, mpzobject *b) -{ -#ifdef MPZ_SPARE_MALLOC - int cmpres; -#endif /* def MPZ_SPARE_MALLOC */ - mpzobject *z; - - - if (( -#ifdef MPZ_SPARE_MALLOC - cmpres = -#endif /* def MPZ_SPARE_MALLOC */ - mpz_cmp_ui(&b->mpz, (unsigned long int)0)) == 0) { - PyErr_SetString(PyExc_ZeroDivisionError, "mpz.% by zero"); - return NULL; - } -#ifdef MPZ_SPARE_MALLOC - if (cmpres > 0) { - if ((cmpres = mpz_cmp_ui(&b->mpz, (unsigned long int)2)) == 0) - { - Py_INCREF(mpz_value_one); - return (PyObject *)mpz_value_one; - } - if (cmpres < 0) { - /* b must be 1 now */ - Py_INCREF(mpz_value_zero); - return (PyObject *)mpz_value_zero; - } - } -#endif /* def MPZ_SPARE_MALLOC */ - - if ((z = newmpzobject()) == NULL) - return NULL; - -#ifdef MPZ_TEST_DIV - fputs("mpz_remain: mod result", stderr); - mpz_mod(&z->mpz, &a->mpz, &b->mpz); - mpz_out_str(stderr, 10, &z->mpz); - putc('\n', stderr); -#endif /* def MPZ_TEST_DIV */ -#ifdef MPZ_MDIV_BUG - - /* the ``naive'' implementation does it right for operands - having the same sign */ - mpz_mod(&z->mpz, &a->mpz, &b->mpz); - - /* assumption: z, a and b all point to different locations */ - if ((mpz_cmp_ui(&a->mpz, (unsigned long int)0) < 0) - != (mpz_cmp_ui(&b->mpz, (unsigned long int)0) < 0) - && mpz_cmp_ui(&z->mpz, (unsigned long int)0) != 0) - mpz_add(&z->mpz, &z->mpz, &b->mpz); - /* - ** numerator has other sign than denominator: we have - ** to look at the remainder for a correction, since mpz_mdiv - ** also calls mpz_divmod, I can as well do it myself - */ -#else /* def MPZ_MDIV_BUG */ - mpz_mmod(&z->mpz, &a->mpz, &b->mpz); -#endif /* def MPZ_MDIV_BUG else */ -#ifdef MPZ_TEST_DIV - fputs("mpz_remain: mmod result", stderr); - mpz_out_str(stderr, 10, &z->mpz); - putc('\n', stderr); -#endif /* def MPZ_TEST_DIV */ - return (PyObject *)z; - -} /* mpz_remainder() */ - -static PyObject * -mpz_div_and_mod(mpzobject *a, mpzobject *b) -{ - PyObject *z = NULL; - mpzobject *x = NULL, *y = NULL; - - - if (mpz_cmp_ui(&b->mpz, (unsigned long int)0) == 0) { - PyErr_SetString(PyExc_ZeroDivisionError, "mpz.divmod by zero"); - return NULL; - } - - if ((z = PyTuple_New(2)) == NULL - || (x = newmpzobject()) == NULL - || (y = newmpzobject()) == NULL) { - Py_XDECREF(z); - Py_XDECREF(x); - Py_XDECREF(y); - return NULL; - } - -#ifdef MPZ_TEST_DIV - fputs("mpz_divmod: dm result", stderr); - mpz_divmod(&x->mpz, &y->mpz, &a->mpz, &b->mpz); - mpz_out_str(stderr, 10, &x->mpz); - putc('\n', stderr); - mpz_out_str(stderr, 10, &y->mpz); - putc('\n', stderr); -#endif /* def MPZ_TEST_DIV */ -#ifdef MPZ_MDIV_BUG - mpz_divmod(&x->mpz, &y->mpz, &a->mpz, &b->mpz); - if ((mpz_cmp_ui(&a->mpz, (unsigned long int)0) < 0) - != (mpz_cmp_ui(&b->mpz, (unsigned long int)0) < 0) - && mpz_cmp_ui(&y->mpz, (unsigned long int)0) != 0) { - /* - ** numerator has other sign than denominator: we have - ** to look at the remainder for a correction. - */ - mpz_add(&y->mpz, &y->mpz, &b->mpz); - mpz_sub_ui(&x->mpz, &x->mpz, (unsigned long int)1); - } -#else /* def MPZ_MDIV_BUG */ - mpz_mdivmod( &x->mpz, &y->mpz, &a->mpz, &b->mpz ); -#endif /* def MPZ_MDIV_BUG else */ -#ifdef MPZ_TEST_DIV - fputs("mpz_divmod: mdm result", stderr); - mpz_out_str(stderr, 10, &x->mpz); - putc('\n', stderr); - mpz_out_str(stderr, 10, &y->mpz); - putc('\n', stderr); -#endif /* def MPZ_TEST_DIV */ - - (void)PyTuple_SetItem(z, 0, (PyObject *)x); - (void)PyTuple_SetItem(z, 1, (PyObject *)y); - - return z; -} /* mpz_div_and_mod() */ - -static PyObject * -mpz_power(mpzobject *a, mpzobject *b, mpzobject *m) -{ - mpzobject *z; - int cmpres; - - if ((PyObject *)m != Py_None) { - mpzobject *z2; - Py_INCREF(Py_None); - z=(mpzobject *)mpz_power(a, b, (mpzobject *)Py_None); - Py_DECREF(Py_None); - if (z==NULL) return((PyObject *)z); - z2=(mpzobject *)mpz_remainder(z, m); - Py_DECREF(z); - return((PyObject *)z2); - } - - if ((cmpres = mpz_cmp_ui(&b->mpz, (unsigned long int)0)) == 0) { - /* the gnu-mp lib sets pow(0,0) to 0, we to 1 */ - - Py_INCREF(mpz_value_one); - return (PyObject *)mpz_value_one; - } - - if (cmpres < 0) { - PyErr_SetString(PyExc_ValueError, - "mpz.pow to negative exponent"); - return NULL; - } - - if ((cmpres = mpz_cmp_ui(&a->mpz, (unsigned long int)0)) == 0) { - /* the base is 0 */ - - Py_INCREF(mpz_value_zero); - return (PyObject *)mpz_value_zero; - } - else if (cmpres > 0 - && mpz_cmp_ui(&a->mpz, (unsigned long int)1) == 0) { - /* the base is 1 */ - - Py_INCREF(mpz_value_one); - return (PyObject *)mpz_value_one; - } - else if (cmpres < 0 - && mpz_cmp_si(&a->mpz, (long int)-1) == 0) { - - MP_INT tmpmpz; - /* the base is -1: pow(-1, any) == 1,-1 for even,uneven b */ - /* XXX this code needs to be optimized: what's better? - mpz_mmod_ui or mpz_mod_2exp, I choose for the latter - for *un*obvious reasons */ - - /* is the exponent even? */ - mpz_init(&tmpmpz); - - /* look to the remainder after a division by (1 << 1) */ - mpz_mod_2exp(&tmpmpz, &b->mpz, (unsigned long int)1); - - if (mpz_cmp_ui(&tmpmpz, (unsigned int)0) == 0) { - mpz_clear(&tmpmpz); - Py_INCREF(mpz_value_one); - return (PyObject *)mpz_value_one; - } - mpz_clear(&tmpmpz); - Py_INCREF(mpz_value_mone); - return (PyObject *)mpz_value_mone; - } - -#ifdef MPZ_LIB_DOES_CHECKING - /* check if it's doable: sizeof(exp) > sizeof(long) && - abs(base) > 1 ?? --> No Way */ - if (mpz_size(&b->mpz) > 1) - return (PyObject *)PyErr_NoMemory(); -#else /* def MPZ_LIB_DOES_CHECKING */ - /* wet finger method */ - if (mpz_cmp_ui(&b->mpz, (unsigned long int)0x10000) >= 0) { - PyErr_SetString(PyExc_ValueError, - "mpz.pow outrageous exponent"); - return NULL; - } -#endif /* def MPZ_LIB_DOES_CHECKING else */ - - if ((z = newmpzobject()) == NULL) - return NULL; - - mpz_pow_ui(&z->mpz, &a->mpz, mpz_get_ui(&b->mpz)); - - return (PyObject *)z; -} /* mpz_power() */ - - -static PyObject * -mpz_negative(mpzobject *v) -{ - mpzobject *z; - - -#ifdef MPZ_SPARE_MALLOC - if (mpz_cmp_ui(&v->mpz, (unsigned long int)0) == 0) { - /* -0 == 0 */ - Py_INCREF(v); - return (PyObject *)v; - } -#endif /* def MPZ_SPARE_MALLOC */ - - if ((z = newmpzobject()) == NULL) - return NULL; - - mpz_neg(&z->mpz, &v->mpz); - return (PyObject *)z; -} /* mpz_negative() */ - - -static PyObject * -mpz_positive(mpzobject *v) -{ - Py_INCREF(v); - return (PyObject *)v; -} /* mpz_positive() */ - - -static PyObject * -mpz_absolute(mpzobject *v) -{ - mpzobject *z; - - - if (mpz_cmp_ui(&v->mpz, (unsigned long int)0) >= 0) { - Py_INCREF(v); - return (PyObject *)v; - } - - if ((z = newmpzobject()) == NULL) - return NULL; - - mpz_neg(&z->mpz, &v->mpz); - return (PyObject *)z; -} /* mpz_absolute() */ - -static int -mpz_nonzero(mpzobject *v) -{ - return mpz_cmp_ui(&v->mpz, (unsigned long int)0) != 0; -} /* mpz_nonzero() */ - -static PyObject * -py_mpz_invert(mpzobject *v) -{ - mpzobject *z; - - - /* I think mpz_com does exactly what needed */ - if ((z = newmpzobject()) == NULL) - return NULL; - - mpz_com(&z->mpz, &v->mpz); - return (PyObject *)z; -} /* py_mpz_invert() */ - -static PyObject * -mpz_lshift(mpzobject *a, mpzobject *b) -{ - int cmpres; - mpzobject *z; - - - if ((cmpres = mpz_cmp_ui(&b->mpz, (unsigned long int)0)) == 0) { - /* a << 0 == a */ - Py_INCREF(a); - return (PyObject *)a; - } - - if (cmpres < 0) { - PyErr_SetString(PyExc_ValueError, - "mpz.<< negative shift count"); - return NULL; - } - -#ifdef MPZ_LIB_DOES_CHECKING - if (mpz_size(&b->mpz) > 1) - return (PyObject *)PyErr_NoMemory(); -#else /* def MPZ_LIB_DOES_CHECKING */ - /* wet finger method */ - if (mpz_cmp_ui(&b->mpz, (unsigned long int)0x10000) >= 0) { - PyErr_SetString(PyExc_ValueError, - "mpz.<< outrageous shift count"); - return NULL; - } -#endif /* def MPZ_LIB_DOES_CHECKING else */ - - if ((z = newmpzobject()) == NULL) - return NULL; - - mpz_mul_2exp(&z->mpz, &a->mpz, mpz_get_ui(&b->mpz)); - return (PyObject *)z; -} /* mpz_lshift() */ - -static PyObject * -mpz_rshift(mpzobject *a, mpzobject *b) -{ - int cmpres; - mpzobject *z; - - - if ((cmpres = mpz_cmp_ui(&b->mpz, (unsigned long int)0)) == 0) { - /* a >> 0 == a */ - Py_INCREF(a); - return (PyObject *)a; - } - - if (cmpres < 0) { - PyErr_SetString(PyExc_ValueError, - "mpz.>> negative shift count"); - return NULL; - } - - if (mpz_size(&b->mpz) > 1) - return (PyObject *)PyErr_NoMemory(); - - if ((z = newmpzobject()) == NULL) - return NULL; - - mpz_div_2exp(&z->mpz, &a->mpz, mpz_get_ui(&b->mpz)); - return (PyObject *)z; -} /* mpz_rshift() */ - -static PyObject * -mpz_andfunc(mpzobject *a, mpzobject *b) -{ - mpzobject *z; - - - if ((z = newmpzobject()) == NULL) - return NULL; - - mpz_and(&z->mpz, &a->mpz, &b->mpz); - return (PyObject *)z; -} /* mpz_andfunc() */ - -/* hack Hack HAck HACk HACK, XXX this code is dead slow */ -void -mpz_xor(MP_INT *res, const MP_INT *op1, const MP_INT *op2) -{ - MP_INT tmpmpz; - - mpz_init(&tmpmpz); - - mpz_and(res, op1, op2); - mpz_com(&tmpmpz, res); - mpz_ior(res, op1, op2); - mpz_and(res, res, &tmpmpz); - - mpz_clear(&tmpmpz); -} /* mpz_xor() HACK */ - -static PyObject * -mpz_xorfunc(mpzobject *a, mpzobject *b) -{ - mpzobject *z; - - - if ((z = newmpzobject()) == NULL) - return NULL; - - mpz_xor(&z->mpz, &a->mpz, &b->mpz); - return (PyObject *)z; -} /* mpz_xorfunc() */ - -static PyObject * -mpz_orfunc(mpzobject *a, mpzobject *b) -{ - mpzobject *z; - - - if ((z = newmpzobject()) == NULL) - return NULL; - - mpz_ior(&z->mpz, &a->mpz, &b->mpz); - return (PyObject *)z; -} /* mpz_orfunc() */ - -/* MPZ initialisation */ - -#include "longintrepr.h" - -static PyObject * -MPZ_mpz(PyObject *self, PyObject *args) -{ - mpzobject *mpzp; - - -#ifdef MPZ_DEBUG - fputs("MPZ_mpz() called...\n", stderr); -#endif /* def MPZ_DEBUG */ - - /* at least we know it's some object */ - /* note DON't Py_DECREF args */ - - if (PyInt_Check(args)) { - long lval = PyInt_AS_LONG(args); - if (lval == (long)0) { - Py_INCREF(mpz_value_zero); - mpzp = mpz_value_zero; - } - else if (lval == (long)1) { - Py_INCREF(mpz_value_one); - mpzp = mpz_value_one; - } - else if ((mpzp = newmpzobject()) == NULL) - return NULL; - else mpz_set_si(&mpzp->mpz, lval); - } - else if (PyLong_Check(args)) { - MP_INT mplongdigit; - int i; - unsigned char isnegative; - - - if ((mpzp = newmpzobject()) == NULL) - return NULL; - - mpz_set_si(&mpzp->mpz, 0L); - mpz_init(&mplongdigit); - - /* how we're gonna handle this? */ - if ((isnegative = - ((i = ((PyLongObject *)args)->ob_size) < 0) )) - i = -i; - - while (i--) { - mpz_set_ui(&mplongdigit, - (unsigned long) - ((PyLongObject *)args)->ob_digit[i]); - mpz_mul_2exp(&mplongdigit,&mplongdigit, - (unsigned long int)i * SHIFT); - mpz_ior(&mpzp->mpz, &mpzp->mpz, &mplongdigit); - } - - if (isnegative) - mpz_neg(&mpzp->mpz, &mpzp->mpz); - - /* get rid of allocation for tmp variable */ - mpz_clear(&mplongdigit); - } - else if (PyString_Check(args)) { - unsigned char *cp = (unsigned char *)PyString_AS_STRING(args); - int len = PyString_GET_SIZE(args); - MP_INT mplongdigit; - - if ((mpzp = newmpzobject()) == NULL) - return NULL; - - mpz_set_si(&mpzp->mpz, 0L); - mpz_init(&mplongdigit); - - /* let's do it the same way as with the long conversion: - without thinking how it can be faster (-: :-) */ - - cp += len; - while (len--) { - mpz_set_ui(&mplongdigit, (unsigned long)*--cp ); - mpz_mul_2exp(&mplongdigit,&mplongdigit, - (unsigned long int)len * 8); - mpz_ior(&mpzp->mpz, &mpzp->mpz, &mplongdigit); - } - - /* get rid of allocation for tmp variable */ - mpz_clear(&mplongdigit); - } - else if (is_mpzobject(args)) { - Py_INCREF(args); - mpzp = (mpzobject *)args; - } - else { - PyErr_SetString(PyExc_TypeError, -"mpz.mpz() expects integer, long, string or mpz object argument"); - return NULL; - } - - -#ifdef MPZ_DEBUG - fputs("MPZ_mpz: created mpz=", stderr); - mpz_out_str(stderr, 10, &mpzp->mpz); - putc('\n', stderr); -#endif /* def MPZ_DEBUG */ - return (PyObject *)mpzp; -} /* MPZ_mpz() */ - -static mpzobject * -mpz_mpzcoerce(PyObject *z) -{ - /* shortcut: 9 out of 10 times the type is already ok */ - if (is_mpzobject(z)) { - Py_INCREF(z); - return (mpzobject *)z; /* coercion succeeded */ - } - - /* what types do we accept?: intobjects and longobjects */ - if (PyInt_Check(z) || PyLong_Check(z)) - return (mpzobject *)MPZ_mpz((PyObject *)NULL, z); - - PyErr_SetString(PyExc_TypeError, - "number coercion (to mpzobject) failed"); - return NULL; -} /* mpz_mpzcoerce() */ - -/* Forward */ -static void mpz_divm(MP_INT *res, const MP_INT *num, - const MP_INT *den, const MP_INT *mod); - -static PyObject * -MPZ_powm(PyObject *self, PyObject *args) -{ - PyObject *base, *exp, *mod; - mpzobject *mpzbase = NULL, *mpzexp = NULL, *mpzmod = NULL; - mpzobject *z = NULL; - int tstres; - - - if (!PyArg_ParseTuple(args, "OOO", &base, &exp, &mod)) - return NULL; - - if ((mpzbase = mpz_mpzcoerce(base)) == NULL - || (mpzexp = mpz_mpzcoerce(exp)) == NULL - || (mpzmod = mpz_mpzcoerce(mod)) == NULL - || (z = newmpzobject()) == NULL) { - Py_XDECREF(mpzbase); - Py_XDECREF(mpzexp); - Py_XDECREF(mpzmod); - Py_XDECREF(z); - return NULL; - } - - if ((tstres=mpz_cmp_ui(&mpzexp->mpz, (unsigned long int)0)) == 0) { - Py_DECREF(mpzbase); - Py_DECREF(mpzexp); - Py_DECREF(mpzmod); - Py_DECREF(z); - Py_INCREF(mpz_value_one); - return (PyObject *)mpz_value_one; - } - - if (mpz_cmp_ui(&mpzmod->mpz, 0) == 0) { - Py_DECREF(mpzbase); - Py_DECREF(mpzexp); - Py_DECREF(mpzmod); - Py_DECREF(z); - PyErr_SetString(PyExc_ValueError, "modulus cannot be 0"); - return NULL; - } - - if (tstres < 0) { - MP_INT absexp; - /* negative exp */ - - mpz_init_set(&absexp, &mpzexp->mpz); - mpz_abs(&absexp, &absexp); - mpz_powm(&z->mpz, &mpzbase->mpz, &absexp, &mpzmod->mpz); - - mpz_divm(&z->mpz, &mpz_value_one->mpz, &z->mpz, &mpzmod->mpz); - - mpz_clear(&absexp); - } - else { - mpz_powm(&z->mpz, &mpzbase->mpz, &mpzexp->mpz, &mpzmod->mpz); - } - - Py_DECREF(mpzbase); - Py_DECREF(mpzexp); - Py_DECREF(mpzmod); - - return (PyObject *)z; -} /* MPZ_powm() */ - - -static PyObject * -MPZ_gcd(PyObject *self, PyObject *args) -{ - PyObject *op1, *op2; - mpzobject *mpzop1 = NULL, *mpzop2 = NULL; - mpzobject *z; - - - if (!PyArg_ParseTuple(args, "OO", &op1, &op2)) - return NULL; - - if ((mpzop1 = mpz_mpzcoerce(op1)) == NULL - || (mpzop2 = mpz_mpzcoerce(op2)) == NULL - || (z = newmpzobject()) == NULL) { - Py_XDECREF(mpzop1); - Py_XDECREF(mpzop2); - return NULL; - } - - /* ok, we have three mpzobjects, and an initialised result holder */ - mpz_gcd(&z->mpz, &mpzop1->mpz, &mpzop2->mpz); - - Py_DECREF(mpzop1); - Py_DECREF(mpzop2); - - return (PyObject *)z; -} /* MPZ_gcd() */ - - -static PyObject * -MPZ_gcdext(PyObject *self, PyObject *args) -{ - PyObject *op1, *op2, *z = NULL; - mpzobject *mpzop1 = NULL, *mpzop2 = NULL; - mpzobject *g = NULL, *s = NULL, *t = NULL; - - - if (!PyArg_ParseTuple(args, "OO", &op1, &op2)) - return NULL; - - if ((mpzop1 = mpz_mpzcoerce(op1)) == NULL - || (mpzop2 = mpz_mpzcoerce(op2)) == NULL - || (z = PyTuple_New(3)) == NULL - || (g = newmpzobject()) == NULL - || (s = newmpzobject()) == NULL - || (t = newmpzobject()) == NULL) { - Py_XDECREF(mpzop1); - Py_XDECREF(mpzop2); - Py_XDECREF(z); - Py_XDECREF(g); - Py_XDECREF(s); - /*Py_XDECREF(t);*/ - return NULL; - } - - mpz_gcdext(&g->mpz, &s->mpz, &t->mpz, &mpzop1->mpz, &mpzop2->mpz); - - Py_DECREF(mpzop1); - Py_DECREF(mpzop2); - - (void)PyTuple_SetItem(z, 0, (PyObject *)g); - (void)PyTuple_SetItem(z, 1, (PyObject *)s); - (void)PyTuple_SetItem(z, 2, (PyObject *)t); - - return (PyObject *)z; -} /* MPZ_gcdext() */ - - -static PyObject * -MPZ_sqrt(PyObject *self, PyObject *args) -{ - mpzobject *mpzop = NULL; - mpzobject *z; - - - if ((mpzop = mpz_mpzcoerce(args)) == NULL - || (z = newmpzobject()) == NULL) { - Py_XDECREF(mpzop); - return NULL; - } - - mpz_sqrt(&z->mpz, &mpzop->mpz); - - Py_DECREF(mpzop); - - return (PyObject *)z; -} /* MPZ_sqrt() */ - - -static PyObject * -MPZ_sqrtrem(PyObject *self, PyObject *args) -{ - PyObject *z = NULL; - mpzobject *mpzop = NULL; - mpzobject *root = NULL, *rem = NULL; - - if ((mpzop = mpz_mpzcoerce(args)) == NULL - || (z = PyTuple_New(2)) == NULL - || (root = newmpzobject()) == NULL - || (rem = newmpzobject()) == NULL) { - Py_XDECREF(mpzop); - Py_XDECREF(z); - Py_XDECREF(root); - /*Py_XDECREF(rem);*/ - return NULL; - } - - mpz_sqrtrem(&root->mpz, &rem->mpz, &mpzop->mpz); - - Py_DECREF(mpzop); - - (void)PyTuple_SetItem(z, 0, (PyObject *)root); - (void)PyTuple_SetItem(z, 1, (PyObject *)rem); - - return (PyObject *)z; -} /* MPZ_sqrtrem() */ - - -static void -mpz_divm(MP_INT *res, const MP_INT *num, const MP_INT *den, const MP_INT *mod) -{ - MP_INT s0, s1, q, r, x, d0, d1; - - mpz_init_set(&s0, num); - mpz_init_set_ui(&s1, 0); - mpz_init(&q); - mpz_init(&r); - mpz_init(&x); - mpz_init_set(&d0, den); - mpz_init_set(&d1, mod); - -#ifdef GMP2 - while (d1._mp_size != 0) { -#else - while (d1.size != 0) { -#endif - mpz_divmod(&q, &r, &d0, &d1); - mpz_set(&d0, &d1); - mpz_set(&d1, &r); - - mpz_mul(&x, &s1, &q); - mpz_sub(&x, &s0, &x); - mpz_set(&s0, &s1); - mpz_set(&s1, &x); - } - -#ifdef GMP2 - if (d0._mp_size != 1 || d0._mp_d[0] != 1) - res->_mp_size = 0; /* trouble: the gcd != 1; set s to zero */ -#else - if (d0.size != 1 || d0.d[0] != 1) - res->size = 0; /* trouble: the gcd != 1; set s to zero */ -#endif - else { -#ifdef MPZ_MDIV_BUG - /* watch out here! first check the signs, and then perform - the mpz_mod() since mod could point to res */ - if ((s0.size < 0) != (mod->size < 0)) { - mpz_mod(res, &s0, mod); - - if (res->size) - mpz_add(res, res, mod); - } - else - mpz_mod(res, &s0, mod); - -#else /* def MPZ_MDIV_BUG */ - mpz_mmod(res, &s0, mod); -#endif /* def MPZ_MDIV_BUG else */ - } - - mpz_clear(&s0); - mpz_clear(&s1); - mpz_clear(&q); - mpz_clear(&r); - mpz_clear(&x); - mpz_clear(&d0); - mpz_clear(&d1); -} /* mpz_divm() */ - - -static PyObject * -MPZ_divm(PyObject *self, PyObject *args) -{ - PyObject *num, *den, *mod; - mpzobject *mpznum, *mpzden = NULL, *mpzmod = NULL; - mpzobject *z = NULL; - - - if (!PyArg_ParseTuple(args, "OOO", &num, &den, &mod)) - return NULL; - - if ((mpznum = mpz_mpzcoerce(num)) == NULL - || (mpzden = mpz_mpzcoerce(den)) == NULL - || (mpzmod = mpz_mpzcoerce(mod)) == NULL - || (z = newmpzobject()) == NULL ) { - Py_XDECREF(mpznum); - Py_XDECREF(mpzden); - Py_XDECREF(mpzmod); - return NULL; - } - - mpz_divm(&z->mpz, &mpznum->mpz, &mpzden->mpz, &mpzmod->mpz); - - Py_DECREF(mpznum); - Py_DECREF(mpzden); - Py_DECREF(mpzmod); - - if (mpz_cmp_ui(&z->mpz, (unsigned long int)0) == 0) { - Py_DECREF(z); - PyErr_SetString(PyExc_ValueError, - "gcd(den, mod) != 1 or num == 0"); - return NULL; - } - - return (PyObject *)z; -} /* MPZ_divm() */ - - -static PyObject * -mpz_int(mpzobject *self) -{ - long sli; - - - if (mpz_size(&self->mpz) > 1 - || (sli = (long)mpz_get_ui(&self->mpz)) < (long)0 ) { - PyErr_SetString(PyExc_ValueError, - "mpz.int() arg too long to convert"); - return NULL; - } - - if (mpz_cmp_ui(&self->mpz, (unsigned long)0) < 0) - sli = -sli; - - return PyInt_FromLong(sli); -} /* mpz_int() */ - -static PyObject * -mpz_long(mpzobject *self) -{ - int i, isnegative; - unsigned long int uli; - PyLongObject *longobjp; - int ldcount; - int bitpointer, newbitpointer; - MP_INT mpzscratch; - - - /* determine length of python-long to be allocated */ - if ((longobjp = _PyLong_New(i = (int) - ((mpz_size(&self->mpz) * BITS_PER_MP_LIMB - + SHIFT - 1) / - SHIFT))) == NULL) - return NULL; - - /* determine sign, and copy self to scratch var */ - mpz_init_set(&mpzscratch, &self->mpz); - if ((isnegative = (mpz_cmp_ui(&self->mpz, (unsigned long int)0) < 0))) - mpz_neg(&mpzscratch, &mpzscratch); - - /* let those bits come, let those bits go, - e.g. dismantle mpzscratch, build PyLongObject */ - - bitpointer = 0; /* the number of valid bits in stock */ - newbitpointer = 0; - ldcount = 0; /* the python-long limb counter */ - uli = (unsigned long int)0; - while (i--) { - longobjp->ob_digit[ldcount] = uli & MASK; - - /* check if we've had enough bits for this digit */ - if (bitpointer < SHIFT) { - uli = mpz_get_ui(&mpzscratch); - longobjp->ob_digit[ldcount] |= - (uli << bitpointer) & MASK; - uli >>= SHIFT-bitpointer; - bitpointer += BITS_PER_MP_LIMB; - mpz_div_2exp(&mpzscratch, &mpzscratch, - BITS_PER_MP_LIMB); - } - else - uli >>= SHIFT; - bitpointer -= SHIFT; - ldcount++; - } - - assert(mpz_cmp_ui(&mpzscratch, (unsigned long int)0) == 0); - mpz_clear(&mpzscratch); - assert(ldcount <= longobjp->ob_size); - - /* long_normalize() is file-static */ - /* longobjp = long_normalize(longobjp); */ - while (ldcount > 0 && longobjp->ob_digit[ldcount-1] == 0) - ldcount--; - longobjp->ob_size = ldcount; - - - if (isnegative) - longobjp->ob_size = -longobjp->ob_size; - - return (PyObject *)longobjp; - -} /* mpz_long() */ - - -/* I would have avoided pow() anyways, so ... */ -static const double multiplier = 256.0 * 256.0 * 256.0 * 256.0; - -static PyObject * -mpz_float(mpzobject *self) -{ - int i, isnegative; - double x; - double mulstate; - MP_INT mpzscratch; - - - i = (int)mpz_size(&self->mpz); - - /* determine sign, and copy abs(self) to scratch var */ - if ((isnegative = (mpz_cmp_ui(&self->mpz, (unsigned long int)0) < 0))) - { - mpz_init(&mpzscratch); - mpz_neg(&mpzscratch, &self->mpz); - } - else - mpz_init_set(&mpzscratch, &self->mpz); - - /* let those bits come, let those bits go, - e.g. dismantle mpzscratch, build PyFloatObject */ - - /* Can this overflow? Dunno, protect against that possibility. */ - PyFPE_START_PROTECT("mpz_float", return 0) - x = 0.0; - mulstate = 1.0; - while (i--) { - x += mulstate * mpz_get_ui(&mpzscratch); - mulstate *= multiplier; - mpz_div_2exp(&mpzscratch, &mpzscratch, BITS_PER_MP_LIMB); - } - PyFPE_END_PROTECT(mulstate) - - assert(mpz_cmp_ui(&mpzscratch, (unsigned long int)0) == 0); - mpz_clear(&mpzscratch); - - if (isnegative) - x = -x; - - return PyFloat_FromDouble(x); - -} /* mpz_float() */ - -static PyObject * -mpz_hex(mpzobject *self) -{ - return mpz_format((PyObject *)self, 16, (unsigned char)1); -} /* mpz_hex() */ - -static PyObject * -mpz_oct(mpzobject *self) -{ - return mpz_format((PyObject *)self, 8, (unsigned char)1); -} /* mpz_oct() */ - -static PyObject * -mpz_binary(mpzobject *self) -{ - int size; - PyStringObject *strobjp; - char *cp; - MP_INT mp; - unsigned long ldigit; - - if (mpz_cmp_ui(&self->mpz, (unsigned long int)0) < 0) { - PyErr_SetString(PyExc_ValueError, - "mpz.binary() arg must be >= 0"); - return NULL; - } - - mpz_init_set(&mp, &self->mpz); - size = (int)mpz_size(&mp); - - if ((strobjp = (PyStringObject *) - PyString_FromStringAndSize( - (char *)0, size * sizeof (unsigned long int))) == NULL) - return NULL; - - /* get the beginning of the string memory and start copying things */ - cp = PyString_AS_STRING(strobjp); - - /* this has been programmed using a (fairly) decent lib-i/f it could - be must faster if we looked into the GMP lib */ - while (size--) { - ldigit = mpz_get_ui(&mp); - mpz_div_2exp(&mp, &mp, BITS_PER_MP_LIMB); - *cp++ = (unsigned char)(ldigit & 0xFF); - *cp++ = (unsigned char)((ldigit >>= 8) & 0xFF); - *cp++ = (unsigned char)((ldigit >>= 8) & 0xFF); - *cp++ = (unsigned char)((ldigit >>= 8) & 0xFF); - if (sizeof(ldigit) == 8 && BITS_PER_MP_LIMB == 64) { - *cp++ = (unsigned char)((ldigit >>= 8) & 0xFF); - *cp++ = (unsigned char)((ldigit >>= 8) & 0xFF); - *cp++ = (unsigned char)((ldigit >>= 8) & 0xFF); - *cp++ = (unsigned char)((ldigit >>= 8) & 0xFF); - } - } - - while (strobjp->ob_size && !*--cp) - strobjp->ob_size--; - - return (PyObject *)strobjp; -} /* mpz_binary() */ - - -static PyMethodDef mpz_methods[] = { -#ifdef MPZ_CONVERSIONS_AS_METHODS - {"int", mpz_int, METH_NOARGS}, - {"long", mpz_long, METH_NOARGS}, - {"float", mpz_float, METH_NOARGS}, - {"hex", mpz_hex, METH_NOARGS}, - {"oct", mpz_oct, METH_NOARGS}, -#endif /* def MPZ_CONVERSIONS_AS_METHODS */ - {"binary", (PyCFunction)mpz_binary, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -mpz_getattr(mpzobject *self, char *name) -{ - return Py_FindMethod(mpz_methods, (PyObject *)self, name); -} /* mpz_getattr() */ - - -static int -mpz_coerce(PyObject **pv, PyObject **pw) -{ - PyObject *z; - -#ifdef MPZ_DEBUG - fputs("mpz_coerce() called...\n", stderr); -#endif /* def MPZ_DEBUG */ - - assert(is_mpzobject(*pv)); - - /* always convert other arg to mpz value, except for floats */ - if (!PyFloat_Check(*pw)) { - if ((z = (PyObject *)mpz_mpzcoerce(*pw)) == NULL) - return -1; /* -1: an error always has been set */ - - Py_INCREF(*pv); - *pw = z; - } - else { - if ((z = mpz_float((mpzobject *)(*pv))) == NULL) - return -1; - - Py_INCREF(*pw); - *pv = z; - } - return 0; /* coercion succeeded */ - -} /* mpz_coerce() */ - - -static PyObject * -mpz_repr(PyObject *v) -{ - return mpz_format(v, 10, (unsigned char)1); -} /* mpz_repr() */ - - - -#define UF (unaryfunc) -#define BF (binaryfunc) -#define TF (ternaryfunc) -#define IF (inquiry) -#define CF (coercion) - -static PyNumberMethods mpz_as_number = { - BF mpz_addition, /*nb_add*/ - BF mpz_substract, /*nb_subtract*/ - BF mpz_multiply, /*nb_multiply*/ - BF mpz_divide, /*nb_divide*/ - BF mpz_remainder, /*nb_remainder*/ - BF mpz_div_and_mod, /*nb_divmod*/ - TF mpz_power, /*nb_power*/ - UF mpz_negative, /*nb_negative*/ - UF mpz_positive, /*tp_positive*/ - UF mpz_absolute, /*tp_absolute*/ - IF mpz_nonzero, /*tp_nonzero*/ - UF py_mpz_invert, /*nb_invert*/ - BF mpz_lshift, /*nb_lshift*/ - BF mpz_rshift, /*nb_rshift*/ - BF mpz_andfunc, /*nb_and*/ - BF mpz_xorfunc, /*nb_xor*/ - BF mpz_orfunc, /*nb_or*/ - CF mpz_coerce, /*nb_coerce*/ -#ifndef MPZ_CONVERSIONS_AS_METHODS - UF mpz_int, /*nb_int*/ - UF mpz_long, /*nb_long*/ - UF mpz_float, /*nb_float*/ - UF mpz_oct, /*nb_oct*/ - UF mpz_hex, /*nb_hex*/ -#endif /* ndef MPZ_CONVERSIONS_AS_METHODS */ -}; - -static PyTypeObject MPZtype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "mpz.mpz", /*tp_name*/ - sizeof(mpzobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)mpz_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)mpz_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - (cmpfunc)mpz_compare, /*tp_compare*/ - (reprfunc)mpz_repr, /*tp_repr*/ - &mpz_as_number, /*tp_as_number*/ -}; - -/* List of functions exported by this module */ - -static PyMethodDef mpz_functions[] = { -#if 0 - {initialiser_name, MPZ_mpz, METH_O}, -#else /* 0 */ - /* until guido ``fixes'' struct PyMethodDef */ - {(char *)initialiser_name, MPZ_mpz, METH_O}, -#endif /* 0 else */ - {"powm", MPZ_powm, METH_VARARGS}, - {"gcd", MPZ_gcd, METH_VARARGS}, - {"gcdext", MPZ_gcdext, METH_VARARGS}, - {"sqrt", MPZ_sqrt, METH_O}, - {"sqrtrem", MPZ_sqrtrem, METH_O}, - {"divm", MPZ_divm, METH_VARARGS}, - {NULL, NULL} /* Sentinel */ -}; - - -/* #define MP_TEST_ALLOC */ - -#ifdef MP_TEST_ALLOC -#define MP_TEST_SIZE 4 -static const char mp_test_magic[MP_TEST_SIZE] = {'\xAA','\xAA','\xAA','\xAA'}; -static mp_test_error(int *location) -{ - /* assumptions: *alloc returns address divisible by 4, - mpz_* routines allocate in chunks divisible by four */ - fprintf(stderr, "MP_TEST_ERROR: location holds 0x%08d\n", *location ); - Py_FatalError("MP_TEST_ERROR"); -} /* static mp_test_error() */ -#define MP_EXTRA_ALLOC(size) ((size) + MP_TEST_SIZE) -#define MP_SET_TEST(basep,size) (void)memcpy( ((char *)(basep))+(size), mp_test_magic, MP_TEST_SIZE) -#define MP_DO_TEST(basep,size) if ( !memcmp( ((char *)(basep))+(size), mp_test_magic, MP_TEST_SIZE ) ) \ - ; \ - else \ - mp_test_error((int *)((char *)(basep) + size)) -#else /* def MP_TEST_ALLOC */ -#define MP_EXTRA_ALLOC(size) (size) -#define MP_SET_TEST(basep,size) -#define MP_DO_TEST(basep,size) -#endif /* def MP_TEST_ALLOC else */ - -void *mp_allocate(size_t alloc_size) -{ - void *res; - -#ifdef MPZ_DEBUG - fprintf(stderr, "mp_allocate : size %ld\n", - alloc_size); -#endif /* def MPZ_DEBUG */ - - if ( (res = malloc(MP_EXTRA_ALLOC(alloc_size))) == NULL ) - Py_FatalError("mp_allocate failure"); - -#ifdef MPZ_DEBUG - fprintf(stderr, "mp_allocate : address %08p\n", res); -#endif /* def MPZ_DEBUG */ - - MP_SET_TEST(res,alloc_size); - - return res; -} /* mp_allocate() */ - - -void *mp_reallocate(void *ptr, size_t old_size, size_t new_size) -{ - void *res; - -#ifdef MPZ_DEBUG - fprintf(stderr, "mp_reallocate: old address %08p, old size %ld\n", - ptr, old_size); -#endif /* def MPZ_DEBUG */ - - MP_DO_TEST(ptr, old_size); - - if ( (res = realloc(ptr, MP_EXTRA_ALLOC(new_size))) == NULL ) - Py_FatalError("mp_reallocate failure"); - -#ifdef MPZ_DEBUG - fprintf(stderr, "mp_reallocate: new address %08p, new size %ld\n", - res, new_size); -#endif /* def MPZ_DEBUG */ - - MP_SET_TEST(res, new_size); - - return res; -} /* mp_reallocate() */ - - -void mp_free(void *ptr, size_t size) -{ - -#ifdef MPZ_DEBUG - fprintf(stderr, "mp_free : old address %08p, old size %ld\n", - ptr, size); -#endif /* def MPZ_DEBUG */ - - MP_DO_TEST(ptr, size); - free(ptr); -} /* mp_free() */ - - - -/* Initialize this module. */ - -PyMODINIT_FUNC -initmpz(void) -{ - PyObject *module; - PyObject *dict; - -#ifdef MPZ_DEBUG - fputs( "initmpz() called...\n", stderr ); -#endif /* def MPZ_DEBUG */ - - mp_set_memory_functions( mp_allocate, mp_reallocate, mp_free ); - MPZtype.ob_type = &PyType_Type; - module = Py_InitModule("mpz", mpz_functions); - - /* create some frequently used constants */ - if ((mpz_value_zero = newmpzobject()) == NULL) - goto finally; - mpz_set_ui(&mpz_value_zero->mpz, (unsigned long int)0); - - if ((mpz_value_one = newmpzobject()) == NULL) - goto finally; - mpz_set_ui(&mpz_value_one->mpz, (unsigned long int)1); - - if ((mpz_value_mone = newmpzobject()) == NULL) - goto finally; - mpz_set_si(&mpz_value_mone->mpz, (long)-1); - - dict = PyModule_GetDict(module); - if (dict != NULL) { - PyDict_SetItemString(dict, "MPZType", (PyObject*)&MPZtype); - } - finally: - return; -} /* initmpz() */ - -#ifdef MAKEDUMMYINT -int _mpz_dummy_int; /* XXX otherwise, we're .bss-less (DYNLOAD->Jack?) */ -#endif /* def MAKEDUMMYINT */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/nismodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/nismodule.c deleted file mode 100644 index adbd852e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/nismodule.c +++ /dev/null @@ -1,382 +0,0 @@ -/*********************************************************** - Written by: - Fred Gansevles - B&O group, - Faculteit der Informatica, - Universiteit Twente, - Enschede, - the Netherlands. -******************************************************************/ - -/* NIS module implementation */ - -#include "Python.h" - -#include -#include -#include -#include -#include - -#ifdef __sgi -/* This is missing from rpcsvc/ypclnt.h */ -extern int yp_get_default_domain(char **); -#endif - -static PyObject *NisError; - -static PyObject * -nis_error (int err) -{ - PyErr_SetString(NisError, yperr_string(err)); - return NULL; -} - -static struct nis_map { - char *alias; - char *map; - int fix; -} aliases [] = { - {"passwd", "passwd.byname", 0}, - {"group", "group.byname", 0}, - {"networks", "networks.byaddr", 0}, - {"hosts", "hosts.byname", 0}, - {"protocols", "protocols.bynumber", 0}, - {"services", "services.byname", 0}, - {"aliases", "mail.aliases", 1}, /* created with 'makedbm -a' */ - {"ethers", "ethers.byname", 0}, - {0L, 0L, 0} -}; - -static char * -nis_mapname (char *map, int *pfix) -{ - int i; - - *pfix = 0; - for (i=0; aliases[i].alias != 0L; i++) { - if (!strcmp (aliases[i].alias, map)) { - *pfix = aliases[i].fix; - return aliases[i].map; - } - if (!strcmp (aliases[i].map, map)) { - *pfix = aliases[i].fix; - return aliases[i].map; - } - } - - return map; -} - -typedef int (*foreachfunc)(int, char *, int, char *, int, char *); - -struct ypcallback_data { - PyObject *dict; - int fix; -}; - -static int -nis_foreach (int instatus, char *inkey, int inkeylen, char *inval, - int invallen, struct ypcallback_data *indata) -{ - if (instatus == YP_TRUE) { - PyObject *key; - PyObject *val; - int err; - - if (indata->fix) { - if (inkeylen > 0 && inkey[inkeylen-1] == '\0') - inkeylen--; - if (invallen > 0 && inval[invallen-1] == '\0') - invallen--; - } - key = PyString_FromStringAndSize(inkey, inkeylen); - val = PyString_FromStringAndSize(inval, invallen); - if (key == NULL || val == NULL) { - /* XXX error -- don't know how to handle */ - PyErr_Clear(); - Py_XDECREF(key); - Py_XDECREF(val); - return 1; - } - err = PyDict_SetItem(indata->dict, key, val); - Py_DECREF(key); - Py_DECREF(val); - if (err != 0) { - PyErr_Clear(); - return 1; - } - return 0; - } - return 1; -} - -static PyObject * -nis_match (PyObject *self, PyObject *args) -{ - char *match; - char *domain; - int keylen, len; - char *key, *map; - int err; - PyObject *res; - int fix; - - if (!PyArg_ParseTuple(args, "t#s:match", &key, &keylen, &map)) - return NULL; - if ((err = yp_get_default_domain(&domain)) != 0) - return nis_error(err); - map = nis_mapname (map, &fix); - if (fix) - keylen++; - Py_BEGIN_ALLOW_THREADS - err = yp_match (domain, map, key, keylen, &match, &len); - Py_END_ALLOW_THREADS - if (fix) - len--; - if (err != 0) - return nis_error(err); - res = PyString_FromStringAndSize (match, len); - free (match); - return res; -} - -static PyObject * -nis_cat (PyObject *self, PyObject *args) -{ - char *domain; - char *map; - struct ypall_callback cb; - struct ypcallback_data data; - PyObject *dict; - int err; - - if (!PyArg_ParseTuple(args, "s:cat", &map)) - return NULL; - if ((err = yp_get_default_domain(&domain)) != 0) - return nis_error(err); - dict = PyDict_New (); - if (dict == NULL) - return NULL; - cb.foreach = (foreachfunc)nis_foreach; - data.dict = dict; - map = nis_mapname (map, &data.fix); - cb.data = (char *)&data; - Py_BEGIN_ALLOW_THREADS - err = yp_all (domain, map, &cb); - Py_END_ALLOW_THREADS - if (err != 0) { - Py_DECREF(dict); - return nis_error(err); - } - return dict; -} - -/* These should be u_long on Sun h/w but not on 64-bit h/w. - This is not portable to machines with 16-bit ints and no prototypes */ -#ifndef YPPROC_MAPLIST -#define YPPROC_MAPLIST 11 -#endif -#ifndef YPPROG -#define YPPROG 100004 -#endif -#ifndef YPVERS -#define YPVERS 2 -#endif - -typedef char *domainname; -typedef char *mapname; - -enum nisstat { - NIS_TRUE = 1, - NIS_NOMORE = 2, - NIS_FALSE = 0, - NIS_NOMAP = -1, - NIS_NODOM = -2, - NIS_NOKEY = -3, - NIS_BADOP = -4, - NIS_BADDB = -5, - NIS_YPERR = -6, - NIS_BADARGS = -7, - NIS_VERS = -8 -}; -typedef enum nisstat nisstat; - -struct nismaplist { - mapname map; - struct nismaplist *next; -}; -typedef struct nismaplist nismaplist; - -struct nisresp_maplist { - nisstat stat; - nismaplist *maps; -}; -typedef struct nisresp_maplist nisresp_maplist; - -static struct timeval TIMEOUT = { 25, 0 }; - -static -bool_t -nis_xdr_domainname(XDR *xdrs, domainname *objp) -{ - if (!xdr_string(xdrs, objp, YPMAXDOMAIN)) { - return (FALSE); - } - return (TRUE); -} - -static -bool_t -nis_xdr_mapname(XDR *xdrs, mapname *objp) -{ - if (!xdr_string(xdrs, objp, YPMAXMAP)) { - return (FALSE); - } - return (TRUE); -} - -static -bool_t -nis_xdr_ypmaplist(XDR *xdrs, nismaplist *objp) -{ - if (!nis_xdr_mapname(xdrs, &objp->map)) { - return (FALSE); - } - if (!xdr_pointer(xdrs, (char **)&objp->next, - sizeof(nismaplist), (xdrproc_t)nis_xdr_ypmaplist)) - { - return (FALSE); - } - return (TRUE); -} - -static -bool_t -nis_xdr_ypstat(XDR *xdrs, nisstat *objp) -{ - if (!xdr_enum(xdrs, (enum_t *)objp)) { - return (FALSE); - } - return (TRUE); -} - - -static -bool_t -nis_xdr_ypresp_maplist(XDR *xdrs, nisresp_maplist *objp) -{ - if (!nis_xdr_ypstat(xdrs, &objp->stat)) { - return (FALSE); - } - if (!xdr_pointer(xdrs, (char **)&objp->maps, - sizeof(nismaplist), (xdrproc_t)nis_xdr_ypmaplist)) - { - return (FALSE); - } - return (TRUE); -} - - -static -nisresp_maplist * -nisproc_maplist_2(domainname *argp, CLIENT *clnt) -{ - static nisresp_maplist res; - - memset(&res, 0, sizeof(res)); - if (clnt_call(clnt, YPPROC_MAPLIST, - (xdrproc_t)nis_xdr_domainname, (caddr_t)argp, - (xdrproc_t)nis_xdr_ypresp_maplist, (caddr_t)&res, - TIMEOUT) != RPC_SUCCESS) - { - return (NULL); - } - return (&res); -} - -static -nismaplist * -nis_maplist (void) -{ - nisresp_maplist *list; - char *dom; - CLIENT *cl; - char *server = NULL; - int mapi = 0; - int err; - - if ((err = yp_get_default_domain (&dom)) != 0) { - nis_error(err); - return NULL; - } - - while (!server && aliases[mapi].map != 0L) { - yp_master (dom, aliases[mapi].map, &server); - mapi++; - } - if (!server) { - PyErr_SetString(NisError, "No NIS master found for any map"); - return NULL; - } - cl = clnt_create(server, YPPROG, YPVERS, "tcp"); - if (cl == NULL) { - PyErr_SetString(NisError, clnt_spcreateerror(server)); - goto finally; - } - list = nisproc_maplist_2 (&dom, cl); - clnt_destroy(cl); - if (list == NULL) - goto finally; - if (list->stat != NIS_TRUE) - goto finally; - - free(server); - return list->maps; - - finally: - free(server); - return NULL; -} - -static PyObject * -nis_maps (PyObject *self) -{ - nismaplist *maps; - PyObject *list; - - if ((maps = nis_maplist ()) == NULL) - return NULL; - if ((list = PyList_New(0)) == NULL) - return NULL; - for (maps = maps; maps; maps = maps->next) { - PyObject *str = PyString_FromString(maps->map); - if (!str || PyList_Append(list, str) < 0) - { - Py_DECREF(list); - list = NULL; - break; - } - Py_DECREF(str); - } - /* XXX Shouldn't we free the list of maps now? */ - return list; -} - -static PyMethodDef nis_methods[] = { - {"match", nis_match, METH_VARARGS}, - {"cat", nis_cat, METH_VARARGS}, - {"maps", (PyCFunction)nis_maps, METH_NOARGS}, - {NULL, NULL} /* Sentinel */ -}; - -void -initnis (void) -{ - PyObject *m, *d; - m = Py_InitModule("nis", nis_methods); - d = PyModule_GetDict(m); - NisError = PyErr_NewException("nis.error", NULL, NULL); - if (NisError != NULL) - PyDict_SetItemString(d, "error", NisError); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/operator.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/operator.c deleted file mode 100644 index c12de483..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/operator.c +++ /dev/null @@ -1,264 +0,0 @@ - -#include "Python.h" - -PyDoc_STRVAR(operator_doc, -"Operator interface.\n\ -\n\ -This module exports a set of functions implemented in C corresponding\n\ -to the intrinsic operators of Python. For example, operator.add(x, y)\n\ -is equivalent to the expression x+y. The function names are those\n\ -used for special class methods; variants without leading and trailing\n\ -'__' are also provided for convenience."); - -#define spam1(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a1) { \ - return AOP(a1); } - -#define spam2(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \ - PyObject *a1, *a2; \ - if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \ - return AOP(a1,a2); } - -#define spamoi(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \ - PyObject *a1; int a2; \ - if(! PyArg_ParseTuple(a,"Oi:" #OP,&a1,&a2)) return NULL; \ - return AOP(a1,a2); } - -#define spam2n(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \ - PyObject *a1, *a2; \ - if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \ - if(-1 == AOP(a1,a2)) return NULL; \ - Py_INCREF(Py_None); \ - return Py_None; } - -#define spam3n(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \ - PyObject *a1, *a2, *a3; \ - if(! PyArg_UnpackTuple(a,#OP,3,3,&a1,&a2,&a3)) return NULL; \ - if(-1 == AOP(a1,a2,a3)) return NULL; \ - Py_INCREF(Py_None); \ - return Py_None; } - -#define spami(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a1) { \ - long r; \ - if(-1 == (r=AOP(a1))) return NULL; \ - return PyBool_FromLong(r); } - -#define spami2(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \ - PyObject *a1, *a2; long r; \ - if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \ - if(-1 == (r=AOP(a1,a2))) return NULL; \ - return PyInt_FromLong(r); } - -#define spami2b(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \ - PyObject *a1, *a2; long r; \ - if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \ - if(-1 == (r=AOP(a1,a2))) return NULL; \ - return PyBool_FromLong(r); } - -#define spamrc(OP,A) static PyObject *OP(PyObject *s, PyObject *a) { \ - PyObject *a1, *a2; \ - if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \ - return PyObject_RichCompare(a1,a2,A); } - -spami(isCallable , PyCallable_Check) -spami(isNumberType , PyNumber_Check) -spami(truth , PyObject_IsTrue) -spam2(op_add , PyNumber_Add) -spam2(op_sub , PyNumber_Subtract) -spam2(op_mul , PyNumber_Multiply) -spam2(op_div , PyNumber_Divide) -spam2(op_floordiv , PyNumber_FloorDivide) -spam2(op_truediv , PyNumber_TrueDivide) -spam2(op_mod , PyNumber_Remainder) -spam1(op_neg , PyNumber_Negative) -spam1(op_pos , PyNumber_Positive) -spam1(op_abs , PyNumber_Absolute) -spam1(op_inv , PyNumber_Invert) -spam1(op_invert , PyNumber_Invert) -spam2(op_lshift , PyNumber_Lshift) -spam2(op_rshift , PyNumber_Rshift) -spami(op_not_ , PyObject_Not) -spam2(op_and_ , PyNumber_And) -spam2(op_xor , PyNumber_Xor) -spam2(op_or_ , PyNumber_Or) -spami(isSequenceType , PySequence_Check) -spam2(op_concat , PySequence_Concat) -spamoi(op_repeat , PySequence_Repeat) -spami2b(op_contains , PySequence_Contains) -spami2b(sequenceIncludes, PySequence_Contains) -spami2(indexOf , PySequence_Index) -spami2(countOf , PySequence_Count) -spami(isMappingType , PyMapping_Check) -spam2(op_getitem , PyObject_GetItem) -spam2n(op_delitem , PyObject_DelItem) -spam3n(op_setitem , PyObject_SetItem) -spamrc(op_lt , Py_LT) -spamrc(op_le , Py_LE) -spamrc(op_eq , Py_EQ) -spamrc(op_ne , Py_NE) -spamrc(op_gt , Py_GT) -spamrc(op_ge , Py_GE) - -static PyObject* -op_pow(PyObject *s, PyObject *a) -{ - PyObject *a1, *a2; - if (PyArg_UnpackTuple(a,"pow", 2, 2, &a1, &a2)) - return PyNumber_Power(a1, a2, Py_None); - return NULL; -} - -static PyObject* -is_(PyObject *s, PyObject *a) -{ - PyObject *a1, *a2, *result = NULL; - if (PyArg_UnpackTuple(a,"is_", 2, 2, &a1, &a2)) { - result = (a1 == a2) ? Py_True : Py_False; - Py_INCREF(result); - } - return result; -} - -static PyObject* -is_not(PyObject *s, PyObject *a) -{ - PyObject *a1, *a2, *result = NULL; - if (PyArg_UnpackTuple(a,"is_not", 2, 2, &a1, &a2)) { - result = (a1 != a2) ? Py_True : Py_False; - Py_INCREF(result); - } - return result; -} - -static PyObject* -op_getslice(PyObject *s, PyObject *a) -{ - PyObject *a1; - int a2,a3; - - if (!PyArg_ParseTuple(a,"Oii:getslice",&a1,&a2,&a3)) - return NULL; - return PySequence_GetSlice(a1,a2,a3); -} - -static PyObject* -op_setslice(PyObject *s, PyObject *a) -{ - PyObject *a1, *a4; - int a2,a3; - - if (!PyArg_ParseTuple(a,"OiiO:setslice",&a1,&a2,&a3,&a4)) - return NULL; - - if (-1 == PySequence_SetSlice(a1,a2,a3,a4)) - return NULL; - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject* -op_delslice(PyObject *s, PyObject *a) -{ - PyObject *a1; - int a2,a3; - - if(! PyArg_ParseTuple(a,"Oii:delslice",&a1,&a2,&a3)) - return NULL; - - if (-1 == PySequence_DelSlice(a1,a2,a3)) - return NULL; - - Py_INCREF(Py_None); - return Py_None; -} - -#undef spam1 -#undef spam2 -#undef spam1o -#undef spam1o -#define spam1(OP,DOC) {#OP, OP, METH_VARARGS, PyDoc_STR(DOC)}, -#define spam2(OP,ALTOP,DOC) {#OP, op_##OP, METH_VARARGS, DOC}, \ - {#ALTOP, op_##OP, METH_VARARGS, PyDoc_STR(DOC)}, -#define spam1o(OP,DOC) {#OP, OP, METH_O, PyDoc_STR(DOC)}, -#define spam2o(OP,ALTOP,DOC) {#OP, op_##OP, METH_O, DOC}, \ - {#ALTOP, op_##OP, METH_O, PyDoc_STR(DOC)}, - -static struct PyMethodDef operator_methods[] = { - -spam1o(isCallable, - "isCallable(a) -- Same as callable(a).") -spam1o(isNumberType, - "isNumberType(a) -- Return True if a has a numeric type, False otherwise.") -spam1o(isSequenceType, - "isSequenceType(a) -- Return True if a has a sequence type, False otherwise.") -spam1o(truth, - "truth(a) -- Return True if a is true, False otherwise.") -spam2(contains,__contains__, - "contains(a, b) -- Same as b in a (note reversed operands).") -spam1(sequenceIncludes, - "sequenceIncludes(a, b) -- Same as b in a (note reversed operands; deprecated).") -spam1(indexOf, - "indexOf(a, b) -- Return the first index of b in a.") -spam1(countOf, - "countOf(a, b) -- Return the number of times b occurs in a.") -spam1o(isMappingType, - "isMappingType(a) -- Return True if a has a mapping type, False otherwise.") - -spam1(is_, "is_(a, b) -- Same as a is b.") -spam1(is_not, "is_not(a, b) -- Same as a is not b.") -spam2(add,__add__, "add(a, b) -- Same as a + b.") -spam2(sub,__sub__, "sub(a, b) -- Same as a - b.") -spam2(mul,__mul__, "mul(a, b) -- Same as a * b.") -spam2(div,__div__, "div(a, b) -- Same as a / b when __future__.division is not in effect.") -spam2(floordiv,__floordiv__, "floordiv(a, b) -- Same as a // b.") -spam2(truediv,__truediv__, "truediv(a, b) -- Same as a / b when __future__.division is in effect.") -spam2(mod,__mod__, "mod(a, b) -- Same as a % b.") -spam2o(neg,__neg__, "neg(a) -- Same as -a.") -spam2o(pos,__pos__, "pos(a) -- Same as +a.") -spam2o(abs,__abs__, "abs(a) -- Same as abs(a).") -spam2o(inv,__inv__, "inv(a) -- Same as ~a.") -spam2o(invert,__invert__, "invert(a) -- Same as ~a.") -spam2(lshift,__lshift__, "lshift(a, b) -- Same as a << b.") -spam2(rshift,__rshift__, "rshift(a, b) -- Same as a >> b.") -spam2o(not_,__not__, "not_(a) -- Same as not a.") -spam2(and_,__and__, "and_(a, b) -- Same as a & b.") -spam2(xor,__xor__, "xor(a, b) -- Same as a ^ b.") -spam2(or_,__or__, "or_(a, b) -- Same as a | b.") -spam2(concat,__concat__, - "concat(a, b) -- Same as a + b, for a and b sequences.") -spam2(repeat,__repeat__, - "repeat(a, b) -- Return a * b, where a is a sequence, and b is an integer.") -spam2(getitem,__getitem__, - "getitem(a, b) -- Same as a[b].") -spam2(setitem,__setitem__, - "setitem(a, b, c) -- Same as a[b] = c.") -spam2(delitem,__delitem__, - "delitem(a, b) -- Same as del a[b].") -spam2(pow,__pow__, "pow(a, b) -- Same as a**b.") -spam2(getslice,__getslice__, - "getslice(a, b, c) -- Same as a[b:c].") -spam2(setslice,__setslice__, -"setslice(a, b, c, d) -- Same as a[b:c] = d.") -spam2(delslice,__delslice__, -"delslice(a, b, c) -- Same as del a[b:c].") -spam2(lt,__lt__, "lt(a, b) -- Same as ab.") -spam2(ge,__ge__, "ge(a, b) -- Same as a>=b.") - - {NULL, NULL} /* sentinel */ - -}; - - -/* Initialization function for the module (*must* be called initoperator) */ - -PyMODINIT_FUNC -initoperator(void) -{ - /* Create the module and add the functions */ - Py_InitModule4("operator", operator_methods, operator_doc, - (PyObject*)NULL, PYTHON_API_VERSION); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/ossaudiodev.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/ossaudiodev.c deleted file mode 100644 index 06215231..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/ossaudiodev.c +++ /dev/null @@ -1,1094 +0,0 @@ -/* - * ossaudiodev -- Python interface to the OSS (Open Sound System) API. - * This is the standard audio API for Linux and some - * flavours of BSD [XXX which ones?]; it is also available - * for a wide range of commercial Unices. - * - * Originally written by Peter Bosch, March 2000, as linuxaudiodev. - * - * Renamed to ossaudiodev and rearranged/revised/hacked up - * by Greg Ward , November 2002. - * Mixer interface by Nicholas FitzRoy-Dale , Dec 2002. - * - * (c) 2000 Peter Bosch. All Rights Reserved. - * (c) 2002 Gregory P. Ward. All Rights Reserved. - * (c) 2002 Python Software Foundation. All Rights Reserved. - * - * XXX need a license statement - * - * $Id: ossaudiodev.c,v 1.34 2003/06/02 14:15:34 gvanrossum Exp $ - */ - -#include "Python.h" -#include "structmember.h" - -#ifdef HAVE_FCNTL_H -#include -#else -#define O_RDONLY 00 -#define O_WRONLY 01 -#endif - -#include -#include - -#if defined(linux) - -typedef unsigned long uint32_t; - -#elif defined(__FreeBSD__) - -# ifndef SNDCTL_DSP_CHANNELS -# define SNDCTL_DSP_CHANNELS SOUND_PCM_WRITE_CHANNELS -# endif - -#endif - -typedef struct { - PyObject_HEAD; - int fd; /* The open file */ - int mode; /* file mode */ - int icount; /* Input count */ - int ocount; /* Output count */ - uint32_t afmts; /* Audio formats supported by hardware */ -} oss_audio_t; - -typedef struct { - PyObject_HEAD; - int fd; /* The open mixer device */ -} oss_mixer_t; - - -static PyTypeObject OSSAudioType; -static PyTypeObject OSSMixerType; - -static PyObject *OSSAudioError; - - -/* ---------------------------------------------------------------------- - * DSP object initialization/deallocation - */ - -static oss_audio_t * -newossobject(PyObject *arg) -{ - oss_audio_t *self; - int fd, afmts, imode; - char *basedev = NULL; - char *mode = NULL; - - /* Two ways to call open(): - open(device, mode) (for consistency with builtin open()) - open(mode) (for backwards compatibility) - because the *first* argument is optional, parsing args is - a wee bit tricky. */ - if (!PyArg_ParseTuple(arg, "s|s:open", &basedev, &mode)) - return NULL; - if (mode == NULL) { /* only one arg supplied */ - mode = basedev; - basedev = NULL; - } - - if (strcmp(mode, "r") == 0) - imode = O_RDONLY; - else if (strcmp(mode, "w") == 0) - imode = O_WRONLY; - else if (strcmp(mode, "rw") == 0) - imode = O_RDWR; - else { - PyErr_SetString(OSSAudioError, "mode must be 'r', 'w', or 'rw'"); - return NULL; - } - - /* Open the correct device: either the 'device' argument, - or the AUDIODEV environment variable, or "/dev/dsp". */ - if (basedev == NULL) { /* called with one arg */ - basedev = getenv("AUDIODEV"); - if (basedev == NULL) /* $AUDIODEV not set */ - basedev = "/dev/dsp"; - } - - /* Open with O_NONBLOCK to avoid hanging on devices that only allow - one open at a time. This does *not* affect later I/O; OSS - provides a special ioctl() for non-blocking read/write, which is - exposed via oss_nonblock() below. */ - if ((fd = open(basedev, imode|O_NONBLOCK)) == -1) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); - return NULL; - } - - /* And (try to) put it back in blocking mode so we get the - expected write() semantics. */ - if (fcntl(fd, F_SETFL, 0) == -1) { - close(fd); - PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); - return NULL; - } - - if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); - return NULL; - } - /* Create and initialize the object */ - if ((self = PyObject_New(oss_audio_t, &OSSAudioType)) == NULL) { - close(fd); - return NULL; - } - self->fd = fd; - self->mode = imode; - self->icount = self->ocount = 0; - self->afmts = afmts; - return self; -} - -static void -oss_dealloc(oss_audio_t *self) -{ - /* if already closed, don't reclose it */ - if (self->fd != -1) - close(self->fd); - PyObject_Del(self); -} - - -/* ---------------------------------------------------------------------- - * Mixer object initialization/deallocation - */ - -static oss_mixer_t * -newossmixerobject(PyObject *arg) -{ - char *basedev = NULL; - int fd; - oss_mixer_t *self; - - if (!PyArg_ParseTuple(arg, "|s", &basedev)) { - return NULL; - } - - if (basedev == NULL) { - basedev = getenv("MIXERDEV"); - if (basedev == NULL) /* MIXERDEV not set */ - basedev = "/dev/mixer"; - } - - if ((fd = open(basedev, O_RDWR)) == -1) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); - return NULL; - } - - if ((self = PyObject_New(oss_mixer_t, &OSSMixerType)) == NULL) { - close(fd); - return NULL; - } - - self->fd = fd; - - return self; -} - -static void -oss_mixer_dealloc(oss_mixer_t *self) -{ - /* if already closed, don't reclose it */ - if (self->fd != -1) - close(self->fd); - PyObject_Del(self); -} - - -/* Methods to wrap the OSS ioctls. The calling convention is pretty - simple: - nonblock() -> ioctl(fd, SNDCTL_DSP_NONBLOCK) - fmt = setfmt(fmt) -> ioctl(fd, SNDCTL_DSP_SETFMT, &fmt) - etc. -*/ - - -/* ---------------------------------------------------------------------- - * Helper functions - */ - -/* _do_ioctl_1() is a private helper function used for the OSS ioctls -- - SNDCTL_DSP_{SETFMT,CHANNELS,SPEED} -- that that are called from C - like this: - ioctl(fd, SNDCTL_DSP_cmd, &arg) - - where arg is the value to set, and on return the driver sets arg to - the value that was actually set. Mapping this to Python is obvious: - arg = dsp.xxx(arg) -*/ -static PyObject * -_do_ioctl_1(int fd, PyObject *args, char *fname, int cmd) -{ - char argfmt[33] = "i:"; - int arg; - - assert(strlen(fname) <= 30); - strcat(argfmt, fname); - if (!PyArg_ParseTuple(args, argfmt, &arg)) - return NULL; - - if (ioctl(fd, cmd, &arg) == -1) - return PyErr_SetFromErrno(PyExc_IOError); - return PyInt_FromLong(arg); -} - - -/* _do_ioctl_1_internal() is a wrapper for ioctls that take no inputs - but return an output -- ie. we need to pass a pointer to a local C - variable so the driver can write its output there, but from Python - all we see is the return value. For example, - SOUND_MIXER_READ_DEVMASK returns a bitmask of available mixer - devices, but does not use the value of the parameter passed-in in any - way. -*/ -static PyObject * -_do_ioctl_1_internal(int fd, PyObject *args, char *fname, int cmd) -{ - char argfmt[32] = ":"; - int arg = 0; - - assert(strlen(fname) <= 30); - strcat(argfmt, fname); - if (!PyArg_ParseTuple(args, argfmt, &arg)) - return NULL; - - if (ioctl(fd, cmd, &arg) == -1) - return PyErr_SetFromErrno(PyExc_IOError); - return PyInt_FromLong(arg); -} - - - -/* _do_ioctl_0() is a private helper for the no-argument ioctls: - SNDCTL_DSP_{SYNC,RESET,POST}. */ -static PyObject * -_do_ioctl_0(int fd, PyObject *args, char *fname, int cmd) -{ - char argfmt[32] = ":"; - int rv; - - assert(strlen(fname) <= 30); - strcat(argfmt, fname); - if (!PyArg_ParseTuple(args, argfmt)) - return NULL; - - /* According to hannu@opensound.com, all three of the ioctls that - use this function can block, so release the GIL. This is - especially important for SYNC, which can block for several - seconds. */ - Py_BEGIN_ALLOW_THREADS - rv = ioctl(fd, cmd, 0); - Py_END_ALLOW_THREADS - - if (rv == -1) - return PyErr_SetFromErrno(PyExc_IOError); - Py_INCREF(Py_None); - return Py_None; -} - - -/* ---------------------------------------------------------------------- - * Methods of DSP objects (OSSAudioType) - */ - -static PyObject * -oss_nonblock(oss_audio_t *self, PyObject *args) -{ - /* Hmmm: it doesn't appear to be possible to return to blocking - mode once we're in non-blocking mode! */ - if (!PyArg_ParseTuple(args, ":nonblock")) - return NULL; - if (ioctl(self->fd, SNDCTL_DSP_NONBLOCK, NULL) == -1) - return PyErr_SetFromErrno(PyExc_IOError); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -oss_setfmt(oss_audio_t *self, PyObject *args) -{ - return _do_ioctl_1(self->fd, args, "setfmt", SNDCTL_DSP_SETFMT); -} - -static PyObject * -oss_getfmts(oss_audio_t *self, PyObject *args) -{ - int mask; - if (!PyArg_ParseTuple(args, ":getfmts")) - return NULL; - if (ioctl(self->fd, SNDCTL_DSP_GETFMTS, &mask) == -1) - return PyErr_SetFromErrno(PyExc_IOError); - return PyInt_FromLong(mask); -} - -static PyObject * -oss_channels(oss_audio_t *self, PyObject *args) -{ - return _do_ioctl_1(self->fd, args, "channels", SNDCTL_DSP_CHANNELS); -} - -static PyObject * -oss_speed(oss_audio_t *self, PyObject *args) -{ - return _do_ioctl_1(self->fd, args, "speed", SNDCTL_DSP_SPEED); -} - -static PyObject * -oss_sync(oss_audio_t *self, PyObject *args) -{ - return _do_ioctl_0(self->fd, args, "sync", SNDCTL_DSP_SYNC); -} - -static PyObject * -oss_reset(oss_audio_t *self, PyObject *args) -{ - return _do_ioctl_0(self->fd, args, "reset", SNDCTL_DSP_RESET); -} - -static PyObject * -oss_post(oss_audio_t *self, PyObject *args) -{ - return _do_ioctl_0(self->fd, args, "post", SNDCTL_DSP_POST); -} - - -/* Regular file methods: read(), write(), close(), etc. as well - as one convenience method, writeall(). */ - -static PyObject * -oss_read(oss_audio_t *self, PyObject *args) -{ - int size, count; - char *cp; - PyObject *rv; - - if (!PyArg_ParseTuple(args, "i:read", &size)) - return NULL; - rv = PyString_FromStringAndSize(NULL, size); - if (rv == NULL) - return NULL; - cp = PyString_AS_STRING(rv); - - Py_BEGIN_ALLOW_THREADS - count = read(self->fd, cp, size); - Py_END_ALLOW_THREADS - - if (count < 0) { - PyErr_SetFromErrno(PyExc_IOError); - Py_DECREF(rv); - return NULL; - } - self->icount += count; - _PyString_Resize(&rv, count); - return rv; -} - -static PyObject * -oss_write(oss_audio_t *self, PyObject *args) -{ - char *cp; - int rv, size; - - if (!PyArg_ParseTuple(args, "s#:write", &cp, &size)) { - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - rv = write(self->fd, cp, size); - Py_END_ALLOW_THREADS - - if (rv == -1) { - return PyErr_SetFromErrno(PyExc_IOError); - } else { - self->ocount += rv; - } - return PyInt_FromLong(rv); -} - -static PyObject * -oss_writeall(oss_audio_t *self, PyObject *args) -{ - char *cp; - int rv, size; - fd_set write_set_fds; - int select_rv; - - /* NB. writeall() is only useful in non-blocking mode: according to - Guenter Geiger on the linux-audio-dev list - (http://eca.cx/lad/2002/11/0380.html), OSS guarantees that - write() in blocking mode consumes the whole buffer. In blocking - mode, the behaviour of write() and writeall() from Python is - indistinguishable. */ - - if (!PyArg_ParseTuple(args, "s#:write", &cp, &size)) - return NULL; - - /* use select to wait for audio device to be available */ - FD_ZERO(&write_set_fds); - FD_SET(self->fd, &write_set_fds); - - while (size > 0) { - Py_BEGIN_ALLOW_THREADS - select_rv = select(self->fd+1, NULL, &write_set_fds, NULL, NULL); - Py_END_ALLOW_THREADS - assert(select_rv != 0); /* no timeout, can't expire */ - if (select_rv == -1) - return PyErr_SetFromErrno(PyExc_IOError); - - Py_BEGIN_ALLOW_THREADS - rv = write(self->fd, cp, size); - Py_END_ALLOW_THREADS - if (rv == -1) { - if (errno == EAGAIN) { /* buffer is full, try again */ - errno = 0; - continue; - } else /* it's a real error */ - return PyErr_SetFromErrno(PyExc_IOError); - } else { /* wrote rv bytes */ - self->ocount += rv; - size -= rv; - cp += rv; - } - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -oss_close(oss_audio_t *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":close")) - return NULL; - - if (self->fd >= 0) { - Py_BEGIN_ALLOW_THREADS - close(self->fd); - Py_END_ALLOW_THREADS - self->fd = -1; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -oss_fileno(oss_audio_t *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":fileno")) - return NULL; - return PyInt_FromLong(self->fd); -} - - -/* Convenience methods: these generally wrap a couple of ioctls into one - common task. */ - -static PyObject * -oss_setparameters(oss_audio_t *self, PyObject *args) -{ - int wanted_fmt, wanted_channels, wanted_rate, strict=0; - int fmt, channels, rate; - PyObject * rv; /* return tuple (fmt, channels, rate) */ - - if (!PyArg_ParseTuple(args, "iii|i:setparameters", - &wanted_fmt, &wanted_channels, &wanted_rate, - &strict)) - return NULL; - - fmt = wanted_fmt; - if (ioctl(self->fd, SNDCTL_DSP_SETFMT, &fmt) == -1) { - return PyErr_SetFromErrno(PyExc_IOError); - } - if (strict && fmt != wanted_fmt) { - return PyErr_Format - (OSSAudioError, - "unable to set requested format (wanted %d, got %d)", - wanted_fmt, fmt); - } - - channels = wanted_channels; - if (ioctl(self->fd, SNDCTL_DSP_CHANNELS, &channels) == -1) { - return PyErr_SetFromErrno(PyExc_IOError); - } - if (strict && channels != wanted_channels) { - return PyErr_Format - (OSSAudioError, - "unable to set requested channels (wanted %d, got %d)", - wanted_channels, channels); - } - - rate = wanted_rate; - if (ioctl(self->fd, SNDCTL_DSP_SPEED, &rate) == -1) { - return PyErr_SetFromErrno(PyExc_IOError); - } - if (strict && rate != wanted_rate) { - return PyErr_Format - (OSSAudioError, - "unable to set requested rate (wanted %d, got %d)", - wanted_rate, rate); - } - - /* Construct the return value: a (fmt, channels, rate) tuple that - tells what the audio hardware was actually set to. */ - rv = PyTuple_New(3); - if (rv == NULL) - return NULL; - PyTuple_SET_ITEM(rv, 0, PyInt_FromLong(fmt)); - PyTuple_SET_ITEM(rv, 1, PyInt_FromLong(channels)); - PyTuple_SET_ITEM(rv, 2, PyInt_FromLong(rate)); - return rv; -} - -static int -_ssize(oss_audio_t *self, int *nchannels, int *ssize) -{ - int fmt; - - fmt = 0; - if (ioctl(self->fd, SNDCTL_DSP_SETFMT, &fmt) < 0) - return -errno; - - switch (fmt) { - case AFMT_MU_LAW: - case AFMT_A_LAW: - case AFMT_U8: - case AFMT_S8: - *ssize = 1; /* 8 bit formats: 1 byte */ - break; - case AFMT_S16_LE: - case AFMT_S16_BE: - case AFMT_U16_LE: - case AFMT_U16_BE: - *ssize = 2; /* 16 bit formats: 2 byte */ - break; - case AFMT_MPEG: - case AFMT_IMA_ADPCM: - default: - return -EOPNOTSUPP; - } - *nchannels = 0; - if (ioctl(self->fd, SNDCTL_DSP_CHANNELS, nchannels) < 0) - return -errno; - return 0; -} - - -/* bufsize returns the size of the hardware audio buffer in number - of samples */ -static PyObject * -oss_bufsize(oss_audio_t *self, PyObject *args) -{ - audio_buf_info ai; - int nchannels, ssize; - - if (!PyArg_ParseTuple(args, ":bufsize")) return NULL; - - if (_ssize(self, &nchannels, &ssize) < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - if (ioctl(self->fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - return PyInt_FromLong((ai.fragstotal * ai.fragsize) / (nchannels * ssize)); -} - -/* obufcount returns the number of samples that are available in the - hardware for playing */ -static PyObject * -oss_obufcount(oss_audio_t *self, PyObject *args) -{ - audio_buf_info ai; - int nchannels, ssize; - - if (!PyArg_ParseTuple(args, ":obufcount")) - return NULL; - - if (_ssize(self, &nchannels, &ssize) < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - if (ioctl(self->fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - return PyInt_FromLong((ai.fragstotal * ai.fragsize - ai.bytes) / - (ssize * nchannels)); -} - -/* obufcount returns the number of samples that can be played without - blocking */ -static PyObject * -oss_obuffree(oss_audio_t *self, PyObject *args) -{ - audio_buf_info ai; - int nchannels, ssize; - - if (!PyArg_ParseTuple(args, ":obuffree")) - return NULL; - - if (_ssize(self, &nchannels, &ssize) < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - if (ioctl(self->fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - return PyInt_FromLong(ai.bytes / (ssize * nchannels)); -} - -static PyObject * -oss_getptr(oss_audio_t *self, PyObject *args) -{ - count_info info; - int req; - - if (!PyArg_ParseTuple(args, ":getptr")) - return NULL; - - if (self->mode == O_RDONLY) - req = SNDCTL_DSP_GETIPTR; - else - req = SNDCTL_DSP_GETOPTR; - if (ioctl(self->fd, req, &info) == -1) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - return Py_BuildValue("iii", info.bytes, info.blocks, info.ptr); -} - - -/* ---------------------------------------------------------------------- - * Methods of mixer objects (OSSMixerType) - */ - -static PyObject * -oss_mixer_close(oss_mixer_t *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":close")) - return NULL; - - if (self->fd >= 0) { - close(self->fd); - self->fd = -1; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -oss_mixer_fileno(oss_mixer_t *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":fileno")) - return NULL; - return PyInt_FromLong(self->fd); -} - -/* Simple mixer interface methods */ - -static PyObject * -oss_mixer_controls(oss_mixer_t *self, PyObject *args) -{ - return _do_ioctl_1_internal(self->fd, args, "controls", - SOUND_MIXER_READ_DEVMASK); -} - -static PyObject * -oss_mixer_stereocontrols(oss_mixer_t *self, PyObject *args) -{ - return _do_ioctl_1_internal(self->fd, args, "stereocontrols", - SOUND_MIXER_READ_STEREODEVS); -} - -static PyObject * -oss_mixer_reccontrols(oss_mixer_t *self, PyObject *args) -{ - return _do_ioctl_1_internal(self->fd, args, "reccontrols", - SOUND_MIXER_READ_RECMASK); -} - -static PyObject * -oss_mixer_get(oss_mixer_t *self, PyObject *args) -{ - int channel, volume; - - /* Can't use _do_ioctl_1 because of encoded arg thingy. */ - if (!PyArg_ParseTuple(args, "i:get", &channel)) - return NULL; - - if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) { - PyErr_SetString(OSSAudioError, "Invalid mixer channel specified."); - return NULL; - } - - if (ioctl(self->fd, MIXER_READ(channel), &volume) == -1) - return PyErr_SetFromErrno(PyExc_IOError); - - return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8); -} - -static PyObject * -oss_mixer_set(oss_mixer_t *self, PyObject *args) -{ - int channel, volume, leftVol, rightVol; - - /* Can't use _do_ioctl_1 because of encoded arg thingy. */ - if (!PyArg_ParseTuple(args, "i(ii):set", &channel, &leftVol, &rightVol)) - return NULL; - - if (channel < 0 || channel > SOUND_MIXER_NRDEVICES) { - PyErr_SetString(OSSAudioError, "Invalid mixer channel specified."); - return NULL; - } - - if (leftVol < 0 || rightVol < 0 || leftVol > 100 || rightVol > 100) { - PyErr_SetString(OSSAudioError, "Volumes must be between 0 and 100."); - return NULL; - } - - volume = (rightVol << 8) | leftVol; - - if (ioctl(self->fd, MIXER_WRITE(channel), &volume) == -1) - return PyErr_SetFromErrno(PyExc_IOError); - - return Py_BuildValue("(ii)", volume & 0xff, (volume & 0xff00) >> 8); -} - -static PyObject * -oss_mixer_get_recsrc(oss_mixer_t *self, PyObject *args) -{ - return _do_ioctl_1_internal(self->fd, args, "get_recsrc", - SOUND_MIXER_READ_RECSRC); -} - -static PyObject * -oss_mixer_set_recsrc(oss_mixer_t *self, PyObject *args) -{ - return _do_ioctl_1(self->fd, args, "set_recsrc", - SOUND_MIXER_WRITE_RECSRC); -} - - -/* ---------------------------------------------------------------------- - * Method tables and other bureaucracy - */ - -static PyMethodDef oss_methods[] = { - /* Regular file methods */ - { "read", (PyCFunction)oss_read, METH_VARARGS }, - { "write", (PyCFunction)oss_write, METH_VARARGS }, - { "writeall", (PyCFunction)oss_writeall, METH_VARARGS }, - { "close", (PyCFunction)oss_close, METH_VARARGS }, - { "fileno", (PyCFunction)oss_fileno, METH_VARARGS }, - - /* Simple ioctl wrappers */ - { "nonblock", (PyCFunction)oss_nonblock, METH_VARARGS }, - { "setfmt", (PyCFunction)oss_setfmt, METH_VARARGS }, - { "getfmts", (PyCFunction)oss_getfmts, METH_VARARGS }, - { "channels", (PyCFunction)oss_channels, METH_VARARGS }, - { "speed", (PyCFunction)oss_speed, METH_VARARGS }, - { "sync", (PyCFunction)oss_sync, METH_VARARGS }, - { "reset", (PyCFunction)oss_reset, METH_VARARGS }, - { "post", (PyCFunction)oss_post, METH_VARARGS }, - - /* Convenience methods -- wrap a couple of ioctls together */ - { "setparameters", (PyCFunction)oss_setparameters, METH_VARARGS }, - { "bufsize", (PyCFunction)oss_bufsize, METH_VARARGS }, - { "obufcount", (PyCFunction)oss_obufcount, METH_VARARGS }, - { "obuffree", (PyCFunction)oss_obuffree, METH_VARARGS }, - { "getptr", (PyCFunction)oss_getptr, METH_VARARGS }, - - /* Aliases for backwards compatibility */ - { "flush", (PyCFunction)oss_sync, METH_VARARGS }, - - { NULL, NULL} /* sentinel */ -}; - -static PyMethodDef oss_mixer_methods[] = { - /* Regular file method - OSS mixers are ioctl-only interface */ - { "close", (PyCFunction)oss_mixer_close, METH_VARARGS }, - { "fileno", (PyCFunction)oss_mixer_fileno, METH_VARARGS }, - - /* Simple ioctl wrappers */ - { "controls", (PyCFunction)oss_mixer_controls, METH_VARARGS }, - { "stereocontrols", (PyCFunction)oss_mixer_stereocontrols, METH_VARARGS}, - { "reccontrols", (PyCFunction)oss_mixer_reccontrols, METH_VARARGS}, - { "get", (PyCFunction)oss_mixer_get, METH_VARARGS }, - { "set", (PyCFunction)oss_mixer_set, METH_VARARGS }, - { "get_recsrc", (PyCFunction)oss_mixer_get_recsrc, METH_VARARGS }, - { "set_recsrc", (PyCFunction)oss_mixer_set_recsrc, METH_VARARGS }, - - { NULL, NULL} -}; - -static PyObject * -oss_getattr(oss_audio_t *self, char *name) -{ - return Py_FindMethod(oss_methods, (PyObject *)self, name); -} - -static PyObject * -oss_mixer_getattr(oss_mixer_t *self, char *name) -{ - return Py_FindMethod(oss_mixer_methods, (PyObject *)self, name); -} - -static PyTypeObject OSSAudioType = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "ossaudiodev.oss_audio_device", /*tp_name*/ - sizeof(oss_audio_t), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)oss_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)oss_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ -}; - -static PyTypeObject OSSMixerType = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "ossaudiodev.oss_mixer_device", /*tp_name*/ - sizeof(oss_mixer_t), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)oss_mixer_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)oss_mixer_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ -}; - - -static PyObject * -ossopen(PyObject *self, PyObject *args) -{ - return (PyObject *)newossobject(args); -} - -static PyObject * -ossopenmixer(PyObject *self, PyObject *args) -{ - return (PyObject *)newossmixerobject(args); -} - -static PyMethodDef ossaudiodev_methods[] = { - { "open", ossopen, METH_VARARGS }, - { "openmixer", ossopenmixer, METH_VARARGS }, - { 0, 0 }, -}; - - -#define _EXPORT_INT(mod, name) \ - if (PyModule_AddIntConstant(mod, #name, (long) (name)) == -1) return; - - -static char *control_labels[] = SOUND_DEVICE_LABELS; -static char *control_names[] = SOUND_DEVICE_NAMES; - - -static int -build_namelists (PyObject *module) -{ - PyObject *labels; - PyObject *names; - PyObject *s; - int num_controls; - int i; - - num_controls = sizeof(control_labels) / sizeof(control_labels[0]); - assert(num_controls == sizeof(control_names) / sizeof(control_names[0])); - - labels = PyList_New(num_controls); - names = PyList_New(num_controls); - for (i = 0; i < num_controls; i++) { - s = PyString_FromString(control_labels[i]); - if (s == NULL) - return -1; - PyList_SET_ITEM(labels, i, s); - - s = PyString_FromString(control_names[i]); - if (s == NULL) - return -1; - PyList_SET_ITEM(names, i, s); - } - - if (PyModule_AddObject(module, "control_labels", labels) == -1) - return -1; - if (PyModule_AddObject(module, "control_names", names) == -1) - return -1; - - return 0; -} - - -void -initossaudiodev(void) -{ - PyObject *m; - - m = Py_InitModule("ossaudiodev", ossaudiodev_methods); - - OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError", - NULL, NULL); - if (OSSAudioError) { - /* Each call to PyModule_AddObject decrefs it; compensate: */ - Py_INCREF(OSSAudioError); - Py_INCREF(OSSAudioError); - PyModule_AddObject(m, "error", OSSAudioError); - PyModule_AddObject(m, "OSSAudioError", OSSAudioError); - } - - /* Build 'control_labels' and 'control_names' lists and add them - to the module. */ - if (build_namelists(m) == -1) /* XXX what to do here? */ - return; - - /* Expose the audio format numbers -- essential! */ - _EXPORT_INT(m, AFMT_QUERY); - _EXPORT_INT(m, AFMT_MU_LAW); - _EXPORT_INT(m, AFMT_A_LAW); - _EXPORT_INT(m, AFMT_IMA_ADPCM); - _EXPORT_INT(m, AFMT_U8); - _EXPORT_INT(m, AFMT_S16_LE); - _EXPORT_INT(m, AFMT_S16_BE); - _EXPORT_INT(m, AFMT_S8); - _EXPORT_INT(m, AFMT_U16_LE); - _EXPORT_INT(m, AFMT_U16_BE); - _EXPORT_INT(m, AFMT_MPEG); -#ifdef AFMT_AC3 - _EXPORT_INT(m, AFMT_AC3); -#endif -#ifdef AFMT_S16_NE - _EXPORT_INT(m, AFMT_S16_NE); -#endif - - /* Expose the sound mixer device numbers. */ - _EXPORT_INT(m, SOUND_MIXER_NRDEVICES); - _EXPORT_INT(m, SOUND_MIXER_VOLUME); - _EXPORT_INT(m, SOUND_MIXER_BASS); - _EXPORT_INT(m, SOUND_MIXER_TREBLE); - _EXPORT_INT(m, SOUND_MIXER_SYNTH); - _EXPORT_INT(m, SOUND_MIXER_PCM); - _EXPORT_INT(m, SOUND_MIXER_SPEAKER); - _EXPORT_INT(m, SOUND_MIXER_LINE); - _EXPORT_INT(m, SOUND_MIXER_MIC); - _EXPORT_INT(m, SOUND_MIXER_CD); - _EXPORT_INT(m, SOUND_MIXER_IMIX); - _EXPORT_INT(m, SOUND_MIXER_ALTPCM); - _EXPORT_INT(m, SOUND_MIXER_RECLEV); - _EXPORT_INT(m, SOUND_MIXER_IGAIN); - _EXPORT_INT(m, SOUND_MIXER_OGAIN); - _EXPORT_INT(m, SOUND_MIXER_LINE1); - _EXPORT_INT(m, SOUND_MIXER_LINE2); - _EXPORT_INT(m, SOUND_MIXER_LINE3); - _EXPORT_INT(m, SOUND_MIXER_DIGITAL1); - _EXPORT_INT(m, SOUND_MIXER_DIGITAL2); - _EXPORT_INT(m, SOUND_MIXER_DIGITAL3); - _EXPORT_INT(m, SOUND_MIXER_PHONEIN); - _EXPORT_INT(m, SOUND_MIXER_PHONEOUT); - _EXPORT_INT(m, SOUND_MIXER_VIDEO); - _EXPORT_INT(m, SOUND_MIXER_RADIO); - _EXPORT_INT(m, SOUND_MIXER_MONITOR); - - /* Expose all the ioctl numbers for masochists who like to do this - stuff directly. */ - _EXPORT_INT(m, SNDCTL_COPR_HALT); - _EXPORT_INT(m, SNDCTL_COPR_LOAD); - _EXPORT_INT(m, SNDCTL_COPR_RCODE); - _EXPORT_INT(m, SNDCTL_COPR_RCVMSG); - _EXPORT_INT(m, SNDCTL_COPR_RDATA); - _EXPORT_INT(m, SNDCTL_COPR_RESET); - _EXPORT_INT(m, SNDCTL_COPR_RUN); - _EXPORT_INT(m, SNDCTL_COPR_SENDMSG); - _EXPORT_INT(m, SNDCTL_COPR_WCODE); - _EXPORT_INT(m, SNDCTL_COPR_WDATA); -#ifdef SNDCTL_DSP_BIND_CHANNEL - _EXPORT_INT(m, SNDCTL_DSP_BIND_CHANNEL); -#endif - _EXPORT_INT(m, SNDCTL_DSP_CHANNELS); - _EXPORT_INT(m, SNDCTL_DSP_GETBLKSIZE); - _EXPORT_INT(m, SNDCTL_DSP_GETCAPS); -#ifdef SNDCTL_DSP_GETCHANNELMASK - _EXPORT_INT(m, SNDCTL_DSP_GETCHANNELMASK); -#endif - _EXPORT_INT(m, SNDCTL_DSP_GETFMTS); - _EXPORT_INT(m, SNDCTL_DSP_GETIPTR); - _EXPORT_INT(m, SNDCTL_DSP_GETISPACE); - _EXPORT_INT(m, SNDCTL_DSP_GETODELAY); - _EXPORT_INT(m, SNDCTL_DSP_GETOPTR); - _EXPORT_INT(m, SNDCTL_DSP_GETOSPACE); -#ifdef SNDCTL_DSP_GETSPDIF - _EXPORT_INT(m, SNDCTL_DSP_GETSPDIF); -#endif - _EXPORT_INT(m, SNDCTL_DSP_GETTRIGGER); - _EXPORT_INT(m, SNDCTL_DSP_MAPINBUF); - _EXPORT_INT(m, SNDCTL_DSP_MAPOUTBUF); - _EXPORT_INT(m, SNDCTL_DSP_NONBLOCK); - _EXPORT_INT(m, SNDCTL_DSP_POST); -#ifdef SNDCTL_DSP_PROFILE - _EXPORT_INT(m, SNDCTL_DSP_PROFILE); -#endif - _EXPORT_INT(m, SNDCTL_DSP_RESET); - _EXPORT_INT(m, SNDCTL_DSP_SAMPLESIZE); - _EXPORT_INT(m, SNDCTL_DSP_SETDUPLEX); - _EXPORT_INT(m, SNDCTL_DSP_SETFMT); - _EXPORT_INT(m, SNDCTL_DSP_SETFRAGMENT); -#ifdef SNDCTL_DSP_SETSPDIF - _EXPORT_INT(m, SNDCTL_DSP_SETSPDIF); -#endif - _EXPORT_INT(m, SNDCTL_DSP_SETSYNCRO); - _EXPORT_INT(m, SNDCTL_DSP_SETTRIGGER); - _EXPORT_INT(m, SNDCTL_DSP_SPEED); - _EXPORT_INT(m, SNDCTL_DSP_STEREO); - _EXPORT_INT(m, SNDCTL_DSP_SUBDIVIDE); - _EXPORT_INT(m, SNDCTL_DSP_SYNC); - _EXPORT_INT(m, SNDCTL_FM_4OP_ENABLE); - _EXPORT_INT(m, SNDCTL_FM_LOAD_INSTR); - _EXPORT_INT(m, SNDCTL_MIDI_INFO); - _EXPORT_INT(m, SNDCTL_MIDI_MPUCMD); - _EXPORT_INT(m, SNDCTL_MIDI_MPUMODE); - _EXPORT_INT(m, SNDCTL_MIDI_PRETIME); - _EXPORT_INT(m, SNDCTL_SEQ_CTRLRATE); - _EXPORT_INT(m, SNDCTL_SEQ_GETINCOUNT); - _EXPORT_INT(m, SNDCTL_SEQ_GETOUTCOUNT); -#ifdef SNDCTL_SEQ_GETTIME - _EXPORT_INT(m, SNDCTL_SEQ_GETTIME); -#endif - _EXPORT_INT(m, SNDCTL_SEQ_NRMIDIS); - _EXPORT_INT(m, SNDCTL_SEQ_NRSYNTHS); - _EXPORT_INT(m, SNDCTL_SEQ_OUTOFBAND); - _EXPORT_INT(m, SNDCTL_SEQ_PANIC); - _EXPORT_INT(m, SNDCTL_SEQ_PERCMODE); - _EXPORT_INT(m, SNDCTL_SEQ_RESET); - _EXPORT_INT(m, SNDCTL_SEQ_RESETSAMPLES); - _EXPORT_INT(m, SNDCTL_SEQ_SYNC); - _EXPORT_INT(m, SNDCTL_SEQ_TESTMIDI); - _EXPORT_INT(m, SNDCTL_SEQ_THRESHOLD); -#ifdef SNDCTL_SYNTH_CONTROL - _EXPORT_INT(m, SNDCTL_SYNTH_CONTROL); -#endif -#ifdef SNDCTL_SYNTH_ID - _EXPORT_INT(m, SNDCTL_SYNTH_ID); -#endif - _EXPORT_INT(m, SNDCTL_SYNTH_INFO); - _EXPORT_INT(m, SNDCTL_SYNTH_MEMAVL); -#ifdef SNDCTL_SYNTH_REMOVESAMPLE - _EXPORT_INT(m, SNDCTL_SYNTH_REMOVESAMPLE); -#endif - _EXPORT_INT(m, SNDCTL_TMR_CONTINUE); - _EXPORT_INT(m, SNDCTL_TMR_METRONOME); - _EXPORT_INT(m, SNDCTL_TMR_SELECT); - _EXPORT_INT(m, SNDCTL_TMR_SOURCE); - _EXPORT_INT(m, SNDCTL_TMR_START); - _EXPORT_INT(m, SNDCTL_TMR_STOP); - _EXPORT_INT(m, SNDCTL_TMR_TEMPO); - _EXPORT_INT(m, SNDCTL_TMR_TIMEBASE); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/parsermodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/parsermodule.c deleted file mode 100644 index 4edbeadd..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/parsermodule.c +++ /dev/null @@ -1,2957 +0,0 @@ -/* parsermodule.c - * - * Copyright 1995-1996 by Fred L. Drake, Jr. and Virginia Polytechnic - * Institute and State University, Blacksburg, Virginia, USA. - * Portions copyright 1991-1995 by Stichting Mathematisch Centrum, - * Amsterdam, The Netherlands. Copying is permitted under the terms - * associated with the main Python distribution, with the additional - * restriction that this additional notice be included and maintained - * on all distributed copies. - * - * This module serves to replace the original parser module written - * by Guido. The functionality is not matched precisely, but the - * original may be implemented on top of this. This is desirable - * since the source of the text to be parsed is now divorced from - * this interface. - * - * Unlike the prior interface, the ability to give a parse tree - * produced by Python code as a tuple to the compiler is enabled by - * this module. See the documentation for more details. - * - * I've added some annotations that help with the lint code-checking - * program, but they're not complete by a long shot. The real errors - * that lint detects are gone, but there are still warnings with - * Py_[X]DECREF() and Py_[X]INCREF() macros. The lint annotations - * look like "NOTE(...)". - */ - -#include "Python.h" /* general Python API */ -#include "graminit.h" /* symbols defined in the grammar */ -#include "node.h" /* internal parser structure */ -#include "errcode.h" /* error codes for PyNode_*() */ -#include "token.h" /* token definitions */ - /* ISTERMINAL() / ISNONTERMINAL() */ -#include "compile.h" /* PyNode_Compile() */ - -#ifdef lint -#include -#else -#define NOTE(x) -#endif - -#ifdef macintosh -char *strdup(char *); -#endif - -/* String constants used to initialize module attributes. - * - */ -static char parser_copyright_string[] = -"Copyright 1995-1996 by Virginia Polytechnic Institute & State\n\ -University, Blacksburg, Virginia, USA, and Fred L. Drake, Jr., Reston,\n\ -Virginia, USA. Portions copyright 1991-1995 by Stichting Mathematisch\n\ -Centrum, Amsterdam, The Netherlands."; - - -PyDoc_STRVAR(parser_doc_string, -"This is an interface to Python's internal parser."); - -static char parser_version_string[] = "0.5"; - - -typedef PyObject* (*SeqMaker) (int length); -typedef int (*SeqInserter) (PyObject* sequence, - int index, - PyObject* element); - -/* The function below is copyrighted by Stichting Mathematisch Centrum. The - * original copyright statement is included below, and continues to apply - * in full to the function immediately following. All other material is - * original, copyrighted by Fred L. Drake, Jr. and Virginia Polytechnic - * Institute and State University. Changes were made to comply with the - * new naming conventions. Added arguments to provide support for creating - * lists as well as tuples, and optionally including the line numbers. - */ - - -static PyObject* -node2tuple(node *n, /* node to convert */ - SeqMaker mkseq, /* create sequence */ - SeqInserter addelem, /* func. to add elem. in seq. */ - int lineno) /* include line numbers? */ -{ - if (n == NULL) { - Py_INCREF(Py_None); - return (Py_None); - } - if (ISNONTERMINAL(TYPE(n))) { - int i; - PyObject *v; - PyObject *w; - - v = mkseq(1 + NCH(n) + (TYPE(n) == encoding_decl)); - if (v == NULL) - return (v); - w = PyInt_FromLong(TYPE(n)); - if (w == NULL) { - Py_DECREF(v); - return ((PyObject*) NULL); - } - (void) addelem(v, 0, w); - for (i = 0; i < NCH(n); i++) { - w = node2tuple(CHILD(n, i), mkseq, addelem, lineno); - if (w == NULL) { - Py_DECREF(v); - return ((PyObject*) NULL); - } - (void) addelem(v, i+1, w); - } - - if (TYPE(n) == encoding_decl) - (void) addelem(v, i+1, PyString_FromString(STR(n))); - return (v); - } - else if (ISTERMINAL(TYPE(n))) { - PyObject *result = mkseq(2 + lineno); - if (result != NULL) { - (void) addelem(result, 0, PyInt_FromLong(TYPE(n))); - (void) addelem(result, 1, PyString_FromString(STR(n))); - if (lineno == 1) - (void) addelem(result, 2, PyInt_FromLong(n->n_lineno)); - } - return (result); - } - else { - PyErr_SetString(PyExc_SystemError, - "unrecognized parse tree node type"); - return ((PyObject*) NULL); - } -} -/* - * End of material copyrighted by Stichting Mathematisch Centrum. - */ - - - -/* There are two types of intermediate objects we're interested in: - * 'eval' and 'exec' types. These constants can be used in the st_type - * field of the object type to identify which any given object represents. - * These should probably go in an external header to allow other extensions - * to use them, but then, we really should be using C++ too. ;-) - */ - -#define PyST_EXPR 1 -#define PyST_SUITE 2 - - -/* These are the internal objects and definitions required to implement the - * ST type. Most of the internal names are more reminiscent of the 'old' - * naming style, but the code uses the new naming convention. - */ - -static PyObject* -parser_error = 0; - - -typedef struct { - PyObject_HEAD /* standard object header */ - node* st_node; /* the node* returned by the parser */ - int st_type; /* EXPR or SUITE ? */ -} PyST_Object; - - -static void parser_free(PyST_Object *st); -static int parser_compare(PyST_Object *left, PyST_Object *right); -static PyObject *parser_getattr(PyObject *self, char *name); - - -static -PyTypeObject PyST_Type = { - PyObject_HEAD_INIT(NULL) - 0, - "parser.st", /* tp_name */ - (int) sizeof(PyST_Object), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)parser_free, /* tp_dealloc */ - 0, /* tp_print */ - parser_getattr, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)parser_compare, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - - /* Functions to access object as input/output buffer */ - 0, /* tp_as_buffer */ - - Py_TPFLAGS_DEFAULT, /* tp_flags */ - - /* __doc__ */ - "Intermediate representation of a Python parse tree." -}; /* PyST_Type */ - - -static int -parser_compare_nodes(node *left, node *right) -{ - int j; - - if (TYPE(left) < TYPE(right)) - return (-1); - - if (TYPE(right) < TYPE(left)) - return (1); - - if (ISTERMINAL(TYPE(left))) - return (strcmp(STR(left), STR(right))); - - if (NCH(left) < NCH(right)) - return (-1); - - if (NCH(right) < NCH(left)) - return (1); - - for (j = 0; j < NCH(left); ++j) { - int v = parser_compare_nodes(CHILD(left, j), CHILD(right, j)); - - if (v != 0) - return (v); - } - return (0); -} - - -/* int parser_compare(PyST_Object* left, PyST_Object* right) - * - * Comparison function used by the Python operators ==, !=, <, >, <=, >= - * This really just wraps a call to parser_compare_nodes() with some easy - * checks and protection code. - * - */ -static int -parser_compare(PyST_Object *left, PyST_Object *right) -{ - if (left == right) - return (0); - - if ((left == 0) || (right == 0)) - return (-1); - - return (parser_compare_nodes(left->st_node, right->st_node)); -} - - -/* parser_newstobject(node* st) - * - * Allocates a new Python object representing an ST. This is simply the - * 'wrapper' object that holds a node* and allows it to be passed around in - * Python code. - * - */ -static PyObject* -parser_newstobject(node *st, int type) -{ - PyST_Object* o = PyObject_New(PyST_Object, &PyST_Type); - - if (o != 0) { - o->st_node = st; - o->st_type = type; - } - else { - PyNode_Free(st); - } - return ((PyObject*)o); -} - - -/* void parser_free(PyST_Object* st) - * - * This is called by a del statement that reduces the reference count to 0. - * - */ -static void -parser_free(PyST_Object *st) -{ - PyNode_Free(st->st_node); - PyObject_Del(st); -} - - -/* parser_st2tuple(PyObject* self, PyObject* args, PyObject* kw) - * - * This provides conversion from a node* to a tuple object that can be - * returned to the Python-level caller. The ST object is not modified. - * - */ -static PyObject* -parser_st2tuple(PyST_Object *self, PyObject *args, PyObject *kw) -{ - PyObject *line_option = 0; - PyObject *res = 0; - int ok; - - static char *keywords[] = {"ast", "line_info", NULL}; - - if (self == NULL) { - ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|O:st2tuple", keywords, - &PyST_Type, &self, &line_option); - } - else - ok = PyArg_ParseTupleAndKeywords(args, kw, "|O:totuple", &keywords[1], - &line_option); - if (ok != 0) { - int lineno = 0; - if (line_option != NULL) { - lineno = (PyObject_IsTrue(line_option) != 0) ? 1 : 0; - } - /* - * Convert ST into a tuple representation. Use Guido's function, - * since it's known to work already. - */ - res = node2tuple(((PyST_Object*)self)->st_node, - PyTuple_New, PyTuple_SetItem, lineno); - } - return (res); -} - - -/* parser_st2list(PyObject* self, PyObject* args, PyObject* kw) - * - * This provides conversion from a node* to a list object that can be - * returned to the Python-level caller. The ST object is not modified. - * - */ -static PyObject* -parser_st2list(PyST_Object *self, PyObject *args, PyObject *kw) -{ - PyObject *line_option = 0; - PyObject *res = 0; - int ok; - - static char *keywords[] = {"ast", "line_info", NULL}; - - if (self == NULL) - ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|O:st2list", keywords, - &PyST_Type, &self, &line_option); - else - ok = PyArg_ParseTupleAndKeywords(args, kw, "|O:tolist", &keywords[1], - &line_option); - if (ok) { - int lineno = 0; - if (line_option != 0) { - lineno = PyObject_IsTrue(line_option) ? 1 : 0; - } - /* - * Convert ST into a tuple representation. Use Guido's function, - * since it's known to work already. - */ - res = node2tuple(self->st_node, - PyList_New, PyList_SetItem, lineno); - } - return (res); -} - - -/* parser_compilest(PyObject* self, PyObject* args) - * - * This function creates code objects from the parse tree represented by - * the passed-in data object. An optional file name is passed in as well. - * - */ -static PyObject* -parser_compilest(PyST_Object *self, PyObject *args, PyObject *kw) -{ - PyObject* res = 0; - char* str = ""; - int ok; - - static char *keywords[] = {"ast", "filename", NULL}; - - if (self == NULL) - ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|s:compilest", keywords, - &PyST_Type, &self, &str); - else - ok = PyArg_ParseTupleAndKeywords(args, kw, "|s:compile", &keywords[1], - &str); - - if (ok) - res = (PyObject *)PyNode_Compile(self->st_node, str); - - return (res); -} - - -/* PyObject* parser_isexpr(PyObject* self, PyObject* args) - * PyObject* parser_issuite(PyObject* self, PyObject* args) - * - * Checks the passed-in ST object to determine if it is an expression or - * a statement suite, respectively. The return is a Python truth value. - * - */ -static PyObject* -parser_isexpr(PyST_Object *self, PyObject *args, PyObject *kw) -{ - PyObject* res = 0; - int ok; - - static char *keywords[] = {"ast", NULL}; - - if (self == NULL) - ok = PyArg_ParseTupleAndKeywords(args, kw, "O!:isexpr", keywords, - &PyST_Type, &self); - else - ok = PyArg_ParseTupleAndKeywords(args, kw, ":isexpr", &keywords[1]); - - if (ok) { - /* Check to see if the ST represents an expression or not. */ - res = (self->st_type == PyST_EXPR) ? Py_True : Py_False; - Py_INCREF(res); - } - return (res); -} - - -static PyObject* -parser_issuite(PyST_Object *self, PyObject *args, PyObject *kw) -{ - PyObject* res = 0; - int ok; - - static char *keywords[] = {"ast", NULL}; - - if (self == NULL) - ok = PyArg_ParseTupleAndKeywords(args, kw, "O!:issuite", keywords, - &PyST_Type, &self); - else - ok = PyArg_ParseTupleAndKeywords(args, kw, ":issuite", &keywords[1]); - - if (ok) { - /* Check to see if the ST represents an expression or not. */ - res = (self->st_type == PyST_EXPR) ? Py_False : Py_True; - Py_INCREF(res); - } - return (res); -} - - -#define PUBLIC_METHOD_TYPE (METH_VARARGS|METH_KEYWORDS) - -static PyMethodDef -parser_methods[] = { - {"compile", (PyCFunction)parser_compilest, PUBLIC_METHOD_TYPE, - PyDoc_STR("Compile this ST object into a code object.")}, - {"isexpr", (PyCFunction)parser_isexpr, PUBLIC_METHOD_TYPE, - PyDoc_STR("Determines if this ST object was created from an expression.")}, - {"issuite", (PyCFunction)parser_issuite, PUBLIC_METHOD_TYPE, - PyDoc_STR("Determines if this ST object was created from a suite.")}, - {"tolist", (PyCFunction)parser_st2list, PUBLIC_METHOD_TYPE, - PyDoc_STR("Creates a list-tree representation of this ST.")}, - {"totuple", (PyCFunction)parser_st2tuple, PUBLIC_METHOD_TYPE, - PyDoc_STR("Creates a tuple-tree representation of this ST.")}, - - {NULL, NULL, 0, NULL} -}; - - -static PyObject* -parser_getattr(PyObject *self, char *name) -{ - return (Py_FindMethod(parser_methods, self, name)); -} - - -/* err_string(char* message) - * - * Sets the error string for an exception of type ParserError. - * - */ -static void -err_string(char *message) -{ - PyErr_SetString(parser_error, message); -} - - -/* PyObject* parser_do_parse(PyObject* args, int type) - * - * Internal function to actually execute the parse and return the result if - * successful or set an exception if not. - * - */ -static PyObject* -parser_do_parse(PyObject *args, PyObject *kw, char *argspec, int type) -{ - char* string = 0; - PyObject* res = 0; - - static char *keywords[] = {"source", NULL}; - - if (PyArg_ParseTupleAndKeywords(args, kw, argspec, keywords, &string)) { - node* n = PyParser_SimpleParseString(string, - (type == PyST_EXPR) - ? eval_input : file_input); - - if (n) - res = parser_newstobject(n, type); - } - return (res); -} - - -/* PyObject* parser_expr(PyObject* self, PyObject* args) - * PyObject* parser_suite(PyObject* self, PyObject* args) - * - * External interfaces to the parser itself. Which is called determines if - * the parser attempts to recognize an expression ('eval' form) or statement - * suite ('exec' form). The real work is done by parser_do_parse() above. - * - */ -static PyObject* -parser_expr(PyST_Object *self, PyObject *args, PyObject *kw) -{ - NOTE(ARGUNUSED(self)) - return (parser_do_parse(args, kw, "s:expr", PyST_EXPR)); -} - - -static PyObject* -parser_suite(PyST_Object *self, PyObject *args, PyObject *kw) -{ - NOTE(ARGUNUSED(self)) - return (parser_do_parse(args, kw, "s:suite", PyST_SUITE)); -} - - - -/* This is the messy part of the code. Conversion from a tuple to an ST - * object requires that the input tuple be valid without having to rely on - * catching an exception from the compiler. This is done to allow the - * compiler itself to remain fast, since most of its input will come from - * the parser directly, and therefore be known to be syntactically correct. - * This validation is done to ensure that we don't core dump the compile - * phase, returning an exception instead. - * - * Two aspects can be broken out in this code: creating a node tree from - * the tuple passed in, and verifying that it is indeed valid. It may be - * advantageous to expand the number of ST types to include funcdefs and - * lambdadefs to take advantage of the optimizer, recognizing those STs - * here. They are not necessary, and not quite as useful in a raw form. - * For now, let's get expressions and suites working reliably. - */ - - -static node* build_node_tree(PyObject *tuple); -static int validate_expr_tree(node *tree); -static int validate_file_input(node *tree); -static int validate_encoding_decl(node *tree); - -/* PyObject* parser_tuple2st(PyObject* self, PyObject* args) - * - * This is the public function, called from the Python code. It receives a - * single tuple object from the caller, and creates an ST object if the - * tuple can be validated. It does this by checking the first code of the - * tuple, and, if acceptable, builds the internal representation. If this - * step succeeds, the internal representation is validated as fully as - * possible with the various validate_*() routines defined below. - * - * This function must be changed if support is to be added for PyST_FRAGMENT - * ST objects. - * - */ -static PyObject* -parser_tuple2st(PyST_Object *self, PyObject *args, PyObject *kw) -{ - NOTE(ARGUNUSED(self)) - PyObject *st = 0; - PyObject *tuple; - node *tree; - - static char *keywords[] = {"sequence", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kw, "O:sequence2st", keywords, - &tuple)) - return (0); - if (!PySequence_Check(tuple)) { - PyErr_SetString(PyExc_ValueError, - "sequence2st() requires a single sequence argument"); - return (0); - } - /* - * Convert the tree to the internal form before checking it. - */ - tree = build_node_tree(tuple); - if (tree != 0) { - int start_sym = TYPE(tree); - if (start_sym == eval_input) { - /* Might be an eval form. */ - if (validate_expr_tree(tree)) - st = parser_newstobject(tree, PyST_EXPR); - else - PyNode_Free(tree); - } - else if (start_sym == file_input) { - /* This looks like an exec form so far. */ - if (validate_file_input(tree)) - st = parser_newstobject(tree, PyST_SUITE); - else - PyNode_Free(tree); - } - else if (start_sym == encoding_decl) { - /* This looks like an encoding_decl so far. */ - if (validate_encoding_decl(tree)) - st = parser_newstobject(tree, PyST_SUITE); - else - PyNode_Free(tree); - } - else { - /* This is a fragment, at best. */ - PyNode_Free(tree); - err_string("parse tree does not use a valid start symbol"); - } - } - /* Make sure we throw an exception on all errors. We should never - * get this, but we'd do well to be sure something is done. - */ - if (st == NULL && !PyErr_Occurred()) - err_string("unspecified ST error occurred"); - - return st; -} - - -/* node* build_node_children() - * - * Iterate across the children of the current non-terminal node and build - * their structures. If successful, return the root of this portion of - * the tree, otherwise, 0. Any required exception will be specified already, - * and no memory will have been deallocated. - * - */ -static node* -build_node_children(PyObject *tuple, node *root, int *line_num) -{ - int len = PyObject_Size(tuple); - int i, err; - - for (i = 1; i < len; ++i) { - /* elem must always be a sequence, however simple */ - PyObject* elem = PySequence_GetItem(tuple, i); - int ok = elem != NULL; - long type = 0; - char *strn = 0; - - if (ok) - ok = PySequence_Check(elem); - if (ok) { - PyObject *temp = PySequence_GetItem(elem, 0); - if (temp == NULL) - ok = 0; - else { - ok = PyInt_Check(temp); - if (ok) - type = PyInt_AS_LONG(temp); - Py_DECREF(temp); - } - } - if (!ok) { - PyErr_SetObject(parser_error, - Py_BuildValue("os", elem, - "Illegal node construct.")); - Py_XDECREF(elem); - return (0); - } - if (ISTERMINAL(type)) { - int len = PyObject_Size(elem); - PyObject *temp; - - if ((len != 2) && (len != 3)) { - err_string("terminal nodes must have 2 or 3 entries"); - return 0; - } - temp = PySequence_GetItem(elem, 1); - if (temp == NULL) - return 0; - if (!PyString_Check(temp)) { - PyErr_Format(parser_error, - "second item in terminal node must be a string," - " found %s", - temp->ob_type->tp_name); - Py_DECREF(temp); - return 0; - } - if (len == 3) { - PyObject *o = PySequence_GetItem(elem, 2); - if (o != NULL) { - if (PyInt_Check(o)) - *line_num = PyInt_AS_LONG(o); - else { - PyErr_Format(parser_error, - "third item in terminal node must be an" - " integer, found %s", - temp->ob_type->tp_name); - Py_DECREF(o); - Py_DECREF(temp); - return 0; - } - Py_DECREF(o); - } - } - len = PyString_GET_SIZE(temp) + 1; - strn = (char *)PyMem_MALLOC(len); - if (strn != NULL) - (void) memcpy(strn, PyString_AS_STRING(temp), len); - Py_DECREF(temp); - } - else if (!ISNONTERMINAL(type)) { - /* - * It has to be one or the other; this is an error. - * Throw an exception. - */ - PyErr_SetObject(parser_error, - Py_BuildValue("os", elem, "unknown node type.")); - Py_XDECREF(elem); - return (0); - } - err = PyNode_AddChild(root, type, strn, *line_num); - if (err == E_NOMEM) { - PyMem_DEL(strn); - return (node *) PyErr_NoMemory(); - } - if (err == E_OVERFLOW) { - PyMem_DEL(strn); - PyErr_SetString(PyExc_ValueError, - "unsupported number of child nodes"); - return NULL; - } - - if (ISNONTERMINAL(type)) { - node* new_child = CHILD(root, i - 1); - - if (new_child != build_node_children(elem, new_child, line_num)) { - Py_XDECREF(elem); - return (0); - } - } - else if (type == NEWLINE) { /* It's true: we increment the */ - ++(*line_num); /* line number *after* the newline! */ - } - Py_XDECREF(elem); - } - return (root); -} - - -static node* -build_node_tree(PyObject *tuple) -{ - node* res = 0; - PyObject *temp = PySequence_GetItem(tuple, 0); - long num = -1; - - if (temp != NULL) - num = PyInt_AsLong(temp); - Py_XDECREF(temp); - if (ISTERMINAL(num)) { - /* - * The tuple is simple, but it doesn't start with a start symbol. - * Throw an exception now and be done with it. - */ - tuple = Py_BuildValue("os", tuple, - "Illegal syntax-tree; cannot start with terminal symbol."); - PyErr_SetObject(parser_error, tuple); - } - else if (ISNONTERMINAL(num)) { - /* - * Not efficient, but that can be handled later. - */ - int line_num = 0; - PyObject *encoding = NULL; - - if (num == encoding_decl) { - encoding = PySequence_GetItem(tuple, 2); - /* tuple isn't borrowed anymore here, need to DECREF */ - tuple = PySequence_GetSlice(tuple, 0, 2); - } - res = PyNode_New(num); - if (res != NULL) { - if (res != build_node_children(tuple, res, &line_num)) { - PyNode_Free(res); - res = NULL; - } - if (res && encoding) { - int len; - len = PyString_GET_SIZE(encoding) + 1; - res->n_str = (char *)PyMem_MALLOC(len); - if (res->n_str != NULL) - (void) memcpy(res->n_str, PyString_AS_STRING(encoding), len); - Py_DECREF(encoding); - Py_DECREF(tuple); - } - } - } - else - /* The tuple is illegal -- if the number is neither TERMINAL nor - * NONTERMINAL, we can't use it. Not sure the implementation - * allows this condition, but the API doesn't preclude it. - */ - PyErr_SetObject(parser_error, - Py_BuildValue("os", tuple, - "Illegal component tuple.")); - - return (res); -} - - -/* - * Validation routines used within the validation section: - */ -static int validate_terminal(node *terminal, int type, char *string); - -#define validate_ampersand(ch) validate_terminal(ch, AMPER, "&") -#define validate_circumflex(ch) validate_terminal(ch, CIRCUMFLEX, "^") -#define validate_colon(ch) validate_terminal(ch, COLON, ":") -#define validate_comma(ch) validate_terminal(ch, COMMA, ",") -#define validate_dedent(ch) validate_terminal(ch, DEDENT, "") -#define validate_equal(ch) validate_terminal(ch, EQUAL, "=") -#define validate_indent(ch) validate_terminal(ch, INDENT, (char*)NULL) -#define validate_lparen(ch) validate_terminal(ch, LPAR, "(") -#define validate_newline(ch) validate_terminal(ch, NEWLINE, (char*)NULL) -#define validate_rparen(ch) validate_terminal(ch, RPAR, ")") -#define validate_semi(ch) validate_terminal(ch, SEMI, ";") -#define validate_star(ch) validate_terminal(ch, STAR, "*") -#define validate_vbar(ch) validate_terminal(ch, VBAR, "|") -#define validate_doublestar(ch) validate_terminal(ch, DOUBLESTAR, "**") -#define validate_dot(ch) validate_terminal(ch, DOT, ".") -#define validate_name(ch, str) validate_terminal(ch, NAME, str) - -#define VALIDATER(n) static int validate_##n(node *tree) - -VALIDATER(node); VALIDATER(small_stmt); -VALIDATER(class); VALIDATER(node); -VALIDATER(parameters); VALIDATER(suite); -VALIDATER(testlist); VALIDATER(varargslist); -VALIDATER(fpdef); VALIDATER(fplist); -VALIDATER(stmt); VALIDATER(simple_stmt); -VALIDATER(expr_stmt); VALIDATER(power); -VALIDATER(print_stmt); VALIDATER(del_stmt); -VALIDATER(return_stmt); VALIDATER(list_iter); -VALIDATER(raise_stmt); VALIDATER(import_stmt); -VALIDATER(global_stmt); VALIDATER(list_if); -VALIDATER(assert_stmt); VALIDATER(list_for); -VALIDATER(exec_stmt); VALIDATER(compound_stmt); -VALIDATER(while); VALIDATER(for); -VALIDATER(try); VALIDATER(except_clause); -VALIDATER(test); VALIDATER(and_test); -VALIDATER(not_test); VALIDATER(comparison); -VALIDATER(comp_op); VALIDATER(expr); -VALIDATER(xor_expr); VALIDATER(and_expr); -VALIDATER(shift_expr); VALIDATER(arith_expr); -VALIDATER(term); VALIDATER(factor); -VALIDATER(atom); VALIDATER(lambdef); -VALIDATER(trailer); VALIDATER(subscript); -VALIDATER(subscriptlist); VALIDATER(sliceop); -VALIDATER(exprlist); VALIDATER(dictmaker); -VALIDATER(arglist); VALIDATER(argument); -VALIDATER(listmaker); VALIDATER(yield_stmt); -VALIDATER(testlist1); - -#undef VALIDATER - -#define is_even(n) (((n) & 1) == 0) -#define is_odd(n) (((n) & 1) == 1) - - -static int -validate_ntype(node *n, int t) -{ - if (TYPE(n) != t) { - PyErr_Format(parser_error, "Expected node type %d, got %d.", - t, TYPE(n)); - return 0; - } - return 1; -} - - -/* Verifies that the number of child nodes is exactly 'num', raising - * an exception if it isn't. The exception message does not indicate - * the exact number of nodes, allowing this to be used to raise the - * "right" exception when the wrong number of nodes is present in a - * specific variant of a statement's syntax. This is commonly used - * in that fashion. - */ -static int -validate_numnodes(node *n, int num, const char *const name) -{ - if (NCH(n) != num) { - PyErr_Format(parser_error, - "Illegal number of children for %s node.", name); - return 0; - } - return 1; -} - - -static int -validate_terminal(node *terminal, int type, char *string) -{ - int res = (validate_ntype(terminal, type) - && ((string == 0) || (strcmp(string, STR(terminal)) == 0))); - - if (!res && !PyErr_Occurred()) { - PyErr_Format(parser_error, - "Illegal terminal: expected \"%s\"", string); - } - return (res); -} - - -/* X (',' X) [','] - */ -static int -validate_repeating_list(node *tree, int ntype, int (*vfunc)(node *), - const char *const name) -{ - int nch = NCH(tree); - int res = (nch && validate_ntype(tree, ntype) - && vfunc(CHILD(tree, 0))); - - if (!res && !PyErr_Occurred()) - (void) validate_numnodes(tree, 1, name); - else { - if (is_even(nch)) - res = validate_comma(CHILD(tree, --nch)); - if (res && nch > 1) { - int pos = 1; - for ( ; res && pos < nch; pos += 2) - res = (validate_comma(CHILD(tree, pos)) - && vfunc(CHILD(tree, pos + 1))); - } - } - return (res); -} - - -/* validate_class() - * - * classdef: - * 'class' NAME ['(' testlist ')'] ':' suite - */ -static int -validate_class(node *tree) -{ - int nch = NCH(tree); - int res = validate_ntype(tree, classdef) && ((nch == 4) || (nch == 7)); - - if (res) { - res = (validate_name(CHILD(tree, 0), "class") - && validate_ntype(CHILD(tree, 1), NAME) - && validate_colon(CHILD(tree, nch - 2)) - && validate_suite(CHILD(tree, nch - 1))); - } - else - (void) validate_numnodes(tree, 4, "class"); - if (res && (nch == 7)) { - res = (validate_lparen(CHILD(tree, 2)) - && validate_testlist(CHILD(tree, 3)) - && validate_rparen(CHILD(tree, 4))); - } - return (res); -} - - -/* if_stmt: - * 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] - */ -static int -validate_if(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, if_stmt) - && (nch >= 4) - && validate_name(CHILD(tree, 0), "if") - && validate_test(CHILD(tree, 1)) - && validate_colon(CHILD(tree, 2)) - && validate_suite(CHILD(tree, 3))); - - if (res && ((nch % 4) == 3)) { - /* ... 'else' ':' suite */ - res = (validate_name(CHILD(tree, nch - 3), "else") - && validate_colon(CHILD(tree, nch - 2)) - && validate_suite(CHILD(tree, nch - 1))); - nch -= 3; - } - else if (!res && !PyErr_Occurred()) - (void) validate_numnodes(tree, 4, "if"); - if ((nch % 4) != 0) - /* Will catch the case for nch < 4 */ - res = validate_numnodes(tree, 0, "if"); - else if (res && (nch > 4)) { - /* ... ('elif' test ':' suite)+ ... */ - int j = 4; - while ((j < nch) && res) { - res = (validate_name(CHILD(tree, j), "elif") - && validate_colon(CHILD(tree, j + 2)) - && validate_test(CHILD(tree, j + 1)) - && validate_suite(CHILD(tree, j + 3))); - j += 4; - } - } - return (res); -} - - -/* parameters: - * '(' [varargslist] ')' - * - */ -static int -validate_parameters(node *tree) -{ - int nch = NCH(tree); - int res = validate_ntype(tree, parameters) && ((nch == 2) || (nch == 3)); - - if (res) { - res = (validate_lparen(CHILD(tree, 0)) - && validate_rparen(CHILD(tree, nch - 1))); - if (res && (nch == 3)) - res = validate_varargslist(CHILD(tree, 1)); - } - else { - (void) validate_numnodes(tree, 2, "parameters"); - } - return (res); -} - - -/* validate_suite() - * - * suite: - * simple_stmt - * | NEWLINE INDENT stmt+ DEDENT - */ -static int -validate_suite(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, suite) && ((nch == 1) || (nch >= 4))); - - if (res && (nch == 1)) - res = validate_simple_stmt(CHILD(tree, 0)); - else if (res) { - /* NEWLINE INDENT stmt+ DEDENT */ - res = (validate_newline(CHILD(tree, 0)) - && validate_indent(CHILD(tree, 1)) - && validate_stmt(CHILD(tree, 2)) - && validate_dedent(CHILD(tree, nch - 1))); - - if (res && (nch > 4)) { - int i = 3; - --nch; /* forget the DEDENT */ - for ( ; res && (i < nch); ++i) - res = validate_stmt(CHILD(tree, i)); - } - else if (nch < 4) - res = validate_numnodes(tree, 4, "suite"); - } - return (res); -} - - -static int -validate_testlist(node *tree) -{ - return (validate_repeating_list(tree, testlist, - validate_test, "testlist")); -} - - -static int -validate_testlist1(node *tree) -{ - return (validate_repeating_list(tree, testlist1, - validate_test, "testlist1")); -} - - -static int -validate_testlist_safe(node *tree) -{ - return (validate_repeating_list(tree, testlist_safe, - validate_test, "testlist_safe")); -} - - -/* '*' NAME [',' '**' NAME] | '**' NAME - */ -static int -validate_varargslist_trailer(node *tree, int start) -{ - int nch = NCH(tree); - int res = 0; - int sym; - - if (nch <= start) { - err_string("expected variable argument trailer for varargslist"); - return 0; - } - sym = TYPE(CHILD(tree, start)); - if (sym == STAR) { - /* - * ('*' NAME [',' '**' NAME] - */ - if (nch-start == 2) - res = validate_name(CHILD(tree, start+1), NULL); - else if (nch-start == 5) - res = (validate_name(CHILD(tree, start+1), NULL) - && validate_comma(CHILD(tree, start+2)) - && validate_doublestar(CHILD(tree, start+3)) - && validate_name(CHILD(tree, start+4), NULL)); - } - else if (sym == DOUBLESTAR) { - /* - * '**' NAME - */ - if (nch-start == 2) - res = validate_name(CHILD(tree, start+1), NULL); - } - if (!res) - err_string("illegal variable argument trailer for varargslist"); - return res; -} - - -/* validate_varargslist() - * - * varargslist: - * (fpdef ['=' test] ',')* - * ('*' NAME [',' '**' NAME] - * | '**' NAME) - * | fpdef ['=' test] (',' fpdef ['=' test])* [','] - * - */ -static int -validate_varargslist(node *tree) -{ - int nch = NCH(tree); - int res = validate_ntype(tree, varargslist) && (nch != 0); - int sym; - - if (!res) - return 0; - if (nch < 1) { - err_string("varargslist missing child nodes"); - return 0; - } - sym = TYPE(CHILD(tree, 0)); - if (sym == STAR || sym == DOUBLESTAR) - /* whole thing matches: - * '*' NAME [',' '**' NAME] | '**' NAME - */ - res = validate_varargslist_trailer(tree, 0); - else if (sym == fpdef) { - int i = 0; - - sym = TYPE(CHILD(tree, nch-1)); - if (sym == NAME) { - /* - * (fpdef ['=' test] ',')+ - * ('*' NAME [',' '**' NAME] - * | '**' NAME) - */ - /* skip over (fpdef ['=' test] ',')+ */ - while (res && (i+2 <= nch)) { - res = validate_fpdef(CHILD(tree, i)); - ++i; - if (res && TYPE(CHILD(tree, i)) == EQUAL && (i+2 <= nch)) { - res = (validate_equal(CHILD(tree, i)) - && validate_test(CHILD(tree, i+1))); - if (res) - i += 2; - } - if (res && i < nch) { - res = validate_comma(CHILD(tree, i)); - ++i; - if (res && i < nch - && (TYPE(CHILD(tree, i)) == DOUBLESTAR - || TYPE(CHILD(tree, i)) == STAR)) - break; - } - } - /* ... '*' NAME [',' '**' NAME] | '**' NAME - * i --^^^ - */ - if (res) - res = validate_varargslist_trailer(tree, i); - } - else { - /* - * fpdef ['=' test] (',' fpdef ['=' test])* [','] - */ - /* strip trailing comma node */ - if (sym == COMMA) { - res = validate_comma(CHILD(tree, nch-1)); - if (!res) - return 0; - --nch; - } - /* - * fpdef ['=' test] (',' fpdef ['=' test])* - */ - res = validate_fpdef(CHILD(tree, 0)); - ++i; - if (res && (i+2 <= nch) && TYPE(CHILD(tree, i)) == EQUAL) { - res = (validate_equal(CHILD(tree, i)) - && validate_test(CHILD(tree, i+1))); - i += 2; - } - /* - * ... (',' fpdef ['=' test])* - * i ---^^^ - */ - while (res && (nch - i) >= 2) { - res = (validate_comma(CHILD(tree, i)) - && validate_fpdef(CHILD(tree, i+1))); - i += 2; - if (res && (nch - i) >= 2 && TYPE(CHILD(tree, i)) == EQUAL) { - res = (validate_equal(CHILD(tree, i)) - && validate_test(CHILD(tree, i+1))); - i += 2; - } - } - if (res && nch - i != 0) { - res = 0; - err_string("illegal formation for varargslist"); - } - } - } - return res; -} - - -/* list_iter: list_for | list_if - */ -static int -validate_list_iter(node *tree) -{ - int res = (validate_ntype(tree, list_iter) - && validate_numnodes(tree, 1, "list_iter")); - if (res && TYPE(CHILD(tree, 0)) == list_for) - res = validate_list_for(CHILD(tree, 0)); - else - res = validate_list_if(CHILD(tree, 0)); - - return res; -} - -/* list_for: 'for' exprlist 'in' testlist [list_iter] - */ -static int -validate_list_for(node *tree) -{ - int nch = NCH(tree); - int res; - - if (nch == 5) - res = validate_list_iter(CHILD(tree, 4)); - else - res = validate_numnodes(tree, 4, "list_for"); - - if (res) - res = (validate_name(CHILD(tree, 0), "for") - && validate_exprlist(CHILD(tree, 1)) - && validate_name(CHILD(tree, 2), "in") - && validate_testlist_safe(CHILD(tree, 3))); - - return res; -} - -/* list_if: 'if' test [list_iter] - */ -static int -validate_list_if(node *tree) -{ - int nch = NCH(tree); - int res; - - if (nch == 3) - res = validate_list_iter(CHILD(tree, 2)); - else - res = validate_numnodes(tree, 2, "list_if"); - - if (res) - res = (validate_name(CHILD(tree, 0), "if") - && validate_test(CHILD(tree, 1))); - - return res; -} - - -/* validate_fpdef() - * - * fpdef: - * NAME - * | '(' fplist ')' - */ -static int -validate_fpdef(node *tree) -{ - int nch = NCH(tree); - int res = validate_ntype(tree, fpdef); - - if (res) { - if (nch == 1) - res = validate_ntype(CHILD(tree, 0), NAME); - else if (nch == 3) - res = (validate_lparen(CHILD(tree, 0)) - && validate_fplist(CHILD(tree, 1)) - && validate_rparen(CHILD(tree, 2))); - else - res = validate_numnodes(tree, 1, "fpdef"); - } - return (res); -} - - -static int -validate_fplist(node *tree) -{ - return (validate_repeating_list(tree, fplist, - validate_fpdef, "fplist")); -} - - -/* simple_stmt | compound_stmt - * - */ -static int -validate_stmt(node *tree) -{ - int res = (validate_ntype(tree, stmt) - && validate_numnodes(tree, 1, "stmt")); - - if (res) { - tree = CHILD(tree, 0); - - if (TYPE(tree) == simple_stmt) - res = validate_simple_stmt(tree); - else - res = validate_compound_stmt(tree); - } - return (res); -} - - -/* small_stmt (';' small_stmt)* [';'] NEWLINE - * - */ -static int -validate_simple_stmt(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, simple_stmt) - && (nch >= 2) - && validate_small_stmt(CHILD(tree, 0)) - && validate_newline(CHILD(tree, nch - 1))); - - if (nch < 2) - res = validate_numnodes(tree, 2, "simple_stmt"); - --nch; /* forget the NEWLINE */ - if (res && is_even(nch)) - res = validate_semi(CHILD(tree, --nch)); - if (res && (nch > 2)) { - int i; - - for (i = 1; res && (i < nch); i += 2) - res = (validate_semi(CHILD(tree, i)) - && validate_small_stmt(CHILD(tree, i + 1))); - } - return (res); -} - - -static int -validate_small_stmt(node *tree) -{ - int nch = NCH(tree); - int res = validate_numnodes(tree, 1, "small_stmt"); - - if (res) { - int ntype = TYPE(CHILD(tree, 0)); - - if ( (ntype == expr_stmt) - || (ntype == print_stmt) - || (ntype == del_stmt) - || (ntype == pass_stmt) - || (ntype == flow_stmt) - || (ntype == import_stmt) - || (ntype == global_stmt) - || (ntype == assert_stmt) - || (ntype == exec_stmt)) - res = validate_node(CHILD(tree, 0)); - else { - res = 0; - err_string("illegal small_stmt child type"); - } - } - else if (nch == 1) { - res = 0; - PyErr_Format(parser_error, - "Unrecognized child node of small_stmt: %d.", - TYPE(CHILD(tree, 0))); - } - return (res); -} - - -/* compound_stmt: - * if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef - */ -static int -validate_compound_stmt(node *tree) -{ - int res = (validate_ntype(tree, compound_stmt) - && validate_numnodes(tree, 1, "compound_stmt")); - int ntype; - - if (!res) - return (0); - - tree = CHILD(tree, 0); - ntype = TYPE(tree); - if ( (ntype == if_stmt) - || (ntype == while_stmt) - || (ntype == for_stmt) - || (ntype == try_stmt) - || (ntype == funcdef) - || (ntype == classdef)) - res = validate_node(tree); - else { - res = 0; - PyErr_Format(parser_error, - "Illegal compound statement type: %d.", TYPE(tree)); - } - return (res); -} - - -static int -validate_expr_stmt(node *tree) -{ - int j; - int nch = NCH(tree); - int res = (validate_ntype(tree, expr_stmt) - && is_odd(nch) - && validate_testlist(CHILD(tree, 0))); - - if (res && nch == 3 - && TYPE(CHILD(tree, 1)) == augassign) { - res = (validate_numnodes(CHILD(tree, 1), 1, "augassign") - && validate_testlist(CHILD(tree, 2))); - - if (res) { - char *s = STR(CHILD(CHILD(tree, 1), 0)); - - res = (strcmp(s, "+=") == 0 - || strcmp(s, "-=") == 0 - || strcmp(s, "*=") == 0 - || strcmp(s, "/=") == 0 - || strcmp(s, "//=") == 0 - || strcmp(s, "%=") == 0 - || strcmp(s, "&=") == 0 - || strcmp(s, "|=") == 0 - || strcmp(s, "^=") == 0 - || strcmp(s, "<<=") == 0 - || strcmp(s, ">>=") == 0 - || strcmp(s, "**=") == 0); - if (!res) - err_string("illegal augmmented assignment operator"); - } - } - else { - for (j = 1; res && (j < nch); j += 2) - res = (validate_equal(CHILD(tree, j)) - && validate_testlist(CHILD(tree, j + 1))); - } - return (res); -} - - -/* print_stmt: - * - * 'print' ( [ test (',' test)* [','] ] - * | '>>' test [ (',' test)+ [','] ] ) - */ -static int -validate_print_stmt(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, print_stmt) - && (nch > 0) - && validate_name(CHILD(tree, 0), "print")); - - if (res && nch > 1) { - int sym = TYPE(CHILD(tree, 1)); - int i = 1; - int allow_trailing_comma = 1; - - if (sym == test) - res = validate_test(CHILD(tree, i++)); - else { - if (nch < 3) - res = validate_numnodes(tree, 3, "print_stmt"); - else { - res = (validate_ntype(CHILD(tree, i), RIGHTSHIFT) - && validate_test(CHILD(tree, i+1))); - i += 2; - allow_trailing_comma = 0; - } - } - if (res) { - /* ... (',' test)* [','] */ - while (res && i+2 <= nch) { - res = (validate_comma(CHILD(tree, i)) - && validate_test(CHILD(tree, i+1))); - allow_trailing_comma = 1; - i += 2; - } - if (res && !allow_trailing_comma) - res = validate_numnodes(tree, i, "print_stmt"); - else if (res && i < nch) - res = validate_comma(CHILD(tree, i)); - } - } - return (res); -} - - -static int -validate_del_stmt(node *tree) -{ - return (validate_numnodes(tree, 2, "del_stmt") - && validate_name(CHILD(tree, 0), "del") - && validate_exprlist(CHILD(tree, 1))); -} - - -static int -validate_return_stmt(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, return_stmt) - && ((nch == 1) || (nch == 2)) - && validate_name(CHILD(tree, 0), "return")); - - if (res && (nch == 2)) - res = validate_testlist(CHILD(tree, 1)); - - return (res); -} - - -static int -validate_raise_stmt(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, raise_stmt) - && ((nch == 1) || (nch == 2) || (nch == 4) || (nch == 6))); - - if (res) { - res = validate_name(CHILD(tree, 0), "raise"); - if (res && (nch >= 2)) - res = validate_test(CHILD(tree, 1)); - if (res && nch > 2) { - res = (validate_comma(CHILD(tree, 2)) - && validate_test(CHILD(tree, 3))); - if (res && (nch > 4)) - res = (validate_comma(CHILD(tree, 4)) - && validate_test(CHILD(tree, 5))); - } - } - else - (void) validate_numnodes(tree, 2, "raise"); - if (res && (nch == 4)) - res = (validate_comma(CHILD(tree, 2)) - && validate_test(CHILD(tree, 3))); - - return (res); -} - - -/* yield_stmt: 'yield' testlist - */ -static int -validate_yield_stmt(node *tree) -{ - return (validate_ntype(tree, yield_stmt) - && validate_numnodes(tree, 2, "yield_stmt") - && validate_name(CHILD(tree, 0), "yield") - && validate_testlist(CHILD(tree, 1))); -} - - -static int -validate_import_as_name(node *tree) -{ - int nch = NCH(tree); - int ok = validate_ntype(tree, import_as_name); - - if (ok) { - if (nch == 1) - ok = validate_name(CHILD(tree, 0), NULL); - else if (nch == 3) - ok = (validate_name(CHILD(tree, 0), NULL) - && validate_name(CHILD(tree, 1), "as") - && validate_name(CHILD(tree, 2), NULL)); - else - ok = validate_numnodes(tree, 3, "import_as_name"); - } - return ok; -} - - -/* dotted_name: NAME ("." NAME)* - */ -static int -validate_dotted_name(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, dotted_name) - && is_odd(nch) - && validate_name(CHILD(tree, 0), NULL)); - int i; - - for (i = 1; res && (i < nch); i += 2) { - res = (validate_dot(CHILD(tree, i)) - && validate_name(CHILD(tree, i+1), NULL)); - } - return res; -} - - -/* dotted_as_name: dotted_name [NAME NAME] - */ -static int -validate_dotted_as_name(node *tree) -{ - int nch = NCH(tree); - int res = validate_ntype(tree, dotted_as_name); - - if (res) { - if (nch == 1) - res = validate_dotted_name(CHILD(tree, 0)); - else if (nch == 3) - res = (validate_dotted_name(CHILD(tree, 0)) - && validate_name(CHILD(tree, 1), "as") - && validate_name(CHILD(tree, 2), NULL)); - else { - res = 0; - err_string("illegal number of children for dotted_as_name"); - } - } - return res; -} - - -/* import_stmt: - * - * 'import' dotted_as_name (',' dotted_as_name)* - * | 'from' dotted_name 'import' ('*' | import_as_name (',' import_as_name)*) - */ -static int -validate_import_stmt(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, import_stmt) - && (nch >= 2) && is_even(nch) - && validate_ntype(CHILD(tree, 0), NAME)); - - if (res && (strcmp(STR(CHILD(tree, 0)), "import") == 0)) { - int j; - - res = validate_dotted_as_name(CHILD(tree, 1)); - for (j = 2; res && (j < nch); j += 2) - res = (validate_comma(CHILD(tree, j)) - && validate_dotted_as_name(CHILD(tree, j + 1))); - } - else if (res && (res = validate_name(CHILD(tree, 0), "from"))) { - res = ((nch >= 4) && is_even(nch) - && validate_dotted_name(CHILD(tree, 1)) - && validate_name(CHILD(tree, 2), "import")); - if (nch == 4) { - if (TYPE(CHILD(tree, 3)) == import_as_name) - res = validate_import_as_name(CHILD(tree, 3)); - else - res = validate_star(CHILD(tree, 3)); - } - else { - /* 'from' dotted_name 'import' import_as_name - * (',' import_as_name)+ - */ - int j; - res = validate_import_as_name(CHILD(tree, 3)); - for (j = 4; res && (j < nch); j += 2) - res = (validate_comma(CHILD(tree, j)) - && validate_import_as_name(CHILD(tree, j + 1))); - } - } - else - res = 0; - - return (res); -} - - -static int -validate_global_stmt(node *tree) -{ - int j; - int nch = NCH(tree); - int res = (validate_ntype(tree, global_stmt) - && is_even(nch) && (nch >= 2)); - - if (!res && !PyErr_Occurred()) - err_string("illegal global statement"); - - if (res) - res = (validate_name(CHILD(tree, 0), "global") - && validate_ntype(CHILD(tree, 1), NAME)); - for (j = 2; res && (j < nch); j += 2) - res = (validate_comma(CHILD(tree, j)) - && validate_ntype(CHILD(tree, j + 1), NAME)); - - return (res); -} - - -/* exec_stmt: - * - * 'exec' expr ['in' test [',' test]] - */ -static int -validate_exec_stmt(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, exec_stmt) - && ((nch == 2) || (nch == 4) || (nch == 6)) - && validate_name(CHILD(tree, 0), "exec") - && validate_expr(CHILD(tree, 1))); - - if (!res && !PyErr_Occurred()) - err_string("illegal exec statement"); - if (res && (nch > 2)) - res = (validate_name(CHILD(tree, 2), "in") - && validate_test(CHILD(tree, 3))); - if (res && (nch == 6)) - res = (validate_comma(CHILD(tree, 4)) - && validate_test(CHILD(tree, 5))); - - return (res); -} - - -/* assert_stmt: - * - * 'assert' test [',' test] - */ -static int -validate_assert_stmt(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, assert_stmt) - && ((nch == 2) || (nch == 4)) - && (validate_name(CHILD(tree, 0), "assert")) - && validate_test(CHILD(tree, 1))); - - if (!res && !PyErr_Occurred()) - err_string("illegal assert statement"); - if (res && (nch > 2)) - res = (validate_comma(CHILD(tree, 2)) - && validate_test(CHILD(tree, 3))); - - return (res); -} - - -static int -validate_while(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, while_stmt) - && ((nch == 4) || (nch == 7)) - && validate_name(CHILD(tree, 0), "while") - && validate_test(CHILD(tree, 1)) - && validate_colon(CHILD(tree, 2)) - && validate_suite(CHILD(tree, 3))); - - if (res && (nch == 7)) - res = (validate_name(CHILD(tree, 4), "else") - && validate_colon(CHILD(tree, 5)) - && validate_suite(CHILD(tree, 6))); - - return (res); -} - - -static int -validate_for(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, for_stmt) - && ((nch == 6) || (nch == 9)) - && validate_name(CHILD(tree, 0), "for") - && validate_exprlist(CHILD(tree, 1)) - && validate_name(CHILD(tree, 2), "in") - && validate_testlist(CHILD(tree, 3)) - && validate_colon(CHILD(tree, 4)) - && validate_suite(CHILD(tree, 5))); - - if (res && (nch == 9)) - res = (validate_name(CHILD(tree, 6), "else") - && validate_colon(CHILD(tree, 7)) - && validate_suite(CHILD(tree, 8))); - - return (res); -} - - -/* try_stmt: - * 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite] - * | 'try' ':' suite 'finally' ':' suite - * - */ -static int -validate_try(node *tree) -{ - int nch = NCH(tree); - int pos = 3; - int res = (validate_ntype(tree, try_stmt) - && (nch >= 6) && ((nch % 3) == 0)); - - if (res) - res = (validate_name(CHILD(tree, 0), "try") - && validate_colon(CHILD(tree, 1)) - && validate_suite(CHILD(tree, 2)) - && validate_colon(CHILD(tree, nch - 2)) - && validate_suite(CHILD(tree, nch - 1))); - else if (!PyErr_Occurred()) { - const char* name = "except"; - if (TYPE(CHILD(tree, nch - 3)) != except_clause) - name = STR(CHILD(tree, nch - 3)); - - PyErr_Format(parser_error, - "Illegal number of children for try/%s node.", name); - } - /* Skip past except_clause sections: */ - while (res && (TYPE(CHILD(tree, pos)) == except_clause)) { - res = (validate_except_clause(CHILD(tree, pos)) - && validate_colon(CHILD(tree, pos + 1)) - && validate_suite(CHILD(tree, pos + 2))); - pos += 3; - } - if (res && (pos < nch)) { - res = validate_ntype(CHILD(tree, pos), NAME); - if (res && (strcmp(STR(CHILD(tree, pos)), "finally") == 0)) - res = (validate_numnodes(tree, 6, "try/finally") - && validate_colon(CHILD(tree, 4)) - && validate_suite(CHILD(tree, 5))); - else if (res) { - if (nch == (pos + 3)) { - res = ((strcmp(STR(CHILD(tree, pos)), "except") == 0) - || (strcmp(STR(CHILD(tree, pos)), "else") == 0)); - if (!res) - err_string("illegal trailing triple in try statement"); - } - else if (nch == (pos + 6)) { - res = (validate_name(CHILD(tree, pos), "except") - && validate_colon(CHILD(tree, pos + 1)) - && validate_suite(CHILD(tree, pos + 2)) - && validate_name(CHILD(tree, pos + 3), "else")); - } - else - res = validate_numnodes(tree, pos + 3, "try/except"); - } - } - return (res); -} - - -static int -validate_except_clause(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, except_clause) - && ((nch == 1) || (nch == 2) || (nch == 4)) - && validate_name(CHILD(tree, 0), "except")); - - if (res && (nch > 1)) - res = validate_test(CHILD(tree, 1)); - if (res && (nch == 4)) - res = (validate_comma(CHILD(tree, 2)) - && validate_test(CHILD(tree, 3))); - - return (res); -} - - -static int -validate_test(node *tree) -{ - int nch = NCH(tree); - int res = validate_ntype(tree, test) && is_odd(nch); - - if (res && (TYPE(CHILD(tree, 0)) == lambdef)) - res = ((nch == 1) - && validate_lambdef(CHILD(tree, 0))); - else if (res) { - int pos; - res = validate_and_test(CHILD(tree, 0)); - for (pos = 1; res && (pos < nch); pos += 2) - res = (validate_name(CHILD(tree, pos), "or") - && validate_and_test(CHILD(tree, pos + 1))); - } - return (res); -} - - -static int -validate_and_test(node *tree) -{ - int pos; - int nch = NCH(tree); - int res = (validate_ntype(tree, and_test) - && is_odd(nch) - && validate_not_test(CHILD(tree, 0))); - - for (pos = 1; res && (pos < nch); pos += 2) - res = (validate_name(CHILD(tree, pos), "and") - && validate_not_test(CHILD(tree, 0))); - - return (res); -} - - -static int -validate_not_test(node *tree) -{ - int nch = NCH(tree); - int res = validate_ntype(tree, not_test) && ((nch == 1) || (nch == 2)); - - if (res) { - if (nch == 2) - res = (validate_name(CHILD(tree, 0), "not") - && validate_not_test(CHILD(tree, 1))); - else if (nch == 1) - res = validate_comparison(CHILD(tree, 0)); - } - return (res); -} - - -static int -validate_comparison(node *tree) -{ - int pos; - int nch = NCH(tree); - int res = (validate_ntype(tree, comparison) - && is_odd(nch) - && validate_expr(CHILD(tree, 0))); - - for (pos = 1; res && (pos < nch); pos += 2) - res = (validate_comp_op(CHILD(tree, pos)) - && validate_expr(CHILD(tree, pos + 1))); - - return (res); -} - - -static int -validate_comp_op(node *tree) -{ - int res = 0; - int nch = NCH(tree); - - if (!validate_ntype(tree, comp_op)) - return (0); - if (nch == 1) { - /* - * Only child will be a terminal with a well-defined symbolic name - * or a NAME with a string of either 'is' or 'in' - */ - tree = CHILD(tree, 0); - switch (TYPE(tree)) { - case LESS: - case GREATER: - case EQEQUAL: - case EQUAL: - case LESSEQUAL: - case GREATEREQUAL: - case NOTEQUAL: - res = 1; - break; - case NAME: - res = ((strcmp(STR(tree), "in") == 0) - || (strcmp(STR(tree), "is") == 0)); - if (!res) { - PyErr_Format(parser_error, - "illegal operator '%s'", STR(tree)); - } - break; - default: - err_string("illegal comparison operator type"); - break; - } - } - else if ((res = validate_numnodes(tree, 2, "comp_op")) != 0) { - res = (validate_ntype(CHILD(tree, 0), NAME) - && validate_ntype(CHILD(tree, 1), NAME) - && (((strcmp(STR(CHILD(tree, 0)), "is") == 0) - && (strcmp(STR(CHILD(tree, 1)), "not") == 0)) - || ((strcmp(STR(CHILD(tree, 0)), "not") == 0) - && (strcmp(STR(CHILD(tree, 1)), "in") == 0)))); - if (!res && !PyErr_Occurred()) - err_string("unknown comparison operator"); - } - return (res); -} - - -static int -validate_expr(node *tree) -{ - int j; - int nch = NCH(tree); - int res = (validate_ntype(tree, expr) - && is_odd(nch) - && validate_xor_expr(CHILD(tree, 0))); - - for (j = 2; res && (j < nch); j += 2) - res = (validate_xor_expr(CHILD(tree, j)) - && validate_vbar(CHILD(tree, j - 1))); - - return (res); -} - - -static int -validate_xor_expr(node *tree) -{ - int j; - int nch = NCH(tree); - int res = (validate_ntype(tree, xor_expr) - && is_odd(nch) - && validate_and_expr(CHILD(tree, 0))); - - for (j = 2; res && (j < nch); j += 2) - res = (validate_circumflex(CHILD(tree, j - 1)) - && validate_and_expr(CHILD(tree, j))); - - return (res); -} - - -static int -validate_and_expr(node *tree) -{ - int pos; - int nch = NCH(tree); - int res = (validate_ntype(tree, and_expr) - && is_odd(nch) - && validate_shift_expr(CHILD(tree, 0))); - - for (pos = 1; res && (pos < nch); pos += 2) - res = (validate_ampersand(CHILD(tree, pos)) - && validate_shift_expr(CHILD(tree, pos + 1))); - - return (res); -} - - -static int -validate_chain_two_ops(node *tree, int (*termvalid)(node *), int op1, int op2) - { - int pos = 1; - int nch = NCH(tree); - int res = (is_odd(nch) - && (*termvalid)(CHILD(tree, 0))); - - for ( ; res && (pos < nch); pos += 2) { - if (TYPE(CHILD(tree, pos)) != op1) - res = validate_ntype(CHILD(tree, pos), op2); - if (res) - res = (*termvalid)(CHILD(tree, pos + 1)); - } - return (res); -} - - -static int -validate_shift_expr(node *tree) -{ - return (validate_ntype(tree, shift_expr) - && validate_chain_two_ops(tree, validate_arith_expr, - LEFTSHIFT, RIGHTSHIFT)); -} - - -static int -validate_arith_expr(node *tree) -{ - return (validate_ntype(tree, arith_expr) - && validate_chain_two_ops(tree, validate_term, PLUS, MINUS)); -} - - -static int -validate_term(node *tree) -{ - int pos = 1; - int nch = NCH(tree); - int res = (validate_ntype(tree, term) - && is_odd(nch) - && validate_factor(CHILD(tree, 0))); - - for ( ; res && (pos < nch); pos += 2) - res = (((TYPE(CHILD(tree, pos)) == STAR) - || (TYPE(CHILD(tree, pos)) == SLASH) - || (TYPE(CHILD(tree, pos)) == DOUBLESLASH) - || (TYPE(CHILD(tree, pos)) == PERCENT)) - && validate_factor(CHILD(tree, pos + 1))); - - return (res); -} - - -/* factor: - * - * factor: ('+'|'-'|'~') factor | power - */ -static int -validate_factor(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, factor) - && (((nch == 2) - && ((TYPE(CHILD(tree, 0)) == PLUS) - || (TYPE(CHILD(tree, 0)) == MINUS) - || (TYPE(CHILD(tree, 0)) == TILDE)) - && validate_factor(CHILD(tree, 1))) - || ((nch == 1) - && validate_power(CHILD(tree, 0))))); - return (res); -} - - -/* power: - * - * power: atom trailer* ('**' factor)* - */ -static int -validate_power(node *tree) -{ - int pos = 1; - int nch = NCH(tree); - int res = (validate_ntype(tree, power) && (nch >= 1) - && validate_atom(CHILD(tree, 0))); - - while (res && (pos < nch) && (TYPE(CHILD(tree, pos)) == trailer)) - res = validate_trailer(CHILD(tree, pos++)); - if (res && (pos < nch)) { - if (!is_even(nch - pos)) { - err_string("illegal number of nodes for 'power'"); - return (0); - } - for ( ; res && (pos < (nch - 1)); pos += 2) - res = (validate_doublestar(CHILD(tree, pos)) - && validate_factor(CHILD(tree, pos + 1))); - } - return (res); -} - - -static int -validate_atom(node *tree) -{ - int pos; - int nch = NCH(tree); - int res = validate_ntype(tree, atom); - - if (res && nch < 1) - res = validate_numnodes(tree, nch+1, "atom"); - if (res) { - switch (TYPE(CHILD(tree, 0))) { - case LPAR: - res = ((nch <= 3) - && (validate_rparen(CHILD(tree, nch - 1)))); - - if (res && (nch == 3)) - res = validate_testlist(CHILD(tree, 1)); - break; - case LSQB: - if (nch == 2) - res = validate_ntype(CHILD(tree, 1), RSQB); - else if (nch == 3) - res = (validate_listmaker(CHILD(tree, 1)) - && validate_ntype(CHILD(tree, 2), RSQB)); - else { - res = 0; - err_string("illegal list display atom"); - } - break; - case LBRACE: - res = ((nch <= 3) - && validate_ntype(CHILD(tree, nch - 1), RBRACE)); - - if (res && (nch == 3)) - res = validate_dictmaker(CHILD(tree, 1)); - break; - case BACKQUOTE: - res = ((nch == 3) - && validate_testlist1(CHILD(tree, 1)) - && validate_ntype(CHILD(tree, 2), BACKQUOTE)); - break; - case NAME: - case NUMBER: - res = (nch == 1); - break; - case STRING: - for (pos = 1; res && (pos < nch); ++pos) - res = validate_ntype(CHILD(tree, pos), STRING); - break; - default: - res = 0; - break; - } - } - return (res); -} - - -/* listmaker: - * test ( list_for | (',' test)* [','] ) - */ -static int -validate_listmaker(node *tree) -{ - int nch = NCH(tree); - int ok = nch; - - if (nch == 0) - err_string("missing child nodes of listmaker"); - else - ok = validate_test(CHILD(tree, 0)); - - /* - * list_iter | (',' test)* [','] - */ - if (nch == 2 && TYPE(CHILD(tree, 1)) == list_for) - ok = validate_list_for(CHILD(tree, 1)); - else { - /* (',' test)* [','] */ - int i = 1; - while (ok && nch - i >= 2) { - ok = (validate_comma(CHILD(tree, i)) - && validate_test(CHILD(tree, i+1))); - i += 2; - } - if (ok && i == nch-1) - ok = validate_comma(CHILD(tree, i)); - else if (i != nch) { - ok = 0; - err_string("illegal trailing nodes for listmaker"); - } - } - return ok; -} - - -/* funcdef: - * 'def' NAME parameters ':' suite - * - */ -static int -validate_funcdef(node *tree) -{ - return (validate_ntype(tree, funcdef) - && validate_numnodes(tree, 5, "funcdef") - && validate_name(CHILD(tree, 0), "def") - && validate_ntype(CHILD(tree, 1), NAME) - && validate_colon(CHILD(tree, 3)) - && validate_parameters(CHILD(tree, 2)) - && validate_suite(CHILD(tree, 4))); -} - - -static int -validate_lambdef(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, lambdef) - && ((nch == 3) || (nch == 4)) - && validate_name(CHILD(tree, 0), "lambda") - && validate_colon(CHILD(tree, nch - 2)) - && validate_test(CHILD(tree, nch - 1))); - - if (res && (nch == 4)) - res = validate_varargslist(CHILD(tree, 1)); - else if (!res && !PyErr_Occurred()) - (void) validate_numnodes(tree, 3, "lambdef"); - - return (res); -} - - -/* arglist: - * - * (argument ',')* (argument [','] | '*' test [',' '**' test] | '**' test) - */ -static int -validate_arglist(node *tree) -{ - int nch = NCH(tree); - int i = 0; - int ok = 1; - - if (nch <= 0) - /* raise the right error from having an invalid number of children */ - return validate_numnodes(tree, nch + 1, "arglist"); - - while (ok && nch-i >= 2) { - /* skip leading (argument ',') */ - ok = (validate_argument(CHILD(tree, i)) - && validate_comma(CHILD(tree, i+1))); - if (ok) - i += 2; - else - PyErr_Clear(); - } - ok = 1; - if (nch-i > 0) { - /* - * argument | '*' test [',' '**' test] | '**' test - */ - int sym = TYPE(CHILD(tree, i)); - - if (sym == argument) { - ok = validate_argument(CHILD(tree, i)); - if (ok && i+1 != nch) { - err_string("illegal arglist specification" - " (extra stuff on end)"); - ok = 0; - } - } - else if (sym == STAR) { - ok = validate_star(CHILD(tree, i)); - if (ok && (nch-i == 2)) - ok = validate_test(CHILD(tree, i+1)); - else if (ok && (nch-i == 5)) - ok = (validate_test(CHILD(tree, i+1)) - && validate_comma(CHILD(tree, i+2)) - && validate_doublestar(CHILD(tree, i+3)) - && validate_test(CHILD(tree, i+4))); - else { - err_string("illegal use of '*' in arglist"); - ok = 0; - } - } - else if (sym == DOUBLESTAR) { - if (nch-i == 2) - ok = (validate_doublestar(CHILD(tree, i)) - && validate_test(CHILD(tree, i+1))); - else { - err_string("illegal use of '**' in arglist"); - ok = 0; - } - } - else { - err_string("illegal arglist specification"); - ok = 0; - } - } - return (ok); -} - - - -/* argument: - * - * [test '='] test - */ -static int -validate_argument(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, argument) - && ((nch == 1) || (nch == 3)) - && validate_test(CHILD(tree, 0))); - - if (res && (nch == 3)) - res = (validate_equal(CHILD(tree, 1)) - && validate_test(CHILD(tree, 2))); - - return (res); -} - - - -/* trailer: - * - * '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME - */ -static int -validate_trailer(node *tree) -{ - int nch = NCH(tree); - int res = validate_ntype(tree, trailer) && ((nch == 2) || (nch == 3)); - - if (res) { - switch (TYPE(CHILD(tree, 0))) { - case LPAR: - res = validate_rparen(CHILD(tree, nch - 1)); - if (res && (nch == 3)) - res = validate_arglist(CHILD(tree, 1)); - break; - case LSQB: - res = (validate_numnodes(tree, 3, "trailer") - && validate_subscriptlist(CHILD(tree, 1)) - && validate_ntype(CHILD(tree, 2), RSQB)); - break; - case DOT: - res = (validate_numnodes(tree, 2, "trailer") - && validate_ntype(CHILD(tree, 1), NAME)); - break; - default: - res = 0; - break; - } - } - else { - (void) validate_numnodes(tree, 2, "trailer"); - } - return (res); -} - - -/* subscriptlist: - * - * subscript (',' subscript)* [','] - */ -static int -validate_subscriptlist(node *tree) -{ - return (validate_repeating_list(tree, subscriptlist, - validate_subscript, "subscriptlist")); -} - - -/* subscript: - * - * '.' '.' '.' | test | [test] ':' [test] [sliceop] - */ -static int -validate_subscript(node *tree) -{ - int offset = 0; - int nch = NCH(tree); - int res = validate_ntype(tree, subscript) && (nch >= 1) && (nch <= 4); - - if (!res) { - if (!PyErr_Occurred()) - err_string("invalid number of arguments for subscript node"); - return (0); - } - if (TYPE(CHILD(tree, 0)) == DOT) - /* take care of ('.' '.' '.') possibility */ - return (validate_numnodes(tree, 3, "subscript") - && validate_dot(CHILD(tree, 0)) - && validate_dot(CHILD(tree, 1)) - && validate_dot(CHILD(tree, 2))); - if (nch == 1) { - if (TYPE(CHILD(tree, 0)) == test) - res = validate_test(CHILD(tree, 0)); - else - res = validate_colon(CHILD(tree, 0)); - return (res); - } - /* Must be [test] ':' [test] [sliceop], - * but at least one of the optional components will - * be present, but we don't know which yet. - */ - if ((TYPE(CHILD(tree, 0)) != COLON) || (nch == 4)) { - res = validate_test(CHILD(tree, 0)); - offset = 1; - } - if (res) - res = validate_colon(CHILD(tree, offset)); - if (res) { - int rem = nch - ++offset; - if (rem) { - if (TYPE(CHILD(tree, offset)) == test) { - res = validate_test(CHILD(tree, offset)); - ++offset; - --rem; - } - if (res && rem) - res = validate_sliceop(CHILD(tree, offset)); - } - } - return (res); -} - - -static int -validate_sliceop(node *tree) -{ - int nch = NCH(tree); - int res = ((nch == 1) || validate_numnodes(tree, 2, "sliceop")) - && validate_ntype(tree, sliceop); - if (!res && !PyErr_Occurred()) { - res = validate_numnodes(tree, 1, "sliceop"); - } - if (res) - res = validate_colon(CHILD(tree, 0)); - if (res && (nch == 2)) - res = validate_test(CHILD(tree, 1)); - - return (res); -} - - -static int -validate_exprlist(node *tree) -{ - return (validate_repeating_list(tree, exprlist, - validate_expr, "exprlist")); -} - - -static int -validate_dictmaker(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, dictmaker) - && (nch >= 3) - && validate_test(CHILD(tree, 0)) - && validate_colon(CHILD(tree, 1)) - && validate_test(CHILD(tree, 2))); - - if (res && ((nch % 4) == 0)) - res = validate_comma(CHILD(tree, --nch)); - else if (res) - res = ((nch % 4) == 3); - - if (res && (nch > 3)) { - int pos = 3; - /* ( ',' test ':' test )* */ - while (res && (pos < nch)) { - res = (validate_comma(CHILD(tree, pos)) - && validate_test(CHILD(tree, pos + 1)) - && validate_colon(CHILD(tree, pos + 2)) - && validate_test(CHILD(tree, pos + 3))); - pos += 4; - } - } - return (res); -} - - -static int -validate_eval_input(node *tree) -{ - int pos; - int nch = NCH(tree); - int res = (validate_ntype(tree, eval_input) - && (nch >= 2) - && validate_testlist(CHILD(tree, 0)) - && validate_ntype(CHILD(tree, nch - 1), ENDMARKER)); - - for (pos = 1; res && (pos < (nch - 1)); ++pos) - res = validate_ntype(CHILD(tree, pos), NEWLINE); - - return (res); -} - - -static int -validate_node(node *tree) -{ - int nch = 0; /* num. children on current node */ - int res = 1; /* result value */ - node* next = 0; /* node to process after this one */ - - while (res && (tree != 0)) { - nch = NCH(tree); - next = 0; - switch (TYPE(tree)) { - /* - * Definition nodes. - */ - case funcdef: - res = validate_funcdef(tree); - break; - case classdef: - res = validate_class(tree); - break; - /* - * "Trivial" parse tree nodes. - * (Why did I call these trivial?) - */ - case stmt: - res = validate_stmt(tree); - break; - case small_stmt: - /* - * expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt - * | import_stmt | global_stmt | exec_stmt | assert_stmt - */ - res = validate_small_stmt(tree); - break; - case flow_stmt: - res = (validate_numnodes(tree, 1, "flow_stmt") - && ((TYPE(CHILD(tree, 0)) == break_stmt) - || (TYPE(CHILD(tree, 0)) == continue_stmt) - || (TYPE(CHILD(tree, 0)) == yield_stmt) - || (TYPE(CHILD(tree, 0)) == return_stmt) - || (TYPE(CHILD(tree, 0)) == raise_stmt))); - if (res) - next = CHILD(tree, 0); - else if (nch == 1) - err_string("illegal flow_stmt type"); - break; - case yield_stmt: - res = validate_yield_stmt(tree); - break; - /* - * Compound statements. - */ - case simple_stmt: - res = validate_simple_stmt(tree); - break; - case compound_stmt: - res = validate_compound_stmt(tree); - break; - /* - * Fundamental statements. - */ - case expr_stmt: - res = validate_expr_stmt(tree); - break; - case print_stmt: - res = validate_print_stmt(tree); - break; - case del_stmt: - res = validate_del_stmt(tree); - break; - case pass_stmt: - res = (validate_numnodes(tree, 1, "pass") - && validate_name(CHILD(tree, 0), "pass")); - break; - case break_stmt: - res = (validate_numnodes(tree, 1, "break") - && validate_name(CHILD(tree, 0), "break")); - break; - case continue_stmt: - res = (validate_numnodes(tree, 1, "continue") - && validate_name(CHILD(tree, 0), "continue")); - break; - case return_stmt: - res = validate_return_stmt(tree); - break; - case raise_stmt: - res = validate_raise_stmt(tree); - break; - case import_stmt: - res = validate_import_stmt(tree); - break; - case global_stmt: - res = validate_global_stmt(tree); - break; - case exec_stmt: - res = validate_exec_stmt(tree); - break; - case assert_stmt: - res = validate_assert_stmt(tree); - break; - case if_stmt: - res = validate_if(tree); - break; - case while_stmt: - res = validate_while(tree); - break; - case for_stmt: - res = validate_for(tree); - break; - case try_stmt: - res = validate_try(tree); - break; - case suite: - res = validate_suite(tree); - break; - /* - * Expression nodes. - */ - case testlist: - res = validate_testlist(tree); - break; - case testlist1: - res = validate_testlist1(tree); - break; - case test: - res = validate_test(tree); - break; - case and_test: - res = validate_and_test(tree); - break; - case not_test: - res = validate_not_test(tree); - break; - case comparison: - res = validate_comparison(tree); - break; - case exprlist: - res = validate_exprlist(tree); - break; - case comp_op: - res = validate_comp_op(tree); - break; - case expr: - res = validate_expr(tree); - break; - case xor_expr: - res = validate_xor_expr(tree); - break; - case and_expr: - res = validate_and_expr(tree); - break; - case shift_expr: - res = validate_shift_expr(tree); - break; - case arith_expr: - res = validate_arith_expr(tree); - break; - case term: - res = validate_term(tree); - break; - case factor: - res = validate_factor(tree); - break; - case power: - res = validate_power(tree); - break; - case atom: - res = validate_atom(tree); - break; - - default: - /* Hopefully never reached! */ - err_string("unrecognized node type"); - res = 0; - break; - } - tree = next; - } - return (res); -} - - -static int -validate_expr_tree(node *tree) -{ - int res = validate_eval_input(tree); - - if (!res && !PyErr_Occurred()) - err_string("could not validate expression tuple"); - - return (res); -} - - -/* file_input: - * (NEWLINE | stmt)* ENDMARKER - */ -static int -validate_file_input(node *tree) -{ - int j; - int nch = NCH(tree) - 1; - int res = ((nch >= 0) - && validate_ntype(CHILD(tree, nch), ENDMARKER)); - - for (j = 0; res && (j < nch); ++j) { - if (TYPE(CHILD(tree, j)) == stmt) - res = validate_stmt(CHILD(tree, j)); - else - res = validate_newline(CHILD(tree, j)); - } - /* This stays in to prevent any internal failures from getting to the - * user. Hopefully, this won't be needed. If a user reports getting - * this, we have some debugging to do. - */ - if (!res && !PyErr_Occurred()) - err_string("VALIDATION FAILURE: report this to the maintainer!"); - - return (res); -} - -static int -validate_encoding_decl(node *tree) -{ - int nch = NCH(tree); - int res = ((nch == 1) - && validate_file_input(CHILD(tree, 0))); - - if (!res && !PyErr_Occurred()) - err_string("Error Parsing encoding_decl"); - - return res; -} - -static PyObject* -pickle_constructor = NULL; - - -static PyObject* -parser__pickler(PyObject *self, PyObject *args) -{ - NOTE(ARGUNUSED(self)) - PyObject *result = NULL; - PyObject *st = NULL; - PyObject *empty_dict = NULL; - - if (PyArg_ParseTuple(args, "O!:_pickler", &PyST_Type, &st)) { - PyObject *newargs; - PyObject *tuple; - - if ((empty_dict = PyDict_New()) == NULL) - goto finally; - if ((newargs = Py_BuildValue("Oi", st, 1)) == NULL) - goto finally; - tuple = parser_st2tuple((PyST_Object*)NULL, newargs, empty_dict); - if (tuple != NULL) { - result = Py_BuildValue("O(O)", pickle_constructor, tuple); - Py_DECREF(tuple); - } - Py_DECREF(empty_dict); - Py_DECREF(newargs); - } - finally: - Py_XDECREF(empty_dict); - - return (result); -} - - -/* Functions exported by this module. Most of this should probably - * be converted into an ST object with methods, but that is better - * done directly in Python, allowing subclasses to be created directly. - * We'd really have to write a wrapper around it all anyway to allow - * inheritance. - */ -static PyMethodDef parser_functions[] = { - {"ast2tuple", (PyCFunction)parser_st2tuple, PUBLIC_METHOD_TYPE, - PyDoc_STR("Creates a tuple-tree representation of an ST.")}, - {"ast2list", (PyCFunction)parser_st2list, PUBLIC_METHOD_TYPE, - PyDoc_STR("Creates a list-tree representation of an ST.")}, - {"compileast", (PyCFunction)parser_compilest, PUBLIC_METHOD_TYPE, - PyDoc_STR("Compiles an ST object into a code object.")}, - {"compilest", (PyCFunction)parser_compilest, PUBLIC_METHOD_TYPE, - PyDoc_STR("Compiles an ST object into a code object.")}, - {"expr", (PyCFunction)parser_expr, PUBLIC_METHOD_TYPE, - PyDoc_STR("Creates an ST object from an expression.")}, - {"isexpr", (PyCFunction)parser_isexpr, PUBLIC_METHOD_TYPE, - PyDoc_STR("Determines if an ST object was created from an expression.")}, - {"issuite", (PyCFunction)parser_issuite, PUBLIC_METHOD_TYPE, - PyDoc_STR("Determines if an ST object was created from a suite.")}, - {"suite", (PyCFunction)parser_suite, PUBLIC_METHOD_TYPE, - PyDoc_STR("Creates an ST object from a suite.")}, - {"sequence2ast", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE, - PyDoc_STR("Creates an ST object from a tree representation.")}, - {"sequence2st", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE, - PyDoc_STR("Creates an ST object from a tree representation.")}, - {"st2tuple", (PyCFunction)parser_st2tuple, PUBLIC_METHOD_TYPE, - PyDoc_STR("Creates a tuple-tree representation of an ST.")}, - {"st2list", (PyCFunction)parser_st2list, PUBLIC_METHOD_TYPE, - PyDoc_STR("Creates a list-tree representation of an ST.")}, - {"tuple2ast", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE, - PyDoc_STR("Creates an ST object from a tree representation.")}, - {"tuple2st", (PyCFunction)parser_tuple2st, PUBLIC_METHOD_TYPE, - PyDoc_STR("Creates an ST object from a tree representation.")}, - - /* private stuff: support pickle module */ - {"_pickler", (PyCFunction)parser__pickler, METH_VARARGS, - PyDoc_STR("Returns the pickle magic to allow ST objects to be pickled.")}, - - {NULL, NULL, 0, NULL} - }; - - -PyMODINIT_FUNC initparser(void); /* supply a prototype */ - -PyMODINIT_FUNC -initparser(void) -{ - PyObject *module, *copyreg; - - PyST_Type.ob_type = &PyType_Type; - module = Py_InitModule("parser", parser_functions); - - if (parser_error == 0) - parser_error = PyErr_NewException("parser.ParserError", NULL, NULL); - - if (parser_error == 0) - /* caller will check PyErr_Occurred() */ - return; - /* CAUTION: The code next used to skip bumping the refcount on - * parser_error. That's a disaster if initparser() gets called more - * than once. By incref'ing, we ensure that each module dict that - * gets created owns its reference to the shared parser_error object, - * and the file static parser_error vrbl owns a reference too. - */ - Py_INCREF(parser_error); - if (PyModule_AddObject(module, "ParserError", parser_error) != 0) - return; - - Py_INCREF(&PyST_Type); - PyModule_AddObject(module, "ASTType", (PyObject*)&PyST_Type); - Py_INCREF(&PyST_Type); - PyModule_AddObject(module, "STType", (PyObject*)&PyST_Type); - - PyModule_AddStringConstant(module, "__copyright__", - parser_copyright_string); - PyModule_AddStringConstant(module, "__doc__", - parser_doc_string); - PyModule_AddStringConstant(module, "__version__", - parser_version_string); - - /* Register to support pickling. - * If this fails, the import of this module will fail because an - * exception will be raised here; should we clear the exception? - */ - copyreg = PyImport_ImportModule("copy_reg"); - if (copyreg != NULL) { - PyObject *func, *pickler; - - func = PyObject_GetAttrString(copyreg, "pickle"); - pickle_constructor = PyObject_GetAttrString(module, "sequence2st"); - pickler = PyObject_GetAttrString(module, "_pickler"); - Py_XINCREF(pickle_constructor); - if ((func != NULL) && (pickle_constructor != NULL) - && (pickler != NULL)) { - PyObject *res; - - res = PyObject_CallFunction(func, "OOO", &PyST_Type, pickler, - pickle_constructor); - Py_XDECREF(res); - } - Py_XDECREF(func); - Py_XDECREF(pickle_constructor); - Py_XDECREF(pickler); - Py_DECREF(copyreg); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/pcre-int.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/pcre-int.h deleted file mode 100644 index f6f7e0f8..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/pcre-int.h +++ /dev/null @@ -1,303 +0,0 @@ -/************************************************* -* Perl-Compatible Regular Expressions * -*************************************************/ - - -#define PCRE_VERSION "1.09 28-Apr-1998" - - -/* This is a library of functions to support regular expressions whose syntax -and semantics are as close as possible to those of the Perl 5 language. See -the file Tech.Notes for some information on the internals. - -Written by: Philip Hazel - - Copyright (c) 1998 University of Cambridge - ------------------------------------------------------------------------------ -Permission is granted to anyone to use this software for any purpose on any -computer system, and to redistribute it freely, subject to the following -restrictions: - -1. This software 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. - -2. The origin of this software must not be misrepresented, either by - explicit claim or by omission. - -3. Altered versions must be plainly marked as such, and must not be - misrepresented as being the original software. ------------------------------------------------------------------------------ -*/ - -/* This header contains definitions that are shared between the different -modules, but which are not relevant to the outside. */ - - -/* To cope with SunOS4 and other systems that lack memmove() but have bcopy(), -define a macro for memmove() if USE_BCOPY is defined. */ - -#ifdef USE_BCOPY -#undef memmove /* some systems may have a macro */ -#define memmove(a, b, c) bcopy(b, a, c) -#endif - -/* Standard C headers plus the external interface definition */ - -#include -#include -#include -#include -#include -#include -#include -#include "pcre.h" - -/* In case there is no definition of offsetof() provided - though any proper -Standard C system should have one. */ - -#ifndef offsetof -#define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field)) -#endif - -/* Private options flags start at the most significant end of the two bytes. -The public options defined in pcre.h start at the least significant end. Make -sure they don't overlap! */ - -#define PCRE_FIRSTSET 0x8000 /* first_char is set */ -#define PCRE_STARTLINE 0x4000 /* start after \n for multiline */ -#define PCRE_COMPILED_CASELESS 0x2000 /* like it says */ - -/* Options for the "extra" block produced by pcre_study(). */ - -#define PCRE_STUDY_CASELESS 0x01 /* study was caseless */ -#define PCRE_STUDY_MAPPED 0x02 /* a map of starting chars exists */ - -/* Masks for identifying the public options: all permitted at compile time, -only some permitted at run or study time. */ - -#ifdef FOR_PYTHON -#define PUBLIC_OPTIONS \ - (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \ - PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY| \ - PCRE_LOCALE) -#else -#define PUBLIC_OPTIONS \ - (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \ - PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY) -#endif -#define PUBLIC_EXEC_OPTIONS \ - (PCRE_CASELESS|PCRE_ANCHORED|PCRE_MULTILINE|PCRE_NOTBOL|PCRE_NOTEOL| \ - PCRE_DOTALL|PCRE_DOLLAR_ENDONLY) - -#define PUBLIC_STUDY_OPTIONS (PCRE_CASELESS) - -/* Magic number to provide a small check against being handed junk. */ - -#define MAGIC_NUMBER 0x50435245 /* 'PCRE' */ - -/* Miscellaneous definitions */ - -typedef int BOOL; - -#define FALSE 0 -#define TRUE 1 - -/* These are escaped items that aren't just an encoding of a particular data -value such as \n. They must have non-zero values, as check_escape() returns -their negation. Also, they must appear in the same order as in the opcode -definitions below, up to ESC_Z. The final one must be ESC_REF as subsequent -values are used for \1, \2, \3, etc. There is a test in the code for an escape -greater than ESC_b and less than ESC_X to detect the types that may be -repeated. If any new escapes are put in-between that don't consume a character, -that code will have to change. */ - -enum { ESC_A = 1, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W, ESC_w, - - /* These are not Perl escapes, so can't appear in the */ - ESC_X, /* simple table-lookup because they must be conditional */ - /* on PCRE_EXTRA. */ - ESC_Z, - ESC_REF }; - -/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets -that extract substrings. Starting from 1 (i.e. after OP_END), the values up to -OP_EOD must correspond in order to the list of escapes immediately above. */ - -enum { - OP_END, /* End of pattern */ - - /* Values corresponding to backslashed metacharacters */ - - OP_SOD, /* Start of data: \A */ - OP_NOT_WORD_BOUNDARY, /* \B */ - OP_WORD_BOUNDARY, /* \b */ - OP_NOT_DIGIT, /* \D */ - OP_DIGIT, /* \d */ - OP_NOT_WHITESPACE, /* \S */ - OP_WHITESPACE, /* \s */ - OP_NOT_WORDCHAR, /* \W */ - OP_WORDCHAR, /* \w */ - OP_CUT, /* The analogue of Prolog's "cut" operation (extension) */ - OP_EOD, /* End of data: \Z. */ - - OP_NOT_WORD_BOUNDARY_L, /* localized \B */ - OP_WORD_BOUNDARY_L, /* localized \b */ - OP_NOT_WORDCHAR_L, /* localized \W */ - OP_WORDCHAR_L, /* localized \w */ - - OP_CIRC, /* Start of line - varies with multiline switch */ - OP_DOLL, /* End of line - varies with multiline switch */ - OP_ANY, /* Match any character */ - OP_CHARS, /* Match string of characters */ - OP_NOT, /* Match anything but the following char */ - - OP_STAR, /* The maximizing and minimizing versions of */ - OP_MINSTAR, /* all these opcodes must come in pairs, with */ - OP_PLUS, /* the minimizing one second. */ - OP_MINPLUS, /* This first set applies to single characters */ - OP_QUERY, - OP_MINQUERY, - OP_UPTO, /* From 0 to n matches */ - OP_MINUPTO, - OP_EXACT, /* Exactly n matches */ - - OP_NOTSTAR, /* The maximizing and minimizing versions of */ - OP_NOTMINSTAR, /* all these opcodes must come in pairs, with */ - OP_NOTPLUS, /* the minimizing one second. */ - OP_NOTMINPLUS, /* This first set applies to "not" single characters */ - OP_NOTQUERY, - OP_NOTMINQUERY, - OP_NOTUPTO, /* From 0 to n matches */ - OP_NOTMINUPTO, - OP_NOTEXACT, /* Exactly n matches */ - - OP_TYPESTAR, /* The maximizing and minimizing versions of */ - OP_TYPEMINSTAR, /* all these opcodes must come in pairs, with */ - OP_TYPEPLUS, /* the minimizing one second. These codes must */ - OP_TYPEMINPLUS, /* be in exactly the same order as those above. */ - OP_TYPEQUERY, /* This set applies to character types such as \d */ - OP_TYPEMINQUERY, - OP_TYPEUPTO, /* From 0 to n matches */ - OP_TYPEMINUPTO, - OP_TYPEEXACT, /* Exactly n matches */ - - OP_CRSTAR, /* The maximizing and minimizing versions of */ - OP_CRMINSTAR, /* all these opcodes must come in pairs, with */ - OP_CRPLUS, /* the minimizing one second. These codes must */ - OP_CRMINPLUS, /* be in exactly the same order as those above. */ - OP_CRQUERY, /* These are for character classes and back refs */ - OP_CRMINQUERY, - OP_CRRANGE, /* These are different to the three seta above. */ - OP_CRMINRANGE, - - OP_CLASS, /* Match a character class */ - OP_NEGCLASS, /* Match a character class, specified negatively */ - OP_CLASS_L, /* Match a character class */ - OP_REF, /* Match a back reference */ - - OP_ALT, /* Start of alternation */ - OP_KET, /* End of group that doesn't have an unbounded repeat */ - OP_KETRMAX, /* These two must remain together and in this */ - OP_KETRMIN, /* order. They are for groups the repeat for ever. */ - - OP_ASSERT, - OP_ASSERT_NOT, - OP_ONCE, /* Once matched, don't back up into the subpattern */ - - OP_BRAZERO, /* These two must remain together and in this */ - OP_BRAMINZERO, /* order. */ - - OP_BRA /* This and greater values are used for brackets that - extract substrings. */ -}; - -/* The highest extraction number. This is limited by the number of opcodes -left after OP_BRA, i.e. 255 - OP_BRA. We actually set it somewhat lower. */ - -#define EXTRACT_MAX 99 - -/* The texts of compile-time error messages are defined as macros here so that -they can be accessed by the POSIX wrapper and converted into error codes. Yes, -I could have used error codes in the first place, but didn't feel like changing -just to accommodate the POSIX wrapper. */ - -#define ERR1 "\\ at end of pattern" -#define ERR2 "\\c at end of pattern" -#define ERR3 "unrecognized character follows \\" -#define ERR4 "numbers out of order in {} quantifier" -#define ERR5 "number too big in {} quantifier" -#define ERR6 "missing terminating ] for character class" -#define ERR7 "invalid escape sequence in character class" -#define ERR8 "range out of order in character class" -#define ERR9 "nothing to repeat" -#define ERR10 "operand of unlimited repeat could match the empty string" -#define ERR11 "internal error: unexpected repeat" -#define ERR12 "unrecognized character after (?" -#define ERR13 "too many capturing parenthesized sub-patterns" -#define ERR14 "missing )" -#define ERR15 "back reference to non-existent subpattern" -#define ERR16 "erroffset passed as NULL" -#define ERR17 "unknown option bit(s) set" -#define ERR18 "missing ) after comment" -#define ERR19 "too many sets of parentheses" -#define ERR20 "regular expression too large" -#define ERR21 "failed to get memory" -#define ERR22 "unmatched brackets" -#define ERR23 "internal error: code overflow" - -/* All character handling must be done as unsigned characters. Otherwise there -are problems with top-bit-set characters and functions such as isspace(). -However, we leave the interface to the outside world as char *, because that -should make things easier for callers. We define a short type for unsigned char -to save lots of typing. I tried "uchar", but it causes problems on Digital -Unix, where it is defined in sys/types, so use "uschar" instead. */ - -typedef unsigned char uschar; - -/* The real format of the start of the pcre block; the actual code vector -runs on as long as necessary after the end. */ - -typedef struct real_pcre { - unsigned int magic_number; - unsigned short int options; - unsigned char top_bracket; - unsigned char top_backref; - unsigned char first_char; - unsigned char code[1]; -} real_pcre; - -/* The real format of the extra block returned by pcre_study(). */ - -typedef struct real_pcre_extra { - unsigned char options; - unsigned char start_bits[32]; -} real_pcre_extra; - -/* Global tables from chartables.c */ - -extern uschar pcre_lcc[]; -extern uschar pcre_fcc[]; -extern uschar pcre_cbits[]; -extern uschar pcre_ctypes[]; - -/* Bit definitions for entries in pcre_ctypes[]. */ - -#define ctype_space 0x01 -#define ctype_letter 0x02 -#define ctype_digit 0x04 -#define ctype_xdigit 0x08 -#define ctype_word 0x10 /* alphameric or '_' */ -#define ctype_odigit 0x20 /* octal digit */ -#define ctype_meta 0x80 /* regexp meta char or zero (end pattern) */ - -/* Offsets for the bitmap tables */ - -#define cbit_digit 0 -#define cbit_letter 32 -#define cbit_word 64 -#define cbit_space 96 -#define cbit_length 128 /* Length of the cbits table */ - -/* End of internal.h */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/pcre.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/pcre.h deleted file mode 100644 index 1f0eb84a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/pcre.h +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************* -* Perl-Compatible Regular Expressions * -*************************************************/ - -/* Copyright (c) 1998 University of Cambridge */ - -#ifndef _PCRE_H -#define _PCRE_H - -#ifdef FOR_PYTHON -#include "Python.h" -#endif - -/* Have to include stdlib.h in order to ensure that size_t is defined; -it is needed here for malloc. */ - -#ifndef DONT_HAVE_SYS_TYPES_H -#include -#endif -#include - -/* Allow for C++ users */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Options */ - -#define PCRE_CASELESS 0x0001 -#define PCRE_EXTENDED 0x0002 -#define PCRE_ANCHORED 0x0004 -#define PCRE_MULTILINE 0x0008 -#define PCRE_DOTALL 0x0010 -#define PCRE_DOLLAR_ENDONLY 0x0020 -#define PCRE_EXTRA 0x0040 -#define PCRE_NOTBOL 0x0080 -#define PCRE_NOTEOL 0x0100 -#define PCRE_UNGREEDY 0x0400 -#ifdef FOR_PYTHON -#define PCRE_LOCALE 0x0200 -#endif - -/* Exec-time error codes */ - -#define PCRE_ERROR_NOMATCH (-1) -#define PCRE_ERROR_BADREF (-2) -#define PCRE_ERROR_NULL (-3) -#define PCRE_ERROR_BADOPTION (-4) -#define PCRE_ERROR_BADMAGIC (-5) -#define PCRE_ERROR_UNKNOWN_NODE (-6) -#define PCRE_ERROR_NOMEMORY (-7) - -/* Types */ - -typedef void pcre; -typedef void pcre_extra; - -/* Store get and free functions. These can be set to alternative malloc/free -functions if required. */ - -extern void *(*pcre_malloc)(size_t); -extern void (*pcre_free)(void *); - -/* Functions */ - -#ifdef FOR_PYTHON -extern pcre *pcre_compile(const char *, int, const char **, int *, PyObject *); -extern int pcre_exec(const pcre *, const pcre_extra *, const char *, - int, int, int, int *, int); -#else -extern pcre *pcre_compile(const char *, int, const char **, int *); -extern int pcre_exec(const pcre *, const pcre_extra *, const char *, - int, int, int *, int); -#endif -extern int pcre_info(const pcre *, int *, int *); -extern pcre_extra *pcre_study(const pcre *, int, const char **); -extern const char *pcre_version(void); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* End of pcre.h */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/pcremodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/pcremodule.c deleted file mode 100644 index b628830d..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/pcremodule.c +++ /dev/null @@ -1,636 +0,0 @@ -/* Pcre objects */ - -#include "Python.h" - -#ifndef Py_eval_input -/* For Python 1.4, graminit.h has to be explicitly included */ -#include "graminit.h" -#define Py_eval_input eval_input -#endif - -#ifndef FOR_PYTHON -#define FOR_PYTHON -#endif - -#include "pcre.h" -#include "pcre-int.h" - -static PyObject *ErrorObject; - -typedef struct { - PyObject_HEAD - pcre *regex; - pcre_extra *regex_extra; - int num_groups; -} PcreObject; - -static PyTypeObject Pcre_Type; - -#define PcreObject_Check(v) ((v)->ob_type == &Pcre_Type) -#define NORMAL 0 -#define CHARCLASS 1 -#define REPLACEMENT 2 - -#define CHAR 0 -#define MEMORY_REFERENCE 1 -#define SYNTAX 2 -#define NOT_SYNTAX 3 -#define SET 4 -#define WORD_BOUNDARY 5 -#define NOT_WORD_BOUNDARY 6 -#define BEGINNING_OF_BUFFER 7 -#define END_OF_BUFFER 8 -#define STRING 9 - -static PcreObject * -newPcreObject(PyObject *args) -{ - PcreObject *self; - self = PyObject_New(PcreObject, &Pcre_Type); - if (self == NULL) - return NULL; - self->regex = NULL; - self->regex_extra = NULL; - return self; -} - -/* Pcre methods */ - -static void -PyPcre_dealloc(PcreObject *self) -{ - if (self->regex) (pcre_free)(self->regex); - if (self->regex_extra) (pcre_free)(self->regex_extra); - PyObject_Del(self); -} - - -static PyObject * -PyPcre_exec(PcreObject *self, PyObject *args) -{ - char *string; - int stringlen, pos = 0, options=0, endpos = -1, i, count; - int offsets[100*2]; - PyObject *list; - - if (!PyArg_ParseTuple(args, "t#|iii:match", &string, &stringlen, - &pos, &endpos, &options)) - return NULL; - if (endpos == -1) {endpos = stringlen;} - count = pcre_exec(self->regex, self->regex_extra, - string, endpos, pos, options, - offsets, sizeof(offsets)/sizeof(int) ); - /* If an error occurred during the match, and an exception was raised, - just return NULL and leave the exception alone. The most likely - problem to cause this would be running out of memory for - the failure stack. */ - if (PyErr_Occurred()) - { - return NULL; - } - if (count==PCRE_ERROR_NOMATCH) {Py_INCREF(Py_None); return Py_None;} - if (count<0) - { - PyObject *errval = Py_BuildValue("si", "Regex execution error", count); - PyErr_SetObject(ErrorObject, errval); - Py_XDECREF(errval); - return NULL; - } - - list=PyList_New(self->num_groups+1); - if (list==NULL) return NULL; - for(i=0; i<=self->num_groups; i++) - { - PyObject *v; - int start=offsets[i*2], end=offsets[i*2+1]; - /* If the group wasn't affected by the match, return -1, -1 */ - if (start<0 || count<=i) - {start=end=-1;} - v=Py_BuildValue("ii", start, end); - if (v==NULL) {Py_DECREF(list); return NULL;} - PyList_SetItem(list, i, v); - } - return list; -} - -static PyMethodDef Pcre_methods[] = { - {"match", (PyCFunction)PyPcre_exec, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -PyPcre_getattr(PcreObject *self, char *name) -{ - return Py_FindMethod(Pcre_methods, (PyObject *)self, name); -} - - -static PyTypeObject Pcre_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "pcre.Pcre", /*tp_name*/ - sizeof(PcreObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)PyPcre_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)PyPcre_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ -}; -/* --------------------------------------------------------------------- */ - -static PyObject * -PyPcre_compile(PyObject *self, PyObject *args) -{ - PcreObject *rv; - PyObject *dictionary; - char *pattern; - const char *error; - - int options, erroroffset; - if (!PyArg_ParseTuple(args, "siO!:pcre_compile", &pattern, &options, - &PyDict_Type, &dictionary)) - return NULL; - rv = newPcreObject(args); - if ( rv == NULL ) - return NULL; - - rv->regex = pcre_compile((char*)pattern, options, - &error, &erroroffset, dictionary); - if (rv->regex==NULL) - { - Py_DECREF(rv); - if (!PyErr_Occurred()) - { - PyObject *errval = Py_BuildValue("si", error, erroroffset); - PyErr_SetObject(ErrorObject, errval); - Py_XDECREF(errval); - } - return NULL; - } - rv->regex_extra=pcre_study(rv->regex, 0, &error); - if (rv->regex_extra==NULL && error!=NULL) - { - PyObject *errval = Py_BuildValue("si", error, 0); - Py_DECREF(rv); - PyErr_SetObject(ErrorObject, errval); - Py_XDECREF(errval); - return NULL; - } - rv->num_groups = pcre_info(rv->regex, NULL, NULL); - if (rv->num_groups<0) - { - PyObject *errval = Py_BuildValue("si", error, rv->num_groups); - PyErr_SetObject(ErrorObject, errval); - Py_XDECREF(errval); - Py_DECREF(rv); - return NULL; - } - return (PyObject *)rv; -} - -static PyObject * -PyPcre_expand_escape(unsigned char *pattern, int pattern_len, - int *indexptr, int *typeptr) -{ - unsigned char c; - int index = *indexptr; - - if (pattern_len<=index) - { - PyErr_SetString(ErrorObject, "escape ends too soon"); - return NULL; - } - c=pattern[index]; index++; - *typeptr=CHAR; - - switch (c) - { - case('t'): - *indexptr=index; - return Py_BuildValue("c", (char)9); - case('n'): - *indexptr = index; - return Py_BuildValue("c", (char)10); - case('v'): - *indexptr = index; - return Py_BuildValue("c", (char)11); - case('r'): - *indexptr = index; - return Py_BuildValue("c", (char)13); - case('f'): - *indexptr = index; - return Py_BuildValue("c", (char)12); - case('a'): - *indexptr = index; - return Py_BuildValue("c", (char)7); - case('b'): - *indexptr=index; - return Py_BuildValue("c", (char)8); - case('\\'): - *indexptr=index; - return Py_BuildValue("c", '\\'); - - case('x'): - { - int x, ch, end; - - x = 0; end = index; - while ( (end starting with digit"); - return NULL; - } - else {group_num = group_num * 10 + pattern[i] - '0';} - if (!(pcre_ctypes[pattern[i]] & ctype_word) ) - { - /* XXX should include the text of the reference */ - PyErr_SetString(ErrorObject, "illegal symbolic reference"); - return NULL; - } - } - - *typeptr = MEMORY_REFERENCE; - *indexptr = end+1; - /* If it's a number, return the integer value of the group */ - if (is_number) return Py_BuildValue("i", group_num); - /* Otherwise, return a string containing the group name */ - return Py_BuildValue("s#", pattern+index, end-index); - } - - case('0'): - { - /* \0 always indicates an octal escape, so we consume up to 3 - characters, as long as they're all octal digits */ - int octval=0, i; - index--; - for(i=index; - i<=index+2 && i255) - { - PyErr_SetString(ErrorObject, "octal value out of range"); - return NULL; - } - *indexptr = i; - return Py_BuildValue("c", (unsigned char)octval); - } - - case('1'): case('2'): case('3'): case('4'): - case('5'): case('6'): case('7'): case('8'): - case('9'): - { - /* Handle \?, where ? is from 1 through 9 */ - int value=0; - index--; - /* If it's at least a two-digit reference, like \34, it might - either be a 3-digit octal escape (\123) or a 2-digit - decimal memory reference (\34) */ - - if ( (index+1) 255) - { - PyErr_SetString(ErrorObject, "octal value out of range"); - return NULL; - } - *indexptr = index+3; - return Py_BuildValue("c", (unsigned char)value); - } - else - { - /* 2-digit form, so it's a memory reference */ - value= 10*(pattern[index ]-'0') + - (pattern[index+1]-'0'); - if (value<1 || EXTRACT_MAX<=value) - { - PyErr_SetString(ErrorObject, "memory reference out of range"); - return NULL; - } - *typeptr = MEMORY_REFERENCE; - *indexptr = index+2; - return Py_BuildValue("i", value); - } - } - else - { - /* Single-digit form, like \2, so it's a memory reference */ - *typeptr = MEMORY_REFERENCE; - *indexptr = index+1; - return Py_BuildValue("i", pattern[index]-'0'); - } - } - - default: - /* It's some unknown escape like \s, so return a string containing - \s */ - *typeptr = STRING; - *indexptr = index; - return Py_BuildValue("s#", pattern+index-2, 2); - } -} - -static PyObject * -PyPcre_expand(PyObject *self, PyObject *args) -{ - PyObject *results, *match_obj; - PyObject *repl_obj, *newstring; - unsigned char *repl; - int size, total_len, i, start, pos; - - if (!PyArg_ParseTuple(args, "OS:pcre_expand", &match_obj, &repl_obj)) - return NULL; - - repl=(unsigned char *)PyString_AsString(repl_obj); - size=PyString_Size(repl_obj); - results=PyList_New(0); - if (results==NULL) return NULL; - for(start=total_len=i=0; i -#endif /* defined(__VMS) */ - -PyDoc_STRVAR(posix__doc__, -"This module provides access to operating system functionality that is\n\ -standardized by the C Standard and the POSIX standard (a thinly\n\ -disguised Unix interface). Refer to the library manual and\n\ -corresponding Unix manual entries for more information on calls."); - -#ifndef Py_USING_UNICODE -/* This is used in signatures of functions. */ -#define Py_UNICODE void -#endif - -#if defined(PYOS_OS2) -#define INCL_DOS -#define INCL_DOSERRORS -#define INCL_DOSPROCESS -#define INCL_NOPMAPI -#include -#if defined(PYCC_GCC) -#include -#include -#include -#include -#include "osdefs.h" -#endif -#endif - -#include -#include - -#ifdef HAVE_SYS_WAIT_H -#include /* For WNOHANG */ -#endif - -#ifdef HAVE_SIGNAL_H -#include -#endif - -#ifdef HAVE_FCNTL_H -#include -#endif /* HAVE_FCNTL_H */ - -#ifdef HAVE_GRP_H -#include -#endif - -#ifdef HAVE_SYSEXITS_H -#include -#endif /* HAVE_SYSEXITS_H */ - -/* Various compilers have only certain posix functions */ -/* XXX Gosh I wish these were all moved into pyconfig.h */ -#if defined(PYCC_VACPP) && defined(PYOS_OS2) -#include -#else -#if defined(__WATCOMC__) && !defined(__QNX__) /* Watcom compiler */ -#define HAVE_GETCWD 1 -#define HAVE_OPENDIR 1 -#define HAVE_SYSTEM 1 -#if defined(__OS2__) -#define HAVE_EXECV 1 -#define HAVE_WAIT 1 -#endif -#include -#else -#ifdef __BORLANDC__ /* Borland compiler */ -#define HAVE_EXECV 1 -#define HAVE_GETCWD 1 -#define HAVE_OPENDIR 1 -#define HAVE_PIPE 1 -#define HAVE_POPEN 1 -#define HAVE_SYSTEM 1 -#define HAVE_WAIT 1 -#else -#ifdef _MSC_VER /* Microsoft compiler */ -#ifndef MS_XBOX -# define HAVE_GETCWD 1 -# define HAVE_SPAWNV 1 -# define HAVE_EXECV 1 -# define HAVE_SYSTEM 1 -# define HAVE_CWAIT 1 -#endif -#define HAVE_PIPE 1 -#define HAVE_POPEN 1 -#define HAVE_FSYNC 1 -#define fsync _commit -#else -#if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS) -/* Everything needed is defined in PC/os2emx/pyconfig.h or vms/pyconfig.h */ -#else /* all other compilers */ -/* Unix functions that the configure script doesn't check for */ -#define HAVE_EXECV 1 -#define HAVE_FORK 1 -#if defined(__USLC__) && defined(__SCO_VERSION__) /* SCO UDK Compiler */ -#define HAVE_FORK1 1 -#endif -#define HAVE_GETCWD 1 -#define HAVE_GETEGID 1 -#define HAVE_GETEUID 1 -#define HAVE_GETGID 1 -#define HAVE_GETPPID 1 -#define HAVE_GETUID 1 -#define HAVE_KILL 1 -#define HAVE_OPENDIR 1 -#define HAVE_PIPE 1 -#define HAVE_POPEN 1 -#define HAVE_SYSTEM 1 -#define HAVE_WAIT 1 -#define HAVE_TTYNAME 1 -#endif /* PYOS_OS2 && PYCC_GCC && __VMS */ -#endif /* _MSC_VER */ -#endif /* __BORLANDC__ */ -#endif /* ! __WATCOMC__ || __QNX__ */ -#endif /* ! __IBMC__ */ - -#ifndef _MSC_VER - -#if defined(sun) && !defined(__SVR4) -/* SunOS 4.1.4 doesn't have prototypes for these: */ -extern int rename(const char *, const char *); -extern int pclose(FILE *); -extern int fclose(FILE *); -extern int fsync(int); -extern int lstat(const char *, struct stat *); -extern int symlink(const char *, const char *); -#endif - -#if defined(__sgi)&&_COMPILER_VERSION>=700 -/* declare ctermid_r if compiling with MIPSPro 7.x in ANSI C mode - (default) */ -extern char *ctermid_r(char *); -#endif - -#ifndef HAVE_UNISTD_H -#if defined(PYCC_VACPP) -extern int mkdir(char *); -#else -#if ( defined(__WATCOMC__) || defined(_MSC_VER) ) && !defined(__QNX__) -extern int mkdir(const char *); -#else -extern int mkdir(const char *, mode_t); -#endif -#endif -#if defined(__IBMC__) || defined(__IBMCPP__) -extern int chdir(char *); -extern int rmdir(char *); -#else -extern int chdir(const char *); -extern int rmdir(const char *); -#endif -#ifdef __BORLANDC__ -extern int chmod(const char *, int); -#else -extern int chmod(const char *, mode_t); -#endif -extern int chown(const char *, uid_t, gid_t); -extern char *getcwd(char *, int); -extern char *strerror(int); -extern int link(const char *, const char *); -extern int rename(const char *, const char *); -extern int stat(const char *, struct stat *); -extern int unlink(const char *); -extern int pclose(FILE *); -#ifdef HAVE_SYMLINK -extern int symlink(const char *, const char *); -#endif /* HAVE_SYMLINK */ -#ifdef HAVE_LSTAT -extern int lstat(const char *, struct stat *); -#endif /* HAVE_LSTAT */ -#endif /* !HAVE_UNISTD_H */ - -#endif /* !_MSC_VER */ - -#ifdef HAVE_UTIME_H -#include -#endif /* HAVE_UTIME_H */ - -#ifdef HAVE_SYS_UTIME_H -#include -#define HAVE_UTIME_H /* pretend we do for the rest of this file */ -#endif /* HAVE_SYS_UTIME_H */ - -#ifdef HAVE_SYS_TIMES_H -#include -#endif /* HAVE_SYS_TIMES_H */ - -#ifdef HAVE_SYS_PARAM_H -#include -#endif /* HAVE_SYS_PARAM_H */ - -#ifdef HAVE_SYS_UTSNAME_H -#include -#endif /* HAVE_SYS_UTSNAME_H */ - -#ifdef HAVE_DIRENT_H -#include -#define NAMLEN(dirent) strlen((dirent)->d_name) -#else -#if defined(__WATCOMC__) && !defined(__QNX__) -#include -#define NAMLEN(dirent) strlen((dirent)->d_name) -#else -#define dirent direct -#define NAMLEN(dirent) (dirent)->d_namlen -#endif -#ifdef HAVE_SYS_NDIR_H -#include -#endif -#ifdef HAVE_SYS_DIR_H -#include -#endif -#ifdef HAVE_NDIR_H -#include -#endif -#endif - -#ifdef _MSC_VER -#include -#include -#include -#include "osdefs.h" -#define WIN32_LEAN_AND_MEAN -#ifdef MS_XBOX -#include -#else -#include -#include /* for ShellExecute() */ -#endif -#define popen _popen -#define pclose _pclose -#endif /* _MSC_VER */ - -#if defined(PYCC_VACPP) && defined(PYOS_OS2) -#include -#endif /* OS2 */ - -#ifndef MAXPATHLEN -#define MAXPATHLEN 1024 -#endif /* MAXPATHLEN */ - -#ifdef UNION_WAIT -/* Emulate some macros on systems that have a union instead of macros */ - -#ifndef WIFEXITED -#define WIFEXITED(u_wait) (!(u_wait).w_termsig && !(u_wait).w_coredump) -#endif - -#ifndef WEXITSTATUS -#define WEXITSTATUS(u_wait) (WIFEXITED(u_wait)?((u_wait).w_retcode):-1) -#endif - -#ifndef WTERMSIG -#define WTERMSIG(u_wait) ((u_wait).w_termsig) -#endif - -#endif /* UNION_WAIT */ - -/* Don't use the "_r" form if we don't need it (also, won't have a - prototype for it, at least on Solaris -- maybe others as well?). */ -#if defined(HAVE_CTERMID_R) && defined(WITH_THREAD) -#define USE_CTERMID_R -#endif - -#if defined(HAVE_TMPNAM_R) && defined(WITH_THREAD) -#define USE_TMPNAM_R -#endif - -/* choose the appropriate stat and fstat functions and return structs */ -#undef STAT -#if defined(MS_WIN64) || defined(MS_WINDOWS) -# define STAT _stati64 -# define FSTAT _fstati64 -# define STRUCT_STAT struct _stati64 -#else -# define STAT stat -# define FSTAT fstat -# define STRUCT_STAT struct stat -#endif - -#if defined(MAJOR_IN_MKDEV) -#include -#else -#if defined(MAJOR_IN_SYSMACROS) -#include -#endif -#if defined(HAVE_MKNOD) && defined(HAVE_SYS_MKDEV_H) -#include -#endif -#endif - -/* Return a dictionary corresponding to the POSIX environment table */ -#ifdef WITH_NEXT_FRAMEWORK -/* On Darwin/MacOSX a shared library or framework has no access to -** environ directly, we must obtain it with _NSGetEnviron(). -*/ -#include -static char **environ; -#elif !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) ) -extern char **environ; -#elif defined(MS_XBOX) -static char **environ = NULL; -#endif /* !_MSC_VER */ - -static PyObject * -convertenviron(void) -{ - PyObject *d; - char **e; - d = PyDict_New(); - if (d == NULL) - return NULL; -#ifdef WITH_NEXT_FRAMEWORK - if (environ == NULL) - environ = *_NSGetEnviron(); -#endif - if (environ == NULL) - return d; - /* This part ignores errors */ - for (e = environ; *e != NULL; e++) { - PyObject *k; - PyObject *v; - char *p = strchr(*e, '='); - if (p == NULL) - continue; - k = PyString_FromStringAndSize(*e, (int)(p-*e)); - if (k == NULL) { - PyErr_Clear(); - continue; - } - v = PyString_FromString(p+1); - if (v == NULL) { - PyErr_Clear(); - Py_DECREF(k); - continue; - } - if (PyDict_GetItem(d, k) == NULL) { - if (PyDict_SetItem(d, k, v) != 0) - PyErr_Clear(); - } - Py_DECREF(k); - Py_DECREF(v); - } -#if defined(PYOS_OS2) - { - APIRET rc; - char buffer[1024]; /* OS/2 Provides a Documented Max of 1024 Chars */ - - rc = DosQueryExtLIBPATH(buffer, BEGIN_LIBPATH); - if (rc == NO_ERROR) { /* (not a type, envname is NOT 'BEGIN_LIBPATH') */ - PyObject *v = PyString_FromString(buffer); - PyDict_SetItemString(d, "BEGINLIBPATH", v); - Py_DECREF(v); - } - rc = DosQueryExtLIBPATH(buffer, END_LIBPATH); - if (rc == NO_ERROR) { /* (not a typo, envname is NOT 'END_LIBPATH') */ - PyObject *v = PyString_FromString(buffer); - PyDict_SetItemString(d, "ENDLIBPATH", v); - Py_DECREF(v); - } - } -#endif - return d; -} - - -/* Set a POSIX-specific error from errno, and return NULL */ - -static PyObject * -posix_error(void) -{ - return PyErr_SetFromErrno(PyExc_OSError); -} -static PyObject * -posix_error_with_filename(char* name) -{ - return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); -} - -#ifdef Py_WIN_WIDE_FILENAMES -static PyObject * -posix_error_with_unicode_filename(Py_UNICODE* name) -{ - return PyErr_SetFromErrnoWithUnicodeFilename(PyExc_OSError, name); -} -#endif /* Py_WIN_WIDE_FILENAMES */ - - -static PyObject * -posix_error_with_allocated_filename(char* name) -{ - PyObject *rc = PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); - PyMem_Free(name); - return rc; -} - -#ifdef MS_WINDOWS -static PyObject * -win32_error(char* function, char* filename) -{ - /* XXX We should pass the function name along in the future. - (_winreg.c also wants to pass the function name.) - This would however require an additional param to the - Windows error object, which is non-trivial. - */ - errno = GetLastError(); - if (filename) - return PyErr_SetFromWindowsErrWithFilename(errno, filename); - else - return PyErr_SetFromWindowsErr(errno); -} - -#ifdef Py_WIN_WIDE_FILENAMES -static PyObject * -win32_error_unicode(char* function, Py_UNICODE* filename) -{ - /* XXX - see win32_error for comments on 'function' */ - errno = GetLastError(); - if (filename) - return PyErr_SetFromWindowsErrWithUnicodeFilename(errno, filename); - else - return PyErr_SetFromWindowsErr(errno); -} - -static PyObject *_PyUnicode_FromFileSystemEncodedObject(register PyObject *obj) -{ - /* XXX Perhaps we should make this API an alias of - PyObject_Unicode() instead ?! */ - if (PyUnicode_CheckExact(obj)) { - Py_INCREF(obj); - return obj; - } - if (PyUnicode_Check(obj)) { - /* For a Unicode subtype that's not a Unicode object, - return a true Unicode object with the same data. */ - return PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(obj), - PyUnicode_GET_SIZE(obj)); - } - return PyUnicode_FromEncodedObject(obj, - Py_FileSystemDefaultEncoding, - "strict"); -} - -#endif /* Py_WIN_WIDE_FILENAMES */ - -#endif - -#if defined(PYOS_OS2) -/********************************************************************** - * Helper Function to Trim and Format OS/2 Messages - **********************************************************************/ - static void -os2_formatmsg(char *msgbuf, int msglen, char *reason) -{ - msgbuf[msglen] = '\0'; /* OS/2 Doesn't Guarantee a Terminator */ - - if (strlen(msgbuf) > 0) { /* If Non-Empty Msg, Trim CRLF */ - char *lastc = &msgbuf[ strlen(msgbuf)-1 ]; - - while (lastc > msgbuf && isspace(*lastc)) - *lastc-- = '\0'; /* Trim Trailing Whitespace (CRLF) */ - } - - /* Add Optional Reason Text */ - if (reason) { - strcat(msgbuf, " : "); - strcat(msgbuf, reason); - } -} - -/********************************************************************** - * Decode an OS/2 Operating System Error Code - * - * A convenience function to lookup an OS/2 error code and return a - * text message we can use to raise a Python exception. - * - * Notes: - * The messages for errors returned from the OS/2 kernel reside in - * the file OSO001.MSG in the \OS2 directory hierarchy. - * - **********************************************************************/ - static char * -os2_strerror(char *msgbuf, int msgbuflen, int errorcode, char *reason) -{ - APIRET rc; - ULONG msglen; - - /* Retrieve Kernel-Related Error Message from OSO001.MSG File */ - Py_BEGIN_ALLOW_THREADS - rc = DosGetMessage(NULL, 0, msgbuf, msgbuflen, - errorcode, "oso001.msg", &msglen); - Py_END_ALLOW_THREADS - - if (rc == NO_ERROR) - os2_formatmsg(msgbuf, msglen, reason); - else - PyOS_snprintf(msgbuf, msgbuflen, - "unknown OS error #%d", errorcode); - - return msgbuf; -} - -/* Set an OS/2-specific error and return NULL. OS/2 kernel - errors are not in a global variable e.g. 'errno' nor are - they congruent with posix error numbers. */ - -static PyObject * os2_error(int code) -{ - char text[1024]; - PyObject *v; - - os2_strerror(text, sizeof(text), code, ""); - - v = Py_BuildValue("(is)", code, text); - if (v != NULL) { - PyErr_SetObject(PyExc_OSError, v); - Py_DECREF(v); - } - return NULL; /* Signal to Python that an Exception is Pending */ -} - -#endif /* OS2 */ - -/* POSIX generic methods */ - -static PyObject * -posix_fildes(PyObject *fdobj, int (*func)(int)) -{ - int fd; - int res; - fd = PyObject_AsFileDescriptor(fdobj); - if (fd < 0) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = (*func)(fd); - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} - -#ifdef Py_WIN_WIDE_FILENAMES -static int -unicode_file_names(void) -{ - static int canusewide = -1; - if (canusewide == -1) { - /* As per doc for ::GetVersion(), this is the correct test for - the Windows NT family. */ - canusewide = (GetVersion() < 0x80000000) ? 1 : 0; - } - return canusewide; -} -#endif - -static PyObject * -posix_1str(PyObject *args, char *format, int (*func)(const char*), - char *wformat, int (*wfunc)(const Py_UNICODE*)) -{ - char *path1 = NULL; - int res; -#ifdef Py_WIN_WIDE_FILENAMES - if (unicode_file_names()) { - PyUnicodeObject *po; - if (PyArg_ParseTuple(args, wformat, &po)) { - Py_BEGIN_ALLOW_THREADS - /* PyUnicode_AS_UNICODE OK without thread - lock as it is a simple dereference. */ - res = (*wfunc)(PyUnicode_AS_UNICODE(po)); - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error_with_unicode_filename(PyUnicode_AS_UNICODE(po)); - Py_INCREF(Py_None); - return Py_None; - } - /* Drop the argument parsing error as narrow - strings are also valid. */ - PyErr_Clear(); - } -#else - /* Platforms that don't support Unicode filenames - shouldn't be passing these extra params */ - assert(wformat==NULL && wfunc == NULL); -#endif - - if (!PyArg_ParseTuple(args, format, - Py_FileSystemDefaultEncoding, &path1)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = (*func)(path1); - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error_with_allocated_filename(path1); - PyMem_Free(path1); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -posix_2str(PyObject *args, - char *format, - int (*func)(const char *, const char *), - char *wformat, - int (*wfunc)(const Py_UNICODE *, const Py_UNICODE *)) -{ - char *path1 = NULL, *path2 = NULL; - int res; -#ifdef Py_WIN_WIDE_FILENAMES - if (unicode_file_names()) { - PyObject *po1; - PyObject *po2; - if (PyArg_ParseTuple(args, wformat, &po1, &po2)) { - if (PyUnicode_Check(po1) || PyUnicode_Check(po2)) { - PyObject *wpath1; - PyObject *wpath2; - wpath1 = _PyUnicode_FromFileSystemEncodedObject(po1); - wpath2 = _PyUnicode_FromFileSystemEncodedObject(po2); - if (!wpath1 || !wpath2) { - Py_XDECREF(wpath1); - Py_XDECREF(wpath2); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - /* PyUnicode_AS_UNICODE OK without thread - lock as it is a simple dereference. */ - res = (*wfunc)(PyUnicode_AS_UNICODE(wpath1), - PyUnicode_AS_UNICODE(wpath2)); - Py_END_ALLOW_THREADS - Py_XDECREF(wpath1); - Py_XDECREF(wpath2); - if (res != 0) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; - } - /* Else flow through as neither is Unicode. */ - } - /* Drop the argument parsing error as narrow - strings are also valid. */ - PyErr_Clear(); - } -#else - /* Platforms that don't support Unicode filenames - shouldn't be passing these extra params */ - assert(wformat==NULL && wfunc == NULL); -#endif - - if (!PyArg_ParseTuple(args, format, - Py_FileSystemDefaultEncoding, &path1, - Py_FileSystemDefaultEncoding, &path2)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = (*func)(path1, path2); - Py_END_ALLOW_THREADS - PyMem_Free(path1); - PyMem_Free(path2); - if (res != 0) - /* XXX how to report both path1 and path2??? */ - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(stat_result__doc__, -"stat_result: Result from stat or lstat.\n\n\ -This object may be accessed either as a tuple of\n\ - (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)\n\ -or via the attributes st_mode, st_ino, st_dev, st_nlink, st_uid, and so on.\n\ -\n\ -Posix/windows: If your platform supports st_blksize, st_blocks, or st_rdev,\n\ -they are available as attributes only.\n\ -\n\ -See os.stat for more information."); - -static PyStructSequence_Field stat_result_fields[] = { - {"st_mode", "protection bits"}, - {"st_ino", "inode"}, - {"st_dev", "device"}, - {"st_nlink", "number of hard links"}, - {"st_uid", "user ID of owner"}, - {"st_gid", "group ID of owner"}, - {"st_size", "total size, in bytes"}, - /* The NULL is replaced with PyStructSequence_UnnamedField later. */ - {NULL, "integer time of last access"}, - {NULL, "integer time of last modification"}, - {NULL, "integer time of last change"}, - {"st_atime", "time of last access"}, - {"st_mtime", "time of last modification"}, - {"st_ctime", "time of last change"}, -#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE - {"st_blksize", "blocksize for filesystem I/O"}, -#endif -#ifdef HAVE_STRUCT_STAT_ST_BLOCKS - {"st_blocks", "number of blocks allocated"}, -#endif -#ifdef HAVE_STRUCT_STAT_ST_RDEV - {"st_rdev", "device type (if inode device)"}, -#endif - {0} -}; - -#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE -#define ST_BLKSIZE_IDX 13 -#else -#define ST_BLKSIZE_IDX 12 -#endif - -#ifdef HAVE_STRUCT_STAT_ST_BLOCKS -#define ST_BLOCKS_IDX (ST_BLKSIZE_IDX+1) -#else -#define ST_BLOCKS_IDX ST_BLKSIZE_IDX -#endif - -#ifdef HAVE_STRUCT_STAT_ST_RDEV -#define ST_RDEV_IDX (ST_BLOCKS_IDX+1) -#else -#define ST_RDEV_IDX ST_BLOCKS_IDX -#endif - -static PyStructSequence_Desc stat_result_desc = { - "stat_result", /* name */ - stat_result__doc__, /* doc */ - stat_result_fields, - 10 -}; - -PyDoc_STRVAR(statvfs_result__doc__, -"statvfs_result: Result from statvfs or fstatvfs.\n\n\ -This object may be accessed either as a tuple of\n\ - (bsize, frsize, blocks, bfree, bavail, files, ffree, favail, flag, namemax),\n\ -or via the attributes f_bsize, f_frsize, f_blocks, f_bfree, and so on.\n\ -\n\ -See os.statvfs for more information."); - -static PyStructSequence_Field statvfs_result_fields[] = { - {"f_bsize", }, - {"f_frsize", }, - {"f_blocks", }, - {"f_bfree", }, - {"f_bavail", }, - {"f_files", }, - {"f_ffree", }, - {"f_favail", }, - {"f_flag", }, - {"f_namemax",}, - {0} -}; - -static PyStructSequence_Desc statvfs_result_desc = { - "statvfs_result", /* name */ - statvfs_result__doc__, /* doc */ - statvfs_result_fields, - 10 -}; - -static PyTypeObject StatResultType; -static PyTypeObject StatVFSResultType; -static newfunc structseq_new; - -static PyObject * -statresult_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyStructSequence *result; - int i; - - result = (PyStructSequence*)structseq_new(type, args, kwds); - if (!result) - return NULL; - /* If we have been initialized from a tuple, - st_?time might be set to None. Initialize it - from the int slots. */ - for (i = 7; i <= 9; i++) { - if (result->ob_item[i+3] == Py_None) { - Py_DECREF(Py_None); - Py_INCREF(result->ob_item[i]); - result->ob_item[i+3] = result->ob_item[i]; - } - } - return (PyObject*)result; -} - - - -/* If true, st_?time is float. */ -static int _stat_float_times = 0; - -PyDoc_STRVAR(stat_float_times__doc__, -"stat_float_times([newval]) -> oldval\n\n\ -Determine whether os.[lf]stat represents time stamps as float objects.\n\ -If newval is True, future calls to stat() return floats, if it is False,\n\ -future calls return ints. \n\ -If newval is omitted, return the current setting.\n"); - -static PyObject* -stat_float_times(PyObject* self, PyObject *args) -{ - int newval = -1; - if (!PyArg_ParseTuple(args, "|i:stat_float_times", &newval)) - return NULL; - if (newval == -1) - /* Return old value */ - return PyBool_FromLong(_stat_float_times); - _stat_float_times = newval; - Py_INCREF(Py_None); - return Py_None; -} - -static void -fill_time(PyObject *v, int index, time_t sec, unsigned long nsec) -{ - PyObject *fval,*ival; -#if SIZEOF_TIME_T > SIZEOF_LONG - ival = PyLong_FromLongLong((PY_LONG_LONG)sec); -#else - ival = PyInt_FromLong((long)sec); -#endif - if (_stat_float_times) { - fval = PyFloat_FromDouble(sec + 1e-9*nsec); - } else { - fval = ival; - Py_INCREF(fval); - } - PyStructSequence_SET_ITEM(v, index, ival); - PyStructSequence_SET_ITEM(v, index+3, fval); -} - -/* pack a system stat C structure into the Python stat tuple - (used by posix_stat() and posix_fstat()) */ -static PyObject* -_pystat_fromstructstat(STRUCT_STAT st) -{ - unsigned long ansec, mnsec, cnsec; - PyObject *v = PyStructSequence_New(&StatResultType); - if (v == NULL) - return NULL; - - PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long)st.st_mode)); -#ifdef HAVE_LARGEFILE_SUPPORT - PyStructSequence_SET_ITEM(v, 1, - PyLong_FromLongLong((PY_LONG_LONG)st.st_ino)); -#else - PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long)st.st_ino)); -#endif -#if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) - PyStructSequence_SET_ITEM(v, 2, - PyLong_FromLongLong((PY_LONG_LONG)st.st_dev)); -#else - PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long)st.st_dev)); -#endif - PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long)st.st_nlink)); - PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st.st_uid)); - PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st.st_gid)); -#ifdef HAVE_LARGEFILE_SUPPORT - PyStructSequence_SET_ITEM(v, 6, - PyLong_FromLongLong((PY_LONG_LONG)st.st_size)); -#else - PyStructSequence_SET_ITEM(v, 6, PyInt_FromLong(st.st_size)); -#endif - -#ifdef HAVE_STAT_TV_NSEC - ansec = st.st_atim.tv_nsec; - mnsec = st.st_mtim.tv_nsec; - cnsec = st.st_ctim.tv_nsec; -#else - ansec = mnsec = cnsec = 0; -#endif - fill_time(v, 7, st.st_atime, ansec); - fill_time(v, 8, st.st_mtime, mnsec); - fill_time(v, 9, st.st_ctime, cnsec); - -#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE - PyStructSequence_SET_ITEM(v, ST_BLKSIZE_IDX, - PyInt_FromLong((long)st.st_blksize)); -#endif -#ifdef HAVE_STRUCT_STAT_ST_BLOCKS - PyStructSequence_SET_ITEM(v, ST_BLOCKS_IDX, - PyInt_FromLong((long)st.st_blocks)); -#endif -#ifdef HAVE_STRUCT_STAT_ST_RDEV - PyStructSequence_SET_ITEM(v, ST_RDEV_IDX, - PyInt_FromLong((long)st.st_rdev)); -#endif - - if (PyErr_Occurred()) { - Py_DECREF(v); - return NULL; - } - - return v; -} - -static PyObject * -posix_do_stat(PyObject *self, PyObject *args, - char *format, -#ifdef __VMS - int (*statfunc)(const char *, STRUCT_STAT *, ...), -#else - int (*statfunc)(const char *, STRUCT_STAT *), -#endif - char *wformat, - int (*wstatfunc)(const Py_UNICODE *, STRUCT_STAT *)) -{ - STRUCT_STAT st; - char *path = NULL; /* pass this to stat; do not free() it */ - char *pathfree = NULL; /* this memory must be free'd */ - int res; - -#ifdef MS_WINDOWS - int pathlen; - char pathcopy[MAX_PATH]; -#endif /* MS_WINDOWS */ - - -#ifdef Py_WIN_WIDE_FILENAMES - /* If on wide-character-capable OS see if argument - is Unicode and if so use wide API. */ - if (unicode_file_names()) { - PyUnicodeObject *po; - if (PyArg_ParseTuple(args, wformat, &po)) { - Py_UNICODE wpath[MAX_PATH+1]; - pathlen = wcslen(PyUnicode_AS_UNICODE(po)); - /* the library call can blow up if the file name is too long! */ - if (pathlen > MAX_PATH) { - errno = ENAMETOOLONG; - return posix_error(); - } - wcscpy(wpath, PyUnicode_AS_UNICODE(po)); - /* Remove trailing slash or backslash, unless it's the current - drive root (/ or \) or a specific drive's root (like c:\ or c:/). - */ - if (pathlen > 0 && - (wpath[pathlen-1]== L'\\' || wpath[pathlen-1] == L'/')) { - /* It does end with a slash -- exempt the root drive cases. */ - /* XXX UNC root drives should also be exempted? */ - if (pathlen == 1 || (pathlen == 3 && wpath[1] == L':')) - /* leave it alone */; - else { - /* nuke the trailing backslash */ - wpath[pathlen-1] = L'\0'; - } - } - Py_BEGIN_ALLOW_THREADS - /* PyUnicode_AS_UNICODE result OK without - thread lock as it is a simple dereference. */ - res = wstatfunc(wpath, &st); - Py_END_ALLOW_THREADS - if (res != 0) - return posix_error_with_unicode_filename(wpath); - return _pystat_fromstructstat(st); - } - /* Drop the argument parsing error as narrow strings - are also valid. */ - PyErr_Clear(); - } -#endif - - if (!PyArg_ParseTuple(args, format, - Py_FileSystemDefaultEncoding, &path)) - return NULL; - pathfree = path; - -#ifdef MS_WINDOWS - pathlen = strlen(path); - /* the library call can blow up if the file name is too long! */ - if (pathlen > MAX_PATH) { - PyMem_Free(pathfree); - errno = ENAMETOOLONG; - return posix_error(); - } - - /* Remove trailing slash or backslash, unless it's the current - drive root (/ or \) or a specific drive's root (like c:\ or c:/). - */ - if (pathlen > 0 && - (path[pathlen-1]== '\\' || path[pathlen-1] == '/')) { - /* It does end with a slash -- exempt the root drive cases. */ - /* XXX UNC root drives should also be exempted? */ - if (pathlen == 1 || (pathlen == 3 && path[1] == ':')) - /* leave it alone */; - else { - /* nuke the trailing backslash */ - strncpy(pathcopy, path, pathlen); - pathcopy[pathlen-1] = '\0'; - path = pathcopy; - } - } -#endif /* MS_WINDOWS */ - - Py_BEGIN_ALLOW_THREADS - res = (*statfunc)(path, &st); - Py_END_ALLOW_THREADS - if (res != 0) - return posix_error_with_allocated_filename(pathfree); - - PyMem_Free(pathfree); - return _pystat_fromstructstat(st); -} - - -/* POSIX methods */ - -PyDoc_STRVAR(posix_access__doc__, -"access(path, mode) -> 1 if granted, 0 otherwise\n\n\ -Use the real uid/gid to test for access to a path. Note that most\n\ -operations will use the effective uid/gid, therefore this routine can\n\ -be used in a suid/sgid environment to test if the invoking user has the\n\ -specified access to the path. The mode argument can be F_OK to test\n\ -existence, or the inclusive-OR of R_OK, W_OK, and X_OK."); - -static PyObject * -posix_access(PyObject *self, PyObject *args) -{ - char *path; - int mode; - int res; - - if (!PyArg_ParseTuple(args, "si:access", &path, &mode)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = access(path, mode); - Py_END_ALLOW_THREADS - return(PyBool_FromLong(res == 0)); -} - -#ifndef F_OK -#define F_OK 0 -#endif -#ifndef R_OK -#define R_OK 4 -#endif -#ifndef W_OK -#define W_OK 2 -#endif -#ifndef X_OK -#define X_OK 1 -#endif - -#ifdef HAVE_TTYNAME -PyDoc_STRVAR(posix_ttyname__doc__, -"ttyname(fd) -> string\n\n\ -Return the name of the terminal device connected to 'fd'."); - -static PyObject * -posix_ttyname(PyObject *self, PyObject *args) -{ - int id; - char *ret; - - if (!PyArg_ParseTuple(args, "i:ttyname", &id)) - return NULL; - -#if defined(__VMS) - /* file descriptor 0 only, the default input device (stdin) */ - if (id == 0) { - ret = ttyname(); - } - else { - ret = NULL; - } -#else - ret = ttyname(id); -#endif - if (ret == NULL) - return(posix_error()); - return(PyString_FromString(ret)); -} -#endif - -#ifdef HAVE_CTERMID -PyDoc_STRVAR(posix_ctermid__doc__, -"ctermid() -> string\n\n\ -Return the name of the controlling terminal for this process."); - -static PyObject * -posix_ctermid(PyObject *self, PyObject *noargs) -{ - char *ret; - char buffer[L_ctermid]; - -#ifdef USE_CTERMID_R - ret = ctermid_r(buffer); -#else - ret = ctermid(buffer); -#endif - if (ret == NULL) - return(posix_error()); - return(PyString_FromString(buffer)); -} -#endif - -PyDoc_STRVAR(posix_chdir__doc__, -"chdir(path)\n\n\ -Change the current working directory to the specified path."); - -static PyObject * -posix_chdir(PyObject *self, PyObject *args) -{ -#ifdef MS_WINDOWS -# ifdef MS_XBOX - Py_INCREF(Py_None); - return Py_None; -# else - return posix_1str(args, "et:chdir", chdir, "U:chdir", _wchdir); -# endif -#elif defined(PYOS_OS2) && defined(PYCC_GCC) - return posix_1str(args, "et:chdir", _chdir2, NULL, NULL); -#elif defined(__VMS) - return posix_1str(args, "et:chdir", (int (*)(const char *))chdir, - NULL, NULL); -#else - return posix_1str(args, "et:chdir", chdir, NULL, NULL); -#endif -} - -#ifdef HAVE_FCHDIR -PyDoc_STRVAR(posix_fchdir__doc__, -"fchdir(fildes)\n\n\ -Change to the directory of the given file descriptor. fildes must be\n\ -opened on a directory, not a file."); - -static PyObject * -posix_fchdir(PyObject *self, PyObject *fdobj) -{ - return posix_fildes(fdobj, fchdir); -} -#endif /* HAVE_FCHDIR */ - - -PyDoc_STRVAR(posix_chmod__doc__, -"chmod(path, mode)\n\n\ -Change the access permissions of a file."); - -static PyObject * -posix_chmod(PyObject *self, PyObject *args) -{ - char *path = NULL; - int i; - int res; -#ifdef Py_WIN_WIDE_FILENAMES - if (unicode_file_names()) { - PyUnicodeObject *po; - if (PyArg_ParseTuple(args, "Ui|:chmod", &po, &i)) { - Py_BEGIN_ALLOW_THREADS - res = _wchmod(PyUnicode_AS_UNICODE(po), i); - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error_with_unicode_filename( - PyUnicode_AS_UNICODE(po)); - Py_INCREF(Py_None); - return Py_None; - } - /* Drop the argument parsing error as narrow strings - are also valid. */ - PyErr_Clear(); - } -#endif /* Py_WIN_WIDE_FILENAMES */ - if (!PyArg_ParseTuple(args, "eti:chmod", Py_FileSystemDefaultEncoding, - &path, &i)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = chmod(path, i); - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error_with_allocated_filename(path); - PyMem_Free(path); - Py_INCREF(Py_None); - return Py_None; -} - - -#ifdef HAVE_CHROOT -PyDoc_STRVAR(posix_chroot__doc__, -"chroot(path)\n\n\ -Change root directory to path."); - -static PyObject * -posix_chroot(PyObject *self, PyObject *args) -{ - return posix_1str(args, "et:chroot", chroot, NULL, NULL); -} -#endif - -#ifdef HAVE_FSYNC -PyDoc_STRVAR(posix_fsync__doc__, -"fsync(fildes)\n\n\ -force write of file with filedescriptor to disk."); - -static PyObject * -posix_fsync(PyObject *self, PyObject *fdobj) -{ - return posix_fildes(fdobj, fsync); -} -#endif /* HAVE_FSYNC */ - -#ifdef HAVE_FDATASYNC - -#ifdef __hpux -extern int fdatasync(int); /* On HP-UX, in libc but not in unistd.h */ -#endif - -PyDoc_STRVAR(posix_fdatasync__doc__, -"fdatasync(fildes)\n\n\ -force write of file with filedescriptor to disk.\n\ - does not force update of metadata."); - -static PyObject * -posix_fdatasync(PyObject *self, PyObject *fdobj) -{ - return posix_fildes(fdobj, fdatasync); -} -#endif /* HAVE_FDATASYNC */ - - -#ifdef HAVE_CHOWN -PyDoc_STRVAR(posix_chown__doc__, -"chown(path, uid, gid)\n\n\ -Change the owner and group id of path to the numeric uid and gid."); - -static PyObject * -posix_chown(PyObject *self, PyObject *args) -{ - char *path = NULL; - int uid, gid; - int res; - if (!PyArg_ParseTuple(args, "etii:chown", - Py_FileSystemDefaultEncoding, &path, - &uid, &gid)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = chown(path, (uid_t) uid, (gid_t) gid); - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error_with_allocated_filename(path); - PyMem_Free(path); - Py_INCREF(Py_None); - return Py_None; -} -#endif /* HAVE_CHOWN */ - -#ifdef HAVE_LCHOWN -PyDoc_STRVAR(posix_lchown__doc__, -"lchown(path, uid, gid)\n\n\ -Change the owner and group id of path to the numeric uid and gid.\n\ -This function will not follow symbolic links."); - -static PyObject * -posix_lchown(PyObject *self, PyObject *args) -{ - char *path = NULL; - int uid, gid; - int res; - if (!PyArg_ParseTuple(args, "etii:lchown", - Py_FileSystemDefaultEncoding, &path, - &uid, &gid)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = lchown(path, (uid_t) uid, (gid_t) gid); - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error_with_allocated_filename(path); - PyMem_Free(path); - Py_INCREF(Py_None); - return Py_None; -} -#endif /* HAVE_LCHOWN */ - - -#ifdef HAVE_GETCWD -PyDoc_STRVAR(posix_getcwd__doc__, -"getcwd() -> path\n\n\ -Return a string representing the current working directory."); - -static PyObject * -posix_getcwd(PyObject *self, PyObject *noargs) -{ - char buf[1026]; - char *res; - - Py_BEGIN_ALLOW_THREADS -#if defined(PYOS_OS2) && defined(PYCC_GCC) - res = _getcwd2(buf, sizeof buf); -#else - res = getcwd(buf, sizeof buf); -#endif - Py_END_ALLOW_THREADS - if (res == NULL) - return posix_error(); - return PyString_FromString(buf); -} - -#ifdef Py_USING_UNICODE -PyDoc_STRVAR(posix_getcwdu__doc__, -"getcwdu() -> path\n\n\ -Return a unicode string representing the current working directory."); - -static PyObject * -posix_getcwdu(PyObject *self, PyObject *noargs) -{ - char buf[1026]; - char *res; - -#ifdef Py_WIN_WIDE_FILENAMES - if (unicode_file_names()) { - wchar_t *wres; - wchar_t wbuf[1026]; - Py_BEGIN_ALLOW_THREADS - wres = _wgetcwd(wbuf, sizeof wbuf/ sizeof wbuf[0]); - Py_END_ALLOW_THREADS - if (wres == NULL) - return posix_error(); - return PyUnicode_FromWideChar(wbuf, wcslen(wbuf)); - } -#endif - - Py_BEGIN_ALLOW_THREADS -#if defined(PYOS_OS2) && defined(PYCC_GCC) - res = _getcwd2(buf, sizeof buf); -#else - res = getcwd(buf, sizeof buf); -#endif - Py_END_ALLOW_THREADS - if (res == NULL) - return posix_error(); - return PyUnicode_Decode(buf, strlen(buf), Py_FileSystemDefaultEncoding,"strict"); -} -#endif -#endif - - -#ifdef HAVE_LINK -PyDoc_STRVAR(posix_link__doc__, -"link(src, dst)\n\n\ -Create a hard link to a file."); - -static PyObject * -posix_link(PyObject *self, PyObject *args) -{ - return posix_2str(args, "etet:link", link, NULL, NULL); -} -#endif /* HAVE_LINK */ - - -PyDoc_STRVAR(posix_listdir__doc__, -"listdir(path) -> list_of_strings\n\n\ -Return a list containing the names of the entries in the directory.\n\ -\n\ - path: path of directory to list\n\ -\n\ -The list is in arbitrary order. It does not include the special\n\ -entries '.' and '..' even if they are present in the directory."); - -static PyObject * -posix_listdir(PyObject *self, PyObject *args) -{ - /* XXX Should redo this putting the (now four) versions of opendir - in separate files instead of having them all here... */ -#if defined(MS_WINDOWS) && !defined(HAVE_OPENDIR) - - PyObject *d, *v; - HANDLE hFindFile; - WIN32_FIND_DATA FileData; - /* MAX_PATH characters could mean a bigger encoded string */ - char namebuf[MAX_PATH*2+5]; - char *bufptr = namebuf; - int len = sizeof(namebuf)/sizeof(namebuf[0]); - -#ifdef Py_WIN_WIDE_FILENAMES - /* If on wide-character-capable OS see if argument - is Unicode and if so use wide API. */ - if (unicode_file_names()) { - PyUnicodeObject *po; - if (PyArg_ParseTuple(args, "U:listdir", &po)) { - WIN32_FIND_DATAW wFileData; - Py_UNICODE wnamebuf[MAX_PATH*2+5]; - Py_UNICODE wch; - wcsncpy(wnamebuf, PyUnicode_AS_UNICODE(po), MAX_PATH); - wnamebuf[MAX_PATH] = L'\0'; - len = wcslen(wnamebuf); - wch = (len > 0) ? wnamebuf[len-1] : L'\0'; - if (wch != L'/' && wch != L'\\' && wch != L':') - wnamebuf[len++] = L'/'; - wcscpy(wnamebuf + len, L"*.*"); - if ((d = PyList_New(0)) == NULL) - return NULL; - hFindFile = FindFirstFileW(wnamebuf, &wFileData); - if (hFindFile == INVALID_HANDLE_VALUE) { - errno = GetLastError(); - if (errno == ERROR_FILE_NOT_FOUND) { - return d; - } - Py_DECREF(d); - return win32_error_unicode("FindFirstFileW", wnamebuf); - } - do { - if (wFileData.cFileName[0] == L'.' && - (wFileData.cFileName[1] == L'\0' || - wFileData.cFileName[1] == L'.' && - wFileData.cFileName[2] == L'\0')) - continue; - v = PyUnicode_FromUnicode(wFileData.cFileName, wcslen(wFileData.cFileName)); - if (v == NULL) { - Py_DECREF(d); - d = NULL; - break; - } - if (PyList_Append(d, v) != 0) { - Py_DECREF(v); - Py_DECREF(d); - d = NULL; - break; - } - Py_DECREF(v); - } while (FindNextFileW(hFindFile, &wFileData) == TRUE); - - if (FindClose(hFindFile) == FALSE) { - Py_DECREF(d); - return win32_error_unicode("FindClose", wnamebuf); - } - return d; - } - /* Drop the argument parsing error as narrow strings - are also valid. */ - PyErr_Clear(); - } -#endif - - if (!PyArg_ParseTuple(args, "et#:listdir", - Py_FileSystemDefaultEncoding, &bufptr, &len)) - return NULL; - if (len > 0) { - char ch = namebuf[len-1]; - if (ch != SEP && ch != ALTSEP && ch != ':') - namebuf[len++] = '/'; - } - strcpy(namebuf + len, "*.*"); - - if ((d = PyList_New(0)) == NULL) - return NULL; - - hFindFile = FindFirstFile(namebuf, &FileData); - if (hFindFile == INVALID_HANDLE_VALUE) { - errno = GetLastError(); - if (errno == ERROR_FILE_NOT_FOUND) - return d; - Py_DECREF(d); - return win32_error("FindFirstFile", namebuf); - } - do { - if (FileData.cFileName[0] == '.' && - (FileData.cFileName[1] == '\0' || - FileData.cFileName[1] == '.' && - FileData.cFileName[2] == '\0')) - continue; - v = PyString_FromString(FileData.cFileName); - if (v == NULL) { - Py_DECREF(d); - d = NULL; - break; - } - if (PyList_Append(d, v) != 0) { - Py_DECREF(v); - Py_DECREF(d); - d = NULL; - break; - } - Py_DECREF(v); - } while (FindNextFile(hFindFile, &FileData) == TRUE); - - if (FindClose(hFindFile) == FALSE) { - Py_DECREF(d); - return win32_error("FindClose", namebuf); - } - - return d; - -#elif defined(PYOS_OS2) - -#ifndef MAX_PATH -#define MAX_PATH CCHMAXPATH -#endif - char *name, *pt; - int len; - PyObject *d, *v; - char namebuf[MAX_PATH+5]; - HDIR hdir = 1; - ULONG srchcnt = 1; - FILEFINDBUF3 ep; - APIRET rc; - - if (!PyArg_ParseTuple(args, "t#:listdir", &name, &len)) - return NULL; - if (len >= MAX_PATH) { - PyErr_SetString(PyExc_ValueError, "path too long"); - return NULL; - } - strcpy(namebuf, name); - for (pt = namebuf; *pt; pt++) - if (*pt == ALTSEP) - *pt = SEP; - if (namebuf[len-1] != SEP) - namebuf[len++] = SEP; - strcpy(namebuf + len, "*.*"); - - if ((d = PyList_New(0)) == NULL) - return NULL; - - rc = DosFindFirst(namebuf, /* Wildcard Pattern to Match */ - &hdir, /* Handle to Use While Search Directory */ - FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY, - &ep, sizeof(ep), /* Structure to Receive Directory Entry */ - &srchcnt, /* Max and Actual Count of Entries Per Iteration */ - FIL_STANDARD); /* Format of Entry (EAs or Not) */ - - if (rc != NO_ERROR) { - errno = ENOENT; - return posix_error_with_filename(name); - } - - if (srchcnt > 0) { /* If Directory is NOT Totally Empty, */ - do { - if (ep.achName[0] == '.' - && (ep.achName[1] == '\0' || (ep.achName[1] == '.' && ep.achName[2] == '\0'))) - continue; /* Skip Over "." and ".." Names */ - - strcpy(namebuf, ep.achName); - - /* Leave Case of Name Alone -- In Native Form */ - /* (Removed Forced Lowercasing Code) */ - - v = PyString_FromString(namebuf); - if (v == NULL) { - Py_DECREF(d); - d = NULL; - break; - } - if (PyList_Append(d, v) != 0) { - Py_DECREF(v); - Py_DECREF(d); - d = NULL; - break; - } - Py_DECREF(v); - } while (DosFindNext(hdir, &ep, sizeof(ep), &srchcnt) == NO_ERROR && srchcnt > 0); - } - - return d; -#else - - char *name = NULL; - PyObject *d, *v; - DIR *dirp; - struct dirent *ep; - int arg_is_unicode = 1; - - if (!PyArg_ParseTuple(args, "U:listdir", &v)) { - arg_is_unicode = 0; - PyErr_Clear(); - } - if (!PyArg_ParseTuple(args, "et:listdir", Py_FileSystemDefaultEncoding, &name)) - return NULL; - if ((dirp = opendir(name)) == NULL) { - return posix_error_with_allocated_filename(name); - } - if ((d = PyList_New(0)) == NULL) { - closedir(dirp); - PyMem_Free(name); - return NULL; - } - while ((ep = readdir(dirp)) != NULL) { - if (ep->d_name[0] == '.' && - (NAMLEN(ep) == 1 || - (ep->d_name[1] == '.' && NAMLEN(ep) == 2))) - continue; - v = PyString_FromStringAndSize(ep->d_name, NAMLEN(ep)); - if (v == NULL) { - Py_DECREF(d); - d = NULL; - break; - } -#ifdef Py_USING_UNICODE - if (arg_is_unicode) { - PyObject *w; - - w = PyUnicode_FromEncodedObject(v, - Py_FileSystemDefaultEncoding, - "strict"); - if (w != NULL) { - Py_DECREF(v); - v = w; - } - else { - /* fall back to the original byte string, as - discussed in patch #683592 */ - PyErr_Clear(); - } - } -#endif - if (PyList_Append(d, v) != 0) { - Py_DECREF(v); - Py_DECREF(d); - d = NULL; - break; - } - Py_DECREF(v); - } - closedir(dirp); - PyMem_Free(name); - - return d; - -#endif /* which OS */ -} /* end of posix_listdir */ - -#if defined(MS_WINDOWS) && !defined(MS_XBOX) -/* A helper function for abspath on win32 */ -static PyObject * -posix__getfullpathname(PyObject *self, PyObject *args) -{ - /* assume encoded strings wont more than double no of chars */ - char inbuf[MAX_PATH*2]; - char *inbufp = inbuf; - int insize = sizeof(inbuf)/sizeof(inbuf[0]); - char outbuf[MAX_PATH*2]; - char *temp; -#ifdef Py_WIN_WIDE_FILENAMES - if (unicode_file_names()) { - PyUnicodeObject *po; - if (PyArg_ParseTuple(args, "U|:_getfullpathname", &po)) { - Py_UNICODE woutbuf[MAX_PATH*2]; - Py_UNICODE *wtemp; - if (!GetFullPathNameW(PyUnicode_AS_UNICODE(po), - sizeof(woutbuf)/sizeof(woutbuf[0]), - woutbuf, &wtemp)) - return win32_error("GetFullPathName", ""); - return PyUnicode_FromUnicode(woutbuf, wcslen(woutbuf)); - } - /* Drop the argument parsing error as narrow strings - are also valid. */ - PyErr_Clear(); - } -#endif - if (!PyArg_ParseTuple (args, "et#:_getfullpathname", - Py_FileSystemDefaultEncoding, &inbufp, - &insize)) - return NULL; - if (!GetFullPathName(inbuf, sizeof(outbuf)/sizeof(outbuf[0]), - outbuf, &temp)) - return win32_error("GetFullPathName", inbuf); - return PyString_FromString(outbuf); -} /* end of posix__getfullpathname */ -#endif /* MS_WINDOWS */ - -PyDoc_STRVAR(posix_mkdir__doc__, -"mkdir(path [, mode=0777])\n\n\ -Create a directory."); - -static PyObject * -posix_mkdir(PyObject *self, PyObject *args) -{ - int res; - char *path = NULL; - int mode = 0777; - -#ifdef Py_WIN_WIDE_FILENAMES - if (unicode_file_names()) { - PyUnicodeObject *po; - if (PyArg_ParseTuple(args, "U|i:mkdir", &po, &mode)) { - Py_BEGIN_ALLOW_THREADS - /* PyUnicode_AS_UNICODE OK without thread lock as - it is a simple dereference. */ - res = _wmkdir(PyUnicode_AS_UNICODE(po)); - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; - } - /* Drop the argument parsing error as narrow strings - are also valid. */ - PyErr_Clear(); - } -#endif - - if (!PyArg_ParseTuple(args, "et|i:mkdir", - Py_FileSystemDefaultEncoding, &path, &mode)) - return NULL; - Py_BEGIN_ALLOW_THREADS -#if ( defined(__WATCOMC__) || defined(_MSC_VER) || defined(PYCC_VACPP) ) && !defined(__QNX__) - res = mkdir(path); -#else - res = mkdir(path, mode); -#endif - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error_with_allocated_filename(path); - PyMem_Free(path); - Py_INCREF(Py_None); - return Py_None; -} - - -#ifdef HAVE_NICE -#if defined(HAVE_BROKEN_NICE) && defined(HAVE_SYS_RESOURCE_H) -#if defined(HAVE_GETPRIORITY) && !defined(PRIO_PROCESS) -#include -#endif -#endif - -PyDoc_STRVAR(posix_nice__doc__, -"nice(inc) -> new_priority\n\n\ -Decrease the priority of process by inc and return the new priority."); - -static PyObject * -posix_nice(PyObject *self, PyObject *args) -{ - int increment, value; - - if (!PyArg_ParseTuple(args, "i:nice", &increment)) - return NULL; - - /* There are two flavours of 'nice': one that returns the new - priority (as required by almost all standards out there) and the - Linux/FreeBSD/BSDI one, which returns '0' on success and advices - the use of getpriority() to get the new priority. - - If we are of the nice family that returns the new priority, we - need to clear errno before the call, and check if errno is filled - before calling posix_error() on a returnvalue of -1, because the - -1 may be the actual new priority! */ - - errno = 0; - value = nice(increment); -#if defined(HAVE_BROKEN_NICE) && defined(HAVE_GETPRIORITY) - if (value == 0) - value = getpriority(PRIO_PROCESS, 0); -#endif - if (value == -1 && errno != 0) - /* either nice() or getpriority() returned an error */ - return posix_error(); - return PyInt_FromLong((long) value); -} -#endif /* HAVE_NICE */ - - -PyDoc_STRVAR(posix_rename__doc__, -"rename(old, new)\n\n\ -Rename a file or directory."); - -static PyObject * -posix_rename(PyObject *self, PyObject *args) -{ -#ifdef MS_WINDOWS - return posix_2str(args, "etet:rename", rename, "OO:rename", _wrename); -#else - return posix_2str(args, "etet:rename", rename, NULL, NULL); -#endif -} - - -PyDoc_STRVAR(posix_rmdir__doc__, -"rmdir(path)\n\n\ -Remove a directory."); - -static PyObject * -posix_rmdir(PyObject *self, PyObject *args) -{ -#ifdef MS_WINDOWS - return posix_1str(args, "et:rmdir", rmdir, "U:rmdir", _wrmdir); -#else - return posix_1str(args, "et:rmdir", rmdir, NULL, NULL); -#endif -} - - -PyDoc_STRVAR(posix_stat__doc__, -"stat(path) -> stat result\n\n\ -Perform a stat system call on the given path."); - -static PyObject * -posix_stat(PyObject *self, PyObject *args) -{ -#ifdef MS_WINDOWS - return posix_do_stat(self, args, "et:stat", STAT, "U:stat", _wstati64); -#else - return posix_do_stat(self, args, "et:stat", STAT, NULL, NULL); -#endif -} - - -#ifdef HAVE_SYSTEM -PyDoc_STRVAR(posix_system__doc__, -"system(command) -> exit_status\n\n\ -Execute the command (a string) in a subshell."); - -static PyObject * -posix_system(PyObject *self, PyObject *args) -{ - char *command; - long sts; - if (!PyArg_ParseTuple(args, "s:system", &command)) - return NULL; - Py_BEGIN_ALLOW_THREADS - sts = system(command); - Py_END_ALLOW_THREADS - return PyInt_FromLong(sts); -} -#endif - - -PyDoc_STRVAR(posix_umask__doc__, -"umask(new_mask) -> old_mask\n\n\ -Set the current numeric umask and return the previous umask."); - -static PyObject * -posix_umask(PyObject *self, PyObject *args) -{ - int i; - if (!PyArg_ParseTuple(args, "i:umask", &i)) - return NULL; - i = (int)umask(i); - if (i < 0) - return posix_error(); - return PyInt_FromLong((long)i); -} - - -PyDoc_STRVAR(posix_unlink__doc__, -"unlink(path)\n\n\ -Remove a file (same as remove(path))."); - -PyDoc_STRVAR(posix_remove__doc__, -"remove(path)\n\n\ -Remove a file (same as unlink(path))."); - -static PyObject * -posix_unlink(PyObject *self, PyObject *args) -{ -#ifdef MS_WINDOWS - return posix_1str(args, "et:remove", unlink, "U:remove", _wunlink); -#else - return posix_1str(args, "et:remove", unlink, NULL, NULL); -#endif -} - - -#ifdef HAVE_UNAME -PyDoc_STRVAR(posix_uname__doc__, -"uname() -> (sysname, nodename, release, version, machine)\n\n\ -Return a tuple identifying the current operating system."); - -static PyObject * -posix_uname(PyObject *self, PyObject *noargs) -{ - struct utsname u; - int res; - - Py_BEGIN_ALLOW_THREADS - res = uname(&u); - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error(); - return Py_BuildValue("(sssss)", - u.sysname, - u.nodename, - u.release, - u.version, - u.machine); -} -#endif /* HAVE_UNAME */ - -static int -extract_time(PyObject *t, long* sec, long* usec) -{ - long intval; - if (PyFloat_Check(t)) { - double tval = PyFloat_AsDouble(t); - PyObject *intobj = t->ob_type->tp_as_number->nb_int(t); - if (!intobj) - return -1; - intval = PyInt_AsLong(intobj); - Py_DECREF(intobj); - *sec = intval; - *usec = (long)((tval - intval) * 1e6); /* can't exceed 1000000 */ - if (*usec < 0) - /* If rounding gave us a negative number, - truncate. */ - *usec = 0; - return 0; - } - intval = PyInt_AsLong(t); - if (intval == -1 && PyErr_Occurred()) - return -1; - *sec = intval; - *usec = 0; - return 0; -} - -PyDoc_STRVAR(posix_utime__doc__, -"utime(path, (atime, utime))\n\ -utime(path, None)\n\n\ -Set the access and modified time of the file to the given values. If the\n\ -second form is used, set the access and modified times to the current time."); - -static PyObject * -posix_utime(PyObject *self, PyObject *args) -{ - char *path; - long atime, mtime, ausec, musec; - int res; - PyObject* arg; - -#if defined(HAVE_UTIMES) - struct timeval buf[2]; -#define ATIME buf[0].tv_sec -#define MTIME buf[1].tv_sec -#elif defined(HAVE_UTIME_H) -/* XXX should define struct utimbuf instead, above */ - struct utimbuf buf; -#define ATIME buf.actime -#define MTIME buf.modtime -#define UTIME_ARG &buf -#else /* HAVE_UTIMES */ - time_t buf[2]; -#define ATIME buf[0] -#define MTIME buf[1] -#define UTIME_ARG buf -#endif /* HAVE_UTIMES */ - - int have_unicode_filename = 0; -#ifdef Py_WIN_WIDE_FILENAMES - PyUnicodeObject *obwpath; - wchar_t *wpath; - if (unicode_file_names()) { - if (PyArg_ParseTuple(args, "UO|:utime", &obwpath, &arg)) { - wpath = PyUnicode_AS_UNICODE(obwpath); - have_unicode_filename = 1; - } else - /* Drop the argument parsing error as narrow strings - are also valid. */ - PyErr_Clear(); - } -#endif /* Py_WIN_WIDE_FILENAMES */ - - if (!have_unicode_filename && \ - !PyArg_ParseTuple(args, "sO:utime", &path, &arg)) - return NULL; - if (arg == Py_None) { - /* optional time values not given */ - Py_BEGIN_ALLOW_THREADS -#ifdef Py_WIN_WIDE_FILENAMES - if (have_unicode_filename) - res = _wutime(wpath, NULL); - else -#endif /* Py_WIN_WIDE_FILENAMES */ - res = utime(path, NULL); - Py_END_ALLOW_THREADS - } - else if (!PyTuple_Check(arg) || PyTuple_Size(arg) != 2) { - PyErr_SetString(PyExc_TypeError, - "utime() arg 2 must be a tuple (atime, mtime)"); - return NULL; - } - else { - if (extract_time(PyTuple_GET_ITEM(arg, 0), - &atime, &ausec) == -1) - return NULL; - if (extract_time(PyTuple_GET_ITEM(arg, 1), - &mtime, &musec) == -1) - return NULL; - ATIME = atime; - MTIME = mtime; -#ifdef HAVE_UTIMES - buf[0].tv_usec = ausec; - buf[1].tv_usec = musec; - Py_BEGIN_ALLOW_THREADS - res = utimes(path, buf); - Py_END_ALLOW_THREADS -#else - Py_BEGIN_ALLOW_THREADS -#ifdef Py_WIN_WIDE_FILENAMES - if (have_unicode_filename) - /* utime is OK with utimbuf, but _wutime insists - on _utimbuf (the msvc headers assert the - underscore version is ansi) */ - res = _wutime(wpath, (struct _utimbuf *)UTIME_ARG); - else -#endif /* Py_WIN_WIDE_FILENAMES */ - res = utime(path, UTIME_ARG); - Py_END_ALLOW_THREADS -#endif /* HAVE_UTIMES */ - } - if (res < 0) - return posix_error_with_filename(path); - Py_INCREF(Py_None); - return Py_None; -#undef UTIME_ARG -#undef ATIME -#undef MTIME -} - - -/* Process operations */ - -PyDoc_STRVAR(posix__exit__doc__, -"_exit(status)\n\n\ -Exit to the system with specified status, without normal exit processing."); - -static PyObject * -posix__exit(PyObject *self, PyObject *args) -{ - int sts; - if (!PyArg_ParseTuple(args, "i:_exit", &sts)) - return NULL; - _exit(sts); - return NULL; /* Make gcc -Wall happy */ -} - -#if defined(HAVE_EXECV) || defined(HAVE_SPAWNV) -static void -free_string_array(char **array, int count) -{ - int i; - for (i = 0; i < count; i++) - PyMem_Free(array[i]); - PyMem_DEL(array); -} -#endif - - -#ifdef HAVE_EXECV -PyDoc_STRVAR(posix_execv__doc__, -"execv(path, args)\n\n\ -Execute an executable path with arguments, replacing current process.\n\ -\n\ - path: path of executable file\n\ - args: tuple or list of strings"); - -static PyObject * -posix_execv(PyObject *self, PyObject *args) -{ - char *path; - PyObject *argv; - char **argvlist; - int i, argc; - PyObject *(*getitem)(PyObject *, int); - - /* execv has two arguments: (path, argv), where - argv is a list or tuple of strings. */ - - if (!PyArg_ParseTuple(args, "etO:execv", - Py_FileSystemDefaultEncoding, - &path, &argv)) - return NULL; - if (PyList_Check(argv)) { - argc = PyList_Size(argv); - getitem = PyList_GetItem; - } - else if (PyTuple_Check(argv)) { - argc = PyTuple_Size(argv); - getitem = PyTuple_GetItem; - } - else { - PyErr_SetString(PyExc_TypeError, "execv() arg 2 must be a tuple or list"); - PyMem_Free(path); - return NULL; - } - - if (argc == 0) { - PyErr_SetString(PyExc_ValueError, "execv() arg 2 must not be empty"); - PyMem_Free(path); - return NULL; - } - - argvlist = PyMem_NEW(char *, argc+1); - if (argvlist == NULL) { - PyMem_Free(path); - return PyErr_NoMemory(); - } - for (i = 0; i < argc; i++) { - if (!PyArg_Parse((*getitem)(argv, i), "et", - Py_FileSystemDefaultEncoding, - &argvlist[i])) { - free_string_array(argvlist, i); - PyErr_SetString(PyExc_TypeError, - "execv() arg 2 must contain only strings"); - PyMem_Free(path); - return NULL; - - } - } - argvlist[argc] = NULL; - -#ifdef BAD_EXEC_PROTOTYPES - execv(path, (const char **) argvlist); -#else /* BAD_EXEC_PROTOTYPES */ - execv(path, argvlist); -#endif /* BAD_EXEC_PROTOTYPES */ - - /* If we get here it's definitely an error */ - - free_string_array(argvlist, argc); - PyMem_Free(path); - return posix_error(); -} - - -PyDoc_STRVAR(posix_execve__doc__, -"execve(path, args, env)\n\n\ -Execute a path with arguments and environment, replacing current process.\n\ -\n\ - path: path of executable file\n\ - args: tuple or list of arguments\n\ - env: dictionary of strings mapping to strings"); - -static PyObject * -posix_execve(PyObject *self, PyObject *args) -{ - char *path; - PyObject *argv, *env; - char **argvlist; - char **envlist; - PyObject *key, *val, *keys=NULL, *vals=NULL; - int i, pos, argc, envc; - PyObject *(*getitem)(PyObject *, int); - int lastarg = 0; - - /* execve has three arguments: (path, argv, env), where - argv is a list or tuple of strings and env is a dictionary - like posix.environ. */ - - if (!PyArg_ParseTuple(args, "etOO:execve", - Py_FileSystemDefaultEncoding, - &path, &argv, &env)) - return NULL; - if (PyList_Check(argv)) { - argc = PyList_Size(argv); - getitem = PyList_GetItem; - } - else if (PyTuple_Check(argv)) { - argc = PyTuple_Size(argv); - getitem = PyTuple_GetItem; - } - else { - PyErr_SetString(PyExc_TypeError, - "execve() arg 2 must be a tuple or list"); - goto fail_0; - } - if (!PyMapping_Check(env)) { - PyErr_SetString(PyExc_TypeError, - "execve() arg 3 must be a mapping object"); - goto fail_0; - } - - if (argc == 0) { - PyErr_SetString(PyExc_ValueError, - "execve() arg 2 must not be empty"); - goto fail_0; - } - - argvlist = PyMem_NEW(char *, argc+1); - if (argvlist == NULL) { - PyErr_NoMemory(); - goto fail_0; - } - for (i = 0; i < argc; i++) { - if (!PyArg_Parse((*getitem)(argv, i), - "et;execve() arg 2 must contain only strings", - Py_FileSystemDefaultEncoding, - &argvlist[i])) - { - lastarg = i; - goto fail_1; - } - } - lastarg = argc; - argvlist[argc] = NULL; - - i = PyMapping_Size(env); - if (i < 0) - goto fail_1; - envlist = PyMem_NEW(char *, i + 1); - if (envlist == NULL) { - PyErr_NoMemory(); - goto fail_1; - } - envc = 0; - keys = PyMapping_Keys(env); - vals = PyMapping_Values(env); - if (!keys || !vals) - goto fail_2; - if (!PyList_Check(keys) || !PyList_Check(vals)) { - PyErr_SetString(PyExc_TypeError, - "execve(): env.keys() or env.values() is not a list"); - goto fail_2; - } - - for (pos = 0; pos < i; pos++) { - char *p, *k, *v; - size_t len; - - key = PyList_GetItem(keys, pos); - val = PyList_GetItem(vals, pos); - if (!key || !val) - goto fail_2; - - if (!PyArg_Parse( - key, - "s;execve() arg 3 contains a non-string key", - &k) || - !PyArg_Parse( - val, - "s;execve() arg 3 contains a non-string value", - &v)) - { - goto fail_2; - } - -#if defined(PYOS_OS2) - /* Omit Pseudo-Env Vars that Would Confuse Programs if Passed On */ - if (stricmp(k, "BEGINLIBPATH") != 0 && stricmp(k, "ENDLIBPATH") != 0) { -#endif - len = PyString_Size(key) + PyString_Size(val) + 2; - p = PyMem_NEW(char, len); - if (p == NULL) { - PyErr_NoMemory(); - goto fail_2; - } - PyOS_snprintf(p, len, "%s=%s", k, v); - envlist[envc++] = p; -#if defined(PYOS_OS2) - } -#endif - } - envlist[envc] = 0; - - -#ifdef BAD_EXEC_PROTOTYPES - execve(path, (const char **)argvlist, envlist); -#else /* BAD_EXEC_PROTOTYPES */ - execve(path, argvlist, envlist); -#endif /* BAD_EXEC_PROTOTYPES */ - - /* If we get here it's definitely an error */ - - (void) posix_error(); - - fail_2: - while (--envc >= 0) - PyMem_DEL(envlist[envc]); - PyMem_DEL(envlist); - fail_1: - free_string_array(argvlist, lastarg); - Py_XDECREF(vals); - Py_XDECREF(keys); - fail_0: - PyMem_Free(path); - return NULL; -} -#endif /* HAVE_EXECV */ - - -#ifdef HAVE_SPAWNV -PyDoc_STRVAR(posix_spawnv__doc__, -"spawnv(mode, path, args)\n\n\ -Execute the program 'path' in a new process.\n\ -\n\ - mode: mode of process creation\n\ - path: path of executable file\n\ - args: tuple or list of strings"); - -static PyObject * -posix_spawnv(PyObject *self, PyObject *args) -{ - char *path; - PyObject *argv; - char **argvlist; - int mode, i, argc; - Py_intptr_t spawnval; - PyObject *(*getitem)(PyObject *, int); - - /* spawnv has three arguments: (mode, path, argv), where - argv is a list or tuple of strings. */ - - if (!PyArg_ParseTuple(args, "ietO:spawnv", &mode, - Py_FileSystemDefaultEncoding, - &path, &argv)) - return NULL; - if (PyList_Check(argv)) { - argc = PyList_Size(argv); - getitem = PyList_GetItem; - } - else if (PyTuple_Check(argv)) { - argc = PyTuple_Size(argv); - getitem = PyTuple_GetItem; - } - else { - PyErr_SetString(PyExc_TypeError, - "spawnv() arg 2 must be a tuple or list"); - PyMem_Free(path); - return NULL; - } - - argvlist = PyMem_NEW(char *, argc+1); - if (argvlist == NULL) { - PyMem_Free(path); - return PyErr_NoMemory(); - } - for (i = 0; i < argc; i++) { - if (!PyArg_Parse((*getitem)(argv, i), "et", - Py_FileSystemDefaultEncoding, - &argvlist[i])) { - free_string_array(argvlist, i); - PyErr_SetString( - PyExc_TypeError, - "spawnv() arg 2 must contain only strings"); - PyMem_Free(path); - return NULL; - } - } - argvlist[argc] = NULL; - -#if defined(PYOS_OS2) && defined(PYCC_GCC) - Py_BEGIN_ALLOW_THREADS - spawnval = spawnv(mode, path, argvlist); - Py_END_ALLOW_THREADS -#else - if (mode == _OLD_P_OVERLAY) - mode = _P_OVERLAY; - - Py_BEGIN_ALLOW_THREADS - spawnval = _spawnv(mode, path, argvlist); - Py_END_ALLOW_THREADS -#endif - - free_string_array(argvlist, argc); - PyMem_Free(path); - - if (spawnval == -1) - return posix_error(); - else -#if SIZEOF_LONG == SIZEOF_VOID_P - return Py_BuildValue("l", (long) spawnval); -#else - return Py_BuildValue("L", (PY_LONG_LONG) spawnval); -#endif -} - - -PyDoc_STRVAR(posix_spawnve__doc__, -"spawnve(mode, path, args, env)\n\n\ -Execute the program 'path' in a new process.\n\ -\n\ - mode: mode of process creation\n\ - path: path of executable file\n\ - args: tuple or list of arguments\n\ - env: dictionary of strings mapping to strings"); - -static PyObject * -posix_spawnve(PyObject *self, PyObject *args) -{ - char *path; - PyObject *argv, *env; - char **argvlist; - char **envlist; - PyObject *key, *val, *keys=NULL, *vals=NULL, *res=NULL; - int mode, i, pos, argc, envc; - Py_intptr_t spawnval; - PyObject *(*getitem)(PyObject *, int); - int lastarg = 0; - - /* spawnve has four arguments: (mode, path, argv, env), where - argv is a list or tuple of strings and env is a dictionary - like posix.environ. */ - - if (!PyArg_ParseTuple(args, "ietOO:spawnve", &mode, - Py_FileSystemDefaultEncoding, - &path, &argv, &env)) - return NULL; - if (PyList_Check(argv)) { - argc = PyList_Size(argv); - getitem = PyList_GetItem; - } - else if (PyTuple_Check(argv)) { - argc = PyTuple_Size(argv); - getitem = PyTuple_GetItem; - } - else { - PyErr_SetString(PyExc_TypeError, - "spawnve() arg 2 must be a tuple or list"); - goto fail_0; - } - if (!PyMapping_Check(env)) { - PyErr_SetString(PyExc_TypeError, - "spawnve() arg 3 must be a mapping object"); - goto fail_0; - } - - argvlist = PyMem_NEW(char *, argc+1); - if (argvlist == NULL) { - PyErr_NoMemory(); - goto fail_0; - } - for (i = 0; i < argc; i++) { - if (!PyArg_Parse((*getitem)(argv, i), - "et;spawnve() arg 2 must contain only strings", - Py_FileSystemDefaultEncoding, - &argvlist[i])) - { - lastarg = i; - goto fail_1; - } - } - lastarg = argc; - argvlist[argc] = NULL; - - i = PyMapping_Size(env); - if (i < 0) - goto fail_1; - envlist = PyMem_NEW(char *, i + 1); - if (envlist == NULL) { - PyErr_NoMemory(); - goto fail_1; - } - envc = 0; - keys = PyMapping_Keys(env); - vals = PyMapping_Values(env); - if (!keys || !vals) - goto fail_2; - if (!PyList_Check(keys) || !PyList_Check(vals)) { - PyErr_SetString(PyExc_TypeError, - "spawnve(): env.keys() or env.values() is not a list"); - goto fail_2; - } - - for (pos = 0; pos < i; pos++) { - char *p, *k, *v; - size_t len; - - key = PyList_GetItem(keys, pos); - val = PyList_GetItem(vals, pos); - if (!key || !val) - goto fail_2; - - if (!PyArg_Parse( - key, - "s;spawnve() arg 3 contains a non-string key", - &k) || - !PyArg_Parse( - val, - "s;spawnve() arg 3 contains a non-string value", - &v)) - { - goto fail_2; - } - len = PyString_Size(key) + PyString_Size(val) + 2; - p = PyMem_NEW(char, len); - if (p == NULL) { - PyErr_NoMemory(); - goto fail_2; - } - PyOS_snprintf(p, len, "%s=%s", k, v); - envlist[envc++] = p; - } - envlist[envc] = 0; - -#if defined(PYOS_OS2) && defined(PYCC_GCC) - Py_BEGIN_ALLOW_THREADS - spawnval = spawnve(mode, path, argvlist, envlist); - Py_END_ALLOW_THREADS -#else - if (mode == _OLD_P_OVERLAY) - mode = _P_OVERLAY; - - Py_BEGIN_ALLOW_THREADS - spawnval = _spawnve(mode, path, argvlist, envlist); - Py_END_ALLOW_THREADS -#endif - - if (spawnval == -1) - (void) posix_error(); - else -#if SIZEOF_LONG == SIZEOF_VOID_P - res = Py_BuildValue("l", (long) spawnval); -#else - res = Py_BuildValue("L", (PY_LONG_LONG) spawnval); -#endif - - fail_2: - while (--envc >= 0) - PyMem_DEL(envlist[envc]); - PyMem_DEL(envlist); - fail_1: - free_string_array(argvlist, lastarg); - Py_XDECREF(vals); - Py_XDECREF(keys); - fail_0: - PyMem_Free(path); - return res; -} -#endif /* HAVE_SPAWNV */ - - -#ifdef HAVE_FORK1 -PyDoc_STRVAR(posix_fork1__doc__, -"fork1() -> pid\n\n\ -Fork a child process with a single multiplexed (i.e., not bound) thread.\n\ -\n\ -Return 0 to child process and PID of child to parent process."); - -static PyObject * -posix_fork1(PyObject *self, PyObject *noargs) -{ - int pid = fork1(); - if (pid == -1) - return posix_error(); - PyOS_AfterFork(); - return PyInt_FromLong((long)pid); -} -#endif - - -#ifdef HAVE_FORK -PyDoc_STRVAR(posix_fork__doc__, -"fork() -> pid\n\n\ -Fork a child process.\n\ -Return 0 to child process and PID of child to parent process."); - -static PyObject * -posix_fork(PyObject *self, PyObject *noargs) -{ - int pid = fork(); - if (pid == -1) - return posix_error(); - if (pid == 0) - PyOS_AfterFork(); - return PyInt_FromLong((long)pid); -} -#endif - -/* AIX uses /dev/ptc but is otherwise the same as /dev/ptmx */ -/* IRIX has both /dev/ptc and /dev/ptmx, use ptmx */ -#if defined(HAVE_DEV_PTC) && !defined(HAVE_DEV_PTMX) -#define DEV_PTY_FILE "/dev/ptc" -#define HAVE_DEV_PTMX -#else -#define DEV_PTY_FILE "/dev/ptmx" -#endif - -#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) || defined(HAVE_DEV_PTMX) -#ifdef HAVE_PTY_H -#include -#else -#ifdef HAVE_LIBUTIL_H -#include -#endif /* HAVE_LIBUTIL_H */ -#endif /* HAVE_PTY_H */ -#ifdef HAVE_STROPTS_H -#include -#endif -#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) || defined(HAVE_DEV_PTMX */ - -#if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX) -PyDoc_STRVAR(posix_openpty__doc__, -"openpty() -> (master_fd, slave_fd)\n\n\ -Open a pseudo-terminal, returning open fd's for both master and slave end.\n"); - -static PyObject * -posix_openpty(PyObject *self, PyObject *noargs) -{ - int master_fd, slave_fd; -#ifndef HAVE_OPENPTY - char * slave_name; -#endif -#if defined(HAVE_DEV_PTMX) && !defined(HAVE_OPENPTY) && !defined(HAVE__GETPTY) - PyOS_sighandler_t sig_saved; -#ifdef sun - extern char *ptsname(); -#endif -#endif - -#ifdef HAVE_OPENPTY - if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0) - return posix_error(); -#elif defined(HAVE__GETPTY) - slave_name = _getpty(&master_fd, O_RDWR, 0666, 0); - if (slave_name == NULL) - return posix_error(); - - slave_fd = open(slave_name, O_RDWR); - if (slave_fd < 0) - return posix_error(); -#else - master_fd = open(DEV_PTY_FILE, O_RDWR | O_NOCTTY); /* open master */ - if (master_fd < 0) - return posix_error(); - sig_saved = signal(SIGCHLD, SIG_DFL); - /* change permission of slave */ - if (grantpt(master_fd) < 0) { - signal(SIGCHLD, sig_saved); - return posix_error(); - } - /* unlock slave */ - if (unlockpt(master_fd) < 0) { - signal(SIGCHLD, sig_saved); - return posix_error(); - } - signal(SIGCHLD, sig_saved); - slave_name = ptsname(master_fd); /* get name of slave */ - if (slave_name == NULL) - return posix_error(); - slave_fd = open(slave_name, O_RDWR | O_NOCTTY); /* open slave */ - if (slave_fd < 0) - return posix_error(); -#if !defined(__CYGWIN__) && !defined(HAVE_DEV_PTC) - ioctl(slave_fd, I_PUSH, "ptem"); /* push ptem */ - ioctl(slave_fd, I_PUSH, "ldterm"); /* push ldterm */ -#ifndef __hpux - ioctl(slave_fd, I_PUSH, "ttcompat"); /* push ttcompat */ -#endif /* __hpux */ -#endif /* HAVE_CYGWIN */ -#endif /* HAVE_OPENPTY */ - - return Py_BuildValue("(ii)", master_fd, slave_fd); - -} -#endif /* defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX) */ - -#ifdef HAVE_FORKPTY -PyDoc_STRVAR(posix_forkpty__doc__, -"forkpty() -> (pid, master_fd)\n\n\ -Fork a new process with a new pseudo-terminal as controlling tty.\n\n\ -Like fork(), return 0 as pid to child process, and PID of child to parent.\n\ -To both, return fd of newly opened pseudo-terminal.\n"); - -static PyObject * -posix_forkpty(PyObject *self, PyObject *noargs) -{ - int master_fd, pid; - - pid = forkpty(&master_fd, NULL, NULL, NULL); - if (pid == -1) - return posix_error(); - if (pid == 0) - PyOS_AfterFork(); - return Py_BuildValue("(ii)", pid, master_fd); -} -#endif - -#ifdef HAVE_GETEGID -PyDoc_STRVAR(posix_getegid__doc__, -"getegid() -> egid\n\n\ -Return the current process's effective group id."); - -static PyObject * -posix_getegid(PyObject *self, PyObject *noargs) -{ - return PyInt_FromLong((long)getegid()); -} -#endif - - -#ifdef HAVE_GETEUID -PyDoc_STRVAR(posix_geteuid__doc__, -"geteuid() -> euid\n\n\ -Return the current process's effective user id."); - -static PyObject * -posix_geteuid(PyObject *self, PyObject *noargs) -{ - return PyInt_FromLong((long)geteuid()); -} -#endif - - -#ifdef HAVE_GETGID -PyDoc_STRVAR(posix_getgid__doc__, -"getgid() -> gid\n\n\ -Return the current process's group id."); - -static PyObject * -posix_getgid(PyObject *self, PyObject *noargs) -{ - return PyInt_FromLong((long)getgid()); -} -#endif - - -PyDoc_STRVAR(posix_getpid__doc__, -"getpid() -> pid\n\n\ -Return the current process id"); - -static PyObject * -posix_getpid(PyObject *self, PyObject *noargs) -{ -#ifdef MS_XBOX - return PyInt_FromLong(0); -#else - return PyInt_FromLong((long)getpid()); -#endif -} - - -#ifdef HAVE_GETGROUPS -PyDoc_STRVAR(posix_getgroups__doc__, -"getgroups() -> list of group IDs\n\n\ -Return list of supplemental group IDs for the process."); - -static PyObject * -posix_getgroups(PyObject *self, PyObject *noargs) -{ - PyObject *result = NULL; - -#ifdef NGROUPS_MAX -#define MAX_GROUPS NGROUPS_MAX -#else - /* defined to be 16 on Solaris7, so this should be a small number */ -#define MAX_GROUPS 64 -#endif - gid_t grouplist[MAX_GROUPS]; - int n; - - n = getgroups(MAX_GROUPS, grouplist); - if (n < 0) - posix_error(); - else { - result = PyList_New(n); - if (result != NULL) { - int i; - for (i = 0; i < n; ++i) { - PyObject *o = PyInt_FromLong((long)grouplist[i]); - if (o == NULL) { - Py_DECREF(result); - result = NULL; - break; - } - PyList_SET_ITEM(result, i, o); - } - } - } - - return result; -} -#endif - -#ifdef HAVE_GETPGID -PyDoc_STRVAR(posix_getpgid__doc__, -"getpgid(pid) -> pgid\n\n\ -Call the system call getpgid()."); - -static PyObject * -posix_getpgid(PyObject *self, PyObject *args) -{ - int pid, pgid; - if (!PyArg_ParseTuple(args, "i:getpgid", &pid)) - return NULL; - pgid = getpgid(pid); - if (pgid < 0) - return posix_error(); - return PyInt_FromLong((long)pgid); -} -#endif /* HAVE_GETPGID */ - - -#ifdef HAVE_GETPGRP -PyDoc_STRVAR(posix_getpgrp__doc__, -"getpgrp() -> pgrp\n\n\ -Return the current process group id."); - -static PyObject * -posix_getpgrp(PyObject *self, PyObject *noargs) -{ -#ifdef GETPGRP_HAVE_ARG - return PyInt_FromLong((long)getpgrp(0)); -#else /* GETPGRP_HAVE_ARG */ - return PyInt_FromLong((long)getpgrp()); -#endif /* GETPGRP_HAVE_ARG */ -} -#endif /* HAVE_GETPGRP */ - - -#ifdef HAVE_SETPGRP -PyDoc_STRVAR(posix_setpgrp__doc__, -"setpgrp()\n\n\ -Make this process a session leader."); - -static PyObject * -posix_setpgrp(PyObject *self, PyObject *noargs) -{ -#ifdef SETPGRP_HAVE_ARG - if (setpgrp(0, 0) < 0) -#else /* SETPGRP_HAVE_ARG */ - if (setpgrp() < 0) -#endif /* SETPGRP_HAVE_ARG */ - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} - -#endif /* HAVE_SETPGRP */ - -#ifdef HAVE_GETPPID -PyDoc_STRVAR(posix_getppid__doc__, -"getppid() -> ppid\n\n\ -Return the parent's process id."); - -static PyObject * -posix_getppid(PyObject *self, PyObject *noargs) -{ - return PyInt_FromLong((long)getppid()); -} -#endif - - -#ifdef HAVE_GETLOGIN -PyDoc_STRVAR(posix_getlogin__doc__, -"getlogin() -> string\n\n\ -Return the actual login name."); - -static PyObject * -posix_getlogin(PyObject *self, PyObject *noargs) -{ - PyObject *result = NULL; - char *name; - int old_errno = errno; - - errno = 0; - name = getlogin(); - if (name == NULL) { - if (errno) - posix_error(); - else - PyErr_SetString(PyExc_OSError, - "unable to determine login name"); - } - else - result = PyString_FromString(name); - errno = old_errno; - - return result; -} -#endif - -#ifdef HAVE_GETUID -PyDoc_STRVAR(posix_getuid__doc__, -"getuid() -> uid\n\n\ -Return the current process's user id."); - -static PyObject * -posix_getuid(PyObject *self, PyObject *noargs) -{ - return PyInt_FromLong((long)getuid()); -} -#endif - - -#ifdef HAVE_KILL -PyDoc_STRVAR(posix_kill__doc__, -"kill(pid, sig)\n\n\ -Kill a process with a signal."); - -static PyObject * -posix_kill(PyObject *self, PyObject *args) -{ - int pid, sig; - if (!PyArg_ParseTuple(args, "ii:kill", &pid, &sig)) - return NULL; -#if defined(PYOS_OS2) && !defined(PYCC_GCC) - if (sig == XCPT_SIGNAL_INTR || sig == XCPT_SIGNAL_BREAK) { - APIRET rc; - if ((rc = DosSendSignalException(pid, sig)) != NO_ERROR) - return os2_error(rc); - - } else if (sig == XCPT_SIGNAL_KILLPROC) { - APIRET rc; - if ((rc = DosKillProcess(DKP_PROCESS, pid)) != NO_ERROR) - return os2_error(rc); - - } else - return NULL; /* Unrecognized Signal Requested */ -#else - if (kill(pid, sig) == -1) - return posix_error(); -#endif - Py_INCREF(Py_None); - return Py_None; -} -#endif - -#ifdef HAVE_KILLPG -PyDoc_STRVAR(posix_killpg__doc__, -"killpg(pgid, sig)\n\n\ -Kill a process group with a signal."); - -static PyObject * -posix_killpg(PyObject *self, PyObject *args) -{ - int pgid, sig; - if (!PyArg_ParseTuple(args, "ii:killpg", &pgid, &sig)) - return NULL; - if (killpg(pgid, sig) == -1) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} -#endif - -#ifdef HAVE_PLOCK - -#ifdef HAVE_SYS_LOCK_H -#include -#endif - -PyDoc_STRVAR(posix_plock__doc__, -"plock(op)\n\n\ -Lock program segments into memory."); - -static PyObject * -posix_plock(PyObject *self, PyObject *args) -{ - int op; - if (!PyArg_ParseTuple(args, "i:plock", &op)) - return NULL; - if (plock(op) == -1) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} -#endif - - -#ifdef HAVE_POPEN -PyDoc_STRVAR(posix_popen__doc__, -"popen(command [, mode='r' [, bufsize]]) -> pipe\n\n\ -Open a pipe to/from a command returning a file object."); - -#if defined(PYOS_OS2) -#if defined(PYCC_VACPP) -static int -async_system(const char *command) -{ - char *p, errormsg[256], args[1024]; - RESULTCODES rcodes; - APIRET rc; - char *shell = Py_GETENV("COMSPEC"); - if (!shell) - shell = "cmd"; - - strcpy(args, shell); - p = &args[ strlen(args)+1 ]; - strcpy(p, "/c "); - strcat(p, command); - p += strlen(p) + 1; - *p = '\0'; - - rc = DosExecPgm(errormsg, sizeof(errormsg), - EXEC_ASYNC, /* Execute Async w/o Wait for Results */ - args, - NULL, /* Inherit Parent's Environment */ - &rcodes, shell); - return rc; -} - -static FILE * -popen(const char *command, const char *mode, int pipesize, int *err) -{ - HFILE rhan, whan; - FILE *retfd = NULL; - APIRET rc = DosCreatePipe(&rhan, &whan, pipesize); - - if (rc != NO_ERROR) { - *err = rc; - return NULL; /* ERROR - Unable to Create Anon Pipe */ - } - - if (strchr(mode, 'r') != NULL) { /* Treat Command as a Data Source */ - int oldfd = dup(1); /* Save STDOUT Handle in Another Handle */ - - DosEnterCritSec(); /* Stop Other Threads While Changing Handles */ - close(1); /* Make STDOUT Available for Reallocation */ - - if (dup2(whan, 1) == 0) { /* Connect STDOUT to Pipe Write Side */ - DosClose(whan); /* Close Now-Unused Pipe Write Handle */ - - rc = async_system(command); - } - - dup2(oldfd, 1); /* Reconnect STDOUT to Original Handle */ - DosExitCritSec(); /* Now Allow Other Threads to Run */ - - if (rc == NO_ERROR) - retfd = fdopen(rhan, mode); /* And Return Pipe Read Handle */ - - close(oldfd); /* And Close Saved STDOUT Handle */ - return retfd; /* Return fd of Pipe or NULL if Error */ - - } else if (strchr(mode, 'w')) { /* Treat Command as a Data Sink */ - int oldfd = dup(0); /* Save STDIN Handle in Another Handle */ - - DosEnterCritSec(); /* Stop Other Threads While Changing Handles */ - close(0); /* Make STDIN Available for Reallocation */ - - if (dup2(rhan, 0) == 0) { /* Connect STDIN to Pipe Read Side */ - DosClose(rhan); /* Close Now-Unused Pipe Read Handle */ - - rc = async_system(command); - } - - dup2(oldfd, 0); /* Reconnect STDIN to Original Handle */ - DosExitCritSec(); /* Now Allow Other Threads to Run */ - - if (rc == NO_ERROR) - retfd = fdopen(whan, mode); /* And Return Pipe Write Handle */ - - close(oldfd); /* And Close Saved STDIN Handle */ - return retfd; /* Return fd of Pipe or NULL if Error */ - - } else { - *err = ERROR_INVALID_ACCESS; - return NULL; /* ERROR - Invalid Mode (Neither Read nor Write) */ - } -} - -static PyObject * -posix_popen(PyObject *self, PyObject *args) -{ - char *name; - char *mode = "r"; - int err, bufsize = -1; - FILE *fp; - PyObject *f; - if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode, &bufsize)) - return NULL; - Py_BEGIN_ALLOW_THREADS - fp = popen(name, mode, (bufsize > 0) ? bufsize : 4096, &err); - Py_END_ALLOW_THREADS - if (fp == NULL) - return os2_error(err); - - f = PyFile_FromFile(fp, name, mode, fclose); - if (f != NULL) - PyFile_SetBufSize(f, bufsize); - return f; -} - -#elif defined(PYCC_GCC) - -/* standard posix version of popen() support */ -static PyObject * -posix_popen(PyObject *self, PyObject *args) -{ - char *name; - char *mode = "r"; - int bufsize = -1; - FILE *fp; - PyObject *f; - if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode, &bufsize)) - return NULL; - Py_BEGIN_ALLOW_THREADS - fp = popen(name, mode); - Py_END_ALLOW_THREADS - if (fp == NULL) - return posix_error(); - f = PyFile_FromFile(fp, name, mode, pclose); - if (f != NULL) - PyFile_SetBufSize(f, bufsize); - return f; -} - -/* fork() under OS/2 has lots'o'warts - * EMX supports pipe() and spawn*() so we can synthesize popen[234]() - * most of this code is a ripoff of the win32 code, but using the - * capabilities of EMX's C library routines - */ - -/* These tell _PyPopen() whether to return 1, 2, or 3 file objects. */ -#define POPEN_1 1 -#define POPEN_2 2 -#define POPEN_3 3 -#define POPEN_4 4 - -static PyObject *_PyPopen(char *, int, int, int); -static int _PyPclose(FILE *file); - -/* - * Internal dictionary mapping popen* file pointers to process handles, - * for use when retrieving the process exit code. See _PyPclose() below - * for more information on this dictionary's use. - */ -static PyObject *_PyPopenProcs = NULL; - -/* os2emx version of popen2() - * - * The result of this function is a pipe (file) connected to the - * process's stdin, and a pipe connected to the process's stdout. - */ - -static PyObject * -os2emx_popen2(PyObject *self, PyObject *args) -{ - PyObject *f; - int tm=0; - - char *cmdstring; - char *mode = "t"; - int bufsize = -1; - if (!PyArg_ParseTuple(args, "s|si:popen2", &cmdstring, &mode, &bufsize)) - return NULL; - - if (*mode == 't') - tm = O_TEXT; - else if (*mode != 'b') { - PyErr_SetString(PyExc_ValueError, "mode must be 't' or 'b'"); - return NULL; - } else - tm = O_BINARY; - - f = _PyPopen(cmdstring, tm, POPEN_2, bufsize); - - return f; -} - -/* - * Variation on os2emx.popen2 - * - * The result of this function is 3 pipes - the process's stdin, - * stdout and stderr - */ - -static PyObject * -os2emx_popen3(PyObject *self, PyObject *args) -{ - PyObject *f; - int tm = 0; - - char *cmdstring; - char *mode = "t"; - int bufsize = -1; - if (!PyArg_ParseTuple(args, "s|si:popen3", &cmdstring, &mode, &bufsize)) - return NULL; - - if (*mode == 't') - tm = O_TEXT; - else if (*mode != 'b') { - PyErr_SetString(PyExc_ValueError, "mode must be 't' or 'b'"); - return NULL; - } else - tm = O_BINARY; - - f = _PyPopen(cmdstring, tm, POPEN_3, bufsize); - - return f; -} - -/* - * Variation on os2emx.popen2 - * - * The result of this function is 2 pipes - the processes stdin, - * and stdout+stderr combined as a single pipe. - */ - -static PyObject * -os2emx_popen4(PyObject *self, PyObject *args) -{ - PyObject *f; - int tm = 0; - - char *cmdstring; - char *mode = "t"; - int bufsize = -1; - if (!PyArg_ParseTuple(args, "s|si:popen4", &cmdstring, &mode, &bufsize)) - return NULL; - - if (*mode == 't') - tm = O_TEXT; - else if (*mode != 'b') { - PyErr_SetString(PyExc_ValueError, "mode must be 't' or 'b'"); - return NULL; - } else - tm = O_BINARY; - - f = _PyPopen(cmdstring, tm, POPEN_4, bufsize); - - return f; -} - -/* a couple of structures for convenient handling of multiple - * file handles and pipes - */ -struct file_ref -{ - int handle; - int flags; -}; - -struct pipe_ref -{ - int rd; - int wr; -}; - -/* The following code is derived from the win32 code */ - -static PyObject * -_PyPopen(char *cmdstring, int mode, int n, int bufsize) -{ - struct file_ref stdio[3]; - struct pipe_ref p_fd[3]; - FILE *p_s[3]; - int file_count, i, pipe_err, pipe_pid; - char *shell, *sh_name, *opt, *rd_mode, *wr_mode; - PyObject *f, *p_f[3]; - - /* file modes for subsequent fdopen's on pipe handles */ - if (mode == O_TEXT) - { - rd_mode = "rt"; - wr_mode = "wt"; - } - else - { - rd_mode = "rb"; - wr_mode = "wb"; - } - - /* prepare shell references */ - if ((shell = Py_GETENV("EMXSHELL")) == NULL) - if ((shell = Py_GETENV("COMSPEC")) == NULL) - { - errno = ENOENT; - return posix_error(); - } - - sh_name = _getname(shell); - if (stricmp(sh_name, "cmd.exe") == 0 || stricmp(sh_name, "4os2.exe") == 0) - opt = "/c"; - else - opt = "-c"; - - /* save current stdio fds + their flags, and set not inheritable */ - i = pipe_err = 0; - while (pipe_err >= 0 && i < 3) - { - pipe_err = stdio[i].handle = dup(i); - stdio[i].flags = fcntl(i, F_GETFD, 0); - fcntl(stdio[i].handle, F_SETFD, stdio[i].flags | FD_CLOEXEC); - i++; - } - if (pipe_err < 0) - { - /* didn't get them all saved - clean up and bail out */ - int saved_err = errno; - while (i-- > 0) - { - close(stdio[i].handle); - } - errno = saved_err; - return posix_error(); - } - - /* create pipe ends */ - file_count = 2; - if (n == POPEN_3) - file_count = 3; - i = pipe_err = 0; - while ((pipe_err == 0) && (i < file_count)) - pipe_err = pipe((int *)&p_fd[i++]); - if (pipe_err < 0) - { - /* didn't get them all made - clean up and bail out */ - while (i-- > 0) - { - close(p_fd[i].wr); - close(p_fd[i].rd); - } - errno = EPIPE; - return posix_error(); - } - - /* change the actual standard IO streams over temporarily, - * making the retained pipe ends non-inheritable - */ - pipe_err = 0; - - /* - stdin */ - if (dup2(p_fd[0].rd, 0) == 0) - { - close(p_fd[0].rd); - i = fcntl(p_fd[0].wr, F_GETFD, 0); - fcntl(p_fd[0].wr, F_SETFD, i | FD_CLOEXEC); - if ((p_s[0] = fdopen(p_fd[0].wr, wr_mode)) == NULL) - { - close(p_fd[0].wr); - pipe_err = -1; - } - } - else - { - pipe_err = -1; - } - - /* - stdout */ - if (pipe_err == 0) - { - if (dup2(p_fd[1].wr, 1) == 1) - { - close(p_fd[1].wr); - i = fcntl(p_fd[1].rd, F_GETFD, 0); - fcntl(p_fd[1].rd, F_SETFD, i | FD_CLOEXEC); - if ((p_s[1] = fdopen(p_fd[1].rd, rd_mode)) == NULL) - { - close(p_fd[1].rd); - pipe_err = -1; - } - } - else - { - pipe_err = -1; - } - } - - /* - stderr, as required */ - if (pipe_err == 0) - switch (n) - { - case POPEN_3: - { - if (dup2(p_fd[2].wr, 2) == 2) - { - close(p_fd[2].wr); - i = fcntl(p_fd[2].rd, F_GETFD, 0); - fcntl(p_fd[2].rd, F_SETFD, i | FD_CLOEXEC); - if ((p_s[2] = fdopen(p_fd[2].rd, rd_mode)) == NULL) - { - close(p_fd[2].rd); - pipe_err = -1; - } - } - else - { - pipe_err = -1; - } - break; - } - - case POPEN_4: - { - if (dup2(1, 2) != 2) - { - pipe_err = -1; - } - break; - } - } - - /* spawn the child process */ - if (pipe_err == 0) - { - pipe_pid = spawnlp(P_NOWAIT, shell, shell, opt, cmdstring, (char *)0); - if (pipe_pid == -1) - { - pipe_err = -1; - } - else - { - /* save the PID into the FILE structure - * NOTE: this implementation doesn't actually - * take advantage of this, but do it for - * completeness - AIM Apr01 - */ - for (i = 0; i < file_count; i++) - p_s[i]->_pid = pipe_pid; - } - } - - /* reset standard IO to normal */ - for (i = 0; i < 3; i++) - { - dup2(stdio[i].handle, i); - fcntl(i, F_SETFD, stdio[i].flags); - close(stdio[i].handle); - } - - /* if any remnant problems, clean up and bail out */ - if (pipe_err < 0) - { - for (i = 0; i < 3; i++) - { - close(p_fd[i].rd); - close(p_fd[i].wr); - } - errno = EPIPE; - return posix_error_with_filename(cmdstring); - } - - /* build tuple of file objects to return */ - if ((p_f[0] = PyFile_FromFile(p_s[0], cmdstring, wr_mode, _PyPclose)) != NULL) - PyFile_SetBufSize(p_f[0], bufsize); - if ((p_f[1] = PyFile_FromFile(p_s[1], cmdstring, rd_mode, _PyPclose)) != NULL) - PyFile_SetBufSize(p_f[1], bufsize); - if (n == POPEN_3) - { - if ((p_f[2] = PyFile_FromFile(p_s[2], cmdstring, rd_mode, _PyPclose)) != NULL) - PyFile_SetBufSize(p_f[0], bufsize); - f = Py_BuildValue("OOO", p_f[0], p_f[1], p_f[2]); - } - else - f = Py_BuildValue("OO", p_f[0], p_f[1]); - - /* - * Insert the files we've created into the process dictionary - * all referencing the list with the process handle and the - * initial number of files (see description below in _PyPclose). - * Since if _PyPclose later tried to wait on a process when all - * handles weren't closed, it could create a deadlock with the - * child, we spend some energy here to try to ensure that we - * either insert all file handles into the dictionary or none - * at all. It's a little clumsy with the various popen modes - * and variable number of files involved. - */ - if (!_PyPopenProcs) - { - _PyPopenProcs = PyDict_New(); - } - - if (_PyPopenProcs) - { - PyObject *procObj, *pidObj, *intObj, *fileObj[3]; - int ins_rc[3]; - - fileObj[0] = fileObj[1] = fileObj[2] = NULL; - ins_rc[0] = ins_rc[1] = ins_rc[2] = 0; - - procObj = PyList_New(2); - pidObj = PyInt_FromLong((long) pipe_pid); - intObj = PyInt_FromLong((long) file_count); - - if (procObj && pidObj && intObj) - { - PyList_SetItem(procObj, 0, pidObj); - PyList_SetItem(procObj, 1, intObj); - - fileObj[0] = PyLong_FromVoidPtr(p_s[0]); - if (fileObj[0]) - { - ins_rc[0] = PyDict_SetItem(_PyPopenProcs, - fileObj[0], - procObj); - } - fileObj[1] = PyLong_FromVoidPtr(p_s[1]); - if (fileObj[1]) - { - ins_rc[1] = PyDict_SetItem(_PyPopenProcs, - fileObj[1], - procObj); - } - if (file_count >= 3) - { - fileObj[2] = PyLong_FromVoidPtr(p_s[2]); - if (fileObj[2]) - { - ins_rc[2] = PyDict_SetItem(_PyPopenProcs, - fileObj[2], - procObj); - } - } - - if (ins_rc[0] < 0 || !fileObj[0] || - ins_rc[1] < 0 || (file_count > 1 && !fileObj[1]) || - ins_rc[2] < 0 || (file_count > 2 && !fileObj[2])) - { - /* Something failed - remove any dictionary - * entries that did make it. - */ - if (!ins_rc[0] && fileObj[0]) - { - PyDict_DelItem(_PyPopenProcs, - fileObj[0]); - } - if (!ins_rc[1] && fileObj[1]) - { - PyDict_DelItem(_PyPopenProcs, - fileObj[1]); - } - if (!ins_rc[2] && fileObj[2]) - { - PyDict_DelItem(_PyPopenProcs, - fileObj[2]); - } - } - } - - /* - * Clean up our localized references for the dictionary keys - * and value since PyDict_SetItem will Py_INCREF any copies - * that got placed in the dictionary. - */ - Py_XDECREF(procObj); - Py_XDECREF(fileObj[0]); - Py_XDECREF(fileObj[1]); - Py_XDECREF(fileObj[2]); - } - - /* Child is launched. */ - return f; -} - -/* - * Wrapper for fclose() to use for popen* files, so we can retrieve the - * exit code for the child process and return as a result of the close. - * - * This function uses the _PyPopenProcs dictionary in order to map the - * input file pointer to information about the process that was - * originally created by the popen* call that created the file pointer. - * The dictionary uses the file pointer as a key (with one entry - * inserted for each file returned by the original popen* call) and a - * single list object as the value for all files from a single call. - * The list object contains the Win32 process handle at [0], and a file - * count at [1], which is initialized to the total number of file - * handles using that list. - * - * This function closes whichever handle it is passed, and decrements - * the file count in the dictionary for the process handle pointed to - * by this file. On the last close (when the file count reaches zero), - * this function will wait for the child process and then return its - * exit code as the result of the close() operation. This permits the - * files to be closed in any order - it is always the close() of the - * final handle that will return the exit code. - * - * NOTE: This function is currently called with the GIL released. - * hence we use the GILState API to manage our state. - */ - -static int _PyPclose(FILE *file) -{ - int result; - int exit_code; - int pipe_pid; - PyObject *procObj, *pidObj, *intObj, *fileObj; - int file_count; -#ifdef WITH_THREAD - PyGILState_STATE state; -#endif - - /* Close the file handle first, to ensure it can't block the - * child from exiting if it's the last handle. - */ - result = fclose(file); - -#ifdef WITH_THREAD - state = PyGILState_Ensure(); -#endif - if (_PyPopenProcs) - { - if ((fileObj = PyLong_FromVoidPtr(file)) != NULL && - (procObj = PyDict_GetItem(_PyPopenProcs, - fileObj)) != NULL && - (pidObj = PyList_GetItem(procObj,0)) != NULL && - (intObj = PyList_GetItem(procObj,1)) != NULL) - { - pipe_pid = (int) PyInt_AsLong(pidObj); - file_count = (int) PyInt_AsLong(intObj); - - if (file_count > 1) - { - /* Still other files referencing process */ - file_count--; - PyList_SetItem(procObj,1, - PyInt_FromLong((long) file_count)); - } - else - { - /* Last file for this process */ - if (result != EOF && - waitpid(pipe_pid, &exit_code, 0) == pipe_pid) - { - /* extract exit status */ - if (WIFEXITED(exit_code)) - { - result = WEXITSTATUS(exit_code); - } - else - { - errno = EPIPE; - result = -1; - } - } - else - { - /* Indicate failure - this will cause the file object - * to raise an I/O error and translate the last - * error code from errno. We do have a problem with - * last errors that overlap the normal errno table, - * but that's a consistent problem with the file object. - */ - result = -1; - } - } - - /* Remove this file pointer from dictionary */ - PyDict_DelItem(_PyPopenProcs, fileObj); - - if (PyDict_Size(_PyPopenProcs) == 0) - { - Py_DECREF(_PyPopenProcs); - _PyPopenProcs = NULL; - } - - } /* if object retrieval ok */ - - Py_XDECREF(fileObj); - } /* if _PyPopenProcs */ - -#ifdef WITH_THREAD - PyGILState_Release(state); -#endif - return result; -} - -#endif /* PYCC_??? */ - -#elif defined(MS_WINDOWS) - -/* - * Portable 'popen' replacement for Win32. - * - * Written by Bill Tutt . Minor tweaks - * and 2.0 integration by Fredrik Lundh - * Return code handling by David Bolen . - */ - -#include -#include -#include - -/* These tell _PyPopen() wether to return 1, 2, or 3 file objects. */ -#define POPEN_1 1 -#define POPEN_2 2 -#define POPEN_3 3 -#define POPEN_4 4 - -static PyObject *_PyPopen(char *, int, int); -static int _PyPclose(FILE *file); - -/* - * Internal dictionary mapping popen* file pointers to process handles, - * for use when retrieving the process exit code. See _PyPclose() below - * for more information on this dictionary's use. - */ -static PyObject *_PyPopenProcs = NULL; - - -/* popen that works from a GUI. - * - * The result of this function is a pipe (file) connected to the - * processes stdin or stdout, depending on the requested mode. - */ - -static PyObject * -posix_popen(PyObject *self, PyObject *args) -{ - PyObject *f; - int tm = 0; - - char *cmdstring; - char *mode = "r"; - int bufsize = -1; - if (!PyArg_ParseTuple(args, "s|si:popen", &cmdstring, &mode, &bufsize)) - return NULL; - - if (*mode == 'r') - tm = _O_RDONLY; - else if (*mode != 'w') { - PyErr_SetString(PyExc_ValueError, "popen() arg 2 must be 'r' or 'w'"); - return NULL; - } else - tm = _O_WRONLY; - - if (bufsize != -1) { - PyErr_SetString(PyExc_ValueError, "popen() arg 3 must be -1"); - return NULL; - } - - if (*(mode+1) == 't') - f = _PyPopen(cmdstring, tm | _O_TEXT, POPEN_1); - else if (*(mode+1) == 'b') - f = _PyPopen(cmdstring, tm | _O_BINARY, POPEN_1); - else - f = _PyPopen(cmdstring, tm | _O_TEXT, POPEN_1); - - return f; -} - -/* Variation on win32pipe.popen - * - * The result of this function is a pipe (file) connected to the - * process's stdin, and a pipe connected to the process's stdout. - */ - -static PyObject * -win32_popen2(PyObject *self, PyObject *args) -{ - PyObject *f; - int tm=0; - - char *cmdstring; - char *mode = "t"; - int bufsize = -1; - if (!PyArg_ParseTuple(args, "s|si:popen2", &cmdstring, &mode, &bufsize)) - return NULL; - - if (*mode == 't') - tm = _O_TEXT; - else if (*mode != 'b') { - PyErr_SetString(PyExc_ValueError, "popen2() arg 2 must be 't' or 'b'"); - return NULL; - } else - tm = _O_BINARY; - - if (bufsize != -1) { - PyErr_SetString(PyExc_ValueError, "popen2() arg 3 must be -1"); - return NULL; - } - - f = _PyPopen(cmdstring, tm, POPEN_2); - - return f; -} - -/* - * Variation on - * - * The result of this function is 3 pipes - the process's stdin, - * stdout and stderr - */ - -static PyObject * -win32_popen3(PyObject *self, PyObject *args) -{ - PyObject *f; - int tm = 0; - - char *cmdstring; - char *mode = "t"; - int bufsize = -1; - if (!PyArg_ParseTuple(args, "s|si:popen3", &cmdstring, &mode, &bufsize)) - return NULL; - - if (*mode == 't') - tm = _O_TEXT; - else if (*mode != 'b') { - PyErr_SetString(PyExc_ValueError, "popen3() arg 2 must be 't' or 'b'"); - return NULL; - } else - tm = _O_BINARY; - - if (bufsize != -1) { - PyErr_SetString(PyExc_ValueError, "popen3() arg 3 must be -1"); - return NULL; - } - - f = _PyPopen(cmdstring, tm, POPEN_3); - - return f; -} - -/* - * Variation on win32pipe.popen - * - * The result of this function is 2 pipes - the processes stdin, - * and stdout+stderr combined as a single pipe. - */ - -static PyObject * -win32_popen4(PyObject *self, PyObject *args) -{ - PyObject *f; - int tm = 0; - - char *cmdstring; - char *mode = "t"; - int bufsize = -1; - if (!PyArg_ParseTuple(args, "s|si:popen4", &cmdstring, &mode, &bufsize)) - return NULL; - - if (*mode == 't') - tm = _O_TEXT; - else if (*mode != 'b') { - PyErr_SetString(PyExc_ValueError, "popen4() arg 2 must be 't' or 'b'"); - return NULL; - } else - tm = _O_BINARY; - - if (bufsize != -1) { - PyErr_SetString(PyExc_ValueError, "popen4() arg 3 must be -1"); - return NULL; - } - - f = _PyPopen(cmdstring, tm, POPEN_4); - - return f; -} - -static BOOL -_PyPopenCreateProcess(char *cmdstring, - HANDLE hStdin, - HANDLE hStdout, - HANDLE hStderr, - HANDLE *hProcess) -{ -#ifndef MS_XBOX - PROCESS_INFORMATION piProcInfo; - STARTUPINFO siStartInfo; - DWORD dwProcessFlags = 0; /* no NEW_CONSOLE by default for Ctrl+C handling */ - char *s1,*s2, *s3 = " /c "; - const char *szConsoleSpawn = "w9xpopen.exe"; - int i; - int x; - - if (i = GetEnvironmentVariable("COMSPEC",NULL,0)) { - char *comshell; - - s1 = (char *)alloca(i); - if (!(x = GetEnvironmentVariable("COMSPEC", s1, i))) - return x; - - /* Explicitly check if we are using COMMAND.COM. If we are - * then use the w9xpopen hack. - */ - comshell = s1 + x; - while (comshell >= s1 && *comshell != '\\') - --comshell; - ++comshell; - - if (GetVersion() < 0x80000000 && - _stricmp(comshell, "command.com") != 0) { - /* NT/2000 and not using command.com. */ - x = i + strlen(s3) + strlen(cmdstring) + 1; - s2 = (char *)alloca(x); - ZeroMemory(s2, x); - PyOS_snprintf(s2, x, "%s%s%s", s1, s3, cmdstring); - } - else { - /* - * Oh gag, we're on Win9x or using COMMAND.COM. Use - * the workaround listed in KB: Q150956 - */ - char modulepath[_MAX_PATH]; - struct stat statinfo; - GetModuleFileName(NULL, modulepath, sizeof(modulepath)); - for (i = x = 0; modulepath[i]; i++) - if (modulepath[i] == SEP) - x = i+1; - modulepath[x] = '\0'; - /* Create the full-name to w9xpopen, so we can test it exists */ - strncat(modulepath, - szConsoleSpawn, - (sizeof(modulepath)/sizeof(modulepath[0])) - -strlen(modulepath)); - if (stat(modulepath, &statinfo) != 0) { - /* Eeek - file-not-found - possibly an embedding - situation - see if we can locate it in sys.prefix - */ - strncpy(modulepath, - Py_GetExecPrefix(), - sizeof(modulepath)/sizeof(modulepath[0])); - if (modulepath[strlen(modulepath)-1] != '\\') - strcat(modulepath, "\\"); - strncat(modulepath, - szConsoleSpawn, - (sizeof(modulepath)/sizeof(modulepath[0])) - -strlen(modulepath)); - /* No where else to look - raise an easily identifiable - error, rather than leaving Windows to report - "file not found" - as the user is probably blissfully - unaware this shim EXE is used, and it will confuse them. - (well, it confused me for a while ;-) - */ - if (stat(modulepath, &statinfo) != 0) { - PyErr_Format(PyExc_RuntimeError, - "Can not locate '%s' which is needed " - "for popen to work with your shell " - "or platform.", - szConsoleSpawn); - return FALSE; - } - } - x = i + strlen(s3) + strlen(cmdstring) + 1 + - strlen(modulepath) + - strlen(szConsoleSpawn) + 1; - - s2 = (char *)alloca(x); - ZeroMemory(s2, x); - /* To maintain correct argument passing semantics, - we pass the command-line as it stands, and allow - quoting to be applied. w9xpopen.exe will then - use its argv vector, and re-quote the necessary - args for the ultimate child process. - */ - PyOS_snprintf( - s2, x, - "\"%s\" %s%s%s", - modulepath, - s1, - s3, - cmdstring); - /* Not passing CREATE_NEW_CONSOLE has been known to - cause random failures on win9x. Specifically a - dialog: - "Your program accessed mem currently in use at xxx" - and a hopeful warning about the stability of your - system. - Cost is Ctrl+C wont kill children, but anyone - who cares can have a go! - */ - dwProcessFlags |= CREATE_NEW_CONSOLE; - } - } - - /* Could be an else here to try cmd.exe / command.com in the path - Now we'll just error out.. */ - else { - PyErr_SetString(PyExc_RuntimeError, - "Cannot locate a COMSPEC environment variable to " - "use as the shell"); - return FALSE; - } - - ZeroMemory(&siStartInfo, sizeof(STARTUPINFO)); - siStartInfo.cb = sizeof(STARTUPINFO); - siStartInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - siStartInfo.hStdInput = hStdin; - siStartInfo.hStdOutput = hStdout; - siStartInfo.hStdError = hStderr; - siStartInfo.wShowWindow = SW_HIDE; - - if (CreateProcess(NULL, - s2, - NULL, - NULL, - TRUE, - dwProcessFlags, - NULL, - NULL, - &siStartInfo, - &piProcInfo) ) { - /* Close the handles now so anyone waiting is woken. */ - CloseHandle(piProcInfo.hThread); - - /* Return process handle */ - *hProcess = piProcInfo.hProcess; - return TRUE; - } - win32_error("CreateProcess", s2); -#endif - return FALSE; -} - -/* The following code is based off of KB: Q190351 */ - -static PyObject * -_PyPopen(char *cmdstring, int mode, int n) -{ -#ifndef MS_XBOX - HANDLE hChildStdinRd, hChildStdinWr, hChildStdoutRd, hChildStdoutWr, - hChildStderrRd, hChildStderrWr, hChildStdinWrDup, hChildStdoutRdDup, - hChildStderrRdDup, hProcess; /* hChildStdoutWrDup; */ - - SECURITY_ATTRIBUTES saAttr; - BOOL fSuccess; - int fd1, fd2, fd3; - FILE *f1, *f2, *f3; - long file_count; - PyObject *f; - - saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); - saAttr.bInheritHandle = TRUE; - saAttr.lpSecurityDescriptor = NULL; - - if (!CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0)) - return win32_error("CreatePipe", NULL); - - /* Create new output read handle and the input write handle. Set - * the inheritance properties to FALSE. Otherwise, the child inherits - * these handles; resulting in non-closeable handles to the pipes - * being created. */ - fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdinWr, - GetCurrentProcess(), &hChildStdinWrDup, 0, - FALSE, - DUPLICATE_SAME_ACCESS); - if (!fSuccess) - return win32_error("DuplicateHandle", NULL); - - /* Close the inheritable version of ChildStdin - that we're using. */ - CloseHandle(hChildStdinWr); - - if (!CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0)) - return win32_error("CreatePipe", NULL); - - fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdoutRd, - GetCurrentProcess(), &hChildStdoutRdDup, 0, - FALSE, DUPLICATE_SAME_ACCESS); - if (!fSuccess) - return win32_error("DuplicateHandle", NULL); - - /* Close the inheritable version of ChildStdout - that we're using. */ - CloseHandle(hChildStdoutRd); - - if (n != POPEN_4) { - if (!CreatePipe(&hChildStderrRd, &hChildStderrWr, &saAttr, 0)) - return win32_error("CreatePipe", NULL); - fSuccess = DuplicateHandle(GetCurrentProcess(), - hChildStderrRd, - GetCurrentProcess(), - &hChildStderrRdDup, 0, - FALSE, DUPLICATE_SAME_ACCESS); - if (!fSuccess) - return win32_error("DuplicateHandle", NULL); - /* Close the inheritable version of ChildStdErr that we're using. */ - CloseHandle(hChildStderrRd); - } - - switch (n) { - case POPEN_1: - switch (mode & (_O_RDONLY | _O_TEXT | _O_BINARY | _O_WRONLY)) { - case _O_WRONLY | _O_TEXT: - /* Case for writing to child Stdin in text mode. */ - fd1 = _open_osfhandle((long)hChildStdinWrDup, mode); - f1 = _fdopen(fd1, "w"); - f = PyFile_FromFile(f1, cmdstring, "w", _PyPclose); - PyFile_SetBufSize(f, 0); - /* We don't care about these pipes anymore, so close them. */ - CloseHandle(hChildStdoutRdDup); - CloseHandle(hChildStderrRdDup); - break; - - case _O_RDONLY | _O_TEXT: - /* Case for reading from child Stdout in text mode. */ - fd1 = _open_osfhandle((long)hChildStdoutRdDup, mode); - f1 = _fdopen(fd1, "r"); - f = PyFile_FromFile(f1, cmdstring, "r", _PyPclose); - PyFile_SetBufSize(f, 0); - /* We don't care about these pipes anymore, so close them. */ - CloseHandle(hChildStdinWrDup); - CloseHandle(hChildStderrRdDup); - break; - - case _O_RDONLY | _O_BINARY: - /* Case for readinig from child Stdout in binary mode. */ - fd1 = _open_osfhandle((long)hChildStdoutRdDup, mode); - f1 = _fdopen(fd1, "rb"); - f = PyFile_FromFile(f1, cmdstring, "rb", _PyPclose); - PyFile_SetBufSize(f, 0); - /* We don't care about these pipes anymore, so close them. */ - CloseHandle(hChildStdinWrDup); - CloseHandle(hChildStderrRdDup); - break; - - case _O_WRONLY | _O_BINARY: - /* Case for writing to child Stdin in binary mode. */ - fd1 = _open_osfhandle((long)hChildStdinWrDup, mode); - f1 = _fdopen(fd1, "wb"); - f = PyFile_FromFile(f1, cmdstring, "wb", _PyPclose); - PyFile_SetBufSize(f, 0); - /* We don't care about these pipes anymore, so close them. */ - CloseHandle(hChildStdoutRdDup); - CloseHandle(hChildStderrRdDup); - break; - } - file_count = 1; - break; - - case POPEN_2: - case POPEN_4: - { - char *m1, *m2; - PyObject *p1, *p2; - - if (mode & _O_TEXT) { - m1 = "r"; - m2 = "w"; - } else { - m1 = "rb"; - m2 = "wb"; - } - - fd1 = _open_osfhandle((long)hChildStdinWrDup, mode); - f1 = _fdopen(fd1, m2); - fd2 = _open_osfhandle((long)hChildStdoutRdDup, mode); - f2 = _fdopen(fd2, m1); - p1 = PyFile_FromFile(f1, cmdstring, m2, _PyPclose); - PyFile_SetBufSize(p1, 0); - p2 = PyFile_FromFile(f2, cmdstring, m1, _PyPclose); - PyFile_SetBufSize(p2, 0); - - if (n != 4) - CloseHandle(hChildStderrRdDup); - - f = Py_BuildValue("OO",p1,p2); - Py_XDECREF(p1); - Py_XDECREF(p2); - file_count = 2; - break; - } - - case POPEN_3: - { - char *m1, *m2; - PyObject *p1, *p2, *p3; - - if (mode & _O_TEXT) { - m1 = "r"; - m2 = "w"; - } else { - m1 = "rb"; - m2 = "wb"; - } - - fd1 = _open_osfhandle((long)hChildStdinWrDup, mode); - f1 = _fdopen(fd1, m2); - fd2 = _open_osfhandle((long)hChildStdoutRdDup, mode); - f2 = _fdopen(fd2, m1); - fd3 = _open_osfhandle((long)hChildStderrRdDup, mode); - f3 = _fdopen(fd3, m1); - p1 = PyFile_FromFile(f1, cmdstring, m2, _PyPclose); - p2 = PyFile_FromFile(f2, cmdstring, m1, _PyPclose); - p3 = PyFile_FromFile(f3, cmdstring, m1, _PyPclose); - PyFile_SetBufSize(p1, 0); - PyFile_SetBufSize(p2, 0); - PyFile_SetBufSize(p3, 0); - f = Py_BuildValue("OOO",p1,p2,p3); - Py_XDECREF(p1); - Py_XDECREF(p2); - Py_XDECREF(p3); - file_count = 3; - break; - } - } - - if (n == POPEN_4) { - if (!_PyPopenCreateProcess(cmdstring, - hChildStdinRd, - hChildStdoutWr, - hChildStdoutWr, - &hProcess)) - return NULL; - } - else { - if (!_PyPopenCreateProcess(cmdstring, - hChildStdinRd, - hChildStdoutWr, - hChildStderrWr, - &hProcess)) - return NULL; - } - - /* - * Insert the files we've created into the process dictionary - * all referencing the list with the process handle and the - * initial number of files (see description below in _PyPclose). - * Since if _PyPclose later tried to wait on a process when all - * handles weren't closed, it could create a deadlock with the - * child, we spend some energy here to try to ensure that we - * either insert all file handles into the dictionary or none - * at all. It's a little clumsy with the various popen modes - * and variable number of files involved. - */ - if (!_PyPopenProcs) { - _PyPopenProcs = PyDict_New(); - } - - if (_PyPopenProcs) { - PyObject *procObj, *hProcessObj, *intObj, *fileObj[3]; - int ins_rc[3]; - - fileObj[0] = fileObj[1] = fileObj[2] = NULL; - ins_rc[0] = ins_rc[1] = ins_rc[2] = 0; - - procObj = PyList_New(2); - hProcessObj = PyLong_FromVoidPtr(hProcess); - intObj = PyInt_FromLong(file_count); - - if (procObj && hProcessObj && intObj) { - PyList_SetItem(procObj,0,hProcessObj); - PyList_SetItem(procObj,1,intObj); - - fileObj[0] = PyLong_FromVoidPtr(f1); - if (fileObj[0]) { - ins_rc[0] = PyDict_SetItem(_PyPopenProcs, - fileObj[0], - procObj); - } - if (file_count >= 2) { - fileObj[1] = PyLong_FromVoidPtr(f2); - if (fileObj[1]) { - ins_rc[1] = PyDict_SetItem(_PyPopenProcs, - fileObj[1], - procObj); - } - } - if (file_count >= 3) { - fileObj[2] = PyLong_FromVoidPtr(f3); - if (fileObj[2]) { - ins_rc[2] = PyDict_SetItem(_PyPopenProcs, - fileObj[2], - procObj); - } - } - - if (ins_rc[0] < 0 || !fileObj[0] || - ins_rc[1] < 0 || (file_count > 1 && !fileObj[1]) || - ins_rc[2] < 0 || (file_count > 2 && !fileObj[2])) { - /* Something failed - remove any dictionary - * entries that did make it. - */ - if (!ins_rc[0] && fileObj[0]) { - PyDict_DelItem(_PyPopenProcs, - fileObj[0]); - } - if (!ins_rc[1] && fileObj[1]) { - PyDict_DelItem(_PyPopenProcs, - fileObj[1]); - } - if (!ins_rc[2] && fileObj[2]) { - PyDict_DelItem(_PyPopenProcs, - fileObj[2]); - } - } - } - - /* - * Clean up our localized references for the dictionary keys - * and value since PyDict_SetItem will Py_INCREF any copies - * that got placed in the dictionary. - */ - Py_XDECREF(procObj); - Py_XDECREF(fileObj[0]); - Py_XDECREF(fileObj[1]); - Py_XDECREF(fileObj[2]); - } - - /* Child is launched. Close the parents copy of those pipe - * handles that only the child should have open. You need to - * make sure that no handles to the write end of the output pipe - * are maintained in this process or else the pipe will not close - * when the child process exits and the ReadFile will hang. */ - - if (!CloseHandle(hChildStdinRd)) - return win32_error("CloseHandle", NULL); - - if (!CloseHandle(hChildStdoutWr)) - return win32_error("CloseHandle", NULL); - - if ((n != 4) && (!CloseHandle(hChildStderrWr))) - return win32_error("CloseHandle", NULL); - - return f; -#else - return 0; -#endif -} - -/* - * Wrapper for fclose() to use for popen* files, so we can retrieve the - * exit code for the child process and return as a result of the close. - * - * This function uses the _PyPopenProcs dictionary in order to map the - * input file pointer to information about the process that was - * originally created by the popen* call that created the file pointer. - * The dictionary uses the file pointer as a key (with one entry - * inserted for each file returned by the original popen* call) and a - * single list object as the value for all files from a single call. - * The list object contains the Win32 process handle at [0], and a file - * count at [1], which is initialized to the total number of file - * handles using that list. - * - * This function closes whichever handle it is passed, and decrements - * the file count in the dictionary for the process handle pointed to - * by this file. On the last close (when the file count reaches zero), - * this function will wait for the child process and then return its - * exit code as the result of the close() operation. This permits the - * files to be closed in any order - it is always the close() of the - * final handle that will return the exit code. - * - * NOTE: This function is currently called with the GIL released. - * hence we use the GILState API to manage our state. - */ - -static int _PyPclose(FILE *file) -{ - int result; - DWORD exit_code; - HANDLE hProcess; - PyObject *procObj, *hProcessObj, *intObj, *fileObj; - long file_count; -#ifdef WITH_THREAD - PyGILState_STATE state; -#endif - - /* Close the file handle first, to ensure it can't block the - * child from exiting if it's the last handle. - */ - result = fclose(file); -#ifdef WITH_THREAD - state = PyGILState_Ensure(); -#endif - if (_PyPopenProcs) { - if ((fileObj = PyLong_FromVoidPtr(file)) != NULL && - (procObj = PyDict_GetItem(_PyPopenProcs, - fileObj)) != NULL && - (hProcessObj = PyList_GetItem(procObj,0)) != NULL && - (intObj = PyList_GetItem(procObj,1)) != NULL) { - - hProcess = PyLong_AsVoidPtr(hProcessObj); - file_count = PyInt_AsLong(intObj); - - if (file_count > 1) { - /* Still other files referencing process */ - file_count--; - PyList_SetItem(procObj,1, - PyInt_FromLong(file_count)); - } else { - /* Last file for this process */ -#ifndef MS_XBOX - if (result != EOF && - WaitForSingleObject(hProcess, INFINITE) != WAIT_FAILED && - GetExitCodeProcess(hProcess, &exit_code)) { - /* Possible truncation here in 16-bit environments, but - * real exit codes are just the lower byte in any event. - */ - result = exit_code; -#else - if (result != EOF && - WaitForSingleObject(hProcess, INFINITE) != WAIT_FAILED) { - /* Possible truncation here in 16-bit environments, but - * real exit codes are just the lower byte in any event. - */ - result = 0; -#endif - } else { - /* Indicate failure - this will cause the file object - * to raise an I/O error and translate the last Win32 - * error code from errno. We do have a problem with - * last errors that overlap the normal errno table, - * but that's a consistent problem with the file object. - */ - if (result != EOF) { - /* If the error wasn't from the fclose(), then - * set errno for the file object error handling. - */ - errno = GetLastError(); - } - result = -1; - } - - /* Free up the native handle at this point */ - CloseHandle(hProcess); - } - - /* Remove this file pointer from dictionary */ - PyDict_DelItem(_PyPopenProcs, fileObj); - - if (PyDict_Size(_PyPopenProcs) == 0) { - Py_DECREF(_PyPopenProcs); - _PyPopenProcs = NULL; - } - - } /* if object retrieval ok */ - - Py_XDECREF(fileObj); - } /* if _PyPopenProcs */ - -#ifdef WITH_THREAD - PyGILState_Release(state); -#endif - return result; -} - -#else /* which OS? */ -static PyObject * -posix_popen(PyObject *self, PyObject *args) -{ - char *name; - char *mode = "r"; - int bufsize = -1; - FILE *fp; - PyObject *f; - if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode, &bufsize)) - return NULL; - /* Strip mode of binary or text modifiers */ - if (strcmp(mode, "rb") == 0 || strcmp(mode, "rt") == 0) - mode = "r"; - else if (strcmp(mode, "wb") == 0 || strcmp(mode, "wt") == 0) - mode = "w"; - Py_BEGIN_ALLOW_THREADS - fp = popen(name, mode); - Py_END_ALLOW_THREADS - if (fp == NULL) - return posix_error(); - f = PyFile_FromFile(fp, name, mode, pclose); - if (f != NULL) - PyFile_SetBufSize(f, bufsize); - return f; -} - -#endif /* PYOS_??? */ -#endif /* HAVE_POPEN */ - - -#ifdef HAVE_SETUID -PyDoc_STRVAR(posix_setuid__doc__, -"setuid(uid)\n\n\ -Set the current process's user id."); - -static PyObject * -posix_setuid(PyObject *self, PyObject *args) -{ - int uid; - if (!PyArg_ParseTuple(args, "i:setuid", &uid)) - return NULL; - if (setuid(uid) < 0) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} -#endif /* HAVE_SETUID */ - - -#ifdef HAVE_SETEUID -PyDoc_STRVAR(posix_seteuid__doc__, -"seteuid(uid)\n\n\ -Set the current process's effective user id."); - -static PyObject * -posix_seteuid (PyObject *self, PyObject *args) -{ - int euid; - if (!PyArg_ParseTuple(args, "i", &euid)) { - return NULL; - } else if (seteuid(euid) < 0) { - return posix_error(); - } else { - Py_INCREF(Py_None); - return Py_None; - } -} -#endif /* HAVE_SETEUID */ - -#ifdef HAVE_SETEGID -PyDoc_STRVAR(posix_setegid__doc__, -"setegid(gid)\n\n\ -Set the current process's effective group id."); - -static PyObject * -posix_setegid (PyObject *self, PyObject *args) -{ - int egid; - if (!PyArg_ParseTuple(args, "i", &egid)) { - return NULL; - } else if (setegid(egid) < 0) { - return posix_error(); - } else { - Py_INCREF(Py_None); - return Py_None; - } -} -#endif /* HAVE_SETEGID */ - -#ifdef HAVE_SETREUID -PyDoc_STRVAR(posix_setreuid__doc__, -"seteuid(ruid, euid)\n\n\ -Set the current process's real and effective user ids."); - -static PyObject * -posix_setreuid (PyObject *self, PyObject *args) -{ - int ruid, euid; - if (!PyArg_ParseTuple(args, "ii", &ruid, &euid)) { - return NULL; - } else if (setreuid(ruid, euid) < 0) { - return posix_error(); - } else { - Py_INCREF(Py_None); - return Py_None; - } -} -#endif /* HAVE_SETREUID */ - -#ifdef HAVE_SETREGID -PyDoc_STRVAR(posix_setregid__doc__, -"setegid(rgid, egid)\n\n\ -Set the current process's real and effective group ids."); - -static PyObject * -posix_setregid (PyObject *self, PyObject *args) -{ - int rgid, egid; - if (!PyArg_ParseTuple(args, "ii", &rgid, &egid)) { - return NULL; - } else if (setregid(rgid, egid) < 0) { - return posix_error(); - } else { - Py_INCREF(Py_None); - return Py_None; - } -} -#endif /* HAVE_SETREGID */ - -#ifdef HAVE_SETGID -PyDoc_STRVAR(posix_setgid__doc__, -"setgid(gid)\n\n\ -Set the current process's group id."); - -static PyObject * -posix_setgid(PyObject *self, PyObject *args) -{ - int gid; - if (!PyArg_ParseTuple(args, "i:setgid", &gid)) - return NULL; - if (setgid(gid) < 0) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} -#endif /* HAVE_SETGID */ - -#ifdef HAVE_SETGROUPS -PyDoc_STRVAR(posix_setgroups__doc__, -"setgroups(list)\n\n\ -Set the groups of the current process to list."); - -static PyObject * -posix_setgroups(PyObject *self, PyObject *args) -{ - PyObject *groups; - int i, len; - gid_t grouplist[MAX_GROUPS]; - - if (!PyArg_ParseTuple(args, "O:setgid", &groups)) - return NULL; - if (!PySequence_Check(groups)) { - PyErr_SetString(PyExc_TypeError, "setgroups argument must be a sequence"); - return NULL; - } - len = PySequence_Size(groups); - if (len > MAX_GROUPS) { - PyErr_SetString(PyExc_ValueError, "too many groups"); - return NULL; - } - for(i = 0; i < len; i++) { - PyObject *elem; - elem = PySequence_GetItem(groups, i); - if (!elem) - return NULL; - if (!PyInt_Check(elem)) { - PyErr_SetString(PyExc_TypeError, - "groups must be integers"); - Py_DECREF(elem); - return NULL; - } - /* XXX: check that value fits into gid_t. */ - grouplist[i] = PyInt_AsLong(elem); - Py_DECREF(elem); - } - - if (setgroups(len, grouplist) < 0) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} -#endif /* HAVE_SETGROUPS */ - -#ifdef HAVE_WAITPID -PyDoc_STRVAR(posix_waitpid__doc__, -"waitpid(pid, options) -> (pid, status)\n\n\ -Wait for completion of a given child process."); - -static PyObject * -posix_waitpid(PyObject *self, PyObject *args) -{ - int pid, options; -#ifdef UNION_WAIT - union wait status; -#define status_i (status.w_status) -#else - int status; -#define status_i status -#endif - status_i = 0; - - if (!PyArg_ParseTuple(args, "ii:waitpid", &pid, &options)) - return NULL; - Py_BEGIN_ALLOW_THREADS - pid = waitpid(pid, &status, options); - Py_END_ALLOW_THREADS - if (pid == -1) - return posix_error(); - else - return Py_BuildValue("ii", pid, status_i); -} - -#elif defined(HAVE_CWAIT) - -/* MS C has a variant of waitpid() that's usable for most purposes. */ -PyDoc_STRVAR(posix_waitpid__doc__, -"waitpid(pid, options) -> (pid, status << 8)\n\n" -"Wait for completion of a given process. options is ignored on Windows."); - -static PyObject * -posix_waitpid(PyObject *self, PyObject *args) -{ - int pid, options; - int status; - - if (!PyArg_ParseTuple(args, "ii:waitpid", &pid, &options)) - return NULL; - Py_BEGIN_ALLOW_THREADS - pid = _cwait(&status, pid, options); - Py_END_ALLOW_THREADS - if (pid == -1) - return posix_error(); - else - /* shift the status left a byte so this is more like the - POSIX waitpid */ - return Py_BuildValue("ii", pid, status << 8); -} -#endif /* HAVE_WAITPID || HAVE_CWAIT */ - -#ifdef HAVE_WAIT -PyDoc_STRVAR(posix_wait__doc__, -"wait() -> (pid, status)\n\n\ -Wait for completion of a child process."); - -static PyObject * -posix_wait(PyObject *self, PyObject *noargs) -{ - int pid; -#ifdef UNION_WAIT - union wait status; -#define status_i (status.w_status) -#else - int status; -#define status_i status -#endif - - status_i = 0; - Py_BEGIN_ALLOW_THREADS - pid = wait(&status); - Py_END_ALLOW_THREADS - if (pid == -1) - return posix_error(); - else - return Py_BuildValue("ii", pid, status_i); -#undef status_i -} -#endif - - -PyDoc_STRVAR(posix_lstat__doc__, -"lstat(path) -> stat result\n\n\ -Like stat(path), but do not follow symbolic links."); - -static PyObject * -posix_lstat(PyObject *self, PyObject *args) -{ -#ifdef HAVE_LSTAT - return posix_do_stat(self, args, "et:lstat", lstat, NULL, NULL); -#else /* !HAVE_LSTAT */ -#ifdef MS_WINDOWS - return posix_do_stat(self, args, "et:lstat", STAT, "U:lstat", _wstati64); -#else - return posix_do_stat(self, args, "et:lstat", STAT, NULL, NULL); -#endif -#endif /* !HAVE_LSTAT */ -} - - -#ifdef HAVE_READLINK -PyDoc_STRVAR(posix_readlink__doc__, -"readlink(path) -> path\n\n\ -Return a string representing the path to which the symbolic link points."); - -static PyObject * -posix_readlink(PyObject *self, PyObject *args) -{ - char buf[MAXPATHLEN]; - char *path; - int n; - if (!PyArg_ParseTuple(args, "s:readlink", &path)) - return NULL; - Py_BEGIN_ALLOW_THREADS - n = readlink(path, buf, (int) sizeof buf); - Py_END_ALLOW_THREADS - if (n < 0) - return posix_error_with_filename(path); - return PyString_FromStringAndSize(buf, n); -} -#endif /* HAVE_READLINK */ - - -#ifdef HAVE_SYMLINK -PyDoc_STRVAR(posix_symlink__doc__, -"symlink(src, dst)\n\n\ -Create a symbolic link pointing to src named dst."); - -static PyObject * -posix_symlink(PyObject *self, PyObject *args) -{ - return posix_2str(args, "etet:symlink", symlink, NULL, NULL); -} -#endif /* HAVE_SYMLINK */ - - -#ifdef HAVE_TIMES -#ifndef HZ -#define HZ 60 /* Universal constant :-) */ -#endif /* HZ */ - -#if defined(PYCC_VACPP) && defined(PYOS_OS2) -static long -system_uptime(void) -{ - ULONG value = 0; - - Py_BEGIN_ALLOW_THREADS - DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &value, sizeof(value)); - Py_END_ALLOW_THREADS - - return value; -} - -static PyObject * -posix_times(PyObject *self, PyObject *noargs) -{ - /* Currently Only Uptime is Provided -- Others Later */ - return Py_BuildValue("ddddd", - (double)0 /* t.tms_utime / HZ */, - (double)0 /* t.tms_stime / HZ */, - (double)0 /* t.tms_cutime / HZ */, - (double)0 /* t.tms_cstime / HZ */, - (double)system_uptime() / 1000); -} -#else /* not OS2 */ -static PyObject * -posix_times(PyObject *self, PyObject *noargs) -{ - struct tms t; - clock_t c; - errno = 0; - c = times(&t); - if (c == (clock_t) -1) - return posix_error(); - return Py_BuildValue("ddddd", - (double)t.tms_utime / HZ, - (double)t.tms_stime / HZ, - (double)t.tms_cutime / HZ, - (double)t.tms_cstime / HZ, - (double)c / HZ); -} -#endif /* not OS2 */ -#endif /* HAVE_TIMES */ - - -#if defined(MS_WINDOWS) && !defined(MS_XBOX) -#define HAVE_TIMES /* so the method table will pick it up */ -static PyObject * -posix_times(PyObject *self, PyObject *noargs) -{ - FILETIME create, exit, kernel, user; - HANDLE hProc; - hProc = GetCurrentProcess(); - GetProcessTimes(hProc, &create, &exit, &kernel, &user); - /* The fields of a FILETIME structure are the hi and lo part - of a 64-bit value expressed in 100 nanosecond units. - 1e7 is one second in such units; 1e-7 the inverse. - 429.4967296 is 2**32 / 1e7 or 2**32 * 1e-7. - */ - return Py_BuildValue( - "ddddd", - (double)(kernel.dwHighDateTime*429.4967296 + - kernel.dwLowDateTime*1e-7), - (double)(user.dwHighDateTime*429.4967296 + - user.dwLowDateTime*1e-7), - (double)0, - (double)0, - (double)0); -} -#endif /* MS_WINDOWS */ - -#ifdef HAVE_TIMES -PyDoc_STRVAR(posix_times__doc__, -"times() -> (utime, stime, cutime, cstime, elapsed_time)\n\n\ -Return a tuple of floating point numbers indicating process times."); -#endif - - -#ifdef HAVE_SETSID -PyDoc_STRVAR(posix_setsid__doc__, -"setsid()\n\n\ -Call the system call setsid()."); - -static PyObject * -posix_setsid(PyObject *self, PyObject *noargs) -{ - if (setsid() < 0) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} -#endif /* HAVE_SETSID */ - -#ifdef HAVE_SETPGID -PyDoc_STRVAR(posix_setpgid__doc__, -"setpgid(pid, pgrp)\n\n\ -Call the system call setpgid()."); - -static PyObject * -posix_setpgid(PyObject *self, PyObject *args) -{ - int pid, pgrp; - if (!PyArg_ParseTuple(args, "ii:setpgid", &pid, &pgrp)) - return NULL; - if (setpgid(pid, pgrp) < 0) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} -#endif /* HAVE_SETPGID */ - - -#ifdef HAVE_TCGETPGRP -PyDoc_STRVAR(posix_tcgetpgrp__doc__, -"tcgetpgrp(fd) -> pgid\n\n\ -Return the process group associated with the terminal given by a fd."); - -static PyObject * -posix_tcgetpgrp(PyObject *self, PyObject *args) -{ - int fd, pgid; - if (!PyArg_ParseTuple(args, "i:tcgetpgrp", &fd)) - return NULL; - pgid = tcgetpgrp(fd); - if (pgid < 0) - return posix_error(); - return PyInt_FromLong((long)pgid); -} -#endif /* HAVE_TCGETPGRP */ - - -#ifdef HAVE_TCSETPGRP -PyDoc_STRVAR(posix_tcsetpgrp__doc__, -"tcsetpgrp(fd, pgid)\n\n\ -Set the process group associated with the terminal given by a fd."); - -static PyObject * -posix_tcsetpgrp(PyObject *self, PyObject *args) -{ - int fd, pgid; - if (!PyArg_ParseTuple(args, "ii:tcsetpgrp", &fd, &pgid)) - return NULL; - if (tcsetpgrp(fd, pgid) < 0) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} -#endif /* HAVE_TCSETPGRP */ - -/* Functions acting on file descriptors */ - -PyDoc_STRVAR(posix_open__doc__, -"open(filename, flag [, mode=0777]) -> fd\n\n\ -Open a file (for low level IO)."); - -static PyObject * -posix_open(PyObject *self, PyObject *args) -{ - char *file = NULL; - int flag; - int mode = 0777; - int fd; - -#ifdef Py_WIN_WIDE_FILENAMES - if (unicode_file_names()) { - PyUnicodeObject *po; - if (PyArg_ParseTuple(args, "Ui|i:mkdir", &po, &flag, &mode)) { - Py_BEGIN_ALLOW_THREADS - /* PyUnicode_AS_UNICODE OK without thread - lock as it is a simple dereference. */ - fd = _wopen(PyUnicode_AS_UNICODE(po), flag, mode); - Py_END_ALLOW_THREADS - if (fd < 0) - return posix_error(); - return PyInt_FromLong((long)fd); - } - /* Drop the argument parsing error as narrow strings - are also valid. */ - PyErr_Clear(); - } -#endif - - if (!PyArg_ParseTuple(args, "eti|i", - Py_FileSystemDefaultEncoding, &file, - &flag, &mode)) - return NULL; - - Py_BEGIN_ALLOW_THREADS - fd = open(file, flag, mode); - Py_END_ALLOW_THREADS - if (fd < 0) - return posix_error_with_allocated_filename(file); - PyMem_Free(file); - return PyInt_FromLong((long)fd); -} - - -PyDoc_STRVAR(posix_close__doc__, -"close(fd)\n\n\ -Close a file descriptor (for low level IO)."); - -static PyObject * -posix_close(PyObject *self, PyObject *args) -{ - int fd, res; - if (!PyArg_ParseTuple(args, "i:close", &fd)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = close(fd); - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} - - -PyDoc_STRVAR(posix_dup__doc__, -"dup(fd) -> fd2\n\n\ -Return a duplicate of a file descriptor."); - -static PyObject * -posix_dup(PyObject *self, PyObject *args) -{ - int fd; - if (!PyArg_ParseTuple(args, "i:dup", &fd)) - return NULL; - Py_BEGIN_ALLOW_THREADS - fd = dup(fd); - Py_END_ALLOW_THREADS - if (fd < 0) - return posix_error(); - return PyInt_FromLong((long)fd); -} - - -PyDoc_STRVAR(posix_dup2__doc__, -"dup2(fd, fd2)\n\n\ -Duplicate file descriptor."); - -static PyObject * -posix_dup2(PyObject *self, PyObject *args) -{ - int fd, fd2, res; - if (!PyArg_ParseTuple(args, "ii:dup2", &fd, &fd2)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = dup2(fd, fd2); - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} - - -PyDoc_STRVAR(posix_lseek__doc__, -"lseek(fd, pos, how) -> newpos\n\n\ -Set the current position of a file descriptor."); - -static PyObject * -posix_lseek(PyObject *self, PyObject *args) -{ - int fd, how; -#if defined(MS_WIN64) || defined(MS_WINDOWS) - PY_LONG_LONG pos, res; -#else - off_t pos, res; -#endif - PyObject *posobj; - if (!PyArg_ParseTuple(args, "iOi:lseek", &fd, &posobj, &how)) - return NULL; -#ifdef SEEK_SET - /* Turn 0, 1, 2 into SEEK_{SET,CUR,END} */ - switch (how) { - case 0: how = SEEK_SET; break; - case 1: how = SEEK_CUR; break; - case 2: how = SEEK_END; break; - } -#endif /* SEEK_END */ - -#if !defined(HAVE_LARGEFILE_SUPPORT) - pos = PyInt_AsLong(posobj); -#else - pos = PyLong_Check(posobj) ? - PyLong_AsLongLong(posobj) : PyInt_AsLong(posobj); -#endif - if (PyErr_Occurred()) - return NULL; - - Py_BEGIN_ALLOW_THREADS -#if defined(MS_WIN64) || defined(MS_WINDOWS) - res = _lseeki64(fd, pos, how); -#else - res = lseek(fd, pos, how); -#endif - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error(); - -#if !defined(HAVE_LARGEFILE_SUPPORT) - return PyInt_FromLong(res); -#else - return PyLong_FromLongLong(res); -#endif -} - - -PyDoc_STRVAR(posix_read__doc__, -"read(fd, buffersize) -> string\n\n\ -Read a file descriptor."); - -static PyObject * -posix_read(PyObject *self, PyObject *args) -{ - int fd, size, n; - PyObject *buffer; - if (!PyArg_ParseTuple(args, "ii:read", &fd, &size)) - return NULL; - buffer = PyString_FromStringAndSize((char *)NULL, size); - if (buffer == NULL) - return NULL; - Py_BEGIN_ALLOW_THREADS - n = read(fd, PyString_AsString(buffer), size); - Py_END_ALLOW_THREADS - if (n < 0) { - Py_DECREF(buffer); - return posix_error(); - } - if (n != size) - _PyString_Resize(&buffer, n); - return buffer; -} - - -PyDoc_STRVAR(posix_write__doc__, -"write(fd, string) -> byteswritten\n\n\ -Write a string to a file descriptor."); - -static PyObject * -posix_write(PyObject *self, PyObject *args) -{ - int fd, size; - char *buffer; - if (!PyArg_ParseTuple(args, "is#:write", &fd, &buffer, &size)) - return NULL; - Py_BEGIN_ALLOW_THREADS - size = write(fd, buffer, size); - Py_END_ALLOW_THREADS - if (size < 0) - return posix_error(); - return PyInt_FromLong((long)size); -} - - -PyDoc_STRVAR(posix_fstat__doc__, -"fstat(fd) -> stat result\n\n\ -Like stat(), but for an open file descriptor."); - -static PyObject * -posix_fstat(PyObject *self, PyObject *args) -{ - int fd; - STRUCT_STAT st; - int res; - if (!PyArg_ParseTuple(args, "i:fstat", &fd)) - return NULL; -#ifdef __VMS - /* on OpenVMS we must ensure that all bytes are written to the file */ - fsync(fd); -#endif - Py_BEGIN_ALLOW_THREADS - res = FSTAT(fd, &st); - Py_END_ALLOW_THREADS - if (res != 0) - return posix_error(); - - return _pystat_fromstructstat(st); -} - - -PyDoc_STRVAR(posix_fdopen__doc__, -"fdopen(fd [, mode='r' [, bufsize]]) -> file_object\n\n\ -Return an open file object connected to a file descriptor."); - -static PyObject * -posix_fdopen(PyObject *self, PyObject *args) -{ - int fd; - char *mode = "r"; - int bufsize = -1; - FILE *fp; - PyObject *f; - if (!PyArg_ParseTuple(args, "i|si", &fd, &mode, &bufsize)) - return NULL; - - if (mode[0] != 'r' && mode[0] != 'w' && mode[0] != 'a') { - PyErr_Format(PyExc_ValueError, - "invalid file mode '%s'", mode); - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - fp = fdopen(fd, mode); - Py_END_ALLOW_THREADS - if (fp == NULL) - return posix_error(); - f = PyFile_FromFile(fp, "", mode, fclose); - if (f != NULL) - PyFile_SetBufSize(f, bufsize); - return f; -} - -PyDoc_STRVAR(posix_isatty__doc__, -"isatty(fd) -> bool\n\n\ -Return True if the file descriptor 'fd' is an open file descriptor\n\ -connected to the slave end of a terminal."); - -static PyObject * -posix_isatty(PyObject *self, PyObject *args) -{ - int fd; - if (!PyArg_ParseTuple(args, "i:isatty", &fd)) - return NULL; - return PyBool_FromLong(isatty(fd)); -} - -#ifdef HAVE_PIPE -PyDoc_STRVAR(posix_pipe__doc__, -"pipe() -> (read_end, write_end)\n\n\ -Create a pipe."); - -static PyObject * -posix_pipe(PyObject *self, PyObject *noargs) -{ -#if defined(PYOS_OS2) - HFILE read, write; - APIRET rc; - - Py_BEGIN_ALLOW_THREADS - rc = DosCreatePipe( &read, &write, 4096); - Py_END_ALLOW_THREADS - if (rc != NO_ERROR) - return os2_error(rc); - - return Py_BuildValue("(ii)", read, write); -#else -#if !defined(MS_WINDOWS) - int fds[2]; - int res; - Py_BEGIN_ALLOW_THREADS - res = pipe(fds); - Py_END_ALLOW_THREADS - if (res != 0) - return posix_error(); - return Py_BuildValue("(ii)", fds[0], fds[1]); -#else /* MS_WINDOWS */ -#ifndef MS_XBOX - HANDLE read, write; - int read_fd, write_fd; - BOOL ok; - Py_BEGIN_ALLOW_THREADS - ok = CreatePipe(&read, &write, NULL, 0); - Py_END_ALLOW_THREADS - if (!ok) - return win32_error("CreatePipe", NULL); - read_fd = _open_osfhandle((Py_intptr_t)read, 0); - write_fd = _open_osfhandle((Py_intptr_t)write, 1); - return Py_BuildValue("(ii)", read_fd, write_fd); -#else - return Py_BuildValue("(ii)", 0, 0); -#endif /* MS_XBOX */ -#endif /* MS_WINDOWS */ -#endif -} -#endif /* HAVE_PIPE */ - - -#ifdef HAVE_MKFIFO -PyDoc_STRVAR(posix_mkfifo__doc__, -"mkfifo(filename [, mode=0666])\n\n\ -Create a FIFO (a POSIX named pipe)."); - -static PyObject * -posix_mkfifo(PyObject *self, PyObject *args) -{ - char *filename; - int mode = 0666; - int res; - if (!PyArg_ParseTuple(args, "s|i:mkfifo", &filename, &mode)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = mkfifo(filename, mode); - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} -#endif - - -#if defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV) -PyDoc_STRVAR(posix_mknod__doc__, -"mknod(filename [, mode=0600, device])\n\n\ -Create a filesystem node (file, device special file or named pipe)\n\ -named filename. mode specifies both the permissions to use and the\n\ -type of node to be created, being combined (bitwise OR) with one of\n\ -S_IFREG, S_IFCHR, S_IFBLK, and S_IFIFO. For S_IFCHR and S_IFBLK,\n\ -device defines the newly created device special file (probably using\n\ -os.makedev()), otherwise it is ignored."); - - -static PyObject * -posix_mknod(PyObject *self, PyObject *args) -{ - char *filename; - int mode = 0600; - int device = 0; - int res; - if (!PyArg_ParseTuple(args, "s|ii:mknod", &filename, &mode, &device)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = mknod(filename, mode, device); - Py_END_ALLOW_THREADS - if (res < 0) - return posix_error(); - Py_INCREF(Py_None); - return Py_None; -} -#endif - -#ifdef HAVE_DEVICE_MACROS -PyDoc_STRVAR(posix_major__doc__, -"major(device) -> major number\n\ -Extracts a device major number from a raw device number."); - -static PyObject * -posix_major(PyObject *self, PyObject *args) -{ - int device; - if (!PyArg_ParseTuple(args, "i:major", &device)) - return NULL; - return PyInt_FromLong((long)major(device)); -} - -PyDoc_STRVAR(posix_minor__doc__, -"minor(device) -> minor number\n\ -Extracts a device minor number from a raw device number."); - -static PyObject * -posix_minor(PyObject *self, PyObject *args) -{ - int device; - if (!PyArg_ParseTuple(args, "i:minor", &device)) - return NULL; - return PyInt_FromLong((long)minor(device)); -} - -PyDoc_STRVAR(posix_makedev__doc__, -"makedev(major, minor) -> device number\n\ -Composes a raw device number from the major and minor device numbers."); - -static PyObject * -posix_makedev(PyObject *self, PyObject *args) -{ - int major, minor; - if (!PyArg_ParseTuple(args, "ii:makedev", &major, &minor)) - return NULL; - return PyInt_FromLong((long)makedev(major, minor)); -} -#endif /* device macros */ - - -#ifdef HAVE_FTRUNCATE -PyDoc_STRVAR(posix_ftruncate__doc__, -"ftruncate(fd, length)\n\n\ -Truncate a file to a specified length."); - -static PyObject * -posix_ftruncate(PyObject *self, PyObject *args) -{ - int fd; - off_t length; - int res; - PyObject *lenobj; - - if (!PyArg_ParseTuple(args, "iO:ftruncate", &fd, &lenobj)) - return NULL; - -#if !defined(HAVE_LARGEFILE_SUPPORT) - length = PyInt_AsLong(lenobj); -#else - length = PyLong_Check(lenobj) ? - PyLong_AsLongLong(lenobj) : PyInt_AsLong(lenobj); -#endif - if (PyErr_Occurred()) - return NULL; - - Py_BEGIN_ALLOW_THREADS - res = ftruncate(fd, length); - Py_END_ALLOW_THREADS - if (res < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} -#endif - -#ifdef HAVE_PUTENV -PyDoc_STRVAR(posix_putenv__doc__, -"putenv(key, value)\n\n\ -Change or add an environment variable."); - -/* Save putenv() parameters as values here, so we can collect them when they - * get re-set with another call for the same key. */ -static PyObject *posix_putenv_garbage; - -static PyObject * -posix_putenv(PyObject *self, PyObject *args) -{ - char *s1, *s2; - char *new; - PyObject *newstr; - size_t len; - - if (!PyArg_ParseTuple(args, "ss:putenv", &s1, &s2)) - return NULL; - -#if defined(PYOS_OS2) - if (stricmp(s1, "BEGINLIBPATH") == 0) { - APIRET rc; - - rc = DosSetExtLIBPATH(s2, BEGIN_LIBPATH); - if (rc != NO_ERROR) - return os2_error(rc); - - } else if (stricmp(s1, "ENDLIBPATH") == 0) { - APIRET rc; - - rc = DosSetExtLIBPATH(s2, END_LIBPATH); - if (rc != NO_ERROR) - return os2_error(rc); - } else { -#endif - - /* XXX This can leak memory -- not easy to fix :-( */ - len = strlen(s1) + strlen(s2) + 2; - /* len includes space for a trailing \0; the size arg to - PyString_FromStringAndSize does not count that */ - newstr = PyString_FromStringAndSize(NULL, (int)len - 1); - if (newstr == NULL) - return PyErr_NoMemory(); - new = PyString_AS_STRING(newstr); - PyOS_snprintf(new, len, "%s=%s", s1, s2); - if (putenv(new)) { - Py_DECREF(newstr); - posix_error(); - return NULL; - } - /* Install the first arg and newstr in posix_putenv_garbage; - * this will cause previous value to be collected. This has to - * happen after the real putenv() call because the old value - * was still accessible until then. */ - if (PyDict_SetItem(posix_putenv_garbage, - PyTuple_GET_ITEM(args, 0), newstr)) { - /* really not much we can do; just leak */ - PyErr_Clear(); - } - else { - Py_DECREF(newstr); - } - -#if defined(PYOS_OS2) - } -#endif - Py_INCREF(Py_None); - return Py_None; -} -#endif /* putenv */ - -#ifdef HAVE_UNSETENV -PyDoc_STRVAR(posix_unsetenv__doc__, -"unsetenv(key)\n\n\ -Delete an environment variable."); - -static PyObject * -posix_unsetenv(PyObject *self, PyObject *args) -{ - char *s1; - - if (!PyArg_ParseTuple(args, "s:unsetenv", &s1)) - return NULL; - - unsetenv(s1); - - /* Remove the key from posix_putenv_garbage; - * this will cause it to be collected. This has to - * happen after the real unsetenv() call because the - * old value was still accessible until then. - */ - if (PyDict_DelItem(posix_putenv_garbage, - PyTuple_GET_ITEM(args, 0))) { - /* really not much we can do; just leak */ - PyErr_Clear(); - } - - Py_INCREF(Py_None); - return Py_None; -} -#endif /* unsetenv */ - -#ifdef HAVE_STRERROR -PyDoc_STRVAR(posix_strerror__doc__, -"strerror(code) -> string\n\n\ -Translate an error code to a message string."); - -static PyObject * -posix_strerror(PyObject *self, PyObject *args) -{ - int code; - char *message; - if (!PyArg_ParseTuple(args, "i:strerror", &code)) - return NULL; - message = strerror(code); - if (message == NULL) { - PyErr_SetString(PyExc_ValueError, - "strerror() argument out of range"); - return NULL; - } - return PyString_FromString(message); -} -#endif /* strerror */ - - -#ifdef HAVE_SYS_WAIT_H - -#ifdef WCOREDUMP -PyDoc_STRVAR(posix_WCOREDUMP__doc__, -"WCOREDUMP(status) -> bool\n\n\ -Return True if the process returning 'status' was dumped to a core file."); - -static PyObject * -posix_WCOREDUMP(PyObject *self, PyObject *args) -{ -#ifdef UNION_WAIT - union wait status; -#define status_i (status.w_status) -#else - int status; -#define status_i status -#endif - status_i = 0; - - if (!PyArg_ParseTuple(args, "i:WCOREDUMP", &status_i)) - { - return NULL; - } - - return PyBool_FromLong(WCOREDUMP(status)); -#undef status_i -} -#endif /* WCOREDUMP */ - -#ifdef WIFCONTINUED -PyDoc_STRVAR(posix_WIFCONTINUED__doc__, -"WIFCONTINUED(status) -> bool\n\n\ -Return True if the process returning 'status' was continued from a\n\ -job control stop."); - -static PyObject * -posix_WIFCONTINUED(PyObject *self, PyObject *args) -{ -#ifdef UNION_WAIT - union wait status; -#define status_i (status.w_status) -#else - int status; -#define status_i status -#endif - status_i = 0; - - if (!PyArg_ParseTuple(args, "i:WCONTINUED", &status_i)) - { - return NULL; - } - - return PyBool_FromLong(WIFCONTINUED(status)); -#undef status_i -} -#endif /* WIFCONTINUED */ - -#ifdef WIFSTOPPED -PyDoc_STRVAR(posix_WIFSTOPPED__doc__, -"WIFSTOPPED(status) -> bool\n\n\ -Return True if the process returning 'status' was stopped."); - -static PyObject * -posix_WIFSTOPPED(PyObject *self, PyObject *args) -{ -#ifdef UNION_WAIT - union wait status; -#define status_i (status.w_status) -#else - int status; -#define status_i status -#endif - status_i = 0; - - if (!PyArg_ParseTuple(args, "i:WIFSTOPPED", &status_i)) - { - return NULL; - } - - return PyBool_FromLong(WIFSTOPPED(status)); -#undef status_i -} -#endif /* WIFSTOPPED */ - -#ifdef WIFSIGNALED -PyDoc_STRVAR(posix_WIFSIGNALED__doc__, -"WIFSIGNALED(status) -> bool\n\n\ -Return True if the process returning 'status' was terminated by a signal."); - -static PyObject * -posix_WIFSIGNALED(PyObject *self, PyObject *args) -{ -#ifdef UNION_WAIT - union wait status; -#define status_i (status.w_status) -#else - int status; -#define status_i status -#endif - status_i = 0; - - if (!PyArg_ParseTuple(args, "i:WIFSIGNALED", &status_i)) - { - return NULL; - } - - return PyBool_FromLong(WIFSIGNALED(status)); -#undef status_i -} -#endif /* WIFSIGNALED */ - -#ifdef WIFEXITED -PyDoc_STRVAR(posix_WIFEXITED__doc__, -"WIFEXITED(status) -> bool\n\n\ -Return true if the process returning 'status' exited using the exit()\n\ -system call."); - -static PyObject * -posix_WIFEXITED(PyObject *self, PyObject *args) -{ -#ifdef UNION_WAIT - union wait status; -#define status_i (status.w_status) -#else - int status; -#define status_i status -#endif - status_i = 0; - - if (!PyArg_ParseTuple(args, "i:WIFEXITED", &status_i)) - { - return NULL; - } - - return PyBool_FromLong(WIFEXITED(status)); -#undef status_i -} -#endif /* WIFEXITED */ - -#ifdef WEXITSTATUS -PyDoc_STRVAR(posix_WEXITSTATUS__doc__, -"WEXITSTATUS(status) -> integer\n\n\ -Return the process return code from 'status'."); - -static PyObject * -posix_WEXITSTATUS(PyObject *self, PyObject *args) -{ -#ifdef UNION_WAIT - union wait status; -#define status_i (status.w_status) -#else - int status; -#define status_i status -#endif - status_i = 0; - - if (!PyArg_ParseTuple(args, "i:WEXITSTATUS", &status_i)) - { - return NULL; - } - - return Py_BuildValue("i", WEXITSTATUS(status)); -#undef status_i -} -#endif /* WEXITSTATUS */ - -#ifdef WTERMSIG -PyDoc_STRVAR(posix_WTERMSIG__doc__, -"WTERMSIG(status) -> integer\n\n\ -Return the signal that terminated the process that provided the 'status'\n\ -value."); - -static PyObject * -posix_WTERMSIG(PyObject *self, PyObject *args) -{ -#ifdef UNION_WAIT - union wait status; -#define status_i (status.w_status) -#else - int status; -#define status_i status -#endif - status_i = 0; - - if (!PyArg_ParseTuple(args, "i:WTERMSIG", &status_i)) - { - return NULL; - } - - return Py_BuildValue("i", WTERMSIG(status)); -#undef status_i -} -#endif /* WTERMSIG */ - -#ifdef WSTOPSIG -PyDoc_STRVAR(posix_WSTOPSIG__doc__, -"WSTOPSIG(status) -> integer\n\n\ -Return the signal that stopped the process that provided\n\ -the 'status' value."); - -static PyObject * -posix_WSTOPSIG(PyObject *self, PyObject *args) -{ -#ifdef UNION_WAIT - union wait status; -#define status_i (status.w_status) -#else - int status; -#define status_i status -#endif - status_i = 0; - - if (!PyArg_ParseTuple(args, "i:WSTOPSIG", &status_i)) - { - return NULL; - } - - return Py_BuildValue("i", WSTOPSIG(status)); -#undef status_i -} -#endif /* WSTOPSIG */ - -#endif /* HAVE_SYS_WAIT_H */ - - -#if defined(HAVE_FSTATVFS) -#ifdef _SCO_DS -/* SCO OpenServer 5.0 and later requires _SVID3 before it reveals the - needed definitions in sys/statvfs.h */ -#define _SVID3 -#endif -#include - -static PyObject* -_pystatvfs_fromstructstatvfs(struct statvfs st) { - PyObject *v = PyStructSequence_New(&StatVFSResultType); - if (v == NULL) - return NULL; - -#if !defined(HAVE_LARGEFILE_SUPPORT) - PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long) st.f_bsize)); - PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long) st.f_frsize)); - PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long) st.f_blocks)); - PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long) st.f_bfree)); - PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long) st.f_bavail)); - PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long) st.f_files)); - PyStructSequence_SET_ITEM(v, 6, PyInt_FromLong((long) st.f_ffree)); - PyStructSequence_SET_ITEM(v, 7, PyInt_FromLong((long) st.f_favail)); - PyStructSequence_SET_ITEM(v, 8, PyInt_FromLong((long) st.f_flag)); - PyStructSequence_SET_ITEM(v, 9, PyInt_FromLong((long) st.f_namemax)); -#else - PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long) st.f_bsize)); - PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long) st.f_frsize)); - PyStructSequence_SET_ITEM(v, 2, - PyLong_FromLongLong((PY_LONG_LONG) st.f_blocks)); - PyStructSequence_SET_ITEM(v, 3, - PyLong_FromLongLong((PY_LONG_LONG) st.f_bfree)); - PyStructSequence_SET_ITEM(v, 4, - PyLong_FromLongLong((PY_LONG_LONG) st.f_bavail)); - PyStructSequence_SET_ITEM(v, 5, - PyLong_FromLongLong((PY_LONG_LONG) st.f_files)); - PyStructSequence_SET_ITEM(v, 6, - PyLong_FromLongLong((PY_LONG_LONG) st.f_ffree)); - PyStructSequence_SET_ITEM(v, 7, - PyLong_FromLongLong((PY_LONG_LONG) st.f_favail)); - PyStructSequence_SET_ITEM(v, 8, PyInt_FromLong((long) st.f_flag)); - PyStructSequence_SET_ITEM(v, 9, PyInt_FromLong((long) st.f_namemax)); -#endif - - return v; -} - -PyDoc_STRVAR(posix_fstatvfs__doc__, -"fstatvfs(fd) -> statvfs result\n\n\ -Perform an fstatvfs system call on the given fd."); - -static PyObject * -posix_fstatvfs(PyObject *self, PyObject *args) -{ - int fd, res; - struct statvfs st; - - if (!PyArg_ParseTuple(args, "i:fstatvfs", &fd)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = fstatvfs(fd, &st); - Py_END_ALLOW_THREADS - if (res != 0) - return posix_error(); - - return _pystatvfs_fromstructstatvfs(st); -} -#endif /* HAVE_FSTATVFS */ - - -#if defined(HAVE_STATVFS) -#include - -PyDoc_STRVAR(posix_statvfs__doc__, -"statvfs(path) -> statvfs result\n\n\ -Perform a statvfs system call on the given path."); - -static PyObject * -posix_statvfs(PyObject *self, PyObject *args) -{ - char *path; - int res; - struct statvfs st; - if (!PyArg_ParseTuple(args, "s:statvfs", &path)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = statvfs(path, &st); - Py_END_ALLOW_THREADS - if (res != 0) - return posix_error_with_filename(path); - - return _pystatvfs_fromstructstatvfs(st); -} -#endif /* HAVE_STATVFS */ - - -#ifdef HAVE_TEMPNAM -PyDoc_STRVAR(posix_tempnam__doc__, -"tempnam([dir[, prefix]]) -> string\n\n\ -Return a unique name for a temporary file.\n\ -The directory and a prefix may be specified as strings; they may be omitted\n\ -or None if not needed."); - -static PyObject * -posix_tempnam(PyObject *self, PyObject *args) -{ - PyObject *result = NULL; - char *dir = NULL; - char *pfx = NULL; - char *name; - - if (!PyArg_ParseTuple(args, "|zz:tempnam", &dir, &pfx)) - return NULL; - - if (PyErr_Warn(PyExc_RuntimeWarning, - "tempnam is a potential security risk to your program") < 0) - return NULL; - -#ifdef MS_WINDOWS - name = _tempnam(dir, pfx); -#else - name = tempnam(dir, pfx); -#endif - if (name == NULL) - return PyErr_NoMemory(); - result = PyString_FromString(name); - free(name); - return result; -} -#endif - - -#ifdef HAVE_TMPFILE -PyDoc_STRVAR(posix_tmpfile__doc__, -"tmpfile() -> file object\n\n\ -Create a temporary file with no directory entries."); - -static PyObject * -posix_tmpfile(PyObject *self, PyObject *noargs) -{ - FILE *fp; - - fp = tmpfile(); - if (fp == NULL) - return posix_error(); - return PyFile_FromFile(fp, "", "w+b", fclose); -} -#endif - - -#ifdef HAVE_TMPNAM -PyDoc_STRVAR(posix_tmpnam__doc__, -"tmpnam() -> string\n\n\ -Return a unique name for a temporary file."); - -static PyObject * -posix_tmpnam(PyObject *self, PyObject *noargs) -{ - char buffer[L_tmpnam]; - char *name; - - if (PyErr_Warn(PyExc_RuntimeWarning, - "tmpnam is a potential security risk to your program") < 0) - return NULL; - -#ifdef USE_TMPNAM_R - name = tmpnam_r(buffer); -#else - name = tmpnam(buffer); -#endif - if (name == NULL) { - PyErr_SetObject(PyExc_OSError, - Py_BuildValue("is", 0, -#ifdef USE_TMPNAM_R - "unexpected NULL from tmpnam_r" -#else - "unexpected NULL from tmpnam" -#endif - )); - return NULL; - } - return PyString_FromString(buffer); -} -#endif - - -/* This is used for fpathconf(), pathconf(), confstr() and sysconf(). - * It maps strings representing configuration variable names to - * integer values, allowing those functions to be called with the - * magic names instead of polluting the module's namespace with tons of - * rarely-used constants. There are three separate tables that use - * these definitions. - * - * This code is always included, even if none of the interfaces that - * need it are included. The #if hackery needed to avoid it would be - * sufficiently pervasive that it's not worth the loss of readability. - */ -struct constdef { - char *name; - long value; -}; - -static int -conv_confname(PyObject *arg, int *valuep, struct constdef *table, - size_t tablesize) -{ - if (PyInt_Check(arg)) { - *valuep = PyInt_AS_LONG(arg); - return 1; - } - if (PyString_Check(arg)) { - /* look up the value in the table using a binary search */ - size_t lo = 0; - size_t mid; - size_t hi = tablesize; - int cmp; - char *confname = PyString_AS_STRING(arg); - while (lo < hi) { - mid = (lo + hi) / 2; - cmp = strcmp(confname, table[mid].name); - if (cmp < 0) - hi = mid; - else if (cmp > 0) - lo = mid + 1; - else { - *valuep = table[mid].value; - return 1; - } - } - PyErr_SetString(PyExc_ValueError, "unrecognized configuration name"); - } - else - PyErr_SetString(PyExc_TypeError, - "configuration names must be strings or integers"); - return 0; -} - - -#if defined(HAVE_FPATHCONF) || defined(HAVE_PATHCONF) -static struct constdef posix_constants_pathconf[] = { -#ifdef _PC_ABI_AIO_XFER_MAX - {"PC_ABI_AIO_XFER_MAX", _PC_ABI_AIO_XFER_MAX}, -#endif -#ifdef _PC_ABI_ASYNC_IO - {"PC_ABI_ASYNC_IO", _PC_ABI_ASYNC_IO}, -#endif -#ifdef _PC_ASYNC_IO - {"PC_ASYNC_IO", _PC_ASYNC_IO}, -#endif -#ifdef _PC_CHOWN_RESTRICTED - {"PC_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED}, -#endif -#ifdef _PC_FILESIZEBITS - {"PC_FILESIZEBITS", _PC_FILESIZEBITS}, -#endif -#ifdef _PC_LAST - {"PC_LAST", _PC_LAST}, -#endif -#ifdef _PC_LINK_MAX - {"PC_LINK_MAX", _PC_LINK_MAX}, -#endif -#ifdef _PC_MAX_CANON - {"PC_MAX_CANON", _PC_MAX_CANON}, -#endif -#ifdef _PC_MAX_INPUT - {"PC_MAX_INPUT", _PC_MAX_INPUT}, -#endif -#ifdef _PC_NAME_MAX - {"PC_NAME_MAX", _PC_NAME_MAX}, -#endif -#ifdef _PC_NO_TRUNC - {"PC_NO_TRUNC", _PC_NO_TRUNC}, -#endif -#ifdef _PC_PATH_MAX - {"PC_PATH_MAX", _PC_PATH_MAX}, -#endif -#ifdef _PC_PIPE_BUF - {"PC_PIPE_BUF", _PC_PIPE_BUF}, -#endif -#ifdef _PC_PRIO_IO - {"PC_PRIO_IO", _PC_PRIO_IO}, -#endif -#ifdef _PC_SOCK_MAXBUF - {"PC_SOCK_MAXBUF", _PC_SOCK_MAXBUF}, -#endif -#ifdef _PC_SYNC_IO - {"PC_SYNC_IO", _PC_SYNC_IO}, -#endif -#ifdef _PC_VDISABLE - {"PC_VDISABLE", _PC_VDISABLE}, -#endif -}; - -static int -conv_path_confname(PyObject *arg, int *valuep) -{ - return conv_confname(arg, valuep, posix_constants_pathconf, - sizeof(posix_constants_pathconf) - / sizeof(struct constdef)); -} -#endif - -#ifdef HAVE_FPATHCONF -PyDoc_STRVAR(posix_fpathconf__doc__, -"fpathconf(fd, name) -> integer\n\n\ -Return the configuration limit name for the file descriptor fd.\n\ -If there is no limit, return -1."); - -static PyObject * -posix_fpathconf(PyObject *self, PyObject *args) -{ - PyObject *result = NULL; - int name, fd; - - if (PyArg_ParseTuple(args, "iO&:fpathconf", &fd, - conv_path_confname, &name)) { - long limit; - - errno = 0; - limit = fpathconf(fd, name); - if (limit == -1 && errno != 0) - posix_error(); - else - result = PyInt_FromLong(limit); - } - return result; -} -#endif - - -#ifdef HAVE_PATHCONF -PyDoc_STRVAR(posix_pathconf__doc__, -"pathconf(path, name) -> integer\n\n\ -Return the configuration limit name for the file or directory path.\n\ -If there is no limit, return -1."); - -static PyObject * -posix_pathconf(PyObject *self, PyObject *args) -{ - PyObject *result = NULL; - int name; - char *path; - - if (PyArg_ParseTuple(args, "sO&:pathconf", &path, - conv_path_confname, &name)) { - long limit; - - errno = 0; - limit = pathconf(path, name); - if (limit == -1 && errno != 0) { - if (errno == EINVAL) - /* could be a path or name problem */ - posix_error(); - else - posix_error_with_filename(path); - } - else - result = PyInt_FromLong(limit); - } - return result; -} -#endif - -#ifdef HAVE_CONFSTR -static struct constdef posix_constants_confstr[] = { -#ifdef _CS_ARCHITECTURE - {"CS_ARCHITECTURE", _CS_ARCHITECTURE}, -#endif -#ifdef _CS_HOSTNAME - {"CS_HOSTNAME", _CS_HOSTNAME}, -#endif -#ifdef _CS_HW_PROVIDER - {"CS_HW_PROVIDER", _CS_HW_PROVIDER}, -#endif -#ifdef _CS_HW_SERIAL - {"CS_HW_SERIAL", _CS_HW_SERIAL}, -#endif -#ifdef _CS_INITTAB_NAME - {"CS_INITTAB_NAME", _CS_INITTAB_NAME}, -#endif -#ifdef _CS_LFS64_CFLAGS - {"CS_LFS64_CFLAGS", _CS_LFS64_CFLAGS}, -#endif -#ifdef _CS_LFS64_LDFLAGS - {"CS_LFS64_LDFLAGS", _CS_LFS64_LDFLAGS}, -#endif -#ifdef _CS_LFS64_LIBS - {"CS_LFS64_LIBS", _CS_LFS64_LIBS}, -#endif -#ifdef _CS_LFS64_LINTFLAGS - {"CS_LFS64_LINTFLAGS", _CS_LFS64_LINTFLAGS}, -#endif -#ifdef _CS_LFS_CFLAGS - {"CS_LFS_CFLAGS", _CS_LFS_CFLAGS}, -#endif -#ifdef _CS_LFS_LDFLAGS - {"CS_LFS_LDFLAGS", _CS_LFS_LDFLAGS}, -#endif -#ifdef _CS_LFS_LIBS - {"CS_LFS_LIBS", _CS_LFS_LIBS}, -#endif -#ifdef _CS_LFS_LINTFLAGS - {"CS_LFS_LINTFLAGS", _CS_LFS_LINTFLAGS}, -#endif -#ifdef _CS_MACHINE - {"CS_MACHINE", _CS_MACHINE}, -#endif -#ifdef _CS_PATH - {"CS_PATH", _CS_PATH}, -#endif -#ifdef _CS_RELEASE - {"CS_RELEASE", _CS_RELEASE}, -#endif -#ifdef _CS_SRPC_DOMAIN - {"CS_SRPC_DOMAIN", _CS_SRPC_DOMAIN}, -#endif -#ifdef _CS_SYSNAME - {"CS_SYSNAME", _CS_SYSNAME}, -#endif -#ifdef _CS_VERSION - {"CS_VERSION", _CS_VERSION}, -#endif -#ifdef _CS_XBS5_ILP32_OFF32_CFLAGS - {"CS_XBS5_ILP32_OFF32_CFLAGS", _CS_XBS5_ILP32_OFF32_CFLAGS}, -#endif -#ifdef _CS_XBS5_ILP32_OFF32_LDFLAGS - {"CS_XBS5_ILP32_OFF32_LDFLAGS", _CS_XBS5_ILP32_OFF32_LDFLAGS}, -#endif -#ifdef _CS_XBS5_ILP32_OFF32_LIBS - {"CS_XBS5_ILP32_OFF32_LIBS", _CS_XBS5_ILP32_OFF32_LIBS}, -#endif -#ifdef _CS_XBS5_ILP32_OFF32_LINTFLAGS - {"CS_XBS5_ILP32_OFF32_LINTFLAGS", _CS_XBS5_ILP32_OFF32_LINTFLAGS}, -#endif -#ifdef _CS_XBS5_ILP32_OFFBIG_CFLAGS - {"CS_XBS5_ILP32_OFFBIG_CFLAGS", _CS_XBS5_ILP32_OFFBIG_CFLAGS}, -#endif -#ifdef _CS_XBS5_ILP32_OFFBIG_LDFLAGS - {"CS_XBS5_ILP32_OFFBIG_LDFLAGS", _CS_XBS5_ILP32_OFFBIG_LDFLAGS}, -#endif -#ifdef _CS_XBS5_ILP32_OFFBIG_LIBS - {"CS_XBS5_ILP32_OFFBIG_LIBS", _CS_XBS5_ILP32_OFFBIG_LIBS}, -#endif -#ifdef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS - {"CS_XBS5_ILP32_OFFBIG_LINTFLAGS", _CS_XBS5_ILP32_OFFBIG_LINTFLAGS}, -#endif -#ifdef _CS_XBS5_LP64_OFF64_CFLAGS - {"CS_XBS5_LP64_OFF64_CFLAGS", _CS_XBS5_LP64_OFF64_CFLAGS}, -#endif -#ifdef _CS_XBS5_LP64_OFF64_LDFLAGS - {"CS_XBS5_LP64_OFF64_LDFLAGS", _CS_XBS5_LP64_OFF64_LDFLAGS}, -#endif -#ifdef _CS_XBS5_LP64_OFF64_LIBS - {"CS_XBS5_LP64_OFF64_LIBS", _CS_XBS5_LP64_OFF64_LIBS}, -#endif -#ifdef _CS_XBS5_LP64_OFF64_LINTFLAGS - {"CS_XBS5_LP64_OFF64_LINTFLAGS", _CS_XBS5_LP64_OFF64_LINTFLAGS}, -#endif -#ifdef _CS_XBS5_LPBIG_OFFBIG_CFLAGS - {"CS_XBS5_LPBIG_OFFBIG_CFLAGS", _CS_XBS5_LPBIG_OFFBIG_CFLAGS}, -#endif -#ifdef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS - {"CS_XBS5_LPBIG_OFFBIG_LDFLAGS", _CS_XBS5_LPBIG_OFFBIG_LDFLAGS}, -#endif -#ifdef _CS_XBS5_LPBIG_OFFBIG_LIBS - {"CS_XBS5_LPBIG_OFFBIG_LIBS", _CS_XBS5_LPBIG_OFFBIG_LIBS}, -#endif -#ifdef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS - {"CS_XBS5_LPBIG_OFFBIG_LINTFLAGS", _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS}, -#endif -#ifdef _MIPS_CS_AVAIL_PROCESSORS - {"MIPS_CS_AVAIL_PROCESSORS", _MIPS_CS_AVAIL_PROCESSORS}, -#endif -#ifdef _MIPS_CS_BASE - {"MIPS_CS_BASE", _MIPS_CS_BASE}, -#endif -#ifdef _MIPS_CS_HOSTID - {"MIPS_CS_HOSTID", _MIPS_CS_HOSTID}, -#endif -#ifdef _MIPS_CS_HW_NAME - {"MIPS_CS_HW_NAME", _MIPS_CS_HW_NAME}, -#endif -#ifdef _MIPS_CS_NUM_PROCESSORS - {"MIPS_CS_NUM_PROCESSORS", _MIPS_CS_NUM_PROCESSORS}, -#endif -#ifdef _MIPS_CS_OSREL_MAJ - {"MIPS_CS_OSREL_MAJ", _MIPS_CS_OSREL_MAJ}, -#endif -#ifdef _MIPS_CS_OSREL_MIN - {"MIPS_CS_OSREL_MIN", _MIPS_CS_OSREL_MIN}, -#endif -#ifdef _MIPS_CS_OSREL_PATCH - {"MIPS_CS_OSREL_PATCH", _MIPS_CS_OSREL_PATCH}, -#endif -#ifdef _MIPS_CS_OS_NAME - {"MIPS_CS_OS_NAME", _MIPS_CS_OS_NAME}, -#endif -#ifdef _MIPS_CS_OS_PROVIDER - {"MIPS_CS_OS_PROVIDER", _MIPS_CS_OS_PROVIDER}, -#endif -#ifdef _MIPS_CS_PROCESSORS - {"MIPS_CS_PROCESSORS", _MIPS_CS_PROCESSORS}, -#endif -#ifdef _MIPS_CS_SERIAL - {"MIPS_CS_SERIAL", _MIPS_CS_SERIAL}, -#endif -#ifdef _MIPS_CS_VENDOR - {"MIPS_CS_VENDOR", _MIPS_CS_VENDOR}, -#endif -}; - -static int -conv_confstr_confname(PyObject *arg, int *valuep) -{ - return conv_confname(arg, valuep, posix_constants_confstr, - sizeof(posix_constants_confstr) - / sizeof(struct constdef)); -} - -PyDoc_STRVAR(posix_confstr__doc__, -"confstr(name) -> string\n\n\ -Return a string-valued system configuration variable."); - -static PyObject * -posix_confstr(PyObject *self, PyObject *args) -{ - PyObject *result = NULL; - int name; - char buffer[64]; - - if (PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name)) { - int len = confstr(name, buffer, sizeof(buffer)); - - errno = 0; - if (len == 0) { - if (errno != 0) - posix_error(); - else - result = PyString_FromString(""); - } - else { - if (len >= sizeof(buffer)) { - result = PyString_FromStringAndSize(NULL, len); - if (result != NULL) - confstr(name, PyString_AS_STRING(result), len+1); - } - else - result = PyString_FromString(buffer); - } - } - return result; -} -#endif - - -#ifdef HAVE_SYSCONF -static struct constdef posix_constants_sysconf[] = { -#ifdef _SC_2_CHAR_TERM - {"SC_2_CHAR_TERM", _SC_2_CHAR_TERM}, -#endif -#ifdef _SC_2_C_BIND - {"SC_2_C_BIND", _SC_2_C_BIND}, -#endif -#ifdef _SC_2_C_DEV - {"SC_2_C_DEV", _SC_2_C_DEV}, -#endif -#ifdef _SC_2_C_VERSION - {"SC_2_C_VERSION", _SC_2_C_VERSION}, -#endif -#ifdef _SC_2_FORT_DEV - {"SC_2_FORT_DEV", _SC_2_FORT_DEV}, -#endif -#ifdef _SC_2_FORT_RUN - {"SC_2_FORT_RUN", _SC_2_FORT_RUN}, -#endif -#ifdef _SC_2_LOCALEDEF - {"SC_2_LOCALEDEF", _SC_2_LOCALEDEF}, -#endif -#ifdef _SC_2_SW_DEV - {"SC_2_SW_DEV", _SC_2_SW_DEV}, -#endif -#ifdef _SC_2_UPE - {"SC_2_UPE", _SC_2_UPE}, -#endif -#ifdef _SC_2_VERSION - {"SC_2_VERSION", _SC_2_VERSION}, -#endif -#ifdef _SC_ABI_ASYNCHRONOUS_IO - {"SC_ABI_ASYNCHRONOUS_IO", _SC_ABI_ASYNCHRONOUS_IO}, -#endif -#ifdef _SC_ACL - {"SC_ACL", _SC_ACL}, -#endif -#ifdef _SC_AIO_LISTIO_MAX - {"SC_AIO_LISTIO_MAX", _SC_AIO_LISTIO_MAX}, -#endif -#ifdef _SC_AIO_MAX - {"SC_AIO_MAX", _SC_AIO_MAX}, -#endif -#ifdef _SC_AIO_PRIO_DELTA_MAX - {"SC_AIO_PRIO_DELTA_MAX", _SC_AIO_PRIO_DELTA_MAX}, -#endif -#ifdef _SC_ARG_MAX - {"SC_ARG_MAX", _SC_ARG_MAX}, -#endif -#ifdef _SC_ASYNCHRONOUS_IO - {"SC_ASYNCHRONOUS_IO", _SC_ASYNCHRONOUS_IO}, -#endif -#ifdef _SC_ATEXIT_MAX - {"SC_ATEXIT_MAX", _SC_ATEXIT_MAX}, -#endif -#ifdef _SC_AUDIT - {"SC_AUDIT", _SC_AUDIT}, -#endif -#ifdef _SC_AVPHYS_PAGES - {"SC_AVPHYS_PAGES", _SC_AVPHYS_PAGES}, -#endif -#ifdef _SC_BC_BASE_MAX - {"SC_BC_BASE_MAX", _SC_BC_BASE_MAX}, -#endif -#ifdef _SC_BC_DIM_MAX - {"SC_BC_DIM_MAX", _SC_BC_DIM_MAX}, -#endif -#ifdef _SC_BC_SCALE_MAX - {"SC_BC_SCALE_MAX", _SC_BC_SCALE_MAX}, -#endif -#ifdef _SC_BC_STRING_MAX - {"SC_BC_STRING_MAX", _SC_BC_STRING_MAX}, -#endif -#ifdef _SC_CAP - {"SC_CAP", _SC_CAP}, -#endif -#ifdef _SC_CHARCLASS_NAME_MAX - {"SC_CHARCLASS_NAME_MAX", _SC_CHARCLASS_NAME_MAX}, -#endif -#ifdef _SC_CHAR_BIT - {"SC_CHAR_BIT", _SC_CHAR_BIT}, -#endif -#ifdef _SC_CHAR_MAX - {"SC_CHAR_MAX", _SC_CHAR_MAX}, -#endif -#ifdef _SC_CHAR_MIN - {"SC_CHAR_MIN", _SC_CHAR_MIN}, -#endif -#ifdef _SC_CHILD_MAX - {"SC_CHILD_MAX", _SC_CHILD_MAX}, -#endif -#ifdef _SC_CLK_TCK - {"SC_CLK_TCK", _SC_CLK_TCK}, -#endif -#ifdef _SC_COHER_BLKSZ - {"SC_COHER_BLKSZ", _SC_COHER_BLKSZ}, -#endif -#ifdef _SC_COLL_WEIGHTS_MAX - {"SC_COLL_WEIGHTS_MAX", _SC_COLL_WEIGHTS_MAX}, -#endif -#ifdef _SC_DCACHE_ASSOC - {"SC_DCACHE_ASSOC", _SC_DCACHE_ASSOC}, -#endif -#ifdef _SC_DCACHE_BLKSZ - {"SC_DCACHE_BLKSZ", _SC_DCACHE_BLKSZ}, -#endif -#ifdef _SC_DCACHE_LINESZ - {"SC_DCACHE_LINESZ", _SC_DCACHE_LINESZ}, -#endif -#ifdef _SC_DCACHE_SZ - {"SC_DCACHE_SZ", _SC_DCACHE_SZ}, -#endif -#ifdef _SC_DCACHE_TBLKSZ - {"SC_DCACHE_TBLKSZ", _SC_DCACHE_TBLKSZ}, -#endif -#ifdef _SC_DELAYTIMER_MAX - {"SC_DELAYTIMER_MAX", _SC_DELAYTIMER_MAX}, -#endif -#ifdef _SC_EQUIV_CLASS_MAX - {"SC_EQUIV_CLASS_MAX", _SC_EQUIV_CLASS_MAX}, -#endif -#ifdef _SC_EXPR_NEST_MAX - {"SC_EXPR_NEST_MAX", _SC_EXPR_NEST_MAX}, -#endif -#ifdef _SC_FSYNC - {"SC_FSYNC", _SC_FSYNC}, -#endif -#ifdef _SC_GETGR_R_SIZE_MAX - {"SC_GETGR_R_SIZE_MAX", _SC_GETGR_R_SIZE_MAX}, -#endif -#ifdef _SC_GETPW_R_SIZE_MAX - {"SC_GETPW_R_SIZE_MAX", _SC_GETPW_R_SIZE_MAX}, -#endif -#ifdef _SC_ICACHE_ASSOC - {"SC_ICACHE_ASSOC", _SC_ICACHE_ASSOC}, -#endif -#ifdef _SC_ICACHE_BLKSZ - {"SC_ICACHE_BLKSZ", _SC_ICACHE_BLKSZ}, -#endif -#ifdef _SC_ICACHE_LINESZ - {"SC_ICACHE_LINESZ", _SC_ICACHE_LINESZ}, -#endif -#ifdef _SC_ICACHE_SZ - {"SC_ICACHE_SZ", _SC_ICACHE_SZ}, -#endif -#ifdef _SC_INF - {"SC_INF", _SC_INF}, -#endif -#ifdef _SC_INT_MAX - {"SC_INT_MAX", _SC_INT_MAX}, -#endif -#ifdef _SC_INT_MIN - {"SC_INT_MIN", _SC_INT_MIN}, -#endif -#ifdef _SC_IOV_MAX - {"SC_IOV_MAX", _SC_IOV_MAX}, -#endif -#ifdef _SC_IP_SECOPTS - {"SC_IP_SECOPTS", _SC_IP_SECOPTS}, -#endif -#ifdef _SC_JOB_CONTROL - {"SC_JOB_CONTROL", _SC_JOB_CONTROL}, -#endif -#ifdef _SC_KERN_POINTERS - {"SC_KERN_POINTERS", _SC_KERN_POINTERS}, -#endif -#ifdef _SC_KERN_SIM - {"SC_KERN_SIM", _SC_KERN_SIM}, -#endif -#ifdef _SC_LINE_MAX - {"SC_LINE_MAX", _SC_LINE_MAX}, -#endif -#ifdef _SC_LOGIN_NAME_MAX - {"SC_LOGIN_NAME_MAX", _SC_LOGIN_NAME_MAX}, -#endif -#ifdef _SC_LOGNAME_MAX - {"SC_LOGNAME_MAX", _SC_LOGNAME_MAX}, -#endif -#ifdef _SC_LONG_BIT - {"SC_LONG_BIT", _SC_LONG_BIT}, -#endif -#ifdef _SC_MAC - {"SC_MAC", _SC_MAC}, -#endif -#ifdef _SC_MAPPED_FILES - {"SC_MAPPED_FILES", _SC_MAPPED_FILES}, -#endif -#ifdef _SC_MAXPID - {"SC_MAXPID", _SC_MAXPID}, -#endif -#ifdef _SC_MB_LEN_MAX - {"SC_MB_LEN_MAX", _SC_MB_LEN_MAX}, -#endif -#ifdef _SC_MEMLOCK - {"SC_MEMLOCK", _SC_MEMLOCK}, -#endif -#ifdef _SC_MEMLOCK_RANGE - {"SC_MEMLOCK_RANGE", _SC_MEMLOCK_RANGE}, -#endif -#ifdef _SC_MEMORY_PROTECTION - {"SC_MEMORY_PROTECTION", _SC_MEMORY_PROTECTION}, -#endif -#ifdef _SC_MESSAGE_PASSING - {"SC_MESSAGE_PASSING", _SC_MESSAGE_PASSING}, -#endif -#ifdef _SC_MMAP_FIXED_ALIGNMENT - {"SC_MMAP_FIXED_ALIGNMENT", _SC_MMAP_FIXED_ALIGNMENT}, -#endif -#ifdef _SC_MQ_OPEN_MAX - {"SC_MQ_OPEN_MAX", _SC_MQ_OPEN_MAX}, -#endif -#ifdef _SC_MQ_PRIO_MAX - {"SC_MQ_PRIO_MAX", _SC_MQ_PRIO_MAX}, -#endif -#ifdef _SC_NACLS_MAX - {"SC_NACLS_MAX", _SC_NACLS_MAX}, -#endif -#ifdef _SC_NGROUPS_MAX - {"SC_NGROUPS_MAX", _SC_NGROUPS_MAX}, -#endif -#ifdef _SC_NL_ARGMAX - {"SC_NL_ARGMAX", _SC_NL_ARGMAX}, -#endif -#ifdef _SC_NL_LANGMAX - {"SC_NL_LANGMAX", _SC_NL_LANGMAX}, -#endif -#ifdef _SC_NL_MSGMAX - {"SC_NL_MSGMAX", _SC_NL_MSGMAX}, -#endif -#ifdef _SC_NL_NMAX - {"SC_NL_NMAX", _SC_NL_NMAX}, -#endif -#ifdef _SC_NL_SETMAX - {"SC_NL_SETMAX", _SC_NL_SETMAX}, -#endif -#ifdef _SC_NL_TEXTMAX - {"SC_NL_TEXTMAX", _SC_NL_TEXTMAX}, -#endif -#ifdef _SC_NPROCESSORS_CONF - {"SC_NPROCESSORS_CONF", _SC_NPROCESSORS_CONF}, -#endif -#ifdef _SC_NPROCESSORS_ONLN - {"SC_NPROCESSORS_ONLN", _SC_NPROCESSORS_ONLN}, -#endif -#ifdef _SC_NPROC_CONF - {"SC_NPROC_CONF", _SC_NPROC_CONF}, -#endif -#ifdef _SC_NPROC_ONLN - {"SC_NPROC_ONLN", _SC_NPROC_ONLN}, -#endif -#ifdef _SC_NZERO - {"SC_NZERO", _SC_NZERO}, -#endif -#ifdef _SC_OPEN_MAX - {"SC_OPEN_MAX", _SC_OPEN_MAX}, -#endif -#ifdef _SC_PAGESIZE - {"SC_PAGESIZE", _SC_PAGESIZE}, -#endif -#ifdef _SC_PAGE_SIZE - {"SC_PAGE_SIZE", _SC_PAGE_SIZE}, -#endif -#ifdef _SC_PASS_MAX - {"SC_PASS_MAX", _SC_PASS_MAX}, -#endif -#ifdef _SC_PHYS_PAGES - {"SC_PHYS_PAGES", _SC_PHYS_PAGES}, -#endif -#ifdef _SC_PII - {"SC_PII", _SC_PII}, -#endif -#ifdef _SC_PII_INTERNET - {"SC_PII_INTERNET", _SC_PII_INTERNET}, -#endif -#ifdef _SC_PII_INTERNET_DGRAM - {"SC_PII_INTERNET_DGRAM", _SC_PII_INTERNET_DGRAM}, -#endif -#ifdef _SC_PII_INTERNET_STREAM - {"SC_PII_INTERNET_STREAM", _SC_PII_INTERNET_STREAM}, -#endif -#ifdef _SC_PII_OSI - {"SC_PII_OSI", _SC_PII_OSI}, -#endif -#ifdef _SC_PII_OSI_CLTS - {"SC_PII_OSI_CLTS", _SC_PII_OSI_CLTS}, -#endif -#ifdef _SC_PII_OSI_COTS - {"SC_PII_OSI_COTS", _SC_PII_OSI_COTS}, -#endif -#ifdef _SC_PII_OSI_M - {"SC_PII_OSI_M", _SC_PII_OSI_M}, -#endif -#ifdef _SC_PII_SOCKET - {"SC_PII_SOCKET", _SC_PII_SOCKET}, -#endif -#ifdef _SC_PII_XTI - {"SC_PII_XTI", _SC_PII_XTI}, -#endif -#ifdef _SC_POLL - {"SC_POLL", _SC_POLL}, -#endif -#ifdef _SC_PRIORITIZED_IO - {"SC_PRIORITIZED_IO", _SC_PRIORITIZED_IO}, -#endif -#ifdef _SC_PRIORITY_SCHEDULING - {"SC_PRIORITY_SCHEDULING", _SC_PRIORITY_SCHEDULING}, -#endif -#ifdef _SC_REALTIME_SIGNALS - {"SC_REALTIME_SIGNALS", _SC_REALTIME_SIGNALS}, -#endif -#ifdef _SC_RE_DUP_MAX - {"SC_RE_DUP_MAX", _SC_RE_DUP_MAX}, -#endif -#ifdef _SC_RTSIG_MAX - {"SC_RTSIG_MAX", _SC_RTSIG_MAX}, -#endif -#ifdef _SC_SAVED_IDS - {"SC_SAVED_IDS", _SC_SAVED_IDS}, -#endif -#ifdef _SC_SCHAR_MAX - {"SC_SCHAR_MAX", _SC_SCHAR_MAX}, -#endif -#ifdef _SC_SCHAR_MIN - {"SC_SCHAR_MIN", _SC_SCHAR_MIN}, -#endif -#ifdef _SC_SELECT - {"SC_SELECT", _SC_SELECT}, -#endif -#ifdef _SC_SEMAPHORES - {"SC_SEMAPHORES", _SC_SEMAPHORES}, -#endif -#ifdef _SC_SEM_NSEMS_MAX - {"SC_SEM_NSEMS_MAX", _SC_SEM_NSEMS_MAX}, -#endif -#ifdef _SC_SEM_VALUE_MAX - {"SC_SEM_VALUE_MAX", _SC_SEM_VALUE_MAX}, -#endif -#ifdef _SC_SHARED_MEMORY_OBJECTS - {"SC_SHARED_MEMORY_OBJECTS", _SC_SHARED_MEMORY_OBJECTS}, -#endif -#ifdef _SC_SHRT_MAX - {"SC_SHRT_MAX", _SC_SHRT_MAX}, -#endif -#ifdef _SC_SHRT_MIN - {"SC_SHRT_MIN", _SC_SHRT_MIN}, -#endif -#ifdef _SC_SIGQUEUE_MAX - {"SC_SIGQUEUE_MAX", _SC_SIGQUEUE_MAX}, -#endif -#ifdef _SC_SIGRT_MAX - {"SC_SIGRT_MAX", _SC_SIGRT_MAX}, -#endif -#ifdef _SC_SIGRT_MIN - {"SC_SIGRT_MIN", _SC_SIGRT_MIN}, -#endif -#ifdef _SC_SOFTPOWER - {"SC_SOFTPOWER", _SC_SOFTPOWER}, -#endif -#ifdef _SC_SPLIT_CACHE - {"SC_SPLIT_CACHE", _SC_SPLIT_CACHE}, -#endif -#ifdef _SC_SSIZE_MAX - {"SC_SSIZE_MAX", _SC_SSIZE_MAX}, -#endif -#ifdef _SC_STACK_PROT - {"SC_STACK_PROT", _SC_STACK_PROT}, -#endif -#ifdef _SC_STREAM_MAX - {"SC_STREAM_MAX", _SC_STREAM_MAX}, -#endif -#ifdef _SC_SYNCHRONIZED_IO - {"SC_SYNCHRONIZED_IO", _SC_SYNCHRONIZED_IO}, -#endif -#ifdef _SC_THREADS - {"SC_THREADS", _SC_THREADS}, -#endif -#ifdef _SC_THREAD_ATTR_STACKADDR - {"SC_THREAD_ATTR_STACKADDR", _SC_THREAD_ATTR_STACKADDR}, -#endif -#ifdef _SC_THREAD_ATTR_STACKSIZE - {"SC_THREAD_ATTR_STACKSIZE", _SC_THREAD_ATTR_STACKSIZE}, -#endif -#ifdef _SC_THREAD_DESTRUCTOR_ITERATIONS - {"SC_THREAD_DESTRUCTOR_ITERATIONS", _SC_THREAD_DESTRUCTOR_ITERATIONS}, -#endif -#ifdef _SC_THREAD_KEYS_MAX - {"SC_THREAD_KEYS_MAX", _SC_THREAD_KEYS_MAX}, -#endif -#ifdef _SC_THREAD_PRIORITY_SCHEDULING - {"SC_THREAD_PRIORITY_SCHEDULING", _SC_THREAD_PRIORITY_SCHEDULING}, -#endif -#ifdef _SC_THREAD_PRIO_INHERIT - {"SC_THREAD_PRIO_INHERIT", _SC_THREAD_PRIO_INHERIT}, -#endif -#ifdef _SC_THREAD_PRIO_PROTECT - {"SC_THREAD_PRIO_PROTECT", _SC_THREAD_PRIO_PROTECT}, -#endif -#ifdef _SC_THREAD_PROCESS_SHARED - {"SC_THREAD_PROCESS_SHARED", _SC_THREAD_PROCESS_SHARED}, -#endif -#ifdef _SC_THREAD_SAFE_FUNCTIONS - {"SC_THREAD_SAFE_FUNCTIONS", _SC_THREAD_SAFE_FUNCTIONS}, -#endif -#ifdef _SC_THREAD_STACK_MIN - {"SC_THREAD_STACK_MIN", _SC_THREAD_STACK_MIN}, -#endif -#ifdef _SC_THREAD_THREADS_MAX - {"SC_THREAD_THREADS_MAX", _SC_THREAD_THREADS_MAX}, -#endif -#ifdef _SC_TIMERS - {"SC_TIMERS", _SC_TIMERS}, -#endif -#ifdef _SC_TIMER_MAX - {"SC_TIMER_MAX", _SC_TIMER_MAX}, -#endif -#ifdef _SC_TTY_NAME_MAX - {"SC_TTY_NAME_MAX", _SC_TTY_NAME_MAX}, -#endif -#ifdef _SC_TZNAME_MAX - {"SC_TZNAME_MAX", _SC_TZNAME_MAX}, -#endif -#ifdef _SC_T_IOV_MAX - {"SC_T_IOV_MAX", _SC_T_IOV_MAX}, -#endif -#ifdef _SC_UCHAR_MAX - {"SC_UCHAR_MAX", _SC_UCHAR_MAX}, -#endif -#ifdef _SC_UINT_MAX - {"SC_UINT_MAX", _SC_UINT_MAX}, -#endif -#ifdef _SC_UIO_MAXIOV - {"SC_UIO_MAXIOV", _SC_UIO_MAXIOV}, -#endif -#ifdef _SC_ULONG_MAX - {"SC_ULONG_MAX", _SC_ULONG_MAX}, -#endif -#ifdef _SC_USHRT_MAX - {"SC_USHRT_MAX", _SC_USHRT_MAX}, -#endif -#ifdef _SC_VERSION - {"SC_VERSION", _SC_VERSION}, -#endif -#ifdef _SC_WORD_BIT - {"SC_WORD_BIT", _SC_WORD_BIT}, -#endif -#ifdef _SC_XBS5_ILP32_OFF32 - {"SC_XBS5_ILP32_OFF32", _SC_XBS5_ILP32_OFF32}, -#endif -#ifdef _SC_XBS5_ILP32_OFFBIG - {"SC_XBS5_ILP32_OFFBIG", _SC_XBS5_ILP32_OFFBIG}, -#endif -#ifdef _SC_XBS5_LP64_OFF64 - {"SC_XBS5_LP64_OFF64", _SC_XBS5_LP64_OFF64}, -#endif -#ifdef _SC_XBS5_LPBIG_OFFBIG - {"SC_XBS5_LPBIG_OFFBIG", _SC_XBS5_LPBIG_OFFBIG}, -#endif -#ifdef _SC_XOPEN_CRYPT - {"SC_XOPEN_CRYPT", _SC_XOPEN_CRYPT}, -#endif -#ifdef _SC_XOPEN_ENH_I18N - {"SC_XOPEN_ENH_I18N", _SC_XOPEN_ENH_I18N}, -#endif -#ifdef _SC_XOPEN_LEGACY - {"SC_XOPEN_LEGACY", _SC_XOPEN_LEGACY}, -#endif -#ifdef _SC_XOPEN_REALTIME - {"SC_XOPEN_REALTIME", _SC_XOPEN_REALTIME}, -#endif -#ifdef _SC_XOPEN_REALTIME_THREADS - {"SC_XOPEN_REALTIME_THREADS", _SC_XOPEN_REALTIME_THREADS}, -#endif -#ifdef _SC_XOPEN_SHM - {"SC_XOPEN_SHM", _SC_XOPEN_SHM}, -#endif -#ifdef _SC_XOPEN_UNIX - {"SC_XOPEN_UNIX", _SC_XOPEN_UNIX}, -#endif -#ifdef _SC_XOPEN_VERSION - {"SC_XOPEN_VERSION", _SC_XOPEN_VERSION}, -#endif -#ifdef _SC_XOPEN_XCU_VERSION - {"SC_XOPEN_XCU_VERSION", _SC_XOPEN_XCU_VERSION}, -#endif -#ifdef _SC_XOPEN_XPG2 - {"SC_XOPEN_XPG2", _SC_XOPEN_XPG2}, -#endif -#ifdef _SC_XOPEN_XPG3 - {"SC_XOPEN_XPG3", _SC_XOPEN_XPG3}, -#endif -#ifdef _SC_XOPEN_XPG4 - {"SC_XOPEN_XPG4", _SC_XOPEN_XPG4}, -#endif -}; - -static int -conv_sysconf_confname(PyObject *arg, int *valuep) -{ - return conv_confname(arg, valuep, posix_constants_sysconf, - sizeof(posix_constants_sysconf) - / sizeof(struct constdef)); -} - -PyDoc_STRVAR(posix_sysconf__doc__, -"sysconf(name) -> integer\n\n\ -Return an integer-valued system configuration variable."); - -static PyObject * -posix_sysconf(PyObject *self, PyObject *args) -{ - PyObject *result = NULL; - int name; - - if (PyArg_ParseTuple(args, "O&:sysconf", conv_sysconf_confname, &name)) { - int value; - - errno = 0; - value = sysconf(name); - if (value == -1 && errno != 0) - posix_error(); - else - result = PyInt_FromLong(value); - } - return result; -} -#endif - - -/* This code is used to ensure that the tables of configuration value names - * are in sorted order as required by conv_confname(), and also to build the - * the exported dictionaries that are used to publish information about the - * names available on the host platform. - * - * Sorting the table at runtime ensures that the table is properly ordered - * when used, even for platforms we're not able to test on. It also makes - * it easier to add additional entries to the tables. - */ - -static int -cmp_constdefs(const void *v1, const void *v2) -{ - const struct constdef *c1 = - (const struct constdef *) v1; - const struct constdef *c2 = - (const struct constdef *) v2; - - return strcmp(c1->name, c2->name); -} - -static int -setup_confname_table(struct constdef *table, size_t tablesize, - char *tablename, PyObject *module) -{ - PyObject *d = NULL; - size_t i; - - qsort(table, tablesize, sizeof(struct constdef), cmp_constdefs); - d = PyDict_New(); - if (d == NULL) - return -1; - - for (i=0; i < tablesize; ++i) { - PyObject *o = PyInt_FromLong(table[i].value); - if (o == NULL || PyDict_SetItemString(d, table[i].name, o) == -1) { - Py_XDECREF(o); - Py_DECREF(d); - return -1; - } - Py_DECREF(o); - } - return PyModule_AddObject(module, tablename, d); -} - -/* Return -1 on failure, 0 on success. */ -static int -setup_confname_tables(PyObject *module) -{ -#if defined(HAVE_FPATHCONF) || defined(HAVE_PATHCONF) - if (setup_confname_table(posix_constants_pathconf, - sizeof(posix_constants_pathconf) - / sizeof(struct constdef), - "pathconf_names", module)) - return -1; -#endif -#ifdef HAVE_CONFSTR - if (setup_confname_table(posix_constants_confstr, - sizeof(posix_constants_confstr) - / sizeof(struct constdef), - "confstr_names", module)) - return -1; -#endif -#ifdef HAVE_SYSCONF - if (setup_confname_table(posix_constants_sysconf, - sizeof(posix_constants_sysconf) - / sizeof(struct constdef), - "sysconf_names", module)) - return -1; -#endif - return 0; -} - - -PyDoc_STRVAR(posix_abort__doc__, -"abort() -> does not return!\n\n\ -Abort the interpreter immediately. This 'dumps core' or otherwise fails\n\ -in the hardest way possible on the hosting operating system."); - -static PyObject * -posix_abort(PyObject *self, PyObject *noargs) -{ - abort(); - /*NOTREACHED*/ - Py_FatalError("abort() called from Python code didn't abort!"); - return NULL; -} - -#if defined(MS_WINDOWS) && !defined(MS_XBOX) -PyDoc_STRVAR(win32_startfile__doc__, -"startfile(filepath) - Start a file with its associated application.\n\ -\n\ -This acts like double-clicking the file in Explorer, or giving the file\n\ -name as an argument to the DOS \"start\" command: the file is opened\n\ -with whatever application (if any) its extension is associated.\n\ -\n\ -startfile returns as soon as the associated application is launched.\n\ -There is no option to wait for the application to close, and no way\n\ -to retrieve the application's exit status.\n\ -\n\ -The filepath is relative to the current directory. If you want to use\n\ -an absolute path, make sure the first character is not a slash (\"/\");\n\ -the underlying Win32 ShellExecute function doesn't work if it is."); - -static PyObject * -win32_startfile(PyObject *self, PyObject *args) -{ - char *filepath; - HINSTANCE rc; - if (!PyArg_ParseTuple(args, "s:startfile", &filepath)) - return NULL; - Py_BEGIN_ALLOW_THREADS - rc = ShellExecute((HWND)0, NULL, filepath, NULL, NULL, SW_SHOWNORMAL); - Py_END_ALLOW_THREADS - if (rc <= (HINSTANCE)32) - return win32_error("startfile", filepath); - Py_INCREF(Py_None); - return Py_None; -} -#endif - -#ifdef HAVE_GETLOADAVG -PyDoc_STRVAR(posix_getloadavg__doc__, -"getloadavg() -> (float, float, float)\n\n\ -Return the number of processes in the system run queue averaged over\n\ -the last 1, 5, and 15 minutes or raises OSError if the load average\n\ -was unobtainable"); - -static PyObject * -posix_getloadavg(PyObject *self, PyObject *noargs) -{ - double loadavg[3]; - if (getloadavg(loadavg, 3)!=3) { - PyErr_SetString(PyExc_OSError, "Load averages are unobtainable"); - return NULL; - } else - return Py_BuildValue("ddd", loadavg[0], loadavg[1], loadavg[2]); -} -#endif - - -static PyMethodDef posix_methods[] = { - {"access", posix_access, METH_VARARGS, posix_access__doc__}, -#ifdef HAVE_TTYNAME - {"ttyname", posix_ttyname, METH_VARARGS, posix_ttyname__doc__}, -#endif - {"chdir", posix_chdir, METH_VARARGS, posix_chdir__doc__}, - {"chmod", posix_chmod, METH_VARARGS, posix_chmod__doc__}, -#ifdef HAVE_CHOWN - {"chown", posix_chown, METH_VARARGS, posix_chown__doc__}, -#endif /* HAVE_CHOWN */ -#ifdef HAVE_LCHOWN - {"lchown", posix_lchown, METH_VARARGS, posix_lchown__doc__}, -#endif /* HAVE_LCHOWN */ -#ifdef HAVE_CHROOT - {"chroot", posix_chroot, METH_VARARGS, posix_chroot__doc__}, -#endif -#ifdef HAVE_CTERMID - {"ctermid", posix_ctermid, METH_NOARGS, posix_ctermid__doc__}, -#endif -#ifdef HAVE_GETCWD - {"getcwd", posix_getcwd, METH_NOARGS, posix_getcwd__doc__}, -#ifdef Py_USING_UNICODE - {"getcwdu", posix_getcwdu, METH_NOARGS, posix_getcwdu__doc__}, -#endif -#endif -#ifdef HAVE_LINK - {"link", posix_link, METH_VARARGS, posix_link__doc__}, -#endif /* HAVE_LINK */ - {"listdir", posix_listdir, METH_VARARGS, posix_listdir__doc__}, - {"lstat", posix_lstat, METH_VARARGS, posix_lstat__doc__}, - {"mkdir", posix_mkdir, METH_VARARGS, posix_mkdir__doc__}, -#ifdef HAVE_NICE - {"nice", posix_nice, METH_VARARGS, posix_nice__doc__}, -#endif /* HAVE_NICE */ -#ifdef HAVE_READLINK - {"readlink", posix_readlink, METH_VARARGS, posix_readlink__doc__}, -#endif /* HAVE_READLINK */ - {"rename", posix_rename, METH_VARARGS, posix_rename__doc__}, - {"rmdir", posix_rmdir, METH_VARARGS, posix_rmdir__doc__}, - {"stat", posix_stat, METH_VARARGS, posix_stat__doc__}, - {"stat_float_times", stat_float_times, METH_VARARGS, stat_float_times__doc__}, -#ifdef HAVE_SYMLINK - {"symlink", posix_symlink, METH_VARARGS, posix_symlink__doc__}, -#endif /* HAVE_SYMLINK */ -#ifdef HAVE_SYSTEM - {"system", posix_system, METH_VARARGS, posix_system__doc__}, -#endif - {"umask", posix_umask, METH_VARARGS, posix_umask__doc__}, -#ifdef HAVE_UNAME - {"uname", posix_uname, METH_NOARGS, posix_uname__doc__}, -#endif /* HAVE_UNAME */ - {"unlink", posix_unlink, METH_VARARGS, posix_unlink__doc__}, - {"remove", posix_unlink, METH_VARARGS, posix_remove__doc__}, - {"utime", posix_utime, METH_VARARGS, posix_utime__doc__}, -#ifdef HAVE_TIMES - {"times", posix_times, METH_NOARGS, posix_times__doc__}, -#endif /* HAVE_TIMES */ - {"_exit", posix__exit, METH_VARARGS, posix__exit__doc__}, -#ifdef HAVE_EXECV - {"execv", posix_execv, METH_VARARGS, posix_execv__doc__}, - {"execve", posix_execve, METH_VARARGS, posix_execve__doc__}, -#endif /* HAVE_EXECV */ -#ifdef HAVE_SPAWNV - {"spawnv", posix_spawnv, METH_VARARGS, posix_spawnv__doc__}, - {"spawnve", posix_spawnve, METH_VARARGS, posix_spawnve__doc__}, -#endif /* HAVE_SPAWNV */ -#ifdef HAVE_FORK1 - {"fork1", posix_fork1, METH_NOARGS, posix_fork1__doc__}, -#endif /* HAVE_FORK1 */ -#ifdef HAVE_FORK - {"fork", posix_fork, METH_NOARGS, posix_fork__doc__}, -#endif /* HAVE_FORK */ -#if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX) - {"openpty", posix_openpty, METH_NOARGS, posix_openpty__doc__}, -#endif /* HAVE_OPENPTY || HAVE__GETPTY || HAVE_DEV_PTMX */ -#ifdef HAVE_FORKPTY - {"forkpty", posix_forkpty, METH_NOARGS, posix_forkpty__doc__}, -#endif /* HAVE_FORKPTY */ -#ifdef HAVE_GETEGID - {"getegid", posix_getegid, METH_NOARGS, posix_getegid__doc__}, -#endif /* HAVE_GETEGID */ -#ifdef HAVE_GETEUID - {"geteuid", posix_geteuid, METH_NOARGS, posix_geteuid__doc__}, -#endif /* HAVE_GETEUID */ -#ifdef HAVE_GETGID - {"getgid", posix_getgid, METH_NOARGS, posix_getgid__doc__}, -#endif /* HAVE_GETGID */ -#ifdef HAVE_GETGROUPS - {"getgroups", posix_getgroups, METH_NOARGS, posix_getgroups__doc__}, -#endif - {"getpid", posix_getpid, METH_NOARGS, posix_getpid__doc__}, -#ifdef HAVE_GETPGRP - {"getpgrp", posix_getpgrp, METH_NOARGS, posix_getpgrp__doc__}, -#endif /* HAVE_GETPGRP */ -#ifdef HAVE_GETPPID - {"getppid", posix_getppid, METH_NOARGS, posix_getppid__doc__}, -#endif /* HAVE_GETPPID */ -#ifdef HAVE_GETUID - {"getuid", posix_getuid, METH_NOARGS, posix_getuid__doc__}, -#endif /* HAVE_GETUID */ -#ifdef HAVE_GETLOGIN - {"getlogin", posix_getlogin, METH_NOARGS, posix_getlogin__doc__}, -#endif -#ifdef HAVE_KILL - {"kill", posix_kill, METH_VARARGS, posix_kill__doc__}, -#endif /* HAVE_KILL */ -#ifdef HAVE_KILLPG - {"killpg", posix_killpg, METH_VARARGS, posix_killpg__doc__}, -#endif /* HAVE_KILLPG */ -#ifdef HAVE_PLOCK - {"plock", posix_plock, METH_VARARGS, posix_plock__doc__}, -#endif /* HAVE_PLOCK */ -#ifdef HAVE_POPEN - {"popen", posix_popen, METH_VARARGS, posix_popen__doc__}, -#ifdef MS_WINDOWS - {"popen2", win32_popen2, METH_VARARGS}, - {"popen3", win32_popen3, METH_VARARGS}, - {"popen4", win32_popen4, METH_VARARGS}, -#ifndef MS_XBOX - {"startfile", win32_startfile, METH_VARARGS, win32_startfile__doc__}, -#endif -#else -#if defined(PYOS_OS2) && defined(PYCC_GCC) - {"popen2", os2emx_popen2, METH_VARARGS}, - {"popen3", os2emx_popen3, METH_VARARGS}, - {"popen4", os2emx_popen4, METH_VARARGS}, -#endif -#endif -#endif /* HAVE_POPEN */ -#ifdef HAVE_SETUID - {"setuid", posix_setuid, METH_VARARGS, posix_setuid__doc__}, -#endif /* HAVE_SETUID */ -#ifdef HAVE_SETEUID - {"seteuid", posix_seteuid, METH_VARARGS, posix_seteuid__doc__}, -#endif /* HAVE_SETEUID */ -#ifdef HAVE_SETEGID - {"setegid", posix_setegid, METH_VARARGS, posix_setegid__doc__}, -#endif /* HAVE_SETEGID */ -#ifdef HAVE_SETREUID - {"setreuid", posix_setreuid, METH_VARARGS, posix_setreuid__doc__}, -#endif /* HAVE_SETREUID */ -#ifdef HAVE_SETREGID - {"setregid", posix_setregid, METH_VARARGS, posix_setregid__doc__}, -#endif /* HAVE_SETREGID */ -#ifdef HAVE_SETGID - {"setgid", posix_setgid, METH_VARARGS, posix_setgid__doc__}, -#endif /* HAVE_SETGID */ -#ifdef HAVE_SETGROUPS - {"setgroups", posix_setgroups, METH_VARARGS, posix_setgroups__doc__}, -#endif /* HAVE_SETGROUPS */ -#ifdef HAVE_GETPGID - {"getpgid", posix_getpgid, METH_VARARGS, posix_getpgid__doc__}, -#endif /* HAVE_GETPGID */ -#ifdef HAVE_SETPGRP - {"setpgrp", posix_setpgrp, METH_NOARGS, posix_setpgrp__doc__}, -#endif /* HAVE_SETPGRP */ -#ifdef HAVE_WAIT - {"wait", posix_wait, METH_NOARGS, posix_wait__doc__}, -#endif /* HAVE_WAIT */ -#if defined(HAVE_WAITPID) || defined(HAVE_CWAIT) - {"waitpid", posix_waitpid, METH_VARARGS, posix_waitpid__doc__}, -#endif /* HAVE_WAITPID */ -#ifdef HAVE_SETSID - {"setsid", posix_setsid, METH_NOARGS, posix_setsid__doc__}, -#endif /* HAVE_SETSID */ -#ifdef HAVE_SETPGID - {"setpgid", posix_setpgid, METH_VARARGS, posix_setpgid__doc__}, -#endif /* HAVE_SETPGID */ -#ifdef HAVE_TCGETPGRP - {"tcgetpgrp", posix_tcgetpgrp, METH_VARARGS, posix_tcgetpgrp__doc__}, -#endif /* HAVE_TCGETPGRP */ -#ifdef HAVE_TCSETPGRP - {"tcsetpgrp", posix_tcsetpgrp, METH_VARARGS, posix_tcsetpgrp__doc__}, -#endif /* HAVE_TCSETPGRP */ - {"open", posix_open, METH_VARARGS, posix_open__doc__}, - {"close", posix_close, METH_VARARGS, posix_close__doc__}, - {"dup", posix_dup, METH_VARARGS, posix_dup__doc__}, - {"dup2", posix_dup2, METH_VARARGS, posix_dup2__doc__}, - {"lseek", posix_lseek, METH_VARARGS, posix_lseek__doc__}, - {"read", posix_read, METH_VARARGS, posix_read__doc__}, - {"write", posix_write, METH_VARARGS, posix_write__doc__}, - {"fstat", posix_fstat, METH_VARARGS, posix_fstat__doc__}, - {"fdopen", posix_fdopen, METH_VARARGS, posix_fdopen__doc__}, - {"isatty", posix_isatty, METH_VARARGS, posix_isatty__doc__}, -#ifdef HAVE_PIPE - {"pipe", posix_pipe, METH_NOARGS, posix_pipe__doc__}, -#endif -#ifdef HAVE_MKFIFO - {"mkfifo", posix_mkfifo, METH_VARARGS, posix_mkfifo__doc__}, -#endif -#if defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV) - {"mknod", posix_mknod, METH_VARARGS, posix_mknod__doc__}, -#endif -#ifdef HAVE_DEVICE_MACROS - {"major", posix_major, METH_VARARGS, posix_major__doc__}, - {"minor", posix_minor, METH_VARARGS, posix_minor__doc__}, - {"makedev", posix_makedev, METH_VARARGS, posix_makedev__doc__}, -#endif -#ifdef HAVE_FTRUNCATE - {"ftruncate", posix_ftruncate, METH_VARARGS, posix_ftruncate__doc__}, -#endif -#ifdef HAVE_PUTENV - {"putenv", posix_putenv, METH_VARARGS, posix_putenv__doc__}, -#endif -#ifdef HAVE_UNSETENV - {"unsetenv", posix_unsetenv, METH_VARARGS, posix_unsetenv__doc__}, -#endif -#ifdef HAVE_STRERROR - {"strerror", posix_strerror, METH_VARARGS, posix_strerror__doc__}, -#endif -#ifdef HAVE_FCHDIR - {"fchdir", posix_fchdir, METH_O, posix_fchdir__doc__}, -#endif -#ifdef HAVE_FSYNC - {"fsync", posix_fsync, METH_O, posix_fsync__doc__}, -#endif -#ifdef HAVE_FDATASYNC - {"fdatasync", posix_fdatasync, METH_O, posix_fdatasync__doc__}, -#endif -#ifdef HAVE_SYS_WAIT_H -#ifdef WCOREDUMP - {"WCOREDUMP", posix_WCOREDUMP, METH_VARARGS, posix_WCOREDUMP__doc__}, -#endif /* WCOREDUMP */ -#ifdef WIFCONTINUED - {"WIFCONTINUED",posix_WIFCONTINUED, METH_VARARGS, posix_WIFCONTINUED__doc__}, -#endif /* WIFCONTINUED */ -#ifdef WIFSTOPPED - {"WIFSTOPPED", posix_WIFSTOPPED, METH_VARARGS, posix_WIFSTOPPED__doc__}, -#endif /* WIFSTOPPED */ -#ifdef WIFSIGNALED - {"WIFSIGNALED", posix_WIFSIGNALED, METH_VARARGS, posix_WIFSIGNALED__doc__}, -#endif /* WIFSIGNALED */ -#ifdef WIFEXITED - {"WIFEXITED", posix_WIFEXITED, METH_VARARGS, posix_WIFEXITED__doc__}, -#endif /* WIFEXITED */ -#ifdef WEXITSTATUS - {"WEXITSTATUS", posix_WEXITSTATUS, METH_VARARGS, posix_WEXITSTATUS__doc__}, -#endif /* WEXITSTATUS */ -#ifdef WTERMSIG - {"WTERMSIG", posix_WTERMSIG, METH_VARARGS, posix_WTERMSIG__doc__}, -#endif /* WTERMSIG */ -#ifdef WSTOPSIG - {"WSTOPSIG", posix_WSTOPSIG, METH_VARARGS, posix_WSTOPSIG__doc__}, -#endif /* WSTOPSIG */ -#endif /* HAVE_SYS_WAIT_H */ -#ifdef HAVE_FSTATVFS - {"fstatvfs", posix_fstatvfs, METH_VARARGS, posix_fstatvfs__doc__}, -#endif -#ifdef HAVE_STATVFS - {"statvfs", posix_statvfs, METH_VARARGS, posix_statvfs__doc__}, -#endif -#ifdef HAVE_TMPFILE - {"tmpfile", posix_tmpfile, METH_NOARGS, posix_tmpfile__doc__}, -#endif -#ifdef HAVE_TEMPNAM - {"tempnam", posix_tempnam, METH_VARARGS, posix_tempnam__doc__}, -#endif -#ifdef HAVE_TMPNAM - {"tmpnam", posix_tmpnam, METH_NOARGS, posix_tmpnam__doc__}, -#endif -#ifdef HAVE_CONFSTR - {"confstr", posix_confstr, METH_VARARGS, posix_confstr__doc__}, -#endif -#ifdef HAVE_SYSCONF - {"sysconf", posix_sysconf, METH_VARARGS, posix_sysconf__doc__}, -#endif -#ifdef HAVE_FPATHCONF - {"fpathconf", posix_fpathconf, METH_VARARGS, posix_fpathconf__doc__}, -#endif -#ifdef HAVE_PATHCONF - {"pathconf", posix_pathconf, METH_VARARGS, posix_pathconf__doc__}, -#endif - {"abort", posix_abort, METH_NOARGS, posix_abort__doc__}, -#if defined(MS_WINDOWS) && !defined(MS_XBOX) - {"_getfullpathname", posix__getfullpathname, METH_VARARGS, NULL}, -#endif -#ifdef HAVE_GETLOADAVG - {"getloadavg", posix_getloadavg, METH_NOARGS, posix_getloadavg__doc__}, -#endif - {NULL, NULL} /* Sentinel */ -}; - - -static int -ins(PyObject *module, char *symbol, long value) -{ - return PyModule_AddIntConstant(module, symbol, value); -} - -#if defined(PYOS_OS2) -/* Insert Platform-Specific Constant Values (Strings & Numbers) of Common Use */ -static int insertvalues(PyObject *module) -{ - APIRET rc; - ULONG values[QSV_MAX+1]; - PyObject *v; - char *ver, tmp[50]; - - Py_BEGIN_ALLOW_THREADS - rc = DosQuerySysInfo(1L, QSV_MAX, &values[1], sizeof(ULONG) * QSV_MAX); - Py_END_ALLOW_THREADS - - if (rc != NO_ERROR) { - os2_error(rc); - return -1; - } - - if (ins(module, "meminstalled", values[QSV_TOTPHYSMEM])) return -1; - if (ins(module, "memkernel", values[QSV_TOTRESMEM])) return -1; - if (ins(module, "memvirtual", values[QSV_TOTAVAILMEM])) return -1; - if (ins(module, "maxpathlen", values[QSV_MAX_PATH_LENGTH])) return -1; - if (ins(module, "maxnamelen", values[QSV_MAX_COMP_LENGTH])) return -1; - if (ins(module, "revision", values[QSV_VERSION_REVISION])) return -1; - if (ins(module, "timeslice", values[QSV_MIN_SLICE])) return -1; - - switch (values[QSV_VERSION_MINOR]) { - case 0: ver = "2.00"; break; - case 10: ver = "2.10"; break; - case 11: ver = "2.11"; break; - case 30: ver = "3.00"; break; - case 40: ver = "4.00"; break; - case 50: ver = "5.00"; break; - default: - PyOS_snprintf(tmp, sizeof(tmp), - "%d-%d", values[QSV_VERSION_MAJOR], - values[QSV_VERSION_MINOR]); - ver = &tmp[0]; - } - - /* Add Indicator of the Version of the Operating System */ - if (PyModule_AddStringConstant(module, "version", tmp) < 0) - return -1; - - /* Add Indicator of Which Drive was Used to Boot the System */ - tmp[0] = 'A' + values[QSV_BOOT_DRIVE] - 1; - tmp[1] = ':'; - tmp[2] = '\0'; - - return PyModule_AddStringConstant(module, "bootdrive", tmp); -} -#endif - -static int -all_ins(PyObject *d) -{ -#ifdef F_OK - if (ins(d, "F_OK", (long)F_OK)) return -1; -#endif -#ifdef R_OK - if (ins(d, "R_OK", (long)R_OK)) return -1; -#endif -#ifdef W_OK - if (ins(d, "W_OK", (long)W_OK)) return -1; -#endif -#ifdef X_OK - if (ins(d, "X_OK", (long)X_OK)) return -1; -#endif -#ifdef NGROUPS_MAX - if (ins(d, "NGROUPS_MAX", (long)NGROUPS_MAX)) return -1; -#endif -#ifdef TMP_MAX - if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1; -#endif -#ifdef WCONTINUED - if (ins(d, "WCONTINUED", (long)WCONTINUED)) return -1; -#endif -#ifdef WNOHANG - if (ins(d, "WNOHANG", (long)WNOHANG)) return -1; -#endif -#ifdef WUNTRACED - if (ins(d, "WUNTRACED", (long)WUNTRACED)) return -1; -#endif -#ifdef O_RDONLY - if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1; -#endif -#ifdef O_WRONLY - if (ins(d, "O_WRONLY", (long)O_WRONLY)) return -1; -#endif -#ifdef O_RDWR - if (ins(d, "O_RDWR", (long)O_RDWR)) return -1; -#endif -#ifdef O_NDELAY - if (ins(d, "O_NDELAY", (long)O_NDELAY)) return -1; -#endif -#ifdef O_NONBLOCK - if (ins(d, "O_NONBLOCK", (long)O_NONBLOCK)) return -1; -#endif -#ifdef O_APPEND - if (ins(d, "O_APPEND", (long)O_APPEND)) return -1; -#endif -#ifdef O_DSYNC - if (ins(d, "O_DSYNC", (long)O_DSYNC)) return -1; -#endif -#ifdef O_RSYNC - if (ins(d, "O_RSYNC", (long)O_RSYNC)) return -1; -#endif -#ifdef O_SYNC - if (ins(d, "O_SYNC", (long)O_SYNC)) return -1; -#endif -#ifdef O_NOCTTY - if (ins(d, "O_NOCTTY", (long)O_NOCTTY)) return -1; -#endif -#ifdef O_CREAT - if (ins(d, "O_CREAT", (long)O_CREAT)) return -1; -#endif -#ifdef O_EXCL - if (ins(d, "O_EXCL", (long)O_EXCL)) return -1; -#endif -#ifdef O_TRUNC - if (ins(d, "O_TRUNC", (long)O_TRUNC)) return -1; -#endif -#ifdef O_BINARY - if (ins(d, "O_BINARY", (long)O_BINARY)) return -1; -#endif -#ifdef O_TEXT - if (ins(d, "O_TEXT", (long)O_TEXT)) return -1; -#endif -#ifdef O_LARGEFILE - if (ins(d, "O_LARGEFILE", (long)O_LARGEFILE)) return -1; -#endif - -/* MS Windows */ -#ifdef O_NOINHERIT - /* Don't inherit in child processes. */ - if (ins(d, "O_NOINHERIT", (long)O_NOINHERIT)) return -1; -#endif -#ifdef _O_SHORT_LIVED - /* Optimize for short life (keep in memory). */ - /* MS forgot to define this one with a non-underscore form too. */ - if (ins(d, "O_SHORT_LIVED", (long)_O_SHORT_LIVED)) return -1; -#endif -#ifdef O_TEMPORARY - /* Automatically delete when last handle is closed. */ - if (ins(d, "O_TEMPORARY", (long)O_TEMPORARY)) return -1; -#endif -#ifdef O_RANDOM - /* Optimize for random access. */ - if (ins(d, "O_RANDOM", (long)O_RANDOM)) return -1; -#endif -#ifdef O_SEQUENTIAL - /* Optimize for sequential access. */ - if (ins(d, "O_SEQUENTIAL", (long)O_SEQUENTIAL)) return -1; -#endif - -/* GNU extensions. */ -#ifdef O_DIRECT - /* Direct disk access. */ - if (ins(d, "O_DIRECT", (long)O_DIRECT)) return -1; -#endif -#ifdef O_DIRECTORY - /* Must be a directory. */ - if (ins(d, "O_DIRECTORY", (long)O_DIRECTORY)) return -1; -#endif -#ifdef O_NOFOLLOW - /* Do not follow links. */ - if (ins(d, "O_NOFOLLOW", (long)O_NOFOLLOW)) return -1; -#endif - - /* These come from sysexits.h */ -#ifdef EX_OK - if (ins(d, "EX_OK", (long)EX_OK)) return -1; -#endif /* EX_OK */ -#ifdef EX_USAGE - if (ins(d, "EX_USAGE", (long)EX_USAGE)) return -1; -#endif /* EX_USAGE */ -#ifdef EX_DATAERR - if (ins(d, "EX_DATAERR", (long)EX_DATAERR)) return -1; -#endif /* EX_DATAERR */ -#ifdef EX_NOINPUT - if (ins(d, "EX_NOINPUT", (long)EX_NOINPUT)) return -1; -#endif /* EX_NOINPUT */ -#ifdef EX_NOUSER - if (ins(d, "EX_NOUSER", (long)EX_NOUSER)) return -1; -#endif /* EX_NOUSER */ -#ifdef EX_NOHOST - if (ins(d, "EX_NOHOST", (long)EX_NOHOST)) return -1; -#endif /* EX_NOHOST */ -#ifdef EX_UNAVAILABLE - if (ins(d, "EX_UNAVAILABLE", (long)EX_UNAVAILABLE)) return -1; -#endif /* EX_UNAVAILABLE */ -#ifdef EX_SOFTWARE - if (ins(d, "EX_SOFTWARE", (long)EX_SOFTWARE)) return -1; -#endif /* EX_SOFTWARE */ -#ifdef EX_OSERR - if (ins(d, "EX_OSERR", (long)EX_OSERR)) return -1; -#endif /* EX_OSERR */ -#ifdef EX_OSFILE - if (ins(d, "EX_OSFILE", (long)EX_OSFILE)) return -1; -#endif /* EX_OSFILE */ -#ifdef EX_CANTCREAT - if (ins(d, "EX_CANTCREAT", (long)EX_CANTCREAT)) return -1; -#endif /* EX_CANTCREAT */ -#ifdef EX_IOERR - if (ins(d, "EX_IOERR", (long)EX_IOERR)) return -1; -#endif /* EX_IOERR */ -#ifdef EX_TEMPFAIL - if (ins(d, "EX_TEMPFAIL", (long)EX_TEMPFAIL)) return -1; -#endif /* EX_TEMPFAIL */ -#ifdef EX_PROTOCOL - if (ins(d, "EX_PROTOCOL", (long)EX_PROTOCOL)) return -1; -#endif /* EX_PROTOCOL */ -#ifdef EX_NOPERM - if (ins(d, "EX_NOPERM", (long)EX_NOPERM)) return -1; -#endif /* EX_NOPERM */ -#ifdef EX_CONFIG - if (ins(d, "EX_CONFIG", (long)EX_CONFIG)) return -1; -#endif /* EX_CONFIG */ -#ifdef EX_NOTFOUND - if (ins(d, "EX_NOTFOUND", (long)EX_NOTFOUND)) return -1; -#endif /* EX_NOTFOUND */ - -#ifdef HAVE_SPAWNV -#if defined(PYOS_OS2) && defined(PYCC_GCC) - if (ins(d, "P_WAIT", (long)P_WAIT)) return -1; - if (ins(d, "P_NOWAIT", (long)P_NOWAIT)) return -1; - if (ins(d, "P_OVERLAY", (long)P_OVERLAY)) return -1; - if (ins(d, "P_DEBUG", (long)P_DEBUG)) return -1; - if (ins(d, "P_SESSION", (long)P_SESSION)) return -1; - if (ins(d, "P_DETACH", (long)P_DETACH)) return -1; - if (ins(d, "P_PM", (long)P_PM)) return -1; - if (ins(d, "P_DEFAULT", (long)P_DEFAULT)) return -1; - if (ins(d, "P_MINIMIZE", (long)P_MINIMIZE)) return -1; - if (ins(d, "P_MAXIMIZE", (long)P_MAXIMIZE)) return -1; - if (ins(d, "P_FULLSCREEN", (long)P_FULLSCREEN)) return -1; - if (ins(d, "P_WINDOWED", (long)P_WINDOWED)) return -1; - if (ins(d, "P_FOREGROUND", (long)P_FOREGROUND)) return -1; - if (ins(d, "P_BACKGROUND", (long)P_BACKGROUND)) return -1; - if (ins(d, "P_NOCLOSE", (long)P_NOCLOSE)) return -1; - if (ins(d, "P_NOSESSION", (long)P_NOSESSION)) return -1; - if (ins(d, "P_QUOTE", (long)P_QUOTE)) return -1; - if (ins(d, "P_TILDE", (long)P_TILDE)) return -1; - if (ins(d, "P_UNRELATED", (long)P_UNRELATED)) return -1; - if (ins(d, "P_DEBUGDESC", (long)P_DEBUGDESC)) return -1; -#else - if (ins(d, "P_WAIT", (long)_P_WAIT)) return -1; - if (ins(d, "P_NOWAIT", (long)_P_NOWAIT)) return -1; - if (ins(d, "P_OVERLAY", (long)_OLD_P_OVERLAY)) return -1; - if (ins(d, "P_NOWAITO", (long)_P_NOWAITO)) return -1; - if (ins(d, "P_DETACH", (long)_P_DETACH)) return -1; -#endif -#endif - -#if defined(PYOS_OS2) - if (insertvalues(d)) return -1; -#endif - return 0; -} - - -#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__) -#define INITFUNC initnt -#define MODNAME "nt" - -#elif defined(PYOS_OS2) -#define INITFUNC initos2 -#define MODNAME "os2" - -#else -#define INITFUNC initposix -#define MODNAME "posix" -#endif - -PyMODINIT_FUNC -INITFUNC(void) -{ - PyObject *m, *v; - - m = Py_InitModule3(MODNAME, - posix_methods, - posix__doc__); - - /* Initialize environ dictionary */ - v = convertenviron(); - Py_XINCREF(v); - if (v == NULL || PyModule_AddObject(m, "environ", v) != 0) - return; - Py_DECREF(v); - - if (all_ins(m)) - return; - - if (setup_confname_tables(m)) - return; - - Py_INCREF(PyExc_OSError); - PyModule_AddObject(m, "error", PyExc_OSError); - -#ifdef HAVE_PUTENV - if (posix_putenv_garbage == NULL) - posix_putenv_garbage = PyDict_New(); -#endif - - stat_result_desc.name = MODNAME ".stat_result"; - stat_result_desc.fields[7].name = PyStructSequence_UnnamedField; - stat_result_desc.fields[8].name = PyStructSequence_UnnamedField; - stat_result_desc.fields[9].name = PyStructSequence_UnnamedField; - PyStructSequence_InitType(&StatResultType, &stat_result_desc); - structseq_new = StatResultType.tp_new; - StatResultType.tp_new = statresult_new; - Py_INCREF((PyObject*) &StatResultType); - PyModule_AddObject(m, "stat_result", (PyObject*) &StatResultType); - - statvfs_result_desc.name = MODNAME ".statvfs_result"; - PyStructSequence_InitType(&StatVFSResultType, &statvfs_result_desc); - Py_INCREF((PyObject*) &StatVFSResultType); - PyModule_AddObject(m, "statvfs_result", - (PyObject*) &StatVFSResultType); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/puremodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/puremodule.c deleted file mode 100644 index e0d14655..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/puremodule.c +++ /dev/null @@ -1,986 +0,0 @@ -/* This module exports the C API to such Pure Software Inc. (tm) (now - * called Pure Atria Corporation) products as Purify (tm) and Quantify - * (tm). Other packages could be added, but I didn't have those products - * and thus lack the API documentation. - * - * Currently supported: Quantify 2.x, Purify 3.x - * - * You need to decide which products you want to incorporate into the - * module when you compile this file. The way to do this is to edit - * /Modules/Setup to pass the appropriate flags to the compiler. - * -DWITH_PURIFY compiles in the Purify support, and -DWITH_QUANTIFY - * compiles in the Quantify support. -DWITH_ALL_PURE compiles in both. - * You can also build a Purify'd or Quantify'd interpreter by passing in - * the LINKCC variable to make. E.g. if you want to build a Purify'd - * interpreter and are using gcc, build Python with this command: - * - * make LINKCC='purify gcc' - * - * It would be nice (and probably easy) to provide this file as a shared - * library, however since it doesn't appear that Pure gives us shared - * libraries of the stubs, it doesn't really matter. For now, you have to - * link this file in statically. - * - * Major bogosity. The purify.h header file exports purify_exit(), but - * guess what? It is not defined in the libpurify_stubs.a file! I tried - * to fake one here, hoping the Pure linker would Do The Right Thing when - * instrumented for Purify, but it doesn't seem to, so I don't export - * purify_exit() to the Python layer. In Python you should raise a - * SystemExit exception anyway. - * - * The actual purify.h and quantify.h files which embody the APIs are - * copyrighted by Pure Software, Inc. and are only attainable through them. - * This module assumes you have legally installed licenses of their - * software. Contact them on the Web via - * - * Author: Barry Warsaw - * - */ - -#include "Python.h" - -#if defined(WITH_PURIFY) || defined(WITH_ALL_PURE) -# include -# define HAS_PURIFY_EXIT 0 /* See note at top of file */ -# define PURE_PURIFY_VERSION 3 /* not provided by purify.h */ -#endif -#if defined(WITH_QUANTIFY) || defined(WITH_ALL_PURE) -# include -# define PURE_QUANTIFY_VERSION 2 /* not provided by quantify.h */ -#endif -#if defined(PURIFY_H) || defined(QUANTIFY_H) -# define COMMON_PURE_FUNCTIONS -#endif /* PURIFY_H || QUANTIFY_H */ - -typedef int (*VoidArgFunc)(void); -typedef int (*StringArgFunc)(char*); -typedef int (*PrintfishFunc)(const char*, ...); -typedef int (*StringIntArgFunc)(const char*, int); - - - -static PyObject* -call_voidarg_function(VoidArgFunc func, PyObject *self, PyObject *args) -{ - int status; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - - status = func(); - return Py_BuildValue("i", status); -} - -static PyObject* -call_stringarg_function(StringArgFunc func, PyObject *self, PyObject *args) -{ - int status; - char* stringarg; - - if (!PyArg_ParseTuple(args, "s", &stringarg)) - return NULL; - - status = func(stringarg); - return Py_BuildValue("i", status); -} - -static PyObject* -call_stringorint_function(StringArgFunc func, PyObject *self, PyObject *args) -{ - int status; - int intarg; - char* stringarg; - - /* according to the quantify.h file, the argument to - * quantify_*_recording_system_call can be an integer or a string, - * but the functions are prototyped as taking a single char* - * argument. Yikes! - */ - if (PyArg_ParseTuple(args, "i", &intarg)) - /* func is prototyped as int(*)(char*) - * better shut up the compiler - */ - status = func((char*)intarg); - - else { - PyErr_Clear(); - if (!PyArg_ParseTuple(args, "s", &stringarg)) - return NULL; - else - status = func(stringarg); - } - return Py_BuildValue("i", status); -} - -static PyObject* -call_printfish_function(PrintfishFunc func, PyObject *self, PyObject *args) -{ - /* we support the printf() style vararg functions by requiring the - * formatting be done in Python. At the C level we pass just a string - * to the printf() style function. - */ - int status; - char* argstring; - - if (!PyArg_ParseTuple(args, "s", &argstring)) - return NULL; - - status = func("%s", argstring); - return Py_BuildValue("i", status); -} - -static PyObject* -call_intasaddr_function(StringArgFunc func, PyObject *self, PyObject *args) -{ - long memrep; - int id; - - if (!PyArg_ParseTuple(args, "l", &memrep)) - return NULL; - - id = func((char*)memrep); - return Py_BuildValue("i", id); -} - -static PyObject* -call_stringandint_function(StringIntArgFunc func, PyObject *self, - PyObject *args) -{ - long srcrep; - int size; - int status; - - if (!PyArg_ParseTuple(args, "li", &srcrep, &size)) - return NULL; - - status = func((char*)srcrep, size); - return Py_BuildValue("i", status); -} - - - -/* functions common to all products - * - * N.B. These printf() style functions are a bit of a kludge. Since the - * API doesn't provide vprintf versions of them, we can't call them - * directly. They don't support all the standard printf % modifiers - * anyway. The way to use these is to use Python's % string operator to do - * the formatting. By the time these functions get the thing to print, - * it's already a string, and they just use "%s" as the format string. - */ - -#ifdef COMMON_PURE_FUNCTIONS - -static PyObject* -pure_pure_logfile_printf(PyObject* self, PyObject* args) -{ - return call_printfish_function(pure_logfile_printf, self, args); -} - -static PyObject* -pure_pure_printf(PyObject* self, PyObject* args) -{ - return call_printfish_function(pure_printf, self, args); -} - -static PyObject* -pure_pure_printf_with_banner(PyObject* self, PyObject* args) -{ - return call_printfish_function(pure_printf_with_banner, self, args); -} - - -#endif /* COMMON_PURE_FUNCTIONS */ - - - -/* Purify functions - * - * N.B. There are some interfaces described in the purify.h file that are - * not described in the manual. - * - * Unsigned longs purify_report_{address,number,type,result} are not - * accessible from the Python layer since they seem mostly useful when - * purify_stop_here() is called by the (C) debugger. The same is true of - * the purify_stop_here_internal() function so it isn't exported either. - * And purify_stop_here() should never be called directly. - * - * The header file says purify_{new,all,clear_new}_reports() are obsolete - * so they aren't exported. - * - * None of the custom dynamic loader functions are exported. - * - * purify_unsafe_memcpy() isn't exported. - * - * purify_{start,size}_of_block() aren't exported. - * - * The manual that I have says that the prototype for the second argument - * to purify_map_pool is: - * - * void (*fn)(char*) - * - * but the purify.h file declares it as: - * - * void (*fn)(char*, int, void*) - * - * and does not explain what the other arguments are for. I support the - * latter but I don't know if I do it right or usefully. - * - * The header file says that purify_describe() returns a char* which is the - * pointer passed to it. The manual says it returns an int, but I believe - * that is a typo. - */ -#ifdef PURIFY_H - -static PyObject* -pure_purify_all_inuse(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_all_inuse, self, args); -} -static PyObject* -pure_purify_all_leaks(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_all_leaks, self, args); -} -static PyObject* -pure_purify_new_inuse(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_new_inuse, self, args); -} -static PyObject* -pure_purify_new_leaks(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_new_leaks, self, args); -} -static PyObject* -pure_purify_clear_inuse(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_clear_inuse, self, args); -} -static PyObject* -pure_purify_clear_leaks(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_clear_leaks, self, args); -} -static PyObject* -pure_purify_all_fds_inuse(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_all_fds_inuse, self, args); -} -static PyObject* -pure_purify_new_fds_inuse(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_new_fds_inuse, self, args); -} -static PyObject* -pure_purify_printf_with_call_chain(PyObject *self, PyObject *args) -{ - return call_printfish_function(purify_printf_with_call_chain, - self, args); -} -static PyObject* -pure_purify_set_pool_id(PyObject *self, PyObject *args) -{ - long memrep; - int id; - - if (!PyArg_ParseTuple(args, "li:purify_set_pool_id", &memrep, &id)) - return NULL; - - purify_set_pool_id((char*)memrep, id); - Py_INCREF(Py_None); - return Py_None; -} -static PyObject* -pure_purify_get_pool_id(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_get_pool_id, self, args); -} -static PyObject* -pure_purify_set_user_data(PyObject *self, PyObject *args) -{ - long memrep; - long datarep; - - if (!PyArg_ParseTuple(args, "ll:purify_set_user_data", &memrep, &datarep)) - return NULL; - - purify_set_user_data((char*)memrep, (void*)datarep); - Py_INCREF(Py_None); - return Py_None; -} -static PyObject* -pure_purify_get_user_data(PyObject *self, PyObject *args) -{ - /* can't use call_intasaddr_function() since purify_get_user_data() - * returns a void* - */ - long memrep; - void* data; - - if (!PyArg_ParseTuple(args, "l:purify_get_user_data", &memrep)) - return NULL; - - data = purify_get_user_data((char*)memrep); - return Py_BuildValue("l", (long)data); -} - - -/* this global variable is shared by both mapping functions: - * pure_purify_map_pool() and pure_purify_map_pool_id(). Since they cache - * this variable it should be safe in the face of recursion or cross - * calling. - * - * Further note that the prototype for the callback function is wrong in - * the Purify manual. The manual says the function takes a single char*, - * but the header file says it takes an additional int and void*. I have - * no idea what these are for! - */ -static PyObject* MapCallable = NULL; - -static void -map_pool_callback(char* mem, int user_size, void *user_aux_data) -{ - long memrep = (long)mem; - long user_aux_data_rep = (long)user_aux_data; - PyObject* result; - PyObject* memobj = Py_BuildValue("lil", memrep, user_size, - user_aux_data_rep); - - if (memobj == NULL) - return; - - result = PyEval_CallObject(MapCallable, memobj); - Py_DECREF(result); - Py_DECREF(memobj); -} - -static PyObject* -pure_purify_map_pool(PyObject *self, PyObject *args) -{ - /* cache global variable in case of recursion */ - PyObject* saved_callable = MapCallable; - PyObject* arg_callable; - int id; - - if (!PyArg_ParseTuple(args, "iO:purify_map_pool", &id, &arg_callable)) - return NULL; - - if (!PyCallable_Check(arg_callable)) { - PyErr_SetString(PyExc_TypeError, - "Second argument must be callable"); - return NULL; - } - MapCallable = arg_callable; - purify_map_pool(id, map_pool_callback); - MapCallable = saved_callable; - - Py_INCREF(Py_None); - return Py_None; -} - -static void -PurifyMapPoolIdCallback(int id) -{ - PyObject* result; - PyObject* intobj = Py_BuildValue("i", id); - - if (intobj == NULL) - return; - - result = PyEval_CallObject(MapCallable, intobj); - Py_DECREF(result); - Py_DECREF(intobj); -} - -static PyObject* -pure_purify_map_pool_id(PyObject *self, PyObject *args) -{ - /* cache global variable in case of recursion */ - PyObject* saved_callable = MapCallable; - PyObject* arg_callable; - - if (!PyArg_ParseTuple(args, "O:purify_map_pool_id", &arg_callable)) - return NULL; - - if (!PyCallable_Check(arg_callable)) { - PyErr_SetString(PyExc_TypeError, "Argument must be callable."); - return NULL; - } - - MapCallable = arg_callable; - purify_map_pool_id(PurifyMapPoolIdCallback); - MapCallable = saved_callable; - - Py_INCREF(Py_None); - return Py_None; -} - - - -static PyObject* -pure_purify_new_messages(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_new_messages, self, args); -} -static PyObject* -pure_purify_all_messages(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_all_messages, self, args); -} -static PyObject* -pure_purify_clear_messages(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_clear_messages, self, args); -} -static PyObject* -pure_purify_clear_new_messages(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_clear_new_messages, self, args); -} -static PyObject* -pure_purify_start_batch(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_start_batch, self, args); -} -static PyObject* -pure_purify_start_batch_show_first(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_start_batch_show_first, - self, args); -} -static PyObject* -pure_purify_stop_batch(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_stop_batch, self, args); -} -static PyObject* -pure_purify_name_thread(PyObject *self, PyObject *args) -{ - /* can't strictly use call_stringarg_function since - * purify_name_thread takes a const char*, not a char* - */ - int status; - char* stringarg; - - if (!PyArg_ParseTuple(args, "s:purify_name_thread", &stringarg)) - return NULL; - - status = purify_name_thread(stringarg); - return Py_BuildValue("i", status); -} -static PyObject* -pure_purify_watch(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch, self, args); -} -static PyObject* -pure_purify_watch_1(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_1, self, args); -} -static PyObject* -pure_purify_watch_2(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_2, self, args); -} -static PyObject* -pure_purify_watch_4(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_4, self, args); -} -static PyObject* -pure_purify_watch_8(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_8, self, args); -} -static PyObject* -pure_purify_watch_w_1(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_w_1, self, args); -} -static PyObject* -pure_purify_watch_w_2(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_w_2, self, args); -} -static PyObject* -pure_purify_watch_w_4(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_w_4, self, args); -} -static PyObject* -pure_purify_watch_w_8(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_w_8, self, args); -} -static PyObject* -pure_purify_watch_r_1(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_r_1, self, args); -} -static PyObject* -pure_purify_watch_r_2(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_r_2, self, args); -} -static PyObject* -pure_purify_watch_r_4(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_r_4, self, args); -} -static PyObject* -pure_purify_watch_r_8(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_r_8, self, args); -} -static PyObject* -pure_purify_watch_rw_1(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_rw_1, self, args); -} -static PyObject* -pure_purify_watch_rw_2(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_rw_2, self, args); -} -static PyObject* -pure_purify_watch_rw_4(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_rw_4, self, args); -} -static PyObject* -pure_purify_watch_rw_8(PyObject *self, PyObject *args) -{ - return call_intasaddr_function(purify_watch_rw_8, self, args); -} - -static PyObject* -pure_purify_watch_n(PyObject *self, PyObject *args) -{ - long addrrep; - unsigned int size; - char* type; - int status; - - if (!PyArg_ParseTuple(args, "lis:purify_watch_n", &addrrep, &size, &type)) - return NULL; - - status = purify_watch_n((char*)addrrep, size, type); - return Py_BuildValue("i", status); -} - -static PyObject* -pure_purify_watch_info(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_watch_info, self, args); -} - -static PyObject* -pure_purify_watch_remove(PyObject *self, PyObject *args) -{ - int watchno; - int status; - - if (!PyArg_ParseTuple(args, "i:purify_watch_remove", &watchno)) - return NULL; - - status = purify_watch_remove(watchno); - return Py_BuildValue("i", status); -} - -static PyObject* -pure_purify_watch_remove_all(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_watch_remove_all, self, args); -} -static PyObject* -pure_purify_describe(PyObject *self, PyObject *args) -{ - long addrrep; - char* rtn; - - if (!PyArg_ParseTuple(args, "l:purify_describe", &addrrep)) - return NULL; - - rtn = purify_describe((char*)addrrep); - return Py_BuildValue("l", (long)rtn); -} - -static PyObject* -pure_purify_what_colors(PyObject *self, PyObject *args) -{ - long addrrep; - unsigned int size; - int status; - - if (!PyArg_ParseTuple(args, "li:purify_what_colors", &addrrep, &size)) - return NULL; - - status = purify_what_colors((char*)addrrep, size); - return Py_BuildValue("i", status); -} - -static PyObject* -pure_purify_is_running(PyObject *self, PyObject *args) -{ - return call_voidarg_function(purify_is_running, self, args); -} - -static PyObject* -pure_purify_assert_is_readable(PyObject *self, PyObject *args) -{ - return call_stringandint_function(purify_assert_is_readable, - self, args); -} -static PyObject* -pure_purify_assert_is_writable(PyObject *self, PyObject *args) -{ - return call_stringandint_function(purify_assert_is_writable, - self, args); -} - -#if HAS_PURIFY_EXIT - -/* I wish I could include this, but I can't. See the notes at the top of - * the file. - */ - -static PyObject* -pure_purify_exit(PyObject *self, PyObject *args) -{ - int status; - - if (!PyArg_ParseTuple(args, "i:purify_exit", &status)) - return NULL; - - /* purify_exit doesn't always act like exit(). See the manual */ - purify_exit(status); - Py_INCREF(Py_None); - return Py_None; -} -#endif /* HAS_PURIFY_EXIT */ - -#endif /* PURIFY_H */ - - - -/* Quantify functions - * - * N.B. Some of these functions are only described in the quantify.h file, - * not in the version of the hardcopy manual that I had. If you're not - * sure what some of these do, check the header file, it is documented - * fairly well. - * - * None of the custom dynamic loader functions are exported. - * - */ -#ifdef QUANTIFY_H - -static PyObject* -pure_quantify_is_running(PyObject *self, PyObject *args) -{ - return call_voidarg_function(quantify_is_running, self, args); -} -static PyObject* -pure_quantify_help(PyObject *self, PyObject *args) -{ - return call_voidarg_function(quantify_help, self, args); -} -static PyObject* -pure_quantify_print_recording_state(PyObject *self, PyObject *args) -{ - return call_voidarg_function(quantify_print_recording_state, - self, args); -} -static PyObject* -pure_quantify_start_recording_data(PyObject *self, PyObject *args) -{ - return call_voidarg_function(quantify_start_recording_data, - self, args); -} -static PyObject* -pure_quantify_stop_recording_data(PyObject *self, PyObject *args) -{ - return call_voidarg_function(quantify_stop_recording_data, self, args); -} -static PyObject* -pure_quantify_is_recording_data(PyObject *self, PyObject *args) -{ - return call_voidarg_function(quantify_is_recording_data, self, args); -} -static PyObject* -pure_quantify_start_recording_system_calls(PyObject *self, PyObject *args) -{ - return call_voidarg_function(quantify_start_recording_system_calls, - self, args); -} -static PyObject* -pure_quantify_stop_recording_system_calls(PyObject *self, PyObject *args) -{ - return call_voidarg_function(quantify_stop_recording_system_calls, - self, args); -} -static PyObject* -pure_quantify_is_recording_system_calls(PyObject *self, PyObject *args) -{ - return call_voidarg_function(quantify_is_recording_system_calls, - self, args); -} -static PyObject* -pure_quantify_start_recording_system_call(PyObject *self, PyObject *args) -{ - return call_stringorint_function(quantify_start_recording_system_call, - self, args); -} -static PyObject* -pure_quantify_stop_recording_system_call(PyObject *self, PyObject *args) -{ - return call_stringorint_function(quantify_stop_recording_system_call, - self, args); -} -static PyObject* -pure_quantify_is_recording_system_call(PyObject *self, PyObject *args) -{ - return call_stringorint_function(quantify_is_recording_system_call, - self, args); -} -static PyObject* -pure_quantify_start_recording_dynamic_library_data(PyObject *self, PyObject *args) -{ - return call_voidarg_function( - quantify_start_recording_dynamic_library_data, - self, args); -} -static PyObject* -pure_quantify_stop_recording_dynamic_library_data(PyObject *self, PyObject *args) -{ - return call_voidarg_function( - quantify_stop_recording_dynamic_library_data, - self, args); -} -static PyObject* -pure_quantify_is_recording_dynamic_library_data(PyObject *self, PyObject *args) -{ - return call_voidarg_function( - quantify_is_recording_dynamic_library_data, - self, args); -} -static PyObject* -pure_quantify_start_recording_register_window_traps(PyObject *self, PyObject *args) -{ - return call_voidarg_function( - quantify_start_recording_register_window_traps, - self, args); -} -static PyObject* -pure_quantify_stop_recording_register_window_traps(PyObject *self, PyObject *args) -{ - return call_voidarg_function( - quantify_stop_recording_register_window_traps, - self, args); -} -static PyObject* -pure_quantify_is_recording_register_window_traps(PyObject *self, PyObject *args) -{ - return call_voidarg_function( - quantify_is_recording_register_window_traps, - self, args); -} -static PyObject* -pure_quantify_disable_recording_data(PyObject *self, PyObject *args) -{ - return call_voidarg_function(quantify_disable_recording_data, - self, args); -} -static PyObject* -pure_quantify_clear_data(PyObject *self, PyObject *args) -{ - return call_voidarg_function(quantify_clear_data, self, args); -} -static PyObject* -pure_quantify_save_data(PyObject *self, PyObject *args) -{ - return call_voidarg_function(quantify_save_data, self, args); -} -static PyObject* -pure_quantify_save_data_to_file(PyObject *self, PyObject *args) -{ - return call_stringarg_function(quantify_save_data_to_file, self, args); -} -static PyObject* -pure_quantify_add_annotation(PyObject *self, PyObject *args) -{ - return call_stringarg_function(quantify_add_annotation, self, args); -} - -#endif /* QUANTIFY_H */ - - - -/* external interface - */ -static struct PyMethodDef -pure_methods[] = { -#ifdef COMMON_PURE_FUNCTIONS - {"pure_logfile_printf", pure_pure_logfile_printf, METH_VARARGS}, - {"pure_printf", pure_pure_printf, METH_VARARGS}, - {"pure_printf_with_banner", pure_pure_printf_with_banner, METH_VARARGS}, -#endif /* COMMON_PURE_FUNCTIONS */ -#ifdef PURIFY_H - {"purify_all_inuse", pure_purify_all_inuse, METH_VARARGS}, - {"purify_all_leaks", pure_purify_all_leaks, METH_VARARGS}, - {"purify_new_inuse", pure_purify_new_inuse, METH_VARARGS}, - {"purify_new_leaks", pure_purify_new_leaks, METH_VARARGS}, - {"purify_clear_inuse", pure_purify_clear_inuse, METH_VARARGS}, - {"purify_clear_leaks", pure_purify_clear_leaks, METH_VARARGS}, - {"purify_all_fds_inuse", pure_purify_all_fds_inuse, METH_VARARGS}, - {"purify_new_fds_inuse", pure_purify_new_fds_inuse, METH_VARARGS}, - /* see purify.h */ - {"purify_logfile_printf", pure_pure_logfile_printf, METH_VARARGS}, - {"purify_printf", pure_pure_printf, METH_VARARGS}, - {"purify_printf_with_banner", pure_pure_printf_with_banner, METH_VARARGS}, - /**/ - {"purify_printf_with_call_chain", pure_purify_printf_with_call_chain, METH_VARARGS}, - {"purify_set_pool_id", pure_purify_set_pool_id, METH_VARARGS}, - {"purify_get_pool_id", pure_purify_get_pool_id, METH_VARARGS}, - {"purify_set_user_data", pure_purify_set_user_data, METH_VARARGS}, - {"purify_get_user_data", pure_purify_get_user_data, METH_VARARGS}, - {"purify_map_pool", pure_purify_map_pool, METH_VARARGS}, - {"purify_map_pool_id", pure_purify_map_pool_id, METH_VARARGS}, - {"purify_new_messages", pure_purify_new_messages, METH_VARARGS}, - {"purify_all_messages", pure_purify_all_messages, METH_VARARGS}, - {"purify_clear_messages", pure_purify_clear_messages, METH_VARARGS}, - {"purify_clear_new_messages", pure_purify_clear_new_messages, METH_VARARGS}, - {"purify_start_batch", pure_purify_start_batch, METH_VARARGS}, - {"purify_start_batch_show_first", pure_purify_start_batch_show_first, METH_VARARGS}, - {"purify_stop_batch", pure_purify_stop_batch, METH_VARARGS}, - {"purify_name_thread", pure_purify_name_thread, METH_VARARGS}, - {"purify_watch", pure_purify_watch, METH_VARARGS}, - {"purify_watch_1", pure_purify_watch_1, METH_VARARGS}, - {"purify_watch_2", pure_purify_watch_2, METH_VARARGS}, - {"purify_watch_4", pure_purify_watch_4, METH_VARARGS}, - {"purify_watch_8", pure_purify_watch_8, METH_VARARGS}, - {"purify_watch_w_1", pure_purify_watch_w_1, METH_VARARGS}, - {"purify_watch_w_2", pure_purify_watch_w_2, METH_VARARGS}, - {"purify_watch_w_4", pure_purify_watch_w_4, METH_VARARGS}, - {"purify_watch_w_8", pure_purify_watch_w_8, METH_VARARGS}, - {"purify_watch_r_1", pure_purify_watch_r_1, METH_VARARGS}, - {"purify_watch_r_2", pure_purify_watch_r_2, METH_VARARGS}, - {"purify_watch_r_4", pure_purify_watch_r_4, METH_VARARGS}, - {"purify_watch_r_8", pure_purify_watch_r_8, METH_VARARGS}, - {"purify_watch_rw_1", pure_purify_watch_rw_1, METH_VARARGS}, - {"purify_watch_rw_2", pure_purify_watch_rw_2, METH_VARARGS}, - {"purify_watch_rw_4", pure_purify_watch_rw_4, METH_VARARGS}, - {"purify_watch_rw_8", pure_purify_watch_rw_8, METH_VARARGS}, - {"purify_watch_n", pure_purify_watch_n, METH_VARARGS}, - {"purify_watch_info", pure_purify_watch_info, METH_VARARGS}, - {"purify_watch_remove", pure_purify_watch_remove, METH_VARARGS}, - {"purify_watch_remove_all", pure_purify_watch_remove_all, METH_VARARGS}, - {"purify_describe", pure_purify_describe, METH_VARARGS}, - {"purify_what_colors", pure_purify_what_colors, METH_VARARGS}, - {"purify_is_running", pure_purify_is_running, METH_VARARGS}, - {"purify_assert_is_readable", pure_purify_assert_is_readable, METH_VARARGS}, - {"purify_assert_is_writable", pure_purify_assert_is_writable, METH_VARARGS}, -#if HAS_PURIFY_EXIT - /* I wish I could include this, but I can't. See the notes at the - * top of the file. - */ - {"purify_exit", pure_purify_exit, METH_VARARGS}, -#endif /* HAS_PURIFY_EXIT */ -#endif /* PURIFY_H */ -#ifdef QUANTIFY_H - {"quantify_is_running", pure_quantify_is_running, METH_VARARGS}, - {"quantify_help", pure_quantify_help, METH_VARARGS}, - {"quantify_print_recording_state", pure_quantify_print_recording_state, METH_VARARGS}, - {"quantify_start_recording_data", pure_quantify_start_recording_data, METH_VARARGS}, - {"quantify_stop_recording_data", pure_quantify_stop_recording_data, METH_VARARGS}, - {"quantify_is_recording_data", pure_quantify_is_recording_data, METH_VARARGS}, - {"quantify_start_recording_system_calls", - pure_quantify_start_recording_system_calls, METH_VARARGS}, - {"quantify_stop_recording_system_calls", - pure_quantify_stop_recording_system_calls, METH_VARARGS}, - {"quantify_is_recording_system_calls", - pure_quantify_is_recording_system_calls, METH_VARARGS}, - {"quantify_start_recording_system_call", - pure_quantify_start_recording_system_call, METH_VARARGS}, - {"quantify_stop_recording_system_call", - pure_quantify_stop_recording_system_call, METH_VARARGS}, - {"quantify_is_recording_system_call", - pure_quantify_is_recording_system_call, METH_VARARGS}, - {"quantify_start_recording_dynamic_library_data", - pure_quantify_start_recording_dynamic_library_data, METH_VARARGS}, - {"quantify_stop_recording_dynamic_library_data", - pure_quantify_stop_recording_dynamic_library_data, METH_VARARGS}, - {"quantify_is_recording_dynamic_library_data", - pure_quantify_is_recording_dynamic_library_data, METH_VARARGS}, - {"quantify_start_recording_register_window_traps", - pure_quantify_start_recording_register_window_traps, METH_VARARGS}, - {"quantify_stop_recording_register_window_traps", - pure_quantify_stop_recording_register_window_traps, METH_VARARGS}, - {"quantify_is_recording_register_window_traps", - pure_quantify_is_recording_register_window_traps, METH_VARARGS}, - {"quantify_disable_recording_data", - pure_quantify_disable_recording_data, METH_VARARGS}, - {"quantify_clear_data", pure_quantify_clear_data, METH_VARARGS}, - {"quantify_save_data", pure_quantify_save_data, METH_VARARGS}, - {"quantify_save_data_to_file", pure_quantify_save_data_to_file, METH_VARARGS}, - {"quantify_add_annotation", pure_quantify_add_annotation, METH_VARARGS}, -#endif /* QUANTIFY_H */ - {NULL, NULL} /* sentinel */ -}; - - - -static void -ins(d, name, val) - PyObject *d; - char* name; - long val; -{ - PyObject *v = PyInt_FromLong(val); - if (v) { - (void)PyDict_SetItemString(d, name, v); - Py_DECREF(v); - } -} - - -void -initpure() -{ - PyObject *m, *d; - - m = Py_InitModule("pure", pure_methods); - d = PyModule_GetDict(m); - - /* this is bogus because we should be able to find this information - * out from the header files. Pure's current versions don't - * include this information! - */ -#ifdef PURE_PURIFY_VERSION - ins(d, "PURIFY_VERSION", PURE_PURIFY_VERSION); -#else - PyDict_SetItemString(d, "PURIFY_VERSION", Py_None); -#endif - - /* these aren't terribly useful because purify_exit() isn't - * exported correctly. See the note at the top of the file. - */ -#ifdef PURIFY_EXIT_ERRORS - ins(d, "PURIFY_EXIT_ERRORS", PURIFY_EXIT_ERRORS); -#endif -#ifdef PURIFY_EXIT_LEAKS - ins(d, "PURIFY_EXIT_LEAKS", PURIFY_EXIT_LEAKS); -#endif -#ifdef PURIFY_EXIT_PLEAKS - ins(d, "PURIFY_EXIT_PLEAKS", PURIFY_EXIT_PLEAKS); -#endif - - -#ifdef PURE_QUANTIFY_VERSION - ins(d, "QUANTIFY_VERSION", PURE_QUANTIFY_VERSION); -#else - PyDict_SetItemString(d, "QUANTIFY_VERSION", Py_None); -#endif -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/pwdmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/pwdmodule.c deleted file mode 100644 index 2a306252..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/pwdmodule.c +++ /dev/null @@ -1,188 +0,0 @@ - -/* UNIX password file access module */ - -#include "Python.h" -#include "structseq.h" - -#include -#include - -static PyStructSequence_Field struct_pwd_type_fields[] = { - {"pw_name", "user name"}, - {"pw_passwd", "password"}, - {"pw_uid", "user id"}, - {"pw_gid", "group id"}, - {"pw_gecos", "real name"}, - {"pw_dir", "home directory"}, - {"pw_shell", "shell program"}, - {0} -}; - -PyDoc_STRVAR(struct_passwd__doc__, -"pwd.struct_passwd: Results from getpw*() routines.\n\n\ -This object may be accessed either as a tuple of\n\ - (pw_name,pw_passwd,pw_uid,pw_gid,pw_gecos,pw_dir,pw_shell)\n\ -or via the object attributes as named in the above tuple."); - -static PyStructSequence_Desc struct_pwd_type_desc = { - "pwd.struct_passwd", - struct_passwd__doc__, - struct_pwd_type_fields, - 7, -}; - -PyDoc_STRVAR(pwd__doc__, -"This module provides access to the Unix password database.\n\ -It is available on all Unix versions.\n\ -\n\ -Password database entries are reported as 7-tuples containing the following\n\ -items from the password database (see `'), in order:\n\ -pw_name, pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir, pw_shell.\n\ -The uid and gid items are integers, all others are strings. An\n\ -exception is raised if the entry asked for cannot be found."); - - -static PyTypeObject StructPwdType; - -static void -sets(PyObject *v, int i, char* val) -{ - if (val) - PyStructSequence_SET_ITEM(v, i, PyString_FromString(val)); - else { - PyStructSequence_SET_ITEM(v, i, Py_None); - Py_INCREF(Py_None); - } -} - -static PyObject * -mkpwent(struct passwd *p) -{ - int setIndex = 0; - PyObject *v = PyStructSequence_New(&StructPwdType); - if (v == NULL) - return NULL; - -#define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val)) -#define SETS(i,val) sets(v, i, val) - - SETS(setIndex++, p->pw_name); -#ifdef __VMS - SETS(setIndex++, ""); -#else - SETS(setIndex++, p->pw_passwd); -#endif - SETI(setIndex++, p->pw_uid); - SETI(setIndex++, p->pw_gid); -#ifdef __VMS - SETS(setIndex++, ""); -#else - SETS(setIndex++, p->pw_gecos); -#endif - SETS(setIndex++, p->pw_dir); - SETS(setIndex++, p->pw_shell); - -#undef SETS -#undef SETI - - if (PyErr_Occurred()) { - Py_XDECREF(v); - return NULL; - } - - return v; -} - -PyDoc_STRVAR(pwd_getpwuid__doc__, -"getpwuid(uid) -> (pw_name,pw_passwd,pw_uid,\n\ - pw_gid,pw_gecos,pw_dir,pw_shell)\n\ -Return the password database entry for the given numeric user ID.\n\ -See pwd.__doc__ for more on password database entries."); - -static PyObject * -pwd_getpwuid(PyObject *self, PyObject *args) -{ - int uid; - struct passwd *p; - if (!PyArg_ParseTuple(args, "i:getpwuid", &uid)) - return NULL; - if ((p = getpwuid(uid)) == NULL) { - PyErr_SetString(PyExc_KeyError, "getpwuid(): uid not found"); - return NULL; - } - return mkpwent(p); -} - -PyDoc_STRVAR(pwd_getpwnam__doc__, -"getpwnam(name) -> (pw_name,pw_passwd,pw_uid,\n\ - pw_gid,pw_gecos,pw_dir,pw_shell)\n\ -Return the password database entry for the given user name.\n\ -See pwd.__doc__ for more on password database entries."); - -static PyObject * -pwd_getpwnam(PyObject *self, PyObject *args) -{ - char *name; - struct passwd *p; - if (!PyArg_ParseTuple(args, "s:getpwnam", &name)) - return NULL; - if ((p = getpwnam(name)) == NULL) { - PyErr_SetString(PyExc_KeyError, "getpwnam(): name not found"); - return NULL; - } - return mkpwent(p); -} - -#ifdef HAVE_GETPWENT -PyDoc_STRVAR(pwd_getpwall__doc__, -"getpwall() -> list_of_entries\n\ -Return a list of all available password database entries, \ -in arbitrary order.\n\ -See pwd.__doc__ for more on password database entries."); - -static PyObject * -pwd_getpwall(PyObject *self) -{ - PyObject *d; - struct passwd *p; - if ((d = PyList_New(0)) == NULL) - return NULL; -#if defined(PYOS_OS2) && defined(PYCC_GCC) - if ((p = getpwuid(0)) != NULL) { -#else - setpwent(); - while ((p = getpwent()) != NULL) { -#endif - PyObject *v = mkpwent(p); - if (v == NULL || PyList_Append(d, v) != 0) { - Py_XDECREF(v); - Py_DECREF(d); - return NULL; - } - Py_DECREF(v); - } - endpwent(); - return d; -} -#endif - -static PyMethodDef pwd_methods[] = { - {"getpwuid", pwd_getpwuid, METH_VARARGS, pwd_getpwuid__doc__}, - {"getpwnam", pwd_getpwnam, METH_VARARGS, pwd_getpwnam__doc__}, -#ifdef HAVE_GETPWENT - {"getpwall", (PyCFunction)pwd_getpwall, - METH_NOARGS, pwd_getpwall__doc__}, -#endif - {NULL, NULL} /* sentinel */ -}; - -PyMODINIT_FUNC -initpwd(void) -{ - PyObject *m; - m = Py_InitModule3("pwd", pwd_methods, pwd__doc__); - - PyStructSequence_InitType(&StructPwdType, &struct_pwd_type_desc); - Py_INCREF((PyObject *) &StructPwdType); - PyModule_AddObject(m, "struct_pwent", (PyObject *) &StructPwdType); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/pyexpat.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/pyexpat.c deleted file mode 100644 index 73b9f2d4..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/pyexpat.c +++ /dev/null @@ -1,2057 +0,0 @@ -#include "Python.h" -#include - -#include "compile.h" -#include "frameobject.h" -#include "expat.h" - -#define XML_COMBINED_VERSION (10000*XML_MAJOR_VERSION+100*XML_MINOR_VERSION+XML_MICRO_VERSION) - -#ifndef PyDoc_STRVAR - -/* - * fdrake says: - * Don't change the PyDoc_STR macro definition to (str), because - * '''the parentheses cause compile failures - * ("non-constant static initializer" or something like that) - * on some platforms (Irix?)''' - */ -#define PyDoc_STR(str) str -#define PyDoc_VAR(name) static char name[] -#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) -#endif - -#if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 2) -/* In Python 2.0 and 2.1, disabling Unicode was not possible. */ -#define Py_USING_UNICODE -#else -#define FIX_TRACE -#endif - -enum HandlerTypes { - StartElement, - EndElement, - ProcessingInstruction, - CharacterData, - UnparsedEntityDecl, - NotationDecl, - StartNamespaceDecl, - EndNamespaceDecl, - Comment, - StartCdataSection, - EndCdataSection, - Default, - DefaultHandlerExpand, - NotStandalone, - ExternalEntityRef, - StartDoctypeDecl, - EndDoctypeDecl, - EntityDecl, - XmlDecl, - ElementDecl, - AttlistDecl, -#if XML_COMBINED_VERSION >= 19504 - SkippedEntity, -#endif - _DummyDecl -}; - -static PyObject *ErrorObject; - -/* ----------------------------------------------------- */ - -/* Declarations for objects of type xmlparser */ - -typedef struct { - PyObject_HEAD - - XML_Parser itself; - int returns_unicode; /* True if Unicode strings are returned; - if false, UTF-8 strings are returned */ - int ordered_attributes; /* Return attributes as a list. */ - int specified_attributes; /* Report only specified attributes. */ - int in_callback; /* Is a callback active? */ - int ns_prefixes; /* Namespace-triplets mode? */ - XML_Char *buffer; /* Buffer used when accumulating characters */ - /* NULL if not enabled */ - int buffer_size; /* Size of buffer, in XML_Char units */ - int buffer_used; /* Buffer units in use */ - PyObject *intern; /* Dictionary to intern strings */ - PyObject **handlers; -} xmlparseobject; - -#define CHARACTER_DATA_BUFFER_SIZE 8192 - -static PyTypeObject Xmlparsetype; - -typedef void (*xmlhandlersetter)(XML_Parser self, void *meth); -typedef void* xmlhandler; - -struct HandlerInfo { - const char *name; - xmlhandlersetter setter; - xmlhandler handler; - PyCodeObject *tb_code; - PyObject *nameobj; -}; - -static struct HandlerInfo handler_info[64]; - -/* Set an integer attribute on the error object; return true on success, - * false on an exception. - */ -static int -set_error_attr(PyObject *err, char *name, int value) -{ - PyObject *v = PyInt_FromLong(value); - - if (v != NULL && PyObject_SetAttrString(err, name, v) == -1) { - Py_DECREF(v); - return 0; - } - return 1; -} - -/* Build and set an Expat exception, including positioning - * information. Always returns NULL. - */ -static PyObject * -set_error(xmlparseobject *self, enum XML_Error code) -{ - PyObject *err; - char buffer[256]; - XML_Parser parser = self->itself; - int lineno = XML_GetErrorLineNumber(parser); - int column = XML_GetErrorColumnNumber(parser); - - /* There is no risk of overflowing this buffer, since - even for 64-bit integers, there is sufficient space. */ - sprintf(buffer, "%.200s: line %i, column %i", - XML_ErrorString(code), lineno, column); - err = PyObject_CallFunction(ErrorObject, "s", buffer); - if ( err != NULL - && set_error_attr(err, "code", code) - && set_error_attr(err, "offset", column) - && set_error_attr(err, "lineno", lineno)) { - PyErr_SetObject(ErrorObject, err); - } - return NULL; -} - -static int -have_handler(xmlparseobject *self, int type) -{ - PyObject *handler = self->handlers[type]; - return handler != NULL; -} - -static PyObject * -get_handler_name(struct HandlerInfo *hinfo) -{ - PyObject *name = hinfo->nameobj; - if (name == NULL) { - name = PyString_FromString(hinfo->name); - hinfo->nameobj = name; - } - Py_XINCREF(name); - return name; -} - - -#ifdef Py_USING_UNICODE -/* Convert a string of XML_Chars into a Unicode string. - Returns None if str is a null pointer. */ - -static PyObject * -conv_string_to_unicode(const XML_Char *str) -{ - /* XXX currently this code assumes that XML_Char is 8-bit, - and hence in UTF-8. */ - /* UTF-8 from Expat, Unicode desired */ - if (str == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyUnicode_DecodeUTF8(str, strlen(str), "strict"); -} - -static PyObject * -conv_string_len_to_unicode(const XML_Char *str, int len) -{ - /* XXX currently this code assumes that XML_Char is 8-bit, - and hence in UTF-8. */ - /* UTF-8 from Expat, Unicode desired */ - if (str == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyUnicode_DecodeUTF8((const char *)str, len, "strict"); -} -#endif - -/* Convert a string of XML_Chars into an 8-bit Python string. - Returns None if str is a null pointer. */ - -static PyObject * -conv_string_to_utf8(const XML_Char *str) -{ - /* XXX currently this code assumes that XML_Char is 8-bit, - and hence in UTF-8. */ - /* UTF-8 from Expat, UTF-8 desired */ - if (str == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyString_FromString(str); -} - -static PyObject * -conv_string_len_to_utf8(const XML_Char *str, int len) -{ - /* XXX currently this code assumes that XML_Char is 8-bit, - and hence in UTF-8. */ - /* UTF-8 from Expat, UTF-8 desired */ - if (str == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyString_FromStringAndSize((const char *)str, len); -} - -/* Callback routines */ - -static void clear_handlers(xmlparseobject *self, int initial); - -/* This handler is used when an error has been detected, in the hope - that actual parsing can be terminated early. This will only help - if an external entity reference is encountered. */ -static int -error_external_entity_ref_handler(XML_Parser parser, - const XML_Char *context, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId) -{ - return 0; -} - -static void -flag_error(xmlparseobject *self) -{ - clear_handlers(self, 0); - XML_SetExternalEntityRefHandler(self->itself, - error_external_entity_ref_handler); -} - -static PyCodeObject* -getcode(enum HandlerTypes slot, char* func_name, int lineno) -{ - PyObject *code = NULL; - PyObject *name = NULL; - PyObject *nulltuple = NULL; - PyObject *filename = NULL; - - if (handler_info[slot].tb_code == NULL) { - code = PyString_FromString(""); - if (code == NULL) - goto failed; - name = PyString_FromString(func_name); - if (name == NULL) - goto failed; - nulltuple = PyTuple_New(0); - if (nulltuple == NULL) - goto failed; - filename = PyString_FromString(__FILE__); - handler_info[slot].tb_code = - PyCode_New(0, /* argcount */ - 0, /* nlocals */ - 0, /* stacksize */ - 0, /* flags */ - code, /* code */ - nulltuple, /* consts */ - nulltuple, /* names */ - nulltuple, /* varnames */ -#if PYTHON_API_VERSION >= 1010 - nulltuple, /* freevars */ - nulltuple, /* cellvars */ -#endif - filename, /* filename */ - name, /* name */ - lineno, /* firstlineno */ - code /* lnotab */ - ); - if (handler_info[slot].tb_code == NULL) - goto failed; - Py_DECREF(code); - Py_DECREF(nulltuple); - Py_DECREF(filename); - Py_DECREF(name); - } - return handler_info[slot].tb_code; - failed: - Py_XDECREF(code); - Py_XDECREF(name); - return NULL; -} - -#ifdef FIX_TRACE -static int -trace_frame(PyThreadState *tstate, PyFrameObject *f, int code, PyObject *val) -{ - int result = 0; - if (!tstate->use_tracing || tstate->tracing) - return 0; - if (tstate->c_profilefunc != NULL) { - tstate->tracing++; - result = tstate->c_profilefunc(tstate->c_profileobj, - f, code , val); - tstate->use_tracing = ((tstate->c_tracefunc != NULL) - || (tstate->c_profilefunc != NULL)); - tstate->tracing--; - if (result) - return result; - } - if (tstate->c_tracefunc != NULL) { - tstate->tracing++; - result = tstate->c_tracefunc(tstate->c_traceobj, - f, code , val); - tstate->use_tracing = ((tstate->c_tracefunc != NULL) - || (tstate->c_profilefunc != NULL)); - tstate->tracing--; - } - return result; -} - -static int -trace_frame_exc(PyThreadState *tstate, PyFrameObject *f) -{ - PyObject *type, *value, *traceback, *arg; - int err; - - if (tstate->c_tracefunc == NULL) - return 0; - - PyErr_Fetch(&type, &value, &traceback); - if (value == NULL) { - value = Py_None; - Py_INCREF(value); - } - arg = Py_BuildValue("(OOO)", type, value, traceback); - if (arg == NULL) { - PyErr_Restore(type, value, traceback); - return 0; - } - err = trace_frame(tstate, f, PyTrace_EXCEPTION, arg); - Py_DECREF(arg); - if (err == 0) - PyErr_Restore(type, value, traceback); - else { - Py_XDECREF(type); - Py_XDECREF(value); - Py_XDECREF(traceback); - } - return err; -} -#endif - -static PyObject* -call_with_frame(PyCodeObject *c, PyObject* func, PyObject* args) -{ - PyThreadState *tstate = PyThreadState_GET(); - PyFrameObject *f; - PyObject *res; - - if (c == NULL) - return NULL; - - f = PyFrame_New(tstate, c, PyEval_GetGlobals(), NULL); - if (f == NULL) - return NULL; - tstate->frame = f; -#ifdef FIX_TRACE - if (trace_frame(tstate, f, PyTrace_CALL, Py_None) < 0) { - return NULL; - } -#endif - res = PyEval_CallObject(func, args); - if (res == NULL) { - if (tstate->curexc_traceback == NULL) - PyTraceBack_Here(f); -#ifdef FIX_TRACE - if (trace_frame_exc(tstate, f) < 0) { - return NULL; - } - } - else { - if (trace_frame(tstate, f, PyTrace_RETURN, res) < 0) { - Py_XDECREF(res); - res = NULL; - } - } -#else - } -#endif - tstate->frame = f->f_back; - Py_DECREF(f); - return res; -} - -#ifndef Py_USING_UNICODE -#define STRING_CONV_FUNC conv_string_to_utf8 -#else -/* Python 2.0 and later versions, when built with Unicode support */ -#define STRING_CONV_FUNC (self->returns_unicode \ - ? conv_string_to_unicode : conv_string_to_utf8) -#endif - -static PyObject* -string_intern(xmlparseobject *self, const char* str) -{ - PyObject *result = STRING_CONV_FUNC(str); - PyObject *value; - if (!self->intern) - return result; - value = PyDict_GetItem(self->intern, result); - if (!value) { - if (PyDict_SetItem(self->intern, result, result) == 0) - return result; - else - return NULL; - } - Py_INCREF(value); - Py_DECREF(result); - return value; -} - -/* Return 0 on success, -1 on exception. - * flag_error() will be called before return if needed. - */ -static int -call_character_handler(xmlparseobject *self, const XML_Char *buffer, int len) -{ - PyObject *args; - PyObject *temp; - - args = PyTuple_New(1); - if (args == NULL) - return -1; -#ifdef Py_USING_UNICODE - temp = (self->returns_unicode - ? conv_string_len_to_unicode(buffer, len) - : conv_string_len_to_utf8(buffer, len)); -#else - temp = conv_string_len_to_utf8(buffer, len); -#endif - if (temp == NULL) { - Py_DECREF(args); - flag_error(self); - return -1; - } - PyTuple_SET_ITEM(args, 0, temp); - /* temp is now a borrowed reference; consider it unused. */ - self->in_callback = 1; - temp = call_with_frame(getcode(CharacterData, "CharacterData", __LINE__), - self->handlers[CharacterData], args); - /* temp is an owned reference again, or NULL */ - self->in_callback = 0; - Py_DECREF(args); - if (temp == NULL) { - flag_error(self); - return -1; - } - Py_DECREF(temp); - return 0; -} - -static int -flush_character_buffer(xmlparseobject *self) -{ - int rc; - if (self->buffer == NULL || self->buffer_used == 0) - return 0; - rc = call_character_handler(self, self->buffer, self->buffer_used); - self->buffer_used = 0; - return rc; -} - -static void -my_CharacterDataHandler(void *userData, const XML_Char *data, int len) -{ - xmlparseobject *self = (xmlparseobject *) userData; - if (self->buffer == NULL) - call_character_handler(self, data, len); - else { - if ((self->buffer_used + len) > self->buffer_size) { - if (flush_character_buffer(self) < 0) - return; - /* handler might have changed; drop the rest on the floor - * if there isn't a handler anymore - */ - if (!have_handler(self, CharacterData)) - return; - } - if (len > self->buffer_size) { - call_character_handler(self, data, len); - self->buffer_used = 0; - } - else { - memcpy(self->buffer + self->buffer_used, - data, len * sizeof(XML_Char)); - self->buffer_used += len; - } - } -} - -static void -my_StartElementHandler(void *userData, - const XML_Char *name, const XML_Char *atts[]) -{ - xmlparseobject *self = (xmlparseobject *)userData; - - if (have_handler(self, StartElement)) { - PyObject *container, *rv, *args; - int i, max; - - if (flush_character_buffer(self) < 0) - return; - /* Set max to the number of slots filled in atts[]; max/2 is - * the number of attributes we need to process. - */ - if (self->specified_attributes) { - max = XML_GetSpecifiedAttributeCount(self->itself); - } - else { - max = 0; - while (atts[max] != NULL) - max += 2; - } - /* Build the container. */ - if (self->ordered_attributes) - container = PyList_New(max); - else - container = PyDict_New(); - if (container == NULL) { - flag_error(self); - return; - } - for (i = 0; i < max; i += 2) { - PyObject *n = string_intern(self, (XML_Char *) atts[i]); - PyObject *v; - if (n == NULL) { - flag_error(self); - Py_DECREF(container); - return; - } - v = STRING_CONV_FUNC((XML_Char *) atts[i+1]); - if (v == NULL) { - flag_error(self); - Py_DECREF(container); - Py_DECREF(n); - return; - } - if (self->ordered_attributes) { - PyList_SET_ITEM(container, i, n); - PyList_SET_ITEM(container, i+1, v); - } - else if (PyDict_SetItem(container, n, v)) { - flag_error(self); - Py_DECREF(n); - Py_DECREF(v); - return; - } - else { - Py_DECREF(n); - Py_DECREF(v); - } - } - args = Py_BuildValue("(NN)", string_intern(self, name), container); - if (args == NULL) { - Py_DECREF(container); - return; - } - /* Container is now a borrowed reference; ignore it. */ - self->in_callback = 1; - rv = call_with_frame(getcode(StartElement, "StartElement", __LINE__), - self->handlers[StartElement], args); - self->in_callback = 0; - Py_DECREF(args); - if (rv == NULL) { - flag_error(self); - return; - } - Py_DECREF(rv); - } -} - -#define RC_HANDLER(RC, NAME, PARAMS, INIT, PARAM_FORMAT, CONVERSION, \ - RETURN, GETUSERDATA) \ -static RC \ -my_##NAME##Handler PARAMS {\ - xmlparseobject *self = GETUSERDATA ; \ - PyObject *args = NULL; \ - PyObject *rv = NULL; \ - INIT \ -\ - if (have_handler(self, NAME)) { \ - if (flush_character_buffer(self) < 0) \ - return RETURN; \ - args = Py_BuildValue PARAM_FORMAT ;\ - if (!args) { flag_error(self); return RETURN;} \ - self->in_callback = 1; \ - rv = call_with_frame(getcode(NAME,#NAME,__LINE__), \ - self->handlers[NAME], args); \ - self->in_callback = 0; \ - Py_DECREF(args); \ - if (rv == NULL) { \ - flag_error(self); \ - return RETURN; \ - } \ - CONVERSION \ - Py_DECREF(rv); \ - } \ - return RETURN; \ -} - -#define VOID_HANDLER(NAME, PARAMS, PARAM_FORMAT) \ - RC_HANDLER(void, NAME, PARAMS, ;, PARAM_FORMAT, ;, ;,\ - (xmlparseobject *)userData) - -#define INT_HANDLER(NAME, PARAMS, PARAM_FORMAT)\ - RC_HANDLER(int, NAME, PARAMS, int rc=0;, PARAM_FORMAT, \ - rc = PyInt_AsLong(rv);, rc, \ - (xmlparseobject *)userData) - -VOID_HANDLER(EndElement, - (void *userData, const XML_Char *name), - ("(N)", string_intern(self, name))) - -VOID_HANDLER(ProcessingInstruction, - (void *userData, - const XML_Char *target, - const XML_Char *data), - ("(NO&)", string_intern(self, target), STRING_CONV_FUNC,data)) - -VOID_HANDLER(UnparsedEntityDecl, - (void *userData, - const XML_Char *entityName, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId, - const XML_Char *notationName), - ("(NNNNN)", - string_intern(self, entityName), string_intern(self, base), - string_intern(self, systemId), string_intern(self, publicId), - string_intern(self, notationName))) - -#ifndef Py_USING_UNICODE -VOID_HANDLER(EntityDecl, - (void *userData, - const XML_Char *entityName, - int is_parameter_entity, - const XML_Char *value, - int value_length, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId, - const XML_Char *notationName), - ("NiNNNNN", - string_intern(self, entityName), is_parameter_entity, - conv_string_len_to_utf8(value, value_length), - string_intern(self, base), string_intern(self, systemId), - string_intern(self, publicId), - string_intern(self, notationName))) -#else -VOID_HANDLER(EntityDecl, - (void *userData, - const XML_Char *entityName, - int is_parameter_entity, - const XML_Char *value, - int value_length, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId, - const XML_Char *notationName), - ("NiNNNNN", - string_intern(self, entityName), is_parameter_entity, - (self->returns_unicode - ? conv_string_len_to_unicode(value, value_length) - : conv_string_len_to_utf8(value, value_length)), - string_intern(self, base), string_intern(self, systemId), - string_intern(self, publicId), - string_intern(self, notationName))) -#endif - -VOID_HANDLER(XmlDecl, - (void *userData, - const XML_Char *version, - const XML_Char *encoding, - int standalone), - ("(O&O&i)", - STRING_CONV_FUNC,version, STRING_CONV_FUNC,encoding, - standalone)) - -static PyObject * -conv_content_model(XML_Content * const model, - PyObject *(*conv_string)(const XML_Char *)) -{ - PyObject *result = NULL; - PyObject *children = PyTuple_New(model->numchildren); - int i; - - if (children != NULL) { - assert(model->numchildren < INT_MAX); - for (i = 0; i < (int)model->numchildren; ++i) { - PyObject *child = conv_content_model(&model->children[i], - conv_string); - if (child == NULL) { - Py_XDECREF(children); - return NULL; - } - PyTuple_SET_ITEM(children, i, child); - } - result = Py_BuildValue("(iiO&N)", - model->type, model->quant, - conv_string,model->name, children); - } - return result; -} - -static void -my_ElementDeclHandler(void *userData, - const XML_Char *name, - XML_Content *model) -{ - xmlparseobject *self = (xmlparseobject *)userData; - PyObject *args = NULL; - - if (have_handler(self, ElementDecl)) { - PyObject *rv = NULL; - PyObject *modelobj, *nameobj; - - if (flush_character_buffer(self) < 0) - goto finally; -#ifdef Py_USING_UNICODE - modelobj = conv_content_model(model, - (self->returns_unicode - ? conv_string_to_unicode - : conv_string_to_utf8)); -#else - modelobj = conv_content_model(model, conv_string_to_utf8); -#endif - if (modelobj == NULL) { - flag_error(self); - goto finally; - } - nameobj = string_intern(self, name); - if (nameobj == NULL) { - Py_DECREF(modelobj); - flag_error(self); - goto finally; - } - args = Py_BuildValue("NN", string_intern(self, name), modelobj); - if (args == NULL) { - Py_DECREF(modelobj); - flag_error(self); - goto finally; - } - self->in_callback = 1; - rv = call_with_frame(getcode(ElementDecl, "ElementDecl", __LINE__), - self->handlers[ElementDecl], args); - self->in_callback = 0; - if (rv == NULL) { - flag_error(self); - goto finally; - } - Py_DECREF(rv); - } - finally: - Py_XDECREF(args); - XML_FreeContentModel(self->itself, model); - return; -} - -VOID_HANDLER(AttlistDecl, - (void *userData, - const XML_Char *elname, - const XML_Char *attname, - const XML_Char *att_type, - const XML_Char *dflt, - int isrequired), - ("(NNO&O&i)", - string_intern(self, elname), string_intern(self, attname), - STRING_CONV_FUNC,att_type, STRING_CONV_FUNC,dflt, - isrequired)) - -#if XML_COMBINED_VERSION >= 19504 -VOID_HANDLER(SkippedEntity, - (void *userData, - const XML_Char *entityName, - int is_parameter_entity), - ("Ni", - string_intern(self, entityName), is_parameter_entity)) -#endif - -VOID_HANDLER(NotationDecl, - (void *userData, - const XML_Char *notationName, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId), - ("(NNNN)", - string_intern(self, notationName), string_intern(self, base), - string_intern(self, systemId), string_intern(self, publicId))) - -VOID_HANDLER(StartNamespaceDecl, - (void *userData, - const XML_Char *prefix, - const XML_Char *uri), - ("(NN)", - string_intern(self, prefix), string_intern(self, uri))) - -VOID_HANDLER(EndNamespaceDecl, - (void *userData, - const XML_Char *prefix), - ("(N)", string_intern(self, prefix))) - -VOID_HANDLER(Comment, - (void *userData, const XML_Char *data), - ("(O&)", STRING_CONV_FUNC,data)) - -VOID_HANDLER(StartCdataSection, - (void *userData), - ("()")) - -VOID_HANDLER(EndCdataSection, - (void *userData), - ("()")) - -#ifndef Py_USING_UNICODE -VOID_HANDLER(Default, - (void *userData, const XML_Char *s, int len), - ("(N)", conv_string_len_to_utf8(s,len))) - -VOID_HANDLER(DefaultHandlerExpand, - (void *userData, const XML_Char *s, int len), - ("(N)", conv_string_len_to_utf8(s,len))) -#else -VOID_HANDLER(Default, - (void *userData, const XML_Char *s, int len), - ("(N)", (self->returns_unicode - ? conv_string_len_to_unicode(s,len) - : conv_string_len_to_utf8(s,len)))) - -VOID_HANDLER(DefaultHandlerExpand, - (void *userData, const XML_Char *s, int len), - ("(N)", (self->returns_unicode - ? conv_string_len_to_unicode(s,len) - : conv_string_len_to_utf8(s,len)))) -#endif - -INT_HANDLER(NotStandalone, - (void *userData), - ("()")) - -RC_HANDLER(int, ExternalEntityRef, - (XML_Parser parser, - const XML_Char *context, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId), - int rc=0;, - ("(O&NNN)", - STRING_CONV_FUNC,context, string_intern(self, base), - string_intern(self, systemId), string_intern(self, publicId)), - rc = PyInt_AsLong(rv);, rc, - XML_GetUserData(parser)) - -/* XXX UnknownEncodingHandler */ - -VOID_HANDLER(StartDoctypeDecl, - (void *userData, const XML_Char *doctypeName, - const XML_Char *sysid, const XML_Char *pubid, - int has_internal_subset), - ("(NNNi)", string_intern(self, doctypeName), - string_intern(self, sysid), string_intern(self, pubid), - has_internal_subset)) - -VOID_HANDLER(EndDoctypeDecl, (void *userData), ("()")) - -/* ---------------------------------------------------------------- */ - -static PyObject * -get_parse_result(xmlparseobject *self, int rv) -{ - if (PyErr_Occurred()) { - return NULL; - } - if (rv == 0) { - return set_error(self, XML_GetErrorCode(self->itself)); - } - if (flush_character_buffer(self) < 0) { - return NULL; - } - return PyInt_FromLong(rv); -} - -PyDoc_STRVAR(xmlparse_Parse__doc__, -"Parse(data[, isfinal])\n\ -Parse XML data. `isfinal' should be true at end of input."); - -static PyObject * -xmlparse_Parse(xmlparseobject *self, PyObject *args) -{ - char *s; - int slen; - int isFinal = 0; - - if (!PyArg_ParseTuple(args, "s#|i:Parse", &s, &slen, &isFinal)) - return NULL; - - return get_parse_result(self, XML_Parse(self->itself, s, slen, isFinal)); -} - -/* File reading copied from cPickle */ - -#define BUF_SIZE 2048 - -static int -readinst(char *buf, int buf_size, PyObject *meth) -{ - PyObject *arg = NULL; - PyObject *bytes = NULL; - PyObject *str = NULL; - int len = -1; - - if ((bytes = PyInt_FromLong(buf_size)) == NULL) - goto finally; - - if ((arg = PyTuple_New(1)) == NULL) { - Py_DECREF(bytes); - goto finally; - } - - PyTuple_SET_ITEM(arg, 0, bytes); - - if ((str = PyObject_Call(meth, arg, NULL)) == NULL) - goto finally; - - /* XXX what to do if it returns a Unicode string? */ - if (!PyString_Check(str)) { - PyErr_Format(PyExc_TypeError, - "read() did not return a string object (type=%.400s)", - str->ob_type->tp_name); - goto finally; - } - len = PyString_GET_SIZE(str); - if (len > buf_size) { - PyErr_Format(PyExc_ValueError, - "read() returned too much data: " - "%i bytes requested, %i returned", - buf_size, len); - goto finally; - } - memcpy(buf, PyString_AsString(str), len); -finally: - Py_XDECREF(arg); - Py_XDECREF(str); - return len; -} - -PyDoc_STRVAR(xmlparse_ParseFile__doc__, -"ParseFile(file)\n\ -Parse XML data from file-like object."); - -static PyObject * -xmlparse_ParseFile(xmlparseobject *self, PyObject *args) -{ - int rv = 1; - PyObject *f; - FILE *fp; - PyObject *readmethod = NULL; - - if (!PyArg_ParseTuple(args, "O:ParseFile", &f)) - return NULL; - - if (PyFile_Check(f)) { - fp = PyFile_AsFile(f); - } - else{ - fp = NULL; - readmethod = PyObject_GetAttrString(f, "read"); - if (readmethod == NULL) { - PyErr_Clear(); - PyErr_SetString(PyExc_TypeError, - "argument must have 'read' attribute"); - return NULL; - } - } - for (;;) { - int bytes_read; - void *buf = XML_GetBuffer(self->itself, BUF_SIZE); - if (buf == NULL) { - Py_XDECREF(readmethod); - return PyErr_NoMemory(); - } - - if (fp) { - bytes_read = fread(buf, sizeof(char), BUF_SIZE, fp); - if (bytes_read < 0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - } - else { - bytes_read = readinst(buf, BUF_SIZE, readmethod); - if (bytes_read < 0) { - Py_DECREF(readmethod); - return NULL; - } - } - rv = XML_ParseBuffer(self->itself, bytes_read, bytes_read == 0); - if (PyErr_Occurred()) { - Py_XDECREF(readmethod); - return NULL; - } - - if (!rv || bytes_read == 0) - break; - } - Py_XDECREF(readmethod); - return get_parse_result(self, rv); -} - -PyDoc_STRVAR(xmlparse_SetBase__doc__, -"SetBase(base_url)\n\ -Set the base URL for the parser."); - -static PyObject * -xmlparse_SetBase(xmlparseobject *self, PyObject *args) -{ - char *base; - - if (!PyArg_ParseTuple(args, "s:SetBase", &base)) - return NULL; - if (!XML_SetBase(self->itself, base)) { - return PyErr_NoMemory(); - } - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(xmlparse_GetBase__doc__, -"GetBase() -> url\n\ -Return base URL string for the parser."); - -static PyObject * -xmlparse_GetBase(xmlparseobject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":GetBase")) - return NULL; - - return Py_BuildValue("z", XML_GetBase(self->itself)); -} - -PyDoc_STRVAR(xmlparse_GetInputContext__doc__, -"GetInputContext() -> string\n\ -Return the untranslated text of the input that caused the current event.\n\ -If the event was generated by a large amount of text (such as a start tag\n\ -for an element with many attributes), not all of the text may be available."); - -static PyObject * -xmlparse_GetInputContext(xmlparseobject *self, PyObject *args) -{ - PyObject *result = NULL; - - if (PyArg_ParseTuple(args, ":GetInputContext")) { - if (self->in_callback) { - int offset, size; - const char *buffer - = XML_GetInputContext(self->itself, &offset, &size); - - if (buffer != NULL) - result = PyString_FromStringAndSize(buffer + offset, size); - else { - result = Py_None; - Py_INCREF(result); - } - } - else { - result = Py_None; - Py_INCREF(result); - } - } - return result; -} - -PyDoc_STRVAR(xmlparse_ExternalEntityParserCreate__doc__, -"ExternalEntityParserCreate(context[, encoding])\n\ -Create a parser for parsing an external entity based on the\n\ -information passed to the ExternalEntityRefHandler."); - -static PyObject * -xmlparse_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args) -{ - char *context; - char *encoding = NULL; - xmlparseobject *new_parser; - int i; - - if (!PyArg_ParseTuple(args, "z|s:ExternalEntityParserCreate", - &context, &encoding)) { - return NULL; - } - -#ifndef Py_TPFLAGS_HAVE_GC - /* Python versions 2.0 and 2.1 */ - new_parser = PyObject_New(xmlparseobject, &Xmlparsetype); -#else - /* Python versions 2.2 and later */ - new_parser = PyObject_GC_New(xmlparseobject, &Xmlparsetype); -#endif - - if (new_parser == NULL) - return NULL; - new_parser->buffer_size = self->buffer_size; - new_parser->buffer_used = 0; - if (self->buffer != NULL) { - new_parser->buffer = malloc(new_parser->buffer_size); - if (new_parser->buffer == NULL) { -#ifndef Py_TPFLAGS_HAVE_GC - /* Code for versions 2.0 and 2.1 */ - PyObject_Del(new_parser); -#else - /* Code for versions 2.2 and later. */ - PyObject_GC_Del(new_parser); -#endif - return PyErr_NoMemory(); - } - } - else - new_parser->buffer = NULL; - new_parser->returns_unicode = self->returns_unicode; - new_parser->ordered_attributes = self->ordered_attributes; - new_parser->specified_attributes = self->specified_attributes; - new_parser->in_callback = 0; - new_parser->ns_prefixes = self->ns_prefixes; - new_parser->itself = XML_ExternalEntityParserCreate(self->itself, context, - encoding); - new_parser->handlers = 0; - new_parser->intern = self->intern; - Py_XINCREF(new_parser->intern); -#ifdef Py_TPFLAGS_HAVE_GC - PyObject_GC_Track(new_parser); -#else - PyObject_GC_Init(new_parser); -#endif - - if (!new_parser->itself) { - Py_DECREF(new_parser); - return PyErr_NoMemory(); - } - - XML_SetUserData(new_parser->itself, (void *)new_parser); - - /* allocate and clear handlers first */ - for (i = 0; handler_info[i].name != NULL; i++) - /* do nothing */; - - new_parser->handlers = malloc(sizeof(PyObject *) * i); - if (!new_parser->handlers) { - Py_DECREF(new_parser); - return PyErr_NoMemory(); - } - clear_handlers(new_parser, 1); - - /* then copy handlers from self */ - for (i = 0; handler_info[i].name != NULL; i++) { - PyObject *handler = self->handlers[i]; - if (handler != NULL) { - Py_INCREF(handler); - new_parser->handlers[i] = handler; - handler_info[i].setter(new_parser->itself, - handler_info[i].handler); - } - } - return (PyObject *)new_parser; -} - -PyDoc_STRVAR(xmlparse_SetParamEntityParsing__doc__, -"SetParamEntityParsing(flag) -> success\n\ -Controls parsing of parameter entities (including the external DTD\n\ -subset). Possible flag values are XML_PARAM_ENTITY_PARSING_NEVER,\n\ -XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE and\n\ -XML_PARAM_ENTITY_PARSING_ALWAYS. Returns true if setting the flag\n\ -was successful."); - -static PyObject* -xmlparse_SetParamEntityParsing(xmlparseobject *p, PyObject* args) -{ - int flag; - if (!PyArg_ParseTuple(args, "i", &flag)) - return NULL; - flag = XML_SetParamEntityParsing(p->itself, flag); - return PyInt_FromLong(flag); -} - - -#if XML_COMBINED_VERSION >= 19505 -PyDoc_STRVAR(xmlparse_UseForeignDTD__doc__, -"UseForeignDTD([flag])\n\ -Allows the application to provide an artificial external subset if one is\n\ -not specified as part of the document instance. This readily allows the\n\ -use of a 'default' document type controlled by the application, while still\n\ -getting the advantage of providing document type information to the parser.\n\ -'flag' defaults to True if not provided."); - -static PyObject * -xmlparse_UseForeignDTD(xmlparseobject *self, PyObject *args) -{ - PyObject *flagobj = NULL; - XML_Bool flag = XML_TRUE; - enum XML_Error rc; - if (!PyArg_ParseTuple(args, "|O:UseForeignDTD", &flagobj)) - return NULL; - if (flagobj != NULL) - flag = PyObject_IsTrue(flagobj) ? XML_TRUE : XML_FALSE; - rc = XML_UseForeignDTD(self->itself, flag); - if (rc != XML_ERROR_NONE) { - return set_error(self, rc); - } - Py_INCREF(Py_None); - return Py_None; -} -#endif - -static struct PyMethodDef xmlparse_methods[] = { - {"Parse", (PyCFunction)xmlparse_Parse, - METH_VARARGS, xmlparse_Parse__doc__}, - {"ParseFile", (PyCFunction)xmlparse_ParseFile, - METH_VARARGS, xmlparse_ParseFile__doc__}, - {"SetBase", (PyCFunction)xmlparse_SetBase, - METH_VARARGS, xmlparse_SetBase__doc__}, - {"GetBase", (PyCFunction)xmlparse_GetBase, - METH_VARARGS, xmlparse_GetBase__doc__}, - {"ExternalEntityParserCreate", (PyCFunction)xmlparse_ExternalEntityParserCreate, - METH_VARARGS, xmlparse_ExternalEntityParserCreate__doc__}, - {"SetParamEntityParsing", (PyCFunction)xmlparse_SetParamEntityParsing, - METH_VARARGS, xmlparse_SetParamEntityParsing__doc__}, - {"GetInputContext", (PyCFunction)xmlparse_GetInputContext, - METH_VARARGS, xmlparse_GetInputContext__doc__}, -#if XML_COMBINED_VERSION >= 19505 - {"UseForeignDTD", (PyCFunction)xmlparse_UseForeignDTD, - METH_VARARGS, xmlparse_UseForeignDTD__doc__}, -#endif - {NULL, NULL} /* sentinel */ -}; - -/* ---------- */ - - -#ifdef Py_USING_UNICODE - -/* pyexpat international encoding support. - Make it as simple as possible. -*/ - -static char template_buffer[257]; -PyObject *template_string = NULL; - -static void -init_template_buffer(void) -{ - int i; - for (i = 0; i < 256; i++) { - template_buffer[i] = i; - } - template_buffer[256] = 0; -} - -static int -PyUnknownEncodingHandler(void *encodingHandlerData, - const XML_Char *name, - XML_Encoding *info) -{ - PyUnicodeObject *_u_string = NULL; - int result = 0; - int i; - - /* Yes, supports only 8bit encodings */ - _u_string = (PyUnicodeObject *) - PyUnicode_Decode(template_buffer, 256, name, "replace"); - - if (_u_string == NULL) - return result; - - for (i = 0; i < 256; i++) { - /* Stupid to access directly, but fast */ - Py_UNICODE c = _u_string->str[i]; - if (c == Py_UNICODE_REPLACEMENT_CHARACTER) - info->map[i] = -1; - else - info->map[i] = c; - } - info->data = NULL; - info->convert = NULL; - info->release = NULL; - result = 1; - Py_DECREF(_u_string); - return result; -} - -#endif - -static PyObject * -newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern) -{ - int i; - xmlparseobject *self; - -#ifdef Py_TPFLAGS_HAVE_GC - /* Code for versions 2.2 and later */ - self = PyObject_GC_New(xmlparseobject, &Xmlparsetype); -#else - self = PyObject_New(xmlparseobject, &Xmlparsetype); -#endif - if (self == NULL) - return NULL; - -#ifdef Py_USING_UNICODE - self->returns_unicode = 1; -#else - self->returns_unicode = 0; -#endif - - self->buffer = NULL; - self->buffer_size = CHARACTER_DATA_BUFFER_SIZE; - self->buffer_used = 0; - self->ordered_attributes = 0; - self->specified_attributes = 0; - self->in_callback = 0; - self->ns_prefixes = 0; - self->handlers = NULL; - if (namespace_separator != NULL) { - self->itself = XML_ParserCreateNS(encoding, *namespace_separator); - } - else { - self->itself = XML_ParserCreate(encoding); - } - self->intern = intern; - Py_XINCREF(self->intern); -#ifdef Py_TPFLAGS_HAVE_GC - PyObject_GC_Track(self); -#else - PyObject_GC_Init(self); -#endif - if (self->itself == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "XML_ParserCreate failed"); - Py_DECREF(self); - return NULL; - } - XML_SetUserData(self->itself, (void *)self); -#ifdef Py_USING_UNICODE - XML_SetUnknownEncodingHandler(self->itself, - (XML_UnknownEncodingHandler) PyUnknownEncodingHandler, NULL); -#endif - - for (i = 0; handler_info[i].name != NULL; i++) - /* do nothing */; - - self->handlers = malloc(sizeof(PyObject *) * i); - if (!self->handlers) { - Py_DECREF(self); - return PyErr_NoMemory(); - } - clear_handlers(self, 1); - - return (PyObject*)self; -} - - -static void -xmlparse_dealloc(xmlparseobject *self) -{ - int i; -#ifdef Py_TPFLAGS_HAVE_GC - PyObject_GC_UnTrack(self); -#else - PyObject_GC_Fini(self); -#endif - if (self->itself != NULL) - XML_ParserFree(self->itself); - self->itself = NULL; - - if (self->handlers != NULL) { - PyObject *temp; - for (i = 0; handler_info[i].name != NULL; i++) { - temp = self->handlers[i]; - self->handlers[i] = NULL; - Py_XDECREF(temp); - } - free(self->handlers); - self->handlers = NULL; - } - if (self->buffer != NULL) { - free(self->buffer); - self->buffer = NULL; - } - Py_XDECREF(self->intern); -#ifndef Py_TPFLAGS_HAVE_GC - /* Code for versions 2.0 and 2.1 */ - PyObject_Del(self); -#else - /* Code for versions 2.2 and later. */ - PyObject_GC_Del(self); -#endif -} - -static int -handlername2int(const char *name) -{ - int i; - for (i = 0; handler_info[i].name != NULL; i++) { - if (strcmp(name, handler_info[i].name) == 0) { - return i; - } - } - return -1; -} - -static PyObject * -get_pybool(int istrue) -{ - PyObject *result = istrue ? Py_True : Py_False; - Py_INCREF(result); - return result; -} - -static PyObject * -xmlparse_getattr(xmlparseobject *self, char *name) -{ - int handlernum = handlername2int(name); - - if (handlernum != -1) { - PyObject *result = self->handlers[handlernum]; - if (result == NULL) - result = Py_None; - Py_INCREF(result); - return result; - } - if (name[0] == 'E') { - if (strcmp(name, "ErrorCode") == 0) - return PyInt_FromLong((long) - XML_GetErrorCode(self->itself)); - if (strcmp(name, "ErrorLineNumber") == 0) - return PyInt_FromLong((long) - XML_GetErrorLineNumber(self->itself)); - if (strcmp(name, "ErrorColumnNumber") == 0) - return PyInt_FromLong((long) - XML_GetErrorColumnNumber(self->itself)); - if (strcmp(name, "ErrorByteIndex") == 0) - return PyInt_FromLong((long) - XML_GetErrorByteIndex(self->itself)); - } - if (name[0] == 'b') { - if (strcmp(name, "buffer_size") == 0) - return PyInt_FromLong((long) self->buffer_size); - if (strcmp(name, "buffer_text") == 0) - return get_pybool(self->buffer != NULL); - if (strcmp(name, "buffer_used") == 0) - return PyInt_FromLong((long) self->buffer_used); - } - if (strcmp(name, "namespace_prefixes") == 0) - return get_pybool(self->ns_prefixes); - if (strcmp(name, "ordered_attributes") == 0) - return get_pybool(self->ordered_attributes); - if (strcmp(name, "returns_unicode") == 0) - return get_pybool((long) self->returns_unicode); - if (strcmp(name, "specified_attributes") == 0) - return get_pybool((long) self->specified_attributes); - if (strcmp(name, "intern") == 0) { - if (self->intern == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - else { - Py_INCREF(self->intern); - return self->intern; - } - } - -#define APPEND(list, str) \ - do { \ - PyObject *o = PyString_FromString(str); \ - if (o != NULL) \ - PyList_Append(list, o); \ - Py_XDECREF(o); \ - } while (0) - - if (strcmp(name, "__members__") == 0) { - int i; - PyObject *rc = PyList_New(0); - for (i = 0; handler_info[i].name != NULL; i++) { - PyObject *o = get_handler_name(&handler_info[i]); - if (o != NULL) - PyList_Append(rc, o); - Py_XDECREF(o); - } - APPEND(rc, "ErrorCode"); - APPEND(rc, "ErrorLineNumber"); - APPEND(rc, "ErrorColumnNumber"); - APPEND(rc, "ErrorByteIndex"); - APPEND(rc, "buffer_size"); - APPEND(rc, "buffer_text"); - APPEND(rc, "buffer_used"); - APPEND(rc, "namespace_prefixes"); - APPEND(rc, "ordered_attributes"); - APPEND(rc, "returns_unicode"); - APPEND(rc, "specified_attributes"); - APPEND(rc, "intern"); - -#undef APPEND - return rc; - } - return Py_FindMethod(xmlparse_methods, (PyObject *)self, name); -} - -static int -sethandler(xmlparseobject *self, const char *name, PyObject* v) -{ - int handlernum = handlername2int(name); - if (handlernum >= 0) { - xmlhandler c_handler = NULL; - PyObject *temp = self->handlers[handlernum]; - - if (v == Py_None) - v = NULL; - else if (v != NULL) { - Py_INCREF(v); - c_handler = handler_info[handlernum].handler; - } - self->handlers[handlernum] = v; - Py_XDECREF(temp); - handler_info[handlernum].setter(self->itself, c_handler); - return 1; - } - return 0; -} - -static int -xmlparse_setattr(xmlparseobject *self, char *name, PyObject *v) -{ - /* Set attribute 'name' to value 'v'. v==NULL means delete */ - if (v == NULL) { - PyErr_SetString(PyExc_RuntimeError, "Cannot delete attribute"); - return -1; - } - if (strcmp(name, "buffer_text") == 0) { - if (PyObject_IsTrue(v)) { - if (self->buffer == NULL) { - self->buffer = malloc(self->buffer_size); - if (self->buffer == NULL) { - PyErr_NoMemory(); - return -1; - } - self->buffer_used = 0; - } - } - else if (self->buffer != NULL) { - if (flush_character_buffer(self) < 0) - return -1; - free(self->buffer); - self->buffer = NULL; - } - return 0; - } - if (strcmp(name, "namespace_prefixes") == 0) { - if (PyObject_IsTrue(v)) - self->ns_prefixes = 1; - else - self->ns_prefixes = 0; - XML_SetReturnNSTriplet(self->itself, self->ns_prefixes); - return 0; - } - if (strcmp(name, "ordered_attributes") == 0) { - if (PyObject_IsTrue(v)) - self->ordered_attributes = 1; - else - self->ordered_attributes = 0; - return 0; - } - if (strcmp(name, "returns_unicode") == 0) { - if (PyObject_IsTrue(v)) { -#ifndef Py_USING_UNICODE - PyErr_SetString(PyExc_ValueError, - "Unicode support not available"); - return -1; -#else - self->returns_unicode = 1; -#endif - } - else - self->returns_unicode = 0; - return 0; - } - if (strcmp(name, "specified_attributes") == 0) { - if (PyObject_IsTrue(v)) - self->specified_attributes = 1; - else - self->specified_attributes = 0; - return 0; - } - if (strcmp(name, "CharacterDataHandler") == 0) { - /* If we're changing the character data handler, flush all - * cached data with the old handler. Not sure there's a - * "right" thing to do, though, but this probably won't - * happen. - */ - if (flush_character_buffer(self) < 0) - return -1; - } - if (sethandler(self, name, v)) { - return 0; - } - PyErr_SetString(PyExc_AttributeError, name); - return -1; -} - -#ifdef WITH_CYCLE_GC -static int -xmlparse_traverse(xmlparseobject *op, visitproc visit, void *arg) -{ - int i, err; - for (i = 0; handler_info[i].name != NULL; i++) { - if (!op->handlers[i]) - continue; - err = visit(op->handlers[i], arg); - if (err) - return err; - } - return 0; -} - -static int -xmlparse_clear(xmlparseobject *op) -{ - clear_handlers(op, 0); - Py_XDECREF(op->intern); - op->intern = 0; - return 0; -} -#endif - -PyDoc_STRVAR(Xmlparsetype__doc__, "XML parser"); - -static PyTypeObject Xmlparsetype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "pyexpat.xmlparser", /*tp_name*/ - sizeof(xmlparseobject) + PyGC_HEAD_SIZE,/*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)xmlparse_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - (getattrfunc)xmlparse_getattr, /*tp_getattr*/ - (setattrfunc)xmlparse_setattr, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ - (reprfunc)0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)0, /*tp_str*/ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ -#ifdef Py_TPFLAGS_HAVE_GC - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ -#else - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ -#endif - Xmlparsetype__doc__, /* tp_doc - Documentation string */ -#ifdef WITH_CYCLE_GC - (traverseproc)xmlparse_traverse, /* tp_traverse */ - (inquiry)xmlparse_clear /* tp_clear */ -#else - 0, 0 -#endif -}; - -/* End of code for xmlparser objects */ -/* -------------------------------------------------------- */ - -PyDoc_STRVAR(pyexpat_ParserCreate__doc__, -"ParserCreate([encoding[, namespace_separator]]) -> parser\n\ -Return a new XML parser object."); - -static PyObject * -pyexpat_ParserCreate(PyObject *notused, PyObject *args, PyObject *kw) -{ - char *encoding = NULL; - char *namespace_separator = NULL; - PyObject *intern = NULL; - PyObject *result; - int intern_decref = 0; - static char *kwlist[] = {"encoding", "namespace_separator", - "intern", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kw, "|zzO:ParserCreate", kwlist, - &encoding, &namespace_separator, &intern)) - return NULL; - if (namespace_separator != NULL - && strlen(namespace_separator) > 1) { - PyErr_SetString(PyExc_ValueError, - "namespace_separator must be at most one" - " character, omitted, or None"); - return NULL; - } - /* Explicitly passing None means no interning is desired. - Not passing anything means that a new dictionary is used. */ - if (intern == Py_None) - intern = NULL; - else if (intern == NULL) { - intern = PyDict_New(); - if (!intern) - return NULL; - intern_decref = 1; - } - else if (!PyDict_Check(intern)) { - PyErr_SetString(PyExc_TypeError, "intern must be a dictionary"); - return NULL; - } - - result = newxmlparseobject(encoding, namespace_separator, intern); - if (intern_decref) { - Py_DECREF(intern); - } - return result; -} - -PyDoc_STRVAR(pyexpat_ErrorString__doc__, -"ErrorString(errno) -> string\n\ -Returns string error for given number."); - -static PyObject * -pyexpat_ErrorString(PyObject *self, PyObject *args) -{ - long code = 0; - - if (!PyArg_ParseTuple(args, "l:ErrorString", &code)) - return NULL; - return Py_BuildValue("z", XML_ErrorString((int)code)); -} - -/* List of methods defined in the module */ - -static struct PyMethodDef pyexpat_methods[] = { - {"ParserCreate", (PyCFunction)pyexpat_ParserCreate, - METH_VARARGS|METH_KEYWORDS, pyexpat_ParserCreate__doc__}, - {"ErrorString", (PyCFunction)pyexpat_ErrorString, - METH_VARARGS, pyexpat_ErrorString__doc__}, - - {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */ -}; - -/* Module docstring */ - -PyDoc_STRVAR(pyexpat_module_documentation, -"Python wrapper for Expat parser."); - -/* Return a Python string that represents the version number without the - * extra cruft added by revision control, even if the right options were - * given to the "cvs export" command to make it not include the extra - * cruft. - */ -static PyObject * -get_version_string(void) -{ - static char *rcsid = "$Revision: 2.83 $"; - char *rev = rcsid; - int i = 0; - - while (!isdigit((int)*rev)) - ++rev; - while (rev[i] != ' ' && rev[i] != '\0') - ++i; - - return PyString_FromStringAndSize(rev, i); -} - -/* Initialization function for the module */ - -#ifndef MODULE_NAME -#define MODULE_NAME "pyexpat" -#endif - -#ifndef MODULE_INITFUNC -#define MODULE_INITFUNC initpyexpat -#endif - -#ifndef PyMODINIT_FUNC -# ifdef MS_WINDOWS -# define PyMODINIT_FUNC __declspec(dllexport) void -# else -# define PyMODINIT_FUNC void -# endif -#endif - -PyMODINIT_FUNC MODULE_INITFUNC(void); /* avoid compiler warnings */ - -PyMODINIT_FUNC -MODULE_INITFUNC(void) -{ - PyObject *m, *d; - PyObject *errmod_name = PyString_FromString(MODULE_NAME ".errors"); - PyObject *errors_module; - PyObject *modelmod_name; - PyObject *model_module; - PyObject *sys_modules; - - if (errmod_name == NULL) - return; - modelmod_name = PyString_FromString(MODULE_NAME ".model"); - if (modelmod_name == NULL) - return; - - Xmlparsetype.ob_type = &PyType_Type; - - /* Create the module and add the functions */ - m = Py_InitModule3(MODULE_NAME, pyexpat_methods, - pyexpat_module_documentation); - - /* Add some symbolic constants to the module */ - if (ErrorObject == NULL) { - ErrorObject = PyErr_NewException("xml.parsers.expat.ExpatError", - NULL, NULL); - if (ErrorObject == NULL) - return; - } - Py_INCREF(ErrorObject); - PyModule_AddObject(m, "error", ErrorObject); - Py_INCREF(ErrorObject); - PyModule_AddObject(m, "ExpatError", ErrorObject); - Py_INCREF(&Xmlparsetype); - PyModule_AddObject(m, "XMLParserType", (PyObject *) &Xmlparsetype); - - PyModule_AddObject(m, "__version__", get_version_string()); - PyModule_AddStringConstant(m, "EXPAT_VERSION", - (char *) XML_ExpatVersion()); - { - XML_Expat_Version info = XML_ExpatVersionInfo(); - PyModule_AddObject(m, "version_info", - Py_BuildValue("(iii)", info.major, - info.minor, info.micro)); - } -#ifdef Py_USING_UNICODE - init_template_buffer(); -#endif - /* XXX When Expat supports some way of figuring out how it was - compiled, this should check and set native_encoding - appropriately. - */ - PyModule_AddStringConstant(m, "native_encoding", "UTF-8"); - - sys_modules = PySys_GetObject("modules"); - d = PyModule_GetDict(m); - errors_module = PyDict_GetItem(d, errmod_name); - if (errors_module == NULL) { - errors_module = PyModule_New(MODULE_NAME ".errors"); - if (errors_module != NULL) { - PyDict_SetItem(sys_modules, errmod_name, errors_module); - /* gives away the reference to errors_module */ - PyModule_AddObject(m, "errors", errors_module); - } - } - Py_DECREF(errmod_name); - model_module = PyDict_GetItem(d, modelmod_name); - if (model_module == NULL) { - model_module = PyModule_New(MODULE_NAME ".model"); - if (model_module != NULL) { - PyDict_SetItem(sys_modules, modelmod_name, model_module); - /* gives away the reference to model_module */ - PyModule_AddObject(m, "model", model_module); - } - } - Py_DECREF(modelmod_name); - if (errors_module == NULL || model_module == NULL) - /* Don't core dump later! */ - return; - -#if XML_COMBINED_VERSION > 19505 - { - const XML_Feature *features = XML_GetFeatureList(); - PyObject *list = PyList_New(0); - if (list == NULL) - /* just ignore it */ - PyErr_Clear(); - else { - int i = 0; - for (; features[i].feature != XML_FEATURE_END; ++i) { - int ok; - PyObject *item = Py_BuildValue("si", features[i].name, - features[i].value); - if (item == NULL) { - Py_DECREF(list); - list = NULL; - break; - } - ok = PyList_Append(list, item); - Py_DECREF(item); - if (ok < 0) { - PyErr_Clear(); - break; - } - } - if (list != NULL) - PyModule_AddObject(m, "features", list); - } - } -#endif - -#define MYCONST(name) \ - PyModule_AddStringConstant(errors_module, #name, \ - (char*)XML_ErrorString(name)) - - MYCONST(XML_ERROR_NO_MEMORY); - MYCONST(XML_ERROR_SYNTAX); - MYCONST(XML_ERROR_NO_ELEMENTS); - MYCONST(XML_ERROR_INVALID_TOKEN); - MYCONST(XML_ERROR_UNCLOSED_TOKEN); - MYCONST(XML_ERROR_PARTIAL_CHAR); - MYCONST(XML_ERROR_TAG_MISMATCH); - MYCONST(XML_ERROR_DUPLICATE_ATTRIBUTE); - MYCONST(XML_ERROR_JUNK_AFTER_DOC_ELEMENT); - MYCONST(XML_ERROR_PARAM_ENTITY_REF); - MYCONST(XML_ERROR_UNDEFINED_ENTITY); - MYCONST(XML_ERROR_RECURSIVE_ENTITY_REF); - MYCONST(XML_ERROR_ASYNC_ENTITY); - MYCONST(XML_ERROR_BAD_CHAR_REF); - MYCONST(XML_ERROR_BINARY_ENTITY_REF); - MYCONST(XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF); - MYCONST(XML_ERROR_MISPLACED_XML_PI); - MYCONST(XML_ERROR_UNKNOWN_ENCODING); - MYCONST(XML_ERROR_INCORRECT_ENCODING); - MYCONST(XML_ERROR_UNCLOSED_CDATA_SECTION); - MYCONST(XML_ERROR_EXTERNAL_ENTITY_HANDLING); - MYCONST(XML_ERROR_NOT_STANDALONE); - - PyModule_AddStringConstant(errors_module, "__doc__", - "Constants used to describe error conditions."); - -#undef MYCONST - -#define MYCONST(c) PyModule_AddIntConstant(m, #c, c) - MYCONST(XML_PARAM_ENTITY_PARSING_NEVER); - MYCONST(XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE); - MYCONST(XML_PARAM_ENTITY_PARSING_ALWAYS); -#undef MYCONST - -#define MYCONST(c) PyModule_AddIntConstant(model_module, #c, c) - PyModule_AddStringConstant(model_module, "__doc__", - "Constants used to interpret content model information."); - - MYCONST(XML_CTYPE_EMPTY); - MYCONST(XML_CTYPE_ANY); - MYCONST(XML_CTYPE_MIXED); - MYCONST(XML_CTYPE_NAME); - MYCONST(XML_CTYPE_CHOICE); - MYCONST(XML_CTYPE_SEQ); - - MYCONST(XML_CQUANT_NONE); - MYCONST(XML_CQUANT_OPT); - MYCONST(XML_CQUANT_REP); - MYCONST(XML_CQUANT_PLUS); -#undef MYCONST -} - -static void -clear_handlers(xmlparseobject *self, int initial) -{ - int i = 0; - PyObject *temp; - - for (; handler_info[i].name != NULL; i++) { - if (initial) - self->handlers[i] = NULL; - else { - temp = self->handlers[i]; - self->handlers[i] = NULL; - Py_XDECREF(temp); - handler_info[i].setter(self->itself, NULL); - } - } -} - -static struct HandlerInfo handler_info[] = { - {"StartElementHandler", - (xmlhandlersetter)XML_SetStartElementHandler, - (xmlhandler)my_StartElementHandler}, - {"EndElementHandler", - (xmlhandlersetter)XML_SetEndElementHandler, - (xmlhandler)my_EndElementHandler}, - {"ProcessingInstructionHandler", - (xmlhandlersetter)XML_SetProcessingInstructionHandler, - (xmlhandler)my_ProcessingInstructionHandler}, - {"CharacterDataHandler", - (xmlhandlersetter)XML_SetCharacterDataHandler, - (xmlhandler)my_CharacterDataHandler}, - {"UnparsedEntityDeclHandler", - (xmlhandlersetter)XML_SetUnparsedEntityDeclHandler, - (xmlhandler)my_UnparsedEntityDeclHandler}, - {"NotationDeclHandler", - (xmlhandlersetter)XML_SetNotationDeclHandler, - (xmlhandler)my_NotationDeclHandler}, - {"StartNamespaceDeclHandler", - (xmlhandlersetter)XML_SetStartNamespaceDeclHandler, - (xmlhandler)my_StartNamespaceDeclHandler}, - {"EndNamespaceDeclHandler", - (xmlhandlersetter)XML_SetEndNamespaceDeclHandler, - (xmlhandler)my_EndNamespaceDeclHandler}, - {"CommentHandler", - (xmlhandlersetter)XML_SetCommentHandler, - (xmlhandler)my_CommentHandler}, - {"StartCdataSectionHandler", - (xmlhandlersetter)XML_SetStartCdataSectionHandler, - (xmlhandler)my_StartCdataSectionHandler}, - {"EndCdataSectionHandler", - (xmlhandlersetter)XML_SetEndCdataSectionHandler, - (xmlhandler)my_EndCdataSectionHandler}, - {"DefaultHandler", - (xmlhandlersetter)XML_SetDefaultHandler, - (xmlhandler)my_DefaultHandler}, - {"DefaultHandlerExpand", - (xmlhandlersetter)XML_SetDefaultHandlerExpand, - (xmlhandler)my_DefaultHandlerExpandHandler}, - {"NotStandaloneHandler", - (xmlhandlersetter)XML_SetNotStandaloneHandler, - (xmlhandler)my_NotStandaloneHandler}, - {"ExternalEntityRefHandler", - (xmlhandlersetter)XML_SetExternalEntityRefHandler, - (xmlhandler)my_ExternalEntityRefHandler}, - {"StartDoctypeDeclHandler", - (xmlhandlersetter)XML_SetStartDoctypeDeclHandler, - (xmlhandler)my_StartDoctypeDeclHandler}, - {"EndDoctypeDeclHandler", - (xmlhandlersetter)XML_SetEndDoctypeDeclHandler, - (xmlhandler)my_EndDoctypeDeclHandler}, - {"EntityDeclHandler", - (xmlhandlersetter)XML_SetEntityDeclHandler, - (xmlhandler)my_EntityDeclHandler}, - {"XmlDeclHandler", - (xmlhandlersetter)XML_SetXmlDeclHandler, - (xmlhandler)my_XmlDeclHandler}, - {"ElementDeclHandler", - (xmlhandlersetter)XML_SetElementDeclHandler, - (xmlhandler)my_ElementDeclHandler}, - {"AttlistDeclHandler", - (xmlhandlersetter)XML_SetAttlistDeclHandler, - (xmlhandler)my_AttlistDeclHandler}, -#if XML_COMBINED_VERSION >= 19504 - {"SkippedEntityHandler", - (xmlhandlersetter)XML_SetSkippedEntityHandler, - (xmlhandler)my_SkippedEntityHandler}, -#endif - - {NULL, NULL, NULL} /* sentinel */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/pypcre.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/pypcre.c deleted file mode 100644 index 5c4b5e16..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/pypcre.c +++ /dev/null @@ -1,4756 +0,0 @@ - -/************************************************* -* Perl-Compatible Regular Expressions * -*************************************************/ - -/* DO NOT EDIT THIS FILE! */ - -/* This file is automatically written by the merge-files.py script -included with the PCRE distribution for Python; it's produced from -several C files, and code is removed in the process. If you want to -modify the code or track down bugs, it will be much easier to work -with the code in its original, multiple-file form. Don't edit this -file by hand, or submit patches to it. - -The Python-specific PCRE distribution can be retrieved from - http://starship.skyport.net/crew/amk/regex/ - -The unmodified original PCRE distribution is available at -ftp://ftp.cus.cam.ac.uk/pub/software/programs/pcre/, and is originally -written by: Philip Hazel - -Extensively modified by the Python String-SIG: -Send bug reports to: -(They'll figure out if it's a bug in PCRE or in the Python-specific -changes.) - - Copyright (c) 1997 University of Cambridge - ------------------------------------------------------------------------------ -Permission is granted to anyone to use this software for any purpose on any -computer system, and to redistribute it freely, subject to the following -restrictions: - -1. This software 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. - -2. The origin of this software must not be misrepresented, either by - explicit claim or by omission. - -3. Altered versions must be plainly marked as such, and must not be - misrepresented as being the original software. ------------------------------------------------------------------------------ -*/ - - -#define FOR_PYTHON -#include "Python.h" -#include "pcre-int.h" -#include -#include "graminit.h" - -/************************************************* -* Perl-Compatible Regular Expressions * -*************************************************/ - -/* This file is automatically written by the makechartables auxiliary -program. If you edit it by hand, you might like to edit the Makefile to -prevent its ever being regenerated. */ - -/* This table is a lower casing table. */ - -unsigned char pcre_lcc[] = { - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, - 64, 97, 98, 99,100,101,102,103, - 104,105,106,107,108,109,110,111, - 112,113,114,115,116,117,118,119, - 120,121,122, 91, 92, 93, 94, 95, - 96, 97, 98, 99,100,101,102,103, - 104,105,106,107,108,109,110,111, - 112,113,114,115,116,117,118,119, - 120,121,122,123,124,125,126,127, - 128,129,130,131,132,133,134,135, - 136,137,138,139,140,141,142,143, - 144,145,146,147,148,149,150,151, - 152,153,154,155,156,157,158,159, - 160,161,162,163,164,165,166,167, - 168,169,170,171,172,173,174,175, - 176,177,178,179,180,181,182,183, - 184,185,186,187,188,189,190,191, - 192,193,194,195,196,197,198,199, - 200,201,202,203,204,205,206,207, - 208,209,210,211,212,213,214,215, - 216,217,218,219,220,221,222,223, - 224,225,226,227,228,229,230,231, - 232,233,234,235,236,237,238,239, - 240,241,242,243,244,245,246,247, - 248,249,250,251,252,253,254,255 }; - -/* This table is a case flipping table. */ - -unsigned char pcre_fcc[] = { - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, - 64, 97, 98, 99,100,101,102,103, - 104,105,106,107,108,109,110,111, - 112,113,114,115,116,117,118,119, - 120,121,122, 91, 92, 93, 94, 95, - 96, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90,123,124,125,126,127, - 128,129,130,131,132,133,134,135, - 136,137,138,139,140,141,142,143, - 144,145,146,147,148,149,150,151, - 152,153,154,155,156,157,158,159, - 160,161,162,163,164,165,166,167, - 168,169,170,171,172,173,174,175, - 176,177,178,179,180,181,182,183, - 184,185,186,187,188,189,190,191, - 192,193,194,195,196,197,198,199, - 200,201,202,203,204,205,206,207, - 208,209,210,211,212,213,214,215, - 216,217,218,219,220,221,222,223, - 224,225,226,227,228,229,230,231, - 232,233,234,235,236,237,238,239, - 240,241,242,243,244,245,246,247, - 248,249,250,251,252,253,254,255 }; - -/* This table contains bit maps for digits, letters, 'word' chars, and -white space. Each map is 32 bytes long and the bits run from the least -significant end of each byte. */ - -unsigned char pcre_cbits[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0xfe,0xff,0xff,0x07,0xfe,0xff,0xff,0x07, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - - 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03, - 0xfe,0xff,0xff,0x87,0xfe,0xff,0xff,0x07, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - - 0x00,0x3e,0x00,0x00,0x01,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; - -/* This table identifies various classes of character by individual bits: - 0x01 white space character - 0x02 letter - 0x04 decimal digit - 0x08 hexadecimal digit - 0x10 alphanumeric or '_' - 0x80 regular expression metacharacter or binary zero -*/ - -unsigned char pcre_ctypes[] = { - 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 */ - 0x00,0x01,0x01,0x01,0x01,0x01,0x00,0x00, /* 8- 15 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 16- 23 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 24- 31 */ - 0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00, /* - ' */ - 0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x00, /* ( - / */ - 0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c, /* 0 - 7 */ - 0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x80, /* 8 - ? */ - 0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* @ - G */ - 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* H - O */ - 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* P - W */ - 0x12,0x12,0x12,0x80,0x00,0x00,0x80,0x10, /* X - _ */ - 0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* ` - g */ - 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* h - o */ - 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* p - w */ - 0x12,0x12,0x12,0x80,0x80,0x00,0x00,0x00, /* x -127 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */ - -/* End of chartables.c */ -/************************************************* -* Perl-Compatible Regular Expressions * -*************************************************/ - -/* -This is a library of functions to support regular expressions whose syntax -and semantics are as close as possible to those of the Perl 5 language. See -the file Tech.Notes for some information on the internals. - -Written by: Philip Hazel - - Copyright (c) 1998 University of Cambridge - ------------------------------------------------------------------------------ -Permission is granted to anyone to use this software for any purpose on any -computer system, and to redistribute it freely, subject to the following -restrictions: - -1. This software 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. - -2. The origin of this software must not be misrepresented, either by - explicit claim or by omission. - -3. Altered versions must be plainly marked as such, and must not be - misrepresented as being the original software. ------------------------------------------------------------------------------ -*/ - - -/* Include the internals header, which itself includes Standard C headers plus -the external pcre header. */ - - - - -/************************************************* -* Create bitmap of starting chars * -*************************************************/ - -/* This function scans a compiled unanchored expression and attempts to build a -bitmap of the set of initial characters. If it can't, it returns FALSE. As time -goes by, we may be able to get more clever at doing this. - -Arguments: - code points to an expression - start_bits points to a 32-byte table, initialized to 0 - -Returns: TRUE if table built, FALSE otherwise -*/ - -static BOOL -set_start_bits(const uschar *code, uschar *start_bits) -{ -register int c; -volatile int dummy; - -do - { - const uschar *tcode = code + 3; - BOOL try_next = TRUE; - - while (try_next) - { - try_next = FALSE; - - if ((int)*tcode >= OP_BRA || *tcode == OP_ASSERT) - { - if (!set_start_bits(tcode, start_bits)) return FALSE; - } - - else switch(*tcode) - { - default: - return FALSE; - - /* BRAZERO does the bracket, but carries on. */ - - case OP_BRAZERO: - case OP_BRAMINZERO: - if (!set_start_bits(++tcode, start_bits)) return FALSE; - dummy = 1; - do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT); - tcode += 3; - try_next = TRUE; - break; - - /* Single-char * or ? sets the bit and tries the next item */ - - case OP_STAR: - case OP_MINSTAR: - case OP_QUERY: - case OP_MINQUERY: - start_bits[tcode[1]/8] |= (1 << (tcode[1]&7)); - tcode += 2; - try_next = TRUE; - break; - - /* Single-char upto sets the bit and tries the next */ - - case OP_UPTO: - case OP_MINUPTO: - start_bits[tcode[3]/8] |= (1 << (tcode[3]&7)); - tcode += 4; - try_next = TRUE; - break; - - /* At least one single char sets the bit and stops */ - - case OP_EXACT: /* Fall through */ - tcode++; - - case OP_CHARS: /* Fall through */ - tcode++; - - case OP_PLUS: - case OP_MINPLUS: - start_bits[tcode[1]/8] |= (1 << (tcode[1]&7)); - break; - - /* Single character type sets the bits and stops */ - - case OP_NOT_DIGIT: - for (c = 0; c < 32; c++) start_bits[c] |= ~pcre_cbits[c+cbit_digit]; - break; - - case OP_DIGIT: - for (c = 0; c < 32; c++) start_bits[c] |= pcre_cbits[c+cbit_digit]; - break; - - case OP_NOT_WHITESPACE: - for (c = 0; c < 32; c++) start_bits[c] |= ~pcre_cbits[c+cbit_space]; - break; - - case OP_WHITESPACE: - for (c = 0; c < 32; c++) start_bits[c] |= pcre_cbits[c+cbit_space]; - break; - - case OP_NOT_WORDCHAR: - for (c = 0; c < 32; c++) - start_bits[c] |= ~(pcre_cbits[c] | pcre_cbits[c+cbit_word]); - break; - - case OP_WORDCHAR: - for (c = 0; c < 32; c++) - start_bits[c] |= (pcre_cbits[c] | pcre_cbits[c+cbit_word]); - break; - - /* One or more character type fudges the pointer and restarts, knowing - it will hit a single character type and stop there. */ - - case OP_TYPEPLUS: - case OP_TYPEMINPLUS: - tcode++; - try_next = TRUE; - break; - - case OP_TYPEEXACT: - tcode += 3; - try_next = TRUE; - break; - - /* Zero or more repeats of character types set the bits and then - try again. */ - - case OP_TYPEUPTO: - case OP_TYPEMINUPTO: - tcode += 2; /* Fall through */ - - case OP_TYPESTAR: - case OP_TYPEMINSTAR: - case OP_TYPEQUERY: - case OP_TYPEMINQUERY: - switch(tcode[1]) - { - case OP_NOT_DIGIT: - for (c = 0; c < 32; c++) start_bits[c] |= ~pcre_cbits[c+cbit_digit]; - break; - - case OP_DIGIT: - for (c = 0; c < 32; c++) start_bits[c] |= pcre_cbits[c+cbit_digit]; - break; - - case OP_NOT_WHITESPACE: - for (c = 0; c < 32; c++) start_bits[c] |= ~pcre_cbits[c+cbit_space]; - break; - - case OP_WHITESPACE: - for (c = 0; c < 32; c++) start_bits[c] |= pcre_cbits[c+cbit_space]; - break; - - case OP_NOT_WORDCHAR: - for (c = 0; c < 32; c++) - start_bits[c] |= ~(pcre_cbits[c] | pcre_cbits[c+cbit_word]); - break; - - case OP_WORDCHAR: - for (c = 0; c < 32; c++) - start_bits[c] |= (pcre_cbits[c] | pcre_cbits[c+cbit_word]); - break; - } - - tcode += 2; - try_next = TRUE; - break; - - /* Character class: set the bits and either carry on or not, - according to the repeat count. */ - - case OP_CLASS: - case OP_NEGCLASS: - { - tcode++; - for (c = 0; c < 32; c++) start_bits[c] |= tcode[c]; - tcode += 32; - switch (*tcode) - { - case OP_CRSTAR: - case OP_CRMINSTAR: - case OP_CRQUERY: - case OP_CRMINQUERY: - tcode++; - try_next = TRUE; - break; - - case OP_CRRANGE: - case OP_CRMINRANGE: - if (((tcode[1] << 8) + tcode[2]) == 0) - { - tcode += 5; - try_next = TRUE; - } - break; - } - } - break; /* End of class handling */ - - } /* End of switch */ - } /* End of try_next loop */ - - code += (code[1] << 8) + code[2]; /* Advance to next branch */ - } -while (*code == OP_ALT); -return TRUE; -} - - - -/************************************************* -* Study a compiled expression * -*************************************************/ - -/* This function is handed a compiled expression that it must study to produce -information that will speed up the matching. It returns a pcre_extra block -which then gets handed back to pcre_exec(). - -Arguments: - re points to the compiled expression - options contains option bits - errorptr points to where to place error messages; - set NULL unless error - -Returns: pointer to a pcre_extra block, - NULL on error or if no optimization possible -*/ - -pcre_extra * -pcre_study(const pcre *external_re, int options, const char **errorptr) -{ -BOOL caseless; -uschar start_bits[32]; -real_pcre_extra *extra; -const real_pcre *re = (const real_pcre *)external_re; - -*errorptr = NULL; - -if (re == NULL || re->magic_number != MAGIC_NUMBER) - { - *errorptr = "argument is not a compiled regular expression"; - return NULL; - } - -if ((options & ~PUBLIC_STUDY_OPTIONS) != 0) - { - *errorptr = "unknown or incorrect option bit(s) set"; - return NULL; - } - -/* Caseless can either be from the compiled regex or from options. */ - -caseless = ((re->options | options) & PCRE_CASELESS) != 0; - -/* For an anchored pattern, or an unanchored pattern that has a first char, or a -multiline pattern that matches only at "line starts", no further processing at -present. */ - -if ((re->options & (PCRE_ANCHORED|PCRE_FIRSTSET|PCRE_STARTLINE)) != 0) - return NULL; - -/* See if we can find a fixed set of initial characters for the pattern. */ - -memset(start_bits, 0, 32 * sizeof(uschar)); -if (!set_start_bits(re->code, start_bits)) return NULL; - -/* If this studying is caseless, scan the created bit map and duplicate the -bits for any letters. */ - -if (caseless) - { - register int c; - for (c = 0; c < 256; c++) - { - if ((start_bits[c/8] & (1 << (c&7))) != 0 && - (pcre_ctypes[c] & ctype_letter) != 0) - { - int d = pcre_fcc[c]; - start_bits[d/8] |= (1 << (d&7)); - } - } - } - -/* Get an "extra" block and put the information therein. */ - -extra = (real_pcre_extra *)(pcre_malloc)(sizeof(real_pcre_extra)); - -if (extra == NULL) - { - *errorptr = "failed to get memory"; - return NULL; - } - -extra->options = PCRE_STUDY_MAPPED | (caseless? PCRE_STUDY_CASELESS : 0); -memcpy(extra->start_bits, start_bits, sizeof(start_bits)); - -return (pcre_extra *)extra; -} - -/* End of study.c */ -/************************************************* -* Perl-Compatible Regular Expressions * -*************************************************/ - -/* -This is a library of functions to support regular expressions whose syntax -and semantics are as close as possible to those of the Perl 5 language. See -the file Tech.Notes for some information on the internals. - -Written by: Philip Hazel - - Copyright (c) 1998 University of Cambridge - ------------------------------------------------------------------------------ -Permission is granted to anyone to use this software for any purpose on any -computer system, and to redistribute it freely, subject to the following -restrictions: - -1. This software 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. - -2. The origin of this software must not be misrepresented, either by - explicit claim or by omission. - -3. Altered versions must be plainly marked as such, and must not be - misrepresented as being the original software. ------------------------------------------------------------------------------ -*/ - - -/* Define DEBUG to get debugging output on stdout. */ - -/* #define DEBUG */ - -/* Use a macro for debugging printing, 'cause that eliminates the use -of #ifdef inline, and there are *still* stupid compilers about that don't like -indented pre-processor statements. I suppose it's only been 10 years... */ - -#undef DPRINTF -#ifdef DEBUG -#define DPRINTF(p) printf p -#else -#define DPRINTF(p) /*nothing*/ -#endif - -/* Include the internals header, which itself includes Standard C headers plus -the external pcre header. */ - - - - -#ifndef Py_eval_input -/* For Python 1.4, graminit.h has to be explicitly included */ -#define Py_eval_input eval_input - -#endif /* FOR_PYTHON */ - -/* Allow compilation as C++ source code, should anybody want to do that. */ - -#ifdef __cplusplus -#define class pcre_class -#endif - - -/* Min and max values for the common repeats; for the maxima, 0 => infinity */ - -static const char rep_min[] = { 0, 0, 1, 1, 0, 0 }; -static const char rep_max[] = { 0, 0, 0, 0, 1, 1 }; - -/* Text forms of OP_ values and things, for debugging (not all used) */ - -#ifdef DEBUG -static const char *OP_names[] = { - "End", "\\A", "\\B", "\\b", "\\D", "\\d", - "\\S", "\\s", "\\W", "\\w", "Cut", "\\Z", - "localized \\B", "localized \\b", "localized \\W", "localized \\w", - "^", "$", "Any", "chars", - "not", - "*", "*?", "+", "+?", "?", "??", "{", "{", "{", - "*", "*?", "+", "+?", "?", "??", "{", "{", "{", - "*", "*?", "+", "+?", "?", "??", "{", "{", "{", - "*", "*?", "+", "+?", "?", "??", "{", "{", - "class", "negclass", "classL", "Ref", - "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not", "Once", - "Brazero", "Braminzero", "Bra" -}; -#endif - -/* Table for handling escaped characters in the range '0'-'z'. Positive returns -are simple data values; negative values are for special things like \d and so -on. Zero means further processing is needed (for things like \x), or the escape -is invalid. */ - -static const short int escapes[] = { - 0, 0, 0, 0, 0, 0, 0, 0, /* 0 - 7 */ - 0, 0, ':', ';', '<', '=', '>', '?', /* 8 - ? */ - '@', -ESC_A, -ESC_B, 0, -ESC_D, 0, 0, 0, /* @ - G */ - 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */ - 0, 0, 0, -ESC_S, 0, 0, 0, -ESC_W, /* P - W */ - 0, 0, -ESC_Z, '[', '\\', ']', '^', '_', /* X - _ */ - '`', 7, -ESC_b, 0, -ESC_d, 0, '\f', 0, /* ` - g */ - 0, 0, 0, 0, 0, 0, '\n', 0, /* h - o */ - 0, 0, '\r', -ESC_s, '\t', 0, '\v', -ESC_w, /* p - w */ - 0, 0, 0 /* x - z */ -}; - -/* Definition to allow mutual recursion */ - -static BOOL -compile_regex(int, int *, uschar **, const uschar **, const char **, - PyObject *); - -/* Structure for passing "static" information around between the functions -doing the matching, so that they are thread-safe. */ - -typedef struct match_data { - int errorcode; /* As it says */ - int *offset_vector; /* Offset vector */ - int offset_end; /* One past the end */ - BOOL offset_overflow; /* Set if too many extractions */ - BOOL caseless; /* Case-independent flag */ - BOOL runtime_caseless; /* Caseless forced at run time */ - BOOL multiline; /* Multiline flag */ - BOOL notbol; /* NOTBOL flag */ - BOOL noteol; /* NOTEOL flag */ - BOOL dotall; /* Dot matches any char */ - BOOL endonly; /* Dollar not before final \n */ - const uschar *start_subject; /* Start of the subject string */ - const uschar *end_subject; /* End of the subject string */ - jmp_buf fail_env; /* Environment for longjump() break out */ - const uschar *end_match_ptr; /* Subject position at end match */ - int end_offset_top; /* Highwater mark at end of match */ - jmp_buf error_env; /* For longjmp() if an error occurs deep inside a - matching operation */ - int length; /* Length of the allocated stacks */ - int point; /* Point to add next item pushed onto stacks */ - /* Pointers to the 6 stacks */ - int *off_num, *offset_top, *r1, *r2; - const uschar **eptr, **ecode; -} match_data; - - - -/************************************************* -* Global variables * -*************************************************/ - -/* PCRE is thread-clean and doesn't use any global variables in the normal -sense. However, it calls memory allocation and free functions via the two -indirections below, which are can be changed by the caller, but are shared -between all threads. */ - -void *(*pcre_malloc)(size_t) = malloc; -void (*pcre_free)(void *) = free; - - - - -/************************************************* -* Return version string * -*************************************************/ - -const char * -pcre_version(void) -{ -return PCRE_VERSION; -} - - - - -/************************************************* -* Return info about a compiled pattern * -*************************************************/ - -/* This function picks potentially useful data out of the private -structure. - -Arguments: - external_re points to compiled code - optptr where to pass back the options - first_char where to pass back the first character, - or -1 if multiline and all branches start ^, - or -2 otherwise - -Returns: number of identifying extraction brackets - or negative values on error -*/ - -int -pcre_info(const pcre *external_re, int *optptr, int *first_char) -{ -const real_pcre *re = (real_pcre *)external_re; -if (re == NULL) return PCRE_ERROR_NULL; -if (re->magic_number != MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC; -if (optptr != NULL) *optptr = (re->options & PUBLIC_OPTIONS); -if (first_char != NULL) - *first_char = ((re->options & PCRE_FIRSTSET) != 0)? re->first_char : - ((re->options & PCRE_STARTLINE) != 0)? -1 : -2; -return re->top_bracket; -} - - - - -#ifdef DEBUG -/************************************************* -* Debugging function to print chars * -*************************************************/ - -/* Print a sequence of chars in printable format, stopping at the end of the -subject if the requested. - -Arguments: - p points to characters - length number to print - is_subject TRUE if printing from within md->start_subject - md pointer to matching data block, if is_subject is TRUE - -Returns: nothing -*/ - -static void -pchars(const uschar *p, int length, BOOL is_subject, match_data *md) -{ -int c; -if (is_subject && length > md->end_subject - p) length = md->end_subject - p; -while (length-- > 0) - if (isprint(c = *(p++))) printf("%c", c); else printf("\\x%02x", c); -} -#endif - - - - -/************************************************* -* Check subpattern for empty operand * -*************************************************/ - -/* This function checks a bracketed subpattern to see if any of the paths -through it could match an empty string. This is used to diagnose an error if -such a subpattern is followed by a quantifier with an unlimited upper bound. - -Argument: - code points to the opening bracket - -Returns: TRUE or FALSE -*/ - -static BOOL -could_be_empty(uschar *code) -{ -do { - uschar *cc = code + 3; - - /* Scan along the opcodes for this branch; as soon as we find something - that matches a non-empty string, break out and advance to test the next - branch. If we get to the end of the branch, return TRUE for the whole - sub-expression. */ - - for (;;) - { - /* Test an embedded subpattern; if it could not be empty, break the - loop. Otherwise carry on in the branch. */ - - if ((int)(*cc) >= OP_BRA || (int)(*cc) == OP_ONCE) - { - if (!could_be_empty(cc)) break; - do cc += (cc[1] << 8) + cc[2]; while (*cc == OP_ALT); - cc += 3; - } - - else switch (*cc) - { - /* Reached end of a branch: the subpattern may match the empty string */ - - case OP_ALT: - case OP_KET: - case OP_KETRMAX: - case OP_KETRMIN: - return TRUE; - - /* Skip over entire bracket groups with zero lower bound */ - - case OP_BRAZERO: - case OP_BRAMINZERO: - cc++; - /* Fall through */ - - /* Skip over assertive subpatterns */ - - case OP_ASSERT: - case OP_ASSERT_NOT: - do cc += (cc[1] << 8) + cc[2]; while (*cc == OP_ALT); - cc += 3; - break; - - /* Skip over things that don't match chars */ - - case OP_SOD: - case OP_EOD: - case OP_CIRC: - case OP_DOLL: - case OP_NOT_WORD_BOUNDARY: - case OP_WORD_BOUNDARY: - case OP_NOT_WORD_BOUNDARY_L: - case OP_WORD_BOUNDARY_L: - cc++; - break; - - /* Skip over simple repeats with zero lower bound */ - - case OP_STAR: - case OP_MINSTAR: - case OP_QUERY: - case OP_MINQUERY: - case OP_NOTSTAR: - case OP_NOTMINSTAR: - case OP_NOTQUERY: - case OP_NOTMINQUERY: - case OP_TYPESTAR: - case OP_TYPEMINSTAR: - case OP_TYPEQUERY: - case OP_TYPEMINQUERY: - cc += 2; - break; - - /* Skip over UPTOs (lower bound is zero) */ - - case OP_UPTO: - case OP_MINUPTO: - case OP_TYPEUPTO: - case OP_TYPEMINUPTO: - cc += 4; - break; - - /* Check a class or a back reference for a zero minimum */ - - case OP_CLASS: - case OP_NEGCLASS: - case OP_REF: - case OP_CLASS_L: - switch(*cc) - { - case (OP_REF): cc += 2; break; - case (OP_CLASS): case (OP_NEGCLASS): cc += 1+32; break; - case (OP_CLASS_L): cc += 1+1+32; break; - } - - switch (*cc) - { - case OP_CRSTAR: - case OP_CRMINSTAR: - case OP_CRQUERY: - case OP_CRMINQUERY: - cc++; - break; - - case OP_CRRANGE: - case OP_CRMINRANGE: - if ((cc[1] << 8) + cc[2] != 0) goto NEXT_BRANCH; - cc += 3; - break; - - default: - goto NEXT_BRANCH; - } - break; - - /* Anything else matches at least one character */ - - default: - goto NEXT_BRANCH; - } - } - - NEXT_BRANCH: - code += (code[1] << 8) + code[2]; - } -while (*code == OP_ALT); - -/* No branches match the empty string */ - -return FALSE; -} - -/* Determine the length of a group ID in an expression like - (?P...) -Arguments: - ptr pattern position pointer (say that 3 times fast) - finalchar the character that will mark the end of the ID - errorptr points to the pointer to the error message -*/ - -static int -get_group_id(const uschar *ptr, char finalchar, const char **errorptr) -{ - const uschar *start = ptr; - - /* If the first character is not in \w, or is in \w but is a digit, - report an error */ - if (!(pcre_ctypes[*ptr] & ctype_word) || - (pcre_ctypes[*ptr++] & ctype_digit)) - { - *errorptr = "(?P identifier must start with a letter or underscore"; - return 0; - } - - /* Increment ptr until we either hit a null byte, the desired - final character, or a non-word character */ - for(; (*ptr != 0) && (*ptr != finalchar) && - (pcre_ctypes[*ptr] & ctype_word); ptr++) - { - /* Empty loop body */ - } - if (*ptr==finalchar) - return ptr-start; - if (*ptr==0) - { - *errorptr = "unterminated (?P identifier"; - return 0; - } - *errorptr = "illegal character in (?P identifier"; - return 0; -} - -/************************************************* -* Handle escapes * -*************************************************/ - -/* This function is called when a \ has been encountered. It either returns a -positive value for a simple escape such as \n, or a negative value which -encodes one of the more complicated things such as \d. On entry, ptr is -pointing at the \. On exit, it is on the final character of the escape -sequence. - -Arguments: - ptrptr points to the pattern position pointer - errorptr points to the pointer to the error message - bracount number of previous extracting brackets - options the options bits - isclass TRUE if inside a character class - -Returns: zero or positive => a data character - negative => a special escape sequence - on error, errorptr is set -*/ - -static int -check_escape(const uschar **ptrptr, const char **errorptr, int bracount, - int options, BOOL isclass) -{ -const uschar *ptr = *ptrptr; -int c = *(++ptr) & 255; /* Ensure > 0 on signed-char systems */ -int i; - -if (c == 0) *errorptr = ERR1; - -/* Digits or letters may have special meaning; all others are literals. */ - -else if (c < '0' || c > 'z') {} - -/* Do an initial lookup in a table. A non-zero result is something that can be -returned immediately. Otherwise further processing may be required. */ - -else if ((i = escapes[c - '0']) != 0) c = i; - -/* Escapes that need further processing, or are illegal. */ - -else - { - - switch (c) - { - /* The handling of escape sequences consisting of a string of digits - starting with one that is not zero is not straightforward. By experiment, - the way Perl works seems to be as follows: - - Outside a character class, the digits are read as a decimal number. If the - number is less than 10, or if there are that many previous extracting - left brackets, then it is a back reference. Otherwise, up to three octal - digits are read to form an escaped byte. Thus \123 is likely to be octal - 123 (cf \0123, which is octal 012 followed by the literal 3). If the octal - value is greater than 377, the least significant 8 bits are taken. Inside a - character class, \ followed by a digit is always an octal number. */ - - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - - { - /* PYTHON: Try to compute an octal value for a character */ - for(c=0, i=0; ptr[i]!=0 && i<3; i++) - { - if (( pcre_ctypes[ ptr[i] ] & ctype_odigit) != 0) - c = (c * 8 + ptr[i]-'0') & 255; - else - break; /* Non-octal character--break out of the loop */ - } - /* It's a character if there were exactly 3 octal digits, or if - we're inside a character class and there was at least one - octal digit. */ - if ( (i == 3) || (isclass && i!=0) ) - { - ptr += i-1; - break; - } - c = ptr[0]; /* Restore the first character after the \ */ - c -= '0'; i = 1; - while (i<2 && (pcre_ctypes[ptr[1]] & ctype_digit) != 0) - { - c = c * 10 + ptr[1] - '0'; - ptr++; i++; - } - if (c > 255 - ESC_REF) *errorptr = "back reference too big"; - c = -(ESC_REF + c); - } - break; - - /* \0 always starts an octal number, but we may drop through to here with a - larger first octal digit */ - - case '0': - c -= '0'; - while(i++ < 2 && (pcre_ctypes[ptr[1]] & ctype_digit) != 0 && - ptr[1] != '8' && ptr[1] != '9') - c = (c * 8 + *(++ptr) - '0') & 255; - break; - - /* Special escapes not starting with a digit are straightforward */ - - case 'x': - c = 0; - while ( (pcre_ctypes[ptr[1]] & ctype_xdigit) != 0) - { - ptr++; - c = c * 16 + pcre_lcc[*ptr] - - (((pcre_ctypes[*ptr] & ctype_digit) != 0)? '0' : 'W'); - c &= 255; - } - break; - - - /* PCRE_EXTRA enables extensions to Perl in the matter of escapes. Any - other alphameric following \ is an error if PCRE_EXTRA was set; otherwise, - for Perl compatibility, it is a literal. */ - - default: - if ((options & PCRE_EXTRA) != 0) switch(c) - { - case 'X': - c = -ESC_X; /* This could be a lookup if it ever got into Perl */ - break; - - default: - *errorptr = ERR3; - break; - } - break; - } - } - -*ptrptr = ptr; -return c; -} - - - -/************************************************* -* Check for counted repeat * -*************************************************/ - -/* This function is called when a '{' is encountered in a place where it might -start a quantifier. It looks ahead to see if it really is a quantifier or not. -It is only a quantifier if it is one of the forms {ddd} {ddd,} or {ddd,ddd} -where the ddds are digits. - -Arguments: - p pointer to the first char after '{' - -Returns: TRUE or FALSE -*/ - -static BOOL -is_counted_repeat(const uschar *p) -{ -if ((pcre_ctypes[*p++] & ctype_digit) == 0) return FALSE; -while ((pcre_ctypes[*p] & ctype_digit) != 0) p++; -if (*p == '}') return TRUE; - -if (*p++ != ',') return FALSE; -if (*p == '}') return TRUE; - -if ((pcre_ctypes[*p++] & ctype_digit) == 0) return FALSE; -while ((pcre_ctypes[*p] & ctype_digit) != 0) p++; -return (*p == '}'); -} - - - -/************************************************* -* Read repeat counts * -*************************************************/ - -/* Read an item of the form {n,m} and return the values. This is called only -after is_counted_repeat() has confirmed that a repeat-count quantifier exists, -so the syntax is guaranteed to be correct, but we need to check the values. - -Arguments: - p pointer to first char after '{' - minp pointer to int for min - maxp pointer to int for max - returned as -1 if no max - errorptr points to pointer to error message - -Returns: pointer to '}' on success; - current ptr on error, with errorptr set -*/ - -static const uschar * -read_repeat_counts(const uschar *p, int *minp, int *maxp, const char **errorptr) -{ -int min = 0; -int max = -1; - -while ((pcre_ctypes[*p] & ctype_digit) != 0) min = min * 10 + *p++ - '0'; - -if (*p == '}') max = min; else - { - if (*(++p) != '}') - { - max = 0; - while((pcre_ctypes[*p] & ctype_digit) != 0) max = max * 10 + *p++ - '0'; - if (max < min) - { - *errorptr = ERR4; - return p; - } - } - } - -/* Do paranoid checks, then fill in the required variables, and pass back the -pointer to the terminating '}'. */ - -if (min > 65535 || max > 65535) - *errorptr = ERR5; -else - { - *minp = min; - *maxp = max; - } -return p; -} - - - -/************************************************* -* Compile one branch * -*************************************************/ - -/* Scan the pattern, compiling it into the code vector. - -Arguments: - options the option bits - bracket points to number of brackets used - code points to the pointer to the current code point - ptrptr points to the current pattern pointer - errorptr points to pointer to error message - -Returns: TRUE on success - FALSE, with *errorptr set on error -*/ - -static BOOL -compile_branch(int options, int *brackets, uschar **codeptr, - const uschar **ptrptr, const char **errorptr, PyObject *dictionary) -{ -int repeat_type, op_type; -int repeat_min, repeat_max; -int bravalue, length; -int greedy_default, greedy_non_default; -register int c; -register uschar *code = *codeptr; -const uschar *ptr = *ptrptr; -const uschar *oldptr; -uschar *previous = NULL; -uschar class[32]; -uschar *class_flag; /* Pointer to the single-byte flag for OP_CLASS_L */ - -/* Set up the default and non-default settings for greediness */ - -greedy_default = ((options & PCRE_UNGREEDY) != 0); -greedy_non_default = greedy_default ^ 1; - -/* Switch on next character until the end of the branch */ - -for (;; ptr++) - { - BOOL negate_class; - int class_charcount; - int class_lastchar; - - c = *ptr; - if ((options & PCRE_EXTENDED) != 0) - { - if ((pcre_ctypes[c] & ctype_space) != 0) continue; - if (c == '#') - { - while ((c = *(++ptr)) != 0 && c != '\n'); - continue; - } - } - - switch(c) - { - /* The branch terminates at end of string, |, or ). */ - - case 0: - case '|': - case ')': - *codeptr = code; - *ptrptr = ptr; - return TRUE; - - /* Handle single-character metacharacters */ - - case '^': - previous = NULL; - *code++ = OP_CIRC; - break; - - case '$': - previous = NULL; - *code++ = OP_DOLL; - break; - - case '.': - previous = code; - *code++ = OP_ANY; - break; - - /* Character classes. These always build a 32-byte bitmap of the permitted - characters, except in the special case where there is only one character. - For negated classes, we build the map as usual, then invert it at the end. - */ - - case '[': - previous = code; - if (options & PCRE_LOCALE) - { - *code++ = OP_CLASS_L; - /* Set the flag for localized classes (like \w) to 0 */ - class_flag = code; - *class_flag = 0; - } - else - { - *code++ = OP_CLASS; - class_flag = NULL; - } - - /* If the first character is '^', set the negation flag, and use a - different opcode. This only matters if caseless matching is specified at - runtime. */ - - if ((c = *(++ptr)) == '^') - { - negate_class = TRUE; - if (*(code-1)==OP_CLASS) *(code-1) = OP_NEGCLASS; - c = *(++ptr); - } - else negate_class = FALSE; - - /* Keep a count of chars so that we can optimize the case of just a single - character. */ - - class_charcount = 0; - class_lastchar = -1; - - /* Initialize the 32-char bit map to all zeros. We have to build the - map in a temporary bit of store, in case the class contains only 1 - character, because in that case the compiled code doesn't use the - bit map. */ - - memset(class, 0, 32 * sizeof(uschar)); - - /* Process characters until ] is reached. By writing this as a "do" it - means that an initial ] is taken as a data character. */ - - do - { - if (c == 0) - { - *errorptr = ERR6; - goto FAILED; - } - - /* Backslash may introduce a single character, or it may introduce one - of the specials, which just set a flag. Escaped items are checked for - validity in the pre-compiling pass. The sequence \b is a special case. - Inside a class (and only there) it is treated as backspace. Elsewhere - it marks a word boundary. Other escapes have preset maps ready to - or into the one we are building. We assume they have more than one - character in them, so set class_count bigger than one. */ - - if (c == '\\') - { - c = check_escape(&ptr, errorptr, *brackets, options, TRUE); - if (-c == ESC_b) c = '\b'; - else if (c < 0) - { - class_charcount = 10; - switch (-c) - { - case ESC_d: - { - for (c = 0; c < 32; c++) class[c] |= pcre_cbits[c+cbit_digit]; - } - continue; - - case ESC_D: - { - for (c = 0; c < 32; c++) class[c] |= ~pcre_cbits[c+cbit_digit]; - } - continue; - - case ESC_w: - if (options & PCRE_LOCALE) - { - *class_flag |= 1; - } - else - { - for (c = 0; c < 32; c++) - class[c] |= (pcre_cbits[c] | pcre_cbits[c+cbit_word]); - } - continue; - - case ESC_W: - if (options & PCRE_LOCALE) - { - *class_flag |= 2; - } - else - { - for (c = 0; c < 32; c++) - class[c] |= ~(pcre_cbits[c] | pcre_cbits[c+cbit_word]); - } - continue; - - case ESC_s: - { - for (c = 0; c < 32; c++) class[c] |= pcre_cbits[c+cbit_space]; - } - continue; - - case ESC_S: - { - for (c = 0; c < 32; c++) class[c] |= ~pcre_cbits[c+cbit_space]; - } - continue; - - default: - *errorptr = ERR7; - goto FAILED; - } - } - /* Fall through if single character */ - } - - /* A single character may be followed by '-' to form a range. However, - Perl does not permit ']' to be the end of the range. A '-' character - here is treated as a literal. */ - - if (ptr[1] == '-' && ptr[2] != ']') - { - int d; - ptr += 2; - d = *ptr; - - if (d == 0) - { - *errorptr = ERR6; - goto FAILED; - } - - /* The second part of a range can be a single-character escape, but - not any of the other escapes. */ - - if (d == '\\') - { - d = check_escape(&ptr, errorptr, *brackets, options, TRUE); - if (d < 0) - { - if (d == -ESC_b) d = '\b'; else - { - *errorptr = ERR7; - goto FAILED; - } - } - } - - if (d < c) - { - *errorptr = ERR8; - goto FAILED; - } - - for (; c <= d; c++) - { - class[c/8] |= (1 << (c&7)); - if ((options & PCRE_CASELESS) != 0) - { - int uc = pcre_fcc[c]; /* flip case */ - class[uc/8] |= (1 << (uc&7)); - } - class_charcount++; /* in case a one-char range */ - class_lastchar = c; - } - continue; /* Go get the next char in the class */ - } - - /* Handle a lone single character - we can get here for a normal - non-escape char, or after \ that introduces a single character. */ - - class [c/8] |= (1 << (c&7)); - if ((options & PCRE_CASELESS) != 0) - { - c = pcre_fcc[c]; /* flip case */ - class[c/8] |= (1 << (c&7)); - } - class_charcount++; - class_lastchar = c; - } - - /* Loop until ']' reached; the check for end of string happens inside the - loop. This "while" is the end of the "do" above. */ - - while ((c = *(++ptr)) != ']'); - - /* If class_charcount is 1 and class_lastchar is not negative, we saw - precisely one character. This doesn't need the whole 32-byte bit map. - We turn it into a 1-character OP_CHAR if it's positive, or OP_NOT if - it's negative. */ - - if (class_charcount == 1 && class_lastchar >= 0) - { - if (negate_class) - { - code[-1] = OP_NOT; - } - else - { - code[-1] = OP_CHARS; - *code++ = 1; - } - *code++ = class_lastchar; - } - - /* Otherwise, negate the 32-byte map if necessary, and copy it into - the code vector. */ - - else - { - /* If this is a localized opcode, bump the code pointer up */ - if (class_flag) code++; - if (negate_class) - { - if (class_flag) *class_flag = (*class_flag) ^ 63; - for (c = 0; c < 32; c++) code[c] = ~class[c]; - } - else - memcpy(code, class, 32); - code += 32; - } - break; - - /* Various kinds of repeat */ - - case '{': - if (!is_counted_repeat(ptr+1)) goto NORMAL_CHAR; - ptr = read_repeat_counts(ptr+1, &repeat_min, &repeat_max, errorptr); - if (*errorptr != NULL) goto FAILED; - goto REPEAT; - - case '*': - repeat_min = 0; - repeat_max = -1; - goto REPEAT; - - case '+': - repeat_min = 1; - repeat_max = -1; - goto REPEAT; - - case '?': - repeat_min = 0; - repeat_max = 1; - - REPEAT: - if (previous == NULL) - { - *errorptr = ERR9; - goto FAILED; - } - - /* If the next character is '?' this is a minimizing repeat, by default, - but if PCRE_UNGREEDY is set, it works the other way round. Advance to the - next character. */ - - if (ptr[1] == '?') - { repeat_type = greedy_non_default; ptr++; } - else repeat_type = greedy_default; - - /* If the maximum is zero then the minimum must also be zero; Perl allows - this case, so we do too - by simply omitting the item altogether. */ - - if (repeat_max == 0) code = previous; - - /* If previous was a string of characters, chop off the last one and use it - as the subject of the repeat. If there was only one character, we can - abolish the previous item altogether. */ - - else if (*previous == OP_CHARS) - { - int len = previous[1]; - if (len == 1) - { - c = previous[2]; - code = previous; - } - else - { - c = previous[len+1]; - previous[1]--; - code--; - } - op_type = 0; /* Use single-char op codes */ - goto OUTPUT_SINGLE_REPEAT; /* Code shared with single character types */ - } - - /* If previous was a single negated character ([^a] or similar), we use - one of the special opcodes, replacing it. The code is shared with single- - character repeats by adding a suitable offset into repeat_type. */ - - else if ((int)*previous == OP_NOT) - { - op_type = OP_NOTSTAR - OP_STAR; /* Use "not" opcodes */ - c = previous[1]; - code = previous; - goto OUTPUT_SINGLE_REPEAT; - } - - /* If previous was a character type match (\d or similar), abolish it and - create a suitable repeat item. The code is shared with single-character - repeats by adding a suitable offset into repeat_type. */ - - else if ((int)*previous < OP_CIRC || *previous == OP_ANY) - { - op_type = OP_TYPESTAR - OP_STAR; /* Use type opcodes */ - c = *previous; - code = previous; - - OUTPUT_SINGLE_REPEAT: - repeat_type += op_type; /* Combine both values for many cases */ - - /* A minimum of zero is handled either as the special case * or ?, or as - an UPTO, with the maximum given. */ - - if (repeat_min == 0) - { - if (repeat_max == -1) *code++ = OP_STAR + repeat_type; - else if (repeat_max == 1) *code++ = OP_QUERY + repeat_type; - else - { - *code++ = OP_UPTO + repeat_type; - *code++ = repeat_max >> 8; - *code++ = (repeat_max & 255); - } - } - - /* The case {1,} is handled as the special case + */ - - else if (repeat_min == 1 && repeat_max == -1) - *code++ = OP_PLUS + repeat_type; - - /* The case {n,n} is just an EXACT, while the general case {n,m} is - handled as an EXACT followed by an UPTO. An EXACT of 1 is optimized. */ - - else - { - if (repeat_min != 1) - { - *code++ = OP_EXACT + op_type; /* NB EXACT doesn't have repeat_type */ - *code++ = repeat_min >> 8; - *code++ = (repeat_min & 255); - } - - /* If the minimum is 1 and the previous item was a character string, - we either have to put back the item that got canceled if the string - length was 1, or add the character back onto the end of a longer - string. For a character type nothing need be done; it will just get - put back naturally. Note that the final character is always going to - get added below. */ - - else if (*previous == OP_CHARS) - { - if (code == previous) code += 2; else previous[1]++; - } - - /* For a single negated character we also have to put back the - item that got canceled. */ - - else if (*previous == OP_NOT) code++; - - /* If the maximum is unlimited, insert an OP_STAR. */ - - if (repeat_max < 0) - { - *code++ = c; - *code++ = OP_STAR + repeat_type; - } - - /* Else insert an UPTO if the max is greater than the min. */ - - else if (repeat_max != repeat_min) - { - *code++ = c; - repeat_max -= repeat_min; - *code++ = OP_UPTO + repeat_type; - *code++ = repeat_max >> 8; - *code++ = (repeat_max & 255); - } - } - - /* The character or character type itself comes last in all cases. */ - - *code++ = c; - } - - /* If previous was a character class or a back reference, we put the repeat - stuff after it. */ - - else if (*previous == OP_CLASS || *previous == OP_NEGCLASS || - *previous==OP_CLASS_L || *previous == OP_REF) - { - if (repeat_min == 0 && repeat_max == -1) - *code++ = OP_CRSTAR + repeat_type; - else if (repeat_min == 1 && repeat_max == -1) - *code++ = OP_CRPLUS + repeat_type; - else if (repeat_min == 0 && repeat_max == 1) - *code++ = OP_CRQUERY + repeat_type; - else - { - *code++ = OP_CRRANGE + repeat_type; - *code++ = repeat_min >> 8; - *code++ = repeat_min & 255; - if (repeat_max == -1) repeat_max = 0; /* 2-byte encoding for max */ - *code++ = repeat_max >> 8; - *code++ = repeat_max & 255; - } - } - - /* If previous was a bracket group, we may have to replicate it in certain - cases. If the maximum repeat count is unlimited, check that the bracket - group cannot match the empty string, and diagnose an error if it can. */ - - else if ((int)*previous >= OP_BRA) - { - int i; - int len = code - previous; - - if (repeat_max == -1 && could_be_empty(previous)) - { - *errorptr = ERR10; - goto FAILED; - } - - /* If the minimum is greater than zero, and the maximum is unlimited or - equal to the minimum, the first copy remains where it is, and is - replicated up to the minimum number of times. This case includes the + - repeat, but of course no replication is needed in that case. */ - - if (repeat_min > 0 && (repeat_max == -1 || repeat_max == repeat_min)) - { - for (i = 1; i < repeat_min; i++) - { - memcpy(code, previous, len); - code += len; - } - } - - /* If the minimum is zero, stick BRAZERO in front of the first copy. - Then, if there is a fixed upper limit, replicated up to that many times, - sticking BRAZERO in front of all the optional ones. */ - - else - { - if (repeat_min == 0) - { - memmove(previous+1, previous, len); - code++; - *previous++ = OP_BRAZERO + repeat_type; - } - - for (i = 1; i < repeat_min; i++) - { - memcpy(code, previous, len); - code += len; - } - - for (i = (repeat_min > 0)? repeat_min : 1; i < repeat_max; i++) - { - *code++ = OP_BRAZERO + repeat_type; - memcpy(code, previous, len); - code += len; - } - } - - /* If the maximum is unlimited, set a repeater in the final copy. */ - - if (repeat_max == -1) code[-3] = OP_KETRMAX + repeat_type; - } - - /* Else there's some kind of shambles */ - - else - { - *errorptr = ERR11; - goto FAILED; - } - - /* In all case we no longer have a previous item. */ - - previous = NULL; - break; - - - /* Start of nested bracket sub-expression, or comment or lookahead. - First deal with special things that can come after a bracket; all are - introduced by ?, and the appearance of any of them means that this is not a - referencing group. They were checked for validity in the first pass over - the string, so we don't have to check for syntax errors here. */ - - case '(': - previous = code; /* Only real brackets can be repeated */ - if (*(++ptr) == '?') - { - bravalue = OP_BRA; - - switch (*(++ptr)) - { - case '#': - case 'i': - case 'L': - case 'm': - case 's': - case 'x': - ptr++; - while (*ptr != ')') ptr++; - previous = NULL; - continue; - - case ':': /* Non-extracting bracket */ - ptr++; - break; - - case '=': /* Assertions can't be repeated */ - bravalue = OP_ASSERT; - ptr++; - previous = NULL; - break; - - case '!': - bravalue = OP_ASSERT_NOT; - ptr++; - previous = NULL; - break; - - case ('P'): - ptr++; - if (*ptr=='<') - { - /* (?P...) */ - int idlen; - PyObject *string, *intobj; - - ptr++; - idlen = get_group_id(ptr, '>', errorptr); - if (*errorptr) { - goto FAILED; - } - string = PyString_FromStringAndSize((char*)ptr, idlen); - intobj = PyInt_FromLong( brackets[0] + 1 ); - if (intobj == NULL || string == NULL) - { - Py_XDECREF(string); - Py_XDECREF(intobj); - *errorptr = "exception raised"; - goto FAILED; - } - PyDict_SetItem(dictionary, string, intobj); - Py_DECREF(string); Py_DECREF(intobj); /* XXX DECREF commented out! */ - ptr += idlen+1; /* Point to rest of expression */ - goto do_grouping_bracket; - } - if (*ptr=='=') - { - /* (?P=groupname) */ - int idlen, refnum; - PyObject *string, *intobj; - - ptr++; - idlen = get_group_id(ptr, ')', errorptr); - if (*errorptr) { - goto FAILED; - } - string = PyString_FromStringAndSize((char *)ptr, idlen); - if (string==NULL) { - *errorptr = "exception raised"; - goto FAILED; - } - intobj = PyDict_GetItem(dictionary, string); - if (intobj==NULL) { - Py_DECREF(string); - *errorptr = "?P= group identifier isn't defined"; - goto FAILED; - } - - refnum = PyInt_AsLong(intobj); - Py_DECREF(string); - /* The caller doesn't own the reference to the value - returned from PyDict_GetItem, so intobj is not - DECREF'ed. */ - - *code++ = OP_REF; - *code++ = refnum; - /* The continue will cause the top-level for() loop to - be resumed, so ptr will be immediately incremented. - Therefore, the following line adds just idlen, not - idlen+1 */ - ptr += idlen; - continue; - } - /* The character after ?P is neither < nor =, so - report an error. Add more Python-extensions here. */ - *errorptr="unknown after (?P"; - goto FAILED; - - case '>': /* "Match once" brackets */ - if ((options & PCRE_EXTRA) != 0) /* Not yet standard */ - { - bravalue = OP_ONCE; - ptr++; - previous = NULL; - break; - } - /* Else fall through */ - - default: - *errorptr = ERR12; - goto FAILED; - } - } - - /* Else we have a referencing group */ - - else - { - do_grouping_bracket: - if (++(*brackets) > EXTRACT_MAX) - { - *errorptr = ERR13; - goto FAILED; - } - bravalue = OP_BRA + *brackets; - } - - /* Process nested bracketed re; at end pointer is on the bracket. We copy - code into a non-register variable in order to be able to pass its address - because some compilers complain otherwise. */ - - *code = bravalue; - { - uschar *mcode = code; - if (!compile_regex(options, brackets, &mcode, &ptr, errorptr, dictionary)) - goto FAILED; - code = mcode; - } - - if (*ptr != ')') - { - *errorptr = ERR14; - goto FAILED; - } - break; - - /* Check \ for being a real metacharacter; if not, fall through and handle - it as a data character at the start of a string. Escape items are checked - for validity in the pre-compiling pass. */ - - case '\\': - oldptr = ptr; - c = check_escape(&ptr, errorptr, *brackets, options, FALSE); - - /* Handle metacharacters introduced by \. For ones like \d, the ESC_ values - are arranged to be the negation of the corresponding OP_values. For the - back references, the values are ESC_REF plus the reference number. Only - back references and those types that consume a character may be repeated. - We can test for values between ESC_b and ESC_Z for the latter; this may - have to change if any new ones are ever created. */ - - if (c < 0) - { - if (-c >= ESC_REF) - { - int refnum = -c - ESC_REF; - if (*brackets < refnum) - { - *errorptr = ERR15; - goto FAILED; - } - previous = code; - *code++ = OP_REF; - *code++ = refnum; - } - else - { - previous = (-c > ESC_b && -c < ESC_X)? code : NULL; - if ( (options & PCRE_LOCALE) != 0) - { - switch (c) - { - case (-ESC_b): c = -OP_WORD_BOUNDARY_L; break; - case (-ESC_B): c = -OP_NOT_WORD_BOUNDARY_L; break; - case (-ESC_w): c = -OP_WORDCHAR_L; break; - case (-ESC_W): c = -OP_NOT_WORDCHAR_L; break; - } - } - *code++ = -c; - } - continue; - } - - /* Data character: Reset and fall through */ - - ptr = oldptr; - c = '\\'; - - /* Handle a run of data characters until a metacharacter is encountered. - The first character is guaranteed not to be whitespace or # when the - extended flag is set. */ - - NORMAL_CHAR: - default: - previous = code; - *code = OP_CHARS; - code += 2; - length = 0; - - do - { - if ((options & PCRE_EXTENDED) != 0) - { - if ((pcre_ctypes[c] & ctype_space) != 0) continue; - if (c == '#') - { - while ((c = *(++ptr)) != 0 && c != '\n'); - if (c == 0) break; - continue; - } - } - - /* Backslash may introduce a data char or a metacharacter. Escaped items - are checked for validity in the pre-compiling pass. Stop the string - before a metaitem. */ - - if (c == '\\') - { - oldptr = ptr; - c = check_escape(&ptr, errorptr, *brackets, options, FALSE); - if (c < 0) { ptr = oldptr; break; } - } - - /* Ordinary character or single-char escape */ - - *code++ = c; - length++; - } - - /* This "while" is the end of the "do" above. */ - - while (length < 255 && (pcre_ctypes[c = *(++ptr)] & ctype_meta) == 0); - - /* Compute the length and set it in the data vector, and advance to - the next state. */ - - previous[1] = length; - if (length < 255) ptr--; - break; - } - } /* end of big loop */ - -/* Control never reaches here by falling through, only by a goto for all the -error states. Pass back the position in the pattern so that it can be displayed -to the user for diagnosing the error. */ - -FAILED: -*ptrptr = ptr; -return FALSE; -} - - - - -/************************************************* -* Compile sequence of alternatives * -*************************************************/ - -/* On entry, ptr is pointing past the bracket character, but on return -it points to the closing bracket, or vertical bar, or end of string. -The code variable is pointing at the byte into which the BRA operator has been -stored. - -Argument: - options the option bits - brackets -> int containing the number of extracting brackets used - codeptr -> the address of the current code pointer - ptrptr -> the address of the current pattern pointer - errorptr -> pointer to error message - -Returns: TRUE on success -*/ - -static BOOL -compile_regex(int options, int *brackets, uschar **codeptr, - const uschar **ptrptr, const char **errorptr, PyObject *dictionary) -{ -const uschar *ptr = *ptrptr; -uschar *code = *codeptr; -uschar *start_bracket = code; - -for (;;) - { - int length; - uschar *last_branch = code; - - code += 3; - if (!compile_branch(options, brackets, &code, &ptr, errorptr, dictionary)) - { - *ptrptr = ptr; - return FALSE; - } - - /* Fill in the length of the last branch */ - - length = code - last_branch; - last_branch[1] = length >> 8; - last_branch[2] = length & 255; - - /* Reached end of expression, either ')' or end of pattern. Insert a - terminating ket and the length of the whole bracketed item, and return, - leaving the pointer at the terminating char. */ - - if (*ptr != '|') - { - length = code - start_bracket; - *code++ = OP_KET; - *code++ = length >> 8; - *code++ = length & 255; - *codeptr = code; - *ptrptr = ptr; - return TRUE; - } - - /* Another branch follows; insert an "or" node and advance the pointer. */ - - *code = OP_ALT; - ptr++; - } -/* Control never reaches here */ -} - - - -/************************************************* -* Check for anchored expression * -*************************************************/ - -/* Try to find out if this is an anchored regular expression. Consider each -alternative branch. If they all start with OP_SOD or OP_CIRC, or with a bracket -all of whose alternatives start with OP_SOD or OP_CIRC (recurse ad lib), then -it's anchored. However, if this is a multiline pattern, then only OP_SOD -counts, since OP_CIRC can match in the middle. - -A branch is also implicitly anchored if it starts with .* because that will try -the rest of the pattern at all possible matching points, so there is no point -trying them again. - -Argument: points to start of expression (the bracket) -Returns: TRUE or FALSE -*/ - -static BOOL -is_anchored(register const uschar *code, BOOL multiline) -{ -do { - int op = (int)code[3]; - if (op >= OP_BRA || op == OP_ASSERT || op == OP_ONCE) - { if (!is_anchored(code+3, multiline)) return FALSE; } - else if (op == OP_TYPESTAR || op == OP_TYPEMINSTAR) - { if (code[4] != OP_ANY) return FALSE; } - else if (op != OP_SOD && (multiline || op != OP_CIRC)) return FALSE; - code += (code[1] << 8) + code[2]; - } -while (*code == OP_ALT); -return TRUE; -} - - - -/************************************************* -* Check for start with \n line expression * -*************************************************/ - -/* This is called for multiline expressions to try to find out if every branch -starts with ^ so that "first char" processing can be done to speed things up. - -Argument: points to start of expression (the bracket) -Returns: TRUE or FALSE -*/ - -static BOOL -is_startline(const uschar *code) -{ -do { - if ((int)code[3] >= OP_BRA || code[3] == OP_ASSERT) - { if (!is_startline(code+3)) return FALSE; } - else if (code[3] != OP_CIRC) return FALSE; - code += (code[1] << 8) + code[2]; - } -while (*code == OP_ALT); -return TRUE; -} - - - -/************************************************* -* Check for fixed first char * -*************************************************/ - -/* Try to find out if there is a fixed first character. This is called for -unanchored expressions, as it speeds up their processing quite considerably. -Consider each alternative branch. If they all start with the same char, or with -a bracket all of whose alternatives start with the same char (recurse ad lib), -then we return that char, otherwise -1. - -Argument: points to start of expression (the bracket) -Returns: -1 or the fixed first char -*/ - -static int -find_firstchar(uschar *code) -{ -register int c = -1; -do - { - register int charoffset = 4; - - if ((int)code[3] >= OP_BRA || code[3] == OP_ASSERT) - { - register int d; - if ((d = find_firstchar(code+3)) < 0) return -1; - if (c < 0) c = d; else if (c != d) return -1; - } - - else switch(code[3]) - { - default: - return -1; - - case OP_EXACT: /* Fall through */ - charoffset++; - - case OP_CHARS: /* Fall through */ - charoffset++; - - case OP_PLUS: - case OP_MINPLUS: - if (c < 0) c = code[charoffset]; else if (c != code[charoffset]) return -1; - break; - } - code += (code[1] << 8) + code[2]; - } -while (*code == OP_ALT); -return c; -} - - - -/************************************************* -* Compile a Regular Expression * -*************************************************/ - -/* This function takes a string and returns a pointer to a block of store -holding a compiled version of the expression. - -Arguments: - pattern the regular expression - options various option bits - errorptr pointer to pointer to error text - erroroffset ptr offset in pattern where error was detected - -Returns: pointer to compiled data block, or NULL on error, - with errorptr and erroroffset set -*/ - -pcre * -pcre_compile(const char *pattern, int options, const char **errorptr, - int *erroroffset, PyObject *dictionary) -{ -real_pcre *re; -int spaces = 0; -int length = 3; /* For initial BRA plus length */ -int runlength; -int c, size; -int bracount = 0; -int brastack[200]; -int top_backref = 0; -unsigned int brastackptr = 0; -uschar *code; -const uschar *ptr; - -#ifdef DEBUG -uschar *code_base, *code_end; -#endif - -/* We can't pass back an error message if errorptr is NULL; I guess the best we -can do is just return NULL. */ - -if (errorptr == NULL) return NULL; -*errorptr = NULL; - -/* However, we can give a message for this error */ - -if (erroroffset == NULL) - { - *errorptr = ERR16; - return NULL; - } -*erroroffset = 0; - -if ((options & ~PUBLIC_OPTIONS) != 0) - { - *errorptr = ERR17; - return NULL; - } - -DPRINTF(("------------------------------------------------------------------\n")); -DPRINTF(("%s\n", pattern)); - -/* The first thing to do is to make a pass over the pattern to compute the -amount of store required to hold the compiled code. This does not have to be -perfect as long as errors are overestimates. At the same time we can detect any -internal flag settings. Make an attempt to correct for any counted white space -if an "extended" flag setting appears late in the pattern. We can't be so -clever for #-comments. */ - -ptr = (const uschar *)(pattern - 1); -while ((c = *(++ptr)) != 0) - { - int min, max; - int class_charcount; - - if ((pcre_ctypes[c] & ctype_space) != 0) - { - if ((options & PCRE_EXTENDED) != 0) continue; - spaces++; - } - - if (c == '#' && (options & PCRE_EXTENDED) != 0) - { - while ((c = *(++ptr)) != 0 && c != '\n'); - continue; - } - - switch(c) - { - /* A backslashed item may be an escaped "normal" character or a - character type. For a "normal" character, put the pointers and - character back so that tests for whitespace etc. in the input - are done correctly. */ - - case '\\': - { - const uschar *save_ptr = ptr; - c = check_escape(&ptr, errorptr, bracount, options, FALSE); - if (*errorptr != NULL) goto PCRE_ERROR_RETURN; - if (c >= 0) - { - ptr = save_ptr; - c = '\\'; - goto NORMAL_CHAR; - } - } - length++; - - /* A back reference needs an additional char, plus either one or 5 - bytes for a repeat. We also need to keep the value of the highest - back reference. */ - - if (c <= -ESC_REF) - { - int refnum = -c - ESC_REF; - if (refnum > top_backref) top_backref = refnum; - length++; /* For single back reference */ - if (ptr[1] == '{' && is_counted_repeat(ptr+2)) - { - ptr = read_repeat_counts(ptr+2, &min, &max, errorptr); - if (*errorptr != NULL) goto PCRE_ERROR_RETURN; - if ((min == 0 && (max == 1 || max == -1)) || - (min == 1 && max == -1)) - length++; - else length += 5; - if (ptr[1] == '?') ptr++; - } - } - continue; - - case '^': - case '.': - case '$': - case '*': /* These repeats won't be after brackets; */ - case '+': /* those are handled separately */ - case '?': - length++; - continue; - - /* This covers the cases of repeats after a single char, metachar, class, - or back reference. */ - - case '{': - if (!is_counted_repeat(ptr+1)) goto NORMAL_CHAR; - ptr = read_repeat_counts(ptr+1, &min, &max, errorptr); - if (*errorptr != NULL) goto PCRE_ERROR_RETURN; - if ((min == 0 && (max == 1 || max == -1)) || - (min == 1 && max == -1)) - length++; - else - { - length--; /* Uncount the original char or metachar */ - if (min == 1) length++; else if (min > 0) length += 4; - if (max > 0) length += 4; else length += 2; - } - if (ptr[1] == '?') ptr++; - continue; - - /* An alternation contains an offset to the next branch or ket. */ - case '|': - length += 3; - continue; - - /* A character class uses 33 characters. Don't worry about character types - that aren't allowed in classes - they'll get picked up during the compile. - A character class that contains only one character uses 2 or 3 bytes, - depending on whether it is negated or not. Notice this where we can. */ - - case '[': - class_charcount = 0; - if (*(++ptr) == '^') ptr++; - do - { - if (*ptr == '\\') - { - int ch = check_escape(&ptr, errorptr, bracount, options, TRUE); - if (*errorptr != NULL) goto PCRE_ERROR_RETURN; - if (-ch == ESC_b) class_charcount++; else class_charcount = 10; - } - else class_charcount++; - ptr++; - } - while (*ptr != 0 && *ptr != ']'); - - /* Repeats for negated single chars are handled by the general code */ - - if (class_charcount == 1) length += 3; else - { - length += 33; - if (options & PCRE_LOCALE) length++; /* Add a byte for the localization flag */ - - /* A repeat needs either 1 or 5 bytes. */ - - if (*ptr != 0 && ptr[1] == '{' && is_counted_repeat(ptr+2)) - { - ptr = read_repeat_counts(ptr+2, &min, &max, errorptr); - if (*errorptr != NULL) goto PCRE_ERROR_RETURN; - if ((min == 0 && (max == 1 || max == -1)) || - (min == 1 && max == -1)) - length++; - else length += 5; - if (ptr[1] == '?') ptr++; - } - } - continue; - - /* Brackets may be genuine groups or special things */ - - case '(': - - /* Handle special forms of bracket, which all start (? */ - - if (ptr[1] == '?') switch (c = ptr[2]) - { - /* Skip over comments entirely */ - case '#': - ptr += 3; - while (*ptr != 0 && *ptr != ')') ptr++; - if (*ptr == 0) - { - *errorptr = ERR18; - goto PCRE_ERROR_RETURN; - } - continue; - - /* Non-referencing groups and lookaheads just move the pointer on, and - then behave like a non-special bracket, except that they don't increment - the count of extracting brackets. */ - - case ':': - case '=': - case '!': - ptr += 2; - break; - - case ('P'): - { - int idlen; - switch (*ptr++) { - case ('<'): - idlen = get_group_id(ptr++, '>', errorptr); - if (*errorptr) goto PCRE_ERROR_RETURN; - ptr += idlen+1; - break; - case ('='): - idlen = get_group_id(ptr++, ')', errorptr); - if (*errorptr) goto PCRE_ERROR_RETURN; - ptr += idlen+1; - length++; - break; - } - } - break; - - /* Ditto for the "once only" bracket, allowed only if the extra bit - is set. */ - - case '>': - if ((options & PCRE_EXTRA) != 0) - { - ptr += 2; - break; - } - /* Else fall through */ - - /* Else loop setting valid options until ) is met. Anything else is an - error. */ - - default: - ptr += 2; - for (;; ptr++) - { - if ((c = *ptr) == 'i') - { - options |= PCRE_CASELESS; - continue; - } - else if ((c = *ptr) == 'L') - { - options |= PCRE_LOCALE; - continue; - } - else if ((c = *ptr) == 'm') - { - options |= PCRE_MULTILINE; - continue; - } - else if (c == 's') - { - options |= PCRE_DOTALL; - continue; - } - else if (c == 'x') - { - options |= PCRE_EXTENDED; - length -= spaces; /* Already counted spaces */ - continue; - } - else if (c == ')') break; - - *errorptr = ERR12; - goto PCRE_ERROR_RETURN; - } - continue; /* End of this bracket handling */ - } - - /* Extracting brackets must be counted so we can process escapes in a - Perlish way. */ - - else bracount++; - - /* Non-special forms of bracket. Save length for computing whole length - at end if there's a repeat that requires duplication of the group. */ - - if (brastackptr >= sizeof(brastack)/sizeof(int)) - { - *errorptr = ERR19; - goto PCRE_ERROR_RETURN; - } - - brastack[brastackptr++] = length; - length += 3; - continue; - - /* Handle ket. Look for subsequent max/min; for certain sets of values we - have to replicate this bracket up to that many times. If brastackptr is - 0 this is an unmatched bracket which will generate an error, but take care - not to try to access brastack[-1]. */ - - case ')': - length += 3; - { - int minval = 1; - int maxval = 1; - int duplength = (brastackptr > 0)? length - brastack[--brastackptr] : 0; - - /* Leave ptr at the final char; for read_repeat_counts this happens - automatically; for the others we need an increment. */ - - if ((c = ptr[1]) == '{' && is_counted_repeat(ptr+2)) - { - ptr = read_repeat_counts(ptr+2, &minval, &maxval, errorptr); - if (*errorptr != NULL) goto PCRE_ERROR_RETURN; - } - else if (c == '*') { minval = 0; maxval = -1; ptr++; } - else if (c == '+') { maxval = -1; ptr++; } - else if (c == '?') { minval = 0; ptr++; } - - /* If there is a minimum > 1 we have to replicate up to minval-1 times; - if there is a limited maximum we have to replicate up to maxval-1 times - and allow for a BRAZERO item before each optional copy, as we also have - to do before the first copy if the minimum is zero. */ - - if (minval == 0) length++; - else if (minval > 1) length += (minval - 1) * duplength; - if (maxval > minval) length += (maxval - minval) * (duplength + 1); - } - continue; - - /* Non-special character. For a run of such characters the length required - is the number of characters + 2, except that the maximum run length is 255. - We won't get a skipped space or a non-data escape or the start of a # - comment as the first character, so the length can't be zero. */ - - NORMAL_CHAR: - default: - length += 2; - runlength = 0; - do - { - if ((pcre_ctypes[c] & ctype_space) != 0) - { - if ((options & PCRE_EXTENDED) != 0) continue; - spaces++; - } - - if (c == '#' && (options & PCRE_EXTENDED) != 0) - { - while ((c = *(++ptr)) != 0 && c != '\n'); - continue; - } - - /* Backslash may introduce a data char or a metacharacter; stop the - string before the latter. */ - - if (c == '\\') - { - const uschar *saveptr = ptr; - c = check_escape(&ptr, errorptr, bracount, options, FALSE); - if (*errorptr != NULL) goto PCRE_ERROR_RETURN; - if (c < 0) { ptr = saveptr; break; } - } - - /* Ordinary character or single-char escape */ - - runlength++; - } - - /* This "while" is the end of the "do" above. */ - - while (runlength < 255 && (pcre_ctypes[c = *(++ptr)] & ctype_meta) == 0); - - ptr--; - length += runlength; - continue; - } - } - -length += 4; /* For final KET and END */ - -if (length > 65539) - { - *errorptr = ERR20; - return NULL; - } - -/* Compute the size of data block needed and get it, either from malloc or -externally provided function. We specify "code[0]" in the offsetof() expression -rather than just "code", because it has been reported that one broken compiler -fails on "code" because it is also an independent variable. It should make no -difference to the value of the offsetof(). */ - -size = length + offsetof(real_pcre, code[0]); -re = (real_pcre *)(pcre_malloc)(size+50); - -if (re == NULL) - { - *errorptr = ERR21; - return NULL; - } - -/* Put in the magic number and the options. */ - -re->magic_number = MAGIC_NUMBER; -re->options = options; - -/* Set up a starting, non-extracting bracket, then compile the expression. On -error, *errorptr will be set non-NULL, so we don't need to look at the result -of the function here. */ - -ptr = (const uschar *)pattern; -code = re->code; -*code = OP_BRA; -bracount = 0; -(void)compile_regex(options, &bracount, &code, &ptr, errorptr, dictionary); -re->top_bracket = bracount; -re->top_backref = top_backref; - -/* If not reached end of pattern on success, there's an excess bracket. */ - -if (*errorptr == NULL && *ptr != 0) *errorptr = ERR22; - -/* Fill in the terminating state and check for disastrous overflow, but -if debugging, leave the test till after things are printed out. */ - -*code++ = OP_END; - - -#ifndef DEBUG -if (code - re->code > length) *errorptr = ERR23; -#endif - -/* Failed to compile */ - -if (*errorptr != NULL) - { - (pcre_free)(re); - PCRE_ERROR_RETURN: - *erroroffset = ptr - (const uschar *)pattern; - return NULL; - } - -/* If the anchored option was not passed, set flag if we can determine that it -is anchored by virtue of ^ characters or \A or anything else. Otherwise, see if -we can determine what the first character has to be, because that speeds up -unanchored matches no end. In the case of multiline matches, an alternative is -to set the PCRE_STARTLINE flag if all branches start with ^. */ - -if ((options & PCRE_ANCHORED) == 0) - { - if (is_anchored(re->code, (options & PCRE_MULTILINE) != 0)) - re->options |= PCRE_ANCHORED; - else - { - int ch = find_firstchar(re->code); - if (ch >= 0) - { - re->first_char = ch; - re->options |= PCRE_FIRSTSET; - } - else if (is_startline(re->code)) - re->options |= PCRE_STARTLINE; - } - } - -/* Print out the compiled data for debugging */ - -#ifdef DEBUG - -printf("Length = %d top_bracket = %d top_backref=%d\n", - length, re->top_bracket, re->top_backref); - -if (re->options != 0) - { - printf("%s%s%s%s%s%s%s%s\n", - ((re->options & PCRE_ANCHORED) != 0)? "anchored " : "", - ((re->options & PCRE_CASELESS) != 0)? "caseless " : "", - ((re->options & PCRE_EXTENDED) != 0)? "extended " : "", - ((re->options & PCRE_MULTILINE) != 0)? "multiline " : "", - ((re->options & PCRE_DOTALL) != 0)? "dotall " : "", - ((re->options & PCRE_DOLLAR_ENDONLY) != 0)? "endonly " : "", - ((re->options & PCRE_EXTRA) != 0)? "extra " : "", - ((re->options & PCRE_UNGREEDY) != 0)? "ungreedy " : ""); - } - -if ((re->options & PCRE_FIRSTSET) != 0) - { - if (isprint(re->first_char)) printf("First char = %c\n", re->first_char); - else printf("First char = \\x%02x\n", re->first_char); - } - -code_end = code; -code_base = code = re->code; - -while (code < code_end) - { - int charlength; - - printf("%3d ", code - code_base); - - if (*code >= OP_BRA) - { - printf("%3d Bra %d", (code[1] << 8) + code[2], *code - OP_BRA); - code += 2; - } - - else switch(*code) - { - case OP_CHARS: - charlength = *(++code); - printf("%3d ", charlength); - while (charlength-- > 0) - if (isprint(c = *(++code))) printf("%c", c); else printf("\\x%02x", c); - break; - - case OP_KETRMAX: - case OP_KETRMIN: - case OP_ALT: - case OP_KET: - case OP_ASSERT: - case OP_ASSERT_NOT: - case OP_ONCE: - printf("%3d %s", (code[1] << 8) + code[2], OP_names[*code]); - code += 2; - break; - - case OP_STAR: - case OP_MINSTAR: - case OP_PLUS: - case OP_MINPLUS: - case OP_QUERY: - case OP_MINQUERY: - case OP_TYPESTAR: - case OP_TYPEMINSTAR: - case OP_TYPEPLUS: - case OP_TYPEMINPLUS: - case OP_TYPEQUERY: - case OP_TYPEMINQUERY: - if (*code >= OP_TYPESTAR) - printf(" %s", OP_names[code[1]]); - else if (isprint(c = code[1])) printf(" %c", c); - else printf(" \\x%02x", c); - printf("%s", OP_names[*code++]); - break; - - case OP_EXACT: - case OP_UPTO: - case OP_MINUPTO: - if (isprint(c = code[3])) printf(" %c{", c); - else printf(" \\x%02x{", c); - if (*code != OP_EXACT) printf("0,"); - printf("%d}", (code[1] << 8) + code[2]); - if (*code == OP_MINUPTO) printf("?"); - code += 3; - break; - - case OP_TYPEEXACT: - case OP_TYPEUPTO: - case OP_TYPEMINUPTO: - printf(" %s{", OP_names[code[3]]); - if (*code != OP_TYPEEXACT) printf(","); - printf("%d}", (code[1] << 8) + code[2]); - if (*code == OP_TYPEMINUPTO) printf("?"); - code += 3; - break; - - case OP_NOT: - if (isprint(c = *(++code))) printf(" [^%c]", c); - else printf(" [^\\x%02x]", c); - break; - - case OP_NOTSTAR: - case OP_NOTMINSTAR: - case OP_NOTPLUS: - case OP_NOTMINPLUS: - case OP_NOTQUERY: - case OP_NOTMINQUERY: - if (isprint(c = code[1])) printf(" [^%c]", c); - else printf(" [^\\x%02x]", c); - printf("%s", OP_names[*code++]); - break; - - case OP_NOTEXACT: - case OP_NOTUPTO: - case OP_NOTMINUPTO: - if (isprint(c = code[3])) printf(" [^%c]{", c); - else printf(" [^\\x%02x]{", c); - if (*code != OP_NOTEXACT) printf(","); - printf("%d}", (code[1] << 8) + code[2]); - if (*code == OP_NOTMINUPTO) printf("?"); - code += 3; - break; - - case OP_REF: - printf(" \\%d", *(++code)); - code ++; - goto CLASS_REF_REPEAT; - - case OP_CLASS: - case OP_NEGCLASS: - case OP_CLASS_L: - { - int i, min, max; - - if (*code==OP_CLASS_L) - { - code++; - printf("Locflag = %i ", *code++); - printf(" ["); - } - else - { - if (*code++ == OP_CLASS) printf(" ["); - else printf(" ^["); - } - - - for (i = 0; i < 256; i++) - { - if ((code[i/8] & (1 << (i&7))) != 0) - { - int j; - for (j = i+1; j < 256; j++) - if ((code[j/8] & (1 << (j&7))) == 0) break; - if (i == '-' || i == ']') printf("\\"); - if (isprint(i)) printf("%c", i); else printf("\\x%02x", i); - if (--j > i) - { - printf("-"); - if (j == '-' || j == ']') printf("\\"); - if (isprint(j)) printf("%c", j); else printf("\\x%02x", j); - } - i = j; - } - } - printf("]"); - code += 32; - /* code ++;*/ - - CLASS_REF_REPEAT: - - switch(*code) - { - case OP_CRSTAR: - case OP_CRMINSTAR: - case OP_CRPLUS: - case OP_CRMINPLUS: - case OP_CRQUERY: - case OP_CRMINQUERY: - printf("%s", OP_names[*code]); - break; - - case OP_CRRANGE: - case OP_CRMINRANGE: - min = (code[1] << 8) + code[2]; - max = (code[3] << 8) + code[4]; - if (max == 0) printf("{%d,}", min); - else printf("{%d,%d}", min, max); - if (*code == OP_CRMINRANGE) printf("?"); - code += 4; - break; - - default: - code--; - } - } - break; - - /* Anything else is just a one-node item */ - - default: - printf(" %s", OP_names[*code]); - break; - } - - code++; - printf("\n"); - } -printf("------------------------------------------------------------------\n"); - -/* This check is done here in the debugging case so that the code that -was compiled can be seen. */ - -if (code - re->code > length) - { - printf("length=%i, code length=%i\n", length, code-re->code); - *errorptr = ERR23; - (pcre_free)(re); - *erroroffset = ptr - (uschar *)pattern; - return NULL; - } -#endif - -return (pcre *)re; -} - - - -/************************************************* -* Match a character type * -*************************************************/ - -/* Not used in all the places it might be as it's sometimes faster -to put the code inline. - -Arguments: - type the character type - c the character - dotall the dotall flag - -Returns: TRUE if character is of the type -*/ - -static BOOL -match_type(int type, int c, BOOL dotall) -{ - -#ifdef DEBUG -if (isprint(c)) printf("matching subject %c against ", c); - else printf("matching subject \\x%02x against ", c); -printf("%s\n", OP_names[type]); -#endif - -switch(type) - { - case OP_ANY: return dotall || c != '\n'; - case OP_NOT_DIGIT: return (pcre_ctypes[c] & ctype_digit) == 0; - case OP_DIGIT: return (pcre_ctypes[c] & ctype_digit) != 0; - case OP_NOT_WHITESPACE: return (pcre_ctypes[c] & ctype_space) == 0; - case OP_WHITESPACE: return (pcre_ctypes[c] & ctype_space) != 0; - case OP_NOT_WORDCHAR: return (pcre_ctypes[c] & ctype_word) == 0; - case OP_WORDCHAR: return (pcre_ctypes[c] & ctype_word) != 0; - case OP_NOT_WORDCHAR_L: return (c!='_' && !isalnum(c)); - case OP_WORDCHAR_L: return (c=='_' || isalnum(c)); - } -return FALSE; -} - - - -/************************************************* -* Match a back-reference * -*************************************************/ - -/* If a back reference hasn't been set, the match fails. - -Arguments: - number reference number - eptr points into the subject - length length to be matched - md points to match data block - -Returns: TRUE if matched -*/ - -static BOOL -match_ref(int number, register const uschar *eptr, int length, match_data *md) -{ -const uschar *p = md->start_subject + md->offset_vector[number]; - -#ifdef DEBUG -if (eptr >= md->end_subject) - printf("matching subject "); -else - { - printf("matching subject "); - pchars(eptr, length, TRUE, md); - } -printf(" against backref "); -pchars(p, length, FALSE, md); -printf("\n"); -#endif - -/* Always fail if not enough characters left */ - -if (length > md->end_subject - p) return FALSE; - -/* Separate the caseless case for speed */ - -if (md->caseless) - { while (length-- > 0) if (pcre_lcc[*p++] != pcre_lcc[*eptr++]) return FALSE; } -else - { while (length-- > 0) if (*p++ != *eptr++) return FALSE; } - -return TRUE; -} - -static int free_stack(match_data *md) -{ -/* Free any stack space that was allocated by the call to match(). */ -if (md->off_num) PyMem_DEL(md->off_num); -if (md->offset_top) PyMem_DEL(md->offset_top); -if (md->r1) PyMem_DEL(md->r1); -if (md->r2) PyMem_DEL(md->r2); -if (md->eptr) PyMem_DEL((char *)md->eptr); -if (md->ecode) PyMem_DEL((char *)md->ecode); -return 0; -} - -static int grow_stack(match_data *md) -{ - if (md->length != 0) - { - md->length = md->length + md->length/2; - } - else - { - int string_len = md->end_subject - md->start_subject + 1; - if (string_len < 80) {md->length = string_len; } - else {md->length = 80;} - } - PyMem_RESIZE(md->offset_top, int, md->length); - /* Can't realloc a pointer-to-const; cast const away. */ - md->eptr = (const uschar **)PyMem_Realloc((void *)md->eptr, - sizeof(uschar *) * md->length); - md->ecode = (const uschar **)PyMem_Realloc((void *)md->ecode, - sizeof(uschar *) * md->length); - PyMem_RESIZE(md->off_num, int, md->length); - PyMem_RESIZE(md->r1, int, md->length); - PyMem_RESIZE(md->r2, int, md->length); - if (md->offset_top == NULL || md->eptr == NULL || md->ecode == NULL || - md->off_num == NULL || md->r1 == NULL || md->r2 == NULL) - { - PyErr_NoMemory(); - longjmp(md->error_env, 1); - } - return 0; -} - - -/************************************************* -* Match from current position * -*************************************************/ - -/* On entry ecode points to the first opcode, and eptr to the first character. - -Arguments: - eptr pointer in subject - ecode position in code - offset_top current top pointer - md pointer to "static" info for the match - -Returns: TRUE if matched -*/ - -static BOOL -match(register const uschar *eptr, register const uschar *ecode, int offset_top, - match_data *md) -{ - int save_stack_position = md->point; -match_loop: - -#define SUCCEED goto succeed -#define FAIL goto fail - -for (;;) - { - int min, max, ctype; - register int i; - register int c; - BOOL minimize = FALSE; - - /* Opening bracket. Check the alternative branches in turn, failing if none - match. We have to set the start offset if required and there is space - in the offset vector so that it is available for subsequent back references - if the bracket matches. However, if the bracket fails, we must put back the - previous value of both offsets in case they were set by a previous copy of - the same bracket. Don't worry about setting the flag for the error case here; - that is handled in the code for KET. */ - - if ((int)*ecode >= OP_BRA) - { - int number = (*ecode - OP_BRA) << 1; - int save_offset1 = 0, save_offset2 = 0; - - DPRINTF(("start bracket %d\n", number/2)); - - if (number > 0 && number < md->offset_end) - { - save_offset1 = md->offset_vector[number]; - save_offset2 = md->offset_vector[number+1]; - md->offset_vector[number] = eptr - md->start_subject; - - DPRINTF(("saving %d %d\n", save_offset1, save_offset2)); - } - - /* Recurse for all the alternatives. */ - - do - { - if (match(eptr, ecode+3, offset_top, md)) SUCCEED; - ecode += (ecode[1] << 8) + ecode[2]; - } - while (*ecode == OP_ALT); - - DPRINTF(("bracket %d failed\n", number/2)); - - if (number > 0 && number < md->offset_end) - { - md->offset_vector[number] = save_offset1; - md->offset_vector[number+1] = save_offset2; - } - - FAIL; - } - - /* Other types of node can be handled by a switch */ - - switch(*ecode) - { - case OP_END: - md->end_match_ptr = eptr; /* Record where we ended */ - md->end_offset_top = offset_top; /* and how many extracts were taken */ - SUCCEED; - - /* The equivalent of Prolog's "cut" - if the rest doesn't match, the - whole thing doesn't match, so we have to get out via a longjmp(). */ - - case OP_CUT: - if (match(eptr, ecode+1, offset_top, md)) SUCCEED; - longjmp(md->fail_env, 1); - - /* Assertion brackets. Check the alternative branches in turn - the - matching won't pass the KET for an assertion. If any one branch matches, - the assertion is true. */ - - case OP_ASSERT: - do - { - if (match(eptr, ecode+3, offset_top, md)) break; - ecode += (ecode[1] << 8) + ecode[2]; - } - while (*ecode == OP_ALT); - if (*ecode == OP_KET) FAIL; - - /* Continue from after the assertion, updating the offsets high water - mark, since extracts may have been taken during the assertion. */ - - do ecode += (ecode[1] << 8) + ecode[2]; while (*ecode == OP_ALT); - ecode += 3; - offset_top = md->end_offset_top; - continue; - - /* Negative assertion: all branches must fail to match */ - - case OP_ASSERT_NOT: - do - { - if (match(eptr, ecode+3, offset_top, md)) FAIL; - ecode += (ecode[1] << 8) + ecode[2]; - } - while (*ecode == OP_ALT); - ecode += 3; - continue; - - /* "Once" brackets are like assertion brackets except that after a match, - the point in the subject string is not moved back. Thus there can never be - a move back into the brackets. Check the alternative branches in turn - the - matching won't pass the KET for this kind of subpattern. If any one branch - matches, we carry on, leaving the subject pointer. */ - - case OP_ONCE: - do - { - if (match(eptr, ecode+3, offset_top, md)) break; - ecode += (ecode[1] << 8) + ecode[2]; - } - while (*ecode == OP_ALT); - if (*ecode == OP_KET) FAIL; - - /* Continue as from after the assertion, updating the offsets high water - mark, since extracts may have been taken. */ - - do ecode += (ecode[1] << 8) + ecode[2]; while (*ecode == OP_ALT); - ecode += 3; - offset_top = md->end_offset_top; - eptr = md->end_match_ptr; - continue; - - /* An alternation is the end of a branch; scan along to find the end of the - bracketed group and go to there. */ - - case OP_ALT: - do ecode += (ecode[1] << 8) + ecode[2]; while (*ecode == OP_ALT); - break; - - /* BRAZERO and BRAMINZERO occur just before a bracket group, indicating - that it may occur zero times. It may repeat infinitely, or not at all - - i.e. it could be ()* or ()? in the pattern. Brackets with fixed upper - repeat limits are compiled as a number of copies, with the optional ones - preceded by BRAZERO or BRAMINZERO. */ - - case OP_BRAZERO: - { - const uschar *next = ecode+1; - if (match(eptr, next, offset_top, md)) SUCCEED; - do next += (next[1] << 8) + next[2]; while (*next == OP_ALT); - ecode = next + 3; - } - break; - - case OP_BRAMINZERO: - { - const uschar *next = ecode+1; - do next += (next[1] << 8) + next[2]; while (*next == OP_ALT); - if (match(eptr, next+3, offset_top, md)) SUCCEED; - ecode++; - } - break;; - - /* End of a group, repeated or non-repeating. If we are at the end of - an assertion "group", stop matching and SUCCEED, but record the - current high water mark for use by positive assertions. */ - - case OP_KET: - case OP_KETRMIN: - case OP_KETRMAX: - { - int number; - const uschar *prev = ecode - (ecode[1] << 8) - ecode[2]; - - if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT || *prev == OP_ONCE) - { - md->end_match_ptr = eptr; /* For ONCE */ - md->end_offset_top = offset_top; - SUCCEED; - } - - /* In all other cases we have to check the group number back at the - start and if necessary complete handling an extraction by setting the - final offset and bumping the high water mark. */ - - number = (*prev - OP_BRA) << 1; - - DPRINTF(("end bracket %d\n", number/2)); - - if (number > 0) - { - if (number >= md->offset_end) md->offset_overflow = TRUE; else - { - md->offset_vector[number+1] = eptr - md->start_subject; - if (offset_top <= number) offset_top = number + 2; - } - } - - /* For a non-repeating ket, just advance to the next node and continue at - this level. */ - - if (*ecode == OP_KET) - { - ecode += 3; - break; - } - - /* The repeating kets try the rest of the pattern or restart from the - preceding bracket, in the appropriate order. */ - - if (*ecode == OP_KETRMIN) - { - const uschar *ptr; - if (match(eptr, ecode+3, offset_top, md)) goto succeed; - /* Handle alternation inside the BRA...KET; push the additional - alternatives onto the stack */ - ptr=prev; - do { - ptr += (ptr[1]<<8)+ ptr[2]; - if (*ptr==OP_ALT) - { - if (md->length == md->point) - { - grow_stack(md); - } - md->offset_top[md->point] = offset_top; - md->eptr[md->point] = eptr; - md->ecode[md->point] = ptr+3; - md->r1[md->point] = 0; - md->r2[md->point] = 0; - md->off_num[md->point] = 0; - md->point++; - } - } while (*ptr==OP_ALT); - ecode=prev+3; goto match_loop; - } - else /* OP_KETRMAX */ - { - const uschar *ptr; - /*int points_pushed=0;*/ - - /* Push one failure point, that will resume matching at the code after - the KETRMAX opcode. */ - if (md->length == md->point) - { - grow_stack(md); - } - md->offset_top[md->point] = offset_top; - md->eptr[md->point] = eptr; - md->ecode[md->point] = ecode+3; - md->r1[md->point] = md->offset_vector[number]; - md->r2[md->point] = md->offset_vector[number+1]; - md->off_num[md->point] = number; - md->point++; - - md->offset_vector[number] = eptr - md->start_subject; - /* Handle alternation inside the BRA...KET; push each of the - additional alternatives onto the stack */ - ptr=prev; - do { - ptr += (ptr[1]<<8)+ ptr[2]; - if (*ptr==OP_ALT) - { - if (md->length == md->point) - if (md->length == md->point) - { - grow_stack(md); - } - md->offset_top[md->point] = offset_top; - md->eptr[md->point] = eptr; - md->ecode[md->point] = ptr+3; - md->r1[md->point] = 0; - md->r2[md->point] = 0; - md->off_num[md->point] = 0; - md->point++; - /*points_pushed++;*/ - } - } while (*ptr==OP_ALT); - /* Jump to the first (or only) alternative and resume trying to match */ - ecode=prev+3; goto match_loop; - } - } - - /* Start of subject unless notbol, or after internal newline if multiline */ - - case OP_CIRC: - if (md->notbol && eptr == md->start_subject) FAIL; - if (md->multiline) - { - if (eptr != md->start_subject && eptr[-1] != '\n') FAIL; - ecode++; - break; - } - /* ... else fall through */ - - /* Start of subject assertion */ - - case OP_SOD: - if (eptr != md->start_subject) FAIL; - ecode++; - break; - - /* Assert before internal newline if multiline, or before - a terminating newline unless endonly is set, else end of subject unless - noteol is set. */ - - case OP_DOLL: - if (md->noteol && eptr >= md->end_subject) FAIL; - if (md->multiline) - { - if (eptr < md->end_subject && *eptr != '\n') FAIL; - ecode++; - break; - } - else if (!md->endonly) - { - if (eptr < md->end_subject - 1 || - (eptr == md->end_subject - 1 && *eptr != '\n')) FAIL; - ecode++; - break; - } - /* ... else fall through */ - - /* End of subject assertion */ - - case OP_EOD: - if (eptr < md->end_subject) FAIL; - ecode++; - break; - - /* Word boundary assertions */ - - case OP_NOT_WORD_BOUNDARY: - case OP_WORD_BOUNDARY: - { - BOOL prev_is_word = (eptr != md->start_subject) && - ((pcre_ctypes[eptr[-1]] & ctype_word) != 0); - BOOL cur_is_word = (eptr < md->end_subject) && - ((pcre_ctypes[*eptr] & ctype_word) != 0); - if ((*ecode++ == OP_WORD_BOUNDARY)? - cur_is_word == prev_is_word : cur_is_word != prev_is_word) - FAIL; - } - break; - - case OP_NOT_WORD_BOUNDARY_L: - case OP_WORD_BOUNDARY_L: - { - BOOL prev_is_word = (eptr != md->start_subject) && - (isalnum(eptr[-1]) || eptr[-1]=='_'); - BOOL cur_is_word = (eptr < md->end_subject) && - (isalnum(*eptr) || *eptr=='_'); - if ((*ecode++ == OP_WORD_BOUNDARY_L)? - cur_is_word == prev_is_word : cur_is_word != prev_is_word) - FAIL; - } - break; - - - /* Match a single character type; inline for speed */ - - case OP_ANY: - if (!md->dotall && eptr < md->end_subject && *eptr == '\n') FAIL; - if (eptr++ >= md->end_subject) FAIL; - ecode++; - break; - - case OP_NOT_DIGIT: - if (eptr >= md->end_subject || (pcre_ctypes[*eptr++] & ctype_digit) != 0) - FAIL; - ecode++; - break; - - case OP_DIGIT: - if (eptr >= md->end_subject || (pcre_ctypes[*eptr++] & ctype_digit) == 0) - FAIL; - ecode++; - break; - - case OP_NOT_WHITESPACE: - if (eptr >= md->end_subject || (pcre_ctypes[*eptr++] & ctype_space) != 0) - FAIL; - ecode++; - break; - - case OP_WHITESPACE: - if (eptr >= md->end_subject || (pcre_ctypes[*eptr++] & ctype_space) == 0) - FAIL; - ecode++; - break; - - case OP_NOT_WORDCHAR: - if (eptr >= md->end_subject || (pcre_ctypes[*eptr++] & ctype_word) != 0) - FAIL; - ecode++; - break; - - case OP_WORDCHAR: - if (eptr >= md->end_subject || (pcre_ctypes[*eptr++] & ctype_word) == 0) - FAIL; - ecode++; - break; - - case OP_NOT_WORDCHAR_L: - if (eptr >= md->end_subject || (*eptr=='_' || isalnum(*eptr) )) - FAIL; - eptr++; - ecode++; - break; - - case OP_WORDCHAR_L: - if (eptr >= md->end_subject || (*eptr!='_' && !isalnum(*eptr) )) - FAIL; - eptr++; - ecode++; - break; - - /* Match a back reference, possibly repeatedly. Look past the end of the - item to see if there is repeat information following. The code is similar - to that for character classes, but repeated for efficiency. Then obey - similar code to character type repeats - written out again for speed. - However, if the referenced string is the empty string, always treat - it as matched, any number of times (otherwise there could be infinite - loops). */ - - case OP_REF: - { - int length; - int number = ecode[1] << 1; /* Doubled reference number */ - ecode += 2; /* Advance past the item */ - - if (number >= offset_top || md->offset_vector[number] < 0) - { - md->errorcode = PCRE_ERROR_BADREF; - FAIL; - } - - length = md->offset_vector[number+1] - md->offset_vector[number]; - - switch (*ecode) - { - case OP_CRSTAR: - case OP_CRMINSTAR: - case OP_CRPLUS: - case OP_CRMINPLUS: - case OP_CRQUERY: - case OP_CRMINQUERY: - c = *ecode++ - OP_CRSTAR; - minimize = (c & 1) != 0; - min = rep_min[c]; /* Pick up values from tables; */ - max = rep_max[c]; /* zero for max => infinity */ - if (max == 0) max = INT_MAX; - break; - - case OP_CRRANGE: - case OP_CRMINRANGE: - minimize = (*ecode == OP_CRMINRANGE); - min = (ecode[1] << 8) + ecode[2]; - max = (ecode[3] << 8) + ecode[4]; - if (max == 0) max = INT_MAX; - ecode += 5; - break; - - default: /* No repeat follows */ - if (!match_ref(number, eptr, length, md)) FAIL; - eptr += length; - continue; /* With the main loop */ - } - - /* If the length of the reference is zero, just continue with the - main loop. */ - - if (length == 0) continue; - - /* First, ensure the minimum number of matches are present. We get back - the length of the reference string explicitly rather than passing the - address of eptr, so that eptr can be a register variable. */ - - for (i = 1; i <= min; i++) - { - if (!match_ref(number, eptr, length, md)) FAIL; - eptr += length; - } - - /* If min = max, continue at the same level without recursion. - They are not both allowed to be zero. */ - - if (min == max) continue; - - /* If minimizing, keep trying and advancing the pointer */ - - if (minimize) - { - for (i = min;; i++) - { - if (match(eptr, ecode, offset_top, md)) SUCCEED; - if (i >= max || !match_ref(number, eptr, length, md)) - FAIL; - eptr += length; - } - /* Control never gets here */ - } - - /* If maximizing, find the longest string and work backwards */ - - else - { - const uschar *pp = eptr; - for (i = min; i < max; i++) - { - if (!match_ref(number, eptr, length, md)) break; - eptr += length; - } - while (eptr >= pp) - { - if (match(eptr, ecode, offset_top, md)) SUCCEED; - eptr -= length; - } - FAIL; - } - } - /* Control never gets here */ - - /* Match a character class, possibly repeatedly. Look past the end of the - item to see if there is repeat information following. Then obey similar - code to character type repeats - written out again for speed. If caseless - matching was set at runtime but not at compile time, we have to check both - versions of a character, and we have to behave differently for positive and - negative classes. This is the only time where OP_CLASS and OP_NEGCLASS are - treated differently. */ - - case OP_CLASS: - case OP_NEGCLASS: - { - BOOL nasty_case = *ecode == OP_NEGCLASS && md->runtime_caseless; - const uschar *data = ecode + 1; /* Save for matching */ - ecode += 33; /* Advance past the item */ - - switch (*ecode) - { - case OP_CRSTAR: - case OP_CRMINSTAR: - case OP_CRPLUS: - case OP_CRMINPLUS: - case OP_CRQUERY: - case OP_CRMINQUERY: - c = *ecode++ - OP_CRSTAR; - minimize = (c & 1) != 0; - min = rep_min[c]; /* Pick up values from tables; */ - max = rep_max[c]; /* zero for max => infinity */ - if (max == 0) max = INT_MAX; - break; - - case OP_CRRANGE: - case OP_CRMINRANGE: - minimize = (*ecode == OP_CRMINRANGE); - min = (ecode[1] << 8) + ecode[2]; - max = (ecode[3] << 8) + ecode[4]; - if (max == 0) max = INT_MAX; - ecode += 5; - break; - - default: /* No repeat follows */ - min = max = 1; - break; - } - - /* First, ensure the minimum number of matches are present. */ - - for (i = 1; i <= min; i++) - { - if (eptr >= md->end_subject) FAIL; - c = *eptr++; - - /* Either not runtime caseless, or it was a positive class. For - runtime caseless, continue if either case is in the map. */ - - if (!nasty_case) - { - if ((data[c/8] & (1 << (c&7))) != 0) continue; - if (md->runtime_caseless) - { - c = pcre_fcc[c]; - if ((data[c/8] & (1 << (c&7))) != 0) continue; - } - } - - /* Runtime caseless and it was a negative class. Continue only if - both cases are in the map. */ - - else - { - if ((data[c/8] & (1 << (c&7))) == 0) FAIL; - c = pcre_fcc[c]; - if ((data[c/8] & (1 << (c&7))) != 0) continue; - } - - FAIL; - } - - /* If max == min we can continue with the main loop without the - need to recurse. */ - - if (min == max) continue; - - /* If minimizing, keep testing the rest of the expression and advancing - the pointer while it matches the class. */ - - if (minimize) - { - for (i = min;; i++) - { - if (match(eptr, ecode, offset_top, md)) SUCCEED; - if (i >= max || eptr >= md->end_subject) FAIL; - c = *eptr++; - - /* Either not runtime caseless, or it was a positive class. For - runtime caseless, continue if either case is in the map. */ - - if (!nasty_case) - { - if ((data[c/8] & (1 << (c&7))) != 0) continue; - if (md->runtime_caseless) - { - c = pcre_fcc[c]; - if ((data[c/8] & (1 << (c&7))) != 0) continue; - } - } - - /* Runtime caseless and it was a negative class. Continue only if - both cases are in the map. */ - - else - { - if ((data[c/8] & (1 << (c&7))) == 0) return FALSE; - c = pcre_fcc[c]; - if ((data[c/8] & (1 << (c&7))) != 0) continue; - } - - FAIL; - } - /* Control never gets here */ - } - - /* If maximizing, find the longest possible run, then work backwards. */ - - else - { - const uschar *pp = eptr; - for (i = min; i < max; eptr++, i++) - { - if (eptr >= md->end_subject) break; - c = *eptr; - - /* Either not runtime caseless, or it was a positive class. For - runtime caseless, continue if either case is in the map. */ - - if (!nasty_case) - { - if ((data[c/8] & (1 << (c&7))) != 0) continue; - if (md->runtime_caseless) - { - c = pcre_fcc[c]; - if ((data[c/8] & (1 << (c&7))) != 0) continue; - } - } - - /* Runtime caseless and it was a negative class. Continue only if - both cases are in the map. */ - - else - { - if ((data[c/8] & (1 << (c&7))) == 0) break; - c = pcre_fcc[c]; - if ((data[c/8] & (1 << (c&7))) != 0) continue; - } - - break; - } - - while (eptr >= pp) - if (match(eptr--, ecode, offset_top, md)) SUCCEED; - FAIL; - } - } - /* Control never gets here */ - - /* OP_CLASS_L opcode: handles localized character classes */ - - case OP_CLASS_L: - { - const uschar *data = ecode + 1; /* Save for matching */ - const uschar locale_flag = *data; - ecode++; data++; /* The localization support adds an extra byte */ - - ecode += 33; /* Advance past the item */ - - switch (*ecode) - { - case OP_CRSTAR: - case OP_CRMINSTAR: - case OP_CRPLUS: - case OP_CRMINPLUS: - case OP_CRQUERY: - case OP_CRMINQUERY: - c = *ecode++ - OP_CRSTAR; - minimize = (c & 1) != 0; - min = rep_min[c]; /* Pick up values from tables; */ - max = rep_max[c]; /* zero for max => infinity */ - if (max == 0) max = INT_MAX; - break; - - case OP_CRRANGE: - case OP_CRMINRANGE: - minimize = (*ecode == OP_CRMINRANGE); - min = (ecode[1] << 8) + ecode[2]; - max = (ecode[3] << 8) + ecode[4]; - if (max == 0) max = INT_MAX; - ecode += 5; - break; - - default: /* No repeat follows */ - if (eptr >= md->end_subject) FAIL; - c = *eptr++; - if ((data[c/8] & (1 << (c&7))) != 0) continue; /* With main loop */ - if ( (locale_flag & 1) && (isalnum(c) || c=='_') ) continue; /* Locale \w */ - if ( (locale_flag & 2) && (!isalnum(c) && c!='_') ) continue; /* Locale \W */ -#if 0 - if ( (locale_flag & 4) && isdigit(c) ) continue; /* Locale \d */ - if ( (locale_flag & 8) && !isdigit(c) ) continue; /* Locale \D */ - if ( (locale_flag & 16) && isspace(c) ) continue; /* Locale \s */ - if ( (locale_flag & 32) && !isspace(c) ) continue; /* Locale \S */ -#endif - - if (md->runtime_caseless) - { - c = pcre_fcc[c]; - if ((data[c/8] & (1 << (c&7))) != 0) continue; /* With main loop */ - - if ( (locale_flag & 1) && (isalnum(c) || c=='_') ) continue; /* Locale \w */ - if ( (locale_flag & 2) && (!isalnum(c) && c!='_') ) continue; /* Locale \W */ - } - FAIL; - } - - /* First, ensure the minimum number of matches are present. */ - - for (i = 1; i <= min; i++) - { - if (eptr >= md->end_subject) FAIL; - c = *eptr++; - if ((data[c/8] & (1 << (c&7))) != 0) continue; - if ( (locale_flag & 1) && (isalnum(c) || c=='_') ) continue; /* Locale \w */ - if ( (locale_flag & 2) && (!isalnum(c) && c!='_') ) continue; /* Locale \W */ - - if (md->runtime_caseless) - { - c = pcre_fcc[c]; - if ((data[c/8] & (1 << (c&7))) != 0) continue; - if ( (locale_flag & 1) && (isalnum(c) || c=='_') ) continue; /* Locale \w */ - if ( (locale_flag & 2) && (!isalnum(c) && c!='_') ) continue; /* Locale \W */ - } - FAIL; - } - - /* If max == min we can continue with the main loop without the - need to recurse. */ - - if (min == max) continue; - - /* If minimizing, keep testing the rest of the expression and advancing - the pointer while it matches the class. */ - - if (minimize) - { - for (i = min;; i++) - { - if (match(eptr, ecode, offset_top, md)) SUCCEED; - if (i >= max || eptr >= md->end_subject) FAIL; - c = *eptr++; - if ((data[c/8] & (1 << (c&7))) != 0) continue; - if ( (locale_flag & 1) && (isalnum(c) || c=='_') ) continue; /* Locale \w */ - if ( (locale_flag & 2) && (!isalnum(c) && c!='_') ) continue; /* Locale \W */ - - if (md->runtime_caseless) - { - c = pcre_fcc[c]; - if ((data[c/8] & (1 << (c&7))) != 0) continue; - if ( (locale_flag & 1) && (isalnum(c) || c=='_') ) continue; /* Locale \w */ - if ( (locale_flag & 2) && (!isalnum(c) && c!='_') ) continue; /* Locale \W */ - } - FAIL; - } - /* Control never gets here */ - } - - /* If maximizing, find the longest possible run, then work backwards. */ - - else - { - const uschar *pp = eptr; - for (i = min; i < max; eptr++, i++) - { - if (eptr >= md->end_subject) break; - c = *eptr; - if ((data[c/8] & (1 << (c&7))) != 0) continue; - if ( (locale_flag & 1) && (isalnum(c) || c=='_') ) continue; /* Locale \w */ - if ( (locale_flag & 2) && (!isalnum(c) && c!='_') ) continue; /* Locale \W */ - if (md->runtime_caseless) - { - c = pcre_fcc[c]; - if ((data[c/8] & (1 << (c&7))) != 0) continue; - if ( (locale_flag & 1) && (isalnum(c) || c=='_') ) continue; /* Locale \w */ - if ( (locale_flag & 2) && (!isalnum(c) && c!='_') ) continue; /* Locale \W */ - } - break; - } - - while (eptr >= pp) - if (match(eptr--, ecode, offset_top, md)) SUCCEED; - FAIL; - } - } - /* Control never gets here */ - - /* Match a run of characters */ - - case OP_CHARS: - { - register int length = ecode[1]; - ecode += 2; - -#ifdef DEBUG /* Sigh. Some compilers never learn. */ - if (eptr >= md->end_subject) - printf("matching subject against pattern "); - else - { - printf("matching subject "); - pchars(eptr, length, TRUE, md); - printf(" against pattern "); - } - pchars(ecode, length, FALSE, md); - printf("\n"); -#endif - - if (length > md->end_subject - eptr) FAIL; - if (md->caseless) - { - while (length-- > 0) if (pcre_lcc[*ecode++] != pcre_lcc[*eptr++]) FAIL; - } - else - { - while (length-- > 0) if (*ecode++ != *eptr++) FAIL; - } - } - break; - - /* Match a single character repeatedly; different opcodes share code. */ - - case OP_EXACT: - min = max = (ecode[1] << 8) + ecode[2]; - ecode += 3; - goto REPEATCHAR; - - case OP_UPTO: - case OP_MINUPTO: - min = 0; - max = (ecode[1] << 8) + ecode[2]; - minimize = *ecode == OP_MINUPTO; - ecode += 3; - goto REPEATCHAR; - - case OP_STAR: - case OP_MINSTAR: - case OP_PLUS: - case OP_MINPLUS: - case OP_QUERY: - case OP_MINQUERY: - c = *ecode++ - OP_STAR; - minimize = (c & 1) != 0; - min = rep_min[c]; /* Pick up values from tables; */ - max = rep_max[c]; /* zero for max => infinity */ - if (max == 0) max = INT_MAX; - - /* Common code for all repeated single-character matches. We can give - up quickly if there are fewer than the minimum number of characters left in - the subject. */ - - REPEATCHAR: - if (min > md->end_subject - eptr) FAIL; - c = *ecode++; - - /* The code is duplicated for the caseless and caseful cases, for speed, - since matching characters is likely to be quite common. First, ensure the - minimum number of matches are present. If min = max, continue at the same - level without recursing. Otherwise, if minimizing, keep trying the rest of - the expression and advancing one matching character if failing, up to the - maximum. Alternatively, if maximizing, find the maximum number of - characters and work backwards. */ - - DPRINTF(("matching %c{%d,%d} against subject %.*s\n", c, min, max, - max, eptr)); - - if (md->caseless) - { - c = pcre_lcc[c]; - for (i = 1; i <= min; i++) if (c != pcre_lcc[*eptr++]) FAIL; - if (min == max) continue; - if (minimize) - { - for (i = min;; i++) - { - if (match(eptr, ecode, offset_top, md)) SUCCEED; - if (i >= max || eptr >= md->end_subject || c != pcre_lcc[*eptr++]) - FAIL; - } - /* Control never gets here */ - } - else - { - const uschar *pp = eptr; - for (i = min; i < max; i++) - { - if (eptr >= md->end_subject || c != pcre_lcc[*eptr]) break; - eptr++; - } - while (eptr >= pp) - if (match(eptr--, ecode, offset_top, md)) SUCCEED; - FAIL; - } - /* Control never gets here */ - } - - /* Caseful comparisons */ - - else - { - for (i = 1; i <= min; i++) if (c != *eptr++) FAIL; - if (min == max) continue; - if (minimize) - { - for (i = min;; i++) - { - if (match(eptr, ecode, offset_top, md)) SUCCEED; - if (i >= max || eptr >= md->end_subject || c != *eptr++) FAIL; - } - /* Control never gets here */ - } - else - { - const uschar *pp = eptr; - for (i = min; i < max; i++) - { - if (eptr >= md->end_subject || c != *eptr) break; - eptr++; - } - while (eptr >= pp) - if (match(eptr--, ecode, offset_top, md)) SUCCEED; - FAIL; - } - } - /* Control never gets here */ - - /* Match a negated single character */ - - case OP_NOT: - if (eptr >= md->end_subject) FAIL; - ecode++; - if (md->caseless) - { - if (pcre_lcc[*ecode++] == pcre_lcc[*eptr++]) FAIL; - } - else - { - if (*ecode++ == *eptr++) FAIL; - } - break; - - /* Match a negated single character repeatedly. This is almost a repeat of - the code for a repeated single character, but I haven't found a nice way of - commoning these up that doesn't require a test of the positive/negative - option for each character match. Maybe that wouldn't add very much to the - time taken, but character matching *is* what this is all about... */ - - case OP_NOTEXACT: - min = max = (ecode[1] << 8) + ecode[2]; - ecode += 3; - goto REPEATNOTCHAR; - - case OP_NOTUPTO: - case OP_NOTMINUPTO: - min = 0; - max = (ecode[1] << 8) + ecode[2]; - minimize = *ecode == OP_NOTMINUPTO; - ecode += 3; - goto REPEATNOTCHAR; - - case OP_NOTSTAR: - case OP_NOTMINSTAR: - case OP_NOTPLUS: - case OP_NOTMINPLUS: - case OP_NOTQUERY: - case OP_NOTMINQUERY: - c = *ecode++ - OP_NOTSTAR; - minimize = (c & 1) != 0; - min = rep_min[c]; /* Pick up values from tables; */ - max = rep_max[c]; /* zero for max => infinity */ - if (max == 0) max = INT_MAX; - - /* Common code for all repeated single-character matches. We can give - up quickly if there are fewer than the minimum number of characters left in - the subject. */ - - REPEATNOTCHAR: - if (min > md->end_subject - eptr) FAIL; - c = *ecode++; - - /* The code is duplicated for the caseless and caseful cases, for speed, - since matching characters is likely to be quite common. First, ensure the - minimum number of matches are present. If min = max, continue at the same - level without recursing. Otherwise, if minimizing, keep trying the rest of - the expression and advancing one matching character if failing, up to the - maximum. Alternatively, if maximizing, find the maximum number of - characters and work backwards. */ - - DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", c, min, max, - max, eptr)); - - if (md->caseless) - { - c = pcre_lcc[c]; - for (i = 1; i <= min; i++) if (c == pcre_lcc[*eptr++]) FAIL; - if (min == max) continue; - if (minimize) - { - for (i = min;; i++) - { - if (match(eptr, ecode, offset_top, md)) SUCCEED; - if (i >= max || eptr >= md->end_subject || c == pcre_lcc[*eptr++]) - FAIL; - } - /* Control never gets here */ - } - else - { - const uschar *pp = eptr; - for (i = min; i < max; i++) - { - if (eptr >= md->end_subject || c == pcre_lcc[*eptr]) break; - eptr++; - } - while (eptr >= pp) - if (match(eptr--, ecode, offset_top, md)) SUCCEED; - FAIL; - } - /* Control never gets here */ - } - - /* Caseful comparisons */ - - else - { - for (i = 1; i <= min; i++) if (c == *eptr++) FAIL; - if (min == max) continue; - if (minimize) - { - for (i = min;; i++) - { - if (match(eptr, ecode, offset_top, md)) SUCCEED; - if (i >= max || eptr >= md->end_subject || c == *eptr++) FAIL; - } - /* Control never gets here */ - } - else - { - const uschar *pp = eptr; - for (i = min; i < max; i++) - { - if (eptr >= md->end_subject || c == *eptr) break; - eptr++; - } - while (eptr >= pp) - if (match(eptr--, ecode, offset_top, md)) SUCCEED; - FAIL; - } - } - /* Control never gets here */ - - /* Match a single character type repeatedly; several different opcodes - share code. This is very similar to the code for single characters, but we - repeat it in the interests of efficiency. */ - - case OP_TYPEEXACT: - min = max = (ecode[1] << 8) + ecode[2]; - minimize = TRUE; - ecode += 3; - goto REPEATTYPE; - - case OP_TYPEUPTO: - case OP_TYPEMINUPTO: - min = 0; - max = (ecode[1] << 8) + ecode[2]; - minimize = *ecode == OP_TYPEMINUPTO; - ecode += 3; - goto REPEATTYPE; - - case OP_TYPESTAR: - case OP_TYPEMINSTAR: - case OP_TYPEPLUS: - case OP_TYPEMINPLUS: - case OP_TYPEQUERY: - case OP_TYPEMINQUERY: - c = *ecode++ - OP_TYPESTAR; - minimize = (c & 1) != 0; - min = rep_min[c]; /* Pick up values from tables; */ - max = rep_max[c]; /* zero for max => infinity */ - if (max == 0) max = INT_MAX; - - /* Common code for all repeated single character type matches */ - - REPEATTYPE: - ctype = *ecode++; /* Code for the character type */ - - /* First, ensure the minimum number of matches are present. Use inline - code for maximizing the speed, and do the type test once at the start - (i.e. keep it out of the loop). Also test that there are at least the - minimum number of characters before we start. */ - - if (min > md->end_subject - eptr) FAIL; - if (min > 0) switch(ctype) - { - case OP_ANY: - if (!md->dotall) - { for (i = 1; i <= min; i++) if (*eptr++ == '\n') FAIL; } - else eptr += min; - break; - - case OP_NOT_DIGIT: - for (i = 1; i <= min; i++) - if ((pcre_ctypes[*eptr++] & ctype_digit) != 0) FAIL; - break; - - case OP_DIGIT: - for (i = 1; i <= min; i++) - if ((pcre_ctypes[*eptr++] & ctype_digit) == 0) FAIL; - break; - - case OP_NOT_WHITESPACE: - for (i = 1; i <= min; i++) - if ((pcre_ctypes[*eptr++] & ctype_space) != 0) FAIL; - break; - - case OP_WHITESPACE: - for (i = 1; i <= min; i++) - if ((pcre_ctypes[*eptr++] & ctype_space) == 0) FAIL; - break; - - case OP_NOT_WORDCHAR: - for (i = 1; i <= min; i++) if ((pcre_ctypes[*eptr++] & ctype_word) != 0) - FAIL; - break; - - case OP_WORDCHAR: - for (i = 1; i <= min; i++) if ((pcre_ctypes[*eptr++] & ctype_word) == 0) - FAIL; - break; - - case OP_NOT_WORDCHAR_L: - for (i = 1; i <= min; i++, eptr++) if (*eptr=='_' || isalnum(*eptr)) - FAIL; - break; - - case OP_WORDCHAR_L: - for (i = 1; i <= min; i++, eptr++) if (*eptr!='_' && !isalnum(*eptr)) - FAIL; - break; - } - - /* If min = max, continue at the same level without recursing */ - - if (min == max) continue; - - /* If minimizing, we have to test the rest of the pattern before each - subsequent match, so inlining isn't much help; just use the function. */ - - if (minimize) - { - for (i = min;; i++) - { - if (match(eptr, ecode, offset_top, md)) SUCCEED; - if (i >= max || eptr >= md->end_subject || - !match_type(ctype, *eptr++, md->dotall)) - FAIL; - } - /* Control never gets here */ - } - - /* If maximizing it is worth using inline code for speed, doing the type - test once at the start (i.e. keep it out of the loop). */ - - else - { - const uschar *pp = eptr; - switch(ctype) - { - case OP_ANY: - if (!md->dotall) - { - for (i = min; i < max; i++) - { - if (eptr >= md->end_subject || *eptr == '\n') break; - eptr++; - } - } - else - { - c = max - min; - if (c > md->end_subject - eptr) c = md->end_subject - eptr; - eptr += c; - } - break; - - case OP_NOT_DIGIT: - for (i = min; i < max; i++) - { - if (eptr >= md->end_subject || (pcre_ctypes[*eptr] & ctype_digit) != 0) - break; - eptr++; - } - break; - - case OP_DIGIT: - for (i = min; i < max; i++) - { - if (eptr >= md->end_subject || (pcre_ctypes[*eptr] & ctype_digit) == 0) - break; - eptr++; - } - break; - - case OP_NOT_WHITESPACE: - for (i = min; i < max; i++) - { - if (eptr >= md->end_subject || (pcre_ctypes[*eptr] & ctype_space) != 0) - break; - eptr++; - } - break; - - case OP_WHITESPACE: - for (i = min; i < max; i++) - { - if (eptr >= md->end_subject || (pcre_ctypes[*eptr] & ctype_space) == 0) - break; - eptr++; - } - break; - - case OP_NOT_WORDCHAR: - for (i = min; i < max; i++) - { - if (eptr >= md->end_subject || (pcre_ctypes[*eptr] & ctype_word) != 0) - break; - eptr++; - } - break; - - case OP_WORDCHAR: - for (i = min; i < max; i++) - { - if (eptr >= md->end_subject || (pcre_ctypes[*eptr] & ctype_word) == 0) - break; - eptr++; - } - break; - case OP_NOT_WORDCHAR_L: - for (i = min; i < max; i++) - { - if (eptr >= md->end_subject || (*eptr=='_' || isalnum(*eptr) ) ) - break; - eptr++; - } - break; - - case OP_WORDCHAR_L: - for (i = min; i < max; i++) - { - if (eptr >= md->end_subject || (*eptr!='_' && !isalnum(*eptr) ) ) - break; - eptr++; - } - break; - } - - while (eptr >= pp) - if (match(eptr--, ecode, offset_top, md)) SUCCEED; - FAIL; - } - /* Control never gets here */ - - /* There's been some horrible disaster. */ - - default: - DPRINTF(("Unknown opcode %d\n", *ecode)); - md->errorcode = PCRE_ERROR_UNKNOWN_NODE; - FAIL; - } - - /* Do not stick any code in here without much thought; it is assumed - that "continue" in the code above comes out to here to repeat the main - loop. */ - - } /* End of main loop */ -/* Control never reaches here */ - -fail: - if (md->point > save_stack_position) - { - /* If there are still points remaining on the stack, pop the next one off */ - int off_num; - - md->point--; - offset_top = md->offset_top[md->point]; - eptr = md->eptr[md->point]; - ecode = md->ecode[md->point]; - off_num = md->off_num[md->point]; - md->offset_vector[off_num] = md->r1[md->point]; - md->offset_vector[off_num+1] = md->r2[md->point]; - goto match_loop; - } - /* Failure, and nothing left on the stack, so end this function call */ - - /* Restore the top of the stack to where it was before this function - call. This lets us use one stack for everything; recursive calls - can push and pop information, and may increase the stack. When - the call returns, the parent function can resume pushing and - popping wherever it was. */ - - md->point = save_stack_position; - return FALSE; - -succeed: - return TRUE; -} - - - -/************************************************* -* Segregate setjmp() * -*************************************************/ - -/* The -Wall option of gcc gives warnings for all local variables when setjmp() -is used, even if the coding conforms to the rules of ANSI C. To avoid this, we -hide it in a separate function. This is called only when PCRE_EXTRA is set, -since it's needed only for the extension \X option, and with any luck, a good -compiler will spot the tail recursion and compile it efficiently. - -Arguments: - eptr pointer in subject - ecode position in code - offset_top current top pointer - md pointer to "static" info for the match - -Returns: TRUE if matched -*/ - -static BOOL -match_with_setjmp(const uschar *eptr, const uschar *ecode, int offset_top, - match_data *match_block) -{ -return setjmp(match_block->fail_env) == 0 && - match(eptr, ecode, offset_top, match_block); -} - - - -/************************************************* -* Execute a Regular Expression * -*************************************************/ - -/* This function applies a compiled re to a subject string and picks out -portions of the string if it matches. Two elements in the vector are set for -each substring: the offsets to the start and end of the substring. - -Arguments: - external_re points to the compiled expression - external_extra points to "hints" from pcre_study() or is NULL - subject points to the subject string - length length of subject string (may contain binary zeros) - options option bits - offsets points to a vector of ints to be filled in with offsets - offsetcount the number of elements in the vector - -Returns: > 0 => success; value is the number of elements filled in - = 0 => success, but offsets is not big enough - -1 => failed to match - < -1 => some kind of unexpected problem -*/ - -int -pcre_exec(const pcre *external_re, const pcre_extra *external_extra, - const char *subject, int length, int start_pos, int options, - int *offsets, int offsetcount) -{ - /* The "volatile" directives are to make gcc -Wall stop complaining - that these variables can be clobbered by the longjmp. Hopefully - they won't cost too much performance. */ -volatile int resetcount, ocount; -volatile int first_char = -1; -const uschar * volatile start_bits = NULL; -const uschar * volatile start_match = (const uschar *)subject + start_pos; -match_data match_block; -const uschar *end_subject; -const real_pcre *re = (const real_pcre *)external_re; -const real_pcre_extra *extra = (const real_pcre_extra *)external_extra; -volatile BOOL using_temporary_offsets = FALSE; -volatile BOOL anchored = ((re->options | options) & PCRE_ANCHORED) != 0; -volatile BOOL startline = (re->options & PCRE_STARTLINE) != 0; - -if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION; - -if (re == NULL || subject == NULL || - (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL; -if (re->magic_number != MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC; - -match_block.start_subject = (const uschar *)subject; -match_block.end_subject = match_block.start_subject + length; -end_subject = match_block.end_subject; - -match_block.caseless = ((re->options | options) & PCRE_CASELESS) != 0; -match_block.runtime_caseless = match_block.caseless && - (re->options & PCRE_CASELESS) == 0; - -match_block.multiline = ((re->options | options) & PCRE_MULTILINE) != 0; -match_block.dotall = ((re->options | options) & PCRE_DOTALL) != 0; -match_block.endonly = ((re->options | options) & PCRE_DOLLAR_ENDONLY) != 0; - -match_block.notbol = (options & PCRE_NOTBOL) != 0; -match_block.noteol = (options & PCRE_NOTEOL) != 0; - -match_block.errorcode = PCRE_ERROR_NOMATCH; /* Default error */ - -/* Set the stack state to empty */ - match_block.off_num = match_block.offset_top = NULL; - match_block.r1 = match_block.r2 = NULL; - match_block.eptr = match_block.ecode = NULL; - match_block.point = match_block.length = 0; - -/* If the expression has got more back references than the offsets supplied can -hold, we get a temporary bit of working store to use during the matching. -Otherwise, we can use the vector supplied, rounding down its size to a multiple -of 2. */ - -ocount = offsetcount & (-2); -if (re->top_backref > 0 && re->top_backref >= ocount/2) - { - ocount = re->top_backref * 2 + 2; - match_block.offset_vector = (int *)(pcre_malloc)(ocount * sizeof(int)); - if (match_block.offset_vector == NULL) return PCRE_ERROR_NOMEMORY; - using_temporary_offsets = TRUE; - DPRINTF(("Got memory to hold back references\n")); - } -else match_block.offset_vector = offsets; - -match_block.offset_end = ocount; -match_block.offset_overflow = FALSE; - -/* Compute the minimum number of offsets that we need to reset each time. Doing -this makes a huge difference to execution time when there aren't many brackets -in the pattern. */ - -resetcount = 2 + re->top_bracket * 2; -if (resetcount > offsetcount) resetcount = ocount; - -/* If MULTILINE is set at exec time but was not set at compile time, and the -anchored flag is set, we must re-check because a setting provoked by ^ in the -pattern is not right in multi-line mode. Calling is_anchored() again here does -the right check, because multiline is now set. If it now yields FALSE, the -expression must have had ^ starting some of its branches. Check to see if -that is true for *all* branches, and if so, set the startline flag. */ - -if (match_block.multiline && anchored && (re->options & PCRE_MULTILINE) == 0 && - !is_anchored(re->code, match_block.multiline)) - { - anchored = FALSE; - if (is_startline(re->code)) startline = TRUE; - } - -/* Set up the first character to match, if available. The first_char value is -never set for an anchored regular expression, but the anchoring may be forced -at run time, so we have to test for anchoring. The first char may be unset for -an unanchored pattern, of course. If there's no first char and the pattern was -studied, the may be a bitmap of possible first characters. However, we can -use this only if the caseless state of the studying was correct. */ - -if (!anchored) - { - if ((re->options & PCRE_FIRSTSET) != 0) - { - first_char = re->first_char; - if (match_block.caseless) first_char = pcre_lcc[first_char]; - } - else - if (!startline && extra != NULL && - (extra->options & PCRE_STUDY_MAPPED) != 0 && - ((extra->options & PCRE_STUDY_CASELESS) != 0) == match_block.caseless) - start_bits = extra->start_bits; - } - -/* Loop for unanchored matches; for anchored regexps the loop runs just once. */ - -do - { - int rc; - register int *iptr = match_block.offset_vector; - register int *iend = iptr + resetcount; - - /* Reset the maximum number of extractions we might see. */ - - while (iptr < iend) *iptr++ = -1; - - /* Advance to a unique first char if possible */ - - if (first_char >= 0) - { - if (match_block.caseless) - while (start_match < end_subject && pcre_lcc[*start_match] != first_char) - start_match++; - else - while (start_match < end_subject && *start_match != first_char) - start_match++; - } - - /* Or to just after \n for a multiline match if possible */ - - else if (startline) - { - if (start_match > match_block.start_subject) - { - while (start_match < end_subject && start_match[-1] != '\n') - start_match++; - } - } - - /* Or to a non-unique first char */ - - else if (start_bits != NULL) - { - while (start_match < end_subject) - { - register int c = *start_match; - if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++; else break; - } - } - -#ifdef DEBUG /* Sigh. Some compilers never learn. */ - printf(">>>> Match against: "); - pchars(start_match, end_subject - start_match, TRUE, &match_block); - printf("\n"); -#endif - - /* When a match occurs, substrings will be set for all internal extractions; - we just need to set up the whole thing as substring 0 before returning. If - there were too many extractions, set the return code to zero. In the case - where we had to get some local store to hold offsets for backreferences, copy - those back references that we can. In this case there need not be overflow - if certain parts of the pattern were not used. - - Before starting the match, we have to set up a longjmp() target to enable - the "cut" operation to fail a match completely without backtracking. This - is done in a separate function to avoid compiler warnings. We need not do - it unless PCRE_EXTRA is set, since only in that case is the "cut" operation - enabled. */ - - /* To handle errors such as running out of memory for the failure - stack, we need to save this location via setjmp(), so - error-handling code can call longjmp() to jump out of deeply-nested code. */ - if (setjmp(match_block.error_env)==0) - { - - if ((re->options & PCRE_EXTRA) != 0) - { - if (!match_with_setjmp(start_match, re->code, 2, &match_block)) - continue; - } - else if (!match(start_match, re->code, 2, &match_block)) continue; - - /* Copy the offset information from temporary store if necessary */ - - if (using_temporary_offsets) - { - if (offsetcount >= 4) - { - memcpy(offsets + 2, match_block.offset_vector + 2, - (offsetcount - 2) * sizeof(int)); - DPRINTF(("Copied offsets from temporary memory\n")); - } - if (match_block.end_offset_top > offsetcount) - match_block.offset_overflow = TRUE; - - DPRINTF(("Freeing temporary memory\n")); - (pcre_free)(match_block.offset_vector); - } - - rc = match_block.offset_overflow? 0 : match_block.end_offset_top/2; - - if (match_block.offset_end < 2) rc = 0; else - { - offsets[0] = start_match - match_block.start_subject; - offsets[1] = match_block.end_match_ptr - match_block.start_subject; - } - - DPRINTF((">>>> returning %d\n", rc)); - free_stack(&match_block); - return rc; - } /* End of (if setjmp(match_block.error_env)...) */ - free_stack(&match_block); - - /* Return an error code; pcremodule.c will preserve the exception */ - if (PyErr_Occurred()) return PCRE_ERROR_NOMEMORY; - } -while (!anchored && - match_block.errorcode == PCRE_ERROR_NOMATCH && - start_match++ < end_subject); - -if (using_temporary_offsets) - { - DPRINTF(("Freeing temporary memory\n")); - (pcre_free)(match_block.offset_vector); - } - -#ifdef DEBUG -printf(">>>> returning %d\n", match_block.errorcode); -#endif - - free_stack(&match_block); - return match_block.errorcode; -} - -/* End of pcre.c */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/python.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/python.c deleted file mode 100644 index a7446e78..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/python.c +++ /dev/null @@ -1,24 +0,0 @@ -/* Minimal main program -- everything is loaded from the library */ - -#include "Python.h" - -#ifdef __FreeBSD__ -#include -#endif - -int -main(int argc, char **argv) -{ - /* 754 requires that FP exceptions run in "no stop" mode by default, - * and until C vendors implement C99's ways to control FP exceptions, - * Python requires non-stop mode. Alas, some platforms enable FP - * exceptions by default. Here we disable them. - */ -#ifdef __FreeBSD__ - fp_except_t m; - - m = fpgetmask(); - fpsetmask(m & ~FP_X_OFL); -#endif - return Py_Main(argc, argv); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/readline.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/readline.c deleted file mode 100644 index c6d8bfb4..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/readline.c +++ /dev/null @@ -1,736 +0,0 @@ -/* This module makes GNU readline available to Python. It has ideas - * contributed by Lee Busby, LLNL, and William Magro, Cornell Theory - * Center. The completer interface was inspired by Lele Gaifax. - * - * More recently, it was largely rewritten by Guido van Rossum who is - * now maintaining it. - */ - -/* Standard definitions */ -#include "Python.h" -#include -#include -#include - -#if defined(HAVE_LOCALE_H) && defined(HAVE_SETLOCALE) -/* GNU readline() mistakenly sets the LC_CTYPE locale. - * This is evil. Only the user or the app's main() should do this! - * We must save and restore the locale around the rl_initialize() call. - */ -#define SAVE_LOCALE -#include -#endif - -/* GNU readline definitions */ -#undef HAVE_CONFIG_H /* Else readline/chardefs.h includes strings.h */ -#include -#include - -#ifdef HAVE_RL_COMPLETION_MATCHES -#define completion_matches(x, y) \ - rl_completion_matches((x), ((rl_compentry_func_t *)(y))) -#endif - - -/* Exported function to send one line to readline's init file parser */ - -static PyObject * -parse_and_bind(PyObject *self, PyObject *args) -{ - char *s, *copy; - if (!PyArg_ParseTuple(args, "s:parse_and_bind", &s)) - return NULL; - /* Make a copy -- rl_parse_and_bind() modifies its argument */ - /* Bernard Herzog */ - copy = malloc(1 + strlen(s)); - if (copy == NULL) - return PyErr_NoMemory(); - strcpy(copy, s); - rl_parse_and_bind(copy); - free(copy); /* Free the copy */ - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(doc_parse_and_bind, -"parse_and_bind(string) -> None\n\ -Parse and execute single line of a readline init file."); - - -/* Exported function to parse a readline init file */ - -static PyObject * -read_init_file(PyObject *self, PyObject *args) -{ - char *s = NULL; - if (!PyArg_ParseTuple(args, "|z:read_init_file", &s)) - return NULL; - errno = rl_read_init_file(s); - if (errno) - return PyErr_SetFromErrno(PyExc_IOError); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(doc_read_init_file, -"read_init_file([filename]) -> None\n\ -Parse a readline initialization file.\n\ -The default filename is the last filename used."); - - -/* Exported function to load a readline history file */ - -static PyObject * -read_history_file(PyObject *self, PyObject *args) -{ - char *s = NULL; - if (!PyArg_ParseTuple(args, "|z:read_history_file", &s)) - return NULL; - errno = read_history(s); - if (errno) - return PyErr_SetFromErrno(PyExc_IOError); - Py_INCREF(Py_None); - return Py_None; -} - -static int history_length = -1; /* do not truncate history by default */ -PyDoc_STRVAR(doc_read_history_file, -"read_history_file([filename]) -> None\n\ -Load a readline history file.\n\ -The default filename is ~/.history."); - - -/* Exported function to save a readline history file */ - -static PyObject * -write_history_file(PyObject *self, PyObject *args) -{ - char *s = NULL; - if (!PyArg_ParseTuple(args, "|z:write_history_file", &s)) - return NULL; - errno = write_history(s); - if (!errno && history_length >= 0) - history_truncate_file(s, history_length); - if (errno) - return PyErr_SetFromErrno(PyExc_IOError); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(doc_write_history_file, -"write_history_file([filename]) -> None\n\ -Save a readline history file.\n\ -The default filename is ~/.history."); - - -/* Set history length */ - -static PyObject* -set_history_length(PyObject *self, PyObject *args) -{ - int length = history_length; - if (!PyArg_ParseTuple(args, "i:set_history_length", &length)) - return NULL; - history_length = length; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(set_history_length_doc, -"set_history_length(length) -> None\n\ -set the maximal number of items which will be written to\n\ -the history file. A negative length is used to inhibit\n\ -history truncation."); - - -/* Get history length */ - -static PyObject* -get_history_length(PyObject *self, PyObject *noarg) -{ - return PyInt_FromLong(history_length); -} - -PyDoc_STRVAR(get_history_length_doc, -"get_history_length() -> int\n\ -return the maximum number of items that will be written to\n\ -the history file."); - - -/* Generic hook function setter */ - -static PyObject * -set_hook(const char *funcname, PyObject **hook_var, - PyThreadState **tstate, PyObject *args) -{ - PyObject *function = Py_None; - char buf[80]; - PyOS_snprintf(buf, sizeof(buf), "|O:set_%.50s", funcname); - if (!PyArg_ParseTuple(args, buf, &function)) - return NULL; - if (function == Py_None) { - Py_XDECREF(*hook_var); - *hook_var = NULL; - *tstate = NULL; - } - else if (PyCallable_Check(function)) { - PyObject *tmp = *hook_var; - Py_INCREF(function); - *hook_var = function; - Py_XDECREF(tmp); - *tstate = PyThreadState_Get(); - } - else { - PyOS_snprintf(buf, sizeof(buf), - "set_%.50s(func): argument not callable", - funcname); - PyErr_SetString(PyExc_TypeError, buf); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - - -/* Exported functions to specify hook functions in Python */ - -static PyObject *startup_hook = NULL; -static PyThreadState *startup_hook_tstate = NULL; - -#ifdef HAVE_RL_PRE_INPUT_HOOK -static PyObject *pre_input_hook = NULL; -static PyThreadState *pre_input_hook_tstate = NULL; -#endif - -static PyObject * -set_startup_hook(PyObject *self, PyObject *args) -{ - return set_hook("startup_hook", &startup_hook, - &startup_hook_tstate, args); -} - -PyDoc_STRVAR(doc_set_startup_hook, -"set_startup_hook([function]) -> None\n\ -Set or remove the startup_hook function.\n\ -The function is called with no arguments just\n\ -before readline prints the first prompt."); - - -#ifdef HAVE_RL_PRE_INPUT_HOOK - -/* Set pre-input hook */ - -static PyObject * -set_pre_input_hook(PyObject *self, PyObject *args) -{ - return set_hook("pre_input_hook", &pre_input_hook, - &pre_input_hook_tstate, args); -} - -PyDoc_STRVAR(doc_set_pre_input_hook, -"set_pre_input_hook([function]) -> None\n\ -Set or remove the pre_input_hook function.\n\ -The function is called with no arguments after the first prompt\n\ -has been printed and just before readline starts reading input\n\ -characters."); - -#endif - - -/* Exported function to specify a word completer in Python */ - -static PyObject *completer = NULL; -static PyThreadState *completer_tstate = NULL; - -static PyObject *begidx = NULL; -static PyObject *endidx = NULL; - - -/* Get the beginning index for the scope of the tab-completion */ - -static PyObject * -get_begidx(PyObject *self, PyObject *noarg) -{ - Py_INCREF(begidx); - return begidx; -} - -PyDoc_STRVAR(doc_get_begidx, -"get_begidx() -> int\n\ -get the beginning index of the readline tab-completion scope"); - - -/* Get the ending index for the scope of the tab-completion */ - -static PyObject * -get_endidx(PyObject *self, PyObject *noarg) -{ - Py_INCREF(endidx); - return endidx; -} - -PyDoc_STRVAR(doc_get_endidx, -"get_endidx() -> int\n\ -get the ending index of the readline tab-completion scope"); - - -/* Set the tab-completion word-delimiters that readline uses */ - -static PyObject * -set_completer_delims(PyObject *self, PyObject *args) -{ - char *break_chars; - - if(!PyArg_ParseTuple(args, "s:set_completer_delims", &break_chars)) { - return NULL; - } - free((void*)rl_completer_word_break_characters); - rl_completer_word_break_characters = strdup(break_chars); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(doc_set_completer_delims, -"set_completer_delims(string) -> None\n\ -set the readline word delimiters for tab-completion"); - - -/* Add a line to the history buffer */ - -static PyObject * -py_add_history(PyObject *self, PyObject *args) -{ - char *line; - - if(!PyArg_ParseTuple(args, "s:add_history", &line)) { - return NULL; - } - add_history(line); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(doc_add_history, -"add_history(string) -> None\n\ -add a line to the history buffer"); - - -/* Get the tab-completion word-delimiters that readline uses */ - -static PyObject * -get_completer_delims(PyObject *self, PyObject *noarg) -{ - return PyString_FromString(rl_completer_word_break_characters); -} - -PyDoc_STRVAR(doc_get_completer_delims, -"get_completer_delims() -> string\n\ -get the readline word delimiters for tab-completion"); - - -/* Set the completer function */ - -static PyObject * -set_completer(PyObject *self, PyObject *args) -{ - return set_hook("completer", &completer, &completer_tstate, args); -} - -PyDoc_STRVAR(doc_set_completer, -"set_completer([function]) -> None\n\ -Set or remove the completer function.\n\ -The function is called as function(text, state),\n\ -for state in 0, 1, 2, ..., until it returns a non-string.\n\ -It should return the next possible completion starting with 'text'."); - - -static PyObject * -get_completer(PyObject *self, PyObject *noargs) -{ - if (completer == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - Py_INCREF(completer); - return completer; -} - -PyDoc_STRVAR(doc_get_completer, -"get_completer() -> function\n\ -\n\ -Returns current completer function."); - -/* Exported function to get any element of history */ - -static PyObject * -get_history_item(PyObject *self, PyObject *args) -{ - int idx = 0; - HIST_ENTRY *hist_ent; - - if (!PyArg_ParseTuple(args, "i:index", &idx)) - return NULL; - if ((hist_ent = history_get(idx))) - return PyString_FromString(hist_ent->line); - else { - Py_INCREF(Py_None); - return Py_None; - } -} - -PyDoc_STRVAR(doc_get_history_item, -"get_history_item() -> string\n\ -return the current contents of history item at index."); - - -/* Exported function to get current length of history */ - -static PyObject * -get_current_history_length(PyObject *self, PyObject *noarg) -{ - HISTORY_STATE *hist_st; - - hist_st = history_get_history_state(); - return PyInt_FromLong(hist_st ? (long) hist_st->length : (long) 0); -} - -PyDoc_STRVAR(doc_get_current_history_length, -"get_current_history_length() -> integer\n\ -return the current (not the maximum) length of history."); - - -/* Exported function to read the current line buffer */ - -static PyObject * -get_line_buffer(PyObject *self, PyObject *noarg) -{ - return PyString_FromString(rl_line_buffer); -} - -PyDoc_STRVAR(doc_get_line_buffer, -"get_line_buffer() -> string\n\ -return the current contents of the line buffer."); - - -/* Exported function to insert text into the line buffer */ - -static PyObject * -insert_text(PyObject *self, PyObject *args) -{ - char *s; - if (!PyArg_ParseTuple(args, "s:insert_text", &s)) - return NULL; - rl_insert_text(s); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(doc_insert_text, -"insert_text(string) -> None\n\ -Insert text into the command line."); - - -/* Redisplay the line buffer */ - -static PyObject * -redisplay(PyObject *self, PyObject *noarg) -{ - rl_redisplay(); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(doc_redisplay, -"redisplay() -> None\n\ -Change what's displayed on the screen to reflect the current\n\ -contents of the line buffer."); - - -/* Table of functions exported by the module */ - -static struct PyMethodDef readline_methods[] = -{ - {"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind}, - {"get_line_buffer", get_line_buffer, METH_NOARGS, doc_get_line_buffer}, - {"insert_text", insert_text, METH_VARARGS, doc_insert_text}, - {"redisplay", redisplay, METH_NOARGS, doc_redisplay}, - {"read_init_file", read_init_file, METH_VARARGS, doc_read_init_file}, - {"read_history_file", read_history_file, - METH_VARARGS, doc_read_history_file}, - {"write_history_file", write_history_file, - METH_VARARGS, doc_write_history_file}, - {"get_history_item", get_history_item, - METH_VARARGS, doc_get_history_item}, - {"get_current_history_length", (PyCFunction)get_current_history_length, - METH_NOARGS, doc_get_current_history_length}, - {"set_history_length", set_history_length, - METH_VARARGS, set_history_length_doc}, - {"get_history_length", get_history_length, - METH_NOARGS, get_history_length_doc}, - {"set_completer", set_completer, METH_VARARGS, doc_set_completer}, - {"get_completer", get_completer, METH_NOARGS, doc_get_completer}, - {"get_begidx", get_begidx, METH_NOARGS, doc_get_begidx}, - {"get_endidx", get_endidx, METH_NOARGS, doc_get_endidx}, - - {"set_completer_delims", set_completer_delims, - METH_VARARGS, doc_set_completer_delims}, - {"add_history", py_add_history, METH_VARARGS, doc_add_history}, - {"get_completer_delims", get_completer_delims, - METH_NOARGS, doc_get_completer_delims}, - - {"set_startup_hook", set_startup_hook, - METH_VARARGS, doc_set_startup_hook}, -#ifdef HAVE_RL_PRE_INPUT_HOOK - {"set_pre_input_hook", set_pre_input_hook, - METH_VARARGS, doc_set_pre_input_hook}, -#endif - {0, 0} -}; - - -/* C function to call the Python hooks. */ - -static int -on_hook(PyObject *func, PyThreadState **tstate) -{ - int result = 0; - if (func != NULL) { - PyObject *r; - /* Note that readline is called with the interpreter - lock released! */ - PyEval_RestoreThread(*tstate); - r = PyObject_CallFunction(func, NULL); - if (r == NULL) - goto error; - if (r == Py_None) - result = 0; - else - result = PyInt_AsLong(r); - Py_DECREF(r); - goto done; - error: - PyErr_Clear(); - Py_XDECREF(r); - done: - *tstate = PyEval_SaveThread(); - } - return result; -} - -static int -on_startup_hook(void) -{ - return on_hook(startup_hook, &startup_hook_tstate); -} - -#ifdef HAVE_RL_PRE_INPUT_HOOK -static int -on_pre_input_hook(void) -{ - return on_hook(pre_input_hook, &pre_input_hook_tstate); -} -#endif - - -/* C function to call the Python completer. */ - -static char * -on_completion(char *text, int state) -{ - char *result = NULL; - if (completer != NULL) { - PyObject *r; - /* Note that readline is called with the interpreter - lock released! */ - PyEval_RestoreThread(completer_tstate); - /* Don't use the default filename completion if we - * have a custom completion function... */ - rl_attempted_completion_over = 1; - r = PyObject_CallFunction(completer, "si", text, state); - if (r == NULL) - goto error; - if (r == Py_None) { - result = NULL; - } - else { - char *s = PyString_AsString(r); - if (s == NULL) - goto error; - result = strdup(s); - } - Py_DECREF(r); - goto done; - error: - PyErr_Clear(); - Py_XDECREF(r); - done: - completer_tstate = PyEval_SaveThread(); - } - return result; -} - - -/* A more flexible constructor that saves the "begidx" and "endidx" - * before calling the normal completer */ - -static char ** -flex_complete(char *text, int start, int end) -{ - Py_XDECREF(begidx); - Py_XDECREF(endidx); - begidx = PyInt_FromLong((long) start); - endidx = PyInt_FromLong((long) end); - return completion_matches(text, *on_completion); -} - - -/* Helper to initialize GNU readline properly. */ - -static void -setup_readline(void) -{ -#ifdef SAVE_LOCALE - char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); -#endif - - using_history(); - - rl_readline_name = "python"; -#if defined(PYOS_OS2) && defined(PYCC_GCC) - /* Allow $if term= in .inputrc to work */ - rl_terminal_name = getenv("TERM"); -#endif - /* Force rebind of TAB to insert-tab */ - rl_bind_key('\t', rl_insert); - /* Bind both ESC-TAB and ESC-ESC to the completion function */ - rl_bind_key_in_map ('\t', rl_complete, emacs_meta_keymap); - rl_bind_key_in_map ('\033', rl_complete, emacs_meta_keymap); - /* Set our hook functions */ - rl_startup_hook = (Function *)on_startup_hook; -#ifdef HAVE_RL_PRE_INPUT_HOOK - rl_pre_input_hook = (Function *)on_pre_input_hook; -#endif - /* Set our completion function */ - rl_attempted_completion_function = (CPPFunction *)flex_complete; - /* Set Python word break characters */ - rl_completer_word_break_characters = - strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?"); - /* All nonalphanums except '.' */ -#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER - rl_completion_append_character ='\0'; -#endif - - begidx = PyInt_FromLong(0L); - endidx = PyInt_FromLong(0L); - /* Initialize (allows .inputrc to override) - * - * XXX: A bug in the readline-2.2 library causes a memory leak - * inside this function. Nothing we can do about it. - */ - rl_initialize(); - -#ifdef SAVE_LOCALE - setlocale(LC_CTYPE, saved_locale); /* Restore locale */ - free(saved_locale); -#endif -} - - -/* Interrupt handler */ - -static jmp_buf jbuf; - -/* ARGSUSED */ -static void -onintr(int sig) -{ - longjmp(jbuf, 1); -} - - -/* Wrapper around GNU readline that handles signals differently. */ - -static char * -call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) -{ - size_t n; - char *p, *q; - PyOS_sighandler_t old_inthandler; - - old_inthandler = PyOS_setsig(SIGINT, onintr); - if (setjmp(jbuf)) { -#ifdef HAVE_SIGRELSE - /* This seems necessary on SunOS 4.1 (Rasmus Hahn) */ - sigrelse(SIGINT); -#endif - PyOS_setsig(SIGINT, old_inthandler); - return NULL; - } - rl_event_hook = PyOS_InputHook; - - if (sys_stdin != rl_instream || sys_stdout != rl_outstream) { - rl_instream = sys_stdin; - rl_outstream = sys_stdout; -#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER - rl_prep_terminal (1); -#endif - } - - p = readline(prompt); - PyOS_setsig(SIGINT, old_inthandler); - - /* We must return a buffer allocated with PyMem_Malloc. */ - if (p == NULL) { - p = PyMem_Malloc(1); - if (p != NULL) - *p = '\0'; - return p; - } - n = strlen(p); - if (n > 0) { - char *line; - HISTORY_STATE *state = history_get_history_state(); - if (state->length > 0) - line = history_get(state->length)->line; - else - line = ""; - if (strcmp(p, line)) - add_history(p); - /* the history docs don't say so, but the address of state - changes each time history_get_history_state is called - which makes me think it's freshly malloc'd memory... - on the other hand, the address of the last line stays the - same as long as history isn't extended, so it appears to - be malloc'd but managed by the history package... */ - free(state); - } - /* Copy the malloc'ed buffer into a PyMem_Malloc'ed one and - release the original. */ - q = p; - p = PyMem_Malloc(n+2); - if (p != NULL) { - strncpy(p, q, n); - p[n] = '\n'; - p[n+1] = '\0'; - } - free(q); - return p; -} - - -/* Initialize the module */ - -PyDoc_STRVAR(doc_module, -"Importing this module enables command line editing using GNU readline."); - -PyMODINIT_FUNC -initreadline(void) -{ - PyObject *m; - - m = Py_InitModule4("readline", readline_methods, doc_module, - (PyObject *)NULL, PYTHON_API_VERSION); - - PyOS_ReadlineFunctionPointer = call_readline; - setup_readline(); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/regexmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/regexmodule.c deleted file mode 100644 index 4938737e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/regexmodule.c +++ /dev/null @@ -1,689 +0,0 @@ -/* -XXX support range parameter on search -XXX support mstop parameter on search -*/ - - -/* Regular expression objects */ -/* This uses Tatu Ylonen's copyleft-free reimplementation of - GNU regular expressions */ - -#include "Python.h" - -#include - -#include "regexpr.h" - -static PyObject *RegexError; /* Exception */ - -typedef struct { - PyObject_HEAD - struct re_pattern_buffer re_patbuf; /* The compiled expression */ - struct re_registers re_regs; /* The registers from the last match */ - char re_fastmap[256]; /* Storage for fastmap */ - PyObject *re_translate; /* String object for translate table */ - PyObject *re_lastok; /* String object last matched/searched */ - PyObject *re_groupindex; /* Group name to index dictionary */ - PyObject *re_givenpat; /* Pattern with symbolic groups */ - PyObject *re_realpat; /* Pattern without symbolic groups */ -} regexobject; - -/* Regex object methods */ - -static void -reg_dealloc(regexobject *re) -{ - if (re->re_patbuf.buffer) - free(re->re_patbuf.buffer); - Py_XDECREF(re->re_translate); - Py_XDECREF(re->re_lastok); - Py_XDECREF(re->re_groupindex); - Py_XDECREF(re->re_givenpat); - Py_XDECREF(re->re_realpat); - PyObject_Del(re); -} - -static PyObject * -makeresult(struct re_registers *regs) -{ - PyObject *v; - int i; - static PyObject *filler = NULL; - - if (filler == NULL) { - filler = Py_BuildValue("(ii)", -1, -1); - if (filler == NULL) - return NULL; - } - v = PyTuple_New(RE_NREGS); - if (v == NULL) - return NULL; - - for (i = 0; i < RE_NREGS; i++) { - int lo = regs->start[i]; - int hi = regs->end[i]; - PyObject *w; - if (lo == -1 && hi == -1) { - w = filler; - Py_INCREF(w); - } - else - w = Py_BuildValue("(ii)", lo, hi); - if (w == NULL || PyTuple_SetItem(v, i, w) < 0) { - Py_DECREF(v); - return NULL; - } - } - return v; -} - -static PyObject * -regobj_match(regexobject *re, PyObject *args) -{ - PyObject *argstring; - char *buffer; - int size; - int offset = 0; - int result; - - if (!PyArg_ParseTuple(args, "O|i:match", &argstring, &offset)) - return NULL; - if (!PyArg_Parse(argstring, "t#", &buffer, &size)) - return NULL; - - if (offset < 0 || offset > size) { - PyErr_SetString(RegexError, "match offset out of range"); - return NULL; - } - Py_XDECREF(re->re_lastok); - re->re_lastok = NULL; - result = _Py_re_match(&re->re_patbuf, (unsigned char *)buffer, size, offset, - &re->re_regs); - if (result < -1) { - /* Serious failure of some sort; if re_match didn't - set an exception, raise a generic error */ - if (!PyErr_Occurred()) - PyErr_SetString(RegexError, "match failure"); - return NULL; - } - if (result >= 0) { - Py_INCREF(argstring); - re->re_lastok = argstring; - } - return PyInt_FromLong((long)result); /* Length of the match or -1 */ -} - -static PyObject * -regobj_search(regexobject *re, PyObject *args) -{ - PyObject *argstring; - char *buffer; - int size; - int offset = 0; - int range; - int result; - - if (!PyArg_ParseTuple(args, "O|i:search", &argstring, &offset)) - return NULL; - if (!PyArg_Parse(argstring, "t#:search", &buffer, &size)) - return NULL; - - if (offset < 0 || offset > size) { - PyErr_SetString(RegexError, "search offset out of range"); - return NULL; - } - /* NB: In Emacs 18.57, the documentation for re_search[_2] and - the implementation don't match: the documentation states that - |range| positions are tried, while the code tries |range|+1 - positions. It seems more productive to believe the code! */ - range = size - offset; - Py_XDECREF(re->re_lastok); - re->re_lastok = NULL; - result = _Py_re_search(&re->re_patbuf, (unsigned char *)buffer, size, offset, range, - &re->re_regs); - if (result < -1) { - /* Serious failure of some sort; if re_match didn't - set an exception, raise a generic error */ - if (!PyErr_Occurred()) - PyErr_SetString(RegexError, "match failure"); - return NULL; - } - if (result >= 0) { - Py_INCREF(argstring); - re->re_lastok = argstring; - } - return PyInt_FromLong((long)result); /* Position of the match or -1 */ -} - -/* get the group from the regex where index can be a string (group name) or - an integer index [0 .. 99] - */ -static PyObject* -group_from_index(regexobject *re, PyObject *index) -{ - int i, a, b; - char *v; - - if (PyString_Check(index)) - if (re->re_groupindex == NULL || - !(index = PyDict_GetItem(re->re_groupindex, index))) - { - PyErr_SetString(RegexError, - "group() group name doesn't exist"); - return NULL; - } - - i = PyInt_AsLong(index); - if (i == -1 && PyErr_Occurred()) - return NULL; - - if (i < 0 || i >= RE_NREGS) { - PyErr_SetString(RegexError, "group() index out of range"); - return NULL; - } - if (re->re_lastok == NULL) { - PyErr_SetString(RegexError, - "group() only valid after successful match/search"); - return NULL; - } - a = re->re_regs.start[i]; - b = re->re_regs.end[i]; - if (a < 0 || b < 0) { - Py_INCREF(Py_None); - return Py_None; - } - - if (!(v = PyString_AsString(re->re_lastok))) - return NULL; - - return PyString_FromStringAndSize(v+a, b-a); -} - - -static PyObject * -regobj_group(regexobject *re, PyObject *args) -{ - int n = PyTuple_Size(args); - int i; - PyObject *res = NULL; - - if (n < 0) - return NULL; - if (n == 0) { - PyErr_SetString(PyExc_TypeError, "not enough arguments"); - return NULL; - } - if (n == 1) { - /* return value is a single string */ - PyObject *index = PyTuple_GetItem(args, 0); - if (!index) - return NULL; - - return group_from_index(re, index); - } - - /* return value is a tuple */ - if (!(res = PyTuple_New(n))) - return NULL; - - for (i = 0; i < n; i++) { - PyObject *index = PyTuple_GetItem(args, i); - PyObject *group = NULL; - - if (!index) - goto finally; - if (!(group = group_from_index(re, index))) - goto finally; - if (PyTuple_SetItem(res, i, group) < 0) - goto finally; - } - return res; - - finally: - Py_DECREF(res); - return NULL; -} - - -static struct PyMethodDef reg_methods[] = { - {"match", (PyCFunction)regobj_match, METH_VARARGS}, - {"search", (PyCFunction)regobj_search, METH_VARARGS}, - {"group", (PyCFunction)regobj_group, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - - - -static char* members[] = { - "last", "regs", "translate", - "groupindex", "realpat", "givenpat", - NULL -}; - - -static PyObject * -regobj_getattr(regexobject *re, char *name) -{ - if (strcmp(name, "regs") == 0) { - if (re->re_lastok == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return makeresult(&re->re_regs); - } - if (strcmp(name, "last") == 0) { - if (re->re_lastok == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - Py_INCREF(re->re_lastok); - return re->re_lastok; - } - if (strcmp(name, "translate") == 0) { - if (re->re_translate == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - Py_INCREF(re->re_translate); - return re->re_translate; - } - if (strcmp(name, "groupindex") == 0) { - if (re->re_groupindex == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - Py_INCREF(re->re_groupindex); - return re->re_groupindex; - } - if (strcmp(name, "realpat") == 0) { - if (re->re_realpat == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - Py_INCREF(re->re_realpat); - return re->re_realpat; - } - if (strcmp(name, "givenpat") == 0) { - if (re->re_givenpat == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - Py_INCREF(re->re_givenpat); - return re->re_givenpat; - } - if (strcmp(name, "__members__") == 0) { - int i = 0; - PyObject *list = NULL; - - /* okay, so it's unlikely this list will change that often. - still, it's easier to change it in just one place. - */ - while (members[i]) - i++; - if (!(list = PyList_New(i))) - return NULL; - - i = 0; - while (members[i]) { - PyObject* v = PyString_FromString(members[i]); - if (!v || PyList_SetItem(list, i, v) < 0) { - Py_DECREF(list); - return NULL; - } - i++; - } - return list; - } - return Py_FindMethod(reg_methods, (PyObject *)re, name); -} - -static PyTypeObject Regextype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "regex.regex", /*tp_name*/ - sizeof(regexobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)reg_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)regobj_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ -}; - -/* reference counting invariants: - pattern: borrowed - translate: borrowed - givenpat: borrowed - groupindex: transferred -*/ -static PyObject * -newregexobject(PyObject *pattern, PyObject *translate, PyObject *givenpat, PyObject *groupindex) -{ - regexobject *re; - char *pat; - int size; - - if (!PyArg_Parse(pattern, "t#", &pat, &size)) - return NULL; - - if (translate != NULL && PyString_Size(translate) != 256) { - PyErr_SetString(RegexError, - "translation table must be 256 bytes"); - return NULL; - } - re = PyObject_New(regexobject, &Regextype); - if (re != NULL) { - char *error; - re->re_patbuf.buffer = NULL; - re->re_patbuf.allocated = 0; - re->re_patbuf.fastmap = (unsigned char *)re->re_fastmap; - if (translate) { - re->re_patbuf.translate = (unsigned char *)PyString_AsString(translate); - if (!re->re_patbuf.translate) - goto finally; - Py_INCREF(translate); - } - else - re->re_patbuf.translate = NULL; - re->re_translate = translate; - re->re_lastok = NULL; - re->re_groupindex = groupindex; - Py_INCREF(pattern); - re->re_realpat = pattern; - Py_INCREF(givenpat); - re->re_givenpat = givenpat; - error = _Py_re_compile_pattern((unsigned char *)pat, size, &re->re_patbuf); - if (error != NULL) { - PyErr_SetString(RegexError, error); - goto finally; - } - } - return (PyObject *)re; - finally: - Py_DECREF(re); - return NULL; -} - -static PyObject * -regex_compile(PyObject *self, PyObject *args) -{ - PyObject *pat = NULL; - PyObject *tran = NULL; - - if (!PyArg_ParseTuple(args, "S|S:compile", &pat, &tran)) - return NULL; - return newregexobject(pat, tran, pat, NULL); -} - -static PyObject * -symcomp(PyObject *pattern, PyObject *gdict) -{ - char *opat, *oend, *o, *n, *g, *v; - int group_count = 0; - int sz; - int escaped = 0; - char name_buf[128]; - PyObject *npattern; - int require_escape = re_syntax & RE_NO_BK_PARENS ? 0 : 1; - - if (!(opat = PyString_AsString(pattern))) - return NULL; - - if ((sz = PyString_Size(pattern)) < 0) - return NULL; - - oend = opat + sz; - o = opat; - - if (oend == opat) { - Py_INCREF(pattern); - return pattern; - } - - if (!(npattern = PyString_FromStringAndSize((char*)NULL, sz)) || - !(n = PyString_AsString(npattern))) - return NULL; - - while (o < oend) { - if (*o == '(' && escaped == require_escape) { - char *backtrack; - escaped = 0; - ++group_count; - *n++ = *o; - if (++o >= oend || *o != '<') - continue; - /* *o == '<' */ - if (o+1 < oend && *(o+1) == '>') - continue; - backtrack = o; - g = name_buf; - for (++o; o < oend;) { - if (*o == '>') { - PyObject *group_name = NULL; - PyObject *group_index = NULL; - *g++ = '\0'; - group_name = PyString_FromString(name_buf); - group_index = PyInt_FromLong(group_count); - if (group_name == NULL || - group_index == NULL || - PyDict_SetItem(gdict, group_name, - group_index) != 0) - { - Py_XDECREF(group_name); - Py_XDECREF(group_index); - Py_XDECREF(npattern); - return NULL; - } - Py_DECREF(group_name); - Py_DECREF(group_index); - ++o; /* eat the '>' */ - break; - } - if (!isalnum(Py_CHARMASK(*o)) && *o != '_') { - o = backtrack; - break; - } - *g++ = *o++; - } - } - else if (*o == '[' && !escaped) { - *n++ = *o; - ++o; /* eat the char following '[' */ - *n++ = *o; - while (o < oend && *o != ']') { - ++o; - *n++ = *o; - } - if (o < oend) - ++o; - } - else if (*o == '\\') { - escaped = 1; - *n++ = *o; - ++o; - } - else { - escaped = 0; - *n++ = *o; - ++o; - } - } - - if (!(v = PyString_AsString(npattern))) { - Py_DECREF(npattern); - return NULL; - } - /* _PyString_Resize() decrements npattern on failure */ - _PyString_Resize(&npattern, n - v); - return npattern; - -} - -static PyObject * -regex_symcomp(PyObject *self, PyObject *args) -{ - PyObject *pattern; - PyObject *tran = NULL; - PyObject *gdict = NULL; - PyObject *npattern; - PyObject *retval = NULL; - - if (!PyArg_ParseTuple(args, "S|S:symcomp", &pattern, &tran)) - return NULL; - - gdict = PyDict_New(); - if (gdict == NULL || (npattern = symcomp(pattern, gdict)) == NULL) { - Py_DECREF(gdict); - Py_DECREF(pattern); - return NULL; - } - retval = newregexobject(npattern, tran, pattern, gdict); - Py_DECREF(npattern); - return retval; -} - - -static PyObject *cache_pat; -static PyObject *cache_prog; - -static int -update_cache(PyObject *pat) -{ - PyObject *tuple = Py_BuildValue("(O)", pat); - int status = 0; - - if (!tuple) - return -1; - - if (pat != cache_pat) { - Py_XDECREF(cache_pat); - cache_pat = NULL; - Py_XDECREF(cache_prog); - cache_prog = regex_compile((PyObject *)NULL, tuple); - if (cache_prog == NULL) { - status = -1; - goto finally; - } - cache_pat = pat; - Py_INCREF(cache_pat); - } - finally: - Py_DECREF(tuple); - return status; -} - -static PyObject * -regex_match(PyObject *self, PyObject *args) -{ - PyObject *pat, *string; - PyObject *tuple, *v; - - if (!PyArg_ParseTuple(args, "SS:match", &pat, &string)) - return NULL; - if (update_cache(pat) < 0) - return NULL; - - if (!(tuple = Py_BuildValue("(S)", string))) - return NULL; - v = regobj_match((regexobject *)cache_prog, tuple); - Py_DECREF(tuple); - return v; -} - -static PyObject * -regex_search(PyObject *self, PyObject *args) -{ - PyObject *pat, *string; - PyObject *tuple, *v; - - if (!PyArg_ParseTuple(args, "SS:search", &pat, &string)) - return NULL; - if (update_cache(pat) < 0) - return NULL; - - if (!(tuple = Py_BuildValue("(S)", string))) - return NULL; - v = regobj_search((regexobject *)cache_prog, tuple); - Py_DECREF(tuple); - return v; -} - -static PyObject * -regex_set_syntax(PyObject *self, PyObject *args) -{ - int syntax; - if (!PyArg_ParseTuple(args, "i:set_syntax", &syntax)) - return NULL; - syntax = re_set_syntax(syntax); - /* wipe the global pattern cache */ - Py_XDECREF(cache_pat); - cache_pat = NULL; - Py_XDECREF(cache_prog); - cache_prog = NULL; - return PyInt_FromLong((long)syntax); -} - -static PyObject * -regex_get_syntax(PyObject *self) -{ - return PyInt_FromLong((long)re_syntax); -} - - -static struct PyMethodDef regex_global_methods[] = { - {"compile", regex_compile, METH_VARARGS}, - {"symcomp", regex_symcomp, METH_VARARGS}, - {"match", regex_match, METH_VARARGS}, - {"search", regex_search, METH_VARARGS}, - {"set_syntax", regex_set_syntax, METH_VARARGS}, - {"get_syntax", (PyCFunction)regex_get_syntax, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - -PyMODINIT_FUNC -initregex(void) -{ - PyObject *m, *d, *v; - int i; - char *s; - - /* Initialize object type */ - Regextype.ob_type = &PyType_Type; - - m = Py_InitModule("regex", regex_global_methods); - d = PyModule_GetDict(m); - - if (PyErr_Warn(PyExc_DeprecationWarning, - "the regex module is deprecated; " - "please use the re module") < 0) - return; - - /* Initialize regex.error exception */ - v = RegexError = PyErr_NewException("regex.error", NULL, NULL); - if (v == NULL || PyDict_SetItemString(d, "error", v) != 0) - goto finally; - - /* Initialize regex.casefold constant */ - if (!(v = PyString_FromStringAndSize((char *)NULL, 256))) - goto finally; - - if (!(s = PyString_AsString(v))) - goto finally; - - for (i = 0; i < 256; i++) { - if (isupper(i)) - s[i] = tolower(i); - else - s[i] = i; - } - if (PyDict_SetItemString(d, "casefold", v) < 0) - goto finally; - Py_DECREF(v); - - if (!PyErr_Occurred()) - return; - finally: - /* Nothing */ ; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/regexpr.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/regexpr.c deleted file mode 100644 index 6a9b67a9..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/regexpr.c +++ /dev/null @@ -1,2094 +0,0 @@ -/* regexpr.c - * - * Author: Tatu Ylonen - * - * Copyright (c) 1991 Tatu Ylonen, Espoo, Finland - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies. - * This software is provided "as is" without express or implied - * warranty. - * - * Created: Thu Sep 26 17:14:05 1991 ylo - * Last modified: Mon Nov 4 17:06:48 1991 ylo - * Ported to Think C: 19 Jan 1992 guido@cwi.nl - * - * This code draws many ideas from the regular expression packages by - * Henry Spencer of the University of Toronto and Richard Stallman of - * the Free Software Foundation. - * - * Emacs-specific code and syntax table code is almost directly borrowed - * from GNU regexp. - * - * Bugs fixed and lots of reorganization by Jeffrey C. Ollie, April - * 1997 Thanks for bug reports and ideas from Andrew Kuchling, Tim - * Peters, Guido van Rossum, Ka-Ping Yee, Sjoerd Mullender, and - * probably one or two others that I'm forgetting. - * - * $Id: regexpr.c,v 1.36 2002/08/07 16:21:51 loewis Exp $ */ - -#include "Python.h" -#include "regexpr.h" - -/* The original code blithely assumed that sizeof(short) == 2. Not - * always true. Original instances of "(short)x" were replaced by - * SHORT(x), where SHORT is #defined below. */ - -#define SHORT(x) ((x) & 0x8000 ? (x) - 0x10000 : (x)) - -/* The stack implementation is taken from an idea by Andrew Kuchling. - * It's a doubly linked list of arrays. The advantages of this over a - * simple linked list are that the number of mallocs required are - * reduced. It also makes it possible to statically allocate enough - * space so that small patterns don't ever need to call malloc. - * - * The advantages over a single array is that is periodically - * realloced when more space is needed is that we avoid ever copying - * the stack. */ - -/* item_t is the basic stack element. Defined as a union of - * structures so that both registers, failure points, and counters can - * be pushed/popped from the stack. There's nothing built into the - * item to keep track of whether a certain stack item is a register, a - * failure point, or a counter. */ - -typedef union item_t -{ - struct - { - int num; - int level; - unsigned char *start; - unsigned char *end; - } reg; - struct - { - int count; - int level; - int phantom; - unsigned char *code; - unsigned char *text; - } fail; - struct - { - int num; - int level; - int count; - } cntr; -} item_t; - -#define STACK_PAGE_SIZE 256 -#define NUM_REGISTERS 256 - -/* A 'page' of stack items. */ - -typedef struct item_page_t -{ - item_t items[STACK_PAGE_SIZE]; - struct item_page_t *prev; - struct item_page_t *next; -} item_page_t; - - -typedef struct match_state -{ - /* The number of registers that have been pushed onto the stack - * since the last failure point. */ - - int count; - - /* Used to control when registers need to be pushed onto the - * stack. */ - - int level; - - /* The number of failure points on the stack. */ - - int point; - - /* Storage for the registers. Each register consists of two - * pointers to characters. So register N is represented as - * start[N] and end[N]. The pointers must be converted to - * offsets from the beginning of the string before returning the - * registers to the calling program. */ - - unsigned char *start[NUM_REGISTERS]; - unsigned char *end[NUM_REGISTERS]; - - /* Keeps track of whether a register has changed recently. */ - - int changed[NUM_REGISTERS]; - - /* Structure to encapsulate the stack. */ - struct - { - /* index into the current page. If index == 0 and you need - * to pop an item, move to the previous page and set index - * = STACK_PAGE_SIZE - 1. Otherwise decrement index to - * push a page. If index == STACK_PAGE_SIZE and you need - * to push a page move to the next page and set index = - * 0. If there is no new next page, allocate a new page - * and link it in. Otherwise, increment index to push a - * page. */ - - int index; - item_page_t *current; /* Pointer to the current page. */ - item_page_t first; /* First page is statically allocated. */ - } stack; -} match_state; - -/* Initialize a state object */ - -/* #define NEW_STATE(state) \ */ -/* memset(&state, 0, (void *)(&state.stack) - (void *)(&state)); \ */ -/* state.stack.current = &state.stack.first; \ */ -/* state.stack.first.prev = NULL; \ */ -/* state.stack.first.next = NULL; \ */ -/* state.stack.index = 0; \ */ -/* state.level = 1 */ - -#define NEW_STATE(state, nregs) \ -{ \ - int i; \ - for (i = 0; i < nregs; i++) \ - { \ - state.start[i] = NULL; \ - state.end[i] = NULL; \ - state.changed[i] = 0; \ - } \ - state.stack.current = &state.stack.first; \ - state.stack.first.prev = NULL; \ - state.stack.first.next = NULL; \ - state.stack.index = 0; \ - state.level = 1; \ - state.count = 0; \ - state.level = 0; \ - state.point = 0; \ -} - -/* Free any memory that might have been malloc'd */ - -#define FREE_STATE(state) \ -while(state.stack.first.next != NULL) \ -{ \ - state.stack.current = state.stack.first.next; \ - state.stack.first.next = state.stack.current->next; \ - free(state.stack.current); \ -} - -/* Discard the top 'count' stack items. */ - -#define STACK_DISCARD(stack, count, on_error) \ -stack.index -= count; \ -while (stack.index < 0) \ -{ \ - if (stack.current->prev == NULL) \ - on_error; \ - stack.current = stack.current->prev; \ - stack.index += STACK_PAGE_SIZE; \ -} - -/* Store a pointer to the previous item on the stack. Used to pop an - * item off of the stack. */ - -#define STACK_PREV(stack, top, on_error) \ -if (stack.index == 0) \ -{ \ - if (stack.current->prev == NULL) \ - on_error; \ - stack.current = stack.current->prev; \ - stack.index = STACK_PAGE_SIZE - 1; \ -} \ -else \ -{ \ - stack.index--; \ -} \ -top = &(stack.current->items[stack.index]) - -/* Store a pointer to the next item on the stack. Used to push an item - * on to the stack. */ - -#define STACK_NEXT(stack, top, on_error) \ -if (stack.index == STACK_PAGE_SIZE) \ -{ \ - if (stack.current->next == NULL) \ - { \ - stack.current->next = (item_page_t *)malloc(sizeof(item_page_t)); \ - if (stack.current->next == NULL) \ - on_error; \ - stack.current->next->prev = stack.current; \ - stack.current->next->next = NULL; \ - } \ - stack.current = stack.current->next; \ - stack.index = 0; \ -} \ -top = &(stack.current->items[stack.index++]) - -/* Store a pointer to the item that is 'count' items back in the - * stack. STACK_BACK(stack, top, 1, on_error) is equivalent to - * STACK_TOP(stack, top, on_error). */ - -#define STACK_BACK(stack, top, count, on_error) \ -{ \ - int index; \ - item_page_t *current; \ - current = stack.current; \ - index = stack.index - (count); \ - while (index < 0) \ - { \ - if (current->prev == NULL) \ - on_error; \ - current = current->prev; \ - index += STACK_PAGE_SIZE; \ - } \ - top = &(current->items[index]); \ -} - -/* Store a pointer to the top item on the stack. Execute the - * 'on_error' code if there are no items on the stack. */ - -#define STACK_TOP(stack, top, on_error) \ -if (stack.index == 0) \ -{ \ - if (stack.current->prev == NULL) \ - on_error; \ - top = &(stack.current->prev->items[STACK_PAGE_SIZE - 1]); \ -} \ -else \ -{ \ - top = &(stack.current->items[stack.index - 1]); \ -} - -/* Test to see if the stack is empty */ - -#define STACK_EMPTY(stack) ((stack.index == 0) && \ - (stack.current->prev == NULL)) - -/* Return the start of register 'reg' */ - -#define GET_REG_START(state, reg) (state.start[reg]) - -/* Return the end of register 'reg' */ - -#define GET_REG_END(state, reg) (state.end[reg]) - -/* Set the start of register 'reg'. If the state of the register needs - * saving, push it on the stack. */ - -#define SET_REG_START(state, reg, text, on_error) \ -if(state.changed[reg] < state.level) \ -{ \ - item_t *item; \ - STACK_NEXT(state.stack, item, on_error); \ - item->reg.num = reg; \ - item->reg.start = state.start[reg]; \ - item->reg.end = state.end[reg]; \ - item->reg.level = state.changed[reg]; \ - state.changed[reg] = state.level; \ - state.count++; \ -} \ -state.start[reg] = text - -/* Set the end of register 'reg'. If the state of the register needs - * saving, push it on the stack. */ - -#define SET_REG_END(state, reg, text, on_error) \ -if(state.changed[reg] < state.level) \ -{ \ - item_t *item; \ - STACK_NEXT(state.stack, item, on_error); \ - item->reg.num = reg; \ - item->reg.start = state.start[reg]; \ - item->reg.end = state.end[reg]; \ - item->reg.level = state.changed[reg]; \ - state.changed[reg] = state.level; \ - state.count++; \ -} \ -state.end[reg] = text - -#define PUSH_FAILURE(state, xcode, xtext, on_error) \ -{ \ - item_t *item; \ - STACK_NEXT(state.stack, item, on_error); \ - item->fail.code = xcode; \ - item->fail.text = xtext; \ - item->fail.count = state.count; \ - item->fail.level = state.level; \ - item->fail.phantom = 0; \ - state.count = 0; \ - state.level++; \ - state.point++; \ -} - -/* Update the last failure point with a new position in the text. */ - -#define UPDATE_FAILURE(state, xtext, on_error) \ -{ \ - item_t *item; \ - STACK_BACK(state.stack, item, state.count + 1, on_error); \ - if (!item->fail.phantom) \ - { \ - item_t *item2; \ - STACK_NEXT(state.stack, item2, on_error); \ - item2->fail.code = item->fail.code; \ - item2->fail.text = xtext; \ - item2->fail.count = state.count; \ - item2->fail.level = state.level; \ - item2->fail.phantom = 1; \ - state.count = 0; \ - state.level++; \ - state.point++; \ - } \ - else \ - { \ - STACK_DISCARD(state.stack, state.count, on_error); \ - STACK_TOP(state.stack, item, on_error); \ - item->fail.text = xtext; \ - state.count = 0; \ - state.level++; \ - } \ -} - -#define POP_FAILURE(state, xcode, xtext, on_empty, on_error) \ -{ \ - item_t *item; \ - do \ - { \ - while(state.count > 0) \ - { \ - STACK_PREV(state.stack, item, on_error); \ - state.start[item->reg.num] = item->reg.start; \ - state.end[item->reg.num] = item->reg.end; \ - state.changed[item->reg.num] = item->reg.level; \ - state.count--; \ - } \ - STACK_PREV(state.stack, item, on_empty); \ - xcode = item->fail.code; \ - xtext = item->fail.text; \ - state.count = item->fail.count; \ - state.level = item->fail.level; \ - state.point--; \ - } \ - while (item->fail.text == NULL); \ -} - -enum regexp_compiled_ops /* opcodes for compiled regexp */ -{ - Cend, /* end of pattern reached */ - Cbol, /* beginning of line */ - Ceol, /* end of line */ - Cset, /* character set. Followed by 32 bytes of set. */ - Cexact, /* followed by a byte to match */ - Canychar, /* matches any character except newline */ - Cstart_memory, /* set register start addr (followed by reg number) */ - Cend_memory, /* set register end addr (followed by reg number) */ - Cmatch_memory, /* match a duplicate of reg contents (regnum follows)*/ - Cjump, /* followed by two bytes (lsb,msb) of displacement. */ - Cstar_jump, /* will change to jump/update_failure_jump at runtime */ - Cfailure_jump, /* jump to addr on failure */ - Cupdate_failure_jump, /* update topmost failure point and jump */ - Cdummy_failure_jump, /* push a dummy failure point and jump */ - Cbegbuf, /* match at beginning of buffer */ - Cendbuf, /* match at end of buffer */ - Cwordbeg, /* match at beginning of word */ - Cwordend, /* match at end of word */ - Cwordbound, /* match if at word boundary */ - Cnotwordbound, /* match if not at word boundary */ - Csyntaxspec, /* matches syntax code (1 byte follows) */ - Cnotsyntaxspec, /* matches if syntax code does not match (1 byte follows) */ - Crepeat1 -}; - -enum regexp_syntax_op /* syntax codes for plain and quoted characters */ -{ - Rend, /* special code for end of regexp */ - Rnormal, /* normal character */ - Ranychar, /* any character except newline */ - Rquote, /* the quote character */ - Rbol, /* match beginning of line */ - Reol, /* match end of line */ - Roptional, /* match preceding expression optionally */ - Rstar, /* match preceding expr zero or more times */ - Rplus, /* match preceding expr one or more times */ - Ror, /* match either of alternatives */ - Ropenpar, /* opening parenthesis */ - Rclosepar, /* closing parenthesis */ - Rmemory, /* match memory register */ - Rextended_memory, /* \vnn to match registers 10-99 */ - Ropenset, /* open set. Internal syntax hard-coded below. */ - /* the following are gnu extensions to "normal" regexp syntax */ - Rbegbuf, /* beginning of buffer */ - Rendbuf, /* end of buffer */ - Rwordchar, /* word character */ - Rnotwordchar, /* not word character */ - Rwordbeg, /* beginning of word */ - Rwordend, /* end of word */ - Rwordbound, /* word bound */ - Rnotwordbound, /* not word bound */ - Rnum_ops -}; - -static int re_compile_initialized = 0; -static int regexp_syntax = 0; -int re_syntax = 0; /* Exported copy of regexp_syntax */ -static unsigned char regexp_plain_ops[256]; -static unsigned char regexp_quoted_ops[256]; -static unsigned char regexp_precedences[Rnum_ops]; -static int regexp_context_indep_ops; -static int regexp_ansi_sequences; - -#define NUM_LEVELS 5 /* number of precedence levels in use */ -#define MAX_NESTING 100 /* max nesting level of operators */ - -#define SYNTAX(ch) re_syntax_table[(unsigned char)(ch)] - -unsigned char re_syntax_table[256]; - -void re_compile_initialize(void) -{ - int a; - - static int syntax_table_inited = 0; - - if (!syntax_table_inited) - { - syntax_table_inited = 1; - memset(re_syntax_table, 0, 256); - for (a = 'a'; a <= 'z'; a++) - re_syntax_table[a] = Sword; - for (a = 'A'; a <= 'Z'; a++) - re_syntax_table[a] = Sword; - for (a = '0'; a <= '9'; a++) - re_syntax_table[a] = Sword | Sdigit | Shexdigit; - for (a = '0'; a <= '7'; a++) - re_syntax_table[a] |= Soctaldigit; - for (a = 'A'; a <= 'F'; a++) - re_syntax_table[a] |= Shexdigit; - for (a = 'a'; a <= 'f'; a++) - re_syntax_table[a] |= Shexdigit; - re_syntax_table['_'] = Sword; - for (a = 9; a <= 13; a++) - re_syntax_table[a] = Swhitespace; - re_syntax_table[' '] = Swhitespace; - } - re_compile_initialized = 1; - for (a = 0; a < 256; a++) - { - regexp_plain_ops[a] = Rnormal; - regexp_quoted_ops[a] = Rnormal; - } - for (a = '0'; a <= '9'; a++) - regexp_quoted_ops[a] = Rmemory; - regexp_plain_ops['\134'] = Rquote; - if (regexp_syntax & RE_NO_BK_PARENS) - { - regexp_plain_ops['('] = Ropenpar; - regexp_plain_ops[')'] = Rclosepar; - } - else - { - regexp_quoted_ops['('] = Ropenpar; - regexp_quoted_ops[')'] = Rclosepar; - } - if (regexp_syntax & RE_NO_BK_VBAR) - regexp_plain_ops['\174'] = Ror; - else - regexp_quoted_ops['\174'] = Ror; - regexp_plain_ops['*'] = Rstar; - if (regexp_syntax & RE_BK_PLUS_QM) - { - regexp_quoted_ops['+'] = Rplus; - regexp_quoted_ops['?'] = Roptional; - } - else - { - regexp_plain_ops['+'] = Rplus; - regexp_plain_ops['?'] = Roptional; - } - if (regexp_syntax & RE_NEWLINE_OR) - regexp_plain_ops['\n'] = Ror; - regexp_plain_ops['\133'] = Ropenset; - regexp_plain_ops['\136'] = Rbol; - regexp_plain_ops['$'] = Reol; - regexp_plain_ops['.'] = Ranychar; - if (!(regexp_syntax & RE_NO_GNU_EXTENSIONS)) - { - regexp_quoted_ops['w'] = Rwordchar; - regexp_quoted_ops['W'] = Rnotwordchar; - regexp_quoted_ops['<'] = Rwordbeg; - regexp_quoted_ops['>'] = Rwordend; - regexp_quoted_ops['b'] = Rwordbound; - regexp_quoted_ops['B'] = Rnotwordbound; - regexp_quoted_ops['`'] = Rbegbuf; - regexp_quoted_ops['\''] = Rendbuf; - } - if (regexp_syntax & RE_ANSI_HEX) - regexp_quoted_ops['v'] = Rextended_memory; - for (a = 0; a < Rnum_ops; a++) - regexp_precedences[a] = 4; - if (regexp_syntax & RE_TIGHT_VBAR) - { - regexp_precedences[Ror] = 3; - regexp_precedences[Rbol] = 2; - regexp_precedences[Reol] = 2; - } - else - { - regexp_precedences[Ror] = 2; - regexp_precedences[Rbol] = 3; - regexp_precedences[Reol] = 3; - } - regexp_precedences[Rclosepar] = 1; - regexp_precedences[Rend] = 0; - regexp_context_indep_ops = (regexp_syntax & RE_CONTEXT_INDEP_OPS) != 0; - regexp_ansi_sequences = (regexp_syntax & RE_ANSI_HEX) != 0; -} - -int re_set_syntax(int syntax) -{ - int ret; - - ret = regexp_syntax; - regexp_syntax = syntax; - re_syntax = syntax; /* Exported copy */ - re_compile_initialize(); - return ret; -} - -static int hex_char_to_decimal(int ch) -{ - if (ch >= '0' && ch <= '9') - return ch - '0'; - if (ch >= 'a' && ch <= 'f') - return ch - 'a' + 10; - if (ch >= 'A' && ch <= 'F') - return ch - 'A' + 10; - return 16; -} - -static void re_compile_fastmap_aux(unsigned char *code, int pos, - unsigned char *visited, - unsigned char *can_be_null, - unsigned char *fastmap) -{ - int a; - int b; - int syntaxcode; - - if (visited[pos]) - return; /* we have already been here */ - visited[pos] = 1; - for (;;) - switch (code[pos++]) { - case Cend: - { - *can_be_null = 1; - return; - } - case Cbol: - case Cbegbuf: - case Cendbuf: - case Cwordbeg: - case Cwordend: - case Cwordbound: - case Cnotwordbound: - { - for (a = 0; a < 256; a++) - fastmap[a] = 1; - break; - } - case Csyntaxspec: - { - syntaxcode = code[pos++]; - for (a = 0; a < 256; a++) - if (SYNTAX(a) & syntaxcode) - fastmap[a] = 1; - return; - } - case Cnotsyntaxspec: - { - syntaxcode = code[pos++]; - for (a = 0; a < 256; a++) - if (!(SYNTAX(a) & syntaxcode) ) - fastmap[a] = 1; - return; - } - case Ceol: - { - fastmap['\n'] = 1; - if (*can_be_null == 0) - *can_be_null = 2; /* can match null, but only at end of buffer*/ - return; - } - case Cset: - { - for (a = 0; a < 256/8; a++) - if (code[pos + a] != 0) - for (b = 0; b < 8; b++) - if (code[pos + a] & (1 << b)) - fastmap[(a << 3) + b] = 1; - pos += 256/8; - return; - } - case Cexact: - { - fastmap[(unsigned char)code[pos]] = 1; - return; - } - case Canychar: - { - for (a = 0; a < 256; a++) - if (a != '\n') - fastmap[a] = 1; - return; - } - case Cstart_memory: - case Cend_memory: - { - pos++; - break; - } - case Cmatch_memory: - { - for (a = 0; a < 256; a++) - fastmap[a] = 1; - *can_be_null = 1; - return; - } - case Cjump: - case Cdummy_failure_jump: - case Cupdate_failure_jump: - case Cstar_jump: - { - a = (unsigned char)code[pos++]; - a |= (unsigned char)code[pos++] << 8; - pos += (int)SHORT(a); - if (visited[pos]) - { - /* argh... the regexp contains empty loops. This is not - good, as this may cause a failure stack overflow when - matching. Oh well. */ - /* this path leads nowhere; pursue other paths. */ - return; - } - visited[pos] = 1; - break; - } - case Cfailure_jump: - { - a = (unsigned char)code[pos++]; - a |= (unsigned char)code[pos++] << 8; - a = pos + (int)SHORT(a); - re_compile_fastmap_aux(code, a, visited, can_be_null, fastmap); - break; - } - case Crepeat1: - { - pos += 2; - break; - } - default: - { - PyErr_SetString(PyExc_SystemError, "Unknown regex opcode: memory corrupted?"); - return; - /*NOTREACHED*/ - } - } -} - -static int re_do_compile_fastmap(unsigned char *buffer, int used, int pos, - unsigned char *can_be_null, - unsigned char *fastmap) -{ - unsigned char small_visited[512], *visited; - - if (used <= sizeof(small_visited)) - visited = small_visited; - else - { - visited = malloc(used); - if (!visited) - return 0; - } - *can_be_null = 0; - memset(fastmap, 0, 256); - memset(visited, 0, used); - re_compile_fastmap_aux(buffer, pos, visited, can_be_null, fastmap); - if (visited != small_visited) - free(visited); - return 1; -} - -void re_compile_fastmap(regexp_t bufp) -{ - if (!bufp->fastmap || bufp->fastmap_accurate) - return; - assert(bufp->used > 0); - if (!re_do_compile_fastmap(bufp->buffer, - bufp->used, - 0, - &bufp->can_be_null, - bufp->fastmap)) - return; - if (PyErr_Occurred()) return; - if (bufp->buffer[0] == Cbol) - bufp->anchor = 1; /* begline */ - else - if (bufp->buffer[0] == Cbegbuf) - bufp->anchor = 2; /* begbuf */ - else - bufp->anchor = 0; /* none */ - bufp->fastmap_accurate = 1; -} - -/* - * star is coded as: - * 1: failure_jump 2 - * ... code for operand of star - * star_jump 1 - * 2: ... code after star - * - * We change the star_jump to update_failure_jump if we can determine - * that it is safe to do so; otherwise we change it to an ordinary - * jump. - * - * plus is coded as - * - * jump 2 - * 1: failure_jump 3 - * 2: ... code for operand of plus - * star_jump 1 - * 3: ... code after plus - * - * For star_jump considerations this is processed identically to star. - * - */ - -static int re_optimize_star_jump(regexp_t bufp, unsigned char *code) -{ - unsigned char map[256]; - unsigned char can_be_null; - unsigned char *p1; - unsigned char *p2; - unsigned char ch; - int a; - int b; - int num_instructions = 0; - - a = (unsigned char)*code++; - a |= (unsigned char)*code++ << 8; - a = (int)SHORT(a); - - p1 = code + a + 3; /* skip the failure_jump */ - /* Check that the jump is within the pattern */ - if (p1buffer || bufp->buffer+bufp->usedbuffer, bufp->used, - (int)(p2 - bufp->buffer), - &can_be_null, map)) - goto make_normal_jump; - - /* If we might introduce a new update point inside the - * loop, we can't optimize because then update_jump would - * update a wrong failure point. Thus we have to be - * quite careful here. - */ - - /* loop until we find something that consumes a character */ - loop_p1: - num_instructions++; - switch (*p1++) - { - case Cbol: - case Ceol: - case Cbegbuf: - case Cendbuf: - case Cwordbeg: - case Cwordend: - case Cwordbound: - case Cnotwordbound: - { - goto loop_p1; - } - case Cstart_memory: - case Cend_memory: - { - p1++; - goto loop_p1; - } - case Cexact: - { - ch = (unsigned char)*p1++; - if (map[(int)ch]) - goto make_normal_jump; - break; - } - case Canychar: - { - for (b = 0; b < 256; b++) - if (b != '\n' && map[b]) - goto make_normal_jump; - break; - } - case Cset: - { - for (b = 0; b < 256; b++) - if ((p1[b >> 3] & (1 << (b & 7))) && map[b]) - goto make_normal_jump; - p1 += 256/8; - break; - } - default: - { - goto make_normal_jump; - } - } - /* now we know that we can't backtrack. */ - while (p1 != p2 - 3) - { - num_instructions++; - switch (*p1++) - { - case Cend: - { - return 0; - } - case Cbol: - case Ceol: - case Canychar: - case Cbegbuf: - case Cendbuf: - case Cwordbeg: - case Cwordend: - case Cwordbound: - case Cnotwordbound: - { - break; - } - case Cset: - { - p1 += 256/8; - break; - } - case Cexact: - case Cstart_memory: - case Cend_memory: - case Cmatch_memory: - case Csyntaxspec: - case Cnotsyntaxspec: - { - p1++; - break; - } - case Cjump: - case Cstar_jump: - case Cfailure_jump: - case Cupdate_failure_jump: - case Cdummy_failure_jump: - { - goto make_normal_jump; - } - default: - { - return 0; - } - } - } - - /* make_update_jump: */ - code -= 3; - a += 3; /* jump to after the Cfailure_jump */ - code[0] = Cupdate_failure_jump; - code[1] = a & 0xff; - code[2] = a >> 8; - if (num_instructions > 1) - return 1; - assert(num_instructions == 1); - /* if the only instruction matches a single character, we can do - * better */ - p1 = code + 3 + a; /* start of sole instruction */ - if (*p1 == Cset || *p1 == Cexact || *p1 == Canychar || - *p1 == Csyntaxspec || *p1 == Cnotsyntaxspec) - code[0] = Crepeat1; - return 1; - - make_normal_jump: - code -= 3; - *code = Cjump; - return 1; -} - -static int re_optimize(regexp_t bufp) -{ - unsigned char *code; - - code = bufp->buffer; - - while(1) - { - switch (*code++) - { - case Cend: - { - return 1; - } - case Canychar: - case Cbol: - case Ceol: - case Cbegbuf: - case Cendbuf: - case Cwordbeg: - case Cwordend: - case Cwordbound: - case Cnotwordbound: - { - break; - } - case Cset: - { - code += 256/8; - break; - } - case Cexact: - case Cstart_memory: - case Cend_memory: - case Cmatch_memory: - case Csyntaxspec: - case Cnotsyntaxspec: - { - code++; - break; - } - case Cstar_jump: - { - if (!re_optimize_star_jump(bufp, code)) - { - return 0; - } - /* fall through */ - } - case Cupdate_failure_jump: - case Cjump: - case Cdummy_failure_jump: - case Cfailure_jump: - case Crepeat1: - { - code += 2; - break; - } - default: - { - return 0; - } - } - } -} - -#define NEXTCHAR(var) \ -{ \ - if (pos >= size) \ - goto ends_prematurely; \ - (var) = regex[pos]; \ - pos++; \ -} - -#define ALLOC(amount) \ -{ \ - if (pattern_offset+(amount) > alloc) \ - { \ - alloc += 256 + (amount); \ - pattern = realloc(pattern, alloc); \ - if (!pattern) \ - goto out_of_memory; \ - } \ -} - -#define STORE(ch) pattern[pattern_offset++] = (ch) - -#define CURRENT_LEVEL_START (starts[starts_base + current_level]) - -#define SET_LEVEL_START starts[starts_base + current_level] = pattern_offset - -#define PUSH_LEVEL_STARTS \ -if (starts_base < (MAX_NESTING-1)*NUM_LEVELS) \ - starts_base += NUM_LEVELS; \ -else \ - goto too_complex \ - -#define POP_LEVEL_STARTS starts_base -= NUM_LEVELS - -#define PUT_ADDR(offset,addr) \ -{ \ - int disp = (addr) - (offset) - 2; \ - pattern[(offset)] = disp & 0xff; \ - pattern[(offset)+1] = (disp>>8) & 0xff; \ -} - -#define INSERT_JUMP(pos,type,addr) \ -{ \ - int a, p = (pos), t = (type), ad = (addr); \ - for (a = pattern_offset - 1; a >= p; a--) \ - pattern[a + 3] = pattern[a]; \ - pattern[p] = t; \ - PUT_ADDR(p+1,ad); \ - pattern_offset += 3; \ -} - -#define SETBIT(buf,offset,bit) (buf)[(offset)+(bit)/8] |= (1<<((bit) & 7)) - -#define SET_FIELDS \ -{ \ - bufp->allocated = alloc; \ - bufp->buffer = pattern; \ - bufp->used = pattern_offset; \ -} - -#define GETHEX(var) \ -{ \ - unsigned char gethex_ch, gethex_value; \ - NEXTCHAR(gethex_ch); \ - gethex_value = hex_char_to_decimal(gethex_ch); \ - if (gethex_value == 16) \ - goto hex_error; \ - NEXTCHAR(gethex_ch); \ - gethex_ch = hex_char_to_decimal(gethex_ch); \ - if (gethex_ch == 16) \ - goto hex_error; \ - (var) = gethex_value * 16 + gethex_ch; \ -} - -#define ANSI_TRANSLATE(ch) \ -{ \ - switch (ch) \ - { \ - case 'a': \ - case 'A': \ - { \ - ch = 7; /* audible bell */ \ - break; \ - } \ - case 'b': \ - case 'B': \ - { \ - ch = 8; /* backspace */ \ - break; \ - } \ - case 'f': \ - case 'F': \ - { \ - ch = 12; /* form feed */ \ - break; \ - } \ - case 'n': \ - case 'N': \ - { \ - ch = 10; /* line feed */ \ - break; \ - } \ - case 'r': \ - case 'R': \ - { \ - ch = 13; /* carriage return */ \ - break; \ - } \ - case 't': \ - case 'T': \ - { \ - ch = 9; /* tab */ \ - break; \ - } \ - case 'v': \ - case 'V': \ - { \ - ch = 11; /* vertical tab */ \ - break; \ - } \ - case 'x': /* hex code */ \ - case 'X': \ - { \ - GETHEX(ch); \ - break; \ - } \ - default: \ - { \ - /* other characters passed through */ \ - if (translate) \ - ch = translate[(unsigned char)ch]; \ - break; \ - } \ - } \ -} - -char *re_compile_pattern(unsigned char *regex, int size, regexp_t bufp) -{ - int a; - int pos; - int op; - int current_level; - int level; - int opcode; - int pattern_offset = 0, alloc; - int starts[NUM_LEVELS * MAX_NESTING]; - int starts_base; - int future_jumps[MAX_NESTING]; - int num_jumps; - unsigned char ch = '\0'; - unsigned char *pattern; - unsigned char *translate; - int next_register; - int paren_depth; - int num_open_registers; - int open_registers[RE_NREGS]; - int beginning_context; - - if (!re_compile_initialized) - re_compile_initialize(); - bufp->used = 0; - bufp->fastmap_accurate = 0; - bufp->uses_registers = 1; - bufp->num_registers = 1; - translate = bufp->translate; - pattern = bufp->buffer; - alloc = bufp->allocated; - if (alloc == 0 || pattern == NULL) - { - alloc = 256; - pattern = malloc(alloc); - if (!pattern) - goto out_of_memory; - } - pattern_offset = 0; - starts_base = 0; - num_jumps = 0; - current_level = 0; - SET_LEVEL_START; - num_open_registers = 0; - next_register = 1; - paren_depth = 0; - beginning_context = 1; - op = -1; - /* we use Rend dummy to ensure that pending jumps are updated - (due to low priority of Rend) before exiting the loop. */ - pos = 0; - while (op != Rend) - { - if (pos >= size) - op = Rend; - else - { - NEXTCHAR(ch); - if (translate) - ch = translate[(unsigned char)ch]; - op = regexp_plain_ops[(unsigned char)ch]; - if (op == Rquote) - { - NEXTCHAR(ch); - op = regexp_quoted_ops[(unsigned char)ch]; - if (op == Rnormal && regexp_ansi_sequences) - ANSI_TRANSLATE(ch); - } - } - level = regexp_precedences[op]; - /* printf("ch='%c' op=%d level=%d current_level=%d - curlevstart=%d\n", ch, op, level, current_level, - CURRENT_LEVEL_START); */ - if (level > current_level) - { - for (current_level++; current_level < level; current_level++) - SET_LEVEL_START; - SET_LEVEL_START; - } - else - if (level < current_level) - { - current_level = level; - for (;num_jumps > 0 && - future_jumps[num_jumps-1] >= CURRENT_LEVEL_START; - num_jumps--) - PUT_ADDR(future_jumps[num_jumps-1], pattern_offset); - } - switch (op) - { - case Rend: - { - break; - } - case Rnormal: - { - normal_char: - opcode = Cexact; - store_opcode_and_arg: /* opcode & ch must be set */ - SET_LEVEL_START; - ALLOC(2); - STORE(opcode); - STORE(ch); - break; - } - case Ranychar: - { - opcode = Canychar; - store_opcode: - SET_LEVEL_START; - ALLOC(1); - STORE(opcode); - break; - } - case Rquote: - { - Py_FatalError("Rquote"); - /*NOTREACHED*/ - } - case Rbol: - { - if (!beginning_context) { - if (regexp_context_indep_ops) - goto op_error; - else - goto normal_char; - } - opcode = Cbol; - goto store_opcode; - } - case Reol: - { - if (!((pos >= size) || - ((regexp_syntax & RE_NO_BK_VBAR) ? - (regex[pos] == '\174') : - (pos+1 < size && regex[pos] == '\134' && - regex[pos+1] == '\174')) || - ((regexp_syntax & RE_NO_BK_PARENS)? - (regex[pos] == ')'): - (pos+1 < size && regex[pos] == '\134' && - regex[pos+1] == ')')))) { - if (regexp_context_indep_ops) - goto op_error; - else - goto normal_char; - } - opcode = Ceol; - goto store_opcode; - /* NOTREACHED */ - break; - } - case Roptional: - { - if (beginning_context) { - if (regexp_context_indep_ops) - goto op_error; - else - goto normal_char; - } - if (CURRENT_LEVEL_START == pattern_offset) - break; /* ignore empty patterns for ? */ - ALLOC(3); - INSERT_JUMP(CURRENT_LEVEL_START, Cfailure_jump, - pattern_offset + 3); - break; - } - case Rstar: - case Rplus: - { - if (beginning_context) { - if (regexp_context_indep_ops) - goto op_error; - else - goto normal_char; - } - if (CURRENT_LEVEL_START == pattern_offset) - break; /* ignore empty patterns for + and * */ - ALLOC(9); - INSERT_JUMP(CURRENT_LEVEL_START, Cfailure_jump, - pattern_offset + 6); - INSERT_JUMP(pattern_offset, Cstar_jump, CURRENT_LEVEL_START); - if (op == Rplus) /* jump over initial failure_jump */ - INSERT_JUMP(CURRENT_LEVEL_START, Cdummy_failure_jump, - CURRENT_LEVEL_START + 6); - break; - } - case Ror: - { - ALLOC(6); - INSERT_JUMP(CURRENT_LEVEL_START, Cfailure_jump, - pattern_offset + 6); - if (num_jumps >= MAX_NESTING) - goto too_complex; - STORE(Cjump); - future_jumps[num_jumps++] = pattern_offset; - STORE(0); - STORE(0); - SET_LEVEL_START; - break; - } - case Ropenpar: - { - SET_LEVEL_START; - if (next_register < RE_NREGS) - { - bufp->uses_registers = 1; - ALLOC(2); - STORE(Cstart_memory); - STORE(next_register); - open_registers[num_open_registers++] = next_register; - bufp->num_registers++; - next_register++; - } - paren_depth++; - PUSH_LEVEL_STARTS; - current_level = 0; - SET_LEVEL_START; - break; - } - case Rclosepar: - { - if (paren_depth <= 0) - goto parenthesis_error; - POP_LEVEL_STARTS; - current_level = regexp_precedences[Ropenpar]; - paren_depth--; - if (paren_depth < num_open_registers) - { - bufp->uses_registers = 1; - ALLOC(2); - STORE(Cend_memory); - num_open_registers--; - STORE(open_registers[num_open_registers]); - } - break; - } - case Rmemory: - { - if (ch == '0') - goto bad_match_register; - assert(ch >= '0' && ch <= '9'); - bufp->uses_registers = 1; - opcode = Cmatch_memory; - ch -= '0'; - goto store_opcode_and_arg; - } - case Rextended_memory: - { - NEXTCHAR(ch); - if (ch < '0' || ch > '9') - goto bad_match_register; - NEXTCHAR(a); - if (a < '0' || a > '9') - goto bad_match_register; - ch = 10 * (a - '0') + ch - '0'; - if (ch == 0 || ch >= RE_NREGS) - goto bad_match_register; - bufp->uses_registers = 1; - opcode = Cmatch_memory; - goto store_opcode_and_arg; - } - case Ropenset: - { - int complement; - int prev; - int offset; - int range; - int firstchar; - - SET_LEVEL_START; - ALLOC(1+256/8); - STORE(Cset); - offset = pattern_offset; - for (a = 0; a < 256/8; a++) - STORE(0); - NEXTCHAR(ch); - if (translate) - ch = translate[(unsigned char)ch]; - if (ch == '\136') - { - complement = 1; - NEXTCHAR(ch); - if (translate) - ch = translate[(unsigned char)ch]; - } - else - complement = 0; - prev = -1; - range = 0; - firstchar = 1; - while (ch != '\135' || firstchar) - { - firstchar = 0; - if (regexp_ansi_sequences && ch == '\134') - { - NEXTCHAR(ch); - ANSI_TRANSLATE(ch); - } - if (range) - { - for (a = prev; a <= (int)ch; a++) - SETBIT(pattern, offset, a); - prev = -1; - range = 0; - } - else - if (prev != -1 && ch == '-') - range = 1; - else - { - SETBIT(pattern, offset, ch); - prev = ch; - } - NEXTCHAR(ch); - if (translate) - ch = translate[(unsigned char)ch]; - } - if (range) - SETBIT(pattern, offset, '-'); - if (complement) - { - for (a = 0; a < 256/8; a++) - pattern[offset+a] ^= 0xff; - } - break; - } - case Rbegbuf: - { - opcode = Cbegbuf; - goto store_opcode; - } - case Rendbuf: - { - opcode = Cendbuf; - goto store_opcode; - } - case Rwordchar: - { - opcode = Csyntaxspec; - ch = Sword; - goto store_opcode_and_arg; - } - case Rnotwordchar: - { - opcode = Cnotsyntaxspec; - ch = Sword; - goto store_opcode_and_arg; - } - case Rwordbeg: - { - opcode = Cwordbeg; - goto store_opcode; - } - case Rwordend: - { - opcode = Cwordend; - goto store_opcode; - } - case Rwordbound: - { - opcode = Cwordbound; - goto store_opcode; - } - case Rnotwordbound: - { - opcode = Cnotwordbound; - goto store_opcode; - } - default: - { - abort(); - } - } - beginning_context = (op == Ropenpar || op == Ror); - } - if (starts_base != 0) - goto parenthesis_error; - assert(num_jumps == 0); - ALLOC(1); - STORE(Cend); - SET_FIELDS; - if(!re_optimize(bufp)) - return "Optimization error"; - return NULL; - - op_error: - SET_FIELDS; - return "Badly placed special character"; - - bad_match_register: - SET_FIELDS; - return "Bad match register number"; - - hex_error: - SET_FIELDS; - return "Bad hexadecimal number"; - - parenthesis_error: - SET_FIELDS; - return "Badly placed parenthesis"; - - out_of_memory: - SET_FIELDS; - return "Out of memory"; - - ends_prematurely: - SET_FIELDS; - return "Regular expression ends prematurely"; - - too_complex: - SET_FIELDS; - return "Regular expression too complex"; -} - -#undef CHARAT -#undef NEXTCHAR -#undef GETHEX -#undef ALLOC -#undef STORE -#undef CURRENT_LEVEL_START -#undef SET_LEVEL_START -#undef PUSH_LEVEL_STARTS -#undef POP_LEVEL_STARTS -#undef PUT_ADDR -#undef INSERT_JUMP -#undef SETBIT -#undef SET_FIELDS - -#define PREFETCH if (text == textend) goto fail - -#define NEXTCHAR(var) \ -PREFETCH; \ -var = (unsigned char)*text++; \ -if (translate) \ - var = translate[var] - -int re_match(regexp_t bufp, unsigned char *string, int size, int pos, - regexp_registers_t old_regs) -{ - unsigned char *code; - unsigned char *translate; - unsigned char *text; - unsigned char *textstart; - unsigned char *textend; - int a; - int b; - int ch; - int reg; - int match_end; - unsigned char *regstart; - unsigned char *regend; - int regsize; - match_state state; - - assert(pos >= 0 && size >= 0); - assert(pos <= size); - - text = string + pos; - textstart = string; - textend = string + size; - - code = bufp->buffer; - - translate = bufp->translate; - - NEW_STATE(state, bufp->num_registers); - - continue_matching: - switch (*code++) - { - case Cend: - { - match_end = text - textstart; - if (old_regs) - { - old_regs->start[0] = pos; - old_regs->end[0] = match_end; - if (!bufp->uses_registers) - { - for (a = 1; a < RE_NREGS; a++) - { - old_regs->start[a] = -1; - old_regs->end[a] = -1; - } - } - else - { - for (a = 1; a < bufp->num_registers; a++) - { - if ((GET_REG_START(state, a) == NULL) || - (GET_REG_END(state, a) == NULL)) - { - old_regs->start[a] = -1; - old_regs->end[a] = -1; - continue; - } - old_regs->start[a] = GET_REG_START(state, a) - textstart; - old_regs->end[a] = GET_REG_END(state, a) - textstart; - } - for (; a < RE_NREGS; a++) - { - old_regs->start[a] = -1; - old_regs->end[a] = -1; - } - } - } - FREE_STATE(state); - return match_end - pos; - } - case Cbol: - { - if (text == textstart || text[-1] == '\n') - goto continue_matching; - goto fail; - } - case Ceol: - { - if (text == textend || *text == '\n') - goto continue_matching; - goto fail; - } - case Cset: - { - NEXTCHAR(ch); - if (code[ch/8] & (1<<(ch & 7))) - { - code += 256/8; - goto continue_matching; - } - goto fail; - } - case Cexact: - { - NEXTCHAR(ch); - if (ch != (unsigned char)*code++) - goto fail; - goto continue_matching; - } - case Canychar: - { - NEXTCHAR(ch); - if (ch == '\n') - goto fail; - goto continue_matching; - } - case Cstart_memory: - { - reg = *code++; - SET_REG_START(state, reg, text, goto error); - goto continue_matching; - } - case Cend_memory: - { - reg = *code++; - SET_REG_END(state, reg, text, goto error); - goto continue_matching; - } - case Cmatch_memory: - { - reg = *code++; - regstart = GET_REG_START(state, reg); - regend = GET_REG_END(state, reg); - if ((regstart == NULL) || (regend == NULL)) - goto fail; /* or should we just match nothing? */ - regsize = regend - regstart; - - if (regsize > (textend - text)) - goto fail; - if(translate) - { - for (; regstart < regend; regstart++, text++) - if (translate[*regstart] != translate[*text]) - goto fail; - } - else - for (; regstart < regend; regstart++, text++) - if (*regstart != *text) - goto fail; - goto continue_matching; - } - case Cupdate_failure_jump: - { - UPDATE_FAILURE(state, text, goto error); - /* fall to next case */ - } - /* treat Cstar_jump just like Cjump if it hasn't been optimized */ - case Cstar_jump: - case Cjump: - { - a = (unsigned char)*code++; - a |= (unsigned char)*code++ << 8; - code += (int)SHORT(a); - if (codebuffer || bufp->buffer+bufp->usedbuffer || bufp->buffer+bufp->used < failuredest) { - PyErr_SetString(PyExc_SystemError, "Regex VM jump out of bounds (Cdummy_failure_jump failuredest)"); - FREE_STATE(state); - return -2; - } - PUSH_FAILURE(state, failuredest, NULL, goto error); - code += a; - if (codebuffer || bufp->buffer+bufp->used < code) { - PyErr_SetString(PyExc_SystemError, "Regex VM jump out of bounds (Cdummy_failure_jump code)"); - FREE_STATE(state); - return -2; - } - goto continue_matching; - } - case Cfailure_jump: - { - a = (unsigned char)*code++; - a |= (unsigned char)*code++ << 8; - a = (int)SHORT(a); - if (code+abuffer || bufp->buffer+bufp->used < code+a) { - PyErr_SetString(PyExc_SystemError, "Regex VM jump out of bounds (Cfailure_jump)"); - FREE_STATE(state); - return -2; - } - PUSH_FAILURE(state, code + a, text, goto error); - goto continue_matching; - } - case Crepeat1: - { - unsigned char *pinst; - a = (unsigned char)*code++; - a |= (unsigned char)*code++ << 8; - a = (int)SHORT(a); - pinst = code + a; - if (pinstbuffer || bufp->buffer+bufp->used */ - } - case Cbegbuf: - { - if (text == textstart) - goto continue_matching; - goto fail; - } - case Cendbuf: - { - if (text == textend) - goto continue_matching; - goto fail; - } - case Cwordbeg: - { - if (text == textend) - goto fail; - if (!(SYNTAX(*text) & Sword)) - goto fail; - if (text == textstart) - goto continue_matching; - if (!(SYNTAX(text[-1]) & Sword)) - goto continue_matching; - goto fail; - } - case Cwordend: - { - if (text == textstart) - goto fail; - if (!(SYNTAX(text[-1]) & Sword)) - goto fail; - if (text == textend) - goto continue_matching; - if (!(SYNTAX(*text) & Sword)) - goto continue_matching; - goto fail; - } - case Cwordbound: - { - /* Note: as in gnu regexp, this also matches at the - * beginning and end of buffer. */ - - if (text == textstart || text == textend) - goto continue_matching; - if ((SYNTAX(text[-1]) & Sword) ^ (SYNTAX(*text) & Sword)) - goto continue_matching; - goto fail; - } - case Cnotwordbound: - { - /* Note: as in gnu regexp, this never matches at the - * beginning and end of buffer. */ - if (text == textstart || text == textend) - goto fail; - if (!((SYNTAX(text[-1]) & Sword) ^ (SYNTAX(*text) & Sword))) - goto continue_matching; - goto fail; - } - case Csyntaxspec: - { - NEXTCHAR(ch); - if (!(SYNTAX(ch) & (unsigned char)*code++)) - goto fail; - goto continue_matching; - } - case Cnotsyntaxspec: - { - NEXTCHAR(ch); - if (SYNTAX(ch) & (unsigned char)*code++) - goto fail; - goto continue_matching; - } - default: - { - FREE_STATE(state); - PyErr_SetString(PyExc_SystemError, "Unknown regex opcode: memory corrupted?"); - return -2; - /*NOTREACHED*/ - } - } - - - -#if 0 /* This line is never reached --Guido */ - abort(); -#endif - /* - *NOTREACHED - */ - - /* Using "break;" in the above switch statement is equivalent to "goto fail;" */ - fail: - POP_FAILURE(state, code, text, goto done_matching, goto error); - goto continue_matching; - - done_matching: -/* if(translated != NULL) */ -/* free(translated); */ - FREE_STATE(state); - return -1; - - error: -/* if (translated != NULL) */ -/* free(translated); */ - FREE_STATE(state); - return -2; -} - - -#undef PREFETCH -#undef NEXTCHAR - -int re_search(regexp_t bufp, unsigned char *string, int size, int pos, - int range, regexp_registers_t regs) -{ - unsigned char *fastmap; - unsigned char *translate; - unsigned char *text; - unsigned char *partstart; - unsigned char *partend; - int dir; - int ret; - unsigned char anchor; - - assert(size >= 0 && pos >= 0); - assert(pos + range >= 0 && pos + range <= size); /* Bugfix by ylo */ - - fastmap = bufp->fastmap; - translate = bufp->translate; - if (fastmap && !bufp->fastmap_accurate) { - re_compile_fastmap(bufp); - if (PyErr_Occurred()) return -2; - } - - anchor = bufp->anchor; - if (bufp->can_be_null == 1) /* can_be_null == 2: can match null at eob */ - fastmap = NULL; - - if (range < 0) - { - dir = -1; - range = -range; - } - else - dir = 1; - - if (anchor == 2) { - if (pos != 0) - return -1; - else - range = 0; - } - - for (; range >= 0; range--, pos += dir) - { - if (fastmap) - { - if (dir == 1) - { /* searching forwards */ - - text = string + pos; - partend = string + size; - partstart = text; - if (translate) - while (text != partend && - !fastmap[(unsigned char) translate[(unsigned char)*text]]) - text++; - else - while (text != partend && !fastmap[(unsigned char)*text]) - text++; - pos += text - partstart; - range -= text - partstart; - if (pos == size && bufp->can_be_null == 0) - return -1; - } - else - { /* searching backwards */ - text = string + pos; - partstart = string + pos - range; - partend = text; - if (translate) - while (text != partstart && - !fastmap[(unsigned char) - translate[(unsigned char)*text]]) - text--; - else - while (text != partstart && - !fastmap[(unsigned char)*text]) - text--; - pos -= partend - text; - range -= partend - text; - } - } - if (anchor == 1) - { /* anchored to begline */ - if (pos > 0 && (string[pos - 1] != '\n')) - continue; - } - assert(pos >= 0 && pos <= size); - ret = re_match(bufp, string, size, pos, regs); - if (ret >= 0) - return pos; - if (ret == -2) - return -2; - } - return -1; -} - -/* -** Local Variables: -** mode: c -** c-file-style: "python" -** End: -*/ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/regexpr.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/regexpr.h deleted file mode 100644 index 607b1e3d..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/regexpr.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * -*- mode: c-mode; c-file-style: python -*- - */ - -#ifndef Py_REGEXPR_H -#define Py_REGEXPR_H -#ifdef __cplusplus -extern "C" { -#endif - -/* - * regexpr.h - * - * Author: Tatu Ylonen - * - * Copyright (c) 1991 Tatu Ylonen, Espoo, Finland - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies. This - * software is provided "as is" without express or implied warranty. - * - * Created: Thu Sep 26 17:15:36 1991 ylo - * Last modified: Mon Nov 4 15:49:46 1991 ylo - */ - -/* $Id: regexpr.h,v 1.13 2000/07/16 12:04:31 twouters Exp $ */ - -#ifndef REGEXPR_H -#define REGEXPR_H - -#define RE_NREGS 100 /* number of registers available */ - -typedef struct re_pattern_buffer -{ - unsigned char *buffer; /* compiled pattern */ - int allocated; /* allocated size of compiled pattern */ - int used; /* actual length of compiled pattern */ - unsigned char *fastmap; /* fastmap[ch] is true if ch can start pattern */ - unsigned char *translate; /* translation to apply during compilation/matching */ - unsigned char fastmap_accurate; /* true if fastmap is valid */ - unsigned char can_be_null; /* true if can match empty string */ - unsigned char uses_registers; /* registers are used and need to be initialized */ - int num_registers; /* number of registers used */ - unsigned char anchor; /* anchor: 0=none 1=begline 2=begbuf */ -} *regexp_t; - -typedef struct re_registers -{ - int start[RE_NREGS]; /* start offset of region */ - int end[RE_NREGS]; /* end offset of region */ -} *regexp_registers_t; - -/* bit definitions for syntax */ -#define RE_NO_BK_PARENS 1 /* no quoting for parentheses */ -#define RE_NO_BK_VBAR 2 /* no quoting for vertical bar */ -#define RE_BK_PLUS_QM 4 /* quoting needed for + and ? */ -#define RE_TIGHT_VBAR 8 /* | binds tighter than ^ and $ */ -#define RE_NEWLINE_OR 16 /* treat newline as or */ -#define RE_CONTEXT_INDEP_OPS 32 /* ^$?*+ are special in all contexts */ -#define RE_ANSI_HEX 64 /* ansi sequences (\n etc) and \xhh */ -#define RE_NO_GNU_EXTENSIONS 128 /* no gnu extensions */ - -/* definitions for some common regexp styles */ -#define RE_SYNTAX_AWK (RE_NO_BK_PARENS|RE_NO_BK_VBAR|RE_CONTEXT_INDEP_OPS) -#define RE_SYNTAX_EGREP (RE_SYNTAX_AWK|RE_NEWLINE_OR) -#define RE_SYNTAX_GREP (RE_BK_PLUS_QM|RE_NEWLINE_OR) -#define RE_SYNTAX_EMACS 0 - -#define Sword 1 -#define Swhitespace 2 -#define Sdigit 4 -#define Soctaldigit 8 -#define Shexdigit 16 - -/* Rename all exported symbols to avoid conflicts with similarly named - symbols in some systems' standard C libraries... */ - -#define re_syntax _Py_re_syntax -#define re_syntax_table _Py_re_syntax_table -#define re_compile_initialize _Py_re_compile_initialize -#define re_set_syntax _Py_re_set_syntax -#define re_compile_pattern _Py_re_compile_pattern -#define re_match _Py_re_match -#define re_search _Py_re_search -#define re_compile_fastmap _Py_re_compile_fastmap -#define re_comp _Py_re_comp -#define re_exec _Py_re_exec - -#ifdef HAVE_PROTOTYPES - -extern int re_syntax; -/* This is the actual syntax mask. It was added so that Python could do - * syntax-dependent munging of patterns before compilation. */ - -extern unsigned char re_syntax_table[256]; - -void re_compile_initialize(void); - -int re_set_syntax(int syntax); -/* This sets the syntax to use and returns the previous syntax. The - * syntax is specified by a bit mask of the above defined bits. */ - -char *re_compile_pattern(unsigned char *regex, int regex_size, regexp_t compiled); -/* This compiles the regexp (given in regex and length in regex_size). - * This returns NULL if the regexp compiled successfully, and an error - * message if an error was encountered. The buffer field must be - * initialized to a memory area allocated by malloc (or to NULL) before - * use, and the allocated field must be set to its length (or 0 if - * buffer is NULL). Also, the translate field must be set to point to a - * valid translation table, or NULL if it is not used. */ - -int re_match(regexp_t compiled, unsigned char *string, int size, int pos, - regexp_registers_t old_regs); -/* This tries to match the regexp against the string. This returns the - * length of the matched portion, or -1 if the pattern could not be - * matched and -2 if an error (such as failure stack overflow) is - * encountered. */ - -int re_search(regexp_t compiled, unsigned char *string, int size, int startpos, - int range, regexp_registers_t regs); -/* This searches for a substring matching the regexp. This returns the - * first index at which a match is found. range specifies at how many - * positions to try matching; positive values indicate searching - * forwards, and negative values indicate searching backwards. mstop - * specifies the offset beyond which a match must not go. This returns - * -1 if no match is found, and -2 if an error (such as failure stack - * overflow) is encountered. */ - -void re_compile_fastmap(regexp_t compiled); -/* This computes the fastmap for the regexp. For this to have any effect, - * the calling program must have initialized the fastmap field to point - * to an array of 256 characters. */ - -#else /* HAVE_PROTOTYPES */ - -extern int re_syntax; -extern unsigned char re_syntax_table[256]; -void re_compile_initialize(); -int re_set_syntax(); -char *re_compile_pattern(); -int re_match(); -int re_search(); -void re_compile_fastmap(); - -#endif /* HAVE_PROTOTYPES */ - -#endif /* REGEXPR_H */ - - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_REGEXPR_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/resource.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/resource.c deleted file mode 100644 index c1f4df9d..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/resource.c +++ /dev/null @@ -1,316 +0,0 @@ - -#include "Python.h" -#include "structseq.h" -#include -#include -#include -#include -/* for sysconf */ -#if defined(HAVE_UNISTD_H) -#include -#endif - -/* On some systems, these aren't in any header file. - On others they are, with inconsistent prototypes. - We declare the (default) return type, to shut up gcc -Wall; - but we can't declare the prototype, to avoid errors - when the header files declare it different. - Worse, on some Linuxes, getpagesize() returns a size_t... */ - -#define doubletime(TV) ((double)(TV).tv_sec + (TV).tv_usec * 0.000001) - -static PyObject *ResourceError; - -PyDoc_STRVAR(struct_rusage__doc__, -"struct_rusage: Result from getrusage.\n\n" -"This object may be accessed either as a tuple of\n" -" (utime,stime,maxrss,ixrss,idrss,isrss,minflt,majflt,\n" -" nswap,inblock,oublock,msgsnd,msgrcv,nsignals,nvcsw,nivcsw)\n" -"or via the attributes ru_utime, ru_stime, ru_maxrss, and so on."); - -static PyStructSequence_Field struct_rusage_fields[] = { - {"ru_utime", "user time used"}, - {"ru_stime", "system time used"}, - {"ru_maxrss", "max. resident set size"}, - {"ru_ixrss", "shared memory size"}, - {"ru_idrss", "unshared data size"}, - {"ru_isrss", "unshared stack size"}, - {"ru_minflt", "page faults not requiring I/O"}, - {"ru_majflt", "page faults requiring I/O"}, - {"ru_nswap", "number of swap outs"}, - {"ru_inblock", "block input operations"}, - {"ru_oublock", "block output operations"}, - {"ru_msgsnd", "IPC messages sent"}, - {"ru_msgrcv", "IPC messages received"}, - {"ru_nsignals", "signals received"}, - {"ru_nvcsw", "voluntary context switches"}, - {"ru_nivcsw", "involuntary context switches"}, - {0} -}; - -static PyStructSequence_Desc struct_rusage_desc = { - "resource.struct_rusage", /* name */ - struct_rusage__doc__, /* doc */ - struct_rusage_fields, /* fields */ - 16 /* n_in_sequence */ -}; - -static PyTypeObject StructRUsageType; - -static PyObject * -resource_getrusage(PyObject *self, PyObject *args) -{ - int who; - struct rusage ru; - PyObject *result; - - if (!PyArg_ParseTuple(args, "i:getrusage", &who)) - return NULL; - - if (getrusage(who, &ru) == -1) { - if (errno == EINVAL) { - PyErr_SetString(PyExc_ValueError, - "invalid who parameter"); - return NULL; - } - PyErr_SetFromErrno(ResourceError); - return NULL; - } - - result = PyStructSequence_New(&StructRUsageType); - if (!result) - return NULL; - - PyStructSequence_SET_ITEM(result, 0, - PyFloat_FromDouble(doubletime(ru.ru_utime))); - PyStructSequence_SET_ITEM(result, 1, - PyFloat_FromDouble(doubletime(ru.ru_stime))); - PyStructSequence_SET_ITEM(result, 2, PyInt_FromLong(ru.ru_maxrss)); - PyStructSequence_SET_ITEM(result, 3, PyInt_FromLong(ru.ru_ixrss)); - PyStructSequence_SET_ITEM(result, 4, PyInt_FromLong(ru.ru_idrss)); - PyStructSequence_SET_ITEM(result, 5, PyInt_FromLong(ru.ru_isrss)); - PyStructSequence_SET_ITEM(result, 6, PyInt_FromLong(ru.ru_minflt)); - PyStructSequence_SET_ITEM(result, 7, PyInt_FromLong(ru.ru_majflt)); - PyStructSequence_SET_ITEM(result, 8, PyInt_FromLong(ru.ru_nswap)); - PyStructSequence_SET_ITEM(result, 9, PyInt_FromLong(ru.ru_inblock)); - PyStructSequence_SET_ITEM(result, 10, PyInt_FromLong(ru.ru_oublock)); - PyStructSequence_SET_ITEM(result, 11, PyInt_FromLong(ru.ru_msgsnd)); - PyStructSequence_SET_ITEM(result, 12, PyInt_FromLong(ru.ru_msgrcv)); - PyStructSequence_SET_ITEM(result, 13, PyInt_FromLong(ru.ru_nsignals)); - PyStructSequence_SET_ITEM(result, 14, PyInt_FromLong(ru.ru_nvcsw)); - PyStructSequence_SET_ITEM(result, 15, PyInt_FromLong(ru.ru_nivcsw)); - - if (PyErr_Occurred()) { - Py_DECREF(result); - return NULL; - } - - return result; -} - - -static PyObject * -resource_getrlimit(PyObject *self, PyObject *args) -{ - struct rlimit rl; - int resource; - - if (!PyArg_ParseTuple(args, "i:getrlimit", &resource)) - return NULL; - - if (resource < 0 || resource >= RLIM_NLIMITS) { - PyErr_SetString(PyExc_ValueError, - "invalid resource specified"); - return NULL; - } - - if (getrlimit(resource, &rl) == -1) { - PyErr_SetFromErrno(ResourceError); - return NULL; - } - -#if defined(HAVE_LONG_LONG) - if (sizeof(rl.rlim_cur) > sizeof(long)) { - return Py_BuildValue("LL", - (PY_LONG_LONG) rl.rlim_cur, - (PY_LONG_LONG) rl.rlim_max); - } -#endif - return Py_BuildValue("ll", (long) rl.rlim_cur, (long) rl.rlim_max); -} - -static PyObject * -resource_setrlimit(PyObject *self, PyObject *args) -{ - struct rlimit rl; - int resource; - PyObject *curobj, *maxobj; - - if (!PyArg_ParseTuple(args, "i(OO):setrlimit", - &resource, &curobj, &maxobj)) - return NULL; - - if (resource < 0 || resource >= RLIM_NLIMITS) { - PyErr_SetString(PyExc_ValueError, - "invalid resource specified"); - return NULL; - } - -#if !defined(HAVE_LARGEFILE_SUPPORT) - rl.rlim_cur = PyInt_AsLong(curobj); - if (rl.rlim_cur == -1 && PyErr_Occurred()) - return NULL; - rl.rlim_max = PyInt_AsLong(maxobj); - if (rl.rlim_max == -1 && PyErr_Occurred()) - return NULL; -#else - /* The limits are probably bigger than a long */ - rl.rlim_cur = PyLong_Check(curobj) ? - PyLong_AsLongLong(curobj) : PyInt_AsLong(curobj); - if (rl.rlim_cur == -1 && PyErr_Occurred()) - return NULL; - rl.rlim_max = PyLong_Check(maxobj) ? - PyLong_AsLongLong(maxobj) : PyInt_AsLong(maxobj); - if (rl.rlim_max == -1 && PyErr_Occurred()) - return NULL; -#endif - - rl.rlim_cur = rl.rlim_cur & RLIM_INFINITY; - rl.rlim_max = rl.rlim_max & RLIM_INFINITY; - if (setrlimit(resource, &rl) == -1) { - if (errno == EINVAL) - PyErr_SetString(PyExc_ValueError, - "current limit exceeds maximum limit"); - else if (errno == EPERM) - PyErr_SetString(PyExc_ValueError, - "not allowed to raise maximum limit"); - else - PyErr_SetFromErrno(ResourceError); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -resource_getpagesize(PyObject *self, PyObject *args) -{ - long pagesize = 0; - if (!PyArg_ParseTuple(args, ":getpagesize")) - return NULL; - -#if defined(HAVE_GETPAGESIZE) - pagesize = getpagesize(); -#elif defined(HAVE_SYSCONF) - pagesize = sysconf(_SC_PAGE_SIZE); -#endif - return Py_BuildValue("i", pagesize); - -} - -/* List of functions */ - -static struct PyMethodDef -resource_methods[] = { - {"getrusage", resource_getrusage, METH_VARARGS}, - {"getrlimit", resource_getrlimit, METH_VARARGS}, - {"setrlimit", resource_setrlimit, METH_VARARGS}, - {"getpagesize", resource_getpagesize, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - - -/* Module initialization */ - -PyMODINIT_FUNC -initresource(void) -{ - PyObject *m, *v; - - /* Create the module and add the functions */ - m = Py_InitModule("resource", resource_methods); - - /* Add some symbolic constants to the module */ - if (ResourceError == NULL) { - ResourceError = PyErr_NewException("resource.error", - NULL, NULL); - } - Py_INCREF(ResourceError); - PyModule_AddObject(m, "error", ResourceError); - PyStructSequence_InitType(&StructRUsageType, &struct_rusage_desc); - PyModule_AddObject(m, "struct_rusage", - (PyObject*) &StructRUsageType); - - /* insert constants */ -#ifdef RLIMIT_CPU - PyModule_AddIntConstant(m, "RLIMIT_CPU", RLIMIT_CPU); -#endif - -#ifdef RLIMIT_FSIZE - PyModule_AddIntConstant(m, "RLIMIT_FSIZE", RLIMIT_FSIZE); -#endif - -#ifdef RLIMIT_DATA - PyModule_AddIntConstant(m, "RLIMIT_DATA", RLIMIT_DATA); -#endif - -#ifdef RLIMIT_STACK - PyModule_AddIntConstant(m, "RLIMIT_STACK", RLIMIT_STACK); -#endif - -#ifdef RLIMIT_CORE - PyModule_AddIntConstant(m, "RLIMIT_CORE", RLIMIT_CORE); -#endif - -#ifdef RLIMIT_NOFILE - PyModule_AddIntConstant(m, "RLIMIT_NOFILE", RLIMIT_NOFILE); -#endif - -#ifdef RLIMIT_OFILE - PyModule_AddIntConstant(m, "RLIMIT_OFILE", RLIMIT_OFILE); -#endif - -#ifdef RLIMIT_VMEM - PyModule_AddIntConstant(m, "RLIMIT_VMEM", RLIMIT_VMEM); -#endif - -#ifdef RLIMIT_AS - PyModule_AddIntConstant(m, "RLIMIT_AS", RLIMIT_AS); -#endif - -#ifdef RLIMIT_RSS - PyModule_AddIntConstant(m, "RLIMIT_RSS", RLIMIT_RSS); -#endif - -#ifdef RLIMIT_NPROC - PyModule_AddIntConstant(m, "RLIMIT_NPROC", RLIMIT_NPROC); -#endif - -#ifdef RLIMIT_MEMLOCK - PyModule_AddIntConstant(m, "RLIMIT_MEMLOCK", RLIMIT_MEMLOCK); -#endif - -#ifdef RUSAGE_SELF - PyModule_AddIntConstant(m, "RUSAGE_SELF", RUSAGE_SELF); -#endif - -#ifdef RUSAGE_CHILDREN - PyModule_AddIntConstant(m, "RUSAGE_CHILDREN", RUSAGE_CHILDREN); -#endif - -#ifdef RUSAGE_BOTH - PyModule_AddIntConstant(m, "RUSAGE_BOTH", RUSAGE_BOTH); -#endif - -#if defined(HAVE_LONG_LONG) - if (sizeof(RLIM_INFINITY) > sizeof(long)) { - v = PyLong_FromLongLong((PY_LONG_LONG) RLIM_INFINITY); - } else -#endif - { - v = PyInt_FromLong((long) RLIM_INFINITY); - } - if (v) { - PyModule_AddObject(m, "RLIM_INFINITY", v); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/rgbimgmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/rgbimgmodule.c deleted file mode 100644 index 9349408f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/rgbimgmodule.c +++ /dev/null @@ -1,763 +0,0 @@ -/* - * fastimg - - * Faster reading and writing of image files. - * - * This code should work on machines with any byte order. - * - * Could someone make this run real fast using multiple processors - * or how about using memory mapped files to speed it up? - * - * Paul Haeberli - 1991 - * - * Changed to return sizes. - * Sjoerd Mullender - 1993 - * Changed to incorporate into Python. - * Sjoerd Mullender - 1993 - */ -#include "Python.h" - -#if SIZEOF_INT == 4 -typedef int Py_Int32; -typedef unsigned int Py_UInt32; -#else -#if SIZEOF_LONG == 4 -typedef long Py_Int32; -typedef unsigned long Py_UInt32; -#else -#error "No 4-byte integral type" -#endif -#endif - -#include - -/* - * from image.h - * - */ -typedef struct { - unsigned short imagic; /* stuff saved on disk . . */ - unsigned short type; - unsigned short dim; - unsigned short xsize; - unsigned short ysize; - unsigned short zsize; - Py_UInt32 min; - Py_UInt32 max; - Py_UInt32 wastebytes; - char name[80]; - Py_UInt32 colormap; - - Py_Int32 file; /* stuff used in core only */ - unsigned short flags; - short dorev; - short x; - short y; - short z; - short cnt; - unsigned short *ptr; - unsigned short *base; - unsigned short *tmpbuf; - Py_UInt32 offset; - Py_UInt32 rleend; /* for rle images */ - Py_UInt32 *rowstart; /* for rle images */ - Py_Int32 *rowsize; /* for rle images */ -} IMAGE; - -#define IMAGIC 0732 - -#define TYPEMASK 0xff00 -#define BPPMASK 0x00ff -#define ITYPE_VERBATIM 0x0000 -#define ITYPE_RLE 0x0100 -#define ISRLE(type) (((type) & 0xff00) == ITYPE_RLE) -#define ISVERBATIM(type) (((type) & 0xff00) == ITYPE_VERBATIM) -#define BPP(type) ((type) & BPPMASK) -#define RLE(bpp) (ITYPE_RLE | (bpp)) -#define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp)) -/* - * end of image.h stuff - * - */ - -#define RINTLUM (79) -#define GINTLUM (156) -#define BINTLUM (21) - -#define ILUM(r,g,b) ((int)(RINTLUM*(r)+GINTLUM*(g)+BINTLUM*(b))>>8) - -#define OFFSET_R 3 /* this is byte order dependent */ -#define OFFSET_G 2 -#define OFFSET_B 1 -#define OFFSET_A 0 - -#define CHANOFFSET(z) (3-(z)) /* this is byte order dependent */ - -static void expandrow(unsigned char *, unsigned char *, int); -static void setalpha(unsigned char *, int); -static void copybw(Py_Int32 *, int); -static void interleaverow(unsigned char*, unsigned char*, int, int); -static int compressrow(unsigned char *, unsigned char *, int, int); -static void lumrow(unsigned char *, unsigned char *, int); - -#ifdef ADD_TAGS -#define TAGLEN (5) -#else -#define TAGLEN (0) -#endif - -static PyObject *ImgfileError; - -static int reverse_order; - -#ifdef ADD_TAGS -/* - * addlongimgtag - - * this is used to extract image data from core dumps. - * - */ -static void -addlongimgtag(Py_UInt32 *dptr, int xsize, int ysize) -{ - dptr = dptr + (xsize * ysize); - dptr[0] = 0x12345678; - dptr[1] = 0x59493333; - dptr[2] = 0x69434222; - dptr[3] = xsize; - dptr[4] = ysize; -} -#endif - -/* - * byte order independent read/write of shorts and longs. - * - */ -static unsigned short -getshort(FILE *inf) -{ - unsigned char buf[2]; - - fread(buf, 2, 1, inf); - return (buf[0] << 8) + (buf[1] << 0); -} - -static Py_UInt32 -getlong(FILE *inf) -{ - unsigned char buf[4]; - - fread(buf, 4, 1, inf); - return (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + (buf[3] << 0); -} - -static void -putshort(FILE *outf, unsigned short val) -{ - unsigned char buf[2]; - - buf[0] = (val >> 8); - buf[1] = (val >> 0); - fwrite(buf, 2, 1, outf); -} - -static int -putlong(FILE *outf, Py_UInt32 val) -{ - unsigned char buf[4]; - - buf[0] = (unsigned char) (val >> 24); - buf[1] = (unsigned char) (val >> 16); - buf[2] = (unsigned char) (val >> 8); - buf[3] = (unsigned char) (val >> 0); - return fwrite(buf, 4, 1, outf); -} - -static void -readheader(FILE *inf, IMAGE *image) -{ - memset(image ,0, sizeof(IMAGE)); - image->imagic = getshort(inf); - image->type = getshort(inf); - image->dim = getshort(inf); - image->xsize = getshort(inf); - image->ysize = getshort(inf); - image->zsize = getshort(inf); -} - -static int -writeheader(FILE *outf, IMAGE *image) -{ - IMAGE t; - - memset(&t, 0, sizeof(IMAGE)); - fwrite(&t, sizeof(IMAGE), 1, outf); - fseek(outf, 0, SEEK_SET); - putshort(outf, image->imagic); - putshort(outf, image->type); - putshort(outf, image->dim); - putshort(outf, image->xsize); - putshort(outf, image->ysize); - putshort(outf, image->zsize); - putlong(outf, image->min); - putlong(outf, image->max); - putlong(outf, 0); - return fwrite("no name", 8, 1, outf); -} - -static int -writetab(FILE *outf, /*unsigned*/ Py_Int32 *tab, int len) -{ - int r = 0; - - while(len) { - r = putlong(outf, *tab++); - len--; - } - return r; -} - -static void -readtab(FILE *inf, /*unsigned*/ Py_Int32 *tab, int len) -{ - while(len) { - *tab++ = getlong(inf); - len--; - } -} - -/* - * sizeofimage - - * return the xsize and ysize of an iris image file. - * - */ -static PyObject * -sizeofimage(PyObject *self, PyObject *args) -{ - char *name; - IMAGE image; - FILE *inf; - - if (!PyArg_ParseTuple(args, "s:sizeofimage", &name)) - return NULL; - - inf = fopen(name, "rb"); - if (!inf) { - PyErr_SetString(ImgfileError, "can't open image file"); - return NULL; - } - readheader(inf, &image); - fclose(inf); - if (image.imagic != IMAGIC) { - PyErr_SetString(ImgfileError, - "bad magic number in image file"); - return NULL; - } - return Py_BuildValue("(ii)", image.xsize, image.ysize); -} - -/* - * longimagedata - - * read in a B/W RGB or RGBA iris image file and return a - * pointer to an array of longs. - * - */ -static PyObject * -longimagedata(PyObject *self, PyObject *args) -{ - char *name; - unsigned char *base, *lptr; - unsigned char *rledat = NULL, *verdat = NULL; - Py_Int32 *starttab = NULL, *lengthtab = NULL; - FILE *inf = NULL; - IMAGE image; - int y, z, tablen; - int xsize, ysize, zsize; - int bpp, rle, cur, badorder; - int rlebuflen; - PyObject *rv = NULL; - - if (!PyArg_ParseTuple(args, "s:longimagedata", &name)) - return NULL; - - inf = fopen(name,"rb"); - if (!inf) { - PyErr_SetString(ImgfileError, "can't open image file"); - return NULL; - } - readheader(inf,&image); - if (image.imagic != IMAGIC) { - PyErr_SetString(ImgfileError, - "bad magic number in image file"); - goto finally; - } - rle = ISRLE(image.type); - bpp = BPP(image.type); - if (bpp != 1) { - PyErr_SetString(ImgfileError, - "image must have 1 byte per pix chan"); - goto finally; - } - xsize = image.xsize; - ysize = image.ysize; - zsize = image.zsize; - if (rle) { - tablen = ysize * zsize * sizeof(Py_Int32); - starttab = (Py_Int32 *)malloc(tablen); - lengthtab = (Py_Int32 *)malloc(tablen); - rlebuflen = (int) (1.05 * xsize +10); - rledat = (unsigned char *)malloc(rlebuflen); - if (!starttab || !lengthtab || !rledat) { - PyErr_NoMemory(); - goto finally; - } - - fseek(inf, 512, SEEK_SET); - readtab(inf, starttab, ysize*zsize); - readtab(inf, lengthtab, ysize*zsize); - - /* check data order */ - cur = 0; - badorder = 0; - for(y = 0; y < ysize; y++) { - for(z = 0; z < zsize; z++) { - if (starttab[y + z * ysize] < cur) { - badorder = 1; - break; - } - cur = starttab[y +z * ysize]; - } - if (badorder) - break; - } - - fseek(inf, 512 + 2 * tablen, SEEK_SET); - cur = 512 + 2 * tablen; - rv = PyString_FromStringAndSize((char *)NULL, - (xsize * ysize + TAGLEN) * sizeof(Py_Int32)); - if (rv == NULL) - goto finally; - - base = (unsigned char *) PyString_AsString(rv); -#ifdef ADD_TAGS - addlongimgtag(base,xsize,ysize); -#endif - if (badorder) { - for (z = 0; z < zsize; z++) { - lptr = base; - if (reverse_order) - lptr += (ysize - 1) * xsize - * sizeof(Py_UInt32); - for (y = 0; y < ysize; y++) { - int idx = y + z * ysize; - if (cur != starttab[idx]) { - fseek(inf,starttab[idx], - SEEK_SET); - cur = starttab[idx]; - } - if (lengthtab[idx] > rlebuflen) { - PyErr_SetString(ImgfileError, - "rlebuf is too small"); - Py_DECREF(rv); - rv = NULL; - goto finally; - } - fread(rledat, lengthtab[idx], 1, inf); - cur += lengthtab[idx]; - expandrow(lptr, rledat, 3-z); - if (reverse_order) - lptr -= xsize - * sizeof(Py_UInt32); - else - lptr += xsize - * sizeof(Py_UInt32); - } - } - } else { - lptr = base; - if (reverse_order) - lptr += (ysize - 1) * xsize - * sizeof(Py_UInt32); - for (y = 0; y < ysize; y++) { - for(z = 0; z < zsize; z++) { - int idx = y + z * ysize; - if (cur != starttab[idx]) { - fseek(inf, starttab[idx], - SEEK_SET); - cur = starttab[idx]; - } - fread(rledat, lengthtab[idx], 1, inf); - cur += lengthtab[idx]; - expandrow(lptr, rledat, 3-z); - } - if (reverse_order) - lptr -= xsize * sizeof(Py_UInt32); - else - lptr += xsize * sizeof(Py_UInt32); - } - } - if (zsize == 3) - setalpha(base, xsize * ysize); - else if (zsize < 3) - copybw((Py_Int32 *) base, xsize * ysize); - } - else { - rv = PyString_FromStringAndSize((char *) 0, - (xsize*ysize+TAGLEN)*sizeof(Py_Int32)); - if (rv == NULL) - goto finally; - - base = (unsigned char *) PyString_AsString(rv); -#ifdef ADD_TAGS - addlongimgtag(base, xsize, ysize); -#endif - verdat = (unsigned char *)malloc(xsize); - fseek(inf, 512, SEEK_SET); - for (z = 0; z < zsize; z++) { - lptr = base; - if (reverse_order) - lptr += (ysize - 1) * xsize - * sizeof(Py_UInt32); - for (y = 0; y < ysize; y++) { - fread(verdat, xsize, 1, inf); - interleaverow(lptr, verdat, 3-z, xsize); - if (reverse_order) - lptr -= xsize * sizeof(Py_UInt32); - else - lptr += xsize * sizeof(Py_UInt32); - } - } - if (zsize == 3) - setalpha(base, xsize * ysize); - else if (zsize < 3) - copybw((Py_Int32 *) base, xsize * ysize); - } - finally: - free(starttab); - free(lengthtab); - free(rledat); - free(verdat); - fclose(inf); - return rv; -} - -/* static utility functions for longimagedata */ - -static void -interleaverow(unsigned char *lptr, unsigned char *cptr, int z, int n) -{ - lptr += z; - while (n--) { - *lptr = *cptr++; - lptr += 4; - } -} - -static void -copybw(Py_Int32 *lptr, int n) -{ - while (n >= 8) { - lptr[0] = 0xff000000 + (0x010101 * (lptr[0] & 0xff)); - lptr[1] = 0xff000000 + (0x010101 * (lptr[1] & 0xff)); - lptr[2] = 0xff000000 + (0x010101 * (lptr[2] & 0xff)); - lptr[3] = 0xff000000 + (0x010101 * (lptr[3] & 0xff)); - lptr[4] = 0xff000000 + (0x010101 * (lptr[4] & 0xff)); - lptr[5] = 0xff000000 + (0x010101 * (lptr[5] & 0xff)); - lptr[6] = 0xff000000 + (0x010101 * (lptr[6] & 0xff)); - lptr[7] = 0xff000000 + (0x010101 * (lptr[7] & 0xff)); - lptr += 8; - n -= 8; - } - while (n--) { - *lptr = 0xff000000 + (0x010101 * (*lptr&0xff)); - lptr++; - } -} - -static void -setalpha(unsigned char *lptr, int n) -{ - while (n >= 8) { - lptr[0 * 4] = 0xff; - lptr[1 * 4] = 0xff; - lptr[2 * 4] = 0xff; - lptr[3 * 4] = 0xff; - lptr[4 * 4] = 0xff; - lptr[5 * 4] = 0xff; - lptr[6 * 4] = 0xff; - lptr[7 * 4] = 0xff; - lptr += 4 * 8; - n -= 8; - } - while (n--) { - *lptr = 0xff; - lptr += 4; - } -} - -static void -expandrow(unsigned char *optr, unsigned char *iptr, int z) -{ - unsigned char pixel, count; - - optr += z; - while (1) { - pixel = *iptr++; - if (!(count = (pixel & 0x7f))) - return; - if (pixel & 0x80) { - while (count >= 8) { - optr[0 * 4] = iptr[0]; - optr[1 * 4] = iptr[1]; - optr[2 * 4] = iptr[2]; - optr[3 * 4] = iptr[3]; - optr[4 * 4] = iptr[4]; - optr[5 * 4] = iptr[5]; - optr[6 * 4] = iptr[6]; - optr[7 * 4] = iptr[7]; - optr += 8 * 4; - iptr += 8; - count -= 8; - } - while (count--) { - *optr = *iptr++; - optr += 4; - } - } - else { - pixel = *iptr++; - while (count >= 8) { - optr[0 * 4] = pixel; - optr[1 * 4] = pixel; - optr[2 * 4] = pixel; - optr[3 * 4] = pixel; - optr[4 * 4] = pixel; - optr[5 * 4] = pixel; - optr[6 * 4] = pixel; - optr[7 * 4] = pixel; - optr += 8 * 4; - count -= 8; - } - while (count--) { - *optr = pixel; - optr += 4; - } - } - } -} - -/* - * longstoimage - - * copy an array of longs to an iris image file. Each long - * represents one pixel. xsize and ysize specify the dimensions of - * the pixel array. zsize specifies what kind of image file to - * write out. if zsize is 1, the luminance of the pixels are - * calculated, and a single channel black and white image is saved. - * If zsize is 3, an RGB image file is saved. If zsize is 4, an - * RGBA image file is saved. - * - */ -static PyObject * -longstoimage(PyObject *self, PyObject *args) -{ - unsigned char *lptr; - char *name; - int xsize, ysize, zsize; - FILE *outf = NULL; - IMAGE image; - int tablen, y, z, pos, len; - Py_Int32 *starttab = NULL, *lengthtab = NULL; - unsigned char *rlebuf = NULL; - unsigned char *lumbuf = NULL; - int rlebuflen, goodwrite; - PyObject *retval = NULL; - - if (!PyArg_ParseTuple(args, "s#iiis:longstoimage", &lptr, &len, - &xsize, &ysize, &zsize, &name)) - return NULL; - - goodwrite = 1; - outf = fopen(name, "wb"); - if (!outf) { - PyErr_SetString(ImgfileError, "can't open output file"); - return NULL; - } - tablen = ysize * zsize * sizeof(Py_Int32); - - starttab = (Py_Int32 *)malloc(tablen); - lengthtab = (Py_Int32 *)malloc(tablen); - rlebuflen = (int) (1.05 * xsize + 10); - rlebuf = (unsigned char *)malloc(rlebuflen); - lumbuf = (unsigned char *)malloc(xsize * sizeof(Py_Int32)); - if (!starttab || !lengthtab || !rlebuf || !lumbuf) { - PyErr_NoMemory(); - goto finally; - } - - memset(&image, 0, sizeof(IMAGE)); - image.imagic = IMAGIC; - image.type = RLE(1); - if (zsize>1) - image.dim = 3; - else - image.dim = 2; - image.xsize = xsize; - image.ysize = ysize; - image.zsize = zsize; - image.min = 0; - image.max = 255; - goodwrite *= writeheader(outf, &image); - pos = 512 + 2 * tablen; - fseek(outf, pos, SEEK_SET); - if (reverse_order) - lptr += (ysize - 1) * xsize * sizeof(Py_UInt32); - for (y = 0; y < ysize; y++) { - for (z = 0; z < zsize; z++) { - if (zsize == 1) { - lumrow(lptr, lumbuf, xsize); - len = compressrow(lumbuf, rlebuf, - CHANOFFSET(z), xsize); - } else { - len = compressrow(lptr, rlebuf, - CHANOFFSET(z), xsize); - } - if(len > rlebuflen) { - PyErr_SetString(ImgfileError, - "rlebuf is too small"); - goto finally; - } - goodwrite *= fwrite(rlebuf, len, 1, outf); - starttab[y + z * ysize] = pos; - lengthtab[y + z * ysize] = len; - pos += len; - } - if (reverse_order) - lptr -= xsize * sizeof(Py_UInt32); - else - lptr += xsize * sizeof(Py_UInt32); - } - - fseek(outf, 512, SEEK_SET); - goodwrite *= writetab(outf, starttab, ysize*zsize); - goodwrite *= writetab(outf, lengthtab, ysize*zsize); - if (goodwrite) { - Py_INCREF(Py_None); - retval = Py_None; - } else - PyErr_SetString(ImgfileError, "not enough space for image"); - - finally: - fclose(outf); - free(starttab); - free(lengthtab); - free(rlebuf); - free(lumbuf); - return retval; -} - -/* static utility functions for longstoimage */ - -static void -lumrow(unsigned char *rgbptr, unsigned char *lumptr, int n) -{ - lumptr += CHANOFFSET(0); - while (n--) { - *lumptr = ILUM(rgbptr[OFFSET_R], - rgbptr[OFFSET_G], - rgbptr[OFFSET_B]); - lumptr += 4; - rgbptr += 4; - } -} - -static int -compressrow(unsigned char *lbuf, unsigned char *rlebuf, int z, int cnt) -{ - unsigned char *iptr, *ibufend, *sptr, *optr; - short todo, cc; - Py_Int32 count; - - lbuf += z; - iptr = lbuf; - ibufend = iptr + cnt * 4; - optr = rlebuf; - - while(iptr < ibufend) { - sptr = iptr; - iptr += 8; - while ((iptr 126 ? 126 : (short)count; - count -= todo; - *optr++ = 0x80 | todo; - while (todo > 8) { - optr[0] = sptr[0 * 4]; - optr[1] = sptr[1 * 4]; - optr[2] = sptr[2 * 4]; - optr[3] = sptr[3 * 4]; - optr[4] = sptr[4 * 4]; - optr[5] = sptr[5 * 4]; - optr[6] = sptr[6 * 4]; - optr[7] = sptr[7 * 4]; - optr += 8; - sptr += 8 * 4; - todo -= 8; - } - while (todo--) { - *optr++ = *sptr; - sptr += 4; - } - } - sptr = iptr; - cc = *iptr; - iptr += 4; - while ((iptr < ibufend) && (*iptr == cc)) - iptr += 4; - count = (iptr - sptr) / 4; - while (count) { - todo = count > 126 ? 126 : (short)count; - count -= todo; - *optr++ = (unsigned char) todo; - *optr++ = (unsigned char) cc; - } - } - *optr++ = 0; - return optr - (unsigned char *)rlebuf; -} - -static PyObject * -ttob(PyObject *self, PyObject *args) -{ - int order, oldorder; - - if (!PyArg_ParseTuple(args, "i:ttob", &order)) - return NULL; - oldorder = reverse_order; - reverse_order = order; - return PyInt_FromLong(oldorder); -} - -static PyMethodDef -rgbimg_methods[] = { - {"sizeofimage", sizeofimage, METH_VARARGS}, - {"longimagedata", longimagedata, METH_VARARGS}, - {"longstoimage", longstoimage, METH_VARARGS}, - {"ttob", ttob, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - - -PyMODINIT_FUNC -initrgbimg(void) -{ - PyObject *m, *d; - m = Py_InitModule("rgbimg", rgbimg_methods); - d = PyModule_GetDict(m); - ImgfileError = PyErr_NewException("rgbimg.error", NULL, NULL); - if (ImgfileError != NULL) - PyDict_SetItemString(d, "error", ImgfileError); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/rotormodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/rotormodule.c deleted file mode 100644 index 988a8085..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/rotormodule.c +++ /dev/null @@ -1,627 +0,0 @@ -/*********************************************************** -Copyright 1994 by Lance Ellinghouse, -Cathedral City, California Republic, United States of America. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Lance Ellinghouse -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL LANCE ELLINGHOUSE BE LIABLE FOR ANY SPECIAL, -INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING -FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, -NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* This creates an encryption and decryption engine I am calling - a rotor due to the original design was a hardware rotor with - contacts used in Germany during WWII. - -Rotor Module: - -- rotor.newrotor('key') -> rotorobject (default of 6 rotors) -- rotor.newrotor('key', num_rotors) -> rotorobject - -Rotor Objects: - -- ro.setkey('string') -> None (resets the key as defined in newrotor(). -- ro.encrypt('string') -> encrypted string -- ro.decrypt('encrypted string') -> unencrypted string - -- ro.encryptmore('string') -> encrypted string -- ro.decryptmore('encrypted string') -> unencrypted string - -NOTE: the {en,de}cryptmore() methods use the setup that was - established via the {en,de}crypt calls. They will NOT - re-initalize the rotors unless: 1) They have not been - initialized with {en,de}crypt since the last setkey() call; - 2) {en,de}crypt has not been called for this rotor yet. - -NOTE: you MUST use the SAME key in rotor.newrotor() - if you wish to decrypt an encrypted string. - Also, the encrypted string is NOT 0-127 ASCII. - It is considered BINARY data. - -*/ - -/* Rotor objects */ - -#include "Python.h" - -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif - -typedef struct { - PyObject_HEAD - int seed[3]; - short key[5]; - int isinited; - int size; - int size_mask; - int rotors; - unsigned char *e_rotor; /* [num_rotors][size] */ - unsigned char *d_rotor; /* [num_rotors][size] */ - unsigned char *positions; /* [num_rotors] */ - unsigned char *advances; /* [num_rotors] */ -} Rotorobj; - -static PyTypeObject Rotor_Type; - -#define is_rotor(v) ((v)->ob_type == &Rotor_Type) - - -/* This defines the necessary routines to manage rotor objects */ - -static void -set_seed(Rotorobj *r) -{ - r->seed[0] = r->key[0]; - r->seed[1] = r->key[1]; - r->seed[2] = r->key[2]; - r->isinited = FALSE; -} - -/* Return the next random number in the range [0.0 .. 1.0) */ -static double -r_random(Rotorobj *r) -{ - int x, y, z; - double val, term; - - x = r->seed[0]; - y = r->seed[1]; - z = r->seed[2]; - - x = 171 * (x % 177) - 2 * (x/177); - y = 172 * (y % 176) - 35 * (y/176); - z = 170 * (z % 178) - 63 * (z/178); - - if (x < 0) x = x + 30269; - if (y < 0) y = y + 30307; - if (z < 0) z = z + 30323; - - r->seed[0] = x; - r->seed[1] = y; - r->seed[2] = z; - - term = (double)( - (((double)x)/(double)30269.0) + - (((double)y)/(double)30307.0) + - (((double)z)/(double)30323.0) - ); - val = term - (double)floor((double)term); - - if (val >= 1.0) - val = 0.0; - - return val; -} - -static short -r_rand(Rotorobj *r, short s) -{ - return (short)((short)(r_random(r) * (double)s) % s); -} - -static void -set_key(Rotorobj *r, char *key) -{ - unsigned long k1=995, k2=576, k3=767, k4=671, k5=463; - size_t i; - size_t len = strlen(key); - - for (i = 0; i < len; i++) { - unsigned short ki = Py_CHARMASK(key[i]); - - k1 = (((k1<<3 | k1>>13) + ki) & 65535); - k2 = (((k2<<3 | k2>>13) ^ ki) & 65535); - k3 = (((k3<<3 | k3>>13) - ki) & 65535); - k4 = ((ki - (k4<<3 | k4>>13)) & 65535); - k5 = (((k5<<3 | k5>>13) ^ ~ki) & 65535); - } - r->key[0] = (short)k1; - r->key[1] = (short)(k2|1); - r->key[2] = (short)k3; - r->key[3] = (short)k4; - r->key[4] = (short)k5; - - set_seed(r); -} - - - -/* These define the interface to a rotor object */ -static Rotorobj * -rotorobj_new(int num_rotors, char *key) -{ - Rotorobj *xp; - - xp = PyObject_New(Rotorobj, &Rotor_Type); - if (xp == NULL) - return NULL; - set_key(xp, key); - - xp->size = 256; - xp->size_mask = xp->size - 1; - xp->size_mask = 0; - xp->rotors = num_rotors; - xp->e_rotor = NULL; - xp->d_rotor = NULL; - xp->positions = NULL; - xp->advances = NULL; - - if (!(xp->e_rotor = PyMem_NEW(unsigned char, num_rotors * xp->size))) - goto finally; - if (!(xp->d_rotor = PyMem_NEW(unsigned char, num_rotors * xp->size))) - goto finally; - if (!(xp->positions = PyMem_NEW(unsigned char, num_rotors))) - goto finally; - if (!(xp->advances = PyMem_NEW(unsigned char, num_rotors))) - goto finally; - - return xp; - - finally: - if (xp->e_rotor) - PyMem_DEL(xp->e_rotor); - if (xp->d_rotor) - PyMem_DEL(xp->d_rotor); - if (xp->positions) - PyMem_DEL(xp->positions); - if (xp->advances) - PyMem_DEL(xp->advances); - Py_DECREF(xp); - return (Rotorobj*)PyErr_NoMemory(); -} - - -/* These routines implement the rotor itself */ - -/* Here is a fairly sophisticated {en,de}cryption system. It is based on - the idea of a "rotor" machine. A bunch of rotors, each with a - different permutation of the alphabet, rotate around a different amount - after encrypting one character. The current state of the rotors is - used to encrypt one character. - - The code is smart enough to tell if your alphabet has a number of - characters equal to a power of two. If it does, it uses logical - operations, if not it uses div and mod (both require a division). - - You will need to make two changes to the code 1) convert to c, and - customize for an alphabet of 255 chars 2) add a filter at the begining, - and end, which subtracts one on the way in, and adds one on the way - out. - - You might wish to do some timing studies. Another viable alternative - is to "byte stuff" the encrypted data of a normal (perhaps this one) - encryption routine. - - j' - - */ - -/* Note: the C code here is a fairly straightforward transliteration of a - * rotor implemented in lisp. The original lisp code has been removed from - * this file to for simplification, but I've kept the docstrings as - * comments in front of the functions. - */ - - -/* Set ROTOR to the identity permutation */ -static void -RTR_make_id_rotor(Rotorobj *r, unsigned char *rtr) -{ - register int j; - register int size = r->size; - for (j = 0; j < size; j++) { - rtr[j] = (unsigned char)j; - } -} - - -/* The current set of encryption rotors */ -static void -RTR_e_rotors(Rotorobj *r) -{ - int i; - for (i = 0; i < r->rotors; i++) { - RTR_make_id_rotor(r, &(r->e_rotor[(i*r->size)])); - } -} - -/* The current set of decryption rotors */ -static void -RTR_d_rotors(Rotorobj *r) -{ - register int i, j; - for (i = 0; i < r->rotors; i++) { - for (j = 0; j < r->size; j++) { - r->d_rotor[((i*r->size)+j)] = (unsigned char)j; - } - } -} - -/* The positions of the rotors at this time */ -static void -RTR_positions(Rotorobj *r) -{ - int i; - for (i = 0; i < r->rotors; i++) { - r->positions[i] = 1; - } -} - -/* The number of positions to advance the rotors at a time */ -static void -RTR_advances(Rotorobj *r) -{ - int i; - for (i = 0; i < r->rotors; i++) { - r->advances[i] = 1; - } -} - -/* Permute the E rotor, and make the D rotor its inverse - * see Knuth for explanation of algorithm. - */ -static void -RTR_permute_rotor(Rotorobj *r, unsigned char *e, unsigned char *d) -{ - short i = r->size; - short q; - unsigned char j; - RTR_make_id_rotor(r,e); - while (2 <= i) { - q = r_rand(r,i); - i--; - j = e[q]; - e[q] = (unsigned char)e[i]; - e[i] = (unsigned char)j; - d[j] = (unsigned char)i; - } - e[0] = (unsigned char)e[0]; - d[(e[0])] = (unsigned char)0; -} - -/* Given KEY (a list of 5 16 bit numbers), initialize the rotor machine. - * Set the advancement, position, and permutation of the rotors - */ -static void -RTR_init(Rotorobj *r) -{ - int i; - set_seed(r); - RTR_positions(r); - RTR_advances(r); - RTR_e_rotors(r); - RTR_d_rotors(r); - for (i = 0; i < r->rotors; i++) { - r->positions[i] = (unsigned char) r_rand(r, (short)r->size); - r->advances[i] = (1+(2*(r_rand(r, (short)(r->size/2))))); - RTR_permute_rotor(r, - &(r->e_rotor[(i*r->size)]), - &(r->d_rotor[(i*r->size)])); - } - r->isinited = TRUE; -} - -/* Change the RTR-positions vector, using the RTR-advances vector */ -static void -RTR_advance(Rotorobj *r) -{ - register int i=0, temp=0; - if (r->size_mask) { - while (i < r->rotors) { - temp = r->positions[i] + r->advances[i]; - r->positions[i] = temp & r->size_mask; - if ((temp >= r->size) && (i < (r->rotors - 1))) { - r->positions[(i+1)] = 1 + r->positions[(i+1)]; - } - i++; - } - } else { - while (i < r->rotors) { - temp = r->positions[i] + r->advances[i]; - r->positions[i] = temp%r->size; - if ((temp >= r->size) && (i < (r->rotors - 1))) { - r->positions[(i+1)] = 1 + r->positions[(i+1)]; - } - i++; - } - } -} - -/* Encrypt the character P with the current rotor machine */ -static unsigned char -RTR_e_char(Rotorobj *r, unsigned char p) -{ - register int i=0; - register unsigned char tp=p; - if (r->size_mask) { - while (i < r->rotors) { - tp = r->e_rotor[(i*r->size) + - (((r->positions[i] ^ tp) & - r->size_mask))]; - i++; - } - } else { - while (i < r->rotors) { - tp = r->e_rotor[(i*r->size) + - (((r->positions[i] ^ tp) % - (unsigned int) r->size))]; - i++; - } - } - RTR_advance(r); - return ((unsigned char)tp); -} - -/* Decrypt the character C with the current rotor machine */ -static unsigned char -RTR_d_char(Rotorobj *r, unsigned char c) -{ - register int i = r->rotors - 1; - register unsigned char tc = c; - - if (r->size_mask) { - while (0 <= i) { - tc = (r->positions[i] ^ - r->d_rotor[(i*r->size)+tc]) & r->size_mask; - i--; - } - } else { - while (0 <= i) { - tc = (r->positions[i] ^ - r->d_rotor[(i*r->size)+tc]) % - (unsigned int) r->size; - i--; - } - } - RTR_advance(r); - return(tc); -} - -/* Perform a rotor encryption of the region from BEG to END by KEY */ -static void -RTR_e_region(Rotorobj *r, unsigned char *beg, int len, int doinit) -{ - register int i; - if (doinit || r->isinited == FALSE) - RTR_init(r); - for (i = 0; i < len; i++) { - beg[i] = RTR_e_char(r, beg[i]); - } -} - -/* Perform a rotor decryption of the region from BEG to END by KEY */ -static void -RTR_d_region(Rotorobj *r, unsigned char *beg, int len, int doinit) -{ - register int i; - if (doinit || r->isinited == FALSE) - RTR_init(r); - for (i = 0; i < len; i++) { - beg[i] = RTR_d_char(r, beg[i]); - } -} - - - -/* Rotor methods */ -static void -rotor_dealloc(Rotorobj *xp) -{ - if (xp->e_rotor) - PyMem_DEL(xp->e_rotor); - if (xp->d_rotor) - PyMem_DEL(xp->d_rotor); - if (xp->positions) - PyMem_DEL(xp->positions); - if (xp->advances) - PyMem_DEL(xp->advances); - PyObject_Del(xp); -} - -static PyObject * -rotorobj_encrypt(Rotorobj *self, PyObject *args) -{ - char *string = NULL; - int len = 0; - PyObject *rtn = NULL; - char *tmp; - - if (!PyArg_ParseTuple(args, "s#:encrypt", &string, &len)) - return NULL; - if (!(tmp = PyMem_NEW(char, len+5))) { - PyErr_NoMemory(); - return NULL; - } - memset(tmp, '\0', len+1); - memcpy(tmp, string, len); - RTR_e_region(self, (unsigned char *)tmp, len, TRUE); - rtn = PyString_FromStringAndSize(tmp, len); - PyMem_DEL(tmp); - return(rtn); -} - -static PyObject * -rotorobj_encrypt_more(Rotorobj *self, PyObject *args) -{ - char *string = NULL; - int len = 0; - PyObject *rtn = NULL; - char *tmp; - - if (!PyArg_ParseTuple(args, "s#:encrypt_more", &string, &len)) - return NULL; - if (!(tmp = PyMem_NEW(char, len+5))) { - PyErr_NoMemory(); - return NULL; - } - memset(tmp, '\0', len+1); - memcpy(tmp, string, len); - RTR_e_region(self, (unsigned char *)tmp, len, FALSE); - rtn = PyString_FromStringAndSize(tmp, len); - PyMem_DEL(tmp); - return(rtn); -} - -static PyObject * -rotorobj_decrypt(Rotorobj *self, PyObject *args) -{ - char *string = NULL; - int len = 0; - PyObject *rtn = NULL; - char *tmp; - - if (!PyArg_ParseTuple(args, "s#:decrypt", &string, &len)) - return NULL; - if (!(tmp = PyMem_NEW(char, len+5))) { - PyErr_NoMemory(); - return NULL; - } - memset(tmp, '\0', len+1); - memcpy(tmp, string, len); - RTR_d_region(self, (unsigned char *)tmp, len, TRUE); - rtn = PyString_FromStringAndSize(tmp, len); - PyMem_DEL(tmp); - return(rtn); -} - -static PyObject * -rotorobj_decrypt_more(Rotorobj *self, PyObject *args) -{ - char *string = NULL; - int len = 0; - PyObject *rtn = NULL; - char *tmp; - - if (!PyArg_ParseTuple(args, "s#:decrypt_more", &string, &len)) - return NULL; - if (!(tmp = PyMem_NEW(char, len+5))) { - PyErr_NoMemory(); - return NULL; - } - memset(tmp, '\0', len+1); - memcpy(tmp, string, len); - RTR_d_region(self, (unsigned char *)tmp, len, FALSE); - rtn = PyString_FromStringAndSize(tmp, len); - PyMem_DEL(tmp); - return(rtn); -} - -static PyObject * -rotorobj_setkey(Rotorobj *self, PyObject *args) -{ - char *key; - - if (!PyArg_ParseTuple(args, "s:setkey", &key)) - return NULL; - - set_key(self, key); - Py_INCREF(Py_None); - return Py_None; -} - -static struct PyMethodDef -rotorobj_methods[] = { - {"encrypt", (PyCFunction)rotorobj_encrypt, METH_VARARGS}, - {"encryptmore", (PyCFunction)rotorobj_encrypt_more, METH_VARARGS}, - {"decrypt", (PyCFunction)rotorobj_decrypt, METH_VARARGS}, - {"decryptmore", (PyCFunction)rotorobj_decrypt_more, METH_VARARGS}, - {"setkey", (PyCFunction)rotorobj_setkey, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - - -/* Return a rotor object's named attribute. */ -static PyObject * -rotorobj_getattr(Rotorobj *s, char *name) -{ - return Py_FindMethod(rotorobj_methods, (PyObject*)s, name); -} - - -static PyTypeObject Rotor_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "rotor.rotor", /*tp_name*/ - sizeof(Rotorobj), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)rotor_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)rotorobj_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_hash*/ -}; - - -static PyObject * -rotor_rotor(PyObject *self, PyObject *args) -{ - Rotorobj *r; - char *string; - int num_rotors = 6; - - if (!PyArg_ParseTuple(args, "s|i:newrotor", &string, &num_rotors)) - return NULL; - - r = rotorobj_new(num_rotors, string); - return (PyObject *)r; -} - - - -static struct PyMethodDef -rotor_methods[] = { - {"newrotor", rotor_rotor, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - - -PyMODINIT_FUNC -initrotor(void) -{ - Rotor_Type.ob_type = &PyType_Type; - (void)Py_InitModule("rotor", rotor_methods); - if (PyErr_Warn(PyExc_DeprecationWarning, - "the rotor module uses an insecure algorithm " - "and is deprecated") < 0) - return; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/selectmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/selectmodule.c deleted file mode 100644 index 0199f914..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/selectmodule.c +++ /dev/null @@ -1,688 +0,0 @@ -/* select - Module containing unix select(2) call. - Under Unix, the file descriptors are small integers. - Under Win32, select only exists for sockets, and sockets may - have any value except INVALID_SOCKET. - Under BeOS, we suffer the same dichotomy as Win32; sockets can be anything - >= 0. -*/ - -#include "Python.h" - -/* Windows #defines FD_SETSIZE to 64 if FD_SETSIZE isn't already defined. - 64 is too small (too many people have bumped into that limit). - Here we boost it. - Users who want even more than the boosted limit should #define - FD_SETSIZE higher before this; e.g., via compiler /D switch. -*/ -#if defined(MS_WINDOWS) && !defined(FD_SETSIZE) -#define FD_SETSIZE 512 -#endif - -#if defined(HAVE_POLL_H) -#include -#elif defined(HAVE_SYS_POLL_H) -#include -#endif - -#ifdef __sgi -/* This is missing from unistd.h */ -extern void bzero(void *, int); -#endif - -#ifndef DONT_HAVE_SYS_TYPES_H -#include -#endif - -#if defined(PYOS_OS2) && !defined(PYCC_GCC) -#include -#include -#endif - -#ifdef MS_WINDOWS -#include -#else -#ifdef __BEOS__ -#include -#define SOCKET int -#else -#define SOCKET int -#endif -#endif - - -static PyObject *SelectError; - -/* list of Python objects and their file descriptor */ -typedef struct { - PyObject *obj; /* owned reference */ - SOCKET fd; - int sentinel; /* -1 == sentinel */ -} pylist; - -static void -reap_obj(pylist fd2obj[FD_SETSIZE + 1]) -{ - int i; - for (i = 0; i < FD_SETSIZE + 1 && fd2obj[i].sentinel >= 0; i++) { - Py_XDECREF(fd2obj[i].obj); - fd2obj[i].obj = NULL; - } - fd2obj[0].sentinel = -1; -} - - -/* returns -1 and sets the Python exception if an error occurred, otherwise - returns a number >= 0 -*/ -static int -list2set(PyObject *list, fd_set *set, pylist fd2obj[FD_SETSIZE + 1]) -{ - int i; - int max = -1; - int index = 0; - int len = PyList_Size(list); - PyObject* o = NULL; - - fd2obj[0].obj = (PyObject*)0; /* set list to zero size */ - FD_ZERO(set); - - for (i = 0; i < len; i++) { - SOCKET v; - - /* any intervening fileno() calls could decr this refcnt */ - if (!(o = PyList_GetItem(list, i))) - return -1; - - Py_INCREF(o); - v = PyObject_AsFileDescriptor( o ); - if (v == -1) goto finally; - -#if defined(_MSC_VER) - max = 0; /* not used for Win32 */ -#else /* !_MSC_VER */ - if (v < 0 || v >= FD_SETSIZE) { - PyErr_SetString(PyExc_ValueError, - "filedescriptor out of range in select()"); - goto finally; - } - if (v > max) - max = v; -#endif /* _MSC_VER */ - FD_SET(v, set); - - /* add object and its file descriptor to the list */ - if (index >= FD_SETSIZE) { - PyErr_SetString(PyExc_ValueError, - "too many file descriptors in select()"); - goto finally; - } - fd2obj[index].obj = o; - fd2obj[index].fd = v; - fd2obj[index].sentinel = 0; - fd2obj[++index].sentinel = -1; - } - return max+1; - - finally: - Py_XDECREF(o); - return -1; -} - -/* returns NULL and sets the Python exception if an error occurred */ -static PyObject * -set2list(fd_set *set, pylist fd2obj[FD_SETSIZE + 1]) -{ - int i, j, count=0; - PyObject *list, *o; - SOCKET fd; - - for (j = 0; fd2obj[j].sentinel >= 0; j++) { - if (FD_ISSET(fd2obj[j].fd, set)) - count++; - } - list = PyList_New(count); - if (!list) - return NULL; - - i = 0; - for (j = 0; fd2obj[j].sentinel >= 0; j++) { - fd = fd2obj[j].fd; - if (FD_ISSET(fd, set)) { -#ifndef _MSC_VER - if (fd > FD_SETSIZE) { - PyErr_SetString(PyExc_SystemError, - "filedescriptor out of range returned in select()"); - goto finally; - } -#endif - o = fd2obj[j].obj; - fd2obj[j].obj = NULL; - /* transfer ownership */ - if (PyList_SetItem(list, i, o) < 0) - goto finally; - - i++; - } - } - return list; - finally: - Py_DECREF(list); - return NULL; -} - -#undef SELECT_USES_HEAP -#if FD_SETSIZE > 1024 -#define SELECT_USES_HEAP -#endif /* FD_SETSIZE > 1024 */ - -static PyObject * -select_select(PyObject *self, PyObject *args) -{ -#ifdef SELECT_USES_HEAP - pylist *rfd2obj, *wfd2obj, *efd2obj; -#else /* !SELECT_USES_HEAP */ - /* XXX: All this should probably be implemented as follows: - * - find the highest descriptor we're interested in - * - add one - * - that's the size - * See: Stevens, APitUE, $12.5.1 - */ - pylist rfd2obj[FD_SETSIZE + 1]; - pylist wfd2obj[FD_SETSIZE + 1]; - pylist efd2obj[FD_SETSIZE + 1]; -#endif /* SELECT_USES_HEAP */ - PyObject *ifdlist, *ofdlist, *efdlist; - PyObject *ret = NULL; - PyObject *tout = Py_None; - fd_set ifdset, ofdset, efdset; - double timeout; - struct timeval tv, *tvp; - long seconds; - int imax, omax, emax, max; - int n; - - /* convert arguments */ - if (!PyArg_ParseTuple(args, "OOO|O:select", - &ifdlist, &ofdlist, &efdlist, &tout)) - return NULL; - - if (tout == Py_None) - tvp = (struct timeval *)0; - else if (!PyNumber_Check(tout)) { - PyErr_SetString(PyExc_TypeError, - "timeout must be a float or None"); - return NULL; - } - else { - timeout = PyFloat_AsDouble(tout); - if (timeout == -1 && PyErr_Occurred()) - return NULL; - if (timeout > (double)LONG_MAX) { - PyErr_SetString(PyExc_OverflowError, - "timeout period too long"); - return NULL; - } - seconds = (long)timeout; - timeout = timeout - (double)seconds; - tv.tv_sec = seconds; - tv.tv_usec = (long)(timeout*1000000.0); - tvp = &tv; - } - - /* sanity check first three arguments */ - if (!PyList_Check(ifdlist) || - !PyList_Check(ofdlist) || - !PyList_Check(efdlist)) - { - PyErr_SetString(PyExc_TypeError, - "arguments 1-3 must be lists"); - return NULL; - } - -#ifdef SELECT_USES_HEAP - /* Allocate memory for the lists */ - rfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1); - wfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1); - efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1); - if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) { - if (rfd2obj) PyMem_DEL(rfd2obj); - if (wfd2obj) PyMem_DEL(wfd2obj); - if (efd2obj) PyMem_DEL(efd2obj); - return PyErr_NoMemory(); - } -#endif /* SELECT_USES_HEAP */ - /* Convert lists to fd_sets, and get maximum fd number - * propagates the Python exception set in list2set() - */ - rfd2obj[0].sentinel = -1; - wfd2obj[0].sentinel = -1; - efd2obj[0].sentinel = -1; - if ((imax=list2set(ifdlist, &ifdset, rfd2obj)) < 0) - goto finally; - if ((omax=list2set(ofdlist, &ofdset, wfd2obj)) < 0) - goto finally; - if ((emax=list2set(efdlist, &efdset, efd2obj)) < 0) - goto finally; - max = imax; - if (omax > max) max = omax; - if (emax > max) max = emax; - - Py_BEGIN_ALLOW_THREADS - n = select(max, &ifdset, &ofdset, &efdset, tvp); - Py_END_ALLOW_THREADS - -#ifdef MS_WINDOWS - if (n == SOCKET_ERROR) { - PyErr_SetExcFromWindowsErr(SelectError, WSAGetLastError()); - } -#else - if (n < 0) { - PyErr_SetFromErrno(SelectError); - } -#endif - else if (n == 0) { - /* optimization */ - ifdlist = PyList_New(0); - if (ifdlist) { - ret = Py_BuildValue("OOO", ifdlist, ifdlist, ifdlist); - Py_DECREF(ifdlist); - } - } - else { - /* any of these three calls can raise an exception. it's more - convenient to test for this after all three calls... but - is that acceptable? - */ - ifdlist = set2list(&ifdset, rfd2obj); - ofdlist = set2list(&ofdset, wfd2obj); - efdlist = set2list(&efdset, efd2obj); - if (PyErr_Occurred()) - ret = NULL; - else - ret = Py_BuildValue("OOO", ifdlist, ofdlist, efdlist); - - Py_DECREF(ifdlist); - Py_DECREF(ofdlist); - Py_DECREF(efdlist); - } - - finally: - reap_obj(rfd2obj); - reap_obj(wfd2obj); - reap_obj(efd2obj); -#ifdef SELECT_USES_HEAP - PyMem_DEL(rfd2obj); - PyMem_DEL(wfd2obj); - PyMem_DEL(efd2obj); -#endif /* SELECT_USES_HEAP */ - return ret; -} - -#ifdef HAVE_POLL -/* - * poll() support - */ - -typedef struct { - PyObject_HEAD - PyObject *dict; - int ufd_uptodate; - int ufd_len; - struct pollfd *ufds; -} pollObject; - -static PyTypeObject poll_Type; - -/* Update the malloc'ed array of pollfds to match the dictionary - contained within a pollObject. Return 1 on success, 0 on an error. -*/ - -static int -update_ufd_array(pollObject *self) -{ - int i, pos; - PyObject *key, *value; - - self->ufd_len = PyDict_Size(self->dict); - PyMem_Resize(self->ufds, struct pollfd, self->ufd_len); - if (self->ufds == NULL) { - PyErr_NoMemory(); - return 0; - } - - i = pos = 0; - while (PyDict_Next(self->dict, &pos, &key, &value)) { - self->ufds[i].fd = PyInt_AsLong(key); - self->ufds[i].events = (short)PyInt_AsLong(value); - i++; - } - self->ufd_uptodate = 1; - return 1; -} - -PyDoc_STRVAR(poll_register_doc, -"register(fd [, eventmask] ) -> None\n\n\ -Register a file descriptor with the polling object.\n\ -fd -- either an integer, or an object with a fileno() method returning an\n\ - int.\n\ -events -- an optional bitmask describing the type of events to check for"); - -static PyObject * -poll_register(pollObject *self, PyObject *args) -{ - PyObject *o, *key, *value; - int fd, events = POLLIN | POLLPRI | POLLOUT; - int err; - - if (!PyArg_ParseTuple(args, "O|i:register", &o, &events)) { - return NULL; - } - - fd = PyObject_AsFileDescriptor(o); - if (fd == -1) return NULL; - - /* Add entry to the internal dictionary: the key is the - file descriptor, and the value is the event mask. */ - key = PyInt_FromLong(fd); - if (key == NULL) - return NULL; - value = PyInt_FromLong(events); - if (value == NULL) { - Py_DECREF(key); - return NULL; - } - err = PyDict_SetItem(self->dict, key, value); - Py_DECREF(key); - Py_DECREF(value); - if (err < 0) - return NULL; - - self->ufd_uptodate = 0; - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(poll_unregister_doc, -"unregister(fd) -> None\n\n\ -Remove a file descriptor being tracked by the polling object."); - -static PyObject * -poll_unregister(pollObject *self, PyObject *args) -{ - PyObject *o, *key; - int fd; - - if (!PyArg_ParseTuple(args, "O:unregister", &o)) { - return NULL; - } - - fd = PyObject_AsFileDescriptor( o ); - if (fd == -1) - return NULL; - - /* Check whether the fd is already in the array */ - key = PyInt_FromLong(fd); - if (key == NULL) - return NULL; - - if (PyDict_DelItem(self->dict, key) == -1) { - Py_DECREF(key); - /* This will simply raise the KeyError set by PyDict_DelItem - if the file descriptor isn't registered. */ - return NULL; - } - - Py_DECREF(key); - self->ufd_uptodate = 0; - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(poll_poll_doc, -"poll( [timeout] ) -> list of (fd, event) 2-tuples\n\n\ -Polls the set of registered file descriptors, returning a list containing \n\ -any descriptors that have events or errors to report."); - -static PyObject * -poll_poll(pollObject *self, PyObject *args) -{ - PyObject *result_list = NULL, *tout = NULL; - int timeout = 0, poll_result, i, j; - PyObject *value = NULL, *num = NULL; - - if (!PyArg_ParseTuple(args, "|O:poll", &tout)) { - return NULL; - } - - /* Check values for timeout */ - if (tout == NULL || tout == Py_None) - timeout = -1; - else if (!PyNumber_Check(tout)) { - PyErr_SetString(PyExc_TypeError, - "timeout must be an integer or None"); - return NULL; - } - else { - tout = PyNumber_Int(tout); - if (!tout) - return NULL; - timeout = PyInt_AsLong(tout); - Py_DECREF(tout); - } - - /* Ensure the ufd array is up to date */ - if (!self->ufd_uptodate) - if (update_ufd_array(self) == 0) - return NULL; - - /* call poll() */ - Py_BEGIN_ALLOW_THREADS; - poll_result = poll(self->ufds, self->ufd_len, timeout); - Py_END_ALLOW_THREADS; - - if (poll_result < 0) { - PyErr_SetFromErrno(SelectError); - return NULL; - } - - /* build the result list */ - - result_list = PyList_New(poll_result); - if (!result_list) - return NULL; - else { - for (i = 0, j = 0; j < poll_result; j++) { - /* skip to the next fired descriptor */ - while (!self->ufds[i].revents) { - i++; - } - /* if we hit a NULL return, set value to NULL - and break out of loop; code at end will - clean up result_list */ - value = PyTuple_New(2); - if (value == NULL) - goto error; - num = PyInt_FromLong(self->ufds[i].fd); - if (num == NULL) { - Py_DECREF(value); - goto error; - } - PyTuple_SET_ITEM(value, 0, num); - - num = PyInt_FromLong(self->ufds[i].revents); - if (num == NULL) { - Py_DECREF(value); - goto error; - } - PyTuple_SET_ITEM(value, 1, num); - if ((PyList_SetItem(result_list, j, value)) == -1) { - Py_DECREF(value); - goto error; - } - i++; - } - } - return result_list; - - error: - Py_DECREF(result_list); - return NULL; -} - -static PyMethodDef poll_methods[] = { - {"register", (PyCFunction)poll_register, - METH_VARARGS, poll_register_doc}, - {"unregister", (PyCFunction)poll_unregister, - METH_VARARGS, poll_unregister_doc}, - {"poll", (PyCFunction)poll_poll, - METH_VARARGS, poll_poll_doc}, - {NULL, NULL} /* sentinel */ -}; - -static pollObject * -newPollObject(void) -{ - pollObject *self; - self = PyObject_New(pollObject, &poll_Type); - if (self == NULL) - return NULL; - /* ufd_uptodate is a Boolean, denoting whether the - array pointed to by ufds matches the contents of the dictionary. */ - self->ufd_uptodate = 0; - self->ufds = NULL; - self->dict = PyDict_New(); - if (self->dict == NULL) { - Py_DECREF(self); - return NULL; - } - return self; -} - -static void -poll_dealloc(pollObject *self) -{ - if (self->ufds != NULL) - PyMem_DEL(self->ufds); - Py_XDECREF(self->dict); - PyObject_Del(self); -} - -static PyObject * -poll_getattr(pollObject *self, char *name) -{ - return Py_FindMethod(poll_methods, (PyObject *)self, name); -} - -static PyTypeObject poll_Type = { - /* The ob_type field must be initialized in the module init function - * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "select.poll", /*tp_name*/ - sizeof(pollObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)poll_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)poll_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ -}; - -PyDoc_STRVAR(poll_doc, -"Returns a polling object, which supports registering and\n\ -unregistering file descriptors, and then polling them for I/O events."); - -static PyObject * -select_poll(PyObject *self, PyObject *args) -{ - pollObject *rv; - - if (!PyArg_ParseTuple(args, ":poll")) - return NULL; - rv = newPollObject(); - if ( rv == NULL ) - return NULL; - return (PyObject *)rv; -} -#endif /* HAVE_POLL */ - -PyDoc_STRVAR(select_doc, -"select(rlist, wlist, xlist[, timeout]) -> (rlist, wlist, xlist)\n\ -\n\ -Wait until one or more file descriptors are ready for some kind of I/O.\n\ -The first three arguments are lists of file descriptors to be waited for:\n\ -rlist -- wait until ready for reading\n\ -wlist -- wait until ready for writing\n\ -xlist -- wait for an ``exceptional condition''\n\ -If only one kind of condition is required, pass [] for the other lists.\n\ -A file descriptor is either a socket or file object, or a small integer\n\ -gotten from a fileno() method call on one of those.\n\ -\n\ -The optional 4th argument specifies a timeout in seconds; it may be\n\ -a floating point number to specify fractions of seconds. If it is absent\n\ -or None, the call will never time out.\n\ -\n\ -The return value is a tuple of three lists corresponding to the first three\n\ -arguments; each contains the subset of the corresponding file descriptors\n\ -that are ready.\n\ -\n\ -*** IMPORTANT NOTICE ***\n\ -On Windows, only sockets are supported; on Unix, all file descriptors."); - -static PyMethodDef select_methods[] = { - {"select", select_select, METH_VARARGS, select_doc}, -#ifdef HAVE_POLL - {"poll", select_poll, METH_VARARGS, poll_doc}, -#endif /* HAVE_POLL */ - {0, 0}, /* sentinel */ -}; - -PyDoc_STRVAR(module_doc, -"This module supports asynchronous I/O on multiple file descriptors.\n\ -\n\ -*** IMPORTANT NOTICE ***\n\ -On Windows, only sockets are supported; on Unix, all file descriptors."); - -PyMODINIT_FUNC -initselect(void) -{ - PyObject *m; - m = Py_InitModule3("select", select_methods, module_doc); - - SelectError = PyErr_NewException("select.error", NULL, NULL); - Py_INCREF(SelectError); - PyModule_AddObject(m, "error", SelectError); -#ifdef HAVE_POLL - poll_Type.ob_type = &PyType_Type; - PyModule_AddIntConstant(m, "POLLIN", POLLIN); - PyModule_AddIntConstant(m, "POLLPRI", POLLPRI); - PyModule_AddIntConstant(m, "POLLOUT", POLLOUT); - PyModule_AddIntConstant(m, "POLLERR", POLLERR); - PyModule_AddIntConstant(m, "POLLHUP", POLLHUP); - PyModule_AddIntConstant(m, "POLLNVAL", POLLNVAL); - -#ifdef POLLRDNORM - PyModule_AddIntConstant(m, "POLLRDNORM", POLLRDNORM); -#endif -#ifdef POLLRDBAND - PyModule_AddIntConstant(m, "POLLRDBAND", POLLRDBAND); -#endif -#ifdef POLLWRNORM - PyModule_AddIntConstant(m, "POLLWRNORM", POLLWRNORM); -#endif -#ifdef POLLWRBAND - PyModule_AddIntConstant(m, "POLLWRBAND", POLLWRBAND); -#endif -#ifdef POLLMSG - PyModule_AddIntConstant(m, "POLLMSG", POLLMSG); -#endif -#endif /* HAVE_POLL */ -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/sgimodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/sgimodule.c deleted file mode 100644 index 6923d3c9..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/sgimodule.c +++ /dev/null @@ -1,55 +0,0 @@ - -/* SGI module -- random SGI-specific things */ - -#include "Python.h" - -#include -#include -#include - -static PyObject * -sgi_nap(PyObject *self, PyObject *args) -{ - long ticks; - if (!PyArg_ParseTuple(args, "l:nap", &ticks)) - return NULL; - Py_BEGIN_ALLOW_THREADS - sginap(ticks); - Py_END_ALLOW_THREADS - Py_INCREF(Py_None); - return Py_None; -} - -extern char *_getpty(int *, int, mode_t, int); - -static PyObject * -sgi__getpty(PyObject *self, PyObject *args) -{ - int oflag; - int mode; - int nofork; - char *name; - int fildes; - if (!PyArg_ParseTuple(args, "iii:_getpty", &oflag, &mode, &nofork)) - return NULL; - errno = 0; - name = _getpty(&fildes, oflag, (mode_t)mode, nofork); - if (name == NULL) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - return Py_BuildValue("(si)", name, fildes); -} - -static PyMethodDef sgi_methods[] = { - {"nap", sgi_nap, METH_VARARGS}, - {"_getpty", sgi__getpty, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - - -void -initsgi(void) -{ - Py_InitModule("sgi", sgi_methods); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/shamodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/shamodule.c deleted file mode 100644 index 13394713..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/shamodule.c +++ /dev/null @@ -1,542 +0,0 @@ -/* SHA module */ - -/* This module provides an interface to NIST's Secure Hash Algorithm */ - -/* See below for information about the original code this module was - based upon. Additional work performed by: - - Andrew Kuchling (amk@amk.ca) - Greg Stein (gstein@lyra.org) -*/ - -/* SHA objects */ - -#include "Python.h" - - -/* Endianness testing and definitions */ -#define TestEndianness(variable) {int i=1; variable=PCT_BIG_ENDIAN;\ - if (*((char*)&i)==1) variable=PCT_LITTLE_ENDIAN;} - -#define PCT_LITTLE_ENDIAN 1 -#define PCT_BIG_ENDIAN 0 - -/* Some useful types */ - -typedef unsigned char SHA_BYTE; - -#if SIZEOF_INT == 4 -typedef unsigned int SHA_INT32; /* 32-bit integer */ -#else -/* not defined. compilation will die. */ -#endif - -/* The SHA block size and message digest sizes, in bytes */ - -#define SHA_BLOCKSIZE 64 -#define SHA_DIGESTSIZE 20 - -/* The structure for storing SHS info */ - -typedef struct { - PyObject_HEAD - SHA_INT32 digest[5]; /* Message digest */ - SHA_INT32 count_lo, count_hi; /* 64-bit bit count */ - SHA_BYTE data[SHA_BLOCKSIZE]; /* SHA data buffer */ - int Endianness; - int local; /* unprocessed amount in data */ -} SHAobject; - -/* When run on a little-endian CPU we need to perform byte reversal on an - array of longwords. */ - -static void longReverse(SHA_INT32 *buffer, int byteCount, int Endianness) -{ - SHA_INT32 value; - - if ( Endianness == PCT_BIG_ENDIAN ) - return; - - byteCount /= sizeof(*buffer); - while (byteCount--) { - value = *buffer; - value = ( ( value & 0xFF00FF00L ) >> 8 ) | \ - ( ( value & 0x00FF00FFL ) << 8 ); - *buffer++ = ( value << 16 ) | ( value >> 16 ); - } -} - -static void SHAcopy(SHAobject *src, SHAobject *dest) -{ - dest->Endianness = src->Endianness; - dest->local = src->local; - dest->count_lo = src->count_lo; - dest->count_hi = src->count_hi; - memcpy(dest->digest, src->digest, sizeof(src->digest)); - memcpy(dest->data, src->data, sizeof(src->data)); -} - - -/* ------------------------------------------------------------------------ - * - * This code for the SHA algorithm was noted as public domain. The original - * headers are pasted below. - * - * Several changes have been made to make it more compatible with the - * Python environment and desired interface. - * - */ - -/* NIST Secure Hash Algorithm */ -/* heavily modified by Uwe Hollerbach */ -/* from Peter C. Gutmann's implementation as found in */ -/* Applied Cryptography by Bruce Schneier */ -/* Further modifications to include the "UNRAVEL" stuff, below */ - -/* This code is in the public domain */ - -/* UNRAVEL should be fastest & biggest */ -/* UNROLL_LOOPS should be just as big, but slightly slower */ -/* both undefined should be smallest and slowest */ - -#define UNRAVEL -/* #define UNROLL_LOOPS */ - -/* The SHA f()-functions. The f1 and f3 functions can be optimized to - save one boolean operation each - thanks to Rich Schroeppel, - rcs@cs.arizona.edu for discovering this */ - -/*#define f1(x,y,z) ((x & y) | (~x & z)) // Rounds 0-19 */ -#define f1(x,y,z) (z ^ (x & (y ^ z))) /* Rounds 0-19 */ -#define f2(x,y,z) (x ^ y ^ z) /* Rounds 20-39 */ -/*#define f3(x,y,z) ((x & y) | (x & z) | (y & z)) // Rounds 40-59 */ -#define f3(x,y,z) ((x & y) | (z & (x | y))) /* Rounds 40-59 */ -#define f4(x,y,z) (x ^ y ^ z) /* Rounds 60-79 */ - -/* SHA constants */ - -#define CONST1 0x5a827999L /* Rounds 0-19 */ -#define CONST2 0x6ed9eba1L /* Rounds 20-39 */ -#define CONST3 0x8f1bbcdcL /* Rounds 40-59 */ -#define CONST4 0xca62c1d6L /* Rounds 60-79 */ - -/* 32-bit rotate */ - -#define R32(x,n) ((x << n) | (x >> (32 - n))) - -/* the generic case, for when the overall rotation is not unraveled */ - -#define FG(n) \ - T = R32(A,5) + f##n(B,C,D) + E + *WP++ + CONST##n; \ - E = D; D = C; C = R32(B,30); B = A; A = T - -/* specific cases, for when the overall rotation is unraveled */ - -#define FA(n) \ - T = R32(A,5) + f##n(B,C,D) + E + *WP++ + CONST##n; B = R32(B,30) - -#define FB(n) \ - E = R32(T,5) + f##n(A,B,C) + D + *WP++ + CONST##n; A = R32(A,30) - -#define FC(n) \ - D = R32(E,5) + f##n(T,A,B) + C + *WP++ + CONST##n; T = R32(T,30) - -#define FD(n) \ - C = R32(D,5) + f##n(E,T,A) + B + *WP++ + CONST##n; E = R32(E,30) - -#define FE(n) \ - B = R32(C,5) + f##n(D,E,T) + A + *WP++ + CONST##n; D = R32(D,30) - -#define FT(n) \ - A = R32(B,5) + f##n(C,D,E) + T + *WP++ + CONST##n; C = R32(C,30) - -/* do SHA transformation */ - -static void -sha_transform(SHAobject *sha_info) -{ - int i; - SHA_INT32 T, A, B, C, D, E, W[80], *WP; - - memcpy(W, sha_info->data, sizeof(sha_info->data)); - longReverse(W, (int)sizeof(sha_info->data), sha_info->Endianness); - - for (i = 16; i < 80; ++i) { - W[i] = W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]; - - /* extra rotation fix */ - W[i] = R32(W[i], 1); - } - A = sha_info->digest[0]; - B = sha_info->digest[1]; - C = sha_info->digest[2]; - D = sha_info->digest[3]; - E = sha_info->digest[4]; - WP = W; -#ifdef UNRAVEL - FA(1); FB(1); FC(1); FD(1); FE(1); FT(1); FA(1); FB(1); FC(1); FD(1); - FE(1); FT(1); FA(1); FB(1); FC(1); FD(1); FE(1); FT(1); FA(1); FB(1); - FC(2); FD(2); FE(2); FT(2); FA(2); FB(2); FC(2); FD(2); FE(2); FT(2); - FA(2); FB(2); FC(2); FD(2); FE(2); FT(2); FA(2); FB(2); FC(2); FD(2); - FE(3); FT(3); FA(3); FB(3); FC(3); FD(3); FE(3); FT(3); FA(3); FB(3); - FC(3); FD(3); FE(3); FT(3); FA(3); FB(3); FC(3); FD(3); FE(3); FT(3); - FA(4); FB(4); FC(4); FD(4); FE(4); FT(4); FA(4); FB(4); FC(4); FD(4); - FE(4); FT(4); FA(4); FB(4); FC(4); FD(4); FE(4); FT(4); FA(4); FB(4); - sha_info->digest[0] += E; - sha_info->digest[1] += T; - sha_info->digest[2] += A; - sha_info->digest[3] += B; - sha_info->digest[4] += C; -#else /* !UNRAVEL */ -#ifdef UNROLL_LOOPS - FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); - FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); - FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); - FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); - FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); - FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); - FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); - FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); -#else /* !UNROLL_LOOPS */ - for (i = 0; i < 20; ++i) { FG(1); } - for (i = 20; i < 40; ++i) { FG(2); } - for (i = 40; i < 60; ++i) { FG(3); } - for (i = 60; i < 80; ++i) { FG(4); } -#endif /* !UNROLL_LOOPS */ - sha_info->digest[0] += A; - sha_info->digest[1] += B; - sha_info->digest[2] += C; - sha_info->digest[3] += D; - sha_info->digest[4] += E; -#endif /* !UNRAVEL */ -} - -/* initialize the SHA digest */ - -static void -sha_init(SHAobject *sha_info) -{ - TestEndianness(sha_info->Endianness) - - sha_info->digest[0] = 0x67452301L; - sha_info->digest[1] = 0xefcdab89L; - sha_info->digest[2] = 0x98badcfeL; - sha_info->digest[3] = 0x10325476L; - sha_info->digest[4] = 0xc3d2e1f0L; - sha_info->count_lo = 0L; - sha_info->count_hi = 0L; - sha_info->local = 0; -} - -/* update the SHA digest */ - -static void -sha_update(SHAobject *sha_info, SHA_BYTE *buffer, int count) -{ - int i; - SHA_INT32 clo; - - clo = sha_info->count_lo + ((SHA_INT32) count << 3); - if (clo < sha_info->count_lo) { - ++sha_info->count_hi; - } - sha_info->count_lo = clo; - sha_info->count_hi += (SHA_INT32) count >> 29; - if (sha_info->local) { - i = SHA_BLOCKSIZE - sha_info->local; - if (i > count) { - i = count; - } - memcpy(((SHA_BYTE *) sha_info->data) + sha_info->local, buffer, i); - count -= i; - buffer += i; - sha_info->local += i; - if (sha_info->local == SHA_BLOCKSIZE) { - sha_transform(sha_info); - } - else { - return; - } - } - while (count >= SHA_BLOCKSIZE) { - memcpy(sha_info->data, buffer, SHA_BLOCKSIZE); - buffer += SHA_BLOCKSIZE; - count -= SHA_BLOCKSIZE; - sha_transform(sha_info); - } - memcpy(sha_info->data, buffer, count); - sha_info->local = count; -} - -/* finish computing the SHA digest */ - -static void -sha_final(unsigned char digest[20], SHAobject *sha_info) -{ - int count; - SHA_INT32 lo_bit_count, hi_bit_count; - - lo_bit_count = sha_info->count_lo; - hi_bit_count = sha_info->count_hi; - count = (int) ((lo_bit_count >> 3) & 0x3f); - ((SHA_BYTE *) sha_info->data)[count++] = 0x80; - if (count > SHA_BLOCKSIZE - 8) { - memset(((SHA_BYTE *) sha_info->data) + count, 0, - SHA_BLOCKSIZE - count); - sha_transform(sha_info); - memset((SHA_BYTE *) sha_info->data, 0, SHA_BLOCKSIZE - 8); - } - else { - memset(((SHA_BYTE *) sha_info->data) + count, 0, - SHA_BLOCKSIZE - 8 - count); - } - - /* GJS: note that we add the hi/lo in big-endian. sha_transform will - swap these values into host-order. */ - sha_info->data[56] = (hi_bit_count >> 24) & 0xff; - sha_info->data[57] = (hi_bit_count >> 16) & 0xff; - sha_info->data[58] = (hi_bit_count >> 8) & 0xff; - sha_info->data[59] = (hi_bit_count >> 0) & 0xff; - sha_info->data[60] = (lo_bit_count >> 24) & 0xff; - sha_info->data[61] = (lo_bit_count >> 16) & 0xff; - sha_info->data[62] = (lo_bit_count >> 8) & 0xff; - sha_info->data[63] = (lo_bit_count >> 0) & 0xff; - sha_transform(sha_info); - digest[ 0] = (unsigned char) ((sha_info->digest[0] >> 24) & 0xff); - digest[ 1] = (unsigned char) ((sha_info->digest[0] >> 16) & 0xff); - digest[ 2] = (unsigned char) ((sha_info->digest[0] >> 8) & 0xff); - digest[ 3] = (unsigned char) ((sha_info->digest[0] ) & 0xff); - digest[ 4] = (unsigned char) ((sha_info->digest[1] >> 24) & 0xff); - digest[ 5] = (unsigned char) ((sha_info->digest[1] >> 16) & 0xff); - digest[ 6] = (unsigned char) ((sha_info->digest[1] >> 8) & 0xff); - digest[ 7] = (unsigned char) ((sha_info->digest[1] ) & 0xff); - digest[ 8] = (unsigned char) ((sha_info->digest[2] >> 24) & 0xff); - digest[ 9] = (unsigned char) ((sha_info->digest[2] >> 16) & 0xff); - digest[10] = (unsigned char) ((sha_info->digest[2] >> 8) & 0xff); - digest[11] = (unsigned char) ((sha_info->digest[2] ) & 0xff); - digest[12] = (unsigned char) ((sha_info->digest[3] >> 24) & 0xff); - digest[13] = (unsigned char) ((sha_info->digest[3] >> 16) & 0xff); - digest[14] = (unsigned char) ((sha_info->digest[3] >> 8) & 0xff); - digest[15] = (unsigned char) ((sha_info->digest[3] ) & 0xff); - digest[16] = (unsigned char) ((sha_info->digest[4] >> 24) & 0xff); - digest[17] = (unsigned char) ((sha_info->digest[4] >> 16) & 0xff); - digest[18] = (unsigned char) ((sha_info->digest[4] >> 8) & 0xff); - digest[19] = (unsigned char) ((sha_info->digest[4] ) & 0xff); -} - -/* - * End of copied SHA code. - * - * ------------------------------------------------------------------------ - */ - -static PyTypeObject SHAtype; - - -static SHAobject * -newSHAobject(void) -{ - return (SHAobject *)PyObject_New(SHAobject, &SHAtype); -} - -/* Internal methods for a hashing object */ - -static void -SHA_dealloc(PyObject *ptr) -{ - PyObject_Del(ptr); -} - - -/* External methods for a hashing object */ - -PyDoc_STRVAR(SHA_copy__doc__, "Return a copy of the hashing object."); - -static PyObject * -SHA_copy(SHAobject *self, PyObject *args) -{ - SHAobject *newobj; - - if (!PyArg_ParseTuple(args, ":copy")) { - return NULL; - } - if ( (newobj = newSHAobject())==NULL) - return NULL; - - SHAcopy(self, newobj); - return (PyObject *)newobj; -} - -PyDoc_STRVAR(SHA_digest__doc__, -"Return the digest value as a string of binary data."); - -static PyObject * -SHA_digest(SHAobject *self, PyObject *args) -{ - unsigned char digest[SHA_DIGESTSIZE]; - SHAobject temp; - - if (!PyArg_ParseTuple(args, ":digest")) - return NULL; - - SHAcopy(self, &temp); - sha_final(digest, &temp); - return PyString_FromStringAndSize((const char *)digest, sizeof(digest)); -} - -PyDoc_STRVAR(SHA_hexdigest__doc__, -"Return the digest value as a string of hexadecimal digits."); - -static PyObject * -SHA_hexdigest(SHAobject *self, PyObject *args) -{ - unsigned char digest[SHA_DIGESTSIZE]; - SHAobject temp; - PyObject *retval; - char *hex_digest; - int i, j; - - if (!PyArg_ParseTuple(args, ":hexdigest")) - return NULL; - - /* Get the raw (binary) digest value */ - SHAcopy(self, &temp); - sha_final(digest, &temp); - - /* Create a new string */ - retval = PyString_FromStringAndSize(NULL, sizeof(digest) * 2); - if (!retval) - return NULL; - hex_digest = PyString_AsString(retval); - if (!hex_digest) { - Py_DECREF(retval); - return NULL; - } - - /* Make hex version of the digest */ - for(i=j=0; i> 4) & 0xf; - c = (c>9) ? c+'a'-10 : c + '0'; - hex_digest[j++] = c; - c = (digest[i] & 0xf); - c = (c>9) ? c+'a'-10 : c + '0'; - hex_digest[j++] = c; - } - return retval; -} - -PyDoc_STRVAR(SHA_update__doc__, -"Update this hashing object's state with the provided string."); - -static PyObject * -SHA_update(SHAobject *self, PyObject *args) -{ - unsigned char *cp; - int len; - - if (!PyArg_ParseTuple(args, "s#:update", &cp, &len)) - return NULL; - - sha_update(self, cp, len); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyMethodDef SHA_methods[] = { - {"copy", (PyCFunction)SHA_copy, METH_VARARGS, SHA_copy__doc__}, - {"digest", (PyCFunction)SHA_digest, METH_VARARGS, SHA_digest__doc__}, - {"hexdigest", (PyCFunction)SHA_hexdigest, METH_VARARGS, SHA_hexdigest__doc__}, - {"update", (PyCFunction)SHA_update, METH_VARARGS, SHA_update__doc__}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -SHA_getattr(PyObject *self, char *name) -{ - if (strcmp(name, "blocksize")==0) - return PyInt_FromLong(1); - if (strcmp(name, "digest_size")==0 || strcmp(name, "digestsize")==0) - return PyInt_FromLong(20); - - return Py_FindMethod(SHA_methods, self, name); -} - -static PyTypeObject SHAtype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "sha.SHA", /*tp_name*/ - sizeof(SHAobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - SHA_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - SHA_getattr, /*tp_getattr*/ -}; - - -/* The single module-level function: new() */ - -PyDoc_STRVAR(SHA_new__doc__, -"Return a new SHA hashing object. An optional string argument\n\ -may be provided; if present, this string will be automatically\n\ -hashed."); - -static PyObject * -SHA_new(PyObject *self, PyObject *args, PyObject *kwdict) -{ - static char *kwlist[] = {"string", NULL}; - SHAobject *new; - unsigned char *cp = NULL; - int len; - - if (!PyArg_ParseTupleAndKeywords(args, kwdict, "|s#:new", kwlist, - &cp, &len)) { - return NULL; - } - - if ((new = newSHAobject()) == NULL) - return NULL; - - sha_init(new); - - if (PyErr_Occurred()) { - Py_DECREF(new); - return NULL; - } - if (cp) - sha_update(new, cp, len); - - return (PyObject *)new; -} - - -/* List of functions exported by this module */ - -static struct PyMethodDef SHA_functions[] = { - {"new", (PyCFunction)SHA_new, METH_VARARGS|METH_KEYWORDS, SHA_new__doc__}, - {"sha", (PyCFunction)SHA_new, METH_VARARGS|METH_KEYWORDS, SHA_new__doc__}, - {NULL, NULL} /* Sentinel */ -}; - - -/* Initialize this module. */ - -#define insint(n,v) { PyModule_AddIntConstant(m,n,v); } - -PyMODINIT_FUNC -initsha(void) -{ - PyObject *m; - - SHAtype.ob_type = &PyType_Type; - m = Py_InitModule("sha", SHA_functions); - - /* Add some symbolic constants to the module */ - insint("blocksize", 1); /* For future use, in case some hash - functions require an integral number of - blocks */ - insint("digestsize", 20); - insint("digest_size", 20); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/signalmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/signalmodule.c deleted file mode 100644 index f68180fb..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/signalmodule.c +++ /dev/null @@ -1,674 +0,0 @@ - -/* Signal module -- many thanks to Lance Ellinghaus */ - -/* XXX Signals should be recorded per thread, now we have thread state. */ - -#include "Python.h" -#include "intrcheck.h" - -#ifdef MS_WINDOWS -#include -#endif - -#include - -#ifndef SIG_ERR -#define SIG_ERR ((PyOS_sighandler_t)(-1)) -#endif - -#if defined(PYOS_OS2) && !defined(PYCC_GCC) -#define NSIG 12 -#include -#endif - -#ifndef NSIG -# if defined(_NSIG) -# define NSIG _NSIG /* For BSD/SysV */ -# elif defined(_SIGMAX) -# define NSIG (_SIGMAX + 1) /* For QNX */ -# elif defined(SIGMAX) -# define NSIG (SIGMAX + 1) /* For djgpp */ -# else -# define NSIG 64 /* Use a reasonable default value */ -# endif -#endif - - -/* - NOTES ON THE INTERACTION BETWEEN SIGNALS AND THREADS - - When threads are supported, we want the following semantics: - - - only the main thread can set a signal handler - - any thread can get a signal handler - - signals are only delivered to the main thread - - I.e. we don't support "synchronous signals" like SIGFPE (catching - this doesn't make much sense in Python anyway) nor do we support - signals as a means of inter-thread communication, since not all - thread implementations support that (at least our thread library - doesn't). - - We still have the problem that in some implementations signals - generated by the keyboard (e.g. SIGINT) are delivered to all - threads (e.g. SGI), while in others (e.g. Solaris) such signals are - delivered to one random thread (an intermediate possibility would - be to deliver it to the main thread -- POSIX?). For now, we have - a working implementation that works in all three cases -- the - handler ignores signals if getpid() isn't the same as in the main - thread. XXX This is a hack. - - GNU pth is a user-space threading library, and as such, all threads - run within the same process. In this case, if the currently running - thread is not the main_thread, send the signal to the main_thread. -*/ - -#ifdef MS_XBOX -// No pid on Xbox -#undef WITH_THREAD -#endif - -#ifdef WITH_THREAD -#include /* For pid_t */ -#include "pythread.h" -static long main_thread; -static pid_t main_pid; -#endif - -static struct { - int tripped; - PyObject *func; -} Handlers[NSIG]; - -static int is_tripped = 0; /* Speed up sigcheck() when none tripped */ - -static PyObject *DefaultHandler; -static PyObject *IgnoreHandler; -static PyObject *IntHandler; - -/* On Solaris 8, gcc will produce a warning that the function - declaration is not a prototype. This is caused by the definition of - SIG_DFL as (void (*)())0; the correct declaration would have been - (void (*)(int))0. */ - -static PyOS_sighandler_t old_siginthandler = SIG_DFL; - - -static PyObject * -signal_default_int_handler(PyObject *self, PyObject *args) -{ - PyErr_SetNone(PyExc_KeyboardInterrupt); - return NULL; -} - -PyDoc_STRVAR(default_int_handler_doc, -"default_int_handler(...)\n\ -\n\ -The default handler for SIGINT instated by Python.\n\ -It raises KeyboardInterrupt."); - - -static int -checksignals_witharg(void * unused) -{ - return PyErr_CheckSignals(); -} - -static void -signal_handler(int sig_num) -{ -#ifdef WITH_THREAD -#ifdef WITH_PTH - if (PyThread_get_thread_ident() != main_thread) { - pth_raise(*(pth_t *) main_thread, sig_num); - return; - } -#endif - /* See NOTES section above */ - if (getpid() == main_pid) { -#endif - is_tripped++; - Handlers[sig_num].tripped = 1; - Py_AddPendingCall(checksignals_witharg, NULL); -#ifdef WITH_THREAD - } -#endif -#ifdef SIGCHLD - if (sig_num == SIGCHLD) { - /* To avoid infinite recursion, this signal remains - reset until explicit re-instated. - Don't clear the 'func' field as it is our pointer - to the Python handler... */ - return; - } -#endif -#ifdef HAVE_SIGINTERRUPT - siginterrupt(sig_num, 1); -#endif - PyOS_setsig(sig_num, signal_handler); -} - - -#ifdef HAVE_ALARM -static PyObject * -signal_alarm(PyObject *self, PyObject *args) -{ - int t; - if (!PyArg_ParseTuple(args, "i:alarm", &t)) - return NULL; - /* alarm() returns the number of seconds remaining */ - return PyInt_FromLong((long)alarm(t)); -} - -PyDoc_STRVAR(alarm_doc, -"alarm(seconds)\n\ -\n\ -Arrange for SIGALRM to arrive after the given number of seconds."); -#endif - -#ifdef HAVE_PAUSE -static PyObject * -signal_pause(PyObject *self) -{ - Py_BEGIN_ALLOW_THREADS - (void)pause(); - Py_END_ALLOW_THREADS - /* make sure that any exceptions that got raised are propagated - * back into Python - */ - if (PyErr_CheckSignals()) - return NULL; - - Py_INCREF(Py_None); - return Py_None; -} -PyDoc_STRVAR(pause_doc, -"pause()\n\ -\n\ -Wait until a signal arrives."); - -#endif - - -static PyObject * -signal_signal(PyObject *self, PyObject *args) -{ - PyObject *obj; - int sig_num; - PyObject *old_handler; - void (*func)(int); - if (!PyArg_ParseTuple(args, "iO:signal", &sig_num, &obj)) - return NULL; -#ifdef WITH_THREAD - if (PyThread_get_thread_ident() != main_thread) { - PyErr_SetString(PyExc_ValueError, - "signal only works in main thread"); - return NULL; - } -#endif - if (sig_num < 1 || sig_num >= NSIG) { - PyErr_SetString(PyExc_ValueError, - "signal number out of range"); - return NULL; - } - if (obj == IgnoreHandler) - func = SIG_IGN; - else if (obj == DefaultHandler) - func = SIG_DFL; - else if (!PyCallable_Check(obj)) { - PyErr_SetString(PyExc_TypeError, -"signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object"); - return NULL; - } - else - func = signal_handler; -#ifdef HAVE_SIGINTERRUPT - siginterrupt(sig_num, 1); -#endif - if (PyOS_setsig(sig_num, func) == SIG_ERR) { - PyErr_SetFromErrno(PyExc_RuntimeError); - return NULL; - } - old_handler = Handlers[sig_num].func; - Handlers[sig_num].tripped = 0; - Py_INCREF(obj); - Handlers[sig_num].func = obj; - return old_handler; -} - -PyDoc_STRVAR(signal_doc, -"signal(sig, action) -> action\n\ -\n\ -Set the action for the given signal. The action can be SIG_DFL,\n\ -SIG_IGN, or a callable Python object. The previous action is\n\ -returned. See getsignal() for possible return values.\n\ -\n\ -*** IMPORTANT NOTICE ***\n\ -A signal handler function is called with two arguments:\n\ -the first is the signal number, the second is the interrupted stack frame."); - - -static PyObject * -signal_getsignal(PyObject *self, PyObject *args) -{ - int sig_num; - PyObject *old_handler; - if (!PyArg_ParseTuple(args, "i:getsignal", &sig_num)) - return NULL; - if (sig_num < 1 || sig_num >= NSIG) { - PyErr_SetString(PyExc_ValueError, - "signal number out of range"); - return NULL; - } - old_handler = Handlers[sig_num].func; - Py_INCREF(old_handler); - return old_handler; -} - -PyDoc_STRVAR(getsignal_doc, -"getsignal(sig) -> action\n\ -\n\ -Return the current action for the given signal. The return value can be:\n\ -SIG_IGN -- if the signal is being ignored\n\ -SIG_DFL -- if the default action for the signal is in effect\n\ -None -- if an unknown handler is in effect\n\ -anything else -- the callable Python object used as a handler"); - - -/* List of functions defined in the module */ -static PyMethodDef signal_methods[] = { -#ifdef HAVE_ALARM - {"alarm", signal_alarm, METH_VARARGS, alarm_doc}, -#endif - {"signal", signal_signal, METH_VARARGS, signal_doc}, - {"getsignal", signal_getsignal, METH_VARARGS, getsignal_doc}, -#ifdef HAVE_PAUSE - {"pause", (PyCFunction)signal_pause, - METH_NOARGS,pause_doc}, -#endif - {"default_int_handler", signal_default_int_handler, - METH_VARARGS, default_int_handler_doc}, - {NULL, NULL} /* sentinel */ -}; - - -PyDoc_STRVAR(module_doc, -"This module provides mechanisms to use signal handlers in Python.\n\ -\n\ -Functions:\n\ -\n\ -alarm() -- cause SIGALRM after a specified time [Unix only]\n\ -signal() -- set the action for a given signal\n\ -getsignal() -- get the signal action for a given signal\n\ -pause() -- wait until a signal arrives [Unix only]\n\ -default_int_handler() -- default SIGINT handler\n\ -\n\ -Constants:\n\ -\n\ -SIG_DFL -- used to refer to the system default handler\n\ -SIG_IGN -- used to ignore the signal\n\ -NSIG -- number of defined signals\n\ -\n\ -SIGINT, SIGTERM, etc. -- signal numbers\n\ -\n\ -*** IMPORTANT NOTICE ***\n\ -A signal handler function is called with two arguments:\n\ -the first is the signal number, the second is the interrupted stack frame."); - -PyMODINIT_FUNC -initsignal(void) -{ - PyObject *m, *d, *x; - int i; - -#ifdef WITH_THREAD - main_thread = PyThread_get_thread_ident(); - main_pid = getpid(); -#endif - - /* Create the module and add the functions */ - m = Py_InitModule3("signal", signal_methods, module_doc); - - /* Add some symbolic constants to the module */ - d = PyModule_GetDict(m); - - x = DefaultHandler = PyLong_FromVoidPtr((void *)SIG_DFL); - if (!x || PyDict_SetItemString(d, "SIG_DFL", x) < 0) - goto finally; - - x = IgnoreHandler = PyLong_FromVoidPtr((void *)SIG_IGN); - if (!x || PyDict_SetItemString(d, "SIG_IGN", x) < 0) - goto finally; - - x = PyInt_FromLong((long)NSIG); - if (!x || PyDict_SetItemString(d, "NSIG", x) < 0) - goto finally; - Py_DECREF(x); - - x = IntHandler = PyDict_GetItemString(d, "default_int_handler"); - if (!x) - goto finally; - Py_INCREF(IntHandler); - - Handlers[0].tripped = 0; - for (i = 1; i < NSIG; i++) { - void (*t)(int); - t = PyOS_getsig(i); - Handlers[i].tripped = 0; - if (t == SIG_DFL) - Handlers[i].func = DefaultHandler; - else if (t == SIG_IGN) - Handlers[i].func = IgnoreHandler; - else - Handlers[i].func = Py_None; /* None of our business */ - Py_INCREF(Handlers[i].func); - } - if (Handlers[SIGINT].func == DefaultHandler) { - /* Install default int handler */ - Py_INCREF(IntHandler); - Py_DECREF(Handlers[SIGINT].func); - Handlers[SIGINT].func = IntHandler; - old_siginthandler = PyOS_setsig(SIGINT, signal_handler); - } - -#ifdef SIGHUP - x = PyInt_FromLong(SIGHUP); - PyDict_SetItemString(d, "SIGHUP", x); - Py_XDECREF(x); -#endif -#ifdef SIGINT - x = PyInt_FromLong(SIGINT); - PyDict_SetItemString(d, "SIGINT", x); - Py_XDECREF(x); -#endif -#ifdef SIGBREAK - x = PyInt_FromLong(SIGBREAK); - PyDict_SetItemString(d, "SIGBREAK", x); - Py_XDECREF(x); -#endif -#ifdef SIGQUIT - x = PyInt_FromLong(SIGQUIT); - PyDict_SetItemString(d, "SIGQUIT", x); - Py_XDECREF(x); -#endif -#ifdef SIGILL - x = PyInt_FromLong(SIGILL); - PyDict_SetItemString(d, "SIGILL", x); - Py_XDECREF(x); -#endif -#ifdef SIGTRAP - x = PyInt_FromLong(SIGTRAP); - PyDict_SetItemString(d, "SIGTRAP", x); - Py_XDECREF(x); -#endif -#ifdef SIGIOT - x = PyInt_FromLong(SIGIOT); - PyDict_SetItemString(d, "SIGIOT", x); - Py_XDECREF(x); -#endif -#ifdef SIGABRT - x = PyInt_FromLong(SIGABRT); - PyDict_SetItemString(d, "SIGABRT", x); - Py_XDECREF(x); -#endif -#ifdef SIGEMT - x = PyInt_FromLong(SIGEMT); - PyDict_SetItemString(d, "SIGEMT", x); - Py_XDECREF(x); -#endif -#ifdef SIGFPE - x = PyInt_FromLong(SIGFPE); - PyDict_SetItemString(d, "SIGFPE", x); - Py_XDECREF(x); -#endif -#ifdef SIGKILL - x = PyInt_FromLong(SIGKILL); - PyDict_SetItemString(d, "SIGKILL", x); - Py_XDECREF(x); -#endif -#ifdef SIGBUS - x = PyInt_FromLong(SIGBUS); - PyDict_SetItemString(d, "SIGBUS", x); - Py_XDECREF(x); -#endif -#ifdef SIGSEGV - x = PyInt_FromLong(SIGSEGV); - PyDict_SetItemString(d, "SIGSEGV", x); - Py_XDECREF(x); -#endif -#ifdef SIGSYS - x = PyInt_FromLong(SIGSYS); - PyDict_SetItemString(d, "SIGSYS", x); - Py_XDECREF(x); -#endif -#ifdef SIGPIPE - x = PyInt_FromLong(SIGPIPE); - PyDict_SetItemString(d, "SIGPIPE", x); - Py_XDECREF(x); -#endif -#ifdef SIGALRM - x = PyInt_FromLong(SIGALRM); - PyDict_SetItemString(d, "SIGALRM", x); - Py_XDECREF(x); -#endif -#ifdef SIGTERM - x = PyInt_FromLong(SIGTERM); - PyDict_SetItemString(d, "SIGTERM", x); - Py_XDECREF(x); -#endif -#ifdef SIGUSR1 - x = PyInt_FromLong(SIGUSR1); - PyDict_SetItemString(d, "SIGUSR1", x); - Py_XDECREF(x); -#endif -#ifdef SIGUSR2 - x = PyInt_FromLong(SIGUSR2); - PyDict_SetItemString(d, "SIGUSR2", x); - Py_XDECREF(x); -#endif -#ifdef SIGCLD - x = PyInt_FromLong(SIGCLD); - PyDict_SetItemString(d, "SIGCLD", x); - Py_XDECREF(x); -#endif -#ifdef SIGCHLD - x = PyInt_FromLong(SIGCHLD); - PyDict_SetItemString(d, "SIGCHLD", x); - Py_XDECREF(x); -#endif -#ifdef SIGPWR - x = PyInt_FromLong(SIGPWR); - PyDict_SetItemString(d, "SIGPWR", x); - Py_XDECREF(x); -#endif -#ifdef SIGIO - x = PyInt_FromLong(SIGIO); - PyDict_SetItemString(d, "SIGIO", x); - Py_XDECREF(x); -#endif -#ifdef SIGURG - x = PyInt_FromLong(SIGURG); - PyDict_SetItemString(d, "SIGURG", x); - Py_XDECREF(x); -#endif -#ifdef SIGWINCH - x = PyInt_FromLong(SIGWINCH); - PyDict_SetItemString(d, "SIGWINCH", x); - Py_XDECREF(x); -#endif -#ifdef SIGPOLL - x = PyInt_FromLong(SIGPOLL); - PyDict_SetItemString(d, "SIGPOLL", x); - Py_XDECREF(x); -#endif -#ifdef SIGSTOP - x = PyInt_FromLong(SIGSTOP); - PyDict_SetItemString(d, "SIGSTOP", x); - Py_XDECREF(x); -#endif -#ifdef SIGTSTP - x = PyInt_FromLong(SIGTSTP); - PyDict_SetItemString(d, "SIGTSTP", x); - Py_XDECREF(x); -#endif -#ifdef SIGCONT - x = PyInt_FromLong(SIGCONT); - PyDict_SetItemString(d, "SIGCONT", x); - Py_XDECREF(x); -#endif -#ifdef SIGTTIN - x = PyInt_FromLong(SIGTTIN); - PyDict_SetItemString(d, "SIGTTIN", x); - Py_XDECREF(x); -#endif -#ifdef SIGTTOU - x = PyInt_FromLong(SIGTTOU); - PyDict_SetItemString(d, "SIGTTOU", x); - Py_XDECREF(x); -#endif -#ifdef SIGVTALRM - x = PyInt_FromLong(SIGVTALRM); - PyDict_SetItemString(d, "SIGVTALRM", x); - Py_XDECREF(x); -#endif -#ifdef SIGPROF - x = PyInt_FromLong(SIGPROF); - PyDict_SetItemString(d, "SIGPROF", x); - Py_XDECREF(x); -#endif -#ifdef SIGXCPU - x = PyInt_FromLong(SIGXCPU); - PyDict_SetItemString(d, "SIGXCPU", x); - Py_XDECREF(x); -#endif -#ifdef SIGXFSZ - x = PyInt_FromLong(SIGXFSZ); - PyDict_SetItemString(d, "SIGXFSZ", x); - Py_XDECREF(x); -#endif -#ifdef SIGINFO - x = PyInt_FromLong(SIGINFO); - PyDict_SetItemString(d, "SIGINFO", x); - Py_XDECREF(x); -#endif - if (!PyErr_Occurred()) - return; - - /* Check for errors */ - finally: - return; -} - -static void -finisignal(void) -{ - int i; - PyObject *func; - - PyOS_setsig(SIGINT, old_siginthandler); - old_siginthandler = SIG_DFL; - - for (i = 1; i < NSIG; i++) { - func = Handlers[i].func; - Handlers[i].tripped = 0; - Handlers[i].func = NULL; - if (i != SIGINT && func != NULL && func != Py_None && - func != DefaultHandler && func != IgnoreHandler) - PyOS_setsig(i, SIG_DFL); - Py_XDECREF(func); - } - - Py_XDECREF(IntHandler); - IntHandler = NULL; - Py_XDECREF(DefaultHandler); - DefaultHandler = NULL; - Py_XDECREF(IgnoreHandler); - IgnoreHandler = NULL; -} - - -/* Declared in pyerrors.h */ -int -PyErr_CheckSignals(void) -{ - int i; - PyObject *f; - - if (!is_tripped) - return 0; -#ifdef WITH_THREAD - if (PyThread_get_thread_ident() != main_thread) - return 0; -#endif - if (!(f = (PyObject *)PyEval_GetFrame())) - f = Py_None; - - for (i = 1; i < NSIG; i++) { - if (Handlers[i].tripped) { - PyObject *result = NULL; - PyObject *arglist = Py_BuildValue("(iO)", i, f); - Handlers[i].tripped = 0; - - if (arglist) { - result = PyEval_CallObject(Handlers[i].func, - arglist); - Py_DECREF(arglist); - } - if (!result) - return -1; - - Py_DECREF(result); - } - } - is_tripped = 0; - return 0; -} - - -/* Replacements for intrcheck.c functionality - * Declared in pyerrors.h - */ -void -PyErr_SetInterrupt(void) -{ - is_tripped++; - Handlers[SIGINT].tripped = 1; - Py_AddPendingCall((int (*)(void *))PyErr_CheckSignals, NULL); -} - -void -PyOS_InitInterrupts(void) -{ - initsignal(); - _PyImport_FixupExtension("signal", "signal"); -} - -void -PyOS_FiniInterrupts(void) -{ - finisignal(); -} - -int -PyOS_InterruptOccurred(void) -{ - if (Handlers[SIGINT].tripped) { -#ifdef WITH_THREAD - if (PyThread_get_thread_ident() != main_thread) - return 0; -#endif - Handlers[SIGINT].tripped = 0; - return 1; - } - return 0; -} - -void -PyOS_AfterFork(void) -{ -#ifdef WITH_THREAD - PyEval_ReInitThreads(); - main_thread = PyThread_get_thread_ident(); - main_pid = getpid(); -#endif -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/socketmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/socketmodule.c deleted file mode 100644 index 70e9f89f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/socketmodule.c +++ /dev/null @@ -1,4151 +0,0 @@ -/* Socket module */ - -/* - -This module provides an interface to Berkeley socket IPC. - -Limitations: - -- Only AF_INET, AF_INET6 and AF_UNIX address families are supported in a - portable manner, though AF_PACKET is supported under Linux. -- No read/write operations (use sendall/recv or makefile instead). -- Additional restrictions apply on some non-Unix platforms (compensated - for by socket.py). - -Module interface: - -- socket.error: exception raised for socket specific errors -- socket.gaierror: exception raised for getaddrinfo/getnameinfo errors, - a subclass of socket.error -- socket.herror: exception raised for gethostby* errors, - a subclass of socket.error -- socket.fromfd(fd, family, type[, proto]) --> new socket object (created - from an existing file descriptor) -- socket.gethostbyname(hostname) --> host IP address (string: 'dd.dd.dd.dd') -- socket.gethostbyaddr(IP address) --> (hostname, [alias, ...], [IP addr, ...]) -- socket.gethostname() --> host name (string: 'spam' or 'spam.domain.com') -- socket.getprotobyname(protocolname) --> protocol number -- socket.getservbyname(servicename, protocolname) --> port number -- socket.socket([family[, type [, proto]]]) --> new socket object -- socket.ntohs(16 bit value) --> new int object -- socket.ntohl(32 bit value) --> new int object -- socket.htons(16 bit value) --> new int object -- socket.htonl(32 bit value) --> new int object -- socket.getaddrinfo(host, port [, family, socktype, proto, flags]) - --> List of (family, socktype, proto, canonname, sockaddr) -- socket.getnameinfo(sockaddr, flags) --> (host, port) -- socket.AF_INET, socket.SOCK_STREAM, etc.: constants from -- socket.has_ipv6: boolean value indicating if IPv6 is supported -- socket.inet_aton(IP address) -> 32-bit packed IP representation -- socket.inet_ntoa(packed IP) -> IP address string -- socket.getdefaulttimeout() -> None | float -- socket.setdefaulttimeout(None | float) -- an Internet socket address is a pair (hostname, port) - where hostname can be anything recognized by gethostbyname() - (including the dd.dd.dd.dd notation) and port is in host byte order -- where a hostname is returned, the dd.dd.dd.dd notation is used -- a UNIX domain socket address is a string specifying the pathname -- an AF_PACKET socket address is a tuple containing a string - specifying the ethernet interface and an integer specifying - the Ethernet protocol number to be received. For example: - ("eth0",0x1234). Optional 3rd,4th,5th elements in the tuple - specify packet-type and ha-type/addr -- these are ignored by - networking code, but accepted since they are returned by the - getsockname() method. - -Local naming conventions: - -- names starting with sock_ are socket object methods -- names starting with socket_ are module-level functions -- names starting with PySocket are exported through socketmodule.h - -*/ - -#include "Python.h" - -#undef MAX -#define MAX(x, y) ((x) < (y) ? (y) : (x)) - -/* Socket object documentation */ -PyDoc_STRVAR(sock_doc, -"socket([family[, type[, proto]]]) -> socket object\n\ -\n\ -Open a socket of the given type. The family argument specifies the\n\ -address family; it defaults to AF_INET. The type argument specifies\n\ -whether this is a stream (SOCK_STREAM, this is the default)\n\ -or datagram (SOCK_DGRAM) socket. The protocol argument defaults to 0,\n\ -specifying the default protocol. Keyword arguments are accepted.\n\ -\n\ -A socket object represents one endpoint of a network connection.\n\ -\n\ -Methods of socket objects (keyword arguments not allowed):\n\ -\n\ -accept() -- accept a connection, returning new socket and client address\n\ -bind(addr) -- bind the socket to a local address\n\ -close() -- close the socket\n\ -connect(addr) -- connect the socket to a remote address\n\ -connect_ex(addr) -- connect, return an error code instead of an exception\n\ -dup() -- return a new socket object identical to the current one [*]\n\ -fileno() -- return underlying file descriptor\n\ -getpeername() -- return remote address [*]\n\ -getsockname() -- return local address\n\ -getsockopt(level, optname[, buflen]) -- get socket options\n\ -gettimeout() -- return timeout or None\n\ -listen(n) -- start listening for incoming connections\n\ -makefile([mode, [bufsize]]) -- return a file object for the socket [*]\n\ -recv(buflen[, flags]) -- receive data\n\ -recvfrom(buflen[, flags]) -- receive data and sender's address\n\ -sendall(data[, flags]) -- send all data\n\ -send(data[, flags]) -- send data, may not send all of it\n\ -sendto(data[, flags], addr) -- send data to a given address\n\ -setblocking(0 | 1) -- set or clear the blocking I/O flag\n\ -setsockopt(level, optname, value) -- set socket options\n\ -settimeout(None | float) -- set or clear the timeout\n\ -shutdown(how) -- shut down traffic in one or both directions\n\ -\n\ - [*] not available on all platforms!"); - -/* XXX This is a terrible mess of platform-dependent preprocessor hacks. - I hope some day someone can clean this up please... */ - -/* Hacks for gethostbyname_r(). On some non-Linux platforms, the configure - script doesn't get this right, so we hardcode some platform checks below. - On the other hand, not all Linux versions agree, so there the settings - computed by the configure script are needed! */ - -#ifndef linux -# undef HAVE_GETHOSTBYNAME_R_3_ARG -# undef HAVE_GETHOSTBYNAME_R_5_ARG -# undef HAVE_GETHOSTBYNAME_R_6_ARG -#endif - -#ifndef WITH_THREAD -# undef HAVE_GETHOSTBYNAME_R -#endif - -#ifdef HAVE_GETHOSTBYNAME_R -# if defined(_AIX) || defined(__osf__) -# define HAVE_GETHOSTBYNAME_R_3_ARG -# elif defined(__sun) || defined(__sgi) -# define HAVE_GETHOSTBYNAME_R_5_ARG -# elif defined(linux) -/* Rely on the configure script */ -# else -# undef HAVE_GETHOSTBYNAME_R -# endif -#endif - -#if !defined(HAVE_GETHOSTBYNAME_R) && defined(WITH_THREAD) && \ - !defined(MS_WINDOWS) -# define USE_GETHOSTBYNAME_LOCK -#endif - -/* On systems on which getaddrinfo() is believed to not be thread-safe, - (this includes the getaddrinfo emulation) protect access with a lock. */ -#if defined(WITH_THREAD) && (defined(__APPLE__) || defined(__FreeBSD__) || \ - defined(__OpenBSD__) || defined(__NetBSD__) || !defined(HAVE_GETADDRINFO)) -#define USE_GETADDRINFO_LOCK -#endif - -#ifdef USE_GETADDRINFO_LOCK -#define ACQUIRE_GETADDRINFO_LOCK PyThread_acquire_lock(netdb_lock, 1); -#define RELEASE_GETADDRINFO_LOCK PyThread_release_lock(netdb_lock); -#else -#define ACQUIRE_GETADDRINFO_LOCK -#define RELEASE_GETADDRINFO_LOCK -#endif - -#if defined(USE_GETHOSTBYNAME_LOCK) || defined(USE_GETADDRINFO_LOCK) -# include "pythread.h" -#endif - -#if defined(PYCC_VACPP) -# include -# include -# include -# include -# include -#endif - -#if defined(__VMS) -#if ! defined(_SOCKADDR_LEN) -# ifdef getaddrinfo -# undef getaddrinfo -# endif -# include "TCPIP_IOCTL_ROUTINE" -#else -# include -#endif -#endif - -#if defined(PYOS_OS2) -# define INCL_DOS -# define INCL_DOSERRORS -# define INCL_NOPMAPI -# include -#endif - -#if defined(__sgi) && _COMPILER_VERSION>700 && !_SGIAPI -/* make sure that the reentrant (gethostbyaddr_r etc) - functions are declared correctly if compiling with - MIPSPro 7.x in ANSI C mode (default) */ - -/* XXX Using _SGIAPI is the wrong thing, - but I don't know what the right thing is. */ -#define _SGIAPI 1 - -#define HAVE_INET_PTON -#include -#endif - -/* Irix 6.5 fails to define this variable at all. This is needed - for both GCC and SGI's compiler. I'd say that the SGI headers - are just busted. */ -#if defined(__sgi) && !defined(INET_ADDRSTRLEN) -#define INET_ADDRSTRLEN 16 -#endif - -/* Generic includes */ -#include -#include - -/* Generic socket object definitions and includes */ -#define PySocket_BUILDING_SOCKET -#include "socketmodule.h" - -/* Addressing includes */ - -#ifndef MS_WINDOWS - -/* Non-MS WINDOWS includes */ -# include - -/* Headers needed for inet_ntoa() and inet_addr() */ -# ifdef __BEOS__ -# include -# elif defined(PYOS_OS2) && defined(PYCC_VACPP) -# include -typedef size_t socklen_t; -# else -# include -# endif - -# ifndef RISCOS -# include -# else -# include -# include -# define NO_DUP -int h_errno; /* not used */ -# define INET_ADDRSTRLEN 16 -# endif - -#else - -/* MS_WINDOWS includes */ -# include - -#endif - -#ifdef HAVE_STDDEF_H -# include -#endif - -#ifndef offsetof -# define offsetof(type, member) ((size_t)(&((type *)0)->member)) -#endif - -#ifndef O_NONBLOCK -# define O_NONBLOCK O_NDELAY -#endif - -#include "addrinfo.h" - -#ifndef HAVE_INET_PTON -int inet_pton(int af, const char *src, void *dst); -const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); -#endif - -#ifdef __APPLE__ -/* On OS X, getaddrinfo returns no error indication of lookup - failure, so we must use the emulation instead of the libinfo - implementation. Unfortunately, performing an autoconf test - for this bug would require DNS access for the machine performing - the configuration, which is not acceptable. Therefore, we - determine the bug just by checking for __APPLE__. If this bug - gets ever fixed, perhaps checking for sys/version.h would be - appropriate, which is 10/0 on the system with the bug. */ -#ifndef HAVE_GETNAMEINFO -/* This bug seems to be fixed in Jaguar. Ths easiest way I could - Find to check for Jaguar is that it has getnameinfo(), which - older releases don't have */ -#undef HAVE_GETADDRINFO -#endif -#endif - -/* I know this is a bad practice, but it is the easiest... */ -#if !defined(HAVE_GETADDRINFO) -/* avoid clashes with the C library definition of the symbol. */ -#define getaddrinfo fake_getaddrinfo -#define gai_strerror fake_gai_strerror -#define freeaddrinfo fake_freeaddrinfo -#include "getaddrinfo.c" -#endif -#if !defined(HAVE_GETNAMEINFO) -#define getnameinfo fake_getnameinfo -#include "getnameinfo.c" -#endif - -#if defined(MS_WINDOWS) || defined(__BEOS__) -/* BeOS suffers from the same socket dichotomy as Win32... - [cjh] */ -/* seem to be a few differences in the API */ -#define SOCKETCLOSE closesocket -#define NO_DUP /* Actually it exists on NT 3.5, but what the heck... */ -#endif - -#ifdef MS_WIN32 -#define EAFNOSUPPORT WSAEAFNOSUPPORT -#define snprintf _snprintf -#endif - -#if defined(PYOS_OS2) && !defined(PYCC_GCC) -#define SOCKETCLOSE soclose -#define NO_DUP /* Sockets are Not Actual File Handles under OS/2 */ -#endif - -#ifndef SOCKETCLOSE -#define SOCKETCLOSE close -#endif - -#ifdef __VMS -/* TCP/IP Services for VMS uses a maximum send/revc buffer length of 65535 */ -#define SEGMENT_SIZE 65535 -#endif - -/* - * Constants for getnameinfo() - */ -#if !defined(NI_MAXHOST) -#define NI_MAXHOST 1025 -#endif -#if !defined(NI_MAXSERV) -#define NI_MAXSERV 32 -#endif - -/* XXX There's a problem here: *static* functions are not supposed to have - a Py prefix (or use CapitalizedWords). Later... */ - -/* Global variable holding the exception type for errors detected - by this module (but not argument type or memory errors, etc.). */ -static PyObject *socket_error; -static PyObject *socket_herror; -static PyObject *socket_gaierror; -static PyObject *socket_timeout; - -#ifdef RISCOS -/* Global variable which is !=0 if Python is running in a RISC OS taskwindow */ -static int taskwindow; -#endif - -/* A forward reference to the socket type object. - The sock_type variable contains pointers to various functions, - some of which call new_sockobject(), which uses sock_type, so - there has to be a circular reference. */ -static PyTypeObject sock_type; - -/* Convenience function to raise an error according to errno - and return a NULL pointer from a function. */ - -static PyObject * -set_error(void) -{ -#ifdef MS_WINDOWS - int err_no = WSAGetLastError(); - static struct { - int no; - const char *msg; - } *msgp, msgs[] = { - {WSAEINTR, "Interrupted system call"}, - {WSAEBADF, "Bad file descriptor"}, - {WSAEACCES, "Permission denied"}, - {WSAEFAULT, "Bad address"}, - {WSAEINVAL, "Invalid argument"}, - {WSAEMFILE, "Too many open files"}, - {WSAEWOULDBLOCK, - "The socket operation could not complete " - "without blocking"}, - {WSAEINPROGRESS, "Operation now in progress"}, - {WSAEALREADY, "Operation already in progress"}, - {WSAENOTSOCK, "Socket operation on non-socket"}, - {WSAEDESTADDRREQ, "Destination address required"}, - {WSAEMSGSIZE, "Message too long"}, - {WSAEPROTOTYPE, "Protocol wrong type for socket"}, - {WSAENOPROTOOPT, "Protocol not available"}, - {WSAEPROTONOSUPPORT, "Protocol not supported"}, - {WSAESOCKTNOSUPPORT, "Socket type not supported"}, - {WSAEOPNOTSUPP, "Operation not supported"}, - {WSAEPFNOSUPPORT, "Protocol family not supported"}, - {WSAEAFNOSUPPORT, "Address family not supported"}, - {WSAEADDRINUSE, "Address already in use"}, - {WSAEADDRNOTAVAIL, "Can't assign requested address"}, - {WSAENETDOWN, "Network is down"}, - {WSAENETUNREACH, "Network is unreachable"}, - {WSAENETRESET, "Network dropped connection on reset"}, - {WSAECONNABORTED, "Software caused connection abort"}, - {WSAECONNRESET, "Connection reset by peer"}, - {WSAENOBUFS, "No buffer space available"}, - {WSAEISCONN, "Socket is already connected"}, - {WSAENOTCONN, "Socket is not connected"}, - {WSAESHUTDOWN, "Can't send after socket shutdown"}, - {WSAETOOMANYREFS, "Too many references: can't splice"}, - {WSAETIMEDOUT, "Operation timed out"}, - {WSAECONNREFUSED, "Connection refused"}, - {WSAELOOP, "Too many levels of symbolic links"}, - {WSAENAMETOOLONG, "File name too long"}, - {WSAEHOSTDOWN, "Host is down"}, - {WSAEHOSTUNREACH, "No route to host"}, - {WSAENOTEMPTY, "Directory not empty"}, - {WSAEPROCLIM, "Too many processes"}, - {WSAEUSERS, "Too many users"}, - {WSAEDQUOT, "Disc quota exceeded"}, - {WSAESTALE, "Stale NFS file handle"}, - {WSAEREMOTE, "Too many levels of remote in path"}, - {WSASYSNOTREADY, "Network subsystem is unvailable"}, - {WSAVERNOTSUPPORTED, "WinSock version is not supported"}, - {WSANOTINITIALISED, - "Successful WSAStartup() not yet performed"}, - {WSAEDISCON, "Graceful shutdown in progress"}, - /* Resolver errors */ - {WSAHOST_NOT_FOUND, "No such host is known"}, - {WSATRY_AGAIN, "Host not found, or server failed"}, - {WSANO_RECOVERY, "Unexpected server error encountered"}, - {WSANO_DATA, "Valid name without requested data"}, - {WSANO_ADDRESS, "No address, look for MX record"}, - {0, NULL} - }; - if (err_no) { - PyObject *v; - const char *msg = "winsock error"; - - for (msgp = msgs; msgp->msg; msgp++) { - if (err_no == msgp->no) { - msg = msgp->msg; - break; - } - } - - v = Py_BuildValue("(is)", err_no, msg); - if (v != NULL) { - PyErr_SetObject(socket_error, v); - Py_DECREF(v); - } - return NULL; - } - else -#endif - -#if defined(PYOS_OS2) && !defined(PYCC_GCC) - if (sock_errno() != NO_ERROR) { - APIRET rc; - ULONG msglen; - char outbuf[100]; - int myerrorcode = sock_errno(); - - /* Retrieve socket-related error message from MPTN.MSG file */ - rc = DosGetMessage(NULL, 0, outbuf, sizeof(outbuf), - myerrorcode - SOCBASEERR + 26, - "mptn.msg", - &msglen); - if (rc == NO_ERROR) { - PyObject *v; - - /* OS/2 doesn't guarantee a terminator */ - outbuf[msglen] = '\0'; - if (strlen(outbuf) > 0) { - /* If non-empty msg, trim CRLF */ - char *lastc = &outbuf[ strlen(outbuf)-1 ]; - while (lastc > outbuf && isspace(*lastc)) { - /* Trim trailing whitespace (CRLF) */ - *lastc-- = '\0'; - } - } - v = Py_BuildValue("(is)", myerrorcode, outbuf); - if (v != NULL) { - PyErr_SetObject(socket_error, v); - Py_DECREF(v); - } - return NULL; - } - } -#endif - -#if defined(RISCOS) - if (_inet_error.errnum != NULL) { - PyObject *v; - v = Py_BuildValue("(is)", errno, _inet_err()); - if (v != NULL) { - PyErr_SetObject(socket_error, v); - Py_DECREF(v); - } - return NULL; - } -#endif - - return PyErr_SetFromErrno(socket_error); -} - - -static PyObject * -set_herror(int h_error) -{ - PyObject *v; - -#ifdef HAVE_HSTRERROR - v = Py_BuildValue("(is)", h_error, (char *)hstrerror(h_error)); -#else - v = Py_BuildValue("(is)", h_error, "host not found"); -#endif - if (v != NULL) { - PyErr_SetObject(socket_herror, v); - Py_DECREF(v); - } - - return NULL; -} - - -static PyObject * -set_gaierror(int error) -{ - PyObject *v; - -#ifdef EAI_SYSTEM - /* EAI_SYSTEM is not available on Windows XP. */ - if (error == EAI_SYSTEM) - return set_error(); -#endif - -#ifdef HAVE_GAI_STRERROR - v = Py_BuildValue("(is)", error, gai_strerror(error)); -#else - v = Py_BuildValue("(is)", error, "getaddrinfo failed"); -#endif - if (v != NULL) { - PyErr_SetObject(socket_gaierror, v); - Py_DECREF(v); - } - - return NULL; -} - -/* Function to perform the setting of socket blocking mode - internally. block = (1 | 0). */ -static int -internal_setblocking(PySocketSockObject *s, int block) -{ -#ifndef RISCOS -#ifndef MS_WINDOWS - int delay_flag; -#endif -#endif - - Py_BEGIN_ALLOW_THREADS -#ifdef __BEOS__ - block = !block; - setsockopt(s->sock_fd, SOL_SOCKET, SO_NONBLOCK, - (void *)(&block), sizeof(int)); -#else -#ifndef RISCOS -#ifndef MS_WINDOWS -#if defined(PYOS_OS2) && !defined(PYCC_GCC) - block = !block; - ioctl(s->sock_fd, FIONBIO, (caddr_t)&block, sizeof(block)); -#elif defined(__VMS) - block = !block; - ioctl(s->sock_fd, FIONBIO, (char *)&block); -#else /* !PYOS_OS2 && !_VMS */ - delay_flag = fcntl(s->sock_fd, F_GETFL, 0); - if (block) - delay_flag &= (~O_NONBLOCK); - else - delay_flag |= O_NONBLOCK; - fcntl(s->sock_fd, F_SETFL, delay_flag); -#endif /* !PYOS_OS2 */ -#else /* MS_WINDOWS */ - block = !block; - ioctlsocket(s->sock_fd, FIONBIO, (u_long*)&block); -#endif /* MS_WINDOWS */ -#else /* RISCOS */ - block = !block; - socketioctl(s->sock_fd, FIONBIO, (u_long*)&block); -#endif /* RISCOS */ -#endif /* __BEOS__ */ - Py_END_ALLOW_THREADS - - /* Since these don't return anything */ - return 1; -} - -/* Do a select() on the socket, if necessary (sock_timeout > 0). - The argument writing indicates the direction. - This does not raise an exception; we'll let our caller do that - after they've reacquired the interpreter lock. - Returns 1 on timeout, 0 otherwise. */ -static int -internal_select(PySocketSockObject *s, int writing) -{ - fd_set fds; - struct timeval tv; - int n; - - /* Nothing to do unless we're in timeout mode (not non-blocking) */ - if (s->sock_timeout <= 0.0) - return 0; - - /* Guard against closed socket */ - if (s->sock_fd < 0) - return 0; - - /* Construct the arguments to select */ - tv.tv_sec = (int)s->sock_timeout; - tv.tv_usec = (int)((s->sock_timeout - tv.tv_sec) * 1e6); - FD_ZERO(&fds); - FD_SET(s->sock_fd, &fds); - - /* See if the socket is ready */ - if (writing) - n = select(s->sock_fd+1, NULL, &fds, NULL, &tv); - else - n = select(s->sock_fd+1, &fds, NULL, NULL, &tv); - if (n == 0) - return 1; - return 0; -} - -/* Initialize a new socket object. */ - -static double defaulttimeout = -1.0; /* Default timeout for new sockets */ - -PyMODINIT_FUNC -init_sockobject(PySocketSockObject *s, - SOCKET_T fd, int family, int type, int proto) -{ -#ifdef RISCOS - int block = 1; -#endif - s->sock_fd = fd; - s->sock_family = family; - s->sock_type = type; - s->sock_proto = proto; - s->sock_timeout = defaulttimeout; - - s->errorhandler = &set_error; - - if (defaulttimeout >= 0.0) - internal_setblocking(s, 0); - -#ifdef RISCOS - if (taskwindow) - socketioctl(s->sock_fd, 0x80046679, (u_long*)&block); -#endif -} - - -/* Create a new socket object. - This just creates the object and initializes it. - If the creation fails, return NULL and set an exception (implicit - in NEWOBJ()). */ - -static PySocketSockObject * -new_sockobject(SOCKET_T fd, int family, int type, int proto) -{ - PySocketSockObject *s; - s = (PySocketSockObject *) - PyType_GenericNew(&sock_type, NULL, NULL); - if (s != NULL) - init_sockobject(s, fd, family, type, proto); - return s; -} - - -/* Lock to allow python interpreter to continue, but only allow one - thread to be in gethostbyname or getaddrinfo */ -#if defined(USE_GETHOSTBYNAME_LOCK) || defined(USE_GETADDRINFO_LOCK) -PyThread_type_lock netdb_lock; -#endif - - -/* Convert a string specifying a host name or one of a few symbolic - names to a numeric IP address. This usually calls gethostbyname() - to do the work; the names "" and "" are special. - Return the length (IPv4 should be 4 bytes), or negative if - an error occurred; then an exception is raised. */ - -static int -setipaddr(char *name, struct sockaddr *addr_ret, size_t addr_ret_size, int af) -{ - struct addrinfo hints, *res; - int error; - int d1, d2, d3, d4; - char ch; - - memset((void *) addr_ret, '\0', sizeof(*addr_ret)); - if (name[0] == '\0') { - int siz; - memset(&hints, 0, sizeof(hints)); - hints.ai_family = af; - hints.ai_socktype = SOCK_DGRAM; /*dummy*/ - hints.ai_flags = AI_PASSIVE; - Py_BEGIN_ALLOW_THREADS - ACQUIRE_GETADDRINFO_LOCK - error = getaddrinfo(NULL, "0", &hints, &res); - Py_END_ALLOW_THREADS - /* We assume that those thread-unsafe getaddrinfo() versions - *are* safe regarding their return value, ie. that a - subsequent call to getaddrinfo() does not destroy the - outcome of the first call. */ - RELEASE_GETADDRINFO_LOCK - if (error) { - set_gaierror(error); - return -1; - } - switch (res->ai_family) { - case AF_INET: - siz = 4; - break; -#ifdef ENABLE_IPV6 - case AF_INET6: - siz = 16; - break; -#endif - default: - freeaddrinfo(res); - PyErr_SetString(socket_error, - "unsupported address family"); - return -1; - } - if (res->ai_next) { - freeaddrinfo(res); - PyErr_SetString(socket_error, - "wildcard resolved to multiple address"); - return -1; - } - if (res->ai_addrlen < addr_ret_size) - addr_ret_size = res->ai_addrlen; - memcpy(addr_ret, res->ai_addr, addr_ret_size); - freeaddrinfo(res); - return siz; - } - if (name[0] == '<' && strcmp(name, "") == 0) { - struct sockaddr_in *sin; - if (af != AF_INET && af != AF_UNSPEC) { - PyErr_SetString(socket_error, - "address family mismatched"); - return -1; - } - sin = (struct sockaddr_in *)addr_ret; - memset((void *) sin, '\0', sizeof(*sin)); - sin->sin_family = AF_INET; -#ifdef HAVE_SOCKADDR_SA_LEN - sin->sin_len = sizeof(*sin); -#endif - sin->sin_addr.s_addr = INADDR_BROADCAST; - return sizeof(sin->sin_addr); - } - if (sscanf(name, "%d.%d.%d.%d%c", &d1, &d2, &d3, &d4, &ch) == 4 && - 0 <= d1 && d1 <= 255 && 0 <= d2 && d2 <= 255 && - 0 <= d3 && d3 <= 255 && 0 <= d4 && d4 <= 255) { - struct sockaddr_in *sin; - sin = (struct sockaddr_in *)addr_ret; - sin->sin_addr.s_addr = htonl( - ((long) d1 << 24) | ((long) d2 << 16) | - ((long) d3 << 8) | ((long) d4 << 0)); - sin->sin_family = AF_INET; -#ifdef HAVE_SOCKADDR_SA_LEN - sin->sin_len = sizeof(*sin); -#endif - return 4; - } - memset(&hints, 0, sizeof(hints)); - hints.ai_family = af; - Py_BEGIN_ALLOW_THREADS - ACQUIRE_GETADDRINFO_LOCK - error = getaddrinfo(name, NULL, &hints, &res); -#if defined(__digital__) && defined(__unix__) - if (error == EAI_NONAME && af == AF_UNSPEC) { - /* On Tru64 V5.1, numeric-to-addr conversion fails - if no address family is given. Assume IPv4 for now.*/ - hints.ai_family = AF_INET; - error = getaddrinfo(name, NULL, &hints, &res); - } -#endif - Py_END_ALLOW_THREADS - RELEASE_GETADDRINFO_LOCK /* see comment in setipaddr() */ - if (error) { - set_gaierror(error); - return -1; - } - if (res->ai_addrlen < addr_ret_size) - addr_ret_size = res->ai_addrlen; - memcpy((char *) addr_ret, res->ai_addr, addr_ret_size); - freeaddrinfo(res); - switch (addr_ret->sa_family) { - case AF_INET: - return 4; -#ifdef ENABLE_IPV6 - case AF_INET6: - return 16; -#endif - default: - PyErr_SetString(socket_error, "unknown address family"); - return -1; - } -} - - -/* Create a string object representing an IP address. - This is always a string of the form 'dd.dd.dd.dd' (with variable - size numbers). */ - -static PyObject * -makeipaddr(struct sockaddr *addr, int addrlen) -{ - char buf[NI_MAXHOST]; - int error; - - error = getnameinfo(addr, addrlen, buf, sizeof(buf), NULL, 0, - NI_NUMERICHOST); - if (error) { - set_gaierror(error); - return NULL; - } - return PyString_FromString(buf); -} - - -/* Create an object representing the given socket address, - suitable for passing it back to bind(), connect() etc. - The family field of the sockaddr structure is inspected - to determine what kind of address it really is. */ - -/*ARGSUSED*/ -static PyObject * -makesockaddr(int sockfd, struct sockaddr *addr, int addrlen) -{ - if (addrlen == 0) { - /* No address -- may be recvfrom() from known socket */ - Py_INCREF(Py_None); - return Py_None; - } - -#ifdef __BEOS__ - /* XXX: BeOS version of accept() doesn't set family correctly */ - addr->sa_family = AF_INET; -#endif - - switch (addr->sa_family) { - - case AF_INET: - { - struct sockaddr_in *a; - PyObject *addrobj = makeipaddr(addr, sizeof(*a)); - PyObject *ret = NULL; - if (addrobj) { - a = (struct sockaddr_in *)addr; - ret = Py_BuildValue("Oi", addrobj, ntohs(a->sin_port)); - Py_DECREF(addrobj); - } - return ret; - } - -#if defined(AF_UNIX) && !defined(PYOS_OS2) - case AF_UNIX: - { - struct sockaddr_un *a = (struct sockaddr_un *) addr; - return PyString_FromString(a->sun_path); - } -#endif /* AF_UNIX */ - -#ifdef ENABLE_IPV6 - case AF_INET6: - { - struct sockaddr_in6 *a; - PyObject *addrobj = makeipaddr(addr, sizeof(*a)); - PyObject *ret = NULL; - if (addrobj) { - a = (struct sockaddr_in6 *)addr; - ret = Py_BuildValue("Oiii", - addrobj, - ntohs(a->sin6_port), - a->sin6_flowinfo, - a->sin6_scope_id); - Py_DECREF(addrobj); - } - return ret; - } -#endif - -#ifdef HAVE_NETPACKET_PACKET_H - case AF_PACKET: - { - struct sockaddr_ll *a = (struct sockaddr_ll *)addr; - char *ifname = ""; - struct ifreq ifr; - /* need to look up interface name give index */ - if (a->sll_ifindex) { - ifr.ifr_ifindex = a->sll_ifindex; - if (ioctl(sockfd, SIOCGIFNAME, &ifr) == 0) - ifname = ifr.ifr_name; - } - return Py_BuildValue("shbhs#", - ifname, - ntohs(a->sll_protocol), - a->sll_pkttype, - a->sll_hatype, - a->sll_addr, - a->sll_halen); - } -#endif - - /* More cases here... */ - - default: - /* If we don't know the address family, don't raise an - exception -- return it as a tuple. */ - return Py_BuildValue("is#", - addr->sa_family, - addr->sa_data, - sizeof(addr->sa_data)); - - } -} - - -/* Parse a socket address argument according to the socket object's - address family. Return 1 if the address was in the proper format, - 0 of not. The address is returned through addr_ret, its length - through len_ret. */ - -static int -getsockaddrarg(PySocketSockObject *s, PyObject *args, - struct sockaddr **addr_ret, int *len_ret) -{ - switch (s->sock_family) { - -#if defined(AF_UNIX) && !defined(PYOS_OS2) - case AF_UNIX: - { - struct sockaddr_un* addr; - char *path; - int len; - addr = (struct sockaddr_un*)&(s->sock_addr).un; - if (!PyArg_Parse(args, "t#", &path, &len)) - return 0; - if (len > sizeof addr->sun_path) { - PyErr_SetString(socket_error, - "AF_UNIX path too long"); - return 0; - } - addr->sun_family = s->sock_family; - memcpy(addr->sun_path, path, len); - addr->sun_path[len] = 0; - *addr_ret = (struct sockaddr *) addr; - *len_ret = len + sizeof(*addr) - sizeof(addr->sun_path); - return 1; - } -#endif /* AF_UNIX */ - - case AF_INET: - { - struct sockaddr_in* addr; - char *host; - int port, result; - addr=(struct sockaddr_in*)&(s->sock_addr).in; - if (!PyTuple_Check(args)) { - PyErr_Format( - PyExc_TypeError, - "getsockaddrarg: " - "AF_INET address must be tuple, not %.500s", - args->ob_type->tp_name); - return 0; - } - if (!PyArg_ParseTuple(args, "eti:getsockaddrarg", - "idna", &host, &port)) - return 0; - result = setipaddr(host, (struct sockaddr *)addr, - sizeof(*addr), AF_INET); - PyMem_Free(host); - if (result < 0) - return 0; - addr->sin_family = AF_INET; - addr->sin_port = htons((short)port); - *addr_ret = (struct sockaddr *) addr; - *len_ret = sizeof *addr; - return 1; - } - -#ifdef ENABLE_IPV6 - case AF_INET6: - { - struct sockaddr_in6* addr; - char *host; - int port, flowinfo, scope_id, result; - addr = (struct sockaddr_in6*)&(s->sock_addr).in6; - flowinfo = scope_id = 0; - if (!PyArg_ParseTuple(args, "eti|ii", - "idna", &host, &port, &flowinfo, - &scope_id)) { - return 0; - } - result = setipaddr(host, (struct sockaddr *)addr, - sizeof(*addr), AF_INET6); - PyMem_Free(host); - if (result < 0) - return 0; - addr->sin6_family = s->sock_family; - addr->sin6_port = htons((short)port); - addr->sin6_flowinfo = flowinfo; - addr->sin6_scope_id = scope_id; - *addr_ret = (struct sockaddr *) addr; - *len_ret = sizeof *addr; - return 1; - } -#endif - -#ifdef HAVE_NETPACKET_PACKET_H - case AF_PACKET: - { - struct sockaddr_ll* addr; - struct ifreq ifr; - char *interfaceName; - int protoNumber; - int hatype = 0; - int pkttype = 0; - char *haddr; - - if (!PyArg_ParseTuple(args, "si|iis", &interfaceName, - &protoNumber, &pkttype, &hatype, &haddr)) - return 0; - strncpy(ifr.ifr_name, interfaceName, sizeof(ifr.ifr_name)); - ifr.ifr_name[(sizeof(ifr.ifr_name))-1] = '\0'; - if (ioctl(s->sock_fd, SIOCGIFINDEX, &ifr) < 0) { - s->errorhandler(); - return 0; - } - addr = &(s->sock_addr.ll); - addr->sll_family = AF_PACKET; - addr->sll_protocol = htons((short)protoNumber); - addr->sll_ifindex = ifr.ifr_ifindex; - addr->sll_pkttype = pkttype; - addr->sll_hatype = hatype; - *addr_ret = (struct sockaddr *) addr; - *len_ret = sizeof *addr; - return 1; - } -#endif - - /* More cases here... */ - - default: - PyErr_SetString(socket_error, "getsockaddrarg: bad family"); - return 0; - - } -} - - -/* Get the address length according to the socket object's address family. - Return 1 if the family is known, 0 otherwise. The length is returned - through len_ret. */ - -static int -getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret) -{ - switch (s->sock_family) { - -#if defined(AF_UNIX) && !defined(PYOS_OS2) - case AF_UNIX: - { - *len_ret = sizeof (struct sockaddr_un); - return 1; - } -#endif /* AF_UNIX */ - - case AF_INET: - { - *len_ret = sizeof (struct sockaddr_in); - return 1; - } - -#ifdef ENABLE_IPV6 - case AF_INET6: - { - *len_ret = sizeof (struct sockaddr_in6); - return 1; - } -#endif - -#ifdef HAVE_NETPACKET_PACKET_H - case AF_PACKET: - { - *len_ret = sizeof (struct sockaddr_ll); - return 1; - } -#endif - - /* More cases here... */ - - default: - PyErr_SetString(socket_error, "getsockaddrlen: bad family"); - return 0; - - } -} - - -/* s.accept() method */ - -static PyObject * -sock_accept(PySocketSockObject *s) -{ - char addrbuf[256]; - SOCKET_T newfd; - socklen_t addrlen; - PyObject *sock = NULL; - PyObject *addr = NULL; - PyObject *res = NULL; - int timeout; - - if (!getsockaddrlen(s, &addrlen)) - return NULL; - memset(addrbuf, 0, addrlen); - -#ifdef MS_WINDOWS - newfd = INVALID_SOCKET; -#else - newfd = -1; -#endif - - Py_BEGIN_ALLOW_THREADS - timeout = internal_select(s, 0); - if (!timeout) - newfd = accept(s->sock_fd, (struct sockaddr *) addrbuf, - &addrlen); - Py_END_ALLOW_THREADS - - if (timeout) { - PyErr_SetString(socket_timeout, "timed out"); - return NULL; - } - -#ifdef MS_WINDOWS - if (newfd == INVALID_SOCKET) -#else - if (newfd < 0) -#endif - return s->errorhandler(); - - /* Create the new object with unspecified family, - to avoid calls to bind() etc. on it. */ - sock = (PyObject *) new_sockobject(newfd, - s->sock_family, - s->sock_type, - s->sock_proto); - - if (sock == NULL) { - SOCKETCLOSE(newfd); - goto finally; - } - addr = makesockaddr(s->sock_fd, (struct sockaddr *)addrbuf, - addrlen); - if (addr == NULL) - goto finally; - - res = Py_BuildValue("OO", sock, addr); - -finally: - Py_XDECREF(sock); - Py_XDECREF(addr); - return res; -} - -PyDoc_STRVAR(accept_doc, -"accept() -> (socket object, address info)\n\ -\n\ -Wait for an incoming connection. Return a new socket representing the\n\ -connection, and the address of the client. For IP sockets, the address\n\ -info is a pair (hostaddr, port)."); - -/* s.setblocking(flag) method. Argument: - False -- non-blocking mode; same as settimeout(0) - True -- blocking mode; same as settimeout(None) -*/ - -static PyObject * -sock_setblocking(PySocketSockObject *s, PyObject *arg) -{ - int block; - - block = PyInt_AsLong(arg); - if (block == -1 && PyErr_Occurred()) - return NULL; - - s->sock_timeout = block ? -1.0 : 0.0; - internal_setblocking(s, block); - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(setblocking_doc, -"setblocking(flag)\n\ -\n\ -Set the socket to blocking (flag is true) or non-blocking (false).\n\ -setblocking(True) is equivalent to settimeout(None);\n\ -setblocking(False) is equivalent to settimeout(0.0)."); - -/* s.settimeout(timeout) method. Argument: - None -- no timeout, blocking mode; same as setblocking(True) - 0.0 -- non-blocking mode; same as setblocking(False) - > 0 -- timeout mode; operations time out after timeout seconds - < 0 -- illegal; raises an exception -*/ -static PyObject * -sock_settimeout(PySocketSockObject *s, PyObject *arg) -{ - double timeout; - - if (arg == Py_None) - timeout = -1.0; - else { - timeout = PyFloat_AsDouble(arg); - if (timeout < 0.0) { - if (!PyErr_Occurred()) - PyErr_SetString(PyExc_ValueError, - "Timeout value out of range"); - return NULL; - } - } - - s->sock_timeout = timeout; - internal_setblocking(s, timeout < 0.0); - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(settimeout_doc, -"settimeout(timeout)\n\ -\n\ -Set a timeout on socket operations. 'timeout' can be a float,\n\ -giving in seconds, or None. Setting a timeout of None disables\n\ -the timeout feature and is equivalent to setblocking(1).\n\ -Setting a timeout of zero is the same as setblocking(0)."); - -/* s.gettimeout() method. - Returns the timeout associated with a socket. */ -static PyObject * -sock_gettimeout(PySocketSockObject *s) -{ - if (s->sock_timeout < 0.0) { - Py_INCREF(Py_None); - return Py_None; - } - else - return PyFloat_FromDouble(s->sock_timeout); -} - -PyDoc_STRVAR(gettimeout_doc, -"gettimeout() -> timeout\n\ -\n\ -Returns the timeout in floating seconds associated with socket \n\ -operations. A timeout of None indicates that timeouts on socket \n\ -operations are disabled."); - -#ifdef RISCOS -/* s.sleeptaskw(1 | 0) method */ - -static PyObject * -sock_sleeptaskw(PySocketSockObject *s,PyObject *arg) -{ - int block; - block = PyInt_AsLong(arg); - if (block == -1 && PyErr_Occurred()) - return NULL; - Py_BEGIN_ALLOW_THREADS - socketioctl(s->sock_fd, 0x80046679, (u_long*)&block); - Py_END_ALLOW_THREADS - - Py_INCREF(Py_None); - return Py_None; -} -PyDoc_STRVAR(sleeptaskw_doc, -"sleeptaskw(flag)\n\ -\n\ -Allow sleeps in taskwindows."); -#endif - - -/* s.setsockopt() method. - With an integer third argument, sets an integer option. - With a string third argument, sets an option from a buffer; - use optional built-in module 'struct' to encode the string. */ - -static PyObject * -sock_setsockopt(PySocketSockObject *s, PyObject *args) -{ - int level; - int optname; - int res; - char *buf; - int buflen; - int flag; - - if (PyArg_ParseTuple(args, "iii:setsockopt", - &level, &optname, &flag)) { - buf = (char *) &flag; - buflen = sizeof flag; - } - else { - PyErr_Clear(); - if (!PyArg_ParseTuple(args, "iis#:setsockopt", - &level, &optname, &buf, &buflen)) - return NULL; - } - res = setsockopt(s->sock_fd, level, optname, (void *)buf, buflen); - if (res < 0) - return s->errorhandler(); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(setsockopt_doc, -"setsockopt(level, option, value)\n\ -\n\ -Set a socket option. See the Unix manual for level and option.\n\ -The value argument can either be an integer or a string."); - - -/* s.getsockopt() method. - With two arguments, retrieves an integer option. - With a third integer argument, retrieves a string buffer of that size; - use optional built-in module 'struct' to decode the string. */ - -static PyObject * -sock_getsockopt(PySocketSockObject *s, PyObject *args) -{ - int level; - int optname; - int res; - PyObject *buf; - socklen_t buflen = 0; - -#ifdef __BEOS__ - /* We have incomplete socket support. */ - PyErr_SetString(socket_error, "getsockopt not supported"); - return NULL; -#else - - if (!PyArg_ParseTuple(args, "ii|i:getsockopt", - &level, &optname, &buflen)) - return NULL; - - if (buflen == 0) { - int flag = 0; - socklen_t flagsize = sizeof flag; - res = getsockopt(s->sock_fd, level, optname, - (void *)&flag, &flagsize); - if (res < 0) - return s->errorhandler(); - return PyInt_FromLong(flag); - } -#ifdef __VMS - if (buflen > 1024) { -#else - if (buflen <= 0 || buflen > 1024) { -#endif - PyErr_SetString(socket_error, - "getsockopt buflen out of range"); - return NULL; - } - buf = PyString_FromStringAndSize((char *)NULL, buflen); - if (buf == NULL) - return NULL; - res = getsockopt(s->sock_fd, level, optname, - (void *)PyString_AS_STRING(buf), &buflen); - if (res < 0) { - Py_DECREF(buf); - return s->errorhandler(); - } - _PyString_Resize(&buf, buflen); - return buf; -#endif /* __BEOS__ */ -} - -PyDoc_STRVAR(getsockopt_doc, -"getsockopt(level, option[, buffersize]) -> value\n\ -\n\ -Get a socket option. See the Unix manual for level and option.\n\ -If a nonzero buffersize argument is given, the return value is a\n\ -string of that length; otherwise it is an integer."); - - -/* s.bind(sockaddr) method */ - -static PyObject * -sock_bind(PySocketSockObject *s, PyObject *addro) -{ - struct sockaddr *addr; - int addrlen; - int res; - - if (!getsockaddrarg(s, addro, &addr, &addrlen)) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = bind(s->sock_fd, addr, addrlen); - Py_END_ALLOW_THREADS - if (res < 0) - return s->errorhandler(); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(bind_doc, -"bind(address)\n\ -\n\ -Bind the socket to a local address. For IP sockets, the address is a\n\ -pair (host, port); the host must refer to the local host. For raw packet\n\ -sockets the address is a tuple (ifname, proto [,pkttype [,hatype]])"); - - -/* s.close() method. - Set the file descriptor to -1 so operations tried subsequently - will surely fail. */ - -static PyObject * -sock_close(PySocketSockObject *s) -{ - SOCKET_T fd; - - if ((fd = s->sock_fd) != -1) { - s->sock_fd = -1; - Py_BEGIN_ALLOW_THREADS - (void) SOCKETCLOSE(fd); - Py_END_ALLOW_THREADS - } - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(close_doc, -"close()\n\ -\n\ -Close the socket. It cannot be used after this call."); - -static int -internal_connect(PySocketSockObject *s, struct sockaddr *addr, int addrlen, - int *timeoutp) -{ - int res, timeout; - - timeout = 0; - res = connect(s->sock_fd, addr, addrlen); - -#ifdef MS_WINDOWS - - if (s->sock_timeout > 0.0) { - if (res < 0 && WSAGetLastError() == WSAEWOULDBLOCK) { - /* This is a mess. Best solution: trust select */ - fd_set fds; - struct timeval tv; - tv.tv_sec = (int)s->sock_timeout; - tv.tv_usec = (int)((s->sock_timeout - tv.tv_sec) * 1e6); - FD_ZERO(&fds); - FD_SET(s->sock_fd, &fds); - res = select(s->sock_fd+1, NULL, &fds, NULL, &tv); - if (res == 0) { - res = WSAEWOULDBLOCK; - timeout = 1; - } else if (res > 0) - res = 0; - /* else if (res < 0) an error occurred */ - } - } - - if (res < 0) - res = WSAGetLastError(); - -#else - - if (s->sock_timeout > 0.0) { - if (res < 0 && errno == EINPROGRESS) { - timeout = internal_select(s, 1); - res = connect(s->sock_fd, addr, addrlen); - if (res < 0 && errno == EISCONN) - res = 0; - } - } - - if (res < 0) - res = errno; - -#endif - *timeoutp = timeout; - - return res; -} - -/* s.connect(sockaddr) method */ - -static PyObject * -sock_connect(PySocketSockObject *s, PyObject *addro) -{ - struct sockaddr *addr; - int addrlen; - int res; - int timeout; - - if (!getsockaddrarg(s, addro, &addr, &addrlen)) - return NULL; - - Py_BEGIN_ALLOW_THREADS - res = internal_connect(s, addr, addrlen, &timeout); - Py_END_ALLOW_THREADS - - if (timeout) { - PyErr_SetString(socket_timeout, "timed out"); - return NULL; - } - if (res != 0) - return s->errorhandler(); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(connect_doc, -"connect(address)\n\ -\n\ -Connect the socket to a remote address. For IP sockets, the address\n\ -is a pair (host, port)."); - - -/* s.connect_ex(sockaddr) method */ - -static PyObject * -sock_connect_ex(PySocketSockObject *s, PyObject *addro) -{ - struct sockaddr *addr; - int addrlen; - int res; - int timeout; - - if (!getsockaddrarg(s, addro, &addr, &addrlen)) - return NULL; - - Py_BEGIN_ALLOW_THREADS - res = internal_connect(s, addr, addrlen, &timeout); - Py_END_ALLOW_THREADS - - return PyInt_FromLong((long) res); -} - -PyDoc_STRVAR(connect_ex_doc, -"connect_ex(address) -> errno\n\ -\n\ -This is like connect(address), but returns an error code (the errno value)\n\ -instead of raising an exception when an error occurs."); - - -/* s.fileno() method */ - -static PyObject * -sock_fileno(PySocketSockObject *s) -{ -#if SIZEOF_SOCKET_T <= SIZEOF_LONG - return PyInt_FromLong((long) s->sock_fd); -#else - return PyLong_FromLongLong((PY_LONG_LONG)s->sock_fd); -#endif -} - -PyDoc_STRVAR(fileno_doc, -"fileno() -> integer\n\ -\n\ -Return the integer file descriptor of the socket."); - - -#ifndef NO_DUP -/* s.dup() method */ - -static PyObject * -sock_dup(PySocketSockObject *s) -{ - SOCKET_T newfd; - PyObject *sock; - - newfd = dup(s->sock_fd); - if (newfd < 0) - return s->errorhandler(); - sock = (PyObject *) new_sockobject(newfd, - s->sock_family, - s->sock_type, - s->sock_proto); - if (sock == NULL) - SOCKETCLOSE(newfd); - return sock; -} - -PyDoc_STRVAR(dup_doc, -"dup() -> socket object\n\ -\n\ -Return a new socket object connected to the same system resource."); - -#endif - - -/* s.getsockname() method */ - -static PyObject * -sock_getsockname(PySocketSockObject *s) -{ - char addrbuf[256]; - int res; - socklen_t addrlen; - - if (!getsockaddrlen(s, &addrlen)) - return NULL; - memset(addrbuf, 0, addrlen); - Py_BEGIN_ALLOW_THREADS - res = getsockname(s->sock_fd, (struct sockaddr *) addrbuf, &addrlen); - Py_END_ALLOW_THREADS - if (res < 0) - return s->errorhandler(); - return makesockaddr(s->sock_fd, (struct sockaddr *) addrbuf, addrlen); -} - -PyDoc_STRVAR(getsockname_doc, -"getsockname() -> address info\n\ -\n\ -Return the address of the local endpoint. For IP sockets, the address\n\ -info is a pair (hostaddr, port)."); - - -#ifdef HAVE_GETPEERNAME /* Cray APP doesn't have this :-( */ -/* s.getpeername() method */ - -static PyObject * -sock_getpeername(PySocketSockObject *s) -{ - char addrbuf[256]; - int res; - socklen_t addrlen; - - if (!getsockaddrlen(s, &addrlen)) - return NULL; - memset(addrbuf, 0, addrlen); - Py_BEGIN_ALLOW_THREADS - res = getpeername(s->sock_fd, (struct sockaddr *) addrbuf, &addrlen); - Py_END_ALLOW_THREADS - if (res < 0) - return s->errorhandler(); - return makesockaddr(s->sock_fd, (struct sockaddr *) addrbuf, addrlen); -} - -PyDoc_STRVAR(getpeername_doc, -"getpeername() -> address info\n\ -\n\ -Return the address of the remote endpoint. For IP sockets, the address\n\ -info is a pair (hostaddr, port)."); - -#endif /* HAVE_GETPEERNAME */ - - -/* s.listen(n) method */ - -static PyObject * -sock_listen(PySocketSockObject *s, PyObject *arg) -{ - int backlog; - int res; - - backlog = PyInt_AsLong(arg); - if (backlog == -1 && PyErr_Occurred()) - return NULL; - Py_BEGIN_ALLOW_THREADS - if (backlog < 1) - backlog = 1; - res = listen(s->sock_fd, backlog); - Py_END_ALLOW_THREADS - if (res < 0) - return s->errorhandler(); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(listen_doc, -"listen(backlog)\n\ -\n\ -Enable a server to accept connections. The backlog argument must be at\n\ -least 1; it specifies the number of unaccepted connection that the system\n\ -will allow before refusing new connections."); - - -#ifndef NO_DUP -/* s.makefile(mode) method. - Create a new open file object referring to a dupped version of - the socket's file descriptor. (The dup() call is necessary so - that the open file and socket objects may be closed independent - of each other.) - The mode argument specifies 'r' or 'w' passed to fdopen(). */ - -static PyObject * -sock_makefile(PySocketSockObject *s, PyObject *args) -{ - extern int fclose(FILE *); - char *mode = "r"; - int bufsize = -1; -#ifdef MS_WIN32 - Py_intptr_t fd; -#else - int fd; -#endif - FILE *fp; - PyObject *f; -#ifdef __VMS - char *mode_r = "r"; - char *mode_w = "w"; -#endif - - if (!PyArg_ParseTuple(args, "|si:makefile", &mode, &bufsize)) - return NULL; -#ifdef __VMS - if (strcmp(mode,"rb") == 0) { - mode = mode_r; - } - else { - if (strcmp(mode,"wb") == 0) { - mode = mode_w; - } - } -#endif -#ifdef MS_WIN32 - if (((fd = _open_osfhandle(s->sock_fd, _O_BINARY)) < 0) || - ((fd = dup(fd)) < 0) || ((fp = fdopen(fd, mode)) == NULL)) -#else - if ((fd = dup(s->sock_fd)) < 0 || (fp = fdopen(fd, mode)) == NULL) -#endif - { - if (fd >= 0) - SOCKETCLOSE(fd); - return s->errorhandler(); - } -#ifdef USE_GUSI2 - /* Workaround for bug in Metrowerks MSL vs. GUSI I/O library */ - if (strchr(mode, 'b') != NULL) - bufsize = 0; -#endif - f = PyFile_FromFile(fp, "", mode, fclose); - if (f != NULL) - PyFile_SetBufSize(f, bufsize); - return f; -} - -PyDoc_STRVAR(makefile_doc, -"makefile([mode[, buffersize]]) -> file object\n\ -\n\ -Return a regular file object corresponding to the socket.\n\ -The mode and buffersize arguments are as for the built-in open() function."); - -#endif /* NO_DUP */ - - -/* s.recv(nbytes [,flags]) method */ - -static PyObject * -sock_recv(PySocketSockObject *s, PyObject *args) -{ - int len, n = 0, flags = 0, timeout; - PyObject *buf; -#ifdef __VMS - int read_length; - char *read_buf; -#endif - - if (!PyArg_ParseTuple(args, "i|i:recv", &len, &flags)) - return NULL; - - if (len < 0) { - PyErr_SetString(PyExc_ValueError, - "negative buffersize in recv"); - return NULL; - } - - buf = PyString_FromStringAndSize((char *) 0, len); - if (buf == NULL) - return NULL; - -#ifndef __VMS - Py_BEGIN_ALLOW_THREADS - timeout = internal_select(s, 0); - if (!timeout) - n = recv(s->sock_fd, PyString_AS_STRING(buf), len, flags); - Py_END_ALLOW_THREADS - - if (timeout) { - Py_DECREF(buf); - PyErr_SetString(socket_timeout, "timed out"); - return NULL; - } - if (n < 0) { - Py_DECREF(buf); - return s->errorhandler(); - } - if (n != len) - _PyString_Resize(&buf, n); -#else - read_buf = PyString_AsString(buf); - read_length = len; - while (read_length != 0) { - unsigned int segment; - - segment = read_length /SEGMENT_SIZE; - if (segment != 0) { - segment = SEGMENT_SIZE; - } - else { - segment = read_length; - } - - Py_BEGIN_ALLOW_THREADS - timeout = internal_select(s, 0); - if (!timeout) - n = recv(s->sock_fd, read_buf, segment, flags); - Py_END_ALLOW_THREADS - - if (timeout) { - Py_DECREF(buf); - PyErr_SetString(socket_timeout, "timed out"); - return NULL; - } - if (n < 0) { - Py_DECREF(buf); - return s->errorhandler(); - } - if (n != read_length) { - read_buf += n; - break; - } - - read_length -= segment; - read_buf += segment; - } - if (_PyString_Resize(&buf, (read_buf - PyString_AsString(buf))) < 0) - { - return NULL; - } -#endif /* !__VMS */ - return buf; -} - -PyDoc_STRVAR(recv_doc, -"recv(buffersize[, flags]) -> data\n\ -\n\ -Receive up to buffersize bytes from the socket. For the optional flags\n\ -argument, see the Unix manual. When no data is available, block until\n\ -at least one byte is available or until the remote end is closed. When\n\ -the remote end is closed and all data is read, return the empty string."); - - -/* s.recvfrom(nbytes [,flags]) method */ - -static PyObject * -sock_recvfrom(PySocketSockObject *s, PyObject *args) -{ - char addrbuf[256]; - PyObject *buf = NULL; - PyObject *addr = NULL; - PyObject *ret = NULL; - int len, n = 0, flags = 0, timeout; - socklen_t addrlen; - - if (!PyArg_ParseTuple(args, "i|i:recvfrom", &len, &flags)) - return NULL; - - if (!getsockaddrlen(s, &addrlen)) - return NULL; - buf = PyString_FromStringAndSize((char *) 0, len); - if (buf == NULL) - return NULL; - - Py_BEGIN_ALLOW_THREADS - memset(addrbuf, 0, addrlen); - timeout = internal_select(s, 0); - if (!timeout) - n = recvfrom(s->sock_fd, PyString_AS_STRING(buf), len, flags, -#ifndef MS_WINDOWS -#if defined(PYOS_OS2) && !defined(PYCC_GCC) - (struct sockaddr *)addrbuf, &addrlen -#else - (void *)addrbuf, &addrlen -#endif -#else - (struct sockaddr *)addrbuf, &addrlen -#endif - ); - Py_END_ALLOW_THREADS - - if (timeout) { - Py_DECREF(buf); - PyErr_SetString(socket_timeout, "timed out"); - return NULL; - } - if (n < 0) { - Py_DECREF(buf); - return s->errorhandler(); - } - - if (n != len && _PyString_Resize(&buf, n) < 0) - return NULL; - - if (!(addr = makesockaddr(s->sock_fd, (struct sockaddr *)addrbuf, - addrlen))) - goto finally; - - ret = Py_BuildValue("OO", buf, addr); - -finally: - Py_XDECREF(addr); - Py_XDECREF(buf); - return ret; -} - -PyDoc_STRVAR(recvfrom_doc, -"recvfrom(buffersize[, flags]) -> (data, address info)\n\ -\n\ -Like recv(buffersize, flags) but also return the sender's address info."); - -/* s.send(data [,flags]) method */ - -static PyObject * -sock_send(PySocketSockObject *s, PyObject *args) -{ - char *buf; - int len, n = 0, flags = 0, timeout; -#ifdef __VMS - int send_length; -#endif - - if (!PyArg_ParseTuple(args, "s#|i:send", &buf, &len, &flags)) - return NULL; - -#ifndef __VMS - Py_BEGIN_ALLOW_THREADS - timeout = internal_select(s, 1); - if (!timeout) - n = send(s->sock_fd, buf, len, flags); - Py_END_ALLOW_THREADS - - if (timeout) { - PyErr_SetString(socket_timeout, "timed out"); - return NULL; - } - if (n < 0) - return s->errorhandler(); -#else - /* Divide packet into smaller segments for */ - /* TCP/IP Services for OpenVMS */ - send_length = len; - while (send_length != 0) { - unsigned int segment; - - segment = send_length / SEGMENT_SIZE; - if (segment != 0) { - segment = SEGMENT_SIZE; - } - else { - segment = send_length; - } - Py_BEGIN_ALLOW_THREADS - timeout = internal_select(s, 1); - if (!timeout) - n = send(s->sock_fd, buf, segment, flags); - Py_END_ALLOW_THREADS - if (timeout) { - PyErr_SetString(socket_timeout, "timed out"); - return NULL; - } - if (n < 0) { - return s->errorhandler(); - } - send_length -= segment; - buf += segment; - } /* end while */ -#endif /* !__VMS */ - return PyInt_FromLong((long)n); -} - -PyDoc_STRVAR(send_doc, -"send(data[, flags]) -> count\n\ -\n\ -Send a data string to the socket. For the optional flags\n\ -argument, see the Unix manual. Return the number of bytes\n\ -sent; this may be less than len(data) if the network is busy."); - - -/* s.sendall(data [,flags]) method */ - -static PyObject * -sock_sendall(PySocketSockObject *s, PyObject *args) -{ - char *buf; - int len, n = 0, flags = 0, timeout; - - if (!PyArg_ParseTuple(args, "s#|i:sendall", &buf, &len, &flags)) - return NULL; - - Py_BEGIN_ALLOW_THREADS - do { - timeout = internal_select(s, 1); - if (timeout) - break; - n = send(s->sock_fd, buf, len, flags); - if (n < 0) - break; - buf += n; - len -= n; - } while (len > 0); - Py_END_ALLOW_THREADS - - if (timeout) { - PyErr_SetString(socket_timeout, "timed out"); - return NULL; - } - if (n < 0) - return s->errorhandler(); - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(sendall_doc, -"sendall(data[, flags])\n\ -\n\ -Send a data string to the socket. For the optional flags\n\ -argument, see the Unix manual. This calls send() repeatedly\n\ -until all data is sent. If an error occurs, it's impossible\n\ -to tell how much data has been sent."); - - -/* s.sendto(data, [flags,] sockaddr) method */ - -static PyObject * -sock_sendto(PySocketSockObject *s, PyObject *args) -{ - PyObject *addro; - char *buf; - struct sockaddr *addr; - int addrlen, len, n = 0, flags, timeout; - - flags = 0; - if (!PyArg_ParseTuple(args, "s#O:sendto", &buf, &len, &addro)) { - PyErr_Clear(); - if (!PyArg_ParseTuple(args, "s#iO:sendto", - &buf, &len, &flags, &addro)) - return NULL; - } - - if (!getsockaddrarg(s, addro, &addr, &addrlen)) - return NULL; - - Py_BEGIN_ALLOW_THREADS - timeout = internal_select(s, 1); - if (!timeout) - n = sendto(s->sock_fd, buf, len, flags, addr, addrlen); - Py_END_ALLOW_THREADS - - if (timeout) { - PyErr_SetString(socket_timeout, "timed out"); - return NULL; - } - if (n < 0) - return s->errorhandler(); - return PyInt_FromLong((long)n); -} - -PyDoc_STRVAR(sendto_doc, -"sendto(data[, flags], address) -> count\n\ -\n\ -Like send(data, flags) but allows specifying the destination address.\n\ -For IP sockets, the address is a pair (hostaddr, port)."); - - -/* s.shutdown(how) method */ - -static PyObject * -sock_shutdown(PySocketSockObject *s, PyObject *arg) -{ - int how; - int res; - - how = PyInt_AsLong(arg); - if (how == -1 && PyErr_Occurred()) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = shutdown(s->sock_fd, how); - Py_END_ALLOW_THREADS - if (res < 0) - return s->errorhandler(); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(shutdown_doc, -"shutdown(flag)\n\ -\n\ -Shut down the reading side of the socket (flag == 0), the writing side\n\ -of the socket (flag == 1), or both ends (flag == 2)."); - - -/* List of methods for socket objects */ - -static PyMethodDef sock_methods[] = { - {"accept", (PyCFunction)sock_accept, METH_NOARGS, - accept_doc}, - {"bind", (PyCFunction)sock_bind, METH_O, - bind_doc}, - {"close", (PyCFunction)sock_close, METH_NOARGS, - close_doc}, - {"connect", (PyCFunction)sock_connect, METH_O, - connect_doc}, - {"connect_ex", (PyCFunction)sock_connect_ex, METH_O, - connect_ex_doc}, -#ifndef NO_DUP - {"dup", (PyCFunction)sock_dup, METH_NOARGS, - dup_doc}, -#endif - {"fileno", (PyCFunction)sock_fileno, METH_NOARGS, - fileno_doc}, -#ifdef HAVE_GETPEERNAME - {"getpeername", (PyCFunction)sock_getpeername, - METH_NOARGS, getpeername_doc}, -#endif - {"getsockname", (PyCFunction)sock_getsockname, - METH_NOARGS, getsockname_doc}, - {"getsockopt", (PyCFunction)sock_getsockopt, METH_VARARGS, - getsockopt_doc}, - {"listen", (PyCFunction)sock_listen, METH_O, - listen_doc}, -#ifndef NO_DUP - {"makefile", (PyCFunction)sock_makefile, METH_VARARGS, - makefile_doc}, -#endif - {"recv", (PyCFunction)sock_recv, METH_VARARGS, - recv_doc}, - {"recvfrom", (PyCFunction)sock_recvfrom, METH_VARARGS, - recvfrom_doc}, - {"send", (PyCFunction)sock_send, METH_VARARGS, - send_doc}, - {"sendall", (PyCFunction)sock_sendall, METH_VARARGS, - sendall_doc}, - {"sendto", (PyCFunction)sock_sendto, METH_VARARGS, - sendto_doc}, - {"setblocking", (PyCFunction)sock_setblocking, METH_O, - setblocking_doc}, - {"settimeout", (PyCFunction)sock_settimeout, METH_O, - settimeout_doc}, - {"gettimeout", (PyCFunction)sock_gettimeout, METH_NOARGS, - gettimeout_doc}, - {"setsockopt", (PyCFunction)sock_setsockopt, METH_VARARGS, - setsockopt_doc}, - {"shutdown", (PyCFunction)sock_shutdown, METH_O, - shutdown_doc}, -#ifdef RISCOS - {"sleeptaskw", (PyCFunction)sock_sleeptaskw, METH_O, - sleeptaskw_doc}, -#endif - {NULL, NULL} /* sentinel */ -}; - - -/* Deallocate a socket object in response to the last Py_DECREF(). - First close the file description. */ - -static void -sock_dealloc(PySocketSockObject *s) -{ - if (s->sock_fd != -1) - (void) SOCKETCLOSE(s->sock_fd); - s->ob_type->tp_free((PyObject *)s); -} - - -static PyObject * -sock_repr(PySocketSockObject *s) -{ - char buf[512]; -#if SIZEOF_SOCKET_T > SIZEOF_LONG - if (s->sock_fd > LONG_MAX) { - /* this can occur on Win64, and actually there is a special - ugly printf formatter for decimal pointer length integer - printing, only bother if necessary*/ - PyErr_SetString(PyExc_OverflowError, - "no printf formatter to display " - "the socket descriptor in decimal"); - return NULL; - } -#endif - PyOS_snprintf( - buf, sizeof(buf), - "", - (long)s->sock_fd, s->sock_family, - s->sock_type, - s->sock_proto); - return PyString_FromString(buf); -} - - -/* Create a new, uninitialized socket object. */ - -static PyObject * -sock_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *new; - - new = type->tp_alloc(type, 0); - if (new != NULL) { - ((PySocketSockObject *)new)->sock_fd = -1; - ((PySocketSockObject *)new)->sock_timeout = -1.0; - ((PySocketSockObject *)new)->errorhandler = &set_error; - } - return new; -} - - -/* Initialize a new socket object. */ - -/*ARGSUSED*/ -static int -sock_initobj(PyObject *self, PyObject *args, PyObject *kwds) -{ - PySocketSockObject *s = (PySocketSockObject *)self; - SOCKET_T fd; - int family = AF_INET, type = SOCK_STREAM, proto = 0; - static char *keywords[] = {"family", "type", "proto", 0}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, - "|iii:socket", keywords, - &family, &type, &proto)) - return -1; - - Py_BEGIN_ALLOW_THREADS - fd = socket(family, type, proto); - Py_END_ALLOW_THREADS - -#ifdef MS_WINDOWS - if (fd == INVALID_SOCKET) -#else - if (fd < 0) -#endif - { - set_error(); - return -1; - } - init_sockobject(s, fd, family, type, proto); - /* From now on, ignore SIGPIPE and let the error checking - do the work. */ -#ifdef SIGPIPE - (void) signal(SIGPIPE, SIG_IGN); -#endif - - return 0; - -} - - -/* Type object for socket objects. */ - -static PyTypeObject sock_type = { - PyObject_HEAD_INIT(0) /* Must fill in type value later */ - 0, /* ob_size */ - "_socket.socket", /* tp_name */ - sizeof(PySocketSockObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)sock_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)sock_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - sock_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - sock_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - sock_initobj, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - sock_new, /* tp_new */ - PyObject_Del, /* tp_free */ -}; - - -/* Python interface to gethostname(). */ - -/*ARGSUSED*/ -static PyObject * -socket_gethostname(PyObject *self, PyObject *args) -{ - char buf[1024]; - int res; - if (!PyArg_ParseTuple(args, ":gethostname")) - return NULL; - Py_BEGIN_ALLOW_THREADS - res = gethostname(buf, (int) sizeof buf - 1); - Py_END_ALLOW_THREADS - if (res < 0) - return set_error(); - buf[sizeof buf - 1] = '\0'; - return PyString_FromString(buf); -} - -PyDoc_STRVAR(gethostname_doc, -"gethostname() -> string\n\ -\n\ -Return the current host name."); - - -/* Python interface to gethostbyname(name). */ - -/*ARGSUSED*/ -static PyObject * -socket_gethostbyname(PyObject *self, PyObject *args) -{ - char *name; -#ifdef ENABLE_IPV6 - struct sockaddr_storage addrbuf; -#else - struct sockaddr_in addrbuf; -#endif - - if (!PyArg_ParseTuple(args, "s:gethostbyname", &name)) - return NULL; - if (setipaddr(name, (struct sockaddr *)&addrbuf, sizeof(addrbuf), AF_INET) < 0) - return NULL; - return makeipaddr((struct sockaddr *)&addrbuf, - sizeof(struct sockaddr_in)); -} - -PyDoc_STRVAR(gethostbyname_doc, -"gethostbyname(host) -> address\n\ -\n\ -Return the IP address (a string of the form '255.255.255.255') for a host."); - - -/* Convenience function common to gethostbyname_ex and gethostbyaddr */ - -static PyObject * -gethost_common(struct hostent *h, struct sockaddr *addr, int alen, int af) -{ - char **pch; - PyObject *rtn_tuple = (PyObject *)NULL; - PyObject *name_list = (PyObject *)NULL; - PyObject *addr_list = (PyObject *)NULL; - PyObject *tmp; - - if (h == NULL) { - /* Let's get real error message to return */ -#ifndef RISCOS - set_herror(h_errno); -#else - PyErr_SetString(socket_error, "host not found"); -#endif - return NULL; - } - - if (h->h_addrtype != af) { -#ifdef HAVE_STRERROR - /* Let's get real error message to return */ - PyErr_SetString(socket_error, - (char *)strerror(EAFNOSUPPORT)); -#else - PyErr_SetString( - socket_error, - "Address family not supported by protocol family"); -#endif - return NULL; - } - - switch (af) { - - case AF_INET: - if (alen < sizeof(struct sockaddr_in)) - return NULL; - break; - -#ifdef ENABLE_IPV6 - case AF_INET6: - if (alen < sizeof(struct sockaddr_in6)) - return NULL; - break; -#endif - - } - - if ((name_list = PyList_New(0)) == NULL) - goto err; - - if ((addr_list = PyList_New(0)) == NULL) - goto err; - - for (pch = h->h_aliases; *pch != NULL; pch++) { - int status; - tmp = PyString_FromString(*pch); - if (tmp == NULL) - goto err; - - status = PyList_Append(name_list, tmp); - Py_DECREF(tmp); - - if (status) - goto err; - } - - for (pch = h->h_addr_list; *pch != NULL; pch++) { - int status; - - switch (af) { - - case AF_INET: - { - struct sockaddr_in sin; - memset(&sin, 0, sizeof(sin)); - sin.sin_family = af; -#ifdef HAVE_SOCKADDR_SA_LEN - sin.sin_len = sizeof(sin); -#endif - memcpy(&sin.sin_addr, *pch, sizeof(sin.sin_addr)); - tmp = makeipaddr((struct sockaddr *)&sin, sizeof(sin)); - - if (pch == h->h_addr_list && alen >= sizeof(sin)) - memcpy((char *) addr, &sin, sizeof(sin)); - break; - } - -#ifdef ENABLE_IPV6 - case AF_INET6: - { - struct sockaddr_in6 sin6; - memset(&sin6, 0, sizeof(sin6)); - sin6.sin6_family = af; -#ifdef HAVE_SOCKADDR_SA_LEN - sin6.sin6_len = sizeof(sin6); -#endif - memcpy(&sin6.sin6_addr, *pch, sizeof(sin6.sin6_addr)); - tmp = makeipaddr((struct sockaddr *)&sin6, - sizeof(sin6)); - - if (pch == h->h_addr_list && alen >= sizeof(sin6)) - memcpy((char *) addr, &sin6, sizeof(sin6)); - break; - } -#endif - - default: /* can't happen */ - PyErr_SetString(socket_error, - "unsupported address family"); - return NULL; - } - - if (tmp == NULL) - goto err; - - status = PyList_Append(addr_list, tmp); - Py_DECREF(tmp); - - if (status) - goto err; - } - - rtn_tuple = Py_BuildValue("sOO", h->h_name, name_list, addr_list); - - err: - Py_XDECREF(name_list); - Py_XDECREF(addr_list); - return rtn_tuple; -} - - -/* Python interface to gethostbyname_ex(name). */ - -/*ARGSUSED*/ -static PyObject * -socket_gethostbyname_ex(PyObject *self, PyObject *args) -{ - char *name; - struct hostent *h; -#ifdef ENABLE_IPV6 - struct sockaddr_storage addr; -#else - struct sockaddr_in addr; -#endif - struct sockaddr *sa; - PyObject *ret; -#ifdef HAVE_GETHOSTBYNAME_R - struct hostent hp_allocated; -#ifdef HAVE_GETHOSTBYNAME_R_3_ARG - struct hostent_data data; -#else - char buf[16384]; - int buf_len = (sizeof buf) - 1; - int errnop; -#endif -#if defined(HAVE_GETHOSTBYNAME_R_3_ARG) || defined(HAVE_GETHOSTBYNAME_R_6_ARG) - int result; -#endif -#endif /* HAVE_GETHOSTBYNAME_R */ - - if (!PyArg_ParseTuple(args, "s:gethostbyname_ex", &name)) - return NULL; - if (setipaddr(name, (struct sockaddr *)&addr, sizeof(addr), AF_INET) < 0) - return NULL; - Py_BEGIN_ALLOW_THREADS -#ifdef HAVE_GETHOSTBYNAME_R -#if defined(HAVE_GETHOSTBYNAME_R_6_ARG) - result = gethostbyname_r(name, &hp_allocated, buf, buf_len, - &h, &errnop); -#elif defined(HAVE_GETHOSTBYNAME_R_5_ARG) - h = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop); -#else /* HAVE_GETHOSTBYNAME_R_3_ARG */ - memset((void *) &data, '\0', sizeof(data)); - result = gethostbyname_r(name, &hp_allocated, &data); - h = (result != 0) ? NULL : &hp_allocated; -#endif -#else /* not HAVE_GETHOSTBYNAME_R */ -#ifdef USE_GETHOSTBYNAME_LOCK - PyThread_acquire_lock(netdb_lock, 1); -#endif - h = gethostbyname(name); -#endif /* HAVE_GETHOSTBYNAME_R */ - Py_END_ALLOW_THREADS - /* Some C libraries would require addr.__ss_family instead of - addr.ss_family. - Therefore, we cast the sockaddr_storage into sockaddr to - access sa_family. */ - sa = (struct sockaddr*)&addr; - ret = gethost_common(h, (struct sockaddr *)&addr, sizeof(addr), - sa->sa_family); -#ifdef USE_GETHOSTBYNAME_LOCK - PyThread_release_lock(netdb_lock); -#endif - return ret; -} - -PyDoc_STRVAR(ghbn_ex_doc, -"gethostbyname_ex(host) -> (name, aliaslist, addresslist)\n\ -\n\ -Return the true host name, a list of aliases, and a list of IP addresses,\n\ -for a host. The host argument is a string giving a host name or IP number."); - - -/* Python interface to gethostbyaddr(IP). */ - -/*ARGSUSED*/ -static PyObject * -socket_gethostbyaddr(PyObject *self, PyObject *args) -{ -#ifdef ENABLE_IPV6 - struct sockaddr_storage addr; -#else - struct sockaddr_in addr; -#endif - struct sockaddr *sa = (struct sockaddr *)&addr; - char *ip_num; - struct hostent *h; - PyObject *ret; -#ifdef HAVE_GETHOSTBYNAME_R - struct hostent hp_allocated; -#ifdef HAVE_GETHOSTBYNAME_R_3_ARG - struct hostent_data data; -#else - char buf[16384]; - int buf_len = (sizeof buf) - 1; - int errnop; -#endif -#if defined(HAVE_GETHOSTBYNAME_R_3_ARG) || defined(HAVE_GETHOSTBYNAME_R_6_ARG) - int result; -#endif -#endif /* HAVE_GETHOSTBYNAME_R */ - char *ap; - int al; - int af; - - if (!PyArg_ParseTuple(args, "s:gethostbyaddr", &ip_num)) - return NULL; - af = AF_UNSPEC; - if (setipaddr(ip_num, sa, sizeof(addr), af) < 0) - return NULL; - af = sa->sa_family; - ap = NULL; - al = 0; - switch (af) { - case AF_INET: - ap = (char *)&((struct sockaddr_in *)sa)->sin_addr; - al = sizeof(((struct sockaddr_in *)sa)->sin_addr); - break; -#ifdef ENABLE_IPV6 - case AF_INET6: - ap = (char *)&((struct sockaddr_in6 *)sa)->sin6_addr; - al = sizeof(((struct sockaddr_in6 *)sa)->sin6_addr); - break; -#endif - default: - PyErr_SetString(socket_error, "unsupported address family"); - return NULL; - } - Py_BEGIN_ALLOW_THREADS -#ifdef HAVE_GETHOSTBYNAME_R -#if defined(HAVE_GETHOSTBYNAME_R_6_ARG) - result = gethostbyaddr_r(ap, al, af, - &hp_allocated, buf, buf_len, - &h, &errnop); -#elif defined(HAVE_GETHOSTBYNAME_R_5_ARG) - h = gethostbyaddr_r(ap, al, af, - &hp_allocated, buf, buf_len, &errnop); -#else /* HAVE_GETHOSTBYNAME_R_3_ARG */ - memset((void *) &data, '\0', sizeof(data)); - result = gethostbyaddr_r(ap, al, af, &hp_allocated, &data); - h = (result != 0) ? NULL : &hp_allocated; -#endif -#else /* not HAVE_GETHOSTBYNAME_R */ -#ifdef USE_GETHOSTBYNAME_LOCK - PyThread_acquire_lock(netdb_lock, 1); -#endif - h = gethostbyaddr(ap, al, af); -#endif /* HAVE_GETHOSTBYNAME_R */ - Py_END_ALLOW_THREADS - ret = gethost_common(h, (struct sockaddr *)&addr, sizeof(addr), af); -#ifdef USE_GETHOSTBYNAME_LOCK - PyThread_release_lock(netdb_lock); -#endif - return ret; -} - -PyDoc_STRVAR(gethostbyaddr_doc, -"gethostbyaddr(host) -> (name, aliaslist, addresslist)\n\ -\n\ -Return the true host name, a list of aliases, and a list of IP addresses,\n\ -for a host. The host argument is a string giving a host name or IP number."); - - -/* Python interface to getservbyname(name). - This only returns the port number, since the other info is already - known or not useful (like the list of aliases). */ - -/*ARGSUSED*/ -static PyObject * -socket_getservbyname(PyObject *self, PyObject *args) -{ - char *name, *proto; - struct servent *sp; - if (!PyArg_ParseTuple(args, "ss:getservbyname", &name, &proto)) - return NULL; - Py_BEGIN_ALLOW_THREADS - sp = getservbyname(name, proto); - Py_END_ALLOW_THREADS - if (sp == NULL) { - PyErr_SetString(socket_error, "service/proto not found"); - return NULL; - } - return PyInt_FromLong((long) ntohs(sp->s_port)); -} - -PyDoc_STRVAR(getservbyname_doc, -"getservbyname(servicename, protocolname) -> integer\n\ -\n\ -Return a port number from a service name and protocol name.\n\ -The protocol name should be 'tcp' or 'udp'."); - - -/* Python interface to getprotobyname(name). - This only returns the protocol number, since the other info is - already known or not useful (like the list of aliases). */ - -/*ARGSUSED*/ -static PyObject * -socket_getprotobyname(PyObject *self, PyObject *args) -{ - char *name; - struct protoent *sp; -#ifdef __BEOS__ -/* Not available in BeOS yet. - [cjh] */ - PyErr_SetString(socket_error, "getprotobyname not supported"); - return NULL; -#else - if (!PyArg_ParseTuple(args, "s:getprotobyname", &name)) - return NULL; - Py_BEGIN_ALLOW_THREADS - sp = getprotobyname(name); - Py_END_ALLOW_THREADS - if (sp == NULL) { - PyErr_SetString(socket_error, "protocol not found"); - return NULL; - } - return PyInt_FromLong((long) sp->p_proto); -#endif -} - -PyDoc_STRVAR(getprotobyname_doc, -"getprotobyname(name) -> integer\n\ -\n\ -Return the protocol number for the named protocol. (Rarely used.)"); - - -#ifndef NO_DUP -/* Create a socket object from a numeric file description. - Useful e.g. if stdin is a socket. - Additional arguments as for socket(). */ - -/*ARGSUSED*/ -static PyObject * -socket_fromfd(PyObject *self, PyObject *args) -{ - PySocketSockObject *s; - SOCKET_T fd; - int family, type, proto = 0; - if (!PyArg_ParseTuple(args, "iii|i:fromfd", - &fd, &family, &type, &proto)) - return NULL; - /* Dup the fd so it and the socket can be closed independently */ - fd = dup(fd); - if (fd < 0) - return set_error(); - s = new_sockobject(fd, family, type, proto); - /* From now on, ignore SIGPIPE and let the error checking - do the work. */ -#ifdef SIGPIPE - (void) signal(SIGPIPE, SIG_IGN); -#endif - return (PyObject *) s; -} - -PyDoc_STRVAR(fromfd_doc, -"fromfd(fd, family, type[, proto]) -> socket object\n\ -\n\ -Create a socket object from the given file descriptor.\n\ -The remaining arguments are the same as for socket()."); - -#endif /* NO_DUP */ - - -static PyObject * -socket_ntohs(PyObject *self, PyObject *args) -{ - int x1, x2; - - if (!PyArg_ParseTuple(args, "i:ntohs", &x1)) { - return NULL; - } - x2 = (int)ntohs((short)x1); - return PyInt_FromLong(x2); -} - -PyDoc_STRVAR(ntohs_doc, -"ntohs(integer) -> integer\n\ -\n\ -Convert a 16-bit integer from network to host byte order."); - - -static PyObject * -socket_ntohl(PyObject *self, PyObject *arg) -{ - unsigned long x; - - if (PyInt_Check(arg)) { - x = PyInt_AS_LONG(arg); - if (x == (unsigned long) -1 && PyErr_Occurred()) - return NULL; - } - else if (PyLong_Check(arg)) { - x = PyLong_AsUnsignedLong(arg); - if (x == (unsigned long) -1 && PyErr_Occurred()) - return NULL; -#if SIZEOF_LONG > 4 - { - unsigned long y; - /* only want the trailing 32 bits */ - y = x & 0xFFFFFFFFUL; - if (y ^ x) - return PyErr_Format(PyExc_OverflowError, - "long int larger than 32 bits"); - x = y; - } -#endif - } - else - return PyErr_Format(PyExc_TypeError, - "expected int/long, %s found", - arg->ob_type->tp_name); - if (x == (unsigned long) -1 && PyErr_Occurred()) - return NULL; - return PyInt_FromLong(ntohl(x)); -} - -PyDoc_STRVAR(ntohl_doc, -"ntohl(integer) -> integer\n\ -\n\ -Convert a 32-bit integer from network to host byte order."); - - -static PyObject * -socket_htons(PyObject *self, PyObject *args) -{ - unsigned long x1, x2; - - if (!PyArg_ParseTuple(args, "i:htons", &x1)) { - return NULL; - } - x2 = (int)htons((short)x1); - return PyInt_FromLong(x2); -} - -PyDoc_STRVAR(htons_doc, -"htons(integer) -> integer\n\ -\n\ -Convert a 16-bit integer from host to network byte order."); - - -static PyObject * -socket_htonl(PyObject *self, PyObject *arg) -{ - unsigned long x; - - if (PyInt_Check(arg)) { - x = PyInt_AS_LONG(arg); - if (x == (unsigned long) -1 && PyErr_Occurred()) - return NULL; - } - else if (PyLong_Check(arg)) { - x = PyLong_AsUnsignedLong(arg); - if (x == (unsigned long) -1 && PyErr_Occurred()) - return NULL; -#if SIZEOF_LONG > 4 - { - unsigned long y; - /* only want the trailing 32 bits */ - y = x & 0xFFFFFFFFUL; - if (y ^ x) - return PyErr_Format(PyExc_OverflowError, - "long int larger than 32 bits"); - x = y; - } -#endif - } - else - return PyErr_Format(PyExc_TypeError, - "expected int/long, %s found", - arg->ob_type->tp_name); - return PyInt_FromLong(htonl(x)); -} - -PyDoc_STRVAR(htonl_doc, -"htonl(integer) -> integer\n\ -\n\ -Convert a 32-bit integer from host to network byte order."); - -/* socket.inet_aton() and socket.inet_ntoa() functions. */ - -PyDoc_STRVAR(inet_aton_doc, -"inet_aton(string) -> packed 32-bit IP representation\n\ -\n\ -Convert an IP address in string format (123.45.67.89) to the 32-bit packed\n\ -binary format used in low-level network functions."); - -static PyObject* -socket_inet_aton(PyObject *self, PyObject *args) -{ -#ifndef INADDR_NONE -#define INADDR_NONE (-1) -#endif -#ifdef HAVE_INET_ATON - struct in_addr buf; -#else - /* Have to use inet_addr() instead */ - unsigned long packed_addr; -#endif - char *ip_addr; - - if (!PyArg_ParseTuple(args, "s:inet_aton", &ip_addr)) - return NULL; - - -#ifdef HAVE_INET_ATON - if (inet_aton(ip_addr, &buf)) - return PyString_FromStringAndSize((char *)(&buf), - sizeof(buf)); - - PyErr_SetString(socket_error, - "illegal IP address string passed to inet_aton"); - return NULL; - -#else /* ! HAVE_INET_ATON */ - /* XXX Problem here: inet_aton('255.255.255.255') raises - an exception while it should be a valid address. */ - packed_addr = inet_addr(ip_addr); - - if (packed_addr == INADDR_NONE) { /* invalid address */ - PyErr_SetString(socket_error, - "illegal IP address string passed to inet_aton"); - return NULL; - } - return PyString_FromStringAndSize((char *) &packed_addr, - sizeof(packed_addr)); -#endif -} - -PyDoc_STRVAR(inet_ntoa_doc, -"inet_ntoa(packed_ip) -> ip_address_string\n\ -\n\ -Convert an IP address from 32-bit packed binary format to string format"); - -static PyObject* -socket_inet_ntoa(PyObject *self, PyObject *args) -{ - char *packed_str; - int addr_len; - struct in_addr packed_addr; - - if (!PyArg_ParseTuple(args, "s#:inet_ntoa", &packed_str, &addr_len)) { - return NULL; - } - - if (addr_len != sizeof(packed_addr)) { - PyErr_SetString(socket_error, - "packed IP wrong length for inet_ntoa"); - return NULL; - } - - memcpy(&packed_addr, packed_str, addr_len); - - return PyString_FromString(inet_ntoa(packed_addr)); -} - -#ifdef HAVE_INET_PTON - -PyDoc_STRVAR(inet_pton_doc, -"inet_pton(af, ip) -> packed IP address string\n\ -\n\ -Convert an IP address from string format to a packed string suitable\n\ -for use with low-level network functions."); - -static PyObject * -socket_inet_pton(PyObject *self, PyObject *args) -{ - int af; - char* ip; - int retval; -#ifdef ENABLE_IPV6 - char packed[MAX(sizeof(struct in_addr), sizeof(struct in6_addr))]; -#else - char packed[sizeof(struct in_addr)]; -#endif - if (!PyArg_ParseTuple(args, "is:inet_pton", &af, &ip)) { - return NULL; - } - -#ifndef ENABLE_IPV6 - if(af == AF_INET6) { - PyErr_SetString(socket_error, - "can't use AF_INET6, IPv6 is disabled"); - return NULL; - } -#endif - - retval = inet_pton(af, ip, packed); - if (retval < 0) { - PyErr_SetFromErrno(socket_error); - return NULL; - } else if (retval == 0) { - PyErr_SetString(socket_error, - "illegal IP address string passed to inet_pton"); - return NULL; - } else if (af == AF_INET) { - return PyString_FromStringAndSize(packed, - sizeof(struct in_addr)); -#ifdef ENABLE_IPV6 - } else if (af == AF_INET6) { - return PyString_FromStringAndSize(packed, - sizeof(struct in6_addr)); -#endif - } else { - PyErr_SetString(socket_error, "unknown address family"); - return NULL; - } -} - -PyDoc_STRVAR(inet_ntop_doc, -"inet_ntop(af, packed_ip) -> string formatted IP address\n\ -\n\ -Convert a packed IP address of the given family to string format."); - -static PyObject * -socket_inet_ntop(PyObject *self, PyObject *args) -{ - int af; - char* packed; - int len; - const char* retval; -#ifdef ENABLE_IPV6 - char ip[MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) + 1]; -#else - char ip[INET_ADDRSTRLEN + 1]; -#endif - - /* Guarantee NUL-termination for PyString_FromString() below */ - memset((void *) &ip[0], '\0', sizeof(ip) + 1); - - if (!PyArg_ParseTuple(args, "is#:inet_ntop", &af, &packed, &len)) { - return NULL; - } - - if (af == AF_INET) { - if (len != sizeof(struct in_addr)) { - PyErr_SetString(PyExc_ValueError, - "invalid length of packed IP address string"); - return NULL; - } -#ifdef ENABLE_IPV6 - } else if (af == AF_INET6) { - if (len != sizeof(struct in6_addr)) { - PyErr_SetString(PyExc_ValueError, - "invalid length of packed IP address string"); - return NULL; - } -#endif - } else { - PyErr_Format(PyExc_ValueError, - "unknown address family %d", af); - return NULL; - } - - retval = inet_ntop(af, packed, ip, sizeof(ip)); - if (!retval) { - PyErr_SetFromErrno(socket_error); - return NULL; - } else { - return PyString_FromString(retval); - } - - /* NOTREACHED */ - PyErr_SetString(PyExc_RuntimeError, "invalid handling of inet_ntop"); - return NULL; -} - -#endif /* HAVE_INET_PTON */ - -/* Python interface to getaddrinfo(host, port). */ - -/*ARGSUSED*/ -static PyObject * -socket_getaddrinfo(PyObject *self, PyObject *args) -{ - struct addrinfo hints, *res; - struct addrinfo *res0 = NULL; - PyObject *hobj = NULL; - PyObject *pobj = (PyObject *)NULL; - char pbuf[30]; - char *hptr, *pptr; - int family, socktype, protocol, flags; - int error; - PyObject *all = (PyObject *)NULL; - PyObject *single = (PyObject *)NULL; - PyObject *idna = NULL; - - family = socktype = protocol = flags = 0; - family = AF_UNSPEC; - if (!PyArg_ParseTuple(args, "OO|iiii:getaddrinfo", - &hobj, &pobj, &family, &socktype, - &protocol, &flags)) { - return NULL; - } - if (hobj == Py_None) { - hptr = NULL; - } else if (PyUnicode_Check(hobj)) { - idna = PyObject_CallMethod(hobj, "encode", "s", "idna"); - if (!idna) - return NULL; - hptr = PyString_AsString(idna); - } else if (PyString_Check(hobj)) { - hptr = PyString_AsString(hobj); - } else { - PyErr_SetString(PyExc_TypeError, - "getaddrinfo() argument 1 must be string or None"); - return NULL; - } - if (PyInt_Check(pobj)) { - PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", PyInt_AsLong(pobj)); - pptr = pbuf; - } else if (PyString_Check(pobj)) { - pptr = PyString_AsString(pobj); - } else if (pobj == Py_None) { - pptr = (char *)NULL; - } else { - PyErr_SetString(socket_error, "Int or String expected"); - goto err; - } - memset(&hints, 0, sizeof(hints)); - hints.ai_family = family; - hints.ai_socktype = socktype; - hints.ai_protocol = protocol; - hints.ai_flags = flags; - Py_BEGIN_ALLOW_THREADS - ACQUIRE_GETADDRINFO_LOCK - error = getaddrinfo(hptr, pptr, &hints, &res0); - Py_END_ALLOW_THREADS - RELEASE_GETADDRINFO_LOCK /* see comment in setipaddr() */ - if (error) { - set_gaierror(error); - goto err; - } - - if ((all = PyList_New(0)) == NULL) - goto err; - for (res = res0; res; res = res->ai_next) { - PyObject *addr = - makesockaddr(-1, res->ai_addr, res->ai_addrlen); - if (addr == NULL) - goto err; - single = Py_BuildValue("iiisO", res->ai_family, - res->ai_socktype, res->ai_protocol, - res->ai_canonname ? res->ai_canonname : "", - addr); - Py_DECREF(addr); - if (single == NULL) - goto err; - - if (PyList_Append(all, single)) - goto err; - Py_XDECREF(single); - } - Py_XDECREF(idna); - if (res0) - freeaddrinfo(res0); - return all; - err: - Py_XDECREF(single); - Py_XDECREF(all); - Py_XDECREF(idna); - if (res0) - freeaddrinfo(res0); - return (PyObject *)NULL; -} - -PyDoc_STRVAR(getaddrinfo_doc, -"getaddrinfo(host, port [, family, socktype, proto, flags])\n\ - -> list of (family, socktype, proto, canonname, sockaddr)\n\ -\n\ -Resolve host and port into addrinfo struct."); - -/* Python interface to getnameinfo(sa, flags). */ - -/*ARGSUSED*/ -static PyObject * -socket_getnameinfo(PyObject *self, PyObject *args) -{ - PyObject *sa = (PyObject *)NULL; - int flags; - char *hostp; - int port, flowinfo, scope_id; - char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; - struct addrinfo hints, *res = NULL; - int error; - PyObject *ret = (PyObject *)NULL; - - flags = flowinfo = scope_id = 0; - if (!PyArg_ParseTuple(args, "Oi:getnameinfo", &sa, &flags)) - return NULL; - if (!PyArg_ParseTuple(sa, "si|ii", - &hostp, &port, &flowinfo, &scope_id)) - return NULL; - PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port); - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; /* make numeric port happy */ - Py_BEGIN_ALLOW_THREADS - ACQUIRE_GETADDRINFO_LOCK - error = getaddrinfo(hostp, pbuf, &hints, &res); - Py_END_ALLOW_THREADS - RELEASE_GETADDRINFO_LOCK /* see comment in setipaddr() */ - if (error) { - set_gaierror(error); - goto fail; - } - if (res->ai_next) { - PyErr_SetString(socket_error, - "sockaddr resolved to multiple addresses"); - goto fail; - } - switch (res->ai_family) { - case AF_INET: - { - char *t1; - int t2; - if (PyArg_ParseTuple(sa, "si", &t1, &t2) == 0) { - PyErr_SetString(socket_error, - "IPv4 sockaddr must be 2 tuple"); - goto fail; - } - break; - } -#ifdef ENABLE_IPV6 - case AF_INET6: - { - struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)res->ai_addr; - sin6->sin6_flowinfo = flowinfo; - sin6->sin6_scope_id = scope_id; - break; - } -#endif - } - error = getnameinfo(res->ai_addr, res->ai_addrlen, - hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), flags); - if (error) { - set_gaierror(error); - goto fail; - } - ret = Py_BuildValue("ss", hbuf, pbuf); - -fail: - if (res) - freeaddrinfo(res); - return ret; -} - -PyDoc_STRVAR(getnameinfo_doc, -"getnameinfo(sockaddr, flags) --> (host, port)\n\ -\n\ -Get host and port for a sockaddr."); - - -/* Python API to getting and setting the default timeout value. */ - -static PyObject * -socket_getdefaulttimeout(PyObject *self) -{ - if (defaulttimeout < 0.0) { - Py_INCREF(Py_None); - return Py_None; - } - else - return PyFloat_FromDouble(defaulttimeout); -} - -PyDoc_STRVAR(getdefaulttimeout_doc, -"getdefaulttimeout() -> timeout\n\ -\n\ -Returns the default timeout in floating seconds for new socket objects.\n\ -A value of None indicates that new socket objects have no timeout.\n\ -When the socket module is first imported, the default is None."); - -static PyObject * -socket_setdefaulttimeout(PyObject *self, PyObject *arg) -{ - double timeout; - - if (arg == Py_None) - timeout = -1.0; - else { - timeout = PyFloat_AsDouble(arg); - if (timeout < 0.0) { - if (!PyErr_Occurred()) - PyErr_SetString(PyExc_ValueError, - "Timeout value out of range"); - return NULL; - } - } - - defaulttimeout = timeout; - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(setdefaulttimeout_doc, -"setdefaulttimeout(timeout)\n\ -\n\ -Set the default timeout in floating seconds for new socket objects.\n\ -A value of None indicates that new socket objects have no timeout.\n\ -When the socket module is first imported, the default is None."); - - -/* List of functions exported by this module. */ - -static PyMethodDef socket_methods[] = { - {"gethostbyname", socket_gethostbyname, - METH_VARARGS, gethostbyname_doc}, - {"gethostbyname_ex", socket_gethostbyname_ex, - METH_VARARGS, ghbn_ex_doc}, - {"gethostbyaddr", socket_gethostbyaddr, - METH_VARARGS, gethostbyaddr_doc}, - {"gethostname", socket_gethostname, - METH_VARARGS, gethostname_doc}, - {"getservbyname", socket_getservbyname, - METH_VARARGS, getservbyname_doc}, - {"getprotobyname", socket_getprotobyname, - METH_VARARGS,getprotobyname_doc}, -#ifndef NO_DUP - {"fromfd", socket_fromfd, - METH_VARARGS, fromfd_doc}, -#endif - {"ntohs", socket_ntohs, - METH_VARARGS, ntohs_doc}, - {"ntohl", socket_ntohl, - METH_O, ntohl_doc}, - {"htons", socket_htons, - METH_VARARGS, htons_doc}, - {"htonl", socket_htonl, - METH_O, htonl_doc}, - {"inet_aton", socket_inet_aton, - METH_VARARGS, inet_aton_doc}, - {"inet_ntoa", socket_inet_ntoa, - METH_VARARGS, inet_ntoa_doc}, -#ifdef HAVE_INET_PTON - {"inet_pton", socket_inet_pton, - METH_VARARGS, inet_pton_doc}, - {"inet_ntop", socket_inet_ntop, - METH_VARARGS, inet_ntop_doc}, -#endif - {"getaddrinfo", socket_getaddrinfo, - METH_VARARGS, getaddrinfo_doc}, - {"getnameinfo", socket_getnameinfo, - METH_VARARGS, getnameinfo_doc}, - {"getdefaulttimeout", (PyCFunction)socket_getdefaulttimeout, - METH_NOARGS, getdefaulttimeout_doc}, - {"setdefaulttimeout", socket_setdefaulttimeout, - METH_O, setdefaulttimeout_doc}, - {NULL, NULL} /* Sentinel */ -}; - - -#ifdef RISCOS -#define OS_INIT_DEFINED - -static int -os_init(void) -{ - _kernel_swi_regs r; - - r.r[0] = 0; - _kernel_swi(0x43380, &r, &r); - taskwindow = r.r[0]; - - return 1; -} - -#endif /* RISCOS */ - - -#ifdef MS_WINDOWS -#define OS_INIT_DEFINED - -/* Additional initialization and cleanup for Windows */ - -static void -os_cleanup(void) -{ - WSACleanup(); -} - -static int -os_init(void) -{ - WSADATA WSAData; - int ret; - char buf[100]; - ret = WSAStartup(0x0101, &WSAData); - switch (ret) { - case 0: /* No error */ - Py_AtExit(os_cleanup); - return 1; /* Success */ - case WSASYSNOTREADY: - PyErr_SetString(PyExc_ImportError, - "WSAStartup failed: network not ready"); - break; - case WSAVERNOTSUPPORTED: - case WSAEINVAL: - PyErr_SetString( - PyExc_ImportError, - "WSAStartup failed: requested version not supported"); - break; - default: - PyOS_snprintf(buf, sizeof(buf), - "WSAStartup failed: error code %d", ret); - PyErr_SetString(PyExc_ImportError, buf); - break; - } - return 0; /* Failure */ -} - -#endif /* MS_WINDOWS */ - - -#ifdef PYOS_OS2 -#define OS_INIT_DEFINED - -/* Additional initialization for OS/2 */ - -static int -os_init(void) -{ -#ifndef PYCC_GCC - char reason[64]; - int rc = sock_init(); - - if (rc == 0) { - return 1; /* Success */ - } - - PyOS_snprintf(reason, sizeof(reason), - "OS/2 TCP/IP Error# %d", sock_errno()); - PyErr_SetString(PyExc_ImportError, reason); - - return 0; /* Failure */ -#else - /* No need to initialise sockets with GCC/EMX */ - return 1; /* Success */ -#endif -} - -#endif /* PYOS_OS2 */ - - -#ifndef OS_INIT_DEFINED -static int -os_init(void) -{ - return 1; /* Success */ -} -#endif - - -/* C API table - always add new things to the end for binary - compatibility. */ -static -PySocketModule_APIObject PySocketModuleAPI = -{ - &sock_type, -}; - - -/* Initialize the _socket module. - - This module is actually called "_socket", and there's a wrapper - "socket.py" which implements some additional functionality. On some - platforms (e.g. Windows and OS/2), socket.py also implements a - wrapper for the socket type that provides missing functionality such - as makefile(), dup() and fromfd(). The import of "_socket" may fail - with an ImportError exception if os-specific initialization fails. - On Windows, this does WINSOCK initialization. When WINSOCK is - initialized succesfully, a call to WSACleanup() is scheduled to be - made at exit time. -*/ - -PyDoc_STRVAR(socket_doc, -"Implementation module for socket operations.\n\ -\n\ -See the socket module for documentation."); - -PyMODINIT_FUNC -init_socket(void) -{ - PyObject *m, *has_ipv6; - - if (!os_init()) - return; - - sock_type.ob_type = &PyType_Type; - m = Py_InitModule3(PySocket_MODULE_NAME, - socket_methods, - socket_doc); - - socket_error = PyErr_NewException("socket.error", NULL, NULL); - if (socket_error == NULL) - return; - Py_INCREF(socket_error); - PyModule_AddObject(m, "error", socket_error); - socket_herror = PyErr_NewException("socket.herror", - socket_error, NULL); - if (socket_herror == NULL) - return; - Py_INCREF(socket_herror); - PyModule_AddObject(m, "herror", socket_herror); - socket_gaierror = PyErr_NewException("socket.gaierror", socket_error, - NULL); - if (socket_gaierror == NULL) - return; - Py_INCREF(socket_gaierror); - PyModule_AddObject(m, "gaierror", socket_gaierror); - socket_timeout = PyErr_NewException("socket.timeout", - socket_error, NULL); - if (socket_timeout == NULL) - return; - Py_INCREF(socket_timeout); - PyModule_AddObject(m, "timeout", socket_timeout); - Py_INCREF((PyObject *)&sock_type); - if (PyModule_AddObject(m, "SocketType", - (PyObject *)&sock_type) != 0) - return; - Py_INCREF((PyObject *)&sock_type); - if (PyModule_AddObject(m, "socket", - (PyObject *)&sock_type) != 0) - return; - -#ifdef ENABLE_IPV6 - has_ipv6 = Py_True; -#else - has_ipv6 = Py_False; -#endif - Py_INCREF(has_ipv6); - PyModule_AddObject(m, "has_ipv6", has_ipv6); - - /* Export C API */ - if (PyModule_AddObject(m, PySocket_CAPI_NAME, - PyCObject_FromVoidPtr((void *)&PySocketModuleAPI, NULL) - ) != 0) - return; - - /* Address families (we only support AF_INET and AF_UNIX) */ -#ifdef AF_UNSPEC - PyModule_AddIntConstant(m, "AF_UNSPEC", AF_UNSPEC); -#endif - PyModule_AddIntConstant(m, "AF_INET", AF_INET); -#ifdef AF_INET6 - PyModule_AddIntConstant(m, "AF_INET6", AF_INET6); -#endif /* AF_INET6 */ -#if defined(AF_UNIX) && !defined(PYOS_OS2) - PyModule_AddIntConstant(m, "AF_UNIX", AF_UNIX); -#endif /* AF_UNIX */ -#ifdef AF_AX25 - /* Amateur Radio AX.25 */ - PyModule_AddIntConstant(m, "AF_AX25", AF_AX25); -#endif -#ifdef AF_IPX - PyModule_AddIntConstant(m, "AF_IPX", AF_IPX); /* Novell IPX */ -#endif -#ifdef AF_APPLETALK - /* Appletalk DDP */ - PyModule_AddIntConstant(m, "AF_APPLETALK", AF_APPLETALK); -#endif -#ifdef AF_NETROM - /* Amateur radio NetROM */ - PyModule_AddIntConstant(m, "AF_NETROM", AF_NETROM); -#endif -#ifdef AF_BRIDGE - /* Multiprotocol bridge */ - PyModule_AddIntConstant(m, "AF_BRIDGE", AF_BRIDGE); -#endif -#ifdef AF_AAL5 - /* Reserved for Werner's ATM */ - PyModule_AddIntConstant(m, "AF_AAL5", AF_AAL5); -#endif -#ifdef AF_X25 - /* Reserved for X.25 project */ - PyModule_AddIntConstant(m, "AF_X25", AF_X25); -#endif -#ifdef AF_INET6 - PyModule_AddIntConstant(m, "AF_INET6", AF_INET6); /* IP version 6 */ -#endif -#ifdef AF_ROSE - /* Amateur Radio X.25 PLP */ - PyModule_AddIntConstant(m, "AF_ROSE", AF_ROSE); -#endif -#ifdef HAVE_NETPACKET_PACKET_H - PyModule_AddIntConstant(m, "AF_PACKET", AF_PACKET); - PyModule_AddIntConstant(m, "PF_PACKET", PF_PACKET); - PyModule_AddIntConstant(m, "PACKET_HOST", PACKET_HOST); - PyModule_AddIntConstant(m, "PACKET_BROADCAST", PACKET_BROADCAST); - PyModule_AddIntConstant(m, "PACKET_MULTICAST", PACKET_MULTICAST); - PyModule_AddIntConstant(m, "PACKET_OTHERHOST", PACKET_OTHERHOST); - PyModule_AddIntConstant(m, "PACKET_OUTGOING", PACKET_OUTGOING); - PyModule_AddIntConstant(m, "PACKET_LOOPBACK", PACKET_LOOPBACK); - PyModule_AddIntConstant(m, "PACKET_FASTROUTE", PACKET_FASTROUTE); -#endif - - /* Socket types */ - PyModule_AddIntConstant(m, "SOCK_STREAM", SOCK_STREAM); - PyModule_AddIntConstant(m, "SOCK_DGRAM", SOCK_DGRAM); -#ifndef __BEOS__ -/* We have incomplete socket support. */ - PyModule_AddIntConstant(m, "SOCK_RAW", SOCK_RAW); - PyModule_AddIntConstant(m, "SOCK_SEQPACKET", SOCK_SEQPACKET); -#if defined(SOCK_RDM) - PyModule_AddIntConstant(m, "SOCK_RDM", SOCK_RDM); -#endif -#endif - -#ifdef SO_DEBUG - PyModule_AddIntConstant(m, "SO_DEBUG", SO_DEBUG); -#endif -#ifdef SO_ACCEPTCONN - PyModule_AddIntConstant(m, "SO_ACCEPTCONN", SO_ACCEPTCONN); -#endif -#ifdef SO_REUSEADDR - PyModule_AddIntConstant(m, "SO_REUSEADDR", SO_REUSEADDR); -#endif -#ifdef SO_KEEPALIVE - PyModule_AddIntConstant(m, "SO_KEEPALIVE", SO_KEEPALIVE); -#endif -#ifdef SO_DONTROUTE - PyModule_AddIntConstant(m, "SO_DONTROUTE", SO_DONTROUTE); -#endif -#ifdef SO_BROADCAST - PyModule_AddIntConstant(m, "SO_BROADCAST", SO_BROADCAST); -#endif -#ifdef SO_USELOOPBACK - PyModule_AddIntConstant(m, "SO_USELOOPBACK", SO_USELOOPBACK); -#endif -#ifdef SO_LINGER - PyModule_AddIntConstant(m, "SO_LINGER", SO_LINGER); -#endif -#ifdef SO_OOBINLINE - PyModule_AddIntConstant(m, "SO_OOBINLINE", SO_OOBINLINE); -#endif -#ifdef SO_REUSEPORT - PyModule_AddIntConstant(m, "SO_REUSEPORT", SO_REUSEPORT); -#endif -#ifdef SO_SNDBUF - PyModule_AddIntConstant(m, "SO_SNDBUF", SO_SNDBUF); -#endif -#ifdef SO_RCVBUF - PyModule_AddIntConstant(m, "SO_RCVBUF", SO_RCVBUF); -#endif -#ifdef SO_SNDLOWAT - PyModule_AddIntConstant(m, "SO_SNDLOWAT", SO_SNDLOWAT); -#endif -#ifdef SO_RCVLOWAT - PyModule_AddIntConstant(m, "SO_RCVLOWAT", SO_RCVLOWAT); -#endif -#ifdef SO_SNDTIMEO - PyModule_AddIntConstant(m, "SO_SNDTIMEO", SO_SNDTIMEO); -#endif -#ifdef SO_RCVTIMEO - PyModule_AddIntConstant(m, "SO_RCVTIMEO", SO_RCVTIMEO); -#endif -#ifdef SO_ERROR - PyModule_AddIntConstant(m, "SO_ERROR", SO_ERROR); -#endif -#ifdef SO_TYPE - PyModule_AddIntConstant(m, "SO_TYPE", SO_TYPE); -#endif - - /* Maximum number of connections for "listen" */ -#ifdef SOMAXCONN - PyModule_AddIntConstant(m, "SOMAXCONN", SOMAXCONN); -#else - PyModule_AddIntConstant(m, "SOMAXCONN", 5); /* Common value */ -#endif - - /* Flags for send, recv */ -#ifdef MSG_OOB - PyModule_AddIntConstant(m, "MSG_OOB", MSG_OOB); -#endif -#ifdef MSG_PEEK - PyModule_AddIntConstant(m, "MSG_PEEK", MSG_PEEK); -#endif -#ifdef MSG_DONTROUTE - PyModule_AddIntConstant(m, "MSG_DONTROUTE", MSG_DONTROUTE); -#endif -#ifdef MSG_DONTWAIT - PyModule_AddIntConstant(m, "MSG_DONTWAIT", MSG_DONTWAIT); -#endif -#ifdef MSG_EOR - PyModule_AddIntConstant(m, "MSG_EOR", MSG_EOR); -#endif -#ifdef MSG_TRUNC - PyModule_AddIntConstant(m, "MSG_TRUNC", MSG_TRUNC); -#endif -#ifdef MSG_CTRUNC - PyModule_AddIntConstant(m, "MSG_CTRUNC", MSG_CTRUNC); -#endif -#ifdef MSG_WAITALL - PyModule_AddIntConstant(m, "MSG_WAITALL", MSG_WAITALL); -#endif -#ifdef MSG_BTAG - PyModule_AddIntConstant(m, "MSG_BTAG", MSG_BTAG); -#endif -#ifdef MSG_ETAG - PyModule_AddIntConstant(m, "MSG_ETAG", MSG_ETAG); -#endif - - /* Protocol level and numbers, usable for [gs]etsockopt */ -#ifdef SOL_SOCKET - PyModule_AddIntConstant(m, "SOL_SOCKET", SOL_SOCKET); -#endif -#ifdef SOL_IP - PyModule_AddIntConstant(m, "SOL_IP", SOL_IP); -#else - PyModule_AddIntConstant(m, "SOL_IP", 0); -#endif -#ifdef SOL_IPX - PyModule_AddIntConstant(m, "SOL_IPX", SOL_IPX); -#endif -#ifdef SOL_AX25 - PyModule_AddIntConstant(m, "SOL_AX25", SOL_AX25); -#endif -#ifdef SOL_ATALK - PyModule_AddIntConstant(m, "SOL_ATALK", SOL_ATALK); -#endif -#ifdef SOL_NETROM - PyModule_AddIntConstant(m, "SOL_NETROM", SOL_NETROM); -#endif -#ifdef SOL_ROSE - PyModule_AddIntConstant(m, "SOL_ROSE", SOL_ROSE); -#endif -#ifdef SOL_TCP - PyModule_AddIntConstant(m, "SOL_TCP", SOL_TCP); -#else - PyModule_AddIntConstant(m, "SOL_TCP", 6); -#endif -#ifdef SOL_UDP - PyModule_AddIntConstant(m, "SOL_UDP", SOL_UDP); -#else - PyModule_AddIntConstant(m, "SOL_UDP", 17); -#endif -#ifdef IPPROTO_IP - PyModule_AddIntConstant(m, "IPPROTO_IP", IPPROTO_IP); -#else - PyModule_AddIntConstant(m, "IPPROTO_IP", 0); -#endif -#ifdef IPPROTO_HOPOPTS - PyModule_AddIntConstant(m, "IPPROTO_HOPOPTS", IPPROTO_HOPOPTS); -#endif -#ifdef IPPROTO_ICMP - PyModule_AddIntConstant(m, "IPPROTO_ICMP", IPPROTO_ICMP); -#else - PyModule_AddIntConstant(m, "IPPROTO_ICMP", 1); -#endif -#ifdef IPPROTO_IGMP - PyModule_AddIntConstant(m, "IPPROTO_IGMP", IPPROTO_IGMP); -#endif -#ifdef IPPROTO_GGP - PyModule_AddIntConstant(m, "IPPROTO_GGP", IPPROTO_GGP); -#endif -#ifdef IPPROTO_IPV4 - PyModule_AddIntConstant(m, "IPPROTO_IPV4", IPPROTO_IPV4); -#endif -#ifdef IPPROTO_IPV6 - PyModule_AddIntConstant(m, "IPPROTO_IPV6", IPPROTO_IPV6); -#endif -#ifdef IPPROTO_IPIP - PyModule_AddIntConstant(m, "IPPROTO_IPIP", IPPROTO_IPIP); -#endif -#ifdef IPPROTO_TCP - PyModule_AddIntConstant(m, "IPPROTO_TCP", IPPROTO_TCP); -#else - PyModule_AddIntConstant(m, "IPPROTO_TCP", 6); -#endif -#ifdef IPPROTO_EGP - PyModule_AddIntConstant(m, "IPPROTO_EGP", IPPROTO_EGP); -#endif -#ifdef IPPROTO_PUP - PyModule_AddIntConstant(m, "IPPROTO_PUP", IPPROTO_PUP); -#endif -#ifdef IPPROTO_UDP - PyModule_AddIntConstant(m, "IPPROTO_UDP", IPPROTO_UDP); -#else - PyModule_AddIntConstant(m, "IPPROTO_UDP", 17); -#endif -#ifdef IPPROTO_IDP - PyModule_AddIntConstant(m, "IPPROTO_IDP", IPPROTO_IDP); -#endif -#ifdef IPPROTO_HELLO - PyModule_AddIntConstant(m, "IPPROTO_HELLO", IPPROTO_HELLO); -#endif -#ifdef IPPROTO_ND - PyModule_AddIntConstant(m, "IPPROTO_ND", IPPROTO_ND); -#endif -#ifdef IPPROTO_TP - PyModule_AddIntConstant(m, "IPPROTO_TP", IPPROTO_TP); -#endif -#ifdef IPPROTO_IPV6 - PyModule_AddIntConstant(m, "IPPROTO_IPV6", IPPROTO_IPV6); -#endif -#ifdef IPPROTO_ROUTING - PyModule_AddIntConstant(m, "IPPROTO_ROUTING", IPPROTO_ROUTING); -#endif -#ifdef IPPROTO_FRAGMENT - PyModule_AddIntConstant(m, "IPPROTO_FRAGMENT", IPPROTO_FRAGMENT); -#endif -#ifdef IPPROTO_RSVP - PyModule_AddIntConstant(m, "IPPROTO_RSVP", IPPROTO_RSVP); -#endif -#ifdef IPPROTO_GRE - PyModule_AddIntConstant(m, "IPPROTO_GRE", IPPROTO_GRE); -#endif -#ifdef IPPROTO_ESP - PyModule_AddIntConstant(m, "IPPROTO_ESP", IPPROTO_ESP); -#endif -#ifdef IPPROTO_AH - PyModule_AddIntConstant(m, "IPPROTO_AH", IPPROTO_AH); -#endif -#ifdef IPPROTO_MOBILE - PyModule_AddIntConstant(m, "IPPROTO_MOBILE", IPPROTO_MOBILE); -#endif -#ifdef IPPROTO_ICMPV6 - PyModule_AddIntConstant(m, "IPPROTO_ICMPV6", IPPROTO_ICMPV6); -#endif -#ifdef IPPROTO_NONE - PyModule_AddIntConstant(m, "IPPROTO_NONE", IPPROTO_NONE); -#endif -#ifdef IPPROTO_DSTOPTS - PyModule_AddIntConstant(m, "IPPROTO_DSTOPTS", IPPROTO_DSTOPTS); -#endif -#ifdef IPPROTO_XTP - PyModule_AddIntConstant(m, "IPPROTO_XTP", IPPROTO_XTP); -#endif -#ifdef IPPROTO_EON - PyModule_AddIntConstant(m, "IPPROTO_EON", IPPROTO_EON); -#endif -#ifdef IPPROTO_PIM - PyModule_AddIntConstant(m, "IPPROTO_PIM", IPPROTO_PIM); -#endif -#ifdef IPPROTO_IPCOMP - PyModule_AddIntConstant(m, "IPPROTO_IPCOMP", IPPROTO_IPCOMP); -#endif -#ifdef IPPROTO_VRRP - PyModule_AddIntConstant(m, "IPPROTO_VRRP", IPPROTO_VRRP); -#endif -#ifdef IPPROTO_BIP - PyModule_AddIntConstant(m, "IPPROTO_BIP", IPPROTO_BIP); -#endif -/**/ -#ifdef IPPROTO_RAW - PyModule_AddIntConstant(m, "IPPROTO_RAW", IPPROTO_RAW); -#else - PyModule_AddIntConstant(m, "IPPROTO_RAW", 255); -#endif -#ifdef IPPROTO_MAX - PyModule_AddIntConstant(m, "IPPROTO_MAX", IPPROTO_MAX); -#endif - - /* Some port configuration */ -#ifdef IPPORT_RESERVED - PyModule_AddIntConstant(m, "IPPORT_RESERVED", IPPORT_RESERVED); -#else - PyModule_AddIntConstant(m, "IPPORT_RESERVED", 1024); -#endif -#ifdef IPPORT_USERRESERVED - PyModule_AddIntConstant(m, "IPPORT_USERRESERVED", IPPORT_USERRESERVED); -#else - PyModule_AddIntConstant(m, "IPPORT_USERRESERVED", 5000); -#endif - - /* Some reserved IP v.4 addresses */ -#ifdef INADDR_ANY - PyModule_AddIntConstant(m, "INADDR_ANY", INADDR_ANY); -#else - PyModule_AddIntConstant(m, "INADDR_ANY", 0x00000000); -#endif -#ifdef INADDR_BROADCAST - PyModule_AddIntConstant(m, "INADDR_BROADCAST", INADDR_BROADCAST); -#else - PyModule_AddIntConstant(m, "INADDR_BROADCAST", 0xffffffff); -#endif -#ifdef INADDR_LOOPBACK - PyModule_AddIntConstant(m, "INADDR_LOOPBACK", INADDR_LOOPBACK); -#else - PyModule_AddIntConstant(m, "INADDR_LOOPBACK", 0x7F000001); -#endif -#ifdef INADDR_UNSPEC_GROUP - PyModule_AddIntConstant(m, "INADDR_UNSPEC_GROUP", INADDR_UNSPEC_GROUP); -#else - PyModule_AddIntConstant(m, "INADDR_UNSPEC_GROUP", 0xe0000000); -#endif -#ifdef INADDR_ALLHOSTS_GROUP - PyModule_AddIntConstant(m, "INADDR_ALLHOSTS_GROUP", - INADDR_ALLHOSTS_GROUP); -#else - PyModule_AddIntConstant(m, "INADDR_ALLHOSTS_GROUP", 0xe0000001); -#endif -#ifdef INADDR_MAX_LOCAL_GROUP - PyModule_AddIntConstant(m, "INADDR_MAX_LOCAL_GROUP", - INADDR_MAX_LOCAL_GROUP); -#else - PyModule_AddIntConstant(m, "INADDR_MAX_LOCAL_GROUP", 0xe00000ff); -#endif -#ifdef INADDR_NONE - PyModule_AddIntConstant(m, "INADDR_NONE", INADDR_NONE); -#else - PyModule_AddIntConstant(m, "INADDR_NONE", 0xffffffff); -#endif - - /* IPv4 [gs]etsockopt options */ -#ifdef IP_OPTIONS - PyModule_AddIntConstant(m, "IP_OPTIONS", IP_OPTIONS); -#endif -#ifdef IP_HDRINCL - PyModule_AddIntConstant(m, "IP_HDRINCL", IP_HDRINCL); -#endif -#ifdef IP_TOS - PyModule_AddIntConstant(m, "IP_TOS", IP_TOS); -#endif -#ifdef IP_TTL - PyModule_AddIntConstant(m, "IP_TTL", IP_TTL); -#endif -#ifdef IP_RECVOPTS - PyModule_AddIntConstant(m, "IP_RECVOPTS", IP_RECVOPTS); -#endif -#ifdef IP_RECVRETOPTS - PyModule_AddIntConstant(m, "IP_RECVRETOPTS", IP_RECVRETOPTS); -#endif -#ifdef IP_RECVDSTADDR - PyModule_AddIntConstant(m, "IP_RECVDSTADDR", IP_RECVDSTADDR); -#endif -#ifdef IP_RETOPTS - PyModule_AddIntConstant(m, "IP_RETOPTS", IP_RETOPTS); -#endif -#ifdef IP_MULTICAST_IF - PyModule_AddIntConstant(m, "IP_MULTICAST_IF", IP_MULTICAST_IF); -#endif -#ifdef IP_MULTICAST_TTL - PyModule_AddIntConstant(m, "IP_MULTICAST_TTL", IP_MULTICAST_TTL); -#endif -#ifdef IP_MULTICAST_LOOP - PyModule_AddIntConstant(m, "IP_MULTICAST_LOOP", IP_MULTICAST_LOOP); -#endif -#ifdef IP_ADD_MEMBERSHIP - PyModule_AddIntConstant(m, "IP_ADD_MEMBERSHIP", IP_ADD_MEMBERSHIP); -#endif -#ifdef IP_DROP_MEMBERSHIP - PyModule_AddIntConstant(m, "IP_DROP_MEMBERSHIP", IP_DROP_MEMBERSHIP); -#endif -#ifdef IP_DEFAULT_MULTICAST_TTL - PyModule_AddIntConstant(m, "IP_DEFAULT_MULTICAST_TTL", - IP_DEFAULT_MULTICAST_TTL); -#endif -#ifdef IP_DEFAULT_MULTICAST_LOOP - PyModule_AddIntConstant(m, "IP_DEFAULT_MULTICAST_LOOP", - IP_DEFAULT_MULTICAST_LOOP); -#endif -#ifdef IP_MAX_MEMBERSHIPS - PyModule_AddIntConstant(m, "IP_MAX_MEMBERSHIPS", IP_MAX_MEMBERSHIPS); -#endif - - /* IPv6 [gs]etsockopt options, defined in RFC2553 */ -#ifdef IPV6_JOIN_GROUP - PyModule_AddIntConstant(m, "IPV6_JOIN_GROUP", IPV6_JOIN_GROUP); -#endif -#ifdef IPV6_LEAVE_GROUP - PyModule_AddIntConstant(m, "IPV6_LEAVE_GROUP", IPV6_LEAVE_GROUP); -#endif -#ifdef IPV6_MULTICAST_HOPS - PyModule_AddIntConstant(m, "IPV6_MULTICAST_HOPS", IPV6_MULTICAST_HOPS); -#endif -#ifdef IPV6_MULTICAST_IF - PyModule_AddIntConstant(m, "IPV6_MULTICAST_IF", IPV6_MULTICAST_IF); -#endif -#ifdef IPV6_MULTICAST_LOOP - PyModule_AddIntConstant(m, "IPV6_MULTICAST_LOOP", IPV6_MULTICAST_LOOP); -#endif -#ifdef IPV6_UNICAST_HOPS - PyModule_AddIntConstant(m, "IPV6_UNICAST_HOPS", IPV6_UNICAST_HOPS); -#endif - - /* TCP options */ -#ifdef TCP_NODELAY - PyModule_AddIntConstant(m, "TCP_NODELAY", TCP_NODELAY); -#endif -#ifdef TCP_MAXSEG - PyModule_AddIntConstant(m, "TCP_MAXSEG", TCP_MAXSEG); -#endif -#ifdef TCP_CORK - PyModule_AddIntConstant(m, "TCP_CORK", TCP_CORK); -#endif -#ifdef TCP_KEEPIDLE - PyModule_AddIntConstant(m, "TCP_KEEPIDLE", TCP_KEEPIDLE); -#endif -#ifdef TCP_KEEPINTVL - PyModule_AddIntConstant(m, "TCP_KEEPINTVL", TCP_KEEPINTVL); -#endif -#ifdef TCP_KEEPCNT - PyModule_AddIntConstant(m, "TCP_KEEPCNT", TCP_KEEPCNT); -#endif -#ifdef TCP_SYNCNT - PyModule_AddIntConstant(m, "TCP_SYNCNT", TCP_SYNCNT); -#endif -#ifdef TCP_LINGER2 - PyModule_AddIntConstant(m, "TCP_LINGER2", TCP_LINGER2); -#endif -#ifdef TCP_DEFER_ACCEPT - PyModule_AddIntConstant(m, "TCP_DEFER_ACCEPT", TCP_DEFER_ACCEPT); -#endif -#ifdef TCP_WINDOW_CLAMP - PyModule_AddIntConstant(m, "TCP_WINDOW_CLAMP", TCP_WINDOW_CLAMP); -#endif -#ifdef TCP_INFO - PyModule_AddIntConstant(m, "TCP_INFO", TCP_INFO); -#endif -#ifdef TCP_QUICKACK - PyModule_AddIntConstant(m, "TCP_QUICKACK", TCP_QUICKACK); -#endif - - - /* IPX options */ -#ifdef IPX_TYPE - PyModule_AddIntConstant(m, "IPX_TYPE", IPX_TYPE); -#endif - - /* get{addr,name}info parameters */ -#ifdef EAI_ADDRFAMILY - PyModule_AddIntConstant(m, "EAI_ADDRFAMILY", EAI_ADDRFAMILY); -#endif -#ifdef EAI_AGAIN - PyModule_AddIntConstant(m, "EAI_AGAIN", EAI_AGAIN); -#endif -#ifdef EAI_BADFLAGS - PyModule_AddIntConstant(m, "EAI_BADFLAGS", EAI_BADFLAGS); -#endif -#ifdef EAI_FAIL - PyModule_AddIntConstant(m, "EAI_FAIL", EAI_FAIL); -#endif -#ifdef EAI_FAMILY - PyModule_AddIntConstant(m, "EAI_FAMILY", EAI_FAMILY); -#endif -#ifdef EAI_MEMORY - PyModule_AddIntConstant(m, "EAI_MEMORY", EAI_MEMORY); -#endif -#ifdef EAI_NODATA - PyModule_AddIntConstant(m, "EAI_NODATA", EAI_NODATA); -#endif -#ifdef EAI_NONAME - PyModule_AddIntConstant(m, "EAI_NONAME", EAI_NONAME); -#endif -#ifdef EAI_SERVICE - PyModule_AddIntConstant(m, "EAI_SERVICE", EAI_SERVICE); -#endif -#ifdef EAI_SOCKTYPE - PyModule_AddIntConstant(m, "EAI_SOCKTYPE", EAI_SOCKTYPE); -#endif -#ifdef EAI_SYSTEM - PyModule_AddIntConstant(m, "EAI_SYSTEM", EAI_SYSTEM); -#endif -#ifdef EAI_BADHINTS - PyModule_AddIntConstant(m, "EAI_BADHINTS", EAI_BADHINTS); -#endif -#ifdef EAI_PROTOCOL - PyModule_AddIntConstant(m, "EAI_PROTOCOL", EAI_PROTOCOL); -#endif -#ifdef EAI_MAX - PyModule_AddIntConstant(m, "EAI_MAX", EAI_MAX); -#endif -#ifdef AI_PASSIVE - PyModule_AddIntConstant(m, "AI_PASSIVE", AI_PASSIVE); -#endif -#ifdef AI_CANONNAME - PyModule_AddIntConstant(m, "AI_CANONNAME", AI_CANONNAME); -#endif -#ifdef AI_NUMERICHOST - PyModule_AddIntConstant(m, "AI_NUMERICHOST", AI_NUMERICHOST); -#endif -#ifdef AI_MASK - PyModule_AddIntConstant(m, "AI_MASK", AI_MASK); -#endif -#ifdef AI_ALL - PyModule_AddIntConstant(m, "AI_ALL", AI_ALL); -#endif -#ifdef AI_V4MAPPED_CFG - PyModule_AddIntConstant(m, "AI_V4MAPPED_CFG", AI_V4MAPPED_CFG); -#endif -#ifdef AI_ADDRCONFIG - PyModule_AddIntConstant(m, "AI_ADDRCONFIG", AI_ADDRCONFIG); -#endif -#ifdef AI_V4MAPPED - PyModule_AddIntConstant(m, "AI_V4MAPPED", AI_V4MAPPED); -#endif -#ifdef AI_DEFAULT - PyModule_AddIntConstant(m, "AI_DEFAULT", AI_DEFAULT); -#endif -#ifdef NI_MAXHOST - PyModule_AddIntConstant(m, "NI_MAXHOST", NI_MAXHOST); -#endif -#ifdef NI_MAXSERV - PyModule_AddIntConstant(m, "NI_MAXSERV", NI_MAXSERV); -#endif -#ifdef NI_NOFQDN - PyModule_AddIntConstant(m, "NI_NOFQDN", NI_NOFQDN); -#endif -#ifdef NI_NUMERICHOST - PyModule_AddIntConstant(m, "NI_NUMERICHOST", NI_NUMERICHOST); -#endif -#ifdef NI_NAMEREQD - PyModule_AddIntConstant(m, "NI_NAMEREQD", NI_NAMEREQD); -#endif -#ifdef NI_NUMERICSERV - PyModule_AddIntConstant(m, "NI_NUMERICSERV", NI_NUMERICSERV); -#endif -#ifdef NI_DGRAM - PyModule_AddIntConstant(m, "NI_DGRAM", NI_DGRAM); -#endif - - /* Initialize gethostbyname lock */ -#if defined(USE_GETHOSTBYNAME_LOCK) || defined(USE_GETADDRINFO_LOCK) - netdb_lock = PyThread_allocate_lock(); -#endif -} - - -#ifndef HAVE_INET_PTON - -/* Simplistic emulation code for inet_pton that only works for IPv4 */ -/* These are not exposed because they do not set errno properly */ - -int -inet_pton(int af, const char *src, void *dst) -{ - if (af == AF_INET) { - long packed_addr; - packed_addr = inet_addr(src); - if (packed_addr == INADDR_NONE) - return 0; - memcpy(dst, &packed_addr, 4); - return 1; - } - /* Should set errno to EAFNOSUPPORT */ - return -1; -} - -const char * -inet_ntop(int af, const void *src, char *dst, socklen_t size) -{ - if (af == AF_INET) { - struct in_addr packed_addr; - if (size < 16) - /* Should set errno to ENOSPC. */ - return NULL; - memcpy(&packed_addr, src, sizeof(packed_addr)); - return strncpy(dst, inet_ntoa(packed_addr), size); - } - /* Should set errno to EAFNOSUPPORT */ - return NULL; -} - -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/socketmodule.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/socketmodule.h deleted file mode 100644 index cedc8da7..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/socketmodule.h +++ /dev/null @@ -1,221 +0,0 @@ -/* Socket module header file */ - -/* Includes needed for the sockaddr_* symbols below */ -#ifndef MS_WINDOWS -#ifdef __VMS -# include -# else -# include -# endif -# include -# if !(defined(__BEOS__) || defined(__CYGWIN__) || (defined(PYOS_OS2) && defined(PYCC_VACPP))) -# include -# endif - -#else /* MS_WINDOWS */ -#if _MSC_VER >= 1300 -# include -# include -# define HAVE_ADDRINFO -# define HAVE_SOCKADDR_STORAGE -# define HAVE_GETADDRINFO -# define HAVE_GETNAMEINFO -# define ENABLE_IPV6 -#else -# include -#endif -#endif - -#ifdef HAVE_SYS_UN_H -# include -#else -# undef AF_UNIX -#endif - -#ifdef HAVE_NETPACKET_PACKET_H -# include -# include -# include -#endif - -#ifndef Py__SOCKET_H -#define Py__SOCKET_H -#ifdef __cplusplus -extern "C" { -#endif - -/* Python module and C API name */ -#define PySocket_MODULE_NAME "_socket" -#define PySocket_CAPI_NAME "CAPI" - -/* Abstract the socket file descriptor type */ -#ifdef MS_WINDOWS -typedef SOCKET SOCKET_T; -# ifdef MS_WIN64 -# define SIZEOF_SOCKET_T 8 -# else -# define SIZEOF_SOCKET_T 4 -# endif -#else -typedef int SOCKET_T; -# define SIZEOF_SOCKET_T SIZEOF_INT -#endif - -/* The object holding a socket. It holds some extra information, - like the address family, which is used to decode socket address - arguments properly. */ - -typedef struct { - PyObject_HEAD - SOCKET_T sock_fd; /* Socket file descriptor */ - int sock_family; /* Address family, e.g., AF_INET */ - int sock_type; /* Socket type, e.g., SOCK_STREAM */ - int sock_proto; /* Protocol type, usually 0 */ - union sock_addr { - struct sockaddr_in in; -#ifdef AF_UNIX - struct sockaddr_un un; -#endif -#ifdef ENABLE_IPV6 - struct sockaddr_in6 in6; - struct sockaddr_storage storage; -#endif -#ifdef HAVE_NETPACKET_PACKET_H - struct sockaddr_ll ll; -#endif - } sock_addr; - PyObject *(*errorhandler)(void); /* Error handler; checks - errno, returns NULL and - sets a Python exception */ - double sock_timeout; /* Operation timeout in seconds; - 0.0 means non-blocking */ -} PySocketSockObject; - -/* --- C API ----------------------------------------------------*/ - -/* Short explanation of what this C API export mechanism does - and how it works: - - The _ssl module needs access to the type object defined in - the _socket module. Since cross-DLL linking introduces a lot of - problems on many platforms, the "trick" is to wrap the - C API of a module in a struct which then gets exported to - other modules via a PyCObject. - - The code in socketmodule.c defines this struct (which currently - only contains the type object reference, but could very - well also include other C APIs needed by other modules) - and exports it as PyCObject via the module dictionary - under the name "CAPI". - - Other modules can now include the socketmodule.h file - which defines the needed C APIs to import and set up - a static copy of this struct in the importing module. - - After initialization, the importing module can then - access the C APIs from the _socket module by simply - referring to the static struct, e.g. - - Load _socket module and its C API; this sets up the global - PySocketModule: - - if (PySocketModule_ImportModuleAndAPI()) - return; - - - Now use the C API as if it were defined in the using - module: - - if (!PyArg_ParseTuple(args, "O!|zz:ssl", - - PySocketModule.Sock_Type, - - (PyObject*)&Sock, - &key_file, &cert_file)) - return NULL; - - Support could easily be extended to export more C APIs/symbols - this way. Currently, only the type object is exported, - other candidates would be socket constructors and socket - access functions. - -*/ - -/* C API for usage by other Python modules */ -typedef struct { - PyTypeObject *Sock_Type; -} PySocketModule_APIObject; - -/* XXX The net effect of the following appears to be to define a function - XXX named PySocketModule_APIObject in _ssl.c. It's unclear why it isn't - XXX defined there directly. - - >>> It's defined here because other modules might also want to use - >>> the C API. - -*/ -#ifndef PySocket_BUILDING_SOCKET - -/* --- C API ----------------------------------------------------*/ - -/* Interfacestructure to C API for other modules. - Call PySocketModule_ImportModuleAndAPI() to initialize this - structure. After that usage is simple: - - if (!PyArg_ParseTuple(args, "O!|zz:ssl", - &PySocketModule.Sock_Type, (PyObject*)&Sock, - &key_file, &cert_file)) - return NULL; - ... -*/ - -static -PySocketModule_APIObject PySocketModule; - -/* You *must* call this before using any of the functions in - PySocketModule and check its outcome; otherwise all accesses will - result in a segfault. Returns 0 on success. */ - -#ifndef DPRINTF -# define DPRINTF if (0) printf -#endif - -static -int PySocketModule_ImportModuleAndAPI(void) -{ - PyObject *mod = 0, *v = 0; - char *apimodule = PySocket_MODULE_NAME; - char *apiname = PySocket_CAPI_NAME; - void *api; - - DPRINTF("Importing the %s C API...\n", apimodule); - mod = PyImport_ImportModule(apimodule); - if (mod == NULL) - goto onError; - DPRINTF(" %s package found\n", apimodule); - v = PyObject_GetAttrString(mod, apiname); - if (v == NULL) - goto onError; - Py_DECREF(mod); - DPRINTF(" API object %s found\n", apiname); - api = PyCObject_AsVoidPtr(v); - if (api == NULL) - goto onError; - Py_DECREF(v); - memcpy(&PySocketModule, api, sizeof(PySocketModule)); - DPRINTF(" API object loaded and initialized.\n"); - return 0; - - onError: - DPRINTF(" not found.\n"); - Py_XDECREF(mod); - Py_XDECREF(v); - return -1; -} - -#endif /* !PySocket_BUILDING_SOCKET */ - -#ifdef __cplusplus -} -#endif -#endif /* !Py__SOCKET_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/sre.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/sre.h deleted file mode 100644 index 61fb0f8f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/sre.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Secret Labs' Regular Expression Engine - * - * regular expression matching engine - * - * Copyright (c) 1997-2001 by Secret Labs AB. All rights reserved. - * - * See the _sre.c file for information on usage and redistribution. - */ - -#ifndef SRE_INCLUDED -#define SRE_INCLUDED - -#include "sre_constants.h" - -/* size of a code word (must be unsigned short or larger, and - large enough to hold a Py_UNICODE character) */ -#ifdef Py_UNICODE_WIDE -#define SRE_CODE unsigned long -#else -#define SRE_CODE unsigned short -#endif - -typedef struct { - PyObject_VAR_HEAD - int groups; /* must be first! */ - PyObject* groupindex; - PyObject* indexgroup; - /* compatibility */ - PyObject* pattern; /* pattern source (or None) */ - int flags; /* flags used when compiling pattern source */ - /* pattern code */ - int codesize; - SRE_CODE code[1]; -} PatternObject; - -#define PatternObject_GetCode(o) (((PatternObject*)(o))->code) - -typedef struct { - PyObject_VAR_HEAD - PyObject* string; /* link to the target string (must be first) */ - PyObject* regs; /* cached list of matching spans */ - PatternObject* pattern; /* link to the regex (pattern) object */ - int pos, endpos; /* current target slice */ - int lastindex; /* last index marker seen by the engine (-1 if none) */ - int groups; /* number of groups (start/end marks) */ - int mark[1]; -} MatchObject; - -typedef unsigned int (*SRE_TOLOWER_HOOK)(unsigned int ch); - -/* FIXME: shouldn't be a constant, really... */ -#define SRE_MARK_SIZE 200 - -typedef struct SRE_REPEAT_T { - int count; - SRE_CODE* pattern; /* points to REPEAT operator arguments */ - struct SRE_REPEAT_T *prev; /* points to previous repeat context */ -} SRE_REPEAT; - -typedef struct { - /* string pointers */ - void* ptr; /* current position (also end of current slice) */ - void* beginning; /* start of original string */ - void* start; /* start of current slice */ - void* end; /* end of original string */ - /* attributes for the match object */ - PyObject* string; - int pos, endpos; - /* character size */ - int charsize; - /* registers */ - int lastindex; - int lastmark; - void* mark[SRE_MARK_SIZE]; - /* dynamically allocated stuff */ - void** mark_stack; - int mark_stack_size; - int mark_stack_base; - SRE_REPEAT *repeat; /* current repeat context */ - /* hooks */ - SRE_TOLOWER_HOOK lower; -} SRE_STATE; - -typedef struct { - PyObject_HEAD - PyObject* pattern; - SRE_STATE state; -} ScannerObject; - -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/sre_constants.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/sre_constants.h deleted file mode 100644 index 0959abe3..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/sre_constants.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Secret Labs' Regular Expression Engine - * - * regular expression matching engine - * - * NOTE: This file is generated by sre_constants.py. If you need - * to change anything in here, edit sre_constants.py and run it. - * - * Copyright (c) 1997-2001 by Secret Labs AB. All rights reserved. - * - * See the _sre.c file for information on usage and redistribution. - */ - -#define SRE_MAGIC 20030419 -#define SRE_OP_FAILURE 0 -#define SRE_OP_SUCCESS 1 -#define SRE_OP_ANY 2 -#define SRE_OP_ANY_ALL 3 -#define SRE_OP_ASSERT 4 -#define SRE_OP_ASSERT_NOT 5 -#define SRE_OP_AT 6 -#define SRE_OP_BRANCH 7 -#define SRE_OP_CALL 8 -#define SRE_OP_CATEGORY 9 -#define SRE_OP_CHARSET 10 -#define SRE_OP_BIGCHARSET 11 -#define SRE_OP_GROUPREF 12 -#define SRE_OP_GROUPREF_IGNORE 13 -#define SRE_OP_IN 14 -#define SRE_OP_IN_IGNORE 15 -#define SRE_OP_INFO 16 -#define SRE_OP_JUMP 17 -#define SRE_OP_LITERAL 18 -#define SRE_OP_LITERAL_IGNORE 19 -#define SRE_OP_MARK 20 -#define SRE_OP_MAX_UNTIL 21 -#define SRE_OP_MIN_UNTIL 22 -#define SRE_OP_NOT_LITERAL 23 -#define SRE_OP_NOT_LITERAL_IGNORE 24 -#define SRE_OP_NEGATE 25 -#define SRE_OP_RANGE 26 -#define SRE_OP_REPEAT 27 -#define SRE_OP_REPEAT_ONE 28 -#define SRE_OP_SUBPATTERN 29 -#define SRE_OP_MIN_REPEAT_ONE 30 -#define SRE_AT_BEGINNING 0 -#define SRE_AT_BEGINNING_LINE 1 -#define SRE_AT_BEGINNING_STRING 2 -#define SRE_AT_BOUNDARY 3 -#define SRE_AT_NON_BOUNDARY 4 -#define SRE_AT_END 5 -#define SRE_AT_END_LINE 6 -#define SRE_AT_END_STRING 7 -#define SRE_AT_LOC_BOUNDARY 8 -#define SRE_AT_LOC_NON_BOUNDARY 9 -#define SRE_AT_UNI_BOUNDARY 10 -#define SRE_AT_UNI_NON_BOUNDARY 11 -#define SRE_CATEGORY_DIGIT 0 -#define SRE_CATEGORY_NOT_DIGIT 1 -#define SRE_CATEGORY_SPACE 2 -#define SRE_CATEGORY_NOT_SPACE 3 -#define SRE_CATEGORY_WORD 4 -#define SRE_CATEGORY_NOT_WORD 5 -#define SRE_CATEGORY_LINEBREAK 6 -#define SRE_CATEGORY_NOT_LINEBREAK 7 -#define SRE_CATEGORY_LOC_WORD 8 -#define SRE_CATEGORY_LOC_NOT_WORD 9 -#define SRE_CATEGORY_UNI_DIGIT 10 -#define SRE_CATEGORY_UNI_NOT_DIGIT 11 -#define SRE_CATEGORY_UNI_SPACE 12 -#define SRE_CATEGORY_UNI_NOT_SPACE 13 -#define SRE_CATEGORY_UNI_WORD 14 -#define SRE_CATEGORY_UNI_NOT_WORD 15 -#define SRE_CATEGORY_UNI_LINEBREAK 16 -#define SRE_CATEGORY_UNI_NOT_LINEBREAK 17 -#define SRE_FLAG_TEMPLATE 1 -#define SRE_FLAG_IGNORECASE 2 -#define SRE_FLAG_LOCALE 4 -#define SRE_FLAG_MULTILINE 8 -#define SRE_FLAG_DOTALL 16 -#define SRE_FLAG_UNICODE 32 -#define SRE_FLAG_VERBOSE 64 -#define SRE_INFO_PREFIX 1 -#define SRE_INFO_LITERAL 2 -#define SRE_INFO_CHARSET 4 diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/stropmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/stropmodule.c deleted file mode 100644 index 2e74c5c5..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/stropmodule.c +++ /dev/null @@ -1,1244 +0,0 @@ -/* strop module */ - -#include "Python.h" -#include - -PyDoc_STRVAR(strop_module__doc__, -"Common string manipulations, optimized for speed.\n" -"\n" -"Always use \"import string\" rather than referencing\n" -"this module directly."); - -/* XXX This file assumes that the is*() functions - XXX are defined for all 8-bit characters! */ - -#define WARN if (PyErr_Warn(PyExc_DeprecationWarning, \ - "strop functions are obsolete; use string methods")) \ - return NULL - -/* The lstrip(), rstrip() and strip() functions are implemented - in do_strip(), which uses an additional parameter to indicate what - type of strip should occur. */ - -#define LEFTSTRIP 0 -#define RIGHTSTRIP 1 -#define BOTHSTRIP 2 - - -static PyObject * -split_whitespace(char *s, int len, int maxsplit) -{ - int i = 0, j, err; - int countsplit = 0; - PyObject* item; - PyObject *list = PyList_New(0); - - if (list == NULL) - return NULL; - - while (i < len) { - while (i < len && isspace(Py_CHARMASK(s[i]))) { - i = i+1; - } - j = i; - while (i < len && !isspace(Py_CHARMASK(s[i]))) { - i = i+1; - } - if (j < i) { - item = PyString_FromStringAndSize(s+j, (int)(i-j)); - if (item == NULL) - goto finally; - - err = PyList_Append(list, item); - Py_DECREF(item); - if (err < 0) - goto finally; - - countsplit++; - while (i < len && isspace(Py_CHARMASK(s[i]))) { - i = i+1; - } - if (maxsplit && (countsplit >= maxsplit) && i < len) { - item = PyString_FromStringAndSize( - s+i, (int)(len - i)); - if (item == NULL) - goto finally; - - err = PyList_Append(list, item); - Py_DECREF(item); - if (err < 0) - goto finally; - - i = len; - } - } - } - return list; - finally: - Py_DECREF(list); - return NULL; -} - - -PyDoc_STRVAR(splitfields__doc__, -"split(s [,sep [,maxsplit]]) -> list of strings\n" -"splitfields(s [,sep [,maxsplit]]) -> list of strings\n" -"\n" -"Return a list of the words in the string s, using sep as the\n" -"delimiter string. If maxsplit is nonzero, splits into at most\n" -"maxsplit words. If sep is not specified, any whitespace string\n" -"is a separator. Maxsplit defaults to 0.\n" -"\n" -"(split and splitfields are synonymous)"); - -static PyObject * -strop_splitfields(PyObject *self, PyObject *args) -{ - int len, n, i, j, err; - int splitcount, maxsplit; - char *s, *sub; - PyObject *list, *item; - - WARN; - sub = NULL; - n = 0; - splitcount = 0; - maxsplit = 0; - if (!PyArg_ParseTuple(args, "t#|z#i:split", &s, &len, &sub, &n, &maxsplit)) - return NULL; - if (sub == NULL) - return split_whitespace(s, len, maxsplit); - if (n == 0) { - PyErr_SetString(PyExc_ValueError, "empty separator"); - return NULL; - } - - list = PyList_New(0); - if (list == NULL) - return NULL; - - i = j = 0; - while (i+n <= len) { - if (s[i] == sub[0] && (n == 1 || memcmp(s+i, sub, n) == 0)) { - item = PyString_FromStringAndSize(s+j, (int)(i-j)); - if (item == NULL) - goto fail; - err = PyList_Append(list, item); - Py_DECREF(item); - if (err < 0) - goto fail; - i = j = i + n; - splitcount++; - if (maxsplit && (splitcount >= maxsplit)) - break; - } - else - i++; - } - item = PyString_FromStringAndSize(s+j, (int)(len-j)); - if (item == NULL) - goto fail; - err = PyList_Append(list, item); - Py_DECREF(item); - if (err < 0) - goto fail; - - return list; - - fail: - Py_DECREF(list); - return NULL; -} - - -PyDoc_STRVAR(joinfields__doc__, -"join(list [,sep]) -> string\n" -"joinfields(list [,sep]) -> string\n" -"\n" -"Return a string composed of the words in list, with\n" -"intervening occurrences of sep. Sep defaults to a single\n" -"space.\n" -"\n" -"(join and joinfields are synonymous)"); - -static PyObject * -strop_joinfields(PyObject *self, PyObject *args) -{ - PyObject *seq; - char *sep = NULL; - int seqlen, seplen = 0; - int i, reslen = 0, slen = 0, sz = 100; - PyObject *res = NULL; - char* p = NULL; - intargfunc getitemfunc; - - WARN; - if (!PyArg_ParseTuple(args, "O|t#:join", &seq, &sep, &seplen)) - return NULL; - if (sep == NULL) { - sep = " "; - seplen = 1; - } - - seqlen = PySequence_Size(seq); - if (seqlen < 0 && PyErr_Occurred()) - return NULL; - - if (seqlen == 1) { - /* Optimization if there's only one item */ - PyObject *item = PySequence_GetItem(seq, 0); - if (item && !PyString_Check(item)) { - PyErr_SetString(PyExc_TypeError, - "first argument must be sequence of strings"); - Py_DECREF(item); - return NULL; - } - return item; - } - - if (!(res = PyString_FromStringAndSize((char*)NULL, sz))) - return NULL; - p = PyString_AsString(res); - - /* optimize for lists, since it's the most common case. all others - * (tuples and arbitrary sequences) just use the sequence abstract - * interface. - */ - if (PyList_Check(seq)) { - for (i = 0; i < seqlen; i++) { - PyObject *item = PyList_GET_ITEM(seq, i); - if (!PyString_Check(item)) { - PyErr_SetString(PyExc_TypeError, - "first argument must be sequence of strings"); - Py_DECREF(res); - return NULL; - } - slen = PyString_GET_SIZE(item); - while (reslen + slen + seplen >= sz) { - if (_PyString_Resize(&res, sz * 2) < 0) - return NULL; - sz *= 2; - p = PyString_AsString(res) + reslen; - } - if (i > 0) { - memcpy(p, sep, seplen); - p += seplen; - reslen += seplen; - } - memcpy(p, PyString_AS_STRING(item), slen); - p += slen; - reslen += slen; - } - _PyString_Resize(&res, reslen); - return res; - } - - if (seq->ob_type->tp_as_sequence == NULL || - (getitemfunc = seq->ob_type->tp_as_sequence->sq_item) == NULL) - { - PyErr_SetString(PyExc_TypeError, - "first argument must be a sequence"); - return NULL; - } - /* This is now type safe */ - for (i = 0; i < seqlen; i++) { - PyObject *item = getitemfunc(seq, i); - if (!item || !PyString_Check(item)) { - PyErr_SetString(PyExc_TypeError, - "first argument must be sequence of strings"); - Py_DECREF(res); - Py_XDECREF(item); - return NULL; - } - slen = PyString_GET_SIZE(item); - while (reslen + slen + seplen >= sz) { - if (_PyString_Resize(&res, sz * 2) < 0) { - Py_DECREF(item); - return NULL; - } - sz *= 2; - p = PyString_AsString(res) + reslen; - } - if (i > 0) { - memcpy(p, sep, seplen); - p += seplen; - reslen += seplen; - } - memcpy(p, PyString_AS_STRING(item), slen); - p += slen; - reslen += slen; - Py_DECREF(item); - } - _PyString_Resize(&res, reslen); - return res; -} - - -PyDoc_STRVAR(find__doc__, -"find(s, sub [,start [,end]]) -> in\n" -"\n" -"Return the lowest index in s where substring sub is found,\n" -"such that sub is contained within s[start,end]. Optional\n" -"arguments start and end are interpreted as in slice notation.\n" -"\n" -"Return -1 on failure."); - -static PyObject * -strop_find(PyObject *self, PyObject *args) -{ - char *s, *sub; - int len, n, i = 0, last = INT_MAX; - - WARN; - if (!PyArg_ParseTuple(args, "t#t#|ii:find", &s, &len, &sub, &n, &i, &last)) - return NULL; - - if (last > len) - last = len; - if (last < 0) - last += len; - if (last < 0) - last = 0; - if (i < 0) - i += len; - if (i < 0) - i = 0; - - if (n == 0 && i <= last) - return PyInt_FromLong((long)i); - - last -= n; - for (; i <= last; ++i) - if (s[i] == sub[0] && - (n == 1 || memcmp(&s[i+1], &sub[1], n-1) == 0)) - return PyInt_FromLong((long)i); - - return PyInt_FromLong(-1L); -} - - -PyDoc_STRVAR(rfind__doc__, -"rfind(s, sub [,start [,end]]) -> int\n" -"\n" -"Return the highest index in s where substring sub is found,\n" -"such that sub is contained within s[start,end]. Optional\n" -"arguments start and end are interpreted as in slice notation.\n" -"\n" -"Return -1 on failure."); - -static PyObject * -strop_rfind(PyObject *self, PyObject *args) -{ - char *s, *sub; - int len, n, j; - int i = 0, last = INT_MAX; - - WARN; - if (!PyArg_ParseTuple(args, "t#t#|ii:rfind", &s, &len, &sub, &n, &i, &last)) - return NULL; - - if (last > len) - last = len; - if (last < 0) - last += len; - if (last < 0) - last = 0; - if (i < 0) - i += len; - if (i < 0) - i = 0; - - if (n == 0 && i <= last) - return PyInt_FromLong((long)last); - - for (j = last-n; j >= i; --j) - if (s[j] == sub[0] && - (n == 1 || memcmp(&s[j+1], &sub[1], n-1) == 0)) - return PyInt_FromLong((long)j); - - return PyInt_FromLong(-1L); -} - - -static PyObject * -do_strip(PyObject *args, int striptype) -{ - char *s; - int len, i, j; - - - if (PyString_AsStringAndSize(args, &s, &len)) - return NULL; - - i = 0; - if (striptype != RIGHTSTRIP) { - while (i < len && isspace(Py_CHARMASK(s[i]))) { - i++; - } - } - - j = len; - if (striptype != LEFTSTRIP) { - do { - j--; - } while (j >= i && isspace(Py_CHARMASK(s[j]))); - j++; - } - - if (i == 0 && j == len) { - Py_INCREF(args); - return args; - } - else - return PyString_FromStringAndSize(s+i, j-i); -} - - -PyDoc_STRVAR(strip__doc__, -"strip(s) -> string\n" -"\n" -"Return a copy of the string s with leading and trailing\n" -"whitespace removed."); - -static PyObject * -strop_strip(PyObject *self, PyObject *args) -{ - WARN; - return do_strip(args, BOTHSTRIP); -} - - -PyDoc_STRVAR(lstrip__doc__, -"lstrip(s) -> string\n" -"\n" -"Return a copy of the string s with leading whitespace removed."); - -static PyObject * -strop_lstrip(PyObject *self, PyObject *args) -{ - WARN; - return do_strip(args, LEFTSTRIP); -} - - -PyDoc_STRVAR(rstrip__doc__, -"rstrip(s) -> string\n" -"\n" -"Return a copy of the string s with trailing whitespace removed."); - -static PyObject * -strop_rstrip(PyObject *self, PyObject *args) -{ - WARN; - return do_strip(args, RIGHTSTRIP); -} - - -PyDoc_STRVAR(lower__doc__, -"lower(s) -> string\n" -"\n" -"Return a copy of the string s converted to lowercase."); - -static PyObject * -strop_lower(PyObject *self, PyObject *args) -{ - char *s, *s_new; - int i, n; - PyObject *new; - int changed; - - WARN; - if (PyString_AsStringAndSize(args, &s, &n)) - return NULL; - new = PyString_FromStringAndSize(NULL, n); - if (new == NULL) - return NULL; - s_new = PyString_AsString(new); - changed = 0; - for (i = 0; i < n; i++) { - int c = Py_CHARMASK(*s++); - if (isupper(c)) { - changed = 1; - *s_new = tolower(c); - } else - *s_new = c; - s_new++; - } - if (!changed) { - Py_DECREF(new); - Py_INCREF(args); - return args; - } - return new; -} - - -PyDoc_STRVAR(upper__doc__, -"upper(s) -> string\n" -"\n" -"Return a copy of the string s converted to uppercase."); - -static PyObject * -strop_upper(PyObject *self, PyObject *args) -{ - char *s, *s_new; - int i, n; - PyObject *new; - int changed; - - WARN; - if (PyString_AsStringAndSize(args, &s, &n)) - return NULL; - new = PyString_FromStringAndSize(NULL, n); - if (new == NULL) - return NULL; - s_new = PyString_AsString(new); - changed = 0; - for (i = 0; i < n; i++) { - int c = Py_CHARMASK(*s++); - if (islower(c)) { - changed = 1; - *s_new = toupper(c); - } else - *s_new = c; - s_new++; - } - if (!changed) { - Py_DECREF(new); - Py_INCREF(args); - return args; - } - return new; -} - - -PyDoc_STRVAR(capitalize__doc__, -"capitalize(s) -> string\n" -"\n" -"Return a copy of the string s with only its first character\n" -"capitalized."); - -static PyObject * -strop_capitalize(PyObject *self, PyObject *args) -{ - char *s, *s_new; - int i, n; - PyObject *new; - int changed; - - WARN; - if (PyString_AsStringAndSize(args, &s, &n)) - return NULL; - new = PyString_FromStringAndSize(NULL, n); - if (new == NULL) - return NULL; - s_new = PyString_AsString(new); - changed = 0; - if (0 < n) { - int c = Py_CHARMASK(*s++); - if (islower(c)) { - changed = 1; - *s_new = toupper(c); - } else - *s_new = c; - s_new++; - } - for (i = 1; i < n; i++) { - int c = Py_CHARMASK(*s++); - if (isupper(c)) { - changed = 1; - *s_new = tolower(c); - } else - *s_new = c; - s_new++; - } - if (!changed) { - Py_DECREF(new); - Py_INCREF(args); - return args; - } - return new; -} - - -PyDoc_STRVAR(expandtabs__doc__, -"expandtabs(string, [tabsize]) -> string\n" -"\n" -"Expand tabs in a string, i.e. replace them by one or more spaces,\n" -"depending on the current column and the given tab size (default 8).\n" -"The column number is reset to zero after each newline occurring in the\n" -"string. This doesn't understand other non-printing characters."); - -static PyObject * -strop_expandtabs(PyObject *self, PyObject *args) -{ - /* Original by Fredrik Lundh */ - char* e; - char* p; - char* q; - int i, j; - PyObject* out; - char* string; - int stringlen; - int tabsize = 8; - - WARN; - /* Get arguments */ - if (!PyArg_ParseTuple(args, "s#|i:expandtabs", &string, &stringlen, &tabsize)) - return NULL; - if (tabsize < 1) { - PyErr_SetString(PyExc_ValueError, - "tabsize must be at least 1"); - return NULL; - } - - /* First pass: determine size of output string */ - i = j = 0; /* j: current column; i: total of previous lines */ - e = string + stringlen; - for (p = string; p < e; p++) { - if (*p == '\t') - j += tabsize - (j%tabsize); - else { - j++; - if (*p == '\n') { - i += j; - j = 0; - } - } - } - - /* Second pass: create output string and fill it */ - out = PyString_FromStringAndSize(NULL, i+j); - if (out == NULL) - return NULL; - - i = 0; - q = PyString_AS_STRING(out); - - for (p = string; p < e; p++) { - if (*p == '\t') { - j = tabsize - (i%tabsize); - i += j; - while (j-- > 0) - *q++ = ' '; - } else { - *q++ = *p; - i++; - if (*p == '\n') - i = 0; - } - } - - return out; -} - - -PyDoc_STRVAR(count__doc__, -"count(s, sub[, start[, end]]) -> int\n" -"\n" -"Return the number of occurrences of substring sub in string\n" -"s[start:end]. Optional arguments start and end are\n" -"interpreted as in slice notation."); - -static PyObject * -strop_count(PyObject *self, PyObject *args) -{ - char *s, *sub; - int len, n; - int i = 0, last = INT_MAX; - int m, r; - - WARN; - if (!PyArg_ParseTuple(args, "t#t#|ii:count", &s, &len, &sub, &n, &i, &last)) - return NULL; - if (last > len) - last = len; - if (last < 0) - last += len; - if (last < 0) - last = 0; - if (i < 0) - i += len; - if (i < 0) - i = 0; - m = last + 1 - n; - if (n == 0) - return PyInt_FromLong((long) (m-i)); - - r = 0; - while (i < m) { - if (!memcmp(s+i, sub, n)) { - r++; - i += n; - } else { - i++; - } - } - return PyInt_FromLong((long) r); -} - - -PyDoc_STRVAR(swapcase__doc__, -"swapcase(s) -> string\n" -"\n" -"Return a copy of the string s with upper case characters\n" -"converted to lowercase and vice versa."); - -static PyObject * -strop_swapcase(PyObject *self, PyObject *args) -{ - char *s, *s_new; - int i, n; - PyObject *new; - int changed; - - WARN; - if (PyString_AsStringAndSize(args, &s, &n)) - return NULL; - new = PyString_FromStringAndSize(NULL, n); - if (new == NULL) - return NULL; - s_new = PyString_AsString(new); - changed = 0; - for (i = 0; i < n; i++) { - int c = Py_CHARMASK(*s++); - if (islower(c)) { - changed = 1; - *s_new = toupper(c); - } - else if (isupper(c)) { - changed = 1; - *s_new = tolower(c); - } - else - *s_new = c; - s_new++; - } - if (!changed) { - Py_DECREF(new); - Py_INCREF(args); - return args; - } - return new; -} - - -PyDoc_STRVAR(atoi__doc__, -"atoi(s [,base]) -> int\n" -"\n" -"Return the integer represented by the string s in the given\n" -"base, which defaults to 10. The string s must consist of one\n" -"or more digits, possibly preceded by a sign. If base is 0, it\n" -"is chosen from the leading characters of s, 0 for octal, 0x or\n" -"0X for hexadecimal. If base is 16, a preceding 0x or 0X is\n" -"accepted."); - -static PyObject * -strop_atoi(PyObject *self, PyObject *args) -{ - char *s, *end; - int base = 10; - long x; - char buffer[256]; /* For errors */ - - WARN; - if (!PyArg_ParseTuple(args, "s|i:atoi", &s, &base)) - return NULL; - - if ((base != 0 && base < 2) || base > 36) { - PyErr_SetString(PyExc_ValueError, "invalid base for atoi()"); - return NULL; - } - - while (*s && isspace(Py_CHARMASK(*s))) - s++; - errno = 0; - if (base == 0 && s[0] == '0') - x = (long) PyOS_strtoul(s, &end, base); - else - x = PyOS_strtol(s, &end, base); - if (end == s || !isalnum((int)end[-1])) - goto bad; - while (*end && isspace(Py_CHARMASK(*end))) - end++; - if (*end != '\0') { - bad: - PyOS_snprintf(buffer, sizeof(buffer), - "invalid literal for atoi(): %.200s", s); - PyErr_SetString(PyExc_ValueError, buffer); - return NULL; - } - else if (errno != 0) { - PyOS_snprintf(buffer, sizeof(buffer), - "atoi() literal too large: %.200s", s); - PyErr_SetString(PyExc_ValueError, buffer); - return NULL; - } - return PyInt_FromLong(x); -} - - -PyDoc_STRVAR(atol__doc__, -"atol(s [,base]) -> long\n" -"\n" -"Return the long integer represented by the string s in the\n" -"given base, which defaults to 10. The string s must consist\n" -"of one or more digits, possibly preceded by a sign. If base\n" -"is 0, it is chosen from the leading characters of s, 0 for\n" -"octal, 0x or 0X for hexadecimal. If base is 16, a preceding\n" -"0x or 0X is accepted. A trailing L or l is not accepted,\n" -"unless base is 0."); - -static PyObject * -strop_atol(PyObject *self, PyObject *args) -{ - char *s, *end; - int base = 10; - PyObject *x; - char buffer[256]; /* For errors */ - - WARN; - if (!PyArg_ParseTuple(args, "s|i:atol", &s, &base)) - return NULL; - - if ((base != 0 && base < 2) || base > 36) { - PyErr_SetString(PyExc_ValueError, "invalid base for atol()"); - return NULL; - } - - while (*s && isspace(Py_CHARMASK(*s))) - s++; - if (s[0] == '\0') { - PyErr_SetString(PyExc_ValueError, "empty string for atol()"); - return NULL; - } - x = PyLong_FromString(s, &end, base); - if (x == NULL) - return NULL; - if (base == 0 && (*end == 'l' || *end == 'L')) - end++; - while (*end && isspace(Py_CHARMASK(*end))) - end++; - if (*end != '\0') { - PyOS_snprintf(buffer, sizeof(buffer), - "invalid literal for atol(): %.200s", s); - PyErr_SetString(PyExc_ValueError, buffer); - Py_DECREF(x); - return NULL; - } - return x; -} - - -PyDoc_STRVAR(atof__doc__, -"atof(s) -> float\n" -"\n" -"Return the floating point number represented by the string s."); - -static PyObject * -strop_atof(PyObject *self, PyObject *args) -{ - extern double strtod(const char *, char **); - char *s, *end; - double x; - char buffer[256]; /* For errors */ - - WARN; - if (!PyArg_ParseTuple(args, "s:atof", &s)) - return NULL; - while (*s && isspace(Py_CHARMASK(*s))) - s++; - if (s[0] == '\0') { - PyErr_SetString(PyExc_ValueError, "empty string for atof()"); - return NULL; - } - errno = 0; - PyFPE_START_PROTECT("strop_atof", return 0) - x = strtod(s, &end); - PyFPE_END_PROTECT(x) - while (*end && isspace(Py_CHARMASK(*end))) - end++; - if (*end != '\0') { - PyOS_snprintf(buffer, sizeof(buffer), - "invalid literal for atof(): %.200s", s); - PyErr_SetString(PyExc_ValueError, buffer); - return NULL; - } - else if (errno != 0) { - PyOS_snprintf(buffer, sizeof(buffer), - "atof() literal too large: %.200s", s); - PyErr_SetString(PyExc_ValueError, buffer); - return NULL; - } - return PyFloat_FromDouble(x); -} - - -PyDoc_STRVAR(maketrans__doc__, -"maketrans(frm, to) -> string\n" -"\n" -"Return a translation table (a string of 256 bytes long)\n" -"suitable for use in string.translate. The strings frm and to\n" -"must be of the same length."); - -static PyObject * -strop_maketrans(PyObject *self, PyObject *args) -{ - unsigned char *c, *from=NULL, *to=NULL; - int i, fromlen=0, tolen=0; - PyObject *result; - - if (!PyArg_ParseTuple(args, "t#t#:maketrans", &from, &fromlen, &to, &tolen)) - return NULL; - - if (fromlen != tolen) { - PyErr_SetString(PyExc_ValueError, - "maketrans arguments must have same length"); - return NULL; - } - - result = PyString_FromStringAndSize((char *)NULL, 256); - if (result == NULL) - return NULL; - c = (unsigned char *) PyString_AS_STRING((PyStringObject *)result); - for (i = 0; i < 256; i++) - c[i]=(unsigned char)i; - for (i = 0; i < fromlen; i++) - c[from[i]]=to[i]; - - return result; -} - - -PyDoc_STRVAR(translate__doc__, -"translate(s,table [,deletechars]) -> string\n" -"\n" -"Return a copy of the string s, where all characters occurring\n" -"in the optional argument deletechars are removed, and the\n" -"remaining characters have been mapped through the given\n" -"translation table, which must be a string of length 256."); - -static PyObject * -strop_translate(PyObject *self, PyObject *args) -{ - register char *input, *table, *output; - register int i, c, changed = 0; - PyObject *input_obj; - char *table1, *output_start, *del_table=NULL; - int inlen, tablen, dellen = 0; - PyObject *result; - int trans_table[256]; - - WARN; - if (!PyArg_ParseTuple(args, "St#|t#:translate", &input_obj, - &table1, &tablen, &del_table, &dellen)) - return NULL; - if (tablen != 256) { - PyErr_SetString(PyExc_ValueError, - "translation table must be 256 characters long"); - return NULL; - } - - table = table1; - inlen = PyString_Size(input_obj); - result = PyString_FromStringAndSize((char *)NULL, inlen); - if (result == NULL) - return NULL; - output_start = output = PyString_AsString(result); - input = PyString_AsString(input_obj); - - if (dellen == 0) { - /* If no deletions are required, use faster code */ - for (i = inlen; --i >= 0; ) { - c = Py_CHARMASK(*input++); - if (Py_CHARMASK((*output++ = table[c])) != c) - changed = 1; - } - if (changed) - return result; - Py_DECREF(result); - Py_INCREF(input_obj); - return input_obj; - } - - for (i = 0; i < 256; i++) - trans_table[i] = Py_CHARMASK(table[i]); - - for (i = 0; i < dellen; i++) - trans_table[(int) Py_CHARMASK(del_table[i])] = -1; - - for (i = inlen; --i >= 0; ) { - c = Py_CHARMASK(*input++); - if (trans_table[c] != -1) - if (Py_CHARMASK(*output++ = (char)trans_table[c]) == c) - continue; - changed = 1; - } - if (!changed) { - Py_DECREF(result); - Py_INCREF(input_obj); - return input_obj; - } - /* Fix the size of the resulting string */ - if (inlen > 0) - _PyString_Resize(&result, output - output_start); - return result; -} - - -/* What follows is used for implementing replace(). Perry Stoll. */ - -/* - mymemfind - - strstr replacement for arbitrary blocks of memory. - - Locates the first occurrence in the memory pointed to by MEM of the - contents of memory pointed to by PAT. Returns the index into MEM if - found, or -1 if not found. If len of PAT is greater than length of - MEM, the function returns -1. -*/ -static int -mymemfind(const char *mem, int len, const char *pat, int pat_len) -{ - register int ii; - - /* pattern can not occur in the last pat_len-1 chars */ - len -= pat_len; - - for (ii = 0; ii <= len; ii++) { - if (mem[ii] == pat[0] && - (pat_len == 1 || - memcmp(&mem[ii+1], &pat[1], pat_len-1) == 0)) { - return ii; - } - } - return -1; -} - -/* - mymemcnt - - Return the number of distinct times PAT is found in MEM. - meaning mem=1111 and pat==11 returns 2. - mem=11111 and pat==11 also return 2. - */ -static int -mymemcnt(const char *mem, int len, const char *pat, int pat_len) -{ - register int offset = 0; - int nfound = 0; - - while (len >= 0) { - offset = mymemfind(mem, len, pat, pat_len); - if (offset == -1) - break; - mem += offset + pat_len; - len -= offset + pat_len; - nfound++; - } - return nfound; -} - -/* - mymemreplace - - Return a string in which all occurrences of PAT in memory STR are - replaced with SUB. - - If length of PAT is less than length of STR or there are no occurrences - of PAT in STR, then the original string is returned. Otherwise, a new - string is allocated here and returned. - - on return, out_len is: - the length of output string, or - -1 if the input string is returned, or - unchanged if an error occurs (no memory). - - return value is: - the new string allocated locally, or - NULL if an error occurred. -*/ -static char * -mymemreplace(const char *str, int len, /* input string */ - const char *pat, int pat_len, /* pattern string to find */ - const char *sub, int sub_len, /* substitution string */ - int count, /* number of replacements */ - int *out_len) -{ - char *out_s; - char *new_s; - int nfound, offset, new_len; - - if (len == 0 || pat_len > len) - goto return_same; - - /* find length of output string */ - nfound = mymemcnt(str, len, pat, pat_len); - if (count < 0) - count = INT_MAX; - else if (nfound > count) - nfound = count; - if (nfound == 0) - goto return_same; - - new_len = len + nfound*(sub_len - pat_len); - if (new_len == 0) { - /* Have to allocate something for the caller to free(). */ - out_s = (char *)PyMem_MALLOC(1); - if (out_s == NULL) - return NULL; - out_s[0] = '\0'; - } - else { - assert(new_len > 0); - new_s = (char *)PyMem_MALLOC(new_len); - if (new_s == NULL) - return NULL; - out_s = new_s; - - for (; count > 0 && len > 0; --count) { - /* find index of next instance of pattern */ - offset = mymemfind(str, len, pat, pat_len); - if (offset == -1) - break; - - /* copy non matching part of input string */ - memcpy(new_s, str, offset); - str += offset + pat_len; - len -= offset + pat_len; - - /* copy substitute into the output string */ - new_s += offset; - memcpy(new_s, sub, sub_len); - new_s += sub_len; - } - /* copy any remaining values into output string */ - if (len > 0) - memcpy(new_s, str, len); - } - *out_len = new_len; - return out_s; - - return_same: - *out_len = -1; - return (char *)str; /* cast away const */ -} - - -PyDoc_STRVAR(replace__doc__, -"replace (str, old, new[, maxsplit]) -> string\n" -"\n" -"Return a copy of string str with all occurrences of substring\n" -"old replaced by new. If the optional argument maxsplit is\n" -"given, only the first maxsplit occurrences are replaced."); - -static PyObject * -strop_replace(PyObject *self, PyObject *args) -{ - char *str, *pat,*sub,*new_s; - int len,pat_len,sub_len,out_len; - int count = -1; - PyObject *new; - - WARN; - if (!PyArg_ParseTuple(args, "t#t#t#|i:replace", - &str, &len, &pat, &pat_len, &sub, &sub_len, - &count)) - return NULL; - if (pat_len <= 0) { - PyErr_SetString(PyExc_ValueError, "empty pattern string"); - return NULL; - } - /* CAUTION: strop treats a replace count of 0 as infinity, unlke - * current (2.1) string.py and string methods. Preserve this for - * ... well, hard to say for what . - */ - if (count == 0) - count = -1; - new_s = mymemreplace(str,len,pat,pat_len,sub,sub_len,count,&out_len); - if (new_s == NULL) { - PyErr_NoMemory(); - return NULL; - } - if (out_len == -1) { - /* we're returning another reference to the input string */ - new = PyTuple_GetItem(args, 0); - Py_XINCREF(new); - } - else { - new = PyString_FromStringAndSize(new_s, out_len); - PyMem_FREE(new_s); - } - return new; -} - - -/* List of functions defined in the module */ - -static PyMethodDef -strop_methods[] = { - {"atof", strop_atof, METH_VARARGS, atof__doc__}, - {"atoi", strop_atoi, METH_VARARGS, atoi__doc__}, - {"atol", strop_atol, METH_VARARGS, atol__doc__}, - {"capitalize", strop_capitalize, METH_O, capitalize__doc__}, - {"count", strop_count, METH_VARARGS, count__doc__}, - {"expandtabs", strop_expandtabs, METH_VARARGS, expandtabs__doc__}, - {"find", strop_find, METH_VARARGS, find__doc__}, - {"join", strop_joinfields, METH_VARARGS, joinfields__doc__}, - {"joinfields", strop_joinfields, METH_VARARGS, joinfields__doc__}, - {"lstrip", strop_lstrip, METH_O, lstrip__doc__}, - {"lower", strop_lower, METH_O, lower__doc__}, - {"maketrans", strop_maketrans, METH_VARARGS, maketrans__doc__}, - {"replace", strop_replace, METH_VARARGS, replace__doc__}, - {"rfind", strop_rfind, METH_VARARGS, rfind__doc__}, - {"rstrip", strop_rstrip, METH_O, rstrip__doc__}, - {"split", strop_splitfields, METH_VARARGS, splitfields__doc__}, - {"splitfields", strop_splitfields, METH_VARARGS, splitfields__doc__}, - {"strip", strop_strip, METH_O, strip__doc__}, - {"swapcase", strop_swapcase, METH_O, swapcase__doc__}, - {"translate", strop_translate, METH_VARARGS, translate__doc__}, - {"upper", strop_upper, METH_O, upper__doc__}, - {NULL, NULL} /* sentinel */ -}; - - -PyMODINIT_FUNC -initstrop(void) -{ - PyObject *m, *s; - char buf[256]; - int c, n; - m = Py_InitModule4("strop", strop_methods, strop_module__doc__, - (PyObject*)NULL, PYTHON_API_VERSION); - - /* Create 'whitespace' object */ - n = 0; - for (c = 0; c < 256; c++) { - if (isspace(c)) - buf[n++] = c; - } - s = PyString_FromStringAndSize(buf, n); - if (s) - PyModule_AddObject(m, "whitespace", s); - - /* Create 'lowercase' object */ - n = 0; - for (c = 0; c < 256; c++) { - if (islower(c)) - buf[n++] = c; - } - s = PyString_FromStringAndSize(buf, n); - if (s) - PyModule_AddObject(m, "lowercase", s); - - /* Create 'uppercase' object */ - n = 0; - for (c = 0; c < 256; c++) { - if (isupper(c)) - buf[n++] = c; - } - s = PyString_FromStringAndSize(buf, n); - if (s) - PyModule_AddObject(m, "uppercase", s); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/structmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/structmodule.c deleted file mode 100644 index 689538f7..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/structmodule.c +++ /dev/null @@ -1,1297 +0,0 @@ -/* struct module -- pack values into and (out of) strings */ - -/* New version supporting byte order, alignment and size options, - character strings, and unsigned numbers */ - -#include "Python.h" -#include - -PyDoc_STRVAR(struct__doc__, -"Functions to convert between Python values and C structs.\n\ -Python strings are used to hold the data representing the C struct\n\ -and also as format strings to describe the layout of data in the C struct.\n\ -\n\ -The optional first format char indicates byte order, size and alignment:\n\ - @: native order, size & alignment (default)\n\ - =: native order, std. size & alignment\n\ - <: little-endian, std. size & alignment\n\ - >: big-endian, std. size & alignment\n\ - !: same as >\n\ -\n\ -The remaining chars indicate types of args and must match exactly;\n\ -these can be preceded by a decimal repeat count:\n\ - x: pad byte (no data); c:char; b:signed byte; B:unsigned byte;\n\ - h:short; H:unsigned short; i:int; I:unsigned int;\n\ - l:long; L:unsigned long; f:float; d:double.\n\ -Special cases (preceding decimal count indicates length):\n\ - s:string (array of char); p: pascal string (with count byte).\n\ -Special case (only available in native format):\n\ - P:an integer type that is wide enough to hold a pointer.\n\ -Special case (not in native mode unless 'long long' in platform C):\n\ - q:long long; Q:unsigned long long\n\ -Whitespace between formats is ignored.\n\ -\n\ -The variable struct.error is an exception raised on errors."); - - -/* Exception */ - -static PyObject *StructError; - - -/* Define various structs to figure out the alignments of types */ - -#ifdef __MWERKS__ -/* -** XXXX We have a problem here. There are no unique alignment rules -** on the PowerPC mac. -*/ -#ifdef __powerc -#pragma options align=mac68k -#endif -#endif /* __MWERKS__ */ - -typedef struct { char c; short x; } st_short; -typedef struct { char c; int x; } st_int; -typedef struct { char c; long x; } st_long; -typedef struct { char c; float x; } st_float; -typedef struct { char c; double x; } st_double; -typedef struct { char c; void *x; } st_void_p; - -#define SHORT_ALIGN (sizeof(st_short) - sizeof(short)) -#define INT_ALIGN (sizeof(st_int) - sizeof(int)) -#define LONG_ALIGN (sizeof(st_long) - sizeof(long)) -#define FLOAT_ALIGN (sizeof(st_float) - sizeof(float)) -#define DOUBLE_ALIGN (sizeof(st_double) - sizeof(double)) -#define VOID_P_ALIGN (sizeof(st_void_p) - sizeof(void *)) - -/* We can't support q and Q in native mode unless the compiler does; - in std mode, they're 8 bytes on all platforms. */ -#ifdef HAVE_LONG_LONG -typedef struct { char c; PY_LONG_LONG x; } s_long_long; -#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) -#endif - -#define STRINGIFY(x) #x - -#ifdef __powerc -#pragma options align=reset -#endif - -/* Helper to get a PyLongObject by hook or by crook. Caller should decref. */ - -static PyObject * -get_pylong(PyObject *v) -{ - PyNumberMethods *m; - - assert(v != NULL); - if (PyInt_Check(v)) - return PyLong_FromLong(PyInt_AS_LONG(v)); - if (PyLong_Check(v)) { - Py_INCREF(v); - return v; - } - m = v->ob_type->tp_as_number; - if (m != NULL && m->nb_long != NULL) { - v = m->nb_long(v); - if (v == NULL) - return NULL; - if (PyLong_Check(v)) - return v; - Py_DECREF(v); - } - PyErr_SetString(StructError, - "cannot convert argument to long"); - return NULL; -} - -/* Helper routine to get a Python integer and raise the appropriate error - if it isn't one */ - -static int -get_long(PyObject *v, long *p) -{ - long x = PyInt_AsLong(v); - if (x == -1 && PyErr_Occurred()) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_SetString(StructError, - "required argument is not an integer"); - return -1; - } - *p = x; - return 0; -} - - -/* Same, but handling unsigned long */ - -static int -get_ulong(PyObject *v, unsigned long *p) -{ - if (PyLong_Check(v)) { - unsigned long x = PyLong_AsUnsignedLong(v); - if (x == (unsigned long)(-1) && PyErr_Occurred()) - return -1; - *p = x; - return 0; - } - else { - return get_long(v, (long *)p); - } -} - -#ifdef HAVE_LONG_LONG - -/* Same, but handling native long long. */ - -static int -get_longlong(PyObject *v, PY_LONG_LONG *p) -{ - PY_LONG_LONG x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsLongLong(v); - Py_DECREF(v); - if (x == (PY_LONG_LONG)-1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -/* Same, but handling native unsigned long long. */ - -static int -get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) -{ - unsigned PY_LONG_LONG x; - - v = get_pylong(v); - if (v == NULL) - return -1; - assert(PyLong_Check(v)); - x = PyLong_AsUnsignedLongLong(v); - Py_DECREF(v); - if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -#endif - -/* Floating point helpers */ - -static PyObject * -unpack_float(const char *p, /* start of 4-byte string */ - int le) /* true for little-endian, false for big-endian */ -{ - double x; - - x = _PyFloat_Unpack4((unsigned char *)p, le); - if (x == -1.0 && PyErr_Occurred()) - return NULL; - return PyFloat_FromDouble(x); -} - -static PyObject * -unpack_double(const char *p, /* start of 8-byte string */ - int le) /* true for little-endian, false for big-endian */ -{ - double x; - - x = _PyFloat_Unpack8((unsigned char *)p, le); - if (x == -1.0 && PyErr_Occurred()) - return NULL; - return PyFloat_FromDouble(x); -} - - -/* The translation function for each format character is table driven */ - -typedef struct _formatdef { - char format; - int size; - int alignment; - PyObject* (*unpack)(const char *, - const struct _formatdef *); - int (*pack)(char *, PyObject *, - const struct _formatdef *); -} formatdef; - -/* A large number of small routines follow, with names of the form - - [bln][up]_TYPE - - [bln] distiguishes among big-endian, little-endian and native. - [pu] distiguishes between pack (to struct) and unpack (from struct). - TYPE is one of char, byte, ubyte, etc. -*/ - -/* Native mode routines. ****************************************************/ -/* NOTE: - In all n[up]_ routines handling types larger than 1 byte, there is - *no* guarantee that the p pointer is properly aligned for each type, - therefore memcpy is called. An intermediate variable is used to - compensate for big-endian architectures. - Normally both the intermediate variable and the memcpy call will be - skipped by C optimisation in little-endian architectures (gcc >= 2.91 - does this). */ - -static PyObject * -nu_char(const char *p, const formatdef *f) -{ - return PyString_FromStringAndSize(p, 1); -} - -static PyObject * -nu_byte(const char *p, const formatdef *f) -{ - return PyInt_FromLong((long) *(signed char *)p); -} - -static PyObject * -nu_ubyte(const char *p, const formatdef *f) -{ - return PyInt_FromLong((long) *(unsigned char *)p); -} - -static PyObject * -nu_short(const char *p, const formatdef *f) -{ - short x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_ushort(const char *p, const formatdef *f) -{ - unsigned short x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_int(const char *p, const formatdef *f) -{ - int x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); -} - -static PyObject * -nu_uint(const char *p, const formatdef *f) -{ - unsigned int x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLong((unsigned long)x); -} - -static PyObject * -nu_long(const char *p, const formatdef *f) -{ - long x; - memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong(x); -} - -static PyObject * -nu_ulong(const char *p, const formatdef *f) -{ - unsigned long x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLong(x); -} - -/* Native mode doesn't support q or Q unless the platform C supports - long long (or, on Windows, __int64). */ - -#ifdef HAVE_LONG_LONG - -static PyObject * -nu_longlong(const char *p, const formatdef *f) -{ - PY_LONG_LONG x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromLongLong(x); -} - -static PyObject * -nu_ulonglong(const char *p, const formatdef *f) -{ - unsigned PY_LONG_LONG x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromUnsignedLongLong(x); -} - -#endif - -static PyObject * -nu_float(const char *p, const formatdef *f) -{ - float x; - memcpy((char *)&x, p, sizeof x); - return PyFloat_FromDouble((double)x); -} - -static PyObject * -nu_double(const char *p, const formatdef *f) -{ - double x; - memcpy((char *)&x, p, sizeof x); - return PyFloat_FromDouble(x); -} - -static PyObject * -nu_void_p(const char *p, const formatdef *f) -{ - void *x; - memcpy((char *)&x, p, sizeof x); - return PyLong_FromVoidPtr(x); -} - -static int -np_byte(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - if (x < -128 || x > 127){ - PyErr_SetString(StructError, - "byte format requires -128<=number<=127"); - return -1; - } - *p = (char)x; - return 0; -} - -static int -np_ubyte(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - if (x < 0 || x > 255){ - PyErr_SetString(StructError, - "ubyte format requires 0<=number<=255"); - return -1; - } - *p = (char)x; - return 0; -} - -static int -np_char(char *p, PyObject *v, const formatdef *f) -{ - if (!PyString_Check(v) || PyString_Size(v) != 1) { - PyErr_SetString(StructError, - "char format require string of length 1"); - return -1; - } - *p = *PyString_AsString(v); - return 0; -} - -static int -np_short(char *p, PyObject *v, const formatdef *f) -{ - long x; - short y; - if (get_long(v, &x) < 0) - return -1; - if (x < SHRT_MIN || x > SHRT_MAX){ - PyErr_SetString(StructError, - "short format requires " STRINGIFY(SHRT_MIN) - "<=number<=" STRINGIFY(SHRT_MAX)); - return -1; - } - y = (short)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_ushort(char *p, PyObject *v, const formatdef *f) -{ - long x; - unsigned short y; - if (get_long(v, &x) < 0) - return -1; - if (x < 0 || x > USHRT_MAX){ - PyErr_SetString(StructError, - "short format requires 0<=number<=" STRINGIFY(USHRT_MAX)); - return -1; - } - y = (unsigned short)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int y; - if (get_long(v, &x) < 0) - return -1; - y = (int)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - unsigned int y; - if (get_ulong(v, &x) < 0) - return -1; - y = (unsigned int)x; - memcpy(p, (char *)&y, sizeof y); - return 0; -} - -static int -np_long(char *p, PyObject *v, const formatdef *f) -{ - long x; - if (get_long(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_ulong(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - if (get_ulong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -#ifdef HAVE_LONG_LONG - -static int -np_longlong(char *p, PyObject *v, const formatdef *f) -{ - PY_LONG_LONG x; - if (get_longlong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - unsigned PY_LONG_LONG x; - if (get_ulonglong(v, &x) < 0) - return -1; - memcpy(p, (char *)&x, sizeof x); - return 0; -} -#endif - -static int -np_float(char *p, PyObject *v, const formatdef *f) -{ - float x = (float)PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static int -np_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - memcpy(p, (char *)&x, sizeof(double)); - return 0; -} - -static int -np_void_p(char *p, PyObject *v, const formatdef *f) -{ - void *x = PyLong_AsVoidPtr(v); - if (x == NULL && PyErr_Occurred()) { - /* ### hrm. PyLong_AsVoidPtr raises SystemError */ - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_SetString(StructError, - "required argument is not an integer"); - return -1; - } - memcpy(p, (char *)&x, sizeof x); - return 0; -} - -static formatdef native_table[] = { - {'x', sizeof(char), 0, NULL}, - {'b', sizeof(char), 0, nu_byte, np_byte}, - {'B', sizeof(char), 0, nu_ubyte, np_ubyte}, - {'c', sizeof(char), 0, nu_char, np_char}, - {'s', sizeof(char), 0, NULL}, - {'p', sizeof(char), 0, NULL}, - {'h', sizeof(short), SHORT_ALIGN, nu_short, np_short}, - {'H', sizeof(short), SHORT_ALIGN, nu_ushort, np_ushort}, - {'i', sizeof(int), INT_ALIGN, nu_int, np_int}, - {'I', sizeof(int), INT_ALIGN, nu_uint, np_uint}, - {'l', sizeof(long), LONG_ALIGN, nu_long, np_long}, - {'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, - {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, - {'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double}, - {'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p}, -#ifdef HAVE_LONG_LONG - {'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong}, - {'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, -#endif - {0} -}; - -/* Big-endian routines. *****************************************************/ - -static PyObject * -bu_int(const char *p, const formatdef *f) -{ - long x = 0; - int i = f->size; - do { - x = (x<<8) | (*p++ & 0xFF); - } while (--i > 0); - /* Extend the sign bit. */ - if (SIZEOF_LONG > f->size) - x |= -(x & (1L << (8*f->size - 1))); - return PyInt_FromLong(x); -} - -static PyObject * -bu_uint(const char *p, const formatdef *f) -{ - unsigned long x = 0; - int i = f->size; - do { - x = (x<<8) | (*p++ & 0xFF); - } while (--i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else - return PyInt_FromLong((long)x); -} - -static PyObject * -bu_longlong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 0, /* little-endian */ - 1 /* signed */); -} - -static PyObject * -bu_ulonglong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 0, /* little-endian */ - 0 /* signed */); -} - -static PyObject * -bu_float(const char *p, const formatdef *f) -{ - return unpack_float(p, 0); -} - -static PyObject * -bu_double(const char *p, const formatdef *f) -{ - return unpack_double(p, 0); -} - -static int -bp_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int i; - if (get_long(v, &x) < 0) - return -1; - i = f->size; - do { - p[--i] = (char)x; - x >>= 8; - } while (i > 0); - return 0; -} - -static int -bp_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - int i; - if (get_ulong(v, &x) < 0) - return -1; - i = f->size; - do { - p[--i] = (char)x; - x >>= 8; - } while (i > 0); - return 0; -} - -static int -bp_longlong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject *)v, - (unsigned char *)p, - 8, - 0, /* little_endian */ - 1 /* signed */); - Py_DECREF(v); - return res; -} - -static int -bp_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject *)v, - (unsigned char *)p, - 8, - 0, /* little_endian */ - 0 /* signed */); - Py_DECREF(v); - return res; -} - -static int -bp_float(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack4(x, (unsigned char *)p, 0); -} - -static int -bp_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack8(x, (unsigned char *)p, 0); -} - -static formatdef bigendian_table[] = { - {'x', 1, 0, NULL}, - {'b', 1, 0, bu_int, bp_int}, - {'B', 1, 0, bu_uint, bp_int}, - {'c', 1, 0, nu_char, np_char}, - {'s', 1, 0, NULL}, - {'p', 1, 0, NULL}, - {'h', 2, 0, bu_int, bp_int}, - {'H', 2, 0, bu_uint, bp_uint}, - {'i', 4, 0, bu_int, bp_int}, - {'I', 4, 0, bu_uint, bp_uint}, - {'l', 4, 0, bu_int, bp_int}, - {'L', 4, 0, bu_uint, bp_uint}, - {'q', 8, 0, bu_longlong, bp_longlong}, - {'Q', 8, 0, bu_ulonglong, bp_ulonglong}, - {'f', 4, 0, bu_float, bp_float}, - {'d', 8, 0, bu_double, bp_double}, - {0} -}; - -/* Little-endian routines. *****************************************************/ - -static PyObject * -lu_int(const char *p, const formatdef *f) -{ - long x = 0; - int i = f->size; - do { - x = (x<<8) | (p[--i] & 0xFF); - } while (i > 0); - /* Extend the sign bit. */ - if (SIZEOF_LONG > f->size) - x |= -(x & (1L << (8*f->size - 1))); - return PyInt_FromLong(x); -} - -static PyObject * -lu_uint(const char *p, const formatdef *f) -{ - unsigned long x = 0; - int i = f->size; - do { - x = (x<<8) | (p[--i] & 0xFF); - } while (i > 0); - if (f->size >= 4) - return PyLong_FromUnsignedLong(x); - else - return PyInt_FromLong((long)x); -} - -static PyObject * -lu_longlong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 1, /* little-endian */ - 1 /* signed */); -} - -static PyObject * -lu_ulonglong(const char *p, const formatdef *f) -{ - return _PyLong_FromByteArray((const unsigned char *)p, - 8, - 1, /* little-endian */ - 0 /* signed */); -} - -static PyObject * -lu_float(const char *p, const formatdef *f) -{ - return unpack_float(p, 1); -} - -static PyObject * -lu_double(const char *p, const formatdef *f) -{ - return unpack_double(p, 1); -} - -static int -lp_int(char *p, PyObject *v, const formatdef *f) -{ - long x; - int i; - if (get_long(v, &x) < 0) - return -1; - i = f->size; - do { - *p++ = (char)x; - x >>= 8; - } while (--i > 0); - return 0; -} - -static int -lp_uint(char *p, PyObject *v, const formatdef *f) -{ - unsigned long x; - int i; - if (get_ulong(v, &x) < 0) - return -1; - i = f->size; - do { - *p++ = (char)x; - x >>= 8; - } while (--i > 0); - return 0; -} - -static int -lp_longlong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject*)v, - (unsigned char *)p, - 8, - 1, /* little_endian */ - 1 /* signed */); - Py_DECREF(v); - return res; -} - -static int -lp_ulonglong(char *p, PyObject *v, const formatdef *f) -{ - int res; - v = get_pylong(v); - if (v == NULL) - return -1; - res = _PyLong_AsByteArray((PyLongObject*)v, - (unsigned char *)p, - 8, - 1, /* little_endian */ - 0 /* signed */); - Py_DECREF(v); - return res; -} - -static int -lp_float(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack4(x, (unsigned char *)p, 1); -} - -static int -lp_double(char *p, PyObject *v, const formatdef *f) -{ - double x = PyFloat_AsDouble(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(StructError, - "required argument is not a float"); - return -1; - } - return _PyFloat_Pack8(x, (unsigned char *)p, 1); -} - -static formatdef lilendian_table[] = { - {'x', 1, 0, NULL}, - {'b', 1, 0, lu_int, lp_int}, - {'B', 1, 0, lu_uint, lp_int}, - {'c', 1, 0, nu_char, np_char}, - {'s', 1, 0, NULL}, - {'p', 1, 0, NULL}, - {'h', 2, 0, lu_int, lp_int}, - {'H', 2, 0, lu_uint, lp_uint}, - {'i', 4, 0, lu_int, lp_int}, - {'I', 4, 0, lu_uint, lp_uint}, - {'l', 4, 0, lu_int, lp_int}, - {'L', 4, 0, lu_uint, lp_uint}, - {'q', 8, 0, lu_longlong, lp_longlong}, - {'Q', 8, 0, lu_ulonglong, lp_ulonglong}, - {'f', 4, 0, lu_float, lp_float}, - {'d', 8, 0, lu_double, lp_double}, - {0} -}; - - -static const formatdef * -whichtable(char **pfmt) -{ - const char *fmt = (*pfmt)++; /* May be backed out of later */ - switch (*fmt) { - case '<': - return lilendian_table; - case '>': - case '!': /* Network byte order is big-endian */ - return bigendian_table; - case '=': { /* Host byte order -- different from native in aligment! */ - int n = 1; - char *p = (char *) &n; - if (*p == 1) - return lilendian_table; - else - return bigendian_table; - } - default: - --*pfmt; /* Back out of pointer increment */ - /* Fall through */ - case '@': - return native_table; - } -} - - -/* Get the table entry for a format code */ - -static const formatdef * -getentry(int c, const formatdef *f) -{ - for (; f->format != '\0'; f++) { - if (f->format == c) { - return f; - } - } - PyErr_SetString(StructError, "bad char in struct format"); - return NULL; -} - - -/* Align a size according to a format code */ - -static int -align(int size, int c, const formatdef *e) -{ - if (e->format == c) { - if (e->alignment) { - size = ((size + e->alignment - 1) - / e->alignment) - * e->alignment; - } - } - return size; -} - - -/* calculate the size of a format string */ - -static int -calcsize(const char *fmt, const formatdef *f) -{ - const formatdef *e; - const char *s; - char c; - int size, num, itemsize, x; - - s = fmt; - size = 0; - while ((c = *s++) != '\0') { - if (isspace((int)c)) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') { - x = num*10 + (c - '0'); - if (x/10 != num) { - PyErr_SetString( - StructError, - "overflow in item count"); - return -1; - } - num = x; - } - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - return -1; - itemsize = e->size; - size = align(size, c, e); - x = num * itemsize; - size += x; - if (x/itemsize != num || size < 0) { - PyErr_SetString(StructError, - "total struct size too long"); - return -1; - } - } - - return size; -} - - -PyDoc_STRVAR(calcsize__doc__, -"calcsize(fmt) -> int\n\ -Return size of C struct described by format string fmt.\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_calcsize(PyObject *self, PyObject *args) -{ - char *fmt; - const formatdef *f; - int size; - - if (!PyArg_ParseTuple(args, "s:calcsize", &fmt)) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - return PyInt_FromLong((long)size); -} - - -PyDoc_STRVAR(pack__doc__, -"pack(fmt, v1, v2, ...) -> string\n\ -Return string containing values v1, v2, ... packed according to fmt.\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_pack(PyObject *self, PyObject *args) -{ - const formatdef *f, *e; - PyObject *format, *result, *v; - char *fmt; - int size, num; - int i, n; - char *s, *res, *restart, *nres; - char c; - - if (args == NULL || !PyTuple_Check(args) || - (n = PyTuple_Size(args)) < 1) - { - PyErr_SetString(PyExc_TypeError, - "struct.pack requires at least one argument"); - return NULL; - } - format = PyTuple_GetItem(args, 0); - fmt = PyString_AsString(format); - if (!fmt) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - result = PyString_FromStringAndSize((char *)NULL, size); - if (result == NULL) - return NULL; - - s = fmt; - i = 1; - res = restart = PyString_AsString(result); - - while ((c = *s++) != '\0') { - if (isspace((int)c)) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') - num = num*10 + (c - '0'); - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - goto fail; - nres = restart + align((int)(res-restart), c, e); - /* Fill padd bytes with zeros */ - while (res < nres) - *res++ = '\0'; - if (num == 0 && c != 's') - continue; - do { - if (c == 'x') { - /* doesn't consume arguments */ - memset(res, '\0', num); - res += num; - break; - } - if (i >= n) { - PyErr_SetString(StructError, - "insufficient arguments to pack"); - goto fail; - } - v = PyTuple_GetItem(args, i++); - if (v == NULL) - goto fail; - if (c == 's') { - /* num is string size, not repeat count */ - int n; - if (!PyString_Check(v)) { - PyErr_SetString(StructError, - "argument for 's' must be a string"); - goto fail; - } - n = PyString_Size(v); - if (n > num) - n = num; - if (n > 0) - memcpy(res, PyString_AsString(v), n); - if (n < num) - memset(res+n, '\0', num-n); - res += num; - break; - } - else if (c == 'p') { - /* num is string size + 1, - to fit in the count byte */ - int n; - num--; /* now num is max string size */ - if (!PyString_Check(v)) { - PyErr_SetString(StructError, - "argument for 'p' must be a string"); - goto fail; - } - n = PyString_Size(v); - if (n > num) - n = num; - if (n > 0) - memcpy(res+1, PyString_AsString(v), n); - if (n < num) - /* no real need, just to be nice */ - memset(res+1+n, '\0', num-n); - if (n > 255) - n = 255; - *res++ = n; /* store the length byte */ - res += num; - break; - } - else { - if (e->pack(res, v, e) < 0) - goto fail; - res += e->size; - } - } while (--num > 0); - } - - if (i < n) { - PyErr_SetString(StructError, - "too many arguments for pack format"); - goto fail; - } - - return result; - - fail: - Py_DECREF(result); - return NULL; -} - - -PyDoc_STRVAR(unpack__doc__, -"unpack(fmt, string) -> (v1, v2, ...)\n\ -Unpack the string, containing packed C structure data, according\n\ -to fmt. Requires len(string)==calcsize(fmt).\n\ -See struct.__doc__ for more on format strings."); - -static PyObject * -struct_unpack(PyObject *self, PyObject *args) -{ - const formatdef *f, *e; - char *str, *start, *fmt, *s; - char c; - int len, size, num; - PyObject *res, *v; - - if (!PyArg_ParseTuple(args, "ss#:unpack", &fmt, &start, &len)) - return NULL; - f = whichtable(&fmt); - size = calcsize(fmt, f); - if (size < 0) - return NULL; - if (size != len) { - PyErr_SetString(StructError, - "unpack str size does not match format"); - return NULL; - } - res = PyList_New(0); - if (res == NULL) - return NULL; - str = start; - s = fmt; - while ((c = *s++) != '\0') { - if (isspace((int)c)) - continue; - if ('0' <= c && c <= '9') { - num = c - '0'; - while ('0' <= (c = *s++) && c <= '9') - num = num*10 + (c - '0'); - if (c == '\0') - break; - } - else - num = 1; - - e = getentry(c, f); - if (e == NULL) - goto fail; - str = start + align((int)(str-start), c, e); - if (num == 0 && c != 's') - continue; - - do { - if (c == 'x') { - str += num; - break; - } - if (c == 's') { - /* num is string size, not repeat count */ - v = PyString_FromStringAndSize(str, num); - if (v == NULL) - goto fail; - str += num; - num = 0; - } - else if (c == 'p') { - /* num is string buffer size, - not repeat count */ - int n = *(unsigned char*)str; - /* first byte (unsigned) is string size */ - if (n >= num) - n = num-1; - v = PyString_FromStringAndSize(str+1, n); - if (v == NULL) - goto fail; - str += num; - num = 0; - } - else { - v = e->unpack(str, e); - if (v == NULL) - goto fail; - str += e->size; - } - if (v == NULL || PyList_Append(res, v) < 0) - goto fail; - Py_DECREF(v); - } while (--num > 0); - } - - v = PyList_AsTuple(res); - Py_DECREF(res); - return v; - - fail: - Py_DECREF(res); - return NULL; -} - - -/* List of functions */ - -static PyMethodDef struct_methods[] = { - {"calcsize", struct_calcsize, METH_VARARGS, calcsize__doc__}, - {"pack", struct_pack, METH_VARARGS, pack__doc__}, - {"unpack", struct_unpack, METH_VARARGS, unpack__doc__}, - {NULL, NULL} /* sentinel */ -}; - - -/* Module initialization */ - -PyMODINIT_FUNC -initstruct(void) -{ - PyObject *m; - - /* Create the module and add the functions */ - m = Py_InitModule4("struct", struct_methods, struct__doc__, - (PyObject*)NULL, PYTHON_API_VERSION); - - /* Add some symbolic constants to the module */ - if (StructError == NULL) { - StructError = PyErr_NewException("struct.error", NULL, NULL); - if (StructError == NULL) - return; - } - Py_INCREF(StructError); - PyModule_AddObject(m, "error", StructError); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/sunaudiodev.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/sunaudiodev.c deleted file mode 100644 index 90eee302..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/sunaudiodev.c +++ /dev/null @@ -1,463 +0,0 @@ - -/* Sad objects */ - -#include "Python.h" -#include "structmember.h" - -#ifdef HAVE_SYS_AUDIOIO_H -#define SOLARIS -#endif - -#ifdef HAVE_FCNTL_H -#include -#endif - -#include -#include -#ifdef SOLARIS -#include -#else -#include -#endif - -/* #define offsetof(str,mem) ((int)(((str *)0)->mem)) */ - -typedef struct { - PyObject_HEAD - int x_fd; /* The open file */ - int x_icount; /* # samples read */ - int x_ocount; /* # samples written */ - int x_isctl; /* True if control device */ - -} sadobject; - -typedef struct { - PyObject_HEAD - audio_info_t ai; -} sadstatusobject; - -static PyTypeObject Sadtype; -static PyTypeObject Sadstatustype; -static sadstatusobject *sads_alloc(void); /* Forward */ - -static PyObject *SunAudioError; - -#define is_sadobject(v) ((v)->ob_type == &Sadtype) -#define is_sadstatusobject(v) ((v)->ob_type == &Sadstatustype) - - -static sadobject * -newsadobject(PyObject *args) -{ - sadobject *xp; - int fd; - char *mode; - int imode; - char* basedev; - char* ctldev; - char* opendev; - - /* Check arg for r/w/rw */ - if (!PyArg_ParseTuple(args, "s", &mode)) - return NULL; - if (strcmp(mode, "r") == 0) - imode = 0; - else if (strcmp(mode, "w") == 0) - imode = 1; - else if (strcmp(mode, "rw") == 0) - imode = 2; - else if (strcmp(mode, "control") == 0) - imode = -1; - else { - PyErr_SetString(SunAudioError, - "Mode should be one of 'r', 'w', 'rw' or 'control'"); - return NULL; - } - - /* Open the correct device. The base device name comes from the - * AUDIODEV environment variable first, then /dev/audio. The - * control device tacks "ctl" onto the base device name. - */ - basedev = getenv("AUDIODEV"); - if (!basedev) - basedev = "/dev/audio"; - ctldev = PyMem_NEW(char, strlen(basedev) + 4); - if (!ctldev) { - PyErr_NoMemory(); - return NULL; - } - strcpy(ctldev, basedev); - strcat(ctldev, "ctl"); - - if (imode < 0) { - opendev = ctldev; - fd = open(ctldev, 2); - } - else { - opendev = basedev; - fd = open(basedev, imode); - } - if (fd < 0) { - PyErr_SetFromErrnoWithFilename(SunAudioError, opendev); - PyMem_DEL(ctldev); - return NULL; - } - PyMem_DEL(ctldev); - - /* Create and initialize the object */ - xp = PyObject_New(sadobject, &Sadtype); - if (xp == NULL) { - close(fd); - return NULL; - } - xp->x_fd = fd; - xp->x_icount = xp->x_ocount = 0; - xp->x_isctl = (imode < 0); - - return xp; -} - -/* Sad methods */ - -static void -sad_dealloc(sadobject *xp) -{ - close(xp->x_fd); - PyObject_Del(xp); -} - -static PyObject * -sad_read(sadobject *self, PyObject *args) -{ - int size, count; - char *cp; - PyObject *rv; - - if (!PyArg_ParseTuple(args, "i:read", &size)) - return NULL; - rv = PyString_FromStringAndSize(NULL, size); - if (rv == NULL) - return NULL; - - if (!(cp = PyString_AsString(rv))) - goto finally; - - count = read(self->x_fd, cp, size); - if (count < 0) { - PyErr_SetFromErrno(SunAudioError); - goto finally; - } -#if 0 - /* TBD: why print this message if you can handle the condition? - * assume it's debugging info which we can just as well get rid - * of. in any case this message should *not* be using printf! - */ - if (count != size) - printf("sunaudio: funny read rv %d wtd %d\n", count, size); -#endif - self->x_icount += count; - return rv; - - finally: - Py_DECREF(rv); - return NULL; -} - -static PyObject * -sad_write(sadobject *self, PyObject *args) -{ - char *cp; - int count, size; - - if (!PyArg_ParseTuple(args, "s#:write", &cp, &size)) - return NULL; - - count = write(self->x_fd, cp, size); - if (count < 0) { - PyErr_SetFromErrno(SunAudioError); - return NULL; - } -#if 0 - if (count != size) - printf("sunaudio: funny write rv %d wanted %d\n", count, size); -#endif - self->x_ocount += count; - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -sad_getinfo(sadobject *self) -{ - sadstatusobject *rv; - - if (!(rv = sads_alloc())) - return NULL; - - if (ioctl(self->x_fd, AUDIO_GETINFO, &rv->ai) < 0) { - PyErr_SetFromErrno(SunAudioError); - Py_DECREF(rv); - return NULL; - } - return (PyObject *)rv; -} - -static PyObject * -sad_setinfo(sadobject *self, sadstatusobject *arg) -{ - if (!is_sadstatusobject(arg)) { - PyErr_SetString(PyExc_TypeError, - "Must be sun audio status object"); - return NULL; - } - if (ioctl(self->x_fd, AUDIO_SETINFO, &arg->ai) < 0) { - PyErr_SetFromErrno(SunAudioError); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -sad_ibufcount(sadobject *self) -{ - audio_info_t ai; - - if (ioctl(self->x_fd, AUDIO_GETINFO, &ai) < 0) { - PyErr_SetFromErrno(SunAudioError); - return NULL; - } - return PyInt_FromLong(ai.record.samples - self->x_icount); -} - -static PyObject * -sad_obufcount(sadobject *self) -{ - audio_info_t ai; - - if (ioctl(self->x_fd, AUDIO_GETINFO, &ai) < 0) { - PyErr_SetFromErrno(SunAudioError); - return NULL; - } - /* x_ocount is in bytes, whereas play.samples is in frames */ - /* we want frames */ - return PyInt_FromLong(self->x_ocount / (ai.play.channels * - ai.play.precision / 8) - - ai.play.samples); -} - -static PyObject * -sad_drain(sadobject *self) -{ - if (ioctl(self->x_fd, AUDIO_DRAIN, 0) < 0) { - PyErr_SetFromErrno(SunAudioError); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -#ifdef SOLARIS -static PyObject * -sad_getdev(sadobject *self) -{ - struct audio_device ad; - - if (ioctl(self->x_fd, AUDIO_GETDEV, &ad) < 0) { - PyErr_SetFromErrno(SunAudioError); - return NULL; - } - return Py_BuildValue("(sss)", ad.name, ad.version, ad.config); -} -#endif - -static PyObject * -sad_flush(sadobject *self) -{ - if (ioctl(self->x_fd, I_FLUSH, FLUSHW) < 0) { - PyErr_SetFromErrno(SunAudioError); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -sad_close(sadobject *self) -{ - - if (self->x_fd >= 0) { - close(self->x_fd); - self->x_fd = -1; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -sad_fileno(sadobject *self) -{ - return PyInt_FromLong(self->x_fd); -} - - -static PyMethodDef sad_methods[] = { - { "read", (PyCFunction)sad_read, METH_VARARGS }, - { "write", (PyCFunction)sad_write, METH_VARARGS }, - { "ibufcount", (PyCFunction)sad_ibufcount, METH_NOARGS }, - { "obufcount", (PyCFunction)sad_obufcount, METH_NOARGS }, -#define CTL_METHODS 4 - { "getinfo", (PyCFunction)sad_getinfo, METH_NOARGS }, - { "setinfo", (PyCFunction)sad_setinfo, METH_O}, - { "drain", (PyCFunction)sad_drain, METH_NOARGS }, - { "flush", (PyCFunction)sad_flush, METH_NOARGS }, -#ifdef SOLARIS - { "getdev", (PyCFunction)sad_getdev, METH_NOARGS }, -#endif - { "close", (PyCFunction)sad_close, METH_NOARGS }, - { "fileno", (PyCFunction)sad_fileno, METH_NOARGS }, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -sad_getattr(sadobject *xp, char *name) -{ - if (xp->x_isctl) - return Py_FindMethod(sad_methods+CTL_METHODS, - (PyObject *)xp, name); - else - return Py_FindMethod(sad_methods, (PyObject *)xp, name); -} - -/* ----------------------------------------------------------------- */ - -static sadstatusobject * -sads_alloc(void) { - return PyObject_New(sadstatusobject, &Sadstatustype); -} - -static void -sads_dealloc(sadstatusobject *xp) -{ - PyMem_DEL(xp); -} - -#define OFF(x) offsetof(audio_info_t,x) -static struct memberlist sads_ml[] = { - { "i_sample_rate", T_UINT, OFF(record.sample_rate) }, - { "i_channels", T_UINT, OFF(record.channels) }, - { "i_precision", T_UINT, OFF(record.precision) }, - { "i_encoding", T_UINT, OFF(record.encoding) }, - { "i_gain", T_UINT, OFF(record.gain) }, - { "i_port", T_UINT, OFF(record.port) }, - { "i_samples", T_UINT, OFF(record.samples) }, - { "i_eof", T_UINT, OFF(record.eof) }, - { "i_pause", T_UBYTE, OFF(record.pause) }, - { "i_error", T_UBYTE, OFF(record.error) }, - { "i_waiting", T_UBYTE, OFF(record.waiting) }, - { "i_open", T_UBYTE, OFF(record.open) , RO}, - { "i_active", T_UBYTE, OFF(record.active) , RO}, -#ifdef SOLARIS - { "i_buffer_size", T_UINT, OFF(record.buffer_size) }, - { "i_balance", T_UBYTE, OFF(record.balance) }, - { "i_avail_ports", T_UINT, OFF(record.avail_ports) }, -#endif - - { "o_sample_rate", T_UINT, OFF(play.sample_rate) }, - { "o_channels", T_UINT, OFF(play.channels) }, - { "o_precision", T_UINT, OFF(play.precision) }, - { "o_encoding", T_UINT, OFF(play.encoding) }, - { "o_gain", T_UINT, OFF(play.gain) }, - { "o_port", T_UINT, OFF(play.port) }, - { "o_samples", T_UINT, OFF(play.samples) }, - { "o_eof", T_UINT, OFF(play.eof) }, - { "o_pause", T_UBYTE, OFF(play.pause) }, - { "o_error", T_UBYTE, OFF(play.error) }, - { "o_waiting", T_UBYTE, OFF(play.waiting) }, - { "o_open", T_UBYTE, OFF(play.open) , RO}, - { "o_active", T_UBYTE, OFF(play.active) , RO}, -#ifdef SOLARIS - { "o_buffer_size", T_UINT, OFF(play.buffer_size) }, - { "o_balance", T_UBYTE, OFF(play.balance) }, - { "o_avail_ports", T_UINT, OFF(play.avail_ports) }, -#endif - - { "monitor_gain", T_UINT, OFF(monitor_gain) }, - { NULL, 0, 0}, -}; - -static PyObject * -sads_getattr(sadstatusobject *xp, char *name) -{ - return PyMember_Get((char *)&xp->ai, sads_ml, name); -} - -static int -sads_setattr(sadstatusobject *xp, char *name, PyObject *v) -{ - - if (v == NULL) { - PyErr_SetString(PyExc_TypeError, - "can't delete sun audio status attributes"); - return -1; - } - return PyMember_Set((char *)&xp->ai, sads_ml, name, v); -} - -/* ------------------------------------------------------------------- */ - - -static PyTypeObject Sadtype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "sunaudiodev.sun_audio_device", /*tp_name*/ - sizeof(sadobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)sad_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)sad_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ -}; - -static PyTypeObject Sadstatustype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "sunaudiodev.sun_audio_device_status", /*tp_name*/ - sizeof(sadstatusobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)sads_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)sads_getattr, /*tp_getattr*/ - (setattrfunc)sads_setattr, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ -}; -/* ------------------------------------------------------------------- */ - -static PyObject * -sadopen(PyObject *self, PyObject *args) -{ - return (PyObject *)newsadobject(args); -} - -static PyMethodDef sunaudiodev_methods[] = { - { "open", sadopen, METH_VARARGS }, - { 0, 0 }, -}; - -void -initsunaudiodev(void) -{ - PyObject *m, *d; - - m = Py_InitModule("sunaudiodev", sunaudiodev_methods); - d = PyModule_GetDict(m); - SunAudioError = PyErr_NewException("sunaudiodev.error", NULL, NULL); - if (SunAudioError) - PyDict_SetItemString(d, "error", SunAudioError); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/svmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/svmodule.c deleted file mode 100644 index 303504dc..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/svmodule.c +++ /dev/null @@ -1,964 +0,0 @@ -/* SV module -- interface to the Indigo video board */ - -/* WARNING! This module is for hardware that we don't have any more, - so it hasn't been tested. It has been converted to the new coding - style, and it is possible that this conversion has broken something - -- user beware! */ - -#include -#include -#include "Python.h" -#include "compile.h" -#include "yuv.h" /* for YUV conversion functions */ - -typedef struct { - PyObject_HEAD - SV_nodeP ob_svideo; - svCaptureInfo ob_info; -} svobject; - -typedef struct { - PyObject_HEAD - void *ob_capture; - int ob_mustunlock; - svCaptureInfo ob_info; - svobject *ob_svideo; -} captureobject; - -static PyObject *SvError; /* exception sv.error */ - -static PyObject *newcaptureobject(svobject *, void *, int); - -/* Set a SV-specific error from svideo_errno and return NULL */ -static PyObject * -sv_error(void) -{ - PyErr_SetString(SvError, svStrerror(svideo_errno)); - return NULL; -} - -static PyObject * -svc_conversion(captureobject *self, PyObject *args, void (*function)(), float factor) -{ - PyObject *output; - int invert; - char* outstr; - - if (!PyArg_Parse(args, "i", &invert)) - return NULL; - - if (!(output = PyString_FromStringAndSize( - NULL, - (int)(self->ob_info.width * self->ob_info.height * factor)))) - { - return NULL; - } - if (!(outstr = PyString_AsString(output))) { - Py_DECREF(output); - return NULL; - } - - (*function)((boolean)invert, self->ob_capture, - outstr, - self->ob_info.width, self->ob_info.height); - - return output; -} - -/* - * 3 functions to convert from Starter Video YUV 4:1:1 format to - * Compression Library 4:2:2 Duplicate Chroma format. - */ -static PyObject * -svc_YUVtoYUV422DC(captureobject *self, PyObject *args) -{ - if (self->ob_info.format != SV_YUV411_FRAMES) { - PyErr_SetString(SvError, "data has bad format"); - return NULL; - } - return svc_conversion(self, args, yuv_sv411_to_cl422dc, 2.0); -} - -static PyObject * -svc_YUVtoYUV422DC_quarter(captureobject *self, PyObject *args) -{ - if (self->ob_info.format != SV_YUV411_FRAMES) { - PyErr_SetString(SvError, "data has bad format"); - return NULL; - } - return svc_conversion(self, args, - yuv_sv411_to_cl422dc_quartersize, 0.5); -} - -static PyObject * -svc_YUVtoYUV422DC_sixteenth(captureobject *self, PyObject *args) -{ - if (self->ob_info.format != SV_YUV411_FRAMES) { - PyErr_SetString(SvError, "data has bad format"); - return NULL; - } - return svc_conversion(self, args, - yuv_sv411_to_cl422dc_sixteenthsize, 0.125); -} - -static PyObject * -svc_YUVtoRGB(captureobject *self, PyObject *args) -{ - switch (self->ob_info.format) { - case SV_YUV411_FRAMES: - case SV_YUV411_FRAMES_AND_BLANKING_BUFFER: - break; - default: - PyErr_SetString(SvError, "data had bad format"); - return NULL; - } - return svc_conversion(self, args, svYUVtoRGB, (float) sizeof(long)); -} - -static PyObject * -svc_RGB8toRGB32(captureobject *self, PyObject *args) -{ - if (self->ob_info.format != SV_RGB8_FRAMES) { - PyErr_SetString(SvError, "data has bad format"); - return NULL; - } - return svc_conversion(self, args, svRGB8toRGB32, (float) sizeof(long)); -} - -static PyObject * -svc_InterleaveFields(captureobject *self, PyObject *args) -{ - if (self->ob_info.format != SV_RGB8_FRAMES) { - PyErr_SetString(SvError, "data has bad format"); - return NULL; - } - return svc_conversion(self, args, svInterleaveFields, 1.0); -} - -static PyObject * -svc_GetFields(captureobject *self, PyObject *args) -{ - PyObject *f1 = NULL; - PyObject *f2 = NULL; - PyObject *ret = NULL; - int fieldsize; - char* obcapture; - - if (self->ob_info.format != SV_RGB8_FRAMES) { - PyErr_SetString(SvError, "data has bad format"); - return NULL; - } - - fieldsize = self->ob_info.width * self->ob_info.height / 2; - obcapture = (char*)self->ob_capture; - - if (!(f1 = PyString_FromStringAndSize(obcapture, fieldsize))) - goto finally; - if (!(f2 = PyString_FromStringAndSize(obcapture + fieldsize, - fieldsize))) - goto finally; - ret = Py_BuildValue("(OO)", f1, f2); - - finally: - Py_XDECREF(f1); - Py_XDECREF(f2); - return ret; -} - -static PyObject * -svc_UnlockCaptureData(captureobject *self, PyObject *args) -{ - if (!PyArg_Parse(args, "")) - return NULL; - - if (!self->ob_mustunlock) { - PyErr_SetString(SvError, "buffer should not be unlocked"); - return NULL; - } - - if (svUnlockCaptureData(self->ob_svideo->ob_svideo, self->ob_capture)) - return sv_error(); - - self->ob_mustunlock = 0; - - Py_INCREF(Py_None); - return Py_None; -} - -#ifdef USE_GL -#include - -static PyObject * -svc_lrectwrite(captureobject *self, PyObject *args) -{ - Screencoord x1, x2, y1, y2; - - if (!PyArg_Parse(args, "(hhhh)", &x1, &x2, &y1, &y2)) - return NULL; - - lrectwrite(x1, x2, y1, y2, (unsigned long *) self->ob_capture); - - Py_INCREF(Py_None); - return Py_None; -} -#endif - -static PyObject * -svc_writefile(captureobject *self, PyObject *args) -{ - PyObject *file; - int size; - FILE* fp; - - if (!PyArg_Parse(args, "O", &file)) - return NULL; - - if (!PyFile_Check(file)) { - PyErr_SetString(SvError, "not a file object"); - return NULL; - } - - if (!(fp = PyFile_AsFile(file))) - return NULL; - - size = self->ob_info.width * self->ob_info.height; - - if (fwrite(self->ob_capture, sizeof(long), size, fp) != size) { - PyErr_SetString(SvError, "writing failed"); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -svc_FindVisibleRegion(captureobject *self, PyObject *args) -{ - void *visible; - int width; - - if (!PyArg_Parse(args, "")) - return NULL; - - if (svFindVisibleRegion(self->ob_svideo->ob_svideo, - self->ob_capture, &visible, - self->ob_info.width)) - return sv_error(); - - if (visible == NULL) { - PyErr_SetString(SvError, "data in wrong format"); - return NULL; - } - - return newcaptureobject(self->ob_svideo, visible, 0); -} - -static PyMethodDef capture_methods[] = { - {"YUVtoRGB", (PyCFunction)svc_YUVtoRGB, METH_OLDARGS}, - {"RGB8toRGB32", (PyCFunction)svc_RGB8toRGB32, METH_OLDARGS}, - {"InterleaveFields", (PyCFunction)svc_InterleaveFields, METH_OLDARGS}, - {"UnlockCaptureData", (PyCFunction)svc_UnlockCaptureData, METH_OLDARGS}, - {"FindVisibleRegion", (PyCFunction)svc_FindVisibleRegion, METH_OLDARGS}, - {"GetFields", (PyCFunction)svc_GetFields, METH_OLDARGS}, - {"YUVtoYUV422DC", (PyCFunction)svc_YUVtoYUV422DC, METH_OLDARGS}, - {"YUVtoYUV422DC_quarter",(PyCFunction)svc_YUVtoYUV422DC_quarter, METH_OLDARGS}, - {"YUVtoYUV422DC_sixteenth",(PyCFunction)svc_YUVtoYUV422DC_sixteenth, METH_OLDARGS}, -#ifdef USE_GL - {"lrectwrite", (PyCFunction)svc_lrectwrite, METH_OLDARGS}, -#endif - {"writefile", (PyCFunction)svc_writefile, METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - -static void -capture_dealloc(captureobject *self) -{ - if (self->ob_capture != NULL) { - if (self->ob_mustunlock) - (void)svUnlockCaptureData(self->ob_svideo->ob_svideo, - self->ob_capture); - self->ob_capture = NULL; - Py_DECREF(self->ob_svideo); - self->ob_svideo = NULL; - } - PyObject_Del(self); -} - -static PyObject * -capture_getattr(svobject *self, char *name) -{ - return Py_FindMethod(capture_methods, (PyObject *)self, name); -} - -PyTypeObject Capturetype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "sv.capture", /*tp_name*/ - sizeof(captureobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)capture_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)capture_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ -}; - -static PyObject * -newcaptureobject(svobject *self, void *ptr, int mustunlock) -{ - captureobject *p; - - p = PyObject_New(captureobject, &Capturetype); - if (p == NULL) - return NULL; - p->ob_svideo = self; - Py_INCREF(self); - p->ob_capture = ptr; - p->ob_mustunlock = mustunlock; - p->ob_info = self->ob_info; - return (PyObject *) p; -} - -static PyObject * -sv_GetCaptureData(svobject *self, PyObject *args) -{ - void *ptr; - long fieldID; - PyObject *res, *c; - - if (!PyArg_Parse(args, "")) - return NULL; - - if (svGetCaptureData(self->ob_svideo, &ptr, &fieldID)) - return sv_error(); - - if (ptr == NULL) { - PyErr_SetString(SvError, "no data available"); - return NULL; - } - - c = newcaptureobject(self, ptr, 1); - if (c == NULL) - return NULL; - res = Py_BuildValue("(Oi)", c, fieldID); - Py_DECREF(c); - return res; -} - -static PyObject * -sv_BindGLWindow(svobject *self, PyObject *args) -{ - long wid; - int mode; - - if (!PyArg_Parse(args, "(ii)", &wid, &mode)) - return NULL; - - if (svBindGLWindow(self->ob_svideo, wid, mode)) - return sv_error(); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -sv_EndContinuousCapture(svobject *self, PyObject *args) -{ - - if (!PyArg_Parse(args, "")) - return NULL; - - if (svEndContinuousCapture(self->ob_svideo)) - return sv_error(); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -sv_IsVideoDisplayed(svobject *self, PyObject *args) -{ - int v; - - if (!PyArg_Parse(args, "")) - return NULL; - - v = svIsVideoDisplayed(self->ob_svideo); - if (v == -1) - return sv_error(); - - return PyInt_FromLong((long) v); -} - -static PyObject * -sv_OutputOffset(svobject *self, PyObject *args) -{ - int x_offset; - int y_offset; - - if (!PyArg_Parse(args, "(ii)", &x_offset, &y_offset)) - return NULL; - - if (svOutputOffset(self->ob_svideo, x_offset, y_offset)) - return sv_error(); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -sv_PutFrame(svobject *self, PyObject *args) -{ - char *buffer; - - if (!PyArg_Parse(args, "s", &buffer)) - return NULL; - - if (svPutFrame(self->ob_svideo, buffer)) - return sv_error(); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -sv_QuerySize(svobject *self, PyObject *args) -{ - int w; - int h; - int rw; - int rh; - - if (!PyArg_Parse(args, "(ii)", &w, &h)) - return NULL; - - if (svQuerySize(self->ob_svideo, w, h, &rw, &rh)) - return sv_error(); - - return Py_BuildValue("(ii)", (long) rw, (long) rh); -} - -static PyObject * -sv_SetSize(svobject *self, PyObject *args) -{ - int w; - int h; - - if (!PyArg_Parse(args, "(ii)", &w, &h)) - return NULL; - - if (svSetSize(self->ob_svideo, w, h)) - return sv_error(); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -sv_SetStdDefaults(svobject *self, PyObject *args) -{ - - if (!PyArg_Parse(args, "")) - return NULL; - - if (svSetStdDefaults(self->ob_svideo)) - return sv_error(); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -sv_UseExclusive(svobject *self, PyObject *args) -{ - boolean onoff; - int mode; - - if (!PyArg_Parse(args, "(ii)", &onoff, &mode)) - return NULL; - - if (svUseExclusive(self->ob_svideo, onoff, mode)) - return sv_error(); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -sv_WindowOffset(svobject *self, PyObject *args) -{ - int x_offset; - int y_offset; - - if (!PyArg_Parse(args, "(ii)", &x_offset, &y_offset)) - return NULL; - - if (svWindowOffset(self->ob_svideo, x_offset, y_offset)) - return sv_error(); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -sv_CaptureBurst(svobject *self, PyObject *args) -{ - int bytes, i; - svCaptureInfo info; - void *bitvector = NULL; - PyObject *videodata = NULL; - PyObject *bitvecobj = NULL; - PyObject *res = NULL; - static PyObject *evenitem, *odditem; - - if (!PyArg_Parse(args, "(iiiii)", &info.format, - &info.width, &info.height, - &info.size, &info.samplingrate)) - return NULL; - - switch (info.format) { - case SV_RGB8_FRAMES: - bitvector = malloc(SV_BITVEC_SIZE(info.size)); - break; - case SV_YUV411_FRAMES_AND_BLANKING_BUFFER: - break; - default: - PyErr_SetString(SvError, "illegal format specified"); - return NULL; - } - - if (svQueryCaptureBufferSize(self->ob_svideo, &info, &bytes)) { - res = sv_error(); - goto finally; - } - - if (!(videodata = PyString_FromStringAndSize(NULL, bytes))) - goto finally; - - /* XXX -- need to do something about the bitvector */ - { - char* str = PyString_AsString(videodata); - if (!str) - goto finally; - - if (svCaptureBurst(self->ob_svideo, &info, str, bitvector)) { - res = sv_error(); - goto finally; - } - } - - if (bitvector) { - if (evenitem == NULL) { - if (!(evenitem = PyInt_FromLong(0))) - goto finally; - } - if (odditem == NULL) { - if (!(odditem = PyInt_FromLong(1))) - goto finally; - } - if (!(bitvecobj = PyTuple_New(2 * info.size))) - goto finally; - - for (i = 0; i < 2 * info.size; i++) { - int sts; - - if (SV_GET_FIELD(bitvector, i) == SV_EVEN_FIELD) { - Py_INCREF(evenitem); - sts = PyTuple_SetItem(bitvecobj, i, evenitem); - } else { - Py_INCREF(odditem); - sts = PyTuple_SetItem(bitvecobj, i, odditem); - } - if (sts < 0) - goto finally; - } - } else { - bitvecobj = Py_None; - Py_INCREF(Py_None); - } - - res = Py_BuildValue("((iiiii)OO)", info.format, - info.width, info.height, - info.size, info.samplingrate, - videodata, bitvecobj); - - finally: - if (bitvector) - free(bitvector); - - Py_XDECREF(videodata); - Py_XDECREF(bitvecobj); - return res; -} - -static PyObject * -sv_CaptureOneFrame(svobject *self, PyObject *args) -{ - svCaptureInfo info; - int format, width, height; - int bytes; - PyObject *videodata = NULL; - PyObject *res = NULL; - char *str; - - if (!PyArg_Parse(args, "(iii)", &format, &width, &height)) - return NULL; - - info.format = format; - info.width = width; - info.height = height; - info.size = 0; - info.samplingrate = 0; - if (svQueryCaptureBufferSize(self->ob_svideo, &info, &bytes)) - return sv_error(); - - if (!(videodata = PyString_FromStringAndSize(NULL, bytes))) - return NULL; - - str = PyString_AsString(videodata); - if (!str) - goto finally; - - if (svCaptureOneFrame(self->ob_svideo, format, &width, &height, str)) { - res = sv_error(); - goto finally; - } - - res = Py_BuildValue("(iiO)", width, height, videodata); - - finally: - Py_XDECREF(videodata); - return res; -} - -static PyObject * -sv_InitContinuousCapture(svobject *self, PyObject *args) -{ - svCaptureInfo info; - - if (!PyArg_Parse(args, "(iiiii)", &info.format, - &info.width, &info.height, - &info.size, &info.samplingrate)) - return NULL; - - if (svInitContinuousCapture(self->ob_svideo, &info)) - return sv_error(); - - self->ob_info = info; - - return Py_BuildValue("(iiiii)", info.format, info.width, info.height, - info.size, info.samplingrate); -} - -static PyObject * -sv_LoadMap(svobject *self, PyObject *args) -{ - PyObject *rgb; - PyObject *res = NULL; - rgb_tuple *mapp = NULL; - int maptype; - int i, j; /* indices */ - - if (!PyArg_Parse(args, "(iO)", &maptype, &rgb)) - return NULL; - - if (!PyList_Check(rgb) || PyList_Size(rgb) != 256) { - PyErr_BadArgument(); - return NULL; - } - - if (!(mapp = PyMem_NEW(rgb_tuple, 256))) - return PyErr_NoMemory(); - - for (i = 0; i < 256; i++) { - PyObject* v = PyList_GetItem(rgb, i); - if (!v) - goto finally; - - if (!PyTuple_Check(v) || PyTuple_Size(v) != 3) { - PyErr_BadArgument(); - goto finally; - } - for (j = 0; j < 3; j++) { - PyObject* cell = PyTuple_GetItem(v, j); - if (!cell) - goto finally; - - if (!PyInt_Check(cell)) { - PyErr_BadArgument(); - goto finally; - } - switch (j) { - case 0: mapp[i].red = PyInt_AsLong(cell); break; - case 1: mapp[i].blue = PyInt_AsLong(cell); break; - case 2: mapp[i].green = PyInt_AsLong(cell); break; - } - if (PyErr_Occurred()) - goto finally; - } - } - - if (svLoadMap(self->ob_svideo, maptype, mapp)) { - res = sv_error(); - goto finally; - } - - Py_INCREF(Py_None); - res = Py_None; - - finally: - PyMem_DEL(mapp); - return res; -} - -static PyObject * -sv_CloseVideo(svobject *self, PyObject *args) -{ - if (!PyArg_Parse(args, "")) - return NULL; - - if (svCloseVideo(self->ob_svideo)) - return sv_error(); - - self->ob_svideo = NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -doParams(svobject *self, PyObject *args, - int (*func)(SV_nodeP, long *, int), int modified) -{ - PyObject *list; - PyObject *res = NULL; - long *PVbuffer = NULL; - long length; - int i; - - if (!PyArg_Parse(args, "O", &list)) - return NULL; - - if (!PyList_Check(list)) { - PyErr_BadArgument(); - return NULL; - } - - if ((length = PyList_Size(list)) < 0) - return NULL; - - PVbuffer = PyMem_NEW(long, length); - if (PVbuffer == NULL) - return PyErr_NoMemory(); - - for (i = 0; i < length; i++) { - PyObject *v = PyList_GetItem(list, i); - if (!v) - goto finally; - - if (!PyInt_Check(v)) { - PyErr_BadArgument(); - goto finally; - } - PVbuffer[i] = PyInt_AsLong(v); - /* can't just test the return value, because what if the - value was -1?! - */ - if (PVbuffer[i] == -1 && PyErr_Occurred()) - goto finally; - } - - if ((*func)(self->ob_svideo, PVbuffer, length)) { - res = sv_error(); - goto finally; - } - - if (modified) { - for (i = 0; i < length; i++) { - PyObject* v = PyInt_FromLong(PVbuffer[i]); - if (!v || PyList_SetItem(list, i, v) < 0) - goto finally; - } - } - - Py_INCREF(Py_None); - res = Py_None; - - finally: - PyMem_DEL(PVbuffer); - return res; -} - -static PyObject * -sv_GetParam(PyObject *self, PyObject *args) -{ - return doParams(self, args, svGetParam, 1); -} - -static PyObject * -sv_GetParamRange(PyObject *self, PyObject *args) -{ - return doParams(self, args, svGetParamRange, 1); -} - -static PyObject * -sv_SetParam(PyObject *self, PyObject *args) -{ - return doParams(self, args, svSetParam, 0); -} - -static PyMethodDef svideo_methods[] = { - {"BindGLWindow", (PyCFunction)sv_BindGLWindow, METH_OLDARGS}, - {"EndContinuousCapture",(PyCFunction)sv_EndContinuousCapture, METH_OLDARGS}, - {"IsVideoDisplayed", (PyCFunction)sv_IsVideoDisplayed, METH_OLDARGS}, - {"OutputOffset", (PyCFunction)sv_OutputOffset, METH_OLDARGS}, - {"PutFrame", (PyCFunction)sv_PutFrame, METH_OLDARGS}, - {"QuerySize", (PyCFunction)sv_QuerySize, METH_OLDARGS}, - {"SetSize", (PyCFunction)sv_SetSize, METH_OLDARGS}, - {"SetStdDefaults", (PyCFunction)sv_SetStdDefaults, METH_OLDARGS}, - {"UseExclusive", (PyCFunction)sv_UseExclusive, METH_OLDARGS}, - {"WindowOffset", (PyCFunction)sv_WindowOffset, METH_OLDARGS}, - {"InitContinuousCapture",(PyCFunction)sv_InitContinuousCapture, METH_OLDARGS}, - {"CaptureBurst", (PyCFunction)sv_CaptureBurst, METH_OLDARGS}, - {"CaptureOneFrame", (PyCFunction)sv_CaptureOneFrame, METH_OLDARGS}, - {"GetCaptureData", (PyCFunction)sv_GetCaptureData, METH_OLDARGS}, - {"CloseVideo", (PyCFunction)sv_CloseVideo, METH_OLDARGS}, - {"LoadMap", (PyCFunction)sv_LoadMap, METH_OLDARGS}, - {"GetParam", (PyCFunction)sv_GetParam, METH_OLDARGS}, - {"GetParamRange", (PyCFunction)sv_GetParamRange, METH_OLDARGS}, - {"SetParam", (PyCFunction)sv_SetParam, METH_OLDARGS}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -sv_conversion(PyObject *self, PyObject *args, void (*function)(), - int inputfactor, float factor) -{ - int invert, width, height, inputlength; - char *input, *str; - PyObject *output; - - if (!PyArg_Parse(args, "(is#ii)", &invert, - &input, &inputlength, &width, &height)) - return NULL; - - if (width * height * inputfactor > inputlength) { - PyErr_SetString(SvError, "input buffer not long enough"); - return NULL; - } - - if (!(output = PyString_FromStringAndSize(NULL, - (int)(width * height * factor)))) - return NULL; - - str = PyString_AsString(output); - if (!str) { - Py_DECREF(output); - return NULL; - } - (*function)(invert, input, str, width, height); - - return output; -} - -static PyObject * -sv_InterleaveFields(PyObject *self, PyObject *args) -{ - return sv_conversion(self, args, svInterleaveFields, 1, 1.0); -} - -static PyObject * -sv_RGB8toRGB32(PyObject *self, PyObject *args) -{ - return sv_conversion(self, args, svRGB8toRGB32, 1, (float) sizeof(long)); -} - -static PyObject * -sv_YUVtoRGB(PyObject *self, PyObject *args) -{ - return sv_conversion(self, args, svYUVtoRGB, 2, (float) sizeof(long)); -} - -static void -svideo_dealloc(svobject *self) -{ - if (self->ob_svideo != NULL) - (void) svCloseVideo(self->ob_svideo); - PyObject_Del(self); -} - -static PyObject * -svideo_getattr(svobject *self, char *name) -{ - return Py_FindMethod(svideo_methods, (PyObject *)self, name); -} - -PyTypeObject Svtype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "sv.sv", /*tp_name*/ - sizeof(svobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)svideo_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)svideo_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ -}; - -static PyObject * -newsvobject(SV_nodeP svp) -{ - svobject *p; - - p = PyObject_New(svobject, &Svtype); - if (p == NULL) - return NULL; - p->ob_svideo = svp; - p->ob_info.format = 0; - p->ob_info.size = 0; - p->ob_info.width = 0; - p->ob_info.height = 0; - p->ob_info.samplingrate = 0; - return (PyObject *) p; -} - -static PyObject * -sv_OpenVideo(PyObject *self, PyObject *args) -{ - SV_nodeP svp; - - if (!PyArg_Parse(args, "")) - return NULL; - - svp = svOpenVideo(); - if (svp == NULL) - return sv_error(); - - return newsvobject(svp); -} - -static PyMethodDef sv_methods[] = { - {"InterleaveFields", (PyCFunction)sv_InterleaveFields, METH_OLDARGS}, - {"RGB8toRGB32", (PyCFunction)sv_RGB8toRGB32, METH_OLDARGS}, - {"YUVtoRGB", (PyCFunction)sv_YUVtoRGB, METH_OLDARGS}, - {"OpenVideo", (PyCFunction)sv_OpenVideo, METH_OLDARGS}, - {NULL, NULL} /* Sentinel */ -}; - -void -initsv(void) -{ - PyObject *m, *d; - - m = Py_InitModule("sv", sv_methods); - d = PyModule_GetDict(m); - - SvError = PyErr_NewException("sv.error", NULL, NULL); - if (SvError == NULL || PyDict_SetItemString(d, "error", SvError) != 0) - return; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/symtablemodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/symtablemodule.c deleted file mode 100644 index fd613943..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/symtablemodule.c +++ /dev/null @@ -1,79 +0,0 @@ -#include "Python.h" - -#include "compile.h" -#include "symtable.h" - -static PyObject * -symtable_symtable(PyObject *self, PyObject *args) -{ - struct symtable *st; - PyObject *t; - - char *str; - char *filename; - char *startstr; - int start; - - if (!PyArg_ParseTuple(args, "sss:symtable", &str, &filename, - &startstr)) - return NULL; - if (strcmp(startstr, "exec") == 0) - start = Py_file_input; - else if (strcmp(startstr, "eval") == 0) - start = Py_eval_input; - else if (strcmp(startstr, "single") == 0) - start = Py_single_input; - else { - PyErr_SetString(PyExc_ValueError, - "symtable() arg 3 must be 'exec' or 'eval' or 'single'"); - return NULL; - } - st = Py_SymtableString(str, filename, start); - if (st == NULL) - return NULL; - t = Py_BuildValue("O", st->st_symbols); - PyMem_Free((void *)st->st_future); - PySymtable_Free(st); - return t; -} - -static PyMethodDef symtable_methods[] = { - {"symtable", symtable_symtable, METH_VARARGS, - PyDoc_STR("Return symbol and scope dictionaries" - " used internally by compiler.")}, - {NULL, NULL} /* sentinel */ -}; - -PyMODINIT_FUNC -init_symtable(void) -{ - PyObject *m; - - m = Py_InitModule("_symtable", symtable_methods); - PyModule_AddIntConstant(m, "USE", USE); - PyModule_AddIntConstant(m, "DEF_GLOBAL", DEF_GLOBAL); - PyModule_AddIntConstant(m, "DEF_LOCAL", DEF_LOCAL); - PyModule_AddIntConstant(m, "DEF_PARAM", DEF_PARAM); - PyModule_AddIntConstant(m, "DEF_STAR", DEF_STAR); - PyModule_AddIntConstant(m, "DEF_DOUBLESTAR", DEF_DOUBLESTAR); - PyModule_AddIntConstant(m, "DEF_INTUPLE", DEF_INTUPLE); - PyModule_AddIntConstant(m, "DEF_FREE", DEF_FREE); - PyModule_AddIntConstant(m, "DEF_FREE_GLOBAL", DEF_FREE_GLOBAL); - PyModule_AddIntConstant(m, "DEF_FREE_CLASS", DEF_FREE_CLASS); - PyModule_AddIntConstant(m, "DEF_IMPORT", DEF_IMPORT); - PyModule_AddIntConstant(m, "DEF_BOUND", DEF_BOUND); - - PyModule_AddIntConstant(m, "TYPE_FUNCTION", TYPE_FUNCTION); - PyModule_AddIntConstant(m, "TYPE_CLASS", TYPE_CLASS); - PyModule_AddIntConstant(m, "TYPE_MODULE", TYPE_MODULE); - - PyModule_AddIntConstant(m, "OPT_IMPORT_STAR", OPT_IMPORT_STAR); - PyModule_AddIntConstant(m, "OPT_EXEC", OPT_EXEC); - PyModule_AddIntConstant(m, "OPT_BARE_EXEC", OPT_BARE_EXEC); - - PyModule_AddIntConstant(m, "LOCAL", LOCAL); - PyModule_AddIntConstant(m, "GLOBAL_EXPLICIT", GLOBAL_EXPLICIT); - PyModule_AddIntConstant(m, "GLOBAL_IMPLICIT", GLOBAL_IMPLICIT); - PyModule_AddIntConstant(m, "FREE", FREE); - PyModule_AddIntConstant(m, "CELL", CELL); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/syslogmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/syslogmodule.c deleted file mode 100644 index 97b7b1c1..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/syslogmodule.c +++ /dev/null @@ -1,222 +0,0 @@ -/*********************************************************** -Copyright 1994 by Lance Ellinghouse, -Cathedral City, California Republic, United States of America. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Lance Ellinghouse -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL LANCE ELLINGHOUSE BE LIABLE FOR ANY SPECIAL, -INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING -FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, -NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/****************************************************************** - -Revision history: - -1998/04/28 (Sean Reifschneider) - - When facility not specified to syslog() method, use default from openlog() - (This is how it was claimed to work in the documentation) - - Potential resource leak of o_ident, now cleaned up in closelog() - - Minor comment accuracy fix. - -95/06/29 (Steve Clift) - - Changed arg parsing to use PyArg_ParseTuple. - - Added PyErr_Clear() call(s) where needed. - - Fix core dumps if user message contains format specifiers. - - Change openlog arg defaults to match normal syslog behavior. - - Plug memory leak in openlog(). - - Fix setlogmask() to return previous mask value. - -******************************************************************/ - -/* syslog module */ - -#include "Python.h" - -#include - -/* only one instance, only one syslog, so globals should be ok */ -static PyObject *S_ident_o = NULL; /* identifier, held by openlog() */ - - -static PyObject * -syslog_openlog(PyObject * self, PyObject * args) -{ - long logopt = 0; - long facility = LOG_USER; - - - Py_XDECREF(S_ident_o); - if (!PyArg_ParseTuple(args, - "S|ll;ident string [, logoption [, facility]]", - &S_ident_o, &logopt, &facility)) - return NULL; - - /* This is needed because openlog() does NOT make a copy - * and syslog() later uses it.. cannot trash it. - */ - Py_INCREF(S_ident_o); - - openlog(PyString_AsString(S_ident_o), logopt, facility); - - Py_INCREF(Py_None); - return Py_None; -} - - -static PyObject * -syslog_syslog(PyObject * self, PyObject * args) -{ - char *message; - int priority = LOG_INFO; - - if (!PyArg_ParseTuple(args, "is;[priority,] message string", - &priority, &message)) { - PyErr_Clear(); - if (!PyArg_ParseTuple(args, "s;[priority,] message string", - &message)) - return NULL; - } - - syslog(priority, "%s", message); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -syslog_closelog(PyObject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":closelog")) - return NULL; - closelog(); - Py_XDECREF(S_ident_o); - S_ident_o = NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -syslog_setlogmask(PyObject *self, PyObject *args) -{ - long maskpri, omaskpri; - - if (!PyArg_ParseTuple(args, "l;mask for priority", &maskpri)) - return NULL; - omaskpri = setlogmask(maskpri); - return PyInt_FromLong(omaskpri); -} - -static PyObject * -syslog_log_mask(PyObject *self, PyObject *args) -{ - long mask; - long pri; - if (!PyArg_ParseTuple(args, "l:LOG_MASK", &pri)) - return NULL; - mask = LOG_MASK(pri); - return PyInt_FromLong(mask); -} - -static PyObject * -syslog_log_upto(PyObject *self, PyObject *args) -{ - long mask; - long pri; - if (!PyArg_ParseTuple(args, "l:LOG_UPTO", &pri)) - return NULL; - mask = LOG_UPTO(pri); - return PyInt_FromLong(mask); -} - -/* List of functions defined in the module */ - -static PyMethodDef syslog_methods[] = { - {"openlog", syslog_openlog, METH_VARARGS}, - {"closelog", syslog_closelog, METH_VARARGS}, - {"syslog", syslog_syslog, METH_VARARGS}, - {"setlogmask", syslog_setlogmask, METH_VARARGS}, - {"LOG_MASK", syslog_log_mask, METH_VARARGS}, - {"LOG_UPTO", syslog_log_upto, METH_VARARGS}, - {NULL, NULL, 0} -}; - -/* Initialization function for the module */ - -PyMODINIT_FUNC -initsyslog(void) -{ - PyObject *m; - - /* Create the module and add the functions */ - m = Py_InitModule("syslog", syslog_methods); - - /* Add some symbolic constants to the module */ - - /* Priorities */ - PyModule_AddIntConstant(m, "LOG_EMERG", LOG_EMERG); - PyModule_AddIntConstant(m, "LOG_ALERT", LOG_ALERT); - PyModule_AddIntConstant(m, "LOG_CRIT", LOG_CRIT); - PyModule_AddIntConstant(m, "LOG_ERR", LOG_ERR); - PyModule_AddIntConstant(m, "LOG_WARNING", LOG_WARNING); - PyModule_AddIntConstant(m, "LOG_NOTICE", LOG_NOTICE); - PyModule_AddIntConstant(m, "LOG_INFO", LOG_INFO); - PyModule_AddIntConstant(m, "LOG_DEBUG", LOG_DEBUG); - - /* openlog() option flags */ - PyModule_AddIntConstant(m, "LOG_PID", LOG_PID); - PyModule_AddIntConstant(m, "LOG_CONS", LOG_CONS); - PyModule_AddIntConstant(m, "LOG_NDELAY", LOG_NDELAY); -#ifdef LOG_NOWAIT - PyModule_AddIntConstant(m, "LOG_NOWAIT", LOG_NOWAIT); -#endif -#ifdef LOG_PERROR - PyModule_AddIntConstant(m, "LOG_PERROR", LOG_PERROR); -#endif - - /* Facilities */ - PyModule_AddIntConstant(m, "LOG_KERN", LOG_KERN); - PyModule_AddIntConstant(m, "LOG_USER", LOG_USER); - PyModule_AddIntConstant(m, "LOG_MAIL", LOG_MAIL); - PyModule_AddIntConstant(m, "LOG_DAEMON", LOG_DAEMON); - PyModule_AddIntConstant(m, "LOG_AUTH", LOG_AUTH); - PyModule_AddIntConstant(m, "LOG_LPR", LOG_LPR); - PyModule_AddIntConstant(m, "LOG_LOCAL0", LOG_LOCAL0); - PyModule_AddIntConstant(m, "LOG_LOCAL1", LOG_LOCAL1); - PyModule_AddIntConstant(m, "LOG_LOCAL2", LOG_LOCAL2); - PyModule_AddIntConstant(m, "LOG_LOCAL3", LOG_LOCAL3); - PyModule_AddIntConstant(m, "LOG_LOCAL4", LOG_LOCAL4); - PyModule_AddIntConstant(m, "LOG_LOCAL5", LOG_LOCAL5); - PyModule_AddIntConstant(m, "LOG_LOCAL6", LOG_LOCAL6); - PyModule_AddIntConstant(m, "LOG_LOCAL7", LOG_LOCAL7); - -#ifndef LOG_SYSLOG -#define LOG_SYSLOG LOG_DAEMON -#endif -#ifndef LOG_NEWS -#define LOG_NEWS LOG_MAIL -#endif -#ifndef LOG_UUCP -#define LOG_UUCP LOG_MAIL -#endif -#ifndef LOG_CRON -#define LOG_CRON LOG_DAEMON -#endif - - PyModule_AddIntConstant(m, "LOG_SYSLOG", LOG_SYSLOG); - PyModule_AddIntConstant(m, "LOG_CRON", LOG_CRON); - PyModule_AddIntConstant(m, "LOG_UUCP", LOG_UUCP); - PyModule_AddIntConstant(m, "LOG_NEWS", LOG_NEWS); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/termios.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/termios.c deleted file mode 100644 index 491bbb5b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/termios.c +++ /dev/null @@ -1,924 +0,0 @@ -/* termiosmodule.c -- POSIX terminal I/O module implementation. */ - -#include "Python.h" - -#define PyInit_termios inittermios - -/* Apparently, on SGI, termios.h won't define CTRL if _XOPEN_SOURCE - is defined, so we define it here. */ -#if defined(__sgi) -#define CTRL(c) ((c)&037) -#endif - -#include -#ifdef __osf__ -/* On OSF, sys/ioctl.h requires that struct termio already be defined, - * so this needs to be included first on that platform. */ -#include -#endif -#include - -/* HP-UX requires that this be included to pick up MDCD, MCTS, MDSR, - * MDTR, MRI, and MRTS (appearantly used internally by some things - * defined as macros; these are not used here directly). - */ -#ifdef HAVE_SYS_MODEM_H -#include -#endif -/* HP-UX requires that this be included to pick up TIOCGPGRP and friends */ -#ifdef HAVE_SYS_BSDTTY_H -#include -#endif - -PyDoc_STRVAR(termios__doc__, -"This module provides an interface to the Posix calls for tty I/O control.\n\ -For a complete description of these calls, see the Posix or Unix manual\n\ -pages. It is only available for those Unix versions that support Posix\n\ -termios style tty I/O control.\n\ -\n\ -All functions in this module take a file descriptor fd as their first\n\ -argument. This can be an integer file descriptor, such as returned by\n\ -sys.stdin.fileno(), or a file object, such as sys.stdin itself."); - -static PyObject *TermiosError; - -static int fdconv(PyObject* obj, void* p) -{ - int fd; - - fd = PyObject_AsFileDescriptor(obj); - if (fd >= 0) { - *(int*)p = fd; - return 1; - } - return 0; -} - -PyDoc_STRVAR(termios_tcgetattr__doc__, -"tcgetattr(fd) -> list_of_attrs\n\ -\n\ -Get the tty attributes for file descriptor fd, as follows:\n\ -[iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list\n\ -of the tty special characters (each a string of length 1, except the items\n\ -with indices VMIN and VTIME, which are integers when these fields are\n\ -defined). The interpretation of the flags and the speeds as well as the\n\ -indexing in the cc array must be done using the symbolic constants defined\n\ -in this module."); - -static PyObject * -termios_tcgetattr(PyObject *self, PyObject *args) -{ - int fd; - struct termios mode; - PyObject *cc; - speed_t ispeed, ospeed; - PyObject *v; - int i; - char ch; - - if (!PyArg_ParseTuple(args, "O&:tcgetattr", - fdconv, (void*)&fd)) - return NULL; - - if (tcgetattr(fd, &mode) == -1) - return PyErr_SetFromErrno(TermiosError); - - ispeed = cfgetispeed(&mode); - ospeed = cfgetospeed(&mode); - - cc = PyList_New(NCCS); - if (cc == NULL) - return NULL; - for (i = 0; i < NCCS; i++) { - ch = (char)mode.c_cc[i]; - v = PyString_FromStringAndSize(&ch, 1); - if (v == NULL) - goto err; - PyList_SetItem(cc, i, v); - } - - /* Convert the MIN and TIME slots to integer. On some systems, the - MIN and TIME slots are the same as the EOF and EOL slots. So we - only do this in noncanonical input mode. */ - if ((mode.c_lflag & ICANON) == 0) { - v = PyInt_FromLong((long)mode.c_cc[VMIN]); - if (v == NULL) - goto err; - PyList_SetItem(cc, VMIN, v); - v = PyInt_FromLong((long)mode.c_cc[VTIME]); - if (v == NULL) - goto err; - PyList_SetItem(cc, VTIME, v); - } - - if (!(v = PyList_New(7))) - goto err; - - PyList_SetItem(v, 0, PyInt_FromLong((long)mode.c_iflag)); - PyList_SetItem(v, 1, PyInt_FromLong((long)mode.c_oflag)); - PyList_SetItem(v, 2, PyInt_FromLong((long)mode.c_cflag)); - PyList_SetItem(v, 3, PyInt_FromLong((long)mode.c_lflag)); - PyList_SetItem(v, 4, PyInt_FromLong((long)ispeed)); - PyList_SetItem(v, 5, PyInt_FromLong((long)ospeed)); - PyList_SetItem(v, 6, cc); - if (PyErr_Occurred()){ - Py_DECREF(v); - goto err; - } - return v; - err: - Py_DECREF(cc); - return NULL; -} - -PyDoc_STRVAR(termios_tcsetattr__doc__, -"tcsetattr(fd, when, attributes) -> None\n\ -\n\ -Set the tty attributes for file descriptor fd.\n\ -The attributes to be set are taken from the attributes argument, which\n\ -is a list like the one returned by tcgetattr(). The when argument\n\ -determines when the attributes are changed: termios.TCSANOW to\n\ -change immediately, termios.TCSADRAIN to change after transmitting all\n\ -queued output, or termios.TCSAFLUSH to change after transmitting all\n\ -queued output and discarding all queued input. "); - -static PyObject * -termios_tcsetattr(PyObject *self, PyObject *args) -{ - int fd, when; - struct termios mode; - speed_t ispeed, ospeed; - PyObject *term, *cc, *v; - int i; - - if (!PyArg_ParseTuple(args, "O&iO:tcsetattr", - fdconv, &fd, &when, &term)) - return NULL; - if (!PyList_Check(term) || PyList_Size(term) != 7) { - PyErr_SetString(PyExc_TypeError, - "tcsetattr, arg 3: must be 7 element list"); - return NULL; - } - - /* Get the old mode, in case there are any hidden fields... */ - if (tcgetattr(fd, &mode) == -1) - return PyErr_SetFromErrno(TermiosError); - mode.c_iflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 0)); - mode.c_oflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 1)); - mode.c_cflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 2)); - mode.c_lflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 3)); - ispeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 4)); - ospeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 5)); - cc = PyList_GetItem(term, 6); - if (PyErr_Occurred()) - return NULL; - - if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) { - PyErr_Format(PyExc_TypeError, - "tcsetattr: attributes[6] must be %d element list", - NCCS); - return NULL; - } - - for (i = 0; i < NCCS; i++) { - v = PyList_GetItem(cc, i); - - if (PyString_Check(v) && PyString_Size(v) == 1) - mode.c_cc[i] = (cc_t) * PyString_AsString(v); - else if (PyInt_Check(v)) - mode.c_cc[i] = (cc_t) PyInt_AsLong(v); - else { - PyErr_SetString(PyExc_TypeError, - "tcsetattr: elements of attributes must be characters or integers"); - return NULL; - } - } - - if (cfsetispeed(&mode, (speed_t) ispeed) == -1) - return PyErr_SetFromErrno(TermiosError); - if (cfsetospeed(&mode, (speed_t) ospeed) == -1) - return PyErr_SetFromErrno(TermiosError); - if (tcsetattr(fd, when, &mode) == -1) - return PyErr_SetFromErrno(TermiosError); - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(termios_tcsendbreak__doc__, -"tcsendbreak(fd, duration) -> None\n\ -\n\ -Send a break on file descriptor fd.\n\ -A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration\n\ -has a system dependent meaning."); - -static PyObject * -termios_tcsendbreak(PyObject *self, PyObject *args) -{ - int fd, duration; - - if (!PyArg_ParseTuple(args, "O&i:tcsendbreak", - fdconv, &fd, &duration)) - return NULL; - if (tcsendbreak(fd, duration) == -1) - return PyErr_SetFromErrno(TermiosError); - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(termios_tcdrain__doc__, -"tcdrain(fd) -> None\n\ -\n\ -Wait until all output written to file descriptor fd has been transmitted."); - -static PyObject * -termios_tcdrain(PyObject *self, PyObject *args) -{ - int fd; - - if (!PyArg_ParseTuple(args, "O&:tcdrain", - fdconv, &fd)) - return NULL; - if (tcdrain(fd) == -1) - return PyErr_SetFromErrno(TermiosError); - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(termios_tcflush__doc__, -"tcflush(fd, queue) -> None\n\ -\n\ -Discard queued data on file descriptor fd.\n\ -The queue selector specifies which queue: termios.TCIFLUSH for the input\n\ -queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for\n\ -both queues. "); - -static PyObject * -termios_tcflush(PyObject *self, PyObject *args) -{ - int fd, queue; - - if (!PyArg_ParseTuple(args, "O&i:tcflush", - fdconv, &fd, &queue)) - return NULL; - if (tcflush(fd, queue) == -1) - return PyErr_SetFromErrno(TermiosError); - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(termios_tcflow__doc__, -"tcflow(fd, action) -> None\n\ -\n\ -Suspend or resume input or output on file descriptor fd.\n\ -The action argument can be termios.TCOOFF to suspend output,\n\ -termios.TCOON to restart output, termios.TCIOFF to suspend input,\n\ -or termios.TCION to restart input."); - -static PyObject * -termios_tcflow(PyObject *self, PyObject *args) -{ - int fd, action; - - if (!PyArg_ParseTuple(args, "O&i:tcflow", - fdconv, &fd, &action)) - return NULL; - if (tcflow(fd, action) == -1) - return PyErr_SetFromErrno(TermiosError); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyMethodDef termios_methods[] = -{ - {"tcgetattr", termios_tcgetattr, - METH_VARARGS, termios_tcgetattr__doc__}, - {"tcsetattr", termios_tcsetattr, - METH_VARARGS, termios_tcsetattr__doc__}, - {"tcsendbreak", termios_tcsendbreak, - METH_VARARGS, termios_tcsendbreak__doc__}, - {"tcdrain", termios_tcdrain, - METH_VARARGS, termios_tcdrain__doc__}, - {"tcflush", termios_tcflush, - METH_VARARGS, termios_tcflush__doc__}, - {"tcflow", termios_tcflow, - METH_VARARGS, termios_tcflow__doc__}, - {NULL, NULL} -}; - - -#if defined(VSWTCH) && !defined(VSWTC) -#define VSWTC VSWTCH -#endif - -#if defined(VSWTC) && !defined(VSWTCH) -#define VSWTCH VSWTC -#endif - -static struct constant { - char *name; - long value; -} termios_constants[] = { - /* cfgetospeed(), cfsetospeed() constants */ - {"B0", B0}, - {"B50", B50}, - {"B75", B75}, - {"B110", B110}, - {"B134", B134}, - {"B150", B150}, - {"B200", B200}, - {"B300", B300}, - {"B600", B600}, - {"B1200", B1200}, - {"B1800", B1800}, - {"B2400", B2400}, - {"B4800", B4800}, - {"B9600", B9600}, - {"B19200", B19200}, - {"B38400", B38400}, -#ifdef B57600 - {"B57600", B57600}, -#endif -#ifdef B115200 - {"B115200", B115200}, -#endif -#ifdef B230400 - {"B230400", B230400}, -#endif -#ifdef CBAUDEX - {"CBAUDEX", CBAUDEX}, -#endif - - /* tcsetattr() constants */ - {"TCSANOW", TCSANOW}, - {"TCSADRAIN", TCSADRAIN}, - {"TCSAFLUSH", TCSAFLUSH}, - - /* tcflush() constants */ - {"TCIFLUSH", TCIFLUSH}, - {"TCOFLUSH", TCOFLUSH}, - {"TCIOFLUSH", TCIOFLUSH}, - - /* tcflow() constants */ - {"TCOOFF", TCOOFF}, - {"TCOON", TCOON}, - {"TCIOFF", TCIOFF}, - {"TCION", TCION}, - - /* struct termios.c_iflag constants */ - {"IGNBRK", IGNBRK}, - {"BRKINT", BRKINT}, - {"IGNPAR", IGNPAR}, - {"PARMRK", PARMRK}, - {"INPCK", INPCK}, - {"ISTRIP", ISTRIP}, - {"INLCR", INLCR}, - {"IGNCR", IGNCR}, - {"ICRNL", ICRNL}, -#ifdef IUCLC - {"IUCLC", IUCLC}, -#endif - {"IXON", IXON}, - {"IXANY", IXANY}, - {"IXOFF", IXOFF}, -#ifdef IMAXBEL - {"IMAXBEL", IMAXBEL}, -#endif - - /* struct termios.c_oflag constants */ - {"OPOST", OPOST}, -#ifdef OLCUC - {"OLCUC", OLCUC}, -#endif -#ifdef ONLCR - {"ONLCR", ONLCR}, -#endif -#ifdef OCRNL - {"OCRNL", OCRNL}, -#endif -#ifdef ONOCR - {"ONOCR", ONOCR}, -#endif -#ifdef ONLRET - {"ONLRET", ONLRET}, -#endif -#ifdef OFILL - {"OFILL", OFILL}, -#endif -#ifdef OFDEL - {"OFDEL", OFDEL}, -#endif -#ifdef NLDLY - {"NLDLY", NLDLY}, -#endif -#ifdef CRDLY - {"CRDLY", CRDLY}, -#endif -#ifdef TABDLY - {"TABDLY", TABDLY}, -#endif -#ifdef BSDLY - {"BSDLY", BSDLY}, -#endif -#ifdef VTDLY - {"VTDLY", VTDLY}, -#endif -#ifdef FFDLY - {"FFDLY", FFDLY}, -#endif - - /* struct termios.c_oflag-related values (delay mask) */ -#ifdef NL0 - {"NL0", NL0}, -#endif -#ifdef NL1 - {"NL1", NL1}, -#endif -#ifdef CR0 - {"CR0", CR0}, -#endif -#ifdef CR1 - {"CR1", CR1}, -#endif -#ifdef CR2 - {"CR2", CR2}, -#endif -#ifdef CR3 - {"CR3", CR3}, -#endif -#ifdef TAB0 - {"TAB0", TAB0}, -#endif -#ifdef TAB1 - {"TAB1", TAB1}, -#endif -#ifdef TAB2 - {"TAB2", TAB2}, -#endif -#ifdef TAB3 - {"TAB3", TAB3}, -#endif -#ifdef XTABS - {"XTABS", XTABS}, -#endif -#ifdef BS0 - {"BS0", BS0}, -#endif -#ifdef BS1 - {"BS1", BS1}, -#endif -#ifdef VT0 - {"VT0", VT0}, -#endif -#ifdef VT1 - {"VT1", VT1}, -#endif -#ifdef FF0 - {"FF0", FF0}, -#endif -#ifdef FF1 - {"FF1", FF1}, -#endif - - /* struct termios.c_cflag constants */ - {"CSIZE", CSIZE}, - {"CSTOPB", CSTOPB}, - {"CREAD", CREAD}, - {"PARENB", PARENB}, - {"PARODD", PARODD}, - {"HUPCL", HUPCL}, - {"CLOCAL", CLOCAL}, -#ifdef CIBAUD - {"CIBAUD", CIBAUD}, -#endif -#ifdef CRTSCTS - {"CRTSCTS", (long)CRTSCTS}, -#endif - - /* struct termios.c_cflag-related values (character size) */ - {"CS5", CS5}, - {"CS6", CS6}, - {"CS7", CS7}, - {"CS8", CS8}, - - /* struct termios.c_lflag constants */ - {"ISIG", ISIG}, - {"ICANON", ICANON}, -#ifdef XCASE - {"XCASE", XCASE}, -#endif - {"ECHO", ECHO}, - {"ECHOE", ECHOE}, - {"ECHOK", ECHOK}, - {"ECHONL", ECHONL}, -#ifdef ECHOCTL - {"ECHOCTL", ECHOCTL}, -#endif -#ifdef ECHOPRT - {"ECHOPRT", ECHOPRT}, -#endif -#ifdef ECHOKE - {"ECHOKE", ECHOKE}, -#endif -#ifdef FLUSHO - {"FLUSHO", FLUSHO}, -#endif - {"NOFLSH", NOFLSH}, - {"TOSTOP", TOSTOP}, -#ifdef PENDIN - {"PENDIN", PENDIN}, -#endif - {"IEXTEN", IEXTEN}, - - /* indexes into the control chars array returned by tcgetattr() */ - {"VINTR", VINTR}, - {"VQUIT", VQUIT}, - {"VERASE", VERASE}, - {"VKILL", VKILL}, - {"VEOF", VEOF}, - {"VTIME", VTIME}, - {"VMIN", VMIN}, -#ifdef VSWTC - /* The #defines above ensure that if either is defined, both are, - * but both may be omitted by the system headers. ;-( */ - {"VSWTC", VSWTC}, - {"VSWTCH", VSWTCH}, -#endif - {"VSTART", VSTART}, - {"VSTOP", VSTOP}, - {"VSUSP", VSUSP}, - {"VEOL", VEOL}, -#ifdef VREPRINT - {"VREPRINT", VREPRINT}, -#endif -#ifdef VDISCARD - {"VDISCARD", VDISCARD}, -#endif -#ifdef VWERASE - {"VWERASE", VWERASE}, -#endif -#ifdef VLNEXT - {"VLNEXT", VLNEXT}, -#endif -#ifdef VEOL2 - {"VEOL2", VEOL2}, -#endif - - -#ifdef B460800 - {"B460800", B460800}, -#endif -#ifdef CBAUD - {"CBAUD", CBAUD}, -#endif -#ifdef CDEL - {"CDEL", CDEL}, -#endif -#ifdef CDSUSP - {"CDSUSP", CDSUSP}, -#endif -#ifdef CEOF - {"CEOF", CEOF}, -#endif -#ifdef CEOL - {"CEOL", CEOL}, -#endif -#ifdef CEOL2 - {"CEOL2", CEOL2}, -#endif -#ifdef CEOT - {"CEOT", CEOT}, -#endif -#ifdef CERASE - {"CERASE", CERASE}, -#endif -#ifdef CESC - {"CESC", CESC}, -#endif -#ifdef CFLUSH - {"CFLUSH", CFLUSH}, -#endif -#ifdef CINTR - {"CINTR", CINTR}, -#endif -#ifdef CKILL - {"CKILL", CKILL}, -#endif -#ifdef CLNEXT - {"CLNEXT", CLNEXT}, -#endif -#ifdef CNUL - {"CNUL", CNUL}, -#endif -#ifdef COMMON - {"COMMON", COMMON}, -#endif -#ifdef CQUIT - {"CQUIT", CQUIT}, -#endif -#ifdef CRPRNT - {"CRPRNT", CRPRNT}, -#endif -#ifdef CSTART - {"CSTART", CSTART}, -#endif -#ifdef CSTOP - {"CSTOP", CSTOP}, -#endif -#ifdef CSUSP - {"CSUSP", CSUSP}, -#endif -#ifdef CSWTCH - {"CSWTCH", CSWTCH}, -#endif -#ifdef CWERASE - {"CWERASE", CWERASE}, -#endif -#ifdef EXTA - {"EXTA", EXTA}, -#endif -#ifdef EXTB - {"EXTB", EXTB}, -#endif -#ifdef FIOASYNC - {"FIOASYNC", FIOASYNC}, -#endif -#ifdef FIOCLEX - {"FIOCLEX", FIOCLEX}, -#endif -#ifdef FIONBIO - {"FIONBIO", FIONBIO}, -#endif -#ifdef FIONCLEX - {"FIONCLEX", FIONCLEX}, -#endif -#ifdef FIONREAD - {"FIONREAD", FIONREAD}, -#endif -#ifdef IBSHIFT - {"IBSHIFT", IBSHIFT}, -#endif -#ifdef INIT_C_CC - {"INIT_C_CC", INIT_C_CC}, -#endif -#ifdef IOCSIZE_MASK - {"IOCSIZE_MASK", IOCSIZE_MASK}, -#endif -#ifdef IOCSIZE_SHIFT - {"IOCSIZE_SHIFT", IOCSIZE_SHIFT}, -#endif -#ifdef NCC - {"NCC", NCC}, -#endif -#ifdef NCCS - {"NCCS", NCCS}, -#endif -#ifdef NSWTCH - {"NSWTCH", NSWTCH}, -#endif -#ifdef N_MOUSE - {"N_MOUSE", N_MOUSE}, -#endif -#ifdef N_PPP - {"N_PPP", N_PPP}, -#endif -#ifdef N_SLIP - {"N_SLIP", N_SLIP}, -#endif -#ifdef N_STRIP - {"N_STRIP", N_STRIP}, -#endif -#ifdef N_TTY - {"N_TTY", N_TTY}, -#endif -#ifdef TCFLSH - {"TCFLSH", TCFLSH}, -#endif -#ifdef TCGETA - {"TCGETA", TCGETA}, -#endif -#ifdef TCGETS - {"TCGETS", TCGETS}, -#endif -#ifdef TCSBRK - {"TCSBRK", TCSBRK}, -#endif -#ifdef TCSBRKP - {"TCSBRKP", TCSBRKP}, -#endif -#ifdef TCSETA - {"TCSETA", TCSETA}, -#endif -#ifdef TCSETAF - {"TCSETAF", TCSETAF}, -#endif -#ifdef TCSETAW - {"TCSETAW", TCSETAW}, -#endif -#ifdef TCSETS - {"TCSETS", TCSETS}, -#endif -#ifdef TCSETSF - {"TCSETSF", TCSETSF}, -#endif -#ifdef TCSETSW - {"TCSETSW", TCSETSW}, -#endif -#ifdef TCXONC - {"TCXONC", TCXONC}, -#endif -#ifdef TIOCCONS - {"TIOCCONS", TIOCCONS}, -#endif -#ifdef TIOCEXCL - {"TIOCEXCL", TIOCEXCL}, -#endif -#ifdef TIOCGETD - {"TIOCGETD", TIOCGETD}, -#endif -#ifdef TIOCGICOUNT - {"TIOCGICOUNT", TIOCGICOUNT}, -#endif -#ifdef TIOCGLCKTRMIOS - {"TIOCGLCKTRMIOS", TIOCGLCKTRMIOS}, -#endif -#ifdef TIOCGPGRP - {"TIOCGPGRP", TIOCGPGRP}, -#endif -#ifdef TIOCGSERIAL - {"TIOCGSERIAL", TIOCGSERIAL}, -#endif -#ifdef TIOCGSOFTCAR - {"TIOCGSOFTCAR", TIOCGSOFTCAR}, -#endif -#ifdef TIOCGWINSZ - {"TIOCGWINSZ", TIOCGWINSZ}, -#endif -#ifdef TIOCINQ - {"TIOCINQ", TIOCINQ}, -#endif -#ifdef TIOCLINUX - {"TIOCLINUX", TIOCLINUX}, -#endif -#ifdef TIOCMBIC - {"TIOCMBIC", TIOCMBIC}, -#endif -#ifdef TIOCMBIS - {"TIOCMBIS", TIOCMBIS}, -#endif -#ifdef TIOCMGET - {"TIOCMGET", TIOCMGET}, -#endif -#ifdef TIOCMIWAIT - {"TIOCMIWAIT", TIOCMIWAIT}, -#endif -#ifdef TIOCMSET - {"TIOCMSET", TIOCMSET}, -#endif -#ifdef TIOCM_CAR - {"TIOCM_CAR", TIOCM_CAR}, -#endif -#ifdef TIOCM_CD - {"TIOCM_CD", TIOCM_CD}, -#endif -#ifdef TIOCM_CTS - {"TIOCM_CTS", TIOCM_CTS}, -#endif -#ifdef TIOCM_DSR - {"TIOCM_DSR", TIOCM_DSR}, -#endif -#ifdef TIOCM_DTR - {"TIOCM_DTR", TIOCM_DTR}, -#endif -#ifdef TIOCM_LE - {"TIOCM_LE", TIOCM_LE}, -#endif -#ifdef TIOCM_RI - {"TIOCM_RI", TIOCM_RI}, -#endif -#ifdef TIOCM_RNG - {"TIOCM_RNG", TIOCM_RNG}, -#endif -#ifdef TIOCM_RTS - {"TIOCM_RTS", TIOCM_RTS}, -#endif -#ifdef TIOCM_SR - {"TIOCM_SR", TIOCM_SR}, -#endif -#ifdef TIOCM_ST - {"TIOCM_ST", TIOCM_ST}, -#endif -#ifdef TIOCNOTTY - {"TIOCNOTTY", TIOCNOTTY}, -#endif -#ifdef TIOCNXCL - {"TIOCNXCL", TIOCNXCL}, -#endif -#ifdef TIOCOUTQ - {"TIOCOUTQ", TIOCOUTQ}, -#endif -#ifdef TIOCPKT - {"TIOCPKT", TIOCPKT}, -#endif -#ifdef TIOCPKT_DATA - {"TIOCPKT_DATA", TIOCPKT_DATA}, -#endif -#ifdef TIOCPKT_DOSTOP - {"TIOCPKT_DOSTOP", TIOCPKT_DOSTOP}, -#endif -#ifdef TIOCPKT_FLUSHREAD - {"TIOCPKT_FLUSHREAD", TIOCPKT_FLUSHREAD}, -#endif -#ifdef TIOCPKT_FLUSHWRITE - {"TIOCPKT_FLUSHWRITE", TIOCPKT_FLUSHWRITE}, -#endif -#ifdef TIOCPKT_NOSTOP - {"TIOCPKT_NOSTOP", TIOCPKT_NOSTOP}, -#endif -#ifdef TIOCPKT_START - {"TIOCPKT_START", TIOCPKT_START}, -#endif -#ifdef TIOCPKT_STOP - {"TIOCPKT_STOP", TIOCPKT_STOP}, -#endif -#ifdef TIOCSCTTY - {"TIOCSCTTY", TIOCSCTTY}, -#endif -#ifdef TIOCSERCONFIG - {"TIOCSERCONFIG", TIOCSERCONFIG}, -#endif -#ifdef TIOCSERGETLSR - {"TIOCSERGETLSR", TIOCSERGETLSR}, -#endif -#ifdef TIOCSERGETMULTI - {"TIOCSERGETMULTI", TIOCSERGETMULTI}, -#endif -#ifdef TIOCSERGSTRUCT - {"TIOCSERGSTRUCT", TIOCSERGSTRUCT}, -#endif -#ifdef TIOCSERGWILD - {"TIOCSERGWILD", TIOCSERGWILD}, -#endif -#ifdef TIOCSERSETMULTI - {"TIOCSERSETMULTI", TIOCSERSETMULTI}, -#endif -#ifdef TIOCSERSWILD - {"TIOCSERSWILD", TIOCSERSWILD}, -#endif -#ifdef TIOCSER_TEMT - {"TIOCSER_TEMT", TIOCSER_TEMT}, -#endif -#ifdef TIOCSETD - {"TIOCSETD", TIOCSETD}, -#endif -#ifdef TIOCSLCKTRMIOS - {"TIOCSLCKTRMIOS", TIOCSLCKTRMIOS}, -#endif -#ifdef TIOCSPGRP - {"TIOCSPGRP", TIOCSPGRP}, -#endif -#ifdef TIOCSSERIAL - {"TIOCSSERIAL", TIOCSSERIAL}, -#endif -#ifdef TIOCSSOFTCAR - {"TIOCSSOFTCAR", TIOCSSOFTCAR}, -#endif -#ifdef TIOCSTI - {"TIOCSTI", TIOCSTI}, -#endif -#ifdef TIOCSWINSZ - {"TIOCSWINSZ", TIOCSWINSZ}, -#endif -#ifdef TIOCTTYGSTRUCT - {"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT}, -#endif - - /* sentinel */ - {NULL, 0} -}; - - -PyMODINIT_FUNC -PyInit_termios(void) -{ - PyObject *m; - struct constant *constant = termios_constants; - - m = Py_InitModule4("termios", termios_methods, termios__doc__, - (PyObject *)NULL, PYTHON_API_VERSION); - - if (TermiosError == NULL) { - TermiosError = PyErr_NewException("termios.error", NULL, NULL); - } - Py_INCREF(TermiosError); - PyModule_AddObject(m, "error", TermiosError); - - while (constant->name != NULL) { - PyModule_AddIntConstant(m, constant->name, constant->value); - ++constant; - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/testcapi_long.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/testcapi_long.h deleted file mode 100644 index 445a7295..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/testcapi_long.h +++ /dev/null @@ -1,166 +0,0 @@ -/* Poor-man's template. Macros used: - TESTNAME name of the test (like test_long_api_inner) - TYPENAME the signed type (like long) - F_S_TO_PY convert signed to pylong; TYPENAME -> PyObject* - F_PY_TO_S convert pylong to signed; PyObject* -> TYPENAME - F_U_TO_PY convert unsigned to pylong; unsigned TYPENAME -> PyObject* - F_PY_TO_U convert pylong to unsigned; PyObject* -> unsigned TYPENAME -*/ - -static PyObject * -TESTNAME(PyObject *error(const char*)) -{ - const int NBITS = sizeof(TYPENAME) * 8; - unsigned TYPENAME base; - PyObject *pyresult; - int i; - - /* Note: This test lets PyObjects leak if an error is raised. Since - an error should never be raised, leaks are impossible . */ - - /* Test native -> PyLong -> native roundtrip identity. - * Generate all powers of 2, and test them and their negations, - * plus the numbers +-1 off from them. - */ - base = 1; - for (i = 0; - i < NBITS + 1; /* on last, base overflows to 0 */ - ++i, base <<= 1) - { - int j; - for (j = 0; j < 6; ++j) { - TYPENAME in, out; - unsigned TYPENAME uin, uout; - - /* For 0, 1, 2 use base; for 3, 4, 5 use -base */ - uin = j < 3 ? base - : (unsigned TYPENAME)(-(TYPENAME)base); - - /* For 0 & 3, subtract 1. - * For 1 & 4, leave alone. - * For 2 & 5, add 1. - */ - uin += (unsigned TYPENAME)(TYPENAME)(j % 3 - 1); - - pyresult = F_U_TO_PY(uin); - if (pyresult == NULL) - return error( - "unsigned unexpected null result"); - - uout = F_PY_TO_U(pyresult); - if (uout == (unsigned TYPENAME)-1 && PyErr_Occurred()) - return error( - "unsigned unexpected -1 result"); - if (uout != uin) - return error( - "unsigned output != input"); - UNBIND(pyresult); - - in = (TYPENAME)uin; - pyresult = F_S_TO_PY(in); - if (pyresult == NULL) - return error( - "signed unexpected null result"); - - out = F_PY_TO_S(pyresult); - if (out == (TYPENAME)-1 && PyErr_Occurred()) - return error( - "signed unexpected -1 result"); - if (out != in) - return error( - "signed output != input"); - UNBIND(pyresult); - } - } - - /* Overflow tests. The loop above ensured that all limit cases that - * should not overflow don't overflow, so all we need to do here is - * provoke one-over-the-limit cases (not exhaustive, but sharp). - */ - { - PyObject *one, *x, *y; - TYPENAME out; - unsigned TYPENAME uout; - - one = PyLong_FromLong(1); - if (one == NULL) - return error( - "unexpected NULL from PyLong_FromLong"); - - /* Unsigned complains about -1? */ - x = PyNumber_Negative(one); - if (x == NULL) - return error( - "unexpected NULL from PyNumber_Negative"); - - uout = F_PY_TO_U(x); - if (uout != (unsigned TYPENAME)-1 || !PyErr_Occurred()) - return error( - "PyLong_AsUnsignedXXX(-1) didn't complain"); - PyErr_Clear(); - UNBIND(x); - - /* Unsigned complains about 2**NBITS? */ - y = PyLong_FromLong((long)NBITS); - if (y == NULL) - return error( - "unexpected NULL from PyLong_FromLong"); - - x = PyNumber_Lshift(one, y); /* 1L << NBITS, == 2**NBITS */ - UNBIND(y); - if (x == NULL) - return error( - "unexpected NULL from PyNumber_Lshift"); - - uout = F_PY_TO_U(x); - if (uout != (unsigned TYPENAME)-1 || !PyErr_Occurred()) - return error( - "PyLong_AsUnsignedXXX(2**NBITS) didn't " - "complain"); - PyErr_Clear(); - - /* Signed complains about 2**(NBITS-1)? - x still has 2**NBITS. */ - y = PyNumber_Rshift(x, one); /* 2**(NBITS-1) */ - UNBIND(x); - if (y == NULL) - return error( - "unexpected NULL from PyNumber_Rshift"); - - out = F_PY_TO_S(y); - if (out != (TYPENAME)-1 || !PyErr_Occurred()) - return error( - "PyLong_AsXXX(2**(NBITS-1)) didn't " - "complain"); - PyErr_Clear(); - - /* Signed complains about -2**(NBITS-1)-1?; - y still has 2**(NBITS-1). */ - x = PyNumber_Negative(y); /* -(2**(NBITS-1)) */ - UNBIND(y); - if (x == NULL) - return error( - "unexpected NULL from PyNumber_Negative"); - - y = PyNumber_Subtract(x, one); /* -(2**(NBITS-1))-1 */ - UNBIND(x); - if (y == NULL) - return error( - "unexpected NULL from PyNumber_Subtract"); - - out = F_PY_TO_S(y); - if (out != (TYPENAME)-1 || !PyErr_Occurred()) - return error( - "PyLong_AsXXX(-2**(NBITS-1)-1) didn't " - "complain"); - PyErr_Clear(); - UNBIND(y); - - Py_XDECREF(x); - Py_XDECREF(y); - Py_DECREF(one); - } - - Py_INCREF(Py_None); - return Py_None; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/threadmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/threadmodule.c deleted file mode 100644 index 8de50795..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/threadmodule.c +++ /dev/null @@ -1,406 +0,0 @@ - -/* Thread module */ -/* Interface to Sjoerd's portable C thread library */ - -#include "Python.h" - -#ifndef WITH_THREAD -#error "Error! The rest of Python is not compiled with thread support." -#error "Rerun configure, adding a --with-threads option." -#error "Then run `make clean' followed by `make'." -#endif - -#include "pythread.h" - -static PyObject *ThreadError; - - -/* Lock objects */ - -typedef struct { - PyObject_HEAD - PyThread_type_lock lock_lock; -} lockobject; - -static PyTypeObject Locktype; - -static lockobject * -newlockobject(void) -{ - lockobject *self; - self = PyObject_New(lockobject, &Locktype); - if (self == NULL) - return NULL; - self->lock_lock = PyThread_allocate_lock(); - if (self->lock_lock == NULL) { - PyObject_Del(self); - self = NULL; - PyErr_SetString(ThreadError, "can't allocate lock"); - } - return self; -} - -static void -lock_dealloc(lockobject *self) -{ - /* Unlock the lock so it's safe to free it */ - PyThread_acquire_lock(self->lock_lock, 0); - PyThread_release_lock(self->lock_lock); - - PyThread_free_lock(self->lock_lock); - PyObject_Del(self); -} - -static PyObject * -lock_PyThread_acquire_lock(lockobject *self, PyObject *args) -{ - int i = 1; - - if (!PyArg_ParseTuple(args, "|i:acquire", &i)) - return NULL; - - Py_BEGIN_ALLOW_THREADS - i = PyThread_acquire_lock(self->lock_lock, i); - Py_END_ALLOW_THREADS - - if (args == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - else - return PyBool_FromLong((long)i); -} - -PyDoc_STRVAR(acquire_doc, -"acquire([wait]) -> None or bool\n\ -(PyThread_acquire_lock() is an obsolete synonym)\n\ -\n\ -Lock the lock. Without argument, this blocks if the lock is already\n\ -locked (even by the same thread), waiting for another thread to release\n\ -the lock, and return None once the lock is acquired.\n\ -With an argument, this will only block if the argument is true,\n\ -and the return value reflects whether the lock is acquired.\n\ -The blocking operation is not interruptible."); - -static PyObject * -lock_PyThread_release_lock(lockobject *self) -{ - /* Sanity check: the lock must be locked */ - if (PyThread_acquire_lock(self->lock_lock, 0)) { - PyThread_release_lock(self->lock_lock); - PyErr_SetString(ThreadError, "release unlocked lock"); - return NULL; - } - - PyThread_release_lock(self->lock_lock); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(release_doc, -"release()\n\ -(PyThread_release_lock() is an obsolete synonym)\n\ -\n\ -Release the lock, allowing another thread that is blocked waiting for\n\ -the lock to acquire the lock. The lock must be in the locked state,\n\ -but it needn't be locked by the same thread that unlocks it."); - -static PyObject * -lock_locked_lock(lockobject *self) -{ - if (PyThread_acquire_lock(self->lock_lock, 0)) { - PyThread_release_lock(self->lock_lock); - return PyBool_FromLong(0L); - } - return PyBool_FromLong(1L); -} - -PyDoc_STRVAR(locked_doc, -"locked() -> bool\n\ -(locked_lock() is an obsolete synonym)\n\ -\n\ -Return whether the lock is in the locked state."); - -static PyMethodDef lock_methods[] = { - {"acquire_lock", (PyCFunction)lock_PyThread_acquire_lock, - METH_VARARGS, acquire_doc}, - {"acquire", (PyCFunction)lock_PyThread_acquire_lock, - METH_VARARGS, acquire_doc}, - {"release_lock", (PyCFunction)lock_PyThread_release_lock, - METH_NOARGS, release_doc}, - {"release", (PyCFunction)lock_PyThread_release_lock, - METH_NOARGS, release_doc}, - {"locked_lock", (PyCFunction)lock_locked_lock, - METH_NOARGS, locked_doc}, - {"locked", (PyCFunction)lock_locked_lock, - METH_NOARGS, locked_doc}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -lock_getattr(lockobject *self, char *name) -{ - return Py_FindMethod(lock_methods, (PyObject *)self, name); -} - -static PyTypeObject Locktype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "thread.lock", /*tp_name*/ - sizeof(lockobject), /*tp_size*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)lock_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)lock_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ -}; - - -/* Module functions */ - -struct bootstate { - PyInterpreterState *interp; - PyObject *func; - PyObject *args; - PyObject *keyw; -}; - -static void -t_bootstrap(void *boot_raw) -{ - struct bootstate *boot = (struct bootstate *) boot_raw; - PyThreadState *tstate; - PyObject *res; - - tstate = PyThreadState_New(boot->interp); - PyEval_AcquireThread(tstate); - res = PyEval_CallObjectWithKeywords( - boot->func, boot->args, boot->keyw); - if (res == NULL) { - if (PyErr_ExceptionMatches(PyExc_SystemExit)) - PyErr_Clear(); - else { - PyObject *file; - PySys_WriteStderr( - "Unhandled exception in thread started by "); - file = PySys_GetObject("stderr"); - if (file) - PyFile_WriteObject(boot->func, file, 0); - else - PyObject_Print(boot->func, stderr, 0); - PySys_WriteStderr("\n"); - PyErr_PrintEx(0); - } - } - else - Py_DECREF(res); - Py_DECREF(boot->func); - Py_DECREF(boot->args); - Py_XDECREF(boot->keyw); - PyMem_DEL(boot_raw); - PyThreadState_Clear(tstate); - PyThreadState_DeleteCurrent(); - PyThread_exit_thread(); -} - -static PyObject * -thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs) -{ - PyObject *func, *args, *keyw = NULL; - struct bootstate *boot; - long ident; - - if (!PyArg_ParseTuple(fargs, "OO|O:start_new_thread", &func, &args, &keyw)) - return NULL; - if (!PyCallable_Check(func)) { - PyErr_SetString(PyExc_TypeError, - "first arg must be callable"); - return NULL; - } - if (!PyTuple_Check(args)) { - PyErr_SetString(PyExc_TypeError, - "2nd arg must be a tuple"); - return NULL; - } - if (keyw != NULL && !PyDict_Check(keyw)) { - PyErr_SetString(PyExc_TypeError, - "optional 3rd arg must be a dictionary"); - return NULL; - } - boot = PyMem_NEW(struct bootstate, 1); - if (boot == NULL) - return PyErr_NoMemory(); - boot->interp = PyThreadState_Get()->interp; - boot->func = func; - boot->args = args; - boot->keyw = keyw; - Py_INCREF(func); - Py_INCREF(args); - Py_XINCREF(keyw); - PyEval_InitThreads(); /* Start the interpreter's thread-awareness */ - ident = PyThread_start_new_thread(t_bootstrap, (void*) boot); - if (ident == -1) { - PyErr_SetString(ThreadError, "can't start new thread\n"); - Py_DECREF(func); - Py_DECREF(args); - Py_XDECREF(keyw); - PyMem_DEL(boot); - return NULL; - } - return PyInt_FromLong(ident); -} - -PyDoc_STRVAR(start_new_doc, -"start_new_thread(function, args[, kwargs])\n\ -(start_new() is an obsolete synonym)\n\ -\n\ -Start a new thread and return its identifier. The thread will call the\n\ -function with positional arguments from the tuple args and keyword arguments\n\ -taken from the optional dictionary kwargs. The thread exits when the\n\ -function returns; the return value is ignored. The thread will also exit\n\ -when the function raises an unhandled exception; a stack trace will be\n\ -printed unless the exception is SystemExit.\n"); - -static PyObject * -thread_PyThread_exit_thread(PyObject *self) -{ - PyErr_SetNone(PyExc_SystemExit); - return NULL; -} - -PyDoc_STRVAR(exit_doc, -"exit()\n\ -(PyThread_exit_thread() is an obsolete synonym)\n\ -\n\ -This is synonymous to ``raise SystemExit''. It will cause the current\n\ -thread to exit silently unless the exception is caught."); - -static PyObject * -thread_PyThread_interrupt_main(PyObject * self) -{ - PyErr_SetInterrupt(); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(interrupt_doc, -"interrupt_main()\n\ -\n\ -Raise a KeyboardInterrupt in the main thread.\n\ -A subthread can use this function to interrupt the main thread." -); - -#ifndef NO_EXIT_PROG -static PyObject * -thread_PyThread_exit_prog(PyObject *self, PyObject *args) -{ - int sts; - if (!PyArg_ParseTuple(args, "i:exit_prog", &sts)) - return NULL; - Py_Exit(sts); /* Calls PyThread_exit_prog(sts) or _PyThread_exit_prog(sts) */ - for (;;) { } /* Should not be reached */ -} -#endif - -static PyObject * -thread_PyThread_allocate_lock(PyObject *self) -{ - return (PyObject *) newlockobject(); -} - -PyDoc_STRVAR(allocate_doc, -"allocate_lock() -> lock object\n\ -(allocate() is an obsolete synonym)\n\ -\n\ -Create a new lock object. See LockType.__doc__ for information about locks."); - -static PyObject * -thread_get_ident(PyObject *self) -{ - long ident; - ident = PyThread_get_thread_ident(); - if (ident == -1) { - PyErr_SetString(ThreadError, "no current thread ident"); - return NULL; - } - return PyInt_FromLong(ident); -} - -PyDoc_STRVAR(get_ident_doc, -"get_ident() -> integer\n\ -\n\ -Return a non-zero integer that uniquely identifies the current thread\n\ -amongst other threads that exist simultaneously.\n\ -This may be used to identify per-thread resources.\n\ -Even though on some platforms threads identities may appear to be\n\ -allocated consecutive numbers starting at 1, this behavior should not\n\ -be relied upon, and the number should be seen purely as a magic cookie.\n\ -A thread's identity may be reused for another thread after it exits."); - -static PyMethodDef thread_methods[] = { - {"start_new_thread", (PyCFunction)thread_PyThread_start_new_thread, - METH_VARARGS, - start_new_doc}, - {"start_new", (PyCFunction)thread_PyThread_start_new_thread, - METH_VARARGS, - start_new_doc}, - {"allocate_lock", (PyCFunction)thread_PyThread_allocate_lock, - METH_NOARGS, allocate_doc}, - {"allocate", (PyCFunction)thread_PyThread_allocate_lock, - METH_NOARGS, allocate_doc}, - {"exit_thread", (PyCFunction)thread_PyThread_exit_thread, - METH_NOARGS, exit_doc}, - {"exit", (PyCFunction)thread_PyThread_exit_thread, - METH_NOARGS, exit_doc}, - {"interrupt_main", (PyCFunction)thread_PyThread_interrupt_main, - METH_NOARGS, interrupt_doc}, - {"get_ident", (PyCFunction)thread_get_ident, - METH_NOARGS, get_ident_doc}, -#ifndef NO_EXIT_PROG - {"exit_prog", (PyCFunction)thread_PyThread_exit_prog, - METH_VARARGS}, -#endif - {NULL, NULL} /* sentinel */ -}; - - -/* Initialization function */ - -PyDoc_STRVAR(thread_doc, -"This module provides primitive operations to write multi-threaded programs.\n\ -The 'threading' module provides a more convenient interface."); - -PyDoc_STRVAR(lock_doc, -"A lock object is a synchronization primitive. To create a lock,\n\ -call the PyThread_allocate_lock() function. Methods are:\n\ -\n\ -acquire() -- lock the lock, possibly blocking until it can be obtained\n\ -release() -- unlock of the lock\n\ -locked() -- test whether the lock is currently locked\n\ -\n\ -A lock is not owned by the thread that locked it; another thread may\n\ -unlock it. A thread attempting to lock a lock that it has already locked\n\ -will block until another thread unlocks it. Deadlocks may ensue."); - -PyMODINIT_FUNC -initthread(void) -{ - PyObject *m, *d; - - /* Create the module and add the functions */ - m = Py_InitModule3("thread", thread_methods, thread_doc); - - /* Add a symbolic constant */ - d = PyModule_GetDict(m); - ThreadError = PyErr_NewException("thread.error", NULL, NULL); - PyDict_SetItemString(d, "error", ThreadError); - Locktype.tp_doc = lock_doc; - Py_INCREF(&Locktype); - PyDict_SetItemString(d, "LockType", (PyObject *)&Locktype); - - /* Initialize the C thread library */ - PyThread_init_thread(); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/timemodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/timemodule.c deleted file mode 100644 index a0bdce7c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/timemodule.c +++ /dev/null @@ -1,944 +0,0 @@ - -/* Time module */ - -#include "Python.h" -#include "structseq.h" - -#include - -#ifdef macintosh -#include -#include -#else -#include -#endif - -#ifdef QUICKWIN -#include -#endif - -#ifdef HAVE_FTIME -#include -#if !defined(MS_WINDOWS) && !defined(PYOS_OS2) -extern int ftime(struct timeb *); -#endif /* MS_WINDOWS */ -#endif /* HAVE_FTIME */ - -#if defined(__WATCOMC__) && !defined(__QNX__) -#include -#else -#ifdef MS_WINDOWS -#ifdef MS_XBOX -#include -#else -#define WIN32_LEAN_AND_MEAN -#include -#endif -#include "pythread.h" - -/* helper to allow us to interrupt sleep() on Windows*/ -static HANDLE hInterruptEvent = NULL; -static BOOL WINAPI PyCtrlHandler(DWORD dwCtrlType) -{ - SetEvent(hInterruptEvent); - /* allow other default handlers to be called. - Default Python handler will setup the - KeyboardInterrupt exception. - */ - return FALSE; -} -static long main_thread; - - -#if defined(__BORLANDC__) -/* These overrides not needed for Win32 */ -#define timezone _timezone -#define tzname _tzname -#define daylight _daylight -#endif /* __BORLANDC__ */ -#endif /* MS_WINDOWS */ -#endif /* !__WATCOMC__ || __QNX__ */ - -#if defined(MS_WINDOWS) && !defined(MS_WIN64) && !defined(__BORLANDC__) -/* Win32 has better clock replacement - XXX Win64 does not yet, but might when the platform matures. */ -#undef HAVE_CLOCK /* We have our own version down below */ -#endif /* MS_WINDOWS && !MS_WIN64 */ - -#if defined(PYOS_OS2) -#define INCL_DOS -#define INCL_ERRORS -#include -#endif - -#if defined(PYCC_VACPP) -#include -#endif - -#ifdef __BEOS__ -#include -/* For bigtime_t, snooze(). - [cjh] */ -#include -#include -#endif - -#ifdef RISCOS -extern int riscos_sleep(double); -#endif - -/* Forward declarations */ -static int floatsleep(double); -static double floattime(void); - -/* For Y2K check */ -static PyObject *moddict; - -#ifdef macintosh -/* Our own timezone. We have enough information to deduce whether -** DST is on currently, but unfortunately we cannot put it to good -** use because we don't know the rules (and that is needed to have -** localtime() return correct tm_isdst values for times other than -** the current time. So, we cop out and only tell the user the current -** timezone. -*/ -static long timezone; - -static void -initmactimezone(void) -{ - MachineLocation loc; - long delta; - - ReadLocation(&loc); - - if (loc.latitude == 0 && loc.longitude == 0 && loc.u.gmtDelta == 0) - return; - - delta = loc.u.gmtDelta & 0x00FFFFFF; - - if (delta & 0x00800000) - delta |= 0xFF000000; - - timezone = -delta; -} -#endif /* macintosh */ - - -static PyObject * -time_time(PyObject *self, PyObject *args) -{ - double secs; - if (!PyArg_ParseTuple(args, ":time")) - return NULL; - secs = floattime(); - if (secs == 0.0) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - return PyFloat_FromDouble(secs); -} - -PyDoc_STRVAR(time_doc, -"time() -> floating point number\n\ -\n\ -Return the current time in seconds since the Epoch.\n\ -Fractions of a second may be present if the system clock provides them."); - -#ifdef HAVE_CLOCK - -#ifndef CLOCKS_PER_SEC -#ifdef CLK_TCK -#define CLOCKS_PER_SEC CLK_TCK -#else -#define CLOCKS_PER_SEC 1000000 -#endif -#endif - -static PyObject * -time_clock(PyObject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":clock")) - return NULL; - return PyFloat_FromDouble(((double)clock()) / CLOCKS_PER_SEC); -} -#endif /* HAVE_CLOCK */ - -#if defined(MS_WINDOWS) && !defined(MS_WIN64) && !defined(__BORLANDC__) -/* Due to Mark Hammond and Tim Peters */ -static PyObject * -time_clock(PyObject *self, PyObject *args) -{ - static LARGE_INTEGER ctrStart; - static double divisor = 0.0; - LARGE_INTEGER now; - double diff; - - if (!PyArg_ParseTuple(args, ":clock")) - return NULL; - - if (divisor == 0.0) { - LARGE_INTEGER freq; - QueryPerformanceCounter(&ctrStart); - if (!QueryPerformanceFrequency(&freq) || freq.QuadPart == 0) { - /* Unlikely to happen - this works on all intel - machines at least! Revert to clock() */ - return PyFloat_FromDouble(clock()); - } - divisor = (double)freq.QuadPart; - } - QueryPerformanceCounter(&now); - diff = (double)(now.QuadPart - ctrStart.QuadPart); - return PyFloat_FromDouble(diff / divisor); -} - -#define HAVE_CLOCK /* So it gets included in the methods */ -#endif /* MS_WINDOWS && !MS_WIN64 */ - -#ifdef HAVE_CLOCK -PyDoc_STRVAR(clock_doc, -"clock() -> floating point number\n\ -\n\ -Return the CPU time or real time since the start of the process or since\n\ -the first call to clock(). This has as much precision as the system\n\ -records."); -#endif - -static PyObject * -time_sleep(PyObject *self, PyObject *args) -{ - double secs; - if (!PyArg_ParseTuple(args, "d:sleep", &secs)) - return NULL; - if (floatsleep(secs) != 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(sleep_doc, -"sleep(seconds)\n\ -\n\ -Delay execution for a given number of seconds. The argument may be\n\ -a floating point number for subsecond precision."); - -static PyStructSequence_Field struct_time_type_fields[] = { - {"tm_year", NULL}, - {"tm_mon", NULL}, - {"tm_mday", NULL}, - {"tm_hour", NULL}, - {"tm_min", NULL}, - {"tm_sec", NULL}, - {"tm_wday", NULL}, - {"tm_yday", NULL}, - {"tm_isdst", NULL}, - {0} -}; - -static PyStructSequence_Desc struct_time_type_desc = { - "time.struct_time", - NULL, - struct_time_type_fields, - 9, -}; - -static PyTypeObject StructTimeType; - -static PyObject * -tmtotuple(struct tm *p) -{ - PyObject *v = PyStructSequence_New(&StructTimeType); - if (v == NULL) - return NULL; - -#define SET(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val)) - - SET(0, p->tm_year + 1900); - SET(1, p->tm_mon + 1); /* Want January == 1 */ - SET(2, p->tm_mday); - SET(3, p->tm_hour); - SET(4, p->tm_min); - SET(5, p->tm_sec); - SET(6, (p->tm_wday + 6) % 7); /* Want Monday == 0 */ - SET(7, p->tm_yday + 1); /* Want January, 1 == 1 */ - SET(8, p->tm_isdst); -#undef SET - if (PyErr_Occurred()) { - Py_XDECREF(v); - return NULL; - } - - return v; -} - -static PyObject * -time_convert(time_t when, struct tm * (*function)(const time_t *)) -{ - struct tm *p; - errno = 0; - p = function(&when); - if (p == NULL) { -#ifdef EINVAL - if (errno == 0) - errno = EINVAL; -#endif - return PyErr_SetFromErrno(PyExc_ValueError); - } - return tmtotuple(p); -} - -static PyObject * -time_gmtime(PyObject *self, PyObject *args) -{ - double when; - if (PyTuple_Size(args) == 0) - when = floattime(); - if (!PyArg_ParseTuple(args, "|d:gmtime", &when)) - return NULL; - return time_convert((time_t)when, gmtime); -} - -PyDoc_STRVAR(gmtime_doc, -"gmtime([seconds]) -> (tm_year, tm_mon, tm_day, tm_hour, tm_min,\n\ - tm_sec, tm_wday, tm_yday, tm_isdst)\n\ -\n\ -Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n\ -GMT). When 'seconds' is not passed in, convert the current time instead."); - -static PyObject * -time_localtime(PyObject *self, PyObject *args) -{ - double when; - if (PyTuple_Size(args) == 0) - when = floattime(); - if (!PyArg_ParseTuple(args, "|d:localtime", &when)) - return NULL; - return time_convert((time_t)when, localtime); -} - -PyDoc_STRVAR(localtime_doc, -"localtime([seconds]) -> (tm_year,tm_mon,tm_day,tm_hour,tm_min,tm_sec,tm_wday,tm_yday,tm_isdst)\n\ -\n\ -Convert seconds since the Epoch to a time tuple expressing local time.\n\ -When 'seconds' is not passed in, convert the current time instead."); - -static int -gettmarg(PyObject *args, struct tm *p) -{ - int y; - memset((void *) p, '\0', sizeof(struct tm)); - - if (!PyArg_Parse(args, "(iiiiiiiii)", - &y, - &p->tm_mon, - &p->tm_mday, - &p->tm_hour, - &p->tm_min, - &p->tm_sec, - &p->tm_wday, - &p->tm_yday, - &p->tm_isdst)) - return 0; - if (y < 1900) { - PyObject *accept = PyDict_GetItemString(moddict, - "accept2dyear"); - if (accept == NULL || !PyInt_Check(accept) || - PyInt_AsLong(accept) == 0) { - PyErr_SetString(PyExc_ValueError, - "year >= 1900 required"); - return 0; - } - if (69 <= y && y <= 99) - y += 1900; - else if (0 <= y && y <= 68) - y += 2000; - else { - PyErr_SetString(PyExc_ValueError, - "year out of range"); - return 0; - } - } - p->tm_year = y - 1900; - p->tm_mon--; - p->tm_wday = (p->tm_wday + 1) % 7; - p->tm_yday--; - return 1; -} - -#ifdef HAVE_STRFTIME -static PyObject * -time_strftime(PyObject *self, PyObject *args) -{ - PyObject *tup = NULL; - struct tm buf; - const char *fmt; - size_t fmtlen, buflen; - char *outbuf = 0; - size_t i; - - memset((void *) &buf, '\0', sizeof(buf)); - - if (!PyArg_ParseTuple(args, "s|O:strftime", &fmt, &tup)) - return NULL; - - if (tup == NULL) { - time_t tt = time(NULL); - buf = *localtime(&tt); - } else if (!gettmarg(tup, &buf)) - return NULL; - - fmtlen = strlen(fmt); - - /* I hate these functions that presume you know how big the output - * will be ahead of time... - */ - for (i = 1024; ; i += i) { - outbuf = malloc(i); - if (outbuf == NULL) { - return PyErr_NoMemory(); - } - buflen = strftime(outbuf, i, fmt, &buf); - if (buflen > 0 || i >= 256 * fmtlen) { - /* If the buffer is 256 times as long as the format, - it's probably not failing for lack of room! - More likely, the format yields an empty result, - e.g. an empty format, or %Z when the timezone - is unknown. */ - PyObject *ret; - ret = PyString_FromStringAndSize(outbuf, buflen); - free(outbuf); - return ret; - } - free(outbuf); - } -} - -PyDoc_STRVAR(strftime_doc, -"strftime(format[, tuple]) -> string\n\ -\n\ -Convert a time tuple to a string according to a format specification.\n\ -See the library reference manual for formatting codes. When the time tuple\n\ -is not present, current time as returned by localtime() is used."); -#endif /* HAVE_STRFTIME */ - -static PyObject * -time_strptime(PyObject *self, PyObject *args) -{ - PyObject *strptime_module = PyImport_ImportModule("_strptime"); - PyObject *strptime_result; - - if (!strptime_module) - return NULL; - strptime_result = PyObject_CallMethod(strptime_module, "strptime", "O", args); - Py_DECREF(strptime_module); - return strptime_result; -} - -PyDoc_STRVAR(strptime_doc, -"strptime(string, format) -> struct_time\n\ -\n\ -Parse a string to a time tuple according to a format specification.\n\ -See the library reference manual for formatting codes (same as strftime())."); - - -static PyObject * -time_asctime(PyObject *self, PyObject *args) -{ - PyObject *tup = NULL; - struct tm buf; - char *p; - if (!PyArg_ParseTuple(args, "|O:asctime", &tup)) - return NULL; - if (tup == NULL) { - time_t tt = time(NULL); - buf = *localtime(&tt); - } else if (!gettmarg(tup, &buf)) - return NULL; - p = asctime(&buf); - if (p[24] == '\n') - p[24] = '\0'; - return PyString_FromString(p); -} - -PyDoc_STRVAR(asctime_doc, -"asctime([tuple]) -> string\n\ -\n\ -Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.\n\ -When the time tuple is not present, current time as returned by localtime()\n\ -is used."); - -static PyObject * -time_ctime(PyObject *self, PyObject *args) -{ - double dt; - time_t tt; - char *p; - - if (PyTuple_Size(args) == 0) - tt = time(NULL); - else { - if (!PyArg_ParseTuple(args, "|d:ctime", &dt)) - return NULL; - tt = (time_t)dt; - } - p = ctime(&tt); - if (p == NULL) { - PyErr_SetString(PyExc_ValueError, "unconvertible time"); - return NULL; - } - if (p[24] == '\n') - p[24] = '\0'; - return PyString_FromString(p); -} - -PyDoc_STRVAR(ctime_doc, -"ctime(seconds) -> string\n\ -\n\ -Convert a time in seconds since the Epoch to a string in local time.\n\ -This is equivalent to asctime(localtime(seconds)). When the time tuple is\n\ -not present, current time as returned by localtime() is used."); - -#ifdef HAVE_MKTIME -static PyObject * -time_mktime(PyObject *self, PyObject *args) -{ - PyObject *tup; - struct tm buf; - time_t tt; - if (!PyArg_ParseTuple(args, "O:mktime", &tup)) - return NULL; - tt = time(&tt); - buf = *localtime(&tt); - if (!gettmarg(tup, &buf)) - return NULL; - tt = mktime(&buf); - if (tt == (time_t)(-1)) { - PyErr_SetString(PyExc_OverflowError, - "mktime argument out of range"); - return NULL; - } - return PyFloat_FromDouble((double)tt); -} - -PyDoc_STRVAR(mktime_doc, -"mktime(tuple) -> floating point number\n\ -\n\ -Convert a time tuple in local time to seconds since the Epoch."); -#endif /* HAVE_MKTIME */ - -#ifdef HAVE_WORKING_TZSET -void inittimezone(PyObject *module); - -static PyObject * -time_tzset(PyObject *self, PyObject *args) -{ - PyObject* m; - - if (!PyArg_ParseTuple(args, ":tzset")) - return NULL; - - m = PyImport_ImportModule("time"); - if (m == NULL) { - return NULL; - } - - tzset(); - - /* Reset timezone, altzone, daylight and tzname */ - inittimezone(m); - Py_DECREF(m); - - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(tzset_doc, -"tzset(zone)\n\ -\n\ -Initialize, or reinitialize, the local timezone to the value stored in\n\ -os.environ['TZ']. The TZ environment variable should be specified in\n\ -standard Uniz timezone format as documented in the tzset man page\n\ -(eg. 'US/Eastern', 'Europe/Amsterdam'). Unknown timezones will silently\n\ -fall back to UTC. If the TZ environment variable is not set, the local\n\ -timezone is set to the systems best guess of wallclock time.\n\ -Changing the TZ environment variable without calling tzset *may* change\n\ -the local timezone used by methods such as localtime, but this behaviour\n\ -should not be relied on."); -#endif /* HAVE_WORKING_TZSET */ - -void inittimezone(PyObject *m) { - /* This code moved from inittime wholesale to allow calling it from - time_tzset. In the future, some parts of it can be moved back - (for platforms that don't HAVE_WORKING_TZSET, when we know what they - are), and the extranious calls to tzset(3) should be removed. - I havn't done this yet, as I don't want to change this code as - little as possible when introducing the time.tzset and time.tzsetwall - methods. This should simply be a method of doing the following once, - at the top of this function and removing the call to tzset() from - time_tzset(): - - #ifdef HAVE_TZSET - tzset() - #endif - - And I'm lazy and hate C so nyer. - */ -#if defined(HAVE_TZNAME) && !defined(__GLIBC__) && !defined(__CYGWIN__) - tzset(); -#ifdef PYOS_OS2 - PyModule_AddIntConstant(m, "timezone", _timezone); -#else /* !PYOS_OS2 */ - PyModule_AddIntConstant(m, "timezone", timezone); -#endif /* PYOS_OS2 */ -#ifdef HAVE_ALTZONE - PyModule_AddIntConstant(m, "altzone", altzone); -#else -#ifdef PYOS_OS2 - PyModule_AddIntConstant(m, "altzone", _timezone-3600); -#else /* !PYOS_OS2 */ - PyModule_AddIntConstant(m, "altzone", timezone-3600); -#endif /* PYOS_OS2 */ -#endif - PyModule_AddIntConstant(m, "daylight", daylight); - PyModule_AddObject(m, "tzname", - Py_BuildValue("(zz)", tzname[0], tzname[1])); -#else /* !HAVE_TZNAME || __GLIBC__ || __CYGWIN__*/ -#ifdef HAVE_STRUCT_TM_TM_ZONE - { -#define YEAR ((time_t)((365 * 24 + 6) * 3600)) - time_t t; - struct tm *p; - long janzone, julyzone; - char janname[10], julyname[10]; - t = (time((time_t *)0) / YEAR) * YEAR; - p = localtime(&t); - janzone = -p->tm_gmtoff; - strncpy(janname, p->tm_zone ? p->tm_zone : " ", 9); - janname[9] = '\0'; - t += YEAR/2; - p = localtime(&t); - julyzone = -p->tm_gmtoff; - strncpy(julyname, p->tm_zone ? p->tm_zone : " ", 9); - julyname[9] = '\0'; - - if( janzone < julyzone ) { - /* DST is reversed in the southern hemisphere */ - PyModule_AddIntConstant(m, "timezone", julyzone); - PyModule_AddIntConstant(m, "altzone", janzone); - PyModule_AddIntConstant(m, "daylight", - janzone != julyzone); - PyModule_AddObject(m, "tzname", - Py_BuildValue("(zz)", - julyname, janname)); - } else { - PyModule_AddIntConstant(m, "timezone", janzone); - PyModule_AddIntConstant(m, "altzone", julyzone); - PyModule_AddIntConstant(m, "daylight", - janzone != julyzone); - PyModule_AddObject(m, "tzname", - Py_BuildValue("(zz)", - janname, julyname)); - } - } -#else -#ifdef macintosh - /* The only thing we can obtain is the current timezone - ** (and whether dst is currently _active_, but that is not what - ** we're looking for:-( ) - */ - initmactimezone(); - PyModule_AddIntConstant(m, "timezone", timezone); - PyModule_AddIntConstant(m, "altzone", timezone); - PyModule_AddIntConstant(m, "daylight", 0); - PyModule_AddObject(m, "tzname", Py_BuildValue("(zz)", "", "")); -#endif /* macintosh */ -#endif /* HAVE_STRUCT_TM_TM_ZONE */ -#ifdef __CYGWIN__ - tzset(); - PyModule_AddIntConstant(m, "timezone", _timezone); - PyModule_AddIntConstant(m, "altzone", _timezone); - PyModule_AddIntConstant(m, "daylight", _daylight); - PyModule_AddObject(m, "tzname", - Py_BuildValue("(zz)", _tzname[0], _tzname[1])); -#endif /* __CYGWIN__ */ -#endif /* !HAVE_TZNAME || __GLIBC__ || __CYGWIN__*/ -} - - -static PyMethodDef time_methods[] = { - {"time", time_time, METH_VARARGS, time_doc}, -#ifdef HAVE_CLOCK - {"clock", time_clock, METH_VARARGS, clock_doc}, -#endif - {"sleep", time_sleep, METH_VARARGS, sleep_doc}, - {"gmtime", time_gmtime, METH_VARARGS, gmtime_doc}, - {"localtime", time_localtime, METH_VARARGS, localtime_doc}, - {"asctime", time_asctime, METH_VARARGS, asctime_doc}, - {"ctime", time_ctime, METH_VARARGS, ctime_doc}, -#ifdef HAVE_MKTIME - {"mktime", time_mktime, METH_VARARGS, mktime_doc}, -#endif -#ifdef HAVE_STRFTIME - {"strftime", time_strftime, METH_VARARGS, strftime_doc}, -#endif - {"strptime", time_strptime, METH_VARARGS, strptime_doc}, -#ifdef HAVE_WORKING_TZSET - {"tzset", time_tzset, METH_VARARGS, tzset_doc}, -#endif - {NULL, NULL} /* sentinel */ -}; - - -PyDoc_STRVAR(module_doc, -"This module provides various functions to manipulate time values.\n\ -\n\ -There are two standard representations of time. One is the number\n\ -of seconds since the Epoch, in UTC (a.k.a. GMT). It may be an integer\n\ -or a floating point number (to represent fractions of seconds).\n\ -The Epoch is system-defined; on Unix, it is generally January 1st, 1970.\n\ -The actual value can be retrieved by calling gmtime(0).\n\ -\n\ -The other representation is a tuple of 9 integers giving local time.\n\ -The tuple items are:\n\ - year (four digits, e.g. 1998)\n\ - month (1-12)\n\ - day (1-31)\n\ - hours (0-23)\n\ - minutes (0-59)\n\ - seconds (0-59)\n\ - weekday (0-6, Monday is 0)\n\ - Julian day (day in the year, 1-366)\n\ - DST (Daylight Savings Time) flag (-1, 0 or 1)\n\ -If the DST flag is 0, the time is given in the regular time zone;\n\ -if it is 1, the time is given in the DST time zone;\n\ -if it is -1, mktime() should guess based on the date and time.\n\ -\n\ -Variables:\n\ -\n\ -timezone -- difference in seconds between UTC and local standard time\n\ -altzone -- difference in seconds between UTC and local DST time\n\ -daylight -- whether local time should reflect DST\n\ -tzname -- tuple of (standard time zone name, DST time zone name)\n\ -\n\ -Functions:\n\ -\n\ -time() -- return current time in seconds since the Epoch as a float\n\ -clock() -- return CPU time since process start as a float\n\ -sleep() -- delay for a number of seconds given as a float\n\ -gmtime() -- convert seconds since Epoch to UTC tuple\n\ -localtime() -- convert seconds since Epoch to local time tuple\n\ -asctime() -- convert time tuple to string\n\ -ctime() -- convert time in seconds to string\n\ -mktime() -- convert local time tuple to seconds since Epoch\n\ -strftime() -- convert time tuple to string according to format specification\n\ -strptime() -- parse string to time tuple according to format specification\n\ -tzset() -- change the local timezone"); - - -PyMODINIT_FUNC -inittime(void) -{ - PyObject *m; - char *p; - m = Py_InitModule3("time", time_methods, module_doc); - - /* Accept 2-digit dates unless PYTHONY2K is set and non-empty */ - p = Py_GETENV("PYTHONY2K"); - PyModule_AddIntConstant(m, "accept2dyear", (long) (!p || !*p)); - /* Squirrel away the module's dictionary for the y2k check */ - moddict = PyModule_GetDict(m); - Py_INCREF(moddict); - - /* Set, or reset, module variables like time.timezone */ - inittimezone(m); - -#if defined(MS_WINDOWS) && !defined(MS_XBOX) - /* Helper to allow interrupts for Windows. - If Ctrl+C event delivered while not sleeping - it will be ignored. - */ - main_thread = PyThread_get_thread_ident(); - hInterruptEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - SetConsoleCtrlHandler( PyCtrlHandler, TRUE); -#endif /* MS_WINDOWS */ - PyStructSequence_InitType(&StructTimeType, &struct_time_type_desc); - Py_INCREF(&StructTimeType); - PyModule_AddObject(m, "struct_time", (PyObject*) &StructTimeType); -} - - -/* Implement floattime() for various platforms */ - -static double -floattime(void) -{ - /* There are three ways to get the time: - (1) gettimeofday() -- resolution in microseconds - (2) ftime() -- resolution in milliseconds - (3) time() -- resolution in seconds - In all cases the return value is a float in seconds. - Since on some systems (e.g. SCO ODT 3.0) gettimeofday() may - fail, so we fall back on ftime() or time(). - Note: clock resolution does not imply clock accuracy! */ -#ifdef HAVE_GETTIMEOFDAY - { - struct timeval t; -#ifdef GETTIMEOFDAY_NO_TZ - if (gettimeofday(&t) == 0) - return (double)t.tv_sec + t.tv_usec*0.000001; -#else /* !GETTIMEOFDAY_NO_TZ */ - if (gettimeofday(&t, (struct timezone *)NULL) == 0) - return (double)t.tv_sec + t.tv_usec*0.000001; -#endif /* !GETTIMEOFDAY_NO_TZ */ - } -#endif /* !HAVE_GETTIMEOFDAY */ - { -#if defined(HAVE_FTIME) - struct timeb t; - ftime(&t); - return (double)t.time + (double)t.millitm * (double)0.001; -#else /* !HAVE_FTIME */ - time_t secs; - time(&secs); - return (double)secs; -#endif /* !HAVE_FTIME */ - } -} - - -/* Implement floatsleep() for various platforms. - When interrupted (or when another error occurs), return -1 and - set an exception; else return 0. */ - -static int -floatsleep(double secs) -{ -/* XXX Should test for MS_WINDOWS first! */ -#if defined(HAVE_SELECT) && !defined(__BEOS__) && !defined(__EMX__) - struct timeval t; - double frac; - frac = fmod(secs, 1.0); - secs = floor(secs); - t.tv_sec = (long)secs; - t.tv_usec = (long)(frac*1000000.0); - Py_BEGIN_ALLOW_THREADS - if (select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t) != 0) { -#ifdef EINTR - if (errno != EINTR) { -#else - if (1) { -#endif - Py_BLOCK_THREADS - PyErr_SetFromErrno(PyExc_IOError); - return -1; - } - } - Py_END_ALLOW_THREADS -#elif defined(macintosh) -#define MacTicks (* (long *)0x16A) - long deadline; - deadline = MacTicks + (long)(secs * 60.0); - while (MacTicks < deadline) { - /* XXX Should call some yielding function here */ - if (PyErr_CheckSignals()) - return -1; - } -#elif defined(__WATCOMC__) && !defined(__QNX__) - /* XXX Can't interrupt this sleep */ - Py_BEGIN_ALLOW_THREADS - delay((int)(secs * 1000 + 0.5)); /* delay() uses milliseconds */ - Py_END_ALLOW_THREADS -#elif defined(MS_WINDOWS) - { - double millisecs = secs * 1000.0; - unsigned long ul_millis; - - if (millisecs > (double)ULONG_MAX) { - PyErr_SetString(PyExc_OverflowError, - "sleep length is too large"); - return -1; - } - Py_BEGIN_ALLOW_THREADS - /* Allow sleep(0) to maintain win32 semantics, and as decreed - * by Guido, only the main thread can be interrupted. - */ - ul_millis = (unsigned long)millisecs; - if (ul_millis == 0 || - main_thread != PyThread_get_thread_ident()) - Sleep(ul_millis); - else { - DWORD rc; - ResetEvent(hInterruptEvent); - rc = WaitForSingleObject(hInterruptEvent, ul_millis); - if (rc == WAIT_OBJECT_0) { - /* Yield to make sure real Python signal - * handler called. - */ - Sleep(1); - Py_BLOCK_THREADS - errno = EINTR; - PyErr_SetFromErrno(PyExc_IOError); - return -1; - } - } - Py_END_ALLOW_THREADS - } -#elif defined(PYOS_OS2) - /* This Sleep *IS* Interruptable by Exceptions */ - Py_BEGIN_ALLOW_THREADS - if (DosSleep(secs * 1000) != NO_ERROR) { - Py_BLOCK_THREADS - PyErr_SetFromErrno(PyExc_IOError); - return -1; - } - Py_END_ALLOW_THREADS -#elif defined(__BEOS__) - /* This sleep *CAN BE* interrupted. */ - { - if( secs <= 0.0 ) { - return; - } - - Py_BEGIN_ALLOW_THREADS - /* BeOS snooze() is in microseconds... */ - if( snooze( (bigtime_t)( secs * 1000.0 * 1000.0 ) ) == B_INTERRUPTED ) { - Py_BLOCK_THREADS - PyErr_SetFromErrno( PyExc_IOError ); - return -1; - } - Py_END_ALLOW_THREADS - } -#elif defined(RISCOS) - if (secs <= 0.0) - return 0; - Py_BEGIN_ALLOW_THREADS - /* This sleep *CAN BE* interrupted. */ - if ( riscos_sleep(secs) ) - return -1; - Py_END_ALLOW_THREADS -#elif defined(PLAN9) - { - double millisecs = secs * 1000.0; - if (millisecs > (double)LONG_MAX) { - PyErr_SetString(PyExc_OverflowError, "sleep length is too large"); - return -1; - } - /* This sleep *CAN BE* interrupted. */ - Py_BEGIN_ALLOW_THREADS - if(sleep((long)millisecs) < 0){ - Py_BLOCK_THREADS - PyErr_SetFromErrno(PyExc_IOError); - return -1; - } - Py_END_ALLOW_THREADS - } -#else - /* XXX Can't interrupt this sleep */ - Py_BEGIN_ALLOW_THREADS - sleep((int)secs); - Py_END_ALLOW_THREADS -#endif - - return 0; -} - - diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/timing.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/timing.h deleted file mode 100644 index bef8bcea..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/timing.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1993 George V. Neville-Neil - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by George V. Neville-Neil - * 4. The name, George Neville-Neil may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _TIMING_H_ -#define _TIMING_H_ - -#ifdef TIME_WITH_SYS_TIME -#include -#include -#else /* !TIME_WITH_SYS_TIME */ -#ifdef HAVE_SYS_TIME_H -#include -#else /* !HAVE_SYS_TIME_H */ -#include -#endif /* !HAVE_SYS_TIME_H */ -#endif /* !TIME_WITH_SYS_TIME */ - -static struct timeval aftertp, beforetp; - -#define BEGINTIMING gettimeofday(&beforetp, NULL) - -#define ENDTIMING gettimeofday(&aftertp, NULL); \ - if(beforetp.tv_usec > aftertp.tv_usec) \ - { \ - aftertp.tv_usec += 1000000; \ - aftertp.tv_sec--; \ - } - -#define TIMINGUS (((aftertp.tv_sec - beforetp.tv_sec) * 1000000) + \ - (aftertp.tv_usec - beforetp.tv_usec)) - -#define TIMINGMS (((aftertp.tv_sec - beforetp.tv_sec) * 1000) + \ - ((aftertp.tv_usec - beforetp.tv_usec) / 1000)) - -#define TIMINGS ((aftertp.tv_sec - beforetp.tv_sec) + \ - (aftertp.tv_usec - beforetp.tv_usec) / 1000000) - -#endif /* _TIMING_H_ */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/timingmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/timingmodule.c deleted file mode 100644 index 43de9224..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/timingmodule.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Author: George V. Neville-Neil - */ - -#include "Python.h" - -/* Our stuff... */ -#include "timing.h" - -static PyObject * -start_timing(PyObject *self) -{ - Py_INCREF(Py_None); - BEGINTIMING; - return Py_None; -} - -static PyObject * -finish_timing(PyObject *self) -{ - ENDTIMING - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -seconds(PyObject *self) -{ - return PyInt_FromLong(TIMINGS); -} - -static PyObject * -milli(PyObject *self) -{ - return PyInt_FromLong(TIMINGMS); -} - -static PyObject * -micro(PyObject *self) -{ - return PyInt_FromLong(TIMINGUS); -} - - -static PyMethodDef timing_methods[] = { - {"start", (PyCFunction)start_timing, METH_NOARGS}, - {"finish", (PyCFunction)finish_timing, METH_NOARGS}, - {"seconds", (PyCFunction)seconds, METH_NOARGS}, - {"milli", (PyCFunction)milli, METH_NOARGS}, - {"micro", (PyCFunction)micro, METH_NOARGS}, - {NULL, NULL} -}; - - -PyMODINIT_FUNC inittiming(void) -{ - (void)Py_InitModule("timing", timing_methods); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/tkappinit.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/tkappinit.c deleted file mode 100644 index f17f8592..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/tkappinit.c +++ /dev/null @@ -1,139 +0,0 @@ -/* appinit.c -- Tcl and Tk application initialization. - - The function Tcl_AppInit() below initializes various Tcl packages. - It is called for each Tcl interpreter created by _tkinter.create(). - It needs to be compiled with -DWITH_ flags for each package - that you are statically linking with. You may have to add sections - for packages not yet listed below. - - Note that those packages for which Tcl_StaticPackage() is called with - a NULL first argument are known as "static loadable" packages to - Tcl but not actually initialized. To use these, you have to load - it explicitly, e.g. tkapp.eval("load {} Blt"). - */ - -#include -#include - -int -Tcl_AppInit(Tcl_Interp *interp) -{ - Tk_Window main_window; - -#ifdef TK_AQUA -#ifndef MAX_PATH_LEN -#define MAX_PATH_LEN 1024 -#endif - char tclLibPath[MAX_PATH_LEN], tkLibPath[MAX_PATH_LEN]; - Tcl_Obj* pathPtr; - - /* pre- Tcl_Init code copied from tkMacOSXAppInit.c */ - Tk_MacOSXOpenBundleResources (interp, "com.tcltk.tcllibrary", - tclLibPath, MAX_PATH_LEN, 0); - - if (tclLibPath[0] != '\0') { - Tcl_SetVar(interp, "tcl_library", tclLibPath, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "tclDefaultLibrary", tclLibPath, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "tcl_pkgPath", tclLibPath, TCL_GLOBAL_ONLY); - } - - if (tclLibPath[0] != '\0') { - Tcl_SetVar(interp, "tcl_library", tclLibPath, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "tclDefaultLibrary", tclLibPath, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "tcl_pkgPath", tclLibPath, TCL_GLOBAL_ONLY); - } -#endif - if (Tcl_Init (interp) == TCL_ERROR) - return TCL_ERROR; - -#ifdef TK_AQUA - /* pre- Tk_Init code copied from tkMacOSXAppInit.c */ - Tk_MacOSXOpenBundleResources (interp, "com.tcltk.tklibrary", - tkLibPath, MAX_PATH_LEN, 1); - - if (tclLibPath[0] != '\0') { - pathPtr = Tcl_NewStringObj(tclLibPath, -1); - } else { - Tcl_Obj *pathPtr = TclGetLibraryPath(); - } - - if (tkLibPath[0] != '\0') { - Tcl_Obj *objPtr; - - Tcl_SetVar(interp, "tk_library", tkLibPath, TCL_GLOBAL_ONLY); - objPtr = Tcl_NewStringObj(tkLibPath, -1); - Tcl_ListObjAppendElement(NULL, pathPtr, objPtr); - } - - TclSetLibraryPath(pathPtr); -#endif - - if (Tk_Init (interp) == TCL_ERROR) - return TCL_ERROR; - - main_window = Tk_MainWindow(interp); - -#ifdef TK_AQUA - TkMacOSXInitAppleEvents(interp); - TkMacOSXInitMenus(interp); -#endif - -#ifdef WITH_MOREBUTTONS - { - extern Tcl_CmdProc studButtonCmd; - extern Tcl_CmdProc triButtonCmd; - - Tcl_CreateCommand(interp, "studbutton", studButtonCmd, - (ClientData) main_window, NULL); - Tcl_CreateCommand(interp, "tributton", triButtonCmd, - (ClientData) main_window, NULL); - } -#endif - -#ifdef WITH_PIL /* 0.2b5 and later -- not yet released as of May 14 */ - { - extern void TkImaging_Init(Tcl_Interp *); - TkImaging_Init(interp); - /* XXX TkImaging_Init() doesn't have the right return type */ - /*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/ - } -#endif - -#ifdef WITH_PIL_OLD /* 0.2b4 and earlier */ - { - extern void TkImaging_Init(void); - /* XXX TkImaging_Init() doesn't have the right prototype */ - /*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/ - } -#endif - -#ifdef WITH_TIX - { - extern int Tix_Init(Tcl_Interp *interp); - extern int Tix_SafeInit(Tcl_Interp *interp); - Tcl_StaticPackage(NULL, "Tix", Tix_Init, Tix_SafeInit); - } -#endif - -#ifdef WITH_BLT - { - extern int Blt_Init(Tcl_Interp *); - extern int Blt_SafeInit(Tcl_Interp *); - Tcl_StaticPackage(NULL, "Blt", Blt_Init, Blt_SafeInit); - } -#endif - -#ifdef WITH_TOGL - { - /* XXX I've heard rumors that this doesn't work */ - extern int Togl_Init(Tcl_Interp *); - /* XXX Is there no Togl_SafeInit? */ - Tcl_StaticPackage(NULL, "Togl", Togl_Init, NULL); - } -#endif - -#ifdef WITH_XXX - -#endif - return TCL_OK; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/unicodedata.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/unicodedata.c deleted file mode 100644 index 06dbd673..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/unicodedata.c +++ /dev/null @@ -1,899 +0,0 @@ -/* ------------------------------------------------------------------------ - - unicodedata -- Provides access to the Unicode 3.2 data base. - - Data was extracted from the Unicode 3.2 UnicodeData.txt file. - - Written by Marc-Andre Lemburg (mal@lemburg.com). - Modified for Python 2.0 by Fredrik Lundh (fredrik@pythonware.com) - Modified by Martin v. Löwis (martin@v.loewis.de) - - Copyright (c) Corporation for National Research Initiatives. - - ------------------------------------------------------------------------ */ - -#include "Python.h" -#include "ucnhash.h" - -/* character properties */ - -typedef struct { - const unsigned char category; /* index into - _PyUnicode_CategoryNames */ - const unsigned char combining; /* combining class value 0 - 255 */ - const unsigned char bidirectional; /* index into - _PyUnicode_BidirectionalNames */ - const unsigned char mirrored; /* true if mirrored in bidir mode */ -} _PyUnicode_DatabaseRecord; - -/* data file generated by Tools/unicode/makeunicodedata.py */ -#include "unicodedata_db.h" - -static const _PyUnicode_DatabaseRecord* -_getrecord_ex(Py_UCS4 code) -{ - int index; - if (code >= 0x110000) - index = 0; - else { - index = index1[(code>>SHIFT)]; - index = index2[(index<category; - return PyString_FromString(_PyUnicode_CategoryNames[index]); -} - -static PyObject * -unicodedata_bidirectional(PyObject *self, PyObject *args) -{ - PyUnicodeObject *v; - int index; - - if (!PyArg_ParseTuple(args, "O!:bidirectional", - &PyUnicode_Type, &v)) - return NULL; - if (PyUnicode_GET_SIZE(v) != 1) { - PyErr_SetString(PyExc_TypeError, - "need a single Unicode character as parameter"); - return NULL; - } - index = (int) _getrecord(v)->bidirectional; - return PyString_FromString(_PyUnicode_BidirectionalNames[index]); -} - -static PyObject * -unicodedata_combining(PyObject *self, PyObject *args) -{ - PyUnicodeObject *v; - - if (!PyArg_ParseTuple(args, "O!:combining", - &PyUnicode_Type, &v)) - return NULL; - if (PyUnicode_GET_SIZE(v) != 1) { - PyErr_SetString(PyExc_TypeError, - "need a single Unicode character as parameter"); - return NULL; - } - return PyInt_FromLong((int) _getrecord(v)->combining); -} - -static PyObject * -unicodedata_mirrored(PyObject *self, PyObject *args) -{ - PyUnicodeObject *v; - - if (!PyArg_ParseTuple(args, "O!:mirrored", - &PyUnicode_Type, &v)) - return NULL; - if (PyUnicode_GET_SIZE(v) != 1) { - PyErr_SetString(PyExc_TypeError, - "need a single Unicode character as parameter"); - return NULL; - } - return PyInt_FromLong((int) _getrecord(v)->mirrored); -} - -static PyObject * -unicodedata_decomposition(PyObject *self, PyObject *args) -{ - PyUnicodeObject *v; - char decomp[256]; - int code, index, count, i; - - if (!PyArg_ParseTuple(args, "O!:decomposition", - &PyUnicode_Type, &v)) - return NULL; - if (PyUnicode_GET_SIZE(v) != 1) { - PyErr_SetString(PyExc_TypeError, - "need a single Unicode character as parameter"); - return NULL; - } - - code = (int) *PyUnicode_AS_UNICODE(v); - - if (code < 0 || code >= 0x110000) - index = 0; - else { - index = decomp_index1[(code>>DECOMP_SHIFT)]; - index = decomp_index2[(index<> 8; - - /* XXX: could allocate the PyString up front instead - (strlen(prefix) + 5 * count + 1 bytes) */ - - /* copy prefix */ - i = strlen(decomp_prefix[decomp_data[index] & 255]); - memcpy(decomp, decomp_prefix[decomp_data[index] & 255], i); - - while (count-- > 0) { - if (i) - decomp[i++] = ' '; - assert((size_t)i < sizeof(decomp)); - PyOS_snprintf(decomp + i, sizeof(decomp) - i, "%04X", - decomp_data[++index]); - i += strlen(decomp + i); - } - - decomp[i] = '\0'; - - return PyString_FromString(decomp); -} - -void -get_decomp_record(Py_UCS4 code, int *index, int *prefix, int *count) -{ - if (code >= 0x110000) { - *index = 0; - } - else { - *index = decomp_index1[(code>>DECOMP_SHIFT)]; - *index = decomp_index2[(*index<> 8; - *prefix = decomp_data[*index] & 255; - - (*index)++; -} - -#define SBase 0xAC00 -#define LBase 0x1100 -#define VBase 0x1161 -#define TBase 0x11A7 -#define LCount 19 -#define VCount 21 -#define TCount 28 -#define NCount (VCount*TCount) -#define SCount (LCount*NCount) - -static PyObject* -nfd_nfkd(PyObject *input, int k) -{ - PyObject *result; - Py_UNICODE *i, *end, *o; - /* Longest decomposition in Unicode 3.2: U+FDFA */ - Py_UNICODE stack[20]; - int space, stackptr, isize; - int index, prefix, count; - unsigned char prev, cur; - - stackptr = 0; - isize = PyUnicode_GET_SIZE(input); - /* Overallocate atmost 10 characters. */ - space = (isize > 10 ? 10 : isize) + isize; - result = PyUnicode_FromUnicode(NULL, space); - if (!result) - return NULL; - i = PyUnicode_AS_UNICODE(input); - end = i + isize; - o = PyUnicode_AS_UNICODE(result); - - while (i < end) { - stack[stackptr++] = *i++; - while(stackptr) { - Py_UNICODE code = stack[--stackptr]; - /* Hangul Decomposition adds three characters in - a single step, so we need atleast that much room. */ - if (space < 3) { - int newsize = PyString_GET_SIZE(result) + 10; - space += 10; - if (PyUnicode_Resize(&result, newsize) == -1) - return NULL; - o = PyUnicode_AS_UNICODE(result) + newsize - space; - } - /* Hangul Decomposition. */ - if (SBase <= code && code < (SBase+SCount)) { - int SIndex = code - SBase; - int L = LBase + SIndex / NCount; - int V = VBase + (SIndex % NCount) / TCount; - int T = TBase + SIndex % TCount; - *o++ = L; - *o++ = V; - space -= 2; - if (T != TBase) { - *o++ = T; - space --; - } - continue; - } - /* Other decompoistions. */ - get_decomp_record(code, &index, &prefix, &count); - - /* Copy character if it is not decomposable, or has a - compatibility decomposition, but we do NFD. */ - if (!count || (prefix && !k)) { - *o++ = code; - space--; - continue; - } - /* Copy decomposition onto the stack, in reverse - order. */ - while(count) { - code = decomp_data[index + (--count)]; - stack[stackptr++] = code; - } - } - } - - /* Drop overallocation. Cannot fail. */ - PyUnicode_Resize(&result, PyUnicode_GET_SIZE(result) - space); - - /* Sort canonically. */ - i = PyUnicode_AS_UNICODE(result); - prev = _getrecord_ex(*i)->combining; - end = i + PyUnicode_GET_SIZE(result); - for (i++; i < end; i++) { - cur = _getrecord_ex(*i)->combining; - if (prev == 0 || cur == 0 || prev <= cur) { - prev = cur; - continue; - } - /* Non-canonical order. Need to switch *i with previous. */ - o = i - 1; - while (1) { - Py_UNICODE tmp = o[1]; - o[1] = o[0]; - o[0] = tmp; - o--; - if (o < PyUnicode_AS_UNICODE(result)) - break; - prev = _getrecord_ex(*o)->combining; - if (prev == 0 || prev <= cur) - break; - } - prev = _getrecord_ex(*i)->combining; - } - return result; -} - -static int -find_nfc_index(struct reindex* nfc, Py_UNICODE code) -{ - int index; - for (index = 0; nfc[index].start; index++) { - int start = nfc[index].start; - if (code < start) - return -1; - if (code <= start + nfc[index].count) { - int delta = code - start; - return nfc[index].index + delta; - } - } - return -1; -} - -static PyObject* -nfc_nfkc(PyObject *input, int k) -{ - PyObject *result; - Py_UNICODE *i, *i1, *o, *end; - int f,l,index,index1,comb; - Py_UNICODE code; - Py_UNICODE *skipped[20]; - int cskipped = 0; - - result = nfd_nfkd(input, k); - if (!result) - return NULL; - - /* We are going to modify result in-place. - If nfd_nfkd is changed to sometimes return the input, - this code needs to be reviewed. */ - assert(result != input); - - i = PyUnicode_AS_UNICODE(result); - end = i + PyUnicode_GET_SIZE(result); - o = PyUnicode_AS_UNICODE(result); - - again: - while (i < end) { - for (index = 0; index < cskipped; index++) { - if (skipped[index] == i) { - /* *i character is skipped. - Remove from list. */ - skipped[index] = skipped[cskipped-1]; - cskipped--; - i++; - goto again; /* continue while */ - } - } - /* Hangul Composition. We don't need to check for - pairs, since we always have decomposed data. */ - if (LBase <= *i && *i < (LBase+LCount) && - i + 1 < end && - VBase <= i[1] && i[1] <= (VBase+VCount)) { - int LIndex, VIndex; - LIndex = i[0] - LBase; - VIndex = i[1] - VBase; - code = SBase + (LIndex*VCount+VIndex)*TCount; - i+=2; - if (i < end && - TBase <= *i && *i <= (TBase+TCount)) { - code += *i-TBase; - i++; - } - *o++ = code; - continue; - } - - f = find_nfc_index(nfc_first, *i); - if (f == -1) { - *o++ = *i++; - continue; - } - /* Find next unblocked character. */ - i1 = i+1; - comb = 0; - while (i1 < end) { - int comb1 = _getrecord_ex(*i1)->combining; - if (comb1 && comb == comb1) { - /* Character is blocked. */ - i1++; - continue; - } - l = find_nfc_index(nfc_last, *i1); - /* *i1 cannot be combined with *i. If *i1 - is a starter, we don't need to look further. - Otherwise, record the combining class. */ - if (l == -1) { - not_combinable: - if (comb1 == 0) - break; - comb = comb1; - i1++; - continue; - } - index = f*TOTAL_LAST + l; - index1 = comp_index[index >> COMP_SHIFT]; - code = comp_data[(index1<>24) & 0xff)) & 0x00ffffff; - } - return h; -} - -static char *hangul_syllables[][3] = { - { "G", "A", "" }, - { "GG", "AE", "G" }, - { "N", "YA", "GG" }, - { "D", "YAE", "GS" }, - { "DD", "EO", "N", }, - { "R", "E", "NJ" }, - { "M", "YEO", "NH" }, - { "B", "YE", "D" }, - { "BB", "O", "L" }, - { "S", "WA", "LG" }, - { "SS", "WAE", "LM" }, - { "", "OE", "LB" }, - { "J", "YO", "LS" }, - { "JJ", "U", "LT" }, - { "C", "WEO", "LP" }, - { "K", "WE", "LH" }, - { "T", "WI", "M" }, - { "P", "YU", "B" }, - { "H", "EU", "BS" }, - { 0, "YI", "S" }, - { 0, "I", "SS" }, - { 0, 0, "NG" }, - { 0, 0, "J" }, - { 0, 0, "C" }, - { 0, 0, "K" }, - { 0, 0, "T" }, - { 0, 0, "P" }, - { 0, 0, "H" } -}; - -static int -is_unified_ideograph(Py_UCS4 code) -{ - return ( - (0x3400 <= code && code <= 0x4DB5) || /* CJK Ideograph Extension A */ - (0x4E00 <= code && code <= 0x9FA5) || /* CJK Ideograph */ - (0x20000 <= code && code <= 0x2A6D6));/* CJK Ideograph Extension B */ -} - -static int -_getucname(Py_UCS4 code, char* buffer, int buflen) -{ - int offset; - int i; - int word; - unsigned char* w; - - if (SBase <= code && code < SBase+SCount) { - /* Hangul syllable. */ - int SIndex = code - SBase; - int L = SIndex / NCount; - int V = (SIndex % NCount) / TCount; - int T = SIndex % TCount; - - if (buflen < 27) - /* Worst case: HANGUL SYLLABLE <10chars>. */ - return 0; - strcpy(buffer, "HANGUL SYLLABLE "); - buffer += 16; - strcpy(buffer, hangul_syllables[L][0]); - buffer += strlen(hangul_syllables[L][0]); - strcpy(buffer, hangul_syllables[V][1]); - buffer += strlen(hangul_syllables[V][1]); - strcpy(buffer, hangul_syllables[T][2]); - buffer += strlen(hangul_syllables[T][2]); - *buffer = '\0'; - return 1; - } - - if (is_unified_ideograph(code)) { - if (buflen < 28) - /* Worst case: CJK UNIFIED IDEOGRAPH-20000 */ - return 0; - sprintf(buffer, "CJK UNIFIED IDEOGRAPH-%X", code); - return 1; - } - - if (code >= 0x110000) - return 0; - - /* get offset into phrasebook */ - offset = phrasebook_offset1[(code>>phrasebook_shift)]; - offset = phrasebook_offset2[(offset<= 0) { - word = (word << 8) + phrasebook[offset+1]; - offset += 2; - } else - word = phrasebook[offset++]; - if (i) { - if (i > buflen) - return 0; /* buffer overflow */ - buffer[i++] = ' '; - } - /* copy word string from lexicon. the last character in the - word has bit 7 set. the last word in a string ends with - 0x80 */ - w = lexicon + lexicon_offset[word]; - while (*w < 128) { - if (i >= buflen) - return 0; /* buffer overflow */ - buffer[i++] = *w++; - } - if (i >= buflen) - return 0; /* buffer overflow */ - buffer[i++] = *w & 127; - if (*w == 128) - break; /* end of word */ - } - - return 1; -} - -static int -_cmpname(int code, const char* name, int namelen) -{ - /* check if code corresponds to the given name */ - int i; - char buffer[NAME_MAXLEN]; - if (!_getucname(code, buffer, sizeof(buffer))) - return 0; - for (i = 0; i < namelen; i++) { - if (toupper(name[i]) != buffer[i]) - return 0; - } - return buffer[namelen] == '\0'; -} - -static void -find_syllable(const char *str, int *len, int *pos, int count, int column) -{ - int i, len1; - *len = -1; - for (i = 0; i < count; i++) { - char *s = hangul_syllables[i][column]; - len1 = strlen(s); - if (len1 <= *len) - continue; - if (strncmp(str, s, len1) == 0) { - *len = len1; - *pos = i; - } - } - if (*len == -1) { - *len = 0; - *pos = -1; - } -} - -static int -_getcode(const char* name, int namelen, Py_UCS4* code) -{ - unsigned int h, v; - unsigned int mask = code_size-1; - unsigned int i, incr; - - /* Check for hangul syllables. */ - if (strncmp(name, "HANGUL SYLLABLE ", 16) == 0) { - int L, V, T, len; - const char *pos = name + 16; - find_syllable(pos, &len, &L, LCount, 0); - pos += len; - find_syllable(pos, &len, &V, VCount, 1); - pos += len; - find_syllable(pos, &len, &T, TCount, 2); - pos += len; - if (V != -1 && V != -1 && T != -1 && pos-name == namelen) { - *code = SBase + (L*VCount+V)*TCount + T; - return 1; - } - /* Otherwise, it's an illegal syllable name. */ - return 0; - } - - /* Check for unified ideographs. */ - if (strncmp(name, "CJK UNIFIED IDEOGRAPH-", 22) == 0) { - /* Four or five hexdigits must follow. */ - v = 0; - name += 22; - namelen -= 22; - if (namelen != 4 && namelen != 5) - return 0; - while (namelen--) { - v *= 16; - if (*name >= '0' && *name <= '9') - v += *name - '0'; - else if (*name >= 'A' && *name <= 'F') - v += *name - 'A' + 10; - else - return 0; - name++; - } - if (!is_unified_ideograph(v)) - return 0; - *code = v; - return 1; - } - - /* the following is the same as python's dictionary lookup, with - only minor changes. see the makeunicodedata script for more - details */ - - h = (unsigned int) _gethash(name, namelen, code_magic); - i = (~h) & mask; - v = code_hash[i]; - if (!v) - return 0; - if (_cmpname(v, name, namelen)) { - *code = v; - return 1; - } - incr = (h ^ (h >> 3)) & mask; - if (!incr) - incr = mask; - for (;;) { - i = (i + incr) & mask; - v = code_hash[i]; - if (!v) - return 0; - if (_cmpname(v, name, namelen)) { - *code = v; - return 1; - } - incr = incr << 1; - if (incr > mask) - incr = incr ^ code_poly; - } -} - -static const _PyUnicode_Name_CAPI hashAPI = -{ - sizeof(_PyUnicode_Name_CAPI), - _getucname, - _getcode -}; - -/* -------------------------------------------------------------------- */ -/* Python bindings */ - -static PyObject * -unicodedata_name(PyObject* self, PyObject* args) -{ - char name[NAME_MAXLEN]; - - PyUnicodeObject* v; - PyObject* defobj = NULL; - if (!PyArg_ParseTuple(args, "O!|O:name", &PyUnicode_Type, &v, &defobj)) - return NULL; - - if (PyUnicode_GET_SIZE(v) != 1) { - PyErr_SetString(PyExc_TypeError, - "need a single Unicode character as parameter"); - return NULL; - } - - if (!_getucname((Py_UCS4) *PyUnicode_AS_UNICODE(v), - name, sizeof(name))) { - if (defobj == NULL) { - PyErr_SetString(PyExc_ValueError, "no such name"); - return NULL; - } - else { - Py_INCREF(defobj); - return defobj; - } - } - - return Py_BuildValue("s", name); -} - -static PyObject * -unicodedata_lookup(PyObject* self, PyObject* args) -{ - Py_UCS4 code; - Py_UNICODE str[1]; - - char* name; - int namelen; - if (!PyArg_ParseTuple(args, "s#:lookup", &name, &namelen)) - return NULL; - - if (!_getcode(name, namelen, &code)) { - char fmt[] = "undefined character name '%s'"; - char *buf = PyMem_MALLOC(sizeof(fmt) + namelen); - sprintf(buf, fmt, name); - PyErr_SetString(PyExc_KeyError, buf); - PyMem_FREE(buf); - return NULL; - } - - str[0] = (Py_UNICODE) code; - return PyUnicode_FromUnicode(str, 1); -} - -/* XXX Add doc strings. */ - -static PyMethodDef unicodedata_functions[] = { - {"decimal", unicodedata_decimal, METH_VARARGS}, - {"digit", unicodedata_digit, METH_VARARGS}, - {"numeric", unicodedata_numeric, METH_VARARGS}, - {"category", unicodedata_category, METH_VARARGS}, - {"bidirectional", unicodedata_bidirectional, METH_VARARGS}, - {"combining", unicodedata_combining, METH_VARARGS}, - {"mirrored", unicodedata_mirrored, METH_VARARGS}, - {"decomposition",unicodedata_decomposition, METH_VARARGS}, - {"name", unicodedata_name, METH_VARARGS}, - {"lookup", unicodedata_lookup, METH_VARARGS}, - {"normalize", unicodedata_normalize, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - -PyDoc_STRVAR(unicodedata_docstring, "unicode character database"); - -PyMODINIT_FUNC -initunicodedata(void) -{ - PyObject *m, *v; - - m = Py_InitModule3( - "unicodedata", unicodedata_functions, unicodedata_docstring); - if (!m) - return; - - PyModule_AddStringConstant(m, "unidata_version", UNIDATA_VERSION); - - /* Export C API */ - v = PyCObject_FromVoidPtr((void *) &hashAPI, NULL); - if (v != NULL) - PyModule_AddObject(m, "ucnhash_CAPI", v); -} - -/* -Local variables: -c-basic-offset: 4 -indent-tabs-mode: nil -End: -*/ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/unicodedata_db.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/unicodedata_db.h deleted file mode 100644 index b6cba477..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/unicodedata_db.h +++ /dev/null @@ -1,3781 +0,0 @@ -/* this file was generated by Tools/unicode/makeunicodedata.py 2.2 */ - -#define UNIDATA_VERSION "3.2.0" -/* a list of unique database records */ -const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = { - {0, 0, 0, 0}, - {13, 0, 15, 0}, - {13, 0, 17, 0}, - {13, 0, 16, 0}, - {13, 0, 18, 0}, - {10, 0, 18, 0}, - {26, 0, 19, 0}, - {26, 0, 11, 0}, - {28, 0, 11, 0}, - {22, 0, 19, 1}, - {23, 0, 19, 1}, - {27, 0, 11, 0}, - {26, 0, 13, 0}, - {21, 0, 11, 0}, - {26, 0, 10, 0}, - {7, 0, 9, 0}, - {27, 0, 19, 1}, - {27, 0, 19, 0}, - {1, 0, 1, 0}, - {29, 0, 19, 0}, - {20, 0, 19, 0}, - {2, 0, 1, 0}, - {10, 0, 13, 0}, - {30, 0, 19, 0}, - {24, 0, 19, 1}, - {21, 0, 19, 0}, - {30, 0, 11, 0}, - {9, 0, 9, 0}, - {25, 0, 19, 1}, - {9, 0, 19, 0}, - {19, 0, 1, 0}, - {3, 0, 1, 0}, - {18, 0, 1, 0}, - {4, 230, 14, 0}, - {4, 232, 14, 0}, - {4, 220, 14, 0}, - {4, 216, 14, 0}, - {4, 202, 14, 0}, - {4, 1, 14, 0}, - {4, 240, 14, 0}, - {4, 0, 14, 0}, - {4, 234, 14, 0}, - {4, 233, 14, 0}, - {30, 0, 1, 0}, - {6, 0, 14, 0}, - {26, 0, 1, 0}, - {4, 222, 14, 0}, - {4, 228, 14, 0}, - {4, 10, 14, 0}, - {4, 11, 14, 0}, - {4, 12, 14, 0}, - {4, 13, 14, 0}, - {4, 14, 14, 0}, - {4, 15, 14, 0}, - {4, 16, 14, 0}, - {4, 17, 14, 0}, - {4, 18, 14, 0}, - {4, 19, 14, 0}, - {4, 20, 14, 0}, - {4, 21, 14, 0}, - {4, 22, 14, 0}, - {26, 0, 4, 0}, - {4, 23, 14, 0}, - {4, 24, 14, 0}, - {4, 25, 14, 0}, - {19, 0, 4, 0}, - {26, 0, 5, 0}, - {19, 0, 5, 0}, - {18, 0, 5, 0}, - {4, 27, 14, 0}, - {4, 28, 14, 0}, - {4, 29, 14, 0}, - {4, 30, 14, 0}, - {4, 31, 14, 0}, - {4, 32, 14, 0}, - {4, 33, 14, 0}, - {4, 34, 14, 0}, - {7, 0, 12, 0}, - {26, 0, 12, 0}, - {4, 35, 14, 0}, - {14, 0, 5, 0}, - {30, 0, 5, 0}, - {14, 0, 15, 0}, - {4, 36, 14, 0}, - {5, 0, 1, 0}, - {4, 7, 14, 0}, - {4, 9, 14, 0}, - {7, 0, 1, 0}, - {9, 0, 1, 0}, - {4, 84, 14, 0}, - {4, 91, 14, 0}, - {4, 103, 14, 0}, - {4, 107, 14, 0}, - {4, 118, 14, 0}, - {4, 122, 14, 0}, - {22, 0, 19, 0}, - {23, 0, 19, 0}, - {4, 129, 14, 0}, - {4, 130, 14, 0}, - {4, 132, 14, 0}, - {8, 0, 1, 0}, - {10, 0, 15, 0}, - {14, 0, 1, 0}, - {14, 0, 4, 0}, - {24, 0, 19, 0}, - {25, 0, 19, 0}, - {11, 0, 18, 0}, - {12, 0, 16, 0}, - {14, 0, 2, 0}, - {14, 0, 6, 0}, - {14, 0, 8, 0}, - {14, 0, 3, 0}, - {14, 0, 7, 0}, - {4, 218, 14, 0}, - {4, 224, 14, 0}, - {4, 8, 14, 0}, - {15, 0, 1, 0}, - {16, 0, 1, 0}, - {4, 26, 14, 0}, - {28, 0, 5, 0}, - {5, 216, 1, 0}, - {5, 226, 1, 0}, - {27, 0, 1, 0}, -}; - -/* Reindexing of NFC first characters. */ -#define TOTAL_FIRST 356 -#define TOTAL_LAST 53 -struct reindex{int start;short count,index;}; -struct reindex nfc_first[] = { - { 60, 2, 0}, - { 65, 15, 3}, - { 82, 8, 19}, - { 97, 15, 28}, - { 114, 8, 44}, - { 168, 0, 53}, - { 194, 0, 54}, - { 196, 3, 55}, - { 202, 0, 59}, - { 207, 0, 60}, - { 212, 2, 61}, - { 216, 0, 64}, - { 220, 0, 65}, - { 226, 0, 66}, - { 228, 3, 67}, - { 234, 0, 71}, - { 239, 0, 72}, - { 244, 2, 73}, - { 248, 0, 76}, - { 252, 0, 77}, - { 258, 1, 78}, - { 274, 1, 80}, - { 332, 1, 82}, - { 346, 1, 84}, - { 352, 1, 86}, - { 360, 3, 88}, - { 383, 0, 92}, - { 416, 1, 93}, - { 431, 1, 95}, - { 439, 0, 97}, - { 490, 1, 98}, - { 550, 3, 100}, - { 558, 1, 104}, - { 658, 0, 106}, - { 913, 0, 107}, - { 917, 0, 108}, - { 919, 0, 109}, - { 921, 0, 110}, - { 927, 0, 111}, - { 929, 0, 112}, - { 933, 0, 113}, - { 937, 0, 114}, - { 940, 0, 115}, - { 942, 0, 116}, - { 945, 0, 117}, - { 949, 0, 118}, - { 951, 0, 119}, - { 953, 0, 120}, - { 959, 0, 121}, - { 961, 0, 122}, - { 965, 0, 123}, - { 969, 2, 124}, - { 974, 0, 127}, - { 978, 0, 128}, - { 1030, 0, 129}, - { 1040, 0, 130}, - { 1043, 0, 131}, - { 1045, 3, 132}, - { 1050, 0, 136}, - { 1054, 0, 137}, - { 1059, 0, 138}, - { 1063, 0, 139}, - { 1067, 0, 140}, - { 1069, 0, 141}, - { 1072, 0, 142}, - { 1075, 0, 143}, - { 1077, 3, 144}, - { 1082, 0, 148}, - { 1086, 0, 149}, - { 1091, 0, 150}, - { 1095, 0, 151}, - { 1099, 0, 152}, - { 1101, 0, 153}, - { 1110, 0, 154}, - { 1140, 1, 155}, - { 1240, 1, 157}, - { 1256, 1, 159}, - { 1575, 0, 161}, - { 1608, 0, 162}, - { 1610, 0, 163}, - { 1729, 0, 164}, - { 1746, 0, 165}, - { 1749, 0, 166}, - { 2344, 0, 167}, - { 2352, 0, 168}, - { 2355, 0, 169}, - { 2503, 0, 170}, - { 2887, 0, 171}, - { 2962, 0, 172}, - { 3014, 1, 173}, - { 3142, 0, 175}, - { 3263, 0, 176}, - { 3270, 0, 177}, - { 3274, 0, 178}, - { 3398, 1, 179}, - { 3545, 0, 181}, - { 3548, 0, 182}, - { 4133, 0, 183}, - { 7734, 1, 184}, - { 7770, 1, 186}, - { 7778, 1, 188}, - { 7840, 1, 190}, - { 7864, 1, 192}, - { 7884, 1, 194}, - { 7936, 17, 196}, - { 7960, 1, 214}, - { 7968, 17, 216}, - { 7992, 1, 234}, - { 8000, 1, 236}, - { 8008, 1, 238}, - { 8016, 1, 240}, - { 8025, 0, 242}, - { 8032, 16, 243}, - { 8052, 0, 260}, - { 8060, 0, 261}, - { 8118, 0, 262}, - { 8127, 0, 263}, - { 8134, 0, 264}, - { 8182, 0, 265}, - { 8190, 0, 266}, - { 8592, 0, 267}, - { 8594, 0, 268}, - { 8596, 0, 269}, - { 8656, 0, 270}, - { 8658, 0, 271}, - { 8660, 0, 272}, - { 8707, 0, 273}, - { 8712, 0, 274}, - { 8715, 0, 275}, - { 8739, 0, 276}, - { 8741, 0, 277}, - { 8764, 0, 278}, - { 8771, 0, 279}, - { 8773, 0, 280}, - { 8776, 0, 281}, - { 8781, 0, 282}, - { 8801, 0, 283}, - { 8804, 1, 284}, - { 8818, 1, 286}, - { 8822, 1, 288}, - { 8826, 3, 290}, - { 8834, 1, 294}, - { 8838, 1, 296}, - { 8849, 1, 298}, - { 8866, 0, 300}, - { 8872, 1, 301}, - { 8875, 0, 303}, - { 8882, 3, 304}, - { 12358, 0, 308}, - { 12363, 0, 309}, - { 12365, 0, 310}, - { 12367, 0, 311}, - { 12369, 0, 312}, - { 12371, 0, 313}, - { 12373, 0, 314}, - { 12375, 0, 315}, - { 12377, 0, 316}, - { 12379, 0, 317}, - { 12381, 0, 318}, - { 12383, 0, 319}, - { 12385, 0, 320}, - { 12388, 0, 321}, - { 12390, 0, 322}, - { 12392, 0, 323}, - { 12399, 0, 324}, - { 12402, 0, 325}, - { 12405, 0, 326}, - { 12408, 0, 327}, - { 12411, 0, 328}, - { 12445, 0, 329}, - { 12454, 0, 330}, - { 12459, 0, 331}, - { 12461, 0, 332}, - { 12463, 0, 333}, - { 12465, 0, 334}, - { 12467, 0, 335}, - { 12469, 0, 336}, - { 12471, 0, 337}, - { 12473, 0, 338}, - { 12475, 0, 339}, - { 12477, 0, 340}, - { 12479, 0, 341}, - { 12481, 0, 342}, - { 12484, 0, 343}, - { 12486, 0, 344}, - { 12488, 0, 345}, - { 12495, 0, 346}, - { 12498, 0, 347}, - { 12501, 0, 348}, - { 12504, 0, 349}, - { 12507, 0, 350}, - { 12527, 3, 351}, - { 12541, 0, 355}, - {0,0,0} -}; - -struct reindex nfc_last[] = { - { 768, 4, 0}, - { 774, 6, 5}, - { 783, 0, 12}, - { 785, 0, 13}, - { 787, 1, 14}, - { 795, 0, 16}, - { 803, 5, 17}, - { 813, 1, 23}, - { 816, 1, 25}, - { 824, 0, 27}, - { 834, 0, 28}, - { 837, 0, 29}, - { 1619, 2, 30}, - { 2364, 0, 33}, - { 2494, 0, 34}, - { 2519, 0, 35}, - { 2878, 0, 36}, - { 2902, 1, 37}, - { 3006, 0, 39}, - { 3031, 0, 40}, - { 3158, 0, 41}, - { 3266, 0, 42}, - { 3285, 1, 43}, - { 3390, 0, 45}, - { 3415, 0, 46}, - { 3530, 0, 47}, - { 3535, 0, 48}, - { 3551, 0, 49}, - { 4142, 0, 50}, - { 12441, 1, 51}, - {0,0,0} -}; - -/* string literals */ -const char *_PyUnicode_CategoryNames[] = { - "Cn", - "Lu", - "Ll", - "Lt", - "Mn", - "Mc", - "Me", - "Nd", - "Nl", - "No", - "Zs", - "Zl", - "Zp", - "Cc", - "Cf", - "Cs", - "Co", - "Cn", - "Lm", - "Lo", - "Pc", - "Pd", - "Ps", - "Pe", - "Pi", - "Pf", - "Po", - "Sm", - "Sc", - "Sk", - "So", - NULL -}; -const char *_PyUnicode_BidirectionalNames[] = { - "", - "L", - "LRE", - "LRO", - "R", - "AL", - "RLE", - "RLO", - "PDF", - "EN", - "ES", - "ET", - "AN", - "CS", - "NSM", - "BN", - "B", - "S", - "WS", - "ON", - NULL -}; -static const char *decomp_prefix[] = { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - NULL -}; -/* index tables for the database records */ -#define SHIFT 8 -static unsigned char index1[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 8, 8, 8, 8, 8, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 8, 8, 8, 38, 39, 40, 41, 42, 43, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 44, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 45, 21, 21, 21, 21, 46, 8, 8, 8, - 8, 8, 8, 8, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 47, 48, 48, 48, 48, 48, 48, 48, - 48, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 21, 50, 51, 52, 53, 54, 55, 8, 8, 8, 56, - 57, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 58, 59, 8, 8, 60, 61, 62, 63, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 64, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 21, 21, 65, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 66, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 67, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 67, -}; - -static unsigned char index2[] = { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 3, 3, 3, 2, 5, 6, 6, 7, 8, 7, 6, 6, 9, 10, 6, 11, 12, 13, 12, - 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 12, 6, 16, 17, 16, 6, 6, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 9, 6, 10, 19, 20, 19, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 9, 17, 10, 17, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 22, 6, 8, 8, 8, 8, 23, - 23, 19, 23, 21, 24, 17, 25, 23, 19, 26, 11, 27, 27, 19, 21, 23, 6, 19, - 27, 21, 28, 29, 29, 29, 6, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 18, 18, 18, 18, 18, - 18, 18, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 17, 21, 21, 21, 21, 21, 21, 21, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 18, 21, 18, 21, 18, 21, - 21, 21, 18, 18, 21, 18, 21, 18, 18, 21, 18, 18, 18, 21, 21, 18, 18, 18, - 18, 21, 18, 18, 21, 18, 18, 18, 21, 21, 21, 18, 18, 21, 18, 18, 21, 18, - 21, 18, 21, 18, 18, 21, 18, 21, 21, 18, 21, 18, 18, 21, 18, 18, 18, 21, - 18, 21, 18, 18, 21, 21, 30, 18, 21, 21, 21, 30, 30, 30, 30, 18, 31, 21, - 18, 31, 21, 18, 31, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, - 18, 21, 18, 21, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 21, 18, 31, 21, 18, 21, 18, 18, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 0, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 0, 0, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 19, 19, 32, 32, 32, 32, 32, 32, 32, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 32, 32, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 32, 32, 32, 32, 32, 19, 19, 19, 19, 19, 19, 19, 19, 19, 32, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 33, 33, 33, 33, - 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 35, - 35, 35, 35, 34, 36, 35, 35, 35, 35, 35, 37, 37, 35, 35, 35, 35, 37, 37, - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 38, 38, 38, 38, 38, 35, 35, - 35, 35, 33, 33, 33, 33, 33, 33, 33, 33, 39, 33, 35, 35, 35, 33, 33, 33, - 35, 35, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 42, - 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 0, 0, 0, 0, 19, 19, - 0, 0, 0, 0, 32, 0, 0, 0, 6, 0, 0, 0, 0, 0, 19, 19, 18, 6, 18, 18, 18, 0, - 18, 0, 18, 18, 21, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 0, 21, 21, 18, 18, - 18, 21, 21, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, - 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 21, 21, 21, 21, 18, 21, 17, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 43, 33, 33, 33, 33, 0, 44, 44, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 0, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 0, 0, - 18, 21, 0, 0, 0, 0, 0, 0, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, - 18, 21, 18, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 0, 0, 32, 45, 45, 45, 45, - 45, 45, 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 0, 45, 25, 0, 0, 0, 0, 0, 0, 35, 33, 33, 33, 33, - 35, 33, 33, 33, 46, 35, 33, 33, 33, 33, 33, 33, 0, 35, 35, 35, 35, 35, - 33, 33, 35, 33, 33, 46, 47, 33, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 0, 58, 59, 60, 61, 62, 61, 63, 64, 61, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 0, 0, 0, 0, 65, 65, 65, 61, - 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 66, 0, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 0, 0, 0, 0, 0, 68, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 69, 70, 71, 72, 73, 74, 75, 76, 33, 33, 35, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 7, 78, 78, 66, 67, - 67, 79, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 66, 67, 33, 33, 33, 33, 33, - 33, 33, 80, 44, 33, 33, 33, 33, 35, 33, 68, 68, 33, 33, 23, 35, 33, 33, - 35, 0, 0, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 67, 67, 67, 81, 81, 0, - 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 0, 82, 67, 83, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 0, 0, 0, 33, 35, 33, 33, 35, 33, 33, - 35, 35, 35, 33, 35, 35, 33, 35, 33, 33, 33, 35, 33, 35, 33, 35, 33, 35, - 33, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, - 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 40, 40, 84, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 0, 0, 85, 30, 84, 84, 84, 40, 40, 40, 40, 40, 40, 40, 40, 84, - 84, 84, 84, 86, 0, 0, 30, 33, 35, 33, 33, 0, 0, 0, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 40, 40, 45, 45, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 84, 84, 0, - 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 30, 30, 0, 0, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, - 30, 30, 30, 30, 30, 30, 30, 0, 30, 0, 0, 0, 30, 30, 30, 30, 0, 0, 85, 0, - 84, 84, 84, 40, 40, 40, 40, 0, 0, 84, 84, 0, 0, 84, 84, 86, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 84, 0, 0, 0, 0, 30, 30, 0, 30, 30, 30, 40, 40, 0, 0, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 30, 30, 8, 8, 88, 88, 88, 88, 88, 88, - 43, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, - 30, 30, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 0, - 30, 30, 0, 30, 30, 0, 0, 85, 0, 84, 84, 84, 40, 40, 0, 0, 0, 0, 40, 40, - 0, 0, 40, 40, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 0, 30, - 0, 0, 0, 0, 0, 0, 0, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 40, 40, 30, - 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 40, 84, 0, 30, 30, 30, - 30, 30, 30, 30, 0, 30, 0, 30, 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, - 30, 30, 30, 30, 0, 30, 30, 0, 30, 30, 30, 30, 30, 0, 0, 85, 30, 84, 84, - 84, 40, 40, 40, 40, 40, 0, 40, 40, 84, 0, 84, 84, 86, 0, 0, 30, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 40, 84, 84, 0, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 30, 30, 0, 0, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 0, 0, 30, 30, 30, - 30, 0, 0, 85, 30, 84, 40, 84, 40, 40, 40, 0, 0, 0, 84, 84, 0, 0, 84, 84, - 86, 0, 0, 0, 0, 0, 0, 0, 0, 40, 84, 0, 0, 0, 0, 30, 30, 0, 30, 30, 30, 0, - 0, 0, 0, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 43, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 30, 0, 30, 30, 30, 30, 30, 30, 0, 0, 0, - 30, 30, 30, 0, 30, 30, 30, 30, 0, 0, 0, 30, 30, 0, 30, 0, 30, 30, 0, 0, - 0, 30, 30, 0, 0, 0, 30, 30, 30, 0, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, - 0, 30, 30, 30, 0, 0, 0, 0, 84, 84, 40, 84, 84, 0, 0, 0, 84, 84, 84, 0, - 84, 84, 84, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 87, 87, 87, 87, 87, 87, 87, 87, 87, 88, 88, 88, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, 84, 84, 0, 30, 30, 30, 30, 30, - 30, 30, 30, 0, 30, 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 0, 30, 30, 30, 30, 30, 0, 0, 0, 0, 40, 40, 40, 84, - 84, 84, 84, 0, 40, 40, 40, 0, 40, 40, 40, 86, 0, 0, 0, 0, 0, 0, 0, 89, - 90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 0, 0, 0, 0, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 84, 84, 0, 30, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, 0, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, 30, 30, - 0, 0, 0, 0, 84, 40, 84, 84, 84, 84, 84, 0, 40, 84, 84, 0, 84, 84, 40, 86, - 0, 0, 0, 0, 0, 0, 0, 84, 84, 0, 0, 0, 0, 0, 0, 0, 30, 0, 30, 30, 0, 0, 0, - 0, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 84, 84, 0, 30, 30, 30, 30, 30, 30, 30, 30, 0, 30, - 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 84, 84, 84, 40, 40, 40, 0, 0, 84, - 84, 84, 0, 84, 84, 84, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, 0, 0, 0, 0, 0, - 0, 0, 0, 30, 30, 0, 0, 0, 0, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, 84, 0, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 30, 0, 0, - 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 86, 0, 0, 0, 0, 84, 84, 84, 40, 40, - 40, 0, 40, 0, 84, 84, 84, 84, 84, 84, 84, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, 84, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 30, 30, 40, 40, - 40, 40, 91, 91, 86, 0, 0, 0, 0, 8, 30, 30, 30, 30, 30, 30, 32, 40, 92, - 92, 92, 92, 40, 40, 40, 45, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 45, - 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 0, 30, 0, 0, 30, 30, 0, - 30, 0, 0, 30, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 0, 30, 30, 30, 30, 30, - 30, 30, 0, 30, 30, 30, 0, 30, 0, 30, 0, 0, 30, 30, 0, 30, 30, 30, 30, 40, - 30, 30, 40, 40, 40, 40, 93, 93, 0, 40, 40, 30, 0, 0, 30, 30, 30, 30, 30, - 0, 32, 0, 94, 94, 94, 94, 40, 40, 0, 0, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 0, 0, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 43, 43, 43, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 43, 43, 43, 43, - 43, 35, 35, 43, 43, 43, 43, 43, 43, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 43, 35, 43, 35, 43, 36, 95, - 96, 95, 96, 84, 84, 30, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 97, 98, - 40, 99, 40, 40, 40, 40, 40, 98, 98, 98, 98, 40, 84, 98, 40, 33, 33, 86, - 45, 33, 33, 30, 30, 30, 30, 0, 0, 0, 0, 40, 40, 40, 40, 40, 40, 40, 40, - 0, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, - 40, 0, 43, 43, 43, 43, 43, 43, 43, 43, 35, 43, 43, 43, 43, 43, 43, 0, 0, - 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, - 30, 30, 30, 30, 30, 0, 30, 30, 0, 84, 40, 40, 40, 40, 84, 40, 0, 0, 0, - 40, 85, 84, 86, 0, 0, 0, 0, 0, 0, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 45, 45, 45, 45, 45, 45, 30, 30, 30, 30, 30, 30, 84, 84, 40, 40, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 45, 0, 0, 0, 0, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, - 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, - 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 30, 30, 30, - 30, 30, 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 30, 0, 30, 30, - 30, 30, 0, 0, 30, 30, 30, 30, 30, 30, 30, 0, 30, 0, 30, 30, 30, 30, 0, 0, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 0, 30, 0, 30, 30, 30, 30, 0, 0, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 0, 30, 0, 30, 30, 30, 30, 0, 0, 30, 30, 30, 30, - 30, 30, 30, 0, 30, 0, 30, 30, 30, 30, 0, 0, 30, 30, 30, 30, 30, 30, 30, - 0, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 30, 0, 30, 30, 30, 30, 0, 0, 30, - 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 45, 45, - 45, 45, 45, 45, 45, 45, 87, 87, 87, 87, 87, 87, 87, 87, 87, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 45, 45, 30, 30, 30, 30, 30, 30, 30, - 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 95, 96, - 0, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 45, 45, 45, 100, 100, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, - 30, 30, 30, 30, 40, 40, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 40, 86, - 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, - 0, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 84, 84, 84, 40, 40, 40, 40, 40, - 40, 40, 84, 84, 84, 84, 84, 84, 84, 84, 40, 84, 84, 40, 40, 40, 40, 40, - 40, 40, 40, 40, 86, 40, 45, 45, 45, 32, 45, 45, 45, 8, 30, 0, 0, 0, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 25, 6, 6, 6, 6, 40, 40, - 40, 82, 0, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 0, 0, 0, 0, 0, 0, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, - 0, 0, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, - 21, 18, 21, 18, 21, 18, 21, 21, 21, 21, 21, 21, 21, 0, 0, 0, 0, 18, 21, - 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, - 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, - 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, - 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, - 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 18, 21, 0, 0, 0, - 0, 0, 0, 21, 21, 21, 21, 21, 21, 21, 21, 18, 18, 18, 18, 18, 18, 18, 18, - 21, 21, 21, 21, 21, 21, 0, 0, 18, 18, 18, 18, 18, 18, 0, 0, 21, 21, 21, - 21, 21, 21, 21, 21, 18, 18, 18, 18, 18, 18, 18, 18, 21, 21, 21, 21, 21, - 21, 21, 21, 18, 18, 18, 18, 18, 18, 18, 18, 21, 21, 21, 21, 21, 21, 0, 0, - 18, 18, 18, 18, 18, 18, 0, 0, 21, 21, 21, 21, 21, 21, 21, 21, 0, 18, 0, - 18, 0, 18, 0, 18, 21, 21, 21, 21, 21, 21, 21, 21, 18, 18, 18, 18, 18, 18, - 18, 18, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 0, 0, 21, - 21, 21, 21, 21, 21, 21, 21, 31, 31, 31, 31, 31, 31, 31, 31, 21, 21, 21, - 21, 21, 21, 21, 21, 31, 31, 31, 31, 31, 31, 31, 31, 21, 21, 21, 21, 21, - 21, 21, 21, 31, 31, 31, 31, 31, 31, 31, 31, 21, 21, 21, 21, 21, 0, 21, - 21, 18, 18, 18, 18, 31, 19, 21, 19, 19, 19, 21, 21, 21, 0, 21, 21, 18, - 18, 18, 18, 31, 19, 19, 19, 21, 21, 21, 21, 0, 0, 21, 21, 18, 18, 18, 18, - 0, 19, 19, 19, 21, 21, 21, 21, 21, 21, 21, 21, 18, 18, 18, 18, 18, 19, - 19, 19, 0, 0, 21, 21, 21, 0, 21, 21, 18, 18, 18, 18, 31, 19, 19, 0, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 101, 82, 82, 102, 103, 25, 25, 25, 25, 25, 25, - 6, 6, 104, 105, 95, 104, 104, 105, 95, 104, 6, 6, 6, 6, 6, 6, 6, 6, 106, - 107, 108, 109, 110, 111, 112, 5, 7, 7, 7, 7, 7, 6, 6, 6, 6, 24, 28, 6, 6, - 6, 6, 20, 20, 6, 6, 6, 17, 9, 10, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 17, 0, - 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 5, 82, 82, 82, 82, 0, 0, 0, 0, 0, 0, 82, - 82, 82, 82, 82, 82, 27, 21, 0, 0, 27, 27, 27, 27, 27, 27, 11, 11, 17, 9, - 10, 21, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 11, 11, 17, 9, 10, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 33, 38, 38, 33, 33, 33, - 33, 38, 38, 38, 33, 33, 44, 44, 44, 44, 33, 44, 44, 44, 38, 38, 33, 35, - 33, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 23, 23, 18, 23, 23, 23, 23, 18, 23, 23, 21, 18, 18, 18, 21, 21, 18, 18, - 18, 21, 23, 18, 23, 23, 23, 18, 18, 18, 18, 18, 23, 23, 23, 23, 23, 23, - 18, 23, 18, 23, 18, 23, 18, 18, 18, 18, 26, 21, 18, 18, 23, 18, 21, 30, - 30, 30, 30, 21, 23, 0, 0, 21, 18, 18, 16, 17, 17, 17, 17, 18, 21, 21, 21, - 21, 23, 17, 0, 0, 0, 0, 0, 0, 0, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, - 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, - 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 17, 17, 17, 17, 17, 23, 23, 23, 23, 23, 17, 17, 23, 23, 23, - 23, 17, 23, 23, 17, 23, 23, 17, 23, 23, 23, 23, 23, 23, 23, 17, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 17, 17, 23, 23, 17, 23, 17, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 17, 17, 17, 16, 16, 16, - 16, 16, 16, 17, 17, 17, 16, 11, 11, 17, 16, 16, 17, 17, 17, 16, 16, 16, - 16, 17, 16, 16, 16, 16, 17, 16, 17, 16, 17, 17, 17, 17, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 16, 17, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 16, - 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 17, 16, 17, 16, - 16, 16, 16, 16, 16, 16, 16, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 17, 17, 16, 16, 16, 16, 17, 17, 17, 17, 17, 16, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 16, 16, 17, 17, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 16, - 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 17, 17, 16, - 16, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 23, 23, 23, 23, 23, 23, 23, - 23, 16, 16, 16, 16, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 16, 16, 23, 23, 23, 23, 23, 23, 23, 9, 10, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 23, 17, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 43, 23, - 23, 23, 23, 23, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 95, 96, 6, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 27, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 0, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 17, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 17, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 17, 17, 17, 17, 17, 17, 17, 17, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 0, - 23, 23, 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 17, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 0, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 0, 23, 23, 23, 23, 0, 0, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 0, 23, 0, 23, 23, 23, 23, 0, 0, 0, 23, 0, - 23, 23, 23, 23, 23, 23, 23, 0, 0, 23, 23, 23, 23, 23, 23, 23, 9, 10, 9, - 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 23, 0, 0, 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 17, 17, 17, 16, 16, 16, 16, 17, 17, 17, 17, 17, 16, 16, - 16, 17, 17, 17, 16, 16, 16, 16, 9, 10, 9, 10, 9, 10, 0, 0, 0, 0, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, - 10, 9, 10, 9, 10, 9, 10, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, - 17, 16, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 17, 17, 17, - 16, 17, 17, 17, 17, 16, 16, 16, 16, 16, 17, 16, 16, 17, 17, 9, 10, 9, 10, - 16, 17, 17, 17, 17, 16, 17, 16, 16, 16, 17, 17, 16, 16, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 17, 17, 9, 10, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 16, 16, 16, 16, 17, 17, - 16, 17, 16, 17, 17, 16, 17, 16, 16, 16, 16, 17, 17, 17, 17, 17, 16, 16, - 17, 17, 17, 17, 17, 17, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 17, 17, 17, 17, 16, 16, - 16, 16, 17, 16, 16, 17, 17, 16, 16, 17, 17, 17, 17, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 17, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, - 17, 17, 17, 17, 16, 17, 16, 17, 17, 17, 16, 16, 16, 16, 16, 17, 17, 17, - 17, 17, 16, 16, 16, 17, 17, 17, 17, 16, 17, 17, 17, 16, 16, 16, 16, 16, - 17, 16, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 0, 0, 0, 0, 5, 6, 6, 6, 23, 32, 30, 100, 9, 10, 9, 10, 9, 10, 9, - 10, 9, 10, 23, 23, 9, 10, 9, 10, 9, 10, 9, 10, 25, 95, 96, 96, 23, 100, - 100, 100, 100, 100, 100, 100, 100, 100, 113, 47, 34, 46, 114, 114, 25, - 32, 32, 32, 32, 32, 23, 23, 100, 100, 100, 32, 30, 6, 23, 23, 0, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 115, 115, 19, 19, - 32, 32, 30, 25, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 20, 32, 32, 32, 30, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, - 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 0, 43, 43, 88, 88, 88, 88, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 0, 0, 0, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 0, 0, 0, 43, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 0, 0, 0, 0, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 0, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 0, 0, 0, 0, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 0, 0, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 0, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 21, 21, 21, - 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 21, 21, 21, 0, 0, 0, - 0, 0, 65, 118, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 11, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 65, 65, 0, 65, 0, - 65, 65, 0, 65, 65, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 95, 96, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 0, 0, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 119, 0, 0, 0, 40, 40, 40, 40, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 33, 33, 33, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 25, - 25, 20, 20, 95, 96, 95, 96, 95, 96, 95, 96, 95, 96, 95, 96, 95, 96, 95, - 96, 6, 6, 0, 0, 6, 6, 6, 6, 20, 20, 20, 12, 6, 12, 0, 6, 12, 6, 6, 25, - 95, 96, 95, 96, 95, 96, 7, 6, 6, 11, 13, 17, 17, 17, 0, 6, 8, 7, 6, 0, 0, - 0, 0, 67, 67, 67, 67, 67, 0, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 0, 0, 82, - 0, 6, 6, 7, 8, 7, 6, 6, 9, 10, 6, 11, 12, 13, 12, 14, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 12, 6, 16, 17, 16, 6, 6, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 9, 6, 10, 19, 20, 19, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 9, 17, 10, 17, 9, - 10, 6, 9, 10, 6, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 32, 32, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 0, 0, 0, 30, 30, 30, 30, 30, 30, 0, 0, 30, 30, 30, 30, - 30, 30, 0, 0, 30, 30, 30, 30, 30, 30, 0, 0, 30, 30, 30, 0, 0, 0, 8, 8, - 17, 19, 23, 8, 8, 0, 23, 17, 17, 17, 17, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 82, 82, 82, 23, 23, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 0, 88, 88, 88, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 0, 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 0, 0, 0, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 120, 120, 38, 38, 38, 43, 43, 43, 121, 120, 120, 120, - 120, 120, 82, 82, 82, 82, 82, 82, 82, 82, 35, 35, 35, 35, 35, 35, 35, 35, - 43, 43, 33, 33, 33, 33, 33, 35, 35, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 33, 33, 33, 33, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 21, 21, 21, 21, - 21, 21, 21, 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 18, 0, 18, 18, 0, 0, 18, 0, 0, 18, 18, 0, 0, 18, 18, 18, 18, 0, - 18, 18, 18, 18, 18, 18, 18, 18, 21, 21, 21, 21, 0, 21, 0, 21, 21, 21, 21, - 0, 21, 21, 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 18, 18, 0, 18, 18, 18, - 18, 0, 0, 18, 18, 18, 18, 18, 18, 18, 18, 0, 18, 18, 18, 18, 18, 18, 18, - 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 18, 18, 0, 18, 18, 18, 18, 0, 18, 18, - 18, 18, 18, 0, 18, 0, 0, 0, 18, 18, 18, 18, 18, 18, 18, 0, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 0, 0, 0, 0, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 122, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 122, 21, 21, 21, 21, 21, 21, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 122, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 122, 21, 21, - 21, 21, 21, 21, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 122, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 122, 21, 21, 21, 21, 21, 21, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 122, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 122, 21, 21, 21, 21, 21, 21, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 122, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 122, 21, 21, 21, 21, 21, 21, 0, 0, 0, - 0, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 0, 0, -}; - -/* decomposition data */ -static unsigned int decomp_data[] = { - 0, 257, 32, 514, 32, 776, 259, 97, 514, 32, 772, 259, 50, 259, 51, 514, - 32, 769, 258, 956, 514, 32, 807, 259, 49, 259, 111, 772, 49, 8260, 52, - 772, 49, 8260, 50, 772, 51, 8260, 52, 512, 65, 768, 512, 65, 769, 512, - 65, 770, 512, 65, 771, 512, 65, 776, 512, 65, 778, 512, 67, 807, 512, 69, - 768, 512, 69, 769, 512, 69, 770, 512, 69, 776, 512, 73, 768, 512, 73, - 769, 512, 73, 770, 512, 73, 776, 512, 78, 771, 512, 79, 768, 512, 79, - 769, 512, 79, 770, 512, 79, 771, 512, 79, 776, 512, 85, 768, 512, 85, - 769, 512, 85, 770, 512, 85, 776, 512, 89, 769, 512, 97, 768, 512, 97, - 769, 512, 97, 770, 512, 97, 771, 512, 97, 776, 512, 97, 778, 512, 99, - 807, 512, 101, 768, 512, 101, 769, 512, 101, 770, 512, 101, 776, 512, - 105, 768, 512, 105, 769, 512, 105, 770, 512, 105, 776, 512, 110, 771, - 512, 111, 768, 512, 111, 769, 512, 111, 770, 512, 111, 771, 512, 111, - 776, 512, 117, 768, 512, 117, 769, 512, 117, 770, 512, 117, 776, 512, - 121, 769, 512, 121, 776, 512, 65, 772, 512, 97, 772, 512, 65, 774, 512, - 97, 774, 512, 65, 808, 512, 97, 808, 512, 67, 769, 512, 99, 769, 512, 67, - 770, 512, 99, 770, 512, 67, 775, 512, 99, 775, 512, 67, 780, 512, 99, - 780, 512, 68, 780, 512, 100, 780, 512, 69, 772, 512, 101, 772, 512, 69, - 774, 512, 101, 774, 512, 69, 775, 512, 101, 775, 512, 69, 808, 512, 101, - 808, 512, 69, 780, 512, 101, 780, 512, 71, 770, 512, 103, 770, 512, 71, - 774, 512, 103, 774, 512, 71, 775, 512, 103, 775, 512, 71, 807, 512, 103, - 807, 512, 72, 770, 512, 104, 770, 512, 73, 771, 512, 105, 771, 512, 73, - 772, 512, 105, 772, 512, 73, 774, 512, 105, 774, 512, 73, 808, 512, 105, - 808, 512, 73, 775, 514, 73, 74, 514, 105, 106, 512, 74, 770, 512, 106, - 770, 512, 75, 807, 512, 107, 807, 512, 76, 769, 512, 108, 769, 512, 76, - 807, 512, 108, 807, 512, 76, 780, 512, 108, 780, 514, 76, 183, 514, 108, - 183, 512, 78, 769, 512, 110, 769, 512, 78, 807, 512, 110, 807, 512, 78, - 780, 512, 110, 780, 514, 700, 110, 512, 79, 772, 512, 111, 772, 512, 79, - 774, 512, 111, 774, 512, 79, 779, 512, 111, 779, 512, 82, 769, 512, 114, - 769, 512, 82, 807, 512, 114, 807, 512, 82, 780, 512, 114, 780, 512, 83, - 769, 512, 115, 769, 512, 83, 770, 512, 115, 770, 512, 83, 807, 512, 115, - 807, 512, 83, 780, 512, 115, 780, 512, 84, 807, 512, 116, 807, 512, 84, - 780, 512, 116, 780, 512, 85, 771, 512, 117, 771, 512, 85, 772, 512, 117, - 772, 512, 85, 774, 512, 117, 774, 512, 85, 778, 512, 117, 778, 512, 85, - 779, 512, 117, 779, 512, 85, 808, 512, 117, 808, 512, 87, 770, 512, 119, - 770, 512, 89, 770, 512, 121, 770, 512, 89, 776, 512, 90, 769, 512, 122, - 769, 512, 90, 775, 512, 122, 775, 512, 90, 780, 512, 122, 780, 258, 115, - 512, 79, 795, 512, 111, 795, 512, 85, 795, 512, 117, 795, 514, 68, 381, - 514, 68, 382, 514, 100, 382, 514, 76, 74, 514, 76, 106, 514, 108, 106, - 514, 78, 74, 514, 78, 106, 514, 110, 106, 512, 65, 780, 512, 97, 780, - 512, 73, 780, 512, 105, 780, 512, 79, 780, 512, 111, 780, 512, 85, 780, - 512, 117, 780, 512, 220, 772, 512, 252, 772, 512, 220, 769, 512, 252, - 769, 512, 220, 780, 512, 252, 780, 512, 220, 768, 512, 252, 768, 512, - 196, 772, 512, 228, 772, 512, 550, 772, 512, 551, 772, 512, 198, 772, - 512, 230, 772, 512, 71, 780, 512, 103, 780, 512, 75, 780, 512, 107, 780, - 512, 79, 808, 512, 111, 808, 512, 490, 772, 512, 491, 772, 512, 439, 780, - 512, 658, 780, 512, 106, 780, 514, 68, 90, 514, 68, 122, 514, 100, 122, - 512, 71, 769, 512, 103, 769, 512, 78, 768, 512, 110, 768, 512, 197, 769, - 512, 229, 769, 512, 198, 769, 512, 230, 769, 512, 216, 769, 512, 248, - 769, 512, 65, 783, 512, 97, 783, 512, 65, 785, 512, 97, 785, 512, 69, - 783, 512, 101, 783, 512, 69, 785, 512, 101, 785, 512, 73, 783, 512, 105, - 783, 512, 73, 785, 512, 105, 785, 512, 79, 783, 512, 111, 783, 512, 79, - 785, 512, 111, 785, 512, 82, 783, 512, 114, 783, 512, 82, 785, 512, 114, - 785, 512, 85, 783, 512, 117, 783, 512, 85, 785, 512, 117, 785, 512, 83, - 806, 512, 115, 806, 512, 84, 806, 512, 116, 806, 512, 72, 780, 512, 104, - 780, 512, 65, 775, 512, 97, 775, 512, 69, 807, 512, 101, 807, 512, 214, - 772, 512, 246, 772, 512, 213, 772, 512, 245, 772, 512, 79, 775, 512, 111, - 775, 512, 558, 772, 512, 559, 772, 512, 89, 772, 512, 121, 772, 259, 104, - 259, 614, 259, 106, 259, 114, 259, 633, 259, 635, 259, 641, 259, 119, - 259, 121, 514, 32, 774, 514, 32, 775, 514, 32, 778, 514, 32, 808, 514, - 32, 771, 514, 32, 779, 259, 611, 259, 108, 259, 115, 259, 120, 259, 661, - 256, 768, 256, 769, 256, 787, 512, 776, 769, 256, 697, 514, 32, 837, 256, - 59, 514, 32, 769, 512, 168, 769, 512, 913, 769, 256, 183, 512, 917, 769, - 512, 919, 769, 512, 921, 769, 512, 927, 769, 512, 933, 769, 512, 937, - 769, 512, 970, 769, 512, 921, 776, 512, 933, 776, 512, 945, 769, 512, - 949, 769, 512, 951, 769, 512, 953, 769, 512, 971, 769, 512, 953, 776, - 512, 965, 776, 512, 959, 769, 512, 965, 769, 512, 969, 769, 258, 946, - 258, 952, 258, 933, 512, 978, 769, 512, 978, 776, 258, 966, 258, 960, - 258, 954, 258, 961, 258, 962, 258, 920, 258, 949, 512, 1045, 768, 512, - 1045, 776, 512, 1043, 769, 512, 1030, 776, 512, 1050, 769, 512, 1048, - 768, 512, 1059, 774, 512, 1048, 774, 512, 1080, 774, 512, 1077, 768, 512, - 1077, 776, 512, 1075, 769, 512, 1110, 776, 512, 1082, 769, 512, 1080, - 768, 512, 1091, 774, 512, 1140, 783, 512, 1141, 783, 512, 1046, 774, 512, - 1078, 774, 512, 1040, 774, 512, 1072, 774, 512, 1040, 776, 512, 1072, - 776, 512, 1045, 774, 512, 1077, 774, 512, 1240, 776, 512, 1241, 776, 512, - 1046, 776, 512, 1078, 776, 512, 1047, 776, 512, 1079, 776, 512, 1048, - 772, 512, 1080, 772, 512, 1048, 776, 512, 1080, 776, 512, 1054, 776, 512, - 1086, 776, 512, 1256, 776, 512, 1257, 776, 512, 1069, 776, 512, 1101, - 776, 512, 1059, 772, 512, 1091, 772, 512, 1059, 776, 512, 1091, 776, 512, - 1059, 779, 512, 1091, 779, 512, 1063, 776, 512, 1095, 776, 512, 1067, - 776, 512, 1099, 776, 514, 1381, 1410, 512, 1575, 1619, 512, 1575, 1620, - 512, 1608, 1620, 512, 1575, 1621, 512, 1610, 1620, 514, 1575, 1652, 514, - 1608, 1652, 514, 1735, 1652, 514, 1610, 1652, 512, 1749, 1620, 512, 1729, - 1620, 512, 1746, 1620, 512, 2344, 2364, 512, 2352, 2364, 512, 2355, 2364, - 512, 2325, 2364, 512, 2326, 2364, 512, 2327, 2364, 512, 2332, 2364, 512, - 2337, 2364, 512, 2338, 2364, 512, 2347, 2364, 512, 2351, 2364, 512, 2503, - 2494, 512, 2503, 2519, 512, 2465, 2492, 512, 2466, 2492, 512, 2479, 2492, - 512, 2610, 2620, 512, 2616, 2620, 512, 2582, 2620, 512, 2583, 2620, 512, - 2588, 2620, 512, 2603, 2620, 512, 2887, 2902, 512, 2887, 2878, 512, 2887, - 2903, 512, 2849, 2876, 512, 2850, 2876, 512, 2962, 3031, 512, 3014, 3006, - 512, 3015, 3006, 512, 3014, 3031, 512, 3142, 3158, 512, 3263, 3285, 512, - 3270, 3285, 512, 3270, 3286, 512, 3270, 3266, 512, 3274, 3285, 512, 3398, - 3390, 512, 3399, 3390, 512, 3398, 3415, 512, 3545, 3530, 512, 3545, 3535, - 512, 3548, 3530, 512, 3545, 3551, 514, 3661, 3634, 514, 3789, 3762, 514, - 3755, 3737, 514, 3755, 3745, 257, 3851, 512, 3906, 4023, 512, 3916, 4023, - 512, 3921, 4023, 512, 3926, 4023, 512, 3931, 4023, 512, 3904, 4021, 512, - 3953, 3954, 512, 3953, 3956, 512, 4018, 3968, 514, 4018, 3969, 512, 4019, - 3968, 514, 4019, 3969, 512, 3953, 3968, 512, 3986, 4023, 512, 3996, 4023, - 512, 4001, 4023, 512, 4006, 4023, 512, 4011, 4023, 512, 3984, 4021, 512, - 4133, 4142, 512, 65, 805, 512, 97, 805, 512, 66, 775, 512, 98, 775, 512, - 66, 803, 512, 98, 803, 512, 66, 817, 512, 98, 817, 512, 199, 769, 512, - 231, 769, 512, 68, 775, 512, 100, 775, 512, 68, 803, 512, 100, 803, 512, - 68, 817, 512, 100, 817, 512, 68, 807, 512, 100, 807, 512, 68, 813, 512, - 100, 813, 512, 274, 768, 512, 275, 768, 512, 274, 769, 512, 275, 769, - 512, 69, 813, 512, 101, 813, 512, 69, 816, 512, 101, 816, 512, 552, 774, - 512, 553, 774, 512, 70, 775, 512, 102, 775, 512, 71, 772, 512, 103, 772, - 512, 72, 775, 512, 104, 775, 512, 72, 803, 512, 104, 803, 512, 72, 776, - 512, 104, 776, 512, 72, 807, 512, 104, 807, 512, 72, 814, 512, 104, 814, - 512, 73, 816, 512, 105, 816, 512, 207, 769, 512, 239, 769, 512, 75, 769, - 512, 107, 769, 512, 75, 803, 512, 107, 803, 512, 75, 817, 512, 107, 817, - 512, 76, 803, 512, 108, 803, 512, 7734, 772, 512, 7735, 772, 512, 76, - 817, 512, 108, 817, 512, 76, 813, 512, 108, 813, 512, 77, 769, 512, 109, - 769, 512, 77, 775, 512, 109, 775, 512, 77, 803, 512, 109, 803, 512, 78, - 775, 512, 110, 775, 512, 78, 803, 512, 110, 803, 512, 78, 817, 512, 110, - 817, 512, 78, 813, 512, 110, 813, 512, 213, 769, 512, 245, 769, 512, 213, - 776, 512, 245, 776, 512, 332, 768, 512, 333, 768, 512, 332, 769, 512, - 333, 769, 512, 80, 769, 512, 112, 769, 512, 80, 775, 512, 112, 775, 512, - 82, 775, 512, 114, 775, 512, 82, 803, 512, 114, 803, 512, 7770, 772, 512, - 7771, 772, 512, 82, 817, 512, 114, 817, 512, 83, 775, 512, 115, 775, 512, - 83, 803, 512, 115, 803, 512, 346, 775, 512, 347, 775, 512, 352, 775, 512, - 353, 775, 512, 7778, 775, 512, 7779, 775, 512, 84, 775, 512, 116, 775, - 512, 84, 803, 512, 116, 803, 512, 84, 817, 512, 116, 817, 512, 84, 813, - 512, 116, 813, 512, 85, 804, 512, 117, 804, 512, 85, 816, 512, 117, 816, - 512, 85, 813, 512, 117, 813, 512, 360, 769, 512, 361, 769, 512, 362, 776, - 512, 363, 776, 512, 86, 771, 512, 118, 771, 512, 86, 803, 512, 118, 803, - 512, 87, 768, 512, 119, 768, 512, 87, 769, 512, 119, 769, 512, 87, 776, - 512, 119, 776, 512, 87, 775, 512, 119, 775, 512, 87, 803, 512, 119, 803, - 512, 88, 775, 512, 120, 775, 512, 88, 776, 512, 120, 776, 512, 89, 775, - 512, 121, 775, 512, 90, 770, 512, 122, 770, 512, 90, 803, 512, 122, 803, - 512, 90, 817, 512, 122, 817, 512, 104, 817, 512, 116, 776, 512, 119, 778, - 512, 121, 778, 514, 97, 702, 512, 383, 775, 512, 65, 803, 512, 97, 803, - 512, 65, 777, 512, 97, 777, 512, 194, 769, 512, 226, 769, 512, 194, 768, - 512, 226, 768, 512, 194, 777, 512, 226, 777, 512, 194, 771, 512, 226, - 771, 512, 7840, 770, 512, 7841, 770, 512, 258, 769, 512, 259, 769, 512, - 258, 768, 512, 259, 768, 512, 258, 777, 512, 259, 777, 512, 258, 771, - 512, 259, 771, 512, 7840, 774, 512, 7841, 774, 512, 69, 803, 512, 101, - 803, 512, 69, 777, 512, 101, 777, 512, 69, 771, 512, 101, 771, 512, 202, - 769, 512, 234, 769, 512, 202, 768, 512, 234, 768, 512, 202, 777, 512, - 234, 777, 512, 202, 771, 512, 234, 771, 512, 7864, 770, 512, 7865, 770, - 512, 73, 777, 512, 105, 777, 512, 73, 803, 512, 105, 803, 512, 79, 803, - 512, 111, 803, 512, 79, 777, 512, 111, 777, 512, 212, 769, 512, 244, 769, - 512, 212, 768, 512, 244, 768, 512, 212, 777, 512, 244, 777, 512, 212, - 771, 512, 244, 771, 512, 7884, 770, 512, 7885, 770, 512, 416, 769, 512, - 417, 769, 512, 416, 768, 512, 417, 768, 512, 416, 777, 512, 417, 777, - 512, 416, 771, 512, 417, 771, 512, 416, 803, 512, 417, 803, 512, 85, 803, - 512, 117, 803, 512, 85, 777, 512, 117, 777, 512, 431, 769, 512, 432, 769, - 512, 431, 768, 512, 432, 768, 512, 431, 777, 512, 432, 777, 512, 431, - 771, 512, 432, 771, 512, 431, 803, 512, 432, 803, 512, 89, 768, 512, 121, - 768, 512, 89, 803, 512, 121, 803, 512, 89, 777, 512, 121, 777, 512, 89, - 771, 512, 121, 771, 512, 945, 787, 512, 945, 788, 512, 7936, 768, 512, - 7937, 768, 512, 7936, 769, 512, 7937, 769, 512, 7936, 834, 512, 7937, - 834, 512, 913, 787, 512, 913, 788, 512, 7944, 768, 512, 7945, 768, 512, - 7944, 769, 512, 7945, 769, 512, 7944, 834, 512, 7945, 834, 512, 949, 787, - 512, 949, 788, 512, 7952, 768, 512, 7953, 768, 512, 7952, 769, 512, 7953, - 769, 512, 917, 787, 512, 917, 788, 512, 7960, 768, 512, 7961, 768, 512, - 7960, 769, 512, 7961, 769, 512, 951, 787, 512, 951, 788, 512, 7968, 768, - 512, 7969, 768, 512, 7968, 769, 512, 7969, 769, 512, 7968, 834, 512, - 7969, 834, 512, 919, 787, 512, 919, 788, 512, 7976, 768, 512, 7977, 768, - 512, 7976, 769, 512, 7977, 769, 512, 7976, 834, 512, 7977, 834, 512, 953, - 787, 512, 953, 788, 512, 7984, 768, 512, 7985, 768, 512, 7984, 769, 512, - 7985, 769, 512, 7984, 834, 512, 7985, 834, 512, 921, 787, 512, 921, 788, - 512, 7992, 768, 512, 7993, 768, 512, 7992, 769, 512, 7993, 769, 512, - 7992, 834, 512, 7993, 834, 512, 959, 787, 512, 959, 788, 512, 8000, 768, - 512, 8001, 768, 512, 8000, 769, 512, 8001, 769, 512, 927, 787, 512, 927, - 788, 512, 8008, 768, 512, 8009, 768, 512, 8008, 769, 512, 8009, 769, 512, - 965, 787, 512, 965, 788, 512, 8016, 768, 512, 8017, 768, 512, 8016, 769, - 512, 8017, 769, 512, 8016, 834, 512, 8017, 834, 512, 933, 788, 512, 8025, - 768, 512, 8025, 769, 512, 8025, 834, 512, 969, 787, 512, 969, 788, 512, - 8032, 768, 512, 8033, 768, 512, 8032, 769, 512, 8033, 769, 512, 8032, - 834, 512, 8033, 834, 512, 937, 787, 512, 937, 788, 512, 8040, 768, 512, - 8041, 768, 512, 8040, 769, 512, 8041, 769, 512, 8040, 834, 512, 8041, - 834, 512, 945, 768, 256, 940, 512, 949, 768, 256, 941, 512, 951, 768, - 256, 942, 512, 953, 768, 256, 943, 512, 959, 768, 256, 972, 512, 965, - 768, 256, 973, 512, 969, 768, 256, 974, 512, 7936, 837, 512, 7937, 837, - 512, 7938, 837, 512, 7939, 837, 512, 7940, 837, 512, 7941, 837, 512, - 7942, 837, 512, 7943, 837, 512, 7944, 837, 512, 7945, 837, 512, 7946, - 837, 512, 7947, 837, 512, 7948, 837, 512, 7949, 837, 512, 7950, 837, 512, - 7951, 837, 512, 7968, 837, 512, 7969, 837, 512, 7970, 837, 512, 7971, - 837, 512, 7972, 837, 512, 7973, 837, 512, 7974, 837, 512, 7975, 837, 512, - 7976, 837, 512, 7977, 837, 512, 7978, 837, 512, 7979, 837, 512, 7980, - 837, 512, 7981, 837, 512, 7982, 837, 512, 7983, 837, 512, 8032, 837, 512, - 8033, 837, 512, 8034, 837, 512, 8035, 837, 512, 8036, 837, 512, 8037, - 837, 512, 8038, 837, 512, 8039, 837, 512, 8040, 837, 512, 8041, 837, 512, - 8042, 837, 512, 8043, 837, 512, 8044, 837, 512, 8045, 837, 512, 8046, - 837, 512, 8047, 837, 512, 945, 774, 512, 945, 772, 512, 8048, 837, 512, - 945, 837, 512, 940, 837, 512, 945, 834, 512, 8118, 837, 512, 913, 774, - 512, 913, 772, 512, 913, 768, 256, 902, 512, 913, 837, 514, 32, 787, 256, - 953, 514, 32, 787, 514, 32, 834, 512, 168, 834, 512, 8052, 837, 512, 951, - 837, 512, 942, 837, 512, 951, 834, 512, 8134, 837, 512, 917, 768, 256, - 904, 512, 919, 768, 256, 905, 512, 919, 837, 512, 8127, 768, 512, 8127, - 769, 512, 8127, 834, 512, 953, 774, 512, 953, 772, 512, 970, 768, 256, - 912, 512, 953, 834, 512, 970, 834, 512, 921, 774, 512, 921, 772, 512, - 921, 768, 256, 906, 512, 8190, 768, 512, 8190, 769, 512, 8190, 834, 512, - 965, 774, 512, 965, 772, 512, 971, 768, 256, 944, 512, 961, 787, 512, - 961, 788, 512, 965, 834, 512, 971, 834, 512, 933, 774, 512, 933, 772, - 512, 933, 768, 256, 910, 512, 929, 788, 512, 168, 768, 256, 901, 256, 96, - 512, 8060, 837, 512, 969, 837, 512, 974, 837, 512, 969, 834, 512, 8182, - 837, 512, 927, 768, 256, 908, 512, 937, 768, 256, 911, 512, 937, 837, - 256, 180, 514, 32, 788, 256, 8194, 256, 8195, 258, 32, 258, 32, 258, 32, - 258, 32, 258, 32, 257, 32, 258, 32, 258, 32, 258, 32, 257, 8208, 514, 32, - 819, 258, 46, 514, 46, 46, 770, 46, 46, 46, 257, 32, 514, 8242, 8242, - 770, 8242, 8242, 8242, 514, 8245, 8245, 770, 8245, 8245, 8245, 514, 33, - 33, 514, 32, 773, 514, 63, 63, 514, 63, 33, 514, 33, 63, 1026, 8242, - 8242, 8242, 8242, 258, 32, 259, 48, 259, 105, 259, 52, 259, 53, 259, 54, - 259, 55, 259, 56, 259, 57, 259, 43, 259, 8722, 259, 61, 259, 40, 259, 41, - 259, 110, 261, 48, 261, 49, 261, 50, 261, 51, 261, 52, 261, 53, 261, 54, - 261, 55, 261, 56, 261, 57, 261, 43, 261, 8722, 261, 61, 261, 40, 261, 41, - 514, 82, 115, 770, 97, 47, 99, 770, 97, 47, 115, 262, 67, 514, 176, 67, - 770, 99, 47, 111, 770, 99, 47, 117, 258, 400, 514, 176, 70, 262, 103, - 262, 72, 262, 72, 262, 72, 262, 104, 262, 295, 262, 73, 262, 73, 262, 76, - 262, 108, 262, 78, 514, 78, 111, 262, 80, 262, 81, 262, 82, 262, 82, 262, - 82, 515, 83, 77, 770, 84, 69, 76, 515, 84, 77, 262, 90, 256, 937, 262, - 90, 256, 75, 256, 197, 262, 66, 262, 67, 262, 101, 262, 69, 262, 70, 262, - 77, 262, 111, 258, 1488, 258, 1489, 258, 1490, 258, 1491, 262, 105, 262, - 947, 262, 915, 262, 928, 262, 8721, 262, 68, 262, 100, 262, 101, 262, - 105, 262, 106, 772, 49, 8260, 51, 772, 50, 8260, 51, 772, 49, 8260, 53, - 772, 50, 8260, 53, 772, 51, 8260, 53, 772, 52, 8260, 53, 772, 49, 8260, - 54, 772, 53, 8260, 54, 772, 49, 8260, 56, 772, 51, 8260, 56, 772, 53, - 8260, 56, 772, 55, 8260, 56, 516, 49, 8260, 258, 73, 514, 73, 73, 770, - 73, 73, 73, 514, 73, 86, 258, 86, 514, 86, 73, 770, 86, 73, 73, 1026, 86, - 73, 73, 73, 514, 73, 88, 258, 88, 514, 88, 73, 770, 88, 73, 73, 258, 76, - 258, 67, 258, 68, 258, 77, 258, 105, 514, 105, 105, 770, 105, 105, 105, - 514, 105, 118, 258, 118, 514, 118, 105, 770, 118, 105, 105, 1026, 118, - 105, 105, 105, 514, 105, 120, 258, 120, 514, 120, 105, 770, 120, 105, - 105, 258, 108, 258, 99, 258, 100, 258, 109, 512, 8592, 824, 512, 8594, - 824, 512, 8596, 824, 512, 8656, 824, 512, 8660, 824, 512, 8658, 824, 512, - 8707, 824, 512, 8712, 824, 512, 8715, 824, 512, 8739, 824, 512, 8741, - 824, 514, 8747, 8747, 770, 8747, 8747, 8747, 514, 8750, 8750, 770, 8750, - 8750, 8750, 512, 8764, 824, 512, 8771, 824, 512, 8773, 824, 512, 8776, - 824, 512, 61, 824, 512, 8801, 824, 512, 8781, 824, 512, 60, 824, 512, 62, - 824, 512, 8804, 824, 512, 8805, 824, 512, 8818, 824, 512, 8819, 824, 512, - 8822, 824, 512, 8823, 824, 512, 8826, 824, 512, 8827, 824, 512, 8834, - 824, 512, 8835, 824, 512, 8838, 824, 512, 8839, 824, 512, 8866, 824, 512, - 8872, 824, 512, 8873, 824, 512, 8875, 824, 512, 8828, 824, 512, 8829, - 824, 512, 8849, 824, 512, 8850, 824, 512, 8882, 824, 512, 8883, 824, 512, - 8884, 824, 512, 8885, 824, 256, 12296, 256, 12297, 263, 49, 263, 50, 263, - 51, 263, 52, 263, 53, 263, 54, 263, 55, 263, 56, 263, 57, 519, 49, 48, - 519, 49, 49, 519, 49, 50, 519, 49, 51, 519, 49, 52, 519, 49, 53, 519, 49, - 54, 519, 49, 55, 519, 49, 56, 519, 49, 57, 519, 50, 48, 770, 40, 49, 41, - 770, 40, 50, 41, 770, 40, 51, 41, 770, 40, 52, 41, 770, 40, 53, 41, 770, - 40, 54, 41, 770, 40, 55, 41, 770, 40, 56, 41, 770, 40, 57, 41, 1026, 40, - 49, 48, 41, 1026, 40, 49, 49, 41, 1026, 40, 49, 50, 41, 1026, 40, 49, 51, - 41, 1026, 40, 49, 52, 41, 1026, 40, 49, 53, 41, 1026, 40, 49, 54, 41, - 1026, 40, 49, 55, 41, 1026, 40, 49, 56, 41, 1026, 40, 49, 57, 41, 1026, - 40, 50, 48, 41, 514, 49, 46, 514, 50, 46, 514, 51, 46, 514, 52, 46, 514, - 53, 46, 514, 54, 46, 514, 55, 46, 514, 56, 46, 514, 57, 46, 770, 49, 48, - 46, 770, 49, 49, 46, 770, 49, 50, 46, 770, 49, 51, 46, 770, 49, 52, 46, - 770, 49, 53, 46, 770, 49, 54, 46, 770, 49, 55, 46, 770, 49, 56, 46, 770, - 49, 57, 46, 770, 50, 48, 46, 770, 40, 97, 41, 770, 40, 98, 41, 770, 40, - 99, 41, 770, 40, 100, 41, 770, 40, 101, 41, 770, 40, 102, 41, 770, 40, - 103, 41, 770, 40, 104, 41, 770, 40, 105, 41, 770, 40, 106, 41, 770, 40, - 107, 41, 770, 40, 108, 41, 770, 40, 109, 41, 770, 40, 110, 41, 770, 40, - 111, 41, 770, 40, 112, 41, 770, 40, 113, 41, 770, 40, 114, 41, 770, 40, - 115, 41, 770, 40, 116, 41, 770, 40, 117, 41, 770, 40, 118, 41, 770, 40, - 119, 41, 770, 40, 120, 41, 770, 40, 121, 41, 770, 40, 122, 41, 263, 65, - 263, 66, 263, 67, 263, 68, 263, 69, 263, 70, 263, 71, 263, 72, 263, 73, - 263, 74, 263, 75, 263, 76, 263, 77, 263, 78, 263, 79, 263, 80, 263, 81, - 263, 82, 263, 83, 263, 84, 263, 85, 263, 86, 263, 87, 263, 88, 263, 89, - 263, 90, 263, 97, 263, 98, 263, 99, 263, 100, 263, 101, 263, 102, 263, - 103, 263, 104, 263, 105, 263, 106, 263, 107, 263, 108, 263, 109, 263, - 110, 263, 111, 263, 112, 263, 113, 263, 114, 263, 115, 263, 116, 263, - 117, 263, 118, 263, 119, 263, 120, 263, 121, 263, 122, 263, 48, 1026, - 8747, 8747, 8747, 8747, 770, 58, 58, 61, 514, 61, 61, 770, 61, 61, 61, - 512, 10973, 824, 258, 27597, 258, 40863, 258, 19968, 258, 20008, 258, - 20022, 258, 20031, 258, 20057, 258, 20101, 258, 20108, 258, 20128, 258, - 20154, 258, 20799, 258, 20837, 258, 20843, 258, 20866, 258, 20886, 258, - 20907, 258, 20960, 258, 20981, 258, 20992, 258, 21147, 258, 21241, 258, - 21269, 258, 21274, 258, 21304, 258, 21313, 258, 21340, 258, 21353, 258, - 21378, 258, 21430, 258, 21448, 258, 21475, 258, 22231, 258, 22303, 258, - 22763, 258, 22786, 258, 22794, 258, 22805, 258, 22823, 258, 22899, 258, - 23376, 258, 23424, 258, 23544, 258, 23567, 258, 23586, 258, 23608, 258, - 23662, 258, 23665, 258, 24027, 258, 24037, 258, 24049, 258, 24062, 258, - 24178, 258, 24186, 258, 24191, 258, 24308, 258, 24318, 258, 24331, 258, - 24339, 258, 24400, 258, 24417, 258, 24435, 258, 24515, 258, 25096, 258, - 25142, 258, 25163, 258, 25903, 258, 25908, 258, 25991, 258, 26007, 258, - 26020, 258, 26041, 258, 26080, 258, 26085, 258, 26352, 258, 26376, 258, - 26408, 258, 27424, 258, 27490, 258, 27513, 258, 27571, 258, 27595, 258, - 27604, 258, 27611, 258, 27663, 258, 27668, 258, 27700, 258, 28779, 258, - 29226, 258, 29238, 258, 29243, 258, 29247, 258, 29255, 258, 29273, 258, - 29275, 258, 29356, 258, 29572, 258, 29577, 258, 29916, 258, 29926, 258, - 29976, 258, 29983, 258, 29992, 258, 30000, 258, 30091, 258, 30098, 258, - 30326, 258, 30333, 258, 30382, 258, 30399, 258, 30446, 258, 30683, 258, - 30690, 258, 30707, 258, 31034, 258, 31160, 258, 31166, 258, 31348, 258, - 31435, 258, 31481, 258, 31859, 258, 31992, 258, 32566, 258, 32593, 258, - 32650, 258, 32701, 258, 32769, 258, 32780, 258, 32786, 258, 32819, 258, - 32895, 258, 32905, 258, 33251, 258, 33258, 258, 33267, 258, 33276, 258, - 33292, 258, 33307, 258, 33311, 258, 33390, 258, 33394, 258, 33400, 258, - 34381, 258, 34411, 258, 34880, 258, 34892, 258, 34915, 258, 35198, 258, - 35211, 258, 35282, 258, 35328, 258, 35895, 258, 35910, 258, 35925, 258, - 35960, 258, 35997, 258, 36196, 258, 36208, 258, 36275, 258, 36523, 258, - 36554, 258, 36763, 258, 36784, 258, 36789, 258, 37009, 258, 37193, 258, - 37318, 258, 37324, 258, 37329, 258, 38263, 258, 38272, 258, 38428, 258, - 38582, 258, 38585, 258, 38632, 258, 38737, 258, 38750, 258, 38754, 258, - 38761, 258, 38859, 258, 38893, 258, 38899, 258, 38913, 258, 39080, 258, - 39131, 258, 39135, 258, 39318, 258, 39321, 258, 39340, 258, 39592, 258, - 39640, 258, 39647, 258, 39717, 258, 39727, 258, 39730, 258, 39740, 258, - 39770, 258, 40165, 258, 40565, 258, 40575, 258, 40613, 258, 40635, 258, - 40643, 258, 40653, 258, 40657, 258, 40697, 258, 40701, 258, 40718, 258, - 40723, 258, 40736, 258, 40763, 258, 40778, 258, 40786, 258, 40845, 258, - 40860, 258, 40864, 264, 32, 258, 12306, 258, 21313, 258, 21316, 258, - 21317, 512, 12363, 12441, 512, 12365, 12441, 512, 12367, 12441, 512, - 12369, 12441, 512, 12371, 12441, 512, 12373, 12441, 512, 12375, 12441, - 512, 12377, 12441, 512, 12379, 12441, 512, 12381, 12441, 512, 12383, - 12441, 512, 12385, 12441, 512, 12388, 12441, 512, 12390, 12441, 512, - 12392, 12441, 512, 12399, 12441, 512, 12399, 12442, 512, 12402, 12441, - 512, 12402, 12442, 512, 12405, 12441, 512, 12405, 12442, 512, 12408, - 12441, 512, 12408, 12442, 512, 12411, 12441, 512, 12411, 12442, 512, - 12358, 12441, 514, 32, 12441, 514, 32, 12442, 512, 12445, 12441, 521, - 12424, 12426, 512, 12459, 12441, 512, 12461, 12441, 512, 12463, 12441, - 512, 12465, 12441, 512, 12467, 12441, 512, 12469, 12441, 512, 12471, - 12441, 512, 12473, 12441, 512, 12475, 12441, 512, 12477, 12441, 512, - 12479, 12441, 512, 12481, 12441, 512, 12484, 12441, 512, 12486, 12441, - 512, 12488, 12441, 512, 12495, 12441, 512, 12495, 12442, 512, 12498, - 12441, 512, 12498, 12442, 512, 12501, 12441, 512, 12501, 12442, 512, - 12504, 12441, 512, 12504, 12442, 512, 12507, 12441, 512, 12507, 12442, - 512, 12454, 12441, 512, 12527, 12441, 512, 12528, 12441, 512, 12529, - 12441, 512, 12530, 12441, 512, 12541, 12441, 521, 12467, 12488, 258, - 4352, 258, 4353, 258, 4522, 258, 4354, 258, 4524, 258, 4525, 258, 4355, - 258, 4356, 258, 4357, 258, 4528, 258, 4529, 258, 4530, 258, 4531, 258, - 4532, 258, 4533, 258, 4378, 258, 4358, 258, 4359, 258, 4360, 258, 4385, - 258, 4361, 258, 4362, 258, 4363, 258, 4364, 258, 4365, 258, 4366, 258, - 4367, 258, 4368, 258, 4369, 258, 4370, 258, 4449, 258, 4450, 258, 4451, - 258, 4452, 258, 4453, 258, 4454, 258, 4455, 258, 4456, 258, 4457, 258, - 4458, 258, 4459, 258, 4460, 258, 4461, 258, 4462, 258, 4463, 258, 4464, - 258, 4465, 258, 4466, 258, 4467, 258, 4468, 258, 4469, 258, 4448, 258, - 4372, 258, 4373, 258, 4551, 258, 4552, 258, 4556, 258, 4558, 258, 4563, - 258, 4567, 258, 4569, 258, 4380, 258, 4573, 258, 4575, 258, 4381, 258, - 4382, 258, 4384, 258, 4386, 258, 4387, 258, 4391, 258, 4393, 258, 4395, - 258, 4396, 258, 4397, 258, 4398, 258, 4399, 258, 4402, 258, 4406, 258, - 4416, 258, 4423, 258, 4428, 258, 4593, 258, 4594, 258, 4439, 258, 4440, - 258, 4441, 258, 4484, 258, 4485, 258, 4488, 258, 4497, 258, 4498, 258, - 4500, 258, 4510, 258, 4513, 259, 19968, 259, 20108, 259, 19977, 259, - 22235, 259, 19978, 259, 20013, 259, 19979, 259, 30002, 259, 20057, 259, - 19993, 259, 19969, 259, 22825, 259, 22320, 259, 20154, 770, 40, 4352, 41, - 770, 40, 4354, 41, 770, 40, 4355, 41, 770, 40, 4357, 41, 770, 40, 4358, - 41, 770, 40, 4359, 41, 770, 40, 4361, 41, 770, 40, 4363, 41, 770, 40, - 4364, 41, 770, 40, 4366, 41, 770, 40, 4367, 41, 770, 40, 4368, 41, 770, - 40, 4369, 41, 770, 40, 4370, 41, 1026, 40, 4352, 4449, 41, 1026, 40, - 4354, 4449, 41, 1026, 40, 4355, 4449, 41, 1026, 40, 4357, 4449, 41, 1026, - 40, 4358, 4449, 41, 1026, 40, 4359, 4449, 41, 1026, 40, 4361, 4449, 41, - 1026, 40, 4363, 4449, 41, 1026, 40, 4364, 4449, 41, 1026, 40, 4366, 4449, - 41, 1026, 40, 4367, 4449, 41, 1026, 40, 4368, 4449, 41, 1026, 40, 4369, - 4449, 41, 1026, 40, 4370, 4449, 41, 1026, 40, 4364, 4462, 41, 770, 40, - 19968, 41, 770, 40, 20108, 41, 770, 40, 19977, 41, 770, 40, 22235, 41, - 770, 40, 20116, 41, 770, 40, 20845, 41, 770, 40, 19971, 41, 770, 40, - 20843, 41, 770, 40, 20061, 41, 770, 40, 21313, 41, 770, 40, 26376, 41, - 770, 40, 28779, 41, 770, 40, 27700, 41, 770, 40, 26408, 41, 770, 40, - 37329, 41, 770, 40, 22303, 41, 770, 40, 26085, 41, 770, 40, 26666, 41, - 770, 40, 26377, 41, 770, 40, 31038, 41, 770, 40, 21517, 41, 770, 40, - 29305, 41, 770, 40, 36001, 41, 770, 40, 31069, 41, 770, 40, 21172, 41, - 770, 40, 20195, 41, 770, 40, 21628, 41, 770, 40, 23398, 41, 770, 40, - 30435, 41, 770, 40, 20225, 41, 770, 40, 36039, 41, 770, 40, 21332, 41, - 770, 40, 31085, 41, 770, 40, 20241, 41, 770, 40, 33258, 41, 770, 40, - 33267, 41, 519, 50, 49, 519, 50, 50, 519, 50, 51, 519, 50, 52, 519, 50, - 53, 519, 50, 54, 519, 50, 55, 519, 50, 56, 519, 50, 57, 519, 51, 48, 519, - 51, 49, 519, 51, 50, 519, 51, 51, 519, 51, 52, 519, 51, 53, 263, 4352, - 263, 4354, 263, 4355, 263, 4357, 263, 4358, 263, 4359, 263, 4361, 263, - 4363, 263, 4364, 263, 4366, 263, 4367, 263, 4368, 263, 4369, 263, 4370, - 519, 4352, 4449, 519, 4354, 4449, 519, 4355, 4449, 519, 4357, 4449, 519, - 4358, 4449, 519, 4359, 4449, 519, 4361, 4449, 519, 4363, 4449, 519, 4364, - 4449, 519, 4366, 4449, 519, 4367, 4449, 519, 4368, 4449, 519, 4369, 4449, - 519, 4370, 4449, 263, 19968, 263, 20108, 263, 19977, 263, 22235, 263, - 20116, 263, 20845, 263, 19971, 263, 20843, 263, 20061, 263, 21313, 263, - 26376, 263, 28779, 263, 27700, 263, 26408, 263, 37329, 263, 22303, 263, - 26085, 263, 26666, 263, 26377, 263, 31038, 263, 21517, 263, 29305, 263, - 36001, 263, 31069, 263, 21172, 263, 31192, 263, 30007, 263, 22899, 263, - 36969, 263, 20778, 263, 21360, 263, 27880, 263, 38917, 263, 20241, 263, - 20889, 263, 27491, 263, 19978, 263, 20013, 263, 19979, 263, 24038, 263, - 21491, 263, 21307, 263, 23447, 263, 23398, 263, 30435, 263, 20225, 263, - 36039, 263, 21332, 263, 22812, 519, 51, 54, 519, 51, 55, 519, 51, 56, - 519, 51, 57, 519, 52, 48, 519, 52, 49, 519, 52, 50, 519, 52, 51, 519, 52, - 52, 519, 52, 53, 519, 52, 54, 519, 52, 55, 519, 52, 56, 519, 52, 57, 519, - 53, 48, 514, 49, 26376, 514, 50, 26376, 514, 51, 26376, 514, 52, 26376, - 514, 53, 26376, 514, 54, 26376, 514, 55, 26376, 514, 56, 26376, 514, 57, - 26376, 770, 49, 48, 26376, 770, 49, 49, 26376, 770, 49, 50, 26376, 263, - 12450, 263, 12452, 263, 12454, 263, 12456, 263, 12458, 263, 12459, 263, - 12461, 263, 12463, 263, 12465, 263, 12467, 263, 12469, 263, 12471, 263, - 12473, 263, 12475, 263, 12477, 263, 12479, 263, 12481, 263, 12484, 263, - 12486, 263, 12488, 263, 12490, 263, 12491, 263, 12492, 263, 12493, 263, - 12494, 263, 12495, 263, 12498, 263, 12501, 263, 12504, 263, 12507, 263, - 12510, 263, 12511, 263, 12512, 263, 12513, 263, 12514, 263, 12516, 263, - 12518, 263, 12520, 263, 12521, 263, 12522, 263, 12523, 263, 12524, 263, - 12525, 263, 12527, 263, 12528, 263, 12529, 263, 12530, 1034, 12450, - 12497, 12540, 12488, 1034, 12450, 12523, 12501, 12449, 1034, 12450, - 12531, 12506, 12450, 778, 12450, 12540, 12523, 1034, 12452, 12491, 12531, - 12464, 778, 12452, 12531, 12481, 778, 12454, 12457, 12531, 1290, 12456, - 12473, 12463, 12540, 12489, 1034, 12456, 12540, 12459, 12540, 778, 12458, - 12531, 12473, 778, 12458, 12540, 12512, 778, 12459, 12452, 12522, 1034, - 12459, 12521, 12483, 12488, 1034, 12459, 12525, 12522, 12540, 778, 12460, - 12525, 12531, 778, 12460, 12531, 12510, 522, 12462, 12460, 778, 12462, - 12491, 12540, 1034, 12461, 12517, 12522, 12540, 1034, 12462, 12523, - 12480, 12540, 522, 12461, 12525, 1290, 12461, 12525, 12464, 12521, 12512, - 1546, 12461, 12525, 12513, 12540, 12488, 12523, 1290, 12461, 12525, - 12527, 12483, 12488, 778, 12464, 12521, 12512, 1290, 12464, 12521, 12512, - 12488, 12531, 1290, 12463, 12523, 12476, 12452, 12525, 1034, 12463, - 12525, 12540, 12493, 778, 12465, 12540, 12473, 778, 12467, 12523, 12490, - 778, 12467, 12540, 12509, 1034, 12469, 12452, 12463, 12523, 1290, 12469, - 12531, 12481, 12540, 12512, 1034, 12471, 12522, 12531, 12464, 778, 12475, - 12531, 12481, 778, 12475, 12531, 12488, 778, 12480, 12540, 12473, 522, - 12487, 12471, 522, 12489, 12523, 522, 12488, 12531, 522, 12490, 12494, - 778, 12494, 12483, 12488, 778, 12495, 12452, 12484, 1290, 12497, 12540, - 12475, 12531, 12488, 778, 12497, 12540, 12484, 1034, 12496, 12540, 12524, - 12523, 1290, 12500, 12450, 12473, 12488, 12523, 778, 12500, 12463, 12523, - 522, 12500, 12467, 522, 12499, 12523, 1290, 12501, 12449, 12521, 12483, - 12489, 1034, 12501, 12451, 12540, 12488, 1290, 12502, 12483, 12471, - 12455, 12523, 778, 12501, 12521, 12531, 1290, 12504, 12463, 12479, 12540, - 12523, 522, 12506, 12477, 778, 12506, 12491, 12498, 778, 12504, 12523, - 12484, 778, 12506, 12531, 12473, 778, 12506, 12540, 12472, 778, 12505, - 12540, 12479, 1034, 12509, 12452, 12531, 12488, 778, 12508, 12523, 12488, - 522, 12507, 12531, 778, 12509, 12531, 12489, 778, 12507, 12540, 12523, - 778, 12507, 12540, 12531, 1034, 12510, 12452, 12463, 12525, 778, 12510, - 12452, 12523, 778, 12510, 12483, 12495, 778, 12510, 12523, 12463, 1290, - 12510, 12531, 12471, 12519, 12531, 1034, 12511, 12463, 12525, 12531, 522, - 12511, 12522, 1290, 12511, 12522, 12496, 12540, 12523, 522, 12513, 12460, - 1034, 12513, 12460, 12488, 12531, 1034, 12513, 12540, 12488, 12523, 778, - 12516, 12540, 12489, 778, 12516, 12540, 12523, 778, 12518, 12450, 12531, - 1034, 12522, 12483, 12488, 12523, 522, 12522, 12521, 778, 12523, 12500, - 12540, 1034, 12523, 12540, 12502, 12523, 522, 12524, 12512, 1290, 12524, - 12531, 12488, 12466, 12531, 778, 12527, 12483, 12488, 514, 48, 28857, - 514, 49, 28857, 514, 50, 28857, 514, 51, 28857, 514, 52, 28857, 514, 53, - 28857, 514, 54, 28857, 514, 55, 28857, 514, 56, 28857, 514, 57, 28857, - 770, 49, 48, 28857, 770, 49, 49, 28857, 770, 49, 50, 28857, 770, 49, 51, - 28857, 770, 49, 52, 28857, 770, 49, 53, 28857, 770, 49, 54, 28857, 770, - 49, 55, 28857, 770, 49, 56, 28857, 770, 49, 57, 28857, 770, 50, 48, - 28857, 770, 50, 49, 28857, 770, 50, 50, 28857, 770, 50, 51, 28857, 770, - 50, 52, 28857, 778, 104, 80, 97, 522, 100, 97, 522, 65, 85, 778, 98, 97, - 114, 522, 111, 86, 522, 112, 99, 522, 24179, 25104, 522, 26157, 21644, - 522, 22823, 27491, 522, 26126, 27835, 1034, 26666, 24335, 20250, 31038, - 522, 112, 65, 522, 110, 65, 522, 956, 65, 522, 109, 65, 522, 107, 65, - 522, 75, 66, 522, 77, 66, 522, 71, 66, 778, 99, 97, 108, 1034, 107, 99, - 97, 108, 522, 112, 70, 522, 110, 70, 522, 956, 70, 522, 956, 103, 522, - 109, 103, 522, 107, 103, 522, 72, 122, 778, 107, 72, 122, 778, 77, 72, - 122, 778, 71, 72, 122, 778, 84, 72, 122, 522, 956, 8467, 522, 109, 8467, - 522, 100, 8467, 522, 107, 8467, 522, 102, 109, 522, 110, 109, 522, 956, - 109, 522, 109, 109, 522, 99, 109, 522, 107, 109, 778, 109, 109, 178, 778, - 99, 109, 178, 522, 109, 178, 778, 107, 109, 178, 778, 109, 109, 179, 778, - 99, 109, 179, 522, 109, 179, 778, 107, 109, 179, 778, 109, 8725, 115, - 1034, 109, 8725, 115, 178, 522, 80, 97, 778, 107, 80, 97, 778, 77, 80, - 97, 778, 71, 80, 97, 778, 114, 97, 100, 1290, 114, 97, 100, 8725, 115, - 1546, 114, 97, 100, 8725, 115, 178, 522, 112, 115, 522, 110, 115, 522, - 956, 115, 522, 109, 115, 522, 112, 86, 522, 110, 86, 522, 956, 86, 522, - 109, 86, 522, 107, 86, 522, 77, 86, 522, 112, 87, 522, 110, 87, 522, 956, - 87, 522, 109, 87, 522, 107, 87, 522, 77, 87, 522, 107, 937, 522, 77, 937, - 1034, 97, 46, 109, 46, 522, 66, 113, 522, 99, 99, 522, 99, 100, 1034, 67, - 8725, 107, 103, 778, 67, 111, 46, 522, 100, 66, 522, 71, 121, 522, 104, - 97, 522, 72, 80, 522, 105, 110, 522, 75, 75, 522, 75, 77, 522, 107, 116, - 522, 108, 109, 522, 108, 110, 778, 108, 111, 103, 522, 108, 120, 522, - 109, 98, 778, 109, 105, 108, 778, 109, 111, 108, 522, 80, 72, 1034, 112, - 46, 109, 46, 778, 80, 80, 77, 522, 80, 82, 522, 115, 114, 522, 83, 118, - 522, 87, 98, 514, 49, 26085, 514, 50, 26085, 514, 51, 26085, 514, 52, - 26085, 514, 53, 26085, 514, 54, 26085, 514, 55, 26085, 514, 56, 26085, - 514, 57, 26085, 770, 49, 48, 26085, 770, 49, 49, 26085, 770, 49, 50, - 26085, 770, 49, 51, 26085, 770, 49, 52, 26085, 770, 49, 53, 26085, 770, - 49, 54, 26085, 770, 49, 55, 26085, 770, 49, 56, 26085, 770, 49, 57, - 26085, 770, 50, 48, 26085, 770, 50, 49, 26085, 770, 50, 50, 26085, 770, - 50, 51, 26085, 770, 50, 52, 26085, 770, 50, 53, 26085, 770, 50, 54, - 26085, 770, 50, 55, 26085, 770, 50, 56, 26085, 770, 50, 57, 26085, 770, - 51, 48, 26085, 770, 51, 49, 26085, 256, 35912, 256, 26356, 256, 36554, - 256, 36040, 256, 28369, 256, 20018, 256, 21477, 256, 40860, 256, 40860, - 256, 22865, 256, 37329, 256, 21895, 256, 22856, 256, 25078, 256, 30313, - 256, 32645, 256, 34367, 256, 34746, 256, 35064, 256, 37007, 256, 27138, - 256, 27931, 256, 28889, 256, 29662, 256, 33853, 256, 37226, 256, 39409, - 256, 20098, 256, 21365, 256, 27396, 256, 29211, 256, 34349, 256, 40478, - 256, 23888, 256, 28651, 256, 34253, 256, 35172, 256, 25289, 256, 33240, - 256, 34847, 256, 24266, 256, 26391, 256, 28010, 256, 29436, 256, 37070, - 256, 20358, 256, 20919, 256, 21214, 256, 25796, 256, 27347, 256, 29200, - 256, 30439, 256, 32769, 256, 34310, 256, 34396, 256, 36335, 256, 38706, - 256, 39791, 256, 40442, 256, 30860, 256, 31103, 256, 32160, 256, 33737, - 256, 37636, 256, 40575, 256, 35542, 256, 22751, 256, 24324, 256, 31840, - 256, 32894, 256, 29282, 256, 30922, 256, 36034, 256, 38647, 256, 22744, - 256, 23650, 256, 27155, 256, 28122, 256, 28431, 256, 32047, 256, 32311, - 256, 38475, 256, 21202, 256, 32907, 256, 20956, 256, 20940, 256, 31260, - 256, 32190, 256, 33777, 256, 38517, 256, 35712, 256, 25295, 256, 27138, - 256, 35582, 256, 20025, 256, 23527, 256, 24594, 256, 29575, 256, 30064, - 256, 21271, 256, 30971, 256, 20415, 256, 24489, 256, 19981, 256, 27852, - 256, 25976, 256, 32034, 256, 21443, 256, 22622, 256, 30465, 256, 33865, - 256, 35498, 256, 27578, 256, 36784, 256, 27784, 256, 25342, 256, 33509, - 256, 25504, 256, 30053, 256, 20142, 256, 20841, 256, 20937, 256, 26753, - 256, 31975, 256, 33391, 256, 35538, 256, 37327, 256, 21237, 256, 21570, - 256, 22899, 256, 24300, 256, 26053, 256, 28670, 256, 31018, 256, 38317, - 256, 39530, 256, 40599, 256, 40654, 256, 21147, 256, 26310, 256, 27511, - 256, 36706, 256, 24180, 256, 24976, 256, 25088, 256, 25754, 256, 28451, - 256, 29001, 256, 29833, 256, 31178, 256, 32244, 256, 32879, 256, 36646, - 256, 34030, 256, 36899, 256, 37706, 256, 21015, 256, 21155, 256, 21693, - 256, 28872, 256, 35010, 256, 35498, 256, 24265, 256, 24565, 256, 25467, - 256, 27566, 256, 31806, 256, 29557, 256, 20196, 256, 22265, 256, 23527, - 256, 23994, 256, 24604, 256, 29618, 256, 29801, 256, 32666, 256, 32838, - 256, 37428, 256, 38646, 256, 38728, 256, 38936, 256, 20363, 256, 31150, - 256, 37300, 256, 38584, 256, 24801, 256, 20102, 256, 20698, 256, 23534, - 256, 23615, 256, 26009, 256, 27138, 256, 29134, 256, 30274, 256, 34044, - 256, 36988, 256, 40845, 256, 26248, 256, 38446, 256, 21129, 256, 26491, - 256, 26611, 256, 27969, 256, 28316, 256, 29705, 256, 30041, 256, 30827, - 256, 32016, 256, 39006, 256, 20845, 256, 25134, 256, 38520, 256, 20523, - 256, 23833, 256, 28138, 256, 36650, 256, 24459, 256, 24900, 256, 26647, - 256, 29575, 256, 38534, 256, 21033, 256, 21519, 256, 23653, 256, 26131, - 256, 26446, 256, 26792, 256, 27877, 256, 29702, 256, 30178, 256, 32633, - 256, 35023, 256, 35041, 256, 37324, 256, 38626, 256, 21311, 256, 28346, - 256, 21533, 256, 29136, 256, 29848, 256, 34298, 256, 38563, 256, 40023, - 256, 40607, 256, 26519, 256, 28107, 256, 33256, 256, 31435, 256, 31520, - 256, 31890, 256, 29376, 256, 28825, 256, 35672, 256, 20160, 256, 33590, - 256, 21050, 256, 20999, 256, 24230, 256, 25299, 256, 31958, 256, 23429, - 256, 27934, 256, 26292, 256, 36667, 256, 34892, 256, 38477, 256, 35211, - 256, 24275, 256, 20800, 256, 21952, 256, 22618, 256, 26228, 256, 20958, - 256, 29482, 256, 30410, 256, 31036, 256, 31070, 256, 31077, 256, 31119, - 256, 38742, 256, 31934, 256, 32701, 256, 34322, 256, 35576, 256, 36920, - 256, 37117, 256, 39151, 256, 39164, 256, 39208, 256, 40372, 256, 20398, - 256, 20711, 256, 20813, 256, 21193, 256, 21220, 256, 21329, 256, 21917, - 256, 22022, 256, 22120, 256, 22592, 256, 22696, 256, 23652, 256, 23662, - 256, 24724, 256, 24936, 256, 24974, 256, 25074, 256, 25935, 256, 26082, - 256, 26257, 256, 26757, 256, 28023, 256, 28186, 256, 28450, 256, 29038, - 256, 29227, 256, 29730, 256, 30865, 256, 31038, 256, 31049, 256, 31048, - 256, 31056, 256, 31062, 256, 31069, 256, 31117, 256, 31118, 256, 31296, - 256, 31361, 256, 31680, 256, 32244, 256, 32265, 256, 32321, 256, 32626, - 256, 32773, 256, 33261, 256, 33401, 256, 33401, 256, 33879, 256, 35088, - 256, 35222, 256, 35585, 256, 35641, 256, 36051, 256, 36104, 256, 36790, - 256, 36920, 256, 38627, 256, 38911, 256, 38971, 514, 102, 102, 514, 102, - 105, 514, 102, 108, 770, 102, 102, 105, 770, 102, 102, 108, 514, 383, - 116, 514, 115, 116, 514, 1396, 1398, 514, 1396, 1381, 514, 1396, 1387, - 514, 1406, 1398, 514, 1396, 1389, 512, 1497, 1460, 512, 1522, 1463, 262, - 1506, 262, 1488, 262, 1491, 262, 1492, 262, 1499, 262, 1500, 262, 1501, - 262, 1512, 262, 1514, 262, 43, 512, 1513, 1473, 512, 1513, 1474, 512, - 64329, 1473, 512, 64329, 1474, 512, 1488, 1463, 512, 1488, 1464, 512, - 1488, 1468, 512, 1489, 1468, 512, 1490, 1468, 512, 1491, 1468, 512, 1492, - 1468, 512, 1493, 1468, 512, 1494, 1468, 512, 1496, 1468, 512, 1497, 1468, - 512, 1498, 1468, 512, 1499, 1468, 512, 1500, 1468, 512, 1502, 1468, 512, - 1504, 1468, 512, 1505, 1468, 512, 1507, 1468, 512, 1508, 1468, 512, 1510, - 1468, 512, 1511, 1468, 512, 1512, 1468, 512, 1513, 1468, 512, 1514, 1468, - 512, 1493, 1465, 512, 1489, 1471, 512, 1499, 1471, 512, 1508, 1471, 514, - 1488, 1500, 267, 1649, 268, 1649, 267, 1659, 268, 1659, 269, 1659, 270, - 1659, 267, 1662, 268, 1662, 269, 1662, 270, 1662, 267, 1664, 268, 1664, - 269, 1664, 270, 1664, 267, 1658, 268, 1658, 269, 1658, 270, 1658, 267, - 1663, 268, 1663, 269, 1663, 270, 1663, 267, 1657, 268, 1657, 269, 1657, - 270, 1657, 267, 1700, 268, 1700, 269, 1700, 270, 1700, 267, 1702, 268, - 1702, 269, 1702, 270, 1702, 267, 1668, 268, 1668, 269, 1668, 270, 1668, - 267, 1667, 268, 1667, 269, 1667, 270, 1667, 267, 1670, 268, 1670, 269, - 1670, 270, 1670, 267, 1671, 268, 1671, 269, 1671, 270, 1671, 267, 1677, - 268, 1677, 267, 1676, 268, 1676, 267, 1678, 268, 1678, 267, 1672, 268, - 1672, 267, 1688, 268, 1688, 267, 1681, 268, 1681, 267, 1705, 268, 1705, - 269, 1705, 270, 1705, 267, 1711, 268, 1711, 269, 1711, 270, 1711, 267, - 1715, 268, 1715, 269, 1715, 270, 1715, 267, 1713, 268, 1713, 269, 1713, - 270, 1713, 267, 1722, 268, 1722, 267, 1723, 268, 1723, 269, 1723, 270, - 1723, 267, 1728, 268, 1728, 267, 1729, 268, 1729, 269, 1729, 270, 1729, - 267, 1726, 268, 1726, 269, 1726, 270, 1726, 267, 1746, 268, 1746, 267, - 1747, 268, 1747, 267, 1709, 268, 1709, 269, 1709, 270, 1709, 267, 1735, - 268, 1735, 267, 1734, 268, 1734, 267, 1736, 268, 1736, 267, 1655, 267, - 1739, 268, 1739, 267, 1733, 268, 1733, 267, 1737, 268, 1737, 267, 1744, - 268, 1744, 269, 1744, 270, 1744, 269, 1609, 270, 1609, 523, 1574, 1575, - 524, 1574, 1575, 523, 1574, 1749, 524, 1574, 1749, 523, 1574, 1608, 524, - 1574, 1608, 523, 1574, 1735, 524, 1574, 1735, 523, 1574, 1734, 524, 1574, - 1734, 523, 1574, 1736, 524, 1574, 1736, 523, 1574, 1744, 524, 1574, 1744, - 525, 1574, 1744, 523, 1574, 1609, 524, 1574, 1609, 525, 1574, 1609, 267, - 1740, 268, 1740, 269, 1740, 270, 1740, 523, 1574, 1580, 523, 1574, 1581, - 523, 1574, 1605, 523, 1574, 1609, 523, 1574, 1610, 523, 1576, 1580, 523, - 1576, 1581, 523, 1576, 1582, 523, 1576, 1605, 523, 1576, 1609, 523, 1576, - 1610, 523, 1578, 1580, 523, 1578, 1581, 523, 1578, 1582, 523, 1578, 1605, - 523, 1578, 1609, 523, 1578, 1610, 523, 1579, 1580, 523, 1579, 1605, 523, - 1579, 1609, 523, 1579, 1610, 523, 1580, 1581, 523, 1580, 1605, 523, 1581, - 1580, 523, 1581, 1605, 523, 1582, 1580, 523, 1582, 1581, 523, 1582, 1605, - 523, 1587, 1580, 523, 1587, 1581, 523, 1587, 1582, 523, 1587, 1605, 523, - 1589, 1581, 523, 1589, 1605, 523, 1590, 1580, 523, 1590, 1581, 523, 1590, - 1582, 523, 1590, 1605, 523, 1591, 1581, 523, 1591, 1605, 523, 1592, 1605, - 523, 1593, 1580, 523, 1593, 1605, 523, 1594, 1580, 523, 1594, 1605, 523, - 1601, 1580, 523, 1601, 1581, 523, 1601, 1582, 523, 1601, 1605, 523, 1601, - 1609, 523, 1601, 1610, 523, 1602, 1581, 523, 1602, 1605, 523, 1602, 1609, - 523, 1602, 1610, 523, 1603, 1575, 523, 1603, 1580, 523, 1603, 1581, 523, - 1603, 1582, 523, 1603, 1604, 523, 1603, 1605, 523, 1603, 1609, 523, 1603, - 1610, 523, 1604, 1580, 523, 1604, 1581, 523, 1604, 1582, 523, 1604, 1605, - 523, 1604, 1609, 523, 1604, 1610, 523, 1605, 1580, 523, 1605, 1581, 523, - 1605, 1582, 523, 1605, 1605, 523, 1605, 1609, 523, 1605, 1610, 523, 1606, - 1580, 523, 1606, 1581, 523, 1606, 1582, 523, 1606, 1605, 523, 1606, 1609, - 523, 1606, 1610, 523, 1607, 1580, 523, 1607, 1605, 523, 1607, 1609, 523, - 1607, 1610, 523, 1610, 1580, 523, 1610, 1581, 523, 1610, 1582, 523, 1610, - 1605, 523, 1610, 1609, 523, 1610, 1610, 523, 1584, 1648, 523, 1585, 1648, - 523, 1609, 1648, 779, 32, 1612, 1617, 779, 32, 1613, 1617, 779, 32, 1614, - 1617, 779, 32, 1615, 1617, 779, 32, 1616, 1617, 779, 32, 1617, 1648, 524, - 1574, 1585, 524, 1574, 1586, 524, 1574, 1605, 524, 1574, 1606, 524, 1574, - 1609, 524, 1574, 1610, 524, 1576, 1585, 524, 1576, 1586, 524, 1576, 1605, - 524, 1576, 1606, 524, 1576, 1609, 524, 1576, 1610, 524, 1578, 1585, 524, - 1578, 1586, 524, 1578, 1605, 524, 1578, 1606, 524, 1578, 1609, 524, 1578, - 1610, 524, 1579, 1585, 524, 1579, 1586, 524, 1579, 1605, 524, 1579, 1606, - 524, 1579, 1609, 524, 1579, 1610, 524, 1601, 1609, 524, 1601, 1610, 524, - 1602, 1609, 524, 1602, 1610, 524, 1603, 1575, 524, 1603, 1604, 524, 1603, - 1605, 524, 1603, 1609, 524, 1603, 1610, 524, 1604, 1605, 524, 1604, 1609, - 524, 1604, 1610, 524, 1605, 1575, 524, 1605, 1605, 524, 1606, 1585, 524, - 1606, 1586, 524, 1606, 1605, 524, 1606, 1606, 524, 1606, 1609, 524, 1606, - 1610, 524, 1609, 1648, 524, 1610, 1585, 524, 1610, 1586, 524, 1610, 1605, - 524, 1610, 1606, 524, 1610, 1609, 524, 1610, 1610, 525, 1574, 1580, 525, - 1574, 1581, 525, 1574, 1582, 525, 1574, 1605, 525, 1574, 1607, 525, 1576, - 1580, 525, 1576, 1581, 525, 1576, 1582, 525, 1576, 1605, 525, 1576, 1607, - 525, 1578, 1580, 525, 1578, 1581, 525, 1578, 1582, 525, 1578, 1605, 525, - 1578, 1607, 525, 1579, 1605, 525, 1580, 1581, 525, 1580, 1605, 525, 1581, - 1580, 525, 1581, 1605, 525, 1582, 1580, 525, 1582, 1605, 525, 1587, 1580, - 525, 1587, 1581, 525, 1587, 1582, 525, 1587, 1605, 525, 1589, 1581, 525, - 1589, 1582, 525, 1589, 1605, 525, 1590, 1580, 525, 1590, 1581, 525, 1590, - 1582, 525, 1590, 1605, 525, 1591, 1581, 525, 1592, 1605, 525, 1593, 1580, - 525, 1593, 1605, 525, 1594, 1580, 525, 1594, 1605, 525, 1601, 1580, 525, - 1601, 1581, 525, 1601, 1582, 525, 1601, 1605, 525, 1602, 1581, 525, 1602, - 1605, 525, 1603, 1580, 525, 1603, 1581, 525, 1603, 1582, 525, 1603, 1604, - 525, 1603, 1605, 525, 1604, 1580, 525, 1604, 1581, 525, 1604, 1582, 525, - 1604, 1605, 525, 1604, 1607, 525, 1605, 1580, 525, 1605, 1581, 525, 1605, - 1582, 525, 1605, 1605, 525, 1606, 1580, 525, 1606, 1581, 525, 1606, 1582, - 525, 1606, 1605, 525, 1606, 1607, 525, 1607, 1580, 525, 1607, 1605, 525, - 1607, 1648, 525, 1610, 1580, 525, 1610, 1581, 525, 1610, 1582, 525, 1610, - 1605, 525, 1610, 1607, 526, 1574, 1605, 526, 1574, 1607, 526, 1576, 1605, - 526, 1576, 1607, 526, 1578, 1605, 526, 1578, 1607, 526, 1579, 1605, 526, - 1579, 1607, 526, 1587, 1605, 526, 1587, 1607, 526, 1588, 1605, 526, 1588, - 1607, 526, 1603, 1604, 526, 1603, 1605, 526, 1604, 1605, 526, 1606, 1605, - 526, 1606, 1607, 526, 1610, 1605, 526, 1610, 1607, 782, 1600, 1614, 1617, - 782, 1600, 1615, 1617, 782, 1600, 1616, 1617, 523, 1591, 1609, 523, 1591, - 1610, 523, 1593, 1609, 523, 1593, 1610, 523, 1594, 1609, 523, 1594, 1610, - 523, 1587, 1609, 523, 1587, 1610, 523, 1588, 1609, 523, 1588, 1610, 523, - 1581, 1609, 523, 1581, 1610, 523, 1580, 1609, 523, 1580, 1610, 523, 1582, - 1609, 523, 1582, 1610, 523, 1589, 1609, 523, 1589, 1610, 523, 1590, 1609, - 523, 1590, 1610, 523, 1588, 1580, 523, 1588, 1581, 523, 1588, 1582, 523, - 1588, 1605, 523, 1588, 1585, 523, 1587, 1585, 523, 1589, 1585, 523, 1590, - 1585, 524, 1591, 1609, 524, 1591, 1610, 524, 1593, 1609, 524, 1593, 1610, - 524, 1594, 1609, 524, 1594, 1610, 524, 1587, 1609, 524, 1587, 1610, 524, - 1588, 1609, 524, 1588, 1610, 524, 1581, 1609, 524, 1581, 1610, 524, 1580, - 1609, 524, 1580, 1610, 524, 1582, 1609, 524, 1582, 1610, 524, 1589, 1609, - 524, 1589, 1610, 524, 1590, 1609, 524, 1590, 1610, 524, 1588, 1580, 524, - 1588, 1581, 524, 1588, 1582, 524, 1588, 1605, 524, 1588, 1585, 524, 1587, - 1585, 524, 1589, 1585, 524, 1590, 1585, 525, 1588, 1580, 525, 1588, 1581, - 525, 1588, 1582, 525, 1588, 1605, 525, 1587, 1607, 525, 1588, 1607, 525, - 1591, 1605, 526, 1587, 1580, 526, 1587, 1581, 526, 1587, 1582, 526, 1588, - 1580, 526, 1588, 1581, 526, 1588, 1582, 526, 1591, 1605, 526, 1592, 1605, - 524, 1575, 1611, 523, 1575, 1611, 781, 1578, 1580, 1605, 780, 1578, 1581, - 1580, 781, 1578, 1581, 1580, 781, 1578, 1581, 1605, 781, 1578, 1582, - 1605, 781, 1578, 1605, 1580, 781, 1578, 1605, 1581, 781, 1578, 1605, - 1582, 780, 1580, 1605, 1581, 781, 1580, 1605, 1581, 780, 1581, 1605, - 1610, 780, 1581, 1605, 1609, 781, 1587, 1581, 1580, 781, 1587, 1580, - 1581, 780, 1587, 1580, 1609, 780, 1587, 1605, 1581, 781, 1587, 1605, - 1581, 781, 1587, 1605, 1580, 780, 1587, 1605, 1605, 781, 1587, 1605, - 1605, 780, 1589, 1581, 1581, 781, 1589, 1581, 1581, 780, 1589, 1605, - 1605, 780, 1588, 1581, 1605, 781, 1588, 1581, 1605, 780, 1588, 1580, - 1610, 780, 1588, 1605, 1582, 781, 1588, 1605, 1582, 780, 1588, 1605, - 1605, 781, 1588, 1605, 1605, 780, 1590, 1581, 1609, 780, 1590, 1582, - 1605, 781, 1590, 1582, 1605, 780, 1591, 1605, 1581, 781, 1591, 1605, - 1581, 781, 1591, 1605, 1605, 780, 1591, 1605, 1610, 780, 1593, 1580, - 1605, 780, 1593, 1605, 1605, 781, 1593, 1605, 1605, 780, 1593, 1605, - 1609, 780, 1594, 1605, 1605, 780, 1594, 1605, 1610, 780, 1594, 1605, - 1609, 780, 1601, 1582, 1605, 781, 1601, 1582, 1605, 780, 1602, 1605, - 1581, 780, 1602, 1605, 1605, 780, 1604, 1581, 1605, 780, 1604, 1581, - 1610, 780, 1604, 1581, 1609, 781, 1604, 1580, 1580, 780, 1604, 1580, - 1580, 780, 1604, 1582, 1605, 781, 1604, 1582, 1605, 780, 1604, 1605, - 1581, 781, 1604, 1605, 1581, 781, 1605, 1581, 1580, 781, 1605, 1581, - 1605, 780, 1605, 1581, 1610, 781, 1605, 1580, 1581, 781, 1605, 1580, - 1605, 781, 1605, 1582, 1580, 781, 1605, 1582, 1605, 781, 1605, 1580, - 1582, 781, 1607, 1605, 1580, 781, 1607, 1605, 1605, 781, 1606, 1581, - 1605, 780, 1606, 1581, 1609, 780, 1606, 1580, 1605, 781, 1606, 1580, - 1605, 780, 1606, 1580, 1609, 780, 1606, 1605, 1610, 780, 1606, 1605, - 1609, 780, 1610, 1605, 1605, 781, 1610, 1605, 1605, 780, 1576, 1582, - 1610, 780, 1578, 1580, 1610, 780, 1578, 1580, 1609, 780, 1578, 1582, - 1610, 780, 1578, 1582, 1609, 780, 1578, 1605, 1610, 780, 1578, 1605, - 1609, 780, 1580, 1605, 1610, 780, 1580, 1581, 1609, 780, 1580, 1605, - 1609, 780, 1587, 1582, 1609, 780, 1589, 1581, 1610, 780, 1588, 1581, - 1610, 780, 1590, 1581, 1610, 780, 1604, 1580, 1610, 780, 1604, 1605, - 1610, 780, 1610, 1581, 1610, 780, 1610, 1580, 1610, 780, 1610, 1605, - 1610, 780, 1605, 1605, 1610, 780, 1602, 1605, 1610, 780, 1606, 1581, - 1610, 781, 1602, 1605, 1581, 781, 1604, 1581, 1605, 780, 1593, 1605, - 1610, 780, 1603, 1605, 1610, 781, 1606, 1580, 1581, 780, 1605, 1582, - 1610, 781, 1604, 1580, 1605, 780, 1603, 1605, 1605, 780, 1604, 1580, - 1605, 780, 1606, 1580, 1581, 780, 1580, 1581, 1610, 780, 1581, 1580, - 1610, 780, 1605, 1580, 1610, 780, 1601, 1605, 1610, 780, 1576, 1581, - 1610, 781, 1603, 1605, 1605, 781, 1593, 1580, 1605, 781, 1589, 1605, - 1605, 780, 1587, 1582, 1610, 780, 1606, 1580, 1610, 779, 1589, 1604, - 1746, 779, 1602, 1604, 1746, 1035, 1575, 1604, 1604, 1607, 1035, 1575, - 1603, 1576, 1585, 1035, 1605, 1581, 1605, 1583, 1035, 1589, 1604, 1593, - 1605, 1035, 1585, 1587, 1608, 1604, 1035, 1593, 1604, 1610, 1607, 1035, - 1608, 1587, 1604, 1605, 779, 1589, 1604, 1609, 4619, 1589, 1604, 1609, - 32, 1575, 1604, 1604, 1607, 32, 1593, 1604, 1610, 1607, 32, 1608, 1587, - 1604, 1605, 2059, 1580, 1604, 32, 1580, 1604, 1575, 1604, 1607, 1035, - 1585, 1740, 1575, 1604, 265, 8229, 265, 8212, 265, 8211, 265, 95, 265, - 95, 265, 40, 265, 41, 265, 123, 265, 125, 265, 12308, 265, 12309, 265, - 12304, 265, 12305, 265, 12298, 265, 12299, 265, 12296, 265, 12297, 265, - 12300, 265, 12301, 265, 12302, 265, 12303, 258, 8254, 258, 8254, 258, - 8254, 258, 8254, 258, 95, 258, 95, 258, 95, 271, 44, 271, 12289, 271, 46, - 271, 59, 271, 58, 271, 63, 271, 33, 271, 8212, 271, 40, 271, 41, 271, - 123, 271, 125, 271, 12308, 271, 12309, 271, 35, 271, 38, 271, 42, 271, - 43, 271, 45, 271, 60, 271, 62, 271, 61, 271, 92, 271, 36, 271, 37, 271, - 64, 523, 32, 1611, 526, 1600, 1611, 523, 32, 1612, 523, 32, 1613, 523, - 32, 1614, 526, 1600, 1614, 523, 32, 1615, 526, 1600, 1615, 523, 32, 1616, - 526, 1600, 1616, 523, 32, 1617, 526, 1600, 1617, 523, 32, 1618, 526, - 1600, 1618, 267, 1569, 267, 1570, 268, 1570, 267, 1571, 268, 1571, 267, - 1572, 268, 1572, 267, 1573, 268, 1573, 267, 1574, 268, 1574, 269, 1574, - 270, 1574, 267, 1575, 268, 1575, 267, 1576, 268, 1576, 269, 1576, 270, - 1576, 267, 1577, 268, 1577, 267, 1578, 268, 1578, 269, 1578, 270, 1578, - 267, 1579, 268, 1579, 269, 1579, 270, 1579, 267, 1580, 268, 1580, 269, - 1580, 270, 1580, 267, 1581, 268, 1581, 269, 1581, 270, 1581, 267, 1582, - 268, 1582, 269, 1582, 270, 1582, 267, 1583, 268, 1583, 267, 1584, 268, - 1584, 267, 1585, 268, 1585, 267, 1586, 268, 1586, 267, 1587, 268, 1587, - 269, 1587, 270, 1587, 267, 1588, 268, 1588, 269, 1588, 270, 1588, 267, - 1589, 268, 1589, 269, 1589, 270, 1589, 267, 1590, 268, 1590, 269, 1590, - 270, 1590, 267, 1591, 268, 1591, 269, 1591, 270, 1591, 267, 1592, 268, - 1592, 269, 1592, 270, 1592, 267, 1593, 268, 1593, 269, 1593, 270, 1593, - 267, 1594, 268, 1594, 269, 1594, 270, 1594, 267, 1601, 268, 1601, 269, - 1601, 270, 1601, 267, 1602, 268, 1602, 269, 1602, 270, 1602, 267, 1603, - 268, 1603, 269, 1603, 270, 1603, 267, 1604, 268, 1604, 269, 1604, 270, - 1604, 267, 1605, 268, 1605, 269, 1605, 270, 1605, 267, 1606, 268, 1606, - 269, 1606, 270, 1606, 267, 1607, 268, 1607, 269, 1607, 270, 1607, 267, - 1608, 268, 1608, 267, 1609, 268, 1609, 267, 1610, 268, 1610, 269, 1610, - 270, 1610, 523, 1604, 1570, 524, 1604, 1570, 523, 1604, 1571, 524, 1604, - 1571, 523, 1604, 1573, 524, 1604, 1573, 523, 1604, 1575, 524, 1604, 1575, - 264, 33, 264, 34, 264, 35, 264, 36, 264, 37, 264, 38, 264, 39, 264, 40, - 264, 41, 264, 42, 264, 43, 264, 44, 264, 45, 264, 46, 264, 47, 264, 48, - 264, 49, 264, 50, 264, 51, 264, 52, 264, 53, 264, 54, 264, 55, 264, 56, - 264, 57, 264, 58, 264, 59, 264, 60, 264, 61, 264, 62, 264, 63, 264, 64, - 264, 65, 264, 66, 264, 67, 264, 68, 264, 69, 264, 70, 264, 71, 264, 72, - 264, 73, 264, 74, 264, 75, 264, 76, 264, 77, 264, 78, 264, 79, 264, 80, - 264, 81, 264, 82, 264, 83, 264, 84, 264, 85, 264, 86, 264, 87, 264, 88, - 264, 89, 264, 90, 264, 91, 264, 92, 264, 93, 264, 94, 264, 95, 264, 96, - 264, 97, 264, 98, 264, 99, 264, 100, 264, 101, 264, 102, 264, 103, 264, - 104, 264, 105, 264, 106, 264, 107, 264, 108, 264, 109, 264, 110, 264, - 111, 264, 112, 264, 113, 264, 114, 264, 115, 264, 116, 264, 117, 264, - 118, 264, 119, 264, 120, 264, 121, 264, 122, 264, 123, 264, 124, 264, - 125, 264, 126, 264, 10629, 264, 10630, 272, 12290, 272, 12300, 272, - 12301, 272, 12289, 272, 12539, 272, 12530, 272, 12449, 272, 12451, 272, - 12453, 272, 12455, 272, 12457, 272, 12515, 272, 12517, 272, 12519, 272, - 12483, 272, 12540, 272, 12450, 272, 12452, 272, 12454, 272, 12456, 272, - 12458, 272, 12459, 272, 12461, 272, 12463, 272, 12465, 272, 12467, 272, - 12469, 272, 12471, 272, 12473, 272, 12475, 272, 12477, 272, 12479, 272, - 12481, 272, 12484, 272, 12486, 272, 12488, 272, 12490, 272, 12491, 272, - 12492, 272, 12493, 272, 12494, 272, 12495, 272, 12498, 272, 12501, 272, - 12504, 272, 12507, 272, 12510, 272, 12511, 272, 12512, 272, 12513, 272, - 12514, 272, 12516, 272, 12518, 272, 12520, 272, 12521, 272, 12522, 272, - 12523, 272, 12524, 272, 12525, 272, 12527, 272, 12531, 272, 12441, 272, - 12442, 272, 12644, 272, 12593, 272, 12594, 272, 12595, 272, 12596, 272, - 12597, 272, 12598, 272, 12599, 272, 12600, 272, 12601, 272, 12602, 272, - 12603, 272, 12604, 272, 12605, 272, 12606, 272, 12607, 272, 12608, 272, - 12609, 272, 12610, 272, 12611, 272, 12612, 272, 12613, 272, 12614, 272, - 12615, 272, 12616, 272, 12617, 272, 12618, 272, 12619, 272, 12620, 272, - 12621, 272, 12622, 272, 12623, 272, 12624, 272, 12625, 272, 12626, 272, - 12627, 272, 12628, 272, 12629, 272, 12630, 272, 12631, 272, 12632, 272, - 12633, 272, 12634, 272, 12635, 272, 12636, 272, 12637, 272, 12638, 272, - 12639, 272, 12640, 272, 12641, 272, 12642, 272, 12643, 264, 162, 264, - 163, 264, 172, 264, 175, 264, 166, 264, 165, 264, 8361, 272, 9474, 272, - 8592, 272, 8593, 272, 8594, 272, 8595, 272, 9632, 272, 9675, 512, 119127, - 119141, 512, 119128, 119141, 512, 119135, 119150, 512, 119135, 119151, - 512, 119135, 119152, 512, 119135, 119153, 512, 119135, 119154, 512, - 119225, 119141, 512, 119226, 119141, 512, 119227, 119150, 512, 119228, - 119150, 512, 119227, 119151, 512, 119228, 119151, 262, 65, 262, 66, 262, - 67, 262, 68, 262, 69, 262, 70, 262, 71, 262, 72, 262, 73, 262, 74, 262, - 75, 262, 76, 262, 77, 262, 78, 262, 79, 262, 80, 262, 81, 262, 82, 262, - 83, 262, 84, 262, 85, 262, 86, 262, 87, 262, 88, 262, 89, 262, 90, 262, - 97, 262, 98, 262, 99, 262, 100, 262, 101, 262, 102, 262, 103, 262, 104, - 262, 105, 262, 106, 262, 107, 262, 108, 262, 109, 262, 110, 262, 111, - 262, 112, 262, 113, 262, 114, 262, 115, 262, 116, 262, 117, 262, 118, - 262, 119, 262, 120, 262, 121, 262, 122, 262, 65, 262, 66, 262, 67, 262, - 68, 262, 69, 262, 70, 262, 71, 262, 72, 262, 73, 262, 74, 262, 75, 262, - 76, 262, 77, 262, 78, 262, 79, 262, 80, 262, 81, 262, 82, 262, 83, 262, - 84, 262, 85, 262, 86, 262, 87, 262, 88, 262, 89, 262, 90, 262, 97, 262, - 98, 262, 99, 262, 100, 262, 101, 262, 102, 262, 103, 262, 105, 262, 106, - 262, 107, 262, 108, 262, 109, 262, 110, 262, 111, 262, 112, 262, 113, - 262, 114, 262, 115, 262, 116, 262, 117, 262, 118, 262, 119, 262, 120, - 262, 121, 262, 122, 262, 65, 262, 66, 262, 67, 262, 68, 262, 69, 262, 70, - 262, 71, 262, 72, 262, 73, 262, 74, 262, 75, 262, 76, 262, 77, 262, 78, - 262, 79, 262, 80, 262, 81, 262, 82, 262, 83, 262, 84, 262, 85, 262, 86, - 262, 87, 262, 88, 262, 89, 262, 90, 262, 97, 262, 98, 262, 99, 262, 100, - 262, 101, 262, 102, 262, 103, 262, 104, 262, 105, 262, 106, 262, 107, - 262, 108, 262, 109, 262, 110, 262, 111, 262, 112, 262, 113, 262, 114, - 262, 115, 262, 116, 262, 117, 262, 118, 262, 119, 262, 120, 262, 121, - 262, 122, 262, 65, 262, 67, 262, 68, 262, 71, 262, 74, 262, 75, 262, 78, - 262, 79, 262, 80, 262, 81, 262, 83, 262, 84, 262, 85, 262, 86, 262, 87, - 262, 88, 262, 89, 262, 90, 262, 97, 262, 98, 262, 99, 262, 100, 262, 102, - 262, 104, 262, 105, 262, 106, 262, 107, 262, 109, 262, 110, 262, 112, - 262, 113, 262, 114, 262, 115, 262, 116, 262, 117, 262, 118, 262, 119, - 262, 120, 262, 121, 262, 122, 262, 65, 262, 66, 262, 67, 262, 68, 262, - 69, 262, 70, 262, 71, 262, 72, 262, 73, 262, 74, 262, 75, 262, 76, 262, - 77, 262, 78, 262, 79, 262, 80, 262, 81, 262, 82, 262, 83, 262, 84, 262, - 85, 262, 86, 262, 87, 262, 88, 262, 89, 262, 90, 262, 97, 262, 98, 262, - 99, 262, 100, 262, 101, 262, 102, 262, 103, 262, 104, 262, 105, 262, 106, - 262, 107, 262, 108, 262, 109, 262, 110, 262, 111, 262, 112, 262, 113, - 262, 114, 262, 115, 262, 116, 262, 117, 262, 118, 262, 119, 262, 120, - 262, 121, 262, 122, 262, 65, 262, 66, 262, 68, 262, 69, 262, 70, 262, 71, - 262, 74, 262, 75, 262, 76, 262, 77, 262, 78, 262, 79, 262, 80, 262, 81, - 262, 83, 262, 84, 262, 85, 262, 86, 262, 87, 262, 88, 262, 89, 262, 97, - 262, 98, 262, 99, 262, 100, 262, 101, 262, 102, 262, 103, 262, 104, 262, - 105, 262, 106, 262, 107, 262, 108, 262, 109, 262, 110, 262, 111, 262, - 112, 262, 113, 262, 114, 262, 115, 262, 116, 262, 117, 262, 118, 262, - 119, 262, 120, 262, 121, 262, 122, 262, 65, 262, 66, 262, 68, 262, 69, - 262, 70, 262, 71, 262, 73, 262, 74, 262, 75, 262, 76, 262, 77, 262, 79, - 262, 83, 262, 84, 262, 85, 262, 86, 262, 87, 262, 88, 262, 89, 262, 97, - 262, 98, 262, 99, 262, 100, 262, 101, 262, 102, 262, 103, 262, 104, 262, - 105, 262, 106, 262, 107, 262, 108, 262, 109, 262, 110, 262, 111, 262, - 112, 262, 113, 262, 114, 262, 115, 262, 116, 262, 117, 262, 118, 262, - 119, 262, 120, 262, 121, 262, 122, 262, 65, 262, 66, 262, 67, 262, 68, - 262, 69, 262, 70, 262, 71, 262, 72, 262, 73, 262, 74, 262, 75, 262, 76, - 262, 77, 262, 78, 262, 79, 262, 80, 262, 81, 262, 82, 262, 83, 262, 84, - 262, 85, 262, 86, 262, 87, 262, 88, 262, 89, 262, 90, 262, 97, 262, 98, - 262, 99, 262, 100, 262, 101, 262, 102, 262, 103, 262, 104, 262, 105, 262, - 106, 262, 107, 262, 108, 262, 109, 262, 110, 262, 111, 262, 112, 262, - 113, 262, 114, 262, 115, 262, 116, 262, 117, 262, 118, 262, 119, 262, - 120, 262, 121, 262, 122, 262, 65, 262, 66, 262, 67, 262, 68, 262, 69, - 262, 70, 262, 71, 262, 72, 262, 73, 262, 74, 262, 75, 262, 76, 262, 77, - 262, 78, 262, 79, 262, 80, 262, 81, 262, 82, 262, 83, 262, 84, 262, 85, - 262, 86, 262, 87, 262, 88, 262, 89, 262, 90, 262, 97, 262, 98, 262, 99, - 262, 100, 262, 101, 262, 102, 262, 103, 262, 104, 262, 105, 262, 106, - 262, 107, 262, 108, 262, 109, 262, 110, 262, 111, 262, 112, 262, 113, - 262, 114, 262, 115, 262, 116, 262, 117, 262, 118, 262, 119, 262, 120, - 262, 121, 262, 122, 262, 65, 262, 66, 262, 67, 262, 68, 262, 69, 262, 70, - 262, 71, 262, 72, 262, 73, 262, 74, 262, 75, 262, 76, 262, 77, 262, 78, - 262, 79, 262, 80, 262, 81, 262, 82, 262, 83, 262, 84, 262, 85, 262, 86, - 262, 87, 262, 88, 262, 89, 262, 90, 262, 97, 262, 98, 262, 99, 262, 100, - 262, 101, 262, 102, 262, 103, 262, 104, 262, 105, 262, 106, 262, 107, - 262, 108, 262, 109, 262, 110, 262, 111, 262, 112, 262, 113, 262, 114, - 262, 115, 262, 116, 262, 117, 262, 118, 262, 119, 262, 120, 262, 121, - 262, 122, 262, 65, 262, 66, 262, 67, 262, 68, 262, 69, 262, 70, 262, 71, - 262, 72, 262, 73, 262, 74, 262, 75, 262, 76, 262, 77, 262, 78, 262, 79, - 262, 80, 262, 81, 262, 82, 262, 83, 262, 84, 262, 85, 262, 86, 262, 87, - 262, 88, 262, 89, 262, 90, 262, 97, 262, 98, 262, 99, 262, 100, 262, 101, - 262, 102, 262, 103, 262, 104, 262, 105, 262, 106, 262, 107, 262, 108, - 262, 109, 262, 110, 262, 111, 262, 112, 262, 113, 262, 114, 262, 115, - 262, 116, 262, 117, 262, 118, 262, 119, 262, 120, 262, 121, 262, 122, - 262, 65, 262, 66, 262, 67, 262, 68, 262, 69, 262, 70, 262, 71, 262, 72, - 262, 73, 262, 74, 262, 75, 262, 76, 262, 77, 262, 78, 262, 79, 262, 80, - 262, 81, 262, 82, 262, 83, 262, 84, 262, 85, 262, 86, 262, 87, 262, 88, - 262, 89, 262, 90, 262, 97, 262, 98, 262, 99, 262, 100, 262, 101, 262, - 102, 262, 103, 262, 104, 262, 105, 262, 106, 262, 107, 262, 108, 262, - 109, 262, 110, 262, 111, 262, 112, 262, 113, 262, 114, 262, 115, 262, - 116, 262, 117, 262, 118, 262, 119, 262, 120, 262, 121, 262, 122, 262, 65, - 262, 66, 262, 67, 262, 68, 262, 69, 262, 70, 262, 71, 262, 72, 262, 73, - 262, 74, 262, 75, 262, 76, 262, 77, 262, 78, 262, 79, 262, 80, 262, 81, - 262, 82, 262, 83, 262, 84, 262, 85, 262, 86, 262, 87, 262, 88, 262, 89, - 262, 90, 262, 97, 262, 98, 262, 99, 262, 100, 262, 101, 262, 102, 262, - 103, 262, 104, 262, 105, 262, 106, 262, 107, 262, 108, 262, 109, 262, - 110, 262, 111, 262, 112, 262, 113, 262, 114, 262, 115, 262, 116, 262, - 117, 262, 118, 262, 119, 262, 120, 262, 121, 262, 122, 262, 913, 262, - 914, 262, 915, 262, 916, 262, 917, 262, 918, 262, 919, 262, 920, 262, - 921, 262, 922, 262, 923, 262, 924, 262, 925, 262, 926, 262, 927, 262, - 928, 262, 929, 262, 1012, 262, 931, 262, 932, 262, 933, 262, 934, 262, - 935, 262, 936, 262, 937, 262, 8711, 262, 945, 262, 946, 262, 947, 262, - 948, 262, 949, 262, 950, 262, 951, 262, 952, 262, 953, 262, 954, 262, - 955, 262, 956, 262, 957, 262, 958, 262, 959, 262, 960, 262, 961, 262, - 962, 262, 963, 262, 964, 262, 965, 262, 966, 262, 967, 262, 968, 262, - 969, 262, 8706, 262, 1013, 262, 977, 262, 1008, 262, 981, 262, 1009, 262, - 982, 262, 913, 262, 914, 262, 915, 262, 916, 262, 917, 262, 918, 262, - 919, 262, 920, 262, 921, 262, 922, 262, 923, 262, 924, 262, 925, 262, - 926, 262, 927, 262, 928, 262, 929, 262, 1012, 262, 931, 262, 932, 262, - 933, 262, 934, 262, 935, 262, 936, 262, 937, 262, 8711, 262, 945, 262, - 946, 262, 947, 262, 948, 262, 949, 262, 950, 262, 951, 262, 952, 262, - 953, 262, 954, 262, 955, 262, 956, 262, 957, 262, 958, 262, 959, 262, - 960, 262, 961, 262, 962, 262, 963, 262, 964, 262, 965, 262, 966, 262, - 967, 262, 968, 262, 969, 262, 8706, 262, 1013, 262, 977, 262, 1008, 262, - 981, 262, 1009, 262, 982, 262, 913, 262, 914, 262, 915, 262, 916, 262, - 917, 262, 918, 262, 919, 262, 920, 262, 921, 262, 922, 262, 923, 262, - 924, 262, 925, 262, 926, 262, 927, 262, 928, 262, 929, 262, 1012, 262, - 931, 262, 932, 262, 933, 262, 934, 262, 935, 262, 936, 262, 937, 262, - 8711, 262, 945, 262, 946, 262, 947, 262, 948, 262, 949, 262, 950, 262, - 951, 262, 952, 262, 953, 262, 954, 262, 955, 262, 956, 262, 957, 262, - 958, 262, 959, 262, 960, 262, 961, 262, 962, 262, 963, 262, 964, 262, - 965, 262, 966, 262, 967, 262, 968, 262, 969, 262, 8706, 262, 1013, 262, - 977, 262, 1008, 262, 981, 262, 1009, 262, 982, 262, 913, 262, 914, 262, - 915, 262, 916, 262, 917, 262, 918, 262, 919, 262, 920, 262, 921, 262, - 922, 262, 923, 262, 924, 262, 925, 262, 926, 262, 927, 262, 928, 262, - 929, 262, 1012, 262, 931, 262, 932, 262, 933, 262, 934, 262, 935, 262, - 936, 262, 937, 262, 8711, 262, 945, 262, 946, 262, 947, 262, 948, 262, - 949, 262, 950, 262, 951, 262, 952, 262, 953, 262, 954, 262, 955, 262, - 956, 262, 957, 262, 958, 262, 959, 262, 960, 262, 961, 262, 962, 262, - 963, 262, 964, 262, 965, 262, 966, 262, 967, 262, 968, 262, 969, 262, - 8706, 262, 1013, 262, 977, 262, 1008, 262, 981, 262, 1009, 262, 982, 262, - 913, 262, 914, 262, 915, 262, 916, 262, 917, 262, 918, 262, 919, 262, - 920, 262, 921, 262, 922, 262, 923, 262, 924, 262, 925, 262, 926, 262, - 927, 262, 928, 262, 929, 262, 1012, 262, 931, 262, 932, 262, 933, 262, - 934, 262, 935, 262, 936, 262, 937, 262, 8711, 262, 945, 262, 946, 262, - 947, 262, 948, 262, 949, 262, 950, 262, 951, 262, 952, 262, 953, 262, - 954, 262, 955, 262, 956, 262, 957, 262, 958, 262, 959, 262, 960, 262, - 961, 262, 962, 262, 963, 262, 964, 262, 965, 262, 966, 262, 967, 262, - 968, 262, 969, 262, 8706, 262, 1013, 262, 977, 262, 1008, 262, 981, 262, - 1009, 262, 982, 262, 48, 262, 49, 262, 50, 262, 51, 262, 52, 262, 53, - 262, 54, 262, 55, 262, 56, 262, 57, 262, 48, 262, 49, 262, 50, 262, 51, - 262, 52, 262, 53, 262, 54, 262, 55, 262, 56, 262, 57, 262, 48, 262, 49, - 262, 50, 262, 51, 262, 52, 262, 53, 262, 54, 262, 55, 262, 56, 262, 57, - 262, 48, 262, 49, 262, 50, 262, 51, 262, 52, 262, 53, 262, 54, 262, 55, - 262, 56, 262, 57, 262, 48, 262, 49, 262, 50, 262, 51, 262, 52, 262, 53, - 262, 54, 262, 55, 262, 56, 262, 57, 256, 20029, 256, 20024, 256, 20033, - 256, 131362, 256, 20320, 256, 20398, 256, 20411, 256, 20482, 256, 20602, - 256, 20633, 256, 20711, 256, 20687, 256, 13470, 256, 132666, 256, 20813, - 256, 20820, 256, 20836, 256, 20855, 256, 132380, 256, 13497, 256, 20839, - 256, 20877, 256, 132427, 256, 20887, 256, 20900, 256, 20172, 256, 20908, - 256, 20917, 256, 168415, 256, 20981, 256, 20995, 256, 13535, 256, 21051, - 256, 21062, 256, 21106, 256, 21111, 256, 13589, 256, 21191, 256, 21193, - 256, 21220, 256, 21242, 256, 21253, 256, 21254, 256, 21271, 256, 21321, - 256, 21329, 256, 21338, 256, 21363, 256, 21373, 256, 21375, 256, 21375, - 256, 21375, 256, 133676, 256, 28784, 256, 21450, 256, 21471, 256, 133987, - 256, 21483, 256, 21489, 256, 21510, 256, 21662, 256, 21560, 256, 21576, - 256, 21608, 256, 21666, 256, 21750, 256, 21776, 256, 21843, 256, 21859, - 256, 21892, 256, 21892, 256, 21913, 256, 21931, 256, 21939, 256, 21954, - 256, 22294, 256, 22022, 256, 22295, 256, 22097, 256, 22132, 256, 20999, - 256, 22766, 256, 22478, 256, 22516, 256, 22541, 256, 22411, 256, 22578, - 256, 22577, 256, 22700, 256, 136420, 256, 22770, 256, 22775, 256, 22790, - 256, 22810, 256, 22818, 256, 22882, 256, 136872, 256, 136938, 256, 23020, - 256, 23067, 256, 23079, 256, 23000, 256, 23142, 256, 14062, 256, 136042, - 256, 23304, 256, 23358, 256, 23358, 256, 137672, 256, 23491, 256, 23512, - 256, 23527, 256, 23539, 256, 138008, 256, 23551, 256, 23558, 256, 24371, - 256, 23586, 256, 14209, 256, 23648, 256, 23662, 256, 23744, 256, 23693, - 256, 138724, 256, 23875, 256, 138726, 256, 23918, 256, 23915, 256, 23932, - 256, 24033, 256, 24034, 256, 14383, 256, 24061, 256, 24104, 256, 24125, - 256, 24169, 256, 14434, 256, 139651, 256, 14460, 256, 24240, 256, 24243, - 256, 24246, 256, 24266, 256, 172946, 256, 24318, 256, 140081, 256, - 140081, 256, 33281, 256, 24354, 256, 24354, 256, 14535, 256, 144056, 256, - 156122, 256, 24418, 256, 24427, 256, 14563, 256, 24474, 256, 24525, 256, - 24535, 256, 24569, 256, 24705, 256, 14650, 256, 14620, 256, 24724, 256, - 141012, 256, 24775, 256, 24904, 256, 24908, 256, 24910, 256, 24908, 256, - 24954, 256, 24974, 256, 25010, 256, 24996, 256, 25007, 256, 25054, 256, - 25074, 256, 25078, 256, 25104, 256, 25115, 256, 25181, 256, 25265, 256, - 25300, 256, 25424, 256, 142092, 256, 25405, 256, 25340, 256, 25448, 256, - 25475, 256, 25572, 256, 142321, 256, 25634, 256, 25541, 256, 25513, 256, - 14894, 256, 25705, 256, 25726, 256, 25757, 256, 25719, 256, 14956, 256, - 25935, 256, 25964, 256, 143370, 256, 26083, 256, 26360, 256, 26185, 256, - 15129, 256, 26257, 256, 15112, 256, 15076, 256, 20882, 256, 20885, 256, - 26368, 256, 26268, 256, 32941, 256, 17369, 256, 26391, 256, 26395, 256, - 26401, 256, 26462, 256, 26451, 256, 144323, 256, 15177, 256, 26618, 256, - 26501, 256, 26706, 256, 26757, 256, 144493, 256, 26766, 256, 26655, 256, - 26900, 256, 15261, 256, 26946, 256, 27043, 256, 27114, 256, 27304, 256, - 145059, 256, 27355, 256, 15384, 256, 27425, 256, 145575, 256, 27476, 256, - 15438, 256, 27506, 256, 27551, 256, 27578, 256, 27579, 256, 146061, 256, - 138507, 256, 146170, 256, 27726, 256, 146620, 256, 27839, 256, 27853, - 256, 27751, 256, 27926, 256, 27966, 256, 28023, 256, 27969, 256, 28009, - 256, 28024, 256, 28037, 256, 146718, 256, 27956, 256, 28207, 256, 28270, - 256, 15667, 256, 28363, 256, 28359, 256, 147153, 256, 28153, 256, 28526, - 256, 147294, 256, 147342, 256, 28614, 256, 28729, 256, 28702, 256, 28699, - 256, 15766, 256, 28746, 256, 28797, 256, 28791, 256, 28845, 256, 132389, - 256, 28997, 256, 148067, 256, 29084, 256, 17323, 256, 29224, 256, 29237, - 256, 29264, 256, 149000, 256, 29312, 256, 29333, 256, 149301, 256, - 149524, 256, 29562, 256, 29579, 256, 16044, 256, 29605, 256, 16056, 256, - 16056, 256, 29767, 256, 29788, 256, 29809, 256, 29829, 256, 29898, 256, - 16155, 256, 29988, 256, 150582, 256, 30014, 256, 150674, 256, 30064, 256, - 139679, 256, 30224, 256, 151457, 256, 151480, 256, 151620, 256, 16380, - 256, 16392, 256, 30452, 256, 151795, 256, 151794, 256, 151833, 256, - 151859, 256, 30494, 256, 30495, 256, 30495, 256, 30538, 256, 16441, 256, - 30603, 256, 16454, 256, 16534, 256, 152605, 256, 30798, 256, 30860, 256, - 30924, 256, 16611, 256, 153126, 256, 31062, 256, 153242, 256, 153285, - 256, 31119, 256, 31211, 256, 16687, 256, 31296, 256, 31306, 256, 31311, - 256, 153980, 256, 154279, 256, 154279, 256, 31406, 256, 16898, 256, - 154539, 256, 31686, 256, 31689, 256, 16935, 256, 154752, 256, 31954, 256, - 17056, 256, 31976, 256, 31971, 256, 32000, 256, 155526, 256, 32099, 256, - 17153, 256, 32199, 256, 32258, 256, 32325, 256, 17204, 256, 156200, 256, - 156231, 256, 17241, 256, 156377, 256, 32634, 256, 156478, 256, 32661, - 256, 32762, 256, 32773, 256, 156890, 256, 156963, 256, 32864, 256, - 157096, 256, 32880, 256, 144223, 256, 17365, 256, 32946, 256, 33027, 256, - 17419, 256, 33086, 256, 23221, 256, 157607, 256, 157621, 256, 144275, - 256, 144284, 256, 33281, 256, 33284, 256, 36766, 256, 17515, 256, 33425, - 256, 33419, 256, 33437, 256, 21171, 256, 33457, 256, 33459, 256, 33469, - 256, 33510, 256, 158524, 256, 33509, 256, 33565, 256, 33635, 256, 33709, - 256, 33571, 256, 33725, 256, 33767, 256, 33879, 256, 33619, 256, 33738, - 256, 33740, 256, 33756, 256, 158774, 256, 159083, 256, 158933, 256, - 17707, 256, 34033, 256, 34035, 256, 34070, 256, 160714, 256, 34148, 256, - 159532, 256, 17757, 256, 17761, 256, 159665, 256, 159954, 256, 17771, - 256, 34384, 256, 34396, 256, 34407, 256, 34409, 256, 34473, 256, 34440, - 256, 34574, 256, 34530, 256, 34681, 256, 34600, 256, 34667, 256, 34694, - 256, 19799, 256, 34785, 256, 34817, 256, 17913, 256, 34912, 256, 34915, - 256, 161383, 256, 35031, 256, 35038, 256, 17973, 256, 35066, 256, 13499, - 256, 161966, 256, 162150, 256, 18110, 256, 18119, 256, 35488, 256, 35565, - 256, 35722, 256, 35925, 256, 162984, 256, 36011, 256, 36033, 256, 36123, - 256, 36215, 256, 163631, 256, 133124, 256, 36299, 256, 36284, 256, 36336, - 256, 133342, 256, 36564, 256, 36664, 256, 165330, 256, 165357, 256, - 37012, 256, 37105, 256, 37137, 256, 165678, 256, 37147, 256, 37432, 256, - 37591, 256, 37592, 256, 37500, 256, 37881, 256, 37909, 256, 166906, 256, - 38283, 256, 18837, 256, 38327, 256, 167287, 256, 18918, 256, 38595, 256, - 23986, 256, 38691, 256, 168261, 256, 168474, 256, 19054, 256, 19062, 256, - 38880, 256, 168970, 256, 19122, 256, 169110, 256, 38923, 256, 38923, 256, - 38953, 256, 169398, 256, 39138, 256, 19251, 256, 39209, 256, 39335, 256, - 39362, 256, 39422, 256, 19406, 256, 170800, 256, 39698, 256, 40000, 256, - 40189, 256, 19662, 256, 19693, 256, 40295, 256, 172238, 256, 19704, 256, - 172293, 256, 172558, 256, 172689, 256, 40635, 256, 19798, 256, 40697, - 256, 40702, 256, 40709, 256, 40719, 256, 40726, 256, 40763, 256, 173568, -}; - -/* index tables for the decomposition data */ -#define DECOMP_SHIFT 8 -static unsigned char decomp_index1[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 16, 17, 18, 19, 20, 21, 22, 7, 7, 7, 7, 7, 23, 7, - 7, 7, 24, 25, 26, 27, 28, 29, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 30, 31, 32, 33, 34, 35, 36, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 37, 7, 7, 38, 39, 40, - 41, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 42, 43, 44, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -}; - -static unsigned short decomp_index2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 3, 0, 6, 0, 0, 0, 0, 8, 0, 0, 11, 13, 15, 18, 0, 0, 20, 23, 25, 0, 27, - 31, 35, 0, 39, 42, 45, 48, 51, 54, 0, 57, 60, 63, 66, 69, 72, 75, 78, 81, - 0, 84, 87, 90, 93, 96, 99, 0, 0, 102, 105, 108, 111, 114, 0, 0, 117, 120, - 123, 126, 129, 132, 0, 135, 138, 141, 144, 147, 150, 153, 156, 159, 0, - 162, 165, 168, 171, 174, 177, 0, 0, 180, 183, 186, 189, 192, 0, 195, 198, - 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240, - 243, 0, 0, 246, 249, 252, 255, 258, 261, 264, 267, 270, 273, 276, 279, - 282, 285, 288, 291, 294, 297, 300, 303, 0, 0, 306, 309, 312, 315, 318, - 321, 324, 327, 330, 0, 333, 336, 339, 342, 345, 348, 0, 351, 354, 357, - 360, 363, 366, 369, 372, 0, 0, 375, 378, 381, 384, 387, 390, 393, 0, 0, - 396, 399, 402, 405, 408, 411, 0, 0, 414, 417, 420, 423, 426, 429, 432, - 435, 438, 441, 444, 447, 450, 453, 456, 459, 462, 465, 0, 0, 468, 471, - 474, 477, 480, 483, 486, 489, 492, 495, 498, 501, 504, 507, 510, 513, - 516, 519, 522, 525, 528, 531, 534, 537, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 539, 542, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 545, 548, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 551, 554, 557, 560, 563, 566, 569, 572, - 575, 578, 581, 584, 587, 590, 593, 596, 599, 602, 605, 608, 611, 614, - 617, 620, 623, 0, 626, 629, 632, 635, 638, 641, 0, 0, 644, 647, 650, 653, - 656, 659, 662, 665, 668, 671, 674, 677, 680, 683, 686, 689, 0, 0, 692, - 695, 698, 701, 704, 707, 710, 713, 716, 719, 722, 725, 728, 731, 734, - 737, 740, 743, 746, 749, 752, 755, 758, 761, 764, 767, 770, 773, 776, - 779, 782, 785, 788, 791, 794, 797, 0, 0, 800, 803, 0, 0, 0, 0, 0, 0, 806, - 809, 812, 815, 818, 821, 824, 827, 830, 833, 836, 839, 842, 845, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 848, 850, 852, 854, 856, 858, 860, 862, 864, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 866, - 869, 872, 875, 878, 881, 0, 0, 884, 886, 888, 890, 892, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 894, 896, 0, 898, 900, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 903, 0, 0, 0, 0, - 0, 905, 0, 0, 0, 908, 0, 0, 0, 0, 0, 910, 913, 916, 919, 921, 924, 927, - 0, 930, 0, 933, 936, 939, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 942, 945, 948, 951, 954, 957, 960, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 963, 966, - 969, 972, 975, 0, 978, 980, 982, 984, 987, 990, 992, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 994, 996, 998, 0, - 1000, 1002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1004, 1007, 0, 1010, 0, 0, 0, - 1013, 0, 0, 0, 0, 1016, 1019, 1022, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1025, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1028, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1031, 1034, 0, 1037, 0, 0, 0, 1040, 0, 0, 0, 0, - 1043, 1046, 1049, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1052, 1055, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1058, 1061, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1064, 1067, 1070, 1073, 0, 0, 1076, 1079, 0, 0, 1082, 1085, - 1088, 1091, 1094, 1097, 0, 0, 1100, 1103, 1106, 1109, 1112, 1115, 0, 0, - 1118, 1121, 1124, 1127, 1130, 1133, 1136, 1139, 1142, 1145, 1148, 1151, - 0, 0, 1154, 1157, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1163, 1166, 1169, 1172, - 1175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1178, 1181, 1184, 1187, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1190, 0, 1193, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1196, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1199, 0, 0, 0, - 0, 0, 0, 0, 1202, 0, 0, 1205, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1208, - 1211, 1214, 1217, 1220, 1223, 1226, 1229, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1232, 1235, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1238, 1241, - 0, 1244, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1247, 0, 0, 1250, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1253, 1256, 1259, 0, 0, 1262, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1265, 0, 0, 1268, 1271, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1274, 1277, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1280, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1283, 1286, 1289, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1292, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1295, 0, 0, 0, 0, 0, 0, 1298, 1301, 0, - 1304, 1307, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1310, 1313, 1316, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1319, 0, 1322, 1325, 1328, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1331, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1334, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1337, 1340, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1343, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1345, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1348, 0, 0, 0, 0, 1351, 0, 0, 0, 0, - 1354, 0, 0, 0, 0, 1357, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1360, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1363, 0, 1366, 1369, 1372, 1375, 1378, 0, 0, 0, 0, - 0, 0, 0, 1381, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1384, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1387, 0, 0, 0, 0, 1390, 0, 0, 0, 0, 1393, 0, - 0, 0, 0, 1396, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1399, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1402, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1405, 1408, 1411, 1414, 1417, 1420, 1423, - 1426, 1429, 1432, 1435, 1438, 1441, 1444, 1447, 1450, 1453, 1456, 1459, - 1462, 1465, 1468, 1471, 1474, 1477, 1480, 1483, 1486, 1489, 1492, 1495, - 1498, 1501, 1504, 1507, 1510, 1513, 1516, 1519, 1522, 1525, 1528, 1531, - 1534, 1537, 1540, 1543, 1546, 1549, 1552, 1555, 1558, 1561, 1564, 1567, - 1570, 1573, 1576, 1579, 1582, 1585, 1588, 1591, 1594, 1597, 1600, 1603, - 1606, 1609, 1612, 1615, 1618, 1621, 1624, 1627, 1630, 1633, 1636, 1639, - 1642, 1645, 1648, 1651, 1654, 1657, 1660, 1663, 1666, 1669, 1672, 1675, - 1678, 1681, 1684, 1687, 1690, 1693, 1696, 1699, 1702, 1705, 1708, 1711, - 1714, 1717, 1720, 1723, 1726, 1729, 1732, 1735, 1738, 1741, 1744, 1747, - 1750, 1753, 1756, 1759, 1762, 1765, 1768, 1771, 1774, 1777, 1780, 1783, - 1786, 1789, 1792, 1795, 1798, 1801, 1804, 1807, 1810, 1813, 1816, 1819, - 1822, 1825, 1828, 1831, 1834, 1837, 1840, 1843, 1846, 1849, 1852, 1855, - 1858, 1861, 1864, 1867, 1870, 0, 0, 0, 0, 1873, 1876, 1879, 1882, 1885, - 1888, 1891, 1894, 1897, 1900, 1903, 1906, 1909, 1912, 1915, 1918, 1921, - 1924, 1927, 1930, 1933, 1936, 1939, 1942, 1945, 1948, 1951, 1954, 1957, - 1960, 1963, 1966, 1969, 1972, 1975, 1978, 1981, 1984, 1987, 1990, 1993, - 1996, 1999, 2002, 2005, 2008, 2011, 2014, 2017, 2020, 2023, 2026, 2029, - 2032, 2035, 2038, 2041, 2044, 2047, 2050, 2053, 2056, 2059, 2062, 2065, - 2068, 2071, 2074, 2077, 2080, 2083, 2086, 2089, 2092, 2095, 2098, 2101, - 2104, 2107, 2110, 2113, 2116, 2119, 2122, 2125, 2128, 2131, 2134, 2137, - 2140, 0, 0, 0, 0, 0, 0, 2143, 2146, 2149, 2152, 2155, 2158, 2161, 2164, - 2167, 2170, 2173, 2176, 2179, 2182, 2185, 2188, 2191, 2194, 2197, 2200, - 2203, 2206, 0, 0, 2209, 2212, 2215, 2218, 2221, 2224, 0, 0, 2227, 2230, - 2233, 2236, 2239, 2242, 2245, 2248, 2251, 2254, 2257, 2260, 2263, 2266, - 2269, 2272, 2275, 2278, 2281, 2284, 2287, 2290, 2293, 2296, 2299, 2302, - 2305, 2308, 2311, 2314, 2317, 2320, 2323, 2326, 2329, 2332, 2335, 2338, - 0, 0, 2341, 2344, 2347, 2350, 2353, 2356, 0, 0, 2359, 2362, 2365, 2368, - 2371, 2374, 2377, 2380, 0, 2383, 0, 2386, 0, 2389, 0, 2392, 2395, 2398, - 2401, 2404, 2407, 2410, 2413, 2416, 2419, 2422, 2425, 2428, 2431, 2434, - 2437, 2440, 2443, 2446, 2448, 2451, 2453, 2456, 2458, 2461, 2463, 2466, - 2468, 2471, 2473, 2476, 0, 0, 2478, 2481, 2484, 2487, 2490, 2493, 2496, - 2499, 2502, 2505, 2508, 2511, 2514, 2517, 2520, 2523, 2526, 2529, 2532, - 2535, 2538, 2541, 2544, 2547, 2550, 2553, 2556, 2559, 2562, 2565, 2568, - 2571, 2574, 2577, 2580, 2583, 2586, 2589, 2592, 2595, 2598, 2601, 2604, - 2607, 2610, 2613, 2616, 2619, 2622, 2625, 2628, 2631, 2634, 0, 2637, - 2640, 2643, 2646, 2649, 2652, 2654, 2657, 2660, 2662, 2665, 2668, 2671, - 2674, 2677, 0, 2680, 2683, 2686, 2689, 2691, 2694, 2696, 2699, 2702, - 2705, 2708, 2711, 2714, 2717, 0, 0, 2719, 2722, 2725, 2728, 2731, 2734, - 0, 2736, 2739, 2742, 2745, 2748, 2751, 2754, 2756, 2759, 2762, 2765, - 2768, 2771, 2774, 2777, 2779, 2782, 2785, 2787, 0, 0, 2789, 2792, 2795, - 0, 2798, 2801, 2804, 2807, 2809, 2812, 2814, 2817, 2819, 0, 2822, 2824, - 2826, 2828, 2830, 2832, 2834, 2836, 2838, 2840, 2842, 0, 0, 0, 0, 0, 0, - 2844, 0, 0, 0, 0, 0, 2846, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2849, - 2851, 2854, 0, 0, 0, 0, 0, 0, 0, 0, 2858, 0, 0, 0, 2860, 2863, 0, 2867, - 2870, 0, 0, 0, 0, 2874, 0, 2877, 0, 0, 0, 0, 0, 0, 0, 0, 2880, 2883, - 2886, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2889, 0, 0, 0, 0, 0, 0, 0, - 2894, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2896, 2898, 0, 0, - 2900, 2902, 2904, 2906, 2908, 2910, 2912, 2914, 2916, 2918, 2920, 2922, - 2924, 2926, 2928, 2930, 2932, 2934, 2936, 2938, 2940, 2942, 2944, 2946, - 2948, 2950, 2952, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 2954, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2957, 2961, 2965, 2967, 0, 2970, 2974, 2978, 0, 2980, 2983, 2985, 2987, - 2989, 2991, 2993, 2995, 2997, 2999, 3001, 0, 3003, 3005, 0, 0, 3008, - 3010, 3012, 3014, 3016, 0, 0, 3018, 3021, 3025, 0, 3028, 0, 3030, 0, - 3032, 0, 3034, 3036, 3038, 3040, 0, 3042, 3044, 3046, 0, 3048, 3050, - 3052, 3054, 3056, 3058, 3060, 0, 0, 0, 3062, 3064, 3066, 3068, 0, 0, 0, - 0, 3070, 3072, 3074, 3076, 3078, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3080, 3084, - 3088, 3092, 3096, 3100, 3104, 3108, 3112, 3116, 3120, 3124, 3128, 3131, - 3133, 3136, 3140, 3143, 3145, 3148, 3152, 3157, 3160, 3162, 3165, 3169, - 3171, 3173, 3175, 3177, 3179, 3182, 3186, 3189, 3191, 3194, 3198, 3203, - 3206, 3208, 3211, 3215, 3217, 3219, 3221, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3223, 3226, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3229, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3232, - 3235, 3238, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 3241, 0, 0, 0, 0, 3244, 0, 0, 3247, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3250, 0, 3253, - 0, 0, 0, 0, 0, 3256, 3259, 0, 3263, 3266, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 3270, 0, 0, 3273, 0, 0, 3276, 0, 3279, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3282, 0, 3285, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 3288, 3291, 3294, 3297, 3300, 0, 0, 3303, 3306, - 0, 0, 3309, 3312, 0, 0, 0, 0, 0, 0, 3315, 3318, 0, 0, 3321, 3324, 0, 0, - 3327, 3330, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3333, 3336, 3339, 3342, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3345, - 3348, 3351, 3354, 0, 0, 0, 0, 0, 0, 3357, 3360, 3363, 3366, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 3369, 3371, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 3373, 3375, 3377, 3379, 3381, 3383, 3385, 3387, - 3389, 3391, 3394, 3397, 3400, 3403, 3406, 3409, 3412, 3415, 3418, 3421, - 3424, 3428, 3432, 3436, 3440, 3444, 3448, 3452, 3456, 3460, 3465, 3470, - 3475, 3480, 3485, 3490, 3495, 3500, 3505, 3510, 3515, 3518, 3521, 3524, - 3527, 3530, 3533, 3536, 3539, 3542, 3546, 3550, 3554, 3558, 3562, 3566, - 3570, 3574, 3578, 3582, 3586, 3590, 3594, 3598, 3602, 3606, 3610, 3614, - 3618, 3622, 3626, 3630, 3634, 3638, 3642, 3646, 3650, 3654, 3658, 3662, - 3666, 3670, 3674, 3678, 3682, 3686, 3690, 3692, 3694, 3696, 3698, 3700, - 3702, 3704, 3706, 3708, 3710, 3712, 3714, 3716, 3718, 3720, 3722, 3724, - 3726, 3728, 3730, 3732, 3734, 3736, 3738, 3740, 3742, 3744, 3746, 3748, - 3750, 3752, 3754, 3756, 3758, 3760, 3762, 3764, 3766, 3768, 3770, 3772, - 3774, 3776, 3778, 3780, 3782, 3784, 3786, 3788, 3790, 3792, 3794, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 3796, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3801, 3805, 3808, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 3812, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 3815, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3817, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3819, 3821, 3823, 3825, 3827, 3829, 3831, - 3833, 3835, 3837, 3839, 3841, 3843, 3845, 3847, 3849, 3851, 3853, 3855, - 3857, 3859, 3861, 3863, 3865, 3867, 3869, 3871, 3873, 3875, 3877, 3879, - 3881, 3883, 3885, 3887, 3889, 3891, 3893, 3895, 3897, 3899, 3901, 3903, - 3905, 3907, 3909, 3911, 3913, 3915, 3917, 3919, 3921, 3923, 3925, 3927, - 3929, 3931, 3933, 3935, 3937, 3939, 3941, 3943, 3945, 3947, 3949, 3951, - 3953, 3955, 3957, 3959, 3961, 3963, 3965, 3967, 3969, 3971, 3973, 3975, - 3977, 3979, 3981, 3983, 3985, 3987, 3989, 3991, 3993, 3995, 3997, 3999, - 4001, 4003, 4005, 4007, 4009, 4011, 4013, 4015, 4017, 4019, 4021, 4023, - 4025, 4027, 4029, 4031, 4033, 4035, 4037, 4039, 4041, 4043, 4045, 4047, - 4049, 4051, 4053, 4055, 4057, 4059, 4061, 4063, 4065, 4067, 4069, 4071, - 4073, 4075, 4077, 4079, 4081, 4083, 4085, 4087, 4089, 4091, 4093, 4095, - 4097, 4099, 4101, 4103, 4105, 4107, 4109, 4111, 4113, 4115, 4117, 4119, - 4121, 4123, 4125, 4127, 4129, 4131, 4133, 4135, 4137, 4139, 4141, 4143, - 4145, 4147, 4149, 4151, 4153, 4155, 4157, 4159, 4161, 4163, 4165, 4167, - 4169, 4171, 4173, 4175, 4177, 4179, 4181, 4183, 4185, 4187, 4189, 4191, - 4193, 4195, 4197, 4199, 4201, 4203, 4205, 4207, 4209, 4211, 4213, 4215, - 4217, 4219, 4221, 4223, 4225, 4227, 4229, 4231, 4233, 4235, 4237, 4239, - 4241, 4243, 4245, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4247, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 4249, 0, 4251, 4253, 4255, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4257, 0, 4260, 0, 4263, 0, 4266, 0, 4269, 0, - 4272, 0, 4275, 0, 4278, 0, 4281, 0, 4284, 0, 4287, 0, 4290, 0, 0, 4293, - 0, 4296, 0, 4299, 0, 0, 0, 0, 0, 0, 4302, 4305, 0, 4308, 4311, 0, 4314, - 4317, 0, 4320, 4323, 0, 4326, 4329, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4332, 0, 0, 0, 0, 0, 0, 4335, 4338, 0, - 4341, 4344, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4347, 0, 4350, 0, 4353, - 0, 4356, 0, 4359, 0, 4362, 0, 4365, 0, 4368, 0, 4371, 0, 4374, 0, 4377, - 0, 4380, 0, 0, 4383, 0, 4386, 0, 4389, 0, 0, 0, 0, 0, 0, 4392, 4395, 0, - 4398, 4401, 0, 4404, 4407, 0, 4410, 4413, 0, 4416, 4419, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4422, 0, 0, 4425, - 4428, 4431, 4434, 0, 0, 0, 4437, 4440, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4443, 4445, 4447, 4449, 4451, - 4453, 4455, 4457, 4459, 4461, 4463, 4465, 4467, 4469, 4471, 4473, 4475, - 4477, 4479, 4481, 4483, 4485, 4487, 4489, 4491, 4493, 4495, 4497, 4499, - 4501, 4503, 4505, 4507, 4509, 4511, 4513, 4515, 4517, 4519, 4521, 4523, - 4525, 4527, 4529, 4531, 4533, 4535, 4537, 4539, 4541, 4543, 4545, 4547, - 4549, 4551, 4553, 4555, 4557, 4559, 4561, 4563, 4565, 4567, 4569, 4571, - 4573, 4575, 4577, 4579, 4581, 4583, 4585, 4587, 4589, 4591, 4593, 4595, - 4597, 4599, 4601, 4603, 4605, 4607, 4609, 4611, 4613, 4615, 4617, 4619, - 4621, 4623, 4625, 4627, 4629, 0, 0, 0, 4631, 4633, 4635, 4637, 4639, - 4641, 4643, 4645, 4647, 4649, 4651, 4653, 4655, 4657, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4659, 4663, 4667, - 4671, 4675, 4679, 4683, 4687, 4691, 4695, 4699, 4703, 4707, 4711, 4715, - 4720, 4725, 4730, 4735, 4740, 4745, 4750, 4755, 4760, 4765, 4770, 4775, - 4780, 4785, 0, 0, 0, 4790, 4794, 4798, 4802, 4806, 4810, 4814, 4818, - 4822, 4826, 4830, 4834, 4838, 4842, 4846, 4850, 4854, 4858, 4862, 4866, - 4870, 4874, 4878, 4882, 4886, 4890, 4894, 4898, 4902, 4906, 4910, 4914, - 4918, 4922, 4926, 4930, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4934, - 4937, 4940, 4943, 4946, 4949, 4952, 4955, 4958, 4961, 4964, 4967, 4970, - 4973, 4976, 4979, 4981, 4983, 4985, 4987, 4989, 4991, 4993, 4995, 4997, - 4999, 5001, 5003, 5005, 5007, 5010, 5013, 5016, 5019, 5022, 5025, 5028, - 5031, 5034, 5037, 5040, 5043, 5046, 0, 0, 0, 0, 5049, 5051, 5053, 5055, - 5057, 5059, 5061, 5063, 5065, 5067, 5069, 5071, 5073, 5075, 5077, 5079, - 5081, 5083, 5085, 5087, 5089, 5091, 5093, 5095, 5097, 5099, 5101, 5103, - 5105, 5107, 5109, 5111, 5113, 5115, 5117, 5119, 5121, 5123, 5125, 5127, - 5129, 5131, 5133, 5135, 5137, 5139, 5141, 5143, 5145, 5147, 5150, 5153, - 5156, 5159, 5162, 5165, 5168, 5171, 5174, 5177, 5180, 5183, 5186, 5189, - 5192, 5195, 5198, 5201, 5204, 5207, 5210, 5213, 5216, 5219, 5223, 5227, - 0, 0, 0, 0, 5231, 5233, 5235, 5237, 5239, 5241, 5243, 5245, 5247, 5249, - 5251, 5253, 5255, 5257, 5259, 5261, 5263, 5265, 5267, 5269, 5271, 5273, - 5275, 5277, 5279, 5281, 5283, 5285, 5287, 5289, 5291, 5293, 5295, 5297, - 5299, 5301, 5303, 5305, 5307, 5309, 5311, 5313, 5315, 5317, 5319, 5321, - 5323, 0, 5325, 5330, 5335, 5340, 5344, 5349, 5353, 5357, 5363, 5368, - 5372, 5376, 5380, 5385, 5390, 5394, 5398, 5401, 5405, 5410, 5415, 5418, - 5424, 5431, 5437, 5441, 5447, 5453, 5458, 5462, 5466, 5470, 5475, 5481, - 5486, 5490, 5494, 5498, 5501, 5504, 5507, 5510, 5514, 5518, 5524, 5528, - 5533, 5539, 5543, 5546, 5549, 5555, 5560, 5566, 5570, 5576, 5579, 5583, - 5587, 5591, 5595, 5599, 5604, 5608, 5611, 5615, 5619, 5623, 5628, 5632, - 5636, 5640, 5646, 5651, 5654, 5660, 5663, 5668, 5673, 5677, 5681, 5685, - 5690, 5693, 5697, 5702, 5705, 5711, 5715, 5718, 5721, 5724, 5727, 5730, - 5733, 5736, 5739, 5742, 5745, 5749, 5753, 5757, 5761, 5765, 5769, 5773, - 5777, 5781, 5785, 5789, 5793, 5797, 5801, 5805, 5809, 5812, 5815, 5819, - 5822, 0, 0, 0, 0, 5825, 5828, 5831, 5834, 5837, 5842, 5845, 5848, 5851, - 5854, 5857, 5860, 5863, 5866, 5870, 5875, 5878, 5881, 5884, 5887, 5890, - 5893, 5896, 5900, 5904, 5908, 5912, 5915, 5918, 5921, 5924, 5927, 5930, - 5933, 5936, 5939, 5942, 5946, 5950, 5953, 5957, 5961, 5965, 5968, 5972, - 5976, 5981, 5984, 5988, 5992, 5996, 6000, 6006, 6013, 6016, 6019, 6022, - 6025, 6028, 6031, 6034, 6037, 6040, 6043, 6046, 6049, 6052, 6055, 6058, - 6061, 6064, 6067, 6072, 6075, 6078, 6081, 6086, 6090, 6093, 6096, 6099, - 6102, 6105, 6108, 6111, 6114, 6117, 6120, 6124, 6127, 6130, 6134, 6138, - 6141, 6146, 6150, 6153, 6156, 6159, 0, 0, 6162, 6165, 6168, 6171, 6174, - 6177, 6180, 6183, 6186, 6189, 6193, 6197, 6201, 6205, 6209, 6213, 6217, - 6221, 6225, 6229, 6233, 6237, 6241, 6245, 6249, 6253, 6257, 6261, 6265, - 6269, 6273, 0, 6277, 6279, 6281, 6283, 6285, 6287, 6289, 6291, 6293, - 6295, 6297, 6299, 6301, 6303, 6305, 6307, 6309, 6311, 6313, 6315, 6317, - 6319, 6321, 6323, 6325, 6327, 6329, 6331, 6333, 6335, 6337, 6339, 6341, - 6343, 6345, 6347, 6349, 6351, 6353, 6355, 6357, 6359, 6361, 6363, 6365, - 6367, 6369, 6371, 6373, 6375, 6377, 6379, 6381, 6383, 6385, 6387, 6389, - 6391, 6393, 6395, 6397, 6399, 6401, 6403, 6405, 6407, 6409, 6411, 6413, - 6415, 6417, 6419, 6421, 6423, 6425, 6427, 6429, 6431, 6433, 6435, 6437, - 6439, 6441, 6443, 6445, 6447, 6449, 6451, 6453, 6455, 6457, 6459, 6461, - 6463, 6465, 6467, 6469, 6471, 6473, 6475, 6477, 6479, 6481, 6483, 6485, - 6487, 6489, 6491, 6493, 6495, 6497, 6499, 6501, 6503, 6505, 6507, 6509, - 6511, 6513, 6515, 6517, 6519, 6521, 6523, 6525, 6527, 6529, 6531, 6533, - 6535, 6537, 6539, 6541, 6543, 6545, 6547, 6549, 6551, 6553, 6555, 6557, - 6559, 6561, 6563, 6565, 6567, 6569, 6571, 6573, 6575, 6577, 6579, 6581, - 6583, 6585, 6587, 6589, 6591, 6593, 6595, 6597, 6599, 6601, 6603, 6605, - 6607, 6609, 6611, 6613, 6615, 6617, 6619, 6621, 6623, 6625, 6627, 6629, - 6631, 6633, 6635, 6637, 6639, 6641, 6643, 6645, 6647, 6649, 6651, 6653, - 6655, 6657, 6659, 6661, 6663, 6665, 6667, 6669, 6671, 6673, 6675, 6677, - 6679, 6681, 6683, 6685, 6687, 6689, 6691, 6693, 6695, 6697, 6699, 6701, - 6703, 6705, 6707, 6709, 6711, 6713, 6715, 6717, 6719, 6721, 6723, 6725, - 6727, 6729, 6731, 6733, 6735, 6737, 6739, 6741, 6743, 6745, 6747, 6749, - 6751, 6753, 6755, 6757, 6759, 6761, 6763, 6765, 6767, 6769, 6771, 6773, - 6775, 6777, 6779, 6781, 6783, 6785, 6787, 6789, 6791, 6793, 6795, 6797, - 6799, 6801, 6803, 6805, 6807, 6809, 6811, 6813, 6815, 0, 0, 6817, 0, - 6819, 0, 0, 6821, 6823, 6825, 6827, 6829, 6831, 6833, 6835, 6837, 6839, - 0, 6841, 0, 6843, 0, 0, 6845, 6847, 0, 0, 0, 6849, 6851, 6853, 6855, 0, - 0, 6857, 6859, 6861, 6863, 6865, 6867, 6869, 6871, 6873, 6875, 6877, - 6879, 6881, 6883, 6885, 6887, 6889, 6891, 6893, 6895, 6897, 6899, 6901, - 6903, 6905, 6907, 6909, 6911, 6913, 6915, 6917, 6919, 6921, 6923, 6925, - 6927, 6929, 6931, 6933, 6935, 6937, 6939, 6941, 6943, 6945, 6947, 6949, - 6951, 6953, 6955, 6957, 6959, 6961, 6963, 6965, 6967, 6969, 6971, 6973, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 6975, 6978, 6981, 6984, 6988, 6992, 6995, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 6998, 7001, 7004, 7007, 7010, 0, 0, 0, 0, 0, 7013, - 0, 7016, 7019, 7021, 7023, 7025, 7027, 7029, 7031, 7033, 7035, 7037, - 7039, 7042, 7045, 7048, 7051, 7054, 7057, 7060, 7063, 7066, 7069, 7072, - 7075, 0, 7078, 7081, 7084, 7087, 7090, 0, 7093, 0, 7096, 7099, 0, 7102, - 7105, 0, 7108, 7111, 7114, 7117, 7120, 7123, 7126, 7129, 7132, 7135, - 7138, 7140, 7142, 7144, 7146, 7148, 7150, 7152, 7154, 7156, 7158, 7160, - 7162, 7164, 7166, 7168, 7170, 7172, 7174, 7176, 7178, 7180, 7182, 7184, - 7186, 7188, 7190, 7192, 7194, 7196, 7198, 7200, 7202, 7204, 7206, 7208, - 7210, 7212, 7214, 7216, 7218, 7220, 7222, 7224, 7226, 7228, 7230, 7232, - 7234, 7236, 7238, 7240, 7242, 7244, 7246, 7248, 7250, 7252, 7254, 7256, - 7258, 7260, 7262, 7264, 7266, 7268, 7270, 7272, 7274, 7276, 7278, 7280, - 7282, 7284, 7286, 7288, 7290, 7292, 7294, 7296, 7298, 7300, 7302, 7304, - 7306, 7308, 7310, 7312, 7314, 7316, 7318, 7320, 7322, 7324, 7326, 7328, - 7330, 7332, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7334, 7336, 7338, 7340, 7342, - 7344, 7346, 7348, 7350, 7352, 7354, 7356, 7358, 7360, 7362, 7364, 7366, - 7368, 7370, 7372, 7374, 7376, 7378, 7380, 7383, 7386, 7389, 7392, 7395, - 7398, 7401, 7404, 7407, 7410, 7413, 7416, 7419, 7422, 7425, 7428, 7431, - 7434, 7436, 7438, 7440, 7442, 7445, 7448, 7451, 7454, 7457, 7460, 7463, - 7466, 7469, 7472, 7475, 7478, 7481, 7484, 7487, 7490, 7493, 7496, 7499, - 7502, 7505, 7508, 7511, 7514, 7517, 7520, 7523, 7526, 7529, 7532, 7535, - 7538, 7541, 7544, 7547, 7550, 7553, 7556, 7559, 7562, 7565, 7568, 7571, - 7574, 7577, 7580, 7583, 7586, 7589, 7592, 7595, 7598, 7601, 7604, 7607, - 7610, 7613, 7616, 7619, 7622, 7625, 7628, 7631, 7634, 7637, 7640, 7643, - 7646, 7649, 7652, 7655, 7658, 7661, 7664, 7667, 7670, 7673, 7676, 7679, - 7682, 7685, 7688, 7691, 7694, 7697, 7700, 7703, 7706, 7709, 7712, 7715, - 7718, 7721, 7724, 7728, 7732, 7736, 7740, 7744, 7748, 7751, 7754, 7757, - 7760, 7763, 7766, 7769, 7772, 7775, 7778, 7781, 7784, 7787, 7790, 7793, - 7796, 7799, 7802, 7805, 7808, 7811, 7814, 7817, 7820, 7823, 7826, 7829, - 7832, 7835, 7838, 7841, 7844, 7847, 7850, 7853, 7856, 7859, 7862, 7865, - 7868, 7871, 7874, 7877, 7880, 7883, 7886, 7889, 7892, 7895, 7898, 7901, - 7904, 7907, 7910, 7913, 7916, 7919, 7922, 7925, 7928, 7931, 7934, 7937, - 7940, 7943, 7946, 7949, 7952, 7955, 7958, 7961, 7964, 7967, 7970, 7973, - 7976, 7979, 7982, 7985, 7988, 7991, 7994, 7997, 8000, 8003, 8006, 8009, - 8012, 8015, 8018, 8021, 8024, 8027, 8030, 8033, 8036, 8039, 8042, 8045, - 8048, 8051, 8054, 8057, 8060, 8063, 8066, 8069, 8072, 8075, 8078, 8081, - 8084, 8087, 8090, 8093, 8096, 8099, 8102, 8105, 8108, 8111, 8114, 8117, - 8120, 8123, 8126, 8129, 8132, 8135, 8138, 8141, 8144, 8147, 8150, 8153, - 8156, 8159, 8162, 8165, 8168, 8171, 8174, 8178, 8182, 8186, 8189, 8192, - 8195, 8198, 8201, 8204, 8207, 8210, 8213, 8216, 8219, 8222, 8225, 8228, - 8231, 8234, 8237, 8240, 8243, 8246, 8249, 8252, 8255, 8258, 8261, 8264, - 8267, 8270, 8273, 8276, 8279, 8282, 8285, 8288, 8291, 8294, 8297, 8300, - 8303, 8306, 8309, 8312, 8315, 8318, 8321, 8324, 8327, 8330, 8333, 8336, - 8339, 8342, 8345, 8348, 8351, 8354, 8357, 8360, 8363, 8366, 8369, 8372, - 8375, 8378, 8381, 8384, 8387, 8390, 8393, 8396, 8399, 8402, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8405, 8409, 8413, 8417, 8421, - 8425, 8429, 8433, 8437, 8441, 8445, 8449, 8453, 8457, 8461, 8465, 8469, - 8473, 8477, 8481, 8485, 8489, 8493, 8497, 8501, 8505, 8509, 8513, 8517, - 8521, 8525, 8529, 8533, 8537, 8541, 8545, 8549, 8553, 8557, 8561, 8565, - 8569, 8573, 8577, 8581, 8585, 8589, 8593, 8597, 8601, 8605, 8609, 8613, - 8617, 8621, 8625, 8629, 8633, 8637, 8641, 8645, 8649, 8653, 8657, 0, 0, - 8661, 8665, 8669, 8673, 8677, 8681, 8685, 8689, 8693, 8697, 8701, 8705, - 8709, 8713, 8717, 8721, 8725, 8729, 8733, 8737, 8741, 8745, 8749, 8753, - 8757, 8761, 8765, 8769, 8773, 8777, 8781, 8785, 8789, 8793, 8797, 8801, - 8805, 8809, 8813, 8817, 8821, 8825, 8829, 8833, 8837, 8841, 8845, 8849, - 8853, 8857, 8861, 8865, 8869, 8873, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 8877, 8881, 8885, 8890, 8895, 8900, 8905, 8910, 8915, 8920, - 8924, 8943, 8952, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 8957, 8959, 8961, 8963, 8965, 8967, 8969, - 8971, 8973, 8975, 8977, 8979, 8981, 8983, 8985, 8987, 8989, 8991, 8993, - 8995, 8997, 0, 0, 0, 0, 8999, 9001, 9003, 9005, 9007, 9009, 9011, 9013, - 9015, 9017, 0, 9019, 9021, 9023, 9025, 9027, 9029, 9031, 9033, 9035, - 9037, 9039, 9041, 9043, 9045, 9047, 9049, 9051, 9053, 9055, 0, 9057, - 9059, 9061, 9063, 0, 0, 0, 0, 9065, 9068, 9071, 0, 9074, 0, 9077, 9080, - 9083, 9086, 9089, 9092, 9095, 9098, 9101, 9104, 9107, 9109, 9111, 9113, - 9115, 9117, 9119, 9121, 9123, 9125, 9127, 9129, 9131, 9133, 9135, 9137, - 9139, 9141, 9143, 9145, 9147, 9149, 9151, 9153, 9155, 9157, 9159, 9161, - 9163, 9165, 9167, 9169, 9171, 9173, 9175, 9177, 9179, 9181, 9183, 9185, - 9187, 9189, 9191, 9193, 9195, 9197, 9199, 9201, 9203, 9205, 9207, 9209, - 9211, 9213, 9215, 9217, 9219, 9221, 9223, 9225, 9227, 9229, 9231, 9233, - 9235, 9237, 9239, 9241, 9243, 9245, 9247, 9249, 9251, 9253, 9255, 9257, - 9259, 9261, 9263, 9265, 9267, 9269, 9271, 9273, 9275, 9277, 9279, 9281, - 9283, 9285, 9287, 9289, 9291, 9293, 9295, 9297, 9299, 9301, 9303, 9305, - 9307, 9309, 9311, 9313, 9315, 9317, 9319, 9321, 9323, 9325, 9327, 9329, - 9331, 9333, 9335, 9337, 9339, 9341, 9344, 9347, 9350, 9353, 9356, 9359, - 9362, 0, 0, 0, 0, 9365, 9367, 9369, 9371, 9373, 9375, 9377, 9379, 9381, - 9383, 9385, 9387, 9389, 9391, 9393, 9395, 9397, 9399, 9401, 9403, 9405, - 9407, 9409, 9411, 9413, 9415, 9417, 9419, 9421, 9423, 9425, 9427, 9429, - 9431, 9433, 9435, 9437, 9439, 9441, 9443, 9445, 9447, 9449, 9451, 9453, - 9455, 9457, 9459, 9461, 9463, 9465, 9467, 9469, 9471, 9473, 9475, 9477, - 9479, 9481, 9483, 9485, 9487, 9489, 9491, 9493, 9495, 9497, 9499, 9501, - 9503, 9505, 9507, 9509, 9511, 9513, 9515, 9517, 9519, 9521, 9523, 9525, - 9527, 9529, 9531, 9533, 9535, 9537, 9539, 9541, 9543, 9545, 9547, 9549, - 9551, 9553, 9555, 9557, 9559, 9561, 9563, 9565, 9567, 9569, 9571, 9573, - 9575, 9577, 9579, 9581, 9583, 9585, 9587, 9589, 9591, 9593, 9595, 9597, - 9599, 9601, 9603, 9605, 9607, 9609, 9611, 9613, 9615, 9617, 9619, 9621, - 9623, 9625, 9627, 9629, 9631, 9633, 9635, 9637, 9639, 9641, 9643, 9645, - 9647, 9649, 9651, 9653, 9655, 9657, 9659, 9661, 9663, 9665, 9667, 9669, - 9671, 9673, 9675, 9677, 9679, 9681, 9683, 9685, 9687, 9689, 9691, 9693, - 9695, 9697, 9699, 9701, 9703, 9705, 9707, 9709, 9711, 9713, 9715, 9717, - 9719, 9721, 9723, 9725, 9727, 9729, 9731, 9733, 9735, 9737, 9739, 9741, - 9743, 0, 0, 0, 9745, 9747, 9749, 9751, 9753, 9755, 0, 0, 9757, 9759, - 9761, 9763, 9765, 9767, 0, 0, 9769, 9771, 9773, 9775, 9777, 9779, 0, 0, - 9781, 9783, 9785, 0, 0, 0, 9787, 9789, 9791, 9793, 9795, 9797, 9799, 0, - 9801, 9803, 9805, 9807, 9809, 9811, 9813, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 9815, 9818, 9821, 9824, 9827, 9830, 9833, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 9836, 9839, 9842, 9845, 9848, 9851, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9854, 9856, 9858, 9860, 9862, 9864, - 9866, 9868, 9870, 9872, 9874, 9876, 9878, 9880, 9882, 9884, 9886, 9888, - 9890, 9892, 9894, 9896, 9898, 9900, 9902, 9904, 9906, 9908, 9910, 9912, - 9914, 9916, 9918, 9920, 9922, 9924, 9926, 9928, 9930, 9932, 9934, 9936, - 9938, 9940, 9942, 9944, 9946, 9948, 9950, 9952, 9954, 9956, 9958, 9960, - 9962, 9964, 9966, 9968, 9970, 9972, 9974, 9976, 9978, 9980, 9982, 9984, - 9986, 9988, 9990, 9992, 9994, 9996, 9998, 10000, 10002, 10004, 10006, - 10008, 10010, 10012, 10014, 10016, 10018, 10020, 10022, 0, 10024, 10026, - 10028, 10030, 10032, 10034, 10036, 10038, 10040, 10042, 10044, 10046, - 10048, 10050, 10052, 10054, 10056, 10058, 10060, 10062, 10064, 10066, - 10068, 10070, 10072, 10074, 10076, 10078, 10080, 10082, 10084, 10086, - 10088, 10090, 10092, 10094, 10096, 10098, 10100, 10102, 10104, 10106, - 10108, 10110, 10112, 10114, 10116, 10118, 10120, 10122, 10124, 10126, - 10128, 10130, 10132, 10134, 10136, 10138, 10140, 10142, 10144, 10146, - 10148, 10150, 10152, 10154, 10156, 10158, 10160, 10162, 10164, 0, 10166, - 10168, 0, 0, 10170, 0, 0, 10172, 10174, 0, 0, 10176, 10178, 10180, 10182, - 0, 10184, 10186, 10188, 10190, 10192, 10194, 10196, 10198, 10200, 10202, - 10204, 10206, 0, 10208, 0, 10210, 10212, 10214, 10216, 0, 10218, 10220, - 0, 10222, 10224, 10226, 10228, 10230, 10232, 10234, 10236, 10238, 10240, - 10242, 10244, 10246, 10248, 10250, 10252, 10254, 10256, 10258, 10260, - 10262, 10264, 10266, 10268, 10270, 10272, 10274, 10276, 10278, 10280, - 10282, 10284, 10286, 10288, 10290, 10292, 10294, 10296, 10298, 10300, - 10302, 10304, 10306, 10308, 10310, 10312, 10314, 10316, 10318, 10320, - 10322, 10324, 10326, 10328, 10330, 10332, 10334, 10336, 10338, 10340, - 10342, 10344, 10346, 10348, 10350, 0, 10352, 10354, 10356, 10358, 0, 0, - 10360, 10362, 10364, 10366, 10368, 10370, 10372, 10374, 0, 10376, 10378, - 10380, 10382, 10384, 10386, 10388, 0, 10390, 10392, 10394, 10396, 10398, - 10400, 10402, 10404, 10406, 10408, 10410, 10412, 10414, 10416, 10418, - 10420, 10422, 10424, 10426, 10428, 10430, 10432, 10434, 10436, 10438, - 10440, 10442, 10444, 0, 10446, 10448, 10450, 10452, 0, 10454, 10456, - 10458, 10460, 10462, 0, 10464, 0, 0, 0, 10466, 10468, 10470, 10472, - 10474, 10476, 10478, 0, 10480, 10482, 10484, 10486, 10488, 10490, 10492, - 10494, 10496, 10498, 10500, 10502, 10504, 10506, 10508, 10510, 10512, - 10514, 10516, 10518, 10520, 10522, 10524, 10526, 10528, 10530, 10532, - 10534, 10536, 10538, 10540, 10542, 10544, 10546, 10548, 10550, 10552, - 10554, 10556, 10558, 10560, 10562, 10564, 10566, 10568, 10570, 10572, - 10574, 10576, 10578, 10580, 10582, 10584, 10586, 10588, 10590, 10592, - 10594, 10596, 10598, 10600, 10602, 10604, 10606, 10608, 10610, 10612, - 10614, 10616, 10618, 10620, 10622, 10624, 10626, 10628, 10630, 10632, - 10634, 10636, 10638, 10640, 10642, 10644, 10646, 10648, 10650, 10652, - 10654, 10656, 10658, 10660, 10662, 10664, 10666, 10668, 10670, 10672, - 10674, 10676, 10678, 10680, 10682, 10684, 10686, 10688, 10690, 10692, - 10694, 10696, 10698, 10700, 10702, 10704, 10706, 10708, 10710, 10712, - 10714, 10716, 10718, 10720, 10722, 10724, 10726, 10728, 10730, 10732, - 10734, 10736, 10738, 10740, 10742, 10744, 10746, 10748, 10750, 10752, - 10754, 10756, 10758, 10760, 10762, 10764, 10766, 10768, 10770, 10772, - 10774, 10776, 10778, 10780, 10782, 10784, 10786, 10788, 10790, 10792, - 10794, 10796, 10798, 10800, 10802, 10804, 10806, 10808, 10810, 10812, - 10814, 10816, 10818, 10820, 10822, 10824, 10826, 10828, 10830, 10832, - 10834, 10836, 10838, 10840, 10842, 10844, 10846, 10848, 10850, 10852, - 10854, 10856, 10858, 10860, 10862, 10864, 10866, 10868, 10870, 10872, - 10874, 10876, 10878, 10880, 10882, 10884, 10886, 10888, 10890, 10892, - 10894, 10896, 10898, 10900, 10902, 10904, 10906, 10908, 10910, 10912, - 10914, 10916, 10918, 10920, 10922, 10924, 10926, 10928, 10930, 10932, - 10934, 10936, 10938, 10940, 10942, 10944, 10946, 10948, 10950, 10952, - 10954, 10956, 10958, 10960, 10962, 10964, 10966, 10968, 10970, 10972, - 10974, 10976, 10978, 10980, 10982, 10984, 10986, 10988, 10990, 10992, - 10994, 10996, 10998, 11000, 11002, 11004, 11006, 11008, 11010, 11012, - 11014, 11016, 11018, 11020, 11022, 11024, 11026, 11028, 11030, 11032, - 11034, 11036, 11038, 11040, 11042, 11044, 11046, 11048, 11050, 11052, - 11054, 11056, 11058, 11060, 11062, 11064, 11066, 11068, 11070, 11072, - 11074, 11076, 11078, 11080, 11082, 11084, 11086, 11088, 11090, 11092, - 11094, 11096, 11098, 11100, 11102, 11104, 11106, 11108, 11110, 11112, - 11114, 11116, 11118, 11120, 11122, 11124, 11126, 11128, 11130, 11132, - 11134, 11136, 11138, 11140, 11142, 11144, 11146, 11148, 11150, 11152, - 11154, 0, 0, 0, 0, 11156, 11158, 11160, 11162, 11164, 11166, 11168, - 11170, 11172, 11174, 11176, 11178, 11180, 11182, 11184, 11186, 11188, - 11190, 11192, 11194, 11196, 11198, 11200, 11202, 11204, 11206, 11208, - 11210, 11212, 11214, 11216, 11218, 11220, 11222, 11224, 11226, 11228, - 11230, 11232, 11234, 11236, 11238, 11240, 11242, 11244, 11246, 11248, - 11250, 11252, 11254, 11256, 11258, 11260, 11262, 11264, 11266, 11268, - 11270, 11272, 11274, 11276, 11278, 11280, 11282, 11284, 11286, 11288, - 11290, 11292, 11294, 11296, 11298, 11300, 11302, 11304, 11306, 11308, - 11310, 11312, 11314, 11316, 11318, 11320, 11322, 11324, 11326, 11328, - 11330, 11332, 11334, 11336, 11338, 11340, 11342, 11344, 11346, 11348, - 11350, 11352, 11354, 11356, 11358, 11360, 11362, 11364, 11366, 11368, - 11370, 11372, 11374, 11376, 11378, 11380, 11382, 11384, 11386, 11388, - 11390, 11392, 11394, 11396, 11398, 11400, 11402, 11404, 11406, 11408, - 11410, 11412, 11414, 11416, 11418, 11420, 11422, 11424, 11426, 11428, - 11430, 11432, 11434, 11436, 11438, 11440, 11442, 11444, 11446, 11448, - 11450, 11452, 11454, 11456, 11458, 11460, 11462, 11464, 11466, 11468, - 11470, 11472, 11474, 11476, 11478, 11480, 11482, 11484, 11486, 11488, - 11490, 11492, 11494, 11496, 11498, 11500, 11502, 11504, 11506, 11508, - 11510, 11512, 11514, 11516, 11518, 11520, 11522, 11524, 11526, 11528, - 11530, 11532, 11534, 11536, 11538, 11540, 11542, 11544, 11546, 11548, - 11550, 11552, 11554, 11556, 11558, 11560, 11562, 11564, 11566, 11568, - 11570, 11572, 11574, 11576, 11578, 11580, 11582, 11584, 11586, 11588, - 11590, 11592, 11594, 11596, 11598, 11600, 11602, 11604, 11606, 11608, - 11610, 11612, 11614, 11616, 11618, 11620, 11622, 11624, 11626, 11628, - 11630, 11632, 11634, 11636, 11638, 11640, 11642, 11644, 11646, 11648, - 11650, 11652, 11654, 11656, 11658, 11660, 11662, 11664, 11666, 11668, - 11670, 11672, 11674, 11676, 11678, 11680, 11682, 11684, 11686, 11688, - 11690, 11692, 11694, 11696, 11698, 11700, 11702, 11704, 11706, 11708, - 11710, 11712, 11714, 11716, 11718, 11720, 11722, 11724, 11726, 11728, - 11730, 11732, 11734, 0, 0, 0, 0, 11736, 11738, 11740, 11742, 11744, - 11746, 11748, 11750, 11752, 11754, 11756, 11758, 11760, 11762, 11764, - 11766, 11768, 11770, 11772, 11774, 11776, 11778, 11780, 11782, 11784, - 11786, 11788, 11790, 11792, 11794, 11796, 11798, 11800, 11802, 11804, - 11806, 11808, 11810, 11812, 11814, 11816, 11818, 11820, 11822, 11824, - 11826, 11828, 11830, 11832, 11834, 11836, 11838, 11840, 11842, 11844, - 11846, 11848, 11850, 11852, 11854, 11856, 11858, 11860, 11862, 11864, - 11866, 11868, 11870, 11872, 11874, 11876, 11878, 11880, 11882, 11884, - 11886, 11888, 11890, 11892, 11894, 11896, 11898, 11900, 11902, 11904, - 11906, 11908, 11910, 11912, 11914, 11916, 11918, 11920, 11922, 11924, - 11926, 11928, 11930, 11932, 11934, 11936, 11938, 11940, 11942, 11944, - 11946, 11948, 11950, 11952, 11954, 11956, 11958, 11960, 11962, 11964, - 11966, 11968, 11970, 11972, 11974, 11976, 11978, 11980, 11982, 11984, - 11986, 11988, 11990, 11992, 11994, 11996, 11998, 12000, 12002, 12004, - 12006, 12008, 12010, 12012, 12014, 12016, 12018, 12020, 12022, 12024, - 12026, 12028, 12030, 12032, 12034, 12036, 12038, 12040, 12042, 12044, - 12046, 12048, 12050, 12052, 12054, 12056, 12058, 12060, 12062, 12064, - 12066, 12068, 12070, 12072, 12074, 12076, 12078, 12080, 12082, 12084, - 12086, 12088, 12090, 12092, 12094, 12096, 12098, 12100, 12102, 12104, - 12106, 12108, 12110, 12112, 12114, 12116, 12118, 12120, 12122, 12124, - 12126, 12128, 12130, 12132, 12134, 12136, 12138, 12140, 12142, 12144, - 12146, 12148, 12150, 12152, 12154, 12156, 12158, 12160, 12162, 12164, - 12166, 12168, 12170, 12172, 12174, 12176, 12178, 12180, 12182, 12184, - 12186, 12188, 12190, 12192, 12194, 12196, 12198, 12200, 12202, 12204, - 12206, 12208, 12210, 12212, 12214, 12216, 12218, 12220, 12222, 12224, - 12226, 12228, 12230, 12232, 12234, 12236, 12238, 12240, 12242, 12244, - 12246, 12248, 12250, 12252, 12254, 12256, 12258, 12260, 12262, 12264, - 12266, 12268, 12270, 12272, 12274, 12276, 12278, 12280, 12282, 12284, - 12286, 12288, 12290, 12292, 12294, 12296, 12298, 12300, 12302, 12304, - 12306, 12308, 12310, 12312, 12314, 12316, 12318, 12320, 12322, 12324, - 12326, 12328, 12330, 12332, 12334, 12336, 12338, 12340, 12342, 12344, - 12346, 12348, 12350, 12352, 12354, 12356, 12358, 12360, 12362, 12364, - 12366, 12368, 12370, 12372, 12374, 12376, 12378, 12380, 12382, 12384, - 12386, 12388, 12390, 12392, 12394, 12396, 12398, 12400, 12402, 12404, - 12406, 12408, 12410, 12412, 12414, 12416, 12418, 12420, 12422, 12424, - 12426, 12428, 12430, 12432, 12434, 12436, 12438, 12440, 12442, 12444, - 12446, 12448, 12450, 12452, 12454, 12456, 12458, 12460, 12462, 12464, - 12466, 12468, 12470, 12472, 12474, 12476, 12478, 12480, 12482, 12484, - 12486, 12488, 12490, 12492, 12494, 12496, 12498, 12500, 12502, 12504, - 12506, 12508, 12510, 12512, 12514, 12516, 12518, 12520, 12522, 12524, - 12526, 12528, 12530, 12532, 12534, 12536, 12538, 12540, 12542, 12544, - 12546, 12548, 12550, 12552, 12554, 12556, 12558, 12560, 12562, 12564, - 12566, 12568, 12570, 12572, 12574, 12576, 12578, 12580, 12582, 12584, - 12586, 12588, 12590, 12592, 12594, 12596, 12598, 12600, 12602, 12604, - 12606, 12608, 12610, 12612, 12614, 12616, 12618, 12620, 12622, 12624, - 12626, 12628, 12630, 12632, 12634, 12636, 12638, 12640, 12642, 12644, - 12646, 12648, 12650, 12652, 12654, 12656, 12658, 12660, 12662, 12664, - 12666, 12668, 12670, 12672, 12674, 12676, 12678, 12680, 12682, 12684, - 12686, 12688, 12690, 12692, 12694, 12696, 12698, 12700, 12702, 12704, - 12706, 12708, 12710, 12712, 12714, 12716, 12718, 12720, 12722, 12724, - 12726, 12728, 12730, 12732, 12734, 12736, 12738, 12740, 12742, 12744, - 12746, 12748, 12750, 12752, 12754, 12756, 12758, 12760, 12762, 12764, - 12766, 12768, 12770, 12772, 12774, 12776, 12778, 12780, 12782, 12784, - 12786, 12788, 12790, 12792, 12794, 12796, 12798, 12800, 12802, 12804, - 12806, 12808, 12810, 12812, 12814, 12816, 12818, 12820, 12822, 12824, - 12826, 12828, 12830, 12832, 12834, 12836, 12838, 12840, 12842, 12844, - 12846, 12848, 12850, 12852, 12854, 12856, 12858, 12860, 12862, 12864, - 12866, 12868, 12870, 12872, 12874, 12876, 12878, 12880, 12882, 12884, - 12886, 12888, 12890, 12892, 12894, 12896, 12898, 12900, 12902, 12904, - 12906, 12908, 12910, 12912, 12914, 12916, 12918, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; - -/* NFC pairs */ -#define COMP_SHIFT 3 -static unsigned short comp_index[] = { - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 3, 0, 0, 4, 5, 6, 7, 0, - 0, 0, 0, 8, 9, 10, 0, 0, 0, 11, 12, 13, 0, 0, 0, 0, 14, 15, 16, 17, 0, 0, - 18, 19, 20, 21, 0, 0, 0, 22, 0, 0, 0, 0, 0, 23, 24, 25, 26, 0, 0, 0, 27, - 28, 29, 30, 0, 0, 31, 32, 33, 34, 35, 0, 0, 36, 0, 0, 0, 0, 0, 0, 37, 38, - 39, 40, 0, 0, 41, 0, 42, 43, 44, 0, 0, 45, 46, 47, 0, 0, 0, 0, 48, 49, - 50, 51, 0, 0, 52, 53, 54, 55, 0, 0, 0, 56, 57, 0, 0, 0, 0, 0, 58, 59, 60, - 61, 0, 0, 62, 63, 64, 65, 0, 0, 0, 66, 67, 68, 69, 0, 0, 70, 71, 72, 73, - 0, 0, 0, 74, 0, 75, 0, 0, 0, 0, 76, 0, 77, 0, 0, 0, 0, 78, 0, 0, 0, 0, 0, - 79, 80, 81, 0, 0, 0, 0, 82, 83, 84, 85, 0, 0, 86, 87, 88, 89, 0, 0, 0, - 90, 0, 91, 92, 0, 0, 93, 94, 95, 96, 0, 0, 0, 0, 97, 98, 99, 0, 0, 0, - 100, 101, 102, 103, 0, 0, 0, 104, 0, 0, 0, 0, 0, 105, 106, 107, 0, 0, 0, - 0, 108, 109, 110, 111, 0, 0, 112, 113, 114, 115, 0, 0, 0, 116, 117, 0, 0, - 0, 0, 118, 0, 119, 120, 121, 0, 0, 122, 123, 124, 125, 0, 0, 0, 126, 0, - 127, 0, 0, 0, 128, 129, 130, 131, 0, 0, 0, 132, 133, 134, 135, 0, 0, 0, - 136, 0, 0, 0, 0, 0, 137, 138, 139, 140, 0, 0, 0, 141, 142, 143, 0, 0, 0, - 0, 144, 145, 146, 147, 0, 0, 148, 149, 150, 151, 0, 0, 0, 152, 0, 153, 0, - 0, 0, 154, 155, 156, 0, 0, 0, 0, 0, 157, 0, 0, 0, 0, 158, 159, 160, 161, - 0, 0, 0, 162, 163, 164, 165, 0, 0, 0, 166, 0, 0, 167, 0, 0, 168, 169, 0, - 0, 0, 0, 0, 170, 0, 0, 0, 0, 0, 0, 171, 0, 0, 0, 0, 0, 172, 173, 0, 0, 0, - 0, 0, 174, 0, 0, 0, 0, 0, 175, 176, 0, 0, 0, 0, 0, 177, 0, 0, 0, 0, 0, 0, - 178, 179, 0, 0, 0, 0, 180, 181, 0, 0, 0, 0, 0, 182, 0, 0, 0, 0, 0, 0, - 183, 0, 0, 0, 0, 0, 184, 185, 186, 0, 0, 0, 0, 187, 188, 0, 0, 0, 0, 0, - 189, 0, 0, 0, 0, 0, 190, 0, 0, 0, 0, 0, 0, 191, 0, 0, 0, 0, 0, 192, 0, 0, - 0, 0, 0, 0, 193, 194, 0, 0, 0, 0, 0, 195, 0, 0, 0, 0, 0, 196, 197, 0, 0, - 0, 0, 0, 198, 199, 0, 0, 0, 0, 0, 200, 0, 0, 0, 0, 0, 201, 0, 0, 0, 0, 0, - 0, 202, 203, 0, 0, 0, 0, 204, 205, 0, 0, 0, 0, 0, 206, 207, 0, 0, 0, 0, - 0, 208, 0, 0, 0, 0, 0, 209, 0, 0, 0, 0, 0, 0, 210, 0, 0, 0, 0, 0, 211, - 212, 0, 0, 0, 0, 0, 0, 213, 0, 0, 0, 0, 0, 214, 0, 0, 0, 0, 0, 0, 215, 0, - 0, 0, 0, 0, 0, 216, 0, 0, 0, 0, 0, 217, 0, 0, 0, 0, 0, 218, 0, 0, 0, 0, - 0, 0, 0, 219, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 221, 0, 0, 0, 0, 0, - 222, 223, 224, 0, 0, 0, 225, 226, 227, 0, 0, 0, 0, 228, 229, 230, 0, 0, - 0, 0, 231, 232, 233, 0, 0, 0, 0, 0, 234, 0, 0, 0, 0, 235, 0, 0, 0, 0, 0, - 0, 236, 0, 0, 0, 0, 0, 0, 237, 0, 0, 0, 0, 0, 238, 0, 0, 0, 0, 0, 0, 239, - 0, 0, 0, 0, 0, 0, 240, 0, 0, 0, 0, 0, 241, 0, 0, 0, 0, 0, 0, 242, 0, 0, - 0, 0, 0, 0, 243, 0, 0, 0, 0, 244, 245, 246, 0, 247, 0, 0, 248, 0, 249, 0, - 0, 0, 0, 250, 251, 252, 253, 0, 0, 254, 255, 256, 0, 0, 0, 0, 257, 0, - 258, 0, 0, 0, 0, 0, 259, 0, 0, 0, 0, 260, 261, 262, 0, 0, 0, 0, 263, 0, - 264, 265, 0, 0, 0, 0, 0, 0, 266, 0, 0, 0, 0, 0, 0, 267, 0, 0, 268, 269, - 270, 271, 0, 0, 272, 0, 273, 0, 0, 0, 0, 274, 0, 275, 276, 277, 0, 0, - 278, 279, 0, 280, 0, 0, 281, 0, 282, 0, 0, 0, 0, 0, 0, 283, 0, 0, 0, 284, - 285, 286, 0, 287, 0, 0, 288, 0, 289, 0, 290, 0, 0, 291, 0, 0, 292, 0, 0, - 293, 0, 0, 0, 294, 0, 0, 0, 0, 0, 0, 295, 0, 0, 296, 0, 0, 0, 0, 0, 0, - 297, 0, 0, 0, 0, 0, 298, 299, 0, 0, 0, 0, 0, 300, 0, 0, 0, 0, 0, 301, - 302, 0, 0, 0, 0, 0, 303, 304, 0, 0, 0, 0, 0, 305, 0, 0, 0, 0, 0, 306, - 307, 0, 0, 0, 0, 0, 308, 0, 0, 0, 0, 0, 0, 309, 0, 0, 0, 0, 0, 310, 311, - 0, 0, 0, 0, 0, 312, 0, 0, 0, 0, 0, 0, 313, 0, 0, 0, 0, 0, 0, 314, 0, 0, - 0, 0, 0, 315, 0, 0, 0, 0, 0, 316, 0, 0, 0, 0, 0, 0, 317, 0, 0, 0, 0, 0, - 0, 318, 0, 0, 0, 0, 0, 0, 319, 0, 0, 0, 0, 320, 321, 0, 0, 0, 0, 0, 322, - 0, 0, 0, 0, 0, 0, 0, 323, 0, 0, 0, 0, 0, 324, 325, 0, 0, 0, 0, 0, 326, 0, - 0, 0, 0, 0, 327, 0, 0, 0, 0, 0, 0, 328, 0, 0, 0, 0, 0, 0, 329, 0, 0, 0, - 0, 0, 0, 330, 0, 0, 0, 0, 0, 0, 331, 0, 0, 0, 0, 0, 332, 0, 0, 0, 0, 0, - 333, 0, 0, 0, 0, 0, 0, 334, 0, 0, 0, 0, 0, 335, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 336, 0, 0, 0, 0, 0, 0, 337, 0, 0, 0, 0, 0, 338, 0, 0, 0, 0, 0, 0, 339, - 0, 0, 0, 0, 0, 0, 340, 0, 0, 0, 0, 0, 341, 0, 0, 0, 0, 0, 0, 342, 0, 0, - 0, 0, 0, 0, 343, 0, 0, 0, 0, 0, 344, 0, 0, 0, 0, 0, 0, 345, 0, 0, 0, 0, - 0, 0, 346, 0, 0, 0, 0, 0, 0, 347, 0, 0, 0, 0, 0, 0, 348, 0, 0, 0, 0, 0, - 349, 0, 0, 0, 0, 0, 0, 350, 0, 0, 0, 0, 0, 0, 351, 0, 0, 0, 0, 0, 352, - 353, 0, 0, 0, 0, 0, 354, 0, 0, 0, 0, 0, 0, 355, 0, 0, 0, 0, 0, 0, 356, 0, - 0, 0, 0, 0, 0, 357, 0, 0, 0, 0, 0, 358, 0, 0, 0, 0, 0, 0, 359, 360, 0, 0, - 0, 0, 0, 0, 361, 0, 0, 0, 0, 0, 362, 0, 0, 0, 0, 0, 0, 363, 0, 0, 0, 0, - 0, 0, 364, 0, 0, 0, 0, 0, 365, 0, 0, 0, 0, 0, 0, 366, 0, 0, 0, 0, 0, 367, - 368, 0, 0, 0, 0, 0, 369, 0, 0, 0, 0, 0, 370, 0, 0, 0, 0, 0, 0, 371, 0, 0, - 0, 0, 0, 0, 372, 0, 0, 0, 0, 0, 373, 0, 0, 0, 374, 0, 0, 375, 0, 0, 376, - 0, 0, 0, 0, 0, 0, 377, 0, 0, 0, 0, 0, 0, 378, 0, 0, 0, 0, 0, 379, 0, 0, - 0, 0, 0, 0, 380, 0, 0, 0, 0, 0, 381, 0, 0, 0, 0, 0, 0, 382, 0, 0, 383, 0, - 0, 0, 384, 0, 0, 385, 0, 0, 386, 0, 0, 0, 0, 0, 0, 387, 0, 0, 0, 0, 0, 0, - 388, 0, 0, 0, 0, 0, 389, 0, 0, 0, 0, 0, 0, 390, 0, 0, 0, 0, 0, 391, 0, 0, - 0, 0, 0, 0, 392, 0, 0, 393, 0, 0, 0, 0, 0, 0, 394, 0, 0, 0, 0, 0, 395, 0, - 0, 0, 0, 0, 0, 396, 0, 0, 0, 0, 0, 0, 397, 0, 0, 398, 0, 0, 399, 0, 0, 0, - 400, 0, 0, 0, 0, 0, 401, 0, 0, 0, 0, 0, 0, 402, 0, 0, 0, 0, 0, 0, 403, 0, - 0, 0, 0, 0, 404, 0, 0, 0, 0, 0, 0, 405, 0, 0, 0, 0, 0, 0, 406, 0, 0, 407, - 0, 0, 408, 0, 0, 409, 0, 0, 0, 410, 0, 0, 0, 0, 0, 411, 0, 0, 0, 0, 0, 0, - 412, 0, 0, 0, 0, 0, 0, 413, 0, 0, 0, 0, 0, 414, 0, 0, 0, 0, 0, 0, 415, 0, - 0, 0, 0, 0, 0, 416, 0, 0, 417, 0, 0, 418, 0, 0, 419, 0, 0, 0, 420, 0, 0, - 421, 0, 0, 422, 0, 0, 423, 424, 0, 0, 425, 0, 0, 426, 0, 0, 0, 0, 0, 0, - 427, 0, 0, 0, 0, 0, 428, 0, 0, 0, 0, 0, 0, 429, 0, 0, 0, 0, 0, 0, 430, 0, - 0, 431, 0, 0, 432, 0, 0, 0, 433, 0, 0, 434, 0, 0, 435, 0, 0, 436, 437, 0, - 0, 438, 0, 0, 439, 0, 0, 0, 440, 0, 0, 0, 0, 0, 441, 0, 0, 0, 0, 0, 0, - 442, 0, 0, 0, 0, 0, 0, 443, 0, 0, 0, 0, 0, 444, 0, 0, 0, 0, 0, 0, 445, 0, - 0, 0, 0, 0, 446, 0, 0, 447, 448, 0, 0, 449, 0, 0, 450, 0, 0, 0, 451, 0, - 0, 0, 0, 0, 452, 0, 0, 0, 0, 0, 0, 453, 0, 0, 0, 0, 0, 0, 454, 0, 0, 0, - 0, 0, 455, 0, 0, 0, 0, 0, 0, 456, 0, 0, 0, 0, 0, 457, 0, 0, 0, 0, 0, 0, - 458, 0, 0, 0, 0, 0, 0, 459, 0, 0, 0, 0, 0, 460, 0, 0, 0, 0, 0, 0, 461, 0, - 0, 462, 0, 0, 463, 0, 0, 0, 0, 0, 0, 464, 0, 0, 0, 0, 0, 0, 465, 0, 0, - 466, 0, 0, 467, 0, 0, 0, 0, 0, 0, 468, 0, 0, 0, 0, 0, 469, 0, 0, 0, 0, 0, - 0, 470, 0, 0, 0, 0, 0, 0, 471, 0, 0, 0, 0, 0, 472, 0, 0, 0, 0, 0, 0, 473, - 0, 0, 0, 0, 0, 0, 474, 0, 0, 0, 0, 0, 475, 0, 0, 0, 0, 0, 0, 476, 0, 0, - 0, 0, 0, 477, 0, 0, 0, 0, 0, 0, 478, 0, 0, 0, 0, 0, 0, 479, 0, 0, 0, 0, - 0, 480, 0, 0, 0, 0, 0, 0, 481, 0, 0, 0, 0, 0, 0, 482, 0, 0, 0, 0, 0, 483, - 0, 0, 0, 0, 0, 0, 484, 0, 0, 0, 0, 0, 485, 0, 0, 0, 0, 0, 0, 486, 0, 0, - 0, 0, 0, 0, 487, 0, 0, 0, 0, 0, 488, 0, 0, 0, 0, 0, 0, 489, 0, 0, 0, 0, - 0, 0, 490, 0, 0, 0, 0, 0, 491, 0, 0, 0, 0, 0, 0, 492, 0, 0, 0, 0, 0, 493, - 0, 0, 0, 0, 0, 0, 494, 0, 0, 0, 0, 0, 0, 495, 0, 0, 0, 0, 0, 496, 0, 0, - 0, 0, 0, 0, 497, 0, 0, 0, 0, 0, 0, 498, 0, 0, 0, 0, 0, 499, 0, 0, 0, 0, - 0, 0, 500, 0, 0, 0, 0, 0, 501, 0, 0, 0, 0, 0, 0, 502, 0, 0, 0, 0, 0, 0, - 503, 0, 0, 0, 0, 0, 504, 0, 0, 0, 0, 0, 0, 505, 0, 0, 0, 0, 0, 0, 506, 0, - 0, 0, 0, 0, 507, 0, 0, 0, 0, 0, 0, 508, 0, 0, 0, 0, 0, 0, 0, 0, 509, 0, - 0, 0, 0, 0, 0, 510, 0, 0, 0, 0, 0, 0, 511, 0, 0, 0, 0, 0, 512, 0, 0, 0, - 0, 0, 0, 513, 0, 0, 0, 0, 0, 0, 514, 0, 0, 0, 0, 0, 515, 0, 0, 0, 0, 0, - 0, 516, 0, 0, 0, 0, 0, 517, 0, 0, 0, 0, 0, 0, 518, 0, 0, 0, 0, 0, 0, 519, - 0, 0, 0, 0, 0, 520, 0, 0, 0, 0, 0, 0, 521, 0, 0, 0, 0, 0, 0, 522, 0, 0, - 0, 0, 0, 523, 0, 0, 0, 0, 0, 0, 524, 0, 0, 0, 0, 0, 525, 526, 0, 0, 0, 0, - 0, 527, 0, 0, 0, 0, 0, 0, 528, 0, 0, 0, 0, 0, 529, 0, 0, 0, 0, 0, 0, 530, - 0, 0, 0, 0, 0, 0, 531, 0, 0, 0, 0, 0, 532, 0, 0, 0, 0, 0, 0, 533, 0, 0, - 0, 0, 0, 534, 0, 0, 0, 0, 0, 0, 535, 0, 0, 0, 0, 0, 0, 536, 0, 0, 0, 0, - 0, 537, 0, 0, 0, 0, 0, 0, 538, 0, 0, 0, 0, 0, 0, 539, 0, 0, 0, 0, 0, 540, - 0, 0, 0, 0, 0, 0, 541, 0, 0, 0, 0, 0, 542, 0, 0, 0, 0, 0, 0, 543, 0, 0, - 0, 0, 0, 0, 544, 0, 0, 0, 0, 0, 545, 0, 0, 0, 0, 0, 0, 546, 0, 0, 0, 0, - 0, 0, 547, 0, 0, 0, 0, 0, 548, 0, 0, 0, 0, 0, 0, 549, 0, 0, 0, 0, 0, 550, - 551, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 553, 0, 0, 0, 0, 0, 554, 0, 0, - 0, 0, 0, 0, 555, 0, 0, 0, 0, 0, 0, 556, 0, 0, 0, 0, 0, 557, 0, 0, 0, 0, - 0, 0, 558, -}; - -static unsigned short comp_data[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8814, 0, 0, 0, 0, 8800, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 8815, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 193, 194, 195, - 256, 258, 550, 196, 7842, 197, 0, 461, 512, 514, 0, 0, 0, 7840, 0, 7680, - 0, 0, 260, 0, 0, 0, 0, 7682, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7684, 0, 0, 0, - 0, 0, 0, 0, 0, 7686, 0, 0, 0, 262, 264, 0, 0, 0, 266, 0, 0, 0, 0, 268, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 199, 0, 0, 0, 0, 0, 7690, 0, 0, 0, 0, 270, 0, 0, - 0, 0, 0, 7692, 0, 0, 0, 7696, 0, 7698, 0, 0, 7694, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 200, 201, 202, 7868, 274, 276, 278, 203, 7866, 0, 0, 282, 516, - 518, 0, 0, 0, 7864, 0, 0, 0, 552, 280, 7704, 0, 7706, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 7710, 0, 0, 0, 0, 0, 0, 0, 500, 284, 0, 7712, 286, 288, 0, 0, 0, - 0, 486, 0, 0, 0, 0, 0, 0, 0, 0, 0, 290, 0, 0, 0, 0, 0, 0, 0, 0, 0, 292, - 0, 0, 0, 7714, 7718, 0, 0, 0, 542, 0, 0, 0, 0, 0, 7716, 0, 0, 0, 7720, 0, - 0, 7722, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 204, 205, 206, 296, 298, - 300, 304, 207, 7880, 0, 0, 463, 520, 522, 0, 0, 0, 7882, 0, 0, 0, 0, 302, - 0, 0, 7724, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 308, 0, 0, 0, 7728, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 488, 0, 0, 0, 0, 0, 7730, 0, 0, 0, 310, 0, 0, 0, - 0, 7732, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 313, 0, 317, 0, 0, 0, 0, 0, - 7734, 0, 0, 0, 315, 0, 7740, 0, 0, 7738, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 7742, 0, 0, 0, 0, 7744, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7746, 0, 0, 0, 504, - 323, 0, 209, 0, 0, 7748, 0, 0, 0, 0, 327, 0, 0, 0, 0, 0, 7750, 0, 0, 0, - 325, 0, 7754, 0, 0, 7752, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 210, 211, 212, - 213, 332, 334, 558, 214, 7886, 0, 336, 465, 524, 526, 0, 0, 416, 7884, 0, - 0, 0, 0, 490, 0, 0, 0, 0, 0, 0, 0, 7764, 0, 0, 0, 0, 7766, 0, 0, 0, 0, 0, - 0, 0, 340, 0, 0, 0, 0, 7768, 0, 0, 0, 0, 344, 528, 530, 0, 0, 0, 7770, 0, - 0, 0, 342, 0, 0, 0, 0, 7774, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 346, 348, - 0, 0, 0, 7776, 0, 0, 0, 0, 352, 0, 0, 0, 0, 0, 7778, 0, 0, 536, 350, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7786, 0, 0, 0, 0, 356, 0, 0, 0, 0, 0, - 7788, 0, 0, 538, 354, 0, 7792, 0, 0, 7790, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 217, 218, 219, 360, 362, 364, 0, 220, 7910, 366, 368, 467, 532, 534, 0, - 0, 431, 7908, 7794, 0, 0, 0, 370, 7798, 0, 7796, 0, 0, 0, 0, 0, 0, 7804, - 0, 0, 0, 0, 0, 7806, 0, 0, 0, 7808, 7810, 372, 0, 0, 0, 7814, 7812, 0, - 7816, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7818, 7820, 0, 0, 0, 0, 0, 7922, 221, - 374, 7928, 562, 0, 7822, 376, 7926, 0, 0, 0, 0, 0, 0, 0, 0, 7924, 0, 0, - 0, 0, 377, 7824, 0, 0, 0, 379, 0, 0, 0, 0, 381, 0, 0, 0, 0, 0, 7826, 0, - 0, 0, 0, 0, 0, 0, 0, 7828, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 225, 226, - 227, 257, 259, 551, 228, 7843, 229, 0, 462, 513, 515, 0, 0, 0, 7841, 0, - 7681, 0, 0, 261, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7683, 0, 0, 7685, 0, - 0, 0, 0, 0, 0, 0, 0, 7687, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 263, 265, 0, - 0, 0, 267, 0, 0, 0, 0, 269, 0, 0, 0, 0, 0, 0, 0, 0, 0, 231, 0, 0, 0, 0, - 0, 7691, 0, 0, 0, 0, 271, 0, 0, 0, 0, 0, 7693, 0, 0, 0, 7697, 0, 7699, 0, - 0, 7695, 0, 0, 232, 233, 234, 7869, 275, 277, 279, 235, 7867, 0, 0, 283, - 517, 519, 0, 0, 0, 7865, 0, 0, 0, 553, 281, 7705, 0, 7707, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7711, 0, 0, 0, 0, 0, 0, 0, 501, 285, 0, 7713, 287, 289, 0, 0, - 0, 0, 487, 0, 0, 0, 0, 0, 0, 0, 0, 0, 291, 0, 293, 0, 0, 0, 7715, 7719, - 0, 0, 0, 543, 0, 0, 0, 0, 0, 7717, 0, 0, 0, 7721, 0, 0, 7723, 0, 7830, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 236, 237, 238, 297, 299, 301, 0, 239, 7881, 0, - 0, 464, 521, 523, 0, 0, 0, 7883, 0, 0, 0, 0, 303, 0, 0, 7725, 0, 0, 0, 0, - 0, 309, 0, 0, 0, 0, 0, 0, 0, 0, 496, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7729, - 0, 489, 0, 0, 0, 0, 0, 7731, 0, 0, 0, 311, 0, 0, 0, 0, 7733, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 314, 0, 0, 0, 0, 0, 0, 0, 0, 0, 318, 0, 0, 0, 0, 0, - 7735, 0, 0, 0, 316, 0, 7741, 0, 0, 7739, 0, 0, 0, 7743, 0, 0, 0, 0, 7745, - 0, 0, 7747, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 505, 324, 0, 241, 0, 0, - 7749, 0, 0, 0, 0, 328, 0, 0, 0, 0, 0, 7751, 0, 0, 0, 326, 0, 7755, 0, 0, - 7753, 0, 0, 242, 243, 244, 245, 333, 335, 559, 246, 7887, 0, 337, 466, - 525, 527, 0, 0, 417, 7885, 0, 0, 0, 0, 491, 0, 0, 0, 0, 0, 0, 0, 7765, 0, - 0, 0, 0, 7767, 0, 0, 0, 0, 0, 0, 0, 341, 0, 0, 0, 0, 7769, 0, 0, 0, 0, - 345, 529, 531, 0, 0, 0, 7771, 0, 0, 0, 343, 0, 0, 0, 0, 7775, 0, 0, 0, - 347, 349, 0, 0, 0, 7777, 0, 0, 0, 0, 353, 0, 0, 0, 0, 0, 7779, 0, 0, 537, - 351, 0, 0, 0, 0, 0, 7787, 7831, 0, 0, 0, 357, 0, 0, 0, 0, 0, 7789, 0, 0, - 539, 355, 0, 7793, 0, 0, 7791, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 249, 250, - 251, 361, 363, 365, 0, 252, 7911, 367, 369, 468, 533, 535, 0, 0, 432, - 7909, 7795, 0, 0, 0, 371, 7799, 0, 7797, 0, 0, 0, 0, 0, 0, 7805, 0, 0, 0, - 0, 0, 7807, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7809, 7811, 373, 0, 0, 0, - 7815, 7813, 0, 7832, 0, 0, 0, 0, 0, 0, 0, 7817, 0, 7819, 7821, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7923, 253, 375, 7929, 563, 0, 7823, 255, - 7927, 7833, 0, 0, 0, 0, 0, 0, 0, 7925, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 378, 7825, 0, 0, 0, 380, 0, 0, 0, 0, 382, 0, 0, 0, 0, 0, 7827, 0, 0, - 0, 0, 0, 0, 0, 0, 7829, 0, 0, 8173, 901, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8129, 0, 0, 0, 0, 0, 0, 0, 0, 7846, 7844, 0, 7850, 0, 0, 0, 0, 7848, 0, - 0, 0, 0, 0, 0, 0, 0, 478, 0, 506, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 508, 0, 0, 482, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7688, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 7872, 7870, 0, 7876, 0, 0, 0, 0, 7874, 0, 0, 0, 0, 0, 7726, 0, - 0, 0, 7890, 7888, 0, 7894, 0, 0, 0, 0, 7892, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7756, 0, 0, 556, 0, 0, 7758, 0, 0, 0, 0, 0, 0, 0, 0, 0, 554, - 0, 510, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 475, 471, 0, 0, 469, 0, 0, 0, 0, - 0, 0, 473, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7847, 7845, 0, 7851, 0, 0, 0, 0, - 7849, 0, 0, 0, 0, 0, 0, 0, 0, 479, 0, 0, 0, 0, 0, 0, 0, 0, 0, 507, 0, 0, - 0, 0, 509, 0, 0, 483, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7689, 0, 0, 0, 7873, - 7871, 0, 7877, 0, 0, 0, 0, 7875, 0, 0, 0, 0, 0, 7727, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 7891, 7889, 0, 7895, 0, 0, 0, 0, 7893, 0, 0, 0, 0, 0, - 7757, 0, 0, 557, 0, 0, 7759, 0, 0, 0, 0, 0, 0, 0, 0, 0, 555, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 511, 0, 0, 0, 476, 472, 0, 0, 470, 0, 0, 0, 0, 0, 0, 474, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 7856, 7854, 0, 7860, 0, 0, 0, 0, 7858, 0, 0, - 0, 0, 7857, 7855, 0, 7861, 0, 0, 0, 0, 7859, 0, 0, 0, 0, 7700, 7702, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7701, 7703, 0, 0, 0, 7760, 7762, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7761, 7763, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7780, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7781, 0, 0, 0, 0, 7782, 0, 0, 0, 0, - 7783, 0, 0, 0, 0, 0, 0, 0, 7800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 7801, 0, 0, 7802, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7803, 0, 0, 0, - 7835, 0, 0, 0, 0, 0, 0, 7900, 7898, 0, 7904, 0, 0, 0, 0, 7902, 0, 0, 0, - 0, 0, 0, 0, 0, 7906, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7901, 7899, 0, - 7905, 0, 0, 0, 0, 7903, 0, 0, 0, 0, 0, 0, 0, 0, 7907, 0, 0, 0, 7914, - 7912, 0, 7918, 0, 0, 0, 0, 7916, 0, 0, 0, 0, 0, 0, 0, 0, 7920, 0, 0, 0, - 7915, 7913, 0, 7919, 0, 0, 0, 0, 7917, 0, 0, 0, 0, 0, 0, 0, 0, 7921, 0, - 0, 0, 0, 0, 0, 494, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 492, 0, 0, 0, - 0, 493, 0, 0, 0, 0, 480, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 481, 0, 0, - 0, 0, 0, 7708, 0, 0, 0, 0, 7709, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 560, 0, - 0, 0, 0, 561, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 495, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 8122, 902, 0, 0, 8121, 8120, 0, 0, 0, 0, 0, 0, 0, 0, 7944, 7945, 0, - 0, 0, 0, 0, 8124, 0, 0, 0, 0, 0, 0, 0, 8136, 904, 0, 0, 0, 0, 7960, 7961, - 0, 0, 0, 0, 0, 8138, 905, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7976, 7977, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8140, 0, 0, 0, 0, 0, 0, 0, 8154, - 906, 0, 0, 8153, 8152, 0, 938, 0, 0, 0, 0, 0, 0, 7992, 7993, 0, 0, 0, 0, - 0, 8184, 908, 0, 0, 0, 0, 8008, 8009, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8172, 0, 0, 0, 0, 0, 8170, 910, 0, 0, 8169, 8168, 0, 939, 0, 0, 0, 0, 0, - 0, 0, 8025, 0, 0, 0, 0, 0, 8186, 911, 0, 0, 0, 0, 8040, 8041, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 8188, 0, 0, 0, 0, 8116, 0, 0, 0, 0, 8132, 0, - 0, 0, 0, 0, 0, 0, 8048, 940, 0, 0, 8113, 8112, 0, 0, 0, 0, 0, 0, 0, 0, - 7936, 7937, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8118, 8115, 0, 0, 0, 0, - 0, 0, 0, 8050, 941, 0, 0, 0, 0, 7952, 7953, 0, 0, 0, 0, 0, 8052, 942, 0, - 0, 0, 0, 7968, 7969, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8134, 8131, 0, - 0, 0, 0, 0, 0, 0, 8054, 943, 0, 0, 8145, 8144, 0, 970, 0, 0, 0, 0, 0, 0, - 7984, 7985, 0, 0, 0, 0, 8150, 0, 0, 0, 0, 0, 0, 0, 0, 8056, 972, 0, 0, 0, - 0, 8000, 8001, 0, 0, 0, 8164, 8165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 8058, 973, 0, 0, 8161, 8160, 0, 971, 0, 0, 0, 0, 0, 0, 8016, 8017, 0, - 0, 0, 0, 8166, 0, 0, 0, 0, 0, 0, 0, 0, 8060, 974, 0, 0, 0, 0, 8032, 8033, - 0, 0, 0, 0, 8182, 8179, 0, 0, 0, 0, 0, 0, 0, 8146, 912, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 8151, 0, 0, 0, 0, 0, 0, 0, 0, 8162, 944, 0, 0, 8167, 0, 0, 0, - 0, 0, 8180, 0, 0, 0, 0, 0, 0, 0, 0, 979, 0, 0, 0, 0, 0, 980, 0, 0, 0, 0, - 1031, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1232, 0, 1234, 0, 0, 0, 0, 0, 0, - 1027, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1024, 0, 0, 0, 0, 1238, 0, 1025, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1217, 0, 1244, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1246, 0, 0, 0, 0, 0, 1037, 0, 0, 0, 1250, 1049, 0, 1252, 0, 0, - 0, 0, 0, 0, 1036, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1254, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1262, 1038, 0, 1264, 0, 0, 1266, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1268, 0, 0, 0, 0, 1272, 0, 0, 0, 0, 1260, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1233, 0, 1235, 0, 0, 0, 0, 0, 0, 1107, 0, 0, 0, 1104, 0, 0, 0, 0, 1239, - 0, 1105, 0, 0, 1218, 0, 1245, 0, 0, 0, 0, 1247, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1117, 0, 0, 0, 1251, 1081, 0, 1253, 0, 0, 0, 0, 0, 0, - 1116, 0, 0, 1255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1263, 1118, 0, 1265, 0, 0, - 1267, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1269, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1273, 0, 0, 0, 0, 1261, 0, 0, 0, 0, 1111, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1142, 0, 0, 0, 0, 1143, 0, 0, 0, 0, 0, 0, 0, 1242, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1243, 0, 0, 0, 0, 1258, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1259, 0, 0, 0, 1570, 1571, 1573, 0, 0, 0, 1572, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1574, 0, 0, 0, 0, 1730, 0, 0, 0, 0, 1747, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1728, 0, 0, 0, 0, 0, 0, 2345, 0, 0, 0, 0, 2353, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2356, 0, 0, 0, 0, 0, 2507, 2508, 0, 0, - 0, 0, 0, 2891, 2888, 2892, 0, 0, 0, 0, 0, 0, 2964, 0, 0, 0, 3018, 3020, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3019, 0, 0, 0, 0, 0, 0, 3144, 0, 0, 0, - 0, 0, 0, 3264, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3274, 3271, 3272, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 3275, 0, 0, 0, 0, 0, 0, 3402, 3404, 0, 0, 0, - 3403, 0, 0, 0, 0, 0, 0, 3546, 3548, 3550, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 3549, 0, 0, 0, 0, 0, 0, 0, 4134, 0, 0, 0, 0, 0, 0, 7736, 0, 0, 0, 0, - 7737, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7772, 0, 0, 0, 0, 7773, 0, 0, - 0, 0, 0, 0, 7784, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7785, 7852, 0, 0, - 7862, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7853, 0, 0, 7863, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 7878, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7879, 0, 0, 0, 0, 7896, - 0, 0, 0, 0, 7897, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7938, 7940, 0, 0, 7942, - 8064, 0, 0, 0, 0, 0, 0, 0, 7939, 7941, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 7943, 8065, 0, 0, 0, 0, 8066, 0, 0, 0, 0, 8067, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 8068, 0, 0, 0, 0, 8069, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8070, 0, 0, 0, 0, 8071, 0, 0, 0, 0, 0, 0, 0, 7946, 7948, 0, 0, 7950, - 8072, 0, 0, 0, 0, 0, 0, 0, 7947, 7949, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 7951, 8073, 0, 0, 0, 0, 8074, 0, 0, 0, 0, 8075, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 8076, 0, 0, 0, 0, 8077, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8078, 0, 0, 0, 0, 8079, 0, 0, 0, 0, 0, 0, 0, 7954, 7956, 0, 0, 0, 7955, - 7957, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7962, 7964, 0, 0, 0, 7963, 7965, - 0, 0, 0, 7970, 7972, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7974, 8080, 0, 0, 0, - 0, 0, 0, 0, 7971, 7973, 0, 0, 7975, 8081, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 8082, 0, 0, 0, 0, 8083, 0, 0, 0, 0, 8084, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 8085, 0, 0, 0, 0, 8086, 0, 0, 0, 0, 8087, 0, 0, 0, 0, 0, 0, - 0, 7978, 7980, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7982, 8088, 0, 0, 0, 0, 0, - 0, 0, 7979, 7981, 0, 0, 7983, 8089, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8090, 0, 0, 0, 0, 8091, 0, 0, 0, 0, 8092, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 8093, 0, 0, 0, 0, 8094, 0, 0, 0, 0, 8095, 0, 0, 0, 0, 0, 0, 0, - 7986, 7988, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7990, 0, 0, 0, 0, 0, 0, 0, 0, - 7987, 7989, 0, 0, 7991, 0, 0, 0, 0, 0, 0, 0, 0, 7994, 7996, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 7998, 0, 0, 0, 0, 0, 0, 0, 0, 7995, 7997, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 7999, 0, 0, 0, 0, 0, 0, 0, 0, 8002, 8004, 0, 0, 0, - 8003, 8005, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8010, 8012, 0, 0, 0, 8011, - 8013, 0, 0, 0, 8018, 8020, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8022, 0, 0, 0, - 0, 0, 0, 0, 0, 8019, 8021, 0, 0, 8023, 0, 0, 0, 0, 0, 0, 0, 0, 8027, - 8029, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8031, 0, 0, 0, 0, 0, 0, 0, 0, 8034, - 8036, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8038, 8096, 0, 0, 0, 0, 0, 0, 0, - 8035, 8037, 0, 0, 8039, 8097, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8098, - 0, 0, 0, 0, 8099, 0, 0, 0, 0, 8100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8101, 0, 0, 0, 0, 8102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8103, 0, 0, - 0, 0, 0, 0, 0, 8042, 8044, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8046, 8104, 0, - 0, 0, 0, 0, 0, 0, 8043, 8045, 0, 0, 8047, 8105, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 8106, 0, 0, 0, 0, 8107, 0, 0, 0, 0, 8108, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 8109, 0, 0, 0, 0, 8110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 8111, 0, 0, 0, 0, 8114, 0, 0, 0, 0, 8130, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 8178, 0, 0, 0, 0, 8119, 0, 0, 0, 0, 0, 0, 0, 8141, 8142, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 8143, 0, 0, 0, 0, 0, 8135, 0, 0, 0, 0, 8183, - 0, 0, 0, 0, 0, 0, 0, 8157, 8158, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8159, 0, - 0, 0, 8602, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8603, 0, 0, 0, 0, 8622, - 0, 0, 0, 0, 8653, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8655, 0, 0, 0, 0, - 8654, 0, 0, 0, 0, 8708, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8713, 0, 0, - 0, 0, 8716, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8740, 0, 0, 0, 0, 8742, - 0, 0, 0, 0, 8769, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8772, 0, 0, 0, 0, - 8775, 0, 0, 0, 0, 8777, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8813, 0, 0, - 0, 0, 8802, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8816, 0, 0, 0, 0, 8817, - 0, 0, 0, 0, 8820, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8821, 0, 0, 0, 0, - 8824, 0, 0, 0, 0, 8825, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8832, 0, 0, - 0, 0, 8833, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8928, 0, 0, 0, 0, 8929, - 0, 0, 0, 0, 8836, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8837, 0, 0, 0, 0, - 8840, 0, 0, 0, 0, 8841, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8930, 0, 0, - 0, 0, 8931, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8876, 0, 0, 0, 0, 8877, - 0, 0, 0, 0, 8878, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8879, 0, 0, 0, 0, - 8938, 0, 0, 0, 0, 8939, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8940, 0, 0, - 0, 0, 8941, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12436, 0, 0, 0, 0, 12364, - 0, 0, 0, 0, 12366, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12368, 0, 0, 0, 0, - 12370, 0, 0, 0, 0, 12372, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12374, 0, - 0, 0, 0, 12376, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12378, 0, 0, 0, 0, - 12380, 0, 0, 0, 0, 12382, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12384, 0, - 0, 0, 0, 12386, 0, 0, 0, 0, 12389, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 12391, 0, 0, 0, 0, 12393, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12400, - 12401, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12403, 12404, 0, 0, 0, 12406, - 12407, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12409, 12410, 0, 0, 0, 12412, - 12413, 0, 0, 0, 12446, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12532, 0, 0, - 0, 0, 12460, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12462, 0, 0, 0, 0, - 12464, 0, 0, 0, 0, 12466, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12468, 0, - 0, 0, 0, 12470, 0, 0, 0, 0, 12472, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 12474, 0, 0, 0, 0, 12476, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12478, 0, - 0, 0, 0, 12480, 0, 0, 0, 0, 12482, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 12485, 0, 0, 0, 0, 12487, 0, 0, 0, 0, 12489, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 12496, 12497, 0, 0, 0, 12499, 12500, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 12502, 12503, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12505, 12506, 0, 0, - 0, 12508, 12509, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12535, 0, 0, 0, 0, - 12536, 0, 0, 0, 0, 12537, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12538, 0, - 0, 0, 0, 12542, 0, -}; - diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/unicodename_db.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/unicodename_db.h deleted file mode 100644 index 1ec6df96..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/unicodename_db.h +++ /dev/null @@ -1,10289 +0,0 @@ -/* this file was generated by Tools/unicode/makeunicodedata.py 2.2 */ - -#define NAME_MAXLEN 256 - -/* lexicon */ -static unsigned char lexicon[] = { - 76, 69, 84, 84, 69, 210, 87, 73, 84, 200, 83, 77, 65, 76, 204, 83, 89, - 76, 76, 65, 66, 76, 197, 67, 65, 80, 73, 84, 65, 204, 89, 201, 67, 74, - 203, 77, 65, 84, 72, 69, 77, 65, 84, 73, 67, 65, 204, 76, 65, 84, 73, - 206, 65, 82, 65, 66, 73, 195, 67, 79, 77, 80, 65, 84, 73, 66, 73, 76, 73, - 84, 217, 70, 79, 82, 77, 128, 83, 89, 77, 66, 79, 204, 67, 65, 78, 65, - 68, 73, 65, 206, 83, 89, 76, 76, 65, 66, 73, 67, 211, 66, 79, 76, 196, - 76, 73, 71, 65, 84, 85, 82, 197, 65, 78, 196, 77, 85, 83, 73, 67, 65, - 204, 72, 65, 78, 71, 85, 204, 73, 84, 65, 76, 73, 195, 82, 65, 68, 73, - 67, 65, 204, 83, 65, 78, 83, 45, 83, 69, 82, 73, 198, 69, 84, 72, 73, 79, - 80, 73, 195, 83, 73, 71, 206, 71, 82, 69, 69, 203, 68, 73, 71, 73, 212, - 67, 73, 82, 67, 76, 69, 196, 70, 73, 78, 65, 204, 83, 81, 85, 65, 82, - 197, 67, 89, 82, 73, 76, 76, 73, 195, 66, 82, 65, 73, 76, 76, 197, 80, - 65, 84, 84, 69, 82, 206, 66, 89, 90, 65, 78, 84, 73, 78, 197, 73, 83, 79, - 76, 65, 84, 69, 196, 76, 69, 70, 212, 82, 73, 71, 72, 212, 86, 79, 87, - 69, 204, 75, 65, 84, 65, 75, 65, 78, 193, 75, 65, 78, 71, 88, 201, 84, - 73, 66, 69, 84, 65, 206, 68, 79, 85, 66, 76, 197, 77, 69, 69, 205, 67, - 65, 82, 82, 73, 69, 210, 66, 69, 76, 79, 87, 128, 73, 78, 73, 84, 73, 65, - 204, 65, 66, 79, 86, 69, 128, 67, 79, 77, 66, 73, 78, 73, 78, 199, 68, - 79, 212, 89, 69, 200, 77, 79, 78, 71, 79, 76, 73, 65, 206, 65, 82, 82, - 79, 87, 128, 65, 66, 79, 86, 197, 70, 79, 210, 86, 69, 82, 84, 73, 67, - 65, 204, 66, 79, 216, 83, 73, 71, 78, 128, 87, 72, 73, 84, 197, 65, 82, - 82, 79, 215, 68, 82, 65, 87, 73, 78, 71, 211, 72, 69, 66, 82, 69, 215, - 72, 65, 76, 70, 87, 73, 68, 84, 200, 82, 73, 71, 72, 84, 87, 65, 82, 68, - 211, 65, 128, 77, 65, 82, 75, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 73, 195, 65, 76, 69, 198, 80, 65, 82, 69, 78, 84, 72, 69, 83, 73, 90, 69, - 196, 73, 128, 83, 67, 82, 73, 80, 212, 68, 69, 86, 65, 78, 65, 71, 65, - 82, 201, 70, 85, 76, 76, 87, 73, 68, 84, 200, 75, 72, 77, 69, 210, 85, - 208, 84, 79, 128, 70, 82, 65, 75, 84, 85, 210, 68, 79, 87, 206, 69, 81, - 85, 65, 204, 72, 65, 200, 72, 69, 65, 86, 217, 78, 85, 77, 66, 69, 210, - 85, 128, 84, 65, 199, 66, 76, 65, 67, 203, 65, 82, 77, 69, 78, 73, 65, - 206, 67, 72, 79, 83, 69, 79, 78, 199, 74, 69, 69, 205, 83, 89, 77, 66, - 79, 76, 128, 66, 69, 78, 71, 65, 76, 201, 67, 72, 65, 82, 65, 67, 84, 69, - 210, 72, 73, 82, 65, 71, 65, 78, 193, 87, 69, 83, 84, 45, 67, 82, 69, - 197, 84, 72, 65, 201, 67, 72, 69, 82, 79, 75, 69, 197, 73, 68, 69, 79, - 71, 82, 65, 80, 200, 77, 69, 68, 73, 65, 204, 74, 79, 78, 71, 83, 69, 79, - 78, 199, 82, 85, 78, 73, 195, 71, 69, 79, 82, 71, 73, 65, 206, 75, 65, - 78, 78, 65, 68, 193, 83, 73, 78, 72, 65, 76, 193, 84, 69, 76, 85, 71, - 213, 79, 82, 73, 89, 193, 71, 85, 74, 65, 82, 65, 84, 201, 77, 65, 76, - 65, 89, 65, 76, 65, 205, 77, 89, 65, 78, 77, 65, 210, 207, 66, 82, 65, - 67, 75, 69, 84, 128, 68, 69, 83, 69, 82, 69, 212, 71, 85, 82, 77, 85, 75, - 72, 201, 84, 87, 79, 128, 65, 67, 85, 84, 69, 128, 76, 73, 71, 72, 212, - 83, 89, 82, 73, 65, 195, 68, 79, 85, 66, 76, 69, 45, 83, 84, 82, 85, 67, - 203, 79, 78, 69, 128, 83, 84, 82, 79, 75, 69, 128, 65, 80, 204, 70, 85, - 78, 67, 84, 73, 79, 78, 65, 204, 72, 65, 77, 90, 193, 76, 69, 70, 84, 87, - 65, 82, 68, 211, 84, 69, 76, 69, 71, 82, 65, 80, 200, 72, 79, 79, 75, - 128, 74, 85, 78, 71, 83, 69, 79, 78, 199, 68, 65, 83, 73, 193, 77, 65, - 75, 83, 85, 82, 193, 76, 65, 207, 66, 65, 82, 194, 66, 79, 80, 79, 77, - 79, 70, 207, 82, 128, 72, 65, 76, 198, 79, 198, 80, 83, 73, 76, 201, 84, - 207, 77, 79, 78, 79, 83, 80, 65, 67, 197, 78, 79, 212, 84, 65, 77, 73, - 204, 66, 65, 82, 128, 75, 72, 65, 200, 72, 79, 82, 73, 90, 79, 78, 84, - 65, 204, 77, 79, 68, 73, 70, 73, 69, 210, 76, 79, 87, 69, 210, 68, 73, - 65, 69, 82, 69, 83, 73, 83, 128, 78, 85, 77, 69, 82, 65, 204, 86, 79, 67, - 65, 76, 73, 195, 84, 72, 82, 69, 69, 128, 72, 65, 82, 80, 79, 79, 206, - 85, 80, 80, 69, 210, 67, 73, 82, 67, 85, 77, 70, 76, 69, 216, 71, 82, 65, - 86, 69, 128, 65, 78, 71, 76, 197, 84, 72, 65, 65, 78, 193, 65, 76, 80, - 72, 193, 70, 79, 85, 82, 128, 72, 128, 76, 79, 78, 199, 77, 65, 67, 82, - 79, 78, 128, 77, 65, 82, 203, 70, 73, 86, 69, 128, 83, 73, 88, 128, 79, - 77, 69, 71, 193, 79, 88, 73, 65, 128, 86, 65, 82, 73, 65, 128, 67, 73, - 82, 67, 76, 197, 69, 73, 71, 72, 84, 128, 78, 79, 79, 206, 78, 73, 78, - 69, 128, 83, 69, 86, 69, 78, 128, 84, 73, 76, 68, 69, 128, 89, 128, 69, - 84, 193, 82, 73, 71, 72, 84, 128, 83, 85, 66, 74, 79, 73, 78, 69, 196, - 86, 128, 68, 128, 72, 69, 200, 83, 84, 79, 80, 128, 84, 69, 200, 67, 65, - 82, 79, 78, 128, 71, 128, 71, 82, 69, 65, 84, 69, 82, 45, 84, 72, 65, - 206, 66, 128, 74, 128, 90, 128, 67, 128, 70, 128, 76, 69, 83, 83, 45, 84, - 72, 65, 206, 83, 72, 79, 82, 212, 75, 65, 128, 81, 128, 85, 80, 87, 65, - 82, 68, 211, 89, 80, 79, 71, 69, 71, 82, 65, 77, 77, 69, 78, 73, 128, 66, - 82, 69, 86, 69, 128, 70, 85, 76, 204, 83, 69, 69, 206, 83, 72, 69, 69, - 206, 89, 65, 128, 76, 73, 78, 197, 82, 79, 77, 65, 206, 84, 82, 73, 65, - 78, 71, 76, 69, 128, 68, 79, 87, 78, 87, 65, 82, 68, 211, 77, 65, 128, - 79, 80, 69, 82, 65, 84, 79, 82, 128, 82, 69, 86, 69, 82, 83, 69, 196, 84, - 87, 207, 66, 82, 65, 67, 75, 69, 212, 68, 79, 84, 128, 73, 79, 84, 193, - 84, 73, 76, 68, 197, 65, 67, 67, 69, 78, 212, 66, 76, 65, 67, 75, 128, - 80, 65, 83, 83, 73, 86, 69, 45, 80, 85, 76, 76, 45, 68, 79, 87, 78, 45, - 79, 85, 84, 80, 85, 212, 66, 89, 69, 76, 79, 82, 85, 83, 83, 73, 65, 78, - 45, 85, 75, 82, 65, 73, 78, 73, 65, 206, 67, 69, 79, 78, 71, 67, 72, 73, - 69, 85, 77, 83, 83, 65, 78, 71, 67, 73, 69, 85, 67, 128, 80, 65, 83, 83, - 73, 86, 69, 45, 80, 85, 76, 76, 45, 85, 80, 45, 79, 85, 84, 80, 85, 212, - 65, 78, 84, 73, 67, 76, 79, 67, 75, 87, 73, 83, 69, 45, 82, 79, 84, 65, - 84, 69, 196, 67, 69, 79, 78, 71, 67, 72, 73, 69, 85, 77, 83, 83, 65, 78, - 71, 83, 73, 79, 83, 128, 80, 83, 73, 70, 73, 83, 84, 79, 80, 65, 82, 65, - 75, 65, 76, 69, 83, 77, 65, 128, 82, 73, 69, 85, 76, 45, 75, 65, 80, 89, - 69, 79, 85, 78, 80, 73, 69, 85, 80, 128, 75, 65, 80, 89, 69, 79, 85, 78, - 83, 83, 65, 78, 71, 80, 73, 69, 85, 80, 128, 79, 80, 69, 78, 45, 67, 73, - 82, 67, 85, 73, 84, 45, 79, 85, 84, 80, 85, 212, 67, 69, 79, 78, 71, 67, - 72, 73, 69, 85, 77, 67, 72, 73, 69, 85, 67, 72, 128, 67, 72, 73, 84, 85, - 69, 85, 77, 83, 83, 65, 78, 71, 67, 73, 69, 85, 67, 128, 75, 73, 89, 69, - 79, 75, 45, 83, 73, 79, 83, 45, 75, 73, 89, 69, 79, 75, 128, 82, 73, 69, - 85, 76, 45, 77, 73, 69, 85, 77, 45, 75, 73, 89, 69, 79, 75, 128, 82, 73, - 69, 85, 76, 45, 84, 73, 75, 69, 85, 84, 45, 72, 73, 69, 85, 72, 128, 84, - 82, 79, 77, 73, 75, 79, 80, 65, 82, 65, 75, 65, 76, 69, 83, 77, 65, 128, - 80, 73, 69, 85, 80, 45, 83, 73, 79, 83, 45, 75, 73, 89, 69, 79, 75, 128, - 80, 73, 69, 85, 80, 45, 83, 73, 79, 83, 45, 84, 73, 75, 69, 85, 84, 128, - 82, 73, 69, 85, 76, 45, 75, 73, 89, 69, 79, 75, 45, 83, 73, 79, 83, 128, - 82, 73, 69, 85, 76, 45, 89, 69, 79, 82, 73, 78, 72, 73, 69, 85, 72, 128, - 67, 72, 73, 84, 85, 69, 85, 77, 83, 83, 65, 78, 71, 83, 73, 79, 83, 128, - 73, 69, 85, 78, 71, 45, 83, 83, 65, 78, 71, 75, 73, 89, 69, 79, 75, 128, - 76, 79, 78, 71, 45, 66, 82, 65, 78, 67, 72, 45, 72, 65, 71, 65, 76, 204, - 80, 65, 82, 84, 73, 65, 76, 76, 89, 45, 82, 69, 67, 89, 67, 76, 69, 196, - 82, 73, 69, 85, 76, 45, 80, 73, 69, 85, 80, 45, 72, 73, 69, 85, 72, 128, - 83, 72, 79, 82, 84, 45, 84, 87, 73, 71, 45, 66, 74, 65, 82, 75, 65, 206, - 83, 73, 79, 83, 45, 80, 73, 69, 85, 80, 45, 75, 73, 89, 69, 79, 75, 128, - 75, 65, 84, 65, 75, 65, 78, 65, 45, 72, 73, 82, 65, 71, 65, 78, 193, 82, - 73, 69, 85, 76, 45, 80, 73, 69, 85, 80, 45, 83, 73, 79, 83, 128, 89, 69, - 83, 73, 69, 85, 78, 71, 45, 80, 65, 78, 83, 73, 79, 83, 128, 67, 69, 79, - 78, 71, 67, 72, 73, 69, 85, 77, 67, 73, 69, 85, 67, 128, 77, 65, 82, 67, - 65, 84, 79, 45, 83, 84, 65, 67, 67, 65, 84, 79, 128, 80, 73, 69, 85, 80, - 45, 83, 73, 79, 83, 45, 67, 73, 69, 85, 67, 128, 80, 73, 69, 85, 80, 45, - 83, 73, 79, 83, 45, 80, 73, 69, 85, 80, 128, 82, 73, 69, 85, 76, 45, 77, - 73, 69, 85, 77, 45, 83, 73, 79, 83, 128, 83, 72, 79, 82, 84, 45, 84, 87, - 73, 71, 45, 72, 65, 71, 65, 76, 204, 83, 79, 70, 84, 87, 65, 82, 69, 45, - 70, 85, 78, 67, 84, 73, 79, 206, 84, 82, 79, 77, 73, 75, 79, 80, 83, 73, - 70, 73, 83, 84, 79, 78, 128, 75, 65, 80, 89, 69, 79, 85, 78, 80, 72, 73, - 69, 85, 80, 72, 128, 65, 78, 84, 73, 82, 69, 83, 84, 82, 73, 67, 84, 73, - 79, 78, 128, 65, 67, 67, 69, 78, 84, 45, 83, 84, 65, 67, 67, 65, 84, 79, - 128, 65, 78, 84, 73, 75, 69, 78, 79, 75, 89, 76, 73, 83, 77, 65, 128, 67, - 69, 79, 78, 71, 67, 72, 73, 69, 85, 77, 83, 73, 79, 83, 128, 67, 72, 73, - 69, 85, 67, 72, 45, 75, 72, 73, 69, 85, 75, 72, 128, 67, 72, 73, 84, 85, - 69, 85, 77, 67, 72, 73, 69, 85, 67, 72, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 48, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 48, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 48, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 48, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 48, 52, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 48, 53, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 48, 54, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 48, 55, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 48, 56, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 48, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 48, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 48, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 48, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 48, 68, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 48, 69, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 48, 70, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 49, 48, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 49, 49, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 49, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 49, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 49, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 49, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 49, 54, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 49, 55, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 49, 56, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 49, 57, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 49, 65, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 49, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 49, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 49, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 49, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 49, 70, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 50, 48, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 50, 49, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 50, 50, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 50, 51, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 50, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 50, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 50, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 50, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 50, 56, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 50, 57, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 50, 65, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 50, 66, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 50, 67, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 50, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 50, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 50, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 51, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 51, 49, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 51, 50, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 51, 51, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 51, 52, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 51, 53, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 51, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 51, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 51, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 51, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 51, 65, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 51, 66, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 51, 67, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 51, 68, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 51, 69, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 51, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 52, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 52, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 52, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 52, 51, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 52, 52, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 52, 53, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 52, 54, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 52, 55, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 52, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 52, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 52, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 52, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 52, 67, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 52, 68, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 52, 69, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 52, 70, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 53, 48, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 53, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 53, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 53, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 53, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 53, 53, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 53, 54, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 53, 55, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 53, 56, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 53, 57, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 53, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 53, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 53, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 53, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 53, 69, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 53, 70, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 54, 48, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 54, 49, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 54, 50, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 54, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 54, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 54, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 54, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 54, 55, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 54, 56, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 54, 57, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 54, 65, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 54, 66, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 54, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 54, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 54, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 54, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 55, 48, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 55, 49, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 55, 50, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 55, 51, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 55, 52, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 55, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 55, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 55, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 55, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 55, 57, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 55, 65, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 55, 66, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 55, 67, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 55, 68, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 55, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 55, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 56, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 56, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 56, 50, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 56, 51, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 56, 52, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 56, 53, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 56, 54, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 56, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 56, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 56, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 56, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 56, 66, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 56, 67, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 56, 68, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 56, 69, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 56, 70, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 57, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 57, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 57, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 57, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 57, 52, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 57, 53, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 57, 54, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 57, 55, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 57, 56, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 57, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 57, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 57, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 57, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 57, 68, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 57, 69, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 57, 70, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 65, 48, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 65, 49, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 65, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 65, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 65, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 65, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 65, 54, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 65, 55, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 65, 56, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 65, 57, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 65, 65, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 65, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 65, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 65, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 65, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 65, 70, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 66, 48, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 66, 49, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 66, 50, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 66, 51, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 66, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 66, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 66, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 66, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 66, 56, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 66, 57, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 66, 65, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 66, 66, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 66, 67, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 66, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 66, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 66, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 67, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 67, 49, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 67, 50, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 67, 51, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 67, 52, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 67, 53, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 67, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 67, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 67, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 67, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 67, 65, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 67, 66, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 67, 67, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 67, 68, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 67, 69, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 67, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 68, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 68, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 68, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 68, 51, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 68, 52, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 68, 53, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 68, 54, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 68, 55, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 68, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 68, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 68, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 68, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 68, 67, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 68, 68, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 68, 69, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 68, 70, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 69, 48, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 69, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 69, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 69, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 69, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 69, 53, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 69, 54, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 69, 55, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 69, 56, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 69, 57, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 69, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 69, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 69, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 69, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 69, 69, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 69, 70, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 70, 48, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 70, 49, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 70, 50, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 70, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 70, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 70, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 70, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 70, 55, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 70, 56, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 70, 57, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, 70, 65, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 56, 70, 66, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 56, 70, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 56, 70, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 56, 70, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 56, - 70, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 48, 48, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 48, 49, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 48, 50, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 48, 51, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 48, 52, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 48, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 48, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 48, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 48, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 48, 57, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 48, 65, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 48, 66, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 48, 67, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 48, 68, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 48, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 48, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 49, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 49, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 49, 50, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 49, 51, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 49, 52, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 49, 53, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 49, 54, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 49, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 49, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 49, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 49, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 49, 66, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 49, 67, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 49, 68, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 49, 69, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 49, 70, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 50, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 50, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 50, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 50, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 50, 52, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 50, 53, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 50, 54, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 50, 55, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 50, 56, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 50, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 50, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 50, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 50, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 50, 68, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 50, 69, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 50, 70, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 51, 48, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 51, 49, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 51, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 51, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 51, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 51, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 51, 54, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 51, 55, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 51, 56, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 51, 57, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 51, 65, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 51, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 51, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 51, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 51, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 51, 70, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 52, 48, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 52, 49, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 52, 50, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 52, 51, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 52, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 52, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 52, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 52, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 52, 56, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 52, 57, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 52, 65, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 52, 66, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 52, 67, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 52, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 52, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 52, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 53, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 53, 49, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 53, 50, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 53, 51, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 53, 52, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 53, 53, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 53, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 53, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 53, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 53, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 53, 65, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 53, 66, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 53, 67, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 53, 68, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 53, 69, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 53, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 54, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 54, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 54, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 54, 51, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 54, 52, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 54, 53, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 54, 54, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 54, 55, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 54, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 54, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 54, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 54, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 54, 67, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 54, 68, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 54, 69, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 54, 70, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 55, 48, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 55, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 55, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 55, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 55, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 55, 53, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 55, 54, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 55, 55, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 55, 56, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 55, 57, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 55, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 55, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 55, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 55, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 55, 69, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 55, 70, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 56, 48, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 56, 49, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 56, 50, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 56, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 56, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 56, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 56, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 56, 55, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 56, 56, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 56, 57, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 56, 65, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 56, 66, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 56, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 56, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 56, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 56, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 57, 48, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 57, 49, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 57, 50, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 57, 51, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 57, 52, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 57, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 57, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 57, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 57, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 57, 57, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 57, 65, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 57, 66, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 57, 67, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 57, 68, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 57, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 57, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 65, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 65, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 65, 50, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 65, 51, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 65, 52, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 65, 53, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 65, 54, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 65, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 65, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 65, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 65, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 65, 66, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 65, 67, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 65, 68, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 65, 69, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 65, 70, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 66, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 66, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 66, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 66, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 66, 52, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 66, 53, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 66, 54, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 66, 55, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 66, 56, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 66, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 66, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 66, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 66, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 66, 68, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 66, 69, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 66, 70, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 67, 48, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 67, 49, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 67, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 67, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 67, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 67, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 67, 54, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 67, 55, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 67, 56, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 67, 57, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 67, 65, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 67, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 67, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 67, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 67, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 67, 70, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 68, 48, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 68, 49, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 68, 50, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 68, 51, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 68, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 68, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 68, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 68, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 68, 56, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 68, 57, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 68, 65, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 68, 66, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 68, 67, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 68, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 68, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 68, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 69, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 69, 49, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 69, 50, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 69, 51, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 69, 52, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 69, 53, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 69, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 69, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 69, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 69, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 69, 65, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 69, 66, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 69, 67, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 69, 68, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 69, 69, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 69, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 70, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 70, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 70, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 70, 51, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 70, 52, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 70, 53, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 70, 54, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 57, 70, 55, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 57, 70, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 57, 70, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 57, 70, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, - 70, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 70, 67, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 70, 68, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 70, 69, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 57, 70, 70, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 65, 48, 48, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 65, 48, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 65, 48, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 65, 48, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, - 48, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, 48, 53, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, 48, 54, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, 48, 55, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, 48, 56, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 65, 48, 57, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 65, 48, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 65, 48, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 65, 48, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, - 48, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, 48, 69, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, 48, 70, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, 49, 48, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, 49, 49, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 65, 49, 50, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 65, 49, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 65, 49, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, - 70, 65, 49, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, - 49, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, 49, 55, - 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, 49, 56, 128, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, 49, 57, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 50, 70, 65, 49, 65, 128, 73, 68, 69, 79, 71, - 82, 65, 80, 72, 45, 50, 70, 65, 49, 66, 128, 73, 68, 69, 79, 71, 82, 65, - 80, 72, 45, 50, 70, 65, 49, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 50, 70, 65, 49, 68, 128, 74, 65, 76, 76, 65, 74, 65, 76, 65, 76, 79, - 85, 72, 79, 85, 128, 75, 82, 65, 84, 73, 77, 79, 75, 79, 85, 70, 73, 83, - 77, 65, 128, 75, 82, 65, 84, 73, 77, 79, 89, 80, 79, 82, 82, 79, 79, 78, - 128, 76, 79, 78, 71, 45, 66, 82, 65, 78, 67, 72, 45, 77, 65, 68, 210, 77, - 73, 69, 85, 77, 45, 83, 83, 65, 78, 71, 83, 73, 79, 83, 128, 80, 69, 84, - 65, 83, 84, 79, 75, 79, 85, 70, 73, 83, 77, 65, 128, 80, 73, 69, 85, 80, - 45, 83, 83, 65, 78, 71, 83, 73, 79, 83, 128, 80, 83, 73, 70, 73, 83, 84, - 79, 76, 89, 71, 73, 83, 77, 65, 128, 80, 83, 73, 70, 73, 83, 84, 79, 83, - 89, 78, 65, 71, 77, 65, 128, 82, 73, 69, 85, 76, 45, 83, 83, 65, 78, 71, - 83, 73, 79, 83, 128, 84, 69, 65, 82, 68, 82, 79, 80, 45, 83, 72, 65, 78, - 75, 69, 196, 80, 82, 79, 83, 71, 69, 71, 82, 65, 77, 77, 69, 78, 73, 128, - 84, 69, 65, 82, 68, 82, 79, 80, 45, 83, 80, 79, 75, 69, 196, 66, 76, 65, - 67, 75, 45, 70, 69, 65, 84, 72, 69, 82, 69, 196, 84, 82, 73, 65, 78, 71, - 76, 69, 45, 72, 69, 65, 68, 69, 196, 67, 79, 78, 71, 82, 65, 84, 85, 76, - 65, 84, 73, 79, 78, 128, 72, 73, 71, 72, 45, 82, 69, 86, 69, 82, 83, 69, - 68, 45, 185, 65, 70, 79, 82, 69, 77, 69, 78, 84, 73, 79, 78, 69, 68, 128, - 65, 82, 79, 85, 78, 68, 45, 80, 82, 79, 70, 73, 76, 69, 128, 67, 79, 78, - 67, 65, 86, 69, 45, 80, 79, 73, 78, 84, 69, 196, 71, 79, 82, 71, 79, 83, - 89, 78, 84, 72, 69, 84, 79, 78, 128, 73, 68, 69, 78, 84, 73, 70, 73, 67, - 65, 84, 73, 79, 78, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 48, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 48, 49, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 48, 50, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 48, 51, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 48, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 48, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 48, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 48, 55, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 48, 56, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 48, 57, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 48, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 48, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 48, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 48, 68, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 48, 69, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 48, 70, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 49, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 49, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 49, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 49, 51, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 49, 52, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 49, 53, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 49, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 49, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 49, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 49, 57, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 49, 65, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 49, 66, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 49, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 49, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 49, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 49, 70, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 50, 48, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 50, 49, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 50, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 50, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 50, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 50, 53, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 50, 54, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 50, 55, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 50, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 50, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 50, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 50, 66, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 50, 67, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 50, 68, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 50, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 50, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 51, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 51, 49, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 51, 50, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 51, 51, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 51, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 51, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 51, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 51, 55, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 51, 56, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 51, 57, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 51, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 51, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 51, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 51, 68, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 51, 69, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 51, 70, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 52, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 52, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 52, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 52, 51, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 52, 52, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 52, 53, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 52, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 52, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 52, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 52, 57, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 52, 65, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 52, 66, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 52, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 52, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 52, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 52, 70, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 53, 48, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 53, 49, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 53, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 53, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 53, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 53, 53, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 53, 54, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 53, 55, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 53, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 53, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 53, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 53, 66, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 53, 67, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 53, 68, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 53, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 53, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 54, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 54, 49, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 54, 50, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 54, 51, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 54, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 54, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 54, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 54, 55, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 54, 56, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 54, 57, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 54, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 54, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 54, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 54, 68, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 54, 69, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 54, 70, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 55, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 55, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 55, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 55, 51, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 55, 52, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 55, 53, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 55, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 55, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 55, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 55, 57, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 55, 65, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 55, 66, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 55, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 55, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 55, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 55, 70, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 56, 48, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 56, 49, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 56, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 56, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 56, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 56, 53, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 56, 54, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 56, 55, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 56, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 56, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 56, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 56, 66, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 56, 67, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 56, 68, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 56, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 56, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 57, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 57, 49, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 57, 50, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 57, 51, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 57, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 57, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 57, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 57, 55, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 57, 56, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 57, 57, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 57, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 57, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 57, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 57, 68, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 57, 69, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 57, 70, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 65, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 65, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 65, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 65, 51, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 65, 52, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 65, 53, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 65, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 65, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 65, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 65, 57, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 65, 65, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 65, 66, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 65, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 65, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 65, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 65, 70, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 66, 48, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 66, 49, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 66, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 66, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 66, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 66, 53, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 66, 54, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 66, 55, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 66, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 66, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 66, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 66, 66, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 66, 67, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 66, 68, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 66, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 66, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 67, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 67, 49, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 67, 50, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 67, 51, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 67, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 67, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 67, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 67, 55, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 67, 56, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 67, 57, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 67, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 67, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 67, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 67, 68, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 67, 69, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 67, 70, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 68, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 68, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 68, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 68, 51, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 68, 52, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 68, 53, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 68, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 68, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 68, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 68, 57, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 68, 65, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 68, 66, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 68, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 68, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 68, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 68, 70, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 69, 48, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 69, 49, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 69, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 69, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 69, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 69, 53, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 69, 54, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 69, 55, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 69, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 69, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 69, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 69, 66, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 69, 67, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 69, 68, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 69, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 69, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 70, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 70, 49, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 70, 50, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 70, 51, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 70, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 70, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 70, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 70, 55, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 70, 56, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 70, 57, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 57, 70, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 57, 70, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, - 70, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 70, 68, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 57, 70, 69, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 57, 70, 70, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 48, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 48, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 48, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 48, 51, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 48, 52, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 48, 53, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 48, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 48, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 48, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 48, 57, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 48, 65, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 48, 66, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 48, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 48, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 48, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 48, 70, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 49, 48, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 49, 49, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 49, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 49, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 49, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 49, 53, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 49, 54, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 49, 55, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 49, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 49, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 49, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 49, 66, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 49, 67, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 49, 68, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 49, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 49, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 50, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 50, 49, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 50, 50, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 50, 51, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 50, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 50, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 50, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 50, 55, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 50, 56, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 50, 57, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 50, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 50, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 50, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 50, 68, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 51, 48, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 51, 49, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 51, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 51, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 51, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 51, 53, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 51, 54, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 51, 55, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 51, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 51, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 51, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 51, 66, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 51, 67, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 51, 68, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 51, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 51, 70, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 52, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 52, 49, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 52, 50, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 52, 51, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 52, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 52, 53, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 52, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 52, 55, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 52, 56, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 52, 57, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 52, 65, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 52, 66, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 52, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 52, 68, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 52, 69, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 52, 70, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 53, 48, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 53, 49, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 53, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 53, 51, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 53, 52, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 53, 53, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 53, 54, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 53, 55, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 53, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 53, 57, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 53, 65, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 53, 66, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 53, 67, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 53, 68, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 53, 69, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 53, 70, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 54, 48, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 54, 49, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 54, 50, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 54, 51, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 54, 52, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 54, 53, 128, - 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, 54, 54, 128, 73, 68, 69, - 79, 71, 82, 65, 80, 72, 45, 70, 65, 54, 55, 128, 73, 68, 69, 79, 71, 82, - 65, 80, 72, 45, 70, 65, 54, 56, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, - 45, 70, 65, 54, 57, 128, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 70, 65, - 54, 65, 128, 76, 79, 78, 71, 45, 66, 82, 65, 78, 67, 72, 45, 79, 83, 211, - 76, 79, 78, 71, 45, 66, 82, 65, 78, 67, 72, 45, 83, 79, 204, 76, 79, 78, - 71, 45, 66, 82, 65, 78, 67, 72, 45, 89, 82, 128, 77, 85, 76, 84, 73, 80, - 76, 73, 67, 65, 84, 73, 79, 78, 128, 80, 65, 76, 65, 84, 65, 76, 73, 90, - 65, 84, 73, 79, 78, 128, 83, 72, 79, 82, 84, 45, 84, 87, 73, 71, 45, 77, - 65, 68, 210, 83, 72, 79, 82, 84, 45, 84, 87, 73, 71, 45, 78, 65, 85, 196, - 83, 73, 79, 83, 45, 83, 83, 65, 78, 71, 83, 73, 79, 83, 128, 84, 69, 65, - 82, 68, 82, 79, 80, 45, 66, 65, 82, 66, 69, 196, 84, 82, 79, 77, 73, 75, - 79, 76, 89, 71, 73, 83, 77, 65, 128, 84, 82, 79, 77, 73, 75, 79, 83, 89, - 78, 65, 71, 77, 65, 128, 87, 72, 73, 84, 69, 45, 70, 69, 65, 84, 72, 69, - 82, 69, 196, 82, 73, 71, 72, 84, 45, 80, 79, 73, 78, 84, 73, 78, 199, 77, - 85, 76, 84, 73, 80, 76, 73, 67, 65, 84, 73, 79, 206, 82, 73, 71, 72, 84, - 45, 83, 72, 65, 68, 79, 87, 69, 196, 66, 65, 76, 76, 79, 79, 78, 45, 83, - 80, 79, 75, 69, 196, 75, 65, 80, 89, 69, 79, 85, 78, 77, 73, 69, 85, 77, - 128, 82, 73, 69, 85, 76, 45, 80, 72, 73, 69, 85, 80, 72, 128, 82, 73, 69, - 85, 76, 45, 84, 72, 73, 69, 85, 84, 72, 128, 65, 82, 71, 79, 83, 89, 78, - 84, 72, 69, 84, 79, 78, 128, 65, 83, 89, 77, 80, 84, 79, 84, 73, 67, 65, - 76, 76, 217, 77, 73, 69, 85, 77, 45, 80, 65, 78, 83, 73, 79, 83, 128, 78, - 73, 69, 85, 78, 45, 80, 65, 78, 83, 73, 79, 83, 128, 80, 65, 82, 65, 76, - 76, 69, 76, 79, 71, 82, 65, 77, 128, 80, 72, 73, 69, 85, 80, 72, 45, 80, - 73, 69, 85, 80, 128, 80, 73, 69, 85, 80, 45, 80, 72, 73, 69, 85, 80, 72, - 128, 80, 73, 69, 85, 80, 45, 84, 72, 73, 69, 85, 84, 72, 128, 82, 73, 69, - 85, 76, 45, 80, 65, 78, 83, 73, 79, 83, 128, 84, 69, 84, 65, 82, 84, 73, - 77, 79, 82, 73, 79, 78, 128, 84, 73, 75, 69, 85, 84, 45, 75, 73, 89, 69, - 79, 75, 128, 84, 82, 73, 65, 78, 71, 76, 69, 45, 82, 79, 85, 78, 196, 89, - 69, 83, 73, 69, 85, 78, 71, 45, 83, 73, 79, 83, 128, 65, 86, 65, 75, 82, - 65, 72, 65, 83, 65, 78, 89, 65, 128, 66, 79, 84, 84, 79, 77, 45, 76, 73, - 71, 72, 84, 69, 196, 67, 72, 73, 69, 85, 67, 72, 45, 72, 73, 69, 85, 72, - 128, 67, 72, 73, 84, 85, 69, 85, 77, 67, 73, 69, 85, 67, 128, 68, 79, 84, - 83, 45, 49, 50, 51, 52, 53, 54, 55, 56, 128, 73, 69, 85, 78, 71, 45, 67, - 72, 73, 69, 85, 67, 72, 128, 73, 69, 85, 78, 71, 45, 75, 72, 73, 69, 85, - 75, 72, 128, 73, 69, 85, 78, 71, 45, 80, 72, 73, 69, 85, 80, 72, 128, 73, - 69, 85, 78, 71, 45, 84, 72, 73, 69, 85, 84, 72, 128, 75, 65, 80, 89, 69, - 79, 85, 78, 82, 73, 69, 85, 76, 128, 76, 79, 78, 71, 45, 66, 82, 65, 78, - 67, 72, 45, 65, 210, 77, 73, 69, 85, 77, 45, 67, 72, 73, 69, 85, 67, 72, - 128, 78, 73, 69, 85, 78, 45, 84, 72, 73, 69, 85, 84, 72, 128, 80, 69, 82, - 80, 69, 78, 68, 73, 67, 85, 76, 65, 82, 128, 80, 73, 69, 85, 80, 45, 67, - 72, 73, 69, 85, 67, 72, 128, 82, 73, 69, 85, 76, 45, 75, 72, 73, 69, 85, - 75, 72, 128, 83, 72, 79, 82, 84, 45, 84, 87, 73, 71, 45, 79, 83, 211, 83, - 72, 79, 82, 84, 45, 84, 87, 73, 71, 45, 83, 79, 204, 83, 72, 79, 82, 84, - 45, 84, 87, 73, 71, 45, 84, 89, 210, 83, 72, 79, 82, 84, 45, 84, 87, 73, - 71, 45, 89, 82, 128, 83, 84, 65, 67, 67, 65, 84, 73, 83, 83, 73, 77, 79, - 128, 84, 72, 69, 82, 77, 79, 68, 89, 78, 65, 77, 73, 67, 128, 89, 85, 85, - 75, 65, 76, 69, 65, 80, 73, 78, 84, 85, 128, 71, 82, 69, 65, 84, 69, 82, - 45, 84, 72, 65, 78, 128, 65, 78, 84, 73, 67, 76, 79, 67, 75, 87, 73, 83, - 197, 76, 69, 70, 84, 45, 80, 79, 73, 78, 84, 73, 78, 199, 73, 78, 84, 69, - 82, 83, 69, 67, 84, 73, 79, 78, 128, 65, 80, 80, 82, 79, 88, 73, 77, 65, - 84, 69, 76, 217, 68, 73, 70, 70, 69, 82, 69, 78, 84, 73, 65, 76, 128, 68, - 79, 87, 78, 45, 80, 79, 73, 78, 84, 73, 78, 199, 80, 65, 82, 69, 83, 84, - 73, 71, 77, 69, 78, 79, 206, 72, 89, 80, 72, 69, 78, 45, 77, 73, 78, 85, - 83, 128, 67, 79, 78, 67, 65, 86, 69, 45, 83, 73, 68, 69, 196, 76, 69, 70, - 84, 45, 84, 79, 45, 82, 73, 71, 72, 212, 78, 73, 69, 85, 78, 45, 84, 73, - 75, 69, 85, 84, 128, 82, 73, 69, 85, 76, 45, 75, 73, 89, 69, 79, 75, 128, - 82, 73, 71, 72, 84, 45, 84, 79, 45, 76, 69, 70, 212, 68, 73, 77, 73, 78, - 85, 84, 73, 79, 78, 45, 49, 128, 68, 82, 79, 80, 45, 83, 72, 65, 68, 79, - 87, 69, 196, 71, 65, 69, 84, 84, 65, 45, 80, 73, 76, 76, 65, 128, 71, 69, - 79, 77, 69, 84, 82, 73, 67, 65, 76, 76, 217, 73, 69, 85, 78, 71, 45, 75, - 73, 89, 69, 79, 75, 128, 78, 73, 69, 85, 78, 45, 75, 73, 89, 69, 79, 75, - 128, 80, 73, 69, 85, 80, 45, 84, 73, 75, 69, 85, 84, 128, 82, 73, 69, 85, - 76, 45, 84, 73, 75, 69, 85, 84, 128, 84, 72, 73, 82, 84, 89, 45, 83, 69, - 67, 79, 78, 196, 84, 87, 69, 78, 84, 89, 45, 69, 73, 71, 72, 84, 200, 84, - 87, 69, 78, 84, 89, 45, 84, 72, 82, 69, 69, 128, 65, 78, 65, 84, 82, 73, - 67, 72, 73, 83, 77, 65, 128, 67, 72, 73, 84, 85, 69, 85, 77, 83, 73, 79, - 83, 128, 67, 82, 79, 83, 83, 69, 68, 45, 84, 65, 73, 76, 128, 67, 89, 76, - 73, 78, 68, 82, 73, 67, 73, 84, 89, 128, 68, 73, 77, 73, 78, 85, 84, 73, - 79, 78, 45, 50, 128, 68, 73, 77, 73, 78, 85, 84, 73, 79, 78, 45, 51, 128, - 68, 73, 83, 67, 79, 78, 84, 73, 78, 85, 79, 85, 211, 68, 79, 84, 83, 45, - 49, 50, 51, 52, 53, 54, 55, 128, 68, 79, 84, 83, 45, 49, 50, 51, 52, 53, - 54, 56, 128, 68, 79, 84, 83, 45, 49, 50, 51, 52, 53, 55, 56, 128, 68, 79, - 84, 83, 45, 49, 50, 51, 52, 54, 55, 56, 128, 68, 79, 84, 83, 45, 49, 50, - 51, 53, 54, 55, 56, 128, 68, 79, 84, 83, 45, 49, 50, 52, 53, 54, 55, 56, - 128, 68, 79, 84, 83, 45, 49, 51, 52, 53, 54, 55, 56, 128, 68, 79, 84, 83, - 45, 50, 51, 52, 53, 54, 55, 56, 128, 69, 85, 82, 79, 45, 67, 85, 82, 82, - 69, 78, 67, 217, 71, 82, 79, 78, 84, 72, 73, 83, 77, 65, 84, 65, 128, 73, - 67, 69, 76, 65, 78, 68, 73, 67, 45, 89, 82, 128, 73, 69, 85, 78, 71, 45, - 84, 73, 75, 69, 85, 84, 128, 73, 78, 84, 69, 82, 83, 89, 76, 76, 65, 66, - 73, 195, 74, 85, 68, 69, 79, 45, 83, 80, 65, 78, 73, 83, 200, 75, 73, 89, - 69, 79, 75, 45, 82, 73, 69, 85, 76, 128, 77, 73, 78, 85, 83, 45, 79, 82, - 45, 80, 76, 85, 211, 79, 80, 69, 78, 45, 79, 85, 84, 76, 73, 78, 69, 196, - 80, 69, 82, 80, 69, 78, 68, 73, 67, 85, 76, 65, 210, 82, 85, 76, 69, 45, - 68, 69, 76, 65, 89, 69, 68, 128, 83, 72, 79, 82, 84, 45, 84, 87, 73, 71, - 45, 65, 210, 83, 73, 79, 83, 45, 67, 72, 73, 69, 85, 67, 72, 128, 83, 73, - 79, 83, 45, 75, 72, 73, 69, 85, 75, 72, 128, 83, 73, 79, 83, 45, 80, 72, - 73, 69, 85, 80, 72, 128, 83, 73, 79, 83, 45, 84, 72, 73, 69, 85, 84, 72, - 128, 83, 84, 82, 65, 71, 71, 73, 83, 77, 65, 84, 65, 128, 84, 72, 85, 78, - 68, 69, 82, 83, 84, 79, 82, 77, 128, 84, 73, 75, 69, 85, 84, 45, 82, 73, - 69, 85, 76, 128, 84, 82, 65, 78, 83, 77, 73, 83, 83, 73, 79, 78, 128, 84, - 87, 69, 78, 84, 89, 45, 69, 73, 71, 72, 84, 128, 84, 87, 69, 78, 84, 89, - 45, 83, 69, 86, 69, 78, 128, 80, 69, 82, 73, 83, 80, 79, 77, 69, 78, 73, - 128, 67, 45, 83, 73, 77, 80, 76, 73, 70, 73, 69, 196, 80, 82, 69, 83, 69, - 78, 84, 65, 84, 73, 79, 206, 65, 82, 65, 66, 73, 67, 45, 73, 78, 68, 73, - 195, 80, 65, 82, 69, 78, 84, 72, 69, 83, 73, 83, 128, 73, 78, 84, 69, 82, - 83, 69, 67, 84, 73, 79, 206, 67, 65, 78, 68, 82, 65, 66, 73, 78, 68, 85, - 128, 69, 82, 82, 79, 82, 45, 66, 65, 82, 82, 69, 196, 66, 76, 65, 67, 75, - 45, 76, 69, 84, 84, 69, 210, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, - 128, 65, 80, 80, 82, 79, 88, 73, 77, 65, 84, 69, 128, 67, 65, 78, 84, 73, - 76, 76, 65, 84, 73, 79, 206, 69, 75, 70, 79, 78, 73, 84, 73, 75, 79, 78, - 128, 74, 45, 83, 73, 77, 80, 76, 73, 70, 73, 69, 196, 82, 73, 69, 85, 76, - 45, 72, 73, 69, 85, 72, 128, 83, 79, 85, 84, 72, 45, 83, 76, 65, 86, 69, - 217, 65, 66, 66, 82, 69, 86, 73, 65, 84, 73, 79, 206, 65, 83, 84, 82, 79, - 76, 79, 71, 73, 67, 65, 204, 71, 65, 89, 65, 78, 85, 75, 73, 84, 84, 65, - 128, 77, 73, 69, 85, 77, 45, 80, 73, 69, 85, 80, 128, 78, 73, 69, 85, 78, - 45, 67, 73, 69, 85, 67, 128, 78, 73, 69, 85, 78, 45, 72, 73, 69, 85, 72, - 128, 82, 73, 69, 85, 76, 45, 77, 73, 69, 85, 77, 128, 82, 73, 69, 85, 76, - 45, 80, 73, 69, 85, 80, 128, 83, 69, 77, 73, 67, 73, 82, 67, 85, 76, 65, - 210, 83, 83, 65, 78, 71, 84, 73, 75, 69, 85, 84, 128, 65, 67, 75, 78, 79, - 87, 76, 69, 68, 71, 69, 128, 67, 79, 77, 80, 79, 83, 73, 84, 73, 79, 78, - 128, 73, 78, 84, 69, 82, 83, 69, 67, 84, 73, 78, 199, 80, 73, 69, 85, 80, - 45, 67, 73, 69, 85, 67, 128, 81, 85, 73, 78, 68, 73, 67, 69, 83, 73, 77, - 193, 82, 73, 69, 85, 76, 45, 78, 73, 69, 85, 78, 128, 83, 73, 88, 84, 89, - 45, 70, 79, 85, 82, 84, 200, 84, 82, 73, 84, 73, 77, 79, 82, 73, 79, 78, - 128, 84, 87, 69, 78, 84, 89, 45, 70, 79, 85, 82, 128, 87, 69, 68, 71, 69, - 45, 84, 65, 73, 76, 69, 196, 65, 77, 65, 76, 71, 65, 77, 65, 84, 73, 79, - 206, 65, 80, 80, 76, 73, 67, 65, 84, 73, 79, 78, 128, 65, 85, 71, 77, 69, - 78, 84, 65, 84, 73, 79, 206, 67, 65, 78, 67, 69, 76, 76, 65, 84, 73, 79, - 206, 67, 73, 69, 85, 67, 45, 73, 69, 85, 78, 71, 128, 67, 79, 78, 74, 85, - 78, 67, 84, 73, 79, 78, 128, 67, 79, 78, 84, 82, 65, 67, 84, 73, 79, 78, - 128, 67, 79, 82, 80, 79, 82, 65, 84, 73, 79, 78, 128, 67, 79, 85, 78, 84, - 69, 82, 66, 79, 82, 69, 128, 67, 79, 85, 78, 84, 69, 82, 83, 73, 78, 75, - 128, 68, 69, 67, 82, 69, 83, 67, 69, 78, 68, 79, 128, 68, 69, 78, 79, 77, - 73, 78, 65, 84, 79, 82, 128, 68, 73, 83, 84, 73, 78, 71, 85, 73, 83, 72, - 128, 68, 79, 65, 67, 72, 65, 83, 72, 77, 69, 69, 128, 68, 79, 84, 83, 45, - 49, 50, 51, 52, 53, 54, 128, 68, 79, 84, 83, 45, 49, 50, 51, 52, 53, 55, - 128, 68, 79, 84, 83, 45, 49, 50, 51, 52, 53, 56, 128, 68, 79, 84, 83, 45, - 49, 50, 51, 52, 54, 55, 128, 68, 79, 84, 83, 45, 49, 50, 51, 52, 54, 56, - 128, 68, 79, 84, 83, 45, 49, 50, 51, 52, 55, 56, 128, 68, 79, 84, 83, 45, - 49, 50, 51, 53, 54, 55, 128, 68, 79, 84, 83, 45, 49, 50, 51, 53, 54, 56, - 128, 68, 79, 84, 83, 45, 49, 50, 51, 53, 55, 56, 128, 68, 79, 84, 83, 45, - 49, 50, 51, 54, 55, 56, 128, 68, 79, 84, 83, 45, 49, 50, 52, 53, 54, 55, - 128, 68, 79, 84, 83, 45, 49, 50, 52, 53, 54, 56, 128, 68, 79, 84, 83, 45, - 49, 50, 52, 53, 55, 56, 128, 68, 79, 84, 83, 45, 49, 50, 52, 54, 55, 56, - 128, 68, 79, 84, 83, 45, 49, 50, 53, 54, 55, 56, 128, 68, 79, 84, 83, 45, - 49, 51, 52, 53, 54, 55, 128, 68, 79, 84, 83, 45, 49, 51, 52, 53, 54, 56, - 128, 68, 79, 84, 83, 45, 49, 51, 52, 53, 55, 56, 128, 68, 79, 84, 83, 45, - 49, 51, 52, 54, 55, 56, 128, 68, 79, 84, 83, 45, 49, 51, 53, 54, 55, 56, - 128, 68, 79, 84, 83, 45, 49, 52, 53, 54, 55, 56, 128, 68, 79, 84, 83, 45, - 50, 51, 52, 53, 54, 55, 128, 68, 79, 84, 83, 45, 50, 51, 52, 53, 54, 56, - 128, 68, 79, 84, 83, 45, 50, 51, 52, 53, 55, 56, 128, 68, 79, 84, 83, 45, - 50, 51, 52, 54, 55, 56, 128, 68, 79, 84, 83, 45, 50, 51, 53, 54, 55, 56, - 128, 68, 79, 84, 83, 45, 50, 52, 53, 54, 55, 56, 128, 68, 79, 84, 83, 45, - 51, 52, 53, 54, 55, 56, 128, 68, 79, 85, 66, 76, 69, 45, 69, 78, 68, 69, - 196, 69, 65, 77, 72, 65, 78, 67, 72, 79, 76, 76, 128, 70, 73, 78, 71, 69, - 82, 78, 65, 73, 76, 83, 128, 70, 82, 79, 78, 84, 45, 84, 73, 76, 84, 69, - 196, 72, 65, 85, 80, 84, 83, 84, 73, 77, 77, 69, 128, 72, 73, 69, 85, 72, - 45, 77, 73, 69, 85, 77, 128, 72, 73, 69, 85, 72, 45, 78, 73, 69, 85, 78, - 128, 72, 73, 69, 85, 72, 45, 80, 73, 69, 85, 80, 128, 72, 73, 69, 85, 72, - 45, 82, 73, 69, 85, 76, 128, 73, 69, 85, 78, 71, 45, 67, 73, 69, 85, 67, - 128, 73, 69, 85, 78, 71, 45, 77, 73, 69, 85, 77, 128, 73, 69, 85, 78, 71, - 45, 80, 73, 69, 85, 80, 128, 73, 78, 84, 69, 71, 82, 65, 84, 73, 79, 78, - 128, 73, 78, 84, 69, 82, 67, 65, 76, 65, 84, 69, 128, 73, 78, 84, 69, 82, - 82, 79, 66, 65, 78, 71, 128, 75, 73, 82, 79, 77, 69, 69, 84, 79, 82, 85, - 128, 76, 65, 75, 75, 72, 65, 78, 71, 89, 65, 79, 128, 77, 73, 69, 85, 77, - 45, 72, 73, 69, 85, 72, 128, 77, 73, 69, 85, 77, 45, 82, 73, 69, 85, 76, - 128, 77, 85, 85, 83, 73, 75, 65, 84, 79, 65, 78, 128, 78, 65, 65, 75, 83, - 73, 75, 89, 65, 89, 65, 128, 78, 69, 66, 69, 78, 83, 84, 73, 77, 77, 69, - 128, 78, 73, 69, 85, 78, 45, 80, 73, 69, 85, 80, 128, 78, 79, 78, 45, 66, - 82, 69, 65, 75, 73, 78, 199, 80, 65, 82, 65, 75, 76, 73, 84, 73, 75, 73, - 128, 80, 69, 82, 83, 80, 69, 67, 84, 73, 86, 69, 128, 80, 73, 69, 85, 80, - 45, 78, 73, 69, 85, 78, 128, 80, 73, 69, 85, 80, 45, 82, 73, 69, 85, 76, - 128, 80, 79, 83, 84, 80, 79, 83, 73, 84, 73, 79, 206, 80, 82, 69, 83, 67, - 82, 73, 80, 84, 73, 79, 206, 80, 82, 79, 80, 79, 82, 84, 73, 79, 78, 65, - 204, 82, 73, 71, 72, 84, 45, 83, 72, 65, 68, 69, 196, 82, 73, 78, 70, 79, - 82, 90, 65, 78, 68, 79, 128, 82, 79, 85, 78, 68, 45, 84, 73, 80, 80, 69, - 196, 83, 65, 71, 73, 84, 84, 65, 82, 73, 85, 83, 128, 83, 69, 76, 69, 67, - 84, 79, 82, 45, 49, 48, 128, 83, 69, 76, 69, 67, 84, 79, 82, 45, 49, 49, - 128, 83, 69, 76, 69, 67, 84, 79, 82, 45, 49, 50, 128, 83, 69, 76, 69, 67, - 84, 79, 82, 45, 49, 51, 128, 83, 69, 76, 69, 67, 84, 79, 82, 45, 49, 52, - 128, 83, 69, 76, 69, 67, 84, 79, 82, 45, 49, 53, 128, 83, 69, 76, 69, 67, - 84, 79, 82, 45, 49, 54, 128, 83, 80, 82, 69, 67, 72, 71, 69, 83, 65, 78, - 199, 83, 85, 80, 69, 82, 73, 77, 80, 79, 83, 69, 196, 84, 69, 84, 82, 65, - 70, 79, 78, 73, 65, 83, 128, 84, 72, 65, 78, 84, 72, 65, 75, 72, 65, 84, - 128, 84, 72, 82, 69, 69, 45, 80, 69, 82, 45, 69, 205, 84, 79, 65, 78, 68, - 65, 75, 72, 73, 65, 84, 128, 84, 82, 65, 78, 83, 77, 73, 83, 83, 73, 79, - 206, 84, 87, 69, 78, 84, 89, 45, 70, 73, 86, 69, 128, 84, 87, 69, 78, 84, - 89, 45, 78, 73, 78, 69, 128, 85, 78, 65, 83, 80, 73, 82, 65, 84, 69, 68, - 128, 67, 73, 82, 67, 85, 77, 70, 76, 69, 88, 128, 83, 85, 80, 69, 82, 83, - 67, 82, 73, 80, 212, 72, 79, 82, 73, 90, 79, 78, 84, 65, 76, 128, 73, 78, - 68, 69, 80, 69, 78, 68, 69, 78, 212, 80, 69, 82, 73, 83, 80, 79, 77, 69, - 78, 201, 68, 69, 83, 67, 82, 73, 80, 84, 73, 79, 206, 69, 88, 67, 76, 65, - 77, 65, 84, 73, 79, 206, 80, 65, 82, 69, 78, 84, 72, 69, 83, 73, 211, 68, - 79, 85, 66, 76, 69, 45, 76, 73, 78, 197, 77, 65, 72, 65, 65, 80, 82, 65, - 65, 78, 193, 65, 80, 79, 83, 84, 82, 79, 80, 72, 69, 128, 80, 85, 78, 67, - 84, 85, 65, 84, 73, 79, 206, 85, 80, 45, 80, 79, 73, 78, 84, 73, 78, 199, - 83, 73, 78, 71, 76, 69, 45, 76, 73, 78, 197, 73, 77, 80, 69, 82, 70, 69, - 67, 84, 85, 205, 82, 73, 71, 72, 84, 87, 65, 82, 68, 83, 128, 65, 82, 82, - 79, 87, 45, 84, 65, 73, 76, 128, 68, 79, 65, 67, 72, 65, 83, 72, 77, 69, - 197, 65, 69, 76, 65, 45, 80, 73, 76, 76, 65, 128, 65, 76, 84, 69, 82, 78, - 65, 84, 73, 86, 197, 73, 78, 84, 69, 71, 82, 65, 84, 73, 79, 206, 73, 78, - 84, 69, 82, 76, 73, 78, 69, 65, 210, 79, 80, 69, 78, 45, 72, 69, 65, 68, - 69, 196, 82, 73, 69, 85, 76, 45, 83, 73, 79, 83, 128, 83, 69, 77, 73, 45, - 86, 79, 73, 67, 69, 196, 83, 83, 65, 78, 71, 73, 69, 85, 78, 71, 128, 83, - 85, 80, 82, 65, 76, 73, 78, 69, 65, 210, 65, 69, 68, 65, 45, 80, 73, 76, - 76, 65, 128, 67, 79, 78, 83, 69, 67, 85, 84, 73, 86, 197, 68, 73, 86, 73, - 78, 65, 84, 73, 79, 78, 128, 69, 78, 84, 69, 82, 80, 82, 73, 83, 69, 128, - 73, 77, 80, 69, 82, 70, 69, 67, 84, 65, 128, 77, 79, 78, 79, 70, 79, 78, - 73, 65, 83, 128, 77, 79, 78, 79, 71, 82, 65, 77, 77, 79, 211, 78, 65, 65, - 83, 73, 75, 89, 65, 89, 65, 128, 78, 73, 69, 85, 78, 45, 83, 73, 79, 83, - 128, 79, 86, 69, 82, 76, 65, 80, 80, 73, 78, 199, 80, 65, 82, 65, 75, 65, - 76, 69, 83, 77, 193, 80, 65, 82, 65, 75, 76, 73, 84, 73, 75, 201, 80, 69, - 82, 67, 85, 83, 83, 73, 86, 69, 128, 80, 82, 79, 80, 79, 82, 84, 73, 79, - 78, 128, 82, 69, 67, 84, 65, 78, 71, 85, 76, 65, 210, 82, 69, 67, 84, 73, - 76, 73, 78, 69, 65, 210, 82, 69, 80, 76, 65, 67, 69, 77, 69, 78, 212, 83, - 73, 79, 83, 45, 78, 73, 69, 85, 78, 128, 83, 73, 79, 83, 45, 82, 73, 69, - 85, 76, 128, 83, 83, 65, 78, 71, 72, 73, 69, 85, 72, 128, 83, 83, 65, 78, - 71, 78, 73, 69, 85, 78, 128, 83, 83, 65, 78, 71, 82, 73, 69, 85, 76, 128, - 84, 65, 66, 85, 76, 65, 84, 73, 79, 78, 128, 84, 69, 84, 82, 65, 83, 73, - 77, 79, 85, 128, 84, 72, 69, 77, 65, 84, 73, 83, 77, 79, 211, 84, 87, 69, - 78, 84, 89, 45, 79, 78, 69, 128, 84, 87, 69, 78, 84, 89, 45, 84, 87, 79, - 128, 65, 76, 84, 69, 82, 78, 65, 84, 73, 79, 206, 65, 78, 71, 75, 72, 65, - 78, 75, 72, 85, 128, 65, 78, 84, 73, 75, 69, 78, 79, 77, 65, 128, 65, 78, - 85, 83, 86, 65, 82, 65, 89, 65, 128, 65, 80, 79, 83, 84, 82, 79, 70, 79, - 83, 128, 65, 83, 84, 69, 82, 73, 83, 67, 85, 83, 128, 66, 65, 67, 75, 45, - 84, 73, 76, 84, 69, 196, 66, 65, 82, 73, 89, 79, 79, 83, 65, 78, 128, 66, - 65, 84, 72, 65, 77, 65, 83, 65, 84, 128, 67, 73, 82, 67, 85, 76, 65, 84, - 73, 79, 206, 67, 76, 85, 66, 45, 83, 80, 79, 75, 69, 196, 67, 79, 77, 80, - 76, 69, 77, 69, 78, 84, 128, 67, 79, 77, 80, 79, 83, 73, 84, 73, 79, 206, - 67, 79, 82, 82, 69, 83, 80, 79, 78, 68, 211, 67, 82, 79, 83, 83, 66, 79, - 78, 69, 83, 128, 68, 69, 70, 73, 78, 73, 84, 73, 79, 78, 128, 68, 69, 78, - 79, 77, 73, 78, 65, 84, 79, 210, 68, 73, 82, 69, 67, 84, 73, 79, 78, 65, - 204, 68, 79, 84, 83, 45, 49, 50, 51, 52, 53, 128, 68, 79, 84, 83, 45, 49, - 50, 51, 52, 54, 128, 68, 79, 84, 83, 45, 49, 50, 51, 52, 55, 128, 68, 79, - 84, 83, 45, 49, 50, 51, 52, 56, 128, 68, 79, 84, 83, 45, 49, 50, 51, 53, - 54, 128, 68, 79, 84, 83, 45, 49, 50, 51, 53, 55, 128, 68, 79, 84, 83, 45, - 49, 50, 51, 53, 56, 128, 68, 79, 84, 83, 45, 49, 50, 51, 54, 55, 128, 68, - 79, 84, 83, 45, 49, 50, 51, 54, 56, 128, 68, 79, 84, 83, 45, 49, 50, 51, - 55, 56, 128, 68, 79, 84, 83, 45, 49, 50, 52, 53, 54, 128, 68, 79, 84, 83, - 45, 49, 50, 52, 53, 55, 128, 68, 79, 84, 83, 45, 49, 50, 52, 53, 56, 128, - 68, 79, 84, 83, 45, 49, 50, 52, 54, 55, 128, 68, 79, 84, 83, 45, 49, 50, - 52, 54, 56, 128, 68, 79, 84, 83, 45, 49, 50, 52, 55, 56, 128, 68, 79, 84, - 83, 45, 49, 50, 53, 54, 55, 128, 68, 79, 84, 83, 45, 49, 50, 53, 54, 56, - 128, 68, 79, 84, 83, 45, 49, 50, 53, 55, 56, 128, 68, 79, 84, 83, 45, 49, - 50, 54, 55, 56, 128, 68, 79, 84, 83, 45, 49, 51, 52, 53, 54, 128, 68, 79, - 84, 83, 45, 49, 51, 52, 53, 55, 128, 68, 79, 84, 83, 45, 49, 51, 52, 53, - 56, 128, 68, 79, 84, 83, 45, 49, 51, 52, 54, 55, 128, 68, 79, 84, 83, 45, - 49, 51, 52, 54, 56, 128, 68, 79, 84, 83, 45, 49, 51, 52, 55, 56, 128, 68, - 79, 84, 83, 45, 49, 51, 53, 54, 55, 128, 68, 79, 84, 83, 45, 49, 51, 53, - 54, 56, 128, 68, 79, 84, 83, 45, 49, 51, 53, 55, 56, 128, 68, 79, 84, 83, - 45, 49, 51, 54, 55, 56, 128, 68, 79, 84, 83, 45, 49, 52, 53, 54, 55, 128, - 68, 79, 84, 83, 45, 49, 52, 53, 54, 56, 128, 68, 79, 84, 83, 45, 49, 52, - 53, 55, 56, 128, 68, 79, 84, 83, 45, 49, 52, 54, 55, 56, 128, 68, 79, 84, - 83, 45, 49, 53, 54, 55, 56, 128, 68, 79, 84, 83, 45, 50, 51, 52, 53, 54, - 128, 68, 79, 84, 83, 45, 50, 51, 52, 53, 55, 128, 68, 79, 84, 83, 45, 50, - 51, 52, 53, 56, 128, 68, 79, 84, 83, 45, 50, 51, 52, 54, 55, 128, 68, 79, - 84, 83, 45, 50, 51, 52, 54, 56, 128, 68, 79, 84, 83, 45, 50, 51, 52, 55, - 56, 128, 68, 79, 84, 83, 45, 50, 51, 53, 54, 55, 128, 68, 79, 84, 83, 45, - 50, 51, 53, 54, 56, 128, 68, 79, 84, 83, 45, 50, 51, 53, 55, 56, 128, 68, - 79, 84, 83, 45, 50, 51, 54, 55, 56, 128, 68, 79, 84, 83, 45, 50, 52, 53, - 54, 55, 128, 68, 79, 84, 83, 45, 50, 52, 53, 54, 56, 128, 68, 79, 84, 83, - 45, 50, 52, 53, 55, 56, 128, 68, 79, 84, 83, 45, 50, 52, 54, 55, 56, 128, - 68, 79, 84, 83, 45, 50, 53, 54, 55, 56, 128, 68, 79, 84, 83, 45, 51, 52, - 53, 54, 55, 128, 68, 79, 84, 83, 45, 51, 52, 53, 54, 56, 128, 68, 79, 84, - 83, 45, 51, 52, 53, 55, 56, 128, 68, 79, 84, 83, 45, 51, 52, 54, 55, 56, - 128, 68, 79, 84, 83, 45, 51, 53, 54, 55, 56, 128, 68, 79, 84, 83, 45, 52, - 53, 54, 55, 56, 128, 69, 75, 83, 84, 82, 69, 80, 84, 79, 78, 128, 69, 77, - 66, 82, 79, 73, 68, 69, 82, 89, 128, 69, 81, 85, 73, 65, 78, 71, 85, 76, - 65, 210, 70, 65, 72, 82, 69, 78, 72, 69, 73, 84, 128, 70, 79, 82, 77, 65, - 84, 84, 73, 78, 71, 128, 70, 79, 85, 82, 45, 80, 69, 82, 45, 69, 205, 70, - 79, 85, 82, 45, 83, 84, 82, 73, 78, 199, 72, 66, 65, 83, 65, 45, 69, 83, - 65, 83, 193, 72, 79, 77, 79, 84, 72, 69, 84, 73, 67, 128, 72, 89, 80, 72, - 69, 78, 65, 84, 73, 79, 206, 73, 77, 73, 68, 73, 65, 82, 71, 79, 78, 128, - 73, 77, 73, 70, 84, 72, 79, 82, 79, 78, 128, 73, 78, 70, 79, 82, 77, 65, - 84, 73, 79, 206, 75, 73, 82, 79, 71, 85, 82, 65, 77, 85, 128, 75, 85, 78, - 68, 68, 65, 76, 73, 89, 65, 128, 76, 69, 70, 84, 45, 83, 72, 65, 68, 69, - 196, 77, 69, 77, 66, 69, 82, 83, 72, 73, 80, 128, 78, 65, 78, 71, 77, 79, - 78, 84, 72, 79, 128, 78, 79, 78, 45, 74, 79, 73, 78, 69, 82, 128, 78, 79, - 78, 70, 79, 82, 75, 73, 78, 71, 128, 79, 80, 80, 79, 83, 73, 84, 73, 79, - 78, 128, 80, 65, 76, 65, 84, 65, 76, 73, 90, 69, 196, 80, 82, 79, 74, 69, - 67, 84, 73, 79, 78, 128, 80, 82, 79, 74, 69, 67, 84, 73, 86, 69, 128, 82, - 65, 68, 73, 79, 65, 67, 84, 73, 86, 197, 83, 65, 67, 82, 73, 70, 73, 67, - 73, 65, 204, 83, 65, 76, 76, 65, 76, 76, 65, 72, 79, 213, 83, 69, 76, 69, - 67, 84, 79, 82, 45, 49, 128, 83, 69, 76, 69, 67, 84, 79, 82, 45, 50, 128, - 83, 69, 76, 69, 67, 84, 79, 82, 45, 51, 128, 83, 69, 76, 69, 67, 84, 79, - 82, 45, 52, 128, 83, 69, 76, 69, 67, 84, 79, 82, 45, 53, 128, 83, 69, 76, - 69, 67, 84, 79, 82, 45, 54, 128, 83, 69, 76, 69, 67, 84, 79, 82, 45, 55, - 128, 83, 69, 76, 69, 67, 84, 79, 82, 45, 56, 128, 83, 69, 76, 69, 67, 84, - 79, 82, 45, 57, 128, 83, 72, 65, 76, 83, 72, 69, 76, 69, 84, 128, 83, 73, - 79, 83, 45, 72, 73, 69, 85, 72, 128, 83, 73, 79, 83, 45, 73, 69, 85, 78, - 71, 128, 83, 73, 79, 83, 45, 77, 73, 69, 85, 77, 128, 83, 83, 65, 78, 71, - 65, 82, 65, 69, 65, 128, 83, 85, 66, 80, 85, 78, 67, 84, 73, 83, 128, 83, - 85, 66, 83, 84, 73, 84, 85, 84, 69, 128, 83, 89, 78, 67, 72, 82, 79, 78, - 79, 85, 211, 84, 69, 82, 77, 73, 78, 65, 84, 79, 82, 128, 84, 72, 73, 82, - 84, 89, 45, 79, 78, 69, 128, 84, 79, 80, 45, 76, 73, 71, 72, 84, 69, 196, - 84, 82, 65, 78, 83, 86, 69, 82, 83, 65, 204, 84, 87, 69, 78, 84, 89, 45, - 83, 73, 88, 128, 86, 69, 82, 84, 73, 67, 65, 76, 76, 89, 128, 87, 73, 68, - 69, 45, 72, 69, 65, 68, 69, 196, 76, 69, 83, 83, 45, 84, 72, 65, 78, 128, - 65, 78, 78, 79, 84, 65, 84, 73, 79, 206, 68, 69, 83, 67, 69, 78, 68, 69, - 82, 128, 69, 81, 85, 73, 86, 65, 76, 69, 78, 212, 83, 69, 80, 65, 82, 65, - 84, 79, 82, 128, 65, 76, 80, 65, 80, 82, 65, 65, 78, 193, 65, 82, 82, 79, - 87, 72, 69, 65, 68, 128, 80, 72, 65, 82, 89, 78, 71, 69, 65, 204, 80, 82, - 79, 76, 65, 84, 73, 79, 78, 197, 84, 85, 82, 78, 83, 84, 73, 76, 69, 128, - 84, 87, 79, 45, 72, 69, 65, 68, 69, 196, 68, 79, 87, 78, 87, 65, 82, 68, - 83, 128, 69, 88, 84, 69, 78, 83, 73, 79, 78, 128, 83, 69, 77, 73, 67, 79, - 76, 79, 78, 128, 65, 77, 80, 69, 82, 83, 65, 78, 68, 128, 76, 69, 70, 84, - 87, 65, 82, 68, 83, 128, 76, 69, 78, 84, 73, 67, 85, 76, 65, 210, 67, 79, - 77, 77, 69, 82, 67, 73, 65, 204, 83, 69, 77, 73, 68, 73, 82, 69, 67, 212, - 83, 69, 86, 69, 78, 84, 69, 69, 78, 128, 87, 79, 79, 68, 83, 45, 67, 82, - 69, 197, 66, 65, 67, 75, 83, 76, 65, 83, 72, 128, 68, 73, 65, 76, 89, 84, - 73, 75, 65, 128, 70, 73, 88, 69, 68, 45, 70, 79, 82, 205, 73, 77, 80, 69, - 82, 70, 69, 67, 84, 193, 73, 78, 68, 73, 67, 65, 84, 79, 82, 128, 82, 69, - 67, 84, 65, 78, 71, 76, 69, 128, 69, 78, 67, 76, 79, 83, 85, 82, 69, 128, - 72, 79, 85, 82, 71, 76, 65, 83, 83, 128, 83, 69, 77, 73, 66, 82, 69, 86, - 73, 211, 83, 69, 77, 73, 77, 73, 78, 73, 77, 193, 83, 78, 79, 87, 70, 76, - 65, 75, 69, 128, 84, 82, 73, 65, 78, 71, 85, 76, 65, 210, 65, 80, 79, 83, - 84, 82, 79, 70, 79, 201, 65, 80, 79, 83, 84, 82, 79, 70, 79, 211, 65, 82, - 80, 69, 71, 71, 73, 65, 84, 207, 65, 84, 72, 65, 80, 65, 83, 67, 65, 206, - 67, 69, 78, 84, 82, 69, 76, 73, 78, 197, 67, 72, 65, 82, 65, 67, 84, 69, - 82, 128, 67, 79, 78, 84, 65, 73, 78, 73, 78, 199, 67, 79, 80, 82, 79, 68, - 85, 67, 84, 128, 67, 82, 79, 83, 83, 72, 65, 84, 67, 200, 69, 77, 66, 69, - 68, 68, 73, 78, 71, 128, 70, 73, 78, 65, 78, 67, 73, 65, 76, 128, 70, 82, - 69, 84, 66, 79, 65, 82, 68, 128, 71, 69, 82, 83, 72, 65, 89, 73, 77, 128, - 71, 79, 82, 84, 72, 77, 73, 75, 79, 206, 73, 67, 72, 73, 77, 65, 84, 79, - 83, 128, 75, 72, 65, 75, 65, 83, 83, 73, 65, 206, 80, 65, 65, 45, 80, 73, - 76, 76, 65, 128, 80, 72, 73, 76, 73, 80, 80, 73, 78, 197, 83, 69, 77, 73, - 67, 73, 82, 67, 76, 197, 83, 85, 77, 77, 65, 84, 73, 79, 78, 128, 83, 85, - 80, 69, 82, 86, 73, 83, 69, 128, 84, 69, 76, 69, 80, 72, 79, 78, 69, 128, - 84, 82, 69, 77, 79, 76, 79, 45, 49, 128, 84, 82, 69, 77, 79, 76, 79, 45, - 50, 128, 84, 82, 69, 77, 79, 76, 79, 45, 51, 128, 84, 82, 73, 71, 82, 65, - 77, 77, 79, 211, 65, 65, 66, 65, 65, 70, 73, 76, 73, 128, 65, 76, 45, 76, - 65, 75, 85, 78, 65, 128, 65, 78, 84, 73, 70, 79, 78, 73, 65, 128, 65, 80, - 80, 82, 79, 65, 67, 72, 69, 211, 65, 83, 83, 69, 82, 84, 73, 79, 78, 128, - 65, 84, 84, 69, 78, 84, 73, 79, 78, 128, 66, 65, 67, 75, 83, 80, 65, 67, - 69, 128, 66, 73, 66, 76, 69, 45, 67, 82, 69, 197, 67, 65, 80, 82, 73, 67, - 79, 82, 78, 128, 67, 72, 65, 86, 73, 89, 65, 78, 73, 128, 67, 79, 77, 80, - 76, 69, 84, 69, 68, 128, 67, 79, 80, 89, 82, 73, 71, 72, 84, 128, 68, 69, - 76, 73, 77, 73, 84, 69, 82, 128, 68, 69, 83, 67, 69, 78, 68, 73, 78, 199, - 68, 73, 70, 70, 69, 82, 69, 78, 67, 197, 68, 79, 84, 83, 45, 49, 50, 51, - 52, 128, 68, 79, 84, 83, 45, 49, 50, 51, 53, 128, 68, 79, 84, 83, 45, 49, - 50, 51, 54, 128, 68, 79, 84, 83, 45, 49, 50, 51, 55, 128, 68, 79, 84, 83, - 45, 49, 50, 51, 56, 128, 68, 79, 84, 83, 45, 49, 50, 52, 53, 128, 68, 79, - 84, 83, 45, 49, 50, 52, 54, 128, 68, 79, 84, 83, 45, 49, 50, 52, 55, 128, - 68, 79, 84, 83, 45, 49, 50, 52, 56, 128, 68, 79, 84, 83, 45, 49, 50, 53, - 54, 128, 68, 79, 84, 83, 45, 49, 50, 53, 55, 128, 68, 79, 84, 83, 45, 49, - 50, 53, 56, 128, 68, 79, 84, 83, 45, 49, 50, 54, 55, 128, 68, 79, 84, 83, - 45, 49, 50, 54, 56, 128, 68, 79, 84, 83, 45, 49, 50, 55, 56, 128, 68, 79, - 84, 83, 45, 49, 51, 52, 53, 128, 68, 79, 84, 83, 45, 49, 51, 52, 54, 128, - 68, 79, 84, 83, 45, 49, 51, 52, 55, 128, 68, 79, 84, 83, 45, 49, 51, 52, - 56, 128, 68, 79, 84, 83, 45, 49, 51, 53, 54, 128, 68, 79, 84, 83, 45, 49, - 51, 53, 55, 128, 68, 79, 84, 83, 45, 49, 51, 53, 56, 128, 68, 79, 84, 83, - 45, 49, 51, 54, 55, 128, 68, 79, 84, 83, 45, 49, 51, 54, 56, 128, 68, 79, - 84, 83, 45, 49, 51, 55, 56, 128, 68, 79, 84, 83, 45, 49, 52, 53, 54, 128, - 68, 79, 84, 83, 45, 49, 52, 53, 55, 128, 68, 79, 84, 83, 45, 49, 52, 53, - 56, 128, 68, 79, 84, 83, 45, 49, 52, 54, 55, 128, 68, 79, 84, 83, 45, 49, - 52, 54, 56, 128, 68, 79, 84, 83, 45, 49, 52, 55, 56, 128, 68, 79, 84, 83, - 45, 49, 53, 54, 55, 128, 68, 79, 84, 83, 45, 49, 53, 54, 56, 128, 68, 79, - 84, 83, 45, 49, 53, 55, 56, 128, 68, 79, 84, 83, 45, 49, 54, 55, 56, 128, - 68, 79, 84, 83, 45, 50, 51, 52, 53, 128, 68, 79, 84, 83, 45, 50, 51, 52, - 54, 128, 68, 79, 84, 83, 45, 50, 51, 52, 55, 128, 68, 79, 84, 83, 45, 50, - 51, 52, 56, 128, 68, 79, 84, 83, 45, 50, 51, 53, 54, 128, 68, 79, 84, 83, - 45, 50, 51, 53, 55, 128, 68, 79, 84, 83, 45, 50, 51, 53, 56, 128, 68, 79, - 84, 83, 45, 50, 51, 54, 55, 128, 68, 79, 84, 83, 45, 50, 51, 54, 56, 128, - 68, 79, 84, 83, 45, 50, 51, 55, 56, 128, 68, 79, 84, 83, 45, 50, 52, 53, - 54, 128, 68, 79, 84, 83, 45, 50, 52, 53, 55, 128, 68, 79, 84, 83, 45, 50, - 52, 53, 56, 128, 68, 79, 84, 83, 45, 50, 52, 54, 55, 128, 68, 79, 84, 83, - 45, 50, 52, 54, 56, 128, 68, 79, 84, 83, 45, 50, 52, 55, 56, 128, 68, 79, - 84, 83, 45, 50, 53, 54, 55, 128, 68, 79, 84, 83, 45, 50, 53, 54, 56, 128, - 68, 79, 84, 83, 45, 50, 53, 55, 56, 128, 68, 79, 84, 83, 45, 50, 54, 55, - 56, 128, 68, 79, 84, 83, 45, 51, 52, 53, 54, 128, 68, 79, 84, 83, 45, 51, - 52, 53, 55, 128, 68, 79, 84, 83, 45, 51, 52, 53, 56, 128, 68, 79, 84, 83, - 45, 51, 52, 54, 55, 128, 68, 79, 84, 83, 45, 51, 52, 54, 56, 128, 68, 79, - 84, 83, 45, 51, 52, 55, 56, 128, 68, 79, 84, 83, 45, 51, 53, 54, 55, 128, - 68, 79, 84, 83, 45, 51, 53, 54, 56, 128, 68, 79, 84, 83, 45, 51, 53, 55, - 56, 128, 68, 79, 84, 83, 45, 51, 54, 55, 56, 128, 68, 79, 84, 83, 45, 52, - 53, 54, 55, 128, 68, 79, 84, 83, 45, 52, 53, 54, 56, 128, 68, 79, 84, 83, - 45, 52, 53, 55, 56, 128, 68, 79, 84, 83, 45, 52, 54, 55, 56, 128, 68, 79, - 84, 83, 45, 53, 54, 55, 56, 128, 69, 69, 66, 69, 69, 70, 73, 76, 73, 128, - 69, 78, 65, 82, 77, 79, 78, 73, 79, 211, 69, 78, 68, 79, 70, 79, 78, 79, - 78, 128, 69, 83, 84, 73, 77, 65, 84, 69, 83, 128, 69, 88, 67, 69, 76, 76, - 69, 78, 84, 128, 69, 88, 84, 82, 65, 45, 72, 73, 71, 200, 69, 89, 66, 69, - 89, 70, 73, 76, 73, 128, 70, 82, 73, 67, 65, 84, 73, 86, 69, 128, 71, 78, - 65, 86, 73, 89, 65, 78, 73, 128, 71, 79, 82, 71, 79, 84, 69, 82, 73, 128, - 71, 85, 82, 65, 77, 85, 84, 79, 78, 128, 72, 69, 75, 85, 84, 65, 65, 82, - 85, 128, 72, 79, 77, 79, 84, 72, 69, 84, 73, 195, 72, 89, 83, 84, 69, 82, - 69, 83, 73, 211, 73, 76, 85, 85, 89, 65, 78, 78, 65, 128, 73, 77, 73, 70, - 84, 72, 79, 82, 65, 128, 73, 78, 67, 79, 77, 80, 76, 69, 84, 197, 73, 78, - 67, 82, 69, 77, 69, 78, 84, 128, 73, 78, 68, 85, 83, 84, 82, 73, 65, 204, - 73, 82, 85, 85, 89, 65, 78, 78, 65, 128, 74, 69, 82, 85, 83, 65, 76, 69, - 77, 128, 75, 65, 84, 65, 86, 65, 83, 77, 65, 128, 75, 69, 78, 84, 73, 77, - 65, 84, 65, 128, 75, 73, 82, 79, 87, 65, 84, 84, 79, 128, 75, 82, 65, 84, - 73, 77, 65, 84, 65, 128, 75, 85, 82, 85, 90, 69, 73, 82, 79, 128, 76, 72, - 65, 86, 73, 89, 65, 78, 73, 128, 76, 73, 71, 72, 84, 78, 73, 78, 71, 128, - 77, 65, 73, 84, 65, 73, 75, 72, 85, 128, 77, 65, 84, 69, 82, 73, 65, 76, - 83, 128, 77, 69, 84, 79, 66, 69, 76, 85, 83, 128, 77, 73, 82, 73, 66, 65, - 65, 82, 85, 128, 77, 79, 78, 79, 83, 84, 65, 66, 76, 197, 77, 79, 79, 83, - 69, 45, 67, 82, 69, 197, 78, 73, 71, 71, 65, 72, 73, 84, 65, 128, 79, 65, - 66, 79, 65, 70, 73, 76, 73, 128, 79, 79, 66, 79, 79, 70, 73, 76, 73, 128, - 79, 82, 84, 72, 79, 71, 79, 78, 65, 204, 80, 65, 73, 89, 65, 78, 78, 79, - 73, 128, 80, 65, 82, 65, 71, 82, 65, 80, 72, 128, 80, 73, 65, 83, 85, 84, - 79, 82, 85, 128, 80, 73, 84, 67, 72, 70, 79, 82, 75, 128, 80, 73, 90, 90, - 73, 67, 65, 84, 79, 128, 80, 76, 85, 83, 45, 77, 73, 78, 85, 211, 80, 79, - 82, 82, 69, 67, 84, 85, 83, 128, 80, 82, 79, 84, 79, 86, 65, 82, 89, 211, - 81, 85, 65, 84, 69, 82, 78, 73, 79, 206, 81, 85, 69, 83, 84, 73, 79, 78, - 69, 196, 81, 85, 83, 72, 83, 72, 65, 89, 65, 128, 82, 69, 71, 73, 83, 84, - 69, 82, 69, 196, 82, 69, 76, 65, 84, 73, 79, 78, 65, 204, 82, 69, 80, 82, - 69, 83, 69, 78, 84, 128, 82, 69, 83, 85, 80, 73, 78, 85, 83, 128, 82, 73, - 71, 72, 84, 45, 83, 73, 68, 197, 83, 67, 65, 78, 68, 73, 67, 85, 83, 128, - 83, 69, 80, 84, 69, 77, 66, 69, 82, 128, 83, 72, 65, 86, 73, 89, 65, 78, - 73, 128, 83, 72, 79, 85, 76, 68, 69, 82, 69, 196, 83, 73, 88, 45, 80, 69, - 82, 45, 69, 205, 83, 73, 88, 45, 83, 84, 82, 73, 78, 199, 83, 84, 82, 79, - 75, 69, 45, 49, 48, 128, 83, 84, 82, 79, 75, 69, 45, 49, 49, 128, 83, 85, - 66, 83, 84, 73, 84, 85, 84, 197, 83, 89, 82, 77, 65, 84, 73, 75, 73, 128, - 84, 72, 69, 82, 69, 70, 79, 82, 69, 128, 84, 72, 82, 69, 69, 45, 76, 73, - 78, 197, 84, 82, 73, 70, 79, 76, 73, 65, 84, 197, 84, 82, 73, 70, 79, 78, - 73, 65, 83, 128, 84, 82, 73, 71, 79, 82, 71, 79, 78, 128, 86, 73, 83, 65, - 82, 71, 65, 89, 65, 128, 87, 79, 82, 68, 83, 80, 65, 67, 69, 128, 89, 80, - 79, 75, 82, 73, 83, 73, 83, 128, 85, 78, 68, 69, 82, 66, 65, 82, 128, 81, - 85, 79, 84, 65, 84, 73, 79, 206, 65, 83, 84, 69, 82, 73, 83, 75, 128, 79, - 82, 78, 65, 77, 69, 78, 84, 128, 86, 65, 82, 73, 65, 84, 73, 79, 206, 65, - 82, 67, 72, 65, 73, 79, 78, 128, 68, 73, 65, 69, 82, 69, 83, 73, 211, 66, - 76, 65, 67, 75, 70, 79, 79, 212, 83, 85, 66, 83, 67, 82, 73, 80, 212, 68, - 69, 78, 84, 73, 83, 84, 82, 217, 68, 73, 65, 76, 89, 84, 73, 75, 193, 73, - 78, 84, 69, 71, 82, 65, 76, 128, 86, 69, 82, 84, 73, 67, 65, 76, 128, 82, - 69, 67, 89, 67, 76, 73, 78, 199, 65, 78, 85, 83, 86, 65, 82, 65, 128, 65, - 66, 75, 72, 65, 83, 73, 65, 206, 68, 79, 68, 69, 75, 65, 84, 65, 128, 81, - 85, 65, 68, 82, 65, 78, 84, 128, 81, 85, 65, 68, 82, 85, 80, 76, 197, 68, - 73, 65, 84, 79, 78, 73, 75, 201, 69, 76, 76, 73, 80, 83, 73, 83, 128, 69, - 78, 67, 76, 79, 83, 73, 78, 199, 79, 86, 69, 82, 76, 73, 78, 69, 128, 80, - 76, 65, 83, 84, 73, 67, 83, 128, 82, 69, 84, 82, 79, 70, 76, 69, 216, 73, - 84, 69, 82, 65, 84, 73, 79, 206, 78, 79, 84, 69, 72, 69, 65, 68, 128, 78, - 85, 77, 69, 82, 65, 84, 79, 210, 84, 72, 79, 85, 83, 65, 78, 68, 128, 69, - 73, 71, 72, 84, 69, 69, 78, 128, 70, 79, 85, 82, 84, 69, 69, 78, 128, 78, - 73, 78, 69, 84, 69, 69, 78, 128, 84, 72, 73, 82, 84, 69, 69, 78, 128, 68, - 73, 65, 71, 79, 78, 65, 76, 128, 70, 76, 79, 82, 69, 84, 84, 69, 128, 73, - 68, 69, 78, 84, 73, 67, 65, 204, 75, 69, 78, 84, 73, 77, 65, 84, 193, 80, - 65, 82, 65, 71, 82, 65, 80, 200, 82, 69, 76, 65, 84, 73, 79, 78, 128, 83, - 67, 73, 83, 83, 79, 82, 83, 128, 83, 85, 80, 69, 82, 83, 69, 84, 128, 65, - 86, 65, 71, 82, 65, 72, 65, 128, 68, 68, 65, 89, 65, 78, 78, 65, 128, 68, - 69, 80, 65, 82, 84, 73, 78, 199, 70, 65, 78, 69, 82, 79, 83, 73, 211, 73, - 78, 70, 73, 78, 73, 84, 89, 128, 77, 85, 76, 84, 73, 77, 65, 80, 128, 77, - 85, 85, 82, 68, 72, 65, 74, 193, 80, 65, 82, 65, 76, 76, 69, 76, 128, 80, - 82, 69, 67, 69, 68, 69, 83, 128, 83, 73, 88, 84, 69, 69, 78, 84, 200, 83, - 80, 72, 69, 82, 73, 67, 65, 204, 83, 85, 66, 76, 73, 78, 69, 65, 210, 83, - 85, 67, 67, 69, 69, 68, 83, 128, 83, 85, 77, 77, 65, 84, 73, 79, 206, 84, - 69, 76, 69, 80, 72, 79, 78, 197, 84, 72, 79, 85, 83, 65, 78, 68, 211, 89, - 69, 83, 73, 69, 85, 78, 71, 128, 65, 76, 76, 73, 65, 78, 67, 69, 128, 67, - 79, 78, 83, 84, 65, 78, 84, 128, 68, 73, 70, 79, 78, 73, 65, 83, 128, 68, - 73, 71, 82, 65, 77, 77, 79, 211, 70, 73, 83, 72, 72, 79, 79, 75, 128, 70, - 76, 65, 84, 84, 69, 78, 69, 196, 71, 65, 82, 83, 72, 85, 78, 73, 128, 71, - 76, 73, 83, 83, 65, 78, 68, 207, 71, 82, 69, 71, 79, 82, 73, 65, 206, 73, - 78, 83, 69, 82, 84, 73, 79, 206, 73, 78, 86, 73, 83, 73, 66, 76, 197, 73, - 83, 45, 80, 73, 76, 76, 65, 128, 77, 79, 85, 78, 84, 65, 73, 78, 128, 79, - 86, 69, 82, 82, 73, 68, 69, 128, 79, 89, 82, 65, 78, 73, 83, 77, 193, 80, - 69, 68, 69, 83, 84, 65, 76, 128, 80, 78, 69, 85, 77, 65, 84, 65, 128, 80, - 82, 79, 76, 79, 78, 71, 69, 196, 80, 82, 79, 80, 69, 76, 76, 69, 210, 82, - 69, 83, 79, 85, 82, 67, 69, 128, 82, 69, 86, 69, 82, 83, 69, 68, 128, 83, - 69, 77, 73, 86, 79, 87, 69, 204, 83, 69, 80, 65, 82, 65, 84, 79, 210, 83, - 85, 66, 71, 82, 79, 85, 80, 128, 83, 87, 65, 80, 80, 73, 78, 71, 128, 83, - 89, 77, 77, 69, 84, 82, 73, 195, 84, 82, 73, 83, 73, 77, 79, 85, 128, 84, - 84, 65, 89, 65, 78, 78, 65, 128, 85, 78, 68, 69, 82, 76, 73, 78, 197, 85, - 78, 73, 86, 69, 82, 83, 65, 204, 65, 68, 68, 82, 69, 83, 83, 69, 196, 65, - 69, 69, 89, 65, 78, 78, 65, 128, 65, 73, 82, 80, 76, 65, 78, 69, 128, 65, - 78, 85, 68, 65, 84, 84, 65, 128, 65, 80, 79, 68, 69, 88, 73, 65, 128, 65, - 80, 79, 84, 72, 69, 77, 65, 128, 65, 81, 85, 65, 82, 73, 85, 83, 128, 65, - 82, 65, 69, 65, 45, 69, 79, 128, 65, 82, 71, 79, 84, 69, 82, 73, 128, 65, - 82, 73, 83, 84, 69, 82, 65, 128, 65, 82, 82, 79, 87, 72, 69, 65, 196, 65, - 83, 67, 69, 78, 68, 73, 78, 199, 65, 83, 84, 69, 82, 73, 83, 75, 211, 65, - 83, 84, 69, 82, 73, 83, 77, 128, 66, 65, 67, 75, 83, 76, 65, 83, 200, 66, - 73, 79, 72, 65, 90, 65, 82, 196, 66, 73, 83, 69, 67, 84, 73, 78, 199, 66, - 85, 76, 76, 83, 69, 89, 69, 128, 66, 85, 83, 83, 89, 69, 82, 85, 128, 67, - 65, 68, 85, 67, 69, 85, 83, 128, 67, 65, 85, 76, 68, 82, 79, 78, 128, 67, - 72, 65, 77, 73, 76, 79, 78, 128, 67, 72, 65, 84, 84, 65, 87, 65, 128, 67, - 73, 86, 73, 76, 73, 65, 78, 128, 67, 76, 73, 77, 65, 67, 85, 83, 128, 67, - 79, 78, 71, 82, 85, 69, 78, 212, 67, 79, 78, 74, 85, 71, 65, 84, 197, 67, - 79, 78, 84, 79, 85, 82, 69, 196, 67, 79, 80, 89, 82, 73, 71, 72, 212, 67, - 82, 69, 83, 67, 69, 78, 84, 128, 68, 65, 77, 77, 65, 84, 65, 78, 128, 68, - 65, 86, 73, 89, 65, 78, 73, 128, 68, 69, 67, 69, 77, 66, 69, 82, 128, 68, - 69, 76, 73, 77, 73, 84, 69, 210, 68, 73, 70, 84, 79, 71, 71, 79, 211, 68, - 73, 71, 79, 82, 71, 79, 78, 128, 68, 73, 77, 69, 78, 83, 73, 79, 206, 68, - 79, 84, 83, 45, 49, 50, 51, 128, 68, 79, 84, 83, 45, 49, 50, 52, 128, 68, - 79, 84, 83, 45, 49, 50, 53, 128, 68, 79, 84, 83, 45, 49, 50, 54, 128, 68, - 79, 84, 83, 45, 49, 50, 55, 128, 68, 79, 84, 83, 45, 49, 50, 56, 128, 68, - 79, 84, 83, 45, 49, 51, 52, 128, 68, 79, 84, 83, 45, 49, 51, 53, 128, 68, - 79, 84, 83, 45, 49, 51, 54, 128, 68, 79, 84, 83, 45, 49, 51, 55, 128, 68, - 79, 84, 83, 45, 49, 51, 56, 128, 68, 79, 84, 83, 45, 49, 52, 53, 128, 68, - 79, 84, 83, 45, 49, 52, 54, 128, 68, 79, 84, 83, 45, 49, 52, 55, 128, 68, - 79, 84, 83, 45, 49, 52, 56, 128, 68, 79, 84, 83, 45, 49, 53, 54, 128, 68, - 79, 84, 83, 45, 49, 53, 55, 128, 68, 79, 84, 83, 45, 49, 53, 56, 128, 68, - 79, 84, 83, 45, 49, 54, 55, 128, 68, 79, 84, 83, 45, 49, 54, 56, 128, 68, - 79, 84, 83, 45, 49, 55, 56, 128, 68, 79, 84, 83, 45, 50, 51, 52, 128, 68, - 79, 84, 83, 45, 50, 51, 53, 128, 68, 79, 84, 83, 45, 50, 51, 54, 128, 68, - 79, 84, 83, 45, 50, 51, 55, 128, 68, 79, 84, 83, 45, 50, 51, 56, 128, 68, - 79, 84, 83, 45, 50, 52, 53, 128, 68, 79, 84, 83, 45, 50, 52, 54, 128, 68, - 79, 84, 83, 45, 50, 52, 55, 128, 68, 79, 84, 83, 45, 50, 52, 56, 128, 68, - 79, 84, 83, 45, 50, 53, 54, 128, 68, 79, 84, 83, 45, 50, 53, 55, 128, 68, - 79, 84, 83, 45, 50, 53, 56, 128, 68, 79, 84, 83, 45, 50, 54, 55, 128, 68, - 79, 84, 83, 45, 50, 54, 56, 128, 68, 79, 84, 83, 45, 50, 55, 56, 128, 68, - 79, 84, 83, 45, 51, 52, 53, 128, 68, 79, 84, 83, 45, 51, 52, 54, 128, 68, - 79, 84, 83, 45, 51, 52, 55, 128, 68, 79, 84, 83, 45, 51, 52, 56, 128, 68, - 79, 84, 83, 45, 51, 53, 54, 128, 68, 79, 84, 83, 45, 51, 53, 55, 128, 68, - 79, 84, 83, 45, 51, 53, 56, 128, 68, 79, 84, 83, 45, 51, 54, 55, 128, 68, - 79, 84, 83, 45, 51, 54, 56, 128, 68, 79, 84, 83, 45, 51, 55, 56, 128, 68, - 79, 84, 83, 45, 52, 53, 54, 128, 68, 79, 84, 83, 45, 52, 53, 55, 128, 68, - 79, 84, 83, 45, 52, 53, 56, 128, 68, 79, 84, 83, 45, 52, 54, 55, 128, 68, - 79, 84, 83, 45, 52, 54, 56, 128, 68, 79, 84, 83, 45, 52, 55, 56, 128, 68, - 79, 84, 83, 45, 53, 54, 55, 128, 68, 79, 84, 83, 45, 53, 54, 56, 128, 68, - 79, 84, 83, 45, 53, 55, 56, 128, 68, 79, 84, 83, 45, 54, 55, 56, 128, 68, - 79, 84, 84, 69, 68, 45, 76, 128, 68, 79, 84, 84, 69, 68, 45, 78, 128, 68, - 79, 84, 84, 69, 68, 45, 80, 128, 69, 78, 86, 69, 76, 79, 80, 69, 128, 69, - 80, 69, 71, 69, 82, 77, 65, 128, 69, 83, 84, 73, 77, 65, 84, 69, 196, 69, - 83, 85, 75, 85, 85, 68, 79, 128, 69, 88, 84, 82, 65, 45, 76, 79, 215, 70, - 65, 84, 72, 65, 84, 65, 78, 128, 70, 69, 66, 82, 85, 65, 82, 89, 128, 70, - 69, 83, 84, 73, 86, 65, 76, 128, 70, 73, 71, 85, 82, 69, 45, 49, 128, 70, - 73, 71, 85, 82, 69, 45, 50, 128, 70, 73, 71, 85, 82, 69, 45, 51, 128, 70, - 73, 86, 69, 45, 76, 73, 78, 197, 70, 79, 85, 82, 45, 76, 73, 78, 197, 70, - 82, 65, 71, 77, 69, 78, 84, 128, 70, 82, 65, 71, 82, 65, 78, 84, 128, 70, - 85, 78, 67, 84, 73, 79, 78, 128, 71, 69, 78, 73, 84, 73, 86, 69, 128, 71, - 69, 79, 77, 69, 84, 82, 73, 195, 72, 65, 78, 45, 65, 75, 65, 84, 128, 72, - 65, 82, 77, 79, 78, 73, 67, 128, 72, 69, 82, 77, 73, 84, 73, 65, 206, 72, - 85, 65, 82, 65, 68, 68, 79, 128, 73, 76, 85, 89, 65, 78, 78, 65, 128, 73, - 77, 73, 70, 79, 78, 79, 78, 128, 73, 78, 67, 76, 85, 68, 73, 78, 199, 73, - 78, 67, 82, 69, 65, 83, 69, 211, 73, 82, 85, 89, 65, 78, 78, 65, 128, 74, - 65, 86, 73, 89, 65, 78, 73, 128, 75, 65, 83, 82, 65, 84, 65, 78, 128, 75, - 65, 84, 72, 73, 83, 84, 73, 128, 75, 69, 89, 66, 79, 65, 82, 68, 128, 75, - 79, 78, 84, 69, 86, 77, 65, 128, 75, 82, 69, 77, 65, 83, 84, 73, 128, 76, - 69, 70, 84, 45, 83, 73, 68, 197, 76, 79, 67, 65, 84, 73, 86, 69, 128, 76, - 79, 82, 82, 65, 73, 78, 69, 128, 77, 65, 72, 65, 80, 65, 75, 72, 128, 77, - 65, 73, 77, 65, 76, 65, 73, 128, 77, 65, 73, 89, 65, 77, 79, 75, 128, 77, - 65, 83, 67, 85, 76, 73, 78, 197, 77, 69, 68, 73, 67, 73, 78, 69, 128, 77, - 73, 78, 73, 83, 84, 69, 82, 128, 77, 85, 76, 84, 73, 83, 69, 84, 128, 78, - 73, 75, 72, 65, 72, 73, 84, 128, 78, 79, 82, 84, 72, 87, 69, 83, 212, 78, - 79, 86, 69, 77, 66, 69, 82, 128, 79, 86, 69, 82, 76, 65, 73, 68, 128, 80, - 65, 65, 83, 69, 78, 84, 79, 128, 80, 65, 73, 82, 84, 72, 82, 65, 128, 80, - 65, 76, 79, 67, 72, 75, 65, 128, 80, 65, 77, 85, 68, 80, 79, 68, 128, 80, - 65, 82, 73, 67, 72, 79, 78, 128, 80, 65, 86, 73, 89, 65, 78, 73, 128, 80, - 69, 76, 65, 83, 84, 79, 78, 128, 80, 73, 84, 67, 72, 70, 79, 82, 203, 80, - 79, 82, 82, 69, 67, 84, 85, 211, 80, 82, 79, 70, 79, 85, 78, 68, 128, 80, - 83, 73, 70, 73, 83, 84, 79, 206, 81, 65, 73, 82, 84, 72, 82, 65, 128, 81, - 85, 65, 82, 84, 69, 82, 83, 128, 81, 85, 69, 83, 84, 73, 79, 78, 128, 82, - 69, 67, 79, 82, 68, 69, 82, 128, 82, 69, 67, 79, 82, 68, 73, 78, 199, 82, - 69, 67, 84, 65, 78, 71, 76, 197, 82, 69, 70, 69, 82, 69, 78, 67, 197, 82, - 69, 76, 73, 71, 73, 79, 78, 128, 82, 69, 78, 84, 79, 71, 69, 78, 128, 82, - 69, 83, 80, 79, 78, 83, 69, 128, 82, 73, 71, 72, 84, 72, 65, 78, 196, 82, - 85, 75, 75, 65, 75, 72, 65, 128, 83, 65, 78, 84, 73, 73, 77, 85, 128, 83, - 65, 88, 73, 77, 65, 84, 65, 128, 83, 67, 65, 78, 68, 73, 67, 85, 211, 83, - 67, 79, 82, 80, 73, 85, 83, 128, 83, 69, 77, 73, 67, 79, 76, 79, 206, 83, - 69, 86, 69, 78, 84, 69, 69, 206, 83, 73, 67, 75, 78, 69, 83, 83, 128, 83, - 84, 79, 80, 80, 73, 78, 71, 128, 83, 84, 82, 69, 84, 67, 72, 69, 196, 83, - 84, 82, 79, 75, 69, 45, 49, 128, 83, 84, 82, 79, 75, 69, 45, 50, 128, 83, - 84, 82, 79, 75, 69, 45, 51, 128, 83, 84, 82, 79, 75, 69, 45, 52, 128, 83, - 84, 82, 79, 75, 69, 45, 53, 128, 83, 84, 82, 79, 75, 69, 45, 54, 128, 83, - 84, 82, 79, 75, 69, 45, 55, 128, 83, 84, 82, 79, 75, 69, 45, 56, 128, 83, - 84, 82, 79, 75, 69, 45, 57, 128, 83, 85, 73, 84, 65, 66, 76, 69, 128, 83, - 85, 82, 82, 79, 85, 78, 68, 128, 83, 89, 77, 77, 69, 84, 82, 89, 128, 83, - 89, 78, 68, 69, 83, 77, 79, 211, 84, 65, 86, 73, 89, 65, 78, 73, 128, 84, - 69, 84, 82, 65, 80, 76, 73, 128, 84, 79, 82, 67, 85, 76, 85, 83, 128, 84, - 82, 79, 77, 73, 75, 79, 78, 128, 84, 82, 85, 78, 67, 65, 84, 69, 196, 85, - 73, 76, 76, 69, 65, 78, 78, 128, 85, 77, 66, 82, 69, 76, 76, 65, 128, 85, - 78, 68, 69, 82, 68, 79, 84, 128, 85, 78, 68, 69, 82, 84, 73, 69, 128, 86, - 69, 82, 83, 73, 67, 76, 69, 128, 87, 65, 83, 65, 76, 76, 65, 77, 128, 89, - 65, 77, 65, 75, 75, 65, 78, 128, 89, 80, 79, 75, 82, 73, 83, 73, 211, 90, - 65, 86, 73, 89, 65, 78, 73, 128, 78, 69, 71, 65, 84, 73, 86, 197, 73, 78, - 86, 69, 82, 84, 69, 196, 67, 69, 68, 73, 76, 76, 65, 128, 84, 82, 73, 65, - 78, 71, 76, 197, 78, 79, 84, 69, 72, 69, 65, 196, 83, 85, 80, 69, 82, 83, - 69, 212, 84, 65, 71, 66, 65, 78, 87, 193, 70, 82, 65, 67, 84, 73, 79, - 206, 81, 85, 65, 68, 82, 65, 78, 212, 68, 73, 65, 71, 79, 78, 65, 204, - 81, 85, 69, 83, 84, 73, 79, 206, 85, 80, 83, 73, 76, 79, 78, 128, 77, 65, - 82, 84, 89, 82, 73, 193, 79, 86, 69, 82, 66, 65, 82, 128, 79, 86, 69, 82, - 76, 65, 89, 128, 68, 73, 65, 77, 79, 78, 68, 128, 69, 80, 83, 73, 76, 79, - 78, 128, 72, 65, 78, 71, 90, 72, 79, 213, 73, 78, 84, 69, 71, 82, 65, - 204, 77, 69, 65, 83, 85, 82, 69, 196, 79, 77, 73, 67, 82, 79, 78, 128, - 84, 79, 82, 84, 79, 73, 83, 197, 79, 82, 78, 65, 77, 69, 78, 212, 69, 88, - 84, 69, 78, 68, 69, 196, 72, 65, 82, 80, 79, 79, 78, 128, 80, 82, 69, 67, - 69, 68, 69, 211, 83, 79, 76, 73, 68, 85, 83, 128, 83, 85, 67, 67, 69, 69, - 68, 211, 67, 79, 78, 84, 65, 73, 78, 211, 86, 73, 83, 65, 82, 71, 65, - 128, 67, 82, 79, 83, 83, 73, 78, 199, 72, 85, 78, 68, 82, 69, 68, 128, - 83, 73, 77, 65, 78, 83, 73, 211, 68, 73, 71, 82, 65, 80, 72, 128, 66, 65, - 82, 76, 73, 78, 69, 128, 68, 73, 86, 73, 83, 73, 79, 206, 73, 79, 84, 73, - 70, 73, 69, 196, 80, 65, 82, 65, 76, 76, 69, 204, 83, 73, 88, 84, 69, 69, - 78, 128, 83, 81, 85, 65, 82, 69, 68, 128, 83, 85, 66, 71, 82, 79, 85, - 208, 83, 85, 82, 82, 79, 85, 78, 196, 70, 73, 70, 84, 69, 69, 78, 128, - 79, 80, 69, 82, 65, 84, 79, 210, 79, 82, 73, 71, 73, 78, 65, 204, 68, 73, - 65, 83, 84, 79, 76, 201, 70, 65, 84, 72, 65, 84, 65, 206, 80, 79, 73, 78, - 84, 69, 82, 128, 83, 84, 82, 65, 73, 71, 72, 212, 85, 80, 87, 65, 82, 68, - 83, 128, 66, 65, 89, 65, 78, 78, 65, 128, 67, 72, 82, 79, 78, 79, 78, - 128, 68, 73, 71, 79, 82, 71, 79, 206, 69, 73, 71, 72, 84, 72, 83, 128, - 70, 73, 78, 71, 69, 82, 69, 196, 71, 65, 89, 65, 78, 78, 65, 128, 72, 65, - 82, 75, 76, 69, 65, 206, 74, 65, 89, 65, 78, 78, 65, 128, 75, 79, 82, 79, - 78, 73, 83, 128, 76, 69, 65, 84, 72, 69, 82, 128, 76, 79, 90, 69, 78, 71, - 69, 128, 77, 65, 75, 83, 85, 82, 65, 128, 78, 79, 45, 66, 82, 69, 65, - 203, 80, 73, 78, 87, 72, 69, 69, 204, 82, 69, 80, 69, 65, 84, 69, 196, - 83, 65, 89, 65, 78, 78, 65, 128, 83, 69, 76, 69, 67, 84, 79, 210, 83, 81, - 85, 73, 71, 71, 76, 197, 84, 69, 84, 65, 82, 84, 79, 211, 84, 82, 79, 77, - 73, 75, 79, 206, 65, 67, 84, 73, 86, 65, 84, 197, 65, 67, 84, 85, 65, 76, - 76, 217, 65, 80, 79, 68, 69, 82, 77, 193, 65, 82, 73, 83, 84, 69, 82, - 193, 65, 83, 84, 69, 82, 73, 83, 203, 66, 69, 84, 87, 69, 69, 78, 128, - 66, 73, 76, 65, 66, 73, 65, 204, 67, 65, 89, 65, 78, 78, 65, 128, 67, 69, - 73, 76, 73, 78, 71, 128, 67, 72, 79, 82, 69, 86, 77, 193, 67, 72, 82, 79, - 78, 79, 85, 128, 67, 76, 79, 84, 72, 69, 83, 128, 68, 65, 77, 77, 65, 84, - 65, 206, 68, 69, 89, 84, 69, 82, 79, 211, 68, 73, 71, 65, 77, 77, 65, - 128, 68, 73, 83, 73, 77, 79, 85, 128, 69, 77, 80, 72, 65, 83, 73, 211, - 70, 69, 77, 73, 78, 73, 78, 197, 73, 78, 72, 69, 82, 69, 78, 212, 73, 78, - 84, 69, 82, 73, 79, 210, 73, 90, 72, 73, 84, 83, 65, 128, 75, 65, 83, 82, - 65, 84, 65, 206, 75, 65, 89, 65, 78, 78, 65, 128, 75, 79, 77, 66, 85, 86, - 65, 128, 76, 65, 89, 65, 78, 78, 65, 128, 76, 79, 71, 79, 84, 89, 80, - 197, 77, 85, 76, 84, 73, 83, 69, 212, 78, 65, 89, 65, 78, 78, 65, 128, - 80, 65, 89, 65, 78, 78, 65, 128, 80, 69, 68, 69, 83, 84, 65, 204, 80, 69, - 84, 65, 76, 76, 69, 196, 81, 85, 65, 82, 84, 69, 82, 211, 82, 71, 89, 73, - 78, 71, 83, 128, 83, 69, 77, 73, 83, 79, 70, 212, 83, 69, 77, 75, 65, 84, - 72, 128, 83, 72, 65, 80, 73, 78, 71, 128, 83, 79, 67, 73, 69, 84, 89, - 128, 83, 80, 65, 82, 75, 76, 69, 128, 83, 80, 69, 67, 73, 65, 76, 128, - 83, 84, 65, 78, 68, 65, 82, 196, 83, 84, 82, 79, 75, 69, 83, 128, 84, 72, - 69, 83, 69, 79, 83, 128, 84, 72, 79, 85, 83, 65, 78, 196, 85, 66, 65, 68, - 65, 77, 65, 128, 65, 65, 89, 65, 78, 78, 65, 128, 65, 66, 65, 70, 73, 76, - 73, 128, 65, 69, 89, 65, 78, 78, 65, 128, 65, 73, 89, 65, 78, 78, 65, - 128, 65, 76, 86, 69, 79, 76, 65, 210, 65, 78, 71, 83, 84, 82, 79, 205, - 65, 78, 71, 85, 76, 65, 82, 128, 65, 78, 85, 83, 86, 65, 82, 193, 65, 80, - 79, 84, 72, 69, 83, 128, 65, 82, 65, 69, 65, 45, 73, 128, 65, 82, 65, 69, - 65, 45, 85, 128, 65, 82, 67, 72, 65, 73, 79, 206, 65, 85, 89, 65, 78, 78, - 65, 128, 66, 65, 65, 82, 69, 82, 85, 128, 66, 65, 73, 82, 75, 65, 78, - 128, 66, 65, 82, 82, 69, 75, 72, 128, 66, 69, 67, 65, 85, 83, 69, 128, - 66, 69, 76, 71, 84, 72, 79, 210, 66, 69, 82, 75, 65, 78, 65, 206, 66, 73, - 68, 69, 78, 84, 65, 204, 66, 79, 85, 78, 68, 65, 82, 217, 66, 82, 73, 83, - 84, 76, 69, 128, 67, 65, 69, 83, 85, 82, 65, 128, 67, 65, 80, 73, 84, 65, - 76, 128, 67, 65, 82, 82, 73, 65, 71, 197, 67, 69, 76, 83, 73, 85, 83, - 128, 67, 72, 65, 77, 73, 76, 73, 128, 67, 79, 77, 80, 65, 82, 69, 128, - 67, 79, 78, 83, 84, 65, 78, 212, 67, 79, 82, 78, 69, 82, 83, 128, 67, 79, - 82, 82, 69, 67, 84, 128, 67, 82, 85, 90, 69, 73, 82, 207, 67, 85, 83, 84, - 79, 77, 69, 210, 67, 87, 69, 79, 82, 84, 72, 128, 68, 65, 71, 65, 76, 71, - 65, 128, 68, 69, 89, 84, 69, 82, 79, 213, 68, 73, 65, 77, 69, 84, 69, - 210, 68, 73, 65, 84, 79, 78, 79, 206, 68, 73, 71, 82, 65, 77, 77, 193, - 68, 73, 80, 76, 79, 85, 78, 128, 68, 73, 82, 69, 67, 84, 76, 217, 68, 73, - 86, 73, 68, 69, 83, 128, 68, 79, 84, 83, 45, 49, 50, 128, 68, 79, 84, 83, - 45, 49, 51, 128, 68, 79, 84, 83, 45, 49, 52, 128, 68, 79, 84, 83, 45, 49, - 53, 128, 68, 79, 84, 83, 45, 49, 54, 128, 68, 79, 84, 83, 45, 49, 55, - 128, 68, 79, 84, 83, 45, 49, 56, 128, 68, 79, 84, 83, 45, 50, 51, 128, - 68, 79, 84, 83, 45, 50, 52, 128, 68, 79, 84, 83, 45, 50, 53, 128, 68, 79, - 84, 83, 45, 50, 54, 128, 68, 79, 84, 83, 45, 50, 55, 128, 68, 79, 84, 83, - 45, 50, 56, 128, 68, 79, 84, 83, 45, 51, 52, 128, 68, 79, 84, 83, 45, 51, - 53, 128, 68, 79, 84, 83, 45, 51, 54, 128, 68, 79, 84, 83, 45, 51, 55, - 128, 68, 79, 84, 83, 45, 51, 56, 128, 68, 79, 84, 83, 45, 52, 53, 128, - 68, 79, 84, 83, 45, 52, 54, 128, 68, 79, 84, 83, 45, 52, 55, 128, 68, 79, - 84, 83, 45, 52, 56, 128, 68, 79, 84, 83, 45, 53, 54, 128, 68, 79, 84, 83, - 45, 53, 55, 128, 68, 79, 84, 83, 45, 53, 56, 128, 68, 79, 84, 83, 45, 54, - 55, 128, 68, 79, 84, 83, 45, 54, 56, 128, 68, 79, 84, 83, 45, 55, 56, - 128, 68, 82, 65, 70, 84, 73, 78, 199, 69, 65, 66, 72, 65, 68, 72, 128, - 69, 65, 68, 72, 65, 68, 72, 128, 69, 66, 69, 70, 73, 76, 73, 128, 69, 73, - 71, 72, 84, 69, 69, 206, 69, 76, 65, 70, 82, 79, 78, 128, 69, 76, 69, 67, - 84, 82, 73, 195, 69, 78, 81, 85, 73, 82, 89, 128, 69, 78, 84, 69, 82, 73, - 78, 199, 69, 84, 78, 65, 72, 84, 65, 128, 69, 86, 69, 78, 73, 78, 71, - 128, 70, 65, 89, 65, 78, 78, 65, 128, 70, 69, 65, 84, 72, 69, 82, 128, - 70, 69, 82, 77, 65, 84, 65, 128, 70, 73, 83, 72, 69, 89, 69, 128, 70, 79, - 78, 71, 77, 65, 78, 128, 70, 79, 85, 82, 84, 69, 69, 206, 70, 82, 79, 87, - 78, 73, 78, 199, 71, 73, 82, 85, 68, 65, 65, 128, 71, 82, 65, 80, 72, 69, - 77, 197, 72, 65, 76, 65, 78, 84, 65, 128, 72, 65, 76, 66, 69, 82, 68, - 128, 72, 65, 89, 65, 78, 78, 65, 128, 72, 69, 65, 68, 73, 78, 71, 128, - 73, 45, 65, 82, 65, 69, 65, 128, 73, 66, 73, 70, 73, 76, 73, 128, 73, 67, - 72, 65, 68, 73, 78, 128, 73, 73, 89, 65, 78, 78, 65, 128, 73, 78, 70, 73, - 78, 73, 84, 217, 73, 78, 84, 69, 82, 69, 83, 212, 73, 79, 68, 72, 65, 68, - 72, 128, 74, 65, 78, 85, 65, 82, 89, 128, 74, 65, 80, 65, 78, 69, 83, - 197, 74, 85, 80, 73, 84, 69, 82, 128, 75, 65, 75, 65, 66, 65, 84, 128, - 75, 65, 82, 65, 84, 84, 79, 128, 75, 65, 82, 79, 82, 73, 73, 128, 75, 79, - 78, 84, 69, 86, 77, 193, 75, 79, 79, 77, 85, 85, 84, 128, 75, 85, 82, 79, - 79, 78, 69, 128, 76, 65, 78, 71, 85, 65, 71, 197, 76, 79, 67, 65, 84, 73, - 79, 206, 77, 65, 73, 75, 85, 82, 79, 128, 77, 65, 73, 77, 85, 65, 78, - 128, 77, 65, 78, 83, 89, 79, 78, 128, 77, 65, 82, 66, 85, 84, 65, 128, - 77, 65, 82, 67, 65, 84, 79, 128, 77, 65, 89, 65, 78, 78, 65, 128, 77, 69, - 71, 65, 84, 79, 78, 128, 77, 69, 82, 67, 85, 82, 89, 128, 77, 73, 75, 85, - 82, 79, 78, 128, 77, 73, 76, 76, 73, 79, 78, 211, 77, 79, 72, 65, 77, 77, - 65, 196, 77, 79, 82, 78, 73, 78, 71, 128, 77, 85, 76, 84, 73, 80, 76, - 197, 78, 65, 84, 73, 79, 78, 65, 204, 78, 69, 71, 65, 84, 73, 79, 206, - 78, 69, 80, 84, 85, 78, 69, 128, 78, 69, 87, 76, 73, 78, 69, 128, 78, 71, - 69, 65, 68, 65, 76, 128, 78, 73, 75, 65, 72, 73, 84, 128, 78, 73, 78, 69, - 84, 69, 69, 206, 79, 66, 79, 70, 73, 76, 73, 128, 79, 67, 84, 79, 66, 69, - 82, 128, 79, 78, 69, 45, 76, 73, 78, 197, 79, 78, 69, 83, 69, 76, 70, - 128, 79, 79, 89, 65, 78, 78, 65, 128, 79, 82, 84, 72, 79, 68, 79, 216, - 79, 85, 84, 76, 73, 78, 69, 128, 80, 69, 76, 65, 83, 84, 79, 206, 80, 69, - 84, 65, 83, 77, 65, 128, 80, 69, 84, 65, 83, 84, 73, 128, 80, 72, 73, 78, - 84, 72, 85, 128, 80, 72, 85, 84, 72, 65, 79, 128, 80, 79, 68, 65, 84, 85, - 83, 128, 80, 82, 69, 67, 69, 68, 69, 128, 80, 82, 69, 67, 69, 68, 69, - 196, 80, 82, 69, 86, 73, 79, 85, 211, 80, 82, 73, 86, 65, 84, 69, 128, - 80, 82, 79, 80, 69, 82, 84, 217, 81, 85, 65, 82, 84, 69, 82, 128, 82, 65, - 75, 72, 65, 78, 71, 128, 82, 65, 80, 73, 83, 77, 65, 128, 82, 65, 89, 65, - 78, 78, 65, 128, 82, 69, 65, 72, 77, 85, 75, 128, 82, 73, 84, 84, 79, 82, - 85, 128, 82, 85, 85, 66, 85, 82, 85, 128, 83, 65, 73, 75, 85, 82, 85, - 128, 83, 65, 76, 84, 73, 82, 69, 128, 83, 65, 77, 80, 72, 65, 79, 128, - 83, 65, 78, 89, 79, 79, 71, 193, 83, 67, 72, 79, 76, 65, 82, 128, 83, 67, - 82, 85, 80, 76, 69, 128, 83, 69, 71, 77, 69, 78, 84, 128, 83, 69, 86, 69, - 78, 84, 89, 128, 83, 73, 77, 73, 76, 65, 82, 128, 83, 73, 82, 73, 78, 71, - 85, 128, 83, 73, 88, 45, 76, 73, 78, 197, 83, 78, 79, 87, 77, 65, 78, - 128, 83, 80, 82, 73, 78, 71, 83, 128, 83, 81, 85, 65, 82, 69, 83, 128, - 83, 84, 65, 86, 82, 79, 83, 128, 83, 84, 65, 86, 82, 79, 85, 128, 83, 84, - 82, 73, 67, 84, 76, 217, 83, 85, 66, 74, 69, 67, 84, 128, 83, 85, 67, 67, - 69, 69, 68, 128, 83, 89, 78, 69, 86, 77, 65, 128, 84, 65, 73, 83, 89, 79, - 85, 128, 84, 65, 84, 87, 69, 69, 76, 128, 84, 67, 72, 69, 72, 69, 72, - 128, 84, 69, 83, 83, 65, 82, 79, 206, 84, 69, 83, 83, 69, 82, 65, 128, - 84, 72, 73, 82, 84, 69, 69, 206, 84, 72, 85, 78, 68, 69, 82, 128, 84, 72, - 85, 82, 73, 83, 65, 218, 84, 73, 78, 65, 71, 77, 65, 128, 84, 73, 82, 79, - 78, 73, 65, 206, 84, 79, 82, 67, 85, 76, 85, 211, 84, 82, 73, 73, 83, 65, - 80, 128, 84, 86, 73, 77, 65, 68, 85, 210, 84, 87, 79, 45, 76, 73, 78, - 197, 85, 45, 69, 79, 45, 69, 85, 128, 85, 66, 85, 70, 73, 76, 73, 128, - 86, 65, 89, 65, 78, 78, 65, 128, 86, 73, 69, 87, 68, 65, 84, 193, 86, 73, - 76, 76, 65, 71, 69, 128, 86, 79, 73, 67, 73, 78, 71, 128, 87, 65, 83, 65, - 76, 76, 65, 205, 89, 65, 89, 65, 78, 78, 65, 128, 89, 80, 79, 82, 82, 79, - 73, 128, 85, 80, 83, 73, 76, 79, 206, 67, 73, 82, 67, 76, 69, 128, 68, - 73, 78, 71, 66, 65, 212, 65, 67, 67, 69, 78, 84, 128, 69, 80, 83, 73, 76, - 79, 206, 83, 76, 65, 78, 84, 69, 196, 72, 65, 78, 85, 78, 79, 207, 83, - 81, 85, 65, 82, 69, 128, 68, 65, 71, 69, 83, 72, 128, 84, 65, 71, 65, 76, - 79, 199, 79, 77, 73, 67, 82, 79, 206, 71, 76, 79, 84, 84, 65, 204, 78, - 65, 83, 75, 65, 80, 201, 67, 79, 82, 78, 69, 82, 128, 69, 76, 69, 77, 69, - 78, 212, 66, 85, 76, 76, 69, 84, 128, 79, 71, 79, 78, 69, 75, 128, 75, - 73, 82, 71, 72, 73, 218, 82, 69, 86, 69, 82, 83, 197, 86, 73, 82, 65, 77, - 65, 128, 68, 73, 65, 77, 79, 78, 196, 68, 79, 85, 66, 76, 69, 128, 78, - 69, 73, 84, 72, 69, 210, 81, 85, 65, 82, 84, 69, 210, 83, 73, 77, 73, 76, - 65, 210, 83, 73, 78, 71, 76, 69, 128, 83, 81, 85, 65, 82, 69, 196, 68, - 79, 84, 76, 69, 83, 211, 78, 85, 78, 65, 86, 73, 203, 83, 79, 76, 73, 68, - 85, 211, 84, 72, 45, 67, 82, 69, 197, 84, 82, 73, 71, 82, 65, 205, 65, - 82, 75, 84, 73, 75, 207, 69, 76, 69, 86, 69, 78, 128, 73, 78, 83, 73, 68, - 69, 128, 79, 80, 69, 78, 73, 78, 199, 83, 85, 66, 83, 69, 84, 128, 84, - 87, 69, 76, 86, 69, 128, 84, 87, 69, 78, 84, 89, 128, 69, 73, 71, 72, 84, - 72, 211, 72, 89, 80, 72, 69, 78, 128, 80, 65, 82, 84, 73, 65, 204, 86, - 82, 65, 67, 72, 89, 128, 65, 82, 82, 79, 87, 83, 128, 70, 65, 76, 76, 73, - 78, 199, 80, 69, 82, 67, 69, 78, 212, 84, 72, 82, 79, 85, 71, 200, 67, - 69, 68, 73, 76, 76, 193, 67, 79, 78, 84, 82, 79, 204, 67, 85, 82, 86, 73, - 78, 199, 68, 73, 71, 82, 65, 80, 200, 69, 81, 85, 65, 76, 83, 128, 70, - 73, 76, 76, 69, 82, 128, 73, 78, 86, 69, 82, 83, 197, 75, 69, 78, 84, 73, - 77, 193, 79, 66, 76, 73, 81, 85, 197, 82, 79, 85, 78, 68, 69, 196, 83, - 65, 78, 89, 65, 75, 193, 84, 67, 72, 69, 72, 69, 200, 84, 72, 73, 82, 84, - 89, 128, 84, 79, 80, 66, 65, 82, 128, 84, 85, 82, 84, 76, 69, 128, 89, - 73, 68, 68, 73, 83, 200, 45, 75, 72, 89, 73, 76, 128, 66, 79, 84, 84, 79, - 77, 128, 67, 69, 78, 84, 82, 69, 196, 67, 79, 78, 84, 65, 73, 206, 67, - 79, 78, 84, 79, 85, 210, 68, 65, 78, 84, 65, 74, 193, 68, 73, 86, 73, 68, - 69, 196, 68, 79, 84, 84, 69, 68, 128, 68, 82, 65, 71, 79, 78, 128, 70, - 73, 70, 84, 72, 83, 128, 72, 85, 78, 68, 82, 69, 196, 75, 79, 77, 66, 85, - 86, 193, 75, 82, 65, 84, 73, 77, 193, 76, 69, 65, 68, 69, 82, 128, 77, - 65, 82, 66, 85, 84, 193, 77, 69, 77, 66, 69, 82, 128, 78, 65, 84, 85, 82, - 65, 204, 80, 69, 78, 67, 73, 76, 128, 81, 65, 77, 65, 84, 83, 128, 83, - 75, 76, 73, 82, 79, 206, 83, 84, 73, 71, 77, 65, 128, 83, 89, 78, 65, 71, - 77, 193, 84, 65, 65, 76, 85, 74, 193, 84, 72, 69, 83, 69, 79, 211, 84, - 79, 78, 71, 85, 69, 128, 65, 67, 67, 79, 85, 78, 212, 65, 80, 76, 79, 85, - 78, 128, 65, 82, 67, 72, 65, 73, 195, 66, 65, 76, 85, 68, 65, 128, 66, - 65, 77, 66, 79, 79, 128, 66, 65, 83, 72, 75, 73, 210, 66, 73, 78, 68, 73, - 78, 199, 66, 73, 83, 72, 79, 80, 128, 66, 79, 87, 84, 73, 69, 128, 67, - 69, 78, 84, 82, 69, 128, 67, 72, 73, 69, 85, 67, 200, 67, 76, 85, 83, 84, - 69, 210, 68, 65, 71, 71, 69, 82, 128, 68, 69, 67, 73, 77, 65, 204, 68, - 73, 86, 73, 68, 69, 128, 69, 83, 67, 65, 80, 69, 128, 70, 69, 65, 84, 72, - 69, 210, 70, 76, 69, 88, 85, 83, 128, 71, 65, 78, 71, 73, 65, 128, 71, - 69, 82, 69, 83, 72, 128, 73, 78, 72, 73, 66, 73, 212, 73, 83, 83, 72, 65, - 82, 128, 73, 90, 72, 73, 84, 83, 193, 75, 72, 73, 69, 85, 75, 200, 75, - 76, 65, 83, 77, 65, 128, 75, 78, 73, 71, 72, 84, 128, 75, 79, 82, 65, 78, - 73, 195, 76, 69, 71, 69, 84, 79, 211, 77, 65, 76, 65, 75, 79, 206, 77, - 79, 82, 84, 65, 82, 128, 78, 69, 71, 65, 84, 69, 196, 78, 73, 78, 69, 84, - 89, 128, 78, 79, 84, 67, 72, 69, 196, 79, 82, 68, 73, 78, 65, 204, 80, - 72, 73, 69, 85, 80, 200, 80, 72, 82, 65, 83, 69, 128, 80, 73, 76, 67, 82, - 79, 215, 80, 76, 65, 71, 73, 79, 211, 83, 69, 82, 73, 70, 83, 128, 83, - 72, 65, 80, 69, 83, 128, 83, 73, 88, 84, 69, 69, 206, 83, 76, 79, 80, 73, - 78, 199, 83, 77, 65, 76, 76, 69, 210, 83, 77, 73, 76, 73, 78, 199, 83, - 80, 69, 69, 67, 72, 128, 84, 69, 76, 69, 73, 65, 128, 84, 69, 76, 73, 83, - 72, 193, 84, 69, 83, 83, 69, 82, 193, 84, 72, 73, 69, 85, 84, 200, 84, - 72, 82, 69, 65, 68, 128, 84, 72, 82, 69, 69, 45, 196, 85, 80, 84, 85, 82, - 78, 128, 89, 69, 76, 76, 79, 87, 128, 89, 79, 45, 89, 65, 69, 128, 89, - 85, 45, 89, 69, 79, 128, 65, 70, 82, 73, 67, 65, 206, 65, 73, 72, 86, 85, - 83, 128, 65, 73, 86, 73, 76, 73, 203, 65, 76, 73, 71, 78, 69, 196, 65, - 78, 67, 72, 79, 82, 128, 65, 78, 78, 85, 73, 84, 217, 65, 80, 65, 65, 84, - 79, 128, 65, 82, 65, 69, 65, 69, 128, 65, 82, 82, 73, 86, 69, 128, 65, - 82, 83, 69, 79, 83, 128, 65, 82, 85, 72, 85, 65, 128, 65, 85, 71, 85, 83, - 84, 128, 65, 86, 69, 82, 65, 71, 197, 66, 65, 68, 71, 69, 82, 128, 66, - 65, 73, 77, 65, 73, 128, 66, 65, 78, 84, 79, 67, 128, 66, 65, 82, 82, 69, - 69, 128, 66, 69, 78, 90, 69, 78, 197, 66, 69, 84, 87, 69, 69, 206, 66, - 69, 89, 89, 65, 76, 128, 66, 73, 84, 84, 69, 82, 128, 66, 79, 82, 85, 84, - 79, 128, 66, 82, 65, 78, 67, 72, 128, 66, 82, 69, 86, 73, 83, 128, 66, - 85, 67, 75, 76, 69, 128, 67, 65, 78, 67, 69, 76, 128, 67, 65, 78, 67, 69, - 82, 128, 67, 65, 84, 65, 87, 65, 128, 67, 65, 85, 84, 73, 79, 206, 67, - 72, 69, 86, 82, 79, 206, 67, 76, 69, 70, 45, 49, 128, 67, 76, 69, 70, 45, - 50, 128, 67, 76, 73, 86, 73, 83, 128, 67, 76, 79, 83, 69, 68, 128, 67, - 79, 78, 73, 67, 65, 204, 67, 79, 82, 80, 83, 69, 128, 67, 85, 82, 82, 69, - 78, 212, 68, 65, 65, 68, 72, 85, 128, 68, 65, 76, 65, 84, 72, 128, 68, - 65, 77, 65, 82, 85, 128, 68, 65, 83, 69, 73, 65, 128, 68, 68, 65, 72, 65, - 76, 128, 68, 69, 76, 69, 84, 69, 128, 68, 72, 65, 65, 76, 85, 128, 68, - 72, 65, 82, 77, 65, 128, 68, 73, 69, 83, 73, 83, 128, 68, 73, 80, 80, 69, - 82, 128, 68, 79, 84, 83, 45, 49, 128, 68, 79, 84, 83, 45, 50, 128, 68, - 79, 84, 83, 45, 51, 128, 68, 79, 84, 83, 45, 52, 128, 68, 79, 84, 83, 45, - 53, 128, 68, 79, 84, 83, 45, 54, 128, 68, 79, 84, 83, 45, 55, 128, 68, - 79, 84, 83, 45, 56, 128, 68, 82, 65, 67, 72, 77, 193, 69, 73, 71, 72, 84, - 72, 128, 69, 73, 71, 72, 84, 89, 128, 69, 78, 65, 82, 88, 73, 211, 69, - 88, 67, 69, 83, 83, 128, 69, 88, 73, 83, 84, 83, 128, 70, 65, 67, 69, 45, - 49, 128, 70, 65, 67, 69, 45, 50, 128, 70, 65, 67, 69, 45, 51, 128, 70, - 65, 67, 69, 45, 52, 128, 70, 65, 67, 69, 45, 53, 128, 70, 65, 67, 69, 45, - 54, 128, 70, 65, 84, 72, 69, 82, 128, 70, 69, 77, 65, 76, 69, 128, 70, - 69, 82, 77, 65, 84, 193, 70, 73, 70, 84, 69, 69, 206, 70, 76, 65, 71, 45, - 49, 128, 70, 76, 65, 71, 45, 50, 128, 70, 76, 65, 71, 45, 51, 128, 70, - 76, 65, 71, 45, 52, 128, 70, 76, 65, 71, 45, 53, 128, 70, 79, 82, 67, 69, - 83, 128, 71, 69, 68, 79, 76, 65, 128, 71, 69, 77, 73, 78, 73, 128, 71, - 69, 78, 69, 82, 73, 195, 71, 72, 65, 73, 78, 85, 128, 71, 72, 85, 78, 78, - 65, 128, 72, 69, 65, 86, 69, 78, 128, 72, 69, 73, 83, 69, 73, 128, 72, - 69, 82, 85, 84, 85, 128, 72, 85, 73, 73, 84, 79, 128, 73, 45, 66, 69, 65, - 77, 128, 73, 77, 73, 83, 69, 79, 211, 73, 78, 71, 87, 65, 90, 128, 73, - 78, 73, 78, 71, 85, 128, 73, 78, 83, 69, 67, 84, 128, 75, 65, 78, 84, 65, - 74, 193, 75, 69, 70, 85, 76, 65, 128, 75, 69, 89, 67, 65, 80, 128, 75, - 72, 79, 77, 85, 84, 128, 75, 76, 73, 84, 79, 78, 128, 75, 79, 82, 85, 78, - 65, 128, 75, 89, 85, 82, 73, 73, 128, 76, 65, 77, 65, 68, 72, 128, 76, - 65, 84, 69, 82, 65, 204, 76, 73, 78, 69, 45, 49, 128, 76, 73, 78, 69, 45, - 51, 128, 76, 73, 78, 69, 45, 55, 128, 76, 73, 78, 69, 45, 57, 128, 76, - 73, 78, 75, 73, 78, 199, 76, 79, 90, 69, 78, 71, 197, 77, 65, 76, 84, 69, - 83, 197, 77, 65, 82, 75, 69, 82, 128, 77, 65, 82, 85, 75, 85, 128, 77, - 65, 84, 82, 73, 88, 128, 77, 65, 88, 73, 77, 65, 128, 77, 69, 68, 73, 85, - 77, 128, 77, 69, 71, 65, 76, 73, 128, 77, 69, 82, 75, 72, 65, 128, 77, - 69, 84, 82, 73, 65, 128, 77, 73, 68, 76, 73, 78, 197, 77, 73, 76, 76, 69, - 84, 128, 77, 73, 78, 73, 77, 65, 128, 77, 79, 68, 69, 76, 83, 128, 77, - 79, 84, 72, 69, 82, 128, 77, 85, 81, 68, 65, 77, 128, 78, 65, 85, 84, 72, - 83, 128, 78, 69, 78, 65, 78, 79, 128, 78, 73, 82, 85, 71, 85, 128, 78, - 79, 75, 72, 85, 75, 128, 78, 79, 77, 73, 78, 65, 204, 78, 85, 77, 66, 69, - 82, 128, 78, 85, 78, 65, 86, 85, 212, 79, 77, 65, 76, 79, 78, 128, 79, - 80, 69, 78, 45, 80, 128, 79, 80, 80, 79, 83, 69, 128, 79, 82, 73, 71, 73, - 78, 128, 79, 84, 72, 65, 76, 65, 206, 80, 65, 76, 65, 84, 65, 204, 80, - 65, 76, 85, 84, 65, 128, 80, 65, 83, 72, 84, 65, 128, 80, 69, 78, 73, 72, - 73, 128, 80, 69, 82, 83, 79, 78, 128, 80, 73, 75, 85, 82, 85, 128, 80, - 73, 80, 73, 78, 71, 128, 80, 73, 83, 67, 69, 83, 128, 80, 79, 73, 78, 84, - 79, 128, 80, 82, 69, 67, 69, 68, 197, 80, 82, 69, 70, 65, 67, 197, 80, - 82, 79, 68, 85, 67, 212, 81, 69, 84, 65, 78, 65, 128, 81, 85, 66, 85, 84, - 83, 128, 82, 69, 80, 69, 65, 84, 128, 82, 69, 84, 85, 82, 78, 128, 82, - 85, 78, 79, 85, 84, 128, 83, 65, 65, 68, 72, 85, 128, 83, 65, 74, 68, 65, - 72, 128, 83, 65, 77, 69, 75, 72, 128, 83, 65, 78, 78, 89, 65, 128, 83, - 65, 84, 85, 82, 78, 128, 83, 67, 82, 69, 69, 78, 128, 83, 67, 82, 73, 80, - 84, 128, 83, 69, 65, 71, 85, 76, 204, 83, 69, 67, 79, 78, 68, 128, 83, - 69, 67, 82, 69, 84, 128, 83, 69, 67, 84, 79, 82, 128, 83, 69, 73, 83, 77, - 65, 128, 83, 69, 82, 86, 73, 67, 197, 83, 72, 65, 68, 68, 65, 128, 83, - 72, 65, 75, 84, 73, 128, 83, 72, 69, 69, 78, 85, 128, 83, 72, 85, 70, 70, - 76, 197, 83, 73, 67, 75, 76, 69, 128, 83, 73, 88, 84, 72, 83, 128, 83, - 76, 79, 87, 76, 89, 128, 83, 80, 65, 84, 72, 73, 128, 83, 80, 73, 82, 73, - 84, 128, 83, 80, 82, 79, 85, 84, 128, 83, 84, 65, 86, 82, 79, 211, 83, - 84, 82, 65, 73, 70, 128, 83, 84, 82, 73, 68, 69, 128, 83, 84, 82, 79, 75, - 69, 211, 83, 85, 66, 73, 84, 79, 128, 83, 85, 67, 67, 69, 69, 196, 83, - 85, 82, 70, 65, 67, 197, 83, 89, 78, 65, 70, 73, 128, 83, 89, 79, 85, 87, - 65, 128, 84, 65, 84, 87, 69, 69, 204, 84, 65, 85, 82, 85, 83, 128, 84, - 69, 78, 85, 84, 79, 128, 84, 72, 65, 65, 76, 85, 128, 84, 72, 65, 72, 65, - 78, 128, 84, 72, 73, 82, 68, 83, 128, 84, 72, 73, 85, 84, 72, 128, 84, - 73, 80, 69, 72, 65, 128, 84, 82, 73, 80, 76, 73, 128, 84, 82, 73, 80, 79, - 68, 128, 84, 83, 72, 85, 71, 83, 128, 84, 84, 69, 72, 69, 72, 128, 84, - 85, 82, 66, 65, 78, 128, 85, 80, 82, 73, 71, 72, 212, 85, 82, 65, 78, 85, - 83, 128, 86, 65, 76, 76, 69, 89, 128, 86, 65, 82, 69, 73, 65, 201, 86, - 65, 82, 73, 65, 78, 212, 86, 65, 82, 73, 75, 65, 128, 86, 73, 67, 84, 79, - 82, 217, 86, 73, 82, 73, 65, 77, 128, 86, 73, 83, 65, 82, 71, 193, 87, - 69, 65, 80, 79, 78, 128, 87, 82, 73, 84, 73, 78, 199, 89, 70, 69, 83, 73, - 83, 128, 89, 79, 45, 89, 69, 79, 128, 89, 80, 83, 73, 76, 73, 128, 84, - 82, 73, 80, 76, 197, 84, 85, 82, 78, 69, 196, 69, 81, 85, 65, 76, 211, - 71, 79, 84, 72, 73, 195, 76, 73, 71, 72, 84, 128, 72, 69, 65, 86, 89, - 128, 77, 73, 68, 68, 76, 197, 83, 73, 78, 71, 76, 197, 66, 76, 79, 67, - 75, 128, 77, 65, 78, 67, 72, 213, 84, 79, 78, 79, 83, 128, 70, 84, 72, - 79, 82, 193, 79, 77, 69, 71, 65, 128, 83, 73, 71, 77, 65, 128, 68, 65, - 83, 73, 65, 128, 83, 85, 66, 83, 69, 212, 67, 76, 79, 83, 69, 196, 65, - 76, 80, 72, 65, 128, 66, 79, 84, 84, 79, 205, 77, 69, 68, 73, 85, 205, - 86, 85, 76, 71, 65, 210, 67, 79, 77, 77, 65, 128, 67, 79, 80, 84, 73, - 195, 67, 79, 82, 78, 69, 210, 68, 69, 76, 84, 65, 128, 69, 81, 85, 65, - 76, 128, 73, 67, 72, 79, 83, 128, 83, 65, 89, 73, 83, 201, 87, 72, 73, - 84, 69, 128, 65, 76, 77, 79, 83, 212, 67, 82, 79, 83, 83, 128, 75, 65, - 80, 80, 65, 128, 76, 65, 77, 68, 65, 128, 84, 72, 69, 84, 65, 128, 89, - 45, 67, 82, 69, 197, 66, 69, 83, 73, 68, 197, 67, 69, 78, 84, 82, 197, - 77, 65, 67, 82, 79, 206, 83, 72, 65, 68, 68, 193, 78, 79, 82, 77, 65, - 204, 84, 87, 69, 78, 84, 217, 68, 65, 83, 72, 69, 196, 76, 69, 78, 71, - 84, 200, 80, 82, 73, 77, 69, 128, 84, 72, 73, 82, 84, 217, 85, 78, 73, - 79, 78, 128, 67, 65, 78, 68, 82, 193, 82, 69, 80, 69, 65, 212, 83, 84, - 82, 79, 75, 197, 84, 69, 77, 80, 85, 211, 68, 79, 84, 84, 69, 196, 82, - 73, 83, 73, 78, 199, 82, 84, 65, 71, 83, 128, 68, 73, 69, 83, 73, 211, - 68, 73, 80, 76, 73, 128, 73, 78, 68, 69, 88, 128, 75, 79, 80, 80, 65, - 128, 78, 65, 66, 76, 65, 128, 79, 84, 84, 65, 86, 193, 83, 84, 65, 70, - 70, 128, 89, 70, 69, 83, 73, 211, 66, 65, 76, 76, 79, 212, 66, 65, 82, - 82, 69, 197, 67, 76, 73, 67, 75, 128, 67, 85, 82, 86, 69, 196, 69, 65, - 82, 84, 72, 128, 70, 69, 78, 67, 69, 128, 70, 73, 70, 84, 89, 128, 76, - 69, 73, 77, 77, 193, 76, 73, 84, 84, 76, 197, 78, 69, 83, 84, 69, 196, - 78, 85, 75, 84, 65, 128, 85, 73, 71, 72, 85, 210, 66, 65, 83, 83, 65, - 128, 66, 82, 73, 68, 71, 197, 67, 72, 82, 79, 77, 193, 67, 85, 66, 69, - 68, 128, 68, 69, 71, 82, 69, 197, 68, 69, 86, 73, 67, 197, 68, 79, 76, - 76, 65, 210, 80, 65, 73, 82, 69, 196, 80, 65, 84, 65, 72, 128, 80, 73, - 69, 67, 69, 128, 83, 67, 72, 87, 65, 128, 83, 75, 69, 87, 69, 196, 84, - 73, 77, 69, 83, 128, 84, 84, 69, 72, 69, 200, 87, 65, 84, 69, 82, 128, - 87, 73, 71, 71, 76, 217, 65, 82, 79, 85, 78, 196, 65, 82, 83, 69, 79, - 211, 66, 82, 79, 75, 69, 206, 67, 65, 82, 69, 84, 128, 67, 76, 73, 70, - 70, 128, 68, 65, 71, 69, 83, 200, 70, 76, 79, 82, 65, 204, 72, 69, 65, - 82, 84, 128, 76, 65, 77, 69, 68, 128, 76, 85, 78, 65, 84, 197, 77, 65, - 80, 73, 81, 128, 78, 45, 67, 82, 69, 197, 80, 79, 83, 84, 65, 204, 80, - 84, 72, 65, 72, 193, 83, 67, 72, 69, 77, 193, 83, 69, 71, 79, 76, 128, - 83, 72, 65, 68, 69, 128, 83, 84, 82, 69, 83, 211, 84, 72, 79, 82, 78, - 128, 84, 73, 84, 76, 79, 128, 84, 79, 79, 84, 72, 128, 86, 65, 82, 69, - 73, 193, 90, 73, 71, 90, 65, 199, 90, 81, 65, 80, 72, 193, 65, 76, 65, - 80, 72, 128, 65, 76, 65, 89, 72, 197, 66, 69, 65, 77, 69, 196, 66, 73, - 78, 65, 82, 217, 66, 79, 87, 84, 73, 197, 67, 72, 69, 67, 75, 128, 67, - 76, 79, 84, 72, 128, 67, 85, 82, 86, 69, 128, 68, 65, 76, 69, 84, 128, - 68, 65, 78, 68, 65, 128, 68, 68, 65, 72, 65, 204, 68, 69, 65, 84, 72, - 128, 69, 84, 69, 82, 79, 206, 70, 65, 67, 84, 79, 210, 70, 73, 71, 85, - 82, 197, 70, 76, 79, 79, 82, 128, 70, 79, 82, 84, 89, 128, 71, 65, 80, - 80, 69, 196, 71, 69, 78, 73, 75, 201, 71, 72, 79, 83, 84, 128, 71, 72, - 85, 78, 78, 193, 71, 78, 89, 73, 83, 128, 71, 79, 82, 71, 73, 128, 72, - 65, 77, 90, 65, 128, 72, 73, 82, 73, 81, 128, 72, 79, 76, 65, 77, 128, - 72, 79, 82, 83, 69, 128, 72, 87, 65, 73, 82, 128, 75, 65, 90, 65, 75, - 200, 75, 73, 89, 69, 79, 203, 75, 76, 65, 83, 77, 193, 76, 65, 66, 79, - 82, 128, 76, 65, 82, 71, 69, 210, 77, 69, 84, 65, 76, 128, 78, 79, 84, - 69, 83, 128, 79, 71, 79, 78, 69, 203, 79, 76, 73, 71, 79, 206, 79, 82, - 78, 65, 84, 197, 80, 73, 65, 83, 77, 193, 80, 76, 65, 78, 67, 203, 80, - 79, 73, 78, 84, 128, 80, 82, 79, 84, 79, 211, 81, 85, 69, 69, 78, 128, - 81, 85, 73, 76, 76, 128, 83, 65, 77, 80, 73, 128, 83, 67, 82, 69, 69, - 206, 83, 69, 71, 78, 79, 128, 83, 69, 82, 73, 70, 211, 83, 69, 83, 65, - 77, 197, 83, 72, 65, 82, 80, 128, 83, 72, 67, 72, 65, 128, 83, 72, 69, - 69, 80, 128, 83, 72, 69, 76, 76, 128, 83, 72, 73, 77, 65, 128, 83, 72, - 87, 65, 65, 128, 83, 72, 87, 73, 73, 128, 83, 72, 87, 79, 79, 128, 83, - 73, 71, 78, 83, 128, 83, 73, 78, 68, 72, 201, 83, 77, 65, 76, 76, 128, - 83, 80, 73, 82, 73, 212, 83, 84, 79, 67, 75, 128, 83, 84, 85, 68, 89, - 128, 83, 85, 75, 85, 78, 128, 84, 65, 78, 78, 69, 196, 84, 69, 76, 79, - 85, 211, 84, 72, 87, 65, 65, 128, 84, 73, 71, 69, 82, 128, 84, 73, 75, - 69, 85, 212, 84, 82, 85, 78, 75, 128, 84, 83, 65, 68, 73, 128, 84, 83, - 72, 69, 71, 128, 84, 83, 72, 69, 83, 128, 84, 87, 69, 76, 86, 197, 87, - 72, 69, 65, 84, 128, 89, 79, 45, 89, 65, 128, 89, 85, 45, 89, 69, 128, - 90, 90, 73, 69, 84, 128, 45, 67, 72, 65, 76, 128, 45, 75, 72, 89, 85, - 196, 45, 80, 72, 82, 85, 128, 65, 68, 68, 65, 75, 128, 65, 71, 65, 73, - 78, 128, 65, 72, 83, 68, 65, 128, 65, 76, 73, 70, 85, 128, 65, 77, 79, - 85, 78, 212, 65, 78, 80, 69, 65, 128, 65, 80, 82, 73, 76, 128, 65, 82, - 73, 69, 83, 128, 65, 82, 76, 65, 85, 199, 66, 66, 73, 69, 80, 128, 66, - 66, 73, 69, 84, 128, 66, 66, 73, 69, 88, 128, 66, 66, 85, 79, 80, 128, - 66, 66, 85, 79, 88, 128, 66, 66, 85, 82, 88, 128, 66, 69, 69, 84, 65, - 128, 66, 69, 72, 69, 72, 128, 66, 69, 73, 84, 72, 128, 66, 73, 78, 68, - 73, 128, 66, 73, 82, 71, 65, 128, 66, 76, 65, 78, 75, 128, 66, 76, 79, - 79, 68, 128, 66, 82, 65, 67, 69, 128, 66, 82, 65, 78, 67, 200, 66, 82, - 69, 65, 84, 200, 66, 82, 85, 83, 72, 128, 66, 83, 84, 65, 82, 128, 66, - 85, 76, 76, 69, 212, 67, 65, 77, 78, 85, 195, 67, 65, 78, 67, 69, 204, - 67, 69, 65, 76, 67, 128, 67, 69, 73, 82, 84, 128, 67, 72, 65, 68, 65, - 128, 67, 72, 65, 73, 82, 128, 67, 72, 65, 78, 71, 128, 67, 72, 73, 76, - 68, 128, 67, 72, 73, 78, 71, 128, 67, 72, 79, 75, 69, 128, 67, 72, 85, - 76, 65, 128, 67, 72, 85, 79, 80, 128, 67, 72, 85, 79, 84, 128, 67, 72, - 85, 79, 88, 128, 67, 72, 85, 82, 88, 128, 67, 72, 89, 82, 88, 128, 67, - 76, 79, 85, 68, 128, 67, 79, 69, 78, 71, 128, 67, 79, 76, 79, 82, 128, - 67, 79, 77, 69, 84, 128, 67, 79, 77, 77, 79, 206, 67, 79, 86, 69, 82, - 128, 67, 82, 79, 73, 88, 128, 68, 65, 65, 83, 85, 128, 68, 65, 76, 65, - 84, 200, 68, 65, 77, 77, 65, 128, 68, 65, 82, 71, 65, 128, 68, 65, 86, - 73, 68, 128, 68, 68, 68, 72, 65, 128, 68, 68, 73, 69, 80, 128, 68, 68, - 73, 69, 88, 128, 68, 68, 85, 79, 80, 128, 68, 68, 85, 79, 88, 128, 68, - 68, 85, 82, 88, 128, 68, 69, 76, 69, 84, 197, 68, 73, 86, 73, 68, 197, - 68, 79, 77, 65, 73, 206, 68, 82, 73, 86, 69, 128, 69, 69, 75, 65, 65, - 128, 69, 76, 69, 86, 69, 206, 69, 76, 73, 70, 73, 128, 69, 78, 84, 69, - 82, 128, 69, 79, 76, 72, 88, 128, 69, 85, 45, 69, 85, 128, 69, 88, 73, - 83, 84, 128, 70, 65, 65, 70, 85, 128, 70, 65, 73, 72, 85, 128, 70, 65, - 84, 72, 65, 128, 70, 69, 65, 82, 78, 128, 70, 69, 77, 65, 76, 197, 70, - 72, 84, 79, 82, 193, 70, 73, 69, 76, 68, 128, 70, 73, 70, 84, 72, 128, - 70, 73, 71, 72, 84, 128, 70, 73, 76, 76, 69, 196, 70, 73, 78, 73, 84, - 197, 70, 76, 85, 84, 69, 128, 70, 79, 82, 67, 69, 128, 70, 79, 82, 84, - 69, 128, 70, 82, 69, 78, 67, 200, 70, 82, 79, 87, 78, 128, 71, 65, 65, - 70, 85, 128, 71, 65, 68, 79, 76, 128, 71, 65, 77, 65, 76, 128, 71, 65, - 78, 77, 65, 128, 71, 65, 82, 79, 78, 128, 71, 69, 82, 69, 83, 200, 71, - 69, 82, 77, 65, 206, 71, 71, 73, 69, 80, 128, 71, 71, 73, 69, 88, 128, - 71, 71, 85, 79, 80, 128, 71, 71, 85, 79, 84, 128, 71, 71, 85, 79, 88, - 128, 71, 71, 85, 82, 88, 128, 71, 72, 65, 73, 78, 128, 71, 73, 77, 69, - 76, 128, 71, 73, 78, 73, 73, 128, 71, 76, 69, 73, 67, 200, 71, 82, 65, - 73, 78, 128, 71, 82, 65, 83, 83, 128, 72, 45, 84, 89, 80, 197, 72, 65, - 71, 76, 65, 218, 72, 65, 73, 84, 85, 128, 72, 65, 77, 77, 69, 210, 72, - 65, 78, 68, 83, 128, 72, 69, 65, 86, 69, 206, 72, 73, 68, 73, 78, 199, - 72, 76, 73, 69, 80, 128, 72, 76, 73, 69, 88, 128, 72, 76, 85, 79, 80, - 128, 72, 76, 85, 79, 88, 128, 72, 76, 85, 82, 88, 128, 72, 76, 89, 82, - 88, 128, 72, 77, 73, 69, 80, 128, 72, 77, 73, 69, 88, 128, 72, 77, 85, - 79, 80, 128, 72, 77, 85, 79, 88, 128, 72, 77, 85, 82, 88, 128, 72, 77, - 89, 82, 88, 128, 72, 78, 73, 69, 80, 128, 72, 78, 73, 69, 84, 128, 72, - 78, 73, 69, 88, 128, 72, 78, 85, 79, 88, 128, 72, 79, 79, 82, 85, 128, - 72, 79, 85, 83, 69, 128, 72, 85, 82, 65, 78, 128, 72, 88, 73, 69, 80, - 128, 72, 88, 73, 69, 84, 128, 72, 88, 73, 69, 88, 128, 72, 88, 85, 79, - 80, 128, 72, 88, 85, 79, 84, 128, 72, 88, 85, 79, 88, 128, 72, 89, 80, - 72, 69, 206, 73, 67, 72, 79, 85, 128, 73, 71, 71, 87, 83, 128, 73, 83, - 65, 75, 73, 193, 74, 74, 73, 69, 80, 128, 74, 74, 73, 69, 84, 128, 74, - 74, 73, 69, 88, 128, 74, 74, 85, 79, 80, 128, 74, 74, 85, 79, 88, 128, - 74, 74, 85, 82, 88, 128, 75, 65, 65, 70, 85, 128, 75, 65, 73, 82, 73, - 128, 75, 65, 83, 82, 65, 128, 75, 65, 84, 65, 86, 193, 75, 65, 85, 78, - 65, 128, 75, 69, 69, 83, 85, 128, 75, 69, 72, 69, 72, 128, 75, 69, 76, - 86, 73, 206, 75, 72, 85, 65, 84, 128, 75, 72, 87, 65, 73, 128, 75, 78, - 73, 70, 69, 128, 75, 79, 79, 80, 79, 128, 75, 79, 82, 69, 65, 206, 75, - 85, 83, 77, 65, 128, 75, 88, 87, 65, 65, 128, 75, 88, 87, 69, 69, 128, - 76, 45, 84, 89, 80, 197, 76, 65, 65, 77, 85, 128, 76, 65, 71, 85, 83, - 128, 76, 65, 77, 66, 68, 193, 76, 65, 85, 75, 65, 218, 76, 69, 77, 79, - 73, 128, 76, 73, 66, 82, 65, 128, 76, 73, 77, 73, 84, 128, 76, 79, 78, - 71, 65, 128, 76, 79, 85, 82, 69, 128, 77, 65, 68, 68, 65, 128, 77, 65, - 68, 68, 65, 200, 77, 65, 72, 72, 65, 128, 77, 65, 73, 82, 85, 128, 77, - 65, 78, 78, 65, 128, 77, 65, 78, 78, 65, 218, 77, 65, 81, 65, 70, 128, - 77, 65, 82, 67, 72, 128, 77, 65, 83, 79, 82, 193, 77, 69, 69, 77, 85, - 128, 77, 69, 73, 90, 73, 128, 77, 69, 76, 79, 78, 128, 77, 69, 77, 66, - 69, 210, 77, 69, 82, 75, 72, 193, 77, 69, 84, 69, 71, 128, 77, 69, 90, - 90, 79, 128, 77, 71, 73, 69, 88, 128, 77, 71, 85, 79, 80, 128, 77, 71, - 85, 79, 88, 128, 77, 71, 85, 82, 88, 128, 77, 73, 75, 82, 73, 128, 77, - 73, 75, 82, 79, 206, 77, 79, 68, 85, 76, 207, 77, 79, 85, 78, 68, 128, - 77, 79, 85, 84, 72, 128, 77, 85, 78, 65, 72, 128, 77, 85, 83, 73, 67, - 128, 78, 65, 82, 82, 79, 215, 78, 65, 85, 68, 73, 218, 78, 66, 73, 69, - 80, 128, 78, 66, 73, 69, 88, 128, 78, 66, 85, 82, 88, 128, 78, 66, 89, - 82, 88, 128, 78, 68, 73, 69, 88, 128, 78, 68, 85, 82, 88, 128, 78, 71, - 65, 65, 73, 128, 78, 71, 73, 69, 80, 128, 78, 71, 73, 69, 88, 128, 78, - 71, 79, 69, 72, 128, 78, 71, 85, 79, 84, 128, 78, 71, 85, 79, 88, 128, - 78, 74, 73, 69, 80, 128, 78, 74, 73, 69, 84, 128, 78, 74, 73, 69, 88, - 128, 78, 74, 85, 79, 88, 128, 78, 74, 85, 82, 88, 128, 78, 74, 89, 82, - 88, 128, 78, 78, 71, 65, 65, 128, 78, 78, 71, 73, 73, 128, 78, 78, 71, - 79, 79, 128, 78, 79, 79, 78, 85, 128, 78, 79, 84, 67, 72, 128, 78, 79, - 84, 84, 79, 128, 78, 82, 85, 82, 88, 128, 78, 82, 89, 82, 88, 128, 78, - 85, 77, 69, 82, 207, 78, 89, 73, 69, 80, 128, 78, 89, 73, 69, 84, 128, - 78, 89, 73, 69, 88, 128, 78, 89, 85, 79, 80, 128, 78, 89, 85, 79, 88, - 128, 78, 90, 73, 69, 80, 128, 78, 90, 73, 69, 88, 128, 78, 90, 85, 79, - 88, 128, 78, 90, 85, 82, 88, 128, 78, 90, 89, 82, 88, 128, 79, 66, 74, - 69, 67, 212, 79, 78, 75, 65, 82, 128, 79, 80, 84, 73, 79, 206, 79, 84, - 72, 65, 76, 128, 79, 88, 69, 73, 65, 201, 80, 65, 65, 84, 85, 128, 80, - 65, 83, 69, 81, 128, 80, 65, 83, 85, 81, 128, 80, 65, 84, 65, 75, 128, - 80, 65, 90, 69, 82, 128, 80, 69, 69, 90, 73, 128, 80, 69, 72, 69, 72, - 128, 80, 69, 73, 84, 72, 128, 80, 69, 78, 83, 85, 128, 80, 69, 79, 82, - 84, 200, 80, 69, 82, 84, 72, 207, 80, 69, 83, 69, 84, 193, 80, 72, 78, - 65, 69, 203, 80, 72, 85, 78, 71, 128, 80, 73, 65, 78, 79, 128, 80, 76, - 85, 84, 79, 128, 80, 79, 78, 68, 79, 128, 80, 79, 87, 69, 82, 128, 80, - 82, 73, 78, 84, 128, 80, 82, 79, 79, 70, 128, 80, 82, 79, 86, 69, 128, - 81, 65, 65, 70, 85, 128, 81, 65, 68, 77, 65, 128, 81, 65, 82, 78, 69, - 217, 81, 65, 84, 65, 78, 128, 81, 72, 87, 65, 65, 128, 81, 72, 87, 69, - 69, 128, 82, 45, 67, 82, 69, 197, 82, 65, 73, 68, 65, 128, 82, 65, 83, - 79, 85, 204, 82, 65, 84, 73, 79, 128, 82, 69, 65, 67, 72, 128, 82, 69, - 67, 79, 82, 196, 82, 69, 84, 85, 82, 206, 82, 69, 86, 73, 65, 128, 82, - 69, 86, 77, 65, 128, 82, 72, 79, 84, 73, 195, 82, 73, 86, 69, 82, 128, - 82, 78, 79, 79, 78, 128, 82, 79, 66, 65, 84, 128, 82, 82, 85, 79, 88, - 128, 82, 82, 85, 82, 88, 128, 82, 82, 89, 82, 88, 128, 82, 85, 80, 73, - 73, 128, 82, 87, 65, 72, 65, 128, 83, 65, 68, 72, 69, 128, 83, 65, 77, - 69, 75, 200, 83, 65, 77, 89, 79, 203, 83, 65, 85, 73, 76, 128, 83, 69, - 69, 78, 85, 128, 83, 69, 73, 83, 77, 193, 83, 69, 78, 84, 73, 128, 83, - 72, 69, 69, 78, 128, 83, 72, 69, 81, 69, 204, 83, 72, 69, 86, 65, 128, - 83, 72, 79, 79, 84, 128, 83, 72, 85, 79, 80, 128, 83, 72, 85, 79, 88, - 128, 83, 72, 85, 82, 88, 128, 83, 72, 89, 82, 88, 128, 83, 73, 88, 84, - 72, 128, 83, 73, 88, 84, 89, 128, 83, 76, 65, 86, 69, 128, 83, 76, 73, - 67, 69, 128, 83, 76, 79, 80, 69, 128, 83, 77, 69, 65, 82, 128, 83, 77, - 73, 76, 69, 128, 83, 78, 65, 75, 69, 128, 83, 78, 79, 85, 84, 128, 83, - 79, 85, 78, 68, 128, 83, 79, 87, 73, 76, 207, 83, 80, 69, 65, 82, 128, - 83, 80, 79, 79, 78, 128, 83, 80, 85, 78, 71, 211, 83, 81, 85, 73, 83, - 200, 83, 83, 73, 69, 80, 128, 83, 83, 73, 69, 88, 128, 83, 83, 89, 82, - 88, 128, 83, 84, 65, 78, 68, 128, 83, 84, 65, 82, 75, 128, 83, 84, 69, - 65, 77, 128, 83, 84, 79, 78, 69, 128, 83, 87, 69, 69, 84, 128, 83, 89, - 82, 77, 65, 128, 84, 65, 80, 69, 82, 128, 84, 67, 72, 69, 72, 128, 84, - 69, 73, 87, 83, 128, 84, 69, 86, 73, 82, 128, 84, 72, 73, 82, 68, 128, - 84, 72, 73, 84, 65, 128, 84, 72, 79, 78, 71, 128, 84, 72, 85, 78, 71, - 128, 84, 73, 78, 78, 69, 128, 84, 73, 80, 80, 73, 128, 84, 76, 72, 69, - 69, 128, 84, 82, 65, 67, 75, 128, 84, 82, 73, 84, 79, 211, 84, 83, 69, - 82, 69, 128, 84, 84, 83, 69, 69, 128, 84, 85, 71, 82, 73, 203, 84, 89, - 80, 69, 45, 177, 84, 89, 80, 69, 45, 178, 84, 89, 80, 69, 45, 179, 84, - 89, 80, 69, 45, 180, 84, 89, 80, 69, 45, 181, 84, 89, 80, 69, 45, 182, - 84, 89, 80, 69, 45, 183, 85, 80, 87, 65, 82, 196, 86, 65, 65, 86, 85, - 128, 86, 65, 83, 73, 83, 128, 86, 65, 84, 72, 89, 128, 86, 69, 67, 84, - 79, 210, 86, 73, 82, 71, 65, 128, 86, 73, 82, 71, 79, 128, 86, 79, 76, - 85, 77, 197, 87, 65, 65, 86, 85, 128, 87, 65, 83, 76, 65, 128, 87, 65, - 84, 67, 72, 128, 87, 73, 78, 74, 65, 128, 87, 79, 77, 65, 78, 128, 87, - 82, 69, 65, 84, 200, 87, 82, 79, 78, 71, 128, 89, 65, 45, 89, 79, 128, - 89, 65, 65, 68, 79, 128, 89, 65, 65, 82, 85, 128, 89, 69, 79, 45, 79, - 128, 89, 69, 79, 45, 85, 128, 89, 69, 84, 73, 86, 128, 89, 85, 45, 69, - 79, 128, 90, 65, 82, 81, 65, 128, 90, 65, 89, 73, 78, 128, 90, 72, 85, - 79, 80, 128, 90, 72, 85, 79, 88, 128, 90, 72, 85, 82, 88, 128, 90, 72, - 89, 82, 88, 128, 90, 73, 76, 68, 69, 128, 90, 73, 78, 79, 82, 128, 90, - 89, 71, 79, 83, 128, 90, 90, 73, 69, 80, 128, 90, 90, 73, 69, 88, 128, - 90, 90, 85, 82, 88, 128, 90, 90, 89, 82, 88, 128, 84, 72, 82, 69, 197, - 76, 69, 70, 84, 128, 90, 69, 82, 79, 128, 79, 71, 72, 65, 205, 67, 85, - 82, 76, 217, 78, 79, 82, 84, 200, 66, 85, 72, 73, 196, 80, 79, 73, 78, - 212, 83, 79, 85, 84, 200, 82, 73, 78, 71, 128, 84, 65, 67, 75, 128, 68, - 79, 87, 78, 128, 78, 45, 65, 82, 217, 82, 69, 83, 84, 128, 66, 69, 76, - 79, 215, 68, 65, 83, 72, 128, 71, 72, 65, 73, 206, 73, 79, 84, 65, 128, - 67, 79, 77, 77, 193, 86, 65, 82, 73, 193, 66, 82, 69, 86, 197, 84, 84, - 72, 65, 128, 65, 67, 85, 84, 197, 66, 69, 84, 65, 128, 67, 72, 69, 83, - 211, 71, 82, 65, 86, 197, 83, 72, 69, 76, 204, 84, 72, 69, 84, 193, 90, - 69, 84, 65, 128, 83, 79, 85, 78, 196, 85, 78, 73, 79, 206, 69, 73, 71, - 72, 212, 78, 79, 84, 69, 128, 70, 79, 82, 84, 217, 73, 77, 65, 71, 197, - 80, 76, 85, 83, 128, 65, 71, 79, 71, 201, 68, 79, 84, 83, 128, 69, 77, - 80, 84, 217, 72, 65, 76, 70, 128, 72, 69, 65, 82, 212, 83, 85, 73, 84, - 128, 70, 73, 76, 76, 128, 75, 65, 84, 79, 128, 76, 65, 82, 71, 197, 83, - 72, 65, 68, 128, 65, 76, 69, 70, 128, 67, 65, 82, 69, 212, 67, 85, 82, - 76, 128, 70, 65, 82, 83, 201, 75, 65, 80, 80, 193, 77, 79, 79, 78, 128, - 83, 85, 78, 71, 128, 84, 73, 67, 75, 128, 67, 76, 69, 70, 128, 67, 82, - 79, 83, 211, 70, 65, 67, 69, 128, 70, 73, 82, 69, 128, 77, 65, 68, 68, - 193, 81, 85, 65, 68, 128, 83, 84, 69, 77, 128, 84, 67, 72, 69, 200, 84, - 73, 77, 69, 211, 84, 83, 72, 69, 199, 65, 76, 84, 65, 128, 66, 69, 71, - 73, 206, 66, 69, 72, 69, 200, 67, 72, 69, 69, 128, 67, 82, 79, 80, 128, - 68, 65, 77, 77, 193, 70, 65, 84, 72, 193, 72, 65, 78, 68, 128, 74, 79, - 73, 78, 128, 75, 65, 83, 82, 193, 75, 69, 72, 69, 200, 75, 87, 65, 65, - 128, 78, 71, 79, 69, 200, 80, 69, 72, 69, 200, 82, 65, 70, 69, 128, 82, - 78, 79, 79, 206, 82, 84, 65, 71, 211, 83, 69, 86, 69, 206, 83, 72, 65, - 82, 208, 83, 72, 73, 78, 128, 84, 72, 65, 65, 128, 84, 72, 69, 69, 128, - 86, 65, 78, 69, 128, 87, 65, 86, 69, 128, 65, 76, 76, 79, 128, 66, 73, - 82, 68, 128, 67, 65, 82, 79, 206, 67, 72, 69, 67, 203, 67, 72, 82, 79, - 193, 67, 73, 69, 85, 195, 67, 87, 65, 65, 128, 68, 69, 76, 84, 193, 70, - 79, 79, 84, 128, 71, 82, 65, 83, 211, 72, 65, 84, 65, 198, 75, 69, 84, - 84, 201, 76, 76, 76, 65, 128, 76, 79, 79, 80, 128, 77, 85, 83, 73, 195, - 77, 87, 65, 65, 128, 78, 87, 65, 65, 128, 79, 85, 84, 69, 210, 79, 88, - 69, 73, 193, 80, 69, 68, 65, 204, 80, 79, 76, 69, 128, 80, 82, 73, 77, - 197, 80, 87, 65, 65, 128, 82, 79, 79, 84, 128, 82, 85, 80, 69, 197, 83, - 67, 72, 87, 193, 83, 69, 69, 78, 128, 83, 72, 87, 65, 128, 83, 73, 76, - 75, 128, 83, 84, 65, 82, 212, 83, 87, 65, 65, 128, 84, 72, 73, 73, 128, - 84, 87, 65, 65, 128, 87, 73, 78, 68, 128, 89, 73, 87, 78, 128, 89, 87, - 65, 65, 128, 90, 72, 69, 69, 128, 45, 68, 90, 85, 196, 65, 80, 69, 83, - 207, 65, 82, 71, 73, 128, 66, 66, 85, 84, 128, 66, 69, 65, 84, 128, 66, - 76, 65, 68, 197, 66, 76, 85, 69, 128, 66, 79, 78, 69, 128, 66, 82, 85, - 83, 200, 66, 90, 85, 78, 199, 67, 65, 82, 84, 128, 67, 72, 65, 82, 128, - 67, 72, 73, 78, 128, 67, 85, 79, 80, 128, 67, 85, 82, 86, 197, 67, 87, - 73, 73, 128, 67, 87, 79, 79, 128, 68, 65, 76, 69, 212, 68, 68, 85, 82, - 128, 68, 90, 72, 65, 128, 68, 90, 72, 69, 128, 68, 90, 74, 69, 128, 69, - 82, 65, 83, 197, 70, 69, 69, 68, 128, 70, 73, 82, 83, 212, 70, 73, 83, - 72, 128, 70, 73, 84, 65, 128, 70, 76, 65, 84, 128, 70, 82, 79, 71, 128, - 70, 87, 65, 65, 128, 71, 65, 84, 69, 128, 71, 67, 73, 71, 128, 71, 71, - 79, 80, 128, 71, 71, 85, 79, 128, 71, 72, 65, 68, 128, 71, 72, 65, 78, - 128, 71, 72, 72, 65, 128, 71, 73, 77, 69, 204, 71, 79, 65, 76, 128, 71, - 79, 76, 68, 128, 71, 82, 65, 67, 197, 71, 83, 85, 77, 128, 71, 89, 65, - 83, 128, 71, 89, 79, 78, 128, 72, 65, 86, 69, 128, 72, 66, 65, 83, 193, - 72, 72, 65, 65, 128, 72, 73, 69, 85, 200, 72, 79, 82, 73, 128, 72, 88, - 73, 84, 128, 72, 88, 79, 80, 128, 72, 88, 85, 79, 128, 73, 69, 85, 78, - 199, 74, 65, 68, 69, 128, 74, 69, 69, 77, 128, 74, 72, 65, 78, 128, 74, - 72, 69, 72, 128, 74, 74, 73, 69, 128, 74, 74, 85, 84, 128, 75, 72, 65, - 72, 128, 75, 72, 65, 78, 199, 75, 72, 65, 82, 128, 75, 72, 69, 73, 128, - 75, 72, 72, 65, 128, 75, 78, 73, 70, 197, 75, 83, 83, 65, 128, 75, 87, - 73, 73, 128, 75, 87, 79, 79, 128, 76, 69, 65, 70, 128, 76, 73, 87, 78, - 128, 76, 79, 78, 71, 128, 76, 79, 78, 71, 193, 76, 79, 87, 45, 185, 76, - 87, 65, 65, 128, 76, 87, 73, 73, 128, 76, 87, 79, 79, 128, 77, 69, 65, - 84, 128, 77, 69, 69, 77, 128, 77, 69, 83, 79, 128, 77, 73, 69, 85, 205, - 77, 79, 85, 78, 196, 77, 87, 73, 73, 128, 77, 87, 79, 79, 128, 78, 65, - 77, 69, 128, 78, 65, 78, 65, 128, 78, 66, 73, 69, 128, 78, 73, 69, 85, - 206, 78, 78, 78, 65, 128, 78, 79, 68, 69, 128, 78, 89, 73, 80, 128, 78, - 89, 79, 80, 128, 78, 90, 85, 80, 128, 80, 65, 71, 69, 128, 80, 65, 80, - 69, 210, 80, 65, 87, 78, 128, 80, 72, 65, 82, 128, 80, 73, 69, 85, 208, - 80, 73, 87, 82, 128, 80, 76, 65, 67, 197, 80, 79, 85, 78, 196, 80, 87, - 73, 73, 128, 80, 87, 79, 79, 128, 81, 85, 79, 84, 197, 82, 65, 89, 83, - 128, 82, 66, 65, 83, 193, 82, 73, 69, 85, 204, 82, 73, 83, 72, 128, 82, - 79, 79, 75, 128, 82, 87, 65, 65, 128, 83, 65, 76, 76, 193, 83, 65, 76, - 84, 128, 83, 69, 65, 76, 128, 83, 72, 65, 65, 128, 83, 72, 65, 84, 128, - 83, 72, 69, 69, 128, 83, 72, 69, 73, 128, 83, 72, 72, 65, 128, 83, 72, - 73, 70, 212, 83, 72, 79, 71, 201, 83, 72, 85, 82, 128, 83, 72, 87, 69, - 128, 83, 72, 87, 73, 128, 83, 72, 87, 79, 128, 83, 76, 85, 82, 128, 83, - 77, 65, 83, 200, 83, 78, 79, 85, 212, 83, 80, 65, 68, 197, 83, 81, 85, - 65, 212, 83, 85, 75, 85, 206, 83, 87, 73, 73, 128, 83, 87, 79, 79, 128, - 84, 69, 88, 84, 128, 84, 72, 69, 82, 197, 84, 72, 79, 79, 128, 84, 73, - 77, 69, 128, 84, 73, 87, 78, 128, 84, 76, 72, 65, 128, 84, 76, 72, 69, - 128, 84, 76, 72, 73, 128, 84, 76, 72, 79, 128, 84, 82, 85, 69, 128, 84, - 83, 72, 65, 128, 84, 83, 72, 69, 128, 84, 84, 72, 79, 128, 84, 87, 73, - 73, 128, 84, 87, 79, 79, 128, 85, 78, 68, 69, 210, 87, 65, 76, 75, 128, - 87, 65, 83, 76, 193, 87, 65, 84, 69, 210, 87, 72, 79, 76, 197, 87, 73, - 78, 69, 128, 87, 79, 79, 68, 128, 87, 89, 78, 78, 128, 89, 79, 45, 73, - 128, 89, 79, 71, 72, 128, 89, 85, 45, 73, 128, 89, 87, 73, 73, 128, 89, - 87, 79, 79, 128, 90, 65, 73, 78, 128, 90, 65, 81, 69, 198, 90, 72, 65, - 82, 128, 90, 76, 65, 77, 193, 45, 67, 72, 65, 210, 65, 69, 83, 67, 128, - 65, 72, 83, 65, 128, 65, 73, 76, 77, 128, 65, 73, 78, 78, 128, 65, 75, - 66, 65, 210, 65, 76, 71, 73, 218, 65, 76, 76, 65, 200, 65, 77, 80, 83, - 128, 65, 78, 75, 72, 128, 65, 78, 83, 85, 218, 65, 85, 78, 78, 128, 65, - 89, 65, 72, 128, 66, 65, 72, 84, 128, 66, 65, 82, 83, 128, 66, 65, 83, - 69, 128, 66, 66, 65, 80, 128, 66, 66, 65, 84, 128, 66, 66, 65, 88, 128, - 66, 66, 69, 80, 128, 66, 66, 69, 88, 128, 66, 66, 73, 69, 128, 66, 66, - 73, 80, 128, 66, 66, 73, 84, 128, 66, 66, 73, 88, 128, 66, 66, 79, 80, - 128, 66, 66, 79, 84, 128, 66, 66, 79, 88, 128, 66, 66, 85, 79, 128, 66, - 66, 85, 80, 128, 66, 66, 85, 82, 128, 66, 66, 85, 88, 128, 66, 66, 89, - 80, 128, 66, 66, 89, 84, 128, 66, 66, 89, 88, 128, 66, 67, 65, 68, 128, - 66, 69, 65, 78, 128, 66, 69, 69, 72, 128, 66, 69, 76, 76, 128, 66, 69, - 76, 84, 128, 66, 69, 78, 68, 128, 66, 69, 79, 82, 195, 66, 69, 84, 72, - 128, 66, 73, 82, 85, 128, 66, 76, 65, 78, 203, 66, 79, 65, 84, 128, 66, - 79, 68, 89, 128, 66, 83, 68, 85, 211, 66, 83, 75, 85, 210, 66, 85, 77, - 80, 217, 67, 65, 65, 73, 128, 67, 65, 76, 67, 128, 67, 65, 76, 76, 128, - 67, 65, 80, 79, 128, 67, 65, 86, 69, 128, 67, 72, 65, 65, 128, 67, 72, - 65, 78, 128, 67, 72, 65, 80, 128, 67, 72, 65, 84, 128, 67, 72, 65, 88, - 128, 67, 72, 69, 80, 128, 67, 72, 69, 84, 128, 67, 72, 69, 88, 128, 67, - 72, 79, 69, 128, 67, 72, 79, 80, 128, 67, 72, 79, 84, 128, 67, 72, 79, - 88, 128, 67, 72, 85, 79, 128, 67, 72, 85, 80, 128, 67, 72, 85, 82, 128, - 67, 72, 85, 88, 128, 67, 72, 89, 80, 128, 67, 72, 89, 82, 128, 67, 72, - 89, 84, 128, 67, 72, 89, 88, 128, 67, 73, 69, 80, 128, 67, 73, 69, 84, - 128, 67, 73, 69, 88, 128, 67, 76, 65, 78, 128, 67, 76, 65, 87, 128, 67, - 76, 69, 65, 210, 67, 76, 79, 83, 197, 67, 79, 68, 65, 128, 67, 79, 76, - 76, 128, 67, 79, 80, 89, 128, 67, 85, 79, 88, 128, 67, 85, 82, 88, 128, - 67, 89, 82, 88, 128, 68, 65, 71, 65, 218, 68, 65, 71, 83, 128, 68, 65, - 73, 82, 128, 68, 65, 77, 80, 128, 68, 68, 65, 65, 128, 68, 68, 65, 76, - 128, 68, 68, 65, 80, 128, 68, 68, 65, 84, 128, 68, 68, 65, 88, 128, 68, - 68, 69, 69, 128, 68, 68, 69, 80, 128, 68, 68, 69, 88, 128, 68, 68, 73, - 69, 128, 68, 68, 73, 80, 128, 68, 68, 73, 84, 128, 68, 68, 73, 88, 128, - 68, 68, 79, 80, 128, 68, 68, 79, 84, 128, 68, 68, 79, 88, 128, 68, 68, - 85, 79, 128, 68, 68, 85, 80, 128, 68, 68, 85, 84, 128, 68, 68, 85, 88, - 128, 68, 68, 87, 65, 128, 68, 69, 69, 82, 128, 68, 69, 72, 73, 128, 68, - 69, 75, 65, 128, 68, 69, 83, 73, 128, 68, 73, 80, 76, 201, 68, 73, 83, - 72, 128, 68, 73, 84, 84, 207, 68, 76, 69, 69, 128, 68, 79, 73, 84, 128, - 68, 79, 79, 82, 128, 68, 79, 82, 85, 128, 68, 82, 85, 77, 128, 68, 89, - 69, 72, 128, 68, 90, 69, 69, 128, 69, 65, 82, 84, 200, 69, 72, 87, 65, - 218, 69, 78, 84, 69, 210, 69, 84, 72, 69, 204, 69, 85, 45, 85, 128, 69, - 85, 76, 69, 210, 70, 65, 65, 73, 128, 70, 65, 78, 71, 128, 70, 76, 73, - 80, 128, 70, 79, 82, 77, 211, 70, 82, 65, 78, 195, 70, 85, 82, 88, 128, - 71, 65, 77, 65, 204, 71, 68, 65, 78, 128, 71, 71, 65, 65, 128, 71, 71, - 65, 80, 128, 71, 71, 65, 84, 128, 71, 71, 65, 88, 128, 71, 71, 69, 69, - 128, 71, 71, 69, 80, 128, 71, 71, 69, 84, 128, 71, 71, 69, 88, 128, 71, - 71, 73, 69, 128, 71, 71, 73, 84, 128, 71, 71, 73, 88, 128, 71, 71, 79, - 84, 128, 71, 71, 79, 88, 128, 71, 71, 85, 80, 128, 71, 71, 85, 82, 128, - 71, 71, 85, 84, 128, 71, 71, 85, 88, 128, 71, 72, 69, 69, 128, 71, 73, - 66, 65, 128, 71, 73, 69, 84, 128, 71, 73, 71, 65, 128, 71, 79, 82, 84, - 128, 71, 85, 69, 72, 128, 71, 87, 65, 65, 128, 71, 87, 69, 69, 128, 72, - 65, 69, 71, 204, 72, 65, 71, 76, 128, 72, 69, 77, 80, 128, 72, 69, 84, - 72, 128, 72, 72, 69, 69, 128, 72, 72, 87, 65, 128, 72, 73, 69, 88, 128, - 72, 73, 71, 72, 128, 72, 73, 90, 66, 128, 72, 76, 65, 80, 128, 72, 76, - 65, 84, 128, 72, 76, 65, 88, 128, 72, 76, 69, 80, 128, 72, 76, 69, 88, - 128, 72, 76, 73, 69, 128, 72, 76, 73, 80, 128, 72, 76, 73, 84, 128, 72, - 76, 73, 88, 128, 72, 76, 79, 80, 128, 72, 76, 79, 88, 128, 72, 76, 85, - 79, 128, 72, 76, 85, 80, 128, 72, 76, 85, 82, 128, 72, 76, 85, 84, 128, - 72, 76, 85, 88, 128, 72, 76, 89, 80, 128, 72, 76, 89, 82, 128, 72, 76, - 89, 84, 128, 72, 76, 89, 88, 128, 72, 77, 65, 80, 128, 72, 77, 65, 84, - 128, 72, 77, 65, 88, 128, 72, 77, 73, 69, 128, 72, 77, 73, 80, 128, 72, - 77, 73, 84, 128, 72, 77, 73, 88, 128, 72, 77, 79, 80, 128, 72, 77, 79, - 84, 128, 72, 77, 79, 88, 128, 72, 77, 85, 79, 128, 72, 77, 85, 80, 128, - 72, 77, 85, 82, 128, 72, 77, 85, 84, 128, 72, 77, 85, 88, 128, 72, 77, - 89, 80, 128, 72, 77, 89, 82, 128, 72, 77, 89, 88, 128, 72, 78, 65, 80, - 128, 72, 78, 65, 84, 128, 72, 78, 65, 88, 128, 72, 78, 69, 80, 128, 72, - 78, 69, 88, 128, 72, 78, 73, 69, 128, 72, 78, 73, 80, 128, 72, 78, 73, - 84, 128, 72, 78, 73, 88, 128, 72, 78, 79, 80, 128, 72, 78, 79, 84, 128, - 72, 78, 79, 88, 128, 72, 78, 85, 79, 128, 72, 78, 85, 84, 128, 72, 79, - 79, 78, 128, 72, 88, 65, 80, 128, 72, 88, 65, 84, 128, 72, 88, 65, 88, - 128, 72, 88, 69, 80, 128, 72, 88, 69, 88, 128, 72, 88, 73, 69, 128, 72, - 88, 73, 80, 128, 72, 88, 73, 88, 128, 72, 88, 79, 84, 128, 72, 88, 79, - 88, 128, 73, 45, 69, 85, 128, 73, 45, 89, 65, 128, 73, 68, 76, 69, 128, - 73, 70, 73, 78, 128, 73, 76, 85, 89, 128, 73, 78, 67, 72, 128, 73, 78, - 78, 78, 128, 73, 78, 84, 73, 128, 73, 83, 79, 78, 128, 73, 84, 69, 77, - 128, 73, 85, 74, 65, 128, 74, 69, 82, 65, 206, 74, 74, 69, 69, 128, 74, - 74, 73, 80, 128, 74, 74, 73, 84, 128, 74, 74, 73, 88, 128, 74, 74, 79, - 80, 128, 74, 74, 79, 84, 128, 74, 74, 79, 88, 128, 74, 74, 85, 79, 128, - 74, 74, 85, 80, 128, 74, 74, 85, 82, 128, 74, 74, 85, 88, 128, 74, 74, - 89, 80, 128, 74, 74, 89, 84, 128, 74, 74, 89, 88, 128, 74, 85, 76, 89, - 128, 74, 85, 78, 69, 128, 74, 85, 79, 84, 128, 75, 65, 65, 73, 128, 75, - 65, 80, 72, 128, 75, 67, 65, 76, 128, 75, 72, 65, 65, 128, 75, 72, 65, - 73, 128, 75, 72, 65, 78, 128, 75, 72, 69, 69, 128, 75, 72, 79, 78, 128, - 75, 73, 69, 80, 128, 75, 73, 69, 88, 128, 75, 73, 82, 79, 128, 75, 75, - 69, 69, 128, 75, 79, 77, 66, 213, 75, 79, 84, 79, 128, 75, 85, 79, 80, - 128, 75, 85, 79, 88, 128, 75, 85, 82, 88, 128, 75, 85, 85, 72, 128, 75, - 87, 69, 69, 128, 75, 88, 65, 65, 128, 75, 88, 69, 69, 128, 75, 88, 87, - 65, 128, 75, 88, 87, 69, 128, 75, 88, 87, 73, 128, 76, 65, 65, 73, 128, - 76, 65, 77, 69, 128, 76, 65, 77, 69, 196, 76, 68, 65, 78, 128, 76, 69, - 69, 75, 128, 76, 69, 71, 83, 128, 76, 69, 86, 69, 204, 76, 69, 90, 72, - 128, 76, 72, 65, 65, 128, 76, 72, 73, 73, 128, 76, 72, 79, 79, 128, 76, - 73, 69, 84, 128, 76, 73, 70, 69, 128, 76, 79, 79, 84, 128, 76, 85, 73, - 83, 128, 76, 85, 79, 84, 128, 77, 65, 65, 73, 128, 77, 69, 83, 72, 128, - 77, 69, 83, 73, 128, 77, 71, 65, 80, 128, 77, 71, 65, 84, 128, 77, 71, - 65, 88, 128, 77, 71, 69, 80, 128, 77, 71, 69, 88, 128, 77, 71, 73, 69, - 128, 77, 71, 79, 80, 128, 77, 71, 79, 84, 128, 77, 71, 79, 88, 128, 77, - 71, 85, 79, 128, 77, 71, 85, 80, 128, 77, 71, 85, 82, 128, 77, 71, 85, - 84, 128, 77, 71, 85, 88, 128, 77, 73, 67, 82, 207, 77, 73, 76, 76, 197, - 77, 73, 78, 89, 128, 77, 73, 82, 73, 128, 77, 79, 86, 69, 196, 77, 85, - 73, 78, 128, 77, 85, 76, 84, 201, 77, 85, 79, 84, 128, 78, 65, 65, 73, - 128, 78, 65, 73, 82, 193, 78, 65, 78, 68, 128, 78, 66, 65, 80, 128, 78, - 66, 65, 84, 128, 78, 66, 65, 88, 128, 78, 66, 73, 80, 128, 78, 66, 73, - 84, 128, 78, 66, 73, 88, 128, 78, 66, 79, 80, 128, 78, 66, 79, 84, 128, - 78, 66, 79, 88, 128, 78, 66, 85, 80, 128, 78, 66, 85, 82, 128, 78, 66, - 85, 84, 128, 78, 66, 85, 88, 128, 78, 66, 89, 80, 128, 78, 66, 89, 82, - 128, 78, 66, 89, 84, 128, 78, 66, 89, 88, 128, 78, 68, 65, 80, 128, 78, - 68, 65, 84, 128, 78, 68, 65, 88, 128, 78, 68, 69, 80, 128, 78, 68, 73, - 69, 128, 78, 68, 73, 80, 128, 78, 68, 73, 84, 128, 78, 68, 73, 88, 128, - 78, 68, 79, 80, 128, 78, 68, 79, 84, 128, 78, 68, 79, 88, 128, 78, 68, - 85, 80, 128, 78, 68, 85, 82, 128, 78, 68, 85, 84, 128, 78, 68, 85, 88, - 128, 78, 71, 65, 73, 128, 78, 71, 65, 80, 128, 78, 71, 65, 84, 128, 78, - 71, 65, 88, 128, 78, 71, 69, 80, 128, 78, 71, 69, 88, 128, 78, 71, 73, - 69, 128, 78, 71, 79, 80, 128, 78, 71, 79, 84, 128, 78, 71, 79, 88, 128, - 78, 71, 85, 79, 128, 78, 74, 73, 69, 128, 78, 74, 73, 80, 128, 78, 74, - 73, 84, 128, 78, 74, 73, 88, 128, 78, 74, 79, 80, 128, 78, 74, 79, 84, - 128, 78, 74, 79, 88, 128, 78, 74, 85, 79, 128, 78, 74, 85, 80, 128, 78, - 74, 85, 82, 128, 78, 74, 85, 88, 128, 78, 74, 89, 80, 128, 78, 74, 89, - 82, 128, 78, 74, 89, 84, 128, 78, 74, 89, 88, 128, 78, 78, 71, 65, 128, - 78, 78, 71, 73, 128, 78, 78, 71, 79, 128, 78, 79, 83, 69, 128, 78, 82, - 65, 80, 128, 78, 82, 65, 84, 128, 78, 82, 65, 88, 128, 78, 82, 69, 80, - 128, 78, 82, 69, 84, 128, 78, 82, 69, 88, 128, 78, 82, 79, 80, 128, 78, - 82, 79, 88, 128, 78, 82, 85, 80, 128, 78, 82, 85, 82, 128, 78, 82, 85, - 84, 128, 78, 82, 85, 88, 128, 78, 82, 89, 80, 128, 78, 82, 89, 82, 128, - 78, 82, 89, 84, 128, 78, 82, 89, 88, 128, 78, 85, 76, 76, 128, 78, 85, - 79, 80, 128, 78, 85, 82, 88, 128, 78, 89, 65, 65, 128, 78, 89, 69, 69, - 128, 78, 89, 69, 72, 128, 78, 89, 73, 69, 128, 78, 89, 73, 84, 128, 78, - 89, 73, 88, 128, 78, 89, 79, 84, 128, 78, 89, 79, 88, 128, 78, 89, 85, - 79, 128, 78, 89, 85, 80, 128, 78, 89, 85, 84, 128, 78, 89, 85, 88, 128, - 78, 89, 87, 65, 128, 78, 90, 65, 80, 128, 78, 90, 65, 84, 128, 78, 90, - 65, 88, 128, 78, 90, 69, 88, 128, 78, 90, 73, 69, 128, 78, 90, 73, 80, - 128, 78, 90, 73, 84, 128, 78, 90, 73, 88, 128, 78, 90, 79, 80, 128, 78, - 90, 79, 88, 128, 78, 90, 85, 79, 128, 78, 90, 85, 82, 128, 78, 90, 85, - 88, 128, 78, 90, 89, 80, 128, 78, 90, 89, 82, 128, 78, 90, 89, 84, 128, - 78, 90, 89, 88, 128, 79, 45, 69, 79, 128, 79, 45, 89, 69, 128, 79, 78, - 83, 85, 128, 79, 79, 77, 85, 128, 79, 85, 78, 67, 197, 80, 65, 65, 73, - 128, 80, 65, 68, 77, 193, 80, 65, 82, 65, 128, 80, 69, 65, 67, 197, 80, - 69, 78, 78, 217, 80, 69, 83, 79, 128, 80, 72, 65, 65, 128, 80, 72, 65, - 78, 128, 80, 72, 69, 69, 128, 80, 72, 87, 65, 128, 80, 73, 69, 80, 128, - 80, 73, 69, 88, 128, 80, 73, 75, 79, 128, 80, 76, 79, 87, 128, 80, 82, - 73, 78, 212, 80, 85, 79, 80, 128, 80, 85, 79, 88, 128, 80, 85, 82, 88, - 128, 80, 89, 82, 88, 128, 81, 65, 65, 73, 128, 81, 65, 80, 72, 128, 81, - 72, 65, 65, 128, 81, 72, 69, 69, 128, 81, 72, 87, 65, 128, 81, 72, 87, - 69, 128, 81, 72, 87, 73, 128, 81, 73, 69, 80, 128, 81, 73, 69, 84, 128, - 81, 73, 69, 88, 128, 81, 85, 79, 80, 128, 81, 85, 79, 84, 128, 81, 85, - 79, 88, 128, 81, 85, 82, 88, 128, 81, 85, 85, 86, 128, 81, 87, 65, 65, - 128, 81, 87, 69, 69, 128, 81, 89, 82, 88, 128, 82, 65, 65, 73, 128, 82, - 65, 73, 68, 207, 82, 65, 78, 71, 197, 82, 69, 77, 85, 128, 82, 73, 67, - 69, 128, 82, 73, 69, 76, 128, 82, 73, 82, 65, 128, 82, 82, 65, 88, 128, - 82, 82, 69, 72, 128, 82, 82, 69, 80, 128, 82, 82, 69, 84, 128, 82, 82, - 69, 88, 128, 82, 82, 79, 80, 128, 82, 82, 79, 84, 128, 82, 82, 79, 88, - 128, 82, 82, 85, 79, 128, 82, 82, 85, 80, 128, 82, 82, 85, 82, 128, 82, - 82, 85, 84, 128, 82, 82, 85, 88, 128, 82, 82, 89, 80, 128, 82, 82, 89, - 82, 128, 82, 82, 89, 84, 128, 82, 82, 89, 88, 128, 82, 85, 73, 83, 128, - 82, 85, 76, 69, 128, 82, 85, 79, 80, 128, 82, 85, 83, 73, 128, 83, 65, - 65, 73, 128, 83, 65, 73, 76, 128, 83, 65, 76, 65, 128, 83, 65, 76, 65, - 205, 83, 66, 82, 85, 204, 83, 67, 87, 65, 128, 83, 68, 79, 78, 199, 83, - 72, 65, 80, 128, 83, 72, 65, 88, 128, 83, 72, 69, 80, 128, 83, 72, 69, - 84, 128, 83, 72, 69, 88, 128, 83, 72, 73, 73, 128, 83, 72, 79, 79, 128, - 83, 72, 79, 84, 128, 83, 72, 79, 88, 128, 83, 72, 85, 79, 128, 83, 72, - 85, 80, 128, 83, 72, 85, 84, 128, 83, 72, 85, 88, 128, 83, 72, 89, 80, - 128, 83, 72, 89, 82, 128, 83, 72, 89, 84, 128, 83, 72, 89, 88, 128, 83, - 73, 71, 69, 204, 83, 73, 71, 77, 193, 83, 75, 73, 78, 128, 83, 75, 85, - 76, 204, 83, 75, 87, 65, 128, 83, 80, 79, 84, 128, 83, 80, 87, 65, 128, - 83, 83, 65, 80, 128, 83, 83, 65, 84, 128, 83, 83, 65, 88, 128, 83, 83, - 69, 80, 128, 83, 83, 69, 88, 128, 83, 83, 73, 69, 128, 83, 83, 73, 80, - 128, 83, 83, 73, 84, 128, 83, 83, 73, 88, 128, 83, 83, 79, 80, 128, 83, - 83, 79, 84, 128, 83, 83, 79, 88, 128, 83, 83, 85, 80, 128, 83, 83, 85, - 84, 128, 83, 83, 85, 88, 128, 83, 83, 89, 80, 128, 83, 83, 89, 82, 128, - 83, 83, 89, 84, 128, 83, 83, 89, 88, 128, 83, 84, 65, 78, 128, 83, 84, - 69, 80, 128, 83, 84, 73, 76, 197, 83, 84, 87, 65, 128, 83, 85, 79, 80, - 128, 83, 85, 79, 88, 128, 83, 85, 82, 88, 128, 83, 87, 65, 83, 200, 83, - 90, 65, 65, 128, 83, 90, 69, 69, 128, 83, 90, 87, 65, 128, 84, 65, 65, - 73, 128, 84, 65, 75, 69, 128, 84, 65, 76, 76, 128, 84, 69, 45, 85, 128, - 84, 69, 78, 84, 128, 84, 69, 84, 72, 128, 84, 72, 69, 72, 128, 84, 72, - 69, 77, 193, 84, 72, 73, 82, 196, 84, 72, 85, 82, 211, 84, 72, 87, 65, - 128, 84, 73, 69, 80, 128, 84, 73, 69, 88, 128, 84, 73, 71, 72, 212, 84, - 73, 78, 89, 128, 84, 73, 87, 65, 218, 84, 76, 69, 69, 128, 84, 76, 72, - 85, 128, 84, 79, 84, 65, 204, 84, 82, 65, 68, 197, 84, 82, 69, 69, 128, - 84, 82, 73, 79, 206, 84, 83, 65, 65, 128, 84, 83, 65, 68, 201, 84, 83, - 87, 65, 128, 84, 84, 65, 65, 128, 84, 84, 69, 69, 128, 84, 84, 69, 72, - 128, 84, 84, 72, 69, 128, 84, 84, 72, 73, 128, 84, 84, 83, 65, 128, 84, - 84, 83, 69, 128, 84, 84, 83, 73, 128, 84, 84, 83, 79, 128, 84, 84, 83, - 85, 128, 84, 85, 79, 80, 128, 84, 85, 79, 84, 128, 84, 85, 79, 88, 128, - 84, 85, 82, 88, 128, 84, 90, 65, 65, 128, 84, 90, 69, 69, 128, 85, 45, - 65, 69, 128, 85, 65, 84, 72, 128, 86, 73, 69, 80, 128, 86, 73, 69, 84, - 128, 86, 73, 69, 88, 128, 86, 85, 82, 88, 128, 86, 89, 82, 88, 128, 87, - 65, 69, 78, 128, 87, 65, 76, 76, 128, 87, 69, 83, 84, 128, 87, 79, 82, - 75, 128, 87, 82, 65, 80, 128, 87, 85, 78, 74, 207, 87, 85, 79, 80, 128, - 87, 85, 79, 88, 128, 88, 73, 82, 79, 206, 88, 89, 82, 88, 128, 89, 65, - 45, 79, 128, 89, 65, 65, 73, 128, 89, 65, 78, 71, 128, 89, 69, 82, 65, - 200, 89, 73, 45, 85, 128, 89, 73, 78, 71, 128, 89, 79, 45, 79, 128, 89, - 79, 77, 79, 128, 89, 79, 82, 73, 128, 89, 85, 45, 65, 128, 89, 85, 45, - 69, 128, 89, 85, 45, 85, 128, 89, 85, 65, 78, 128, 89, 85, 68, 72, 128, - 89, 85, 79, 84, 128, 89, 85, 82, 88, 128, 89, 89, 82, 88, 128, 90, 65, - 89, 73, 206, 90, 72, 65, 65, 128, 90, 72, 65, 80, 128, 90, 72, 65, 84, - 128, 90, 72, 65, 88, 128, 90, 72, 69, 80, 128, 90, 72, 69, 84, 128, 90, - 72, 69, 88, 128, 90, 72, 79, 80, 128, 90, 72, 79, 84, 128, 90, 72, 79, - 88, 128, 90, 72, 85, 79, 128, 90, 72, 85, 80, 128, 90, 72, 85, 82, 128, - 90, 72, 85, 84, 128, 90, 72, 85, 88, 128, 90, 72, 87, 65, 128, 90, 72, - 89, 80, 128, 90, 72, 89, 82, 128, 90, 72, 89, 84, 128, 90, 72, 89, 88, - 128, 90, 85, 79, 80, 128, 90, 90, 65, 80, 128, 90, 90, 65, 84, 128, 90, - 90, 65, 88, 128, 90, 90, 69, 80, 128, 90, 90, 69, 88, 128, 90, 90, 73, - 69, 128, 90, 90, 73, 80, 128, 90, 90, 73, 84, 128, 90, 90, 73, 88, 128, - 90, 90, 79, 80, 128, 90, 90, 79, 88, 128, 90, 90, 85, 80, 128, 90, 90, - 85, 82, 128, 90, 90, 85, 88, 128, 90, 90, 89, 80, 128, 90, 90, 89, 82, - 128, 90, 90, 89, 84, 128, 90, 90, 89, 88, 128, 68, 79, 84, 211, 70, 82, - 79, 205, 72, 79, 79, 203, 79, 80, 69, 206, 84, 79, 68, 207, 69, 65, 83, - 212, 84, 79, 78, 197, 72, 79, 85, 210, 83, 73, 66, 197, 72, 79, 82, 206, - 81, 85, 65, 196, 68, 65, 83, 200, 78, 69, 79, 128, 84, 69, 78, 128, 84, - 72, 69, 200, 75, 79, 77, 201, 67, 72, 73, 128, 79, 86, 69, 210, 79, 88, - 73, 193, 70, 79, 85, 210, 80, 72, 73, 128, 80, 83, 73, 128, 82, 72, 79, - 128, 83, 65, 82, 193, 84, 65, 67, 203, 71, 72, 65, 128, 66, 72, 65, 128, - 68, 79, 69, 211, 84, 65, 85, 128, 67, 72, 69, 128, 74, 72, 65, 128, 70, - 73, 86, 197, 82, 82, 65, 128, 87, 73, 68, 197, 82, 68, 69, 204, 83, 72, - 73, 206, 87, 65, 86, 217, 89, 85, 83, 128, 90, 65, 73, 206, 67, 65, 78, - 128, 68, 73, 71, 193, 65, 82, 67, 128, 83, 84, 79, 208, 84, 65, 77, 128, - 68, 90, 69, 128, 71, 72, 69, 128, 71, 79, 65, 204, 71, 84, 69, 210, 75, - 65, 70, 128, 76, 69, 71, 128, 78, 89, 79, 128, 83, 72, 79, 128, 83, 84, - 65, 210, 83, 85, 78, 128, 84, 65, 73, 204, 87, 65, 86, 197, 65, 80, 76, - 201, 66, 69, 69, 200, 67, 72, 79, 128, 67, 76, 69, 198, 68, 74, 69, 128, - 68, 75, 65, 210, 68, 89, 69, 200, 68, 90, 65, 128, 70, 69, 72, 128, 70, - 73, 83, 200, 71, 85, 69, 200, 76, 65, 77, 197, 76, 74, 69, 128, 77, 71, - 79, 128, 77, 85, 67, 200, 78, 65, 77, 197, 78, 74, 69, 128, 78, 79, 87, - 128, 78, 89, 69, 200, 80, 69, 69, 128, 82, 65, 65, 128, 83, 72, 73, 128, - 84, 72, 69, 206, 84, 73, 67, 203, 84, 84, 69, 200, 87, 65, 87, 128, 90, - 69, 82, 207, 66, 69, 69, 128, 66, 79, 87, 128, 66, 90, 72, 201, 67, 72, - 85, 128, 70, 76, 65, 212, 70, 82, 69, 197, 72, 73, 69, 128, 75, 69, 72, - 128, 75, 87, 69, 128, 75, 87, 73, 128, 76, 87, 65, 128, 77, 69, 77, 128, - 77, 69, 78, 128, 77, 87, 65, 128, 78, 65, 65, 128, 78, 85, 78, 128, 78, - 87, 65, 128, 78, 89, 73, 211, 80, 69, 72, 128, 81, 65, 65, 128, 82, 72, - 65, 128, 83, 72, 79, 197, 83, 72, 85, 128, 84, 72, 65, 204, 84, 79, 79, - 128, 86, 69, 69, 128, 87, 65, 69, 128, 87, 65, 76, 203, 87, 69, 79, 128, - 88, 69, 72, 128, 89, 79, 68, 128, 89, 89, 65, 128, 65, 76, 76, 201, 65, - 89, 66, 128, 66, 65, 65, 128, 66, 69, 72, 128, 66, 69, 78, 128, 66, 79, - 76, 212, 67, 65, 65, 128, 67, 73, 80, 128, 67, 76, 85, 194, 67, 79, 79, - 128, 67, 79, 87, 128, 67, 85, 80, 128, 67, 87, 69, 128, 67, 87, 73, 128, - 67, 87, 79, 128, 67, 89, 80, 128, 67, 89, 84, 128, 68, 68, 65, 204, 68, - 68, 69, 128, 68, 68, 73, 128, 68, 68, 85, 128, 68, 69, 73, 128, 68, 76, - 65, 128, 68, 79, 71, 128, 68, 79, 78, 128, 68, 82, 85, 205, 70, 65, 65, - 128, 70, 69, 73, 128, 70, 76, 89, 128, 70, 85, 82, 128, 70, 85, 83, 193, - 71, 65, 78, 128, 71, 65, 89, 128, 71, 71, 65, 128, 71, 71, 69, 128, 71, - 71, 73, 128, 71, 71, 79, 128, 71, 71, 85, 128, 71, 73, 77, 128, 71, 74, - 69, 128, 72, 65, 69, 128, 72, 65, 82, 196, 72, 77, 79, 128, 72, 78, 65, - 128, 73, 83, 79, 206, 74, 73, 76, 128, 74, 74, 73, 128, 74, 74, 79, 128, - 74, 74, 85, 128, 74, 74, 89, 128, 75, 65, 89, 128, 75, 69, 78, 128, 75, - 72, 69, 128, 75, 72, 79, 128, 75, 73, 84, 128, 75, 74, 69, 128, 75, 79, - 79, 128, 75, 83, 73, 128, 75, 87, 79, 128, 76, 65, 65, 128, 76, 65, 83, - 128, 76, 79, 79, 128, 76, 87, 69, 128, 76, 87, 73, 128, 76, 87, 79, 128, - 77, 65, 65, 128, 77, 79, 79, 128, 77, 79, 79, 206, 77, 87, 69, 128, 77, - 87, 73, 128, 77, 87, 79, 128, 78, 65, 82, 128, 78, 69, 69, 128, 78, 71, - 65, 211, 78, 73, 66, 128, 78, 79, 79, 128, 78, 79, 84, 197, 78, 87, 69, - 128, 78, 89, 73, 128, 78, 89, 85, 128, 79, 72, 77, 128, 79, 75, 84, 207, - 79, 78, 78, 128, 80, 65, 65, 128, 80, 65, 82, 128, 80, 65, 82, 212, 80, - 65, 84, 200, 80, 72, 79, 128, 80, 72, 85, 210, 80, 79, 76, 201, 80, 79, - 79, 128, 80, 85, 84, 128, 80, 87, 69, 128, 80, 87, 73, 128, 80, 87, 79, - 128, 80, 89, 84, 128, 81, 65, 73, 128, 81, 65, 82, 128, 81, 73, 73, 128, - 81, 79, 84, 128, 81, 85, 79, 128, 81, 85, 85, 128, 82, 65, 69, 128, 82, - 71, 89, 193, 82, 78, 65, 205, 82, 82, 69, 200, 83, 69, 72, 128, 83, 72, - 65, 196, 83, 72, 89, 128, 83, 73, 79, 211, 83, 74, 69, 128, 83, 79, 79, - 128, 83, 83, 73, 128, 83, 83, 79, 128, 83, 87, 69, 128, 83, 87, 73, 128, - 83, 87, 79, 128, 84, 65, 71, 128, 84, 65, 84, 128, 84, 65, 86, 128, 84, - 74, 69, 128, 84, 76, 65, 128, 84, 76, 73, 128, 84, 76, 85, 128, 84, 82, - 69, 197, 84, 84, 73, 128, 84, 87, 69, 128, 84, 87, 73, 128, 85, 83, 69, - 196, 86, 65, 86, 128, 86, 69, 80, 128, 86, 69, 82, 217, 86, 69, 87, 128, - 86, 73, 78, 128, 86, 79, 85, 128, 86, 85, 82, 128, 88, 65, 78, 128, 89, - 65, 78, 199, 89, 65, 84, 128, 89, 69, 82, 213, 89, 70, 69, 206, 89, 79, - 79, 128, 89, 87, 69, 128, 89, 87, 73, 128, 89, 87, 79, 128, 90, 69, 78, - 128, 90, 72, 73, 128, 90, 72, 79, 128, 90, 72, 85, 128, 90, 79, 84, 128, - 65, 77, 66, 193, 65, 82, 67, 200, 65, 88, 69, 128, 66, 65, 78, 203, 66, - 66, 65, 128, 66, 66, 69, 128, 66, 66, 73, 128, 66, 66, 79, 128, 66, 66, - 85, 128, 66, 66, 89, 128, 66, 67, 65, 196, 66, 69, 76, 204, 66, 69, 76, - 212, 66, 69, 84, 128, 66, 69, 84, 193, 66, 73, 71, 128, 66, 75, 65, 173, - 66, 87, 65, 128, 67, 65, 68, 193, 67, 65, 78, 199, 67, 65, 82, 197, 67, - 65, 84, 128, 67, 65, 88, 128, 67, 69, 69, 128, 67, 69, 78, 128, 67, 69, - 80, 128, 67, 69, 88, 128, 67, 72, 65, 196, 67, 72, 69, 206, 67, 73, 69, - 128, 67, 73, 73, 128, 67, 73, 84, 128, 67, 73, 88, 128, 67, 79, 80, 128, - 67, 79, 84, 128, 67, 79, 88, 128, 67, 85, 66, 197, 67, 85, 79, 128, 67, - 85, 82, 128, 67, 85, 84, 128, 67, 85, 88, 128, 67, 89, 65, 128, 67, 89, - 82, 128, 67, 89, 88, 128, 68, 65, 68, 128, 68, 65, 69, 199, 68, 65, 77, - 208, 68, 65, 82, 203, 68, 69, 75, 128, 68, 69, 76, 128, 68, 69, 90, 200, - 68, 76, 73, 128, 68, 76, 79, 128, 68, 76, 85, 128, 68, 82, 73, 204, 68, - 82, 89, 128, 68, 85, 76, 128, 68, 89, 79, 128, 68, 90, 73, 128, 68, 90, - 79, 128, 68, 90, 85, 128, 69, 73, 83, 128, 69, 75, 83, 128, 69, 78, 78, - 128, 69, 78, 79, 211, 69, 79, 72, 128, 69, 85, 82, 207, 69, 87, 69, 128, - 69, 88, 79, 128, 70, 65, 78, 128, 70, 65, 80, 128, 70, 65, 84, 128, 70, - 65, 88, 128, 70, 69, 69, 128, 70, 69, 69, 196, 70, 69, 72, 213, 70, 69, - 78, 199, 70, 69, 79, 200, 70, 70, 73, 128, 70, 70, 76, 128, 70, 73, 73, - 128, 70, 73, 76, 197, 70, 73, 76, 204, 70, 73, 80, 128, 70, 73, 84, 128, - 70, 73, 88, 128, 70, 79, 79, 128, 70, 79, 80, 128, 70, 79, 88, 128, 70, - 85, 80, 128, 70, 85, 84, 128, 70, 85, 88, 128, 70, 87, 65, 128, 70, 89, - 65, 128, 70, 89, 80, 128, 70, 89, 84, 128, 70, 89, 88, 128, 71, 65, 70, - 128, 71, 65, 82, 128, 71, 67, 65, 206, 71, 69, 66, 207, 71, 69, 84, 193, - 71, 72, 73, 128, 71, 72, 79, 128, 71, 72, 85, 128, 71, 72, 90, 128, 71, - 73, 80, 128, 71, 80, 65, 128, 71, 83, 85, 205, 71, 87, 65, 128, 71, 87, - 69, 128, 71, 87, 73, 128, 71, 89, 70, 213, 72, 65, 73, 210, 72, 69, 76, - 205, 72, 69, 78, 199, 72, 72, 69, 128, 72, 72, 73, 128, 72, 72, 79, 128, - 72, 72, 85, 128, 72, 76, 65, 128, 72, 76, 69, 128, 72, 76, 73, 128, 72, - 76, 79, 128, 72, 76, 85, 128, 72, 76, 89, 128, 72, 77, 65, 128, 72, 77, - 73, 128, 72, 77, 85, 128, 72, 77, 89, 128, 72, 78, 69, 128, 72, 78, 73, - 128, 72, 80, 65, 128, 72, 87, 85, 128, 72, 88, 65, 128, 72, 88, 69, 128, - 72, 88, 73, 128, 72, 88, 79, 128, 73, 45, 65, 128, 73, 45, 79, 128, 73, - 79, 82, 128, 74, 65, 65, 128, 74, 65, 82, 128, 74, 69, 72, 128, 74, 69, - 82, 128, 74, 73, 65, 128, 74, 74, 65, 128, 74, 74, 69, 128, 74, 87, 65, - 128, 75, 65, 72, 128, 75, 65, 73, 128, 75, 65, 80, 128, 75, 65, 85, 206, - 75, 65, 88, 128, 75, 69, 80, 128, 75, 69, 88, 128, 75, 69, 89, 128, 75, - 72, 73, 128, 75, 72, 90, 128, 75, 73, 69, 128, 75, 73, 72, 128, 75, 73, - 73, 128, 75, 73, 80, 128, 75, 73, 88, 128, 75, 75, 65, 128, 75, 75, 69, - 128, 75, 75, 73, 128, 75, 75, 79, 128, 75, 75, 85, 128, 75, 79, 72, 128, - 75, 79, 80, 128, 75, 79, 84, 128, 75, 79, 88, 128, 75, 80, 65, 128, 75, - 82, 65, 128, 75, 85, 79, 128, 75, 85, 80, 128, 75, 85, 82, 128, 75, 85, - 84, 128, 75, 85, 88, 128, 75, 88, 65, 128, 75, 88, 69, 128, 75, 88, 73, - 128, 75, 88, 79, 128, 75, 88, 85, 128, 76, 65, 71, 213, 76, 65, 83, 212, - 76, 65, 90, 217, 76, 69, 79, 128, 76, 72, 65, 199, 76, 73, 68, 128, 76, - 73, 73, 128, 76, 73, 78, 203, 76, 73, 82, 193, 76, 79, 71, 128, 76, 79, - 71, 210, 76, 79, 84, 128, 76, 89, 89, 128, 77, 65, 83, 213, 77, 65, 89, - 128, 77, 67, 72, 213, 77, 68, 85, 206, 77, 69, 84, 193, 77, 69, 88, 128, - 77, 71, 65, 128, 77, 71, 69, 128, 77, 71, 85, 128, 77, 72, 90, 128, 77, - 73, 73, 128, 77, 73, 76, 128, 77, 73, 76, 204, 77, 73, 77, 128, 77, 79, - 76, 128, 77, 80, 65, 128, 77, 89, 65, 128, 77, 89, 84, 128, 78, 65, 71, - 128, 78, 65, 79, 211, 78, 66, 65, 128, 78, 66, 73, 128, 78, 66, 79, 128, - 78, 66, 85, 128, 78, 66, 89, 128, 78, 68, 69, 128, 78, 69, 78, 128, 78, - 69, 84, 128, 78, 69, 88, 212, 78, 71, 71, 128, 78, 74, 73, 128, 78, 74, - 79, 128, 78, 74, 85, 128, 78, 74, 89, 128, 78, 78, 71, 128, 78, 78, 79, - 128, 78, 82, 65, 128, 78, 82, 69, 128, 78, 82, 79, 128, 78, 82, 85, 128, - 78, 82, 89, 128, 78, 85, 76, 204, 78, 85, 80, 128, 78, 85, 82, 128, 78, - 85, 88, 128, 78, 89, 69, 128, 78, 90, 65, 128, 78, 90, 69, 128, 78, 90, - 73, 128, 78, 90, 85, 128, 78, 90, 89, 128, 79, 45, 69, 128, 80, 65, 80, - 128, 80, 65, 84, 128, 80, 65, 88, 128, 80, 72, 85, 128, 80, 73, 69, 128, - 80, 73, 71, 128, 80, 73, 80, 128, 80, 73, 84, 128, 80, 73, 88, 128, 80, - 76, 65, 128, 80, 79, 80, 128, 80, 79, 88, 128, 80, 80, 77, 128, 80, 85, - 79, 128, 80, 85, 80, 128, 80, 85, 82, 128, 80, 85, 88, 128, 80, 89, 80, - 128, 80, 89, 82, 128, 80, 89, 88, 128, 81, 65, 76, 193, 81, 65, 81, 128, - 81, 65, 85, 128, 81, 69, 69, 128, 81, 72, 65, 128, 81, 72, 69, 128, 81, - 72, 73, 128, 81, 72, 79, 128, 81, 72, 85, 128, 81, 73, 69, 128, 81, 73, - 80, 128, 81, 73, 84, 128, 81, 73, 88, 128, 81, 79, 70, 128, 81, 79, 79, - 128, 81, 79, 80, 128, 81, 79, 88, 128, 81, 85, 65, 128, 81, 85, 69, 128, - 81, 85, 73, 128, 81, 85, 75, 128, 81, 85, 80, 128, 81, 85, 82, 128, 81, - 85, 84, 128, 81, 85, 86, 128, 81, 85, 88, 128, 81, 87, 65, 128, 81, 87, - 69, 128, 81, 87, 73, 128, 81, 89, 80, 128, 81, 89, 82, 128, 81, 89, 84, - 128, 81, 89, 88, 128, 82, 65, 68, 128, 82, 65, 77, 211, 82, 69, 73, 196, - 82, 73, 80, 128, 82, 74, 69, 128, 82, 74, 69, 211, 82, 79, 79, 128, 82, - 82, 69, 128, 82, 82, 79, 128, 82, 82, 85, 128, 82, 82, 89, 128, 82, 85, - 65, 128, 82, 85, 78, 128, 82, 87, 65, 128, 82, 89, 65, 128, 82, 89, 89, - 128, 83, 45, 87, 128, 83, 65, 68, 128, 83, 65, 89, 128, 83, 66, 85, 194, - 83, 71, 65, 194, 83, 71, 79, 210, 83, 71, 82, 193, 83, 72, 79, 199, 83, - 73, 73, 128, 83, 73, 78, 197, 83, 75, 87, 128, 83, 78, 65, 208, 83, 83, - 69, 128, 83, 83, 85, 128, 83, 83, 89, 128, 83, 84, 69, 205, 83, 85, 65, - 128, 83, 85, 79, 128, 83, 85, 82, 128, 83, 90, 65, 128, 83, 90, 69, 128, - 83, 90, 73, 128, 83, 90, 79, 128, 83, 90, 85, 128, 84, 65, 79, 128, 84, - 65, 80, 128, 84, 65, 80, 197, 84, 65, 87, 128, 84, 65, 88, 128, 84, 69, - 83, 200, 84, 69, 84, 128, 84, 69, 84, 200, 84, 69, 88, 128, 84, 72, 69, - 211, 84, 72, 73, 206, 84, 72, 90, 128, 84, 73, 73, 128, 84, 73, 80, 128, - 84, 73, 84, 128, 84, 73, 88, 128, 84, 76, 86, 128, 84, 79, 84, 128, 84, - 79, 88, 128, 84, 82, 73, 128, 84, 83, 86, 128, 84, 84, 72, 128, 84, 84, - 85, 128, 84, 85, 79, 128, 84, 85, 80, 128, 84, 85, 82, 128, 84, 85, 84, - 128, 84, 85, 88, 128, 84, 89, 65, 128, 84, 89, 69, 128, 84, 89, 73, 128, - 84, 89, 79, 128, 84, 90, 65, 128, 84, 90, 69, 128, 84, 90, 73, 128, 84, - 90, 79, 128, 84, 90, 85, 128, 85, 69, 69, 128, 85, 78, 68, 207, 85, 78, - 73, 212, 85, 79, 78, 128, 85, 82, 85, 218, 86, 65, 65, 128, 86, 65, 80, - 128, 86, 65, 84, 128, 86, 65, 88, 128, 86, 69, 72, 128, 86, 69, 88, 128, - 86, 73, 69, 128, 86, 73, 80, 128, 86, 73, 84, 128, 86, 73, 88, 128, 86, - 79, 73, 196, 86, 79, 80, 128, 86, 79, 84, 128, 86, 79, 88, 128, 86, 85, - 80, 128, 86, 85, 84, 128, 86, 85, 88, 128, 86, 87, 65, 128, 86, 89, 80, - 128, 86, 89, 82, 128, 86, 89, 84, 128, 86, 89, 88, 128, 87, 65, 80, 128, - 87, 65, 84, 128, 87, 65, 88, 128, 87, 69, 80, 128, 87, 69, 88, 128, 87, - 79, 80, 128, 87, 79, 82, 196, 87, 79, 88, 128, 87, 85, 79, 128, 87, 89, - 78, 206, 88, 79, 82, 128, 88, 89, 80, 128, 88, 89, 82, 128, 88, 89, 84, - 128, 88, 89, 88, 128, 89, 65, 75, 128, 89, 73, 73, 128, 89, 85, 68, 200, - 89, 85, 82, 128, 89, 89, 80, 128, 89, 89, 82, 128, 89, 89, 84, 128, 89, - 89, 88, 128, 90, 65, 72, 128, 90, 72, 89, 128, 90, 76, 65, 128, 90, 82, - 65, 128, 90, 85, 84, 128, 90, 90, 65, 128, 90, 90, 69, 128, 90, 90, 73, - 128, 90, 90, 85, 128, 90, 90, 89, 128, 75, 65, 198, 68, 65, 217, 66, 69, - 200, 68, 65, 196, 83, 65, 196, 70, 69, 200, 81, 65, 198, 84, 65, 200, 69, - 78, 196, 82, 82, 128, 65, 82, 195, 78, 79, 210, 77, 65, 201, 79, 67, 210, - 87, 65, 215, 67, 72, 197, 82, 72, 207, 84, 72, 197, 89, 73, 199, 65, 82, - 205, 66, 85, 212, 67, 79, 128, 67, 85, 205, 78, 69, 207, 71, 65, 198, 75, - 72, 207, 77, 71, 207, 90, 65, 200, 66, 73, 199, 68, 73, 197, 71, 72, 197, - 80, 72, 201, 86, 79, 128, 90, 72, 197, 80, 72, 207, 80, 85, 128, 67, 72, - 207, 77, 69, 206, 78, 69, 212, 80, 69, 200, 81, 73, 128, 84, 69, 206, 84, - 73, 208, 86, 69, 200, 89, 79, 196, 66, 69, 212, 67, 73, 128, 68, 89, 207, - 70, 79, 128, 72, 65, 193, 75, 65, 201, 78, 65, 199, 81, 79, 128, 81, 85, - 128, 82, 65, 196, 83, 73, 206, 83, 73, 216, 86, 65, 214, 86, 73, 128, 45, - 85, 205, 67, 72, 201, 67, 85, 128, 67, 89, 128, 68, 85, 204, 68, 90, 128, - 69, 88, 207, 71, 82, 213, 71, 85, 199, 72, 86, 128, 73, 74, 128, 74, 69, - 200, 74, 79, 212, 75, 69, 217, 75, 71, 128, 75, 75, 128, 76, 74, 128, 77, - 73, 199, 78, 74, 128, 78, 86, 128, 78, 89, 201, 79, 72, 205, 80, 65, 215, - 81, 69, 128, 81, 79, 207, 82, 68, 207, 83, 85, 206, 87, 79, 206, 89, 69, - 206, 65, 78, 207, 66, 65, 199, 66, 69, 206, 66, 79, 215, 66, 81, 128, 67, - 77, 128, 67, 85, 212, 68, 76, 128, 68, 86, 128, 69, 67, 200, 70, 77, 128, - 70, 89, 128, 71, 66, 128, 71, 86, 128, 71, 89, 128, 72, 75, 128, 72, 79, - 212, 72, 80, 128, 73, 83, 211, 73, 85, 128, 73, 89, 128, 75, 66, 128, 75, - 73, 208, 75, 76, 128, 75, 77, 128, 75, 84, 128, 75, 86, 128, 76, 67, 197, - 76, 67, 201, 76, 69, 203, 76, 72, 128, 76, 78, 128, 76, 88, 128, 77, 66, - 128, 77, 69, 205, 77, 71, 128, 77, 72, 128, 77, 73, 196, 77, 76, 128, 77, - 77, 128, 77, 83, 128, 77, 86, 128, 77, 87, 128, 78, 65, 193, 78, 69, 215, - 78, 70, 128, 78, 71, 207, 78, 72, 128, 78, 77, 128, 78, 85, 206, 78, 87, - 128, 78, 89, 196, 79, 86, 128, 80, 67, 128, 80, 69, 211, 80, 70, 128, 80, - 73, 201, 80, 79, 208, 80, 82, 128, 80, 86, 128, 80, 87, 128, 81, 79, 198, - 81, 89, 128, 82, 73, 206, 82, 74, 197, 82, 85, 194, 83, 78, 193, 83, 79, - 198, 83, 82, 128, 83, 87, 128, 84, 65, 214, 84, 69, 197, 84, 69, 212, 84, - 73, 210, 84, 82, 128, 86, 69, 197, 86, 69, 215, 87, 66, 128, 87, 86, 128, - 88, 89, 128, 89, 65, 210, 89, 78, 128, 89, 86, 128, 90, 76, 193, 66, 217, - 77, 213, 65, 197, 89, 213, 65, 213, 68, 218, 90, 197, 75, 205, 67, 205, - 75, 213, 77, 205, 76, 218, 77, 194, 77, 207, 77, 214, 77, 215, 80, 207, - 84, 195, 202, 209, -}; - -static unsigned short lexicon_offset[] = { - 0, 0, 6, 10, 15, 23, 30, 32, 35, 47, 52, 58, 71, 76, 82, 90, 99, 103, - 111, 114, 121, 127, 133, 140, 150, 158, 162, 167, 172, 179, 184, 190, - 198, 205, 212, 221, 229, 233, 238, 243, 251, 257, 264, 270, 274, 281, - 287, 294, 300, 309, 312, 315, 324, 330, 335, 338, 346, 349, 354, 359, - 364, 372, 378, 387, 397, 399, 404, 415, 419, 432, 298, 434, 440, 450, - 459, 464, 466, 469, 467, 476, 480, 485, 488, 493, 499, 501, 504, 509, - 517, 525, 529, 536, 543, 552, 560, 569, 573, 581, 590, 596, 605, 610, - 618, 625, 632, 638, 643, 651, 660, 667, 668, 676, 336, 683, 691, 637, - 695, 701, 706, 250, 712, 725, 729, 736, 739, 749, 754, 763, 772, 777, - 786, 791, 798, 801, 805, 813, 815, 819, 821, 826, 828, 837, 840, 845, 22, - 849, 853, 863, 534, 871, 876, 886, 893, 900, 906, 657, 913, 918, 928, - 884, 934, 939, 945, 950, 955, 957, 961, 968, 972, 977, 979, 74, 981, 986, - 991, 997, 1003, 1009, 1013, 1018, 1024, 1030, 1032, 352, 1035, 1041, - 1050, 1052, 1054, 1057, 674, 1062, 540, 1065, 1071, 539, 1073, 31, 1060, - 1085, 1087, 285, 1089, 1091, 1093, 402, 1095, 1104, 1109, 1112, 1114, - 1121, 1135, 1141, 1145, 1149, 1154, 1157, 1161, 1166, 1175, 1184, 100, - 1187, 1196, 1204, 1207, 1214, 1218, 1222, 1227, 1233, 1239, 1263, 1285, - 1307, 1329, 1350, 1371, 1391, 1411, 1430, 1449, 1468, 1487, 1506, 1525, - 1544, 1563, 1581, 1599, 1617, 1635, 1653, 1671, 1689, 1707, 1725, 1743, - 1761, 1778, 1795, 1812, 1829, 1846, 1863, 1880, 1897, 1914, 1931, 1948, - 1964, 1980, 1996, 2012, 2028, 2044, 2060, 2076, 2092, 2108, 2124, 2140, - 2156, 2172, 2188, 2204, 2220, 2236, 2252, 2268, 2284, 2300, 2316, 2332, - 2348, 2364, 2380, 2396, 2412, 2428, 2444, 2460, 2476, 2492, 2508, 2524, - 2540, 2556, 2572, 2588, 2604, 2620, 2636, 2652, 2668, 2684, 2700, 2716, - 2732, 2748, 2764, 2780, 2796, 2812, 2828, 2844, 2860, 2876, 2892, 2908, - 2924, 2940, 2956, 2972, 2988, 3004, 3020, 3036, 3052, 3068, 3084, 3100, - 3116, 3132, 3148, 3164, 3180, 3196, 3212, 3228, 3244, 3260, 3276, 3292, - 3308, 3324, 3340, 3356, 3372, 3388, 3404, 3420, 3436, 3452, 3468, 3484, - 3500, 3516, 3532, 3548, 3564, 3580, 3596, 3612, 3628, 3644, 3660, 3676, - 3692, 3708, 3724, 3740, 3756, 3772, 3788, 3804, 3820, 3836, 3852, 3868, - 3884, 3900, 3916, 3932, 3948, 3964, 3980, 3996, 4012, 4028, 4044, 4060, - 4076, 4092, 4108, 4124, 4140, 4156, 4172, 4188, 4204, 4220, 4236, 4252, - 4268, 4284, 4300, 4316, 4332, 4348, 4364, 4380, 4396, 4412, 4428, 4444, - 4460, 4476, 4492, 4508, 4524, 4540, 4556, 4572, 4588, 4604, 4620, 4636, - 4652, 4668, 4684, 4700, 4716, 4732, 4748, 4764, 4780, 4796, 4812, 4828, - 4844, 4860, 4876, 4892, 4908, 4924, 4940, 4956, 4972, 4988, 5004, 5020, - 5036, 5052, 5068, 5084, 5100, 5116, 5132, 5148, 5164, 5180, 5196, 5212, - 5228, 5244, 5260, 5276, 5292, 5308, 5324, 5340, 5356, 5372, 5388, 5404, - 5420, 5436, 5452, 5468, 5484, 5500, 5516, 5532, 5548, 5564, 5580, 5596, - 5612, 5628, 5644, 5660, 5676, 5692, 5708, 5724, 5740, 5756, 5772, 5788, - 5804, 5820, 5836, 5852, 5868, 5884, 5900, 5916, 5932, 5948, 5964, 5980, - 5996, 6012, 6028, 6044, 6060, 6076, 6092, 6108, 6124, 6140, 6156, 6172, - 6188, 6204, 6220, 6236, 6252, 6268, 6284, 6300, 6316, 6332, 6348, 6364, - 6380, 6396, 6412, 6428, 6444, 6460, 6476, 6492, 6508, 6524, 6540, 6556, - 6572, 6588, 6604, 6620, 6636, 6652, 6668, 6684, 6700, 6716, 6732, 6748, - 6764, 6780, 6796, 6812, 6828, 6844, 6860, 6876, 6892, 6908, 6924, 6940, - 6956, 6972, 6988, 7004, 7020, 7036, 7052, 7068, 7084, 7100, 7116, 7132, - 7148, 7164, 7180, 7196, 7212, 7228, 7244, 7260, 7276, 7292, 7308, 7324, - 7340, 7356, 7372, 7388, 7404, 7420, 7436, 7452, 7468, 7484, 7500, 7516, - 7532, 7548, 7564, 7580, 7596, 7612, 7628, 7644, 7660, 7676, 7692, 7708, - 7724, 7740, 7756, 7772, 7788, 7804, 7820, 7836, 7852, 7868, 7884, 7900, - 7916, 7932, 7948, 7964, 7980, 7996, 8012, 8028, 8044, 8060, 8076, 8092, - 8108, 8124, 8140, 8156, 8172, 8188, 8204, 8220, 8236, 8252, 8268, 8284, - 8300, 8316, 8332, 8348, 8364, 8380, 8396, 8412, 8428, 8444, 8460, 8476, - 8492, 8508, 8524, 8540, 8556, 8572, 8588, 8604, 8620, 8636, 8652, 8668, - 8684, 8700, 8716, 8732, 8748, 8764, 8780, 8796, 8812, 8828, 8844, 8860, - 8876, 8892, 8908, 8924, 8940, 8956, 8972, 8988, 9004, 9020, 9036, 9052, - 9068, 9084, 9100, 9116, 9132, 9148, 9164, 9180, 9196, 9212, 9228, 9244, - 9260, 9276, 9292, 9308, 9324, 9340, 9356, 9372, 9388, 9404, 9420, 9436, - 9452, 9468, 9484, 9500, 9516, 9532, 9548, 9564, 9580, 9596, 9612, 9628, - 9644, 9660, 9676, 9692, 9708, 9724, 9740, 9756, 9772, 9788, 9804, 9820, - 9836, 9852, 9868, 9884, 9900, 9916, 9932, 9948, 9964, 9980, 9996, 10012, - 10028, 10044, 10060, 10076, 10092, 10108, 10124, 10140, 10156, 10172, - 10188, 10204, 10220, 10236, 10252, 10268, 10284, 10300, 10316, 10332, - 10348, 10364, 10380, 10396, 10412, 10428, 10444, 10460, 10476, 10492, - 10508, 10524, 10540, 10556, 10572, 10588, 10604, 10620, 10636, 10652, - 10668, 10684, 10700, 10716, 10732, 10748, 10764, 10780, 10796, 10812, - 10828, 10844, 10860, 10876, 10892, 10908, 10923, 10938, 10953, 10968, - 10983, 10998, 11013, 11028, 11043, 11058, 11073, 11088, 11103, 11118, - 11133, 11148, 11163, 11178, 11193, 11208, 11223, 11238, 11253, 11268, - 11283, 11298, 11313, 11328, 11343, 11358, 11373, 11388, 11403, 11418, - 11433, 11448, 11463, 11478, 11493, 11508, 11523, 11538, 11553, 11568, - 11583, 11598, 11613, 11628, 11643, 11658, 11673, 11688, 11703, 11718, - 11733, 11748, 11763, 11778, 11793, 11808, 11823, 11838, 11853, 11868, - 11883, 11898, 11913, 11928, 11943, 11958, 11973, 11988, 12003, 12018, - 12033, 12048, 12063, 12078, 12093, 12108, 12123, 12138, 12153, 12168, - 12183, 12198, 12213, 12228, 12243, 12258, 12273, 12288, 12303, 12318, - 12333, 12348, 12363, 12378, 12393, 12408, 12423, 12438, 12453, 12468, - 12483, 12498, 12513, 12528, 12543, 12558, 12573, 12588, 12603, 12618, - 12633, 12648, 12663, 12678, 12693, 12708, 12723, 12738, 12753, 12768, - 12783, 12798, 12813, 12828, 12843, 12858, 12873, 12888, 12903, 12918, - 12933, 12948, 12963, 12978, 12993, 13008, 13023, 13038, 13053, 13068, - 13083, 13098, 13113, 13128, 13143, 13158, 13173, 13188, 13203, 13218, - 13233, 13248, 13263, 13278, 13293, 13308, 13323, 13338, 13353, 13368, - 13383, 13398, 13413, 13428, 13443, 13458, 13473, 13488, 13503, 13518, - 13533, 13548, 13563, 13578, 13593, 13608, 13623, 13638, 13653, 13668, - 13683, 13698, 13713, 13728, 13743, 13758, 13773, 13788, 13803, 13818, - 13833, 13848, 13863, 13878, 13893, 13908, 13923, 13938, 13953, 13968, - 13983, 13998, 14013, 14028, 14043, 14058, 14073, 14088, 14103, 14118, - 14133, 14148, 14163, 14178, 14193, 14208, 14223, 14238, 14253, 14268, - 14283, 14298, 14313, 14328, 14343, 14358, 14373, 14388, 14403, 14418, - 14433, 14448, 14463, 14478, 14493, 14508, 14523, 14538, 14553, 14568, - 14583, 14598, 14613, 14628, 14643, 14658, 14673, 14688, 14703, 14718, - 14733, 14748, 14763, 14778, 14793, 14808, 14823, 14838, 14853, 14868, - 14883, 14898, 14913, 14928, 14943, 14958, 14973, 14988, 15003, 15018, - 15033, 15048, 15063, 15078, 15093, 15108, 15123, 15138, 15153, 15168, - 15183, 15198, 15213, 15228, 15243, 15258, 15273, 15288, 15303, 15318, - 15333, 15348, 15363, 15378, 15393, 15408, 15423, 15438, 15453, 15468, - 15483, 15498, 15513, 15528, 15543, 15558, 15573, 15588, 15603, 15618, - 15633, 15648, 15663, 15678, 15693, 15708, 15723, 15738, 15753, 15768, - 15783, 15798, 15813, 15828, 15843, 15858, 15873, 15888, 15903, 15918, - 15933, 15948, 15963, 15978, 15993, 16008, 16023, 16038, 16053, 16068, - 16083, 16098, 16113, 16128, 16143, 16158, 16173, 16188, 16203, 16218, - 16233, 16248, 16263, 16278, 16293, 16308, 16323, 16338, 16353, 16368, - 16383, 16398, 16413, 16428, 16443, 16458, 16473, 16488, 16503, 16518, - 16533, 16548, 16563, 16578, 16593, 16608, 16623, 16638, 16653, 16668, - 16682, 16696, 16710, 16724, 1397, 16738, 16752, 16766, 16780, 16794, - 16808, 16822, 16836, 16850, 16864, 16878, 16892, 16906, 16920, 16934, - 16948, 16962, 16976, 16990, 17004, 17018, 17032, 1798, 17046, 17060, - 17074, 17088, 17102, 17116, 17130, 17144, 17158, 17172, 17186, 17200, - 17214, 17228, 17242, 17256, 17270, 17283, 17296, 17309, 17322, 17335, - 17348, 17361, 17374, 17387, 17400, 17413, 17426, 17439, 17452, 17465, - 17478, 17491, 17504, 17517, 1748, 17530, 17543, 17556, 17569, 17582, - 17595, 17608, 17621, 17634, 17647, 17660, 17673, 17686, 17699, 17712, - 17725, 17738, 17751, 17764, 17777, 17790, 17803, 17816, 17829, 17842, - 17855, 17868, 1512, 17881, 17894, 17907, 17920, 17933, 17946, 17959, - 17972, 17985, 17998, 18011, 18024, 18037, 18050, 18063, 18076, 18088, - 18100, 18112, 18124, 18136, 18148, 18160, 18172, 18184, 18196, 18208, - 18220, 18232, 18244, 18256, 1659, 18268, 18280, 18292, 1605, 18304, - 18316, 18328, 18340, 18352, 18364, 1494, 1587, 18376, 1623, 18388, 18400, - 18412, 18424, 18436, 18448, 18460, 18472, 18484, 18496, 18508, 18520, - 18532, 18544, 18556, 18568, 18580, 18592, 18604, 18616, 18628, 18640, - 18652, 18664, 18676, 18688, 18700, 18712, 18724, 18736, 18748, 18760, - 18772, 18784, 18796, 18808, 18820, 18832, 18844, 18856, 18868, 18880, - 18892, 18904, 18916, 18928, 18940, 18952, 18964, 18976, 18988, 19000, - 19012, 19024, 19036, 19048, 19060, 19072, 19084, 19096, 19108, 19120, - 19132, 19144, 19156, 19168, 19180, 19192, 19204, 19216, 19228, 19240, - 19252, 19264, 19276, 19288, 1379, 19300, 19312, 1713, 19324, 19336, - 19348, 19360, 19372, 19384, 19396, 19408, 19420, 19432, 19444, 19456, - 19468, 19480, 19492, 19504, 19516, 19528, 19540, 19552, 19564, 19576, - 19588, 19600, 19612, 19624, 19636, 19647, 19658, 19669, 19680, 19691, - 19702, 19713, 19724, 19735, 19746, 19757, 19768, 19779, 19790, 19801, - 19812, 19823, 1784, 19834, 19845, 19856, 19867, 19878, 19889, 19900, - 1869, 1296, 19911, 1419, 19922, 19933, 19944, 19955, 19966, 19977, 1886, - 19988, 19999, 20010, 20021, 20032, 20043, 20054, 20065, 20076, 20087, - 20098, 20109, 1852, 20120, 20131, 20142, 20153, 20164, 20175, 20186, - 20197, 20208, 20219, 20230, 20241, 20252, 20263, 20274, 20285, 20296, - 20307, 20318, 20329, 20340, 20351, 20362, 20373, 20384, 20395, 20406, - 20417, 20428, 20439, 20450, 20461, 20472, 20483, 20494, 20505, 20516, - 20527, 20538, 20549, 20560, 20571, 20582, 20593, 20604, 20615, 20626, - 20637, 20648, 20659, 20670, 20681, 20692, 20703, 20714, 20725, 20736, - 20747, 20758, 20769, 20780, 20791, 20802, 20813, 20824, 20835, 20846, - 20857, 20868, 20879, 20890, 20901, 20912, 20923, 20934, 20945, 20956, - 20967, 20978, 20989, 21000, 21011, 21022, 21033, 21044, 21055, 21066, - 21077, 21088, 21099, 21110, 21121, 21132, 21143, 16937, 21154, 21165, - 21176, 21187, 21198, 21209, 21220, 21231, 21242, 21253, 21264, 21275, - 21286, 21297, 21308, 21319, 21330, 21341, 21352, 21363, 21374, 21385, - 21396, 21407, 21418, 21429, 21440, 21451, 21462, 21473, 21484, 21495, - 21506, 21517, 21528, 21539, 21550, 21561, 21572, 21583, 21594, 21605, - 21615, 21625, 21635, 21645, 21655, 21665, 21675, 21685, 21695, 21705, - 21715, 21725, 21735, 21745, 21755, 21765, 21775, 21785, 21795, 18090, - 21805, 21815, 21825, 21835, 21845, 21855, 21865, 1361, 21875, 21885, - 21895, 21905, 21915, 21925, 21935, 21945, 21955, 21965, 21975, 21985, - 21995, 22005, 22015, 22025, 22035, 22045, 22055, 22065, 22075, 22085, - 22095, 22105, 22115, 22125, 22135, 22145, 22155, 22165, 22175, 22185, - 22195, 22205, 22215, 22225, 22235, 22245, 22255, 22265, 22275, 22285, - 22295, 17676, 22305, 18630, 22315, 22325, 22335, 22345, 22355, 22365, - 22375, 22385, 22395, 22405, 22415, 22425, 22435, 22445, 22455, 22465, - 22475, 22485, 22495, 22505, 22515, 22525, 22535, 22545, 22555, 22565, - 22575, 22585, 22595, 22605, 22615, 22625, 22635, 22645, 22655, 22665, - 22675, 22685, 22695, 22705, 22715, 22725, 22735, 22745, 22755, 22765, - 22775, 22785, 22795, 22805, 22815, 22825, 22835, 22845, 22855, 22865, - 22875, 22885, 22895, 22905, 22915, 22925, 22935, 22945, 22955, 22965, - 22975, 22985, 22995, 23005, 23015, 23025, 23035, 23045, 23055, 23065, - 23075, 23085, 23095, 23105, 23115, 23125, 23135, 23145, 23155, 23165, - 23175, 23185, 23195, 23205, 23215, 23225, 23235, 23245, 23255, 23265, - 23275, 23285, 23295, 23305, 23315, 23325, 23335, 23345, 23355, 23365, - 23375, 23385, 23395, 23405, 23415, 23425, 23435, 23445, 23455, 23465, - 23475, 23485, 23495, 1938, 23505, 23515, 23525, 23535, 23545, 23555, - 23565, 23575, 23585, 23595, 23605, 23615, 23625, 23635, 23645, 23655, - 23665, 23675, 23685, 23695, 23705, 23715, 23725, 23735, 23745, 23755, - 23765, 23774, 23783, 23792, 23801, 23810, 23819, 23828, 23837, 23846, - 23855, 23864, 17287, 23873, 23882, 23891, 23900, 23909, 23918, 23927, - 23936, 23945, 23954, 23963, 23972, 23981, 23990, 23999, 24008, 24017, - 24026, 24035, 24044, 24053, 24062, 24071, 24080, 24089, 24098, 24107, - 24116, 24125, 24134, 24143, 24152, 24161, 24170, 24179, 24188, 24197, - 19792, 24206, 24215, 24224, 24233, 24242, 24251, 24260, 24269, 24278, - 24287, 24296, 24305, 24314, 24323, 24332, 24341, 24350, 24359, 24368, - 24377, 24386, 24395, 24404, 24413, 24422, 19979, 24431, 24440, 24449, - 24458, 24467, 24476, 24485, 24494, 24503, 24512, 24521, 24530, 1276, - 24539, 24548, 24557, 24566, 24575, 24584, 24593, 24602, 24611, 24620, - 24629, 24638, 24647, 24656, 24665, 24674, 24683, 24692, 24701, 24710, - 24719, 24728, 24737, 24746, 24755, 24764, 24773, 24782, 24791, 24800, - 24809, 24818, 24827, 24836, 24845, 24854, 24863, 24872, 24881, 24890, - 24899, 24908, 24917, 24926, 24935, 24944, 24953, 24962, 24971, 24980, - 24989, 24998, 25007, 25016, 25025, 25034, 25043, 25052, 25061, 25070, - 25079, 25088, 25097, 25106, 25115, 25124, 25133, 25142, 25151, 25160, - 25169, 25178, 25187, 25196, 25205, 25214, 25223, 25232, 25241, 25250, - 25259, 25268, 25277, 25286, 25295, 25304, 25313, 25322, 25331, 25340, - 25349, 25358, 25367, 25376, 25385, 25394, 25403, 25412, 25421, 25430, - 25439, 25448, 25457, 25466, 25475, 25484, 25493, 25502, 25511, 25520, - 25529, 25538, 25547, 25556, 25565, 25574, 25583, 25592, 25601, 25610, - 25619, 25628, 25637, 25646, 25655, 25664, 25673, 25682, 25691, 25700, - 10755, 25709, 25718, 25727, 25736, 25745, 25754, 25763, 25772, 25781, - 25790, 25799, 25808, 25817, 25826, 25835, 25844, 25853, 25862, 25871, - 25880, 25889, 25898, 25907, 25916, 25925, 25934, 25943, 25952, 25961, - 25970, 25979, 25988, 25997, 26006, 26015, 26024, 26033, 26042, 26051, - 26060, 26069, 26078, 26087, 26096, 26105, 1837, 26114, 26123, 26132, - 26141, 26150, 26159, 26168, 26177, 26186, 26195, 26204, 26213, 26222, - 26231, 26240, 26249, 26258, 26267, 26276, 26285, 26294, 26303, 26312, - 26321, 26330, 26339, 26348, 26357, 26366, 26375, 26383, 26391, 26399, - 16674, 26407, 26415, 26423, 26431, 26439, 26447, 26455, 26463, 26471, - 21617, 26479, 26487, 26495, 26503, 26511, 26519, 26527, 26535, 22007, - 26543, 26551, 26559, 26567, 26575, 26583, 26591, 26599, 17795, 26607, - 26615, 26623, 26631, 26639, 16702, 26647, 1460, 26655, 26663, 2036, - 17899, 26671, 1956, 26679, 26687, 26695, 26703, 16758, 26711, 26719, - 26727, 18368, 26735, 26743, 26751, 17314, 26759, 26767, 26775, 26783, - 24144, 26791, 26799, 26807, 26815, 26823, 26831, 26839, 26847, 26855, - 26863, 26871, 1804, 26879, 26887, 26895, 26903, 26911, 26919, 26927, - 26935, 26943, 26951, 26959, 26967, 26975, 26983, 26991, 26999, 27007, - 27015, 27023, 27031, 27039, 27047, 27055, 27063, 27071, 27079, 27087, - 27095, 27103, 27111, 27119, 27127, 27135, 27143, 27151, 27159, 27167, - 21847, 27175, 27183, 27191, 27199, 27207, 27215, 27223, 27231, 27239, - 27247, 27255, 24531, 27263, 27271, 27279, 27287, 27295, 27303, 27311, - 27319, 27327, 27335, 27343, 27351, 27359, 27367, 27375, 27383, 27391, - 27399, 27407, 27415, 27423, 27431, 27439, 27447, 27455, 27463, 27471, - 27479, 27487, 27495, 27503, 27511, 27519, 27527, 27535, 27543, 27551, - 27559, 27567, 27575, 21157, 27583, 27591, 27599, 27607, 27615, 27623, - 27631, 27639, 27647, 27655, 27663, 27671, 27679, 27687, 27695, 27703, - 27711, 27719, 27727, 27735, 27743, 27751, 27759, 27767, 27775, 27783, - 27791, 27799, 27807, 27815, 27823, 27831, 27839, 27847, 27855, 27863, - 27871, 24567, 27879, 27887, 27895, 27903, 27911, 27919, 27927, 27935, - 27943, 27951, 27959, 27967, 21256, 27975, 27983, 1923, 27991, 27999, - 28007, 28015, 28023, 28031, 28039, 28047, 28055, 28063, 28071, 28079, - 28087, 28095, 28103, 28111, 28119, 28127, 28135, 28143, 28151, 28159, - 2004, 28167, 28175, 10852, 28183, 28191, 28199, 28207, 28215, 28223, - 19196, 28231, 28239, 28247, 28255, 28263, 28271, 28279, 28287, 28295, - 28303, 28311, 28319, 28327, 28335, 28343, 28351, 28359, 28367, 28375, - 28383, 28391, 28399, 28407, 28415, 28423, 28431, 28439, 19352, 28447, - 28455, 28463, 28471, 28479, 28487, 28495, 28503, 28511, 28519, 1699, - 28527, 28535, 28543, 28551, 28559, 28567, 28575, 28583, 28591, 28599, - 28607, 28615, 28623, 28631, 28639, 28647, 28655, 28663, 28671, 28679, - 28687, 28695, 28703, 28711, 28719, 28727, 28735, 28743, 28751, 28759, - 28767, 28775, 28783, 28791, 28799, 28807, 28815, 28823, 23187, 28831, - 28839, 28847, 28855, 28863, 28871, 28879, 28887, 28894, 28901, 18285, - 28908, 28915, 28922, 28929, 28936, 28943, 28950, 28957, 28964, 28971, - 28978, 28985, 28992, 28999, 29006, 11036, 29013, 29020, 29027, 29034, - 29041, 29048, 29055, 29062, 29069, 29076, 29083, 29090, 29097, 29104, - 29111, 29118, 29125, 29132, 29139, 29146, 29153, 29160, 29167, 1499, - 29174, 1592, 29181, 29188, 29195, 29202, 29209, 29216, 29223, 29230, - 29237, 29244, 29251, 29258, 29265, 29272, 1343, 29279, 29286, 29293, - 29300, 29307, 29314, 29321, 29328, 29335, 29342, 29349, 29356, 29363, - 29370, 29377, 29384, 29391, 29398, 21246, 29405, 29412, 29419, 29426, - 29433, 29440, 29447, 29454, 29461, 29468, 29475, 29482, 29489, 29496, - 29503, 29510, 29517, 29524, 29531, 29538, 29545, 29552, 29559, 29566, - 29573, 23956, 29580, 29587, 29594, 29601, 29608, 29615, 29622, 29629, - 29636, 29643, 29650, 29657, 29664, 29671, 29678, 29685, 29692, 29699, - 29706, 29713, 29720, 29727, 29734, 29741, 29748, 29755, 29762, 29769, - 29776, 29783, 29790, 29797, 29804, 29811, 29818, 29825, 29832, 29839, - 29846, 29853, 29860, 29867, 29874, 29881, 29888, 29895, 29902, 29909, - 29916, 29923, 29930, 29937, 29944, 29951, 29958, 29965, 29972, 24145, - 29979, 29986, 29993, 30000, 30007, 30014, 30021, 30028, 1736, 30035, - 30042, 30049, 30056, 30063, 30070, 30077, 30084, 30091, 30098, 30105, - 30112, 30119, 30126, 30133, 30140, 30147, 30154, 30161, 30168, 30175, - 30182, 30189, 30196, 30203, 30210, 30217, 30224, 30231, 30238, 30245, - 30252, 30259, 30266, 30273, 30280, 30287, 30294, 30301, 30308, 24568, - 30315, 30322, 30329, 30336, 30343, 30350, 30357, 30364, 30371, 30378, - 30385, 30392, 30399, 30406, 30413, 30420, 30427, 30434, 30441, 30448, - 30455, 21191, 30462, 30469, 30476, 30483, 30490, 30497, 30504, 30511, - 30518, 27312, 30525, 30532, 30539, 30546, 30553, 30560, 30567, 30574, - 30581, 30588, 30595, 30602, 30609, 30616, 30623, 30630, 30637, 30644, - 30651, 30658, 30665, 30672, 30679, 30686, 30693, 30700, 30707, 30714, - 30721, 30728, 30735, 30742, 30749, 30756, 30763, 30770, 30777, 23348, - 30784, 30791, 30798, 30805, 30812, 28376, 30819, 30826, 30833, 30840, - 30847, 30854, 30861, 30868, 30875, 30882, 30889, 30896, 26464, 30903, - 30910, 30917, 30924, 30931, 30938, 30945, 30952, 30959, 30966, 30973, - 30980, 30987, 30994, 31001, 18141, 31008, 31015, 31022, 31029, 31036, - 31043, 31050, 31057, 31064, 31071, 24460, 31078, 31085, 31092, 31099, - 19065, 31106, 31113, 31120, 31127, 31134, 31141, 31148, 31155, 31162, - 31169, 31176, 31183, 31190, 31197, 31204, 31211, 31218, 31225, 31232, - 31239, 31246, 24586, 31253, 31260, 23188, 31267, 31274, 31281, 31288, - 31295, 31302, 31309, 31316, 31323, 31330, 31337, 31344, 31351, 31357, - 31363, 31369, 31375, 31381, 31387, 31393, 31399, 31405, 22259, 31411, - 31417, 31423, 31429, 31435, 27049, 31441, 31447, 31345, 31453, 31459, - 21739, 31465, 31471, 31477, 31483, 31489, 31495, 31501, 31507, 31513, - 21819, 31519, 31525, 31531, 31537, 31543, 31549, 31555, 31561, 31567, - 31573, 31579, 31585, 31591, 31597, 31603, 31609, 31615, 31621, 31627, - 17576, 22329, 31633, 31639, 31645, 19905, 1169, 31651, 17381, 31657, - 31663, 1301, 31669, 31675, 1538, 18562, 31681, 31687, 16732, 31693, - 18454, 31699, 1405, 17082, 31705, 31711, 31717, 18166, 31723, 31729, - 31735, 31741, 31747, 31753, 26793, 31759, 31765, 31771, 31777, 21699, - 31783, 31789, 31795, 31801, 31807, 31813, 31819, 31825, 10962, 1044, - 31831, 31837, 31843, 31849, 17563, 31855, 31861, 31867, 31873, 31879, - 31885, 31891, 31897, 31903, 31909, 31915, 31921, 31927, 31933, 31939, - 31945, 31951, 31957, 31963, 31969, 31975, 31981, 31987, 31993, 31999, - 32005, 32011, 32017, 32023, 32029, 32035, 21489, 32041, 32047, 32053, - 32059, 32065, 32071, 32077, 32083, 32089, 32095, 24596, 32101, 32107, - 32113, 32119, 32125, 18466, 32131, 32137, 32143, 32149, 32155, 32161, - 32167, 32173, 32179, 32185, 32191, 32197, 32203, 32209, 32215, 32221, - 32227, 21909, 32233, 32239, 32245, 32251, 32257, 32263, 32269, 32275, - 32281, 32287, 32293, 32299, 32305, 32311, 32317, 32323, 32329, 32335, - 32341, 32347, 32353, 32359, 32365, 32371, 32377, 32383, 32389, 32395, - 32401, 32407, 26216, 32413, 32419, 32425, 32431, 32437, 32443, 32449, - 32455, 32461, 32467, 32473, 32479, 32485, 32491, 32497, 32503, 32509, - 32515, 32521, 32527, 32533, 32539, 32545, 32551, 21159, 32557, 32563, - 32569, 32575, 32581, 32587, 32593, 32599, 32605, 32611, 32617, 32623, - 32629, 32635, 32641, 32647, 32653, 32659, 21899, 32665, 32671, 32677, - 32683, 32689, 32695, 32701, 32707, 32713, 32719, 32725, 32731, 32737, - 32743, 32749, 32755, 32761, 32767, 32773, 32779, 32785, 32791, 32797, - 32803, 32809, 32815, 32821, 30176, 32827, 32833, 32839, 32845, 32851, - 32857, 32863, 32869, 32875, 32881, 32887, 27441, 21789, 32893, 32899, - 32905, 32911, 32917, 32923, 32929, 28817, 32935, 32941, 32947, 32953, - 32959, 32965, 32971, 32977, 32983, 32989, 32995, 33001, 33007, 33013, - 33019, 33025, 33031, 33037, 33043, 33049, 33055, 33061, 33067, 33073, - 33079, 33085, 33091, 33097, 33103, 33109, 33115, 33121, 33127, 33133, - 33139, 33145, 33151, 33157, 33163, 33169, 33175, 33181, 33187, 33193, - 33199, 33205, 33211, 33217, 33223, 33229, 33235, 33241, 33247, 33253, - 33259, 33265, 33271, 33277, 33283, 33289, 33295, 33301, 33307, 33313, - 33319, 33325, 33331, 33337, 33343, 33349, 33355, 33361, 33367, 33373, - 33379, 33385, 33391, 33397, 33403, 33409, 33415, 33421, 33427, 33433, - 33439, 33445, 33451, 33457, 33463, 33469, 33475, 33481, 33487, 33493, - 33499, 33505, 33511, 33517, 33523, 33529, 33535, 33541, 33547, 33553, - 33559, 33565, 33571, 33577, 33583, 33589, 33595, 33601, 33607, 33613, - 33619, 33625, 33631, 33637, 33643, 33649, 33655, 33661, 33667, 33673, - 33679, 33685, 33691, 33697, 33703, 33709, 33715, 33721, 33727, 33733, - 33739, 33745, 33751, 33757, 33763, 33769, 33775, 33781, 33787, 33793, - 33799, 33805, 33811, 29679, 33817, 33823, 33829, 33835, 33841, 33847, - 33853, 33859, 33865, 33871, 33877, 33883, 33889, 33895, 33901, 33907, - 33913, 33919, 33925, 33931, 33937, 33943, 33949, 33955, 33961, 33967, - 33973, 33979, 33985, 33991, 33997, 34003, 34009, 34015, 34021, 34027, - 34033, 34039, 34045, 34051, 34057, 34063, 34069, 34075, 34081, 34087, - 34093, 34099, 34105, 34111, 34117, 34123, 34129, 34135, 34141, 34147, - 34153, 34159, 34165, 34171, 34177, 34183, 34189, 34195, 34201, 34207, - 34213, 34219, 34225, 34231, 34237, 34243, 34249, 34255, 34261, 34267, - 34273, 34279, 34285, 34291, 34297, 34303, 25847, 34309, 34315, 34321, - 34327, 34333, 34339, 34345, 34351, 34357, 34363, 34369, 34375, 34381, - 34387, 34393, 34399, 34405, 34411, 34417, 34423, 10932, 34429, 34435, - 34441, 34447, 34453, 34459, 34465, 34471, 34477, 34483, 34489, 34495, - 18502, 34501, 34507, 31240, 34513, 34519, 24605, 34525, 34531, 34537, - 34543, 34549, 34555, 34561, 34567, 34573, 34579, 34585, 34591, 34597, - 34603, 34609, 34615, 34621, 34627, 34633, 34639, 34645, 34651, 34657, - 34663, 34669, 34675, 34681, 34687, 34693, 34699, 23279, 34705, 34711, - 34717, 34723, 34729, 34735, 34741, 34747, 34753, 34759, 34765, 34771, - 34777, 34783, 34789, 34795, 34801, 34807, 34813, 34819, 34825, 34831, - 34837, 34843, 34849, 34854, 34859, 34864, 34869, 23967, 34874, 32672, - 34879, 34884, 34889, 17629, 34894, 34899, 34904, 34909, 34914, 34919, - 34924, 34929, 34934, 34939, 34944, 34949, 34954, 34959, 23480, 34964, - 34969, 32852, 34974, 34979, 34984, 34989, 34994, 34999, 35004, 35009, - 35014, 31994, 35019, 35024, 35029, 26091, 35034, 35039, 35044, 35049, - 35054, 35059, 35064, 35069, 35074, 35079, 35084, 35089, 35094, 35099, - 35104, 1366, 35109, 35114, 35119, 35124, 35129, 35134, 35139, 35144, - 35149, 35154, 35159, 35164, 35169, 35174, 35179, 35184, 35189, 35194, - 35199, 35204, 35209, 35214, 35219, 35224, 35229, 35234, 35239, 35244, - 35249, 35254, 35259, 35264, 31868, 35269, 35274, 35279, 35284, 382, - 35289, 35294, 35299, 35304, 35309, 35314, 35319, 35324, 1019, 35329, - 35334, 35339, 21670, 35344, 35349, 35354, 31424, 35359, 35364, 35369, - 35374, 35379, 35384, 35389, 35394, 35399, 35404, 35409, 35414, 35419, - 35424, 35429, 35434, 35439, 17278, 35444, 35449, 35454, 35459, 35464, - 35469, 35474, 35479, 35484, 34778, 35489, 30492, 35494, 35499, 35504, - 35509, 35514, 35519, 35524, 35529, 34508, 35534, 17642, 35539, 35544, - 35549, 35554, 32090, 35559, 35564, 35569, 35574, 35579, 35584, 21127, - 35589, 35594, 35599, 35604, 35609, 23460, 35614, 35619, 35624, 35629, - 35634, 35639, 35644, 35649, 35654, 35659, 35664, 35669, 35674, 35679, - 35684, 35689, 35694, 35699, 35704, 35709, 35714, 35719, 35724, 35729, - 35734, 35739, 35744, 35749, 35754, 35759, 35764, 35769, 35774, 35779, - 35784, 35789, 21259, 35794, 35799, 35804, 35809, 35814, 27002, 35819, - 35824, 35829, 35834, 35839, 35844, 35849, 35854, 35859, 35864, 35869, - 35874, 35879, 35884, 35889, 35894, 35899, 35904, 35909, 35914, 34226, - 35919, 35924, 35929, 35934, 35939, 35944, 35949, 35954, 35959, 35964, - 35969, 35974, 35979, 35984, 33152, 35989, 35994, 29638, 35999, 36004, - 36009, 16929, 36014, 36019, 36024, 36029, 28370, 36034, 36039, 36044, - 36049, 36054, 36059, 36064, 29554, 36069, 36074, 36079, 36084, 36089, - 36094, 36099, 36104, 36109, 36114, 36119, 36124, 36129, 36134, 36139, - 36144, 36149, 36154, 36159, 36164, 36169, 36174, 34586, 36179, 36184, - 36189, 29862, 36194, 36199, 36204, 36209, 36214, 36219, 36224, 36229, - 36234, 36239, 24723, 36244, 36249, 36254, 36259, 36264, 36269, 36274, - 36279, 36284, 36289, 23160, 36294, 36299, 36304, 36309, 30450, 36314, - 36319, 36324, 36329, 36334, 36339, 26262, 36344, 36349, 36354, 36359, - 36364, 36369, 36374, 36379, 36384, 36389, 36394, 36399, 36404, 36409, - 36414, 36419, 36424, 36429, 36434, 36439, 36444, 36449, 36454, 36459, - 36464, 36469, 36474, 36479, 36484, 36489, 36494, 36499, 32570, 32576, - 32582, 36504, 36509, 36514, 36519, 36524, 36529, 36534, 32588, 32594, - 32600, 33764, 36539, 36544, 36549, 36554, 36559, 36564, 36569, 36574, - 36579, 36584, 36589, 36594, 36599, 36604, 36609, 36614, 36619, 36624, - 36629, 36634, 36639, 31850, 36644, 36649, 36654, 36659, 36664, 36669, - 36674, 36679, 36684, 36689, 36694, 36699, 36704, 36709, 36714, 36719, - 36724, 36729, 36734, 36739, 36744, 36749, 36754, 36759, 36764, 36769, - 36774, 36779, 36784, 36789, 36794, 36799, 36804, 36809, 36814, 36819, - 36824, 36829, 36834, 36839, 36844, 36849, 36854, 36859, 36864, 32858, - 32864, 36869, 36874, 36879, 36884, 36889, 36894, 36899, 36904, 32876, - 32882, 36909, 36914, 36919, 36924, 36929, 34748, 34754, 36934, 36939, - 36944, 36949, 36954, 36959, 36964, 36969, 36974, 36979, 36984, 36989, - 36994, 36999, 37004, 37009, 37014, 37019, 37024, 37029, 37034, 37039, - 37044, 37049, 37054, 37059, 37064, 37069, 37074, 37079, 33092, 37084, - 33098, 37089, 37094, 16831, 26698, 37099, 33104, 33110, 33116, 33122, - 37104, 37109, 37114, 37119, 32714, 37124, 37129, 37134, 37139, 37144, - 37149, 37154, 37159, 37164, 37169, 37174, 37179, 37184, 37189, 37194, - 37199, 37204, 37209, 37214, 37219, 37224, 37229, 37234, 37239, 37244, - 37249, 37254, 37259, 37264, 37269, 37274, 37279, 37284, 37289, 37294, - 37299, 37304, 37309, 37314, 37319, 37324, 37329, 37334, 37339, 37344, - 37349, 37354, 37359, 37364, 37369, 37374, 37379, 37384, 37389, 37394, - 37399, 37404, 37409, 37414, 37419, 32750, 32756, 32762, 34154, 37424, - 37429, 37434, 37439, 37444, 37449, 37454, 37459, 37464, 37469, 37474, - 37479, 37484, 37489, 37494, 37499, 37504, 37509, 37514, 37519, 37524, - 37529, 33380, 33386, 33392, 37534, 37539, 37544, 37549, 37554, 37559, - 37564, 37569, 37574, 37579, 37584, 37589, 37594, 37599, 37604, 37609, - 33398, 37614, 33404, 33410, 33848, 37619, 37624, 37629, 37634, 37639, - 37644, 37649, 37654, 37659, 37664, 37669, 37674, 37679, 37684, 37689, - 37694, 37699, 37704, 37709, 37714, 37719, 37724, 37729, 37734, 37739, - 1234, 21920, 37744, 37749, 37754, 37759, 37764, 37769, 37774, 37779, - 34562, 37784, 37789, 33206, 37794, 33212, 37799, 37804, 37809, 33218, - 37814, 33224, 33230, 33236, 37819, 30366, 37824, 37829, 37834, 37839, - 37844, 37849, 37854, 37859, 37864, 37869, 37874, 37879, 37884, 37889, - 37894, 37899, 37904, 33242, 33248, 37909, 37914, 37919, 37924, 28194, - 37929, 37934, 33254, 37939, 33260, 33266, 37944, 37949, 37954, 30744, - 37959, 37964, 37969, 37974, 37979, 37984, 37989, 37994, 37999, 38004, - 38009, 38014, 38019, 38024, 38029, 38034, 38039, 38044, 38049, 38054, - 38059, 31682, 38064, 38069, 38074, 38079, 38084, 38089, 38094, 38099, - 38104, 38109, 38114, 33854, 38119, 38124, 38129, 38134, 38139, 38144, - 38149, 33860, 33866, 38154, 38159, 38164, 38169, 33278, 33290, 31622, - 38174, 38179, 38184, 38189, 38194, 38199, 38204, 38209, 38214, 38219, - 38224, 38229, 38234, 38239, 38244, 38249, 38254, 38259, 30961, 38264, - 38269, 38274, 38279, 38284, 38289, 38294, 38299, 38304, 38309, 38314, - 38319, 38324, 38329, 38334, 38339, 38344, 38349, 38354, 33296, 38359, - 38364, 38369, 38374, 38379, 38384, 38389, 38394, 38399, 38404, 38409, - 38414, 38419, 38424, 38429, 38434, 38439, 38444, 38449, 38454, 38459, - 38464, 38469, 38474, 38479, 38484, 38489, 38494, 38499, 38504, 38509, - 38514, 38519, 38524, 38529, 38534, 38539, 38544, 38549, 38554, 38559, - 38564, 38569, 38574, 38579, 38584, 38589, 38594, 38599, 38604, 38609, - 38614, 38619, 38624, 38629, 38634, 38639, 38644, 38649, 38654, 38659, - 38664, 38669, 38674, 38679, 38684, 38689, 38694, 38699, 38704, 38709, - 38714, 38719, 38724, 38729, 38734, 38739, 38744, 38749, 38754, 34112, - 38759, 38764, 38769, 38774, 38779, 38784, 38789, 38794, 38799, 38804, - 38809, 38814, 38819, 38824, 38829, 38834, 38839, 38844, 38849, 38854, - 34238, 33890, 38859, 33896, 38864, 38869, 38874, 38879, 38884, 38889, - 38894, 38899, 38904, 38909, 38914, 38919, 38924, 38929, 38934, 38939, - 38944, 38949, 38954, 38959, 38964, 38969, 38974, 38979, 34448, 34454, - 38984, 38989, 38994, 38999, 39004, 24687, 832, 39009, 39014, 39019, - 39024, 39029, 39034, 39039, 39044, 39049, 39054, 39059, 39064, 39069, - 39074, 39079, 39084, 39089, 39094, 39099, 39104, 39109, 39114, 39119, - 39124, 39129, 39134, 39139, 39144, 39149, 34460, 39154, 39159, 39164, - 39169, 39174, 39179, 39184, 39189, 39194, 33986, 39199, 39204, 39209, - 39214, 39219, 39224, 39229, 39234, 21700, 39239, 39244, 39249, 39254, - 39259, 39264, 39269, 30688, 39274, 39279, 39284, 39289, 39294, 39299, - 39304, 39309, 39314, 39319, 39324, 39329, 39334, 39339, 39344, 39349, - 39354, 39359, 39364, 39369, 39374, 32486, 39379, 31171, 23500, 39384, - 39389, 39394, 39399, 39404, 39409, 39414, 39419, 26882, 39424, 39429, - 39434, 39439, 39444, 33320, 33326, 33332, 39449, 33350, 33500, 33506, - 39454, 39459, 39464, 39469, 39474, 39479, 33908, 33914, 33920, 39484, - 39489, 39494, 39499, 39504, 39509, 39514, 39519, 39524, 33926, 39529, - 33932, 39534, 39539, 39544, 39549, 39554, 39559, 39564, 39569, 39574, - 39579, 39584, 39589, 39594, 39599, 39604, 39609, 39614, 39619, 39624, - 39629, 39634, 39639, 39644, 33938, 33944, 39649, 33950, 33956, 33962, - 39654, 39659, 39664, 39669, 39674, 39679, 39684, 39689, 39694, 39699, - 39704, 39709, 39714, 39719, 39724, 39729, 39734, 39739, 39744, 39748, - 39752, 39756, 39760, 39764, 21841, 17890, 39768, 39772, 36180, 39776, - 21117, 23101, 32331, 39780, 33561, 39784, 39788, 39792, 25822, 39796, - 32967, 39800, 39804, 18300, 39808, 26047, 39812, 39816, 31032, 39820, - 31455, 39824, 39828, 39832, 39836, 31791, 39840, 39844, 23191, 16958, - 39848, 32853, 39852, 31551, 39856, 39860, 39864, 21751, 36425, 39868, - 17487, 39872, 39876, 35570, 39880, 39884, 21238, 27099, 39888, 39892, - 39896, 30745, 39900, 39904, 39310, 39325, 39908, 32787, 28946, 35270, - 37560, 36185, 39912, 39916, 31081, 35575, 19188, 39920, 36500, 39924, - 39928, 39932, 39936, 247, 39940, 39944, 39948, 39952, 39956, 39960, - 26326, 39964, 36910, 39968, 39972, 39976, 39980, 36775, 39984, 39988, - 39992, 39996, 40000, 40004, 40008, 37535, 40012, 40016, 40020, 40024, - 40028, 38260, 40032, 40036, 40040, 40044, 40048, 21971, 34587, 40052, - 27203, 40056, 40060, 40064, 32355, 40068, 38370, 36915, 40072, 40076, - 40080, 40084, 40088, 38890, 29814, 40092, 40096, 33855, 40100, 30437, - 26353, 40104, 39005, 40108, 40112, 36155, 40116, 27971, 40120, 40124, - 40128, 40132, 37400, 40136, 40140, 40144, 40148, 39015, 40152, 38270, - 38765, 40156, 40160, 40164, 39290, 39300, 40168, 1081, 40172, 1058, - 39330, 39335, 39340, 39130, 27139, 40176, 40180, 40184, 40188, 32367, - 40192, 38365, 29877, 29884, 40196, 40200, 32385, 40204, 40208, 40212, - 31249, 40216, 40220, 40224, 36440, 40228, 30542, 1229, 29450, 40232, - 40236, 40240, 40244, 40248, 40252, 40256, 40260, 40264, 40268, 40272, - 40276, 40280, 25615, 40284, 40288, 40292, 40296, 40300, 40304, 34389, - 30920, 24715, 37775, 40308, 40312, 40316, 40320, 40324, 40328, 40332, - 37010, 37015, 40336, 40340, 40344, 40348, 40352, 40356, 40360, 37045, - 40364, 29653, 40368, 34563, 40372, 40376, 36605, 40380, 40384, 40388, - 40392, 40396, 40400, 32913, 40404, 40408, 40412, 40416, 40420, 40424, - 40428, 40432, 40436, 40440, 40444, 36885, 36165, 36170, 37185, 40448, - 40452, 40456, 40460, 37245, 40464, 18672, 40468, 40472, 37295, 40476, - 40480, 40484, 40488, 40492, 40496, 40500, 27075, 40504, 40508, 40512, - 40516, 40520, 40524, 40528, 35670, 40532, 40536, 40540, 40544, 40548, - 19753, 40552, 40556, 40560, 40564, 40568, 40572, 40576, 40580, 40584, - 33609, 40588, 40592, 40596, 40600, 40604, 40608, 40612, 38275, 902, - 40616, 40620, 40624, 39280, 20314, 40628, 24130, 40632, 40636, 40640, - 40644, 40648, 40652, 40656, 40660, 40664, 40668, 39295, 40672, 31839, - 24832, 29709, 40676, 40680, 28427, 40684, 40688, 27459, 40692, 32001, - 40696, 40700, 24076, 40704, 23281, 34197, 40708, 40712, 40716, 40720, - 40724, 40728, 40732, 40736, 40740, 40744, 33507, 32361, 40748, 40752, - 40756, 40760, 40764, 38385, 40768, 38395, 38425, 40772, 40776, 40780, - 39155, 40784, 40788, 40792, 40796, 35580, 40800, 35930, 38485, 39460, - 27371, 33783, 24400, 40804, 26299, 40808, 40812, 40816, 36370, 28123, - 36380, 40820, 40824, 40828, 40832, 40836, 40840, 40844, 40848, 40852, - 36385, 40856, 40860, 36390, 35900, 40864, 36400, 36405, 36410, 40868, - 36415, 36420, 36430, 36435, 35490, 36445, 40872, 36450, 38030, 36455, - 36460, 40876, 23878, 40880, 40884, 40888, 40892, 40896, 40900, 40904, - 40908, 40912, 40916, 29184, 40920, 40924, 40928, 40932, 40936, 40940, - 40944, 40948, 40952, 40956, 40960, 40964, 40968, 40972, 40976, 27995, - 40980, 40984, 28323, 40988, 36760, 40992, 36765, 28843, 36770, 40996, - 41000, 36780, 31683, 41004, 36790, 36795, 36800, 36805, 37485, 41008, - 41012, 41016, 38895, 36810, 36820, 41020, 41024, 41028, 36825, 36830, - 35565, 36835, 36840, 36845, 41032, 41036, 41040, 41044, 41048, 41052, - 41056, 41060, 41064, 25957, 35865, 41068, 41072, 41076, 41080, 41084, - 41088, 41092, 41096, 41100, 41104, 41108, 41112, 41116, 41120, 41124, - 41128, 41132, 41136, 41140, 41144, 41148, 41152, 41156, 41160, 41164, - 41168, 41172, 41176, 41180, 41184, 41188, 41192, 36995, 41196, 37000, - 37005, 41200, 41204, 29590, 37020, 41208, 37025, 41212, 41216, 41220, - 41224, 37030, 41228, 37035, 37040, 35635, 37050, 41232, 29107, 41236, - 35640, 37055, 37060, 37065, 37070, 41240, 41244, 41248, 41252, 35770, - 41256, 36575, 19560, 36585, 24652, 28723, 41260, 41264, 36590, 36595, - 36600, 33585, 41268, 41272, 41276, 41280, 35445, 21227, 25813, 41284, - 41288, 41292, 41296, 41300, 41304, 41308, 41312, 41316, 41320, 41324, - 41328, 25885, 36140, 29555, 36615, 36620, 41332, 36625, 31851, 36075, - 36080, 36085, 41336, 41340, 41344, 41348, 41352, 41356, 41360, 39480, - 34377, 32571, 32493, 32583, 21095, 36310, 41364, 33423, 28763, 39245, - 41368, 41372, 41376, 41380, 41384, 35760, 37540, 37545, 37550, 41388, - 41392, 37555, 37565, 37570, 37575, 37580, 35765, 37585, 41396, 37590, - 38235, 37595, 37600, 41400, 41404, 41408, 25588, 41412, 41416, 37675, - 41420, 672, 41424, 41428, 41432, 20248, 41436, 41440, 41444, 41448, - 41452, 41456, 41460, 41464, 41468, 41472, 41476, 41480, 18228, 41484, - 41488, 41492, 41496, 41500, 41504, 41508, 41512, 41516, 41520, 41524, - 41528, 41532, 41536, 41540, 41544, 26344, 37160, 41548, 35610, 37170, - 41552, 41556, 37175, 29079, 19643, 41560, 36160, 39255, 41564, 41568, - 41572, 36960, 41576, 37195, 37200, 41580, 41584, 37205, 41588, 283, - 37210, 37215, 37220, 36090, 37230, 37235, 37240, 37250, 37255, 41592, - 32979, 24184, 41596, 37265, 37270, 41600, 41604, 41608, 41612, 41616, - 41620, 41624, 41628, 41632, 37275, 41636, 41640, 41644, 41648, 37280, - 33555, 37290, 41652, 37300, 37305, 41656, 37310, 37315, 37320, 30549, - 37330, 41660, 37335, 41664, 37345, 41668, 33723, 41672, 37350, 16589, - 37360, 41676, 41680, 41684, 41688, 41692, 32085, 41696, 32625, 18636, - 18156, 41700, 37365, 41704, 37370, 41708, 26859, 41712, 38255, 28619, - 22221, 37375, 33141, 37380, 37385, 37390, 41716, 41720, 41724, 41728, - 41732, 41736, 37395, 34815, 37405, 41740, 41744, 41748, 41752, 41756, - 41760, 37410, 41764, 41768, 37415, 41772, 41776, 41780, 41784, 41788, - 41792, 41796, 41800, 34749, 34755, 35390, 34539, 30934, 41804, 41808, - 41812, 35480, 41816, 41820, 41824, 34257, 41828, 41832, 41836, 41840, - 41844, 39010, 41848, 41852, 41856, 41860, 41864, 41868, 41872, 41876, - 41880, 41884, 41888, 41892, 41896, 41900, 41904, 41908, 41912, 41916, - 41920, 41924, 41928, 41932, 41936, 41940, 41944, 41948, 41952, 41956, - 41960, 41964, 41968, 41972, 41976, 41980, 41984, 41988, 41992, 41996, - 42000, 42004, 42008, 42012, 42016, 16832, 42020, 38280, 26627, 42024, - 38285, 33081, 38295, 23231, 28139, 42028, 42032, 42036, 42040, 35190, - 38790, 38305, 42044, 42048, 42052, 42056, 42060, 42064, 38800, 38310, - 38315, 38320, 38325, 42068, 42072, 38330, 38335, 38340, 38345, 42076, - 42080, 42084, 28795, 20325, 39030, 42088, 42092, 39035, 39040, 42096, - 42100, 42104, 42108, 39045, 42112, 42116, 39050, 39055, 42120, 42124, - 39065, 39070, 39075, 42128, 42132, 42136, 42140, 42144, 35680, 42148, - 39080, 42152, 39085, 39090, 39095, 39100, 39105, 39110, 42156, 42160, - 42164, 42168, 42172, 42176, 42180, 42184, 42188, 42192, 39305, 39120, - 42196, 42200, 42204, 42208, 42212, 42216, 42220, 42224, 42228, 42232, - 42236, 42240, 1944, 42244, 42248, 42252, 42256, 42260, 42264, 42268, - 42272, 42276, 42280, 42284, 42288, 42292, 42296, 42300, 42304, 42308, - 42312, 42316, 42320, 39505, 36940, 42324, 22211, 42328, 42332, 36345, - 42336, 32589, 32595, 26867, 42340, 27419, 42344, 42348, 42352, 42356, - 42360, 42364, 42368, 42372, 42376, 42380, 42384, 42388, 42392, 42396, - 42400, 42404, 42408, 42412, 42416, 42420, 42424, 42428, 42432, 42436, - 42440, 42444, 42448, 42452, 42456, 42460, 42464, 42468, 37715, 37720, - 37450, 37455, 35720, 37460, 35725, 42472, 37465, 37470, 35730, 37725, - 37730, 37735, 42476, 42480, 42484, 42488, 42492, 38380, 42496, 35920, - 38390, 35925, 38400, 42500, 38405, 38410, 42504, 38415, 38420, 42508, - 42512, 42516, 42520, 42524, 38430, 38435, 38440, 39670, 38445, 42528, - 38450, 38455, 38460, 38465, 42532, 38470, 38475, 42536, 38480, 42540, - 38490, 39165, 38495, 38500, 38505, 38510, 42544, 42548, 42552, 33663, - 42556, 42560, 42564, 24140, 42567, 31540, 17813, 23202, 5561, 22212, - 4793, 28140, 27100, 24761, 36316, 26612, 21692, 42570, 17488, 40609, - 40625, 25760, 42573, 42576, 39857, 5049, 42579, 30452, 25463, 21195, - 5305, 32296, 29353, 34708, 29535, 42582, 39913, 42585, 34732, 40521, - 19754, 903, 42588, 34114, 32170, 42591, 1408, 36076, 42594, 733, 41349, - 30746, 42597, 692, 40517, 21239, 17239, 36606, 25427, 23302, 36081, - 19033, 42600, 1132, 42603, 18613, 698, 1027, 6073, 30844, 38601, 41313, - 726, 36866, 35866, 17267, 27124, 42606, 4857, 42609, 32452, 1021, 19069, - 42612, 23142, 19201, 19974, 32824, 42615, 25688, 42618, 42621, 42624, - 42627, 42630, 35386, 26327, 19309, 30648, 32002, 42633, 1193, 33484, - 34060, 39921, 33664, 5113, 40837, 18637, 42636, 34678, 28620, 20249, - 42639, 42642, 24716, 42645, 42648, 42651, 18157, 21250, 41005, 18397, - 42654, 32164, 1172, 22202, 42657, 34774, 297, 42660, 41337, 42663, 33634, - 30949, 19561, 40833, 5897, 24203, 23252, 20392, 31152, 24401, 40389, - 30193, 42666, 42669, 26420, 41045, 16833, 17280, 40829, 42672, 26964, - 35581, 40393, 40397, 42675, 42678, 18565, 29339, 965, 10745, 42681, - 42684, 42687, 16763, 42690, 29500, 42693, 34648, 42696, 12, 26492, 42699, - 5369, 42702, 39881, 42705, 31636, 28724, 24626, 673, 28820, 42708, 42711, - 42714, 42717, 1215, 42720, 42723, 42726, 18661, 42729, 42732, 42735, - 42738, 41593, 39506, 42741, 19525, 40841, 42744, 42747, 42750, 42753, - 42756, 30473, 29003, 31918, 42759, 6137, 32536, 42762, 42765, 42768, - 42771, 34180, 42774, 42777, 42780, 42783, 42786, 42121, 42789, 21591, - 1163, 42792, 42795, 42798, 42801, 41065, 42804, 23432, 1059, 284, 42807, - 915, 42810, 42813, 42816, 21063, 42819, 42257, 29661, 28524, 18457, - 42822, 41077, 42825, 39546, 16530, 39286, 42828, 24185, 41889, 19549, - 36381, 42831, 42834, 42837, 42840, 21972, 5337, 5353, 1465, 42843, 42846, - 5577, 42849, 42852, 42855, 19644, 6153, 41121, 42858, 42861, 42864, - 41713, 351, 42867, 42870, 42873, 42876, 42879, 41225, 22062, 21228, - 32194, 42882, 21085, 42885, 978, 42888, 40401, 42891, 33652, 42894, - 42897, 42900, 42903, 42906, 42909, 42912, 42915, 42918, 36306, 42921, - 42241, 42924, 664, 42927, 32044, 42930, 42933, 42936, 42939, 42942, - 42945, 42948, 42951, 42954, 41321, 42957, 42960, 42963, 35831, 42966, - 42969, 42972, 32374, 42975, 42978, 42981, 42984, 32596, 42987, 42990, - 42993, 1961, 42996, 41853, 42999, 43002, 36331, 43005, 43008, 36711, - 43011, 43014, 43017, 43020, 43023, 23789, 43026, 43029, 43032, 29969, - 43035, 42137, 43038, 43041, 43044, 32056, 43047, 43050, 17211, 29962, - 35641, 952, 43053, 43056, 31384, 43059, 43062, 41341, 40813, 41541, - 43065, 43068, 43071, 43074, 37776, 43077, 41797, 50, 1147, 43080, 40498, - 23862, 43082, 272, 43084, 34061, 40162, 28976, 35482, 43086, 571, 28906, - 27141, 43088, 43090, 811, 32057, 33707, 307, 911, 357, 43092, 37682, - 24357, 241, 43094, 42829, 43096, 4, 22233, 926, 948, 29116, 43098, 43100, - 19689, 796, 40762, 333, 42706, 710, 88, 41206, 623, 313, 165, 35797, - 42643, 32039, 19722, 31367, 43102, 43104, 28005, 43106, 43108, 43110, - 20008, 35102, 43112, 27541, 41598, 43114, 39746, 474, 1205, 28766, 51, - 98, 5, 14, 308, 171, 102, 70, 57, 9, 34, 273, 363, 804, 149, 348, 42737, - 43116, 465, 43117, -}; - -/* code->name phrasebook */ -#define phrasebook_shift 8 -#define phrasebook_short 231 -static unsigned char phrasebook[] = { - 0, 242, 69, 236, 186, 65, 238, 76, 65, 83, 57, 242, 158, 57, 240, 248, - 57, 237, 124, 236, 190, 36, 236, 47, 37, 236, 47, 238, 77, 249, 4, 57, - 242, 84, 235, 243, 213, 189, 239, 144, 27, 244, 173, 27, 121, 27, 114, - 27, 153, 27, 163, 27, 168, 27, 169, 27, 179, 27, 176, 27, 178, 242, 81, - 237, 123, 206, 57, 242, 61, 57, 196, 57, 239, 126, 65, 237, 127, 253, - 220, 9, 5, 1, 64, 9, 5, 1, 199, 9, 5, 1, 203, 9, 5, 1, 187, 9, 5, 1, 70, - 9, 5, 1, 204, 9, 5, 1, 194, 9, 5, 1, 164, 9, 5, 1, 69, 9, 5, 1, 200, 9, - 5, 1, 205, 9, 5, 1, 148, 9, 5, 1, 171, 9, 5, 1, 183, 9, 5, 1, 78, 9, 5, - 1, 198, 9, 5, 1, 209, 9, 5, 1, 135, 9, 5, 1, 159, 9, 5, 1, 190, 9, 5, 1, - 84, 9, 5, 1, 186, 9, 5, 1, 201, 9, 5, 1, 170, 9, 5, 1, 181, 9, 5, 1, 202, - 36, 30, 110, 240, 219, 239, 144, 37, 30, 110, 157, 240, 203, 253, 113, - 244, 176, 244, 201, 240, 203, 9, 3, 1, 64, 9, 3, 1, 199, 9, 3, 1, 203, 9, - 3, 1, 187, 9, 3, 1, 70, 9, 3, 1, 204, 9, 3, 1, 194, 9, 3, 1, 164, 9, 3, - 1, 69, 9, 3, 1, 200, 9, 3, 1, 205, 9, 3, 1, 148, 9, 3, 1, 171, 9, 3, 1, - 183, 9, 3, 1, 78, 9, 3, 1, 198, 9, 3, 1, 209, 9, 3, 1, 135, 9, 3, 1, 159, - 9, 3, 1, 190, 9, 3, 1, 84, 9, 3, 1, 186, 9, 3, 1, 201, 9, 3, 1, 170, 9, - 3, 1, 181, 9, 3, 1, 202, 36, 244, 175, 110, 55, 244, 176, 37, 244, 175, - 110, 180, 239, 190, 242, 69, 239, 116, 236, 186, 65, 249, 196, 57, 245, - 163, 57, 239, 147, 57, 254, 78, 57, 242, 173, 143, 242, 5, 57, 150, 238, - 195, 57, 239, 216, 241, 71, 237, 136, 235, 237, 42, 160, 238, 76, 65, - 141, 57, 249, 119, 240, 241, 238, 52, 57, 166, 242, 156, 57, 238, 45, 57, - 236, 181, 114, 236, 181, 153, 244, 196, 240, 203, 247, 93, 57, 241, 74, - 57, 242, 65, 227, 239, 117, 236, 181, 121, 239, 47, 241, 71, 237, 136, - 235, 190, 42, 160, 238, 76, 65, 242, 83, 239, 123, 253, 101, 240, 147, - 242, 83, 239, 123, 253, 101, 244, 217, 242, 83, 239, 123, 244, 171, 239, - 67, 239, 116, 239, 126, 65, 9, 5, 1, 119, 2, 158, 9, 5, 1, 119, 2, 116, - 9, 5, 1, 119, 2, 236, 180, 9, 5, 1, 119, 2, 180, 9, 5, 1, 119, 2, 150, 9, - 5, 1, 119, 2, 249, 9, 47, 9, 5, 1, 253, 163, 9, 5, 1, 255, 36, 2, 239, - 117, 9, 5, 1, 144, 2, 158, 9, 5, 1, 144, 2, 116, 9, 5, 1, 144, 2, 236, - 180, 9, 5, 1, 144, 2, 150, 9, 5, 1, 197, 2, 158, 9, 5, 1, 197, 2, 116, 9, - 5, 1, 197, 2, 236, 180, 9, 5, 1, 197, 2, 150, 9, 5, 1, 249, 77, 9, 5, 1, - 255, 28, 2, 180, 9, 5, 1, 109, 2, 158, 9, 5, 1, 109, 2, 116, 9, 5, 1, - 109, 2, 236, 180, 9, 5, 1, 109, 2, 180, 9, 5, 1, 109, 2, 150, 235, 191, - 57, 9, 5, 1, 109, 2, 122, 9, 5, 1, 115, 2, 158, 9, 5, 1, 115, 2, 116, 9, - 5, 1, 115, 2, 236, 180, 9, 5, 1, 115, 2, 150, 9, 5, 1, 255, 35, 2, 116, - 9, 5, 1, 242, 189, 9, 3, 1, 245, 5, 159, 9, 3, 1, 119, 2, 158, 9, 3, 1, - 119, 2, 116, 9, 3, 1, 119, 2, 236, 180, 9, 3, 1, 119, 2, 180, 9, 3, 1, - 119, 2, 150, 9, 3, 1, 119, 2, 249, 9, 47, 9, 3, 1, 253, 163, 9, 3, 1, - 255, 36, 2, 239, 117, 9, 3, 1, 144, 2, 158, 9, 3, 1, 144, 2, 116, 9, 3, - 1, 144, 2, 236, 180, 9, 3, 1, 144, 2, 150, 9, 3, 1, 197, 2, 158, 9, 3, 1, - 197, 2, 116, 9, 3, 1, 197, 2, 236, 180, 9, 3, 1, 197, 2, 150, 9, 3, 1, - 249, 77, 9, 3, 1, 255, 28, 2, 180, 9, 3, 1, 109, 2, 158, 9, 3, 1, 109, 2, - 116, 9, 3, 1, 109, 2, 236, 180, 9, 3, 1, 109, 2, 180, 9, 3, 1, 109, 2, - 150, 239, 156, 57, 9, 3, 1, 109, 2, 122, 9, 3, 1, 115, 2, 158, 9, 3, 1, - 115, 2, 116, 9, 3, 1, 115, 2, 236, 180, 9, 3, 1, 115, 2, 150, 9, 3, 1, - 255, 35, 2, 116, 9, 3, 1, 242, 189, 9, 3, 1, 255, 35, 2, 150, 9, 5, 1, - 119, 2, 166, 9, 3, 1, 119, 2, 166, 9, 5, 1, 119, 2, 212, 9, 3, 1, 119, 2, - 212, 9, 5, 1, 119, 2, 240, 216, 9, 3, 1, 119, 2, 240, 216, 9, 5, 1, 255, - 36, 2, 116, 9, 3, 1, 255, 36, 2, 116, 9, 5, 1, 255, 36, 2, 236, 180, 9, - 3, 1, 255, 36, 2, 236, 180, 9, 5, 1, 255, 36, 2, 49, 47, 9, 3, 1, 255, - 36, 2, 49, 47, 9, 5, 1, 255, 36, 2, 193, 9, 3, 1, 255, 36, 2, 193, 9, 5, - 1, 255, 34, 2, 193, 9, 3, 1, 255, 34, 2, 193, 9, 5, 1, 255, 34, 2, 122, - 9, 3, 1, 255, 34, 2, 122, 9, 5, 1, 144, 2, 166, 9, 3, 1, 144, 2, 166, 9, - 5, 1, 144, 2, 212, 9, 3, 1, 144, 2, 212, 9, 5, 1, 144, 2, 49, 47, 9, 3, - 1, 144, 2, 49, 47, 9, 5, 1, 144, 2, 240, 216, 9, 3, 1, 144, 2, 240, 216, - 9, 5, 1, 144, 2, 193, 9, 3, 1, 144, 2, 193, 9, 5, 1, 255, 32, 2, 236, - 180, 9, 3, 1, 255, 32, 2, 236, 180, 9, 5, 1, 255, 32, 2, 212, 9, 3, 1, - 255, 32, 2, 212, 9, 5, 1, 255, 32, 2, 49, 47, 9, 3, 1, 255, 32, 2, 49, - 47, 9, 5, 1, 255, 32, 2, 239, 117, 9, 3, 1, 255, 32, 2, 239, 117, 9, 5, - 1, 255, 37, 2, 236, 180, 9, 3, 1, 255, 37, 2, 236, 180, 9, 5, 1, 255, 37, - 2, 122, 9, 3, 1, 255, 37, 2, 122, 9, 5, 1, 197, 2, 180, 9, 3, 1, 197, 2, - 180, 9, 5, 1, 197, 2, 166, 9, 3, 1, 197, 2, 166, 9, 5, 1, 197, 2, 212, 9, - 3, 1, 197, 2, 212, 9, 5, 1, 197, 2, 240, 216, 9, 3, 1, 197, 2, 240, 216, - 9, 5, 1, 197, 2, 49, 47, 9, 3, 1, 240, 228, 69, 9, 5, 17, 254, 45, 9, 3, - 17, 254, 45, 9, 5, 1, 255, 45, 2, 236, 180, 9, 3, 1, 255, 45, 2, 236, - 180, 9, 5, 1, 255, 38, 2, 239, 117, 9, 3, 1, 255, 38, 2, 239, 117, 9, 3, - 1, 251, 170, 9, 5, 1, 255, 31, 2, 116, 9, 3, 1, 255, 31, 2, 116, 9, 5, 1, - 255, 31, 2, 239, 117, 9, 3, 1, 255, 31, 2, 239, 117, 9, 5, 1, 255, 31, 2, - 193, 9, 3, 1, 255, 31, 2, 193, 9, 5, 1, 255, 31, 2, 242, 65, 227, 9, 3, - 1, 255, 31, 2, 242, 65, 227, 9, 5, 1, 255, 31, 2, 122, 9, 3, 1, 255, 31, - 2, 122, 9, 5, 1, 255, 28, 2, 116, 9, 3, 1, 255, 28, 2, 116, 9, 5, 1, 255, - 28, 2, 239, 117, 9, 3, 1, 255, 28, 2, 239, 117, 9, 5, 1, 255, 28, 2, 193, - 9, 3, 1, 255, 28, 2, 193, 9, 3, 1, 255, 28, 240, 143, 254, 216, 236, 190, - 9, 5, 1, 249, 66, 9, 3, 1, 249, 66, 9, 5, 1, 109, 2, 166, 9, 3, 1, 109, - 2, 166, 9, 5, 1, 109, 2, 212, 9, 3, 1, 109, 2, 212, 9, 5, 1, 109, 2, 42, - 116, 9, 3, 1, 109, 2, 42, 116, 9, 5, 17, 253, 142, 9, 3, 17, 253, 142, 9, - 5, 1, 255, 30, 2, 116, 9, 3, 1, 255, 30, 2, 116, 9, 5, 1, 255, 30, 2, - 239, 117, 9, 3, 1, 255, 30, 2, 239, 117, 9, 5, 1, 255, 30, 2, 193, 9, 3, - 1, 255, 30, 2, 193, 9, 5, 1, 255, 29, 2, 116, 9, 3, 1, 255, 29, 2, 116, - 9, 5, 1, 255, 29, 2, 236, 180, 9, 3, 1, 255, 29, 2, 236, 180, 9, 5, 1, - 255, 29, 2, 239, 117, 9, 3, 1, 255, 29, 2, 239, 117, 9, 5, 1, 255, 29, 2, - 193, 9, 3, 1, 255, 29, 2, 193, 9, 5, 1, 255, 33, 2, 239, 117, 9, 3, 1, - 255, 33, 2, 239, 117, 9, 5, 1, 255, 33, 2, 193, 9, 3, 1, 255, 33, 2, 193, - 9, 5, 1, 255, 33, 2, 122, 9, 3, 1, 255, 33, 2, 122, 9, 5, 1, 115, 2, 180, - 9, 3, 1, 115, 2, 180, 9, 5, 1, 115, 2, 166, 9, 3, 1, 115, 2, 166, 9, 5, - 1, 115, 2, 212, 9, 3, 1, 115, 2, 212, 9, 5, 1, 115, 2, 249, 9, 47, 9, 3, - 1, 115, 2, 249, 9, 47, 9, 5, 1, 115, 2, 42, 116, 9, 3, 1, 115, 2, 42, - 116, 9, 5, 1, 115, 2, 240, 216, 9, 3, 1, 115, 2, 240, 216, 9, 5, 1, 255, - 40, 2, 236, 180, 9, 3, 1, 255, 40, 2, 236, 180, 9, 5, 1, 255, 35, 2, 236, - 180, 9, 3, 1, 255, 35, 2, 236, 180, 9, 5, 1, 255, 35, 2, 150, 9, 5, 1, - 255, 27, 2, 116, 9, 3, 1, 255, 27, 2, 116, 9, 5, 1, 255, 27, 2, 49, 47, - 9, 3, 1, 255, 27, 2, 49, 47, 9, 5, 1, 255, 27, 2, 193, 9, 3, 1, 255, 27, - 2, 193, 9, 3, 1, 165, 159, 9, 3, 1, 255, 41, 2, 122, 9, 5, 1, 255, 41, 2, - 128, 9, 5, 1, 255, 41, 2, 241, 8, 9, 3, 1, 255, 41, 2, 241, 8, 9, 5, 1, - 249, 5, 169, 9, 3, 1, 249, 5, 169, 9, 5, 1, 249, 0, 78, 9, 5, 1, 255, 36, - 2, 128, 9, 3, 1, 255, 36, 2, 128, 9, 5, 1, 241, 93, 187, 9, 5, 1, 255, - 34, 2, 128, 9, 5, 1, 255, 34, 2, 241, 8, 9, 3, 1, 255, 34, 2, 241, 8, 9, - 3, 1, 242, 60, 242, 87, 9, 5, 1, 224, 70, 9, 5, 1, 242, 164, 9, 5, 1, - 249, 0, 70, 9, 5, 1, 255, 42, 2, 128, 9, 3, 1, 255, 42, 2, 128, 9, 5, 1, - 255, 32, 2, 128, 9, 5, 1, 242, 75, 9, 3, 1, 254, 44, 9, 5, 1, 244, 191, - 9, 5, 1, 197, 2, 122, 9, 5, 1, 255, 38, 2, 128, 9, 3, 1, 255, 38, 2, 128, - 9, 3, 1, 255, 31, 2, 143, 9, 3, 1, 243, 200, 2, 122, 9, 5, 1, 242, 60, - 171, 9, 5, 1, 255, 28, 2, 36, 128, 9, 3, 1, 255, 28, 2, 165, 37, 249, 83, - 9, 5, 1, 109, 2, 242, 65, 180, 9, 5, 1, 109, 2, 244, 210, 9, 3, 1, 109, - 2, 244, 210, 9, 5, 1, 254, 62, 9, 3, 1, 254, 62, 9, 5, 1, 255, 46, 2, - 128, 9, 3, 1, 255, 46, 2, 128, 9, 1, 254, 80, 9, 5, 1, 249, 5, 114, 9, 3, - 1, 249, 5, 114, 9, 5, 1, 249, 67, 9, 1, 224, 254, 38, 245, 28, 9, 3, 1, - 255, 33, 2, 241, 233, 128, 9, 5, 1, 255, 33, 2, 128, 9, 3, 1, 255, 33, 2, - 128, 9, 5, 1, 255, 33, 2, 238, 100, 128, 9, 5, 1, 115, 2, 244, 210, 9, 3, - 1, 115, 2, 244, 210, 9, 5, 1, 239, 127, 9, 5, 1, 255, 44, 2, 128, 9, 5, - 1, 255, 35, 2, 128, 9, 3, 1, 255, 35, 2, 128, 9, 5, 1, 255, 27, 2, 122, - 9, 3, 1, 255, 27, 2, 122, 9, 5, 1, 249, 221, 9, 5, 1, 253, 206, 238, 156, - 9, 3, 1, 253, 206, 238, 156, 9, 3, 1, 253, 206, 2, 244, 182, 9, 1, 225, - 2, 122, 9, 5, 1, 249, 5, 168, 9, 3, 1, 249, 5, 168, 9, 1, 239, 116, 240, - 211, 249, 71, 2, 122, 9, 1, 245, 224, 9, 1, 243, 91, 242, 140, 9, 1, 241, - 197, 242, 140, 9, 1, 239, 249, 242, 140, 9, 1, 238, 100, 242, 140, 9, 5, - 1, 254, 231, 2, 193, 9, 5, 1, 255, 34, 2, 3, 1, 255, 27, 2, 193, 9, 3, 1, - 254, 231, 2, 193, 9, 5, 1, 254, 53, 9, 5, 1, 255, 31, 2, 3, 1, 200, 9, 3, - 1, 254, 53, 9, 5, 1, 254, 57, 9, 5, 1, 255, 28, 2, 3, 1, 200, 9, 3, 1, - 254, 57, 9, 5, 1, 119, 2, 193, 9, 3, 1, 119, 2, 193, 9, 5, 1, 197, 2, - 193, 9, 3, 1, 197, 2, 193, 9, 5, 1, 109, 2, 193, 9, 3, 1, 109, 2, 193, 9, - 5, 1, 115, 2, 193, 9, 3, 1, 115, 2, 193, 9, 5, 1, 115, 2, 238, 81, 18, - 166, 9, 3, 1, 115, 2, 238, 81, 18, 166, 9, 5, 1, 115, 2, 238, 81, 18, - 116, 9, 3, 1, 115, 2, 238, 81, 18, 116, 9, 5, 1, 115, 2, 238, 81, 18, - 193, 9, 3, 1, 115, 2, 238, 81, 18, 193, 9, 5, 1, 115, 2, 238, 81, 18, - 158, 9, 3, 1, 115, 2, 238, 81, 18, 158, 9, 3, 1, 242, 60, 70, 9, 5, 1, - 119, 2, 238, 81, 18, 166, 9, 3, 1, 119, 2, 238, 81, 18, 166, 9, 5, 1, - 119, 2, 49, 53, 18, 166, 9, 3, 1, 119, 2, 49, 53, 18, 166, 9, 5, 1, 254, - 221, 2, 166, 9, 3, 1, 254, 221, 2, 166, 9, 5, 1, 255, 32, 2, 122, 9, 3, - 1, 255, 32, 2, 122, 9, 5, 1, 255, 32, 2, 193, 9, 3, 1, 255, 32, 2, 193, - 9, 5, 1, 255, 38, 2, 193, 9, 3, 1, 255, 38, 2, 193, 9, 5, 1, 109, 2, 240, - 216, 9, 3, 1, 109, 2, 240, 216, 9, 5, 1, 109, 2, 242, 234, 18, 166, 9, 3, - 1, 109, 2, 242, 234, 18, 166, 9, 5, 1, 253, 206, 2, 193, 9, 3, 1, 253, - 206, 2, 193, 9, 3, 1, 255, 45, 2, 193, 9, 5, 1, 254, 35, 9, 5, 1, 255, - 34, 2, 3, 1, 202, 9, 3, 1, 254, 35, 9, 5, 1, 255, 32, 2, 116, 9, 3, 1, - 255, 32, 2, 116, 9, 5, 1, 242, 225, 9, 5, 1, 245, 224, 9, 5, 1, 255, 28, - 2, 158, 9, 3, 1, 255, 28, 2, 158, 9, 5, 1, 119, 2, 249, 9, 53, 18, 116, - 9, 3, 1, 119, 2, 249, 9, 53, 18, 116, 9, 5, 1, 254, 221, 2, 116, 9, 3, 1, - 254, 221, 2, 116, 9, 5, 1, 109, 2, 242, 114, 18, 116, 9, 3, 1, 109, 2, - 242, 114, 18, 116, 9, 5, 1, 119, 2, 42, 158, 9, 3, 1, 119, 2, 42, 158, 9, - 5, 1, 119, 2, 239, 116, 212, 9, 3, 1, 119, 2, 239, 116, 212, 9, 5, 1, - 144, 2, 42, 158, 9, 3, 1, 144, 2, 42, 158, 9, 5, 1, 144, 2, 239, 116, - 212, 9, 3, 1, 144, 2, 239, 116, 212, 9, 5, 1, 197, 2, 42, 158, 9, 3, 1, - 197, 2, 42, 158, 9, 5, 1, 197, 2, 239, 116, 212, 9, 3, 1, 197, 2, 239, - 116, 212, 9, 5, 1, 109, 2, 42, 158, 9, 3, 1, 109, 2, 42, 158, 9, 5, 1, - 109, 2, 239, 116, 212, 9, 3, 1, 109, 2, 239, 116, 212, 9, 5, 1, 255, 30, - 2, 42, 158, 9, 3, 1, 255, 30, 2, 42, 158, 9, 5, 1, 255, 30, 2, 239, 116, - 212, 9, 3, 1, 255, 30, 2, 239, 116, 212, 9, 5, 1, 115, 2, 42, 158, 9, 3, - 1, 115, 2, 42, 158, 9, 5, 1, 115, 2, 239, 116, 212, 9, 3, 1, 115, 2, 239, - 116, 212, 9, 5, 1, 255, 29, 2, 244, 192, 45, 9, 3, 1, 255, 29, 2, 244, - 192, 45, 9, 5, 1, 255, 33, 2, 244, 192, 45, 9, 3, 1, 255, 33, 2, 244, - 192, 45, 9, 5, 1, 245, 227, 9, 3, 1, 245, 227, 9, 5, 1, 255, 37, 2, 193, - 9, 3, 1, 255, 37, 2, 193, 9, 5, 1, 255, 28, 2, 165, 37, 249, 83, 9, 5, 1, - 253, 247, 9, 3, 1, 253, 247, 9, 5, 1, 255, 27, 2, 128, 9, 3, 1, 255, 27, - 2, 128, 9, 5, 1, 119, 2, 49, 47, 9, 3, 1, 119, 2, 49, 47, 9, 5, 1, 144, - 2, 239, 117, 9, 3, 1, 144, 2, 239, 117, 9, 5, 1, 109, 2, 238, 81, 18, - 166, 9, 3, 1, 109, 2, 238, 81, 18, 166, 9, 5, 1, 109, 2, 229, 18, 166, 9, - 3, 1, 109, 2, 229, 18, 166, 9, 5, 1, 109, 2, 49, 47, 9, 3, 1, 109, 2, 49, - 47, 9, 5, 1, 109, 2, 49, 53, 18, 166, 9, 3, 1, 109, 2, 49, 53, 18, 166, - 9, 5, 1, 255, 35, 2, 166, 9, 3, 1, 255, 35, 2, 166, 9, 3, 1, 242, 60, 64, - 9, 3, 1, 242, 79, 9, 3, 1, 242, 60, 242, 79, 9, 3, 1, 255, 41, 2, 128, 9, - 3, 1, 249, 0, 78, 9, 3, 1, 255, 36, 2, 244, 226, 9, 3, 1, 255, 34, 2, - 244, 182, 9, 3, 1, 255, 34, 2, 128, 9, 3, 1, 224, 70, 9, 3, 1, 242, 164, - 9, 3, 1, 245, 41, 2, 128, 9, 3, 1, 249, 0, 70, 9, 3, 1, 224, 249, 0, 70, - 9, 3, 1, 224, 249, 0, 144, 2, 128, 9, 3, 1, 242, 77, 224, 249, 0, 70, 9, - 3, 1, 240, 228, 255, 45, 2, 122, 9, 3, 1, 255, 32, 2, 128, 9, 3, 1, 71, - 194, 9, 1, 3, 5, 194, 9, 3, 1, 242, 75, 9, 3, 1, 252, 117, 244, 210, 9, - 3, 1, 242, 60, 164, 9, 3, 1, 255, 37, 2, 128, 9, 3, 1, 251, 64, 2, 128, - 9, 3, 1, 197, 2, 122, 9, 3, 1, 244, 191, 9, 1, 3, 5, 69, 9, 3, 1, 255, - 31, 2, 242, 65, 180, 9, 3, 1, 255, 31, 2, 246, 21, 9, 3, 1, 255, 31, 2, - 238, 100, 128, 9, 3, 1, 247, 59, 9, 3, 1, 242, 60, 171, 9, 3, 1, 242, 60, - 255, 39, 2, 165, 249, 83, 9, 3, 1, 255, 39, 2, 128, 9, 3, 1, 255, 28, 2, - 36, 128, 9, 3, 1, 255, 28, 2, 238, 100, 128, 9, 1, 3, 5, 183, 9, 3, 1, - 242, 138, 78, 9, 1, 3, 5, 253, 142, 9, 3, 1, 242, 77, 242, 72, 9, 3, 1, - 249, 30, 9, 3, 1, 242, 60, 135, 9, 3, 1, 242, 60, 255, 30, 2, 165, 249, - 83, 9, 3, 1, 242, 60, 255, 30, 2, 128, 9, 3, 1, 255, 30, 2, 165, 249, 83, - 9, 3, 1, 255, 30, 2, 244, 182, 9, 3, 1, 255, 30, 2, 238, 139, 9, 3, 1, - 224, 255, 30, 2, 238, 139, 9, 1, 3, 5, 135, 9, 1, 3, 5, 239, 116, 135, 9, - 3, 1, 255, 29, 2, 128, 9, 3, 1, 249, 67, 9, 3, 1, 240, 228, 255, 45, 2, - 242, 114, 18, 128, 9, 3, 1, 245, 196, 224, 249, 67, 9, 3, 1, 254, 38, 2, - 244, 226, 9, 3, 1, 242, 60, 190, 9, 3, 1, 255, 33, 2, 238, 100, 128, 9, - 3, 1, 115, 143, 9, 3, 1, 239, 127, 9, 3, 1, 255, 44, 2, 128, 9, 3, 1, - 242, 60, 186, 9, 3, 1, 242, 60, 201, 9, 3, 1, 242, 60, 181, 9, 1, 3, 5, - 181, 9, 3, 1, 255, 27, 2, 238, 100, 128, 9, 3, 1, 255, 27, 2, 244, 226, - 9, 3, 1, 249, 221, 9, 3, 1, 253, 206, 2, 244, 226, 9, 1, 240, 211, 189, - 9, 1, 237, 117, 242, 116, 238, 9, 9, 1, 239, 116, 240, 211, 189, 9, 1, - 239, 87, 203, 9, 1, 239, 205, 242, 140, 9, 1, 3, 5, 199, 9, 3, 1, 242, - 77, 249, 0, 70, 9, 1, 3, 5, 255, 32, 2, 128, 9, 1, 3, 5, 164, 9, 3, 1, - 255, 45, 2, 236, 7, 9, 3, 1, 242, 60, 205, 9, 1, 3, 5, 148, 9, 3, 1, 255, - 47, 2, 128, 9, 1, 240, 211, 249, 71, 2, 122, 9, 1, 224, 240, 211, 249, - 71, 2, 122, 9, 3, 1, 254, 231, 239, 152, 9, 3, 1, 250, 216, 239, 152, 9, - 3, 1, 254, 231, 240, 253, 2, 244, 226, 9, 3, 1, 255, 24, 239, 152, 9, 3, - 1, 252, 201, 239, 152, 9, 3, 1, 255, 23, 240, 253, 2, 244, 226, 9, 3, 1, - 251, 2, 239, 152, 9, 3, 1, 255, 11, 239, 152, 9, 3, 1, 255, 12, 239, 152, - 9, 1, 239, 205, 236, 224, 9, 1, 240, 8, 236, 224, 147, 1, 3, 164, 147, 1, - 3, 255, 37, 2, 128, 147, 1, 3, 200, 147, 1, 3, 135, 147, 1, 3, 242, 60, - 135, 147, 1, 3, 242, 60, 255, 30, 2, 128, 147, 1, 3, 5, 239, 116, 135, - 147, 1, 3, 201, 147, 1, 3, 181, 147, 1, 242, 107, 147, 1, 42, 242, 107, - 147, 1, 242, 60, 242, 84, 147, 1, 236, 190, 147, 1, 224, 242, 84, 147, 1, - 37, 136, 244, 183, 147, 1, 36, 136, 244, 183, 147, 1, 240, 211, 189, 147, - 1, 224, 240, 211, 189, 147, 1, 36, 237, 116, 147, 1, 37, 237, 116, 147, - 1, 75, 237, 116, 147, 1, 79, 237, 116, 147, 1, 157, 240, 203, 193, 147, - 1, 55, 244, 176, 147, 1, 166, 147, 1, 244, 196, 240, 203, 147, 1, 244, - 201, 240, 203, 147, 1, 253, 113, 55, 244, 176, 147, 1, 253, 113, 166, - 147, 1, 253, 113, 244, 201, 240, 203, 147, 1, 253, 113, 244, 196, 240, - 203, 147, 1, 237, 144, 242, 81, 147, 1, 136, 237, 144, 242, 81, 147, 1, - 241, 13, 37, 136, 244, 183, 147, 1, 241, 13, 36, 136, 244, 183, 147, 1, - 75, 244, 184, 147, 1, 79, 244, 184, 147, 1, 249, 4, 57, 147, 1, 244, 197, - 57, 212, 49, 47, 249, 9, 47, 240, 216, 3, 180, 42, 244, 196, 240, 203, - 147, 1, 244, 59, 128, 147, 1, 244, 234, 240, 203, 147, 1, 3, 242, 75, - 147, 1, 3, 148, 147, 1, 3, 159, 147, 1, 3, 170, 147, 1, 3, 224, 240, 211, - 189, 147, 1, 238, 7, 249, 5, 143, 147, 1, 249, 10, 249, 5, 143, 147, 1, - 254, 145, 249, 5, 143, 147, 1, 253, 113, 249, 5, 143, 147, 1, 239, 11, - 249, 5, 143, 147, 1, 254, 79, 238, 119, 249, 5, 65, 147, 1, 250, 112, - 238, 119, 249, 5, 65, 147, 1, 240, 195, 147, 1, 236, 179, 147, 1, 42, - 236, 190, 48, 244, 201, 240, 203, 48, 244, 196, 240, 203, 48, 157, 240, - 203, 48, 180, 48, 166, 48, 238, 98, 48, 212, 48, 49, 47, 48, 150, 48, - 248, 255, 47, 48, 249, 9, 47, 48, 42, 244, 196, 240, 203, 48, 193, 48, - 55, 217, 47, 48, 42, 55, 217, 47, 48, 42, 244, 201, 240, 203, 48, 236, - 49, 48, 239, 116, 212, 48, 242, 60, 244, 192, 47, 48, 244, 192, 47, 48, - 224, 244, 192, 47, 48, 244, 192, 53, 184, 48, 244, 201, 230, 45, 48, 244, - 196, 230, 45, 48, 36, 249, 35, 45, 48, 37, 249, 35, 45, 48, 36, 160, 47, - 48, 244, 210, 48, 36, 136, 249, 9, 45, 48, 75, 249, 35, 45, 48, 79, 249, - 35, 45, 48, 249, 4, 25, 45, 48, 244, 197, 25, 45, 48, 237, 80, 248, 255, - 45, 48, 238, 100, 248, 255, 45, 48, 49, 45, 48, 238, 81, 45, 48, 249, 9, - 45, 48, 244, 192, 45, 48, 239, 117, 48, 240, 216, 48, 55, 217, 45, 48, - 242, 153, 45, 48, 239, 116, 42, 250, 138, 45, 48, 245, 15, 45, 48, 157, - 230, 45, 48, 244, 194, 45, 48, 239, 116, 244, 194, 45, 48, 229, 45, 48, - 242, 101, 45, 48, 253, 113, 244, 176, 48, 42, 253, 113, 244, 176, 48, - 229, 239, 131, 48, 207, 242, 114, 239, 131, 48, 165, 242, 114, 239, 131, - 48, 207, 240, 230, 239, 131, 48, 165, 240, 230, 239, 131, 48, 37, 136, - 249, 9, 45, 48, 239, 116, 242, 153, 45, 48, 30, 45, 48, 242, 2, 45, 48, - 255, 43, 47, 48, 55, 180, 48, 42, 238, 98, 48, 244, 201, 249, 5, 65, 48, - 244, 196, 249, 5, 65, 48, 26, 236, 43, 48, 26, 239, 186, 48, 26, 238, 85, - 242, 70, 48, 26, 211, 48, 242, 153, 47, 48, 242, 61, 25, 45, 48, 42, 55, - 217, 45, 48, 36, 160, 45, 48, 141, 229, 47, 48, 238, 14, 47, 48, 242, 93, - 80, 139, 47, 48, 36, 37, 59, 45, 48, 210, 59, 45, 48, 240, 82, 241, 22, - 48, 42, 180, 48, 42, 239, 116, 212, 48, 42, 63, 59, 45, 48, 9, 3, 1, 64, - 48, 9, 3, 1, 70, 48, 9, 3, 1, 69, 48, 9, 3, 1, 78, 48, 9, 3, 1, 84, 48, - 9, 3, 1, 203, 48, 9, 3, 1, 187, 48, 9, 3, 1, 164, 48, 9, 3, 1, 171, 48, - 9, 3, 1, 135, 48, 9, 3, 1, 190, 48, 9, 3, 1, 186, 48, 9, 3, 1, 170, 26, - 151, 57, 26, 149, 151, 57, 26, 211, 26, 239, 126, 65, 26, 242, 70, 26, - 238, 85, 242, 70, 26, 5, 1, 162, 2, 242, 70, 26, 254, 82, 241, 83, 26, 5, - 1, 240, 204, 2, 242, 70, 26, 5, 1, 182, 2, 242, 70, 26, 5, 1, 228, 2, - 242, 70, 26, 5, 1, 240, 210, 2, 242, 70, 26, 5, 1, 240, 199, 2, 242, 70, - 26, 5, 1, 172, 2, 242, 70, 26, 3, 1, 228, 2, 238, 85, 18, 242, 70, 26, 5, - 1, 242, 79, 26, 5, 1, 244, 198, 26, 5, 1, 242, 75, 26, 5, 1, 242, 87, 26, - 5, 1, 239, 133, 26, 5, 1, 244, 204, 26, 5, 1, 249, 42, 26, 5, 1, 242, 97, - 26, 5, 1, 244, 191, 26, 5, 1, 242, 95, 26, 5, 1, 242, 96, 26, 5, 1, 253, - 114, 26, 5, 1, 253, 112, 26, 5, 1, 253, 135, 26, 5, 1, 239, 137, 26, 5, - 1, 253, 116, 26, 5, 1, 249, 32, 26, 5, 1, 242, 73, 26, 5, 1, 249, 43, 26, - 5, 1, 239, 127, 26, 5, 1, 249, 30, 26, 5, 1, 249, 23, 26, 5, 1, 249, 31, - 26, 5, 1, 242, 72, 26, 5, 1, 228, 2, 237, 133, 26, 5, 1, 240, 199, 2, - 237, 133, 26, 3, 1, 162, 2, 242, 70, 26, 3, 1, 240, 204, 2, 242, 70, 26, - 3, 1, 182, 2, 242, 70, 26, 3, 1, 228, 2, 242, 70, 26, 3, 1, 240, 199, 2, - 238, 85, 18, 242, 70, 26, 3, 1, 242, 79, 26, 3, 1, 244, 198, 26, 3, 1, - 242, 75, 26, 3, 1, 242, 87, 26, 3, 1, 239, 133, 26, 3, 1, 244, 204, 26, - 3, 1, 249, 42, 26, 3, 1, 242, 97, 26, 3, 1, 244, 191, 26, 3, 1, 242, 95, - 26, 3, 1, 242, 96, 26, 3, 1, 253, 114, 26, 3, 1, 253, 112, 26, 3, 1, 253, - 135, 26, 3, 1, 239, 137, 26, 3, 1, 253, 116, 26, 3, 1, 249, 32, 26, 3, 1, - 29, 242, 73, 26, 3, 1, 242, 73, 26, 3, 1, 249, 43, 26, 3, 1, 239, 127, - 26, 3, 1, 249, 30, 26, 3, 1, 249, 23, 26, 3, 1, 249, 31, 26, 3, 1, 242, - 72, 26, 3, 1, 228, 2, 237, 133, 26, 3, 1, 240, 199, 2, 237, 133, 26, 3, - 1, 240, 210, 2, 242, 70, 26, 3, 1, 240, 199, 2, 242, 70, 26, 3, 1, 172, - 2, 242, 70, 26, 250, 155, 90, 26, 244, 203, 90, 26, 240, 199, 2, 248, - 255, 90, 26, 240, 199, 2, 244, 196, 18, 248, 255, 90, 26, 240, 199, 2, - 238, 81, 18, 248, 255, 90, 26, 253, 212, 90, 26, 254, 224, 90, 26, 254, - 15, 90, 26, 1, 241, 39, 242, 128, 26, 3, 1, 241, 39, 242, 128, 26, 1, - 241, 32, 26, 3, 1, 241, 32, 26, 1, 239, 213, 26, 3, 1, 239, 213, 26, 1, - 242, 128, 26, 3, 1, 242, 128, 26, 1, 242, 243, 26, 3, 1, 242, 243, 242, - 85, 5, 1, 245, 183, 242, 85, 3, 1, 245, 183, 242, 85, 5, 1, 249, 223, - 242, 85, 3, 1, 249, 223, 242, 85, 5, 1, 245, 123, 242, 85, 3, 1, 245, - 123, 242, 85, 5, 1, 245, 109, 242, 85, 3, 1, 245, 109, 242, 85, 5, 1, - 241, 56, 242, 85, 3, 1, 241, 56, 242, 85, 5, 1, 242, 252, 242, 85, 3, 1, - 242, 252, 242, 85, 5, 1, 249, 213, 242, 85, 3, 1, 249, 213, 26, 244, 228, - 90, 26, 253, 168, 90, 26, 242, 180, 248, 76, 90, 26, 1, 250, 118, 26, 5, - 244, 203, 90, 26, 242, 180, 240, 204, 90, 26, 224, 242, 180, 240, 204, - 90, 31, 5, 1, 254, 233, 2, 158, 31, 5, 1, 254, 46, 31, 5, 1, 249, 97, 31, - 5, 1, 249, 237, 31, 5, 1, 238, 164, 253, 181, 31, 5, 1, 249, 76, 31, 5, - 1, 231, 233, 69, 31, 5, 1, 253, 139, 31, 5, 1, 253, 239, 31, 5, 1, 249, - 106, 31, 5, 1, 249, 111, 31, 5, 1, 245, 212, 31, 5, 1, 250, 2, 31, 5, 1, - 197, 2, 158, 31, 5, 1, 207, 84, 31, 5, 1, 245, 79, 31, 5, 1, 64, 31, 5, - 1, 253, 191, 31, 5, 1, 253, 214, 31, 5, 1, 249, 78, 31, 5, 1, 253, 152, - 31, 5, 1, 253, 181, 31, 5, 1, 249, 74, 31, 5, 1, 253, 189, 31, 5, 1, 69, - 31, 5, 1, 207, 69, 31, 5, 1, 208, 31, 5, 1, 253, 223, 31, 5, 1, 253, 224, - 31, 5, 1, 253, 166, 31, 5, 1, 78, 31, 5, 1, 253, 143, 31, 5, 1, 253, 205, - 31, 5, 1, 253, 225, 31, 5, 1, 253, 151, 31, 5, 1, 84, 31, 5, 1, 253, 222, - 31, 5, 1, 253, 88, 31, 5, 1, 249, 64, 31, 5, 1, 249, 44, 31, 5, 1, 249, - 7, 31, 5, 1, 242, 249, 31, 5, 1, 249, 241, 57, 31, 5, 1, 245, 225, 31, 5, - 1, 249, 119, 57, 31, 5, 1, 70, 31, 5, 1, 253, 124, 31, 5, 1, 216, 31, 3, - 1, 64, 31, 3, 1, 253, 191, 31, 3, 1, 253, 214, 31, 3, 1, 249, 78, 31, 3, - 1, 253, 152, 31, 3, 1, 253, 181, 31, 3, 1, 249, 74, 31, 3, 1, 253, 189, - 31, 3, 1, 69, 31, 3, 1, 207, 69, 31, 3, 1, 208, 31, 3, 1, 253, 223, 31, - 3, 1, 253, 224, 31, 3, 1, 253, 166, 31, 3, 1, 78, 31, 3, 1, 253, 143, 31, - 3, 1, 253, 205, 31, 3, 1, 253, 225, 31, 3, 1, 253, 151, 31, 3, 1, 84, 31, - 3, 1, 253, 222, 31, 3, 1, 253, 88, 31, 3, 1, 249, 64, 31, 3, 1, 249, 44, - 31, 3, 1, 249, 7, 31, 3, 1, 242, 249, 31, 3, 1, 249, 241, 57, 31, 3, 1, - 245, 225, 31, 3, 1, 249, 119, 57, 31, 3, 1, 70, 31, 3, 1, 253, 124, 31, - 3, 1, 216, 31, 3, 1, 254, 233, 2, 158, 31, 3, 1, 254, 46, 31, 3, 1, 249, - 97, 31, 3, 1, 249, 237, 31, 3, 1, 238, 164, 253, 181, 31, 3, 1, 249, 76, - 31, 3, 1, 231, 233, 69, 31, 3, 1, 253, 139, 31, 3, 1, 253, 239, 31, 3, 1, - 249, 106, 31, 3, 1, 249, 111, 31, 3, 1, 245, 212, 31, 3, 1, 250, 2, 31, - 3, 1, 197, 2, 158, 31, 3, 1, 207, 84, 31, 3, 1, 245, 79, 31, 5, 1, 242, - 72, 31, 3, 1, 242, 72, 31, 5, 1, 250, 113, 31, 3, 1, 250, 113, 31, 5, 1, - 239, 157, 70, 31, 3, 1, 239, 157, 70, 31, 5, 1, 242, 147, 249, 58, 31, 3, - 1, 242, 147, 249, 58, 31, 5, 1, 239, 157, 242, 147, 249, 58, 31, 3, 1, - 239, 157, 242, 147, 249, 58, 31, 5, 1, 253, 202, 249, 58, 31, 3, 1, 253, - 202, 249, 58, 31, 5, 1, 239, 157, 253, 202, 249, 58, 31, 3, 1, 239, 157, - 253, 202, 249, 58, 31, 5, 1, 250, 4, 31, 3, 1, 250, 4, 31, 5, 1, 249, 31, - 31, 3, 1, 249, 31, 31, 5, 1, 245, 86, 31, 3, 1, 245, 86, 31, 5, 1, 239, - 219, 31, 3, 1, 239, 219, 31, 5, 1, 241, 60, 2, 42, 244, 201, 240, 203, - 31, 3, 1, 241, 60, 2, 42, 244, 201, 240, 203, 31, 5, 1, 254, 74, 31, 3, - 1, 254, 74, 31, 5, 1, 245, 174, 242, 72, 31, 3, 1, 245, 174, 242, 72, 31, - 5, 1, 172, 2, 242, 190, 31, 3, 1, 172, 2, 242, 190, 31, 5, 1, 254, 17, - 31, 3, 1, 254, 17, 31, 5, 1, 242, 128, 31, 3, 1, 242, 128, 31, 238, 133, - 57, 48, 31, 242, 190, 48, 31, 235, 182, 48, 31, 130, 238, 152, 48, 31, - 138, 238, 152, 48, 31, 241, 21, 238, 133, 57, 48, 31, 240, 117, 57, 31, - 5, 1, 207, 197, 2, 244, 182, 31, 3, 1, 207, 197, 2, 244, 182, 31, 5, 1, - 239, 233, 57, 31, 3, 1, 239, 233, 57, 31, 5, 1, 254, 245, 2, 244, 232, - 31, 3, 1, 254, 245, 2, 244, 232, 31, 5, 1, 253, 208, 2, 241, 89, 31, 3, - 1, 253, 208, 2, 241, 89, 31, 5, 1, 253, 208, 2, 122, 31, 3, 1, 253, 208, - 2, 122, 31, 5, 1, 253, 208, 2, 242, 65, 128, 31, 3, 1, 253, 208, 2, 242, - 65, 128, 31, 5, 1, 253, 217, 2, 237, 112, 31, 3, 1, 253, 217, 2, 237, - 112, 31, 5, 1, 254, 238, 2, 237, 112, 31, 3, 1, 254, 238, 2, 237, 112, - 31, 5, 1, 254, 218, 2, 237, 112, 31, 3, 1, 254, 218, 2, 237, 112, 31, 5, - 1, 254, 218, 2, 55, 122, 31, 3, 1, 254, 218, 2, 55, 122, 31, 5, 1, 254, - 218, 2, 122, 31, 3, 1, 254, 218, 2, 122, 31, 5, 1, 241, 42, 208, 31, 3, - 1, 241, 42, 208, 31, 5, 1, 254, 215, 2, 237, 112, 31, 3, 1, 254, 215, 2, - 237, 112, 31, 5, 17, 254, 215, 249, 78, 31, 3, 17, 254, 215, 249, 78, 31, - 5, 1, 254, 229, 2, 242, 65, 128, 31, 3, 1, 254, 229, 2, 242, 65, 128, 31, - 5, 1, 238, 91, 253, 88, 31, 3, 1, 238, 91, 253, 88, 31, 5, 1, 254, 246, - 2, 237, 112, 31, 3, 1, 254, 246, 2, 237, 112, 31, 5, 1, 254, 237, 2, 237, - 112, 31, 3, 1, 254, 237, 2, 237, 112, 31, 5, 1, 239, 175, 84, 31, 3, 1, - 239, 175, 84, 31, 5, 1, 239, 175, 115, 2, 122, 31, 3, 1, 239, 175, 115, - 2, 122, 31, 5, 1, 254, 248, 2, 237, 112, 31, 3, 1, 254, 248, 2, 237, 112, - 31, 5, 17, 254, 237, 249, 64, 31, 3, 17, 254, 237, 249, 64, 31, 5, 1, - 253, 164, 2, 237, 112, 31, 3, 1, 253, 164, 2, 237, 112, 31, 5, 1, 253, - 164, 2, 55, 122, 31, 3, 1, 253, 164, 2, 55, 122, 31, 5, 1, 245, 184, 31, - 3, 1, 245, 184, 31, 5, 1, 238, 91, 249, 44, 31, 3, 1, 238, 91, 249, 44, - 31, 5, 1, 238, 91, 253, 164, 2, 237, 112, 31, 3, 1, 238, 91, 253, 164, 2, - 237, 112, 31, 1, 239, 57, 31, 5, 1, 253, 217, 2, 212, 31, 3, 1, 253, 217, - 2, 212, 31, 5, 1, 254, 218, 2, 128, 31, 3, 1, 254, 218, 2, 128, 31, 5, 1, - 254, 241, 2, 244, 182, 31, 3, 1, 254, 241, 2, 244, 182, 31, 5, 1, 254, - 215, 2, 128, 31, 3, 1, 254, 215, 2, 128, 31, 5, 1, 254, 215, 2, 244, 182, - 31, 3, 1, 254, 215, 2, 244, 182, 31, 5, 1, 237, 160, 249, 44, 31, 3, 1, - 237, 160, 249, 44, 31, 5, 1, 254, 220, 2, 244, 182, 31, 3, 1, 254, 220, - 2, 244, 182, 31, 5, 1, 119, 2, 212, 31, 3, 1, 119, 2, 212, 31, 5, 1, 119, - 2, 150, 31, 3, 1, 119, 2, 150, 31, 5, 17, 119, 253, 181, 31, 3, 17, 119, - 253, 181, 31, 5, 1, 254, 233, 2, 212, 31, 3, 1, 254, 233, 2, 212, 31, 5, - 1, 242, 164, 31, 3, 1, 242, 164, 31, 5, 1, 245, 41, 2, 150, 31, 3, 1, - 245, 41, 2, 150, 31, 5, 1, 253, 217, 2, 150, 31, 3, 1, 253, 217, 2, 150, - 31, 5, 1, 254, 238, 2, 150, 31, 3, 1, 254, 238, 2, 150, 31, 5, 1, 238, - 91, 249, 76, 31, 3, 1, 238, 91, 249, 76, 31, 5, 1, 197, 2, 166, 31, 3, 1, - 197, 2, 166, 31, 5, 1, 197, 2, 150, 31, 3, 1, 197, 2, 150, 31, 5, 1, 109, - 2, 150, 31, 3, 1, 109, 2, 150, 31, 5, 1, 242, 138, 78, 31, 3, 1, 242, - 138, 78, 31, 5, 1, 242, 138, 109, 2, 150, 31, 3, 1, 242, 138, 109, 2, - 150, 31, 5, 1, 144, 2, 150, 31, 3, 1, 144, 2, 150, 31, 5, 1, 115, 2, 166, - 31, 3, 1, 115, 2, 166, 31, 5, 1, 115, 2, 150, 31, 3, 1, 115, 2, 150, 31, - 5, 1, 115, 2, 42, 116, 31, 3, 1, 115, 2, 42, 116, 31, 5, 1, 253, 164, 2, - 150, 31, 3, 1, 253, 164, 2, 150, 31, 5, 1, 250, 114, 2, 150, 31, 3, 1, - 250, 114, 2, 150, 31, 5, 1, 249, 21, 253, 152, 31, 3, 1, 249, 21, 253, - 152, 31, 5, 1, 249, 21, 249, 97, 31, 3, 1, 249, 21, 249, 97, 31, 5, 1, - 249, 21, 250, 128, 31, 3, 1, 249, 21, 250, 128, 31, 5, 1, 249, 21, 245, - 80, 31, 3, 1, 249, 21, 245, 80, 31, 5, 1, 249, 21, 249, 106, 31, 3, 1, - 249, 21, 249, 106, 31, 5, 1, 249, 21, 249, 111, 31, 3, 1, 249, 21, 249, - 111, 31, 5, 1, 249, 21, 250, 73, 31, 3, 1, 249, 21, 250, 73, 31, 5, 1, - 249, 21, 250, 88, 31, 3, 1, 249, 21, 250, 88, 87, 5, 1, 249, 187, 87, 5, - 1, 249, 191, 87, 5, 1, 249, 236, 87, 5, 1, 253, 93, 87, 5, 1, 249, 133, - 87, 5, 1, 253, 129, 87, 5, 1, 254, 9, 87, 5, 1, 254, 11, 87, 5, 1, 76, - 87, 5, 1, 249, 74, 87, 5, 1, 249, 138, 87, 5, 1, 245, 132, 87, 5, 1, 249, - 179, 87, 5, 1, 253, 115, 87, 5, 1, 249, 254, 87, 5, 1, 253, 140, 87, 5, - 1, 253, 118, 87, 5, 1, 245, 95, 87, 5, 1, 245, 68, 87, 5, 1, 249, 148, - 87, 5, 1, 253, 139, 87, 5, 1, 249, 112, 87, 5, 1, 249, 7, 87, 5, 1, 253, - 215, 87, 5, 1, 249, 11, 87, 5, 1, 249, 155, 87, 5, 1, 245, 117, 87, 5, 1, - 253, 92, 87, 5, 1, 250, 68, 87, 5, 1, 250, 105, 87, 5, 1, 245, 204, 87, - 5, 1, 249, 159, 87, 5, 1, 253, 178, 87, 5, 1, 245, 51, 87, 5, 1, 245, - 161, 87, 5, 1, 249, 140, 87, 5, 1, 254, 60, 87, 5, 1, 249, 101, 87, 147, - 1, 36, 136, 244, 183, 87, 236, 190, 87, 239, 215, 65, 87, 236, 186, 65, - 87, 242, 84, 87, 239, 126, 65, 87, 236, 60, 65, 87, 3, 1, 249, 187, 87, - 3, 1, 249, 191, 87, 3, 1, 249, 236, 87, 3, 1, 253, 93, 87, 3, 1, 249, - 133, 87, 3, 1, 253, 129, 87, 3, 1, 254, 9, 87, 3, 1, 254, 11, 87, 3, 1, - 76, 87, 3, 1, 249, 74, 87, 3, 1, 249, 138, 87, 3, 1, 245, 132, 87, 3, 1, - 249, 179, 87, 3, 1, 253, 115, 87, 3, 1, 249, 254, 87, 3, 1, 253, 140, 87, - 3, 1, 253, 118, 87, 3, 1, 245, 95, 87, 3, 1, 245, 68, 87, 3, 1, 249, 148, - 87, 3, 1, 253, 139, 87, 3, 1, 249, 112, 87, 3, 1, 249, 7, 87, 3, 1, 253, - 215, 87, 3, 1, 249, 11, 87, 3, 1, 249, 155, 87, 3, 1, 245, 117, 87, 3, 1, - 253, 92, 87, 3, 1, 250, 68, 87, 3, 1, 250, 105, 87, 3, 1, 245, 204, 87, - 3, 1, 249, 159, 87, 3, 1, 253, 178, 87, 3, 1, 245, 51, 87, 3, 1, 245, - 161, 87, 3, 1, 249, 140, 87, 3, 1, 254, 60, 87, 3, 1, 249, 101, 87, 3, - 17, 254, 100, 245, 51, 87, 213, 189, 87, 240, 241, 61, 230, 240, 70, 61, - 230, 242, 186, 61, 230, 237, 95, 61, 230, 245, 232, 244, 47, 61, 230, - 245, 232, 243, 121, 61, 230, 242, 37, 61, 230, 244, 57, 61, 230, 244, - 158, 61, 230, 241, 235, 61, 230, 244, 156, 61, 230, 244, 114, 61, 230, - 241, 57, 61, 230, 243, 125, 241, 218, 61, 230, 237, 157, 61, 230, 244, - 46, 247, 238, 61, 230, 241, 84, 241, 173, 61, 230, 244, 27, 61, 230, 243, - 232, 61, 230, 239, 44, 61, 230, 241, 211, 61, 230, 243, 220, 241, 190, - 61, 230, 243, 82, 61, 230, 244, 45, 61, 230, 241, 84, 241, 246, 61, 230, - 248, 189, 254, 88, 248, 196, 61, 230, 252, 56, 61, 230, 246, 250, 61, - 230, 246, 103, 61, 230, 244, 165, 61, 167, 243, 215, 240, 200, 61, 244, - 180, 244, 78, 61, 244, 180, 245, 24, 242, 186, 61, 244, 180, 245, 24, - 242, 162, 61, 244, 180, 245, 24, 241, 30, 61, 244, 180, 242, 222, 61, - 244, 180, 244, 125, 61, 244, 180, 242, 186, 61, 244, 180, 242, 162, 61, - 244, 180, 241, 30, 61, 244, 180, 242, 223, 61, 244, 180, 241, 247, 61, - 244, 180, 242, 176, 112, 242, 181, 61, 244, 180, 243, 221, 61, 236, 191, - 243, 213, 61, 244, 180, 245, 1, 61, 236, 191, 244, 24, 61, 244, 180, 249, - 54, 227, 61, 244, 180, 254, 22, 227, 61, 236, 191, 254, 184, 244, 25, 61, - 167, 156, 227, 61, 1, 244, 224, 61, 1, 250, 154, 61, 1, 243, 134, 61, 1, - 242, 204, 61, 1, 253, 125, 61, 1, 250, 102, 61, 1, 244, 159, 61, 1, 251, - 66, 61, 1, 252, 202, 61, 1, 249, 183, 61, 1, 29, 249, 81, 61, 1, 249, 81, - 61, 1, 242, 179, 61, 1, 29, 249, 147, 61, 1, 249, 147, 61, 1, 29, 249, - 152, 61, 1, 249, 152, 61, 1, 241, 253, 61, 1, 245, 57, 61, 1, 29, 253, - 143, 61, 1, 253, 143, 61, 1, 29, 243, 14, 61, 1, 243, 14, 61, 1, 252, 95, - 61, 1, 245, 170, 61, 1, 245, 6, 61, 1, 250, 86, 61, 17, 241, 10, 42, 250, - 102, 61, 17, 241, 10, 254, 24, 249, 183, 61, 17, 241, 10, 42, 249, 183, - 61, 236, 191, 241, 57, 61, 236, 191, 237, 157, 10, 242, 84, 10, 237, 123, - 10, 239, 126, 65, 10, 1, 242, 221, 10, 1, 67, 2, 244, 237, 47, 10, 1, 67, - 2, 125, 47, 10, 1, 253, 162, 2, 125, 47, 10, 1, 67, 2, 125, 45, 10, 1, - 50, 2, 125, 47, 10, 1, 244, 224, 10, 1, 249, 190, 10, 1, 191, 240, 110, - 10, 1, 252, 199, 10, 1, 248, 122, 10, 1, 245, 115, 10, 1, 251, 56, 10, 1, - 245, 120, 10, 1, 250, 205, 10, 1, 248, 121, 10, 1, 249, 159, 10, 1, 245, - 231, 10, 1, 245, 42, 10, 1, 244, 76, 10, 1, 252, 152, 10, 1, 250, 203, - 10, 1, 250, 82, 10, 1, 253, 58, 10, 1, 250, 135, 10, 1, 243, 133, 10, - 240, 176, 10, 1, 249, 101, 10, 1, 250, 53, 10, 1, 249, 81, 10, 1, 251, - 182, 10, 1, 245, 140, 10, 1, 245, 152, 10, 1, 251, 62, 10, 1, 249, 124, - 10, 1, 67, 239, 189, 10, 1, 249, 91, 10, 239, 12, 10, 238, 197, 10, 239, - 35, 10, 243, 106, 10, 243, 81, 10, 243, 183, 10, 242, 9, 10, 243, 6, 10, - 243, 208, 47, 10, 125, 47, 10, 125, 45, 236, 46, 27, 244, 173, 236, 46, - 27, 121, 236, 46, 27, 114, 236, 46, 27, 153, 236, 46, 27, 163, 236, 46, - 27, 168, 236, 46, 27, 169, 236, 46, 27, 179, 236, 46, 27, 176, 236, 46, - 27, 178, 10, 240, 248, 57, 10, 241, 51, 237, 114, 10, 238, 133, 237, 114, - 10, 249, 48, 240, 218, 244, 178, 10, 1, 240, 228, 249, 190, 10, 1, 240, - 228, 250, 53, 10, 1, 236, 181, 244, 224, 10, 1, 67, 244, 144, 10, 1, 67, - 2, 249, 57, 125, 47, 10, 1, 67, 2, 249, 57, 125, 45, 10, 1, 249, 10, 242, - 221, 10, 1, 249, 10, 125, 244, 224, 10, 1, 249, 10, 125, 249, 124, 10, 1, - 115, 2, 125, 47, 10, 1, 249, 10, 125, 249, 91, 10, 1, 248, 145, 10, 1, - 242, 41, 10, 1, 246, 19, 10, 1, 191, 2, 244, 183, 10, 1, 191, 2, 244, - 171, 248, 253, 53, 237, 121, 10, 1, 249, 155, 10, 1, 244, 112, 10, 1, - 243, 42, 10, 1, 81, 2, 125, 47, 10, 1, 81, 2, 225, 248, 253, 55, 47, 10, - 1, 247, 203, 10, 1, 246, 118, 10, 1, 81, 2, 244, 171, 248, 253, 47, 10, - 1, 244, 111, 10, 1, 240, 177, 10, 1, 246, 83, 10, 1, 253, 180, 2, 244, - 183, 10, 1, 253, 180, 2, 49, 45, 10, 1, 253, 180, 2, 49, 244, 188, 18, 3, - 250, 82, 10, 1, 243, 79, 10, 1, 241, 136, 10, 1, 250, 230, 10, 1, 253, - 180, 2, 244, 171, 248, 253, 53, 237, 121, 10, 1, 253, 180, 2, 249, 28, - 248, 253, 47, 10, 1, 248, 26, 10, 1, 253, 105, 2, 3, 186, 10, 1, 253, - 105, 2, 244, 183, 10, 1, 253, 105, 2, 49, 45, 10, 1, 253, 105, 2, 3, 255, - 44, 45, 10, 1, 253, 105, 2, 49, 244, 188, 18, 49, 47, 10, 1, 253, 105, 2, - 225, 248, 253, 47, 10, 1, 251, 119, 10, 1, 253, 105, 2, 249, 28, 248, - 253, 47, 10, 1, 214, 2, 49, 244, 188, 18, 49, 47, 10, 1, 214, 2, 244, - 171, 248, 253, 45, 10, 1, 214, 2, 244, 171, 248, 253, 244, 188, 18, 244, - 171, 248, 253, 47, 10, 1, 253, 108, 2, 225, 248, 253, 45, 10, 1, 253, - 108, 2, 244, 171, 248, 253, 47, 10, 1, 253, 122, 2, 244, 171, 248, 253, - 47, 10, 1, 253, 117, 2, 244, 171, 248, 253, 47, 10, 1, 240, 228, 249, - 101, 10, 1, 253, 111, 2, 49, 247, 99, 45, 10, 1, 253, 111, 2, 49, 45, 10, - 1, 252, 251, 10, 1, 253, 111, 2, 244, 171, 248, 253, 45, 10, 1, 244, 29, - 10, 1, 253, 120, 2, 49, 47, 10, 1, 253, 120, 2, 244, 171, 248, 253, 47, - 10, 1, 243, 187, 10, 1, 248, 110, 249, 81, 10, 1, 253, 87, 2, 244, 183, - 10, 1, 253, 87, 2, 49, 47, 10, 1, 253, 244, 10, 1, 253, 87, 2, 244, 171, - 248, 253, 45, 10, 1, 251, 23, 10, 1, 253, 194, 2, 244, 183, 10, 1, 243, - 245, 10, 1, 253, 194, 2, 225, 248, 253, 45, 10, 1, 246, 162, 10, 1, 253, - 194, 2, 244, 171, 248, 253, 47, 10, 1, 155, 2, 3, 186, 10, 1, 155, 2, 49, - 47, 10, 1, 155, 2, 244, 171, 248, 253, 47, 10, 1, 155, 2, 244, 171, 248, - 253, 45, 10, 1, 177, 2, 49, 45, 10, 1, 177, 241, 177, 10, 1, 244, 61, 10, - 1, 177, 2, 244, 183, 10, 1, 177, 2, 244, 171, 248, 253, 47, 10, 1, 188, - 236, 97, 10, 1, 244, 240, 2, 49, 47, 10, 1, 188, 2, 50, 47, 10, 1, 188, - 245, 99, 10, 1, 188, 249, 79, 2, 125, 47, 10, 1, 191, 241, 26, 245, 99, - 10, 1, 253, 162, 2, 244, 183, 10, 1, 240, 217, 253, 142, 10, 1, 253, 142, - 10, 1, 84, 10, 1, 253, 124, 10, 1, 240, 217, 253, 124, 10, 1, 253, 162, - 2, 225, 248, 253, 47, 10, 1, 253, 214, 10, 1, 244, 227, 249, 91, 10, 1, - 50, 2, 244, 182, 10, 1, 50, 2, 3, 186, 10, 1, 253, 162, 2, 49, 47, 10, 1, - 70, 10, 1, 50, 2, 244, 171, 248, 253, 45, 10, 1, 50, 241, 110, 10, 1, 50, - 242, 139, 2, 125, 47, 10, 213, 189, 10, 1, 253, 163, 10, 3, 249, 10, 17, - 253, 108, 2, 155, 2, 67, 239, 189, 10, 3, 249, 10, 17, 253, 120, 2, 155, - 2, 67, 239, 189, 10, 3, 249, 10, 43, 46, 12, 10, 3, 249, 10, 155, 244, - 224, 10, 3, 249, 10, 245, 115, 10, 3, 249, 10, 244, 171, 244, 215, 10, 3, - 249, 10, 245, 42, 10, 253, 127, 137, 245, 250, 10, 245, 45, 137, 254, - 181, 254, 241, 246, 178, 10, 3, 249, 10, 241, 4, 244, 173, 10, 3, 249, - 10, 242, 44, 236, 226, 244, 173, 10, 3, 249, 10, 240, 228, 251, 61, 137, - 245, 120, 10, 3, 249, 10, 43, 35, 12, 10, 3, 253, 113, 245, 42, 10, 3, - 249, 10, 243, 207, 10, 3, 249, 124, 10, 3, 249, 91, 10, 3, 249, 10, 249, - 91, 10, 3, 249, 10, 245, 152, 10, 245, 162, 137, 241, 252, 10, 244, 216, - 242, 100, 253, 113, 189, 10, 244, 216, 242, 100, 249, 10, 189, 10, 241, - 4, 249, 10, 249, 71, 2, 243, 113, 241, 46, 10, 3, 253, 113, 245, 140, - 239, 141, 236, 46, 27, 244, 173, 239, 141, 236, 46, 27, 121, 239, 141, - 236, 46, 27, 114, 239, 141, 236, 46, 27, 153, 239, 141, 236, 46, 27, 163, - 239, 141, 236, 46, 27, 168, 239, 141, 236, 46, 27, 169, 239, 141, 236, - 46, 27, 179, 239, 141, 236, 46, 27, 176, 239, 141, 236, 46, 27, 178, 10, - 1, 215, 2, 49, 45, 10, 1, 253, 107, 2, 49, 45, 10, 1, 244, 190, 2, 49, - 45, 10, 25, 243, 1, 237, 124, 10, 25, 243, 1, 236, 156, 249, 148, 118, - 253, 127, 137, 238, 41, 118, 236, 210, 213, 189, 118, 238, 129, 213, 189, - 118, 236, 210, 242, 81, 118, 238, 129, 242, 81, 118, 146, 242, 81, 118, - 244, 214, 242, 166, 244, 172, 118, 244, 214, 242, 166, 184, 118, 236, - 210, 244, 214, 242, 166, 244, 172, 118, 238, 129, 244, 214, 242, 166, - 184, 118, 236, 90, 118, 239, 184, 241, 226, 118, 239, 184, 238, 32, 118, - 239, 184, 236, 245, 118, 236, 60, 65, 118, 1, 242, 195, 118, 1, 236, 181, - 242, 195, 118, 1, 246, 24, 118, 1, 243, 122, 118, 1, 246, 134, 238, 141, - 118, 1, 241, 133, 118, 1, 240, 228, 243, 80, 245, 172, 118, 1, 253, 125, - 118, 1, 249, 124, 118, 1, 245, 231, 118, 1, 246, 173, 118, 1, 248, 120, - 118, 1, 252, 203, 238, 141, 118, 1, 248, 202, 118, 1, 253, 48, 253, 125, - 118, 1, 247, 27, 118, 1, 241, 196, 118, 1, 251, 235, 118, 1, 249, 152, - 118, 1, 239, 234, 118, 1, 29, 239, 234, 118, 1, 70, 118, 1, 253, 143, - 118, 1, 224, 253, 143, 118, 1, 244, 68, 118, 1, 248, 0, 118, 1, 245, 172, - 118, 1, 245, 6, 118, 1, 252, 197, 118, 242, 184, 47, 118, 242, 184, 45, - 118, 242, 184, 241, 18, 118, 242, 194, 47, 118, 242, 194, 45, 118, 242, - 194, 241, 18, 118, 245, 169, 47, 118, 245, 169, 45, 118, 242, 118, 245, - 234, 236, 182, 118, 242, 118, 245, 234, 239, 251, 118, 245, 106, 47, 118, - 245, 106, 45, 118, 237, 65, 241, 18, 118, 245, 82, 47, 118, 245, 82, 45, - 118, 244, 67, 118, 239, 216, 227, 118, 238, 51, 118, 239, 77, 118, 225, - 55, 248, 253, 47, 118, 225, 55, 248, 253, 45, 118, 244, 171, 248, 253, - 47, 118, 244, 171, 248, 253, 45, 118, 241, 2, 217, 47, 118, 241, 2, 217, - 45, 118, 243, 233, 118, 240, 4, 161, 1, 249, 68, 161, 1, 238, 59, 161, 1, - 244, 2, 161, 1, 249, 115, 161, 1, 249, 188, 161, 1, 238, 28, 161, 1, 243, - 181, 161, 1, 243, 28, 161, 1, 244, 136, 161, 1, 243, 216, 161, 1, 243, - 104, 161, 1, 241, 138, 161, 1, 245, 8, 161, 1, 243, 198, 161, 1, 243, - 120, 161, 1, 238, 10, 161, 1, 244, 72, 161, 1, 238, 198, 161, 1, 239, - 114, 161, 1, 239, 101, 161, 1, 249, 180, 161, 1, 239, 60, 161, 1, 239, - 34, 161, 1, 237, 180, 161, 1, 248, 143, 161, 1, 245, 107, 161, 1, 247, - 29, 161, 1, 242, 33, 161, 1, 250, 123, 161, 1, 242, 11, 161, 1, 241, 251, - 161, 1, 241, 132, 161, 1, 76, 161, 1, 253, 190, 161, 1, 245, 241, 161, 1, - 241, 176, 161, 1, 244, 44, 161, 1, 244, 143, 161, 239, 246, 161, 237, - 171, 161, 240, 88, 161, 238, 2, 161, 240, 190, 161, 238, 38, 161, 240, - 63, 161, 238, 8, 161, 240, 128, 161, 238, 37, 161, 243, 6, 161, 1, 249, - 150, 72, 25, 236, 49, 72, 25, 238, 90, 72, 25, 239, 148, 72, 1, 64, 72, - 1, 253, 95, 72, 1, 69, 72, 1, 253, 96, 72, 1, 84, 72, 1, 253, 104, 72, 1, - 152, 135, 72, 1, 152, 148, 72, 1, 242, 110, 70, 72, 1, 207, 70, 72, 1, - 70, 72, 1, 253, 106, 72, 1, 242, 110, 78, 72, 1, 207, 78, 72, 1, 78, 72, - 1, 253, 109, 72, 1, 208, 72, 1, 249, 24, 72, 1, 253, 100, 72, 1, 249, 36, - 72, 1, 249, 13, 72, 1, 253, 115, 72, 1, 249, 11, 72, 1, 253, 118, 72, 1, - 249, 45, 72, 1, 249, 38, 72, 1, 249, 22, 72, 1, 244, 195, 72, 1, 249, 27, - 72, 1, 244, 200, 72, 1, 249, 37, 72, 1, 253, 91, 72, 1, 249, 19, 72, 1, - 253, 93, 72, 1, 249, 40, 72, 1, 253, 94, 72, 1, 245, 150, 72, 1, 253, 90, - 72, 1, 249, 29, 72, 1, 253, 110, 72, 1, 249, 39, 72, 1, 221, 72, 1, 216, - 72, 1, 253, 92, 72, 1, 249, 50, 72, 1, 253, 103, 72, 1, 249, 49, 72, 1, - 245, 27, 72, 1, 253, 161, 72, 1, 249, 7, 72, 1, 249, 34, 72, 1, 253, 97, - 72, 1, 253, 88, 72, 25, 242, 149, 72, 25, 238, 117, 72, 38, 25, 253, 95, - 72, 38, 25, 69, 72, 38, 25, 253, 96, 72, 38, 25, 84, 72, 38, 25, 253, - 104, 72, 38, 25, 152, 135, 72, 38, 25, 152, 253, 130, 72, 38, 25, 242, - 110, 70, 72, 38, 25, 207, 70, 72, 38, 25, 70, 72, 38, 25, 253, 106, 72, - 38, 25, 242, 110, 78, 72, 38, 25, 207, 78, 72, 38, 25, 78, 72, 38, 25, - 253, 109, 72, 25, 240, 220, 72, 253, 245, 72, 242, 188, 25, 242, 43, 72, - 242, 188, 25, 238, 170, 72, 244, 201, 240, 203, 72, 244, 196, 240, 203, - 72, 1, 253, 213, 72, 1, 245, 124, 72, 1, 245, 97, 72, 1, 253, 129, 72, 1, - 243, 84, 72, 1, 249, 160, 72, 1, 253, 153, 72, 1, 249, 184, 72, 1, 152, - 253, 130, 72, 1, 152, 253, 146, 72, 38, 25, 152, 148, 72, 38, 25, 152, - 253, 146, 72, 242, 205, 72, 42, 242, 205, 72, 27, 244, 173, 72, 27, 121, - 72, 27, 114, 72, 27, 153, 72, 27, 163, 72, 27, 168, 72, 27, 169, 72, 27, - 179, 72, 27, 176, 72, 27, 178, 72, 236, 60, 57, 91, 25, 236, 49, 91, 25, - 238, 90, 91, 25, 239, 148, 91, 1, 64, 91, 1, 253, 95, 91, 1, 69, 91, 1, - 253, 96, 91, 1, 84, 91, 1, 253, 104, 91, 1, 152, 135, 91, 1, 152, 148, - 91, 1, 70, 91, 1, 253, 106, 91, 1, 78, 91, 1, 253, 109, 91, 1, 208, 91, - 1, 249, 24, 91, 1, 253, 100, 91, 1, 249, 36, 91, 1, 249, 13, 91, 1, 253, - 115, 91, 1, 249, 11, 91, 1, 253, 118, 91, 1, 249, 45, 91, 1, 249, 38, 91, - 1, 249, 22, 91, 1, 244, 195, 91, 1, 249, 27, 91, 1, 244, 200, 91, 1, 249, - 37, 91, 1, 253, 91, 91, 1, 249, 19, 91, 1, 253, 93, 91, 1, 249, 40, 91, - 1, 253, 94, 91, 1, 253, 90, 91, 1, 249, 29, 91, 1, 253, 110, 91, 1, 249, - 39, 91, 1, 221, 91, 1, 216, 91, 1, 253, 92, 91, 1, 253, 103, 91, 1, 249, - 7, 91, 1, 249, 34, 91, 1, 253, 97, 91, 1, 253, 88, 91, 25, 242, 149, 91, - 38, 25, 253, 95, 91, 38, 25, 69, 91, 38, 25, 253, 96, 91, 38, 25, 84, 91, - 38, 25, 253, 104, 91, 38, 25, 152, 135, 91, 38, 25, 152, 253, 130, 91, - 38, 25, 70, 91, 38, 25, 253, 106, 91, 38, 25, 78, 91, 38, 25, 253, 109, - 91, 25, 240, 220, 91, 254, 230, 242, 106, 65, 91, 1, 249, 50, 91, 1, 249, - 160, 91, 1, 249, 184, 91, 1, 152, 253, 130, 91, 1, 152, 253, 146, 91, 38, - 25, 152, 148, 91, 38, 25, 152, 253, 146, 91, 27, 244, 173, 91, 27, 121, - 91, 27, 114, 91, 27, 153, 91, 27, 163, 91, 27, 168, 91, 27, 169, 91, 27, - 179, 91, 27, 176, 91, 27, 178, 91, 1, 254, 253, 2, 242, 65, 238, 109, 91, - 1, 254, 253, 2, 149, 238, 109, 91, 245, 40, 65, 91, 245, 40, 57, 91, 239, - 147, 238, 103, 121, 91, 239, 147, 238, 103, 114, 91, 239, 147, 238, 103, - 153, 91, 239, 147, 238, 103, 163, 91, 239, 147, 238, 103, 253, 101, 251, - 190, 249, 166, 253, 173, 236, 95, 91, 239, 147, 237, 0, 239, 162, 91, - 241, 59, 113, 25, 243, 44, 113, 1, 64, 113, 1, 253, 95, 113, 1, 69, 113, - 1, 253, 96, 113, 1, 84, 113, 1, 253, 104, 113, 1, 253, 126, 113, 1, 253, - 106, 113, 1, 253, 119, 113, 1, 253, 109, 113, 1, 208, 113, 1, 249, 24, - 113, 1, 253, 100, 113, 1, 249, 36, 113, 1, 249, 13, 113, 1, 253, 115, - 113, 1, 249, 11, 113, 1, 253, 118, 113, 1, 249, 45, 113, 1, 249, 38, 113, - 1, 249, 22, 113, 1, 244, 195, 113, 1, 249, 27, 113, 1, 244, 200, 113, 1, - 249, 37, 113, 1, 253, 91, 113, 1, 249, 19, 113, 1, 253, 93, 113, 1, 249, - 40, 113, 1, 253, 94, 113, 1, 253, 90, 113, 1, 249, 29, 113, 1, 253, 110, - 113, 1, 249, 39, 113, 1, 221, 113, 1, 216, 113, 1, 253, 92, 113, 1, 253, - 103, 113, 1, 249, 49, 113, 1, 253, 161, 113, 1, 249, 7, 113, 1, 253, 97, - 113, 1, 253, 88, 113, 25, 242, 149, 113, 38, 25, 253, 95, 113, 38, 25, - 69, 113, 38, 25, 253, 96, 113, 38, 25, 84, 113, 38, 25, 253, 104, 113, - 38, 25, 253, 126, 113, 38, 25, 253, 106, 113, 38, 25, 253, 119, 113, 38, - 25, 253, 109, 113, 25, 240, 220, 113, 1, 245, 124, 113, 1, 245, 97, 113, - 1, 253, 129, 113, 1, 249, 50, 113, 1, 253, 153, 113, 27, 244, 173, 113, - 27, 121, 113, 27, 114, 113, 27, 153, 113, 27, 163, 113, 27, 168, 113, 27, - 169, 113, 27, 179, 113, 27, 176, 113, 27, 178, 113, 244, 121, 113, 243, - 25, 113, 251, 114, 113, 252, 244, 113, 255, 6, 244, 19, 106, 25, 236, 49, - 106, 25, 238, 90, 106, 25, 239, 148, 106, 1, 64, 106, 1, 253, 95, 106, 1, - 69, 106, 1, 253, 96, 106, 1, 84, 106, 1, 253, 104, 106, 1, 152, 135, 106, - 38, 242, 110, 70, 106, 1, 70, 106, 1, 253, 106, 106, 38, 242, 110, 78, - 106, 1, 78, 106, 1, 253, 109, 106, 1, 208, 106, 1, 249, 24, 106, 1, 253, - 100, 106, 1, 249, 36, 106, 1, 249, 13, 106, 1, 253, 115, 106, 1, 249, 11, - 106, 1, 253, 118, 106, 1, 249, 45, 106, 1, 249, 38, 106, 1, 249, 22, 106, - 1, 244, 195, 106, 1, 249, 27, 106, 1, 244, 200, 106, 1, 249, 37, 106, 1, - 253, 91, 106, 1, 249, 19, 106, 1, 253, 93, 106, 1, 249, 40, 106, 1, 253, - 94, 106, 1, 253, 90, 106, 1, 249, 29, 106, 1, 253, 110, 106, 1, 249, 39, - 106, 1, 221, 106, 1, 216, 106, 1, 253, 92, 106, 1, 253, 103, 106, 1, 249, - 49, 106, 1, 253, 161, 106, 1, 249, 7, 106, 1, 249, 34, 106, 1, 253, 97, - 106, 1, 253, 88, 106, 25, 242, 149, 106, 25, 238, 117, 106, 38, 25, 253, - 95, 106, 38, 25, 69, 106, 38, 25, 253, 96, 106, 38, 25, 84, 106, 38, 25, - 253, 104, 106, 38, 25, 152, 135, 106, 38, 25, 152, 253, 130, 106, 38, 25, - 242, 110, 70, 106, 38, 25, 70, 106, 38, 25, 253, 106, 106, 38, 25, 242, - 110, 78, 106, 38, 25, 78, 106, 38, 25, 253, 109, 106, 25, 240, 220, 106, - 253, 245, 106, 1, 152, 253, 130, 106, 27, 244, 173, 106, 27, 121, 106, - 27, 114, 106, 27, 153, 106, 27, 163, 106, 27, 168, 106, 27, 169, 106, 27, - 179, 106, 27, 176, 106, 27, 178, 105, 25, 236, 49, 105, 25, 238, 90, 105, - 25, 239, 148, 105, 1, 64, 105, 1, 253, 95, 105, 1, 69, 105, 1, 253, 96, - 105, 1, 84, 105, 1, 253, 104, 105, 1, 152, 135, 105, 1, 152, 148, 105, 1, - 70, 105, 1, 253, 106, 105, 1, 78, 105, 1, 253, 109, 105, 1, 208, 105, 1, - 249, 24, 105, 1, 253, 100, 105, 1, 249, 36, 105, 1, 249, 13, 105, 1, 253, - 115, 105, 1, 249, 11, 105, 1, 253, 118, 105, 1, 249, 45, 105, 1, 249, 38, - 105, 1, 249, 22, 105, 1, 244, 195, 105, 1, 249, 27, 105, 1, 244, 200, - 105, 1, 249, 37, 105, 1, 253, 91, 105, 1, 249, 19, 105, 1, 253, 93, 105, - 1, 249, 40, 105, 1, 253, 94, 105, 1, 253, 90, 105, 1, 249, 29, 105, 1, - 253, 110, 105, 1, 249, 39, 105, 1, 221, 105, 1, 216, 105, 1, 253, 92, - 105, 1, 253, 103, 105, 1, 249, 49, 105, 1, 249, 7, 105, 1, 249, 34, 105, - 1, 253, 97, 105, 1, 253, 88, 105, 25, 242, 149, 105, 25, 238, 117, 105, - 38, 25, 253, 95, 105, 38, 25, 69, 105, 38, 25, 253, 96, 105, 38, 25, 84, - 105, 38, 25, 253, 104, 105, 38, 25, 152, 135, 105, 38, 25, 70, 105, 38, - 25, 253, 106, 105, 38, 25, 78, 105, 38, 25, 253, 109, 105, 25, 240, 220, - 105, 254, 227, 242, 106, 65, 105, 254, 230, 242, 106, 65, 105, 1, 249, - 50, 105, 1, 249, 160, 105, 1, 249, 184, 105, 1, 152, 253, 130, 105, 1, - 152, 253, 146, 105, 27, 244, 173, 105, 27, 121, 105, 27, 114, 105, 27, - 153, 105, 27, 163, 105, 27, 168, 105, 27, 169, 105, 27, 179, 105, 27, - 176, 105, 27, 178, 105, 241, 59, 142, 25, 238, 90, 142, 25, 239, 148, - 142, 1, 64, 142, 1, 253, 95, 142, 1, 69, 142, 1, 253, 96, 142, 1, 84, - 142, 1, 253, 104, 142, 1, 70, 142, 1, 253, 126, 142, 1, 253, 106, 142, 1, - 78, 142, 1, 253, 119, 142, 1, 253, 109, 142, 1, 208, 142, 1, 249, 13, - 142, 1, 253, 115, 142, 1, 253, 118, 142, 1, 249, 38, 142, 1, 249, 22, - 142, 1, 249, 37, 142, 1, 253, 91, 142, 1, 253, 94, 142, 1, 245, 150, 142, - 1, 253, 90, 142, 1, 221, 142, 1, 216, 142, 1, 253, 92, 142, 1, 249, 50, - 142, 1, 253, 103, 142, 1, 249, 49, 142, 1, 245, 27, 142, 1, 253, 161, - 142, 1, 249, 34, 142, 1, 253, 97, 142, 1, 253, 88, 142, 38, 25, 253, 95, - 142, 38, 25, 69, 142, 38, 25, 253, 96, 142, 38, 25, 84, 142, 38, 25, 253, - 104, 142, 38, 25, 70, 142, 38, 25, 253, 126, 142, 38, 25, 253, 106, 142, - 38, 25, 78, 142, 38, 25, 253, 119, 142, 38, 25, 253, 109, 142, 25, 240, - 220, 142, 254, 230, 242, 106, 65, 142, 27, 121, 142, 27, 114, 142, 27, - 153, 142, 27, 163, 142, 27, 168, 142, 27, 169, 142, 27, 179, 142, 27, - 176, 142, 27, 178, 142, 83, 249, 18, 142, 83, 253, 101, 239, 150, 142, - 83, 253, 101, 238, 104, 104, 25, 236, 49, 104, 25, 238, 90, 104, 25, 239, - 148, 104, 1, 64, 104, 1, 253, 95, 104, 1, 69, 104, 1, 253, 96, 104, 1, - 84, 104, 1, 253, 104, 104, 1, 152, 135, 104, 1, 152, 148, 104, 1, 70, - 104, 1, 253, 126, 104, 1, 253, 106, 104, 1, 78, 104, 1, 253, 119, 104, 1, - 253, 109, 104, 1, 208, 104, 1, 249, 24, 104, 1, 253, 100, 104, 1, 249, - 36, 104, 1, 249, 13, 104, 1, 253, 115, 104, 1, 249, 11, 104, 1, 253, 118, - 104, 1, 249, 45, 104, 1, 249, 38, 104, 1, 249, 22, 104, 1, 244, 195, 104, - 1, 249, 27, 104, 1, 244, 200, 104, 1, 249, 37, 104, 1, 253, 91, 104, 1, - 249, 19, 104, 1, 253, 93, 104, 1, 249, 40, 104, 1, 253, 94, 104, 1, 253, - 90, 104, 1, 249, 29, 104, 1, 253, 110, 104, 1, 249, 39, 104, 1, 221, 104, - 1, 216, 104, 1, 253, 92, 104, 1, 249, 50, 104, 1, 253, 103, 104, 1, 249, - 49, 104, 1, 253, 161, 104, 1, 249, 7, 104, 1, 249, 34, 104, 1, 253, 97, - 104, 1, 253, 88, 104, 38, 25, 253, 95, 104, 38, 25, 69, 104, 38, 25, 253, - 96, 104, 38, 25, 84, 104, 38, 25, 253, 104, 104, 38, 25, 152, 135, 104, - 38, 25, 152, 253, 130, 104, 38, 25, 70, 104, 38, 25, 253, 126, 104, 38, - 25, 253, 106, 104, 38, 25, 78, 104, 38, 25, 253, 119, 104, 38, 25, 253, - 109, 104, 25, 240, 220, 104, 242, 106, 65, 104, 254, 227, 242, 106, 65, - 104, 1, 152, 253, 130, 104, 1, 152, 253, 146, 104, 27, 244, 173, 104, 27, - 121, 104, 27, 114, 104, 27, 153, 104, 27, 163, 104, 27, 168, 104, 27, - 169, 104, 27, 179, 104, 27, 176, 104, 27, 178, 102, 25, 238, 90, 102, 25, - 239, 148, 102, 1, 64, 102, 1, 253, 95, 102, 1, 69, 102, 1, 253, 96, 102, - 1, 84, 102, 1, 253, 104, 102, 1, 152, 135, 102, 1, 152, 148, 102, 1, 70, - 102, 1, 253, 126, 102, 1, 253, 106, 102, 1, 78, 102, 1, 253, 119, 102, 1, - 253, 109, 102, 1, 208, 102, 1, 249, 24, 102, 1, 253, 100, 102, 1, 249, - 36, 102, 1, 249, 13, 102, 1, 253, 115, 102, 1, 249, 11, 102, 1, 253, 118, - 102, 1, 249, 45, 102, 1, 249, 38, 102, 1, 249, 22, 102, 1, 244, 195, 102, - 1, 249, 27, 102, 1, 244, 200, 102, 1, 249, 37, 102, 1, 253, 91, 102, 1, - 249, 19, 102, 1, 253, 93, 102, 1, 249, 40, 102, 1, 253, 94, 102, 1, 253, - 90, 102, 1, 249, 29, 102, 1, 253, 110, 102, 1, 249, 39, 102, 1, 221, 102, - 1, 216, 102, 1, 253, 92, 102, 1, 249, 50, 102, 1, 253, 103, 102, 1, 249, - 49, 102, 1, 253, 161, 102, 1, 249, 7, 102, 1, 249, 34, 102, 1, 253, 97, - 102, 1, 253, 88, 102, 38, 25, 253, 95, 102, 38, 25, 69, 102, 38, 25, 253, - 96, 102, 38, 25, 84, 102, 38, 25, 253, 104, 102, 38, 25, 152, 135, 102, - 38, 25, 152, 253, 130, 102, 38, 25, 70, 102, 38, 25, 253, 126, 102, 38, - 25, 253, 106, 102, 38, 25, 78, 102, 38, 25, 253, 119, 102, 38, 25, 253, - 109, 102, 25, 240, 220, 102, 242, 106, 65, 102, 254, 227, 242, 106, 65, - 102, 1, 253, 153, 102, 1, 152, 253, 130, 102, 1, 152, 253, 146, 102, 27, - 244, 173, 102, 27, 121, 102, 27, 114, 102, 27, 153, 102, 27, 163, 102, - 27, 168, 102, 27, 169, 102, 27, 179, 102, 27, 176, 102, 27, 178, 107, 25, - 238, 90, 107, 25, 239, 148, 107, 1, 64, 107, 1, 253, 95, 107, 1, 69, 107, - 1, 253, 96, 107, 1, 84, 107, 1, 253, 104, 107, 1, 152, 135, 107, 1, 152, - 148, 107, 1, 70, 107, 1, 253, 126, 107, 1, 253, 106, 107, 1, 78, 107, 1, - 253, 119, 107, 1, 253, 109, 107, 1, 208, 107, 1, 249, 24, 107, 1, 253, - 100, 107, 1, 249, 36, 107, 1, 249, 13, 107, 1, 253, 115, 107, 1, 249, 11, - 107, 1, 253, 118, 107, 1, 249, 45, 107, 1, 249, 38, 107, 1, 249, 22, 107, - 1, 244, 195, 107, 1, 249, 27, 107, 1, 244, 200, 107, 1, 249, 37, 107, 1, - 253, 91, 107, 1, 249, 19, 107, 1, 253, 93, 107, 1, 249, 40, 107, 1, 253, - 94, 107, 1, 253, 90, 107, 1, 249, 29, 107, 1, 253, 110, 107, 1, 249, 39, - 107, 1, 221, 107, 1, 216, 107, 1, 253, 92, 107, 1, 249, 50, 107, 1, 253, - 103, 107, 1, 249, 49, 107, 1, 245, 27, 107, 1, 253, 161, 107, 1, 249, 7, - 107, 1, 249, 34, 107, 1, 253, 97, 107, 1, 253, 88, 107, 38, 25, 253, 95, - 107, 38, 25, 69, 107, 38, 25, 253, 96, 107, 38, 25, 84, 107, 38, 25, 253, - 104, 107, 38, 25, 152, 135, 107, 38, 25, 70, 107, 38, 25, 253, 126, 107, - 38, 25, 253, 106, 107, 38, 25, 78, 107, 38, 25, 253, 119, 107, 38, 25, - 253, 109, 107, 25, 240, 220, 107, 254, 230, 242, 106, 65, 107, 1, 152, - 253, 130, 107, 1, 152, 253, 146, 107, 27, 244, 173, 107, 27, 121, 107, - 27, 114, 107, 27, 153, 107, 27, 163, 107, 27, 168, 107, 27, 169, 107, 27, - 179, 107, 27, 176, 107, 27, 178, 103, 25, 236, 243, 103, 25, 238, 72, - 103, 1, 241, 106, 103, 1, 239, 245, 103, 1, 239, 247, 103, 1, 238, 168, - 103, 1, 241, 188, 103, 1, 240, 90, 103, 1, 242, 46, 103, 1, 240, 191, - 103, 1, 239, 33, 103, 1, 238, 21, 103, 1, 239, 29, 103, 1, 238, 16, 103, - 1, 241, 156, 103, 1, 240, 64, 103, 1, 239, 248, 103, 1, 241, 232, 103, 1, - 240, 132, 103, 1, 240, 1, 103, 1, 237, 115, 239, 221, 103, 1, 236, 189, - 239, 221, 103, 1, 237, 115, 239, 183, 103, 1, 236, 189, 239, 183, 103, 1, - 241, 189, 236, 219, 103, 1, 241, 5, 239, 183, 103, 1, 237, 115, 239, 206, - 103, 1, 236, 189, 239, 206, 103, 1, 237, 115, 239, 185, 103, 1, 236, 189, - 239, 185, 103, 1, 241, 34, 236, 219, 103, 1, 241, 34, 240, 158, 236, 146, - 103, 1, 241, 5, 239, 185, 103, 1, 237, 115, 238, 163, 103, 1, 236, 189, - 238, 163, 103, 1, 237, 115, 238, 118, 103, 1, 236, 189, 238, 118, 103, 1, - 238, 123, 239, 226, 103, 1, 241, 5, 238, 118, 103, 1, 237, 115, 239, 241, - 103, 1, 236, 189, 239, 241, 103, 1, 237, 115, 239, 179, 103, 1, 236, 189, - 239, 179, 103, 1, 241, 16, 239, 226, 103, 1, 241, 5, 239, 179, 103, 1, - 237, 115, 239, 227, 103, 1, 236, 189, 239, 227, 103, 1, 237, 115, 239, - 177, 103, 1, 236, 189, 239, 177, 103, 1, 240, 112, 103, 1, 250, 136, 239, - 177, 103, 1, 240, 197, 103, 1, 240, 150, 103, 1, 241, 16, 239, 223, 103, - 1, 240, 192, 103, 1, 241, 34, 239, 194, 103, 1, 238, 123, 239, 194, 103, - 1, 241, 16, 239, 194, 103, 1, 240, 85, 103, 1, 238, 123, 239, 223, 103, - 1, 240, 72, 103, 25, 237, 172, 103, 38, 25, 236, 199, 103, 38, 25, 245, - 26, 236, 211, 103, 38, 25, 249, 62, 236, 211, 103, 38, 25, 245, 26, 238, - 146, 103, 38, 25, 249, 62, 238, 146, 103, 38, 25, 245, 26, 237, 161, 103, - 38, 25, 249, 62, 237, 161, 103, 38, 25, 235, 251, 103, 38, 25, 239, 222, - 103, 38, 25, 249, 62, 239, 222, 103, 38, 25, 247, 38, 246, 104, 103, 38, - 25, 241, 23, 254, 14, 236, 199, 103, 38, 25, 241, 23, 254, 14, 249, 62, - 236, 199, 103, 38, 25, 241, 23, 254, 14, 236, 62, 103, 38, 25, 236, 62, - 103, 38, 25, 249, 62, 235, 251, 103, 38, 25, 249, 62, 236, 62, 103, 236, - 191, 237, 73, 95, 92, 254, 249, 251, 141, 95, 92, 253, 198, 247, 30, 95, - 92, 253, 198, 243, 189, 95, 92, 253, 198, 243, 190, 95, 92, 253, 198, - 247, 33, 95, 92, 253, 198, 240, 148, 95, 92, 254, 156, 252, 20, 95, 92, - 253, 237, 246, 45, 95, 92, 253, 237, 243, 63, 95, 92, 253, 237, 243, 61, - 95, 92, 254, 225, 253, 159, 95, 92, 253, 237, 246, 52, 95, 92, 255, 0, - 248, 194, 95, 92, 254, 240, 243, 59, 95, 92, 139, 244, 26, 95, 92, 253, - 188, 245, 47, 95, 92, 253, 188, 237, 76, 95, 92, 253, 188, 240, 139, 95, - 92, 254, 243, 252, 12, 95, 92, 254, 240, 250, 212, 95, 92, 139, 252, 194, - 95, 92, 253, 188, 244, 119, 95, 92, 253, 188, 242, 34, 95, 92, 253, 188, - 244, 118, 95, 92, 254, 243, 253, 112, 95, 92, 255, 3, 241, 108, 95, 92, - 255, 20, 252, 70, 95, 92, 253, 230, 244, 36, 95, 92, 254, 232, 253, 153, - 95, 92, 253, 230, 247, 243, 95, 92, 254, 232, 250, 251, 95, 92, 253, 230, - 240, 157, 95, 92, 255, 15, 221, 95, 92, 255, 0, 253, 41, 95, 92, 255, 21, - 252, 137, 95, 92, 253, 170, 95, 92, 254, 234, 245, 131, 95, 92, 253, 229, - 95, 92, 255, 26, 248, 169, 95, 92, 254, 225, 248, 51, 95, 92, 254, 225, - 248, 47, 95, 92, 254, 225, 252, 178, 95, 92, 254, 222, 251, 74, 95, 92, - 254, 234, 243, 65, 95, 92, 109, 249, 75, 95, 92, 254, 222, 241, 222, 95, - 92, 238, 40, 95, 92, 249, 33, 64, 95, 92, 253, 147, 239, 25, 95, 92, 249, - 33, 253, 95, 95, 92, 249, 33, 253, 234, 95, 92, 249, 33, 69, 95, 92, 249, - 33, 253, 96, 95, 92, 249, 33, 253, 253, 95, 92, 249, 33, 252, 236, 95, - 92, 249, 33, 84, 95, 92, 249, 33, 253, 104, 95, 92, 240, 138, 95, 239, - 147, 13, 245, 251, 95, 92, 249, 33, 70, 95, 92, 249, 33, 253, 163, 95, - 92, 249, 33, 78, 95, 92, 249, 33, 254, 227, 240, 108, 95, 92, 249, 33, - 254, 227, 239, 45, 95, 92, 236, 142, 95, 92, 239, 46, 95, 92, 238, 30, - 95, 92, 253, 147, 254, 37, 95, 92, 253, 147, 249, 55, 95, 92, 253, 147, - 252, 216, 95, 92, 253, 147, 238, 189, 95, 92, 236, 173, 95, 92, 239, 51, - 95, 92, 239, 112, 95, 92, 240, 76, 95, 27, 244, 173, 95, 27, 121, 95, 27, - 114, 95, 27, 153, 95, 27, 163, 95, 27, 168, 95, 27, 169, 95, 27, 179, 95, - 27, 176, 95, 27, 178, 95, 92, 236, 241, 95, 92, 241, 192, 132, 1, 253, - 155, 132, 1, 253, 198, 244, 231, 132, 1, 253, 198, 249, 72, 132, 1, 249, - 110, 132, 1, 253, 178, 132, 1, 254, 225, 249, 72, 132, 1, 249, 84, 132, - 1, 253, 193, 132, 1, 76, 132, 1, 253, 188, 244, 231, 132, 1, 253, 188, - 249, 72, 132, 1, 253, 136, 132, 1, 253, 221, 132, 1, 253, 187, 132, 1, - 253, 230, 244, 231, 132, 1, 254, 232, 249, 72, 132, 1, 253, 230, 249, 72, - 132, 1, 254, 232, 244, 231, 132, 1, 253, 141, 132, 1, 253, 123, 132, 1, - 254, 234, 245, 131, 132, 1, 254, 234, 247, 68, 132, 1, 253, 138, 132, 1, - 254, 225, 244, 231, 132, 1, 254, 222, 244, 231, 132, 1, 78, 132, 1, 254, - 222, 249, 72, 132, 238, 96, 132, 38, 25, 64, 132, 38, 25, 253, 147, 249, - 139, 132, 38, 25, 253, 95, 132, 38, 25, 253, 234, 132, 38, 25, 69, 132, - 38, 25, 253, 96, 132, 38, 25, 181, 132, 38, 25, 254, 26, 132, 38, 25, 84, - 132, 38, 25, 253, 104, 132, 38, 25, 253, 147, 251, 165, 132, 238, 157, - 25, 253, 184, 132, 238, 157, 25, 249, 84, 132, 38, 25, 70, 132, 38, 25, - 254, 36, 132, 38, 25, 78, 132, 38, 25, 254, 2, 132, 38, 25, 253, 106, - 132, 254, 249, 253, 103, 132, 249, 5, 253, 147, 254, 37, 132, 249, 5, - 253, 147, 249, 55, 132, 249, 5, 253, 147, 253, 174, 132, 249, 5, 253, - 147, 241, 122, 132, 236, 87, 65, 132, 238, 36, 132, 27, 244, 173, 132, - 27, 121, 132, 27, 114, 132, 27, 153, 132, 27, 163, 132, 27, 168, 132, 27, - 169, 132, 27, 179, 132, 27, 176, 132, 27, 178, 132, 254, 222, 253, 136, - 132, 254, 222, 253, 141, 41, 4, 253, 245, 41, 167, 249, 80, 253, 175, - 253, 199, 239, 105, 64, 41, 167, 249, 80, 253, 175, 253, 199, 254, 28, - 250, 64, 250, 150, 221, 41, 167, 249, 80, 253, 175, 253, 199, 254, 28, - 249, 80, 244, 242, 221, 41, 167, 46, 253, 175, 253, 199, 251, 224, 221, - 41, 167, 241, 48, 253, 175, 253, 199, 252, 160, 221, 41, 167, 244, 225, - 253, 175, 253, 199, 250, 45, 250, 70, 221, 41, 167, 253, 175, 253, 199, - 244, 242, 250, 70, 221, 41, 167, 248, 53, 244, 223, 41, 167, 246, 33, - 253, 175, 249, 107, 41, 167, 250, 162, 252, 163, 253, 175, 249, 107, 41, - 167, 236, 24, 243, 15, 41, 167, 238, 200, 244, 242, 243, 53, 41, 167, - 244, 223, 41, 167, 249, 154, 244, 223, 41, 167, 244, 242, 244, 223, 41, - 167, 249, 154, 244, 242, 244, 223, 41, 167, 254, 179, 250, 185, 244, 98, - 244, 223, 41, 167, 250, 63, 251, 45, 244, 223, 41, 167, 244, 225, 245, - 54, 245, 3, 255, 14, 165, 249, 61, 41, 167, 249, 80, 243, 15, 41, 239, - 224, 25, 250, 184, 242, 121, 41, 239, 224, 25, 251, 192, 242, 121, 41, - 236, 61, 25, 252, 162, 251, 28, 245, 235, 242, 121, 41, 236, 61, 25, 243, - 23, 253, 90, 41, 236, 61, 25, 248, 55, 242, 40, 41, 25, 249, 53, 249, 98, - 245, 92, 41, 25, 249, 53, 249, 98, 242, 219, 41, 25, 249, 53, 249, 98, - 245, 102, 41, 25, 249, 53, 254, 16, 245, 92, 41, 25, 249, 53, 254, 16, - 242, 219, 41, 25, 249, 53, 249, 98, 249, 53, 251, 252, 41, 27, 244, 173, - 41, 27, 121, 41, 27, 114, 41, 27, 153, 41, 27, 163, 41, 27, 168, 41, 27, - 169, 41, 27, 179, 41, 27, 176, 41, 27, 178, 41, 27, 136, 121, 41, 27, - 136, 114, 41, 27, 136, 153, 41, 27, 136, 163, 41, 27, 136, 168, 41, 27, - 136, 169, 41, 27, 136, 179, 41, 27, 136, 176, 41, 27, 136, 178, 41, 27, - 136, 244, 173, 41, 167, 246, 32, 242, 121, 41, 167, 250, 27, 245, 65, - 254, 59, 253, 69, 41, 167, 244, 225, 245, 54, 245, 3, 249, 130, 254, 56, - 249, 61, 41, 167, 250, 27, 245, 65, 252, 161, 242, 121, 41, 167, 253, - 164, 249, 107, 41, 167, 254, 73, 243, 24, 41, 167, 254, 43, 245, 3, 245, - 104, 41, 167, 254, 43, 245, 3, 245, 103, 41, 167, 254, 29, 245, 121, 245, - 104, 41, 167, 254, 29, 245, 121, 245, 103, 41, 25, 254, 208, 243, 16, 41, - 25, 254, 139, 243, 16, 41, 1, 208, 41, 1, 249, 24, 41, 1, 253, 100, 41, - 1, 249, 36, 41, 1, 249, 13, 41, 1, 253, 115, 41, 1, 249, 11, 41, 1, 253, - 118, 41, 1, 249, 38, 41, 1, 249, 22, 41, 1, 244, 195, 41, 1, 249, 27, 41, - 1, 244, 200, 41, 1, 249, 37, 41, 1, 253, 91, 41, 1, 249, 19, 41, 1, 253, - 93, 41, 1, 249, 40, 41, 1, 253, 94, 41, 1, 253, 90, 41, 1, 249, 29, 41, - 1, 253, 110, 41, 1, 249, 39, 41, 1, 221, 41, 1, 249, 56, 41, 1, 245, 211, - 41, 1, 249, 100, 41, 1, 245, 78, 41, 1, 253, 98, 41, 1, 249, 52, 41, 1, - 253, 129, 41, 1, 254, 27, 41, 1, 216, 41, 1, 253, 92, 41, 1, 253, 103, - 41, 1, 249, 7, 41, 1, 249, 34, 41, 1, 253, 97, 41, 1, 253, 88, 41, 1, 64, - 41, 1, 245, 127, 41, 1, 237, 134, 253, 92, 41, 38, 25, 253, 95, 41, 38, - 25, 69, 41, 38, 25, 253, 96, 41, 38, 25, 84, 41, 38, 25, 253, 104, 41, - 38, 25, 152, 135, 41, 38, 25, 152, 253, 130, 41, 38, 25, 152, 148, 41, - 38, 25, 152, 253, 146, 41, 38, 25, 70, 41, 38, 25, 253, 126, 41, 38, 25, - 78, 41, 38, 25, 253, 119, 41, 25, 252, 128, 255, 22, 254, 155, 253, 144, - 41, 25, 250, 64, 246, 17, 41, 38, 25, 224, 69, 41, 38, 25, 224, 253, 96, - 41, 25, 254, 59, 254, 212, 254, 152, 253, 93, 41, 25, 254, 183, 247, 55, - 41, 167, 240, 83, 41, 167, 241, 234, 41, 25, 254, 132, 242, 121, 41, 25, - 250, 112, 242, 121, 41, 25, 254, 131, 254, 73, 249, 61, 41, 25, 251, 223, - 249, 61, 41, 25, 254, 42, 254, 91, 239, 232, 41, 25, 254, 42, 254, 141, - 239, 232, 41, 185, 1, 208, 41, 185, 1, 249, 24, 41, 185, 1, 253, 100, 41, - 185, 1, 249, 36, 41, 185, 1, 249, 13, 41, 185, 1, 253, 115, 41, 185, 1, - 249, 11, 41, 185, 1, 253, 118, 41, 185, 1, 249, 38, 41, 185, 1, 249, 22, - 41, 185, 1, 244, 195, 41, 185, 1, 249, 27, 41, 185, 1, 244, 200, 41, 185, - 1, 249, 37, 41, 185, 1, 253, 91, 41, 185, 1, 249, 19, 41, 185, 1, 253, - 93, 41, 185, 1, 249, 40, 41, 185, 1, 253, 94, 41, 185, 1, 253, 90, 41, - 185, 1, 249, 29, 41, 185, 1, 253, 110, 41, 185, 1, 249, 39, 41, 185, 1, - 221, 41, 185, 1, 249, 56, 41, 185, 1, 245, 211, 41, 185, 1, 249, 100, 41, - 185, 1, 245, 78, 41, 185, 1, 253, 98, 41, 185, 1, 249, 52, 41, 185, 1, - 253, 129, 41, 185, 1, 254, 27, 41, 185, 1, 216, 41, 185, 1, 253, 92, 41, - 185, 1, 253, 103, 41, 185, 1, 249, 7, 41, 185, 1, 249, 34, 41, 185, 1, - 253, 97, 41, 185, 1, 253, 88, 41, 185, 1, 64, 41, 185, 1, 245, 127, 41, - 185, 1, 237, 134, 253, 98, 41, 185, 1, 237, 134, 216, 41, 185, 1, 237, - 134, 253, 92, 41, 254, 250, 254, 254, 249, 24, 41, 254, 250, 254, 254, - 254, 125, 249, 130, 254, 56, 249, 61, 41, 236, 54, 25, 82, 245, 60, 41, - 236, 54, 25, 117, 245, 60, 41, 236, 54, 25, 250, 176, 248, 118, 41, 236, - 54, 25, 252, 157, 243, 22, 41, 13, 250, 228, 253, 192, 41, 13, 254, 69, - 252, 127, 41, 13, 247, 237, 246, 135, 41, 13, 254, 69, 254, 180, 250, 63, - 246, 160, 41, 13, 250, 45, 253, 90, 41, 13, 253, 137, 253, 192, 41, 13, - 253, 137, 254, 239, 249, 154, 241, 11, 41, 13, 253, 137, 254, 239, 251, - 46, 241, 11, 41, 13, 253, 137, 254, 239, 249, 130, 241, 11, 41, 25, 249, - 53, 254, 16, 245, 102, 108, 1, 208, 108, 1, 249, 24, 108, 1, 253, 100, - 108, 1, 249, 36, 108, 1, 249, 13, 108, 1, 253, 115, 108, 1, 249, 11, 108, - 1, 253, 118, 108, 1, 249, 45, 108, 1, 249, 38, 108, 1, 247, 179, 108, 1, - 249, 22, 108, 1, 244, 195, 108, 1, 249, 27, 108, 1, 244, 200, 108, 1, - 249, 37, 108, 1, 253, 91, 108, 1, 249, 19, 108, 1, 253, 93, 108, 1, 249, - 40, 108, 1, 253, 94, 108, 1, 253, 90, 108, 1, 249, 29, 108, 1, 253, 110, - 108, 1, 249, 39, 108, 1, 221, 108, 1, 216, 108, 1, 253, 92, 108, 1, 253, - 103, 108, 1, 253, 98, 108, 1, 253, 97, 108, 1, 253, 88, 108, 1, 249, 49, - 108, 1, 64, 108, 1, 69, 108, 1, 253, 96, 108, 1, 84, 108, 1, 253, 104, - 108, 1, 70, 108, 1, 78, 108, 1, 253, 109, 108, 38, 25, 253, 95, 108, 38, - 25, 69, 108, 38, 25, 253, 96, 108, 38, 25, 84, 108, 38, 25, 253, 104, - 108, 38, 25, 70, 108, 38, 25, 253, 106, 108, 25, 238, 90, 108, 25, 49, - 45, 108, 25, 239, 148, 108, 25, 240, 220, 108, 27, 244, 173, 108, 27, - 121, 108, 27, 114, 108, 27, 153, 108, 27, 163, 108, 27, 168, 108, 27, - 169, 108, 27, 179, 108, 27, 176, 108, 27, 178, 108, 25, 242, 147, 239, - 174, 108, 25, 239, 174, 108, 13, 239, 42, 108, 13, 237, 181, 108, 13, - 234, 68, 108, 13, 239, 23, 108, 1, 249, 7, 108, 1, 249, 34, 108, 1, 152, - 135, 108, 1, 152, 253, 130, 108, 1, 152, 148, 108, 1, 152, 253, 146, 108, - 38, 25, 152, 135, 108, 38, 25, 152, 253, 130, 108, 38, 25, 152, 148, 108, - 38, 25, 152, 253, 146, 101, 5, 1, 253, 235, 101, 5, 1, 249, 189, 101, 5, - 1, 249, 227, 101, 5, 1, 249, 216, 101, 5, 1, 253, 166, 101, 5, 1, 250, - 106, 101, 5, 1, 250, 124, 101, 5, 1, 250, 83, 101, 5, 1, 253, 227, 101, - 5, 1, 249, 139, 101, 5, 1, 250, 7, 101, 5, 1, 249, 146, 101, 5, 1, 250, - 25, 101, 5, 1, 253, 246, 101, 5, 1, 250, 40, 101, 5, 1, 245, 233, 101, 5, - 1, 250, 60, 101, 5, 1, 250, 67, 101, 5, 1, 250, 84, 101, 5, 1, 254, 75, - 101, 5, 1, 245, 159, 101, 5, 1, 245, 122, 101, 5, 1, 245, 96, 101, 5, 1, - 250, 55, 101, 5, 1, 245, 6, 101, 5, 1, 245, 69, 101, 5, 1, 249, 61, 101, - 5, 1, 249, 247, 101, 5, 1, 249, 197, 101, 5, 1, 245, 67, 101, 5, 1, 250, - 111, 101, 5, 1, 245, 116, 101, 5, 1, 249, 239, 101, 5, 1, 253, 125, 101, - 5, 1, 249, 137, 101, 5, 1, 253, 132, 101, 5, 1, 249, 240, 101, 5, 1, 249, - 245, 101, 1, 253, 235, 101, 1, 249, 189, 101, 1, 249, 227, 101, 1, 249, - 216, 101, 1, 253, 166, 101, 1, 250, 106, 101, 1, 250, 124, 101, 1, 250, - 83, 101, 1, 253, 227, 101, 1, 249, 139, 101, 1, 250, 7, 101, 1, 249, 146, - 101, 1, 250, 25, 101, 1, 253, 246, 101, 1, 250, 40, 101, 1, 245, 233, - 101, 1, 250, 60, 101, 1, 250, 67, 101, 1, 250, 84, 101, 1, 254, 75, 101, - 1, 245, 159, 101, 1, 245, 122, 101, 1, 245, 96, 101, 1, 250, 55, 101, 1, - 245, 6, 101, 1, 245, 69, 101, 1, 249, 61, 101, 1, 249, 247, 101, 1, 249, - 197, 101, 1, 245, 67, 101, 1, 250, 111, 101, 1, 245, 116, 101, 1, 249, - 239, 101, 1, 253, 125, 101, 1, 249, 137, 101, 1, 253, 132, 101, 1, 249, - 240, 101, 1, 249, 245, 101, 1, 253, 226, 101, 1, 254, 209, 101, 1, 243, - 98, 101, 238, 113, 237, 114, 20, 88, 240, 242, 20, 88, 236, 59, 20, 88, - 242, 131, 20, 88, 240, 244, 20, 88, 236, 72, 20, 88, 242, 134, 20, 88, - 242, 129, 20, 88, 242, 133, 20, 88, 236, 209, 20, 88, 244, 230, 20, 88, - 237, 138, 20, 88, 242, 126, 20, 88, 242, 122, 20, 88, 236, 207, 20, 88, - 239, 155, 20, 88, 239, 158, 20, 88, 239, 166, 20, 88, 239, 161, 20, 88, - 242, 125, 20, 88, 235, 254, 20, 88, 236, 233, 20, 88, 235, 246, 20, 88, - 236, 148, 20, 88, 235, 208, 20, 88, 236, 79, 20, 88, 236, 234, 20, 88, - 236, 57, 20, 88, 235, 221, 20, 88, 236, 64, 20, 88, 235, 194, 20, 88, - 235, 255, 20, 88, 236, 154, 20, 88, 236, 0, 20, 88, 236, 198, 20, 88, - 231, 248, 20, 88, 231, 249, 20, 88, 232, 9, 20, 88, 234, 57, 20, 88, 232, - 8, 20, 88, 236, 77, 20, 88, 235, 226, 20, 88, 235, 205, 20, 88, 235, 204, - 20, 88, 235, 195, 20, 88, 231, 240, 20, 88, 236, 70, 20, 88, 236, 230, - 20, 88, 236, 71, 20, 88, 236, 231, 20, 88, 237, 98, 20, 88, 236, 206, 20, - 88, 232, 2, 20, 88, 235, 185, 20, 88, 237, 97, 20, 88, 236, 229, 20, 88, - 236, 33, 20, 88, 236, 34, 20, 88, 236, 36, 20, 88, 236, 35, 20, 88, 237, - 96, 20, 88, 236, 6, 20, 88, 231, 252, 20, 88, 232, 18, 20, 88, 231, 237, - 20, 88, 239, 191, 20, 88, 235, 253, 20, 88, 236, 23, 20, 88, 236, 136, - 20, 88, 236, 137, 20, 88, 237, 68, 20, 88, 235, 218, 20, 88, 236, 208, - 20, 88, 236, 135, 20, 88, 235, 216, 20, 88, 235, 220, 20, 88, 235, 219, - 20, 88, 238, 134, 20, 88, 236, 88, 20, 88, 235, 214, 20, 88, 231, 243, - 20, 88, 232, 6, 20, 88, 231, 234, 20, 88, 232, 19, 20, 88, 235, 213, 20, - 88, 232, 20, 20, 88, 231, 242, 20, 88, 235, 203, 20, 88, 232, 14, 20, 88, - 236, 232, 20, 88, 236, 73, 20, 88, 240, 255, 20, 129, 240, 255, 20, 129, - 64, 20, 129, 253, 163, 20, 129, 216, 20, 129, 249, 181, 20, 129, 254, 10, - 20, 129, 70, 20, 129, 249, 182, 20, 129, 253, 200, 20, 129, 78, 20, 129, - 253, 98, 20, 129, 249, 175, 20, 129, 253, 142, 20, 129, 253, 123, 20, - 129, 84, 20, 129, 249, 177, 20, 129, 253, 132, 20, 129, 253, 145, 20, - 129, 253, 124, 20, 129, 254, 12, 20, 129, 253, 139, 20, 129, 69, 20, 129, - 250, 132, 20, 129, 250, 133, 20, 129, 248, 186, 20, 129, 244, 151, 20, - 129, 246, 123, 20, 129, 246, 124, 20, 129, 243, 100, 20, 129, 244, 154, - 20, 129, 244, 155, 20, 129, 247, 231, 20, 129, 252, 53, 20, 129, 247, - 232, 20, 129, 252, 54, 20, 129, 252, 55, 20, 129, 243, 19, 20, 129, 241, - 91, 20, 129, 242, 57, 20, 129, 248, 195, 20, 129, 245, 226, 20, 129, 252, - 234, 20, 129, 248, 159, 20, 129, 240, 189, 20, 129, 248, 160, 20, 129, - 252, 235, 20, 129, 248, 198, 20, 129, 244, 157, 20, 129, 248, 199, 20, - 129, 241, 92, 20, 129, 243, 20, 20, 129, 248, 200, 20, 129, 245, 228, 20, - 129, 246, 126, 20, 129, 243, 102, 20, 129, 248, 190, 20, 129, 251, 104, - 20, 129, 246, 247, 20, 129, 251, 105, 20, 129, 251, 106, 20, 129, 246, - 246, 20, 129, 240, 87, 20, 129, 242, 197, 20, 129, 238, 174, 20, 129, - 239, 255, 20, 129, 239, 254, 20, 129, 237, 99, 20, 99, 240, 242, 20, 99, - 236, 59, 20, 99, 236, 63, 20, 99, 242, 131, 20, 99, 236, 65, 20, 99, 236, - 66, 20, 99, 240, 244, 20, 99, 242, 134, 20, 99, 235, 247, 20, 99, 236, - 67, 20, 99, 236, 68, 20, 99, 236, 204, 20, 99, 235, 197, 20, 99, 235, - 196, 20, 99, 236, 57, 20, 99, 242, 129, 20, 99, 242, 133, 20, 99, 236, - 198, 20, 99, 244, 230, 20, 99, 237, 138, 20, 99, 242, 126, 20, 99, 242, - 122, 20, 99, 239, 155, 20, 99, 239, 158, 20, 99, 239, 166, 20, 99, 239, - 161, 20, 99, 242, 125, 20, 99, 236, 26, 20, 99, 231, 244, 20, 99, 235, - 254, 20, 99, 235, 246, 20, 99, 236, 220, 20, 99, 235, 201, 20, 99, 235, - 224, 20, 99, 235, 208, 20, 99, 236, 39, 20, 99, 231, 250, 20, 99, 236, - 79, 20, 99, 236, 1, 20, 99, 231, 246, 20, 99, 236, 234, 20, 99, 231, 245, - 20, 99, 232, 10, 20, 99, 232, 4, 20, 99, 232, 0, 20, 99, 231, 239, 20, - 99, 234, 60, 20, 99, 235, 206, 20, 99, 235, 227, 20, 99, 231, 251, 20, - 99, 236, 27, 20, 99, 236, 144, 20, 99, 236, 64, 20, 99, 236, 216, 20, 99, - 234, 55, 20, 99, 235, 200, 20, 99, 235, 223, 20, 99, 236, 143, 20, 99, - 235, 194, 20, 99, 236, 155, 20, 99, 235, 204, 20, 99, 236, 153, 20, 99, - 235, 195, 20, 99, 236, 70, 20, 99, 236, 71, 20, 99, 236, 231, 20, 99, - 236, 206, 20, 99, 239, 191, 20, 99, 235, 253, 20, 99, 231, 253, 20, 99, - 236, 208, 20, 99, 235, 217, 20, 99, 238, 134, 20, 99, 235, 210, 20, 99, - 232, 5, 20, 99, 235, 203, 20, 99, 232, 14, 20, 99, 236, 132, 20, 99, 236, - 134, 20, 99, 236, 131, 20, 99, 236, 133, 20, 99, 236, 73, 24, 4, 253, 88, - 24, 4, 253, 197, 24, 4, 253, 154, 24, 4, 249, 68, 24, 4, 249, 242, 24, 4, - 253, 125, 24, 4, 253, 140, 24, 4, 253, 103, 24, 4, 253, 229, 24, 4, 253, - 211, 24, 4, 250, 6, 24, 4, 250, 8, 24, 4, 253, 210, 24, 4, 253, 184, 24, - 4, 249, 145, 24, 4, 251, 68, 24, 4, 251, 72, 24, 4, 251, 70, 24, 4, 245, - 107, 24, 4, 246, 174, 24, 4, 251, 69, 24, 4, 251, 71, 24, 4, 246, 175, - 24, 4, 221, 24, 4, 253, 114, 24, 4, 253, 156, 24, 4, 250, 17, 24, 4, 250, - 18, 24, 4, 253, 167, 24, 4, 253, 141, 24, 4, 249, 149, 24, 4, 252, 189, - 24, 4, 252, 193, 24, 4, 252, 191, 24, 4, 248, 112, 24, 4, 248, 113, 24, - 4, 252, 190, 24, 4, 252, 192, 24, 4, 248, 114, 24, 4, 253, 92, 24, 4, - 253, 170, 24, 4, 253, 169, 24, 4, 249, 115, 24, 4, 250, 62, 24, 4, 253, - 150, 24, 4, 253, 144, 24, 4, 252, 144, 24, 4, 253, 97, 24, 4, 253, 172, - 24, 4, 253, 158, 24, 4, 250, 66, 24, 4, 249, 117, 24, 4, 253, 171, 24, 4, - 253, 159, 24, 4, 249, 163, 24, 4, 249, 7, 24, 4, 249, 162, 24, 4, 249, - 118, 24, 4, 245, 180, 24, 4, 245, 182, 24, 4, 249, 70, 24, 4, 249, 85, - 24, 4, 245, 43, 24, 4, 253, 213, 24, 4, 254, 19, 24, 4, 253, 249, 24, 4, - 249, 157, 24, 4, 252, 85, 24, 4, 254, 67, 24, 4, 254, 18, 24, 4, 252, - 108, 24, 4, 252, 110, 24, 4, 248, 14, 24, 4, 248, 15, 24, 4, 252, 109, - 24, 4, 252, 86, 24, 4, 252, 90, 24, 4, 252, 88, 24, 4, 248, 1, 24, 4, - 248, 2, 24, 4, 252, 87, 24, 4, 252, 89, 24, 4, 248, 3, 24, 4, 248, 5, 24, - 4, 244, 48, 24, 4, 244, 49, 24, 4, 248, 4, 24, 4, 253, 110, 24, 4, 253, - 192, 24, 4, 253, 236, 24, 4, 249, 188, 24, 4, 249, 128, 24, 4, 253, 191, - 24, 4, 253, 221, 24, 4, 250, 169, 24, 4, 253, 161, 24, 4, 253, 255, 24, - 4, 254, 25, 24, 4, 252, 247, 24, 4, 249, 174, 24, 4, 253, 214, 24, 4, - 253, 215, 24, 4, 253, 8, 24, 4, 253, 91, 24, 4, 253, 160, 24, 4, 253, - 174, 24, 4, 250, 80, 24, 4, 249, 164, 24, 4, 253, 151, 24, 4, 76, 24, 4, - 249, 172, 24, 4, 253, 115, 24, 4, 254, 32, 24, 4, 254, 5, 24, 4, 249, - 194, 24, 4, 250, 180, 24, 4, 254, 4, 24, 4, 253, 178, 24, 4, 249, 132, - 24, 4, 254, 204, 24, 4, 254, 206, 24, 4, 253, 135, 24, 4, 253, 23, 24, 4, - 253, 24, 24, 4, 254, 205, 24, 4, 254, 77, 24, 4, 253, 34, 24, 4, 253, 36, - 24, 4, 248, 183, 24, 4, 248, 184, 24, 4, 253, 35, 24, 4, 253, 94, 24, 4, - 253, 112, 24, 4, 253, 148, 24, 4, 249, 150, 24, 4, 250, 26, 24, 4, 253, - 157, 24, 4, 253, 136, 24, 4, 249, 153, 24, 4, 249, 38, 24, 4, 250, 34, - 24, 4, 250, 33, 24, 4, 247, 201, 24, 4, 247, 202, 24, 4, 252, 47, 24, 4, - 249, 84, 24, 4, 247, 213, 24, 4, 240, 211, 64, 24, 4, 240, 211, 84, 24, - 4, 240, 211, 69, 24, 4, 240, 211, 253, 95, 24, 4, 240, 211, 253, 126, 24, - 4, 240, 211, 70, 24, 4, 240, 211, 78, 24, 4, 240, 211, 253, 98, 24, 4, - 208, 24, 4, 253, 183, 24, 4, 253, 182, 24, 4, 249, 252, 24, 4, 251, 146, - 24, 4, 253, 134, 24, 4, 253, 155, 24, 4, 249, 141, 24, 4, 249, 143, 24, - 4, 244, 254, 24, 4, 247, 44, 24, 4, 249, 142, 24, 4, 251, 176, 24, 4, - 251, 180, 24, 4, 251, 178, 24, 4, 247, 45, 24, 4, 247, 46, 24, 4, 251, - 177, 24, 4, 251, 179, 24, 4, 247, 47, 24, 4, 247, 49, 24, 4, 243, 195, - 24, 4, 243, 196, 24, 4, 247, 48, 24, 4, 253, 98, 24, 4, 253, 216, 24, 4, - 253, 145, 24, 4, 249, 123, 24, 4, 250, 109, 24, 4, 253, 132, 24, 4, 253, - 138, 24, 4, 237, 117, 64, 24, 4, 237, 117, 84, 24, 4, 237, 117, 69, 24, - 4, 237, 117, 253, 95, 24, 4, 237, 117, 253, 126, 24, 4, 237, 117, 70, 24, - 4, 237, 117, 78, 24, 4, 253, 129, 24, 4, 253, 233, 24, 4, 253, 218, 24, - 4, 250, 123, 24, 4, 249, 126, 24, 4, 253, 189, 24, 4, 253, 190, 24, 4, - 253, 76, 24, 4, 249, 52, 24, 4, 250, 127, 24, 4, 250, 125, 24, 4, 248, - 209, 24, 4, 245, 53, 24, 4, 249, 74, 24, 4, 250, 126, 24, 4, 248, 224, - 24, 4, 216, 24, 4, 253, 124, 24, 4, 253, 139, 24, 4, 249, 180, 24, 4, - 249, 125, 24, 4, 253, 200, 24, 4, 253, 123, 24, 4, 253, 93, 24, 4, 253, - 204, 24, 4, 253, 165, 24, 4, 250, 202, 24, 4, 249, 96, 24, 4, 253, 152, - 24, 4, 253, 193, 24, 4, 250, 236, 24, 4, 249, 27, 24, 4, 249, 212, 24, 4, - 249, 210, 24, 4, 246, 82, 24, 4, 246, 87, 24, 4, 249, 209, 24, 4, 249, - 211, 24, 4, 246, 101, 24, 4, 253, 118, 24, 4, 253, 241, 24, 4, 253, 228, - 24, 4, 251, 117, 24, 4, 249, 104, 24, 4, 253, 239, 24, 4, 253, 240, 24, - 4, 251, 135, 24, 4, 253, 100, 24, 4, 253, 196, 24, 4, 253, 209, 24, 4, - 249, 136, 24, 4, 249, 229, 24, 4, 253, 207, 24, 4, 253, 195, 24, 4, 251, - 52, 24, 4, 251, 54, 24, 4, 246, 167, 24, 4, 246, 168, 24, 4, 251, 53, 24, - 4, 249, 231, 24, 4, 249, 235, 24, 4, 249, 233, 24, 4, 246, 136, 24, 4, - 246, 140, 24, 4, 249, 232, 24, 4, 249, 234, 24, 4, 249, 19, 24, 4, 250, - 87, 24, 4, 249, 73, 24, 4, 245, 8, 24, 4, 245, 9, 24, 4, 249, 63, 24, 4, - 249, 55, 24, 4, 248, 126, 24, 4, 249, 11, 24, 4, 249, 131, 24, 4, 249, - 23, 24, 4, 246, 44, 24, 4, 244, 246, 24, 4, 249, 44, 24, 4, 249, 94, 24, - 4, 246, 60, 24, 4, 249, 29, 24, 4, 252, 63, 24, 4, 249, 30, 24, 4, 247, - 242, 24, 4, 247, 244, 24, 4, 250, 43, 24, 4, 250, 44, 24, 4, 247, 245, - 24, 4, 249, 56, 24, 4, 249, 171, 24, 4, 249, 169, 24, 4, 248, 140, 24, 4, - 245, 210, 24, 4, 249, 64, 24, 4, 249, 170, 24, 4, 248, 142, 24, 4, 252, - 229, 24, 4, 252, 233, 24, 4, 252, 231, 24, 4, 248, 157, 24, 4, 248, 158, - 24, 4, 252, 230, 24, 4, 252, 232, 24, 4, 253, 153, 24, 4, 254, 41, 24, 4, - 253, 226, 24, 4, 249, 222, 24, 4, 250, 255, 24, 4, 254, 40, 24, 4, 254, - 13, 24, 4, 251, 18, 24, 4, 253, 90, 24, 4, 253, 231, 24, 4, 253, 116, 24, - 4, 250, 39, 24, 4, 249, 114, 24, 4, 253, 143, 24, 4, 253, 187, 24, 4, - 249, 156, 24, 4, 252, 145, 24, 4, 251, 248, 24, 4, 251, 19, 24, 238, 73, - 24, 213, 189, 24, 242, 84, 24, 237, 123, 24, 242, 81, 24, 241, 243, 242, - 81, 24, 239, 126, 65, 24, 238, 113, 237, 114, 24, 27, 121, 24, 27, 114, - 24, 27, 153, 24, 27, 163, 24, 27, 168, 24, 27, 169, 24, 27, 179, 24, 27, - 176, 24, 27, 178, 24, 83, 249, 18, 24, 83, 240, 239, 24, 83, 241, 7, 24, - 83, 242, 213, 24, 83, 242, 144, 24, 83, 244, 85, 24, 83, 240, 162, 24, - 83, 241, 152, 24, 83, 241, 69, 24, 83, 239, 150, 24, 83, 253, 250, 238, - 104, 96, 1, 64, 96, 1, 70, 96, 1, 69, 96, 1, 78, 96, 1, 84, 96, 1, 186, - 96, 1, 253, 100, 96, 1, 208, 96, 1, 253, 207, 96, 1, 253, 209, 96, 1, - 253, 195, 96, 1, 253, 196, 96, 1, 254, 109, 96, 1, 253, 88, 96, 1, 253, - 125, 96, 1, 253, 154, 96, 1, 253, 140, 96, 1, 253, 197, 96, 1, 254, 44, - 96, 1, 253, 103, 96, 1, 253, 210, 96, 1, 253, 211, 96, 1, 253, 184, 96, - 1, 253, 229, 96, 1, 254, 137, 96, 1, 221, 96, 1, 253, 167, 96, 1, 253, - 156, 96, 1, 253, 141, 96, 1, 253, 114, 96, 1, 253, 94, 96, 1, 249, 244, - 96, 1, 251, 253, 96, 1, 253, 157, 96, 1, 253, 148, 96, 1, 253, 136, 96, - 1, 253, 112, 96, 1, 254, 58, 96, 1, 252, 99, 96, 1, 252, 100, 96, 1, 252, - 101, 96, 1, 250, 58, 96, 1, 250, 59, 96, 1, 252, 106, 96, 1, 253, 97, 96, - 1, 159, 96, 1, 253, 171, 96, 1, 253, 158, 96, 1, 253, 159, 96, 1, 253, - 172, 96, 1, 254, 72, 96, 1, 253, 93, 96, 1, 253, 91, 96, 1, 253, 152, 96, - 1, 253, 151, 96, 1, 253, 165, 96, 1, 253, 174, 96, 1, 253, 193, 96, 1, - 253, 204, 96, 1, 254, 99, 96, 1, 249, 214, 96, 1, 250, 89, 96, 1, 250, - 90, 96, 1, 250, 91, 96, 1, 250, 92, 96, 1, 250, 93, 96, 1, 252, 212, 96, - 1, 249, 56, 96, 1, 249, 64, 96, 1, 249, 169, 96, 1, 249, 170, 96, 1, 249, - 171, 96, 1, 252, 217, 96, 1, 253, 98, 96, 1, 253, 132, 96, 1, 253, 145, - 96, 1, 253, 138, 96, 1, 253, 216, 96, 1, 254, 203, 96, 1, 216, 96, 1, - 253, 200, 96, 1, 253, 139, 96, 1, 253, 123, 96, 1, 253, 124, 96, 1, 254, - 210, 14, 15, 70, 14, 15, 250, 134, 14, 15, 69, 14, 15, 253, 96, 14, 15, - 78, 14, 15, 253, 119, 14, 15, 242, 98, 253, 119, 14, 15, 44, 253, 126, - 14, 15, 44, 69, 14, 15, 64, 14, 15, 253, 95, 14, 15, 253, 132, 14, 15, - 94, 253, 132, 14, 15, 253, 145, 14, 15, 94, 253, 145, 14, 15, 250, 110, - 14, 15, 94, 250, 110, 14, 15, 253, 138, 14, 15, 94, 253, 138, 14, 15, - 249, 178, 14, 15, 94, 249, 178, 14, 15, 240, 212, 249, 178, 14, 15, 253, - 98, 14, 15, 94, 253, 98, 14, 15, 249, 123, 14, 15, 94, 249, 123, 14, 15, - 240, 212, 249, 123, 14, 15, 253, 106, 14, 15, 242, 98, 201, 14, 15, 240, - 211, 189, 14, 15, 29, 116, 14, 15, 29, 158, 14, 15, 29, 242, 80, 136, - 244, 183, 14, 15, 29, 253, 121, 136, 244, 183, 14, 15, 29, 37, 136, 244, - 183, 14, 15, 29, 244, 183, 14, 15, 29, 42, 116, 14, 15, 29, 42, 207, 55, - 239, 240, 14, 15, 29, 242, 65, 227, 14, 15, 29, 207, 146, 122, 14, 15, - 29, 244, 212, 14, 15, 29, 79, 244, 184, 14, 15, 253, 166, 14, 15, 253, - 227, 14, 15, 253, 246, 14, 15, 253, 235, 14, 15, 253, 143, 14, 15, 247, - 236, 14, 15, 253, 116, 14, 15, 252, 66, 14, 15, 253, 187, 14, 15, 250, - 47, 14, 15, 242, 98, 250, 47, 14, 15, 44, 249, 242, 14, 15, 44, 253, 154, - 14, 15, 253, 90, 14, 15, 250, 39, 14, 15, 250, 49, 14, 15, 94, 250, 49, - 14, 15, 250, 50, 14, 15, 94, 250, 50, 14, 15, 245, 164, 14, 15, 94, 245, - 164, 14, 15, 250, 51, 14, 15, 94, 250, 51, 14, 15, 245, 165, 14, 15, 94, - 245, 165, 14, 15, 249, 156, 14, 15, 94, 249, 156, 14, 15, 245, 38, 14, - 15, 94, 245, 38, 14, 15, 242, 98, 245, 38, 14, 15, 198, 14, 15, 94, 198, - 14, 15, 44, 164, 14, 15, 253, 151, 14, 15, 248, 115, 14, 15, 253, 174, - 14, 15, 252, 208, 14, 15, 76, 14, 15, 249, 167, 14, 15, 242, 98, 249, - 167, 14, 15, 44, 249, 96, 14, 15, 44, 253, 165, 14, 15, 253, 91, 14, 15, - 250, 80, 14, 15, 250, 99, 14, 15, 94, 250, 99, 14, 15, 250, 100, 14, 15, - 94, 250, 100, 14, 15, 245, 215, 14, 15, 94, 245, 215, 14, 15, 114, 14, - 15, 94, 114, 14, 15, 245, 216, 14, 15, 94, 245, 216, 14, 15, 249, 172, - 14, 15, 94, 249, 172, 14, 15, 245, 49, 14, 15, 94, 245, 49, 14, 15, 240, - 212, 245, 49, 14, 15, 190, 14, 15, 250, 95, 14, 15, 250, 96, 14, 15, 250, - 97, 14, 15, 249, 22, 14, 15, 253, 134, 14, 15, 247, 26, 14, 15, 253, 182, - 14, 15, 251, 156, 14, 15, 253, 155, 14, 15, 250, 3, 14, 15, 242, 98, 250, - 3, 14, 15, 208, 14, 15, 249, 252, 14, 15, 249, 142, 14, 15, 94, 249, 142, - 14, 15, 249, 143, 14, 15, 94, 249, 143, 14, 15, 245, 128, 14, 15, 94, - 245, 128, 14, 15, 250, 5, 14, 15, 94, 250, 5, 14, 15, 245, 129, 14, 15, - 94, 245, 129, 14, 15, 249, 141, 14, 15, 94, 249, 141, 14, 15, 244, 254, - 14, 15, 94, 244, 254, 14, 15, 240, 212, 244, 254, 14, 15, 205, 14, 15, - 254, 52, 14, 15, 236, 58, 249, 140, 14, 15, 236, 58, 251, 155, 14, 15, - 236, 58, 251, 164, 14, 15, 236, 58, 251, 140, 14, 15, 254, 4, 14, 15, - 246, 39, 14, 15, 254, 5, 14, 15, 250, 188, 14, 15, 253, 178, 14, 15, 249, - 200, 14, 15, 242, 98, 249, 200, 14, 15, 253, 115, 14, 15, 249, 194, 14, - 15, 249, 203, 14, 15, 94, 249, 203, 14, 15, 249, 204, 14, 15, 94, 249, - 204, 14, 15, 245, 73, 14, 15, 94, 245, 73, 14, 15, 249, 205, 14, 15, 94, - 249, 205, 14, 15, 245, 74, 14, 15, 94, 245, 74, 14, 15, 249, 132, 14, 15, - 94, 249, 132, 14, 15, 245, 19, 14, 15, 94, 245, 19, 14, 15, 240, 212, - 245, 19, 14, 15, 203, 14, 15, 242, 90, 253, 251, 14, 15, 253, 167, 14, - 15, 247, 75, 14, 15, 253, 156, 14, 15, 251, 232, 14, 15, 253, 141, 14, - 15, 250, 19, 14, 15, 242, 98, 250, 19, 14, 15, 221, 14, 15, 250, 17, 14, - 15, 250, 22, 14, 15, 94, 250, 22, 14, 15, 250, 23, 14, 15, 94, 250, 23, - 14, 15, 245, 144, 14, 15, 94, 245, 144, 14, 15, 250, 24, 14, 15, 94, 250, - 24, 14, 15, 245, 145, 14, 15, 94, 245, 145, 14, 15, 249, 149, 14, 15, 94, - 249, 149, 14, 15, 245, 31, 14, 15, 94, 245, 31, 14, 15, 240, 212, 245, - 31, 14, 15, 171, 14, 15, 94, 171, 14, 15, 254, 144, 14, 15, 237, 148, - 171, 14, 15, 242, 90, 171, 14, 15, 253, 157, 14, 15, 247, 107, 14, 15, - 253, 148, 14, 15, 252, 23, 14, 15, 253, 136, 14, 15, 250, 30, 14, 15, - 242, 98, 250, 30, 14, 15, 253, 94, 14, 15, 249, 150, 14, 15, 250, 32, 14, - 15, 94, 250, 32, 14, 15, 249, 153, 14, 15, 94, 249, 153, 14, 15, 245, 32, - 14, 15, 94, 245, 32, 14, 15, 240, 212, 245, 32, 14, 15, 183, 14, 15, 44, - 253, 244, 14, 15, 254, 157, 14, 15, 253, 210, 14, 15, 247, 50, 14, 15, - 253, 211, 14, 15, 251, 196, 14, 15, 253, 184, 14, 15, 250, 12, 14, 15, - 242, 98, 250, 12, 14, 15, 253, 103, 14, 15, 250, 6, 14, 15, 250, 13, 14, - 15, 94, 250, 13, 14, 15, 250, 14, 14, 15, 94, 250, 14, 14, 15, 245, 137, - 14, 15, 94, 245, 137, 14, 15, 250, 15, 14, 15, 94, 250, 15, 14, 15, 245, - 138, 14, 15, 94, 245, 138, 14, 15, 249, 145, 14, 15, 94, 249, 145, 14, - 15, 245, 136, 14, 15, 94, 245, 136, 14, 15, 148, 14, 15, 94, 148, 14, 15, - 98, 148, 14, 15, 253, 171, 14, 15, 248, 49, 14, 15, 253, 158, 14, 15, - 252, 165, 14, 15, 253, 159, 14, 15, 250, 74, 14, 15, 242, 98, 250, 74, - 14, 15, 253, 97, 14, 15, 250, 66, 14, 15, 250, 77, 14, 15, 94, 250, 77, - 14, 15, 250, 78, 14, 15, 94, 250, 78, 14, 15, 245, 198, 14, 15, 94, 245, - 198, 14, 15, 250, 79, 14, 15, 94, 250, 79, 14, 15, 245, 199, 14, 15, 94, - 245, 199, 14, 15, 249, 163, 14, 15, 94, 249, 163, 14, 15, 245, 46, 14, - 15, 94, 245, 46, 14, 15, 240, 212, 245, 46, 14, 15, 159, 14, 15, 237, - 148, 159, 14, 15, 254, 187, 14, 15, 238, 82, 159, 14, 15, 238, 35, 254, - 182, 14, 15, 240, 212, 252, 169, 14, 15, 240, 212, 252, 151, 14, 15, 240, - 212, 248, 83, 14, 15, 240, 212, 248, 106, 14, 15, 240, 212, 248, 79, 14, - 15, 240, 212, 248, 54, 14, 15, 249, 70, 14, 15, 249, 118, 14, 15, 248, - 61, 14, 15, 249, 85, 14, 15, 248, 62, 14, 15, 249, 7, 14, 15, 245, 180, - 14, 15, 245, 189, 14, 15, 94, 245, 189, 14, 15, 245, 190, 14, 15, 94, - 245, 190, 14, 15, 242, 254, 14, 15, 94, 242, 254, 14, 15, 245, 191, 14, - 15, 94, 245, 191, 14, 15, 242, 255, 14, 15, 94, 242, 255, 14, 15, 245, - 43, 14, 15, 94, 245, 43, 14, 15, 242, 253, 14, 15, 94, 242, 253, 14, 15, - 254, 21, 14, 15, 253, 200, 14, 15, 248, 187, 14, 15, 253, 139, 14, 15, - 253, 43, 14, 15, 253, 123, 14, 15, 250, 117, 14, 15, 242, 98, 250, 117, - 14, 15, 216, 14, 15, 249, 180, 14, 15, 250, 120, 14, 15, 94, 250, 120, - 14, 15, 250, 121, 14, 15, 94, 250, 121, 14, 15, 245, 229, 14, 15, 94, - 245, 229, 14, 15, 250, 122, 14, 15, 94, 250, 122, 14, 15, 245, 230, 14, - 15, 94, 245, 230, 14, 15, 250, 119, 14, 15, 94, 250, 119, 14, 15, 245, - 52, 14, 15, 94, 245, 52, 14, 15, 240, 212, 245, 52, 14, 15, 181, 14, 15, - 237, 178, 181, 14, 15, 94, 181, 14, 15, 242, 90, 253, 139, 14, 15, 253, - 150, 14, 15, 244, 50, 253, 150, 14, 15, 94, 253, 210, 14, 15, 248, 17, - 14, 15, 253, 169, 14, 15, 252, 125, 14, 15, 253, 144, 14, 15, 252, 129, - 14, 15, 94, 253, 184, 14, 15, 253, 92, 14, 15, 249, 115, 14, 15, 94, 253, - 103, 14, 15, 245, 175, 14, 15, 94, 245, 175, 14, 15, 135, 14, 15, 94, - 135, 14, 15, 98, 135, 14, 15, 254, 40, 14, 15, 246, 128, 14, 15, 253, - 226, 14, 15, 251, 6, 14, 15, 254, 13, 14, 15, 251, 12, 14, 15, 253, 153, - 14, 15, 249, 222, 14, 15, 245, 90, 14, 15, 94, 245, 90, 14, 15, 204, 14, - 15, 249, 63, 14, 15, 242, 182, 249, 63, 14, 15, 249, 73, 14, 15, 242, - 182, 249, 73, 14, 15, 245, 48, 14, 15, 242, 182, 245, 48, 14, 15, 249, - 55, 14, 15, 245, 202, 14, 15, 249, 19, 14, 15, 245, 8, 14, 15, 243, 10, - 14, 15, 94, 243, 10, 14, 15, 253, 251, 14, 15, 248, 146, 14, 15, 248, - 147, 14, 15, 245, 213, 14, 15, 244, 195, 14, 15, 252, 218, 14, 15, 252, - 226, 14, 15, 252, 227, 14, 15, 252, 228, 14, 15, 252, 225, 14, 15, 240, - 229, 253, 125, 14, 15, 240, 229, 253, 154, 14, 15, 240, 229, 251, 73, 14, - 15, 240, 229, 253, 140, 14, 15, 240, 229, 251, 89, 14, 15, 240, 229, 253, - 88, 14, 15, 240, 229, 249, 68, 14, 15, 240, 229, 164, 14, 15, 241, 225, - 164, 14, 15, 254, 111, 14, 15, 247, 255, 14, 15, 253, 249, 14, 15, 250, - 56, 14, 15, 254, 18, 14, 15, 252, 96, 14, 15, 253, 213, 14, 15, 249, 157, - 14, 15, 209, 14, 15, 245, 206, 14, 15, 245, 207, 14, 15, 245, 208, 14, - 15, 245, 205, 14, 15, 94, 253, 150, 14, 15, 94, 253, 169, 14, 15, 94, - 253, 144, 14, 15, 94, 253, 92, 14, 15, 243, 242, 14, 15, 252, 19, 14, 15, - 247, 152, 14, 15, 249, 110, 14, 15, 247, 153, 14, 15, 249, 13, 14, 15, - 247, 144, 14, 15, 253, 244, 14, 15, 252, 31, 14, 15, 242, 90, 249, 70, - 14, 15, 242, 90, 249, 118, 14, 15, 242, 90, 249, 85, 14, 15, 242, 90, - 249, 7, 14, 15, 237, 131, 249, 63, 14, 15, 237, 131, 249, 73, 14, 15, - 237, 131, 249, 55, 14, 15, 237, 131, 249, 19, 14, 15, 237, 131, 253, 251, - 14, 15, 250, 9, 14, 15, 247, 62, 14, 15, 250, 10, 14, 15, 247, 63, 14, - 15, 249, 144, 14, 15, 247, 60, 14, 15, 254, 134, 14, 15, 240, 231, 249, - 63, 14, 15, 240, 231, 249, 73, 14, 15, 240, 231, 245, 48, 14, 15, 240, - 231, 249, 55, 14, 15, 240, 231, 245, 202, 14, 15, 240, 231, 249, 19, 14, - 15, 240, 231, 245, 8, 14, 15, 240, 231, 253, 251, 14, 15, 241, 95, 199, - 14, 15, 238, 82, 70, 14, 15, 238, 82, 69, 14, 15, 238, 82, 78, 14, 15, - 238, 82, 64, 14, 15, 238, 82, 253, 132, 14, 15, 238, 82, 253, 145, 14, - 15, 238, 82, 253, 138, 14, 15, 238, 82, 253, 98, 14, 15, 238, 82, 253, - 157, 14, 15, 238, 82, 253, 148, 14, 15, 238, 82, 253, 136, 14, 15, 238, - 82, 253, 94, 14, 15, 238, 82, 253, 134, 14, 15, 238, 82, 253, 182, 14, - 15, 238, 82, 253, 155, 14, 15, 238, 82, 208, 14, 15, 242, 90, 253, 125, - 14, 15, 242, 90, 253, 154, 14, 15, 242, 90, 253, 140, 14, 15, 242, 90, - 253, 88, 14, 15, 44, 251, 36, 14, 15, 44, 251, 35, 14, 15, 44, 249, 78, - 14, 15, 44, 246, 153, 14, 15, 44, 251, 34, 14, 15, 44, 249, 36, 14, 15, - 44, 253, 170, 14, 15, 44, 253, 144, 14, 15, 44, 253, 150, 14, 15, 44, - 250, 62, 14, 15, 44, 253, 169, 14, 15, 44, 253, 92, 14, 15, 44, 253, 216, - 14, 15, 44, 253, 138, 14, 15, 44, 253, 132, 14, 15, 44, 250, 109, 14, 15, - 44, 253, 145, 14, 15, 44, 253, 98, 14, 15, 44, 251, 99, 14, 15, 44, 251, - 98, 14, 15, 44, 251, 96, 14, 15, 44, 246, 235, 14, 15, 44, 251, 97, 14, - 15, 44, 251, 95, 14, 15, 44, 250, 87, 14, 15, 44, 249, 55, 14, 15, 44, - 249, 63, 14, 15, 44, 245, 9, 14, 15, 44, 249, 73, 14, 15, 44, 249, 19, - 14, 15, 44, 252, 219, 14, 15, 44, 250, 97, 14, 15, 44, 250, 95, 14, 15, - 44, 248, 144, 14, 15, 44, 250, 96, 14, 15, 44, 249, 22, 14, 15, 44, 253, - 231, 14, 15, 44, 253, 187, 14, 15, 44, 253, 143, 14, 15, 44, 249, 114, - 14, 15, 44, 253, 116, 14, 15, 44, 253, 90, 14, 15, 44, 198, 14, 15, 44, - 253, 196, 14, 15, 44, 253, 195, 14, 15, 44, 253, 207, 14, 15, 44, 249, - 229, 14, 15, 44, 253, 209, 14, 15, 44, 253, 100, 14, 15, 44, 251, 152, - 14, 15, 44, 250, 0, 14, 15, 44, 249, 255, 14, 15, 44, 247, 32, 14, 15, - 44, 251, 151, 14, 15, 44, 249, 24, 14, 15, 44, 251, 163, 14, 15, 44, 251, - 162, 14, 15, 44, 251, 160, 14, 15, 44, 247, 37, 14, 15, 44, 251, 161, 14, - 15, 44, 251, 159, 14, 15, 44, 254, 51, 14, 15, 44, 253, 112, 14, 15, 44, - 253, 136, 14, 15, 44, 253, 157, 14, 15, 44, 250, 26, 14, 15, 44, 253, - 148, 14, 15, 44, 253, 94, 14, 15, 44, 253, 114, 14, 15, 44, 253, 141, 14, - 15, 44, 253, 167, 14, 15, 44, 250, 18, 14, 15, 44, 253, 156, 14, 15, 44, - 221, 14, 15, 44, 253, 124, 14, 15, 44, 253, 123, 14, 15, 44, 253, 200, - 14, 15, 44, 249, 125, 14, 15, 44, 253, 139, 14, 15, 44, 216, 14, 15, 44, - 253, 241, 14, 15, 242, 90, 253, 241, 14, 15, 44, 253, 240, 14, 15, 44, - 253, 239, 14, 15, 44, 249, 104, 14, 15, 44, 253, 228, 14, 15, 242, 90, - 253, 228, 14, 15, 44, 253, 118, 14, 15, 44, 249, 250, 14, 15, 44, 249, - 249, 14, 15, 44, 251, 127, 14, 15, 44, 247, 5, 14, 15, 44, 249, 248, 14, - 15, 44, 251, 126, 14, 15, 44, 253, 229, 14, 15, 44, 253, 184, 14, 15, 44, - 253, 210, 14, 15, 44, 250, 8, 14, 15, 44, 253, 211, 14, 15, 44, 253, 103, - 14, 15, 44, 250, 224, 14, 15, 44, 250, 223, 14, 15, 44, 250, 221, 14, 15, - 44, 246, 111, 14, 15, 44, 250, 222, 14, 15, 44, 249, 214, 14, 15, 44, - 251, 194, 14, 15, 44, 250, 10, 14, 15, 44, 251, 193, 14, 15, 44, 247, 61, - 14, 15, 44, 250, 9, 14, 15, 44, 249, 144, 14, 15, 44, 248, 134, 14, 15, - 44, 245, 208, 14, 15, 44, 245, 206, 14, 15, 44, 244, 122, 14, 15, 44, - 245, 207, 14, 15, 44, 245, 205, 14, 15, 44, 250, 93, 14, 15, 44, 250, 92, - 14, 15, 44, 250, 90, 14, 15, 44, 248, 133, 14, 15, 44, 250, 91, 14, 15, - 44, 250, 89, 14, 15, 44, 253, 233, 14, 15, 44, 253, 190, 14, 15, 44, 253, - 189, 14, 15, 44, 249, 126, 14, 15, 44, 253, 218, 14, 15, 44, 253, 129, - 14, 15, 44, 202, 14, 15, 44, 46, 202, 14, 15, 44, 250, 240, 14, 15, 44, - 250, 239, 14, 15, 44, 249, 76, 14, 15, 44, 246, 119, 14, 15, 44, 250, - 238, 14, 15, 44, 249, 100, 14, 15, 44, 253, 172, 14, 15, 44, 253, 159, - 14, 15, 44, 253, 171, 14, 15, 44, 249, 117, 14, 15, 44, 253, 158, 14, 15, - 44, 253, 97, 14, 15, 44, 249, 162, 14, 15, 44, 249, 85, 14, 15, 44, 249, - 70, 14, 15, 44, 245, 182, 14, 15, 44, 249, 118, 14, 15, 44, 249, 7, 14, - 15, 44, 254, 21, 14, 15, 44, 249, 171, 14, 15, 44, 249, 170, 14, 15, 44, - 249, 64, 14, 15, 44, 245, 210, 14, 15, 44, 249, 169, 14, 15, 44, 249, 56, - 14, 15, 44, 249, 131, 14, 15, 44, 249, 94, 14, 15, 44, 249, 44, 14, 15, - 44, 244, 246, 14, 15, 44, 249, 23, 14, 15, 44, 249, 11, 14, 15, 44, 248, - 152, 14, 15, 44, 248, 151, 14, 15, 44, 248, 149, 14, 15, 44, 244, 126, - 14, 15, 44, 248, 150, 14, 15, 44, 248, 148, 14, 15, 254, 31, 57, 14, 15, - 213, 189, 14, 15, 250, 54, 14, 15, 247, 145, 14, 15, 247, 177, 14, 15, - 244, 0, 14, 15, 247, 178, 14, 15, 244, 1, 14, 15, 247, 176, 14, 15, 243, - 255, 244, 174, 248, 81, 65, 244, 174, 1, 243, 43, 244, 174, 1, 247, 69, - 244, 174, 1, 243, 107, 244, 174, 1, 248, 50, 244, 174, 1, 247, 160, 244, - 174, 1, 248, 161, 244, 174, 1, 246, 80, 244, 174, 1, 244, 120, 244, 174, - 1, 246, 73, 244, 174, 1, 243, 58, 244, 174, 1, 247, 101, 244, 174, 1, - 246, 159, 244, 174, 1, 240, 125, 244, 174, 1, 242, 22, 244, 174, 1, 248, - 42, 244, 174, 1, 245, 239, 244, 174, 1, 250, 38, 244, 174, 1, 254, 198, - 244, 174, 1, 240, 62, 244, 174, 1, 240, 93, 244, 174, 1, 240, 61, 244, - 174, 1, 253, 186, 244, 174, 1, 239, 106, 244, 174, 1, 246, 249, 244, 174, - 1, 236, 127, 244, 174, 1, 244, 30, 244, 174, 241, 54, 65, 244, 174, 224, - 241, 54, 65, 100, 1, 251, 1, 251, 3, 255, 7, 204, 100, 1, 186, 100, 1, - 252, 245, 255, 25, 84, 100, 1, 254, 80, 100, 1, 181, 100, 1, 201, 100, 1, - 240, 182, 248, 125, 242, 189, 100, 1, 249, 77, 100, 1, 245, 247, 64, 100, - 1, 255, 18, 78, 100, 1, 255, 1, 64, 100, 1, 245, 237, 100, 1, 235, 178, - 78, 100, 1, 235, 228, 78, 100, 1, 78, 100, 1, 253, 142, 100, 1, 253, 246, - 100, 1, 248, 18, 254, 20, 252, 120, 135, 100, 1, 243, 185, 100, 1, 250, - 181, 100, 1, 251, 144, 205, 100, 1, 194, 100, 1, 249, 66, 100, 1, 251, - 29, 251, 55, 194, 100, 1, 251, 25, 100, 1, 248, 175, 253, 22, 201, 100, - 1, 243, 140, 164, 100, 1, 246, 169, 164, 100, 1, 231, 254, 164, 100, 1, - 232, 11, 164, 100, 1, 243, 235, 254, 162, 252, 0, 183, 100, 1, 235, 184, - 183, 100, 1, 239, 5, 100, 1, 251, 115, 255, 10, 254, 118, 69, 100, 1, 70, - 100, 1, 247, 1, 200, 100, 1, 251, 30, 100, 1, 235, 222, 253, 163, 100, 1, - 236, 32, 64, 100, 1, 251, 116, 250, 245, 100, 1, 244, 33, 244, 32, 198, - 100, 1, 245, 243, 243, 101, 100, 1, 244, 94, 159, 100, 1, 248, 75, 235, - 179, 159, 100, 1, 235, 229, 159, 100, 1, 203, 100, 1, 202, 100, 1, 248, - 132, 254, 193, 254, 195, 190, 100, 1, 235, 230, 190, 100, 1, 187, 100, 1, - 240, 7, 246, 23, 241, 115, 199, 100, 1, 232, 1, 199, 100, 1, 239, 6, 100, - 1, 241, 228, 100, 1, 246, 121, 255, 5, 70, 100, 1, 243, 212, 254, 55, - 171, 100, 1, 234, 54, 171, 100, 1, 235, 183, 171, 100, 1, 243, 201, 251, - 181, 251, 203, 148, 100, 1, 239, 4, 100, 1, 241, 185, 100, 1, 251, 111, - 100, 1, 246, 78, 250, 204, 187, 100, 1, 241, 231, 246, 125, 78, 100, 1, - 249, 218, 100, 1, 251, 113, 100, 1, 240, 22, 100, 1, 246, 40, 100, 1, - 243, 57, 100, 1, 248, 103, 100, 1, 235, 180, 100, 1, 235, 231, 100, 1, - 236, 22, 100, 1, 209, 100, 1, 170, 100, 242, 66, 236, 52, 100, 240, 120, - 236, 52, 100, 244, 234, 236, 52, 100, 243, 34, 90, 100, 240, 187, 90, - 100, 240, 6, 90, 240, 209, 1, 64, 240, 209, 1, 69, 240, 209, 1, 84, 240, - 209, 1, 208, 240, 209, 1, 253, 100, 240, 209, 1, 249, 13, 240, 209, 1, - 253, 91, 240, 209, 1, 253, 93, 240, 209, 1, 253, 94, 240, 209, 1, 253, - 90, 240, 209, 1, 253, 110, 240, 209, 1, 221, 240, 209, 1, 216, 240, 209, - 1, 253, 103, 240, 209, 1, 253, 98, 240, 209, 1, 253, 97, 240, 209, 1, - 253, 88, 240, 209, 38, 25, 69, 240, 209, 38, 25, 84, 240, 209, 25, 240, - 220, 240, 206, 1, 64, 240, 206, 1, 69, 240, 206, 1, 84, 240, 206, 1, 208, - 240, 206, 1, 253, 100, 240, 206, 1, 249, 13, 240, 206, 1, 253, 91, 240, - 206, 1, 253, 93, 240, 206, 1, 253, 94, 240, 206, 1, 253, 90, 240, 206, 1, - 253, 110, 240, 206, 1, 221, 240, 206, 1, 216, 240, 206, 1, 253, 92, 240, - 206, 1, 253, 103, 240, 206, 1, 253, 98, 240, 206, 1, 253, 97, 240, 206, - 1, 253, 88, 240, 206, 38, 25, 69, 240, 206, 38, 25, 84, 240, 206, 25, - 239, 58, 237, 162, 242, 66, 236, 52, 237, 162, 42, 236, 52, 244, 179, 1, - 64, 244, 179, 1, 69, 244, 179, 1, 84, 244, 179, 1, 208, 244, 179, 1, 253, - 100, 244, 179, 1, 249, 13, 244, 179, 1, 253, 91, 244, 179, 1, 253, 93, - 244, 179, 1, 253, 94, 244, 179, 1, 253, 90, 244, 179, 1, 253, 110, 244, - 179, 1, 221, 244, 179, 1, 216, 244, 179, 1, 253, 92, 244, 179, 1, 253, - 103, 244, 179, 1, 253, 98, 244, 179, 1, 253, 97, 244, 179, 1, 253, 88, - 244, 179, 38, 25, 69, 244, 179, 38, 25, 84, 239, 122, 1, 64, 239, 122, 1, - 69, 239, 122, 1, 84, 239, 122, 1, 208, 239, 122, 1, 253, 100, 239, 122, - 1, 249, 13, 239, 122, 1, 253, 91, 239, 122, 1, 253, 93, 239, 122, 1, 253, - 94, 239, 122, 1, 253, 90, 239, 122, 1, 253, 110, 239, 122, 1, 221, 239, - 122, 1, 216, 239, 122, 1, 253, 103, 239, 122, 1, 253, 98, 239, 122, 1, - 253, 97, 239, 122, 38, 25, 69, 239, 122, 38, 25, 84, 74, 1, 208, 74, 1, - 249, 24, 74, 1, 253, 155, 74, 1, 250, 0, 74, 1, 249, 110, 74, 1, 253, - 115, 74, 1, 249, 11, 74, 1, 253, 178, 74, 1, 249, 94, 74, 1, 249, 84, 74, - 1, 253, 93, 74, 1, 244, 195, 74, 1, 253, 193, 74, 1, 245, 213, 74, 1, - 252, 32, 74, 1, 253, 91, 74, 1, 249, 19, 74, 1, 76, 74, 1, 249, 55, 74, - 1, 253, 136, 74, 1, 253, 110, 74, 1, 249, 29, 74, 1, 253, 187, 74, 1, - 250, 44, 74, 1, 253, 141, 74, 1, 253, 123, 74, 1, 253, 144, 74, 1, 253, - 184, 74, 1, 253, 215, 74, 1, 249, 7, 74, 1, 250, 76, 74, 1, 253, 97, 74, - 1, 253, 88, 74, 1, 253, 103, 74, 1, 253, 213, 74, 236, 183, 38, 252, 83, - 74, 236, 183, 38, 249, 157, 74, 236, 183, 38, 253, 249, 74, 236, 183, 38, - 250, 56, 74, 236, 183, 38, 254, 19, 74, 236, 183, 38, 252, 102, 74, 236, - 183, 38, 250, 59, 74, 236, 183, 38, 248, 13, 74, 236, 183, 38, 254, 70, - 74, 236, 183, 38, 252, 150, 74, 236, 183, 38, 254, 54, 74, 236, 183, 38, - 251, 216, 74, 236, 183, 38, 254, 67, 74, 236, 183, 38, 250, 54, 74, 236, - 183, 38, 254, 68, 249, 173, 121, 74, 236, 183, 38, 254, 68, 249, 173, - 114, 74, 236, 183, 38, 252, 84, 74, 38, 239, 217, 254, 84, 74, 38, 239, - 217, 253, 95, 74, 38, 25, 253, 95, 74, 38, 25, 69, 74, 38, 25, 253, 96, - 74, 38, 25, 181, 74, 38, 25, 254, 26, 74, 38, 25, 84, 74, 38, 25, 253, - 104, 74, 38, 25, 254, 196, 74, 38, 25, 253, 142, 74, 38, 25, 216, 74, 38, - 25, 253, 181, 74, 38, 25, 70, 74, 38, 25, 253, 163, 74, 38, 25, 253, 106, - 74, 38, 25, 253, 119, 74, 38, 25, 253, 109, 74, 25, 240, 126, 74, 25, - 240, 151, 74, 25, 235, 234, 74, 25, 236, 145, 74, 25, 240, 186, 74, 25, - 241, 109, 74, 25, 244, 62, 74, 25, 236, 175, 74, 25, 240, 97, 74, 25, - 243, 27, 74, 25, 244, 70, 241, 254, 74, 25, 242, 52, 74, 25, 243, 72, 74, - 25, 236, 248, 74, 25, 247, 31, 74, 25, 236, 247, 74, 25, 243, 55, 254, - 169, 247, 43, 74, 25, 254, 133, 249, 167, 74, 25, 241, 113, 74, 25, 244, - 35, 247, 100, 74, 25, 240, 101, 74, 239, 147, 13, 248, 22, 74, 25, 235, - 211, 74, 27, 244, 173, 74, 27, 121, 74, 27, 114, 74, 27, 153, 74, 27, - 163, 74, 27, 168, 74, 27, 169, 74, 27, 179, 74, 27, 176, 74, 27, 178, 51, - 243, 45, 51, 238, 96, 51, 242, 84, 51, 213, 189, 51, 242, 81, 51, 249, - 28, 244, 215, 51, 249, 1, 249, 119, 240, 241, 51, 249, 8, 4, 240, 9, 241, - 205, 51, 242, 68, 242, 84, 51, 242, 68, 213, 189, 51, 241, 221, 51, 249, - 135, 238, 79, 239, 195, 121, 51, 249, 135, 238, 79, 239, 195, 114, 51, - 249, 135, 238, 79, 239, 195, 153, 51, 38, 237, 114, 51, 27, 244, 173, 51, - 27, 121, 51, 27, 114, 51, 27, 153, 51, 27, 163, 51, 27, 168, 51, 27, 169, - 51, 27, 179, 51, 27, 176, 51, 27, 178, 51, 1, 64, 51, 1, 70, 51, 1, 69, - 51, 1, 78, 51, 1, 84, 51, 1, 253, 142, 51, 1, 253, 253, 51, 1, 253, 126, - 51, 1, 253, 94, 51, 1, 249, 75, 51, 1, 253, 110, 51, 1, 253, 90, 51, 1, - 253, 213, 51, 1, 253, 100, 51, 1, 221, 51, 1, 253, 103, 51, 1, 253, 97, - 51, 1, 249, 7, 51, 1, 253, 91, 51, 1, 253, 93, 51, 1, 249, 11, 51, 1, - 253, 118, 51, 1, 216, 51, 1, 253, 92, 51, 1, 253, 98, 51, 1, 253, 153, - 51, 1, 208, 51, 1, 249, 24, 51, 1, 249, 56, 51, 1, 253, 129, 51, 1, 249, - 68, 51, 1, 253, 72, 51, 1, 249, 144, 51, 1, 250, 125, 51, 1, 249, 23, 51, - 1, 249, 1, 165, 38, 57, 51, 1, 249, 1, 70, 51, 1, 249, 1, 69, 51, 1, 249, - 1, 78, 51, 1, 249, 1, 84, 51, 1, 249, 1, 253, 142, 51, 1, 249, 1, 253, - 253, 51, 1, 249, 1, 249, 75, 51, 1, 249, 1, 253, 110, 51, 1, 249, 1, 253, - 90, 51, 1, 249, 1, 253, 213, 51, 1, 249, 1, 253, 100, 51, 1, 249, 1, 221, - 51, 1, 249, 1, 253, 91, 51, 1, 249, 1, 253, 93, 51, 1, 249, 1, 249, 11, - 51, 1, 249, 1, 253, 118, 51, 1, 249, 1, 249, 56, 51, 1, 249, 1, 216, 51, - 1, 249, 1, 253, 98, 51, 1, 249, 1, 208, 51, 1, 249, 1, 249, 136, 51, 1, - 249, 1, 249, 68, 51, 1, 249, 1, 251, 121, 51, 1, 249, 1, 252, 21, 51, 1, - 249, 1, 249, 100, 51, 1, 249, 8, 70, 51, 1, 249, 8, 69, 51, 1, 249, 8, - 254, 122, 51, 1, 249, 8, 253, 253, 51, 1, 249, 8, 84, 51, 1, 249, 8, 249, - 75, 51, 1, 249, 8, 208, 51, 1, 249, 8, 253, 100, 51, 1, 249, 8, 253, 88, - 51, 1, 249, 8, 253, 90, 51, 1, 249, 8, 249, 7, 51, 1, 249, 8, 253, 91, - 51, 1, 249, 8, 253, 93, 51, 1, 249, 8, 253, 118, 51, 1, 249, 8, 253, 153, - 51, 1, 249, 8, 249, 136, 51, 1, 249, 8, 249, 68, 51, 1, 249, 8, 249, 56, - 51, 1, 249, 8, 253, 129, 51, 1, 249, 8, 249, 115, 51, 1, 249, 8, 249, 11, - 51, 1, 249, 8, 249, 52, 51, 1, 242, 68, 69, 51, 1, 242, 68, 208, 51, 1, - 242, 68, 253, 92, 51, 1, 242, 68, 253, 153, 51, 1, 242, 68, 249, 52, 51, - 1, 192, 195, 239, 252, 121, 51, 1, 192, 195, 242, 53, 121, 51, 1, 192, - 195, 241, 134, 51, 1, 192, 195, 239, 244, 51, 1, 192, 195, 239, 116, 239, - 244, 51, 1, 192, 195, 241, 40, 51, 1, 192, 195, 244, 171, 241, 40, 51, 1, - 192, 195, 64, 51, 1, 192, 195, 69, 51, 1, 192, 195, 208, 51, 1, 192, 195, - 249, 13, 51, 1, 192, 195, 253, 115, 51, 1, 192, 195, 249, 22, 51, 1, 192, - 195, 244, 195, 51, 1, 192, 195, 249, 27, 51, 1, 192, 195, 249, 37, 51, 1, - 192, 195, 253, 91, 51, 1, 192, 195, 253, 93, 51, 1, 192, 195, 253, 90, - 51, 1, 192, 195, 249, 29, 51, 1, 192, 195, 249, 34, 51, 1, 192, 195, 249, - 52, 51, 1, 192, 195, 253, 129, 51, 1, 192, 195, 253, 219, 51, 1, 249, 1, - 192, 195, 253, 91, 51, 1, 249, 1, 192, 195, 249, 52, 51, 1, 242, 68, 192, - 195, 249, 36, 51, 1, 242, 68, 192, 195, 249, 13, 51, 1, 242, 68, 192, - 195, 253, 115, 51, 1, 242, 68, 192, 195, 249, 45, 51, 1, 242, 68, 192, - 195, 249, 22, 51, 1, 242, 68, 192, 195, 244, 200, 51, 1, 242, 68, 192, - 195, 253, 91, 51, 1, 242, 68, 192, 195, 249, 40, 51, 1, 242, 68, 192, - 195, 249, 34, 51, 1, 242, 68, 192, 195, 250, 199, 51, 1, 242, 68, 192, - 195, 249, 52, 51, 1, 242, 68, 192, 195, 253, 129, 51, 1, 192, 195, 136, - 84, 51, 1, 192, 195, 136, 216, 51, 1, 242, 68, 192, 195, 249, 39, 51, 1, - 192, 195, 240, 23, 9, 5, 1, 119, 2, 249, 9, 45, 9, 3, 1, 119, 2, 249, 9, - 45, 9, 5, 1, 255, 41, 2, 49, 47, 9, 3, 1, 255, 41, 2, 49, 47, 9, 5, 1, - 255, 41, 2, 49, 45, 9, 3, 1, 255, 41, 2, 49, 45, 9, 5, 1, 255, 41, 2, - 217, 45, 9, 3, 1, 255, 41, 2, 217, 45, 9, 5, 1, 255, 36, 2, 240, 250, 18, - 116, 9, 3, 1, 255, 36, 2, 240, 250, 18, 116, 9, 5, 1, 255, 34, 2, 49, 47, - 9, 3, 1, 255, 34, 2, 49, 47, 9, 5, 1, 255, 34, 2, 49, 45, 9, 3, 1, 255, - 34, 2, 49, 45, 9, 5, 1, 255, 34, 2, 217, 45, 9, 3, 1, 255, 34, 2, 217, - 45, 9, 5, 1, 255, 34, 2, 239, 117, 9, 3, 1, 255, 34, 2, 239, 117, 9, 5, - 1, 255, 34, 2, 157, 45, 9, 3, 1, 255, 34, 2, 157, 45, 9, 5, 1, 144, 2, - 242, 101, 18, 158, 9, 3, 1, 144, 2, 242, 101, 18, 158, 9, 5, 1, 144, 2, - 242, 101, 18, 116, 9, 3, 1, 144, 2, 242, 101, 18, 116, 9, 5, 1, 144, 2, - 157, 45, 9, 3, 1, 144, 2, 157, 45, 9, 5, 1, 144, 2, 229, 45, 9, 3, 1, - 144, 2, 229, 45, 9, 5, 1, 144, 2, 240, 250, 18, 212, 9, 3, 1, 144, 2, - 240, 250, 18, 212, 9, 5, 1, 255, 42, 2, 49, 47, 9, 3, 1, 255, 42, 2, 49, - 47, 9, 5, 1, 255, 32, 2, 166, 9, 3, 1, 255, 32, 2, 166, 9, 5, 1, 255, 37, - 2, 49, 47, 9, 3, 1, 255, 37, 2, 49, 47, 9, 5, 1, 255, 37, 2, 49, 45, 9, - 3, 1, 255, 37, 2, 49, 45, 9, 5, 1, 255, 37, 2, 150, 9, 3, 1, 255, 37, 2, - 150, 9, 5, 1, 255, 37, 2, 239, 117, 9, 3, 1, 255, 37, 2, 239, 117, 9, 5, - 1, 255, 37, 2, 244, 194, 45, 9, 3, 1, 255, 37, 2, 244, 194, 45, 9, 5, 1, - 197, 2, 229, 45, 9, 3, 1, 197, 2, 229, 45, 9, 5, 1, 197, 2, 238, 81, 18, - 116, 9, 3, 1, 197, 2, 238, 81, 18, 116, 9, 5, 1, 255, 38, 2, 116, 9, 3, - 1, 255, 38, 2, 116, 9, 5, 1, 255, 38, 2, 49, 45, 9, 3, 1, 255, 38, 2, 49, - 45, 9, 5, 1, 255, 38, 2, 217, 45, 9, 3, 1, 255, 38, 2, 217, 45, 9, 5, 1, - 255, 31, 2, 49, 45, 9, 3, 1, 255, 31, 2, 49, 45, 9, 5, 1, 255, 31, 2, 49, - 244, 188, 18, 166, 9, 3, 1, 255, 31, 2, 49, 244, 188, 18, 166, 9, 5, 1, - 255, 31, 2, 217, 45, 9, 3, 1, 255, 31, 2, 217, 45, 9, 5, 1, 255, 31, 2, - 157, 45, 9, 3, 1, 255, 31, 2, 157, 45, 9, 5, 1, 255, 39, 2, 116, 9, 3, 1, - 255, 39, 2, 116, 9, 5, 1, 255, 39, 2, 49, 47, 9, 3, 1, 255, 39, 2, 49, - 47, 9, 5, 1, 255, 39, 2, 49, 45, 9, 3, 1, 255, 39, 2, 49, 45, 9, 5, 1, - 255, 28, 2, 49, 47, 9, 3, 1, 255, 28, 2, 49, 47, 9, 5, 1, 255, 28, 2, 49, - 45, 9, 3, 1, 255, 28, 2, 49, 45, 9, 5, 1, 255, 28, 2, 217, 45, 9, 3, 1, - 255, 28, 2, 217, 45, 9, 5, 1, 255, 28, 2, 157, 45, 9, 3, 1, 255, 28, 2, - 157, 45, 9, 5, 1, 109, 2, 229, 18, 116, 9, 3, 1, 109, 2, 229, 18, 116, 9, - 5, 1, 109, 2, 229, 18, 150, 9, 3, 1, 109, 2, 229, 18, 150, 9, 5, 1, 109, - 2, 242, 101, 18, 158, 9, 3, 1, 109, 2, 242, 101, 18, 158, 9, 5, 1, 109, - 2, 242, 101, 18, 116, 9, 3, 1, 109, 2, 242, 101, 18, 116, 9, 5, 1, 255, - 46, 2, 116, 9, 3, 1, 255, 46, 2, 116, 9, 5, 1, 255, 46, 2, 49, 47, 9, 3, - 1, 255, 46, 2, 49, 47, 9, 5, 1, 255, 30, 2, 49, 47, 9, 3, 1, 255, 30, 2, - 49, 47, 9, 5, 1, 255, 30, 2, 49, 45, 9, 3, 1, 255, 30, 2, 49, 45, 9, 5, - 1, 255, 30, 2, 49, 244, 188, 18, 166, 9, 3, 1, 255, 30, 2, 49, 244, 188, - 18, 166, 9, 5, 1, 255, 30, 2, 217, 45, 9, 3, 1, 255, 30, 2, 217, 45, 9, - 5, 1, 255, 29, 2, 49, 47, 9, 3, 1, 255, 29, 2, 49, 47, 9, 5, 1, 255, 29, - 2, 49, 45, 9, 3, 1, 255, 29, 2, 49, 45, 9, 5, 1, 255, 29, 2, 244, 196, - 18, 49, 47, 9, 3, 1, 255, 29, 2, 244, 196, 18, 49, 47, 9, 5, 1, 255, 29, - 2, 245, 15, 18, 49, 47, 9, 3, 1, 255, 29, 2, 245, 15, 18, 49, 47, 9, 5, - 1, 255, 29, 2, 49, 244, 188, 18, 49, 47, 9, 3, 1, 255, 29, 2, 49, 244, - 188, 18, 49, 47, 9, 5, 1, 255, 33, 2, 49, 47, 9, 3, 1, 255, 33, 2, 49, - 47, 9, 5, 1, 255, 33, 2, 49, 45, 9, 3, 1, 255, 33, 2, 49, 45, 9, 5, 1, - 255, 33, 2, 217, 45, 9, 3, 1, 255, 33, 2, 217, 45, 9, 5, 1, 255, 33, 2, - 157, 45, 9, 3, 1, 255, 33, 2, 157, 45, 9, 5, 1, 115, 2, 238, 81, 45, 9, - 3, 1, 115, 2, 238, 81, 45, 9, 5, 1, 115, 2, 229, 45, 9, 3, 1, 115, 2, - 229, 45, 9, 5, 1, 115, 2, 157, 45, 9, 3, 1, 115, 2, 157, 45, 9, 5, 1, - 115, 2, 229, 18, 116, 9, 3, 1, 115, 2, 229, 18, 116, 9, 5, 1, 115, 2, - 242, 101, 18, 150, 9, 3, 1, 115, 2, 242, 101, 18, 150, 9, 5, 1, 255, 44, - 2, 180, 9, 3, 1, 255, 44, 2, 180, 9, 5, 1, 255, 44, 2, 49, 45, 9, 3, 1, - 255, 44, 2, 49, 45, 9, 5, 1, 255, 40, 2, 158, 9, 3, 1, 255, 40, 2, 158, - 9, 5, 1, 255, 40, 2, 116, 9, 3, 1, 255, 40, 2, 116, 9, 5, 1, 255, 40, 2, - 150, 9, 3, 1, 255, 40, 2, 150, 9, 5, 1, 255, 40, 2, 49, 47, 9, 3, 1, 255, - 40, 2, 49, 47, 9, 5, 1, 255, 40, 2, 49, 45, 9, 3, 1, 255, 40, 2, 49, 45, - 9, 5, 1, 255, 43, 2, 49, 47, 9, 3, 1, 255, 43, 2, 49, 47, 9, 5, 1, 255, - 43, 2, 150, 9, 3, 1, 255, 43, 2, 150, 9, 5, 1, 255, 35, 2, 49, 47, 9, 3, - 1, 255, 35, 2, 49, 47, 9, 5, 1, 255, 27, 2, 236, 180, 9, 3, 1, 255, 27, - 2, 236, 180, 9, 5, 1, 255, 27, 2, 49, 45, 9, 3, 1, 255, 27, 2, 49, 45, 9, - 5, 1, 255, 27, 2, 217, 45, 9, 3, 1, 255, 27, 2, 217, 45, 9, 3, 1, 255, - 37, 2, 217, 45, 9, 3, 1, 255, 33, 2, 150, 9, 3, 1, 255, 40, 2, 249, 9, - 47, 9, 3, 1, 255, 35, 2, 249, 9, 47, 9, 3, 1, 119, 2, 37, 136, 244, 183, - 9, 3, 1, 165, 255, 29, 2, 49, 47, 9, 5, 1, 119, 2, 49, 45, 9, 3, 1, 119, - 2, 49, 45, 9, 5, 1, 119, 2, 248, 255, 47, 9, 3, 1, 119, 2, 248, 255, 47, - 9, 5, 1, 119, 2, 157, 18, 116, 9, 3, 1, 119, 2, 157, 18, 116, 9, 5, 1, - 119, 2, 157, 18, 158, 9, 3, 1, 119, 2, 157, 18, 158, 9, 5, 1, 119, 2, - 157, 18, 248, 255, 47, 9, 3, 1, 119, 2, 157, 18, 248, 255, 47, 9, 5, 1, - 119, 2, 157, 18, 180, 9, 3, 1, 119, 2, 157, 18, 180, 9, 5, 1, 119, 2, - 157, 18, 49, 45, 9, 3, 1, 119, 2, 157, 18, 49, 45, 9, 5, 1, 119, 2, 244, - 194, 18, 116, 9, 3, 1, 119, 2, 244, 194, 18, 116, 9, 5, 1, 119, 2, 244, - 194, 18, 158, 9, 3, 1, 119, 2, 244, 194, 18, 158, 9, 5, 1, 119, 2, 244, - 194, 18, 248, 255, 47, 9, 3, 1, 119, 2, 244, 194, 18, 248, 255, 47, 9, 5, - 1, 119, 2, 244, 194, 18, 180, 9, 3, 1, 119, 2, 244, 194, 18, 180, 9, 5, - 1, 119, 2, 244, 194, 18, 49, 45, 9, 3, 1, 119, 2, 244, 194, 18, 49, 45, - 9, 5, 1, 144, 2, 49, 45, 9, 3, 1, 144, 2, 49, 45, 9, 5, 1, 144, 2, 248, - 255, 47, 9, 3, 1, 144, 2, 248, 255, 47, 9, 5, 1, 144, 2, 180, 9, 3, 1, - 144, 2, 180, 9, 5, 1, 144, 2, 157, 18, 116, 9, 3, 1, 144, 2, 157, 18, - 116, 9, 5, 1, 144, 2, 157, 18, 158, 9, 3, 1, 144, 2, 157, 18, 158, 9, 5, - 1, 144, 2, 157, 18, 248, 255, 47, 9, 3, 1, 144, 2, 157, 18, 248, 255, 47, - 9, 5, 1, 144, 2, 157, 18, 180, 9, 3, 1, 144, 2, 157, 18, 180, 9, 5, 1, - 144, 2, 157, 18, 49, 45, 9, 3, 1, 144, 2, 157, 18, 49, 45, 9, 5, 1, 197, - 2, 248, 255, 47, 9, 3, 1, 197, 2, 248, 255, 47, 9, 5, 1, 197, 2, 49, 45, - 9, 3, 1, 197, 2, 49, 45, 9, 5, 1, 109, 2, 49, 45, 9, 3, 1, 109, 2, 49, - 45, 9, 5, 1, 109, 2, 248, 255, 47, 9, 3, 1, 109, 2, 248, 255, 47, 9, 5, - 1, 109, 2, 157, 18, 116, 9, 3, 1, 109, 2, 157, 18, 116, 9, 5, 1, 109, 2, - 157, 18, 158, 9, 3, 1, 109, 2, 157, 18, 158, 9, 5, 1, 109, 2, 157, 18, - 248, 255, 47, 9, 3, 1, 109, 2, 157, 18, 248, 255, 47, 9, 5, 1, 109, 2, - 157, 18, 180, 9, 3, 1, 109, 2, 157, 18, 180, 9, 5, 1, 109, 2, 157, 18, - 49, 45, 9, 3, 1, 109, 2, 157, 18, 49, 45, 9, 5, 1, 109, 2, 249, 12, 18, - 116, 9, 3, 1, 109, 2, 249, 12, 18, 116, 9, 5, 1, 109, 2, 249, 12, 18, - 158, 9, 3, 1, 109, 2, 249, 12, 18, 158, 9, 5, 1, 109, 2, 249, 12, 18, - 248, 255, 47, 9, 3, 1, 109, 2, 249, 12, 18, 248, 255, 47, 9, 5, 1, 109, - 2, 249, 12, 18, 180, 9, 3, 1, 109, 2, 249, 12, 18, 180, 9, 5, 1, 109, 2, - 249, 12, 18, 49, 45, 9, 3, 1, 109, 2, 249, 12, 18, 49, 45, 9, 5, 1, 115, - 2, 49, 45, 9, 3, 1, 115, 2, 49, 45, 9, 5, 1, 115, 2, 248, 255, 47, 9, 3, - 1, 115, 2, 248, 255, 47, 9, 5, 1, 115, 2, 249, 12, 18, 116, 9, 3, 1, 115, - 2, 249, 12, 18, 116, 9, 5, 1, 115, 2, 249, 12, 18, 158, 9, 3, 1, 115, 2, - 249, 12, 18, 158, 9, 5, 1, 115, 2, 249, 12, 18, 248, 255, 47, 9, 3, 1, - 115, 2, 249, 12, 18, 248, 255, 47, 9, 5, 1, 115, 2, 249, 12, 18, 180, 9, - 3, 1, 115, 2, 249, 12, 18, 180, 9, 5, 1, 115, 2, 249, 12, 18, 49, 45, 9, - 3, 1, 115, 2, 249, 12, 18, 49, 45, 9, 5, 1, 255, 35, 2, 158, 9, 3, 1, - 255, 35, 2, 158, 9, 5, 1, 255, 35, 2, 49, 45, 9, 3, 1, 255, 35, 2, 49, - 45, 9, 5, 1, 255, 35, 2, 248, 255, 47, 9, 3, 1, 255, 35, 2, 248, 255, 47, - 9, 5, 1, 255, 35, 2, 180, 9, 3, 1, 255, 35, 2, 180, 26, 3, 1, 162, 2, - 242, 78, 26, 3, 1, 162, 2, 242, 74, 26, 3, 1, 162, 2, 138, 18, 174, 26, - 3, 1, 162, 2, 130, 18, 174, 26, 3, 1, 162, 2, 138, 18, 173, 26, 3, 1, - 162, 2, 130, 18, 173, 26, 3, 1, 162, 2, 138, 18, 236, 43, 26, 3, 1, 162, - 2, 130, 18, 236, 43, 26, 5, 1, 162, 2, 242, 78, 26, 5, 1, 162, 2, 242, - 74, 26, 5, 1, 162, 2, 138, 18, 174, 26, 5, 1, 162, 2, 130, 18, 174, 26, - 5, 1, 162, 2, 138, 18, 173, 26, 5, 1, 162, 2, 130, 18, 173, 26, 5, 1, - 162, 2, 138, 18, 236, 43, 26, 5, 1, 162, 2, 130, 18, 236, 43, 26, 3, 1, - 240, 204, 2, 242, 78, 26, 3, 1, 240, 204, 2, 242, 74, 26, 3, 1, 240, 204, - 2, 138, 18, 174, 26, 3, 1, 240, 204, 2, 130, 18, 174, 26, 3, 1, 240, 204, - 2, 138, 18, 173, 26, 3, 1, 240, 204, 2, 130, 18, 173, 26, 5, 1, 240, 204, - 2, 242, 78, 26, 5, 1, 240, 204, 2, 242, 74, 26, 5, 1, 240, 204, 2, 138, - 18, 174, 26, 5, 1, 240, 204, 2, 130, 18, 174, 26, 5, 1, 240, 204, 2, 138, - 18, 173, 26, 5, 1, 240, 204, 2, 130, 18, 173, 26, 3, 1, 182, 2, 242, 78, - 26, 3, 1, 182, 2, 242, 74, 26, 3, 1, 182, 2, 138, 18, 174, 26, 3, 1, 182, - 2, 130, 18, 174, 26, 3, 1, 182, 2, 138, 18, 173, 26, 3, 1, 182, 2, 130, - 18, 173, 26, 3, 1, 182, 2, 138, 18, 236, 43, 26, 3, 1, 182, 2, 130, 18, - 236, 43, 26, 5, 1, 182, 2, 242, 78, 26, 5, 1, 182, 2, 242, 74, 26, 5, 1, - 182, 2, 138, 18, 174, 26, 5, 1, 182, 2, 130, 18, 174, 26, 5, 1, 182, 2, - 138, 18, 173, 26, 5, 1, 182, 2, 130, 18, 173, 26, 5, 1, 182, 2, 138, 18, - 236, 43, 26, 5, 1, 182, 2, 130, 18, 236, 43, 26, 3, 1, 228, 2, 242, 78, - 26, 3, 1, 228, 2, 242, 74, 26, 3, 1, 228, 2, 138, 18, 174, 26, 3, 1, 228, - 2, 130, 18, 174, 26, 3, 1, 228, 2, 138, 18, 173, 26, 3, 1, 228, 2, 130, - 18, 173, 26, 3, 1, 228, 2, 138, 18, 236, 43, 26, 3, 1, 228, 2, 130, 18, - 236, 43, 26, 5, 1, 228, 2, 242, 78, 26, 5, 1, 228, 2, 242, 74, 26, 5, 1, - 228, 2, 138, 18, 174, 26, 5, 1, 228, 2, 130, 18, 174, 26, 5, 1, 228, 2, - 138, 18, 173, 26, 5, 1, 228, 2, 130, 18, 173, 26, 5, 1, 228, 2, 138, 18, - 236, 43, 26, 5, 1, 228, 2, 130, 18, 236, 43, 26, 3, 1, 240, 210, 2, 242, - 78, 26, 3, 1, 240, 210, 2, 242, 74, 26, 3, 1, 240, 210, 2, 138, 18, 174, - 26, 3, 1, 240, 210, 2, 130, 18, 174, 26, 3, 1, 240, 210, 2, 138, 18, 173, - 26, 3, 1, 240, 210, 2, 130, 18, 173, 26, 5, 1, 240, 210, 2, 242, 78, 26, - 5, 1, 240, 210, 2, 242, 74, 26, 5, 1, 240, 210, 2, 138, 18, 174, 26, 5, - 1, 240, 210, 2, 130, 18, 174, 26, 5, 1, 240, 210, 2, 138, 18, 173, 26, 5, - 1, 240, 210, 2, 130, 18, 173, 26, 3, 1, 240, 199, 2, 242, 78, 26, 3, 1, - 240, 199, 2, 242, 74, 26, 3, 1, 240, 199, 2, 138, 18, 174, 26, 3, 1, 240, - 199, 2, 130, 18, 174, 26, 3, 1, 240, 199, 2, 138, 18, 173, 26, 3, 1, 240, - 199, 2, 130, 18, 173, 26, 3, 1, 240, 199, 2, 138, 18, 236, 43, 26, 3, 1, - 240, 199, 2, 130, 18, 236, 43, 26, 5, 1, 240, 199, 2, 242, 74, 26, 5, 1, - 240, 199, 2, 130, 18, 174, 26, 5, 1, 240, 199, 2, 130, 18, 173, 26, 5, 1, - 240, 199, 2, 130, 18, 236, 43, 26, 3, 1, 172, 2, 242, 78, 26, 3, 1, 172, - 2, 242, 74, 26, 3, 1, 172, 2, 138, 18, 174, 26, 3, 1, 172, 2, 130, 18, - 174, 26, 3, 1, 172, 2, 138, 18, 173, 26, 3, 1, 172, 2, 130, 18, 173, 26, - 3, 1, 172, 2, 138, 18, 236, 43, 26, 3, 1, 172, 2, 130, 18, 236, 43, 26, - 5, 1, 172, 2, 242, 78, 26, 5, 1, 172, 2, 242, 74, 26, 5, 1, 172, 2, 138, - 18, 174, 26, 5, 1, 172, 2, 130, 18, 174, 26, 5, 1, 172, 2, 138, 18, 173, - 26, 5, 1, 172, 2, 130, 18, 173, 26, 5, 1, 172, 2, 138, 18, 236, 43, 26, - 5, 1, 172, 2, 130, 18, 236, 43, 26, 3, 1, 162, 2, 174, 26, 3, 1, 162, 2, - 173, 26, 3, 1, 240, 204, 2, 174, 26, 3, 1, 240, 204, 2, 173, 26, 3, 1, - 182, 2, 174, 26, 3, 1, 182, 2, 173, 26, 3, 1, 228, 2, 174, 26, 3, 1, 228, - 2, 173, 26, 3, 1, 240, 210, 2, 174, 26, 3, 1, 240, 210, 2, 173, 26, 3, 1, - 240, 199, 2, 174, 26, 3, 1, 240, 199, 2, 173, 26, 3, 1, 172, 2, 174, 26, - 3, 1, 172, 2, 173, 26, 3, 1, 162, 2, 138, 18, 211, 26, 3, 1, 162, 2, 130, - 18, 211, 26, 3, 1, 162, 2, 138, 18, 244, 193, 18, 211, 26, 3, 1, 162, 2, - 130, 18, 244, 193, 18, 211, 26, 3, 1, 162, 2, 138, 18, 249, 26, 18, 211, - 26, 3, 1, 162, 2, 130, 18, 249, 26, 18, 211, 26, 3, 1, 162, 2, 138, 18, - 236, 184, 18, 211, 26, 3, 1, 162, 2, 130, 18, 236, 184, 18, 211, 26, 5, - 1, 162, 2, 138, 18, 234, 62, 26, 5, 1, 162, 2, 130, 18, 234, 62, 26, 5, - 1, 162, 2, 138, 18, 244, 193, 18, 234, 62, 26, 5, 1, 162, 2, 130, 18, - 244, 193, 18, 234, 62, 26, 5, 1, 162, 2, 138, 18, 249, 26, 18, 234, 62, - 26, 5, 1, 162, 2, 130, 18, 249, 26, 18, 234, 62, 26, 5, 1, 162, 2, 138, - 18, 236, 184, 18, 234, 62, 26, 5, 1, 162, 2, 130, 18, 236, 184, 18, 234, - 62, 26, 3, 1, 182, 2, 138, 18, 211, 26, 3, 1, 182, 2, 130, 18, 211, 26, - 3, 1, 182, 2, 138, 18, 244, 193, 18, 211, 26, 3, 1, 182, 2, 130, 18, 244, - 193, 18, 211, 26, 3, 1, 182, 2, 138, 18, 249, 26, 18, 211, 26, 3, 1, 182, - 2, 130, 18, 249, 26, 18, 211, 26, 3, 1, 182, 2, 138, 18, 236, 184, 18, - 211, 26, 3, 1, 182, 2, 130, 18, 236, 184, 18, 211, 26, 5, 1, 182, 2, 138, - 18, 234, 62, 26, 5, 1, 182, 2, 130, 18, 234, 62, 26, 5, 1, 182, 2, 138, - 18, 244, 193, 18, 234, 62, 26, 5, 1, 182, 2, 130, 18, 244, 193, 18, 234, - 62, 26, 5, 1, 182, 2, 138, 18, 249, 26, 18, 234, 62, 26, 5, 1, 182, 2, - 130, 18, 249, 26, 18, 234, 62, 26, 5, 1, 182, 2, 138, 18, 236, 184, 18, - 234, 62, 26, 5, 1, 182, 2, 130, 18, 236, 184, 18, 234, 62, 26, 3, 1, 172, - 2, 138, 18, 211, 26, 3, 1, 172, 2, 130, 18, 211, 26, 3, 1, 172, 2, 138, - 18, 244, 193, 18, 211, 26, 3, 1, 172, 2, 130, 18, 244, 193, 18, 211, 26, - 3, 1, 172, 2, 138, 18, 249, 26, 18, 211, 26, 3, 1, 172, 2, 130, 18, 249, - 26, 18, 211, 26, 3, 1, 172, 2, 138, 18, 236, 184, 18, 211, 26, 3, 1, 172, - 2, 130, 18, 236, 184, 18, 211, 26, 5, 1, 172, 2, 138, 18, 234, 62, 26, 5, - 1, 172, 2, 130, 18, 234, 62, 26, 5, 1, 172, 2, 138, 18, 244, 193, 18, - 234, 62, 26, 5, 1, 172, 2, 130, 18, 244, 193, 18, 234, 62, 26, 5, 1, 172, - 2, 138, 18, 249, 26, 18, 234, 62, 26, 5, 1, 172, 2, 130, 18, 249, 26, 18, - 234, 62, 26, 5, 1, 172, 2, 138, 18, 236, 184, 18, 234, 62, 26, 5, 1, 172, - 2, 130, 18, 236, 184, 18, 234, 62, 26, 3, 1, 162, 2, 240, 245, 26, 3, 1, - 162, 2, 166, 26, 3, 1, 162, 2, 244, 193, 18, 211, 26, 3, 1, 162, 2, 211, - 26, 3, 1, 162, 2, 249, 26, 18, 211, 26, 3, 1, 162, 2, 236, 43, 26, 3, 1, - 162, 2, 236, 184, 18, 211, 26, 5, 1, 162, 2, 240, 245, 26, 5, 1, 162, 2, - 166, 26, 5, 1, 162, 2, 174, 26, 5, 1, 162, 2, 173, 26, 5, 1, 162, 2, 234, - 62, 26, 239, 186, 26, 234, 62, 26, 242, 78, 26, 236, 43, 26, 238, 85, 18, - 236, 43, 26, 3, 1, 182, 2, 244, 193, 18, 211, 26, 3, 1, 182, 2, 211, 26, - 3, 1, 182, 2, 249, 26, 18, 211, 26, 3, 1, 182, 2, 236, 43, 26, 3, 1, 182, - 2, 236, 184, 18, 211, 26, 5, 1, 240, 204, 2, 174, 26, 5, 1, 240, 204, 2, - 173, 26, 5, 1, 182, 2, 174, 26, 5, 1, 182, 2, 173, 26, 5, 1, 182, 2, 234, - 62, 26, 138, 18, 174, 26, 138, 18, 173, 26, 138, 18, 236, 43, 26, 3, 1, - 228, 2, 240, 245, 26, 3, 1, 228, 2, 166, 26, 3, 1, 228, 2, 238, 85, 18, - 174, 26, 3, 1, 228, 2, 238, 85, 18, 173, 26, 3, 1, 228, 2, 236, 43, 26, - 3, 1, 228, 2, 238, 85, 18, 236, 43, 26, 5, 1, 228, 2, 240, 245, 26, 5, 1, - 228, 2, 166, 26, 5, 1, 228, 2, 174, 26, 5, 1, 228, 2, 173, 26, 130, 18, - 174, 26, 130, 18, 173, 26, 130, 18, 236, 43, 26, 3, 1, 240, 199, 2, 240, - 245, 26, 3, 1, 240, 199, 2, 166, 26, 3, 1, 240, 199, 2, 238, 85, 18, 174, - 26, 3, 1, 240, 199, 2, 238, 85, 18, 173, 26, 3, 1, 253, 168, 2, 242, 78, - 26, 3, 1, 253, 168, 2, 242, 74, 26, 3, 1, 240, 199, 2, 236, 43, 26, 3, 1, - 240, 199, 2, 238, 85, 18, 236, 43, 26, 5, 1, 240, 199, 2, 240, 245, 26, - 5, 1, 240, 199, 2, 166, 26, 5, 1, 240, 199, 2, 174, 26, 5, 1, 240, 199, - 2, 173, 26, 5, 1, 253, 168, 2, 242, 74, 26, 238, 85, 18, 174, 26, 238, - 85, 18, 173, 26, 174, 26, 3, 1, 172, 2, 244, 193, 18, 211, 26, 3, 1, 172, - 2, 211, 26, 3, 1, 172, 2, 249, 26, 18, 211, 26, 3, 1, 172, 2, 236, 43, - 26, 3, 1, 172, 2, 236, 184, 18, 211, 26, 5, 1, 240, 210, 2, 174, 26, 5, - 1, 240, 210, 2, 173, 26, 5, 1, 172, 2, 174, 26, 5, 1, 172, 2, 173, 26, 5, - 1, 172, 2, 234, 62, 26, 173, 26, 242, 74, 254, 215, 244, 238, 254, 220, - 244, 238, 254, 215, 242, 69, 254, 220, 242, 69, 236, 174, 242, 69, 237, - 63, 242, 69, 238, 61, 242, 69, 242, 211, 242, 69, 236, 191, 242, 69, 252, - 206, 242, 69, 251, 57, 242, 69, 249, 127, 245, 12, 242, 69, 249, 127, - 245, 12, 237, 77, 249, 127, 245, 12, 241, 22, 235, 245, 65, 235, 248, 65, - 240, 241, 236, 149, 240, 241, 242, 211, 244, 189, 254, 215, 244, 189, - 254, 220, 244, 189, 146, 143, 42, 55, 244, 176, 42, 253, 113, 244, 176, - 36, 242, 66, 238, 76, 65, 37, 242, 66, 238, 76, 65, 242, 66, 245, 135, - 238, 76, 65, 242, 66, 234, 67, 238, 76, 65, 36, 42, 238, 76, 65, 37, 42, - 238, 76, 65, 42, 245, 135, 238, 76, 65, 42, 234, 67, 238, 76, 65, 241, - 50, 42, 241, 50, 240, 215, 237, 144, 240, 215, 253, 101, 49, 241, 25, - 225, 49, 241, 25, 146, 238, 96, 237, 67, 242, 239, 217, 237, 114, 238, - 113, 237, 114, 235, 245, 237, 154, 235, 248, 237, 154, 254, 171, 237, 1, - 237, 62, 235, 245, 238, 148, 235, 248, 238, 148, 243, 234, 239, 190, 242, - 69, 254, 66, 247, 96, 57, 254, 66, 253, 250, 239, 243, 57, 242, 107, 42, - 242, 107, 242, 59, 242, 107, 224, 242, 107, 224, 42, 242, 107, 224, 242, - 59, 242, 107, 242, 174, 242, 66, 235, 237, 160, 238, 76, 65, 242, 66, - 235, 190, 160, 238, 76, 65, 239, 72, 65, 42, 236, 186, 65, 236, 140, 238, - 98, 239, 109, 92, 249, 89, 244, 225, 238, 144, 242, 239, 238, 180, 243, - 171, 240, 215, 239, 123, 242, 91, 36, 30, 226, 2, 242, 242, 37, 30, 226, - 2, 242, 242, 42, 239, 126, 65, 239, 126, 236, 186, 65, 236, 186, 239, - 126, 65, 240, 184, 25, 254, 11, 224, 241, 74, 57, 86, 126, 240, 215, 86, - 63, 240, 215, 253, 113, 238, 77, 224, 237, 123, 246, 71, 253, 131, 225, - 238, 179, 241, 96, 237, 108, 237, 127, 244, 197, 57, 238, 94, 242, 107, - 242, 82, 8, 242, 69, 253, 19, 241, 22, 240, 80, 236, 85, 238, 145, 242, - 167, 238, 145, 237, 114, 241, 58, 238, 161, 238, 160, 239, 199, 238, 161, - 238, 160, 241, 58, 10, 249, 3, 239, 235, 239, 199, 10, 249, 3, 239, 235, - 240, 121, 27, 241, 77, 241, 223, 27, 241, 77, 236, 181, 244, 173, 236, - 181, 9, 3, 1, 69, 236, 181, 163, 236, 181, 168, 236, 181, 169, 236, 181, - 179, 236, 181, 176, 236, 181, 178, 236, 181, 249, 4, 57, 236, 181, 242, - 119, 236, 181, 242, 61, 57, 236, 181, 36, 236, 47, 236, 181, 37, 236, 47, - 236, 181, 9, 3, 1, 183, 238, 83, 244, 173, 238, 83, 121, 238, 83, 114, - 238, 83, 153, 238, 83, 163, 238, 83, 168, 238, 83, 169, 238, 83, 179, - 238, 83, 176, 238, 83, 178, 238, 83, 249, 4, 57, 238, 83, 242, 119, 238, - 83, 242, 61, 57, 238, 83, 36, 236, 47, 238, 83, 37, 236, 47, 236, 20, 57, - 244, 214, 57, 240, 20, 57, 243, 118, 246, 132, 57, 251, 199, 57, 251, - 234, 57, 247, 108, 57, 244, 34, 57, 245, 40, 57, 254, 76, 57, 254, 153, - 244, 77, 57, 250, 225, 57, 250, 248, 57, 254, 126, 57, 244, 127, 57, 241, - 150, 57, 243, 126, 247, 240, 57, 252, 62, 57, 48, 36, 154, 47, 48, 37, - 154, 47, 48, 165, 55, 217, 239, 131, 48, 207, 55, 217, 239, 131, 48, 235, - 236, 59, 47, 48, 238, 87, 59, 47, 48, 36, 59, 47, 48, 37, 59, 47, 48, - 249, 9, 239, 131, 48, 238, 87, 249, 9, 239, 131, 48, 235, 236, 249, 9, - 239, 131, 48, 244, 171, 248, 253, 47, 48, 249, 28, 248, 253, 47, 48, 238, - 97, 240, 200, 48, 238, 97, 240, 207, 48, 238, 97, 239, 132, 48, 238, 97, - 175, 237, 132, 48, 36, 37, 59, 47, 48, 238, 97, 242, 0, 48, 238, 97, 241, - 191, 48, 238, 97, 244, 135, 239, 119, 219, 48, 240, 219, 240, 230, 239, - 131, 48, 42, 55, 242, 114, 239, 131, 48, 241, 98, 90, 48, 242, 59, 239, - 108, 48, 249, 51, 242, 153, 47, 48, 126, 59, 239, 131, 241, 37, 253, 128, - 238, 167, 139, 253, 173, 240, 172, 120, 5, 203, 242, 156, 240, 14, 242, - 100, 217, 90, 250, 177, 253, 128, 250, 174, 252, 237, 246, 127, 238, 136, - 240, 160, 242, 156, 237, 61, 71, 3, 194, 71, 5, 164, 236, 51, 5, 164, - 120, 5, 164, 242, 238, 238, 136, 242, 238, 240, 17, 249, 25, 225, 253, - 116, 71, 5, 69, 236, 51, 5, 69, 71, 5, 148, 71, 3, 148, 255, 31, 255, 41, - 253, 99, 90, 120, 5, 183, 244, 7, 57, 244, 205, 239, 70, 237, 183, 71, 5, - 198, 120, 5, 198, 120, 5, 209, 71, 5, 135, 236, 51, 5, 135, 120, 5, 135, - 236, 157, 248, 116, 239, 75, 242, 8, 65, 238, 132, 57, 248, 136, 167, 57, - 239, 110, 120, 5, 202, 247, 235, 57, 254, 61, 57, 239, 116, 254, 61, 57, - 236, 51, 5, 202, 242, 60, 26, 3, 1, 244, 191, 243, 188, 57, 239, 250, 57, - 71, 5, 199, 236, 51, 5, 203, 239, 9, 90, 71, 3, 70, 71, 5, 70, 71, 5, - 204, 242, 60, 5, 204, 71, 5, 171, 71, 3, 78, 67, 90, 254, 3, 90, 245, 98, - 90, 245, 76, 90, 237, 71, 242, 16, 241, 3, 5, 209, 120, 3, 242, 75, 120, - 5, 242, 75, 120, 5, 253, 116, 120, 244, 186, 237, 164, 242, 60, 23, 5, - 194, 242, 60, 23, 5, 148, 224, 23, 5, 148, 242, 60, 23, 5, 181, 120, 21, - 5, 187, 120, 21, 3, 187, 120, 21, 3, 70, 120, 21, 3, 69, 120, 21, 3, 200, - 240, 146, 244, 176, 242, 60, 237, 124, 242, 83, 239, 123, 253, 101, 244, - 116, 242, 83, 239, 123, 225, 242, 35, 242, 83, 239, 123, 253, 101, 243, - 111, 242, 83, 239, 123, 225, 241, 20, 242, 83, 239, 123, 244, 171, 241, - 20, 242, 83, 239, 123, 249, 28, 241, 20, 242, 83, 239, 123, 253, 101, - 244, 84, 242, 83, 239, 123, 249, 48, 242, 14, 242, 83, 239, 123, 253, - 101, 241, 151, 242, 83, 239, 123, 244, 171, 239, 181, 242, 83, 239, 123, - 249, 48, 239, 181, 242, 83, 239, 123, 245, 4, 239, 181, 239, 123, 238, - 103, 121, 218, 151, 121, 218, 151, 114, 218, 151, 153, 218, 151, 163, - 218, 151, 168, 218, 151, 169, 218, 151, 179, 218, 151, 176, 218, 151, - 178, 218, 151, 249, 18, 218, 151, 240, 234, 218, 151, 240, 238, 218, 151, - 242, 144, 218, 151, 253, 101, 239, 150, 218, 151, 249, 48, 239, 150, 218, - 151, 253, 101, 238, 104, 3, 218, 151, 121, 3, 218, 151, 114, 3, 218, 151, - 153, 3, 218, 151, 163, 3, 218, 151, 168, 3, 218, 151, 169, 3, 218, 151, - 179, 3, 218, 151, 176, 3, 218, 151, 178, 3, 218, 151, 249, 18, 3, 218, - 151, 240, 234, 3, 218, 151, 240, 238, 3, 218, 151, 242, 144, 3, 218, 151, - 253, 101, 239, 150, 3, 218, 151, 249, 48, 239, 150, 3, 218, 151, 253, - 101, 238, 104, 218, 151, 253, 101, 239, 243, 255, 36, 187, 218, 151, 249, - 48, 238, 104, 218, 151, 253, 250, 238, 104, 218, 151, 224, 253, 101, 239, - 150, 126, 52, 210, 52, 63, 52, 220, 52, 36, 37, 52, 75, 79, 52, 244, 177, - 249, 17, 52, 244, 177, 249, 2, 52, 244, 181, 249, 2, 52, 244, 181, 249, - 17, 52, 126, 59, 2, 122, 63, 59, 2, 122, 126, 249, 90, 52, 63, 249, 90, - 52, 126, 225, 242, 159, 52, 210, 225, 242, 159, 52, 63, 225, 242, 159, - 52, 220, 225, 242, 159, 52, 126, 59, 2, 244, 182, 63, 59, 2, 244, 182, - 126, 59, 248, 254, 143, 210, 59, 248, 254, 143, 63, 59, 248, 254, 143, - 220, 59, 248, 254, 143, 75, 79, 59, 2, 245, 253, 126, 59, 2, 128, 63, 59, - 2, 128, 126, 59, 2, 245, 28, 63, 59, 2, 245, 28, 36, 37, 249, 90, 52, 36, - 37, 59, 2, 122, 220, 242, 193, 52, 210, 59, 2, 253, 252, 237, 125, 210, - 59, 2, 253, 252, 236, 195, 220, 59, 2, 253, 252, 237, 125, 220, 59, 2, - 253, 252, 236, 195, 63, 59, 2, 242, 86, 237, 121, 220, 59, 2, 242, 86, - 237, 125, 235, 236, 253, 121, 237, 163, 52, 238, 87, 253, 121, 237, 163, - 52, 244, 177, 249, 17, 59, 139, 165, 143, 126, 59, 139, 253, 99, 249, 25, - 63, 59, 139, 143, 235, 236, 249, 0, 175, 52, 238, 87, 249, 0, 175, 52, - 126, 154, 2, 133, 239, 176, 126, 154, 2, 133, 237, 121, 210, 154, 2, 133, - 236, 195, 210, 154, 2, 133, 237, 125, 63, 154, 2, 133, 239, 176, 63, 154, - 2, 133, 237, 121, 220, 154, 2, 133, 236, 195, 220, 154, 2, 133, 237, 125, - 63, 59, 249, 25, 126, 52, 210, 59, 126, 137, 220, 52, 126, 59, 249, 25, - 63, 52, 126, 242, 161, 240, 246, 210, 242, 161, 240, 246, 63, 242, 161, - 240, 246, 220, 242, 161, 240, 246, 126, 154, 249, 25, 63, 239, 142, 63, - 154, 249, 25, 126, 239, 142, 126, 42, 59, 2, 122, 36, 37, 42, 59, 2, 122, - 63, 42, 59, 2, 122, 126, 42, 52, 210, 42, 52, 63, 42, 52, 220, 42, 52, - 36, 37, 42, 52, 75, 79, 42, 52, 244, 177, 249, 17, 42, 52, 244, 177, 249, - 2, 42, 52, 244, 181, 249, 2, 42, 52, 244, 181, 249, 17, 42, 52, 126, 242, - 59, 52, 63, 242, 59, 52, 126, 239, 196, 52, 63, 239, 196, 52, 210, 59, 2, - 42, 122, 220, 59, 2, 42, 122, 126, 242, 105, 52, 210, 242, 105, 52, 63, - 242, 105, 52, 220, 242, 105, 52, 126, 59, 139, 143, 63, 59, 139, 143, - 126, 58, 52, 210, 58, 52, 63, 58, 52, 220, 58, 52, 210, 58, 59, 248, 254, - 143, 210, 58, 59, 254, 236, 238, 150, 210, 58, 59, 254, 236, 239, 228, 2, - 146, 143, 210, 58, 59, 254, 236, 239, 228, 2, 55, 143, 210, 58, 42, 52, - 210, 58, 42, 59, 254, 236, 238, 150, 63, 58, 59, 248, 254, 248, 170, 244, - 177, 249, 17, 59, 139, 240, 213, 244, 181, 249, 2, 59, 139, 240, 213, 75, - 79, 58, 52, 37, 59, 2, 3, 240, 200, 220, 59, 126, 137, 210, 52, 244, 171, - 63, 240, 246, 126, 59, 2, 55, 122, 63, 59, 2, 55, 122, 36, 37, 59, 2, 55, - 122, 126, 59, 2, 42, 55, 122, 63, 59, 2, 42, 55, 122, 36, 37, 59, 2, 42, - 55, 122, 126, 236, 203, 52, 63, 236, 203, 52, 36, 37, 236, 203, 52, 54, - 249, 185, 236, 251, 240, 243, 235, 240, 245, 201, 241, 155, 245, 201, - 249, 41, 141, 243, 103, 244, 216, 250, 69, 238, 19, 242, 130, 240, 214, - 253, 128, 141, 255, 2, 240, 214, 253, 128, 3, 240, 214, 253, 128, 239, - 146, 254, 217, 241, 27, 249, 41, 141, 241, 14, 254, 217, 241, 27, 3, 239, - 146, 254, 217, 241, 27, 253, 127, 137, 244, 42, 244, 186, 239, 138, 244, - 186, 237, 152, 244, 186, 237, 164, 244, 197, 57, 236, 28, 57, 49, 244, - 212, 239, 156, 242, 91, 253, 232, 242, 119, 239, 203, 223, 249, 9, 223, - 243, 54, 223, 30, 245, 39, 250, 194, 245, 39, 242, 214, 245, 39, 236, - 158, 76, 238, 121, 37, 242, 117, 242, 117, 239, 136, 242, 117, 238, 128, - 242, 117, 240, 31, 249, 41, 141, 241, 52, 239, 160, 76, 141, 239, 160, - 76, 240, 202, 249, 46, 240, 202, 253, 186, 235, 238, 242, 109, 238, 86, - 42, 238, 86, 242, 59, 238, 86, 241, 15, 238, 86, 242, 27, 238, 86, 244, - 142, 238, 86, 238, 87, 238, 86, 238, 87, 241, 15, 238, 86, 235, 236, 241, - 15, 238, 86, 238, 67, 240, 5, 244, 53, 236, 225, 49, 242, 119, 241, 154, - 239, 24, 236, 225, 237, 66, 229, 223, 224, 180, 239, 116, 251, 187, 159, - 252, 166, 245, 11, 244, 149, 239, 138, 141, 180, 244, 197, 180, 235, 199, - 80, 76, 141, 235, 199, 80, 76, 235, 239, 80, 76, 235, 239, 253, 177, 141, - 239, 200, 80, 76, 240, 223, 235, 239, 253, 137, 239, 200, 80, 76, 242, - 93, 80, 76, 141, 242, 93, 80, 76, 242, 93, 80, 112, 80, 76, 242, 59, 180, - 254, 1, 80, 76, 237, 113, 76, 235, 252, 237, 113, 76, 237, 187, 239, 204, - 237, 174, 253, 173, 243, 204, 235, 252, 80, 76, 235, 239, 80, 139, 112, - 253, 173, 244, 211, 253, 128, 244, 211, 137, 112, 235, 239, 80, 76, 244, - 214, 240, 254, 242, 61, 242, 81, 249, 9, 254, 214, 80, 76, 249, 9, 80, - 76, 236, 253, 76, 238, 5, 237, 60, 76, 249, 86, 240, 254, 245, 20, 80, - 76, 80, 139, 254, 216, 236, 255, 239, 136, 254, 30, 238, 50, 80, 76, 141, - 80, 76, 238, 111, 76, 141, 238, 111, 76, 240, 171, 237, 113, 76, 206, - 112, 80, 76, 196, 112, 80, 76, 206, 249, 25, 80, 76, 196, 249, 25, 80, - 76, 206, 253, 177, 141, 80, 76, 196, 253, 177, 141, 80, 76, 249, 108, - 237, 110, 249, 108, 235, 235, 239, 204, 141, 237, 113, 76, 141, 237, 110, - 141, 235, 235, 240, 223, 206, 253, 137, 80, 76, 240, 223, 196, 253, 137, - 80, 76, 206, 112, 237, 113, 76, 196, 112, 237, 113, 76, 240, 223, 206, - 253, 137, 237, 113, 76, 240, 223, 196, 253, 137, 237, 113, 76, 206, 112, - 235, 235, 196, 112, 237, 110, 240, 223, 206, 253, 137, 235, 235, 240, - 223, 196, 253, 137, 237, 110, 238, 126, 238, 130, 239, 143, 112, 80, 76, - 239, 145, 112, 80, 76, 239, 143, 112, 237, 113, 76, 239, 145, 112, 237, - 113, 76, 249, 41, 141, 240, 142, 249, 41, 141, 240, 173, 242, 76, 253, - 128, 239, 121, 253, 128, 141, 119, 242, 76, 253, 128, 141, 119, 239, 121, - 253, 128, 242, 76, 137, 112, 80, 76, 239, 121, 137, 112, 80, 76, 240, - 223, 119, 242, 76, 137, 253, 137, 80, 76, 240, 223, 119, 239, 121, 137, - 253, 137, 80, 76, 242, 76, 137, 2, 141, 80, 76, 239, 121, 137, 2, 141, - 80, 76, 239, 50, 239, 225, 235, 181, 239, 225, 242, 109, 30, 244, 211, - 253, 128, 30, 239, 169, 253, 128, 30, 244, 211, 137, 112, 80, 76, 30, - 239, 169, 137, 112, 80, 76, 30, 249, 195, 30, 249, 202, 28, 244, 212, 28, - 242, 119, 28, 242, 167, 28, 239, 156, 242, 91, 28, 49, 223, 28, 249, 9, - 223, 28, 239, 203, 223, 28, 240, 254, 28, 244, 189, 240, 227, 244, 212, - 240, 227, 242, 119, 240, 227, 242, 167, 240, 227, 49, 223, 37, 244, 184, - 36, 244, 184, 79, 244, 184, 75, 244, 184, 237, 175, 241, 216, 245, 209, - 241, 172, 242, 59, 55, 253, 99, 37, 237, 119, 42, 55, 253, 99, 42, 37, - 237, 119, 249, 41, 141, 244, 43, 141, 245, 209, 249, 41, 141, 243, 116, - 241, 68, 42, 55, 253, 99, 42, 37, 237, 119, 239, 143, 245, 217, 238, 114, - 239, 145, 245, 217, 238, 114, 242, 103, 239, 164, 253, 128, 239, 146, - 254, 217, 242, 103, 238, 159, 242, 103, 239, 164, 137, 112, 80, 76, 239, - 146, 254, 217, 242, 103, 239, 164, 112, 80, 76, 239, 169, 253, 128, 244, - 211, 253, 128, 238, 122, 239, 27, 238, 193, 241, 207, 236, 139, 253, 30, - 247, 109, 252, 34, 37, 160, 2, 249, 65, 37, 219, 244, 186, 240, 202, 249, - 46, 244, 186, 240, 202, 253, 186, 244, 186, 235, 238, 244, 186, 242, 109, - 240, 221, 223, 49, 223, 249, 86, 223, 239, 156, 242, 167, 241, 45, 36, - 242, 103, 242, 210, 237, 128, 239, 138, 37, 242, 103, 242, 210, 237, 128, - 239, 138, 36, 237, 128, 239, 138, 37, 237, 128, 239, 138, 224, 229, 240, - 254, 244, 175, 240, 202, 253, 186, 244, 175, 240, 202, 249, 46, 42, 240, - 237, 42, 238, 116, 42, 235, 238, 42, 242, 109, 238, 43, 80, 18, 239, 160, - 76, 206, 2, 227, 196, 2, 227, 250, 104, 249, 108, 237, 110, 250, 104, - 249, 108, 235, 235, 206, 80, 139, 112, 235, 235, 196, 80, 139, 112, 237, - 110, 80, 139, 112, 237, 110, 80, 139, 112, 235, 235, 80, 139, 112, 238, - 126, 80, 139, 112, 238, 130, 249, 41, 141, 241, 242, 112, 242, 88, 249, - 41, 141, 242, 26, 112, 242, 88, 141, 30, 244, 211, 137, 112, 80, 76, 141, - 30, 239, 169, 137, 112, 80, 76, 30, 244, 211, 137, 112, 141, 80, 76, 30, - 239, 169, 137, 112, 141, 80, 76, 206, 253, 177, 141, 237, 113, 76, 196, - 253, 177, 141, 237, 113, 76, 239, 143, 253, 177, 141, 237, 113, 76, 239, - 145, 253, 177, 141, 237, 113, 76, 141, 242, 103, 239, 164, 253, 128, 249, - 41, 141, 241, 14, 254, 217, 242, 103, 238, 159, 141, 242, 103, 239, 164, - 137, 112, 80, 76, 249, 41, 141, 241, 14, 254, 217, 242, 103, 239, 164, - 112, 242, 88, 55, 238, 96, 241, 213, 146, 238, 96, 75, 37, 239, 125, 238, - 96, 79, 37, 239, 125, 238, 96, 240, 214, 137, 2, 165, 146, 122, 240, 214, - 137, 2, 55, 253, 99, 254, 228, 253, 127, 137, 146, 122, 3, 240, 214, 137, - 2, 55, 253, 99, 254, 228, 253, 127, 137, 146, 122, 240, 214, 137, 2, 49, - 47, 240, 214, 137, 2, 239, 130, 3, 240, 214, 137, 2, 239, 130, 240, 214, - 137, 2, 238, 75, 240, 214, 137, 2, 225, 146, 239, 240, 239, 146, 2, 165, - 146, 122, 239, 146, 2, 55, 253, 99, 254, 228, 253, 127, 137, 146, 122, 3, - 239, 146, 2, 55, 253, 99, 254, 228, 253, 127, 137, 146, 122, 239, 146, 2, - 239, 130, 3, 239, 146, 2, 239, 130, 255, 27, 239, 129, 254, 87, 237, 75, - 240, 25, 57, 240, 67, 52, 243, 163, 75, 237, 116, 79, 237, 116, 237, 82, - 236, 152, 249, 57, 244, 176, 36, 239, 207, 37, 239, 207, 36, 242, 212, - 37, 242, 212, 242, 80, 37, 244, 247, 242, 80, 36, 244, 247, 253, 121, 37, - 244, 247, 253, 121, 36, 244, 247, 224, 141, 57, 30, 239, 188, 249, 65, - 240, 161, 242, 6, 238, 132, 239, 69, 240, 141, 237, 136, 240, 193, 240, - 207, 245, 162, 137, 240, 92, 57, 242, 60, 141, 57, 244, 145, 237, 140, - 253, 121, 36, 240, 213, 253, 121, 37, 240, 213, 242, 80, 36, 240, 213, - 242, 80, 37, 240, 213, 253, 121, 136, 238, 86, 242, 80, 136, 238, 86, - 243, 119, 244, 90, 75, 238, 177, 241, 112, 225, 146, 245, 252, 244, 20, - 251, 150, 245, 81, 139, 253, 173, 184, 255, 43, 254, 214, 119, 239, 71, - 249, 47, 239, 37, 235, 237, 160, 110, 235, 190, 160, 110, 245, 81, 139, - 253, 173, 244, 172, 241, 111, 244, 183, 236, 8, 254, 1, 234, 69, 239, 99, - 248, 135, 241, 250, 238, 203, 241, 230, 241, 129, 244, 110, 244, 88, 236, - 92, 236, 93, 123, 124, 13, 241, 183, 123, 124, 13, 244, 99, 244, 238, - 123, 124, 13, 249, 14, 242, 88, 123, 124, 13, 249, 14, 241, 52, 123, 124, - 13, 249, 14, 239, 132, 123, 124, 13, 249, 14, 249, 69, 123, 124, 13, 249, - 14, 240, 200, 123, 124, 13, 175, 242, 150, 123, 124, 13, 175, 249, 69, - 123, 124, 13, 248, 80, 143, 123, 124, 13, 238, 181, 143, 123, 124, 13, - 249, 14, 242, 91, 123, 124, 13, 249, 14, 237, 132, 123, 124, 13, 249, 14, - 237, 110, 123, 124, 13, 249, 14, 235, 235, 123, 124, 13, 126, 245, 10, - 123, 124, 13, 63, 245, 10, 123, 124, 13, 249, 14, 126, 52, 123, 124, 13, - 249, 14, 63, 52, 123, 124, 13, 175, 237, 132, 123, 124, 13, 79, 249, 35, - 238, 75, 123, 124, 13, 245, 20, 242, 150, 123, 124, 13, 249, 14, 79, 242, - 174, 123, 124, 13, 249, 14, 242, 87, 123, 124, 13, 79, 249, 35, 249, 69, - 123, 124, 13, 210, 245, 10, 123, 124, 13, 249, 14, 210, 52, 123, 124, 13, - 75, 249, 35, 239, 130, 123, 124, 13, 254, 6, 242, 150, 123, 124, 13, 249, - 14, 75, 242, 174, 123, 124, 13, 249, 14, 250, 213, 123, 124, 13, 75, 249, - 35, 249, 69, 123, 124, 13, 220, 245, 10, 123, 124, 13, 249, 14, 220, 52, - 123, 124, 13, 245, 166, 238, 75, 123, 124, 13, 245, 20, 238, 75, 123, - 124, 13, 240, 221, 238, 75, 123, 124, 13, 254, 48, 238, 75, 123, 124, 13, - 175, 238, 75, 123, 124, 13, 75, 249, 161, 249, 69, 123, 124, 13, 245, - 166, 244, 238, 123, 124, 13, 175, 244, 178, 123, 124, 13, 249, 14, 242, - 81, 123, 124, 13, 75, 249, 35, 150, 123, 124, 13, 254, 6, 150, 123, 124, - 13, 249, 86, 150, 123, 124, 13, 254, 48, 150, 123, 124, 13, 175, 150, - 123, 124, 13, 79, 249, 161, 242, 150, 123, 124, 13, 36, 249, 161, 242, - 150, 123, 124, 13, 229, 150, 123, 124, 13, 196, 150, 123, 124, 13, 244, - 192, 143, 123, 124, 13, 254, 6, 180, 123, 124, 13, 244, 164, 123, 124, - 13, 248, 105, 180, 123, 124, 13, 239, 82, 238, 75, 123, 124, 13, 249, 14, - 141, 242, 88, 123, 124, 13, 249, 14, 239, 68, 123, 124, 13, 79, 244, 225, - 180, 123, 124, 13, 75, 244, 225, 180, 123, 124, 13, 244, 191, 123, 124, - 13, 249, 32, 123, 124, 13, 242, 72, 123, 124, 13, 162, 238, 75, 123, 124, - 13, 240, 204, 238, 75, 123, 124, 13, 228, 238, 75, 123, 124, 13, 172, - 238, 75, 123, 124, 13, 242, 79, 141, 245, 16, 65, 37, 160, 2, 220, 242, - 193, 52, 238, 60, 249, 0, 249, 47, 250, 151, 90, 55, 217, 2, 242, 65, - 227, 238, 144, 90, 237, 182, 238, 165, 90, 236, 11, 238, 165, 90, 239, - 215, 90, 236, 252, 90, 58, 30, 2, 242, 100, 55, 244, 176, 246, 122, 90, - 236, 200, 254, 49, 90, 251, 63, 90, 28, 146, 253, 99, 2, 244, 3, 28, 239, - 118, 244, 185, 242, 173, 175, 2, 239, 52, 52, 252, 238, 90, 238, 34, 90, - 238, 15, 90, 231, 241, 243, 139, 90, 231, 241, 243, 197, 90, 231, 232, - 90, 231, 235, 90, 243, 92, 241, 131, 13, 249, 3, 114, 232, 12, 90, 123, - 124, 13, 244, 238, 241, 51, 238, 158, 254, 49, 90, 240, 144, 245, 156, - 252, 16, 245, 156, 247, 250, 242, 244, 90, 246, 70, 242, 244, 90, 36, - 236, 187, 156, 128, 36, 236, 187, 237, 122, 36, 236, 187, 149, 128, 37, - 236, 187, 156, 128, 37, 236, 187, 237, 122, 37, 236, 187, 149, 128, 36, - 30, 226, 156, 240, 213, 36, 30, 226, 237, 122, 36, 30, 226, 149, 240, - 213, 37, 30, 226, 156, 240, 213, 37, 30, 226, 237, 122, 37, 30, 226, 149, - 240, 213, 36, 244, 175, 226, 156, 128, 36, 244, 175, 226, 242, 65, 242, - 163, 36, 244, 175, 226, 149, 128, 244, 175, 226, 237, 122, 37, 244, 175, - 226, 156, 128, 37, 244, 175, 226, 242, 65, 242, 163, 37, 244, 175, 226, - 149, 128, 239, 135, 237, 122, 146, 217, 237, 122, 156, 36, 112, 149, 37, - 244, 175, 226, 239, 174, 156, 37, 112, 149, 36, 244, 175, 226, 239, 174, - 238, 131, 249, 168, 238, 131, 241, 12, 253, 121, 30, 110, 242, 80, 30, - 110, 242, 80, 30, 226, 249, 25, 253, 121, 30, 110, 22, 13, 241, 12, 36, - 55, 56, 244, 176, 37, 55, 56, 244, 176, 146, 249, 116, 241, 198, 146, - 249, 116, 241, 199, 146, 249, 116, 241, 200, 146, 249, 116, 241, 201, - 238, 84, 13, 117, 55, 18, 253, 121, 184, 238, 84, 13, 117, 55, 18, 242, - 80, 184, 238, 84, 13, 117, 55, 2, 240, 200, 238, 84, 13, 117, 79, 18, - 146, 2, 240, 200, 238, 84, 13, 117, 75, 18, 146, 2, 240, 200, 238, 84, - 13, 117, 55, 2, 219, 238, 84, 13, 117, 79, 18, 146, 2, 219, 238, 84, 13, - 117, 75, 18, 146, 2, 219, 238, 84, 13, 117, 55, 18, 245, 11, 238, 84, 13, - 117, 79, 18, 146, 2, 245, 11, 238, 84, 13, 117, 75, 18, 146, 2, 245, 11, - 238, 84, 13, 117, 79, 18, 236, 182, 238, 84, 13, 117, 75, 18, 236, 182, - 238, 84, 13, 117, 55, 18, 253, 121, 244, 172, 238, 84, 13, 117, 55, 18, - 242, 80, 244, 172, 30, 245, 22, 244, 56, 90, 13, 54, 247, 197, 13, 54, - 245, 45, 137, 240, 86, 13, 54, 245, 45, 137, 245, 200, 13, 54, 253, 127, - 137, 245, 200, 13, 54, 253, 127, 137, 236, 40, 13, 54, 240, 68, 13, 54, - 236, 74, 13, 54, 246, 20, 13, 54, 237, 177, 13, 54, 146, 236, 235, 13, - 54, 217, 245, 83, 13, 54, 55, 236, 235, 13, 54, 249, 3, 245, 83, 13, 54, - 240, 13, 241, 249, 13, 54, 245, 185, 252, 58, 13, 54, 245, 185, 253, 227, - 13, 54, 250, 210, 251, 197, 241, 53, 13, 54, 242, 157, 240, 251, 121, 13, - 54, 242, 157, 240, 251, 114, 13, 54, 242, 157, 240, 251, 153, 13, 54, - 242, 157, 240, 251, 163, 13, 54, 239, 115, 236, 74, 13, 54, 237, 102, - 246, 248, 13, 54, 253, 127, 137, 236, 176, 242, 67, 13, 54, 241, 120, 13, - 54, 253, 127, 137, 241, 209, 13, 54, 237, 101, 13, 54, 241, 53, 13, 54, - 251, 7, 237, 114, 13, 54, 246, 161, 237, 114, 13, 54, 244, 55, 237, 114, - 13, 54, 252, 239, 237, 114, 13, 54, 242, 69, 13, 54, 241, 137, 246, 29, - 90, 249, 0, 249, 47, 13, 54, 240, 124, 13, 54, 243, 90, 249, 3, 114, 13, - 54, 238, 65, 249, 3, 114, 253, 149, 128, 253, 149, 243, 60, 253, 149, - 245, 88, 253, 149, 239, 116, 245, 88, 253, 149, 250, 152, 241, 119, 253, - 149, 254, 89, 249, 89, 253, 149, 243, 49, 250, 140, 234, 72, 253, 149, - 243, 29, 137, 242, 201, 253, 149, 244, 189, 253, 149, 240, 21, 241, 37, - 241, 224, 253, 149, 42, 237, 132, 28, 27, 121, 28, 27, 114, 28, 27, 153, - 28, 27, 163, 28, 27, 168, 28, 27, 169, 28, 27, 179, 28, 27, 176, 28, 27, - 178, 28, 83, 249, 18, 28, 83, 240, 234, 28, 83, 240, 238, 28, 83, 238, - 108, 28, 83, 238, 106, 28, 83, 239, 167, 28, 83, 239, 162, 28, 83, 237, - 129, 28, 83, 238, 105, 28, 83, 238, 107, 28, 83, 240, 239, 68, 27, 121, - 68, 27, 114, 68, 27, 153, 68, 27, 163, 68, 27, 168, 68, 27, 169, 68, 27, - 179, 68, 27, 176, 68, 27, 178, 68, 83, 249, 18, 68, 83, 240, 234, 68, 83, - 240, 238, 68, 83, 238, 108, 68, 83, 238, 106, 68, 83, 239, 167, 68, 83, - 239, 162, 68, 83, 237, 129, 68, 83, 238, 105, 68, 83, 238, 107, 68, 83, - 240, 239, 27, 253, 101, 213, 189, 27, 225, 213, 189, 27, 244, 171, 213, - 189, 27, 249, 28, 213, 189, 27, 249, 48, 213, 189, 27, 254, 23, 213, 189, - 27, 245, 4, 213, 189, 27, 244, 207, 213, 189, 27, 250, 29, 213, 189, 83, - 253, 250, 213, 189, 83, 243, 97, 213, 189, 83, 243, 17, 213, 189, 83, - 240, 180, 213, 189, 83, 240, 78, 213, 189, 83, 241, 166, 213, 189, 83, - 241, 78, 213, 189, 83, 239, 83, 213, 189, 83, 240, 65, 213, 189, 83, 240, - 127, 213, 189, 83, 242, 104, 213, 189, 68, 9, 3, 1, 64, 68, 9, 3, 1, 199, - 68, 9, 3, 1, 203, 68, 9, 3, 1, 187, 68, 9, 3, 1, 70, 68, 9, 3, 1, 204, - 68, 9, 3, 1, 194, 68, 9, 3, 1, 164, 68, 9, 3, 1, 69, 68, 9, 3, 1, 200, - 68, 9, 3, 1, 205, 68, 9, 3, 1, 148, 68, 9, 3, 1, 171, 68, 9, 3, 1, 183, - 68, 9, 3, 1, 78, 68, 9, 3, 1, 198, 68, 9, 3, 1, 209, 68, 9, 3, 1, 135, - 68, 9, 3, 1, 159, 68, 9, 3, 1, 190, 68, 9, 3, 1, 84, 68, 9, 3, 1, 186, - 68, 9, 3, 1, 201, 68, 9, 3, 1, 170, 68, 9, 3, 1, 181, 68, 9, 3, 1, 202, - 28, 9, 5, 1, 64, 28, 9, 5, 1, 199, 28, 9, 5, 1, 203, 28, 9, 5, 1, 187, - 28, 9, 5, 1, 70, 28, 9, 5, 1, 204, 28, 9, 5, 1, 194, 28, 9, 5, 1, 164, - 28, 9, 5, 1, 69, 28, 9, 5, 1, 200, 28, 9, 5, 1, 205, 28, 9, 5, 1, 148, - 28, 9, 5, 1, 171, 28, 9, 5, 1, 183, 28, 9, 5, 1, 78, 28, 9, 5, 1, 198, - 28, 9, 5, 1, 209, 28, 9, 5, 1, 135, 28, 9, 5, 1, 159, 28, 9, 5, 1, 190, - 28, 9, 5, 1, 84, 28, 9, 5, 1, 186, 28, 9, 5, 1, 201, 28, 9, 5, 1, 170, - 28, 9, 5, 1, 181, 28, 9, 5, 1, 202, 28, 9, 3, 1, 64, 28, 9, 3, 1, 199, - 28, 9, 3, 1, 203, 28, 9, 3, 1, 187, 28, 9, 3, 1, 70, 28, 9, 3, 1, 204, - 28, 9, 3, 1, 194, 28, 9, 3, 1, 164, 28, 9, 3, 1, 69, 28, 9, 3, 1, 200, - 28, 9, 3, 1, 205, 28, 9, 3, 1, 148, 28, 9, 3, 1, 171, 28, 9, 3, 1, 183, - 28, 9, 3, 1, 78, 28, 9, 3, 1, 198, 28, 9, 3, 1, 209, 28, 9, 3, 1, 135, - 28, 9, 3, 1, 159, 28, 9, 3, 1, 190, 28, 9, 3, 1, 84, 28, 9, 3, 1, 186, - 28, 9, 3, 1, 201, 28, 9, 3, 1, 170, 28, 9, 3, 1, 181, 28, 9, 3, 1, 202, - 28, 27, 244, 173, 239, 115, 28, 83, 240, 234, 239, 115, 28, 83, 240, 238, - 239, 115, 28, 83, 238, 108, 239, 115, 28, 83, 238, 106, 239, 115, 28, 83, - 239, 167, 239, 115, 28, 83, 239, 162, 239, 115, 28, 83, 237, 129, 239, - 115, 28, 83, 238, 105, 239, 115, 28, 83, 238, 107, 239, 115, 28, 83, 240, - 239, 42, 28, 27, 121, 42, 28, 27, 114, 42, 28, 27, 153, 42, 28, 27, 163, - 42, 28, 27, 168, 42, 28, 27, 169, 42, 28, 27, 179, 42, 28, 27, 176, 42, - 28, 27, 178, 42, 28, 83, 249, 18, 56, 60, 117, 236, 182, 56, 60, 82, 236, - 182, 56, 60, 117, 238, 88, 56, 60, 82, 238, 88, 56, 60, 117, 242, 59, - 249, 15, 236, 182, 56, 60, 82, 242, 59, 249, 15, 236, 182, 56, 60, 117, - 242, 59, 249, 15, 238, 88, 56, 60, 82, 242, 59, 249, 15, 238, 88, 56, 60, - 117, 238, 94, 249, 15, 236, 182, 56, 60, 82, 238, 94, 249, 15, 236, 182, - 56, 60, 117, 238, 94, 249, 15, 238, 88, 56, 60, 82, 238, 94, 249, 15, - 238, 88, 56, 60, 117, 79, 18, 184, 56, 60, 79, 117, 18, 37, 242, 64, 56, - 60, 79, 82, 18, 37, 242, 63, 56, 60, 82, 79, 18, 184, 56, 60, 117, 79, - 18, 244, 172, 56, 60, 79, 117, 18, 36, 242, 64, 56, 60, 79, 82, 18, 36, - 242, 63, 56, 60, 82, 79, 18, 244, 172, 56, 60, 117, 75, 18, 184, 56, 60, - 75, 117, 18, 37, 242, 64, 56, 60, 75, 82, 18, 37, 242, 63, 56, 60, 82, - 75, 18, 184, 56, 60, 117, 75, 18, 244, 172, 56, 60, 75, 117, 18, 36, 242, - 64, 56, 60, 75, 82, 18, 36, 242, 63, 56, 60, 82, 75, 18, 244, 172, 56, - 60, 117, 55, 18, 184, 56, 60, 55, 117, 18, 37, 242, 64, 56, 60, 75, 82, - 18, 37, 79, 242, 63, 56, 60, 79, 82, 18, 37, 75, 242, 63, 56, 60, 55, 82, - 18, 37, 242, 63, 56, 60, 79, 117, 18, 37, 75, 242, 64, 56, 60, 75, 117, - 18, 37, 79, 242, 64, 56, 60, 82, 55, 18, 184, 56, 60, 117, 55, 18, 244, - 172, 56, 60, 55, 117, 18, 36, 242, 64, 56, 60, 75, 82, 18, 36, 79, 242, - 63, 56, 60, 79, 82, 18, 36, 75, 242, 63, 56, 60, 55, 82, 18, 36, 242, 63, - 56, 60, 79, 117, 18, 36, 75, 242, 64, 56, 60, 75, 117, 18, 36, 79, 242, - 64, 56, 60, 82, 55, 18, 244, 172, 56, 60, 117, 79, 18, 236, 182, 56, 60, - 36, 82, 18, 37, 79, 242, 63, 56, 60, 37, 82, 18, 36, 79, 242, 63, 56, 60, - 79, 117, 18, 146, 242, 64, 56, 60, 79, 82, 18, 146, 242, 63, 56, 60, 37, - 117, 18, 36, 79, 242, 64, 56, 60, 36, 117, 18, 37, 79, 242, 64, 56, 60, - 82, 79, 18, 236, 182, 56, 60, 117, 75, 18, 236, 182, 56, 60, 36, 82, 18, - 37, 75, 242, 63, 56, 60, 37, 82, 18, 36, 75, 242, 63, 56, 60, 75, 117, - 18, 146, 242, 64, 56, 60, 75, 82, 18, 146, 242, 63, 56, 60, 37, 117, 18, - 36, 75, 242, 64, 56, 60, 36, 117, 18, 37, 75, 242, 64, 56, 60, 82, 75, - 18, 236, 182, 56, 60, 117, 55, 18, 236, 182, 56, 60, 36, 82, 18, 37, 55, - 242, 63, 56, 60, 37, 82, 18, 36, 55, 242, 63, 56, 60, 55, 117, 18, 146, - 242, 64, 56, 60, 75, 82, 18, 79, 146, 242, 63, 56, 60, 79, 82, 18, 75, - 146, 242, 63, 56, 60, 55, 82, 18, 146, 242, 63, 56, 60, 36, 75, 82, 18, - 37, 79, 242, 63, 56, 60, 37, 75, 82, 18, 36, 79, 242, 63, 56, 60, 36, 79, - 82, 18, 37, 75, 242, 63, 56, 60, 37, 79, 82, 18, 36, 75, 242, 63, 56, 60, - 79, 117, 18, 75, 146, 242, 64, 56, 60, 75, 117, 18, 79, 146, 242, 64, 56, - 60, 37, 117, 18, 36, 55, 242, 64, 56, 60, 36, 117, 18, 37, 55, 242, 64, - 56, 60, 82, 55, 18, 236, 182, 56, 60, 117, 42, 249, 15, 236, 182, 56, 60, - 82, 42, 249, 15, 236, 182, 56, 60, 117, 42, 249, 15, 238, 88, 56, 60, 82, - 42, 249, 15, 238, 88, 56, 60, 42, 236, 182, 56, 60, 42, 238, 88, 56, 60, - 79, 242, 66, 18, 37, 240, 222, 56, 60, 79, 42, 18, 37, 240, 226, 56, 60, - 42, 79, 18, 184, 56, 60, 79, 242, 66, 18, 36, 240, 222, 56, 60, 79, 42, - 18, 36, 240, 226, 56, 60, 42, 79, 18, 244, 172, 56, 60, 75, 242, 66, 18, - 37, 240, 222, 56, 60, 75, 42, 18, 37, 240, 226, 56, 60, 42, 75, 18, 184, - 56, 60, 75, 242, 66, 18, 36, 240, 222, 56, 60, 75, 42, 18, 36, 240, 226, - 56, 60, 42, 75, 18, 244, 172, 56, 60, 55, 242, 66, 18, 37, 240, 222, 56, - 60, 55, 42, 18, 37, 240, 226, 56, 60, 42, 55, 18, 184, 56, 60, 55, 242, - 66, 18, 36, 240, 222, 56, 60, 55, 42, 18, 36, 240, 226, 56, 60, 42, 55, - 18, 244, 172, 56, 60, 79, 242, 66, 18, 146, 240, 222, 56, 60, 79, 42, 18, - 146, 240, 226, 56, 60, 42, 79, 18, 236, 182, 56, 60, 75, 242, 66, 18, - 146, 240, 222, 56, 60, 75, 42, 18, 146, 240, 226, 56, 60, 42, 75, 18, - 236, 182, 56, 60, 55, 242, 66, 18, 146, 240, 222, 56, 60, 55, 42, 18, - 146, 240, 226, 56, 60, 42, 55, 18, 236, 182, 56, 60, 117, 253, 133, 79, - 18, 184, 56, 60, 117, 253, 133, 79, 18, 244, 172, 56, 60, 117, 253, 133, - 75, 18, 244, 172, 56, 60, 117, 253, 133, 75, 18, 184, 56, 60, 117, 239, - 125, 156, 37, 139, 149, 244, 172, 56, 60, 117, 239, 125, 156, 36, 139, - 149, 184, 56, 60, 117, 239, 125, 242, 94, 56, 60, 117, 244, 172, 56, 60, - 117, 253, 131, 56, 60, 117, 184, 56, 60, 117, 244, 185, 56, 60, 82, 244, - 172, 56, 60, 82, 253, 131, 56, 60, 82, 184, 56, 60, 82, 244, 185, 56, 60, - 117, 36, 18, 82, 184, 56, 60, 117, 75, 18, 82, 244, 185, 56, 60, 82, 36, - 18, 117, 184, 56, 60, 82, 75, 18, 117, 244, 185, 156, 136, 242, 67, 149, - 253, 101, 242, 111, 242, 67, 149, 253, 101, 240, 224, 242, 67, 149, 244, - 171, 240, 240, 242, 67, 149, 136, 242, 67, 149, 249, 48, 240, 240, 242, - 67, 149, 244, 171, 239, 231, 242, 67, 149, 245, 4, 240, 240, 242, 67, - 213, 242, 67, 36, 245, 4, 240, 240, 242, 67, 36, 244, 171, 239, 231, 242, - 67, 36, 249, 48, 240, 240, 242, 67, 36, 136, 242, 67, 36, 244, 171, 240, - 240, 242, 67, 36, 253, 101, 240, 224, 242, 67, 36, 253, 101, 242, 111, - 242, 67, 37, 136, 242, 67, 117, 242, 187, 242, 82, 242, 187, 250, 208, - 242, 187, 156, 253, 101, 242, 111, 242, 67, 37, 253, 101, 242, 111, 242, - 67, 239, 124, 149, 244, 172, 239, 124, 149, 184, 239, 124, 156, 244, 172, - 239, 124, 156, 36, 18, 149, 36, 18, 149, 184, 239, 124, 156, 36, 18, 149, - 184, 239, 124, 156, 36, 18, 156, 37, 18, 149, 244, 172, 239, 124, 156, - 36, 18, 156, 37, 18, 149, 184, 239, 124, 156, 184, 239, 124, 156, 37, 18, - 149, 244, 172, 239, 124, 156, 37, 18, 149, 36, 18, 149, 184, 86, 240, - 207, 58, 240, 207, 58, 30, 2, 241, 4, 240, 18, 58, 30, 237, 151, 86, 3, - 240, 207, 30, 2, 146, 244, 220, 30, 2, 55, 244, 220, 30, 2, 238, 39, 237, - 153, 244, 220, 30, 2, 156, 36, 139, 149, 37, 244, 220, 30, 2, 156, 37, - 139, 149, 36, 244, 220, 30, 2, 239, 125, 237, 153, 244, 220, 86, 3, 240, - 207, 58, 3, 240, 207, 86, 237, 137, 58, 237, 137, 86, 55, 237, 137, 58, - 55, 237, 137, 86, 235, 202, 58, 235, 202, 86, 236, 192, 219, 58, 236, - 192, 219, 86, 236, 192, 3, 219, 58, 236, 192, 3, 219, 86, 235, 190, 219, - 58, 235, 190, 219, 86, 235, 190, 3, 219, 58, 235, 190, 3, 219, 86, 235, - 190, 239, 173, 58, 235, 190, 239, 173, 86, 235, 241, 219, 58, 235, 241, - 219, 86, 235, 241, 3, 219, 58, 235, 241, 3, 219, 86, 235, 237, 219, 58, - 235, 237, 219, 86, 235, 237, 3, 219, 58, 235, 237, 3, 219, 86, 235, 237, - 239, 173, 58, 235, 237, 239, 173, 86, 239, 132, 58, 239, 132, 58, 240, - 221, 237, 151, 86, 3, 239, 132, 240, 75, 239, 188, 58, 240, 200, 242, - 118, 240, 200, 175, 2, 55, 244, 220, 238, 184, 86, 240, 200, 175, 2, 36, - 136, 231, 231, 175, 2, 37, 136, 231, 231, 175, 2, 149, 136, 231, 231, - 175, 2, 156, 136, 231, 231, 175, 2, 156, 37, 239, 124, 231, 231, 175, 2, - 254, 1, 253, 177, 156, 36, 239, 124, 231, 231, 36, 136, 86, 240, 200, 37, - 136, 86, 240, 200, 241, 0, 240, 215, 241, 0, 58, 240, 200, 156, 136, 241, - 0, 58, 240, 200, 149, 136, 241, 0, 58, 240, 200, 156, 36, 239, 124, 239, - 170, 249, 65, 156, 37, 239, 124, 239, 170, 249, 65, 149, 37, 239, 124, - 239, 170, 249, 65, 149, 36, 239, 124, 239, 170, 249, 65, 156, 136, 240, - 200, 149, 136, 240, 200, 86, 149, 37, 219, 86, 149, 36, 219, 86, 156, 36, - 219, 86, 156, 37, 219, 58, 240, 215, 30, 2, 36, 136, 231, 231, 30, 2, 37, - 136, 231, 231, 30, 2, 156, 36, 239, 125, 136, 231, 231, 30, 2, 149, 37, - 239, 125, 136, 231, 231, 58, 30, 2, 55, 238, 183, 244, 176, 58, 236, 192, - 239, 118, 2, 227, 236, 192, 239, 118, 2, 36, 136, 231, 231, 236, 192, - 239, 118, 2, 37, 136, 231, 231, 244, 222, 240, 200, 58, 30, 2, 156, 36, - 238, 93, 58, 30, 2, 149, 36, 238, 93, 58, 30, 2, 149, 37, 238, 93, 58, - 30, 2, 156, 37, 238, 93, 58, 175, 2, 156, 36, 238, 93, 58, 175, 2, 149, - 36, 238, 93, 58, 175, 2, 149, 37, 238, 93, 58, 175, 2, 156, 37, 238, 93, - 156, 36, 219, 156, 37, 219, 149, 36, 219, 58, 242, 82, 240, 207, 86, 242, - 82, 240, 207, 58, 242, 82, 3, 240, 207, 86, 242, 82, 3, 240, 207, 149, - 37, 219, 86, 254, 71, 2, 245, 168, 243, 71, 239, 107, 240, 166, 243, 74, - 86, 244, 178, 58, 244, 178, 238, 29, 236, 38, 249, 87, 238, 178, 245, - 151, 237, 186, 245, 151, 236, 89, 237, 79, 86, 237, 166, 58, 237, 166, - 242, 137, 249, 47, 242, 137, 56, 2, 242, 201, 242, 137, 56, 2, 170, 240, - 156, 58, 245, 186, 242, 163, 86, 245, 186, 242, 163, 224, 241, 3, 242, - 177, 244, 218, 240, 215, 86, 36, 239, 119, 242, 127, 86, 37, 239, 119, - 242, 127, 58, 36, 239, 119, 242, 127, 58, 75, 239, 119, 242, 127, 58, 37, - 239, 119, 242, 127, 58, 79, 239, 119, 242, 127, 248, 78, 18, 236, 254, - 241, 123, 57, 237, 83, 57, 238, 182, 57, 238, 186, 245, 246, 240, 133, - 242, 94, 254, 31, 249, 32, 244, 234, 137, 239, 43, 244, 234, 137, 238, - 22, 249, 86, 18, 238, 196, 244, 227, 90, 254, 81, 242, 10, 243, 142, 18, - 242, 13, 247, 239, 90, 254, 79, 248, 188, 240, 232, 54, 241, 179, 240, - 232, 54, 247, 52, 240, 232, 54, 244, 236, 240, 232, 54, 240, 181, 240, - 232, 54, 245, 50, 240, 232, 54, 242, 169, 240, 232, 54, 238, 147, 240, - 232, 54, 242, 142, 248, 172, 137, 241, 139, 58, 240, 79, 244, 235, 58, - 241, 81, 244, 235, 86, 241, 81, 244, 235, 58, 254, 71, 2, 245, 168, 245, - 84, 240, 224, 244, 229, 251, 184, 240, 224, 244, 229, 240, 115, 243, 108, - 57, 242, 142, 251, 217, 57, 240, 96, 241, 255, 242, 45, 240, 123, 244, - 38, 243, 33, 242, 31, 241, 174, 241, 121, 251, 188, 244, 141, 243, 203, - 239, 81, 236, 162, 237, 179, 238, 173, 241, 240, 58, 244, 199, 245, 125, - 58, 244, 199, 242, 241, 58, 244, 199, 245, 173, 58, 244, 199, 241, 44, - 58, 244, 199, 241, 63, 58, 244, 199, 245, 158, 86, 244, 199, 245, 125, - 86, 244, 199, 242, 241, 86, 244, 199, 245, 173, 86, 244, 199, 241, 44, - 86, 244, 199, 241, 63, 86, 244, 199, 245, 158, 86, 245, 195, 244, 219, - 58, 244, 218, 244, 219, 58, 240, 221, 244, 219, 86, 249, 199, 244, 219, - 58, 245, 195, 244, 219, 86, 244, 218, 244, 219, 86, 240, 221, 244, 219, - 58, 249, 199, 244, 219, 254, 112, 240, 167, 240, 224, 244, 208, 242, 111, - 244, 208, 242, 198, 242, 111, 242, 233, 242, 198, 238, 127, 242, 233, - 245, 30, 249, 134, 57, 245, 30, 241, 28, 57, 245, 30, 245, 5, 57, 249, - 17, 118, 242, 94, 249, 2, 118, 242, 94, 238, 166, 238, 89, 90, 238, 89, - 13, 54, 244, 128, 238, 99, 238, 89, 13, 54, 244, 129, 238, 99, 238, 89, - 13, 54, 244, 130, 238, 99, 238, 89, 13, 54, 244, 131, 238, 99, 238, 89, - 13, 54, 244, 132, 238, 99, 238, 89, 13, 54, 244, 133, 238, 99, 238, 89, - 13, 54, 244, 134, 238, 99, 238, 89, 13, 54, 241, 175, 238, 31, 86, 238, - 166, 238, 89, 90, 240, 152, 245, 157, 90, 231, 255, 245, 157, 90, 253, - 203, 241, 157, 253, 203, 241, 158, 253, 203, 241, 159, 253, 203, 241, - 160, 253, 203, 241, 161, 253, 203, 241, 162, 58, 175, 2, 49, 184, 58, - 175, 2, 225, 244, 215, 86, 175, 2, 58, 49, 184, 86, 175, 2, 225, 58, 244, - 215, 156, 245, 61, 238, 115, 86, 238, 115, 149, 245, 61, 238, 115, 58, - 238, 115, 238, 132, 240, 105, 57, 252, 196, 243, 95, 238, 169, 239, 7, - 242, 51, 244, 250, 242, 55, 244, 250, 149, 37, 241, 29, 241, 29, 156, 37, - 241, 29, 58, 250, 28, 86, 250, 28, 245, 16, 65, 82, 245, 16, 65, 235, - 191, 170, 82, 235, 191, 170, 242, 137, 170, 82, 242, 137, 170, 239, 159, - 26, 242, 94, 82, 26, 242, 94, 249, 0, 242, 100, 242, 94, 82, 249, 0, 242, - 100, 242, 94, 9, 242, 94, 239, 153, 58, 9, 242, 94, 239, 159, 9, 242, 94, - 241, 204, 242, 94, 249, 86, 137, 243, 83, 249, 28, 234, 63, 238, 77, 249, - 28, 235, 193, 238, 77, 82, 249, 28, 235, 193, 238, 77, 249, 28, 236, 250, - 238, 77, 86, 249, 28, 240, 218, 244, 178, 58, 249, 28, 240, 218, 244, - 178, 242, 188, 239, 159, 58, 244, 178, 28, 58, 244, 178, 249, 0, 242, - 100, 86, 244, 178, 86, 242, 100, 58, 244, 178, 239, 159, 86, 244, 178, - 82, 239, 159, 86, 244, 178, 239, 192, 244, 178, 239, 153, 58, 244, 178, - 82, 238, 77, 249, 0, 242, 100, 238, 77, 244, 207, 244, 96, 238, 77, 244, - 207, 240, 218, 86, 244, 178, 244, 207, 240, 218, 239, 192, 244, 178, 254, - 23, 240, 218, 86, 244, 178, 244, 207, 240, 218, 236, 227, 86, 244, 178, - 82, 244, 207, 240, 218, 236, 227, 86, 244, 178, 243, 17, 240, 218, 86, - 244, 178, 241, 78, 240, 218, 238, 77, 234, 63, 238, 77, 249, 0, 242, 100, - 234, 63, 238, 77, 82, 234, 63, 238, 77, 254, 23, 239, 230, 86, 18, 58, - 238, 110, 86, 238, 110, 58, 238, 110, 244, 207, 239, 230, 239, 159, 86, - 238, 110, 28, 249, 0, 242, 100, 244, 207, 240, 218, 244, 178, 82, 234, - 63, 239, 192, 238, 77, 237, 143, 248, 129, 238, 69, 237, 143, 82, 241, - 124, 237, 143, 239, 237, 82, 239, 237, 235, 193, 238, 77, 244, 207, 234, - 63, 238, 154, 238, 77, 82, 244, 207, 234, 63, 238, 154, 238, 77, 239, - 153, 58, 240, 200, 149, 37, 235, 250, 58, 240, 207, 156, 37, 235, 250, - 58, 240, 207, 149, 37, 239, 153, 58, 240, 207, 156, 37, 239, 153, 58, - 240, 207, 86, 240, 221, 244, 197, 58, 170, 117, 55, 143, 242, 82, 55, - 143, 82, 55, 143, 82, 242, 66, 242, 60, 244, 192, 238, 76, 167, 238, 78, - 82, 242, 66, 244, 192, 238, 76, 167, 238, 78, 82, 42, 242, 60, 244, 192, - 238, 76, 167, 238, 78, 82, 42, 244, 192, 238, 76, 167, 238, 78, 242, 141, - 252, 177, 238, 113, 25, 238, 78, 82, 236, 186, 167, 238, 78, 82, 244, - 218, 236, 186, 167, 238, 78, 82, 86, 242, 178, 241, 3, 82, 86, 244, 218, - 240, 215, 242, 177, 242, 178, 241, 3, 242, 177, 244, 218, 240, 215, 242, - 82, 36, 236, 187, 238, 78, 242, 82, 37, 236, 187, 238, 78, 242, 82, 238, - 140, 36, 236, 187, 238, 78, 242, 82, 238, 140, 37, 236, 187, 238, 78, - 242, 82, 235, 237, 160, 226, 238, 78, 242, 82, 235, 190, 160, 226, 238, - 78, 82, 235, 237, 160, 238, 76, 167, 238, 78, 82, 235, 190, 160, 238, 76, - 167, 238, 78, 82, 235, 237, 160, 226, 238, 78, 82, 235, 190, 160, 226, - 238, 78, 117, 36, 239, 139, 244, 202, 226, 238, 78, 117, 37, 239, 139, - 244, 202, 226, 238, 78, 242, 82, 36, 244, 175, 226, 238, 78, 242, 82, 37, - 244, 175, 226, 238, 78, 240, 201, 239, 115, 28, 27, 121, 240, 201, 239, - 115, 28, 27, 114, 240, 201, 239, 115, 28, 27, 153, 240, 201, 239, 115, - 28, 27, 163, 240, 201, 239, 115, 28, 27, 168, 240, 201, 239, 115, 28, 27, - 169, 240, 201, 239, 115, 28, 27, 179, 240, 201, 239, 115, 28, 27, 176, - 240, 201, 239, 115, 28, 27, 178, 240, 201, 239, 115, 28, 83, 249, 18, - 240, 201, 28, 23, 27, 121, 240, 201, 28, 23, 27, 114, 240, 201, 28, 23, - 27, 153, 240, 201, 28, 23, 27, 163, 240, 201, 28, 23, 27, 168, 240, 201, - 28, 23, 27, 169, 240, 201, 28, 23, 27, 179, 240, 201, 28, 23, 27, 176, - 240, 201, 28, 23, 27, 178, 240, 201, 28, 23, 83, 249, 18, 240, 201, 239, - 115, 28, 23, 27, 121, 240, 201, 239, 115, 28, 23, 27, 114, 240, 201, 239, - 115, 28, 23, 27, 153, 240, 201, 239, 115, 28, 23, 27, 163, 240, 201, 239, - 115, 28, 23, 27, 168, 240, 201, 239, 115, 28, 23, 27, 169, 240, 201, 239, - 115, 28, 23, 27, 179, 240, 201, 239, 115, 28, 23, 27, 176, 240, 201, 239, - 115, 28, 23, 27, 178, 240, 201, 239, 115, 28, 23, 83, 249, 18, 82, 237, - 109, 63, 52, 82, 244, 181, 249, 2, 52, 82, 63, 52, 82, 244, 177, 249, 2, - 52, 240, 60, 244, 180, 63, 52, 82, 236, 161, 63, 52, 234, 65, 63, 52, 82, - 234, 65, 63, 52, 242, 105, 234, 65, 63, 52, 82, 242, 105, 234, 65, 63, - 52, 86, 63, 52, 241, 88, 237, 105, 63, 237, 116, 241, 88, 235, 212, 63, - 237, 116, 86, 63, 237, 116, 82, 86, 242, 141, 220, 18, 63, 52, 82, 86, - 242, 141, 210, 18, 63, 52, 245, 196, 86, 63, 52, 82, 234, 70, 86, 63, 52, - 236, 159, 58, 63, 52, 237, 74, 58, 63, 52, 236, 246, 239, 153, 58, 63, - 52, 236, 129, 239, 153, 58, 63, 52, 82, 149, 235, 192, 58, 63, 52, 82, - 156, 235, 192, 58, 63, 52, 241, 70, 149, 235, 192, 58, 63, 52, 241, 70, - 156, 235, 192, 58, 63, 52, 28, 82, 58, 63, 52, 235, 189, 63, 52, 234, 64, - 244, 181, 249, 2, 52, 234, 64, 63, 52, 234, 64, 244, 177, 249, 2, 52, 82, - 234, 64, 244, 181, 249, 2, 52, 82, 234, 64, 63, 52, 82, 234, 64, 244, - 177, 249, 2, 52, 235, 186, 63, 52, 82, 234, 61, 63, 52, 236, 83, 63, 52, - 82, 236, 83, 63, 52, 236, 29, 63, 52, 58, 240, 221, 2, 241, 13, 227, 18, - 2, 227, 240, 214, 137, 240, 236, 239, 176, 149, 37, 242, 86, 2, 227, 156, - 36, 242, 86, 2, 227, 36, 245, 33, 244, 251, 37, 245, 33, 244, 251, 213, - 245, 33, 244, 251, 244, 222, 75, 244, 184, 244, 222, 79, 244, 184, 36, - 18, 37, 42, 237, 119, 36, 18, 37, 244, 184, 36, 238, 122, 165, 37, 244, - 184, 165, 36, 244, 184, 75, 249, 35, 2, 175, 47, 241, 203, 241, 17, 254, - 216, 146, 248, 43, 58, 235, 244, 239, 132, 58, 235, 244, 240, 221, 2, - 126, 244, 232, 58, 235, 244, 240, 221, 2, 63, 244, 232, 58, 30, 2, 126, - 244, 232, 58, 30, 2, 63, 244, 232, 8, 36, 58, 30, 110, 8, 37, 58, 30, - 110, 8, 36, 160, 110, 8, 37, 160, 110, 8, 36, 42, 160, 110, 8, 37, 42, - 160, 110, 210, 238, 94, 52, 220, 238, 94, 52, 235, 236, 242, 215, 175, - 52, 238, 87, 242, 215, 175, 52, 37, 59, 2, 28, 244, 212, 165, 126, 52, - 165, 63, 52, 165, 36, 37, 52, 165, 126, 42, 52, 165, 63, 42, 52, 165, 36, - 37, 42, 52, 165, 126, 59, 248, 254, 143, 165, 63, 59, 248, 254, 143, 165, - 126, 42, 59, 248, 254, 143, 165, 63, 42, 59, 248, 254, 143, 165, 63, 239, - 196, 52, 32, 33, 243, 46, 32, 33, 241, 142, 32, 33, 241, 143, 32, 33, - 240, 32, 32, 33, 241, 144, 32, 33, 240, 33, 32, 33, 240, 39, 32, 33, 238, - 204, 32, 33, 241, 145, 32, 33, 240, 34, 32, 33, 240, 40, 32, 33, 238, - 205, 32, 33, 240, 45, 32, 33, 238, 210, 32, 33, 238, 225, 32, 33, 237, - 188, 32, 33, 241, 146, 32, 33, 240, 35, 32, 33, 240, 41, 32, 33, 238, - 206, 32, 33, 240, 46, 32, 33, 238, 211, 32, 33, 238, 226, 32, 33, 237, - 189, 32, 33, 240, 50, 32, 33, 238, 215, 32, 33, 238, 230, 32, 33, 237, - 193, 32, 33, 238, 240, 32, 33, 237, 203, 32, 33, 237, 223, 32, 33, 237, - 2, 32, 33, 241, 147, 32, 33, 240, 36, 32, 33, 240, 42, 32, 33, 238, 207, - 32, 33, 240, 47, 32, 33, 238, 212, 32, 33, 238, 227, 32, 33, 237, 190, - 32, 33, 240, 51, 32, 33, 238, 216, 32, 33, 238, 231, 32, 33, 237, 194, - 32, 33, 238, 241, 32, 33, 237, 204, 32, 33, 237, 224, 32, 33, 237, 3, 32, - 33, 240, 54, 32, 33, 238, 219, 32, 33, 238, 234, 32, 33, 237, 197, 32, - 33, 238, 244, 32, 33, 237, 207, 32, 33, 237, 227, 32, 33, 237, 6, 32, 33, - 238, 250, 32, 33, 237, 213, 32, 33, 237, 233, 32, 33, 237, 12, 32, 33, - 237, 243, 32, 33, 237, 22, 32, 33, 237, 37, 32, 33, 236, 98, 32, 33, 241, - 148, 32, 33, 240, 37, 32, 33, 240, 43, 32, 33, 238, 208, 32, 33, 240, 48, - 32, 33, 238, 213, 32, 33, 238, 228, 32, 33, 237, 191, 32, 33, 240, 52, - 32, 33, 238, 217, 32, 33, 238, 232, 32, 33, 237, 195, 32, 33, 238, 242, - 32, 33, 237, 205, 32, 33, 237, 225, 32, 33, 237, 4, 32, 33, 240, 55, 32, - 33, 238, 220, 32, 33, 238, 235, 32, 33, 237, 198, 32, 33, 238, 245, 32, - 33, 237, 208, 32, 33, 237, 228, 32, 33, 237, 7, 32, 33, 238, 251, 32, 33, - 237, 214, 32, 33, 237, 234, 32, 33, 237, 13, 32, 33, 237, 244, 32, 33, - 237, 23, 32, 33, 237, 38, 32, 33, 236, 99, 32, 33, 240, 57, 32, 33, 238, - 222, 32, 33, 238, 237, 32, 33, 237, 200, 32, 33, 238, 247, 32, 33, 237, - 210, 32, 33, 237, 230, 32, 33, 237, 9, 32, 33, 238, 253, 32, 33, 237, - 216, 32, 33, 237, 236, 32, 33, 237, 15, 32, 33, 237, 246, 32, 33, 237, - 25, 32, 33, 237, 40, 32, 33, 236, 101, 32, 33, 239, 0, 32, 33, 237, 219, - 32, 33, 237, 239, 32, 33, 237, 18, 32, 33, 237, 249, 32, 33, 237, 28, 32, - 33, 237, 43, 32, 33, 236, 104, 32, 33, 237, 253, 32, 33, 237, 32, 32, 33, - 237, 47, 32, 33, 236, 108, 32, 33, 237, 52, 32, 33, 236, 113, 32, 33, - 236, 119, 32, 33, 236, 12, 32, 33, 241, 149, 32, 33, 240, 38, 32, 33, - 240, 44, 32, 33, 238, 209, 32, 33, 240, 49, 32, 33, 238, 214, 32, 33, - 238, 229, 32, 33, 237, 192, 32, 33, 240, 53, 32, 33, 238, 218, 32, 33, - 238, 233, 32, 33, 237, 196, 32, 33, 238, 243, 32, 33, 237, 206, 32, 33, - 237, 226, 32, 33, 237, 5, 32, 33, 240, 56, 32, 33, 238, 221, 32, 33, 238, - 236, 32, 33, 237, 199, 32, 33, 238, 246, 32, 33, 237, 209, 32, 33, 237, - 229, 32, 33, 237, 8, 32, 33, 238, 252, 32, 33, 237, 215, 32, 33, 237, - 235, 32, 33, 237, 14, 32, 33, 237, 245, 32, 33, 237, 24, 32, 33, 237, 39, - 32, 33, 236, 100, 32, 33, 240, 58, 32, 33, 238, 223, 32, 33, 238, 238, - 32, 33, 237, 201, 32, 33, 238, 248, 32, 33, 237, 211, 32, 33, 237, 231, - 32, 33, 237, 10, 32, 33, 238, 254, 32, 33, 237, 217, 32, 33, 237, 237, - 32, 33, 237, 16, 32, 33, 237, 247, 32, 33, 237, 26, 32, 33, 237, 41, 32, - 33, 236, 102, 32, 33, 239, 1, 32, 33, 237, 220, 32, 33, 237, 240, 32, 33, - 237, 19, 32, 33, 237, 250, 32, 33, 237, 29, 32, 33, 237, 44, 32, 33, 236, - 105, 32, 33, 237, 254, 32, 33, 237, 33, 32, 33, 237, 48, 32, 33, 236, - 109, 32, 33, 237, 53, 32, 33, 236, 114, 32, 33, 236, 120, 32, 33, 236, - 13, 32, 33, 240, 59, 32, 33, 238, 224, 32, 33, 238, 239, 32, 33, 237, - 202, 32, 33, 238, 249, 32, 33, 237, 212, 32, 33, 237, 232, 32, 33, 237, - 11, 32, 33, 238, 255, 32, 33, 237, 218, 32, 33, 237, 238, 32, 33, 237, - 17, 32, 33, 237, 248, 32, 33, 237, 27, 32, 33, 237, 42, 32, 33, 236, 103, - 32, 33, 239, 2, 32, 33, 237, 221, 32, 33, 237, 241, 32, 33, 237, 20, 32, - 33, 237, 251, 32, 33, 237, 30, 32, 33, 237, 45, 32, 33, 236, 106, 32, 33, - 237, 255, 32, 33, 237, 34, 32, 33, 237, 49, 32, 33, 236, 110, 32, 33, - 237, 54, 32, 33, 236, 115, 32, 33, 236, 121, 32, 33, 236, 14, 32, 33, - 239, 3, 32, 33, 237, 222, 32, 33, 237, 242, 32, 33, 237, 21, 32, 33, 237, - 252, 32, 33, 237, 31, 32, 33, 237, 46, 32, 33, 236, 107, 32, 33, 238, 0, - 32, 33, 237, 35, 32, 33, 237, 50, 32, 33, 236, 111, 32, 33, 237, 55, 32, - 33, 236, 116, 32, 33, 236, 122, 32, 33, 236, 15, 32, 33, 238, 1, 32, 33, - 237, 36, 32, 33, 237, 51, 32, 33, 236, 112, 32, 33, 237, 56, 32, 33, 236, - 117, 32, 33, 236, 123, 32, 33, 236, 16, 32, 33, 237, 57, 32, 33, 236, - 118, 32, 33, 236, 124, 32, 33, 236, 17, 32, 33, 236, 125, 32, 33, 236, - 18, 32, 33, 236, 19, 32, 33, 235, 215, 63, 237, 120, 59, 2, 55, 122, 63, - 237, 120, 59, 2, 42, 55, 122, 126, 42, 59, 2, 55, 122, 63, 42, 59, 2, 55, - 122, 36, 37, 42, 59, 2, 55, 122, 63, 237, 120, 59, 248, 254, 143, 126, - 42, 59, 248, 254, 143, 63, 42, 59, 248, 254, 143, 220, 59, 2, 146, 122, - 210, 59, 2, 146, 122, 210, 242, 59, 52, 220, 242, 59, 52, 126, 42, 249, - 15, 52, 63, 42, 249, 15, 52, 126, 242, 59, 249, 15, 52, 63, 242, 59, 249, - 15, 52, 63, 237, 120, 242, 59, 249, 15, 52, 63, 59, 2, 242, 118, 244, - 239, 210, 59, 139, 143, 220, 59, 139, 143, 63, 59, 2, 249, 88, 2, 55, - 122, 63, 59, 2, 249, 88, 2, 42, 55, 122, 63, 237, 120, 59, 2, 244, 182, - 63, 237, 120, 59, 2, 249, 88, 2, 55, 122, 63, 237, 120, 59, 2, 249, 88, - 2, 42, 55, 122, 126, 236, 196, 63, 236, 196, 126, 42, 236, 196, 63, 42, - 236, 196, 126, 59, 139, 86, 239, 132, 63, 59, 139, 86, 239, 132, 126, 59, - 248, 254, 253, 99, 139, 86, 239, 132, 63, 59, 248, 254, 253, 99, 139, 86, - 239, 132, 244, 177, 249, 17, 18, 244, 181, 249, 2, 52, 244, 177, 249, 2, - 18, 244, 181, 249, 17, 52, 244, 177, 249, 17, 59, 2, 128, 244, 177, 249, - 2, 59, 2, 128, 244, 181, 249, 2, 59, 2, 128, 244, 181, 249, 17, 59, 2, - 128, 244, 177, 249, 17, 59, 18, 244, 177, 249, 2, 52, 244, 177, 249, 2, - 59, 18, 244, 181, 249, 2, 52, 244, 181, 249, 2, 59, 18, 244, 181, 249, - 17, 52, 244, 181, 249, 17, 59, 18, 244, 177, 249, 17, 52, 242, 120, 239, - 125, 239, 149, 240, 247, 238, 109, 240, 247, 239, 125, 239, 149, 242, - 120, 238, 109, 244, 181, 249, 2, 59, 239, 149, 244, 177, 249, 2, 52, 244, - 177, 249, 2, 59, 239, 149, 244, 181, 249, 2, 52, 240, 247, 239, 125, 239, - 149, 244, 177, 249, 2, 52, 242, 120, 239, 125, 239, 149, 244, 181, 249, - 2, 52, 244, 177, 249, 2, 59, 239, 149, 244, 177, 249, 17, 52, 244, 177, - 249, 17, 59, 239, 149, 244, 177, 249, 2, 52, 249, 90, 59, 239, 119, 240, - 30, 184, 59, 239, 119, 63, 249, 120, 240, 252, 239, 176, 59, 239, 119, - 63, 249, 120, 240, 252, 237, 121, 59, 239, 119, 220, 249, 120, 240, 252, - 237, 125, 59, 239, 119, 220, 249, 120, 240, 252, 236, 195, 238, 56, 253, - 133, 238, 87, 52, 239, 41, 253, 133, 235, 236, 52, 253, 121, 253, 133, - 235, 236, 52, 242, 80, 253, 133, 235, 236, 52, 253, 121, 253, 133, 238, - 87, 59, 2, 242, 119, 253, 121, 253, 133, 235, 236, 59, 2, 244, 212, 149, - 37, 236, 69, 238, 87, 52, 149, 36, 236, 69, 235, 236, 52, 235, 236, 242, - 77, 175, 52, 238, 87, 242, 77, 175, 52, 63, 59, 53, 207, 126, 52, 126, - 59, 53, 207, 63, 52, 207, 63, 59, 53, 126, 52, 63, 59, 2, 249, 4, 45, - 126, 59, 2, 249, 4, 45, 63, 59, 240, 249, 170, 36, 37, 59, 240, 249, 3, - 240, 200, 210, 237, 120, 59, 248, 254, 3, 240, 200, 36, 133, 75, 37, 133, - 79, 239, 142, 36, 133, 79, 37, 133, 75, 239, 142, 75, 133, 37, 79, 133, - 36, 239, 142, 75, 133, 36, 79, 133, 37, 239, 142, 36, 133, 75, 37, 133, - 75, 239, 142, 75, 133, 37, 79, 133, 37, 239, 142, 36, 133, 79, 37, 133, - 79, 239, 142, 75, 133, 36, 79, 133, 36, 239, 142, 126, 154, 2, 133, 75, - 139, 143, 63, 154, 2, 133, 75, 139, 143, 210, 154, 2, 133, 37, 139, 143, - 220, 154, 2, 133, 37, 139, 143, 126, 154, 2, 133, 79, 139, 143, 63, 154, - 2, 133, 79, 139, 143, 210, 154, 2, 133, 36, 139, 143, 220, 154, 2, 133, - 36, 139, 143, 126, 154, 2, 133, 75, 248, 254, 143, 63, 154, 2, 133, 75, - 248, 254, 143, 210, 154, 2, 133, 37, 248, 254, 143, 220, 154, 2, 133, 37, - 248, 254, 143, 126, 154, 2, 133, 79, 248, 254, 143, 63, 154, 2, 133, 79, - 248, 254, 143, 210, 154, 2, 133, 36, 248, 254, 143, 220, 154, 2, 133, 36, - 248, 254, 143, 126, 154, 2, 133, 75, 53, 126, 154, 2, 133, 244, 185, 210, - 154, 2, 133, 36, 242, 99, 210, 154, 2, 133, 184, 63, 154, 2, 133, 75, 53, - 63, 154, 2, 133, 244, 185, 220, 154, 2, 133, 36, 242, 99, 220, 154, 2, - 133, 184, 126, 154, 2, 133, 75, 53, 63, 154, 2, 133, 253, 131, 126, 154, - 2, 133, 79, 53, 63, 154, 2, 133, 244, 185, 63, 154, 2, 133, 75, 53, 126, - 154, 2, 133, 253, 131, 63, 154, 2, 133, 79, 53, 126, 154, 2, 133, 244, - 185, 126, 154, 2, 133, 75, 53, 165, 244, 189, 126, 154, 2, 133, 79, 244, - 188, 165, 244, 189, 63, 154, 2, 133, 75, 53, 165, 244, 189, 63, 154, 2, - 133, 79, 244, 188, 165, 244, 189, 210, 154, 2, 133, 36, 242, 99, 220, - 154, 2, 133, 184, 220, 154, 2, 133, 36, 242, 99, 210, 154, 2, 133, 184, - 37, 42, 59, 2, 241, 4, 245, 25, 242, 61, 25, 53, 63, 52, 229, 239, 168, - 53, 63, 52, 126, 59, 53, 229, 223, 63, 59, 53, 229, 223, 63, 59, 53, 242, - 93, 80, 76, 206, 53, 126, 52, 126, 59, 240, 249, 237, 110, 196, 53, 63, - 52, 242, 76, 53, 63, 52, 126, 59, 240, 249, 240, 237, 239, 121, 53, 126, - 52, 36, 249, 102, 244, 182, 37, 249, 102, 244, 182, 75, 249, 102, 244, - 182, 79, 249, 102, 244, 182, 242, 59, 55, 253, 99, 237, 185, 255, 27, - 239, 129, 248, 82, 255, 27, 239, 129, 249, 173, 242, 81, 36, 58, 244, - 175, 110, 37, 58, 244, 175, 110, 36, 58, 236, 47, 37, 58, 236, 47, 255, - 27, 239, 129, 36, 244, 211, 110, 255, 27, 239, 129, 37, 244, 211, 110, - 255, 27, 239, 129, 36, 241, 43, 110, 255, 27, 239, 129, 37, 241, 43, 110, - 36, 30, 226, 2, 238, 75, 37, 30, 226, 2, 238, 75, 36, 30, 226, 2, 249, - 121, 254, 214, 253, 121, 240, 213, 37, 30, 226, 2, 249, 121, 254, 214, - 242, 80, 240, 213, 36, 30, 226, 2, 249, 121, 254, 214, 242, 80, 240, 213, - 37, 30, 226, 2, 249, 121, 254, 214, 253, 121, 240, 213, 36, 160, 226, 2, - 227, 37, 160, 226, 2, 227, 36, 253, 133, 206, 110, 37, 253, 133, 196, - 110, 42, 36, 253, 133, 196, 110, 42, 37, 253, 133, 206, 110, 36, 86, 239, - 139, 244, 202, 110, 37, 86, 239, 139, 244, 202, 110, 242, 118, 242, 143, - 55, 242, 193, 244, 176, 239, 136, 160, 240, 236, 244, 172, 37, 160, 242, - 49, 2, 240, 207, 239, 136, 37, 160, 2, 227, 160, 2, 255, 29, 240, 235, - 244, 196, 242, 117, 238, 128, 160, 240, 236, 244, 172, 238, 128, 160, - 240, 236, 253, 131, 242, 60, 242, 117, 224, 242, 117, 160, 2, 238, 75, - 224, 160, 2, 238, 75, 241, 2, 160, 240, 236, 253, 131, 241, 2, 160, 240, - 236, 244, 185, 239, 136, 160, 2, 249, 0, 253, 176, 242, 112, 254, 214, - 59, 239, 119, 75, 18, 184, 239, 136, 160, 2, 249, 0, 253, 176, 242, 112, - 254, 214, 59, 239, 119, 75, 18, 244, 172, 239, 136, 160, 2, 249, 0, 253, - 176, 242, 112, 254, 214, 59, 239, 119, 79, 18, 184, 239, 136, 160, 2, - 249, 0, 253, 176, 242, 112, 254, 214, 59, 239, 119, 79, 18, 244, 172, - 239, 136, 160, 2, 249, 0, 253, 176, 242, 112, 254, 214, 59, 239, 119, 37, - 18, 253, 131, 239, 136, 160, 2, 249, 0, 253, 176, 242, 112, 254, 214, 59, - 239, 119, 36, 18, 253, 131, 239, 136, 160, 2, 249, 0, 253, 176, 242, 112, - 254, 214, 59, 239, 119, 37, 18, 244, 185, 239, 136, 160, 2, 249, 0, 253, - 176, 242, 112, 254, 214, 59, 239, 119, 36, 18, 244, 185, 224, 244, 216, - 250, 69, 244, 216, 253, 232, 2, 239, 130, 244, 216, 253, 232, 2, 3, 175, - 47, 244, 216, 253, 232, 2, 37, 59, 47, 244, 216, 253, 232, 2, 36, 59, 47, - 175, 2, 146, 143, 28, 55, 143, 28, 238, 124, 28, 240, 219, 239, 144, 28, - 235, 225, 175, 241, 17, 254, 216, 146, 253, 99, 18, 253, 121, 136, 241, - 17, 254, 216, 55, 143, 175, 2, 236, 171, 170, 28, 231, 236, 239, 156, 57, - 75, 59, 240, 249, 240, 200, 28, 58, 240, 215, 28, 240, 215, 28, 237, 110, - 28, 235, 235, 175, 2, 3, 175, 139, 253, 173, 184, 175, 2, 225, 146, 242, - 24, 139, 253, 173, 184, 240, 227, 242, 120, 239, 125, 242, 91, 240, 227, - 240, 247, 239, 125, 242, 91, 240, 227, 238, 77, 240, 227, 3, 240, 200, - 240, 227, 240, 207, 225, 242, 160, 240, 168, 239, 118, 2, 49, 47, 239, - 118, 2, 238, 75, 255, 29, 254, 214, 219, 239, 118, 2, 242, 246, 254, 228, - 241, 12, 37, 239, 118, 53, 36, 219, 36, 239, 118, 242, 99, 55, 143, 55, - 253, 99, 242, 99, 37, 219, 242, 200, 2, 36, 136, 231, 231, 242, 200, 2, - 37, 136, 231, 231, 86, 241, 45, 244, 241, 2, 36, 136, 231, 231, 244, 241, - 2, 37, 136, 231, 231, 58, 237, 140, 86, 237, 140, 36, 242, 170, 242, 143, - 37, 242, 170, 242, 143, 36, 42, 242, 170, 242, 143, 37, 42, 242, 170, - 242, 143, 238, 18, 238, 121, 254, 192, 249, 25, 238, 121, 240, 91, 241, - 68, 2, 55, 143, 236, 126, 238, 122, 30, 2, 238, 194, 240, 134, 239, 32, - 254, 85, 242, 12, 239, 138, 242, 61, 25, 18, 240, 205, 238, 124, 242, 61, - 25, 18, 240, 205, 239, 160, 2, 229, 47, 238, 111, 139, 18, 240, 205, 238, - 124, 243, 136, 244, 104, 235, 233, 235, 241, 239, 118, 2, 36, 136, 231, - 231, 235, 241, 239, 118, 2, 37, 136, 231, 231, 86, 240, 221, 2, 79, 52, - 86, 239, 188, 58, 175, 2, 79, 52, 86, 175, 2, 79, 52, 236, 50, 58, 240, - 207, 236, 50, 86, 240, 207, 236, 50, 58, 239, 132, 236, 50, 86, 239, 132, - 236, 50, 58, 240, 200, 236, 50, 86, 240, 200, 236, 31, 240, 219, 240, - 230, 223, 240, 230, 2, 239, 130, 240, 219, 240, 230, 2, 146, 122, 253, - 202, 239, 144, 253, 202, 240, 219, 239, 144, 42, 244, 212, 242, 59, 244, - 212, 235, 237, 242, 141, 160, 110, 235, 190, 242, 141, 160, 110, 248, - 131, 247, 97, 244, 186, 28, 49, 223, 244, 186, 28, 249, 4, 223, 244, 186, - 28, 244, 241, 223, 244, 186, 244, 206, 239, 168, 2, 227, 244, 186, 244, - 206, 239, 168, 2, 244, 212, 244, 186, 30, 236, 48, 223, 244, 186, 30, - 244, 206, 223, 225, 240, 202, 18, 223, 225, 240, 202, 112, 223, 244, 186, - 244, 241, 223, 243, 229, 225, 252, 179, 238, 131, 2, 238, 86, 238, 94, - 239, 135, 223, 243, 114, 250, 41, 238, 86, 239, 135, 2, 42, 122, 239, - 135, 241, 105, 2, 242, 91, 236, 249, 239, 22, 235, 236, 236, 138, 217, - 236, 201, 2, 236, 226, 250, 42, 242, 171, 245, 36, 217, 236, 201, 2, 236, - 69, 250, 42, 242, 171, 245, 36, 217, 236, 201, 141, 239, 31, 253, 173, - 245, 36, 239, 135, 242, 171, 119, 244, 180, 223, 238, 49, 239, 135, 223, - 239, 135, 2, 126, 59, 2, 128, 239, 135, 2, 244, 241, 57, 239, 135, 2, - 235, 238, 239, 135, 2, 242, 109, 239, 135, 2, 239, 130, 239, 135, 2, 238, - 75, 244, 251, 244, 222, 36, 239, 118, 223, 255, 27, 239, 129, 242, 185, - 236, 75, 255, 27, 239, 129, 242, 185, 241, 239, 255, 27, 239, 129, 242, - 185, 237, 81, 249, 4, 25, 2, 3, 175, 47, 249, 4, 25, 2, 157, 230, 47, - 249, 4, 25, 2, 229, 47, 249, 4, 25, 2, 49, 45, 249, 4, 25, 2, 229, 45, - 249, 4, 25, 2, 238, 83, 114, 249, 4, 25, 2, 86, 219, 244, 197, 25, 2, - 244, 192, 47, 244, 197, 25, 2, 49, 45, 244, 197, 25, 2, 240, 247, 244, - 215, 244, 197, 25, 2, 242, 120, 244, 215, 249, 4, 25, 254, 214, 36, 136, - 240, 200, 249, 4, 25, 254, 214, 37, 136, 240, 200, 244, 139, 112, 244, - 234, 239, 138, 235, 191, 25, 2, 49, 47, 235, 191, 25, 2, 238, 75, 237, - 128, 241, 244, 2, 242, 80, 241, 128, 245, 193, 239, 138, 235, 191, 25, - 254, 214, 36, 136, 240, 200, 235, 191, 25, 254, 214, 37, 136, 240, 200, - 28, 235, 191, 25, 2, 157, 240, 203, 235, 191, 25, 254, 214, 42, 240, 200, - 28, 239, 156, 57, 249, 4, 25, 254, 214, 219, 244, 197, 25, 254, 214, 219, - 235, 191, 25, 254, 214, 219, 239, 218, 239, 138, 239, 76, 239, 218, 239, - 138, 255, 27, 239, 129, 238, 53, 236, 75, 236, 84, 112, 237, 152, 236, - 48, 2, 227, 244, 206, 2, 244, 197, 57, 244, 206, 2, 239, 130, 236, 48, 2, - 239, 130, 236, 48, 2, 240, 202, 249, 46, 244, 206, 2, 240, 202, 253, 186, - 244, 206, 53, 235, 238, 236, 48, 53, 242, 109, 244, 206, 53, 253, 99, 53, - 235, 238, 236, 48, 53, 253, 99, 53, 242, 109, 244, 206, 242, 99, 18, 242, - 160, 2, 242, 109, 236, 48, 242, 99, 18, 242, 160, 2, 235, 238, 242, 77, - 244, 206, 2, 241, 76, 242, 77, 236, 48, 2, 241, 76, 42, 30, 235, 238, 42, - 30, 242, 109, 242, 77, 244, 206, 2, 242, 246, 18, 245, 193, 239, 138, - 240, 202, 18, 2, 49, 47, 240, 202, 112, 2, 49, 47, 42, 240, 202, 249, 46, - 42, 240, 202, 253, 186, 225, 236, 76, 240, 202, 249, 46, 225, 236, 76, - 240, 202, 253, 186, 241, 79, 244, 222, 253, 186, 241, 79, 244, 222, 249, - 46, 240, 202, 112, 236, 221, 240, 202, 249, 46, 240, 202, 18, 2, 242, 65, - 244, 239, 240, 202, 112, 2, 242, 65, 244, 239, 240, 202, 18, 2, 146, 244, - 189, 240, 202, 112, 2, 146, 244, 189, 240, 202, 18, 2, 42, 239, 130, 240, - 202, 18, 2, 238, 75, 240, 202, 18, 2, 42, 238, 75, 3, 254, 199, 2, 238, - 75, 240, 202, 112, 2, 42, 239, 130, 240, 202, 112, 2, 42, 238, 75, 255, - 27, 239, 129, 243, 94, 232, 15, 255, 27, 239, 129, 248, 19, 232, 15, 242, - 61, 25, 2, 49, 45, 238, 111, 2, 49, 47, 242, 59, 146, 253, 99, 2, 42, 55, - 122, 242, 59, 146, 253, 99, 2, 242, 59, 55, 122, 229, 239, 168, 2, 49, - 47, 229, 239, 168, 2, 242, 120, 244, 215, 240, 225, 244, 197, 240, 163, - 238, 192, 2, 49, 47, 242, 61, 2, 238, 77, 242, 93, 80, 139, 2, 157, 240, - 203, 235, 239, 80, 112, 80, 76, 242, 61, 25, 53, 249, 4, 57, 249, 4, 25, - 53, 242, 61, 57, 242, 61, 25, 53, 229, 223, 42, 244, 214, 242, 88, 225, - 236, 212, 242, 61, 243, 0, 244, 171, 236, 212, 242, 61, 243, 0, 242, 61, - 25, 2, 225, 248, 253, 53, 18, 225, 248, 253, 45, 237, 113, 2, 249, 28, - 248, 253, 47, 206, 2, 175, 240, 235, 196, 2, 175, 240, 235, 206, 2, 239, - 126, 167, 47, 196, 2, 239, 126, 167, 47, 206, 112, 240, 205, 80, 76, 196, - 112, 240, 205, 80, 76, 206, 112, 240, 205, 80, 139, 2, 49, 240, 235, 196, - 112, 240, 205, 80, 139, 2, 49, 240, 235, 206, 112, 240, 205, 80, 139, 2, - 49, 47, 196, 112, 240, 205, 80, 139, 2, 49, 47, 206, 112, 240, 205, 80, - 139, 2, 49, 53, 184, 196, 112, 240, 205, 80, 139, 2, 49, 53, 244, 172, - 206, 112, 236, 53, 196, 112, 236, 53, 206, 18, 236, 193, 141, 80, 76, - 196, 18, 236, 193, 141, 80, 76, 206, 18, 141, 236, 53, 196, 18, 141, 236, - 53, 206, 53, 236, 188, 80, 53, 235, 235, 196, 53, 236, 188, 80, 53, 237, - 110, 206, 53, 240, 225, 112, 242, 88, 196, 53, 240, 225, 112, 242, 88, - 206, 53, 240, 225, 53, 235, 235, 196, 53, 240, 225, 53, 237, 110, 206, - 53, 196, 53, 236, 188, 242, 88, 196, 53, 206, 53, 236, 188, 242, 88, 206, - 53, 240, 205, 80, 53, 196, 53, 240, 205, 242, 88, 196, 53, 240, 205, 80, - 53, 206, 53, 240, 205, 242, 88, 240, 205, 80, 139, 112, 237, 110, 240, - 205, 80, 139, 112, 235, 235, 240, 205, 80, 139, 112, 206, 2, 49, 240, - 235, 240, 205, 80, 139, 112, 196, 2, 49, 240, 235, 236, 188, 80, 139, - 112, 237, 110, 236, 188, 80, 139, 112, 235, 235, 236, 188, 240, 205, 80, - 139, 112, 237, 110, 236, 188, 240, 205, 80, 139, 112, 235, 235, 240, 225, - 112, 237, 110, 240, 225, 112, 235, 235, 240, 225, 53, 206, 53, 242, 61, - 57, 240, 225, 53, 196, 53, 242, 61, 57, 42, 242, 148, 237, 110, 42, 242, - 148, 235, 235, 42, 242, 148, 206, 2, 238, 75, 196, 236, 221, 237, 110, - 196, 242, 99, 237, 110, 206, 242, 77, 254, 216, 242, 203, 196, 242, 77, - 254, 216, 242, 203, 206, 242, 77, 254, 216, 245, 72, 53, 240, 205, 242, - 88, 196, 242, 77, 254, 216, 245, 72, 53, 240, 205, 242, 88, 241, 80, 245, - 47, 242, 230, 245, 47, 241, 80, 249, 166, 112, 80, 76, 242, 230, 249, - 166, 112, 80, 76, 242, 61, 25, 2, 246, 34, 47, 239, 143, 53, 236, 193, - 242, 61, 57, 239, 145, 53, 236, 193, 242, 61, 57, 239, 143, 53, 236, 193, - 141, 80, 76, 239, 145, 53, 236, 193, 141, 80, 76, 239, 143, 53, 242, 61, - 57, 239, 145, 53, 242, 61, 57, 239, 143, 53, 141, 80, 76, 239, 145, 53, - 141, 80, 76, 239, 143, 53, 242, 93, 80, 76, 239, 145, 53, 242, 93, 80, - 76, 239, 143, 53, 141, 242, 93, 80, 76, 239, 145, 53, 141, 242, 93, 80, - 76, 42, 238, 126, 42, 238, 130, 242, 76, 2, 227, 239, 121, 2, 227, 242, - 76, 2, 249, 4, 25, 45, 239, 121, 2, 249, 4, 25, 45, 242, 76, 2, 235, 191, - 25, 45, 239, 121, 2, 235, 191, 25, 45, 242, 76, 137, 112, 80, 139, 2, 49, - 47, 239, 121, 137, 112, 80, 139, 2, 49, 47, 242, 76, 137, 53, 242, 61, - 57, 239, 121, 137, 53, 242, 61, 57, 242, 76, 137, 53, 229, 223, 239, 121, - 137, 53, 229, 223, 242, 76, 137, 53, 242, 93, 80, 76, 239, 121, 137, 53, - 242, 93, 80, 76, 242, 76, 137, 53, 141, 80, 76, 239, 121, 137, 53, 141, - 80, 76, 30, 36, 249, 0, 56, 223, 30, 37, 249, 0, 56, 223, 242, 77, 240, - 237, 242, 77, 238, 116, 242, 77, 242, 76, 112, 80, 76, 242, 77, 239, 121, - 112, 80, 76, 242, 76, 53, 238, 116, 239, 121, 53, 240, 237, 242, 76, 53, - 240, 237, 239, 121, 53, 238, 116, 239, 121, 242, 99, 240, 237, 239, 121, - 242, 99, 18, 242, 160, 254, 216, 249, 15, 2, 240, 237, 240, 214, 137, - 240, 236, 237, 121, 239, 62, 2, 254, 190, 249, 168, 237, 106, 235, 238, - 240, 77, 237, 78, 207, 36, 244, 184, 207, 79, 244, 184, 207, 75, 244, - 184, 236, 30, 2, 159, 55, 253, 99, 242, 59, 37, 237, 119, 42, 55, 253, - 99, 36, 237, 119, 55, 253, 99, 42, 36, 237, 119, 42, 55, 253, 99, 42, 36, - 237, 119, 165, 249, 15, 248, 254, 36, 243, 219, 137, 42, 238, 88, 207, - 79, 249, 35, 2, 239, 130, 207, 75, 249, 35, 2, 238, 75, 207, 75, 249, 35, - 53, 207, 79, 244, 184, 42, 79, 244, 184, 42, 75, 244, 184, 42, 242, 114, - 141, 57, 224, 42, 242, 114, 141, 57, 249, 41, 141, 243, 93, 2, 224, 240, - 122, 242, 91, 55, 217, 2, 175, 47, 55, 217, 2, 175, 45, 79, 249, 35, 2, - 175, 45, 239, 160, 2, 146, 122, 239, 160, 2, 229, 223, 242, 59, 55, 253, - 99, 242, 199, 238, 114, 242, 59, 55, 253, 99, 2, 146, 122, 242, 59, 244, - 214, 223, 242, 59, 242, 148, 237, 110, 242, 59, 242, 148, 235, 235, 236, - 188, 240, 205, 206, 112, 80, 76, 236, 188, 240, 205, 196, 112, 80, 76, - 242, 59, 240, 230, 242, 199, 238, 114, 244, 222, 242, 59, 55, 253, 99, - 223, 42, 240, 230, 223, 58, 55, 143, 244, 186, 58, 55, 143, 7, 22, 241, - 248, 7, 22, 242, 175, 7, 22, 242, 165, 121, 7, 22, 242, 165, 114, 7, 22, - 242, 165, 153, 7, 22, 241, 237, 7, 22, 249, 47, 7, 22, 243, 7, 7, 22, - 245, 126, 121, 7, 22, 245, 126, 114, 7, 22, 236, 213, 7, 22, 245, 178, 7, - 22, 3, 121, 7, 22, 3, 114, 7, 22, 249, 105, 121, 7, 22, 249, 105, 114, 7, - 22, 249, 105, 153, 7, 22, 249, 105, 163, 7, 22, 244, 91, 7, 22, 241, 87, - 7, 22, 245, 194, 121, 7, 22, 245, 194, 114, 7, 22, 244, 218, 121, 7, 22, - 244, 218, 114, 7, 22, 244, 250, 7, 22, 249, 158, 7, 22, 243, 64, 7, 22, - 249, 87, 7, 22, 244, 229, 7, 22, 242, 207, 7, 22, 241, 217, 7, 22, 238, - 190, 7, 22, 245, 220, 121, 7, 22, 245, 220, 114, 7, 22, 244, 236, 7, 22, - 254, 65, 121, 7, 22, 254, 65, 114, 7, 22, 237, 130, 136, 250, 94, 243, - 13, 7, 22, 249, 201, 7, 22, 249, 215, 7, 22, 245, 114, 7, 22, 249, 192, - 137, 242, 202, 7, 22, 249, 220, 7, 22, 243, 3, 121, 7, 22, 243, 3, 114, - 7, 22, 241, 41, 7, 22, 245, 44, 7, 22, 236, 44, 245, 44, 7, 22, 253, 243, - 121, 7, 22, 253, 243, 114, 7, 22, 253, 243, 153, 7, 22, 253, 243, 163, 7, - 22, 247, 77, 7, 22, 242, 250, 7, 22, 252, 116, 7, 22, 250, 249, 7, 22, - 250, 37, 7, 22, 245, 64, 121, 7, 22, 245, 64, 114, 7, 22, 245, 139, 7, - 22, 241, 67, 7, 22, 245, 23, 121, 7, 22, 245, 23, 114, 7, 22, 245, 23, - 153, 7, 22, 243, 11, 7, 22, 239, 210, 7, 22, 249, 17, 121, 7, 22, 249, - 17, 114, 7, 22, 236, 44, 249, 117, 7, 22, 237, 130, 244, 210, 7, 22, 244, - 210, 7, 22, 236, 44, 241, 82, 7, 22, 236, 44, 242, 251, 7, 22, 245, 22, - 7, 22, 236, 44, 245, 66, 7, 22, 237, 130, 245, 218, 7, 22, 249, 176, 121, - 7, 22, 249, 176, 114, 7, 22, 245, 70, 7, 22, 236, 44, 245, 100, 7, 22, - 165, 121, 7, 22, 165, 114, 7, 22, 236, 44, 245, 133, 7, 22, 236, 44, 245, - 91, 7, 22, 245, 143, 121, 7, 22, 245, 143, 114, 7, 22, 245, 167, 7, 22, - 245, 62, 7, 22, 236, 44, 243, 8, 239, 187, 7, 22, 236, 44, 245, 130, 7, - 22, 236, 44, 245, 50, 7, 22, 236, 44, 249, 224, 7, 22, 254, 8, 121, 7, - 22, 254, 8, 114, 7, 22, 254, 8, 153, 7, 22, 236, 44, 249, 219, 7, 22, - 245, 25, 7, 22, 236, 44, 242, 224, 7, 22, 245, 63, 7, 22, 242, 217, 7, - 22, 236, 44, 245, 85, 7, 22, 236, 44, 245, 14, 7, 22, 236, 44, 245, 177, - 7, 22, 237, 130, 243, 18, 7, 22, 237, 130, 241, 90, 7, 22, 236, 44, 245, - 89, 7, 22, 236, 56, 245, 21, 7, 22, 236, 44, 245, 21, 7, 22, 236, 56, - 242, 191, 7, 22, 236, 44, 242, 191, 7, 22, 236, 56, 241, 19, 7, 22, 236, - 44, 241, 19, 7, 22, 241, 9, 7, 22, 236, 56, 241, 9, 7, 22, 236, 44, 241, - 9, 40, 22, 121, 40, 22, 244, 176, 40, 22, 227, 40, 22, 242, 91, 40, 22, - 242, 3, 40, 22, 128, 40, 22, 114, 40, 22, 251, 195, 40, 22, 249, 146, 40, - 22, 247, 57, 40, 22, 243, 99, 40, 22, 176, 40, 22, 79, 249, 47, 40, 22, - 243, 76, 40, 22, 251, 107, 40, 22, 243, 7, 40, 22, 249, 0, 249, 47, 40, - 22, 243, 191, 40, 22, 244, 40, 40, 22, 248, 174, 40, 22, 244, 97, 40, 22, - 37, 249, 0, 249, 47, 40, 22, 243, 145, 237, 139, 40, 22, 249, 18, 40, 22, - 236, 213, 40, 22, 245, 178, 40, 22, 242, 175, 40, 22, 240, 145, 40, 22, - 243, 26, 40, 22, 243, 231, 40, 22, 237, 139, 40, 22, 242, 142, 40, 22, - 240, 159, 40, 22, 253, 195, 40, 22, 255, 8, 242, 15, 40, 22, 240, 71, 40, - 22, 250, 158, 40, 22, 244, 148, 40, 22, 243, 62, 40, 22, 248, 24, 40, 22, - 246, 251, 40, 22, 243, 2, 40, 22, 247, 53, 40, 22, 241, 130, 40, 22, 242, - 19, 40, 22, 238, 147, 40, 22, 244, 60, 40, 22, 248, 173, 40, 22, 240, - 131, 40, 22, 242, 42, 40, 22, 250, 229, 40, 22, 207, 241, 87, 40, 22, - 242, 118, 242, 175, 40, 22, 165, 242, 23, 40, 22, 225, 243, 143, 40, 22, - 244, 79, 40, 22, 249, 129, 40, 22, 244, 92, 40, 22, 240, 10, 40, 22, 248, - 104, 40, 22, 242, 178, 40, 22, 240, 84, 40, 22, 246, 113, 40, 22, 244, - 250, 40, 22, 241, 117, 40, 22, 249, 158, 40, 22, 242, 1, 40, 22, 241, - 141, 40, 22, 250, 139, 40, 22, 240, 207, 40, 22, 249, 151, 40, 22, 249, - 87, 40, 22, 252, 156, 40, 22, 244, 229, 40, 22, 248, 137, 40, 22, 247, - 51, 40, 22, 189, 40, 22, 242, 207, 40, 22, 242, 54, 40, 22, 254, 240, - 249, 151, 40, 22, 240, 16, 40, 22, 249, 225, 40, 22, 246, 68, 40, 22, - 244, 105, 40, 22, 242, 169, 40, 22, 244, 236, 40, 22, 246, 69, 40, 22, - 241, 163, 40, 22, 42, 170, 40, 22, 136, 250, 94, 243, 13, 40, 22, 244, - 87, 40, 22, 246, 129, 40, 22, 249, 201, 40, 22, 249, 215, 40, 22, 239, - 64, 40, 22, 245, 114, 40, 22, 243, 218, 40, 22, 248, 130, 40, 22, 244, - 107, 40, 22, 247, 67, 40, 22, 252, 246, 40, 22, 243, 110, 40, 22, 249, - 192, 137, 242, 202, 40, 22, 239, 84, 40, 22, 242, 118, 248, 119, 40, 22, - 242, 92, 40, 22, 248, 77, 40, 22, 246, 109, 40, 22, 249, 220, 40, 22, - 244, 95, 40, 22, 52, 40, 22, 244, 106, 40, 22, 242, 18, 40, 22, 244, 123, - 40, 22, 243, 137, 40, 22, 246, 43, 40, 22, 244, 103, 40, 22, 241, 41, 40, - 22, 248, 21, 40, 22, 245, 44, 40, 22, 251, 118, 40, 22, 252, 14, 40, 22, - 242, 250, 40, 22, 240, 73, 40, 22, 250, 37, 40, 22, 249, 46, 40, 22, 247, - 249, 40, 22, 249, 218, 40, 22, 243, 52, 40, 22, 245, 139, 40, 22, 239, - 49, 40, 22, 245, 179, 40, 22, 241, 101, 40, 22, 241, 67, 40, 22, 241, 36, - 40, 22, 241, 229, 40, 22, 246, 30, 40, 22, 239, 86, 40, 22, 243, 73, 40, - 22, 243, 138, 40, 22, 243, 11, 40, 22, 241, 187, 40, 22, 243, 47, 40, 22, - 249, 176, 237, 139, 40, 22, 239, 210, 40, 22, 248, 171, 40, 22, 249, 117, - 40, 22, 244, 210, 40, 22, 241, 82, 40, 22, 242, 47, 40, 22, 246, 18, 40, - 22, 252, 65, 40, 22, 241, 107, 40, 22, 242, 251, 40, 22, 252, 119, 40, - 22, 252, 138, 40, 22, 245, 22, 40, 22, 246, 31, 40, 22, 245, 66, 40, 22, - 241, 114, 40, 22, 240, 119, 40, 22, 245, 218, 40, 22, 245, 70, 40, 22, - 245, 222, 40, 22, 236, 96, 40, 22, 240, 194, 40, 22, 245, 100, 40, 22, - 245, 133, 40, 22, 245, 91, 40, 22, 243, 230, 40, 22, 244, 86, 40, 22, - 207, 244, 109, 245, 14, 40, 22, 245, 167, 40, 22, 245, 62, 40, 22, 244, - 150, 40, 22, 244, 235, 40, 22, 239, 187, 40, 22, 243, 8, 239, 187, 40, - 22, 247, 56, 40, 22, 244, 93, 40, 22, 245, 130, 40, 22, 245, 50, 40, 22, - 249, 224, 40, 22, 249, 219, 40, 22, 245, 25, 40, 22, 239, 21, 40, 22, - 242, 224, 40, 22, 245, 63, 40, 22, 248, 117, 40, 22, 246, 171, 40, 22, - 243, 112, 40, 22, 237, 84, 245, 222, 40, 22, 238, 187, 40, 22, 242, 217, - 40, 22, 245, 85, 40, 22, 245, 14, 40, 22, 245, 177, 40, 22, 246, 102, 40, - 22, 243, 18, 40, 22, 246, 172, 40, 22, 241, 90, 40, 22, 241, 214, 40, 22, - 231, 231, 40, 22, 237, 59, 40, 22, 245, 89, 40, 22, 242, 39, 40, 22, 246, - 115, 40, 22, 250, 61, 40, 22, 247, 180, 40, 22, 245, 21, 40, 22, 242, - 191, 40, 22, 241, 19, 40, 22, 241, 9, 40, 22, 243, 115, 66, 236, 185, 92, - 36, 139, 184, 66, 236, 185, 92, 53, 139, 45, 66, 236, 185, 92, 36, 139, - 242, 65, 18, 184, 66, 236, 185, 92, 53, 139, 242, 65, 18, 45, 66, 236, - 185, 92, 213, 239, 98, 66, 236, 185, 92, 239, 165, 248, 254, 47, 66, 236, - 185, 92, 239, 165, 248, 254, 45, 66, 236, 185, 92, 239, 165, 248, 254, - 244, 172, 66, 236, 185, 92, 239, 165, 248, 254, 156, 244, 172, 66, 236, - 185, 92, 239, 165, 248, 254, 156, 184, 66, 236, 185, 92, 239, 165, 248, - 254, 149, 244, 172, 66, 236, 185, 92, 239, 54, 66, 242, 69, 66, 242, 84, - 66, 213, 189, 246, 110, 65, 240, 95, 238, 20, 239, 239, 90, 66, 238, 101, - 65, 66, 241, 48, 65, 66, 83, 244, 173, 36, 160, 110, 37, 160, 110, 36, - 42, 160, 110, 37, 42, 160, 110, 36, 242, 86, 110, 37, 242, 86, 110, 36, - 58, 242, 86, 110, 37, 58, 242, 86, 110, 36, 86, 237, 126, 110, 37, 86, - 237, 126, 110, 242, 183, 65, 251, 32, 65, 36, 239, 139, 244, 202, 110, - 37, 239, 139, 244, 202, 110, 36, 58, 237, 126, 110, 37, 58, 237, 126, - 110, 36, 58, 239, 139, 244, 202, 110, 37, 58, 239, 139, 244, 202, 110, - 36, 58, 30, 110, 37, 58, 30, 110, 249, 90, 244, 189, 224, 42, 245, 37, - 238, 76, 65, 42, 245, 37, 238, 76, 65, 253, 113, 42, 245, 37, 238, 76, - 65, 242, 183, 167, 244, 235, 239, 134, 151, 121, 239, 134, 151, 114, 239, - 134, 151, 153, 239, 134, 151, 163, 239, 134, 151, 168, 239, 134, 151, - 169, 239, 134, 151, 179, 239, 134, 151, 176, 239, 134, 151, 178, 66, 247, - 58, 249, 5, 65, 66, 242, 120, 249, 5, 65, 66, 238, 119, 249, 5, 65, 66, - 240, 69, 249, 5, 65, 20, 242, 66, 49, 249, 5, 65, 20, 42, 49, 249, 5, 65, - 249, 57, 244, 189, 55, 249, 82, 242, 113, 65, 55, 249, 82, 242, 113, 2, - 242, 116, 244, 205, 65, 55, 249, 82, 242, 113, 167, 156, 244, 217, 55, - 249, 82, 242, 113, 2, 242, 116, 244, 205, 167, 156, 244, 217, 55, 249, - 82, 242, 113, 167, 149, 244, 217, 28, 242, 183, 65, 66, 127, 217, 251, 0, - 238, 158, 90, 239, 134, 151, 249, 18, 239, 134, 151, 240, 239, 239, 134, - 151, 241, 7, 55, 66, 238, 101, 65, 251, 219, 65, 250, 41, 236, 240, 65, - 66, 238, 79, 237, 136, 66, 136, 251, 8, 242, 69, 93, 1, 3, 64, 93, 1, 64, - 93, 1, 3, 69, 93, 1, 69, 93, 1, 3, 84, 93, 1, 84, 93, 1, 3, 70, 93, 1, - 70, 93, 1, 3, 78, 93, 1, 78, 93, 1, 208, 93, 1, 253, 100, 93, 1, 253, - 182, 93, 1, 253, 209, 93, 1, 253, 183, 93, 1, 253, 196, 93, 1, 253, 134, - 93, 1, 253, 207, 93, 1, 253, 155, 93, 1, 253, 195, 93, 1, 253, 97, 93, 1, - 253, 129, 93, 1, 253, 158, 93, 1, 253, 218, 93, 1, 253, 172, 93, 1, 253, - 233, 93, 1, 253, 171, 93, 1, 253, 189, 93, 1, 253, 159, 93, 1, 253, 190, - 93, 1, 253, 91, 93, 1, 253, 93, 93, 1, 253, 174, 93, 1, 253, 165, 93, 1, - 3, 253, 160, 93, 1, 253, 160, 93, 1, 253, 204, 93, 1, 253, 151, 93, 1, - 253, 152, 93, 1, 76, 93, 1, 253, 193, 93, 1, 253, 94, 93, 1, 253, 148, - 93, 1, 253, 112, 93, 1, 253, 157, 93, 1, 253, 136, 93, 1, 253, 88, 93, 1, - 253, 110, 93, 1, 253, 90, 93, 1, 253, 154, 93, 1, 253, 236, 93, 1, 253, - 116, 93, 1, 253, 197, 93, 1, 253, 192, 93, 1, 253, 231, 93, 1, 253, 125, - 93, 1, 253, 191, 93, 1, 253, 143, 93, 1, 253, 140, 93, 1, 253, 221, 93, - 1, 253, 187, 93, 1, 221, 93, 1, 253, 156, 93, 1, 253, 114, 93, 1, 253, - 167, 93, 1, 253, 141, 93, 1, 3, 216, 93, 1, 216, 93, 1, 3, 253, 124, 93, - 1, 253, 124, 93, 1, 3, 253, 123, 93, 1, 253, 123, 93, 1, 253, 92, 93, 1, - 253, 169, 93, 1, 253, 170, 93, 1, 253, 150, 93, 1, 253, 144, 93, 1, 3, - 253, 98, 93, 1, 253, 98, 93, 1, 253, 145, 93, 1, 253, 132, 93, 1, 253, - 138, 93, 1, 183, 93, 1, 253, 255, 93, 1, 3, 208, 93, 1, 3, 253, 134, 48, - 232, 3, 242, 116, 244, 205, 65, 48, 232, 3, 236, 205, 244, 205, 65, 232, - 3, 242, 116, 244, 205, 65, 232, 3, 236, 205, 244, 205, 65, 93, 238, 101, - 65, 93, 242, 116, 238, 101, 65, 93, 240, 253, 248, 197, 232, 3, 42, 240, - 241, 39, 1, 3, 64, 39, 1, 64, 39, 1, 3, 69, 39, 1, 69, 39, 1, 3, 84, 39, - 1, 84, 39, 1, 3, 70, 39, 1, 70, 39, 1, 3, 78, 39, 1, 78, 39, 1, 208, 39, - 1, 253, 100, 39, 1, 253, 182, 39, 1, 253, 209, 39, 1, 253, 183, 39, 1, - 253, 196, 39, 1, 253, 134, 39, 1, 253, 207, 39, 1, 253, 155, 39, 1, 253, - 195, 39, 1, 253, 97, 39, 1, 253, 129, 39, 1, 253, 158, 39, 1, 253, 218, - 39, 1, 253, 172, 39, 1, 253, 233, 39, 1, 253, 171, 39, 1, 253, 189, 39, - 1, 253, 159, 39, 1, 253, 190, 39, 1, 253, 91, 39, 1, 253, 93, 39, 1, 253, - 174, 39, 1, 253, 165, 39, 1, 3, 253, 160, 39, 1, 253, 160, 39, 1, 253, - 204, 39, 1, 253, 151, 39, 1, 253, 152, 39, 1, 76, 39, 1, 253, 193, 39, 1, - 253, 94, 39, 1, 253, 148, 39, 1, 253, 112, 39, 1, 253, 157, 39, 1, 253, - 136, 39, 1, 253, 88, 39, 1, 253, 110, 39, 1, 253, 90, 39, 1, 253, 154, - 39, 1, 253, 236, 39, 1, 253, 116, 39, 1, 253, 197, 39, 1, 253, 192, 39, - 1, 253, 231, 39, 1, 253, 125, 39, 1, 253, 191, 39, 1, 253, 143, 39, 1, - 253, 140, 39, 1, 253, 221, 39, 1, 253, 187, 39, 1, 221, 39, 1, 253, 156, - 39, 1, 253, 114, 39, 1, 253, 167, 39, 1, 253, 141, 39, 1, 3, 216, 39, 1, - 216, 39, 1, 3, 253, 124, 39, 1, 253, 124, 39, 1, 3, 253, 123, 39, 1, 253, - 123, 39, 1, 253, 92, 39, 1, 253, 169, 39, 1, 253, 170, 39, 1, 253, 150, - 39, 1, 253, 144, 39, 1, 3, 253, 98, 39, 1, 253, 98, 39, 1, 253, 145, 39, - 1, 253, 132, 39, 1, 253, 138, 39, 1, 183, 39, 1, 253, 255, 39, 1, 3, 208, - 39, 1, 3, 253, 134, 39, 1, 253, 161, 39, 1, 254, 25, 39, 1, 253, 214, 39, - 1, 253, 215, 39, 242, 65, 227, 232, 3, 238, 153, 244, 205, 65, 39, 238, - 101, 65, 39, 242, 116, 238, 101, 65, 39, 240, 253, 247, 39, 134, 1, 199, - 134, 1, 198, 134, 1, 171, 134, 1, 204, 134, 1, 187, 134, 1, 190, 134, 1, - 183, 134, 1, 148, 134, 1, 194, 134, 1, 205, 134, 1, 164, 134, 1, 200, - 134, 1, 209, 134, 1, 170, 134, 1, 254, 211, 134, 1, 254, 94, 134, 1, 254, - 21, 134, 1, 135, 134, 1, 202, 134, 1, 203, 134, 1, 159, 134, 1, 64, 134, - 1, 78, 134, 1, 70, 134, 1, 254, 9, 134, 1, 253, 106, 134, 1, 254, 36, - 134, 1, 253, 109, 134, 1, 253, 247, 134, 1, 253, 235, 134, 1, 253, 166, - 134, 1, 249, 75, 134, 1, 249, 66, 134, 1, 253, 205, 134, 1, 69, 134, 1, - 84, 134, 1, 254, 120, 134, 1, 186, 134, 1, 253, 244, 134, 1, 254, 108, - 20, 1, 240, 242, 20, 1, 236, 59, 20, 1, 236, 63, 20, 1, 242, 131, 20, 1, - 236, 65, 20, 1, 236, 66, 20, 1, 240, 244, 20, 1, 236, 72, 20, 1, 242, - 134, 20, 1, 235, 247, 20, 1, 236, 67, 20, 1, 236, 68, 20, 1, 236, 204, - 20, 1, 235, 197, 20, 1, 235, 196, 20, 1, 236, 57, 20, 1, 242, 129, 20, 1, - 242, 133, 20, 1, 236, 209, 20, 1, 236, 198, 20, 1, 244, 230, 20, 1, 237, - 138, 20, 1, 242, 126, 20, 1, 242, 122, 20, 1, 236, 207, 20, 1, 239, 155, - 20, 1, 239, 158, 20, 1, 239, 166, 20, 1, 239, 161, 20, 1, 242, 125, 20, - 1, 64, 20, 1, 253, 163, 20, 1, 216, 20, 1, 249, 181, 20, 1, 254, 10, 20, - 1, 70, 20, 1, 249, 182, 20, 1, 253, 200, 20, 1, 78, 20, 1, 253, 98, 20, - 1, 249, 175, 20, 1, 253, 142, 20, 1, 253, 123, 20, 1, 84, 20, 1, 249, - 177, 20, 1, 253, 132, 20, 1, 253, 145, 20, 1, 253, 124, 20, 1, 254, 12, - 20, 1, 253, 139, 20, 1, 69, 20, 240, 255, 20, 1, 236, 233, 20, 1, 235, - 246, 20, 1, 236, 220, 20, 1, 235, 201, 20, 1, 231, 250, 20, 1, 236, 1, - 20, 1, 232, 4, 20, 1, 235, 206, 20, 1, 231, 251, 20, 1, 236, 64, 20, 1, - 236, 216, 20, 1, 235, 200, 20, 1, 235, 194, 20, 1, 235, 255, 20, 1, 236, - 0, 20, 1, 231, 248, 20, 1, 231, 249, 20, 1, 236, 77, 20, 1, 235, 205, 20, - 1, 235, 195, 20, 1, 231, 240, 20, 1, 236, 70, 20, 1, 236, 230, 20, 1, - 236, 71, 20, 1, 236, 206, 20, 1, 236, 229, 20, 1, 239, 191, 20, 1, 236, - 208, 20, 1, 238, 134, 20, 1, 235, 210, 20, 1, 232, 5, 20, 1, 232, 14, 20, - 1, 236, 232, 20, 1, 236, 73, 20, 1, 243, 19, 20, 1, 241, 91, 20, 1, 245, - 226, 20, 1, 241, 92, 20, 1, 243, 20, 20, 1, 245, 228, 20, 1, 242, 197, - 20, 1, 241, 100, 66, 237, 111, 241, 202, 65, 66, 237, 111, 240, 219, 65, - 66, 237, 111, 253, 101, 65, 66, 237, 111, 225, 65, 66, 237, 111, 244, - 171, 65, 66, 237, 111, 249, 28, 65, 66, 237, 111, 253, 121, 65, 66, 237, - 111, 242, 65, 65, 66, 237, 111, 242, 80, 65, 66, 237, 111, 245, 84, 65, - 66, 237, 111, 242, 165, 65, 66, 237, 111, 248, 124, 65, 66, 237, 111, - 242, 214, 65, 66, 237, 111, 243, 144, 65, 66, 237, 111, 246, 120, 65, 66, - 237, 111, 254, 55, 65, 134, 1, 253, 192, 134, 1, 253, 218, 134, 1, 253, - 228, 134, 1, 253, 196, 134, 1, 253, 126, 134, 1, 250, 243, 134, 1, 253, - 119, 134, 1, 250, 38, 134, 1, 254, 117, 134, 1, 250, 137, 134, 1, 251, - 112, 134, 1, 252, 240, 134, 1, 254, 115, 134, 1, 252, 18, 134, 1, 245, - 240, 134, 1, 245, 249, 134, 1, 253, 234, 134, 1, 253, 245, 134, 1, 252, - 57, 134, 1, 246, 252, 134, 29, 1, 198, 134, 29, 1, 190, 134, 29, 1, 205, - 134, 29, 1, 164, 39, 1, 3, 253, 183, 39, 1, 3, 253, 158, 39, 1, 3, 253, - 172, 39, 1, 3, 76, 39, 1, 3, 253, 112, 39, 1, 3, 253, 88, 39, 1, 3, 253, - 154, 39, 1, 3, 253, 197, 39, 1, 3, 253, 125, 39, 1, 3, 253, 140, 39, 1, - 3, 253, 114, 39, 1, 3, 253, 92, 39, 1, 3, 253, 169, 39, 1, 3, 253, 170, - 39, 1, 3, 253, 150, 39, 1, 3, 253, 144, 68, 20, 240, 242, 68, 20, 242, - 131, 68, 20, 240, 244, 68, 20, 242, 134, 68, 20, 242, 129, 68, 20, 242, - 133, 68, 20, 244, 230, 68, 20, 242, 126, 68, 20, 242, 122, 68, 20, 239, - 155, 68, 20, 239, 158, 68, 20, 239, 166, 68, 20, 239, 161, 68, 20, 242, - 125, 68, 20, 242, 227, 64, 68, 20, 245, 149, 64, 68, 20, 243, 12, 64, 68, - 20, 245, 171, 64, 68, 20, 245, 142, 64, 68, 20, 245, 160, 64, 68, 20, - 250, 72, 64, 68, 20, 245, 113, 64, 68, 20, 245, 18, 64, 68, 20, 241, 47, - 64, 68, 20, 241, 61, 64, 68, 20, 241, 86, 64, 68, 20, 241, 72, 64, 68, - 20, 245, 108, 64, 68, 20, 245, 18, 84, 68, 97, 121, 68, 97, 114, 68, 97, - 153, 68, 97, 163, 68, 97, 168, 68, 97, 169, 68, 97, 179, 68, 97, 176, 68, - 97, 178, 68, 97, 249, 18, 68, 97, 244, 229, 68, 97, 244, 236, 68, 97, - 242, 169, 68, 97, 245, 223, 68, 97, 242, 231, 68, 97, 242, 142, 68, 97, - 249, 87, 68, 97, 243, 4, 68, 97, 245, 105, 68, 97, 239, 236, 68, 97, 245, - 146, 68, 97, 239, 238, 68, 97, 237, 155, 68, 97, 234, 66, 68, 97, 242, - 229, 68, 97, 238, 54, 68, 97, 246, 41, 68, 97, 243, 5, 68, 97, 237, 165, - 68, 97, 236, 214, 68, 97, 238, 155, 68, 97, 238, 135, 68, 97, 239, 14, - 68, 97, 244, 187, 68, 97, 245, 179, 68, 97, 244, 54, 28, 83, 242, 104, - 121, 28, 83, 242, 104, 114, 28, 83, 242, 104, 153, 28, 83, 242, 104, 163, - 28, 83, 242, 104, 168, 28, 83, 242, 104, 169, 28, 83, 242, 104, 179, 28, - 83, 242, 104, 176, 28, 83, 242, 104, 178, 28, 83, 241, 7, 28, 83, 242, - 108, 121, 28, 83, 242, 108, 114, 28, 83, 242, 108, 153, 28, 83, 242, 108, - 163, 28, 83, 242, 108, 168, 28, 20, 240, 242, 28, 20, 242, 131, 28, 20, - 240, 244, 28, 20, 242, 134, 28, 20, 242, 129, 28, 20, 242, 133, 28, 20, - 244, 230, 28, 20, 242, 126, 28, 20, 242, 122, 28, 20, 239, 155, 28, 20, - 239, 158, 28, 20, 239, 166, 28, 20, 239, 161, 28, 20, 242, 125, 28, 20, - 242, 227, 64, 28, 20, 245, 149, 64, 28, 20, 243, 12, 64, 28, 20, 245, - 171, 64, 28, 20, 245, 142, 64, 28, 20, 245, 160, 64, 28, 20, 250, 72, 64, - 28, 20, 245, 113, 64, 28, 20, 245, 18, 64, 28, 20, 241, 47, 64, 28, 20, - 241, 61, 64, 28, 20, 241, 86, 64, 28, 20, 241, 72, 64, 28, 20, 245, 108, - 64, 243, 193, 239, 239, 90, 28, 97, 121, 28, 97, 114, 28, 97, 153, 28, - 97, 163, 28, 97, 168, 28, 97, 169, 28, 97, 179, 28, 97, 176, 28, 97, 178, - 28, 97, 249, 18, 28, 97, 244, 229, 28, 97, 244, 236, 28, 97, 242, 169, - 28, 97, 245, 223, 28, 97, 242, 231, 28, 97, 242, 142, 28, 97, 249, 87, - 28, 97, 243, 4, 28, 97, 245, 105, 28, 97, 239, 236, 28, 97, 245, 146, 28, - 97, 239, 238, 28, 97, 237, 155, 28, 97, 234, 66, 28, 97, 242, 229, 28, - 97, 242, 4, 28, 97, 247, 76, 28, 97, 241, 164, 28, 97, 239, 97, 28, 97, - 238, 6, 28, 97, 244, 41, 28, 97, 237, 176, 28, 97, 246, 255, 28, 97, 244, - 187, 28, 97, 246, 74, 28, 97, 240, 19, 28, 97, 246, 177, 28, 97, 241, 46, - 28, 97, 251, 206, 28, 97, 244, 172, 28, 97, 184, 28, 97, 239, 48, 28, 97, - 239, 73, 28, 97, 243, 5, 28, 97, 237, 165, 28, 97, 236, 214, 28, 97, 238, - 155, 28, 97, 238, 135, 28, 97, 243, 248, 28, 83, 242, 108, 169, 28, 83, - 242, 108, 179, 28, 83, 242, 108, 176, 28, 83, 242, 108, 178, 28, 83, 242, - 213, 28, 83, 244, 209, 121, 28, 83, 244, 209, 114, 28, 83, 244, 209, 153, - 28, 83, 244, 209, 163, 28, 83, 244, 209, 168, 28, 83, 244, 209, 169, 28, - 83, 244, 209, 179, 28, 83, 244, 209, 176, 28, 83, 244, 209, 178, 28, 83, - 242, 144, 66, 127, 13, 54, 240, 94, 66, 127, 13, 54, 239, 13, 66, 127, - 13, 54, 243, 214, 66, 127, 13, 54, 243, 31, 66, 127, 13, 54, 251, 222, - 66, 127, 13, 54, 247, 20, 66, 127, 13, 54, 247, 19, 66, 127, 13, 54, 241, - 104, 66, 127, 13, 54, 238, 58, 66, 127, 13, 54, 240, 129, 66, 127, 13, - 54, 239, 53, 66, 127, 13, 54, 238, 199, 28, 39, 64, 28, 39, 69, 28, 39, - 84, 28, 39, 70, 28, 39, 78, 28, 39, 208, 28, 39, 253, 182, 28, 39, 253, - 183, 28, 39, 253, 134, 28, 39, 253, 155, 28, 39, 253, 97, 28, 39, 253, - 158, 28, 39, 253, 172, 28, 39, 253, 171, 28, 39, 253, 159, 28, 39, 253, - 91, 28, 39, 253, 174, 28, 39, 253, 160, 28, 39, 253, 151, 28, 39, 76, 28, - 39, 253, 94, 28, 39, 253, 148, 28, 39, 253, 112, 28, 39, 253, 157, 28, - 39, 253, 136, 28, 39, 253, 88, 28, 39, 253, 154, 28, 39, 253, 197, 28, - 39, 253, 125, 28, 39, 253, 140, 28, 39, 221, 28, 39, 253, 156, 28, 39, - 253, 114, 28, 39, 253, 167, 28, 39, 253, 141, 28, 39, 216, 28, 39, 253, - 124, 28, 39, 253, 123, 28, 39, 253, 92, 28, 39, 253, 169, 28, 39, 253, - 170, 28, 39, 253, 150, 28, 39, 253, 144, 28, 39, 253, 98, 28, 39, 253, - 145, 28, 39, 253, 132, 28, 39, 253, 138, 30, 241, 99, 30, 241, 103, 30, - 243, 30, 30, 245, 236, 30, 241, 186, 30, 246, 253, 30, 252, 241, 30, 239, - 10, 30, 243, 96, 30, 247, 233, 30, 247, 234, 30, 243, 182, 30, 240, 98, - 30, 240, 99, 30, 243, 124, 30, 243, 123, 30, 246, 158, 30, 243, 135, 30, - 241, 195, 30, 240, 81, 30, 247, 36, 30, 237, 72, 30, 236, 141, 30, 238, - 25, 30, 241, 178, 30, 238, 12, 30, 238, 27, 30, 240, 102, 30, 243, 186, - 30, 241, 194, 30, 243, 192, 30, 240, 155, 30, 239, 78, 30, 240, 164, 30, - 244, 74, 30, 244, 75, 30, 243, 78, 30, 246, 105, 30, 246, 114, 30, 252, - 213, 30, 247, 110, 30, 244, 4, 30, 243, 141, 30, 239, 55, 30, 244, 23, - 30, 240, 2, 30, 238, 42, 30, 241, 238, 30, 247, 248, 30, 246, 28, 30, - 239, 28, 30, 241, 182, 30, 238, 185, 30, 243, 164, 30, 238, 13, 30, 247, - 241, 30, 241, 236, 30, 241, 181, 30, 244, 31, 30, 244, 28, 30, 243, 41, - 30, 241, 241, 30, 241, 116, 30, 251, 88, 30, 244, 39, 30, 243, 162, 30, - 246, 231, 30, 240, 107, 30, 243, 210, 30, 243, 209, 30, 241, 206, 30, - 240, 109, 30, 240, 116, 30, 247, 98, 30, 238, 33, 30, 245, 29, 30, 240, - 114, 30, 240, 113, 30, 244, 152, 30, 244, 153, 30, 248, 201, 30, 240, - 153, 30, 248, 23, 30, 244, 66, 30, 240, 154, 30, 248, 20, 30, 239, 74, - 30, 244, 146, 66, 127, 13, 54, 249, 6, 244, 173, 66, 127, 13, 54, 249, 6, - 121, 66, 127, 13, 54, 249, 6, 114, 66, 127, 13, 54, 249, 6, 153, 66, 127, - 13, 54, 249, 6, 163, 66, 127, 13, 54, 249, 6, 168, 66, 127, 13, 54, 249, - 6, 169, 66, 127, 13, 54, 249, 6, 179, 66, 127, 13, 54, 249, 6, 176, 66, - 127, 13, 54, 249, 6, 178, 66, 127, 13, 54, 249, 6, 249, 18, 66, 127, 13, - 54, 249, 6, 240, 234, 66, 127, 13, 54, 249, 6, 240, 238, 66, 127, 13, 54, - 249, 6, 238, 108, 66, 127, 13, 54, 249, 6, 238, 106, 66, 127, 13, 54, - 249, 6, 239, 167, 66, 127, 13, 54, 249, 6, 239, 162, 66, 127, 13, 54, - 249, 6, 237, 129, 66, 127, 13, 54, 249, 6, 238, 105, 66, 127, 13, 54, - 249, 6, 238, 107, 66, 127, 13, 54, 249, 6, 240, 239, 66, 127, 13, 54, - 249, 6, 236, 238, 66, 127, 13, 54, 249, 6, 236, 239, 66, 127, 13, 54, - 249, 6, 236, 4, 66, 127, 13, 54, 249, 6, 236, 82, 30, 251, 93, 30, 253, - 93, 30, 253, 109, 30, 143, 30, 254, 163, 30, 254, 165, 30, 253, 238, 249, - 109, 241, 180, 30, 253, 238, 249, 109, 242, 29, 30, 253, 238, 249, 109, - 240, 175, 30, 253, 238, 249, 109, 243, 217, 30, 236, 91, 30, 255, 19, - 245, 245, 30, 253, 94, 30, 254, 219, 64, 30, 221, 30, 208, 30, 254, 124, - 30, 254, 140, 30, 254, 106, 30, 250, 175, 30, 247, 28, 30, 254, 167, 30, - 254, 154, 30, 254, 219, 204, 30, 254, 219, 194, 30, 254, 143, 30, 254, - 50, 30, 254, 114, 30, 251, 153, 30, 251, 230, 30, 251, 37, 30, 252, 207, - 30, 254, 219, 148, 30, 254, 146, 30, 254, 98, 30, 254, 127, 30, 254, 104, - 30, 254, 158, 30, 254, 219, 171, 30, 254, 147, 30, 254, 95, 30, 254, 128, - 30, 254, 251, 239, 163, 30, 254, 244, 239, 163, 30, 255, 39, 239, 163, - 30, 254, 242, 239, 163, 30, 254, 251, 242, 155, 30, 254, 244, 242, 155, - 30, 255, 39, 242, 155, 30, 254, 242, 242, 155, 30, 255, 39, 249, 25, 159, - 30, 255, 39, 249, 25, 255, 29, 239, 163, 30, 253, 90, 30, 251, 169, 30, - 251, 242, 30, 251, 44, 30, 252, 115, 30, 254, 20, 249, 25, 159, 30, 254, - 20, 249, 25, 255, 29, 239, 163, 30, 254, 173, 30, 254, 159, 30, 254, 219, - 159, 30, 254, 148, 30, 254, 174, 30, 254, 58, 30, 254, 219, 186, 30, 254, - 149, 30, 254, 130, 30, 255, 16, 245, 29, 30, 254, 175, 30, 254, 161, 30, - 254, 219, 201, 30, 254, 150, 30, 254, 52, 30, 255, 17, 245, 29, 30, 255, - 38, 250, 35, 30, 255, 39, 250, 35, 30, 253, 234, 30, 254, 90, 30, 254, - 92, 30, 254, 93, 30, 255, 36, 249, 25, 254, 50, 30, 253, 178, 30, 254, - 97, 30, 254, 110, 30, 253, 88, 30, 254, 113, 30, 253, 227, 30, 254, 51, - 30, 254, 242, 240, 12, 30, 254, 129, 30, 254, 135, 30, 254, 136, 30, 251, - 202, 30, 254, 138, 30, 255, 13, 243, 2, 30, 251, 233, 30, 251, 239, 30, - 254, 168, 30, 254, 170, 30, 252, 74, 30, 254, 172, 30, 254, 185, 30, 254, - 72, 30, 254, 202, 66, 127, 13, 54, 253, 89, 121, 66, 127, 13, 54, 253, - 89, 114, 66, 127, 13, 54, 253, 89, 153, 66, 127, 13, 54, 253, 89, 163, - 66, 127, 13, 54, 253, 89, 168, 66, 127, 13, 54, 253, 89, 169, 66, 127, - 13, 54, 253, 89, 179, 66, 127, 13, 54, 253, 89, 176, 66, 127, 13, 54, - 253, 89, 178, 66, 127, 13, 54, 253, 89, 249, 18, 66, 127, 13, 54, 253, - 89, 240, 234, 66, 127, 13, 54, 253, 89, 240, 238, 66, 127, 13, 54, 253, - 89, 238, 108, 66, 127, 13, 54, 253, 89, 238, 106, 66, 127, 13, 54, 253, - 89, 239, 167, 66, 127, 13, 54, 253, 89, 239, 162, 66, 127, 13, 54, 253, - 89, 237, 129, 66, 127, 13, 54, 253, 89, 238, 105, 66, 127, 13, 54, 253, - 89, 238, 107, 66, 127, 13, 54, 253, 89, 240, 239, 66, 127, 13, 54, 253, - 89, 236, 238, 66, 127, 13, 54, 253, 89, 236, 239, 66, 127, 13, 54, 253, - 89, 236, 4, 66, 127, 13, 54, 253, 89, 236, 82, 66, 127, 13, 54, 253, 89, - 236, 177, 66, 127, 13, 54, 253, 89, 237, 107, 66, 127, 13, 54, 253, 89, - 236, 42, 66, 127, 13, 54, 253, 89, 236, 41, 66, 127, 13, 54, 253, 89, - 236, 178, 66, 127, 13, 54, 253, 89, 241, 7, 66, 127, 13, 54, 253, 89, - 237, 104, 6, 4, 254, 119, 6, 4, 254, 121, 6, 4, 69, 6, 4, 254, 116, 6, 4, - 251, 109, 6, 4, 251, 110, 6, 4, 253, 181, 6, 4, 251, 108, 6, 4, 253, 220, - 6, 4, 254, 86, 6, 4, 64, 6, 4, 254, 83, 6, 4, 252, 243, 6, 4, 254, 197, - 6, 4, 252, 242, 6, 4, 254, 17, 6, 4, 254, 164, 6, 4, 78, 6, 4, 254, 63, - 6, 4, 254, 101, 6, 4, 70, 6, 4, 253, 216, 6, 4, 250, 160, 6, 4, 250, 161, - 6, 4, 253, 236, 6, 4, 250, 159, 6, 4, 246, 26, 6, 4, 246, 27, 6, 4, 250, - 157, 6, 4, 246, 25, 6, 4, 250, 142, 6, 4, 250, 143, 6, 4, 253, 110, 6, 4, - 250, 141, 6, 4, 246, 36, 6, 4, 250, 165, 6, 4, 246, 35, 6, 4, 250, 164, - 6, 4, 249, 47, 6, 4, 253, 221, 6, 4, 250, 163, 6, 4, 250, 156, 6, 4, 253, - 191, 6, 4, 250, 153, 6, 4, 250, 167, 6, 4, 250, 168, 6, 4, 253, 192, 6, - 4, 250, 166, 6, 4, 246, 37, 6, 4, 249, 193, 6, 4, 250, 172, 6, 4, 250, - 173, 6, 4, 254, 30, 6, 4, 250, 170, 6, 4, 246, 38, 6, 4, 250, 171, 6, 4, - 252, 68, 6, 4, 252, 69, 6, 4, 253, 116, 6, 4, 252, 67, 6, 4, 247, 247, 6, - 4, 252, 64, 6, 4, 247, 246, 6, 4, 252, 60, 6, 4, 252, 61, 6, 4, 253, 90, - 6, 4, 252, 59, 6, 4, 247, 252, 6, 4, 252, 75, 6, 4, 247, 251, 6, 4, 252, - 72, 6, 4, 252, 73, 6, 4, 253, 187, 6, 4, 252, 71, 6, 4, 250, 48, 6, 4, - 252, 78, 6, 4, 253, 231, 6, 4, 252, 76, 6, 4, 247, 253, 6, 4, 252, 77, 6, - 4, 250, 52, 6, 4, 252, 81, 6, 4, 254, 176, 6, 4, 252, 79, 6, 4, 247, 254, - 6, 4, 252, 80, 6, 4, 246, 5, 6, 4, 246, 6, 6, 4, 250, 146, 6, 4, 246, 4, - 6, 4, 243, 36, 6, 4, 243, 37, 6, 4, 246, 3, 6, 4, 243, 35, 6, 4, 245, - 255, 6, 4, 246, 0, 6, 4, 250, 144, 6, 4, 245, 254, 6, 4, 243, 39, 6, 4, - 246, 10, 6, 4, 243, 38, 6, 4, 246, 8, 6, 4, 246, 9, 6, 4, 250, 147, 6, 4, - 246, 7, 6, 4, 246, 2, 6, 4, 250, 145, 6, 4, 246, 1, 6, 4, 245, 58, 6, 4, - 246, 13, 6, 4, 250, 148, 6, 4, 246, 11, 6, 4, 243, 40, 6, 4, 246, 12, 6, - 4, 246, 15, 6, 4, 246, 16, 6, 4, 250, 149, 6, 4, 246, 14, 6, 4, 247, 115, - 6, 4, 247, 116, 6, 4, 252, 3, 6, 4, 247, 114, 6, 4, 243, 237, 6, 4, 245, - 148, 6, 4, 243, 236, 6, 4, 247, 112, 6, 4, 247, 113, 6, 4, 252, 2, 6, 4, - 247, 111, 6, 4, 247, 118, 6, 4, 247, 119, 6, 4, 252, 4, 6, 4, 247, 117, - 6, 4, 247, 122, 6, 4, 247, 123, 6, 4, 252, 5, 6, 4, 247, 120, 6, 4, 243, - 238, 6, 4, 247, 121, 6, 4, 247, 126, 6, 4, 247, 127, 6, 4, 252, 6, 6, 4, - 247, 124, 6, 4, 243, 239, 6, 4, 247, 125, 6, 4, 246, 204, 6, 4, 246, 205, - 6, 4, 251, 83, 6, 4, 246, 203, 6, 4, 243, 153, 6, 4, 246, 202, 6, 4, 243, - 152, 6, 4, 246, 200, 6, 4, 246, 201, 6, 4, 251, 82, 6, 4, 246, 199, 6, 4, - 243, 155, 6, 4, 246, 209, 6, 4, 243, 154, 6, 4, 246, 207, 6, 4, 246, 208, - 6, 4, 249, 243, 6, 4, 246, 206, 6, 4, 246, 212, 6, 4, 246, 213, 6, 4, - 251, 84, 6, 4, 246, 210, 6, 4, 243, 156, 6, 4, 246, 211, 6, 4, 246, 216, - 6, 4, 251, 85, 6, 4, 246, 214, 6, 4, 243, 157, 6, 4, 246, 215, 6, 4, 251, - 237, 6, 4, 251, 238, 6, 4, 253, 156, 6, 4, 251, 236, 6, 4, 247, 95, 6, 4, - 251, 231, 6, 4, 247, 94, 6, 4, 251, 220, 6, 4, 251, 221, 6, 4, 221, 6, 4, - 251, 218, 6, 4, 247, 104, 6, 4, 247, 105, 6, 4, 251, 243, 6, 4, 247, 103, - 6, 4, 251, 240, 6, 4, 251, 241, 6, 4, 253, 141, 6, 4, 250, 21, 6, 4, 251, - 226, 6, 4, 253, 167, 6, 4, 251, 246, 6, 4, 251, 247, 6, 4, 253, 114, 6, - 4, 251, 244, 6, 4, 247, 106, 6, 4, 251, 245, 6, 4, 251, 250, 6, 4, 251, - 251, 6, 4, 254, 151, 6, 4, 251, 249, 6, 4, 251, 10, 6, 4, 251, 11, 6, 4, - 253, 226, 6, 4, 251, 9, 6, 4, 250, 253, 6, 4, 250, 254, 6, 4, 253, 153, - 6, 4, 250, 252, 6, 4, 251, 14, 6, 4, 254, 13, 6, 4, 251, 13, 6, 4, 251, - 16, 6, 4, 251, 17, 6, 4, 254, 41, 6, 4, 251, 15, 6, 4, 246, 133, 6, 4, - 249, 225, 6, 4, 251, 21, 6, 4, 251, 22, 6, 4, 254, 105, 6, 4, 251, 20, 6, - 4, 252, 255, 6, 4, 253, 0, 6, 4, 254, 25, 6, 4, 252, 254, 6, 4, 248, 165, - 6, 4, 248, 166, 6, 4, 252, 253, 6, 4, 248, 164, 6, 4, 252, 249, 6, 4, - 252, 250, 6, 4, 253, 161, 6, 4, 252, 248, 6, 4, 253, 3, 6, 4, 253, 4, 6, - 4, 253, 215, 6, 4, 253, 2, 6, 4, 252, 252, 6, 4, 250, 103, 6, 4, 253, 6, - 6, 4, 253, 7, 6, 4, 253, 255, 6, 4, 253, 5, 6, 4, 248, 167, 6, 4, 250, - 108, 6, 4, 253, 11, 6, 4, 253, 12, 6, 4, 254, 201, 6, 4, 253, 9, 6, 4, - 248, 168, 6, 4, 253, 10, 6, 4, 250, 219, 6, 4, 250, 220, 6, 4, 253, 165, - 6, 4, 250, 218, 6, 4, 246, 107, 6, 4, 250, 217, 6, 4, 246, 106, 6, 4, - 250, 209, 6, 4, 250, 211, 6, 4, 253, 93, 6, 4, 250, 207, 6, 4, 246, 116, - 6, 4, 250, 231, 6, 4, 227, 6, 4, 250, 227, 6, 4, 253, 193, 6, 4, 250, - 226, 6, 4, 250, 215, 6, 4, 253, 152, 6, 4, 250, 214, 6, 4, 250, 234, 6, - 4, 250, 235, 6, 4, 253, 204, 6, 4, 250, 232, 6, 4, 246, 117, 6, 4, 250, - 233, 6, 4, 252, 210, 6, 4, 252, 211, 6, 4, 253, 174, 6, 4, 252, 209, 6, - 4, 248, 128, 6, 4, 249, 89, 6, 4, 248, 127, 6, 4, 250, 85, 6, 4, 252, - 198, 6, 4, 253, 91, 6, 4, 252, 195, 6, 4, 248, 154, 6, 4, 248, 155, 6, 4, - 252, 220, 6, 4, 248, 153, 6, 4, 252, 214, 6, 4, 252, 215, 6, 4, 76, 6, 4, - 249, 168, 6, 4, 252, 204, 6, 4, 253, 151, 6, 4, 252, 200, 6, 4, 252, 223, - 6, 4, 252, 224, 6, 4, 253, 160, 6, 4, 252, 221, 6, 4, 248, 156, 6, 4, - 252, 222, 6, 4, 246, 92, 6, 4, 246, 93, 6, 4, 249, 210, 6, 4, 246, 91, 6, - 4, 243, 86, 6, 4, 246, 90, 6, 4, 243, 85, 6, 4, 246, 85, 6, 4, 246, 86, - 6, 4, 249, 27, 6, 4, 246, 84, 6, 4, 243, 88, 6, 4, 246, 97, 6, 4, 243, - 87, 6, 4, 246, 95, 6, 4, 246, 96, 6, 4, 249, 211, 6, 4, 246, 94, 6, 4, - 246, 89, 6, 4, 249, 209, 6, 4, 246, 88, 6, 4, 246, 99, 6, 4, 246, 100, 6, - 4, 249, 212, 6, 4, 246, 98, 6, 4, 243, 89, 6, 4, 245, 77, 6, 4, 247, 135, - 6, 4, 247, 136, 6, 4, 252, 9, 6, 4, 247, 134, 6, 4, 243, 240, 6, 4, 247, - 133, 6, 4, 247, 129, 6, 4, 247, 130, 6, 4, 252, 7, 6, 4, 247, 128, 6, 4, - 247, 138, 6, 4, 247, 139, 6, 4, 252, 10, 6, 4, 247, 137, 6, 4, 247, 132, - 6, 4, 252, 8, 6, 4, 247, 131, 6, 4, 247, 142, 6, 4, 247, 143, 6, 4, 252, - 11, 6, 4, 247, 140, 6, 4, 243, 241, 6, 4, 247, 141, 6, 4, 246, 224, 6, 4, - 246, 225, 6, 4, 251, 87, 6, 4, 246, 223, 6, 4, 243, 159, 6, 4, 243, 160, - 6, 4, 246, 222, 6, 4, 243, 158, 6, 4, 246, 218, 6, 4, 246, 219, 6, 4, - 249, 244, 6, 4, 246, 217, 6, 4, 243, 161, 6, 4, 246, 229, 6, 4, 246, 227, - 6, 4, 246, 228, 6, 4, 246, 226, 6, 4, 246, 221, 6, 4, 251, 86, 6, 4, 246, - 220, 6, 4, 246, 230, 6, 4, 252, 25, 6, 4, 252, 26, 6, 4, 253, 148, 6, 4, - 252, 24, 6, 4, 247, 159, 6, 4, 252, 22, 6, 4, 247, 158, 6, 4, 252, 1, 6, - 4, 253, 94, 6, 4, 251, 255, 6, 4, 247, 199, 6, 4, 252, 42, 6, 4, 247, - 198, 6, 4, 249, 151, 6, 4, 252, 35, 6, 4, 253, 136, 6, 4, 252, 33, 6, 4, - 252, 15, 6, 4, 253, 157, 6, 4, 252, 13, 6, 4, 252, 45, 6, 4, 252, 46, 6, - 4, 253, 112, 6, 4, 252, 43, 6, 4, 247, 200, 6, 4, 252, 44, 6, 4, 246, - 186, 6, 4, 246, 187, 6, 4, 251, 78, 6, 4, 246, 185, 6, 4, 243, 147, 6, 4, - 246, 184, 6, 4, 243, 146, 6, 4, 246, 180, 6, 4, 246, 181, 6, 4, 251, 76, - 6, 4, 246, 179, 6, 4, 243, 149, 6, 4, 246, 190, 6, 4, 243, 148, 6, 4, - 246, 189, 6, 4, 251, 79, 6, 4, 246, 188, 6, 4, 246, 183, 6, 4, 251, 77, - 6, 4, 246, 182, 6, 4, 246, 193, 6, 4, 246, 194, 6, 4, 251, 80, 6, 4, 246, - 191, 6, 4, 243, 150, 6, 4, 246, 192, 6, 4, 246, 197, 6, 4, 246, 198, 6, - 4, 251, 81, 6, 4, 246, 195, 6, 4, 243, 151, 6, 4, 246, 196, 6, 4, 251, - 200, 6, 4, 251, 201, 6, 4, 253, 211, 6, 4, 251, 198, 6, 4, 247, 65, 6, 4, - 247, 66, 6, 4, 250, 11, 6, 4, 247, 64, 6, 4, 251, 185, 6, 4, 251, 186, 6, - 4, 253, 103, 6, 4, 251, 183, 6, 4, 247, 71, 6, 4, 247, 72, 6, 4, 251, - 208, 6, 4, 247, 70, 6, 4, 251, 205, 6, 4, 251, 207, 6, 4, 253, 184, 6, 4, - 251, 204, 6, 4, 251, 191, 6, 4, 253, 210, 6, 4, 251, 189, 6, 4, 251, 211, - 6, 4, 251, 212, 6, 4, 253, 229, 6, 4, 251, 209, 6, 4, 247, 73, 6, 4, 251, - 210, 6, 4, 251, 214, 6, 4, 251, 215, 6, 4, 254, 54, 6, 4, 251, 213, 6, 4, - 247, 74, 6, 4, 250, 16, 6, 4, 251, 40, 6, 4, 251, 41, 6, 4, 253, 209, 6, - 4, 251, 39, 6, 4, 246, 156, 6, 4, 246, 157, 6, 4, 251, 38, 6, 4, 246, - 155, 6, 4, 251, 26, 6, 4, 251, 27, 6, 4, 253, 100, 6, 4, 251, 24, 6, 4, - 246, 164, 6, 4, 246, 165, 6, 4, 251, 47, 6, 4, 246, 163, 6, 4, 249, 238, - 6, 4, 251, 43, 6, 4, 253, 195, 6, 4, 251, 42, 6, 4, 251, 31, 6, 4, 251, - 33, 6, 4, 253, 207, 6, 4, 249, 230, 6, 4, 251, 50, 6, 4, 251, 51, 6, 4, - 253, 196, 6, 4, 251, 48, 6, 4, 246, 166, 6, 4, 251, 49, 6, 4, 250, 1, 6, - 4, 251, 158, 6, 4, 253, 182, 6, 4, 251, 157, 6, 4, 247, 35, 6, 4, 251, - 154, 6, 4, 247, 34, 6, 4, 251, 143, 6, 4, 251, 145, 6, 4, 208, 6, 4, 251, - 142, 6, 4, 247, 41, 6, 4, 251, 171, 6, 4, 247, 40, 6, 4, 251, 167, 6, 4, - 251, 168, 6, 4, 253, 155, 6, 4, 251, 166, 6, 4, 251, 148, 6, 4, 251, 149, - 6, 4, 253, 134, 6, 4, 251, 147, 6, 4, 251, 174, 6, 4, 251, 175, 6, 4, - 253, 183, 6, 4, 251, 172, 6, 4, 247, 42, 6, 4, 251, 173, 6, 4, 246, 145, - 6, 4, 246, 146, 6, 4, 249, 233, 6, 4, 243, 128, 6, 4, 246, 144, 6, 4, - 243, 127, 6, 4, 246, 138, 6, 4, 246, 139, 6, 4, 249, 231, 6, 4, 246, 137, - 6, 4, 243, 130, 6, 4, 243, 131, 6, 4, 245, 94, 6, 4, 243, 129, 6, 4, 246, - 147, 6, 4, 246, 148, 6, 4, 249, 234, 6, 4, 245, 93, 6, 4, 246, 142, 6, 4, - 246, 143, 6, 4, 249, 232, 6, 4, 246, 141, 6, 4, 246, 151, 6, 4, 246, 152, - 6, 4, 249, 235, 6, 4, 246, 149, 6, 4, 243, 132, 6, 4, 246, 150, 6, 4, - 243, 223, 6, 4, 247, 84, 6, 4, 247, 80, 6, 4, 247, 81, 6, 4, 251, 227, 6, - 4, 247, 79, 6, 4, 243, 225, 6, 4, 247, 88, 6, 4, 243, 224, 6, 4, 247, 86, - 6, 4, 247, 87, 6, 4, 249, 107, 6, 4, 247, 85, 6, 4, 247, 83, 6, 4, 251, - 228, 6, 4, 247, 82, 6, 4, 247, 91, 6, 4, 247, 92, 6, 4, 251, 229, 6, 4, - 247, 89, 6, 4, 243, 226, 6, 4, 247, 90, 6, 4, 245, 110, 6, 4, 246, 243, - 6, 4, 251, 102, 6, 4, 246, 242, 6, 4, 243, 166, 6, 4, 243, 167, 6, 4, - 246, 241, 6, 4, 243, 165, 6, 4, 246, 237, 6, 4, 246, 238, 6, 4, 251, 100, - 6, 4, 246, 236, 6, 4, 243, 169, 6, 4, 243, 170, 6, 4, 245, 112, 6, 4, - 243, 168, 6, 4, 246, 244, 6, 4, 246, 245, 6, 4, 251, 103, 6, 4, 245, 111, - 6, 4, 246, 240, 6, 4, 251, 101, 6, 4, 246, 239, 6, 4, 243, 244, 6, 4, - 247, 151, 6, 4, 243, 243, 6, 4, 247, 147, 6, 4, 247, 148, 6, 4, 249, 13, - 6, 4, 247, 146, 6, 4, 243, 246, 6, 4, 243, 247, 6, 4, 247, 157, 6, 4, - 247, 155, 6, 4, 247, 156, 6, 4, 249, 110, 6, 4, 247, 154, 6, 4, 247, 150, - 6, 4, 252, 17, 6, 4, 247, 149, 6, 4, 251, 75, 6, 4, 246, 176, 6, 4, 249, - 137, 6, 4, 251, 59, 6, 4, 251, 60, 6, 4, 253, 88, 6, 4, 251, 58, 6, 4, - 246, 233, 6, 4, 246, 234, 6, 4, 251, 94, 6, 4, 246, 232, 6, 4, 251, 91, - 6, 4, 251, 92, 6, 4, 253, 140, 6, 4, 251, 90, 6, 4, 251, 67, 6, 4, 253, - 125, 6, 4, 251, 65, 6, 4, 253, 14, 6, 4, 253, 15, 6, 4, 253, 98, 6, 4, - 253, 13, 6, 4, 248, 177, 6, 4, 253, 21, 6, 4, 248, 176, 6, 4, 253, 20, 6, - 4, 253, 138, 6, 4, 253, 18, 6, 4, 253, 17, 6, 4, 253, 132, 6, 4, 253, 16, - 6, 4, 253, 67, 6, 4, 253, 68, 6, 4, 253, 218, 6, 4, 253, 66, 6, 4, 248, - 230, 6, 4, 253, 65, 6, 4, 248, 229, 6, 4, 253, 60, 6, 4, 253, 61, 6, 4, - 253, 129, 6, 4, 253, 59, 6, 4, 248, 232, 6, 4, 253, 73, 6, 4, 248, 231, - 6, 4, 250, 129, 6, 4, 253, 71, 6, 4, 253, 190, 6, 4, 253, 70, 6, 4, 253, - 63, 6, 4, 253, 189, 6, 4, 253, 62, 6, 4, 253, 74, 6, 4, 253, 75, 6, 4, - 253, 233, 6, 4, 250, 130, 6, 4, 248, 233, 6, 4, 250, 131, 6, 4, 253, 79, - 6, 4, 253, 80, 6, 4, 254, 213, 6, 4, 253, 77, 6, 4, 248, 234, 6, 4, 253, - 78, 6, 4, 250, 189, 6, 4, 250, 190, 6, 4, 254, 5, 6, 4, 249, 198, 6, 4, - 246, 66, 6, 4, 246, 67, 6, 4, 250, 187, 6, 4, 246, 65, 6, 4, 250, 178, 6, - 4, 250, 179, 6, 4, 253, 115, 6, 4, 249, 195, 6, 4, 246, 75, 6, 4, 250, - 195, 6, 4, 245, 71, 6, 4, 250, 192, 6, 4, 250, 193, 6, 4, 253, 178, 6, 4, - 250, 191, 6, 4, 250, 183, 6, 4, 254, 4, 6, 4, 250, 182, 6, 4, 250, 197, - 6, 4, 250, 198, 6, 4, 254, 32, 6, 4, 249, 202, 6, 4, 246, 76, 6, 4, 250, - 196, 6, 4, 249, 207, 6, 4, 250, 201, 6, 4, 254, 33, 6, 4, 249, 206, 6, 4, - 246, 77, 6, 4, 250, 200, 6, 4, 248, 242, 6, 4, 248, 243, 6, 4, 253, 83, - 6, 4, 248, 241, 6, 4, 243, 21, 6, 4, 244, 168, 6, 4, 248, 240, 6, 4, 244, - 167, 6, 4, 248, 236, 6, 4, 248, 237, 6, 4, 253, 81, 6, 4, 248, 235, 6, 4, - 248, 245, 6, 4, 253, 84, 6, 4, 248, 244, 6, 4, 248, 239, 6, 4, 253, 82, - 6, 4, 248, 238, 6, 4, 248, 248, 6, 4, 253, 85, 6, 4, 248, 246, 6, 4, 244, - 169, 6, 4, 248, 247, 6, 4, 248, 251, 6, 4, 248, 252, 6, 4, 253, 86, 6, 4, - 248, 249, 6, 4, 244, 170, 6, 4, 248, 250, 6, 4, 247, 220, 6, 4, 247, 221, - 6, 4, 252, 50, 6, 4, 247, 219, 6, 4, 244, 14, 6, 4, 247, 218, 6, 4, 244, - 13, 6, 4, 247, 215, 6, 4, 247, 216, 6, 4, 252, 48, 6, 4, 247, 214, 6, 4, - 244, 15, 6, 4, 247, 224, 6, 4, 247, 223, 6, 4, 247, 222, 6, 4, 247, 217, - 6, 4, 252, 49, 6, 4, 247, 226, 6, 4, 252, 51, 6, 4, 245, 155, 6, 4, 244, - 16, 6, 4, 247, 225, 6, 4, 247, 229, 6, 4, 247, 230, 6, 4, 252, 52, 6, 4, - 247, 227, 6, 4, 244, 17, 6, 4, 247, 228, 6, 4, 252, 168, 6, 4, 169, 6, 4, - 253, 158, 6, 4, 252, 167, 6, 4, 248, 74, 6, 4, 252, 164, 6, 4, 248, 73, - 6, 4, 252, 154, 6, 4, 252, 155, 6, 4, 253, 97, 6, 4, 252, 153, 6, 4, 248, - 108, 6, 4, 252, 180, 6, 4, 248, 107, 6, 4, 252, 172, 6, 4, 252, 173, 6, - 4, 253, 159, 6, 4, 252, 171, 6, 4, 252, 159, 6, 4, 253, 171, 6, 4, 252, - 158, 6, 4, 252, 183, 6, 4, 252, 184, 6, 4, 253, 172, 6, 4, 252, 181, 6, - 4, 248, 109, 6, 4, 252, 182, 6, 4, 252, 187, 6, 4, 252, 188, 6, 4, 254, - 188, 6, 4, 252, 185, 6, 4, 248, 111, 6, 4, 252, 186, 6, 4, 248, 91, 6, 4, - 248, 92, 6, 4, 250, 75, 6, 4, 248, 90, 6, 4, 244, 101, 6, 4, 248, 89, 6, - 4, 244, 100, 6, 4, 248, 85, 6, 4, 248, 86, 6, 4, 249, 34, 6, 4, 248, 84, - 6, 4, 248, 94, 6, 4, 248, 95, 6, 4, 250, 76, 6, 4, 248, 93, 6, 4, 248, - 88, 6, 4, 252, 174, 6, 4, 248, 87, 6, 4, 248, 97, 6, 4, 248, 98, 6, 4, - 252, 175, 6, 4, 248, 96, 6, 4, 248, 101, 6, 4, 248, 102, 6, 4, 252, 176, - 6, 4, 248, 99, 6, 4, 244, 102, 6, 4, 248, 100, 6, 4, 248, 211, 6, 4, 248, - 212, 6, 4, 249, 52, 6, 4, 248, 210, 6, 4, 244, 161, 6, 4, 248, 219, 6, 4, - 244, 160, 6, 4, 248, 217, 6, 4, 248, 218, 6, 4, 250, 126, 6, 4, 248, 216, - 6, 4, 248, 214, 6, 4, 248, 215, 6, 4, 249, 74, 6, 4, 248, 213, 6, 4, 248, - 222, 6, 4, 248, 223, 6, 4, 250, 127, 6, 4, 248, 220, 6, 4, 244, 162, 6, - 4, 248, 221, 6, 4, 248, 227, 6, 4, 248, 228, 6, 4, 253, 64, 6, 4, 248, - 225, 6, 4, 244, 163, 6, 4, 248, 226, 6, 4, 246, 47, 6, 4, 246, 48, 6, 4, - 249, 11, 6, 4, 246, 46, 6, 4, 243, 67, 6, 4, 243, 68, 6, 4, 246, 56, 6, - 4, 243, 66, 6, 4, 246, 54, 6, 4, 246, 55, 6, 4, 249, 94, 6, 4, 246, 53, - 6, 4, 246, 50, 6, 4, 246, 51, 6, 4, 249, 44, 6, 4, 246, 49, 6, 4, 246, - 59, 6, 4, 249, 131, 6, 4, 246, 57, 6, 4, 243, 69, 6, 4, 246, 58, 6, 4, - 246, 63, 6, 4, 246, 64, 6, 4, 250, 186, 6, 4, 246, 61, 6, 4, 243, 70, 6, - 4, 246, 62, 6, 4, 248, 25, 6, 4, 249, 50, 6, 4, 244, 63, 6, 4, 248, 33, - 6, 4, 248, 31, 6, 4, 248, 32, 6, 4, 252, 134, 6, 4, 248, 30, 6, 4, 248, - 28, 6, 4, 248, 29, 6, 4, 252, 133, 6, 4, 248, 27, 6, 4, 248, 36, 6, 4, - 248, 37, 6, 4, 252, 135, 6, 4, 248, 34, 6, 4, 244, 64, 6, 4, 248, 35, 6, - 4, 248, 40, 6, 4, 248, 41, 6, 4, 252, 136, 6, 4, 248, 38, 6, 4, 244, 65, - 6, 4, 248, 39, 6, 4, 247, 182, 6, 4, 247, 183, 6, 4, 252, 36, 6, 4, 247, - 181, 6, 4, 247, 188, 6, 4, 252, 38, 6, 4, 247, 187, 6, 4, 247, 185, 6, 4, - 247, 186, 6, 4, 252, 37, 6, 4, 247, 184, 6, 4, 247, 191, 6, 4, 247, 192, - 6, 4, 252, 39, 6, 4, 247, 189, 6, 4, 244, 5, 6, 4, 247, 190, 6, 4, 247, - 195, 6, 4, 247, 196, 6, 4, 252, 40, 6, 4, 247, 193, 6, 4, 244, 6, 6, 4, - 247, 194, 6, 4, 245, 181, 6, 4, 248, 57, 6, 4, 249, 7, 6, 4, 248, 56, 6, - 4, 244, 81, 6, 4, 248, 65, 6, 4, 244, 80, 6, 4, 248, 63, 6, 4, 248, 64, - 6, 4, 249, 85, 6, 4, 245, 187, 6, 4, 248, 59, 6, 4, 248, 60, 6, 4, 249, - 70, 6, 4, 248, 58, 6, 4, 248, 67, 6, 4, 248, 68, 6, 4, 249, 162, 6, 4, - 248, 66, 6, 4, 244, 82, 6, 4, 245, 188, 6, 4, 248, 71, 6, 4, 248, 72, 6, - 4, 250, 71, 6, 4, 248, 69, 6, 4, 244, 83, 6, 4, 248, 70, 6, 4, 250, 61, - 6, 4, 252, 118, 6, 4, 253, 92, 6, 4, 249, 158, 6, 4, 248, 45, 6, 4, 252, - 139, 6, 4, 248, 44, 6, 4, 252, 131, 6, 4, 252, 132, 6, 4, 253, 144, 6, 4, - 252, 130, 6, 4, 252, 123, 6, 4, 253, 150, 6, 4, 252, 121, 6, 4, 252, 142, - 6, 4, 252, 143, 6, 4, 253, 170, 6, 4, 252, 140, 6, 4, 248, 46, 6, 4, 252, - 141, 6, 4, 252, 148, 6, 4, 252, 149, 6, 4, 254, 70, 6, 4, 252, 146, 6, 4, - 248, 48, 6, 4, 252, 147, 6, 4, 251, 124, 6, 4, 251, 125, 6, 4, 253, 228, - 6, 4, 251, 123, 6, 4, 247, 3, 6, 4, 247, 4, 6, 4, 251, 122, 6, 4, 247, 2, - 6, 4, 247, 22, 6, 4, 247, 23, 6, 4, 251, 130, 6, 4, 247, 21, 6, 4, 249, - 69, 6, 4, 251, 129, 6, 4, 253, 240, 6, 4, 251, 128, 6, 4, 251, 133, 6, 4, - 251, 134, 6, 4, 253, 241, 6, 4, 251, 131, 6, 4, 247, 24, 6, 4, 251, 132, - 6, 4, 251, 138, 6, 4, 251, 139, 6, 4, 254, 123, 6, 4, 251, 136, 6, 4, - 247, 25, 6, 4, 251, 137, 6, 4, 252, 93, 6, 4, 252, 94, 6, 4, 253, 249, 6, - 4, 252, 92, 6, 4, 248, 7, 6, 4, 248, 8, 6, 4, 252, 91, 6, 4, 248, 6, 6, - 4, 248, 10, 6, 4, 248, 11, 6, 4, 250, 58, 6, 4, 248, 9, 6, 4, 250, 57, 6, - 4, 252, 98, 6, 4, 254, 18, 6, 4, 252, 97, 6, 4, 252, 105, 6, 4, 252, 107, - 6, 4, 254, 19, 6, 4, 252, 103, 6, 4, 248, 12, 6, 4, 252, 104, 6, 4, 252, - 113, 6, 4, 252, 114, 6, 4, 254, 178, 6, 4, 252, 111, 6, 4, 248, 16, 6, 4, - 252, 112, 6, 4, 247, 7, 6, 4, 247, 8, 6, 4, 249, 248, 6, 4, 247, 6, 6, 4, - 243, 176, 6, 4, 243, 177, 6, 4, 245, 118, 6, 4, 243, 175, 6, 4, 243, 179, - 6, 4, 247, 12, 6, 4, 243, 178, 6, 4, 247, 10, 6, 4, 247, 11, 6, 4, 249, - 249, 6, 4, 247, 9, 6, 4, 245, 119, 6, 4, 247, 15, 6, 4, 249, 250, 6, 4, - 247, 13, 6, 4, 243, 180, 6, 4, 247, 14, 6, 4, 247, 17, 6, 4, 247, 18, 6, - 4, 249, 251, 6, 4, 247, 16, 6, 4, 247, 163, 6, 4, 247, 164, 6, 4, 252, - 27, 6, 4, 247, 162, 6, 4, 243, 250, 6, 4, 243, 251, 6, 4, 247, 161, 6, 4, - 243, 249, 6, 4, 243, 252, 6, 4, 247, 168, 6, 4, 247, 166, 6, 4, 247, 167, - 6, 4, 252, 28, 6, 4, 247, 165, 6, 4, 247, 171, 6, 4, 252, 29, 6, 4, 247, - 169, 6, 4, 243, 253, 6, 4, 247, 170, 6, 4, 247, 174, 6, 4, 247, 175, 6, - 4, 252, 30, 6, 4, 247, 172, 6, 4, 243, 254, 6, 4, 247, 173, 6, 4, 247, - 205, 6, 4, 247, 206, 6, 4, 250, 33, 6, 4, 245, 153, 6, 4, 244, 9, 6, 4, - 244, 10, 6, 4, 247, 204, 6, 4, 244, 8, 6, 4, 244, 12, 6, 4, 247, 209, 6, - 4, 244, 11, 6, 4, 247, 207, 6, 4, 247, 208, 6, 4, 249, 84, 6, 4, 245, - 154, 6, 4, 247, 211, 6, 4, 247, 212, 6, 4, 250, 34, 6, 4, 247, 210, 6, 4, - 253, 27, 6, 4, 253, 28, 6, 4, 253, 135, 6, 4, 253, 26, 6, 4, 248, 179, 6, - 4, 248, 180, 6, 4, 253, 25, 6, 4, 248, 178, 6, 4, 248, 182, 6, 4, 253, - 33, 6, 4, 253, 31, 6, 4, 253, 32, 6, 4, 254, 77, 6, 4, 253, 29, 6, 4, - 253, 39, 6, 4, 253, 40, 6, 4, 254, 207, 6, 4, 253, 37, 6, 4, 248, 185, 6, - 4, 253, 38, 6, 4, 250, 116, 6, 4, 253, 45, 6, 4, 253, 139, 6, 4, 253, 44, - 6, 4, 248, 192, 6, 4, 248, 193, 6, 4, 253, 42, 6, 4, 248, 191, 6, 4, 248, - 204, 6, 4, 248, 205, 6, 4, 253, 49, 6, 4, 248, 203, 6, 4, 250, 118, 6, 4, - 253, 47, 6, 4, 253, 123, 6, 4, 253, 46, 6, 4, 253, 52, 6, 4, 253, 53, 6, - 4, 253, 124, 6, 4, 253, 50, 6, 4, 248, 206, 6, 4, 253, 51, 6, 4, 253, 56, - 6, 4, 253, 57, 6, 4, 254, 26, 6, 4, 253, 54, 6, 4, 248, 207, 6, 4, 253, - 55, 6, 22, 250, 57, 6, 22, 253, 211, 6, 22, 250, 1, 6, 22, 245, 153, 6, - 22, 249, 206, 6, 22, 250, 75, 6, 22, 245, 93, 6, 22, 249, 230, 6, 22, - 253, 156, 6, 22, 245, 110, 6, 22, 250, 16, 6, 22, 245, 58, 6, 22, 250, - 21, 6, 22, 253, 123, 6, 22, 250, 48, 6, 22, 245, 112, 6, 22, 250, 85, 6, - 22, 253, 100, 6, 22, 250, 130, 6, 22, 249, 207, 6, 22, 245, 77, 6, 22, - 249, 193, 6, 22, 245, 94, 6, 22, 245, 154, 6, 22, 253, 160, 6, 22, 254, - 63, 6, 22, 245, 119, 6, 22, 250, 129, 6, 22, 250, 52, 6, 22, 249, 243, 6, - 22, 250, 116, 6, 22, 250, 108, 6, 22, 250, 71, 6, 22, 250, 103, 6, 22, - 253, 129, 6, 22, 253, 240, 6, 22, 245, 155, 6, 22, 249, 251, 6, 22, 249, - 238, 6, 22, 245, 118, 6, 22, 253, 138, 6, 22, 253, 204, 6, 22, 245, 188, - 6, 22, 250, 11, 6, 22, 254, 33, 6, 22, 245, 71, 6, 22, 249, 198, 6, 22, - 245, 111, 6, 22, 245, 181, 6, 22, 250, 131, 6, 22, 245, 187, 6, 22, 249, - 44, 6, 22, 243, 21, 6, 22, 245, 148, 6, 22, 253, 134, 7, 11, 234, 73, 7, - 11, 234, 74, 7, 11, 234, 75, 7, 11, 234, 76, 7, 11, 234, 77, 7, 11, 234, - 78, 7, 11, 234, 79, 7, 11, 234, 80, 7, 11, 234, 81, 7, 11, 234, 82, 7, - 11, 234, 83, 7, 11, 234, 84, 7, 11, 234, 85, 7, 11, 234, 86, 7, 11, 234, - 87, 7, 11, 234, 88, 7, 11, 234, 89, 7, 11, 234, 90, 7, 11, 234, 91, 7, - 11, 234, 92, 7, 11, 234, 93, 7, 11, 234, 94, 7, 11, 234, 95, 7, 11, 234, - 96, 7, 11, 234, 97, 7, 11, 234, 98, 7, 11, 234, 99, 7, 11, 234, 100, 7, - 11, 234, 101, 7, 11, 234, 102, 7, 11, 234, 103, 7, 11, 234, 104, 7, 11, - 234, 105, 7, 11, 234, 106, 7, 11, 234, 107, 7, 11, 234, 108, 7, 11, 234, - 109, 7, 11, 234, 110, 7, 11, 234, 111, 7, 11, 234, 112, 7, 11, 234, 113, - 7, 11, 234, 114, 7, 11, 234, 115, 7, 11, 234, 116, 7, 11, 234, 117, 7, - 11, 234, 118, 7, 11, 234, 119, 7, 11, 234, 120, 7, 11, 234, 121, 7, 11, - 234, 122, 7, 11, 234, 123, 7, 11, 234, 124, 7, 11, 234, 125, 7, 11, 234, - 126, 7, 11, 234, 127, 7, 11, 234, 128, 7, 11, 234, 129, 7, 11, 234, 130, - 7, 11, 234, 131, 7, 11, 234, 132, 7, 11, 234, 133, 7, 11, 234, 134, 7, - 11, 234, 135, 7, 11, 234, 136, 7, 11, 234, 137, 7, 11, 234, 138, 7, 11, - 234, 139, 7, 11, 234, 140, 7, 11, 234, 141, 7, 11, 234, 142, 7, 11, 234, - 143, 7, 11, 234, 144, 7, 11, 234, 145, 7, 11, 234, 146, 7, 11, 234, 147, - 7, 11, 234, 148, 7, 11, 234, 149, 7, 11, 234, 150, 7, 11, 234, 151, 7, - 11, 234, 152, 7, 11, 234, 153, 7, 11, 234, 154, 7, 11, 234, 155, 7, 11, - 234, 156, 7, 11, 234, 157, 7, 11, 234, 158, 7, 11, 234, 159, 7, 11, 234, - 160, 7, 11, 234, 161, 7, 11, 234, 162, 7, 11, 234, 163, 7, 11, 234, 164, - 7, 11, 234, 165, 7, 11, 234, 166, 7, 11, 234, 167, 7, 11, 234, 168, 7, - 11, 234, 169, 7, 11, 234, 170, 7, 11, 234, 171, 7, 11, 234, 172, 7, 11, - 234, 173, 7, 11, 234, 174, 7, 11, 234, 175, 7, 11, 234, 176, 7, 11, 234, - 177, 7, 11, 234, 178, 7, 11, 234, 179, 7, 11, 234, 180, 7, 11, 234, 181, - 7, 11, 234, 182, 7, 11, 234, 183, 7, 11, 234, 184, 7, 11, 234, 185, 7, - 11, 234, 186, 7, 11, 234, 187, 7, 11, 234, 188, 7, 11, 234, 189, 7, 11, - 234, 190, 7, 11, 234, 191, 7, 11, 234, 192, 7, 11, 234, 193, 7, 11, 234, - 194, 7, 11, 234, 195, 7, 11, 234, 196, 7, 11, 234, 197, 7, 11, 234, 198, - 7, 11, 234, 199, 7, 11, 234, 200, 7, 11, 234, 201, 7, 11, 234, 202, 7, - 11, 234, 203, 7, 11, 234, 204, 7, 11, 234, 205, 7, 11, 234, 206, 7, 11, - 234, 207, 7, 11, 234, 208, 7, 11, 234, 209, 7, 11, 234, 210, 7, 11, 234, - 211, 7, 11, 234, 212, 7, 11, 234, 213, 7, 11, 234, 214, 7, 11, 234, 215, - 7, 11, 234, 216, 7, 11, 234, 217, 7, 11, 234, 218, 7, 11, 234, 219, 7, - 11, 234, 220, 7, 11, 234, 221, 7, 11, 234, 222, 7, 11, 234, 223, 7, 11, - 234, 224, 7, 11, 234, 225, 7, 11, 234, 226, 7, 11, 234, 227, 7, 11, 234, - 228, 7, 11, 234, 229, 7, 11, 234, 230, 7, 11, 234, 231, 7, 11, 234, 232, - 7, 11, 234, 233, 7, 11, 234, 234, 7, 11, 234, 235, 7, 11, 234, 236, 7, - 11, 234, 237, 7, 11, 234, 238, 7, 11, 234, 239, 7, 11, 234, 240, 7, 11, - 234, 241, 7, 11, 234, 242, 7, 11, 234, 243, 7, 11, 234, 244, 7, 11, 234, - 245, 7, 11, 234, 246, 7, 11, 234, 247, 7, 11, 234, 248, 7, 11, 234, 249, - 7, 11, 234, 250, 7, 11, 234, 251, 7, 11, 234, 252, 7, 11, 234, 253, 7, - 11, 234, 254, 7, 11, 234, 255, 7, 11, 235, 0, 7, 11, 235, 1, 7, 11, 235, - 2, 7, 11, 235, 3, 7, 11, 235, 4, 7, 11, 235, 5, 7, 11, 235, 6, 7, 11, - 235, 7, 7, 11, 235, 8, 7, 11, 235, 9, 7, 11, 235, 10, 7, 11, 235, 11, 7, - 11, 235, 12, 7, 11, 235, 13, 7, 11, 235, 14, 7, 11, 235, 15, 7, 11, 235, - 16, 7, 11, 235, 17, 7, 11, 235, 18, 7, 11, 235, 19, 7, 11, 235, 20, 7, - 11, 235, 21, 7, 11, 235, 22, 7, 11, 235, 23, 7, 11, 235, 24, 7, 11, 235, - 25, 7, 11, 235, 26, 7, 11, 235, 27, 7, 11, 235, 28, 7, 11, 235, 29, 7, - 11, 235, 30, 7, 11, 235, 31, 7, 11, 235, 32, 7, 11, 235, 33, 7, 11, 235, - 34, 7, 11, 235, 35, 7, 11, 235, 36, 7, 11, 235, 37, 7, 11, 235, 38, 7, - 11, 235, 39, 7, 11, 235, 40, 7, 11, 235, 41, 7, 11, 235, 42, 7, 11, 235, - 43, 7, 11, 235, 44, 7, 11, 235, 45, 7, 11, 235, 46, 7, 11, 235, 47, 7, - 11, 235, 48, 7, 11, 235, 49, 7, 11, 235, 50, 7, 11, 235, 51, 7, 11, 235, - 52, 7, 11, 235, 53, 7, 11, 235, 54, 7, 11, 235, 55, 7, 11, 235, 56, 7, - 11, 235, 57, 7, 11, 235, 58, 7, 11, 235, 59, 7, 11, 235, 60, 7, 11, 235, - 61, 7, 11, 235, 62, 7, 11, 235, 63, 7, 11, 235, 64, 7, 11, 235, 65, 7, - 11, 235, 66, 7, 11, 235, 67, 7, 11, 235, 68, 7, 11, 235, 69, 7, 11, 235, - 70, 7, 11, 235, 71, 7, 11, 235, 72, 7, 11, 235, 73, 7, 11, 235, 74, 7, - 11, 235, 75, 7, 11, 235, 76, 7, 11, 235, 77, 7, 11, 235, 78, 7, 11, 235, - 79, 7, 11, 235, 80, 7, 11, 235, 81, 7, 11, 235, 82, 7, 11, 235, 83, 7, - 11, 235, 84, 7, 11, 235, 85, 7, 11, 235, 86, 7, 11, 235, 87, 7, 11, 235, - 88, 7, 11, 235, 89, 7, 11, 235, 90, 7, 11, 235, 91, 7, 11, 235, 92, 7, - 11, 235, 93, 7, 11, 235, 94, 7, 11, 235, 95, 7, 11, 235, 96, 7, 11, 235, - 97, 7, 11, 235, 98, 7, 11, 235, 99, 7, 11, 235, 100, 7, 11, 235, 101, 7, - 11, 235, 102, 7, 11, 235, 103, 7, 11, 235, 104, 7, 11, 235, 105, 7, 11, - 235, 106, 7, 11, 235, 107, 7, 11, 235, 108, 7, 11, 235, 109, 7, 11, 235, - 110, 7, 11, 235, 111, 7, 11, 235, 112, 7, 11, 235, 113, 7, 11, 235, 114, - 7, 11, 235, 115, 7, 11, 235, 116, 7, 11, 235, 117, 7, 11, 235, 118, 7, - 11, 235, 119, 7, 11, 235, 120, 7, 11, 235, 121, 7, 11, 235, 122, 7, 11, - 235, 123, 7, 11, 235, 124, 7, 11, 235, 125, 7, 11, 235, 126, 7, 11, 235, - 127, 7, 11, 235, 128, 7, 11, 235, 129, 7, 11, 235, 130, 7, 11, 235, 131, - 7, 11, 235, 132, 7, 11, 235, 133, 7, 11, 235, 134, 7, 11, 235, 135, 7, - 11, 235, 136, 7, 11, 235, 137, 7, 11, 235, 138, 7, 11, 235, 139, 7, 11, - 235, 140, 7, 11, 235, 141, 7, 11, 235, 142, 7, 11, 235, 143, 7, 11, 235, - 144, 7, 11, 235, 145, 7, 11, 235, 146, 7, 11, 235, 147, 7, 11, 235, 148, - 7, 11, 235, 149, 7, 11, 235, 150, 7, 11, 235, 151, 7, 11, 235, 152, 7, - 11, 235, 153, 7, 11, 235, 154, 7, 11, 235, 155, 7, 11, 235, 156, 7, 11, - 235, 157, 7, 11, 235, 158, 7, 11, 235, 159, 7, 11, 235, 160, 7, 11, 235, - 161, 7, 11, 235, 162, 7, 11, 235, 163, 7, 11, 235, 164, 7, 11, 235, 165, - 7, 11, 235, 166, 7, 11, 235, 167, 7, 11, 235, 168, 7, 11, 235, 169, 7, - 11, 235, 170, 7, 11, 235, 171, 7, 11, 235, 172, 7, 11, 235, 173, 7, 11, - 235, 174, 7, 11, 235, 175, 7, 11, 235, 176, 7, 11, 235, 177, 9, 3, 17, - 254, 102, 9, 3, 17, 253, 226, 9, 3, 17, 254, 103, 9, 3, 17, 251, 4, 9, 3, - 17, 251, 5, 9, 3, 17, 165, 255, 29, 190, 9, 3, 17, 254, 186, 87, 3, 17, - 253, 242, 249, 112, 87, 3, 17, 253, 242, 249, 133, 87, 3, 17, 253, 242, - 249, 138, 87, 3, 17, 254, 200, 249, 112, 87, 3, 17, 253, 242, 249, 179, - 61, 1, 254, 0, 2, 242, 222, 61, 244, 180, 236, 25, 242, 50, 61, 17, 241, - 10, 254, 0, 254, 0, 242, 162, 61, 1, 236, 200, 245, 57, 61, 1, 249, 51, - 244, 224, 61, 1, 249, 51, 242, 204, 61, 1, 249, 51, 253, 125, 61, 1, 249, - 51, 249, 81, 61, 1, 249, 51, 242, 179, 61, 1, 249, 51, 29, 249, 147, 61, - 1, 249, 51, 245, 170, 61, 1, 249, 51, 250, 86, 61, 1, 236, 200, 249, 4, - 57, 61, 1, 249, 54, 2, 249, 54, 227, 61, 1, 249, 54, 2, 254, 22, 227, 61, - 1, 249, 54, 2, 242, 176, 18, 249, 54, 227, 61, 1, 249, 54, 2, 242, 176, - 18, 254, 22, 227, 61, 1, 67, 2, 242, 162, 61, 1, 67, 2, 241, 30, 61, 1, - 67, 2, 242, 181, 61, 1, 254, 3, 2, 240, 208, 61, 1, 245, 98, 2, 240, 208, - 61, 1, 245, 76, 2, 240, 208, 61, 1, 255, 9, 2, 242, 181, 61, 1, 254, 24, - 2, 240, 208, 61, 1, 248, 208, 2, 240, 208, 61, 1, 254, 191, 2, 240, 208, - 61, 1, 254, 0, 2, 240, 208, 61, 1, 29, 253, 87, 2, 240, 208, 61, 1, 253, - 87, 2, 240, 208, 61, 1, 247, 54, 2, 240, 208, 61, 1, 254, 142, 2, 240, - 208, 61, 1, 254, 160, 2, 240, 208, 61, 1, 244, 69, 2, 240, 208, 61, 1, - 29, 254, 229, 2, 240, 208, 61, 1, 254, 229, 2, 240, 208, 61, 1, 248, 141, - 2, 240, 208, 61, 1, 254, 177, 2, 240, 208, 61, 1, 252, 122, 2, 240, 208, - 61, 1, 249, 54, 2, 240, 208, 61, 1, 254, 189, 2, 240, 208, 61, 1, 254, - 24, 2, 242, 223, 61, 1, 254, 3, 2, 245, 1, 61, 1, 253, 87, 2, 245, 1, 61, - 1, 254, 229, 2, 245, 1, 61, 17, 67, 242, 179, 10, 1, 67, 245, 219, 35, - 12, 10, 1, 67, 245, 219, 29, 12, 10, 1, 249, 93, 35, 12, 10, 1, 249, 93, - 29, 12, 10, 1, 249, 93, 46, 12, 10, 1, 249, 93, 98, 12, 10, 1, 253, 248, - 35, 12, 10, 1, 253, 248, 29, 12, 10, 1, 253, 248, 46, 12, 10, 1, 253, - 248, 98, 12, 10, 1, 244, 245, 35, 12, 10, 1, 244, 245, 29, 12, 10, 1, - 244, 245, 46, 12, 10, 1, 244, 245, 98, 12, 10, 1, 242, 168, 35, 12, 10, - 1, 242, 168, 29, 12, 10, 1, 242, 168, 46, 12, 10, 1, 242, 168, 98, 12, - 10, 1, 245, 7, 35, 12, 10, 1, 245, 7, 29, 12, 10, 1, 245, 7, 46, 12, 10, - 1, 245, 7, 98, 12, 10, 1, 249, 122, 35, 12, 10, 1, 249, 122, 29, 12, 10, - 1, 249, 122, 46, 12, 10, 1, 249, 122, 98, 12, 10, 1, 253, 254, 35, 12, - 10, 1, 253, 254, 29, 12, 10, 1, 253, 254, 46, 12, 10, 1, 253, 254, 98, - 12, 10, 1, 245, 0, 35, 12, 10, 1, 245, 0, 29, 12, 10, 1, 245, 0, 46, 12, - 10, 1, 245, 0, 98, 12, 10, 1, 249, 99, 35, 12, 10, 1, 249, 99, 29, 12, - 10, 1, 249, 99, 46, 12, 10, 1, 249, 99, 98, 12, 10, 1, 249, 113, 35, 12, - 10, 1, 249, 113, 29, 12, 10, 1, 249, 113, 46, 12, 10, 1, 249, 113, 98, - 12, 10, 1, 244, 240, 35, 12, 10, 1, 244, 240, 29, 12, 10, 1, 244, 240, - 46, 12, 10, 1, 244, 240, 98, 12, 10, 1, 241, 6, 35, 12, 10, 1, 241, 6, - 29, 12, 10, 1, 241, 6, 46, 12, 10, 1, 241, 6, 98, 12, 10, 1, 242, 206, - 35, 12, 10, 1, 242, 206, 29, 12, 10, 1, 245, 75, 35, 12, 10, 1, 245, 75, - 29, 12, 10, 1, 254, 34, 35, 12, 10, 1, 254, 34, 29, 12, 10, 1, 249, 208, - 35, 12, 10, 1, 249, 208, 29, 12, 10, 1, 254, 47, 35, 12, 10, 1, 254, 47, - 29, 12, 10, 1, 250, 65, 35, 12, 10, 1, 250, 65, 29, 12, 10, 1, 244, 253, - 35, 12, 10, 1, 244, 253, 29, 12, 10, 1, 244, 253, 46, 12, 10, 1, 244, - 253, 98, 12, 10, 1, 253, 194, 35, 12, 10, 1, 253, 194, 29, 12, 10, 1, - 253, 194, 46, 12, 10, 1, 253, 194, 98, 12, 10, 1, 249, 103, 35, 12, 10, - 1, 249, 103, 29, 12, 10, 1, 249, 103, 46, 12, 10, 1, 249, 103, 98, 12, - 10, 1, 244, 255, 35, 12, 10, 1, 244, 255, 29, 12, 10, 1, 244, 255, 46, - 12, 10, 1, 244, 255, 98, 12, 10, 1, 177, 242, 218, 35, 12, 10, 1, 177, - 242, 218, 29, 12, 10, 1, 245, 2, 35, 12, 10, 1, 245, 2, 29, 12, 10, 1, - 245, 2, 46, 12, 10, 1, 245, 2, 98, 12, 10, 1, 188, 2, 50, 53, 35, 12, 10, - 1, 188, 2, 50, 53, 29, 12, 10, 1, 188, 249, 79, 35, 12, 10, 1, 188, 249, - 79, 29, 12, 10, 1, 188, 249, 79, 46, 12, 10, 1, 188, 249, 79, 98, 12, 10, - 1, 188, 236, 197, 35, 12, 10, 1, 188, 236, 197, 29, 12, 10, 1, 188, 236, - 197, 46, 12, 10, 1, 188, 236, 197, 98, 12, 10, 1, 50, 242, 139, 35, 12, - 10, 1, 50, 242, 139, 29, 12, 10, 1, 50, 242, 139, 2, 125, 53, 35, 12, 10, - 1, 50, 242, 139, 2, 125, 53, 29, 12, 10, 1, 254, 235, 35, 12, 10, 1, 254, - 235, 29, 12, 10, 1, 254, 235, 46, 12, 10, 1, 254, 235, 98, 12, 10, 1, - 115, 35, 12, 10, 1, 115, 29, 12, 10, 1, 254, 223, 35, 12, 10, 1, 254, - 223, 29, 12, 10, 1, 254, 226, 35, 12, 10, 1, 254, 226, 29, 12, 10, 1, - 115, 2, 125, 53, 35, 12, 10, 1, 254, 255, 35, 12, 10, 1, 254, 255, 29, - 12, 10, 1, 240, 217, 254, 223, 35, 12, 10, 1, 240, 217, 254, 223, 29, 12, - 10, 1, 240, 217, 254, 226, 35, 12, 10, 1, 240, 217, 254, 226, 29, 12, 10, - 1, 144, 35, 12, 10, 1, 144, 29, 12, 10, 1, 144, 46, 12, 10, 1, 144, 98, - 12, 10, 1, 242, 151, 242, 226, 240, 217, 67, 131, 46, 12, 10, 1, 242, - 151, 242, 226, 240, 217, 67, 131, 98, 12, 10, 17, 50, 2, 125, 53, 2, 67, - 35, 12, 10, 17, 50, 2, 125, 53, 2, 67, 29, 12, 10, 17, 50, 2, 125, 53, 2, - 254, 221, 35, 12, 10, 17, 50, 2, 125, 53, 2, 254, 221, 29, 12, 10, 17, - 50, 2, 125, 53, 2, 253, 162, 35, 12, 10, 17, 50, 2, 125, 53, 2, 253, 162, - 29, 12, 10, 17, 50, 2, 125, 53, 2, 115, 35, 12, 10, 17, 50, 2, 125, 53, - 2, 115, 29, 12, 10, 17, 50, 2, 125, 53, 2, 254, 223, 35, 12, 10, 17, 50, - 2, 125, 53, 2, 254, 223, 29, 12, 10, 17, 50, 2, 125, 53, 2, 254, 226, 35, - 12, 10, 17, 50, 2, 125, 53, 2, 254, 226, 29, 12, 10, 17, 50, 2, 125, 53, - 2, 144, 35, 12, 10, 17, 50, 2, 125, 53, 2, 144, 29, 12, 10, 17, 50, 2, - 125, 53, 2, 144, 46, 12, 10, 17, 242, 151, 240, 217, 50, 2, 125, 53, 2, - 67, 131, 35, 12, 10, 17, 242, 151, 240, 217, 50, 2, 125, 53, 2, 67, 131, - 29, 12, 10, 17, 242, 151, 240, 217, 50, 2, 125, 53, 2, 67, 131, 46, 12, - 10, 1, 244, 227, 50, 35, 12, 10, 1, 244, 227, 50, 29, 12, 10, 1, 244, - 227, 50, 46, 12, 10, 1, 244, 227, 50, 98, 12, 10, 17, 50, 2, 125, 53, 2, - 89, 35, 12, 10, 17, 50, 2, 125, 53, 2, 81, 35, 12, 10, 17, 50, 2, 125, - 53, 2, 43, 35, 12, 10, 17, 50, 2, 125, 53, 2, 67, 131, 35, 12, 10, 17, - 50, 2, 125, 53, 2, 50, 35, 12, 10, 17, 253, 102, 2, 89, 35, 12, 10, 17, - 253, 102, 2, 81, 35, 12, 10, 17, 253, 102, 2, 145, 35, 12, 10, 17, 253, - 102, 2, 43, 35, 12, 10, 17, 253, 102, 2, 67, 131, 35, 12, 10, 17, 253, - 102, 2, 50, 35, 12, 10, 17, 191, 2, 89, 35, 12, 10, 17, 191, 2, 81, 35, - 12, 10, 17, 191, 2, 145, 35, 12, 10, 17, 191, 2, 43, 35, 12, 10, 17, 191, - 2, 67, 131, 35, 12, 10, 17, 191, 2, 50, 35, 12, 10, 17, 249, 20, 2, 89, - 35, 12, 10, 17, 249, 20, 2, 43, 35, 12, 10, 17, 249, 20, 2, 67, 131, 35, - 12, 10, 17, 249, 20, 2, 50, 35, 12, 10, 17, 89, 2, 81, 35, 12, 10, 17, - 89, 2, 43, 35, 12, 10, 17, 81, 2, 89, 35, 12, 10, 17, 81, 2, 43, 35, 12, - 10, 17, 145, 2, 89, 35, 12, 10, 17, 145, 2, 81, 35, 12, 10, 17, 145, 2, - 43, 35, 12, 10, 17, 214, 2, 89, 35, 12, 10, 17, 214, 2, 81, 35, 12, 10, - 17, 214, 2, 145, 35, 12, 10, 17, 214, 2, 43, 35, 12, 10, 17, 253, 108, 2, - 81, 35, 12, 10, 17, 253, 108, 2, 43, 35, 12, 10, 17, 253, 107, 2, 89, 35, - 12, 10, 17, 253, 107, 2, 81, 35, 12, 10, 17, 253, 107, 2, 145, 35, 12, - 10, 17, 253, 107, 2, 43, 35, 12, 10, 17, 253, 122, 2, 81, 35, 12, 10, 17, - 253, 122, 2, 43, 35, 12, 10, 17, 253, 201, 2, 43, 35, 12, 10, 17, 253, - 117, 2, 89, 35, 12, 10, 17, 253, 117, 2, 43, 35, 12, 10, 17, 244, 190, 2, - 89, 35, 12, 10, 17, 244, 190, 2, 43, 35, 12, 10, 17, 253, 111, 2, 89, 35, - 12, 10, 17, 253, 111, 2, 81, 35, 12, 10, 17, 253, 111, 2, 145, 35, 12, - 10, 17, 253, 111, 2, 43, 35, 12, 10, 17, 253, 111, 2, 67, 131, 35, 12, - 10, 17, 253, 111, 2, 50, 35, 12, 10, 17, 253, 120, 2, 81, 35, 12, 10, 17, - 253, 120, 2, 43, 35, 12, 10, 17, 253, 120, 2, 67, 131, 35, 12, 10, 17, - 253, 120, 2, 50, 35, 12, 10, 17, 253, 87, 2, 67, 35, 12, 10, 17, 253, 87, - 2, 89, 35, 12, 10, 17, 253, 87, 2, 81, 35, 12, 10, 17, 253, 87, 2, 145, - 35, 12, 10, 17, 253, 87, 2, 155, 35, 12, 10, 17, 253, 87, 2, 43, 35, 12, - 10, 17, 253, 87, 2, 67, 131, 35, 12, 10, 17, 253, 87, 2, 50, 35, 12, 10, - 17, 155, 2, 89, 35, 12, 10, 17, 155, 2, 81, 35, 12, 10, 17, 155, 2, 145, - 35, 12, 10, 17, 155, 2, 43, 35, 12, 10, 17, 155, 2, 67, 131, 35, 12, 10, - 17, 155, 2, 50, 35, 12, 10, 17, 43, 2, 89, 35, 12, 10, 17, 43, 2, 81, 35, - 12, 10, 17, 43, 2, 145, 35, 12, 10, 17, 43, 2, 43, 35, 12, 10, 17, 43, 2, - 67, 131, 35, 12, 10, 17, 43, 2, 50, 35, 12, 10, 17, 177, 2, 89, 35, 12, - 10, 17, 177, 2, 81, 35, 12, 10, 17, 177, 2, 145, 35, 12, 10, 17, 177, 2, - 43, 35, 12, 10, 17, 177, 2, 67, 131, 35, 12, 10, 17, 177, 2, 50, 35, 12, - 10, 17, 188, 2, 89, 35, 12, 10, 17, 188, 2, 43, 35, 12, 10, 17, 188, 2, - 67, 131, 35, 12, 10, 17, 188, 2, 50, 35, 12, 10, 17, 50, 2, 89, 35, 12, - 10, 17, 50, 2, 81, 35, 12, 10, 17, 50, 2, 145, 35, 12, 10, 17, 50, 2, 43, - 35, 12, 10, 17, 50, 2, 67, 131, 35, 12, 10, 17, 50, 2, 50, 35, 12, 10, - 17, 249, 165, 2, 236, 181, 67, 35, 12, 10, 17, 253, 105, 2, 236, 181, 67, - 35, 12, 10, 17, 67, 131, 2, 236, 181, 67, 35, 12, 10, 17, 242, 102, 2, - 239, 211, 35, 12, 10, 17, 242, 102, 2, 239, 220, 35, 12, 10, 17, 242, - 102, 2, 244, 249, 35, 12, 10, 17, 242, 102, 2, 244, 248, 35, 12, 10, 17, - 242, 102, 2, 244, 252, 35, 12, 10, 17, 242, 102, 2, 236, 181, 67, 35, 12, - 10, 17, 50, 2, 125, 53, 2, 253, 105, 29, 12, 10, 17, 50, 2, 125, 53, 2, - 249, 59, 29, 12, 10, 17, 50, 2, 125, 53, 2, 43, 29, 12, 10, 17, 50, 2, - 125, 53, 2, 177, 29, 12, 10, 17, 50, 2, 125, 53, 2, 67, 131, 29, 12, 10, - 17, 50, 2, 125, 53, 2, 50, 29, 12, 10, 17, 253, 102, 2, 253, 105, 29, 12, - 10, 17, 253, 102, 2, 249, 59, 29, 12, 10, 17, 253, 102, 2, 43, 29, 12, - 10, 17, 253, 102, 2, 177, 29, 12, 10, 17, 253, 102, 2, 67, 131, 29, 12, - 10, 17, 253, 102, 2, 50, 29, 12, 10, 17, 191, 2, 253, 105, 29, 12, 10, - 17, 191, 2, 249, 59, 29, 12, 10, 17, 191, 2, 43, 29, 12, 10, 17, 191, 2, - 177, 29, 12, 10, 17, 191, 2, 67, 131, 29, 12, 10, 17, 191, 2, 50, 29, 12, - 10, 17, 249, 20, 2, 253, 105, 29, 12, 10, 17, 249, 20, 2, 249, 59, 29, - 12, 10, 17, 249, 20, 2, 43, 29, 12, 10, 17, 249, 20, 2, 177, 29, 12, 10, - 17, 249, 20, 2, 67, 131, 29, 12, 10, 17, 249, 20, 2, 50, 29, 12, 10, 17, - 253, 111, 2, 67, 131, 29, 12, 10, 17, 253, 111, 2, 50, 29, 12, 10, 17, - 253, 120, 2, 67, 131, 29, 12, 10, 17, 253, 120, 2, 50, 29, 12, 10, 17, - 253, 87, 2, 67, 29, 12, 10, 17, 253, 87, 2, 155, 29, 12, 10, 17, 253, 87, - 2, 43, 29, 12, 10, 17, 253, 87, 2, 67, 131, 29, 12, 10, 17, 253, 87, 2, - 50, 29, 12, 10, 17, 155, 2, 43, 29, 12, 10, 17, 155, 2, 67, 131, 29, 12, - 10, 17, 155, 2, 50, 29, 12, 10, 17, 43, 2, 67, 29, 12, 10, 17, 43, 2, 43, - 29, 12, 10, 17, 177, 2, 253, 105, 29, 12, 10, 17, 177, 2, 249, 59, 29, - 12, 10, 17, 177, 2, 43, 29, 12, 10, 17, 177, 2, 177, 29, 12, 10, 17, 177, - 2, 67, 131, 29, 12, 10, 17, 177, 2, 50, 29, 12, 10, 17, 67, 131, 2, 236, - 181, 67, 29, 12, 10, 17, 50, 2, 253, 105, 29, 12, 10, 17, 50, 2, 249, 59, - 29, 12, 10, 17, 50, 2, 43, 29, 12, 10, 17, 50, 2, 177, 29, 12, 10, 17, - 50, 2, 67, 131, 29, 12, 10, 17, 50, 2, 50, 29, 12, 10, 17, 50, 2, 125, - 53, 2, 89, 46, 12, 10, 17, 50, 2, 125, 53, 2, 81, 46, 12, 10, 17, 50, 2, - 125, 53, 2, 145, 46, 12, 10, 17, 50, 2, 125, 53, 2, 43, 46, 12, 10, 17, - 50, 2, 125, 53, 2, 188, 46, 12, 10, 17, 253, 102, 2, 89, 46, 12, 10, 17, - 253, 102, 2, 81, 46, 12, 10, 17, 253, 102, 2, 145, 46, 12, 10, 17, 253, - 102, 2, 43, 46, 12, 10, 17, 253, 102, 2, 188, 46, 12, 10, 17, 191, 2, 89, - 46, 12, 10, 17, 191, 2, 81, 46, 12, 10, 17, 191, 2, 145, 46, 12, 10, 17, - 191, 2, 43, 46, 12, 10, 17, 191, 2, 188, 46, 12, 10, 17, 249, 20, 2, 43, - 46, 12, 10, 17, 89, 2, 81, 46, 12, 10, 17, 89, 2, 43, 46, 12, 10, 17, 81, - 2, 89, 46, 12, 10, 17, 81, 2, 43, 46, 12, 10, 17, 145, 2, 89, 46, 12, 10, - 17, 145, 2, 43, 46, 12, 10, 17, 214, 2, 89, 46, 12, 10, 17, 214, 2, 81, - 46, 12, 10, 17, 214, 2, 145, 46, 12, 10, 17, 214, 2, 43, 46, 12, 10, 17, - 253, 108, 2, 81, 46, 12, 10, 17, 253, 108, 2, 145, 46, 12, 10, 17, 253, - 108, 2, 43, 46, 12, 10, 17, 253, 107, 2, 89, 46, 12, 10, 17, 253, 107, 2, - 81, 46, 12, 10, 17, 253, 107, 2, 145, 46, 12, 10, 17, 253, 107, 2, 43, - 46, 12, 10, 17, 253, 122, 2, 81, 46, 12, 10, 17, 253, 201, 2, 43, 46, 12, - 10, 17, 253, 117, 2, 89, 46, 12, 10, 17, 253, 117, 2, 43, 46, 12, 10, 17, - 244, 190, 2, 89, 46, 12, 10, 17, 244, 190, 2, 43, 46, 12, 10, 17, 253, - 111, 2, 89, 46, 12, 10, 17, 253, 111, 2, 81, 46, 12, 10, 17, 253, 111, 2, - 145, 46, 12, 10, 17, 253, 111, 2, 43, 46, 12, 10, 17, 253, 120, 2, 81, - 46, 12, 10, 17, 253, 120, 2, 43, 46, 12, 10, 17, 253, 87, 2, 89, 46, 12, - 10, 17, 253, 87, 2, 81, 46, 12, 10, 17, 253, 87, 2, 145, 46, 12, 10, 17, - 253, 87, 2, 155, 46, 12, 10, 17, 253, 87, 2, 43, 46, 12, 10, 17, 155, 2, - 89, 46, 12, 10, 17, 155, 2, 81, 46, 12, 10, 17, 155, 2, 145, 46, 12, 10, - 17, 155, 2, 43, 46, 12, 10, 17, 155, 2, 188, 46, 12, 10, 17, 43, 2, 89, - 46, 12, 10, 17, 43, 2, 81, 46, 12, 10, 17, 43, 2, 145, 46, 12, 10, 17, - 43, 2, 43, 46, 12, 10, 17, 177, 2, 89, 46, 12, 10, 17, 177, 2, 81, 46, - 12, 10, 17, 177, 2, 145, 46, 12, 10, 17, 177, 2, 43, 46, 12, 10, 17, 177, - 2, 188, 46, 12, 10, 17, 188, 2, 89, 46, 12, 10, 17, 188, 2, 43, 46, 12, - 10, 17, 188, 2, 236, 181, 67, 46, 12, 10, 17, 50, 2, 89, 46, 12, 10, 17, - 50, 2, 81, 46, 12, 10, 17, 50, 2, 145, 46, 12, 10, 17, 50, 2, 43, 46, 12, - 10, 17, 50, 2, 188, 46, 12, 10, 17, 50, 2, 125, 53, 2, 43, 98, 12, 10, - 17, 50, 2, 125, 53, 2, 188, 98, 12, 10, 17, 253, 102, 2, 43, 98, 12, 10, - 17, 253, 102, 2, 188, 98, 12, 10, 17, 191, 2, 43, 98, 12, 10, 17, 191, 2, - 188, 98, 12, 10, 17, 249, 20, 2, 43, 98, 12, 10, 17, 249, 20, 2, 188, 98, - 12, 10, 17, 214, 2, 43, 98, 12, 10, 17, 214, 2, 188, 98, 12, 10, 17, 215, - 2, 43, 98, 12, 10, 17, 215, 2, 188, 98, 12, 10, 17, 253, 87, 2, 155, 98, - 12, 10, 17, 253, 87, 2, 43, 98, 12, 10, 17, 155, 2, 43, 98, 12, 10, 17, - 177, 2, 43, 98, 12, 10, 17, 177, 2, 188, 98, 12, 10, 17, 50, 2, 43, 98, - 12, 10, 17, 50, 2, 188, 98, 12, 10, 17, 242, 102, 2, 244, 249, 98, 12, - 10, 17, 242, 102, 2, 244, 248, 98, 12, 10, 17, 242, 102, 2, 244, 252, 98, - 12, 10, 17, 253, 122, 2, 67, 131, 35, 12, 10, 17, 253, 122, 2, 50, 35, - 12, 10, 17, 253, 117, 2, 67, 131, 35, 12, 10, 17, 253, 117, 2, 50, 35, - 12, 10, 17, 244, 190, 2, 67, 131, 35, 12, 10, 17, 244, 190, 2, 50, 35, - 12, 10, 17, 214, 2, 67, 131, 35, 12, 10, 17, 214, 2, 50, 35, 12, 10, 17, - 215, 2, 67, 131, 35, 12, 10, 17, 215, 2, 50, 35, 12, 10, 17, 81, 2, 67, - 131, 35, 12, 10, 17, 81, 2, 50, 35, 12, 10, 17, 89, 2, 67, 131, 35, 12, - 10, 17, 89, 2, 50, 35, 12, 10, 17, 145, 2, 67, 131, 35, 12, 10, 17, 145, - 2, 50, 35, 12, 10, 17, 253, 108, 2, 67, 131, 35, 12, 10, 17, 253, 108, 2, - 50, 35, 12, 10, 17, 253, 107, 2, 67, 131, 35, 12, 10, 17, 253, 107, 2, - 50, 35, 12, 10, 17, 215, 2, 89, 35, 12, 10, 17, 215, 2, 81, 35, 12, 10, - 17, 215, 2, 145, 35, 12, 10, 17, 215, 2, 43, 35, 12, 10, 17, 215, 2, 253, - 105, 35, 12, 10, 17, 214, 2, 253, 105, 35, 12, 10, 17, 253, 108, 2, 253, - 105, 35, 12, 10, 17, 253, 107, 2, 253, 105, 35, 12, 10, 17, 253, 122, 2, - 67, 131, 29, 12, 10, 17, 253, 122, 2, 50, 29, 12, 10, 17, 253, 117, 2, - 67, 131, 29, 12, 10, 17, 253, 117, 2, 50, 29, 12, 10, 17, 244, 190, 2, - 67, 131, 29, 12, 10, 17, 244, 190, 2, 50, 29, 12, 10, 17, 214, 2, 67, - 131, 29, 12, 10, 17, 214, 2, 50, 29, 12, 10, 17, 215, 2, 67, 131, 29, 12, - 10, 17, 215, 2, 50, 29, 12, 10, 17, 81, 2, 67, 131, 29, 12, 10, 17, 81, - 2, 50, 29, 12, 10, 17, 89, 2, 67, 131, 29, 12, 10, 17, 89, 2, 50, 29, 12, - 10, 17, 145, 2, 67, 131, 29, 12, 10, 17, 145, 2, 50, 29, 12, 10, 17, 253, - 108, 2, 67, 131, 29, 12, 10, 17, 253, 108, 2, 50, 29, 12, 10, 17, 253, - 107, 2, 67, 131, 29, 12, 10, 17, 253, 107, 2, 50, 29, 12, 10, 17, 215, 2, - 89, 29, 12, 10, 17, 215, 2, 81, 29, 12, 10, 17, 215, 2, 145, 29, 12, 10, - 17, 215, 2, 43, 29, 12, 10, 17, 215, 2, 253, 105, 29, 12, 10, 17, 214, 2, - 253, 105, 29, 12, 10, 17, 253, 108, 2, 253, 105, 29, 12, 10, 17, 253, - 107, 2, 253, 105, 29, 12, 10, 17, 215, 2, 89, 46, 12, 10, 17, 215, 2, 81, - 46, 12, 10, 17, 215, 2, 145, 46, 12, 10, 17, 215, 2, 43, 46, 12, 10, 17, - 214, 2, 188, 46, 12, 10, 17, 215, 2, 188, 46, 12, 10, 17, 253, 122, 2, - 43, 46, 12, 10, 17, 214, 2, 89, 98, 12, 10, 17, 214, 2, 81, 98, 12, 10, - 17, 214, 2, 145, 98, 12, 10, 17, 215, 2, 89, 98, 12, 10, 17, 215, 2, 81, - 98, 12, 10, 17, 215, 2, 145, 98, 12, 10, 17, 253, 122, 2, 43, 98, 12, 10, - 17, 253, 201, 2, 43, 98, 12, 10, 17, 67, 2, 239, 172, 29, 12, 10, 17, 67, - 2, 239, 172, 35, 12, 242, 236, 36, 236, 47, 242, 236, 37, 236, 47, 10, - 17, 191, 2, 89, 2, 43, 46, 12, 10, 17, 191, 2, 81, 2, 89, 29, 12, 10, 17, - 191, 2, 81, 2, 89, 46, 12, 10, 17, 191, 2, 81, 2, 43, 46, 12, 10, 17, - 191, 2, 145, 2, 43, 46, 12, 10, 17, 191, 2, 43, 2, 89, 46, 12, 10, 17, - 191, 2, 43, 2, 81, 46, 12, 10, 17, 191, 2, 43, 2, 145, 46, 12, 10, 17, - 89, 2, 43, 2, 81, 29, 12, 10, 17, 89, 2, 43, 2, 81, 46, 12, 10, 17, 81, - 2, 43, 2, 50, 29, 12, 10, 17, 81, 2, 43, 2, 67, 131, 29, 12, 10, 17, 214, - 2, 81, 2, 89, 46, 12, 10, 17, 214, 2, 89, 2, 81, 46, 12, 10, 17, 214, 2, - 89, 2, 67, 131, 29, 12, 10, 17, 214, 2, 43, 2, 81, 29, 12, 10, 17, 214, - 2, 43, 2, 81, 46, 12, 10, 17, 214, 2, 43, 2, 89, 46, 12, 10, 17, 214, 2, - 43, 2, 43, 29, 12, 10, 17, 214, 2, 43, 2, 43, 46, 12, 10, 17, 253, 108, - 2, 81, 2, 81, 29, 12, 10, 17, 253, 108, 2, 81, 2, 81, 46, 12, 10, 17, - 253, 108, 2, 43, 2, 43, 29, 12, 10, 17, 215, 2, 81, 2, 43, 29, 12, 10, - 17, 215, 2, 81, 2, 43, 46, 12, 10, 17, 215, 2, 89, 2, 50, 29, 12, 10, 17, - 215, 2, 43, 2, 145, 29, 12, 10, 17, 215, 2, 43, 2, 145, 46, 12, 10, 17, - 215, 2, 43, 2, 43, 29, 12, 10, 17, 215, 2, 43, 2, 43, 46, 12, 10, 17, - 253, 107, 2, 81, 2, 67, 131, 29, 12, 10, 17, 253, 107, 2, 145, 2, 43, 29, - 12, 10, 17, 253, 107, 2, 145, 2, 43, 46, 12, 10, 17, 253, 122, 2, 43, 2, - 81, 29, 12, 10, 17, 253, 122, 2, 43, 2, 81, 46, 12, 10, 17, 253, 122, 2, - 43, 2, 43, 46, 12, 10, 17, 253, 122, 2, 43, 2, 50, 29, 12, 10, 17, 253, - 117, 2, 89, 2, 43, 29, 12, 10, 17, 253, 117, 2, 43, 2, 43, 29, 12, 10, - 17, 253, 117, 2, 43, 2, 43, 46, 12, 10, 17, 253, 117, 2, 43, 2, 67, 131, - 29, 12, 10, 17, 244, 190, 2, 43, 2, 43, 29, 12, 10, 17, 244, 190, 2, 43, - 2, 50, 29, 12, 10, 17, 244, 190, 2, 43, 2, 67, 131, 29, 12, 10, 17, 253, - 111, 2, 145, 2, 43, 29, 12, 10, 17, 253, 111, 2, 145, 2, 43, 46, 12, 10, - 17, 253, 120, 2, 43, 2, 81, 29, 12, 10, 17, 253, 120, 2, 43, 2, 43, 29, - 12, 10, 17, 155, 2, 81, 2, 43, 29, 12, 10, 17, 155, 2, 81, 2, 50, 29, 12, - 10, 17, 155, 2, 81, 2, 67, 131, 29, 12, 10, 17, 155, 2, 89, 2, 89, 46, - 12, 10, 17, 155, 2, 89, 2, 89, 29, 12, 10, 17, 155, 2, 145, 2, 43, 29, - 12, 10, 17, 155, 2, 145, 2, 43, 46, 12, 10, 17, 155, 2, 43, 2, 81, 29, - 12, 10, 17, 155, 2, 43, 2, 81, 46, 12, 10, 17, 43, 2, 81, 2, 89, 46, 12, - 10, 17, 43, 2, 81, 2, 43, 46, 12, 10, 17, 43, 2, 81, 2, 50, 29, 12, 10, - 17, 43, 2, 89, 2, 81, 46, 12, 10, 17, 43, 2, 89, 2, 43, 46, 12, 10, 17, - 43, 2, 145, 2, 89, 46, 12, 10, 17, 43, 2, 145, 2, 43, 46, 12, 10, 17, 43, - 2, 89, 2, 145, 46, 12, 10, 17, 188, 2, 43, 2, 89, 46, 12, 10, 17, 188, 2, - 43, 2, 43, 46, 12, 10, 17, 177, 2, 81, 2, 43, 46, 12, 10, 17, 177, 2, 81, - 2, 67, 131, 29, 12, 10, 17, 177, 2, 89, 2, 43, 29, 12, 10, 17, 177, 2, - 89, 2, 43, 46, 12, 10, 17, 177, 2, 89, 2, 67, 131, 29, 12, 10, 17, 177, - 2, 43, 2, 50, 29, 12, 10, 17, 177, 2, 43, 2, 67, 131, 29, 12, 10, 17, 50, - 2, 43, 2, 43, 29, 12, 10, 17, 50, 2, 43, 2, 43, 46, 12, 10, 17, 253, 102, - 2, 145, 2, 50, 29, 12, 10, 17, 191, 2, 89, 2, 50, 29, 12, 10, 17, 191, 2, - 89, 2, 67, 131, 29, 12, 10, 17, 191, 2, 145, 2, 50, 29, 12, 10, 17, 191, - 2, 145, 2, 67, 131, 29, 12, 10, 17, 191, 2, 43, 2, 50, 29, 12, 10, 17, - 191, 2, 43, 2, 67, 131, 29, 12, 10, 17, 89, 2, 43, 2, 50, 29, 12, 10, 17, - 89, 2, 81, 2, 67, 131, 29, 12, 10, 17, 89, 2, 43, 2, 67, 131, 29, 12, 10, - 17, 214, 2, 145, 2, 67, 131, 29, 12, 10, 17, 253, 108, 2, 81, 2, 50, 29, - 12, 10, 17, 215, 2, 81, 2, 50, 29, 12, 10, 17, 253, 107, 2, 81, 2, 50, - 29, 12, 10, 17, 155, 2, 89, 2, 50, 29, 12, 10, 17, 155, 2, 43, 2, 50, 29, - 12, 10, 17, 50, 2, 81, 2, 50, 29, 12, 10, 17, 50, 2, 89, 2, 50, 29, 12, - 10, 17, 50, 2, 43, 2, 50, 29, 12, 10, 17, 43, 2, 43, 2, 50, 29, 12, 10, - 17, 253, 120, 2, 43, 2, 50, 29, 12, 10, 17, 177, 2, 81, 2, 50, 29, 12, - 10, 17, 253, 120, 2, 43, 2, 81, 46, 12, 10, 17, 155, 2, 81, 2, 43, 46, - 12, 10, 17, 253, 117, 2, 43, 2, 50, 29, 12, 10, 17, 253, 87, 2, 43, 2, - 50, 29, 12, 10, 17, 177, 2, 89, 2, 81, 46, 12, 10, 17, 43, 2, 145, 2, 50, - 29, 12, 10, 17, 155, 2, 89, 2, 43, 46, 12, 10, 17, 253, 87, 2, 43, 2, 43, - 29, 12, 10, 17, 155, 2, 89, 2, 43, 29, 12, 10, 17, 177, 2, 89, 2, 81, 29, - 12, 10, 17, 89, 2, 81, 2, 50, 29, 12, 10, 17, 81, 2, 89, 2, 50, 29, 12, - 10, 17, 43, 2, 89, 2, 50, 29, 12, 10, 17, 253, 111, 2, 43, 2, 50, 29, 12, - 10, 17, 253, 102, 2, 81, 2, 50, 29, 12, 10, 17, 253, 87, 2, 43, 2, 43, - 46, 12, 10, 17, 253, 117, 2, 89, 2, 43, 46, 12, 10, 17, 253, 108, 2, 43, - 2, 43, 46, 12, 10, 17, 214, 2, 145, 2, 50, 29, 12, 10, 17, 177, 2, 89, 2, - 50, 29, 12, 10, 17, 245, 176, 250, 101, 254, 217, 241, 64, 249, 71, 25, - 35, 12, 10, 17, 252, 82, 250, 101, 254, 217, 241, 64, 249, 71, 25, 35, - 12, 10, 17, 245, 244, 35, 12, 10, 17, 245, 242, 35, 12, 10, 17, 240, 118, - 35, 12, 10, 17, 248, 52, 35, 12, 10, 17, 244, 52, 35, 12, 10, 17, 242, - 196, 35, 12, 10, 17, 240, 196, 35, 12, 10, 17, 245, 176, 35, 12, 10, 17, - 237, 85, 242, 196, 239, 111, 10, 17, 234, 51, 252, 124, 57, 238, 79, 237, - 86, 238, 79, 237, 87, 238, 79, 237, 88, 238, 79, 237, 89, 238, 79, 237, - 90, 238, 79, 237, 91, 238, 79, 237, 92, 238, 79, 237, 93, 238, 79, 237, - 94, 238, 79, 236, 163, 238, 79, 236, 164, 238, 79, 236, 165, 238, 79, - 236, 166, 238, 79, 236, 167, 238, 79, 236, 168, 238, 79, 236, 169, 48, - 17, 36, 244, 217, 48, 17, 37, 244, 217, 48, 42, 229, 36, 244, 217, 48, - 42, 229, 37, 244, 217, 236, 45, 249, 3, 54, 55, 225, 49, 241, 25, 236, - 45, 249, 3, 54, 55, 254, 220, 244, 189, 236, 45, 249, 3, 54, 55, 254, - 215, 244, 189, 236, 45, 249, 3, 54, 55, 253, 113, 244, 176, 236, 45, 249, - 3, 54, 55, 249, 57, 253, 113, 244, 176, 236, 45, 249, 3, 54, 55, 36, 236, - 47, 236, 45, 249, 3, 54, 55, 37, 236, 47, 236, 45, 249, 3, 54, 55, 36, - 244, 175, 110, 236, 45, 249, 3, 54, 55, 37, 244, 175, 110, 236, 45, 249, - 3, 54, 55, 36, 239, 139, 244, 202, 110, 236, 45, 249, 3, 54, 55, 37, 239, - 139, 244, 202, 110, 236, 45, 249, 3, 54, 55, 36, 86, 237, 126, 110, 236, - 45, 249, 3, 54, 55, 37, 86, 237, 126, 110, 236, 45, 249, 3, 54, 55, 36, - 42, 160, 110, 236, 45, 249, 3, 54, 55, 37, 42, 160, 110, 236, 45, 249, 3, - 54, 55, 36, 160, 110, 236, 45, 249, 3, 54, 55, 37, 160, 110, 236, 45, - 249, 3, 54, 55, 36, 242, 86, 110, 236, 45, 249, 3, 54, 55, 37, 242, 86, - 110, 236, 45, 249, 3, 54, 55, 36, 58, 242, 86, 110, 236, 45, 249, 3, 54, - 55, 37, 58, 242, 86, 110, 242, 247, 227, 58, 242, 247, 227, 242, 105, - 238, 98, 237, 149, 238, 98, 249, 57, 238, 98, 42, 249, 57, 238, 98, 242, - 105, 253, 113, 244, 176, 237, 149, 253, 113, 244, 176, 249, 57, 253, 113, - 244, 176, 3, 242, 84, 3, 66, 242, 84, 3, 213, 189, 3, 237, 123, 3, 242, - 81, 3, 239, 126, 65, 3, 236, 186, 65, 3, 254, 220, 244, 189, 3, 36, 236, - 47, 3, 37, 236, 47, 3, 36, 244, 175, 110, 3, 37, 244, 175, 110, 3, 36, - 239, 139, 244, 202, 110, 3, 37, 239, 139, 244, 202, 110, 3, 83, 57, 3, - 237, 124, 3, 238, 77, 3, 249, 4, 57, 3, 235, 243, 3, 206, 57, 3, 196, 57, - 3, 242, 61, 57, 3, 240, 219, 239, 144, 3, 242, 158, 57, 3, 240, 248, 57, - 3, 237, 127, 253, 220, 10, 239, 172, 35, 12, 10, 242, 30, 2, 239, 172, - 47, 10, 239, 211, 35, 12, 10, 249, 88, 239, 20, 10, 239, 220, 35, 12, 10, - 244, 249, 35, 12, 10, 244, 249, 98, 12, 10, 244, 248, 35, 12, 10, 244, - 248, 98, 12, 10, 244, 252, 35, 12, 10, 244, 252, 98, 12, 10, 242, 102, - 35, 12, 10, 242, 102, 98, 12, 10, 245, 197, 35, 12, 10, 245, 197, 98, 12, - 10, 1, 125, 35, 12, 10, 1, 67, 2, 244, 237, 53, 35, 12, 10, 1, 67, 2, - 244, 237, 53, 29, 12, 10, 1, 67, 2, 125, 53, 35, 12, 10, 1, 67, 2, 125, - 53, 29, 12, 10, 1, 253, 162, 2, 125, 53, 35, 12, 10, 1, 253, 162, 2, 125, - 53, 29, 12, 10, 1, 67, 2, 125, 244, 188, 35, 12, 10, 1, 67, 2, 125, 244, - 188, 29, 12, 10, 1, 50, 2, 125, 53, 35, 12, 10, 1, 50, 2, 125, 53, 29, - 12, 10, 1, 50, 2, 125, 53, 46, 12, 10, 1, 50, 2, 125, 53, 98, 12, 10, 1, - 67, 35, 12, 10, 1, 67, 29, 12, 10, 1, 253, 102, 35, 12, 10, 1, 253, 102, - 29, 12, 10, 1, 253, 102, 46, 12, 10, 1, 253, 102, 98, 12, 10, 1, 191, - 241, 26, 35, 12, 10, 1, 191, 241, 26, 29, 12, 10, 1, 191, 35, 12, 10, 1, - 191, 29, 12, 10, 1, 191, 46, 12, 10, 1, 191, 98, 12, 10, 1, 249, 20, 35, - 12, 10, 1, 249, 20, 29, 12, 10, 1, 249, 20, 46, 12, 10, 1, 249, 20, 98, - 12, 10, 1, 89, 35, 12, 10, 1, 89, 29, 12, 10, 1, 89, 46, 12, 10, 1, 89, - 98, 12, 10, 1, 81, 35, 12, 10, 1, 81, 29, 12, 10, 1, 81, 46, 12, 10, 1, - 81, 98, 12, 10, 1, 145, 35, 12, 10, 1, 145, 29, 12, 10, 1, 145, 46, 12, - 10, 1, 145, 98, 12, 10, 1, 253, 180, 35, 12, 10, 1, 253, 180, 29, 12, 10, - 1, 249, 165, 35, 12, 10, 1, 249, 165, 29, 12, 10, 1, 253, 105, 35, 12, - 10, 1, 253, 105, 29, 12, 10, 1, 249, 59, 35, 12, 10, 1, 249, 59, 29, 12, - 10, 1, 214, 35, 12, 10, 1, 214, 29, 12, 10, 1, 214, 46, 12, 10, 1, 214, - 98, 12, 10, 1, 215, 35, 12, 10, 1, 215, 29, 12, 10, 1, 215, 46, 12, 10, - 1, 215, 98, 12, 10, 1, 253, 108, 35, 12, 10, 1, 253, 108, 29, 12, 10, 1, - 253, 108, 46, 12, 10, 1, 253, 108, 98, 12, 10, 1, 253, 107, 35, 12, 10, - 1, 253, 107, 29, 12, 10, 1, 253, 107, 46, 12, 10, 1, 253, 107, 98, 12, - 10, 1, 253, 122, 35, 12, 10, 1, 253, 122, 29, 12, 10, 1, 253, 122, 46, - 12, 10, 1, 253, 122, 98, 12, 10, 1, 253, 201, 35, 12, 10, 1, 253, 201, - 29, 12, 10, 1, 253, 201, 46, 12, 10, 1, 253, 201, 98, 12, 10, 1, 253, - 117, 35, 12, 10, 1, 253, 117, 29, 12, 10, 1, 253, 117, 46, 12, 10, 1, - 253, 117, 98, 12, 10, 1, 244, 190, 35, 12, 10, 1, 244, 190, 29, 12, 10, - 1, 244, 190, 46, 12, 10, 1, 244, 190, 98, 12, 10, 1, 253, 111, 35, 12, - 10, 1, 253, 111, 29, 12, 10, 1, 253, 111, 46, 12, 10, 1, 253, 111, 98, - 12, 10, 1, 253, 120, 35, 12, 10, 1, 253, 120, 29, 12, 10, 1, 253, 120, - 46, 12, 10, 1, 253, 120, 98, 12, 10, 1, 253, 87, 35, 12, 10, 1, 253, 87, - 29, 12, 10, 1, 253, 87, 46, 12, 10, 1, 253, 87, 98, 12, 10, 1, 155, 35, - 12, 10, 1, 155, 29, 12, 10, 1, 155, 46, 12, 10, 1, 155, 98, 12, 10, 1, - 43, 35, 12, 10, 1, 43, 29, 12, 10, 1, 43, 46, 12, 10, 1, 43, 98, 12, 10, - 1, 177, 35, 12, 10, 1, 177, 29, 12, 10, 1, 177, 46, 12, 10, 1, 177, 98, - 12, 10, 1, 188, 35, 12, 10, 1, 188, 29, 12, 10, 1, 188, 46, 12, 10, 1, - 188, 98, 12, 10, 1, 253, 162, 35, 12, 10, 1, 253, 162, 29, 12, 10, 1, 67, - 131, 35, 12, 10, 1, 67, 131, 29, 12, 10, 1, 50, 35, 12, 10, 1, 50, 29, - 12, 10, 1, 50, 46, 12, 10, 1, 50, 98, 12, 10, 17, 155, 2, 67, 2, 244, - 237, 53, 35, 12, 10, 17, 155, 2, 67, 2, 244, 237, 53, 29, 12, 10, 17, - 155, 2, 67, 2, 125, 53, 35, 12, 10, 17, 155, 2, 67, 2, 125, 53, 29, 12, - 10, 17, 155, 2, 67, 2, 125, 244, 188, 35, 12, 10, 17, 155, 2, 67, 2, 125, - 244, 188, 29, 12, 10, 17, 155, 2, 67, 35, 12, 10, 17, 155, 2, 67, 29, 12, - 249, 127, 245, 12, 239, 190, 242, 69, 73, 236, 186, 65, 73, 238, 76, 65, - 73, 83, 57, 73, 242, 158, 57, 73, 240, 248, 57, 73, 237, 124, 73, 236, - 190, 73, 36, 236, 47, 73, 37, 236, 47, 73, 238, 77, 73, 249, 4, 57, 73, - 242, 84, 73, 235, 243, 73, 213, 189, 73, 239, 144, 73, 27, 244, 173, 73, - 27, 121, 73, 27, 114, 73, 27, 153, 73, 27, 163, 73, 27, 168, 73, 27, 169, - 73, 27, 179, 73, 27, 176, 73, 27, 178, 73, 242, 81, 73, 237, 123, 73, - 206, 57, 73, 242, 61, 57, 73, 196, 57, 73, 239, 126, 65, 73, 237, 127, - 253, 220, 73, 9, 5, 1, 64, 73, 9, 5, 1, 199, 73, 9, 5, 1, 203, 73, 9, 5, - 1, 187, 73, 9, 5, 1, 70, 73, 9, 5, 1, 204, 73, 9, 5, 1, 194, 73, 9, 5, 1, - 164, 73, 9, 5, 1, 69, 73, 9, 5, 1, 200, 73, 9, 5, 1, 205, 73, 9, 5, 1, - 148, 73, 9, 5, 1, 171, 73, 9, 5, 1, 183, 73, 9, 5, 1, 78, 73, 9, 5, 1, - 198, 73, 9, 5, 1, 209, 73, 9, 5, 1, 135, 73, 9, 5, 1, 159, 73, 9, 5, 1, - 190, 73, 9, 5, 1, 84, 73, 9, 5, 1, 186, 73, 9, 5, 1, 201, 73, 9, 5, 1, - 170, 73, 9, 5, 1, 181, 73, 9, 5, 1, 202, 73, 36, 30, 110, 73, 240, 219, - 239, 144, 73, 37, 30, 110, 73, 157, 240, 203, 73, 253, 113, 244, 176, 73, - 244, 201, 240, 203, 73, 9, 3, 1, 64, 73, 9, 3, 1, 199, 73, 9, 3, 1, 203, - 73, 9, 3, 1, 187, 73, 9, 3, 1, 70, 73, 9, 3, 1, 204, 73, 9, 3, 1, 194, - 73, 9, 3, 1, 164, 73, 9, 3, 1, 69, 73, 9, 3, 1, 200, 73, 9, 3, 1, 205, - 73, 9, 3, 1, 148, 73, 9, 3, 1, 171, 73, 9, 3, 1, 183, 73, 9, 3, 1, 78, - 73, 9, 3, 1, 198, 73, 9, 3, 1, 209, 73, 9, 3, 1, 135, 73, 9, 3, 1, 159, - 73, 9, 3, 1, 190, 73, 9, 3, 1, 84, 73, 9, 3, 1, 186, 73, 9, 3, 1, 201, - 73, 9, 3, 1, 170, 73, 9, 3, 1, 181, 73, 9, 3, 1, 202, 73, 36, 244, 175, - 110, 73, 55, 244, 176, 73, 37, 244, 175, 110, 73, 180, 73, 36, 58, 236, - 47, 73, 37, 58, 236, 47, 62, 66, 213, 189, 62, 36, 242, 86, 110, 62, 37, - 242, 86, 110, 62, 66, 242, 84, 62, 39, 242, 65, 227, 62, 39, 1, 253, 138, - 62, 39, 1, 3, 64, 62, 39, 1, 3, 69, 62, 39, 1, 3, 84, 62, 39, 1, 3, 70, - 62, 39, 1, 3, 78, 62, 39, 1, 3, 216, 62, 39, 1, 3, 253, 124, 62, 39, 1, - 3, 253, 123, 62, 39, 1, 3, 253, 160, 62, 232, 3, 238, 153, 244, 205, 65, - 62, 39, 1, 64, 62, 39, 1, 69, 62, 39, 1, 84, 62, 39, 1, 70, 62, 39, 1, - 78, 62, 39, 1, 208, 62, 39, 1, 253, 182, 62, 39, 1, 253, 183, 62, 39, 1, - 253, 134, 62, 39, 1, 253, 155, 62, 39, 1, 253, 97, 62, 39, 1, 253, 158, - 62, 39, 1, 253, 172, 62, 39, 1, 253, 171, 62, 39, 1, 253, 159, 62, 39, 1, - 253, 91, 62, 39, 1, 253, 174, 62, 39, 1, 253, 160, 62, 39, 1, 253, 151, - 62, 39, 1, 76, 62, 39, 1, 253, 94, 62, 39, 1, 253, 148, 62, 39, 1, 253, - 112, 62, 39, 1, 253, 157, 62, 39, 1, 253, 136, 62, 39, 1, 253, 88, 62, - 39, 1, 253, 154, 62, 39, 1, 253, 197, 62, 39, 1, 253, 125, 62, 39, 1, - 253, 140, 62, 39, 1, 221, 62, 39, 1, 253, 156, 62, 39, 1, 253, 114, 62, - 39, 1, 253, 167, 62, 39, 1, 253, 141, 62, 39, 1, 216, 62, 39, 1, 253, - 124, 62, 39, 1, 253, 123, 62, 39, 1, 253, 92, 62, 39, 1, 253, 169, 62, - 39, 1, 253, 170, 62, 39, 1, 253, 150, 62, 39, 1, 253, 144, 62, 39, 1, - 253, 98, 62, 39, 1, 183, 62, 39, 242, 116, 244, 205, 65, 62, 39, 236, - 205, 244, 205, 65, 62, 20, 240, 255, 62, 20, 1, 240, 242, 62, 20, 1, 236, - 59, 62, 20, 1, 236, 63, 62, 20, 1, 242, 131, 62, 20, 1, 236, 65, 62, 20, - 1, 236, 66, 62, 20, 1, 240, 244, 62, 20, 1, 236, 72, 62, 20, 1, 242, 134, - 62, 20, 1, 235, 247, 62, 20, 1, 236, 67, 62, 20, 1, 236, 68, 62, 20, 1, - 236, 204, 62, 20, 1, 235, 197, 62, 20, 1, 235, 196, 62, 20, 1, 236, 57, - 62, 20, 1, 242, 129, 62, 20, 1, 242, 133, 62, 20, 1, 236, 209, 62, 20, 1, - 236, 198, 62, 20, 1, 244, 230, 62, 20, 1, 237, 138, 62, 20, 1, 242, 126, - 62, 20, 1, 242, 122, 62, 20, 1, 236, 207, 62, 20, 1, 239, 155, 62, 20, 1, - 239, 158, 62, 20, 1, 239, 166, 62, 20, 1, 239, 161, 62, 20, 1, 242, 125, - 62, 20, 1, 64, 62, 20, 1, 253, 163, 62, 20, 1, 216, 62, 20, 1, 249, 181, - 62, 20, 1, 254, 10, 62, 20, 1, 70, 62, 20, 1, 249, 182, 62, 20, 1, 253, - 200, 62, 20, 1, 78, 62, 20, 1, 253, 98, 62, 20, 1, 249, 175, 62, 20, 1, - 253, 142, 62, 20, 1, 253, 123, 62, 20, 1, 84, 62, 20, 1, 249, 177, 62, - 20, 1, 253, 132, 62, 20, 1, 253, 145, 62, 20, 1, 253, 124, 62, 20, 1, - 254, 12, 62, 20, 1, 253, 139, 62, 20, 1, 69, 73, 249, 196, 57, 73, 245, - 163, 57, 73, 141, 57, 73, 166, 73, 242, 173, 143, 73, 254, 78, 57, 73, - 254, 76, 57, 62, 246, 131, 117, 238, 88, 62, 126, 52, 62, 210, 52, 62, - 63, 52, 62, 220, 52, 62, 86, 240, 207, 62, 58, 240, 200, 236, 202, 237, - 111, 241, 97, 236, 202, 237, 111, 237, 114, 236, 202, 237, 111, 237, 103, - 244, 18, 236, 228, 237, 150, 236, 228, 237, 150, 222, 21, 1, 64, 222, 21, - 1, 253, 191, 222, 21, 1, 253, 134, 222, 21, 1, 253, 152, 222, 21, 1, 70, - 222, 21, 1, 253, 214, 222, 21, 1, 253, 189, 222, 21, 1, 253, 125, 222, - 21, 1, 249, 63, 222, 21, 1, 69, 222, 21, 1, 208, 222, 21, 1, 253, 223, - 222, 21, 1, 253, 224, 222, 21, 1, 253, 166, 222, 21, 1, 249, 67, 222, 21, - 1, 78, 222, 21, 1, 253, 143, 222, 21, 1, 249, 70, 222, 21, 1, 253, 183, - 222, 21, 1, 253, 205, 222, 21, 1, 253, 225, 222, 21, 1, 253, 151, 222, - 21, 1, 84, 222, 21, 1, 250, 242, 222, 21, 1, 250, 43, 222, 21, 1, 249, - 255, 222, 21, 1, 253, 222, 222, 21, 1, 250, 246, 222, 21, 1, 249, 44, - 222, 21, 1, 253, 96, 222, 21, 1, 253, 104, 222, 21, 151, 121, 222, 21, - 151, 168, 222, 21, 151, 249, 18, 222, 21, 151, 242, 144, 242, 62, 1, 245, - 238, 242, 62, 1, 240, 3, 242, 62, 1, 246, 154, 242, 62, 1, 246, 79, 242, - 62, 1, 241, 94, 242, 62, 1, 239, 66, 242, 62, 1, 247, 0, 242, 62, 1, 246, - 170, 242, 62, 1, 242, 36, 242, 62, 1, 250, 241, 242, 62, 1, 243, 194, - 242, 62, 1, 243, 199, 242, 62, 1, 243, 211, 242, 62, 1, 241, 219, 242, - 62, 1, 251, 120, 242, 62, 1, 248, 162, 242, 62, 1, 239, 56, 242, 62, 1, - 241, 69, 242, 62, 1, 244, 51, 242, 62, 1, 244, 71, 242, 62, 1, 244, 113, - 242, 62, 1, 244, 147, 242, 62, 1, 243, 105, 242, 62, 1, 243, 173, 242, - 62, 1, 242, 225, 242, 62, 1, 244, 21, 242, 62, 1, 250, 29, 239, 150, 111, - 5, 1, 165, 69, 111, 5, 1, 165, 70, 111, 5, 1, 165, 64, 111, 5, 1, 165, - 253, 219, 111, 5, 1, 165, 78, 111, 5, 1, 165, 253, 119, 111, 5, 1, 207, - 69, 111, 5, 1, 207, 70, 111, 5, 1, 207, 64, 111, 5, 1, 207, 253, 219, - 111, 5, 1, 207, 78, 111, 5, 1, 207, 253, 119, 111, 5, 1, 254, 2, 111, 5, - 1, 254, 64, 111, 5, 1, 253, 216, 111, 5, 1, 249, 125, 111, 5, 1, 164, - 111, 5, 1, 249, 114, 111, 5, 1, 249, 128, 111, 5, 1, 249, 164, 111, 5, 1, - 249, 96, 111, 5, 1, 244, 246, 111, 5, 1, 249, 104, 111, 5, 1, 249, 253, - 111, 5, 1, 249, 228, 111, 5, 1, 253, 222, 111, 5, 1, 249, 174, 111, 5, 1, - 249, 77, 111, 5, 1, 245, 9, 111, 5, 1, 253, 225, 111, 5, 1, 249, 126, - 111, 5, 1, 249, 67, 111, 5, 1, 245, 53, 111, 5, 1, 253, 205, 111, 5, 1, - 253, 223, 111, 5, 1, 253, 224, 111, 5, 1, 253, 166, 111, 5, 1, 249, 66, - 111, 3, 1, 165, 69, 111, 3, 1, 165, 70, 111, 3, 1, 165, 64, 111, 3, 1, - 165, 253, 219, 111, 3, 1, 165, 78, 111, 3, 1, 165, 253, 119, 111, 3, 1, - 207, 69, 111, 3, 1, 207, 70, 111, 3, 1, 207, 64, 111, 3, 1, 207, 253, - 219, 111, 3, 1, 207, 78, 111, 3, 1, 207, 253, 119, 111, 3, 1, 254, 2, - 111, 3, 1, 254, 64, 111, 3, 1, 253, 216, 111, 3, 1, 249, 125, 111, 3, 1, - 164, 111, 3, 1, 249, 114, 111, 3, 1, 249, 128, 111, 3, 1, 249, 164, 111, - 3, 1, 249, 96, 111, 3, 1, 244, 246, 111, 3, 1, 249, 104, 111, 3, 1, 249, - 253, 111, 3, 1, 249, 228, 111, 3, 1, 253, 222, 111, 3, 1, 249, 174, 111, - 3, 1, 249, 77, 111, 3, 1, 245, 9, 111, 3, 1, 253, 225, 111, 3, 1, 249, - 126, 111, 3, 1, 249, 67, 111, 3, 1, 245, 53, 111, 3, 1, 253, 205, 111, 3, - 1, 253, 223, 111, 3, 1, 253, 224, 111, 3, 1, 253, 166, 111, 3, 1, 249, - 66, 34, 19, 13, 242, 78, 34, 19, 13, 241, 135, 34, 19, 13, 236, 43, 34, - 19, 13, 245, 34, 236, 55, 34, 19, 13, 245, 34, 242, 124, 34, 19, 13, 242, - 192, 236, 55, 34, 19, 13, 242, 192, 242, 124, 34, 19, 13, 239, 36, 34, - 19, 13, 238, 66, 34, 19, 13, 236, 151, 34, 19, 13, 238, 74, 34, 19, 13, - 239, 113, 242, 124, 34, 19, 13, 239, 40, 34, 19, 13, 245, 55, 236, 55, - 34, 19, 13, 254, 39, 236, 55, 34, 19, 13, 241, 83, 34, 19, 13, 238, 24, - 34, 19, 13, 236, 244, 34, 19, 13, 237, 146, 242, 124, 34, 19, 13, 240, - 174, 34, 19, 13, 244, 117, 34, 19, 13, 242, 235, 238, 80, 34, 19, 13, - 242, 145, 238, 80, 34, 19, 13, 241, 245, 34, 19, 13, 238, 188, 34, 19, - 13, 244, 138, 34, 19, 13, 249, 246, 238, 80, 34, 19, 13, 241, 1, 238, 80, - 34, 19, 13, 238, 112, 238, 80, 34, 19, 13, 239, 79, 34, 19, 13, 239, 59, - 34, 19, 13, 242, 20, 238, 171, 34, 19, 13, 244, 22, 238, 80, 34, 19, 13, - 242, 48, 238, 80, 34, 19, 13, 239, 201, 238, 80, 34, 19, 13, 238, 172, - 34, 19, 13, 241, 62, 34, 19, 13, 244, 58, 34, 19, 13, 242, 237, 238, 80, - 34, 19, 13, 240, 183, 34, 19, 13, 236, 5, 34, 19, 13, 242, 7, 34, 19, 13, - 241, 33, 238, 80, 34, 19, 13, 241, 33, 251, 225, 240, 170, 34, 19, 13, - 238, 149, 238, 80, 34, 19, 13, 244, 115, 34, 19, 13, 243, 202, 34, 19, - 13, 250, 237, 34, 19, 13, 248, 138, 34, 19, 13, 240, 179, 34, 19, 13, - 238, 26, 34, 19, 13, 245, 55, 254, 39, 249, 16, 34, 19, 13, 242, 71, 238, - 80, 34, 19, 13, 238, 17, 34, 19, 13, 239, 198, 238, 80, 34, 19, 13, 243, - 184, 239, 104, 34, 19, 13, 239, 61, 34, 19, 13, 238, 48, 34, 19, 13, 239, - 38, 34, 19, 13, 239, 208, 238, 80, 34, 19, 13, 240, 149, 34, 19, 13, 236, - 222, 238, 80, 34, 19, 13, 236, 223, 238, 80, 34, 19, 13, 240, 89, 34, 19, - 13, 245, 147, 34, 19, 13, 240, 136, 34, 19, 13, 240, 100, 245, 13, 34, - 19, 13, 239, 198, 245, 13, 34, 19, 13, 236, 37, 34, 19, 13, 236, 21, 34, - 19, 13, 249, 246, 249, 16, 34, 19, 13, 242, 235, 249, 16, 34, 19, 13, - 245, 34, 249, 16, 34, 19, 13, 240, 137, 34, 19, 13, 239, 39, 34, 19, 13, - 234, 56, 34, 19, 13, 234, 52, 34, 19, 13, 240, 135, 249, 16, 34, 19, 13, - 238, 112, 253, 185, 249, 60, 34, 19, 13, 241, 1, 253, 185, 249, 60, 34, - 19, 13, 242, 58, 34, 19, 13, 237, 146, 249, 16, 34, 19, 13, 237, 145, - 239, 100, 249, 16, 34, 19, 13, 240, 198, 34, 19, 13, 234, 53, 34, 19, 13, - 240, 66, 34, 19, 13, 240, 15, 34, 19, 13, 243, 228, 246, 254, 34, 19, 13, - 242, 192, 249, 16, 34, 19, 13, 242, 237, 249, 16, 34, 19, 13, 239, 65, - 249, 16, 34, 19, 13, 241, 227, 34, 19, 13, 236, 242, 34, 19, 13, 240, - 106, 34, 19, 13, 236, 223, 249, 16, 34, 19, 13, 236, 222, 249, 16, 34, - 19, 13, 242, 209, 236, 150, 34, 19, 13, 240, 103, 34, 19, 13, 232, 17, - 34, 19, 13, 239, 198, 249, 16, 34, 19, 13, 237, 58, 34, 19, 13, 241, 33, - 249, 16, 34, 19, 13, 244, 108, 34, 19, 13, 239, 208, 249, 16, 34, 19, 13, - 239, 8, 34, 19, 13, 244, 73, 249, 16, 34, 19, 13, 248, 181, 241, 62, 34, - 19, 13, 232, 13, 34, 19, 13, 234, 58, 34, 19, 13, 235, 187, 34, 19, 13, - 231, 247, 34, 19, 13, 231, 238, 34, 19, 13, 235, 188, 34, 19, 13, 234, - 59, 34, 19, 13, 234, 71, 34, 19, 13, 235, 198, 34, 19, 13, 242, 209, 235, - 198, 34, 19, 13, 238, 149, 249, 16, 34, 19, 13, 236, 237, 250, 247, 34, - 19, 13, 236, 237, 250, 250, 34, 19, 13, 248, 123, 241, 38, 34, 19, 13, - 252, 205, 254, 15, 239, 253, 34, 19, 13, 238, 23, 34, 19, 13, 238, 4, 34, - 19, 13, 250, 115, 244, 221, 34, 19, 13, 250, 115, 249, 60, 34, 19, 13, - 240, 169, 34, 19, 13, 242, 228, 249, 60, 34, 19, 13, 246, 108, 238, 80, - 34, 19, 13, 241, 24, 238, 80, 34, 19, 13, 241, 24, 245, 13, 34, 19, 13, - 241, 24, 249, 16, 34, 19, 13, 239, 201, 249, 16, 34, 19, 13, 245, 248, - 34, 19, 13, 242, 124, 34, 19, 13, 242, 38, 34, 19, 13, 239, 102, 34, 19, - 13, 239, 186, 34, 19, 13, 242, 146, 250, 244, 239, 209, 34, 19, 13, 242, - 146, 254, 7, 239, 178, 34, 19, 13, 242, 146, 248, 139, 239, 178, 34, 19, - 13, 242, 146, 240, 178, 239, 178, 34, 19, 13, 242, 146, 241, 184, 239, - 209, 34, 19, 13, 242, 145, 253, 185, 249, 60, 34, 19, 13, 242, 145, 235, - 242, 238, 176, 34, 19, 13, 242, 145, 235, 242, 242, 208, 34, 19, 13, 238, - 202, 34, 19, 13, 239, 180, 235, 242, 239, 202, 244, 221, 34, 19, 13, 239, - 180, 235, 242, 239, 202, 249, 60, 34, 19, 13, 239, 180, 235, 242, 242, - 208, 34, 19, 13, 238, 71, 34, 19, 13, 243, 32, 34, 19, 13, 237, 69, 34, - 19, 13, 240, 26, 34, 19, 13, 244, 213, 250, 46, 245, 56, 34, 19, 13, 244, - 213, 238, 175, 34, 19, 13, 244, 213, 245, 56, 34, 19, 13, 244, 213, 241, - 212, 34, 19, 13, 244, 213, 247, 78, 34, 19, 13, 244, 213, 242, 220, 34, - 19, 13, 244, 213, 238, 11, 34, 19, 13, 244, 213, 250, 46, 242, 220, 34, - 19, 13, 239, 128, 242, 240, 242, 89, 34, 19, 13, 239, 128, 249, 186, 242, - 240, 242, 89, 34, 19, 13, 239, 128, 239, 212, 242, 89, 34, 19, 13, 239, - 128, 249, 186, 239, 212, 242, 89, 34, 19, 13, 239, 128, 244, 124, 242, - 89, 34, 19, 13, 239, 128, 238, 70, 34, 19, 13, 239, 128, 239, 197, 242, - 89, 34, 19, 13, 239, 128, 239, 197, 241, 65, 242, 89, 34, 19, 13, 239, - 128, 241, 65, 242, 89, 34, 19, 13, 239, 128, 241, 75, 242, 89, 34, 19, - 13, 243, 174, 243, 9, 237, 159, 34, 19, 13, 237, 145, 243, 9, 237, 159, - 34, 19, 13, 238, 120, 236, 172, 34, 19, 13, 238, 120, 236, 217, 34, 19, - 13, 238, 120, 238, 137, 34, 19, 13, 239, 128, 248, 163, 242, 89, 34, 19, - 13, 239, 128, 238, 47, 242, 89, 34, 19, 13, 239, 128, 241, 75, 239, 197, - 242, 89, 34, 19, 13, 237, 158, 255, 28, 241, 38, 34, 19, 13, 237, 158, - 255, 28, 240, 29, 34, 19, 13, 241, 153, 254, 15, 242, 71, 250, 107, 34, - 19, 13, 239, 30, 34, 19, 13, 237, 70, 34, 19, 13, 242, 71, 240, 0, 240, - 24, 243, 172, 34, 19, 13, 242, 71, 238, 95, 253, 90, 34, 19, 13, 242, 71, - 238, 95, 245, 147, 34, 19, 13, 242, 71, 251, 254, 242, 89, 34, 19, 13, - 242, 71, 238, 95, 253, 165, 34, 19, 13, 242, 71, 241, 31, 240, 27, 253, - 165, 34, 19, 13, 242, 71, 238, 95, 253, 134, 34, 19, 13, 242, 71, 238, - 95, 253, 190, 34, 19, 13, 242, 71, 238, 95, 254, 252, 244, 221, 34, 19, - 13, 242, 71, 238, 95, 254, 252, 249, 60, 34, 19, 13, 242, 71, 241, 66, - 242, 154, 238, 137, 34, 19, 13, 242, 71, 241, 66, 242, 154, 236, 217, 34, - 19, 13, 243, 109, 241, 31, 242, 154, 244, 137, 34, 19, 13, 242, 71, 241, - 31, 242, 154, 242, 28, 34, 19, 13, 242, 71, 241, 220, 34, 19, 13, 245, - 17, 244, 166, 34, 19, 13, 245, 17, 241, 193, 34, 19, 13, 245, 17, 242, - 17, 34, 19, 13, 242, 71, 197, 242, 136, 235, 207, 34, 19, 13, 242, 71, - 238, 3, 237, 173, 34, 19, 13, 242, 136, 236, 81, 34, 19, 13, 242, 123, - 236, 81, 34, 19, 13, 242, 123, 235, 207, 34, 19, 13, 242, 123, 249, 92, - 254, 7, 238, 92, 34, 19, 13, 242, 123, 236, 218, 241, 85, 238, 92, 34, - 19, 13, 242, 123, 238, 138, 254, 247, 238, 92, 34, 19, 13, 242, 123, 237, - 170, 250, 36, 238, 92, 34, 19, 13, 242, 136, 249, 92, 254, 7, 238, 92, - 34, 19, 13, 242, 136, 236, 218, 241, 85, 238, 92, 34, 19, 13, 242, 136, - 238, 138, 254, 247, 238, 92, 34, 19, 13, 242, 136, 237, 170, 250, 36, - 238, 92, 34, 19, 13, 242, 216, 241, 140, 34, 19, 13, 242, 216, 242, 56, - 34, 19, 13, 239, 171, 249, 92, 243, 227, 34, 19, 13, 239, 171, 249, 92, - 241, 210, 34, 19, 13, 239, 171, 242, 124, 34, 19, 13, 239, 171, 239, 242, - 34, 19, 13, 239, 151, 239, 242, 34, 19, 13, 239, 151, 241, 35, 239, 214, - 34, 19, 13, 239, 151, 241, 35, 238, 162, 34, 19, 13, 239, 151, 241, 35, - 236, 236, 34, 19, 13, 239, 151, 241, 102, 34, 19, 13, 239, 151, 242, 172, - 239, 214, 34, 19, 13, 239, 151, 242, 172, 238, 162, 34, 19, 13, 239, 151, - 242, 172, 236, 236, 34, 19, 13, 240, 28, 254, 107, 34, 19, 13, 238, 201, - 253, 247, 34, 19, 13, 241, 32, 34, 19, 13, 240, 233, 253, 90, 34, 19, 13, - 240, 233, 250, 107, 34, 19, 13, 240, 233, 253, 100, 34, 19, 13, 240, 233, - 253, 165, 34, 19, 13, 240, 233, 253, 134, 34, 19, 13, 240, 233, 253, 190, - 34, 19, 13, 240, 233, 253, 148, 34, 19, 13, 238, 112, 253, 185, 245, 141, - 34, 19, 13, 241, 1, 253, 185, 245, 141, 34, 19, 13, 238, 112, 253, 185, - 244, 221, 34, 19, 13, 241, 1, 253, 185, 244, 221, 34, 19, 13, 242, 228, - 244, 221, 34, 19, 13, 242, 145, 253, 185, 244, 221, 19, 13, 242, 66, 239, - 154, 19, 13, 42, 239, 154, 19, 13, 29, 239, 154, 19, 13, 240, 219, 29, - 239, 154, 19, 13, 242, 105, 239, 154, 19, 13, 207, 239, 154, 19, 13, 36, - 242, 113, 57, 19, 13, 37, 242, 113, 57, 19, 13, 242, 113, 244, 215, 19, - 13, 253, 180, 242, 245, 19, 13, 255, 4, 246, 42, 19, 13, 242, 245, 19, - 13, 246, 72, 19, 13, 239, 193, 239, 15, 19, 13, 239, 193, 239, 16, 19, - 13, 239, 193, 239, 17, 19, 13, 240, 74, 19, 13, 241, 165, 45, 19, 13, - 243, 50, 65, 19, 13, 240, 11, 19, 13, 243, 48, 19, 13, 110, 19, 13, 240, - 130, 242, 135, 19, 13, 240, 188, 242, 135, 19, 13, 238, 68, 242, 135, 19, - 13, 239, 19, 242, 135, 19, 13, 239, 18, 242, 135, 19, 13, 240, 165, 242, - 135, 19, 13, 238, 62, 237, 156, 19, 13, 237, 64, 237, 156, 19, 13, 255, - 32, 244, 233, 19, 13, 255, 32, 249, 95, 242, 132, 244, 243, 19, 13, 255, - 32, 249, 95, 242, 132, 242, 152, 19, 13, 255, 36, 244, 233, 19, 13, 255, - 42, 244, 233, 19, 13, 255, 42, 249, 95, 242, 132, 244, 243, 19, 13, 255, - 42, 249, 95, 242, 132, 242, 152, 19, 13, 249, 217, 241, 125, 19, 13, 249, - 217, 241, 126, 19, 13, 42, 242, 248, 19, 13, 42, 245, 87, 19, 13, 249, - 134, 253, 131, 19, 13, 249, 134, 244, 185, 19, 13, 241, 28, 253, 131, 19, - 13, 241, 28, 244, 185, 19, 13, 245, 5, 253, 131, 19, 13, 245, 5, 244, - 185, 19, 13, 240, 224, 249, 5, 242, 248, 19, 13, 240, 224, 249, 5, 245, - 87, 19, 13, 243, 75, 245, 203, 19, 13, 254, 96, 245, 203, 19, 13, 242, - 132, 244, 243, 19, 13, 242, 132, 242, 152, 19, 13, 236, 78, 244, 243, 19, - 13, 236, 78, 242, 152, 19, 13, 247, 102, 244, 187, 19, 13, 245, 221, 244, - 187, 19, 13, 136, 244, 187, 19, 13, 240, 224, 244, 187, 19, 13, 242, 111, - 244, 187, 19, 13, 238, 127, 244, 187, 19, 13, 236, 2, 244, 187, 19, 13, - 236, 80, 244, 187, 19, 13, 253, 101, 241, 21, 236, 3, 244, 187, 19, 13, - 255, 43, 238, 102, 19, 13, 249, 4, 238, 102, 19, 13, 175, 255, 43, 238, - 102, 19, 13, 30, 239, 120, 242, 92, 19, 13, 30, 239, 120, 231, 231, 19, - 13, 239, 118, 239, 120, 75, 242, 92, 19, 13, 239, 118, 239, 120, 75, 231, - 231, 19, 13, 239, 118, 239, 120, 36, 242, 92, 19, 13, 239, 118, 239, 120, - 36, 231, 231, 19, 13, 239, 118, 239, 120, 37, 242, 92, 19, 13, 239, 118, - 239, 120, 37, 231, 231, 19, 13, 239, 118, 239, 120, 79, 242, 92, 19, 13, - 239, 118, 239, 120, 79, 231, 231, 19, 13, 239, 118, 239, 120, 75, 37, - 242, 92, 19, 13, 239, 118, 239, 120, 75, 37, 231, 231, 19, 13, 250, 20, - 239, 120, 242, 92, 19, 13, 250, 20, 239, 120, 231, 231, 19, 13, 235, 209, - 239, 120, 79, 242, 92, 19, 13, 235, 209, 239, 120, 79, 231, 231, 19, 13, - 236, 187, 238, 102, 19, 13, 253, 1, 238, 102, 19, 13, 239, 120, 231, 231, - 19, 13, 252, 41, 238, 102, 19, 13, 241, 49, 239, 120, 242, 92, 19, 13, - 241, 49, 239, 120, 231, 231, 19, 13, 212, 19, 13, 245, 221, 244, 208, 19, - 13, 136, 244, 208, 19, 13, 240, 224, 244, 208, 19, 13, 242, 111, 244, - 208, 19, 13, 238, 127, 244, 208, 19, 13, 236, 2, 244, 208, 19, 13, 236, - 80, 244, 208, 19, 13, 253, 101, 241, 21, 236, 3, 244, 208, 19, 13, 48, - 244, 239, 19, 13, 48, 236, 170, 244, 239, 19, 13, 48, 237, 167, 19, 13, - 48, 237, 168, 19, 13, 48, 237, 169, 19, 13, 239, 182, 237, 167, 19, 13, - 239, 182, 237, 168, 19, 13, 239, 182, 237, 169, 19, 13, 48, 236, 86, 227, - 19, 13, 48, 241, 167, 19, 13, 48, 241, 168, 19, 13, 48, 241, 169, 19, 13, - 48, 241, 170, 19, 13, 48, 241, 171, 19, 13, 244, 244, 245, 59, 19, 13, - 253, 127, 245, 59, 19, 13, 244, 244, 249, 89, 19, 13, 253, 127, 249, 89, - 19, 13, 244, 244, 245, 192, 19, 13, 253, 127, 245, 192, 19, 13, 244, 244, - 241, 73, 19, 13, 253, 127, 241, 73, 19, 13, 48, 240, 203, 19, 13, 48, - 239, 85, 19, 13, 48, 242, 32, 19, 13, 48, 235, 232, 19, 13, 48, 240, 111, - 19, 13, 48, 232, 7, 19, 13, 48, 232, 16, 19, 13, 48, 243, 206, 19, 13, - 237, 147, 253, 131, 19, 13, 237, 147, 244, 185, 19, 13, 48, 246, 112, 19, - 13, 48, 252, 126, 19, 13, 48, 246, 130, 19, 13, 48, 244, 89, 19, 13, 48, - 246, 22, 19, 13, 48, 42, 241, 36, 19, 13, 48, 242, 59, 241, 36, 19, 13, - 236, 160, 19, 13, 242, 25, 19, 13, 202, 19, 13, 244, 37, 19, 13, 243, - 222, 19, 13, 243, 117, 19, 13, 237, 184, 19, 13, 236, 94, 19, 13, 245, - 101, 250, 31, 242, 91, 19, 13, 245, 101, 250, 31, 254, 243, 242, 91, 19, - 13, 254, 194, 19, 13, 245, 214, 19, 13, 239, 116, 245, 214, 19, 13, 250, - 98, 242, 91, 19, 13, 250, 98, 253, 131, 19, 13, 239, 140, 239, 88, 19, - 13, 239, 140, 239, 89, 19, 13, 239, 140, 239, 90, 19, 13, 239, 140, 239, - 91, 19, 13, 239, 140, 239, 92, 19, 13, 239, 140, 239, 93, 19, 13, 239, - 140, 239, 94, 19, 13, 239, 140, 239, 95, 19, 13, 239, 140, 239, 96, 19, - 13, 239, 140, 238, 63, 19, 13, 239, 140, 238, 64, 19, 13, 236, 130, 19, - 13, 236, 147, 19, 13, 253, 127, 137, 242, 21, 19, 13, 242, 156, 242, 91, - 19, 13, 48, 79, 249, 129, 19, 13, 48, 75, 249, 129, 19, 13, 48, 239, 26, - 19, 13, 48, 252, 170, 238, 44, 19, 13, 245, 35, 65, 19, 13, 245, 35, 75, - 65, 19, 13, 136, 245, 35, 65, 19, 13, 238, 142, 253, 131, 19, 13, 238, - 142, 244, 185, 19, 13, 2, 236, 128, 19, 13, 246, 81, 19, 13, 250, 206, - 249, 185, 19, 13, 241, 208, 19, 13, 243, 205, 19, 13, 241, 118, 19, 13, - 237, 141, 242, 92, 19, 13, 237, 141, 231, 231, 19, 13, 241, 215, 19, 13, - 242, 232, 231, 231, 19, 13, 237, 142, 242, 92, 19, 13, 237, 142, 231, - 231, 19, 13, 249, 226, 242, 92, 19, 13, 249, 226, 231, 231, 19, 13, 245, - 134, 239, 229, 244, 187, 19, 13, 245, 134, 237, 135, 244, 187, 19, 13, - 243, 51, 244, 187, 19, 13, 237, 141, 244, 187, 19, 13, 242, 232, 244, - 187, 19, 13, 237, 142, 244, 187, 19, 13, 242, 115, 238, 125, 253, 179, - 237, 118, 238, 151, 19, 13, 242, 115, 238, 125, 253, 179, 237, 118, 236, - 215, 19, 13, 242, 115, 238, 125, 253, 179, 237, 118, 239, 229, 235, 249, - 19, 13, 242, 115, 236, 194, 253, 179, 237, 118, 238, 151, 19, 13, 242, - 115, 236, 194, 253, 179, 237, 118, 236, 215, 19, 13, 242, 115, 236, 194, - 253, 179, 237, 118, 237, 135, 235, 249, 19, 13, 242, 115, 236, 194, 253, - 179, 237, 118, 237, 135, 236, 9, 19, 13, 242, 115, 236, 194, 253, 179, - 237, 118, 237, 135, 236, 10, 19, 13, 243, 77, 19, 13, 238, 143, 255, 36, - 244, 233, 19, 13, 238, 143, 255, 42, 244, 233, 19, 13, 30, 199, 19, 13, - 244, 140, 19, 13, 240, 140, 19, 13, 241, 127, 19, 13, 238, 57, 19, 13, - 238, 191, 19, 13, 239, 103, 19, 13, 238, 46, 19, 13, 239, 63, 241, 55, - 19, 13, 239, 80, 241, 55, 19, 13, 240, 185, 238, 55, 19, 13, 254, 166, - 237, 100, 8, 16, 5, 64, 8, 16, 5, 199, 8, 16, 5, 203, 8, 16, 5, 187, 8, - 16, 5, 70, 8, 16, 5, 204, 8, 16, 5, 194, 8, 16, 5, 164, 8, 16, 5, 69, 8, - 16, 5, 200, 8, 16, 5, 205, 8, 16, 5, 148, 8, 16, 5, 171, 8, 16, 5, 183, - 8, 16, 5, 78, 8, 16, 5, 198, 8, 16, 5, 209, 8, 16, 5, 135, 8, 16, 5, 159, - 8, 16, 5, 190, 8, 16, 5, 84, 8, 16, 5, 186, 8, 16, 5, 201, 8, 16, 5, 170, - 8, 16, 5, 181, 8, 16, 5, 202, 8, 16, 3, 64, 8, 16, 3, 199, 8, 16, 3, 203, - 8, 16, 3, 187, 8, 16, 3, 70, 8, 16, 3, 204, 8, 16, 3, 194, 8, 16, 3, 164, - 8, 16, 3, 69, 8, 16, 3, 200, 8, 16, 3, 205, 8, 16, 3, 148, 8, 16, 3, 171, - 8, 16, 3, 183, 8, 16, 3, 78, 8, 16, 3, 198, 8, 16, 3, 209, 8, 16, 3, 135, - 8, 16, 3, 159, 8, 16, 3, 190, 8, 16, 3, 84, 8, 16, 3, 186, 8, 16, 3, 201, - 8, 16, 3, 170, 8, 16, 3, 181, 8, 16, 3, 202, 8, 21, 5, 64, 8, 21, 5, 199, - 8, 21, 5, 203, 8, 21, 5, 187, 8, 21, 5, 70, 8, 21, 5, 204, 8, 21, 5, 194, - 8, 21, 5, 164, 8, 21, 5, 69, 8, 21, 5, 200, 8, 21, 5, 205, 8, 21, 5, 148, - 8, 21, 5, 171, 8, 21, 5, 183, 8, 21, 5, 78, 8, 21, 5, 198, 8, 21, 5, 209, - 8, 21, 5, 135, 8, 21, 5, 159, 8, 21, 5, 190, 8, 21, 5, 84, 8, 21, 5, 186, - 8, 21, 5, 201, 8, 21, 5, 170, 8, 21, 5, 181, 8, 21, 5, 202, 8, 21, 3, 64, - 8, 21, 3, 199, 8, 21, 3, 203, 8, 21, 3, 187, 8, 21, 3, 70, 8, 21, 3, 204, - 8, 21, 3, 194, 8, 21, 3, 69, 8, 21, 3, 200, 8, 21, 3, 205, 8, 21, 3, 148, - 8, 21, 3, 171, 8, 21, 3, 183, 8, 21, 3, 78, 8, 21, 3, 198, 8, 21, 3, 209, - 8, 21, 3, 135, 8, 21, 3, 159, 8, 21, 3, 190, 8, 21, 3, 84, 8, 21, 3, 186, - 8, 21, 3, 201, 8, 21, 3, 170, 8, 21, 3, 181, 8, 21, 3, 202, 8, 16, 21, 5, - 64, 8, 16, 21, 5, 199, 8, 16, 21, 5, 203, 8, 16, 21, 5, 187, 8, 16, 21, - 5, 70, 8, 16, 21, 5, 204, 8, 16, 21, 5, 194, 8, 16, 21, 5, 164, 8, 16, - 21, 5, 69, 8, 16, 21, 5, 200, 8, 16, 21, 5, 205, 8, 16, 21, 5, 148, 8, - 16, 21, 5, 171, 8, 16, 21, 5, 183, 8, 16, 21, 5, 78, 8, 16, 21, 5, 198, - 8, 16, 21, 5, 209, 8, 16, 21, 5, 135, 8, 16, 21, 5, 159, 8, 16, 21, 5, - 190, 8, 16, 21, 5, 84, 8, 16, 21, 5, 186, 8, 16, 21, 5, 201, 8, 16, 21, - 5, 170, 8, 16, 21, 5, 181, 8, 16, 21, 5, 202, 8, 16, 21, 3, 64, 8, 16, - 21, 3, 199, 8, 16, 21, 3, 203, 8, 16, 21, 3, 187, 8, 16, 21, 3, 70, 8, - 16, 21, 3, 204, 8, 16, 21, 3, 194, 8, 16, 21, 3, 164, 8, 16, 21, 3, 69, - 8, 16, 21, 3, 200, 8, 16, 21, 3, 205, 8, 16, 21, 3, 148, 8, 16, 21, 3, - 171, 8, 16, 21, 3, 183, 8, 16, 21, 3, 78, 8, 16, 21, 3, 198, 8, 16, 21, - 3, 209, 8, 16, 21, 3, 135, 8, 16, 21, 3, 159, 8, 16, 21, 3, 190, 8, 16, - 21, 3, 84, 8, 16, 21, 3, 186, 8, 16, 21, 3, 201, 8, 16, 21, 3, 170, 8, - 16, 21, 3, 181, 8, 16, 21, 3, 202, 8, 71, 5, 64, 8, 71, 5, 203, 8, 71, 5, - 187, 8, 71, 5, 194, 8, 71, 5, 200, 8, 71, 5, 205, 8, 71, 5, 183, 8, 71, - 5, 78, 8, 71, 5, 198, 8, 71, 5, 209, 8, 71, 5, 159, 8, 71, 5, 190, 8, 71, - 5, 84, 8, 71, 5, 186, 8, 71, 5, 201, 8, 71, 5, 170, 8, 71, 5, 181, 8, 71, - 5, 202, 8, 71, 3, 64, 8, 71, 3, 199, 8, 71, 3, 203, 8, 71, 3, 187, 8, 71, - 3, 204, 8, 71, 3, 164, 8, 71, 3, 69, 8, 71, 3, 200, 8, 71, 3, 205, 8, 71, - 3, 171, 8, 71, 3, 183, 8, 71, 3, 198, 8, 71, 3, 209, 8, 71, 3, 135, 8, - 71, 3, 159, 8, 71, 3, 190, 8, 71, 3, 84, 8, 71, 3, 186, 8, 71, 3, 201, 8, - 71, 3, 170, 8, 71, 3, 181, 8, 71, 3, 202, 8, 16, 71, 5, 64, 8, 16, 71, 5, - 199, 8, 16, 71, 5, 203, 8, 16, 71, 5, 187, 8, 16, 71, 5, 70, 8, 16, 71, - 5, 204, 8, 16, 71, 5, 194, 8, 16, 71, 5, 164, 8, 16, 71, 5, 69, 8, 16, - 71, 5, 200, 8, 16, 71, 5, 205, 8, 16, 71, 5, 148, 8, 16, 71, 5, 171, 8, - 16, 71, 5, 183, 8, 16, 71, 5, 78, 8, 16, 71, 5, 198, 8, 16, 71, 5, 209, - 8, 16, 71, 5, 135, 8, 16, 71, 5, 159, 8, 16, 71, 5, 190, 8, 16, 71, 5, - 84, 8, 16, 71, 5, 186, 8, 16, 71, 5, 201, 8, 16, 71, 5, 170, 8, 16, 71, - 5, 181, 8, 16, 71, 5, 202, 8, 16, 71, 3, 64, 8, 16, 71, 3, 199, 8, 16, - 71, 3, 203, 8, 16, 71, 3, 187, 8, 16, 71, 3, 70, 8, 16, 71, 3, 204, 8, - 16, 71, 3, 194, 8, 16, 71, 3, 164, 8, 16, 71, 3, 69, 8, 16, 71, 3, 200, - 8, 16, 71, 3, 205, 8, 16, 71, 3, 148, 8, 16, 71, 3, 171, 8, 16, 71, 3, - 183, 8, 16, 71, 3, 78, 8, 16, 71, 3, 198, 8, 16, 71, 3, 209, 8, 16, 71, - 3, 135, 8, 16, 71, 3, 159, 8, 16, 71, 3, 190, 8, 16, 71, 3, 84, 8, 16, - 71, 3, 186, 8, 16, 71, 3, 201, 8, 16, 71, 3, 170, 8, 16, 71, 3, 181, 8, - 16, 71, 3, 202, 8, 77, 5, 64, 8, 77, 5, 199, 8, 77, 5, 187, 8, 77, 5, 70, - 8, 77, 5, 204, 8, 77, 5, 194, 8, 77, 5, 200, 8, 77, 5, 205, 8, 77, 5, - 148, 8, 77, 5, 171, 8, 77, 5, 183, 8, 77, 5, 78, 8, 77, 5, 198, 8, 77, 5, - 209, 8, 77, 5, 159, 8, 77, 5, 190, 8, 77, 5, 84, 8, 77, 5, 186, 8, 77, 5, - 201, 8, 77, 5, 170, 8, 77, 5, 181, 8, 77, 3, 64, 8, 77, 3, 199, 8, 77, 3, - 203, 8, 77, 3, 187, 8, 77, 3, 70, 8, 77, 3, 204, 8, 77, 3, 194, 8, 77, 3, - 164, 8, 77, 3, 69, 8, 77, 3, 200, 8, 77, 3, 205, 8, 77, 3, 148, 8, 77, 3, - 171, 8, 77, 3, 183, 8, 77, 3, 78, 8, 77, 3, 198, 8, 77, 3, 209, 8, 77, 3, - 135, 8, 77, 3, 159, 8, 77, 3, 190, 8, 77, 3, 84, 8, 77, 3, 186, 8, 77, 3, - 201, 8, 77, 3, 170, 8, 77, 3, 181, 8, 77, 3, 202, 8, 120, 5, 64, 8, 120, - 5, 199, 8, 120, 5, 187, 8, 120, 5, 70, 8, 120, 5, 204, 8, 120, 5, 194, 8, - 120, 5, 69, 8, 120, 5, 200, 8, 120, 5, 205, 8, 120, 5, 148, 8, 120, 5, - 171, 8, 120, 5, 78, 8, 120, 5, 159, 8, 120, 5, 190, 8, 120, 5, 84, 8, - 120, 5, 186, 8, 120, 5, 201, 8, 120, 5, 170, 8, 120, 5, 181, 8, 120, 3, - 64, 8, 120, 3, 199, 8, 120, 3, 203, 8, 120, 3, 187, 8, 120, 3, 70, 8, - 120, 3, 204, 8, 120, 3, 194, 8, 120, 3, 164, 8, 120, 3, 69, 8, 120, 3, - 200, 8, 120, 3, 205, 8, 120, 3, 148, 8, 120, 3, 171, 8, 120, 3, 183, 8, - 120, 3, 78, 8, 120, 3, 198, 8, 120, 3, 209, 8, 120, 3, 135, 8, 120, 3, - 159, 8, 120, 3, 190, 8, 120, 3, 84, 8, 120, 3, 186, 8, 120, 3, 201, 8, - 120, 3, 170, 8, 120, 3, 181, 8, 120, 3, 202, 8, 16, 77, 5, 64, 8, 16, 77, - 5, 199, 8, 16, 77, 5, 203, 8, 16, 77, 5, 187, 8, 16, 77, 5, 70, 8, 16, - 77, 5, 204, 8, 16, 77, 5, 194, 8, 16, 77, 5, 164, 8, 16, 77, 5, 69, 8, - 16, 77, 5, 200, 8, 16, 77, 5, 205, 8, 16, 77, 5, 148, 8, 16, 77, 5, 171, - 8, 16, 77, 5, 183, 8, 16, 77, 5, 78, 8, 16, 77, 5, 198, 8, 16, 77, 5, - 209, 8, 16, 77, 5, 135, 8, 16, 77, 5, 159, 8, 16, 77, 5, 190, 8, 16, 77, - 5, 84, 8, 16, 77, 5, 186, 8, 16, 77, 5, 201, 8, 16, 77, 5, 170, 8, 16, - 77, 5, 181, 8, 16, 77, 5, 202, 8, 16, 77, 3, 64, 8, 16, 77, 3, 199, 8, - 16, 77, 3, 203, 8, 16, 77, 3, 187, 8, 16, 77, 3, 70, 8, 16, 77, 3, 204, - 8, 16, 77, 3, 194, 8, 16, 77, 3, 164, 8, 16, 77, 3, 69, 8, 16, 77, 3, - 200, 8, 16, 77, 3, 205, 8, 16, 77, 3, 148, 8, 16, 77, 3, 171, 8, 16, 77, - 3, 183, 8, 16, 77, 3, 78, 8, 16, 77, 3, 198, 8, 16, 77, 3, 209, 8, 16, - 77, 3, 135, 8, 16, 77, 3, 159, 8, 16, 77, 3, 190, 8, 16, 77, 3, 84, 8, - 16, 77, 3, 186, 8, 16, 77, 3, 201, 8, 16, 77, 3, 170, 8, 16, 77, 3, 181, - 8, 16, 77, 3, 202, 8, 23, 5, 64, 8, 23, 5, 199, 8, 23, 5, 203, 8, 23, 5, - 187, 8, 23, 5, 70, 8, 23, 5, 204, 8, 23, 5, 194, 8, 23, 5, 164, 8, 23, 5, - 69, 8, 23, 5, 200, 8, 23, 5, 205, 8, 23, 5, 148, 8, 23, 5, 171, 8, 23, 5, - 183, 8, 23, 5, 78, 8, 23, 5, 198, 8, 23, 5, 209, 8, 23, 5, 135, 8, 23, 5, - 159, 8, 23, 5, 190, 8, 23, 5, 84, 8, 23, 5, 186, 8, 23, 5, 201, 8, 23, 5, - 170, 8, 23, 5, 181, 8, 23, 5, 202, 8, 23, 3, 64, 8, 23, 3, 199, 8, 23, 3, - 203, 8, 23, 3, 187, 8, 23, 3, 70, 8, 23, 3, 204, 8, 23, 3, 194, 8, 23, 3, - 164, 8, 23, 3, 69, 8, 23, 3, 200, 8, 23, 3, 205, 8, 23, 3, 148, 8, 23, 3, - 171, 8, 23, 3, 183, 8, 23, 3, 78, 8, 23, 3, 198, 8, 23, 3, 209, 8, 23, 3, - 135, 8, 23, 3, 159, 8, 23, 3, 190, 8, 23, 3, 84, 8, 23, 3, 186, 8, 23, 3, - 201, 8, 23, 3, 170, 8, 23, 3, 181, 8, 23, 3, 202, 8, 23, 16, 5, 64, 8, - 23, 16, 5, 199, 8, 23, 16, 5, 203, 8, 23, 16, 5, 187, 8, 23, 16, 5, 70, - 8, 23, 16, 5, 204, 8, 23, 16, 5, 194, 8, 23, 16, 5, 164, 8, 23, 16, 5, - 69, 8, 23, 16, 5, 200, 8, 23, 16, 5, 205, 8, 23, 16, 5, 148, 8, 23, 16, - 5, 171, 8, 23, 16, 5, 183, 8, 23, 16, 5, 78, 8, 23, 16, 5, 198, 8, 23, - 16, 5, 209, 8, 23, 16, 5, 135, 8, 23, 16, 5, 159, 8, 23, 16, 5, 190, 8, - 23, 16, 5, 84, 8, 23, 16, 5, 186, 8, 23, 16, 5, 201, 8, 23, 16, 5, 170, - 8, 23, 16, 5, 181, 8, 23, 16, 5, 202, 8, 23, 16, 3, 64, 8, 23, 16, 3, - 199, 8, 23, 16, 3, 203, 8, 23, 16, 3, 187, 8, 23, 16, 3, 70, 8, 23, 16, - 3, 204, 8, 23, 16, 3, 194, 8, 23, 16, 3, 164, 8, 23, 16, 3, 69, 8, 23, - 16, 3, 200, 8, 23, 16, 3, 205, 8, 23, 16, 3, 148, 8, 23, 16, 3, 171, 8, - 23, 16, 3, 183, 8, 23, 16, 3, 78, 8, 23, 16, 3, 198, 8, 23, 16, 3, 209, - 8, 23, 16, 3, 135, 8, 23, 16, 3, 159, 8, 23, 16, 3, 190, 8, 23, 16, 3, - 84, 8, 23, 16, 3, 186, 8, 23, 16, 3, 201, 8, 23, 16, 3, 170, 8, 23, 16, - 3, 181, 8, 23, 16, 3, 202, 8, 23, 21, 5, 64, 8, 23, 21, 5, 199, 8, 23, - 21, 5, 203, 8, 23, 21, 5, 187, 8, 23, 21, 5, 70, 8, 23, 21, 5, 204, 8, - 23, 21, 5, 194, 8, 23, 21, 5, 164, 8, 23, 21, 5, 69, 8, 23, 21, 5, 200, - 8, 23, 21, 5, 205, 8, 23, 21, 5, 148, 8, 23, 21, 5, 171, 8, 23, 21, 5, - 183, 8, 23, 21, 5, 78, 8, 23, 21, 5, 198, 8, 23, 21, 5, 209, 8, 23, 21, - 5, 135, 8, 23, 21, 5, 159, 8, 23, 21, 5, 190, 8, 23, 21, 5, 84, 8, 23, - 21, 5, 186, 8, 23, 21, 5, 201, 8, 23, 21, 5, 170, 8, 23, 21, 5, 181, 8, - 23, 21, 5, 202, 8, 23, 21, 3, 64, 8, 23, 21, 3, 199, 8, 23, 21, 3, 203, - 8, 23, 21, 3, 187, 8, 23, 21, 3, 70, 8, 23, 21, 3, 204, 8, 23, 21, 3, - 194, 8, 23, 21, 3, 164, 8, 23, 21, 3, 69, 8, 23, 21, 3, 200, 8, 23, 21, - 3, 205, 8, 23, 21, 3, 148, 8, 23, 21, 3, 171, 8, 23, 21, 3, 183, 8, 23, - 21, 3, 78, 8, 23, 21, 3, 198, 8, 23, 21, 3, 209, 8, 23, 21, 3, 135, 8, - 23, 21, 3, 159, 8, 23, 21, 3, 190, 8, 23, 21, 3, 84, 8, 23, 21, 3, 186, - 8, 23, 21, 3, 201, 8, 23, 21, 3, 170, 8, 23, 21, 3, 181, 8, 23, 21, 3, - 202, 8, 23, 16, 21, 5, 64, 8, 23, 16, 21, 5, 199, 8, 23, 16, 21, 5, 203, - 8, 23, 16, 21, 5, 187, 8, 23, 16, 21, 5, 70, 8, 23, 16, 21, 5, 204, 8, - 23, 16, 21, 5, 194, 8, 23, 16, 21, 5, 164, 8, 23, 16, 21, 5, 69, 8, 23, - 16, 21, 5, 200, 8, 23, 16, 21, 5, 205, 8, 23, 16, 21, 5, 148, 8, 23, 16, - 21, 5, 171, 8, 23, 16, 21, 5, 183, 8, 23, 16, 21, 5, 78, 8, 23, 16, 21, - 5, 198, 8, 23, 16, 21, 5, 209, 8, 23, 16, 21, 5, 135, 8, 23, 16, 21, 5, - 159, 8, 23, 16, 21, 5, 190, 8, 23, 16, 21, 5, 84, 8, 23, 16, 21, 5, 186, - 8, 23, 16, 21, 5, 201, 8, 23, 16, 21, 5, 170, 8, 23, 16, 21, 5, 181, 8, - 23, 16, 21, 5, 202, 8, 23, 16, 21, 3, 64, 8, 23, 16, 21, 3, 199, 8, 23, - 16, 21, 3, 203, 8, 23, 16, 21, 3, 187, 8, 23, 16, 21, 3, 70, 8, 23, 16, - 21, 3, 204, 8, 23, 16, 21, 3, 194, 8, 23, 16, 21, 3, 164, 8, 23, 16, 21, - 3, 69, 8, 23, 16, 21, 3, 200, 8, 23, 16, 21, 3, 205, 8, 23, 16, 21, 3, - 148, 8, 23, 16, 21, 3, 171, 8, 23, 16, 21, 3, 183, 8, 23, 16, 21, 3, 78, - 8, 23, 16, 21, 3, 198, 8, 23, 16, 21, 3, 209, 8, 23, 16, 21, 3, 135, 8, - 23, 16, 21, 3, 159, 8, 23, 16, 21, 3, 190, 8, 23, 16, 21, 3, 84, 8, 23, - 16, 21, 3, 186, 8, 23, 16, 21, 3, 201, 8, 23, 16, 21, 3, 170, 8, 23, 16, - 21, 3, 181, 8, 23, 16, 21, 3, 202, 8, 140, 5, 64, 8, 140, 5, 199, 8, 140, - 5, 203, 8, 140, 5, 187, 8, 140, 5, 70, 8, 140, 5, 204, 8, 140, 5, 194, 8, - 140, 5, 164, 8, 140, 5, 69, 8, 140, 5, 200, 8, 140, 5, 205, 8, 140, 5, - 148, 8, 140, 5, 171, 8, 140, 5, 183, 8, 140, 5, 78, 8, 140, 5, 198, 8, - 140, 5, 209, 8, 140, 5, 135, 8, 140, 5, 159, 8, 140, 5, 190, 8, 140, 5, - 84, 8, 140, 5, 186, 8, 140, 5, 201, 8, 140, 5, 170, 8, 140, 5, 181, 8, - 140, 5, 202, 8, 140, 3, 64, 8, 140, 3, 199, 8, 140, 3, 203, 8, 140, 3, - 187, 8, 140, 3, 70, 8, 140, 3, 204, 8, 140, 3, 194, 8, 140, 3, 164, 8, - 140, 3, 69, 8, 140, 3, 200, 8, 140, 3, 205, 8, 140, 3, 148, 8, 140, 3, - 171, 8, 140, 3, 183, 8, 140, 3, 78, 8, 140, 3, 198, 8, 140, 3, 209, 8, - 140, 3, 135, 8, 140, 3, 159, 8, 140, 3, 190, 8, 140, 3, 84, 8, 140, 3, - 186, 8, 140, 3, 201, 8, 140, 3, 170, 8, 140, 3, 181, 8, 140, 3, 202, 8, - 16, 5, 242, 79, 8, 16, 5, 244, 198, 8, 16, 5, 242, 75, 8, 16, 5, 242, 87, - 8, 16, 5, 239, 133, 8, 16, 5, 244, 204, 8, 16, 5, 249, 42, 8, 16, 5, 242, - 97, 8, 16, 5, 244, 191, 8, 16, 5, 242, 95, 8, 16, 5, 242, 96, 8, 16, 5, - 253, 114, 8, 16, 5, 253, 112, 8, 16, 5, 253, 135, 8, 16, 5, 239, 137, 8, - 16, 5, 253, 116, 8, 16, 5, 249, 32, 8, 16, 5, 244, 203, 90, 8, 16, 5, - 242, 73, 8, 16, 5, 249, 43, 8, 16, 5, 239, 127, 8, 16, 5, 249, 30, 8, 16, - 5, 249, 23, 8, 16, 5, 249, 31, 8, 16, 5, 242, 72, 8, 16, 242, 130, 8, 16, - 3, 242, 79, 8, 16, 3, 244, 198, 8, 16, 3, 242, 75, 8, 16, 3, 242, 87, 8, - 16, 3, 239, 133, 8, 16, 3, 244, 204, 8, 16, 3, 249, 42, 8, 16, 3, 242, - 97, 8, 16, 3, 244, 191, 8, 16, 3, 242, 95, 8, 16, 3, 242, 96, 8, 16, 3, - 253, 114, 8, 16, 3, 253, 112, 8, 16, 3, 253, 135, 8, 16, 3, 239, 137, 8, - 16, 3, 253, 116, 8, 16, 3, 249, 32, 8, 16, 3, 29, 242, 73, 8, 16, 3, 242, - 73, 8, 16, 3, 249, 43, 8, 16, 3, 239, 127, 8, 16, 3, 249, 30, 8, 16, 3, - 249, 23, 8, 16, 3, 249, 31, 8, 16, 3, 242, 72, 8, 16, 240, 243, 235, 240, - 8, 16, 240, 204, 90, 8, 16, 244, 203, 90, 8, 16, 244, 228, 90, 8, 16, - 253, 212, 90, 8, 16, 253, 168, 90, 8, 16, 254, 224, 90, 8, 21, 5, 242, - 79, 8, 21, 5, 244, 198, 8, 21, 5, 242, 75, 8, 21, 5, 242, 87, 8, 21, 5, - 239, 133, 8, 21, 5, 244, 204, 8, 21, 5, 249, 42, 8, 21, 5, 242, 97, 8, - 21, 5, 244, 191, 8, 21, 5, 242, 95, 8, 21, 5, 242, 96, 8, 21, 5, 253, - 114, 8, 21, 5, 253, 112, 8, 21, 5, 253, 135, 8, 21, 5, 239, 137, 8, 21, - 5, 253, 116, 8, 21, 5, 249, 32, 8, 21, 5, 244, 203, 90, 8, 21, 5, 242, - 73, 8, 21, 5, 249, 43, 8, 21, 5, 239, 127, 8, 21, 5, 249, 30, 8, 21, 5, - 249, 23, 8, 21, 5, 249, 31, 8, 21, 5, 242, 72, 8, 21, 242, 130, 8, 21, 3, - 242, 79, 8, 21, 3, 244, 198, 8, 21, 3, 242, 75, 8, 21, 3, 242, 87, 8, 21, - 3, 239, 133, 8, 21, 3, 244, 204, 8, 21, 3, 249, 42, 8, 21, 3, 242, 97, 8, - 21, 3, 244, 191, 8, 21, 3, 242, 95, 8, 21, 3, 242, 96, 8, 21, 3, 253, - 114, 8, 21, 3, 253, 112, 8, 21, 3, 253, 135, 8, 21, 3, 239, 137, 8, 21, - 3, 253, 116, 8, 21, 3, 249, 32, 8, 21, 3, 29, 242, 73, 8, 21, 3, 242, 73, - 8, 21, 3, 249, 43, 8, 21, 3, 239, 127, 8, 21, 3, 249, 30, 8, 21, 3, 249, - 23, 8, 21, 3, 249, 31, 8, 21, 3, 242, 72, 8, 21, 240, 243, 235, 240, 8, - 21, 240, 204, 90, 8, 21, 244, 203, 90, 8, 21, 244, 228, 90, 8, 21, 253, - 212, 90, 8, 21, 253, 168, 90, 8, 21, 254, 224, 90, 8, 16, 21, 5, 242, 79, - 8, 16, 21, 5, 244, 198, 8, 16, 21, 5, 242, 75, 8, 16, 21, 5, 242, 87, 8, - 16, 21, 5, 239, 133, 8, 16, 21, 5, 244, 204, 8, 16, 21, 5, 249, 42, 8, - 16, 21, 5, 242, 97, 8, 16, 21, 5, 244, 191, 8, 16, 21, 5, 242, 95, 8, 16, - 21, 5, 242, 96, 8, 16, 21, 5, 253, 114, 8, 16, 21, 5, 253, 112, 8, 16, - 21, 5, 253, 135, 8, 16, 21, 5, 239, 137, 8, 16, 21, 5, 253, 116, 8, 16, - 21, 5, 249, 32, 8, 16, 21, 5, 244, 203, 90, 8, 16, 21, 5, 242, 73, 8, 16, - 21, 5, 249, 43, 8, 16, 21, 5, 239, 127, 8, 16, 21, 5, 249, 30, 8, 16, 21, - 5, 249, 23, 8, 16, 21, 5, 249, 31, 8, 16, 21, 5, 242, 72, 8, 16, 21, 242, - 130, 8, 16, 21, 3, 242, 79, 8, 16, 21, 3, 244, 198, 8, 16, 21, 3, 242, - 75, 8, 16, 21, 3, 242, 87, 8, 16, 21, 3, 239, 133, 8, 16, 21, 3, 244, - 204, 8, 16, 21, 3, 249, 42, 8, 16, 21, 3, 242, 97, 8, 16, 21, 3, 244, - 191, 8, 16, 21, 3, 242, 95, 8, 16, 21, 3, 242, 96, 8, 16, 21, 3, 253, - 114, 8, 16, 21, 3, 253, 112, 8, 16, 21, 3, 253, 135, 8, 16, 21, 3, 239, - 137, 8, 16, 21, 3, 253, 116, 8, 16, 21, 3, 249, 32, 8, 16, 21, 3, 29, - 242, 73, 8, 16, 21, 3, 242, 73, 8, 16, 21, 3, 249, 43, 8, 16, 21, 3, 239, - 127, 8, 16, 21, 3, 249, 30, 8, 16, 21, 3, 249, 23, 8, 16, 21, 3, 249, 31, - 8, 16, 21, 3, 242, 72, 8, 16, 21, 240, 243, 235, 240, 8, 16, 21, 240, - 204, 90, 8, 16, 21, 244, 203, 90, 8, 16, 21, 244, 228, 90, 8, 16, 21, - 253, 212, 90, 8, 16, 21, 253, 168, 90, 8, 16, 21, 254, 224, 90, 8, 23, - 16, 5, 242, 79, 8, 23, 16, 5, 244, 198, 8, 23, 16, 5, 242, 75, 8, 23, 16, - 5, 242, 87, 8, 23, 16, 5, 239, 133, 8, 23, 16, 5, 244, 204, 8, 23, 16, 5, - 249, 42, 8, 23, 16, 5, 242, 97, 8, 23, 16, 5, 244, 191, 8, 23, 16, 5, - 242, 95, 8, 23, 16, 5, 242, 96, 8, 23, 16, 5, 253, 114, 8, 23, 16, 5, - 253, 112, 8, 23, 16, 5, 253, 135, 8, 23, 16, 5, 239, 137, 8, 23, 16, 5, - 253, 116, 8, 23, 16, 5, 249, 32, 8, 23, 16, 5, 244, 203, 90, 8, 23, 16, - 5, 242, 73, 8, 23, 16, 5, 249, 43, 8, 23, 16, 5, 239, 127, 8, 23, 16, 5, - 249, 30, 8, 23, 16, 5, 249, 23, 8, 23, 16, 5, 249, 31, 8, 23, 16, 5, 242, - 72, 8, 23, 16, 242, 130, 8, 23, 16, 3, 242, 79, 8, 23, 16, 3, 244, 198, - 8, 23, 16, 3, 242, 75, 8, 23, 16, 3, 242, 87, 8, 23, 16, 3, 239, 133, 8, - 23, 16, 3, 244, 204, 8, 23, 16, 3, 249, 42, 8, 23, 16, 3, 242, 97, 8, 23, - 16, 3, 244, 191, 8, 23, 16, 3, 242, 95, 8, 23, 16, 3, 242, 96, 8, 23, 16, - 3, 253, 114, 8, 23, 16, 3, 253, 112, 8, 23, 16, 3, 253, 135, 8, 23, 16, - 3, 239, 137, 8, 23, 16, 3, 253, 116, 8, 23, 16, 3, 249, 32, 8, 23, 16, 3, - 29, 242, 73, 8, 23, 16, 3, 242, 73, 8, 23, 16, 3, 249, 43, 8, 23, 16, 3, - 239, 127, 8, 23, 16, 3, 249, 30, 8, 23, 16, 3, 249, 23, 8, 23, 16, 3, - 249, 31, 8, 23, 16, 3, 242, 72, 8, 23, 16, 240, 243, 235, 240, 8, 23, 16, - 240, 204, 90, 8, 23, 16, 244, 203, 90, 8, 23, 16, 244, 228, 90, 8, 23, - 16, 253, 212, 90, 8, 23, 16, 253, 168, 90, 8, 23, 16, 254, 224, 90, 8, - 23, 16, 21, 5, 242, 79, 8, 23, 16, 21, 5, 244, 198, 8, 23, 16, 21, 5, - 242, 75, 8, 23, 16, 21, 5, 242, 87, 8, 23, 16, 21, 5, 239, 133, 8, 23, - 16, 21, 5, 244, 204, 8, 23, 16, 21, 5, 249, 42, 8, 23, 16, 21, 5, 242, - 97, 8, 23, 16, 21, 5, 244, 191, 8, 23, 16, 21, 5, 242, 95, 8, 23, 16, 21, - 5, 242, 96, 8, 23, 16, 21, 5, 253, 114, 8, 23, 16, 21, 5, 253, 112, 8, - 23, 16, 21, 5, 253, 135, 8, 23, 16, 21, 5, 239, 137, 8, 23, 16, 21, 5, - 253, 116, 8, 23, 16, 21, 5, 249, 32, 8, 23, 16, 21, 5, 244, 203, 90, 8, - 23, 16, 21, 5, 242, 73, 8, 23, 16, 21, 5, 249, 43, 8, 23, 16, 21, 5, 239, - 127, 8, 23, 16, 21, 5, 249, 30, 8, 23, 16, 21, 5, 249, 23, 8, 23, 16, 21, - 5, 249, 31, 8, 23, 16, 21, 5, 242, 72, 8, 23, 16, 21, 242, 130, 8, 23, - 16, 21, 3, 242, 79, 8, 23, 16, 21, 3, 244, 198, 8, 23, 16, 21, 3, 242, - 75, 8, 23, 16, 21, 3, 242, 87, 8, 23, 16, 21, 3, 239, 133, 8, 23, 16, 21, - 3, 244, 204, 8, 23, 16, 21, 3, 249, 42, 8, 23, 16, 21, 3, 242, 97, 8, 23, - 16, 21, 3, 244, 191, 8, 23, 16, 21, 3, 242, 95, 8, 23, 16, 21, 3, 242, - 96, 8, 23, 16, 21, 3, 253, 114, 8, 23, 16, 21, 3, 253, 112, 8, 23, 16, - 21, 3, 253, 135, 8, 23, 16, 21, 3, 239, 137, 8, 23, 16, 21, 3, 253, 116, - 8, 23, 16, 21, 3, 249, 32, 8, 23, 16, 21, 3, 29, 242, 73, 8, 23, 16, 21, - 3, 242, 73, 8, 23, 16, 21, 3, 249, 43, 8, 23, 16, 21, 3, 239, 127, 8, 23, - 16, 21, 3, 249, 30, 8, 23, 16, 21, 3, 249, 23, 8, 23, 16, 21, 3, 249, 31, - 8, 23, 16, 21, 3, 242, 72, 8, 23, 16, 21, 240, 243, 235, 240, 8, 23, 16, - 21, 240, 204, 90, 8, 23, 16, 21, 244, 203, 90, 8, 23, 16, 21, 244, 228, - 90, 8, 23, 16, 21, 253, 212, 90, 8, 23, 16, 21, 253, 168, 90, 8, 23, 16, - 21, 254, 224, 90, 8, 16, 27, 244, 173, 8, 16, 27, 121, 8, 16, 27, 114, 8, - 16, 27, 153, 8, 16, 27, 163, 8, 16, 27, 168, 8, 16, 27, 169, 8, 16, 27, - 179, 8, 16, 27, 176, 8, 16, 27, 178, 8, 120, 27, 244, 173, 8, 120, 27, - 121, 8, 120, 27, 114, 8, 120, 27, 153, 8, 120, 27, 163, 8, 120, 27, 168, - 8, 120, 27, 169, 8, 120, 27, 179, 8, 120, 27, 176, 8, 120, 27, 178, 8, - 23, 27, 244, 173, 8, 23, 27, 121, 8, 23, 27, 114, 8, 23, 27, 153, 8, 23, - 27, 163, 8, 23, 27, 168, 8, 23, 27, 169, 8, 23, 27, 179, 8, 23, 27, 176, - 8, 23, 27, 178, 8, 23, 16, 27, 244, 173, 8, 23, 16, 27, 121, 8, 23, 16, - 27, 114, 8, 23, 16, 27, 153, 8, 23, 16, 27, 163, 8, 23, 16, 27, 168, 8, - 23, 16, 27, 169, 8, 23, 16, 27, 179, 8, 23, 16, 27, 176, 8, 23, 16, 27, - 178, 8, 140, 27, 244, 173, 8, 140, 27, 121, 8, 140, 27, 114, 8, 140, 27, - 153, 8, 140, 27, 163, 8, 140, 27, 168, 8, 140, 27, 169, 8, 140, 27, 179, - 8, 140, 27, 176, 8, 140, 27, 178, 7, 11, 232, 21, 7, 11, 232, 22, 7, 11, - 232, 23, 7, 11, 232, 24, 7, 11, 232, 25, 7, 11, 232, 26, 7, 11, 232, 27, - 7, 11, 232, 28, 7, 11, 232, 29, 7, 11, 232, 30, 7, 11, 232, 31, 7, 11, - 232, 32, 7, 11, 232, 33, 7, 11, 232, 34, 7, 11, 232, 35, 7, 11, 232, 36, - 7, 11, 232, 37, 7, 11, 232, 38, 7, 11, 232, 39, 7, 11, 232, 40, 7, 11, - 232, 41, 7, 11, 232, 42, 7, 11, 232, 43, 7, 11, 232, 44, 7, 11, 232, 45, - 7, 11, 232, 46, 7, 11, 232, 47, 7, 11, 232, 48, 7, 11, 232, 49, 7, 11, - 232, 50, 7, 11, 232, 51, 7, 11, 232, 52, 7, 11, 232, 53, 7, 11, 232, 54, - 7, 11, 232, 55, 7, 11, 232, 56, 7, 11, 232, 57, 7, 11, 232, 58, 7, 11, - 232, 59, 7, 11, 232, 60, 7, 11, 232, 61, 7, 11, 232, 62, 7, 11, 232, 63, - 7, 11, 232, 64, 7, 11, 232, 65, 7, 11, 232, 66, 7, 11, 232, 67, 7, 11, - 232, 68, 7, 11, 232, 69, 7, 11, 232, 70, 7, 11, 232, 71, 7, 11, 232, 72, - 7, 11, 232, 73, 7, 11, 232, 74, 7, 11, 232, 75, 7, 11, 232, 76, 7, 11, - 232, 77, 7, 11, 232, 78, 7, 11, 232, 79, 7, 11, 232, 80, 7, 11, 232, 81, - 7, 11, 232, 82, 7, 11, 232, 83, 7, 11, 232, 84, 7, 11, 232, 85, 7, 11, - 232, 86, 7, 11, 232, 87, 7, 11, 232, 88, 7, 11, 232, 89, 7, 11, 232, 90, - 7, 11, 232, 91, 7, 11, 232, 92, 7, 11, 232, 93, 7, 11, 232, 94, 7, 11, - 232, 95, 7, 11, 232, 96, 7, 11, 232, 97, 7, 11, 232, 98, 7, 11, 232, 99, - 7, 11, 232, 100, 7, 11, 232, 101, 7, 11, 232, 102, 7, 11, 232, 103, 7, - 11, 232, 104, 7, 11, 232, 105, 7, 11, 232, 106, 7, 11, 232, 107, 7, 11, - 232, 108, 7, 11, 232, 109, 7, 11, 232, 110, 7, 11, 232, 111, 7, 11, 232, - 112, 7, 11, 232, 113, 7, 11, 232, 114, 7, 11, 232, 115, 7, 11, 232, 116, - 7, 11, 232, 117, 7, 11, 232, 118, 7, 11, 232, 119, 7, 11, 232, 120, 7, - 11, 232, 121, 7, 11, 232, 122, 7, 11, 232, 123, 7, 11, 232, 124, 7, 11, - 232, 125, 7, 11, 232, 126, 7, 11, 232, 127, 7, 11, 232, 128, 7, 11, 232, - 129, 7, 11, 232, 130, 7, 11, 232, 131, 7, 11, 232, 132, 7, 11, 232, 133, - 7, 11, 232, 134, 7, 11, 232, 135, 7, 11, 232, 136, 7, 11, 232, 137, 7, - 11, 232, 138, 7, 11, 232, 139, 7, 11, 232, 140, 7, 11, 232, 141, 7, 11, - 232, 142, 7, 11, 232, 143, 7, 11, 232, 144, 7, 11, 232, 145, 7, 11, 232, - 146, 7, 11, 232, 147, 7, 11, 232, 148, 7, 11, 232, 149, 7, 11, 232, 150, - 7, 11, 232, 151, 7, 11, 232, 152, 7, 11, 232, 153, 7, 11, 232, 154, 7, - 11, 232, 155, 7, 11, 232, 156, 7, 11, 232, 157, 7, 11, 232, 158, 7, 11, - 232, 159, 7, 11, 232, 160, 7, 11, 232, 161, 7, 11, 232, 162, 7, 11, 232, - 163, 7, 11, 232, 164, 7, 11, 232, 165, 7, 11, 232, 166, 7, 11, 232, 167, - 7, 11, 232, 168, 7, 11, 232, 169, 7, 11, 232, 170, 7, 11, 232, 171, 7, - 11, 232, 172, 7, 11, 232, 173, 7, 11, 232, 174, 7, 11, 232, 175, 7, 11, - 232, 176, 7, 11, 232, 177, 7, 11, 232, 178, 7, 11, 232, 179, 7, 11, 232, - 180, 7, 11, 232, 181, 7, 11, 232, 182, 7, 11, 232, 183, 7, 11, 232, 184, - 7, 11, 232, 185, 7, 11, 232, 186, 7, 11, 232, 187, 7, 11, 232, 188, 7, - 11, 232, 189, 7, 11, 232, 190, 7, 11, 232, 191, 7, 11, 232, 192, 7, 11, - 232, 193, 7, 11, 232, 194, 7, 11, 232, 195, 7, 11, 232, 196, 7, 11, 232, - 197, 7, 11, 232, 198, 7, 11, 232, 199, 7, 11, 232, 200, 7, 11, 232, 201, - 7, 11, 232, 202, 7, 11, 232, 203, 7, 11, 232, 204, 7, 11, 232, 205, 7, - 11, 232, 206, 7, 11, 232, 207, 7, 11, 232, 208, 7, 11, 232, 209, 7, 11, - 232, 210, 7, 11, 232, 211, 7, 11, 232, 212, 7, 11, 232, 213, 7, 11, 232, - 214, 7, 11, 232, 215, 7, 11, 232, 216, 7, 11, 232, 217, 7, 11, 232, 218, - 7, 11, 232, 219, 7, 11, 232, 220, 7, 11, 232, 221, 7, 11, 232, 222, 7, - 11, 232, 223, 7, 11, 232, 224, 7, 11, 232, 225, 7, 11, 232, 226, 7, 11, - 232, 227, 7, 11, 232, 228, 7, 11, 232, 229, 7, 11, 232, 230, 7, 11, 232, - 231, 7, 11, 232, 232, 7, 11, 232, 233, 7, 11, 232, 234, 7, 11, 232, 235, - 7, 11, 232, 236, 7, 11, 232, 237, 7, 11, 232, 238, 7, 11, 232, 239, 7, - 11, 232, 240, 7, 11, 232, 241, 7, 11, 232, 242, 7, 11, 232, 243, 7, 11, - 232, 244, 7, 11, 232, 245, 7, 11, 232, 246, 7, 11, 232, 247, 7, 11, 232, - 248, 7, 11, 232, 249, 7, 11, 232, 250, 7, 11, 232, 251, 7, 11, 232, 252, - 7, 11, 232, 253, 7, 11, 232, 254, 7, 11, 232, 255, 7, 11, 233, 0, 7, 11, - 233, 1, 7, 11, 233, 2, 7, 11, 233, 3, 7, 11, 233, 4, 7, 11, 233, 5, 7, - 11, 233, 6, 7, 11, 233, 7, 7, 11, 233, 8, 7, 11, 233, 9, 7, 11, 233, 10, - 7, 11, 233, 11, 7, 11, 233, 12, 7, 11, 233, 13, 7, 11, 233, 14, 7, 11, - 233, 15, 7, 11, 233, 16, 7, 11, 233, 17, 7, 11, 233, 18, 7, 11, 233, 19, - 7, 11, 233, 20, 7, 11, 233, 21, 7, 11, 233, 22, 7, 11, 233, 23, 7, 11, - 233, 24, 7, 11, 233, 25, 7, 11, 233, 26, 7, 11, 233, 27, 7, 11, 233, 28, - 7, 11, 233, 29, 7, 11, 233, 30, 7, 11, 233, 31, 7, 11, 233, 32, 7, 11, - 233, 33, 7, 11, 233, 34, 7, 11, 233, 35, 7, 11, 233, 36, 7, 11, 233, 37, - 7, 11, 233, 38, 7, 11, 233, 39, 7, 11, 233, 40, 7, 11, 233, 41, 7, 11, - 233, 42, 7, 11, 233, 43, 7, 11, 233, 44, 7, 11, 233, 45, 7, 11, 233, 46, - 7, 11, 233, 47, 7, 11, 233, 48, 7, 11, 233, 49, 7, 11, 233, 50, 7, 11, - 233, 51, 7, 11, 233, 52, 7, 11, 233, 53, 7, 11, 233, 54, 7, 11, 233, 55, - 7, 11, 233, 56, 7, 11, 233, 57, 7, 11, 233, 58, 7, 11, 233, 59, 7, 11, - 233, 60, 7, 11, 233, 61, 7, 11, 233, 62, 7, 11, 233, 63, 7, 11, 233, 64, - 7, 11, 233, 65, 7, 11, 233, 66, 7, 11, 233, 67, 7, 11, 233, 68, 7, 11, - 233, 69, 7, 11, 233, 70, 7, 11, 233, 71, 7, 11, 233, 72, 7, 11, 233, 73, - 7, 11, 233, 74, 7, 11, 233, 75, 7, 11, 233, 76, 7, 11, 233, 77, 7, 11, - 233, 78, 7, 11, 233, 79, 7, 11, 233, 80, 7, 11, 233, 81, 7, 11, 233, 82, - 7, 11, 233, 83, 7, 11, 233, 84, 7, 11, 233, 85, 7, 11, 233, 86, 7, 11, - 233, 87, 7, 11, 233, 88, 7, 11, 233, 89, 7, 11, 233, 90, 7, 11, 233, 91, - 7, 11, 233, 92, 7, 11, 233, 93, 7, 11, 233, 94, 7, 11, 233, 95, 7, 11, - 233, 96, 7, 11, 233, 97, 7, 11, 233, 98, 7, 11, 233, 99, 7, 11, 233, 100, - 7, 11, 233, 101, 7, 11, 233, 102, 7, 11, 233, 103, 7, 11, 233, 104, 7, - 11, 233, 105, 7, 11, 233, 106, 7, 11, 233, 107, 7, 11, 233, 108, 7, 11, - 233, 109, 7, 11, 233, 110, 7, 11, 233, 111, 7, 11, 233, 112, 7, 11, 233, - 113, 7, 11, 233, 114, 7, 11, 233, 115, 7, 11, 233, 116, 7, 11, 233, 117, - 7, 11, 233, 118, 7, 11, 233, 119, 7, 11, 233, 120, 7, 11, 233, 121, 7, - 11, 233, 122, 7, 11, 233, 123, 7, 11, 233, 124, 7, 11, 233, 125, 7, 11, - 233, 126, 7, 11, 233, 127, 7, 11, 233, 128, 7, 11, 233, 129, 7, 11, 233, - 130, 7, 11, 233, 131, 7, 11, 233, 132, 7, 11, 233, 133, 7, 11, 233, 134, - 7, 11, 233, 135, 7, 11, 233, 136, 7, 11, 233, 137, 7, 11, 233, 138, 7, - 11, 233, 139, 7, 11, 233, 140, 7, 11, 233, 141, 7, 11, 233, 142, 7, 11, - 233, 143, 7, 11, 233, 144, 7, 11, 233, 145, 7, 11, 233, 146, 7, 11, 233, - 147, 7, 11, 233, 148, 7, 11, 233, 149, 7, 11, 233, 150, 7, 11, 233, 151, - 7, 11, 233, 152, 7, 11, 233, 153, 7, 11, 233, 154, 7, 11, 233, 155, 7, - 11, 233, 156, 7, 11, 233, 157, 7, 11, 233, 158, 7, 11, 233, 159, 7, 11, - 233, 160, 7, 11, 233, 161, 7, 11, 233, 162, 7, 11, 233, 163, 7, 11, 233, - 164, 7, 11, 233, 165, 7, 11, 233, 166, 7, 11, 233, 167, 7, 11, 233, 168, - 7, 11, 233, 169, 7, 11, 233, 170, 7, 11, 233, 171, 7, 11, 233, 172, 7, - 11, 233, 173, 7, 11, 233, 174, 7, 11, 233, 175, 7, 11, 233, 176, 7, 11, - 233, 177, 7, 11, 233, 178, 7, 11, 233, 179, 7, 11, 233, 180, 7, 11, 233, - 181, 7, 11, 233, 182, 7, 11, 233, 183, 7, 11, 233, 184, 7, 11, 233, 185, - 7, 11, 233, 186, 7, 11, 233, 187, 7, 11, 233, 188, 7, 11, 233, 189, 7, - 11, 233, 190, 7, 11, 233, 191, 7, 11, 233, 192, 7, 11, 233, 193, 7, 11, - 233, 194, 7, 11, 233, 195, 7, 11, 233, 196, 7, 11, 233, 197, 7, 11, 233, - 198, 7, 11, 233, 199, 7, 11, 233, 200, 7, 11, 233, 201, 7, 11, 233, 202, - 7, 11, 233, 203, 7, 11, 233, 204, 7, 11, 233, 205, 7, 11, 233, 206, 7, - 11, 233, 207, 7, 11, 233, 208, 7, 11, 233, 209, 7, 11, 233, 210, 7, 11, - 233, 211, 7, 11, 233, 212, 7, 11, 233, 213, 7, 11, 233, 214, 7, 11, 233, - 215, 7, 11, 233, 216, 7, 11, 233, 217, 7, 11, 233, 218, 7, 11, 233, 219, - 7, 11, 233, 220, 7, 11, 233, 221, 7, 11, 233, 222, 7, 11, 233, 223, 7, - 11, 233, 224, 7, 11, 233, 225, 7, 11, 233, 226, 7, 11, 233, 227, 7, 11, - 233, 228, 7, 11, 233, 229, 7, 11, 233, 230, 7, 11, 233, 231, 7, 11, 233, - 232, 7, 11, 233, 233, 7, 11, 233, 234, 7, 11, 233, 235, 7, 11, 233, 236, - 7, 11, 233, 237, 7, 11, 233, 238, 7, 11, 233, 239, 7, 11, 233, 240, 7, - 11, 233, 241, 7, 11, 233, 242, 7, 11, 233, 243, 7, 11, 233, 244, 7, 11, - 233, 245, 7, 11, 233, 246, 7, 11, 233, 247, 7, 11, 233, 248, 7, 11, 233, - 249, 7, 11, 233, 250, 7, 11, 233, 251, 7, 11, 233, 252, 7, 11, 233, 253, - 7, 11, 233, 254, 7, 11, 233, 255, 7, 11, 234, 0, 7, 11, 234, 1, 7, 11, - 234, 2, 7, 11, 234, 3, 7, 11, 234, 4, 7, 11, 234, 5, 7, 11, 234, 6, 7, - 11, 234, 7, 7, 11, 234, 8, 7, 11, 234, 9, 7, 11, 234, 10, 7, 11, 234, 11, - 7, 11, 234, 12, 7, 11, 234, 13, 7, 11, 234, 14, 7, 11, 234, 15, 7, 11, - 234, 16, 7, 11, 234, 17, 7, 11, 234, 18, 7, 11, 234, 19, 7, 11, 234, 20, - 7, 11, 234, 21, 7, 11, 234, 22, 7, 11, 234, 23, 7, 11, 234, 24, 7, 11, - 234, 25, 7, 11, 234, 26, 7, 11, 234, 27, 7, 11, 234, 28, 7, 11, 234, 29, - 7, 11, 234, 30, 7, 11, 234, 31, 7, 11, 234, 32, 7, 11, 234, 33, 7, 11, - 234, 34, 7, 11, 234, 35, 7, 11, 234, 36, 7, 11, 234, 37, 7, 11, 234, 38, - 7, 11, 234, 39, 7, 11, 234, 40, 7, 11, 234, 41, 7, 11, 234, 42, 7, 11, - 234, 43, 7, 11, 234, 44, 7, 11, 234, 45, 7, 11, 234, 46, 7, 11, 234, 47, - 7, 11, 234, 48, 7, 11, 234, 49, 7, 11, 234, 50, 240, 104, 250, 81, 85, - 242, 69, 85, 236, 186, 65, 85, 238, 76, 65, 85, 83, 57, 85, 242, 158, 57, - 85, 240, 248, 57, 85, 237, 124, 85, 236, 190, 85, 36, 236, 47, 85, 37, - 236, 47, 85, 238, 77, 85, 249, 4, 57, 85, 242, 84, 85, 235, 243, 85, 213, - 189, 85, 239, 144, 85, 27, 244, 173, 85, 27, 121, 85, 27, 114, 85, 27, - 153, 85, 27, 163, 85, 27, 168, 85, 27, 169, 85, 27, 179, 85, 27, 176, 85, - 27, 178, 85, 242, 81, 85, 237, 123, 85, 206, 57, 85, 242, 61, 57, 85, - 196, 57, 85, 239, 126, 65, 85, 237, 127, 253, 220, 85, 9, 5, 1, 64, 85, - 9, 5, 1, 199, 85, 9, 5, 1, 203, 85, 9, 5, 1, 187, 85, 9, 5, 1, 70, 85, 9, - 5, 1, 204, 85, 9, 5, 1, 194, 85, 9, 5, 1, 164, 85, 9, 5, 1, 69, 85, 9, 5, - 1, 200, 85, 9, 5, 1, 205, 85, 9, 5, 1, 148, 85, 9, 5, 1, 171, 85, 9, 5, - 1, 183, 85, 9, 5, 1, 78, 85, 9, 5, 1, 198, 85, 9, 5, 1, 209, 85, 9, 5, 1, - 135, 85, 9, 5, 1, 159, 85, 9, 5, 1, 190, 85, 9, 5, 1, 84, 85, 9, 5, 1, - 186, 85, 9, 5, 1, 201, 85, 9, 5, 1, 170, 85, 9, 5, 1, 181, 85, 9, 5, 1, - 202, 85, 36, 30, 110, 85, 240, 219, 239, 144, 85, 37, 30, 110, 85, 157, - 240, 203, 85, 253, 113, 244, 176, 85, 244, 201, 240, 203, 85, 9, 3, 1, - 64, 85, 9, 3, 1, 199, 85, 9, 3, 1, 203, 85, 9, 3, 1, 187, 85, 9, 3, 1, - 70, 85, 9, 3, 1, 204, 85, 9, 3, 1, 194, 85, 9, 3, 1, 164, 85, 9, 3, 1, - 69, 85, 9, 3, 1, 200, 85, 9, 3, 1, 205, 85, 9, 3, 1, 148, 85, 9, 3, 1, - 171, 85, 9, 3, 1, 183, 85, 9, 3, 1, 78, 85, 9, 3, 1, 198, 85, 9, 3, 1, - 209, 85, 9, 3, 1, 135, 85, 9, 3, 1, 159, 85, 9, 3, 1, 190, 85, 9, 3, 1, - 84, 85, 9, 3, 1, 186, 85, 9, 3, 1, 201, 85, 9, 3, 1, 170, 85, 9, 3, 1, - 181, 85, 9, 3, 1, 202, 85, 36, 244, 175, 110, 85, 55, 244, 176, 85, 37, - 244, 175, 110, 85, 180, 243, 56, 250, 81, -}; - -static unsigned char phrasebook_offset1[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 8, 8, 8, 8, 8, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 8, 8, 8, 38, 39, 40, 41, 42, 43, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 44, 45, 46, 47, 48, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 49, 50, - 51, 52, 53, 54, 55, 8, 8, 8, 56, 57, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 58, - 59, 8, 8, 60, 61, 62, 63, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 64, 65, 66, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 67, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, -}; - -static unsigned int phrasebook_offset2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 6, 9, 11, 14, 17, 19, 21, 24, 27, 29, 32, - 34, 36, 38, 40, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 70, - 72, 75, 79, 83, 87, 91, 95, 99, 103, 107, 111, 115, 119, 123, 127, 131, - 135, 139, 143, 147, 151, 155, 159, 163, 167, 171, 175, 179, 183, 186, - 190, 193, 196, 200, 204, 208, 212, 216, 220, 224, 228, 232, 236, 240, - 244, 248, 252, 256, 260, 264, 268, 272, 276, 280, 284, 288, 292, 296, - 300, 304, 308, 312, 315, 319, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 320, 324, 329, - 332, 335, 338, 341, 344, 347, 348, 351, 357, 364, 366, 370, 373, 374, - 377, 380, 383, 386, 390, 393, 396, 399, 401, 404, 410, 417, 425, 433, - 441, 446, 452, 458, 465, 471, 477, 485, 490, 498, 504, 510, 517, 523, - 529, 535, 542, 548, 553, 560, 566, 572, 579, 585, 591, 594, 600, 606, - 612, 619, 625, 632, 637, 643, 649, 655, 662, 668, 674, 682, 687, 695, - 701, 707, 714, 720, 726, 732, 739, 745, 750, 757, 763, 769, 776, 782, - 788, 791, 797, 803, 809, 816, 822, 829, 834, 841, 847, 853, 859, 865, - 872, 879, 886, 893, 901, 909, 917, 925, 932, 939, 946, 953, 960, 967, - 973, 979, 985, 991, 998, 1005, 1012, 1019, 1025, 1031, 1039, 1047, 1054, - 1061, 1069, 1077, 1085, 1093, 1101, 1109, 1116, 1123, 1129, 1135, 1141, - 1147, 1153, 1159, 1166, 1173, 1180, 1186, 1191, 1196, 1204, 1212, 1220, - 1228, 1233, 1240, 1247, 1255, 1263, 1270, 1277, 1286, 1295, 1302, 1309, - 1316, 1323, 1331, 1339, 1346, 1353, 1364, 1369, 1374, 1380, 1386, 1392, - 1398, 1405, 1412, 1417, 1422, 1429, 1436, 1444, 1452, 1459, 1466, 1473, - 1480, 1488, 1496, 1504, 1512, 1519, 1526, 1534, 1542, 1549, 1556, 1563, - 1570, 1576, 1582, 1588, 1594, 1600, 1606, 1614, 1622, 1629, 1636, 1643, - 1650, 1658, 1666, 1674, 1682, 1689, 1696, 1703, 1711, 1719, 1726, 1733, - 1738, 1745, 1752, 1760, 1768, 1774, 1780, 1786, 1793, 1800, 1806, 1813, - 1821, 1829, 1836, 1841, 1846, 1852, 1859, 1866, 1873, 1878, 1883, 1888, - 1894, 1901, 1908, 1915, 1922, 1928, 1936, 1946, 1954, 1961, 1968, 1973, - 1978, 1985, 1992, 1996, 2002, 2008, 2013, 2020, 2029, 2036, 2043, 2052, - 2059, 2066, 2071, 2078, 2085, 2092, 2099, 2106, 2111, 2118, 2125, 2133, - 2138, 2144, 2150, 2160, 2164, 2170, 2176, 2182, 2188, 2195, 2207, 2214, - 2219, 2228, 2233, 2238, 2247, 2252, 2258, 2264, 2270, 2276, 2282, 2288, - 2294, 2300, 2309, 2318, 2327, 2336, 2345, 2354, 2363, 2372, 2378, 2387, - 2396, 2405, 2414, 2421, 2428, 2435, 2442, 2449, 2456, 2463, 2470, 2477, - 2484, 2493, 2502, 2509, 2516, 2523, 2528, 2537, 2542, 2549, 2556, 2561, - 2566, 2573, 2580, 2590, 2600, 2607, 2614, 2623, 2632, 2639, 2646, 2654, - 2662, 2669, 2676, 2684, 2692, 2699, 2706, 2714, 2722, 2729, 2736, 2744, - 2752, 2760, 2768, 2777, 2786, 2793, 2800, 2808, 2816, 2825, 2834, 2843, - 2852, 2857, 2862, 2869, 2876, 0, 2886, 2891, 2896, 2903, 2910, 2917, - 2924, 2931, 2938, 2947, 2956, 2964, 2972, 2979, 2986, 2995, 3004, 3011, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3018, 3024, 3029, 3036, 3043, 3049, 3057, 3065, 3072, 3077, - 3082, 3089, 3095, 3102, 3111, 3120, 3129, 3136, 3141, 3146, 3151, 3158, - 3164, 3171, 3178, 3184, 3189, 3194, 3203, 3211, 3220, 3225, 3231, 3242, - 3249, 3257, 3266, 3271, 3277, 3283, 3290, 3295, 3301, 3312, 3321, 3330, - 3338, 3346, 3355, 3360, 3367, 3374, 3379, 3391, 3399, 3407, 3413, 3422, - 3427, 3432, 3439, 3445, 3451, 3457, 3462, 3471, 3479, 3484, 3492, 3497, - 3505, 3512, 3517, 3523, 3528, 3536, 3544, 3549, 3557, 3563, 3568, 3575, - 3583, 3592, 3599, 3606, 3616, 3623, 3630, 3640, 3647, 3654, 3661, 3667, - 0, 0, 3673, 3677, 3684, 3688, 3692, 3698, 3707, 3714, 3718, 3722, 3726, - 3731, 3737, 3741, 3746, 3752, 3758, 3763, 3769, 3774, 3779, 3784, 3789, - 3794, 3795, 3800, 3803, 3809, 3815, 3822, 3827, 3835, 3843, 3849, 3856, - 3864, 3872, 3877, 3882, 3887, 3892, 3893, 3895, 3898, 3900, 3902, 3907, - 3912, 3918, 3923, 3927, 3931, 3935, 3942, 3949, 3956, 3963, 3970, 3977, - 3986, 3995, 3999, 4003, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 4008, 4013, 4018, 4022, 4024, 4026, 4029, 4031, 4034, 4036, 4040, - 4044, 4050, 4052, 4056, 4061, 4067, 4070, 4074, 4080, 4084, 4089, 4094, - 4099, 4104, 4109, 4114, 4118, 4121, 4127, 4132, 4137, 4142, 4147, 4153, - 4159, 4162, 4166, 4170, 4174, 4177, 4180, 4184, 4188, 4195, 4199, 4203, - 4207, 4213, 4216, 4220, 4225, 4231, 4235, 4241, 4247, 4253, 4259, 4265, - 4271, 4274, 4278, 4282, 4285, 4289, 4295, 4301, 4305, 4309, 4315, 4318, - 4322, 4327, 4332, 4336, 4340, 4344, 4350, 4355, 4359, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4364, 4367, 4372, 4377, 4382, 4387, 4392, - 4397, 4402, 4407, 4412, 4417, 4422, 4427, 4432, 4437, 0, 0, 0, 0, 4442, - 4445, 0, 0, 0, 0, 4449, 0, 0, 0, 4451, 0, 0, 0, 0, 0, 4455, 4458, 4463, - 4470, 4475, 4483, 4490, 0, 4497, 0, 4505, 4513, 4520, 4530, 4535, 4540, - 4545, 4550, 4555, 4560, 4565, 4570, 4575, 4580, 4585, 4590, 4595, 4600, - 4605, 4610, 0, 4615, 4620, 4625, 4630, 4635, 4640, 4645, 4650, 4657, - 4665, 4672, 4680, 4687, 4694, 4705, 4710, 4715, 4720, 4725, 4730, 4735, - 4740, 4745, 4750, 4755, 4760, 4765, 4770, 4775, 4780, 4785, 4790, 4796, - 4801, 4806, 4811, 4816, 4821, 4826, 4831, 4838, 4846, 4854, 4862, 0, - 4869, 4873, 4877, 4884, 4894, 4904, 4908, 4912, 4916, 4922, 4929, 4933, - 4938, 4942, 4947, 4951, 4956, 4960, 4965, 4971, 4977, 4983, 4989, 4995, - 5001, 5007, 5013, 5019, 5025, 5031, 5037, 5043, 5049, 5053, 5057, 5063, - 5067, 5072, 5078, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5085, 5092, 5097, 5102, - 5107, 5114, 5119, 5125, 5130, 5135, 5140, 5145, 5150, 5155, 5161, 5166, - 5171, 5175, 5180, 5185, 5190, 5195, 5200, 5205, 5210, 5214, 5219, 5223, - 5228, 5233, 5238, 5242, 5247, 5252, 5257, 5262, 5266, 5271, 5276, 5281, - 5286, 5291, 5296, 5302, 5307, 5313, 5317, 5322, 5326, 5330, 5335, 5340, - 5345, 5350, 5355, 5360, 5365, 5369, 5374, 5378, 5383, 5388, 5393, 5397, - 5402, 5407, 5412, 5417, 5421, 5426, 5431, 5436, 5441, 5446, 5451, 5457, - 5462, 5468, 5472, 5477, 5481, 5488, 5493, 5498, 5503, 5510, 5515, 5521, - 5526, 5531, 5536, 5541, 5546, 5551, 5557, 5562, 5567, 5572, 5577, 5582, - 5587, 5593, 5599, 5606, 5613, 5622, 5631, 5638, 5645, 5654, 5663, 5668, - 5673, 5678, 5683, 5688, 5693, 5698, 5703, 5714, 5725, 5730, 5735, 5742, - 5749, 5756, 5763, 5768, 5773, 5778, 5783, 5787, 5791, 5795, 5800, 0, - 5805, 5812, 5817, 5825, 5833, 5839, 5845, 5853, 5861, 5869, 5877, 5884, - 5891, 5900, 5909, 5917, 5925, 5933, 5941, 5949, 5957, 5965, 5973, 5980, - 5987, 5993, 5999, 6007, 6015, 6022, 6029, 6038, 6047, 6054, 6061, 6069, - 6077, 6085, 6093, 6099, 6105, 6113, 6121, 6129, 6137, 6144, 6151, 6159, - 6167, 6175, 6183, 6188, 6193, 6200, 6207, 6217, 6227, 6231, 6238, 6245, - 6252, 6259, 6267, 6275, 6282, 6289, 6297, 6305, 6312, 6319, 6327, 0, - 6335, 6341, 6347, 6353, 6359, 6365, 6371, 6378, 6385, 6390, 6395, 6402, - 6409, 6416, 6423, 6430, 6437, 6444, 6451, 6457, 6463, 6469, 6475, 6481, - 6487, 6493, 6499, 6507, 6515, 6521, 6527, 6533, 6539, 6545, 6551, 6558, - 6565, 6572, 0, 0, 6579, 6586, 0, 0, 0, 0, 0, 0, 6593, 6600, 6607, 6614, - 6621, 6628, 6635, 6642, 6649, 6656, 6663, 6670, 6677, 6684, 6691, 6698, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 6705, 6710, 6715, 6720, 6725, 6730, 6735, - 6740, 6745, 6749, 6754, 6759, 6764, 6769, 6774, 6779, 6784, 6789, 6794, - 6799, 6804, 6809, 6814, 6819, 6824, 6829, 6834, 6839, 6844, 6849, 6854, - 6859, 6864, 6869, 6874, 6879, 6884, 6889, 0, 0, 6894, 6901, 6904, 6908, - 6912, 6915, 6919, 0, 6923, 6928, 6933, 6938, 6943, 6948, 6953, 6958, - 6963, 6967, 6972, 6977, 6982, 6987, 6992, 6997, 7002, 7007, 7012, 7017, - 7022, 7027, 7032, 7037, 7042, 7047, 7052, 7057, 7062, 7067, 7072, 7077, - 7082, 7087, 7092, 7097, 7102, 7107, 7112, 0, 7119, 7122, 0, 0, 0, 0, 0, - 0, 7125, 7129, 7133, 7137, 7143, 7149, 7153, 7157, 7161, 7165, 7169, - 7173, 7177, 7183, 7187, 7193, 7199, 0, 7203, 7207, 7211, 7215, 7221, - 7225, 7229, 7235, 7243, 7247, 7251, 7255, 7259, 7265, 7270, 7277, 7284, - 7291, 7296, 7301, 7306, 7311, 7316, 0, 7321, 7326, 7334, 7339, 7344, - 7349, 7354, 7360, 7366, 7373, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7377, - 7381, 7385, 7389, 7393, 7397, 7401, 7405, 7409, 7413, 7417, 7422, 7426, - 7430, 7435, 7439, 7444, 7448, 7452, 7456, 7461, 7465, 7470, 7474, 7478, - 7482, 7486, 0, 0, 0, 0, 0, 7490, 7497, 7505, 7512, 7517, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7522, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7525, 0, 0, 0, 7528, 0, 7532, 7536, 7543, - 7549, 7556, 7562, 7568, 7572, 7576, 7581, 7585, 7589, 7593, 7597, 7601, - 7605, 7609, 7613, 7617, 7621, 7625, 7629, 7633, 7637, 7641, 7645, 0, 0, - 0, 0, 0, 7649, 7652, 7656, 7660, 7664, 7668, 7672, 7676, 7680, 7684, - 7689, 7693, 7696, 7699, 7702, 7705, 7708, 7711, 7714, 7717, 7721, 7724, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7727, 7732, 7736, 7740, 7744, 7748, 7752, - 7756, 7760, 7764, 7768, 7772, 7777, 7782, 7789, 7795, 7801, 7807, 7812, - 7820, 7828, 7834, 7841, 7848, 7854, 7861, 7865, 7869, 7873, 7879, 7890, - 7894, 7898, 7902, 7908, 7917, 7921, 7925, 7934, 7938, 7942, 7946, 7953, - 7960, 7972, 7976, 7980, 7984, 7996, 8006, 8010, 8017, 8024, 8031, 8040, - 8051, 8060, 8064, 8074, 8084, 8093, 8109, 8118, 8128, 8138, 8148, 8154, - 8163, 8170, 8174, 8184, 8188, 8195, 8205, 8209, 8215, 8222, 8229, 8233, - 8243, 8247, 8254, 8258, 8267, 8271, 8281, 8287, 8293, 8302, 8311, 8317, - 8322, 8326, 8332, 8341, 8346, 8353, 8359, 8364, 8372, 8379, 8386, 8392, - 8396, 8399, 8403, 8409, 8418, 8422, 8428, 8434, 8440, 8447, 8450, 8459, - 8464, 8472, 8475, 8479, 8492, 8505, 8512, 8519, 8525, 8533, 8539, 8545, - 8555, 8563, 8573, 8584, 8591, 8597, 8603, 8607, 8611, 8617, 8623, 8629, - 8637, 8645, 8657, 0, 0, 8663, 8670, 8676, 8682, 8688, 8694, 8700, 8706, - 8712, 8718, 8724, 8730, 8737, 8744, 8750, 0, 8758, 8764, 8769, 8774, - 8779, 8784, 8788, 8795, 8801, 8810, 8818, 8821, 8826, 8831, 0, 8836, - 8840, 8844, 8850, 8854, 8858, 8864, 8868, 8876, 8880, 8884, 8888, 8892, - 8896, 8902, 8906, 8912, 8916, 8920, 8924, 8928, 8932, 8937, 8940, 8944, - 8949, 8953, 8957, 8961, 8965, 0, 0, 0, 8969, 8973, 8977, 8982, 8986, - 8990, 8995, 8999, 9003, 9010, 9017, 9021, 9025, 9030, 9034, 9038, 9041, - 9045, 9048, 9051, 9057, 9063, 9069, 9075, 9080, 9085, 9088, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 9091, 9095, 9099, 9103, 9107, 9111, 9115, 9119, 9123, 9127, 9131, - 9135, 9139, 9143, 9147, 9151, 9155, 9159, 9163, 9167, 9171, 9175, 9179, - 9183, 9187, 9191, 9195, 9199, 9203, 9207, 9211, 9215, 9219, 9222, 9226, - 9230, 9234, 9238, 9242, 9245, 9248, 9251, 9254, 9257, 9260, 9263, 9266, - 9269, 9272, 9275, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 9279, 9283, 9287, 0, 9291, 9294, 9298, 9301, 9305, 9308, - 9312, 9316, 9320, 9325, 9329, 9332, 9336, 9341, 9345, 9348, 9352, 9355, - 9359, 9363, 9367, 9371, 9375, 9379, 9383, 9387, 9391, 9395, 9399, 9403, - 9407, 9411, 9415, 9419, 9423, 9427, 9431, 9435, 9439, 9443, 9447, 9451, - 9454, 9457, 9461, 9465, 9469, 9473, 9477, 9481, 9485, 9489, 9493, 0, 0, - 9497, 9501, 9505, 9510, 9514, 9519, 9523, 9528, 9533, 9539, 9545, 9550, - 9554, 9559, 9565, 9570, 9574, 9579, 0, 0, 9583, 9586, 9592, 9598, 9603, - 0, 0, 0, 9608, 9612, 9616, 9620, 9624, 9628, 9632, 9636, 9640, 9645, - 9650, 9655, 9661, 9664, 9668, 9672, 9675, 9678, 9681, 9684, 9687, 9690, - 9693, 9696, 9699, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9703, - 9707, 9711, 0, 9715, 9718, 9722, 9725, 9729, 9732, 9736, 9740, 0, 0, - 9744, 9747, 0, 0, 9751, 9754, 9758, 9761, 9765, 9769, 9773, 9777, 9781, - 9785, 9789, 9793, 9797, 9801, 9805, 9809, 9813, 9817, 9821, 9825, 9829, - 9833, 0, 9837, 9841, 9845, 9849, 9853, 9856, 9859, 0, 9863, 0, 0, 0, - 9867, 9871, 9875, 9879, 0, 0, 9883, 0, 9887, 9892, 9896, 9901, 9905, - 9910, 9915, 0, 0, 9921, 9925, 0, 0, 9930, 9934, 9939, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 9943, 0, 0, 0, 0, 9949, 9953, 0, 9957, 9961, 9966, 9971, 9976, - 0, 0, 9982, 9986, 9989, 9992, 9995, 9998, 10001, 10004, 10007, 10010, - 10013, 10022, 10030, 10034, 10038, 10044, 10050, 10056, 10062, 10077, - 10084, 0, 0, 0, 0, 0, 0, 0, 10087, 0, 0, 10091, 10094, 10098, 10101, - 10105, 10108, 0, 0, 0, 0, 10112, 10116, 0, 0, 10120, 10124, 10128, 10131, - 10135, 10139, 10143, 10147, 10151, 10155, 10159, 10163, 10167, 10171, - 10175, 10179, 10183, 10187, 10191, 10195, 10199, 10203, 0, 10207, 10211, - 10215, 10219, 10223, 10226, 10229, 0, 10233, 10237, 0, 10241, 10245, 0, - 10249, 10253, 0, 0, 10257, 0, 10261, 10266, 10270, 10275, 10279, 0, 0, 0, - 0, 10284, 10289, 0, 0, 10294, 10299, 10304, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 10308, 10312, 10316, 10320, 0, 10324, 0, 0, 0, 0, 0, 0, 0, 10328, - 10332, 10335, 10338, 10341, 10344, 10347, 10350, 10353, 10356, 10359, - 10362, 10365, 10368, 10371, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10376, - 10380, 10384, 0, 10388, 10391, 10395, 10398, 10402, 10405, 10409, 0, - 10413, 0, 10418, 10421, 10425, 0, 10430, 10433, 10437, 10440, 10444, - 10448, 10452, 10456, 10460, 10464, 10468, 10472, 10476, 10480, 10484, - 10488, 10492, 10496, 10500, 10504, 10508, 10512, 0, 10516, 10520, 10524, - 10528, 10532, 10535, 10538, 0, 10542, 10546, 0, 10550, 10554, 10558, - 10562, 10566, 0, 0, 10570, 10574, 10578, 10583, 10587, 10592, 10596, - 10601, 10606, 10612, 0, 10618, 10622, 10627, 0, 10633, 10637, 10642, 0, - 0, 10646, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10649, 0, 0, 0, 0, - 0, 10654, 10658, 10661, 10664, 10667, 10670, 10673, 10676, 10679, 10682, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10685, 10689, 10693, - 0, 10697, 10700, 10704, 10707, 10711, 10714, 10718, 10722, 0, 0, 10726, - 10729, 0, 0, 10733, 10736, 10740, 10743, 10747, 10751, 10755, 10759, - 10763, 10767, 10771, 10775, 10779, 10783, 10787, 10791, 10795, 10799, - 10803, 10807, 10811, 10815, 0, 10819, 10823, 10827, 10831, 10835, 10838, - 10841, 0, 10845, 10849, 0, 0, 10853, 10857, 10861, 10865, 0, 0, 10869, - 10873, 10877, 10882, 10886, 10891, 10895, 10900, 0, 0, 0, 10905, 10909, - 0, 0, 10914, 10918, 10923, 0, 0, 0, 0, 0, 0, 0, 0, 10927, 10933, 0, 0, 0, - 0, 10939, 10943, 0, 10947, 10951, 10956, 0, 0, 0, 0, 10961, 10965, 10968, - 10971, 10974, 10977, 10980, 10983, 10986, 10989, 10992, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10995, 10999, 0, 11003, 11006, 11010, - 11013, 11017, 11020, 0, 0, 0, 11024, 11027, 11031, 0, 11035, 11038, - 11042, 11046, 0, 0, 0, 11049, 11053, 0, 11057, 0, 11061, 11065, 0, 0, 0, - 11069, 11073, 0, 0, 0, 11077, 11081, 11085, 0, 0, 0, 11089, 11092, 11095, - 11099, 11103, 11107, 11111, 11115, 0, 11119, 11123, 11127, 0, 0, 0, 0, - 11131, 11136, 11140, 11145, 11149, 0, 0, 0, 11154, 11158, 11163, 0, - 11168, 11172, 11177, 11182, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11186, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11192, 11195, 11198, 11201, 11204, - 11207, 11210, 11213, 11216, 11219, 11223, 11229, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 11235, 11239, 11243, 0, 11247, 11250, 11254, 11257, - 11261, 11264, 11268, 11272, 0, 11276, 11279, 11283, 0, 11287, 11290, - 11294, 11298, 11301, 11305, 11309, 11313, 11317, 11321, 11325, 11329, - 11333, 11337, 11341, 11345, 11349, 11353, 11357, 11361, 11365, 11369, - 11373, 0, 11377, 11381, 11385, 11389, 11393, 11396, 11399, 11403, 11407, - 11411, 0, 11415, 11419, 11423, 11427, 11431, 0, 0, 0, 0, 11435, 11440, - 11444, 11449, 11453, 11458, 11463, 0, 11469, 11473, 11478, 0, 11483, - 11487, 11492, 11497, 0, 0, 0, 0, 0, 0, 0, 11501, 11505, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 11511, 11516, 0, 0, 0, 0, 11521, 11525, 11528, 11531, 11534, - 11537, 11540, 11543, 11546, 11549, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 11552, 11556, 0, 11560, 11563, 11567, 11570, 11574, 11577, - 11581, 11585, 0, 11589, 11592, 11596, 0, 11600, 11603, 11607, 11611, - 11614, 11618, 11622, 11626, 11630, 11634, 11638, 11642, 11646, 11650, - 11654, 11658, 11662, 11666, 11670, 11674, 11678, 11682, 11686, 0, 11690, - 11694, 11698, 11702, 11706, 11709, 11712, 11716, 11720, 11724, 0, 11728, - 11732, 11736, 11740, 11744, 0, 0, 0, 0, 11748, 11753, 11757, 11762, - 11766, 11771, 11776, 0, 11782, 11786, 11791, 0, 11796, 11800, 11805, - 11810, 0, 0, 0, 0, 0, 0, 0, 11814, 11818, 0, 0, 0, 0, 0, 0, 0, 11824, 0, - 11828, 11833, 0, 0, 0, 0, 11838, 11842, 11845, 11848, 11851, 11854, - 11857, 11860, 11863, 11866, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 11869, 11873, 0, 11877, 11880, 11884, 11887, 11891, 11894, - 11898, 11902, 0, 11906, 11909, 11913, 0, 11917, 11920, 11924, 11928, - 11931, 11935, 11939, 11943, 11947, 11951, 11955, 11959, 11963, 11967, - 11971, 11975, 11979, 11983, 11987, 11991, 11995, 11999, 12003, 0, 12007, - 12011, 12015, 12019, 12023, 12026, 12029, 12033, 12037, 12041, 12045, - 12049, 12053, 12057, 12061, 12065, 0, 0, 0, 0, 12069, 12074, 12078, - 12083, 12087, 12092, 0, 0, 12097, 12101, 12106, 0, 12111, 12115, 12120, - 12125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12129, 0, 0, 0, 0, 0, 0, 0, 0, 12135, - 12140, 0, 0, 0, 0, 12145, 12149, 12152, 12155, 12158, 12161, 12164, - 12167, 12170, 12173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 12176, 12180, 0, 12184, 12188, 12192, 12196, 12200, 12204, 12208, - 12212, 12216, 12220, 12224, 12228, 12232, 12236, 12240, 12244, 12248, - 12252, 0, 0, 0, 12256, 12262, 12268, 12274, 12280, 12286, 12292, 12298, - 12304, 12310, 12316, 12322, 12330, 12336, 12342, 12348, 12354, 12360, - 12366, 12372, 12378, 12384, 12390, 12396, 0, 12402, 12408, 12414, 12420, - 12426, 12432, 12436, 12442, 12446, 0, 12450, 0, 0, 12456, 12460, 12466, - 12472, 12478, 12482, 12488, 0, 0, 0, 12492, 0, 0, 0, 0, 12496, 12501, - 12508, 12515, 12522, 12529, 0, 12536, 0, 12543, 12548, 12553, 12560, - 12567, 12576, 12587, 12596, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 12601, 12608, 12615, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12620, - 12626, 12632, 12638, 12644, 12650, 12656, 12662, 12668, 12674, 12680, - 12686, 12692, 12698, 12704, 12709, 12715, 12721, 12727, 12733, 12739, - 12744, 12750, 12756, 12762, 12768, 12774, 12780, 12786, 12792, 12798, - 12804, 12810, 12815, 12821, 12827, 12831, 12837, 12841, 12847, 12853, - 12859, 12865, 12871, 12877, 12882, 12888, 12892, 12897, 12903, 12909, - 12915, 12920, 12926, 12932, 12938, 12943, 12949, 0, 0, 0, 0, 12953, - 12959, 12964, 12970, 12975, 12983, 12991, 12995, 12999, 13003, 13009, - 13015, 13021, 13027, 13031, 13035, 13039, 13043, 13047, 13050, 13053, - 13056, 13059, 13062, 13065, 13068, 13071, 13074, 13078, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 13082, 13086, 0, 13092, 0, 0, 13098, 13102, 0, - 13106, 0, 0, 13112, 0, 0, 0, 0, 0, 0, 13116, 13120, 13123, 13129, 0, - 13135, 13139, 13143, 13147, 13153, 13159, 13165, 0, 13171, 13175, 13179, - 0, 13185, 0, 13191, 0, 0, 13195, 13201, 0, 13207, 13210, 13216, 13219, - 13223, 13230, 13235, 13240, 13244, 13249, 13253, 13258, 13262, 0, 13267, - 13274, 13280, 0, 0, 13286, 13290, 13295, 13299, 13304, 0, 13309, 0, - 13314, 13321, 13328, 13335, 13342, 13346, 0, 0, 13349, 13353, 13356, - 13359, 13362, 13365, 13368, 13371, 13374, 13377, 0, 0, 13380, 13385, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 13390, 13394, 13405, 13420, 13435, 13445, - 13456, 13469, 13480, 13486, 13494, 13504, 13510, 13518, 13522, 13528, - 13534, 13542, 13552, 13560, 13573, 13579, 13587, 13595, 13607, 13615, - 13623, 13631, 13639, 13647, 13655, 13663, 13673, 13677, 13680, 13683, - 13686, 13689, 13692, 13695, 13698, 13701, 13704, 13708, 13712, 13716, - 13720, 13724, 13728, 13732, 13736, 13740, 13745, 13751, 13761, 13775, - 13785, 13791, 13797, 13805, 13813, 13821, 13829, 13835, 13841, 13844, - 13848, 13852, 13856, 13860, 13864, 13868, 0, 13872, 13876, 13880, 13884, - 13888, 13892, 13896, 13900, 13904, 13908, 13912, 13916, 13920, 13924, - 13928, 13932, 13935, 13939, 13943, 13947, 13951, 13955, 13959, 13963, - 13967, 13970, 13974, 13978, 13982, 13986, 13990, 13994, 13997, 14001, 0, - 0, 0, 0, 0, 0, 14007, 14012, 14016, 14021, 14025, 14030, 14035, 14041, - 14046, 14052, 14056, 14061, 14065, 14070, 14080, 14086, 14091, 14097, - 14107, 14113, 14117, 14121, 14127, 14133, 14141, 14147, 14155, 0, 0, 0, - 0, 14163, 14167, 14172, 14177, 14182, 14187, 14192, 14197, 0, 14202, - 14207, 14212, 14217, 14222, 14227, 14232, 14237, 14242, 14247, 14252, - 14257, 14262, 14267, 14272, 14277, 14281, 14286, 14291, 14296, 14301, - 14306, 14311, 14316, 14321, 14325, 14330, 14335, 14340, 14345, 14350, - 14355, 14359, 14364, 14371, 14377, 0, 14384, 14391, 14404, 14411, 14418, - 14426, 14434, 14440, 14446, 14452, 14462, 14468, 14474, 14484, 14494, 0, - 0, 14504, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 14512, 14515, 14519, 14523, 14527, 14531, 14535, 14539, 14543, - 14547, 14551, 14555, 14559, 14563, 14567, 14571, 14575, 14579, 14583, - 14587, 14591, 14595, 14599, 14603, 14607, 14611, 14614, 14617, 14621, - 14625, 14629, 14633, 14637, 14641, 0, 14644, 14647, 14651, 14654, 14658, - 0, 14661, 14664, 0, 14668, 14673, 14677, 14682, 14686, 14691, 14695, 0, - 0, 0, 14700, 14704, 14708, 14712, 0, 0, 0, 0, 0, 0, 14716, 14720, 14723, - 14726, 14729, 14732, 14735, 14738, 14741, 14744, 14747, 14753, 14757, - 14761, 14765, 14769, 14773, 14777, 14781, 14785, 14790, 14794, 14799, - 14804, 14810, 14815, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 14821, 14826, 14831, 14836, 14841, 14846, 14851, 14856, - 14861, 14866, 14871, 14876, 14881, 14886, 14891, 14896, 14901, 14906, - 14911, 14916, 14921, 14926, 14931, 14936, 14941, 14946, 14951, 14956, - 14961, 14966, 14971, 14976, 14981, 14986, 14991, 14996, 15001, 15006, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 15011, 15015, 15019, 15023, 15027, 15031, - 15035, 15039, 15043, 15047, 15051, 15055, 15059, 15063, 15067, 15071, - 15075, 15079, 15083, 15087, 15091, 15095, 15099, 15103, 15107, 15111, - 15115, 15119, 15123, 15127, 15131, 15135, 15139, 15143, 15147, 15151, - 15155, 15159, 15163, 15167, 15171, 0, 0, 15175, 0, 0, 0, 0, 15180, 15184, - 15188, 15192, 15196, 15200, 15204, 15208, 15212, 15216, 15220, 15224, - 15228, 15232, 15236, 15240, 15244, 15248, 15252, 15256, 15260, 15264, - 15268, 15272, 15276, 15280, 15284, 15288, 15292, 15296, 15300, 15304, - 15308, 15312, 15316, 15320, 15324, 15328, 15332, 15336, 15340, 15344, - 15348, 15352, 15356, 15360, 15364, 15368, 15372, 15376, 15380, 15384, - 15388, 15392, 15396, 15400, 15404, 15408, 15412, 15416, 15420, 15424, - 15428, 15432, 15436, 15440, 15444, 15448, 15452, 15456, 15460, 15464, - 15468, 15472, 15476, 15480, 15484, 15488, 15492, 15496, 15500, 15504, - 15508, 15512, 15516, 15520, 15524, 15528, 15532, 15536, 0, 0, 0, 0, 0, - 15540, 15544, 15548, 15551, 15555, 15558, 15562, 15566, 15569, 15573, - 15577, 15580, 15584, 15588, 15592, 15596, 15599, 15603, 15607, 15611, - 15615, 15619, 15623, 15626, 15630, 15634, 15638, 15642, 15646, 15650, - 15654, 15658, 15662, 15666, 15670, 15674, 15678, 15682, 15686, 15690, - 15694, 15698, 15702, 15706, 15710, 15714, 15718, 15722, 15726, 15730, - 15734, 15738, 15742, 15746, 15750, 15754, 15758, 15762, 15766, 15770, - 15774, 15778, 15782, 15786, 15790, 15794, 15798, 15802, 0, 0, 0, 0, 0, - 15806, 15810, 15814, 15818, 15822, 15826, 15830, 15834, 15838, 15842, - 15846, 15850, 15854, 15858, 15862, 15866, 15870, 15874, 15878, 15882, - 15886, 15890, 15894, 15898, 15902, 15906, 15910, 15914, 15918, 15922, - 15926, 15930, 15934, 15938, 15942, 15946, 15950, 15954, 15958, 15962, - 15966, 15970, 15974, 15978, 15982, 15986, 15990, 15994, 15998, 16002, - 16006, 16010, 16014, 16018, 16022, 16026, 16030, 16034, 16038, 16042, - 16046, 16050, 16054, 16058, 16062, 16066, 16070, 16074, 16078, 16082, - 16086, 16090, 16094, 16098, 16102, 16106, 16110, 16114, 16118, 16122, - 16126, 16130, 0, 0, 0, 0, 0, 0, 16134, 16138, 16142, 16146, 16150, 16154, - 16158, 0, 16162, 16166, 16170, 16174, 16178, 16182, 16186, 16190, 16194, - 16198, 16202, 16206, 16210, 16214, 16218, 16222, 16226, 16229, 16233, - 16237, 16241, 16245, 16249, 16253, 16257, 16261, 16265, 16269, 16273, - 16277, 16281, 16285, 16289, 16293, 16297, 16301, 16305, 16309, 16313, - 16317, 16321, 16325, 16329, 16333, 16337, 16341, 16345, 16349, 16353, - 16357, 16361, 16365, 16369, 16373, 16377, 16381, 16385, 16389, 16393, - 16397, 16401, 16405, 16409, 0, 16413, 0, 16417, 16421, 16425, 16429, 0, - 0, 16433, 16437, 16441, 16445, 16449, 16453, 16457, 0, 16461, 0, 16465, - 16469, 16473, 16477, 0, 0, 16481, 16485, 16489, 16493, 16497, 16501, - 16505, 16509, 16513, 16517, 16521, 16525, 16529, 16533, 16537, 16541, - 16545, 16549, 16553, 16557, 16561, 16565, 16569, 16572, 16576, 16580, - 16584, 16588, 16592, 16596, 16600, 16604, 16608, 16612, 16616, 16620, - 16624, 16628, 16632, 0, 16636, 0, 16640, 16644, 16648, 16652, 0, 0, - 16656, 16660, 16664, 16668, 16672, 16676, 16680, 16684, 16688, 16692, - 16696, 16700, 16704, 16708, 16712, 16716, 16720, 16725, 16730, 16735, - 16741, 16747, 16752, 16757, 16763, 16766, 16770, 16774, 16778, 16782, - 16786, 0, 16790, 0, 16794, 16798, 16802, 16806, 0, 0, 16810, 16814, - 16818, 16822, 16826, 16830, 16834, 0, 16838, 0, 16842, 16846, 16850, - 16854, 0, 0, 16858, 16862, 16866, 16870, 16874, 16878, 16882, 0, 16886, - 16891, 16896, 16901, 16907, 16913, 16918, 0, 16923, 16927, 16931, 16935, - 16939, 16943, 16947, 16951, 16955, 16959, 16963, 16967, 16971, 16975, - 16979, 16983, 16987, 16990, 16994, 16998, 17002, 17006, 17010, 0, 17014, - 17018, 17022, 17026, 17030, 17034, 17038, 17042, 17046, 17050, 17054, - 17058, 17062, 17066, 17070, 17074, 17078, 17082, 17086, 17090, 17094, - 17098, 17102, 17106, 17110, 17114, 17118, 17122, 17126, 17130, 17134, 0, - 17138, 0, 17142, 17146, 17150, 17154, 0, 0, 17158, 17162, 17166, 17170, - 17174, 17178, 17182, 0, 17186, 17190, 17194, 17198, 17202, 17206, 17210, - 17214, 17218, 17222, 17226, 17230, 17234, 17238, 17242, 17246, 17250, - 17254, 17258, 17262, 17266, 17270, 17274, 17278, 17282, 17286, 17290, - 17294, 17298, 17302, 17306, 17310, 17314, 17318, 17322, 17326, 17330, - 17334, 17338, 0, 17342, 17346, 17350, 17354, 17358, 17362, 17366, 17370, - 17374, 17378, 17382, 17386, 17390, 17394, 17398, 17402, 17406, 17410, - 17414, 0, 0, 0, 0, 0, 0, 17418, 17421, 17424, 17427, 17430, 17433, 17438, - 17442, 17447, 17450, 17453, 17456, 17459, 17462, 17465, 17468, 17471, - 17474, 17478, 17482, 17486, 17490, 17494, 17498, 17502, 17506, 17510, - 17514, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17520, 17523, 17526, 17529, 17532, - 17535, 17538, 17542, 17545, 17549, 17553, 17557, 17561, 17565, 17569, - 17573, 17577, 17581, 17585, 17589, 17593, 17597, 17601, 17605, 17609, - 17613, 17616, 17620, 17624, 17628, 17632, 17636, 17640, 17644, 17648, - 17652, 17656, 17660, 17664, 17668, 17672, 17676, 17680, 17684, 17688, - 17692, 17695, 17699, 17703, 17707, 17711, 17715, 17719, 17723, 17727, - 17731, 17735, 17739, 17743, 17747, 17751, 17755, 17759, 17763, 17767, - 17771, 17775, 17779, 17783, 17787, 17791, 17795, 17799, 17803, 17807, - 17811, 17815, 17819, 17823, 17827, 17830, 17834, 17838, 17842, 17846, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17850, 17853, 17857, 17860, 17864, - 17867, 17871, 17877, 17882, 17886, 17889, 17893, 17897, 17902, 17906, - 17911, 17915, 17920, 17924, 17929, 17933, 17938, 17944, 17948, 17953, - 17957, 17962, 17968, 17972, 17977, 17982, 17986, 17990, 17998, 18006, - 18013, 18018, 18023, 18031, 18037, 18043, 18048, 18054, 18058, 18062, - 18066, 18070, 18074, 18078, 18082, 18086, 18090, 18094, 18100, 18105, - 18110, 18114, 18118, 18122, 18127, 18131, 18136, 18140, 18145, 18149, - 18154, 18158, 18163, 18167, 18172, 18176, 18181, 18187, 18190, 18194, - 18198, 18202, 18206, 18210, 18214, 18217, 18221, 18227, 18232, 18237, - 18241, 18245, 18249, 18254, 18258, 18263, 18267, 18272, 18275, 18279, - 18283, 18288, 18292, 18297, 18301, 18306, 18312, 18315, 18319, 18323, - 18327, 18331, 18335, 18339, 18343, 18347, 18351, 18355, 18361, 18364, - 18368, 18372, 18377, 18381, 18386, 18390, 18395, 18399, 18404, 18408, - 18413, 18417, 18422, 18426, 18431, 18437, 18440, 18444, 18450, 18456, - 18462, 18468, 18472, 18476, 18480, 18484, 18488, 18492, 18498, 18502, - 18506, 18510, 18515, 18519, 18524, 18528, 18533, 18537, 18542, 18546, - 18551, 18555, 18560, 18564, 18569, 18575, 18578, 18584, 18588, 18592, - 18596, 18600, 18604, 18608, 18614, 18617, 18621, 18625, 18630, 18634, - 18639, 18643, 18648, 18652, 18657, 18661, 18666, 18670, 18675, 18679, - 18684, 18690, 18693, 18697, 18701, 18706, 18711, 18715, 18719, 18723, - 18727, 18731, 18735, 18741, 18745, 18749, 18753, 18758, 18762, 18767, - 18771, 18776, 18782, 18785, 18790, 18794, 18798, 18802, 18806, 18810, - 18814, 18818, 18824, 18828, 18832, 18836, 18841, 18845, 18850, 18854, - 18859, 18863, 18868, 18872, 18877, 18881, 18886, 18890, 18895, 18898, - 18902, 18906, 18910, 18914, 18918, 18922, 18926, 18930, 18936, 18940, - 18944, 18948, 18953, 18957, 18962, 18966, 18971, 18975, 18980, 18984, - 18989, 18993, 18998, 19002, 19007, 19013, 19016, 19021, 19025, 19030, - 19036, 19042, 19048, 19054, 19060, 19066, 19072, 19076, 19080, 19084, - 19088, 19092, 19096, 19100, 19104, 19109, 19113, 19118, 19122, 19127, - 19131, 19136, 19140, 19145, 19149, 19154, 19158, 19163, 19167, 19171, - 19175, 19179, 19183, 19187, 19191, 19197, 19200, 19204, 19208, 19213, - 19217, 19222, 19226, 19231, 19235, 19240, 19244, 19249, 19253, 19258, - 19262, 19267, 19273, 19276, 19281, 19285, 19291, 19295, 19301, 19306, - 19310, 19314, 19318, 19322, 19326, 19331, 19335, 19339, 19344, 19348, - 19353, 19356, 19360, 19364, 19368, 19372, 19376, 19380, 19384, 19388, - 19392, 19396, 19400, 19405, 19408, 19412, 19418, 19422, 19428, 19432, - 19438, 19442, 19446, 19450, 19454, 19458, 19463, 19467, 19471, 19475, - 19479, 19483, 19487, 19491, 19495, 19499, 19503, 19509, 19515, 19521, - 19527, 19533, 19539, 19545, 19550, 19555, 19559, 19563, 19567, 19571, - 19575, 19579, 19583, 19587, 19590, 19594, 19598, 19602, 19606, 19611, - 19616, 19621, 19626, 19630, 19634, 19638, 19642, 19646, 19650, 19654, - 19658, 19662, 19668, 19674, 19680, 19686, 19692, 19698, 19704, 19710, - 19716, 19720, 19724, 19728, 19732, 19736, 19740, 19744, 19750, 19756, - 19762, 19768, 19774, 19780, 19786, 19792, 19797, 19802, 19807, 19812, - 19817, 19823, 19829, 19835, 19841, 19847, 19853, 19859, 19865, 19871, - 19877, 19883, 19888, 19894, 19900, 19906, 19912, 19917, 19922, 19927, - 19932, 19937, 19942, 19947, 19952, 19957, 19962, 19967, 19972, 19977, - 19982, 19987, 19992, 19997, 20002, 20007, 20012, 20017, 20022, 20027, - 20032, 20037, 20042, 20047, 20052, 20057, 20062, 20067, 20072, 20077, - 20082, 20087, 20092, 20097, 20102, 20107, 20112, 20117, 20122, 20126, - 20131, 20136, 20141, 20146, 20151, 20156, 20161, 20166, 20171, 20176, - 20181, 20186, 20191, 20196, 20201, 20206, 20211, 20216, 20221, 20226, - 20231, 20236, 20241, 20246, 20251, 20256, 20261, 20266, 20271, 20276, - 20280, 20285, 20290, 20295, 20300, 20305, 20309, 20314, 20320, 20325, - 20330, 20335, 20340, 20346, 20351, 20356, 20361, 20366, 20371, 20376, - 20381, 20386, 20391, 20396, 20401, 20406, 20411, 20416, 20421, 20426, - 20431, 20436, 20441, 20446, 20451, 20456, 20461, 20466, 20471, 20476, - 20481, 20486, 20491, 20496, 20501, 20506, 20511, 20516, 20521, 20526, - 20531, 20536, 20541, 20546, 20551, 20556, 20561, 20565, 20570, 20575, - 20580, 20585, 20590, 20595, 20600, 20605, 20610, 20615, 20620, 20625, - 20630, 20635, 20640, 20645, 20650, 20655, 20660, 20665, 20670, 20675, - 20680, 20685, 20690, 20695, 20700, 20705, 20710, 20715, 20720, 20725, - 20730, 20735, 20740, 20745, 20750, 20755, 20760, 20764, 20768, 20772, - 20776, 20780, 20784, 20788, 20792, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20796, - 20801, 20806, 20811, 20816, 20821, 20826, 20831, 20836, 20841, 20846, - 20851, 20856, 20861, 20866, 20871, 20876, 20881, 20886, 20891, 20896, - 20901, 20906, 20911, 20916, 20921, 20926, 20931, 20936, 0, 0, 0, 20942, - 20951, 20954, 20961, 20965, 20968, 20971, 20979, 20983, 20988, 20993, - 20998, 21002, 21007, 21012, 21015, 21019, 21023, 21032, 21036, 21040, - 21045, 21048, 21052, 21059, 21063, 21070, 21075, 21080, 21085, 21090, - 21099, 21104, 21108, 21117, 21120, 21125, 21129, 21135, 21140, 21146, - 21153, 21159, 21164, 21171, 21176, 21179, 21182, 21191, 21196, 21199, - 21208, 21213, 21217, 21221, 21228, 21235, 21240, 21245, 21254, 21258, - 21262, 21266, 21273, 21280, 21284, 21288, 21292, 21296, 21300, 21304, - 21308, 21312, 21316, 21319, 21322, 21327, 21332, 21337, 21341, 21345, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21349, 21353, 21357, 21361, - 21365, 21370, 21375, 21380, 21385, 21390, 21395, 21400, 21404, 0, 21408, - 21413, 21418, 21423, 21428, 21433, 21438, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 21443, 21447, 21451, 21455, 21459, 21464, 21469, 21474, 21479, 21484, - 21489, 21494, 21498, 21502, 21507, 21512, 21517, 21522, 21527, 21532, - 21537, 21542, 21548, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21553, 21557, 21561, - 21565, 21569, 21574, 21579, 21584, 21589, 21594, 21599, 21604, 21608, - 21612, 21617, 21622, 21627, 21632, 21637, 21642, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 21647, 21651, 21655, 21659, 21663, 21668, 21673, 21678, - 21683, 21688, 21693, 21698, 21702, 0, 21706, 21711, 21716, 0, 21721, - 21726, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21731, 21734, 21738, 21742, - 21746, 21750, 21754, 21758, 21762, 21766, 21770, 21774, 21778, 21782, - 21786, 21790, 21794, 21798, 21801, 21805, 21809, 21813, 21817, 21821, - 21825, 21829, 21833, 21837, 21841, 21845, 21849, 21853, 21857, 21861, - 21865, 21869, 21875, 21881, 21887, 21893, 21899, 21905, 21911, 21917, - 21923, 21929, 21935, 21941, 21947, 21953, 21962, 21971, 21977, 21983, - 21989, 21994, 21998, 22003, 22007, 22012, 22016, 22021, 22026, 22031, - 22035, 22040, 22044, 22049, 22054, 22059, 22064, 22068, 22072, 22076, - 22080, 22084, 22088, 22092, 22096, 22100, 22104, 22110, 22114, 22118, - 22122, 22126, 22130, 22138, 22144, 22148, 22154, 22158, 22164, 0, 0, 0, - 22168, 22172, 22175, 22178, 22181, 22184, 22187, 22190, 22193, 22196, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22199, - 22202, 22205, 22208, 22211, 22214, 22219, 22226, 22234, 22239, 22244, - 22247, 22255, 22263, 22271, 0, 22275, 22279, 22282, 22285, 22288, 22291, - 22294, 22297, 22300, 22303, 0, 0, 0, 0, 0, 0, 22306, 22309, 22312, 22315, - 22318, 22321, 22325, 22329, 22333, 22337, 22341, 22345, 22349, 22353, - 22357, 22360, 22364, 22368, 22372, 22376, 22380, 22384, 22388, 22391, - 22395, 22399, 22403, 22406, 22410, 22414, 22418, 22422, 22426, 22430, - 22434, 22438, 22445, 22450, 22455, 22460, 22465, 22471, 22477, 22483, - 22489, 22495, 22501, 22507, 22512, 22518, 22524, 22530, 22536, 22542, - 22547, 22553, 22558, 22564, 22570, 22576, 22582, 22588, 22593, 22598, - 22604, 22610, 22615, 22621, 22626, 22632, 22638, 22644, 22650, 22656, - 22662, 22668, 22674, 22680, 22686, 22692, 22698, 22704, 22710, 22716, - 22721, 22726, 22732, 22738, 0, 0, 0, 0, 0, 0, 0, 0, 22744, 22751, 22758, - 22764, 22770, 22778, 22784, 22792, 22797, 22802, 22807, 22813, 22819, - 22825, 22831, 22837, 22843, 22849, 22855, 22861, 22867, 22873, 22879, - 22885, 22891, 22899, 22907, 22915, 22923, 22931, 22939, 22947, 22955, - 22963, 22971, 22979, 22987, 22995, 23003, 23009, 23015, 23023, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23029, 23037, 23045, 23053, 23061, - 23069, 23077, 23085, 23093, 23103, 23113, 23121, 23129, 23137, 23145, - 23153, 23161, 23169, 23177, 23185, 23193, 23202, 23211, 23220, 23229, - 23236, 23243, 23250, 23257, 23266, 23275, 23283, 23291, 23298, 23305, - 23313, 23321, 23329, 23337, 23344, 23351, 23359, 23367, 23376, 23385, - 23392, 23399, 23408, 23417, 23424, 23431, 23439, 23447, 23455, 23463, - 23471, 23479, 23490, 23501, 23509, 23517, 23525, 23533, 23540, 23547, - 23555, 23563, 23571, 23579, 23587, 23595, 23603, 23611, 23619, 23627, - 23635, 23643, 23651, 23659, 23667, 23675, 23684, 23693, 23702, 23711, - 23718, 23725, 23733, 23741, 23749, 23757, 23765, 23773, 23784, 23795, - 23803, 23811, 23819, 23827, 23835, 23843, 23854, 23865, 23876, 23887, - 23899, 23911, 23919, 23927, 23935, 23943, 23951, 23959, 23967, 23975, - 23983, 23991, 23998, 24005, 24012, 24019, 24027, 24035, 24044, 24053, - 24060, 24067, 24075, 24083, 24090, 24097, 24104, 24111, 24118, 24125, - 24133, 24141, 24149, 24157, 24165, 24173, 24180, 24187, 24195, 24203, - 24211, 24219, 24227, 24235, 24243, 24251, 24259, 24266, 24275, 24284, - 24293, 0, 0, 0, 0, 24302, 24309, 24316, 24324, 24332, 24340, 24348, - 24356, 24364, 24374, 24384, 24392, 24400, 24409, 24418, 24427, 24436, - 24445, 24454, 24465, 24476, 24485, 24494, 24504, 24514, 24521, 24528, - 24536, 24544, 24550, 24556, 24564, 24572, 24580, 24588, 24598, 24608, - 24616, 24624, 24633, 24642, 24650, 24658, 24665, 24672, 24679, 24686, - 24694, 24702, 24710, 24718, 24726, 24734, 24744, 24754, 24762, 24770, - 24779, 24788, 24797, 24806, 24815, 24824, 24835, 24846, 24855, 24864, - 24874, 24884, 24891, 24898, 24906, 24914, 24923, 24932, 24941, 24950, - 24961, 24972, 24981, 24990, 25000, 25010, 25017, 25024, 25032, 25040, - 25049, 25058, 25065, 0, 0, 0, 0, 0, 0, 25072, 25079, 25086, 25094, 25102, - 25110, 25118, 25127, 25136, 25143, 25150, 25158, 25166, 25174, 25182, - 25191, 25200, 25208, 25216, 25225, 25234, 25243, 0, 0, 25252, 25260, - 25268, 25277, 25286, 25295, 0, 0, 25304, 25311, 25318, 25326, 25334, - 25342, 25350, 25359, 25368, 25375, 25382, 25390, 25398, 25406, 25414, - 25423, 25432, 25439, 25446, 25454, 25462, 25470, 25478, 25487, 25496, - 25503, 25510, 25518, 25526, 25534, 25542, 25551, 25560, 25568, 25576, - 25585, 25594, 25603, 0, 0, 25612, 25620, 25628, 25637, 25646, 25655, 0, - 0, 25664, 25672, 25680, 25689, 25698, 25707, 25716, 25726, 0, 25736, 0, - 25744, 0, 25753, 0, 25762, 25772, 25779, 25786, 25794, 25802, 25810, - 25818, 25827, 25836, 25843, 25850, 25858, 25866, 25874, 25882, 25891, - 25900, 25906, 25912, 25919, 25926, 25932, 25938, 25944, 25950, 25957, - 25964, 25971, 25978, 25984, 0, 0, 25990, 25998, 26006, 26017, 26028, - 26039, 26050, 26061, 26072, 26081, 26090, 26102, 26114, 26126, 26138, - 26150, 26162, 26170, 26178, 26189, 26200, 26211, 26222, 26233, 26244, - 26253, 26262, 26274, 26286, 26298, 26310, 26322, 26334, 26342, 26350, - 26361, 26372, 26383, 26394, 26405, 26416, 26425, 26434, 26446, 26458, - 26470, 26482, 26494, 26506, 26513, 26519, 26528, 26534, 0, 26543, 26550, - 26559, 26566, 26572, 26578, 26584, 26591, 26594, 26597, 26600, 26603, - 26609, 26618, 26624, 0, 26633, 26640, 26649, 26656, 26663, 26669, 26675, - 26682, 26686, 26690, 26695, 26702, 26708, 26717, 0, 0, 26726, 26733, - 26743, 26750, 26756, 26762, 0, 26768, 26772, 26776, 26781, 26789, 26796, - 26806, 26816, 26824, 26832, 26840, 26851, 26859, 26866, 26873, 26880, - 26888, 26893, 26898, 0, 0, 26900, 26909, 26915, 0, 26924, 26931, 26940, - 26947, 26954, 26960, 26966, 26973, 26975, 0, 26978, 26982, 26986, 26990, - 26994, 26998, 27002, 27006, 27010, 27014, 27018, 27022, 27028, 27034, - 27040, 27043, 27046, 27048, 27052, 27056, 27060, 27064, 27066, 27070, - 27075, 27081, 27087, 27094, 27101, 27106, 27111, 27117, 27123, 27125, - 27128, 27130, 27134, 27139, 27143, 27146, 27150, 27153, 27157, 27161, - 27165, 27171, 27175, 27179, 27185, 27190, 27197, 27199, 27202, 27206, - 27209, 27213, 27218, 27220, 27228, 27236, 27239, 27243, 27245, 27247, - 27249, 27252, 27258, 27260, 27264, 27268, 27274, 27280, 27284, 27289, - 27294, 27299, 27303, 27307, 27311, 27315, 27318, 27322, 27329, 0, 0, 0, - 0, 27334, 0, 0, 0, 0, 0, 0, 0, 27338, 27343, 27347, 27351, 27355, 0, 0, - 0, 0, 0, 0, 27359, 27365, 27371, 27378, 27385, 27390, 27395, 27399, 0, 0, - 27405, 27408, 27411, 27414, 27417, 27420, 27423, 27428, 27432, 27437, - 27442, 27447, 27453, 27457, 27460, 27463, 27466, 27469, 27472, 27475, - 27478, 27481, 27484, 27489, 27493, 27498, 27503, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 27508, 27511, 27514, 27517, 27522, 27525, - 27528, 27531, 27534, 27537, 27540, 27545, 27548, 27551, 27554, 27557, - 27560, 27565, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27568, 27572, 27576, 27582, 27588, 27593, - 27598, 27602, 27606, 27611, 27618, 27625, 27631, 27637, 27642, 27647, - 27652, 27658, 27663, 27668, 27673, 27681, 27688, 27695, 27699, 27704, - 27710, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 27715, 27719, 27726, 27729, 27733, 27737, 27741, 27745, 27749, 27751, - 27755, 27758, 27761, 27765, 27768, 27772, 27781, 27784, 27788, 27791, - 27794, 27801, 27804, 27807, 27813, 27816, 27819, 27822, 27825, 27829, - 27832, 27836, 27838, 27841, 27844, 27848, 27850, 27853, 27856, 27859, - 27864, 27868, 27875, 27878, 27881, 27884, 27888, 27891, 27894, 27897, - 27900, 27904, 27907, 27910, 27912, 27915, 27918, 27921, 27925, 0, 0, - 27929, 27933, 27937, 27941, 27946, 27951, 27956, 27960, 27965, 27969, - 27973, 27977, 27981, 27985, 27989, 0, 0, 0, 0, 0, 0, 0, 27993, 28001, - 28008, 28016, 28023, 28031, 28039, 28047, 28055, 28063, 28071, 28079, - 28087, 28092, 28095, 28098, 28101, 28104, 28107, 28110, 28113, 28116, - 28119, 28123, 28127, 28131, 28135, 28141, 28147, 28153, 28157, 28161, - 28165, 28169, 28173, 28177, 28181, 28185, 28189, 28194, 28199, 28204, - 28209, 28216, 28223, 28230, 28239, 28245, 28251, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 28258, 28260, 28262, 28264, 28266, 28269, 28272, 28277, - 28282, 28287, 28292, 28296, 28300, 28304, 28308, 28313, 28318, 28323, - 28328, 28333, 28338, 28343, 28348, 28353, 28358, 28364, 28368, 28372, - 28377, 28382, 28387, 28392, 28396, 28403, 28410, 28417, 28424, 28431, - 28438, 28445, 28452, 28460, 28471, 28477, 28483, 28489, 28495, 28501, - 28507, 28513, 28519, 28525, 28531, 28537, 28543, 28549, 28554, 28559, - 28564, 28569, 28576, 28583, 28588, 28594, 28599, 28602, 28605, 28608, - 28611, 28615, 28619, 28625, 28631, 28637, 28643, 28647, 28651, 28655, - 28659, 28664, 28669, 28673, 28677, 28681, 28685, 28689, 28693, 28696, - 28699, 28702, 28705, 28711, 28718, 28728, 28738, 28742, 28750, 28757, - 28765, 28773, 28777, 28783, 28789, 28794, 28799, 28804, 28810, 28816, - 28822, 28829, 28833, 28837, 28842, 28845, 28847, 28851, 28855, 28862, - 28866, 28868, 28870, 28874, 28881, 28886, 28892, 28901, 28908, 28913, - 28917, 28921, 28925, 28928, 28931, 28934, 28938, 28942, 28945, 28948, - 28951, 28954, 28958, 28962, 28965, 28967, 28970, 28972, 28976, 28980, - 28982, 28987, 28990, 28994, 28998, 29002, 29004, 29006, 29008, 29011, - 29015, 29019, 29023, 29027, 29031, 29037, 29043, 29045, 29047, 29049, - 29051, 29054, 29056, 29060, 29062, 29064, 29066, 29071, 29075, 29079, - 29081, 29084, 29088, 29093, 29097, 29106, 29116, 29120, 29125, 29131, - 29134, 29138, 29141, 29146, 29150, 29156, 29160, 29171, 29179, 29183, - 29187, 29193, 29197, 29200, 29202, 29205, 29209, 29213, 29219, 29223, - 29227, 29230, 29233, 29237, 29242, 29246, 29250, 29255, 29260, 29266, - 29272, 29276, 29280, 29282, 29286, 29289, 29292, 29299, 29306, 29311, - 29316, 29324, 29332, 29336, 29340, 29347, 29354, 29356, 29358, 29363, - 29368, 29374, 29380, 29385, 29390, 29394, 29398, 29404, 29410, 29416, - 29422, 29432, 29442, 29449, 29456, 29458, 29462, 29466, 29471, 29476, - 29483, 29490, 29493, 29496, 29499, 29502, 29505, 29510, 29513, 29517, - 29521, 29524, 29527, 29531, 29535, 29539, 29543, 29546, 29549, 29552, - 29555, 29557, 29559, 29561, 29563, 29571, 29579, 29584, 29587, 29592, - 29602, 29608, 29614, 29620, 29628, 29636, 29647, 29651, 29655, 29657, - 29663, 29665, 29667, 29669, 29671, 29676, 29678, 29684, 29690, 29694, - 29698, 29701, 29703, 29706, 29710, 29712, 29721, 29730, 29735, 29740, - 29744, 29750, 29756, 29759, 29762, 29765, 29768, 29770, 29775, 29778, - 29781, 29787, 29793, 29799, 29805, 29810, 29815, 29820, 29825, 29833, - 29841, 29849, 29857, 29865, 29873, 29880, 29887, 29895, 29903, 29910, - 29921, 29930, 29944, 29947, 29952, 29958, 29964, 29971, 29985, 30000, - 30006, 30012, 30019, 30025, 30033, 30039, 30052, 30066, 30071, 30077, - 30085, 30088, 30091, 30093, 30096, 30099, 30101, 30103, 30107, 30110, - 30113, 30116, 30119, 30124, 30129, 30134, 30139, 30142, 30145, 30147, - 30149, 30151, 30155, 30159, 30163, 30169, 30173, 30175, 30177, 30182, - 30187, 30192, 30197, 30202, 30207, 30209, 30211, 30220, 30224, 30230, - 30239, 30241, 30245, 30249, 30256, 30260, 30262, 30266, 30268, 30272, - 30276, 30280, 30282, 30284, 30286, 30291, 30298, 30305, 30312, 30319, - 30326, 30333, 30339, 30345, 30351, 30357, 30364, 30371, 30378, 30385, - 30391, 30397, 30404, 30411, 30417, 30425, 30432, 30440, 30447, 30455, - 30461, 30468, 30476, 30483, 30491, 30498, 30506, 30512, 30519, 30526, - 30533, 30540, 30547, 30553, 30561, 30568, 30574, 30581, 30588, 30594, - 30600, 30606, 30611, 30619, 30627, 30632, 30637, 30643, 30649, 30654, - 30660, 30667, 30675, 30682, 30689, 30696, 30701, 30706, 30711, 30717, - 30724, 30730, 30736, 30741, 30745, 30752, 30758, 30761, 30767, 30770, - 30775, 30780, 30783, 30786, 30794, 30797, 30802, 30805, 30812, 30817, - 30824, 30827, 30830, 30833, 30838, 30843, 30846, 30849, 30857, 30860, - 30865, 30872, 30876, 30880, 30885, 30890, 30895, 30900, 30905, 30910, - 30915, 30920, 30926, 30931, 30937, 30943, 30948, 30954, 30960, 30968, - 30974, 30979, 30985, 30993, 30999, 31003, 31007, 31017, 31027, 31031, - 31035, 31039, 31043, 31053, 31057, 31062, 31067, 31072, 31077, 31082, - 31087, 31096, 31105, 31113, 31123, 31133, 31140, 31149, 31158, 31166, - 31176, 31186, 31194, 31202, 31212, 31222, 31225, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31228, 31232, 31239, - 31246, 31253, 31260, 31264, 31268, 31272, 31276, 31281, 31286, 31291, - 31297, 31303, 31309, 31315, 31323, 31330, 31337, 31344, 31351, 31357, - 31363, 31372, 31376, 31383, 31387, 31391, 31397, 31403, 31409, 31415, - 31419, 31423, 31426, 31430, 31434, 31441, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31448, 31451, 31455, 31459, - 31465, 31471, 31477, 31485, 31492, 31496, 31504, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31509, 31512, 31515, 31518, 31521, - 31524, 31527, 31530, 31533, 31536, 31540, 31544, 31548, 31552, 31556, - 31560, 31564, 31568, 31572, 31576, 31580, 31583, 31586, 31589, 31592, - 31595, 31598, 31601, 31604, 31607, 31611, 31615, 31619, 31623, 31627, - 31631, 31635, 31639, 31643, 31647, 31651, 31656, 31660, 31665, 31670, - 31675, 31680, 31685, 31690, 31695, 31700, 31705, 31710, 31715, 31720, - 31725, 31730, 31735, 31740, 31745, 31750, 31755, 31760, 31765, 31770, - 31775, 31780, 31785, 31790, 31795, 31800, 31805, 31810, 31815, 31820, - 31825, 31830, 31835, 31840, 31845, 31850, 31855, 31860, 31865, 31870, - 31875, 31880, 31885, 31890, 31895, 31900, 31905, 31910, 31915, 31920, - 31925, 31930, 31935, 31940, 31945, 31950, 31955, 31960, 31965, 31970, - 31975, 31980, 31985, 31990, 31995, 32000, 32005, 32010, 32015, 32020, - 32025, 32030, 32035, 32040, 32045, 32050, 32055, 32060, 32065, 32070, - 32075, 32080, 32085, 32090, 32095, 32100, 32105, 32110, 32115, 32120, - 32125, 32130, 32135, 32140, 32144, 32150, 32156, 32162, 32168, 32174, - 32180, 32186, 32192, 32198, 32204, 32208, 32212, 32216, 32220, 32224, - 32228, 32232, 32236, 32240, 0, 32245, 32250, 32255, 32260, 32265, 32274, - 32283, 32292, 32301, 32310, 32319, 32328, 32337, 32343, 32351, 32359, - 32365, 32372, 32380, 32388, 32395, 32401, 32409, 32417, 32423, 32430, - 32438, 32446, 32453, 32459, 32467, 32476, 32485, 32493, 32502, 32511, - 32517, 32524, 32532, 32541, 32550, 32558, 32567, 32576, 32583, 32590, - 32599, 32608, 32616, 32624, 32633, 32642, 32649, 32656, 32665, 32674, - 32682, 32690, 32699, 32708, 32715, 32722, 32731, 32740, 32748, 32757, - 32766, 32774, 32784, 32794, 32804, 32814, 32823, 32832, 32841, 32850, - 32857, 32865, 32873, 32881, 32889, 32894, 32899, 32908, 32916, 32922, - 32931, 32939, 32946, 32955, 32963, 32969, 32978, 32986, 32993, 33002, - 33010, 33016, 33025, 33033, 33040, 33049, 33057, 33064, 33073, 33081, - 33088, 33097, 33105, 33112, 33120, 33129, 33138, 33146, 33157, 33167, - 33174, 33179, 33184, 33188, 33193, 33198, 33203, 33207, 33212, 33219, - 33227, 33234, 33242, 33246, 33253, 33260, 33267, 33271, 33278, 33285, - 33292, 33295, 33302, 33309, 33316, 33320, 33327, 33334, 33341, 33345, - 33348, 33352, 33356, 33363, 33370, 33375, 33379, 33384, 33394, 33401, - 33412, 33422, 33426, 33434, 33444, 33447, 33450, 33457, 33465, 33470, - 33475, 33483, 33492, 33501, 33509, 33513, 33517, 33520, 33523, 33527, - 33531, 33534, 33537, 33541, 33545, 33550, 33555, 33559, 33563, 33568, - 33573, 33578, 33583, 33587, 33591, 33596, 33601, 33605, 33609, 33614, - 33619, 33624, 33629, 33632, 33635, 33644, 33646, 33648, 33651, 33655, - 33660, 33662, 33665, 33671, 33677, 33683, 33689, 33697, 33709, 33714, - 33719, 33723, 33728, 33735, 33742, 33750, 33758, 33766, 33774, 33778, - 33782, 33786, 33790, 33794, 33798, 33801, 33807, 33813, 33822, 33831, - 33839, 33846, 33855, 33864, 33868, 33875, 33882, 33889, 33896, 33903, - 33910, 33917, 33924, 33927, 33930, 33933, 33938, 33943, 33949, 33955, - 33958, 33964, 33966, 33968, 33970, 33972, 33975, 33978, 33980, 33982, - 33984, 33988, 33992, 33994, 33996, 33999, 34002, 34006, 34012, 34017, 0, - 0, 34019, 34024, 0, 34029, 34038, 34044, 34050, 34056, 34062, 34068, - 34074, 34079, 34082, 34085, 34088, 34090, 34092, 34096, 34100, 34105, - 34110, 34115, 34118, 34122, 34127, 34130, 34134, 34139, 34144, 34149, - 34154, 34159, 34164, 34169, 34174, 34179, 34184, 34189, 34194, 34200, - 34206, 34212, 34214, 34217, 34219, 34222, 34224, 34226, 34228, 34230, - 34232, 34234, 34236, 34238, 34240, 34242, 34244, 34246, 34248, 34250, - 34252, 34254, 34256, 34261, 34266, 34271, 34276, 34281, 34286, 34291, - 34296, 34301, 34306, 34311, 34316, 34321, 34326, 34331, 34336, 34341, - 34346, 34351, 34356, 34360, 34364, 34368, 34374, 34380, 34385, 34390, - 34395, 34400, 34405, 34410, 34418, 34426, 34434, 34442, 34450, 34458, - 34466, 34474, 34480, 34485, 0, 0, 34490, 34494, 34498, 34502, 34506, - 34510, 34514, 34519, 34525, 34531, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34538, 34543, 34546, 34551, 0, 34554, - 34559, 34563, 34565, 0, 0, 34567, 34571, 34575, 34579, 34581, 34585, - 34588, 34591, 34594, 34598, 34601, 34605, 34608, 34612, 34617, 34621, - 34627, 34634, 34637, 34643, 34648, 34652, 34657, 34663, 34669, 34676, - 34682, 34689, 0, 34696, 34703, 34707, 34714, 34720, 34725, 34731, 34735, - 34740, 34743, 34749, 34755, 34762, 34770, 34777, 34786, 34796, 34803, - 34809, 34813, 34821, 34826, 34835, 34838, 34841, 34850, 34861, 34868, - 34870, 34876, 34881, 34883, 34886, 34890, 34898, 0, 34907, 0, 34912, - 34919, 34926, 34933, 0, 0, 0, 34940, 0, 34947, 34950, 34954, 34957, - 34969, 34979, 34990, 0, 0, 34999, 35008, 35014, 35022, 35026, 35034, - 35038, 35046, 35053, 35060, 35069, 35078, 35086, 35094, 35103, 35112, - 35119, 35126, 35135, 35144, 35152, 35160, 35167, 35174, 35181, 35188, - 35195, 35202, 35209, 35216, 35223, 35231, 35237, 35243, 35249, 35255, - 35261, 35267, 35273, 35279, 35285, 35292, 35300, 35308, 35316, 35324, - 35332, 35340, 35348, 35356, 35364, 35373, 0, 0, 0, 35378, 35384, 35387, - 35393, 35399, 35404, 35408, 35413, 35419, 35426, 35429, 35436, 35443, - 35447, 35455, 35463, 35468, 35474, 35479, 35484, 35491, 35498, 35505, - 35512, 0, 35520, 35528, 35533, 35537, 35544, 35548, 35555, 35563, 35568, - 35576, 35580, 35585, 35589, 35594, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 35598, 35605, 35608, 35615, 35621, 35627, 35632, 35637, - 35642, 35647, 35652, 35658, 35663, 35666, 35670, 35674, 35680, 35689, - 35694, 35703, 35712, 35718, 35724, 35729, 35734, 35738, 35742, 35747, 0, - 0, 0, 0, 35752, 35756, 35760, 35766, 35772, 35778, 35781, 35784, 35788, - 35792, 35796, 35801, 35807, 35813, 35820, 35827, 35832, 35836, 35840, - 35844, 35848, 35852, 35856, 35860, 35864, 35868, 35872, 35876, 35880, - 35884, 35888, 35892, 35896, 35900, 35904, 35908, 35912, 35916, 35920, - 35924, 35928, 35932, 35936, 35940, 35944, 35948, 35952, 35956, 35960, - 35964, 35968, 35972, 35976, 35980, 35984, 35988, 35992, 35996, 36000, - 36004, 36008, 36012, 36016, 36020, 36024, 36028, 36032, 36036, 36040, - 36044, 36048, 36052, 36056, 36060, 36064, 36068, 36072, 36076, 36080, - 36084, 36088, 36092, 36096, 36100, 36104, 36108, 36112, 36116, 36120, - 36124, 36128, 36132, 36136, 36140, 36144, 36148, 36152, 36156, 36160, - 36164, 36168, 36172, 36176, 36180, 36184, 36188, 36192, 36196, 36200, - 36204, 36208, 36212, 36216, 36220, 36224, 36228, 36232, 36236, 36240, - 36244, 36248, 36252, 36256, 36260, 36264, 36268, 36272, 36276, 36280, - 36284, 36288, 36292, 36296, 36300, 36304, 36308, 36312, 36316, 36320, - 36324, 36328, 36332, 36336, 36340, 36344, 36348, 36352, 36356, 36360, - 36364, 36368, 36372, 36376, 36380, 36384, 36388, 36392, 36396, 36400, - 36404, 36408, 36412, 36416, 36420, 36424, 36428, 36432, 36436, 36440, - 36444, 36448, 36452, 36456, 36460, 36464, 36468, 36472, 36476, 36480, - 36484, 36488, 36492, 36496, 36500, 36504, 36508, 36512, 36516, 36520, - 36524, 36528, 36532, 36536, 36540, 36544, 36548, 36552, 36556, 36560, - 36564, 36568, 36572, 36576, 36580, 36584, 36588, 36592, 36596, 36600, - 36604, 36608, 36612, 36616, 36620, 36624, 36628, 36632, 36636, 36640, - 36644, 36648, 36652, 36656, 36660, 36664, 36668, 36672, 36676, 36680, - 36684, 36688, 36692, 36696, 36700, 36704, 36708, 36712, 36716, 36720, - 36724, 36728, 36732, 36736, 36740, 36744, 36748, 36752, 36756, 36760, - 36764, 36768, 36772, 36776, 36780, 36784, 36788, 36792, 36796, 36800, - 36804, 36808, 36812, 36816, 36820, 36824, 36828, 36832, 36836, 36840, - 36844, 36848, 36852, 36856, 36863, 36871, 36877, 36883, 36890, 36897, - 36903, 36909, 36914, 36919, 36923, 36927, 36932, 36937, 36943, 36949, - 36957, 36964, 36968, 36972, 36980, 36989, 36996, 37006, 37017, 37020, - 37023, 37027, 37031, 37037, 37043, 37053, 37063, 37073, 37083, 37090, - 37097, 37104, 37111, 37122, 37133, 37144, 37155, 37165, 37175, 37187, - 37199, 37210, 37221, 37233, 37245, 37253, 37263, 37273, 37283, 37293, - 37300, 37307, 37314, 37321, 37331, 37341, 37348, 37355, 37361, 37367, - 37373, 37379, 37385, 37391, 37397, 37402, 37410, 37419, 37427, 37435, - 37443, 37451, 37459, 37467, 37475, 37483, 37490, 37497, 37504, 37511, - 37518, 37525, 37532, 37539, 37547, 37555, 37563, 37571, 37579, 37587, - 37595, 37603, 37615, 37627, 37639, 37651, 37663, 37675, 37687, 37699, - 37708, 37718, 37727, 37737, 37749, 37761, 37769, 37775, 37781, 37786, - 37791, 37798, 37802, 37808, 37812, 37817, 37823, 37828, 37833, 37838, - 37843, 37848, 37855, 37861, 37869, 37874, 37879, 37883, 37887, 37895, - 37903, 37911, 37919, 37925, 37931, 37943, 37955, 37967, 37979, 37984, - 37989, 37994, 37999, 38005, 38011, 38018, 38025, 38029, 38034, 38041, - 38048, 38054, 38060, 38064, 38071, 38078, 38082, 38085, 38089, 38094, - 38101, 38108, 38126, 38145, 38163, 38182, 38201, 38220, 38239, 38258, - 38263, 38270, 38278, 38286, 38294, 38298, 38301, 38304, 38309, 38312, - 38330, 38335, 38341, 38347, 38351, 38354, 38357, 38360, 38368, 38378, - 38386, 38394, 38398, 38403, 38407, 38412, 38417, 38422, 38427, 38436, - 38442, 38449, 38456, 38463, 38470, 38473, 38480, 38487, 38490, 38493, - 38498, 38503, 38509, 38515, 38519, 38525, 38532, 38536, 38542, 38546, - 38550, 38558, 38569, 38577, 38581, 38583, 38592, 38601, 38607, 38610, - 38615, 38620, 38625, 38630, 38635, 38640, 38645, 38650, 38652, 38657, - 38662, 38669, 38673, 38679, 38682, 38686, 38692, 38698, 38700, 38702, - 38707, 38713, 38719, 38727, 38736, 38742, 38748, 38753, 38758, 38763, - 38768, 38773, 38778, 38784, 38789, 38796, 38800, 38804, 38816, 38828, - 38838, 38846, 38851, 38858, 38864, 38869, 38874, 38879, 38884, 38886, - 38892, 38900, 38908, 38916, 38923, 38930, 38936, 38942, 38948, 38955, - 38961, 38968, 38974, 38982, 38990, 38999, 39008, 39015, 39021, 39027, - 39036, 39040, 39049, 39058, 39066, 39074, 39078, 39084, 39090, 39096, - 39100, 39106, 39114, 39119, 39123, 39129, 39134, 39139, 39146, 39153, - 39158, 39163, 39171, 39179, 39189, 39199, 39206, 39213, 39217, 39221, - 39233, 39239, 39245, 39250, 39255, 39262, 39269, 39275, 39281, 39290, - 39298, 39306, 39313, 39320, 39327, 39333, 39340, 39346, 39353, 39360, - 39368, 39376, 39382, 39387, 39396, 39406, 39412, 39420, 39426, 39431, - 39436, 39444, 39450, 39457, 39464, 39470, 39475, 39482, 39490, 39503, - 39511, 39516, 39521, 39527, 39533, 39539, 39545, 39555, 39565, 39574, - 39583, 39593, 39604, 39608, 39612, 39619, 39626, 39631, 39636, 39644, - 39652, 39659, 39666, 39673, 39680, 39688, 39696, 39708, 39720, 39727, - 39734, 39744, 39754, 39761, 39768, 39777, 39786, 39791, 39796, 39804, - 39812, 39817, 39822, 39829, 39834, 39839, 39846, 39853, 39865, 39877, - 39881, 39885, 39892, 39899, 39906, 39914, 39922, 39930, 39938, 39944, - 39950, 39956, 39962, 39969, 39976, 39984, 39992, 39995, 39998, 40002, - 40006, 40013, 40020, 40027, 40034, 40043, 40052, 40059, 40066, 40072, - 40078, 40086, 40094, 40101, 40108, 40114, 40120, 40124, 40128, 40135, - 40142, 40147, 40152, 40157, 40162, 40168, 40182, 40189, 40196, 40200, - 40202, 40204, 40208, 40212, 40216, 40220, 40228, 40235, 40242, 40250, - 40262, 40269, 40276, 40285, 40289, 40293, 40298, 40304, 40315, 40320, - 40325, 40331, 40336, 40341, 40350, 40358, 40363, 40369, 40375, 40383, - 40391, 40399, 40407, 40411, 40414, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40419, 40423, - 40427, 40432, 40437, 40442, 40446, 40450, 40454, 40459, 40464, 40468, - 40472, 40476, 40480, 40485, 40490, 40495, 40500, 40504, 40508, 40513, - 40518, 40523, 40528, 40532, 0, 40536, 40540, 40544, 40548, 40552, 40556, - 40560, 40565, 40570, 40574, 40579, 40584, 40593, 40597, 40601, 40605, - 40612, 40616, 40621, 40626, 40630, 40634, 40640, 40645, 40650, 40655, - 40660, 40664, 40668, 40672, 40676, 40680, 40685, 40690, 40694, 40698, - 40703, 40708, 40713, 40717, 40721, 40726, 40731, 40737, 40743, 40747, - 40753, 40759, 40763, 40769, 40775, 40780, 40785, 40789, 40795, 40799, - 40803, 40809, 40815, 40820, 40825, 40829, 40833, 40841, 40847, 40853, - 40859, 40864, 40869, 40874, 40880, 40884, 40890, 40894, 40898, 40904, - 40910, 40916, 40922, 40928, 40934, 40940, 40946, 40952, 40958, 40964, - 40970, 40974, 40980, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40986, 40989, - 40993, 40996, 41000, 41004, 41007, 41010, 41014, 41018, 41022, 41026, - 41029, 41034, 41038, 41042, 41046, 41052, 41056, 41060, 41064, 41068, - 41075, 41081, 41085, 41089, 41093, 41097, 41101, 41105, 41109, 41113, - 41117, 41121, 41125, 41131, 41135, 41139, 41143, 41147, 41151, 41155, - 41159, 41163, 41167, 41171, 41175, 41179, 41183, 41187, 41191, 41195, - 41200, 41206, 41211, 41216, 41220, 41224, 41228, 41232, 41236, 41240, - 41244, 41248, 41252, 41256, 41260, 41264, 41268, 41272, 41276, 41280, - 41284, 41288, 41292, 41296, 41300, 41303, 41307, 41311, 41317, 41321, - 41325, 41329, 41333, 41337, 41341, 41345, 41349, 41353, 41360, 41364, - 41368, 41372, 41376, 41380, 41384, 41388, 41392, 41396, 41400, 41404, - 41408, 41415, 41419, 41425, 41429, 41433, 41437, 41441, 41445, 41448, - 41452, 41456, 41460, 41464, 41468, 41472, 41476, 41480, 41484, 41488, - 41492, 41496, 41500, 41504, 41508, 41512, 41516, 41520, 41524, 41528, - 41532, 41536, 41540, 41544, 41548, 41552, 41556, 41560, 41564, 41568, - 41572, 41576, 41582, 41586, 41590, 41594, 41598, 41602, 41606, 41610, - 41614, 41618, 41622, 41626, 41630, 41634, 41638, 41642, 41646, 41650, - 41654, 41658, 41662, 41666, 41670, 41674, 41678, 41682, 41686, 41690, - 41697, 41701, 41705, 41709, 41713, 41717, 41723, 41727, 41731, 41735, - 41739, 41743, 41747, 41751, 41755, 41759, 41763, 41767, 41771, 41775, - 41781, 41785, 41789, 41793, 41797, 41801, 41805, 41809, 41813, 41817, - 41821, 41825, 41829, 41833, 41837, 41841, 41845, 41849, 41853, 41857, - 41861, 41865, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 41869, 41876, 41883, 41893, 41903, 41910, 41919, 41928, - 41938, 41949, 41959, 41970, 0, 0, 0, 0, 41976, 41979, 41982, 41985, - 41988, 41995, 41999, 42003, 42007, 42010, 42013, 42017, 42021, 42025, - 42029, 42034, 42039, 42044, 42049, 42052, 42055, 42061, 42067, 42072, - 42077, 42084, 42091, 42095, 42099, 42103, 42110, 42116, 42124, 42129, - 42133, 42137, 42141, 42145, 42149, 42153, 42157, 42161, 42165, 42171, - 42177, 42183, 42189, 42196, 42202, 42206, 42212, 42223, 42232, 42246, - 42255, 42259, 42267, 42272, 42277, 42282, 42287, 42290, 42295, 42300, 0, - 42306, 42310, 42313, 42317, 42320, 42324, 42327, 42331, 42334, 42338, - 42341, 42344, 42348, 42352, 42356, 42360, 42364, 42368, 42372, 42376, - 42380, 42384, 42388, 42392, 42396, 42400, 42404, 42408, 42412, 42416, - 42420, 42424, 42428, 42432, 42436, 42441, 42445, 42449, 42453, 42457, - 42460, 42464, 42468, 42472, 42476, 42480, 42484, 42488, 42492, 42496, - 42500, 42504, 42508, 42512, 42516, 42520, 42524, 42528, 42532, 42536, - 42540, 42544, 42547, 42551, 42555, 42559, 42563, 42567, 42570, 42575, - 42579, 42584, 42588, 42592, 42596, 42600, 42604, 42608, 42613, 42617, - 42621, 42625, 42629, 42632, 42636, 42640, 0, 0, 42645, 42653, 42661, - 42668, 42675, 42679, 42685, 42690, 42695, 42699, 42702, 42706, 42709, - 42713, 42716, 42720, 42723, 42727, 42730, 42733, 42737, 42741, 42745, - 42749, 42753, 42757, 42761, 42765, 42769, 42773, 42777, 42781, 42785, - 42789, 42793, 42797, 42801, 42805, 42809, 42813, 42817, 42821, 42825, - 42830, 42834, 42838, 42842, 42846, 42849, 42853, 42857, 42861, 42865, - 42869, 42873, 42877, 42881, 42885, 42889, 42893, 42897, 42901, 42905, - 42909, 42913, 42917, 42921, 42925, 42929, 42933, 42936, 42940, 42944, - 42948, 42952, 42956, 42959, 42964, 42968, 42973, 42977, 42981, 42985, - 42989, 42993, 42997, 43002, 43006, 43010, 43014, 43018, 43021, 43025, - 43029, 43034, 43038, 43042, 43046, 43050, 43054, 43061, 43065, 43071, 0, - 0, 0, 0, 0, 43076, 43079, 43082, 43085, 43088, 43091, 43094, 43097, - 43100, 43103, 43106, 43109, 43112, 43115, 43118, 43122, 43126, 43130, - 43133, 43136, 43139, 43142, 43145, 43148, 43151, 43155, 43159, 43163, - 43167, 43171, 43175, 43179, 43183, 43187, 43191, 43194, 43197, 43201, - 43204, 43208, 0, 0, 0, 0, 43212, 43216, 43220, 43224, 43228, 43232, - 43236, 43240, 43244, 43248, 43252, 43256, 43260, 43264, 43268, 43272, - 43276, 43280, 43284, 43288, 43292, 43296, 43300, 43304, 43308, 43312, - 43316, 43320, 43324, 43328, 43332, 43335, 43339, 43342, 43346, 43350, - 43353, 43357, 43361, 43364, 43368, 43372, 43376, 43380, 43383, 43387, - 43391, 43395, 43399, 43403, 43407, 43410, 43413, 43417, 43421, 43425, - 43429, 43433, 43437, 43441, 43445, 43449, 43453, 43457, 43461, 43465, - 43469, 43473, 43477, 43481, 43485, 43489, 43493, 43497, 43501, 43505, - 43509, 43513, 43517, 43521, 43525, 43529, 43533, 43537, 43541, 43545, - 43549, 43553, 43557, 43561, 43565, 43569, 43573, 43577, 0, 43581, 43587, - 43593, 43599, 43604, 43610, 43616, 43622, 43628, 43634, 43640, 43646, - 43652, 43658, 43664, 43670, 43676, 43680, 43684, 43688, 43692, 43696, - 43700, 43704, 43708, 43712, 43716, 43720, 43724, 43728, 43732, 43736, - 43740, 43744, 43748, 43752, 43756, 43760, 43764, 43768, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 43772, 43777, 43782, 43787, 43791, 43796, 43801, 43806, 43811, - 43816, 43821, 43826, 43831, 43836, 43841, 43846, 43851, 43855, 43859, - 43863, 43867, 43871, 43875, 43879, 43883, 43887, 43891, 43895, 43899, - 43903, 43907, 43912, 43917, 43922, 43927, 43932, 43937, 43942, 43947, - 43952, 43957, 43962, 43967, 43972, 43977, 0, 0, 0, 43982, 43985, 43988, - 43991, 43994, 43997, 44000, 44003, 44006, 44009, 44013, 44017, 44021, - 44025, 44029, 44033, 44037, 44041, 44045, 44049, 44053, 44057, 44061, - 44065, 44069, 44073, 44077, 44081, 44085, 44089, 44093, 44097, 44101, - 44105, 44109, 44113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44117, 44122, - 44127, 44132, 44137, 44142, 44147, 44152, 44157, 44162, 44166, 44171, - 44176, 44181, 44186, 44191, 44195, 44199, 44203, 44207, 44211, 44215, - 44219, 44223, 44227, 44231, 44235, 44239, 44243, 44247, 44252, 44257, - 44262, 44267, 44272, 44277, 44282, 44287, 44292, 44297, 44302, 44307, - 44312, 0, 0, 0, 44317, 44322, 44325, 44328, 44331, 44334, 44337, 44340, - 44343, 44346, 44349, 44353, 44357, 44361, 44365, 44369, 44373, 44377, - 44381, 44385, 44389, 44393, 44397, 44401, 44405, 44409, 44413, 44417, - 44421, 44425, 44429, 44433, 44437, 44441, 44445, 44449, 44453, 44457, - 44461, 44465, 44469, 44473, 44476, 44480, 44484, 44488, 44492, 44496, - 44500, 44504, 44508, 44513, 44518, 44523, 44528, 44532, 44537, 44542, - 44547, 44552, 44557, 44562, 44567, 44572, 44577, 44581, 44587, 44593, - 44599, 44605, 44611, 44617, 44623, 44629, 44635, 44641, 44647, 0, 0, 0, - 0, 44653, 44656, 44659, 44662, 44665, 44668, 44671, 44675, 44679, 44683, - 44687, 44691, 44695, 44699, 44703, 44707, 44711, 44715, 44719, 44723, - 44726, 44730, 44734, 44738, 44742, 44746, 44750, 44754, 44758, 44762, - 44766, 44769, 44773, 44777, 44781, 44785, 44788, 44792, 44796, 44800, - 44804, 44808, 44812, 44816, 44820, 44824, 44828, 0, 44832, 44835, 44838, - 44841, 44844, 44847, 44850, 44853, 44856, 44859, 44862, 44865, 44868, - 44871, 44874, 44877, 44880, 44883, 44886, 44889, 44892, 44895, 44898, - 44901, 44904, 44907, 44910, 44913, 44916, 44919, 44922, 44925, 44928, - 44931, 44934, 44937, 44940, 44943, 44946, 44949, 44952, 44955, 44958, - 44961, 44964, 44967, 44970, 44973, 44976, 44979, 44982, 44985, 44988, - 44991, 44994, 44997, 45000, 45003, 45006, 45009, 45012, 45015, 45018, - 45021, 45024, 45027, 45030, 45033, 45036, 45039, 45042, 45045, 45048, - 45051, 45054, 45057, 45060, 45063, 45066, 45069, 45072, 45075, 45078, - 45081, 45084, 45087, 45090, 45093, 45096, 45104, 45111, 45118, 45125, - 45132, 45139, 45146, 45153, 45160, 45167, 45175, 45183, 45191, 45199, - 45207, 45215, 45223, 45231, 45239, 45247, 45255, 45263, 45271, 45279, - 45287, 45290, 45293, 45296, 45298, 45301, 0, 0, 0, 0, 45304, 45311, - 45318, 45325, 45332, 45335, 45340, 45343, 45347, 45349, 45351, 45354, - 45357, 45360, 45363, 45366, 45369, 45372, 45376, 45380, 45383, 45386, - 45389, 45392, 45395, 45398, 45401, 45405, 45408, 45411, 45414, 45417, - 45420, 45424, 45427, 45430, 45433, 45438, 45443, 45448, 45453, 45458, - 45463, 45468, 45473, 45479, 45488, 45491, 45494, 45497, 45500, 45503, - 45509, 45518, 45521, 45524, 45528, 45531, 45534, 45537, 45541, 45544, - 45547, 45552, 45555, 45558, 45562, 45565, 45568, 45573, 45578, 45583, - 45586, 45589, 45592, 45595, 45602, 45605, 45608, 45611, 45614, 45617, - 45620, 45623, 45628, 45631, 45634, 45637, 45640, 45643, 45648, 45651, - 45654, 45657, 45660, 45663, 45666, 45669, 45672, 0, 0, 45675, 45682, - 45689, 45696, 45703, 45710, 45717, 45724, 45731, 45738, 45746, 45754, - 45762, 45770, 45778, 45786, 45794, 45802, 45810, 45818, 45826, 45834, - 45842, 45850, 45858, 45866, 45874, 45882, 45890, 45898, 45906, 0, 45914, - 45918, 45922, 45925, 45929, 45933, 45937, 45941, 45945, 45949, 45953, - 45956, 45960, 45964, 45968, 45972, 45976, 45980, 45983, 45987, 45991, - 45994, 45998, 46002, 46006, 46010, 46014, 46018, 46022, 46026, 46030, - 46034, 46038, 46042, 46046, 46050, 46054, 46058, 46062, 46066, 46070, - 46074, 46078, 46082, 46086, 46090, 46094, 46098, 46102, 46106, 46110, - 46114, 46118, 46122, 46126, 46130, 46134, 46138, 46142, 46146, 46150, - 46154, 46158, 46162, 46166, 46170, 46174, 46178, 46182, 46186, 46190, - 46194, 46198, 46202, 46206, 46210, 46214, 46218, 46222, 46226, 46230, - 46234, 46238, 46242, 46246, 46250, 46254, 46258, 46262, 46266, 46270, - 46274, 46278, 46282, 46286, 46290, 46294, 46298, 46302, 46306, 46310, - 46314, 46318, 46322, 46326, 46330, 46334, 46338, 46342, 46346, 46350, - 46354, 46358, 46362, 46366, 46370, 46374, 46378, 46382, 46386, 46390, - 46394, 46398, 46402, 46406, 46410, 46414, 46418, 46422, 46426, 46430, - 46434, 46438, 46442, 46446, 46450, 46454, 46458, 46462, 46466, 46470, - 46474, 46478, 46482, 46486, 46490, 46494, 46498, 46502, 46506, 46510, - 46514, 46518, 46522, 46526, 46530, 46534, 46538, 46542, 46546, 46550, - 46554, 46558, 46562, 46566, 46570, 46574, 46578, 46582, 46586, 46590, - 46594, 46598, 46602, 46606, 46610, 46614, 46618, 46622, 46626, 46630, - 46634, 46638, 46642, 46645, 46649, 46653, 46657, 46661, 46665, 46669, - 46673, 46677, 46681, 46685, 46689, 46693, 46697, 46701, 46705, 46709, - 46713, 46717, 46721, 46725, 46729, 46733, 46737, 46741, 46745, 46749, - 46753, 46757, 46761, 46765, 46769, 46773, 46777, 46781, 46785, 46789, - 46793, 46797, 46801, 46805, 46809, 46813, 46817, 46821, 46825, 46829, - 46833, 46837, 46841, 46845, 46849, 46853, 46857, 46861, 46865, 46869, - 46873, 46877, 46881, 46885, 46889, 46893, 46897, 46901, 46905, 46909, - 46913, 46917, 46921, 46925, 46929, 46933, 46937, 46941, 46945, 46949, - 46953, 46957, 46961, 46965, 46969, 46973, 46977, 46981, 46985, 46988, - 46992, 46996, 47000, 47004, 47008, 47012, 47016, 47020, 47024, 47028, - 47032, 47036, 47040, 47044, 47048, 47052, 47056, 47060, 47064, 47068, - 47072, 47076, 47080, 47084, 47088, 47092, 47096, 47100, 47104, 47107, - 47111, 47115, 47119, 47123, 47127, 47131, 47135, 47139, 47143, 47147, - 47151, 47155, 47159, 47163, 47167, 47171, 47175, 47179, 47183, 47187, - 47191, 47195, 47199, 47203, 47207, 47211, 47215, 47219, 47223, 47227, - 47231, 47235, 47239, 47243, 47247, 47251, 47255, 47259, 47263, 47267, - 47271, 47275, 47279, 47283, 47287, 47291, 47295, 47299, 47303, 47307, - 47311, 47315, 47319, 47323, 47327, 47331, 47335, 47339, 47343, 47347, - 47351, 47355, 47359, 47363, 47367, 47371, 47375, 47379, 47383, 47387, - 47391, 47395, 47399, 47403, 47407, 47411, 47415, 47419, 47423, 47427, - 47431, 47435, 47439, 47443, 47447, 47451, 47455, 47459, 47463, 47467, - 47471, 47475, 47479, 47483, 47487, 47491, 47495, 47499, 47503, 47507, - 47511, 47515, 47519, 47523, 47527, 47531, 47535, 47539, 47543, 47547, - 47551, 47555, 47559, 47563, 47567, 47571, 47575, 47579, 47583, 47587, - 47591, 47595, 47599, 47603, 47607, 47611, 47615, 47619, 47623, 47627, - 47631, 47635, 47639, 47643, 47647, 47651, 47655, 47659, 47663, 47667, - 47671, 47675, 47679, 47683, 47687, 47691, 47695, 47699, 47703, 47707, - 47711, 47715, 47719, 47723, 47727, 47731, 47735, 47739, 47743, 47747, - 47751, 47755, 47759, 47763, 47767, 47771, 47775, 47779, 47783, 47787, - 47791, 47795, 47799, 47803, 47807, 47811, 47815, 47819, 47823, 47827, - 47831, 47835, 47839, 47843, 47847, 47851, 47855, 47859, 47863, 47867, - 47871, 47875, 47879, 47883, 47887, 47891, 47895, 47899, 47903, 47907, - 47911, 47915, 47919, 47923, 47927, 47931, 47935, 47939, 47943, 47947, - 47951, 47955, 47959, 47962, 47966, 47970, 47974, 47978, 47982, 47986, - 47990, 47994, 47998, 48002, 48006, 48010, 48014, 48018, 48022, 48026, - 48030, 48034, 48038, 48042, 48046, 48050, 48054, 48058, 48062, 48066, - 48070, 48074, 48078, 48082, 48086, 48090, 48094, 48098, 48102, 48106, - 48110, 48114, 48118, 48122, 48126, 48130, 48134, 48138, 48142, 48146, - 48150, 48154, 48158, 48162, 48166, 48170, 48174, 48178, 48182, 48186, - 48190, 48194, 48198, 48202, 48206, 48210, 48214, 48218, 48222, 48226, - 48230, 48234, 48238, 48242, 48246, 48250, 48254, 48258, 48262, 48266, - 48270, 48274, 48278, 48282, 48286, 48290, 48294, 48298, 48302, 48306, - 48310, 48314, 48318, 48322, 48326, 48330, 48334, 48338, 48342, 48346, - 48350, 48354, 48358, 48362, 48366, 48370, 48374, 48378, 48382, 48386, - 48390, 48394, 48398, 48402, 48406, 48410, 48414, 48418, 48422, 48426, - 48430, 48434, 48438, 48442, 48446, 48450, 48454, 48458, 48462, 48466, - 48470, 48474, 48478, 48482, 48486, 48490, 48494, 48498, 48502, 48506, - 48510, 48514, 48518, 48522, 48526, 48530, 48534, 48538, 48542, 48546, - 48550, 48554, 48558, 48562, 48566, 48570, 48574, 48578, 48582, 48586, - 48590, 48594, 48598, 48602, 48606, 48610, 48614, 48618, 48622, 48626, - 48630, 48634, 48638, 48642, 48646, 48650, 48654, 48658, 48662, 48666, - 48670, 48674, 48678, 48682, 48686, 48690, 48694, 48698, 48702, 48706, - 48710, 48714, 48718, 48722, 48726, 48730, 48734, 48738, 48742, 48746, - 48750, 48754, 48758, 48762, 48766, 48770, 48774, 48778, 48782, 48786, - 48790, 48794, 48798, 48802, 48806, 48810, 48814, 48818, 48822, 48826, - 48830, 48834, 48838, 48842, 48846, 48850, 48854, 48858, 48862, 48866, - 48870, 48874, 48878, 48882, 48886, 48890, 48894, 48898, 48902, 48906, - 48910, 48914, 48918, 48922, 48926, 48930, 48934, 48938, 48942, 48946, - 48950, 48954, 48958, 48962, 48966, 48970, 48974, 48978, 48982, 48986, - 48990, 48994, 48998, 49002, 49006, 49010, 49014, 49018, 49021, 49025, - 49029, 49033, 49037, 49041, 49045, 49049, 49053, 49057, 49061, 49065, - 49069, 49073, 49077, 49081, 49085, 49089, 49093, 49097, 49101, 49105, - 49109, 49113, 49117, 49121, 49125, 49129, 49133, 49137, 49141, 49145, - 49149, 49153, 49157, 49161, 49165, 49169, 49173, 49177, 49181, 49185, - 49189, 49193, 49197, 49201, 49205, 49209, 49213, 49217, 49221, 49225, - 49229, 49233, 49237, 49241, 49245, 49249, 49253, 49257, 49261, 49265, - 49269, 49273, 49277, 49281, 49285, 49289, 49293, 49297, 49301, 49305, - 49309, 49313, 49317, 49321, 49325, 49329, 49333, 49337, 49341, 49345, - 49349, 49353, 49357, 49361, 49365, 49369, 49373, 49377, 49381, 49385, - 49389, 49393, 49397, 49401, 49405, 49409, 49413, 49417, 49421, 49425, - 49429, 49433, 49437, 49441, 49445, 49449, 49453, 49457, 49461, 49465, - 49469, 49473, 49477, 49481, 49485, 49489, 49493, 49497, 49501, 49505, - 49509, 49513, 49517, 49521, 49525, 49529, 49533, 49537, 49541, 49545, - 49549, 49553, 49557, 49561, 49565, 49569, 49573, 49577, 49581, 49585, - 49589, 49593, 49597, 49601, 49605, 49609, 49613, 49617, 49621, 49625, - 49629, 49633, 49637, 49641, 49645, 49649, 49653, 49657, 49661, 49665, - 49669, 49673, 49677, 49681, 49685, 49689, 49693, 49697, 49701, 49705, - 49709, 49713, 49717, 49721, 49725, 49729, 49733, 49737, 49741, 49745, - 49749, 49753, 49757, 49761, 49765, 49769, 49773, 49777, 49781, 49785, - 49789, 49793, 49797, 49801, 49805, 49809, 49813, 49817, 49821, 49825, - 49829, 49833, 49837, 49841, 49845, 49849, 49853, 49857, 49861, 49865, - 49869, 49873, 49877, 49881, 49885, 49889, 49893, 49897, 49901, 49905, - 49909, 49913, 49917, 49921, 49925, 49929, 49933, 49937, 49941, 49945, - 49949, 49953, 49957, 49961, 49965, 49969, 49973, 49977, 49981, 49985, - 49989, 49993, 49997, 50001, 50005, 50009, 50013, 50017, 50021, 50025, - 50029, 50033, 50037, 50041, 50045, 50049, 50053, 50057, 50061, 50065, - 50069, 50073, 50077, 50081, 50085, 50089, 50093, 50097, 50101, 50105, - 50109, 50113, 50117, 50121, 50125, 50129, 50133, 50137, 50141, 50145, - 50149, 50153, 50157, 50161, 50165, 50169, 50173, 50177, 50181, 50185, - 50189, 50193, 50197, 50201, 50205, 50209, 50213, 50217, 50221, 50225, - 50229, 50233, 50237, 50241, 50245, 50249, 50253, 50257, 50261, 50265, - 50269, 50273, 50277, 50281, 50285, 50289, 50293, 50297, 50301, 50305, - 50309, 50313, 50317, 50321, 50325, 50329, 50333, 50337, 50341, 50345, - 50349, 50353, 50357, 50361, 50365, 50369, 50373, 50377, 50381, 50385, - 50389, 50393, 50397, 50401, 50405, 50409, 50413, 50417, 50421, 50425, - 50429, 50433, 50437, 50441, 50445, 50449, 50453, 50457, 50461, 50465, - 50469, 50473, 50477, 50481, 50485, 50489, 50493, 50497, 50501, 50505, - 50509, 50513, 50517, 50521, 50525, 50529, 50533, 50537, 50541, 50545, - 50549, 50553, 50557, 50561, 0, 0, 0, 50565, 50569, 50573, 50577, 50581, - 50585, 50589, 50593, 50597, 50601, 50605, 50609, 50613, 50617, 50621, - 50625, 50629, 50633, 50637, 50641, 50645, 50649, 50653, 50657, 50661, - 50665, 50669, 50673, 50677, 50681, 50685, 50689, 50693, 50697, 50701, - 50705, 50709, 50713, 50717, 50721, 50725, 50729, 50733, 50737, 50741, - 50745, 50749, 50753, 50757, 50761, 50765, 50769, 50773, 50777, 50781, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 50785, 50789, 50793, 50797, 50801, 50805, 50809, - 50813, 50817, 50821, 50825, 50829, 50833, 50837, 50841, 50845, 50849, - 50853, 50857, 50861, 50865, 50869, 50873, 50877, 50881, 50885, 50889, - 50893, 50897, 50901, 50905, 50909, 50913, 50917, 50921, 50925, 50929, - 50933, 50937, 50941, 50945, 50949, 50953, 50957, 50961, 50965, 50969, - 50973, 50977, 50981, 50985, 50989, 50993, 50997, 51001, 51005, 51009, - 51013, 51017, 51021, 51025, 51029, 51033, 51037, 51041, 51045, 51049, - 51053, 51057, 51061, 51065, 51069, 51073, 51077, 51081, 51085, 51089, - 51093, 51097, 51101, 51105, 51109, 51113, 51117, 51121, 51125, 51129, - 51133, 51137, 51141, 51145, 51149, 51153, 51157, 51161, 51165, 51169, - 51173, 51177, 51181, 51185, 51189, 51193, 51197, 51201, 51205, 51209, - 51213, 51217, 51221, 51225, 51229, 51233, 51237, 51241, 51245, 51249, - 51253, 51257, 51261, 51265, 51269, 51273, 51277, 51281, 51285, 51289, - 51293, 51297, 51301, 51305, 51309, 51313, 51317, 51321, 51325, 51329, - 51333, 51337, 51341, 51345, 51349, 51353, 51357, 51361, 51365, 51369, - 51373, 51377, 51381, 51385, 51389, 51393, 51397, 51401, 51405, 51409, - 51413, 51417, 51421, 51425, 51429, 51433, 51437, 51441, 51445, 51449, - 51453, 51457, 51461, 51465, 51469, 51473, 51477, 51481, 51485, 51489, - 51493, 51497, 51501, 51505, 51509, 51513, 51517, 51521, 51525, 51529, - 51533, 51537, 51541, 51545, 51549, 51553, 51557, 51561, 51565, 51569, - 51573, 51577, 51581, 51585, 51589, 51593, 51597, 51601, 51605, 51609, - 51613, 51617, 51621, 51625, 51629, 51633, 51637, 51641, 51645, 51649, - 51653, 51657, 51661, 51665, 51669, 51673, 51677, 51681, 51685, 51689, - 51693, 51697, 51701, 51705, 51709, 51713, 51717, 51721, 51725, 51729, - 51733, 51737, 51741, 51745, 51749, 51753, 51757, 51761, 51765, 51769, - 51773, 51777, 51781, 51785, 51789, 51793, 51797, 51801, 51805, 51809, - 51813, 51817, 51821, 51825, 51829, 51833, 51837, 51841, 51845, 51849, - 51853, 51857, 51861, 51865, 51869, 51873, 51877, 51881, 51885, 51889, - 51893, 51897, 51901, 51905, 51909, 51913, 51917, 51921, 51925, 51929, - 51933, 51937, 51941, 51945, 51949, 51953, 51957, 51961, 51965, 51969, - 51973, 51977, 51981, 51985, 51989, 0, 0, 51993, 51997, 52001, 52005, - 52009, 52013, 52017, 52021, 52025, 52029, 52033, 52037, 52041, 52045, - 52049, 52053, 52057, 52061, 52065, 52069, 52073, 52077, 52081, 52085, - 52089, 52093, 52097, 52101, 52105, 52109, 52113, 52117, 52121, 52125, - 52129, 52133, 52137, 52141, 52145, 52149, 52153, 52157, 52161, 52165, - 52169, 52173, 52177, 52181, 52185, 52189, 52193, 52197, 52201, 52205, - 52209, 52213, 52217, 52221, 52225, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52229, 52234, 52239, - 52244, 52249, 52254, 52261, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52266, - 52273, 52280, 52287, 52294, 0, 0, 0, 0, 0, 52301, 52308, 52315, 52325, - 52331, 52337, 52343, 52349, 52355, 52361, 52368, 52374, 52380, 52387, - 52395, 52403, 52414, 52425, 52431, 52437, 52443, 52450, 52457, 52464, - 52471, 52478, 0, 52485, 52492, 52499, 52507, 52514, 0, 52521, 0, 52528, - 52535, 0, 52542, 52550, 0, 52557, 52564, 52571, 52578, 52585, 52592, - 52599, 52606, 52613, 52620, 52625, 52632, 52639, 52645, 52651, 52657, - 52663, 52669, 52675, 52681, 52687, 52693, 52699, 52705, 52711, 52717, - 52723, 52729, 52735, 52741, 52747, 52753, 52759, 52765, 52771, 52777, - 52783, 52789, 52795, 52801, 52807, 52813, 52819, 52825, 52831, 52837, - 52843, 52849, 52855, 52861, 52867, 52873, 52879, 52885, 52891, 52897, - 52903, 52909, 52915, 52921, 52927, 52933, 52939, 52945, 52951, 52957, - 52963, 52969, 52975, 52981, 52987, 52993, 52999, 53005, 53011, 53017, - 53023, 53029, 53035, 53041, 53047, 53053, 53059, 53065, 53071, 53077, - 53083, 53089, 53095, 53102, 53109, 53115, 53121, 53127, 53133, 53141, - 53149, 53156, 53163, 53170, 53177, 53184, 53191, 53198, 53205, 53212, - 53219, 53229, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53239, 53245, 53251, 53257, 53263, - 53268, 53273, 53279, 53285, 53291, 53297, 53305, 53311, 53317, 53325, - 53333, 53341, 53349, 53354, 53359, 53364, 53369, 53381, 53393, 53403, - 53413, 53424, 53435, 53446, 53457, 53467, 53477, 53488, 53499, 53510, - 53521, 53531, 53541, 53551, 53566, 53581, 53596, 53603, 53610, 53617, - 53624, 53634, 53644, 53654, 53665, 53675, 53683, 53691, 53699, 53707, - 53716, 53724, 53731, 53738, 53745, 53752, 53760, 53767, 53775, 53783, - 53792, 53800, 53807, 53814, 53821, 53828, 53835, 53842, 53849, 53856, - 53863, 53870, 53877, 53885, 53893, 53901, 53909, 53917, 53925, 53933, - 53941, 53949, 53957, 53965, 53973, 53981, 53989, 53997, 54005, 54013, - 54022, 54030, 54038, 54046, 54055, 54063, 54071, 54079, 54087, 54095, - 54103, 54111, 54120, 54128, 54135, 54142, 54149, 54156, 54164, 54171, - 54178, 54185, 54192, 54199, 54207, 54214, 54221, 54228, 54235, 54242, - 54250, 54257, 54264, 54271, 54279, 54286, 54293, 54300, 54307, 54314, - 54322, 54329, 54339, 54349, 54359, 54368, 54377, 54386, 54395, 54404, - 54414, 54425, 54436, 54446, 54456, 54467, 54477, 54486, 54495, 54503, - 54511, 54520, 54528, 54536, 54544, 54551, 54558, 54566, 54573, 54582, - 54591, 54599, 54607, 54616, 54624, 54633, 54641, 54650, 54658, 54666, - 54674, 54682, 54691, 54699, 54706, 54714, 54721, 54728, 54735, 54743, - 54751, 54758, 54765, 54773, 54780, 54790, 54798, 54806, 54813, 54820, - 54828, 54835, 54845, 54855, 54865, 54875, 54885, 54893, 54901, 54909, - 54917, 54925, 54932, 54939, 54946, 54953, 54960, 54968, 54975, 54982, - 54989, 54996, 55003, 55010, 55017, 55024, 55031, 55038, 55046, 55054, - 55062, 55070, 55078, 55086, 55094, 55102, 55110, 55118, 55126, 55134, - 55142, 55150, 55158, 55166, 55174, 55182, 55190, 55198, 55206, 55214, - 55222, 55230, 55237, 55244, 55251, 55258, 55265, 55272, 55279, 55286, - 55293, 55300, 55307, 55314, 55321, 55328, 55335, 55342, 55351, 55358, - 55365, 55372, 55379, 55386, 55396, 55406, 55414, 55422, 55429, 55436, - 55444, 55452, 55459, 55466, 55473, 55480, 55488, 55496, 55503, 55510, - 55517, 55524, 55531, 55540, 55549, 55558, 55567, 55575, 55584, 55592, - 55601, 55609, 55617, 55624, 55632, 55639, 55647, 55654, 55662, 55669, - 55677, 55684, 55693, 55701, 55710, 55718, 55725, 55732, 55739, 55746, - 55754, 55762, 55771, 55780, 55789, 55797, 55806, 55814, 55823, 55831, - 55839, 55846, 55854, 55861, 55869, 55876, 55884, 55891, 55899, 55906, - 55915, 55923, 55932, 55940, 55947, 55954, 55961, 55968, 55976, 55984, - 55993, 56002, 56009, 56016, 56023, 56030, 56037, 56044, 56052, 56059, - 56066, 56073, 56080, 56087, 56094, 56102, 56110, 56118, 56126, 56131, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56136, 56145, 56154, 56163, - 56172, 56181, 56190, 56199, 56208, 56217, 56226, 56235, 56245, 56254, - 56263, 56273, 56282, 56291, 56300, 56309, 56318, 56328, 56338, 56348, - 56357, 56366, 56375, 56384, 56393, 56402, 56411, 56422, 56432, 56442, - 56452, 56462, 56472, 56482, 56492, 56502, 56512, 56523, 56533, 56543, - 56554, 56564, 56574, 56584, 56594, 56603, 56612, 56622, 56631, 56640, - 56649, 56658, 56667, 56676, 56685, 56694, 56703, 56712, 56721, 56730, 0, - 0, 56739, 56748, 56757, 56766, 56775, 56785, 56794, 56803, 56813, 56822, - 56832, 56841, 56850, 56860, 56869, 56879, 56888, 56898, 56907, 56917, - 56926, 56936, 56946, 56956, 56966, 56975, 56985, 56994, 57003, 57012, - 57021, 57030, 57039, 57049, 57058, 57068, 57077, 57087, 57097, 57106, - 57115, 57124, 57134, 57143, 57152, 57161, 57170, 57179, 57189, 57199, - 57209, 57219, 57229, 57238, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 57247, 57262, 57277, 57283, 57289, 57295, 57301, 57307, 57313, 57319, - 57325, 57333, 57337, 0, 0, 0, 57340, 57344, 57348, 57352, 57356, 57360, - 57364, 57368, 57372, 57376, 57380, 57384, 57388, 57392, 57396, 57400, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57404, 57409, 57414, 57420, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57426, 57436, 57446, 57456, 57466, - 57478, 57487, 57496, 57506, 57516, 57528, 57540, 57551, 57562, 57572, - 57582, 57591, 57600, 57610, 57620, 57631, 57642, 57645, 0, 0, 57649, - 57653, 57657, 57661, 57666, 57672, 57678, 57684, 57687, 57691, 0, 57694, - 57697, 57700, 57704, 57708, 57713, 57717, 57721, 57726, 57731, 57738, - 57745, 57748, 57751, 57754, 57758, 57761, 57764, 57767, 0, 57771, 57776, - 57780, 57784, 0, 0, 0, 0, 57789, 57794, 57801, 57806, 57811, 0, 57816, - 57821, 57826, 57831, 57836, 57841, 57846, 57851, 57856, 57861, 57866, - 57871, 57880, 57889, 57897, 57905, 57914, 57923, 57932, 57941, 57949, - 57957, 57965, 57973, 57978, 57983, 57989, 57995, 58001, 58007, 58014, - 58021, 58026, 58031, 58036, 58041, 58047, 58053, 58059, 58065, 58070, - 58075, 58080, 58085, 58090, 58095, 58100, 58105, 58110, 58115, 58120, - 58125, 58131, 58137, 58143, 58149, 58155, 58161, 58167, 58173, 58178, - 58183, 58188, 58193, 58198, 58203, 58208, 58213, 58219, 58225, 58231, - 58237, 58243, 58249, 58255, 58261, 58267, 58273, 58279, 58285, 58291, - 58297, 58303, 58309, 58315, 58321, 58327, 58333, 58339, 58345, 58351, - 58357, 58363, 58369, 58375, 58381, 58387, 58393, 58399, 58405, 58411, - 58417, 58423, 58429, 58434, 58439, 58444, 58449, 58454, 58459, 58464, - 58469, 58474, 58479, 58484, 58489, 58494, 58499, 58504, 58509, 58515, - 58521, 58527, 58533, 58538, 58543, 58548, 58553, 58564, 58575, 58585, - 58595, 58606, 58617, 58624, 0, 0, 58631, 0, 58639, 58643, 58647, 58650, - 58654, 58658, 58661, 58664, 58668, 58672, 58675, 58679, 58682, 58685, - 58688, 58691, 58695, 58698, 58701, 58704, 58707, 58710, 58713, 58716, - 58719, 58722, 58725, 58728, 58731, 58735, 58738, 58742, 58747, 58752, - 58757, 58762, 58767, 58772, 58777, 58782, 58787, 58792, 58797, 58802, - 58807, 58812, 58817, 58822, 58827, 58832, 58837, 58842, 58847, 58852, - 58857, 58862, 58867, 58872, 58877, 58881, 58886, 58890, 58894, 58899, - 58904, 58909, 58914, 58919, 58924, 58929, 58934, 58939, 58944, 58949, - 58954, 58959, 58964, 58969, 58974, 58979, 58984, 58989, 58994, 58999, - 59004, 59009, 59014, 59019, 59024, 59029, 59034, 59039, 59043, 59048, - 59050, 59055, 59060, 59064, 59069, 59074, 59078, 59083, 59088, 59093, - 59098, 59103, 59108, 59113, 59118, 59124, 59130, 59136, 59144, 59148, - 59152, 59156, 59160, 59164, 59168, 59173, 59178, 59183, 59188, 59193, - 59198, 59203, 59208, 59213, 59218, 59223, 59228, 59233, 59237, 59242, - 59247, 59252, 59257, 59262, 59267, 59272, 59277, 59282, 59287, 59291, - 59296, 59301, 59306, 59311, 59315, 59320, 59325, 59330, 59335, 59340, - 59345, 59350, 59355, 59359, 59366, 59373, 59377, 59382, 59387, 59392, - 59397, 59402, 59407, 59412, 59417, 59422, 59427, 59432, 59437, 59442, - 59447, 59452, 59457, 59462, 59467, 59472, 59477, 59482, 59487, 59492, - 59497, 59502, 59507, 59512, 59517, 59522, 0, 0, 0, 59527, 59531, 59536, - 59540, 59545, 59550, 0, 0, 59554, 59559, 59564, 59568, 59573, 59578, 0, - 0, 59583, 59588, 59592, 59597, 59602, 59607, 0, 0, 59612, 59617, 59622, - 0, 0, 0, 59626, 59630, 59634, 59637, 59639, 59643, 59647, 0, 59651, - 59657, 59660, 59663, 59666, 59669, 59673, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 59677, 59683, 59689, 59695, 59701, 0, 0, 59705, 59709, 59714, 59719, - 59724, 59728, 59733, 59738, 59743, 59748, 59752, 59756, 59761, 59766, - 59771, 59776, 59780, 59785, 59790, 59795, 59800, 59805, 59810, 59814, - 59819, 59824, 59829, 59834, 59839, 59844, 59849, 0, 59854, 59858, 59862, - 59867, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59872, 59877, 59882, 59887, - 59892, 59897, 59902, 59907, 59912, 59917, 59922, 59927, 59932, 59937, - 59942, 59947, 59952, 59957, 59962, 59967, 59972, 59977, 59982, 59987, - 59992, 59997, 60002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60009, 60014, - 60019, 60024, 60030, 60035, 60041, 60046, 60051, 60056, 60062, 60067, - 60073, 60078, 60083, 60088, 60093, 60097, 60102, 60107, 60112, 60117, - 60122, 60127, 60132, 60137, 60142, 60147, 60152, 60157, 60162, 60167, - 60172, 60177, 60182, 60187, 60192, 60197, 0, 0, 60202, 60207, 60212, - 60217, 60223, 60228, 60234, 60239, 60244, 60249, 60255, 60260, 60266, - 60271, 60276, 60281, 60286, 60290, 60295, 60300, 60305, 60310, 60315, - 60320, 60325, 60330, 60335, 60340, 60345, 60350, 60355, 60360, 60365, - 60370, 60375, 60380, 60385, 60390, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60395, - 60400, 60405, 60410, 60417, 60424, 60431, 60438, 60443, 60448, 60453, - 60458, 60465, 60470, 60477, 60484, 60489, 60494, 60499, 60506, 60511, - 60516, 60523, 60530, 60535, 60540, 60545, 60552, 60559, 60566, 60571, - 60576, 60583, 60590, 60597, 60604, 60609, 60614, 60619, 60626, 60631, - 60636, 60641, 60648, 60657, 60664, 60669, 60674, 60679, 60684, 60689, - 60694, 60703, 60710, 60715, 60722, 60729, 60734, 60739, 60744, 60751, - 60756, 60763, 60770, 60775, 60780, 60785, 60792, 60799, 60804, 60809, - 60816, 60823, 60830, 60835, 60840, 60845, 60850, 60857, 60866, 60875, - 60880, 60887, 60896, 60901, 60906, 60911, 60916, 60923, 60930, 60937, - 60944, 60949, 60954, 60959, 60966, 60973, 60980, 60985, 60990, 60997, - 61002, 61009, 61014, 61021, 61026, 61033, 61040, 61045, 61050, 61055, - 61060, 61065, 61070, 61075, 61080, 61085, 61092, 61099, 61106, 61113, - 61120, 61129, 61134, 61139, 61146, 61153, 61158, 61165, 61172, 61179, - 61186, 61193, 61200, 61205, 61210, 61215, 61220, 61225, 61234, 61243, - 61252, 61261, 61270, 61279, 61288, 61297, 61302, 61313, 61324, 61333, - 61338, 61343, 61348, 61353, 61362, 61369, 61376, 61383, 61390, 61397, - 61404, 61413, 61422, 61433, 61442, 61453, 61462, 61469, 61478, 61489, - 61498, 61507, 61516, 61525, 61532, 61539, 61546, 61555, 61564, 61575, - 61584, 61593, 61604, 61609, 61614, 61625, 61634, 61643, 61652, 61661, - 61672, 61681, 61690, 61701, 61712, 61723, 61734, 61745, 61756, 61763, - 61770, 61777, 61784, 61794, 61803, 61810, 61817, 61824, 61835, 61846, - 61857, 61868, 61879, 61890, 61901, 61912, 61919, 61926, 61935, 61944, - 61951, 61958, 61965, 61974, 61983, 61992, 61999, 62008, 62017, 62026, - 62033, 62040, 62045, 62052, 62059, 62066, 62073, 62080, 62087, 62094, - 62103, 62112, 62121, 62130, 62137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62146, - 62152, 62157, 62162, 62169, 62175, 62180, 62186, 62192, 62198, 62204, - 62210, 62214, 62218, 62224, 62230, 62236, 62240, 62245, 62250, 62254, - 62258, 62261, 62267, 62273, 62279, 62285, 62291, 62297, 62303, 62309, - 62315, 62325, 62335, 62341, 62347, 62357, 62367, 62373, 0, 0, 0, 62379, - 62384, 62389, 62395, 62401, 62407, 62413, 62419, 62425, 62433, 62441, - 62447, 62453, 62459, 62465, 62471, 62477, 62483, 62489, 62494, 62500, - 62506, 62512, 62518, 62524, 62534, 62540, 62546, 62553, 62560, 62567, - 62576, 62585, 62594, 62603, 62612, 62621, 62630, 62639, 62649, 62659, - 62667, 62675, 62684, 62693, 62699, 62705, 62711, 62717, 62725, 62733, - 62736, 62742, 62747, 62753, 62759, 62765, 62771, 62777, 62787, 62792, - 62799, 62804, 62809, 62814, 62820, 62826, 62832, 62838, 62843, 62848, - 62853, 62858, 62863, 62869, 62875, 62881, 62887, 62893, 62899, 62905, - 62911, 62916, 62921, 62926, 62931, 62936, 62941, 62946, 62951, 62957, - 62963, 62968, 62973, 62978, 62983, 62988, 62994, 63001, 63005, 63009, - 63012, 63016, 63020, 63024, 63028, 63032, 63040, 63050, 63054, 63058, - 63064, 63070, 63076, 63082, 63088, 63094, 63100, 63106, 63112, 63118, - 63124, 63130, 63136, 63142, 63146, 63150, 63157, 63163, 63169, 63175, - 63180, 63187, 63192, 63198, 63204, 63210, 63216, 63221, 63225, 63231, - 63235, 63239, 63243, 63249, 63255, 63259, 63265, 63271, 63277, 63283, - 63289, 63297, 63305, 63311, 63317, 63323, 63329, 63341, 63353, 63367, - 63379, 63391, 63405, 63419, 63433, 63437, 63445, 63453, 63457, 63461, - 63465, 63469, 63473, 63477, 63481, 63485, 63491, 63497, 63503, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 63509, 63513, 63517, 63521, 63525, 63529, 63533, - 63537, 63541, 63545, 63549, 63553, 63557, 63561, 63565, 63569, 63573, - 63577, 63581, 63585, 63589, 63593, 63597, 63601, 63605, 63609, 63613, - 63617, 63621, 63625, 63629, 63633, 63637, 63641, 63645, 63649, 63653, - 63657, 63661, 63665, 63669, 63673, 63677, 63681, 63685, 63689, 63693, - 63697, 63701, 63705, 63709, 63713, 63717, 63721, 63725, 63729, 63733, - 63737, 63741, 63745, 63749, 63753, 63757, 63761, 63765, 63769, 63773, - 63777, 63781, 63785, 63789, 63793, 63797, 63801, 63805, 63809, 63813, - 63817, 63821, 63825, 63829, 63833, 63837, 63841, 63845, 0, 63849, 63853, - 63857, 63861, 63865, 63869, 63873, 63877, 63881, 63885, 63889, 63893, - 63897, 63901, 63905, 63909, 63913, 63917, 63921, 63926, 63931, 63936, - 63941, 63946, 63951, 63956, 63961, 63966, 63971, 63976, 63981, 63986, - 63991, 63996, 64001, 64006, 64011, 64016, 64021, 64026, 64031, 64036, - 64041, 64046, 64051, 64056, 64061, 64066, 64071, 64076, 64081, 64086, - 64091, 64096, 64101, 64106, 64111, 64116, 64121, 64126, 64131, 64136, - 64141, 64146, 64151, 64156, 64161, 64166, 64171, 64176, 64181, 0, 64185, - 64189, 0, 0, 64193, 0, 0, 64197, 64201, 0, 0, 64205, 64209, 64213, 64217, - 0, 64221, 64225, 64229, 64233, 64237, 64241, 64245, 64249, 64253, 64257, - 64261, 64265, 0, 64269, 0, 64273, 64277, 64281, 64285, 0, 64289, 64293, - 0, 64297, 64301, 64305, 64309, 64313, 64317, 64321, 64325, 64329, 64333, - 64337, 64341, 64346, 64351, 64356, 64361, 64366, 64371, 64376, 64381, - 64386, 64391, 64396, 64401, 64406, 64411, 64416, 64421, 64426, 64431, - 64436, 64441, 64446, 64451, 64456, 64461, 64466, 64471, 64476, 64481, - 64486, 64491, 64496, 64501, 64506, 64511, 64516, 64521, 64526, 64531, - 64536, 64541, 64546, 64551, 64556, 64561, 64566, 64571, 64576, 64581, - 64586, 64591, 64596, 64601, 64605, 0, 64609, 64613, 64617, 64621, 0, 0, - 64625, 64629, 64633, 64637, 64641, 64645, 64649, 64653, 0, 64657, 64661, - 64665, 64669, 64673, 64677, 64681, 0, 64685, 64689, 64693, 64697, 64701, - 64705, 64709, 64713, 64717, 64721, 64725, 64729, 64733, 64737, 64741, - 64745, 64749, 64753, 64757, 64761, 64765, 64769, 64773, 64777, 64781, - 64785, 64789, 64793, 0, 64797, 64801, 64805, 64809, 0, 64813, 64817, - 64821, 64825, 64829, 0, 64833, 0, 0, 0, 64837, 64841, 64845, 64849, - 64853, 64857, 64861, 0, 64865, 64869, 64873, 64877, 64881, 64885, 64889, - 64893, 64897, 64901, 64905, 64909, 64913, 64917, 64921, 64925, 64929, - 64933, 64937, 64941, 64945, 64949, 64953, 64957, 64961, 64965, 64969, - 64974, 64979, 64984, 64989, 64994, 64999, 65004, 65009, 65014, 65019, - 65024, 65029, 65034, 65039, 65044, 65049, 65054, 65059, 65064, 65069, - 65074, 65079, 65084, 65089, 65094, 65099, 65104, 65109, 65114, 65119, - 65124, 65129, 65134, 65139, 65144, 65149, 65154, 65159, 65164, 65169, - 65174, 65179, 65184, 65189, 65194, 65199, 65204, 65209, 65214, 65219, - 65224, 65229, 65233, 65237, 65241, 65245, 65249, 65253, 65257, 65261, - 65265, 65269, 65273, 65277, 65281, 65285, 65289, 65293, 65297, 65301, - 65305, 65309, 65313, 65317, 65321, 65325, 65329, 65333, 65337, 65341, - 65345, 65349, 65353, 65357, 65361, 65365, 65369, 65373, 65377, 65381, - 65385, 65389, 65393, 65397, 65401, 65405, 65409, 65413, 65417, 65421, - 65425, 65429, 65433, 65437, 65442, 65447, 65452, 65457, 65462, 65467, - 65472, 65477, 65482, 65487, 65492, 65497, 65502, 65507, 65512, 65517, - 65522, 65527, 65532, 65537, 65542, 65547, 65552, 65557, 65562, 65567, - 65572, 65577, 65582, 65587, 65592, 65597, 65602, 65607, 65612, 65617, - 65622, 65627, 65632, 65637, 65642, 65647, 65652, 65657, 65662, 65667, - 65672, 65677, 65682, 65687, 65692, 65697, 65702, 65707, 65712, 65717, - 65722, 65727, 65732, 65737, 65742, 65747, 65752, 65757, 65762, 65767, - 65772, 65777, 65782, 65787, 65792, 65797, 65802, 65807, 65812, 65817, - 65822, 65827, 65832, 65837, 65842, 65847, 65852, 65857, 65862, 65867, - 65872, 65877, 65882, 65887, 65892, 65897, 65902, 65907, 65912, 65917, - 65922, 65927, 65932, 65937, 65942, 65947, 65952, 65957, 65963, 65969, - 65975, 65981, 65987, 65993, 65999, 66005, 66011, 66017, 66023, 66029, - 66035, 66041, 66047, 66053, 66059, 66065, 66071, 66077, 66083, 66089, - 66095, 66101, 66107, 66113, 66119, 66125, 66131, 66137, 66143, 66149, - 66155, 66161, 66167, 66173, 66179, 66185, 66191, 66197, 66203, 66209, - 66215, 66221, 66227, 66233, 66239, 66245, 66251, 66257, 66263, 66269, - 66273, 66277, 66281, 66285, 66289, 66293, 66297, 66301, 66305, 66309, - 66313, 66317, 66321, 66325, 66329, 66333, 66337, 66341, 66345, 66349, - 66353, 66357, 66361, 66365, 66369, 66373, 66377, 66381, 66385, 66389, - 66393, 66397, 66401, 66405, 66409, 66413, 66417, 66421, 66425, 66429, - 66433, 66437, 66441, 66445, 66449, 66453, 66457, 66461, 66465, 66469, - 66473, 0, 0, 0, 0, 66477, 66482, 66487, 66492, 66497, 66502, 66507, - 66512, 66517, 66522, 66527, 66532, 66537, 66542, 66547, 66552, 66557, - 66562, 66568, 66573, 66578, 66583, 66588, 66593, 66598, 66603, 66607, - 66612, 66617, 66622, 66627, 66632, 66637, 66642, 66647, 66652, 66657, - 66662, 66667, 66672, 66677, 66682, 66687, 66692, 66698, 66703, 66708, - 66713, 66718, 66723, 66728, 66733, 66739, 66744, 66749, 66754, 66759, - 66764, 66769, 66774, 66779, 66784, 66789, 66794, 66799, 66804, 66809, - 66814, 66819, 66824, 66829, 66834, 66839, 66844, 66849, 66854, 66860, - 66865, 66870, 66875, 66880, 66885, 66890, 66895, 66899, 66904, 66909, - 66914, 66919, 66924, 66929, 66934, 66939, 66944, 66949, 66954, 66959, - 66964, 66969, 66974, 66979, 66984, 66990, 66995, 67000, 67005, 67010, - 67015, 67020, 67025, 67031, 67036, 67041, 67046, 67051, 67056, 67061, - 67067, 67073, 67079, 67085, 67091, 67097, 67103, 67109, 67115, 67121, - 67127, 67133, 67139, 67145, 67151, 67157, 67163, 67170, 67176, 67182, - 67188, 67194, 67200, 67206, 67212, 67217, 67223, 67229, 67235, 67241, - 67247, 67253, 67259, 67265, 67271, 67277, 67283, 67289, 67295, 67301, - 67307, 67313, 67319, 67326, 67332, 67338, 67344, 67350, 67356, 67362, - 67368, 67375, 67381, 67387, 67393, 67399, 67405, 67411, 67417, 67423, - 67429, 67435, 67441, 67447, 67453, 67459, 67465, 67471, 67477, 67483, - 67489, 67495, 67501, 67507, 67513, 67520, 67526, 67532, 67538, 67544, - 67550, 67556, 67562, 67567, 67573, 67579, 67585, 67591, 67597, 67603, - 67609, 67615, 67621, 67627, 67633, 67639, 67645, 67651, 67657, 67663, - 67669, 67676, 67682, 67688, 67694, 67700, 67706, 67712, 67718, 67725, - 67731, 67737, 67743, 67749, 67755, 67761, 67768, 67775, 67782, 67789, - 67796, 67803, 67810, 67817, 67824, 67831, 67838, 67845, 67852, 67859, - 67866, 67873, 67880, 67888, 67895, 67902, 67909, 67916, 67923, 67930, - 67937, 67943, 67950, 67957, 67964, 67971, 67978, 67985, 67992, 67999, - 68006, 68013, 68020, 68027, 68034, 68041, 68048, 68055, 68062, 68070, - 68077, 68084, 68091, 68098, 68105, 68112, 68119, 68127, 68134, 68141, - 68148, 68155, 68162, 0, 0, 0, 0, 68169, 68174, 68178, 68182, 68186, - 68190, 68194, 68198, 68202, 68206, 68210, 68215, 68219, 68223, 68227, - 68231, 68235, 68239, 68243, 68247, 68251, 68256, 68260, 68264, 68268, - 68272, 68276, 68280, 68284, 68288, 68292, 68298, 68303, 68308, 68313, - 68318, 68323, 68328, 68333, 68338, 68343, 68348, 68352, 68356, 68360, - 68364, 68368, 68372, 68376, 68380, 68384, 68388, 68392, 68396, 68400, - 68404, 68408, 68412, 68416, 68420, 68424, 68428, 68432, 68436, 68440, - 68444, 68448, 68452, 68456, 68460, 68464, 68468, 68472, 68476, 68480, - 68484, 68488, 68492, 68496, 68500, 68504, 68508, 68512, 68516, 68520, - 68524, 68528, 68532, 68536, 68540, 68544, 68548, 68552, 68556, 68560, - 68564, 68568, 68572, 68576, 68580, 68584, 68588, 68592, 68596, 68600, - 68604, 68608, 68612, 68616, 68620, 68624, 68628, 68632, 68636, 68640, - 68644, 68648, 68652, 68656, 68660, 68664, 68668, 68672, 68676, 68680, - 68684, 68688, 68692, 68696, 68700, 68704, 68708, 68712, 68716, 68720, - 68724, 68728, 68732, 68736, 68740, 68744, 68748, 68752, 68756, 68760, - 68764, 68768, 68772, 68776, 68780, 68784, 68788, 68792, 68796, 68800, - 68804, 68808, 68812, 68816, 68820, 68824, 68828, 68832, 68836, 68840, - 68844, 68848, 68852, 68856, 68860, 68864, 68868, 68872, 68876, 68880, - 68884, 68888, 68892, 68896, 68900, 68904, 68908, 68912, 68916, 68920, - 68924, 68928, 68932, 68936, 68940, 68944, 68948, 68952, 68956, 68960, - 68964, 68968, 68972, 68976, 68980, 68984, 68988, 68992, 68996, 69000, - 69004, 69008, 69012, 69016, 69020, 69024, 69028, 69032, 69036, 69040, - 69044, 69048, 69052, 69056, 69060, 69064, 69068, 69072, 69076, 69080, - 69084, 69088, 69092, 69096, 69100, 69104, 69108, 69112, 69116, 69120, - 69124, 69128, 69132, 69136, 69140, 69144, 69148, 69152, 69156, 69160, - 69164, 69168, 69172, 69176, 69180, 69184, 69188, 69192, 69196, 69200, - 69204, 69208, 69212, 69216, 69220, 69224, 69228, 69232, 69236, 69240, - 69244, 69248, 69252, 69256, 69260, 69264, 69268, 69272, 69276, 69280, - 69284, 69288, 69292, 69296, 69300, 69304, 69308, 69312, 69316, 69320, - 69324, 69328, 69332, 69336, 69340, 69344, 69348, 69352, 69356, 69360, - 69364, 69368, 69372, 69376, 69380, 69384, 69388, 69392, 69396, 69400, - 69404, 69408, 69412, 69416, 69420, 69424, 69428, 69432, 69436, 69440, - 69444, 69448, 69452, 69456, 69460, 69464, 69468, 69472, 69476, 69480, - 69484, 69488, 69492, 69496, 69500, 69504, 69508, 69512, 69516, 69520, - 69524, 69528, 69532, 69536, 69540, 69544, 69548, 69552, 69556, 69560, - 69564, 69568, 69572, 69576, 69580, 69584, 69588, 69592, 69596, 69600, - 69604, 69608, 69612, 69616, 69620, 69624, 69628, 69632, 69636, 69640, - 69644, 69648, 69652, 69656, 69660, 69664, 69668, 69672, 69676, 69680, - 69684, 69688, 69692, 69696, 69700, 69704, 69708, 69712, 69716, 69720, - 69724, 69728, 69732, 69736, 69740, 69744, 69748, 69752, 69756, 69760, - 69764, 69768, 69772, 69776, 69780, 69784, 69788, 69792, 69796, 69800, - 69804, 69808, 69812, 69816, 69820, 69824, 69828, 69832, 69836, 69840, - 69844, 69848, 69852, 69856, 69860, 69864, 69868, 69872, 69876, 69880, - 69884, 69888, 69892, 69896, 69900, 69904, 69908, 69912, 69916, 69920, - 69924, 69928, 69932, 69936, 69940, 69944, 69948, 69952, 69956, 69960, - 69964, 69968, 69972, 69976, 69980, 69984, 69988, 69992, 69996, 70000, - 70004, 70008, 70012, 70016, 70020, 70024, 70028, 70032, 70036, 70040, - 70044, 70048, 70052, 70056, 70060, 70064, 70068, 70072, 70076, 70080, - 70084, 70088, 70092, 70096, 70100, 70104, 70108, 70112, 70116, 70120, - 70124, 70128, 70132, 70136, 70140, 70144, 70148, 70152, 70156, 70160, - 70164, 70168, 70172, 70176, 70180, 70184, 70188, 70192, 70196, 70200, - 70204, 70208, 70212, 70216, 70220, 70224, 70228, 70232, 70236, 70240, - 70244, 70248, 70252, 70256, 70260, 70264, 70268, 70272, 70276, 70280, - 70284, 70288, 70292, 70296, 70300, 70304, 70308, 70312, 70316, 70320, - 70324, 70328, 70332, 70336, 70340, 70344, 70348, 70352, 70356, 70360, - 70364, 70368, 70372, 70376, 70380, 70384, 70388, 70392, 70396, 70400, - 70404, 70408, 70412, 70416, 70420, 70424, 70428, 70432, 70436, 70440, - 70444, 70448, 70452, 70456, 70460, 70464, 70468, 70472, 70476, 70480, - 70484, 70488, 70492, 70496, 70500, 70504, 70508, 70512, 70516, 70520, - 70524, 70528, 70532, 70536, 70540, 70544, 70548, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 70552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70556, 70559, 70563, 70567, 70570, - 70574, 70578, 70581, 70584, 70588, 70592, 70595, 70599, 70602, 70605, - 70608, 70611, 70615, 70618, 70621, 70624, 70627, 70630, 70633, 70636, - 70639, 70642, 70645, 70648, 70651, 70655, 70658, 70662, 70667, 70672, - 70677, 70682, 70687, 70692, 70697, 70702, 70707, 70712, 70717, 70722, - 70727, 70732, 70737, 70742, 70747, 70752, 70757, 70762, 70767, 70772, - 70777, 70782, 70787, 70792, 70797, 70801, 70806, 70810, 70814, 70819, - 70824, 70829, 70834, 70839, 70844, 70849, 70854, 70859, 70864, 70869, - 70874, 70879, 70884, 70889, 70894, 70899, 70904, 70909, 70914, 70919, - 70924, 70929, 70934, 70939, 70944, 70949, 70954, 70959, 70963, 70968, - 70970, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -/* name->code dictionary */ -static unsigned int code_hash[] = { - 0, 4851, 118860, 0, 0, 66306, 7929, 64584, 9518, 64710, 0, 42166, 0, - 1097, 0, 12064, 41730, 596, 8570, 0, 120216, 8651, 41728, 41721, 41835, - 12995, 41202, 1373, 0, 13110, 5816, 119067, 64810, 1000, 0, 11951, 41140, - 1209, 9717, 0, 0, 1073, 0, 65470, 41138, 8851, 0, 0, 12167, 1115, 8874, - 9794, 194660, 0, 0, 12237, 3966, 41603, 8308, 9290, 120763, 41600, 9231, - 120183, 2959, 1457, 3535, 0, 42179, 63860, 41538, 12927, 8618, 42175, - 3404, 64661, 5148, 41737, 1759, 0, 119974, 0, 118949, 12290, 66577, - 120019, 9860, 12312, 10151, 8205, 0, 5131, 0, 9627, 0, 9834, 3055, 9852, - 1944, 1248, 10148, 63884, 119990, 119991, 12701, 119204, 12235, 603, 0, - 65327, 119998, 65305, 120000, 3350, 66576, 64318, 0, 8154, 3390, 120007, - 41817, 119956, 64603, 66328, 120012, 120013, 3400, 120015, 6041, 65020, - 41899, 119879, 8002, 8562, 4364, 0, 4043, 8712, 119988, 7813, 119117, - 120759, 10124, 11966, 8601, 6069, 10143, 4814, 12041, 1418, 10885, 12673, - 0, 0, 9660, 2764, 13012, 4571, 5704, 0, 119946, 12078, 2970, 5457, 5440, - 8857, 0, 0, 2843, 5355, 41599, 118883, 119175, 5194, 12950, 0, 3486, - 65324, 194602, 10123, 65167, 0, 10717, 64570, 2637, 64629, 8460, 10682, - 8476, 10602, 800, 0, 120583, 194632, 7799, 64930, 0, 8465, 12289, 0, - 2384, 13172, 13119, 8488, 5412, 10906, 1353, 0, 41351, 41823, 5828, 8206, - 120674, 8933, 1601, 9072, 5867, 13302, 12458, 0, 8090, 5418, 12452, 0, - 9483, 3351, 917544, 64510, 10817, 0, 41539, 2750, 0, 556, 41855, 41246, - 0, 12213, 0, 2760, 10620, 0, 12210, 120743, 0, 5498, 9998, 41536, 0, 0, - 9242, 3459, 8997, 0, 0, 194888, 0, 0, 4839, 12604, 0, 4435, 119016, 4975, - 4635, 295, 120026, 195039, 6050, 64898, 0, 7688, 0, 63903, 9036, 63901, - 0, 3971, 118975, 0, 2952, 917618, 6287, 8031, 2725, 63899, 63898, 5482, - 667, 12332, 1177, 6086, 12322, 12069, 5172, 41617, 64102, 7859, 1945, - 64099, 9815, 10453, 63883, 63882, 7997, 8555, 63878, 63877, 8705, 64097, - 64096, 9571, 528, 0, 0, 12132, 41723, 63875, 41578, 63873, 63855, 63854, - 41913, 9056, 0, 6188, 64593, 6155, 10806, 446, 41911, 64065, 41318, - 63850, 63, 64069, 63846, 2972, 9455, 63843, 64064, 63849, 63848, 63847, - 1176, 0, 8302, 9577, 63842, 4178, 13208, 13188, 10948, 10041, 8105, 4333, - 0, 118983, 1105, 4180, 5388, 12094, 120165, 0, 7714, 63890, 63889, 7768, - 5538, 9987, 0, 118932, 1678, 917611, 552, 9560, 64077, 10785, 8996, - 12280, 4471, 119112, 9159, 10171, 63861, 10486, 5540, 63858, 63865, 281, - 63863, 12075, 42041, 0, 5174, 0, 63857, 1388, 3123, 0, 1077, 13272, 8408, - 64704, 194821, 0, 9223, 0, 65318, 0, 194822, 42105, 1116, 13274, 194972, - 3663, 0, 1112, 119122, 8686, 8881, 5334, 42108, 0, 64092, 64091, 9322, 0, - 120595, 64095, 5327, 8111, 63870, 63869, 3478, 63867, 6199, 2903, 0, - 3001, 1158, 8745, 64081, 4741, 63866, 4737, 4370, 4846, 0, 4742, 41335, - 4118, 1797, 64600, 805, 120130, 46, 65101, 8760, 298, 118987, 12212, - 120123, 65174, 63836, 32, 5965, 0, 0, 12225, 3665, 63837, 64793, 65330, - 41336, 4305, 66360, 8083, 0, 119938, 63821, 4412, 63819, 63818, 12244, - 5227, 9047, 12702, 4181, 4752, 63975, 4634, 560, 5643, 8226, 6181, 63812, - 41181, 63810, 63790, 3639, 63815, 10122, 63813, 6047, 7937, 63974, 780, - 206, 0, 4936, 65147, 1098, 63930, 0, 1093, 41729, 3016, 4869, 63932, - 917554, 63929, 3546, 1605, 0, 6182, 0, 65058, 8400, 41533, 63920, 0, - 5471, 2984, 5314, 9287, 5473, 44, 0, 195075, 13169, 5290, 5283, 1695, - 63827, 1088, 5961, 8304, 1084, 1085, 63829, 1083, 10131, 5576, 0, 64405, - 4263, 1092, 4754, 8947, 5252, 0, 65253, 64938, 0, 7908, 120622, 120719, - 120673, 0, 2965, 0, 8808, 0, 1089, 7761, 41641, 42119, 12355, 65204, 940, - 5787, 9992, 63938, 5057, 64679, 12463, 2994, 5054, 41694, 0, 9664, 41026, - 1437, 9399, 658, 3497, 12920, 0, 660, 5060, 666, 9022, 5532, 118951, - 5533, 5059, 4727, 6118, 222, 979, 3884, 12459, 65154, 5773, 978, 120748, - 120690, 41619, 10239, 12465, 0, 194863, 64411, 63946, 1707, 0, 12461, - 63895, 63949, 63948, 63947, 3376, 6038, 63943, 63942, 63894, 65323, 0, - 65508, 7776, 64278, 2379, 8703, 917591, 64668, 801, 8125, 1690, 63919, - 63918, 63917, 2369, 0, 12844, 0, 119235, 5486, 2334, 64893, 4463, 5483, - 10207, 0, 2367, 5484, 63909, 264, 2375, 8060, 6194, 5485, 1844, 119084, - 9061, 5534, 10672, 4502, 0, 253, 0, 1823, 8800, 10746, 64470, 0, 11957, - 6192, 0, 0, 118942, 0, 725, 4550, 13257, 120800, 118944, 12892, 0, 0, - 41775, 8413, 0, 0, 5693, 10397, 0, 13209, 5074, 5073, 0, 8983, 0, 119183, - 66586, 5072, 63982, 6198, 12478, 917609, 196, 66608, 3111, 64725, 4929, - 12445, 0, 0, 0, 66606, 64942, 1076, 0, 1436, 4934, 64415, 41323, 9758, 0, - 12807, 63907, 63906, 4548, 4329, 6113, 4979, 3048, 4423, 41320, 0, 10515, - 6218, 8971, 5071, 0, 3642, 1430, 5070, 10042, 120606, 3987, 5068, 120483, - 3255, 3493, 0, 8905, 10735, 120217, 41635, 3378, 4531, 1245, 9105, 66311, - 4921, 4481, 3771, 194649, 2710, 41693, 0, 41724, 64709, 41682, 41690, - 120790, 4922, 325, 992, 0, 4925, 10914, 0, 9526, 4920, 65262, 948, 10783, - 120208, 4930, 917570, 4462, 194855, 4933, 5339, 6115, 120210, 4928, - 917603, 4457, 0, 65290, 42163, 722, 5684, 8678, 12637, 0, 5689, 8753, - 1509, 120617, 5468, 9511, 195043, 65183, 1672, 6205, 5832, 6310, 5686, 0, - 120818, 0, 0, 0, 50, 0, 41607, 120115, 1679, 120116, 10759, 120113, 0, - 3183, 13259, 4448, 119225, 401, 119139, 120109, 64763, 5761, 342, 8553, - 1151, 8143, 0, 11983, 64384, 624, 120715, 65500, 0, 5078, 12501, 5656, 0, - 5076, 118870, 8812, 0, 41601, 685, 9025, 1524, 8003, 194714, 5539, 8087, - 12971, 120101, 120094, 1252, 0, 194612, 4636, 0, 118985, 8053, 9732, 0, - 5080, 13121, 5036, 5035, 120590, 12277, 119187, 195042, 8074, 275, 13084, - 194594, 8741, 4432, 120610, 5033, 120668, 64605, 4836, 3888, 473, 0, - 8502, 120250, 120681, 1087, 12499, 0, 63844, 12496, 3601, 1922, 194626, - 64965, 65422, 12502, 194624, 12505, 66321, 0, 9489, 0, 3432, 4384, - 917548, 6094, 0, 8815, 13295, 64753, 0, 1676, 1154, 3857, 1205, 5030, 0, - 13100, 12958, 10519, 9622, 0, 64723, 4421, 10592, 0, 495, 0, 10544, 7983, - 118882, 10749, 119835, 8494, 13297, 10979, 41710, 947, 0, 437, 41709, - 10969, 119935, 119934, 9465, 13290, 4795, 119930, 64306, 8826, 120181, - 41714, 120611, 8626, 4590, 4711, 120769, 120195, 2739, 119918, 8044, - 40964, 251, 12686, 7895, 4395, 119927, 119926, 119929, 1779, 8146, - 119922, 41543, 5325, 642, 120753, 8880, 7685, 194653, 0, 6234, 13229, - 625, 8187, 9990, 1113, 194643, 7915, 1104, 120176, 8179, 10655, 0, 9316, - 10980, 2489, 1082, 8150, 1359, 194645, 0, 0, 0, 5042, 5041, 0, 12084, - 8049, 41548, 0, 40962, 0, 0, 4761, 10506, 4766, 1616, 1273, 0, 8795, - 118876, 0, 63957, 9232, 1138, 10483, 12677, 41545, 12881, 3239, 0, 0, - 66614, 194582, 42128, 3484, 64545, 194801, 12620, 8503, 5122, 41527, - 5040, 4924, 194913, 0, 120535, 0, 5039, 41926, 8303, 0, 5038, 0, 10003, - 0, 917543, 120586, 1686, 0, 9359, 66609, 3664, 0, 8238, 64299, 0, 0, - 3863, 126, 4835, 0, 0, 13245, 4309, 7744, 194569, 119902, 194568, 13184, - 0, 0, 12222, 8136, 194987, 711, 1633, 0, 0, 4762, 1103, 194561, 12281, - 4765, 41331, 1006, 13040, 4760, 9461, 8201, 10871, 0, 1102, 5031, 118904, - 194664, 0, 64636, 13042, 337, 194781, 0, 119184, 12279, 1111, 120309, - 194636, 4707, 194635, 5511, 7883, 8822, 7880, 4522, 8255, 5512, 13010, - 119232, 66378, 64313, 194667, 5906, 1119, 120233, 13038, 120639, 2455, - 64734, 13008, 41652, 4385, 12492, 12821, 8714, 64775, 119161, 13009, 160, - 0, 0, 64262, 5052, 64031, 5821, 6186, 41792, 0, 5051, 0, 1429, 64573, - 5050, 302, 388, 12058, 735, 0, 1079, 3867, 5708, 12726, 0, 9117, 5706, - 10679, 5513, 8791, 4005, 0, 5510, 10991, 0, 65458, 2470, 917581, 41399, - 1925, 194805, 917577, 917576, 917571, 5048, 5047, 41532, 10058, 0, - 917569, 9070, 0, 3339, 8089, 1106, 639, 120456, 63967, 3340, 3109, 3653, - 4599, 10799, 917583, 10605, 917585, 1476, 648, 1754, 11001, 3233, 864, - 41782, 10164, 8972, 0, 3530, 9750, 0, 13240, 41781, 5192, 4338, 5046, - 8512, 63770, 13199, 8967, 1236, 5045, 12012, 13189, 7986, 5044, 120556, - 9006, 13128, 5043, 9553, 1590, 63777, 63776, 9669, 12341, 8654, 8402, - 63779, 1583, 4740, 13260, 3586, 13276, 0, 120306, 0, 194661, 41523, - 13296, 517, 12922, 120140, 194658, 41528, 123, 65454, 12393, 63807, - 41997, 10531, 7784, 13271, 1334, 120445, 4479, 1126, 119004, 120663, 0, - 8520, 3925, 0, 8069, 4357, 42154, 489, 120450, 120440, 8848, 63786, 8450, - 120434, 11926, 41557, 1145, 63788, 7910, 63785, 63784, 10456, 8711, 6183, - 8183, 120741, 8928, 0, 7952, 0, 125, 9235, 64861, 0, 12689, 0, 10779, - 10990, 3523, 1074, 13258, 9536, 8477, 0, 4427, 10517, 63757, 7726, 12217, - 41802, 267, 1349, 10713, 1371, 120293, 195070, 2458, 63753, 6201, 41084, - 41074, 4266, 10652, 41612, 41077, 3402, 9050, 3398, 8140, 42084, 6260, - 3391, 41075, 2476, 41956, 11988, 3898, 10625, 10201, 10988, 13017, 63794, - 10367, 12521, 10431, 13014, 13013, 1068, 194806, 12523, 12945, 12524, - 12438, 7950, 10804, 13233, 12082, 4386, 9053, 12473, 2793, 12475, 704, 0, - 6195, 9530, 12238, 12232, 0, 194944, 5681, 12629, 4595, 63760, 792, 0, - 64803, 0, 8742, 0, 64947, 65448, 63744, 12948, 64787, 195002, 63748, - 1693, 63746, 63745, 5055, 0, 4287, 1090, 4902, 1131, 41180, 194721, 4558, - 1816, 9523, 41712, 168, 0, 4898, 64298, 6157, 63775, 4901, 1821, 13191, - 12170, 3500, 3139, 791, 9162, 12485, 10306, 119001, 194945, 0, 64433, - 8354, 10033, 941, 0, 64422, 120185, 0, 8234, 64559, 8228, 8424, 10246, - 194996, 12811, 194998, 3946, 195000, 8057, 0, 673, 194854, 64357, 0, 0, - 9547, 288, 64296, 194976, 2448, 10025, 194981, 2918, 2452, 65300, 41529, - 8729, 64726, 2790, 7845, 3793, 0, 4408, 4122, 0, 41535, 8723, 65178, - 10087, 0, 731, 42109, 12923, 2438, 64855, 65396, 0, 1175, 13256, 1282, - 373, 119172, 5396, 8653, 8557, 7723, 0, 3330, 0, 41952, 0, 5273, 8248, - 5269, 3304, 5202, 2404, 5267, 0, 0, 0, 5277, 12963, 5371, 6189, 4125, - 1826, 12133, 65241, 118873, 8785, 917589, 0, 64643, 9035, 3864, 13185, - 4631, 3879, 118785, 0, 4166, 164, 0, 0, 64484, 0, 10212, 5384, 41882, 0, - 64346, 0, 120098, 0, 41388, 0, 12005, 12666, 41387, 13207, 8706, 5552, - 10172, 700, 5929, 5553, 12978, 194610, 5356, 12906, 8563, 41888, 3180, 0, - 0, 5554, 971, 12344, 8724, 0, 13201, 63874, 0, 2866, 8517, 12446, 13190, - 64632, 120227, 5555, 10045, 12882, 13275, 120672, 41522, 13206, 9143, - 194957, 41525, 120539, 195069, 656, 194614, 65037, 4577, 12229, 8715, 0, - 0, 120261, 4269, 64813, 119163, 41609, 10476, 950, 0, 3932, 41450, 0, 0, - 0, 120014, 11974, 118884, 369, 119096, 41784, 119099, 5097, 194869, 9848, - 0, 10381, 4796, 10317, 3651, 10285, 194616, 10269, 5102, 5101, 120511, - 9064, 8138, 120455, 404, 5100, 1439, 12093, 1247, 8092, 195064, 5099, - 1831, 1441, 4793, 3842, 650, 0, 746, 120784, 195041, 41453, 12018, 9031, - 12182, 120305, 9078, 8545, 4422, 4708, 3799, 3268, 0, 9118, 119127, 2676, - 7750, 4374, 195052, 6190, 1364, 195053, 8038, 195055, 9857, 0, 9858, - 195033, 66585, 12129, 13174, 8481, 12412, 6202, 64380, 10920, 10872, - 2365, 7841, 195038, 5108, 5107, 0, 13210, 6176, 195093, 5541, 41785, - 41171, 12613, 5284, 4372, 207, 0, 4275, 120171, 0, 119147, 0, 12965, 384, - 5103, 10404, 10340, 10702, 0, 488, 13236, 12937, 10017, 9733, 13187, - 10014, 11982, 41373, 13198, 5203, 120517, 13232, 5106, 349, 4863, 41371, - 13194, 41367, 5105, 13133, 12861, 4398, 5104, 5672, 304, 1096, 0, 0, 932, - 12441, 0, 238, 195008, 4318, 10452, 195013, 8032, 13243, 13237, 12719, - 194884, 119059, 64814, 64884, 119872, 10670, 8597, 1178, 64017, 9864, - 13195, 8803, 309, 0, 8151, 10858, 64961, 7722, 12553, 10459, 12568, - 64824, 12549, 66590, 12570, 9712, 41417, 41496, 0, 65165, 4965, 0, 10538, - 0, 41401, 0, 0, 6191, 6261, 0, 0, 11965, 1957, 10420, 982, 2756, 9370, - 2720, 12357, 119260, 2925, 118817, 13056, 3222, 13212, 10116, 41644, - 10105, 10624, 41581, 10834, 118793, 64407, 5242, 41963, 64476, 1694, - 8216, 10814, 0, 7781, 6306, 64568, 0, 120738, 12077, 42057, 41444, 0, - 120325, 64799, 3475, 66566, 2479, 9709, 3632, 120322, 10698, 0, 3648, - 3907, 194963, 194962, 3636, 40979, 2979, 8837, 65229, 1843, 3936, 0, 0, - 41347, 65119, 13235, 3640, 41248, 120579, 4379, 13239, 12692, 7969, - 120120, 66353, 194951, 118908, 120509, 41846, 2529, 734, 10808, 65146, - 42083, 194955, 194954, 42055, 1846, 66367, 12181, 9634, 120310, 9988, - 12991, 1670, 5740, 120317, 10072, 5379, 120318, 41163, 41157, 785, 8236, - 194942, 9027, 63897, 13267, 64383, 64688, 925, 0, 120541, 41773, 41071, - 9586, 120312, 41984, 9217, 6151, 12110, 0, 194901, 64580, 4016, 13265, - 13264, 381, 12936, 6100, 42077, 120768, 5808, 5184, 8200, 12967, 10810, - 5612, 4583, 0, 5860, 120506, 64575, 0, 812, 3615, 65284, 5178, 194929, - 119015, 9825, 5188, 9698, 7814, 194935, 10692, 1166, 64429, 41921, 924, - 9756, 12359, 119258, 0, 2442, 10703, 194940, 194939, 8012, 5674, 0, 0, - 12361, 5677, 0, 0, 40972, 12453, 41920, 5673, 0, 5676, 8542, 12694, - 118978, 2468, 1294, 41294, 3336, 3883, 64388, 1727, 194991, 0, 3605, - 120638, 0, 12034, 8718, 3550, 736, 7806, 4505, 2715, 806, 5826, 41884, - 5813, 0, 65391, 5841, 5837, 64731, 66325, 3105, 2405, 5838, 5796, 0, - 65259, 5793, 5735, 5866, 5797, 1432, 5865, 12143, 7956, 598, 0, 41886, - 2480, 0, 66334, 9037, 5671, 5537, 0, 0, 10932, 0, 1211, 847, 120615, - 9529, 118832, 12318, 194601, 0, 5645, 10622, 41391, 194967, 120033, - 64597, 0, 5650, 120039, 119102, 64864, 194968, 9624, 0, 0, 0, 2748, 3589, - 0, 4035, 10297, 0, 4265, 194969, 3977, 65344, 12051, 836, 5698, 2488, - 194634, 4582, 120713, 5644, 10292, 66627, 8046, 0, 10550, 120081, 65116, - 119206, 120022, 65120, 1374, 64878, 119014, 41013, 10568, 41374, 4030, - 41010, 0, 41015, 120516, 65325, 400, 12597, 120621, 0, 120593, 41375, - 5659, 64827, 4759, 118906, 390, 10266, 41349, 1170, 3473, 7718, 118962, - 1609, 902, 0, 0, 66352, 0, 8122, 5712, 0, 8004, 3861, 9540, 10278, 2554, - 5158, 5714, 41136, 194970, 64351, 807, 0, 194691, 64677, 976, 0, 6146, - 65518, 771, 10954, 41356, 9673, 13168, 0, 41143, 8676, 7904, 5579, 953, - 451, 194585, 5578, 12635, 0, 9724, 0, 0, 9524, 120794, 118789, 1440, - 3379, 10310, 120016, 120722, 471, 0, 0, 3795, 120220, 12586, 10701, 0, - 41060, 10094, 64900, 194959, 10857, 2474, 120640, 9590, 93, 10615, 10213, - 8128, 12551, 10049, 8171, 3544, 0, 6017, 65311, 383, 120223, 13306, - 10533, 7870, 0, 5187, 120711, 1456, 0, 42164, 0, 194702, 5232, 0, 41009, - 2472, 41005, 120699, 8710, 6019, 4256, 120776, 4980, 8860, 9640, 10028, - 12845, 119114, 13182, 65121, 120685, 0, 10631, 65126, 7972, 118928, 8066, - 0, 7900, 8316, 0, 120213, 120555, 0, 120830, 0, 10347, 445, 120566, 0, - 12931, 0, 8330, 0, 0, 0, 64366, 64369, 8814, 3902, 64607, 1770, 0, 12836, - 0, 64552, 0, 4584, 9684, 0, 0, 10866, 0, 1118, 0, 0, 9349, 1081, 120464, - 0, 8162, 9342, 5996, 0, 4903, 64332, 41386, 5162, 41007, 1330, 64486, - 40995, 12209, 12047, 41384, 0, 0, 1848, 4334, 120334, 41975, 64777, - 10674, 5522, 0, 61, 120157, 0, 3633, 917582, 65162, 41234, 12089, 118800, - 9771, 120333, 13251, 41959, 64749, 6262, 2784, 0, 9334, 8126, 0, 64967, - 7975, 441, 194591, 0, 66621, 4884, 40999, 120269, 0, 66314, 6313, 10890, - 0, 119090, 8324, 7855, 2345, 0, 463, 64737, 0, 0, 3117, 5460, 0, 1193, - 10056, 1148, 12396, 13252, 7829, 42173, 0, 7743, 0, 13248, 5499, 120549, - 120557, 9034, 6039, 0, 5663, 119182, 41018, 0, 10338, 2482, 1471, 195027, - 120079, 66370, 12378, 41966, 41970, 0, 12374, 10903, 9592, 0, 911, 2460, - 120499, 11944, 12376, 41032, 40996, 120614, 12380, 5520, 64473, 10869, - 5870, 64670, 13310, 2603, 12326, 539, 0, 65180, 0, 3853, 41327, 64901, - 120796, 0, 10722, 0, 8659, 0, 12474, 0, 5857, 65342, 2478, 119120, 4162, - 7942, 4260, 12953, 119245, 120090, 12470, 0, 0, 2742, 12476, 5439, 10946, - 9101, 12472, 0, 12302, 3018, 12942, 5748, 194895, 10773, 6161, 0, 8796, - 0, 194583, 118986, 8519, 13146, 119954, 42053, 9422, 10333, 2882, 4366, - 0, 12843, 4520, 0, 0, 10648, 0, 4014, 12842, 0, 12015, 13117, 0, 3893, - 66362, 5810, 0, 0, 42147, 64747, 13292, 0, 12938, 10427, 9154, 3844, - 63934, 9755, 1110, 65239, 10892, 8231, 10775, 0, 41968, 783, 12161, 3591, - 41969, 0, 2453, 8518, 3620, 119181, 12443, 4556, 10349, 10413, 0, 41159, - 3202, 119097, 10510, 4382, 0, 0, 10842, 41265, 120088, 8902, 0, 1840, - 41751, 12891, 0, 4883, 285, 4723, 41917, 9788, 4459, 66635, 1634, 41958, - 9155, 240, 9786, 65082, 41919, 8579, 9743, 7981, 13134, 118878, 4508, - 64883, 41999, 120231, 120664, 118885, 63887, 3081, 63886, 120080, 0, 0, - 10445, 41720, 0, 0, 2614, 9024, 64620, 1729, 0, 64289, 65221, 0, 65466, - 64852, 64509, 120235, 63916, 194984, 41203, 0, 41879, 0, 4121, 12957, - 884, 41214, 63879, 4943, 5150, 0, 5278, 7773, 643, 3086, 118912, 64652, - 120068, 58, 0, 6167, 120083, 63872, 8491, 0, 0, 41495, 3624, 0, 0, 64655, - 2721, 9616, 63988, 41955, 41321, 10500, 10440, 9611, 4264, 120077, 0, - 7738, 63986, 63985, 12638, 0, 3435, 3094, 12916, 9754, 66376, 4437, - 41292, 8899, 0, 42058, 9517, 65143, 0, 65360, 0, 119047, 63956, 4306, - 41380, 11995, 63960, 9591, 63958, 10217, 118845, 120657, 120578, 12456, - 2723, 0, 5088, 5086, 0, 0, 7752, 41378, 2880, 0, 0, 2872, 1386, 65034, - 3498, 4378, 65039, 4270, 12392, 65036, 7853, 0, 12101, 5822, 5230, 0, - 710, 0, 12390, 1666, 8161, 371, 12013, 63891, 42092, 119103, 415, 63851, - 63892, 63962, 42096, 5183, 3362, 12377, 7924, 2927, 4324, 63961, 4472, - 1244, 331, 0, 12683, 10662, 64678, 4756, 195017, 119021, 10730, 7691, - 10331, 0, 41964, 6238, 8938, 8628, 6043, 0, 64895, 1604, 9565, 10539, - 120814, 41220, 13032, 120791, 194575, 10032, 8750, 12373, 63828, 11992, - 1351, 0, 8698, 12190, 3622, 1930, 194573, 9621, 12427, 63981, 4967, - 13031, 1966, 2330, 0, 3657, 0, 65202, 6000, 4347, 4416, 42098, 13180, - 10694, 8099, 402, 41916, 13147, 0, 42100, 12429, 9695, 41757, 41281, - 3515, 5170, 65261, 41755, 676, 6259, 41742, 0, 41870, 0, 3536, 0, 41305, - 63902, 6162, 10532, 0, 10113, 41829, 120545, 5159, 12422, 41832, 439, 0, - 194948, 12316, 12481, 2325, 40970, 41830, 194947, 0, 5145, 12486, 65018, - 194723, 5409, 8976, 0, 12336, 4135, 9685, 341, 2727, 4129, 3539, 66616, - 0, 41736, 7913, 5405, 63859, 4131, 41267, 64721, 63871, 4133, 63864, 210, - 4600, 64690, 3254, 4137, 120608, 0, 119062, 0, 0, 4591, 65077, 118982, 0, - 3355, 9508, 3393, 561, 12159, 195, 64261, 3377, 12497, 41269, 0, 13135, - 0, 8368, 119224, 41499, 0, 0, 0, 41498, 0, 1379, 246, 12603, 0, 3788, - 2924, 64587, 12812, 8728, 64906, 119213, 8917, 0, 301, 64765, 3969, - 64964, 9575, 64562, 0, 9652, 0, 64590, 42086, 0, 0, 13163, 0, 41877, - 120443, 3182, 327, 0, 9042, 120298, 0, 42169, 4755, 0, 119882, 13223, - 12431, 8668, 12434, 608, 600, 5999, 1219, 3934, 9494, 0, 0, 1726, 0, - 64686, 8212, 12115, 0, 13160, 7759, 65363, 485, 0, 65291, 9828, 927, - 42102, 194979, 12436, 9351, 7778, 64379, 0, 0, 10126, 1208, 0, 64757, - 9337, 64362, 0, 64535, 120735, 9021, 0, 0, 0, 119237, 5411, 0, 9648, - 64617, 63834, 9150, 63835, 1117, 13037, 2594, 63809, 10691, 12052, 10643, - 41503, 65212, 64536, 2546, 119216, 213, 65309, 10554, 3972, 0, 194678, - 65442, 194677, 12416, 11914, 5452, 8230, 0, 41951, 12418, 42049, 3882, - 8532, 2713, 1573, 9650, 42136, 4596, 66339, 1406, 194682, 40990, 194593, - 12414, 8287, 4143, 194687, 10489, 1143, 4141, 9682, 12415, 1508, 64515, - 8779, 10569, 8725, 120783, 65264, 64487, 119064, 4145, 194761, 194794, - 66613, 0, 8027, 120192, 0, 9550, 0, 0, 194799, 120189, 64070, 10740, - 195020, 64816, 10998, 66333, 12955, 0, 2888, 0, 0, 7715, 3881, 41487, - 12118, 194778, 2878, 5390, 0, 3009, 41476, 41489, 63765, 3007, 1448, - 2975, 10429, 3889, 8521, 5083, 5082, 0, 5235, 803, 194966, 3014, 5081, - 8986, 11002, 10632, 11934, 0, 1332, 64802, 3929, 4597, 65532, 64767, - 9107, 5191, 9288, 9657, 2892, 10577, 6031, 555, 120188, 0, 194927, 12367, - 42170, 13151, 0, 629, 1924, 0, 12037, 0, 5858, 8462, 8005, 12365, 1784, - 1361, 118939, 12369, 7905, 120041, 5077, 194668, 10880, 63927, 5075, - 194973, 9371, 65075, 41193, 11007, 0, 10997, 0, 1342, 0, 0, 3434, 4843, - 4506, 0, 5266, 0, 5272, 4482, 4507, 9578, 63923, 66319, 7979, 64381, - 9831, 64417, 0, 461, 9803, 41972, 4504, 444, 0, 9127, 5276, 64522, 0, - 120179, 0, 64911, 12848, 5177, 41324, 12055, 8722, 120805, 1197, 65512, - 1149, 4114, 409, 4383, 8900, 8948, 7684, 3492, 721, 41191, 9108, 0, 0, - 11954, 119191, 118819, 40963, 3099, 0, 65088, 0, 119834, 12587, 194703, - 0, 12036, 0, 65123, 41576, 8152, 120721, 64428, 12227, 8578, 5995, 12828, - 41575, 2922, 63950, 63944, 120643, 0, 2670, 4167, 0, 65009, 120025, - 65173, 118958, 13023, 938, 0, 0, 0, 9721, 0, 41017, 9606, 12413, 4024, - 41063, 0, 12334, 0, 4153, 11911, 10793, 5250, 12407, 3395, 4404, 0, - 12401, 42007, 5775, 42005, 194739, 119251, 0, 12205, 1344, 8870, 194744, - 4940, 4735, 7683, 1167, 12822, 4983, 0, 63939, 64907, 0, 0, 0, 63896, 0, - 12039, 10559, 11956, 119841, 118892, 9472, 4282, 11929, 0, 12816, 9596, - 0, 12710, 0, 12721, 4101, 0, 0, 5992, 119840, 0, 120280, 1004, 9632, - 120602, 0, 0, 12627, 10953, 0, 6290, 0, 0, 0, 9491, 9686, 5890, 0, 65232, - 12712, 0, 194748, 10718, 13154, 3461, 9139, 64756, 0, 119151, 0, 0, - 13227, 12585, 10565, 119152, 12177, 41708, 12860, 41098, 10015, 10838, - 4900, 10352, 0, 10061, 5903, 4119, 5140, 209, 64002, 41704, 9702, 119100, - 41132, 9245, 13048, 4927, 4138, 41093, 65286, 0, 2410, 993, 194975, - 13054, 12394, 0, 0, 0, 12685, 120011, 119040, 10781, 41230, 0, 0, 1680, - 10507, 118809, 10659, 3600, 13049, 120027, 1336, 41518, 0, 5896, 119838, - 5993, 2819, 64820, 12706, 12966, 41134, 120581, 63915, 0, 8184, 272, - 1363, 8793, 8411, 63908, 41502, 3077, 983, 0, 1512, 0, 1190, 4109, 1335, - 841, 5888, 41358, 9836, 9544, 120820, 41481, 8313, 7832, 118954, 3090, - 2409, 817, 1664, 1850, 120757, 3079, 4731, 10118, 66629, 64541, 12033, - 1255, 12386, 9247, 64350, 66633, 12389, 66610, 0, 41996, 63990, 64936, - 5864, 1147, 63992, 5835, 5328, 66625, 5480, 7858, 41990, 4116, 12391, - 66634, 1094, 194, 12384, 0, 8180, 41686, 12313, 0, 63904, 195018, 6114, - 10898, 0, 64578, 8247, 507, 91, 0, 10695, 0, 12070, 0, 10036, 7857, 6067, - 774, 119829, 2744, 119815, 5994, 12539, 41857, 64321, 8359, 119820, 6028, - 119819, 13167, 0, 7719, 119875, 2486, 7893, 41059, 162, 5436, 0, 119809, - 9687, 64956, 6304, 119078, 6051, 0, 5262, 5904, 0, 12681, 0, 0, 12406, - 12219, 3652, 10537, 0, 10492, 64550, 0, 279, 0, 119978, 64619, 12403, - 1489, 195016, 4132, 4899, 3899, 1007, 42124, 4976, 2343, 4103, 0, 0, - 10750, 1345, 0, 120801, 12859, 8956, 4098, 65267, 5861, 0, 11999, 12151, - 64804, 0, 12645, 5146, 0, 0, 0, 41094, 492, 8685, 12974, 0, 118865, - 41551, 5147, 2582, 0, 64538, 0, 1928, 0, 9594, 5991, 13304, 0, 2527, 0, - 197, 2799, 8241, 0, 119810, 120199, 0, 64958, 0, 5524, 194809, 10138, - 119808, 0, 8897, 119072, 41553, 8357, 4124, 1799, 65371, 42148, 0, 12954, - 194688, 65340, 1123, 963, 2434, 10120, 12405, 195015, 0, 398, 392, 9723, - 7894, 119011, 7945, 64935, 4402, 10896, 12402, 119106, 41880, 8414, - 12408, 120554, 0, 406, 0, 9164, 12411, 0, 4560, 8554, 4961, 0, 1575, - 64682, 5438, 165, 9993, 41467, 63953, 8064, 9093, 9599, 9147, 0, 0, 4987, - 9148, 2399, 4096, 53, 10944, 12368, 65435, 195011, 8178, 64598, 3367, - 12910, 10884, 727, 65272, 0, 5805, 1947, 0, 195022, 42176, 12370, 120397, - 1705, 9331, 8898, 0, 12372, 120642, 195023, 8017, 65287, 8813, 12366, - 10963, 6066, 1329, 4909, 3052, 9220, 120696, 4904, 120274, 10803, 1365, - 9253, 0, 41264, 0, 120712, 0, 119814, 1499, 0, 8055, 0, 8740, 5398, - 63964, 120419, 8924, 0, 5988, 3660, 12017, 64646, 9476, 8788, 1357, - 42113, 0, 3629, 8774, 42114, 0, 3628, 120172, 0, 1933, 3469, 1567, 42116, - 11969, 64809, 2928, 4905, 2487, 4910, 3121, 1804, 3311, 194916, 9114, 0, - 12083, 9315, 4822, 4906, 3852, 2847, 0, 3236, 0, 1251, 7777, 41852, 7951, - 1198, 9132, 0, 12274, 510, 10259, 9865, 0, 4561, 6018, 1398, 0, 12276, - 120683, 41569, 0, 120750, 8167, 12127, 41932, 840, 120300, 2443, 10918, - 10410, 0, 1001, 9241, 1927, 333, 41930, 0, 8144, 8034, 119833, 0, 118828, - 0, 12867, 0, 8260, 7769, 64910, 12621, 65364, 8904, 518, 4764, 0, 41168, - 13204, 4387, 4127, 10530, 65369, 0, 120724, 41044, 0, 0, 9358, 0, 42078, - 5136, 1968, 0, 0, 1337, 10581, 0, 4533, 796, 195001, 0, 0, 12038, 120649, - 12664, 0, 65461, 9798, 6120, 478, 1948, 119007, 10962, 952, 6016, 0, 0, - 9512, 4276, 1206, 3619, 41638, 0, 3843, 8142, 8853, 3361, 41795, 490, - 10715, 3436, 0, 63841, 12817, 9847, 12348, 3930, 12854, 0, 6154, 9551, - 65354, 65346, 784, 65357, 334, 64797, 1453, 65356, 8940, 120329, 8500, - 10428, 10364, 64715, 778, 4317, 10004, 7989, 64676, 3227, 120238, 194654, - 120782, 0, 10855, 13102, 41702, 10309, 9718, 10277, 194958, 120308, - 41624, 5415, 9613, 9001, 4526, 3462, 65215, 64520, 41020, 0, 120042, - 42056, 9759, 64957, 3963, 120304, 8114, 1469, 65445, 65381, 194709, 4988, - 0, 118956, 9598, 904, 352, 0, 1451, 1356, 8453, 4134, 0, 0, 1619, 9703, - 41745, 0, 8575, 119180, 1201, 64732, 12846, 0, 41860, 11919, 64962, - 41550, 5289, 13144, 8511, 9460, 823, 9675, 12305, 5940, 226, 2649, 12387, - 1253, 0, 0, 500, 64521, 9081, 1658, 11936, 64735, 120705, 64660, 63845, - 64784, 9785, 42123, 64783, 194619, 0, 5152, 8935, 41754, 119101, 5304, 0, - 616, 4323, 64666, 4684, 0, 120613, 194912, 65339, 10560, 6048, 4763, - 4112, 118935, 10870, 5260, 9821, 65129, 326, 9681, 4475, 0, 10771, 2876, - 194915, 194833, 6035, 41398, 41192, 9802, 13261, 194880, 453, 41396, - 917564, 13159, 12140, 9572, 65274, 10392, 10328, 40998, 7704, 917542, - 194886, 9800, 4123, 0, 42103, 41000, 7854, 119239, 0, 10977, 64061, - 10344, 9808, 64014, 5394, 4126, 12800, 9521, 9589, 64755, 194917, 4425, - 194897, 10464, 63802, 64769, 1288, 0, 64016, 64024, 12173, 679, 64012, - 194893, 5850, 12049, 118937, 10796, 4474, 10742, 10693, 64006, 1587, - 64005, 0, 120519, 65490, 1369, 12134, 119050, 7927, 0, 1139, 64030, - 64026, 64029, 8970, 64948, 4430, 0, 10774, 4514, 0, 12421, 8194, 0, 1852, - 3057, 65483, 8893, 64032, 12542, 12973, 65341, 120497, 0, 7925, 12423, - 10475, 0, 3496, 1352, 10933, 7707, 9102, 627, 42034, 6158, 8327, 64497, - 0, 6040, 917592, 10129, 64863, 9336, 65451, 5730, 7844, 7798, 64474, - 64259, 1682, 64290, 7820, 119049, 12951, 194906, 7746, 1492, 0, 8288, - 12563, 10728, 5127, 120163, 65509, 5495, 4273, 118922, 9644, 10849, 1833, - 2999, 120612, 64373, 194622, 185, 65085, 6023, 169, 5497, 64611, 8085, 0, - 194850, 194789, 8224, 119010, 1949, 4117, 7847, 120489, 119982, 5321, 0, - 120534, 9313, 2589, 64408, 1689, 7802, 4683, 120502, 120716, 64667, 0, - 1184, 0, 815, 8273, 0, 6049, 120530, 4027, 834, 0, 1803, 64683, 1503, - 8995, 0, 0, 5731, 1381, 2387, 0, 12430, 8289, 10981, 12654, 2881, 65514, - 917600, 9601, 332, 9668, 9766, 5142, 2407, 119221, 0, 6036, 64881, 4026, - 8645, 64789, 2887, 119832, 3526, 6298, 119136, 64475, 4833, 1834, 195095, - 8572, 6021, 10940, 65249, 119848, 8662, 119207, 0, 2652, 10959, 119849, - 10784, 120720, 0, 166, 0, 8635, 9706, 10623, 408, 1828, 0, 13298, 0, - 8531, 8168, 6280, 12324, 8811, 10639, 0, 4832, 64557, 41643, 6279, 12508, - 8713, 10690, 9161, 41645, 1620, 0, 646, 0, 195091, 42129, 609, 119858, - 3472, 8697, 41086, 0, 4343, 6212, 0, 0, 5809, 1950, 239, 119828, 637, - 120048, 41592, 119855, 917539, 120449, 0, 3247, 120754, 12985, 12696, - 119854, 0, 119827, 12929, 10983, 712, 120291, 0, 41567, 0, 0, 0, 119852, - 120793, 119137, 1506, 41565, 0, 4509, 0, 12651, 12216, 64628, 40988, - 11961, 120626, 41727, 7803, 64341, 2396, 42036, 118844, 0, 120264, 355, - 9719, 3886, 9814, 63912, 0, 65444, 996, 42075, 64880, 917578, 65199, - 194810, 8655, 8222, 0, 7939, 10342, 917574, 3178, 917590, 0, 5907, 42071, - 3976, 0, 42161, 0, 5833, 12561, 12555, 5969, 5699, 12562, 12550, 9488, - 40982, 8489, 0, 1488, 0, 13149, 0, 9799, 5265, 66612, 1563, 119091, 9619, - 12464, 0, 917557, 119842, 64508, 5803, 7797, 6070, 10006, 64919, 465, - 6082, 13078, 9692, 194745, 12567, 8116, 795, 0, 7843, 12462, 3607, 12715, - 10046, 9612, 42153, 8218, 9485, 120811, 0, 12468, 8607, 1008, 65322, - 3306, 120321, 65138, 6057, 508, 0, 1766, 119074, 11996, 1820, 4547, 0, - 638, 6083, 120265, 12308, 0, 2305, 0, 0, 9470, 6056, 10878, 65236, 4818, - 6085, 0, 65207, 3915, 41634, 5382, 41639, 0, 6235, 119060, 4028, 1787, - 42180, 41979, 0, 3249, 1768, 1130, 12328, 501, 42016, 10601, 195087, - 917629, 65294, 7742, 0, 13280, 41922, 10747, 118925, 5310, 9475, 0, - 120810, 8959, 5526, 119085, 0, 0, 8568, 119818, 65155, 64939, 5403, 0, - 41703, 64926, 1771, 12460, 8936, 120631, 119023, 0, 10760, 119115, 9158, - 0, 120259, 0, 120582, 5410, 5783, 10365, 8403, 5400, 120526, 120295, - 5027, 9326, 10491, 0, 4831, 120698, 5028, 5587, 0, 0, 5026, 4923, 65086, - 8981, 12382, 8931, 120755, 1415, 8866, 0, 65513, 10461, 12103, 0, 8642, - 5029, 64788, 1580, 3598, 0, 41070, 10053, 0, 0, 120258, 6026, 41515, 0, - 64592, 1716, 1461, 910, 11907, 620, 41001, 3658, 41541, 120107, 120332, - 64758, 5024, 12888, 41003, 118811, 5025, 120767, 41514, 0, 5703, 119124, - 41517, 41504, 41519, 0, 40989, 119160, 5849, 623, 781, 670, 10660, 5769, - 613, 6105, 120774, 477, 1268, 65275, 8906, 592, 1578, 2636, 64404, 10815, - 917602, 8225, 194928, 654, 0, 653, 652, 7721, 647, 7869, 633, 120224, - 42152, 64361, 12480, 6119, 829, 39, 12487, 0, 120529, 0, 12482, 0, 12489, - 9667, 391, 5550, 0, 482, 0, 1203, 0, 1813, 64544, 41311, 9503, 120623, - 2877, 120249, 120758, 1675, 4939, 5315, 0, 66567, 10070, 10595, 65443, - 4576, 0, 64304, 120241, 4277, 40997, 4039, 0, 64472, 368, 13036, 3960, - 65460, 119073, 120247, 120244, 0, 3958, 0, 1849, 194564, 270, 13086, - 10714, 194650, 42064, 11959, 0, 64657, 41608, 3618, 120240, 9069, 6273, - 5156, 364, 9595, 929, 119980, 42035, 707, 41155, 41725, 8691, 0, 224, - 41662, 0, 9332, 4966, 0, 0, 4578, 64513, 3841, 0, 0, 10732, 13074, 9580, - 4972, 9356, 0, 2909, 118847, 1286, 10166, 8682, 12147, 10203, 9608, - 12815, 7730, 11962, 41540, 12507, 1196, 0, 0, 777, 10020, 4375, 41372, - 41924, 525, 12198, 0, 8763, 0, 41628, 533, 11931, 8658, 0, 41520, 2705, - 65010, 13126, 9838, 4377, 8559, 7765, 120234, 63780, 13193, 2701, 119051, - 8679, 5767, 1576, 7735, 9809, 8353, 63747, 41960, 63772, 0, 10889, 1748, - 7757, 65265, 120226, 12803, 0, 2718, 4168, 0, 13308, 63764, 63787, 1179, - 4440, 0, 7694, 363, 8896, 63768, 3485, 12987, 41701, 64908, 120826, 0, - 1591, 42168, 64625, 10192, 0, 119192, 13053, 10013, 5630, 0, 0, 9492, - 10390, 13083, 12833, 5543, 120609, 1640, 12495, 630, 0, 3138, 10996, - 41127, 1043, 0, 12498, 10090, 0, 0, 313, 0, 8615, 120746, 41878, 493, - 41426, 5750, 1717, 9417, 479, 9405, 120771, 0, 9398, 9403, 3520, 8426, - 12490, 64315, 65185, 0, 12493, 5815, 10707, 1002, 12491, 0, 12934, 631, - 120146, 64922, 13161, 41303, 0, 10546, 120147, 118901, 13305, 0, 2797, - 13107, 120095, 306, 714, 3058, 0, 0, 917555, 119961, 194824, 0, 12644, 0, - 0, 194815, 7909, 9157, 4569, 63758, 63805, 0, 63804, 40986, 180, 244, 0, - 12898, 12494, 12674, 8244, 362, 0, 118967, 8037, 0, 0, 120680, 4882, - 5185, 0, 5521, 4885, 5519, 42155, 10302, 4880, 10104, 1027, 1360, 248, - 12424, 10523, 1446, 4319, 41646, 991, 5189, 63754, 10494, 120527, 1722, - 5581, 120151, 470, 118965, 65271, 5523, 0, 64527, 4579, 0, 9549, 12511, - 10549, 12514, 9661, 0, 12000, 9602, 8623, 0, 0, 0, 0, 12512, 41341, - 13041, 6150, 9846, 659, 6098, 0, 1174, 10334, 0, 8311, 12510, 63856, - 13039, 0, 12513, 9284, 12471, 0, 12330, 0, 63853, 0, 2323, 65288, 2319, - 6293, 12477, 0, 2311, 194867, 4415, 237, 6281, 0, 0, 9010, 2309, 7897, - 8173, 64894, 12469, 0, 118979, 1736, 10609, 3894, 12228, 9397, 10987, - 3383, 9396, 9393, 693, 9130, 314, 9389, 6209, 9387, 9388, 4932, 9386, - 9383, 5332, 12204, 9285, 10436, 8185, 41808, 1751, 273, 8165, 13166, - 2313, 65449, 7948, 9236, 8544, 4528, 2584, 6301, 119185, 6289, 10484, - 9463, 0, 9339, 10922, 3757, 3147, 195092, 12420, 10421, 120488, 2310, - 64389, 2326, 9382, 2565, 9380, 9377, 7921, 9375, 9376, 1683, 9374, 2567, - 8596, 12444, 4044, 41274, 12527, 8210, 120756, 8334, 474, 12331, 0, - 42032, 8744, 726, 9839, 120313, 0, 0, 41276, 42030, 10467, 12522, 9835, - 0, 4951, 634, 12275, 10895, 65492, 274, 120236, 1858, 4744, 4746, 0, - 9548, 120596, 403, 120117, 12503, 9610, 8068, 8197, 63996, 699, 120634, - 41665, 1819, 10496, 0, 42182, 0, 13262, 0, 41667, 12506, 194835, 1923, 0, - 12500, 118849, 12509, 64393, 194755, 120692, 10589, 64279, 41047, 2996, - 1937, 194716, 917505, 8084, 4047, 3608, 63840, 65016, 1107, 194718, 9076, - 8862, 120636, 293, 194841, 64766, 64791, 41827, 13222, 65416, 10579, - 8560, 10463, 63994, 118835, 4803, 9043, 1739, 1941, 498, 64471, 1713, 0, - 12529, 8042, 0, 2344, 12528, 6297, 2414, 0, 0, 3231, 0, 12200, 0, 65156, - 12530, 2537, 969, 41429, 12658, 13034, 6165, 13035, 0, 41433, 4719, 469, - 119240, 4363, 5211, 8914, 0, 119948, 1772, 1435, 64876, 2969, 6046, - 64812, 6208, 64101, 5746, 12215, 0, 4931, 1951, 8612, 917599, 9607, 0, - 338, 0, 5061, 10675, 41106, 10767, 1491, 8115, 0, 11941, 41061, 8227, - 8270, 1218, 0, 41993, 41509, 0, 63808, 12889, 120603, 41108, 4486, 41995, - 1075, 1958, 10925, 41992, 41506, 0, 0, 120326, 10257, 0, 10273, 120327, - 7692, 12669, 8008, 120320, 330, 8566, 65083, 9046, 41117, 41126, 12532, - 0, 120114, 3508, 7794, 0, 0, 9645, 65026, 10770, 3669, 3968, 65028, 0, - 13028, 194890, 12537, 194802, 120112, 0, 12536, 2350, 13029, 66320, 0, - 12116, 13030, 118980, 4527, 1588, 12538, 8409, 119026, 10683, 65398, 787, - 9502, 4948, 12484, 4032, 118940, 41654, 65399, 6207, 0, 6117, 65401, - 8412, 65247, 194842, 8734, 644, 9769, 41657, 10149, 3659, 9533, 184, - 9853, 10827, 12488, 65382, 10502, 41556, 12623, 65474, 2354, 0, 8220, - 118856, 6295, 901, 41510, 7953, 118826, 5157, 4020, 63811, 11927, 66584, - 64818, 0, 41687, 64303, 0, 63816, 0, 0, 119868, 65198, 0, 0, 118930, - 64094, 118926, 7877, 2352, 0, 120726, 64576, 13299, 1407, 10911, 0, - 13026, 0, 7941, 0, 8362, 8903, 9777, 0, 10399, 5869, 8636, 0, 1343, 0, - 12649, 9325, 13025, 6283, 64499, 12643, 0, 0, 13027, 8543, 10051, 9216, - 8263, 13019, 41258, 8625, 194754, 13021, 10477, 3136, 8733, 120742, 8315, - 13022, 10196, 64588, 0, 6152, 0, 5477, 917566, 10112, 194763, 13020, - 194765, 8675, 194767, 194766, 119870, 0, 10978, 8029, 6091, 120350, 4485, - 3335, 118886, 3590, 9776, 41397, 66578, 5215, 194750, 3333, 1632, 63900, - 3588, 3342, 9341, 5363, 917559, 12725, 120564, 0, 64076, 223, 64079, - 1611, 13246, 13018, 120319, 63792, 65245, 3337, 1171, 194605, 194587, 0, - 1805, 8772, 41423, 119241, 11945, 8708, 13046, 8838, 425, 4025, 10709, - 41868, 0, 2392, 13047, 4530, 120105, 10617, 1213, 119233, 120103, 797, - 118814, 7888, 13050, 194742, 64387, 4115, 0, 194735, 0, 3277, 8929, 4947, - 41055, 0, 64276, 426, 194724, 13045, 8251, 10136, 7751, 194727, 9726, - 119253, 1224, 12806, 8768, 13044, 0, 1764, 3101, 119817, 8480, 1078, - 9757, 65439, 41057, 120167, 0, 8663, 9312, 4413, 4539, 3787, 42160, 9222, - 0, 9165, 1572, 9092, 12593, 41961, 2346, 12724, 8958, 0, 9646, 3773, - 41825, 1293, 7947, 12003, 120228, 13043, 8056, 2454, 5349, 208, 0, - 120168, 64849, 120525, 8816, 10699, 10840, 0, 7825, 5661, 0, 12595, 3603, - 41109, 2398, 3548, 1157, 64903, 8638, 0, 0, 3115, 0, 0, 118787, 8235, - 4405, 10086, 4876, 0, 0, 119256, 65430, 64493, 6079, 12646, 10764, 8158, - 41561, 41472, 998, 13051, 13105, 3143, 194674, 194673, 41559, 8509, 7882, - 13052, 118948, 5665, 530, 119071, 41986, 0, 12002, 64526, 5742, 5664, - 4692, 8979, 12310, 4007, 63970, 194686, 7896, 1121, 119168, 3382, 63959, - 66373, 13231, 0, 64874, 4732, 6311, 0, 12004, 63976, 8627, 63977, 10110, - 194671, 41705, 0, 42028, 64327, 10509, 2795, 63979, 65308, 0, 0, 6275, - 917573, 41699, 120324, 194655, 3229, 65517, 63952, 41133, 0, 5407, 12823, - 2331, 41678, 42026, 12156, 2336, 119046, 0, 120323, 0, 0, 1921, 120003, - 194642, 0, 822, 65529, 12691, 4284, 194657, 194648, 194659, 12841, 9229, - 10956, 41255, 12607, 5311, 1795, 965, 3521, 10587, 5774, 8325, 0, 65403, - 0, 1854, 10794, 119250, 10057, 6294, 3144, 64780, 5280, 65019, 4344, - 12905, 41610, 6076, 748, 12385, 768, 535, 442, 12375, 194652, 194629, - 10556, 2475, 12388, 4889, 8968, 6071, 3593, 64093, 4804, 2342, 0, 1800, - 0, 4894, 467, 4890, 120803, 194800, 120707, 4893, 8421, 12433, 10666, - 4888, 502, 64080, 64615, 41490, 0, 12043, 10119, 316, 0, 10230, 65191, - 64087, 64924, 64086, 64746, 2332, 4860, 412, 194567, 11997, 12432, 9583, - 8058, 5546, 8019, 917553, 66561, 63750, 12203, 5544, 2355, 8913, 120390, - 4875, 10613, 120381, 12137, 5548, 9344, 6250, 7944, 120395, 13104, 6077, - 12383, 65452, 120405, 0, 3134, 0, 120775, 4669, 0, 0, 0, 3050, 63839, - 10319, 119075, 10383, 118842, 4592, 120694, 10809, 0, 4691, 0, 9345, 621, - 0, 120055, 4918, 10734, 120032, 64631, 0, 7804, 0, 10811, 8457, 10545, - 4914, 10271, 3786, 8886, 4917, 0, 64914, 7923, 3716, 5464, 9996, 118893, - 2361, 7971, 8195, 0, 9566, 7682, 3722, 8086, 41707, 10845, 8319, 2312, - 40977, 10050, 10874, 8305, 8859, 41458, 40980, 65110, 13202, 0, 12582, - 9119, 0, 7920, 41521, 4021, 6288, 7985, 0, 5653, 120063, 10891, 7698, - 5658, 410, 41552, 1802, 120789, 4913, 0, 41659, 41671, 1827, 0, 64396, - 41668, 9077, 2327, 8810, 12959, 120372, 12705, 3860, 10756, 9239, 8821, - 6153, 2867, 120364, 42158, 698, 120359, 8749, 10356, 12698, 64858, 361, - 12641, 845, 194599, 41560, 11970, 4562, 63756, 2926, 194639, 4099, - 194692, 194695, 7936, 194697, 611, 0, 4716, 118891, 0, 120528, 7686, - 120568, 0, 194700, 120543, 118875, 194701, 6291, 5462, 10823, 41669, - 9734, 65455, 9071, 4655, 4151, 0, 0, 0, 839, 42162, 7695, 8769, 65246, - 10737, 119194, 4859, 64467, 65504, 4826, 118998, 41090, 0, 12172, 120387, - 0, 0, 120345, 12576, 7842, 12839, 0, 804, 2699, 0, 10542, 2985, 119222, - 194596, 8271, 10091, 0, 9468, 0, 9827, 64106, 0, 286, 12323, 118830, - 66592, 0, 0, 1425, 35, 119229, 65084, 0, 41210, 64432, 8482, 0, 6090, - 5032, 7812, 10534, 195035, 664, 194633, 5034, 4272, 65211, 40967, 40965, - 42024, 12704, 13294, 66589, 64869, 6032, 120367, 9129, 119867, 0, 120166, - 0, 194813, 5244, 120169, 120170, 41161, 5518, 4174, 10993, 8189, 968, - 120161, 1169, 434, 41437, 66573, 6034, 41164, 64744, 12574, 118867, 0, - 524, 0, 118934, 788, 0, 12679, 64506, 64528, 1663, 10419, 0, 41227, - 120398, 12346, 12855, 64848, 120399, 10415, 41562, 0, 120432, 118850, - 119141, 0, 0, 194662, 959, 8885, 12564, 64333, 120339, 9469, 5195, 5445, - 9355, 64323, 42151, 4644, 8989, 221, 310, 41253, 41564, 8010, 120396, - 4962, 63766, 8855, 10054, 120413, 120618, 0, 9012, 120415, 12088, 41002, - 13215, 120287, 10451, 64260, 374, 120153, 816, 64634, 120148, 120054, - 41934, 3873, 8367, 0, 64608, 4715, 6101, 11987, 41936, 0, 64511, 12723, - 65089, 0, 307, 120416, 9585, 5374, 120178, 1462, 10235, 0, 194670, 0, - 12119, 120498, 13024, 1929, 120426, 12142, 120425, 12236, 41419, 194618, - 120427, 12982, 64374, 5378, 194666, 64295, 41421, 0, 741, 10083, 0, - 120662, 821, 0, 2498, 5800, 10755, 2992, 1760, 8124, 4469, 2324, 828, - 3611, 194865, 0, 1185, 194728, 531, 0, 10628, 194683, 0, 7999, 8204, - 3614, 2827, 9696, 10942, 7713, 2348, 4354, 10904, 4380, 194608, 7833, - 10573, 5320, 41240, 194611, 3000, 10301, 1810, 3673, 5137, 9525, 64569, - 194849, 118861, 0, 120821, 10121, 64940, 194592, 120406, 12824, 13066, - 4748, 7970, 120630, 12608, 194600, 5871, 41160, 9700, 12580, 0, 120777, - 119811, 3967, 7898, 13137, 8775, 64560, 12713, 2963, 9090, 8410, 4454, - 723, 1734, 966, 4449, 0, 64594, 2456, 231, 2320, 194589, 339, 4968, - 194590, 63752, 8075, 1230, 120795, 8047, 3597, 9761, 10584, 41542, 65404, - 1290, 66358, 8352, 0, 5687, 120505, 3840, 1584, 0, 6045, 0, 10498, 9704, - 0, 120338, 119869, 119992, 12311, 8660, 0, 8365, 8643, 0, 0, 4483, 1709, - 64399, 9780, 6080, 13092, 120044, 1746, 6072, 8667, 12121, 194579, 13140, - 194581, 194584, 2531, 4480, 120765, 0, 1226, 1259, 0, 10394, 0, 10897, - 194560, 605, 120164, 641, 5219, 12342, 64100, 41500, 41129, 311, 12283, - 6221, 9075, 120358, 5466, 10877, 118868, 64885, 120737, 4535, 2667, 4271, - 65406, 0, 345, 41410, 10829, 41198, 0, 41407, 64104, 5037, 41131, 1776, - 8422, 41201, 64103, 41508, 4660, 323, 0, 0, 64338, 1295, 0, 4625, 8323, - 4630, 247, 0, 0, 12338, 4651, 2668, 12080, 0, 64574, 11933, 2519, 0, - 41903, 41079, 5053, 194787, 5049, 0, 65459, 706, 7754, 7727, 8738, 4031, - 6278, 0, 9672, 649, 5514, 118920, 0, 10280, 12670, 1013, 41218, 0, 705, - 41591, 8755, 0, 1183, 65252, 8268, 917549, 0, 8157, 9736, 64503, 65418, - 118921, 4747, 0, 194843, 11913, 4718, 0, 10837, 5141, 10614, 0, 7962, - 12211, 9837, 0, 64722, 119008, 5719, 119977, 9773, 119068, 0, 1857, - 119921, 4626, 8464, 8472, 0, 4629, 8499, 6059, 0, 4624, 7818, 8535, - 119914, 65179, 7805, 64805, 64811, 12242, 41011, 194905, 0, 10558, 0, 0, - 0, 8492, 0, 8459, 0, 1788, 1579, 10766, 0, 0, 8048, 9543, 9028, 120522, - 119177, 0, 41455, 1285, 64882, 194620, 10092, 8684, 12640, 6102, 0, 5298, - 12625, 5294, 0, 42013, 3940, 41597, 119917, 0, 9816, 8665, 0, 12073, - 12630, 1653, 64669, 10153, 0, 6166, 118791, 119913, 0, 5292, 0, 0, 1939, - 913, 3970, 64599, 12455, 1793, 0, 120162, 0, 7878, 8211, 65263, 0, 0, - 118910, 0, 119125, 3514, 13219, 9569, 10865, 120645, 5263, 13286, 0, - 5500, 10022, 65387, 118831, 65384, 5322, 980, 66354, 10008, 5324, 0, - 3784, 41614, 64751, 6230, 0, 63885, 10085, 3360, 8098, 41616, 0, 41734, - 10096, 41613, 8072, 120299, 0, 41821, 1249, 7783, 41731, 12032, 8237, 0, - 64899, 12395, 41149, 12818, 120565, 10462, 41150, 194574, 9795, 119057, - 194609, 13213, 0, 0, 41152, 194679, 9249, 12518, 7808, 1829, 194780, - 41811, 4358, 65315, 10831, 0, 0, 0, 64354, 1710, 0, 10168, 120597, 9781, - 49, 194613, 194953, 6258, 8269, 120594, 9741, 0, 5649, 194617, 315, - 12813, 1643, 194615, 12397, 3470, 8884, 65175, 41099, 65314, 120008, - 1378, 65163, 1072, 120647, 118802, 0, 0, 0, 120002, 0, 1080, 120411, - 8787, 194828, 1101, 41618, 0, 8405, 0, 12632, 1086, 10968, 42088, 7680, - 8847, 10805, 120714, 12639, 3380, 8123, 1091, 6121, 7977, 4501, 12665, - 8119, 12998, 66309, 0, 1494, 0, 3127, 0, 64945, 12930, 1394, 119230, 0, - 12363, 5345, 9789, 0, 9527, 120659, 64582, 12977, 12309, 42090, 8022, - 10635, 12939, 12404, 65168, 42003, 2495, 5848, 8726, 5570, 2587, 12410, - 41722, 1012, 8100, 7890, 120296, 0, 10649, 5569, 6229, 1593, 65319, 6063, - 619, 0, 65080, 6053, 194598, 4120, 65337, 64727, 9160, 0, 119214, 0, - 9366, 9016, 42006, 6055, 3870, 4279, 2500, 10757, 1507, 8497, 8602, - 65320, 41991, 65334, 65333, 65332, 65331, 42059, 42061, 9080, 120099, - 9128, 64480, 5571, 3674, 9740, 9121, 4371, 5798, 10408, 42085, 10107, - 4106, 41989, 65313, 42074, 63999, 41228, 0, 10233, 13098, 120423, 41239, - 0, 0, 8182, 0, 119831, 0, 11947, 0, 5847, 1505, 9131, 0, 12606, 12695, - 41988, 41250, 12175, 0, 64075, 120739, 7809, 0, 0, 562, 8120, 120701, 0, - 13033, 64738, 3219, 120532, 10664, 1366, 1037, 194747, 4551, 0, 118945, - 0, 10637, 4568, 549, 1570, 10478, 2835, 12517, 557, 9457, 5952, 64649, - 41056, 12519, 41004, 0, 2825, 66636, 10825, 8079, 2821, 41046, 0, 195065, - 12111, 3927, 13071, 12515, 452, 5271, 5492, 64718, 2831, 10604, 10144, - 41706, 5212, 5493, 41120, 8916, 0, 9747, 12019, 41332, 1618, 12333, - 917584, 1668, 10430, 0, 5853, 1187, 10363, 118990, 12956, 0, 119107, 0, - 3240, 12060, 12194, 120100, 41631, 41065, 5323, 8166, 4557, 0, 2707, - 8309, 0, 65297, 41052, 0, 2697, 8752, 194689, 4912, 2695, 65172, 0, - 119223, 8864, 0, 64798, 10736, 2693, 12125, 41124, 0, 1164, 0, 0, 1035, - 41067, 120219, 7881, 701, 12178, 3489, 0, 12340, 120751, 5248, 12218, - 120538, 6303, 3796, 41123, 0, 3994, 120283, 10457, 9991, 41128, 64485, - 5792, 120282, 64857, 42171, 2855, 7994, 64762, 6104, 0, 0, 9340, 10654, - 1589, 119226, 296, 3246, 7906, 2879, 41981, 41620, 0, 7815, 120797, - 120482, 0, 0, 10585, 12579, 1496, 747, 12708, 942, 2378, 10960, 119830, - 5299, 0, 9320, 5449, 1232, 8139, 6216, 41431, 0, 65373, 5295, 66624, 0, - 1223, 1642, 174, 120824, 12158, 4161, 2374, 120546, 8475, 3212, 66313, - 3211, 194576, 5286, 0, 0, 917546, 9728, 3846, 8070, 5536, 0, 7705, 11942, - 0, 12136, 3309, 0, 66377, 41491, 0, 4986, 12189, 41653, 1280, 1241, - 917537, 4257, 8496, 0, 6220, 9004, 65411, 194580, 41513, 41650, 0, - 194578, 194878, 12914, 120740, 0, 12797, 6078, 10237, 0, 1475, 119118, - 11979, 6084, 118900, 41064, 41062, 9635, 12600, 3256, 41236, 42076, 0, 0, - 119866, 8727, 65304, 64866, 41237, 64073, 64867, 10562, 118947, 65329, - 64071, 10640, 3248, 2613, 119865, 9015, 0, 66568, 3635, 64337, 41651, - 41241, 64944, 3494, 0, 0, 10588, 0, 0, 0, 0, 635, 0, 194797, 0, 65312, - 5447, 0, 0, 64382, 4010, 7984, 8600, 41915, 120139, 4176, 41105, 5812, - 119933, 6232, 0, 0, 194588, 318, 5302, 0, 0, 4335, 3649, 3941, 42145, - 41110, 3634, 64892, 9113, 1954, 12155, 7866, 0, 0, 42146, 120134, 120138, - 120129, 2849, 120128, 0, 7938, 12960, 1761, 4586, 65379, 350, 10930, - 119936, 509, 0, 0, 0, 0, 542, 5133, 41680, 0, 9500, 0, 1514, 64741, 0, - 5453, 65533, 64921, 0, 2496, 8493, 944, 9368, 3890, 12168, 1438, 8817, - 120592, 10818, 41947, 1220, 120828, 63931, 1194, 3242, 1571, 9555, 8598, - 0, 6169, 943, 41946, 2798, 312, 0, 41980, 119025, 120717, 8877, 269, - 3495, 6272, 9617, 1460, 8988, 120660, 4891, 0, 10862, 0, 41119, 41416, 0, - 4173, 0, 194637, 0, 12895, 64955, 41418, 0, 119022, 120286, 41415, 6296, - 9582, 193, 12188, 0, 64680, 41122, 1730, 2457, 4493, 2314, 10469, 1362, - 9822, 7703, 8840, 5807, 0, 120451, 8534, 0, 4426, 0, 0, 120209, 119123, - 7874, 8681, 5220, 120281, 13136, 119825, 2416, 3310, 10972, 118881, 379, - 119215, 13220, 0, 0, 3223, 5517, 1284, 8041, 4549, 120475, 5240, 9811, - 10012, 3096, 120275, 0, 0, 8515, 8688, 12866, 0, 3294, 9501, 0, 1272, - 65485, 64514, 64654, 120035, 65210, 1467, 10158, 10040, 5288, 9519, - 41861, 8132, 64090, 118899, 12193, 66615, 65493, 3215, 0, 7710, 1610, - 120271, 0, 63881, 0, 0, 5181, 5275, 0, 228, 8637, 1501, 120476, 3789, - 5179, 0, 6225, 118927, 0, 1725, 66603, 8196, 9352, 12042, 0, 0, 9537, - 3961, 5762, 1967, 2605, 4500, 64561, 8104, 4981, 917545, 3405, 0, 63876, - 10414, 13001, 8141, 9559, 2600, 41649, 41647, 64851, 0, 3237, 8631, 2545, - 10466, 8541, 0, 0, 41866, 0, 120430, 64517, 10127, 0, 1650, 262, 1637, - 10958, 7901, 3238, 41945, 0, 41941, 3308, 65158, 10860, 8614, 65220, - 41493, 120624, 41943, 10762, 0, 45, 0, 0, 8106, 4128, 10065, 64083, 4494, - 0, 4012, 10395, 0, 9084, 4537, 8737, 64089, 11004, 695, 739, 696, 7912, - 2620, 64398, 195044, 9227, 0, 179, 5098, 691, 738, 2853, 0, 118813, 3868, - 688, 0, 690, 2548, 737, 974, 64084, 119837, 10854, 119839, 10034, 3985, - 8783, 118838, 9362, 0, 0, 4682, 118869, 12809, 8082, 4685, 3158, 10879, - 4389, 4680, 923, 41863, 3851, 292, 13002, 119845, 119844, 3221, 1763, - 64468, 4612, 119851, 119850, 12999, 41219, 12349, 64644, 10782, 3637, - 12996, 0, 11949, 63922, 10594, 3228, 41826, 64624, 0, 10967, 2731, 0, - 9651, 651, 3891, 7696, 0, 2337, 1735, 0, 0, 4177, 195098, 9089, 66312, - 64695, 120580, 64500, 1860, 2654, 0, 1856, 12240, 8599, 195049, 66356, - 118999, 3458, 3208, 12975, 8498, 119121, 8949, 8758, 9450, 194859, 1569, - 63888, 12534, 12124, 7690, 119254, 12533, 917551, 7740, 4543, 41471, 0, - 64674, 0, 0, 0, 11980, 0, 41544, 41689, 63789, 12282, 64909, 13064, - 63893, 64556, 8850, 9238, 0, 8561, 4573, 0, 0, 12791, 120605, 0, 0, - 120744, 8778, 10630, 12900, 0, 10950, 8314, 194936, 12790, 8804, 65092, - 66607, 12792, 120435, 42018, 1744, 12789, 10366, 12317, 41310, 0, 13164, - 10723, 967, 120253, 64546, 12690, 120454, 3257, 0, 9862, 1845, 2974, - 10446, 41848, 0, 278, 10580, 10089, 870, 0, 3499, 8609, 42149, 876, 871, - 877, 6002, 878, 42015, 879, 0, 4563, 65176, 41308, 0, 65306, 867, 9520, - 872, 8646, 868, 873, 0, 0, 869, 874, 195048, 1940, 875, 790, 220, 65193, - 194845, 10678, 10044, 194877, 5429, 13082, 0, 917541, 5707, 10393, 0, - 120267, 42067, 41890, 5433, 10657, 7911, 0, 3742, 9775, 3959, 0, 5425, - 4977, 2467, 5317, 5423, 4611, 120553, 8040, 5069, 9679, 4182, 0, 4676, - 120501, 41073, 4418, 4184, 4628, 10208, 12989, 118784, 917540, 1851, - 12186, 120601, 11908, 120254, 9360, 9083, 0, 41764, 194565, 12837, 8829, - 7711, 64423, 119218, 194777, 120260, 118855, 8809, 64371, 365, 12056, - 41382, 0, 0, 65395, 42080, 195040, 5516, 2845, 7717, 4588, 41717, 63830, - 544, 12045, 2433, 0, 5515, 3352, 0, 64377, 65437, 793, 65194, 0, 305, 0, - 119002, 842, 120576, 8208, 0, 41695, 1647, 118877, 5608, 63824, 917625, - 818, 5337, 917622, 917621, 120531, 9638, 8061, 8735, 12483, 120468, - 13003, 119140, 10973, 66359, 1372, 118858, 917608, 4969, 1254, 917605, - 989, 64257, 118862, 65228, 6060, 0, 4326, 2840, 64601, 13068, 0, 65242, - 3245, 9068, 119069, 949, 0, 0, 6148, 8605, 2651, 0, 0, 0, 0, 0, 65106, - 120418, 0, 0, 41796, 1269, 195028, 63868, 41777, 64372, 5144, 3226, 655, - 120467, 4431, 4331, 8777, 3285, 41834, 5279, 0, 10336, 8312, 0, 12091, - 671, 250, 0, 618, 668, 610, 65195, 0, 1152, 5256, 640, 41229, 12207, - 1067, 255, 3905, 917593, 9493, 120466, 41014, 10795, 0, 0, 120728, 0, - 10653, 41272, 0, 13287, 0, 65166, 9019, 0, 0, 120695, 987, 64410, 5527, - 2768, 10684, 3365, 5135, 0, 12796, 11953, 0, 0, 5139, 346, 119144, 6305, - 12609, 4675, 5168, 5530, 5210, 0, 4627, 8253, 5208, 1136, 65433, 120587, - 5218, 7976, 118864, 65285, 3244, 5529, 0, 0, 0, 5432, 64258, 4041, 8784, - 2357, 0, 5528, 229, 42140, 119884, 0, 0, 119881, 119880, 119197, 4000, - 119877, 119876, 665, 119045, 3206, 7770, 7884, 64853, 0, 118916, 0, 211, - 2509, 7790, 10470, 7861, 3220, 10791, 64050, 450, 8951, 5214, 10432, - 8118, 5450, 10768, 1233, 4661, 5852, 0, 66338, 41865, 1708, 13293, 40985, - 2623, 10927, 1701, 0, 2388, 4698, 41761, 1066, 8361, 4701, 41758, 5444, - 2617, 64889, 8267, 119863, 119089, 0, 0, 120633, 2625, 8801, 3053, 4340, - 120412, 3631, 10955, 7850, 120292, 8416, 917607, 120203, 65507, 194803, - 12660, 8232, 65434, 194807, 194713, 41069, 194808, 0, 12099, 4310, 4336, - 6252, 713, 41068, 7990, 3990, 194811, 65113, 64638, 65243, 13145, 4489, - 194791, 42138, 1030, 5358, 64577, 9513, 10370, 9357, 194764, 1773, 10250, - 10258, 2712, 1635, 7745, 1410, 0, 0, 94, 194965, 120149, 194731, 8908, - 559, 120421, 12862, 0, 10752, 4892, 10876, 64537, 41307, 8732, 120336, - 5777, 1757, 9539, 4696, 2586, 65248, 8945, 8466, 3641, 5419, 41803, - 42062, 0, 0, 120344, 3668, 120823, 8610, 12226, 0, 194949, 2340, 936, - 13289, 64478, 120436, 1459, 0, 10499, 2962, 0, 2321, 1504, 10465, 41312, - 8921, 195025, 120206, 195026, 64525, 41901, 63814, 4113, 2949, 2372, 336, - 194774, 2958, 12152, 5348, 682, 2395, 120061, 13291, 64743, 10593, 1703, - 4013, 194779, 8033, 120064, 65152, 9810, 10198, 4150, 12970, 8318, 41790, - 10109, 41893, 2360, 41794, 12858, 0, 3999, 3777, 118946, 1965, 9796, - 2411, 194950, 799, 0, 10276, 10308, 10372, 63832, 8501, 63833, 2317, - 10260, 41317, 120513, 5417, 0, 10384, 0, 9353, 0, 7753, 2351, 10641, - 64489, 41314, 0, 119812, 0, 119236, 230, 65431, 12009, 0, 4855, 4165, - 8746, 5441, 9654, 10288, 10320, 0, 10596, 0, 0, 4784, 0, 13270, 7786, - 10098, 41147, 194570, 63769, 680, 6274, 10312, 1181, 0, 3174, 13127, 0, - 64822, 41887, 0, 4862, 9735, 120709, 0, 917604, 3914, 41037, 10828, 9065, - 12961, 41039, 119173, 0, 6231, 289, 65302, 4694, 64504, 4690, 0, 118955, - 0, 4693, 65257, 40987, 4667, 4688, 0, 8828, 0, 0, 1246, 3110, 64705, - 12197, 41008, 4749, 0, 0, 921, 218, 0, 1520, 242, 4786, 41700, 8217, - 8932, 64653, 7834, 10088, 0, 0, 64681, 5313, 951, 8888, 64534, 4816, 0, - 0, 4009, 194694, 0, 120562, 41549, 195031, 64860, 119138, 119900, 4689, - 119888, 0, 120158, 119209, 120159, 1646, 120156, 119891, 4040, 194734, - 65118, 119889, 2579, 119905, 3177, 8207, 9099, 4107, 0, 119894, 662, - 120706, 9244, 0, 63781, 10084, 0, 0, 118840, 194858, 41929, 3399, 9851, - 120442, 8739, 9059, 0, 7687, 64637, 8854, 40993, 52, 13241, 0, 0, 120444, - 1777, 9151, 1137, 0, 749, 120809, 120584, 5385, 3978, 917594, 0, 0, 5989, - 0, 10170, 65013, 0, 41685, 64702, 120438, 8425, 41684, 0, 519, 10369, - 64547, 1585, 195030, 10249, 422, 1500, 10305, 986, 0, 3666, 5781, 5599, - 3098, 2494, 120202, 4861, 0, 64334, 194712, 0, 0, 41221, 65102, 8961, - 252, 10243, 10245, 63936, 0, 120452, 194707, 63751, 9478, 2508, 9060, - 917630, 202, 10761, 120747, 1242, 12899, 120447, 194705, 63940, 64533, 0, - 9593, 10543, 2403, 12979, 64609, 0, 65260, 2504, 9784, 41024, 7764, - 64701, 9514, 120825, 5859, 119259, 2858, 8298, 0, 120700, 65478, 9691, - 4971, 12992, 2753, 1936, 0, 8456, 2751, 12662, 2763, 8953, 42104, 10731, - 7774, 4780, 9792, 63991, 0, 194871, 0, 120764, 2856, 10019, 47, 63989, - 2823, 4365, 120629, 0, 3647, 7899, 2602, 8417, 119903, 0, 41135, 120437, - 4033, 118854, 194848, 172, 194720, 212, 41137, 12350, 12320, 118808, - 64623, 0, 8257, 8915, 2759, 945, 3732, 120230, 0, 5344, 194851, 1291, 0, - 9062, 119252, 9531, 13155, 8505, 64479, 12062, 119018, 64703, 65487, 0, - 10900, 41531, 1263, 3720, 12048, 63935, 64292, 41524, 64692, 12652, 6099, - 41534, 0, 63933, 64426, 299, 0, 119892, 63951, 3524, 64785, 8831, 0, - 8674, 3075, 0, 8245, 0, 12624, 0, 1673, 4811, 63928, 5845, 9338, 6243, - 65414, 2581, 4001, 0, 9820, 64098, 12187, 5551, 0, 5984, 0, 195073, 4393, - 10566, 120407, 8680, 0, 194726, 2588, 5422, 0, 0, 3491, 2471, 0, 2883, - 2749, 63921, 0, 10913, 0, 194725, 119134, 675, 120551, 63924, 0, 41287, - 6219, 63926, 0, 41232, 9329, 63925, 41153, 219, 63945, 41330, 692, 65200, - 0, 9240, 3181, 9688, 0, 1222, 66369, 8262, 119155, 64530, 0, 64610, 3092, - 12092, 9615, 64808, 120691, 8013, 0, 0, 195019, 8895, 5253, 0, 5458, 0, - 922, 118805, 0, 65111, 0, 3218, 12618, 63997, 120469, 63831, 8962, 8569, - 9641, 11932, 12202, 3214, 120461, 9604, 12053, 3207, 120465, 63826, - 118941, 64392, 120141, 63825, 2844, 3205, 41974, 41286, 12139, 66588, - 64708, 0, 3358, 2606, 0, 3104, 2608, 0, 1173, 0, 5308, 195007, 290, 0, - 194937, 2862, 2792, 64498, 66371, 378, 2610, 66591, 65079, 0, 65372, 0, - 37, 0, 0, 1814, 120479, 3209, 118843, 0, 10638, 9768, 64648, 0, 66372, 0, - 2591, 2837, 4341, 41403, 64105, 0, 5233, 65270, 64792, 195090, 3570, - 9112, 0, 40991, 9490, 63761, 1685, 595, 64856, 194730, 1292, 6222, - 120142, 3654, 120552, 9637, 0, 2535, 41293, 0, 10656, 194983, 3243, 9014, - 5606, 63762, 538, 11006, 5602, 7807, 8073, 0, 10629, 8203, 0, 3056, 8458, - 41778, 8495, 8762, 10508, 917552, 779, 9818, 64367, 2465, 3463, 8193, 0, - 9730, 8695, 4738, 0, 5811, 12345, 64904, 0, 504, 0, 10899, 8982, 0, 0, 0, - 782, 4867, 10883, 1262, 64771, 732, 3737, 917614, 1548, 0, 120589, 1832, - 5604, 5611, 41141, 0, 4376, 64612, 11991, 3745, 41738, 119928, 1502, 0, - 0, 3869, 11937, 5702, 3655, 1783, 0, 5728, 195086, 13285, 120521, 11918, - 9603, 5724, 5254, 5727, 7724, 0, 119901, 5723, 5129, 194898, 0, 10597, - 9033, 5614, 5893, 6223, 12303, 42073, 0, 120702, 0, 119862, 4792, 0, - 1964, 0, 41950, 12146, 0, 120648, 66570, 195082, 894, 300, 194595, 10037, - 120675, 195085, 0, 9783, 2562, 2607, 64740, 64830, 0, 0, 0, 119861, - 64056, 13062, 64946, 5096, 5095, 2863, 3424, 0, 10454, 118801, 5094, - 10093, 4369, 13156, 12306, 5401, 5093, 119909, 194597, 65251, 5092, 526, - 0, 41295, 5091, 176, 41691, 8985, 4104, 119911, 6285, 1215, 11985, 5744, - 12272, 9832, 0, 3713, 13218, 0, 0, 8980, 118988, 12293, 8844, 13106, - 41505, 42082, 4278, 1737, 8987, 12917, 0, 9074, 917560, 9335, 12850, - 118991, 8113, 10339, 5255, 1786, 661, 0, 5475, 0, 41854, 120620, 0, - 12419, 1160, 1267, 119238, 41217, 0, 10018, 360, 194792, 3621, 64662, - 5863, 3137, 0, 12108, 12928, 41216, 1228, 2616, 119190, 64401, 65234, - 10745, 1714, 3135, 0, 0, 0, 3142, 0, 0, 10819, 917565, 0, 0, 64, 1470, - 194566, 10291, 6227, 2826, 41749, 0, 119864, 6163, 9708, 13250, 0, 42011, - 0, 8603, 12206, 5839, 1702, 1240, 41461, 6286, 194995, 5834, 0, 3858, 0, - 1765, 12086, 42001, 1600, 64309, 0, 0, 8401, 120786, 42014, 9282, 8882, - 118929, 10479, 2570, 2852, 5367, 4601, 194941, 0, 1234, 9678, 13115, - 66310, 12667, 0, 41973, 10147, 12935, 0, 0, 118829, 0, 8163, 41716, - 12727, 194816, 120533, 41289, 0, 13129, 2864, 8977, 602, 10435, 9395, - 41675, 120340, 2765, 64540, 41279, 120414, 119246, 0, 0, 0, 119220, - 10887, 65206, 118963, 64920, 66593, 63914, 12150, 263, 194563, 41288, 0, - 9633, 10886, 119042, 7831, 12067, 0, 0, 0, 8076, 118827, 8290, 8291, 0, - 0, 0, 2596, 10852, 63911, 13113, 0, 42019, 2393, 8766, 9087, 750, 0, - 41574, 10163, 120654, 63913, 10441, 5954, 64931, 4314, 194675, 198, 0, - 730, 41441, 7819, 194826, 0, 13165, 1720, 63905, 8619, 678, 8240, 118960, - 194852, 3751, 0, 0, 4262, 1798, 709, 0, 1354, 10778, 13152, 0, 3892, - 8137, 10449, 0, 0, 41470, 245, 41045, 41719, 41233, 64801, 0, 497, 12100, - 5953, 0, 7796, 41235, 0, 42045, 9804, 8449, 432, 1281, 64355, 65393, - 64339, 10677, 604, 41097, 9120, 1859, 0, 10460, 3425, 0, 0, 2836, 8797, - 8490, 9052, 64888, 0, 2356, 95, 64786, 1738, 0, 0, 2832, 64640, 9670, - 6096, 0, 64918, 65151, 10063, 2822, 12199, 4436, 0, 2566, 11971, 12090, - 64872, 1065, 1331, 0, 0, 2576, 0, 41142, 5090, 5089, 120263, 9505, - 119109, 514, 41692, 319, 2921, 0, 9477, 5772, 12968, 5087, 118822, - 917567, 96, 2580, 0, 10522, 41223, 5085, 1463, 41342, 0, 5293, 0, 0, - 3733, 3772, 13090, 12054, 64496, 41254, 64300, 12575, 13091, 0, 0, 9680, - 0, 0, 41413, 64419, 118953, 0, 0, 118923, 0, 0, 10939, 6106, 0, 41271, - 1132, 0, 4534, 41270, 0, 9224, 195099, 0, 64761, 0, 3671, 8510, 0, 0, - 41275, 0, 0, 10807, 7963, 42012, 0, 0, 65227, 6187, 13109, 3854, 41479, - 13141, 9715, 0, 8258, 0, 4185, 41334, 65148, 8871, 42, 0, 0, 4102, 0, - 9029, 118995, 0, 2353, 6308, 41604, 11958, 2611, 119186, 41021, 0, - 194631, 66336, 8045, 120428, 12946, 4484, 8747, 118976, 12826, 65233, - 5557, 41224, 9737, 13216, 3747, 9467, 5291, 8878, 1691, 41226, 0, 12107, - 10146, 10905, 9086, 64566, 697, 0, 628, 0, 12594, 0, 10468, 4546, 7731, - 65256, 12010, 0, 0, 3805, 0, 64293, 0, 9844, 0, 6307, 118950, 0, 0, - 12166, 64697, 10516, 194706, 10152, 12648, 10354, 0, 9532, 5785, 41309, - 9764, 41316, 120160, 0, 13230, 41299, 5559, 0, 8704, 2397, 5556, 0, - 66368, 13122, 9011, 191, 9630, 41837, 42040, 5506, 0, 0, 64850, 41072, - 12598, 8845, 41577, 194790, 10002, 8889, 119113, 42141, 41570, 41838, - 683, 396, 41580, 12526, 0, 12901, 12351, 65115, 343, 66597, 194680, - 41360, 0, 10481, 4559, 0, 1956, 118857, 0, 0, 1724, 1210, 120066, 9412, - 3739, 6263, 0, 0, 3964, 8984, 38, 8533, 9234, 10947, 65073, 13063, 0, - 1778, 3956, 65091, 42070, 42069, 119846, 8743, 8369, 118807, 10941, - 12467, 0, 5547, 66618, 0, 0, 8175, 0, 284, 8108, 934, 5696, 0, 173, 0, - 8652, 0, 120670, 1750, 0, 4394, 65056, 1807, 9354, 0, 0, 5889, 63783, 0, - 64714, 917624, 0, 12162, 12120, 41087, 1721, 7767, 7891, 120446, 10563, - 2583, 4512, 63973, 2462, 7693, 64294, 10434, 3855, 8107, 41337, 63972, - 4952, 65413, 0, 5504, 41340, 3975, 0, 0, 65420, 12672, 3798, 2703, 0, - 64347, 0, 9774, 41847, 1127, 455, 41095, 3962, 10100, 3483, 41101, 3954, - 41091, 4513, 9104, 3503, 65375, 41298, 1468, 65386, 1864, 41851, 0, - 41446, 2540, 7736, 41080, 41849, 917619, 4320, 3224, 12909, 9705, 64684, - 8604, 195006, 1510, 11978, 6149, 3887, 194882, 1411, 2824, 194708, 10106, - 8770, 1403, 0, 1347, 9631, 8671, 0, 4283, 0, 194785, 8640, 13124, 258, - 1654, 41408, 8858, 0, 42139, 3741, 0, 4042, 4581, 2873, 119029, 0, 0, - 8549, 10861, 0, 41673, 64829, 1733, 4392, 2568, 10786, 63983, 0, 376, - 41486, 9221, 64871, 119907, 8823, 41222, 12857, 6217, 7965, 4896, 0, - 10154, 0, 41350, 8301, 0, 0, 1684, 64501, 10974, 458, 41199, 0, 0, - 195046, 11916, 340, 194980, 12298, 10864, 0, 12288, 0, 4388, 1493, 10521, - 0, 4097, 0, 13080, 65203, 195051, 41642, 6030, 8059, 3210, 13131, 120190, - 917597, 0, 8794, 41278, 41629, 12154, 0, 10043, 64658, 1186, 41571, - 41297, 617, 9464, 0, 3675, 5207, 63955, 5213, 118896, 833, 41348, 41568, - 0, 3253, 63954, 41088, 8630, 6062, 0, 5596, 5545, 194982, 933, 1341, - 9842, 5217, 0, 8942, 64800, 0, 0, 41615, 2635, 0, 194768, 41632, 120152, - 0, 7835, 41622, 9002, 0, 194770, 64558, 0, 9716, 0, 9805, 5990, 900, - 5784, 194775, 9317, 0, 3612, 4011, 64376, 41953, 5389, 7864, 0, 65336, - 2839, 5600, 3903, 0, 10447, 3749, 1207, 9319, 0, 3501, 0, 119142, 4403, - 0, 1124, 5597, 195009, 0, 9321, 4429, 917606, 0, 194572, 1719, 64873, - 546, 9671, 1125, 4399, 9542, 472, 7716, 8452, 5488, 65223, 42025, 0, - 5491, 3602, 8328, 41182, 2604, 41949, 5490, 41183, 5489, 8522, 10287, - 684, 6300, 0, 2854, 0, 4390, 454, 7823, 194784, 195061, 0, 195062, 0, 0, - 64572, 8478, 194788, 2394, 2575, 3415, 3746, 0, 8648, 0, 65421, 65505, - 119092, 11989, 65142, 418, 118810, 917616, 10295, 8249, 10391, 41752, - 4565, 8641, 41449, 2598, 513, 0, 41475, 8656, 0, 1024, 65008, 7961, 0, - 8941, 917563, 4554, 0, 9023, 40973, 194977, 12126, 10964, 0, 63799, 9509, - 0, 1036, 65114, 0, 1723, 0, 9049, 41185, 41579, 2444, 41200, 10705, - 41447, 194795, 65224, 0, 740, 63963, 917613, 118874, 194986, 5300, 10407, - 9459, 0, 0, 195060, 7856, 8121, 10438, 12050, 41698, 2860, 12157, 5238, - 0, 5690, 5743, 10424, 12065, 0, 13095, 0, 0, 8875, 8694, 9506, 13254, - 5575, 12847, 2413, 118917, 0, 962, 12176, 1122, 317, 9040, 119116, 1582, - 0, 1920, 41477, 10173, 827, 10801, 0, 118798, 0, 5223, 496, 10439, 4313, - 5226, 12602, 7860, 120627, 906, 7758, 2842, 10215, 5224, 5487, 798, 5692, - 12801, 8406, 1153, 5695, 41711, 64627, 8054, 12626, 120131, 5691, 287, - 866, 233, 4642, 66574, 0, 0, 0, 65140, 42089, 8830, 9008, 0, 10524, - 41175, 42079, 65423, 119065, 5296, 0, 0, 10663, 0, 3302, 0, 0, 0, 0, 0, - 0, 0, 42093, 3920, 8690, 120036, 0, 12122, 4580, 41967, 6116, 1785, - 41965, 120635, 3021, 42004, 5138, 0, 0, 41998, 41867, 4540, 41179, - 194804, 6200, 63796, 5134, 42021, 322, 4643, 5132, 42010, 194988, 64589, - 5143, 64875, 8790, 0, 194796, 64604, 9365, 8869, 0, 64400, 42060, 0, - 64887, 194814, 64941, 10270, 10286, 10318, 10382, 0, 4110, 0, 41530, - 10929, 64277, 3234, 120607, 13058, 8617, 41982, 6025, 120736, 12805, - 8767, 0, 0, 9597, 41283, 5201, 0, 6215, 12714, 6214, 13101, 65282, - 120490, 65268, 120504, 120045, 194681, 187, 0, 10059, 10511, 4963, 9767, - 789, 1749, 8964, 0, 194577, 320, 41948, 41833, 195047, 3049, 41139, 9787, - 9449, 10081, 10528, 42121, 118894, 0, 7954, 5549, 0, 195071, 8485, 4671, - 1189, 905, 480, 10985, 10240, 10610, 5414, 8647, 1745, 4286, 5421, 5427, - 9554, 0, 0, 65465, 41507, 8806, 42047, 9442, 6213, 9443, 9436, 7867, - 64720, 6236, 42052, 0, 2406, 0, 12851, 4566, 348, 5474, 3801, 3103, - 10406, 5246, 5236, 64395, 0, 5200, 64305, 41739, 41733, 64518, 10931, - 13181, 41402, 395, 5391, 5198, 8786, 9428, 41259, 5196, 0, 2691, 42009, - 5205, 41244, 5562, 0, 118973, 41262, 66364, 64421, 0, 41251, 9126, 435, - 3979, 12014, 12893, 8093, 9079, 3203, 192, 120785, 3385, 41266, 64430, - 5383, 10294, 10326, 0, 5738, 9574, 2666, 0, 5361, 831, 419, 8256, 10716, - 7872, 64583, 194758, 1260, 3149, 5359, 7766, 0, 7914, 5357, 916, 769, - 2624, 5364, 64739, 120599, 5563, 547, 1943, 41188, 5560, 41212, 487, 0, - 4497, 3754, 0, 0, 9039, 10619, 41776, 0, 8716, 120126, 40983, 64072, - 41516, 0, 119044, 0, 41376, 0, 3232, 12185, 0, 120632, 0, 120458, 41889, - 0, 8634, 1161, 41895, 118804, 9701, 8622, 120215, 0, 0, 120588, 669, - 5679, 41362, 120125, 118961, 11921, 42087, 5678, 0, 0, 41364, 460, 0, - 41352, 41361, 195101, 41366, 0, 3356, 6178, 917, 0, 119915, 64068, 7782, - 9044, 4974, 677, 119916, 0, 119932, 41912, 1216, 12504, 11952, 3349, - 195097, 12296, 8927, 4739, 3738, 5802, 194997, 5683, 10368, 0, 491, 0, - 120503, 0, 0, 5682, 6206, 8670, 0, 5680, 917568, 10001, 41881, 118823, - 1449, 10241, 3768, 65255, 3776, 9095, 7741, 12684, 41885, 1046, 0, 5567, - 2717, 4620, 5171, 5564, 64571, 41908, 41786, 5565, 12819, 12578, 194992, - 194771, 5169, 5566, 3465, 64694, 3175, 11904, 120065, 120804, 5176, 5942, - 8468, 4871, 10361, 10425, 119210, 118952, 64729, 1128, 194722, 10548, - 64664, 10647, 9408, 9409, 9410, 457, 3662, 9413, 1934, 9415, 9416, 8802, - 9418, 8909, 9420, 9421, 5897, 9423, 5165, 5126, 41385, 8043, 8950, - 194562, 8955, 3374, 9400, 9401, 9402, 8939, 9404, 3507, 9406, 9407, 0, - 65515, 9499, 10035, 183, 65078, 2631, 0, 10636, 41130, 0, 3996, 120650, - 64675, 1667, 41584, 65486, 41582, 0, 4332, 64825, 10741, 10726, 12912, - 41125, 5899, 8101, 3610, 12085, 41748, 0, 955, 120092, 5340, 5350, 41058, - 5446, 64549, 10875, 64796, 5442, 120424, 0, 9782, 5451, 12896, 3616, 0, - 0, 3874, 7708, 64370, 10859, 0, 10345, 10409, 0, 11909, 120591, 120303, - 41038, 0, 194733, 4447, 8536, 120708, 917586, 0, 194732, 724, 42048, - 1455, 205, 0, 10351, 64618, 0, 4175, 12307, 0, 120380, 939, 41355, 5505, - 119154, 5503, 8021, 0, 119150, 9819, 41357, 8011, 6088, 5507, 12044, 190, - 0, 10026, 4356, 8188, 1191, 0, 4417, 10329, 5476, 8991, 0, 7827, 0, 5829, - 8550, 0, 5592, 2919, 64925, 2675, 5595, 0, 7918, 4367, 0, 0, 5478, 1728, - 5594, 120710, 178, 12972, 5590, 10727, 13067, 118909, 65254, 0, 9731, 0, - 64633, 0, 12113, 13065, 118863, 9252, 12278, 4652, 0, 66563, 194879, 0, - 0, 12887, 10551, 10710, 0, 0, 0, 120570, 41804, 5199, 9497, 1120, 120471, - 8333, 1444, 9486, 120808, 13142, 4538, 194830, 5285, 6177, 5894, 0, - 11910, 13224, 0, 8963, 4034, 13162, 65389, 3334, 64003, 41747, 10708, - 194571, 8677, 120734, 1651, 9350, 8861, 0, 8836, 1142, 0, 4396, 10928, 0, - 8922, 8856, 66611, 4002, 0, 10442, 10676, 3344, 120402, 64963, 10813, - 2592, 12853, 120242, 120243, 3438, 119912, 7871, 120239, 65516, 12321, - 120391, 118890, 120389, 10007, 120246, 9588, 120248, 4700, 66366, 41994, - 120051, 8661, 120365, 66572, 0, 120401, 4973, 5573, 12588, 9629, 40981, - 119873, 118981, 7993, 64328, 42002, 64754, 41766, 8825, 13016, 0, 0, - 10346, 6107, 0, 9243, 2464, 0, 6108, 3372, 335, 6247, 64689, 438, 4510, - 5765, 8721, 119878, 4036, 6092, 12840, 120229, 8876, 10303, 8096, 10284, - 3354, 10268, 0, 9289, 8689, 10316, 3876, 10335, 0, 42044, 0, 0, 0, 8050, - 120030, 0, 64591, 0, 120053, 0, 843, 120495, 194829, 120770, 0, 10117, - 66560, 41902, 118871, 6312, 215, 1963, 118889, 64494, 1953, 9579, 41938, - 1256, 3910, 13015, 6242, 41329, 9662, 41257, 41900, 3366, 10700, 8805, - 1742, 5542, 9333, 8202, 120459, 120232, 41611, 0, 0, 120385, 499, 118846, - 8593, 0, 0, 41169, 1712, 5932, 8097, 41762, 12292, 194685, 11967, 11963, - 65296, 41243, 118957, 5662, 416, 9458, 64687, 0, 0, 194844, 10984, 64386, - 64672, 0, 0, 0, 41172, 0, 66355, 120669, 41937, 194825, 12540, 65446, - 3804, 41760, 5794, 201, 2662, 9419, 64579, 8254, 41726, 10975, 0, 120625, - 65131, 9507, 4108, 3880, 8023, 1200, 12243, 0, 5282, 0, 0, 65032, 5891, - 65031, 3343, 1636, 195057, 65029, 65024, 3896, 195056, 9674, 2947, 99, - 98, 97, 120571, 64414, 13059, 8221, 64085, 3381, 0, 7892, 0, 10777, 0, - 65310, 3913, 0, 0, 64959, 8039, 1265, 4316, 6309, 118815, 12969, 12596, - 66595, 66596, 41939, 5593, 195059, 5998, 9163, 12300, 6061, 64854, 119, - 118, 117, 116, 8930, 122, 121, 120, 111, 110, 109, 108, 115, 114, 113, - 112, 103, 102, 101, 100, 107, 106, 105, 104, 41793, 917572, 534, 120515, - 0, 42027, 12114, 0, 917579, 0, 194698, 6020, 12716, 10561, 10075, 475, - 118888, 13266, 9144, 120383, 917580, 195088, 194741, 10645, 1212, 5079, - 0, 8134, 8483, 2913, 10330, 4908, 1866, 1639, 119189, 0, 8923, 1645, - 12059, 64505, 0, 194873, 0, 4817, 5935, 1250, 0, 8174, 9600, 9856, 9859, - 7916, 9861, 5343, 5258, 4328, 41206, 64794, 10882, 405, 0, 4659, 195045, - 657, 12610, 4970, 4461, 1134, 41170, 1454, 41242, 65130, 4468, 5987, - 195079, 9762, 4456, 5206, 10720, 0, 10480, 41718, 5818, 0, 8264, 10229, - 260, 645, 195054, 10687, 118837, 4821, 4466, 120500, 5824, 984, 0, 10688, - 5851, 5705, 7729, 41406, 10591, 41797, 119983, 65438, 119985, 119984, - 119979, 41404, 1165, 7879, 4451, 13087, 0, 195067, 119987, 119986, 41909, - 118902, 2791, 9363, 9552, 3375, 0, 5900, 12997, 7889, 2722, 0, 13173, - 2381, 12883, 10994, 10529, 12437, 194756, 8644, 63791, 12425, 10661, - 10856, 9614, 0, 41478, 0, 10064, 10901, 10748, 120542, 11005, 4868, - 119162, 1952, 0, 8455, 10082, 0, 8467, 12577, 194760, 5182, 12183, 6145, - 119188, 64929, 4465, 42120, 12135, 5732, 4464, 7728, 3922, 977, 4458, 0, - 195068, 64770, 120772, 3353, 344, 0, 41626, 1395, 64635, 120089, 5776, - 8558, 786, 65153, 0, 64340, 120082, 10202, 120084, 41027, 120086, 10132, - 64413, 120087, 120074, 119119, 120059, 0, 120078, 63862, 41896, 8657, 0, - 8594, 10204, 0, 120477, 120069, 120072, 1399, 119203, 120056, 0, 8852, - 64492, 241, 194759, 4907, 0, 9738, 0, 9727, 7851, 119196, 10951, 4439, 0, - 119199, 195021, 9085, 0, 119200, 9327, 6160, 0, 8650, 64865, 8088, 64933, - 41910, 118872, 65217, 3965, 120050, 0, 0, 13300, 0, 0, 65491, 65145, - 9041, 0, 65017, 10826, 4420, 41263, 10583, 7760, 194798, 0, 0, 120047, - 13217, 8748, 65415, 0, 42159, 9066, 194860, 11993, 0, 2626, 7762, 10902, - 0, 0, 41526, 64285, 10472, 2995, 120704, 12907, 41184, 2371, 0, 10038, - 259, 1009, 0, 2402, 2333, 65011, 0, 12962, 65125, 0, 12417, 65380, 9103, - 12700, 3148, 0, 119145, 7779, 10219, 0, 9479, 6029, 120369, 119910, 9689, - 41261, 0, 8993, 8613, 0, 118989, 3368, 606, 41492, 7697, 10228, 41596, - 4311, 194769, 6027, 120572, 4322, 41661, 7991, 0, 10578, 0, 41465, 41054, - 2735, 41664, 0, 63778, 65273, 1287, 65408, 9348, 120656, 6164, 0, 41273, - 0, 65027, 0, 9576, 0, 3347, 4160, 5154, 0, 3794, 66564, 65219, 11925, - 7709, 9088, 3743, 65099, 1396, 4572, 0, 3847, 0, 65081, 4985, 1615, 672, - 809, 12980, 63806, 0, 65218, 5799, 0, 65072, 1577, 194934, 0, 5928, 4525, - 10658, 120561, 1266, 0, 0, 195024, 12622, 9347, 0, 0, 64424, 41048, 7789, - 773, 63910, 41112, 283, 64416, 66374, 532, 0, 120049, 41115, 3051, 5862, - 3370, 0, 119132, 5443, 3250, 8153, 0, 120278, 9510, 120279, 120493, 9541, - 0, 41066, 64706, 0, 0, 3505, 8707, 9466, 64286, 8537, 120802, 3626, 3471, - 0, 915, 195094, 12990, 120034, 0, 118797, 195074, 0, 41906, 0, 195072, 0, - 64365, 0, 3225, 0, 4433, 5186, 0, 41933, 1443, 4381, 9829, 65124, 10926, - 0, 195076, 64879, 64699, 0, 65476, 0, 0, 10021, 5160, 1387, 65495, 6103, - 120388, 41480, 0, 0, 217, 0, 0, 12466, 10443, 10789, 41158, 41460, 0, 0, - 41483, 195096, 12565, 64287, 10077, 12890, 5931, 195014, 9283, 7700, - 41252, 6042, 65499, 0, 41249, 512, 2990, 0, 0, 65456, 0, 632, 12940, 0, - 41296, 9545, 41291, 5957, 0, 8926, 3511, 41282, 5923, 10400, 10174, - 41456, 64581, 5386, 4274, 5786, 10633, 0, 5056, 119860, 417, 41474, - 120773, 13263, 9812, 5934, 4460, 66583, 119231, 64877, 65410, 64481, 0, - 0, 10937, 0, 120218, 0, 0, 0, 2953, 5819, 1801, 12835, 917627, 0, 194743, - 0, 66375, 8867, 702, 120410, 1237, 10274, 4552, 65447, 119966, 0, 1375, - 12106, 194693, 10264, 1755, 10482, 9228, 10376, 1163, 2951, 7840, 64336, - 64890, 10252, 0, 3384, 120703, 10167, 830, 194656, 65425, 10769, 8451, - 41368, 12520, 9753, 120762, 8944, 0, 0, 10473, 2908, 0, 0, 64902, 10299, - 119165, 12097, 64733, 12952, 4441, 10503, 0, 41430, 9330, 0, 10267, 411, - 10315, 10379, 0, 0, 13281, 10009, 7865, 2730, 10388, 9677, 5428, 118993, - 3364, 64806, 66363, 119179, 118816, 65463, 9535, 216, 10332, 1401, - 119895, 622, 0, 885, 64772, 1602, 4467, 41405, 5768, 0, 12160, 41328, - 484, 65187, 41051, 12071, 9609, 9806, 41497, 3338, 0, 120671, 10411, - 2736, 10255, 10263, 10279, 2794, 8807, 64491, 119896, 4315, 5222, 5381, - 0, 0, 5193, 5125, 5456, 5509, 41177, 0, 9534, 0, 64431, 1603, 3430, 0, - 10298, 0, 0, 981, 41176, 4330, 994, 120536, 1824, 10908, 0, 41681, 41683, - 5921, 194925, 2597, 3957, 5922, 118903, 0, 674, 194971, 0, 2946, 5354, - 5251, 4406, 5307, 3759, 65160, 8364, 5123, 1433, 5281, 5469, 5121, 5924, - 5920, 0, 5130, 64606, 0, 0, 8418, 41420, 1221, 2733, 0, 742, 5216, 2893, - 10772, 65276, 5937, 3468, 2553, 9230, 5939, 3997, 0, 8363, 120677, 2993, - 7772, 3916, 10289, 194932, 1141, 120301, 8159, 718, 10137, 973, 9666, - 120718, 3235, 2415, 5938, 0, 8018, 12448, 0, 10401, 10337, 0, 0, 65390, - 0, 8719, 1202, 0, 64651, 12983, 0, 12165, 119095, 0, 9067, 13116, 8077, - 65388, 0, 8419, 63773, 65419, 63774, 0, 0, 10725, 10433, 0, 0, 1431, - 64519, 66565, 10821, 4359, 12804, 12192, 8229, 1235, 3307, 41928, 0, - 3146, 4544, 9009, 8551, 118820, 1740, 194749, 65469, 985, 2724, 13076, - 120806, 12068, 119949, 515, 10141, 119944, 119945, 63763, 4476, 119146, - 119941, 12655, 8907, 13226, 4589, 4521, 119077, 9141, 64645, 10665, 2741, - 41572, 6197, 1370, 10101, 41573, 194746, 3931, 194924, 0, 6184, 8606, - 3303, 11968, 65475, 9473, 13103, 63771, 8879, 41390, 120600, 4478, - 917588, 41735, 120349, 717, 10754, 4477, 0, 814, 42066, 119962, 63767, - 1780, 41031, 119958, 41392, 819, 10611, 9694, 11955, 119952, 119953, - 41111, 9462, 0, 7788, 12820, 66327, 66580, 0, 118966, 0, 1581, 12650, - 41173, 3346, 430, 64698, 0, 66628, 268, 0, 4945, 0, 4950, 12918, 9456, - 10923, 5936, 0, 5964, 12908, 13081, 308, 0, 12933, 0, 41746, 4949, 0, - 443, 41030, 4944, 5467, 194938, 5926, 1862, 6044, 65392, 8820, 4946, - 194793, 9038, 7887, 0, 7830, 41306, 13093, 2698, 41144, 0, 12072, 41753, - 41914, 41304, 824, 0, 8595, 65225, 119813, 119816, 4673, 41354, 4678, - 13283, 12697, 65059, 12381, 3488, 5933, 5481, 3490, 1199, 65014, 8356, - 12297, 119153, 1955, 12688, 3102, 10474, 4672, 119822, 119821, 5531, - 119823, 119826, 66332, 8835, 4674, 119041, 5831, 0, 64896, 12379, 8025, - 119947, 64542, 1855, 65128, 5472, 64425, 7852, 194993, 119943, 0, 0, - 2745, 5470, 65171, 9124, 119110, 4654, 65289, 291, 0, 120285, 10525, - 4649, 65209, 120284, 12647, 4648, 4640, 64713, 10224, 120429, 6246, - 64950, 7828, 4650, 41464, 0, 119086, 4653, 7822, 120331, 118824, 120330, - 8669, 194921, 10729, 65093, 5778, 6302, 2716, 194606, 12680, 119130, - 1417, 10916, 0, 9452, 8547, 2711, 42165, 120798, 64953, 7992, 64663, - 41907, 4662, 65453, 120408, 9149, 9146, 599, 4641, 11990, 64819, 63782, - 4656, 10130, 41469, 7811, 40994, 12426, 4646, 5967, 865, 3725, 5713, - 5814, 4645, 42033, 120422, 41756, 13132, 64728, 9026, 10833, 64673, 1659, - 919, 41935, 1671, 195089, 3054, 9219, 9744, 1661, 13120, 4622, 119087, - 10140, 9713, 0, 119143, 194961, 9045, 2306, 10485, 118943, 6068, 10612, - 65307, 4617, 120294, 194964, 41462, 4616, 10518, 10423, 10359, 0, 5958, - 0, 9564, 4618, 826, 195083, 4321, 4621, 195084, 41313, 522, 5368, 1808, - 7848, 0, 5366, 12201, 5372, 0, 66632, 0, 4391, 64331, 2696, 120155, - 11003, 4638, 64490, 1790, 66304, 167, 10921, 9791, 0, 9840, 5376, 1835, - 5335, 10313, 41370, 4633, 64320, 10265, 1180, 4632, 118970, 5387, 5333, - 64256, 12903, 41, 5331, 1792, 11928, 64363, 5338, 4637, 0, 5971, 12066, - 120393, 385, 4152, 2585, 0, 10909, 3126, 1427, 194812, 10957, 5970, 3431, - 120394, 10358, 10422, 4758, 0, 1608, 2738, 12707, 10455, 4753, 0, 0, 0, - 6240, 5231, 119013, 12541, 65216, 6248, 0, 2593, 8463, 7810, 119923, - 5229, 4757, 65192, 66581, 2728, 4411, 64563, 65235, 5234, 119924, 194914, - 0, 10066, 9746, 0, 2622, 6033, 13061, 8016, 41196, 8954, 64831, 65189, - 2632, 13228, 10108, 1011, 5574, 1853, 2709, 65139, 5577, 42091, 41165, - 393, 12450, 8965, 41166, 42177, 5316, 0, 171, 5941, 5572, 120062, 5312, - 12531, 5525, 5330, 5319, 64066, 195100, 64647, 8937, 63798, 12454, 12291, - 42132, 12063, 0, 64343, 3230, 0, 10350, 10644, 5209, 297, 5721, 12109, - 8415, 8632, 10102, 119925, 0, 2497, 5720, 960, 1692, 118792, 4610, 8696, - 4292, 64760, 4609, 10512, 4614, 541, 0, 5287, 5309, 2503, 119243, 1762, - 4647, 56, 10743, 5844, 41381, 601, 4613, 10194, 4663, 64469, 4608, 2507, - 13273, 5190, 119963, 63759, 195010, 66357, 8892, 0, 119942, 119931, 2734, - 5782, 420, 64368, 63795, 65105, 10797, 5960, 63797, 8992, 65293, 41238, - 1782, 12814, 63852, 12525, 10686, 41383, 5501, 0, 3650, 119955, 120749, - 359, 4183, 119957, 6239, 41670, 41256, 329, 66582, 12573, 120462, 0, - 9346, 66331, 13244, 119048, 42167, 3767, 5737, 5380, 4865, 0, 1155, - 917538, 5736, 4368, 64724, 63749, 0, 5601, 5739, 41023, 4866, 9985, 7987, - 64406, 1172, 120563, 0, 6253, 0, 8574, 5603, 41666, 4473, 119847, 4870, - 0, 65347, 41799, 65345, 8199, 0, 5347, 119063, 9280, 4864, 10398, 4144, - 0, 120567, 6245, 120478, 2732, 5598, 745, 4555, 5341, 0, 4777, 0, 5351, - 0, 0, 65244, 120729, 195080, 3097, 63817, 5966, 120363, 4778, 0, 10863, - 1660, 4781, 0, 271, 0, 65370, 8577, 65368, 12653, 65366, 10216, 4782, - 10000, 65362, 65361, 11912, 12325, 65358, 8717, 41583, 65355, 4776, - 65353, 65352, 8700, 65350, 65349, 10575, 10426, 0, 120150, 10362, 0, - 1715, 4849, 8242, 9561, 0, 0, 0, 0, 0, 5963, 0, 0, 4916, 4850, 380, 1607, - 466, 4853, 0, 4854, 0, 5164, 41096, 1350, 5124, 64420, 0, 5362, 8471, - 2708, 119131, 7946, 3785, 234, 0, 120481, 41268, 4848, 2530, 41636, 4798, - 1225, 41842, 0, 10458, 0, 8576, 5197, 0, 2704, 4794, 8329, 63823, 8322, - 4797, 66326, 5725, 2694, 2595, 3363, 2439, 65104, 5607, 41089, 303, - 41162, 195037, 2665, 2437, 0, 9817, 4844, 8764, 0, 8934, 0, 0, 4492, 0, - 9843, 2441, 10739, 65090, 1188, 120290, 1100, 2451, 2714, 41081, 2912, 0, - 4937, 119104, 0, 3572, 10023, 12343, 13079, 9248, 0, 9729, 0, 65190, - 119094, 2726, 3107, 0, 4941, 7996, 10995, 9140, 1408, 5261, 0, 41451, - 181, 0, 4942, 63801, 4938, 0, 972, 5259, 9369, 64868, 4142, 5257, 0, 0, - 4964, 5264, 9538, 0, 0, 41225, 0, 63800, 0, 119058, 9482, 4873, 3265, - 1822, 0, 12601, 41078, 3865, 261, 5927, 7791, 0, 0, 0, 10696, 9830, 6073, - 389, 10893, 6255, 6075, 4872, 282, 0, 3125, 9567, 195012, 4878, 5459, - 4874, 0, 9557, 3474, 64774, 120356, 194704, 6081, 9563, 9411, 13139, 0, - 11940, 41744, 0, 10788, 119176, 8751, 10385, 120273, 7816, 9414, 4665, - 12628, 4670, 119871, 41555, 0, 9642, 10912, 958, 119853, 3082, 0, 4666, - 0, 4915, 0, 2891, 5856, 12096, 5163, 4664, 10836, 1817, 120010, 12231, - 41554, 10564, 7763, 13077, 42099, 4400, 9697, 3606, 10275, 8925, 10371, - 10307, 1063, 10227, 120251, 9772, 4541, 6299, 1389, 0, 120257, 9823, - 42081, 12941, 65197, 10520, 120255, 120256, 12301, 120266, 10505, 120268, - 66604, 120262, 66601, 41814, 13282, 66600, 523, 505, 1447, 846, 0, 41813, - 0, 8608, 120537, 65482, 2543, 12163, 3108, 9745, 4529, 120472, 64764, - 118825, 7919, 0, 1641, 119874, 64949, 8966, 10251, 10247, 5908, 715, - 64353, 0, 9453, 1699, 10943, 10763, 0, 118992, 550, 10169, 0, 64385, - 66579, 3766, 120457, 5780, 9504, 9051, 257, 10373, 13153, 12061, 10261, - 10253, 7821, 2599, 9433, 11984, 9156, 5930, 120377, 0, 0, 3128, 4789, - 5067, 5066, 3760, 1718, 9438, 8827, 1146, 5065, 41435, 4352, 0, 2435, - 41839, 5064, 5326, 120453, 3778, 1809, 8873, 7824, 41434, 5062, 1264, - 64817, 41586, 41440, 3764, 8473, 64716, 8469, 3933, 12947, 4564, 12337, - 0, 10375, 0, 120362, 64768, 0, 0, 5225, 0, 42130, 7903, 5151, 0, 0, - 64685, 5626, 2569, 0, 3800, 65424, 0, 0, 5353, 5625, 10894, 954, 64927, - 1010, 41043, 0, 41438, 41439, 120357, 10711, 4593, 120752, 119003, 2590, - 5629, 13309, 10293, 10325, 5632, 10471, 120038, 64759, 42054, 5166, 5628, - 120031, 970, 120029, 4772, 2400, 5627, 118972, 120018, 12885, 3119, - 120021, 10961, 65103, 203, 9986, 0, 64344, 636, 120550, 120652, 64378, - 42111, 64356, 0, 554, 120761, 8320, 64275, 8863, 120520, 42042, 41883, - 63803, 0, 120792, 5694, 7689, 42142, 9323, 4325, 3047, 3937, 175, 195077, - 3169, 64335, 64781, 912, 1243, 4536, 5431, 120005, 0, 6244, 120154, 0, - 3935, 120665, 1129, 0, 11950, 5392, 118859, 7846, 118806, 5397, 0, 12046, - 12599, 3845, 4490, 5395, 0, 5393, 354, 120544, 11977, 0, 8366, 0, 7756, - 3901, 65484, 51, 626, 41602, 5895, 9568, 64057, 456, 0, 8145, 1168, 9251, - 9082, 119964, 64055, 0, 3866, 8818, 41512, 0, 0, 10324, 3918, 5377, 3797, - 1644, 10405, 9658, 4140, 13057, 42029, 42037, 9030, 813, 119973, 41454, - 4146, 195036, 5360, 2466, 236, 195032, 0, 6249, 42117, 5898, 0, 41457, - 119148, 5855, 1969, 4911, 988, 0, 12838, 64483, 0, 10341, 10552, 65479, - 5854, 0, 0, 118933, 119989, 119940, 10416, 11981, 3872, 0, 0, 120725, - 6093, 0, 2838, 119939, 0, 170, 0, 13143, 4169, 118931, 41859, 6058, - 120813, 10553, 1662, 65295, 0, 64342, 5892, 195081, 0, 42106, 66, 65, 68, - 67, 70, 69, 72, 71, 74, 73, 76, 75, 78, 77, 80, 79, 82, 81, 84, 83, 86, - 85, 88, 87, 90, 89, 4736, 10357, 120400, 8170, 1704, 8556, 120661, 9659, - 120403, 1743, 120512, 9556, 9496, 4503, 41977, 9647, 7876, 0, 120575, - 3928, 11948, 65283, 10706, 66562, 66308, 4842, 7771, 0, 9109, 4841, 1289, - 4171, 12008, 6251, 3923, 1490, 2447, 120347, 0, 10907, 5245, 0, 10114, - 64000, 9790, 4845, 8332, 10582, 0, 4840, 5675, 254, 1747, 65429, 4825, - 10626, 8918, 10281, 5716, 64004, 66594, 0, 119019, 0, 8080, 118895, 367, - 1472, 120386, 0, 4829, 64693, 5905, 12339, 8919, 9515, 120384, 194651, - 65266, 0, 4830, 9134, 41365, 64671, 41978, 1412, 4594, 1391, 10536, 7720, - 4824, 7775, 0, 120392, 0, 1960, 3140, 0, 7960, 41836, 41844, 6052, 6064, - 54, 1428, 12214, 0, 6211, 7699, 358, 0, 10557, 65161, 10758, 8223, - 120341, 4261, 12642, 0, 120343, 0, 0, 119053, 120382, 119055, 119054, - 194902, 64554, 10574, 3878, 4017, 12827, 1752, 0, 0, 41118, 3924, 10199, - 0, 64966, 0, 0, 0, 41116, 720, 324, 0, 120684, 12057, 11917, 1464, 41343, - 4721, 7974, 65407, 8957, 0, 64488, 120371, 0, 64041, 195058, 120091, 0, - 4722, 917617, 0, 0, 4725, 9690, 4726, 0, 194956, 119843, 118969, 5204, 0, - 0, 118851, 4015, 3995, 8052, 476, 3714, 10073, 3595, 10232, 10999, 1382, - 120558, 12636, 0, 120404, 1656, 41831, 8130, 8672, 8832, 8720, 3908, - 1452, 13111, 64523, 64067, 0, 8552, 12398, 41845, 3849, 0, 0, 9778, 468, - 612, 42150, 55, 118959, 0, 0, 1674, 120277, 5823, 120276, 1114, 42110, - 540, 120052, 119017, 12516, 41743, 3938, 120057, 65417, 64316, 120060, - 12400, 820, 41741, 6292, 65303, 7955, 64074, 4713, 3359, 7800, 41566, - 65177, 6226, 353, 719, 9656, 9474, 64742, 120043, 4532, 65412, 120046, - 10868, 4717, 2349, 5902, 0, 4712, 9481, 119012, 65400, 3623, 8155, 1195, - 3942, 4714, 9625, 41151, 0, 41589, 12006, 0, 12074, 12409, 0, 4360, - 12964, 9739, 1229, 63793, 0, 0, 0, 8539, 65100, 120508, 4809, 9623, 4788, - 0, 0, 64745, 0, 65405, 120104, 13075, 194866, 5365, 4545, 8901, 8000, - 2492, 4813, 65432, 0, 5925, 4808, 64330, 9649, 41154, 65030, 5128, 4038, - 12718, 4810, 64859, 12794, 64928, 1648, 5435, 3522, 120689, 414, 10236, - 0, 12709, 41359, 120494, 0, 11905, 41082, 119859, 12581, 10374, 5175, - 119857, 0, 10254, 63820, 9751, 10262, 64088, 41363, 3919, 607, 0, 120288, - 9018, 5270, 10314, 10282, 65477, 10378, 64310, 40976, 8265, 7737, 0, - 40975, 5840, 0, 10162, 40978, 0, 8454, 42072, 42038, 387, 119098, 119083, - 0, 2550, 0, 119836, 118971, 41344, 3525, 120297, 0, 64641, 41590, 5619, - 41346, 13157, 375, 12703, 0, 5616, 64943, 64324, 0, 119202, 9454, 5615, - 0, 2315, 0, 1938, 5455, 64752, 808, 5568, 119201, 119198, 1026, 5620, - 194887, 195078, 13150, 5617, 0, 9225, 64639, 12902, 9145, 64595, 1338, - 120352, 119178, 9863, 0, 3084, 64553, 0, 41025, 6037, 0, 3974, 7998, - 10290, 10888, 3083, 10322, 2316, 118821, 64297, 41036, 0, 917615, 0, 0, - 0, 12904, 5373, 194773, 64700, 3762, 1445, 40961, 0, 11986, 0, 40960, 0, - 3780, 12808, 5779, 64952, 10402, 12011, 3906, 9707, 10603, 8326, 0, - 65498, 3763, 194923, 5618, 0, 3779, 194922, 9324, 118852, 63822, 9073, 0, - 64302, 10704, 280, 4787, 0, 917556, 13072, 9999, 0, 0, 9570, 0, 8699, - 2689, 917626, 65426, 0, 42135, 119061, 2551, 40966, 10011, 10200, 3998, - 120448, 120788, 503, 0, 4470, 2690, 118853, 7780, 5369, 41954, 5249, - 1652, 772, 8756, 8310, 65428, 3487, 120585, 3585, 1688, 917610, 119159, - 41822, 194874, 65359, 41904, 9720, 41697, 41319, 13125, 10650, 5836, - 12358, 4668, 4355, 9048, 1465, 10850, 3943, 65025, 41205, 41315, 41488, - 0, 917601, 5352, 12362, 12435, 8839, 41053, 3266, 7785, 12356, 8616, - 12104, 0, 0, 194621, 0, 3638, 5420, 3897, 3216, 0, 2358, 4018, 8633, - 2850, 0, 9639, 0, 0, 0, 64630, 65427, 3542, 120023, 12076, 5303, 8078, - 12676, 64418, 6276, 1706, 0, 41819, 41422, 12943, 65150, 10792, 41484, - 194607, 10847, 41050, 8872, 41824, 13099, 0, 0, 120378, 8504, 10830, 0, - 615, 10668, 10139, 0, 10504, 9779, 3625, 64650, 41409, 0, 41425, 65087, - 41688, 8789, 41427, 4022, 0, 0, 0, 120355, 41424, 917598, 0, 41820, 0, - 65292, 4812, 1261, 0, 3911, 12102, 120727, 1033, 0, 64642, 0, 3904, - 119205, 10514, 3275, 0, 0, 13123, 10846, 0, 118936, 195029, 12138, 10989, - 0, 6233, 10598, 449, 2669, 903, 118997, 2920, 9636, 65240, 10738, 0, - 9367, 593, 41085, 3917, 64622, 41713, 64307, 0, 41448, 3596, 0, 0, 9763, - 64082, 8819, 12347, 124, 12981, 41113, 232, 12234, 120646, 0, 0, 10820, - 194978, 0, 9094, 1769, 41715, 2463, 0, 1064, 13307, 41976, 10115, 64482, - 0, 0, 7862, 7795, 1474, 8516, 4828, 1258, 118994, 0, 0, 0, 9498, 0, 2911, - 120289, 41178, 3939, 64823, 8846, 8943, 12617, 41174, 2650, 4491, 1961, - 41463, 64291, 41167, 1959, 775, 120311, 41732, 41016, 6074, 9618, 194903, - 1511, 3613, 0, 4259, 41436, 3656, 0, 65436, 41019, 12428, 0, 0, 194896, - 8514, 8513, 9054, 1613, 41828, 0, 65531, 0, 118879, 0, 0, 5741, 10145, - 8865, 64551, 120379, 5788, 7917, 0, 66622, 7733, 64359, 9558, 120375, 0, - 120376, 0, 4268, 41247, 120524, 120370, 3871, 194892, 10881, 9111, 10621, - 41696, 65462, 120366, 119111, 120745, 9765, 120368, 0, 0, 42118, 10321, - 65281, 41587, 10949, 0, 42107, 0, 0, 5416, 10802, 195050, 66318, 65298, - 0, 5685, 0, 12633, 7928, 120354, 8094, 41595, 120510, 0, 794, 194907, - 12656, 10355, 64665, 5274, 1665, 41598, 3993, 194909, 64512, 40971, 536, - 189, 12611, 119234, 0, 2859, 4838, 63838, 4834, 2338, 0, 194839, 4837, - 41944, 770, 41452, 811, 1687, 41042, 66620, 120730, 64427, 64326, 40969, - 10526, 3895, 5406, 40968, 1339, 0, 120473, 10193, 3116, 7747, 0, 8020, - 10843, 41012, 12825, 0, 8266, 41006, 12371, 2871, 64614, 41245, 999, - 119129, 64567, 41876, 2663, 64586, 0, 120651, 120687, 10150, 65367, - 64308, 1522, 597, 4775, 10917, 12571, 10448, 12583, 12560, 12558, 12556, - 12584, 1741, 65097, 1227, 9676, 12566, 12569, 12554, 0, 10812, 1586, - 4978, 0, 3078, 1402, 118924, 9391, 40984, 9379, 9372, 394, 3088, 6284, 0, - 41663, 3991, 64391, 0, 9237, 424, 41648, 41208, 0, 9384, 41076, 1830, 0, - 0, 41656, 8246, 120307, 0, 0, 41840, 0, 2377, 41676, 0, 12572, 12552, - 12557, 12559, 5479, 2796, 1003, 2373, 9446, 9447, 9448, 48, 0, 9480, 481, - 2359, 9125, 9439, 9440, 9441, 548, 9153, 9444, 9445, 9430, 9431, 9432, - 397, 9434, 9435, 3984, 9437, 0, 1614, 9424, 9425, 9426, 9427, 1358, 9429, - 428, 9620, 9655, 0, 10982, 9096, 1333, 65170, 407, 12299, 0, 0, 5955, - 194985, 1108, 5804, 11976, 41231, 41466, 64782, 3926, 9057, 64613, 8798, - 0, 0, 1392, 8250, 10952, 5986, 5985, 8065, 41326, 10353, 10417, 0, 0, - 4407, 64524, 4019, 0, 118919, 8448, 8219, 118914, 1812, 12675, 12659, 0, - 194823, 119167, 42172, 42068, 6054, 10697, 2386, 0, 41759, 10642, 3909, - 64585, 10296, 41763, 119171, 42051, 64862, 4164, 1049, 0, 120569, 11943, - 41806, 8709, 10606, 3921, 120637, 64691, 41985, 8994, 1038, 120373, 8470, - 0, 0, 4008, 0, 8773, 10733, 36, 0, 5153, 41805, 13097, 0, 64937, 8736, - 1414, 64495, 9683, 0, 0, 0, 2536, 119951, 66330, 0, 8621, 65157, 12852, - 3031, 120441, 41345, 66317, 182, 66315, 66316, 0, 10210, 120492, 9058, - 366, 0, 120102, 961, 63755, 10848, 4570, 65301, 3106, 0, 41284, 1696, - 41189, 4003, 12105, 0, 5766, 12802, 3264, 8824, 13268, 0, 10936, 63980, - 0, 0, 194604, 120523, 0, 2322, 917561, 65506, 8300, 120374, 917536, - 41285, 3547, 120144, 8112, 0, 41459, 41369, 6089, 13000, 0, 12117, 4170, - 1029, 10540, 12315, 9063, 0, 120666, 744, 0, 12897, 3792, 4926, 917623, - 6065, 3551, 0, 0, 4623, 41186, 41816, 4598, 41818, 12795, 5968, 7922, - 12614, 10851, 8523, 6179, 119066, 6180, 1863, 4710, 0, 5956, 11972, - 41290, 0, 4705, 716, 177, 120831, 4704, 12360, 120270, 64719, 161, 9020, - 120272, 0, 4706, 10646, 0, 120037, 4709, 10680, 8754, 0, 120237, 120245, - 119164, 0, 41377, 9136, 1700, 4401, 41280, 194711, 8974, 4004, 0, 10634, - 41791, 2318, 8506, 66361, 8198, 42022, 1005, 937, 118996, 4734, 2870, - 41277, 12319, 66619, 5404, 4729, 3667, 235, 1384, 4728, 41049, 120420, - 120644, 120017, 8109, 120020, 119920, 4730, 447, 13186, 1513, 4733, 8664, - 63978, 0, 120252, 12911, 9665, 1383, 8565, 2469, 120024, 12663, 6156, - 120417, 0, 0, 4288, 120225, 2674, 13238, 11922, 41145, 41468, 3510, - 13234, 41148, 8683, 5605, 42095, 10497, 12221, 1380, 12314, 41146, - 118964, 13196, 13197, 3512, 120682, 9495, 8103, 0, 5959, 65184, 0, 41563, - 0, 120028, 41925, 13205, 13211, 5801, 41923, 0, 120316, 1283, 120302, - 4779, 7988, 3719, 4006, 3271, 66569, 64711, 8355, 118799, 8842, 0, 64870, - 13070, 0, 3875, 5962, 1095, 120106, 3599, 119149, 5827, 0, 7787, 0, - 65494, 120816, 64565, 0, 4773, 64531, 64034, 0, 0, 12785, 42043, 65467, - 119227, 0, 42046, 9742, 521, 65136, 10800, 41473, 8404, 917595, 483, 0, - 1450, 12986, 928, 0, 65441, 0, 10599, 0, 3989, 10971, 120431, 5771, 9841, - 8843, 12145, 119950, 119959, 194856, 9807, 3769, 41190, 3973, 119105, - 4575, 9573, 7982, 429, 8849, 0, 0, 41771, 1796, 118918, 118968, 194853, - 8164, 41301, 3502, 0, 0, 0, 4919, 10590, 5825, 7755, 0, 0, 64548, 12661, - 1621, 10214, 10418, 41962, 0, 41971, 1409, 12195, 1617, 3112, 10824, - 42101, 1390, 64403, 0, 421, 1756, 5846, 0, 8666, 120132, 0, 120360, - 42174, 3630, 5408, 2817, 1214, 119000, 120124, 10218, 41769, 3168, 0, - 42134, 7957, 2370, 2846, 1056, 119070, 12798, 0, 120314, 1836, 8757, 0, - 12327, 3740, 119028, 5622, 65374, 41765, 2341, 3944, 8484, 8474, 120817, - 120433, 3118, 8461, 41942, 12153, 5621, 12799, 8127, 8975, 9451, 7943, - 13073, 12169, 10618, 681, 0, 703, 120812, 3272, 8781, 12894, 0, 12223, 0, - 6204, 0, 0, 8279, 8776, 64954, 3276, 0, 65222, 4267, 194627, 41325, 0, - 64795, 0, 12171, 10047, 9710, 3262, 0, 0, 0, 42020, 118788, 163, 3877, - 10495, 1655, 5842, 12479, 3122, 0, 7793, 0, 9328, 64352, 10039, 6003, - 42094, 5623, 0, 5717, 3986, 0, 0, 8912, 64555, 41858, 64078, 0, 3627, - 4523, 194836, 12241, 8540, 12993, 8887, 4574, 41040, 2459, 64886, 13060, - 41041, 8946, 10348, 10412, 5718, 0, 10450, 8147, 13221, 66329, 120353, - 3765, 119885, 0, 1606, 120348, 120351, 3093, 119126, 4619, 10600, 119247, - 7712, 0, 4312, 41918, 120337, 10128, 11923, 4023, 41892, 5763, 120335, - 4827, 2401, 12810, 8792, 120346, 4455, 7826, 433, 120342, 0, 2499, 41812, - 12886, 0, 11973, 13089, 4293, 10300, 10161, 10396, 12196, 66322, 66630, - 0, 0, 3010, 5817, 120604, 1458, 3120, 9797, 9643, 0, 4984, 10389, 120111, - 9100, 0, 0, 0, 1061, 4699, 9115, 3509, 0, 486, 4290, 120201, 0, 0, 0, - 1045, 120361, 5631, 10380, 9626, 2380, 0, 0, 120678, 2376, 8486, 0, 9824, - 2335, 4362, 12174, 0, 2366, 1025, 0, 12634, 120760, 0, 41443, 120732, 0, - 64035, 9711, 1523, 0, 5058, 41445, 120058, 0, 8567, 41442, 3988, 0, 0, - 1847, 0, 10403, 8564, 65385, 65076, 65117, 0, 0, 0, 12616, 0, 6256, 0, - 12671, 0, 10206, 118974, 0, 2673, 11960, 5820, 0, 4488, 194740, 7926, 0, - 10444, 42137, 120787, 2754, 9850, 0, 4487, 13192, 41957, 1032, 65530, - 1711, 0, 120067, 3114, 614, 0, 118938, 119261, 0, 926, 120822, 0, 0, 0, - 0, 10832, 0, 1050, 41798, 41035, 0, 9314, 41801, 119088, 120616, 520, - 10437, 12699, 8331, 0, 3091, 41034, 0, 2307, 8360, 10097, 0, 321, 41028, - 64543, 0, 0, 0, 0, 2861, 10360, 10095, 0, 66307, 440, 1861, 13085, 9233, - 0, 64532, 0, 119158, 12123, 0, 3859, 10570, 41660, 8209, 0, 118841, - 10910, 0, 1521, 7875, 41658, 10487, 0, 5760, 13011, 743, 4414, 120766, - 120628, 0, 5243, 9849, 5239, 0, 0, 1405, 5237, 0, 65112, 10103, 5247, - 4769, 42063, 5508, 120829, 5764, 0, 3513, 3008, 9378, 0, 194960, 10125, - 120686, 41103, 9394, 13225, 1397, 120548, 65365, 119093, 4770, 0, 9392, - 8731, 65378, 12079, 120619, 12682, 9122, 0, 4774, 3019, 9997, 12834, 0, - 1099, 10490, 120547, 1340, 9390, 0, 0, 464, 4281, 4768, 9385, 0, 1346, - 9017, 917631, 12087, 64516, 423, 1818, 65144, 0, 8272, 0, 66324, 120676, - 3087, 64960, 10111, 65181, 64707, 0, 9584, 8214, 0, 0, 0, 9106, 118907, - 119248, 5806, 64750, 119195, 8243, 9123, 5709, 0, 265, 64409, 13255, - 12605, 0, 2752, 64626, 0, 1434, 59, 5637, 0, 0, 64897, 0, 41810, 42008, - 66305, 0, 41809, 10283, 41983, 64826, 917596, 1156, 8009, 3305, 3782, - 511, 41843, 0, 1014, 64360, 11906, 194676, 10835, 10157, 0, 1400, 10323, - 10685, 7702, 41211, 10387, 4453, 2440, 3758, 1150, 10547, 5700, 41213, - 118812, 65383, 2339, 64019, 5697, 41156, 63984, 9116, 120480, 0, 462, - 41841, 10493, 3862, 8129, 0, 0, 12864, 42065, 9845, 0, 8261, 5701, 9722, - 9581, 1385, 1426, 120474, 194943, 41872, 0, 41033, 8571, 194870, 13288, - 120108, 5167, 0, 1681, 12184, 1204, 3755, 11935, 7748, 8213, 3286, 8911, - 64712, 10744, 0, 990, 5647, 5726, 64915, 10377, 0, 194989, 5646, 195063, - 13253, 2851, 3945, 120096, 120119, 4373, 0, 64402, 9587, 1789, 5651, - 120097, 3100, 0, 5648, 64748, 118897, 0, 10205, 3545, 8190, 10016, 64616, - 0, 8479, 64312, 120118, 2368, 63993, 4419, 120460, 0, 3439, 1825, 1192, - 119166, 8891, 3080, 118836, 2347, 5430, 1140, 8990, 2848, 10159, 0, - 120212, 249, 0, 66623, 12191, 1815, 0, 890, 8883, 3267, 728, 42144, 995, - 0, 4410, 1041, 10576, 8102, 10099, 10343, 0, 8091, 558, 120110, 12273, 0, - 0, 12112, 0, 41389, 0, 65214, 5375, 10142, 8548, 8215, 3129, 10074, - 12913, 9005, 41856, 13242, 64891, 7725, 11938, 194757, 0, 8624, 5173, - 65348, 527, 0, 41894, 10327, 6277, 10608, 11915, 10010, 0, 3540, 41672, - 835, 2329, 0, 41029, 0, 7849, 12245, 5426, 4258, 63987, 41787, 5424, - 12016, 9699, 0, 5434, 0, 0, 8067, 6144, 0, 10311, 118977, 1404, 3095, - 64917, 120211, 3464, 494, 4819, 0, 65098, 10965, 956, 3672, 13112, 1498, - 194864, 0, 120667, 431, 10029, 65159, 0, 8761, 41537, 13171, 13096, 0, - 65108, 0, 9516, 1044, 5268, 0, 4954, 0, 4450, 120723, 0, 64358, 11946, - 356, 3477, 227, 10488, 13214, 382, 41940, 12295, 0, 66631, 0, 3020, - 120819, 120560, 2541, 0, 12364, 64934, 0, 1057, 957, 9110, 194974, 2743, - 0, 63965, 120463, 9097, 66571, 0, 8782, 3006, 776, 2524, 1592, 8573, 0, - 10924, 65164, 63941, 41593, 4397, 8952, 3856, 118818, 0, 5872, 65377, 0, - 917620, 0, 1698, 0, 64477, 5413, 3953, 1053, 120827, 65094, 11994, 4339, - 1052, 1051, 459, 1060, 0, 194647, 65299, 0, 5228, 0, 7868, 689, 12984, - 4163, 0, 8639, 0, 65226, 65510, 1162, 12130, 2671, 0, 8095, 64375, - 119005, 42178, 4553, 0, 0, 195005, 0, 195004, 0, 195003, 0, 194623, 4567, - 41891, 1926, 0, 119056, 4820, 8110, 10935, 194646, 194665, 5830, 119212, - 1377, 0, 4897, 12932, 9250, 8693, 4438, 0, 0, 1753, 194641, 6147, 917558, - 64621, 8833, 0, 0, 194644, 41428, 64596, 10719, 65440, 194669, 1413, - 194994, 65394, 802, 12141, 0, 5561, 10607, 10671, 2528, 41774, 41379, - 42023, 838, 5669, 120697, 844, 8036, 194891, 256, 0, 5583, 41987, 0, 0, - 5580, 65464, 2923, 10853, 5582, 10048, 0, 13069, 5795, 13158, 119006, - 195066, 6087, 120514, 41322, 12180, 0, 194640, 0, 0, 8894, 5370, 119997, - 194628, 1638, 10966, 120491, 194630, 118848, 5733, 0, 64288, 0, 8172, - 42017, 5729, 10844, 194715, 64054, 9760, 0, 120121, 1238, 200, 0, 1062, - 119993, 194946, 118905, 0, 0, 1070, 9361, 0, 6095, 3394, 0, 3015, 0, 0, - 4037, 0, 119995, 65186, 66626, 7817, 1841, 13183, 12976, 120496, 372, - 1669, 10776, 63937, 7701, 41585, 64397, 119211, 1732, 276, 41862, 2828, - 33, 65326, 41768, 9007, 118796, 41588, 914, 427, 8071, 3538, 3900, 65321, - 41864, 1031, 6257, 65279, 41869, 0, 0, 2328, 917550, 1071, 41400, 194717, - 13249, 10841, 41627, 5301, 1047, 0, 5734, 8960, 120688, 8001, 10651, - 119970, 65012, 9663, 194990, 12304, 41621, 5711, 12921, 12098, 119244, - 9166, 12164, 5710, 119082, 194782, 65213, 12447, 10571, 0, 0, 0, 119108, - 5558, 0, 5715, 10915, 0, 12007, 3670, 2761, 11975, 0, 3074, 5722, 194876, - 8629, 0, 0, 4499, 2757, 4496, 9725, 0, 8910, 10689, 0, 12717, 0, 64730, - 0, 0, 0, 41630, 41640, 120143, 0, 118911, 4280, 13118, 8765, 12784, 7792, - 1393, 0, 8701, 119027, 8487, 8233, 0, 0, 0, 120009, 4495, 12144, 2841, - 12543, 0, 1473, 10992, 64329, 118984, 0, 120006, 9318, 357, 1048, 41100, - 0, 41104, 65457, 8035, 1054, 0, 1040, 65450, 5454, 4434, 1069, 0, 0, 0, - 0, 5084, 65402, 119133, 9693, 12354, 733, 41931, 41677, 41102, 4353, - 41674, 1059, 9218, 1731, 0, 0, 0, 194786, 41679, 8299, 0, 118833, 64390, - 0, 5155, 12786, 12787, 42122, 63998, 0, 41779, 0, 3587, 12131, 41432, - 10986, 66602, 9605, 64807, 12788, 194926, 41767, 3371, 0, 13114, 8771, - 3955, 41022, 0, 1109, 11000, 0, 65351, 9770, 9246, 12230, 64507, 8868, - 399, 65137, 41783, 41772, 64045, 12149, 2755, 551, 0, 10156, 4857, 0, - 4428, 2544, 65074, 0, 0, 0, 917612, 351, 5747, 12179, 194603, 7978, - 41092, 120731, 0, 11924, 0, 10712, 65015, 120733, 563, 64815, 0, 9013, - 5588, 57, 0, 10386, 65269, 119043, 5585, 0, 2549, 694, 0, 0, 5584, 8358, - 64717, 10238, 194919, 10919, 277, 7980, 0, 41815, 194920, 41800, 5589, - 41807, 2664, 12793, 5586, 1574, 10513, 0, 2525, 4852, 5749, 0, 41605, - 64696, 0, 1039, 9801, 10155, 5745, 188, 8135, 0, 10055, 120655, 9055, - 41853, 4858, 5657, 0, 436, 4771, 0, 0, 5654, 4856, 8051, 120799, 0, 0, - 5652, 10945, 0, 0, 0, 3661, 7863, 118834, 0, 41302, 0, 0, 5402, 10234, - 5843, 11939, 5655, 42157, 0, 3157, 1055, 917628, 0, 3504, 0, 0, 10822, - 5149, 41927, 10226, 41871, 0, 3594, 10272, 10304, 40, 12657, 594, 10244, - 386, 10256, 8834, 10816, 118866, 3467, 0, 0, 3331, 946, 10231, 1495, - 8131, 13179, 194752, 9562, 4304, 0, 8160, 0, 194753, 64529, 64656, 63995, - 1348, 12239, 64013, 5666, 13303, 10555, 194729, 119919, 9091, 10798, - 65230, 13269, 10195, 194931, 7732, 41905, 9793, 0, 6097, 5668, 8780, - 4982, 119883, 5670, 63969, 0, 194762, 2672, 3735, 5667, 13138, 120807, - 9484, 10724, 13203, 119024, 65258, 194933, 4361, 9487, 64314, 9286, 1497, - 195034, 1932, 12442, 6193, 3571, 13247, 0, 7973, 119157, 64821, 11964, - 41339, 7873, 63968, 119219, 553, 120653, 194690, 194857, 3604, 0, 4587, - 0, 0, 119020, 65149, 1962, 194861, 194696, 5633, 194862, 66337, 0, 0, - 64905, 12856, 5437, 65208, 10669, 8702, 7964, 63971, 9135, 199, 10976, - 4105, 63880, 194699, 194736, 194710, 12148, 13148, 194684, 0, 9226, - 120439, 12399, 10765, 5634, 4524, 12720, 4724, 0, 8407, 66323, 12224, - 120815, 0, 5221, 64348, 328, 7886, 0, 5448, 5636, 120071, 5329, 0, 5638, - 118839, 7940, 119076, 0, 65182, 5635, 3373, 2986, 118880, 194751, 3437, - 194832, 6203, 9833, 12693, 11920, 8274, 194838, 64394, 1657, 41558, - 194672, 118887, 5639, 2954, 5660, 5640, 65376, 194818, 194817, 194820, - 194819, 5297, 41637, 13284, 6112, 7968, 41625, 194737, 194738, 120507, - 41780, 5642, 0, 194827, 42181, 4342, 42039, 194831, 1677, 0, 4585, 5641, - 8259, 13301, 1058, 2719, 194625, 194638, 917587, 1144, 5868, 0, 10867, - 65169, 13277, 4308, 2539, 0, 65122, 543, 64916, 64736, 2547, 10209, - 119170, 65317, 5399, 65316, 0, 41633, 7902, 64932, 9000, 12233, 0, - 120315, 1865, 0, 5613, 194772, 12994, 65057, 5610, 0, 6228, 4307, 3482, - 42133, 10787, 194840, 2997, 506, 5609, 41194, 12863, 194776, 64412, - 41195, 2412, 8169, 8186, 8841, 9522, 516, 13130, 41197, 0, 34, 64007, - 10030, 5306, 1612, 120187, 120182, 64951, 120184, 12001, 10211, 120177, - 64564, 66365, 120174, 120173, 7749, 120175, 118898, 1758, 413, 10667, - 4677, 120197, 9133, 1935, 120194, 1042, 120196, 64779, 1931, 10248, 6185, - 64776, 1217, 10242, 708, 825, 118913, 0, 12294, 0, 194908, 9138, 2534, - 810, 12631, 194911, 0, 4424, 119255, 5591, 1239, 2364, 0, 917562, 3403, - 119193, 0, 64364, 0, 65250, 10027, 8998, 0, 0, 9152, 194952, 120191, - 2980, 119169, 41850, 931, 3433, 13170, 12615, 1594, 119937, 65397, 0, - 12944, 41623, 8730, 41353, 65409, 119009, 4337, 65188, 41394, 918, - 194899, 935, 7681, 194900, 377, 41393, 12668, 194904, 2477, 64301, 0, 0, - 0, 65201, 9528, 0, 12884, 194881, 7907, 194883, 120186, 194885, 65328, - 10673, 119217, 194889, 119128, 917575, 1781, 5496, 3357, 62, 1649, - 120641, 964, 119242, 65033, 194894, 0, 0, 65035, 194872, 65038, 0, 64602, - 119856, 0, 12220, 12711, 66575, 4542, 194875, 8423, 3348, 448, 120573, - 2991, 9364, 0, 997, 7949, 194918, 12849, 0, 0, 3073, 42000, 9714, 120679, - 4657, 12988, 4658, 65335, 12335, 119228, 65237, 6241, 2818, 4877, 2385, - 5463, 41897, 4172, 10052, 4409, 0, 10873, 12095, 0, 5346, 120328, 0, - 6237, 5461, 118803, 12722, 119999, 40974, 65231, 64828, 12678, 194868, - 8592, 1257, 0, 10970, 2408, 3251, 66617, 3274, 5465, 41501, 2461, 0, 0, - 5342, 8317, 194663, 194999, 3263, 120559, 8673, 194719, 3270, 64539, - 65338, 0, 120518, 0, 0, 5535, 9142, 0, 4289, 8687, 10938, 120658, 118790, - 1182, 2542, 186, 0, 119156, 5770, 529, 65196, 12612, 12949, 10586, 10790, - 10839, 8920, 5241, 41207, 0, 0, 41594, 225, 0, 5688, 41300, 41204, 0, - 118794, 10721, 41209, 9254, 42097, 1794, 41875, 65238, 5624, 266, 120221, - 120222, 41873, 3617, 120040, 41494, 119824, 8420, 13088, 120214, 10225, - 41338, 3734, 7734, 0, 5502, 66605, 4452, 41260, 0, 0, 4511, 5161, 10572, - 0, 42115, 42050, 64349, 41083, 0, 0, 0, 9003, 8192, 0, 5305, 9653, 10616, - 1697, 9546, 0, 194847, 119174, 41482, 65205, 10031, 64063, 12353, 12535, - 8620, 120207, 64058, 8799, 42131, 42031, 64062, 1028, 64060, 64059, 837, - 10567, 119960, 41606, 3176, 64773, 0, 2902, 64043, 64042, 41740, 3609, - 120577, 13200, 832, 64044, 42156, 10076, 64040, 64039, 12919, 1034, 3392, - 10753, 5180, 64033, 41395, 65468, 64038, 64037, 64036, 41898, 4291, - 63966, 64015, 41114, 243, 194930, 0, 6024, 194586, 12128, 194910, 3476, - 8973, 8538, 64011, 64010, 64008, 4285, 4800, 7706, 41750, 0, 2538, 64009, - 204, 0, 4802, 4111, 8239, 9098, 4805, 64001, 214, 7885, 42143, 8321, 0, - 12208, 4767, 9343, 64049, 64048, 0, 1133, 64053, 64052, 64051, 41187, - 8692, 6022, 119052, 10005, 12329, 41333, 0, 43, 1942, 0, 0, 41107, 12619, - 41121, 3885, 92, 64023, 64022, 64021, 64020, 0, 12451, 64025, 41412, - 41485, 12035, 119208, 6254, 10501, 64018, 8890, 12457, 66587, 194837, 0, - 64778, 118915, 194834, 120193, 0, 66637, 7995, 8759, 41411, 13094, 12449, - 8546, 41414, 65109, 3179, 0, 4720, 10165, 0, 119249, 0, 10751, 0, 12915, - 120180, 10535, 0, 0, 0, 6168, 10934, 1946, 294, 41874, 5494, 4639, 0, - 12040, 6196, 4498, 0, 64028, 64027, 41789, 41788, 2960, 118786, 118795, - 8969, 119887, 10197, 0, 119886, 2950, 11998, 6210, 119890, 370, 3549, - 64790, 7801, 4953, 119967, 0, 0, 3297, 10681, 120693, 1135, 194783, 0, - 5063, 3517, 2964, 119257, 0, 2552, 41546, 60, 10627, 8649, 8252, 729, - 120598, 0, 10541, 0, 64923, 41770, 41547, 9032, 0, 0, 119899, 41215, - 119897, 119898, 12832, 119904, 8081, 3761, 3537, 119908, 9137, 119906, - 8999, 65343, 3850, 3466, 4327, 0, 9373, 0, 908, 6282, 8611, 9813, 0, - 41655, 537, 41511, 4179, 8978, 120540, 119135, 1842, 10527, 120409, 9628, - 3848, 12081, 9826, 64502, 1767, 5336, 120200, 64659, 663, 194846, 10780, - 0, 13108, 120574, 120204, 120198, 120205, 347, 42112, 40992, 4100, 920, - 1811, 1355, 7739, 917547, 3592, 10078, 5318, 0, 0, 120073, 0, 6224, - 120470, 9381, 0, 64345, 0, 9281, 3296, 12865, 0, 0, -}; - -#define code_magic 47 -#define code_size 16384 -#define code_poly 16427 diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/xreadlinesmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/xreadlinesmodule.c deleted file mode 100644 index 81ed3049..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/xreadlinesmodule.c +++ /dev/null @@ -1,171 +0,0 @@ -#include "Python.h" - -PyDoc_STRVAR(xreadlines_doc, -"xreadlines(f)\n\ -\n\ -Return an xreadlines object for the file f."); - -typedef struct { - PyObject_HEAD - PyObject *file; - PyObject *lines; - int lineslen; - int lineno; - int abslineno; -} PyXReadlinesObject; - -static PyTypeObject XReadlinesObject_Type; - -static void -xreadlines_dealloc(PyXReadlinesObject *op) -{ - Py_XDECREF(op->file); - Py_XDECREF(op->lines); - PyObject_DEL(op); -} - -/* A larger chunk size doesn't seem to make a difference */ -#define CHUNKSIZE 8192 - -static PyXReadlinesObject * -newreadlinesobject(PyObject *file) -{ - PyXReadlinesObject *op; - op = PyObject_NEW(PyXReadlinesObject, &XReadlinesObject_Type); - if (op == NULL) - return NULL; - Py_XINCREF(file); - op->file = file; - op->lines = NULL; - op->abslineno = op->lineno = op->lineslen = 0; - return op; -} - -static PyObject * -xreadlines(PyObject *self, PyObject *args) -{ - PyObject *file; - PyXReadlinesObject *ret; - - if (!PyArg_ParseTuple(args, "O:xreadlines", &file)) - return NULL; - ret = newreadlinesobject(file); - return (PyObject*)ret; -} - -static PyObject * -xreadlines_common(PyXReadlinesObject *a) -{ - if (a->lineno >= a->lineslen) { - Py_XDECREF(a->lines); - a->lines = PyObject_CallMethod(a->file, "readlines", "(i)", - CHUNKSIZE); - if (a->lines == NULL) - return NULL; - a->lineno = 0; - if ((a->lineslen = PySequence_Size(a->lines)) < 0) - return NULL; - } - a->abslineno++; - return PySequence_GetItem(a->lines, a->lineno++); -} - -static PyObject * -xreadlines_item(PyXReadlinesObject *a, int i) -{ - if (i != a->abslineno) { - PyErr_SetString(PyExc_RuntimeError, - "xreadlines object accessed out of order"); - return NULL; - } - return xreadlines_common(a); -} - -static PyObject * -xreadlines_iternext(PyXReadlinesObject *a) -{ - PyObject *res; - - res = xreadlines_common(a); - if (res == NULL && PyErr_ExceptionMatches(PyExc_IndexError)) - PyErr_Clear(); - return res; -} - -static PyObject * -xreadlines_next(PyXReadlinesObject *a, PyObject *args) -{ - PyObject *res; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - res = xreadlines_common(a); - if (res == NULL && PyErr_ExceptionMatches(PyExc_IndexError)) - PyErr_SetObject(PyExc_StopIteration, Py_None); - return res; -} - -PyDoc_STRVAR(next_doc, "x.next() -> the next line or raise StopIteration"); - -static PyMethodDef xreadlines_methods[] = { - {"next", (PyCFunction)xreadlines_next, METH_VARARGS, next_doc}, - {NULL, NULL} -}; - -static PyObject * -xreadlines_getattr(PyObject *a, char *name) -{ - return Py_FindMethod(xreadlines_methods, a, name); -} - -static PySequenceMethods xreadlines_as_sequence = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - (intargfunc)xreadlines_item, /*sq_item*/ -}; - -static PyTypeObject XReadlinesObject_Type = { - PyObject_HEAD_INIT(NULL) - 0, - "xreadlines.xreadlines", - sizeof(PyXReadlinesObject), - 0, - (destructor)xreadlines_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - xreadlines_getattr, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - &xreadlines_as_sequence, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - 0, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)xreadlines_iternext, /* tp_iternext */ -}; - -static PyMethodDef xreadlines_functions[] = { - {"xreadlines", xreadlines, METH_VARARGS, xreadlines_doc}, - {NULL, NULL} -}; - -PyMODINIT_FUNC -initxreadlines(void) -{ - XReadlinesObject_Type.ob_type = &PyType_Type; - Py_InitModule("xreadlines", xreadlines_functions); - PyErr_Warn(PyExc_DeprecationWarning, - "xreadlines is deprecated; use 'for line in file'."); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/xxmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/xxmodule.c deleted file mode 100644 index a647bf17..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/xxmodule.c +++ /dev/null @@ -1,374 +0,0 @@ - -/* Use this file as a template to start implementing a module that - also declares object types. All occurrences of 'Xxo' should be changed - to something reasonable for your objects. After that, all other - occurrences of 'xx' should be changed to something reasonable for your - module. If your module is named foo your sourcefile should be named - foomodule.c. - - You will probably want to delete all references to 'x_attr' and add - your own types of attributes instead. Maybe you want to name your - local variables other than 'self'. If your object type is needed in - other files, you'll have to create a file "foobarobject.h"; see - intobject.h for an example. */ - -/* Xxo objects */ - -#include "Python.h" - -static PyObject *ErrorObject; - -typedef struct { - PyObject_HEAD - PyObject *x_attr; /* Attributes dictionary */ -} XxoObject; - -static PyTypeObject Xxo_Type; - -#define XxoObject_Check(v) ((v)->ob_type == &Xxo_Type) - -static XxoObject * -newXxoObject(PyObject *arg) -{ - XxoObject *self; - self = PyObject_New(XxoObject, &Xxo_Type); - if (self == NULL) - return NULL; - self->x_attr = NULL; - return self; -} - -/* Xxo methods */ - -static void -Xxo_dealloc(XxoObject *self) -{ - Py_XDECREF(self->x_attr); - PyObject_Del(self); -} - -static PyObject * -Xxo_demo(XxoObject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":demo")) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyMethodDef Xxo_methods[] = { - {"demo", (PyCFunction)Xxo_demo, METH_VARARGS, - PyDoc_STR("demo() -> None")}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -Xxo_getattr(XxoObject *self, char *name) -{ - if (self->x_attr != NULL) { - PyObject *v = PyDict_GetItemString(self->x_attr, name); - if (v != NULL) { - Py_INCREF(v); - return v; - } - } - return Py_FindMethod(Xxo_methods, (PyObject *)self, name); -} - -static int -Xxo_setattr(XxoObject *self, char *name, PyObject *v) -{ - if (self->x_attr == NULL) { - self->x_attr = PyDict_New(); - if (self->x_attr == NULL) - return -1; - } - if (v == NULL) { - int rv = PyDict_DelItemString(self->x_attr, name); - if (rv < 0) - PyErr_SetString(PyExc_AttributeError, - "delete non-existing Xxo attribute"); - return rv; - } - else - return PyDict_SetItemString(self->x_attr, name, v); -} - -static PyTypeObject Xxo_Type = { - /* The ob_type field must be initialized in the module init function - * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "xxmodule.Xxo", /*tp_name*/ - sizeof(XxoObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)Xxo_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)Xxo_getattr, /*tp_getattr*/ - (setattrfunc)Xxo_setattr, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - 0, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - 0, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ -}; -/* --------------------------------------------------------------------- */ - -/* Function of two integers returning integer */ - -PyDoc_STRVAR(xx_foo_doc, -"foo(i,j)\n\ -\n\ -Return the sum of i and j."); - -static PyObject * -xx_foo(PyObject *self, PyObject *args) -{ - long i, j; - long res; - if (!PyArg_ParseTuple(args, "ll:foo", &i, &j)) - return NULL; - res = i+j; /* XXX Do something here */ - return PyInt_FromLong(res); -} - - -/* Function of no arguments returning new Xxo object */ - -static PyObject * -xx_new(PyObject *self, PyObject *args) -{ - XxoObject *rv; - - if (!PyArg_ParseTuple(args, ":new")) - return NULL; - rv = newXxoObject(args); - if (rv == NULL) - return NULL; - return (PyObject *)rv; -} - -/* Example with subtle bug from extensions manual ("Thin Ice"). */ - -static PyObject * -xx_bug(PyObject *self, PyObject *args) -{ - PyObject *list, *item; - - if (!PyArg_ParseTuple(args, "O:bug", &list)) - return NULL; - - item = PyList_GetItem(list, 0); - /* Py_INCREF(item); */ - PyList_SetItem(list, 1, PyInt_FromLong(0L)); - PyObject_Print(item, stdout, 0); - printf("\n"); - /* Py_DECREF(item); */ - - Py_INCREF(Py_None); - return Py_None; -} - -/* Test bad format character */ - -static PyObject * -xx_roj(PyObject *self, PyObject *args) -{ - PyObject *a; - long b; - if (!PyArg_ParseTuple(args, "O#:roj", &a, &b)) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - - -/* ---------- */ - -static PyTypeObject Str_Type = { - /* The ob_type field must be initialized in the module init function - * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "xxmodule.Str", /*tp_name*/ - 0, /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - 0, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - 0, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - &PyString_Type, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - 0, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ -}; - -/* ---------- */ - -static PyObject * -null_richcompare(PyObject *self, PyObject *other, int op) -{ - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; -} - -static PyTypeObject Null_Type = { - /* The ob_type field must be initialized in the module init function - * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "xxmodule.Null", /*tp_name*/ - 0, /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - 0, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - null_richcompare, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - 0, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - &PyBaseObject_Type, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - PyType_GenericNew, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ -}; - - -/* ---------- */ - - -/* List of functions defined in the module */ - -static PyMethodDef xx_methods[] = { - {"roj", xx_roj, METH_VARARGS, - PyDoc_STR("roj(a,b) -> None")}, - {"foo", xx_foo, METH_VARARGS, - xx_foo_doc}, - {"new", xx_new, METH_VARARGS, - PyDoc_STR("new() -> new Xx object")}, - {"bug", xx_bug, METH_VARARGS, - PyDoc_STR("bug(o) -> None")}, - {NULL, NULL} /* sentinel */ -}; - -PyDoc_STRVAR(module_doc, -"This is a template module just for instruction."); - -/* Initialization function for the module (*must* be called initxx) */ - -PyMODINIT_FUNC -initxx(void) -{ - PyObject *m; - - /* Finalize the type object including setting type of the new type - * object; doing it here is required for portability to Windows - * without requiring C++. */ - if (PyType_Ready(&Xxo_Type) < 0) - return; - - /* Create the module and add the functions */ - m = Py_InitModule3("xx", xx_methods, module_doc); - - /* Add some symbolic constants to the module */ - if (ErrorObject == NULL) { - ErrorObject = PyErr_NewException("xx.error", NULL, NULL); - if (ErrorObject == NULL) - return; - } - Py_INCREF(ErrorObject); - PyModule_AddObject(m, "error", ErrorObject); - - /* Add Str */ - if (PyType_Ready(&Str_Type) < 0) - return; - PyModule_AddObject(m, "Str", (PyObject *)&Str_Type); - - /* Add Null */ - if (PyType_Ready(&Null_Type) < 0) - return; - PyModule_AddObject(m, "Null", (PyObject *)&Null_Type); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/xxsubtype.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/xxsubtype.c deleted file mode 100644 index 9d36e46d..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/xxsubtype.c +++ /dev/null @@ -1,303 +0,0 @@ -#include "Python.h" -#include "structmember.h" - -PyDoc_STRVAR(xxsubtype__doc__, -"xxsubtype is an example module showing how to subtype builtin types from C.\n" -"test_descr.py in the standard test suite requires it in order to complete.\n" -"If you don't care about the examples, and don't intend to run the Python\n" -"test suite, you can recompile Python without Modules/xxsubtype.c."); - -/* We link this module statically for convenience. If compiled as a shared - library instead, some compilers don't allow addresses of Python objects - defined in other libraries to be used in static initializers here. The - DEFERRED_ADDRESS macro is used to tag the slots where such addresses - appear; the module init function must fill in the tagged slots at runtime. - The argument is for documentation -- the macro ignores it. -*/ -#define DEFERRED_ADDRESS(ADDR) 0 - -/* spamlist -- a list subtype */ - -typedef struct { - PyListObject list; - int state; -} spamlistobject; - -static PyObject * -spamlist_getstate(spamlistobject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":getstate")) - return NULL; - return PyInt_FromLong(self->state); -} - -static PyObject * -spamlist_setstate(spamlistobject *self, PyObject *args) -{ - int state; - - if (!PyArg_ParseTuple(args, "i:setstate", &state)) - return NULL; - self->state = state; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -spamlist_specialmeth(PyObject *self, PyObject *args, PyObject *kw) -{ - PyObject *result = PyTuple_New(3); - - if (result != NULL) { - if (self == NULL) - self = Py_None; - if (kw == NULL) - kw = Py_None; - Py_INCREF(self); - PyTuple_SET_ITEM(result, 0, self); - Py_INCREF(args); - PyTuple_SET_ITEM(result, 1, args); - Py_INCREF(kw); - PyTuple_SET_ITEM(result, 2, kw); - } - return result; -} - -static PyMethodDef spamlist_methods[] = { - {"getstate", (PyCFunction)spamlist_getstate, METH_VARARGS, - PyDoc_STR("getstate() -> state")}, - {"setstate", (PyCFunction)spamlist_setstate, METH_VARARGS, - PyDoc_STR("setstate(state)")}, - /* These entries differ only in the flags; they are used by the tests - in test.test_descr. */ - {"classmeth", (PyCFunction)spamlist_specialmeth, - METH_VARARGS | METH_KEYWORDS | METH_CLASS, - PyDoc_STR("classmeth(*args, **kw)")}, - {"staticmeth", (PyCFunction)spamlist_specialmeth, - METH_VARARGS | METH_KEYWORDS | METH_STATIC, - PyDoc_STR("staticmeth(*args, **kw)")}, - {NULL, NULL}, -}; - -static PyTypeObject spamlist_type; - -static int -spamlist_init(spamlistobject *self, PyObject *args, PyObject *kwds) -{ - if (PyList_Type.tp_init((PyObject *)self, args, kwds) < 0) - return -1; - self->state = 0; - return 0; -} - -static PyObject * -spamlist_state_get(spamlistobject *self) -{ - return PyInt_FromLong(self->state); -} - -static PyGetSetDef spamlist_getsets[] = { - {"state", (getter)spamlist_state_get, NULL, - PyDoc_STR("an int variable for demonstration purposes")}, - {0} -}; - -static PyTypeObject spamlist_type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, - "xxsubtype.spamlist", - sizeof(spamlistobject), - 0, - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - 0, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - spamlist_methods, /* tp_methods */ - 0, /* tp_members */ - spamlist_getsets, /* tp_getset */ - DEFERRED_ADDRESS(&PyList_Type), /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)spamlist_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ -}; - -/* spamdict -- a dict subtype */ - -typedef struct { - PyDictObject dict; - int state; -} spamdictobject; - -static PyObject * -spamdict_getstate(spamdictobject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":getstate")) - return NULL; - return PyInt_FromLong(self->state); -} - -static PyObject * -spamdict_setstate(spamdictobject *self, PyObject *args) -{ - int state; - - if (!PyArg_ParseTuple(args, "i:setstate", &state)) - return NULL; - self->state = state; - Py_INCREF(Py_None); - return Py_None; -} - -static PyMethodDef spamdict_methods[] = { - {"getstate", (PyCFunction)spamdict_getstate, METH_VARARGS, - PyDoc_STR("getstate() -> state")}, - {"setstate", (PyCFunction)spamdict_setstate, METH_VARARGS, - PyDoc_STR("setstate(state)")}, - {NULL, NULL}, -}; - -static PyTypeObject spamdict_type; - -static int -spamdict_init(spamdictobject *self, PyObject *args, PyObject *kwds) -{ - if (PyDict_Type.tp_init((PyObject *)self, args, kwds) < 0) - return -1; - self->state = 0; - return 0; -} - -static PyMemberDef spamdict_members[] = { - {"state", T_INT, offsetof(spamdictobject, state), READONLY, - PyDoc_STR("an int variable for demonstration purposes")}, - {0} -}; - -static PyTypeObject spamdict_type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, - "xxsubtype.spamdict", - sizeof(spamdictobject), - 0, - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - 0, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - spamdict_methods, /* tp_methods */ - spamdict_members, /* tp_members */ - 0, /* tp_getset */ - DEFERRED_ADDRESS(&PyDict_Type), /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)spamdict_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ -}; - -static PyObject * -spam_bench(PyObject *self, PyObject *args) -{ - PyObject *obj, *name, *res; - int n = 1000; - time_t t0, t1; - - if (!PyArg_ParseTuple(args, "OS|i", &obj, &name, &n)) - return NULL; - t0 = clock(); - while (--n >= 0) { - res = PyObject_GetAttr(obj, name); - if (res == NULL) - return NULL; - Py_DECREF(res); - } - t1 = clock(); - return PyFloat_FromDouble((double)(t1-t0) / CLOCKS_PER_SEC); -} - -static PyMethodDef xxsubtype_functions[] = { - {"bench", spam_bench, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - -PyMODINIT_FUNC -initxxsubtype(void) -{ - PyObject *m; - - /* Fill in deferred data addresses. This must be done before - PyType_Ready() is called. Note that PyType_Ready() automatically - initializes the ob.ob_type field to &PyType_Type if it's NULL, - so it's not necessary to fill in ob_type first. */ - spamdict_type.tp_base = &PyDict_Type; - if (PyType_Ready(&spamdict_type) < 0) - return; - - spamlist_type.tp_base = &PyList_Type; - if (PyType_Ready(&spamlist_type) < 0) - return; - - m = Py_InitModule3("xxsubtype", - xxsubtype_functions, - xxsubtype__doc__); - if (m == NULL) - return; - - if (PyType_Ready(&spamlist_type) < 0) - return; - if (PyType_Ready(&spamdict_type) < 0) - return; - - Py_INCREF(&spamlist_type); - if (PyModule_AddObject(m, "spamlist", - (PyObject *) &spamlist_type) < 0) - return; - - Py_INCREF(&spamdict_type); - if (PyModule_AddObject(m, "spamdict", - (PyObject *) &spamdict_type) < 0) - return; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/yuv.h b/SDKs/XPlatform/Cypython-2.3.3/Modules/yuv.h deleted file mode 100644 index fa406344..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/yuv.h +++ /dev/null @@ -1,99 +0,0 @@ - -#ifndef Py_YUV_H -#define Py_YUV_H -#ifdef __cplusplus -extern "C" { -#endif - -/* - * SVideo YUV 4:1:1 format. - * - * 4 consecutive quadwords describe 8 pixels on 2 lines, as depicted - * below. An array of (width/4) of the below structure describes 2 - * scan lines. - * - * +-------------------+ - * | 00 | 01 | 02 | 03 | . . . - * +-------------------+ - * | 10 | 11 | 12 | 13 | . . . - * +-------------------+ - */ -struct yuv411 { - struct { - unsigned int dummy:8; - unsigned int y0:8; - unsigned int u0:2; - unsigned int v0:2; - unsigned int y1:8; - unsigned int u1:2; - unsigned int v1:2; - } v[4]; -}; - -#define YUV411_Y00(y) (y).v[0].y0 -#define YUV411_Y01(y) (y).v[1].y0 -#define YUV411_Y02(y) (y).v[2].y0 -#define YUV411_Y03(y) (y).v[3].y0 -#define YUV411_Y10(y) (y).v[0].y1 -#define YUV411_Y11(y) (y).v[1].y1 -#define YUV411_Y12(y) (y).v[2].y1 -#define YUV411_Y13(y) (y).v[3].y1 -#define YUV411_U00(y) ((y).v[0].u0<<6|(y).v[1].u0<<4|(y).v[2].u0<<2|(y).v[3].u0) -#define YUV411_U01(y) YUV411_U00(y) -#define YUV411_U02(y) YUV411_U00(y) -#define YUV411_U03(y) YUV411_U00(y) -#define YUV411_U10(y) ((y).v[0].u1<<6|(y).v[1].u1<<4|(y).v[2].u1<<2|(y).v[3].u1) -#define YUV411_U11(y) YUV411_U10(y) -#define YUV411_U12(y) YUV411_U10(y) -#define YUV411_U13(y) YUV411_U10(y) -#define YUV411_V00(y) ((y).v[0].v0<<6|(y).v[1].v0<<4|(y).v[2].v0<<2|(y).v[3].v0) -#define YUV411_V01(y) YUV411_V00(y) -#define YUV411_V02(y) YUV411_V00(y) -#define YUV411_V03(y) YUV411_V00(y) -#define YUV411_V10(y) ((y).v[0].v1<<6|(y).v[1].v1<<4|(y).v[2].v1<<2|(y).v[3].v1) -#define YUV411_V11(y) YUV411_V10(y) -#define YUV411_V12(y) YUV411_V10(y) -#define YUV411_V13(y) YUV411_V10(y) - -/* - * Compression Library YUV 4:2:2 format. - * - * 1 longword describes 2 pixels. - * - * +-------+ - * | 0 | 1 | - * +-------+ - */ -struct yuv422 { - unsigned int u:8; - unsigned int y0:8; - unsigned int v:8; - unsigned int y1:8; -}; -#define YUV422_Y0(y) (y).y0 -#define YUV422_Y1(y) (y).y1 -#define YUV422_U0(y) (y).u -#define YUV422_U1(y) (y).u -#define YUV422_V0(y) (y).v -#define YUV422_V1(y) (y).v - -/* - * Compression library YUV 4:2:2 Duplicate Chroma format. - * - * This is like the previous format, but the U and V values are - * duplicated vertically (and hence there is some redundancy in the - * data). With other words, lines 2*n and 2*n+1 have the same U and V - * values but different Y values. - */ - -/* - * Conversion functions. - */ -void yuv_sv411_to_cl422dc(int, void *, void *, int, int); -void yuv_sv411_to_cl422dc_quartersize(int, void *, void *, int, int); -void yuv_sv411_to_cl422dc_sixteenthsize(int, void *, void *, int, int); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_YUV_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/yuvconvert.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/yuvconvert.c deleted file mode 100644 index f24b35c0..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/yuvconvert.c +++ /dev/null @@ -1,118 +0,0 @@ - -#include "yuv.h" - -void -yuv_sv411_to_cl422dc(int invert, void *data, void *yuv, int width, int height) -{ - struct yuv411 *in = data; - struct yuv422 *out_even = yuv; - struct yuv422 *out_odd = out_even + width / 2; - int i, j; /* counters */ - - for (i = height / 2; i--; ) { - for (j = width / 4; j--; ) { - YUV422_Y0(*out_even) = YUV411_Y00(*in); - YUV422_U0(*out_even) = YUV411_U00(*in); - YUV422_V0(*out_even) = YUV411_V00(*in); - YUV422_Y1(*out_even) = YUV411_Y01(*in); - out_even++; - YUV422_Y0(*out_even) = YUV411_Y02(*in); - YUV422_U0(*out_even) = YUV411_U02(*in); - YUV422_V0(*out_even) = YUV411_V02(*in); - YUV422_Y1(*out_even) = YUV411_Y03(*in); - out_even++; - YUV422_Y0(*out_odd) = YUV411_Y10(*in); - YUV422_U0(*out_odd) = YUV411_U10(*in); - YUV422_V0(*out_odd) = YUV411_V10(*in); - YUV422_Y1(*out_odd) = YUV411_Y11(*in); - out_odd++; - YUV422_Y0(*out_odd) = YUV411_Y12(*in); - YUV422_U0(*out_odd) = YUV411_U12(*in); - YUV422_V0(*out_odd) = YUV411_V12(*in); - YUV422_Y1(*out_odd) = YUV411_Y13(*in); - out_odd++; - in++; - } - out_even += width / 2; - out_odd += width / 2; - } -} - -void -yuv_sv411_to_cl422dc_quartersize(int invert, void *data, void *yuv, - int width, int height) -{ - int w4 = width / 4; /* quarter of width is used often */ - struct yuv411 *in_even = data; - struct yuv411 *in_odd = in_even + w4; - struct yuv422 *out_even = yuv; - struct yuv422 *out_odd = out_even + w4; - int i, j; /* counters */ - int u, v; /* U and V values */ - - for (i = height / 4; i--; ) { - for (j = w4; j--; ) { - u = YUV411_U00(*in_even); - v = YUV411_V00(*in_even); - - YUV422_Y0(*out_even) = YUV411_Y00(*in_even); - YUV422_U0(*out_even) = u; - YUV422_V0(*out_even) = v; - YUV422_Y1(*out_even) = YUV411_Y02(*in_even); - - YUV422_Y0(*out_odd) = YUV411_Y10(*in_odd); - YUV422_U0(*out_odd) = u; - YUV422_V0(*out_odd) = v; - YUV422_Y1(*out_odd) = YUV411_Y12(*in_odd); - - in_even++; - in_odd++; - out_even++; - out_odd++; - } - in_even += w4; - in_odd += w4; - out_even += w4; - out_odd += w4; - } -} - -void -yuv_sv411_to_cl422dc_sixteenthsize(int invert, void *data, void *yuv, - int width, int height) -{ - int w4_3 = 3 * width / 4; /* three quarters of width is used often */ - int w8 = width / 8; /* and so is one eighth */ - struct yuv411 *in_even = data; - struct yuv411 *in_odd = in_even + width / 2; - struct yuv422 *out_even = yuv; - struct yuv422 *out_odd = out_even + w8; - int i, j; /* counters */ - int u, v; /* U and V values */ - - for (i = height / 8; i--; ) { - for (j = w8; j--; ) { - u = YUV411_U00(in_even[0]); - v = YUV411_V00(in_even[0]); - - YUV422_Y0(*out_even) = YUV411_Y00(in_even[0]); - YUV422_U0(*out_even) = u; - YUV422_V0(*out_even) = v; - YUV422_Y1(*out_even) = YUV411_Y00(in_even[1]); - - YUV422_Y0(*out_odd) = YUV411_Y00(in_odd[0]); - YUV422_U0(*out_odd) = u; - YUV422_V0(*out_odd) = v; - YUV422_Y1(*out_odd) = YUV411_Y00(in_even[1]); - - in_even += 2; - in_odd += 2; - out_even++; - out_odd++; - } - in_even += w4_3; - in_odd += w4_3; - out_even += w8; - out_odd += w8; - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/zipimport.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/zipimport.c deleted file mode 100644 index d2ffaf69..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/zipimport.c +++ /dev/null @@ -1,1188 +0,0 @@ -#include "Python.h" -#include "structmember.h" -#include "osdefs.h" -#include "marshal.h" -#include "compile.h" -#include - - -#define IS_SOURCE 0x0 -#define IS_BYTECODE 0x1 -#define IS_PACKAGE 0x2 - -struct st_zip_searchorder { - char suffix[14]; - int type; -}; - -/* zip_searchorder defines how we search for a module in the Zip - archive: we first search for a package __init__, then for - non-package .pyc, .pyo and .py entries. The .pyc and .pyo entries - are swapped by initzipimport() if we run in optimized mode. Also, - '/' is replaced by SEP there. */ -static struct st_zip_searchorder zip_searchorder[] = { - {"/__init__.pyc", IS_PACKAGE | IS_BYTECODE}, - {"/__init__.pyo", IS_PACKAGE | IS_BYTECODE}, - {"/__init__.py", IS_PACKAGE | IS_SOURCE}, - {".pyc", IS_BYTECODE}, - {".pyo", IS_BYTECODE}, - {".py", IS_SOURCE}, - {"", 0} -}; - -/* zipimporter object definition and support */ - -typedef struct _zipimporter ZipImporter; - -struct _zipimporter { - PyObject_HEAD - PyObject *archive; /* pathname of the Zip archive */ - PyObject *prefix; /* file prefix: "a/sub/directory/" */ - PyObject *files; /* dict with file info {path: toc_entry} */ -}; - -static PyTypeObject ZipImporter_Type; -static PyObject *ZipImportError; -static PyObject *zip_directory_cache = NULL; - -/* forward decls */ -static PyObject *read_directory(char *archive); -static PyObject *get_data(char *archive, PyObject *toc_entry); -static PyObject *get_module_code(ZipImporter *self, char *fullname, - int *p_ispackage, char **p_modpath); - - -#define ZipImporter_Check(op) PyObject_TypeCheck(op, &ZipImporter_Type) - - -/* zipimporter.__init__ - Split the "subdirectory" from the Zip archive path, lookup a matching - entry in sys.path_importer_cache, fetch the file directory from there - if found, or else read it from the archive. */ -static int -zipimporter_init(ZipImporter *self, PyObject *args, PyObject *kwds) -{ - char *path, *p, *prefix, buf[MAXPATHLEN+2]; - int len; - - if (!PyArg_ParseTuple(args, "s:zipimporter", - &path)) - return -1; - - len = strlen(path); - if (len == 0) { - PyErr_SetString(ZipImportError, "archive path is empty"); - return -1; - } - if (len >= MAXPATHLEN) { - PyErr_SetString(ZipImportError, - "archive path too long"); - return -1; - } - strcpy(buf, path); - -#ifdef ALTSEP - for (p = buf; *p; p++) { - if (*p == ALTSEP) - *p = SEP; - } -#endif - - path = NULL; - prefix = NULL; - for (;;) { -#ifndef RISCOS - struct stat statbuf; - int rv; - - rv = stat(buf, &statbuf); - if (rv == 0) { - /* it exists */ - if (S_ISREG(statbuf.st_mode)) - /* it's a file */ - path = buf; - break; - } -#else - if (object_exists(buf)) { - /* it exists */ - if (isfile(buf)) - /* it's a file */ - path = buf; - break; - } -#endif - /* back up one path element */ - p = strrchr(buf, SEP); - if (prefix != NULL) - *prefix = SEP; - if (p == NULL) - break; - *p = '\0'; - prefix = p; - } - if (path != NULL) { - PyObject *files; - files = PyDict_GetItemString(zip_directory_cache, path); - if (files == NULL) { - files = read_directory(buf); - if (files == NULL) - return -1; - if (PyDict_SetItemString(zip_directory_cache, path, - files) != 0) - return -1; - } - else - Py_INCREF(files); - self->files = files; - } - else { - PyErr_SetString(ZipImportError, "not a Zip file"); - return -1; - } - - if (prefix == NULL) - prefix = ""; - else { - prefix++; - len = strlen(prefix); - if (prefix[len-1] != SEP) { - /* add trailing SEP */ - prefix[len] = SEP; - prefix[len + 1] = '\0'; - } - } - - self->archive = PyString_FromString(buf); - if (self->archive == NULL) - return -1; - - self->prefix = PyString_FromString(prefix); - if (self->prefix == NULL) - return -1; - - return 0; -} - -/* GC support. */ -static int -zipimporter_traverse(PyObject *obj, visitproc visit, void *arg) -{ - ZipImporter *self = (ZipImporter *)obj; - int err; - - if (self->files != NULL) { - err = visit(self->files, arg); - if (err) - return err; - } - return 0; -} - -static void -zipimporter_dealloc(ZipImporter *self) -{ - PyObject_GC_UnTrack(self); - Py_XDECREF(self->archive); - Py_XDECREF(self->prefix); - Py_XDECREF(self->files); - self->ob_type->tp_free((PyObject *)self); -} - -static PyObject * -zipimporter_repr(ZipImporter *self) -{ - char buf[500]; - char *archive = "???"; - char *prefix = ""; - - if (self->archive != NULL && PyString_Check(self->archive)) - archive = PyString_AsString(self->archive); - if (self->prefix != NULL && PyString_Check(self->prefix)) - prefix = PyString_AsString(self->prefix); - if (prefix != NULL && *prefix) - PyOS_snprintf(buf, sizeof(buf), - "", - archive, SEP, prefix); - else - PyOS_snprintf(buf, sizeof(buf), - "", - archive); - return PyString_FromString(buf); -} - -/* return fullname.split(".")[-1] */ -static char * -get_subname(char *fullname) -{ - char *subname = strrchr(fullname, '.'); - if (subname == NULL) - subname = fullname; - else - subname++; - return subname; -} - -/* Given a (sub)modulename, write the potential file path in the - archive (without extension) to the path buffer. Return the - length of the resulting string. */ -static int -make_filename(char *prefix, char *name, char *path) -{ - int len; - char *p; - - len = strlen(prefix); - - /* self.prefix + name [+ SEP + "__init__"] + ".py[co]" */ - if (len + strlen(name) + 13 >= MAXPATHLEN) { - PyErr_SetString(ZipImportError, "path too long"); - return -1; - } - - strcpy(path, prefix); - strcpy(path + len, name); - for (p = path + len; *p; p++) { - if (*p == '.') - *p = SEP; - } - len += strlen(name); - return len; -} - -enum module_info { - MI_ERROR, - MI_NOT_FOUND, - MI_MODULE, - MI_PACKAGE -}; - -/* Return some information about a module. */ -static enum module_info -get_module_info(ZipImporter *self, char *fullname) -{ - char *subname, path[MAXPATHLEN + 1]; - int len; - struct st_zip_searchorder *zso; - - subname = get_subname(fullname); - - len = make_filename(PyString_AsString(self->prefix), subname, path); - if (len < 0) - return MI_ERROR; - - for (zso = zip_searchorder; *zso->suffix; zso++) { - strcpy(path + len, zso->suffix); - if (PyDict_GetItemString(self->files, path) != NULL) { - if (zso->type & IS_PACKAGE) - return MI_PACKAGE; - else - return MI_MODULE; - } - } - return MI_NOT_FOUND; -} - -/* Check whether we can satisfy the import of the module named by - 'fullname'. Return self if we can, None if we can't. */ -static PyObject * -zipimporter_find_module(PyObject *obj, PyObject *args) -{ - ZipImporter *self = (ZipImporter *)obj; - PyObject *path = NULL; - char *fullname; - enum module_info mi; - - if (!PyArg_ParseTuple(args, "s|O:zipimporter.find_module", - &fullname, &path)) - return NULL; - - mi = get_module_info(self, fullname); - if (mi == MI_ERROR) - return NULL; - if (mi == MI_NOT_FOUND) { - Py_INCREF(Py_None); - return Py_None; - } - Py_INCREF(self); - return (PyObject *)self; -} - -/* Load and return the module named by 'fullname'. */ -static PyObject * -zipimporter_load_module(PyObject *obj, PyObject *args) -{ - ZipImporter *self = (ZipImporter *)obj; - PyObject *code, *mod, *dict; - char *fullname, *modpath; - int ispackage; - - if (!PyArg_ParseTuple(args, "s:zipimporter.load_module", - &fullname)) - return NULL; - - code = get_module_code(self, fullname, &ispackage, &modpath); - if (code == NULL) - return NULL; - - mod = PyImport_AddModule(fullname); - if (mod == NULL) { - Py_DECREF(code); - return NULL; - } - dict = PyModule_GetDict(mod); - - /* mod.__loader__ = self */ - if (PyDict_SetItemString(dict, "__loader__", (PyObject *)self) != 0) - goto error; - - if (ispackage) { - /* add __path__ to the module *before* the code gets - executed */ - PyObject *pkgpath, *fullpath; - char *prefix = PyString_AsString(self->prefix); - char *subname = get_subname(fullname); - int err; - - fullpath = PyString_FromFormat("%s%c%s%s", - PyString_AsString(self->archive), - SEP, - *prefix ? prefix : "", - subname); - if (fullpath == NULL) - goto error; - - pkgpath = Py_BuildValue("[O]", fullpath); - Py_DECREF(fullpath); - if (pkgpath == NULL) - goto error; - err = PyDict_SetItemString(dict, "__path__", pkgpath); - Py_DECREF(pkgpath); - if (err != 0) - goto error; - } - mod = PyImport_ExecCodeModuleEx(fullname, code, modpath); - Py_DECREF(code); - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # loaded from Zip %s\n", - fullname, modpath); - return mod; -error: - Py_DECREF(code); - Py_DECREF(mod); - return NULL; -} - -/* Return a bool signifying whether the module is a package or not. */ -static PyObject * -zipimporter_is_package(PyObject *obj, PyObject *args) -{ - ZipImporter *self = (ZipImporter *)obj; - char *fullname; - enum module_info mi; - - if (!PyArg_ParseTuple(args, "s:zipimporter.is_package", - &fullname)) - return NULL; - - mi = get_module_info(self, fullname); - if (mi == MI_ERROR) - return NULL; - if (mi == MI_NOT_FOUND) { - PyErr_Format(ZipImportError, "can't find module '%.200s'", - fullname); - return NULL; - } - return PyBool_FromLong(mi == MI_PACKAGE); -} - -static PyObject * -zipimporter_get_data(PyObject *obj, PyObject *args) -{ - ZipImporter *self = (ZipImporter *)obj; - char *path; -#ifdef ALTSEP - char *p, buf[MAXPATHLEN + 1]; -#endif - PyObject *toc_entry; - int len; - - if (!PyArg_ParseTuple(args, "s:zipimporter.get_data", &path)) - return NULL; - -#ifdef ALTSEP - if (strlen(path) >= MAXPATHLEN) { - PyErr_SetString(ZipImportError, "path too long"); - return NULL; - } - strcpy(buf, path); - for (p = buf; *p; p++) { - if (*p == ALTSEP) - *p = SEP; - } - path = buf; -#endif - len = PyString_Size(self->archive); - if ((size_t)len < strlen(path) && - strncmp(path, PyString_AsString(self->archive), len) == 0 && - path[len] == SEP) { - path = path + len + 1; - } - - toc_entry = PyDict_GetItemString(self->files, path); - if (toc_entry == NULL) { - PyErr_Format(PyExc_IOError, "file not found [%.200s]", - path); - return NULL; - } - return get_data(PyString_AsString(self->archive), toc_entry); -} - -static PyObject * -zipimporter_get_code(PyObject *obj, PyObject *args) -{ - ZipImporter *self = (ZipImporter *)obj; - char *fullname; - - if (!PyArg_ParseTuple(args, "s:zipimporter.get_code", &fullname)) - return NULL; - - return get_module_code(self, fullname, NULL, NULL); -} - -static PyObject * -zipimporter_get_source(PyObject *obj, PyObject *args) -{ - ZipImporter *self = (ZipImporter *)obj; - PyObject *toc_entry; - char *fullname, *subname, path[MAXPATHLEN+1]; - int len; - enum module_info mi; - - if (!PyArg_ParseTuple(args, "s:zipimporter.get_source", &fullname)) - return NULL; - - mi = get_module_info(self, fullname); - if (mi == MI_ERROR) - return NULL; - if (mi == MI_NOT_FOUND) { - PyErr_Format(ZipImportError, "can't find module '%.200s'", - fullname); - return NULL; - } - subname = get_subname(fullname); - - len = make_filename(PyString_AsString(self->prefix), subname, path); - if (len < 0) - return NULL; - - if (mi == MI_PACKAGE) { - path[len] = SEP; - strcpy(path + len + 1, "__init__.py"); - } - else - strcpy(path + len, ".py"); - - toc_entry = PyDict_GetItemString(self->files, path); - if (toc_entry != NULL) - return get_data(PyString_AsString(self->archive), toc_entry); - - /* we have the module, but no source */ - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(doc_find_module, -"find_module(fullname, path=None) -> self or None.\n\ -\n\ -Search for a module specified by 'fullname'. 'fullname' must be the\n\ -fully qualified (dotted) module name. It returns the zipimporter\n\ -instance itself if the module was found, or None if it wasn't.\n\ -The optional 'path' argument is ignored -- it's there for compatibility\n\ -with the importer protocol."); - -PyDoc_STRVAR(doc_load_module, -"load_module(fullname) -> module.\n\ -\n\ -Load the module specified by 'fullname'. 'fullname' must be the\n\ -fully qualified (dotted) module name. It returns the imported\n\ -module, or raises ZipImportError if it wasn't found."); - -PyDoc_STRVAR(doc_get_data, -"get_data(pathname) -> string with file data.\n\ -\n\ -Return the data associated with 'pathname'. Raise IOError if\n\ -the file wasn't found."); - -PyDoc_STRVAR(doc_is_package, -"is_package(fullname) -> bool.\n\ -\n\ -Return True if the module specified by fullname is a package.\n\ -Raise ZipImportError is the module couldn't be found."); - -PyDoc_STRVAR(doc_get_code, -"get_code(fullname) -> code object.\n\ -\n\ -Return the code object for the specified module. Raise ZipImportError\n\ -is the module couldn't be found."); - -PyDoc_STRVAR(doc_get_source, -"get_source(fullname) -> source string.\n\ -\n\ -Return the source code for the specified module. Raise ZipImportError\n\ -is the module couldn't be found, return None if the archive does\n\ -contain the module, but has no source for it."); - -static PyMethodDef zipimporter_methods[] = { - {"find_module", zipimporter_find_module, METH_VARARGS, - doc_find_module}, - {"load_module", zipimporter_load_module, METH_VARARGS, - doc_load_module}, - {"get_data", zipimporter_get_data, METH_VARARGS, - doc_get_data}, - {"get_code", zipimporter_get_code, METH_VARARGS, - doc_get_code}, - {"get_source", zipimporter_get_source, METH_VARARGS, - doc_get_source}, - {"is_package", zipimporter_is_package, METH_VARARGS, - doc_is_package}, - {NULL, NULL} /* sentinel */ -}; - -static PyMemberDef zipimporter_members[] = { - {"archive", T_OBJECT, offsetof(ZipImporter, archive), READONLY}, - {"prefix", T_OBJECT, offsetof(ZipImporter, prefix), READONLY}, - {"_files", T_OBJECT, offsetof(ZipImporter, files), READONLY}, - {NULL} -}; - -PyDoc_STRVAR(zipimporter_doc, -"zipimporter(archivepath) -> zipimporter object\n\ -\n\ -Create a new zipimporter instance. 'archivepath' must be a path to\n\ -a zipfile. ZipImportError is raised if 'archivepath' doesn't point to\n\ -a valid Zip archive."); - -#define DEFERRED_ADDRESS(ADDR) 0 - -static PyTypeObject ZipImporter_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, - "zipimport.zipimporter", - sizeof(ZipImporter), - 0, /* tp_itemsize */ - (destructor)zipimporter_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)zipimporter_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HAVE_GC, /* tp_flags */ - zipimporter_doc, /* tp_doc */ - zipimporter_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - zipimporter_methods, /* tp_methods */ - zipimporter_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)zipimporter_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - - -/* implementation */ - -/* Given a buffer, return the long that is represented by the first - 4 bytes, encoded as little endian. This partially reimplements - marshal.c:r_long() */ -static long -get_long(unsigned char *buf) { - long x; - x = buf[0]; - x |= (long)buf[1] << 8; - x |= (long)buf[2] << 16; - x |= (long)buf[3] << 24; -#if SIZEOF_LONG > 4 - /* Sign extension for 64-bit machines */ - x |= -(x & 0x80000000L); -#endif - return x; -} - -/* - read_directory(archive) -> files dict (new reference) - - Given a path to a Zip archive, build a dict, mapping file names - (local to the archive, using SEP as a separator) to toc entries. - - A toc_entry is a tuple: - - (compress, # compression kind; 0 for uncompressed - data_size, # size of compressed data on disk - file_size, # size of decompressed data - file_offset, # offset of file header from start of archive - time, # mod time of file (in dos format) - date, # mod data of file (in dos format) - crc, # crc checksum of the data - ) - - Directories can be recognized by the trailing SEP in the name, - data_size and file_offset are 0. -*/ -static PyObject * -read_directory(char *archive) -{ - PyObject *files = NULL; - FILE *fp; - long compress, crc, data_size, file_size, file_offset, date, time; - long header_offset, name_size, header_size, header_position; - long i, l, length, count; - char path[MAXPATHLEN + 5]; - char name[MAXPATHLEN + 5]; - char *p, endof_central_dir[22]; - long arc_offset; /* offset from beginning of file to start of zip-archive */ - - if (strlen(archive) > MAXPATHLEN) { - PyErr_SetString(PyExc_OverflowError, - "Zip path name is too long"); - return NULL; - } - strcpy(path, archive); - - fp = fopen(archive, "rb"); - if (fp == NULL) { - PyErr_Format(ZipImportError, "can't open Zip file: " - "'%.200s'", archive); - return NULL; - } - fseek(fp, -22, SEEK_END); - header_position = ftell(fp); - if (fread(endof_central_dir, 1, 22, fp) != 22) { - fclose(fp); - PyErr_Format(ZipImportError, "can't read Zip file: " - "'%.200s'", archive); - return NULL; - } - if (get_long((unsigned char *)endof_central_dir) != 0x06054B50) { - /* Bad: End of Central Dir signature */ - fclose(fp); - PyErr_Format(ZipImportError, "not a Zip file: " - "'%.200s'", archive); - return NULL; - } - - header_size = get_long((unsigned char *)endof_central_dir + 12); - header_offset = get_long((unsigned char *)endof_central_dir + 16); - arc_offset = header_position - header_offset - header_size; - header_offset += arc_offset; - - files = PyDict_New(); - if (files == NULL) - goto error; - - length = (long)strlen(path); - path[length] = SEP; - - /* Start of Central Directory */ - count = 0; - for (;;) { - PyObject *t; - int err; - - fseek(fp, header_offset, 0); /* Start of file header */ - l = PyMarshal_ReadLongFromFile(fp); - if (l != 0x02014B50) - break; /* Bad: Central Dir File Header */ - fseek(fp, header_offset + 10, 0); - compress = PyMarshal_ReadShortFromFile(fp); - time = PyMarshal_ReadShortFromFile(fp); - date = PyMarshal_ReadShortFromFile(fp); - crc = PyMarshal_ReadLongFromFile(fp); - data_size = PyMarshal_ReadLongFromFile(fp); - file_size = PyMarshal_ReadLongFromFile(fp); - name_size = PyMarshal_ReadShortFromFile(fp); - header_size = 46 + name_size + - PyMarshal_ReadShortFromFile(fp) + - PyMarshal_ReadShortFromFile(fp); - fseek(fp, header_offset + 42, 0); - file_offset = PyMarshal_ReadLongFromFile(fp) + arc_offset; - if (name_size > MAXPATHLEN) - name_size = MAXPATHLEN; - - p = name; - for (i = 0; i < name_size; i++) { - *p = (char)getc(fp); - if (*p == '/') - *p = SEP; - p++; - } - *p = 0; /* Add terminating null byte */ - header_offset += header_size; - - strncpy(path + length + 1, name, MAXPATHLEN - length - 1); - - t = Py_BuildValue("siiiiiii", path, compress, data_size, - file_size, file_offset, time, date, crc); - if (t == NULL) - goto error; - err = PyDict_SetItemString(files, name, t); - Py_DECREF(t); - if (err != 0) - goto error; - count++; - } - fclose(fp); - if (Py_VerboseFlag) - PySys_WriteStderr("# zipimport: found %ld names in %s\n", - count, archive); - return files; -error: - fclose(fp); - Py_XDECREF(files); - return NULL; -} - -/* Return the zlib.decompress function object, or NULL if zlib couldn't - be imported. The function is cached when found, so subsequent calls - don't import zlib again. Returns a *borrowed* reference. - XXX This makes zlib.decompress immortal. */ -static PyObject * -get_decompress_func(void) -{ - static PyObject *decompress = NULL; - - if (decompress == NULL) { - PyObject *zlib; - static int importing_zlib = 0; - - if (importing_zlib != 0) - /* Someone has a zlib.py[co] in their Zip file; - let's avoid a stack overflow. */ - return NULL; - importing_zlib = 1; - zlib = PyImport_ImportModule("zlib"); /* import zlib */ - importing_zlib = 0; - if (zlib != NULL) { - decompress = PyObject_GetAttrString(zlib, - "decompress"); - Py_DECREF(zlib); - } - else - PyErr_Clear(); - if (Py_VerboseFlag) - PySys_WriteStderr("# zipimport: zlib %s\n", - zlib != NULL ? "available": "UNAVAILABLE"); - } - return decompress; -} - -/* Given a path to a Zip file and a toc_entry, return the (uncompressed) - data as a new reference. */ -static PyObject * -get_data(char *archive, PyObject *toc_entry) -{ - PyObject *raw_data, *data = NULL, *decompress; - char *buf; - FILE *fp; - int err, bytes_read = 0; - long l; - char *datapath; - long compress, data_size, file_size, file_offset; - long time, date, crc; - - if (!PyArg_ParseTuple(toc_entry, "slllllll", &datapath, &compress, - &data_size, &file_size, &file_offset, &time, - &date, &crc)) { - return NULL; - } - - fp = fopen(archive, "rb"); - if (!fp) { - PyErr_Format(PyExc_IOError, - "zipimport: can not open file %s", archive); - return NULL; - } - - /* Check to make sure the local file header is correct */ - fseek(fp, file_offset, 0); - l = PyMarshal_ReadLongFromFile(fp); - if (l != 0x04034B50) { - /* Bad: Local File Header */ - PyErr_Format(ZipImportError, - "bad local file header in %s", - archive); - fclose(fp); - return NULL; - } - fseek(fp, file_offset + 26, 0); - l = 30 + PyMarshal_ReadShortFromFile(fp) + - PyMarshal_ReadShortFromFile(fp); /* local header size */ - file_offset += l; /* Start of file data */ - - raw_data = PyString_FromStringAndSize((char *)NULL, compress == 0 ? - data_size : data_size + 1); - if (raw_data == NULL) { - fclose(fp); - return NULL; - } - buf = PyString_AsString(raw_data); - - err = fseek(fp, file_offset, 0); - if (err == 0) - bytes_read = fread(buf, 1, data_size, fp); - fclose(fp); - if (err || bytes_read != data_size) { - PyErr_SetString(PyExc_IOError, - "zipimport: can't read data"); - Py_DECREF(raw_data); - return NULL; - } - - if (compress != 0) { - buf[data_size] = 'Z'; /* saw this in zipfile.py */ - data_size++; - } - buf[data_size] = '\0'; - - if (compress == 0) /* data is not compressed */ - return raw_data; - - /* Decompress with zlib */ - decompress = get_decompress_func(); - if (decompress == NULL) { - PyErr_SetString(ZipImportError, - "can't decompress data; " - "zlib not available"); - goto error; - } - data = PyObject_CallFunction(decompress, "Ol", raw_data, -15); -error: - Py_DECREF(raw_data); - return data; -} - -/* Lenient date/time comparison function. The precision of the mtime - in the archive is lower than the mtime stored in a .pyc: we - must allow a difference of at most one second. */ -static int -eq_mtime(time_t t1, time_t t2) -{ - time_t d = t1 - t2; - if (d < 0) - d = -d; - /* dostime only stores even seconds, so be lenient */ - return d <= 1; -} - -/* Given the contents of a .py[co] file in a buffer, unmarshal the data - and return the code object. Return None if it the magic word doesn't - match (we do this instead of raising an exception as we fall back - to .py if available and we don't want to mask other errors). - Returns a new reference. */ -static PyObject * -unmarshal_code(char *pathname, PyObject *data, time_t mtime) -{ - PyObject *code; - char *buf = PyString_AsString(data); - int size = PyString_Size(data); - - if (size <= 9) { - PyErr_SetString(ZipImportError, - "bad pyc data"); - return NULL; - } - - if (get_long((unsigned char *)buf) != PyImport_GetMagicNumber()) { - if (Py_VerboseFlag) - PySys_WriteStderr("# %s has bad magic\n", - pathname); - Py_INCREF(Py_None); - return Py_None; /* signal caller to try alternative */ - } - - if (mtime != 0 && !eq_mtime(get_long((unsigned char *)buf + 4), - mtime)) { - if (Py_VerboseFlag) - PySys_WriteStderr("# %s has bad mtime\n", - pathname); - Py_INCREF(Py_None); - return Py_None; /* signal caller to try alternative */ - } - - code = PyMarshal_ReadObjectFromString(buf + 8, size - 8); - if (code == NULL) - return NULL; - if (!PyCode_Check(code)) { - Py_DECREF(code); - PyErr_Format(PyExc_TypeError, - "compiled module %.200s is not a code object", - pathname); - return NULL; - } - return code; -} - -/* Replace any occurances of "\r\n?" in the input string with "\n". - This converts DOS and Mac line endings to Unix line endings. - Also append a trailing "\n" to be compatible with - PyParser_SimpleParseFile(). Returns a new reference. */ -static PyObject * -normalize_line_endings(PyObject *source) -{ - char *buf, *q, *p = PyString_AsString(source); - PyObject *fixed_source; - - /* one char extra for trailing \n and one for terminating \0 */ - buf = PyMem_Malloc(PyString_Size(source) + 2); - if (buf == NULL) { - PyErr_SetString(PyExc_MemoryError, - "zipimport: no memory to allocate " - "source buffer"); - return NULL; - } - /* replace "\r\n?" by "\n" */ - for (q = buf; *p != '\0'; p++) { - if (*p == '\r') { - *q++ = '\n'; - if (*(p + 1) == '\n') - p++; - } - else - *q++ = *p; - } - *q++ = '\n'; /* add trailing \n */ - *q = '\0'; - fixed_source = PyString_FromString(buf); - PyMem_Free(buf); - return fixed_source; -} - -/* Given a string buffer containing Python source code, compile it - return and return a code object as a new reference. */ -static PyObject * -compile_source(char *pathname, PyObject *source) -{ - PyObject *code, *fixed_source; - - fixed_source = normalize_line_endings(source); - if (fixed_source == NULL) - return NULL; - - code = Py_CompileString(PyString_AsString(fixed_source), pathname, - Py_file_input); - Py_DECREF(fixed_source); - return code; -} - -/* Convert the date/time values found in the Zip archive to a value - that's compatible with the time stamp stored in .pyc files. */ -static time_t -parse_dostime(int dostime, int dosdate) -{ - struct tm stm; - - stm.tm_sec = (dostime & 0x1f) * 2; - stm.tm_min = (dostime >> 5) & 0x3f; - stm.tm_hour = (dostime >> 11) & 0x1f; - stm.tm_mday = dosdate & 0x1f; - stm.tm_mon = ((dosdate >> 5) & 0x0f) - 1; - stm.tm_year = ((dosdate >> 9) & 0x7f) + 80; - stm.tm_isdst = -1; /* wday/yday is ignored */ - - return mktime(&stm); -} - -/* Given a path to a .pyc or .pyo file in the archive, return the - modifictaion time of the matching .py file, or 0 if no source - is available. */ -static time_t -get_mtime_of_source(ZipImporter *self, char *path) -{ - PyObject *toc_entry; - time_t mtime = 0; - int lastchar = strlen(path) - 1; - char savechar = path[lastchar]; - path[lastchar] = '\0'; /* strip 'c' or 'o' from *.py[co] */ - toc_entry = PyDict_GetItemString(self->files, path); - if (toc_entry != NULL && PyTuple_Check(toc_entry) && - PyTuple_Size(toc_entry) == 8) { - /* fetch the time stamp of the .py file for comparison - with an embedded pyc time stamp */ - int time, date; - time = PyInt_AsLong(PyTuple_GetItem(toc_entry, 5)); - date = PyInt_AsLong(PyTuple_GetItem(toc_entry, 6)); - mtime = parse_dostime(time, date); - } - path[lastchar] = savechar; - return mtime; -} - -/* Return the code object for the module named by 'fullname' from the - Zip archive as a new reference. */ -static PyObject * -get_code_from_data(ZipImporter *self, int ispackage, int isbytecode, - time_t mtime, PyObject *toc_entry) -{ - PyObject *data, *code; - char *modpath; - char *archive = PyString_AsString(self->archive); - - if (archive == NULL) - return NULL; - - data = get_data(archive, toc_entry); - if (data == NULL) - return NULL; - - modpath = PyString_AsString(PyTuple_GetItem(toc_entry, 0)); - - if (isbytecode) { - code = unmarshal_code(modpath, data, mtime); - } - else { - code = compile_source(modpath, data); - } - Py_DECREF(data); - return code; -} - -/* Get the code object assoiciated with the module specified by - 'fullname'. */ -static PyObject * -get_module_code(ZipImporter *self, char *fullname, - int *p_ispackage, char **p_modpath) -{ - PyObject *toc_entry; - char *subname, path[MAXPATHLEN + 1]; - int len; - struct st_zip_searchorder *zso; - - subname = get_subname(fullname); - - len = make_filename(PyString_AsString(self->prefix), subname, path); - if (len < 0) - return NULL; - - for (zso = zip_searchorder; *zso->suffix; zso++) { - PyObject *code = NULL; - - strcpy(path + len, zso->suffix); - if (Py_VerboseFlag > 1) - PySys_WriteStderr("# trying %s%c%s\n", - PyString_AsString(self->archive), - SEP, path); - toc_entry = PyDict_GetItemString(self->files, path); - if (toc_entry != NULL) { - time_t mtime = 0; - int ispackage = zso->type & IS_PACKAGE; - int isbytecode = zso->type & IS_BYTECODE; - - if (isbytecode) - mtime = get_mtime_of_source(self, path); - if (p_ispackage != NULL) - *p_ispackage = ispackage; - code = get_code_from_data(self, ispackage, - isbytecode, mtime, - toc_entry); - if (code == Py_None) { - /* bad magic number or non-matching mtime - in byte code, try next */ - Py_DECREF(code); - continue; - } - if (code != NULL && p_modpath != NULL) - *p_modpath = PyString_AsString( - PyTuple_GetItem(toc_entry, 0)); - return code; - } - } - PyErr_Format(ZipImportError, "can't find module '%.200s'", fullname); - return NULL; -} - - -/* Module init */ - -PyDoc_STRVAR(zipimport_doc, -"zipimport provides support for importing Python modules from Zip archives.\n\ -\n\ -This module exports three objects:\n\ -- zipimporter: a class; its constructor takes a path to a Zip archive.\n\ -- ZipImporterError: exception raised by zipimporter objects. It's a\n\ - subclass of ImportError, so it can be caught as ImportError, too.\n\ -- _zip_directory_cache: a dict, mapping archive paths to zip directory\n\ - info dicts, as used in zipimporter._files.\n\ -\n\ -It is usually not needed to use the zipimport module explicitly; it is\n\ -used by the builtin import mechanism for sys.path items that are paths\n\ -to Zip archives."); - -PyMODINIT_FUNC -initzipimport(void) -{ - PyObject *mod; - - if (PyType_Ready(&ZipImporter_Type) < 0) - return; - - /* Correct directory separator */ - zip_searchorder[0].suffix[0] = SEP; - zip_searchorder[1].suffix[0] = SEP; - zip_searchorder[2].suffix[0] = SEP; - if (Py_OptimizeFlag) { - /* Reverse *.pyc and *.pyo */ - struct st_zip_searchorder tmp; - tmp = zip_searchorder[0]; - zip_searchorder[0] = zip_searchorder[1]; - zip_searchorder[1] = tmp; - tmp = zip_searchorder[3]; - zip_searchorder[3] = zip_searchorder[4]; - zip_searchorder[4] = tmp; - } - - mod = Py_InitModule4("zipimport", NULL, zipimport_doc, - NULL, PYTHON_API_VERSION); - - ZipImportError = PyErr_NewException("zipimport.ZipImportError", - PyExc_ImportError, NULL); - if (ZipImportError == NULL) - return; - - Py_INCREF(ZipImportError); - if (PyModule_AddObject(mod, "ZipImportError", - ZipImportError) < 0) - return; - - Py_INCREF(&ZipImporter_Type); - if (PyModule_AddObject(mod, "zipimporter", - (PyObject *)&ZipImporter_Type) < 0) - return; - - zip_directory_cache = PyDict_New(); - if (zip_directory_cache == NULL) - return; - Py_INCREF(zip_directory_cache); - if (PyModule_AddObject(mod, "_zip_directory_cache", - zip_directory_cache) < 0) - return; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Modules/zlibmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Modules/zlibmodule.c deleted file mode 100644 index 90ab2f25..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Modules/zlibmodule.c +++ /dev/null @@ -1,907 +0,0 @@ -/* zlibmodule.c -- gzip-compatible data compression */ -/* See http://www.gzip.org/zlib/ */ - -/* Windows users: read Python's PCbuild\readme.txt */ - - -#include "Python.h" -#include "zlib.h" - -#ifdef WITH_THREAD -#include "pythread.h" - -/* #defs ripped off from _tkinter.c, even though the situation here is much - simpler, because we don't have to worry about waiting for Tcl - events! And, since zlib itself is threadsafe, we don't need to worry - about re-entering zlib functions. - - N.B. - - Since ENTER_ZLIB and LEAVE_ZLIB only need to be called on functions - that modify the components of preexisting de/compress objects, it - could prove to be a performance gain on multiprocessor machines if - there was an de/compress object-specific lock. However, for the - moment the ENTER_ZLIB and LEAVE_ZLIB calls are global for ALL - de/compress objects. - */ - -static PyThread_type_lock zlib_lock = NULL; /* initialized on module load */ - -#define ENTER_ZLIB \ - Py_BEGIN_ALLOW_THREADS \ - PyThread_acquire_lock(zlib_lock, 1); \ - Py_END_ALLOW_THREADS - -#define LEAVE_ZLIB \ - PyThread_release_lock(zlib_lock); - -#else - -#define ENTER_ZLIB -#define LEAVE_ZLIB - -#endif - -/* The following parameters are copied from zutil.h, version 0.95 */ -#define DEFLATED 8 -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -#define DEF_WBITS MAX_WBITS - -/* The output buffer will be increased in chunks of DEFAULTALLOC bytes. */ -#define DEFAULTALLOC (16*1024) -#define PyInit_zlib initzlib - -static PyTypeObject Comptype; -static PyTypeObject Decomptype; - -static PyObject *ZlibError; - -typedef struct -{ - PyObject_HEAD - z_stream zst; - PyObject *unused_data; - PyObject *unconsumed_tail; - int is_initialised; -} compobject; - -static void -zlib_error(z_stream zst, int err, char *msg) -{ - if (zst.msg == Z_NULL) - PyErr_Format(ZlibError, "Error %d %s", err, msg); - else - PyErr_Format(ZlibError, "Error %d %s: %.200s", err, msg, zst.msg); -} - -PyDoc_STRVAR(compressobj__doc__, -"compressobj([level]) -- Return a compressor object.\n" -"\n" -"Optional arg level is the compression level, in 1-9."); - -PyDoc_STRVAR(decompressobj__doc__, -"decompressobj([wbits]) -- Return a decompressor object.\n" -"\n" -"Optional arg wbits is the window buffer size."); - -static compobject * -newcompobject(PyTypeObject *type) -{ - compobject *self; - self = PyObject_New(compobject, type); - if (self == NULL) - return NULL; - self->is_initialised = 0; - self->unused_data = PyString_FromString(""); - if (self->unused_data == NULL) { - Py_DECREF(self); - return NULL; - } - self->unconsumed_tail = PyString_FromString(""); - if (self->unconsumed_tail == NULL) { - Py_DECREF(self); - return NULL; - } - return self; -} - -PyDoc_STRVAR(compress__doc__, -"compress(string[, level]) -- Returned compressed string.\n" -"\n" -"Optional arg level is the compression level, in 1-9."); - -static PyObject * -PyZlib_compress(PyObject *self, PyObject *args) -{ - PyObject *ReturnVal = NULL; - Byte *input, *output; - int length, level=Z_DEFAULT_COMPRESSION, err; - z_stream zst; - - /* require Python string object, optional 'level' arg */ - if (!PyArg_ParseTuple(args, "s#|i:compress", &input, &length, &level)) - return NULL; - - zst.avail_out = length + length/1000 + 12 + 1; - - output = (Byte*)malloc(zst.avail_out); - if (output == NULL) { - PyErr_SetString(PyExc_MemoryError, - "Can't allocate memory to compress data"); - return NULL; - } - - /* Past the point of no return. From here on out, we need to make sure - we clean up mallocs & INCREFs. */ - - zst.zalloc = (alloc_func)NULL; - zst.zfree = (free_func)Z_NULL; - zst.next_out = (Byte *)output; - zst.next_in = (Byte *)input; - zst.avail_in = length; - err = deflateInit(&zst, level); - - switch(err) { - case(Z_OK): - break; - case(Z_MEM_ERROR): - PyErr_SetString(PyExc_MemoryError, - "Out of memory while compressing data"); - goto error; - case(Z_STREAM_ERROR): - PyErr_SetString(ZlibError, - "Bad compression level"); - goto error; - default: - deflateEnd(&zst); - zlib_error(zst, err, "while compressing data"); - goto error; - } - - Py_BEGIN_ALLOW_THREADS; - err = deflate(&zst, Z_FINISH); - Py_END_ALLOW_THREADS; - - if (err != Z_STREAM_END) { - zlib_error(zst, err, "while compressing data"); - deflateEnd(&zst); - goto error; - } - - err=deflateEnd(&zst); - if (err == Z_OK) - ReturnVal = PyString_FromStringAndSize((char *)output, - zst.total_out); - else - zlib_error(zst, err, "while finishing compression"); - - error: - free(output); - - return ReturnVal; -} - -PyDoc_STRVAR(decompress__doc__, -"decompress(string[, wbits[, bufsize]]) -- Return decompressed string.\n" -"\n" -"Optional arg wbits is the window buffer size. Optional arg bufsize is\n" -"the initial output buffer size."); - -static PyObject * -PyZlib_decompress(PyObject *self, PyObject *args) -{ - PyObject *result_str; - Byte *input; - int length, err; - int wsize=DEF_WBITS, r_strlen=DEFAULTALLOC; - z_stream zst; - - if (!PyArg_ParseTuple(args, "s#|ii:decompress", - &input, &length, &wsize, &r_strlen)) - return NULL; - - if (r_strlen <= 0) - r_strlen = 1; - - zst.avail_in = length; - zst.avail_out = r_strlen; - - if (!(result_str = PyString_FromStringAndSize(NULL, r_strlen))) - return NULL; - - zst.zalloc = (alloc_func)NULL; - zst.zfree = (free_func)Z_NULL; - zst.next_out = (Byte *)PyString_AS_STRING(result_str); - zst.next_in = (Byte *)input; - err = inflateInit2(&zst, wsize); - - switch(err) { - case(Z_OK): - break; - case(Z_MEM_ERROR): - PyErr_SetString(PyExc_MemoryError, - "Out of memory while decompressing data"); - goto error; - default: - inflateEnd(&zst); - zlib_error(zst, err, "while preparing to decompress data"); - goto error; - } - - do { - Py_BEGIN_ALLOW_THREADS - err=inflate(&zst, Z_FINISH); - Py_END_ALLOW_THREADS - - switch(err) { - case(Z_STREAM_END): - break; - case(Z_BUF_ERROR): - /* - * If there is at least 1 byte of room according to zst.avail_out - * and we get this error, assume that it means zlib cannot - * process the inflate call() due to an error in the data. - */ - if (zst.avail_out > 0) { - PyErr_Format(ZlibError, "Error %i while decompressing data", - err); - inflateEnd(&zst); - goto error; - } - /* fall through */ - case(Z_OK): - /* need more memory */ - if (_PyString_Resize(&result_str, r_strlen << 1) < 0) { - inflateEnd(&zst); - goto error; - } - zst.next_out = (unsigned char *)PyString_AS_STRING(result_str) \ - + r_strlen; - zst.avail_out = r_strlen; - r_strlen = r_strlen << 1; - break; - default: - inflateEnd(&zst); - zlib_error(zst, err, "while decompressing data"); - goto error; - } - } while (err != Z_STREAM_END); - - err = inflateEnd(&zst); - if (err != Z_OK) { - zlib_error(zst, err, "while finishing data decompression"); - goto error; - } - - _PyString_Resize(&result_str, zst.total_out); - return result_str; - - error: - Py_XDECREF(result_str); - return NULL; -} - -static PyObject * -PyZlib_compressobj(PyObject *selfptr, PyObject *args) -{ - compobject *self; - int level=Z_DEFAULT_COMPRESSION, method=DEFLATED; - int wbits=MAX_WBITS, memLevel=DEF_MEM_LEVEL, strategy=0, err; - - if (!PyArg_ParseTuple(args, "|iiiii:compressobj", &level, &method, &wbits, - &memLevel, &strategy)) - return NULL; - - self = newcompobject(&Comptype); - if (self==NULL) - return(NULL); - self->zst.zalloc = (alloc_func)NULL; - self->zst.zfree = (free_func)Z_NULL; - err = deflateInit2(&self->zst, level, method, wbits, memLevel, strategy); - switch(err) { - case (Z_OK): - self->is_initialised = 1; - return (PyObject*)self; - case (Z_MEM_ERROR): - Py_DECREF(self); - PyErr_SetString(PyExc_MemoryError, - "Can't allocate memory for compression object"); - return NULL; - case(Z_STREAM_ERROR): - Py_DECREF(self); - PyErr_SetString(PyExc_ValueError, "Invalid initialization option"); - return NULL; - default: - zlib_error(self->zst, err, "while creating compression object"); - Py_DECREF(self); - return NULL; - } -} - -static PyObject * -PyZlib_decompressobj(PyObject *selfptr, PyObject *args) -{ - int wbits=DEF_WBITS, err; - compobject *self; - if (!PyArg_ParseTuple(args, "|i:decompressobj", &wbits)) - return NULL; - - self = newcompobject(&Decomptype); - if (self == NULL) - return(NULL); - self->zst.zalloc = (alloc_func)NULL; - self->zst.zfree = (free_func)Z_NULL; - err = inflateInit2(&self->zst, wbits); - switch(err) { - case (Z_OK): - self->is_initialised = 1; - return (PyObject*)self; - case(Z_STREAM_ERROR): - Py_DECREF(self); - PyErr_SetString(PyExc_ValueError, "Invalid initialization option"); - return NULL; - case (Z_MEM_ERROR): - Py_DECREF(self); - PyErr_SetString(PyExc_MemoryError, - "Can't allocate memory for decompression object"); - return NULL; - default: - zlib_error(self->zst, err, "while creating decompression object"); - Py_DECREF(self); - return NULL; - } -} - -static void -Comp_dealloc(compobject *self) -{ - if (self->is_initialised) - deflateEnd(&self->zst); - Py_XDECREF(self->unused_data); - Py_XDECREF(self->unconsumed_tail); - PyObject_Del(self); -} - -static void -Decomp_dealloc(compobject *self) -{ - if (self->is_initialised) - inflateEnd(&self->zst); - Py_XDECREF(self->unused_data); - Py_XDECREF(self->unconsumed_tail); - PyObject_Del(self); -} - -PyDoc_STRVAR(comp_compress__doc__, -"compress(data) -- Return a string containing data compressed.\n" -"\n" -"After calling this function, some of the input data may still\n" -"be stored in internal buffers for later processing.\n" -"Call the flush() method to clear these buffers."); - - -static PyObject * -PyZlib_objcompress(compobject *self, PyObject *args) -{ - int err, inplen, length = DEFAULTALLOC; - PyObject *RetVal; - Byte *input; - unsigned long start_total_out; - - if (!PyArg_ParseTuple(args, "s#:compress", &input, &inplen)) - return NULL; - - if (!(RetVal = PyString_FromStringAndSize(NULL, length))) - return NULL; - - ENTER_ZLIB - - start_total_out = self->zst.total_out; - self->zst.avail_in = inplen; - self->zst.next_in = input; - self->zst.avail_out = length; - self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal); - - Py_BEGIN_ALLOW_THREADS - err = deflate(&(self->zst), Z_NO_FLUSH); - Py_END_ALLOW_THREADS - - /* while Z_OK and the output buffer is full, there might be more output, - so extend the output buffer and try again */ - while (err == Z_OK && self->zst.avail_out == 0) { - if (_PyString_Resize(&RetVal, length << 1) < 0) - goto error; - self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal) \ - + length; - self->zst.avail_out = length; - length = length << 1; - - Py_BEGIN_ALLOW_THREADS - err = deflate(&(self->zst), Z_NO_FLUSH); - Py_END_ALLOW_THREADS - } - /* We will only get Z_BUF_ERROR if the output buffer was full but - there wasn't more output when we tried again, so it is not an error - condition. - */ - - if (err != Z_OK && err != Z_BUF_ERROR) { - zlib_error(self->zst, err, "while compressing"); - Py_DECREF(RetVal); - RetVal = NULL; - goto error; - } - _PyString_Resize(&RetVal, self->zst.total_out - start_total_out); - - error: - LEAVE_ZLIB - return RetVal; -} - -PyDoc_STRVAR(decomp_decompress__doc__, -"decompress(data, max_length) -- Return a string containing the decompressed\n" -"version of the data.\n" -"\n" -"After calling this function, some of the input data may still be stored in\n" -"internal buffers for later processing.\n" -"Call the flush() method to clear these buffers.\n" -"If the max_length parameter is specified then the return value will be\n" -"no longer than max_length. Unconsumed input data will be stored in\n" -"the unconsumed_tail attribute."); - -static PyObject * -PyZlib_objdecompress(compobject *self, PyObject *args) -{ - int err, inplen, old_length, length = DEFAULTALLOC; - int max_length = 0; - PyObject *RetVal; - Byte *input; - unsigned long start_total_out; - - if (!PyArg_ParseTuple(args, "s#|i:decompress", &input, - &inplen, &max_length)) - return NULL; - if (max_length < 0) { - PyErr_SetString(PyExc_ValueError, - "max_length must be greater than zero"); - return NULL; - } - - /* limit amount of data allocated to max_length */ - if (max_length && length > max_length) - length = max_length; - if (!(RetVal = PyString_FromStringAndSize(NULL, length))) - return NULL; - - ENTER_ZLIB - - start_total_out = self->zst.total_out; - self->zst.avail_in = inplen; - self->zst.next_in = input; - self->zst.avail_out = length; - self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal); - - Py_BEGIN_ALLOW_THREADS - err = inflate(&(self->zst), Z_SYNC_FLUSH); - Py_END_ALLOW_THREADS - - /* While Z_OK and the output buffer is full, there might be more output. - So extend the output buffer and try again. - */ - while (err == Z_OK && self->zst.avail_out == 0) { - /* If max_length set, don't continue decompressing if we've already - reached the limit. - */ - if (max_length && length >= max_length) - break; - - /* otherwise, ... */ - old_length = length; - length = length << 1; - if (max_length && length > max_length) - length = max_length; - - if (_PyString_Resize(&RetVal, length) < 0) - goto error; - self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal) \ - + old_length; - self->zst.avail_out = length - old_length; - - Py_BEGIN_ALLOW_THREADS - err = inflate(&(self->zst), Z_SYNC_FLUSH); - Py_END_ALLOW_THREADS - } - - /* Not all of the compressed data could be accomodated in the output buffer - of specified size. Return the unconsumed tail in an attribute.*/ - if(max_length) { - Py_DECREF(self->unconsumed_tail); - self->unconsumed_tail = PyString_FromStringAndSize((char *)self->zst.next_in, - self->zst.avail_in); - if(!self->unconsumed_tail) { - Py_DECREF(RetVal); - RetVal = NULL; - goto error; - } - } - - /* The end of the compressed data has been reached, so set the - unused_data attribute to a string containing the remainder of the - data in the string. Note that this is also a logical place to call - inflateEnd, but the old behaviour of only calling it on flush() is - preserved. - */ - if (err == Z_STREAM_END) { - Py_XDECREF(self->unused_data); /* Free original empty string */ - self->unused_data = PyString_FromStringAndSize( - (char *)self->zst.next_in, self->zst.avail_in); - if (self->unused_data == NULL) { - Py_DECREF(RetVal); - goto error; - } - /* We will only get Z_BUF_ERROR if the output buffer was full - but there wasn't more output when we tried again, so it is - not an error condition. - */ - } else if (err != Z_OK && err != Z_BUF_ERROR) { - zlib_error(self->zst, err, "while decompressing"); - Py_DECREF(RetVal); - RetVal = NULL; - goto error; - } - - _PyString_Resize(&RetVal, self->zst.total_out - start_total_out); - - error: - LEAVE_ZLIB - - return RetVal; -} - -PyDoc_STRVAR(comp_flush__doc__, -"flush( [mode] ) -- Return a string containing any remaining compressed data.\n" -"\n" -"mode can be one of the constants Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH; the\n" -"default value used when mode is not specified is Z_FINISH.\n" -"If mode == Z_FINISH, the compressor object can no longer be used after\n" -"calling the flush() method. Otherwise, more data can still be compressed."); - -static PyObject * -PyZlib_flush(compobject *self, PyObject *args) -{ - int err, length = DEFAULTALLOC; - PyObject *RetVal; - int flushmode = Z_FINISH; - unsigned long start_total_out; - - if (!PyArg_ParseTuple(args, "|i:flush", &flushmode)) - return NULL; - - /* Flushing with Z_NO_FLUSH is a no-op, so there's no point in - doing any work at all; just return an empty string. */ - if (flushmode == Z_NO_FLUSH) { - return PyString_FromStringAndSize(NULL, 0); - } - - if (!(RetVal = PyString_FromStringAndSize(NULL, length))) - return NULL; - - ENTER_ZLIB - - start_total_out = self->zst.total_out; - self->zst.avail_in = 0; - self->zst.avail_out = length; - self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal); - - Py_BEGIN_ALLOW_THREADS - err = deflate(&(self->zst), flushmode); - Py_END_ALLOW_THREADS - - /* while Z_OK and the output buffer is full, there might be more output, - so extend the output buffer and try again */ - while (err == Z_OK && self->zst.avail_out == 0) { - if (_PyString_Resize(&RetVal, length << 1) < 0) - goto error; - self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal) \ - + length; - self->zst.avail_out = length; - length = length << 1; - - Py_BEGIN_ALLOW_THREADS - err = deflate(&(self->zst), flushmode); - Py_END_ALLOW_THREADS - } - - /* If flushmode is Z_FINISH, we also have to call deflateEnd() to free - various data structures. Note we should only get Z_STREAM_END when - flushmode is Z_FINISH, but checking both for safety*/ - if (err == Z_STREAM_END && flushmode == Z_FINISH) { - err = deflateEnd(&(self->zst)); - if (err != Z_OK) { - zlib_error(self->zst, err, "from deflateEnd()"); - Py_DECREF(RetVal); - RetVal = NULL; - goto error; - } - else - self->is_initialised = 0; - - /* We will only get Z_BUF_ERROR if the output buffer was full - but there wasn't more output when we tried again, so it is - not an error condition. - */ - } else if (err!=Z_OK && err!=Z_BUF_ERROR) { - zlib_error(self->zst, err, "while flushing"); - Py_DECREF(RetVal); - RetVal = NULL; - goto error; - } - - _PyString_Resize(&RetVal, self->zst.total_out - start_total_out); - - error: - LEAVE_ZLIB - - return RetVal; -} - -PyDoc_STRVAR(decomp_flush__doc__, -"flush() -- Return a string containing any remaining decompressed data.\n" -"\n" -"The decompressor object can no longer be used after this call."); - -static PyObject * -PyZlib_unflush(compobject *self, PyObject *args) -{ - int err, length = DEFAULTALLOC; - PyObject * retval = NULL; - unsigned long start_total_out; - - if (!PyArg_ParseTuple(args, "|i:flush", &length)) - return NULL; - if (!(retval = PyString_FromStringAndSize(NULL, length))) - return NULL; - - - ENTER_ZLIB - - start_total_out = self->zst.total_out; - self->zst.avail_out = length; - self->zst.next_out = (Byte *)PyString_AS_STRING(retval); - - Py_BEGIN_ALLOW_THREADS - err = inflate(&(self->zst), Z_FINISH); - Py_END_ALLOW_THREADS - - /* while Z_OK and the output buffer is full, there might be more output, - so extend the output buffer and try again */ - while ((err == Z_OK || err == Z_BUF_ERROR) && self->zst.avail_out == 0) { - if (_PyString_Resize(&retval, length << 1) < 0) - goto error; - self->zst.next_out = (Byte *)PyString_AS_STRING(retval) + length; - self->zst.avail_out = length; - length = length << 1; - - Py_BEGIN_ALLOW_THREADS - err = inflate(&(self->zst), Z_FINISH); - Py_END_ALLOW_THREADS - } - - /* If flushmode is Z_FINISH, we also have to call deflateEnd() to free - various data structures. Note we should only get Z_STREAM_END when - flushmode is Z_FINISH */ - if (err == Z_STREAM_END) { - err = inflateEnd(&(self->zst)); - self->is_initialised = 0; - if (err != Z_OK) { - zlib_error(self->zst, err, "from inflateEnd()"); - Py_DECREF(retval); - retval = NULL; - goto error; - } - } - _PyString_Resize(&retval, self->zst.total_out - start_total_out); - -error: - - LEAVE_ZLIB - - return retval; -} - -static PyMethodDef comp_methods[] = -{ - {"compress", (binaryfunc)PyZlib_objcompress, METH_VARARGS, - comp_compress__doc__}, - {"flush", (binaryfunc)PyZlib_flush, METH_VARARGS, - comp_flush__doc__}, - {NULL, NULL} -}; - -static PyMethodDef Decomp_methods[] = -{ - {"decompress", (binaryfunc)PyZlib_objdecompress, METH_VARARGS, - decomp_decompress__doc__}, - {"flush", (binaryfunc)PyZlib_unflush, METH_VARARGS, - decomp_flush__doc__}, - {NULL, NULL} -}; - -static PyObject * -Comp_getattr(compobject *self, char *name) -{ - /* No ENTER/LEAVE_ZLIB is necessary because this fn doesn't touch - internal data. */ - - return Py_FindMethod(comp_methods, (PyObject *)self, name); -} - -static PyObject * -Decomp_getattr(compobject *self, char *name) -{ - PyObject * retval; - - ENTER_ZLIB - - if (strcmp(name, "unused_data") == 0) { - Py_INCREF(self->unused_data); - retval = self->unused_data; - } else if (strcmp(name, "unconsumed_tail") == 0) { - Py_INCREF(self->unconsumed_tail); - retval = self->unconsumed_tail; - } else - retval = Py_FindMethod(Decomp_methods, (PyObject *)self, name); - - LEAVE_ZLIB - - return retval; -} - -PyDoc_STRVAR(adler32__doc__, -"adler32(string[, start]) -- Compute an Adler-32 checksum of string.\n" -"\n" -"An optional starting value can be specified. The returned checksum is\n" -"an integer."); - -static PyObject * -PyZlib_adler32(PyObject *self, PyObject *args) -{ - uLong adler32val = adler32(0L, Z_NULL, 0); - Byte *buf; - int len; - - if (!PyArg_ParseTuple(args, "s#|l:adler32", &buf, &len, &adler32val)) - return NULL; - adler32val = adler32(adler32val, buf, len); - return PyInt_FromLong(adler32val); -} - -PyDoc_STRVAR(crc32__doc__, -"crc32(string[, start]) -- Compute a CRC-32 checksum of string.\n" -"\n" -"An optional starting value can be specified. The returned checksum is\n" -"an integer."); - -static PyObject * -PyZlib_crc32(PyObject *self, PyObject *args) -{ - uLong crc32val = crc32(0L, Z_NULL, 0); - Byte *buf; - int len; - if (!PyArg_ParseTuple(args, "s#|l:crc32", &buf, &len, &crc32val)) - return NULL; - crc32val = crc32(crc32val, buf, len); - return PyInt_FromLong(crc32val); -} - - -static PyMethodDef zlib_methods[] = -{ - {"adler32", (PyCFunction)PyZlib_adler32, METH_VARARGS, - adler32__doc__}, - {"compress", (PyCFunction)PyZlib_compress, METH_VARARGS, - compress__doc__}, - {"compressobj", (PyCFunction)PyZlib_compressobj, METH_VARARGS, - compressobj__doc__}, - {"crc32", (PyCFunction)PyZlib_crc32, METH_VARARGS, - crc32__doc__}, - {"decompress", (PyCFunction)PyZlib_decompress, METH_VARARGS, - decompress__doc__}, - {"decompressobj", (PyCFunction)PyZlib_decompressobj, METH_VARARGS, - decompressobj__doc__}, - {NULL, NULL} -}; - -static PyTypeObject Comptype = { - PyObject_HEAD_INIT(0) - 0, - "zlib.Compress", - sizeof(compobject), - 0, - (destructor)Comp_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)Comp_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ -}; - -static PyTypeObject Decomptype = { - PyObject_HEAD_INIT(0) - 0, - "zlib.Decompress", - sizeof(compobject), - 0, - (destructor)Decomp_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)Decomp_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ -}; - -PyDoc_STRVAR(zlib_module_documentation, -"The functions in this module allow compression and decompression using the\n" -"zlib library, which is based on GNU zip.\n" -"\n" -"adler32(string[, start]) -- Compute an Adler-32 checksum.\n" -"compress(string[, level]) -- Compress string, with compression level in 1-9.\n" -"compressobj([level]) -- Return a compressor object.\n" -"crc32(string[, start]) -- Compute a CRC-32 checksum.\n" -"decompress(string,[wbits],[bufsize]) -- Decompresses a compressed string.\n" -"decompressobj([wbits]) -- Return a decompressor object.\n" -"\n" -"'wbits' is window buffer size.\n" -"Compressor objects support compress() and flush() methods; decompressor\n" -"objects support decompress() and flush()."); - -PyMODINIT_FUNC -PyInit_zlib(void) -{ - PyObject *m, *ver; - Comptype.ob_type = &PyType_Type; - Decomptype.ob_type = &PyType_Type; - m = Py_InitModule4("zlib", zlib_methods, - zlib_module_documentation, - (PyObject*)NULL,PYTHON_API_VERSION); - - ZlibError = PyErr_NewException("zlib.error", NULL, NULL); - if (ZlibError != NULL) { - Py_INCREF(ZlibError); - PyModule_AddObject(m, "error", ZlibError); - } - PyModule_AddIntConstant(m, "MAX_WBITS", MAX_WBITS); - PyModule_AddIntConstant(m, "DEFLATED", DEFLATED); - PyModule_AddIntConstant(m, "DEF_MEM_LEVEL", DEF_MEM_LEVEL); - PyModule_AddIntConstant(m, "Z_BEST_SPEED", Z_BEST_SPEED); - PyModule_AddIntConstant(m, "Z_BEST_COMPRESSION", Z_BEST_COMPRESSION); - PyModule_AddIntConstant(m, "Z_DEFAULT_COMPRESSION", Z_DEFAULT_COMPRESSION); - PyModule_AddIntConstant(m, "Z_FILTERED", Z_FILTERED); - PyModule_AddIntConstant(m, "Z_HUFFMAN_ONLY", Z_HUFFMAN_ONLY); - PyModule_AddIntConstant(m, "Z_DEFAULT_STRATEGY", Z_DEFAULT_STRATEGY); - - PyModule_AddIntConstant(m, "Z_FINISH", Z_FINISH); - PyModule_AddIntConstant(m, "Z_NO_FLUSH", Z_NO_FLUSH); - PyModule_AddIntConstant(m, "Z_SYNC_FLUSH", Z_SYNC_FLUSH); - PyModule_AddIntConstant(m, "Z_FULL_FLUSH", Z_FULL_FLUSH); - - ver = PyString_FromString(ZLIB_VERSION); - if (ver != NULL) - PyModule_AddObject(m, "ZLIB_VERSION", ver); - - PyModule_AddStringConstant(m, "__version__", "1.0"); - -#ifdef WITH_THREAD - zlib_lock = PyThread_allocate_lock(); -#endif /* WITH_THREAD */ -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/.cvsignore b/SDKs/XPlatform/Cypython-2.3.3/Objects/.cvsignore deleted file mode 100644 index 6ea1ddf4..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -add2lib -Makefile diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/abstract.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/abstract.c deleted file mode 100644 index c9055ac8..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/abstract.c +++ /dev/null @@ -1,2192 +0,0 @@ -/* Abstract Object Interface (many thanks to Jim Fulton) */ - -#include "Python.h" -#include -#include "structmember.h" /* we need the offsetof() macro from there */ -#include "longintrepr.h" - -#define NEW_STYLE_NUMBER(o) PyType_HasFeature((o)->ob_type, \ - Py_TPFLAGS_CHECKTYPES) - -/* Shorthands to return certain errors */ - -static PyObject * -type_error(const char *msg) -{ - PyErr_SetString(PyExc_TypeError, msg); - return NULL; -} - -static PyObject * -null_error(void) -{ - if (!PyErr_Occurred()) - PyErr_SetString(PyExc_SystemError, - "null argument to internal routine"); - return NULL; -} - -/* Operations on any object */ - -int -PyObject_Cmp(PyObject *o1, PyObject *o2, int *result) -{ - int r; - - if (o1 == NULL || o2 == NULL) { - null_error(); - return -1; - } - r = PyObject_Compare(o1, o2); - if (PyErr_Occurred()) - return -1; - *result = r; - return 0; -} - -PyObject * -PyObject_Type(PyObject *o) -{ - PyObject *v; - - if (o == NULL) - return null_error(); - v = (PyObject *)o->ob_type; - Py_INCREF(v); - return v; -} - -int -PyObject_Size(PyObject *o) -{ - PySequenceMethods *m; - - if (o == NULL) { - null_error(); - return -1; - } - - m = o->ob_type->tp_as_sequence; - if (m && m->sq_length) - return m->sq_length(o); - - return PyMapping_Size(o); -} - -#undef PyObject_Length -int -PyObject_Length(PyObject *o) -{ - return PyObject_Size(o); -} -#define PyObject_Length PyObject_Size - -PyObject * -PyObject_GetItem(PyObject *o, PyObject *key) -{ - PyMappingMethods *m; - - if (o == NULL || key == NULL) - return null_error(); - - m = o->ob_type->tp_as_mapping; - if (m && m->mp_subscript) - return m->mp_subscript(o, key); - - if (o->ob_type->tp_as_sequence) { - if (PyInt_Check(key)) - return PySequence_GetItem(o, PyInt_AsLong(key)); - else if (PyLong_Check(key)) { - long key_value = PyLong_AsLong(key); - if (key_value == -1 && PyErr_Occurred()) - return NULL; - return PySequence_GetItem(o, key_value); - } - else if (o->ob_type->tp_as_sequence->sq_item) - return type_error("sequence index must be integer"); - } - - return type_error("unsubscriptable object"); -} - -int -PyObject_SetItem(PyObject *o, PyObject *key, PyObject *value) -{ - PyMappingMethods *m; - - if (o == NULL || key == NULL || value == NULL) { - null_error(); - return -1; - } - m = o->ob_type->tp_as_mapping; - if (m && m->mp_ass_subscript) - return m->mp_ass_subscript(o, key, value); - - if (o->ob_type->tp_as_sequence) { - if (PyInt_Check(key)) - return PySequence_SetItem(o, PyInt_AsLong(key), value); - else if (PyLong_Check(key)) { - long key_value = PyLong_AsLong(key); - if (key_value == -1 && PyErr_Occurred()) - return -1; - return PySequence_SetItem(o, key_value, value); - } - else if (o->ob_type->tp_as_sequence->sq_ass_item) { - type_error("sequence index must be integer"); - return -1; - } - } - - type_error("object does not support item assignment"); - return -1; -} - -int -PyObject_DelItem(PyObject *o, PyObject *key) -{ - PyMappingMethods *m; - - if (o == NULL || key == NULL) { - null_error(); - return -1; - } - m = o->ob_type->tp_as_mapping; - if (m && m->mp_ass_subscript) - return m->mp_ass_subscript(o, key, (PyObject*)NULL); - - if (o->ob_type->tp_as_sequence) { - if (PyInt_Check(key)) - return PySequence_DelItem(o, PyInt_AsLong(key)); - else if (PyLong_Check(key)) { - long key_value = PyLong_AsLong(key); - if (key_value == -1 && PyErr_Occurred()) - return -1; - return PySequence_DelItem(o, key_value); - } - else if (o->ob_type->tp_as_sequence->sq_ass_item) { - type_error("sequence index must be integer"); - return -1; - } - } - - type_error("object does not support item deletion"); - return -1; -} - -int -PyObject_DelItemString(PyObject *o, char *key) -{ - PyObject *okey; - int ret; - - if (o == NULL || key == NULL) { - null_error(); - return -1; - } - okey = PyString_FromString(key); - if (okey == NULL) - return -1; - ret = PyObject_DelItem(o, okey); - Py_DECREF(okey); - return ret; -} - -int PyObject_AsCharBuffer(PyObject *obj, - const char **buffer, - int *buffer_len) -{ - PyBufferProcs *pb; - const char *pp; - int len; - - if (obj == NULL || buffer == NULL || buffer_len == NULL) { - null_error(); - return -1; - } - pb = obj->ob_type->tp_as_buffer; - if (pb == NULL || - pb->bf_getcharbuffer == NULL || - pb->bf_getsegcount == NULL) { - PyErr_SetString(PyExc_TypeError, - "expected a character buffer object"); - return -1; - } - if ((*pb->bf_getsegcount)(obj,NULL) != 1) { - PyErr_SetString(PyExc_TypeError, - "expected a single-segment buffer object"); - return -1; - } - len = (*pb->bf_getcharbuffer)(obj, 0, &pp); - if (len < 0) - return -1; - *buffer = pp; - *buffer_len = len; - return 0; -} - -int -PyObject_CheckReadBuffer(PyObject *obj) -{ - PyBufferProcs *pb = obj->ob_type->tp_as_buffer; - - if (pb == NULL || - pb->bf_getreadbuffer == NULL || - pb->bf_getsegcount == NULL || - (*pb->bf_getsegcount)(obj, NULL) != 1) - return 0; - return 1; -} - -int PyObject_AsReadBuffer(PyObject *obj, - const void **buffer, - int *buffer_len) -{ - PyBufferProcs *pb; - void *pp; - int len; - - if (obj == NULL || buffer == NULL || buffer_len == NULL) { - null_error(); - return -1; - } - pb = obj->ob_type->tp_as_buffer; - if (pb == NULL || - pb->bf_getreadbuffer == NULL || - pb->bf_getsegcount == NULL) { - PyErr_SetString(PyExc_TypeError, - "expected a readable buffer object"); - return -1; - } - if ((*pb->bf_getsegcount)(obj, NULL) != 1) { - PyErr_SetString(PyExc_TypeError, - "expected a single-segment buffer object"); - return -1; - } - len = (*pb->bf_getreadbuffer)(obj, 0, &pp); - if (len < 0) - return -1; - *buffer = pp; - *buffer_len = len; - return 0; -} - -int PyObject_AsWriteBuffer(PyObject *obj, - void **buffer, - int *buffer_len) -{ - PyBufferProcs *pb; - void*pp; - int len; - - if (obj == NULL || buffer == NULL || buffer_len == NULL) { - null_error(); - return -1; - } - pb = obj->ob_type->tp_as_buffer; - if (pb == NULL || - pb->bf_getwritebuffer == NULL || - pb->bf_getsegcount == NULL) { - PyErr_SetString(PyExc_TypeError, - "expected a writeable buffer object"); - return -1; - } - if ((*pb->bf_getsegcount)(obj, NULL) != 1) { - PyErr_SetString(PyExc_TypeError, - "expected a single-segment buffer object"); - return -1; - } - len = (*pb->bf_getwritebuffer)(obj,0,&pp); - if (len < 0) - return -1; - *buffer = pp; - *buffer_len = len; - return 0; -} - -/* Operations on numbers */ - -int -PyNumber_Check(PyObject *o) -{ - return o && o->ob_type->tp_as_number && - (o->ob_type->tp_as_number->nb_int || - o->ob_type->tp_as_number->nb_float); -} - -/* Binary operators */ - -/* New style number protocol support */ - -#define NB_SLOT(x) offsetof(PyNumberMethods, x) -#define NB_BINOP(nb_methods, slot) \ - (*(binaryfunc*)(& ((char*)nb_methods)[slot])) -#define NB_TERNOP(nb_methods, slot) \ - (*(ternaryfunc*)(& ((char*)nb_methods)[slot])) - -/* - Calling scheme used for binary operations: - - v w Action - ------------------------------------------------------------------- - new new w.op(v,w)[*], v.op(v,w), w.op(v,w) - new old v.op(v,w), coerce(v,w), v.op(v,w) - old new w.op(v,w), coerce(v,w), v.op(v,w) - old old coerce(v,w), v.op(v,w) - - [*] only when v->ob_type != w->ob_type && w->ob_type is a subclass of - v->ob_type - - Legend: - ------- - * new == new style number - * old == old style number - * Action indicates the order in which operations are tried until either - a valid result is produced or an error occurs. - - */ - -static PyObject * -binary_op1(PyObject *v, PyObject *w, const int op_slot) -{ - PyObject *x; - binaryfunc slotv = NULL; - binaryfunc slotw = NULL; - - if (v->ob_type->tp_as_number != NULL && NEW_STYLE_NUMBER(v)) - slotv = NB_BINOP(v->ob_type->tp_as_number, op_slot); - if (w->ob_type != v->ob_type && - w->ob_type->tp_as_number != NULL && NEW_STYLE_NUMBER(w)) { - slotw = NB_BINOP(w->ob_type->tp_as_number, op_slot); - if (slotw == slotv) - slotw = NULL; - } - if (slotv) { - if (slotw && PyType_IsSubtype(w->ob_type, v->ob_type)) { - x = slotw(v, w); - if (x != Py_NotImplemented) - return x; - Py_DECREF(x); /* can't do it */ - slotw = NULL; - } - x = slotv(v, w); - if (x != Py_NotImplemented) - return x; - Py_DECREF(x); /* can't do it */ - } - if (slotw) { - x = slotw(v, w); - if (x != Py_NotImplemented) - return x; - Py_DECREF(x); /* can't do it */ - } - if (!NEW_STYLE_NUMBER(v) || !NEW_STYLE_NUMBER(w)) { - int err = PyNumber_CoerceEx(&v, &w); - if (err < 0) { - return NULL; - } - if (err == 0) { - PyNumberMethods *mv = v->ob_type->tp_as_number; - if (mv) { - binaryfunc slot; - slot = NB_BINOP(mv, op_slot); - if (slot) { - PyObject *x = slot(v, w); - Py_DECREF(v); - Py_DECREF(w); - return x; - } - } - /* CoerceEx incremented the reference counts */ - Py_DECREF(v); - Py_DECREF(w); - } - } - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; -} - -static PyObject * -binop_type_error(PyObject *v, PyObject *w, const char *op_name) -{ - PyErr_Format(PyExc_TypeError, - "unsupported operand type(s) for %s: '%s' and '%s'", - op_name, - v->ob_type->tp_name, - w->ob_type->tp_name); - return NULL; -} - -static PyObject * -binary_op(PyObject *v, PyObject *w, const int op_slot, const char *op_name) -{ - PyObject *result = binary_op1(v, w, op_slot); - if (result == Py_NotImplemented) { - Py_DECREF(result); - return binop_type_error(v, w, op_name); - } - return result; -} - - -/* - Calling scheme used for ternary operations: - - *** In some cases, w.op is called before v.op; see binary_op1. *** - - v w z Action - ------------------------------------------------------------------- - new new new v.op(v,w,z), w.op(v,w,z), z.op(v,w,z) - new old new v.op(v,w,z), z.op(v,w,z), coerce(v,w,z), v.op(v,w,z) - old new new w.op(v,w,z), z.op(v,w,z), coerce(v,w,z), v.op(v,w,z) - old old new z.op(v,w,z), coerce(v,w,z), v.op(v,w,z) - new new old v.op(v,w,z), w.op(v,w,z), coerce(v,w,z), v.op(v,w,z) - new old old v.op(v,w,z), coerce(v,w,z), v.op(v,w,z) - old new old w.op(v,w,z), coerce(v,w,z), v.op(v,w,z) - old old old coerce(v,w,z), v.op(v,w,z) - - Legend: - ------- - * new == new style number - * old == old style number - * Action indicates the order in which operations are tried until either - a valid result is produced or an error occurs. - * coerce(v,w,z) actually does: coerce(v,w), coerce(v,z), coerce(w,z) and - only if z != Py_None; if z == Py_None, then it is treated as absent - variable and only coerce(v,w) is tried. - - */ - -static PyObject * -ternary_op(PyObject *v, - PyObject *w, - PyObject *z, - const int op_slot, - const char *op_name) -{ - PyNumberMethods *mv, *mw, *mz; - PyObject *x = NULL; - ternaryfunc slotv = NULL; - ternaryfunc slotw = NULL; - ternaryfunc slotz = NULL; - - mv = v->ob_type->tp_as_number; - mw = w->ob_type->tp_as_number; - if (mv != NULL && NEW_STYLE_NUMBER(v)) - slotv = NB_TERNOP(mv, op_slot); - if (w->ob_type != v->ob_type && - mw != NULL && NEW_STYLE_NUMBER(w)) { - slotw = NB_TERNOP(mw, op_slot); - if (slotw == slotv) - slotw = NULL; - } - if (slotv) { - if (slotw && PyType_IsSubtype(w->ob_type, v->ob_type)) { - x = slotw(v, w, z); - if (x != Py_NotImplemented) - return x; - Py_DECREF(x); /* can't do it */ - slotw = NULL; - } - x = slotv(v, w, z); - if (x != Py_NotImplemented) - return x; - Py_DECREF(x); /* can't do it */ - } - if (slotw) { - x = slotw(v, w, z); - if (x != Py_NotImplemented) - return x; - Py_DECREF(x); /* can't do it */ - } - mz = z->ob_type->tp_as_number; - if (mz != NULL && NEW_STYLE_NUMBER(z)) { - slotz = NB_TERNOP(mz, op_slot); - if (slotz == slotv || slotz == slotw) - slotz = NULL; - if (slotz) { - x = slotz(v, w, z); - if (x != Py_NotImplemented) - return x; - Py_DECREF(x); /* can't do it */ - } - } - - if (!NEW_STYLE_NUMBER(v) || !NEW_STYLE_NUMBER(w) || - (z != Py_None && !NEW_STYLE_NUMBER(z))) { - /* we have an old style operand, coerce */ - PyObject *v1, *z1, *w2, *z2; - int c; - - c = PyNumber_Coerce(&v, &w); - if (c != 0) - goto error3; - - /* Special case: if the third argument is None, it is - treated as absent argument and not coerced. */ - if (z == Py_None) { - if (v->ob_type->tp_as_number) { - slotz = NB_TERNOP(v->ob_type->tp_as_number, - op_slot); - if (slotz) - x = slotz(v, w, z); - else - c = -1; - } - else - c = -1; - goto error2; - } - v1 = v; - z1 = z; - c = PyNumber_Coerce(&v1, &z1); - if (c != 0) - goto error2; - w2 = w; - z2 = z1; - c = PyNumber_Coerce(&w2, &z2); - if (c != 0) - goto error1; - - if (v1->ob_type->tp_as_number != NULL) { - slotv = NB_TERNOP(v1->ob_type->tp_as_number, - op_slot); - if (slotv) - x = slotv(v1, w2, z2); - else - c = -1; - } - else - c = -1; - - Py_DECREF(w2); - Py_DECREF(z2); - error1: - Py_DECREF(v1); - Py_DECREF(z1); - error2: - Py_DECREF(v); - Py_DECREF(w); - error3: - if (c >= 0) - return x; - } - - if (z == Py_None) - PyErr_Format( - PyExc_TypeError, - "unsupported operand type(s) for ** or pow(): " - "'%s' and '%s'", - v->ob_type->tp_name, - w->ob_type->tp_name); - else - PyErr_Format( - PyExc_TypeError, - "unsupported operand type(s) for pow(): " - "'%s', '%s', '%s'", - v->ob_type->tp_name, - w->ob_type->tp_name, - z->ob_type->tp_name); - return NULL; -} - -#define BINARY_FUNC(func, op, op_name) \ - PyObject * \ - func(PyObject *v, PyObject *w) { \ - return binary_op(v, w, NB_SLOT(op), op_name); \ - } - -BINARY_FUNC(PyNumber_Or, nb_or, "|") -BINARY_FUNC(PyNumber_Xor, nb_xor, "^") -BINARY_FUNC(PyNumber_And, nb_and, "&") -BINARY_FUNC(PyNumber_Lshift, nb_lshift, "<<") -BINARY_FUNC(PyNumber_Rshift, nb_rshift, ">>") -BINARY_FUNC(PyNumber_Subtract, nb_subtract, "-") -BINARY_FUNC(PyNumber_Divide, nb_divide, "/") -BINARY_FUNC(PyNumber_Divmod, nb_divmod, "divmod()") - -PyObject * -PyNumber_Add(PyObject *v, PyObject *w) -{ - PyObject *result = binary_op1(v, w, NB_SLOT(nb_add)); - if (result == Py_NotImplemented) { - PySequenceMethods *m = v->ob_type->tp_as_sequence; - if (m && m->sq_concat) { - Py_DECREF(result); - result = (*m->sq_concat)(v, w); - } - if (result == Py_NotImplemented) { - Py_DECREF(result); - return binop_type_error(v, w, "+"); - } - } - return result; -} - -static PyObject * -sequence_repeat(intargfunc repeatfunc, PyObject *seq, PyObject *n) -{ - long count; - if (PyInt_Check(n)) { - count = PyInt_AsLong(n); - } - else if (PyLong_Check(n)) { - count = PyLong_AsLong(n); - if (count == -1 && PyErr_Occurred()) - return NULL; - } - else { - return type_error( - "can't multiply sequence to non-int"); - } -#if LONG_MAX != INT_MAX - if (count > INT_MAX) { - PyErr_SetString(PyExc_ValueError, - "sequence repeat count too large"); - return NULL; - } - else if (count < INT_MIN) - count = INT_MIN; - /* XXX Why don't I either - - - set count to -1 whenever it's negative (after all, - sequence repeat usually treats negative numbers - as zero(); or - - - raise an exception when it's less than INT_MIN? - - I'm thinking about a hypothetical use case where some - sequence type might use a negative value as a flag of - some kind. In those cases I don't want to break the - code by mapping all negative values to -1. But I also - don't want to break e.g. []*(-sys.maxint), which is - perfectly safe, returning []. As a compromise, I do - map out-of-range negative values. - */ -#endif - return (*repeatfunc)(seq, (int)count); -} - -PyObject * -PyNumber_Multiply(PyObject *v, PyObject *w) -{ - PyObject *result = binary_op1(v, w, NB_SLOT(nb_multiply)); - if (result == Py_NotImplemented) { - PySequenceMethods *mv = v->ob_type->tp_as_sequence; - PySequenceMethods *mw = w->ob_type->tp_as_sequence; - Py_DECREF(result); - if (mv && mv->sq_repeat) { - return sequence_repeat(mv->sq_repeat, v, w); - } - else if (mw && mw->sq_repeat) { - return sequence_repeat(mw->sq_repeat, w, v); - } - result = binop_type_error(v, w, "*"); - } - return result; -} - -PyObject * -PyNumber_FloorDivide(PyObject *v, PyObject *w) -{ - /* XXX tp_flags test */ - return binary_op(v, w, NB_SLOT(nb_floor_divide), "//"); -} - -PyObject * -PyNumber_TrueDivide(PyObject *v, PyObject *w) -{ - /* XXX tp_flags test */ - return binary_op(v, w, NB_SLOT(nb_true_divide), "/"); -} - -PyObject * -PyNumber_Remainder(PyObject *v, PyObject *w) -{ - return binary_op(v, w, NB_SLOT(nb_remainder), "%"); -} - -PyObject * -PyNumber_Power(PyObject *v, PyObject *w, PyObject *z) -{ - return ternary_op(v, w, z, NB_SLOT(nb_power), "** or pow()"); -} - -/* Binary in-place operators */ - -/* The in-place operators are defined to fall back to the 'normal', - non in-place operations, if the in-place methods are not in place. - - - If the left hand object has the appropriate struct members, and - they are filled, call the appropriate function and return the - result. No coercion is done on the arguments; the left-hand object - is the one the operation is performed on, and it's up to the - function to deal with the right-hand object. - - - Otherwise, in-place modification is not supported. Handle it exactly as - a non in-place operation of the same kind. - - */ - -#define HASINPLACE(t) \ - PyType_HasFeature((t)->ob_type, Py_TPFLAGS_HAVE_INPLACEOPS) - -static PyObject * -binary_iop1(PyObject *v, PyObject *w, const int iop_slot, const int op_slot) -{ - PyNumberMethods *mv = v->ob_type->tp_as_number; - if (mv != NULL && HASINPLACE(v)) { - binaryfunc slot = NB_BINOP(mv, iop_slot); - if (slot) { - PyObject *x = (slot)(v, w); - if (x != Py_NotImplemented) { - return x; - } - Py_DECREF(x); - } - } - return binary_op1(v, w, op_slot); -} - -static PyObject * -binary_iop(PyObject *v, PyObject *w, const int iop_slot, const int op_slot, - const char *op_name) -{ - PyObject *result = binary_iop1(v, w, iop_slot, op_slot); - if (result == Py_NotImplemented) { - Py_DECREF(result); - return binop_type_error(v, w, op_name); - } - return result; -} - -#define INPLACE_BINOP(func, iop, op, op_name) \ - PyObject * \ - func(PyObject *v, PyObject *w) { \ - return binary_iop(v, w, NB_SLOT(iop), NB_SLOT(op), op_name); \ - } - -INPLACE_BINOP(PyNumber_InPlaceOr, nb_inplace_or, nb_or, "|=") -INPLACE_BINOP(PyNumber_InPlaceXor, nb_inplace_xor, nb_xor, "^=") -INPLACE_BINOP(PyNumber_InPlaceAnd, nb_inplace_and, nb_and, "&=") -INPLACE_BINOP(PyNumber_InPlaceLshift, nb_inplace_lshift, nb_lshift, "<<=") -INPLACE_BINOP(PyNumber_InPlaceRshift, nb_inplace_rshift, nb_rshift, ">>=") -INPLACE_BINOP(PyNumber_InPlaceSubtract, nb_inplace_subtract, nb_subtract, "-=") -INPLACE_BINOP(PyNumber_InPlaceDivide, nb_inplace_divide, nb_divide, "/=") - -PyObject * -PyNumber_InPlaceFloorDivide(PyObject *v, PyObject *w) -{ - /* XXX tp_flags test */ - return binary_iop(v, w, NB_SLOT(nb_inplace_floor_divide), - NB_SLOT(nb_floor_divide), "//="); -} - -PyObject * -PyNumber_InPlaceTrueDivide(PyObject *v, PyObject *w) -{ - /* XXX tp_flags test */ - return binary_iop(v, w, NB_SLOT(nb_inplace_true_divide), - NB_SLOT(nb_true_divide), "/="); -} - -PyObject * -PyNumber_InPlaceAdd(PyObject *v, PyObject *w) -{ - PyObject *result = binary_iop1(v, w, NB_SLOT(nb_inplace_add), - NB_SLOT(nb_add)); - if (result == Py_NotImplemented) { - PySequenceMethods *m = v->ob_type->tp_as_sequence; - Py_DECREF(result); - if (m != NULL) { - binaryfunc f = NULL; - if (HASINPLACE(v)) - f = m->sq_inplace_concat; - if (f == NULL) - f = m->sq_concat; - if (f != NULL) - return (*f)(v, w); - } - result = binop_type_error(v, w, "+="); - } - return result; -} - -PyObject * -PyNumber_InPlaceMultiply(PyObject *v, PyObject *w) -{ - PyObject *result = binary_iop1(v, w, NB_SLOT(nb_inplace_multiply), - NB_SLOT(nb_multiply)); - if (result == Py_NotImplemented) { - intargfunc f = NULL; - PySequenceMethods *mv = v->ob_type->tp_as_sequence; - PySequenceMethods *mw = w->ob_type->tp_as_sequence; - Py_DECREF(result); - if (mv != NULL) { - if (HASINPLACE(v)) - f = mv->sq_inplace_repeat; - if (f == NULL) - f = mv->sq_repeat; - if (f != NULL) - return sequence_repeat(f, v, w); - } - else if (mw != NULL) { - /* Note that the right hand operand should not be - * mutated in this case so sq_inplace_repeat is not - * used. */ - if (mw->sq_repeat) - return sequence_repeat(mw->sq_repeat, w, v); - } - result = binop_type_error(v, w, "*="); - } - return result; -} - -PyObject * -PyNumber_InPlaceRemainder(PyObject *v, PyObject *w) -{ - return binary_iop(v, w, NB_SLOT(nb_inplace_remainder), - NB_SLOT(nb_remainder), "%="); -} - -PyObject * -PyNumber_InPlacePower(PyObject *v, PyObject *w, PyObject *z) -{ - if (HASINPLACE(v) && v->ob_type->tp_as_number && - v->ob_type->tp_as_number->nb_inplace_power != NULL) { - return ternary_op(v, w, z, NB_SLOT(nb_inplace_power), "**="); - } - else { - return ternary_op(v, w, z, NB_SLOT(nb_power), "**="); - } -} - - -/* Unary operators and functions */ - -PyObject * -PyNumber_Negative(PyObject *o) -{ - PyNumberMethods *m; - - if (o == NULL) - return null_error(); - m = o->ob_type->tp_as_number; - if (m && m->nb_negative) - return (*m->nb_negative)(o); - - return type_error("bad operand type for unary -"); -} - -PyObject * -PyNumber_Positive(PyObject *o) -{ - PyNumberMethods *m; - - if (o == NULL) - return null_error(); - m = o->ob_type->tp_as_number; - if (m && m->nb_positive) - return (*m->nb_positive)(o); - - return type_error("bad operand type for unary +"); -} - -PyObject * -PyNumber_Invert(PyObject *o) -{ - PyNumberMethods *m; - - if (o == NULL) - return null_error(); - m = o->ob_type->tp_as_number; - if (m && m->nb_invert) - return (*m->nb_invert)(o); - - return type_error("bad operand type for unary ~"); -} - -PyObject * -PyNumber_Absolute(PyObject *o) -{ - PyNumberMethods *m; - - if (o == NULL) - return null_error(); - m = o->ob_type->tp_as_number; - if (m && m->nb_absolute) - return m->nb_absolute(o); - - return type_error("bad operand type for abs()"); -} - -/* Add a check for embedded NULL-bytes in the argument. */ -static PyObject * -int_from_string(const char *s, int len) -{ - char *end; - PyObject *x; - - x = PyInt_FromString((char*)s, &end, 10); - if (x == NULL) - return NULL; - if (end != s + len) { - PyErr_SetString(PyExc_ValueError, - "null byte in argument for int()"); - Py_DECREF(x); - return NULL; - } - return x; -} - -PyObject * -PyNumber_Int(PyObject *o) -{ - PyNumberMethods *m; - const char *buffer; - int buffer_len; - - if (o == NULL) - return null_error(); - if (PyInt_CheckExact(o)) { - Py_INCREF(o); - return o; - } - if (PyInt_Check(o)) { - PyIntObject *io = (PyIntObject*)o; - return PyInt_FromLong(io->ob_ival); - } - if (PyString_Check(o)) - return int_from_string(PyString_AS_STRING(o), - PyString_GET_SIZE(o)); -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(o)) - return PyInt_FromUnicode(PyUnicode_AS_UNICODE(o), - PyUnicode_GET_SIZE(o), - 10); -#endif - m = o->ob_type->tp_as_number; - if (m && m->nb_int) - return m->nb_int(o); - if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len)) - return int_from_string((char*)buffer, buffer_len); - - return type_error("int() argument must be a string or a number"); -} - -/* Add a check for embedded NULL-bytes in the argument. */ -static PyObject * -long_from_string(const char *s, int len) -{ - char *end; - PyObject *x; - - x = PyLong_FromString((char*)s, &end, 10); - if (x == NULL) - return NULL; - if (end != s + len) { - PyErr_SetString(PyExc_ValueError, - "null byte in argument for long()"); - Py_DECREF(x); - return NULL; - } - return x; -} - -PyObject * -PyNumber_Long(PyObject *o) -{ - PyNumberMethods *m; - const char *buffer; - int buffer_len; - - if (o == NULL) - return null_error(); - if (PyLong_CheckExact(o)) { - Py_INCREF(o); - return o; - } - if (PyLong_Check(o)) - return _PyLong_Copy((PyLongObject *)o); - if (PyString_Check(o)) - /* need to do extra error checking that PyLong_FromString() - * doesn't do. In particular long('9.5') must raise an - * exception, not truncate the float. - */ - return long_from_string(PyString_AS_STRING(o), - PyString_GET_SIZE(o)); -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(o)) - /* The above check is done in PyLong_FromUnicode(). */ - return PyLong_FromUnicode(PyUnicode_AS_UNICODE(o), - PyUnicode_GET_SIZE(o), - 10); -#endif - m = o->ob_type->tp_as_number; - if (m && m->nb_long) - return m->nb_long(o); - if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len)) - return long_from_string(buffer, buffer_len); - - return type_error("long() argument must be a string or a number"); -} - -PyObject * -PyNumber_Float(PyObject *o) -{ - PyNumberMethods *m; - - if (o == NULL) - return null_error(); - if (PyFloat_CheckExact(o)) { - Py_INCREF(o); - return o; - } - if (PyFloat_Check(o)) { - PyFloatObject *po = (PyFloatObject *)o; - return PyFloat_FromDouble(po->ob_fval); - } - if (!PyString_Check(o)) { - m = o->ob_type->tp_as_number; - if (m && m->nb_float) - return m->nb_float(o); - } - return PyFloat_FromString(o, NULL); -} - -/* Operations on sequences */ - -int -PySequence_Check(PyObject *s) -{ - return s != NULL && s->ob_type->tp_as_sequence && - s->ob_type->tp_as_sequence->sq_item != NULL; -} - -int -PySequence_Size(PyObject *s) -{ - PySequenceMethods *m; - - if (s == NULL) { - null_error(); - return -1; - } - - m = s->ob_type->tp_as_sequence; - if (m && m->sq_length) - return m->sq_length(s); - - type_error("len() of unsized object"); - return -1; -} - -#undef PySequence_Length -int -PySequence_Length(PyObject *s) -{ - return PySequence_Size(s); -} -#define PySequence_Length PySequence_Size - -PyObject * -PySequence_Concat(PyObject *s, PyObject *o) -{ - PySequenceMethods *m; - - if (s == NULL || o == NULL) - return null_error(); - - m = s->ob_type->tp_as_sequence; - if (m && m->sq_concat) - return m->sq_concat(s, o); - - return type_error("object can't be concatenated"); -} - -PyObject * -PySequence_Repeat(PyObject *o, int count) -{ - PySequenceMethods *m; - - if (o == NULL) - return null_error(); - - m = o->ob_type->tp_as_sequence; - if (m && m->sq_repeat) - return m->sq_repeat(o, count); - - return type_error("object can't be repeated"); -} - -PyObject * -PySequence_InPlaceConcat(PyObject *s, PyObject *o) -{ - PySequenceMethods *m; - - if (s == NULL || o == NULL) - return null_error(); - - m = s->ob_type->tp_as_sequence; - if (m && HASINPLACE(s) && m->sq_inplace_concat) - return m->sq_inplace_concat(s, o); - if (m && m->sq_concat) - return m->sq_concat(s, o); - - return type_error("object can't be concatenated"); -} - -PyObject * -PySequence_InPlaceRepeat(PyObject *o, int count) -{ - PySequenceMethods *m; - - if (o == NULL) - return null_error(); - - m = o->ob_type->tp_as_sequence; - if (m && HASINPLACE(o) && m->sq_inplace_repeat) - return m->sq_inplace_repeat(o, count); - if (m && m->sq_repeat) - return m->sq_repeat(o, count); - - return type_error("object can't be repeated"); -} - -PyObject * -PySequence_GetItem(PyObject *s, int i) -{ - PySequenceMethods *m; - - if (s == NULL) - return null_error(); - - m = s->ob_type->tp_as_sequence; - if (m && m->sq_item) { - if (i < 0) { - if (m->sq_length) { - int l = (*m->sq_length)(s); - if (l < 0) - return NULL; - i += l; - } - } - return m->sq_item(s, i); - } - - return type_error("unindexable object"); -} - -static PyObject * -sliceobj_from_intint(int i, int j) -{ - PyObject *start, *end, *slice; - start = PyInt_FromLong((long)i); - if (!start) - return NULL; - end = PyInt_FromLong((long)j); - if (!end) { - Py_DECREF(start); - return NULL; - } - slice = PySlice_New(start, end, NULL); - Py_DECREF(start); - Py_DECREF(end); - return slice; -} - -PyObject * -PySequence_GetSlice(PyObject *s, int i1, int i2) -{ - PySequenceMethods *m; - PyMappingMethods *mp; - - if (!s) return null_error(); - - m = s->ob_type->tp_as_sequence; - if (m && m->sq_slice) { - if (i1 < 0 || i2 < 0) { - if (m->sq_length) { - int l = (*m->sq_length)(s); - if (l < 0) - return NULL; - if (i1 < 0) - i1 += l; - if (i2 < 0) - i2 += l; - } - } - return m->sq_slice(s, i1, i2); - } else if ((mp = s->ob_type->tp_as_mapping) && mp->mp_subscript) { - PyObject *res; - PyObject *slice = sliceobj_from_intint(i1, i2); - if (!slice) - return NULL; - res = mp->mp_subscript(s, slice); - Py_DECREF(slice); - return res; - } - - return type_error("unsliceable object"); -} - -int -PySequence_SetItem(PyObject *s, int i, PyObject *o) -{ - PySequenceMethods *m; - - if (s == NULL) { - null_error(); - return -1; - } - - m = s->ob_type->tp_as_sequence; - if (m && m->sq_ass_item) { - if (i < 0) { - if (m->sq_length) { - int l = (*m->sq_length)(s); - if (l < 0) - return -1; - i += l; - } - } - return m->sq_ass_item(s, i, o); - } - - type_error("object doesn't support item assignment"); - return -1; -} - -int -PySequence_DelItem(PyObject *s, int i) -{ - PySequenceMethods *m; - - if (s == NULL) { - null_error(); - return -1; - } - - m = s->ob_type->tp_as_sequence; - if (m && m->sq_ass_item) { - if (i < 0) { - if (m->sq_length) { - int l = (*m->sq_length)(s); - if (l < 0) - return -1; - i += l; - } - } - return m->sq_ass_item(s, i, (PyObject *)NULL); - } - - type_error("object doesn't support item deletion"); - return -1; -} - -int -PySequence_SetSlice(PyObject *s, int i1, int i2, PyObject *o) -{ - PySequenceMethods *m; - PyMappingMethods *mp; - - if (s == NULL) { - null_error(); - return -1; - } - - m = s->ob_type->tp_as_sequence; - if (m && m->sq_ass_slice) { - if (i1 < 0 || i2 < 0) { - if (m->sq_length) { - int l = (*m->sq_length)(s); - if (l < 0) - return -1; - if (i1 < 0) - i1 += l; - if (i2 < 0) - i2 += l; - } - } - return m->sq_ass_slice(s, i1, i2, o); - } else if ((mp = s->ob_type->tp_as_mapping) && mp->mp_ass_subscript) { - int res; - PyObject *slice = sliceobj_from_intint(i1, i2); - if (!slice) - return -1; - res = mp->mp_ass_subscript(s, slice, o); - Py_DECREF(slice); - return res; - } - - type_error("object doesn't support slice assignment"); - return -1; -} - -int -PySequence_DelSlice(PyObject *s, int i1, int i2) -{ - PySequenceMethods *m; - - if (s == NULL) { - null_error(); - return -1; - } - - m = s->ob_type->tp_as_sequence; - if (m && m->sq_ass_slice) { - if (i1 < 0 || i2 < 0) { - if (m->sq_length) { - int l = (*m->sq_length)(s); - if (l < 0) - return -1; - if (i1 < 0) - i1 += l; - if (i2 < 0) - i2 += l; - } - } - return m->sq_ass_slice(s, i1, i2, (PyObject *)NULL); - } - type_error("object doesn't support slice deletion"); - return -1; -} - -PyObject * -PySequence_Tuple(PyObject *v) -{ - PyObject *it; /* iter(v) */ - int n; /* guess for result tuple size */ - PyObject *result; - int j; - - if (v == NULL) - return null_error(); - - /* Special-case the common tuple and list cases, for efficiency. */ - if (PyTuple_CheckExact(v)) { - /* Note that we can't know whether it's safe to return - a tuple *subclass* instance as-is, hence the restriction - to exact tuples here. In contrast, lists always make - a copy, so there's no need for exactness below. */ - Py_INCREF(v); - return v; - } - if (PyList_Check(v)) - return PyList_AsTuple(v); - - /* Get iterator. */ - it = PyObject_GetIter(v); - if (it == NULL) - return NULL; - - /* Guess result size and allocate space. */ - n = PySequence_Size(v); - if (n < 0) { - PyErr_Clear(); - n = 10; /* arbitrary */ - } - result = PyTuple_New(n); - if (result == NULL) - goto Fail; - - /* Fill the tuple. */ - for (j = 0; ; ++j) { - PyObject *item = PyIter_Next(it); - if (item == NULL) { - if (PyErr_Occurred()) - goto Fail; - break; - } - if (j >= n) { - if (n < 500) - n += 10; - else - n += 100; - if (_PyTuple_Resize(&result, n) != 0) { - Py_DECREF(item); - goto Fail; - } - } - PyTuple_SET_ITEM(result, j, item); - } - - /* Cut tuple back if guess was too large. */ - if (j < n && - _PyTuple_Resize(&result, j) != 0) - goto Fail; - - Py_DECREF(it); - return result; - -Fail: - Py_XDECREF(result); - Py_DECREF(it); - return NULL; -} - -PyObject * -PySequence_List(PyObject *v) -{ - PyObject *it; /* iter(v) */ - PyObject *result; /* result list */ - int n; /* guess for result list size */ - int i; - - if (v == NULL) - return null_error(); - - /* Special-case list(a_list), for speed. */ - if (PyList_Check(v)) - return PyList_GetSlice(v, 0, PyList_GET_SIZE(v)); - - /* Get iterator. There may be some low-level efficiency to be gained - * by caching the tp_iternext slot instead of using PyIter_Next() - * later, but premature optimization is the root etc. - */ - it = PyObject_GetIter(v); - if (it == NULL) - return NULL; - - /* Guess a result list size. */ - n = -1; /* unknown */ - if (PySequence_Check(v) && - v->ob_type->tp_as_sequence->sq_length) { - n = PySequence_Size(v); - if (n < 0) - PyErr_Clear(); - } - if (n < 0) - n = 8; /* arbitrary */ - result = PyList_New(n); - if (result == NULL) { - Py_DECREF(it); - return NULL; - } - - /* Run iterator to exhaustion. */ - for (i = 0; ; i++) { - PyObject *item = PyIter_Next(it); - if (item == NULL) { - if (PyErr_Occurred()) { - Py_DECREF(result); - result = NULL; - } - break; - } - if (i < n) - PyList_SET_ITEM(result, i, item); /* steals ref */ - else { - int status = PyList_Append(result, item); - Py_DECREF(item); /* append creates a new ref */ - if (status < 0) { - Py_DECREF(result); - result = NULL; - break; - } - } - } - - /* Cut back result list if initial guess was too large. */ - if (i < n && result != NULL) { - if (PyList_SetSlice(result, i, n, (PyObject *)NULL) != 0) { - Py_DECREF(result); - result = NULL; - } - } - Py_DECREF(it); - return result; -} - -PyObject * -PySequence_Fast(PyObject *v, const char *m) -{ - if (v == NULL) - return null_error(); - - if (PyList_CheckExact(v) || PyTuple_CheckExact(v)) { - Py_INCREF(v); - return v; - } - - v = PySequence_Tuple(v); - if (v == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) - return type_error(m); - - return v; -} - -/* Iterate over seq. Result depends on the operation: - PY_ITERSEARCH_COUNT: -1 if error, else # of times obj appears in seq. - PY_ITERSEARCH_INDEX: 0-based index of first occurence of obj in seq; - set ValueError and return -1 if none found; also return -1 on error. - Py_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on error. -*/ -int -_PySequence_IterSearch(PyObject *seq, PyObject *obj, int operation) -{ - int n; - int wrapped; /* for PY_ITERSEARCH_INDEX, true iff n wrapped around */ - PyObject *it; /* iter(seq) */ - - if (seq == NULL || obj == NULL) { - null_error(); - return -1; - } - - it = PyObject_GetIter(seq); - if (it == NULL) { - type_error("iterable argument required"); - return -1; - } - - n = wrapped = 0; - for (;;) { - int cmp; - PyObject *item = PyIter_Next(it); - if (item == NULL) { - if (PyErr_Occurred()) - goto Fail; - break; - } - - cmp = PyObject_RichCompareBool(obj, item, Py_EQ); - Py_DECREF(item); - if (cmp < 0) - goto Fail; - if (cmp > 0) { - switch (operation) { - case PY_ITERSEARCH_COUNT: - ++n; - if (n <= 0) { - PyErr_SetString(PyExc_OverflowError, - "count exceeds C int size"); - goto Fail; - } - break; - - case PY_ITERSEARCH_INDEX: - if (wrapped) { - PyErr_SetString(PyExc_OverflowError, - "index exceeds C int size"); - goto Fail; - } - goto Done; - - case PY_ITERSEARCH_CONTAINS: - n = 1; - goto Done; - - default: - assert(!"unknown operation"); - } - } - - if (operation == PY_ITERSEARCH_INDEX) { - ++n; - if (n <= 0) - wrapped = 1; - } - } - - if (operation != PY_ITERSEARCH_INDEX) - goto Done; - - PyErr_SetString(PyExc_ValueError, - "sequence.index(x): x not in sequence"); - /* fall into failure code */ -Fail: - n = -1; - /* fall through */ -Done: - Py_DECREF(it); - return n; - -} - -/* Return # of times o appears in s. */ -int -PySequence_Count(PyObject *s, PyObject *o) -{ - return _PySequence_IterSearch(s, o, PY_ITERSEARCH_COUNT); -} - -/* Return -1 if error; 1 if ob in seq; 0 if ob not in seq. - * Use sq_contains if possible, else defer to _PySequence_IterSearch(). - */ -int -PySequence_Contains(PyObject *seq, PyObject *ob) -{ - if (PyType_HasFeature(seq->ob_type, Py_TPFLAGS_HAVE_SEQUENCE_IN)) { - PySequenceMethods *sqm = seq->ob_type->tp_as_sequence; - if (sqm != NULL && sqm->sq_contains != NULL) - return (*sqm->sq_contains)(seq, ob); - } - return _PySequence_IterSearch(seq, ob, PY_ITERSEARCH_CONTAINS); -} - -/* Backwards compatibility */ -#undef PySequence_In -int -PySequence_In(PyObject *w, PyObject *v) -{ - return PySequence_Contains(w, v); -} - -int -PySequence_Index(PyObject *s, PyObject *o) -{ - return _PySequence_IterSearch(s, o, PY_ITERSEARCH_INDEX); -} - -/* Operations on mappings */ - -int -PyMapping_Check(PyObject *o) -{ - return o && o->ob_type->tp_as_mapping && - o->ob_type->tp_as_mapping->mp_subscript; -} - -int -PyMapping_Size(PyObject *o) -{ - PyMappingMethods *m; - - if (o == NULL) { - null_error(); - return -1; - } - - m = o->ob_type->tp_as_mapping; - if (m && m->mp_length) - return m->mp_length(o); - - type_error("len() of unsized object"); - return -1; -} - -#undef PyMapping_Length -int -PyMapping_Length(PyObject *o) -{ - return PyMapping_Size(o); -} -#define PyMapping_Length PyMapping_Size - -PyObject * -PyMapping_GetItemString(PyObject *o, char *key) -{ - PyObject *okey, *r; - - if (key == NULL) - return null_error(); - - okey = PyString_FromString(key); - if (okey == NULL) - return NULL; - r = PyObject_GetItem(o, okey); - Py_DECREF(okey); - return r; -} - -int -PyMapping_SetItemString(PyObject *o, char *key, PyObject *value) -{ - PyObject *okey; - int r; - - if (key == NULL) { - null_error(); - return -1; - } - - okey = PyString_FromString(key); - if (okey == NULL) - return -1; - r = PyObject_SetItem(o, okey, value); - Py_DECREF(okey); - return r; -} - -int -PyMapping_HasKeyString(PyObject *o, char *key) -{ - PyObject *v; - - v = PyMapping_GetItemString(o, key); - if (v) { - Py_DECREF(v); - return 1; - } - PyErr_Clear(); - return 0; -} - -int -PyMapping_HasKey(PyObject *o, PyObject *key) -{ - PyObject *v; - - v = PyObject_GetItem(o, key); - if (v) { - Py_DECREF(v); - return 1; - } - PyErr_Clear(); - return 0; -} - -/* Operations on callable objects */ - -/* XXX PyCallable_Check() is in object.c */ - -PyObject * -PyObject_CallObject(PyObject *o, PyObject *a) -{ - return PyEval_CallObjectWithKeywords(o, a, NULL); -} - -PyObject * -PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) -{ - ternaryfunc call; - - if ((call = func->ob_type->tp_call) != NULL) { - PyObject *result = (*call)(func, arg, kw); - if (result == NULL && !PyErr_Occurred()) - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - return result; - } - PyErr_Format(PyExc_TypeError, "'%s' object is not callable", - func->ob_type->tp_name); - return NULL; -} - -PyObject * -PyObject_CallFunction(PyObject *callable, char *format, ...) -{ - va_list va; - PyObject *args, *retval; - - if (callable == NULL) - return null_error(); - - if (format && *format) { - va_start(va, format); - args = Py_VaBuildValue(format, va); - va_end(va); - } - else - args = PyTuple_New(0); - - if (args == NULL) - return NULL; - - if (!PyTuple_Check(args)) { - PyObject *a; - - a = PyTuple_New(1); - if (a == NULL) - return NULL; - if (PyTuple_SetItem(a, 0, args) < 0) - return NULL; - args = a; - } - retval = PyObject_Call(callable, args, NULL); - - Py_DECREF(args); - - return retval; -} - -PyObject * -PyObject_CallMethod(PyObject *o, char *name, char *format, ...) -{ - va_list va; - PyObject *args, *func = 0, *retval; - - if (o == NULL || name == NULL) - return null_error(); - - func = PyObject_GetAttrString(o, name); - if (func == NULL) { - PyErr_SetString(PyExc_AttributeError, name); - return 0; - } - - if (!PyCallable_Check(func)) - return type_error("call of non-callable attribute"); - - if (format && *format) { - va_start(va, format); - args = Py_VaBuildValue(format, va); - va_end(va); - } - else - args = PyTuple_New(0); - - if (!args) - return NULL; - - if (!PyTuple_Check(args)) { - PyObject *a; - - a = PyTuple_New(1); - if (a == NULL) - return NULL; - if (PyTuple_SetItem(a, 0, args) < 0) - return NULL; - args = a; - } - - retval = PyObject_Call(func, args, NULL); - - Py_DECREF(args); - Py_DECREF(func); - - return retval; -} - - -static PyObject * -objargs_mktuple(va_list va) -{ - int i, n = 0; - va_list countva; - PyObject *result, *tmp; - -#ifdef VA_LIST_IS_ARRAY - memcpy(countva, va, sizeof(va_list)); -#else -#ifdef __va_copy - __va_copy(countva, va); -#else - countva = va; -#endif -#endif - - while (((PyObject *)va_arg(countva, PyObject *)) != NULL) - ++n; - result = PyTuple_New(n); - if (result != NULL && n > 0) { - for (i = 0; i < n; ++i) { - tmp = (PyObject *)va_arg(va, PyObject *); - PyTuple_SET_ITEM(result, i, tmp); - Py_INCREF(tmp); - } - } - return result; -} - -PyObject * -PyObject_CallMethodObjArgs(PyObject *callable, PyObject *name, ...) -{ - PyObject *args, *tmp; - va_list vargs; - - if (callable == NULL || name == NULL) - return null_error(); - - callable = PyObject_GetAttr(callable, name); - if (callable == NULL) - return NULL; - - /* count the args */ - va_start(vargs, name); - args = objargs_mktuple(vargs); - va_end(vargs); - if (args == NULL) { - Py_DECREF(callable); - return NULL; - } - tmp = PyObject_Call(callable, args, NULL); - Py_DECREF(args); - Py_DECREF(callable); - - return tmp; -} - -PyObject * -PyObject_CallFunctionObjArgs(PyObject *callable, ...) -{ - PyObject *args, *tmp; - va_list vargs; - - if (callable == NULL) - return null_error(); - - /* count the args */ - va_start(vargs, callable); - args = objargs_mktuple(vargs); - va_end(vargs); - if (args == NULL) - return NULL; - tmp = PyObject_Call(callable, args, NULL); - Py_DECREF(args); - - return tmp; -} - - -/* isinstance(), issubclass() */ - -/* abstract_get_bases() has logically 4 return states, with a sort of 0th - * state that will almost never happen. - * - * 0. creating the __bases__ static string could get a MemoryError - * 1. getattr(cls, '__bases__') could raise an AttributeError - * 2. getattr(cls, '__bases__') could raise some other exception - * 3. getattr(cls, '__bases__') could return a tuple - * 4. getattr(cls, '__bases__') could return something other than a tuple - * - * Only state #3 is a non-error state and only it returns a non-NULL object - * (it returns the retrieved tuple). - * - * Any raised AttributeErrors are masked by clearing the exception and - * returning NULL. If an object other than a tuple comes out of __bases__, - * then again, the return value is NULL. So yes, these two situations - * produce exactly the same results: NULL is returned and no error is set. - * - * If some exception other than AttributeError is raised, then NULL is also - * returned, but the exception is not cleared. That's because we want the - * exception to be propagated along. - * - * Callers are expected to test for PyErr_Occurred() when the return value - * is NULL to decide whether a valid exception should be propagated or not. - * When there's no exception to propagate, it's customary for the caller to - * set a TypeError. - */ -static PyObject * -abstract_get_bases(PyObject *cls) -{ - static PyObject *__bases__ = NULL; - PyObject *bases; - - if (__bases__ == NULL) { - __bases__ = PyString_FromString("__bases__"); - if (__bases__ == NULL) - return NULL; - } - bases = PyObject_GetAttr(cls, __bases__); - if (bases == NULL) { - if (PyErr_ExceptionMatches(PyExc_AttributeError)) - PyErr_Clear(); - return NULL; - } - if (!PyTuple_Check(bases)) { - Py_DECREF(bases); - return NULL; - } - return bases; -} - - -static int -abstract_issubclass(PyObject *derived, PyObject *cls) -{ - PyObject *bases; - int i, n; - int r = 0; - - - if (derived == cls) - return 1; - - if (PyTuple_Check(cls)) { - /* Not a general sequence -- that opens up the road to - recursion and stack overflow. */ - n = PyTuple_GET_SIZE(cls); - for (i = 0; i < n; i++) { - if (derived == PyTuple_GET_ITEM(cls, i)) - return 1; - } - } - bases = abstract_get_bases(derived); - if (bases == NULL) { - if (PyErr_Occurred()) - return -1; - return 0; - } - n = PyTuple_GET_SIZE(bases); - for (i = 0; i < n; i++) { - r = abstract_issubclass(PyTuple_GET_ITEM(bases, i), cls); - if (r != 0) - break; - } - - Py_DECREF(bases); - - return r; -} - -static int -check_class(PyObject *cls, const char *error) -{ - PyObject *bases = abstract_get_bases(cls); - if (bases == NULL) { - /* Do not mask errors. */ - if (!PyErr_Occurred()) - PyErr_SetString(PyExc_TypeError, error); - return 0; - } - Py_DECREF(bases); - return -1; -} - -int -PyObject_IsInstance(PyObject *inst, PyObject *cls) -{ - PyObject *icls; - static PyObject *__class__ = NULL; - int retval = 0; - - if (__class__ == NULL) { - __class__ = PyString_FromString("__class__"); - if (__class__ == NULL) - return -1; - } - - if (PyClass_Check(cls) && PyInstance_Check(inst)) { - PyObject *inclass = - (PyObject*)((PyInstanceObject*)inst)->in_class; - retval = PyClass_IsSubclass(inclass, cls); - } - else if (PyType_Check(cls)) { - retval = PyObject_TypeCheck(inst, (PyTypeObject *)cls); - if (retval == 0) { - PyObject *c = PyObject_GetAttr(inst, __class__); - if (c == NULL) { - PyErr_Clear(); - } - else { - if (c != (PyObject *)(inst->ob_type) && - PyType_Check(c)) - retval = PyType_IsSubtype( - (PyTypeObject *)c, - (PyTypeObject *)cls); - Py_DECREF(c); - } - } - } - else if (PyTuple_Check(cls)) { - /* Not a general sequence -- that opens up the road to - recursion and stack overflow. */ - int i, n; - - n = PyTuple_GET_SIZE(cls); - for (i = 0; i < n; i++) { - retval = PyObject_IsInstance( - inst, PyTuple_GET_ITEM(cls, i)); - if (retval != 0) - break; - } - } - else { - if (!check_class(cls, - "isinstance() arg 2 must be a class, type," - " or tuple of classes and types")) - return -1; - icls = PyObject_GetAttr(inst, __class__); - if (icls == NULL) { - PyErr_Clear(); - retval = 0; - } - else { - retval = abstract_issubclass(icls, cls); - Py_DECREF(icls); - } - } - - return retval; -} - -int -PyObject_IsSubclass(PyObject *derived, PyObject *cls) -{ - int retval; - - if (!PyClass_Check(derived) || !PyClass_Check(cls)) { - if (!check_class(derived, - "issubclass() arg 1 must be a class")) - return -1; - - if (PyTuple_Check(cls)) { - int i; - int n = PyTuple_GET_SIZE(cls); - for (i = 0; i < n; ++i) { - retval = PyObject_IsSubclass( - derived, PyTuple_GET_ITEM(cls, i)); - if (retval != 0) { - /* either found it, or got an error */ - return retval; - } - } - return 0; - } - else { - if (!check_class(cls, - "issubclass() arg 2 must be a class" - " or tuple of classes")) - return -1; - } - - retval = abstract_issubclass(derived, cls); - } - else { - /* shortcut */ - if (!(retval = (derived == cls))) - retval = PyClass_IsSubclass(derived, cls); - } - - return retval; -} - -PyObject * -PyObject_GetIter(PyObject *o) -{ - PyTypeObject *t = o->ob_type; - getiterfunc f = NULL; - if (PyType_HasFeature(t, Py_TPFLAGS_HAVE_ITER)) - f = t->tp_iter; - if (f == NULL) { - if (PySequence_Check(o)) - return PySeqIter_New(o); - PyErr_SetString(PyExc_TypeError, - "iteration over non-sequence"); - return NULL; - } - else { - PyObject *res = (*f)(o); - if (res != NULL && !PyIter_Check(res)) { - PyErr_Format(PyExc_TypeError, - "iter() returned non-iterator " - "of type '%.100s'", - res->ob_type->tp_name); - Py_DECREF(res); - res = NULL; - } - return res; - } -} - -/* Return next item. - * If an error occurs, return NULL. PyErr_Occurred() will be true. - * If the iteration terminates normally, return NULL and clear the - * PyExc_StopIteration exception (if it was set). PyErr_Occurred() - * will be false. - * Else return the next object. PyErr_Occurred() will be false. - */ -PyObject * -PyIter_Next(PyObject *iter) -{ - PyObject *result; - assert(PyIter_Check(iter)); - result = (*iter->ob_type->tp_iternext)(iter); - if (result == NULL && - PyErr_Occurred() && - PyErr_ExceptionMatches(PyExc_StopIteration)) - PyErr_Clear(); - return result; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/boolobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/boolobject.c deleted file mode 100644 index 75165e31..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/boolobject.c +++ /dev/null @@ -1,201 +0,0 @@ -/* Boolean type, a subtype of int */ - -#include "Python.h" - -/* We need to define bool_print to override int_print */ - -static int -bool_print(PyBoolObject *self, FILE *fp, int flags) -{ - fputs(self->ob_ival == 0 ? "False" : "True", fp); - return 0; -} - -/* We define bool_repr to return "False" or "True" */ - -static PyObject *false_str = NULL; -static PyObject *true_str = NULL; - -static PyObject * -bool_repr(PyBoolObject *self) -{ - PyObject *s; - - if (self->ob_ival) - s = true_str ? true_str : - (true_str = PyString_InternFromString("True")); - else - s = false_str ? false_str : - (false_str = PyString_InternFromString("False")); - Py_XINCREF(s); - return s; -} - -/* Function to return a bool from a C long */ - -PyObject *PyBool_FromLong(long ok) -{ - PyObject *result; - - if (ok) - result = Py_True; - else - result = Py_False; - Py_INCREF(result); - return result; -} - -/* We define bool_new to always return either Py_True or Py_False */ - -static PyObject * -bool_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - static char *kwlist[] = {"x", 0}; - PyObject *x = Py_False; - long ok; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:bool", kwlist, &x)) - return NULL; - ok = PyObject_IsTrue(x); - if (ok < 0) - return NULL; - return PyBool_FromLong(ok); -} - -/* Arithmetic operations redefined to return bool if both args are bool. */ - -static PyObject * -bool_and(PyObject *a, PyObject *b) -{ - if (!PyBool_Check(a) || !PyBool_Check(b)) - return PyInt_Type.tp_as_number->nb_and(a, b); - return PyBool_FromLong( - ((PyBoolObject *)a)->ob_ival & ((PyBoolObject *)b)->ob_ival); -} - -static PyObject * -bool_or(PyObject *a, PyObject *b) -{ - if (!PyBool_Check(a) || !PyBool_Check(b)) - return PyInt_Type.tp_as_number->nb_or(a, b); - return PyBool_FromLong( - ((PyBoolObject *)a)->ob_ival | ((PyBoolObject *)b)->ob_ival); -} - -static PyObject * -bool_xor(PyObject *a, PyObject *b) -{ - if (!PyBool_Check(a) || !PyBool_Check(b)) - return PyInt_Type.tp_as_number->nb_xor(a, b); - return PyBool_FromLong( - ((PyBoolObject *)a)->ob_ival ^ ((PyBoolObject *)b)->ob_ival); -} - -/* Doc string */ - -PyDoc_STRVAR(bool_doc, -"bool(x) -> bool\n\ -\n\ -Returns True when the argument x is true, False otherwise.\n\ -The builtins True and False are the only two instances of the class bool.\n\ -The class bool is a subclass of the class int, and cannot be subclassed."); - -/* Arithmetic methods -- only so we can override &, |, ^. */ - -static PyNumberMethods bool_as_number = { - 0, /* nb_add */ - 0, /* nb_subtract */ - 0, /* nb_multiply */ - 0, /* nb_divide */ - 0, /* nb_remainder */ - 0, /* nb_divmod */ - 0, /* nb_power */ - 0, /* nb_negative */ - 0, /* nb_positive */ - 0, /* nb_absolute */ - 0, /* nb_nonzero */ - 0, /* nb_invert */ - 0, /* nb_lshift */ - 0, /* nb_rshift */ - (binaryfunc)bool_and, /* nb_and */ - (binaryfunc)bool_xor, /* nb_xor */ - (binaryfunc)bool_or, /* nb_or */ - 0, /* nb_coerce */ - 0, /* nb_int */ - 0, /* nb_long */ - 0, /* nb_float */ - 0, /* nb_oct */ - 0, /* nb_hex */ - 0, /* nb_inplace_add */ - 0, /* nb_inplace_subtract */ - 0, /* nb_inplace_multiply */ - 0, /* nb_inplace_divide */ - 0, /* nb_inplace_remainder */ - 0, /* nb_inplace_power */ - 0, /* nb_inplace_lshift */ - 0, /* nb_inplace_rshift */ - 0, /* nb_inplace_and */ - 0, /* nb_inplace_xor */ - 0, /* nb_inplace_or */ - 0, /* nb_floor_divide */ - 0, /* nb_true_divide */ - 0, /* nb_inplace_floor_divide */ - 0, /* nb_inplace_true_divide */ -}; - -/* The type object for bool. Note that this cannot be subclassed! */ - -PyTypeObject PyBool_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "bool", - sizeof(PyIntObject), - 0, - 0, /* tp_dealloc */ - (printfunc)bool_print, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)bool_repr, /* tp_repr */ - &bool_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)bool_repr, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, /* tp_flags */ - bool_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - &PyInt_Type, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - bool_new, /* tp_new */ -}; - -/* The objects representing bool values False and True */ - -/* Named Zero for link-level compatibility */ -PyIntObject _Py_ZeroStruct = { - PyObject_HEAD_INIT(&PyBool_Type) - 0 -}; - -PyIntObject _Py_TrueStruct = { - PyObject_HEAD_INIT(&PyBool_Type) - 1 -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/bufferobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/bufferobject.c deleted file mode 100644 index 216a7a9c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/bufferobject.c +++ /dev/null @@ -1,568 +0,0 @@ - -/* Buffer object implementation */ - -#include "Python.h" - - -typedef struct { - PyObject_HEAD - PyObject *b_base; - void *b_ptr; - int b_size; - int b_readonly; - long b_hash; -} PyBufferObject; - - -static PyObject * -_PyBuffer_FromMemory(PyObject *base, void *ptr, int size, int readonly) -{ - PyBufferObject * b; - - if ( size < 0 ) { - PyErr_SetString(PyExc_ValueError, - "size must be zero or positive"); - return NULL; - } - - b = PyObject_NEW(PyBufferObject, &PyBuffer_Type); - if ( b == NULL ) - return NULL; - - Py_XINCREF(base); - b->b_base = base; - b->b_ptr = ptr; - b->b_size = size; - b->b_readonly = readonly; - b->b_hash = -1; - - return (PyObject *) b; -} - -static PyObject * -_PyBuffer_FromObject(PyObject *base, int offset, int size, - getreadbufferproc proc, int readonly) -{ - PyBufferProcs *pb = base->ob_type->tp_as_buffer; - void *p; - int count; - - if ( offset < 0 ) { - PyErr_SetString(PyExc_ValueError, - "offset must be zero or positive"); - return NULL; - } - - if ( (*pb->bf_getsegcount)(base, NULL) != 1 ) - { - PyErr_SetString(PyExc_TypeError, - "single-segment buffer object expected"); - return NULL; - } - if ( (count = (*proc)(base, 0, &p)) < 0 ) - return NULL; - - /* apply constraints to the start/end */ - if ( size == Py_END_OF_BUFFER || size < 0 ) - size = count; - if ( offset > count ) - offset = count; - if ( offset + size > count ) - size = count - offset; - - /* if the base object is another buffer, then "deref" it, - * except if the base of the other buffer is NULL - */ - if ( PyBuffer_Check(base) && (((PyBufferObject *)base)->b_base) ) - base = ((PyBufferObject *)base)->b_base; - - return _PyBuffer_FromMemory(base, (char *)p + offset, size, readonly); -} - - -PyObject * -PyBuffer_FromObject(PyObject *base, int offset, int size) -{ - PyBufferProcs *pb = base->ob_type->tp_as_buffer; - - if ( pb == NULL || - pb->bf_getreadbuffer == NULL || - pb->bf_getsegcount == NULL ) - { - PyErr_SetString(PyExc_TypeError, "buffer object expected"); - return NULL; - } - - return _PyBuffer_FromObject(base, offset, size, - pb->bf_getreadbuffer, 1); -} - -PyObject * -PyBuffer_FromReadWriteObject(PyObject *base, int offset, int size) -{ - PyBufferProcs *pb = base->ob_type->tp_as_buffer; - - if ( pb == NULL || - pb->bf_getwritebuffer == NULL || - pb->bf_getsegcount == NULL ) - { - PyErr_SetString(PyExc_TypeError, "buffer object expected"); - return NULL; - } - - return _PyBuffer_FromObject(base, offset, size, - (getreadbufferproc)pb->bf_getwritebuffer, - 0); -} - -PyObject * -PyBuffer_FromMemory(void *ptr, int size) -{ - return _PyBuffer_FromMemory(NULL, ptr, size, 1); -} - -PyObject * -PyBuffer_FromReadWriteMemory(void *ptr, int size) -{ - return _PyBuffer_FromMemory(NULL, ptr, size, 0); -} - -PyObject * -PyBuffer_New(int size) -{ - PyObject *o; - PyBufferObject * b; - - if (size < 0) { - PyErr_SetString(PyExc_ValueError, - "size must be zero or positive"); - return NULL; - } - /* Inline PyObject_New */ - o = PyObject_MALLOC(sizeof(*b) + size); - if ( o == NULL ) - return PyErr_NoMemory(); - b = (PyBufferObject *) PyObject_INIT(o, &PyBuffer_Type); - - b->b_base = NULL; - b->b_ptr = (void *)(b + 1); - b->b_size = size; - b->b_readonly = 0; - b->b_hash = -1; - - return o; -} - -/* Methods */ - -static PyObject * -buffer_new(PyTypeObject *type, PyObject *args, PyObject *kw) -{ - PyObject *ob; - int offset = 0; - int size = Py_END_OF_BUFFER; - - if ( !PyArg_ParseTuple(args, "O|ii:buffer", &ob, &offset, &size) ) - return NULL; - return PyBuffer_FromObject(ob, offset, size); -} - -PyDoc_STRVAR(buffer_doc, -"buffer(object [, offset[, size]])\n\ -\n\ -Create a new buffer object which references the given object.\n\ -The buffer will reference a slice of the target object from the\n\ -start of the object (or at the specified offset). The slice will\n\ -extend to the end of the target object (or with the specified size)."); - - -static void -buffer_dealloc(PyBufferObject *self) -{ - Py_XDECREF(self->b_base); - PyObject_DEL(self); -} - -static int -buffer_compare(PyBufferObject *self, PyBufferObject *other) -{ - int len_self = self->b_size; - int len_other = other->b_size; - int min_len = (len_self < len_other) ? len_self : len_other; - int cmp; - if (min_len > 0) { - cmp = memcmp(self->b_ptr, other->b_ptr, min_len); - if (cmp != 0) - return cmp; - } - return (len_self < len_other) ? -1 : (len_self > len_other) ? 1 : 0; -} - -static PyObject * -buffer_repr(PyBufferObject *self) -{ - char *status = self->b_readonly ? "read-only" : "read-write"; - - if ( self->b_base == NULL ) - return PyString_FromFormat("<%s buffer ptr %p, size %d at %p>", - status, - self->b_ptr, - self->b_size, - self); - else - return PyString_FromFormat( - "<%s buffer for %p, ptr %p, size %d at %p>", - status, - self->b_base, - self->b_ptr, - self->b_size, - self); -} - -static long -buffer_hash(PyBufferObject *self) -{ - register int len; - register unsigned char *p; - register long x; - - if ( self->b_hash != -1 ) - return self->b_hash; - - if ( !self->b_readonly ) - { - /* ### use different wording, since this is conditional? */ - PyErr_SetString(PyExc_TypeError, "unhashable type"); - return -1; - } - - len = self->b_size; - p = (unsigned char *) self->b_ptr; - x = *p << 7; - while (--len >= 0) - x = (1000003*x) ^ *p++; - x ^= self->b_size; - if (x == -1) - x = -2; - self->b_hash = x; - return x; -} - -static PyObject * -buffer_str(PyBufferObject *self) -{ - return PyString_FromStringAndSize(self->b_ptr, self->b_size); -} - -/* Sequence methods */ - -static int -buffer_length(PyBufferObject *self) -{ - return self->b_size; -} - -static PyObject * -buffer_concat(PyBufferObject *self, PyObject *other) -{ - PyBufferProcs *pb = other->ob_type->tp_as_buffer; - char *p1; - void *p2; - PyObject *ob; - int count; - - if ( pb == NULL || - pb->bf_getreadbuffer == NULL || - pb->bf_getsegcount == NULL ) - { - PyErr_BadArgument(); - return NULL; - } - if ( (*pb->bf_getsegcount)(other, NULL) != 1 ) - { - /* ### use a different exception type/message? */ - PyErr_SetString(PyExc_TypeError, - "single-segment buffer object expected"); - return NULL; - } - - /* optimize special case */ - if ( self->b_size == 0 ) - { - Py_INCREF(other); - return other; - } - - if ( (count = (*pb->bf_getreadbuffer)(other, 0, &p2)) < 0 ) - return NULL; - - ob = PyString_FromStringAndSize(NULL, self->b_size + count); - p1 = PyString_AS_STRING(ob); - memcpy(p1, self->b_ptr, self->b_size); - memcpy(p1 + self->b_size, p2, count); - - /* there is an extra byte in the string object, so this is safe */ - p1[self->b_size + count] = '\0'; - - return ob; -} - -static PyObject * -buffer_repeat(PyBufferObject *self, int count) -{ - PyObject *ob; - register char *p; - void *ptr = self->b_ptr; - int size = self->b_size; - - if ( count < 0 ) - count = 0; - ob = PyString_FromStringAndSize(NULL, size * count); - if ( ob == NULL ) - return NULL; - - p = PyString_AS_STRING(ob); - while ( count-- ) - { - memcpy(p, ptr, size); - p += size; - } - - /* there is an extra byte in the string object, so this is safe */ - *p = '\0'; - - return ob; -} - -static PyObject * -buffer_item(PyBufferObject *self, int idx) -{ - if ( idx < 0 || idx >= self->b_size ) - { - PyErr_SetString(PyExc_IndexError, "buffer index out of range"); - return NULL; - } - return PyString_FromStringAndSize((char *)self->b_ptr + idx, 1); -} - -static PyObject * -buffer_slice(PyBufferObject *self, int left, int right) -{ - if ( left < 0 ) - left = 0; - if ( right < 0 ) - right = 0; - if ( right > self->b_size ) - right = self->b_size; - if ( right < left ) - right = left; - return PyString_FromStringAndSize((char *)self->b_ptr + left, - right - left); -} - -static int -buffer_ass_item(PyBufferObject *self, int idx, PyObject *other) -{ - PyBufferProcs *pb; - void *p; - int count; - - if ( self->b_readonly ) { - PyErr_SetString(PyExc_TypeError, - "buffer is read-only"); - return -1; - } - - if (idx < 0 || idx >= self->b_size) { - PyErr_SetString(PyExc_IndexError, - "buffer assignment index out of range"); - return -1; - } - - pb = other ? other->ob_type->tp_as_buffer : NULL; - if ( pb == NULL || - pb->bf_getreadbuffer == NULL || - pb->bf_getsegcount == NULL ) - { - PyErr_BadArgument(); - return -1; - } - if ( (*pb->bf_getsegcount)(other, NULL) != 1 ) - { - /* ### use a different exception type/message? */ - PyErr_SetString(PyExc_TypeError, - "single-segment buffer object expected"); - return -1; - } - - if ( (count = (*pb->bf_getreadbuffer)(other, 0, &p)) < 0 ) - return -1; - if ( count != 1 ) { - PyErr_SetString(PyExc_TypeError, - "right operand must be a single byte"); - return -1; - } - - ((char *)self->b_ptr)[idx] = *(char *)p; - return 0; -} - -static int -buffer_ass_slice(PyBufferObject *self, int left, int right, PyObject *other) -{ - PyBufferProcs *pb; - void *p; - int slice_len; - int count; - - if ( self->b_readonly ) { - PyErr_SetString(PyExc_TypeError, - "buffer is read-only"); - return -1; - } - - pb = other ? other->ob_type->tp_as_buffer : NULL; - if ( pb == NULL || - pb->bf_getreadbuffer == NULL || - pb->bf_getsegcount == NULL ) - { - PyErr_BadArgument(); - return -1; - } - if ( (*pb->bf_getsegcount)(other, NULL) != 1 ) - { - /* ### use a different exception type/message? */ - PyErr_SetString(PyExc_TypeError, - "single-segment buffer object expected"); - return -1; - } - if ( (count = (*pb->bf_getreadbuffer)(other, 0, &p)) < 0 ) - return -1; - - if ( left < 0 ) - left = 0; - else if ( left > self->b_size ) - left = self->b_size; - if ( right < left ) - right = left; - else if ( right > self->b_size ) - right = self->b_size; - slice_len = right - left; - - if ( count != slice_len ) { - PyErr_SetString( - PyExc_TypeError, - "right operand length must match slice length"); - return -1; - } - - if ( slice_len ) - memcpy((char *)self->b_ptr + left, p, slice_len); - - return 0; -} - -/* Buffer methods */ - -static int -buffer_getreadbuf(PyBufferObject *self, int idx, void **pp) -{ - if ( idx != 0 ) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent buffer segment"); - return -1; - } - *pp = self->b_ptr; - return self->b_size; -} - -static int -buffer_getwritebuf(PyBufferObject *self, int idx, void **pp) -{ - if ( self->b_readonly ) - { - PyErr_SetString(PyExc_TypeError, "buffer is read-only"); - return -1; - } - return buffer_getreadbuf(self, idx, pp); -} - -static int -buffer_getsegcount(PyBufferObject *self, int *lenp) -{ - if ( lenp ) - *lenp = self->b_size; - return 1; -} - -static int -buffer_getcharbuf(PyBufferObject *self, int idx, const char **pp) -{ - if ( idx != 0 ) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent buffer segment"); - return -1; - } - *pp = (const char *)self->b_ptr; - return self->b_size; -} - - -static PySequenceMethods buffer_as_sequence = { - (inquiry)buffer_length, /*sq_length*/ - (binaryfunc)buffer_concat, /*sq_concat*/ - (intargfunc)buffer_repeat, /*sq_repeat*/ - (intargfunc)buffer_item, /*sq_item*/ - (intintargfunc)buffer_slice, /*sq_slice*/ - (intobjargproc)buffer_ass_item, /*sq_ass_item*/ - (intintobjargproc)buffer_ass_slice, /*sq_ass_slice*/ -}; - -static PyBufferProcs buffer_as_buffer = { - (getreadbufferproc)buffer_getreadbuf, - (getwritebufferproc)buffer_getwritebuf, - (getsegcountproc)buffer_getsegcount, - (getcharbufferproc)buffer_getcharbuf, -}; - -PyTypeObject PyBuffer_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "buffer", - sizeof(PyBufferObject), - 0, - (destructor)buffer_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)buffer_compare, /* tp_compare */ - (reprfunc)buffer_repr, /* tp_repr */ - 0, /* tp_as_number */ - &buffer_as_sequence, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)buffer_hash, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)buffer_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - &buffer_as_buffer, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - buffer_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - buffer_new, /* tp_new */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/cellobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/cellobject.c deleted file mode 100644 index 5744ce8b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/cellobject.c +++ /dev/null @@ -1,114 +0,0 @@ -/* Cell object implementation */ - -#include "Python.h" - -PyObject * -PyCell_New(PyObject *obj) -{ - PyCellObject *op; - - op = (PyCellObject *)PyObject_GC_New(PyCellObject, &PyCell_Type); - op->ob_ref = obj; - Py_XINCREF(obj); - - _PyObject_GC_TRACK(op); - return (PyObject *)op; -} - -PyObject * -PyCell_Get(PyObject *op) -{ - if (!PyCell_Check(op)) { - PyErr_BadInternalCall(); - return NULL; - } - Py_XINCREF(((PyCellObject*)op)->ob_ref); - return PyCell_GET(op); -} - -int -PyCell_Set(PyObject *op, PyObject *obj) -{ - if (!PyCell_Check(op)) { - PyErr_BadInternalCall(); - return -1; - } - Py_XDECREF(((PyCellObject*)op)->ob_ref); - Py_XINCREF(obj); - PyCell_SET(op, obj); - return 0; -} - -static void -cell_dealloc(PyCellObject *op) -{ - _PyObject_GC_UNTRACK(op); - Py_XDECREF(op->ob_ref); - PyObject_GC_Del(op); -} - -static int -cell_compare(PyCellObject *a, PyCellObject *b) -{ - if (a->ob_ref == NULL) { - if (b->ob_ref == NULL) - return 0; - return -1; - } else if (b->ob_ref == NULL) - return 1; - return PyObject_Compare(a->ob_ref, b->ob_ref); -} - -static PyObject * -cell_repr(PyCellObject *op) -{ - if (op->ob_ref == NULL) - return PyString_FromFormat("", op); - - return PyString_FromFormat("", - op, op->ob_ref->ob_type->tp_name, - op->ob_ref); -} - -static int -cell_traverse(PyCellObject *op, visitproc visit, void *arg) -{ - if (op->ob_ref) - return visit(op->ob_ref, arg); - return 0; -} - -static int -cell_clear(PyCellObject *op) -{ - Py_XDECREF(op->ob_ref); - op->ob_ref = NULL; - return 0; -} - -PyTypeObject PyCell_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "cell", - sizeof(PyCellObject), - 0, - (destructor)cell_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)cell_compare, /* tp_compare */ - (reprfunc)cell_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - 0, /* tp_doc */ - (traverseproc)cell_traverse, /* tp_traverse */ - (inquiry)cell_clear, /* tp_clear */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/classobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/classobject.c deleted file mode 100644 index 4d282cfd..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/classobject.c +++ /dev/null @@ -1,2516 +0,0 @@ - -/* Class object implementation */ - -#include "Python.h" -#include "structmember.h" - -#define TP_DESCR_GET(t) \ - (PyType_HasFeature(t, Py_TPFLAGS_HAVE_CLASS) ? (t)->tp_descr_get : NULL) - - -/* Forward */ -static PyObject *class_lookup(PyClassObject *, PyObject *, - PyClassObject **); -static PyObject *instance_getattr1(PyInstanceObject *, PyObject *); -static PyObject *instance_getattr2(PyInstanceObject *, PyObject *); - -static PyObject *getattrstr, *setattrstr, *delattrstr; - - -PyObject * -PyClass_New(PyObject *bases, PyObject *dict, PyObject *name) - /* bases is NULL or tuple of classobjects! */ -{ - PyClassObject *op, *dummy; - static PyObject *docstr, *modstr, *namestr; - if (docstr == NULL) { - docstr= PyString_InternFromString("__doc__"); - if (docstr == NULL) - return NULL; - } - if (modstr == NULL) { - modstr= PyString_InternFromString("__module__"); - if (modstr == NULL) - return NULL; - } - if (namestr == NULL) { - namestr= PyString_InternFromString("__name__"); - if (namestr == NULL) - return NULL; - } - if (name == NULL || !PyString_Check(name)) { - PyErr_SetString(PyExc_TypeError, - "PyClass_New: name must be a string"); - return NULL; - } - if (dict == NULL || !PyDict_Check(dict)) { - PyErr_SetString(PyExc_TypeError, - "PyClass_New: dict must be a dictionary"); - return NULL; - } - if (PyDict_GetItem(dict, docstr) == NULL) { - if (PyDict_SetItem(dict, docstr, Py_None) < 0) - return NULL; - } - if (PyDict_GetItem(dict, modstr) == NULL) { - PyObject *globals = PyEval_GetGlobals(); - if (globals != NULL) { - PyObject *modname = PyDict_GetItem(globals, namestr); - if (modname != NULL) { - if (PyDict_SetItem(dict, modstr, modname) < 0) - return NULL; - } - } - } - if (bases == NULL) { - bases = PyTuple_New(0); - if (bases == NULL) - return NULL; - } - else { - int i, n; - PyObject *base; - if (!PyTuple_Check(bases)) { - PyErr_SetString(PyExc_TypeError, - "PyClass_New: bases must be a tuple"); - return NULL; - } - n = PyTuple_Size(bases); - for (i = 0; i < n; i++) { - base = PyTuple_GET_ITEM(bases, i); - if (!PyClass_Check(base)) { - if (PyCallable_Check( - (PyObject *) base->ob_type)) - return PyObject_CallFunction( - (PyObject *) base->ob_type, - "OOO", - name, - bases, - dict); - PyErr_SetString(PyExc_TypeError, - "PyClass_New: base must be a class"); - return NULL; - } - } - Py_INCREF(bases); - } - op = PyObject_GC_New(PyClassObject, &PyClass_Type); - if (op == NULL) { - Py_DECREF(bases); - return NULL; - } - op->cl_bases = bases; - Py_INCREF(dict); - op->cl_dict = dict; - Py_XINCREF(name); - op->cl_name = name; - if (getattrstr == NULL) { - getattrstr = PyString_InternFromString("__getattr__"); - setattrstr = PyString_InternFromString("__setattr__"); - delattrstr = PyString_InternFromString("__delattr__"); - } - op->cl_getattr = class_lookup(op, getattrstr, &dummy); - op->cl_setattr = class_lookup(op, setattrstr, &dummy); - op->cl_delattr = class_lookup(op, delattrstr, &dummy); - Py_XINCREF(op->cl_getattr); - Py_XINCREF(op->cl_setattr); - Py_XINCREF(op->cl_delattr); - _PyObject_GC_TRACK(op); - return (PyObject *) op; -} - -PyObject * -PyMethod_Function(PyObject *im) -{ - if (!PyMethod_Check(im)) { - PyErr_BadInternalCall(); - return NULL; - } - return ((PyMethodObject *)im)->im_func; -} - -PyObject * -PyMethod_Self(PyObject *im) -{ - if (!PyMethod_Check(im)) { - PyErr_BadInternalCall(); - return NULL; - } - return ((PyMethodObject *)im)->im_self; -} - -PyObject * -PyMethod_Class(PyObject *im) -{ - if (!PyMethod_Check(im)) { - PyErr_BadInternalCall(); - return NULL; - } - return ((PyMethodObject *)im)->im_class; -} - -PyDoc_STRVAR(class_doc, -"classobj(name, bases, dict)\n\ -\n\ -Create a class object. The name must be a string; the second argument\n\ -a tuple of classes, and the third a dictionary."); - -static PyObject * -class_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *name, *bases, *dict; - static char *kwlist[] = {"name", "bases", "dict", 0}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "SOO", kwlist, - &name, &bases, &dict)) - return NULL; - return PyClass_New(bases, dict, name); -} - -/* Class methods */ - -static void -class_dealloc(PyClassObject *op) -{ - _PyObject_GC_UNTRACK(op); - Py_DECREF(op->cl_bases); - Py_DECREF(op->cl_dict); - Py_XDECREF(op->cl_name); - Py_XDECREF(op->cl_getattr); - Py_XDECREF(op->cl_setattr); - Py_XDECREF(op->cl_delattr); - PyObject_GC_Del(op); -} - -static PyObject * -class_lookup(PyClassObject *cp, PyObject *name, PyClassObject **pclass) -{ - int i, n; - PyObject *value = PyDict_GetItem(cp->cl_dict, name); - if (value != NULL) { - *pclass = cp; - return value; - } - n = PyTuple_Size(cp->cl_bases); - for (i = 0; i < n; i++) { - /* XXX What if one of the bases is not a class? */ - PyObject *v = class_lookup( - (PyClassObject *) - PyTuple_GetItem(cp->cl_bases, i), name, pclass); - if (v != NULL) - return v; - } - return NULL; -} - -static PyObject * -class_getattr(register PyClassObject *op, PyObject *name) -{ - register PyObject *v; - register char *sname = PyString_AsString(name); - PyClassObject *class; - descrgetfunc f; - - if (sname[0] == '_' && sname[1] == '_') { - if (strcmp(sname, "__dict__") == 0) { - if (PyEval_GetRestricted()) { - PyErr_SetString(PyExc_RuntimeError, - "class.__dict__ not accessible in restricted mode"); - return NULL; - } - Py_INCREF(op->cl_dict); - return op->cl_dict; - } - if (strcmp(sname, "__bases__") == 0) { - Py_INCREF(op->cl_bases); - return op->cl_bases; - } - if (strcmp(sname, "__name__") == 0) { - if (op->cl_name == NULL) - v = Py_None; - else - v = op->cl_name; - Py_INCREF(v); - return v; - } - } - v = class_lookup(op, name, &class); - if (v == NULL) { - PyErr_Format(PyExc_AttributeError, - "class %.50s has no attribute '%.400s'", - PyString_AS_STRING(op->cl_name), sname); - return NULL; - } - f = TP_DESCR_GET(v->ob_type); - if (f == NULL) - Py_INCREF(v); - else - v = f(v, (PyObject *)NULL, (PyObject *)op); - return v; -} - -static void -set_slot(PyObject **slot, PyObject *v) -{ - PyObject *temp = *slot; - Py_XINCREF(v); - *slot = v; - Py_XDECREF(temp); -} - -static void -set_attr_slots(PyClassObject *c) -{ - PyClassObject *dummy; - - set_slot(&c->cl_getattr, class_lookup(c, getattrstr, &dummy)); - set_slot(&c->cl_setattr, class_lookup(c, setattrstr, &dummy)); - set_slot(&c->cl_delattr, class_lookup(c, delattrstr, &dummy)); -} - -static char * -set_dict(PyClassObject *c, PyObject *v) -{ - if (v == NULL || !PyDict_Check(v)) - return "__dict__ must be a dictionary object"; - set_slot(&c->cl_dict, v); - set_attr_slots(c); - return ""; -} - -static char * -set_bases(PyClassObject *c, PyObject *v) -{ - int i, n; - - if (v == NULL || !PyTuple_Check(v)) - return "__bases__ must be a tuple object"; - n = PyTuple_Size(v); - for (i = 0; i < n; i++) { - PyObject *x = PyTuple_GET_ITEM(v, i); - if (!PyClass_Check(x)) - return "__bases__ items must be classes"; - if (PyClass_IsSubclass(x, (PyObject *)c)) - return "a __bases__ item causes an inheritance cycle"; - } - set_slot(&c->cl_bases, v); - set_attr_slots(c); - return ""; -} - -static char * -set_name(PyClassObject *c, PyObject *v) -{ - if (v == NULL || !PyString_Check(v)) - return "__name__ must be a string object"; - if (strlen(PyString_AS_STRING(v)) != (size_t)PyString_GET_SIZE(v)) - return "__name__ must not contain null bytes"; - set_slot(&c->cl_name, v); - return ""; -} - -static int -class_setattr(PyClassObject *op, PyObject *name, PyObject *v) -{ - char *sname; - if (PyEval_GetRestricted()) { - PyErr_SetString(PyExc_RuntimeError, - "classes are read-only in restricted mode"); - return -1; - } - sname = PyString_AsString(name); - if (sname[0] == '_' && sname[1] == '_') { - int n = PyString_Size(name); - if (sname[n-1] == '_' && sname[n-2] == '_') { - char *err = NULL; - if (strcmp(sname, "__dict__") == 0) - err = set_dict(op, v); - else if (strcmp(sname, "__bases__") == 0) - err = set_bases(op, v); - else if (strcmp(sname, "__name__") == 0) - err = set_name(op, v); - else if (strcmp(sname, "__getattr__") == 0) - set_slot(&op->cl_getattr, v); - else if (strcmp(sname, "__setattr__") == 0) - set_slot(&op->cl_setattr, v); - else if (strcmp(sname, "__delattr__") == 0) - set_slot(&op->cl_delattr, v); - /* For the last three, we fall through to update the - dictionary as well. */ - if (err != NULL) { - if (*err == '\0') - return 0; - PyErr_SetString(PyExc_TypeError, err); - return -1; - } - } - } - if (v == NULL) { - int rv = PyDict_DelItem(op->cl_dict, name); - if (rv < 0) - PyErr_Format(PyExc_AttributeError, - "class %.50s has no attribute '%.400s'", - PyString_AS_STRING(op->cl_name), sname); - return rv; - } - else - return PyDict_SetItem(op->cl_dict, name, v); -} - -static PyObject * -class_repr(PyClassObject *op) -{ - PyObject *mod = PyDict_GetItemString(op->cl_dict, "__module__"); - char *name; - if (op->cl_name == NULL || !PyString_Check(op->cl_name)) - name = "?"; - else - name = PyString_AsString(op->cl_name); - if (mod == NULL || !PyString_Check(mod)) - return PyString_FromFormat("", name, op); - else - return PyString_FromFormat("", - PyString_AsString(mod), - name, op); -} - -static PyObject * -class_str(PyClassObject *op) -{ - PyObject *mod = PyDict_GetItemString(op->cl_dict, "__module__"); - PyObject *name = op->cl_name; - PyObject *res; - int m, n; - - if (name == NULL || !PyString_Check(name)) - return class_repr(op); - if (mod == NULL || !PyString_Check(mod)) { - Py_INCREF(name); - return name; - } - m = PyString_Size(mod); - n = PyString_Size(name); - res = PyString_FromStringAndSize((char *)NULL, m+1+n); - if (res != NULL) { - char *s = PyString_AsString(res); - memcpy(s, PyString_AsString(mod), m); - s += m; - *s++ = '.'; - memcpy(s, PyString_AsString(name), n); - } - return res; -} - -static int -class_traverse(PyClassObject *o, visitproc visit, void *arg) -{ - int err; - if (o->cl_bases) { - err = visit(o->cl_bases, arg); - if (err) - return err; - } - if (o->cl_dict) { - err = visit(o->cl_dict, arg); - if (err) - return err; - } - if (o->cl_name) { - err = visit(o->cl_name, arg); - if (err) - return err; - } - if (o->cl_getattr) { - err = visit(o->cl_getattr, arg); - if (err) - return err; - } - if (o->cl_setattr) { - err = visit(o->cl_setattr, arg); - if (err) - return err; - } - if (o->cl_delattr) { - err = visit(o->cl_delattr, arg); - if (err) - return err; - } - return 0; -} - -PyTypeObject PyClass_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "classobj", - sizeof(PyClassObject), - 0, - (destructor)class_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)class_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - PyInstance_New, /* tp_call */ - (reprfunc)class_str, /* tp_str */ - (getattrofunc)class_getattr, /* tp_getattro */ - (setattrofunc)class_setattr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - class_doc, /* tp_doc */ - (traverseproc)class_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - class_new, /* tp_new */ -}; - -int -PyClass_IsSubclass(PyObject *class, PyObject *base) -{ - int i, n; - PyClassObject *cp; - if (class == base) - return 1; - if (PyTuple_Check(base)) { - n = PyTuple_GET_SIZE(base); - for (i = 0; i < n; i++) { - if (PyClass_IsSubclass(class, PyTuple_GET_ITEM(base, i))) - return 1; - } - return 0; - } - if (class == NULL || !PyClass_Check(class)) - return 0; - cp = (PyClassObject *)class; - n = PyTuple_Size(cp->cl_bases); - for (i = 0; i < n; i++) { - if (PyClass_IsSubclass(PyTuple_GetItem(cp->cl_bases, i), base)) - return 1; - } - return 0; -} - - -/* Instance objects */ - -PyObject * -PyInstance_NewRaw(PyObject *klass, PyObject *dict) -{ - PyInstanceObject *inst; - - if (!PyClass_Check(klass)) { - PyErr_BadInternalCall(); - return NULL; - } - if (dict == NULL) { - dict = PyDict_New(); - if (dict == NULL) - return NULL; - } - else { - if (!PyDict_Check(dict)) { - PyErr_BadInternalCall(); - return NULL; - } - Py_INCREF(dict); - } - inst = PyObject_GC_New(PyInstanceObject, &PyInstance_Type); - if (inst == NULL) { - Py_DECREF(dict); - return NULL; - } - inst->in_weakreflist = NULL; - Py_INCREF(klass); - inst->in_class = (PyClassObject *)klass; - inst->in_dict = dict; - _PyObject_GC_TRACK(inst); - return (PyObject *)inst; -} - -PyObject * -PyInstance_New(PyObject *klass, PyObject *arg, PyObject *kw) -{ - register PyInstanceObject *inst; - PyObject *init; - static PyObject *initstr; - - inst = (PyInstanceObject *) PyInstance_NewRaw(klass, NULL); - if (inst == NULL) - return NULL; - if (initstr == NULL) - initstr = PyString_InternFromString("__init__"); - init = instance_getattr2(inst, initstr); - if (init == NULL) { - if (PyErr_Occurred()) { - Py_DECREF(inst); - return NULL; - } - if ((arg != NULL && (!PyTuple_Check(arg) || - PyTuple_Size(arg) != 0)) - || (kw != NULL && (!PyDict_Check(kw) || - PyDict_Size(kw) != 0))) { - PyErr_SetString(PyExc_TypeError, - "this constructor takes no arguments"); - Py_DECREF(inst); - inst = NULL; - } - } - else { - PyObject *res = PyEval_CallObjectWithKeywords(init, arg, kw); - Py_DECREF(init); - if (res == NULL) { - Py_DECREF(inst); - inst = NULL; - } - else { - if (res != Py_None) { - PyErr_SetString(PyExc_TypeError, - "__init__() should return None"); - Py_DECREF(inst); - inst = NULL; - } - Py_DECREF(res); - } - } - return (PyObject *)inst; -} - -/* Instance methods */ - -PyDoc_STRVAR(instance_doc, -"instance(class[, dict])\n\ -\n\ -Create an instance without calling its __init__() method.\n\ -The class must be a classic class.\n\ -If present, dict must be a dictionary or None."); - -static PyObject * -instance_new(PyTypeObject* type, PyObject* args, PyObject *kw) -{ - PyObject *klass; - PyObject *dict = Py_None; - - if (!PyArg_ParseTuple(args, "O!|O:instance", - &PyClass_Type, &klass, &dict)) - return NULL; - - if (dict == Py_None) - dict = NULL; - else if (!PyDict_Check(dict)) { - PyErr_SetString(PyExc_TypeError, - "instance() second arg must be dictionary or None"); - return NULL; - } - return PyInstance_NewRaw(klass, dict); -} - - -static void -instance_dealloc(register PyInstanceObject *inst) -{ - PyObject *error_type, *error_value, *error_traceback; - PyObject *del; - static PyObject *delstr; - - _PyObject_GC_UNTRACK(inst); - if (inst->in_weakreflist != NULL) - PyObject_ClearWeakRefs((PyObject *) inst); - - /* Temporarily resurrect the object. */ - assert(inst->ob_type == &PyInstance_Type); - assert(inst->ob_refcnt == 0); - inst->ob_refcnt = 1; - - /* Save the current exception, if any. */ - PyErr_Fetch(&error_type, &error_value, &error_traceback); - /* Execute __del__ method, if any. */ - if (delstr == NULL) - delstr = PyString_InternFromString("__del__"); - if ((del = instance_getattr2(inst, delstr)) != NULL) { - PyObject *res = PyEval_CallObject(del, (PyObject *)NULL); - if (res == NULL) - PyErr_WriteUnraisable(del); - else - Py_DECREF(res); - Py_DECREF(del); - } - /* Restore the saved exception. */ - PyErr_Restore(error_type, error_value, error_traceback); - - /* Undo the temporary resurrection; can't use DECREF here, it would - * cause a recursive call. - */ - assert(inst->ob_refcnt > 0); - if (--inst->ob_refcnt == 0) { - Py_DECREF(inst->in_class); - Py_XDECREF(inst->in_dict); - PyObject_GC_Del(inst); - } - else { - int refcnt = inst->ob_refcnt; - /* __del__ resurrected it! Make it look like the original - * Py_DECREF never happened. - */ - _Py_NewReference((PyObject *)inst); - inst->ob_refcnt = refcnt; - _PyObject_GC_TRACK(inst); - /* If Py_REF_DEBUG, the original decref dropped _Py_RefTotal, - * but _Py_NewReference bumped it again, so that's a wash. - * If Py_TRACE_REFS, _Py_NewReference re-added self to the - * object chain, so no more to do there either. - * If COUNT_ALLOCS, the original decref bumped tp_frees, and - * _Py_NewReference bumped tp_allocs: both of those need to - * be undone. - */ -#ifdef COUNT_ALLOCS - --inst->ob_type->tp_frees; - --inst->ob_type->tp_allocs; -#endif - } -} - -static PyObject * -instance_getattr1(register PyInstanceObject *inst, PyObject *name) -{ - register PyObject *v; - register char *sname = PyString_AsString(name); - if (sname[0] == '_' && sname[1] == '_') { - if (strcmp(sname, "__dict__") == 0) { - if (PyEval_GetRestricted()) { - PyErr_SetString(PyExc_RuntimeError, - "instance.__dict__ not accessible in restricted mode"); - return NULL; - } - Py_INCREF(inst->in_dict); - return inst->in_dict; - } - if (strcmp(sname, "__class__") == 0) { - Py_INCREF(inst->in_class); - return (PyObject *)inst->in_class; - } - } - v = instance_getattr2(inst, name); - if (v == NULL && !PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, - "%.50s instance has no attribute '%.400s'", - PyString_AS_STRING(inst->in_class->cl_name), sname); - } - return v; -} - -static PyObject * -instance_getattr2(register PyInstanceObject *inst, PyObject *name) -{ - register PyObject *v; - PyClassObject *class; - descrgetfunc f; - - v = PyDict_GetItem(inst->in_dict, name); - if (v != NULL) { - Py_INCREF(v); - return v; - } - v = class_lookup(inst->in_class, name, &class); - if (v != NULL) { - Py_INCREF(v); - f = TP_DESCR_GET(v->ob_type); - if (f != NULL) { - PyObject *w = f(v, (PyObject *)inst, - (PyObject *)(inst->in_class)); - Py_DECREF(v); - v = w; - } - } - return v; -} - -static PyObject * -instance_getattr(register PyInstanceObject *inst, PyObject *name) -{ - register PyObject *func, *res; - res = instance_getattr1(inst, name); - if (res == NULL && (func = inst->in_class->cl_getattr) != NULL) { - PyObject *args; - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return NULL; - PyErr_Clear(); - args = Py_BuildValue("(OO)", inst, name); - if (args == NULL) - return NULL; - res = PyEval_CallObject(func, args); - Py_DECREF(args); - } - return res; -} - -/* See classobject.h comments: this only does dict lookups, and is always - * safe to call. - */ -PyObject * -_PyInstance_Lookup(PyObject *pinst, PyObject *name) -{ - PyObject *v; - PyClassObject *class; - PyInstanceObject *inst; /* pinst cast to the right type */ - - assert(PyInstance_Check(pinst)); - inst = (PyInstanceObject *)pinst; - - assert(PyString_Check(name)); - - v = PyDict_GetItem(inst->in_dict, name); - if (v == NULL) - v = class_lookup(inst->in_class, name, &class); - return v; -} - -static int -instance_setattr1(PyInstanceObject *inst, PyObject *name, PyObject *v) -{ - if (v == NULL) { - int rv = PyDict_DelItem(inst->in_dict, name); - if (rv < 0) - PyErr_Format(PyExc_AttributeError, - "%.50s instance has no attribute '%.400s'", - PyString_AS_STRING(inst->in_class->cl_name), - PyString_AS_STRING(name)); - return rv; - } - else - return PyDict_SetItem(inst->in_dict, name, v); -} - -static int -instance_setattr(PyInstanceObject *inst, PyObject *name, PyObject *v) -{ - PyObject *func, *args, *res, *tmp; - char *sname = PyString_AsString(name); - if (sname[0] == '_' && sname[1] == '_') { - int n = PyString_Size(name); - if (sname[n-1] == '_' && sname[n-2] == '_') { - if (strcmp(sname, "__dict__") == 0) { - if (PyEval_GetRestricted()) { - PyErr_SetString(PyExc_RuntimeError, - "__dict__ not accessible in restricted mode"); - return -1; - } - if (v == NULL || !PyDict_Check(v)) { - PyErr_SetString(PyExc_TypeError, - "__dict__ must be set to a dictionary"); - return -1; - } - tmp = inst->in_dict; - Py_INCREF(v); - inst->in_dict = v; - Py_DECREF(tmp); - return 0; - } - if (strcmp(sname, "__class__") == 0) { - if (PyEval_GetRestricted()) { - PyErr_SetString(PyExc_RuntimeError, - "__class__ not accessible in restricted mode"); - return -1; - } - if (v == NULL || !PyClass_Check(v)) { - PyErr_SetString(PyExc_TypeError, - "__class__ must be set to a class"); - return -1; - } - tmp = (PyObject *)(inst->in_class); - Py_INCREF(v); - inst->in_class = (PyClassObject *)v; - Py_DECREF(tmp); - return 0; - } - } - } - if (v == NULL) - func = inst->in_class->cl_delattr; - else - func = inst->in_class->cl_setattr; - if (func == NULL) - return instance_setattr1(inst, name, v); - if (v == NULL) - args = Py_BuildValue("(OO)", inst, name); - else - args = Py_BuildValue("(OOO)", inst, name, v); - if (args == NULL) - return -1; - res = PyEval_CallObject(func, args); - Py_DECREF(args); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; -} - -static PyObject * -instance_repr(PyInstanceObject *inst) -{ - PyObject *func; - PyObject *res; - static PyObject *reprstr; - - if (reprstr == NULL) - reprstr = PyString_InternFromString("__repr__"); - func = instance_getattr(inst, reprstr); - if (func == NULL) { - PyObject *classname, *mod; - char *cname; - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return NULL; - PyErr_Clear(); - classname = inst->in_class->cl_name; - mod = PyDict_GetItemString(inst->in_class->cl_dict, - "__module__"); - if (classname != NULL && PyString_Check(classname)) - cname = PyString_AsString(classname); - else - cname = "?"; - if (mod == NULL || !PyString_Check(mod)) - return PyString_FromFormat("", - cname, inst); - else - return PyString_FromFormat("<%s.%s instance at %p>", - PyString_AsString(mod), - cname, inst); - } - res = PyEval_CallObject(func, (PyObject *)NULL); - Py_DECREF(func); - return res; -} - -static PyObject * -instance_str(PyInstanceObject *inst) -{ - PyObject *func; - PyObject *res; - static PyObject *strstr; - - if (strstr == NULL) - strstr = PyString_InternFromString("__str__"); - func = instance_getattr(inst, strstr); - if (func == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return NULL; - PyErr_Clear(); - return instance_repr(inst); - } - res = PyEval_CallObject(func, (PyObject *)NULL); - Py_DECREF(func); - return res; -} - -static long -instance_hash(PyInstanceObject *inst) -{ - PyObject *func; - PyObject *res; - long outcome; - static PyObject *hashstr, *eqstr, *cmpstr; - - if (hashstr == NULL) - hashstr = PyString_InternFromString("__hash__"); - func = instance_getattr(inst, hashstr); - if (func == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return -1; - PyErr_Clear(); - /* If there is no __eq__ and no __cmp__ method, we hash on the - address. If an __eq__ or __cmp__ method exists, there must - be a __hash__. */ - if (eqstr == NULL) - eqstr = PyString_InternFromString("__eq__"); - func = instance_getattr(inst, eqstr); - if (func == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return -1; - PyErr_Clear(); - if (cmpstr == NULL) - cmpstr = PyString_InternFromString("__cmp__"); - func = instance_getattr(inst, cmpstr); - if (func == NULL) { - if (!PyErr_ExceptionMatches( - PyExc_AttributeError)) - return -1; - PyErr_Clear(); - return _Py_HashPointer(inst); - } - } - Py_XDECREF(func); - PyErr_SetString(PyExc_TypeError, "unhashable instance"); - return -1; - } - res = PyEval_CallObject(func, (PyObject *)NULL); - Py_DECREF(func); - if (res == NULL) - return -1; - if (PyInt_Check(res)) { - outcome = PyInt_AsLong(res); - if (outcome == -1) - outcome = -2; - } - else { - PyErr_SetString(PyExc_TypeError, - "__hash__() should return an int"); - outcome = -1; - } - Py_DECREF(res); - return outcome; -} - -static int -instance_traverse(PyInstanceObject *o, visitproc visit, void *arg) -{ - int err; - if (o->in_class) { - err = visit((PyObject *)(o->in_class), arg); - if (err) - return err; - } - if (o->in_dict) { - err = visit(o->in_dict, arg); - if (err) - return err; - } - return 0; -} - -static PyObject *getitemstr, *setitemstr, *delitemstr, *lenstr; -static PyObject *iterstr, *nextstr; - -static int -instance_length(PyInstanceObject *inst) -{ - PyObject *func; - PyObject *res; - int outcome; - - if (lenstr == NULL) - lenstr = PyString_InternFromString("__len__"); - func = instance_getattr(inst, lenstr); - if (func == NULL) - return -1; - res = PyEval_CallObject(func, (PyObject *)NULL); - Py_DECREF(func); - if (res == NULL) - return -1; - if (PyInt_Check(res)) { - outcome = PyInt_AsLong(res); - if (outcome < 0) - PyErr_SetString(PyExc_ValueError, - "__len__() should return >= 0"); - } - else { - PyErr_SetString(PyExc_TypeError, - "__len__() should return an int"); - outcome = -1; - } - Py_DECREF(res); - return outcome; -} - -static PyObject * -instance_subscript(PyInstanceObject *inst, PyObject *key) -{ - PyObject *func; - PyObject *arg; - PyObject *res; - - if (getitemstr == NULL) - getitemstr = PyString_InternFromString("__getitem__"); - func = instance_getattr(inst, getitemstr); - if (func == NULL) - return NULL; - arg = Py_BuildValue("(O)", key); - if (arg == NULL) { - Py_DECREF(func); - return NULL; - } - res = PyEval_CallObject(func, arg); - Py_DECREF(func); - Py_DECREF(arg); - return res; -} - -static int -instance_ass_subscript(PyInstanceObject *inst, PyObject *key, PyObject *value) -{ - PyObject *func; - PyObject *arg; - PyObject *res; - - if (value == NULL) { - if (delitemstr == NULL) - delitemstr = PyString_InternFromString("__delitem__"); - func = instance_getattr(inst, delitemstr); - } - else { - if (setitemstr == NULL) - setitemstr = PyString_InternFromString("__setitem__"); - func = instance_getattr(inst, setitemstr); - } - if (func == NULL) - return -1; - if (value == NULL) - arg = Py_BuildValue("(O)", key); - else - arg = Py_BuildValue("(OO)", key, value); - if (arg == NULL) { - Py_DECREF(func); - return -1; - } - res = PyEval_CallObject(func, arg); - Py_DECREF(func); - Py_DECREF(arg); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; -} - -static PyMappingMethods instance_as_mapping = { - (inquiry)instance_length, /* mp_length */ - (binaryfunc)instance_subscript, /* mp_subscript */ - (objobjargproc)instance_ass_subscript, /* mp_ass_subscript */ -}; - -static PyObject * -instance_item(PyInstanceObject *inst, int i) -{ - PyObject *func, *arg, *res; - - if (getitemstr == NULL) - getitemstr = PyString_InternFromString("__getitem__"); - func = instance_getattr(inst, getitemstr); - if (func == NULL) - return NULL; - arg = Py_BuildValue("(i)", i); - if (arg == NULL) { - Py_DECREF(func); - return NULL; - } - res = PyEval_CallObject(func, arg); - Py_DECREF(func); - Py_DECREF(arg); - return res; -} - -static PyObject * -sliceobj_from_intint(int i, int j) -{ - PyObject *start, *end, *res; - - start = PyInt_FromLong((long)i); - if (!start) - return NULL; - - end = PyInt_FromLong((long)j); - if (!end) { - Py_DECREF(start); - return NULL; - } - res = PySlice_New(start, end, NULL); - Py_DECREF(start); - Py_DECREF(end); - return res; -} - - -static PyObject * -instance_slice(PyInstanceObject *inst, int i, int j) -{ - PyObject *func, *arg, *res; - static PyObject *getslicestr; - - if (getslicestr == NULL) - getslicestr = PyString_InternFromString("__getslice__"); - func = instance_getattr(inst, getslicestr); - - if (func == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return NULL; - PyErr_Clear(); - - if (getitemstr == NULL) - getitemstr = PyString_InternFromString("__getitem__"); - func = instance_getattr(inst, getitemstr); - if (func == NULL) - return NULL; - arg = Py_BuildValue("(N)", sliceobj_from_intint(i, j)); - } else - arg = Py_BuildValue("(ii)", i, j); - - if (arg == NULL) { - Py_DECREF(func); - return NULL; - } - res = PyEval_CallObject(func, arg); - Py_DECREF(func); - Py_DECREF(arg); - return res; -} - -static int -instance_ass_item(PyInstanceObject *inst, int i, PyObject *item) -{ - PyObject *func, *arg, *res; - - if (item == NULL) { - if (delitemstr == NULL) - delitemstr = PyString_InternFromString("__delitem__"); - func = instance_getattr(inst, delitemstr); - } - else { - if (setitemstr == NULL) - setitemstr = PyString_InternFromString("__setitem__"); - func = instance_getattr(inst, setitemstr); - } - if (func == NULL) - return -1; - if (item == NULL) - arg = Py_BuildValue("i", i); - else - arg = Py_BuildValue("(iO)", i, item); - if (arg == NULL) { - Py_DECREF(func); - return -1; - } - res = PyEval_CallObject(func, arg); - Py_DECREF(func); - Py_DECREF(arg); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; -} - -static int -instance_ass_slice(PyInstanceObject *inst, int i, int j, PyObject *value) -{ - PyObject *func, *arg, *res; - static PyObject *setslicestr, *delslicestr; - - if (value == NULL) { - if (delslicestr == NULL) - delslicestr = - PyString_InternFromString("__delslice__"); - func = instance_getattr(inst, delslicestr); - if (func == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return -1; - PyErr_Clear(); - if (delitemstr == NULL) - delitemstr = - PyString_InternFromString("__delitem__"); - func = instance_getattr(inst, delitemstr); - if (func == NULL) - return -1; - - arg = Py_BuildValue("(N)", - sliceobj_from_intint(i, j)); - } else - arg = Py_BuildValue("(ii)", i, j); - } - else { - if (setslicestr == NULL) - setslicestr = - PyString_InternFromString("__setslice__"); - func = instance_getattr(inst, setslicestr); - if (func == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return -1; - PyErr_Clear(); - if (setitemstr == NULL) - setitemstr = - PyString_InternFromString("__setitem__"); - func = instance_getattr(inst, setitemstr); - if (func == NULL) - return -1; - - arg = Py_BuildValue("(NO)", - sliceobj_from_intint(i, j), value); - } else - arg = Py_BuildValue("(iiO)", i, j, value); - } - if (arg == NULL) { - Py_DECREF(func); - return -1; - } - res = PyEval_CallObject(func, arg); - Py_DECREF(func); - Py_DECREF(arg); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; -} - -static int -instance_contains(PyInstanceObject *inst, PyObject *member) -{ - static PyObject *__contains__; - PyObject *func; - - /* Try __contains__ first. - * If that can't be done, try iterator-based searching. - */ - - if(__contains__ == NULL) { - __contains__ = PyString_InternFromString("__contains__"); - if(__contains__ == NULL) - return -1; - } - func = instance_getattr(inst, __contains__); - if (func) { - PyObject *res; - int ret; - PyObject *arg = Py_BuildValue("(O)", member); - if(arg == NULL) { - Py_DECREF(func); - return -1; - } - res = PyEval_CallObject(func, arg); - Py_DECREF(func); - Py_DECREF(arg); - if(res == NULL) - return -1; - ret = PyObject_IsTrue(res); - Py_DECREF(res); - return ret; - } - - /* Couldn't find __contains__. */ - if (PyErr_ExceptionMatches(PyExc_AttributeError)) { - /* Assume the failure was simply due to that there is no - * __contains__ attribute, and try iterating instead. - */ - PyErr_Clear(); - return _PySequence_IterSearch((PyObject *)inst, member, - PY_ITERSEARCH_CONTAINS); - } - else - return -1; -} - -static PySequenceMethods -instance_as_sequence = { - (inquiry)instance_length, /* sq_length */ - 0, /* sq_concat */ - 0, /* sq_repeat */ - (intargfunc)instance_item, /* sq_item */ - (intintargfunc)instance_slice, /* sq_slice */ - (intobjargproc)instance_ass_item, /* sq_ass_item */ - (intintobjargproc)instance_ass_slice, /* sq_ass_slice */ - (objobjproc)instance_contains, /* sq_contains */ -}; - -static PyObject * -generic_unary_op(PyInstanceObject *self, PyObject *methodname) -{ - PyObject *func, *res; - - if ((func = instance_getattr(self, methodname)) == NULL) - return NULL; - res = PyEval_CallObject(func, (PyObject *)NULL); - Py_DECREF(func); - return res; -} - -static PyObject * -generic_binary_op(PyObject *v, PyObject *w, char *opname) -{ - PyObject *result; - PyObject *args; - PyObject *func = PyObject_GetAttrString(v, opname); - if (func == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return NULL; - PyErr_Clear(); - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - args = Py_BuildValue("(O)", w); - if (args == NULL) { - Py_DECREF(func); - return NULL; - } - result = PyEval_CallObject(func, args); - Py_DECREF(args); - Py_DECREF(func); - return result; -} - - -static PyObject *coerce_obj; - -/* Try one half of a binary operator involving a class instance. */ -static PyObject * -half_binop(PyObject *v, PyObject *w, char *opname, binaryfunc thisfunc, - int swapped) -{ - PyObject *args; - PyObject *coercefunc; - PyObject *coerced = NULL; - PyObject *v1; - PyObject *result; - - if (!PyInstance_Check(v)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - - if (coerce_obj == NULL) { - coerce_obj = PyString_InternFromString("__coerce__"); - if (coerce_obj == NULL) - return NULL; - } - coercefunc = PyObject_GetAttr(v, coerce_obj); - if (coercefunc == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return NULL; - PyErr_Clear(); - return generic_binary_op(v, w, opname); - } - - args = Py_BuildValue("(O)", w); - if (args == NULL) { - Py_DECREF(coercefunc); - return NULL; - } - coerced = PyEval_CallObject(coercefunc, args); - Py_DECREF(args); - Py_DECREF(coercefunc); - if (coerced == NULL) { - return NULL; - } - if (coerced == Py_None || coerced == Py_NotImplemented) { - Py_DECREF(coerced); - return generic_binary_op(v, w, opname); - } - if (!PyTuple_Check(coerced) || PyTuple_Size(coerced) != 2) { - Py_DECREF(coerced); - PyErr_SetString(PyExc_TypeError, - "coercion should return None or 2-tuple"); - return NULL; - } - v1 = PyTuple_GetItem(coerced, 0); - w = PyTuple_GetItem(coerced, 1); - if (v1->ob_type == v->ob_type && PyInstance_Check(v)) { - /* prevent recursion if __coerce__ returns self as the first - * argument */ - result = generic_binary_op(v1, w, opname); - } else { - if (swapped) - result = (thisfunc)(w, v1); - else - result = (thisfunc)(v1, w); - } - Py_DECREF(coerced); - return result; -} - -/* Implement a binary operator involving at least one class instance. */ -static PyObject * -do_binop(PyObject *v, PyObject *w, char *opname, char *ropname, - binaryfunc thisfunc) -{ - PyObject *result = half_binop(v, w, opname, thisfunc, 0); - if (result == Py_NotImplemented) { - Py_DECREF(result); - result = half_binop(w, v, ropname, thisfunc, 1); - } - return result; -} - -static PyObject * -do_binop_inplace(PyObject *v, PyObject *w, char *iopname, char *opname, - char *ropname, binaryfunc thisfunc) -{ - PyObject *result = half_binop(v, w, iopname, thisfunc, 0); - if (result == Py_NotImplemented) { - Py_DECREF(result); - result = do_binop(v, w, opname, ropname, thisfunc); - } - return result; -} - -static int -instance_coerce(PyObject **pv, PyObject **pw) -{ - PyObject *v = *pv; - PyObject *w = *pw; - PyObject *coercefunc; - PyObject *args; - PyObject *coerced; - - if (coerce_obj == NULL) { - coerce_obj = PyString_InternFromString("__coerce__"); - if (coerce_obj == NULL) - return -1; - } - coercefunc = PyObject_GetAttr(v, coerce_obj); - if (coercefunc == NULL) { - /* No __coerce__ method */ - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return -1; - PyErr_Clear(); - return 1; - } - /* Has __coerce__ method: call it */ - args = Py_BuildValue("(O)", w); - if (args == NULL) { - return -1; - } - coerced = PyEval_CallObject(coercefunc, args); - Py_DECREF(args); - Py_DECREF(coercefunc); - if (coerced == NULL) { - /* __coerce__ call raised an exception */ - return -1; - } - if (coerced == Py_None || coerced == Py_NotImplemented) { - /* __coerce__ says "I can't do it" */ - Py_DECREF(coerced); - return 1; - } - if (!PyTuple_Check(coerced) || PyTuple_Size(coerced) != 2) { - /* __coerce__ return value is malformed */ - Py_DECREF(coerced); - PyErr_SetString(PyExc_TypeError, - "coercion should return None or 2-tuple"); - return -1; - } - /* __coerce__ returned two new values */ - *pv = PyTuple_GetItem(coerced, 0); - *pw = PyTuple_GetItem(coerced, 1); - Py_INCREF(*pv); - Py_INCREF(*pw); - Py_DECREF(coerced); - return 0; -} - -#define UNARY(funcname, methodname) \ -static PyObject *funcname(PyInstanceObject *self) { \ - static PyObject *o; \ - if (o == NULL) o = PyString_InternFromString(methodname); \ - return generic_unary_op(self, o); \ -} - -#define BINARY(f, m, n) \ -static PyObject *f(PyObject *v, PyObject *w) { \ - return do_binop(v, w, "__" m "__", "__r" m "__", n); \ -} - -#define BINARY_INPLACE(f, m, n) \ -static PyObject *f(PyObject *v, PyObject *w) { \ - return do_binop_inplace(v, w, "__i" m "__", "__" m "__", \ - "__r" m "__", n); \ -} - -UNARY(instance_neg, "__neg__") -UNARY(instance_pos, "__pos__") -UNARY(instance_abs, "__abs__") - -BINARY(instance_or, "or", PyNumber_Or) -BINARY(instance_and, "and", PyNumber_And) -BINARY(instance_xor, "xor", PyNumber_Xor) -BINARY(instance_lshift, "lshift", PyNumber_Lshift) -BINARY(instance_rshift, "rshift", PyNumber_Rshift) -BINARY(instance_add, "add", PyNumber_Add) -BINARY(instance_sub, "sub", PyNumber_Subtract) -BINARY(instance_mul, "mul", PyNumber_Multiply) -BINARY(instance_div, "div", PyNumber_Divide) -BINARY(instance_mod, "mod", PyNumber_Remainder) -BINARY(instance_divmod, "divmod", PyNumber_Divmod) -BINARY(instance_floordiv, "floordiv", PyNumber_FloorDivide) -BINARY(instance_truediv, "truediv", PyNumber_TrueDivide) - -BINARY_INPLACE(instance_ior, "or", PyNumber_InPlaceOr) -BINARY_INPLACE(instance_ixor, "xor", PyNumber_InPlaceXor) -BINARY_INPLACE(instance_iand, "and", PyNumber_InPlaceAnd) -BINARY_INPLACE(instance_ilshift, "lshift", PyNumber_InPlaceLshift) -BINARY_INPLACE(instance_irshift, "rshift", PyNumber_InPlaceRshift) -BINARY_INPLACE(instance_iadd, "add", PyNumber_InPlaceAdd) -BINARY_INPLACE(instance_isub, "sub", PyNumber_InPlaceSubtract) -BINARY_INPLACE(instance_imul, "mul", PyNumber_InPlaceMultiply) -BINARY_INPLACE(instance_idiv, "div", PyNumber_InPlaceDivide) -BINARY_INPLACE(instance_imod, "mod", PyNumber_InPlaceRemainder) -BINARY_INPLACE(instance_ifloordiv, "floordiv", PyNumber_InPlaceFloorDivide) -BINARY_INPLACE(instance_itruediv, "truediv", PyNumber_InPlaceTrueDivide) - -/* Try a 3-way comparison, returning an int; v is an instance. Return: - -2 for an exception; - -1 if v < w; - 0 if v == w; - 1 if v > w; - 2 if this particular 3-way comparison is not implemented or undefined. -*/ -static int -half_cmp(PyObject *v, PyObject *w) -{ - static PyObject *cmp_obj; - PyObject *args; - PyObject *cmp_func; - PyObject *result; - long l; - - assert(PyInstance_Check(v)); - - if (cmp_obj == NULL) { - cmp_obj = PyString_InternFromString("__cmp__"); - if (cmp_obj == NULL) - return -2; - } - - cmp_func = PyObject_GetAttr(v, cmp_obj); - if (cmp_func == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return -2; - PyErr_Clear(); - return 2; - } - - args = Py_BuildValue("(O)", w); - if (args == NULL) { - Py_DECREF(cmp_func); - return -2; - } - - result = PyEval_CallObject(cmp_func, args); - Py_DECREF(args); - Py_DECREF(cmp_func); - - if (result == NULL) - return -2; - - if (result == Py_NotImplemented) { - Py_DECREF(result); - return 2; - } - - l = PyInt_AsLong(result); - Py_DECREF(result); - if (l == -1 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, - "comparison did not return an int"); - return -2; - } - - return l < 0 ? -1 : l > 0 ? 1 : 0; -} - -/* Try a 3-way comparison, returning an int; either v or w is an instance. - We first try a coercion. Return: - -2 for an exception; - -1 if v < w; - 0 if v == w; - 1 if v > w; - 2 if this particular 3-way comparison is not implemented or undefined. - THIS IS ONLY CALLED FROM object.c! -*/ -static int -instance_compare(PyObject *v, PyObject *w) -{ - int c; - - c = PyNumber_CoerceEx(&v, &w); - if (c < 0) - return -2; - if (c == 0) { - /* If neither is now an instance, use regular comparison */ - if (!PyInstance_Check(v) && !PyInstance_Check(w)) { - c = PyObject_Compare(v, w); - Py_DECREF(v); - Py_DECREF(w); - if (PyErr_Occurred()) - return -2; - return c < 0 ? -1 : c > 0 ? 1 : 0; - } - } - else { - /* The coercion didn't do anything. - Treat this the same as returning v and w unchanged. */ - Py_INCREF(v); - Py_INCREF(w); - } - - if (PyInstance_Check(v)) { - c = half_cmp(v, w); - if (c <= 1) { - Py_DECREF(v); - Py_DECREF(w); - return c; - } - } - if (PyInstance_Check(w)) { - c = half_cmp(w, v); - if (c <= 1) { - Py_DECREF(v); - Py_DECREF(w); - if (c >= -1) - c = -c; - return c; - } - } - Py_DECREF(v); - Py_DECREF(w); - return 2; -} - -static int -instance_nonzero(PyInstanceObject *self) -{ - PyObject *func, *res; - long outcome; - static PyObject *nonzerostr; - - if (nonzerostr == NULL) - nonzerostr = PyString_InternFromString("__nonzero__"); - if ((func = instance_getattr(self, nonzerostr)) == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return -1; - PyErr_Clear(); - if (lenstr == NULL) - lenstr = PyString_InternFromString("__len__"); - if ((func = instance_getattr(self, lenstr)) == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return -1; - PyErr_Clear(); - /* Fall back to the default behavior: - all instances are nonzero */ - return 1; - } - } - res = PyEval_CallObject(func, (PyObject *)NULL); - Py_DECREF(func); - if (res == NULL) - return -1; - if (!PyInt_Check(res)) { - Py_DECREF(res); - PyErr_SetString(PyExc_TypeError, - "__nonzero__ should return an int"); - return -1; - } - outcome = PyInt_AsLong(res); - Py_DECREF(res); - if (outcome < 0) { - PyErr_SetString(PyExc_ValueError, - "__nonzero__ should return >= 0"); - return -1; - } - return outcome > 0; -} - -UNARY(instance_invert, "__invert__") -UNARY(instance_int, "__int__") -UNARY(instance_long, "__long__") -UNARY(instance_float, "__float__") -UNARY(instance_oct, "__oct__") -UNARY(instance_hex, "__hex__") - -static PyObject * -bin_power(PyObject *v, PyObject *w) -{ - return PyNumber_Power(v, w, Py_None); -} - -/* This version is for ternary calls only (z != None) */ -static PyObject * -instance_pow(PyObject *v, PyObject *w, PyObject *z) -{ - if (z == Py_None) { - return do_binop(v, w, "__pow__", "__rpow__", bin_power); - } - else { - PyObject *func; - PyObject *args; - PyObject *result; - - /* XXX Doesn't do coercions... */ - func = PyObject_GetAttrString(v, "__pow__"); - if (func == NULL) - return NULL; - args = Py_BuildValue("(OO)", w, z); - if (args == NULL) { - Py_DECREF(func); - return NULL; - } - result = PyEval_CallObject(func, args); - Py_DECREF(func); - Py_DECREF(args); - return result; - } -} - -static PyObject * -bin_inplace_power(PyObject *v, PyObject *w) -{ - return PyNumber_InPlacePower(v, w, Py_None); -} - - -static PyObject * -instance_ipow(PyObject *v, PyObject *w, PyObject *z) -{ - if (z == Py_None) { - return do_binop_inplace(v, w, "__ipow__", "__pow__", - "__rpow__", bin_inplace_power); - } - else { - /* XXX Doesn't do coercions... */ - PyObject *func; - PyObject *args; - PyObject *result; - - func = PyObject_GetAttrString(v, "__ipow__"); - if (func == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return NULL; - PyErr_Clear(); - return instance_pow(v, w, z); - } - args = Py_BuildValue("(OO)", w, z); - if (args == NULL) { - Py_DECREF(func); - return NULL; - } - result = PyEval_CallObject(func, args); - Py_DECREF(func); - Py_DECREF(args); - return result; - } -} - - -/* Map rich comparison operators to their __xx__ namesakes */ -#define NAME_OPS 6 -static PyObject **name_op = NULL; - -static int -init_name_op(void) -{ - int i; - char *_name_op[] = { - "__lt__", - "__le__", - "__eq__", - "__ne__", - "__gt__", - "__ge__", - }; - - name_op = (PyObject **)malloc(sizeof(PyObject *) * NAME_OPS); - if (name_op == NULL) - return -1; - for (i = 0; i < NAME_OPS; ++i) { - name_op[i] = PyString_InternFromString(_name_op[i]); - if (name_op[i] == NULL) - return -1; - } - return 0; -} - -static PyObject * -half_richcompare(PyObject *v, PyObject *w, int op) -{ - PyObject *method; - PyObject *args; - PyObject *res; - - assert(PyInstance_Check(v)); - - if (name_op == NULL) { - if (init_name_op() < 0) - return NULL; - } - /* If the instance doesn't define an __getattr__ method, use - instance_getattr2 directly because it will not set an - exception on failure. */ - if (((PyInstanceObject *)v)->in_class->cl_getattr == NULL) - method = instance_getattr2((PyInstanceObject *)v, - name_op[op]); - else - method = PyObject_GetAttr(v, name_op[op]); - if (method == NULL) { - if (PyErr_Occurred()) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return NULL; - PyErr_Clear(); - } - res = Py_NotImplemented; - Py_INCREF(res); - return res; - } - - args = Py_BuildValue("(O)", w); - if (args == NULL) { - Py_DECREF(method); - return NULL; - } - - res = PyEval_CallObject(method, args); - Py_DECREF(args); - Py_DECREF(method); - - return res; -} - -/* Map rich comparison operators to their swapped version, e.g. LT --> GT */ -static int swapped_op[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE}; - -static PyObject * -instance_richcompare(PyObject *v, PyObject *w, int op) -{ - PyObject *res; - - if (PyInstance_Check(v)) { - res = half_richcompare(v, w, op); - if (res != Py_NotImplemented) - return res; - Py_DECREF(res); - } - - if (PyInstance_Check(w)) { - res = half_richcompare(w, v, swapped_op[op]); - if (res != Py_NotImplemented) - return res; - Py_DECREF(res); - } - - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; -} - - -/* Get the iterator */ -static PyObject * -instance_getiter(PyInstanceObject *self) -{ - PyObject *func; - - if (iterstr == NULL) { - iterstr = PyString_InternFromString("__iter__"); - if (iterstr == NULL) - return NULL; - } - if (getitemstr == NULL) { - getitemstr = PyString_InternFromString("__getitem__"); - if (getitemstr == NULL) - return NULL; - } - - if ((func = instance_getattr(self, iterstr)) != NULL) { - PyObject *res = PyEval_CallObject(func, (PyObject *)NULL); - Py_DECREF(func); - if (res != NULL && !PyIter_Check(res)) { - PyErr_Format(PyExc_TypeError, - "__iter__ returned non-iterator " - "of type '%.100s'", - res->ob_type->tp_name); - Py_DECREF(res); - res = NULL; - } - return res; - } - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return NULL; - PyErr_Clear(); - if ((func = instance_getattr(self, getitemstr)) == NULL) { - PyErr_SetString(PyExc_TypeError, - "iteration over non-sequence"); - return NULL; - } - Py_DECREF(func); - return PySeqIter_New((PyObject *)self); -} - - -/* Call the iterator's next */ -static PyObject * -instance_iternext(PyInstanceObject *self) -{ - PyObject *func; - - if (nextstr == NULL) - nextstr = PyString_InternFromString("next"); - - if ((func = instance_getattr(self, nextstr)) != NULL) { - PyObject *res = PyEval_CallObject(func, (PyObject *)NULL); - Py_DECREF(func); - if (res != NULL) { - return res; - } - if (PyErr_ExceptionMatches(PyExc_StopIteration)) { - PyErr_Clear(); - return NULL; - } - return NULL; - } - PyErr_SetString(PyExc_TypeError, "instance has no next() method"); - return NULL; -} - -static PyObject * -instance_call(PyObject *func, PyObject *arg, PyObject *kw) -{ - PyThreadState *tstate = PyThreadState_GET(); - PyObject *res, *call = PyObject_GetAttrString(func, "__call__"); - if (call == NULL) { - PyInstanceObject *inst = (PyInstanceObject*) func; - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return NULL; - PyErr_Clear(); - PyErr_Format(PyExc_AttributeError, - "%.200s instance has no __call__ method", - PyString_AsString(inst->in_class->cl_name)); - return NULL; - } - /* We must check and increment the recursion depth here. Scenario: - class A: - pass - A.__call__ = A() # that's right - a = A() # ok - a() # infinite recursion - This bounces between instance_call() and PyObject_Call() without - ever hitting eval_frame() (which has the main recursion check). */ - if (tstate->recursion_depth++ > Py_GetRecursionLimit()) { - PyErr_SetString(PyExc_RuntimeError, - "maximum __call__ recursion depth exceeded"); - res = NULL; - } - else - res = PyObject_Call(call, arg, kw); - tstate->recursion_depth--; - Py_DECREF(call); - return res; -} - - -static PyNumberMethods instance_as_number = { - (binaryfunc)instance_add, /* nb_add */ - (binaryfunc)instance_sub, /* nb_subtract */ - (binaryfunc)instance_mul, /* nb_multiply */ - (binaryfunc)instance_div, /* nb_divide */ - (binaryfunc)instance_mod, /* nb_remainder */ - (binaryfunc)instance_divmod, /* nb_divmod */ - (ternaryfunc)instance_pow, /* nb_power */ - (unaryfunc)instance_neg, /* nb_negative */ - (unaryfunc)instance_pos, /* nb_positive */ - (unaryfunc)instance_abs, /* nb_absolute */ - (inquiry)instance_nonzero, /* nb_nonzero */ - (unaryfunc)instance_invert, /* nb_invert */ - (binaryfunc)instance_lshift, /* nb_lshift */ - (binaryfunc)instance_rshift, /* nb_rshift */ - (binaryfunc)instance_and, /* nb_and */ - (binaryfunc)instance_xor, /* nb_xor */ - (binaryfunc)instance_or, /* nb_or */ - (coercion)instance_coerce, /* nb_coerce */ - (unaryfunc)instance_int, /* nb_int */ - (unaryfunc)instance_long, /* nb_long */ - (unaryfunc)instance_float, /* nb_float */ - (unaryfunc)instance_oct, /* nb_oct */ - (unaryfunc)instance_hex, /* nb_hex */ - (binaryfunc)instance_iadd, /* nb_inplace_add */ - (binaryfunc)instance_isub, /* nb_inplace_subtract */ - (binaryfunc)instance_imul, /* nb_inplace_multiply */ - (binaryfunc)instance_idiv, /* nb_inplace_divide */ - (binaryfunc)instance_imod, /* nb_inplace_remainder */ - (ternaryfunc)instance_ipow, /* nb_inplace_power */ - (binaryfunc)instance_ilshift, /* nb_inplace_lshift */ - (binaryfunc)instance_irshift, /* nb_inplace_rshift */ - (binaryfunc)instance_iand, /* nb_inplace_and */ - (binaryfunc)instance_ixor, /* nb_inplace_xor */ - (binaryfunc)instance_ior, /* nb_inplace_or */ - (binaryfunc)instance_floordiv, /* nb_floor_divide */ - (binaryfunc)instance_truediv, /* nb_true_divide */ - (binaryfunc)instance_ifloordiv, /* nb_inplace_floor_divide */ - (binaryfunc)instance_itruediv, /* nb_inplace_true_divide */ -}; - -PyTypeObject PyInstance_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "instance", - sizeof(PyInstanceObject), - 0, - (destructor)instance_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - instance_compare, /* tp_compare */ - (reprfunc)instance_repr, /* tp_repr */ - &instance_as_number, /* tp_as_number */ - &instance_as_sequence, /* tp_as_sequence */ - &instance_as_mapping, /* tp_as_mapping */ - (hashfunc)instance_hash, /* tp_hash */ - instance_call, /* tp_call */ - (reprfunc)instance_str, /* tp_str */ - (getattrofunc)instance_getattr, /* tp_getattro */ - (setattrofunc)instance_setattr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES,/*tp_flags*/ - instance_doc, /* tp_doc */ - (traverseproc)instance_traverse, /* tp_traverse */ - 0, /* tp_clear */ - instance_richcompare, /* tp_richcompare */ - offsetof(PyInstanceObject, in_weakreflist), /* tp_weaklistoffset */ - (getiterfunc)instance_getiter, /* tp_iter */ - (iternextfunc)instance_iternext, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - instance_new, /* tp_new */ -}; - - -/* Instance method objects are used for two purposes: - (a) as bound instance methods (returned by instancename.methodname) - (b) as unbound methods (returned by ClassName.methodname) - In case (b), im_self is NULL -*/ - -static PyMethodObject *free_list; - -PyObject * -PyMethod_New(PyObject *func, PyObject *self, PyObject *class) -{ - register PyMethodObject *im; - if (!PyCallable_Check(func)) { - PyErr_BadInternalCall(); - return NULL; - } - im = free_list; - if (im != NULL) { - free_list = (PyMethodObject *)(im->im_self); - PyObject_INIT(im, &PyMethod_Type); - } - else { - im = PyObject_GC_New(PyMethodObject, &PyMethod_Type); - if (im == NULL) - return NULL; - } - im->im_weakreflist = NULL; - Py_INCREF(func); - im->im_func = func; - Py_XINCREF(self); - im->im_self = self; - Py_XINCREF(class); - im->im_class = class; - _PyObject_GC_TRACK(im); - return (PyObject *)im; -} - -/* Descriptors for PyMethod attributes */ - -/* im_class, im_func and im_self are stored in the PyMethod object */ - -#define OFF(x) offsetof(PyMethodObject, x) - -static PyMemberDef instancemethod_memberlist[] = { - {"im_class", T_OBJECT, OFF(im_class), READONLY|RESTRICTED, - "the class associated with a method"}, - {"im_func", T_OBJECT, OFF(im_func), READONLY|RESTRICTED, - "the function (or other callable) implementing a method"}, - {"im_self", T_OBJECT, OFF(im_self), READONLY|RESTRICTED, - "the instance to which a method is bound; None for unbound methods"}, - {NULL} /* Sentinel */ -}; - -/* The getattr() implementation for PyMethod objects is similar to - PyObject_GenericGetAttr(), but instead of looking in __dict__ it - asks im_self for the attribute. Then the error handling is a bit - different because we want to preserve the exception raised by the - delegate, unless we have an alternative from our class. */ - -static PyObject * -instancemethod_getattro(PyObject *obj, PyObject *name) -{ - PyMethodObject *im = (PyMethodObject *)obj; - PyTypeObject *tp = obj->ob_type; - PyObject *descr = NULL, *res; - descrgetfunc f = NULL; - - if (PyType_HasFeature(tp, Py_TPFLAGS_HAVE_CLASS)) { - if (tp->tp_dict == NULL) { - if (PyType_Ready(tp) < 0) - return NULL; - } - descr = _PyType_Lookup(tp, name); - } - - f = NULL; - if (descr != NULL) { - f = TP_DESCR_GET(descr->ob_type); - if (f != NULL && PyDescr_IsData(descr)) - return f(descr, obj, (PyObject *)obj->ob_type); - } - - res = PyObject_GetAttr(im->im_func, name); - if (res != NULL || !PyErr_ExceptionMatches(PyExc_AttributeError)) - return res; - - if (f != NULL) { - PyErr_Clear(); - return f(descr, obj, (PyObject *)obj->ob_type); - } - - if (descr != NULL) { - PyErr_Clear(); - Py_INCREF(descr); - return descr; - } - - assert(PyErr_Occurred()); - return NULL; -} - -PyDoc_STRVAR(instancemethod_doc, -"instancemethod(function, instance, class)\n\ -\n\ -Create an instance method object."); - -static PyObject * -instancemethod_new(PyTypeObject* type, PyObject* args, PyObject *kw) -{ - PyObject *func; - PyObject *self; - PyObject *classObj = NULL; - - if (!PyArg_UnpackTuple(args, "instancemethod", 2, 3, - &func, &self, &classObj)) - return NULL; - if (!PyCallable_Check(func)) { - PyErr_SetString(PyExc_TypeError, - "first argument must be callable"); - return NULL; - } - if (self == Py_None) - self = NULL; - return PyMethod_New(func, self, classObj); -} - -static void -instancemethod_dealloc(register PyMethodObject *im) -{ - _PyObject_GC_UNTRACK(im); - if (im->im_weakreflist != NULL) - PyObject_ClearWeakRefs((PyObject *)im); - Py_DECREF(im->im_func); - Py_XDECREF(im->im_self); - Py_XDECREF(im->im_class); - im->im_self = (PyObject *)free_list; - free_list = im; -} - -static int -instancemethod_compare(PyMethodObject *a, PyMethodObject *b) -{ - if (a->im_self != b->im_self) - return (a->im_self < b->im_self) ? -1 : 1; - return PyObject_Compare(a->im_func, b->im_func); -} - -static PyObject * -instancemethod_repr(PyMethodObject *a) -{ - PyObject *self = a->im_self; - PyObject *func = a->im_func; - PyObject *klass = a->im_class; - PyObject *funcname = NULL, *klassname = NULL, *result = NULL; - char *sfuncname = "?", *sklassname = "?"; - - funcname = PyObject_GetAttrString(func, "__name__"); - if (funcname == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return NULL; - PyErr_Clear(); - } - else if (!PyString_Check(funcname)) { - Py_DECREF(funcname); - funcname = NULL; - } - else - sfuncname = PyString_AS_STRING(funcname); - if (klass == NULL) - klassname = NULL; - else { - klassname = PyObject_GetAttrString(klass, "__name__"); - if (klassname == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return NULL; - PyErr_Clear(); - } - else if (!PyString_Check(klassname)) { - Py_DECREF(klassname); - klassname = NULL; - } - else - sklassname = PyString_AS_STRING(klassname); - } - if (self == NULL) - result = PyString_FromFormat("", - sklassname, sfuncname); - else { - /* XXX Shouldn't use repr() here! */ - PyObject *selfrepr = PyObject_Repr(self); - if (selfrepr == NULL) - goto fail; - if (!PyString_Check(selfrepr)) { - Py_DECREF(selfrepr); - goto fail; - } - result = PyString_FromFormat("", - sklassname, sfuncname, - PyString_AS_STRING(selfrepr)); - Py_DECREF(selfrepr); - } - fail: - Py_XDECREF(funcname); - Py_XDECREF(klassname); - return result; -} - -static long -instancemethod_hash(PyMethodObject *a) -{ - long x, y; - if (a->im_self == NULL) - x = PyObject_Hash(Py_None); - else - x = PyObject_Hash(a->im_self); - if (x == -1) - return -1; - y = PyObject_Hash(a->im_func); - if (y == -1) - return -1; - return x ^ y; -} - -static int -instancemethod_traverse(PyMethodObject *im, visitproc visit, void *arg) -{ - int err; - if (im->im_func) { - err = visit(im->im_func, arg); - if (err) - return err; - } - if (im->im_self) { - err = visit(im->im_self, arg); - if (err) - return err; - } - if (im->im_class) { - err = visit(im->im_class, arg); - if (err) - return err; - } - return 0; -} - -static void -getclassname(PyObject *class, char *buf, int bufsize) -{ - PyObject *name; - - assert(bufsize > 1); - strcpy(buf, "?"); /* Default outcome */ - if (class == NULL) - return; - name = PyObject_GetAttrString(class, "__name__"); - if (name == NULL) { - /* This function cannot return an exception */ - PyErr_Clear(); - return; - } - if (PyString_Check(name)) { - strncpy(buf, PyString_AS_STRING(name), bufsize); - buf[bufsize-1] = '\0'; - } - Py_DECREF(name); -} - -static void -getinstclassname(PyObject *inst, char *buf, int bufsize) -{ - PyObject *class; - - if (inst == NULL) { - assert(bufsize > 0 && (size_t)bufsize > strlen("nothing")); - strcpy(buf, "nothing"); - return; - } - - class = PyObject_GetAttrString(inst, "__class__"); - if (class == NULL) { - /* This function cannot return an exception */ - PyErr_Clear(); - class = (PyObject *)(inst->ob_type); - Py_INCREF(class); - } - getclassname(class, buf, bufsize); - Py_XDECREF(class); -} - -static PyObject * -instancemethod_call(PyObject *func, PyObject *arg, PyObject *kw) -{ - PyObject *self = PyMethod_GET_SELF(func); - PyObject *class = PyMethod_GET_CLASS(func); - PyObject *result; - - func = PyMethod_GET_FUNCTION(func); - if (self == NULL) { - /* Unbound methods must be called with an instance of - the class (or a derived class) as first argument */ - int ok; - if (PyTuple_Size(arg) >= 1) - self = PyTuple_GET_ITEM(arg, 0); - if (self == NULL) - ok = 0; - else { - ok = PyObject_IsInstance(self, class); - if (ok < 0) - return NULL; - } - if (!ok) { - char clsbuf[256]; - char instbuf[256]; - getclassname(class, clsbuf, sizeof(clsbuf)); - getinstclassname(self, instbuf, sizeof(instbuf)); - PyErr_Format(PyExc_TypeError, - "unbound method %s%s must be called with " - "%s instance as first argument " - "(got %s%s instead)", - PyEval_GetFuncName(func), - PyEval_GetFuncDesc(func), - clsbuf, - instbuf, - self == NULL ? "" : " instance"); - return NULL; - } - Py_INCREF(arg); - } - else { - int argcount = PyTuple_Size(arg); - PyObject *newarg = PyTuple_New(argcount + 1); - int i; - if (newarg == NULL) - return NULL; - Py_INCREF(self); - PyTuple_SET_ITEM(newarg, 0, self); - for (i = 0; i < argcount; i++) { - PyObject *v = PyTuple_GET_ITEM(arg, i); - Py_XINCREF(v); - PyTuple_SET_ITEM(newarg, i+1, v); - } - arg = newarg; - } - result = PyObject_Call((PyObject *)func, arg, kw); - Py_DECREF(arg); - return result; -} - -static PyObject * -instancemethod_descr_get(PyObject *meth, PyObject *obj, PyObject *cls) -{ - /* Don't rebind an already bound method, or an unbound method - of a class that's not a base class of cls. */ - - if (PyMethod_GET_SELF(meth) != NULL) { - /* Already bound */ - Py_INCREF(meth); - return meth; - } - /* No, it is an unbound method */ - if (PyMethod_GET_CLASS(meth) != NULL && cls != NULL) { - /* Do subclass test. If it fails, return meth unchanged. */ - int ok = PyObject_IsSubclass(cls, PyMethod_GET_CLASS(meth)); - if (ok < 0) - return NULL; - if (!ok) { - Py_INCREF(meth); - return meth; - } - } - /* Bind it to obj */ - return PyMethod_New(PyMethod_GET_FUNCTION(meth), obj, cls); -} - -PyTypeObject PyMethod_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "instancemethod", - sizeof(PyMethodObject), - 0, - (destructor)instancemethod_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)instancemethod_compare, /* tp_compare */ - (reprfunc)instancemethod_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)instancemethod_hash, /* tp_hash */ - instancemethod_call, /* tp_call */ - 0, /* tp_str */ - (getattrofunc)instancemethod_getattro, /* tp_getattro */ - PyObject_GenericSetAttr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - instancemethod_doc, /* tp_doc */ - (traverseproc)instancemethod_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - offsetof(PyMethodObject, im_weakreflist), /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - instancemethod_memberlist, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - instancemethod_descr_get, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - instancemethod_new, /* tp_new */ -}; - -/* Clear out the free list */ - -void -PyMethod_Fini(void) -{ - while (free_list) { - PyMethodObject *im = free_list; - free_list = (PyMethodObject *)(im->im_self); - PyObject_GC_Del(im); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/cobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/cobject.c deleted file mode 100644 index 6e066722..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/cobject.c +++ /dev/null @@ -1,146 +0,0 @@ - -/* Wrap void* pointers to be passed between C modules */ - -#include "Python.h" - - -/* Declarations for objects of type PyCObject */ - -typedef void (*destructor1)(void *); -typedef void (*destructor2)(void *, void*); - -typedef struct { - PyObject_HEAD - void *cobject; - void *desc; - void (*destructor)(void *); -} PyCObject; - -PyObject * -PyCObject_FromVoidPtr(void *cobj, void (*destr)(void *)) -{ - PyCObject *self; - - self = PyObject_NEW(PyCObject, &PyCObject_Type); - if (self == NULL) - return NULL; - self->cobject=cobj; - self->destructor=destr; - self->desc=NULL; - - return (PyObject *)self; -} - -PyObject * -PyCObject_FromVoidPtrAndDesc(void *cobj, void *desc, - void (*destr)(void *, void *)) -{ - PyCObject *self; - - if (!desc) { - PyErr_SetString(PyExc_TypeError, - "PyCObject_FromVoidPtrAndDesc called with null" - " description"); - return NULL; - } - self = PyObject_NEW(PyCObject, &PyCObject_Type); - if (self == NULL) - return NULL; - self->cobject = cobj; - self->destructor = (destructor1)destr; - self->desc = desc; - - return (PyObject *)self; -} - -void * -PyCObject_AsVoidPtr(PyObject *self) -{ - if (self) { - if (self->ob_type == &PyCObject_Type) - return ((PyCObject *)self)->cobject; - PyErr_SetString(PyExc_TypeError, - "PyCObject_AsVoidPtr with non-C-object"); - } - if (!PyErr_Occurred()) - PyErr_SetString(PyExc_TypeError, - "PyCObject_AsVoidPtr called with null pointer"); - return NULL; -} - -void * -PyCObject_GetDesc(PyObject *self) -{ - if (self) { - if (self->ob_type == &PyCObject_Type) - return ((PyCObject *)self)->desc; - PyErr_SetString(PyExc_TypeError, - "PyCObject_GetDesc with non-C-object"); - } - if (!PyErr_Occurred()) - PyErr_SetString(PyExc_TypeError, - "PyCObject_GetDesc called with null pointer"); - return NULL; -} - -void * -PyCObject_Import(char *module_name, char *name) -{ - PyObject *m, *c; - void *r = NULL; - - if ((m = PyImport_ImportModule(module_name))) { - if ((c = PyObject_GetAttrString(m,name))) { - r = PyCObject_AsVoidPtr(c); - Py_DECREF(c); - } - Py_DECREF(m); - } - return r; -} - -static void -PyCObject_dealloc(PyCObject *self) -{ - if (self->destructor) { - if(self->desc) - ((destructor2)(self->destructor))(self->cobject, self->desc); - else - (self->destructor)(self->cobject); - } - PyObject_DEL(self); -} - - -PyDoc_STRVAR(PyCObject_Type__doc__, -"C objects to be exported from one extension module to another\n\ -\n\ -C objects are used for communication between extension modules. They\n\ -provide a way for an extension module to export a C interface to other\n\ -extension modules, so that extension modules can use the Python import\n\ -mechanism to link to one another."); - -PyTypeObject PyCObject_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - "PyCObject", /*tp_name*/ - sizeof(PyCObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)PyCObject_dealloc, /*tp_dealloc*/ - (printfunc)0, /*tp_print*/ - (getattrfunc)0, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ - (reprfunc)0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)0, /*tp_str*/ - - /* Space for future expansion */ - 0L,0L,0L,0L, - PyCObject_Type__doc__ /* Documentation string */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/complexobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/complexobject.c deleted file mode 100644 index 35f36b99..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/complexobject.c +++ /dev/null @@ -1,1022 +0,0 @@ - -/* Complex object implementation */ - -/* Borrows heavily from floatobject.c */ - -/* Submitted by Jim Hugunin */ - -#include "Python.h" -#include "structmember.h" - -#ifndef WITHOUT_COMPLEX - -/* Precisions used by repr() and str(), respectively. - - The repr() precision (17 significant decimal digits) is the minimal number - that is guaranteed to have enough precision so that if the number is read - back in the exact same binary value is recreated. This is true for IEEE - floating point by design, and also happens to work for all other modern - hardware. - - The str() precision is chosen so that in most cases, the rounding noise - created by various operations is suppressed, while giving plenty of - precision for practical use. -*/ - -#define PREC_REPR 17 -#define PREC_STR 12 - -/* elementary operations on complex numbers */ - -static Py_complex c_1 = {1., 0.}; - -Py_complex -c_sum(Py_complex a, Py_complex b) -{ - Py_complex r; - r.real = a.real + b.real; - r.imag = a.imag + b.imag; - return r; -} - -Py_complex -c_diff(Py_complex a, Py_complex b) -{ - Py_complex r; - r.real = a.real - b.real; - r.imag = a.imag - b.imag; - return r; -} - -Py_complex -c_neg(Py_complex a) -{ - Py_complex r; - r.real = -a.real; - r.imag = -a.imag; - return r; -} - -Py_complex -c_prod(Py_complex a, Py_complex b) -{ - Py_complex r; - r.real = a.real*b.real - a.imag*b.imag; - r.imag = a.real*b.imag + a.imag*b.real; - return r; -} - -Py_complex -c_quot(Py_complex a, Py_complex b) -{ - /****************************************************************** - This was the original algorithm. It's grossly prone to spurious - overflow and underflow errors. It also merrily divides by 0 despite - checking for that(!). The code still serves a doc purpose here, as - the algorithm following is a simple by-cases transformation of this - one: - - Py_complex r; - double d = b.real*b.real + b.imag*b.imag; - if (d == 0.) - errno = EDOM; - r.real = (a.real*b.real + a.imag*b.imag)/d; - r.imag = (a.imag*b.real - a.real*b.imag)/d; - return r; - ******************************************************************/ - - /* This algorithm is better, and is pretty obvious: first divide the - * numerators and denominator by whichever of {b.real, b.imag} has - * larger magnitude. The earliest reference I found was to CACM - * Algorithm 116 (Complex Division, Robert L. Smith, Stanford - * University). As usual, though, we're still ignoring all IEEE - * endcases. - */ - Py_complex r; /* the result */ - const double abs_breal = b.real < 0 ? -b.real : b.real; - const double abs_bimag = b.imag < 0 ? -b.imag : b.imag; - - if (abs_breal >= abs_bimag) { - /* divide tops and bottom by b.real */ - if (abs_breal == 0.0) { - errno = EDOM; - r.real = r.imag = 0.0; - } - else { - const double ratio = b.imag / b.real; - const double denom = b.real + b.imag * ratio; - r.real = (a.real + a.imag * ratio) / denom; - r.imag = (a.imag - a.real * ratio) / denom; - } - } - else { - /* divide tops and bottom by b.imag */ - const double ratio = b.real / b.imag; - const double denom = b.real * ratio + b.imag; - assert(b.imag != 0.0); - r.real = (a.real * ratio + a.imag) / denom; - r.imag = (a.imag * ratio - a.real) / denom; - } - return r; -} - -Py_complex -c_pow(Py_complex a, Py_complex b) -{ - Py_complex r; - double vabs,len,at,phase; - if (b.real == 0. && b.imag == 0.) { - r.real = 1.; - r.imag = 0.; - } - else if (a.real == 0. && a.imag == 0.) { - if (b.imag != 0. || b.real < 0.) - errno = EDOM; - r.real = 0.; - r.imag = 0.; - } - else { - vabs = hypot(a.real,a.imag); - len = pow(vabs,b.real); - at = atan2(a.imag, a.real); - phase = at*b.real; - if (b.imag != 0.0) { - len /= exp(at*b.imag); - phase += b.imag*log(vabs); - } - r.real = len*cos(phase); - r.imag = len*sin(phase); - } - return r; -} - -static Py_complex -c_powu(Py_complex x, long n) -{ - Py_complex r, p; - long mask = 1; - r = c_1; - p = x; - while (mask > 0 && n >= mask) { - if (n & mask) - r = c_prod(r,p); - mask <<= 1; - p = c_prod(p,p); - } - return r; -} - -static Py_complex -c_powi(Py_complex x, long n) -{ - Py_complex cn; - - if (n > 100 || n < -100) { - cn.real = (double) n; - cn.imag = 0.; - return c_pow(x,cn); - } - else if (n > 0) - return c_powu(x,n); - else - return c_quot(c_1,c_powu(x,-n)); - -} - -static PyObject * -complex_subtype_from_c_complex(PyTypeObject *type, Py_complex cval) -{ - PyObject *op; - - op = PyType_GenericAlloc(type, 0); - if (op != NULL) - ((PyComplexObject *)op)->cval = cval; - return op; -} - -PyObject * -PyComplex_FromCComplex(Py_complex cval) -{ - register PyComplexObject *op; - - /* Inline PyObject_New */ - op = (PyComplexObject *) PyObject_MALLOC(sizeof(PyComplexObject)); - if (op == NULL) - return PyErr_NoMemory(); - PyObject_INIT(op, &PyComplex_Type); - op->cval = cval; - return (PyObject *) op; -} - -static PyObject * -complex_subtype_from_doubles(PyTypeObject *type, double real, double imag) -{ - Py_complex c; - c.real = real; - c.imag = imag; - return complex_subtype_from_c_complex(type, c); -} - -PyObject * -PyComplex_FromDoubles(double real, double imag) -{ - Py_complex c; - c.real = real; - c.imag = imag; - return PyComplex_FromCComplex(c); -} - -double -PyComplex_RealAsDouble(PyObject *op) -{ - if (PyComplex_Check(op)) { - return ((PyComplexObject *)op)->cval.real; - } - else { - return PyFloat_AsDouble(op); - } -} - -double -PyComplex_ImagAsDouble(PyObject *op) -{ - if (PyComplex_Check(op)) { - return ((PyComplexObject *)op)->cval.imag; - } - else { - return 0.0; - } -} - -Py_complex -PyComplex_AsCComplex(PyObject *op) -{ - Py_complex cv; - if (PyComplex_Check(op)) { - return ((PyComplexObject *)op)->cval; - } - else { - cv.real = PyFloat_AsDouble(op); - cv.imag = 0.; - return cv; - } -} - -static void -complex_dealloc(PyObject *op) -{ - op->ob_type->tp_free(op); -} - - -static void -complex_to_buf(char *buf, int bufsz, PyComplexObject *v, int precision) -{ - if (v->cval.real == 0.) - PyOS_snprintf(buf, bufsz, "%.*gj", - precision, v->cval.imag); - else - PyOS_snprintf(buf, bufsz, "(%.*g%+.*gj)", - precision, v->cval.real, - precision, v->cval.imag); -} - -static int -complex_print(PyComplexObject *v, FILE *fp, int flags) -{ - char buf[100]; - complex_to_buf(buf, sizeof(buf), v, - (flags & Py_PRINT_RAW) ? PREC_STR : PREC_REPR); - fputs(buf, fp); - return 0; -} - -static PyObject * -complex_repr(PyComplexObject *v) -{ - char buf[100]; - complex_to_buf(buf, sizeof(buf), v, PREC_REPR); - return PyString_FromString(buf); -} - -static PyObject * -complex_str(PyComplexObject *v) -{ - char buf[100]; - complex_to_buf(buf, sizeof(buf), v, PREC_STR); - return PyString_FromString(buf); -} - -static long -complex_hash(PyComplexObject *v) -{ - long hashreal, hashimag, combined; - hashreal = _Py_HashDouble(v->cval.real); - if (hashreal == -1) - return -1; - hashimag = _Py_HashDouble(v->cval.imag); - if (hashimag == -1) - return -1; - /* Note: if the imaginary part is 0, hashimag is 0 now, - * so the following returns hashreal unchanged. This is - * important because numbers of different types that - * compare equal must have the same hash value, so that - * hash(x + 0*j) must equal hash(x). - */ - combined = hashreal + 1000003 * hashimag; - if (combined == -1) - combined = -2; - return combined; -} - -static PyObject * -complex_add(PyComplexObject *v, PyComplexObject *w) -{ - Py_complex result; - PyFPE_START_PROTECT("complex_add", return 0) - result = c_sum(v->cval,w->cval); - PyFPE_END_PROTECT(result) - return PyComplex_FromCComplex(result); -} - -static PyObject * -complex_sub(PyComplexObject *v, PyComplexObject *w) -{ - Py_complex result; - PyFPE_START_PROTECT("complex_sub", return 0) - result = c_diff(v->cval,w->cval); - PyFPE_END_PROTECT(result) - return PyComplex_FromCComplex(result); -} - -static PyObject * -complex_mul(PyComplexObject *v, PyComplexObject *w) -{ - Py_complex result; - PyFPE_START_PROTECT("complex_mul", return 0) - result = c_prod(v->cval,w->cval); - PyFPE_END_PROTECT(result) - return PyComplex_FromCComplex(result); -} - -static PyObject * -complex_div(PyComplexObject *v, PyComplexObject *w) -{ - Py_complex quot; - PyFPE_START_PROTECT("complex_div", return 0) - errno = 0; - quot = c_quot(v->cval,w->cval); - PyFPE_END_PROTECT(quot) - if (errno == EDOM) { - PyErr_SetString(PyExc_ZeroDivisionError, "complex division"); - return NULL; - } - return PyComplex_FromCComplex(quot); -} - -static PyObject * -complex_classic_div(PyComplexObject *v, PyComplexObject *w) -{ - Py_complex quot; - - if (Py_DivisionWarningFlag >= 2 && - PyErr_Warn(PyExc_DeprecationWarning, - "classic complex division") < 0) - return NULL; - - PyFPE_START_PROTECT("complex_classic_div", return 0) - errno = 0; - quot = c_quot(v->cval,w->cval); - PyFPE_END_PROTECT(quot) - if (errno == EDOM) { - PyErr_SetString(PyExc_ZeroDivisionError, "complex division"); - return NULL; - } - return PyComplex_FromCComplex(quot); -} - -static PyObject * -complex_remainder(PyComplexObject *v, PyComplexObject *w) -{ - Py_complex div, mod; - - if (PyErr_Warn(PyExc_DeprecationWarning, - "complex divmod(), // and % are deprecated") < 0) - return NULL; - - errno = 0; - div = c_quot(v->cval,w->cval); /* The raw divisor value. */ - if (errno == EDOM) { - PyErr_SetString(PyExc_ZeroDivisionError, "complex remainder"); - return NULL; - } - div.real = floor(div.real); /* Use the floor of the real part. */ - div.imag = 0.0; - mod = c_diff(v->cval, c_prod(w->cval, div)); - - return PyComplex_FromCComplex(mod); -} - - -static PyObject * -complex_divmod(PyComplexObject *v, PyComplexObject *w) -{ - Py_complex div, mod; - PyObject *d, *m, *z; - - if (PyErr_Warn(PyExc_DeprecationWarning, - "complex divmod(), // and % are deprecated") < 0) - return NULL; - - errno = 0; - div = c_quot(v->cval,w->cval); /* The raw divisor value. */ - if (errno == EDOM) { - PyErr_SetString(PyExc_ZeroDivisionError, "complex divmod()"); - return NULL; - } - div.real = floor(div.real); /* Use the floor of the real part. */ - div.imag = 0.0; - mod = c_diff(v->cval, c_prod(w->cval, div)); - d = PyComplex_FromCComplex(div); - m = PyComplex_FromCComplex(mod); - z = Py_BuildValue("(OO)", d, m); - Py_XDECREF(d); - Py_XDECREF(m); - return z; -} - -static PyObject * -complex_pow(PyComplexObject *v, PyObject *w, PyComplexObject *z) -{ - Py_complex p; - Py_complex exponent; - long int_exponent; - - if ((PyObject *)z!=Py_None) { - PyErr_SetString(PyExc_ValueError, "complex modulo"); - return NULL; - } - PyFPE_START_PROTECT("complex_pow", return 0) - errno = 0; - exponent = ((PyComplexObject*)w)->cval; - int_exponent = (long)exponent.real; - if (exponent.imag == 0. && exponent.real == int_exponent) - p = c_powi(v->cval,int_exponent); - else - p = c_pow(v->cval,exponent); - - PyFPE_END_PROTECT(p) - Py_ADJUST_ERANGE2(p.real, p.imag); - if (errno == EDOM) { - PyErr_SetString(PyExc_ZeroDivisionError, - "0.0 to a negative or complex power"); - return NULL; - } - else if (errno == ERANGE) { - PyErr_SetString(PyExc_OverflowError, - "complex exponentiaion"); - return NULL; - } - return PyComplex_FromCComplex(p); -} - -static PyObject * -complex_int_div(PyComplexObject *v, PyComplexObject *w) -{ - PyObject *t, *r; - - t = complex_divmod(v, w); - if (t != NULL) { - r = PyTuple_GET_ITEM(t, 0); - Py_INCREF(r); - Py_DECREF(t); - return r; - } - return NULL; -} - -static PyObject * -complex_neg(PyComplexObject *v) -{ - Py_complex neg; - neg.real = -v->cval.real; - neg.imag = -v->cval.imag; - return PyComplex_FromCComplex(neg); -} - -static PyObject * -complex_pos(PyComplexObject *v) -{ - if (PyComplex_CheckExact(v)) { - Py_INCREF(v); - return (PyObject *)v; - } - else - return PyComplex_FromCComplex(v->cval); -} - -static PyObject * -complex_abs(PyComplexObject *v) -{ - double result; - PyFPE_START_PROTECT("complex_abs", return 0) - result = hypot(v->cval.real,v->cval.imag); - PyFPE_END_PROTECT(result) - return PyFloat_FromDouble(result); -} - -static int -complex_nonzero(PyComplexObject *v) -{ - return v->cval.real != 0.0 || v->cval.imag != 0.0; -} - -static int -complex_coerce(PyObject **pv, PyObject **pw) -{ - Py_complex cval; - cval.imag = 0.; - if (PyInt_Check(*pw)) { - cval.real = (double)PyInt_AsLong(*pw); - *pw = PyComplex_FromCComplex(cval); - Py_INCREF(*pv); - return 0; - } - else if (PyLong_Check(*pw)) { - cval.real = PyLong_AsDouble(*pw); - if (cval.real == -1.0 && PyErr_Occurred()) - return -1; - *pw = PyComplex_FromCComplex(cval); - Py_INCREF(*pv); - return 0; - } - else if (PyFloat_Check(*pw)) { - cval.real = PyFloat_AsDouble(*pw); - *pw = PyComplex_FromCComplex(cval); - Py_INCREF(*pv); - return 0; - } - else if (PyComplex_Check(*pw)) { - Py_INCREF(*pv); - Py_INCREF(*pw); - return 0; - } - return 1; /* Can't do it */ -} - -static PyObject * -complex_richcompare(PyObject *v, PyObject *w, int op) -{ - int c; - Py_complex i, j; - PyObject *res; - - c = PyNumber_CoerceEx(&v, &w); - if (c < 0) - return NULL; - if (c > 0) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - /* Make sure both arguments are complex. */ - if (!(PyComplex_Check(v) && PyComplex_Check(w))) { - Py_DECREF(v); - Py_DECREF(w); - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - - i = ((PyComplexObject *)v)->cval; - j = ((PyComplexObject *)w)->cval; - Py_DECREF(v); - Py_DECREF(w); - - if (op != Py_EQ && op != Py_NE) { - PyErr_SetString(PyExc_TypeError, - "cannot compare complex numbers using <, <=, >, >="); - return NULL; - } - - if ((i.real == j.real && i.imag == j.imag) == (op == Py_EQ)) - res = Py_True; - else - res = Py_False; - - Py_INCREF(res); - return res; -} - -static PyObject * -complex_int(PyObject *v) -{ - PyErr_SetString(PyExc_TypeError, - "can't convert complex to int; use int(abs(z))"); - return NULL; -} - -static PyObject * -complex_long(PyObject *v) -{ - PyErr_SetString(PyExc_TypeError, - "can't convert complex to long; use long(abs(z))"); - return NULL; -} - -static PyObject * -complex_float(PyObject *v) -{ - PyErr_SetString(PyExc_TypeError, - "can't convert complex to float; use abs(z)"); - return NULL; -} - -static PyObject * -complex_conjugate(PyObject *self) -{ - Py_complex c; - c = ((PyComplexObject *)self)->cval; - c.imag = -c.imag; - return PyComplex_FromCComplex(c); -} - -static PyObject * -complex_getnewargs(PyComplexObject *v) -{ - return Py_BuildValue("(D)", &v->cval); -} - -static PyMethodDef complex_methods[] = { - {"conjugate", (PyCFunction)complex_conjugate, METH_NOARGS}, - {"__getnewargs__", (PyCFunction)complex_getnewargs, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - -static PyMemberDef complex_members[] = { - {"real", T_DOUBLE, offsetof(PyComplexObject, cval.real), READONLY, - "the real part of a complex number"}, - {"imag", T_DOUBLE, offsetof(PyComplexObject, cval.imag), READONLY, - "the imaginary part of a complex number"}, - {0}, -}; - -static PyObject * -complex_subtype_from_string(PyTypeObject *type, PyObject *v) -{ - extern double strtod(const char *, char **); - const char *s, *start; - char *end; - double x=0.0, y=0.0, z; - int got_re=0, got_im=0, done=0; - int digit_or_dot; - int sw_error=0; - int sign; - char buffer[256]; /* For errors */ -#ifdef Py_USING_UNICODE - char s_buffer[256]; -#endif - int len; - - if (PyString_Check(v)) { - s = PyString_AS_STRING(v); - len = PyString_GET_SIZE(v); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(v)) { - if (PyUnicode_GET_SIZE(v) >= sizeof(s_buffer)) { - PyErr_SetString(PyExc_ValueError, - "complex() literal too large to convert"); - return NULL; - } - if (PyUnicode_EncodeDecimal(PyUnicode_AS_UNICODE(v), - PyUnicode_GET_SIZE(v), - s_buffer, - NULL)) - return NULL; - s = s_buffer; - len = (int)strlen(s); - } -#endif - else if (PyObject_AsCharBuffer(v, &s, &len)) { - PyErr_SetString(PyExc_TypeError, - "complex() arg is not a string"); - return NULL; - } - - /* position on first nonblank */ - start = s; - while (*s && isspace(Py_CHARMASK(*s))) - s++; - if (s[0] == '\0') { - PyErr_SetString(PyExc_ValueError, - "complex() arg is an empty string"); - return NULL; - } - - z = -1.0; - sign = 1; - do { - - switch (*s) { - - case '\0': - if (s-start != len) { - PyErr_SetString( - PyExc_ValueError, - "complex() arg contains a null byte"); - return NULL; - } - if(!done) sw_error=1; - break; - - case '-': - sign = -1; - /* Fallthrough */ - case '+': - if (done) sw_error=1; - s++; - if ( *s=='\0'||*s=='+'||*s=='-' || - isspace(Py_CHARMASK(*s)) ) sw_error=1; - break; - - case 'J': - case 'j': - if (got_im || done) { - sw_error = 1; - break; - } - if (z<0.0) { - y=sign; - } - else{ - y=sign*z; - } - got_im=1; - s++; - if (*s!='+' && *s!='-' ) - done=1; - break; - - default: - if (isspace(Py_CHARMASK(*s))) { - while (*s && isspace(Py_CHARMASK(*s))) - s++; - if (s[0] != '\0') - sw_error=1; - else - done = 1; - break; - } - digit_or_dot = - (*s=='.' || isdigit(Py_CHARMASK(*s))); - if (done||!digit_or_dot) { - sw_error=1; - break; - } - errno = 0; - PyFPE_START_PROTECT("strtod", return 0) - z = strtod(s, &end) ; - PyFPE_END_PROTECT(z) - if (errno != 0) { - PyOS_snprintf(buffer, sizeof(buffer), - "float() out of range: %.150s", s); - PyErr_SetString( - PyExc_ValueError, - buffer); - return NULL; - } - s=end; - if (*s=='J' || *s=='j') { - - break; - } - if (got_re) { - sw_error=1; - break; - } - - /* accept a real part */ - x=sign*z; - got_re=1; - if (got_im) done=1; - z = -1.0; - sign = 1; - break; - - } /* end of switch */ - - } while (s - start < len && !sw_error); - - if (sw_error) { - PyErr_SetString(PyExc_ValueError, - "complex() arg is a malformed string"); - return NULL; - } - - return complex_subtype_from_doubles(type, x, y); -} - -static PyObject * -complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *r, *i, *tmp, *f; - PyNumberMethods *nbr, *nbi = NULL; - Py_complex cr, ci; - int own_r = 0; - static PyObject *complexstr; - static char *kwlist[] = {"real", "imag", 0}; - - r = Py_False; - i = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:complex", kwlist, - &r, &i)) - return NULL; - - /* Special-case for single argument that is already complex */ - if (PyComplex_CheckExact(r) && i == NULL && - type == &PyComplex_Type) { - /* Note that we can't know whether it's safe to return - a complex *subclass* instance as-is, hence the restriction - to exact complexes here. */ - Py_INCREF(r); - return r; - } - if (PyString_Check(r) || PyUnicode_Check(r)) { - if (i != NULL) { - PyErr_SetString(PyExc_TypeError, - "complex() can't take second arg" - " if first is a string"); - return NULL; - } - return complex_subtype_from_string(type, r); - } - if (i != NULL && (PyString_Check(i) || PyUnicode_Check(i))) { - PyErr_SetString(PyExc_TypeError, - "complex() second arg can't be a string"); - return NULL; - } - - /* XXX Hack to support classes with __complex__ method */ - if (complexstr == NULL) { - complexstr = PyString_InternFromString("__complex__"); - if (complexstr == NULL) - return NULL; - } - f = PyObject_GetAttr(r, complexstr); - if (f == NULL) - PyErr_Clear(); - else { - PyObject *args = Py_BuildValue("()"); - if (args == NULL) - return NULL; - r = PyEval_CallObject(f, args); - Py_DECREF(args); - Py_DECREF(f); - if (r == NULL) - return NULL; - own_r = 1; - } - nbr = r->ob_type->tp_as_number; - if (i != NULL) - nbi = i->ob_type->tp_as_number; - if (nbr == NULL || nbr->nb_float == NULL || - ((i != NULL) && (nbi == NULL || nbi->nb_float == NULL))) { - PyErr_SetString(PyExc_TypeError, - "complex() argument must be a string or a number"); - return NULL; - } - if (PyComplex_Check(r)) { - /* Note that if r is of a complex subtype, we're only - retaining its real & imag parts here, and the return - value is (properly) of the builtin complex type. */ - cr = ((PyComplexObject*)r)->cval; - if (own_r) { - Py_DECREF(r); - } - } - else { - tmp = PyNumber_Float(r); - if (own_r) { - Py_DECREF(r); - } - if (tmp == NULL) - return NULL; - if (!PyFloat_Check(tmp)) { - PyErr_SetString(PyExc_TypeError, - "float(r) didn't return a float"); - Py_DECREF(tmp); - return NULL; - } - cr.real = PyFloat_AsDouble(tmp); - Py_DECREF(tmp); - cr.imag = 0.0; - } - if (i == NULL) { - ci.real = 0.0; - ci.imag = 0.0; - } - else if (PyComplex_Check(i)) - ci = ((PyComplexObject*)i)->cval; - else { - tmp = (*nbi->nb_float)(i); - if (tmp == NULL) - return NULL; - ci.real = PyFloat_AsDouble(tmp); - Py_DECREF(tmp); - ci.imag = 0.; - } - cr.real -= ci.imag; - cr.imag += ci.real; - return complex_subtype_from_c_complex(type, cr); -} - -PyDoc_STRVAR(complex_doc, -"complex(real[, imag]) -> complex number\n" -"\n" -"Create a complex number from a real part and an optional imaginary part.\n" -"This is equivalent to (real + imag*1j) where imag defaults to 0."); - -static PyNumberMethods complex_as_number = { - (binaryfunc)complex_add, /* nb_add */ - (binaryfunc)complex_sub, /* nb_subtract */ - (binaryfunc)complex_mul, /* nb_multiply */ - (binaryfunc)complex_classic_div, /* nb_divide */ - (binaryfunc)complex_remainder, /* nb_remainder */ - (binaryfunc)complex_divmod, /* nb_divmod */ - (ternaryfunc)complex_pow, /* nb_power */ - (unaryfunc)complex_neg, /* nb_negative */ - (unaryfunc)complex_pos, /* nb_positive */ - (unaryfunc)complex_abs, /* nb_absolute */ - (inquiry)complex_nonzero, /* nb_nonzero */ - 0, /* nb_invert */ - 0, /* nb_lshift */ - 0, /* nb_rshift */ - 0, /* nb_and */ - 0, /* nb_xor */ - 0, /* nb_or */ - (coercion)complex_coerce, /* nb_coerce */ - (unaryfunc)complex_int, /* nb_int */ - (unaryfunc)complex_long, /* nb_long */ - (unaryfunc)complex_float, /* nb_float */ - 0, /* nb_oct */ - 0, /* nb_hex */ - 0, /* nb_inplace_add */ - 0, /* nb_inplace_subtract */ - 0, /* nb_inplace_multiply*/ - 0, /* nb_inplace_divide */ - 0, /* nb_inplace_remainder */ - 0, /* nb_inplace_power */ - 0, /* nb_inplace_lshift */ - 0, /* nb_inplace_rshift */ - 0, /* nb_inplace_and */ - 0, /* nb_inplace_xor */ - 0, /* nb_inplace_or */ - (binaryfunc)complex_int_div, /* nb_floor_divide */ - (binaryfunc)complex_div, /* nb_true_divide */ - 0, /* nb_inplace_floor_divide */ - 0, /* nb_inplace_true_divide */ -}; - -PyTypeObject PyComplex_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "complex", - sizeof(PyComplexObject), - 0, - (destructor)complex_dealloc, /* tp_dealloc */ - (printfunc)complex_print, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)complex_repr, /* tp_repr */ - &complex_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)complex_hash, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)complex_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - complex_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - complex_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - complex_methods, /* tp_methods */ - complex_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - complex_new, /* tp_new */ - PyObject_Del, /* tp_free */ -}; - -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/descrobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/descrobject.c deleted file mode 100644 index cf0ec0d2..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/descrobject.c +++ /dev/null @@ -1,1255 +0,0 @@ -/* Descriptors -- a new, flexible way to describe attributes */ - -#include "Python.h" -#include "structmember.h" /* Why is this not included in Python.h? */ - -static void -descr_dealloc(PyDescrObject *descr) -{ - _PyObject_GC_UNTRACK(descr); - Py_XDECREF(descr->d_type); - Py_XDECREF(descr->d_name); - PyObject_GC_Del(descr); -} - -static char * -descr_name(PyDescrObject *descr) -{ - if (descr->d_name != NULL && PyString_Check(descr->d_name)) - return PyString_AS_STRING(descr->d_name); - else - return "?"; -} - -static PyObject * -descr_repr(PyDescrObject *descr, char *format) -{ - return PyString_FromFormat(format, descr_name(descr), - descr->d_type->tp_name); -} - -static PyObject * -method_repr(PyMethodDescrObject *descr) -{ - return descr_repr((PyDescrObject *)descr, - ""); -} - -static PyObject * -member_repr(PyMemberDescrObject *descr) -{ - return descr_repr((PyDescrObject *)descr, - ""); -} - -static PyObject * -getset_repr(PyGetSetDescrObject *descr) -{ - return descr_repr((PyDescrObject *)descr, - ""); -} - -static PyObject * -wrapper_repr(PyWrapperDescrObject *descr) -{ - return descr_repr((PyDescrObject *)descr, - ""); -} - -static int -descr_check(PyDescrObject *descr, PyObject *obj, PyObject **pres) -{ - if (obj == NULL) { - Py_INCREF(descr); - *pres = (PyObject *)descr; - return 1; - } - if (!PyObject_TypeCheck(obj, descr->d_type)) { - PyErr_Format(PyExc_TypeError, - "descriptor '%s' for '%s' objects " - "doesn't apply to '%s' object", - descr_name((PyDescrObject *)descr), - descr->d_type->tp_name, - obj->ob_type->tp_name); - *pres = NULL; - return 1; - } - return 0; -} - -static PyObject * -classmethod_get(PyMethodDescrObject *descr, PyObject *obj, PyObject *type) -{ - /* Ensure a valid type. Class methods ignore obj. */ - if (type == NULL) { - if (obj != NULL) - type = (PyObject *)obj->ob_type; - else { - /* Wot - no type?! */ - PyErr_Format(PyExc_TypeError, - "descriptor '%s' for type '%s' " - "needs either an object or a type", - descr_name((PyDescrObject *)descr), - descr->d_type->tp_name); - return NULL; - } - } - if (!PyType_Check(type)) { - PyErr_Format(PyExc_TypeError, - "descriptor '%s' for type '%s' " - "needs a type, not a '%s' as arg 2", - descr_name((PyDescrObject *)descr), - descr->d_type->tp_name, - type->ob_type->tp_name); - return NULL; - } - if (!PyType_IsSubtype((PyTypeObject *)type, descr->d_type)) { - PyErr_Format(PyExc_TypeError, - "descriptor '%s' for type '%s' " - "doesn't apply to type '%s'", - descr_name((PyDescrObject *)descr), - descr->d_type->tp_name, - ((PyTypeObject *)type)->tp_name); - return NULL; - } - return PyCFunction_New(descr->d_method, type); -} - -static PyObject * -method_get(PyMethodDescrObject *descr, PyObject *obj, PyObject *type) -{ - PyObject *res; - - if (descr_check((PyDescrObject *)descr, obj, &res)) - return res; - return PyCFunction_New(descr->d_method, obj); -} - -static PyObject * -member_get(PyMemberDescrObject *descr, PyObject *obj, PyObject *type) -{ - PyObject *res; - - if (descr_check((PyDescrObject *)descr, obj, &res)) - return res; - return PyMember_GetOne((char *)obj, descr->d_member); -} - -static PyObject * -getset_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *type) -{ - PyObject *res; - - if (descr_check((PyDescrObject *)descr, obj, &res)) - return res; - if (descr->d_getset->get != NULL) - return descr->d_getset->get(obj, descr->d_getset->closure); - PyErr_Format(PyExc_TypeError, - "attribute '%.300s' of '%.100s' objects is not readable", - descr_name((PyDescrObject *)descr), - descr->d_type->tp_name); - return NULL; -} - -static PyObject * -wrapper_get(PyWrapperDescrObject *descr, PyObject *obj, PyObject *type) -{ - PyObject *res; - - if (descr_check((PyDescrObject *)descr, obj, &res)) - return res; - return PyWrapper_New((PyObject *)descr, obj); -} - -static int -descr_setcheck(PyDescrObject *descr, PyObject *obj, PyObject *value, - int *pres) -{ - assert(obj != NULL); - if (!PyObject_IsInstance(obj, (PyObject *)(descr->d_type))) { - PyErr_Format(PyExc_TypeError, - "descriptor '%.200s' for '%.100s' objects " - "doesn't apply to '%.100s' object", - descr_name(descr), - descr->d_type->tp_name, - obj->ob_type->tp_name); - *pres = -1; - return 1; - } - return 0; -} - -static int -member_set(PyMemberDescrObject *descr, PyObject *obj, PyObject *value) -{ - int res; - - if (descr_setcheck((PyDescrObject *)descr, obj, value, &res)) - return res; - return PyMember_SetOne((char *)obj, descr->d_member, value); -} - -static int -getset_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value) -{ - int res; - - if (descr_setcheck((PyDescrObject *)descr, obj, value, &res)) - return res; - if (descr->d_getset->set != NULL) - return descr->d_getset->set(obj, value, - descr->d_getset->closure); - PyErr_Format(PyExc_TypeError, - "attribute '%.300s' of '%.100s' objects is not writable", - descr_name((PyDescrObject *)descr), - descr->d_type->tp_name); - return -1; -} - -static PyObject * -methoddescr_call(PyMethodDescrObject *descr, PyObject *args, PyObject *kwds) -{ - int argc; - PyObject *self, *func, *result; - - /* Make sure that the first argument is acceptable as 'self' */ - assert(PyTuple_Check(args)); - argc = PyTuple_GET_SIZE(args); - if (argc < 1) { - PyErr_Format(PyExc_TypeError, - "descriptor '%.300s' of '%.100s' " - "object needs an argument", - descr_name((PyDescrObject *)descr), - descr->d_type->tp_name); - return NULL; - } - self = PyTuple_GET_ITEM(args, 0); - if (!PyObject_IsInstance(self, (PyObject *)(descr->d_type))) { - PyErr_Format(PyExc_TypeError, - "descriptor '%.200s' " - "requires a '%.100s' object " - "but received a '%.100s'", - descr_name((PyDescrObject *)descr), - descr->d_type->tp_name, - self->ob_type->tp_name); - return NULL; - } - - func = PyCFunction_New(descr->d_method, self); - if (func == NULL) - return NULL; - args = PyTuple_GetSlice(args, 1, argc); - if (args == NULL) { - Py_DECREF(func); - return NULL; - } - result = PyEval_CallObjectWithKeywords(func, args, kwds); - Py_DECREF(args); - Py_DECREF(func); - return result; -} - -static PyObject * -classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args, - PyObject *kwds) -{ - PyObject *func, *result; - - func = PyCFunction_New(descr->d_method, (PyObject *)descr->d_type); - if (func == NULL) - return NULL; - - result = PyEval_CallObjectWithKeywords(func, args, kwds); - Py_DECREF(func); - return result; -} - -static PyObject * -wrapperdescr_call(PyWrapperDescrObject *descr, PyObject *args, PyObject *kwds) -{ - int argc; - PyObject *self, *func, *result; - - /* Make sure that the first argument is acceptable as 'self' */ - assert(PyTuple_Check(args)); - argc = PyTuple_GET_SIZE(args); - if (argc < 1) { - PyErr_Format(PyExc_TypeError, - "descriptor '%.300s' of '%.100s' " - "object needs an argument", - descr_name((PyDescrObject *)descr), - descr->d_type->tp_name); - return NULL; - } - self = PyTuple_GET_ITEM(args, 0); - if (!PyObject_IsInstance(self, (PyObject *)(descr->d_type))) { - PyErr_Format(PyExc_TypeError, - "descriptor '%.200s' " - "requires a '%.100s' object " - "but received a '%.100s'", - descr_name((PyDescrObject *)descr), - descr->d_type->tp_name, - self->ob_type->tp_name); - return NULL; - } - - func = PyWrapper_New((PyObject *)descr, self); - if (func == NULL) - return NULL; - args = PyTuple_GetSlice(args, 1, argc); - if (args == NULL) { - Py_DECREF(func); - return NULL; - } - result = PyEval_CallObjectWithKeywords(func, args, kwds); - Py_DECREF(args); - Py_DECREF(func); - return result; -} - -static PyObject * -method_get_doc(PyMethodDescrObject *descr, void *closure) -{ - if (descr->d_method->ml_doc == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyString_FromString(descr->d_method->ml_doc); -} - -static PyMemberDef descr_members[] = { - {"__objclass__", T_OBJECT, offsetof(PyDescrObject, d_type), READONLY}, - {"__name__", T_OBJECT, offsetof(PyDescrObject, d_name), READONLY}, - {0} -}; - -static PyGetSetDef method_getset[] = { - {"__doc__", (getter)method_get_doc}, - {0} -}; - -static PyObject * -member_get_doc(PyMemberDescrObject *descr, void *closure) -{ - if (descr->d_member->doc == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyString_FromString(descr->d_member->doc); -} - -static PyGetSetDef member_getset[] = { - {"__doc__", (getter)member_get_doc}, - {0} -}; - -static PyObject * -getset_get_doc(PyGetSetDescrObject *descr, void *closure) -{ - if (descr->d_getset->doc == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyString_FromString(descr->d_getset->doc); -} - -static PyGetSetDef getset_getset[] = { - {"__doc__", (getter)getset_get_doc}, - {0} -}; - -static PyObject * -wrapper_get_doc(PyWrapperDescrObject *descr, void *closure) -{ - if (descr->d_base->doc == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyString_FromString(descr->d_base->doc); -} - -static PyGetSetDef wrapper_getset[] = { - {"__doc__", (getter)wrapper_get_doc}, - {0} -}; - -static int -descr_traverse(PyObject *self, visitproc visit, void *arg) -{ - PyDescrObject *descr = (PyDescrObject *)self; - int err; - - if (descr->d_type) { - err = visit((PyObject *)(descr->d_type), arg); - if (err) - return err; - } - return 0; -} - -static PyTypeObject PyMethodDescr_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "method_descriptor", - sizeof(PyMethodDescrObject), - 0, - (destructor)descr_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)method_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - (ternaryfunc)methoddescr_call, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - 0, /* tp_doc */ - descr_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - descr_members, /* tp_members */ - method_getset, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - (descrgetfunc)method_get, /* tp_descr_get */ - 0, /* tp_descr_set */ -}; - -/* This is for METH_CLASS in C, not for "f = classmethod(f)" in Python! */ -static PyTypeObject PyClassMethodDescr_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "classmethod_descriptor", - sizeof(PyMethodDescrObject), - 0, - (destructor)descr_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)method_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - (ternaryfunc)classmethoddescr_call, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - 0, /* tp_doc */ - descr_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - descr_members, /* tp_members */ - method_getset, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - (descrgetfunc)classmethod_get, /* tp_descr_get */ - 0, /* tp_descr_set */ -}; - -static PyTypeObject PyMemberDescr_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "member_descriptor", - sizeof(PyMemberDescrObject), - 0, - (destructor)descr_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)member_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - 0, /* tp_doc */ - descr_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - descr_members, /* tp_members */ - member_getset, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - (descrgetfunc)member_get, /* tp_descr_get */ - (descrsetfunc)member_set, /* tp_descr_set */ -}; - -static PyTypeObject PyGetSetDescr_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "getset_descriptor", - sizeof(PyGetSetDescrObject), - 0, - (destructor)descr_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)getset_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - 0, /* tp_doc */ - descr_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - descr_members, /* tp_members */ - getset_getset, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - (descrgetfunc)getset_get, /* tp_descr_get */ - (descrsetfunc)getset_set, /* tp_descr_set */ -}; - -PyTypeObject PyWrapperDescr_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "wrapper_descriptor", - sizeof(PyWrapperDescrObject), - 0, - (destructor)descr_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)wrapper_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - (ternaryfunc)wrapperdescr_call, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - 0, /* tp_doc */ - descr_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - descr_members, /* tp_members */ - wrapper_getset, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - (descrgetfunc)wrapper_get, /* tp_descr_get */ - 0, /* tp_descr_set */ -}; - -static PyDescrObject * -descr_new(PyTypeObject *descrtype, PyTypeObject *type, char *name) -{ - PyDescrObject *descr; - - descr = (PyDescrObject *)PyType_GenericAlloc(descrtype, 0); - if (descr != NULL) { - Py_XINCREF(type); - descr->d_type = type; - descr->d_name = PyString_InternFromString(name); - if (descr->d_name == NULL) { - Py_DECREF(descr); - descr = NULL; - } - } - return descr; -} - -PyObject * -PyDescr_NewMethod(PyTypeObject *type, PyMethodDef *method) -{ - PyMethodDescrObject *descr; - - descr = (PyMethodDescrObject *)descr_new(&PyMethodDescr_Type, - type, method->ml_name); - if (descr != NULL) - descr->d_method = method; - return (PyObject *)descr; -} - -PyObject * -PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method) -{ - PyMethodDescrObject *descr; - - descr = (PyMethodDescrObject *)descr_new(&PyClassMethodDescr_Type, - type, method->ml_name); - if (descr != NULL) - descr->d_method = method; - return (PyObject *)descr; -} - -PyObject * -PyDescr_NewMember(PyTypeObject *type, PyMemberDef *member) -{ - PyMemberDescrObject *descr; - - descr = (PyMemberDescrObject *)descr_new(&PyMemberDescr_Type, - type, member->name); - if (descr != NULL) - descr->d_member = member; - return (PyObject *)descr; -} - -PyObject * -PyDescr_NewGetSet(PyTypeObject *type, PyGetSetDef *getset) -{ - PyGetSetDescrObject *descr; - - descr = (PyGetSetDescrObject *)descr_new(&PyGetSetDescr_Type, - type, getset->name); - if (descr != NULL) - descr->d_getset = getset; - return (PyObject *)descr; -} - -PyObject * -PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *base, void *wrapped) -{ - PyWrapperDescrObject *descr; - - descr = (PyWrapperDescrObject *)descr_new(&PyWrapperDescr_Type, - type, base->name); - if (descr != NULL) { - descr->d_base = base; - descr->d_wrapped = wrapped; - } - return (PyObject *)descr; -} - - -/* --- Readonly proxy for dictionaries (actually any mapping) --- */ - -/* This has no reason to be in this file except that adding new files is a - bit of a pain */ - -typedef struct { - PyObject_HEAD - PyObject *dict; -} proxyobject; - -static int -proxy_len(proxyobject *pp) -{ - return PyObject_Size(pp->dict); -} - -static PyObject * -proxy_getitem(proxyobject *pp, PyObject *key) -{ - return PyObject_GetItem(pp->dict, key); -} - -static PyMappingMethods proxy_as_mapping = { - (inquiry)proxy_len, /* mp_length */ - (binaryfunc)proxy_getitem, /* mp_subscript */ - 0, /* mp_ass_subscript */ -}; - -static int -proxy_contains(proxyobject *pp, PyObject *key) -{ - return PySequence_Contains(pp->dict, key); -} - -static PySequenceMethods proxy_as_sequence = { - 0, /* sq_length */ - 0, /* sq_concat */ - 0, /* sq_repeat */ - 0, /* sq_item */ - 0, /* sq_slice */ - 0, /* sq_ass_item */ - 0, /* sq_ass_slice */ - (objobjproc)proxy_contains, /* sq_contains */ - 0, /* sq_inplace_concat */ - 0, /* sq_inplace_repeat */ -}; - -static PyObject * -proxy_has_key(proxyobject *pp, PyObject *key) -{ - int res = PySequence_Contains(pp->dict, key); - if (res < 0) - return NULL; - return PyBool_FromLong(res); -} - -static PyObject * -proxy_get(proxyobject *pp, PyObject *args) -{ - PyObject *key, *def = Py_None; - - if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &def)) - return NULL; - return PyObject_CallMethod(pp->dict, "get", "(OO)", key, def); -} - -static PyObject * -proxy_keys(proxyobject *pp) -{ - return PyMapping_Keys(pp->dict); -} - -static PyObject * -proxy_values(proxyobject *pp) -{ - return PyMapping_Values(pp->dict); -} - -static PyObject * -proxy_items(proxyobject *pp) -{ - return PyMapping_Items(pp->dict); -} - -static PyObject * -proxy_iterkeys(proxyobject *pp) -{ - return PyObject_CallMethod(pp->dict, "iterkeys", NULL); -} - -static PyObject * -proxy_itervalues(proxyobject *pp) -{ - return PyObject_CallMethod(pp->dict, "itervalues", NULL); -} - -static PyObject * -proxy_iteritems(proxyobject *pp) -{ - return PyObject_CallMethod(pp->dict, "iteritems", NULL); -} -static PyObject * -proxy_copy(proxyobject *pp) -{ - return PyObject_CallMethod(pp->dict, "copy", NULL); -} - -static PyMethodDef proxy_methods[] = { - {"has_key", (PyCFunction)proxy_has_key, METH_O, - PyDoc_STR("D.has_key(k) -> True if D has a key k, else False")}, - {"get", (PyCFunction)proxy_get, METH_VARARGS, - PyDoc_STR("D.get(k[,d]) -> D[k] if D.has_key(k), else d." - " d defaults to None.")}, - {"keys", (PyCFunction)proxy_keys, METH_NOARGS, - PyDoc_STR("D.keys() -> list of D's keys")}, - {"values", (PyCFunction)proxy_values, METH_NOARGS, - PyDoc_STR("D.values() -> list of D's values")}, - {"items", (PyCFunction)proxy_items, METH_NOARGS, - PyDoc_STR("D.items() -> list of D's (key, value) pairs, as 2-tuples")}, - {"iterkeys", (PyCFunction)proxy_iterkeys, METH_NOARGS, - PyDoc_STR("D.iterkeys() -> an iterator over the keys of D")}, - {"itervalues",(PyCFunction)proxy_itervalues, METH_NOARGS, - PyDoc_STR("D.itervalues() -> an iterator over the values of D")}, - {"iteritems", (PyCFunction)proxy_iteritems, METH_NOARGS, - PyDoc_STR("D.iteritems() ->" - " an iterator over the (key, value) items of D")}, - {"copy", (PyCFunction)proxy_copy, METH_NOARGS, - PyDoc_STR("D.copy() -> a shallow copy of D")}, - {0} -}; - -static void -proxy_dealloc(proxyobject *pp) -{ - _PyObject_GC_UNTRACK(pp); - Py_DECREF(pp->dict); - PyObject_GC_Del(pp); -} - -static PyObject * -proxy_getiter(proxyobject *pp) -{ - return PyObject_GetIter(pp->dict); -} - -static PyObject * -proxy_str(proxyobject *pp) -{ - return PyObject_Str(pp->dict); -} - -static int -proxy_traverse(PyObject *self, visitproc visit, void *arg) -{ - proxyobject *pp = (proxyobject *)self; - int err; - - if (pp->dict) { - err = visit(pp->dict, arg); - if (err) - return err; - } - return 0; -} - -static int -proxy_compare(proxyobject *v, PyObject *w) -{ - return PyObject_Compare(v->dict, w); -} - -static PyObject * -proxy_richcompare(proxyobject *v, PyObject *w, int op) -{ - return PyObject_RichCompare(v->dict, w, op); -} - -static PyTypeObject proxytype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "dictproxy", /* tp_name */ - sizeof(proxyobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)proxy_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)proxy_compare, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - &proxy_as_sequence, /* tp_as_sequence */ - &proxy_as_mapping, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)proxy_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - 0, /* tp_doc */ - proxy_traverse, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)proxy_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc)proxy_getiter, /* tp_iter */ - 0, /* tp_iternext */ - proxy_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -}; - -PyObject * -PyDictProxy_New(PyObject *dict) -{ - proxyobject *pp; - - pp = PyObject_GC_New(proxyobject, &proxytype); - if (pp != NULL) { - Py_INCREF(dict); - pp->dict = dict; - _PyObject_GC_TRACK(pp); - } - return (PyObject *)pp; -} - - -/* --- Wrapper object for "slot" methods --- */ - -/* This has no reason to be in this file except that adding new files is a - bit of a pain */ - -typedef struct { - PyObject_HEAD - PyWrapperDescrObject *descr; - PyObject *self; -} wrapperobject; - -static void -wrapper_dealloc(wrapperobject *wp) -{ - _PyObject_GC_UNTRACK(wp); - Py_XDECREF(wp->descr); - Py_XDECREF(wp->self); - PyObject_GC_Del(wp); -} - -static PyMethodDef wrapper_methods[] = { - {0} -}; - -static PyObject * -wrapper_name(wrapperobject *wp) -{ - char *s = wp->descr->d_base->name; - - return PyString_FromString(s); -} - -static PyObject * -wrapper_doc(wrapperobject *wp) -{ - char *s = wp->descr->d_base->doc; - - if (s == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - else { - return PyString_FromString(s); - } -} - -static PyGetSetDef wrapper_getsets[] = { - {"__name__", (getter)wrapper_name}, - {"__doc__", (getter)wrapper_doc}, - {0} -}; - -static PyObject * -wrapper_call(wrapperobject *wp, PyObject *args, PyObject *kwds) -{ - wrapperfunc wrapper = wp->descr->d_base->wrapper; - PyObject *self = wp->self; - - if (wp->descr->d_base->flags & PyWrapperFlag_KEYWORDS) { - wrapperfunc_kwds wk = (wrapperfunc_kwds)wrapper; - return (*wk)(self, args, wp->descr->d_wrapped, kwds); - } - - if (kwds != NULL && (!PyDict_Check(kwds) || PyDict_Size(kwds) != 0)) { - PyErr_Format(PyExc_TypeError, - "wrapper %s doesn't take keyword arguments", - wp->descr->d_base->name); - return NULL; - } - return (*wrapper)(self, args, wp->descr->d_wrapped); -} - -static int -wrapper_traverse(PyObject *self, visitproc visit, void *arg) -{ - wrapperobject *wp = (wrapperobject *)self; - int err; - - if (wp->descr) { - err = visit((PyObject *)(wp->descr), arg); - if (err) - return err; - } - if (wp->self) { - err = visit(wp->self, arg); - if (err) - return err; - } - return 0; -} - -static PyTypeObject wrappertype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "method-wrapper", /* tp_name */ - sizeof(wrapperobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)wrapper_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - (ternaryfunc)wrapper_call, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - 0, /* tp_doc */ - wrapper_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - wrapper_methods, /* tp_methods */ - 0, /* tp_members */ - wrapper_getsets, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -}; - -PyObject * -PyWrapper_New(PyObject *d, PyObject *self) -{ - wrapperobject *wp; - PyWrapperDescrObject *descr; - - assert(PyObject_TypeCheck(d, &PyWrapperDescr_Type)); - descr = (PyWrapperDescrObject *)d; - assert(PyObject_IsInstance(self, (PyObject *)(descr->d_type))); - - wp = PyObject_GC_New(wrapperobject, &wrappertype); - if (wp != NULL) { - Py_INCREF(descr); - wp->descr = descr; - Py_INCREF(self); - wp->self = self; - _PyObject_GC_TRACK(wp); - } - return (PyObject *)wp; -} - - -/* A built-in 'property' type */ - -/* - class property(object): - - def __init__(self, fget=None, fset=None, fdel=None, doc=None): - self.__get = fget - self.__set = fset - self.__del = fdel - self.__doc__ = doc - - def __get__(self, inst, type=None): - if inst is None: - return self - if self.__get is None: - raise AttributeError, "unreadable attribute" - return self.__get(inst) - - def __set__(self, inst, value): - if self.__set is None: - raise AttributeError, "can't set attribute" - return self.__set(inst, value) - - def __delete__(self, inst): - if self.__del is None: - raise AttributeError, "can't delete attribute" - return self.__del(inst) - -*/ - -typedef struct { - PyObject_HEAD - PyObject *prop_get; - PyObject *prop_set; - PyObject *prop_del; - PyObject *prop_doc; -} propertyobject; - -static PyMemberDef property_members[] = { - {"fget", T_OBJECT, offsetof(propertyobject, prop_get), READONLY}, - {"fset", T_OBJECT, offsetof(propertyobject, prop_set), READONLY}, - {"fdel", T_OBJECT, offsetof(propertyobject, prop_del), READONLY}, - {"__doc__", T_OBJECT, offsetof(propertyobject, prop_doc), READONLY}, - {0} -}; - - -static void -property_dealloc(PyObject *self) -{ - propertyobject *gs = (propertyobject *)self; - - _PyObject_GC_UNTRACK(self); - Py_XDECREF(gs->prop_get); - Py_XDECREF(gs->prop_set); - Py_XDECREF(gs->prop_del); - Py_XDECREF(gs->prop_doc); - self->ob_type->tp_free(self); -} - -static PyObject * -property_descr_get(PyObject *self, PyObject *obj, PyObject *type) -{ - propertyobject *gs = (propertyobject *)self; - - if (obj == NULL || obj == Py_None) { - Py_INCREF(self); - return self; - } - if (gs->prop_get == NULL) { - PyErr_SetString(PyExc_AttributeError, "unreadable attribute"); - return NULL; - } - return PyObject_CallFunction(gs->prop_get, "(O)", obj); -} - -static int -property_descr_set(PyObject *self, PyObject *obj, PyObject *value) -{ - propertyobject *gs = (propertyobject *)self; - PyObject *func, *res; - - if (value == NULL) - func = gs->prop_del; - else - func = gs->prop_set; - if (func == NULL) { - PyErr_SetString(PyExc_AttributeError, - value == NULL ? - "can't delete attribute" : - "can't set attribute"); - return -1; - } - if (value == NULL) - res = PyObject_CallFunction(func, "(O)", obj); - else - res = PyObject_CallFunction(func, "(OO)", obj, value); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; -} - -static int -property_init(PyObject *self, PyObject *args, PyObject *kwds) -{ - PyObject *get = NULL, *set = NULL, *del = NULL, *doc = NULL; - static char *kwlist[] = {"fget", "fset", "fdel", "doc", 0}; - propertyobject *gs = (propertyobject *)self; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO:property", - kwlist, &get, &set, &del, &doc)) - return -1; - - if (get == Py_None) - get = NULL; - if (set == Py_None) - set = NULL; - if (del == Py_None) - del = NULL; - - Py_XINCREF(get); - Py_XINCREF(set); - Py_XINCREF(del); - Py_XINCREF(doc); - - gs->prop_get = get; - gs->prop_set = set; - gs->prop_del = del; - gs->prop_doc = doc; - - return 0; -} - -PyDoc_STRVAR(property_doc, -"property(fget=None, fset=None, fdel=None, doc=None) -> property attribute\n" -"\n" -"fget is a function to be used for getting an attribute value, and likewise\n" -"fset is a function for setting, and fdel a function for del'ing, an\n" -"attribute. Typical use is to define a managed attribute x:\n" -"class C(object):\n" -" def getx(self): return self.__x\n" -" def setx(self, value): self.__x = value\n" -" def delx(self): del self.__x\n" -" x = property(getx, setx, delx, \"I'm the 'x' property.\")"); - -static int -property_traverse(PyObject *self, visitproc visit, void *arg) -{ - propertyobject *pp = (propertyobject *)self; - int err; - -#define VISIT(SLOT) \ - if (pp->SLOT) { \ - err = visit((PyObject *)(pp->SLOT), arg); \ - if (err) \ - return err; \ - } - - VISIT(prop_get); - VISIT(prop_set); - VISIT(prop_del); - VISIT(prop_doc); - - return 0; -} - -PyTypeObject PyProperty_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "property", /* tp_name */ - sizeof(propertyobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - property_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - property_doc, /* tp_doc */ - property_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - property_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - property_descr_get, /* tp_descr_get */ - property_descr_set, /* tp_descr_set */ - 0, /* tp_dictoffset */ - property_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/dictnotes.txt b/SDKs/XPlatform/Cypython-2.3.3/Objects/dictnotes.txt deleted file mode 100644 index 88b13070..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/dictnotes.txt +++ /dev/null @@ -1,245 +0,0 @@ -NOTES ON OPTIMIZING DICTIONARIES -================================ - - -Principal Use Cases for Dictionaries ------------------------------------- - -Passing keyword arguments - Typically, one read and one write for 1 to 3 elements. - Occurs frequently in normal python code. - -Class method lookup - Dictionaries vary in size with 8 to 16 elements being common. - Usually written once with many lookups. - When base classes are used, there are many failed lookups - followed by a lookup in a base class. - -Instance attribute lookup and Global variables - Dictionaries vary in size. 4 to 10 elements are common. - Both reads and writes are common. - -Builtins - Frequent reads. Almost never written. - Size 126 interned strings (as of Py2.3b1). - A few keys are accessed much more frequently than others. - -Uniquification - Dictionaries of any size. Bulk of work is in creation. - Repeated writes to a smaller set of keys. - Single read of each key. - Some use cases have two consecutive accesses to the same key. - - * Removing duplicates from a sequence. - dict.fromkeys(seqn).keys() - - * Counting elements in a sequence. - for e in seqn: - d[e] = d.get(e,0) + 1 - - * Accumulating references in a dictionary of lists: - - for pagenumber, page in enumerate(pages): - for word in page: - d.setdefault(word, []).append(pagenumber) - - Note, the second example is a use case characterized by a get and set - to the same key. There are similar used cases with a __contains__ - followed by a get, set, or del to the same key. Part of the - justification for d.setdefault is combining the two lookups into one. - -Membership Testing - Dictionaries of any size. Created once and then rarely changes. - Single write to each key. - Many calls to __contains__() or has_key(). - Similar access patterns occur with replacement dictionaries - such as with the % formatting operator. - -Dynamic Mappings - Characterized by deletions interspersed with adds and replacements. - Performance benefits greatly from the re-use of dummy entries. - - -Data Layout (assuming a 32-bit box with 64 bytes per cache line) ----------------------------------------------------------------- - -Smalldicts (8 entries) are attached to the dictobject structure -and the whole group nearly fills two consecutive cache lines. - -Larger dicts use the first half of the dictobject structure (one cache -line) and a separate, continuous block of entries (at 12 bytes each -for a total of 5.333 entries per cache line). - - -Tunable Dictionary Parameters ------------------------------ - -* PyDict_MINSIZE. Currently set to 8. - Must be a power of two. New dicts have to zero-out every cell. - Each additional 8 consumes 1.5 cache lines. Increasing improves - the sparseness of small dictionaries but costs time to read in - the additional cache lines if they are not already in cache. - That case is common when keyword arguments are passed. - -* Maximum dictionary load in PyDict_SetItem. Currently set to 2/3. - Increasing this ratio makes dictionaries more dense resulting - in more collisions. Decreasing it improves sparseness at the - expense of spreading entries over more cache lines and at the - cost of total memory consumed. - - The load test occurs in highly time sensitive code. Efforts - to make the test more complex (for example, varying the load - for different sizes) have degraded performance. - -* Growth rate upon hitting maximum load. Currently set to *2. - Raising this to *4 results in half the number of resizes, - less effort to resize, better sparseness for some (but not - all dict sizes), and potentially double memory consumption - depending on the size of the dictionary. Setting to *4 - eliminates every other resize step. - -Tune-ups should be measured across a broad range of applications and -use cases. A change to any parameter will help in some situations and -hurt in others. The key is to find settings that help the most common -cases and do the least damage to the less common cases. Results will -vary dramatically depending on the exact number of keys, whether the -keys are all strings, whether reads or writes dominate, the exact -hash values of the keys (some sets of values have fewer collisions than -others). Any one test or benchmark is likely to prove misleading. - -While making a dictionary more sparse reduces collisions, it impairs -iteration and key listing. Those methods loop over every potential -entry. Doubling the size of dictionary results in twice as many -non-overlapping memory accesses for keys(), items(), values(), -__iter__(), iterkeys(), iteritems(), itervalues(), and update(). - - -Results of Cache Locality Experiments -------------------------------------- - -When an entry is retrieved from memory, 4.333 adjacent entries are also -retrieved into a cache line. Since accessing items in cache is *much* -cheaper than a cache miss, an enticing idea is to probe the adjacent -entries as a first step in collision resolution. Unfortunately, the -introduction of any regularity into collision searches results in more -collisions than the current random chaining approach. - -Exploiting cache locality at the expense of additional collisions fails -to payoff when the entries are already loaded in cache (the expense -is paid with no compensating benefit). This occurs in small dictionaries -where the whole dictionary fits into a pair of cache lines. It also -occurs frequently in large dictionaries which have a common access pattern -where some keys are accessed much more frequently than others. The -more popular entries *and* their collision chains tend to remain in cache. - -To exploit cache locality, change the collision resolution section -in lookdict() and lookdict_string(). Set i^=1 at the top of the -loop and move the i = (i << 2) + i + perturb + 1 to an unrolled -version of the loop. - -This optimization strategy can be leveraged in several ways: - -* If the dictionary is kept sparse (through the tunable parameters), -then the occurrence of additional collisions is lessened. - -* If lookdict() and lookdict_string() are specialized for small dicts -and for largedicts, then the versions for large_dicts can be given -an alternate search strategy without increasing collisions in small dicts -which already have the maximum benefit of cache locality. - -* If the use case for a dictionary is known to have a random key -access pattern (as opposed to a more common pattern with a Zipf's law -distribution), then there will be more benefit for large dictionaries -because any given key is no more likely than another to already be -in cache. - -* In use cases with paired accesses to the same key, the second access -is always in cache and gets no benefit from efforts to further improve -cache locality. - -Optimizing the Search of Small Dictionaries -------------------------------------------- - -If lookdict() and lookdict_string() are specialized for smaller dictionaries, -then a custom search approach can be implemented that exploits the small -search space and cache locality. - -* The simplest example is a linear search of contiguous entries. This is - simple to implement, guaranteed to terminate rapidly, never searches - the same entry twice, and precludes the need to check for dummy entries. - -* A more advanced example is a self-organizing search so that the most - frequently accessed entries get probed first. The organization - adapts if the access pattern changes over time. Treaps are ideally - suited for self-organization with the most common entries at the - top of the heap and a rapid binary search pattern. Most probes and - results are all located at the top of the tree allowing them all to - be located in one or two cache lines. - -* Also, small dictionaries may be made more dense, perhaps filling all - eight cells to take the maximum advantage of two cache lines. - - -Strategy Pattern ----------------- - -Consider allowing the user to set the tunable parameters or to select a -particular search method. Since some dictionary use cases have known -sizes and access patterns, the user may be able to provide useful hints. - -1) For example, if membership testing or lookups dominate runtime and memory - is not at a premium, the user may benefit from setting the maximum load - ratio at 5% or 10% instead of the usual 66.7%. This will sharply - curtail the number of collisions but will increase iteration time. - -2) Dictionary creation time can be shortened in cases where the ultimate - size of the dictionary is known in advance. The dictionary can be - pre-sized so that no resize operations are required during creation. - Not only does this save resizes, but the key insertion will go - more quickly because the first half of the keys will be inserted into - a more sparse environment than before. The preconditions for this - strategy arise whenever a dictionary is created from a key or item - sequence and the number of unique keys is known. - -3) If the key space is large and the access pattern is known to be random, - then search strategies exploiting cache locality can be fruitful. - The preconditions for this strategy arise in simulations and - numerical analysis. - -4) If the keys are fixed and the access pattern strongly favors some of - the keys, then the entries can be stored contiguously and accessed - with a linear search or treap. This exploits knowledge of the data, - cache locality, and a simplified search routine. It also eliminates - the need to test for dummy entries on each probe. The preconditions - for this strategy arise in symbol tables and in the builtin dictionary. - - -Readonly Dictionaries ---------------------- -Some dictionary use cases pass through a build stage and then move to a -more heavily exercised lookup stage with no further changes to the -dictionary. - -An idea that emerged on python-dev is to be able to convert a dictionary -to a read-only state. This can help prevent programming errors and also -provide knowledge that can be exploited for lookup optimization. - -The dictionary can be immediately rebuilt (eliminating dummy entries), -resized (to an appropriate level of sparseness), and the keys can be -jostled (to minimize collisions). The lookdict() routine can then -eliminate the test for dummy entries (saving about 1/4 of the time -spend in the collision resolution loop). - -An additional possibility is to insert links into the empty spaces -so that dictionary iteration can proceed in len(d) steps instead of -(mp->mask + 1) steps. - - -Caching Lookups ---------------- -The idea is to exploit key access patterns by anticipating future lookups -based of previous lookups. - -The simplest incarnation is to save the most recently accessed entry. -This gives optimal performance for use cases where every get is followed -by a set or del to the same key. diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/dictobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/dictobject.c deleted file mode 100644 index ca401048..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/dictobject.c +++ /dev/null @@ -1,2086 +0,0 @@ - -/* Dictionary object implementation using a hash table */ - -/* The distribution includes a separate file, Objects/dictnotes.txt, - describing explorations into dictionary design and optimization. - It covers typical dictionary use patterns, the parameters for - tuning dictionaries, and several ideas for possible optimizations. -*/ - -#include "Python.h" - -typedef PyDictEntry dictentry; -typedef PyDictObject dictobject; - -/* Define this out if you don't want conversion statistics on exit. */ -#undef SHOW_CONVERSION_COUNTS - -/* See large comment block below. This must be >= 1. */ -#define PERTURB_SHIFT 5 - -/* -Major subtleties ahead: Most hash schemes depend on having a "good" hash -function, in the sense of simulating randomness. Python doesn't: its most -important hash functions (for strings and ints) are very regular in common -cases: - ->>> map(hash, (0, 1, 2, 3)) -[0, 1, 2, 3] ->>> map(hash, ("namea", "nameb", "namec", "named")) -[-1658398457, -1658398460, -1658398459, -1658398462] ->>> - -This isn't necessarily bad! To the contrary, in a table of size 2**i, taking -the low-order i bits as the initial table index is extremely fast, and there -are no collisions at all for dicts indexed by a contiguous range of ints. -The same is approximately true when keys are "consecutive" strings. So this -gives better-than-random behavior in common cases, and that's very desirable. - -OTOH, when collisions occur, the tendency to fill contiguous slices of the -hash table makes a good collision resolution strategy crucial. Taking only -the last i bits of the hash code is also vulnerable: for example, consider -[i << 16 for i in range(20000)] as a set of keys. Since ints are their own -hash codes, and this fits in a dict of size 2**15, the last 15 bits of every -hash code are all 0: they *all* map to the same table index. - -But catering to unusual cases should not slow the usual ones, so we just take -the last i bits anyway. It's up to collision resolution to do the rest. If -we *usually* find the key we're looking for on the first try (and, it turns -out, we usually do -- the table load factor is kept under 2/3, so the odds -are solidly in our favor), then it makes best sense to keep the initial index -computation dirt cheap. - -The first half of collision resolution is to visit table indices via this -recurrence: - - j = ((5*j) + 1) mod 2**i - -For any initial j in range(2**i), repeating that 2**i times generates each -int in range(2**i) exactly once (see any text on random-number generation for -proof). By itself, this doesn't help much: like linear probing (setting -j += 1, or j -= 1, on each loop trip), it scans the table entries in a fixed -order. This would be bad, except that's not the only thing we do, and it's -actually *good* in the common cases where hash keys are consecutive. In an -example that's really too small to make this entirely clear, for a table of -size 2**3 the order of indices is: - - 0 -> 1 -> 6 -> 7 -> 4 -> 5 -> 2 -> 3 -> 0 [and here it's repeating] - -If two things come in at index 5, the first place we look after is index 2, -not 6, so if another comes in at index 6 the collision at 5 didn't hurt it. -Linear probing is deadly in this case because there the fixed probe order -is the *same* as the order consecutive keys are likely to arrive. But it's -extremely unlikely hash codes will follow a 5*j+1 recurrence by accident, -and certain that consecutive hash codes do not. - -The other half of the strategy is to get the other bits of the hash code -into play. This is done by initializing a (unsigned) vrbl "perturb" to the -full hash code, and changing the recurrence to: - - j = (5*j) + 1 + perturb; - perturb >>= PERTURB_SHIFT; - use j % 2**i as the next table index; - -Now the probe sequence depends (eventually) on every bit in the hash code, -and the pseudo-scrambling property of recurring on 5*j+1 is more valuable, -because it quickly magnifies small differences in the bits that didn't affect -the initial index. Note that because perturb is unsigned, if the recurrence -is executed often enough perturb eventually becomes and remains 0. At that -point (very rarely reached) the recurrence is on (just) 5*j+1 again, and -that's certain to find an empty slot eventually (since it generates every int -in range(2**i), and we make sure there's always at least one empty slot). - -Selecting a good value for PERTURB_SHIFT is a balancing act. You want it -small so that the high bits of the hash code continue to affect the probe -sequence across iterations; but you want it large so that in really bad cases -the high-order hash bits have an effect on early iterations. 5 was "the -best" in minimizing total collisions across experiments Tim Peters ran (on -both normal and pathological cases), but 4 and 6 weren't significantly worse. - -Historical: Reimer Behrends contributed the idea of using a polynomial-based -approach, using repeated multiplication by x in GF(2**n) where an irreducible -polynomial for each table size was chosen such that x was a primitive root. -Christian Tismer later extended that to use division by x instead, as an -efficient way to get the high bits of the hash code into play. This scheme -also gave excellent collision statistics, but was more expensive: two -if-tests were required inside the loop; computing "the next" index took about -the same number of operations but without as much potential parallelism -(e.g., computing 5*j can go on at the same time as computing 1+perturb in the -above, and then shifting perturb can be done while the table index is being -masked); and the dictobject struct required a member to hold the table's -polynomial. In Tim's experiments the current scheme ran faster, produced -equally good collision statistics, needed less code & used less memory. -*/ - -/* Object used as dummy key to fill deleted entries */ -static PyObject *dummy; /* Initialized by first call to newdictobject() */ - -/* forward declarations */ -static dictentry * -lookdict_string(dictobject *mp, PyObject *key, long hash); - -#ifdef SHOW_CONVERSION_COUNTS -static long created = 0L; -static long converted = 0L; - -static void -show_counts(void) -{ - fprintf(stderr, "created %ld string dicts\n", created); - fprintf(stderr, "converted %ld to normal dicts\n", converted); - fprintf(stderr, "%.2f%% conversion rate\n", (100.0*converted)/created); -} -#endif - -/* Initialization macros. - There are two ways to create a dict: PyDict_New() is the main C API - function, and the tp_new slot maps to dict_new(). In the latter case we - can save a little time over what PyDict_New does because it's guaranteed - that the PyDictObject struct is already zeroed out. - Everyone except dict_new() should use EMPTY_TO_MINSIZE (unless they have - an excellent reason not to). -*/ - -#define INIT_NONZERO_DICT_SLOTS(mp) do { \ - (mp)->ma_table = (mp)->ma_smalltable; \ - (mp)->ma_mask = PyDict_MINSIZE - 1; \ - } while(0) - -#define EMPTY_TO_MINSIZE(mp) do { \ - memset((mp)->ma_smalltable, 0, sizeof((mp)->ma_smalltable)); \ - (mp)->ma_used = (mp)->ma_fill = 0; \ - INIT_NONZERO_DICT_SLOTS(mp); \ - } while(0) - -PyObject * -PyDict_New(void) -{ - register dictobject *mp; - if (dummy == NULL) { /* Auto-initialize dummy */ - dummy = PyString_FromString(""); - if (dummy == NULL) - return NULL; -#ifdef SHOW_CONVERSION_COUNTS - Py_AtExit(show_counts); -#endif - } - mp = PyObject_GC_New(dictobject, &PyDict_Type); - if (mp == NULL) - return NULL; - EMPTY_TO_MINSIZE(mp); - mp->ma_lookup = lookdict_string; -#ifdef SHOW_CONVERSION_COUNTS - ++created; -#endif - _PyObject_GC_TRACK(mp); - return (PyObject *)mp; -} - -/* -The basic lookup function used by all operations. -This is based on Algorithm D from Knuth Vol. 3, Sec. 6.4. -Open addressing is preferred over chaining since the link overhead for -chaining would be substantial (100% with typical malloc overhead). - -The initial probe index is computed as hash mod the table size. Subsequent -probe indices are computed as explained earlier. - -All arithmetic on hash should ignore overflow. - -(The details in this version are due to Tim Peters, building on many past -contributions by Reimer Behrends, Jyrki Alakuijala, Vladimir Marangozov and -Christian Tismer). - -This function must never return NULL; failures are indicated by returning -a dictentry* for which the me_value field is NULL. Exceptions are never -reported by this function, and outstanding exceptions are maintained. -*/ - -static dictentry * -lookdict(dictobject *mp, PyObject *key, register long hash) -{ - register int i; - register unsigned int perturb; - register dictentry *freeslot; - register unsigned int mask = mp->ma_mask; - dictentry *ep0 = mp->ma_table; - register dictentry *ep; - register int restore_error; - register int checked_error; - register int cmp; - PyObject *err_type, *err_value, *err_tb; - PyObject *startkey; - - i = hash & mask; - ep = &ep0[i]; - if (ep->me_key == NULL || ep->me_key == key) - return ep; - - restore_error = checked_error = 0; - if (ep->me_key == dummy) - freeslot = ep; - else { - if (ep->me_hash == hash) { - /* error can't have been checked yet */ - checked_error = 1; - if (PyErr_Occurred()) { - restore_error = 1; - PyErr_Fetch(&err_type, &err_value, &err_tb); - } - startkey = ep->me_key; - cmp = PyObject_RichCompareBool(startkey, key, Py_EQ); - if (cmp < 0) - PyErr_Clear(); - if (ep0 == mp->ma_table && ep->me_key == startkey) { - if (cmp > 0) - goto Done; - } - else { - /* The compare did major nasty stuff to the - * dict: start over. - * XXX A clever adversary could prevent this - * XXX from terminating. - */ - ep = lookdict(mp, key, hash); - goto Done; - } - } - freeslot = NULL; - } - - /* In the loop, me_key == dummy is by far (factor of 100s) the - least likely outcome, so test for that last. */ - for (perturb = hash; ; perturb >>= PERTURB_SHIFT) { - i = (i << 2) + i + perturb + 1; - ep = &ep0[i & mask]; - if (ep->me_key == NULL) { - if (freeslot != NULL) - ep = freeslot; - break; - } - if (ep->me_key == key) - break; - if (ep->me_hash == hash && ep->me_key != dummy) { - if (!checked_error) { - checked_error = 1; - if (PyErr_Occurred()) { - restore_error = 1; - PyErr_Fetch(&err_type, &err_value, - &err_tb); - } - } - startkey = ep->me_key; - cmp = PyObject_RichCompareBool(startkey, key, Py_EQ); - if (cmp < 0) - PyErr_Clear(); - if (ep0 == mp->ma_table && ep->me_key == startkey) { - if (cmp > 0) - break; - } - else { - /* The compare did major nasty stuff to the - * dict: start over. - * XXX A clever adversary could prevent this - * XXX from terminating. - */ - ep = lookdict(mp, key, hash); - break; - } - } - else if (ep->me_key == dummy && freeslot == NULL) - freeslot = ep; - } - -Done: - if (restore_error) - PyErr_Restore(err_type, err_value, err_tb); - return ep; -} - -/* - * Hacked up version of lookdict which can assume keys are always strings; - * this assumption allows testing for errors during PyObject_Compare() to - * be dropped; string-string comparisons never raise exceptions. This also - * means we don't need to go through PyObject_Compare(); we can always use - * _PyString_Eq directly. - * - * This is valuable because the general-case error handling in lookdict() is - * expensive, and dicts with pure-string keys are very common. - */ -static dictentry * -lookdict_string(dictobject *mp, PyObject *key, register long hash) -{ - register int i; - register unsigned int perturb; - register dictentry *freeslot; - register unsigned int mask = mp->ma_mask; - dictentry *ep0 = mp->ma_table; - register dictentry *ep; - - /* Make sure this function doesn't have to handle non-string keys, - including subclasses of str; e.g., one reason to subclass - strings is to override __eq__, and for speed we don't cater to - that here. */ - if (!PyString_CheckExact(key)) { -#ifdef SHOW_CONVERSION_COUNTS - ++converted; -#endif - mp->ma_lookup = lookdict; - return lookdict(mp, key, hash); - } - i = hash & mask; - ep = &ep0[i]; - if (ep->me_key == NULL || ep->me_key == key) - return ep; - if (ep->me_key == dummy) - freeslot = ep; - else { - if (ep->me_hash == hash - && _PyString_Eq(ep->me_key, key)) { - return ep; - } - freeslot = NULL; - } - - /* In the loop, me_key == dummy is by far (factor of 100s) the - least likely outcome, so test for that last. */ - for (perturb = hash; ; perturb >>= PERTURB_SHIFT) { - i = (i << 2) + i + perturb + 1; - ep = &ep0[i & mask]; - if (ep->me_key == NULL) - return freeslot == NULL ? ep : freeslot; - if (ep->me_key == key - || (ep->me_hash == hash - && ep->me_key != dummy - && _PyString_Eq(ep->me_key, key))) - return ep; - if (ep->me_key == dummy && freeslot == NULL) - freeslot = ep; - } -} - -/* -Internal routine to insert a new item into the table. -Used both by the internal resize routine and by the public insert routine. -Eats a reference to key and one to value. -*/ -static void -insertdict(register dictobject *mp, PyObject *key, long hash, PyObject *value) -{ - PyObject *old_value; - register dictentry *ep; - typedef PyDictEntry *(*lookupfunc)(PyDictObject *, PyObject *, long); - - assert(mp->ma_lookup != NULL); - ep = mp->ma_lookup(mp, key, hash); - if (ep->me_value != NULL) { - old_value = ep->me_value; - ep->me_value = value; - Py_DECREF(old_value); /* which **CAN** re-enter */ - Py_DECREF(key); - } - else { - if (ep->me_key == NULL) - mp->ma_fill++; - else - Py_DECREF(ep->me_key); - ep->me_key = key; - ep->me_hash = hash; - ep->me_value = value; - mp->ma_used++; - } -} - -/* -Restructure the table by allocating a new table and reinserting all -items again. When entries have been deleted, the new table may -actually be smaller than the old one. -*/ -static int -dictresize(dictobject *mp, int minused) -{ - int newsize; - dictentry *oldtable, *newtable, *ep; - int i; - int is_oldtable_malloced; - dictentry small_copy[PyDict_MINSIZE]; - - assert(minused >= 0); - - /* Find the smallest table size > minused. */ - for (newsize = PyDict_MINSIZE; - newsize <= minused && newsize > 0; - newsize <<= 1) - ; - if (newsize <= 0) { - PyErr_NoMemory(); - return -1; - } - - /* Get space for a new table. */ - oldtable = mp->ma_table; - assert(oldtable != NULL); - is_oldtable_malloced = oldtable != mp->ma_smalltable; - - if (newsize == PyDict_MINSIZE) { - /* A large table is shrinking, or we can't get any smaller. */ - newtable = mp->ma_smalltable; - if (newtable == oldtable) { - if (mp->ma_fill == mp->ma_used) { - /* No dummies, so no point doing anything. */ - return 0; - } - /* We're not going to resize it, but rebuild the - table anyway to purge old dummy entries. - Subtle: This is *necessary* if fill==size, - as lookdict needs at least one virgin slot to - terminate failing searches. If fill < size, it's - merely desirable, as dummies slow searches. */ - assert(mp->ma_fill > mp->ma_used); - memcpy(small_copy, oldtable, sizeof(small_copy)); - oldtable = small_copy; - } - } - else { - newtable = PyMem_NEW(dictentry, newsize); - if (newtable == NULL) { - PyErr_NoMemory(); - return -1; - } - } - - /* Make the dict empty, using the new table. */ - assert(newtable != oldtable); - mp->ma_table = newtable; - mp->ma_mask = newsize - 1; - memset(newtable, 0, sizeof(dictentry) * newsize); - mp->ma_used = 0; - i = mp->ma_fill; - mp->ma_fill = 0; - - /* Copy the data over; this is refcount-neutral for active entries; - dummy entries aren't copied over, of course */ - for (ep = oldtable; i > 0; ep++) { - if (ep->me_value != NULL) { /* active entry */ - --i; - insertdict(mp, ep->me_key, ep->me_hash, ep->me_value); - } - else if (ep->me_key != NULL) { /* dummy entry */ - --i; - assert(ep->me_key == dummy); - Py_DECREF(ep->me_key); - } - /* else key == value == NULL: nothing to do */ - } - - if (is_oldtable_malloced) - PyMem_DEL(oldtable); - return 0; -} - -PyObject * -PyDict_GetItem(PyObject *op, PyObject *key) -{ - long hash; - dictobject *mp = (dictobject *)op; - if (!PyDict_Check(op)) { - return NULL; - } - if (!PyString_CheckExact(key) || - (hash = ((PyStringObject *) key)->ob_shash) == -1) - { - hash = PyObject_Hash(key); - if (hash == -1) { - PyErr_Clear(); - return NULL; - } - } - return (mp->ma_lookup)(mp, key, hash)->me_value; -} - -/* CAUTION: PyDict_SetItem() must guarantee that it won't resize the - * dictionary if it is merely replacing the value for an existing key. - * This is means that it's safe to loop over a dictionary with - * PyDict_Next() and occasionally replace a value -- but you can't - * insert new keys or remove them. - */ -int -PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value) -{ - register dictobject *mp; - register long hash; - register int n_used; - - if (!PyDict_Check(op)) { - PyErr_BadInternalCall(); - return -1; - } - mp = (dictobject *)op; - if (PyString_CheckExact(key)) { - hash = ((PyStringObject *)key)->ob_shash; - if (hash == -1) - hash = PyObject_Hash(key); - } - else { - hash = PyObject_Hash(key); - if (hash == -1) - return -1; - } - assert(mp->ma_fill <= mp->ma_mask); /* at least one empty slot */ - n_used = mp->ma_used; - Py_INCREF(value); - Py_INCREF(key); - insertdict(mp, key, hash, value); - /* If we added a key, we can safely resize. Otherwise just return! - * If fill >= 2/3 size, adjust size. Normally, this doubles or - * quaduples the size, but it's also possible for the dict to shrink - * (if ma_fill is much larger than ma_used, meaning a lot of dict - * keys have been * deleted). - * - * Quadrupling the size improves average dictionary sparseness - * (reducing collisions) at the cost of some memory and iteration - * speed (which loops over every possible entry). It also halves - * the number of expensive resize operations in a growing dictionary. - * - * Very large dictionaries (over 50K items) use doubling instead. - * This may help applications with severe memory constraints. - */ - if (!(mp->ma_used > n_used && mp->ma_fill*3 >= (mp->ma_mask+1)*2)) - return 0; - return dictresize(mp, mp->ma_used*(mp->ma_used>50000 ? 2 : 4)); -} - -int -PyDict_DelItem(PyObject *op, PyObject *key) -{ - register dictobject *mp; - register long hash; - register dictentry *ep; - PyObject *old_value, *old_key; - - if (!PyDict_Check(op)) { - PyErr_BadInternalCall(); - return -1; - } - if (!PyString_CheckExact(key) || - (hash = ((PyStringObject *) key)->ob_shash) == -1) { - hash = PyObject_Hash(key); - if (hash == -1) - return -1; - } - mp = (dictobject *)op; - ep = (mp->ma_lookup)(mp, key, hash); - if (ep->me_value == NULL) { - PyErr_SetObject(PyExc_KeyError, key); - return -1; - } - old_key = ep->me_key; - Py_INCREF(dummy); - ep->me_key = dummy; - old_value = ep->me_value; - ep->me_value = NULL; - mp->ma_used--; - Py_DECREF(old_value); - Py_DECREF(old_key); - return 0; -} - -void -PyDict_Clear(PyObject *op) -{ - dictobject *mp; - dictentry *ep, *table; - int table_is_malloced; - int fill; - dictentry small_copy[PyDict_MINSIZE]; -#ifdef Py_DEBUG - int i, n; -#endif - - if (!PyDict_Check(op)) - return; - mp = (dictobject *)op; -#ifdef Py_DEBUG - n = mp->ma_mask + 1; - i = 0; -#endif - - table = mp->ma_table; - assert(table != NULL); - table_is_malloced = table != mp->ma_smalltable; - - /* This is delicate. During the process of clearing the dict, - * decrefs can cause the dict to mutate. To avoid fatal confusion - * (voice of experience), we have to make the dict empty before - * clearing the slots, and never refer to anything via mp->xxx while - * clearing. - */ - fill = mp->ma_fill; - if (table_is_malloced) - EMPTY_TO_MINSIZE(mp); - - else if (fill > 0) { - /* It's a small table with something that needs to be cleared. - * Afraid the only safe way is to copy the dict entries into - * another small table first. - */ - memcpy(small_copy, table, sizeof(small_copy)); - table = small_copy; - EMPTY_TO_MINSIZE(mp); - } - /* else it's a small table that's already empty */ - - /* Now we can finally clear things. If C had refcounts, we could - * assert that the refcount on table is 1 now, i.e. that this function - * has unique access to it, so decref side-effects can't alter it. - */ - for (ep = table; fill > 0; ++ep) { -#ifdef Py_DEBUG - assert(i < n); - ++i; -#endif - if (ep->me_key) { - --fill; - Py_DECREF(ep->me_key); - Py_XDECREF(ep->me_value); - } -#ifdef Py_DEBUG - else - assert(ep->me_value == NULL); -#endif - } - - if (table_is_malloced) - PyMem_DEL(table); -} - -/* - * Iterate over a dict. Use like so: - * - * int i; - * PyObject *key, *value; - * i = 0; # important! i should not otherwise be changed by you - * while (PyDict_Next(yourdict, &i, &key, &value)) { - * Refer to borrowed references in key and value. - * } - * - * CAUTION: In general, it isn't safe to use PyDict_Next in a loop that - * mutates the dict. One exception: it is safe if the loop merely changes - * the values associated with the keys (but doesn't insert new keys or - * delete keys), via PyDict_SetItem(). - */ -int -PyDict_Next(PyObject *op, int *ppos, PyObject **pkey, PyObject **pvalue) -{ - int i; - register dictobject *mp; - if (!PyDict_Check(op)) - return 0; - mp = (dictobject *)op; - i = *ppos; - if (i < 0) - return 0; - while (i <= mp->ma_mask && mp->ma_table[i].me_value == NULL) - i++; - *ppos = i+1; - if (i > mp->ma_mask) - return 0; - if (pkey) - *pkey = mp->ma_table[i].me_key; - if (pvalue) - *pvalue = mp->ma_table[i].me_value; - return 1; -} - -/* Methods */ - -static void -dict_dealloc(register dictobject *mp) -{ - register dictentry *ep; - int fill = mp->ma_fill; - PyObject_GC_UnTrack(mp); - Py_TRASHCAN_SAFE_BEGIN(mp) - for (ep = mp->ma_table; fill > 0; ep++) { - if (ep->me_key) { - --fill; - Py_DECREF(ep->me_key); - Py_XDECREF(ep->me_value); - } - } - if (mp->ma_table != mp->ma_smalltable) - PyMem_DEL(mp->ma_table); - mp->ob_type->tp_free((PyObject *)mp); - Py_TRASHCAN_SAFE_END(mp) -} - -static int -dict_print(register dictobject *mp, register FILE *fp, register int flags) -{ - register int i; - register int any; - - i = Py_ReprEnter((PyObject*)mp); - if (i != 0) { - if (i < 0) - return i; - fprintf(fp, "{...}"); - return 0; - } - - fprintf(fp, "{"); - any = 0; - for (i = 0; i <= mp->ma_mask; i++) { - dictentry *ep = mp->ma_table + i; - PyObject *pvalue = ep->me_value; - if (pvalue != NULL) { - /* Prevent PyObject_Repr from deleting value during - key format */ - Py_INCREF(pvalue); - if (any++ > 0) - fprintf(fp, ", "); - if (PyObject_Print((PyObject *)ep->me_key, fp, 0)!=0) { - Py_DECREF(pvalue); - Py_ReprLeave((PyObject*)mp); - return -1; - } - fprintf(fp, ": "); - if (PyObject_Print(pvalue, fp, 0) != 0) { - Py_DECREF(pvalue); - Py_ReprLeave((PyObject*)mp); - return -1; - } - Py_DECREF(pvalue); - } - } - fprintf(fp, "}"); - Py_ReprLeave((PyObject*)mp); - return 0; -} - -static PyObject * -dict_repr(dictobject *mp) -{ - int i; - PyObject *s, *temp, *colon = NULL; - PyObject *pieces = NULL, *result = NULL; - PyObject *key, *value; - - i = Py_ReprEnter((PyObject *)mp); - if (i != 0) { - return i > 0 ? PyString_FromString("{...}") : NULL; - } - - if (mp->ma_used == 0) { - result = PyString_FromString("{}"); - goto Done; - } - - pieces = PyList_New(0); - if (pieces == NULL) - goto Done; - - colon = PyString_FromString(": "); - if (colon == NULL) - goto Done; - - /* Do repr() on each key+value pair, and insert ": " between them. - Note that repr may mutate the dict. */ - i = 0; - while (PyDict_Next((PyObject *)mp, &i, &key, &value)) { - int status; - /* Prevent repr from deleting value during key format. */ - Py_INCREF(value); - s = PyObject_Repr(key); - PyString_Concat(&s, colon); - PyString_ConcatAndDel(&s, PyObject_Repr(value)); - Py_DECREF(value); - if (s == NULL) - goto Done; - status = PyList_Append(pieces, s); - Py_DECREF(s); /* append created a new ref */ - if (status < 0) - goto Done; - } - - /* Add "{}" decorations to the first and last items. */ - assert(PyList_GET_SIZE(pieces) > 0); - s = PyString_FromString("{"); - if (s == NULL) - goto Done; - temp = PyList_GET_ITEM(pieces, 0); - PyString_ConcatAndDel(&s, temp); - PyList_SET_ITEM(pieces, 0, s); - if (s == NULL) - goto Done; - - s = PyString_FromString("}"); - if (s == NULL) - goto Done; - temp = PyList_GET_ITEM(pieces, PyList_GET_SIZE(pieces) - 1); - PyString_ConcatAndDel(&temp, s); - PyList_SET_ITEM(pieces, PyList_GET_SIZE(pieces) - 1, temp); - if (temp == NULL) - goto Done; - - /* Paste them all together with ", " between. */ - s = PyString_FromString(", "); - if (s == NULL) - goto Done; - result = _PyString_Join(s, pieces); - Py_DECREF(s); - -Done: - Py_XDECREF(pieces); - Py_XDECREF(colon); - Py_ReprLeave((PyObject *)mp); - return result; -} - -static int -dict_length(dictobject *mp) -{ - return mp->ma_used; -} - -static PyObject * -dict_subscript(dictobject *mp, register PyObject *key) -{ - PyObject *v; - long hash; - assert(mp->ma_table != NULL); - if (!PyString_CheckExact(key) || - (hash = ((PyStringObject *) key)->ob_shash) == -1) { - hash = PyObject_Hash(key); - if (hash == -1) - return NULL; - } - v = (mp->ma_lookup)(mp, key, hash) -> me_value; - if (v == NULL) - PyErr_SetObject(PyExc_KeyError, key); - else - Py_INCREF(v); - return v; -} - -static int -dict_ass_sub(dictobject *mp, PyObject *v, PyObject *w) -{ - if (w == NULL) - return PyDict_DelItem((PyObject *)mp, v); - else - return PyDict_SetItem((PyObject *)mp, v, w); -} - -static PyMappingMethods dict_as_mapping = { - (inquiry)dict_length, /*mp_length*/ - (binaryfunc)dict_subscript, /*mp_subscript*/ - (objobjargproc)dict_ass_sub, /*mp_ass_subscript*/ -}; - -static PyObject * -dict_keys(register dictobject *mp) -{ - register PyObject *v; - register int i, j, n; - - again: - n = mp->ma_used; - v = PyList_New(n); - if (v == NULL) - return NULL; - if (n != mp->ma_used) { - /* Durnit. The allocations caused the dict to resize. - * Just start over, this shouldn't normally happen. - */ - Py_DECREF(v); - goto again; - } - for (i = 0, j = 0; i <= mp->ma_mask; i++) { - if (mp->ma_table[i].me_value != NULL) { - PyObject *key = mp->ma_table[i].me_key; - Py_INCREF(key); - PyList_SET_ITEM(v, j, key); - j++; - } - } - return v; -} - -static PyObject * -dict_values(register dictobject *mp) -{ - register PyObject *v; - register int i, j, n; - - again: - n = mp->ma_used; - v = PyList_New(n); - if (v == NULL) - return NULL; - if (n != mp->ma_used) { - /* Durnit. The allocations caused the dict to resize. - * Just start over, this shouldn't normally happen. - */ - Py_DECREF(v); - goto again; - } - for (i = 0, j = 0; i <= mp->ma_mask; i++) { - if (mp->ma_table[i].me_value != NULL) { - PyObject *value = mp->ma_table[i].me_value; - Py_INCREF(value); - PyList_SET_ITEM(v, j, value); - j++; - } - } - return v; -} - -static PyObject * -dict_items(register dictobject *mp) -{ - register PyObject *v; - register int i, j, n; - PyObject *item, *key, *value; - - /* Preallocate the list of tuples, to avoid allocations during - * the loop over the items, which could trigger GC, which - * could resize the dict. :-( - */ - again: - n = mp->ma_used; - v = PyList_New(n); - if (v == NULL) - return NULL; - for (i = 0; i < n; i++) { - item = PyTuple_New(2); - if (item == NULL) { - Py_DECREF(v); - return NULL; - } - PyList_SET_ITEM(v, i, item); - } - if (n != mp->ma_used) { - /* Durnit. The allocations caused the dict to resize. - * Just start over, this shouldn't normally happen. - */ - Py_DECREF(v); - goto again; - } - /* Nothing we do below makes any function calls. */ - for (i = 0, j = 0; i <= mp->ma_mask; i++) { - if (mp->ma_table[i].me_value != NULL) { - key = mp->ma_table[i].me_key; - value = mp->ma_table[i].me_value; - item = PyList_GET_ITEM(v, j); - Py_INCREF(key); - PyTuple_SET_ITEM(item, 0, key); - Py_INCREF(value); - PyTuple_SET_ITEM(item, 1, value); - j++; - } - } - assert(j == n); - return v; -} - -static PyObject * -dict_fromkeys(PyObject *cls, PyObject *args) -{ - PyObject *seq; - PyObject *value = Py_None; - PyObject *it; /* iter(seq) */ - PyObject *key; - PyObject *d; - int status; - - if (!PyArg_UnpackTuple(args, "fromkeys", 1, 2, &seq, &value)) - return NULL; - - d = PyObject_CallObject(cls, NULL); - if (d == NULL) - return NULL; - - it = PyObject_GetIter(seq); - if (it == NULL){ - Py_DECREF(d); - return NULL; - } - - for (;;) { - key = PyIter_Next(it); - if (key == NULL) { - if (PyErr_Occurred()) - goto Fail; - break; - } - status = PyObject_SetItem(d, key, value); - Py_DECREF(key); - if (status < 0) - goto Fail; - } - - Py_DECREF(it); - return d; - -Fail: - Py_DECREF(it); - Py_DECREF(d); - return NULL; -} - -static PyObject * -dict_update(PyObject *mp, PyObject *other) -{ - if (PyDict_Update(mp, other) < 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -/* Update unconditionally replaces existing items. - Merge has a 3rd argument 'override'; if set, it acts like Update, - otherwise it leaves existing items unchanged. - - PyDict_{Update,Merge} update/merge from a mapping object. - - PyDict_MergeFromSeq2 updates/merges from any iterable object - producing iterable objects of length 2. -*/ - -int -PyDict_MergeFromSeq2(PyObject *d, PyObject *seq2, int override) -{ - PyObject *it; /* iter(seq2) */ - int i; /* index into seq2 of current element */ - PyObject *item; /* seq2[i] */ - PyObject *fast; /* item as a 2-tuple or 2-list */ - - assert(d != NULL); - assert(PyDict_Check(d)); - assert(seq2 != NULL); - - it = PyObject_GetIter(seq2); - if (it == NULL) - return -1; - - for (i = 0; ; ++i) { - PyObject *key, *value; - int n; - - fast = NULL; - item = PyIter_Next(it); - if (item == NULL) { - if (PyErr_Occurred()) - goto Fail; - break; - } - - /* Convert item to sequence, and verify length 2. */ - fast = PySequence_Fast(item, ""); - if (fast == NULL) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_Format(PyExc_TypeError, - "cannot convert dictionary update " - "sequence element #%d to a sequence", - i); - goto Fail; - } - n = PySequence_Fast_GET_SIZE(fast); - if (n != 2) { - PyErr_Format(PyExc_ValueError, - "dictionary update sequence element #%d " - "has length %d; 2 is required", - i, n); - goto Fail; - } - - /* Update/merge with this (key, value) pair. */ - key = PySequence_Fast_GET_ITEM(fast, 0); - value = PySequence_Fast_GET_ITEM(fast, 1); - if (override || PyDict_GetItem(d, key) == NULL) { - int status = PyDict_SetItem(d, key, value); - if (status < 0) - goto Fail; - } - Py_DECREF(fast); - Py_DECREF(item); - } - - i = 0; - goto Return; -Fail: - Py_XDECREF(item); - Py_XDECREF(fast); - i = -1; -Return: - Py_DECREF(it); - return i; -} - -int -PyDict_Update(PyObject *a, PyObject *b) -{ - return PyDict_Merge(a, b, 1); -} - -int -PyDict_Merge(PyObject *a, PyObject *b, int override) -{ - register PyDictObject *mp, *other; - register int i; - dictentry *entry; - - /* We accept for the argument either a concrete dictionary object, - * or an abstract "mapping" object. For the former, we can do - * things quite efficiently. For the latter, we only require that - * PyMapping_Keys() and PyObject_GetItem() be supported. - */ - if (a == NULL || !PyDict_Check(a) || b == NULL) { - PyErr_BadInternalCall(); - return -1; - } - mp = (dictobject*)a; - if (PyDict_Check(b)) { - other = (dictobject*)b; - if (other == mp || other->ma_used == 0) - /* a.update(a) or a.update({}); nothing to do */ - return 0; - /* Do one big resize at the start, rather than - * incrementally resizing as we insert new items. Expect - * that there will be no (or few) overlapping keys. - */ - if ((mp->ma_fill + other->ma_used)*3 >= (mp->ma_mask+1)*2) { - if (dictresize(mp, (mp->ma_used + other->ma_used)*2) != 0) - return -1; - } - for (i = 0; i <= other->ma_mask; i++) { - entry = &other->ma_table[i]; - if (entry->me_value != NULL && - (override || - PyDict_GetItem(a, entry->me_key) == NULL)) { - Py_INCREF(entry->me_key); - Py_INCREF(entry->me_value); - insertdict(mp, entry->me_key, entry->me_hash, - entry->me_value); - } - } - } - else { - /* Do it the generic, slower way */ - PyObject *keys = PyMapping_Keys(b); - PyObject *iter; - PyObject *key, *value; - int status; - - if (keys == NULL) - /* Docstring says this is equivalent to E.keys() so - * if E doesn't have a .keys() method we want - * AttributeError to percolate up. Might as well - * do the same for any other error. - */ - return -1; - - iter = PyObject_GetIter(keys); - Py_DECREF(keys); - if (iter == NULL) - return -1; - - for (key = PyIter_Next(iter); key; key = PyIter_Next(iter)) { - if (!override && PyDict_GetItem(a, key) != NULL) { - Py_DECREF(key); - continue; - } - value = PyObject_GetItem(b, key); - if (value == NULL) { - Py_DECREF(iter); - Py_DECREF(key); - return -1; - } - status = PyDict_SetItem(a, key, value); - Py_DECREF(key); - Py_DECREF(value); - if (status < 0) { - Py_DECREF(iter); - return -1; - } - } - Py_DECREF(iter); - if (PyErr_Occurred()) - /* Iterator completed, via error */ - return -1; - } - return 0; -} - -static PyObject * -dict_copy(register dictobject *mp) -{ - return PyDict_Copy((PyObject*)mp); -} - -PyObject * -PyDict_Copy(PyObject *o) -{ - register dictobject *mp; - register int i; - dictobject *copy; - dictentry *entry; - - if (o == NULL || !PyDict_Check(o)) { - PyErr_BadInternalCall(); - return NULL; - } - mp = (dictobject *)o; - copy = (dictobject *)PyDict_New(); - if (copy == NULL) - return NULL; - if (mp->ma_used > 0) { - if (dictresize(copy, mp->ma_used*2) != 0) - return NULL; - for (i = 0; i <= mp->ma_mask; i++) { - entry = &mp->ma_table[i]; - if (entry->me_value != NULL) { - Py_INCREF(entry->me_key); - Py_INCREF(entry->me_value); - insertdict(copy, entry->me_key, entry->me_hash, - entry->me_value); - } - } - } - return (PyObject *)copy; -} - -int -PyDict_Size(PyObject *mp) -{ - if (mp == NULL || !PyDict_Check(mp)) { - PyErr_BadInternalCall(); - return 0; - } - return ((dictobject *)mp)->ma_used; -} - -PyObject * -PyDict_Keys(PyObject *mp) -{ - if (mp == NULL || !PyDict_Check(mp)) { - PyErr_BadInternalCall(); - return NULL; - } - return dict_keys((dictobject *)mp); -} - -PyObject * -PyDict_Values(PyObject *mp) -{ - if (mp == NULL || !PyDict_Check(mp)) { - PyErr_BadInternalCall(); - return NULL; - } - return dict_values((dictobject *)mp); -} - -PyObject * -PyDict_Items(PyObject *mp) -{ - if (mp == NULL || !PyDict_Check(mp)) { - PyErr_BadInternalCall(); - return NULL; - } - return dict_items((dictobject *)mp); -} - -/* Subroutine which returns the smallest key in a for which b's value - is different or absent. The value is returned too, through the - pval argument. Both are NULL if no key in a is found for which b's status - differs. The refcounts on (and only on) non-NULL *pval and function return - values must be decremented by the caller (characterize() increments them - to ensure that mutating comparison and PyDict_GetItem calls can't delete - them before the caller is done looking at them). */ - -static PyObject * -characterize(dictobject *a, dictobject *b, PyObject **pval) -{ - PyObject *akey = NULL; /* smallest key in a s.t. a[akey] != b[akey] */ - PyObject *aval = NULL; /* a[akey] */ - int i, cmp; - - for (i = 0; i <= a->ma_mask; i++) { - PyObject *thiskey, *thisaval, *thisbval; - if (a->ma_table[i].me_value == NULL) - continue; - thiskey = a->ma_table[i].me_key; - Py_INCREF(thiskey); /* keep alive across compares */ - if (akey != NULL) { - cmp = PyObject_RichCompareBool(akey, thiskey, Py_LT); - if (cmp < 0) { - Py_DECREF(thiskey); - goto Fail; - } - if (cmp > 0 || - i > a->ma_mask || - a->ma_table[i].me_value == NULL) - { - /* Not the *smallest* a key; or maybe it is - * but the compare shrunk the dict so we can't - * find its associated value anymore; or - * maybe it is but the compare deleted the - * a[thiskey] entry. - */ - Py_DECREF(thiskey); - continue; - } - } - - /* Compare a[thiskey] to b[thiskey]; cmp <- true iff equal. */ - thisaval = a->ma_table[i].me_value; - assert(thisaval); - Py_INCREF(thisaval); /* keep alive */ - thisbval = PyDict_GetItem((PyObject *)b, thiskey); - if (thisbval == NULL) - cmp = 0; - else { - /* both dicts have thiskey: same values? */ - cmp = PyObject_RichCompareBool( - thisaval, thisbval, Py_EQ); - if (cmp < 0) { - Py_DECREF(thiskey); - Py_DECREF(thisaval); - goto Fail; - } - } - if (cmp == 0) { - /* New winner. */ - Py_XDECREF(akey); - Py_XDECREF(aval); - akey = thiskey; - aval = thisaval; - } - else { - Py_DECREF(thiskey); - Py_DECREF(thisaval); - } - } - *pval = aval; - return akey; - -Fail: - Py_XDECREF(akey); - Py_XDECREF(aval); - *pval = NULL; - return NULL; -} - -static int -dict_compare(dictobject *a, dictobject *b) -{ - PyObject *adiff, *bdiff, *aval, *bval; - int res; - - /* Compare lengths first */ - if (a->ma_used < b->ma_used) - return -1; /* a is shorter */ - else if (a->ma_used > b->ma_used) - return 1; /* b is shorter */ - - /* Same length -- check all keys */ - bdiff = bval = NULL; - adiff = characterize(a, b, &aval); - if (adiff == NULL) { - assert(!aval); - /* Either an error, or a is a subset with the same length so - * must be equal. - */ - res = PyErr_Occurred() ? -1 : 0; - goto Finished; - } - bdiff = characterize(b, a, &bval); - if (bdiff == NULL && PyErr_Occurred()) { - assert(!bval); - res = -1; - goto Finished; - } - res = 0; - if (bdiff) { - /* bdiff == NULL "should be" impossible now, but perhaps - * the last comparison done by the characterize() on a had - * the side effect of making the dicts equal! - */ - res = PyObject_Compare(adiff, bdiff); - } - if (res == 0 && bval != NULL) - res = PyObject_Compare(aval, bval); - -Finished: - Py_XDECREF(adiff); - Py_XDECREF(bdiff); - Py_XDECREF(aval); - Py_XDECREF(bval); - return res; -} - -/* Return 1 if dicts equal, 0 if not, -1 if error. - * Gets out as soon as any difference is detected. - * Uses only Py_EQ comparison. - */ -static int -dict_equal(dictobject *a, dictobject *b) -{ - int i; - - if (a->ma_used != b->ma_used) - /* can't be equal if # of entries differ */ - return 0; - - /* Same # of entries -- check all of 'em. Exit early on any diff. */ - for (i = 0; i <= a->ma_mask; i++) { - PyObject *aval = a->ma_table[i].me_value; - if (aval != NULL) { - int cmp; - PyObject *bval; - PyObject *key = a->ma_table[i].me_key; - /* temporarily bump aval's refcount to ensure it stays - alive until we're done with it */ - Py_INCREF(aval); - bval = PyDict_GetItem((PyObject *)b, key); - if (bval == NULL) { - Py_DECREF(aval); - return 0; - } - cmp = PyObject_RichCompareBool(aval, bval, Py_EQ); - Py_DECREF(aval); - if (cmp <= 0) /* error or not equal */ - return cmp; - } - } - return 1; - } - -static PyObject * -dict_richcompare(PyObject *v, PyObject *w, int op) -{ - int cmp; - PyObject *res; - - if (!PyDict_Check(v) || !PyDict_Check(w)) { - res = Py_NotImplemented; - } - else if (op == Py_EQ || op == Py_NE) { - cmp = dict_equal((dictobject *)v, (dictobject *)w); - if (cmp < 0) - return NULL; - res = (cmp == (op == Py_EQ)) ? Py_True : Py_False; - } - else - res = Py_NotImplemented; - Py_INCREF(res); - return res; - } - -static PyObject * -dict_has_key(register dictobject *mp, PyObject *key) -{ - long hash; - register long ok; - if (!PyString_CheckExact(key) || - (hash = ((PyStringObject *) key)->ob_shash) == -1) { - hash = PyObject_Hash(key); - if (hash == -1) - return NULL; - } - ok = (mp->ma_lookup)(mp, key, hash)->me_value != NULL; - return PyBool_FromLong(ok); -} - -static PyObject * -dict_get(register dictobject *mp, PyObject *args) -{ - PyObject *key; - PyObject *failobj = Py_None; - PyObject *val = NULL; - long hash; - - if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &failobj)) - return NULL; - - if (!PyString_CheckExact(key) || - (hash = ((PyStringObject *) key)->ob_shash) == -1) { - hash = PyObject_Hash(key); - if (hash == -1) - return NULL; - } - val = (mp->ma_lookup)(mp, key, hash)->me_value; - - if (val == NULL) - val = failobj; - Py_INCREF(val); - return val; -} - - -static PyObject * -dict_setdefault(register dictobject *mp, PyObject *args) -{ - PyObject *key; - PyObject *failobj = Py_None; - PyObject *val = NULL; - long hash; - - if (!PyArg_UnpackTuple(args, "setdefault", 1, 2, &key, &failobj)) - return NULL; - - if (!PyString_CheckExact(key) || - (hash = ((PyStringObject *) key)->ob_shash) == -1) { - hash = PyObject_Hash(key); - if (hash == -1) - return NULL; - } - val = (mp->ma_lookup)(mp, key, hash)->me_value; - if (val == NULL) { - val = failobj; - if (PyDict_SetItem((PyObject*)mp, key, failobj)) - val = NULL; - } - Py_XINCREF(val); - return val; -} - - -static PyObject * -dict_clear(register dictobject *mp) -{ - PyDict_Clear((PyObject *)mp); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -dict_pop(dictobject *mp, PyObject *args) -{ - long hash; - dictentry *ep; - PyObject *old_value, *old_key; - PyObject *key, *deflt = NULL; - - if(!PyArg_UnpackTuple(args, "pop", 1, 2, &key, &deflt)) - return NULL; - if (mp->ma_used == 0) { - if (deflt) { - Py_INCREF(deflt); - return deflt; - } - PyErr_SetString(PyExc_KeyError, - "pop(): dictionary is empty"); - return NULL; - } - if (!PyString_CheckExact(key) || - (hash = ((PyStringObject *) key)->ob_shash) == -1) { - hash = PyObject_Hash(key); - if (hash == -1) - return NULL; - } - ep = (mp->ma_lookup)(mp, key, hash); - if (ep->me_value == NULL) { - if (deflt) { - Py_INCREF(deflt); - return deflt; - } - PyErr_SetObject(PyExc_KeyError, key); - return NULL; - } - old_key = ep->me_key; - Py_INCREF(dummy); - ep->me_key = dummy; - old_value = ep->me_value; - ep->me_value = NULL; - mp->ma_used--; - Py_DECREF(old_key); - return old_value; -} - -static PyObject * -dict_popitem(dictobject *mp) -{ - int i = 0; - dictentry *ep; - PyObject *res; - - /* Allocate the result tuple before checking the size. Believe it - * or not, this allocation could trigger a garbage collection which - * could empty the dict, so if we checked the size first and that - * happened, the result would be an infinite loop (searching for an - * entry that no longer exists). Note that the usual popitem() - * idiom is "while d: k, v = d.popitem()". so needing to throw the - * tuple away if the dict *is* empty isn't a significant - * inefficiency -- possible, but unlikely in practice. - */ - res = PyTuple_New(2); - if (res == NULL) - return NULL; - if (mp->ma_used == 0) { - Py_DECREF(res); - PyErr_SetString(PyExc_KeyError, - "popitem(): dictionary is empty"); - return NULL; - } - /* Set ep to "the first" dict entry with a value. We abuse the hash - * field of slot 0 to hold a search finger: - * If slot 0 has a value, use slot 0. - * Else slot 0 is being used to hold a search finger, - * and we use its hash value as the first index to look. - */ - ep = &mp->ma_table[0]; - if (ep->me_value == NULL) { - i = (int)ep->me_hash; - /* The hash field may be a real hash value, or it may be a - * legit search finger, or it may be a once-legit search - * finger that's out of bounds now because it wrapped around - * or the table shrunk -- simply make sure it's in bounds now. - */ - if (i > mp->ma_mask || i < 1) - i = 1; /* skip slot 0 */ - while ((ep = &mp->ma_table[i])->me_value == NULL) { - i++; - if (i > mp->ma_mask) - i = 1; - } - } - PyTuple_SET_ITEM(res, 0, ep->me_key); - PyTuple_SET_ITEM(res, 1, ep->me_value); - Py_INCREF(dummy); - ep->me_key = dummy; - ep->me_value = NULL; - mp->ma_used--; - assert(mp->ma_table[0].me_value == NULL); - mp->ma_table[0].me_hash = i + 1; /* next place to start */ - return res; -} - -static int -dict_traverse(PyObject *op, visitproc visit, void *arg) -{ - int i = 0, err; - PyObject *pk; - PyObject *pv; - - while (PyDict_Next(op, &i, &pk, &pv)) { - err = visit(pk, arg); - if (err) - return err; - err = visit(pv, arg); - if (err) - return err; - } - return 0; -} - -static int -dict_tp_clear(PyObject *op) -{ - PyDict_Clear(op); - return 0; -} - - -static PyObject *dictiter_new(dictobject *, binaryfunc); - -static PyObject * -select_key(PyObject *key, PyObject *value) -{ - Py_INCREF(key); - return key; -} - -static PyObject * -select_value(PyObject *key, PyObject *value) -{ - Py_INCREF(value); - return value; -} - -static PyObject * -select_item(PyObject *key, PyObject *value) -{ - PyObject *res = PyTuple_New(2); - - if (res != NULL) { - Py_INCREF(key); - Py_INCREF(value); - PyTuple_SET_ITEM(res, 0, key); - PyTuple_SET_ITEM(res, 1, value); - } - return res; -} - -static PyObject * -dict_iterkeys(dictobject *dict) -{ - return dictiter_new(dict, select_key); -} - -static PyObject * -dict_itervalues(dictobject *dict) -{ - return dictiter_new(dict, select_value); -} - -static PyObject * -dict_iteritems(dictobject *dict) -{ - return dictiter_new(dict, select_item); -} - - -PyDoc_STRVAR(has_key__doc__, -"D.has_key(k) -> True if D has a key k, else False"); - -PyDoc_STRVAR(get__doc__, -"D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None."); - -PyDoc_STRVAR(setdefault_doc__, -"D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D"); - -PyDoc_STRVAR(pop__doc__, -"D.pop(k[,d]) -> v, remove specified key and return the corresponding value\n\ -If key is not found, d is returned if given, otherwise KeyError is raised"); - -PyDoc_STRVAR(popitem__doc__, -"D.popitem() -> (k, v), remove and return some (key, value) pair as a\n\ -2-tuple; but raise KeyError if D is empty"); - -PyDoc_STRVAR(keys__doc__, -"D.keys() -> list of D's keys"); - -PyDoc_STRVAR(items__doc__, -"D.items() -> list of D's (key, value) pairs, as 2-tuples"); - -PyDoc_STRVAR(values__doc__, -"D.values() -> list of D's values"); - -PyDoc_STRVAR(update__doc__, -"D.update(E) -> None. Update D from E: for k in E.keys(): D[k] = E[k]"); - -PyDoc_STRVAR(fromkeys__doc__, -"dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.\n\ -v defaults to None."); - -PyDoc_STRVAR(clear__doc__, -"D.clear() -> None. Remove all items from D."); - -PyDoc_STRVAR(copy__doc__, -"D.copy() -> a shallow copy of D"); - -PyDoc_STRVAR(iterkeys__doc__, -"D.iterkeys() -> an iterator over the keys of D"); - -PyDoc_STRVAR(itervalues__doc__, -"D.itervalues() -> an iterator over the values of D"); - -PyDoc_STRVAR(iteritems__doc__, -"D.iteritems() -> an iterator over the (key, value) items of D"); - -static PyMethodDef mapp_methods[] = { - {"has_key", (PyCFunction)dict_has_key, METH_O, - has_key__doc__}, - {"get", (PyCFunction)dict_get, METH_VARARGS, - get__doc__}, - {"setdefault", (PyCFunction)dict_setdefault, METH_VARARGS, - setdefault_doc__}, - {"pop", (PyCFunction)dict_pop, METH_VARARGS, - pop__doc__}, - {"popitem", (PyCFunction)dict_popitem, METH_NOARGS, - popitem__doc__}, - {"keys", (PyCFunction)dict_keys, METH_NOARGS, - keys__doc__}, - {"items", (PyCFunction)dict_items, METH_NOARGS, - items__doc__}, - {"values", (PyCFunction)dict_values, METH_NOARGS, - values__doc__}, - {"update", (PyCFunction)dict_update, METH_O, - update__doc__}, - {"fromkeys", (PyCFunction)dict_fromkeys, METH_VARARGS | METH_CLASS, - fromkeys__doc__}, - {"clear", (PyCFunction)dict_clear, METH_NOARGS, - clear__doc__}, - {"copy", (PyCFunction)dict_copy, METH_NOARGS, - copy__doc__}, - {"iterkeys", (PyCFunction)dict_iterkeys, METH_NOARGS, - iterkeys__doc__}, - {"itervalues", (PyCFunction)dict_itervalues, METH_NOARGS, - itervalues__doc__}, - {"iteritems", (PyCFunction)dict_iteritems, METH_NOARGS, - iteritems__doc__}, - {NULL, NULL} /* sentinel */ -}; - -static int -dict_contains(dictobject *mp, PyObject *key) -{ - long hash; - - if (!PyString_CheckExact(key) || - (hash = ((PyStringObject *) key)->ob_shash) == -1) { - hash = PyObject_Hash(key); - if (hash == -1) - return -1; - } - return (mp->ma_lookup)(mp, key, hash)->me_value != NULL; -} - -/* Hack to implement "key in dict" */ -static PySequenceMethods dict_as_sequence = { - 0, /* sq_length */ - 0, /* sq_concat */ - 0, /* sq_repeat */ - 0, /* sq_item */ - 0, /* sq_slice */ - 0, /* sq_ass_item */ - 0, /* sq_ass_slice */ - (objobjproc)dict_contains, /* sq_contains */ - 0, /* sq_inplace_concat */ - 0, /* sq_inplace_repeat */ -}; - -static PyObject * -dict_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *self; - - assert(type != NULL && type->tp_alloc != NULL); - self = type->tp_alloc(type, 0); - if (self != NULL) { - PyDictObject *d = (PyDictObject *)self; - /* It's guaranteed that tp->alloc zeroed out the struct. */ - assert(d->ma_table == NULL && d->ma_fill == 0 && d->ma_used == 0); - INIT_NONZERO_DICT_SLOTS(d); - d->ma_lookup = lookdict_string; -#ifdef SHOW_CONVERSION_COUNTS - ++created; -#endif - } - return self; -} - -static int -dict_init(PyObject *self, PyObject *args, PyObject *kwds) -{ - PyObject *arg = NULL; - int result = 0; - - if (!PyArg_UnpackTuple(args, "dict", 0, 1, &arg)) - result = -1; - - else if (arg != NULL) { - if (PyObject_HasAttrString(arg, "keys")) - result = PyDict_Merge(self, arg, 1); - else - result = PyDict_MergeFromSeq2(self, arg, 1); - } - if (result == 0 && kwds != NULL) - result = PyDict_Merge(self, kwds, 1); - return result; -} - -static long -dict_nohash(PyObject *self) -{ - PyErr_SetString(PyExc_TypeError, "dict objects are unhashable"); - return -1; -} - -static PyObject * -dict_iter(dictobject *dict) -{ - return dictiter_new(dict, select_key); -} - -PyDoc_STRVAR(dictionary_doc, -"dict() -> new empty dictionary.\n" -"dict(mapping) -> new dictionary initialized from a mapping object's\n" -" (key, value) pairs.\n" -"dict(seq) -> new dictionary initialized as if via:\n" -" d = {}\n" -" for k, v in seq:\n" -" d[k] = v\n" -"dict(**kwargs) -> new dictionary initialized with the name=value pairs\n" -" in the keyword argument list. For example: dict(one=1, two=2)"); - -PyTypeObject PyDict_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "dict", - sizeof(dictobject), - 0, - (destructor)dict_dealloc, /* tp_dealloc */ - (printfunc)dict_print, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)dict_compare, /* tp_compare */ - (reprfunc)dict_repr, /* tp_repr */ - 0, /* tp_as_number */ - &dict_as_sequence, /* tp_as_sequence */ - &dict_as_mapping, /* tp_as_mapping */ - dict_nohash, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - dictionary_doc, /* tp_doc */ - (traverseproc)dict_traverse, /* tp_traverse */ - (inquiry)dict_tp_clear, /* tp_clear */ - dict_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc)dict_iter, /* tp_iter */ - 0, /* tp_iternext */ - mapp_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)dict_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - dict_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - -/* For backward compatibility with old dictionary interface */ - -PyObject * -PyDict_GetItemString(PyObject *v, const char *key) -{ - PyObject *kv, *rv; - kv = PyString_FromString(key); - if (kv == NULL) - return NULL; - rv = PyDict_GetItem(v, kv); - Py_DECREF(kv); - return rv; -} - -int -PyDict_SetItemString(PyObject *v, const char *key, PyObject *item) -{ - PyObject *kv; - int err; - kv = PyString_FromString(key); - if (kv == NULL) - return -1; - PyString_InternInPlace(&kv); /* XXX Should we really? */ - err = PyDict_SetItem(v, kv, item); - Py_DECREF(kv); - return err; -} - -int -PyDict_DelItemString(PyObject *v, const char *key) -{ - PyObject *kv; - int err; - kv = PyString_FromString(key); - if (kv == NULL) - return -1; - err = PyDict_DelItem(v, kv); - Py_DECREF(kv); - return err; -} - -/* Dictionary iterator type */ - -extern PyTypeObject PyDictIter_Type; /* Forward */ - -typedef struct { - PyObject_HEAD - dictobject *di_dict; /* Set to NULL when iterator is exhausted */ - int di_used; - int di_pos; - binaryfunc di_select; -} dictiterobject; - -static PyObject * -dictiter_new(dictobject *dict, binaryfunc select) -{ - dictiterobject *di; - di = PyObject_New(dictiterobject, &PyDictIter_Type); - if (di == NULL) - return NULL; - Py_INCREF(dict); - di->di_dict = dict; - di->di_used = dict->ma_used; - di->di_pos = 0; - di->di_select = select; - return (PyObject *)di; -} - -static void -dictiter_dealloc(dictiterobject *di) -{ - Py_XDECREF(di->di_dict); - PyObject_Del(di); -} - -static PyObject *dictiter_iternext(dictiterobject *di) -{ - PyObject *key, *value; - - if (di->di_dict == NULL) - return NULL; - - if (di->di_used != di->di_dict->ma_used) { - PyErr_SetString(PyExc_RuntimeError, - "dictionary changed size during iteration"); - di->di_used = -1; /* Make this state sticky */ - return NULL; - } - if (PyDict_Next((PyObject *)(di->di_dict), &di->di_pos, &key, &value)) - return (*di->di_select)(key, value); - - Py_DECREF(di->di_dict); - di->di_dict = NULL; - return NULL; -} - -PyTypeObject PyDictIter_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "dictionary-iterator", /* tp_name */ - sizeof(dictiterobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)dictiter_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - 0, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)dictiter_iternext, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/enumobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/enumobject.c deleted file mode 100644 index 9dec09cd..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/enumobject.c +++ /dev/null @@ -1,161 +0,0 @@ -/* enumerate object */ - -#include "Python.h" - -typedef struct { - PyObject_HEAD - long en_index; /* current index of enumeration */ - PyObject* en_sit; /* secondary iterator of enumeration */ - PyObject* en_result; /* result tuple */ -} enumobject; - -PyTypeObject PyEnum_Type; - -static PyObject * -enum_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - enumobject *en; - PyObject *seq = NULL; - static char *kwlist[] = {"sequence", 0}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:enumerate", kwlist, - &seq)) - return NULL; - - en = (enumobject *)type->tp_alloc(type, 0); - if (en == NULL) - return NULL; - en->en_index = 0; - en->en_sit = PyObject_GetIter(seq); - if (en->en_sit == NULL) { - Py_DECREF(en); - return NULL; - } - en->en_result = PyTuple_New(2); - if (en->en_result == NULL) { - Py_DECREF(en->en_sit); - Py_DECREF(en); - return NULL; - } - Py_INCREF(Py_None); - PyTuple_SET_ITEM(en->en_result, 0, Py_None); - Py_INCREF(Py_None); - PyTuple_SET_ITEM(en->en_result, 1, Py_None); - return (PyObject *)en; -} - -static void -enum_dealloc(enumobject *en) -{ - PyObject_GC_UnTrack(en); - Py_XDECREF(en->en_sit); - Py_XDECREF(en->en_result); - en->ob_type->tp_free(en); -} - -static int -enum_traverse(enumobject *en, visitproc visit, void *arg) -{ - int err; - - if (en->en_sit) { - err = visit(en->en_sit, arg); - if (err) - return err; - } - if (en->en_result) { - err = visit(en->en_result, arg); - if (err) - return err; - } - return 0; -} - -static PyObject * -enum_next(enumobject *en) -{ - PyObject *next_index; - PyObject *next_item; - PyObject *result = en->en_result; - PyObject *it = en->en_sit; - - next_item = (*it->ob_type->tp_iternext)(it); - if (next_item == NULL) - return NULL; - - next_index = PyInt_FromLong(en->en_index); - if (next_index == NULL) { - Py_DECREF(next_item); - return NULL; - } - en->en_index++; - - if (result->ob_refcnt == 1) { - Py_INCREF(result); - Py_DECREF(PyTuple_GET_ITEM(result, 0)); - Py_DECREF(PyTuple_GET_ITEM(result, 1)); - } else { - result = PyTuple_New(2); - if (result == NULL) { - Py_DECREF(next_index); - Py_DECREF(next_item); - return NULL; - } - } - PyTuple_SET_ITEM(result, 0, next_index); - PyTuple_SET_ITEM(result, 1, next_item); - return result; -} - -PyDoc_STRVAR(enum_doc, -"enumerate(iterable) -> iterator for index, value of iterable\n" -"\n" -"Return an enumerate object. iterable must be an other object that supports\n" -"iteration. The enumerate object yields pairs containing a count (from\n" -"zero) and a value yielded by the iterable argument. enumerate is useful\n" -"for obtaining an indexed list: (0, seq[0]), (1, seq[1]), (2, seq[2]), ..."); - -PyTypeObject PyEnum_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "enumerate", /* tp_name */ - sizeof(enumobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)enum_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - enum_doc, /* tp_doc */ - (traverseproc)enum_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)enum_next, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - enum_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/fileobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/fileobject.c deleted file mode 100644 index 2813f0d9..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/fileobject.c +++ /dev/null @@ -1,2402 +0,0 @@ -/* File object implementation */ - -#include "Python.h" -#include "structmember.h" - -#ifndef DONT_HAVE_SYS_TYPES_H -#include -#endif /* DONT_HAVE_SYS_TYPES_H */ - -#ifdef MS_WINDOWS -#define fileno _fileno -/* can simulate truncate with Win32 API functions; see file_truncate */ -#define HAVE_FTRUNCATE -#ifdef MS_XBOX -#include -#else -#define WIN32_LEAN_AND_MEAN -#include -#endif -#endif - -//#ifdef _MSC_VER -///* Need GetVersion to see if on NT so safe to use _wfopen */ -//#define WIN32_LEAN_AND_MEAN -//#include -//#endif /* _MSC_VER */ - -#ifdef macintosh -#ifdef USE_GUSI -#define HAVE_FTRUNCATE -#endif -#endif - -#ifdef __MWERKS__ -/* Mwerks fopen() doesn't always set errno */ -#define NO_FOPEN_ERRNO -#endif - -#if defined(PYOS_OS2) && defined(PYCC_GCC) -#include -#endif - -#define BUF(v) PyString_AS_STRING((PyStringObject *)v) - -#ifndef DONT_HAVE_ERRNO_H -#include -#endif - -#ifdef HAVE_GETC_UNLOCKED -#define GETC(f) getc_unlocked(f) -#define FLOCKFILE(f) flockfile(f) -#define FUNLOCKFILE(f) funlockfile(f) -#else -#define GETC(f) getc(f) -#define FLOCKFILE(f) -#define FUNLOCKFILE(f) -#endif - -#ifdef WITH_UNIVERSAL_NEWLINES -/* Bits in f_newlinetypes */ -#define NEWLINE_UNKNOWN 0 /* No newline seen, yet */ -#define NEWLINE_CR 1 /* \r newline seen */ -#define NEWLINE_LF 2 /* \n newline seen */ -#define NEWLINE_CRLF 4 /* \r\n newline seen */ -#endif - -FILE * -PyFile_AsFile(PyObject *f) -{ - if (f == NULL || !PyFile_Check(f)) - return NULL; - else - return ((PyFileObject *)f)->f_fp; -} - -PyObject * -PyFile_Name(PyObject *f) -{ - if (f == NULL || !PyFile_Check(f)) - return NULL; - else - return ((PyFileObject *)f)->f_name; -} - -/* On Unix, fopen will succeed for directories. - In Python, there should be no file objects referring to - directories, so we need a check. */ - -static PyFileObject* -dircheck(PyFileObject* f) -{ -#if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR) - struct stat buf; - if (f->f_fp == NULL) - return f; - if (fstat(fileno(f->f_fp), &buf) == 0 && - S_ISDIR(buf.st_mode)) { -#ifdef HAVE_STRERROR - char *msg = strerror(EISDIR); -#else - char *msg = "Is a directory"; -#endif - PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(is)", - EISDIR, msg); - PyErr_SetObject(PyExc_IOError, exc); - Py_XDECREF(exc); - return NULL; - } -#endif - return f; -} - - -static PyObject * -fill_file_fields(PyFileObject *f, FILE *fp, char *name, char *mode, - int (*close)(FILE *), PyObject *wname) -{ - assert(f != NULL); - assert(PyFile_Check(f)); - assert(f->f_fp == NULL); - - Py_DECREF(f->f_name); - Py_DECREF(f->f_mode); - Py_DECREF(f->f_encoding); -#ifdef Py_USING_UNICODE - if (wname) - f->f_name = PyUnicode_FromObject(wname); - else -#endif - f->f_name = PyString_FromString(name); - f->f_mode = PyString_FromString(mode); - - f->f_close = close; - f->f_softspace = 0; - f->f_binary = strchr(mode,'b') != NULL; - f->f_buf = NULL; -#ifdef WITH_UNIVERSAL_NEWLINES - f->f_univ_newline = (strchr(mode, 'U') != NULL); - f->f_newlinetypes = NEWLINE_UNKNOWN; - f->f_skipnextlf = 0; -#endif - Py_INCREF(Py_None); - f->f_encoding = Py_None; - - if (f->f_name == NULL || f->f_mode == NULL) - return NULL; - f->f_fp = fp; - f = dircheck(f); - return (PyObject *) f; -} - -static PyObject * -open_the_file(PyFileObject *f, char *name, char *mode) -{ - assert(f != NULL); - assert(PyFile_Check(f)); -#ifdef MS_WINDOWS - /* windows ignores the passed name in order to support Unicode */ - assert(f->f_name != NULL); -#else - assert(name != NULL); -#endif - assert(mode != NULL); - assert(f->f_fp == NULL); - - /* rexec.py can't stop a user from getting the file() constructor -- - all they have to do is get *any* file object f, and then do - type(f). Here we prevent them from doing damage with it. */ - if (PyEval_GetRestricted()) { - PyErr_SetString(PyExc_IOError, - "file() constructor not accessible in restricted mode"); - return NULL; - } - errno = 0; -#ifdef HAVE_FOPENRF - if (*mode == '*') { - FILE *fopenRF(); - f->f_fp = fopenRF(name, mode+1); - } - else -#endif - { -#ifdef WITH_UNIVERSAL_NEWLINES - if (strcmp(mode, "U") == 0 || strcmp(mode, "rU") == 0) - mode = "rb"; -#else - /* Compatibility: specifying U in a Python without universal - ** newlines is allowed, and the file is opened as a normal text - ** file. - */ - if (strcmp(mode, "U") == 0 || strcmp(mode, "rU") == 0) - mode = "r"; -#endif -#ifdef MS_WINDOWS - if (PyUnicode_Check(f->f_name)) { - PyObject *wmode; - wmode = PyUnicode_DecodeASCII(mode, strlen(mode), NULL); - if (f->f_name && wmode) { - Py_BEGIN_ALLOW_THREADS - /* PyUnicode_AS_UNICODE OK without thread - lock as it is a simple dereference. */ - f->f_fp = _wfopen(PyUnicode_AS_UNICODE(f->f_name), - PyUnicode_AS_UNICODE(wmode)); - Py_END_ALLOW_THREADS - } - Py_XDECREF(wmode); - } -#endif - if (NULL == f->f_fp && NULL != name) { - Py_BEGIN_ALLOW_THREADS - f->f_fp = fopen(name, mode); - Py_END_ALLOW_THREADS - } - } - if (f->f_fp == NULL) { -#ifdef NO_FOPEN_ERRNO - /* Metroworks only, wich does not always sets errno */ - if (errno == 0) { - PyObject *v; - v = Py_BuildValue("(is)", 0, "Cannot open file"); - if (v != NULL) { - PyErr_SetObject(PyExc_IOError, v); - Py_DECREF(v); - } - return NULL; - } -#endif -#ifdef _MSC_VER - /* MSVC 6 (Microsoft) leaves errno at 0 for bad mode strings, - * across all Windows flavors. When it sets EINVAL varies - * across Windows flavors, the exact conditions aren't - * documented, and the answer lies in the OS's implementation - * of Win32's CreateFile function (whose source is secret). - * Seems the best we can do is map EINVAL to ENOENT. - */ - if (errno == 0) /* bad mode string */ - errno = EINVAL; - else if (errno == EINVAL) /* unknown, but not a mode string */ - errno = ENOENT; -#endif - if (errno == EINVAL) - PyErr_Format(PyExc_IOError, "invalid mode: %s", - mode); - else -#ifdef MS_WINDOWS - PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, f->f_name); -#else - PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); -#endif /* MS_WINDOWS */ - f = NULL; - } - if (f != NULL) - f = dircheck(f); - return (PyObject *)f; -} - -PyObject * -PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *)) -{ - PyFileObject *f = (PyFileObject *)PyFile_Type.tp_new(&PyFile_Type, - NULL, NULL); - if (f != NULL) { - if (fill_file_fields(f, fp, name, mode, close, NULL) == NULL) { - Py_DECREF(f); - f = NULL; - } - } - return (PyObject *) f; -} - -PyObject * -PyFile_FromString(char *name, char *mode) -{ - extern int fclose(FILE *); - PyFileObject *f; - - f = (PyFileObject *)PyFile_FromFile((FILE *)NULL, name, mode, fclose); - if (f != NULL) { - if (open_the_file(f, name, mode) == NULL) { - Py_DECREF(f); - f = NULL; - } - } - return (PyObject *)f; -} - -void -PyFile_SetBufSize(PyObject *f, int bufsize) -{ - PyFileObject *file = (PyFileObject *)f; - if (bufsize >= 0) { - int type; - switch (bufsize) { - case 0: - type = _IONBF; - break; -#ifdef HAVE_SETVBUF - case 1: - type = _IOLBF; - bufsize = BUFSIZ; - break; -#endif - default: - type = _IOFBF; -#ifndef HAVE_SETVBUF - bufsize = BUFSIZ; -#endif - break; - } - fflush(file->f_fp); - if (type == _IONBF) { - PyMem_Free(file->f_setbuf); - file->f_setbuf = NULL; - } else { - file->f_setbuf = PyMem_Realloc(file->f_setbuf, bufsize); - } -#ifdef HAVE_SETVBUF - setvbuf(file->f_fp, file->f_setbuf, type, bufsize); -#else /* !HAVE_SETVBUF */ - setbuf(file->f_fp, file->f_setbuf); -#endif /* !HAVE_SETVBUF */ - } -} - -/* Set the encoding used to output Unicode strings. - Returh 1 on success, 0 on failure. */ - -int -PyFile_SetEncoding(PyObject *f, const char *enc) -{ - PyFileObject *file = (PyFileObject*)f; - PyObject *str = PyString_FromString(enc); - if (!str) - return 0; - Py_DECREF(file->f_encoding); - file->f_encoding = str; - return 1; -} - -static PyObject * -err_closed(void) -{ - PyErr_SetString(PyExc_ValueError, "I/O operation on closed file"); - return NULL; -} - -static void drop_readahead(PyFileObject *); - -/* Methods */ - -static void -file_dealloc(PyFileObject *f) -{ - if (f->f_fp != NULL && f->f_close != NULL) { - Py_BEGIN_ALLOW_THREADS - (*f->f_close)(f->f_fp); - Py_END_ALLOW_THREADS - } - Py_XDECREF(f->f_name); - Py_XDECREF(f->f_mode); - Py_XDECREF(f->f_encoding); - drop_readahead(f); - f->ob_type->tp_free((PyObject *)f); -} - -static PyObject * -file_repr(PyFileObject *f) -{ - if (PyUnicode_Check(f->f_name)) { -#ifdef Py_USING_UNICODE - PyObject *ret = NULL; - PyObject *name; - name = PyUnicode_AsUnicodeEscapeString(f->f_name); - ret = PyString_FromFormat("<%s file u'%s', mode '%s' at %p>", - f->f_fp == NULL ? "closed" : "open", - PyString_AsString(name), - PyString_AsString(f->f_mode), - f); - Py_XDECREF(name); - return ret; -#endif - } else { - return PyString_FromFormat("<%s file '%s', mode '%s' at %p>", - f->f_fp == NULL ? "closed" : "open", - PyString_AsString(f->f_name), - PyString_AsString(f->f_mode), - f); - } -} - -static PyObject * -file_close(PyFileObject *f) -{ - int sts = 0; - if (f->f_fp != NULL) { - if (f->f_close != NULL) { - Py_BEGIN_ALLOW_THREADS - errno = 0; - sts = (*f->f_close)(f->f_fp); - Py_END_ALLOW_THREADS - } - f->f_fp = NULL; - } - PyMem_Free(f->f_setbuf); - if (sts == EOF) - return PyErr_SetFromErrno(PyExc_IOError); - if (sts != 0) - return PyInt_FromLong((long)sts); - Py_INCREF(Py_None); - return Py_None; -} - - -/* Our very own off_t-like type, 64-bit if possible */ -#if !defined(HAVE_LARGEFILE_SUPPORT) -typedef off_t Py_off_t; -#elif SIZEOF_OFF_T >= 8 -typedef off_t Py_off_t; -#elif SIZEOF_FPOS_T >= 8 -typedef fpos_t Py_off_t; -#else -#error "Large file support, but neither off_t nor fpos_t is large enough." -#endif - - -/* a portable fseek() function - return 0 on success, non-zero on failure (with errno set) */ -static int -_portable_fseek(FILE *fp, Py_off_t offset, int whence) -{ -#if !defined(HAVE_LARGEFILE_SUPPORT) - return fseek(fp, offset, whence); -#elif defined(HAVE_FSEEKO) && SIZEOF_OFF_T >= 8 - return fseeko(fp, offset, whence); -#elif defined(HAVE_FSEEK64) - return fseek64(fp, offset, whence); -#elif defined(__BEOS__) - return _fseek(fp, offset, whence); -#elif SIZEOF_FPOS_T >= 8 - /* lacking a 64-bit capable fseek(), use a 64-bit capable fsetpos() - and fgetpos() to implement fseek()*/ - fpos_t pos; - switch (whence) { - case SEEK_END: -#ifdef MS_WINDOWS - fflush(fp); - if (_lseeki64(fileno(fp), 0, 2) == -1) - return -1; -#else - if (fseek(fp, 0, SEEK_END) != 0) - return -1; -#endif - /* fall through */ - case SEEK_CUR: - if (fgetpos(fp, &pos) != 0) - return -1; - offset += pos; - break; - /* case SEEK_SET: break; */ - } - return fsetpos(fp, &offset); -#else -#error "Large file support, but no way to fseek." -#endif -} - - -/* a portable ftell() function - Return -1 on failure with errno set appropriately, current file - position on success */ -static Py_off_t -_portable_ftell(FILE* fp) -{ -#if !defined(HAVE_LARGEFILE_SUPPORT) - return ftell(fp); -#elif defined(HAVE_FTELLO) && SIZEOF_OFF_T >= 8 - return ftello(fp); -#elif defined(HAVE_FTELL64) - return ftell64(fp); -#elif SIZEOF_FPOS_T >= 8 - fpos_t pos; - if (fgetpos(fp, &pos) != 0) - return -1; - return pos; -#else -#error "Large file support, but no way to ftell." -#endif -} - - -static PyObject * -file_seek(PyFileObject *f, PyObject *args) -{ - int whence; - int ret; - Py_off_t offset; - PyObject *offobj; - - if (f->f_fp == NULL) - return err_closed(); - drop_readahead(f); - whence = 0; - if (!PyArg_ParseTuple(args, "O|i:seek", &offobj, &whence)) - return NULL; -#if !defined(HAVE_LARGEFILE_SUPPORT) - offset = PyInt_AsLong(offobj); -#else - offset = PyLong_Check(offobj) ? - PyLong_AsLongLong(offobj) : PyInt_AsLong(offobj); -#endif - if (PyErr_Occurred()) - return NULL; - - Py_BEGIN_ALLOW_THREADS - errno = 0; - ret = _portable_fseek(f->f_fp, offset, whence); - Py_END_ALLOW_THREADS - - if (ret != 0) { - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - return NULL; - } -#ifdef WITH_UNIVERSAL_NEWLINES - f->f_skipnextlf = 0; -#endif - Py_INCREF(Py_None); - return Py_None; -} - - -#ifdef HAVE_FTRUNCATE -static PyObject * -file_truncate(PyFileObject *f, PyObject *args) -{ - int ret; - Py_off_t newsize; - PyObject *newsizeobj; - - if (f->f_fp == NULL) - return err_closed(); - newsizeobj = NULL; - if (!PyArg_UnpackTuple(args, "truncate", 0, 1, &newsizeobj)) - return NULL; - - /* Set newsize to current postion if newsizeobj NULL, else to the - specified value. */ - if (newsizeobj != NULL) { -#if !defined(HAVE_LARGEFILE_SUPPORT) - newsize = PyInt_AsLong(newsizeobj); -#else - newsize = PyLong_Check(newsizeobj) ? - PyLong_AsLongLong(newsizeobj) : - PyInt_AsLong(newsizeobj); -#endif - if (PyErr_Occurred()) - return NULL; - } - else { - /* Default to current position. */ - Py_BEGIN_ALLOW_THREADS - errno = 0; - newsize = _portable_ftell(f->f_fp); - Py_END_ALLOW_THREADS - if (newsize == -1) - goto onioerror; - } - - /* Flush the file. */ - Py_BEGIN_ALLOW_THREADS - errno = 0; - ret = fflush(f->f_fp); - Py_END_ALLOW_THREADS - if (ret != 0) - goto onioerror; - -#ifdef MS_WINDOWS - /* MS _chsize doesn't work if newsize doesn't fit in 32 bits, - so don't even try using it. */ - { - Py_off_t current; /* current file position */ - HANDLE hFile; - int error; - - /* current <- current file postion. */ - if (newsizeobj == NULL) - current = newsize; - else { - Py_BEGIN_ALLOW_THREADS - errno = 0; - current = _portable_ftell(f->f_fp); - Py_END_ALLOW_THREADS - if (current == -1) - goto onioerror; - } - - /* Move to newsize. */ - if (current != newsize) { - Py_BEGIN_ALLOW_THREADS - errno = 0; - error = _portable_fseek(f->f_fp, newsize, SEEK_SET) - != 0; - Py_END_ALLOW_THREADS - if (error) - goto onioerror; - } - - /* Truncate. Note that this may grow the file! */ - Py_BEGIN_ALLOW_THREADS - errno = 0; - hFile = (HANDLE)_get_osfhandle(fileno(f->f_fp)); - error = hFile == (HANDLE)-1; - if (!error) { - error = SetEndOfFile(hFile) == 0; - if (error) - errno = EACCES; - } - Py_END_ALLOW_THREADS - if (error) - goto onioerror; - - /* Restore original file position. */ - if (current != newsize) { - Py_BEGIN_ALLOW_THREADS - errno = 0; - error = _portable_fseek(f->f_fp, current, SEEK_SET) - != 0; - Py_END_ALLOW_THREADS - if (error) - goto onioerror; - } - } -#else - Py_BEGIN_ALLOW_THREADS - errno = 0; - ret = ftruncate(fileno(f->f_fp), newsize); - Py_END_ALLOW_THREADS - if (ret != 0) goto onioerror; -#endif /* !MS_WINDOWS */ - - Py_INCREF(Py_None); - return Py_None; - -onioerror: - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - return NULL; -} -#endif /* HAVE_FTRUNCATE */ - -static PyObject * -file_tell(PyFileObject *f) -{ - Py_off_t pos; - - if (f->f_fp == NULL) - return err_closed(); - Py_BEGIN_ALLOW_THREADS - errno = 0; - pos = _portable_ftell(f->f_fp); - Py_END_ALLOW_THREADS - if (pos == -1) { - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - return NULL; - } -#ifdef WITH_UNIVERSAL_NEWLINES - if (f->f_skipnextlf) { - int c; - c = GETC(f->f_fp); - if (c == '\n') { - pos++; - f->f_skipnextlf = 0; - } else if (c != EOF) ungetc(c, f->f_fp); - } -#endif -#if !defined(HAVE_LARGEFILE_SUPPORT) - return PyInt_FromLong(pos); -#else - return PyLong_FromLongLong(pos); -#endif -} - -static PyObject * -file_fileno(PyFileObject *f) -{ - if (f->f_fp == NULL) - return err_closed(); - return PyInt_FromLong((long) fileno(f->f_fp)); -} - -static PyObject * -file_flush(PyFileObject *f) -{ - int res; - - if (f->f_fp == NULL) - return err_closed(); - Py_BEGIN_ALLOW_THREADS - errno = 0; - res = fflush(f->f_fp); - Py_END_ALLOW_THREADS - if (res != 0) { - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -file_isatty(PyFileObject *f) -{ - long res; - if (f->f_fp == NULL) - return err_closed(); - Py_BEGIN_ALLOW_THREADS - res = isatty((int)fileno(f->f_fp)); - Py_END_ALLOW_THREADS - return PyBool_FromLong(res); -} - - -#if BUFSIZ < 8192 -#define SMALLCHUNK 8192 -#else -#define SMALLCHUNK BUFSIZ -#endif - -#if SIZEOF_INT < 4 -#define BIGCHUNK (512 * 32) -#else -#define BIGCHUNK (512 * 1024) -#endif - -static size_t -new_buffersize(PyFileObject *f, size_t currentsize) -{ -#ifdef HAVE_FSTAT - off_t pos, end; - struct stat st; - if (fstat(fileno(f->f_fp), &st) == 0) { - end = st.st_size; - /* The following is not a bug: we really need to call lseek() - *and* ftell(). The reason is that some stdio libraries - mistakenly flush their buffer when ftell() is called and - the lseek() call it makes fails, thereby throwing away - data that cannot be recovered in any way. To avoid this, - we first test lseek(), and only call ftell() if lseek() - works. We can't use the lseek() value either, because we - need to take the amount of buffered data into account. - (Yet another reason why stdio stinks. :-) */ -#ifdef USE_GUSI2 - pos = lseek(fileno(f->f_fp), 1L, SEEK_CUR); - pos = lseek(fileno(f->f_fp), -1L, SEEK_CUR); -#else - pos = lseek(fileno(f->f_fp), 0L, SEEK_CUR); -#endif - if (pos >= 0) { - pos = ftell(f->f_fp); - } - if (pos < 0) - clearerr(f->f_fp); - if (end > pos && pos >= 0) - return currentsize + end - pos + 1; - /* Add 1 so if the file were to grow we'd notice. */ - } -#endif - if (currentsize > SMALLCHUNK) { - /* Keep doubling until we reach BIGCHUNK; - then keep adding BIGCHUNK. */ - if (currentsize <= BIGCHUNK) - return currentsize + currentsize; - else - return currentsize + BIGCHUNK; - } - return currentsize + SMALLCHUNK; -} - -#if defined(EWOULDBLOCK) && defined(EAGAIN) && EWOULDBLOCK != EAGAIN -#define BLOCKED_ERRNO(x) ((x) == EWOULDBLOCK || (x) == EAGAIN) -#else -#ifdef EWOULDBLOCK -#define BLOCKED_ERRNO(x) ((x) == EWOULDBLOCK) -#else -#ifdef EAGAIN -#define BLOCKED_ERRNO(x) ((x) == EAGAIN) -#else -#define BLOCKED_ERRNO(x) 0 -#endif -#endif -#endif - -static PyObject * -file_read(PyFileObject *f, PyObject *args) -{ - long bytesrequested = -1; - size_t bytesread, buffersize, chunksize; - PyObject *v; - - if (f->f_fp == NULL) - return err_closed(); - if (!PyArg_ParseTuple(args, "|l:read", &bytesrequested)) - return NULL; - if (bytesrequested < 0) - buffersize = new_buffersize(f, (size_t)0); - else - buffersize = bytesrequested; - if (buffersize > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "requested number of bytes is more than a Python string can hold"); - return NULL; - } - v = PyString_FromStringAndSize((char *)NULL, buffersize); - if (v == NULL) - return NULL; - bytesread = 0; - for (;;) { - Py_BEGIN_ALLOW_THREADS - errno = 0; - chunksize = Py_UniversalNewlineFread(BUF(v) + bytesread, - buffersize - bytesread, f->f_fp, (PyObject *)f); - Py_END_ALLOW_THREADS - if (chunksize == 0) { - if (!ferror(f->f_fp)) - break; - clearerr(f->f_fp); - /* When in non-blocking mode, data shouldn't - * be discarded if a blocking signal was - * received. That will also happen if - * chunksize != 0, but bytesread < buffersize. */ - if (bytesread > 0 && BLOCKED_ERRNO(errno)) - break; - PyErr_SetFromErrno(PyExc_IOError); - Py_DECREF(v); - return NULL; - } - bytesread += chunksize; - if (bytesread < buffersize) { - clearerr(f->f_fp); - break; - } - if (bytesrequested < 0) { - buffersize = new_buffersize(f, buffersize); - if (_PyString_Resize(&v, buffersize) < 0) - return NULL; - } else { - /* Got what was requested. */ - break; - } - } - if (bytesread != buffersize) - _PyString_Resize(&v, bytesread); - return v; -} - -static PyObject * -file_readinto(PyFileObject *f, PyObject *args) -{ - char *ptr; - int ntodo; - size_t ndone, nnow; - - if (f->f_fp == NULL) - return err_closed(); - if (!PyArg_ParseTuple(args, "w#", &ptr, &ntodo)) - return NULL; - ndone = 0; - while (ntodo > 0) { - Py_BEGIN_ALLOW_THREADS - errno = 0; - nnow = Py_UniversalNewlineFread(ptr+ndone, ntodo, f->f_fp, - (PyObject *)f); - Py_END_ALLOW_THREADS - if (nnow == 0) { - if (!ferror(f->f_fp)) - break; - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - return NULL; - } - ndone += nnow; - ntodo -= nnow; - } - return PyInt_FromLong((long)ndone); -} - -/************************************************************************** -Routine to get next line using platform fgets(). - -Under MSVC 6: - -+ MS threadsafe getc is very slow (multiple layers of function calls before+ - after each character, to lock+unlock the stream). -+ The stream-locking functions are MS-internal -- can't access them from user - code. -+ There's nothing Tim could find in the MS C or platform SDK libraries that - can worm around this. -+ MS fgets locks/unlocks only once per line; it's the only hook we have. - -So we use fgets for speed(!), despite that it's painful. - -MS realloc is also slow. - -Reports from other platforms on this method vs getc_unlocked (which MS doesn't -have): - Linux a wash - Solaris a wash - Tru64 Unix getline_via_fgets significantly faster - -CAUTION: The C std isn't clear about this: in those cases where fgets -writes something into the buffer, can it write into any position beyond the -required trailing null byte? MSVC 6 fgets does not, and no platform is (yet) -known on which it does; and it would be a strange way to code fgets. Still, -getline_via_fgets may not work correctly if it does. The std test -test_bufio.py should fail if platform fgets() routinely writes beyond the -trailing null byte. #define DONT_USE_FGETS_IN_GETLINE to disable this code. -**************************************************************************/ - -/* Use this routine if told to, or by default on non-get_unlocked() - * platforms unless told not to. Yikes! Let's spell that out: - * On a platform with getc_unlocked(): - * By default, use getc_unlocked(). - * If you want to use fgets() instead, #define USE_FGETS_IN_GETLINE. - * On a platform without getc_unlocked(): - * By default, use fgets(). - * If you don't want to use fgets(), #define DONT_USE_FGETS_IN_GETLINE. - */ -#if !defined(USE_FGETS_IN_GETLINE) && !defined(HAVE_GETC_UNLOCKED) -#define USE_FGETS_IN_GETLINE -#endif - -#if defined(DONT_USE_FGETS_IN_GETLINE) && defined(USE_FGETS_IN_GETLINE) -#undef USE_FGETS_IN_GETLINE -#endif - -#ifdef USE_FGETS_IN_GETLINE -static PyObject* -getline_via_fgets(FILE *fp) -{ -/* INITBUFSIZE is the maximum line length that lets us get away with the fast - * no-realloc, one-fgets()-call path. Boosting it isn't free, because we have - * to fill this much of the buffer with a known value in order to figure out - * how much of the buffer fgets() overwrites. So if INITBUFSIZE is larger - * than "most" lines, we waste time filling unused buffer slots. 100 is - * surely adequate for most peoples' email archives, chewing over source code, - * etc -- "regular old text files". - * MAXBUFSIZE is the maximum line length that lets us get away with the less - * fast (but still zippy) no-realloc, two-fgets()-call path. See above for - * cautions about boosting that. 300 was chosen because the worst real-life - * text-crunching job reported on Python-Dev was a mail-log crawler where over - * half the lines were 254 chars. - */ -#define INITBUFSIZE 100 -#define MAXBUFSIZE 300 - char* p; /* temp */ - char buf[MAXBUFSIZE]; - PyObject* v; /* the string object result */ - char* pvfree; /* address of next free slot */ - char* pvend; /* address one beyond last free slot */ - size_t nfree; /* # of free buffer slots; pvend-pvfree */ - size_t total_v_size; /* total # of slots in buffer */ - size_t increment; /* amount to increment the buffer */ - - /* Optimize for normal case: avoid _PyString_Resize if at all - * possible via first reading into stack buffer "buf". - */ - total_v_size = INITBUFSIZE; /* start small and pray */ - pvfree = buf; - for (;;) { - Py_BEGIN_ALLOW_THREADS - pvend = buf + total_v_size; - nfree = pvend - pvfree; - memset(pvfree, '\n', nfree); - p = fgets(pvfree, nfree, fp); - Py_END_ALLOW_THREADS - - if (p == NULL) { - clearerr(fp); - if (PyErr_CheckSignals()) - return NULL; - v = PyString_FromStringAndSize(buf, pvfree - buf); - return v; - } - /* fgets read *something* */ - p = memchr(pvfree, '\n', nfree); - if (p != NULL) { - /* Did the \n come from fgets or from us? - * Since fgets stops at the first \n, and then writes - * \0, if it's from fgets a \0 must be next. But if - * that's so, it could not have come from us, since - * the \n's we filled the buffer with have only more - * \n's to the right. - */ - if (p+1 < pvend && *(p+1) == '\0') { - /* It's from fgets: we win! In particular, - * we haven't done any mallocs yet, and can - * build the final result on the first try. - */ - ++p; /* include \n from fgets */ - } - else { - /* Must be from us: fgets didn't fill the - * buffer and didn't find a newline, so it - * must be the last and newline-free line of - * the file. - */ - assert(p > pvfree && *(p-1) == '\0'); - --p; /* don't include \0 from fgets */ - } - v = PyString_FromStringAndSize(buf, p - buf); - return v; - } - /* yuck: fgets overwrote all the newlines, i.e. the entire - * buffer. So this line isn't over yet, or maybe it is but - * we're exactly at EOF. If we haven't already, try using the - * rest of the stack buffer. - */ - assert(*(pvend-1) == '\0'); - if (pvfree == buf) { - pvfree = pvend - 1; /* overwrite trailing null */ - total_v_size = MAXBUFSIZE; - } - else - break; - } - - /* The stack buffer isn't big enough; malloc a string object and read - * into its buffer. - */ - total_v_size = MAXBUFSIZE << 1; - v = PyString_FromStringAndSize((char*)NULL, (int)total_v_size); - if (v == NULL) - return v; - /* copy over everything except the last null byte */ - memcpy(BUF(v), buf, MAXBUFSIZE-1); - pvfree = BUF(v) + MAXBUFSIZE - 1; - - /* Keep reading stuff into v; if it ever ends successfully, break - * after setting p one beyond the end of the line. The code here is - * very much like the code above, except reads into v's buffer; see - * the code above for detailed comments about the logic. - */ - for (;;) { - Py_BEGIN_ALLOW_THREADS - pvend = BUF(v) + total_v_size; - nfree = pvend - pvfree; - memset(pvfree, '\n', nfree); - p = fgets(pvfree, nfree, fp); - Py_END_ALLOW_THREADS - - if (p == NULL) { - clearerr(fp); - if (PyErr_CheckSignals()) { - Py_DECREF(v); - return NULL; - } - p = pvfree; - break; - } - p = memchr(pvfree, '\n', nfree); - if (p != NULL) { - if (p+1 < pvend && *(p+1) == '\0') { - /* \n came from fgets */ - ++p; - break; - } - /* \n came from us; last line of file, no newline */ - assert(p > pvfree && *(p-1) == '\0'); - --p; - break; - } - /* expand buffer and try again */ - assert(*(pvend-1) == '\0'); - increment = total_v_size >> 2; /* mild exponential growth */ - total_v_size += increment; - if (total_v_size > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "line is longer than a Python string can hold"); - Py_DECREF(v); - return NULL; - } - if (_PyString_Resize(&v, (int)total_v_size) < 0) - return NULL; - /* overwrite the trailing null byte */ - pvfree = BUF(v) + (total_v_size - increment - 1); - } - if (BUF(v) + total_v_size != p) - _PyString_Resize(&v, p - BUF(v)); - return v; -#undef INITBUFSIZE -#undef MAXBUFSIZE -} -#endif /* ifdef USE_FGETS_IN_GETLINE */ - -/* Internal routine to get a line. - Size argument interpretation: - > 0: max length; - <= 0: read arbitrary line -*/ - -static PyObject * -get_line(PyFileObject *f, int n) -{ - FILE *fp = f->f_fp; - int c; - char *buf, *end; - size_t total_v_size; /* total # of slots in buffer */ - size_t used_v_size; /* # used slots in buffer */ - size_t increment; /* amount to increment the buffer */ - PyObject *v; -#ifdef WITH_UNIVERSAL_NEWLINES - int newlinetypes = f->f_newlinetypes; - int skipnextlf = f->f_skipnextlf; - int univ_newline = f->f_univ_newline; -#endif - -#if defined(USE_FGETS_IN_GETLINE) -#ifdef WITH_UNIVERSAL_NEWLINES - if (n <= 0 && !univ_newline ) -#else - if (n <= 0) -#endif - return getline_via_fgets(fp); -#endif - total_v_size = n > 0 ? n : 100; - v = PyString_FromStringAndSize((char *)NULL, total_v_size); - if (v == NULL) - return NULL; - buf = BUF(v); - end = buf + total_v_size; - - for (;;) { - Py_BEGIN_ALLOW_THREADS - FLOCKFILE(fp); -#ifdef WITH_UNIVERSAL_NEWLINES - if (univ_newline) { - c = 'x'; /* Shut up gcc warning */ - while ( buf != end && (c = GETC(fp)) != EOF ) { - if (skipnextlf ) { - skipnextlf = 0; - if (c == '\n') { - /* Seeing a \n here with - * skipnextlf true means we - * saw a \r before. - */ - newlinetypes |= NEWLINE_CRLF; - c = GETC(fp); - if (c == EOF) break; - } else { - newlinetypes |= NEWLINE_CR; - } - } - if (c == '\r') { - skipnextlf = 1; - c = '\n'; - } else if ( c == '\n') - newlinetypes |= NEWLINE_LF; - *buf++ = c; - if (c == '\n') break; - } - if ( c == EOF && skipnextlf ) - newlinetypes |= NEWLINE_CR; - } else /* If not universal newlines use the normal loop */ -#endif - while ((c = GETC(fp)) != EOF && - (*buf++ = c) != '\n' && - buf != end) - ; - FUNLOCKFILE(fp); - Py_END_ALLOW_THREADS -#ifdef WITH_UNIVERSAL_NEWLINES - f->f_newlinetypes = newlinetypes; - f->f_skipnextlf = skipnextlf; -#endif - if (c == '\n') - break; - if (c == EOF) { - if (ferror(fp)) { - PyErr_SetFromErrno(PyExc_IOError); - clearerr(fp); - Py_DECREF(v); - return NULL; - } - clearerr(fp); - if (PyErr_CheckSignals()) { - Py_DECREF(v); - return NULL; - } - break; - } - /* Must be because buf == end */ - if (n > 0) - break; - used_v_size = total_v_size; - increment = total_v_size >> 2; /* mild exponential growth */ - total_v_size += increment; - if (total_v_size > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "line is longer than a Python string can hold"); - Py_DECREF(v); - return NULL; - } - if (_PyString_Resize(&v, total_v_size) < 0) - return NULL; - buf = BUF(v) + used_v_size; - end = BUF(v) + total_v_size; - } - - used_v_size = buf - BUF(v); - if (used_v_size != total_v_size) - _PyString_Resize(&v, used_v_size); - return v; -} - -/* External C interface */ - -PyObject * -PyFile_GetLine(PyObject *f, int n) -{ - PyObject *result; - - if (f == NULL) { - PyErr_BadInternalCall(); - return NULL; - } - - if (PyFile_Check(f)) { - if (((PyFileObject*)f)->f_fp == NULL) - return err_closed(); - result = get_line((PyFileObject *)f, n); - } - else { - PyObject *reader; - PyObject *args; - - reader = PyObject_GetAttrString(f, "readline"); - if (reader == NULL) - return NULL; - if (n <= 0) - args = Py_BuildValue("()"); - else - args = Py_BuildValue("(i)", n); - if (args == NULL) { - Py_DECREF(reader); - return NULL; - } - result = PyEval_CallObject(reader, args); - Py_DECREF(reader); - Py_DECREF(args); - if (result != NULL && !PyString_Check(result) && - !PyUnicode_Check(result)) { - Py_DECREF(result); - result = NULL; - PyErr_SetString(PyExc_TypeError, - "object.readline() returned non-string"); - } - } - - if (n < 0 && result != NULL && PyString_Check(result)) { - char *s = PyString_AS_STRING(result); - int len = PyString_GET_SIZE(result); - if (len == 0) { - Py_DECREF(result); - result = NULL; - PyErr_SetString(PyExc_EOFError, - "EOF when reading a line"); - } - else if (s[len-1] == '\n') { - if (result->ob_refcnt == 1) - _PyString_Resize(&result, len-1); - else { - PyObject *v; - v = PyString_FromStringAndSize(s, len-1); - Py_DECREF(result); - result = v; - } - } - } -#ifdef Py_USING_UNICODE - if (n < 0 && result != NULL && PyUnicode_Check(result)) { - Py_UNICODE *s = PyUnicode_AS_UNICODE(result); - int len = PyUnicode_GET_SIZE(result); - if (len == 0) { - Py_DECREF(result); - result = NULL; - PyErr_SetString(PyExc_EOFError, - "EOF when reading a line"); - } - else if (s[len-1] == '\n') { - if (result->ob_refcnt == 1) - PyUnicode_Resize(&result, len-1); - else { - PyObject *v; - v = PyUnicode_FromUnicode(s, len-1); - Py_DECREF(result); - result = v; - } - } - } -#endif - return result; -} - -/* Python method */ - -static PyObject * -file_readline(PyFileObject *f, PyObject *args) -{ - int n = -1; - - if (f->f_fp == NULL) - return err_closed(); - if (!PyArg_ParseTuple(args, "|i:readline", &n)) - return NULL; - if (n == 0) - return PyString_FromString(""); - if (n < 0) - n = 0; - return get_line(f, n); -} - -static PyObject * -file_readlines(PyFileObject *f, PyObject *args) -{ - long sizehint = 0; - PyObject *list; - PyObject *line; - char small_buffer[SMALLCHUNK]; - char *buffer = small_buffer; - size_t buffersize = SMALLCHUNK; - PyObject *big_buffer = NULL; - size_t nfilled = 0; - size_t nread; - size_t totalread = 0; - char *p, *q, *end; - int err; - int shortread = 0; - - if (f->f_fp == NULL) - return err_closed(); - if (!PyArg_ParseTuple(args, "|l:readlines", &sizehint)) - return NULL; - if ((list = PyList_New(0)) == NULL) - return NULL; - for (;;) { - if (shortread) - nread = 0; - else { - Py_BEGIN_ALLOW_THREADS - errno = 0; - nread = Py_UniversalNewlineFread(buffer+nfilled, - buffersize-nfilled, f->f_fp, (PyObject *)f); - Py_END_ALLOW_THREADS - shortread = (nread < buffersize-nfilled); - } - if (nread == 0) { - sizehint = 0; - if (!ferror(f->f_fp)) - break; - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - error: - Py_DECREF(list); - list = NULL; - goto cleanup; - } - totalread += nread; - p = memchr(buffer+nfilled, '\n', nread); - if (p == NULL) { - /* Need a larger buffer to fit this line */ - nfilled += nread; - buffersize *= 2; - if (buffersize > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "line is longer than a Python string can hold"); - goto error; - } - if (big_buffer == NULL) { - /* Create the big buffer */ - big_buffer = PyString_FromStringAndSize( - NULL, buffersize); - if (big_buffer == NULL) - goto error; - buffer = PyString_AS_STRING(big_buffer); - memcpy(buffer, small_buffer, nfilled); - } - else { - /* Grow the big buffer */ - if ( _PyString_Resize(&big_buffer, buffersize) < 0 ) - goto error; - buffer = PyString_AS_STRING(big_buffer); - } - continue; - } - end = buffer+nfilled+nread; - q = buffer; - do { - /* Process complete lines */ - p++; - line = PyString_FromStringAndSize(q, p-q); - if (line == NULL) - goto error; - err = PyList_Append(list, line); - Py_DECREF(line); - if (err != 0) - goto error; - q = p; - p = memchr(q, '\n', end-q); - } while (p != NULL); - /* Move the remaining incomplete line to the start */ - nfilled = end-q; - memmove(buffer, q, nfilled); - if (sizehint > 0) - if (totalread >= (size_t)sizehint) - break; - } - if (nfilled != 0) { - /* Partial last line */ - line = PyString_FromStringAndSize(buffer, nfilled); - if (line == NULL) - goto error; - if (sizehint > 0) { - /* Need to complete the last line */ - PyObject *rest = get_line(f, 0); - if (rest == NULL) { - Py_DECREF(line); - goto error; - } - PyString_Concat(&line, rest); - Py_DECREF(rest); - if (line == NULL) - goto error; - } - err = PyList_Append(list, line); - Py_DECREF(line); - if (err != 0) - goto error; - } - cleanup: - Py_XDECREF(big_buffer); - return list; -} - -static PyObject * -file_write(PyFileObject *f, PyObject *args) -{ - char *s; - int n, n2; - if (f->f_fp == NULL) - return err_closed(); - if (!PyArg_ParseTuple(args, f->f_binary ? "s#" : "t#", &s, &n)) - return NULL; - f->f_softspace = 0; - Py_BEGIN_ALLOW_THREADS - errno = 0; - n2 = fwrite(s, 1, n, f->f_fp); - Py_END_ALLOW_THREADS - if (n2 != n) { - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -file_writelines(PyFileObject *f, PyObject *seq) -{ -#define CHUNKSIZE 1000 - PyObject *list, *line; - PyObject *it; /* iter(seq) */ - PyObject *result; - int i, j, index, len, nwritten, islist; - - assert(seq != NULL); - if (f->f_fp == NULL) - return err_closed(); - - result = NULL; - list = NULL; - islist = PyList_Check(seq); - if (islist) - it = NULL; - else { - it = PyObject_GetIter(seq); - if (it == NULL) { - PyErr_SetString(PyExc_TypeError, - "writelines() requires an iterable argument"); - return NULL; - } - /* From here on, fail by going to error, to reclaim "it". */ - list = PyList_New(CHUNKSIZE); - if (list == NULL) - goto error; - } - - /* Strategy: slurp CHUNKSIZE lines into a private list, - checking that they are all strings, then write that list - without holding the interpreter lock, then come back for more. */ - for (index = 0; ; index += CHUNKSIZE) { - if (islist) { - Py_XDECREF(list); - list = PyList_GetSlice(seq, index, index+CHUNKSIZE); - if (list == NULL) - goto error; - j = PyList_GET_SIZE(list); - } - else { - for (j = 0; j < CHUNKSIZE; j++) { - line = PyIter_Next(it); - if (line == NULL) { - if (PyErr_Occurred()) - goto error; - break; - } - PyList_SetItem(list, j, line); - } - } - if (j == 0) - break; - - /* Check that all entries are indeed strings. If not, - apply the same rules as for file.write() and - convert the results to strings. This is slow, but - seems to be the only way since all conversion APIs - could potentially execute Python code. */ - for (i = 0; i < j; i++) { - PyObject *v = PyList_GET_ITEM(list, i); - if (!PyString_Check(v)) { - const char *buffer; - int len; - if (((f->f_binary && - PyObject_AsReadBuffer(v, - (const void**)&buffer, - &len)) || - PyObject_AsCharBuffer(v, - &buffer, - &len))) { - PyErr_SetString(PyExc_TypeError, - "writelines() argument must be a sequence of strings"); - goto error; - } - line = PyString_FromStringAndSize(buffer, - len); - if (line == NULL) - goto error; - Py_DECREF(v); - PyList_SET_ITEM(list, i, line); - } - } - - /* Since we are releasing the global lock, the - following code may *not* execute Python code. */ - Py_BEGIN_ALLOW_THREADS - f->f_softspace = 0; - errno = 0; - for (i = 0; i < j; i++) { - line = PyList_GET_ITEM(list, i); - len = PyString_GET_SIZE(line); - nwritten = fwrite(PyString_AS_STRING(line), - 1, len, f->f_fp); - if (nwritten != len) { - Py_BLOCK_THREADS - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - goto error; - } - } - Py_END_ALLOW_THREADS - - if (j < CHUNKSIZE) - break; - } - - Py_INCREF(Py_None); - result = Py_None; - error: - Py_XDECREF(list); - Py_XDECREF(it); - return result; -#undef CHUNKSIZE -} - -static PyObject * -file_getiter(PyFileObject *f) -{ - if (f->f_fp == NULL) - return err_closed(); - Py_INCREF(f); - return (PyObject *)f; -} - -PyDoc_STRVAR(readline_doc, -"readline([size]) -> next line from the file, as a string.\n" -"\n" -"Retain newline. A non-negative size argument limits the maximum\n" -"number of bytes to return (an incomplete line may be returned then).\n" -"Return an empty string at EOF."); - -PyDoc_STRVAR(read_doc, -"read([size]) -> read at most size bytes, returned as a string.\n" -"\n" -"If the size argument is negative or omitted, read until EOF is reached.\n" -"Notice that when in non-blocking mode, less data than what was requested\n" -"may be returned, even if no size parameter was given."); - -PyDoc_STRVAR(write_doc, -"write(str) -> None. Write string str to file.\n" -"\n" -"Note that due to buffering, flush() or close() may be needed before\n" -"the file on disk reflects the data written."); - -PyDoc_STRVAR(fileno_doc, -"fileno() -> integer \"file descriptor\".\n" -"\n" -"This is needed for lower-level file interfaces, such os.read()."); - -PyDoc_STRVAR(seek_doc, -"seek(offset[, whence]) -> None. Move to new file position.\n" -"\n" -"Argument offset is a byte count. Optional argument whence defaults to\n" -"0 (offset from start of file, offset should be >= 0); other values are 1\n" -"(move relative to current position, positive or negative), and 2 (move\n" -"relative to end of file, usually negative, although many platforms allow\n" -"seeking beyond the end of a file). If the file is opened in text mode,\n" -"only offsets returned by tell() are legal. Use of other offsets causes\n" -"undefined behavior." -"\n" -"Note that not all file objects are seekable."); - -#ifdef HAVE_FTRUNCATE -PyDoc_STRVAR(truncate_doc, -"truncate([size]) -> None. Truncate the file to at most size bytes.\n" -"\n" -"Size defaults to the current file position, as returned by tell()."); -#endif - -PyDoc_STRVAR(tell_doc, -"tell() -> current file position, an integer (may be a long integer)."); - -PyDoc_STRVAR(readinto_doc, -"readinto() -> Undocumented. Don't use this; it may go away."); - -PyDoc_STRVAR(readlines_doc, -"readlines([size]) -> list of strings, each a line from the file.\n" -"\n" -"Call readline() repeatedly and return a list of the lines so read.\n" -"The optional size argument, if given, is an approximate bound on the\n" -"total number of bytes in the lines returned."); - -PyDoc_STRVAR(xreadlines_doc, -"xreadlines() -> returns self.\n" -"\n" -"For backward compatibility. File objects now include the performance\n" -"optimizations previously implemented in the xreadlines module."); - -PyDoc_STRVAR(writelines_doc, -"writelines(sequence_of_strings) -> None. Write the strings to the file.\n" -"\n" -"Note that newlines are not added. The sequence can be any iterable object\n" -"producing strings. This is equivalent to calling write() for each string."); - -PyDoc_STRVAR(flush_doc, -"flush() -> None. Flush the internal I/O buffer."); - -PyDoc_STRVAR(close_doc, -"close() -> None or (perhaps) an integer. Close the file.\n" -"\n" -"Sets data attribute .closed to True. A closed file cannot be used for\n" -"further I/O operations. close() may be called more than once without\n" -"error. Some kinds of file objects (for example, opened by popen())\n" -"may return an exit status upon closing."); - -PyDoc_STRVAR(isatty_doc, -"isatty() -> true or false. True if the file is connected to a tty device."); - -static PyMethodDef file_methods[] = { - {"readline", (PyCFunction)file_readline, METH_VARARGS, readline_doc}, - {"read", (PyCFunction)file_read, METH_VARARGS, read_doc}, - {"write", (PyCFunction)file_write, METH_VARARGS, write_doc}, - {"fileno", (PyCFunction)file_fileno, METH_NOARGS, fileno_doc}, - {"seek", (PyCFunction)file_seek, METH_VARARGS, seek_doc}, -#ifdef HAVE_FTRUNCATE - {"truncate", (PyCFunction)file_truncate, METH_VARARGS, truncate_doc}, -#endif - {"tell", (PyCFunction)file_tell, METH_NOARGS, tell_doc}, - {"readinto", (PyCFunction)file_readinto, METH_VARARGS, readinto_doc}, - {"readlines", (PyCFunction)file_readlines,METH_VARARGS, readlines_doc}, - {"xreadlines",(PyCFunction)file_getiter, METH_NOARGS, xreadlines_doc}, - {"writelines",(PyCFunction)file_writelines, METH_O, writelines_doc}, - {"flush", (PyCFunction)file_flush, METH_NOARGS, flush_doc}, - {"close", (PyCFunction)file_close, METH_NOARGS, close_doc}, - {"isatty", (PyCFunction)file_isatty, METH_NOARGS, isatty_doc}, - {NULL, NULL} /* sentinel */ -}; - -#define OFF(x) offsetof(PyFileObject, x) - -static PyMemberDef file_memberlist[] = { - {"softspace", T_INT, OFF(f_softspace), 0, - "flag indicating that a space needs to be printed; used by print"}, - {"mode", T_OBJECT, OFF(f_mode), RO, - "file mode ('r', 'U', 'w', 'a', possibly with 'b' or '+' added)"}, - {"name", T_OBJECT, OFF(f_name), RO, - "file name"}, - {"encoding", T_OBJECT, OFF(f_encoding), RO, - "file encoding"}, - /* getattr(f, "closed") is implemented without this table */ - {NULL} /* Sentinel */ -}; - -static PyObject * -get_closed(PyFileObject *f, void *closure) -{ - return PyBool_FromLong((long)(f->f_fp == 0)); -} -#ifdef WITH_UNIVERSAL_NEWLINES -static PyObject * -get_newlines(PyFileObject *f, void *closure) -{ - switch (f->f_newlinetypes) { - case NEWLINE_UNKNOWN: - Py_INCREF(Py_None); - return Py_None; - case NEWLINE_CR: - return PyString_FromString("\r"); - case NEWLINE_LF: - return PyString_FromString("\n"); - case NEWLINE_CR|NEWLINE_LF: - return Py_BuildValue("(ss)", "\r", "\n"); - case NEWLINE_CRLF: - return PyString_FromString("\r\n"); - case NEWLINE_CR|NEWLINE_CRLF: - return Py_BuildValue("(ss)", "\r", "\r\n"); - case NEWLINE_LF|NEWLINE_CRLF: - return Py_BuildValue("(ss)", "\n", "\r\n"); - case NEWLINE_CR|NEWLINE_LF|NEWLINE_CRLF: - return Py_BuildValue("(sss)", "\r", "\n", "\r\n"); - default: - PyErr_Format(PyExc_SystemError, - "Unknown newlines value 0x%x\n", - f->f_newlinetypes); - return NULL; - } -} -#endif - -static PyGetSetDef file_getsetlist[] = { - {"closed", (getter)get_closed, NULL, "True if the file is closed"}, -#ifdef WITH_UNIVERSAL_NEWLINES - {"newlines", (getter)get_newlines, NULL, - "end-of-line convention used in this file"}, -#endif - {0}, -}; - -static void -drop_readahead(PyFileObject *f) -{ - if (f->f_buf != NULL) { - PyMem_Free(f->f_buf); - f->f_buf = NULL; - } -} - -/* Make sure that file has a readahead buffer with at least one byte - (unless at EOF) and no more than bufsize. Returns negative value on - error */ -static int -readahead(PyFileObject *f, int bufsize) -{ - int chunksize; - - if (f->f_buf != NULL) { - if( (f->f_bufend - f->f_bufptr) >= 1) - return 0; - else - drop_readahead(f); - } - if ((f->f_buf = PyMem_Malloc(bufsize)) == NULL) { - return -1; - } - Py_BEGIN_ALLOW_THREADS - errno = 0; - chunksize = Py_UniversalNewlineFread( - f->f_buf, bufsize, f->f_fp, (PyObject *)f); - Py_END_ALLOW_THREADS - if (chunksize == 0) { - if (ferror(f->f_fp)) { - PyErr_SetFromErrno(PyExc_IOError); - clearerr(f->f_fp); - drop_readahead(f); - return -1; - } - } - f->f_bufptr = f->f_buf; - f->f_bufend = f->f_buf + chunksize; - return 0; -} - -/* Used by file_iternext. The returned string will start with 'skip' - uninitialized bytes followed by the remainder of the line. Don't be - horrified by the recursive call: maximum recursion depth is limited by - logarithmic buffer growth to about 50 even when reading a 1gb line. */ - -static PyStringObject * -readahead_get_line_skip(PyFileObject *f, int skip, int bufsize) -{ - PyStringObject* s; - char *bufptr; - char *buf; - int len; - - if (f->f_buf == NULL) - if (readahead(f, bufsize) < 0) - return NULL; - - len = f->f_bufend - f->f_bufptr; - if (len == 0) - return (PyStringObject *) - PyString_FromStringAndSize(NULL, skip); - bufptr = memchr(f->f_bufptr, '\n', len); - if (bufptr != NULL) { - bufptr++; /* Count the '\n' */ - len = bufptr - f->f_bufptr; - s = (PyStringObject *) - PyString_FromStringAndSize(NULL, skip+len); - if (s == NULL) - return NULL; - memcpy(PyString_AS_STRING(s)+skip, f->f_bufptr, len); - f->f_bufptr = bufptr; - if (bufptr == f->f_bufend) - drop_readahead(f); - } else { - bufptr = f->f_bufptr; - buf = f->f_buf; - f->f_buf = NULL; /* Force new readahead buffer */ - s = readahead_get_line_skip( - f, skip+len, bufsize + (bufsize>>2) ); - if (s == NULL) { - PyMem_Free(buf); - return NULL; - } - memcpy(PyString_AS_STRING(s)+skip, bufptr, len); - PyMem_Free(buf); - } - return s; -} - -/* A larger buffer size may actually decrease performance. */ -#define READAHEAD_BUFSIZE 8192 - -static PyObject * -file_iternext(PyFileObject *f) -{ - PyStringObject* l; - - if (f->f_fp == NULL) - return err_closed(); - - l = readahead_get_line_skip(f, 0, READAHEAD_BUFSIZE); - if (l == NULL || PyString_GET_SIZE(l) == 0) { - Py_XDECREF(l); - return NULL; - } - return (PyObject *)l; -} - - -static PyObject * -file_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *self; - static PyObject *not_yet_string; - - assert(type != NULL && type->tp_alloc != NULL); - - if (not_yet_string == NULL) { - not_yet_string = PyString_FromString(""); - if (not_yet_string == NULL) - return NULL; - } - - self = type->tp_alloc(type, 0); - if (self != NULL) { - /* Always fill in the name and mode, so that nobody else - needs to special-case NULLs there. */ - Py_INCREF(not_yet_string); - ((PyFileObject *)self)->f_name = not_yet_string; - Py_INCREF(not_yet_string); - ((PyFileObject *)self)->f_mode = not_yet_string; - Py_INCREF(Py_None); - ((PyFileObject *)self)->f_encoding = Py_None; - } - return self; -} - -static int -file_init(PyObject *self, PyObject *args, PyObject *kwds) -{ - PyFileObject *foself = (PyFileObject *)self; - int ret = 0; - static char *kwlist[] = {"name", "mode", "buffering", 0}; - char *name = NULL; - char *mode = "r"; - int bufsize = -1; - int wideargument = 0; - - assert(PyFile_Check(self)); - if (foself->f_fp != NULL) { - /* Have to close the existing file first. */ - PyObject *closeresult = file_close(foself); - if (closeresult == NULL) - return -1; - Py_DECREF(closeresult); - } - -#ifdef Py_WIN_WIDE_FILENAMES - if (GetVersion() < 0x80000000) { /* On NT, so wide API available */ - PyObject *po; - if (PyArg_ParseTupleAndKeywords(args, kwds, "U|si:file", - kwlist, &po, &mode, &bufsize)) { - wideargument = 1; - if (fill_file_fields(foself, NULL, name, mode, - fclose, po) == NULL) - goto Error; - } else { - /* Drop the argument parsing error as narrow - strings are also valid. */ - PyErr_Clear(); - } - } -#endif - - if (!wideargument) { - if (!PyArg_ParseTupleAndKeywords(args, kwds, "et|si:file", kwlist, - Py_FileSystemDefaultEncoding, - &name, - &mode, &bufsize)) - return -1; - if (fill_file_fields(foself, NULL, name, mode, - fclose, NULL) == NULL) - goto Error; - } - if (open_the_file(foself, name, mode) == NULL) - goto Error; - foself->f_setbuf = NULL; - PyFile_SetBufSize(self, bufsize); - goto Done; - -Error: - ret = -1; - /* fall through */ -Done: - PyMem_Free(name); /* free the encoded string */ - return ret; -} - -PyDoc_VAR(file_doc) = -PyDoc_STR( -"file(name[, mode[, buffering]]) -> file object\n" -"\n" -"Open a file. The mode can be 'r', 'w' or 'a' for reading (default),\n" -"writing or appending. The file will be created if it doesn't exist\n" -"when opened for writing or appending; it will be truncated when\n" -"opened for writing. Add a 'b' to the mode for binary files.\n" -"Add a '+' to the mode to allow simultaneous reading and writing.\n" -"If the buffering argument is given, 0 means unbuffered, 1 means line\n" -"buffered, and larger numbers specify the buffer size.\n" -) -#ifdef WITH_UNIVERSAL_NEWLINES -PyDoc_STR( -"Add a 'U' to mode to open the file for input with universal newline\n" -"support. Any line ending in the input file will be seen as a '\\n'\n" -"in Python. Also, a file so opened gains the attribute 'newlines';\n" -"the value for this attribute is one of None (no newline read yet),\n" -"'\\r', '\\n', '\\r\\n' or a tuple containing all the newline types seen.\n" -"\n" -"'U' cannot be combined with 'w' or '+' mode.\n" -) -#endif /* WITH_UNIVERSAL_NEWLINES */ -PyDoc_STR( -"\n" -"Note: open() is an alias for file()." -); - -PyTypeObject PyFile_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "file", - sizeof(PyFileObject), - 0, - (destructor)file_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)file_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - /* softspace is writable: we must supply tp_setattro */ - PyObject_GenericSetAttr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - file_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc)file_getiter, /* tp_iter */ - (iternextfunc)file_iternext, /* tp_iternext */ - file_methods, /* tp_methods */ - file_memberlist, /* tp_members */ - file_getsetlist, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)file_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - file_new, /* tp_new */ - PyObject_Del, /* tp_free */ -}; - -/* Interface for the 'soft space' between print items. */ - -int -PyFile_SoftSpace(PyObject *f, int newflag) -{ - int oldflag = 0; - if (f == NULL) { - /* Do nothing */ - } - else if (PyFile_Check(f)) { - oldflag = ((PyFileObject *)f)->f_softspace; - ((PyFileObject *)f)->f_softspace = newflag; - } - else { - PyObject *v; - v = PyObject_GetAttrString(f, "softspace"); - if (v == NULL) - PyErr_Clear(); - else { - if (PyInt_Check(v)) - oldflag = PyInt_AsLong(v); - Py_DECREF(v); - } - v = PyInt_FromLong((long)newflag); - if (v == NULL) - PyErr_Clear(); - else { - if (PyObject_SetAttrString(f, "softspace", v) != 0) - PyErr_Clear(); - Py_DECREF(v); - } - } - return oldflag; -} - -/* Interfaces to write objects/strings to file-like objects */ - -int -PyFile_WriteObject(PyObject *v, PyObject *f, int flags) -{ - PyObject *writer, *value, *args, *result; - if (f == NULL) { - PyErr_SetString(PyExc_TypeError, "writeobject with NULL file"); - return -1; - } - else if (PyFile_Check(f)) { - FILE *fp = PyFile_AsFile(f); - PyObject *enc = ((PyFileObject*)f)->f_encoding; - int result; - if (fp == NULL) { - err_closed(); - return -1; - } -#ifdef Py_USING_UNICODE - if ((flags & Py_PRINT_RAW) && - PyUnicode_Check(v) && enc != Py_None) { - char *cenc = PyString_AS_STRING(enc); - value = PyUnicode_AsEncodedString(v, cenc, "strict"); - if (value == NULL) - return -1; - } else { - value = v; - Py_INCREF(value); - } - result = PyObject_Print(value, fp, flags); - Py_DECREF(value); - return result; -#else - return PyObject_Print(v, fp, flags); -#endif - } - writer = PyObject_GetAttrString(f, "write"); - if (writer == NULL) - return -1; - if (flags & Py_PRINT_RAW) { - if (PyUnicode_Check(v)) { - value = v; - Py_INCREF(value); - } else - value = PyObject_Str(v); - } - else - value = PyObject_Repr(v); - if (value == NULL) { - Py_DECREF(writer); - return -1; - } - args = Py_BuildValue("(O)", value); - if (args == NULL) { - Py_DECREF(value); - Py_DECREF(writer); - return -1; - } - result = PyEval_CallObject(writer, args); - Py_DECREF(args); - Py_DECREF(value); - Py_DECREF(writer); - if (result == NULL) - return -1; - Py_DECREF(result); - return 0; -} - -int -PyFile_WriteString(const char *s, PyObject *f) -{ - if (f == NULL) { - /* Should be caused by a pre-existing error */ - if (!PyErr_Occurred()) - PyErr_SetString(PyExc_SystemError, - "null file for PyFile_WriteString"); - return -1; - } - else if (PyFile_Check(f)) { - FILE *fp = PyFile_AsFile(f); - if (fp == NULL) { - err_closed(); - return -1; - } - fputs(s, fp); - return 0; - } - else if (!PyErr_Occurred()) { - PyObject *v = PyString_FromString(s); - int err; - if (v == NULL) - return -1; - err = PyFile_WriteObject(v, f, Py_PRINT_RAW); - Py_DECREF(v); - return err; - } - else - return -1; -} - -/* Try to get a file-descriptor from a Python object. If the object - is an integer or long integer, its value is returned. If not, the - object's fileno() method is called if it exists; the method must return - an integer or long integer, which is returned as the file descriptor value. - -1 is returned on failure. -*/ - -int PyObject_AsFileDescriptor(PyObject *o) -{ - int fd; - PyObject *meth; - - if (PyInt_Check(o)) { - fd = PyInt_AsLong(o); - } - else if (PyLong_Check(o)) { - fd = PyLong_AsLong(o); - } - else if ((meth = PyObject_GetAttrString(o, "fileno")) != NULL) - { - PyObject *fno = PyEval_CallObject(meth, NULL); - Py_DECREF(meth); - if (fno == NULL) - return -1; - - if (PyInt_Check(fno)) { - fd = PyInt_AsLong(fno); - Py_DECREF(fno); - } - else if (PyLong_Check(fno)) { - fd = PyLong_AsLong(fno); - Py_DECREF(fno); - } - else { - PyErr_SetString(PyExc_TypeError, - "fileno() returned a non-integer"); - Py_DECREF(fno); - return -1; - } - } - else { - PyErr_SetString(PyExc_TypeError, - "argument must be an int, or have a fileno() method."); - return -1; - } - - if (fd < 0) { - PyErr_Format(PyExc_ValueError, - "file descriptor cannot be a negative integer (%i)", - fd); - return -1; - } - return fd; -} - -#ifdef WITH_UNIVERSAL_NEWLINES -/* From here on we need access to the real fgets and fread */ -#undef fgets -#undef fread - -/* -** Py_UniversalNewlineFgets is an fgets variation that understands -** all of \r, \n and \r\n conventions. -** The stream should be opened in binary mode. -** If fobj is NULL the routine always does newline conversion, and -** it may peek one char ahead to gobble the second char in \r\n. -** If fobj is non-NULL it must be a PyFileObject. In this case there -** is no readahead but in stead a flag is used to skip a following -** \n on the next read. Also, if the file is open in binary mode -** the whole conversion is skipped. Finally, the routine keeps track of -** the different types of newlines seen. -** Note that we need no error handling: fgets() treats error and eof -** identically. -*/ -char * -Py_UniversalNewlineFgets(char *buf, int n, FILE *stream, PyObject *fobj) -{ - char *p = buf; - int c; - int newlinetypes = 0; - int skipnextlf = 0; - int univ_newline = 1; - - if (fobj) { - if (!PyFile_Check(fobj)) { - errno = ENXIO; /* What can you do... */ - return NULL; - } - univ_newline = ((PyFileObject *)fobj)->f_univ_newline; - if ( !univ_newline ) - return fgets(buf, n, stream); - newlinetypes = ((PyFileObject *)fobj)->f_newlinetypes; - skipnextlf = ((PyFileObject *)fobj)->f_skipnextlf; - } - FLOCKFILE(stream); - c = 'x'; /* Shut up gcc warning */ - while (--n > 0 && (c = GETC(stream)) != EOF ) { - if (skipnextlf ) { - skipnextlf = 0; - if (c == '\n') { - /* Seeing a \n here with skipnextlf true - ** means we saw a \r before. - */ - newlinetypes |= NEWLINE_CRLF; - c = GETC(stream); - if (c == EOF) break; - } else { - /* - ** Note that c == EOF also brings us here, - ** so we're okay if the last char in the file - ** is a CR. - */ - newlinetypes |= NEWLINE_CR; - } - } - if (c == '\r') { - /* A \r is translated into a \n, and we skip - ** an adjacent \n, if any. We don't set the - ** newlinetypes flag until we've seen the next char. - */ - skipnextlf = 1; - c = '\n'; - } else if ( c == '\n') { - newlinetypes |= NEWLINE_LF; - } - *p++ = c; - if (c == '\n') break; - } - if ( c == EOF && skipnextlf ) - newlinetypes |= NEWLINE_CR; - FUNLOCKFILE(stream); - *p = '\0'; - if (fobj) { - ((PyFileObject *)fobj)->f_newlinetypes = newlinetypes; - ((PyFileObject *)fobj)->f_skipnextlf = skipnextlf; - } else if ( skipnextlf ) { - /* If we have no file object we cannot save the - ** skipnextlf flag. We have to readahead, which - ** will cause a pause if we're reading from an - ** interactive stream, but that is very unlikely - ** unless we're doing something silly like - ** execfile("/dev/tty"). - */ - c = GETC(stream); - if ( c != '\n' ) - ungetc(c, stream); - } - if (p == buf) - return NULL; - return buf; -} - -/* -** Py_UniversalNewlineFread is an fread variation that understands -** all of \r, \n and \r\n conventions. -** The stream should be opened in binary mode. -** fobj must be a PyFileObject. In this case there -** is no readahead but in stead a flag is used to skip a following -** \n on the next read. Also, if the file is open in binary mode -** the whole conversion is skipped. Finally, the routine keeps track of -** the different types of newlines seen. -*/ -size_t -Py_UniversalNewlineFread(char *buf, size_t n, - FILE *stream, PyObject *fobj) -{ - char *dst = buf; - PyFileObject *f = (PyFileObject *)fobj; - int newlinetypes, skipnextlf; - - assert(buf != NULL); - assert(stream != NULL); - - if (!fobj || !PyFile_Check(fobj)) { - errno = ENXIO; /* What can you do... */ - return 0; - } - if (!f->f_univ_newline) - return fread(buf, 1, n, stream); - newlinetypes = f->f_newlinetypes; - skipnextlf = f->f_skipnextlf; - /* Invariant: n is the number of bytes remaining to be filled - * in the buffer. - */ - while (n) { - size_t nread; - int shortread; - char *src = dst; - - nread = fread(dst, 1, n, stream); - assert(nread <= n); - if (nread == 0) - break; - - n -= nread; /* assuming 1 byte out for each in; will adjust */ - shortread = n != 0; /* true iff EOF or error */ - while (nread--) { - char c = *src++; - if (c == '\r') { - /* Save as LF and set flag to skip next LF. */ - *dst++ = '\n'; - skipnextlf = 1; - } - else if (skipnextlf && c == '\n') { - /* Skip LF, and remember we saw CR LF. */ - skipnextlf = 0; - newlinetypes |= NEWLINE_CRLF; - ++n; - } - else { - /* Normal char to be stored in buffer. Also - * update the newlinetypes flag if either this - * is an LF or the previous char was a CR. - */ - if (c == '\n') - newlinetypes |= NEWLINE_LF; - else if (skipnextlf) - newlinetypes |= NEWLINE_CR; - *dst++ = c; - skipnextlf = 0; - } - } - if (shortread) { - /* If this is EOF, update type flags. */ - if (skipnextlf && feof(stream)) - newlinetypes |= NEWLINE_CR; - break; - } - } - f->f_newlinetypes = newlinetypes; - f->f_skipnextlf = skipnextlf; - return dst - buf; -} -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/floatobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/floatobject.c deleted file mode 100644 index 347e4f56..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/floatobject.c +++ /dev/null @@ -1,1253 +0,0 @@ - -/* Float object implementation */ - -/* XXX There should be overflow checks here, but it's hard to check - for any kind of float exception without losing portability. */ - -#include "Python.h" - -#include - -#if !defined(__STDC__) && !defined(macintosh) -extern double fmod(double, double); -extern double pow(double, double); -#endif - -#if defined(sun) && !defined(__SVR4) -/* On SunOS4.1 only libm.a exists. Make sure that references to all - needed math functions exist in the executable, so that dynamic - loading of mathmodule does not fail. */ -double (*_Py_math_funcs_hack[])() = { - acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, - fmod, log, log10, pow, sin, sinh, sqrt, tan, tanh -}; -#endif - -/* Special free list -- see comments for same code in intobject.c. */ -#define BLOCK_SIZE 1000 /* 1K less typical malloc overhead */ -#define BHEAD_SIZE 8 /* Enough for a 64-bit pointer */ -#define N_FLOATOBJECTS ((BLOCK_SIZE - BHEAD_SIZE) / sizeof(PyFloatObject)) - -struct _floatblock { - struct _floatblock *next; - PyFloatObject objects[N_FLOATOBJECTS]; -}; - -typedef struct _floatblock PyFloatBlock; - -static PyFloatBlock *block_list = NULL; -static PyFloatObject *free_list = NULL; - -static PyFloatObject * -fill_free_list(void) -{ - PyFloatObject *p, *q; - /* XXX Float blocks escape the object heap. Use PyObject_MALLOC ??? */ - p = (PyFloatObject *) PyMem_MALLOC(sizeof(PyFloatBlock)); - if (p == NULL) - return (PyFloatObject *) PyErr_NoMemory(); - ((PyFloatBlock *)p)->next = block_list; - block_list = (PyFloatBlock *)p; - p = &((PyFloatBlock *)p)->objects[0]; - q = p + N_FLOATOBJECTS; - while (--q > p) - q->ob_type = (struct _typeobject *)(q-1); - q->ob_type = NULL; - return p + N_FLOATOBJECTS - 1; -} - -PyObject * -PyFloat_FromDouble(double fval) -{ - register PyFloatObject *op; - if (free_list == NULL) { - if ((free_list = fill_free_list()) == NULL) - return NULL; - } - /* Inline PyObject_New */ - op = free_list; - free_list = (PyFloatObject *)op->ob_type; - PyObject_INIT(op, &PyFloat_Type); - op->ob_fval = fval; - return (PyObject *) op; -} - -/************************************************************************** -RED_FLAG 22-Sep-2000 tim -PyFloat_FromString's pend argument is braindead. Prior to this RED_FLAG, - -1. If v was a regular string, *pend was set to point to its terminating - null byte. That's useless (the caller can find that without any - help from this function!). - -2. If v was a Unicode string, or an object convertible to a character - buffer, *pend was set to point into stack trash (the auto temp - vector holding the character buffer). That was downright dangerous. - -Since we can't change the interface of a public API function, pend is -still supported but now *officially* useless: if pend is not NULL, -*pend is set to NULL. -**************************************************************************/ -PyObject * -PyFloat_FromString(PyObject *v, char **pend) -{ - const char *s, *last, *end; - double x; - char buffer[256]; /* for errors */ -#ifdef Py_USING_UNICODE - char s_buffer[256]; /* for objects convertible to a char buffer */ -#endif - int len; - - if (pend) - *pend = NULL; - if (PyString_Check(v)) { - s = PyString_AS_STRING(v); - len = PyString_GET_SIZE(v); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(v)) { - if (PyUnicode_GET_SIZE(v) >= sizeof(s_buffer)) { - PyErr_SetString(PyExc_ValueError, - "Unicode float() literal too long to convert"); - return NULL; - } - if (PyUnicode_EncodeDecimal(PyUnicode_AS_UNICODE(v), - PyUnicode_GET_SIZE(v), - s_buffer, - NULL)) - return NULL; - s = s_buffer; - len = (int)strlen(s); - } -#endif - else if (PyObject_AsCharBuffer(v, &s, &len)) { - PyErr_SetString(PyExc_TypeError, - "float() argument must be a string or a number"); - return NULL; - } - - last = s + len; - while (*s && isspace(Py_CHARMASK(*s))) - s++; - if (*s == '\0') { - PyErr_SetString(PyExc_ValueError, "empty string for float()"); - return NULL; - } - /* We don't care about overflow or underflow. If the platform supports - * them, infinities and signed zeroes (on underflow) are fine. - * However, strtod can return 0 for denormalized numbers, where atof - * does not. So (alas!) we special-case a zero result. Note that - * whether strtod sets errno on underflow is not defined, so we can't - * key off errno. - */ - PyFPE_START_PROTECT("strtod", return NULL) - x = strtod(s, (char **)&end); - PyFPE_END_PROTECT(x) - errno = 0; - /* Believe it or not, Solaris 2.6 can move end *beyond* the null - byte at the end of the string, when the input is inf(inity). */ - if (end > last) - end = last; - if (end == s) { - PyOS_snprintf(buffer, sizeof(buffer), - "invalid literal for float(): %.200s", s); - PyErr_SetString(PyExc_ValueError, buffer); - return NULL; - } - /* Since end != s, the platform made *some* kind of sense out - of the input. Trust it. */ - while (*end && isspace(Py_CHARMASK(*end))) - end++; - if (*end != '\0') { - PyOS_snprintf(buffer, sizeof(buffer), - "invalid literal for float(): %.200s", s); - PyErr_SetString(PyExc_ValueError, buffer); - return NULL; - } - else if (end != last) { - PyErr_SetString(PyExc_ValueError, - "null byte in argument for float()"); - return NULL; - } - if (x == 0.0) { - /* See above -- may have been strtod being anal - about denorms. */ - PyFPE_START_PROTECT("atof", return NULL) - x = atof(s); - PyFPE_END_PROTECT(x) - errno = 0; /* whether atof ever set errno is undefined */ - } - return PyFloat_FromDouble(x); -} - -static void -float_dealloc(PyFloatObject *op) -{ - if (PyFloat_CheckExact(op)) { - op->ob_type = (struct _typeobject *)free_list; - free_list = op; - } - else - op->ob_type->tp_free((PyObject *)op); -} - -double -PyFloat_AsDouble(PyObject *op) -{ - PyNumberMethods *nb; - PyFloatObject *fo; - double val; - - if (op && PyFloat_Check(op)) - return PyFloat_AS_DOUBLE((PyFloatObject*) op); - - if (op == NULL) { - PyErr_BadArgument(); - return -1; - } - - if ((nb = op->ob_type->tp_as_number) == NULL || nb->nb_float == NULL) { - PyErr_SetString(PyExc_TypeError, "a float is required"); - return -1; - } - - fo = (PyFloatObject*) (*nb->nb_float) (op); - if (fo == NULL) - return -1; - if (!PyFloat_Check(fo)) { - PyErr_SetString(PyExc_TypeError, - "nb_float should return float object"); - return -1; - } - - val = PyFloat_AS_DOUBLE(fo); - Py_DECREF(fo); - - return val; -} - -/* Methods */ - -static void -format_float(char *buf, size_t buflen, PyFloatObject *v, int precision) -{ - register char *cp; - /* Subroutine for float_repr and float_print. - We want float numbers to be recognizable as such, - i.e., they should contain a decimal point or an exponent. - However, %g may print the number as an integer; - in such cases, we append ".0" to the string. */ - - assert(PyFloat_Check(v)); - PyOS_snprintf(buf, buflen, "%.*g", precision, v->ob_fval); - cp = buf; - if (*cp == '-') - cp++; - for (; *cp != '\0'; cp++) { - /* Any non-digit means it's not an integer; - this takes care of NAN and INF as well. */ - if (!isdigit(Py_CHARMASK(*cp))) - break; - } - if (*cp == '\0') { - *cp++ = '.'; - *cp++ = '0'; - *cp++ = '\0'; - } -} - -/* XXX PyFloat_AsStringEx should not be a public API function (for one - XXX thing, its signature passes a buffer without a length; for another, - XXX it isn't useful outside this file). -*/ -void -PyFloat_AsStringEx(char *buf, PyFloatObject *v, int precision) -{ - format_float(buf, 100, v, precision); -} - -/* Macro and helper that convert PyObject obj to a C double and store - the value in dbl; this replaces the functionality of the coercion - slot function. If conversion to double raises an exception, obj is - set to NULL, and the function invoking this macro returns NULL. If - obj is not of float, int or long type, Py_NotImplemented is incref'ed, - stored in obj, and returned from the function invoking this macro. -*/ -#define CONVERT_TO_DOUBLE(obj, dbl) \ - if (PyFloat_Check(obj)) \ - dbl = PyFloat_AS_DOUBLE(obj); \ - else if (convert_to_double(&(obj), &(dbl)) < 0) \ - return obj; - -static int -convert_to_double(PyObject **v, double *dbl) -{ - register PyObject *obj = *v; - - if (PyInt_Check(obj)) { - *dbl = (double)PyInt_AS_LONG(obj); - } - else if (PyLong_Check(obj)) { - *dbl = PyLong_AsDouble(obj); - if (*dbl == -1.0 && PyErr_Occurred()) { - *v = NULL; - return -1; - } - } - else { - Py_INCREF(Py_NotImplemented); - *v = Py_NotImplemented; - return -1; - } - return 0; -} - -/* Precisions used by repr() and str(), respectively. - - The repr() precision (17 significant decimal digits) is the minimal number - that is guaranteed to have enough precision so that if the number is read - back in the exact same binary value is recreated. This is true for IEEE - floating point by design, and also happens to work for all other modern - hardware. - - The str() precision is chosen so that in most cases, the rounding noise - created by various operations is suppressed, while giving plenty of - precision for practical use. - -*/ - -#define PREC_REPR 17 -#define PREC_STR 12 - -/* XXX PyFloat_AsString and PyFloat_AsReprString should be deprecated: - XXX they pass a char buffer without passing a length. -*/ -void -PyFloat_AsString(char *buf, PyFloatObject *v) -{ - format_float(buf, 100, v, PREC_STR); -} - -void -PyFloat_AsReprString(char *buf, PyFloatObject *v) -{ - format_float(buf, 100, v, PREC_REPR); -} - -/* ARGSUSED */ -static int -float_print(PyFloatObject *v, FILE *fp, int flags) -{ - char buf[100]; - format_float(buf, sizeof(buf), v, - (flags & Py_PRINT_RAW) ? PREC_STR : PREC_REPR); - fputs(buf, fp); - return 0; -} - -static PyObject * -float_repr(PyFloatObject *v) -{ - char buf[100]; - format_float(buf, sizeof(buf), v, PREC_REPR); - return PyString_FromString(buf); -} - -static PyObject * -float_str(PyFloatObject *v) -{ - char buf[100]; - format_float(buf, sizeof(buf), v, PREC_STR); - return PyString_FromString(buf); -} - -static int -float_compare(PyFloatObject *v, PyFloatObject *w) -{ - double i = v->ob_fval; - double j = w->ob_fval; - return (i < j) ? -1 : (i > j) ? 1 : 0; -} - -static long -float_hash(PyFloatObject *v) -{ - return _Py_HashDouble(v->ob_fval); -} - -static PyObject * -float_add(PyObject *v, PyObject *w) -{ - double a,b; - CONVERT_TO_DOUBLE(v, a); - CONVERT_TO_DOUBLE(w, b); - PyFPE_START_PROTECT("add", return 0) - a = a + b; - PyFPE_END_PROTECT(a) - return PyFloat_FromDouble(a); -} - -static PyObject * -float_sub(PyObject *v, PyObject *w) -{ - double a,b; - CONVERT_TO_DOUBLE(v, a); - CONVERT_TO_DOUBLE(w, b); - PyFPE_START_PROTECT("subtract", return 0) - a = a - b; - PyFPE_END_PROTECT(a) - return PyFloat_FromDouble(a); -} - -static PyObject * -float_mul(PyObject *v, PyObject *w) -{ - double a,b; - CONVERT_TO_DOUBLE(v, a); - CONVERT_TO_DOUBLE(w, b); - PyFPE_START_PROTECT("multiply", return 0) - a = a * b; - PyFPE_END_PROTECT(a) - return PyFloat_FromDouble(a); -} - -static PyObject * -float_div(PyObject *v, PyObject *w) -{ - double a,b; - CONVERT_TO_DOUBLE(v, a); - CONVERT_TO_DOUBLE(w, b); - if (b == 0.0) { - PyErr_SetString(PyExc_ZeroDivisionError, "float division"); - return NULL; - } - PyFPE_START_PROTECT("divide", return 0) - a = a / b; - PyFPE_END_PROTECT(a) - return PyFloat_FromDouble(a); -} - -static PyObject * -float_classic_div(PyObject *v, PyObject *w) -{ - double a,b; - CONVERT_TO_DOUBLE(v, a); - CONVERT_TO_DOUBLE(w, b); - if (Py_DivisionWarningFlag >= 2 && - PyErr_Warn(PyExc_DeprecationWarning, "classic float division") < 0) - return NULL; - if (b == 0.0) { - PyErr_SetString(PyExc_ZeroDivisionError, "float division"); - return NULL; - } - PyFPE_START_PROTECT("divide", return 0) - a = a / b; - PyFPE_END_PROTECT(a) - return PyFloat_FromDouble(a); -} - -static PyObject * -float_rem(PyObject *v, PyObject *w) -{ - double vx, wx; - double mod; - CONVERT_TO_DOUBLE(v, vx); - CONVERT_TO_DOUBLE(w, wx); - if (wx == 0.0) { - PyErr_SetString(PyExc_ZeroDivisionError, "float modulo"); - return NULL; - } - PyFPE_START_PROTECT("modulo", return 0) - mod = fmod(vx, wx); - /* note: checking mod*wx < 0 is incorrect -- underflows to - 0 if wx < sqrt(smallest nonzero double) */ - if (mod && ((wx < 0) != (mod < 0))) { - mod += wx; - } - PyFPE_END_PROTECT(mod) - return PyFloat_FromDouble(mod); -} - -static PyObject * -float_divmod(PyObject *v, PyObject *w) -{ - double vx, wx; - double div, mod, floordiv; - CONVERT_TO_DOUBLE(v, vx); - CONVERT_TO_DOUBLE(w, wx); - if (wx == 0.0) { - PyErr_SetString(PyExc_ZeroDivisionError, "float divmod()"); - return NULL; - } - PyFPE_START_PROTECT("divmod", return 0) - mod = fmod(vx, wx); - /* fmod is typically exact, so vx-mod is *mathematically* an - exact multiple of wx. But this is fp arithmetic, and fp - vx - mod is an approximation; the result is that div may - not be an exact integral value after the division, although - it will always be very close to one. - */ - div = (vx - mod) / wx; - if (mod) { - /* ensure the remainder has the same sign as the denominator */ - if ((wx < 0) != (mod < 0)) { - mod += wx; - div -= 1.0; - } - } - else { - /* the remainder is zero, and in the presence of signed zeroes - fmod returns different results across platforms; ensure - it has the same sign as the denominator; we'd like to do - "mod = wx * 0.0", but that may get optimized away */ - mod *= mod; /* hide "mod = +0" from optimizer */ - if (wx < 0.0) - mod = -mod; - } - /* snap quotient to nearest integral value */ - if (div) { - floordiv = floor(div); - if (div - floordiv > 0.5) - floordiv += 1.0; - } - else { - /* div is zero - get the same sign as the true quotient */ - div *= div; /* hide "div = +0" from optimizers */ - floordiv = div * vx / wx; /* zero w/ sign of vx/wx */ - } - PyFPE_END_PROTECT(floordiv) - return Py_BuildValue("(dd)", floordiv, mod); -} - -static PyObject * -float_floor_div(PyObject *v, PyObject *w) -{ - PyObject *t, *r; - - t = float_divmod(v, w); - if (t == NULL || t == Py_NotImplemented) - return t; - assert(PyTuple_CheckExact(t)); - r = PyTuple_GET_ITEM(t, 0); - Py_INCREF(r); - Py_DECREF(t); - return r; -} - -static PyObject * -float_pow(PyObject *v, PyObject *w, PyObject *z) -{ - double iv, iw, ix; - - if ((PyObject *)z != Py_None) { - PyErr_SetString(PyExc_TypeError, "pow() 3rd argument not " - "allowed unless all arguments are integers"); - return NULL; - } - - CONVERT_TO_DOUBLE(v, iv); - CONVERT_TO_DOUBLE(w, iw); - - /* Sort out special cases here instead of relying on pow() */ - if (iw == 0) { /* v**0 is 1, even 0**0 */ - PyFPE_START_PROTECT("pow", return NULL) - if ((PyObject *)z != Py_None) { - double iz; - CONVERT_TO_DOUBLE(z, iz); - ix = fmod(1.0, iz); - if (ix != 0 && iz < 0) - ix += iz; - } - else - ix = 1.0; - PyFPE_END_PROTECT(ix) - return PyFloat_FromDouble(ix); - } - if (iv == 0.0) { /* 0**w is error if w<0, else 1 */ - if (iw < 0.0) { - PyErr_SetString(PyExc_ZeroDivisionError, - "0.0 cannot be raised to a negative power"); - return NULL; - } - return PyFloat_FromDouble(0.0); - } - if (iv < 0.0) { - /* Whether this is an error is a mess, and bumps into libm - * bugs so we have to figure it out ourselves. - */ - if (iw != floor(iw)) { - PyErr_SetString(PyExc_ValueError, "negative number " - "cannot be raised to a fractional power"); - return NULL; - } - /* iw is an exact integer, albeit perhaps a very large one. - * -1 raised to an exact integer should never be exceptional. - * Alas, some libms (chiefly glibc as of early 2003) return - * NaN and set EDOM on pow(-1, large_int) if the int doesn't - * happen to be representable in a *C* integer. That's a - * bug; we let that slide in math.pow() (which currently - * reflects all platform accidents), but not for Python's **. - */ - if (iv == -1.0 && !Py_IS_INFINITY(iw) && iw == iw) { - /* XXX the "iw == iw" was to weed out NaNs. This - * XXX doesn't actually work on all platforms. - */ - /* Return 1 if iw is even, -1 if iw is odd; there's - * no guarantee that any C integral type is big - * enough to hold iw, so we have to check this - * indirectly. - */ - ix = floor(iw * 0.5) * 2.0; - return PyFloat_FromDouble(ix == iw ? 1.0 : -1.0); - } - /* Else iv != -1.0, and overflow or underflow are possible. - * Unless we're to write pow() ourselves, we have to trust - * the platform to do this correctly. - */ - } - errno = 0; - PyFPE_START_PROTECT("pow", return NULL) - ix = pow(iv, iw); - PyFPE_END_PROTECT(ix) - Py_ADJUST_ERANGE1(ix); - if (errno != 0) { - /* We don't expect any errno value other than ERANGE, but - * the range of libm bugs appears unbounded. - */ - PyErr_SetFromErrno(errno == ERANGE ? PyExc_OverflowError : - PyExc_ValueError); - return NULL; - } - return PyFloat_FromDouble(ix); -} - -static PyObject * -float_neg(PyFloatObject *v) -{ - return PyFloat_FromDouble(-v->ob_fval); -} - -static PyObject * -float_pos(PyFloatObject *v) -{ - if (PyFloat_CheckExact(v)) { - Py_INCREF(v); - return (PyObject *)v; - } - else - return PyFloat_FromDouble(v->ob_fval); -} - -static PyObject * -float_abs(PyFloatObject *v) -{ - return PyFloat_FromDouble(fabs(v->ob_fval)); -} - -static int -float_nonzero(PyFloatObject *v) -{ - return v->ob_fval != 0.0; -} - -static int -float_coerce(PyObject **pv, PyObject **pw) -{ - if (PyInt_Check(*pw)) { - long x = PyInt_AsLong(*pw); - *pw = PyFloat_FromDouble((double)x); - Py_INCREF(*pv); - return 0; - } - else if (PyLong_Check(*pw)) { - double x = PyLong_AsDouble(*pw); - if (x == -1.0 && PyErr_Occurred()) - return -1; - *pw = PyFloat_FromDouble(x); - Py_INCREF(*pv); - return 0; - } - else if (PyFloat_Check(*pw)) { - Py_INCREF(*pv); - Py_INCREF(*pw); - return 0; - } - return 1; /* Can't do it */ -} - -static PyObject * -float_long(PyObject *v) -{ - double x = PyFloat_AsDouble(v); - return PyLong_FromDouble(x); -} - -static PyObject * -float_int(PyObject *v) -{ - double x = PyFloat_AsDouble(v); - double wholepart; /* integral portion of x, rounded toward 0 */ - - (void)modf(x, &wholepart); - /* Try to get out cheap if this fits in a Python int. The attempt - * to cast to long must be protected, as C doesn't define what - * happens if the double is too big to fit in a long. Some rare - * systems raise an exception then (RISCOS was mentioned as one, - * and someone using a non-default option on Sun also bumped into - * that). Note that checking for >= and <= LONG_{MIN,MAX} would - * still be vulnerable: if a long has more bits of precision than - * a double, casting MIN/MAX to double may yield an approximation, - * and if that's rounded up, then, e.g., wholepart=LONG_MAX+1 would - * yield true from the C expression wholepart<=LONG_MAX, despite - * that wholepart is actually greater than LONG_MAX. - */ - if (LONG_MIN < wholepart && wholepart < LONG_MAX) { - const long aslong = (long)wholepart; - return PyInt_FromLong(aslong); - } - return PyLong_FromDouble(wholepart); -} - -static PyObject * -float_float(PyObject *v) -{ - Py_INCREF(v); - return v; -} - - -static PyObject * -float_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); - -static PyObject * -float_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *x = Py_False; /* Integer zero */ - static char *kwlist[] = {"x", 0}; - - if (type != &PyFloat_Type) - return float_subtype_new(type, args, kwds); /* Wimp out */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:float", kwlist, &x)) - return NULL; - if (PyString_Check(x)) - return PyFloat_FromString(x, NULL); - return PyNumber_Float(x); -} - -/* Wimpy, slow approach to tp_new calls for subtypes of float: - first create a regular float from whatever arguments we got, - then allocate a subtype instance and initialize its ob_fval - from the regular float. The regular float is then thrown away. -*/ -static PyObject * -float_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *tmp, *new; - - assert(PyType_IsSubtype(type, &PyFloat_Type)); - tmp = float_new(&PyFloat_Type, args, kwds); - if (tmp == NULL) - return NULL; - assert(PyFloat_CheckExact(tmp)); - new = type->tp_alloc(type, 0); - if (new == NULL) { - Py_DECREF(tmp); - return NULL; - } - ((PyFloatObject *)new)->ob_fval = ((PyFloatObject *)tmp)->ob_fval; - Py_DECREF(tmp); - return new; -} - -static PyObject * -float_getnewargs(PyFloatObject *v) -{ - return Py_BuildValue("(d)", v->ob_fval); -} - -static PyMethodDef float_methods[] = { - {"__getnewargs__", (PyCFunction)float_getnewargs, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - -PyDoc_STRVAR(float_doc, -"float(x) -> floating point number\n\ -\n\ -Convert a string or number to a floating point number, if possible."); - - -static PyNumberMethods float_as_number = { - (binaryfunc)float_add, /*nb_add*/ - (binaryfunc)float_sub, /*nb_subtract*/ - (binaryfunc)float_mul, /*nb_multiply*/ - (binaryfunc)float_classic_div, /*nb_divide*/ - (binaryfunc)float_rem, /*nb_remainder*/ - (binaryfunc)float_divmod, /*nb_divmod*/ - (ternaryfunc)float_pow, /*nb_power*/ - (unaryfunc)float_neg, /*nb_negative*/ - (unaryfunc)float_pos, /*nb_positive*/ - (unaryfunc)float_abs, /*nb_absolute*/ - (inquiry)float_nonzero, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - (coercion)float_coerce, /*nb_coerce*/ - (unaryfunc)float_int, /*nb_int*/ - (unaryfunc)float_long, /*nb_long*/ - (unaryfunc)float_float, /*nb_float*/ - 0, /* nb_oct */ - 0, /* nb_hex */ - 0, /* nb_inplace_add */ - 0, /* nb_inplace_subtract */ - 0, /* nb_inplace_multiply */ - 0, /* nb_inplace_divide */ - 0, /* nb_inplace_remainder */ - 0, /* nb_inplace_power */ - 0, /* nb_inplace_lshift */ - 0, /* nb_inplace_rshift */ - 0, /* nb_inplace_and */ - 0, /* nb_inplace_xor */ - 0, /* nb_inplace_or */ - float_floor_div, /* nb_floor_divide */ - float_div, /* nb_true_divide */ - 0, /* nb_inplace_floor_divide */ - 0, /* nb_inplace_true_divide */ -}; - -PyTypeObject PyFloat_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "float", - sizeof(PyFloatObject), - 0, - (destructor)float_dealloc, /* tp_dealloc */ - (printfunc)float_print, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)float_compare, /* tp_compare */ - (reprfunc)float_repr, /* tp_repr */ - &float_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)float_hash, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)float_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - float_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - float_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - float_new, /* tp_new */ -}; - -void -PyFloat_Fini(void) -{ - PyFloatObject *p; - PyFloatBlock *list, *next; - int i; - int bc, bf; /* block count, number of freed blocks */ - int frem, fsum; /* remaining unfreed floats per block, total */ - - bc = 0; - bf = 0; - fsum = 0; - list = block_list; - block_list = NULL; - free_list = NULL; - while (list != NULL) { - bc++; - frem = 0; - for (i = 0, p = &list->objects[0]; - i < N_FLOATOBJECTS; - i++, p++) { - if (PyFloat_CheckExact(p) && p->ob_refcnt != 0) - frem++; - } - next = list->next; - if (frem) { - list->next = block_list; - block_list = list; - for (i = 0, p = &list->objects[0]; - i < N_FLOATOBJECTS; - i++, p++) { - if (!PyFloat_CheckExact(p) || - p->ob_refcnt == 0) { - p->ob_type = (struct _typeobject *) - free_list; - free_list = p; - } - } - } - else { - PyMem_FREE(list); /* XXX PyObject_FREE ??? */ - bf++; - } - fsum += frem; - list = next; - } - if (!Py_VerboseFlag) - return; - fprintf(stderr, "# cleanup floats"); - if (!fsum) { - fprintf(stderr, "\n"); - } - else { - fprintf(stderr, - ": %d unfreed float%s in %d out of %d block%s\n", - fsum, fsum == 1 ? "" : "s", - bc - bf, bc, bc == 1 ? "" : "s"); - } - if (Py_VerboseFlag > 1) { - list = block_list; - while (list != NULL) { - for (i = 0, p = &list->objects[0]; - i < N_FLOATOBJECTS; - i++, p++) { - if (PyFloat_CheckExact(p) && - p->ob_refcnt != 0) { - char buf[100]; - PyFloat_AsString(buf, p); - fprintf(stderr, - "# \n", - p, p->ob_refcnt, buf); - } - } - list = list->next; - } - } -} - -/*---------------------------------------------------------------------------- - * _PyFloat_{Pack,Unpack}{4,8}. See floatobject.h. - * - * TODO: On platforms that use the standard IEEE-754 single and double - * formats natively, these routines could simply copy the bytes. - */ -int -_PyFloat_Pack4(double x, unsigned char *p, int le) -{ - unsigned char sign; - int e; - double f; - unsigned int fbits; - int incr = 1; - - if (le) { - p += 3; - incr = -1; - } - - if (x < 0) { - sign = 1; - x = -x; - } - else - sign = 0; - - f = frexp(x, &e); - - /* Normalize f to be in the range [1.0, 2.0) */ - if (0.5 <= f && f < 1.0) { - f *= 2.0; - e--; - } - else if (f == 0.0) - e = 0; - else { - PyErr_SetString(PyExc_SystemError, - "frexp() result out of range"); - return -1; - } - - if (e >= 128) - goto Overflow; - else if (e < -126) { - /* Gradual underflow */ - f = ldexp(f, 126 + e); - e = 0; - } - else if (!(e == 0 && f == 0.0)) { - e += 127; - f -= 1.0; /* Get rid of leading 1 */ - } - - f *= 8388608.0; /* 2**23 */ - fbits = (unsigned int)(f + 0.5); /* Round */ - assert(fbits <= 8388608); - if (fbits >> 23) { - /* The carry propagated out of a string of 23 1 bits. */ - fbits = 0; - ++e; - if (e >= 255) - goto Overflow; - } - - /* First byte */ - *p = (sign << 7) | (e >> 1); - p += incr; - - /* Second byte */ - *p = (char) (((e & 1) << 7) | (fbits >> 16)); - p += incr; - - /* Third byte */ - *p = (fbits >> 8) & 0xFF; - p += incr; - - /* Fourth byte */ - *p = fbits & 0xFF; - - /* Done */ - return 0; - - Overflow: - PyErr_SetString(PyExc_OverflowError, - "float too large to pack with f format"); - return -1; -} - -int -_PyFloat_Pack8(double x, unsigned char *p, int le) -{ - unsigned char sign; - int e; - double f; - unsigned int fhi, flo; - int incr = 1; - - if (le) { - p += 7; - incr = -1; - } - - if (x < 0) { - sign = 1; - x = -x; - } - else - sign = 0; - - f = frexp(x, &e); - - /* Normalize f to be in the range [1.0, 2.0) */ - if (0.5 <= f && f < 1.0) { - f *= 2.0; - e--; - } - else if (f == 0.0) - e = 0; - else { - PyErr_SetString(PyExc_SystemError, - "frexp() result out of range"); - return -1; - } - - if (e >= 1024) - goto Overflow; - else if (e < -1022) { - /* Gradual underflow */ - f = ldexp(f, 1022 + e); - e = 0; - } - else if (!(e == 0 && f == 0.0)) { - e += 1023; - f -= 1.0; /* Get rid of leading 1 */ - } - - /* fhi receives the high 28 bits; flo the low 24 bits (== 52 bits) */ - f *= 268435456.0; /* 2**28 */ - fhi = (unsigned int)f; /* Truncate */ - assert(fhi < 268435456); - - f -= (double)fhi; - f *= 16777216.0; /* 2**24 */ - flo = (unsigned int)(f + 0.5); /* Round */ - assert(flo <= 16777216); - if (flo >> 24) { - /* The carry propagated out of a string of 24 1 bits. */ - flo = 0; - ++fhi; - if (fhi >> 28) { - /* And it also progagated out of the next 28 bits. */ - fhi = 0; - ++e; - if (e >= 2047) - goto Overflow; - } - } - - /* First byte */ - *p = (sign << 7) | (e >> 4); - p += incr; - - /* Second byte */ - *p = (unsigned char) (((e & 0xF) << 4) | (fhi >> 24)); - p += incr; - - /* Third byte */ - *p = (fhi >> 16) & 0xFF; - p += incr; - - /* Fourth byte */ - *p = (fhi >> 8) & 0xFF; - p += incr; - - /* Fifth byte */ - *p = fhi & 0xFF; - p += incr; - - /* Sixth byte */ - *p = (flo >> 16) & 0xFF; - p += incr; - - /* Seventh byte */ - *p = (flo >> 8) & 0xFF; - p += incr; - - /* Eighth byte */ - *p = flo & 0xFF; - p += incr; - - /* Done */ - return 0; - - Overflow: - PyErr_SetString(PyExc_OverflowError, - "float too large to pack with d format"); - return -1; -} - -double -_PyFloat_Unpack4(const unsigned char *p, int le) -{ - unsigned char sign; - int e; - unsigned int f; - double x; - int incr = 1; - - if (le) { - p += 3; - incr = -1; - } - - /* First byte */ - sign = (*p >> 7) & 1; - e = (*p & 0x7F) << 1; - p += incr; - - /* Second byte */ - e |= (*p >> 7) & 1; - f = (*p & 0x7F) << 16; - p += incr; - - /* Third byte */ - f |= *p << 8; - p += incr; - - /* Fourth byte */ - f |= *p; - - x = (double)f / 8388608.0; - - /* XXX This sadly ignores Inf/NaN issues */ - if (e == 0) - e = -126; - else { - x += 1.0; - e -= 127; - } - x = ldexp(x, e); - - if (sign) - x = -x; - - return x; -} - -double -_PyFloat_Unpack8(const unsigned char *p, int le) -{ - unsigned char sign; - int e; - unsigned int fhi, flo; - double x; - int incr = 1; - - if (le) { - p += 7; - incr = -1; - } - - /* First byte */ - sign = (*p >> 7) & 1; - e = (*p & 0x7F) << 4; - p += incr; - - /* Second byte */ - e |= (*p >> 4) & 0xF; - fhi = (*p & 0xF) << 24; - p += incr; - - /* Third byte */ - fhi |= *p << 16; - p += incr; - - /* Fourth byte */ - fhi |= *p << 8; - p += incr; - - /* Fifth byte */ - fhi |= *p; - p += incr; - - /* Sixth byte */ - flo = *p << 16; - p += incr; - - /* Seventh byte */ - flo |= *p << 8; - p += incr; - - /* Eighth byte */ - flo |= *p; - - x = (double)fhi + (double)flo / 16777216.0; /* 2**24 */ - x /= 268435456.0; /* 2**28 */ - - /* XXX This sadly ignores Inf/NaN */ - if (e == 0) - e = -1022; - else { - x += 1.0; - e -= 1023; - } - x = ldexp(x, e); - - if (sign) - x = -x; - - return x; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/frameobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/frameobject.c deleted file mode 100644 index 86b0dfda..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/frameobject.c +++ /dev/null @@ -1,815 +0,0 @@ - -/* Frame object implementation */ - -#include "Python.h" - -#include "compile.h" -#include "frameobject.h" -#include "opcode.h" -#include "structmember.h" - -#undef MIN -#undef MAX -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define MAX(a, b) ((a) > (b) ? (a) : (b)) - -#define OFF(x) offsetof(PyFrameObject, x) - -static PyMemberDef frame_memberlist[] = { - {"f_back", T_OBJECT, OFF(f_back), RO}, - {"f_code", T_OBJECT, OFF(f_code), RO}, - {"f_builtins", T_OBJECT, OFF(f_builtins),RO}, - {"f_globals", T_OBJECT, OFF(f_globals), RO}, - {"f_lasti", T_INT, OFF(f_lasti), RO}, - {"f_restricted",T_INT, OFF(f_restricted),RO}, - {"f_exc_type", T_OBJECT, OFF(f_exc_type)}, - {"f_exc_value", T_OBJECT, OFF(f_exc_value)}, - {"f_exc_traceback", T_OBJECT, OFF(f_exc_traceback)}, - {NULL} /* Sentinel */ -}; - -static PyObject * -frame_getlocals(PyFrameObject *f, void *closure) -{ - PyFrame_FastToLocals(f); - Py_INCREF(f->f_locals); - return f->f_locals; -} - -static PyObject * -frame_getlineno(PyFrameObject *f, void *closure) -{ - int lineno; - - if (f->f_trace) - lineno = f->f_lineno; - else - lineno = PyCode_Addr2Line(f->f_code, f->f_lasti); - - return PyInt_FromLong(lineno); -} - -/* Setter for f_lineno - you can set f_lineno from within a trace function in - * order to jump to a given line of code, subject to some restrictions. Most - * lines are OK to jump to because they don't make any assumptions about the - * state of the stack (obvious because you could remove the line and the code - * would still work without any stack errors), but there are some constructs - * that limit jumping: - * - * o Lines with an 'except' statement on them can't be jumped to, because - * they expect an exception to be on the top of the stack. - * o Lines that live in a 'finally' block can't be jumped from or to, since - * the END_FINALLY expects to clean up the stack after the 'try' block. - * o 'try'/'for'/'while' blocks can't be jumped into because the blockstack - * needs to be set up before their code runs, and for 'for' loops the - * iterator needs to be on the stack. - */ -static int -frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno) -{ - int new_lineno = 0; /* The new value of f_lineno */ - int new_lasti = 0; /* The new value of f_lasti */ - int new_iblock = 0; /* The new value of f_iblock */ - char *code = NULL; /* The bytecode for the frame... */ - int code_len = 0; /* ...and its length */ - char *lnotab = NULL; /* Iterating over co_lnotab */ - int lnotab_len = 0; /* (ditto) */ - int offset = 0; /* (ditto) */ - int line = 0; /* (ditto) */ - int addr = 0; /* (ditto) */ - int min_addr = 0; /* Scanning the SETUPs and POPs */ - int max_addr = 0; /* (ditto) */ - int delta_iblock = 0; /* (ditto) */ - int min_delta_iblock = 0; /* (ditto) */ - int min_iblock = 0; /* (ditto) */ - int f_lasti_setup_addr = 0; /* Policing no-jump-into-finally */ - int new_lasti_setup_addr = 0; /* (ditto) */ - int blockstack[CO_MAXBLOCKS]; /* Walking the 'finally' blocks */ - int in_finally[CO_MAXBLOCKS]; /* (ditto) */ - int blockstack_top = 0; /* (ditto) */ - int setup_op = 0; /* (ditto) */ - - /* f_lineno must be an integer. */ - if (!PyInt_Check(p_new_lineno)) { - PyErr_SetString(PyExc_ValueError, - "lineno must be an integer"); - return -1; - } - - /* You can only do this from within a trace function, not via - * _getframe or similar hackery. */ - if (!f->f_trace) - { - PyErr_Format(PyExc_ValueError, - "f_lineno can only be set by a trace function"); - return -1; - } - - /* Fail if the line comes before the start of the code block. */ - new_lineno = (int) PyInt_AsLong(p_new_lineno); - if (new_lineno < f->f_code->co_firstlineno) { - PyErr_Format(PyExc_ValueError, - "line %d comes before the current code block", - new_lineno); - return -1; - } - - /* Find the bytecode offset for the start of the given line, or the - * first code-owning line after it. */ - PyString_AsStringAndSize(f->f_code->co_lnotab, &lnotab, &lnotab_len); - addr = 0; - line = f->f_code->co_firstlineno; - new_lasti = -1; - for (offset = 0; offset < lnotab_len; offset += 2) { - addr += lnotab[offset]; - line += lnotab[offset+1]; - if (line >= new_lineno) { - new_lasti = addr; - new_lineno = line; - break; - } - } - - /* If we didn't reach the requested line, return an error. */ - if (new_lasti == -1) { - PyErr_Format(PyExc_ValueError, - "line %d comes after the current code block", - new_lineno); - return -1; - } - - /* We're now ready to look at the bytecode. */ - PyString_AsStringAndSize(f->f_code->co_code, &code, &code_len); - min_addr = MIN(new_lasti, f->f_lasti); - max_addr = MAX(new_lasti, f->f_lasti); - - /* You can't jump onto a line with an 'except' statement on it - - * they expect to have an exception on the top of the stack, which - * won't be true if you jump to them. They always start with code - * that either pops the exception using POP_TOP (plain 'except:' - * lines do this) or duplicates the exception on the stack using - * DUP_TOP (if there's an exception type specified). See compile.c, - * 'com_try_except' for the full details. There aren't any other - * cases (AFAIK) where a line's code can start with DUP_TOP or - * POP_TOP, but if any ever appear, they'll be subject to the same - * restriction (but with a different error message). */ - if (code[new_lasti] == DUP_TOP || code[new_lasti] == POP_TOP) { - PyErr_SetString(PyExc_ValueError, - "can't jump to 'except' line as there's no exception"); - return -1; - } - - /* You can't jump into or out of a 'finally' block because the 'try' - * block leaves something on the stack for the END_FINALLY to clean - * up. So we walk the bytecode, maintaining a simulated blockstack. - * When we reach the old or new address and it's in a 'finally' block - * we note the address of the corresponding SETUP_FINALLY. The jump - * is only legal if neither address is in a 'finally' block or - * they're both in the same one. 'blockstack' is a stack of the - * bytecode addresses of the SETUP_X opcodes, and 'in_finally' tracks - * whether we're in a 'finally' block at each blockstack level. */ - f_lasti_setup_addr = -1; - new_lasti_setup_addr = -1; - memset(blockstack, '\0', sizeof(blockstack)); - memset(in_finally, '\0', sizeof(in_finally)); - blockstack_top = 0; - for (addr = 0; addr < code_len; addr++) { - unsigned char op = code[addr]; - switch (op) { - case SETUP_LOOP: - case SETUP_EXCEPT: - case SETUP_FINALLY: - blockstack[blockstack_top++] = addr; - in_finally[blockstack_top-1] = 0; - break; - - case POP_BLOCK: - assert(blockstack_top > 0); - setup_op = code[blockstack[blockstack_top-1]]; - if (setup_op == SETUP_FINALLY) { - in_finally[blockstack_top-1] = 1; - } - else { - blockstack_top--; - } - break; - - case END_FINALLY: - /* Ignore END_FINALLYs for SETUP_EXCEPTs - they exist - * in the bytecode but don't correspond to an actual - * 'finally' block. (If blockstack_top is 0, we must - * be seeing such an END_FINALLY.) */ - if (blockstack_top > 0) { - setup_op = code[blockstack[blockstack_top-1]]; - if (setup_op == SETUP_FINALLY) { - blockstack_top--; - } - } - break; - } - - /* For the addresses we're interested in, see whether they're - * within a 'finally' block and if so, remember the address - * of the SETUP_FINALLY. */ - if (addr == new_lasti || addr == f->f_lasti) { - int i = 0; - int setup_addr = -1; - for (i = blockstack_top-1; i >= 0; i--) { - if (in_finally[i]) { - setup_addr = blockstack[i]; - break; - } - } - - if (setup_addr != -1) { - if (addr == new_lasti) { - new_lasti_setup_addr = setup_addr; - } - - if (addr == f->f_lasti) { - f_lasti_setup_addr = setup_addr; - } - } - } - - if (op >= HAVE_ARGUMENT) { - addr += 2; - } - } - - /* Verify that the blockstack tracking code didn't get lost. */ - assert(blockstack_top == 0); - - /* After all that, are we jumping into / out of a 'finally' block? */ - if (new_lasti_setup_addr != f_lasti_setup_addr) { - PyErr_SetString(PyExc_ValueError, - "can't jump into or out of a 'finally' block"); - return -1; - } - - - /* Police block-jumping (you can't jump into the middle of a block) - * and ensure that the blockstack finishes up in a sensible state (by - * popping any blocks we're jumping out of). We look at all the - * blockstack operations between the current position and the new - * one, and keep track of how many blocks we drop out of on the way. - * By also keeping track of the lowest blockstack position we see, we - * can tell whether the jump goes into any blocks without coming out - * again - in that case we raise an exception below. */ - delta_iblock = 0; - for (addr = min_addr; addr < max_addr; addr++) { - unsigned char op = code[addr]; - switch (op) { - case SETUP_LOOP: - case SETUP_EXCEPT: - case SETUP_FINALLY: - delta_iblock++; - break; - - case POP_BLOCK: - delta_iblock--; - break; - } - - min_delta_iblock = MIN(min_delta_iblock, delta_iblock); - - if (op >= HAVE_ARGUMENT) { - addr += 2; - } - } - - /* Derive the absolute iblock values from the deltas. */ - min_iblock = f->f_iblock + min_delta_iblock; - if (new_lasti > f->f_lasti) { - /* Forwards jump. */ - new_iblock = f->f_iblock + delta_iblock; - } - else { - /* Backwards jump. */ - new_iblock = f->f_iblock - delta_iblock; - } - - /* Are we jumping into a block? */ - if (new_iblock > min_iblock) { - PyErr_SetString(PyExc_ValueError, - "can't jump into the middle of a block"); - return -1; - } - - /* Pop any blocks that we're jumping out of. */ - while (f->f_iblock > new_iblock) { - PyTryBlock *b = &f->f_blockstack[--f->f_iblock]; - while ((f->f_stacktop - f->f_valuestack) > b->b_level) { - PyObject *v = (*--f->f_stacktop); - Py_DECREF(v); - } - } - - /* Finally set the new f_lineno and f_lasti and return OK. */ - f->f_lineno = new_lineno; - f->f_lasti = new_lasti; - return 0; -} - -static PyObject * -frame_gettrace(PyFrameObject *f, void *closure) -{ - PyObject* trace = f->f_trace; - - if (trace == NULL) - trace = Py_None; - - Py_INCREF(trace); - - return trace; -} - -static int -frame_settrace(PyFrameObject *f, PyObject* v, void *closure) -{ - /* We rely on f_lineno being accurate when f_trace is set. */ - - PyObject* old_value = f->f_trace; - - Py_XINCREF(v); - f->f_trace = v; - - if (v != NULL) - f->f_lineno = PyCode_Addr2Line(f->f_code, f->f_lasti); - - Py_XDECREF(old_value); - - return 0; -} - -static PyGetSetDef frame_getsetlist[] = { - {"f_locals", (getter)frame_getlocals, NULL, NULL}, - {"f_lineno", (getter)frame_getlineno, - (setter)frame_setlineno, NULL}, - {"f_trace", (getter)frame_gettrace, (setter)frame_settrace, NULL}, - {0} -}; - -/* Stack frames are allocated and deallocated at a considerable rate. - In an attempt to improve the speed of function calls, we maintain a - separate free list of stack frames (just like integers are - allocated in a special way -- see intobject.c). When a stack frame - is on the free list, only the following members have a meaning: - ob_type == &Frametype - f_back next item on free list, or NULL - f_nlocals number of locals - f_stacksize size of value stack - ob_size size of localsplus - Note that the value and block stacks are preserved -- this can save - another malloc() call or two (and two free() calls as well!). - Also note that, unlike for integers, each frame object is a - malloc'ed object in its own right -- it is only the actual calls to - malloc() that we are trying to save here, not the administration. - After all, while a typical program may make millions of calls, a - call depth of more than 20 or 30 is probably already exceptional - unless the program contains run-away recursion. I hope. - - Later, MAXFREELIST was added to bound the # of frames saved on - free_list. Else programs creating lots of cyclic trash involving - frames could provoke free_list into growing without bound. -*/ - -static PyFrameObject *free_list = NULL; -static int numfree = 0; /* number of frames currently in free_list */ -#define MAXFREELIST 200 /* max value for numfree */ - -static void -frame_dealloc(PyFrameObject *f) -{ - int i, slots; - PyObject **fastlocals; - PyObject **p; - - PyObject_GC_UnTrack(f); - Py_TRASHCAN_SAFE_BEGIN(f) - /* Kill all local variables */ - slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; - fastlocals = f->f_localsplus; - for (i = slots; --i >= 0; ++fastlocals) { - Py_XDECREF(*fastlocals); - } - - /* Free stack */ - if (f->f_stacktop != NULL) { - for (p = f->f_valuestack; p < f->f_stacktop; p++) - Py_XDECREF(*p); - } - - Py_XDECREF(f->f_back); - Py_DECREF(f->f_code); - Py_DECREF(f->f_builtins); - Py_DECREF(f->f_globals); - Py_XDECREF(f->f_locals); - Py_XDECREF(f->f_trace); - Py_XDECREF(f->f_exc_type); - Py_XDECREF(f->f_exc_value); - Py_XDECREF(f->f_exc_traceback); - if (numfree < MAXFREELIST) { - ++numfree; - f->f_back = free_list; - free_list = f; - } - else - PyObject_GC_Del(f); - Py_TRASHCAN_SAFE_END(f) -} - -static int -frame_traverse(PyFrameObject *f, visitproc visit, void *arg) -{ - PyObject **fastlocals, **p; - int i, err, slots; -#define VISIT(o) if (o) {if ((err = visit((PyObject *)(o), arg))) return err;} - - VISIT(f->f_back); - VISIT(f->f_code); - VISIT(f->f_builtins); - VISIT(f->f_globals); - VISIT(f->f_locals); - VISIT(f->f_trace); - VISIT(f->f_exc_type); - VISIT(f->f_exc_value); - VISIT(f->f_exc_traceback); - - /* locals */ - slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; - fastlocals = f->f_localsplus; - for (i = slots; --i >= 0; ++fastlocals) { - VISIT(*fastlocals); - } - - /* stack */ - if (f->f_stacktop != NULL) { - for (p = f->f_valuestack; p < f->f_stacktop; p++) - VISIT(*p); - } - return 0; -} - -static void -frame_clear(PyFrameObject *f) -{ - PyObject **fastlocals, **p; - int i, slots; - - Py_XDECREF(f->f_exc_type); - f->f_exc_type = NULL; - - Py_XDECREF(f->f_exc_value); - f->f_exc_value = NULL; - - Py_XDECREF(f->f_exc_traceback); - f->f_exc_traceback = NULL; - - Py_XDECREF(f->f_trace); - f->f_trace = NULL; - - /* locals */ - slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; - fastlocals = f->f_localsplus; - for (i = slots; --i >= 0; ++fastlocals) { - if (*fastlocals != NULL) { - Py_XDECREF(*fastlocals); - *fastlocals = NULL; - } - } - - /* stack */ - if (f->f_stacktop != NULL) { - for (p = f->f_valuestack; p < f->f_stacktop; p++) { - Py_XDECREF(*p); - *p = NULL; - } - } -} - - -PyTypeObject PyFrame_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "frame", - sizeof(PyFrameObject), - sizeof(PyObject *), - (destructor)frame_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - PyObject_GenericSetAttr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - 0, /* tp_doc */ - (traverseproc)frame_traverse, /* tp_traverse */ - (inquiry)frame_clear, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - frame_memberlist, /* tp_members */ - frame_getsetlist, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ -}; - -static PyObject *builtin_object; - -int _PyFrame_Init() -{ - builtin_object = PyString_InternFromString("__builtins__"); - return (builtin_object != NULL); -} - -PyFrameObject * -PyFrame_New(PyThreadState *tstate, PyCodeObject *code, PyObject *globals, - PyObject *locals) -{ - PyFrameObject *back = tstate->frame; - PyFrameObject *f; - PyObject *builtins; - int extras, ncells, nfrees; - -#ifdef Py_DEBUG - if (code == NULL || globals == NULL || !PyDict_Check(globals) || - (locals != NULL && !PyDict_Check(locals))) { - PyErr_BadInternalCall(); - return NULL; - } -#endif - ncells = PyTuple_GET_SIZE(code->co_cellvars); - nfrees = PyTuple_GET_SIZE(code->co_freevars); - extras = code->co_stacksize + code->co_nlocals + ncells + nfrees; - if (back == NULL || back->f_globals != globals) { - builtins = PyDict_GetItem(globals, builtin_object); - if (builtins) { - if (PyModule_Check(builtins)) { - builtins = PyModule_GetDict(builtins); - assert(!builtins || PyDict_Check(builtins)); - } - else if (!PyDict_Check(builtins)) - builtins = NULL; - } - if (builtins == NULL) { - /* No builtins! Make up a minimal one - Give them 'None', at least. */ - builtins = PyDict_New(); - if (builtins == NULL || - PyDict_SetItemString( - builtins, "None", Py_None) < 0) - return NULL; - } - else - Py_INCREF(builtins); - - } - else { - /* If we share the globals, we share the builtins. - Save a lookup and a call. */ - builtins = back->f_builtins; - assert(builtins != NULL && PyDict_Check(builtins)); - Py_INCREF(builtins); - } - if (free_list == NULL) { - f = PyObject_GC_NewVar(PyFrameObject, &PyFrame_Type, extras); - if (f == NULL) - return NULL; - } - else { - assert(numfree > 0); - --numfree; - f = free_list; - free_list = free_list->f_back; - if (f->ob_size < extras) { - f = PyObject_GC_Resize(PyFrameObject, f, extras); - if (f == NULL) - return NULL; - } - _Py_NewReference((PyObject *)f); - } - f->f_builtins = builtins; - Py_XINCREF(back); - f->f_back = back; - Py_INCREF(code); - f->f_code = code; - Py_INCREF(globals); - f->f_globals = globals; - /* Most functions have CO_NEWLOCALS and CO_OPTIMIZED set. */ - if ((code->co_flags & (CO_NEWLOCALS | CO_OPTIMIZED)) == - (CO_NEWLOCALS | CO_OPTIMIZED)) - locals = NULL; /* PyFrame_Fast2Locals() will set. */ - else if (code->co_flags & CO_NEWLOCALS) { - locals = PyDict_New(); - if (locals == NULL) { - Py_DECREF(f); - return NULL; - } - } - else { - if (locals == NULL) - locals = globals; - Py_INCREF(locals); - } - f->f_locals = locals; - f->f_trace = NULL; - f->f_exc_type = f->f_exc_value = f->f_exc_traceback = NULL; - f->f_tstate = tstate; - - f->f_lasti = -1; - f->f_lineno = code->co_firstlineno; - f->f_restricted = (builtins != tstate->interp->builtins); - f->f_iblock = 0; - f->f_nlocals = code->co_nlocals; - f->f_stacksize = code->co_stacksize; - f->f_ncells = ncells; - f->f_nfreevars = nfrees; - - extras = f->f_nlocals + ncells + nfrees; - memset(f->f_localsplus, 0, extras * sizeof(f->f_localsplus[0])); - - f->f_valuestack = f->f_localsplus + extras; - f->f_stacktop = f->f_valuestack; - _PyObject_GC_TRACK(f); - return f; -} - -/* Block management */ - -void -PyFrame_BlockSetup(PyFrameObject *f, int type, int handler, int level) -{ - PyTryBlock *b; - if (f->f_iblock >= CO_MAXBLOCKS) - Py_FatalError("XXX block stack overflow"); - b = &f->f_blockstack[f->f_iblock++]; - b->b_type = type; - b->b_level = level; - b->b_handler = handler; -} - -PyTryBlock * -PyFrame_BlockPop(PyFrameObject *f) -{ - PyTryBlock *b; - if (f->f_iblock <= 0) - Py_FatalError("XXX block stack underflow"); - b = &f->f_blockstack[--f->f_iblock]; - return b; -} - -/* Convert between "fast" version of locals and dictionary version */ - -static void -map_to_dict(PyObject *map, int nmap, PyObject *dict, PyObject **values, - int deref) -{ - int j; - for (j = nmap; --j >= 0; ) { - PyObject *key = PyTuple_GET_ITEM(map, j); - PyObject *value = values[j]; - if (deref) - value = PyCell_GET(value); - if (value == NULL) { - if (PyDict_DelItem(dict, key) != 0) - PyErr_Clear(); - } - else { - if (PyDict_SetItem(dict, key, value) != 0) - PyErr_Clear(); - } - } -} - -static void -dict_to_map(PyObject *map, int nmap, PyObject *dict, PyObject **values, - int deref, int clear) -{ - int j; - for (j = nmap; --j >= 0; ) { - PyObject *key = PyTuple_GET_ITEM(map, j); - PyObject *value = PyDict_GetItem(dict, key); - if (deref) { - if (value || clear) { - if (PyCell_GET(values[j]) != value) { - if (PyCell_Set(values[j], value) < 0) - PyErr_Clear(); - } - } - } else if (value != NULL || clear) { - if (values[j] != value) { - Py_XINCREF(value); - Py_XDECREF(values[j]); - values[j] = value; - } - } - } -} - -void -PyFrame_FastToLocals(PyFrameObject *f) -{ - /* Merge fast locals into f->f_locals */ - PyObject *locals, *map; - PyObject **fast; - PyObject *error_type, *error_value, *error_traceback; - int j; - if (f == NULL) - return; - locals = f->f_locals; - if (locals == NULL) { - locals = f->f_locals = PyDict_New(); - if (locals == NULL) { - PyErr_Clear(); /* Can't report it :-( */ - return; - } - } - map = f->f_code->co_varnames; - if (!PyDict_Check(locals) || !PyTuple_Check(map)) - return; - PyErr_Fetch(&error_type, &error_value, &error_traceback); - fast = f->f_localsplus; - j = PyTuple_Size(map); - if (j > f->f_nlocals) - j = f->f_nlocals; - if (f->f_nlocals) - map_to_dict(map, j, locals, fast, 0); - if (f->f_ncells || f->f_nfreevars) { - if (!(PyTuple_Check(f->f_code->co_cellvars) - && PyTuple_Check(f->f_code->co_freevars))) { - return; - } - map_to_dict(f->f_code->co_cellvars, - PyTuple_GET_SIZE(f->f_code->co_cellvars), - locals, fast + f->f_nlocals, 1); - map_to_dict(f->f_code->co_freevars, - PyTuple_GET_SIZE(f->f_code->co_freevars), - locals, fast + f->f_nlocals + f->f_ncells, 1); - } - PyErr_Restore(error_type, error_value, error_traceback); -} - -void -PyFrame_LocalsToFast(PyFrameObject *f, int clear) -{ - /* Merge f->f_locals into fast locals */ - PyObject *locals, *map; - PyObject **fast; - PyObject *error_type, *error_value, *error_traceback; - int j; - if (f == NULL) - return; - locals = f->f_locals; - map = f->f_code->co_varnames; - if (locals == NULL) - return; - if (!PyDict_Check(locals) || !PyTuple_Check(map)) - return; - PyErr_Fetch(&error_type, &error_value, &error_traceback); - fast = f->f_localsplus; - j = PyTuple_Size(map); - if (j > f->f_nlocals) - j = f->f_nlocals; - if (f->f_nlocals) - dict_to_map(f->f_code->co_varnames, j, locals, fast, 0, clear); - if (f->f_ncells || f->f_nfreevars) { - if (!(PyTuple_Check(f->f_code->co_cellvars) - && PyTuple_Check(f->f_code->co_freevars))) - return; - dict_to_map(f->f_code->co_cellvars, - PyTuple_GET_SIZE(f->f_code->co_cellvars), - locals, fast + f->f_nlocals, 1, clear); - dict_to_map(f->f_code->co_freevars, - PyTuple_GET_SIZE(f->f_code->co_freevars), - locals, fast + f->f_nlocals + f->f_ncells, 1, - clear); - } - PyErr_Restore(error_type, error_value, error_traceback); -} - -/* Clear out the free list */ - -void -PyFrame_Fini(void) -{ - while (free_list != NULL) { - PyFrameObject *f = free_list; - free_list = free_list->f_back; - PyObject_GC_Del(f); - --numfree; - } - assert(numfree == 0); - Py_XDECREF(builtin_object); - builtin_object = NULL; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/funcobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/funcobject.c deleted file mode 100644 index f4afbcb2..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/funcobject.c +++ /dev/null @@ -1,875 +0,0 @@ - -/* Function object implementation */ - -#include "Python.h" -#include "compile.h" -#include "eval.h" -#include "structmember.h" - -PyObject * -PyFunction_New(PyObject *code, PyObject *globals) -{ - PyFunctionObject *op = PyObject_GC_New(PyFunctionObject, - &PyFunction_Type); - if (op != NULL) { - PyObject *doc; - PyObject *consts; - PyObject *module; - op->func_weakreflist = NULL; - Py_INCREF(code); - op->func_code = code; - Py_INCREF(globals); - op->func_globals = globals; - op->func_name = ((PyCodeObject *)code)->co_name; - Py_INCREF(op->func_name); - op->func_defaults = NULL; /* No default arguments */ - op->func_closure = NULL; - consts = ((PyCodeObject *)code)->co_consts; - if (PyTuple_Size(consts) >= 1) { - doc = PyTuple_GetItem(consts, 0); - if (!PyString_Check(doc) && !PyUnicode_Check(doc)) - doc = Py_None; - } - else - doc = Py_None; - Py_INCREF(doc); - op->func_doc = doc; - op->func_dict = NULL; - op->func_module = NULL; - - /* __module__: If module name is in globals, use it. - Otherwise, use None. - */ - module = PyDict_GetItemString(globals, "__name__"); - if (module) { - Py_INCREF(module); - op->func_module = module; - } - } - else - return NULL; - _PyObject_GC_TRACK(op); - return (PyObject *)op; -} - -PyObject * -PyFunction_GetCode(PyObject *op) -{ - if (!PyFunction_Check(op)) { - PyErr_BadInternalCall(); - return NULL; - } - return ((PyFunctionObject *) op) -> func_code; -} - -PyObject * -PyFunction_GetGlobals(PyObject *op) -{ - if (!PyFunction_Check(op)) { - PyErr_BadInternalCall(); - return NULL; - } - return ((PyFunctionObject *) op) -> func_globals; -} - -PyObject * -PyFunction_GetModule(PyObject *op) -{ - if (!PyFunction_Check(op)) { - PyErr_BadInternalCall(); - return NULL; - } - return ((PyFunctionObject *) op) -> func_module; -} - -PyObject * -PyFunction_GetDefaults(PyObject *op) -{ - if (!PyFunction_Check(op)) { - PyErr_BadInternalCall(); - return NULL; - } - return ((PyFunctionObject *) op) -> func_defaults; -} - -int -PyFunction_SetDefaults(PyObject *op, PyObject *defaults) -{ - if (!PyFunction_Check(op)) { - PyErr_BadInternalCall(); - return -1; - } - if (defaults == Py_None) - defaults = NULL; - else if (PyTuple_Check(defaults)) { - Py_XINCREF(defaults); - } - else { - PyErr_SetString(PyExc_SystemError, "non-tuple default args"); - return -1; - } - Py_XDECREF(((PyFunctionObject *) op) -> func_defaults); - ((PyFunctionObject *) op) -> func_defaults = defaults; - return 0; -} - -PyObject * -PyFunction_GetClosure(PyObject *op) -{ - if (!PyFunction_Check(op)) { - PyErr_BadInternalCall(); - return NULL; - } - return ((PyFunctionObject *) op) -> func_closure; -} - -int -PyFunction_SetClosure(PyObject *op, PyObject *closure) -{ - if (!PyFunction_Check(op)) { - PyErr_BadInternalCall(); - return -1; - } - if (closure == Py_None) - closure = NULL; - else if (PyTuple_Check(closure)) { - Py_XINCREF(closure); - } - else { - PyErr_SetString(PyExc_SystemError, "non-tuple closure"); - return -1; - } - Py_XDECREF(((PyFunctionObject *) op) -> func_closure); - ((PyFunctionObject *) op) -> func_closure = closure; - return 0; -} - -/* Methods */ - -#define OFF(x) offsetof(PyFunctionObject, x) - -#define RR () - -static PyMemberDef func_memberlist[] = { - {"func_closure", T_OBJECT, OFF(func_closure), - RESTRICTED|READONLY}, - {"func_doc", T_OBJECT, OFF(func_doc), WRITE_RESTRICTED}, - {"__doc__", T_OBJECT, OFF(func_doc), WRITE_RESTRICTED}, - {"func_globals", T_OBJECT, OFF(func_globals), - RESTRICTED|READONLY}, - {"func_name", T_OBJECT, OFF(func_name), READONLY}, - {"__name__", T_OBJECT, OFF(func_name), READONLY}, - {"__module__", T_OBJECT, OFF(func_module), WRITE_RESTRICTED}, - {NULL} /* Sentinel */ -}; - -static int -restricted(void) -{ - if (!PyEval_GetRestricted()) - return 0; - PyErr_SetString(PyExc_RuntimeError, - "function attributes not accessible in restricted mode"); - return 1; -} - -static PyObject * -func_get_dict(PyFunctionObject *op) -{ - if (restricted()) - return NULL; - if (op->func_dict == NULL) { - op->func_dict = PyDict_New(); - if (op->func_dict == NULL) - return NULL; - } - Py_INCREF(op->func_dict); - return op->func_dict; -} - -static int -func_set_dict(PyFunctionObject *op, PyObject *value) -{ - PyObject *tmp; - - if (restricted()) - return -1; - /* It is illegal to del f.func_dict */ - if (value == NULL) { - PyErr_SetString(PyExc_TypeError, - "function's dictionary may not be deleted"); - return -1; - } - /* Can only set func_dict to a dictionary */ - if (!PyDict_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "setting function's dictionary to a non-dict"); - return -1; - } - tmp = op->func_dict; - Py_INCREF(value); - op->func_dict = value; - Py_XDECREF(tmp); - return 0; -} - -static PyObject * -func_get_code(PyFunctionObject *op) -{ - if (restricted()) - return NULL; - Py_INCREF(op->func_code); - return op->func_code; -} - -static int -func_set_code(PyFunctionObject *op, PyObject *value) -{ - PyObject *tmp; - - if (restricted()) - return -1; - /* Not legal to del f.func_code or to set it to anything - * other than a code object. */ - if (value == NULL || !PyCode_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "func_code must be set to a code object"); - return -1; - } - tmp = op->func_code; - Py_INCREF(value); - op->func_code = value; - Py_DECREF(tmp); - return 0; -} - -static PyObject * -func_get_defaults(PyFunctionObject *op) -{ - if (restricted()) - return NULL; - if (op->func_defaults == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - Py_INCREF(op->func_defaults); - return op->func_defaults; -} - -static int -func_set_defaults(PyFunctionObject *op, PyObject *value) -{ - PyObject *tmp; - - if (restricted()) - return -1; - /* Legal to del f.func_defaults. - * Can only set func_defaults to NULL or a tuple. */ - if (value == Py_None) - value = NULL; - if (value != NULL && !PyTuple_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "func_defaults must be set to a tuple object"); - return -1; - } - tmp = op->func_defaults; - Py_XINCREF(value); - op->func_defaults = value; - Py_XDECREF(tmp); - return 0; -} - -static PyGetSetDef func_getsetlist[] = { - {"func_code", (getter)func_get_code, (setter)func_set_code}, - {"func_defaults", (getter)func_get_defaults, - (setter)func_set_defaults}, - {"func_dict", (getter)func_get_dict, (setter)func_set_dict}, - {"__dict__", (getter)func_get_dict, (setter)func_set_dict}, - {NULL} /* Sentinel */ -}; - -PyDoc_STRVAR(func_doc, -"function(code, globals[, name[, argdefs[, closure]]])\n\ -\n\ -Create a function object from a code object and a dictionary.\n\ -The optional name string overrides the name from the code object.\n\ -The optional argdefs tuple specifies the default argument values.\n\ -The optional closure tuple supplies the bindings for free variables."); - -/* func_new() maintains the following invariants for closures. The - closure must correspond to the free variables of the code object. - - if len(code.co_freevars) == 0: - closure = NULL - else: - len(closure) == len(code.co_freevars) - for every elt in closure, type(elt) == cell -*/ - -static PyObject * -func_new(PyTypeObject* type, PyObject* args, PyObject* kw) -{ - PyCodeObject *code; - PyObject *globals; - PyObject *name = Py_None; - PyObject *defaults = Py_None; - PyObject *closure = Py_None; - PyFunctionObject *newfunc; - int nfree, nclosure; - static char *kwlist[] = {"code", "globals", "name", - "argdefs", "closure", 0}; - - if (!PyArg_ParseTupleAndKeywords(args, kw, "O!O!|OOO:function", - kwlist, - &PyCode_Type, &code, - &PyDict_Type, &globals, - &name, &defaults, &closure)) - return NULL; - if (name != Py_None && !PyString_Check(name)) { - PyErr_SetString(PyExc_TypeError, - "arg 3 (name) must be None or string"); - return NULL; - } - if (defaults != Py_None && !PyTuple_Check(defaults)) { - PyErr_SetString(PyExc_TypeError, - "arg 4 (defaults) must be None or tuple"); - return NULL; - } - nfree = PyTuple_GET_SIZE(code->co_freevars); - if (!PyTuple_Check(closure)) { - if (nfree && closure == Py_None) { - PyErr_SetString(PyExc_TypeError, - "arg 5 (closure) must be tuple"); - return NULL; - } - else if (closure != Py_None) { - PyErr_SetString(PyExc_TypeError, - "arg 5 (closure) must be None or tuple"); - return NULL; - } - } - - /* check that the closure is well-formed */ - nclosure = closure == Py_None ? 0 : PyTuple_GET_SIZE(closure); - if (nfree != nclosure) - return PyErr_Format(PyExc_ValueError, - "%s requires closure of length %d, not %d", - PyString_AS_STRING(code->co_name), - nfree, nclosure); - if (nclosure) { - int i; - for (i = 0; i < nclosure; i++) { - PyObject *o = PyTuple_GET_ITEM(closure, i); - if (!PyCell_Check(o)) { - return PyErr_Format(PyExc_TypeError, - "arg 5 (closure) expected cell, found %s", - o->ob_type->tp_name); - } - } - } - - newfunc = (PyFunctionObject *)PyFunction_New((PyObject *)code, - globals); - if (newfunc == NULL) - return NULL; - - if (name != Py_None) { - Py_INCREF(name); - Py_DECREF(newfunc->func_name); - newfunc->func_name = name; - } - if (defaults != Py_None) { - Py_INCREF(defaults); - newfunc->func_defaults = defaults; - } - if (closure != Py_None) { - Py_INCREF(closure); - newfunc->func_closure = closure; - } - - return (PyObject *)newfunc; -} - -static void -func_dealloc(PyFunctionObject *op) -{ - _PyObject_GC_UNTRACK(op); - if (op->func_weakreflist != NULL) - PyObject_ClearWeakRefs((PyObject *) op); - Py_DECREF(op->func_code); - Py_DECREF(op->func_globals); - Py_XDECREF(op->func_module); - Py_DECREF(op->func_name); - Py_XDECREF(op->func_defaults); - Py_XDECREF(op->func_doc); - Py_XDECREF(op->func_dict); - Py_XDECREF(op->func_closure); - PyObject_GC_Del(op); -} - -static PyObject* -func_repr(PyFunctionObject *op) -{ - if (op->func_name == Py_None) - return PyString_FromFormat("", op); - return PyString_FromFormat("", - PyString_AsString(op->func_name), - op); -} - -static int -func_traverse(PyFunctionObject *f, visitproc visit, void *arg) -{ - int err; - if (f->func_code) { - err = visit(f->func_code, arg); - if (err) - return err; - } - if (f->func_globals) { - err = visit(f->func_globals, arg); - if (err) - return err; - } - if (f->func_module) { - err = visit(f->func_module, arg); - if (err) - return err; - } - if (f->func_defaults) { - err = visit(f->func_defaults, arg); - if (err) - return err; - } - if (f->func_doc) { - err = visit(f->func_doc, arg); - if (err) - return err; - } - if (f->func_name) { - err = visit(f->func_name, arg); - if (err) - return err; - } - if (f->func_dict) { - err = visit(f->func_dict, arg); - if (err) - return err; - } - if (f->func_closure) { - err = visit(f->func_closure, arg); - if (err) - return err; - } - return 0; -} - -static PyObject * -function_call(PyObject *func, PyObject *arg, PyObject *kw) -{ - PyObject *result; - PyObject *argdefs; - PyObject **d, **k; - int nk, nd; - - argdefs = PyFunction_GET_DEFAULTS(func); - if (argdefs != NULL && PyTuple_Check(argdefs)) { - d = &PyTuple_GET_ITEM((PyTupleObject *)argdefs, 0); - nd = PyTuple_Size(argdefs); - } - else { - d = NULL; - nd = 0; - } - - if (kw != NULL && PyDict_Check(kw)) { - int pos, i; - nk = PyDict_Size(kw); - k = PyMem_NEW(PyObject *, 2*nk); - if (k == NULL) { - PyErr_NoMemory(); - return NULL; - } - pos = i = 0; - while (PyDict_Next(kw, &pos, &k[i], &k[i+1])) - i += 2; - nk = i/2; - /* XXX This is broken if the caller deletes dict items! */ - } - else { - k = NULL; - nk = 0; - } - - result = PyEval_EvalCodeEx( - (PyCodeObject *)PyFunction_GET_CODE(func), - PyFunction_GET_GLOBALS(func), (PyObject *)NULL, - &PyTuple_GET_ITEM(arg, 0), PyTuple_Size(arg), - k, nk, d, nd, - PyFunction_GET_CLOSURE(func)); - - if (k != NULL) - PyMem_DEL(k); - - return result; -} - -/* Bind a function to an object */ -static PyObject * -func_descr_get(PyObject *func, PyObject *obj, PyObject *type) -{ - if (obj == Py_None) - obj = NULL; - return PyMethod_New(func, obj, type); -} - -PyTypeObject PyFunction_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "function", - sizeof(PyFunctionObject), - 0, - (destructor)func_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)func_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - function_call, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - PyObject_GenericSetAttr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - func_doc, /* tp_doc */ - (traverseproc)func_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - offsetof(PyFunctionObject, func_weakreflist), /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - func_memberlist, /* tp_members */ - func_getsetlist, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - func_descr_get, /* tp_descr_get */ - 0, /* tp_descr_set */ - offsetof(PyFunctionObject, func_dict), /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - func_new, /* tp_new */ -}; - - -/* Class method object */ - -/* A class method receives the class as implicit first argument, - just like an instance method receives the instance. - To declare a class method, use this idiom: - - class C: - def f(cls, arg1, arg2, ...): ... - f = classmethod(f) - - It can be called either on the class (e.g. C.f()) or on an instance - (e.g. C().f()); the instance is ignored except for its class. - If a class method is called for a derived class, the derived class - object is passed as the implied first argument. - - Class methods are different than C++ or Java static methods. - If you want those, see static methods below. -*/ - -typedef struct { - PyObject_HEAD - PyObject *cm_callable; -} classmethod; - -static void -cm_dealloc(classmethod *cm) -{ - _PyObject_GC_UNTRACK((PyObject *)cm); - Py_XDECREF(cm->cm_callable); - cm->ob_type->tp_free((PyObject *)cm); -} - -static int -cm_traverse(classmethod *cm, visitproc visit, void *arg) -{ - if (!cm->cm_callable) - return 0; - return visit(cm->cm_callable, arg); -} - -static int -cm_clear(classmethod *cm) -{ - Py_XDECREF(cm->cm_callable); - cm->cm_callable = NULL; - - return 0; -} - - -static PyObject * -cm_descr_get(PyObject *self, PyObject *obj, PyObject *type) -{ - classmethod *cm = (classmethod *)self; - - if (cm->cm_callable == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "uninitialized classmethod object"); - return NULL; - } - if (type == NULL) - type = (PyObject *)(obj->ob_type); - return PyMethod_New(cm->cm_callable, - type, (PyObject *)(type->ob_type)); -} - -static int -cm_init(PyObject *self, PyObject *args, PyObject *kwds) -{ - classmethod *cm = (classmethod *)self; - PyObject *callable; - - if (!PyArg_UnpackTuple(args, "classmethod", 1, 1, &callable)) - return -1; - if (!PyCallable_Check(callable)) { - PyErr_Format(PyExc_TypeError, "'%s' object is not callable", - callable->ob_type->tp_name); - return -1; - } - - Py_INCREF(callable); - cm->cm_callable = callable; - return 0; -} - -PyDoc_STRVAR(classmethod_doc, -"classmethod(function) -> method\n\ -\n\ -Convert a function to be a class method.\n\ -\n\ -A class method receives the class as implicit first argument,\n\ -just like an instance method receives the instance.\n\ -To declare a class method, use this idiom:\n\ -\n\ - class C:\n\ - def f(cls, arg1, arg2, ...): ...\n\ - f = classmethod(f)\n\ -\n\ -It can be called either on the class (e.g. C.f()) or on an instance\n\ -(e.g. C().f()). The instance is ignored except for its class.\n\ -If a class method is called for a derived class, the derived class\n\ -object is passed as the implied first argument.\n\ -\n\ -Class methods are different than C++ or Java static methods.\n\ -If you want those, see the staticmethod builtin."); - -PyTypeObject PyClassMethod_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "classmethod", - sizeof(classmethod), - 0, - (destructor)cm_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, - classmethod_doc, /* tp_doc */ - (traverseproc)cm_traverse, /* tp_traverse */ - (inquiry)cm_clear, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - cm_descr_get, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - cm_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - -PyObject * -PyClassMethod_New(PyObject *callable) -{ - classmethod *cm = (classmethod *) - PyType_GenericAlloc(&PyClassMethod_Type, 0); - if (cm != NULL) { - Py_INCREF(callable); - cm->cm_callable = callable; - } - return (PyObject *)cm; -} - - -/* Static method object */ - -/* A static method does not receive an implicit first argument. - To declare a static method, use this idiom: - - class C: - def f(arg1, arg2, ...): ... - f = staticmethod(f) - - It can be called either on the class (e.g. C.f()) or on an instance - (e.g. C().f()); the instance is ignored except for its class. - - Static methods in Python are similar to those found in Java or C++. - For a more advanced concept, see class methods above. -*/ - -typedef struct { - PyObject_HEAD - PyObject *sm_callable; -} staticmethod; - -static void -sm_dealloc(staticmethod *sm) -{ - _PyObject_GC_UNTRACK((PyObject *)sm); - Py_XDECREF(sm->sm_callable); - sm->ob_type->tp_free((PyObject *)sm); -} - -static int -sm_traverse(staticmethod *sm, visitproc visit, void *arg) -{ - if (!sm->sm_callable) - return 0; - return visit(sm->sm_callable, arg); -} - -static int -sm_clear(staticmethod *sm) -{ - Py_XDECREF(sm->sm_callable); - sm->sm_callable = NULL; - - return 0; -} - -static PyObject * -sm_descr_get(PyObject *self, PyObject *obj, PyObject *type) -{ - staticmethod *sm = (staticmethod *)self; - - if (sm->sm_callable == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "uninitialized staticmethod object"); - return NULL; - } - Py_INCREF(sm->sm_callable); - return sm->sm_callable; -} - -static int -sm_init(PyObject *self, PyObject *args, PyObject *kwds) -{ - staticmethod *sm = (staticmethod *)self; - PyObject *callable; - - if (!PyArg_UnpackTuple(args, "staticmethod", 1, 1, &callable)) - return -1; - Py_INCREF(callable); - sm->sm_callable = callable; - return 0; -} - -PyDoc_STRVAR(staticmethod_doc, -"staticmethod(function) -> method\n\ -\n\ -Convert a function to be a static method.\n\ -\n\ -A static method does not receive an implicit first argument.\n\ -To declare a static method, use this idiom:\n\ -\n\ - class C:\n\ - def f(arg1, arg2, ...): ...\n\ - f = staticmethod(f)\n\ -\n\ -It can be called either on the class (e.g. C.f()) or on an instance\n\ -(e.g. C().f()). The instance is ignored except for its class.\n\ -\n\ -Static methods in Python are similar to those found in Java or C++.\n\ -For a more advanced concept, see the classmethod builtin."); - -PyTypeObject PyStaticMethod_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "staticmethod", - sizeof(staticmethod), - 0, - (destructor)sm_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, - staticmethod_doc, /* tp_doc */ - (traverseproc)sm_traverse, /* tp_traverse */ - (inquiry)sm_clear, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - sm_descr_get, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - sm_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - -PyObject * -PyStaticMethod_New(PyObject *callable) -{ - staticmethod *sm = (staticmethod *) - PyType_GenericAlloc(&PyStaticMethod_Type, 0); - if (sm != NULL) { - Py_INCREF(callable); - sm->sm_callable = callable; - } - return (PyObject *)sm; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/intobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/intobject.c deleted file mode 100644 index 3d0957fe..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/intobject.c +++ /dev/null @@ -1,1188 +0,0 @@ - -/* Integer object implementation */ - -#include "Python.h" -#include - -long -PyInt_GetMax(void) -{ - return LONG_MAX; /* To initialize sys.maxint */ -} - -/* Return 1 if exception raised, 0 if caller should retry using longs */ -static int -err_ovf(char *msg) -{ - if (PyErr_Warn(PyExc_OverflowWarning, msg) < 0) { - if (PyErr_ExceptionMatches(PyExc_OverflowWarning)) - PyErr_SetString(PyExc_OverflowError, msg); - return 1; - } - else - return 0; -} - -/* Integers are quite normal objects, to make object handling uniform. - (Using odd pointers to represent integers would save much space - but require extra checks for this special case throughout the code.) - Since a typical Python program spends much of its time allocating - and deallocating integers, these operations should be very fast. - Therefore we use a dedicated allocation scheme with a much lower - overhead (in space and time) than straight malloc(): a simple - dedicated free list, filled when necessary with memory from malloc(). - - block_list is a singly-linked list of all PyIntBlocks ever allocated, - linked via their next members. PyIntBlocks are never returned to the - system before shutdown (PyInt_Fini). - - free_list is a singly-linked list of available PyIntObjects, linked - via abuse of their ob_type members. -*/ - -#define BLOCK_SIZE 1000 /* 1K less typical malloc overhead */ -#define BHEAD_SIZE 8 /* Enough for a 64-bit pointer */ -#define N_INTOBJECTS ((BLOCK_SIZE - BHEAD_SIZE) / sizeof(PyIntObject)) - -struct _intblock { - struct _intblock *next; - PyIntObject objects[N_INTOBJECTS]; -}; - -typedef struct _intblock PyIntBlock; - -static PyIntBlock *block_list = NULL; -static PyIntObject *free_list = NULL; - -static PyIntObject * -fill_free_list(void) -{ - PyIntObject *p, *q; - /* Python's object allocator isn't appropriate for large blocks. */ - p = (PyIntObject *) PyMem_MALLOC(sizeof(PyIntBlock)); - if (p == NULL) - return (PyIntObject *) PyErr_NoMemory(); - ((PyIntBlock *)p)->next = block_list; - block_list = (PyIntBlock *)p; - /* Link the int objects together, from rear to front, then return - the address of the last int object in the block. */ - p = &((PyIntBlock *)p)->objects[0]; - q = p + N_INTOBJECTS; - while (--q > p) - q->ob_type = (struct _typeobject *)(q-1); - q->ob_type = NULL; - return p + N_INTOBJECTS - 1; -} - -#ifndef NSMALLPOSINTS -#define NSMALLPOSINTS 100 -#endif -#ifndef NSMALLNEGINTS -#define NSMALLNEGINTS 5 -#endif -#if NSMALLNEGINTS + NSMALLPOSINTS > 0 -/* References to small integers are saved in this array so that they - can be shared. - The integers that are saved are those in the range - -NSMALLNEGINTS (inclusive) to NSMALLPOSINTS (not inclusive). -*/ -static PyIntObject *small_ints[NSMALLNEGINTS + NSMALLPOSINTS]; -#endif -#ifdef COUNT_ALLOCS -int quick_int_allocs, quick_neg_int_allocs; -#endif - -PyObject * -PyInt_FromLong(long ival) -{ - register PyIntObject *v; -#if NSMALLNEGINTS + NSMALLPOSINTS > 0 - if (-NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS) { - v = small_ints[ival + NSMALLNEGINTS]; - Py_INCREF(v); -#ifdef COUNT_ALLOCS - if (ival >= 0) - quick_int_allocs++; - else - quick_neg_int_allocs++; -#endif - return (PyObject *) v; - } -#endif - if (free_list == NULL) { - if ((free_list = fill_free_list()) == NULL) - return NULL; - } - /* Inline PyObject_New */ - v = free_list; - free_list = (PyIntObject *)v->ob_type; - PyObject_INIT(v, &PyInt_Type); - v->ob_ival = ival; - return (PyObject *) v; -} - -static void -int_dealloc(PyIntObject *v) -{ - if (PyInt_CheckExact(v)) { - v->ob_type = (struct _typeobject *)free_list; - free_list = v; - } - else - v->ob_type->tp_free((PyObject *)v); -} - -static void -int_free(PyIntObject *v) -{ - v->ob_type = (struct _typeobject *)free_list; - free_list = v; -} - -long -PyInt_AsLong(register PyObject *op) -{ - PyNumberMethods *nb; - PyIntObject *io; - long val; - - if (op && PyInt_Check(op)) - return PyInt_AS_LONG((PyIntObject*) op); - - if (op == NULL || (nb = op->ob_type->tp_as_number) == NULL || - nb->nb_int == NULL) { - PyErr_SetString(PyExc_TypeError, "an integer is required"); - return -1; - } - - io = (PyIntObject*) (*nb->nb_int) (op); - if (io == NULL) - return -1; - if (!PyInt_Check(io)) { - if (PyLong_Check(io)) { - /* got a long? => retry int conversion */ - val = PyLong_AsLong((PyObject *)io); - Py_DECREF(io); - if ((val == -1) && PyErr_Occurred()) - return -1; - return val; - } - else - { - Py_DECREF(io); - PyErr_SetString(PyExc_TypeError, - "nb_int should return int object"); - return -1; - } - } - - val = PyInt_AS_LONG(io); - Py_DECREF(io); - - return val; -} - -unsigned long -PyInt_AsUnsignedLongMask(register PyObject *op) -{ - PyNumberMethods *nb; - PyIntObject *io; - unsigned long val; - - if (op && PyInt_Check(op)) - return PyInt_AS_LONG((PyIntObject*) op); - if (op && PyLong_Check(op)) - return PyLong_AsUnsignedLongMask(op); - - if (op == NULL || (nb = op->ob_type->tp_as_number) == NULL || - nb->nb_int == NULL) { - PyErr_SetString(PyExc_TypeError, "an integer is required"); - return -1; - } - - io = (PyIntObject*) (*nb->nb_int) (op); - if (io == NULL) - return -1; - if (!PyInt_Check(io)) { - if (PyLong_Check(io)) { - val = PyLong_AsUnsignedLongMask((PyObject *)io); - Py_DECREF(io); - if (PyErr_Occurred()) - return -1; - return val; - } - else - { - Py_DECREF(io); - PyErr_SetString(PyExc_TypeError, - "nb_int should return int object"); - return -1; - } - } - - val = PyInt_AS_LONG(io); - Py_DECREF(io); - - return val; -} - -#ifdef HAVE_LONG_LONG -unsigned PY_LONG_LONG -PyInt_AsUnsignedLongLongMask(register PyObject *op) -{ - PyNumberMethods *nb; - PyIntObject *io; - unsigned PY_LONG_LONG val; - - if (op && PyInt_Check(op)) - return PyInt_AS_LONG((PyIntObject*) op); - if (op && PyLong_Check(op)) - return PyLong_AsUnsignedLongLongMask(op); - - if (op == NULL || (nb = op->ob_type->tp_as_number) == NULL || - nb->nb_int == NULL) { - PyErr_SetString(PyExc_TypeError, "an integer is required"); - return -1; - } - - io = (PyIntObject*) (*nb->nb_int) (op); - if (io == NULL) - return -1; - if (!PyInt_Check(io)) { - if (PyLong_Check(io)) { - val = PyLong_AsUnsignedLongLongMask((PyObject *)io); - Py_DECREF(io); - if (PyErr_Occurred()) - return -1; - return val; - } - else - { - Py_DECREF(io); - PyErr_SetString(PyExc_TypeError, - "nb_int should return int object"); - return -1; - } - } - - val = PyInt_AS_LONG(io); - Py_DECREF(io); - - return val; -} -#endif - -PyObject * -PyInt_FromString(char *s, char **pend, int base) -{ - char *end; - long x; - char buffer[256]; /* For errors */ - int warn = 0; - - if ((base != 0 && base < 2) || base > 36) { - PyErr_SetString(PyExc_ValueError, - "int() base must be >= 2 and <= 36"); - return NULL; - } - - while (*s && isspace(Py_CHARMASK(*s))) - s++; - errno = 0; - if (base == 0 && s[0] == '0') { - x = (long) PyOS_strtoul(s, &end, base); - if (x < 0) - warn = 1; - } - else - x = PyOS_strtol(s, &end, base); - if (end == s || !isalnum(Py_CHARMASK(end[-1]))) - goto bad; - while (*end && isspace(Py_CHARMASK(*end))) - end++; - if (*end != '\0') { - bad: - PyOS_snprintf(buffer, sizeof(buffer), - "invalid literal for int(): %.200s", s); - PyErr_SetString(PyExc_ValueError, buffer); - return NULL; - } - else if (errno != 0) { - if (err_ovf("string/unicode conversion")) - return NULL; - return PyLong_FromString(s, pend, base); - } - if (warn) { - if (PyErr_Warn(PyExc_FutureWarning, - "int('0...', 0): sign will change in Python 2.4") < 0) - return NULL; - } - if (pend) - *pend = end; - return PyInt_FromLong(x); -} - -#ifdef Py_USING_UNICODE -PyObject * -PyInt_FromUnicode(Py_UNICODE *s, int length, int base) -{ - PyObject *result; - char *buffer = PyMem_MALLOC(length+1); - - if (buffer == NULL) - return NULL; - - if (PyUnicode_EncodeDecimal(s, length, buffer, NULL)) { - PyMem_FREE(buffer); - return NULL; - } - result = PyInt_FromString(buffer, NULL, base); - PyMem_FREE(buffer); - return result; -} -#endif - -/* Methods */ - -/* Integers are seen as the "smallest" of all numeric types and thus - don't have any knowledge about conversion of other types to - integers. */ - -#define CONVERT_TO_LONG(obj, lng) \ - if (PyInt_Check(obj)) { \ - lng = PyInt_AS_LONG(obj); \ - } \ - else { \ - Py_INCREF(Py_NotImplemented); \ - return Py_NotImplemented; \ - } - -/* ARGSUSED */ -static int -int_print(PyIntObject *v, FILE *fp, int flags) - /* flags -- not used but required by interface */ -{ - fprintf(fp, "%ld", v->ob_ival); - return 0; -} - -static PyObject * -int_repr(PyIntObject *v) -{ - char buf[64]; - PyOS_snprintf(buf, sizeof(buf), "%ld", v->ob_ival); - return PyString_FromString(buf); -} - -static int -int_compare(PyIntObject *v, PyIntObject *w) -{ - register long i = v->ob_ival; - register long j = w->ob_ival; - return (i < j) ? -1 : (i > j) ? 1 : 0; -} - -static long -int_hash(PyIntObject *v) -{ - /* XXX If this is changed, you also need to change the way - Python's long, float and complex types are hashed. */ - long x = v -> ob_ival; - if (x == -1) - x = -2; - return x; -} - -static PyObject * -int_add(PyIntObject *v, PyIntObject *w) -{ - register long a, b, x; - CONVERT_TO_LONG(v, a); - CONVERT_TO_LONG(w, b); - x = a + b; - if ((x^a) >= 0 || (x^b) >= 0) - return PyInt_FromLong(x); - if (err_ovf("integer addition")) - return NULL; - return PyLong_Type.tp_as_number->nb_add((PyObject *)v, (PyObject *)w); -} - -static PyObject * -int_sub(PyIntObject *v, PyIntObject *w) -{ - register long a, b, x; - CONVERT_TO_LONG(v, a); - CONVERT_TO_LONG(w, b); - x = a - b; - if ((x^a) >= 0 || (x^~b) >= 0) - return PyInt_FromLong(x); - if (err_ovf("integer subtraction")) - return NULL; - return PyLong_Type.tp_as_number->nb_subtract((PyObject *)v, - (PyObject *)w); -} - -/* -Integer overflow checking for * is painful: Python tried a couple ways, but -they didn't work on all platforms, or failed in endcases (a product of --sys.maxint-1 has been a particular pain). - -Here's another way: - -The native long product x*y is either exactly right or *way* off, being -just the last n bits of the true product, where n is the number of bits -in a long (the delivered product is the true product plus i*2**n for -some integer i). - -The native double product (double)x * (double)y is subject to three -rounding errors: on a sizeof(long)==8 box, each cast to double can lose -info, and even on a sizeof(long)==4 box, the multiplication can lose info. -But, unlike the native long product, it's not in *range* trouble: even -if sizeof(long)==32 (256-bit longs), the product easily fits in the -dynamic range of a double. So the leading 50 (or so) bits of the double -product are correct. - -We check these two ways against each other, and declare victory if they're -approximately the same. Else, because the native long product is the only -one that can lose catastrophic amounts of information, it's the native long -product that must have overflowed. -*/ - -static PyObject * -int_mul(PyObject *v, PyObject *w) -{ - long a, b; - long longprod; /* a*b in native long arithmetic */ - double doubled_longprod; /* (double)longprod */ - double doubleprod; /* (double)a * (double)b */ - - CONVERT_TO_LONG(v, a); - CONVERT_TO_LONG(w, b); - longprod = a * b; - doubleprod = (double)a * (double)b; - doubled_longprod = (double)longprod; - - /* Fast path for normal case: small multiplicands, and no info - is lost in either method. */ - if (doubled_longprod == doubleprod) - return PyInt_FromLong(longprod); - - /* Somebody somewhere lost info. Close enough, or way off? Note - that a != 0 and b != 0 (else doubled_longprod == doubleprod == 0). - The difference either is or isn't significant compared to the - true value (of which doubleprod is a good approximation). - */ - { - const double diff = doubled_longprod - doubleprod; - const double absdiff = diff >= 0.0 ? diff : -diff; - const double absprod = doubleprod >= 0.0 ? doubleprod : - -doubleprod; - /* absdiff/absprod <= 1/32 iff - 32 * absdiff <= absprod -- 5 good bits is "close enough" */ - if (32.0 * absdiff <= absprod) - return PyInt_FromLong(longprod); - else if (err_ovf("integer multiplication")) - return NULL; - else - return PyLong_Type.tp_as_number->nb_multiply(v, w); - } -} - -/* Return type of i_divmod */ -enum divmod_result { - DIVMOD_OK, /* Correct result */ - DIVMOD_OVERFLOW, /* Overflow, try again using longs */ - DIVMOD_ERROR /* Exception raised */ -}; - -static enum divmod_result -i_divmod(register long x, register long y, - long *p_xdivy, long *p_xmody) -{ - long xdivy, xmody; - - if (y == 0) { - PyErr_SetString(PyExc_ZeroDivisionError, - "integer division or modulo by zero"); - return DIVMOD_ERROR; - } - /* (-sys.maxint-1)/-1 is the only overflow case. */ - if (y == -1 && x < 0 && x == -x) { - if (err_ovf("integer division")) - return DIVMOD_ERROR; - return DIVMOD_OVERFLOW; - } - xdivy = x / y; - xmody = x - xdivy * y; - /* If the signs of x and y differ, and the remainder is non-0, - * C89 doesn't define whether xdivy is now the floor or the - * ceiling of the infinitely precise quotient. We want the floor, - * and we have it iff the remainder's sign matches y's. - */ - if (xmody && ((y ^ xmody) < 0) /* i.e. and signs differ */) { - xmody += y; - --xdivy; - assert(xmody && ((y ^ xmody) >= 0)); - } - *p_xdivy = xdivy; - *p_xmody = xmody; - return DIVMOD_OK; -} - -static PyObject * -int_div(PyIntObject *x, PyIntObject *y) -{ - long xi, yi; - long d, m; - CONVERT_TO_LONG(x, xi); - CONVERT_TO_LONG(y, yi); - switch (i_divmod(xi, yi, &d, &m)) { - case DIVMOD_OK: - return PyInt_FromLong(d); - case DIVMOD_OVERFLOW: - return PyLong_Type.tp_as_number->nb_divide((PyObject *)x, - (PyObject *)y); - default: - return NULL; - } -} - -static PyObject * -int_classic_div(PyIntObject *x, PyIntObject *y) -{ - long xi, yi; - long d, m; - CONVERT_TO_LONG(x, xi); - CONVERT_TO_LONG(y, yi); - if (Py_DivisionWarningFlag && - PyErr_Warn(PyExc_DeprecationWarning, "classic int division") < 0) - return NULL; - switch (i_divmod(xi, yi, &d, &m)) { - case DIVMOD_OK: - return PyInt_FromLong(d); - case DIVMOD_OVERFLOW: - return PyLong_Type.tp_as_number->nb_divide((PyObject *)x, - (PyObject *)y); - default: - return NULL; - } -} - -static PyObject * -int_true_divide(PyObject *v, PyObject *w) -{ - /* If they aren't both ints, give someone else a chance. In - particular, this lets int/long get handled by longs, which - underflows to 0 gracefully if the long is too big to convert - to float. */ - if (PyInt_Check(v) && PyInt_Check(w)) - return PyFloat_Type.tp_as_number->nb_true_divide(v, w); - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; -} - -static PyObject * -int_mod(PyIntObject *x, PyIntObject *y) -{ - long xi, yi; - long d, m; - CONVERT_TO_LONG(x, xi); - CONVERT_TO_LONG(y, yi); - switch (i_divmod(xi, yi, &d, &m)) { - case DIVMOD_OK: - return PyInt_FromLong(m); - case DIVMOD_OVERFLOW: - return PyLong_Type.tp_as_number->nb_remainder((PyObject *)x, - (PyObject *)y); - default: - return NULL; - } -} - -static PyObject * -int_divmod(PyIntObject *x, PyIntObject *y) -{ - long xi, yi; - long d, m; - CONVERT_TO_LONG(x, xi); - CONVERT_TO_LONG(y, yi); - switch (i_divmod(xi, yi, &d, &m)) { - case DIVMOD_OK: - return Py_BuildValue("(ll)", d, m); - case DIVMOD_OVERFLOW: - return PyLong_Type.tp_as_number->nb_divmod((PyObject *)x, - (PyObject *)y); - default: - return NULL; - } -} - -static PyObject * -int_pow(PyIntObject *v, PyIntObject *w, PyIntObject *z) -{ - register long iv, iw, iz=0, ix, temp, prev; - CONVERT_TO_LONG(v, iv); - CONVERT_TO_LONG(w, iw); - if (iw < 0) { - if ((PyObject *)z != Py_None) { - PyErr_SetString(PyExc_TypeError, "pow() 2nd argument " - "cannot be negative when 3rd argument specified"); - return NULL; - } - /* Return a float. This works because we know that - this calls float_pow() which converts its - arguments to double. */ - return PyFloat_Type.tp_as_number->nb_power( - (PyObject *)v, (PyObject *)w, (PyObject *)z); - } - if ((PyObject *)z != Py_None) { - CONVERT_TO_LONG(z, iz); - if (iz == 0) { - PyErr_SetString(PyExc_ValueError, - "pow() 3rd argument cannot be 0"); - return NULL; - } - } - /* - * XXX: The original exponentiation code stopped looping - * when temp hit zero; this code will continue onwards - * unnecessarily, but at least it won't cause any errors. - * Hopefully the speed improvement from the fast exponentiation - * will compensate for the slight inefficiency. - * XXX: Better handling of overflows is desperately needed. - */ - temp = iv; - ix = 1; - while (iw > 0) { - prev = ix; /* Save value for overflow check */ - if (iw & 1) { - ix = ix*temp; - if (temp == 0) - break; /* Avoid ix / 0 */ - if (ix / temp != prev) { - if (err_ovf("integer exponentiation")) - return NULL; - return PyLong_Type.tp_as_number->nb_power( - (PyObject *)v, - (PyObject *)w, - (PyObject *)z); - } - } - iw >>= 1; /* Shift exponent down by 1 bit */ - if (iw==0) break; - prev = temp; - temp *= temp; /* Square the value of temp */ - if (prev!=0 && temp/prev!=prev) { - if (err_ovf("integer exponentiation")) - return NULL; - return PyLong_Type.tp_as_number->nb_power( - (PyObject *)v, (PyObject *)w, (PyObject *)z); - } - if (iz) { - /* If we did a multiplication, perform a modulo */ - ix = ix % iz; - temp = temp % iz; - } - } - if (iz) { - long div, mod; - switch (i_divmod(ix, iz, &div, &mod)) { - case DIVMOD_OK: - ix = mod; - break; - case DIVMOD_OVERFLOW: - return PyLong_Type.tp_as_number->nb_power( - (PyObject *)v, (PyObject *)w, (PyObject *)z); - default: - return NULL; - } - } - return PyInt_FromLong(ix); -} - -static PyObject * -int_neg(PyIntObject *v) -{ - register long a, x; - a = v->ob_ival; - x = -a; - if (a < 0 && x < 0) { - PyObject *o; - if (err_ovf("integer negation")) - return NULL; - o = PyLong_FromLong(a); - if (o != NULL) { - PyObject *result = PyNumber_Negative(o); - Py_DECREF(o); - return result; - } - return NULL; - } - return PyInt_FromLong(x); -} - -static PyObject * -int_pos(PyIntObject *v) -{ - if (PyInt_CheckExact(v)) { - Py_INCREF(v); - return (PyObject *)v; - } - else - return PyInt_FromLong(v->ob_ival); -} - -static PyObject * -int_abs(PyIntObject *v) -{ - if (v->ob_ival >= 0) - return int_pos(v); - else - return int_neg(v); -} - -static int -int_nonzero(PyIntObject *v) -{ - return v->ob_ival != 0; -} - -static PyObject * -int_invert(PyIntObject *v) -{ - return PyInt_FromLong(~v->ob_ival); -} - -static PyObject * -int_lshift(PyIntObject *v, PyIntObject *w) -{ - long a, b, c; - CONVERT_TO_LONG(v, a); - CONVERT_TO_LONG(w, b); - if (b < 0) { - PyErr_SetString(PyExc_ValueError, "negative shift count"); - return NULL; - } - if (a == 0 || b == 0) - return int_pos(v); - if (b >= LONG_BIT) { - if (PyErr_Warn(PyExc_FutureWarning, - "x<= LONG_BIT) { - if (a < 0) - a = -1; - else - a = 0; - } - else { - a = Py_ARITHMETIC_RIGHT_SHIFT(long, a, b); - } - return PyInt_FromLong(a); -} - -static PyObject * -int_and(PyIntObject *v, PyIntObject *w) -{ - register long a, b; - CONVERT_TO_LONG(v, a); - CONVERT_TO_LONG(w, b); - return PyInt_FromLong(a & b); -} - -static PyObject * -int_xor(PyIntObject *v, PyIntObject *w) -{ - register long a, b; - CONVERT_TO_LONG(v, a); - CONVERT_TO_LONG(w, b); - return PyInt_FromLong(a ^ b); -} - -static PyObject * -int_or(PyIntObject *v, PyIntObject *w) -{ - register long a, b; - CONVERT_TO_LONG(v, a); - CONVERT_TO_LONG(w, b); - return PyInt_FromLong(a | b); -} - -static int -int_coerce(PyObject **pv, PyObject **pw) -{ - if (PyInt_Check(*pw)) { - Py_INCREF(*pv); - Py_INCREF(*pw); - return 0; - } - return 1; /* Can't do it */ -} - -static PyObject * -int_int(PyIntObject *v) -{ - Py_INCREF(v); - return (PyObject *)v; -} - -static PyObject * -int_long(PyIntObject *v) -{ - return PyLong_FromLong((v -> ob_ival)); -} - -static PyObject * -int_float(PyIntObject *v) -{ - return PyFloat_FromDouble((double)(v -> ob_ival)); -} - -static PyObject * -int_oct(PyIntObject *v) -{ - char buf[100]; - long x = v -> ob_ival; - if (x < 0) { - if (PyErr_Warn(PyExc_FutureWarning, - "hex()/oct() of negative int will return " - "a signed string in Python 2.4 and up") < 0) - return NULL; - } - if (x == 0) - strcpy(buf, "0"); - else - PyOS_snprintf(buf, sizeof(buf), "0%lo", x); - return PyString_FromString(buf); -} - -static PyObject * -int_hex(PyIntObject *v) -{ - char buf[100]; - long x = v -> ob_ival; - if (x < 0) { - if (PyErr_Warn(PyExc_FutureWarning, - "hex()/oct() of negative int will return " - "a signed string in Python 2.4 and up") < 0) - return NULL; - } - PyOS_snprintf(buf, sizeof(buf), "0x%lx", x); - return PyString_FromString(buf); -} - -static PyObject * -int_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); - -static PyObject * -int_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *x = NULL; - int base = -909; - static char *kwlist[] = {"x", "base", 0}; - - if (type != &PyInt_Type) - return int_subtype_new(type, args, kwds); /* Wimp out */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:int", kwlist, - &x, &base)) - return NULL; - if (x == NULL) - return PyInt_FromLong(0L); - if (base == -909) - return PyNumber_Int(x); - if (PyString_Check(x)) - return PyInt_FromString(PyString_AS_STRING(x), NULL, base); -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(x)) - return PyInt_FromUnicode(PyUnicode_AS_UNICODE(x), - PyUnicode_GET_SIZE(x), - base); -#endif - PyErr_SetString(PyExc_TypeError, - "int() can't convert non-string with explicit base"); - return NULL; -} - -/* Wimpy, slow approach to tp_new calls for subtypes of int: - first create a regular int from whatever arguments we got, - then allocate a subtype instance and initialize its ob_ival - from the regular int. The regular int is then thrown away. -*/ -static PyObject * -int_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *tmp, *new; - long ival; - - assert(PyType_IsSubtype(type, &PyInt_Type)); - tmp = int_new(&PyInt_Type, args, kwds); - if (tmp == NULL) - return NULL; - if (!PyInt_Check(tmp)) { - if (!PyLong_Check(tmp)) { - PyErr_SetString(PyExc_ValueError, - "value must convertable to an int"); - return NULL; - } - ival = PyLong_AsLong(tmp); - if (ival == -1 && PyErr_Occurred()) - return NULL; - - } else { - ival = ((PyIntObject *)tmp)->ob_ival; - } - - new = type->tp_alloc(type, 0); - if (new == NULL) { - Py_DECREF(tmp); - return NULL; - } - ((PyIntObject *)new)->ob_ival = ival; - Py_DECREF(tmp); - return new; -} - -static PyObject * -int_getnewargs(PyIntObject *v) -{ - return Py_BuildValue("(l)", v->ob_ival); -} - -static PyMethodDef int_methods[] = { - {"__getnewargs__", (PyCFunction)int_getnewargs, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - -PyDoc_STRVAR(int_doc, -"int(x[, base]) -> integer\n\ -\n\ -Convert a string or number to an integer, if possible. A floating point\n\ -argument will be truncated towards zero (this does not include a string\n\ -representation of a floating point number!) When converting a string, use\n\ -the optional base. It is an error to supply a base when converting a\n\ -non-string. If the argument is outside the integer range a long object\n\ -will be returned instead."); - -static PyNumberMethods int_as_number = { - (binaryfunc)int_add, /*nb_add*/ - (binaryfunc)int_sub, /*nb_subtract*/ - (binaryfunc)int_mul, /*nb_multiply*/ - (binaryfunc)int_classic_div, /*nb_divide*/ - (binaryfunc)int_mod, /*nb_remainder*/ - (binaryfunc)int_divmod, /*nb_divmod*/ - (ternaryfunc)int_pow, /*nb_power*/ - (unaryfunc)int_neg, /*nb_negative*/ - (unaryfunc)int_pos, /*nb_positive*/ - (unaryfunc)int_abs, /*nb_absolute*/ - (inquiry)int_nonzero, /*nb_nonzero*/ - (unaryfunc)int_invert, /*nb_invert*/ - (binaryfunc)int_lshift, /*nb_lshift*/ - (binaryfunc)int_rshift, /*nb_rshift*/ - (binaryfunc)int_and, /*nb_and*/ - (binaryfunc)int_xor, /*nb_xor*/ - (binaryfunc)int_or, /*nb_or*/ - int_coerce, /*nb_coerce*/ - (unaryfunc)int_int, /*nb_int*/ - (unaryfunc)int_long, /*nb_long*/ - (unaryfunc)int_float, /*nb_float*/ - (unaryfunc)int_oct, /*nb_oct*/ - (unaryfunc)int_hex, /*nb_hex*/ - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - 0, /*nb_inplace_divide*/ - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - (binaryfunc)int_div, /* nb_floor_divide */ - int_true_divide, /* nb_true_divide */ - 0, /* nb_inplace_floor_divide */ - 0, /* nb_inplace_true_divide */ -}; - -PyTypeObject PyInt_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "int", - sizeof(PyIntObject), - 0, - (destructor)int_dealloc, /* tp_dealloc */ - (printfunc)int_print, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)int_compare, /* tp_compare */ - (reprfunc)int_repr, /* tp_repr */ - &int_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)int_hash, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)int_repr, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - int_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - int_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - int_new, /* tp_new */ - (freefunc)int_free, /* tp_free */ -}; - -int -_PyInt_Init(void) -{ - PyIntObject *v; - int ival; -#if NSMALLNEGINTS + NSMALLPOSINTS > 0 - for (ival = -NSMALLNEGINTS; ival < NSMALLPOSINTS; ival++) { - if ((free_list = fill_free_list()) == NULL) - return 0; - /* PyObject_New is inlined */ - v = free_list; - free_list = (PyIntObject *)v->ob_type; - PyObject_INIT(v, &PyInt_Type); - v->ob_ival = ival; - small_ints[ival + NSMALLNEGINTS] = v; - } -#endif - return 1; -} - -void -PyInt_Fini(void) -{ - PyIntObject *p; - PyIntBlock *list, *next; - int i; - int bc, bf; /* block count, number of freed blocks */ - int irem, isum; /* remaining unfreed ints per block, total */ - -#if NSMALLNEGINTS + NSMALLPOSINTS > 0 - PyIntObject **q; - - i = NSMALLNEGINTS + NSMALLPOSINTS; - q = small_ints; - while (--i >= 0) { - Py_XDECREF(*q); - *q++ = NULL; - } -#endif - bc = 0; - bf = 0; - isum = 0; - list = block_list; - block_list = NULL; - free_list = NULL; - while (list != NULL) { - bc++; - irem = 0; - for (i = 0, p = &list->objects[0]; - i < N_INTOBJECTS; - i++, p++) { - if (PyInt_CheckExact(p) && p->ob_refcnt != 0) - irem++; - } - next = list->next; - if (irem) { - list->next = block_list; - block_list = list; - for (i = 0, p = &list->objects[0]; - i < N_INTOBJECTS; - i++, p++) { - if (!PyInt_CheckExact(p) || - p->ob_refcnt == 0) { - p->ob_type = (struct _typeobject *) - free_list; - free_list = p; - } -#if NSMALLNEGINTS + NSMALLPOSINTS > 0 - else if (-NSMALLNEGINTS <= p->ob_ival && - p->ob_ival < NSMALLPOSINTS && - small_ints[p->ob_ival + - NSMALLNEGINTS] == NULL) { - Py_INCREF(p); - small_ints[p->ob_ival + - NSMALLNEGINTS] = p; - } -#endif - } - } - else { - PyMem_FREE(list); - bf++; - } - isum += irem; - list = next; - } - if (!Py_VerboseFlag) - return; - fprintf(stderr, "# cleanup ints"); - if (!isum) { - fprintf(stderr, "\n"); - } - else { - fprintf(stderr, - ": %d unfreed int%s in %d out of %d block%s\n", - isum, isum == 1 ? "" : "s", - bc - bf, bc, bc == 1 ? "" : "s"); - } - if (Py_VerboseFlag > 1) { - list = block_list; - while (list != NULL) { - for (i = 0, p = &list->objects[0]; - i < N_INTOBJECTS; - i++, p++) { - if (PyInt_CheckExact(p) && p->ob_refcnt != 0) - fprintf(stderr, - "# \n", - p, p->ob_refcnt, p->ob_ival); - } - list = list->next; - } - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/iterobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/iterobject.c deleted file mode 100644 index 61fa6375..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/iterobject.c +++ /dev/null @@ -1,228 +0,0 @@ -/* Iterator objects */ - -#include "Python.h" - -typedef struct { - PyObject_HEAD - long it_index; - PyObject *it_seq; /* Set to NULL when iterator is exhausted */ -} seqiterobject; - -PyObject * -PySeqIter_New(PyObject *seq) -{ - seqiterobject *it; - - if (!PySequence_Check(seq)) { - PyErr_BadInternalCall(); - return NULL; - } - it = PyObject_GC_New(seqiterobject, &PySeqIter_Type); - if (it == NULL) - return NULL; - it->it_index = 0; - Py_INCREF(seq); - it->it_seq = seq; - _PyObject_GC_TRACK(it); - return (PyObject *)it; -} - -static void -iter_dealloc(seqiterobject *it) -{ - _PyObject_GC_UNTRACK(it); - Py_XDECREF(it->it_seq); - PyObject_GC_Del(it); -} - -static int -iter_traverse(seqiterobject *it, visitproc visit, void *arg) -{ - if (it->it_seq == NULL) - return 0; - return visit(it->it_seq, arg); -} - -static PyObject * -iter_iternext(PyObject *iterator) -{ - seqiterobject *it; - PyObject *seq; - PyObject *result; - - assert(PySeqIter_Check(iterator)); - it = (seqiterobject *)iterator; - seq = it->it_seq; - if (seq == NULL) - return NULL; - - result = PySequence_GetItem(seq, it->it_index); - if (result != NULL) { - it->it_index++; - return result; - } - if (PyErr_ExceptionMatches(PyExc_IndexError) || - PyErr_ExceptionMatches(PyExc_StopIteration)) - { - PyErr_Clear(); - Py_DECREF(seq); - it->it_seq = NULL; - } - return NULL; -} - -PyTypeObject PySeqIter_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "iterator", /* tp_name */ - sizeof(seqiterobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)iter_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - 0, /* tp_doc */ - (traverseproc)iter_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)iter_iternext, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -}; - -/* -------------------------------------- */ - -typedef struct { - PyObject_HEAD - PyObject *it_callable; /* Set to NULL when iterator is exhausted */ - PyObject *it_sentinel; /* Set to NULL when iterator is exhausted */ -} calliterobject; - -PyObject * -PyCallIter_New(PyObject *callable, PyObject *sentinel) -{ - calliterobject *it; - it = PyObject_GC_New(calliterobject, &PyCallIter_Type); - if (it == NULL) - return NULL; - Py_INCREF(callable); - it->it_callable = callable; - Py_INCREF(sentinel); - it->it_sentinel = sentinel; - _PyObject_GC_TRACK(it); - return (PyObject *)it; -} -static void -calliter_dealloc(calliterobject *it) -{ - _PyObject_GC_UNTRACK(it); - Py_XDECREF(it->it_callable); - Py_XDECREF(it->it_sentinel); - PyObject_GC_Del(it); -} - -static int -calliter_traverse(calliterobject *it, visitproc visit, void *arg) -{ - int err; - if (it->it_callable != NULL && (err = visit(it->it_callable, arg))) - return err; - if (it->it_sentinel != NULL && (err = visit(it->it_sentinel, arg))) - return err; - return 0; -} - -static PyObject * -calliter_iternext(calliterobject *it) -{ - if (it->it_callable != NULL) { - PyObject *args = PyTuple_New(0); - PyObject *result; - if (args == NULL) - return NULL; - result = PyObject_Call(it->it_callable, args, NULL); - Py_DECREF(args); - if (result != NULL) { - int ok; - ok = PyObject_RichCompareBool(result, - it->it_sentinel, - Py_EQ); - if (ok == 0) - return result; /* Common case, fast path */ - Py_DECREF(result); - if (ok > 0) { - Py_DECREF(it->it_callable); - it->it_callable = NULL; - Py_DECREF(it->it_sentinel); - it->it_sentinel = NULL; - } - } - else if (PyErr_ExceptionMatches(PyExc_StopIteration)) { - PyErr_Clear(); - Py_DECREF(it->it_callable); - it->it_callable = NULL; - Py_DECREF(it->it_sentinel); - it->it_sentinel = NULL; - } - } - return NULL; -} - -PyTypeObject PyCallIter_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "callable-iterator", /* tp_name */ - sizeof(calliterobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)calliter_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - 0, /* tp_doc */ - (traverseproc)calliter_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)calliter_iternext, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/listobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/listobject.c deleted file mode 100644 index 00d8b4c1..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/listobject.c +++ /dev/null @@ -1,2501 +0,0 @@ -/* List object implementation */ - -#include "Python.h" - -#ifdef STDC_HEADERS -#include -#else -#include /* For size_t */ -#endif - -static int -roundupsize(int n) -{ - unsigned int nbits = 0; - unsigned int n2 = (unsigned int)n >> 5; - - /* Round up: - * If n < 256, to a multiple of 8. - * If n < 2048, to a multiple of 64. - * If n < 16384, to a multiple of 512. - * If n < 131072, to a multiple of 4096. - * If n < 1048576, to a multiple of 32768. - * If n < 8388608, to a multiple of 262144. - * If n < 67108864, to a multiple of 2097152. - * If n < 536870912, to a multiple of 16777216. - * ... - * If n < 2**(5+3*i), to a multiple of 2**(3*i). - * - * This over-allocates proportional to the list size, making room - * for additional growth. The over-allocation is mild, but is - * enough to give linear-time amortized behavior over a long - * sequence of appends() in the presence of a poorly-performing - * system realloc() (which is a reality, e.g., across all flavors - * of Windows, with Win9x behavior being particularly bad -- and - * we've still got address space fragmentation problems on Win9x - * even with this scheme, although it requires much longer lists to - * provoke them than it used to). - */ - do { - n2 >>= 3; - nbits += 3; - } while (n2); - return ((n >> nbits) + 1) << nbits; - } - -#define NRESIZE(var, type, nitems) \ -do { \ - size_t _new_size = roundupsize(nitems); \ - if (_new_size <= ((~(size_t)0) / sizeof(type))) \ - PyMem_RESIZE(var, type, _new_size); \ - else \ - var = NULL; \ -} while (0) - -PyObject * -PyList_New(int size) -{ - PyListObject *op; - size_t nbytes; - if (size < 0) { - PyErr_BadInternalCall(); - return NULL; - } - nbytes = size * sizeof(PyObject *); - /* Check for overflow */ - if (nbytes / sizeof(PyObject *) != (size_t)size) { - return PyErr_NoMemory(); - } - op = PyObject_GC_New(PyListObject, &PyList_Type); - if (op == NULL) { - return NULL; - } - if (size <= 0) { - op->ob_item = NULL; - } - else { - op->ob_item = (PyObject **) PyMem_MALLOC(nbytes); - if (op->ob_item == NULL) { - return PyErr_NoMemory(); - } - memset(op->ob_item, 0, sizeof(*op->ob_item) * size); - } - op->ob_size = size; - _PyObject_GC_TRACK(op); - return (PyObject *) op; -} - -int -PyList_Size(PyObject *op) -{ - if (!PyList_Check(op)) { - PyErr_BadInternalCall(); - return -1; - } - else - return ((PyListObject *)op) -> ob_size; -} - -static PyObject *indexerr; - -PyObject * -PyList_GetItem(PyObject *op, int i) -{ - if (!PyList_Check(op)) { - PyErr_BadInternalCall(); - return NULL; - } - if (i < 0 || i >= ((PyListObject *)op) -> ob_size) { - if (indexerr == NULL) - indexerr = PyString_FromString( - "list index out of range"); - PyErr_SetObject(PyExc_IndexError, indexerr); - return NULL; - } - return ((PyListObject *)op) -> ob_item[i]; -} - -int -PyList_SetItem(register PyObject *op, register int i, - register PyObject *newitem) -{ - register PyObject *olditem; - register PyObject **p; - if (!PyList_Check(op)) { - Py_XDECREF(newitem); - PyErr_BadInternalCall(); - return -1; - } - if (i < 0 || i >= ((PyListObject *)op) -> ob_size) { - Py_XDECREF(newitem); - PyErr_SetString(PyExc_IndexError, - "list assignment index out of range"); - return -1; - } - p = ((PyListObject *)op) -> ob_item + i; - olditem = *p; - *p = newitem; - Py_XDECREF(olditem); - return 0; -} - -static int -ins1(PyListObject *self, int where, PyObject *v) -{ - int i; - PyObject **items; - if (v == NULL) { - PyErr_BadInternalCall(); - return -1; - } - if (self->ob_size == INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "cannot add more objects to list"); - return -1; - } - items = self->ob_item; - NRESIZE(items, PyObject *, self->ob_size+1); - if (items == NULL) { - PyErr_NoMemory(); - return -1; - } - if (where < 0) { - where += self->ob_size; - if (where < 0) - where = 0; - } - if (where > self->ob_size) - where = self->ob_size; - for (i = self->ob_size; --i >= where; ) - items[i+1] = items[i]; - Py_INCREF(v); - items[where] = v; - self->ob_item = items; - self->ob_size++; - return 0; -} - -int -PyList_Insert(PyObject *op, int where, PyObject *newitem) -{ - if (!PyList_Check(op)) { - PyErr_BadInternalCall(); - return -1; - } - return ins1((PyListObject *)op, where, newitem); -} - -int -PyList_Append(PyObject *op, PyObject *newitem) -{ - if (!PyList_Check(op)) { - PyErr_BadInternalCall(); - return -1; - } - return ins1((PyListObject *)op, - (int) ((PyListObject *)op)->ob_size, newitem); -} - -/* Methods */ - -static void -list_dealloc(PyListObject *op) -{ - int i; - PyObject_GC_UnTrack(op); - Py_TRASHCAN_SAFE_BEGIN(op) - if (op->ob_item != NULL) { - /* Do it backwards, for Christian Tismer. - There's a simple test case where somehow this reduces - thrashing when a *very* large list is created and - immediately deleted. */ - i = op->ob_size; - while (--i >= 0) { - Py_XDECREF(op->ob_item[i]); - } - PyMem_FREE(op->ob_item); - } - op->ob_type->tp_free((PyObject *)op); - Py_TRASHCAN_SAFE_END(op) -} - -static int -list_print(PyListObject *op, FILE *fp, int flags) -{ - int i; - - i = Py_ReprEnter((PyObject*)op); - if (i != 0) { - if (i < 0) - return i; - fprintf(fp, "[...]"); - return 0; - } - fprintf(fp, "["); - for (i = 0; i < op->ob_size; i++) { - if (i > 0) - fprintf(fp, ", "); - if (PyObject_Print(op->ob_item[i], fp, 0) != 0) { - Py_ReprLeave((PyObject *)op); - return -1; - } - } - fprintf(fp, "]"); - Py_ReprLeave((PyObject *)op); - return 0; -} - -static PyObject * -list_repr(PyListObject *v) -{ - int i; - PyObject *s, *temp; - PyObject *pieces = NULL, *result = NULL; - - i = Py_ReprEnter((PyObject*)v); - if (i != 0) { - return i > 0 ? PyString_FromString("[...]") : NULL; - } - - if (v->ob_size == 0) { - result = PyString_FromString("[]"); - goto Done; - } - - pieces = PyList_New(0); - if (pieces == NULL) - goto Done; - - /* Do repr() on each element. Note that this may mutate the list, - so must refetch the list size on each iteration. */ - for (i = 0; i < v->ob_size; ++i) { - int status; - s = PyObject_Repr(v->ob_item[i]); - if (s == NULL) - goto Done; - status = PyList_Append(pieces, s); - Py_DECREF(s); /* append created a new ref */ - if (status < 0) - goto Done; - } - - /* Add "[]" decorations to the first and last items. */ - assert(PyList_GET_SIZE(pieces) > 0); - s = PyString_FromString("["); - if (s == NULL) - goto Done; - temp = PyList_GET_ITEM(pieces, 0); - PyString_ConcatAndDel(&s, temp); - PyList_SET_ITEM(pieces, 0, s); - if (s == NULL) - goto Done; - - s = PyString_FromString("]"); - if (s == NULL) - goto Done; - temp = PyList_GET_ITEM(pieces, PyList_GET_SIZE(pieces) - 1); - PyString_ConcatAndDel(&temp, s); - PyList_SET_ITEM(pieces, PyList_GET_SIZE(pieces) - 1, temp); - if (temp == NULL) - goto Done; - - /* Paste them all together with ", " between. */ - s = PyString_FromString(", "); - if (s == NULL) - goto Done; - result = _PyString_Join(s, pieces); - Py_DECREF(s); - -Done: - Py_XDECREF(pieces); - Py_ReprLeave((PyObject *)v); - return result; -} - -static int -list_length(PyListObject *a) -{ - return a->ob_size; -} - - - -static int -list_contains(PyListObject *a, PyObject *el) -{ - int i, cmp; - - for (i = 0, cmp = 0 ; cmp == 0 && i < a->ob_size; ++i) - cmp = PyObject_RichCompareBool(el, PyList_GET_ITEM(a, i), - Py_EQ); - return cmp; -} - - -static PyObject * -list_item(PyListObject *a, int i) -{ - if (i < 0 || i >= a->ob_size) { - if (indexerr == NULL) - indexerr = PyString_FromString( - "list index out of range"); - PyErr_SetObject(PyExc_IndexError, indexerr); - return NULL; - } - Py_INCREF(a->ob_item[i]); - return a->ob_item[i]; -} - -static PyObject * -list_slice(PyListObject *a, int ilow, int ihigh) -{ - PyListObject *np; - int i; - if (ilow < 0) - ilow = 0; - else if (ilow > a->ob_size) - ilow = a->ob_size; - if (ihigh < ilow) - ihigh = ilow; - else if (ihigh > a->ob_size) - ihigh = a->ob_size; - np = (PyListObject *) PyList_New(ihigh - ilow); - if (np == NULL) - return NULL; - for (i = ilow; i < ihigh; i++) { - PyObject *v = a->ob_item[i]; - Py_INCREF(v); - np->ob_item[i - ilow] = v; - } - return (PyObject *)np; -} - -PyObject * -PyList_GetSlice(PyObject *a, int ilow, int ihigh) -{ - if (!PyList_Check(a)) { - PyErr_BadInternalCall(); - return NULL; - } - return list_slice((PyListObject *)a, ilow, ihigh); -} - -static PyObject * -list_concat(PyListObject *a, PyObject *bb) -{ - int size; - int i; - PyListObject *np; - if (!PyList_Check(bb)) { - PyErr_Format(PyExc_TypeError, - "can only concatenate list (not \"%.200s\") to list", - bb->ob_type->tp_name); - return NULL; - } -#define b ((PyListObject *)bb) - size = a->ob_size + b->ob_size; - if (size < 0) - return PyErr_NoMemory(); - np = (PyListObject *) PyList_New(size); - if (np == NULL) { - return NULL; - } - for (i = 0; i < a->ob_size; i++) { - PyObject *v = a->ob_item[i]; - Py_INCREF(v); - np->ob_item[i] = v; - } - for (i = 0; i < b->ob_size; i++) { - PyObject *v = b->ob_item[i]; - Py_INCREF(v); - np->ob_item[i + a->ob_size] = v; - } - return (PyObject *)np; -#undef b -} - -static PyObject * -list_repeat(PyListObject *a, int n) -{ - int i, j; - int size; - PyListObject *np; - PyObject **p; - PyObject *elem; - if (n < 0) - n = 0; - size = a->ob_size * n; - if (size == 0) - return PyList_New(0); - if (n && size/n != a->ob_size) - return PyErr_NoMemory(); - np = (PyListObject *) PyList_New(size); - if (np == NULL) - return NULL; - - if (a->ob_size == 1) { - elem = a->ob_item[0]; - for (i = 0; i < n; i++) { - np->ob_item[i] = elem; - Py_INCREF(elem); - } - return (PyObject *) np; - } - p = np->ob_item; - for (i = 0; i < n; i++) { - for (j = 0; j < a->ob_size; j++) { - *p = a->ob_item[j]; - Py_INCREF(*p); - p++; - } - } - return (PyObject *) np; -} - -static int -list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v) -{ - /* Because [X]DECREF can recursively invoke list operations on - this list, we must postpone all [X]DECREF activity until - after the list is back in its canonical shape. Therefore - we must allocate an additional array, 'recycle', into which - we temporarily copy the items that are deleted from the - list. :-( */ - PyObject **recycle, **p; - PyObject **item; - PyObject *v_as_SF = NULL; /* PySequence_Fast(v) */ - int n; /* Size of replacement list */ - int d; /* Change in size */ - int k; /* Loop index */ -#define b ((PyListObject *)v) - if (v == NULL) - n = 0; - else { - char msg[256]; - if (a == b) { - /* Special case "a[i:j] = a" -- copy b first */ - int ret; - v = list_slice(b, 0, b->ob_size); - if (v == NULL) - return -1; - ret = list_ass_slice(a, ilow, ihigh, v); - Py_DECREF(v); - return ret; - } - - PyOS_snprintf(msg, sizeof(msg), - "must assign sequence" - " (not \"%.200s\") to slice", - v->ob_type->tp_name); - v_as_SF = PySequence_Fast(v, msg); - if(v_as_SF == NULL) - return -1; - n = PySequence_Fast_GET_SIZE(v_as_SF); - } - if (ilow < 0) - ilow = 0; - else if (ilow > a->ob_size) - ilow = a->ob_size; - if (ihigh < ilow) - ihigh = ilow; - else if (ihigh > a->ob_size) - ihigh = a->ob_size; - item = a->ob_item; - d = n - (ihigh-ilow); - if (ihigh > ilow) { - p = recycle = PyMem_NEW(PyObject *, (ihigh-ilow)); - if (recycle == NULL) { - PyErr_NoMemory(); - return -1; - } - } - else - p = recycle = NULL; - if (d <= 0) { /* Delete -d items; recycle ihigh-ilow items */ - for (k = ilow; k < ihigh; k++) - *p++ = item[k]; - if (d < 0) { - for (/*k = ihigh*/; k < a->ob_size; k++) - item[k+d] = item[k]; - a->ob_size += d; - NRESIZE(item, PyObject *, a->ob_size); /* Can't fail */ - a->ob_item = item; - } - } - else { /* Insert d items; recycle ihigh-ilow items */ - NRESIZE(item, PyObject *, a->ob_size + d); - if (item == NULL) { - if (recycle != NULL) - PyMem_DEL(recycle); - PyErr_NoMemory(); - return -1; - } - for (k = a->ob_size; --k >= ihigh; ) - item[k+d] = item[k]; - for (/*k = ihigh-1*/; k >= ilow; --k) - *p++ = item[k]; - a->ob_item = item; - a->ob_size += d; - } - for (k = 0; k < n; k++, ilow++) { - PyObject *w = PySequence_Fast_GET_ITEM(v_as_SF, k); - Py_XINCREF(w); - item[ilow] = w; - } - if (recycle) { - while (--p >= recycle) - Py_XDECREF(*p); - PyMem_DEL(recycle); - } - if (a->ob_size == 0 && a->ob_item != NULL) { - PyMem_FREE(a->ob_item); - a->ob_item = NULL; - } - Py_XDECREF(v_as_SF); - return 0; -#undef b -} - -int -PyList_SetSlice(PyObject *a, int ilow, int ihigh, PyObject *v) -{ - if (!PyList_Check(a)) { - PyErr_BadInternalCall(); - return -1; - } - return list_ass_slice((PyListObject *)a, ilow, ihigh, v); -} - -static PyObject * -list_inplace_repeat(PyListObject *self, int n) -{ - PyObject **items; - int size, i, j; - - - size = PyList_GET_SIZE(self); - if (size == 0) { - Py_INCREF(self); - return (PyObject *)self; - } - - items = self->ob_item; - - if (n < 1) { - self->ob_item = NULL; - self->ob_size = 0; - for (i = 0; i < size; i++) - Py_XDECREF(items[i]); - PyMem_DEL(items); - Py_INCREF(self); - return (PyObject *)self; - } - - NRESIZE(items, PyObject*, size*n); - if (items == NULL) { - PyErr_NoMemory(); - goto finally; - } - self->ob_item = items; - for (i = 1; i < n; i++) { /* Start counting at 1, not 0 */ - for (j = 0; j < size; j++) { - PyObject *o = PyList_GET_ITEM(self, j); - Py_INCREF(o); - PyList_SET_ITEM(self, self->ob_size++, o); - } - } - Py_INCREF(self); - return (PyObject *)self; - finally: - return NULL; -} - -static int -list_ass_item(PyListObject *a, int i, PyObject *v) -{ - PyObject *old_value; - if (i < 0 || i >= a->ob_size) { - PyErr_SetString(PyExc_IndexError, - "list assignment index out of range"); - return -1; - } - if (v == NULL) - return list_ass_slice(a, i, i+1, v); - Py_INCREF(v); - old_value = a->ob_item[i]; - a->ob_item[i] = v; - Py_DECREF(old_value); - return 0; -} - -static PyObject * -ins(PyListObject *self, int where, PyObject *v) -{ - if (ins1(self, where, v) != 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -listinsert(PyListObject *self, PyObject *args) -{ - int i; - PyObject *v; - if (!PyArg_ParseTuple(args, "iO:insert", &i, &v)) - return NULL; - return ins(self, i, v); -} - -static PyObject * -listappend(PyListObject *self, PyObject *v) -{ - return ins(self, (int) self->ob_size, v); -} - -static int -listextend_internal(PyListObject *self, PyObject *b) -{ - PyObject **items; - int selflen = PyList_GET_SIZE(self); - int blen; - register int i; - - if (PyObject_Size(b) == 0) { - /* short circuit when b is empty */ - Py_DECREF(b); - return 0; - } - - if (self == (PyListObject*)b) { - /* as in list_ass_slice() we must special case the - * situation: a.extend(a) - * - * XXX: I think this way ought to be faster than using - * list_slice() the way list_ass_slice() does. - */ - Py_DECREF(b); - b = PyList_New(selflen); - if (!b) - return -1; - for (i = 0; i < selflen; i++) { - PyObject *o = PyList_GET_ITEM(self, i); - Py_INCREF(o); - PyList_SET_ITEM(b, i, o); - } - } - - blen = PyObject_Size(b); - - /* resize a using idiom */ - items = self->ob_item; - NRESIZE(items, PyObject*, selflen + blen); - if (items == NULL) { - PyErr_NoMemory(); - Py_DECREF(b); - return -1; - } - - self->ob_item = items; - - /* populate the end of self with b's items */ - for (i = 0; i < blen; i++) { - PyObject *o = PySequence_Fast_GET_ITEM(b, i); - Py_INCREF(o); - PyList_SET_ITEM(self, self->ob_size++, o); - } - Py_DECREF(b); - return 0; -} - - -static PyObject * -list_inplace_concat(PyListObject *self, PyObject *other) -{ - other = PySequence_Fast(other, "argument to += must be iterable"); - if (!other) - return NULL; - - if (listextend_internal(self, other) < 0) - return NULL; - - Py_INCREF(self); - return (PyObject *)self; -} - -static PyObject * -listextend(PyListObject *self, PyObject *b) -{ - - b = PySequence_Fast(b, "list.extend() argument must be iterable"); - if (!b) - return NULL; - - if (listextend_internal(self, b) < 0) - return NULL; - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -listpop(PyListObject *self, PyObject *args) -{ - int i = -1; - PyObject *v; - if (!PyArg_ParseTuple(args, "|i:pop", &i)) - return NULL; - if (self->ob_size == 0) { - /* Special-case most common failure cause */ - PyErr_SetString(PyExc_IndexError, "pop from empty list"); - return NULL; - } - if (i < 0) - i += self->ob_size; - if (i < 0 || i >= self->ob_size) { - PyErr_SetString(PyExc_IndexError, "pop index out of range"); - return NULL; - } - v = self->ob_item[i]; - Py_INCREF(v); - if (list_ass_slice(self, i, i+1, (PyObject *)NULL) != 0) { - Py_DECREF(v); - return NULL; - } - return v; -} - -/* Reverse a slice of a list in place, from lo up to (exclusive) hi. */ -static void -reverse_slice(PyObject **lo, PyObject **hi) -{ - assert(lo && hi); - - --hi; - while (lo < hi) { - PyObject *t = *lo; - *lo = *hi; - *hi = t; - ++lo; - --hi; - } -} - -/* Lots of code for an adaptive, stable, natural mergesort. There are many - * pieces to this algorithm; read listsort.txt for overviews and details. - */ - -/* Comparison function. Takes care of calling a user-supplied - * comparison function (any callable Python object), which must not be - * NULL (use the ISLT macro if you don't know, or call PyObject_RichCompareBool - * with Py_LT if you know it's NULL). - * Returns -1 on error, 1 if x < y, 0 if x >= y. - */ -static int -islt(PyObject *x, PyObject *y, PyObject *compare) -{ - PyObject *res; - PyObject *args; - int i; - - assert(compare != NULL); - /* Call the user's comparison function and translate the 3-way - * result into true or false (or error). - */ - args = PyTuple_New(2); - if (args == NULL) - return -1; - Py_INCREF(x); - Py_INCREF(y); - PyTuple_SET_ITEM(args, 0, x); - PyTuple_SET_ITEM(args, 1, y); - res = PyObject_Call(compare, args, NULL); - Py_DECREF(args); - if (res == NULL) - return -1; - if (!PyInt_Check(res)) { - Py_DECREF(res); - PyErr_SetString(PyExc_TypeError, - "comparison function must return int"); - return -1; - } - i = PyInt_AsLong(res); - Py_DECREF(res); - return i < 0; -} - -/* If COMPARE is NULL, calls PyObject_RichCompareBool with Py_LT, else calls - * islt. This avoids a layer of function call in the usual case, and - * sorting does many comparisons. - * Returns -1 on error, 1 if x < y, 0 if x >= y. - */ -#define ISLT(X, Y, COMPARE) ((COMPARE) == NULL ? \ - PyObject_RichCompareBool(X, Y, Py_LT) : \ - islt(X, Y, COMPARE)) - -/* Compare X to Y via "<". Goto "fail" if the comparison raises an - error. Else "k" is set to true iff X. X and Y are PyObject*s. -*/ -#define IFLT(X, Y) if ((k = ISLT(X, Y, compare)) < 0) goto fail; \ - if (k) - -/* binarysort is the best method for sorting small arrays: it does - few compares, but can do data movement quadratic in the number of - elements. - [lo, hi) is a contiguous slice of a list, and is sorted via - binary insertion. This sort is stable. - On entry, must have lo <= start <= hi, and that [lo, start) is already - sorted (pass start == lo if you don't know!). - If islt() complains return -1, else 0. - Even in case of error, the output slice will be some permutation of - the input (nothing is lost or duplicated). -*/ -static int -binarysort(PyObject **lo, PyObject **hi, PyObject **start, PyObject *compare) - /* compare -- comparison function object, or NULL for default */ -{ - register int k; - register PyObject **l, **p, **r; - register PyObject *pivot; - - assert(lo <= start && start <= hi); - /* assert [lo, start) is sorted */ - if (lo == start) - ++start; - for (; start < hi; ++start) { - /* set l to where *start belongs */ - l = lo; - r = start; - pivot = *r; - /* Invariants: - * pivot >= all in [lo, l). - * pivot < all in [r, start). - * The second is vacuously true at the start. - */ - assert(l < r); - do { - p = l + ((r - l) >> 1); - IFLT(pivot, *p) - r = p; - else - l = p+1; - } while (l < r); - assert(l == r); - /* The invariants still hold, so pivot >= all in [lo, l) and - pivot < all in [l, start), so pivot belongs at l. Note - that if there are elements equal to pivot, l points to the - first slot after them -- that's why this sort is stable. - Slide over to make room. - Caution: using memmove is much slower under MSVC 5; - we're not usually moving many slots. */ - for (p = start; p > l; --p) - *p = *(p-1); - *l = pivot; - } - return 0; - - fail: - return -1; -} - -/* -Return the length of the run beginning at lo, in the slice [lo, hi). lo < hi -is required on entry. "A run" is the longest ascending sequence, with - - lo[0] <= lo[1] <= lo[2] <= ... - -or the longest descending sequence, with - - lo[0] > lo[1] > lo[2] > ... - -Boolean *descending is set to 0 in the former case, or to 1 in the latter. -For its intended use in a stable mergesort, the strictness of the defn of -"descending" is needed so that the caller can safely reverse a descending -sequence without violating stability (strict > ensures there are no equal -elements to get out of order). - -Returns -1 in case of error. -*/ -static int -count_run(PyObject **lo, PyObject **hi, PyObject *compare, int *descending) -{ - int k; - int n; - - assert(lo < hi); - *descending = 0; - ++lo; - if (lo == hi) - return 1; - - n = 2; - IFLT(*lo, *(lo-1)) { - *descending = 1; - for (lo = lo+1; lo < hi; ++lo, ++n) { - IFLT(*lo, *(lo-1)) - ; - else - break; - } - } - else { - for (lo = lo+1; lo < hi; ++lo, ++n) { - IFLT(*lo, *(lo-1)) - break; - } - } - - return n; -fail: - return -1; -} - -/* -Locate the proper position of key in a sorted vector; if the vector contains -an element equal to key, return the position immediately to the left of -the leftmost equal element. [gallop_right() does the same except returns -the position to the right of the rightmost equal element (if any).] - -"a" is a sorted vector with n elements, starting at a[0]. n must be > 0. - -"hint" is an index at which to begin the search, 0 <= hint < n. The closer -hint is to the final result, the faster this runs. - -The return value is the int k in 0..n such that - - a[k-1] < key <= a[k] - -pretending that *(a-1) is minus infinity and a[n] is plus infinity. IOW, -key belongs at index k; or, IOW, the first k elements of a should precede -key, and the last n-k should follow key. - -Returns -1 on error. See listsort.txt for info on the method. -*/ -static int -gallop_left(PyObject *key, PyObject **a, int n, int hint, PyObject *compare) -{ - int ofs; - int lastofs; - int k; - - assert(key && a && n > 0 && hint >= 0 && hint < n); - - a += hint; - lastofs = 0; - ofs = 1; - IFLT(*a, key) { - /* a[hint] < key -- gallop right, until - * a[hint + lastofs] < key <= a[hint + ofs] - */ - const int maxofs = n - hint; /* &a[n-1] is highest */ - while (ofs < maxofs) { - IFLT(a[ofs], key) { - lastofs = ofs; - ofs = (ofs << 1) + 1; - if (ofs <= 0) /* int overflow */ - ofs = maxofs; - } - else /* key <= a[hint + ofs] */ - break; - } - if (ofs > maxofs) - ofs = maxofs; - /* Translate back to offsets relative to &a[0]. */ - lastofs += hint; - ofs += hint; - } - else { - /* key <= a[hint] -- gallop left, until - * a[hint - ofs] < key <= a[hint - lastofs] - */ - const int maxofs = hint + 1; /* &a[0] is lowest */ - while (ofs < maxofs) { - IFLT(*(a-ofs), key) - break; - /* key <= a[hint - ofs] */ - lastofs = ofs; - ofs = (ofs << 1) + 1; - if (ofs <= 0) /* int overflow */ - ofs = maxofs; - } - if (ofs > maxofs) - ofs = maxofs; - /* Translate back to positive offsets relative to &a[0]. */ - k = lastofs; - lastofs = hint - ofs; - ofs = hint - k; - } - a -= hint; - - assert(-1 <= lastofs && lastofs < ofs && ofs <= n); - /* Now a[lastofs] < key <= a[ofs], so key belongs somewhere to the - * right of lastofs but no farther right than ofs. Do a binary - * search, with invariant a[lastofs-1] < key <= a[ofs]. - */ - ++lastofs; - while (lastofs < ofs) { - int m = lastofs + ((ofs - lastofs) >> 1); - - IFLT(a[m], key) - lastofs = m+1; /* a[m] < key */ - else - ofs = m; /* key <= a[m] */ - } - assert(lastofs == ofs); /* so a[ofs-1] < key <= a[ofs] */ - return ofs; - -fail: - return -1; -} - -/* -Exactly like gallop_left(), except that if key already exists in a[0:n], -finds the position immediately to the right of the rightmost equal value. - -The return value is the int k in 0..n such that - - a[k-1] <= key < a[k] - -or -1 if error. - -The code duplication is massive, but this is enough different given that -we're sticking to "<" comparisons that it's much harder to follow if -written as one routine with yet another "left or right?" flag. -*/ -static int -gallop_right(PyObject *key, PyObject **a, int n, int hint, PyObject *compare) -{ - int ofs; - int lastofs; - int k; - - assert(key && a && n > 0 && hint >= 0 && hint < n); - - a += hint; - lastofs = 0; - ofs = 1; - IFLT(key, *a) { - /* key < a[hint] -- gallop left, until - * a[hint - ofs] <= key < a[hint - lastofs] - */ - const int maxofs = hint + 1; /* &a[0] is lowest */ - while (ofs < maxofs) { - IFLT(key, *(a-ofs)) { - lastofs = ofs; - ofs = (ofs << 1) + 1; - if (ofs <= 0) /* int overflow */ - ofs = maxofs; - } - else /* a[hint - ofs] <= key */ - break; - } - if (ofs > maxofs) - ofs = maxofs; - /* Translate back to positive offsets relative to &a[0]. */ - k = lastofs; - lastofs = hint - ofs; - ofs = hint - k; - } - else { - /* a[hint] <= key -- gallop right, until - * a[hint + lastofs] <= key < a[hint + ofs] - */ - const int maxofs = n - hint; /* &a[n-1] is highest */ - while (ofs < maxofs) { - IFLT(key, a[ofs]) - break; - /* a[hint + ofs] <= key */ - lastofs = ofs; - ofs = (ofs << 1) + 1; - if (ofs <= 0) /* int overflow */ - ofs = maxofs; - } - if (ofs > maxofs) - ofs = maxofs; - /* Translate back to offsets relative to &a[0]. */ - lastofs += hint; - ofs += hint; - } - a -= hint; - - assert(-1 <= lastofs && lastofs < ofs && ofs <= n); - /* Now a[lastofs] <= key < a[ofs], so key belongs somewhere to the - * right of lastofs but no farther right than ofs. Do a binary - * search, with invariant a[lastofs-1] <= key < a[ofs]. - */ - ++lastofs; - while (lastofs < ofs) { - int m = lastofs + ((ofs - lastofs) >> 1); - - IFLT(key, a[m]) - ofs = m; /* key < a[m] */ - else - lastofs = m+1; /* a[m] <= key */ - } - assert(lastofs == ofs); /* so a[ofs-1] <= key < a[ofs] */ - return ofs; - -fail: - return -1; -} - -/* The maximum number of entries in a MergeState's pending-runs stack. - * This is enough to sort arrays of size up to about - * 32 * phi ** MAX_MERGE_PENDING - * where phi ~= 1.618. 85 is ridiculouslylarge enough, good for an array - * with 2**64 elements. - */ -#define MAX_MERGE_PENDING 85 - -/* When we get into galloping mode, we stay there until both runs win less - * often than MIN_GALLOP consecutive times. See listsort.txt for more info. - */ -#define MIN_GALLOP 7 - -/* Avoid malloc for small temp arrays. */ -#define MERGESTATE_TEMP_SIZE 256 - -/* One MergeState exists on the stack per invocation of mergesort. It's just - * a convenient way to pass state around among the helper functions. - */ -struct s_slice { - PyObject **base; - int len; -}; - -typedef struct s_MergeState { - /* The user-supplied comparison function. or NULL if none given. */ - PyObject *compare; - - /* This controls when we get *into* galloping mode. It's initialized - * to MIN_GALLOP. merge_lo and merge_hi tend to nudge it higher for - * random data, and lower for highly structured data. - */ - int min_gallop; - - /* 'a' is temp storage to help with merges. It contains room for - * alloced entries. - */ - PyObject **a; /* may point to temparray below */ - int alloced; - - /* A stack of n pending runs yet to be merged. Run #i starts at - * address base[i] and extends for len[i] elements. It's always - * true (so long as the indices are in bounds) that - * - * pending[i].base + pending[i].len == pending[i+1].base - * - * so we could cut the storage for this, but it's a minor amount, - * and keeping all the info explicit simplifies the code. - */ - int n; - struct s_slice pending[MAX_MERGE_PENDING]; - - /* 'a' points to this when possible, rather than muck with malloc. */ - PyObject *temparray[MERGESTATE_TEMP_SIZE]; -} MergeState; - -/* Conceptually a MergeState's constructor. */ -static void -merge_init(MergeState *ms, PyObject *compare) -{ - assert(ms != NULL); - ms->compare = compare; - ms->a = ms->temparray; - ms->alloced = MERGESTATE_TEMP_SIZE; - ms->n = 0; - ms->min_gallop = MIN_GALLOP; -} - -/* Free all the temp memory owned by the MergeState. This must be called - * when you're done with a MergeState, and may be called before then if - * you want to free the temp memory early. - */ -static void -merge_freemem(MergeState *ms) -{ - assert(ms != NULL); - if (ms->a != ms->temparray) - PyMem_Free(ms->a); - ms->a = ms->temparray; - ms->alloced = MERGESTATE_TEMP_SIZE; -} - -/* Ensure enough temp memory for 'need' array slots is available. - * Returns 0 on success and -1 if the memory can't be gotten. - */ -static int -merge_getmem(MergeState *ms, int need) -{ - assert(ms != NULL); - if (need <= ms->alloced) - return 0; - /* Don't realloc! That can cost cycles to copy the old data, but - * we don't care what's in the block. - */ - merge_freemem(ms); - ms->a = (PyObject **)PyMem_Malloc(need * sizeof(PyObject*)); - if (ms->a) { - ms->alloced = need; - return 0; - } - PyErr_NoMemory(); - merge_freemem(ms); /* reset to sane state */ - return -1; -} -#define MERGE_GETMEM(MS, NEED) ((NEED) <= (MS)->alloced ? 0 : \ - merge_getmem(MS, NEED)) - -/* Merge the na elements starting at pa with the nb elements starting at pb - * in a stable way, in-place. na and nb must be > 0, and pa + na == pb. - * Must also have that *pb < *pa, that pa[na-1] belongs at the end of the - * merge, and should have na <= nb. See listsort.txt for more info. - * Return 0 if successful, -1 if error. - */ -static int -merge_lo(MergeState *ms, PyObject **pa, int na, PyObject **pb, int nb) -{ - int k; - PyObject *compare; - PyObject **dest; - int result = -1; /* guilty until proved innocent */ - int min_gallop = ms->min_gallop; - - assert(ms && pa && pb && na > 0 && nb > 0 && pa + na == pb); - if (MERGE_GETMEM(ms, na) < 0) - return -1; - memcpy(ms->a, pa, na * sizeof(PyObject*)); - dest = pa; - pa = ms->a; - - *dest++ = *pb++; - --nb; - if (nb == 0) - goto Succeed; - if (na == 1) - goto CopyB; - - compare = ms->compare; - for (;;) { - int acount = 0; /* # of times A won in a row */ - int bcount = 0; /* # of times B won in a row */ - - /* Do the straightforward thing until (if ever) one run - * appears to win consistently. - */ - for (;;) { - assert(na > 1 && nb > 0); - k = ISLT(*pb, *pa, compare); - if (k) { - if (k < 0) - goto Fail; - *dest++ = *pb++; - ++bcount; - acount = 0; - --nb; - if (nb == 0) - goto Succeed; - if (bcount >= min_gallop) - break; - } - else { - *dest++ = *pa++; - ++acount; - bcount = 0; - --na; - if (na == 1) - goto CopyB; - if (acount >= min_gallop) - break; - } - } - - /* One run is winning so consistently that galloping may - * be a huge win. So try that, and continue galloping until - * (if ever) neither run appears to be winning consistently - * anymore. - */ - ++min_gallop; - do { - assert(na > 1 && nb > 0); - min_gallop -= min_gallop > 1; - ms->min_gallop = min_gallop; - k = gallop_right(*pb, pa, na, 0, compare); - acount = k; - if (k) { - if (k < 0) - goto Fail; - memcpy(dest, pa, k * sizeof(PyObject *)); - dest += k; - pa += k; - na -= k; - if (na == 1) - goto CopyB; - /* na==0 is impossible now if the comparison - * function is consistent, but we can't assume - * that it is. - */ - if (na == 0) - goto Succeed; - } - *dest++ = *pb++; - --nb; - if (nb == 0) - goto Succeed; - - k = gallop_left(*pa, pb, nb, 0, compare); - bcount = k; - if (k) { - if (k < 0) - goto Fail; - memmove(dest, pb, k * sizeof(PyObject *)); - dest += k; - pb += k; - nb -= k; - if (nb == 0) - goto Succeed; - } - *dest++ = *pa++; - --na; - if (na == 1) - goto CopyB; - } while (acount >= MIN_GALLOP || bcount >= MIN_GALLOP); - ++min_gallop; /* penalize it for leaving galloping mode */ - ms->min_gallop = min_gallop; - } -Succeed: - result = 0; -Fail: - if (na) - memcpy(dest, pa, na * sizeof(PyObject*)); - return result; -CopyB: - assert(na == 1 && nb > 0); - /* The last element of pa belongs at the end of the merge. */ - memmove(dest, pb, nb * sizeof(PyObject *)); - dest[nb] = *pa; - return 0; -} - -/* Merge the na elements starting at pa with the nb elements starting at pb - * in a stable way, in-place. na and nb must be > 0, and pa + na == pb. - * Must also have that *pb < *pa, that pa[na-1] belongs at the end of the - * merge, and should have na >= nb. See listsort.txt for more info. - * Return 0 if successful, -1 if error. - */ -static int -merge_hi(MergeState *ms, PyObject **pa, int na, PyObject **pb, int nb) -{ - int k; - PyObject *compare; - PyObject **dest; - int result = -1; /* guilty until proved innocent */ - PyObject **basea; - PyObject **baseb; - int min_gallop = ms->min_gallop; - - assert(ms && pa && pb && na > 0 && nb > 0 && pa + na == pb); - if (MERGE_GETMEM(ms, nb) < 0) - return -1; - dest = pb + nb - 1; - memcpy(ms->a, pb, nb * sizeof(PyObject*)); - basea = pa; - baseb = ms->a; - pb = ms->a + nb - 1; - pa += na - 1; - - *dest-- = *pa--; - --na; - if (na == 0) - goto Succeed; - if (nb == 1) - goto CopyA; - - compare = ms->compare; - for (;;) { - int acount = 0; /* # of times A won in a row */ - int bcount = 0; /* # of times B won in a row */ - - /* Do the straightforward thing until (if ever) one run - * appears to win consistently. - */ - for (;;) { - assert(na > 0 && nb > 1); - k = ISLT(*pb, *pa, compare); - if (k) { - if (k < 0) - goto Fail; - *dest-- = *pa--; - ++acount; - bcount = 0; - --na; - if (na == 0) - goto Succeed; - if (acount >= min_gallop) - break; - } - else { - *dest-- = *pb--; - ++bcount; - acount = 0; - --nb; - if (nb == 1) - goto CopyA; - if (bcount >= min_gallop) - break; - } - } - - /* One run is winning so consistently that galloping may - * be a huge win. So try that, and continue galloping until - * (if ever) neither run appears to be winning consistently - * anymore. - */ - ++min_gallop; - do { - assert(na > 0 && nb > 1); - min_gallop -= min_gallop > 1; - ms->min_gallop = min_gallop; - k = gallop_right(*pb, basea, na, na-1, compare); - if (k < 0) - goto Fail; - k = na - k; - acount = k; - if (k) { - dest -= k; - pa -= k; - memmove(dest+1, pa+1, k * sizeof(PyObject *)); - na -= k; - if (na == 0) - goto Succeed; - } - *dest-- = *pb--; - --nb; - if (nb == 1) - goto CopyA; - - k = gallop_left(*pa, baseb, nb, nb-1, compare); - if (k < 0) - goto Fail; - k = nb - k; - bcount = k; - if (k) { - dest -= k; - pb -= k; - memcpy(dest+1, pb+1, k * sizeof(PyObject *)); - nb -= k; - if (nb == 1) - goto CopyA; - /* nb==0 is impossible now if the comparison - * function is consistent, but we can't assume - * that it is. - */ - if (nb == 0) - goto Succeed; - } - *dest-- = *pa--; - --na; - if (na == 0) - goto Succeed; - } while (acount >= MIN_GALLOP || bcount >= MIN_GALLOP); - ++min_gallop; /* penalize it for leaving galloping mode */ - ms->min_gallop = min_gallop; - } -Succeed: - result = 0; -Fail: - if (nb) - memcpy(dest-(nb-1), baseb, nb * sizeof(PyObject*)); - return result; -CopyA: - assert(nb == 1 && na > 0); - /* The first element of pb belongs at the front of the merge. */ - dest -= na; - pa -= na; - memmove(dest+1, pa+1, na * sizeof(PyObject *)); - *dest = *pb; - return 0; -} - -/* Merge the two runs at stack indices i and i+1. - * Returns 0 on success, -1 on error. - */ -static int -merge_at(MergeState *ms, int i) -{ - PyObject **pa, **pb; - int na, nb; - int k; - PyObject *compare; - - assert(ms != NULL); - assert(ms->n >= 2); - assert(i >= 0); - assert(i == ms->n - 2 || i == ms->n - 3); - - pa = ms->pending[i].base; - na = ms->pending[i].len; - pb = ms->pending[i+1].base; - nb = ms->pending[i+1].len; - assert(na > 0 && nb > 0); - assert(pa + na == pb); - - /* Record the length of the combined runs; if i is the 3rd-last - * run now, also slide over the last run (which isn't involved - * in this merge). The current run i+1 goes away in any case. - */ - ms->pending[i].len = na + nb; - if (i == ms->n - 3) - ms->pending[i+1] = ms->pending[i+2]; - --ms->n; - - /* Where does b start in a? Elements in a before that can be - * ignored (already in place). - */ - compare = ms->compare; - k = gallop_right(*pb, pa, na, 0, compare); - if (k < 0) - return -1; - pa += k; - na -= k; - if (na == 0) - return 0; - - /* Where does a end in b? Elements in b after that can be - * ignored (already in place). - */ - nb = gallop_left(pa[na-1], pb, nb, nb-1, compare); - if (nb <= 0) - return nb; - - /* Merge what remains of the runs, using a temp array with - * min(na, nb) elements. - */ - if (na <= nb) - return merge_lo(ms, pa, na, pb, nb); - else - return merge_hi(ms, pa, na, pb, nb); -} - -/* Examine the stack of runs waiting to be merged, merging adjacent runs - * until the stack invariants are re-established: - * - * 1. len[-3] > len[-2] + len[-1] - * 2. len[-2] > len[-1] - * - * See listsort.txt for more info. - * - * Returns 0 on success, -1 on error. - */ -static int -merge_collapse(MergeState *ms) -{ - struct s_slice *p = ms->pending; - - assert(ms); - while (ms->n > 1) { - int n = ms->n - 2; - if (n > 0 && p[n-1].len <= p[n].len + p[n+1].len) { - if (p[n-1].len < p[n+1].len) - --n; - if (merge_at(ms, n) < 0) - return -1; - } - else if (p[n].len <= p[n+1].len) { - if (merge_at(ms, n) < 0) - return -1; - } - else - break; - } - return 0; -} - -/* Regardless of invariants, merge all runs on the stack until only one - * remains. This is used at the end of the mergesort. - * - * Returns 0 on success, -1 on error. - */ -static int -merge_force_collapse(MergeState *ms) -{ - struct s_slice *p = ms->pending; - - assert(ms); - while (ms->n > 1) { - int n = ms->n - 2; - if (n > 0 && p[n-1].len < p[n+1].len) - --n; - if (merge_at(ms, n) < 0) - return -1; - } - return 0; -} - -/* Compute a good value for the minimum run length; natural runs shorter - * than this are boosted artificially via binary insertion. - * - * If n < 64, return n (it's too small to bother with fancy stuff). - * Else if n is an exact power of 2, return 32. - * Else return an int k, 32 <= k <= 64, such that n/k is close to, but - * strictly less than, an exact power of 2. - * - * See listsort.txt for more info. - */ -static int -merge_compute_minrun(int n) -{ - int r = 0; /* becomes 1 if any 1 bits are shifted off */ - - assert(n >= 0); - while (n >= 64) { - r |= n & 1; - n >>= 1; - } - return n + r; -} - -/* An adaptive, stable, natural mergesort. See listsort.txt. - * Returns Py_None on success, NULL on error. Even in case of error, the - * list will be some permutation of its input state (nothing is lost or - * duplicated). - */ -static PyObject * -listsort(PyListObject *self, PyObject *args) -{ - MergeState ms; - PyObject **lo, **hi; - int nremaining; - int minrun; - int saved_ob_size; - PyObject **saved_ob_item; - PyObject **empty_ob_item; - PyObject *compare = NULL; - PyObject *result = NULL; /* guilty until proved innocent */ - - assert(self != NULL); - if (args != NULL) { - if (!PyArg_UnpackTuple(args, "sort", 0, 1, &compare)) - return NULL; - } - if (compare == Py_None) - compare = NULL; - - merge_init(&ms, compare); - - /* The list is temporarily made empty, so that mutations performed - * by comparison functions can't affect the slice of memory we're - * sorting (allowing mutations during sorting is a core-dump - * factory, since ob_item may change). - */ - saved_ob_size = self->ob_size; - saved_ob_item = self->ob_item; - self->ob_size = 0; - self->ob_item = empty_ob_item = PyMem_NEW(PyObject *, 0); - - nremaining = saved_ob_size; - if (nremaining < 2) - goto succeed; - - /* March over the array once, left to right, finding natural runs, - * and extending short natural runs to minrun elements. - */ - lo = saved_ob_item; - hi = lo + nremaining; - minrun = merge_compute_minrun(nremaining); - do { - int descending; - int n; - - /* Identify next run. */ - n = count_run(lo, hi, compare, &descending); - if (n < 0) - goto fail; - if (descending) - reverse_slice(lo, lo + n); - /* If short, extend to min(minrun, nremaining). */ - if (n < minrun) { - const int force = nremaining <= minrun ? - nremaining : minrun; - if (binarysort(lo, lo + force, lo + n, compare) < 0) - goto fail; - n = force; - } - /* Push run onto pending-runs stack, and maybe merge. */ - assert(ms.n < MAX_MERGE_PENDING); - ms.pending[ms.n].base = lo; - ms.pending[ms.n].len = n; - ++ms.n; - if (merge_collapse(&ms) < 0) - goto fail; - /* Advance to find next run. */ - lo += n; - nremaining -= n; - } while (nremaining); - assert(lo == hi); - - if (merge_force_collapse(&ms) < 0) - goto fail; - assert(ms.n == 1); - assert(ms.pending[0].base == saved_ob_item); - assert(ms.pending[0].len == saved_ob_size); - -succeed: - result = Py_None; -fail: - if (self->ob_item != empty_ob_item || self->ob_size) { - /* The user mucked with the list during the sort. */ - (void)list_ass_slice(self, 0, self->ob_size, (PyObject *)NULL); - if (result != NULL) { - PyErr_SetString(PyExc_ValueError, - "list modified during sort"); - result = NULL; - } - } - if (self->ob_item == empty_ob_item) - PyMem_FREE(empty_ob_item); - self->ob_size = saved_ob_size; - self->ob_item = saved_ob_item; - merge_freemem(&ms); - Py_XINCREF(result); - return result; -} -#undef IFLT -#undef ISLT - -int -PyList_Sort(PyObject *v) -{ - if (v == NULL || !PyList_Check(v)) { - PyErr_BadInternalCall(); - return -1; - } - v = listsort((PyListObject *)v, (PyObject *)NULL); - if (v == NULL) - return -1; - Py_DECREF(v); - return 0; -} - -static PyObject * -listreverse(PyListObject *self) -{ - if (self->ob_size > 1) - reverse_slice(self->ob_item, self->ob_item + self->ob_size); - Py_INCREF(Py_None); - return Py_None; -} - -int -PyList_Reverse(PyObject *v) -{ - PyListObject *self = (PyListObject *)v; - - if (v == NULL || !PyList_Check(v)) { - PyErr_BadInternalCall(); - return -1; - } - if (self->ob_size > 1) - reverse_slice(self->ob_item, self->ob_item + self->ob_size); - return 0; -} - -PyObject * -PyList_AsTuple(PyObject *v) -{ - PyObject *w; - PyObject **p; - int n; - if (v == NULL || !PyList_Check(v)) { - PyErr_BadInternalCall(); - return NULL; - } - n = ((PyListObject *)v)->ob_size; - w = PyTuple_New(n); - if (w == NULL) - return NULL; - p = ((PyTupleObject *)w)->ob_item; - memcpy((void *)p, - (void *)((PyListObject *)v)->ob_item, - n*sizeof(PyObject *)); - while (--n >= 0) { - Py_INCREF(*p); - p++; - } - return w; -} - -static PyObject * -listindex(PyListObject *self, PyObject *args) -{ - int i, start=0, stop=self->ob_size; - PyObject *v; - - if (!PyArg_ParseTuple(args, "O|O&O&:index", &v, - _PyEval_SliceIndex, &start, - _PyEval_SliceIndex, &stop)) - return NULL; - if (start < 0) { - start += self->ob_size; - if (start < 0) - start = 0; - } - if (stop < 0) { - stop += self->ob_size; - if (stop < 0) - stop = 0; - } - else if (stop > self->ob_size) - stop = self->ob_size; - for (i = start; i < stop; i++) { - int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ); - if (cmp > 0) - return PyInt_FromLong((long)i); - else if (cmp < 0) - return NULL; - } - PyErr_SetString(PyExc_ValueError, "list.index(x): x not in list"); - return NULL; -} - -static PyObject * -listcount(PyListObject *self, PyObject *v) -{ - int count = 0; - int i; - - for (i = 0; i < self->ob_size; i++) { - int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ); - if (cmp > 0) - count++; - else if (cmp < 0) - return NULL; - } - return PyInt_FromLong((long)count); -} - -static PyObject * -listremove(PyListObject *self, PyObject *v) -{ - int i; - - for (i = 0; i < self->ob_size; i++) { - int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ); - if (cmp > 0) { - if (list_ass_slice(self, i, i+1, - (PyObject *)NULL) != 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; - } - else if (cmp < 0) - return NULL; - } - PyErr_SetString(PyExc_ValueError, "list.remove(x): x not in list"); - return NULL; -} - -static int -list_traverse(PyListObject *o, visitproc visit, void *arg) -{ - int i, err; - PyObject *x; - - for (i = o->ob_size; --i >= 0; ) { - x = o->ob_item[i]; - if (x != NULL) { - err = visit(x, arg); - if (err) - return err; - } - } - return 0; -} - -static int -list_clear(PyListObject *lp) -{ - (void) PyList_SetSlice((PyObject *)lp, 0, lp->ob_size, 0); - return 0; -} - -static PyObject * -list_richcompare(PyObject *v, PyObject *w, int op) -{ - PyListObject *vl, *wl; - int i; - - if (!PyList_Check(v) || !PyList_Check(w)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - - vl = (PyListObject *)v; - wl = (PyListObject *)w; - - if (vl->ob_size != wl->ob_size && (op == Py_EQ || op == Py_NE)) { - /* Shortcut: if the lengths differ, the lists differ */ - PyObject *res; - if (op == Py_EQ) - res = Py_False; - else - res = Py_True; - Py_INCREF(res); - return res; - } - - /* Search for the first index where items are different */ - for (i = 0; i < vl->ob_size && i < wl->ob_size; i++) { - int k = PyObject_RichCompareBool(vl->ob_item[i], - wl->ob_item[i], Py_EQ); - if (k < 0) - return NULL; - if (!k) - break; - } - - if (i >= vl->ob_size || i >= wl->ob_size) { - /* No more items to compare -- compare sizes */ - int vs = vl->ob_size; - int ws = wl->ob_size; - int cmp; - PyObject *res; - switch (op) { - case Py_LT: cmp = vs < ws; break; - case Py_LE: cmp = vs <= ws; break; - case Py_EQ: cmp = vs == ws; break; - case Py_NE: cmp = vs != ws; break; - case Py_GT: cmp = vs > ws; break; - case Py_GE: cmp = vs >= ws; break; - default: return NULL; /* cannot happen */ - } - if (cmp) - res = Py_True; - else - res = Py_False; - Py_INCREF(res); - return res; - } - - /* We have an item that differs -- shortcuts for EQ/NE */ - if (op == Py_EQ) { - Py_INCREF(Py_False); - return Py_False; - } - if (op == Py_NE) { - Py_INCREF(Py_True); - return Py_True; - } - - /* Compare the final item again using the proper operator */ - return PyObject_RichCompare(vl->ob_item[i], wl->ob_item[i], op); -} - -/* Adapted from newer code by Tim */ -static int -list_fill(PyListObject *result, PyObject *v) -{ - PyObject *it; /* iter(v) */ - int n; /* guess for result list size */ - int i; - - n = result->ob_size; - - /* Special-case list(a_list), for speed. */ - if (PyList_Check(v)) { - if (v == (PyObject *)result) - return 0; /* source is destination, we're done */ - return list_ass_slice(result, 0, n, v); - } - - /* Empty previous contents */ - if (n != 0) { - if (list_ass_slice(result, 0, n, (PyObject *)NULL) != 0) - return -1; - } - - /* Get iterator. There may be some low-level efficiency to be gained - * by caching the tp_iternext slot instead of using PyIter_Next() - * later, but premature optimization is the root etc. - */ - it = PyObject_GetIter(v); - if (it == NULL) - return -1; - - /* Guess a result list size. */ - n = -1; /* unknown */ - if (PySequence_Check(v) && - v->ob_type->tp_as_sequence->sq_length) { - n = PySequence_Size(v); - if (n < 0) - PyErr_Clear(); - } - if (n < 0) - n = 8; /* arbitrary */ - NRESIZE(result->ob_item, PyObject*, n); - if (result->ob_item == NULL) { - PyErr_NoMemory(); - goto error; - } - memset(result->ob_item, 0, sizeof(*result->ob_item) * n); - result->ob_size = n; - - /* Run iterator to exhaustion. */ - for (i = 0; ; i++) { - PyObject *item = PyIter_Next(it); - if (item == NULL) { - if (PyErr_Occurred()) - goto error; - break; - } - if (i < n) - PyList_SET_ITEM(result, i, item); /* steals ref */ - else { - int status = ins1(result, result->ob_size, item); - Py_DECREF(item); /* append creates a new ref */ - if (status < 0) - goto error; - } - } - - /* Cut back result list if initial guess was too large. */ - if (i < n && result != NULL) { - if (list_ass_slice(result, i, n, (PyObject *)NULL) != 0) - goto error; - } - Py_DECREF(it); - return 0; - - error: - Py_DECREF(it); - return -1; -} - -static int -list_init(PyListObject *self, PyObject *args, PyObject *kw) -{ - PyObject *arg = NULL; - static char *kwlist[] = {"sequence", 0}; - - if (!PyArg_ParseTupleAndKeywords(args, kw, "|O:list", kwlist, &arg)) - return -1; - if (arg != NULL) - return list_fill(self, arg); - if (self->ob_size > 0) - return list_ass_slice(self, 0, self->ob_size, (PyObject*)NULL); - return 0; -} - -static long -list_nohash(PyObject *self) -{ - PyErr_SetString(PyExc_TypeError, "list objects are unhashable"); - return -1; -} - -PyDoc_STRVAR(append_doc, -"L.append(object) -- append object to end"); -PyDoc_STRVAR(extend_doc, -"L.extend(iterable) -- extend list by appending elements from the iterable"); -PyDoc_STRVAR(insert_doc, -"L.insert(index, object) -- insert object before index"); -PyDoc_STRVAR(pop_doc, -"L.pop([index]) -> item -- remove and return item at index (default last)"); -PyDoc_STRVAR(remove_doc, -"L.remove(value) -- remove first occurrence of value"); -PyDoc_STRVAR(index_doc, -"L.index(value, [start, [stop]]) -> integer -- return first index of value"); -PyDoc_STRVAR(count_doc, -"L.count(value) -> integer -- return number of occurrences of value"); -PyDoc_STRVAR(reverse_doc, -"L.reverse() -- reverse *IN PLACE*"); -PyDoc_STRVAR(sort_doc, -"L.sort(cmpfunc=None) -- stable sort *IN PLACE*; cmpfunc(x, y) -> -1, 0, 1"); - -static PyMethodDef list_methods[] = { - {"append", (PyCFunction)listappend, METH_O, append_doc}, - {"insert", (PyCFunction)listinsert, METH_VARARGS, insert_doc}, - {"extend", (PyCFunction)listextend, METH_O, extend_doc}, - {"pop", (PyCFunction)listpop, METH_VARARGS, pop_doc}, - {"remove", (PyCFunction)listremove, METH_O, remove_doc}, - {"index", (PyCFunction)listindex, METH_VARARGS, index_doc}, - {"count", (PyCFunction)listcount, METH_O, count_doc}, - {"reverse", (PyCFunction)listreverse, METH_NOARGS, reverse_doc}, - {"sort", (PyCFunction)listsort, METH_VARARGS, sort_doc}, - {NULL, NULL} /* sentinel */ -}; - -static PySequenceMethods list_as_sequence = { - (inquiry)list_length, /* sq_length */ - (binaryfunc)list_concat, /* sq_concat */ - (intargfunc)list_repeat, /* sq_repeat */ - (intargfunc)list_item, /* sq_item */ - (intintargfunc)list_slice, /* sq_slice */ - (intobjargproc)list_ass_item, /* sq_ass_item */ - (intintobjargproc)list_ass_slice, /* sq_ass_slice */ - (objobjproc)list_contains, /* sq_contains */ - (binaryfunc)list_inplace_concat, /* sq_inplace_concat */ - (intargfunc)list_inplace_repeat, /* sq_inplace_repeat */ -}; - -PyDoc_STRVAR(list_doc, -"list() -> new list\n" -"list(sequence) -> new list initialized from sequence's items"); - -static PyObject *list_iter(PyObject *seq); - -static PyObject * -list_subscript(PyListObject* self, PyObject* item) -{ - if (PyInt_Check(item)) { - long i = PyInt_AS_LONG(item); - if (i < 0) - i += PyList_GET_SIZE(self); - return list_item(self, i); - } - else if (PyLong_Check(item)) { - long i = PyLong_AsLong(item); - if (i == -1 && PyErr_Occurred()) - return NULL; - if (i < 0) - i += PyList_GET_SIZE(self); - return list_item(self, i); - } - else if (PySlice_Check(item)) { - int start, stop, step, slicelength, cur, i; - PyObject* result; - PyObject* it; - - if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size, - &start, &stop, &step, &slicelength) < 0) { - return NULL; - } - - if (slicelength <= 0) { - return PyList_New(0); - } - else { - result = PyList_New(slicelength); - if (!result) return NULL; - - for (cur = start, i = 0; i < slicelength; - cur += step, i++) { - it = PyList_GET_ITEM(self, cur); - Py_INCREF(it); - PyList_SET_ITEM(result, i, it); - } - - return result; - } - } - else { - PyErr_SetString(PyExc_TypeError, - "list indices must be integers"); - return NULL; - } -} - -static int -list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value) -{ - if (PyInt_Check(item)) { - long i = PyInt_AS_LONG(item); - if (i < 0) - i += PyList_GET_SIZE(self); - return list_ass_item(self, i, value); - } - else if (PyLong_Check(item)) { - long i = PyLong_AsLong(item); - if (i == -1 && PyErr_Occurred()) - return -1; - if (i < 0) - i += PyList_GET_SIZE(self); - return list_ass_item(self, i, value); - } - else if (PySlice_Check(item)) { - int start, stop, step, slicelength; - - if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size, - &start, &stop, &step, &slicelength) < 0) { - return -1; - } - - /* treat L[slice(a,b)] = v _exactly_ like L[a:b] = v */ - if (step == 1 && ((PySliceObject*)item)->step == Py_None) - return list_ass_slice(self, start, stop, value); - - if (value == NULL) { - /* delete slice */ - PyObject **garbage, **it; - int cur, i, j; - - if (slicelength <= 0) - return 0; - - if (step < 0) { - stop = start + 1; - start = stop + step*(slicelength - 1) - 1; - step = -step; - } - - garbage = (PyObject**) - PyMem_MALLOC(slicelength*sizeof(PyObject*)); - - /* drawing pictures might help - understand these for loops */ - for (cur = start, i = 0; - cur < stop; - cur += step, i++) { - int lim = step; - - garbage[i] = PyList_GET_ITEM(self, cur); - - if (cur + step >= self->ob_size) { - lim = self->ob_size - cur - 1; - } - - for (j = 0; j < lim; j++) { - PyList_SET_ITEM(self, cur + j - i, - PyList_GET_ITEM(self, - cur + j + 1)); - } - } - for (cur = start + slicelength*step + 1; - cur < self->ob_size; cur++) { - PyList_SET_ITEM(self, cur - slicelength, - PyList_GET_ITEM(self, cur)); - } - self->ob_size -= slicelength; - it = self->ob_item; - NRESIZE(it, PyObject*, self->ob_size); - self->ob_item = it; - - for (i = 0; i < slicelength; i++) { - Py_DECREF(garbage[i]); - } - PyMem_FREE(garbage); - - return 0; - } - else { - /* assign slice */ - PyObject **garbage, *ins, *seq; - int cur, i; - - /* protect against a[::-1] = a */ - if (self == (PyListObject*)value) { - seq = list_slice((PyListObject*)value, 0, - PyList_GET_SIZE(value)); - } - else { - char msg[256]; - PyOS_snprintf(msg, sizeof(msg), - "must assign sequence (not \"%.200s\") to extended slice", - value->ob_type->tp_name); - seq = PySequence_Fast(value, msg); - if (!seq) - return -1; - } - - if (PySequence_Fast_GET_SIZE(seq) != slicelength) { - PyErr_Format(PyExc_ValueError, - "attempt to assign sequence of size %d to extended slice of size %d", - PySequence_Fast_GET_SIZE(seq), - slicelength); - Py_DECREF(seq); - return -1; - } - - if (!slicelength) { - Py_DECREF(seq); - return 0; - } - - garbage = (PyObject**) - PyMem_MALLOC(slicelength*sizeof(PyObject*)); - - for (cur = start, i = 0; i < slicelength; - cur += step, i++) { - garbage[i] = PyList_GET_ITEM(self, cur); - - ins = PySequence_Fast_GET_ITEM(seq, i); - Py_INCREF(ins); - PyList_SET_ITEM(self, cur, ins); - } - - for (i = 0; i < slicelength; i++) { - Py_DECREF(garbage[i]); - } - - PyMem_FREE(garbage); - Py_DECREF(seq); - - return 0; - } - } - else { - PyErr_SetString(PyExc_TypeError, - "list indices must be integers"); - return -1; - } -} - -static PyMappingMethods list_as_mapping = { - (inquiry)list_length, - (binaryfunc)list_subscript, - (objobjargproc)list_ass_subscript -}; - -PyTypeObject PyList_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "list", - sizeof(PyListObject), - 0, - (destructor)list_dealloc, /* tp_dealloc */ - (printfunc)list_print, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)list_repr, /* tp_repr */ - 0, /* tp_as_number */ - &list_as_sequence, /* tp_as_sequence */ - &list_as_mapping, /* tp_as_mapping */ - list_nohash, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - list_doc, /* tp_doc */ - (traverseproc)list_traverse, /* tp_traverse */ - (inquiry)list_clear, /* tp_clear */ - list_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - list_iter, /* tp_iter */ - 0, /* tp_iternext */ - list_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)list_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - - -/*********************** List Iterator **************************/ - -typedef struct { - PyObject_HEAD - long it_index; - PyListObject *it_seq; /* Set to NULL when iterator is exhausted */ -} listiterobject; - -PyTypeObject PyListIter_Type; - -static PyObject * -list_iter(PyObject *seq) -{ - listiterobject *it; - - if (!PyList_Check(seq)) { - PyErr_BadInternalCall(); - return NULL; - } - it = PyObject_GC_New(listiterobject, &PyListIter_Type); - if (it == NULL) - return NULL; - it->it_index = 0; - Py_INCREF(seq); - it->it_seq = (PyListObject *)seq; - _PyObject_GC_TRACK(it); - return (PyObject *)it; -} - -static void -listiter_dealloc(listiterobject *it) -{ - _PyObject_GC_UNTRACK(it); - Py_XDECREF(it->it_seq); - PyObject_GC_Del(it); -} - -static int -listiter_traverse(listiterobject *it, visitproc visit, void *arg) -{ - if (it->it_seq == NULL) - return 0; - return visit((PyObject *)it->it_seq, arg); -} - -static PyObject * -listiter_next(listiterobject *it) -{ - PyListObject *seq; - PyObject *item; - - assert(it != NULL); - seq = it->it_seq; - if (seq == NULL) - return NULL; - assert(PyList_Check(seq)); - - if (it->it_index < PyList_GET_SIZE(seq)) { - item = PyList_GET_ITEM(seq, it->it_index); - ++it->it_index; - Py_INCREF(item); - return item; - } - - Py_DECREF(seq); - it->it_seq = NULL; - return NULL; -} - -PyTypeObject PyListIter_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "listiterator", /* tp_name */ - sizeof(listiterobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)listiter_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - 0, /* tp_doc */ - (traverseproc)listiter_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)listiter_next, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/listsort.txt b/SDKs/XPlatform/Cypython-2.3.3/Objects/listsort.txt deleted file mode 100644 index 3ccae1b5..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/listsort.txt +++ /dev/null @@ -1,667 +0,0 @@ -Intro ------ -This describes an adaptive, stable, natural mergesort, modestly called -timsort (hey, I earned it ). It has supernatural performance on many -kinds of partially ordered arrays (less than lg(N!) comparisons needed, and -as few as N-1), yet as fast as Python's previous highly tuned samplesort -hybrid on random arrays. - -In a nutshell, the main routine marches over the array once, left to right, -alternately identifying the next run, then merging it into the previous -runs "intelligently". Everything else is complication for speed, and some -hard-won measure of memory efficiency. - - -Comparison with Python's Samplesort Hybrid ------------------------------------------- -+ timsort can require a temp array containing as many as N//2 pointers, - which means as many as 2*N extra bytes on 32-bit boxes. It can be - expected to require a temp array this large when sorting random data; on - data with significant structure, it may get away without using any extra - heap memory. This appears to be the strongest argument against it, but - compared to the size of an object, 2 temp bytes worst-case (also expected- - case for random data) doesn't scare me much. - - It turns out that Perl is moving to a stable mergesort, and the code for - that appears always to require a temp array with room for at least N - pointers. (Note that I wouldn't want to do that even if space weren't an - issue; I believe its efforts at memory frugality also save timsort - significant pointer-copying costs, and allow it to have a smaller working - set.) - -+ Across about four hours of generating random arrays, and sorting them - under both methods, samplesort required about 1.5% more comparisons - (the program is at the end of this file). - -+ In real life, this may be faster or slower on random arrays than - samplesort was, depending on platform quirks. Since it does fewer - comparisons on average, it can be expected to do better the more - expensive a comparison function is. OTOH, it does more data movement - (pointer copying) than samplesort, and that may negate its small - comparison advantage (depending on platform quirks) unless comparison - is very expensive. - -+ On arrays with many kinds of pre-existing order, this blows samplesort out - of the water. It's significantly faster than samplesort even on some - cases samplesort was special-casing the snot out of. I believe that lists - very often do have exploitable partial order in real life, and this is the - strongest argument in favor of timsort (indeed, samplesort's special cases - for extreme partial order are appreciated by real users, and timsort goes - much deeper than those, in particular naturally covering every case where - someone has suggested "and it would be cool if list.sort() had a special - case for this too ... and for that ..."). - -+ Here are exact comparison counts across all the tests in sortperf.py, - when run with arguments "15 20 1". - - First the trivial cases, trivial for samplesort because it special-cased - them, and trivial for timsort because it naturally works on runs. Within - an "n" block, the first line gives the # of compares done by samplesort, - the second line by timsort, and the third line is the percentage by - which the samplesort count exceeds the timsort count: - - n \sort /sort =sort -------- ------ ------ ------ - 32768 32768 32767 32767 samplesort - 32767 32767 32767 timsort - 0.00% 0.00% 0.00% (samplesort - timsort) / timsort - - 65536 65536 65535 65535 - 65535 65535 65535 - 0.00% 0.00% 0.00% - - 131072 131072 131071 131071 - 131071 131071 131071 - 0.00% 0.00% 0.00% - - 262144 262144 262143 262143 - 262143 262143 262143 - 0.00% 0.00% 0.00% - - 524288 524288 524287 524287 - 524287 524287 524287 - 0.00% 0.00% 0.00% - -1048576 1048576 1048575 1048575 - 1048575 1048575 1048575 - 0.00% 0.00% 0.00% - - The algorithms are effectively identical in these cases, except that - timsort does one less compare in \sort. - - Now for the more interesting cases. lg(n!) is the information-theoretic - limit for the best any comparison-based sorting algorithm can do on - average (across all permutations). When a method gets significantly - below that, it's either astronomically lucky, or is finding exploitable - structure in the data. - - n lg(n!) *sort 3sort +sort %sort ~sort !sort -------- ------- ------ ------- ------- ------ ------- -------- - 32768 444255 453096 453614 32908 452871 130491 469141 old - 448885 33016 33007 50426 182083 65534 new - 0.94% 1273.92% -0.30% 798.09% -28.33% 615.87% %ch from new - - 65536 954037 972699 981940 65686 973104 260029 1004607 - 962991 65821 65808 101667 364341 131070 - 1.01% 1391.83% -0.19% 857.15% -28.63% 666.47% - - 131072 2039137 2101881 2091491 131232 2092894 554790 2161379 - 2057533 131410 131361 206193 728871 262142 - 2.16% 1491.58% -0.10% 915.02% -23.88% 724.51% - - 262144 4340409 4464460 4403233 262314 4445884 1107842 4584560 - 4377402 262437 262459 416347 1457945 524286 - 1.99% 1577.82% -0.06% 967.83% -24.01% 774.44% - - 524288 9205096 9453356 9408463 524468 9441930 2218577 9692015 - 9278734 524580 524633 837947 2916107 1048574 - 1.88% 1693.52% -0.03% 1026.79% -23.92% 824.30% - -1048576 19458756 19950272 19838588 1048766 19912134 4430649 20434212 - 19606028 1048958 1048941 1694896 5832445 2097150 - 1.76% 1791.27% -0.02% 1074.83% -24.03% 874.38% - - Discussion of cases: - - *sort: There's no structure in random data to exploit, so the theoretical - limit is lg(n!). Both methods get close to that, and timsort is hugging - it (indeed, in a *marginal* sense, it's a spectacular improvement -- - there's only about 1% left before hitting the wall, and timsort knows - darned well it's doing compares that won't pay on random data -- but so - does the samplesort hybrid). For contrast, Hoare's original random-pivot - quicksort does about 39% more compares than the limit, and the median-of-3 - variant about 19% more. - - 3sort, %sort, and !sort: No contest; there's structure in this data, but - not of the specific kinds samplesort special-cases. Note that structure - in !sort wasn't put there on purpose -- it was crafted as a worst case for - a previous quicksort implementation. That timsort nails it came as a - surprise to me (although it's obvious in retrospect). - - +sort: samplesort special-cases this data, and does a few less compares - than timsort. However, timsort runs this case significantly faster on all - boxes we have timings for, because timsort is in the business of merging - runs efficiently, while samplesort does much more data movement in this - (for it) special case. - - ~sort: samplesort's special cases for large masses of equal elements are - extremely effective on ~sort's specific data pattern, and timsort just - isn't going to get close to that, despite that it's clearly getting a - great deal of benefit out of the duplicates (the # of compares is much less - than lg(n!)). ~sort has a perfectly uniform distribution of just 4 - distinct values, and as the distribution gets more skewed, samplesort's - equal-element gimmicks become less effective, while timsort's adaptive - strategies find more to exploit; in a database supplied by Kevin Altis, a - sort on its highly skewed "on which stock exchange does this company's - stock trade?" field ran over twice as fast under timsort. - - However, despite that timsort does many more comparisons on ~sort, and - that on several platforms ~sort runs highly significantly slower under - timsort, on other platforms ~sort runs highly significantly faster under - timsort. No other kind of data has shown this wild x-platform behavior, - and we don't have an explanation for it. The only thing I can think of - that could transform what "should be" highly significant slowdowns into - highly significant speedups on some boxes are catastrophic cache effects - in samplesort. - - But timsort "should be" slower than samplesort on ~sort, so it's hard - to count that it isn't on some boxes as a strike against it . - -+ Here's the highwater mark for the number of heap-based temp slots (4 - bytes each on this box) needed by each test, again with arguments - "15 20 1": - - 2**i *sort \sort /sort 3sort +sort %sort ~sort =sort !sort - 32768 16384 0 0 6256 0 10821 12288 0 16383 - 65536 32766 0 0 21652 0 31276 24576 0 32767 - 131072 65534 0 0 17258 0 58112 49152 0 65535 - 262144 131072 0 0 35660 0 123561 98304 0 131071 - 524288 262142 0 0 31302 0 212057 196608 0 262143 -1048576 524286 0 0 312438 0 484942 393216 0 524287 - - Discussion: The tests that end up doing (close to) perfectly balanced - merges (*sort, !sort) need all N//2 temp slots (or almost all). ~sort - also ends up doing balanced merges, but systematically benefits a lot from - the preliminary pre-merge searches described under "Merge Memory" later. - %sort approaches having a balanced merge at the end because the random - selection of elements to replace is expected to produce an out-of-order - element near the midpoint. \sort, /sort, =sort are the trivial one-run - cases, needing no merging at all. +sort ends up having one very long run - and one very short, and so gets all the temp space it needs from the small - temparray member of the MergeState struct (note that the same would be - true if the new random elements were prefixed to the sorted list instead, - but not if they appeared "in the middle"). 3sort approaches N//3 temp - slots twice, but the run lengths that remain after 3 random exchanges - clearly has very high variance. - - -A detailed description of timsort follows. - -Runs ----- -count_run() returns the # of elements in the next run. A run is either -"ascending", which means non-decreasing: - - a0 <= a1 <= a2 <= ... - -or "descending", which means strictly decreasing: - - a0 > a1 > a2 > ... - -Note that a run is always at least 2 long, unless we start at the array's -last element. - -The definition of descending is strict, because the main routine reverses -a descending run in-place, transforming a descending run into an ascending -run. Reversal is done via the obvious fast "swap elements starting at each -end, and converge at the middle" method, and that can violate stability if -the slice contains any equal elements. Using a strict definition of -descending ensures that a descending run contains distinct elements. - -If an array is random, it's very unlikely we'll see long runs. If a natural -run contains less than minrun elements (see next section), the main loop -artificially boosts it to minrun elements, via a stable binary insertion sort -applied to the right number of array elements following the short natural -run. In a random array, *all* runs are likely to be minrun long as a -result. This has two primary good effects: - -1. Random data strongly tends then toward perfectly balanced (both runs have - the same length) merges, which is the most efficient way to proceed when - data is random. - -2. Because runs are never very short, the rest of the code doesn't make - heroic efforts to shave a few cycles off per-merge overheads. For - example, reasonable use of function calls is made, rather than trying to - inline everything. Since there are no more than N/minrun runs to begin - with, a few "extra" function calls per merge is barely measurable. - - -Computing minrun ----------------- -If N < 64, minrun is N. IOW, binary insertion sort is used for the whole -array then; it's hard to beat that given the overheads of trying something -fancier. - -When N is a power of 2, testing on random data showed that minrun values of -16, 32, 64 and 128 worked about equally well. At 256 the data-movement cost -in binary insertion sort clearly hurt, and at 8 the increase in the number -of function calls clearly hurt. Picking *some* power of 2 is important -here, so that the merges end up perfectly balanced (see next section). We -pick 32 as a good value in the sweet range; picking a value at the low end -allows the adaptive gimmicks more opportunity to exploit shorter natural -runs. - -Because sortperf.py only tries powers of 2, it took a long time to notice -that 32 isn't a good choice for the general case! Consider N=2112: - ->>> divmod(2112, 32) -(66, 0) ->>> - -If the data is randomly ordered, we're very likely to end up with 66 runs -each of length 32. The first 64 of these trigger a sequence of perfectly -balanced merges (see next section), leaving runs of lengths 2048 and 64 to -merge at the end. The adaptive gimmicks can do that with fewer than 2048+64 -compares, but it's still more compares than necessary, and-- mergesort's -bugaboo relative to samplesort --a lot more data movement (O(N) copies just -to get 64 elements into place). - -If we take minrun=33 in this case, then we're very likely to end up with 64 -runs each of length 33, and then all merges are perfectly balanced. Better! - -What we want to avoid is picking minrun such that in - - q, r = divmod(N, minrun) - -q is a power of 2 and r>0 (then the last merge only gets r elements into -place, and r < minrun is small compared to N), or q a little larger than a -power of 2 regardless of r (then we've got a case similar to "2112", again -leaving too little work for the last merge to do). - -Instead we pick a minrun in range(32, 65) such that N/minrun is exactly a -power of 2, or if that isn't possible, is close to, but strictly less than, -a power of 2. This is easier to do than it may sound: take the first 6 -bits of N, and add 1 if any of the remaining bits are set. In fact, that -rule covers every case in this section, including small N and exact powers -of 2; merge_compute_minrun() is a deceptively simple function. - - -The Merge Pattern ------------------ -In order to exploit regularities in the data, we're merging on natural -run lengths, and they can become wildly unbalanced. That's a Good Thing -for this sort! It means we have to find a way to manage an assortment of -potentially very different run lengths, though. - -Stability constrains permissible merging patterns. For example, if we have -3 consecutive runs of lengths - - A:10000 B:20000 C:10000 - -we dare not merge A with C first, because if A, B and C happen to contain -a common element, it would get out of order wrt its occurence(s) in B. The -merging must be done as (A+B)+C or A+(B+C) instead. - -So merging is always done on two consecutive runs at a time, and in-place, -although this may require some temp memory (more on that later). - -When a run is identified, its base address and length are pushed on a stack -in the MergeState struct. merge_collapse() is then called to see whether it -should merge it with preceding run(s). We would like to delay merging as -long as possible in order to exploit patterns that may come up later, but we -like even more to do merging as soon as possible to exploit that the run just -found is still high in the memory hierarchy. We also can't delay merging -"too long" because it consumes memory to remember the runs that are still -unmerged, and the stack has a fixed size. - -What turned out to be a good compromise maintains two invariants on the -stack entries, where A, B and C are the lengths of the three righmost not-yet -merged slices: - -1. A > B+C -2. B > C - -Note that, by induction, #2 implies the lengths of pending runs form a -decreasing sequence. #1 implies that, reading the lengths right to left, -the pending-run lengths grow at least as fast as the Fibonacci numbers. -Therefore the stack can never grow larger than about log_base_phi(N) entries, -where phi = (1+sqrt(5))/2 ~= 1.618. Thus a small # of stack slots suffice -for very large arrays. - -If A <= B+C, the smaller of A and C is merged with B (ties favor C, for the -freshness-in-cache reason), and the new run replaces the A,B or B,C entries; -e.g., if the last 3 entries are - - A:30 B:20 C:10 - -then B is merged with C, leaving - - A:30 BC:30 - -on the stack. Or if they were - - A:500 B:400: C:1000 - -then A is merged with B, leaving - - AB:900 C:1000 - -on the stack. - -In both examples, the stack configuration after the merge still violates -invariant #2, and merge_collapse() goes on to continue merging runs until -both invariants are satisfied. As an extreme case, suppose we didn't do the -minrun gimmick, and natural runs were of lengths 128, 64, 32, 16, 8, 4, 2, -and 2. Nothing would get merged until the final 2 was seen, and that would -trigger 7 perfectly balanced merges. - -The thrust of these rules when they trigger merging is to balance the run -lengths as closely as possible, while keeping a low bound on the number of -runs we have to remember. This is maximally effective for random data, -where all runs are likely to be of (artificially forced) length minrun, and -then we get a sequence of perfectly balanced merges (with, perhaps, some -oddballs at the end). - -OTOH, one reason this sort is so good for partly ordered data has to do -with wildly unbalanced run lengths. - - -Merge Memory ------------- -Merging adjacent runs of lengths A and B in-place is very difficult. -Theoretical constructions are known that can do it, but they're too difficult -and slow for practical use. But if we have temp memory equal to min(A, B), -it's easy. - -If A is smaller (function merge_lo), copy A to a temp array, leave B alone, -and then we can do the obvious merge algorithm left to right, from the temp -area and B, starting the stores into where A used to live. There's always a -free area in the original area comprising a number of elements equal to the -number not yet merged from the temp array (trivially true at the start; -proceed by induction). The only tricky bit is that if a comparison raises an -exception, we have to remember to copy the remaining elements back in from -the temp area, lest the array end up with duplicate entries from B. But -that's exactly the same thing we need to do if we reach the end of B first, -so the exit code is pleasantly common to both the normal and error cases. - -If B is smaller (function merge_hi, which is merge_lo's "mirror image"), -much the same, except that we need to merge right to left, copying B into a -temp array and starting the stores at the right end of where B used to live. - -A refinement: When we're about to merge adjacent runs A and B, we first do -a form of binary search (more on that later) to see where B[0] should end up -in A. Elements in A preceding that point are already in their final -positions, effectively shrinking the size of A. Likewise we also search to -see where A[-1] should end up in B, and elements of B after that point can -also be ignored. This cuts the amount of temp memory needed by the same -amount. - -These preliminary searches may not pay off, and can be expected *not* to -repay their cost if the data is random. But they can win huge in all of -time, copying, and memory savings when they do pay, so this is one of the -"per-merge overheads" mentioned above that we're happy to endure because -there is at most one very short run. It's generally true in this algorithm -that we're willing to gamble a little to win a lot, even though the net -expectation is negative for random data. - - -Merge Algorithms ----------------- -merge_lo() and merge_hi() are where the bulk of the time is spent. merge_lo -deals with runs where A <= B, and merge_hi where A > B. They don't know -whether the data is clustered or uniform, but a lovely thing about merging -is that many kinds of clustering "reveal themselves" by how many times in a -row the winning merge element comes from the same run. We'll only discuss -merge_lo here; merge_hi is exactly analogous. - -Merging begins in the usual, obvious way, comparing the first element of A -to the first of B, and moving B[0] to the merge area if it's less than A[0], -else moving A[0] to the merge area. Call that the "one pair at a time" -mode. The only twist here is keeping track of how many times in a row "the -winner" comes from the same run. - -If that count reaches MIN_GALLOP, we switch to "galloping mode". Here -we *search* B for where A[0] belongs, and move over all the B's before -that point in one chunk to the merge area, then move A[0] to the merge -area. Then we search A for where B[0] belongs, and similarly move a -slice of A in one chunk. Then back to searching B for where A[0] belongs, -etc. We stay in galloping mode until both searches find slices to copy -less than MIN_GALLOP elements long, at which point we go back to one-pair- -at-a-time mode. - -A refinement: The MergeState struct contains the value of min_gallop that -controls when we enter galloping mode, initialized to MIN_GALLOP. -merge_lo() and merge_hi() adjust this higher when galloping isn't paying -off, and lower when it is. - - -Galloping ---------- -Still without loss of generality, assume A is the shorter run. In galloping -mode, we first look for A[0] in B. We do this via "galloping", comparing -A[0] in turn to B[0], B[1], B[3], B[7], ..., B[2**j - 1], ..., until finding -the k such that B[2**(k-1) - 1] < A[0] <= B[2**k - 1]. This takes at most -roughly lg(B) comparisons, and, unlike a straight binary search, favors -finding the right spot early in B (more on that later). - -After finding such a k, the region of uncertainty is reduced to 2**(k-1) - 1 -consecutive elements, and a straight binary search requires exactly k-1 -additional comparisons to nail it. Then we copy all the B's up to that -point in one chunk, and then copy A[0]. Note that no matter where A[0] -belongs in B, the combination of galloping + binary search finds it in no -more than about 2*lg(B) comparisons. - -If we did a straight binary search, we could find it in no more than -ceiling(lg(B+1)) comparisons -- but straight binary search takes that many -comparisons no matter where A[0] belongs. Straight binary search thus loses -to galloping unless the run is quite long, and we simply can't guess -whether it is in advance. - -If data is random and runs have the same length, A[0] belongs at B[0] half -the time, at B[1] a quarter of the time, and so on: a consecutive winning -sub-run in B of length k occurs with probability 1/2**(k+1). So long -winning sub-runs are extremely unlikely in random data, and guessing that a -winning sub-run is going to be long is a dangerous game. - -OTOH, if data is lopsided or lumpy or contains many duplicates, long -stretches of winning sub-runs are very likely, and cutting the number of -comparisons needed to find one from O(B) to O(log B) is a huge win. - -Galloping compromises by getting out fast if there isn't a long winning -sub-run, yet finding such very efficiently when they exist. - -I first learned about the galloping strategy in a related context; see: - - "Adaptive Set Intersections, Unions, and Differences" (2000) - Erik D. Demaine, Alejandro López-Ortiz, J. Ian Munro - -and its followup(s). An earlier paper called the same strategy -"exponential search": - - "Optimistic Sorting and Information Theoretic Complexity" - Peter McIlroy - SODA (Fourth Annual ACM-SIAM Symposium on Discrete Algorithms), pp - 467-474, Austin, Texas, 25-27 January 1993. - -and it probably dates back to an earlier paper by Bentley and Yao. The -McIlory paper in particular has good analysis of a mergesort that's -probably strongly related to this one in its galloping strategy. - - -Galloping with a Broken Leg ---------------------------- -So why don't we always gallop? Because it can lose, on two counts: - -1. While we're willing to endure small per-merge overheads, per-comparison - overheads are a different story. Calling Yet Another Function per - comparison is expensive, and gallop_left() and gallop_right() are - too long-winded for sane inlining. - -2. Galloping can-- alas --require more comparisons than linear one-at-time - search, depending on the data. - -#2 requires details. If A[0] belongs before B[0], galloping requires 1 -compare to determine that, same as linear search, except it costs more -to call the gallop function. If A[0] belongs right before B[1], galloping -requires 2 compares, again same as linear search. On the third compare, -galloping checks A[0] against B[3], and if it's <=, requires one more -compare to determine whether A[0] belongs at B[2] or B[3]. That's a total -of 4 compares, but if A[0] does belong at B[2], linear search would have -discovered that in only 3 compares, and that's a huge loss! Really. It's -an increase of 33% in the number of compares needed, and comparisons are -expensive in Python. - -index in B where # compares linear # gallop # binary gallop -A[0] belongs search needs compares compares total ----------------- ----------------- -------- -------- ------ - 0 1 1 0 1 - - 1 2 2 0 2 - - 2 3 3 1 4 - 3 4 3 1 4 - - 4 5 4 2 6 - 5 6 4 2 6 - 6 7 4 2 6 - 7 8 4 2 6 - - 8 9 5 3 8 - 9 10 5 3 8 - 10 11 5 3 8 - 11 12 5 3 8 - ... - -In general, if A[0] belongs at B[i], linear search requires i+1 comparisons -to determine that, and galloping a total of 2*floor(lg(i))+2 comparisons. -The advantage of galloping is unbounded as i grows, but it doesn't win at -all until i=6. Before then, it loses twice (at i=2 and i=4), and ties -at the other values. At and after i=6, galloping always wins. - -We can't guess in advance when it's going to win, though, so we do one pair -at a time until the evidence seems strong that galloping may pay. MIN_GALLOP -is 7, and that's pretty strong evidence. However, if the data is random, it -simply will trigger galloping mode purely by luck every now and again, and -it's quite likely to hit one of the losing cases next. On the other hand, -in cases like ~sort, galloping always pays, and MIN_GALLOP is larger than it -"should be" then. So the MergeState struct keeps a min_gallop variable -that merge_lo and merge_hi adjust: the longer we stay in galloping mode, -the smaller min_gallop gets, making it easier to transition back to -galloping mode (if we ever leave it in the current merge, and at the -start of the next merge). But whenever the gallop loop doesn't pay, -min_gallop is increased by one, making it harder to transition back -to galloping mode (and again both within a merge and across merges). For -random data, this all but eliminates the gallop penalty: min_gallop grows -large enough that we almost never get into galloping mode. And for cases -like ~sort, min_gallop can fall to as low as 1. This seems to work well, -but in all it's a minor improvement over using a fixed MIN_GALLOP value. - - -Galloping Complication ----------------------- -The description above was for merge_lo. merge_hi has to merge "from the -other end", and really needs to gallop starting at the last element in a run -instead of the first. Galloping from the first still works, but does more -comparisons than it should (this is significant -- I timed it both ways). -For this reason, the gallop_left() and gallop_right() functions have a -"hint" argument, which is the index at which galloping should begin. So -galloping can actually start at any index, and proceed at offsets of 1, 3, -7, 15, ... or -1, -3, -7, -15, ... from the starting index. - -In the code as I type it's always called with either 0 or n-1 (where n is -the # of elements in a run). It's tempting to try to do something fancier, -melding galloping with some form of interpolation search; for example, if -we're merging a run of length 1 with a run of length 10000, index 5000 is -probably a better guess at the final result than either 0 or 9999. But -it's unclear how to generalize that intuition usefully, and merging of -wildly unbalanced runs already enjoys excellent performance. - -~sort is a good example of when balanced runs could benefit from a better -hint value: to the extent possible, this would like to use a starting -offset equal to the previous value of acount/bcount. Doing so saves about -10% of the compares in ~sort. However, doing so is also a mixed bag, -hurting other cases. - - -Comparing Average # of Compares on Random Arrays ------------------------------------------------- -[NOTE: This was done when the new algorithm used about 0.1% more compares - on random data than does its current incarnation.] - -Here list.sort() is samplesort, and list.msort() this sort: - -""" -import random -from time import clock as now - -def fill(n): - from random import random - return [random() for i in xrange(n)] - -def mycmp(x, y): - global ncmp - ncmp += 1 - return cmp(x, y) - -def timeit(values, method): - global ncmp - X = values[:] - bound = getattr(X, method) - ncmp = 0 - t1 = now() - bound(mycmp) - t2 = now() - return t2-t1, ncmp - -format = "%5s %9.2f %11d" -f2 = "%5s %9.2f %11.2f" - -def drive(): - count = sst = sscmp = mst = mscmp = nelts = 0 - while True: - n = random.randrange(100000) - nelts += n - x = fill(n) - - t, c = timeit(x, 'sort') - sst += t - sscmp += c - - t, c = timeit(x, 'msort') - mst += t - mscmp += c - - count += 1 - if count % 10: - continue - - print "count", count, "nelts", nelts - print format % ("sort", sst, sscmp) - print format % ("msort", mst, mscmp) - print f2 % ("", (sst-mst)*1e2/mst, (sscmp-mscmp)*1e2/mscmp) - -drive() -""" - -I ran this on Windows and kept using the computer lightly while it was -running. time.clock() is wall-clock time on Windows, with better than -microsecond resolution. samplesort started with a 1.52% #-of-comparisons -disadvantage, fell quickly to 1.48%, and then fluctuated within that small -range. Here's the last chunk of output before I killed the job: - -count 2630 nelts 130906543 - sort 6110.80 1937887573 -msort 6002.78 1909389381 - 1.80 1.49 - -We've done nearly 2 billion comparisons apiece at Python speed there, and -that's enough . - -For random arrays of size 2 (yes, there are only 2 interesting ones), -samplesort has a 50%(!) comparison disadvantage. This is a consequence of -samplesort special-casing at most one ascending run at the start, then -falling back to the general case if it doesn't find an ascending run -immediately. The consequence is that it ends up using two compares to sort -[2, 1]. Gratifyingly, timsort doesn't do any special-casing, so had to be -taught how to deal with mixtures of ascending and descending runs -efficiently in all cases. diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/longobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/longobject.c deleted file mode 100644 index 9c8fa9dc..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/longobject.c +++ /dev/null @@ -1,2912 +0,0 @@ - -/* Long (arbitrary precision) integer object implementation */ - -/* XXX The functional organization of this file is terrible */ - -#include "Python.h" -#include "longintrepr.h" - -#include - -/* For long multiplication, use the O(N**2) school algorithm unless - * both operands contain more than KARATSUBA_CUTOFF digits (this - * being an internal Python long digit, in base BASE). - */ -#define KARATSUBA_CUTOFF 35 - -#define ABS(x) ((x) < 0 ? -(x) : (x)) - -#undef MIN -#undef MAX -#define MAX(x, y) ((x) < (y) ? (y) : (x)) -#define MIN(x, y) ((x) > (y) ? (y) : (x)) - -/* Forward */ -static PyLongObject *long_normalize(PyLongObject *); -static PyLongObject *mul1(PyLongObject *, wdigit); -static PyLongObject *muladd1(PyLongObject *, wdigit, wdigit); -static PyLongObject *divrem1(PyLongObject *, digit, digit *); -static PyObject *long_format(PyObject *aa, int base, int addL); - -#define SIGCHECK(PyTryBlock) \ - if (--_Py_Ticker < 0) { \ - _Py_Ticker = _Py_CheckInterval; \ - if (PyErr_CheckSignals()) { PyTryBlock; } \ - } - -/* Normalize (remove leading zeros from) a long int object. - Doesn't attempt to free the storage--in most cases, due to the nature - of the algorithms used, this could save at most be one word anyway. */ - -static PyLongObject * -long_normalize(register PyLongObject *v) -{ - int j = ABS(v->ob_size); - register int i = j; - - while (i > 0 && v->ob_digit[i-1] == 0) - --i; - if (i != j) - v->ob_size = (v->ob_size < 0) ? -(i) : i; - return v; -} - -/* Allocate a new long int object with size digits. - Return NULL and set exception if we run out of memory. */ - -PyLongObject * -_PyLong_New(int size) -{ - return PyObject_NEW_VAR(PyLongObject, &PyLong_Type, size); -} - -PyObject * -_PyLong_Copy(PyLongObject *src) -{ - PyLongObject *result; - int i; - - assert(src != NULL); - i = src->ob_size; - if (i < 0) - i = -(i); - result = _PyLong_New(i); - if (result != NULL) { - result->ob_size = src->ob_size; - while (--i >= 0) - result->ob_digit[i] = src->ob_digit[i]; - } - return (PyObject *)result; -} - -/* Create a new long int object from a C long int */ - -PyObject * -PyLong_FromLong(long ival) -{ - PyLongObject *v; - unsigned long t; /* unsigned so >> doesn't propagate sign bit */ - int ndigits = 0; - int negative = 0; - - if (ival < 0) { - ival = -ival; - negative = 1; - } - - /* Count the number of Python digits. - We used to pick 5 ("big enough for anything"), but that's a - waste of time and space given that 5*15 = 75 bits are rarely - needed. */ - t = (unsigned long)ival; - while (t) { - ++ndigits; - t >>= SHIFT; - } - v = _PyLong_New(ndigits); - if (v != NULL) { - digit *p = v->ob_digit; - v->ob_size = negative ? -ndigits : ndigits; - t = (unsigned long)ival; - while (t) { - *p++ = (digit)(t & MASK); - t >>= SHIFT; - } - } - return (PyObject *)v; -} - -/* Create a new long int object from a C unsigned long int */ - -PyObject * -PyLong_FromUnsignedLong(unsigned long ival) -{ - PyLongObject *v; - unsigned long t; - int ndigits = 0; - - /* Count the number of Python digits. */ - t = (unsigned long)ival; - while (t) { - ++ndigits; - t >>= SHIFT; - } - v = _PyLong_New(ndigits); - if (v != NULL) { - digit *p = v->ob_digit; - v->ob_size = ndigits; - while (ival) { - *p++ = (digit)(ival & MASK); - ival >>= SHIFT; - } - } - return (PyObject *)v; -} - -/* Create a new long int object from a C double */ - -PyObject * -PyLong_FromDouble(double dval) -{ - PyLongObject *v; - double frac; - int i, ndig, expo, neg; - neg = 0; - if (Py_IS_INFINITY(dval)) { - PyErr_SetString(PyExc_OverflowError, - "cannot convert float infinity to long"); - return NULL; - } - if (dval < 0.0) { - neg = 1; - dval = -dval; - } - frac = frexp(dval, &expo); /* dval = frac*2**expo; 0.0 <= frac < 1.0 */ - if (expo <= 0) - return PyLong_FromLong(0L); - ndig = (expo-1) / SHIFT + 1; /* Number of 'digits' in result */ - v = _PyLong_New(ndig); - if (v == NULL) - return NULL; - frac = ldexp(frac, (expo-1) % SHIFT + 1); - for (i = ndig; --i >= 0; ) { - long bits = (long)frac; - v->ob_digit[i] = (digit) bits; - frac = frac - (double)bits; - frac = ldexp(frac, SHIFT); - } - if (neg) - v->ob_size = -(v->ob_size); - return (PyObject *)v; -} - -/* Get a C long int from a long int object. - Returns -1 and sets an error condition if overflow occurs. */ - -long -PyLong_AsLong(PyObject *vv) -{ - /* This version by Tim Peters */ - register PyLongObject *v; - unsigned long x, prev; - int i, sign; - - if (vv == NULL || !PyLong_Check(vv)) { - if (vv != NULL && PyInt_Check(vv)) - return PyInt_AsLong(vv); - PyErr_BadInternalCall(); - return -1; - } - v = (PyLongObject *)vv; - i = v->ob_size; - sign = 1; - x = 0; - if (i < 0) { - sign = -1; - i = -(i); - } - while (--i >= 0) { - prev = x; - x = (x << SHIFT) + v->ob_digit[i]; - if ((x >> SHIFT) != prev) - goto overflow; - } - /* Haven't lost any bits, but if the sign bit is set we're in - * trouble *unless* this is the min negative number. So, - * trouble iff sign bit set && (positive || some bit set other - * than the sign bit). - */ - if ((long)x < 0 && (sign > 0 || (x << 1) != 0)) - goto overflow; - return (long)x * sign; - - overflow: - PyErr_SetString(PyExc_OverflowError, - "long int too large to convert to int"); - return -1; -} - -/* Get a C unsigned long int from a long int object. - Returns -1 and sets an error condition if overflow occurs. */ - -unsigned long -PyLong_AsUnsignedLong(PyObject *vv) -{ - register PyLongObject *v; - unsigned long x, prev; - int i; - - if (vv == NULL || !PyLong_Check(vv)) { - PyErr_BadInternalCall(); - return (unsigned long) -1; - } - v = (PyLongObject *)vv; - i = v->ob_size; - x = 0; - if (i < 0) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned long"); - return (unsigned long) -1; - } - while (--i >= 0) { - prev = x; - x = (x << SHIFT) + v->ob_digit[i]; - if ((x >> SHIFT) != prev) { - PyErr_SetString(PyExc_OverflowError, - "long int too large to convert"); - return (unsigned long) -1; - } - } - return x; -} - -/* Get a C unsigned long int from a long int object, ignoring the high bits. - Returns -1 and sets an error condition if an error occurs. */ - -unsigned long -PyLong_AsUnsignedLongMask(PyObject *vv) -{ - register PyLongObject *v; - unsigned long x; - int i, sign; - - if (vv == NULL || !PyLong_Check(vv)) { - PyErr_BadInternalCall(); - return (unsigned long) -1; - } - v = (PyLongObject *)vv; - i = v->ob_size; - sign = 1; - x = 0; - if (i < 0) { - sign = -1; - i = -i; - } - while (--i >= 0) { - x = (x << SHIFT) + v->ob_digit[i]; - } - return x * sign; -} - -int -_PyLong_Sign(PyObject *vv) -{ - PyLongObject *v = (PyLongObject *)vv; - - assert(v != NULL); - assert(PyLong_Check(v)); - - return v->ob_size == 0 ? 0 : (v->ob_size < 0 ? -1 : 1); -} - -size_t -_PyLong_NumBits(PyObject *vv) -{ - PyLongObject *v = (PyLongObject *)vv; - size_t result = 0; - int ndigits; - - assert(v != NULL); - assert(PyLong_Check(v)); - ndigits = ABS(v->ob_size); - assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0); - if (ndigits > 0) { - digit msd = v->ob_digit[ndigits - 1]; - - result = (ndigits - 1) * SHIFT; - if (result / SHIFT != (size_t)ndigits - 1) - goto Overflow; - do { - ++result; - if (result == 0) - goto Overflow; - msd >>= 1; - } while (msd); - } - return result; - -Overflow: - PyErr_SetString(PyExc_OverflowError, "long has too many bits " - "to express in a platform size_t"); - return (size_t)-1; -} - -PyObject * -_PyLong_FromByteArray(const unsigned char* bytes, size_t n, - int little_endian, int is_signed) -{ - const unsigned char* pstartbyte;/* LSB of bytes */ - int incr; /* direction to move pstartbyte */ - const unsigned char* pendbyte; /* MSB of bytes */ - size_t numsignificantbytes; /* number of bytes that matter */ - size_t ndigits; /* number of Python long digits */ - PyLongObject* v; /* result */ - int idigit = 0; /* next free index in v->ob_digit */ - - if (n == 0) - return PyLong_FromLong(0L); - - if (little_endian) { - pstartbyte = bytes; - pendbyte = bytes + n - 1; - incr = 1; - } - else { - pstartbyte = bytes + n - 1; - pendbyte = bytes; - incr = -1; - } - - if (is_signed) - is_signed = *pendbyte >= 0x80; - - /* Compute numsignificantbytes. This consists of finding the most - significant byte. Leading 0 bytes are insignficant if the number - is positive, and leading 0xff bytes if negative. */ - { - size_t i; - const unsigned char* p = pendbyte; - const int pincr = -incr; /* search MSB to LSB */ - const unsigned char insignficant = is_signed ? 0xff : 0x00; - - for (i = 0; i < n; ++i, p += pincr) { - if (*p != insignficant) - break; - } - numsignificantbytes = n - i; - /* 2's-comp is a bit tricky here, e.g. 0xff00 == -0x0100, so - actually has 2 significant bytes. OTOH, 0xff0001 == - -0x00ffff, so we wouldn't *need* to bump it there; but we - do for 0xffff = -0x0001. To be safe without bothering to - check every case, bump it regardless. */ - if (is_signed && numsignificantbytes < n) - ++numsignificantbytes; - } - - /* How many Python long digits do we need? We have - 8*numsignificantbytes bits, and each Python long digit has SHIFT - bits, so it's the ceiling of the quotient. */ - ndigits = (numsignificantbytes * 8 + SHIFT - 1) / SHIFT; - if (ndigits > (size_t)INT_MAX) - return PyErr_NoMemory(); - v = _PyLong_New((int)ndigits); - if (v == NULL) - return NULL; - - /* Copy the bits over. The tricky parts are computing 2's-comp on - the fly for signed numbers, and dealing with the mismatch between - 8-bit bytes and (probably) 15-bit Python digits.*/ - { - size_t i; - twodigits carry = 1; /* for 2's-comp calculation */ - twodigits accum = 0; /* sliding register */ - unsigned int accumbits = 0; /* number of bits in accum */ - const unsigned char* p = pstartbyte; - - for (i = 0; i < numsignificantbytes; ++i, p += incr) { - twodigits thisbyte = *p; - /* Compute correction for 2's comp, if needed. */ - if (is_signed) { - thisbyte = (0xff ^ thisbyte) + carry; - carry = thisbyte >> 8; - thisbyte &= 0xff; - } - /* Because we're going LSB to MSB, thisbyte is - more significant than what's already in accum, - so needs to be prepended to accum. */ - accum |= thisbyte << accumbits; - accumbits += 8; - if (accumbits >= SHIFT) { - /* There's enough to fill a Python digit. */ - assert(idigit < (int)ndigits); - v->ob_digit[idigit] = (digit)(accum & MASK); - ++idigit; - accum >>= SHIFT; - accumbits -= SHIFT; - assert(accumbits < SHIFT); - } - } - assert(accumbits < SHIFT); - if (accumbits) { - assert(idigit < (int)ndigits); - v->ob_digit[idigit] = (digit)accum; - ++idigit; - } - } - - v->ob_size = is_signed ? -idigit : idigit; - return (PyObject *)long_normalize(v); -} - -int -_PyLong_AsByteArray(PyLongObject* v, - unsigned char* bytes, size_t n, - int little_endian, int is_signed) -{ - int i; /* index into v->ob_digit */ - int ndigits; /* |v->ob_size| */ - twodigits accum; /* sliding register */ - unsigned int accumbits; /* # bits in accum */ - int do_twos_comp; /* store 2's-comp? is_signed and v < 0 */ - twodigits carry; /* for computing 2's-comp */ - size_t j; /* # bytes filled */ - unsigned char* p; /* pointer to next byte in bytes */ - int pincr; /* direction to move p */ - - assert(v != NULL && PyLong_Check(v)); - - if (v->ob_size < 0) { - ndigits = -(v->ob_size); - if (!is_signed) { - PyErr_SetString(PyExc_TypeError, - "can't convert negative long to unsigned"); - return -1; - } - do_twos_comp = 1; - } - else { - ndigits = v->ob_size; - do_twos_comp = 0; - } - - if (little_endian) { - p = bytes; - pincr = 1; - } - else { - p = bytes + n - 1; - pincr = -1; - } - - /* Copy over all the Python digits. - It's crucial that every Python digit except for the MSD contribute - exactly SHIFT bits to the total, so first assert that the long is - normalized. */ - assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0); - j = 0; - accum = 0; - accumbits = 0; - carry = do_twos_comp ? 1 : 0; - for (i = 0; i < ndigits; ++i) { - twodigits thisdigit = v->ob_digit[i]; - if (do_twos_comp) { - thisdigit = (thisdigit ^ MASK) + carry; - carry = thisdigit >> SHIFT; - thisdigit &= MASK; - } - /* Because we're going LSB to MSB, thisdigit is more - significant than what's already in accum, so needs to be - prepended to accum. */ - accum |= thisdigit << accumbits; - accumbits += SHIFT; - - /* The most-significant digit may be (probably is) at least - partly empty. */ - if (i == ndigits - 1) { - /* Count # of sign bits -- they needn't be stored, - * although for signed conversion we need later to - * make sure at least one sign bit gets stored. - * First shift conceptual sign bit to real sign bit. - */ - stwodigits s = (stwodigits)(thisdigit << - (8*sizeof(stwodigits) - SHIFT)); - unsigned int nsignbits = 0; - while ((s < 0) == do_twos_comp && nsignbits < SHIFT) { - ++nsignbits; - s <<= 1; - } - accumbits -= nsignbits; - } - - /* Store as many bytes as possible. */ - while (accumbits >= 8) { - if (j >= n) - goto Overflow; - ++j; - *p = (unsigned char)(accum & 0xff); - p += pincr; - accumbits -= 8; - accum >>= 8; - } - } - - /* Store the straggler (if any). */ - assert(accumbits < 8); - assert(carry == 0); /* else do_twos_comp and *every* digit was 0 */ - if (accumbits > 0) { - if (j >= n) - goto Overflow; - ++j; - if (do_twos_comp) { - /* Fill leading bits of the byte with sign bits - (appropriately pretending that the long had an - infinite supply of sign bits). */ - accum |= (~(twodigits)0) << accumbits; - } - *p = (unsigned char)(accum & 0xff); - p += pincr; - } - else if (j == n && n > 0 && is_signed) { - /* The main loop filled the byte array exactly, so the code - just above didn't get to ensure there's a sign bit, and the - loop below wouldn't add one either. Make sure a sign bit - exists. */ - unsigned char msb = *(p - pincr); - int sign_bit_set = msb >= 0x80; - assert(accumbits == 0); - if (sign_bit_set == do_twos_comp) - return 0; - else - goto Overflow; - } - - /* Fill remaining bytes with copies of the sign bit. */ - { - unsigned char signbyte = do_twos_comp ? 0xffU : 0U; - for ( ; j < n; ++j, p += pincr) - *p = signbyte; - } - - return 0; - -Overflow: - PyErr_SetString(PyExc_OverflowError, "long too big to convert"); - return -1; - -} - -double -_PyLong_AsScaledDouble(PyObject *vv, int *exponent) -{ -/* NBITS_WANTED should be > the number of bits in a double's precision, - but small enough so that 2**NBITS_WANTED is within the normal double - range. nbitsneeded is set to 1 less than that because the most-significant - Python digit contains at least 1 significant bit, but we don't want to - bother counting them (catering to the worst case cheaply). - - 57 is one more than VAX-D double precision; I (Tim) don't know of a double - format with more precision than that; it's 1 larger so that we add in at - least one round bit to stand in for the ignored least-significant bits. -*/ -#define NBITS_WANTED 57 - PyLongObject *v; - double x; - const double multiplier = (double)(1L << SHIFT); - int i, sign; - int nbitsneeded; - - if (vv == NULL || !PyLong_Check(vv)) { - PyErr_BadInternalCall(); - return -1; - } - v = (PyLongObject *)vv; - i = v->ob_size; - sign = 1; - if (i < 0) { - sign = -1; - i = -(i); - } - else if (i == 0) { - *exponent = 0; - return 0.0; - } - --i; - x = (double)v->ob_digit[i]; - nbitsneeded = NBITS_WANTED - 1; - /* Invariant: i Python digits remain unaccounted for. */ - while (i > 0 && nbitsneeded > 0) { - --i; - x = x * multiplier + (double)v->ob_digit[i]; - nbitsneeded -= SHIFT; - } - /* There are i digits we didn't shift in. Pretending they're all - zeroes, the true value is x * 2**(i*SHIFT). */ - *exponent = i; - assert(x > 0.0); - return x * sign; -#undef NBITS_WANTED -} - -/* Get a C double from a long int object. */ - -double -PyLong_AsDouble(PyObject *vv) -{ - int e; - double x; - - if (vv == NULL || !PyLong_Check(vv)) { - PyErr_BadInternalCall(); - return -1; - } - x = _PyLong_AsScaledDouble(vv, &e); - if (x == -1.0 && PyErr_Occurred()) - return -1.0; - if (e > INT_MAX / SHIFT) - goto overflow; - errno = 0; - x = ldexp(x, e * SHIFT); - if (Py_OVERFLOWED(x)) - goto overflow; - return x; - -overflow: - PyErr_SetString(PyExc_OverflowError, - "long int too large to convert to float"); - return -1.0; -} - -/* Create a new long (or int) object from a C pointer */ - -PyObject * -PyLong_FromVoidPtr(void *p) -{ -#if SIZEOF_VOID_P <= SIZEOF_LONG - return PyInt_FromLong((long)p); -#else - -#ifndef HAVE_LONG_LONG -# error "PyLong_FromVoidPtr: sizeof(void*) > sizeof(long), but no long long" -#endif -#if SIZEOF_LONG_LONG < SIZEOF_VOID_P -# error "PyLong_FromVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)" -#endif - /* optimize null pointers */ - if (p == NULL) - return PyInt_FromLong(0); - return PyLong_FromLongLong((PY_LONG_LONG)p); - -#endif /* SIZEOF_VOID_P <= SIZEOF_LONG */ -} - -/* Get a C pointer from a long object (or an int object in some cases) */ - -void * -PyLong_AsVoidPtr(PyObject *vv) -{ - /* This function will allow int or long objects. If vv is neither, - then the PyLong_AsLong*() functions will raise the exception: - PyExc_SystemError, "bad argument to internal function" - */ -#if SIZEOF_VOID_P <= SIZEOF_LONG - long x; - - if (PyInt_Check(vv)) - x = PyInt_AS_LONG(vv); - else - x = PyLong_AsLong(vv); -#else - -#ifndef HAVE_LONG_LONG -# error "PyLong_AsVoidPtr: sizeof(void*) > sizeof(long), but no long long" -#endif -#if SIZEOF_LONG_LONG < SIZEOF_VOID_P -# error "PyLong_AsVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)" -#endif - PY_LONG_LONG x; - - if (PyInt_Check(vv)) - x = PyInt_AS_LONG(vv); - else - x = PyLong_AsLongLong(vv); - -#endif /* SIZEOF_VOID_P <= SIZEOF_LONG */ - - if (x == -1 && PyErr_Occurred()) - return NULL; - return (void *)x; -} - -#ifdef HAVE_LONG_LONG - -/* Initial PY_LONG_LONG support by Chris Herborth (chrish@qnx.com), later - * rewritten to use the newer PyLong_{As,From}ByteArray API. - */ - -#define IS_LITTLE_ENDIAN (int)*(unsigned char*)&one - -/* Create a new long int object from a C PY_LONG_LONG int. */ - -PyObject * -PyLong_FromLongLong(PY_LONG_LONG ival) -{ - PY_LONG_LONG bytes = ival; - int one = 1; - return _PyLong_FromByteArray( - (unsigned char *)&bytes, - SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 1); -} - -/* Create a new long int object from a C unsigned PY_LONG_LONG int. */ - -PyObject * -PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG ival) -{ - unsigned PY_LONG_LONG bytes = ival; - int one = 1; - return _PyLong_FromByteArray( - (unsigned char *)&bytes, - SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 0); -} - -/* Get a C PY_LONG_LONG int from a long int object. - Return -1 and set an error if overflow occurs. */ - -PY_LONG_LONG -PyLong_AsLongLong(PyObject *vv) -{ - PY_LONG_LONG bytes; - int one = 1; - int res; - - if (vv == NULL) { - PyErr_BadInternalCall(); - return -1; - } - if (!PyLong_Check(vv)) { - if (PyInt_Check(vv)) - return (PY_LONG_LONG)PyInt_AsLong(vv); - PyErr_BadInternalCall(); - return -1; - } - - res = _PyLong_AsByteArray( - (PyLongObject *)vv, (unsigned char *)&bytes, - SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 1); - - /* Plan 9 can't handle PY_LONG_LONG in ? : expressions */ - if (res < 0) - return (PY_LONG_LONG)-1; - else - return bytes; -} - -/* Get a C unsigned PY_LONG_LONG int from a long int object. - Return -1 and set an error if overflow occurs. */ - -unsigned PY_LONG_LONG -PyLong_AsUnsignedLongLong(PyObject *vv) -{ - unsigned PY_LONG_LONG bytes; - int one = 1; - int res; - - if (vv == NULL || !PyLong_Check(vv)) { - PyErr_BadInternalCall(); - return -1; - } - - res = _PyLong_AsByteArray( - (PyLongObject *)vv, (unsigned char *)&bytes, - SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 0); - - /* Plan 9 can't handle PY_LONG_LONG in ? : expressions */ - if (res < 0) - return (unsigned PY_LONG_LONG)res; - else - return bytes; -} - -/* Get a C unsigned long int from a long int object, ignoring the high bits. - Returns -1 and sets an error condition if an error occurs. */ - -unsigned PY_LONG_LONG -PyLong_AsUnsignedLongLongMask(PyObject *vv) -{ - register PyLongObject *v; - unsigned PY_LONG_LONG x; - int i, sign; - - if (vv == NULL || !PyLong_Check(vv)) { - PyErr_BadInternalCall(); - return (unsigned long) -1; - } - v = (PyLongObject *)vv; - i = v->ob_size; - sign = 1; - x = 0; - if (i < 0) { - sign = -1; - i = -i; - } - while (--i >= 0) { - x = (x << SHIFT) + v->ob_digit[i]; - } - return x * sign; -} -#undef IS_LITTLE_ENDIAN - -#endif /* HAVE_LONG_LONG */ - - -static int -convert_binop(PyObject *v, PyObject *w, PyLongObject **a, PyLongObject **b) { - if (PyLong_Check(v)) { - *a = (PyLongObject *) v; - Py_INCREF(v); - } - else if (PyInt_Check(v)) { - *a = (PyLongObject *) PyLong_FromLong(PyInt_AS_LONG(v)); - } - else { - return 0; - } - if (PyLong_Check(w)) { - *b = (PyLongObject *) w; - Py_INCREF(w); - } - else if (PyInt_Check(w)) { - *b = (PyLongObject *) PyLong_FromLong(PyInt_AS_LONG(w)); - } - else { - Py_DECREF(*a); - return 0; - } - return 1; -} - -#define CONVERT_BINOP(v, w, a, b) \ - if (!convert_binop(v, w, a, b)) { \ - Py_INCREF(Py_NotImplemented); \ - return Py_NotImplemented; \ - } - -/* x[0:m] and y[0:n] are digit vectors, LSD first, m >= n required. x[0:n] - * is modified in place, by adding y to it. Carries are propagated as far as - * x[m-1], and the remaining carry (0 or 1) is returned. - */ -static digit -v_iadd(digit *x, int m, digit *y, int n) -{ - int i; - digit carry = 0; - - assert(m >= n); - for (i = 0; i < n; ++i) { - carry += x[i] + y[i]; - x[i] = carry & MASK; - carry >>= SHIFT; - assert((carry & 1) == carry); - } - for (; carry && i < m; ++i) { - carry += x[i]; - x[i] = carry & MASK; - carry >>= SHIFT; - assert((carry & 1) == carry); - } - return carry; -} - -/* x[0:m] and y[0:n] are digit vectors, LSD first, m >= n required. x[0:n] - * is modified in place, by subtracting y from it. Borrows are propagated as - * far as x[m-1], and the remaining borrow (0 or 1) is returned. - */ -static digit -v_isub(digit *x, int m, digit *y, int n) -{ - int i; - digit borrow = 0; - - assert(m >= n); - for (i = 0; i < n; ++i) { - borrow = x[i] - y[i] - borrow; - x[i] = borrow & MASK; - borrow >>= SHIFT; - borrow &= 1; /* keep only 1 sign bit */ - } - for (; borrow && i < m; ++i) { - borrow = x[i] - borrow; - x[i] = borrow & MASK; - borrow >>= SHIFT; - borrow &= 1; - } - return borrow; -} - -/* Multiply by a single digit, ignoring the sign. */ - -static PyLongObject * -mul1(PyLongObject *a, wdigit n) -{ - return muladd1(a, n, (digit)0); -} - -/* Multiply by a single digit and add a single digit, ignoring the sign. */ - -static PyLongObject * -muladd1(PyLongObject *a, wdigit n, wdigit extra) -{ - int size_a = ABS(a->ob_size); - PyLongObject *z = _PyLong_New(size_a+1); - twodigits carry = extra; - int i; - - if (z == NULL) - return NULL; - for (i = 0; i < size_a; ++i) { - carry += (twodigits)a->ob_digit[i] * n; - z->ob_digit[i] = (digit) (carry & MASK); - carry >>= SHIFT; - } - z->ob_digit[i] = (digit) carry; - return long_normalize(z); -} - -/* Divide long pin, w/ size digits, by non-zero digit n, storing quotient - in pout, and returning the remainder. pin and pout point at the LSD. - It's OK for pin == pout on entry, which saves oodles of mallocs/frees in - long_format, but that should be done with great care since longs are - immutable. */ - -static digit -inplace_divrem1(digit *pout, digit *pin, int size, digit n) -{ - twodigits rem = 0; - - assert(n > 0 && n <= MASK); - pin += size; - pout += size; - while (--size >= 0) { - digit hi; - rem = (rem << SHIFT) + *--pin; - *--pout = hi = (digit)(rem / n); - rem -= hi * n; - } - return (digit)rem; -} - -/* Divide a long integer by a digit, returning both the quotient - (as function result) and the remainder (through *prem). - The sign of a is ignored; n should not be zero. */ - -static PyLongObject * -divrem1(PyLongObject *a, digit n, digit *prem) -{ - const int size = ABS(a->ob_size); - PyLongObject *z; - - assert(n > 0 && n <= MASK); - z = _PyLong_New(size); - if (z == NULL) - return NULL; - *prem = inplace_divrem1(z->ob_digit, a->ob_digit, size, n); - return long_normalize(z); -} - -/* Convert a long int object to a string, using a given conversion base. - Return a string object. - If base is 8 or 16, add the proper prefix '0' or '0x'. */ - -static PyObject * -long_format(PyObject *aa, int base, int addL) -{ - register PyLongObject *a = (PyLongObject *)aa; - PyStringObject *str; - int i; - const int size_a = ABS(a->ob_size); - char *p; - int bits; - char sign = '\0'; - - if (a == NULL || !PyLong_Check(a)) { - PyErr_BadInternalCall(); - return NULL; - } - assert(base >= 2 && base <= 36); - - /* Compute a rough upper bound for the length of the string */ - i = base; - bits = 0; - while (i > 1) { - ++bits; - i >>= 1; - } - i = 5 + (addL ? 1 : 0) + (size_a*SHIFT + bits-1) / bits; - str = (PyStringObject *) PyString_FromStringAndSize((char *)0, i); - if (str == NULL) - return NULL; - p = PyString_AS_STRING(str) + i; - *p = '\0'; - if (addL) - *--p = 'L'; - if (a->ob_size < 0) - sign = '-'; - - if (a->ob_size == 0) { - *--p = '0'; - } - else if ((base & (base - 1)) == 0) { - /* JRH: special case for power-of-2 bases */ - twodigits accum = 0; - int accumbits = 0; /* # of bits in accum */ - int basebits = 1; /* # of bits in base-1 */ - i = base; - while ((i >>= 1) > 1) - ++basebits; - - for (i = 0; i < size_a; ++i) { - accum |= (twodigits)a->ob_digit[i] << accumbits; - accumbits += SHIFT; - assert(accumbits >= basebits); - do { - char cdigit = (char)(accum & (base - 1)); - cdigit += (cdigit < 10) ? '0' : 'A'-10; - assert(p > PyString_AS_STRING(str)); - *--p = cdigit; - accumbits -= basebits; - accum >>= basebits; - } while (i < size_a-1 ? accumbits >= basebits : - accum > 0); - } - } - else { - /* Not 0, and base not a power of 2. Divide repeatedly by - base, but for speed use the highest power of base that - fits in a digit. */ - int size = size_a; - digit *pin = a->ob_digit; - PyLongObject *scratch; - /* powbasw <- largest power of base that fits in a digit. */ - digit powbase = base; /* powbase == base ** power */ - int power = 1; - for (;;) { - unsigned long newpow = powbase * (unsigned long)base; - if (newpow >> SHIFT) /* doesn't fit in a digit */ - break; - powbase = (digit)newpow; - ++power; - } - - /* Get a scratch area for repeated division. */ - scratch = _PyLong_New(size); - if (scratch == NULL) { - Py_DECREF(str); - return NULL; - } - - /* Repeatedly divide by powbase. */ - do { - int ntostore = power; - digit rem = inplace_divrem1(scratch->ob_digit, - pin, size, powbase); - pin = scratch->ob_digit; /* no need to use a again */ - if (pin[size - 1] == 0) - --size; - SIGCHECK({ - Py_DECREF(scratch); - Py_DECREF(str); - return NULL; - }) - - /* Break rem into digits. */ - assert(ntostore > 0); - do { - digit nextrem = (digit)(rem / base); - char c = (char)(rem - nextrem * base); - assert(p > PyString_AS_STRING(str)); - c += (c < 10) ? '0' : 'A'-10; - *--p = c; - rem = nextrem; - --ntostore; - /* Termination is a bit delicate: must not - store leading zeroes, so must get out if - remaining quotient and rem are both 0. */ - } while (ntostore && (size || rem)); - } while (size != 0); - Py_DECREF(scratch); - } - - if (base == 8) { - if (size_a != 0) - *--p = '0'; - } - else if (base == 16) { - *--p = 'x'; - *--p = '0'; - } - else if (base != 10) { - *--p = '#'; - *--p = '0' + base%10; - if (base > 10) - *--p = '0' + base/10; - } - if (sign) - *--p = sign; - if (p != PyString_AS_STRING(str)) { - char *q = PyString_AS_STRING(str); - assert(p > q); - do { - } while ((*q++ = *p++) != '\0'); - q--; - _PyString_Resize((PyObject **)&str, - (int) (q - PyString_AS_STRING(str))); - } - return (PyObject *)str; -} - -/* *str points to the first digit in a string of base base digits. base - * is a power of 2 (2, 4, 8, 16, or 32). *str is set to point to the first - * non-digit (which may be *str!). A normalized long is returned. - * The point to this routine is that it takes time linear in the number of - * string characters. - */ -static PyLongObject * -long_from_binary_base(char **str, int base) -{ - char *p = *str; - char *start = p; - int bits_per_char; - int n; - PyLongObject *z; - twodigits accum; - int bits_in_accum; - digit *pdigit; - - assert(base >= 2 && base <= 32 && (base & (base - 1)) == 0); - n = base; - for (bits_per_char = -1; n; ++bits_per_char) - n >>= 1; - /* n <- total # of bits needed, while setting p to end-of-string */ - n = 0; - for (;;) { - int k = -1; - char ch = *p; - - if (ch <= '9') - k = ch - '0'; - else if (ch >= 'a') - k = ch - 'a' + 10; - else if (ch >= 'A') - k = ch - 'A' + 10; - if (k < 0 || k >= base) - break; - ++p; - } - *str = p; - n = (p - start) * bits_per_char; - if (n / bits_per_char != p - start) { - PyErr_SetString(PyExc_ValueError, - "long string too large to convert"); - return NULL; - } - /* n <- # of Python digits needed, = ceiling(n/SHIFT). */ - n = (n + SHIFT - 1) / SHIFT; - z = _PyLong_New(n); - if (z == NULL) - return NULL; - /* Read string from right, and fill in long from left; i.e., - * from least to most significant in both. - */ - accum = 0; - bits_in_accum = 0; - pdigit = z->ob_digit; - while (--p >= start) { - int k; - char ch = *p; - - if (ch <= '9') - k = ch - '0'; - else if (ch >= 'a') - k = ch - 'a' + 10; - else { - assert(ch >= 'A'); - k = ch - 'A' + 10; - } - assert(k >= 0 && k < base); - accum |= (twodigits)(k << bits_in_accum); - bits_in_accum += bits_per_char; - if (bits_in_accum >= SHIFT) { - *pdigit++ = (digit)(accum & MASK); - assert(pdigit - z->ob_digit <= n); - accum >>= SHIFT; - bits_in_accum -= SHIFT; - assert(bits_in_accum < SHIFT); - } - } - if (bits_in_accum) { - assert(bits_in_accum <= SHIFT); - *pdigit++ = (digit)accum; - assert(pdigit - z->ob_digit <= n); - } - while (pdigit - z->ob_digit < n) - *pdigit++ = 0; - return long_normalize(z); -} - -PyObject * -PyLong_FromString(char *str, char **pend, int base) -{ - int sign = 1; - char *start, *orig_str = str; - PyLongObject *z; - - if ((base != 0 && base < 2) || base > 36) { - PyErr_SetString(PyExc_ValueError, - "long() arg 2 must be >= 2 and <= 36"); - return NULL; - } - while (*str != '\0' && isspace(Py_CHARMASK(*str))) - str++; - if (*str == '+') - ++str; - else if (*str == '-') { - ++str; - sign = -1; - } - while (*str != '\0' && isspace(Py_CHARMASK(*str))) - str++; - if (base == 0) { - if (str[0] != '0') - base = 10; - else if (str[1] == 'x' || str[1] == 'X') - base = 16; - else - base = 8; - } - if (base == 16 && str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) - str += 2; - start = str; - if ((base & (base - 1)) == 0) - z = long_from_binary_base(&str, base); - else { - z = _PyLong_New(0); - for ( ; z != NULL; ++str) { - int k = -1; - PyLongObject *temp; - - if (*str <= '9') - k = *str - '0'; - else if (*str >= 'a') - k = *str - 'a' + 10; - else if (*str >= 'A') - k = *str - 'A' + 10; - if (k < 0 || k >= base) - break; - temp = muladd1(z, (digit)base, (digit)k); - Py_DECREF(z); - z = temp; - } - } - if (z == NULL) - return NULL; - if (str == start) - goto onError; - if (sign < 0 && z != NULL && z->ob_size != 0) - z->ob_size = -(z->ob_size); - if (*str == 'L' || *str == 'l') - str++; - while (*str && isspace(Py_CHARMASK(*str))) - str++; - if (*str != '\0') - goto onError; - if (pend) - *pend = str; - return (PyObject *) z; - - onError: - PyErr_Format(PyExc_ValueError, - "invalid literal for long(): %.200s", orig_str); - Py_XDECREF(z); - return NULL; -} - -#ifdef Py_USING_UNICODE -PyObject * -PyLong_FromUnicode(Py_UNICODE *u, int length, int base) -{ - PyObject *result; - char *buffer = PyMem_MALLOC(length+1); - - if (buffer == NULL) - return NULL; - - if (PyUnicode_EncodeDecimal(u, length, buffer, NULL)) { - PyMem_FREE(buffer); - return NULL; - } - result = PyLong_FromString(buffer, NULL, base); - PyMem_FREE(buffer); - return result; -} -#endif - -/* forward */ -static PyLongObject *x_divrem - (PyLongObject *, PyLongObject *, PyLongObject **); -static PyObject *long_pos(PyLongObject *); -static int long_divrem(PyLongObject *, PyLongObject *, - PyLongObject **, PyLongObject **); - -/* Long division with remainder, top-level routine */ - -static int -long_divrem(PyLongObject *a, PyLongObject *b, - PyLongObject **pdiv, PyLongObject **prem) -{ - int size_a = ABS(a->ob_size), size_b = ABS(b->ob_size); - PyLongObject *z; - - if (size_b == 0) { - PyErr_SetString(PyExc_ZeroDivisionError, - "long division or modulo by zero"); - return -1; - } - if (size_a < size_b || - (size_a == size_b && - a->ob_digit[size_a-1] < b->ob_digit[size_b-1])) { - /* |a| < |b|. */ - *pdiv = _PyLong_New(0); - Py_INCREF(a); - *prem = (PyLongObject *) a; - return 0; - } - if (size_b == 1) { - digit rem = 0; - z = divrem1(a, b->ob_digit[0], &rem); - if (z == NULL) - return -1; - *prem = (PyLongObject *) PyLong_FromLong((long)rem); - } - else { - z = x_divrem(a, b, prem); - if (z == NULL) - return -1; - } - /* Set the signs. - The quotient z has the sign of a*b; - the remainder r has the sign of a, - so a = b*z + r. */ - if ((a->ob_size < 0) != (b->ob_size < 0)) - z->ob_size = -(z->ob_size); - if (a->ob_size < 0 && (*prem)->ob_size != 0) - (*prem)->ob_size = -((*prem)->ob_size); - *pdiv = z; - return 0; -} - -/* Unsigned long division with remainder -- the algorithm */ - -static PyLongObject * -x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem) -{ - int size_v = ABS(v1->ob_size), size_w = ABS(w1->ob_size); - digit d = (digit) ((twodigits)BASE / (w1->ob_digit[size_w-1] + 1)); - PyLongObject *v = mul1(v1, d); - PyLongObject *w = mul1(w1, d); - PyLongObject *a; - int j, k; - - if (v == NULL || w == NULL) { - Py_XDECREF(v); - Py_XDECREF(w); - return NULL; - } - - assert(size_v >= size_w && size_w > 1); /* Assert checks by div() */ - assert(v->ob_refcnt == 1); /* Since v will be used as accumulator! */ - assert(size_w == ABS(w->ob_size)); /* That's how d was calculated */ - - size_v = ABS(v->ob_size); - a = _PyLong_New(size_v - size_w + 1); - - for (j = size_v, k = a->ob_size-1; a != NULL && k >= 0; --j, --k) { - digit vj = (j >= size_v) ? 0 : v->ob_digit[j]; - twodigits q; - stwodigits carry = 0; - int i; - - SIGCHECK({ - Py_DECREF(a); - a = NULL; - break; - }) - if (vj == w->ob_digit[size_w-1]) - q = MASK; - else - q = (((twodigits)vj << SHIFT) + v->ob_digit[j-1]) / - w->ob_digit[size_w-1]; - - while (w->ob_digit[size_w-2]*q > - (( - ((twodigits)vj << SHIFT) - + v->ob_digit[j-1] - - q*w->ob_digit[size_w-1] - ) << SHIFT) - + v->ob_digit[j-2]) - --q; - - for (i = 0; i < size_w && i+k < size_v; ++i) { - twodigits z = w->ob_digit[i] * q; - digit zz = (digit) (z >> SHIFT); - carry += v->ob_digit[i+k] - z - + ((twodigits)zz << SHIFT); - v->ob_digit[i+k] = (digit)(carry & MASK); - carry = Py_ARITHMETIC_RIGHT_SHIFT(BASE_TWODIGITS_TYPE, - carry, SHIFT); - carry -= zz; - } - - if (i+k < size_v) { - carry += v->ob_digit[i+k]; - v->ob_digit[i+k] = 0; - } - - if (carry == 0) - a->ob_digit[k] = (digit) q; - else { - assert(carry == -1); - a->ob_digit[k] = (digit) q-1; - carry = 0; - for (i = 0; i < size_w && i+k < size_v; ++i) { - carry += v->ob_digit[i+k] + w->ob_digit[i]; - v->ob_digit[i+k] = (digit)(carry & MASK); - carry = Py_ARITHMETIC_RIGHT_SHIFT( - BASE_TWODIGITS_TYPE, - carry, SHIFT); - } - } - } /* for j, k */ - - if (a == NULL) - *prem = NULL; - else { - a = long_normalize(a); - *prem = divrem1(v, d, &d); - /* d receives the (unused) remainder */ - if (*prem == NULL) { - Py_DECREF(a); - a = NULL; - } - } - Py_DECREF(v); - Py_DECREF(w); - return a; -} - -/* Methods */ - -static void -long_dealloc(PyObject *v) -{ - v->ob_type->tp_free(v); -} - -static PyObject * -long_repr(PyObject *v) -{ - return long_format(v, 10, 1); -} - -static PyObject * -long_str(PyObject *v) -{ - return long_format(v, 10, 0); -} - -static int -long_compare(PyLongObject *a, PyLongObject *b) -{ - int sign; - - if (a->ob_size != b->ob_size) { - if (ABS(a->ob_size) == 0 && ABS(b->ob_size) == 0) - sign = 0; - else - sign = a->ob_size - b->ob_size; - } - else { - int i = ABS(a->ob_size); - while (--i >= 0 && a->ob_digit[i] == b->ob_digit[i]) - ; - if (i < 0) - sign = 0; - else { - sign = (int)a->ob_digit[i] - (int)b->ob_digit[i]; - if (a->ob_size < 0) - sign = -sign; - } - } - return sign < 0 ? -1 : sign > 0 ? 1 : 0; -} - -static long -long_hash(PyLongObject *v) -{ - long x; - int i, sign; - - /* This is designed so that Python ints and longs with the - same value hash to the same value, otherwise comparisons - of mapping keys will turn out weird */ - i = v->ob_size; - sign = 1; - x = 0; - if (i < 0) { - sign = -1; - i = -(i); - } -#define LONG_BIT_SHIFT (8*sizeof(long) - SHIFT) - while (--i >= 0) { - /* Force a native long #-bits (32 or 64) circular shift */ - x = ((x << SHIFT) & ~MASK) | ((x >> LONG_BIT_SHIFT) & MASK); - x += v->ob_digit[i]; - } -#undef LONG_BIT_SHIFT - x = x * sign; - if (x == -1) - x = -2; - return x; -} - - -/* Add the absolute values of two long integers. */ - -static PyLongObject * -x_add(PyLongObject *a, PyLongObject *b) -{ - int size_a = ABS(a->ob_size), size_b = ABS(b->ob_size); - PyLongObject *z; - int i; - digit carry = 0; - - /* Ensure a is the larger of the two: */ - if (size_a < size_b) { - { PyLongObject *temp = a; a = b; b = temp; } - { int size_temp = size_a; - size_a = size_b; - size_b = size_temp; } - } - z = _PyLong_New(size_a+1); - if (z == NULL) - return NULL; - for (i = 0; i < size_b; ++i) { - carry += a->ob_digit[i] + b->ob_digit[i]; - z->ob_digit[i] = carry & MASK; - carry >>= SHIFT; - } - for (; i < size_a; ++i) { - carry += a->ob_digit[i]; - z->ob_digit[i] = carry & MASK; - carry >>= SHIFT; - } - z->ob_digit[i] = carry; - return long_normalize(z); -} - -/* Subtract the absolute values of two integers. */ - -static PyLongObject * -x_sub(PyLongObject *a, PyLongObject *b) -{ - int size_a = ABS(a->ob_size), size_b = ABS(b->ob_size); - PyLongObject *z; - int i; - int sign = 1; - digit borrow = 0; - - /* Ensure a is the larger of the two: */ - if (size_a < size_b) { - sign = -1; - { PyLongObject *temp = a; a = b; b = temp; } - { int size_temp = size_a; - size_a = size_b; - size_b = size_temp; } - } - else if (size_a == size_b) { - /* Find highest digit where a and b differ: */ - i = size_a; - while (--i >= 0 && a->ob_digit[i] == b->ob_digit[i]) - ; - if (i < 0) - return _PyLong_New(0); - if (a->ob_digit[i] < b->ob_digit[i]) { - sign = -1; - { PyLongObject *temp = a; a = b; b = temp; } - } - size_a = size_b = i+1; - } - z = _PyLong_New(size_a); - if (z == NULL) - return NULL; - for (i = 0; i < size_b; ++i) { - /* The following assumes unsigned arithmetic - works module 2**N for some N>SHIFT. */ - borrow = a->ob_digit[i] - b->ob_digit[i] - borrow; - z->ob_digit[i] = borrow & MASK; - borrow >>= SHIFT; - borrow &= 1; /* Keep only one sign bit */ - } - for (; i < size_a; ++i) { - borrow = a->ob_digit[i] - borrow; - z->ob_digit[i] = borrow & MASK; - borrow >>= SHIFT; - borrow &= 1; /* Keep only one sign bit */ - } - assert(borrow == 0); - if (sign < 0) - z->ob_size = -(z->ob_size); - return long_normalize(z); -} - -static PyObject * -long_add(PyLongObject *v, PyLongObject *w) -{ - PyLongObject *a, *b, *z; - - CONVERT_BINOP((PyObject *)v, (PyObject *)w, &a, &b); - - if (a->ob_size < 0) { - if (b->ob_size < 0) { - z = x_add(a, b); - if (z != NULL && z->ob_size != 0) - z->ob_size = -(z->ob_size); - } - else - z = x_sub(b, a); - } - else { - if (b->ob_size < 0) - z = x_sub(a, b); - else - z = x_add(a, b); - } - Py_DECREF(a); - Py_DECREF(b); - return (PyObject *)z; -} - -static PyObject * -long_sub(PyLongObject *v, PyLongObject *w) -{ - PyLongObject *a, *b, *z; - - CONVERT_BINOP((PyObject *)v, (PyObject *)w, &a, &b); - - if (a->ob_size < 0) { - if (b->ob_size < 0) - z = x_sub(a, b); - else - z = x_add(a, b); - if (z != NULL && z->ob_size != 0) - z->ob_size = -(z->ob_size); - } - else { - if (b->ob_size < 0) - z = x_add(a, b); - else - z = x_sub(a, b); - } - Py_DECREF(a); - Py_DECREF(b); - return (PyObject *)z; -} - -/* Grade school multiplication, ignoring the signs. - * Returns the absolute value of the product, or NULL if error. - */ -static PyLongObject * -x_mul(PyLongObject *a, PyLongObject *b) -{ - PyLongObject *z; - int size_a = ABS(a->ob_size); - int size_b = ABS(b->ob_size); - int i; - - z = _PyLong_New(size_a + size_b); - if (z == NULL) - return NULL; - - memset(z->ob_digit, 0, z->ob_size * sizeof(digit)); - for (i = 0; i < size_a; ++i) { - twodigits carry = 0; - twodigits f = a->ob_digit[i]; - int j; - digit *pz = z->ob_digit + i; - - SIGCHECK({ - Py_DECREF(z); - return NULL; - }) - for (j = 0; j < size_b; ++j) { - carry += *pz + b->ob_digit[j] * f; - *pz++ = (digit) (carry & MASK); - carry >>= SHIFT; - } - for (; carry != 0; ++j) { - assert(i+j < z->ob_size); - carry += *pz; - *pz++ = (digit) (carry & MASK); - carry >>= SHIFT; - } - } - return long_normalize(z); -} - -/* A helper for Karatsuba multiplication (k_mul). - Takes a long "n" and an integer "size" representing the place to - split, and sets low and high such that abs(n) == (high << size) + low, - viewing the shift as being by digits. The sign bit is ignored, and - the return values are >= 0. - Returns 0 on success, -1 on failure. -*/ -static int -kmul_split(PyLongObject *n, int size, PyLongObject **high, PyLongObject **low) -{ - PyLongObject *hi, *lo; - int size_lo, size_hi; - const int size_n = ABS(n->ob_size); - - size_lo = MIN(size_n, size); - size_hi = size_n - size_lo; - - if ((hi = _PyLong_New(size_hi)) == NULL) - return -1; - if ((lo = _PyLong_New(size_lo)) == NULL) { - Py_DECREF(hi); - return -1; - } - - memcpy(lo->ob_digit, n->ob_digit, size_lo * sizeof(digit)); - memcpy(hi->ob_digit, n->ob_digit + size_lo, size_hi * sizeof(digit)); - - *high = long_normalize(hi); - *low = long_normalize(lo); - return 0; -} - -static PyLongObject *k_lopsided_mul(PyLongObject *a, PyLongObject *b); - -/* Karatsuba multiplication. Ignores the input signs, and returns the - * absolute value of the product (or NULL if error). - * See Knuth Vol. 2 Chapter 4.3.3 (Pp. 294-295). - */ -static PyLongObject * -k_mul(PyLongObject *a, PyLongObject *b) -{ - int asize = ABS(a->ob_size); - int bsize = ABS(b->ob_size); - PyLongObject *ah = NULL; - PyLongObject *al = NULL; - PyLongObject *bh = NULL; - PyLongObject *bl = NULL; - PyLongObject *ret = NULL; - PyLongObject *t1, *t2, *t3; - int shift; /* the number of digits we split off */ - int i; - - /* (ah*X+al)(bh*X+bl) = ah*bh*X*X + (ah*bl + al*bh)*X + al*bl - * Let k = (ah+al)*(bh+bl) = ah*bl + al*bh + ah*bh + al*bl - * Then the original product is - * ah*bh*X*X + (k - ah*bh - al*bl)*X + al*bl - * By picking X to be a power of 2, "*X" is just shifting, and it's - * been reduced to 3 multiplies on numbers half the size. - */ - - /* We want to split based on the larger number; fiddle so that b - * is largest. - */ - if (asize > bsize) { - t1 = a; - a = b; - b = t1; - - i = asize; - asize = bsize; - bsize = i; - } - - /* Use gradeschool math when either number is too small. */ - if (asize <= KARATSUBA_CUTOFF) { - if (asize == 0) - return _PyLong_New(0); - else - return x_mul(a, b); - } - - /* If a is small compared to b, splitting on b gives a degenerate - * case with ah==0, and Karatsuba may be (even much) less efficient - * than "grade school" then. However, we can still win, by viewing - * b as a string of "big digits", each of width a->ob_size. That - * leads to a sequence of balanced calls to k_mul. - */ - if (2 * asize <= bsize) - return k_lopsided_mul(a, b); - - /* Split a & b into hi & lo pieces. */ - shift = bsize >> 1; - if (kmul_split(a, shift, &ah, &al) < 0) goto fail; - assert(ah->ob_size > 0); /* the split isn't degenerate */ - - if (kmul_split(b, shift, &bh, &bl) < 0) goto fail; - - /* The plan: - * 1. Allocate result space (asize + bsize digits: that's always - * enough). - * 2. Compute ah*bh, and copy into result at 2*shift. - * 3. Compute al*bl, and copy into result at 0. Note that this - * can't overlap with #2. - * 4. Subtract al*bl from the result, starting at shift. This may - * underflow (borrow out of the high digit), but we don't care: - * we're effectively doing unsigned arithmetic mod - * BASE**(sizea + sizeb), and so long as the *final* result fits, - * borrows and carries out of the high digit can be ignored. - * 5. Subtract ah*bh from the result, starting at shift. - * 6. Compute (ah+al)*(bh+bl), and add it into the result starting - * at shift. - */ - - /* 1. Allocate result space. */ - ret = _PyLong_New(asize + bsize); - if (ret == NULL) goto fail; -#ifdef Py_DEBUG - /* Fill with trash, to catch reference to uninitialized digits. */ - memset(ret->ob_digit, 0xDF, ret->ob_size * sizeof(digit)); -#endif - - /* 2. t1 <- ah*bh, and copy into high digits of result. */ - if ((t1 = k_mul(ah, bh)) == NULL) goto fail; - assert(t1->ob_size >= 0); - assert(2*shift + t1->ob_size <= ret->ob_size); - memcpy(ret->ob_digit + 2*shift, t1->ob_digit, - t1->ob_size * sizeof(digit)); - - /* Zero-out the digits higher than the ah*bh copy. */ - i = ret->ob_size - 2*shift - t1->ob_size; - if (i) - memset(ret->ob_digit + 2*shift + t1->ob_size, 0, - i * sizeof(digit)); - - /* 3. t2 <- al*bl, and copy into the low digits. */ - if ((t2 = k_mul(al, bl)) == NULL) { - Py_DECREF(t1); - goto fail; - } - assert(t2->ob_size >= 0); - assert(t2->ob_size <= 2*shift); /* no overlap with high digits */ - memcpy(ret->ob_digit, t2->ob_digit, t2->ob_size * sizeof(digit)); - - /* Zero out remaining digits. */ - i = 2*shift - t2->ob_size; /* number of uninitialized digits */ - if (i) - memset(ret->ob_digit + t2->ob_size, 0, i * sizeof(digit)); - - /* 4 & 5. Subtract ah*bh (t1) and al*bl (t2). We do al*bl first - * because it's fresher in cache. - */ - i = ret->ob_size - shift; /* # digits after shift */ - (void)v_isub(ret->ob_digit + shift, i, t2->ob_digit, t2->ob_size); - Py_DECREF(t2); - - (void)v_isub(ret->ob_digit + shift, i, t1->ob_digit, t1->ob_size); - Py_DECREF(t1); - - /* 6. t3 <- (ah+al)(bh+bl), and add into result. */ - if ((t1 = x_add(ah, al)) == NULL) goto fail; - Py_DECREF(ah); - Py_DECREF(al); - ah = al = NULL; - - if ((t2 = x_add(bh, bl)) == NULL) { - Py_DECREF(t1); - goto fail; - } - Py_DECREF(bh); - Py_DECREF(bl); - bh = bl = NULL; - - t3 = k_mul(t1, t2); - Py_DECREF(t1); - Py_DECREF(t2); - if (t3 == NULL) goto fail; - assert(t3->ob_size >= 0); - - /* Add t3. It's not obvious why we can't run out of room here. - * See the (*) comment after this function. - */ - (void)v_iadd(ret->ob_digit + shift, i, t3->ob_digit, t3->ob_size); - Py_DECREF(t3); - - return long_normalize(ret); - - fail: - Py_XDECREF(ret); - Py_XDECREF(ah); - Py_XDECREF(al); - Py_XDECREF(bh); - Py_XDECREF(bl); - return NULL; -} - -/* (*) Why adding t3 can't "run out of room" above. - -Let f(x) mean the floor of x and c(x) mean the ceiling of x. Some facts -to start with: - -1. For any integer i, i = c(i/2) + f(i/2). In particular, - bsize = c(bsize/2) + f(bsize/2). -2. shift = f(bsize/2) -3. asize <= bsize -4. Since we call k_lopsided_mul if asize*2 <= bsize, asize*2 > bsize in this - routine, so asize > bsize/2 >= f(bsize/2) in this routine. - -We allocated asize + bsize result digits, and add t3 into them at an offset -of shift. This leaves asize+bsize-shift allocated digit positions for t3 -to fit into, = (by #1 and #2) asize + f(bsize/2) + c(bsize/2) - f(bsize/2) = -asize + c(bsize/2) available digit positions. - -bh has c(bsize/2) digits, and bl at most f(size/2) digits. So bh+hl has -at most c(bsize/2) digits + 1 bit. - -If asize == bsize, ah has c(bsize/2) digits, else ah has at most f(bsize/2) -digits, and al has at most f(bsize/2) digits in any case. So ah+al has at -most (asize == bsize ? c(bsize/2) : f(bsize/2)) digits + 1 bit. - -The product (ah+al)*(bh+bl) therefore has at most - - c(bsize/2) + (asize == bsize ? c(bsize/2) : f(bsize/2)) digits + 2 bits - -and we have asize + c(bsize/2) available digit positions. We need to show -this is always enough. An instance of c(bsize/2) cancels out in both, so -the question reduces to whether asize digits is enough to hold -(asize == bsize ? c(bsize/2) : f(bsize/2)) digits + 2 bits. If asize < bsize, -then we're asking whether asize digits >= f(bsize/2) digits + 2 bits. By #4, -asize is at least f(bsize/2)+1 digits, so this in turn reduces to whether 1 -digit is enough to hold 2 bits. This is so since SHIFT=15 >= 2. If -asize == bsize, then we're asking whether bsize digits is enough to hold -c(bsize/2) digits + 2 bits, or equivalently (by #1) whether f(bsize/2) digits -is enough to hold 2 bits. This is so if bsize >= 2, which holds because -bsize >= KARATSUBA_CUTOFF >= 2. - -Note that since there's always enough room for (ah+al)*(bh+bl), and that's -clearly >= each of ah*bh and al*bl, there's always enough room to subtract -ah*bh and al*bl too. -*/ - -/* b has at least twice the digits of a, and a is big enough that Karatsuba - * would pay off *if* the inputs had balanced sizes. View b as a sequence - * of slices, each with a->ob_size digits, and multiply the slices by a, - * one at a time. This gives k_mul balanced inputs to work with, and is - * also cache-friendly (we compute one double-width slice of the result - * at a time, then move on, never bactracking except for the helpful - * single-width slice overlap between successive partial sums). - */ -static PyLongObject * -k_lopsided_mul(PyLongObject *a, PyLongObject *b) -{ - const int asize = ABS(a->ob_size); - int bsize = ABS(b->ob_size); - int nbdone; /* # of b digits already multiplied */ - PyLongObject *ret; - PyLongObject *bslice = NULL; - - assert(asize > KARATSUBA_CUTOFF); - assert(2 * asize <= bsize); - - /* Allocate result space, and zero it out. */ - ret = _PyLong_New(asize + bsize); - if (ret == NULL) - return NULL; - memset(ret->ob_digit, 0, ret->ob_size * sizeof(digit)); - - /* Successive slices of b are copied into bslice. */ - bslice = _PyLong_New(asize); - if (bslice == NULL) - goto fail; - - nbdone = 0; - while (bsize > 0) { - PyLongObject *product; - const int nbtouse = MIN(bsize, asize); - - /* Multiply the next slice of b by a. */ - memcpy(bslice->ob_digit, b->ob_digit + nbdone, - nbtouse * sizeof(digit)); - bslice->ob_size = nbtouse; - product = k_mul(a, bslice); - if (product == NULL) - goto fail; - - /* Add into result. */ - (void)v_iadd(ret->ob_digit + nbdone, ret->ob_size - nbdone, - product->ob_digit, product->ob_size); - Py_DECREF(product); - - bsize -= nbtouse; - nbdone += nbtouse; - } - - Py_DECREF(bslice); - return long_normalize(ret); - - fail: - Py_DECREF(ret); - Py_XDECREF(bslice); - return NULL; -} - -static PyObject * -long_mul(PyLongObject *v, PyLongObject *w) -{ - PyLongObject *a, *b, *z; - - if (!convert_binop((PyObject *)v, (PyObject *)w, &a, &b)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - - z = k_mul(a, b); - /* Negate if exactly one of the inputs is negative. */ - if (((a->ob_size ^ b->ob_size) < 0) && z) - z->ob_size = -(z->ob_size); - Py_DECREF(a); - Py_DECREF(b); - return (PyObject *)z; -} - -/* The / and % operators are now defined in terms of divmod(). - The expression a mod b has the value a - b*floor(a/b). - The long_divrem function gives the remainder after division of - |a| by |b|, with the sign of a. This is also expressed - as a - b*trunc(a/b), if trunc truncates towards zero. - Some examples: - a b a rem b a mod b - 13 10 3 3 - -13 10 -3 7 - 13 -10 3 -7 - -13 -10 -3 -3 - So, to get from rem to mod, we have to add b if a and b - have different signs. We then subtract one from the 'div' - part of the outcome to keep the invariant intact. */ - -static int -l_divmod(PyLongObject *v, PyLongObject *w, - PyLongObject **pdiv, PyLongObject **pmod) -{ - PyLongObject *div, *mod; - - if (long_divrem(v, w, &div, &mod) < 0) - return -1; - if ((mod->ob_size < 0 && w->ob_size > 0) || - (mod->ob_size > 0 && w->ob_size < 0)) { - PyLongObject *temp; - PyLongObject *one; - temp = (PyLongObject *) long_add(mod, w); - Py_DECREF(mod); - mod = temp; - if (mod == NULL) { - Py_DECREF(div); - return -1; - } - one = (PyLongObject *) PyLong_FromLong(1L); - if (one == NULL || - (temp = (PyLongObject *) long_sub(div, one)) == NULL) { - Py_DECREF(mod); - Py_DECREF(div); - Py_XDECREF(one); - return -1; - } - Py_DECREF(one); - Py_DECREF(div); - div = temp; - } - *pdiv = div; - *pmod = mod; - return 0; -} - -static PyObject * -long_div(PyObject *v, PyObject *w) -{ - PyLongObject *a, *b, *div, *mod; - - CONVERT_BINOP(v, w, &a, &b); - - if (l_divmod(a, b, &div, &mod) < 0) { - Py_DECREF(a); - Py_DECREF(b); - return NULL; - } - Py_DECREF(a); - Py_DECREF(b); - Py_DECREF(mod); - return (PyObject *)div; -} - -static PyObject * -long_classic_div(PyObject *v, PyObject *w) -{ - PyLongObject *a, *b, *div, *mod; - - CONVERT_BINOP(v, w, &a, &b); - - if (Py_DivisionWarningFlag && - PyErr_Warn(PyExc_DeprecationWarning, "classic long division") < 0) - div = NULL; - else if (l_divmod(a, b, &div, &mod) < 0) - div = NULL; - else - Py_DECREF(mod); - - Py_DECREF(a); - Py_DECREF(b); - return (PyObject *)div; -} - -static PyObject * -long_true_divide(PyObject *v, PyObject *w) -{ - PyLongObject *a, *b; - double ad, bd; - int aexp, bexp, failed; - - CONVERT_BINOP(v, w, &a, &b); - ad = _PyLong_AsScaledDouble((PyObject *)a, &aexp); - bd = _PyLong_AsScaledDouble((PyObject *)b, &bexp); - failed = (ad == -1.0 || bd == -1.0) && PyErr_Occurred(); - Py_DECREF(a); - Py_DECREF(b); - if (failed) - return NULL; - - if (bd == 0.0) { - PyErr_SetString(PyExc_ZeroDivisionError, - "long division or modulo by zero"); - return NULL; - } - - /* True value is very close to ad/bd * 2**(SHIFT*(aexp-bexp)) */ - ad /= bd; /* overflow/underflow impossible here */ - aexp -= bexp; - if (aexp > INT_MAX / SHIFT) - goto overflow; - else if (aexp < -(INT_MAX / SHIFT)) - return PyFloat_FromDouble(0.0); /* underflow to 0 */ - errno = 0; - ad = ldexp(ad, aexp * SHIFT); - if (Py_OVERFLOWED(ad)) /* ignore underflow to 0.0 */ - goto overflow; - return PyFloat_FromDouble(ad); - -overflow: - PyErr_SetString(PyExc_OverflowError, - "long/long too large for a float"); - return NULL; - -} - -static PyObject * -long_mod(PyObject *v, PyObject *w) -{ - PyLongObject *a, *b, *div, *mod; - - CONVERT_BINOP(v, w, &a, &b); - - if (l_divmod(a, b, &div, &mod) < 0) { - Py_DECREF(a); - Py_DECREF(b); - return NULL; - } - Py_DECREF(a); - Py_DECREF(b); - Py_DECREF(div); - return (PyObject *)mod; -} - -static PyObject * -long_divmod(PyObject *v, PyObject *w) -{ - PyLongObject *a, *b, *div, *mod; - PyObject *z; - - CONVERT_BINOP(v, w, &a, &b); - - if (l_divmod(a, b, &div, &mod) < 0) { - Py_DECREF(a); - Py_DECREF(b); - return NULL; - } - z = PyTuple_New(2); - if (z != NULL) { - PyTuple_SetItem(z, 0, (PyObject *) div); - PyTuple_SetItem(z, 1, (PyObject *) mod); - } - else { - Py_DECREF(div); - Py_DECREF(mod); - } - Py_DECREF(a); - Py_DECREF(b); - return z; -} - -static PyObject * -long_pow(PyObject *v, PyObject *w, PyObject *x) -{ - PyLongObject *a, *b; - PyObject *c; - PyLongObject *z, *div, *mod; - int size_b, i; - - CONVERT_BINOP(v, w, &a, &b); - if (PyLong_Check(x) || Py_None == x) { - c = x; - Py_INCREF(x); - } - else if (PyInt_Check(x)) { - c = PyLong_FromLong(PyInt_AS_LONG(x)); - } - else { - Py_DECREF(a); - Py_DECREF(b); - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - - if (c != Py_None && ((PyLongObject *)c)->ob_size == 0) { - PyErr_SetString(PyExc_ValueError, - "pow() 3rd argument cannot be 0"); - z = NULL; - goto error; - } - - size_b = b->ob_size; - if (size_b < 0) { - Py_DECREF(a); - Py_DECREF(b); - Py_DECREF(c); - if (x != Py_None) { - PyErr_SetString(PyExc_TypeError, "pow() 2nd argument " - "cannot be negative when 3rd argument specified"); - return NULL; - } - /* Return a float. This works because we know that - this calls float_pow() which converts its - arguments to double. */ - return PyFloat_Type.tp_as_number->nb_power(v, w, x); - } - z = (PyLongObject *)PyLong_FromLong(1L); - for (i = 0; i < size_b; ++i) { - digit bi = b->ob_digit[i]; - int j; - - for (j = 0; j < SHIFT; ++j) { - PyLongObject *temp; - - if (bi & 1) { - temp = (PyLongObject *)long_mul(z, a); - Py_DECREF(z); - if (c!=Py_None && temp!=NULL) { - if (l_divmod(temp,(PyLongObject *)c, - &div,&mod) < 0) { - Py_DECREF(temp); - z = NULL; - goto error; - } - Py_XDECREF(div); - Py_DECREF(temp); - temp = mod; - } - z = temp; - if (z == NULL) - break; - } - bi >>= 1; - if (bi == 0 && i+1 == size_b) - break; - temp = (PyLongObject *)long_mul(a, a); - Py_DECREF(a); - if (c!=Py_None && temp!=NULL) { - if (l_divmod(temp, (PyLongObject *)c, &div, - &mod) < 0) { - Py_DECREF(temp); - z = NULL; - goto error; - } - Py_XDECREF(div); - Py_DECREF(temp); - temp = mod; - } - a = temp; - if (a == NULL) { - Py_DECREF(z); - z = NULL; - break; - } - } - if (a == NULL || z == NULL) - break; - } - if (c!=Py_None && z!=NULL) { - if (l_divmod(z, (PyLongObject *)c, &div, &mod) < 0) { - Py_DECREF(z); - z = NULL; - } - else { - Py_XDECREF(div); - Py_DECREF(z); - z = mod; - } - } - error: - Py_XDECREF(a); - Py_DECREF(b); - Py_DECREF(c); - return (PyObject *)z; -} - -static PyObject * -long_invert(PyLongObject *v) -{ - /* Implement ~x as -(x+1) */ - PyLongObject *x; - PyLongObject *w; - w = (PyLongObject *)PyLong_FromLong(1L); - if (w == NULL) - return NULL; - x = (PyLongObject *) long_add(v, w); - Py_DECREF(w); - if (x == NULL) - return NULL; - x->ob_size = -(x->ob_size); - return (PyObject *)x; -} - -static PyObject * -long_pos(PyLongObject *v) -{ - if (PyLong_CheckExact(v)) { - Py_INCREF(v); - return (PyObject *)v; - } - else - return _PyLong_Copy(v); -} - -static PyObject * -long_neg(PyLongObject *v) -{ - PyLongObject *z; - if (v->ob_size == 0 && PyLong_CheckExact(v)) { - /* -0 == 0 */ - Py_INCREF(v); - return (PyObject *) v; - } - z = (PyLongObject *)_PyLong_Copy(v); - if (z != NULL) - z->ob_size = -(v->ob_size); - return (PyObject *)z; -} - -static PyObject * -long_abs(PyLongObject *v) -{ - if (v->ob_size < 0) - return long_neg(v); - else - return long_pos(v); -} - -static int -long_nonzero(PyLongObject *v) -{ - return ABS(v->ob_size) != 0; -} - -static PyObject * -long_rshift(PyLongObject *v, PyLongObject *w) -{ - PyLongObject *a, *b; - PyLongObject *z = NULL; - long shiftby; - int newsize, wordshift, loshift, hishift, i, j; - digit lomask, himask; - - CONVERT_BINOP((PyObject *)v, (PyObject *)w, &a, &b); - - if (a->ob_size < 0) { - /* Right shifting negative numbers is harder */ - PyLongObject *a1, *a2; - a1 = (PyLongObject *) long_invert(a); - if (a1 == NULL) - goto rshift_error; - a2 = (PyLongObject *) long_rshift(a1, b); - Py_DECREF(a1); - if (a2 == NULL) - goto rshift_error; - z = (PyLongObject *) long_invert(a2); - Py_DECREF(a2); - } - else { - - shiftby = PyLong_AsLong((PyObject *)b); - if (shiftby == -1L && PyErr_Occurred()) - goto rshift_error; - if (shiftby < 0) { - PyErr_SetString(PyExc_ValueError, - "negative shift count"); - goto rshift_error; - } - wordshift = shiftby / SHIFT; - newsize = ABS(a->ob_size) - wordshift; - if (newsize <= 0) { - z = _PyLong_New(0); - Py_DECREF(a); - Py_DECREF(b); - return (PyObject *)z; - } - loshift = shiftby % SHIFT; - hishift = SHIFT - loshift; - lomask = ((digit)1 << hishift) - 1; - himask = MASK ^ lomask; - z = _PyLong_New(newsize); - if (z == NULL) - goto rshift_error; - if (a->ob_size < 0) - z->ob_size = -(z->ob_size); - for (i = 0, j = wordshift; i < newsize; i++, j++) { - z->ob_digit[i] = (a->ob_digit[j] >> loshift) & lomask; - if (i+1 < newsize) - z->ob_digit[i] |= - (a->ob_digit[j+1] << hishift) & himask; - } - z = long_normalize(z); - } -rshift_error: - Py_DECREF(a); - Py_DECREF(b); - return (PyObject *) z; - -} - -static PyObject * -long_lshift(PyObject *v, PyObject *w) -{ - /* This version due to Tim Peters */ - PyLongObject *a, *b; - PyLongObject *z = NULL; - long shiftby; - int oldsize, newsize, wordshift, remshift, i, j; - twodigits accum; - - CONVERT_BINOP(v, w, &a, &b); - - shiftby = PyLong_AsLong((PyObject *)b); - if (shiftby == -1L && PyErr_Occurred()) - goto lshift_error; - if (shiftby < 0) { - PyErr_SetString(PyExc_ValueError, "negative shift count"); - goto lshift_error; - } - if ((long)(int)shiftby != shiftby) { - PyErr_SetString(PyExc_ValueError, - "outrageous left shift count"); - goto lshift_error; - } - /* wordshift, remshift = divmod(shiftby, SHIFT) */ - wordshift = (int)shiftby / SHIFT; - remshift = (int)shiftby - wordshift * SHIFT; - - oldsize = ABS(a->ob_size); - newsize = oldsize + wordshift; - if (remshift) - ++newsize; - z = _PyLong_New(newsize); - if (z == NULL) - goto lshift_error; - if (a->ob_size < 0) - z->ob_size = -(z->ob_size); - for (i = 0; i < wordshift; i++) - z->ob_digit[i] = 0; - accum = 0; - for (i = wordshift, j = 0; j < oldsize; i++, j++) { - accum |= (twodigits)a->ob_digit[j] << remshift; - z->ob_digit[i] = (digit)(accum & MASK); - accum >>= SHIFT; - } - if (remshift) - z->ob_digit[newsize-1] = (digit)accum; - else - assert(!accum); - z = long_normalize(z); -lshift_error: - Py_DECREF(a); - Py_DECREF(b); - return (PyObject *) z; -} - - -/* Bitwise and/xor/or operations */ - -static PyObject * -long_bitwise(PyLongObject *a, - int op, /* '&', '|', '^' */ - PyLongObject *b) -{ - digit maska, maskb; /* 0 or MASK */ - int negz; - int size_a, size_b, size_z; - PyLongObject *z; - int i; - digit diga, digb; - PyObject *v; - - if (a->ob_size < 0) { - a = (PyLongObject *) long_invert(a); - maska = MASK; - } - else { - Py_INCREF(a); - maska = 0; - } - if (b->ob_size < 0) { - b = (PyLongObject *) long_invert(b); - maskb = MASK; - } - else { - Py_INCREF(b); - maskb = 0; - } - - negz = 0; - switch (op) { - case '^': - if (maska != maskb) { - maska ^= MASK; - negz = -1; - } - break; - case '&': - if (maska && maskb) { - op = '|'; - maska ^= MASK; - maskb ^= MASK; - negz = -1; - } - break; - case '|': - if (maska || maskb) { - op = '&'; - maska ^= MASK; - maskb ^= MASK; - negz = -1; - } - break; - } - - /* JRH: The original logic here was to allocate the result value (z) - as the longer of the two operands. However, there are some cases - where the result is guaranteed to be shorter than that: AND of two - positives, OR of two negatives: use the shorter number. AND with - mixed signs: use the positive number. OR with mixed signs: use the - negative number. After the transformations above, op will be '&' - iff one of these cases applies, and mask will be non-0 for operands - whose length should be ignored. - */ - - size_a = a->ob_size; - size_b = b->ob_size; - size_z = op == '&' - ? (maska - ? size_b - : (maskb ? size_a : MIN(size_a, size_b))) - : MAX(size_a, size_b); - z = _PyLong_New(size_z); - if (a == NULL || b == NULL || z == NULL) { - Py_XDECREF(a); - Py_XDECREF(b); - Py_XDECREF(z); - return NULL; - } - - for (i = 0; i < size_z; ++i) { - diga = (i < size_a ? a->ob_digit[i] : 0) ^ maska; - digb = (i < size_b ? b->ob_digit[i] : 0) ^ maskb; - switch (op) { - case '&': z->ob_digit[i] = diga & digb; break; - case '|': z->ob_digit[i] = diga | digb; break; - case '^': z->ob_digit[i] = diga ^ digb; break; - } - } - - Py_DECREF(a); - Py_DECREF(b); - z = long_normalize(z); - if (negz == 0) - return (PyObject *) z; - v = long_invert(z); - Py_DECREF(z); - return v; -} - -static PyObject * -long_and(PyObject *v, PyObject *w) -{ - PyLongObject *a, *b; - PyObject *c; - CONVERT_BINOP(v, w, &a, &b); - c = long_bitwise(a, '&', b); - Py_DECREF(a); - Py_DECREF(b); - return c; -} - -static PyObject * -long_xor(PyObject *v, PyObject *w) -{ - PyLongObject *a, *b; - PyObject *c; - CONVERT_BINOP(v, w, &a, &b); - c = long_bitwise(a, '^', b); - Py_DECREF(a); - Py_DECREF(b); - return c; -} - -static PyObject * -long_or(PyObject *v, PyObject *w) -{ - PyLongObject *a, *b; - PyObject *c; - CONVERT_BINOP(v, w, &a, &b); - c = long_bitwise(a, '|', b); - Py_DECREF(a); - Py_DECREF(b); - return c; -} - -static int -long_coerce(PyObject **pv, PyObject **pw) -{ - if (PyInt_Check(*pw)) { - *pw = PyLong_FromLong(PyInt_AS_LONG(*pw)); - Py_INCREF(*pv); - return 0; - } - else if (PyLong_Check(*pw)) { - Py_INCREF(*pv); - Py_INCREF(*pw); - return 0; - } - return 1; /* Can't do it */ -} - -static PyObject * -long_long(PyObject *v) -{ - Py_INCREF(v); - return v; -} - -static PyObject * -long_int(PyObject *v) -{ - long x; - x = PyLong_AsLong(v); - if (PyErr_Occurred()) { - if (PyErr_ExceptionMatches(PyExc_OverflowError)) { - PyErr_Clear(); - if (PyLong_CheckExact(v)) { - Py_INCREF(v); - return v; - } - else - return _PyLong_Copy((PyLongObject *)v); - } - else - return NULL; - } - return PyInt_FromLong(x); -} - -static PyObject * -long_float(PyObject *v) -{ - double result; - result = PyLong_AsDouble(v); - if (result == -1.0 && PyErr_Occurred()) - return NULL; - return PyFloat_FromDouble(result); -} - -static PyObject * -long_oct(PyObject *v) -{ - return long_format(v, 8, 1); -} - -static PyObject * -long_hex(PyObject *v) -{ - return long_format(v, 16, 1); -} - -static PyObject * -long_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); - -static PyObject * -long_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *x = NULL; - int base = -909; /* unlikely! */ - static char *kwlist[] = {"x", "base", 0}; - - if (type != &PyLong_Type) - return long_subtype_new(type, args, kwds); /* Wimp out */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:long", kwlist, - &x, &base)) - return NULL; - if (x == NULL) - return PyLong_FromLong(0L); - if (base == -909) - return PyNumber_Long(x); - else if (PyString_Check(x)) - return PyLong_FromString(PyString_AS_STRING(x), NULL, base); -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(x)) - return PyLong_FromUnicode(PyUnicode_AS_UNICODE(x), - PyUnicode_GET_SIZE(x), - base); -#endif - else { - PyErr_SetString(PyExc_TypeError, - "long() can't convert non-string with explicit base"); - return NULL; - } -} - -/* Wimpy, slow approach to tp_new calls for subtypes of long: - first create a regular long from whatever arguments we got, - then allocate a subtype instance and initialize it from - the regular long. The regular long is then thrown away. -*/ -static PyObject * -long_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyLongObject *tmp, *new; - int i, n; - - assert(PyType_IsSubtype(type, &PyLong_Type)); - tmp = (PyLongObject *)long_new(&PyLong_Type, args, kwds); - if (tmp == NULL) - return NULL; - assert(PyLong_CheckExact(tmp)); - n = tmp->ob_size; - if (n < 0) - n = -n; - new = (PyLongObject *)type->tp_alloc(type, n); - if (new == NULL) { - Py_DECREF(tmp); - return NULL; - } - assert(PyLong_Check(new)); - new->ob_size = tmp->ob_size; - for (i = 0; i < n; i++) - new->ob_digit[i] = tmp->ob_digit[i]; - Py_DECREF(tmp); - return (PyObject *)new; -} - -static PyObject * -long_getnewargs(PyLongObject *v) -{ - return Py_BuildValue("(N)", _PyLong_Copy(v)); -} - -static PyMethodDef long_methods[] = { - {"__getnewargs__", (PyCFunction)long_getnewargs, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - -PyDoc_STRVAR(long_doc, -"long(x[, base]) -> integer\n\ -\n\ -Convert a string or number to a long integer, if possible. A floating\n\ -point argument will be truncated towards zero (this does not include a\n\ -string representation of a floating point number!) When converting a\n\ -string, use the optional base. It is an error to supply a base when\n\ -converting a non-string."); - -static PyNumberMethods long_as_number = { - (binaryfunc) long_add, /*nb_add*/ - (binaryfunc) long_sub, /*nb_subtract*/ - (binaryfunc) long_mul, /*nb_multiply*/ - (binaryfunc) long_classic_div, /*nb_divide*/ - (binaryfunc) long_mod, /*nb_remainder*/ - (binaryfunc) long_divmod, /*nb_divmod*/ - (ternaryfunc) long_pow, /*nb_power*/ - (unaryfunc) long_neg, /*nb_negative*/ - (unaryfunc) long_pos, /*tp_positive*/ - (unaryfunc) long_abs, /*tp_absolute*/ - (inquiry) long_nonzero, /*tp_nonzero*/ - (unaryfunc) long_invert, /*nb_invert*/ - (binaryfunc) long_lshift, /*nb_lshift*/ - (binaryfunc) long_rshift, /*nb_rshift*/ - (binaryfunc) long_and, /*nb_and*/ - (binaryfunc) long_xor, /*nb_xor*/ - (binaryfunc) long_or, /*nb_or*/ - (coercion) long_coerce, /*nb_coerce*/ - (unaryfunc) long_int, /*nb_int*/ - (unaryfunc) long_long, /*nb_long*/ - (unaryfunc) long_float, /*nb_float*/ - (unaryfunc) long_oct, /*nb_oct*/ - (unaryfunc) long_hex, /*nb_hex*/ - 0, /* nb_inplace_add */ - 0, /* nb_inplace_subtract */ - 0, /* nb_inplace_multiply */ - 0, /* nb_inplace_divide */ - 0, /* nb_inplace_remainder */ - 0, /* nb_inplace_power */ - 0, /* nb_inplace_lshift */ - 0, /* nb_inplace_rshift */ - 0, /* nb_inplace_and */ - 0, /* nb_inplace_xor */ - 0, /* nb_inplace_or */ - (binaryfunc)long_div, /* nb_floor_divide */ - long_true_divide, /* nb_true_divide */ - 0, /* nb_inplace_floor_divide */ - 0, /* nb_inplace_true_divide */ -}; - -PyTypeObject PyLong_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "long", /* tp_name */ - sizeof(PyLongObject) - sizeof(digit), /* tp_basicsize */ - sizeof(digit), /* tp_itemsize */ - (destructor)long_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)long_compare, /* tp_compare */ - (reprfunc)long_repr, /* tp_repr */ - &long_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)long_hash, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)long_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - long_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - long_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - long_new, /* tp_new */ - PyObject_Del, /* tp_free */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/methodobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/methodobject.c deleted file mode 100644 index 6c2f6270..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/methodobject.c +++ /dev/null @@ -1,374 +0,0 @@ - -/* Method object implementation */ - -#include "Python.h" -#include "structmember.h" - -static PyCFunctionObject *free_list = NULL; - -PyObject * -PyCFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module) -{ - PyCFunctionObject *op; - op = free_list; - if (op != NULL) { - free_list = (PyCFunctionObject *)(op->m_self); - PyObject_INIT(op, &PyCFunction_Type); - } - else { - op = PyObject_GC_New(PyCFunctionObject, &PyCFunction_Type); - if (op == NULL) - return NULL; - } - op->m_ml = ml; - Py_XINCREF(self); - op->m_self = self; - Py_XINCREF(module); - op->m_module = module; - _PyObject_GC_TRACK(op); - return (PyObject *)op; -} - -PyCFunction -PyCFunction_GetFunction(PyObject *op) -{ - if (!PyCFunction_Check(op)) { - PyErr_BadInternalCall(); - return NULL; - } - return ((PyCFunctionObject *)op) -> m_ml -> ml_meth; -} - -PyObject * -PyCFunction_GetSelf(PyObject *op) -{ - if (!PyCFunction_Check(op)) { - PyErr_BadInternalCall(); - return NULL; - } - return ((PyCFunctionObject *)op) -> m_self; -} - -int -PyCFunction_GetFlags(PyObject *op) -{ - if (!PyCFunction_Check(op)) { - PyErr_BadInternalCall(); - return -1; - } - return ((PyCFunctionObject *)op) -> m_ml -> ml_flags; -} - -PyObject * -PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) -{ - PyCFunctionObject* f = (PyCFunctionObject*)func; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - int size; - - switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC)) { - case METH_VARARGS: - if (kw == NULL || PyDict_Size(kw) == 0) - return (*meth)(self, arg); - break; - case METH_VARARGS | METH_KEYWORDS: - case METH_OLDARGS | METH_KEYWORDS: - return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); - case METH_NOARGS: - if (kw == NULL || PyDict_Size(kw) == 0) { - size = PyTuple_GET_SIZE(arg); - if (size == 0) - return (*meth)(self, NULL); - PyErr_Format(PyExc_TypeError, - "%.200s() takes no arguments (%d given)", - f->m_ml->ml_name, size); - return NULL; - } - break; - case METH_O: - if (kw == NULL || PyDict_Size(kw) == 0) { - size = PyTuple_GET_SIZE(arg); - if (size == 1) - return (*meth)(self, PyTuple_GET_ITEM(arg, 0)); - PyErr_Format(PyExc_TypeError, - "%.200s() takes exactly one argument (%d given)", - f->m_ml->ml_name, size); - return NULL; - } - break; - case METH_OLDARGS: - /* the really old style */ - if (kw == NULL || PyDict_Size(kw) == 0) { - size = PyTuple_GET_SIZE(arg); - if (size == 1) - arg = PyTuple_GET_ITEM(arg, 0); - else if (size == 0) - arg = NULL; - return (*meth)(self, arg); - } - break; - default: - PyErr_BadInternalCall(); - return NULL; - } - PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", - f->m_ml->ml_name); - return NULL; -} - -/* Methods (the standard built-in methods, that is) */ - -static void -meth_dealloc(PyCFunctionObject *m) -{ - _PyObject_GC_UNTRACK(m); - Py_XDECREF(m->m_self); - Py_XDECREF(m->m_module); - m->m_self = (PyObject *)free_list; - free_list = m; -} - -static PyObject * -meth_get__doc__(PyCFunctionObject *m, void *closure) -{ - char *doc = m->m_ml->ml_doc; - - if (doc != NULL) - return PyString_FromString(doc); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -meth_get__name__(PyCFunctionObject *m, void *closure) -{ - return PyString_FromString(m->m_ml->ml_name); -} - -static int -meth_traverse(PyCFunctionObject *m, visitproc visit, void *arg) -{ - int err; - if (m->m_self != NULL) { - err = visit(m->m_self, arg); - if (err) - return err; - } - if (m->m_module != NULL) { - err = visit(m->m_module, arg); - if (err) - return err; - } - return 0; -} - -static PyObject * -meth_get__self__(PyCFunctionObject *m, void *closure) -{ - PyObject *self; - if (PyEval_GetRestricted()) { - PyErr_SetString(PyExc_RuntimeError, - "method.__self__ not accessible in restricted mode"); - return NULL; - } - self = m->m_self; - if (self == NULL) - self = Py_None; - Py_INCREF(self); - return self; -} - -static PyGetSetDef meth_getsets [] = { - {"__doc__", (getter)meth_get__doc__, NULL, NULL}, - {"__name__", (getter)meth_get__name__, NULL, NULL}, - {"__self__", (getter)meth_get__self__, NULL, NULL}, - {0} -}; - -#define OFF(x) offsetof(PyCFunctionObject, x) - -static PyMemberDef meth_members[] = { - {"__module__", T_OBJECT, OFF(m_module), WRITE_RESTRICTED}, - {NULL} -}; - -static PyObject * -meth_repr(PyCFunctionObject *m) -{ - if (m->m_self == NULL) - return PyString_FromFormat("", - m->m_ml->ml_name); - return PyString_FromFormat("", - m->m_ml->ml_name, - m->m_self->ob_type->tp_name, - m->m_self); -} - -static int -meth_compare(PyCFunctionObject *a, PyCFunctionObject *b) -{ - if (a->m_self != b->m_self) - return (a->m_self < b->m_self) ? -1 : 1; - if (a->m_ml->ml_meth == b->m_ml->ml_meth) - return 0; - if (strcmp(a->m_ml->ml_name, b->m_ml->ml_name) < 0) - return -1; - else - return 1; -} - -static long -meth_hash(PyCFunctionObject *a) -{ - long x,y; - if (a->m_self == NULL) - x = 0; - else { - x = PyObject_Hash(a->m_self); - if (x == -1) - return -1; - } - y = _Py_HashPointer((void*)(a->m_ml->ml_meth)); - if (y == -1) - return -1; - x ^= y; - if (x == -1) - x = -2; - return x; -} - - -PyTypeObject PyCFunction_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "builtin_function_or_method", - sizeof(PyCFunctionObject), - 0, - (destructor)meth_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)meth_compare, /* tp_compare */ - (reprfunc)meth_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)meth_hash, /* tp_hash */ - PyCFunction_Call, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - 0, /* tp_doc */ - (traverseproc)meth_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - meth_members, /* tp_members */ - meth_getsets, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ -}; - -/* List all methods in a chain -- helper for findmethodinchain */ - -static PyObject * -listmethodchain(PyMethodChain *chain) -{ - PyMethodChain *c; - PyMethodDef *ml; - int i, n; - PyObject *v; - - n = 0; - for (c = chain; c != NULL; c = c->link) { - for (ml = c->methods; ml->ml_name != NULL; ml++) - n++; - } - v = PyList_New(n); - if (v == NULL) - return NULL; - i = 0; - for (c = chain; c != NULL; c = c->link) { - for (ml = c->methods; ml->ml_name != NULL; ml++) { - PyList_SetItem(v, i, PyString_FromString(ml->ml_name)); - i++; - } - } - if (PyErr_Occurred()) { - Py_DECREF(v); - return NULL; - } - PyList_Sort(v); - return v; -} - -/* Find a method in a method chain */ - -PyObject * -Py_FindMethodInChain(PyMethodChain *chain, PyObject *self, char *name) -{ - if (name[0] == '_' && name[1] == '_') { - if (strcmp(name, "__methods__") == 0) - return listmethodchain(chain); - if (strcmp(name, "__doc__") == 0) { - char *doc = self->ob_type->tp_doc; - if (doc != NULL) - return PyString_FromString(doc); - } - } - while (chain != NULL) { - PyMethodDef *ml = chain->methods; - for (; ml->ml_name != NULL; ml++) { - if (name[0] == ml->ml_name[0] && - strcmp(name+1, ml->ml_name+1) == 0) - /* XXX */ - return PyCFunction_New(ml, self); - } - chain = chain->link; - } - PyErr_SetString(PyExc_AttributeError, name); - return NULL; -} - -/* Find a method in a single method list */ - -PyObject * -Py_FindMethod(PyMethodDef *methods, PyObject *self, char *name) -{ - PyMethodChain chain; - chain.methods = methods; - chain.link = NULL; - return Py_FindMethodInChain(&chain, self, name); -} - -/* Clear out the free list */ - -void -PyCFunction_Fini(void) -{ - while (free_list) { - PyCFunctionObject *v = free_list; - free_list = (PyCFunctionObject *)(v->m_self); - PyObject_GC_Del(v); - } -} - -/* PyCFunction_New() is now just a macro that calls PyCFunction_NewEx(), - but it's part of the API so we need to keep a function around that - existing C extensions can call. -*/ - -#undef PyCFunction_New -PyAPI_FUNC(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *); - -PyObject * -PyCFunction_New(PyMethodDef *ml, PyObject *self) -{ - return PyCFunction_NewEx(ml, self, NULL); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/moduleobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/moduleobject.c deleted file mode 100644 index 31ffdc00..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/moduleobject.c +++ /dev/null @@ -1,260 +0,0 @@ - -/* Module object implementation */ - -#include "Python.h" -#include "structmember.h" - -typedef struct { - PyObject_HEAD - PyObject *md_dict; -} PyModuleObject; - -static PyMemberDef module_members[] = { - {"__dict__", T_OBJECT, offsetof(PyModuleObject, md_dict), READONLY}, - {0} -}; - -PyObject * -PyModule_New(char *name) -{ - PyModuleObject *m; - PyObject *nameobj; - m = PyObject_GC_New(PyModuleObject, &PyModule_Type); - if (m == NULL) - return NULL; - nameobj = PyString_FromString(name); - m->md_dict = PyDict_New(); - if (m->md_dict == NULL || nameobj == NULL) - goto fail; - if (PyDict_SetItemString(m->md_dict, "__name__", nameobj) != 0) - goto fail; - if (PyDict_SetItemString(m->md_dict, "__doc__", Py_None) != 0) - goto fail; - Py_DECREF(nameobj); - PyObject_GC_Track(m); - return (PyObject *)m; - - fail: - Py_XDECREF(nameobj); - Py_DECREF(m); - return NULL; -} - -PyObject * -PyModule_GetDict(PyObject *m) -{ - PyObject *d; - if (!PyModule_Check(m)) { - PyErr_BadInternalCall(); - return NULL; - } - d = ((PyModuleObject *)m) -> md_dict; - if (d == NULL) - ((PyModuleObject *)m) -> md_dict = d = PyDict_New(); - return d; -} - -char * -PyModule_GetName(PyObject *m) -{ - PyObject *d; - PyObject *nameobj; - if (!PyModule_Check(m)) { - PyErr_BadArgument(); - return NULL; - } - d = ((PyModuleObject *)m)->md_dict; - if (d == NULL || - (nameobj = PyDict_GetItemString(d, "__name__")) == NULL || - !PyString_Check(nameobj)) - { - PyErr_SetString(PyExc_SystemError, "nameless module"); - return NULL; - } - return PyString_AsString(nameobj); -} - -char * -PyModule_GetFilename(PyObject *m) -{ - PyObject *d; - PyObject *fileobj; - if (!PyModule_Check(m)) { - PyErr_BadArgument(); - return NULL; - } - d = ((PyModuleObject *)m)->md_dict; - if (d == NULL || - (fileobj = PyDict_GetItemString(d, "__file__")) == NULL || - !PyString_Check(fileobj)) - { - PyErr_SetString(PyExc_SystemError, "module filename missing"); - return NULL; - } - return PyString_AsString(fileobj); -} - -void -_PyModule_Clear(PyObject *m) -{ - /* To make the execution order of destructors for global - objects a bit more predictable, we first zap all objects - whose name starts with a single underscore, before we clear - the entire dictionary. We zap them by replacing them with - None, rather than deleting them from the dictionary, to - avoid rehashing the dictionary (to some extent). */ - - int pos; - PyObject *key, *value; - PyObject *d; - - d = ((PyModuleObject *)m)->md_dict; - if (d == NULL) - return; - - /* First, clear only names starting with a single underscore */ - pos = 0; - while (PyDict_Next(d, &pos, &key, &value)) { - if (value != Py_None && PyString_Check(key)) { - char *s = PyString_AsString(key); - if (s[0] == '_' && s[1] != '_') { - if (Py_VerboseFlag > 1) - PySys_WriteStderr("# clear[1] %s\n", s); - PyDict_SetItem(d, key, Py_None); - } - } - } - - /* Next, clear all names except for __builtins__ */ - pos = 0; - while (PyDict_Next(d, &pos, &key, &value)) { - if (value != Py_None && PyString_Check(key)) { - char *s = PyString_AsString(key); - if (s[0] != '_' || strcmp(s, "__builtins__") != 0) { - if (Py_VerboseFlag > 1) - PySys_WriteStderr("# clear[2] %s\n", s); - PyDict_SetItem(d, key, Py_None); - } - } - } - - /* Note: we leave __builtins__ in place, so that destructors - of non-global objects defined in this module can still use - builtins, in particularly 'None'. */ - -} - -/* Methods */ - -static int -module_init(PyModuleObject *m, PyObject *args, PyObject *kwds) -{ - static char *kwlist[] = {"name", "doc", NULL}; - PyObject *dict, *name = Py_None, *doc = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "S|O", kwlist, - &name, &doc)) - return -1; - dict = m->md_dict; - if (dict == NULL) { - dict = PyDict_New(); - if (dict == NULL) - return -1; - m->md_dict = dict; - } - if (PyDict_SetItemString(dict, "__name__", name) < 0) - return -1; - if (PyDict_SetItemString(dict, "__doc__", doc) < 0) - return -1; - return 0; -} - -static void -module_dealloc(PyModuleObject *m) -{ - PyObject_GC_UnTrack(m); - if (m->md_dict != NULL) { - _PyModule_Clear((PyObject *)m); - Py_DECREF(m->md_dict); - } - m->ob_type->tp_free((PyObject *)m); -} - -static PyObject * -module_repr(PyModuleObject *m) -{ - char *name; - char *filename; - - name = PyModule_GetName((PyObject *)m); - if (name == NULL) { - PyErr_Clear(); - name = "?"; - } - filename = PyModule_GetFilename((PyObject *)m); - if (filename == NULL) { - PyErr_Clear(); - return PyString_FromFormat("", name); - } - return PyString_FromFormat("", name, filename); -} - -/* We only need a traverse function, no clear function: If the module - is in a cycle, md_dict will be cleared as well, which will break - the cycle. */ -static int -module_traverse(PyModuleObject *m, visitproc visit, void *arg) -{ - if (m->md_dict != NULL) - return visit(m->md_dict, arg); - return 0; -} - -PyDoc_STRVAR(module_doc, -"module(name[, doc])\n\ -\n\ -Create a module object.\n\ -The name must be a string; the optional doc argument can have any type."); - -PyTypeObject PyModule_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "module", /* tp_name */ - sizeof(PyModuleObject), /* tp_size */ - 0, /* tp_itemsize */ - (destructor)module_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)module_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - PyObject_GenericSetAttr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - module_doc, /* tp_doc */ - (traverseproc)module_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - module_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - offsetof(PyModuleObject, md_dict), /* tp_dictoffset */ - (initproc)module_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/object.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/object.c deleted file mode 100644 index 86f4b6ac..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/object.c +++ /dev/null @@ -1,2228 +0,0 @@ - -/* Generic object operations; and implementation of None (NoObject) */ - -#include "Python.h" - -#ifdef macintosh -#include "macglue.h" -#endif - -#ifdef Py_REF_DEBUG -long _Py_RefTotal; -#endif - -int Py_DivisionWarningFlag; - -/* Object allocation routines used by NEWOBJ and NEWVAROBJ macros. - These are used by the individual routines for object creation. - Do not call them otherwise, they do not initialize the object! */ - -#ifdef Py_TRACE_REFS -/* Head of circular doubly-linked list of all objects. These are linked - * together via the _ob_prev and _ob_next members of a PyObject, which - * exist only in a Py_TRACE_REFS build. - */ -static PyObject refchain = {&refchain, &refchain}; - -/* Insert op at the front of the list of all objects. If force is true, - * op is added even if _ob_prev and _ob_next are non-NULL already. If - * force is false amd _ob_prev or _ob_next are non-NULL, do nothing. - * force should be true if and only if op points to freshly allocated, - * uninitialized memory, or you've unlinked op from the list and are - * relinking it into the front. - * Note that objects are normally added to the list via _Py_NewReference, - * which is called by PyObject_Init. Not all objects are initialized that - * way, though; exceptions include statically allocated type objects, and - * statically allocated singletons (like Py_True and Py_None). - */ -void -_Py_AddToAllObjects(PyObject *op, int force) -{ -#ifdef Py_DEBUG - if (!force) { - /* If it's initialized memory, op must be in or out of - * the list unambiguously. - */ - assert((op->_ob_prev == NULL) == (op->_ob_next == NULL)); - } -#endif - if (force || op->_ob_prev == NULL) { - op->_ob_next = refchain._ob_next; - op->_ob_prev = &refchain; - refchain._ob_next->_ob_prev = op; - refchain._ob_next = op; - } -} -#endif /* Py_TRACE_REFS */ - -#ifdef COUNT_ALLOCS -static PyTypeObject *type_list; -extern int tuple_zero_allocs, fast_tuple_allocs; -extern int quick_int_allocs, quick_neg_int_allocs; -extern int null_strings, one_strings; -void -dump_counts(void) -{ - PyTypeObject *tp; - - for (tp = type_list; tp; tp = tp->tp_next) - fprintf(stderr, "%s alloc'd: %d, freed: %d, max in use: %d\n", - tp->tp_name, tp->tp_allocs, tp->tp_frees, - tp->tp_maxalloc); - fprintf(stderr, "fast tuple allocs: %d, empty: %d\n", - fast_tuple_allocs, tuple_zero_allocs); - fprintf(stderr, "fast int allocs: pos: %d, neg: %d\n", - quick_int_allocs, quick_neg_int_allocs); - fprintf(stderr, "null strings: %d, 1-strings: %d\n", - null_strings, one_strings); -} - -PyObject * -get_counts(void) -{ - PyTypeObject *tp; - PyObject *result; - PyObject *v; - - result = PyList_New(0); - if (result == NULL) - return NULL; - for (tp = type_list; tp; tp = tp->tp_next) { - v = Py_BuildValue("(siii)", tp->tp_name, tp->tp_allocs, - tp->tp_frees, tp->tp_maxalloc); - if (v == NULL) { - Py_DECREF(result); - return NULL; - } - if (PyList_Append(result, v) < 0) { - Py_DECREF(v); - Py_DECREF(result); - return NULL; - } - Py_DECREF(v); - } - return result; -} - -void -inc_count(PyTypeObject *tp) -{ - if (tp->tp_allocs == 0) { - /* first time; insert in linked list */ - if (tp->tp_next != NULL) /* sanity check */ - Py_FatalError("XXX inc_count sanity check"); - tp->tp_next = type_list; - /* Note that as of Python 2.2, heap-allocated type objects - * can go away, but this code requires that they stay alive - * until program exit. That's why we're careful with - * refcounts here. type_list gets a new reference to tp, - * while ownership of the reference type_list used to hold - * (if any) was transferred to tp->tp_next in the line above. - * tp is thus effectively immortal after this. - */ - Py_INCREF(tp); - type_list = tp; -#ifdef Py_TRACE_REFS - /* Also insert in the doubly-linked list of all objects, - * if not already there. - */ - _Py_AddToAllObjects((PyObject *)tp, 0); -#endif - } - tp->tp_allocs++; - if (tp->tp_allocs - tp->tp_frees > tp->tp_maxalloc) - tp->tp_maxalloc = tp->tp_allocs - tp->tp_frees; -} -#endif - -#ifdef Py_REF_DEBUG -/* Log a fatal error; doesn't return. */ -void -_Py_NegativeRefcount(const char *fname, int lineno, PyObject *op) -{ - char buf[300]; - - PyOS_snprintf(buf, sizeof(buf), - "%s:%i object at %p has negative ref count %i", - fname, lineno, op, op->ob_refcnt); - Py_FatalError(buf); -} - -#endif /* Py_REF_DEBUG */ - -PyObject * -PyObject_Init(PyObject *op, PyTypeObject *tp) -{ - if (op == NULL) - return PyErr_NoMemory(); - /* Any changes should be reflected in PyObject_INIT (objimpl.h) */ - op->ob_type = tp; - _Py_NewReference(op); - return op; -} - -PyVarObject * -PyObject_InitVar(PyVarObject *op, PyTypeObject *tp, int size) -{ - if (op == NULL) - return (PyVarObject *) PyErr_NoMemory(); - /* Any changes should be reflected in PyObject_INIT_VAR */ - op->ob_size = size; - op->ob_type = tp; - _Py_NewReference((PyObject *)op); - return op; -} - -PyObject * -_PyObject_New(PyTypeObject *tp) -{ - PyObject *op; - op = (PyObject *) PyObject_MALLOC(_PyObject_SIZE(tp)); - if (op == NULL) - return PyErr_NoMemory(); - return PyObject_INIT(op, tp); -} - -PyVarObject * -_PyObject_NewVar(PyTypeObject *tp, int nitems) -{ - PyVarObject *op; - const size_t size = _PyObject_VAR_SIZE(tp, nitems); - op = (PyVarObject *) PyObject_MALLOC(size); - if (op == NULL) - return (PyVarObject *)PyErr_NoMemory(); - return PyObject_INIT_VAR(op, tp, nitems); -} - -/* for binary compatibility with 2.2 */ -#undef _PyObject_Del -void -_PyObject_Del(PyObject *op) -{ - PyObject_FREE(op); -} - -/* Implementation of PyObject_Print with recursion checking */ -static int -internal_print(PyObject *op, FILE *fp, int flags, int nesting) -{ - int ret = 0; - if (nesting > 10) { - PyErr_SetString(PyExc_RuntimeError, "print recursion"); - return -1; - } - if (PyErr_CheckSignals()) - return -1; -#ifdef USE_STACKCHECK - if (PyOS_CheckStack()) { - PyErr_SetString(PyExc_MemoryError, "stack overflow"); - return -1; - } -#endif - clearerr(fp); /* Clear any previous error condition */ - if (op == NULL) { - fprintf(fp, ""); - } - else { - if (op->ob_refcnt <= 0) - fprintf(fp, "", - op->ob_refcnt, op); - else if (op->ob_type->tp_print == NULL) { - PyObject *s; - if (flags & Py_PRINT_RAW) - s = PyObject_Str(op); - else - s = PyObject_Repr(op); - if (s == NULL) - ret = -1; - else { - ret = internal_print(s, fp, Py_PRINT_RAW, - nesting+1); - } - Py_XDECREF(s); - } - else - ret = (*op->ob_type->tp_print)(op, fp, flags); - } - if (ret == 0) { - if (ferror(fp)) { - PyErr_SetFromErrno(PyExc_IOError); - clearerr(fp); - ret = -1; - } - } - return ret; -} - -int -PyObject_Print(PyObject *op, FILE *fp, int flags) -{ - return internal_print(op, fp, flags, 0); -} - - -/* For debugging convenience. See Misc/gdbinit for some useful gdb hooks */ -void _PyObject_Dump(PyObject* op) -{ - if (op == NULL) - fprintf(stderr, "NULL\n"); - else { - fprintf(stderr, "object : "); - (void)PyObject_Print(op, stderr, 0); - fprintf(stderr, "\n" - "type : %s\n" - "refcount: %d\n" - "address : %p\n", - op->ob_type==NULL ? "NULL" : op->ob_type->tp_name, - op->ob_refcnt, - op); - } -} - -PyObject * -PyObject_Repr(PyObject *v) -{ - if (PyErr_CheckSignals()) - return NULL; -#ifdef USE_STACKCHECK - if (PyOS_CheckStack()) { - PyErr_SetString(PyExc_MemoryError, "stack overflow"); - return NULL; - } -#endif - if (v == NULL) - return PyString_FromString(""); - else if (v->ob_type->tp_repr == NULL) - return PyString_FromFormat("<%s object at %p>", - v->ob_type->tp_name, v); - else { - PyObject *res; - res = (*v->ob_type->tp_repr)(v); - if (res == NULL) - return NULL; -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(res)) { - PyObject* str; - str = PyUnicode_AsUnicodeEscapeString(res); - Py_DECREF(res); - if (str) - res = str; - else - return NULL; - } -#endif - if (!PyString_Check(res)) { - PyErr_Format(PyExc_TypeError, - "__repr__ returned non-string (type %.200s)", - res->ob_type->tp_name); - Py_DECREF(res); - return NULL; - } - return res; - } -} - -PyObject * -PyObject_Str(PyObject *v) -{ - PyObject *res; - - if (v == NULL) - return PyString_FromString(""); - if (PyString_CheckExact(v)) { - Py_INCREF(v); - return v; - } - if (v->ob_type->tp_str == NULL) - return PyObject_Repr(v); - - res = (*v->ob_type->tp_str)(v); - if (res == NULL) - return NULL; -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(res)) { - PyObject* str; - str = PyUnicode_AsEncodedString(res, NULL, NULL); - Py_DECREF(res); - if (str) - res = str; - else - return NULL; - } -#endif - if (!PyString_Check(res)) { - PyErr_Format(PyExc_TypeError, - "__str__ returned non-string (type %.200s)", - res->ob_type->tp_name); - Py_DECREF(res); - return NULL; - } - return res; -} - -#ifdef Py_USING_UNICODE -PyObject * -PyObject_Unicode(PyObject *v) -{ - PyObject *res; - - if (v == NULL) - res = PyString_FromString(""); - if (PyUnicode_CheckExact(v)) { - Py_INCREF(v); - return v; - } - if (PyUnicode_Check(v)) { - /* For a Unicode subtype that's not a Unicode object, - return a true Unicode object with the same data. */ - return PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(v), - PyUnicode_GET_SIZE(v)); - } - if (PyString_Check(v)) { - Py_INCREF(v); - res = v; - } - else { - PyObject *func; - static PyObject *unicodestr; - /* XXX As soon as we have a tp_unicode slot, we should - check this before trying the __unicode__ - method. */ - if (unicodestr == NULL) { - unicodestr= PyString_InternFromString( - "__unicode__"); - if (unicodestr == NULL) - return NULL; - } - func = PyObject_GetAttr(v, unicodestr); - if (func != NULL) { - res = PyEval_CallObject(func, (PyObject *)NULL); - Py_DECREF(func); - } - else { - PyErr_Clear(); - if (v->ob_type->tp_str != NULL) - res = (*v->ob_type->tp_str)(v); - else - res = PyObject_Repr(v); - } - } - if (res == NULL) - return NULL; - if (!PyUnicode_Check(res)) { - PyObject *str; - str = PyUnicode_FromEncodedObject(res, NULL, "strict"); - Py_DECREF(res); - if (str) - res = str; - else - return NULL; - } - return res; -} -#endif - - -/* Helper to warn about deprecated tp_compare return values. Return: - -2 for an exception; - -1 if v < w; - 0 if v == w; - 1 if v > w. - (This function cannot return 2.) -*/ -static int -adjust_tp_compare(int c) -{ - if (PyErr_Occurred()) { - if (c != -1 && c != -2) { - PyObject *t, *v, *tb; - PyErr_Fetch(&t, &v, &tb); - if (PyErr_Warn(PyExc_RuntimeWarning, - "tp_compare didn't return -1 or -2 " - "for exception") < 0) { - Py_XDECREF(t); - Py_XDECREF(v); - Py_XDECREF(tb); - } - else - PyErr_Restore(t, v, tb); - } - return -2; - } - else if (c < -1 || c > 1) { - if (PyErr_Warn(PyExc_RuntimeWarning, - "tp_compare didn't return -1, 0 or 1") < 0) - return -2; - else - return c < -1 ? -1 : 1; - } - else { - assert(c >= -1 && c <= 1); - return c; - } -} - - -/* Macro to get the tp_richcompare field of a type if defined */ -#define RICHCOMPARE(t) (PyType_HasFeature((t), Py_TPFLAGS_HAVE_RICHCOMPARE) \ - ? (t)->tp_richcompare : NULL) - -/* Map rich comparison operators to their swapped version, e.g. LT --> GT */ -static int swapped_op[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE}; - -/* Try a genuine rich comparison, returning an object. Return: - NULL for exception; - NotImplemented if this particular rich comparison is not implemented or - undefined; - some object not equal to NotImplemented if it is implemented - (this latter object may not be a Boolean). -*/ -static PyObject * -try_rich_compare(PyObject *v, PyObject *w, int op) -{ - richcmpfunc f; - PyObject *res; - - if (v->ob_type != w->ob_type && - PyType_IsSubtype(w->ob_type, v->ob_type) && - (f = RICHCOMPARE(w->ob_type)) != NULL) { - res = (*f)(w, v, swapped_op[op]); - if (res != Py_NotImplemented) - return res; - Py_DECREF(res); - } - if ((f = RICHCOMPARE(v->ob_type)) != NULL) { - res = (*f)(v, w, op); - if (res != Py_NotImplemented) - return res; - Py_DECREF(res); - } - if ((f = RICHCOMPARE(w->ob_type)) != NULL) { - return (*f)(w, v, swapped_op[op]); - } - res = Py_NotImplemented; - Py_INCREF(res); - return res; -} - -/* Try a genuine rich comparison, returning an int. Return: - -1 for exception (including the case where try_rich_compare() returns an - object that's not a Boolean); - 0 if the outcome is false; - 1 if the outcome is true; - 2 if this particular rich comparison is not implemented or undefined. -*/ -static int -try_rich_compare_bool(PyObject *v, PyObject *w, int op) -{ - PyObject *res; - int ok; - - if (RICHCOMPARE(v->ob_type) == NULL && RICHCOMPARE(w->ob_type) == NULL) - return 2; /* Shortcut, avoid INCREF+DECREF */ - res = try_rich_compare(v, w, op); - if (res == NULL) - return -1; - if (res == Py_NotImplemented) { - Py_DECREF(res); - return 2; - } - ok = PyObject_IsTrue(res); - Py_DECREF(res); - return ok; -} - -/* Try rich comparisons to determine a 3-way comparison. Return: - -2 for an exception; - -1 if v < w; - 0 if v == w; - 1 if v > w; - 2 if this particular rich comparison is not implemented or undefined. -*/ -static int -try_rich_to_3way_compare(PyObject *v, PyObject *w) -{ - static struct { int op; int outcome; } tries[3] = { - /* Try this operator, and if it is true, use this outcome: */ - {Py_EQ, 0}, - {Py_LT, -1}, - {Py_GT, 1}, - }; - int i; - - if (RICHCOMPARE(v->ob_type) == NULL && RICHCOMPARE(w->ob_type) == NULL) - return 2; /* Shortcut */ - - for (i = 0; i < 3; i++) { - switch (try_rich_compare_bool(v, w, tries[i].op)) { - case -1: - return -2; - case 1: - return tries[i].outcome; - } - } - - return 2; -} - -/* Try a 3-way comparison, returning an int. Return: - -2 for an exception; - -1 if v < w; - 0 if v == w; - 1 if v > w; - 2 if this particular 3-way comparison is not implemented or undefined. -*/ -static int -try_3way_compare(PyObject *v, PyObject *w) -{ - int c; - cmpfunc f; - - /* Comparisons involving instances are given to instance_compare, - which has the same return conventions as this function. */ - - f = v->ob_type->tp_compare; - if (PyInstance_Check(v)) - return (*f)(v, w); - if (PyInstance_Check(w)) - return (*w->ob_type->tp_compare)(v, w); - - /* If both have the same (non-NULL) tp_compare, use it. */ - if (f != NULL && f == w->ob_type->tp_compare) { - c = (*f)(v, w); - return adjust_tp_compare(c); - } - - /* If either tp_compare is _PyObject_SlotCompare, that's safe. */ - if (f == _PyObject_SlotCompare || - w->ob_type->tp_compare == _PyObject_SlotCompare) - return _PyObject_SlotCompare(v, w); - - /* Try coercion; if it fails, give up */ - c = PyNumber_CoerceEx(&v, &w); - if (c < 0) - return -2; - if (c > 0) - return 2; - - /* Try v's comparison, if defined */ - if ((f = v->ob_type->tp_compare) != NULL) { - c = (*f)(v, w); - Py_DECREF(v); - Py_DECREF(w); - return adjust_tp_compare(c); - } - - /* Try w's comparison, if defined */ - if ((f = w->ob_type->tp_compare) != NULL) { - c = (*f)(w, v); /* swapped! */ - Py_DECREF(v); - Py_DECREF(w); - c = adjust_tp_compare(c); - if (c >= -1) - return -c; /* Swapped! */ - else - return c; - } - - /* No comparison defined */ - Py_DECREF(v); - Py_DECREF(w); - return 2; -} - -/* Final fallback 3-way comparison, returning an int. Return: - -2 if an error occurred; - -1 if v < w; - 0 if v == w; - 1 if v > w. -*/ -static int -default_3way_compare(PyObject *v, PyObject *w) -{ - int c; - char *vname, *wname; - - if (v->ob_type == w->ob_type) { - /* When comparing these pointers, they must be cast to - * integer types (i.e. Py_uintptr_t, our spelling of C9X's - * uintptr_t). ANSI specifies that pointer compares other - * than == and != to non-related structures are undefined. - */ - Py_uintptr_t vv = (Py_uintptr_t)v; - Py_uintptr_t ww = (Py_uintptr_t)w; - return (vv < ww) ? -1 : (vv > ww) ? 1 : 0; - } - -#ifdef Py_USING_UNICODE - /* Special case for Unicode */ - if (PyUnicode_Check(v) || PyUnicode_Check(w)) { - c = PyUnicode_Compare(v, w); - if (!PyErr_Occurred()) - return c; - /* TypeErrors are ignored: if Unicode coercion fails due - to one of the arguments not having the right type, we - continue as defined by the coercion protocol (see - above). Luckily, decoding errors are reported as - ValueErrors and are not masked by this technique. */ - if (!PyErr_ExceptionMatches(PyExc_TypeError)) - return -2; - PyErr_Clear(); - } -#endif - - /* None is smaller than anything */ - if (v == Py_None) - return -1; - if (w == Py_None) - return 1; - - /* different type: compare type names; numbers are smaller */ - if (PyNumber_Check(v)) - vname = ""; - else - vname = v->ob_type->tp_name; - if (PyNumber_Check(w)) - wname = ""; - else - wname = w->ob_type->tp_name; - c = strcmp(vname, wname); - if (c < 0) - return -1; - if (c > 0) - return 1; - /* Same type name, or (more likely) incomparable numeric types */ - return ((Py_uintptr_t)(v->ob_type) < ( - Py_uintptr_t)(w->ob_type)) ? -1 : 1; -} - -#define CHECK_TYPES(o) PyType_HasFeature((o)->ob_type, Py_TPFLAGS_CHECKTYPES) - -/* Do a 3-way comparison, by hook or by crook. Return: - -2 for an exception (but see below); - -1 if v < w; - 0 if v == w; - 1 if v > w; - BUT: if the object implements a tp_compare function, it returns - whatever this function returns (whether with an exception or not). -*/ -static int -do_cmp(PyObject *v, PyObject *w) -{ - int c; - cmpfunc f; - - if (v->ob_type == w->ob_type - && (f = v->ob_type->tp_compare) != NULL) { - c = (*f)(v, w); - if (PyInstance_Check(v)) { - /* Instance tp_compare has a different signature. - But if it returns undefined we fall through. */ - if (c != 2) - return c; - /* Else fall through to try_rich_to_3way_compare() */ - } - else - return adjust_tp_compare(c); - } - /* We only get here if one of the following is true: - a) v and w have different types - b) v and w have the same type, which doesn't have tp_compare - c) v and w are instances, and either __cmp__ is not defined or - __cmp__ returns NotImplemented - */ - c = try_rich_to_3way_compare(v, w); - if (c < 2) - return c; - c = try_3way_compare(v, w); - if (c < 2) - return c; - return default_3way_compare(v, w); -} - -/* compare_nesting is incremented before calling compare (for - some types) and decremented on exit. If the count exceeds the - nesting limit, enable code to detect circular data structures. - - This is a tunable parameter that should only affect the performance - of comparisons, nothing else. Setting it high makes comparing deeply - nested non-cyclical data structures faster, but makes comparing cyclical - data structures slower. -*/ -#define NESTING_LIMIT 20 - -static int compare_nesting = 0; - -static PyObject* -get_inprogress_dict(void) -{ - static PyObject *key; - PyObject *tstate_dict, *inprogress; - - if (key == NULL) { - key = PyString_InternFromString("cmp_state"); - if (key == NULL) - return NULL; - } - - tstate_dict = PyThreadState_GetDict(); - if (tstate_dict == NULL) { - PyErr_BadInternalCall(); - return NULL; - } - - inprogress = PyDict_GetItem(tstate_dict, key); - if (inprogress == NULL) { - inprogress = PyDict_New(); - if (inprogress == NULL) - return NULL; - if (PyDict_SetItem(tstate_dict, key, inprogress) == -1) { - Py_DECREF(inprogress); - return NULL; - } - Py_DECREF(inprogress); - } - - return inprogress; -} - -/* If the comparison "v op w" is already in progress in this thread, returns - * a borrowed reference to Py_None (the caller must not decref). - * If it's not already in progress, returns "a token" which must eventually - * be passed to delete_token(). The caller must not decref this either - * (delete_token decrefs it). The token must not survive beyond any point - * where v or w may die. - * If an error occurs (out-of-memory), returns NULL. - */ -static PyObject * -check_recursion(PyObject *v, PyObject *w, int op) -{ - PyObject *inprogress; - PyObject *token; - Py_uintptr_t iv = (Py_uintptr_t)v; - Py_uintptr_t iw = (Py_uintptr_t)w; - PyObject *x, *y, *z; - - inprogress = get_inprogress_dict(); - if (inprogress == NULL) - return NULL; - - token = PyTuple_New(3); - if (token == NULL) - return NULL; - - if (iv <= iw) { - PyTuple_SET_ITEM(token, 0, x = PyLong_FromVoidPtr((void *)v)); - PyTuple_SET_ITEM(token, 1, y = PyLong_FromVoidPtr((void *)w)); - if (op >= 0) - op = swapped_op[op]; - } else { - PyTuple_SET_ITEM(token, 0, x = PyLong_FromVoidPtr((void *)w)); - PyTuple_SET_ITEM(token, 1, y = PyLong_FromVoidPtr((void *)v)); - } - PyTuple_SET_ITEM(token, 2, z = PyInt_FromLong((long)op)); - if (x == NULL || y == NULL || z == NULL) { - Py_DECREF(token); - return NULL; - } - - if (PyDict_GetItem(inprogress, token) != NULL) { - Py_DECREF(token); - return Py_None; /* Without INCREF! */ - } - - if (PyDict_SetItem(inprogress, token, token) < 0) { - Py_DECREF(token); - return NULL; - } - - return token; -} - -static void -delete_token(PyObject *token) -{ - PyObject *inprogress; - - if (token == NULL || token == Py_None) - return; - inprogress = get_inprogress_dict(); - if (inprogress == NULL) - PyErr_Clear(); - else - PyDict_DelItem(inprogress, token); - Py_DECREF(token); -} - -/* Compare v to w. Return - -1 if v < w or exception (PyErr_Occurred() true in latter case). - 0 if v == w. - 1 if v > w. - XXX The docs (C API manual) say the return value is undefined in case - XXX of error. -*/ -int -PyObject_Compare(PyObject *v, PyObject *w) -{ - PyTypeObject *vtp; - int result; - -#if defined(USE_STACKCHECK) - if (PyOS_CheckStack()) { - PyErr_SetString(PyExc_MemoryError, "Stack overflow"); - return -1; - } -#endif - if (v == NULL || w == NULL) { - PyErr_BadInternalCall(); - return -1; - } - if (v == w) - return 0; - vtp = v->ob_type; - compare_nesting++; - if (compare_nesting > NESTING_LIMIT && - (vtp->tp_as_mapping || vtp->tp_as_sequence) && - !PyString_CheckExact(v) && - !PyTuple_CheckExact(v)) { - /* try to detect circular data structures */ - PyObject *token = check_recursion(v, w, -1); - - if (token == NULL) { - result = -1; - } - else if (token == Py_None) { - /* already comparing these objects. assume - they're equal until shown otherwise */ - result = 0; - } - else { - result = do_cmp(v, w); - delete_token(token); - } - } - else { - result = do_cmp(v, w); - } - compare_nesting--; - return result < 0 ? -1 : result; -} - -/* Return (new reference to) Py_True or Py_False. */ -static PyObject * -convert_3way_to_object(int op, int c) -{ - PyObject *result; - switch (op) { - case Py_LT: c = c < 0; break; - case Py_LE: c = c <= 0; break; - case Py_EQ: c = c == 0; break; - case Py_NE: c = c != 0; break; - case Py_GT: c = c > 0; break; - case Py_GE: c = c >= 0; break; - } - result = c ? Py_True : Py_False; - Py_INCREF(result); - return result; -} - -/* We want a rich comparison but don't have one. Try a 3-way cmp instead. - Return - NULL if error - Py_True if v op w - Py_False if not (v op w) -*/ -static PyObject * -try_3way_to_rich_compare(PyObject *v, PyObject *w, int op) -{ - int c; - - c = try_3way_compare(v, w); - if (c >= 2) - c = default_3way_compare(v, w); - if (c <= -2) - return NULL; - return convert_3way_to_object(op, c); -} - -/* Do rich comparison on v and w. Return - NULL if error - Else a new reference to an object other than Py_NotImplemented, usually(?): - Py_True if v op w - Py_False if not (v op w) -*/ -static PyObject * -do_richcmp(PyObject *v, PyObject *w, int op) -{ - PyObject *res; - - res = try_rich_compare(v, w, op); - if (res != Py_NotImplemented) - return res; - Py_DECREF(res); - - return try_3way_to_rich_compare(v, w, op); -} - -/* Return: - NULL for exception; - some object not equal to NotImplemented if it is implemented - (this latter object may not be a Boolean). -*/ -PyObject * -PyObject_RichCompare(PyObject *v, PyObject *w, int op) -{ - PyObject *res; - - assert(Py_LT <= op && op <= Py_GE); - - compare_nesting++; - if (compare_nesting > NESTING_LIMIT && - (v->ob_type->tp_as_mapping || v->ob_type->tp_as_sequence) && - !PyString_CheckExact(v) && - !PyTuple_CheckExact(v)) { - /* try to detect circular data structures */ - PyObject *token = check_recursion(v, w, op); - if (token == NULL) { - res = NULL; - goto Done; - } - else if (token == Py_None) { - /* already comparing these objects with this operator. - assume they're equal until shown otherwise */ - if (op == Py_EQ) - res = Py_True; - else if (op == Py_NE) - res = Py_False; - else { - PyErr_SetString(PyExc_ValueError, - "can't order recursive values"); - res = NULL; - } - Py_XINCREF(res); - } - else { - res = do_richcmp(v, w, op); - delete_token(token); - } - goto Done; - } - - /* No nesting extremism. - If the types are equal, and not old-style instances, try to - get out cheap (don't bother with coercions etc.). */ - if (v->ob_type == w->ob_type && !PyInstance_Check(v)) { - cmpfunc fcmp; - richcmpfunc frich = RICHCOMPARE(v->ob_type); - /* If the type has richcmp, try it first. try_rich_compare - tries it two-sided, which is not needed since we've a - single type only. */ - if (frich != NULL) { - res = (*frich)(v, w, op); - if (res != Py_NotImplemented) - goto Done; - Py_DECREF(res); - } - /* No richcmp, or this particular richmp not implemented. - Try 3-way cmp. */ - fcmp = v->ob_type->tp_compare; - if (fcmp != NULL) { - int c = (*fcmp)(v, w); - c = adjust_tp_compare(c); - if (c == -2) { - res = NULL; - goto Done; - } - res = convert_3way_to_object(op, c); - goto Done; - } - } - - /* Fast path not taken, or couldn't deliver a useful result. */ - res = do_richcmp(v, w, op); -Done: - compare_nesting--; - return res; -} - -/* Return -1 if error; 1 if v op w; 0 if not (v op w). */ -int -PyObject_RichCompareBool(PyObject *v, PyObject *w, int op) -{ - PyObject *res = PyObject_RichCompare(v, w, op); - int ok; - - if (res == NULL) - return -1; - if (PyBool_Check(res)) - ok = (res == Py_True); - else - ok = PyObject_IsTrue(res); - Py_DECREF(res); - return ok; -} - -/* Set of hash utility functions to help maintaining the invariant that - iff a==b then hash(a)==hash(b) - - All the utility functions (_Py_Hash*()) return "-1" to signify an error. -*/ - -long -_Py_HashDouble(double v) -{ - double intpart, fractpart; - int expo; - long hipart; - long x; /* the final hash value */ - /* This is designed so that Python numbers of different types - * that compare equal hash to the same value; otherwise comparisons - * of mapping keys will turn out weird. - */ - -#ifdef MPW /* MPW C modf expects pointer to extended as second argument */ -{ - extended e; - fractpart = modf(v, &e); - intpart = e; -} -#else - fractpart = modf(v, &intpart); -#endif - if (fractpart == 0.0) { - /* This must return the same hash as an equal int or long. */ - if (intpart > LONG_MAX || -intpart > LONG_MAX) { - /* Convert to long and use its hash. */ - PyObject *plong; /* converted to Python long */ - if (Py_IS_INFINITY(intpart)) - /* can't convert to long int -- arbitrary */ - v = v < 0 ? -271828.0 : 314159.0; - plong = PyLong_FromDouble(v); - if (plong == NULL) - return -1; - x = PyObject_Hash(plong); - Py_DECREF(plong); - return x; - } - /* Fits in a C long == a Python int, so is its own hash. */ - x = (long)intpart; - if (x == -1) - x = -2; - return x; - } - /* The fractional part is non-zero, so we don't have to worry about - * making this match the hash of some other type. - * Use frexp to get at the bits in the double. - * Since the VAX D double format has 56 mantissa bits, which is the - * most of any double format in use, each of these parts may have as - * many as (but no more than) 56 significant bits. - * So, assuming sizeof(long) >= 4, each part can be broken into two - * longs; frexp and multiplication are used to do that. - * Also, since the Cray double format has 15 exponent bits, which is - * the most of any double format in use, shifting the exponent field - * left by 15 won't overflow a long (again assuming sizeof(long) >= 4). - */ - v = frexp(v, &expo); - v *= 2147483648.0; /* 2**31 */ - hipart = (long)v; /* take the top 32 bits */ - v = (v - (double)hipart) * 2147483648.0; /* get the next 32 bits */ - x = hipart + (long)v + (expo << 15); - if (x == -1) - x = -2; - return x; -} - -long -_Py_HashPointer(void *p) -{ -#if SIZEOF_LONG >= SIZEOF_VOID_P - return (long)p; -#else - /* convert to a Python long and hash that */ - PyObject* longobj; - long x; - - if ((longobj = PyLong_FromVoidPtr(p)) == NULL) { - x = -1; - goto finally; - } - x = PyObject_Hash(longobj); - -finally: - Py_XDECREF(longobj); - return x; -#endif -} - - -long -PyObject_Hash(PyObject *v) -{ - PyTypeObject *tp = v->ob_type; - if (tp->tp_hash != NULL) - return (*tp->tp_hash)(v); - if (tp->tp_compare == NULL && RICHCOMPARE(tp) == NULL) { - return _Py_HashPointer(v); /* Use address as hash value */ - } - /* If there's a cmp but no hash defined, the object can't be hashed */ - PyErr_SetString(PyExc_TypeError, "unhashable type"); - return -1; -} - -PyObject * -PyObject_GetAttrString(PyObject *v, char *name) -{ - PyObject *w, *res; - - if (v->ob_type->tp_getattr != NULL) - return (*v->ob_type->tp_getattr)(v, name); - w = PyString_InternFromString(name); - if (w == NULL) - return NULL; - res = PyObject_GetAttr(v, w); - Py_XDECREF(w); - return res; -} - -int -PyObject_HasAttrString(PyObject *v, char *name) -{ - PyObject *res = PyObject_GetAttrString(v, name); - if (res != NULL) { - Py_DECREF(res); - return 1; - } - PyErr_Clear(); - return 0; -} - -int -PyObject_SetAttrString(PyObject *v, char *name, PyObject *w) -{ - PyObject *s; - int res; - - if (v->ob_type->tp_setattr != NULL) - return (*v->ob_type->tp_setattr)(v, name, w); - s = PyString_InternFromString(name); - if (s == NULL) - return -1; - res = PyObject_SetAttr(v, s, w); - Py_XDECREF(s); - return res; -} - -PyObject * -PyObject_GetAttr(PyObject *v, PyObject *name) -{ - PyTypeObject *tp = v->ob_type; - - if (!PyString_Check(name)) { -#ifdef Py_USING_UNICODE - /* The Unicode to string conversion is done here because the - existing tp_getattro slots expect a string object as name - and we wouldn't want to break those. */ - if (PyUnicode_Check(name)) { - name = _PyUnicode_AsDefaultEncodedString(name, NULL); - if (name == NULL) - return NULL; - } - else -#endif - { - PyErr_SetString(PyExc_TypeError, - "attribute name must be string"); - return NULL; - } - } - if (tp->tp_getattro != NULL) - return (*tp->tp_getattro)(v, name); - if (tp->tp_getattr != NULL) - return (*tp->tp_getattr)(v, PyString_AS_STRING(name)); - PyErr_Format(PyExc_AttributeError, - "'%.50s' object has no attribute '%.400s'", - tp->tp_name, PyString_AS_STRING(name)); - return NULL; -} - -int -PyObject_HasAttr(PyObject *v, PyObject *name) -{ - PyObject *res = PyObject_GetAttr(v, name); - if (res != NULL) { - Py_DECREF(res); - return 1; - } - PyErr_Clear(); - return 0; -} - -int -PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value) -{ - PyTypeObject *tp = v->ob_type; - int err; - - if (!PyString_Check(name)){ -#ifdef Py_USING_UNICODE - /* The Unicode to string conversion is done here because the - existing tp_setattro slots expect a string object as name - and we wouldn't want to break those. */ - if (PyUnicode_Check(name)) { - name = PyUnicode_AsEncodedString(name, NULL, NULL); - if (name == NULL) - return -1; - } - else -#endif - { - PyErr_SetString(PyExc_TypeError, - "attribute name must be string"); - return -1; - } - } - else - Py_INCREF(name); - - PyString_InternInPlace(&name); - if (tp->tp_setattro != NULL) { - err = (*tp->tp_setattro)(v, name, value); - Py_DECREF(name); - return err; - } - if (tp->tp_setattr != NULL) { - err = (*tp->tp_setattr)(v, PyString_AS_STRING(name), value); - Py_DECREF(name); - return err; - } - Py_DECREF(name); - if (tp->tp_getattr == NULL && tp->tp_getattro == NULL) - PyErr_Format(PyExc_TypeError, - "'%.100s' object has no attributes " - "(%s .%.100s)", - tp->tp_name, - value==NULL ? "del" : "assign to", - PyString_AS_STRING(name)); - else - PyErr_Format(PyExc_TypeError, - "'%.100s' object has only read-only attributes " - "(%s .%.100s)", - tp->tp_name, - value==NULL ? "del" : "assign to", - PyString_AS_STRING(name)); - return -1; -} - -/* Helper to get a pointer to an object's __dict__ slot, if any */ - -PyObject ** -_PyObject_GetDictPtr(PyObject *obj) -{ - long dictoffset; - PyTypeObject *tp = obj->ob_type; - - if (!(tp->tp_flags & Py_TPFLAGS_HAVE_CLASS)) - return NULL; - dictoffset = tp->tp_dictoffset; - if (dictoffset == 0) - return NULL; - if (dictoffset < 0) { - int tsize; - size_t size; - - tsize = ((PyVarObject *)obj)->ob_size; - if (tsize < 0) - tsize = -tsize; - size = _PyObject_VAR_SIZE(tp, tsize); - - dictoffset += (long)size; - assert(dictoffset > 0); - assert(dictoffset % SIZEOF_VOID_P == 0); - } - return (PyObject **) ((char *)obj + dictoffset); -} - -/* Generic GetAttr functions - put these in your tp_[gs]etattro slot */ - -PyObject * -PyObject_SelfIter(PyObject *obj) -{ - Py_INCREF(obj); - return obj; -} - -PyObject * -PyObject_GenericGetAttr(PyObject *obj, PyObject *name) -{ - PyTypeObject *tp = obj->ob_type; - PyObject *descr = NULL; - PyObject *res = NULL; - descrgetfunc f; - long dictoffset; - PyObject **dictptr; - - if (!PyString_Check(name)){ -#ifdef Py_USING_UNICODE - /* The Unicode to string conversion is done here because the - existing tp_setattro slots expect a string object as name - and we wouldn't want to break those. */ - if (PyUnicode_Check(name)) { - name = PyUnicode_AsEncodedString(name, NULL, NULL); - if (name == NULL) - return NULL; - } - else -#endif - { - PyErr_SetString(PyExc_TypeError, - "attribute name must be string"); - return NULL; - } - } - else - Py_INCREF(name); - - if (tp->tp_dict == NULL) { - if (PyType_Ready(tp) < 0) - goto done; - } - - /* Inline _PyType_Lookup */ - { - int i, n; - PyObject *mro, *base, *dict; - - /* Look in tp_dict of types in MRO */ - mro = tp->tp_mro; - assert(mro != NULL); - assert(PyTuple_Check(mro)); - n = PyTuple_GET_SIZE(mro); - for (i = 0; i < n; i++) { - base = PyTuple_GET_ITEM(mro, i); - if (PyClass_Check(base)) - dict = ((PyClassObject *)base)->cl_dict; - else { - assert(PyType_Check(base)); - dict = ((PyTypeObject *)base)->tp_dict; - } - assert(dict && PyDict_Check(dict)); - descr = PyDict_GetItem(dict, name); - if (descr != NULL) - break; - } - } - - f = NULL; - if (descr != NULL && - PyType_HasFeature(descr->ob_type, Py_TPFLAGS_HAVE_CLASS)) { - f = descr->ob_type->tp_descr_get; - if (f != NULL && PyDescr_IsData(descr)) { - res = f(descr, obj, (PyObject *)obj->ob_type); - goto done; - } - } - - /* Inline _PyObject_GetDictPtr */ - dictoffset = tp->tp_dictoffset; - if (dictoffset != 0) { - PyObject *dict; - if (dictoffset < 0) { - int tsize; - size_t size; - - tsize = ((PyVarObject *)obj)->ob_size; - if (tsize < 0) - tsize = -tsize; - size = _PyObject_VAR_SIZE(tp, tsize); - - dictoffset += (long)size; - assert(dictoffset > 0); - assert(dictoffset % SIZEOF_VOID_P == 0); - } - dictptr = (PyObject **) ((char *)obj + dictoffset); - dict = *dictptr; - if (dict != NULL) { - res = PyDict_GetItem(dict, name); - if (res != NULL) { - Py_INCREF(res); - goto done; - } - } - } - - if (f != NULL) { - res = f(descr, obj, (PyObject *)obj->ob_type); - goto done; - } - - if (descr != NULL) { - Py_INCREF(descr); - res = descr; - goto done; - } - - PyErr_Format(PyExc_AttributeError, - "'%.50s' object has no attribute '%.400s'", - tp->tp_name, PyString_AS_STRING(name)); - done: - Py_DECREF(name); - return res; -} - -int -PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value) -{ - PyTypeObject *tp = obj->ob_type; - PyObject *descr; - descrsetfunc f; - PyObject **dictptr; - int res = -1; - - if (!PyString_Check(name)){ -#ifdef Py_USING_UNICODE - /* The Unicode to string conversion is done here because the - existing tp_setattro slots expect a string object as name - and we wouldn't want to break those. */ - if (PyUnicode_Check(name)) { - name = PyUnicode_AsEncodedString(name, NULL, NULL); - if (name == NULL) - return -1; - } - else -#endif - { - PyErr_SetString(PyExc_TypeError, - "attribute name must be string"); - return -1; - } - } - else - Py_INCREF(name); - - if (tp->tp_dict == NULL) { - if (PyType_Ready(tp) < 0) - goto done; - } - - descr = _PyType_Lookup(tp, name); - f = NULL; - if (descr != NULL && - PyType_HasFeature(descr->ob_type, Py_TPFLAGS_HAVE_CLASS)) { - f = descr->ob_type->tp_descr_set; - if (f != NULL && PyDescr_IsData(descr)) { - res = f(descr, obj, value); - goto done; - } - } - - dictptr = _PyObject_GetDictPtr(obj); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL && value != NULL) { - dict = PyDict_New(); - if (dict == NULL) - goto done; - *dictptr = dict; - } - if (dict != NULL) { - if (value == NULL) - res = PyDict_DelItem(dict, name); - else - res = PyDict_SetItem(dict, name, value); - if (res < 0 && PyErr_ExceptionMatches(PyExc_KeyError)) - PyErr_SetObject(PyExc_AttributeError, name); - goto done; - } - } - - if (f != NULL) { - res = f(descr, obj, value); - goto done; - } - - if (descr == NULL) { - PyErr_Format(PyExc_AttributeError, - "'%.50s' object has no attribute '%.400s'", - tp->tp_name, PyString_AS_STRING(name)); - goto done; - } - - PyErr_Format(PyExc_AttributeError, - "'%.50s' object attribute '%.400s' is read-only", - tp->tp_name, PyString_AS_STRING(name)); - done: - Py_DECREF(name); - return res; -} - -/* Test a value used as condition, e.g., in a for or if statement. - Return -1 if an error occurred */ - -int -PyObject_IsTrue(PyObject *v) -{ - int res; - if (v == Py_True) - return 1; - if (v == Py_False) - return 0; - if (v == Py_None) - return 0; - else if (v->ob_type->tp_as_number != NULL && - v->ob_type->tp_as_number->nb_nonzero != NULL) - res = (*v->ob_type->tp_as_number->nb_nonzero)(v); - else if (v->ob_type->tp_as_mapping != NULL && - v->ob_type->tp_as_mapping->mp_length != NULL) - res = (*v->ob_type->tp_as_mapping->mp_length)(v); - else if (v->ob_type->tp_as_sequence != NULL && - v->ob_type->tp_as_sequence->sq_length != NULL) - res = (*v->ob_type->tp_as_sequence->sq_length)(v); - else - return 1; - return (res > 0) ? 1 : res; -} - -/* equivalent of 'not v' - Return -1 if an error occurred */ - -int -PyObject_Not(PyObject *v) -{ - int res; - res = PyObject_IsTrue(v); - if (res < 0) - return res; - return res == 0; -} - -/* Coerce two numeric types to the "larger" one. - Increment the reference count on each argument. - Return value: - -1 if an error occurred; - 0 if the coercion succeeded (and then the reference counts are increased); - 1 if no coercion is possible (and no error is raised). -*/ -int -PyNumber_CoerceEx(PyObject **pv, PyObject **pw) -{ - register PyObject *v = *pv; - register PyObject *w = *pw; - int res; - - /* Shortcut only for old-style types */ - if (v->ob_type == w->ob_type && - !PyType_HasFeature(v->ob_type, Py_TPFLAGS_CHECKTYPES)) - { - Py_INCREF(v); - Py_INCREF(w); - return 0; - } - if (v->ob_type->tp_as_number && v->ob_type->tp_as_number->nb_coerce) { - res = (*v->ob_type->tp_as_number->nb_coerce)(pv, pw); - if (res <= 0) - return res; - } - if (w->ob_type->tp_as_number && w->ob_type->tp_as_number->nb_coerce) { - res = (*w->ob_type->tp_as_number->nb_coerce)(pw, pv); - if (res <= 0) - return res; - } - return 1; -} - -/* Coerce two numeric types to the "larger" one. - Increment the reference count on each argument. - Return -1 and raise an exception if no coercion is possible - (and then no reference count is incremented). -*/ -int -PyNumber_Coerce(PyObject **pv, PyObject **pw) -{ - int err = PyNumber_CoerceEx(pv, pw); - if (err <= 0) - return err; - PyErr_SetString(PyExc_TypeError, "number coercion failed"); - return -1; -} - - -/* Test whether an object can be called */ - -int -PyCallable_Check(PyObject *x) -{ - if (x == NULL) - return 0; - if (PyInstance_Check(x)) { - PyObject *call = PyObject_GetAttrString(x, "__call__"); - if (call == NULL) { - PyErr_Clear(); - return 0; - } - /* Could test recursively but don't, for fear of endless - recursion if some joker sets self.__call__ = self */ - Py_DECREF(call); - return 1; - } - else { - return x->ob_type->tp_call != NULL; - } -} - -/* Helper for PyObject_Dir. - Merge the __dict__ of aclass into dict, and recursively also all - the __dict__s of aclass's base classes. The order of merging isn't - defined, as it's expected that only the final set of dict keys is - interesting. - Return 0 on success, -1 on error. -*/ - -static int -merge_class_dict(PyObject* dict, PyObject* aclass) -{ - PyObject *classdict; - PyObject *bases; - - assert(PyDict_Check(dict)); - assert(aclass); - - /* Merge in the type's dict (if any). */ - classdict = PyObject_GetAttrString(aclass, "__dict__"); - if (classdict == NULL) - PyErr_Clear(); - else { - int status = PyDict_Update(dict, classdict); - Py_DECREF(classdict); - if (status < 0) - return -1; - } - - /* Recursively merge in the base types' (if any) dicts. */ - bases = PyObject_GetAttrString(aclass, "__bases__"); - if (bases == NULL) - PyErr_Clear(); - else { - /* We have no guarantee that bases is a real tuple */ - int i, n; - n = PySequence_Size(bases); /* This better be right */ - if (n < 0) - PyErr_Clear(); - else { - for (i = 0; i < n; i++) { - int status; - PyObject *base = PySequence_GetItem(bases, i); - if (base == NULL) { - Py_DECREF(bases); - return -1; - } - status = merge_class_dict(dict, base); - Py_DECREF(base); - if (status < 0) { - Py_DECREF(bases); - return -1; - } - } - } - Py_DECREF(bases); - } - return 0; -} - -/* Helper for PyObject_Dir. - If obj has an attr named attrname that's a list, merge its string - elements into keys of dict. - Return 0 on success, -1 on error. Errors due to not finding the attr, - or the attr not being a list, are suppressed. -*/ - -static int -merge_list_attr(PyObject* dict, PyObject* obj, char *attrname) -{ - PyObject *list; - int result = 0; - - assert(PyDict_Check(dict)); - assert(obj); - assert(attrname); - - list = PyObject_GetAttrString(obj, attrname); - if (list == NULL) - PyErr_Clear(); - - else if (PyList_Check(list)) { - int i; - for (i = 0; i < PyList_GET_SIZE(list); ++i) { - PyObject *item = PyList_GET_ITEM(list, i); - if (PyString_Check(item)) { - result = PyDict_SetItem(dict, item, Py_None); - if (result < 0) - break; - } - } - } - - Py_XDECREF(list); - return result; -} - -/* Like __builtin__.dir(arg). See bltinmodule.c's builtin_dir for the - docstring, which should be kept in synch with this implementation. */ - -PyObject * -PyObject_Dir(PyObject *arg) -{ - /* Set exactly one of these non-NULL before the end. */ - PyObject *result = NULL; /* result list */ - PyObject *masterdict = NULL; /* result is masterdict.keys() */ - - /* If NULL arg, return the locals. */ - if (arg == NULL) { - PyObject *locals = PyEval_GetLocals(); - if (locals == NULL) - goto error; - result = PyDict_Keys(locals); - if (result == NULL) - goto error; - } - - /* Elif this is some form of module, we only want its dict. */ - else if (PyModule_Check(arg)) { - masterdict = PyObject_GetAttrString(arg, "__dict__"); - if (masterdict == NULL) - goto error; - if (!PyDict_Check(masterdict)) { - PyErr_SetString(PyExc_TypeError, - "module.__dict__ is not a dictionary"); - goto error; - } - } - - /* Elif some form of type or class, grab its dict and its bases. - We deliberately don't suck up its __class__, as methods belonging - to the metaclass would probably be more confusing than helpful. */ - else if (PyType_Check(arg) || PyClass_Check(arg)) { - masterdict = PyDict_New(); - if (masterdict == NULL) - goto error; - if (merge_class_dict(masterdict, arg) < 0) - goto error; - } - - /* Else look at its dict, and the attrs reachable from its class. */ - else { - PyObject *itsclass; - /* Create a dict to start with. CAUTION: Not everything - responding to __dict__ returns a dict! */ - masterdict = PyObject_GetAttrString(arg, "__dict__"); - if (masterdict == NULL) { - PyErr_Clear(); - masterdict = PyDict_New(); - } - else if (!PyDict_Check(masterdict)) { - Py_DECREF(masterdict); - masterdict = PyDict_New(); - } - else { - /* The object may have returned a reference to its - dict, so copy it to avoid mutating it. */ - PyObject *temp = PyDict_Copy(masterdict); - Py_DECREF(masterdict); - masterdict = temp; - } - if (masterdict == NULL) - goto error; - - /* Merge in __members__ and __methods__ (if any). - XXX Would like this to go away someday; for now, it's - XXX needed to get at im_self etc of method objects. */ - if (merge_list_attr(masterdict, arg, "__members__") < 0) - goto error; - if (merge_list_attr(masterdict, arg, "__methods__") < 0) - goto error; - - /* Merge in attrs reachable from its class. - CAUTION: Not all objects have a __class__ attr. */ - itsclass = PyObject_GetAttrString(arg, "__class__"); - if (itsclass == NULL) - PyErr_Clear(); - else { - int status = merge_class_dict(masterdict, itsclass); - Py_DECREF(itsclass); - if (status < 0) - goto error; - } - } - - assert((result == NULL) ^ (masterdict == NULL)); - if (masterdict != NULL) { - /* The result comes from its keys. */ - assert(result == NULL); - result = PyDict_Keys(masterdict); - if (result == NULL) - goto error; - } - - assert(result); - if (PyList_Sort(result) != 0) - goto error; - else - goto normal_return; - - error: - Py_XDECREF(result); - result = NULL; - /* fall through */ - normal_return: - Py_XDECREF(masterdict); - return result; -} - -/* -NoObject is usable as a non-NULL undefined value, used by the macro None. -There is (and should be!) no way to create other objects of this type, -so there is exactly one (which is indestructible, by the way). -(XXX This type and the type of NotImplemented below should be unified.) -*/ - -/* ARGSUSED */ -static PyObject * -none_repr(PyObject *op) -{ - return PyString_FromString("None"); -} - -/* ARGUSED */ -static void -none_dealloc(PyObject* ignore) -{ - /* This should never get called, but we also don't want to SEGV if - * we accidently decref None out of existance. - */ - Py_FatalError("deallocating None"); -} - - -static PyTypeObject PyNone_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "NoneType", - 0, - 0, - (destructor)none_dealloc, /*tp_dealloc*/ /*never called*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - (reprfunc)none_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ -}; - -PyObject _Py_NoneStruct = { - PyObject_HEAD_INIT(&PyNone_Type) -}; - -/* NotImplemented is an object that can be used to signal that an - operation is not implemented for the given type combination. */ - -static PyObject * -NotImplemented_repr(PyObject *op) -{ - return PyString_FromString("NotImplemented"); -} - -static PyTypeObject PyNotImplemented_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "NotImplementedType", - 0, - 0, - (destructor)none_dealloc, /*tp_dealloc*/ /*never called*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - (reprfunc)NotImplemented_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ -}; - -PyObject _Py_NotImplementedStruct = { - PyObject_HEAD_INIT(&PyNotImplemented_Type) -}; - -void -_Py_ReadyTypes(void) -{ - if (PyType_Ready(&PyType_Type) < 0) - Py_FatalError("Can't initialize 'type'"); - - if (PyType_Ready(&PyBool_Type) < 0) - Py_FatalError("Can't initialize 'bool'"); - - if (PyType_Ready(&PyString_Type) < 0) - Py_FatalError("Can't initialize 'str'"); - - if (PyType_Ready(&PyList_Type) < 0) - Py_FatalError("Can't initialize 'list'"); - - if (PyType_Ready(&PyNone_Type) < 0) - Py_FatalError("Can't initialize type(None)"); - - if (PyType_Ready(&PyNotImplemented_Type) < 0) - Py_FatalError("Can't initialize type(NotImplemented)"); -} - - -#ifdef Py_TRACE_REFS - -void -_Py_NewReference(PyObject *op) -{ - _Py_INC_REFTOTAL; - op->ob_refcnt = 1; - _Py_AddToAllObjects(op, 1); - _Py_INC_TPALLOCS(op); -} - -void -_Py_ForgetReference(register PyObject *op) -{ -#ifdef SLOW_UNREF_CHECK - register PyObject *p; -#endif - if (op->ob_refcnt < 0) - Py_FatalError("UNREF negative refcnt"); - if (op == &refchain || - op->_ob_prev->_ob_next != op || op->_ob_next->_ob_prev != op) - Py_FatalError("UNREF invalid object"); -#ifdef SLOW_UNREF_CHECK - for (p = refchain._ob_next; p != &refchain; p = p->_ob_next) { - if (p == op) - break; - } - if (p == &refchain) /* Not found */ - Py_FatalError("UNREF unknown object"); -#endif - op->_ob_next->_ob_prev = op->_ob_prev; - op->_ob_prev->_ob_next = op->_ob_next; - op->_ob_next = op->_ob_prev = NULL; - _Py_INC_TPFREES(op); -} - -void -_Py_Dealloc(PyObject *op) -{ - destructor dealloc = op->ob_type->tp_dealloc; - _Py_ForgetReference(op); - (*dealloc)(op); -} - -/* Print all live objects. Because PyObject_Print is called, the - * interpreter must be in a healthy state. - */ -void -_Py_PrintReferences(FILE *fp) -{ - PyObject *op; - fprintf(fp, "Remaining objects:\n"); - for (op = refchain._ob_next; op != &refchain; op = op->_ob_next) { - fprintf(fp, "%p [%d] ", op, op->ob_refcnt); - if (PyObject_Print(op, fp, 0) != 0) - PyErr_Clear(); - putc('\n', fp); - } -} - -/* Print the addresses of all live objects. Unlike _Py_PrintReferences, this - * doesn't make any calls to the Python C API, so is always safe to call. - */ -void -_Py_PrintReferenceAddresses(FILE *fp) -{ - PyObject *op; - fprintf(fp, "Remaining object addresses:\n"); - for (op = refchain._ob_next; op != &refchain; op = op->_ob_next) - fprintf(fp, "%p [%d] %s\n", op, op->ob_refcnt, - op->ob_type->tp_name); -} - -PyObject * -_Py_GetObjects(PyObject *self, PyObject *args) -{ - int i, n; - PyObject *t = NULL; - PyObject *res, *op; - - if (!PyArg_ParseTuple(args, "i|O", &n, &t)) - return NULL; - op = refchain._ob_next; - res = PyList_New(0); - if (res == NULL) - return NULL; - for (i = 0; (n == 0 || i < n) && op != &refchain; i++) { - while (op == self || op == args || op == res || op == t || - (t != NULL && op->ob_type != (PyTypeObject *) t)) { - op = op->_ob_next; - if (op == &refchain) - return res; - } - if (PyList_Append(res, op) < 0) { - Py_DECREF(res); - return NULL; - } - op = op->_ob_next; - } - return res; -} - -#endif - - -/* Hack to force loading of cobject.o */ -PyTypeObject *_Py_cobject_hack = &PyCObject_Type; - - -/* Hack to force loading of abstract.o */ -int (*_Py_abstract_hack)(PyObject *) = PyObject_Size; - - -/* Python's malloc wrappers (see pymem.h) */ - -void * -PyMem_Malloc(size_t nbytes) -{ - return PyMem_MALLOC(nbytes); -} - -void * -PyMem_Realloc(void *p, size_t nbytes) -{ - return PyMem_REALLOC(p, nbytes); -} - -void -PyMem_Free(void *p) -{ - PyMem_FREE(p); -} - - -/* These methods are used to control infinite recursion in repr, str, print, - etc. Container objects that may recursively contain themselves, - e.g. builtin dictionaries and lists, should used Py_ReprEnter() and - Py_ReprLeave() to avoid infinite recursion. - - Py_ReprEnter() returns 0 the first time it is called for a particular - object and 1 every time thereafter. It returns -1 if an exception - occurred. Py_ReprLeave() has no return value. - - See dictobject.c and listobject.c for examples of use. -*/ - -#define KEY "Py_Repr" - -int -Py_ReprEnter(PyObject *obj) -{ - PyObject *dict; - PyObject *list; - int i; - - dict = PyThreadState_GetDict(); - if (dict == NULL) - return 0; - list = PyDict_GetItemString(dict, KEY); - if (list == NULL) { - list = PyList_New(0); - if (list == NULL) - return -1; - if (PyDict_SetItemString(dict, KEY, list) < 0) - return -1; - Py_DECREF(list); - } - i = PyList_GET_SIZE(list); - while (--i >= 0) { - if (PyList_GET_ITEM(list, i) == obj) - return 1; - } - PyList_Append(list, obj); - return 0; -} - -void -Py_ReprLeave(PyObject *obj) -{ - PyObject *dict; - PyObject *list; - int i; - - dict = PyThreadState_GetDict(); - if (dict == NULL) - return; - list = PyDict_GetItemString(dict, KEY); - if (list == NULL || !PyList_Check(list)) - return; - i = PyList_GET_SIZE(list); - /* Count backwards because we always expect obj to be list[-1] */ - while (--i >= 0) { - if (PyList_GET_ITEM(list, i) == obj) { - PyList_SetSlice(list, i, i + 1, NULL); - break; - } - } -} - -/* Trashcan support. */ - -/* Current call-stack depth of tp_dealloc calls. */ -int _PyTrash_delete_nesting = 0; - -/* List of objects that still need to be cleaned up, singly linked via their - * gc headers' gc_prev pointers. - */ -PyObject *_PyTrash_delete_later = NULL; - -/* Add op to the _PyTrash_delete_later list. Called when the current - * call-stack depth gets large. op must be a currently untracked gc'ed - * object, with refcount 0. Py_DECREF must already have been called on it. - */ -void -_PyTrash_deposit_object(PyObject *op) -{ - assert(PyObject_IS_GC(op)); - assert(_Py_AS_GC(op)->gc.gc_refs == _PyGC_REFS_UNTRACKED); - assert(op->ob_refcnt == 0); - _Py_AS_GC(op)->gc.gc_prev = (PyGC_Head *)_PyTrash_delete_later; - _PyTrash_delete_later = op; -} - -/* Dealloccate all the objects in the _PyTrash_delete_later list. Called when - * the call-stack unwinds again. - */ -void -_PyTrash_destroy_chain(void) -{ - while (_PyTrash_delete_later) { - PyObject *op = _PyTrash_delete_later; - destructor dealloc = op->ob_type->tp_dealloc; - - _PyTrash_delete_later = - (PyObject*) _Py_AS_GC(op)->gc.gc_prev; - - /* Call the deallocator directly. This used to try to - * fool Py_DECREF into calling it indirectly, but - * Py_DECREF was already called on this object, and in - * assorted non-release builds calling Py_DECREF again ends - * up distorting allocation statistics. - */ - assert(op->ob_refcnt == 0); - ++_PyTrash_delete_nesting; - (*dealloc)(op); - --_PyTrash_delete_nesting; - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/obmalloc.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/obmalloc.c deleted file mode 100644 index a2cec1d9..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/obmalloc.c +++ /dev/null @@ -1,1375 +0,0 @@ -#include "Python.h" - -#ifdef WITH_PYMALLOC - -/* An object allocator for Python. - - Here is an introduction to the layers of the Python memory architecture, - showing where the object allocator is actually used (layer +2), It is - called for every object allocation and deallocation (PyObject_New/Del), - unless the object-specific allocators implement a proprietary allocation - scheme (ex.: ints use a simple free list). This is also the place where - the cyclic garbage collector operates selectively on container objects. - - - Object-specific allocators - _____ ______ ______ ________ - [ int ] [ dict ] [ list ] ... [ string ] Python core | -+3 | <----- Object-specific memory -----> | <-- Non-object memory --> | - _______________________________ | | - [ Python's object allocator ] | | -+2 | ####### Object memory ####### | <------ Internal buffers ------> | - ______________________________________________________________ | - [ Python's raw memory allocator (PyMem_ API) ] | -+1 | <----- Python memory (under PyMem manager's control) ------> | | - __________________________________________________________________ - [ Underlying general-purpose allocator (ex: C library malloc) ] - 0 | <------ Virtual memory allocated for the python process -------> | - - ========================================================================= - _______________________________________________________________________ - [ OS-specific Virtual Memory Manager (VMM) ] --1 | <--- Kernel dynamic storage allocation & management (page-based) ---> | - __________________________________ __________________________________ - [ ] [ ] --2 | <-- Physical memory: ROM/RAM --> | | <-- Secondary storage (swap) --> | - -*/ -/*==========================================================================*/ - -/* A fast, special-purpose memory allocator for small blocks, to be used - on top of a general-purpose malloc -- heavily based on previous art. */ - -/* Vladimir Marangozov -- August 2000 */ - -/* - * "Memory management is where the rubber meets the road -- if we do the wrong - * thing at any level, the results will not be good. And if we don't make the - * levels work well together, we are in serious trouble." (1) - * - * (1) Paul R. Wilson, Mark S. Johnstone, Michael Neely, and David Boles, - * "Dynamic Storage Allocation: A Survey and Critical Review", - * in Proc. 1995 Int'l. Workshop on Memory Management, September 1995. - */ - -/* #undef WITH_MEMORY_LIMITS */ /* disable mem limit checks */ - -/*==========================================================================*/ - -/* - * Allocation strategy abstract: - * - * For small requests, the allocator sub-allocates blocks of memory. - * Requests greater than 256 bytes are routed to the system's allocator. - * - * Small requests are grouped in size classes spaced 8 bytes apart, due - * to the required valid alignment of the returned address. Requests of - * a particular size are serviced from memory pools of 4K (one VMM page). - * Pools are fragmented on demand and contain free lists of blocks of one - * particular size class. In other words, there is a fixed-size allocator - * for each size class. Free pools are shared by the different allocators - * thus minimizing the space reserved for a particular size class. - * - * This allocation strategy is a variant of what is known as "simple - * segregated storage based on array of free lists". The main drawback of - * simple segregated storage is that we might end up with lot of reserved - * memory for the different free lists, which degenerate in time. To avoid - * this, we partition each free list in pools and we share dynamically the - * reserved space between all free lists. This technique is quite efficient - * for memory intensive programs which allocate mainly small-sized blocks. - * - * For small requests we have the following table: - * - * Request in bytes Size of allocated block Size class idx - * ---------------------------------------------------------------- - * 1-8 8 0 - * 9-16 16 1 - * 17-24 24 2 - * 25-32 32 3 - * 33-40 40 4 - * 41-48 48 5 - * 49-56 56 6 - * 57-64 64 7 - * 65-72 72 8 - * ... ... ... - * 241-248 248 30 - * 249-256 256 31 - * - * 0, 257 and up: routed to the underlying allocator. - */ - -/*==========================================================================*/ - -/* - * -- Main tunable settings section -- - */ - -/* - * Alignment of addresses returned to the user. 8-bytes alignment works - * on most current architectures (with 32-bit or 64-bit address busses). - * The alignment value is also used for grouping small requests in size - * classes spaced ALIGNMENT bytes apart. - * - * You shouldn't change this unless you know what you are doing. - */ -#define ALIGNMENT 8 /* must be 2^N */ -#define ALIGNMENT_SHIFT 3 -#define ALIGNMENT_MASK (ALIGNMENT - 1) - -/* Return the number of bytes in size class I, as a uint. */ -#define INDEX2SIZE(I) (((uint)(I) + 1) << ALIGNMENT_SHIFT) - -/* - * Max size threshold below which malloc requests are considered to be - * small enough in order to use preallocated memory pools. You can tune - * this value according to your application behaviour and memory needs. - * - * The following invariants must hold: - * 1) ALIGNMENT <= SMALL_REQUEST_THRESHOLD <= 256 - * 2) SMALL_REQUEST_THRESHOLD is evenly divisible by ALIGNMENT - * - * Although not required, for better performance and space efficiency, - * it is recommended that SMALL_REQUEST_THRESHOLD is set to a power of 2. - */ -#define SMALL_REQUEST_THRESHOLD 256 -#define NB_SMALL_SIZE_CLASSES (SMALL_REQUEST_THRESHOLD / ALIGNMENT) - -/* - * The system's VMM page size can be obtained on most unices with a - * getpagesize() call or deduced from various header files. To make - * things simpler, we assume that it is 4K, which is OK for most systems. - * It is probably better if this is the native page size, but it doesn't - * have to be. In theory, if SYSTEM_PAGE_SIZE is larger than the native page - * size, then `POOL_ADDR(p)->arenaindex' could rarely cause a segmentation - * violation fault. 4K is apparently OK for all the platforms that python - * currently targets. - */ -#define SYSTEM_PAGE_SIZE (4 * 1024) -#define SYSTEM_PAGE_SIZE_MASK (SYSTEM_PAGE_SIZE - 1) - -/* - * Maximum amount of memory managed by the allocator for small requests. - */ -#ifdef WITH_MEMORY_LIMITS -#ifndef SMALL_MEMORY_LIMIT -#define SMALL_MEMORY_LIMIT (64 * 1024 * 1024) /* 64 MB -- more? */ -#endif -#endif - -/* - * The allocator sub-allocates blocks of memory (called arenas) aligned - * on a page boundary. This is a reserved virtual address space for the - * current process (obtained through a malloc call). In no way this means - * that the memory arenas will be used entirely. A malloc() is usually - * an address range reservation for bytes, unless all pages within this - * space are referenced subsequently. So malloc'ing big blocks and not using - * them does not mean "wasting memory". It's an addressable range wastage... - * - * Therefore, allocating arenas with malloc is not optimal, because there is - * some address space wastage, but this is the most portable way to request - * memory from the system across various platforms. - */ -#define ARENA_SIZE (256 << 10) /* 256KB */ - -#ifdef WITH_MEMORY_LIMITS -#define MAX_ARENAS (SMALL_MEMORY_LIMIT / ARENA_SIZE) -#endif - -/* - * Size of the pools used for small blocks. Should be a power of 2, - * between 1K and SYSTEM_PAGE_SIZE, that is: 1k, 2k, 4k. - */ -#define POOL_SIZE SYSTEM_PAGE_SIZE /* must be 2^N */ -#define POOL_SIZE_MASK SYSTEM_PAGE_SIZE_MASK - -/* - * -- End of tunable settings section -- - */ - -/*==========================================================================*/ - -/* - * Locking - * - * To reduce lock contention, it would probably be better to refine the - * crude function locking with per size class locking. I'm not positive - * however, whether it's worth switching to such locking policy because - * of the performance penalty it might introduce. - * - * The following macros describe the simplest (should also be the fastest) - * lock object on a particular platform and the init/fini/lock/unlock - * operations on it. The locks defined here are not expected to be recursive - * because it is assumed that they will always be called in the order: - * INIT, [LOCK, UNLOCK]*, FINI. - */ - -/* - * Python's threads are serialized, so object malloc locking is disabled. - */ -#define SIMPLELOCK_DECL(lock) /* simple lock declaration */ -#define SIMPLELOCK_INIT(lock) /* allocate (if needed) and initialize */ -#define SIMPLELOCK_FINI(lock) /* free/destroy an existing lock */ -#define SIMPLELOCK_LOCK(lock) /* acquire released lock */ -#define SIMPLELOCK_UNLOCK(lock) /* release acquired lock */ - -/* - * Basic types - * I don't care if these are defined in or elsewhere. Axiom. - */ -#undef uchar -#define uchar unsigned char /* assuming == 8 bits */ - -#undef uint -#define uint unsigned int /* assuming >= 16 bits */ - -#undef ulong -#define ulong unsigned long /* assuming >= 32 bits */ - -#undef uptr -#define uptr Py_uintptr_t - -/* When you say memory, my mind reasons in terms of (pointers to) blocks */ -typedef uchar block; - -/* Pool for small blocks. */ -struct pool_header { - union { block *_padding; - uint count; } ref; /* number of allocated blocks */ - block *freeblock; /* pool's free list head */ - struct pool_header *nextpool; /* next pool of this size class */ - struct pool_header *prevpool; /* previous pool "" */ - uint arenaindex; /* index into arenas of base adr */ - uint szidx; /* block size class index */ - uint nextoffset; /* bytes to virgin block */ - uint maxnextoffset; /* largest valid nextoffset */ -}; - -typedef struct pool_header *poolp; - -#undef ROUNDUP -#define ROUNDUP(x) (((x) + ALIGNMENT_MASK) & ~ALIGNMENT_MASK) -#define POOL_OVERHEAD ROUNDUP(sizeof(struct pool_header)) - -#define DUMMY_SIZE_IDX 0xffff /* size class of newly cached pools */ - -/* Round pointer P down to the closest pool-aligned address <= P, as a poolp */ -#define POOL_ADDR(P) ((poolp)((uptr)(P) & ~(uptr)POOL_SIZE_MASK)) - -/* Return total number of blocks in pool of size index I, as a uint. */ -#define NUMBLOCKS(I) ((uint)(POOL_SIZE - POOL_OVERHEAD) / INDEX2SIZE(I)) - -/*==========================================================================*/ - -/* - * This malloc lock - */ -SIMPLELOCK_DECL(_malloc_lock) -#define LOCK() SIMPLELOCK_LOCK(_malloc_lock) -#define UNLOCK() SIMPLELOCK_UNLOCK(_malloc_lock) -#define LOCK_INIT() SIMPLELOCK_INIT(_malloc_lock) -#define LOCK_FINI() SIMPLELOCK_FINI(_malloc_lock) - -/* - * Pool table -- headed, circular, doubly-linked lists of partially used pools. - -This is involved. For an index i, usedpools[i+i] is the header for a list of -all partially used pools holding small blocks with "size class idx" i. So -usedpools[0] corresponds to blocks of size 8, usedpools[2] to blocks of size -16, and so on: index 2*i <-> blocks of size (i+1)<freeblock points to -the start of a singly-linked list of free blocks within the pool. When a -block is freed, it's inserted at the front of its pool's freeblock list. Note -that the available blocks in a pool are *not* linked all together when a pool -is initialized. Instead only "the first two" (lowest addresses) blocks are -set up, returning the first such block, and setting pool->freeblock to a -one-block list holding the second such block. This is consistent with that -pymalloc strives at all levels (arena, pool, and block) never to touch a piece -of memory until it's actually needed. - -So long as a pool is in the used state, we're certain there *is* a block -available for allocating, and pool->freeblock is not NULL. If pool->freeblock -points to the end of the free list before we've carved the entire pool into -blocks, that means we simply haven't yet gotten to one of the higher-address -blocks. The offset from the pool_header to the start of "the next" virgin -block is stored in the pool_header nextoffset member, and the largest value -of nextoffset that makes sense is stored in the maxnextoffset member when a -pool is initialized. All the blocks in a pool have been passed out at least -once when and only when nextoffset > maxnextoffset. - - -Major obscurity: While the usedpools vector is declared to have poolp -entries, it doesn't really. It really contains two pointers per (conceptual) -poolp entry, the nextpool and prevpool members of a pool_header. The -excruciating initialization code below fools C so that - - usedpool[i+i] - -"acts like" a genuine poolp, but only so long as you only reference its -nextpool and prevpool members. The "- 2*sizeof(block *)" gibberish is -compensating for that a pool_header's nextpool and prevpool members -immediately follow a pool_header's first two members: - - union { block *_padding; - uint count; } ref; - block *freeblock; - -each of which consume sizeof(block *) bytes. So what usedpools[i+i] really -contains is a fudged-up pointer p such that *if* C believes it's a poolp -pointer, then p->nextpool and p->prevpool are both p (meaning that the headed -circular list is empty). - -It's unclear why the usedpools setup is so convoluted. It could be to -minimize the amount of cache required to hold this heavily-referenced table -(which only *needs* the two interpool pointer members of a pool_header). OTOH, -referencing code has to remember to "double the index" and doing so isn't -free, usedpools[0] isn't a strictly legal pointer, and we're crucially relying -on that C doesn't insert any padding anywhere in a pool_header at or before -the prevpool member. -**************************************************************************** */ - -#define PTA(x) ((poolp )((uchar *)&(usedpools[2*(x)]) - 2*sizeof(block *))) -#define PT(x) PTA(x), PTA(x) - -static poolp usedpools[2 * ((NB_SMALL_SIZE_CLASSES + 7) / 8) * 8] = { - PT(0), PT(1), PT(2), PT(3), PT(4), PT(5), PT(6), PT(7) -#if NB_SMALL_SIZE_CLASSES > 8 - , PT(8), PT(9), PT(10), PT(11), PT(12), PT(13), PT(14), PT(15) -#if NB_SMALL_SIZE_CLASSES > 16 - , PT(16), PT(17), PT(18), PT(19), PT(20), PT(21), PT(22), PT(23) -#if NB_SMALL_SIZE_CLASSES > 24 - , PT(24), PT(25), PT(26), PT(27), PT(28), PT(29), PT(30), PT(31) -#if NB_SMALL_SIZE_CLASSES > 32 - , PT(32), PT(33), PT(34), PT(35), PT(36), PT(37), PT(38), PT(39) -#if NB_SMALL_SIZE_CLASSES > 40 - , PT(40), PT(41), PT(42), PT(43), PT(44), PT(45), PT(46), PT(47) -#if NB_SMALL_SIZE_CLASSES > 48 - , PT(48), PT(49), PT(50), PT(51), PT(52), PT(53), PT(54), PT(55) -#if NB_SMALL_SIZE_CLASSES > 56 - , PT(56), PT(57), PT(58), PT(59), PT(60), PT(61), PT(62), PT(63) -#endif /* NB_SMALL_SIZE_CLASSES > 56 */ -#endif /* NB_SMALL_SIZE_CLASSES > 48 */ -#endif /* NB_SMALL_SIZE_CLASSES > 40 */ -#endif /* NB_SMALL_SIZE_CLASSES > 32 */ -#endif /* NB_SMALL_SIZE_CLASSES > 24 */ -#endif /* NB_SMALL_SIZE_CLASSES > 16 */ -#endif /* NB_SMALL_SIZE_CLASSES > 8 */ -}; - -/* - * Free (cached) pools - */ -static poolp freepools = NULL; /* free list for cached pools */ - -/*==========================================================================*/ -/* Arena management. */ - -/* arenas is a vector of arena base addresses, in order of allocation time. - * arenas currently contains narenas entries, and has space allocated - * for at most maxarenas entries. - * - * CAUTION: See the long comment block about thread safety in new_arena(): - * the code currently relies in deep ways on that this vector only grows, - * and only grows by appending at the end. For now we never return an arena - * to the OS. - */ -static uptr *volatile arenas = NULL; /* the pointer itself is volatile */ -static volatile uint narenas = 0; -static uint maxarenas = 0; - -/* Number of pools still available to be allocated in the current arena. */ -static uint nfreepools = 0; - -/* Free space start address in current arena. This is pool-aligned. */ -static block *arenabase = NULL; - -/* Allocate a new arena and return its base address. If we run out of - * memory, return NULL. - */ -static block * -new_arena(void) -{ - uint excess; /* number of bytes above pool alignment */ - block *bp = (block *)malloc(ARENA_SIZE); - if (bp == NULL) - return NULL; - -#ifdef PYMALLOC_DEBUG - if (Py_GETENV("PYTHONMALLOCSTATS")) - _PyObject_DebugMallocStats(); -#endif - - /* arenabase <- first pool-aligned address in the arena - nfreepools <- number of whole pools that fit after alignment */ - arenabase = bp; - nfreepools = ARENA_SIZE / POOL_SIZE; - assert(POOL_SIZE * nfreepools == ARENA_SIZE); - excess = (uint) ((Py_uintptr_t)bp & POOL_SIZE_MASK); - if (excess != 0) { - --nfreepools; - arenabase += POOL_SIZE - excess; - } - - /* Make room for a new entry in the arenas vector. */ - if (arenas == NULL) { - assert(narenas == 0 && maxarenas == 0); - arenas = (uptr *)malloc(16 * sizeof(*arenas)); - if (arenas == NULL) - goto error; - maxarenas = 16; - } - else if (narenas == maxarenas) { - /* Grow arenas. - * - * Exceedingly subtle: Someone may be calling the pymalloc - * free via PyMem_{DEL, Del, FREE, Free} without holding the - *.GIL. Someone else may simultaneously be calling the - * pymalloc malloc while holding the GIL via, e.g., - * PyObject_New. Now the pymalloc free may index into arenas - * for an address check, while the pymalloc malloc calls - * new_arena and we end up here to grow a new arena *and* - * grow the arenas vector. If the value for arenas pymalloc - * free picks up "vanishes" during this resize, anything may - * happen, and it would be an incredibly rare bug. Therefore - * the code here takes great pains to make sure that, at every - * moment, arenas always points to an intact vector of - * addresses. It doesn't matter whether arenas points to a - * wholly up-to-date vector when pymalloc free checks it in - * this case, because the only legal (and that even this is - * legal is debatable) way to call PyMem_{Del, etc} while not - * holding the GIL is if the memory being released is not - * object memory, i.e. if the address check in pymalloc free - * is supposed to fail. Having an incomplete vector can't - * make a supposed-to-fail case succeed by mistake (it could - * only make a supposed-to-succeed case fail by mistake). - * - * In addition, without a lock we can't know for sure when - * an old vector is no longer referenced, so we simply let - * old vectors leak. - * - * And on top of that, since narenas and arenas can't be - * changed as-a-pair atomically without a lock, we're also - * careful to declare them volatile and ensure that we change - * arenas first. This prevents another thread from picking - * up an narenas value too large for the arenas value it - * reads up (arenas never shrinks). - * - * Read the above 50 times before changing anything in this - * block. - */ - uptr *p; - uint newmax = maxarenas << 1; - if (newmax <= maxarenas) /* overflow */ - goto error; - p = (uptr *)malloc(newmax * sizeof(*arenas)); - if (p == NULL) - goto error; - memcpy(p, arenas, narenas * sizeof(*arenas)); - arenas = p; /* old arenas deliberately leaked */ - maxarenas = newmax; - } - - /* Append the new arena address to arenas. */ - assert(narenas < maxarenas); - arenas[narenas] = (uptr)bp; - ++narenas; /* can't overflow, since narenas < maxarenas before */ - return bp; - -error: - free(bp); - nfreepools = 0; - return NULL; -} - -/* Return true if and only if P is an address that was allocated by - * pymalloc. I must be the index into arenas that the address claims - * to come from. - * - * Tricky: Letting B be the arena base address in arenas[I], P belongs to the - * arena if and only if - * B <= P < B + ARENA_SIZE - * Subtracting B throughout, this is true iff - * 0 <= P-B < ARENA_SIZE - * By using unsigned arithmetic, the "0 <=" half of the test can be skipped. - * - * Obscure: A PyMem "free memory" function can call the pymalloc free or - * realloc before the first arena has been allocated. arenas is still - * NULL in that case. We're relying on that narenas is also 0 in that case, - * so the (I) < narenas must be false, saving us from trying to index into - * a NULL arenas. - */ -#define ADDRESS_IN_RANGE(P, I) \ - ((I) < narenas && (uptr)(P) - arenas[I] < (uptr)ARENA_SIZE) - -/*==========================================================================*/ - -/* malloc. Note that nbytes==0 tries to return a non-NULL pointer, distinct - * from all other currently live pointers. This may not be possible. - */ - -/* - * The basic blocks are ordered by decreasing execution frequency, - * which minimizes the number of jumps in the most common cases, - * improves branching prediction and instruction scheduling (small - * block allocations typically result in a couple of instructions). - * Unless the optimizer reorders everything, being too smart... - */ - -#undef PyObject_Malloc -void * -PyObject_Malloc(size_t nbytes) -{ - block *bp; - poolp pool; - poolp next; - uint size; - - /* - * This implicitly redirects malloc(0). - */ - if ((nbytes - 1) < SMALL_REQUEST_THRESHOLD) { - LOCK(); - /* - * Most frequent paths first - */ - size = (uint )(nbytes - 1) >> ALIGNMENT_SHIFT; - pool = usedpools[size + size]; - if (pool != pool->nextpool) { - /* - * There is a used pool for this size class. - * Pick up the head block of its free list. - */ - ++pool->ref.count; - bp = pool->freeblock; - assert(bp != NULL); - if ((pool->freeblock = *(block **)bp) != NULL) { - UNLOCK(); - return (void *)bp; - } - /* - * Reached the end of the free list, try to extend it - */ - if (pool->nextoffset <= pool->maxnextoffset) { - /* - * There is room for another block - */ - pool->freeblock = (block *)pool + - pool->nextoffset; - pool->nextoffset += INDEX2SIZE(size); - *(block **)(pool->freeblock) = NULL; - UNLOCK(); - return (void *)bp; - } - /* - * Pool is full, unlink from used pools - */ - next = pool->nextpool; - pool = pool->prevpool; - next->prevpool = pool; - pool->nextpool = next; - UNLOCK(); - return (void *)bp; - } - /* - * Try to get a cached free pool - */ - pool = freepools; - if (pool != NULL) { - /* - * Unlink from cached pools - */ - freepools = pool->nextpool; - init_pool: - /* - * Frontlink to used pools - */ - next = usedpools[size + size]; /* == prev */ - pool->nextpool = next; - pool->prevpool = next; - next->nextpool = pool; - next->prevpool = pool; - pool->ref.count = 1; - if (pool->szidx == size) { - /* - * Luckily, this pool last contained blocks - * of the same size class, so its header - * and free list are already initialized. - */ - bp = pool->freeblock; - pool->freeblock = *(block **)bp; - UNLOCK(); - return (void *)bp; - } - /* - * Initialize the pool header, set up the free list to - * contain just the second block, and return the first - * block. - */ - pool->szidx = size; - size = INDEX2SIZE(size); - bp = (block *)pool + POOL_OVERHEAD; - pool->nextoffset = POOL_OVERHEAD + (size << 1); - pool->maxnextoffset = POOL_SIZE - size; - pool->freeblock = bp + size; - *(block **)(pool->freeblock) = NULL; - UNLOCK(); - return (void *)bp; - } - /* - * Allocate new pool - */ - if (nfreepools) { - commit_pool: - --nfreepools; - pool = (poolp)arenabase; - arenabase += POOL_SIZE; - pool->arenaindex = narenas - 1; - pool->szidx = DUMMY_SIZE_IDX; - goto init_pool; - } - /* - * Allocate new arena - */ -#ifdef WITH_MEMORY_LIMITS - if (!(narenas < MAX_ARENAS)) { - UNLOCK(); - goto redirect; - } -#endif - bp = new_arena(); - if (bp != NULL) - goto commit_pool; - UNLOCK(); - goto redirect; - } - - /* The small block allocator ends here. */ - -redirect: - /* - * Redirect the original request to the underlying (libc) allocator. - * We jump here on bigger requests, on error in the code above (as a - * last chance to serve the request) or when the max memory limit - * has been reached. - */ - if (nbytes == 0) - nbytes = 1; - return (void *)malloc(nbytes); -} - -/* free */ - -#undef PyObject_Free -void -PyObject_Free(void *p) -{ - poolp pool; - block *lastfree; - poolp next, prev; - uint size; - - if (p == NULL) /* free(NULL) has no effect */ - return; - - pool = POOL_ADDR(p); - if (ADDRESS_IN_RANGE(p, pool->arenaindex)) { - /* We allocated this address. */ - LOCK(); - /* - * Link p to the start of the pool's freeblock list. Since - * the pool had at least the p block outstanding, the pool - * wasn't empty (so it's already in a usedpools[] list, or - * was full and is in no list -- it's not in the freeblocks - * list in any case). - */ - assert(pool->ref.count > 0); /* else it was empty */ - *(block **)p = lastfree = pool->freeblock; - pool->freeblock = (block *)p; - if (lastfree) { - /* - * freeblock wasn't NULL, so the pool wasn't full, - * and the pool is in a usedpools[] list. - */ - if (--pool->ref.count != 0) { - /* pool isn't empty: leave it in usedpools */ - UNLOCK(); - return; - } - /* - * Pool is now empty: unlink from usedpools, and - * link to the front of freepools. This ensures that - * previously freed pools will be allocated later - * (being not referenced, they are perhaps paged out). - */ - next = pool->nextpool; - prev = pool->prevpool; - next->prevpool = prev; - prev->nextpool = next; - /* Link to freepools. This is a singly-linked list, - * and pool->prevpool isn't used there. - */ - pool->nextpool = freepools; - freepools = pool; - UNLOCK(); - return; - } - /* - * Pool was full, so doesn't currently live in any list: - * link it to the front of the appropriate usedpools[] list. - * This mimics LRU pool usage for new allocations and - * targets optimal filling when several pools contain - * blocks of the same size class. - */ - --pool->ref.count; - assert(pool->ref.count > 0); /* else the pool is empty */ - size = pool->szidx; - next = usedpools[size + size]; - prev = next->prevpool; - /* insert pool before next: prev <-> pool <-> next */ - pool->nextpool = next; - pool->prevpool = prev; - next->prevpool = pool; - prev->nextpool = pool; - UNLOCK(); - return; - } - - /* We didn't allocate this address. */ - free(p); -} - -/* realloc. If p is NULL, this acts like malloc(nbytes). Else if nbytes==0, - * then as the Python docs promise, we do not treat this like free(p), and - * return a non-NULL result. - */ - -#undef PyObject_Realloc -void * -PyObject_Realloc(void *p, size_t nbytes) -{ - void *bp; - poolp pool; - uint size; - - if (p == NULL) - return PyObject_Malloc(nbytes); - - pool = POOL_ADDR(p); - if (ADDRESS_IN_RANGE(p, pool->arenaindex)) { - /* We're in charge of this block */ - size = INDEX2SIZE(pool->szidx); - if (nbytes <= size) { - /* The block is staying the same or shrinking. If - * it's shrinking, there's a tradeoff: it costs - * cycles to copy the block to a smaller size class, - * but it wastes memory not to copy it. The - * compromise here is to copy on shrink only if at - * least 25% of size can be shaved off. - */ - if (4 * nbytes > 3 * size) { - /* It's the same, - * or shrinking and new/old > 3/4. - */ - return p; - } - size = nbytes; - } - bp = PyObject_Malloc(nbytes); - if (bp != NULL) { - memcpy(bp, p, size); - PyObject_Free(p); - } - return bp; - } - /* We're not managing this block. */ - if (nbytes <= SMALL_REQUEST_THRESHOLD) { - /* Take over this block -- ask for at least one byte so - * we really do take it over (PyObject_Malloc(0) goes to - * the system malloc). - */ - bp = PyObject_Malloc(nbytes ? nbytes : 1); - if (bp != NULL) { - memcpy(bp, p, nbytes); - free(p); - } - else if (nbytes == 0) { - /* Meet the doc's promise that nbytes==0 will - * never return a NULL pointer when p isn't NULL. - */ - bp = p; - } - - } - else { - assert(nbytes != 0); - bp = realloc(p, nbytes); - } - return bp; -} - -#else /* ! WITH_PYMALLOC */ - -/*==========================================================================*/ -/* pymalloc not enabled: Redirect the entry points to malloc. These will - * only be used by extensions that are compiled with pymalloc enabled. */ - -void * -PyObject_Malloc(size_t n) -{ - return PyMem_MALLOC(n); -} - -void * -PyObject_Realloc(void *p, size_t n) -{ - return PyMem_REALLOC(p, n); -} - -void -PyObject_Free(void *p) -{ - PyMem_FREE(p); -} -#endif /* WITH_PYMALLOC */ - -#ifdef PYMALLOC_DEBUG -/*==========================================================================*/ -/* A x-platform debugging allocator. This doesn't manage memory directly, - * it wraps a real allocator, adding extra debugging info to the memory blocks. - */ - -/* Special bytes broadcast into debug memory blocks at appropriate times. - * Strings of these are unlikely to be valid addresses, floats, ints or - * 7-bit ASCII. - */ -#undef CLEANBYTE -#undef DEADBYTE -#undef FORBIDDENBYTE -#define CLEANBYTE 0xCB /* clean (newly allocated) memory */ -#define DEADBYTE 0xDB /* dead (newly freed) memory */ -#define FORBIDDENBYTE 0xFB /* untouchable bytes at each end of a block */ - -static ulong serialno = 0; /* incremented on each debug {m,re}alloc */ - -/* serialno is always incremented via calling this routine. The point is - to supply a single place to set a breakpoint. -*/ -static void -bumpserialno(void) -{ - ++serialno; -} - - -/* Read 4 bytes at p as a big-endian ulong. */ -static ulong -read4(const void *p) -{ - const uchar *q = (const uchar *)p; - return ((ulong)q[0] << 24) | - ((ulong)q[1] << 16) | - ((ulong)q[2] << 8) | - (ulong)q[3]; -} - -/* Write the 4 least-significant bytes of n as a big-endian unsigned int, - MSB at address p, LSB at p+3. */ -static void -write4(void *p, ulong n) -{ - uchar *q = (uchar *)p; - q[0] = (uchar)((n >> 24) & 0xff); - q[1] = (uchar)((n >> 16) & 0xff); - q[2] = (uchar)((n >> 8) & 0xff); - q[3] = (uchar)( n & 0xff); -} - -#ifdef Py_DEBUG -/* Is target in the list? The list is traversed via the nextpool pointers. - * The list may be NULL-terminated, or circular. Return 1 if target is in - * list, else 0. - */ -static int -pool_is_in_list(const poolp target, poolp list) -{ - poolp origlist = list; - assert(target != NULL); - if (list == NULL) - return 0; - do { - if (target == list) - return 1; - list = list->nextpool; - } while (list != NULL && list != origlist); - return 0; -} - -#else -#define pool_is_in_list(X, Y) 1 - -#endif /* Py_DEBUG */ - -/* The debug malloc asks for 16 extra bytes and fills them with useful stuff, - here calling the underlying malloc's result p: - -p[0:4] - Number of bytes originally asked for. 4-byte unsigned integer, - big-endian (easier to read in a memory dump). -p[4:8] - Copies of FORBIDDENBYTE. Used to catch under- writes and reads. -p[8:8+n] - The requested memory, filled with copies of CLEANBYTE. - Used to catch reference to uninitialized memory. - &p[8] is returned. Note that this is 8-byte aligned if pymalloc - handled the request itself. -p[8+n:8+n+4] - Copies of FORBIDDENBYTE. Used to catch over- writes and reads. -p[8+n+4:8+n+8] - A serial number, incremented by 1 on each call to _PyObject_DebugMalloc - and _PyObject_DebugRealloc. - 4-byte unsigned integer, big-endian. - If "bad memory" is detected later, the serial number gives an - excellent way to set a breakpoint on the next run, to capture the - instant at which this block was passed out. -*/ - -void * -_PyObject_DebugMalloc(size_t nbytes) -{ - uchar *p; /* base address of malloc'ed block */ - uchar *tail; /* p + 8 + nbytes == pointer to tail pad bytes */ - size_t total; /* nbytes + 16 */ - - bumpserialno(); - total = nbytes + 16; - if (total < nbytes || (total >> 31) > 1) { - /* overflow, or we can't represent it in 4 bytes */ - /* Obscure: can't do (total >> 32) != 0 instead, because - C doesn't define what happens for a right-shift of 32 - when size_t is a 32-bit type. At least C guarantees - size_t is an unsigned type. */ - return NULL; - } - - p = (uchar *)PyObject_Malloc(total); - if (p == NULL) - return NULL; - - write4(p, nbytes); - p[4] = p[5] = p[6] = p[7] = FORBIDDENBYTE; - - if (nbytes > 0) - memset(p+8, CLEANBYTE, nbytes); - - tail = p + 8 + nbytes; - tail[0] = tail[1] = tail[2] = tail[3] = FORBIDDENBYTE; - write4(tail + 4, serialno); - - return p+8; -} - -/* The debug free first checks the 8 bytes on each end for sanity (in - particular, that the FORBIDDENBYTEs are still intact). - Then fills the original bytes with DEADBYTE. - Then calls the underlying free. -*/ -void -_PyObject_DebugFree(void *p) -{ - uchar *q = (uchar *)p; - size_t nbytes; - - if (p == NULL) - return; - _PyObject_DebugCheckAddress(p); - nbytes = read4(q-8); - if (nbytes > 0) - memset(q, DEADBYTE, nbytes); - PyObject_Free(q-8); -} - -void * -_PyObject_DebugRealloc(void *p, size_t nbytes) -{ - uchar *q = (uchar *)p; - uchar *tail; - size_t total; /* nbytes + 16 */ - size_t original_nbytes; - - if (p == NULL) - return _PyObject_DebugMalloc(nbytes); - - _PyObject_DebugCheckAddress(p); - bumpserialno(); - original_nbytes = read4(q-8); - total = nbytes + 16; - if (total < nbytes || (total >> 31) > 1) { - /* overflow, or we can't represent it in 4 bytes */ - return NULL; - } - - if (nbytes < original_nbytes) { - /* shrinking: mark old extra memory dead */ - memset(q + nbytes, DEADBYTE, original_nbytes - nbytes); - } - - /* Resize and add decorations. */ - q = (uchar *)PyObject_Realloc(q-8, total); - if (q == NULL) - return NULL; - - write4(q, nbytes); - assert(q[4] == FORBIDDENBYTE && - q[5] == FORBIDDENBYTE && - q[6] == FORBIDDENBYTE && - q[7] == FORBIDDENBYTE); - q += 8; - tail = q + nbytes; - tail[0] = tail[1] = tail[2] = tail[3] = FORBIDDENBYTE; - write4(tail + 4, serialno); - - if (nbytes > original_nbytes) { - /* growing: mark new extra memory clean */ - memset(q + original_nbytes, CLEANBYTE, - nbytes - original_nbytes); - } - - return q; -} - -/* Check the forbidden bytes on both ends of the memory allocated for p. - * If anything is wrong, print info to stderr via _PyObject_DebugDumpAddress, - * and call Py_FatalError to kill the program. - */ - void -_PyObject_DebugCheckAddress(const void *p) -{ - const uchar *q = (const uchar *)p; - char *msg; - ulong nbytes; - const uchar *tail; - int i; - - if (p == NULL) { - msg = "didn't expect a NULL pointer"; - goto error; - } - - /* Check the stuff at the start of p first: if there's underwrite - * corruption, the number-of-bytes field may be nuts, and checking - * the tail could lead to a segfault then. - */ - for (i = 4; i >= 1; --i) { - if (*(q-i) != FORBIDDENBYTE) { - msg = "bad leading pad byte"; - goto error; - } - } - - nbytes = read4(q-8); - tail = q + nbytes; - for (i = 0; i < 4; ++i) { - if (tail[i] != FORBIDDENBYTE) { - msg = "bad trailing pad byte"; - goto error; - } - } - - return; - -error: - _PyObject_DebugDumpAddress(p); - Py_FatalError(msg); -} - -/* Display info to stderr about the memory block at p. */ -void -_PyObject_DebugDumpAddress(const void *p) -{ - const uchar *q = (const uchar *)p; - const uchar *tail; - ulong nbytes, serial; - int i; - - fprintf(stderr, "Debug memory block at address p=%p:\n", p); - if (p == NULL) - return; - - nbytes = read4(q-8); - fprintf(stderr, " %lu bytes originally requested\n", nbytes); - - /* In case this is nuts, check the leading pad bytes first. */ - fputs(" The 4 pad bytes at p-4 are ", stderr); - if (*(q-4) == FORBIDDENBYTE && - *(q-3) == FORBIDDENBYTE && - *(q-2) == FORBIDDENBYTE && - *(q-1) == FORBIDDENBYTE) { - fputs("FORBIDDENBYTE, as expected.\n", stderr); - } - else { - fprintf(stderr, "not all FORBIDDENBYTE (0x%02x):\n", - FORBIDDENBYTE); - for (i = 4; i >= 1; --i) { - const uchar byte = *(q-i); - fprintf(stderr, " at p-%d: 0x%02x", i, byte); - if (byte != FORBIDDENBYTE) - fputs(" *** OUCH", stderr); - fputc('\n', stderr); - } - - fputs(" Because memory is corrupted at the start, the " - "count of bytes requested\n" - " may be bogus, and checking the trailing pad " - "bytes may segfault.\n", stderr); - } - - tail = q + nbytes; - fprintf(stderr, " The 4 pad bytes at tail=%p are ", tail); - if (tail[0] == FORBIDDENBYTE && - tail[1] == FORBIDDENBYTE && - tail[2] == FORBIDDENBYTE && - tail[3] == FORBIDDENBYTE) { - fputs("FORBIDDENBYTE, as expected.\n", stderr); - } - else { - fprintf(stderr, "not all FORBIDDENBYTE (0x%02x):\n", - FORBIDDENBYTE); - for (i = 0; i < 4; ++i) { - const uchar byte = tail[i]; - fprintf(stderr, " at tail+%d: 0x%02x", - i, byte); - if (byte != FORBIDDENBYTE) - fputs(" *** OUCH", stderr); - fputc('\n', stderr); - } - } - - serial = read4(tail+4); - fprintf(stderr, " The block was made by call #%lu to " - "debug malloc/realloc.\n", serial); - - if (nbytes > 0) { - int i = 0; - fputs(" Data at p:", stderr); - /* print up to 8 bytes at the start */ - while (q < tail && i < 8) { - fprintf(stderr, " %02x", *q); - ++i; - ++q; - } - /* and up to 8 at the end */ - if (q < tail) { - if (tail - q > 8) { - fputs(" ...", stderr); - q = tail - 8; - } - while (q < tail) { - fprintf(stderr, " %02x", *q); - ++q; - } - } - fputc('\n', stderr); - } -} - -static ulong -printone(const char* msg, ulong value) -{ - int i, k; - char buf[100]; - ulong origvalue = value; - - fputs(msg, stderr); - for (i = (int)strlen(msg); i < 35; ++i) - fputc(' ', stderr); - fputc('=', stderr); - - /* Write the value with commas. */ - i = 22; - buf[i--] = '\0'; - buf[i--] = '\n'; - k = 3; - do { - ulong nextvalue = value / 10UL; - uint digit = value - nextvalue * 10UL; - value = nextvalue; - buf[i--] = (char)(digit + '0'); - --k; - if (k == 0 && value && i >= 0) { - k = 3; - buf[i--] = ','; - } - } while (value && i >= 0); - - while (i >= 0) - buf[i--] = ' '; - fputs(buf, stderr); - - return origvalue; -} - -/* Print summary info to stderr about the state of pymalloc's structures. - * In Py_DEBUG mode, also perform some expensive internal consistency - * checks. - */ -void -_PyObject_DebugMallocStats(void) -{ - uint i; - const uint numclasses = SMALL_REQUEST_THRESHOLD >> ALIGNMENT_SHIFT; - /* # of pools, allocated blocks, and free blocks per class index */ - ulong numpools[SMALL_REQUEST_THRESHOLD >> ALIGNMENT_SHIFT]; - ulong numblocks[SMALL_REQUEST_THRESHOLD >> ALIGNMENT_SHIFT]; - ulong numfreeblocks[SMALL_REQUEST_THRESHOLD >> ALIGNMENT_SHIFT]; - /* total # of allocated bytes in used and full pools */ - ulong allocated_bytes = 0; - /* total # of available bytes in used pools */ - ulong available_bytes = 0; - /* # of free pools + pools not yet carved out of current arena */ - uint numfreepools = 0; - /* # of bytes for arena alignment padding */ - ulong arena_alignment = 0; - /* # of bytes in used and full pools used for pool_headers */ - ulong pool_header_bytes = 0; - /* # of bytes in used and full pools wasted due to quantization, - * i.e. the necessarily leftover space at the ends of used and - * full pools. - */ - ulong quantization = 0; - /* running total -- should equal narenas * ARENA_SIZE */ - ulong total; - char buf[128]; - - fprintf(stderr, "Small block threshold = %d, in %u size classes.\n", - SMALL_REQUEST_THRESHOLD, numclasses); - - for (i = 0; i < numclasses; ++i) - numpools[i] = numblocks[i] = numfreeblocks[i] = 0; - - /* Because full pools aren't linked to from anything, it's easiest - * to march over all the arenas. If we're lucky, most of the memory - * will be living in full pools -- would be a shame to miss them. - */ - for (i = 0; i < narenas; ++i) { - uint poolsinarena; - uint j; - uptr base = arenas[i]; - - /* round up to pool alignment */ - poolsinarena = ARENA_SIZE / POOL_SIZE; - if (base & (uptr)POOL_SIZE_MASK) { - --poolsinarena; - arena_alignment += POOL_SIZE; - base &= ~(uptr)POOL_SIZE_MASK; - base += POOL_SIZE; - } - - if (i == narenas - 1) { - /* current arena may have raw memory at the end */ - numfreepools += nfreepools; - poolsinarena -= nfreepools; - } - - /* visit every pool in the arena */ - for (j = 0; j < poolsinarena; ++j, base += POOL_SIZE) { - poolp p = (poolp)base; - const uint sz = p->szidx; - uint freeblocks; - - if (p->ref.count == 0) { - /* currently unused */ - ++numfreepools; - assert(pool_is_in_list(p, freepools)); - continue; - } - ++numpools[sz]; - numblocks[sz] += p->ref.count; - freeblocks = NUMBLOCKS(sz) - p->ref.count; - numfreeblocks[sz] += freeblocks; -#ifdef Py_DEBUG - if (freeblocks > 0) - assert(pool_is_in_list(p, usedpools[sz + sz])); -#endif - } - } - - fputc('\n', stderr); - fputs("class size num pools blocks in use avail blocks\n" - "----- ---- --------- ------------- ------------\n", - stderr); - - for (i = 0; i < numclasses; ++i) { - ulong p = numpools[i]; - ulong b = numblocks[i]; - ulong f = numfreeblocks[i]; - uint size = INDEX2SIZE(i); - if (p == 0) { - assert(b == 0 && f == 0); - continue; - } - fprintf(stderr, "%5u %6u %11lu %15lu %13lu\n", - i, size, p, b, f); - allocated_bytes += b * size; - available_bytes += f * size; - pool_header_bytes += p * POOL_OVERHEAD; - quantization += p * ((POOL_SIZE - POOL_OVERHEAD) % size); - } - fputc('\n', stderr); - (void)printone("# times object malloc called", serialno); - - PyOS_snprintf(buf, sizeof(buf), - "%u arenas * %d bytes/arena", narenas, ARENA_SIZE); - (void)printone(buf, (ulong)narenas * ARENA_SIZE); - - fputc('\n', stderr); - - total = printone("# bytes in allocated blocks", allocated_bytes); - total += printone("# bytes in available blocks", available_bytes); - - PyOS_snprintf(buf, sizeof(buf), - "%u unused pools * %d bytes", numfreepools, POOL_SIZE); - total += printone(buf, (ulong)numfreepools * POOL_SIZE); - - total += printone("# bytes lost to pool headers", pool_header_bytes); - total += printone("# bytes lost to quantization", quantization); - total += printone("# bytes lost to arena alignment", arena_alignment); - (void)printone("Total", total); -} - -#endif /* PYMALLOC_DEBUG */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/rangeobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/rangeobject.c deleted file mode 100644 index 635f0dd8..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/rangeobject.c +++ /dev/null @@ -1,287 +0,0 @@ -/* Range object implementation */ - -#include "Python.h" - -typedef struct { - PyObject_HEAD - long start; - long step; - long len; -} rangeobject; - -PyObject * -PyRange_New(long start, long len, long step, int reps) -{ - rangeobject *obj; - - if (reps != 1) { - PyErr_SetString(PyExc_ValueError, - "PyRange_New's 'repetitions' argument must be 1"); - return NULL; - } - - obj = PyObject_New(rangeobject, &PyRange_Type); - if (obj == NULL) - return NULL; - - if (len == 0) { - start = 0; - len = 0; - step = 1; - } - else { - long last = start + (len - 1) * step; - if ((step > 0) ? - (last > (PyInt_GetMax() - step)) : - (last < (-1 - PyInt_GetMax() - step))) { - PyErr_SetString(PyExc_OverflowError, - "integer addition"); - return NULL; - } - } - obj->start = start; - obj->len = len; - obj->step = step; - - return (PyObject *) obj; -} - -/* Return number of items in range/xrange (lo, hi, step). step > 0 - * required. Return a value < 0 if & only if the true value is too - * large to fit in a signed long. - */ -static long -get_len_of_range(long lo, long hi, long step) -{ - /* ------------------------------------------------------------- - If lo >= hi, the range is empty. - Else if n values are in the range, the last one is - lo + (n-1)*step, which must be <= hi-1. Rearranging, - n <= (hi - lo - 1)/step + 1, so taking the floor of the RHS gives - the proper value. Since lo < hi in this case, hi-lo-1 >= 0, so - the RHS is non-negative and so truncation is the same as the - floor. Letting M be the largest positive long, the worst case - for the RHS numerator is hi=M, lo=-M-1, and then - hi-lo-1 = M-(-M-1)-1 = 2*M. Therefore unsigned long has enough - precision to compute the RHS exactly. - ---------------------------------------------------------------*/ - long n = 0; - if (lo < hi) { - unsigned long uhi = (unsigned long)hi; - unsigned long ulo = (unsigned long)lo; - unsigned long diff = uhi - ulo - 1; - n = (long)(diff / (unsigned long)step + 1); - } - return n; -} - -static PyObject * -range_new(PyTypeObject *type, PyObject *args, PyObject *kw) -{ - long ilow = 0, ihigh = 0, istep = 1; - long n; - - if (PyTuple_Size(args) <= 1) { - if (!PyArg_ParseTuple(args, - "l;xrange() requires 1-3 int arguments", - &ihigh)) - return NULL; - } - else { - if (!PyArg_ParseTuple(args, - "ll|l;xrange() requires 1-3 int arguments", - &ilow, &ihigh, &istep)) - return NULL; - } - if (istep == 0) { - PyErr_SetString(PyExc_ValueError, "xrange() arg 3 must not be zero"); - return NULL; - } - if (istep > 0) - n = get_len_of_range(ilow, ihigh, istep); - else - n = get_len_of_range(ihigh, ilow, -istep); - if (n < 0) { - PyErr_SetString(PyExc_OverflowError, - "xrange() result has too many items"); - return NULL; - } - return PyRange_New(ilow, n, istep, 1); -} - -PyDoc_STRVAR(range_doc, -"xrange([start,] stop[, step]) -> xrange object\n\ -\n\ -Like range(), but instead of returning a list, returns an object that\n\ -generates the numbers in the range on demand. For looping, this is \n\ -slightly faster than range() and more memory efficient."); - -static PyObject * -range_item(rangeobject *r, int i) -{ - if (i < 0 || i >= r->len) { - PyErr_SetString(PyExc_IndexError, - "xrange object index out of range"); - return NULL; - } - return PyInt_FromLong(r->start + (i % r->len) * r->step); -} - -static int -range_length(rangeobject *r) -{ -#if LONG_MAX != INT_MAX - if (r->len > INT_MAX) { - PyErr_SetString(PyExc_ValueError, - "xrange object size cannot be reported"); - return -1; - } -#endif - return (int)(r->len); -} - -static PyObject * -range_repr(rangeobject *r) -{ - PyObject *rtn; - - if (r->start == 0 && r->step == 1) - rtn = PyString_FromFormat("xrange(%ld)", - r->start + r->len * r->step); - - else if (r->step == 1) - rtn = PyString_FromFormat("xrange(%ld, %ld)", - r->start, - r->start + r->len * r->step); - - else - rtn = PyString_FromFormat("xrange(%ld, %ld, %ld)", - r->start, - r->start + r->len * r->step, - r->step); - return rtn; -} - -static PySequenceMethods range_as_sequence = { - (inquiry)range_length, /* sq_length */ - 0, /* sq_concat */ - 0, /* sq_repeat */ - (intargfunc)range_item, /* sq_item */ - 0, /* sq_slice */ -}; - -static PyObject * range_iter(PyObject *seq); - -PyTypeObject PyRange_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* Number of items for varobject */ - "xrange", /* Name of this type */ - sizeof(rangeobject), /* Basic object size */ - 0, /* Item size for varobject */ - (destructor)PyObject_Del, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)range_repr, /* tp_repr */ - 0, /* tp_as_number */ - &range_as_sequence, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - range_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc)range_iter, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - range_new, /* tp_new */ -}; - -/*********************** Xrange Iterator **************************/ - -typedef struct { - PyObject_HEAD - long index; - long start; - long step; - long len; -} rangeiterobject; - -static PyTypeObject Pyrangeiter_Type; - -static PyObject * -range_iter(PyObject *seq) -{ - rangeiterobject *it; - - if (!PyRange_Check(seq)) { - PyErr_BadInternalCall(); - return NULL; - } - it = PyObject_New(rangeiterobject, &Pyrangeiter_Type); - if (it == NULL) - return NULL; - it->index = 0; - it->start = ((rangeobject *)seq)->start; - it->step = ((rangeobject *)seq)->step; - it->len = ((rangeobject *)seq)->len; - return (PyObject *)it; -} - -static PyObject * -rangeiter_next(rangeiterobject *r) -{ - if (r->index < r->len) - return PyInt_FromLong(r->start + (r->index++) * r->step); - return NULL; -} - -static PyTypeObject Pyrangeiter_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "rangeiterator", /* tp_name */ - sizeof(rangeiterobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)PyObject_Del, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - 0, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)rangeiter_next, /* tp_iternext */ - 0, /* tp_methods */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/sliceobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/sliceobject.c deleted file mode 100644 index 90367b0d..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/sliceobject.c +++ /dev/null @@ -1,328 +0,0 @@ -/* -Written by Jim Hugunin and Chris Chase. - -This includes both the singular ellipsis object and slice objects. - -Guido, feel free to do whatever you want in the way of copyrights -for this file. -*/ - -/* -Py_Ellipsis encodes the '...' rubber index token. It is similar to -the Py_NoneStruct in that there is no way to create other objects of -this type and there is exactly one in existence. -*/ - -#include "Python.h" -#include "structmember.h" - -static PyObject * -ellipsis_repr(PyObject *op) -{ - return PyString_FromString("Ellipsis"); -} - -static PyTypeObject PyEllipsis_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "ellipsis", /* tp_name */ - 0, /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /*never called*/ /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)ellipsis_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ -}; - -PyObject _Py_EllipsisObject = { - PyObject_HEAD_INIT(&PyEllipsis_Type) -}; - - -/* Slice object implementation - - start, stop, and step are python objects with None indicating no - index is present. -*/ - -PyObject * -PySlice_New(PyObject *start, PyObject *stop, PyObject *step) -{ - PySliceObject *obj = PyObject_New(PySliceObject, &PySlice_Type); - - if (obj == NULL) - return NULL; - - if (step == NULL) step = Py_None; - Py_INCREF(step); - if (start == NULL) start = Py_None; - Py_INCREF(start); - if (stop == NULL) stop = Py_None; - Py_INCREF(stop); - - obj->step = step; - obj->start = start; - obj->stop = stop; - - return (PyObject *) obj; -} - -int -PySlice_GetIndices(PySliceObject *r, int length, - int *start, int *stop, int *step) -{ - if (r->step == Py_None) { - *step = 1; - } else { - if (!PyInt_Check(r->step)) return -1; - *step = PyInt_AsLong(r->step); - } - if (r->start == Py_None) { - *start = *step < 0 ? length-1 : 0; - } else { - if (!PyInt_Check(r->start)) return -1; - *start = PyInt_AsLong(r->start); - if (*start < 0) *start += length; - } - if (r->stop == Py_None) { - *stop = *step < 0 ? -1 : length; - } else { - if (!PyInt_Check(r->stop)) return -1; - *stop = PyInt_AsLong(r->stop); - if (*stop < 0) *stop += length; - } - if (*stop > length) return -1; - if (*start >= length) return -1; - if (*step == 0) return -1; - return 0; -} - -int -PySlice_GetIndicesEx(PySliceObject *r, int length, - int *start, int *stop, int *step, int *slicelength) -{ - /* this is harder to get right than you might think */ - - int defstart, defstop; - - if (r->step == Py_None) { - *step = 1; - } - else { - if (!_PyEval_SliceIndex(r->step, step)) return -1; - if (*step == 0) { - PyErr_SetString(PyExc_ValueError, - "slice step cannot be zero"); - return -1; - } - } - - defstart = *step < 0 ? length-1 : 0; - defstop = *step < 0 ? -1 : length; - - if (r->start == Py_None) { - *start = defstart; - } - else { - if (!_PyEval_SliceIndex(r->start, start)) return -1; - if (*start < 0) *start += length; - if (*start < 0) *start = (*step < 0) ? -1 : 0; - if (*start >= length) - *start = (*step < 0) ? length - 1 : length; - } - - if (r->stop == Py_None) { - *stop = defstop; - } - else { - if (!_PyEval_SliceIndex(r->stop, stop)) return -1; - if (*stop < 0) *stop += length; - if (*stop < 0) *stop = -1; - if (*stop > length) *stop = length; - } - - if ((*step < 0 && *stop >= *start) - || (*step > 0 && *start >= *stop)) { - *slicelength = 0; - } - else if (*step < 0) { - *slicelength = (*stop-*start+1)/(*step)+1; - } - else { - *slicelength = (*stop-*start-1)/(*step)+1; - } - - return 0; -} - -static PyObject * -slice_new(PyTypeObject *type, PyObject *args, PyObject *kw) -{ - PyObject *start, *stop, *step; - - start = stop = step = NULL; - - if (!PyArg_UnpackTuple(args, "slice", 1, 3, &start, &stop, &step)) - return NULL; - - /* This swapping of stop and start is to maintain similarity with - range(). */ - if (stop == NULL) { - stop = start; - start = NULL; - } - return PySlice_New(start, stop, step); -} - -PyDoc_STRVAR(slice_doc, -"slice([start,] stop[, step])\n\ -\n\ -Create a slice object. This is used for extended slicing (e.g. a[0:10:2])."); - -static void -slice_dealloc(PySliceObject *r) -{ - Py_DECREF(r->step); - Py_DECREF(r->start); - Py_DECREF(r->stop); - PyObject_Del(r); -} - -static PyObject * -slice_repr(PySliceObject *r) -{ - PyObject *s, *comma; - - s = PyString_FromString("slice("); - comma = PyString_FromString(", "); - PyString_ConcatAndDel(&s, PyObject_Repr(r->start)); - PyString_Concat(&s, comma); - PyString_ConcatAndDel(&s, PyObject_Repr(r->stop)); - PyString_Concat(&s, comma); - PyString_ConcatAndDel(&s, PyObject_Repr(r->step)); - PyString_ConcatAndDel(&s, PyString_FromString(")")); - Py_DECREF(comma); - return s; -} - -static PyMemberDef slice_members[] = { - {"start", T_OBJECT, offsetof(PySliceObject, start), READONLY}, - {"stop", T_OBJECT, offsetof(PySliceObject, stop), READONLY}, - {"step", T_OBJECT, offsetof(PySliceObject, step), READONLY}, - {0} -}; - -static PyObject* -slice_indices(PySliceObject* self, PyObject* len) -{ - int ilen, start, stop, step, slicelength; - - ilen = PyInt_AsLong(len); - - if (ilen == -1 && PyErr_Occurred()) { - return NULL; - } - - if (PySlice_GetIndicesEx(self, ilen, &start, &stop, - &step, &slicelength) < 0) { - return NULL; - } - - return Py_BuildValue("(iii)", start, stop, step); -} - -PyDoc_STRVAR(slice_indices_doc, -"S.indices(len) -> (start, stop, stride)\n\ -\n\ -Assuming a sequence of length len, calculate the start and stop\n\ -indices, and the stride length of the extended slice described by\n\ -S. Out of bounds indices are clipped in a manner consistent with the\n\ -handling of normal slices."); - -static PyMethodDef slice_methods[] = { - {"indices", (PyCFunction)slice_indices, - METH_O, slice_indices_doc}, - {NULL, NULL} -}; - -static int -slice_compare(PySliceObject *v, PySliceObject *w) -{ - int result = 0; - - if (v == w) - return 0; - - if (PyObject_Cmp(v->start, w->start, &result) < 0) - return -2; - if (result != 0) - return result; - if (PyObject_Cmp(v->stop, w->stop, &result) < 0) - return -2; - if (result != 0) - return result; - if (PyObject_Cmp(v->step, w->step, &result) < 0) - return -2; - return result; -} - -static long -slice_hash(PySliceObject *v) -{ - PyErr_SetString(PyExc_TypeError, "unhashable type"); - return -1L; -} - -PyTypeObject PySlice_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* Number of items for varobject */ - "slice", /* Name of this type */ - sizeof(PySliceObject), /* Basic object size */ - 0, /* Item size for varobject */ - (destructor)slice_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)slice_compare, /* tp_compare */ - (reprfunc)slice_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)slice_hash, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - slice_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - slice_methods, /* tp_methods */ - slice_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - slice_new, /* tp_new */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/stringobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/stringobject.c deleted file mode 100644 index 74b58154..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/stringobject.c +++ /dev/null @@ -1,4228 +0,0 @@ -/* String object implementation */ - -#include "Python.h" - -#include - -#ifdef COUNT_ALLOCS -int null_strings, one_strings; -#endif - -#if !defined(HAVE_LIMITS_H) && !defined(UCHAR_MAX) -#define UCHAR_MAX 255 -#endif - -static PyStringObject *characters[UCHAR_MAX + 1]; -static PyStringObject *nullstring; - -/* This dictionary holds all interned strings. Note that references to - strings in this dictionary are *not* counted in the string's ob_refcnt. - When the interned string reaches a refcnt of 0 the string deallocation - function will delete the reference from this dictionary. - - Another way to look at this is that to say that the actual reference - count of a string is: s->ob_refcnt + (s->ob_sstate?2:0) -*/ -static PyObject *interned; - - -/* - For both PyString_FromString() and PyString_FromStringAndSize(), the - parameter `size' denotes number of characters to allocate, not counting any - null terminating character. - - For PyString_FromString(), the parameter `str' points to a null-terminated - string containing exactly `size' bytes. - - For PyString_FromStringAndSize(), the parameter the parameter `str' is - either NULL or else points to a string containing at least `size' bytes. - For PyString_FromStringAndSize(), the string in the `str' parameter does - not have to be null-terminated. (Therefore it is safe to construct a - substring by calling `PyString_FromStringAndSize(origstring, substrlen)'.) - If `str' is NULL then PyString_FromStringAndSize() will allocate `size+1' - bytes (setting the last byte to the null terminating character) and you can - fill in the data yourself. If `str' is non-NULL then the resulting - PyString object must be treated as immutable and you must not fill in nor - alter the data yourself, since the strings may be shared. - - The PyObject member `op->ob_size', which denotes the number of "extra - items" in a variable-size object, will contain the number of bytes - allocated for string data, not counting the null terminating character. It - is therefore equal to the equal to the `size' parameter (for - PyString_FromStringAndSize()) or the length of the string in the `str' - parameter (for PyString_FromString()). -*/ -PyObject * -PyString_FromStringAndSize(const char *str, int size) -{ - register PyStringObject *op; - if (size == 0 && (op = nullstring) != NULL) { -#ifdef COUNT_ALLOCS - null_strings++; -#endif - Py_INCREF(op); - return (PyObject *)op; - } - if (size == 1 && str != NULL && - (op = characters[*str & UCHAR_MAX]) != NULL) - { -#ifdef COUNT_ALLOCS - one_strings++; -#endif - Py_INCREF(op); - return (PyObject *)op; - } - - /* Inline PyObject_NewVar */ - op = (PyStringObject *) - PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); - if (op == NULL) - return PyErr_NoMemory(); - PyObject_INIT_VAR(op, &PyString_Type, size); - op->ob_shash = -1; - op->ob_sstate = SSTATE_NOT_INTERNED; - if (str != NULL) - memcpy(op->ob_sval, str, size); - op->ob_sval[size] = '\0'; - /* share short strings */ - if (size == 0) { - PyObject *t = (PyObject *)op; - PyString_InternInPlace(&t); - op = (PyStringObject *)t; - nullstring = op; - Py_INCREF(op); - } else if (size == 1 && str != NULL) { - PyObject *t = (PyObject *)op; - PyString_InternInPlace(&t); - op = (PyStringObject *)t; - characters[*str & UCHAR_MAX] = op; - Py_INCREF(op); - } - return (PyObject *) op; -} - -PyObject * -PyString_FromString(const char *str) -{ - register size_t size; - register PyStringObject *op; - - assert(str != NULL); - size = strlen(str); - if (size > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "string is too long for a Python string"); - return NULL; - } - if (size == 0 && (op = nullstring) != NULL) { -#ifdef COUNT_ALLOCS - null_strings++; -#endif - Py_INCREF(op); - return (PyObject *)op; - } - if (size == 1 && (op = characters[*str & UCHAR_MAX]) != NULL) { -#ifdef COUNT_ALLOCS - one_strings++; -#endif - Py_INCREF(op); - return (PyObject *)op; - } - - /* Inline PyObject_NewVar */ - op = (PyStringObject *) - PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); - if (op == NULL) - return PyErr_NoMemory(); - PyObject_INIT_VAR(op, &PyString_Type, size); - op->ob_shash = -1; - op->ob_sstate = SSTATE_NOT_INTERNED; - memcpy(op->ob_sval, str, size+1); - /* share short strings */ - if (size == 0) { - PyObject *t = (PyObject *)op; - PyString_InternInPlace(&t); - op = (PyStringObject *)t; - nullstring = op; - Py_INCREF(op); - } else if (size == 1) { - PyObject *t = (PyObject *)op; - PyString_InternInPlace(&t); - op = (PyStringObject *)t; - characters[*str & UCHAR_MAX] = op; - Py_INCREF(op); - } - return (PyObject *) op; -} - -PyObject * -PyString_FromFormatV(const char *format, va_list vargs) -{ - va_list count; - int n = 0; - const char* f; - char *s; - PyObject* string; - -#ifdef VA_LIST_IS_ARRAY - memcpy(count, vargs, sizeof(va_list)); -#else -#ifdef __va_copy - __va_copy(count, vargs); -#else - count = vargs; -#endif -#endif - /* step 1: figure out how large a buffer we need */ - for (f = format; *f; f++) { - if (*f == '%') { - const char* p = f; - while (*++f && *f != '%' && !isalpha(Py_CHARMASK(*f))) - ; - - /* skip the 'l' in %ld, since it doesn't change the - width. although only %d is supported (see - "expand" section below), others can be easily - added */ - if (*f == 'l' && *(f+1) == 'd') - ++f; - - switch (*f) { - case 'c': - (void)va_arg(count, int); - /* fall through... */ - case '%': - n++; - break; - case 'd': case 'i': case 'x': - (void) va_arg(count, int); - /* 20 bytes is enough to hold a 64-bit - integer. Decimal takes the most space. - This isn't enough for octal. */ - n += 20; - break; - case 's': - s = va_arg(count, char*); - n += strlen(s); - break; - case 'p': - (void) va_arg(count, int); - /* maximum 64-bit pointer representation: - * 0xffffffffffffffff - * so 19 characters is enough. - * XXX I count 18 -- what's the extra for? - */ - n += 19; - break; - default: - /* if we stumble upon an unknown - formatting code, copy the rest of - the format string to the output - string. (we cannot just skip the - code, since there's no way to know - what's in the argument list) */ - n += strlen(p); - goto expand; - } - } else - n++; - } - expand: - /* step 2: fill the buffer */ - /* Since we've analyzed how much space we need for the worst case, - use sprintf directly instead of the slower PyOS_snprintf. */ - string = PyString_FromStringAndSize(NULL, n); - if (!string) - return NULL; - - s = PyString_AsString(string); - - for (f = format; *f; f++) { - if (*f == '%') { - const char* p = f++; - int i, longflag = 0; - /* parse the width.precision part (we're only - interested in the precision value, if any) */ - n = 0; - while (isdigit(Py_CHARMASK(*f))) - n = (n*10) + *f++ - '0'; - if (*f == '.') { - f++; - n = 0; - while (isdigit(Py_CHARMASK(*f))) - n = (n*10) + *f++ - '0'; - } - while (*f && *f != '%' && !isalpha(Py_CHARMASK(*f))) - f++; - /* handle the long flag, but only for %ld. others - can be added when necessary. */ - if (*f == 'l' && *(f+1) == 'd') { - longflag = 1; - ++f; - } - - switch (*f) { - case 'c': - *s++ = va_arg(vargs, int); - break; - case 'd': - if (longflag) - sprintf(s, "%ld", va_arg(vargs, long)); - else - sprintf(s, "%d", va_arg(vargs, int)); - s += strlen(s); - break; - case 'i': - sprintf(s, "%i", va_arg(vargs, int)); - s += strlen(s); - break; - case 'x': - sprintf(s, "%x", va_arg(vargs, int)); - s += strlen(s); - break; - case 's': - p = va_arg(vargs, char*); - i = strlen(p); - if (n > 0 && i > n) - i = n; - memcpy(s, p, i); - s += i; - break; - case 'p': - sprintf(s, "%p", va_arg(vargs, void*)); - /* %p is ill-defined: ensure leading 0x. */ - if (s[1] == 'X') - s[1] = 'x'; - else if (s[1] != 'x') { - memmove(s+2, s, strlen(s)+1); - s[0] = '0'; - s[1] = 'x'; - } - s += strlen(s); - break; - case '%': - *s++ = '%'; - break; - default: - strcpy(s, p); - s += strlen(s); - goto end; - } - } else - *s++ = *f; - } - - end: - _PyString_Resize(&string, s - PyString_AS_STRING(string)); - return string; -} - -PyObject * -PyString_FromFormat(const char *format, ...) -{ - PyObject* ret; - va_list vargs; - -#ifdef HAVE_STDARG_PROTOTYPES - va_start(vargs, format); -#else - va_start(vargs); -#endif - ret = PyString_FromFormatV(format, vargs); - va_end(vargs); - return ret; -} - - -PyObject *PyString_Decode(const char *s, - int size, - const char *encoding, - const char *errors) -{ - PyObject *v, *str; - - str = PyString_FromStringAndSize(s, size); - if (str == NULL) - return NULL; - v = PyString_AsDecodedString(str, encoding, errors); - Py_DECREF(str); - return v; -} - -PyObject *PyString_AsDecodedObject(PyObject *str, - const char *encoding, - const char *errors) -{ - PyObject *v; - - if (!PyString_Check(str)) { - PyErr_BadArgument(); - goto onError; - } - - if (encoding == NULL) { -#ifdef Py_USING_UNICODE - encoding = PyUnicode_GetDefaultEncoding(); -#else - PyErr_SetString(PyExc_ValueError, "no encoding specified"); - goto onError; -#endif - } - - /* Decode via the codec registry */ - v = PyCodec_Decode(str, encoding, errors); - if (v == NULL) - goto onError; - - return v; - - onError: - return NULL; -} - -PyObject *PyString_AsDecodedString(PyObject *str, - const char *encoding, - const char *errors) -{ - PyObject *v; - - v = PyString_AsDecodedObject(str, encoding, errors); - if (v == NULL) - goto onError; - -#ifdef Py_USING_UNICODE - /* Convert Unicode to a string using the default encoding */ - if (PyUnicode_Check(v)) { - PyObject *temp = v; - v = PyUnicode_AsEncodedString(v, NULL, NULL); - Py_DECREF(temp); - if (v == NULL) - goto onError; - } -#endif - if (!PyString_Check(v)) { - PyErr_Format(PyExc_TypeError, - "decoder did not return a string object (type=%.400s)", - v->ob_type->tp_name); - Py_DECREF(v); - goto onError; - } - - return v; - - onError: - return NULL; -} - -PyObject *PyString_Encode(const char *s, - int size, - const char *encoding, - const char *errors) -{ - PyObject *v, *str; - - str = PyString_FromStringAndSize(s, size); - if (str == NULL) - return NULL; - v = PyString_AsEncodedString(str, encoding, errors); - Py_DECREF(str); - return v; -} - -PyObject *PyString_AsEncodedObject(PyObject *str, - const char *encoding, - const char *errors) -{ - PyObject *v; - - if (!PyString_Check(str)) { - PyErr_BadArgument(); - goto onError; - } - - if (encoding == NULL) { -#ifdef Py_USING_UNICODE - encoding = PyUnicode_GetDefaultEncoding(); -#else - PyErr_SetString(PyExc_ValueError, "no encoding specified"); - goto onError; -#endif - } - - /* Encode via the codec registry */ - v = PyCodec_Encode(str, encoding, errors); - if (v == NULL) - goto onError; - - return v; - - onError: - return NULL; -} - -PyObject *PyString_AsEncodedString(PyObject *str, - const char *encoding, - const char *errors) -{ - PyObject *v; - - v = PyString_AsEncodedObject(str, encoding, errors); - if (v == NULL) - goto onError; - -#ifdef Py_USING_UNICODE - /* Convert Unicode to a string using the default encoding */ - if (PyUnicode_Check(v)) { - PyObject *temp = v; - v = PyUnicode_AsEncodedString(v, NULL, NULL); - Py_DECREF(temp); - if (v == NULL) - goto onError; - } -#endif - if (!PyString_Check(v)) { - PyErr_Format(PyExc_TypeError, - "encoder did not return a string object (type=%.400s)", - v->ob_type->tp_name); - Py_DECREF(v); - goto onError; - } - - return v; - - onError: - return NULL; -} - -static void -string_dealloc(PyObject *op) -{ - switch (PyString_CHECK_INTERNED(op)) { - case SSTATE_NOT_INTERNED: - break; - - case SSTATE_INTERNED_MORTAL: - /* revive dead object temporarily for DelItem */ - op->ob_refcnt = 3; - if (PyDict_DelItem(interned, op) != 0) - Py_FatalError( - "deletion of interned string failed"); - break; - - case SSTATE_INTERNED_IMMORTAL: - Py_FatalError("Immortal interned string died."); - - default: - Py_FatalError("Inconsistent interned string state."); - } - op->ob_type->tp_free(op); -} - -/* Unescape a backslash-escaped string. If unicode is non-zero, - the string is a u-literal. If recode_encoding is non-zero, - the string is UTF-8 encoded and should be re-encoded in the - specified encoding. */ - -PyObject *PyString_DecodeEscape(const char *s, - int len, - const char *errors, - int unicode, - const char *recode_encoding) -{ - int c; - char *p, *buf; - const char *end; - PyObject *v; - int newlen = recode_encoding ? 4*len:len; - v = PyString_FromStringAndSize((char *)NULL, newlen); - if (v == NULL) - return NULL; - p = buf = PyString_AsString(v); - end = s + len; - while (s < end) { - if (*s != '\\') { - non_esc: -#ifdef Py_USING_UNICODE - if (recode_encoding && (*s & 0x80)) { - PyObject *u, *w; - char *r; - const char* t; - int rn; - t = s; - /* Decode non-ASCII bytes as UTF-8. */ - while (t < end && (*t & 0x80)) t++; - u = PyUnicode_DecodeUTF8(s, t - s, errors); - if(!u) goto failed; - - /* Recode them in target encoding. */ - w = PyUnicode_AsEncodedString( - u, recode_encoding, errors); - Py_DECREF(u); - if (!w) goto failed; - - /* Append bytes to output buffer. */ - r = PyString_AsString(w); - rn = PyString_Size(w); - memcpy(p, r, rn); - p += rn; - Py_DECREF(w); - s = t; - } else { - *p++ = *s++; - } -#else - *p++ = *s++; -#endif - continue; - } - s++; - if (s==end) { - PyErr_SetString(PyExc_ValueError, - "Trailing \\ in string"); - goto failed; - } - switch (*s++) { - /* XXX This assumes ASCII! */ - case '\n': break; - case '\\': *p++ = '\\'; break; - case '\'': *p++ = '\''; break; - case '\"': *p++ = '\"'; break; - case 'b': *p++ = '\b'; break; - case 'f': *p++ = '\014'; break; /* FF */ - case 't': *p++ = '\t'; break; - case 'n': *p++ = '\n'; break; - case 'r': *p++ = '\r'; break; - case 'v': *p++ = '\013'; break; /* VT */ - case 'a': *p++ = '\007'; break; /* BEL, not classic C */ - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - c = s[-1] - '0'; - if ('0' <= *s && *s <= '7') { - c = (c<<3) + *s++ - '0'; - if ('0' <= *s && *s <= '7') - c = (c<<3) + *s++ - '0'; - } - *p++ = c; - break; - case 'x': - if (isxdigit(Py_CHARMASK(s[0])) - && isxdigit(Py_CHARMASK(s[1]))) { - unsigned int x = 0; - c = Py_CHARMASK(*s); - s++; - if (isdigit(c)) - x = c - '0'; - else if (islower(c)) - x = 10 + c - 'a'; - else - x = 10 + c - 'A'; - x = x << 4; - c = Py_CHARMASK(*s); - s++; - if (isdigit(c)) - x += c - '0'; - else if (islower(c)) - x += 10 + c - 'a'; - else - x += 10 + c - 'A'; - *p++ = x; - break; - } - if (!errors || strcmp(errors, "strict") == 0) { - PyErr_SetString(PyExc_ValueError, - "invalid \\x escape"); - goto failed; - } - if (strcmp(errors, "replace") == 0) { - *p++ = '?'; - } else if (strcmp(errors, "ignore") == 0) - /* do nothing */; - else { - PyErr_Format(PyExc_ValueError, - "decoding error; " - "unknown error handling code: %.400s", - errors); - goto failed; - } -#ifndef Py_USING_UNICODE - case 'u': - case 'U': - case 'N': - if (unicode) { - PyErr_SetString(PyExc_ValueError, - "Unicode escapes not legal " - "when Unicode disabled"); - goto failed; - } -#endif - default: - *p++ = '\\'; - s--; - goto non_esc; /* an arbitry number of unescaped - UTF-8 bytes may follow. */ - } - } - if (p-buf < newlen) - _PyString_Resize(&v, (int)(p - buf)); - return v; - failed: - Py_DECREF(v); - return NULL; -} - -static int -string_getsize(register PyObject *op) -{ - char *s; - int len; - if (PyString_AsStringAndSize(op, &s, &len)) - return -1; - return len; -} - -static /*const*/ char * -string_getbuffer(register PyObject *op) -{ - char *s; - int len; - if (PyString_AsStringAndSize(op, &s, &len)) - return NULL; - return s; -} - -int -PyString_Size(register PyObject *op) -{ - if (!PyString_Check(op)) - return string_getsize(op); - return ((PyStringObject *)op) -> ob_size; -} - -/*const*/ char * -PyString_AsString(register PyObject *op) -{ - if (!PyString_Check(op)) - return string_getbuffer(op); - return ((PyStringObject *)op) -> ob_sval; -} - -int -PyString_AsStringAndSize(register PyObject *obj, - register char **s, - register int *len) -{ - if (s == NULL) { - PyErr_BadInternalCall(); - return -1; - } - - if (!PyString_Check(obj)) { -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(obj)) { - obj = _PyUnicode_AsDefaultEncodedString(obj, NULL); - if (obj == NULL) - return -1; - } - else -#endif - { - PyErr_Format(PyExc_TypeError, - "expected string or Unicode object, " - "%.200s found", obj->ob_type->tp_name); - return -1; - } - } - - *s = PyString_AS_STRING(obj); - if (len != NULL) - *len = PyString_GET_SIZE(obj); - else if ((int)strlen(*s) != PyString_GET_SIZE(obj)) { - PyErr_SetString(PyExc_TypeError, - "expected string without null bytes"); - return -1; - } - return 0; -} - -/* Methods */ - -static int -string_print(PyStringObject *op, FILE *fp, int flags) -{ - int i; - char c; - int quote; - - /* XXX Ought to check for interrupts when writing long strings */ - if (! PyString_CheckExact(op)) { - int ret; - /* A str subclass may have its own __str__ method. */ - op = (PyStringObject *) PyObject_Str((PyObject *)op); - if (op == NULL) - return -1; - ret = string_print(op, fp, flags); - Py_DECREF(op); - return ret; - } - if (flags & Py_PRINT_RAW) { -#ifdef __VMS - if (op->ob_size) fwrite(op->ob_sval, (int) op->ob_size, 1, fp); -#else - fwrite(op->ob_sval, 1, (int) op->ob_size, fp); -#endif - return 0; - } - - /* figure out which quote to use; single is preferred */ - quote = '\''; - if (memchr(op->ob_sval, '\'', op->ob_size) && - !memchr(op->ob_sval, '"', op->ob_size)) - quote = '"'; - - fputc(quote, fp); - for (i = 0; i < op->ob_size; i++) { - c = op->ob_sval[i]; - if (c == quote || c == '\\') - fprintf(fp, "\\%c", c); - else if (c == '\t') - fprintf(fp, "\\t"); - else if (c == '\n') - fprintf(fp, "\\n"); - else if (c == '\r') - fprintf(fp, "\\r"); - else if (c < ' ' || c >= 0x7f) - fprintf(fp, "\\x%02x", c & 0xff); - else - fputc(c, fp); - } - fputc(quote, fp); - return 0; -} - -PyObject * -PyString_Repr(PyObject *obj, int smartquotes) -{ - register PyStringObject* op = (PyStringObject*) obj; - size_t newsize = 2 + 4 * op->ob_size * sizeof(char); - PyObject *v; - if (newsize > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "string is too large to make repr"); - } - v = PyString_FromStringAndSize((char *)NULL, newsize); - if (v == NULL) { - return NULL; - } - else { - register int i; - register char c; - register char *p; - int quote; - - /* figure out which quote to use; single is preferred */ - quote = '\''; - if (smartquotes && - memchr(op->ob_sval, '\'', op->ob_size) && - !memchr(op->ob_sval, '"', op->ob_size)) - quote = '"'; - - p = PyString_AS_STRING(v); - *p++ = quote; - for (i = 0; i < op->ob_size; i++) { - /* There's at least enough room for a hex escape - and a closing quote. */ - assert(newsize - (p - PyString_AS_STRING(v)) >= 5); - c = op->ob_sval[i]; - if (c == quote || c == '\\') - *p++ = '\\', *p++ = c; - else if (c == '\t') - *p++ = '\\', *p++ = 't'; - else if (c == '\n') - *p++ = '\\', *p++ = 'n'; - else if (c == '\r') - *p++ = '\\', *p++ = 'r'; - else if (c < ' ' || c >= 0x7f) { - /* For performance, we don't want to call - PyOS_snprintf here (extra layers of - function call). */ - sprintf(p, "\\x%02x", c & 0xff); - p += 4; - } - else - *p++ = c; - } - assert(newsize - (p - PyString_AS_STRING(v)) >= 1); - *p++ = quote; - *p = '\0'; - _PyString_Resize( - &v, (int) (p - PyString_AS_STRING(v))); - return v; - } -} - -static PyObject * -string_repr(PyObject *op) -{ - return PyString_Repr(op, 1); -} - -static PyObject * -string_str(PyObject *s) -{ - assert(PyString_Check(s)); - if (PyString_CheckExact(s)) { - Py_INCREF(s); - return s; - } - else { - /* Subtype -- return genuine string with the same value. */ - PyStringObject *t = (PyStringObject *) s; - return PyString_FromStringAndSize(t->ob_sval, t->ob_size); - } -} - -static int -string_length(PyStringObject *a) -{ - return a->ob_size; -} - -static PyObject * -string_concat(register PyStringObject *a, register PyObject *bb) -{ - register unsigned int size; - register PyStringObject *op; - if (!PyString_Check(bb)) { -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(bb)) - return PyUnicode_Concat((PyObject *)a, bb); -#endif - PyErr_Format(PyExc_TypeError, - "cannot concatenate 'str' and '%.200s' objects", - bb->ob_type->tp_name); - return NULL; - } -#define b ((PyStringObject *)bb) - /* Optimize cases with empty left or right operand */ - if ((a->ob_size == 0 || b->ob_size == 0) && - PyString_CheckExact(a) && PyString_CheckExact(b)) { - if (a->ob_size == 0) { - Py_INCREF(bb); - return bb; - } - Py_INCREF(a); - return (PyObject *)a; - } - size = a->ob_size + b->ob_size; - /* Inline PyObject_NewVar */ - op = (PyStringObject *) - PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); - if (op == NULL) - return PyErr_NoMemory(); - PyObject_INIT_VAR(op, &PyString_Type, size); - op->ob_shash = -1; - op->ob_sstate = SSTATE_NOT_INTERNED; - memcpy(op->ob_sval, a->ob_sval, (int) a->ob_size); - memcpy(op->ob_sval + a->ob_size, b->ob_sval, (int) b->ob_size); - op->ob_sval[size] = '\0'; - return (PyObject *) op; -#undef b -} - -static PyObject * -string_repeat(register PyStringObject *a, register int n) -{ - register int i; - register int j; - register int size; - register PyStringObject *op; - size_t nbytes; - if (n < 0) - n = 0; - /* watch out for overflows: the size can overflow int, - * and the # of bytes needed can overflow size_t - */ - size = a->ob_size * n; - if (n && size / n != a->ob_size) { - PyErr_SetString(PyExc_OverflowError, - "repeated string is too long"); - return NULL; - } - if (size == a->ob_size && PyString_CheckExact(a)) { - Py_INCREF(a); - return (PyObject *)a; - } - nbytes = size * sizeof(char); - if (nbytes / sizeof(char) != (size_t)size || - nbytes + sizeof(PyStringObject) <= nbytes) { - PyErr_SetString(PyExc_OverflowError, - "repeated string is too long"); - return NULL; - } - op = (PyStringObject *) - PyObject_MALLOC(sizeof(PyStringObject) + nbytes); - if (op == NULL) - return PyErr_NoMemory(); - PyObject_INIT_VAR(op, &PyString_Type, size); - op->ob_shash = -1; - op->ob_sstate = SSTATE_NOT_INTERNED; - op->ob_sval[size] = '\0'; - if (a->ob_size == 1 && n > 0) { - memset(op->ob_sval, a->ob_sval[0] , n); - return (PyObject *) op; - } - i = 0; - if (i < size) { - memcpy(op->ob_sval, a->ob_sval, (int) a->ob_size); - i = (int) a->ob_size; - } - while (i < size) { - j = (i <= size-i) ? i : size-i; - memcpy(op->ob_sval+i, op->ob_sval, j); - i += j; - } - return (PyObject *) op; -} - -/* String slice a[i:j] consists of characters a[i] ... a[j-1] */ - -static PyObject * -string_slice(register PyStringObject *a, register int i, register int j) - /* j -- may be negative! */ -{ - if (i < 0) - i = 0; - if (j < 0) - j = 0; /* Avoid signed/unsigned bug in next line */ - if (j > a->ob_size) - j = a->ob_size; - if (i == 0 && j == a->ob_size && PyString_CheckExact(a)) { - /* It's the same as a */ - Py_INCREF(a); - return (PyObject *)a; - } - if (j < i) - j = i; - return PyString_FromStringAndSize(a->ob_sval + i, (int) (j-i)); -} - -static int -string_contains(PyObject *a, PyObject *el) -{ - const char *lhs, *rhs, *end; - int size; - - if (!PyString_CheckExact(el)) { -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(el)) - return PyUnicode_Contains(a, el); -#endif - if (!PyString_Check(el)) { - PyErr_SetString(PyExc_TypeError, - "'in ' requires string as left operand"); - return -1; - } - } - size = PyString_GET_SIZE(el); - rhs = PyString_AS_STRING(el); - lhs = PyString_AS_STRING(a); - - /* optimize for a single character */ - if (size == 1) - return memchr(lhs, *rhs, PyString_GET_SIZE(a)) != NULL; - - end = lhs + (PyString_GET_SIZE(a) - size); - while (lhs <= end) { - if (memcmp(lhs++, rhs, size) == 0) - return 1; - } - - return 0; -} - -static PyObject * -string_item(PyStringObject *a, register int i) -{ - PyObject *v; - char *pchar; - if (i < 0 || i >= a->ob_size) { - PyErr_SetString(PyExc_IndexError, "string index out of range"); - return NULL; - } - pchar = a->ob_sval + i; - v = (PyObject *)characters[*pchar & UCHAR_MAX]; - if (v == NULL) - v = PyString_FromStringAndSize(pchar, 1); - else { -#ifdef COUNT_ALLOCS - one_strings++; -#endif - Py_INCREF(v); - } - return v; -} - -static PyObject* -string_richcompare(PyStringObject *a, PyStringObject *b, int op) -{ - int c; - int len_a, len_b; - int min_len; - PyObject *result; - - /* Make sure both arguments are strings. */ - if (!(PyString_Check(a) && PyString_Check(b))) { - result = Py_NotImplemented; - goto out; - } - if (a == b) { - switch (op) { - case Py_EQ:case Py_LE:case Py_GE: - result = Py_True; - goto out; - case Py_NE:case Py_LT:case Py_GT: - result = Py_False; - goto out; - } - } - if (op == Py_EQ) { - /* Supporting Py_NE here as well does not save - much time, since Py_NE is rarely used. */ - if (a->ob_size == b->ob_size - && (a->ob_sval[0] == b->ob_sval[0] - && memcmp(a->ob_sval, b->ob_sval, - a->ob_size) == 0)) { - result = Py_True; - } else { - result = Py_False; - } - goto out; - } - len_a = a->ob_size; len_b = b->ob_size; - min_len = (len_a < len_b) ? len_a : len_b; - if (min_len > 0) { - c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval); - if (c==0) - c = memcmp(a->ob_sval, b->ob_sval, min_len); - }else - c = 0; - if (c == 0) - c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0; - switch (op) { - case Py_LT: c = c < 0; break; - case Py_LE: c = c <= 0; break; - case Py_EQ: assert(0); break; /* unreachable */ - case Py_NE: c = c != 0; break; - case Py_GT: c = c > 0; break; - case Py_GE: c = c >= 0; break; - default: - result = Py_NotImplemented; - goto out; - } - result = c ? Py_True : Py_False; - out: - Py_INCREF(result); - return result; -} - -int -_PyString_Eq(PyObject *o1, PyObject *o2) -{ - PyStringObject *a, *b; - a = (PyStringObject*)o1; - b = (PyStringObject*)o2; - return a->ob_size == b->ob_size - && *a->ob_sval == *b->ob_sval - && memcmp(a->ob_sval, b->ob_sval, a->ob_size) == 0; -} - -static long -string_hash(PyStringObject *a) -{ - register int len; - register unsigned char *p; - register long x; - - if (a->ob_shash != -1) - return a->ob_shash; - len = a->ob_size; - p = (unsigned char *) a->ob_sval; - x = *p << 7; - while (--len >= 0) - x = (1000003*x) ^ *p++; - x ^= a->ob_size; - if (x == -1) - x = -2; - a->ob_shash = x; - return x; -} - -static PyObject* -string_subscript(PyStringObject* self, PyObject* item) -{ - if (PyInt_Check(item)) { - long i = PyInt_AS_LONG(item); - if (i < 0) - i += PyString_GET_SIZE(self); - return string_item(self,i); - } - else if (PyLong_Check(item)) { - long i = PyLong_AsLong(item); - if (i == -1 && PyErr_Occurred()) - return NULL; - if (i < 0) - i += PyString_GET_SIZE(self); - return string_item(self,i); - } - else if (PySlice_Check(item)) { - int start, stop, step, slicelength, cur, i; - char* source_buf; - char* result_buf; - PyObject* result; - - if (PySlice_GetIndicesEx((PySliceObject*)item, - PyString_GET_SIZE(self), - &start, &stop, &step, &slicelength) < 0) { - return NULL; - } - - if (slicelength <= 0) { - return PyString_FromStringAndSize("", 0); - } - else { - source_buf = PyString_AsString((PyObject*)self); - result_buf = PyMem_Malloc(slicelength); - - for (cur = start, i = 0; i < slicelength; - cur += step, i++) { - result_buf[i] = source_buf[cur]; - } - - result = PyString_FromStringAndSize(result_buf, - slicelength); - PyMem_Free(result_buf); - return result; - } - } - else { - PyErr_SetString(PyExc_TypeError, - "string indices must be integers"); - return NULL; - } -} - -static int -string_buffer_getreadbuf(PyStringObject *self, int index, const void **ptr) -{ - if ( index != 0 ) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent string segment"); - return -1; - } - *ptr = (void *)self->ob_sval; - return self->ob_size; -} - -static int -string_buffer_getwritebuf(PyStringObject *self, int index, const void **ptr) -{ - PyErr_SetString(PyExc_TypeError, - "Cannot use string as modifiable buffer"); - return -1; -} - -static int -string_buffer_getsegcount(PyStringObject *self, int *lenp) -{ - if ( lenp ) - *lenp = self->ob_size; - return 1; -} - -static int -string_buffer_getcharbuf(PyStringObject *self, int index, const char **ptr) -{ - if ( index != 0 ) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent string segment"); - return -1; - } - *ptr = self->ob_sval; - return self->ob_size; -} - -static PySequenceMethods string_as_sequence = { - (inquiry)string_length, /*sq_length*/ - (binaryfunc)string_concat, /*sq_concat*/ - (intargfunc)string_repeat, /*sq_repeat*/ - (intargfunc)string_item, /*sq_item*/ - (intintargfunc)string_slice, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - (objobjproc)string_contains /*sq_contains*/ -}; - -static PyMappingMethods string_as_mapping = { - (inquiry)string_length, - (binaryfunc)string_subscript, - 0, -}; - -static PyBufferProcs string_as_buffer = { - (getreadbufferproc)string_buffer_getreadbuf, - (getwritebufferproc)string_buffer_getwritebuf, - (getsegcountproc)string_buffer_getsegcount, - (getcharbufferproc)string_buffer_getcharbuf, -}; - - - -#define LEFTSTRIP 0 -#define RIGHTSTRIP 1 -#define BOTHSTRIP 2 - -/* Arrays indexed by above */ -static const char *stripformat[] = {"|O:lstrip", "|O:rstrip", "|O:strip"}; - -#define STRIPNAME(i) (stripformat[i]+3) - - -static PyObject * -split_whitespace(const char *s, int len, int maxsplit) -{ - int i, j, err; - PyObject* item; - PyObject *list = PyList_New(0); - - if (list == NULL) - return NULL; - - for (i = j = 0; i < len; ) { - while (i < len && isspace(Py_CHARMASK(s[i]))) - i++; - j = i; - while (i < len && !isspace(Py_CHARMASK(s[i]))) - i++; - if (j < i) { - if (maxsplit-- <= 0) - break; - item = PyString_FromStringAndSize(s+j, (int)(i-j)); - if (item == NULL) - goto finally; - err = PyList_Append(list, item); - Py_DECREF(item); - if (err < 0) - goto finally; - while (i < len && isspace(Py_CHARMASK(s[i]))) - i++; - j = i; - } - } - if (j < len) { - item = PyString_FromStringAndSize(s+j, (int)(len - j)); - if (item == NULL) - goto finally; - err = PyList_Append(list, item); - Py_DECREF(item); - if (err < 0) - goto finally; - } - return list; - finally: - Py_DECREF(list); - return NULL; -} - - -PyDoc_STRVAR(split__doc__, -"S.split([sep [,maxsplit]]) -> list of strings\n\ -\n\ -Return a list of the words in the string S, using sep as the\n\ -delimiter string. If maxsplit is given, at most maxsplit\n\ -splits are done. If sep is not specified or is None, any\n\ -whitespace string is a separator."); - -static PyObject * -string_split(PyStringObject *self, PyObject *args) -{ - int len = PyString_GET_SIZE(self), n, i, j, err; - int maxsplit = -1; - const char *s = PyString_AS_STRING(self), *sub; - PyObject *list, *item, *subobj = Py_None; - - if (!PyArg_ParseTuple(args, "|Oi:split", &subobj, &maxsplit)) - return NULL; - if (maxsplit < 0) - maxsplit = INT_MAX; - if (subobj == Py_None) - return split_whitespace(s, len, maxsplit); - if (PyString_Check(subobj)) { - sub = PyString_AS_STRING(subobj); - n = PyString_GET_SIZE(subobj); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(subobj)) - return PyUnicode_Split((PyObject *)self, subobj, maxsplit); -#endif - else if (PyObject_AsCharBuffer(subobj, &sub, &n)) - return NULL; - if (n == 0) { - PyErr_SetString(PyExc_ValueError, "empty separator"); - return NULL; - } - - list = PyList_New(0); - if (list == NULL) - return NULL; - - i = j = 0; - while (i+n <= len) { - if (s[i] == sub[0] && memcmp(s+i, sub, n) == 0) { - if (maxsplit-- <= 0) - break; - item = PyString_FromStringAndSize(s+j, (int)(i-j)); - if (item == NULL) - goto fail; - err = PyList_Append(list, item); - Py_DECREF(item); - if (err < 0) - goto fail; - i = j = i + n; - } - else - i++; - } - item = PyString_FromStringAndSize(s+j, (int)(len-j)); - if (item == NULL) - goto fail; - err = PyList_Append(list, item); - Py_DECREF(item); - if (err < 0) - goto fail; - - return list; - - fail: - Py_DECREF(list); - return NULL; -} - - -PyDoc_STRVAR(join__doc__, -"S.join(sequence) -> string\n\ -\n\ -Return a string which is the concatenation of the strings in the\n\ -sequence. The separator between elements is S."); - -static PyObject * -string_join(PyStringObject *self, PyObject *orig) -{ - char *sep = PyString_AS_STRING(self); - const int seplen = PyString_GET_SIZE(self); - PyObject *res = NULL; - char *p; - int seqlen = 0; - size_t sz = 0; - int i; - PyObject *seq, *item; - - seq = PySequence_Fast(orig, ""); - if (seq == NULL) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_Format(PyExc_TypeError, - "sequence expected, %.80s found", - orig->ob_type->tp_name); - return NULL; - } - - seqlen = PySequence_Size(seq); - if (seqlen == 0) { - Py_DECREF(seq); - return PyString_FromString(""); - } - if (seqlen == 1) { - item = PySequence_Fast_GET_ITEM(seq, 0); - if (!PyString_Check(item) && !PyUnicode_Check(item)) { - PyErr_Format(PyExc_TypeError, - "sequence item 0: expected string," - " %.80s found", - item->ob_type->tp_name); - Py_DECREF(seq); - return NULL; - } - Py_INCREF(item); - Py_DECREF(seq); - return item; - } - - /* There are at least two things to join. Do a pre-pass to figure out - * the total amount of space we'll need (sz), see whether any argument - * is absurd, and defer to the Unicode join if appropriate. - */ - for (i = 0; i < seqlen; i++) { - const size_t old_sz = sz; - item = PySequence_Fast_GET_ITEM(seq, i); - if (!PyString_Check(item)){ -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(item)) { - /* Defer to Unicode join. - * CAUTION: There's no gurantee that the - * original sequence can be iterated over - * again, so we must pass seq here. - */ - PyObject *result; - result = PyUnicode_Join((PyObject *)self, seq); - Py_DECREF(seq); - return result; - } -#endif - PyErr_Format(PyExc_TypeError, - "sequence item %i: expected string," - " %.80s found", - i, item->ob_type->tp_name); - Py_DECREF(seq); - return NULL; - } - sz += PyString_GET_SIZE(item); - if (i != 0) - sz += seplen; - if (sz < old_sz || sz > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "join() is too long for a Python string"); - Py_DECREF(seq); - return NULL; - } - } - - /* Allocate result space. */ - res = PyString_FromStringAndSize((char*)NULL, (int)sz); - if (res == NULL) { - Py_DECREF(seq); - return NULL; - } - - /* Catenate everything. */ - p = PyString_AS_STRING(res); - for (i = 0; i < seqlen; ++i) { - size_t n; - item = PySequence_Fast_GET_ITEM(seq, i); - n = PyString_GET_SIZE(item); - memcpy(p, PyString_AS_STRING(item), n); - p += n; - if (i < seqlen - 1) { - memcpy(p, sep, seplen); - p += seplen; - } - } - - Py_DECREF(seq); - return res; -} - -PyObject * -_PyString_Join(PyObject *sep, PyObject *x) -{ - assert(sep != NULL && PyString_Check(sep)); - assert(x != NULL); - return string_join((PyStringObject *)sep, x); -} - -static void -string_adjust_indices(int *start, int *end, int len) -{ - if (*end > len) - *end = len; - else if (*end < 0) - *end += len; - if (*end < 0) - *end = 0; - if (*start < 0) - *start += len; - if (*start < 0) - *start = 0; -} - -static long -string_find_internal(PyStringObject *self, PyObject *args, int dir) -{ - const char *s = PyString_AS_STRING(self), *sub; - int len = PyString_GET_SIZE(self); - int n, i = 0, last = INT_MAX; - PyObject *subobj; - - if (!PyArg_ParseTuple(args, "O|O&O&:find/rfind/index/rindex", - &subobj, _PyEval_SliceIndex, &i, _PyEval_SliceIndex, &last)) - return -2; - if (PyString_Check(subobj)) { - sub = PyString_AS_STRING(subobj); - n = PyString_GET_SIZE(subobj); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(subobj)) - return PyUnicode_Find((PyObject *)self, subobj, i, last, dir); -#endif - else if (PyObject_AsCharBuffer(subobj, &sub, &n)) - return -2; - - string_adjust_indices(&i, &last, len); - - if (dir > 0) { - if (n == 0 && i <= last) - return (long)i; - last -= n; - for (; i <= last; ++i) - if (s[i] == sub[0] && memcmp(&s[i], sub, n) == 0) - return (long)i; - } - else { - int j; - - if (n == 0 && i <= last) - return (long)last; - for (j = last-n; j >= i; --j) - if (s[j] == sub[0] && memcmp(&s[j], sub, n) == 0) - return (long)j; - } - - return -1; -} - - -PyDoc_STRVAR(find__doc__, -"S.find(sub [,start [,end]]) -> int\n\ -\n\ -Return the lowest index in S where substring sub is found,\n\ -such that sub is contained within s[start,end]. Optional\n\ -arguments start and end are interpreted as in slice notation.\n\ -\n\ -Return -1 on failure."); - -static PyObject * -string_find(PyStringObject *self, PyObject *args) -{ - long result = string_find_internal(self, args, +1); - if (result == -2) - return NULL; - return PyInt_FromLong(result); -} - - -PyDoc_STRVAR(index__doc__, -"S.index(sub [,start [,end]]) -> int\n\ -\n\ -Like S.find() but raise ValueError when the substring is not found."); - -static PyObject * -string_index(PyStringObject *self, PyObject *args) -{ - long result = string_find_internal(self, args, +1); - if (result == -2) - return NULL; - if (result == -1) { - PyErr_SetString(PyExc_ValueError, - "substring not found"); - return NULL; - } - return PyInt_FromLong(result); -} - - -PyDoc_STRVAR(rfind__doc__, -"S.rfind(sub [,start [,end]]) -> int\n\ -\n\ -Return the highest index in S where substring sub is found,\n\ -such that sub is contained within s[start,end]. Optional\n\ -arguments start and end are interpreted as in slice notation.\n\ -\n\ -Return -1 on failure."); - -static PyObject * -string_rfind(PyStringObject *self, PyObject *args) -{ - long result = string_find_internal(self, args, -1); - if (result == -2) - return NULL; - return PyInt_FromLong(result); -} - - -PyDoc_STRVAR(rindex__doc__, -"S.rindex(sub [,start [,end]]) -> int\n\ -\n\ -Like S.rfind() but raise ValueError when the substring is not found."); - -static PyObject * -string_rindex(PyStringObject *self, PyObject *args) -{ - long result = string_find_internal(self, args, -1); - if (result == -2) - return NULL; - if (result == -1) { - PyErr_SetString(PyExc_ValueError, - "substring not found"); - return NULL; - } - return PyInt_FromLong(result); -} - - -static PyObject * -do_xstrip(PyStringObject *self, int striptype, PyObject *sepobj) -{ - char *s = PyString_AS_STRING(self); - int len = PyString_GET_SIZE(self); - char *sep = PyString_AS_STRING(sepobj); - int seplen = PyString_GET_SIZE(sepobj); - int i, j; - - i = 0; - if (striptype != RIGHTSTRIP) { - while (i < len && memchr(sep, Py_CHARMASK(s[i]), seplen)) { - i++; - } - } - - j = len; - if (striptype != LEFTSTRIP) { - do { - j--; - } while (j >= i && memchr(sep, Py_CHARMASK(s[j]), seplen)); - j++; - } - - if (i == 0 && j == len && PyString_CheckExact(self)) { - Py_INCREF(self); - return (PyObject*)self; - } - else - return PyString_FromStringAndSize(s+i, j-i); -} - - -static PyObject * -do_strip(PyStringObject *self, int striptype) -{ - char *s = PyString_AS_STRING(self); - int len = PyString_GET_SIZE(self), i, j; - - i = 0; - if (striptype != RIGHTSTRIP) { - while (i < len && isspace(Py_CHARMASK(s[i]))) { - i++; - } - } - - j = len; - if (striptype != LEFTSTRIP) { - do { - j--; - } while (j >= i && isspace(Py_CHARMASK(s[j]))); - j++; - } - - if (i == 0 && j == len && PyString_CheckExact(self)) { - Py_INCREF(self); - return (PyObject*)self; - } - else - return PyString_FromStringAndSize(s+i, j-i); -} - - -static PyObject * -do_argstrip(PyStringObject *self, int striptype, PyObject *args) -{ - PyObject *sep = NULL; - - if (!PyArg_ParseTuple(args, (char *)stripformat[striptype], &sep)) - return NULL; - - if (sep != NULL && sep != Py_None) { - if (PyString_Check(sep)) - return do_xstrip(self, striptype, sep); -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(sep)) { - PyObject *uniself = PyUnicode_FromObject((PyObject *)self); - PyObject *res; - if (uniself==NULL) - return NULL; - res = _PyUnicode_XStrip((PyUnicodeObject *)uniself, - striptype, sep); - Py_DECREF(uniself); - return res; - } -#endif - else { - PyErr_Format(PyExc_TypeError, -#ifdef Py_USING_UNICODE - "%s arg must be None, str or unicode", -#else - "%s arg must be None or str", -#endif - STRIPNAME(striptype)); - return NULL; - } - return do_xstrip(self, striptype, sep); - } - - return do_strip(self, striptype); -} - - -PyDoc_STRVAR(strip__doc__, -"S.strip([chars]) -> string or unicode\n\ -\n\ -Return a copy of the string S with leading and trailing\n\ -whitespace removed.\n\ -If chars is given and not None, remove characters in chars instead.\n\ -If chars is unicode, S will be converted to unicode before stripping"); - -static PyObject * -string_strip(PyStringObject *self, PyObject *args) -{ - if (PyTuple_GET_SIZE(args) == 0) - return do_strip(self, BOTHSTRIP); /* Common case */ - else - return do_argstrip(self, BOTHSTRIP, args); -} - - -PyDoc_STRVAR(lstrip__doc__, -"S.lstrip([chars]) -> string or unicode\n\ -\n\ -Return a copy of the string S with leading whitespace removed.\n\ -If chars is given and not None, remove characters in chars instead.\n\ -If chars is unicode, S will be converted to unicode before stripping"); - -static PyObject * -string_lstrip(PyStringObject *self, PyObject *args) -{ - if (PyTuple_GET_SIZE(args) == 0) - return do_strip(self, LEFTSTRIP); /* Common case */ - else - return do_argstrip(self, LEFTSTRIP, args); -} - - -PyDoc_STRVAR(rstrip__doc__, -"S.rstrip([chars]) -> string or unicode\n\ -\n\ -Return a copy of the string S with trailing whitespace removed.\n\ -If chars is given and not None, remove characters in chars instead.\n\ -If chars is unicode, S will be converted to unicode before stripping"); - -static PyObject * -string_rstrip(PyStringObject *self, PyObject *args) -{ - if (PyTuple_GET_SIZE(args) == 0) - return do_strip(self, RIGHTSTRIP); /* Common case */ - else - return do_argstrip(self, RIGHTSTRIP, args); -} - - -PyDoc_STRVAR(lower__doc__, -"S.lower() -> string\n\ -\n\ -Return a copy of the string S converted to lowercase."); - -static PyObject * -string_lower(PyStringObject *self) -{ - char *s = PyString_AS_STRING(self), *s_new; - int i, n = PyString_GET_SIZE(self); - PyObject *new; - - new = PyString_FromStringAndSize(NULL, n); - if (new == NULL) - return NULL; - s_new = PyString_AsString(new); - for (i = 0; i < n; i++) { - int c = Py_CHARMASK(*s++); - if (isupper(c)) { - *s_new = tolower(c); - } else - *s_new = c; - s_new++; - } - return new; -} - - -PyDoc_STRVAR(upper__doc__, -"S.upper() -> string\n\ -\n\ -Return a copy of the string S converted to uppercase."); - -static PyObject * -string_upper(PyStringObject *self) -{ - char *s = PyString_AS_STRING(self), *s_new; - int i, n = PyString_GET_SIZE(self); - PyObject *new; - - new = PyString_FromStringAndSize(NULL, n); - if (new == NULL) - return NULL; - s_new = PyString_AsString(new); - for (i = 0; i < n; i++) { - int c = Py_CHARMASK(*s++); - if (islower(c)) { - *s_new = toupper(c); - } else - *s_new = c; - s_new++; - } - return new; -} - - -PyDoc_STRVAR(title__doc__, -"S.title() -> string\n\ -\n\ -Return a titlecased version of S, i.e. words start with uppercase\n\ -characters, all remaining cased characters have lowercase."); - -static PyObject* -string_title(PyStringObject *self) -{ - char *s = PyString_AS_STRING(self), *s_new; - int i, n = PyString_GET_SIZE(self); - int previous_is_cased = 0; - PyObject *new; - - new = PyString_FromStringAndSize(NULL, n); - if (new == NULL) - return NULL; - s_new = PyString_AsString(new); - for (i = 0; i < n; i++) { - int c = Py_CHARMASK(*s++); - if (islower(c)) { - if (!previous_is_cased) - c = toupper(c); - previous_is_cased = 1; - } else if (isupper(c)) { - if (previous_is_cased) - c = tolower(c); - previous_is_cased = 1; - } else - previous_is_cased = 0; - *s_new++ = c; - } - return new; -} - -PyDoc_STRVAR(capitalize__doc__, -"S.capitalize() -> string\n\ -\n\ -Return a copy of the string S with only its first character\n\ -capitalized."); - -static PyObject * -string_capitalize(PyStringObject *self) -{ - char *s = PyString_AS_STRING(self), *s_new; - int i, n = PyString_GET_SIZE(self); - PyObject *new; - - new = PyString_FromStringAndSize(NULL, n); - if (new == NULL) - return NULL; - s_new = PyString_AsString(new); - if (0 < n) { - int c = Py_CHARMASK(*s++); - if (islower(c)) - *s_new = toupper(c); - else - *s_new = c; - s_new++; - } - for (i = 1; i < n; i++) { - int c = Py_CHARMASK(*s++); - if (isupper(c)) - *s_new = tolower(c); - else - *s_new = c; - s_new++; - } - return new; -} - - -PyDoc_STRVAR(count__doc__, -"S.count(sub[, start[, end]]) -> int\n\ -\n\ -Return the number of occurrences of substring sub in string\n\ -S[start:end]. Optional arguments start and end are\n\ -interpreted as in slice notation."); - -static PyObject * -string_count(PyStringObject *self, PyObject *args) -{ - const char *s = PyString_AS_STRING(self), *sub; - int len = PyString_GET_SIZE(self), n; - int i = 0, last = INT_MAX; - int m, r; - PyObject *subobj; - - if (!PyArg_ParseTuple(args, "O|O&O&:count", &subobj, - _PyEval_SliceIndex, &i, _PyEval_SliceIndex, &last)) - return NULL; - - if (PyString_Check(subobj)) { - sub = PyString_AS_STRING(subobj); - n = PyString_GET_SIZE(subobj); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(subobj)) { - int count; - count = PyUnicode_Count((PyObject *)self, subobj, i, last); - if (count == -1) - return NULL; - else - return PyInt_FromLong((long) count); - } -#endif - else if (PyObject_AsCharBuffer(subobj, &sub, &n)) - return NULL; - - string_adjust_indices(&i, &last, len); - - m = last + 1 - n; - if (n == 0) - return PyInt_FromLong((long) (m-i)); - - r = 0; - while (i < m) { - if (!memcmp(s+i, sub, n)) { - r++; - i += n; - } else { - i++; - } - } - return PyInt_FromLong((long) r); -} - - -PyDoc_STRVAR(swapcase__doc__, -"S.swapcase() -> string\n\ -\n\ -Return a copy of the string S with uppercase characters\n\ -converted to lowercase and vice versa."); - -static PyObject * -string_swapcase(PyStringObject *self) -{ - char *s = PyString_AS_STRING(self), *s_new; - int i, n = PyString_GET_SIZE(self); - PyObject *new; - - new = PyString_FromStringAndSize(NULL, n); - if (new == NULL) - return NULL; - s_new = PyString_AsString(new); - for (i = 0; i < n; i++) { - int c = Py_CHARMASK(*s++); - if (islower(c)) { - *s_new = toupper(c); - } - else if (isupper(c)) { - *s_new = tolower(c); - } - else - *s_new = c; - s_new++; - } - return new; -} - - -PyDoc_STRVAR(translate__doc__, -"S.translate(table [,deletechars]) -> string\n\ -\n\ -Return a copy of the string S, where all characters occurring\n\ -in the optional argument deletechars are removed, and the\n\ -remaining characters have been mapped through the given\n\ -translation table, which must be a string of length 256."); - -static PyObject * -string_translate(PyStringObject *self, PyObject *args) -{ - register char *input, *output; - register const char *table; - register int i, c, changed = 0; - PyObject *input_obj = (PyObject*)self; - const char *table1, *output_start, *del_table=NULL; - int inlen, tablen, dellen = 0; - PyObject *result; - int trans_table[256]; - PyObject *tableobj, *delobj = NULL; - - if (!PyArg_UnpackTuple(args, "translate", 1, 2, - &tableobj, &delobj)) - return NULL; - - if (PyString_Check(tableobj)) { - table1 = PyString_AS_STRING(tableobj); - tablen = PyString_GET_SIZE(tableobj); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(tableobj)) { - /* Unicode .translate() does not support the deletechars - parameter; instead a mapping to None will cause characters - to be deleted. */ - if (delobj != NULL) { - PyErr_SetString(PyExc_TypeError, - "deletions are implemented differently for unicode"); - return NULL; - } - return PyUnicode_Translate((PyObject *)self, tableobj, NULL); - } -#endif - else if (PyObject_AsCharBuffer(tableobj, &table1, &tablen)) - return NULL; - - if (tablen != 256) { - PyErr_SetString(PyExc_ValueError, - "translation table must be 256 characters long"); - return NULL; - } - - if (delobj != NULL) { - if (PyString_Check(delobj)) { - del_table = PyString_AS_STRING(delobj); - dellen = PyString_GET_SIZE(delobj); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(delobj)) { - PyErr_SetString(PyExc_TypeError, - "deletions are implemented differently for unicode"); - return NULL; - } -#endif - else if (PyObject_AsCharBuffer(delobj, &del_table, &dellen)) - return NULL; - } - else { - del_table = NULL; - dellen = 0; - } - - table = table1; - inlen = PyString_Size(input_obj); - result = PyString_FromStringAndSize((char *)NULL, inlen); - if (result == NULL) - return NULL; - output_start = output = PyString_AsString(result); - input = PyString_AsString(input_obj); - - if (dellen == 0) { - /* If no deletions are required, use faster code */ - for (i = inlen; --i >= 0; ) { - c = Py_CHARMASK(*input++); - if (Py_CHARMASK((*output++ = table[c])) != c) - changed = 1; - } - if (changed || !PyString_CheckExact(input_obj)) - return result; - Py_DECREF(result); - Py_INCREF(input_obj); - return input_obj; - } - - for (i = 0; i < 256; i++) - trans_table[i] = Py_CHARMASK(table[i]); - - for (i = 0; i < dellen; i++) - trans_table[(int) Py_CHARMASK(del_table[i])] = -1; - - for (i = inlen; --i >= 0; ) { - c = Py_CHARMASK(*input++); - if (trans_table[c] != -1) - if (Py_CHARMASK(*output++ = (char)trans_table[c]) == c) - continue; - changed = 1; - } - if (!changed && PyString_CheckExact(input_obj)) { - Py_DECREF(result); - Py_INCREF(input_obj); - return input_obj; - } - /* Fix the size of the resulting string */ - if (inlen > 0) - _PyString_Resize(&result, output - output_start); - return result; -} - - -/* What follows is used for implementing replace(). Perry Stoll. */ - -/* - mymemfind - - strstr replacement for arbitrary blocks of memory. - - Locates the first occurrence in the memory pointed to by MEM of the - contents of memory pointed to by PAT. Returns the index into MEM if - found, or -1 if not found. If len of PAT is greater than length of - MEM, the function returns -1. -*/ -static int -mymemfind(const char *mem, int len, const char *pat, int pat_len) -{ - register int ii; - - /* pattern can not occur in the last pat_len-1 chars */ - len -= pat_len; - - for (ii = 0; ii <= len; ii++) { - if (mem[ii] == pat[0] && memcmp(&mem[ii], pat, pat_len) == 0) { - return ii; - } - } - return -1; -} - -/* - mymemcnt - - Return the number of distinct times PAT is found in MEM. - meaning mem=1111 and pat==11 returns 2. - mem=11111 and pat==11 also return 2. - */ -static int -mymemcnt(const char *mem, int len, const char *pat, int pat_len) -{ - register int offset = 0; - int nfound = 0; - - while (len >= 0) { - offset = mymemfind(mem, len, pat, pat_len); - if (offset == -1) - break; - mem += offset + pat_len; - len -= offset + pat_len; - nfound++; - } - return nfound; -} - -/* - mymemreplace - - Return a string in which all occurrences of PAT in memory STR are - replaced with SUB. - - If length of PAT is less than length of STR or there are no occurrences - of PAT in STR, then the original string is returned. Otherwise, a new - string is allocated here and returned. - - on return, out_len is: - the length of output string, or - -1 if the input string is returned, or - unchanged if an error occurs (no memory). - - return value is: - the new string allocated locally, or - NULL if an error occurred. -*/ -static char * -mymemreplace(const char *str, int len, /* input string */ - const char *pat, int pat_len, /* pattern string to find */ - const char *sub, int sub_len, /* substitution string */ - int count, /* number of replacements */ - int *out_len) -{ - char *out_s; - char *new_s; - int nfound, offset, new_len; - - if (len == 0 || (pat_len == 0 && sub_len == 0) || pat_len > len) - goto return_same; - - /* find length of output string */ - nfound = (pat_len > 0) ? mymemcnt(str, len, pat, pat_len) : len + 1; - if (count < 0) - count = INT_MAX; - else if (nfound > count) - nfound = count; - if (nfound == 0) - goto return_same; - - new_len = len + nfound*(sub_len - pat_len); - if (new_len == 0) { - /* Have to allocate something for the caller to free(). */ - out_s = (char *)PyMem_MALLOC(1); - if (out_s == NULL) - return NULL; - out_s[0] = '\0'; - } - else { - assert(new_len > 0); - new_s = (char *)PyMem_MALLOC(new_len); - if (new_s == NULL) - return NULL; - out_s = new_s; - - if (pat_len > 0) { - for (; nfound > 0; --nfound) { - /* find index of next instance of pattern */ - offset = mymemfind(str, len, pat, pat_len); - if (offset == -1) - break; - - /* copy non matching part of input string */ - memcpy(new_s, str, offset); - str += offset + pat_len; - len -= offset + pat_len; - - /* copy substitute into the output string */ - new_s += offset; - memcpy(new_s, sub, sub_len); - new_s += sub_len; - } - /* copy any remaining values into output string */ - if (len > 0) - memcpy(new_s, str, len); - } - else { - for (;;++str, --len) { - memcpy(new_s, sub, sub_len); - new_s += sub_len; - if (--nfound <= 0) { - memcpy(new_s, str, len); - break; - } - *new_s++ = *str; - } - } - } - *out_len = new_len; - return out_s; - - return_same: - *out_len = -1; - return (char *)str; /* cast away const */ -} - - -PyDoc_STRVAR(replace__doc__, -"S.replace (old, new[, count]) -> string\n\ -\n\ -Return a copy of string S with all occurrences of substring\n\ -old replaced by new. If the optional argument count is\n\ -given, only the first count occurrences are replaced."); - -static PyObject * -string_replace(PyStringObject *self, PyObject *args) -{ - const char *str = PyString_AS_STRING(self), *sub, *repl; - char *new_s; - const int len = PyString_GET_SIZE(self); - int sub_len, repl_len, out_len; - int count = -1; - PyObject *new; - PyObject *subobj, *replobj; - - if (!PyArg_ParseTuple(args, "OO|i:replace", - &subobj, &replobj, &count)) - return NULL; - - if (PyString_Check(subobj)) { - sub = PyString_AS_STRING(subobj); - sub_len = PyString_GET_SIZE(subobj); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(subobj)) - return PyUnicode_Replace((PyObject *)self, - subobj, replobj, count); -#endif - else if (PyObject_AsCharBuffer(subobj, &sub, &sub_len)) - return NULL; - - if (PyString_Check(replobj)) { - repl = PyString_AS_STRING(replobj); - repl_len = PyString_GET_SIZE(replobj); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(replobj)) - return PyUnicode_Replace((PyObject *)self, - subobj, replobj, count); -#endif - else if (PyObject_AsCharBuffer(replobj, &repl, &repl_len)) - return NULL; - - new_s = mymemreplace(str,len,sub,sub_len,repl,repl_len,count,&out_len); - if (new_s == NULL) { - PyErr_NoMemory(); - return NULL; - } - if (out_len == -1) { - if (PyString_CheckExact(self)) { - /* we're returning another reference to self */ - new = (PyObject*)self; - Py_INCREF(new); - } - else { - new = PyString_FromStringAndSize(str, len); - if (new == NULL) - return NULL; - } - } - else { - new = PyString_FromStringAndSize(new_s, out_len); - PyMem_FREE(new_s); - } - return new; -} - - -PyDoc_STRVAR(startswith__doc__, -"S.startswith(prefix[, start[, end]]) -> bool\n\ -\n\ -Return True if S starts with the specified prefix, False otherwise.\n\ -With optional start, test S beginning at that position.\n\ -With optional end, stop comparing S at that position."); - -static PyObject * -string_startswith(PyStringObject *self, PyObject *args) -{ - const char* str = PyString_AS_STRING(self); - int len = PyString_GET_SIZE(self); - const char* prefix; - int plen; - int start = 0; - int end = INT_MAX; - PyObject *subobj; - - if (!PyArg_ParseTuple(args, "O|O&O&:startswith", &subobj, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) - return NULL; - if (PyString_Check(subobj)) { - prefix = PyString_AS_STRING(subobj); - plen = PyString_GET_SIZE(subobj); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(subobj)) { - int rc; - rc = PyUnicode_Tailmatch((PyObject *)self, - subobj, start, end, -1); - if (rc == -1) - return NULL; - else - return PyBool_FromLong((long) rc); - } -#endif - else if (PyObject_AsCharBuffer(subobj, &prefix, &plen)) - return NULL; - - string_adjust_indices(&start, &end, len); - - if (start+plen > len) - return PyBool_FromLong(0); - - if (end-start >= plen) - return PyBool_FromLong(!memcmp(str+start, prefix, plen)); - else - return PyBool_FromLong(0); -} - - -PyDoc_STRVAR(endswith__doc__, -"S.endswith(suffix[, start[, end]]) -> bool\n\ -\n\ -Return True if S ends with the specified suffix, False otherwise.\n\ -With optional start, test S beginning at that position.\n\ -With optional end, stop comparing S at that position."); - -static PyObject * -string_endswith(PyStringObject *self, PyObject *args) -{ - const char* str = PyString_AS_STRING(self); - int len = PyString_GET_SIZE(self); - const char* suffix; - int slen; - int start = 0; - int end = INT_MAX; - PyObject *subobj; - - if (!PyArg_ParseTuple(args, "O|O&O&:endswith", &subobj, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) - return NULL; - if (PyString_Check(subobj)) { - suffix = PyString_AS_STRING(subobj); - slen = PyString_GET_SIZE(subobj); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(subobj)) { - int rc; - rc = PyUnicode_Tailmatch((PyObject *)self, - subobj, start, end, +1); - if (rc == -1) - return NULL; - else - return PyBool_FromLong((long) rc); - } -#endif - else if (PyObject_AsCharBuffer(subobj, &suffix, &slen)) - return NULL; - - string_adjust_indices(&start, &end, len); - - if (end-start < slen || start > len) - return PyBool_FromLong(0); - - if (end-slen > start) - start = end - slen; - if (end-start >= slen) - return PyBool_FromLong(!memcmp(str+start, suffix, slen)); - else - return PyBool_FromLong(0); -} - - -PyDoc_STRVAR(encode__doc__, -"S.encode([encoding[,errors]]) -> object\n\ -\n\ -Encodes S using the codec registered for encoding. encoding defaults\n\ -to the default encoding. errors may be given to set a different error\n\ -handling scheme. Default is 'strict' meaning that encoding errors raise\n\ -a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and\n\ -'xmlcharrefreplace' as well as any other name registered with\n\ -codecs.register_error that is able to handle UnicodeEncodeErrors."); - -static PyObject * -string_encode(PyStringObject *self, PyObject *args) -{ - char *encoding = NULL; - char *errors = NULL; - if (!PyArg_ParseTuple(args, "|ss:encode", &encoding, &errors)) - return NULL; - return PyString_AsEncodedObject((PyObject *)self, encoding, errors); -} - - -PyDoc_STRVAR(decode__doc__, -"S.decode([encoding[,errors]]) -> object\n\ -\n\ -Decodes S using the codec registered for encoding. encoding defaults\n\ -to the default encoding. errors may be given to set a different error\n\ -handling scheme. Default is 'strict' meaning that encoding errors raise\n\ -a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'\n\ -as well as any other name registerd with codecs.register_error that is\n\ -able to handle UnicodeDecodeErrors."); - -static PyObject * -string_decode(PyStringObject *self, PyObject *args) -{ - char *encoding = NULL; - char *errors = NULL; - if (!PyArg_ParseTuple(args, "|ss:decode", &encoding, &errors)) - return NULL; - return PyString_AsDecodedObject((PyObject *)self, encoding, errors); -} - - -PyDoc_STRVAR(expandtabs__doc__, -"S.expandtabs([tabsize]) -> string\n\ -\n\ -Return a copy of S where all tab characters are expanded using spaces.\n\ -If tabsize is not given, a tab size of 8 characters is assumed."); - -static PyObject* -string_expandtabs(PyStringObject *self, PyObject *args) -{ - const char *e, *p; - char *q; - int i, j; - PyObject *u; - int tabsize = 8; - - if (!PyArg_ParseTuple(args, "|i:expandtabs", &tabsize)) - return NULL; - - /* First pass: determine size of output string */ - i = j = 0; - e = PyString_AS_STRING(self) + PyString_GET_SIZE(self); - for (p = PyString_AS_STRING(self); p < e; p++) - if (*p == '\t') { - if (tabsize > 0) - j += tabsize - (j % tabsize); - } - else { - j++; - if (*p == '\n' || *p == '\r') { - i += j; - j = 0; - } - } - - /* Second pass: create output string and fill it */ - u = PyString_FromStringAndSize(NULL, i + j); - if (!u) - return NULL; - - j = 0; - q = PyString_AS_STRING(u); - - for (p = PyString_AS_STRING(self); p < e; p++) - if (*p == '\t') { - if (tabsize > 0) { - i = tabsize - (j % tabsize); - j += i; - while (i--) - *q++ = ' '; - } - } - else { - j++; - *q++ = *p; - if (*p == '\n' || *p == '\r') - j = 0; - } - - return u; -} - -static PyObject * -pad(PyStringObject *self, int left, int right, char fill) -{ - PyObject *u; - - if (left < 0) - left = 0; - if (right < 0) - right = 0; - - if (left == 0 && right == 0 && PyString_CheckExact(self)) { - Py_INCREF(self); - return (PyObject *)self; - } - - u = PyString_FromStringAndSize(NULL, - left + PyString_GET_SIZE(self) + right); - if (u) { - if (left) - memset(PyString_AS_STRING(u), fill, left); - memcpy(PyString_AS_STRING(u) + left, - PyString_AS_STRING(self), - PyString_GET_SIZE(self)); - if (right) - memset(PyString_AS_STRING(u) + left + PyString_GET_SIZE(self), - fill, right); - } - - return u; -} - -PyDoc_STRVAR(ljust__doc__, -"S.ljust(width) -> string\n" -"\n" -"Return S left justified in a string of length width. Padding is\n" -"done using spaces."); - -static PyObject * -string_ljust(PyStringObject *self, PyObject *args) -{ - int width; - if (!PyArg_ParseTuple(args, "i:ljust", &width)) - return NULL; - - if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) { - Py_INCREF(self); - return (PyObject*) self; - } - - return pad(self, 0, width - PyString_GET_SIZE(self), ' '); -} - - -PyDoc_STRVAR(rjust__doc__, -"S.rjust(width) -> string\n" -"\n" -"Return S right justified in a string of length width. Padding is\n" -"done using spaces."); - -static PyObject * -string_rjust(PyStringObject *self, PyObject *args) -{ - int width; - if (!PyArg_ParseTuple(args, "i:rjust", &width)) - return NULL; - - if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) { - Py_INCREF(self); - return (PyObject*) self; - } - - return pad(self, width - PyString_GET_SIZE(self), 0, ' '); -} - - -PyDoc_STRVAR(center__doc__, -"S.center(width) -> string\n" -"\n" -"Return S centered in a string of length width. Padding is done\n" -"using spaces."); - -static PyObject * -string_center(PyStringObject *self, PyObject *args) -{ - int marg, left; - int width; - - if (!PyArg_ParseTuple(args, "i:center", &width)) - return NULL; - - if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) { - Py_INCREF(self); - return (PyObject*) self; - } - - marg = width - PyString_GET_SIZE(self); - left = marg / 2 + (marg & width & 1); - - return pad(self, left, marg - left, ' '); -} - -PyDoc_STRVAR(zfill__doc__, -"S.zfill(width) -> string\n" -"\n" -"Pad a numeric string S with zeros on the left, to fill a field\n" -"of the specified width. The string S is never truncated."); - -static PyObject * -string_zfill(PyStringObject *self, PyObject *args) -{ - int fill; - PyObject *s; - char *p; - - int width; - if (!PyArg_ParseTuple(args, "i:zfill", &width)) - return NULL; - - if (PyString_GET_SIZE(self) >= width) { - if (PyString_CheckExact(self)) { - Py_INCREF(self); - return (PyObject*) self; - } - else - return PyString_FromStringAndSize( - PyString_AS_STRING(self), - PyString_GET_SIZE(self) - ); - } - - fill = width - PyString_GET_SIZE(self); - - s = pad(self, fill, 0, '0'); - - if (s == NULL) - return NULL; - - p = PyString_AS_STRING(s); - if (p[fill] == '+' || p[fill] == '-') { - /* move sign to beginning of string */ - p[0] = p[fill]; - p[fill] = '0'; - } - - return (PyObject*) s; -} - -PyDoc_STRVAR(isspace__doc__, -"S.isspace() -> bool\n\ -\n\ -Return True if all characters in S are whitespace\n\ -and there is at least one character in S, False otherwise."); - -static PyObject* -string_isspace(PyStringObject *self) -{ - register const unsigned char *p - = (unsigned char *) PyString_AS_STRING(self); - register const unsigned char *e; - - /* Shortcut for single character strings */ - if (PyString_GET_SIZE(self) == 1 && - isspace(*p)) - return PyBool_FromLong(1); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyString_GET_SIZE(self); - for (; p < e; p++) { - if (!isspace(*p)) - return PyBool_FromLong(0); - } - return PyBool_FromLong(1); -} - - -PyDoc_STRVAR(isalpha__doc__, -"S.isalpha() -> bool\n\ -\n\ -Return True if all characters in S are alphabetic\n\ -and there is at least one character in S, False otherwise."); - -static PyObject* -string_isalpha(PyStringObject *self) -{ - register const unsigned char *p - = (unsigned char *) PyString_AS_STRING(self); - register const unsigned char *e; - - /* Shortcut for single character strings */ - if (PyString_GET_SIZE(self) == 1 && - isalpha(*p)) - return PyBool_FromLong(1); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyString_GET_SIZE(self); - for (; p < e; p++) { - if (!isalpha(*p)) - return PyBool_FromLong(0); - } - return PyBool_FromLong(1); -} - - -PyDoc_STRVAR(isalnum__doc__, -"S.isalnum() -> bool\n\ -\n\ -Return True if all characters in S are alphanumeric\n\ -and there is at least one character in S, False otherwise."); - -static PyObject* -string_isalnum(PyStringObject *self) -{ - register const unsigned char *p - = (unsigned char *) PyString_AS_STRING(self); - register const unsigned char *e; - - /* Shortcut for single character strings */ - if (PyString_GET_SIZE(self) == 1 && - isalnum(*p)) - return PyBool_FromLong(1); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyString_GET_SIZE(self); - for (; p < e; p++) { - if (!isalnum(*p)) - return PyBool_FromLong(0); - } - return PyBool_FromLong(1); -} - - -PyDoc_STRVAR(isdigit__doc__, -"S.isdigit() -> bool\n\ -\n\ -Return True if all characters in S are digits\n\ -and there is at least one character in S, False otherwise."); - -static PyObject* -string_isdigit(PyStringObject *self) -{ - register const unsigned char *p - = (unsigned char *) PyString_AS_STRING(self); - register const unsigned char *e; - - /* Shortcut for single character strings */ - if (PyString_GET_SIZE(self) == 1 && - isdigit(*p)) - return PyBool_FromLong(1); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyString_GET_SIZE(self); - for (; p < e; p++) { - if (!isdigit(*p)) - return PyBool_FromLong(0); - } - return PyBool_FromLong(1); -} - - -PyDoc_STRVAR(islower__doc__, -"S.islower() -> bool\n\ -\n\ -Return True if all cased characters in S are lowercase and there is\n\ -at least one cased character in S, False otherwise."); - -static PyObject* -string_islower(PyStringObject *self) -{ - register const unsigned char *p - = (unsigned char *) PyString_AS_STRING(self); - register const unsigned char *e; - int cased; - - /* Shortcut for single character strings */ - if (PyString_GET_SIZE(self) == 1) - return PyBool_FromLong(islower(*p) != 0); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyString_GET_SIZE(self); - cased = 0; - for (; p < e; p++) { - if (isupper(*p)) - return PyBool_FromLong(0); - else if (!cased && islower(*p)) - cased = 1; - } - return PyBool_FromLong(cased); -} - - -PyDoc_STRVAR(isupper__doc__, -"S.isupper() -> bool\n\ -\n\ -Return True if all cased characters in S are uppercase and there is\n\ -at least one cased character in S, False otherwise."); - -static PyObject* -string_isupper(PyStringObject *self) -{ - register const unsigned char *p - = (unsigned char *) PyString_AS_STRING(self); - register const unsigned char *e; - int cased; - - /* Shortcut for single character strings */ - if (PyString_GET_SIZE(self) == 1) - return PyBool_FromLong(isupper(*p) != 0); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyString_GET_SIZE(self); - cased = 0; - for (; p < e; p++) { - if (islower(*p)) - return PyBool_FromLong(0); - else if (!cased && isupper(*p)) - cased = 1; - } - return PyBool_FromLong(cased); -} - - -PyDoc_STRVAR(istitle__doc__, -"S.istitle() -> bool\n\ -\n\ -Return True if S is a titlecased string and there is at least one\n\ -character in S, i.e. uppercase characters may only follow uncased\n\ -characters and lowercase characters only cased ones. Return False\n\ -otherwise."); - -static PyObject* -string_istitle(PyStringObject *self, PyObject *uncased) -{ - register const unsigned char *p - = (unsigned char *) PyString_AS_STRING(self); - register const unsigned char *e; - int cased, previous_is_cased; - - /* Shortcut for single character strings */ - if (PyString_GET_SIZE(self) == 1) - return PyBool_FromLong(isupper(*p) != 0); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyString_GET_SIZE(self); - cased = 0; - previous_is_cased = 0; - for (; p < e; p++) { - register const unsigned char ch = *p; - - if (isupper(ch)) { - if (previous_is_cased) - return PyBool_FromLong(0); - previous_is_cased = 1; - cased = 1; - } - else if (islower(ch)) { - if (!previous_is_cased) - return PyBool_FromLong(0); - previous_is_cased = 1; - cased = 1; - } - else - previous_is_cased = 0; - } - return PyBool_FromLong(cased); -} - - -PyDoc_STRVAR(splitlines__doc__, -"S.splitlines([keepends]) -> list of strings\n\ -\n\ -Return a list of the lines in S, breaking at line boundaries.\n\ -Line breaks are not included in the resulting list unless keepends\n\ -is given and true."); - -#define SPLIT_APPEND(data, left, right) \ - str = PyString_FromStringAndSize(data + left, right - left); \ - if (!str) \ - goto onError; \ - if (PyList_Append(list, str)) { \ - Py_DECREF(str); \ - goto onError; \ - } \ - else \ - Py_DECREF(str); - -static PyObject* -string_splitlines(PyStringObject *self, PyObject *args) -{ - register int i; - register int j; - int len; - int keepends = 0; - PyObject *list; - PyObject *str; - char *data; - - if (!PyArg_ParseTuple(args, "|i:splitlines", &keepends)) - return NULL; - - data = PyString_AS_STRING(self); - len = PyString_GET_SIZE(self); - - list = PyList_New(0); - if (!list) - goto onError; - - for (i = j = 0; i < len; ) { - int eol; - - /* Find a line and append it */ - while (i < len && data[i] != '\n' && data[i] != '\r') - i++; - - /* Skip the line break reading CRLF as one line break */ - eol = i; - if (i < len) { - if (data[i] == '\r' && i + 1 < len && - data[i+1] == '\n') - i += 2; - else - i++; - if (keepends) - eol = i; - } - SPLIT_APPEND(data, j, eol); - j = i; - } - if (j < len) { - SPLIT_APPEND(data, j, len); - } - - return list; - - onError: - Py_DECREF(list); - return NULL; -} - -#undef SPLIT_APPEND - -static PyObject * -string_getnewargs(PyStringObject *v) -{ - return Py_BuildValue("(s#)", v->ob_sval, v->ob_size); -} - - -static PyMethodDef -string_methods[] = { - /* Counterparts of the obsolete stropmodule functions; except - string.maketrans(). */ - {"join", (PyCFunction)string_join, METH_O, join__doc__}, - {"split", (PyCFunction)string_split, METH_VARARGS, split__doc__}, - {"lower", (PyCFunction)string_lower, METH_NOARGS, lower__doc__}, - {"upper", (PyCFunction)string_upper, METH_NOARGS, upper__doc__}, - {"islower", (PyCFunction)string_islower, METH_NOARGS, islower__doc__}, - {"isupper", (PyCFunction)string_isupper, METH_NOARGS, isupper__doc__}, - {"isspace", (PyCFunction)string_isspace, METH_NOARGS, isspace__doc__}, - {"isdigit", (PyCFunction)string_isdigit, METH_NOARGS, isdigit__doc__}, - {"istitle", (PyCFunction)string_istitle, METH_NOARGS, istitle__doc__}, - {"isalpha", (PyCFunction)string_isalpha, METH_NOARGS, isalpha__doc__}, - {"isalnum", (PyCFunction)string_isalnum, METH_NOARGS, isalnum__doc__}, - {"capitalize", (PyCFunction)string_capitalize, METH_NOARGS, - capitalize__doc__}, - {"count", (PyCFunction)string_count, METH_VARARGS, count__doc__}, - {"endswith", (PyCFunction)string_endswith, METH_VARARGS, - endswith__doc__}, - {"find", (PyCFunction)string_find, METH_VARARGS, find__doc__}, - {"index", (PyCFunction)string_index, METH_VARARGS, index__doc__}, - {"lstrip", (PyCFunction)string_lstrip, METH_VARARGS, lstrip__doc__}, - {"replace", (PyCFunction)string_replace, METH_VARARGS, replace__doc__}, - {"rfind", (PyCFunction)string_rfind, METH_VARARGS, rfind__doc__}, - {"rindex", (PyCFunction)string_rindex, METH_VARARGS, rindex__doc__}, - {"rstrip", (PyCFunction)string_rstrip, METH_VARARGS, rstrip__doc__}, - {"startswith", (PyCFunction)string_startswith, METH_VARARGS, - startswith__doc__}, - {"strip", (PyCFunction)string_strip, METH_VARARGS, strip__doc__}, - {"swapcase", (PyCFunction)string_swapcase, METH_NOARGS, - swapcase__doc__}, - {"translate", (PyCFunction)string_translate, METH_VARARGS, - translate__doc__}, - {"title", (PyCFunction)string_title, METH_NOARGS, title__doc__}, - {"ljust", (PyCFunction)string_ljust, METH_VARARGS, ljust__doc__}, - {"rjust", (PyCFunction)string_rjust, METH_VARARGS, rjust__doc__}, - {"center", (PyCFunction)string_center, METH_VARARGS, center__doc__}, - {"zfill", (PyCFunction)string_zfill, METH_VARARGS, zfill__doc__}, - {"encode", (PyCFunction)string_encode, METH_VARARGS, encode__doc__}, - {"decode", (PyCFunction)string_decode, METH_VARARGS, decode__doc__}, - {"expandtabs", (PyCFunction)string_expandtabs, METH_VARARGS, - expandtabs__doc__}, - {"splitlines", (PyCFunction)string_splitlines, METH_VARARGS, - splitlines__doc__}, - {"__getnewargs__", (PyCFunction)string_getnewargs, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -str_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); - -static PyObject * -string_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *x = NULL; - static char *kwlist[] = {"object", 0}; - - if (type != &PyString_Type) - return str_subtype_new(type, args, kwds); - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:str", kwlist, &x)) - return NULL; - if (x == NULL) - return PyString_FromString(""); - return PyObject_Str(x); -} - -static PyObject * -str_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *tmp, *pnew; - int n; - - assert(PyType_IsSubtype(type, &PyString_Type)); - tmp = string_new(&PyString_Type, args, kwds); - if (tmp == NULL) - return NULL; - assert(PyString_CheckExact(tmp)); - n = PyString_GET_SIZE(tmp); - pnew = type->tp_alloc(type, n); - if (pnew != NULL) { - memcpy(PyString_AS_STRING(pnew), PyString_AS_STRING(tmp), n+1); - ((PyStringObject *)pnew)->ob_shash = - ((PyStringObject *)tmp)->ob_shash; - ((PyStringObject *)pnew)->ob_sstate = SSTATE_NOT_INTERNED; - } - Py_DECREF(tmp); - return pnew; -} - -static PyObject * -basestring_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyErr_SetString(PyExc_TypeError, - "The basestring type cannot be instantiated"); - return NULL; -} - -static PyObject * -string_mod(PyObject *v, PyObject *w) -{ - if (!PyString_Check(v)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - return PyString_Format(v, w); -} - -PyDoc_STRVAR(basestring_doc, -"Type basestring cannot be instantiated; it is the base for str and unicode."); - -static PyNumberMethods string_as_number = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - 0, /*nb_divide*/ - string_mod, /*nb_remainder*/ -}; - - -PyTypeObject PyBaseString_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "basestring", - 0, - 0, - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - basestring_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - &PyBaseObject_Type, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - basestring_new, /* tp_new */ - 0, /* tp_free */ -}; - -PyDoc_STRVAR(string_doc, -"str(object) -> string\n\ -\n\ -Return a nice string representation of the object.\n\ -If the argument is a string, the return value is the same object."); - -PyTypeObject PyString_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "str", - sizeof(PyStringObject), - sizeof(char), - (destructor)string_dealloc, /* tp_dealloc */ - (printfunc)string_print, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)string_repr, /* tp_repr */ - &string_as_number, /* tp_as_number */ - &string_as_sequence, /* tp_as_sequence */ - &string_as_mapping, /* tp_as_mapping */ - (hashfunc)string_hash, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)string_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - &string_as_buffer, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - string_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)string_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - string_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - &PyBaseString_Type, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - string_new, /* tp_new */ - PyObject_Del, /* tp_free */ -}; - -void -PyString_Concat(register PyObject **pv, register PyObject *w) -{ - register PyObject *v; - if (*pv == NULL) - return; - if (w == NULL || !PyString_Check(*pv)) { - Py_DECREF(*pv); - *pv = NULL; - return; - } - v = string_concat((PyStringObject *) *pv, w); - Py_DECREF(*pv); - *pv = v; -} - -void -PyString_ConcatAndDel(register PyObject **pv, register PyObject *w) -{ - PyString_Concat(pv, w); - Py_XDECREF(w); -} - - -/* The following function breaks the notion that strings are immutable: - it changes the size of a string. We get away with this only if there - is only one module referencing the object. You can also think of it - as creating a new string object and destroying the old one, only - more efficiently. In any case, don't use this if the string may - already be known to some other part of the code... - Note that if there's not enough memory to resize the string, the original - string object at *pv is deallocated, *pv is set to NULL, an "out of - memory" exception is set, and -1 is returned. Else (on success) 0 is - returned, and the value in *pv may or may not be the same as on input. - As always, an extra byte is allocated for a trailing \0 byte (newsize - does *not* include that), and a trailing \0 byte is stored. -*/ - -int -_PyString_Resize(PyObject **pv, int newsize) -{ - register PyObject *v; - register PyStringObject *sv; - v = *pv; - if (!PyString_Check(v) || v->ob_refcnt != 1 || newsize < 0) { - *pv = 0; - Py_DECREF(v); - PyErr_BadInternalCall(); - return -1; - } - /* XXX UNREF/NEWREF interface should be more symmetrical */ - _Py_DEC_REFTOTAL; - _Py_ForgetReference(v); - *pv = (PyObject *) - PyObject_REALLOC((char *)v, - sizeof(PyStringObject) + newsize * sizeof(char)); - if (*pv == NULL) { - PyObject_Del(v); - PyErr_NoMemory(); - return -1; - } - _Py_NewReference(*pv); - sv = (PyStringObject *) *pv; - sv->ob_size = newsize; - sv->ob_sval[newsize] = '\0'; - return 0; -} - -/* Helpers for formatstring */ - -static PyObject * -getnextarg(PyObject *args, int arglen, int *p_argidx) -{ - int argidx = *p_argidx; - if (argidx < arglen) { - (*p_argidx)++; - if (arglen < 0) - return args; - else - return PyTuple_GetItem(args, argidx); - } - PyErr_SetString(PyExc_TypeError, - "not enough arguments for format string"); - return NULL; -} - -/* Format codes - * F_LJUST '-' - * F_SIGN '+' - * F_BLANK ' ' - * F_ALT '#' - * F_ZERO '0' - */ -#define F_LJUST (1<<0) -#define F_SIGN (1<<1) -#define F_BLANK (1<<2) -#define F_ALT (1<<3) -#define F_ZERO (1<<4) - -static int -formatfloat(char *buf, size_t buflen, int flags, - int prec, int type, PyObject *v) -{ - /* fmt = '%#.' + `prec` + `type` - worst case length = 3 + 10 (len of INT_MAX) + 1 = 14 (use 20)*/ - char fmt[20]; - double x; - x = PyFloat_AsDouble(v); - if (x == -1.0 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, "float argument required"); - return -1; - } - if (prec < 0) - prec = 6; - if (type == 'f' && fabs(x)/1e25 >= 1e25) - type = 'g'; - /* Worst case length calc to ensure no buffer overrun: - - 'g' formats: - fmt = %#.g - buf = '-' + [0-9]*prec + '.' + 'e+' + (longest exp - for any double rep.) - len = 1 + prec + 1 + 2 + 5 = 9 + prec - - 'f' formats: - buf = '-' + [0-9]*x + '.' + [0-9]*prec (with x < 50) - len = 1 + 50 + 1 + prec = 52 + prec - - If prec=0 the effective precision is 1 (the leading digit is - always given), therefore increase the length by one. - - */ - if ((type == 'g' && buflen <= (size_t)10 + (size_t)prec) || - (type == 'f' && buflen <= (size_t)53 + (size_t)prec)) { - PyErr_SetString(PyExc_OverflowError, - "formatted float is too long (precision too large?)"); - return -1; - } - PyOS_snprintf(fmt, sizeof(fmt), "%%%s.%d%c", - (flags&F_ALT) ? "#" : "", - prec, type); - PyOS_snprintf(buf, buflen, fmt, x); - return strlen(buf); -} - -/* _PyString_FormatLong emulates the format codes d, u, o, x and X, and - * the F_ALT flag, for Python's long (unbounded) ints. It's not used for - * Python's regular ints. - * Return value: a new PyString*, or NULL if error. - * . *pbuf is set to point into it, - * *plen set to the # of chars following that. - * Caller must decref it when done using pbuf. - * The string starting at *pbuf is of the form - * "-"? ("0x" | "0X")? digit+ - * "0x"/"0X" are present only for x and X conversions, with F_ALT - * set in flags. The case of hex digits will be correct, - * There will be at least prec digits, zero-filled on the left if - * necessary to get that many. - * val object to be converted - * flags bitmask of format flags; only F_ALT is looked at - * prec minimum number of digits; 0-fill on left if needed - * type a character in [duoxX]; u acts the same as d - * - * CAUTION: o, x and X conversions on regular ints can never - * produce a '-' sign, but can for Python's unbounded ints. - */ -PyObject* -_PyString_FormatLong(PyObject *val, int flags, int prec, int type, - char **pbuf, int *plen) -{ - PyObject *result = NULL; - char *buf; - int i; - int sign; /* 1 if '-', else 0 */ - int len; /* number of characters */ - int numdigits; /* len == numnondigits + numdigits */ - int numnondigits = 0; - - switch (type) { - case 'd': - case 'u': - result = val->ob_type->tp_str(val); - break; - case 'o': - result = val->ob_type->tp_as_number->nb_oct(val); - break; - case 'x': - case 'X': - numnondigits = 2; - result = val->ob_type->tp_as_number->nb_hex(val); - break; - default: - assert(!"'type' not in [duoxX]"); - } - if (!result) - return NULL; - - /* To modify the string in-place, there can only be one reference. */ - if (result->ob_refcnt != 1) { - PyErr_BadInternalCall(); - return NULL; - } - buf = PyString_AsString(result); - len = PyString_Size(result); - if (buf[len-1] == 'L') { - --len; - buf[len] = '\0'; - } - sign = buf[0] == '-'; - numnondigits += sign; - numdigits = len - numnondigits; - assert(numdigits > 0); - - /* Get rid of base marker unless F_ALT */ - if ((flags & F_ALT) == 0) { - /* Need to skip 0x, 0X or 0. */ - int skipped = 0; - switch (type) { - case 'o': - assert(buf[sign] == '0'); - /* If 0 is only digit, leave it alone. */ - if (numdigits > 1) { - skipped = 1; - --numdigits; - } - break; - case 'x': - case 'X': - assert(buf[sign] == '0'); - assert(buf[sign + 1] == 'x'); - skipped = 2; - numnondigits -= 2; - break; - } - if (skipped) { - buf += skipped; - len -= skipped; - if (sign) - buf[0] = '-'; - } - assert(len == numnondigits + numdigits); - assert(numdigits > 0); - } - - /* Fill with leading zeroes to meet minimum width. */ - if (prec > numdigits) { - PyObject *r1 = PyString_FromStringAndSize(NULL, - numnondigits + prec); - char *b1; - if (!r1) { - Py_DECREF(result); - return NULL; - } - b1 = PyString_AS_STRING(r1); - for (i = 0; i < numnondigits; ++i) - *b1++ = *buf++; - for (i = 0; i < prec - numdigits; i++) - *b1++ = '0'; - for (i = 0; i < numdigits; i++) - *b1++ = *buf++; - *b1 = '\0'; - Py_DECREF(result); - result = r1; - buf = PyString_AS_STRING(result); - len = numnondigits + prec; - } - - /* Fix up case for hex conversions. */ - switch (type) { - case 'x': - /* Need to convert all upper case letters to lower case. */ - for (i = 0; i < len; i++) - if (buf[i] >= 'A' && buf[i] <= 'F') - buf[i] += 'a'-'A'; - break; - case 'X': - /* Need to convert 0x to 0X (and -0x to -0X). */ - if (buf[sign + 1] == 'x') - buf[sign + 1] = 'X'; - break; - } - *pbuf = buf; - *plen = len; - return result; -} - -static int -formatint(char *buf, size_t buflen, int flags, - int prec, int type, PyObject *v) -{ - /* fmt = '%#.' + `prec` + 'l' + `type` - worst case length = 3 + 19 (worst len of INT_MAX on 64-bit machine) - + 1 + 1 = 24 */ - char fmt[64]; /* plenty big enough! */ - long x; - - x = PyInt_AsLong(v); - if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, "int argument required"); - return -1; - } - if (x < 0 && type != 'd' && type != 'i') { - if (PyErr_Warn(PyExc_FutureWarning, - "%u/%o/%x/%X of negative int will return " - "a signed string in Python 2.4 and up") < 0) - return -1; - } - if (prec < 0) - prec = 1; - - if ((flags & F_ALT) && - (type == 'x' || type == 'X')) { - /* When converting under %#x or %#X, there are a number - * of issues that cause pain: - * - when 0 is being converted, the C standard leaves off - * the '0x' or '0X', which is inconsistent with other - * %#x/%#X conversions and inconsistent with Python's - * hex() function - * - there are platforms that violate the standard and - * convert 0 with the '0x' or '0X' - * (Metrowerks, Compaq Tru64) - * - there are platforms that give '0x' when converting - * under %#X, but convert 0 in accordance with the - * standard (OS/2 EMX) - * - * We can achieve the desired consistency by inserting our - * own '0x' or '0X' prefix, and substituting %x/%X in place - * of %#x/%#X. - * - * Note that this is the same approach as used in - * formatint() in unicodeobject.c - */ - PyOS_snprintf(fmt, sizeof(fmt), "0%c%%.%dl%c", - type, prec, type); - } - else { - PyOS_snprintf(fmt, sizeof(fmt), "%%%s.%dl%c", - (flags&F_ALT) ? "#" : "", - prec, type); - } - - /* buf = '+'/'-'/'0'/'0x' + '[0-9]'*max(prec, len(x in octal)) - * worst case buf = '0x' + [0-9]*prec, where prec >= 11 - */ - if (buflen <= 13 || buflen <= (size_t)2 + (size_t)prec) { - PyErr_SetString(PyExc_OverflowError, - "formatted integer is too long (precision too large?)"); - return -1; - } - PyOS_snprintf(buf, buflen, fmt, x); - return strlen(buf); -} - -static int -formatchar(char *buf, size_t buflen, PyObject *v) -{ - /* presume that the buffer is at least 2 characters long */ - if (PyString_Check(v)) { - if (!PyArg_Parse(v, "c;%c requires int or char", &buf[0])) - return -1; - } - else { - if (!PyArg_Parse(v, "b;%c requires int or char", &buf[0])) - return -1; - } - buf[1] = '\0'; - return 1; -} - - -/* fmt%(v1,v2,...) is roughly equivalent to sprintf(fmt, v1, v2, ...) - - FORMATBUFLEN is the length of the buffer in which the floats, ints, & - chars are formatted. XXX This is a magic number. Each formatting - routine does bounds checking to ensure no overflow, but a better - solution may be to malloc a buffer of appropriate size for each - format. For now, the current solution is sufficient. -*/ -#define FORMATBUFLEN (size_t)120 - -PyObject * -PyString_Format(PyObject *format, PyObject *args) -{ - char *fmt, *res; - int fmtcnt, rescnt, reslen, arglen, argidx; - int args_owned = 0; - PyObject *result, *orig_args; -#ifdef Py_USING_UNICODE - PyObject *v, *w; -#endif - PyObject *dict = NULL; - if (format == NULL || !PyString_Check(format) || args == NULL) { - PyErr_BadInternalCall(); - return NULL; - } - orig_args = args; - fmt = PyString_AS_STRING(format); - fmtcnt = PyString_GET_SIZE(format); - reslen = rescnt = fmtcnt + 100; - result = PyString_FromStringAndSize((char *)NULL, reslen); - if (result == NULL) - return NULL; - res = PyString_AsString(result); - if (PyTuple_Check(args)) { - arglen = PyTuple_GET_SIZE(args); - argidx = 0; - } - else { - arglen = -1; - argidx = -2; - } - if (args->ob_type->tp_as_mapping && !PyTuple_Check(args) && - !PyObject_TypeCheck(args, &PyBaseString_Type)) - dict = args; - while (--fmtcnt >= 0) { - if (*fmt != '%') { - if (--rescnt < 0) { - rescnt = fmtcnt + 100; - reslen += rescnt; - if (_PyString_Resize(&result, reslen) < 0) - return NULL; - res = PyString_AS_STRING(result) - + reslen - rescnt; - --rescnt; - } - *res++ = *fmt++; - } - else { - /* Got a format specifier */ - int flags = 0; - int width = -1; - int prec = -1; - int c = '\0'; - int fill; - PyObject *v = NULL; - PyObject *temp = NULL; - char *pbuf; - int sign; - int len; - char formatbuf[FORMATBUFLEN]; - /* For format{float,int,char}() */ -#ifdef Py_USING_UNICODE - char *fmt_start = fmt; - int argidx_start = argidx; -#endif - - fmt++; - if (*fmt == '(') { - char *keystart; - int keylen; - PyObject *key; - int pcount = 1; - - if (dict == NULL) { - PyErr_SetString(PyExc_TypeError, - "format requires a mapping"); - goto error; - } - ++fmt; - --fmtcnt; - keystart = fmt; - /* Skip over balanced parentheses */ - while (pcount > 0 && --fmtcnt >= 0) { - if (*fmt == ')') - --pcount; - else if (*fmt == '(') - ++pcount; - fmt++; - } - keylen = fmt - keystart - 1; - if (fmtcnt < 0 || pcount > 0) { - PyErr_SetString(PyExc_ValueError, - "incomplete format key"); - goto error; - } - key = PyString_FromStringAndSize(keystart, - keylen); - if (key == NULL) - goto error; - if (args_owned) { - Py_DECREF(args); - args_owned = 0; - } - args = PyObject_GetItem(dict, key); - Py_DECREF(key); - if (args == NULL) { - goto error; - } - args_owned = 1; - arglen = -1; - argidx = -2; - } - while (--fmtcnt >= 0) { - switch (c = *fmt++) { - case '-': flags |= F_LJUST; continue; - case '+': flags |= F_SIGN; continue; - case ' ': flags |= F_BLANK; continue; - case '#': flags |= F_ALT; continue; - case '0': flags |= F_ZERO; continue; - } - break; - } - if (c == '*') { - v = getnextarg(args, arglen, &argidx); - if (v == NULL) - goto error; - if (!PyInt_Check(v)) { - PyErr_SetString(PyExc_TypeError, - "* wants int"); - goto error; - } - width = PyInt_AsLong(v); - if (width < 0) { - flags |= F_LJUST; - width = -width; - } - if (--fmtcnt >= 0) - c = *fmt++; - } - else if (c >= 0 && isdigit(c)) { - width = c - '0'; - while (--fmtcnt >= 0) { - c = Py_CHARMASK(*fmt++); - if (!isdigit(c)) - break; - if ((width*10) / 10 != width) { - PyErr_SetString( - PyExc_ValueError, - "width too big"); - goto error; - } - width = width*10 + (c - '0'); - } - } - if (c == '.') { - prec = 0; - if (--fmtcnt >= 0) - c = *fmt++; - if (c == '*') { - v = getnextarg(args, arglen, &argidx); - if (v == NULL) - goto error; - if (!PyInt_Check(v)) { - PyErr_SetString( - PyExc_TypeError, - "* wants int"); - goto error; - } - prec = PyInt_AsLong(v); - if (prec < 0) - prec = 0; - if (--fmtcnt >= 0) - c = *fmt++; - } - else if (c >= 0 && isdigit(c)) { - prec = c - '0'; - while (--fmtcnt >= 0) { - c = Py_CHARMASK(*fmt++); - if (!isdigit(c)) - break; - if ((prec*10) / 10 != prec) { - PyErr_SetString( - PyExc_ValueError, - "prec too big"); - goto error; - } - prec = prec*10 + (c - '0'); - } - } - } /* prec */ - if (fmtcnt >= 0) { - if (c == 'h' || c == 'l' || c == 'L') { - if (--fmtcnt >= 0) - c = *fmt++; - } - } - if (fmtcnt < 0) { - PyErr_SetString(PyExc_ValueError, - "incomplete format"); - goto error; - } - if (c != '%') { - v = getnextarg(args, arglen, &argidx); - if (v == NULL) - goto error; - } - sign = 0; - fill = ' '; - switch (c) { - case '%': - pbuf = "%"; - len = 1; - break; - case 's': -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(v)) { - fmt = fmt_start; - argidx = argidx_start; - goto unicode; - } -#endif - /* Fall through */ - case 'r': - if (c == 's') - temp = PyObject_Str(v); - else - temp = PyObject_Repr(v); - if (temp == NULL) - goto error; - if (!PyString_Check(temp)) { - /* XXX Note: this should never happen, - since PyObject_Repr() and - PyObject_Str() assure this */ - PyErr_SetString(PyExc_TypeError, - "%s argument has non-string str()"); - Py_DECREF(temp); - goto error; - } - pbuf = PyString_AS_STRING(temp); - len = PyString_GET_SIZE(temp); - if (prec >= 0 && len > prec) - len = prec; - break; - case 'i': - case 'd': - case 'u': - case 'o': - case 'x': - case 'X': - if (c == 'i') - c = 'd'; - if (PyLong_Check(v)) { - temp = _PyString_FormatLong(v, flags, - prec, c, &pbuf, &len); - if (!temp) - goto error; - /* unbounded ints can always produce - a sign character! */ - sign = 1; - } - else { - pbuf = formatbuf; - len = formatint(pbuf, - sizeof(formatbuf), - flags, prec, c, v); - if (len < 0) - goto error; - /* only d conversion is signed */ - sign = c == 'd'; - } - if (flags & F_ZERO) - fill = '0'; - break; - case 'e': - case 'E': - case 'f': - case 'F': - case 'g': - case 'G': - if (c == 'F') - c = 'f'; - pbuf = formatbuf; - len = formatfloat(pbuf, sizeof(formatbuf), - flags, prec, c, v); - if (len < 0) - goto error; - sign = 1; - if (flags & F_ZERO) - fill = '0'; - break; - case 'c': -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(v)) { - fmt = fmt_start; - argidx = argidx_start; - goto unicode; - } -#endif - pbuf = formatbuf; - len = formatchar(pbuf, sizeof(formatbuf), v); - if (len < 0) - goto error; - break; - default: - PyErr_Format(PyExc_ValueError, - "unsupported format character '%c' (0x%x) " - "at index %i", - c, c, - (int)(fmt - 1 - PyString_AsString(format))); - goto error; - } - if (sign) { - if (*pbuf == '-' || *pbuf == '+') { - sign = *pbuf++; - len--; - } - else if (flags & F_SIGN) - sign = '+'; - else if (flags & F_BLANK) - sign = ' '; - else - sign = 0; - } - if (width < len) - width = len; - if (rescnt - (sign != 0) < width) { - reslen -= rescnt; - rescnt = width + fmtcnt + 100; - reslen += rescnt; - if (reslen < 0) { - Py_DECREF(result); - return PyErr_NoMemory(); - } - if (_PyString_Resize(&result, reslen) < 0) - return NULL; - res = PyString_AS_STRING(result) - + reslen - rescnt; - } - if (sign) { - if (fill != ' ') - *res++ = sign; - rescnt--; - if (width > len) - width--; - } - if ((flags & F_ALT) && (c == 'x' || c == 'X')) { - assert(pbuf[0] == '0'); - assert(pbuf[1] == c); - if (fill != ' ') { - *res++ = *pbuf++; - *res++ = *pbuf++; - } - rescnt -= 2; - width -= 2; - if (width < 0) - width = 0; - len -= 2; - } - if (width > len && !(flags & F_LJUST)) { - do { - --rescnt; - *res++ = fill; - } while (--width > len); - } - if (fill == ' ') { - if (sign) - *res++ = sign; - if ((flags & F_ALT) && - (c == 'x' || c == 'X')) { - assert(pbuf[0] == '0'); - assert(pbuf[1] == c); - *res++ = *pbuf++; - *res++ = *pbuf++; - } - } - memcpy(res, pbuf, len); - res += len; - rescnt -= len; - while (--width >= len) { - --rescnt; - *res++ = ' '; - } - if (dict && (argidx < arglen) && c != '%') { - PyErr_SetString(PyExc_TypeError, - "not all arguments converted during string formatting"); - goto error; - } - Py_XDECREF(temp); - } /* '%' */ - } /* until end */ - if (argidx < arglen && !dict) { - PyErr_SetString(PyExc_TypeError, - "not all arguments converted during string formatting"); - goto error; - } - if (args_owned) { - Py_DECREF(args); - } - _PyString_Resize(&result, reslen - rescnt); - return result; - -#ifdef Py_USING_UNICODE - unicode: - if (args_owned) { - Py_DECREF(args); - args_owned = 0; - } - /* Fiddle args right (remove the first argidx arguments) */ - if (PyTuple_Check(orig_args) && argidx > 0) { - PyObject *v; - int n = PyTuple_GET_SIZE(orig_args) - argidx; - v = PyTuple_New(n); - if (v == NULL) - goto error; - while (--n >= 0) { - PyObject *w = PyTuple_GET_ITEM(orig_args, n + argidx); - Py_INCREF(w); - PyTuple_SET_ITEM(v, n, w); - } - args = v; - } else { - Py_INCREF(orig_args); - args = orig_args; - } - args_owned = 1; - /* Take what we have of the result and let the Unicode formatting - function format the rest of the input. */ - rescnt = res - PyString_AS_STRING(result); - if (_PyString_Resize(&result, rescnt)) - goto error; - fmtcnt = PyString_GET_SIZE(format) - \ - (fmt - PyString_AS_STRING(format)); - format = PyUnicode_Decode(fmt, fmtcnt, NULL, NULL); - if (format == NULL) - goto error; - v = PyUnicode_Format(format, args); - Py_DECREF(format); - if (v == NULL) - goto error; - /* Paste what we have (result) to what the Unicode formatting - function returned (v) and return the result (or error) */ - w = PyUnicode_Concat(result, v); - Py_DECREF(result); - Py_DECREF(v); - Py_DECREF(args); - return w; -#endif /* Py_USING_UNICODE */ - - error: - Py_DECREF(result); - if (args_owned) { - Py_DECREF(args); - } - return NULL; -} - -void -PyString_InternInPlace(PyObject **p) -{ - register PyStringObject *s = (PyStringObject *)(*p); - PyObject *t; - if (s == NULL || !PyString_Check(s)) - Py_FatalError("PyString_InternInPlace: strings only please!"); - if (PyString_CHECK_INTERNED(s)) - return; - if (interned == NULL) { - interned = PyDict_New(); - if (interned == NULL) { - PyErr_Clear(); /* Don't leave an exception */ - return; - } - } - if ((t = PyDict_GetItem(interned, (PyObject *)s)) != NULL) { - Py_INCREF(t); - Py_DECREF(*p); - *p = t; - return; - } - /* Ensure that only true string objects appear in the intern dict */ - if (!PyString_CheckExact(s)) { - t = PyString_FromStringAndSize(PyString_AS_STRING(s), - PyString_GET_SIZE(s)); - if (t == NULL) { - PyErr_Clear(); - return; - } - } else { - t = (PyObject*) s; - Py_INCREF(t); - } - - if (PyDict_SetItem(interned, t, t) == 0) { - /* The two references in interned are not counted by - refcnt. The string deallocator will take care of this */ - ((PyObject *)t)->ob_refcnt-=2; - PyString_CHECK_INTERNED(t) = SSTATE_INTERNED_MORTAL; - Py_DECREF(*p); - *p = t; - return; - } - Py_DECREF(t); - PyErr_Clear(); -} - -void -PyString_InternImmortal(PyObject **p) -{ - PyString_InternInPlace(p); - if (PyString_CHECK_INTERNED(*p) != SSTATE_INTERNED_IMMORTAL) { - PyString_CHECK_INTERNED(*p) = SSTATE_INTERNED_IMMORTAL; - Py_INCREF(*p); - } -} - - -PyObject * -PyString_InternFromString(const char *cp) -{ - PyObject *s = PyString_FromString(cp); - if (s == NULL) - return NULL; - PyString_InternInPlace(&s); - return s; -} - -void -PyString_Fini(void) -{ - int i; - for (i = 0; i < UCHAR_MAX + 1; i++) { - Py_XDECREF(characters[i]); - characters[i] = NULL; - } - Py_XDECREF(nullstring); - nullstring = NULL; -} - -void _Py_ReleaseInternedStrings(void) -{ - PyObject *keys; - PyStringObject *s; - int i, n; - - if (interned == NULL || !PyDict_Check(interned)) - return; - keys = PyDict_Keys(interned); - if (keys == NULL || !PyList_Check(keys)) { - PyErr_Clear(); - return; - } - - /* Since _Py_ReleaseInternedStrings() is intended to help a leak - detector, interned strings are not forcibly deallocated; rather, we - give them their stolen references back, and then clear and DECREF - the interned dict. */ - - fprintf(stderr, "releasing interned strings\n"); - n = PyList_GET_SIZE(keys); - for (i = 0; i < n; i++) { - s = (PyStringObject *) PyList_GET_ITEM(keys, i); - switch (s->ob_sstate) { - case SSTATE_NOT_INTERNED: - /* XXX Shouldn't happen */ - break; - case SSTATE_INTERNED_IMMORTAL: - s->ob_refcnt += 1; - break; - case SSTATE_INTERNED_MORTAL: - s->ob_refcnt += 2; - break; - default: - Py_FatalError("Inconsistent interned string state."); - } - s->ob_sstate = SSTATE_NOT_INTERNED; - } - Py_DECREF(keys); - PyDict_Clear(interned); - Py_DECREF(interned); - interned = NULL; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/structseq.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/structseq.c deleted file mode 100644 index a968f1fc..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/structseq.c +++ /dev/null @@ -1,395 +0,0 @@ -/* Implementation helper: a struct that looks like a tuple. See timemodule - and posixmodule for example uses. */ - -#include "Python.h" -#include "structmember.h" -#include "structseq.h" - -static char visible_length_key[] = "n_sequence_fields"; -static char real_length_key[] = "n_fields"; -static char unnamed_fields_key[] = "n_unnamed_fields"; - -/* Fields with this name have only a field index, not a field name. - They are only allowed for indices < n_visible_fields. */ -char *PyStructSequence_UnnamedField = "unnamed field"; - -#define VISIBLE_SIZE(op) ((op)->ob_size) -#define VISIBLE_SIZE_TP(tp) PyInt_AsLong( \ - PyDict_GetItemString((tp)->tp_dict, visible_length_key)) - -#define REAL_SIZE_TP(tp) PyInt_AsLong( \ - PyDict_GetItemString((tp)->tp_dict, real_length_key)) -#define REAL_SIZE(op) REAL_SIZE_TP((op)->ob_type) - -#define UNNAMED_FIELDS_TP(tp) PyInt_AsLong( \ - PyDict_GetItemString((tp)->tp_dict, unnamed_fields_key)) -#define UNNAMED_FIELDS(op) UNNAMED_FIELDS_TP((op)->ob_type) - - -PyObject * -PyStructSequence_New(PyTypeObject *type) -{ - PyStructSequence *obj; - - obj = PyObject_New(PyStructSequence, type); - obj->ob_size = VISIBLE_SIZE_TP(type); - - return (PyObject*) obj; -} - -static void -structseq_dealloc(PyStructSequence *obj) -{ - int i, size; - - size = REAL_SIZE(obj); - for (i = 0; i < size; ++i) { - Py_XDECREF(obj->ob_item[i]); - } - PyObject_Del(obj); -} - -static int -structseq_length(PyStructSequence *obj) -{ - return VISIBLE_SIZE(obj); -} - -static PyObject* -structseq_item(PyStructSequence *obj, int i) -{ - if (i < 0 || i >= VISIBLE_SIZE(obj)) { - PyErr_SetString(PyExc_IndexError, "tuple index out of range"); - return NULL; - } - Py_INCREF(obj->ob_item[i]); - return obj->ob_item[i]; -} - -static PyObject* -structseq_slice(PyStructSequence *obj, int low, int high) -{ - PyTupleObject *np; - int i; - - if (low < 0) - low = 0; - if (high > VISIBLE_SIZE(obj)) - high = VISIBLE_SIZE(obj); - if (high < low) - high = low; - np = (PyTupleObject *)PyTuple_New(high-low); - if (np == NULL) - return NULL; - for(i = low; i < high; ++i) { - PyObject *v = obj->ob_item[i]; - Py_INCREF(v); - PyTuple_SET_ITEM(np, i-low, v); - } - return (PyObject *) np; -} - -static PyObject * -structseq_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *arg = NULL; - PyObject *dict = NULL; - PyObject *ob; - PyStructSequence *res = NULL; - int len, min_len, max_len, i, n_unnamed_fields; - static char *kwlist[] = {"sequence", "dict", 0}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:structseq", - kwlist, &arg, &dict)) - return NULL; - - arg = PySequence_Fast(arg, "constructor requires a sequence"); - - if (!arg) { - return NULL; - } - - if (dict && !PyDict_Check(dict)) { - PyErr_Format(PyExc_TypeError, - "%.500s() takes a dict as second arg, if any", - type->tp_name); - Py_DECREF(arg); - return NULL; - } - - len = PySequence_Fast_GET_SIZE(arg); - min_len = VISIBLE_SIZE_TP(type); - max_len = REAL_SIZE_TP(type); - n_unnamed_fields = UNNAMED_FIELDS_TP(type); - - if (min_len != max_len) { - if (len < min_len) { - PyErr_Format(PyExc_TypeError, - "%.500s() takes an at least %d-sequence (%d-sequence given)", - type->tp_name, min_len, len); - Py_DECREF(arg); - return NULL; - } - - if (len > max_len) { - PyErr_Format(PyExc_TypeError, - "%.500s() takes an at most %d-sequence (%d-sequence given)", - type->tp_name, max_len, len); - Py_DECREF(arg); - return NULL; - } - } - else { - if (len != min_len) { - PyErr_Format(PyExc_TypeError, - "%.500s() takes a %d-sequence (%d-sequence given)", - type->tp_name, min_len, len); - Py_DECREF(arg); - return NULL; - } - } - - res = (PyStructSequence*) PyStructSequence_New(type); - if (res == NULL) { - return NULL; - } - for (i = 0; i < len; ++i) { - PyObject *v = PySequence_Fast_GET_ITEM(arg, i); - Py_INCREF(v); - res->ob_item[i] = v; - } - for (; i < max_len; ++i) { - if (dict && (ob = PyDict_GetItemString( - dict, type->tp_members[i-n_unnamed_fields].name))) { - } - else { - ob = Py_None; - } - Py_INCREF(ob); - res->ob_item[i] = ob; - } - - Py_DECREF(arg); - return (PyObject*) res; -} - -static PyObject * -make_tuple(PyStructSequence *obj) -{ - return structseq_slice(obj, 0, VISIBLE_SIZE(obj)); -} - -static PyObject * -structseq_repr(PyStructSequence *obj) -{ - PyObject *tup, *str; - tup = make_tuple(obj); - str = PyObject_Repr(tup); - Py_DECREF(tup); - return str; -} - -static PyObject * -structseq_concat(PyStructSequence *obj, PyObject *b) -{ - PyObject *tup, *result; - tup = make_tuple(obj); - result = PySequence_Concat(tup, b); - Py_DECREF(tup); - return result; -} - -static PyObject * -structseq_repeat(PyStructSequence *obj, int n) -{ - PyObject *tup, *result; - tup = make_tuple(obj); - result = PySequence_Repeat(tup, n); - Py_DECREF(tup); - return result; -} - -static int -structseq_contains(PyStructSequence *obj, PyObject *o) -{ - PyObject *tup; - int result; - tup = make_tuple(obj); - result = PySequence_Contains(tup, o); - Py_DECREF(tup); - return result; -} - -static long -structseq_hash(PyObject *obj) -{ - PyObject *tup; - long result; - tup = make_tuple((PyStructSequence*) obj); - result = PyObject_Hash(tup); - Py_DECREF(tup); - return result; -} - -static PyObject * -structseq_richcompare(PyObject *obj, PyObject *o2, int op) -{ - PyObject *tup, *result; - tup = make_tuple((PyStructSequence*) obj); - result = PyObject_RichCompare(tup, o2, op); - Py_DECREF(tup); - return result; -} - -static PyObject * -structseq_reduce(PyStructSequence* self) -{ - PyObject* tup; - PyObject* dict; - PyObject* result; - long n_fields, n_visible_fields, n_unnamed_fields; - int i; - - n_fields = REAL_SIZE(self); - n_visible_fields = VISIBLE_SIZE(self); - n_unnamed_fields = UNNAMED_FIELDS(self); - tup = PyTuple_New(n_visible_fields); - if (!tup) { - return NULL; - } - - dict = PyDict_New(); - if (!dict) { - Py_DECREF(tup); - return NULL; - } - - for (i = 0; i < n_visible_fields; i++) { - Py_INCREF(self->ob_item[i]); - PyTuple_SET_ITEM(tup, i, self->ob_item[i]); - } - - for (; i < n_fields; i++) { - char *n = self->ob_type->tp_members[i-n_unnamed_fields].name; - PyDict_SetItemString(dict, n, - self->ob_item[i]); - } - - result = Py_BuildValue("(O(OO))", self->ob_type, tup, dict); - - Py_DECREF(tup); - Py_DECREF(dict); - - return result; -} - -static PySequenceMethods structseq_as_sequence = { - (inquiry)structseq_length, - (binaryfunc)structseq_concat, /* sq_concat */ - (intargfunc)structseq_repeat, /* sq_repeat */ - (intargfunc)structseq_item, /* sq_item */ - (intintargfunc)structseq_slice, /* sq_slice */ - 0, /* sq_ass_item */ - 0, /* sq_ass_slice */ - (objobjproc)structseq_contains, /* sq_contains */ -}; - -static PyMethodDef structseq_methods[] = { - {"__reduce__", (PyCFunction)structseq_reduce, - METH_NOARGS, NULL}, - {NULL, NULL} -}; - -static PyTypeObject _struct_sequence_template = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - NULL, /* tp_name */ - 0, /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)structseq_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)structseq_repr, /* tp_repr */ - 0, /* tp_as_number */ - &structseq_as_sequence, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)structseq_hash, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - NULL, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - structseq_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - structseq_methods, /* tp_methods */ - NULL, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - structseq_new, /* tp_new */ -}; - -void -PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc) -{ - PyObject *dict; - PyMemberDef* members; - int n_members, n_unnamed_members, i, k; - - n_unnamed_members = 0; - for (i = 0; desc->fields[i].name != NULL; ++i) - if (desc->fields[i].name == PyStructSequence_UnnamedField) - n_unnamed_members++; - n_members = i; - - memcpy(type, &_struct_sequence_template, sizeof(PyTypeObject)); - type->tp_name = desc->name; - type->tp_doc = desc->doc; - type->tp_basicsize = sizeof(PyStructSequence)+ - sizeof(PyObject*)*(n_members-1); - type->tp_itemsize = 0; - - members = PyMem_NEW(PyMemberDef, n_members-n_unnamed_members+1); - if (members == NULL) - return; - - for (i = k = 0; i < n_members; ++i) { - if (desc->fields[i].name == PyStructSequence_UnnamedField) - continue; - members[k].name = desc->fields[i].name; - members[k].type = T_OBJECT; - members[k].offset = offsetof(PyStructSequence, ob_item) - + i * sizeof(PyObject*); - members[k].flags = READONLY; - members[k].doc = desc->fields[i].doc; - k++; - } - members[k].name = NULL; - - type->tp_members = members; - - if (PyType_Ready(type) < 0) - return; - Py_INCREF(type); - - dict = type->tp_dict; - PyDict_SetItemString(dict, visible_length_key, - PyInt_FromLong((long) desc->n_in_sequence)); - PyDict_SetItemString(dict, real_length_key, - PyInt_FromLong((long) n_members)); - PyDict_SetItemString(dict, unnamed_fields_key, - PyInt_FromLong((long) n_unnamed_members)); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/tupleobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/tupleobject.c deleted file mode 100644 index 369db6ca..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/tupleobject.c +++ /dev/null @@ -1,836 +0,0 @@ - -/* Tuple object implementation */ - -#include "Python.h" - -/* Speed optimization to avoid frequent malloc/free of small tuples */ -#ifndef MAXSAVESIZE -#define MAXSAVESIZE 20 /* Largest tuple to save on free list */ -#endif -#ifndef MAXSAVEDTUPLES -#define MAXSAVEDTUPLES 2000 /* Maximum number of tuples of each size to save */ -#endif - -#if MAXSAVESIZE > 0 -/* Entries 1 up to MAXSAVESIZE are free lists, entry 0 is the empty - tuple () of which at most one instance will be allocated. -*/ -static PyTupleObject *free_tuples[MAXSAVESIZE]; -static int num_free_tuples[MAXSAVESIZE]; -#endif -#ifdef COUNT_ALLOCS -int fast_tuple_allocs; -int tuple_zero_allocs; -#endif - -PyObject * -PyTuple_New(register int size) -{ - register PyTupleObject *op; - if (size < 0) { - PyErr_BadInternalCall(); - return NULL; - } -#if MAXSAVESIZE > 0 - if (size == 0 && free_tuples[0]) { - op = free_tuples[0]; - Py_INCREF(op); -#ifdef COUNT_ALLOCS - tuple_zero_allocs++; -#endif - return (PyObject *) op; - } - if (0 < size && size < MAXSAVESIZE && - (op = free_tuples[size]) != NULL) - { - free_tuples[size] = (PyTupleObject *) op->ob_item[0]; - num_free_tuples[size]--; -#ifdef COUNT_ALLOCS - fast_tuple_allocs++; -#endif - /* Inline PyObject_InitVar */ -#ifdef Py_TRACE_REFS - op->ob_size = size; - op->ob_type = &PyTuple_Type; -#endif - _Py_NewReference((PyObject *)op); - } - else -#endif - { - int nbytes = size * sizeof(PyObject *); - /* Check for overflow */ - if (nbytes / sizeof(PyObject *) != (size_t)size || - (nbytes += sizeof(PyTupleObject) - sizeof(PyObject *)) - <= 0) - { - return PyErr_NoMemory(); - } - op = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, size); - if (op == NULL) - return NULL; - } - memset(op->ob_item, 0, sizeof(*op->ob_item) * size); -#if MAXSAVESIZE > 0 - if (size == 0) { - free_tuples[0] = op; - ++num_free_tuples[0]; - Py_INCREF(op); /* extra INCREF so that this is never freed */ - } -#endif - _PyObject_GC_TRACK(op); - return (PyObject *) op; -} - -int -PyTuple_Size(register PyObject *op) -{ - if (!PyTuple_Check(op)) { - PyErr_BadInternalCall(); - return -1; - } - else - return ((PyTupleObject *)op)->ob_size; -} - -PyObject * -PyTuple_GetItem(register PyObject *op, register int i) -{ - if (!PyTuple_Check(op)) { - PyErr_BadInternalCall(); - return NULL; - } - if (i < 0 || i >= ((PyTupleObject *)op) -> ob_size) { - PyErr_SetString(PyExc_IndexError, "tuple index out of range"); - return NULL; - } - return ((PyTupleObject *)op) -> ob_item[i]; -} - -int -PyTuple_SetItem(register PyObject *op, register int i, PyObject *newitem) -{ - register PyObject *olditem; - register PyObject **p; - if (!PyTuple_Check(op) || op->ob_refcnt != 1) { - Py_XDECREF(newitem); - PyErr_BadInternalCall(); - return -1; - } - if (i < 0 || i >= ((PyTupleObject *)op) -> ob_size) { - Py_XDECREF(newitem); - PyErr_SetString(PyExc_IndexError, - "tuple assignment index out of range"); - return -1; - } - p = ((PyTupleObject *)op) -> ob_item + i; - olditem = *p; - *p = newitem; - Py_XDECREF(olditem); - return 0; -} - -/* Methods */ - -static void -tupledealloc(register PyTupleObject *op) -{ - register int i; - register int len = op->ob_size; - PyObject_GC_UnTrack(op); - Py_TRASHCAN_SAFE_BEGIN(op) - if (len > 0) { - i = len; - while (--i >= 0) - Py_XDECREF(op->ob_item[i]); -#if MAXSAVESIZE > 0 - if (len < MAXSAVESIZE && - num_free_tuples[len] < MAXSAVEDTUPLES && - op->ob_type == &PyTuple_Type) - { - op->ob_item[0] = (PyObject *) free_tuples[len]; - num_free_tuples[len]++; - free_tuples[len] = op; - goto done; /* return */ - } -#endif - } - op->ob_type->tp_free((PyObject *)op); -done: - Py_TRASHCAN_SAFE_END(op) -} - -static int -tupleprint(PyTupleObject *op, FILE *fp, int flags) -{ - int i; - fprintf(fp, "("); - for (i = 0; i < op->ob_size; i++) { - if (i > 0) - fprintf(fp, ", "); - if (PyObject_Print(op->ob_item[i], fp, 0) != 0) - return -1; - } - if (op->ob_size == 1) - fprintf(fp, ","); - fprintf(fp, ")"); - return 0; -} - -static PyObject * -tuplerepr(PyTupleObject *v) -{ - int i, n; - PyObject *s, *temp; - PyObject *pieces, *result = NULL; - - n = v->ob_size; - if (n == 0) - return PyString_FromString("()"); - - pieces = PyTuple_New(n); - if (pieces == NULL) - return NULL; - - /* Do repr() on each element. */ - for (i = 0; i < n; ++i) { - s = PyObject_Repr(v->ob_item[i]); - if (s == NULL) - goto Done; - PyTuple_SET_ITEM(pieces, i, s); - } - - /* Add "()" decorations to the first and last items. */ - assert(n > 0); - s = PyString_FromString("("); - if (s == NULL) - goto Done; - temp = PyTuple_GET_ITEM(pieces, 0); - PyString_ConcatAndDel(&s, temp); - PyTuple_SET_ITEM(pieces, 0, s); - if (s == NULL) - goto Done; - - s = PyString_FromString(n == 1 ? ",)" : ")"); - if (s == NULL) - goto Done; - temp = PyTuple_GET_ITEM(pieces, n-1); - PyString_ConcatAndDel(&temp, s); - PyTuple_SET_ITEM(pieces, n-1, temp); - if (temp == NULL) - goto Done; - - /* Paste them all together with ", " between. */ - s = PyString_FromString(", "); - if (s == NULL) - goto Done; - result = _PyString_Join(s, pieces); - Py_DECREF(s); - -Done: - Py_DECREF(pieces); - return result; -} - -static long -tuplehash(PyTupleObject *v) -{ - register long x, y; - register int len = v->ob_size; - register PyObject **p; - x = 0x345678L; - p = v->ob_item; - while (--len >= 0) { - y = PyObject_Hash(*p++); - if (y == -1) - return -1; - x = (1000003*x) ^ y; - } - x ^= v->ob_size; - if (x == -1) - x = -2; - return x; -} - -static int -tuplelength(PyTupleObject *a) -{ - return a->ob_size; -} - -static int -tuplecontains(PyTupleObject *a, PyObject *el) -{ - int i, cmp; - - for (i = 0, cmp = 0 ; cmp == 0 && i < a->ob_size; ++i) - cmp = PyObject_RichCompareBool(el, PyTuple_GET_ITEM(a, i), - Py_EQ); - return cmp; -} - -static PyObject * -tupleitem(register PyTupleObject *a, register int i) -{ - if (i < 0 || i >= a->ob_size) { - PyErr_SetString(PyExc_IndexError, "tuple index out of range"); - return NULL; - } - Py_INCREF(a->ob_item[i]); - return a->ob_item[i]; -} - -static PyObject * -tupleslice(register PyTupleObject *a, register int ilow, register int ihigh) -{ - register PyTupleObject *np; - register int i; - if (ilow < 0) - ilow = 0; - if (ihigh > a->ob_size) - ihigh = a->ob_size; - if (ihigh < ilow) - ihigh = ilow; - if (ilow == 0 && ihigh == a->ob_size && PyTuple_CheckExact(a)) { - Py_INCREF(a); - return (PyObject *)a; - } - np = (PyTupleObject *)PyTuple_New(ihigh - ilow); - if (np == NULL) - return NULL; - for (i = ilow; i < ihigh; i++) { - PyObject *v = a->ob_item[i]; - Py_INCREF(v); - np->ob_item[i - ilow] = v; - } - return (PyObject *)np; -} - -PyObject * -PyTuple_GetSlice(PyObject *op, int i, int j) -{ - if (op == NULL || !PyTuple_Check(op)) { - PyErr_BadInternalCall(); - return NULL; - } - return tupleslice((PyTupleObject *)op, i, j); -} - -static PyObject * -tupleconcat(register PyTupleObject *a, register PyObject *bb) -{ - register int size; - register int i; - PyTupleObject *np; - if (!PyTuple_Check(bb)) { - PyErr_Format(PyExc_TypeError, - "can only concatenate tuple (not \"%.200s\") to tuple", - bb->ob_type->tp_name); - return NULL; - } -#define b ((PyTupleObject *)bb) - size = a->ob_size + b->ob_size; - if (size < 0) - return PyErr_NoMemory(); - np = (PyTupleObject *) PyTuple_New(size); - if (np == NULL) { - return NULL; - } - for (i = 0; i < a->ob_size; i++) { - PyObject *v = a->ob_item[i]; - Py_INCREF(v); - np->ob_item[i] = v; - } - for (i = 0; i < b->ob_size; i++) { - PyObject *v = b->ob_item[i]; - Py_INCREF(v); - np->ob_item[i + a->ob_size] = v; - } - return (PyObject *)np; -#undef b -} - -static PyObject * -tuplerepeat(PyTupleObject *a, int n) -{ - int i, j; - int size; - PyTupleObject *np; - PyObject **p; - if (n < 0) - n = 0; - if (a->ob_size == 0 || n == 1) { - if (PyTuple_CheckExact(a)) { - /* Since tuples are immutable, we can return a shared - copy in this case */ - Py_INCREF(a); - return (PyObject *)a; - } - if (a->ob_size == 0) - return PyTuple_New(0); - } - size = a->ob_size * n; - if (size/a->ob_size != n) - return PyErr_NoMemory(); - np = (PyTupleObject *) PyTuple_New(size); - if (np == NULL) - return NULL; - p = np->ob_item; - for (i = 0; i < n; i++) { - for (j = 0; j < a->ob_size; j++) { - *p = a->ob_item[j]; - Py_INCREF(*p); - p++; - } - } - return (PyObject *) np; -} - -static int -tupletraverse(PyTupleObject *o, visitproc visit, void *arg) -{ - int i, err; - PyObject *x; - - for (i = o->ob_size; --i >= 0; ) { - x = o->ob_item[i]; - if (x != NULL) { - err = visit(x, arg); - if (err) - return err; - } - } - return 0; -} - -static PyObject * -tuplerichcompare(PyObject *v, PyObject *w, int op) -{ - PyTupleObject *vt, *wt; - int i; - int vlen, wlen; - - if (!PyTuple_Check(v) || !PyTuple_Check(w)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - - vt = (PyTupleObject *)v; - wt = (PyTupleObject *)w; - - vlen = vt->ob_size; - wlen = wt->ob_size; - - /* Note: the corresponding code for lists has an "early out" test - * here when op is EQ or NE and the lengths differ. That pays there, - * but Tim was unable to find any real code where EQ/NE tuple - * compares don't have the same length, so testing for it here would - * have cost without benefit. - */ - - /* Search for the first index where items are different. - * Note that because tuples are immutable, it's safe to reuse - * vlen and wlen across the comparison calls. - */ - for (i = 0; i < vlen && i < wlen; i++) { - int k = PyObject_RichCompareBool(vt->ob_item[i], - wt->ob_item[i], Py_EQ); - if (k < 0) - return NULL; - if (!k) - break; - } - - if (i >= vlen || i >= wlen) { - /* No more items to compare -- compare sizes */ - int cmp; - PyObject *res; - switch (op) { - case Py_LT: cmp = vlen < wlen; break; - case Py_LE: cmp = vlen <= wlen; break; - case Py_EQ: cmp = vlen == wlen; break; - case Py_NE: cmp = vlen != wlen; break; - case Py_GT: cmp = vlen > wlen; break; - case Py_GE: cmp = vlen >= wlen; break; - default: return NULL; /* cannot happen */ - } - if (cmp) - res = Py_True; - else - res = Py_False; - Py_INCREF(res); - return res; - } - - /* We have an item that differs -- shortcuts for EQ/NE */ - if (op == Py_EQ) { - Py_INCREF(Py_False); - return Py_False; - } - if (op == Py_NE) { - Py_INCREF(Py_True); - return Py_True; - } - - /* Compare the final item again using the proper operator */ - return PyObject_RichCompare(vt->ob_item[i], wt->ob_item[i], op); -} - -static PyObject * -tuple_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); - -static PyObject * -tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *arg = NULL; - static char *kwlist[] = {"sequence", 0}; - - if (type != &PyTuple_Type) - return tuple_subtype_new(type, args, kwds); - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:tuple", kwlist, &arg)) - return NULL; - - if (arg == NULL) - return PyTuple_New(0); - else - return PySequence_Tuple(arg); -} - -static PyObject * -tuple_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *tmp, *new, *item; - int i, n; - - assert(PyType_IsSubtype(type, &PyTuple_Type)); - tmp = tuple_new(&PyTuple_Type, args, kwds); - if (tmp == NULL) - return NULL; - assert(PyTuple_Check(tmp)); - new = type->tp_alloc(type, n = PyTuple_GET_SIZE(tmp)); - if (new == NULL) - return NULL; - for (i = 0; i < n; i++) { - item = PyTuple_GET_ITEM(tmp, i); - Py_INCREF(item); - PyTuple_SET_ITEM(new, i, item); - } - Py_DECREF(tmp); - return new; -} - -PyDoc_STRVAR(tuple_doc, -"tuple() -> an empty tuple\n" -"tuple(sequence) -> tuple initialized from sequence's items\n" -"\n" -"If the argument is a tuple, the return value is the same object."); - -static PySequenceMethods tuple_as_sequence = { - (inquiry)tuplelength, /* sq_length */ - (binaryfunc)tupleconcat, /* sq_concat */ - (intargfunc)tuplerepeat, /* sq_repeat */ - (intargfunc)tupleitem, /* sq_item */ - (intintargfunc)tupleslice, /* sq_slice */ - 0, /* sq_ass_item */ - 0, /* sq_ass_slice */ - (objobjproc)tuplecontains, /* sq_contains */ -}; - -static PyObject* -tuplesubscript(PyTupleObject* self, PyObject* item) -{ - if (PyInt_Check(item)) { - long i = PyInt_AS_LONG(item); - if (i < 0) - i += PyTuple_GET_SIZE(self); - return tupleitem(self, i); - } - else if (PyLong_Check(item)) { - long i = PyLong_AsLong(item); - if (i == -1 && PyErr_Occurred()) - return NULL; - if (i < 0) - i += PyTuple_GET_SIZE(self); - return tupleitem(self, i); - } - else if (PySlice_Check(item)) { - int start, stop, step, slicelength, cur, i; - PyObject* result; - PyObject* it; - - if (PySlice_GetIndicesEx((PySliceObject*)item, - PyTuple_GET_SIZE(self), - &start, &stop, &step, &slicelength) < 0) { - return NULL; - } - - if (slicelength <= 0) { - return PyTuple_New(0); - } - else { - result = PyTuple_New(slicelength); - - for (cur = start, i = 0; i < slicelength; - cur += step, i++) { - it = PyTuple_GET_ITEM(self, cur); - Py_INCREF(it); - PyTuple_SET_ITEM(result, i, it); - } - - return result; - } - } - else { - PyErr_SetString(PyExc_TypeError, - "tuple indices must be integers"); - return NULL; - } -} - -static PyObject * -tuple_getnewargs(PyTupleObject *v) -{ - return Py_BuildValue("(N)", tupleslice(v, 0, v->ob_size)); - -} - -static PyMethodDef tuple_methods[] = { - {"__getnewargs__", (PyCFunction)tuple_getnewargs, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; - -static PyMappingMethods tuple_as_mapping = { - (inquiry)tuplelength, - (binaryfunc)tuplesubscript, - 0 -}; - -static PyObject *tuple_iter(PyObject *seq); - -PyTypeObject PyTuple_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "tuple", - sizeof(PyTupleObject) - sizeof(PyObject *), - sizeof(PyObject *), - (destructor)tupledealloc, /* tp_dealloc */ - (printfunc)tupleprint, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)tuplerepr, /* tp_repr */ - 0, /* tp_as_number */ - &tuple_as_sequence, /* tp_as_sequence */ - &tuple_as_mapping, /* tp_as_mapping */ - (hashfunc)tuplehash, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - tuple_doc, /* tp_doc */ - (traverseproc)tupletraverse, /* tp_traverse */ - 0, /* tp_clear */ - tuplerichcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - tuple_iter, /* tp_iter */ - 0, /* tp_iternext */ - tuple_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - tuple_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; - -/* The following function breaks the notion that tuples are immutable: - it changes the size of a tuple. We get away with this only if there - is only one module referencing the object. You can also think of it - as creating a new tuple object and destroying the old one, only more - efficiently. In any case, don't use this if the tuple may already be - known to some other part of the code. */ - -int -_PyTuple_Resize(PyObject **pv, int newsize) -{ - register PyTupleObject *v; - register PyTupleObject *sv; - int i; - int oldsize; - - v = (PyTupleObject *) *pv; - if (v == NULL || v->ob_type != &PyTuple_Type || - (v->ob_size != 0 && v->ob_refcnt != 1)) { - *pv = 0; - Py_XDECREF(v); - PyErr_BadInternalCall(); - return -1; - } - oldsize = v->ob_size; - if (oldsize == newsize) - return 0; - - if (oldsize == 0) { - /* Empty tuples are often shared, so we should never - resize them in-place even if we do own the only - (current) reference */ - Py_DECREF(v); - *pv = PyTuple_New(newsize); - return *pv == NULL ? -1 : 0; - } - - /* XXX UNREF/NEWREF interface should be more symmetrical */ - _Py_DEC_REFTOTAL; - _PyObject_GC_UNTRACK(v); - _Py_ForgetReference((PyObject *) v); - /* DECREF items deleted by shrinkage */ - for (i = newsize; i < oldsize; i++) { - Py_XDECREF(v->ob_item[i]); - v->ob_item[i] = NULL; - } - sv = PyObject_GC_Resize(PyTupleObject, v, newsize); - if (sv == NULL) { - *pv = NULL; - PyObject_GC_Del(v); - return -1; - } - _Py_NewReference((PyObject *) sv); - /* Zero out items added by growing */ - if (newsize > oldsize) - memset(&sv->ob_item[oldsize], 0, - sizeof(*sv->ob_item) * (newsize - oldsize)); - *pv = (PyObject *) sv; - _PyObject_GC_TRACK(sv); - return 0; -} - -void -PyTuple_Fini(void) -{ -#if MAXSAVESIZE > 0 - int i; - - Py_XDECREF(free_tuples[0]); - free_tuples[0] = NULL; - - for (i = 1; i < MAXSAVESIZE; i++) { - PyTupleObject *p, *q; - p = free_tuples[i]; - free_tuples[i] = NULL; - while (p) { - q = p; - p = (PyTupleObject *)(p->ob_item[0]); - PyObject_GC_Del(q); - } - } -#endif -} - -/*********************** Tuple Iterator **************************/ - -typedef struct { - PyObject_HEAD - long it_index; - PyTupleObject *it_seq; /* Set to NULL when iterator is exhausted */ -} tupleiterobject; - -PyTypeObject PyTupleIter_Type; - -static PyObject * -tuple_iter(PyObject *seq) -{ - tupleiterobject *it; - - if (!PyTuple_Check(seq)) { - PyErr_BadInternalCall(); - return NULL; - } - it = PyObject_GC_New(tupleiterobject, &PyTupleIter_Type); - if (it == NULL) - return NULL; - it->it_index = 0; - Py_INCREF(seq); - it->it_seq = (PyTupleObject *)seq; - _PyObject_GC_TRACK(it); - return (PyObject *)it; -} - -static void -tupleiter_dealloc(tupleiterobject *it) -{ - _PyObject_GC_UNTRACK(it); - Py_XDECREF(it->it_seq); - PyObject_GC_Del(it); -} - -static int -tupleiter_traverse(tupleiterobject *it, visitproc visit, void *arg) -{ - if (it->it_seq == NULL) - return 0; - return visit((PyObject *)it->it_seq, arg); -} - -static PyObject * -tupleiter_next(tupleiterobject *it) -{ - PyTupleObject *seq; - PyObject *item; - - assert(it != NULL); - seq = it->it_seq; - if (seq == NULL) - return NULL; - assert(PyTuple_Check(seq)); - - if (it->it_index < PyTuple_GET_SIZE(seq)) { - item = PyTuple_GET_ITEM(seq, it->it_index); - ++it->it_index; - Py_INCREF(item); - return item; - } - - Py_DECREF(seq); - it->it_seq = NULL; - return NULL; -} - -PyTypeObject PyTupleIter_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "tupleiterator", /* tp_name */ - sizeof(tupleiterobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)tupleiter_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - 0, /* tp_doc */ - (traverseproc)tupleiter_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - (iternextfunc)tupleiter_next, /* tp_iternext */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/typeobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/typeobject.c deleted file mode 100644 index 3c0e5894..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/typeobject.c +++ /dev/null @@ -1,5707 +0,0 @@ -/* Type object implementation */ - -#include "Python.h" -#include "structmember.h" - -#include - -static PyMemberDef type_members[] = { - {"__basicsize__", T_INT, offsetof(PyTypeObject,tp_basicsize),READONLY}, - {"__itemsize__", T_INT, offsetof(PyTypeObject, tp_itemsize), READONLY}, - {"__flags__", T_LONG, offsetof(PyTypeObject, tp_flags), READONLY}, - {"__weakrefoffset__", T_LONG, - offsetof(PyTypeObject, tp_weaklistoffset), READONLY}, - {"__base__", T_OBJECT, offsetof(PyTypeObject, tp_base), READONLY}, - {"__dictoffset__", T_LONG, - offsetof(PyTypeObject, tp_dictoffset), READONLY}, - {"__mro__", T_OBJECT, offsetof(PyTypeObject, tp_mro), READONLY}, - {0} -}; - -static PyObject * -type_name(PyTypeObject *type, void *context) -{ - char *s; - - if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) { - PyHeapTypeObject* et = (PyHeapTypeObject*)type; - - Py_INCREF(et->name); - return et->name; - } - else { - s = strrchr(type->tp_name, '.'); - if (s == NULL) - s = type->tp_name; - else - s++; - return PyString_FromString(s); - } -} - -static int -type_set_name(PyTypeObject *type, PyObject *value, void *context) -{ - PyHeapTypeObject* et; - - if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) { - PyErr_Format(PyExc_TypeError, - "can't set %s.__name__", type->tp_name); - return -1; - } - if (!value) { - PyErr_Format(PyExc_TypeError, - "can't delete %s.__name__", type->tp_name); - return -1; - } - if (!PyString_Check(value)) { - PyErr_Format(PyExc_TypeError, - "can only assign string to %s.__name__, not '%s'", - type->tp_name, value->ob_type->tp_name); - return -1; - } - if (strlen(PyString_AS_STRING(value)) - != (size_t)PyString_GET_SIZE(value)) { - PyErr_Format(PyExc_ValueError, - "__name__ must not contain null bytes"); - return -1; - } - - et = (PyHeapTypeObject*)type; - - Py_INCREF(value); - - Py_DECREF(et->name); - et->name = value; - - type->tp_name = PyString_AS_STRING(value); - - return 0; -} - -static PyObject * -type_module(PyTypeObject *type, void *context) -{ - PyObject *mod; - char *s; - - if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) { - mod = PyDict_GetItemString(type->tp_dict, "__module__"); - Py_XINCREF(mod); - return mod; - } - else { - s = strrchr(type->tp_name, '.'); - if (s != NULL) - return PyString_FromStringAndSize( - type->tp_name, (int)(s - type->tp_name)); - return PyString_FromString("__builtin__"); - } -} - -static int -type_set_module(PyTypeObject *type, PyObject *value, void *context) -{ - if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) { - PyErr_Format(PyExc_TypeError, - "can't set %s.__module__", type->tp_name); - return -1; - } - if (!value) { - PyErr_Format(PyExc_TypeError, - "can't delete %s.__module__", type->tp_name); - return -1; - } - - return PyDict_SetItemString(type->tp_dict, "__module__", value); -} - -static PyObject * -type_get_bases(PyTypeObject *type, void *context) -{ - Py_INCREF(type->tp_bases); - return type->tp_bases; -} - -static PyTypeObject *best_base(PyObject *); -static int mro_internal(PyTypeObject *); -static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, char *); -static int add_subclass(PyTypeObject*, PyTypeObject*); -static void remove_subclass(PyTypeObject *, PyTypeObject *); -static void update_all_slots(PyTypeObject *); - -typedef int (*update_callback)(PyTypeObject *, void *); -static int update_subclasses(PyTypeObject *type, PyObject *name, - update_callback callback, void *data); -static int recurse_down_subclasses(PyTypeObject *type, PyObject *name, - update_callback callback, void *data); - -static int -mro_subclasses(PyTypeObject *type, PyObject* temp) -{ - PyTypeObject *subclass; - PyObject *ref, *subclasses, *old_mro; - int i, n; - - subclasses = type->tp_subclasses; - if (subclasses == NULL) - return 0; - assert(PyList_Check(subclasses)); - n = PyList_GET_SIZE(subclasses); - for (i = 0; i < n; i++) { - ref = PyList_GET_ITEM(subclasses, i); - assert(PyWeakref_CheckRef(ref)); - subclass = (PyTypeObject *)PyWeakref_GET_OBJECT(ref); - assert(subclass != NULL); - if ((PyObject *)subclass == Py_None) - continue; - assert(PyType_Check(subclass)); - old_mro = subclass->tp_mro; - if (mro_internal(subclass) < 0) { - subclass->tp_mro = old_mro; - return -1; - } - else { - PyObject* tuple; - tuple = Py_BuildValue("OO", subclass, old_mro); - Py_DECREF(old_mro); - if (!tuple) - return -1; - if (PyList_Append(temp, tuple) < 0) - return -1; - Py_DECREF(tuple); - } - if (mro_subclasses(subclass, temp) < 0) - return -1; - } - return 0; -} - -static int -type_set_bases(PyTypeObject *type, PyObject *value, void *context) -{ - int i, r = 0; - PyObject *ob, *temp; - PyTypeObject *new_base, *old_base; - PyObject *old_bases, *old_mro; - - if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) { - PyErr_Format(PyExc_TypeError, - "can't set %s.__bases__", type->tp_name); - return -1; - } - if (!value) { - PyErr_Format(PyExc_TypeError, - "can't delete %s.__bases__", type->tp_name); - return -1; - } - if (!PyTuple_Check(value)) { - PyErr_Format(PyExc_TypeError, - "can only assign tuple to %s.__bases__, not %s", - type->tp_name, value->ob_type->tp_name); - return -1; - } - if (PyTuple_GET_SIZE(value) == 0) { - PyErr_Format(PyExc_TypeError, - "can only assign non-empty tuple to %s.__bases__, not ()", - type->tp_name); - return -1; - } - for (i = 0; i < PyTuple_GET_SIZE(value); i++) { - ob = PyTuple_GET_ITEM(value, i); - if (!PyClass_Check(ob) && !PyType_Check(ob)) { - PyErr_Format( - PyExc_TypeError, - "%s.__bases__ must be tuple of old- or new-style classes, not '%s'", - type->tp_name, ob->ob_type->tp_name); - return -1; - } - if (PyType_Check(ob)) { - if (PyType_IsSubtype((PyTypeObject*)ob, type)) { - PyErr_SetString(PyExc_TypeError, - "a __bases__ item causes an inheritance cycle"); - return -1; - } - } - } - - new_base = best_base(value); - - if (!new_base) { - return -1; - } - - if (!compatible_for_assignment(type->tp_base, new_base, "__bases__")) - return -1; - - Py_INCREF(new_base); - Py_INCREF(value); - - old_bases = type->tp_bases; - old_base = type->tp_base; - old_mro = type->tp_mro; - - type->tp_bases = value; - type->tp_base = new_base; - - if (mro_internal(type) < 0) { - goto bail; - } - - temp = PyList_New(0); - if (!temp) - goto bail; - - r = mro_subclasses(type, temp); - - if (r < 0) { - for (i = 0; i < PyList_Size(temp); i++) { - PyTypeObject* cls; - PyObject* mro; - PyArg_ParseTuple(PyList_GET_ITEM(temp, i), - "OO", &cls, &mro); - Py_DECREF(cls->tp_mro); - cls->tp_mro = mro; - Py_INCREF(cls->tp_mro); - } - Py_DECREF(temp); - goto bail; - } - - Py_DECREF(temp); - - /* any base that was in __bases__ but now isn't, we - need to remove |type| from its tp_subclasses. - conversely, any class now in __bases__ that wasn't - needs to have |type| added to its subclasses. */ - - /* for now, sod that: just remove from all old_bases, - add to all new_bases */ - - for (i = PyTuple_GET_SIZE(old_bases) - 1; i >= 0; i--) { - ob = PyTuple_GET_ITEM(old_bases, i); - if (PyType_Check(ob)) { - remove_subclass( - (PyTypeObject*)ob, type); - } - } - - for (i = PyTuple_GET_SIZE(value) - 1; i >= 0; i--) { - ob = PyTuple_GET_ITEM(value, i); - if (PyType_Check(ob)) { - if (add_subclass((PyTypeObject*)ob, type) < 0) - r = -1; - } - } - - update_all_slots(type); - - Py_DECREF(old_bases); - Py_DECREF(old_base); - Py_DECREF(old_mro); - - return r; - - bail: - Py_DECREF(type->tp_bases); - Py_DECREF(type->tp_base); - if (type->tp_mro != old_mro) { - Py_DECREF(type->tp_mro); - } - - type->tp_bases = old_bases; - type->tp_base = old_base; - type->tp_mro = old_mro; - - return -1; -} - -static PyObject * -type_dict(PyTypeObject *type, void *context) -{ - if (type->tp_dict == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyDictProxy_New(type->tp_dict); -} - -static PyObject * -type_get_doc(PyTypeObject *type, void *context) -{ - PyObject *result; - if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE) && type->tp_doc != NULL) - return PyString_FromString(type->tp_doc); - result = PyDict_GetItemString(type->tp_dict, "__doc__"); - if (result == NULL) { - result = Py_None; - Py_INCREF(result); - } - else if (result->ob_type->tp_descr_get) { - result = result->ob_type->tp_descr_get(result, NULL, - (PyObject *)type); - } - else { - Py_INCREF(result); - } - return result; -} - -static PyGetSetDef type_getsets[] = { - {"__name__", (getter)type_name, (setter)type_set_name, NULL}, - {"__bases__", (getter)type_get_bases, (setter)type_set_bases, NULL}, - {"__module__", (getter)type_module, (setter)type_set_module, NULL}, - {"__dict__", (getter)type_dict, NULL, NULL}, - {"__doc__", (getter)type_get_doc, NULL, NULL}, - {0} -}; - -static int -type_compare(PyObject *v, PyObject *w) -{ - /* This is called with type objects only. So we - can just compare the addresses. */ - Py_uintptr_t vv = (Py_uintptr_t)v; - Py_uintptr_t ww = (Py_uintptr_t)w; - return (vv < ww) ? -1 : (vv > ww) ? 1 : 0; -} - -static PyObject * -type_repr(PyTypeObject *type) -{ - PyObject *mod, *name, *rtn; - char *kind; - - mod = type_module(type, NULL); - if (mod == NULL) - PyErr_Clear(); - else if (!PyString_Check(mod)) { - Py_DECREF(mod); - mod = NULL; - } - name = type_name(type, NULL); - if (name == NULL) - return NULL; - - if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) - kind = "class"; - else - kind = "type"; - - if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__")) { - rtn = PyString_FromFormat("<%s '%s.%s'>", - kind, - PyString_AS_STRING(mod), - PyString_AS_STRING(name)); - } - else - rtn = PyString_FromFormat("<%s '%s'>", kind, type->tp_name); - - Py_XDECREF(mod); - Py_DECREF(name); - return rtn; -} - -static PyObject * -type_call(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *obj; - - if (type->tp_new == NULL) { - PyErr_Format(PyExc_TypeError, - "cannot create '%.100s' instances", - type->tp_name); - return NULL; - } - - obj = type->tp_new(type, args, kwds); - if (obj != NULL) { - /* Ugly exception: when the call was type(something), - don't call tp_init on the result. */ - if (type == &PyType_Type && - PyTuple_Check(args) && PyTuple_GET_SIZE(args) == 1 && - (kwds == NULL || - (PyDict_Check(kwds) && PyDict_Size(kwds) == 0))) - return obj; - /* If the returned object is not an instance of type, - it won't be initialized. */ - if (!PyType_IsSubtype(obj->ob_type, type)) - return obj; - type = obj->ob_type; - if (PyType_HasFeature(type, Py_TPFLAGS_HAVE_CLASS) && - type->tp_init != NULL && - type->tp_init(obj, args, kwds) < 0) { - Py_DECREF(obj); - obj = NULL; - } - } - return obj; -} - -PyObject * -PyType_GenericAlloc(PyTypeObject *type, int nitems) -{ - PyObject *obj; - const size_t size = _PyObject_VAR_SIZE(type, nitems+1); - /* note that we need to add one, for the sentinel */ - - if (PyType_IS_GC(type)) - obj = _PyObject_GC_Malloc(size); - else - obj = PyObject_MALLOC(size); - - if (obj == NULL) - return PyErr_NoMemory(); - - memset(obj, '\0', size); - - if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) - Py_INCREF(type); - - if (type->tp_itemsize == 0) - PyObject_INIT(obj, type); - else - (void) PyObject_INIT_VAR((PyVarObject *)obj, type, nitems); - - if (PyType_IS_GC(type)) - _PyObject_GC_TRACK(obj); - return obj; -} - -PyObject * -PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - return type->tp_alloc(type, 0); -} - -/* Helpers for subtyping */ - -static int -traverse_slots(PyTypeObject *type, PyObject *self, visitproc visit, void *arg) -{ - int i, n; - PyMemberDef *mp; - - n = type->ob_size; - mp = PyHeapType_GET_MEMBERS((PyHeapTypeObject *)type); - for (i = 0; i < n; i++, mp++) { - if (mp->type == T_OBJECT_EX) { - char *addr = (char *)self + mp->offset; - PyObject *obj = *(PyObject **)addr; - if (obj != NULL) { - int err = visit(obj, arg); - if (err) - return err; - } - } - } - return 0; -} - -static int -subtype_traverse(PyObject *self, visitproc visit, void *arg) -{ - PyTypeObject *type, *base; - traverseproc basetraverse; - - /* Find the nearest base with a different tp_traverse, - and traverse slots while we're at it */ - type = self->ob_type; - base = type; - while ((basetraverse = base->tp_traverse) == subtype_traverse) { - if (base->ob_size) { - int err = traverse_slots(base, self, visit, arg); - if (err) - return err; - } - base = base->tp_base; - assert(base); - } - - if (type->tp_dictoffset != base->tp_dictoffset) { - PyObject **dictptr = _PyObject_GetDictPtr(self); - if (dictptr && *dictptr) { - int err = visit(*dictptr, arg); - if (err) - return err; - } - } - - if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) { - /* For a heaptype, the instances count as references - to the type. Traverse the type so the collector - can find cycles involving this link. */ - int err = visit((PyObject *)type, arg); - if (err) - return err; - } - - if (basetraverse) - return basetraverse(self, visit, arg); - return 0; -} - -static void -clear_slots(PyTypeObject *type, PyObject *self) -{ - int i, n; - PyMemberDef *mp; - - n = type->ob_size; - mp = PyHeapType_GET_MEMBERS((PyHeapTypeObject *)type); - for (i = 0; i < n; i++, mp++) { - if (mp->type == T_OBJECT_EX && !(mp->flags & READONLY)) { - char *addr = (char *)self + mp->offset; - PyObject *obj = *(PyObject **)addr; - if (obj != NULL) { - Py_DECREF(obj); - *(PyObject **)addr = NULL; - } - } - } -} - -static int -subtype_clear(PyObject *self) -{ - PyTypeObject *type, *base; - inquiry baseclear; - - /* Find the nearest base with a different tp_clear - and clear slots while we're at it */ - type = self->ob_type; - base = type; - while ((baseclear = base->tp_clear) == subtype_clear) { - if (base->ob_size) - clear_slots(base, self); - base = base->tp_base; - assert(base); - } - - /* There's no need to clear the instance dict (if any); - the collector will call its tp_clear handler. */ - - if (baseclear) - return baseclear(self); - return 0; -} - -static void -subtype_dealloc(PyObject *self) -{ - PyTypeObject *type, *base; - destructor basedealloc; - - /* Extract the type; we expect it to be a heap type */ - type = self->ob_type; - assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE); - - /* Test whether the type has GC exactly once */ - - if (!PyType_IS_GC(type)) { - /* It's really rare to find a dynamic type that doesn't have - GC; it can only happen when deriving from 'object' and not - adding any slots or instance variables. This allows - certain simplifications: there's no need to call - clear_slots(), or DECREF the dict, or clear weakrefs. */ - - /* Maybe call finalizer; exit early if resurrected */ - if (type->tp_del) { - type->tp_del(self); - if (self->ob_refcnt > 0) - return; - } - - /* Find the nearest base with a different tp_dealloc */ - base = type; - while ((basedealloc = base->tp_dealloc) == subtype_dealloc) { - assert(base->ob_size == 0); - base = base->tp_base; - assert(base); - } - - /* Call the base tp_dealloc() */ - assert(basedealloc); - basedealloc(self); - - /* Can't reference self beyond this point */ - Py_DECREF(type); - - /* Done */ - return; - } - - /* We get here only if the type has GC */ - - /* UnTrack and re-Track around the trashcan macro, alas */ - /* See explanation at end of function for full disclosure */ - PyObject_GC_UnTrack(self); - ++_PyTrash_delete_nesting; - Py_TRASHCAN_SAFE_BEGIN(self); - --_PyTrash_delete_nesting; - /* DO NOT restore GC tracking at this point. weakref callbacks - * (if any, and whether directly here or indirectly in something we - * call) may trigger GC, and if self is tracked at that point, it - * will look like trash to GC and GC will try to delete self again. - */ - - /* Find the nearest base with a different tp_dealloc */ - base = type; - while ((basedealloc = base->tp_dealloc) == subtype_dealloc) { - base = base->tp_base; - assert(base); - } - - /* If we added a weaklist, we clear it. Do this *before* calling - the finalizer (__del__), clearing slots, or clearing the instance - dict. */ - - if (type->tp_weaklistoffset && !base->tp_weaklistoffset) - PyObject_ClearWeakRefs(self); - - /* Maybe call finalizer; exit early if resurrected */ - if (type->tp_del) { - _PyObject_GC_TRACK(self); - type->tp_del(self); - if (self->ob_refcnt > 0) - goto endlabel; /* resurrected */ - else - _PyObject_GC_UNTRACK(self); - } - - /* Clear slots up to the nearest base with a different tp_dealloc */ - base = type; - while ((basedealloc = base->tp_dealloc) == subtype_dealloc) { - if (base->ob_size) - clear_slots(base, self); - base = base->tp_base; - assert(base); - } - - /* If we added a dict, DECREF it */ - if (type->tp_dictoffset && !base->tp_dictoffset) { - PyObject **dictptr = _PyObject_GetDictPtr(self); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict != NULL) { - Py_DECREF(dict); - *dictptr = NULL; - } - } - } - - /* Call the base tp_dealloc(); first retrack self if - * basedealloc knows about gc. - */ - if (PyType_IS_GC(base)) - _PyObject_GC_TRACK(self); - assert(basedealloc); - basedealloc(self); - - /* Can't reference self beyond this point */ - Py_DECREF(type); - - endlabel: - ++_PyTrash_delete_nesting; - Py_TRASHCAN_SAFE_END(self); - --_PyTrash_delete_nesting; - - /* Explanation of the weirdness around the trashcan macros: - - Q. What do the trashcan macros do? - - A. Read the comment titled "Trashcan mechanism" in object.h. - For one, this explains why there must be a call to GC-untrack - before the trashcan begin macro. Without understanding the - trashcan code, the answers to the following questions don't make - sense. - - Q. Why do we GC-untrack before the trashcan and then immediately - GC-track again afterward? - - A. In the case that the base class is GC-aware, the base class - probably GC-untracks the object. If it does that using the - UNTRACK macro, this will crash when the object is already - untracked. Because we don't know what the base class does, the - only safe thing is to make sure the object is tracked when we - call the base class dealloc. But... The trashcan begin macro - requires that the object is *untracked* before it is called. So - the dance becomes: - - GC untrack - trashcan begin - GC track - - Q. Why did the last question say "immediately GC-track again"? - It's nowhere near immediately. - - A. Because the code *used* to re-track immediately. Bad Idea. - self has a refcount of 0, and if gc ever gets its hands on it - (which can happen if any weakref callback gets invoked), it - looks like trash to gc too, and gc also tries to delete self - then. But we're already deleting self. Double dealloction is - a subtle disaster. - - Q. Why the bizarre (net-zero) manipulation of - _PyTrash_delete_nesting around the trashcan macros? - - A. Some base classes (e.g. list) also use the trashcan mechanism. - The following scenario used to be possible: - - - suppose the trashcan level is one below the trashcan limit - - - subtype_dealloc() is called - - - the trashcan limit is not yet reached, so the trashcan level - is incremented and the code between trashcan begin and end is - executed - - - this destroys much of the object's contents, including its - slots and __dict__ - - - basedealloc() is called; this is really list_dealloc(), or - some other type which also uses the trashcan macros - - - the trashcan limit is now reached, so the object is put on the - trashcan's to-be-deleted-later list - - - basedealloc() returns - - - subtype_dealloc() decrefs the object's type - - - subtype_dealloc() returns - - - later, the trashcan code starts deleting the objects from its - to-be-deleted-later list - - - subtype_dealloc() is called *AGAIN* for the same object - - - at the very least (if the destroyed slots and __dict__ don't - cause problems) the object's type gets decref'ed a second - time, which is *BAD*!!! - - The remedy is to make sure that if the code between trashcan - begin and end in subtype_dealloc() is called, the code between - trashcan begin and end in basedealloc() will also be called. - This is done by decrementing the level after passing into the - trashcan block, and incrementing it just before leaving the - block. - - But now it's possible that a chain of objects consisting solely - of objects whose deallocator is subtype_dealloc() will defeat - the trashcan mechanism completely: the decremented level means - that the effective level never reaches the limit. Therefore, we - *increment* the level *before* entering the trashcan block, and - matchingly decrement it after leaving. This means the trashcan - code will trigger a little early, but that's no big deal. - - Q. Are there any live examples of code in need of all this - complexity? - - A. Yes. See SF bug 668433 for code that crashed (when Python was - compiled in debug mode) before the trashcan level manipulations - were added. For more discussion, see SF patches 581742, 575073 - and bug 574207. - */ -} - -static PyTypeObject *solid_base(PyTypeObject *type); - -/* type test with subclassing support */ - -int -PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b) -{ - PyObject *mro; - - if (!(a->tp_flags & Py_TPFLAGS_HAVE_CLASS)) - return b == a || b == &PyBaseObject_Type; - - mro = a->tp_mro; - if (mro != NULL) { - /* Deal with multiple inheritance without recursion - by walking the MRO tuple */ - int i, n; - assert(PyTuple_Check(mro)); - n = PyTuple_GET_SIZE(mro); - for (i = 0; i < n; i++) { - if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) - return 1; - } - return 0; - } - else { - /* a is not completely initilized yet; follow tp_base */ - do { - if (a == b) - return 1; - a = a->tp_base; - } while (a != NULL); - return b == &PyBaseObject_Type; - } -} - -/* Internal routines to do a method lookup in the type - without looking in the instance dictionary - (so we can't use PyObject_GetAttr) but still binding - it to the instance. The arguments are the object, - the method name as a C string, and the address of a - static variable used to cache the interned Python string. - - Two variants: - - - lookup_maybe() returns NULL without raising an exception - when the _PyType_Lookup() call fails; - - - lookup_method() always raises an exception upon errors. -*/ - -static PyObject * -lookup_maybe(PyObject *self, char *attrstr, PyObject **attrobj) -{ - PyObject *res; - - if (*attrobj == NULL) { - *attrobj = PyString_InternFromString(attrstr); - if (*attrobj == NULL) - return NULL; - } - res = _PyType_Lookup(self->ob_type, *attrobj); - if (res != NULL) { - descrgetfunc f; - if ((f = res->ob_type->tp_descr_get) == NULL) - Py_INCREF(res); - else - res = f(res, self, (PyObject *)(self->ob_type)); - } - return res; -} - -static PyObject * -lookup_method(PyObject *self, char *attrstr, PyObject **attrobj) -{ - PyObject *res = lookup_maybe(self, attrstr, attrobj); - if (res == NULL && !PyErr_Occurred()) - PyErr_SetObject(PyExc_AttributeError, *attrobj); - return res; -} - -/* A variation of PyObject_CallMethod that uses lookup_method() - instead of PyObject_GetAttrString(). This uses the same convention - as lookup_method to cache the interned name string object. */ - -static PyObject * -call_method(PyObject *o, char *name, PyObject **nameobj, char *format, ...) -{ - va_list va; - PyObject *args, *func = 0, *retval; - va_start(va, format); - - func = lookup_maybe(o, name, nameobj); - if (func == NULL) { - va_end(va); - if (!PyErr_Occurred()) - PyErr_SetObject(PyExc_AttributeError, *nameobj); - return NULL; - } - - if (format && *format) - args = Py_VaBuildValue(format, va); - else - args = PyTuple_New(0); - - va_end(va); - - if (args == NULL) - return NULL; - - assert(PyTuple_Check(args)); - retval = PyObject_Call(func, args, NULL); - - Py_DECREF(args); - Py_DECREF(func); - - return retval; -} - -/* Clone of call_method() that returns NotImplemented when the lookup fails. */ - -static PyObject * -call_maybe(PyObject *o, char *name, PyObject **nameobj, char *format, ...) -{ - va_list va; - PyObject *args, *func = 0, *retval; - va_start(va, format); - - func = lookup_maybe(o, name, nameobj); - if (func == NULL) { - va_end(va); - if (!PyErr_Occurred()) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - return NULL; - } - - if (format && *format) - args = Py_VaBuildValue(format, va); - else - args = PyTuple_New(0); - - va_end(va); - - if (args == NULL) - return NULL; - - assert(PyTuple_Check(args)); - retval = PyObject_Call(func, args, NULL); - - Py_DECREF(args); - Py_DECREF(func); - - return retval; -} - -static int -fill_classic_mro(PyObject *mro, PyObject *cls) -{ - PyObject *bases, *base; - int i, n; - - assert(PyList_Check(mro)); - assert(PyClass_Check(cls)); - i = PySequence_Contains(mro, cls); - if (i < 0) - return -1; - if (!i) { - if (PyList_Append(mro, cls) < 0) - return -1; - } - bases = ((PyClassObject *)cls)->cl_bases; - assert(bases && PyTuple_Check(bases)); - n = PyTuple_GET_SIZE(bases); - for (i = 0; i < n; i++) { - base = PyTuple_GET_ITEM(bases, i); - if (fill_classic_mro(mro, base) < 0) - return -1; - } - return 0; -} - -static PyObject * -classic_mro(PyObject *cls) -{ - PyObject *mro; - - assert(PyClass_Check(cls)); - mro = PyList_New(0); - if (mro != NULL) { - if (fill_classic_mro(mro, cls) == 0) - return mro; - Py_DECREF(mro); - } - return NULL; -} - -/* - Method resolution order algorithm C3 described in - "A Monotonic Superclass Linearization for Dylan", - by Kim Barrett, Bob Cassel, Paul Haahr, - David A. Moon, Keith Playford, and P. Tucker Withington. - (OOPSLA 1996) - - Some notes about the rules implied by C3: - - No duplicate bases. - It isn't legal to repeat a class in a list of base classes. - - The next three properties are the 3 constraints in "C3". - - Local precendece order. - If A precedes B in C's MRO, then A will precede B in the MRO of all - subclasses of C. - - Monotonicity. - The MRO of a class must be an extension without reordering of the - MRO of each of its superclasses. - - Extended Precedence Graph (EPG). - Linearization is consistent if there is a path in the EPG from - each class to all its successors in the linearization. See - the paper for definition of EPG. - */ - -static int -tail_contains(PyObject *list, int whence, PyObject *o) { - int j, size; - size = PyList_GET_SIZE(list); - - for (j = whence+1; j < size; j++) { - if (PyList_GET_ITEM(list, j) == o) - return 1; - } - return 0; -} - -static PyObject * -class_name(PyObject *cls) -{ - PyObject *name = PyObject_GetAttrString(cls, "__name__"); - if (name == NULL) { - PyErr_Clear(); - Py_XDECREF(name); - name = PyObject_Repr(cls); - } - if (name == NULL) - return NULL; - if (!PyString_Check(name)) { - Py_DECREF(name); - return NULL; - } - return name; -} - -static int -check_duplicates(PyObject *list) -{ - int i, j, n; - /* Let's use a quadratic time algorithm, - assuming that the bases lists is short. - */ - n = PyList_GET_SIZE(list); - for (i = 0; i < n; i++) { - PyObject *o = PyList_GET_ITEM(list, i); - for (j = i + 1; j < n; j++) { - if (PyList_GET_ITEM(list, j) == o) { - o = class_name(o); - PyErr_Format(PyExc_TypeError, - "duplicate base class %s", - o ? PyString_AS_STRING(o) : "?"); - Py_XDECREF(o); - return -1; - } - } - } - return 0; -} - -/* Raise a TypeError for an MRO order disagreement. - - It's hard to produce a good error message. In the absence of better - insight into error reporting, report the classes that were candidates - to be put next into the MRO. There is some conflict between the - order in which they should be put in the MRO, but it's hard to - diagnose what constraint can't be satisfied. -*/ - -static void -set_mro_error(PyObject *to_merge, int *remain) -{ - int i, n, off, to_merge_size; - char buf[1000]; - PyObject *k, *v; - PyObject *set = PyDict_New(); - - to_merge_size = PyList_GET_SIZE(to_merge); - for (i = 0; i < to_merge_size; i++) { - PyObject *L = PyList_GET_ITEM(to_merge, i); - if (remain[i] < PyList_GET_SIZE(L)) { - PyObject *c = PyList_GET_ITEM(L, remain[i]); - if (PyDict_SetItem(set, c, Py_None) < 0) - return; - } - } - n = PyDict_Size(set); - - off = PyOS_snprintf(buf, sizeof(buf), "Cannot create a \ -consistent method resolution\norder (MRO) for bases"); - i = 0; - while (PyDict_Next(set, &i, &k, &v) && off < sizeof(buf)) { - PyObject *name = class_name(k); - off += PyOS_snprintf(buf + off, sizeof(buf) - off, " %s", - name ? PyString_AS_STRING(name) : "?"); - Py_XDECREF(name); - if (--n && off+1 < sizeof(buf)) { - buf[off++] = ','; - buf[off] = '\0'; - } - } - PyErr_SetString(PyExc_TypeError, buf); - Py_DECREF(set); -} - -static int -pmerge(PyObject *acc, PyObject* to_merge) { - int i, j, to_merge_size; - int *remain; - int ok, empty_cnt; - - to_merge_size = PyList_GET_SIZE(to_merge); - - /* remain stores an index into each sublist of to_merge. - remain[i] is the index of the next base in to_merge[i] - that is not included in acc. - */ - remain = PyMem_MALLOC(SIZEOF_INT*to_merge_size); - if (remain == NULL) - return -1; - for (i = 0; i < to_merge_size; i++) - remain[i] = 0; - - again: - empty_cnt = 0; - for (i = 0; i < to_merge_size; i++) { - PyObject *candidate; - - PyObject *cur_list = PyList_GET_ITEM(to_merge, i); - - if (remain[i] >= PyList_GET_SIZE(cur_list)) { - empty_cnt++; - continue; - } - - /* Choose next candidate for MRO. - - The input sequences alone can determine the choice. - If not, choose the class which appears in the MRO - of the earliest direct superclass of the new class. - */ - - candidate = PyList_GET_ITEM(cur_list, remain[i]); - for (j = 0; j < to_merge_size; j++) { - PyObject *j_lst = PyList_GET_ITEM(to_merge, j); - if (tail_contains(j_lst, remain[j], candidate)) { - goto skip; /* continue outer loop */ - } - } - ok = PyList_Append(acc, candidate); - if (ok < 0) { - PyMem_Free(remain); - return -1; - } - for (j = 0; j < to_merge_size; j++) { - PyObject *j_lst = PyList_GET_ITEM(to_merge, j); - if (remain[j] < PyList_GET_SIZE(j_lst) && - PyList_GET_ITEM(j_lst, remain[j]) == candidate) { - remain[j]++; - } - } - goto again; - skip: ; - } - - if (empty_cnt == to_merge_size) { - PyMem_FREE(remain); - return 0; - } - set_mro_error(to_merge, remain); - PyMem_FREE(remain); - return -1; -} - -static PyObject * -mro_implementation(PyTypeObject *type) -{ - int i, n, ok; - PyObject *bases, *result; - PyObject *to_merge, *bases_aslist; - - if(type->tp_dict == NULL) { - if(PyType_Ready(type) < 0) - return NULL; - } - - /* Find a superclass linearization that honors the constraints - of the explicit lists of bases and the constraints implied by - each base class. - - to_merge is a list of lists, where each list is a superclass - linearization implied by a base class. The last element of - to_merge is the declared list of bases. - */ - - bases = type->tp_bases; - n = PyTuple_GET_SIZE(bases); - - to_merge = PyList_New(n+1); - if (to_merge == NULL) - return NULL; - - for (i = 0; i < n; i++) { - PyObject *base = PyTuple_GET_ITEM(bases, i); - PyObject *parentMRO; - if (PyType_Check(base)) - parentMRO = PySequence_List( - ((PyTypeObject*)base)->tp_mro); - else - parentMRO = classic_mro(base); - if (parentMRO == NULL) { - Py_DECREF(to_merge); - return NULL; - } - - PyList_SET_ITEM(to_merge, i, parentMRO); - } - - bases_aslist = PySequence_List(bases); - if (bases_aslist == NULL) { - Py_DECREF(to_merge); - return NULL; - } - /* This is just a basic sanity check. */ - if (check_duplicates(bases_aslist) < 0) { - Py_DECREF(to_merge); - Py_DECREF(bases_aslist); - return NULL; - } - PyList_SET_ITEM(to_merge, n, bases_aslist); - - result = Py_BuildValue("[O]", (PyObject *)type); - if (result == NULL) { - Py_DECREF(to_merge); - return NULL; - } - - ok = pmerge(result, to_merge); - Py_DECREF(to_merge); - if (ok < 0) { - Py_DECREF(result); - return NULL; - } - - return result; -} - -static PyObject * -mro_external(PyObject *self) -{ - PyTypeObject *type = (PyTypeObject *)self; - - return mro_implementation(type); -} - -static int -mro_internal(PyTypeObject *type) -{ - PyObject *mro, *result, *tuple; - - if (type->ob_type == &PyType_Type) { - result = mro_implementation(type); - } - else { - static PyObject *mro_str; - mro = lookup_method((PyObject *)type, "mro", &mro_str); - if (mro == NULL) - return -1; - result = PyObject_CallObject(mro, NULL); - Py_DECREF(mro); - } - if (result == NULL) - return -1; - tuple = PySequence_Tuple(result); - Py_DECREF(result); - type->tp_mro = tuple; - return 0; -} - - -/* Calculate the best base amongst multiple base classes. - This is the first one that's on the path to the "solid base". */ - -static PyTypeObject * -best_base(PyObject *bases) -{ - int i, n; - PyTypeObject *base, *winner, *candidate, *base_i; - PyObject *base_proto; - - assert(PyTuple_Check(bases)); - n = PyTuple_GET_SIZE(bases); - assert(n > 0); - base = NULL; - winner = NULL; - for (i = 0; i < n; i++) { - base_proto = PyTuple_GET_ITEM(bases, i); - if (PyClass_Check(base_proto)) - continue; - if (!PyType_Check(base_proto)) { - PyErr_SetString( - PyExc_TypeError, - "bases must be types"); - return NULL; - } - base_i = (PyTypeObject *)base_proto; - if (base_i->tp_dict == NULL) { - if (PyType_Ready(base_i) < 0) - return NULL; - } - candidate = solid_base(base_i); - if (winner == NULL) { - winner = candidate; - base = base_i; - } - else if (PyType_IsSubtype(winner, candidate)) - ; - else if (PyType_IsSubtype(candidate, winner)) { - winner = candidate; - base = base_i; - } - else { - PyErr_SetString( - PyExc_TypeError, - "multiple bases have " - "instance lay-out conflict"); - return NULL; - } - } - if (base == NULL) - PyErr_SetString(PyExc_TypeError, - "a new-style class can't have only classic bases"); - return base; -} - -static int -extra_ivars(PyTypeObject *type, PyTypeObject *base) -{ - size_t t_size = type->tp_basicsize; - size_t b_size = base->tp_basicsize; - - assert(t_size >= b_size); /* Else type smaller than base! */ - if (type->tp_itemsize || base->tp_itemsize) { - /* If itemsize is involved, stricter rules */ - return t_size != b_size || - type->tp_itemsize != base->tp_itemsize; - } - if (type->tp_weaklistoffset && base->tp_weaklistoffset == 0 && - type->tp_weaklistoffset + sizeof(PyObject *) == t_size) - t_size -= sizeof(PyObject *); - if (type->tp_dictoffset && base->tp_dictoffset == 0 && - type->tp_dictoffset + sizeof(PyObject *) == t_size) - t_size -= sizeof(PyObject *); - - return t_size != b_size; -} - -static PyTypeObject * -solid_base(PyTypeObject *type) -{ - PyTypeObject *base; - - if (type->tp_base) - base = solid_base(type->tp_base); - else - base = &PyBaseObject_Type; - if (extra_ivars(type, base)) - return type; - else - return base; -} - -static void object_dealloc(PyObject *); -static int object_init(PyObject *, PyObject *, PyObject *); -static int update_slot(PyTypeObject *, PyObject *); -static void fixup_slot_dispatchers(PyTypeObject *); - -static PyObject * -subtype_dict(PyObject *obj, void *context) -{ - PyObject **dictptr = _PyObject_GetDictPtr(obj); - PyObject *dict; - - if (dictptr == NULL) { - PyErr_SetString(PyExc_AttributeError, - "This object has no __dict__"); - return NULL; - } - dict = *dictptr; - if (dict == NULL) - *dictptr = dict = PyDict_New(); - Py_XINCREF(dict); - return dict; -} - -static int -subtype_setdict(PyObject *obj, PyObject *value, void *context) -{ - PyObject **dictptr = _PyObject_GetDictPtr(obj); - PyObject *dict; - - if (dictptr == NULL) { - PyErr_SetString(PyExc_AttributeError, - "This object has no __dict__"); - return -1; - } - if (value != NULL && !PyDict_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "__dict__ must be set to a dictionary"); - return -1; - } - dict = *dictptr; - Py_XINCREF(value); - *dictptr = value; - Py_XDECREF(dict); - return 0; -} - -static PyObject * -subtype_getweakref(PyObject *obj, void *context) -{ - PyObject **weaklistptr; - PyObject *result; - - if (obj->ob_type->tp_weaklistoffset == 0) { - PyErr_SetString(PyExc_AttributeError, - "This object has no __weaklist__"); - return NULL; - } - assert(obj->ob_type->tp_weaklistoffset > 0); - assert(obj->ob_type->tp_weaklistoffset + sizeof(PyObject *) <= - (size_t)(obj->ob_type->tp_basicsize)); - weaklistptr = (PyObject **) - ((char *)obj + obj->ob_type->tp_weaklistoffset); - if (*weaklistptr == NULL) - result = Py_None; - else - result = *weaklistptr; - Py_INCREF(result); - return result; -} - -/* Three variants on the subtype_getsets list. */ - -static PyGetSetDef subtype_getsets_full[] = { - {"__dict__", subtype_dict, subtype_setdict, - PyDoc_STR("dictionary for instance variables (if defined)")}, - {"__weakref__", subtype_getweakref, NULL, - PyDoc_STR("list of weak references to the object (if defined)")}, - {0} -}; - -static PyGetSetDef subtype_getsets_dict_only[] = { - {"__dict__", subtype_dict, subtype_setdict, - PyDoc_STR("dictionary for instance variables (if defined)")}, - {0} -}; - -static PyGetSetDef subtype_getsets_weakref_only[] = { - {"__weakref__", subtype_getweakref, NULL, - PyDoc_STR("list of weak references to the object (if defined)")}, - {0} -}; - -static int -valid_identifier(PyObject *s) -{ - unsigned char *p; - int i, n; - - if (!PyString_Check(s)) { - PyErr_SetString(PyExc_TypeError, - "__slots__ must be strings"); - return 0; - } - p = (unsigned char *) PyString_AS_STRING(s); - n = PyString_GET_SIZE(s); - /* We must reject an empty name. As a hack, we bump the - length to 1 so that the loop will balk on the trailing \0. */ - if (n == 0) - n = 1; - for (i = 0; i < n; i++, p++) { - if (!(i == 0 ? isalpha(*p) : isalnum(*p)) && *p != '_') { - PyErr_SetString(PyExc_TypeError, - "__slots__ must be identifiers"); - return 0; - } - } - return 1; -} - -#ifdef Py_USING_UNICODE -/* Replace Unicode objects in slots. */ - -static PyObject * -_unicode_to_string(PyObject *slots, int nslots) -{ - PyObject *tmp = slots; - PyObject *o, *o1; - int i; - intintargfunc copy = slots->ob_type->tp_as_sequence->sq_slice; - for (i = 0; i < nslots; i++) { - if (PyUnicode_Check(o = PyTuple_GET_ITEM(tmp, i))) { - if (tmp == slots) { - tmp = copy(slots, 0, PyTuple_GET_SIZE(slots)); - if (tmp == NULL) - return NULL; - } - o1 = _PyUnicode_AsDefaultEncodedString - (o, NULL); - if (o1 == NULL) { - Py_DECREF(tmp); - return 0; - } - Py_INCREF(o1); - Py_DECREF(o); - PyTuple_SET_ITEM(tmp, i, o1); - } - } - return tmp; -} -#endif - -static PyObject * -type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) -{ - PyObject *name, *bases, *dict; - static char *kwlist[] = {"name", "bases", "dict", 0}; - PyObject *slots, *tmp, *newslots; - PyTypeObject *type, *base, *tmptype, *winner; - PyHeapTypeObject *et; - PyMemberDef *mp; - int i, nbases, nslots, slotoffset, add_dict, add_weak; - int j, may_add_dict, may_add_weak; - - assert(args != NULL && PyTuple_Check(args)); - assert(kwds == NULL || PyDict_Check(kwds)); - - /* Special case: type(x) should return x->ob_type */ - { - const int nargs = PyTuple_GET_SIZE(args); - const int nkwds = kwds == NULL ? 0 : PyDict_Size(kwds); - - if (PyType_CheckExact(metatype) && nargs == 1 && nkwds == 0) { - PyObject *x = PyTuple_GET_ITEM(args, 0); - Py_INCREF(x->ob_type); - return (PyObject *) x->ob_type; - } - - /* SF bug 475327 -- if that didn't trigger, we need 3 - arguments. but PyArg_ParseTupleAndKeywords below may give - a msg saying type() needs exactly 3. */ - if (nargs + nkwds != 3) { - PyErr_SetString(PyExc_TypeError, - "type() takes 1 or 3 arguments"); - return NULL; - } - } - - /* Check arguments: (name, bases, dict) */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "SO!O!:type", kwlist, - &name, - &PyTuple_Type, &bases, - &PyDict_Type, &dict)) - return NULL; - - /* Determine the proper metatype to deal with this, - and check for metatype conflicts while we're at it. - Note that if some other metatype wins to contract, - it's possible that its instances are not types. */ - nbases = PyTuple_GET_SIZE(bases); - winner = metatype; - for (i = 0; i < nbases; i++) { - tmp = PyTuple_GET_ITEM(bases, i); - tmptype = tmp->ob_type; - if (tmptype == &PyClass_Type) - continue; /* Special case classic classes */ - if (PyType_IsSubtype(winner, tmptype)) - continue; - if (PyType_IsSubtype(tmptype, winner)) { - winner = tmptype; - continue; - } - PyErr_SetString(PyExc_TypeError, - "metaclass conflict: " - "the metaclass of a derived class " - "must be a (non-strict) subclass " - "of the metaclasses of all its bases"); - return NULL; - } - if (winner != metatype) { - if (winner->tp_new != type_new) /* Pass it to the winner */ - return winner->tp_new(winner, args, kwds); - metatype = winner; - } - - /* Adjust for empty tuple bases */ - if (nbases == 0) { - bases = Py_BuildValue("(O)", &PyBaseObject_Type); - if (bases == NULL) - return NULL; - nbases = 1; - } - else - Py_INCREF(bases); - - /* XXX From here until type is allocated, "return NULL" leaks bases! */ - - /* Calculate best base, and check that all bases are type objects */ - base = best_base(bases); - if (base == NULL) - return NULL; - if (!PyType_HasFeature(base, Py_TPFLAGS_BASETYPE)) { - PyErr_Format(PyExc_TypeError, - "type '%.100s' is not an acceptable base type", - base->tp_name); - return NULL; - } - - /* Check for a __slots__ sequence variable in dict, and count it */ - slots = PyDict_GetItemString(dict, "__slots__"); - nslots = 0; - add_dict = 0; - add_weak = 0; - may_add_dict = base->tp_dictoffset == 0; - may_add_weak = base->tp_weaklistoffset == 0 && base->tp_itemsize == 0; - if (slots == NULL) { - if (may_add_dict) { - add_dict++; - } - if (may_add_weak) { - add_weak++; - } - } - else { - /* Have slots */ - - /* Make it into a tuple */ - if (PyString_Check(slots)) - slots = Py_BuildValue("(O)", slots); - else - slots = PySequence_Tuple(slots); - if (slots == NULL) - return NULL; - assert(PyTuple_Check(slots)); - - /* Are slots allowed? */ - nslots = PyTuple_GET_SIZE(slots); - if (nslots > 0 && base->tp_itemsize != 0) { - PyErr_Format(PyExc_TypeError, - "nonempty __slots__ " - "not supported for subtype of '%s'", - base->tp_name); - bad_slots: - Py_DECREF(slots); - return NULL; - } - -#ifdef Py_USING_UNICODE - tmp = _unicode_to_string(slots, nslots); - if (tmp != slots) { - Py_DECREF(slots); - slots = tmp; - } - if (!tmp) - return NULL; -#endif - /* Check for valid slot names and two special cases */ - for (i = 0; i < nslots; i++) { - PyObject *tmp = PyTuple_GET_ITEM(slots, i); - char *s; - if (!valid_identifier(tmp)) - goto bad_slots; - assert(PyString_Check(tmp)); - s = PyString_AS_STRING(tmp); - if (strcmp(s, "__dict__") == 0) { - if (!may_add_dict || add_dict) { - PyErr_SetString(PyExc_TypeError, - "__dict__ slot disallowed: " - "we already got one"); - goto bad_slots; - } - add_dict++; - } - if (strcmp(s, "__weakref__") == 0) { - if (!may_add_weak || add_weak) { - PyErr_SetString(PyExc_TypeError, - "__weakref__ slot disallowed: " - "either we already got one, " - "or __itemsize__ != 0"); - goto bad_slots; - } - add_weak++; - } - } - - /* Copy slots into yet another tuple, demangling names */ - newslots = PyTuple_New(nslots - add_dict - add_weak); - if (newslots == NULL) - goto bad_slots; - for (i = j = 0; i < nslots; i++) { - char *s; - char buffer[256]; - tmp = PyTuple_GET_ITEM(slots, i); - s = PyString_AS_STRING(tmp); - if ((add_dict && strcmp(s, "__dict__") == 0) || - (add_weak && strcmp(s, "__weakref__") == 0)) - continue; - if (_Py_Mangle(PyString_AS_STRING(name), - PyString_AS_STRING(tmp), - buffer, sizeof(buffer))) - { - tmp = PyString_FromString(buffer); - } else { - Py_INCREF(tmp); - } - PyTuple_SET_ITEM(newslots, j, tmp); - j++; - } - assert(j == nslots - add_dict - add_weak); - nslots = j; - Py_DECREF(slots); - slots = newslots; - - /* Secondary bases may provide weakrefs or dict */ - if (nbases > 1 && - ((may_add_dict && !add_dict) || - (may_add_weak && !add_weak))) { - for (i = 0; i < nbases; i++) { - tmp = PyTuple_GET_ITEM(bases, i); - if (tmp == (PyObject *)base) - continue; /* Skip primary base */ - if (PyClass_Check(tmp)) { - /* Classic base class provides both */ - if (may_add_dict && !add_dict) - add_dict++; - if (may_add_weak && !add_weak) - add_weak++; - break; - } - assert(PyType_Check(tmp)); - tmptype = (PyTypeObject *)tmp; - if (may_add_dict && !add_dict && - tmptype->tp_dictoffset != 0) - add_dict++; - if (may_add_weak && !add_weak && - tmptype->tp_weaklistoffset != 0) - add_weak++; - if (may_add_dict && !add_dict) - continue; - if (may_add_weak && !add_weak) - continue; - /* Nothing more to check */ - break; - } - } - } - - /* XXX From here until type is safely allocated, - "return NULL" may leak slots! */ - - /* Allocate the type object */ - type = (PyTypeObject *)metatype->tp_alloc(metatype, nslots); - if (type == NULL) { - Py_XDECREF(slots); - return NULL; - } - - /* Keep name and slots alive in the extended type object */ - et = (PyHeapTypeObject *)type; - Py_INCREF(name); - et->name = name; - et->slots = slots; - - /* Initialize tp_flags */ - type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE | - Py_TPFLAGS_BASETYPE; - if (base->tp_flags & Py_TPFLAGS_HAVE_GC) - type->tp_flags |= Py_TPFLAGS_HAVE_GC; - - /* It's a new-style number unless it specifically inherits any - old-style numeric behavior */ - if ((base->tp_flags & Py_TPFLAGS_CHECKTYPES) || - (base->tp_as_number == NULL)) - type->tp_flags |= Py_TPFLAGS_CHECKTYPES; - - /* Initialize essential fields */ - type->tp_as_number = &et->as_number; - type->tp_as_sequence = &et->as_sequence; - type->tp_as_mapping = &et->as_mapping; - type->tp_as_buffer = &et->as_buffer; - type->tp_name = PyString_AS_STRING(name); - - /* Set tp_base and tp_bases */ - type->tp_bases = bases; - Py_INCREF(base); - type->tp_base = base; - - /* Initialize tp_dict from passed-in dict */ - type->tp_dict = dict = PyDict_Copy(dict); - if (dict == NULL) { - Py_DECREF(type); - return NULL; - } - - /* Set __module__ in the dict */ - if (PyDict_GetItemString(dict, "__module__") == NULL) { - tmp = PyEval_GetGlobals(); - if (tmp != NULL) { - tmp = PyDict_GetItemString(tmp, "__name__"); - if (tmp != NULL) { - if (PyDict_SetItemString(dict, "__module__", - tmp) < 0) - return NULL; - } - } - } - - /* Set tp_doc to a copy of dict['__doc__'], if the latter is there - and is a string. The __doc__ accessor will first look for tp_doc; - if that fails, it will still look into __dict__. - */ - { - PyObject *doc = PyDict_GetItemString(dict, "__doc__"); - if (doc != NULL && PyString_Check(doc)) { - const size_t n = (size_t)PyString_GET_SIZE(doc); - type->tp_doc = (char *)PyObject_MALLOC(n+1); - if (type->tp_doc == NULL) { - Py_DECREF(type); - return NULL; - } - memcpy(type->tp_doc, PyString_AS_STRING(doc), n+1); - } - } - - /* Special-case __new__: if it's a plain function, - make it a static function */ - tmp = PyDict_GetItemString(dict, "__new__"); - if (tmp != NULL && PyFunction_Check(tmp)) { - tmp = PyStaticMethod_New(tmp); - if (tmp == NULL) { - Py_DECREF(type); - return NULL; - } - PyDict_SetItemString(dict, "__new__", tmp); - Py_DECREF(tmp); - } - - /* Add descriptors for custom slots from __slots__, or for __dict__ */ - mp = PyHeapType_GET_MEMBERS(et); - slotoffset = base->tp_basicsize; - if (slots != NULL) { - for (i = 0; i < nslots; i++, mp++) { - mp->name = PyString_AS_STRING( - PyTuple_GET_ITEM(slots, i)); - mp->type = T_OBJECT_EX; - mp->offset = slotoffset; - if (base->tp_weaklistoffset == 0 && - strcmp(mp->name, "__weakref__") == 0) { - add_weak++; - mp->type = T_OBJECT; - mp->flags = READONLY; - type->tp_weaklistoffset = slotoffset; - } - slotoffset += sizeof(PyObject *); - } - } - if (add_dict) { - if (base->tp_itemsize) - type->tp_dictoffset = -(long)sizeof(PyObject *); - else - type->tp_dictoffset = slotoffset; - slotoffset += sizeof(PyObject *); - } - if (add_weak) { - assert(!base->tp_itemsize); - type->tp_weaklistoffset = slotoffset; - slotoffset += sizeof(PyObject *); - } - type->tp_basicsize = slotoffset; - type->tp_itemsize = base->tp_itemsize; - type->tp_members = PyHeapType_GET_MEMBERS(et); - - if (type->tp_weaklistoffset && type->tp_dictoffset) - type->tp_getset = subtype_getsets_full; - else if (type->tp_weaklistoffset && !type->tp_dictoffset) - type->tp_getset = subtype_getsets_weakref_only; - else if (!type->tp_weaklistoffset && type->tp_dictoffset) - type->tp_getset = subtype_getsets_dict_only; - else - type->tp_getset = NULL; - - /* Special case some slots */ - if (type->tp_dictoffset != 0 || nslots > 0) { - if (base->tp_getattr == NULL && base->tp_getattro == NULL) - type->tp_getattro = PyObject_GenericGetAttr; - if (base->tp_setattr == NULL && base->tp_setattro == NULL) - type->tp_setattro = PyObject_GenericSetAttr; - } - type->tp_dealloc = subtype_dealloc; - - /* Enable GC unless there are really no instance variables possible */ - if (!(type->tp_basicsize == sizeof(PyObject) && - type->tp_itemsize == 0)) - type->tp_flags |= Py_TPFLAGS_HAVE_GC; - - /* Always override allocation strategy to use regular heap */ - type->tp_alloc = PyType_GenericAlloc; - if (type->tp_flags & Py_TPFLAGS_HAVE_GC) { - type->tp_free = PyObject_GC_Del; - type->tp_traverse = subtype_traverse; - type->tp_clear = subtype_clear; - } - else - type->tp_free = PyObject_Del; - - /* Initialize the rest */ - if (PyType_Ready(type) < 0) { - Py_DECREF(type); - return NULL; - } - - /* Put the proper slots in place */ - fixup_slot_dispatchers(type); - - return (PyObject *)type; -} - -/* Internal API to look for a name through the MRO. - This returns a borrowed reference, and doesn't set an exception! */ -PyObject * -_PyType_Lookup(PyTypeObject *type, PyObject *name) -{ - int i, n; - PyObject *mro, *res, *base, *dict; - - /* Look in tp_dict of types in MRO */ - mro = type->tp_mro; - - /* If mro is NULL, the type is either not yet initialized - by PyType_Ready(), or already cleared by type_clear(). - Either way the safest thing to do is to return NULL. */ - if (mro == NULL) - return NULL; - - assert(PyTuple_Check(mro)); - n = PyTuple_GET_SIZE(mro); - for (i = 0; i < n; i++) { - base = PyTuple_GET_ITEM(mro, i); - if (PyClass_Check(base)) - dict = ((PyClassObject *)base)->cl_dict; - else { - assert(PyType_Check(base)); - dict = ((PyTypeObject *)base)->tp_dict; - } - assert(dict && PyDict_Check(dict)); - res = PyDict_GetItem(dict, name); - if (res != NULL) - return res; - } - return NULL; -} - -/* This is similar to PyObject_GenericGetAttr(), - but uses _PyType_Lookup() instead of just looking in type->tp_dict. */ -static PyObject * -type_getattro(PyTypeObject *type, PyObject *name) -{ - PyTypeObject *metatype = type->ob_type; - PyObject *meta_attribute, *attribute; - descrgetfunc meta_get; - - /* Initialize this type (we'll assume the metatype is initialized) */ - if (type->tp_dict == NULL) { - if (PyType_Ready(type) < 0) - return NULL; - } - - /* No readable descriptor found yet */ - meta_get = NULL; - - /* Look for the attribute in the metatype */ - meta_attribute = _PyType_Lookup(metatype, name); - - if (meta_attribute != NULL) { - meta_get = meta_attribute->ob_type->tp_descr_get; - - if (meta_get != NULL && PyDescr_IsData(meta_attribute)) { - /* Data descriptors implement tp_descr_set to intercept - * writes. Assume the attribute is not overridden in - * type's tp_dict (and bases): call the descriptor now. - */ - return meta_get(meta_attribute, (PyObject *)type, - (PyObject *)metatype); - } - } - - /* No data descriptor found on metatype. Look in tp_dict of this - * type and its bases */ - attribute = _PyType_Lookup(type, name); - if (attribute != NULL) { - /* Implement descriptor functionality, if any */ - descrgetfunc local_get = attribute->ob_type->tp_descr_get; - if (local_get != NULL) { - /* NULL 2nd argument indicates the descriptor was - * found on the target object itself (or a base) */ - return local_get(attribute, (PyObject *)NULL, - (PyObject *)type); - } - - Py_INCREF(attribute); - return attribute; - } - - /* No attribute found in local __dict__ (or bases): use the - * descriptor from the metatype, if any */ - if (meta_get != NULL) - return meta_get(meta_attribute, (PyObject *)type, - (PyObject *)metatype); - - /* If an ordinary attribute was found on the metatype, return it now */ - if (meta_attribute != NULL) { - Py_INCREF(meta_attribute); - return meta_attribute; - } - - /* Give up */ - PyErr_Format(PyExc_AttributeError, - "type object '%.50s' has no attribute '%.400s'", - type->tp_name, PyString_AS_STRING(name)); - return NULL; -} - -static int -type_setattro(PyTypeObject *type, PyObject *name, PyObject *value) -{ - if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) { - PyErr_Format( - PyExc_TypeError, - "can't set attributes of built-in/extension type '%s'", - type->tp_name); - return -1; - } - /* XXX Example of how I expect this to be used... - if (update_subclasses(type, name, invalidate_cache, NULL) < 0) - return -1; - */ - if (PyObject_GenericSetAttr((PyObject *)type, name, value) < 0) - return -1; - return update_slot(type, name); -} - -static void -type_dealloc(PyTypeObject *type) -{ - PyHeapTypeObject *et; - - /* Assert this is a heap-allocated type object */ - assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE); - _PyObject_GC_UNTRACK(type); - PyObject_ClearWeakRefs((PyObject *)type); - et = (PyHeapTypeObject *)type; - Py_XDECREF(type->tp_base); - Py_XDECREF(type->tp_dict); - Py_XDECREF(type->tp_bases); - Py_XDECREF(type->tp_mro); - Py_XDECREF(type->tp_cache); - Py_XDECREF(type->tp_subclasses); - PyObject_Free(type->tp_doc); - Py_XDECREF(et->name); - Py_XDECREF(et->slots); - type->ob_type->tp_free((PyObject *)type); -} - -static PyObject * -type_subclasses(PyTypeObject *type, PyObject *args_ignored) -{ - PyObject *list, *raw, *ref; - int i, n; - - list = PyList_New(0); - if (list == NULL) - return NULL; - raw = type->tp_subclasses; - if (raw == NULL) - return list; - assert(PyList_Check(raw)); - n = PyList_GET_SIZE(raw); - for (i = 0; i < n; i++) { - ref = PyList_GET_ITEM(raw, i); - assert(PyWeakref_CheckRef(ref)); - ref = PyWeakref_GET_OBJECT(ref); - if (ref != Py_None) { - if (PyList_Append(list, ref) < 0) { - Py_DECREF(list); - return NULL; - } - } - } - return list; -} - -static PyMethodDef type_methods[] = { - {"mro", (PyCFunction)mro_external, METH_NOARGS, - PyDoc_STR("mro() -> list\nreturn a type's method resolution order")}, - {"__subclasses__", (PyCFunction)type_subclasses, METH_NOARGS, - PyDoc_STR("__subclasses__() -> list of immediate subclasses")}, - {0} -}; - -PyDoc_STRVAR(type_doc, -"type(object) -> the object's type\n" -"type(name, bases, dict) -> a new type"); - -static int -type_traverse(PyTypeObject *type, visitproc visit, void *arg) -{ - int err; - - /* Because of type_is_gc(), the collector only calls this - for heaptypes. */ - assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE); - -#define VISIT(SLOT) \ - if (SLOT) { \ - err = visit((PyObject *)(SLOT), arg); \ - if (err) \ - return err; \ - } - - VISIT(type->tp_dict); - VISIT(type->tp_cache); - VISIT(type->tp_mro); - VISIT(type->tp_bases); - VISIT(type->tp_base); - - /* There's no need to visit type->tp_subclasses or - ((PyHeapTypeObject *)type)->slots, because they can't be involved - in cycles; tp_subclasses is a list of weak references, - and slots is a tuple of strings. */ - -#undef VISIT - - return 0; -} - -static int -type_clear(PyTypeObject *type) -{ - PyObject *tmp; - - /* Because of type_is_gc(), the collector only calls this - for heaptypes. */ - assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE); - -#define CLEAR(SLOT) \ - if (SLOT) { \ - tmp = (PyObject *)(SLOT); \ - SLOT = NULL; \ - Py_DECREF(tmp); \ - } - - /* The only field we need to clear is tp_mro, which is part of a - hard cycle (its first element is the class itself) that won't - be broken otherwise (it's a tuple and tuples don't have a - tp_clear handler). None of the other fields need to be - cleared, and here's why: - - tp_dict: - It is a dict, so the collector will call its tp_clear. - - tp_cache: - Not used; if it were, it would be a dict. - - tp_bases, tp_base: - If these are involved in a cycle, there must be at least - one other, mutable object in the cycle, e.g. a base - class's dict; the cycle will be broken that way. - - tp_subclasses: - A list of weak references can't be part of a cycle; and - lists have their own tp_clear. - - slots (in PyHeapTypeObject): - A tuple of strings can't be part of a cycle. - */ - - CLEAR(type->tp_mro); - -#undef CLEAR - - return 0; -} - -static int -type_is_gc(PyTypeObject *type) -{ - return type->tp_flags & Py_TPFLAGS_HEAPTYPE; -} - -PyTypeObject PyType_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "type", /* tp_name */ - sizeof(PyHeapTypeObject), /* tp_basicsize */ - sizeof(PyMemberDef), /* tp_itemsize */ - (destructor)type_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - type_compare, /* tp_compare */ - (reprfunc)type_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)_Py_HashPointer, /* tp_hash */ - (ternaryfunc)type_call, /* tp_call */ - 0, /* tp_str */ - (getattrofunc)type_getattro, /* tp_getattro */ - (setattrofunc)type_setattro, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - type_doc, /* tp_doc */ - (traverseproc)type_traverse, /* tp_traverse */ - (inquiry)type_clear, /* tp_clear */ - 0, /* tp_richcompare */ - offsetof(PyTypeObject, tp_weaklist), /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - type_methods, /* tp_methods */ - type_members, /* tp_members */ - type_getsets, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - offsetof(PyTypeObject, tp_dict), /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - type_new, /* tp_new */ - PyObject_GC_Del, /* tp_free */ - (inquiry)type_is_gc, /* tp_is_gc */ -}; - - -/* The base type of all types (eventually)... except itself. */ - -static int -object_init(PyObject *self, PyObject *args, PyObject *kwds) -{ - return 0; -} - -/* If we don't have a tp_new for a new-style class, new will use this one. - Therefore this should take no arguments/keywords. However, this new may - also be inherited by objects that define a tp_init but no tp_new. These - objects WILL pass argumets to tp_new, because it gets the same args as - tp_init. So only allow arguments if we aren't using the default init, in - which case we expect init to handle argument parsing. */ -static PyObject * -object_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - if (type->tp_init == object_init && (PyTuple_GET_SIZE(args) || - (kwds && PyDict_Check(kwds) && PyDict_Size(kwds)))) { - PyErr_SetString(PyExc_TypeError, - "default __new__ takes no parameters"); - return NULL; - } - return type->tp_alloc(type, 0); -} - -static void -object_dealloc(PyObject *self) -{ - self->ob_type->tp_free(self); -} - -static PyObject * -object_repr(PyObject *self) -{ - PyTypeObject *type; - PyObject *mod, *name, *rtn; - - type = self->ob_type; - mod = type_module(type, NULL); - if (mod == NULL) - PyErr_Clear(); - else if (!PyString_Check(mod)) { - Py_DECREF(mod); - mod = NULL; - } - name = type_name(type, NULL); - if (name == NULL) - return NULL; - if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__")) - rtn = PyString_FromFormat("<%s.%s object at %p>", - PyString_AS_STRING(mod), - PyString_AS_STRING(name), - self); - else - rtn = PyString_FromFormat("<%s object at %p>", - type->tp_name, self); - Py_XDECREF(mod); - Py_DECREF(name); - return rtn; -} - -static PyObject * -object_str(PyObject *self) -{ - unaryfunc f; - - f = self->ob_type->tp_repr; - if (f == NULL) - f = object_repr; - return f(self); -} - -static long -object_hash(PyObject *self) -{ - return _Py_HashPointer(self); -} - -static PyObject * -object_get_class(PyObject *self, void *closure) -{ - Py_INCREF(self->ob_type); - return (PyObject *)(self->ob_type); -} - -static int -equiv_structs(PyTypeObject *a, PyTypeObject *b) -{ - return a == b || - (a != NULL && - b != NULL && - a->tp_basicsize == b->tp_basicsize && - a->tp_itemsize == b->tp_itemsize && - a->tp_dictoffset == b->tp_dictoffset && - a->tp_weaklistoffset == b->tp_weaklistoffset && - ((a->tp_flags & Py_TPFLAGS_HAVE_GC) == - (b->tp_flags & Py_TPFLAGS_HAVE_GC))); -} - -static int -same_slots_added(PyTypeObject *a, PyTypeObject *b) -{ - PyTypeObject *base = a->tp_base; - int size; - - if (base != b->tp_base) - return 0; - if (equiv_structs(a, base) && equiv_structs(b, base)) - return 1; - size = base->tp_basicsize; - if (a->tp_dictoffset == size && b->tp_dictoffset == size) - size += sizeof(PyObject *); - if (a->tp_weaklistoffset == size && b->tp_weaklistoffset == size) - size += sizeof(PyObject *); - return size == a->tp_basicsize && size == b->tp_basicsize; -} - -static int -compatible_for_assignment(PyTypeObject* old, PyTypeObject* new, char* attr) -{ - PyTypeObject *newbase, *oldbase; - - if (new->tp_dealloc != old->tp_dealloc || - new->tp_free != old->tp_free) - { - PyErr_Format(PyExc_TypeError, - "%s assignment: " - "'%s' deallocator differs from '%s'", - attr, - new->tp_name, - old->tp_name); - return 0; - } - newbase = new; - oldbase = old; - while (equiv_structs(newbase, newbase->tp_base)) - newbase = newbase->tp_base; - while (equiv_structs(oldbase, oldbase->tp_base)) - oldbase = oldbase->tp_base; - if (newbase != oldbase && - (newbase->tp_base != oldbase->tp_base || - !same_slots_added(newbase, oldbase))) { - PyErr_Format(PyExc_TypeError, - "%s assignment: " - "'%s' object layout differs from '%s'", - attr, - new->tp_name, - old->tp_name); - return 0; - } - - return 1; -} - -static int -object_set_class(PyObject *self, PyObject *value, void *closure) -{ - PyTypeObject *old = self->ob_type; - PyTypeObject *new; - - if (value == NULL) { - PyErr_SetString(PyExc_TypeError, - "can't delete __class__ attribute"); - return -1; - } - if (!PyType_Check(value)) { - PyErr_Format(PyExc_TypeError, - "__class__ must be set to new-style class, not '%s' object", - value->ob_type->tp_name); - return -1; - } - new = (PyTypeObject *)value; - if (!(new->tp_flags & Py_TPFLAGS_HEAPTYPE) || - !(old->tp_flags & Py_TPFLAGS_HEAPTYPE)) - { - PyErr_Format(PyExc_TypeError, - "__class__ assignment: only for heap types"); - return -1; - } - if (compatible_for_assignment(new, old, "__class__")) { - Py_INCREF(new); - self->ob_type = new; - Py_DECREF(old); - return 0; - } - else { - return -1; - } -} - -static PyGetSetDef object_getsets[] = { - {"__class__", object_get_class, object_set_class, - PyDoc_STR("the object's class")}, - {0} -}; - - -/* Stuff to implement __reduce_ex__ for pickle protocols >= 2. - We fall back to helpers in copy_reg for: - - pickle protocols < 2 - - calculating the list of slot names (done only once per class) - - the __newobj__ function (which is used as a token but never called) -*/ - -static PyObject * -import_copy_reg(void) -{ - static PyObject *copy_reg_str; - - if (!copy_reg_str) { - copy_reg_str = PyString_InternFromString("copy_reg"); - if (copy_reg_str == NULL) - return NULL; - } - - return PyImport_Import(copy_reg_str); -} - -static PyObject * -slotnames(PyObject *cls) -{ - PyObject *clsdict; - PyObject *copy_reg; - PyObject *slotnames; - - if (!PyType_Check(cls)) { - Py_INCREF(Py_None); - return Py_None; - } - - clsdict = ((PyTypeObject *)cls)->tp_dict; - slotnames = PyDict_GetItemString(clsdict, "__slotnames__"); - if (slotnames != NULL) { - Py_INCREF(slotnames); - return slotnames; - } - - copy_reg = import_copy_reg(); - if (copy_reg == NULL) - return NULL; - - slotnames = PyObject_CallMethod(copy_reg, "_slotnames", "O", cls); - Py_DECREF(copy_reg); - if (slotnames != NULL && - slotnames != Py_None && - !PyList_Check(slotnames)) - { - PyErr_SetString(PyExc_TypeError, - "copy_reg._slotnames didn't return a list or None"); - Py_DECREF(slotnames); - slotnames = NULL; - } - - return slotnames; -} - -static PyObject * -reduce_2(PyObject *obj) -{ - PyObject *cls, *getnewargs; - PyObject *args = NULL, *args2 = NULL; - PyObject *getstate = NULL, *state = NULL, *names = NULL; - PyObject *slots = NULL, *listitems = NULL, *dictitems = NULL; - PyObject *copy_reg = NULL, *newobj = NULL, *res = NULL; - int i, n; - - cls = PyObject_GetAttrString(obj, "__class__"); - if (cls == NULL) - return NULL; - - getnewargs = PyObject_GetAttrString(obj, "__getnewargs__"); - if (getnewargs != NULL) { - args = PyObject_CallObject(getnewargs, NULL); - Py_DECREF(getnewargs); - if (args != NULL && !PyTuple_Check(args)) { - PyErr_SetString(PyExc_TypeError, - "__getnewargs__ should return a tuple"); - goto end; - } - } - else { - PyErr_Clear(); - args = PyTuple_New(0); - } - if (args == NULL) - goto end; - - getstate = PyObject_GetAttrString(obj, "__getstate__"); - if (getstate != NULL) { - state = PyObject_CallObject(getstate, NULL); - Py_DECREF(getstate); - if (state == NULL) - goto end; - } - else { - state = PyObject_GetAttrString(obj, "__dict__"); - if (state == NULL) { - PyErr_Clear(); - state = Py_None; - Py_INCREF(state); - } - names = slotnames(cls); - if (names == NULL) - goto end; - if (names != Py_None) { - assert(PyList_Check(names)); - slots = PyDict_New(); - if (slots == NULL) - goto end; - n = 0; - /* Can't pre-compute the list size; the list - is stored on the class so accessible to other - threads, which may be run by DECREF */ - for (i = 0; i < PyList_GET_SIZE(names); i++) { - PyObject *name, *value; - name = PyList_GET_ITEM(names, i); - value = PyObject_GetAttr(obj, name); - if (value == NULL) - PyErr_Clear(); - else { - int err = PyDict_SetItem(slots, name, - value); - Py_DECREF(value); - if (err) - goto end; - n++; - } - } - if (n) { - state = Py_BuildValue("(NO)", state, slots); - if (state == NULL) - goto end; - } - } - } - - if (!PyList_Check(obj)) { - listitems = Py_None; - Py_INCREF(listitems); - } - else { - listitems = PyObject_GetIter(obj); - if (listitems == NULL) - goto end; - } - - if (!PyDict_Check(obj)) { - dictitems = Py_None; - Py_INCREF(dictitems); - } - else { - dictitems = PyObject_CallMethod(obj, "iteritems", ""); - if (dictitems == NULL) - goto end; - } - - copy_reg = import_copy_reg(); - if (copy_reg == NULL) - goto end; - newobj = PyObject_GetAttrString(copy_reg, "__newobj__"); - if (newobj == NULL) - goto end; - - n = PyTuple_GET_SIZE(args); - args2 = PyTuple_New(n+1); - if (args2 == NULL) - goto end; - PyTuple_SET_ITEM(args2, 0, cls); - cls = NULL; - for (i = 0; i < n; i++) { - PyObject *v = PyTuple_GET_ITEM(args, i); - Py_INCREF(v); - PyTuple_SET_ITEM(args2, i+1, v); - } - - res = Py_BuildValue("(OOOOO)", - newobj, args2, state, listitems, dictitems); - - end: - Py_XDECREF(cls); - Py_XDECREF(args); - Py_XDECREF(args2); - Py_XDECREF(slots); - Py_XDECREF(state); - Py_XDECREF(names); - Py_XDECREF(listitems); - Py_XDECREF(dictitems); - Py_XDECREF(copy_reg); - Py_XDECREF(newobj); - return res; -} - -static PyObject * -object_reduce_ex(PyObject *self, PyObject *args) -{ - /* Call copy_reg._reduce_ex(self, proto) */ - PyObject *reduce, *copy_reg, *res; - int proto = 0; - - if (!PyArg_ParseTuple(args, "|i:__reduce_ex__", &proto)) - return NULL; - - reduce = PyObject_GetAttrString(self, "__reduce__"); - if (reduce == NULL) - PyErr_Clear(); - else { - PyObject *cls, *clsreduce, *objreduce; - int override; - cls = PyObject_GetAttrString(self, "__class__"); - if (cls == NULL) { - Py_DECREF(reduce); - return NULL; - } - clsreduce = PyObject_GetAttrString(cls, "__reduce__"); - Py_DECREF(cls); - if (clsreduce == NULL) { - Py_DECREF(reduce); - return NULL; - } - objreduce = PyDict_GetItemString(PyBaseObject_Type.tp_dict, - "__reduce__"); - override = (clsreduce != objreduce); - Py_DECREF(clsreduce); - if (override) { - res = PyObject_CallObject(reduce, NULL); - Py_DECREF(reduce); - return res; - } - else - Py_DECREF(reduce); - } - - if (proto >= 2) - return reduce_2(self); - - copy_reg = import_copy_reg(); - if (!copy_reg) - return NULL; - - res = PyEval_CallMethod(copy_reg, "_reduce_ex", "(Oi)", self, proto); - Py_DECREF(copy_reg); - - return res; -} - -static PyMethodDef object_methods[] = { - {"__reduce_ex__", object_reduce_ex, METH_VARARGS, - PyDoc_STR("helper for pickle")}, - {"__reduce__", object_reduce_ex, METH_VARARGS, - PyDoc_STR("helper for pickle")}, - {0} -}; - - -PyTypeObject PyBaseObject_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "object", /* tp_name */ - sizeof(PyObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)object_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - object_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - object_hash, /* tp_hash */ - 0, /* tp_call */ - object_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - PyObject_GenericSetAttr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - PyDoc_STR("The most base type"), /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - object_methods, /* tp_methods */ - 0, /* tp_members */ - object_getsets, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - object_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - object_new, /* tp_new */ - PyObject_Del, /* tp_free */ -}; - - -/* Initialize the __dict__ in a type object */ - -static int -add_methods(PyTypeObject *type, PyMethodDef *meth) -{ - PyObject *dict = type->tp_dict; - - for (; meth->ml_name != NULL; meth++) { - PyObject *descr; - if (PyDict_GetItemString(dict, meth->ml_name)) - continue; - if (meth->ml_flags & METH_CLASS) { - if (meth->ml_flags & METH_STATIC) { - PyErr_SetString(PyExc_ValueError, - "method cannot be both class and static"); - return -1; - } - descr = PyDescr_NewClassMethod(type, meth); - } - else if (meth->ml_flags & METH_STATIC) { - PyObject *cfunc = PyCFunction_New(meth, NULL); - if (cfunc == NULL) - return -1; - descr = PyStaticMethod_New(cfunc); - Py_DECREF(cfunc); - } - else { - descr = PyDescr_NewMethod(type, meth); - } - if (descr == NULL) - return -1; - if (PyDict_SetItemString(dict, meth->ml_name, descr) < 0) - return -1; - Py_DECREF(descr); - } - return 0; -} - -static int -add_members(PyTypeObject *type, PyMemberDef *memb) -{ - PyObject *dict = type->tp_dict; - - for (; memb->name != NULL; memb++) { - PyObject *descr; - if (PyDict_GetItemString(dict, memb->name)) - continue; - descr = PyDescr_NewMember(type, memb); - if (descr == NULL) - return -1; - if (PyDict_SetItemString(dict, memb->name, descr) < 0) - return -1; - Py_DECREF(descr); - } - return 0; -} - -static int -add_getset(PyTypeObject *type, PyGetSetDef *gsp) -{ - PyObject *dict = type->tp_dict; - - for (; gsp->name != NULL; gsp++) { - PyObject *descr; - if (PyDict_GetItemString(dict, gsp->name)) - continue; - descr = PyDescr_NewGetSet(type, gsp); - - if (descr == NULL) - return -1; - if (PyDict_SetItemString(dict, gsp->name, descr) < 0) - return -1; - Py_DECREF(descr); - } - return 0; -} - -static void -inherit_special(PyTypeObject *type, PyTypeObject *base) -{ - int oldsize, newsize; - - /* Special flag magic */ - if (!type->tp_as_buffer && base->tp_as_buffer) { - type->tp_flags &= ~Py_TPFLAGS_HAVE_GETCHARBUFFER; - type->tp_flags |= - base->tp_flags & Py_TPFLAGS_HAVE_GETCHARBUFFER; - } - if (!type->tp_as_sequence && base->tp_as_sequence) { - type->tp_flags &= ~Py_TPFLAGS_HAVE_SEQUENCE_IN; - type->tp_flags |= base->tp_flags & Py_TPFLAGS_HAVE_SEQUENCE_IN; - } - if ((type->tp_flags & Py_TPFLAGS_HAVE_INPLACEOPS) != - (base->tp_flags & Py_TPFLAGS_HAVE_INPLACEOPS)) { - if ((!type->tp_as_number && base->tp_as_number) || - (!type->tp_as_sequence && base->tp_as_sequence)) { - type->tp_flags &= ~Py_TPFLAGS_HAVE_INPLACEOPS; - if (!type->tp_as_number && !type->tp_as_sequence) { - type->tp_flags |= base->tp_flags & - Py_TPFLAGS_HAVE_INPLACEOPS; - } - } - /* Wow */ - } - if (!type->tp_as_number && base->tp_as_number) { - type->tp_flags &= ~Py_TPFLAGS_CHECKTYPES; - type->tp_flags |= base->tp_flags & Py_TPFLAGS_CHECKTYPES; - } - - /* Copying basicsize is connected to the GC flags */ - oldsize = base->tp_basicsize; - newsize = type->tp_basicsize ? type->tp_basicsize : oldsize; - if (!(type->tp_flags & Py_TPFLAGS_HAVE_GC) && - (base->tp_flags & Py_TPFLAGS_HAVE_GC) && - (type->tp_flags & Py_TPFLAGS_HAVE_RICHCOMPARE/*GC slots exist*/) && - (!type->tp_traverse && !type->tp_clear)) { - type->tp_flags |= Py_TPFLAGS_HAVE_GC; - if (type->tp_traverse == NULL) - type->tp_traverse = base->tp_traverse; - if (type->tp_clear == NULL) - type->tp_clear = base->tp_clear; - } - if (type->tp_flags & base->tp_flags & Py_TPFLAGS_HAVE_CLASS) { - /* The condition below could use some explanation. - It appears that tp_new is not inherited for static types - whose base class is 'object'; this seems to be a precaution - so that old extension types don't suddenly become - callable (object.__new__ wouldn't insure the invariants - that the extension type's own factory function ensures). - Heap types, of course, are under our control, so they do - inherit tp_new; static extension types that specify some - other built-in type as the default are considered - new-style-aware so they also inherit object.__new__. */ - if (base != &PyBaseObject_Type || - (type->tp_flags & Py_TPFLAGS_HEAPTYPE)) { - if (type->tp_new == NULL) - type->tp_new = base->tp_new; - } - } - type->tp_basicsize = newsize; - - /* Copy other non-function slots */ - -#undef COPYVAL -#define COPYVAL(SLOT) \ - if (type->SLOT == 0) type->SLOT = base->SLOT - - COPYVAL(tp_itemsize); - if (type->tp_flags & base->tp_flags & Py_TPFLAGS_HAVE_WEAKREFS) { - COPYVAL(tp_weaklistoffset); - } - if (type->tp_flags & base->tp_flags & Py_TPFLAGS_HAVE_CLASS) { - COPYVAL(tp_dictoffset); - } -} - -static void -inherit_slots(PyTypeObject *type, PyTypeObject *base) -{ - PyTypeObject *basebase; - -#undef SLOTDEFINED -#undef COPYSLOT -#undef COPYNUM -#undef COPYSEQ -#undef COPYMAP -#undef COPYBUF - -#define SLOTDEFINED(SLOT) \ - (base->SLOT != 0 && \ - (basebase == NULL || base->SLOT != basebase->SLOT)) - -#define COPYSLOT(SLOT) \ - if (!type->SLOT && SLOTDEFINED(SLOT)) type->SLOT = base->SLOT - -#define COPYNUM(SLOT) COPYSLOT(tp_as_number->SLOT) -#define COPYSEQ(SLOT) COPYSLOT(tp_as_sequence->SLOT) -#define COPYMAP(SLOT) COPYSLOT(tp_as_mapping->SLOT) -#define COPYBUF(SLOT) COPYSLOT(tp_as_buffer->SLOT) - - /* This won't inherit indirect slots (from tp_as_number etc.) - if type doesn't provide the space. */ - - if (type->tp_as_number != NULL && base->tp_as_number != NULL) { - basebase = base->tp_base; - if (basebase->tp_as_number == NULL) - basebase = NULL; - COPYNUM(nb_add); - COPYNUM(nb_subtract); - COPYNUM(nb_multiply); - COPYNUM(nb_divide); - COPYNUM(nb_remainder); - COPYNUM(nb_divmod); - COPYNUM(nb_power); - COPYNUM(nb_negative); - COPYNUM(nb_positive); - COPYNUM(nb_absolute); - COPYNUM(nb_nonzero); - COPYNUM(nb_invert); - COPYNUM(nb_lshift); - COPYNUM(nb_rshift); - COPYNUM(nb_and); - COPYNUM(nb_xor); - COPYNUM(nb_or); - COPYNUM(nb_coerce); - COPYNUM(nb_int); - COPYNUM(nb_long); - COPYNUM(nb_float); - COPYNUM(nb_oct); - COPYNUM(nb_hex); - COPYNUM(nb_inplace_add); - COPYNUM(nb_inplace_subtract); - COPYNUM(nb_inplace_multiply); - COPYNUM(nb_inplace_divide); - COPYNUM(nb_inplace_remainder); - COPYNUM(nb_inplace_power); - COPYNUM(nb_inplace_lshift); - COPYNUM(nb_inplace_rshift); - COPYNUM(nb_inplace_and); - COPYNUM(nb_inplace_xor); - COPYNUM(nb_inplace_or); - if (base->tp_flags & Py_TPFLAGS_CHECKTYPES) { - COPYNUM(nb_true_divide); - COPYNUM(nb_floor_divide); - COPYNUM(nb_inplace_true_divide); - COPYNUM(nb_inplace_floor_divide); - } - } - - if (type->tp_as_sequence != NULL && base->tp_as_sequence != NULL) { - basebase = base->tp_base; - if (basebase->tp_as_sequence == NULL) - basebase = NULL; - COPYSEQ(sq_length); - COPYSEQ(sq_concat); - COPYSEQ(sq_repeat); - COPYSEQ(sq_item); - COPYSEQ(sq_slice); - COPYSEQ(sq_ass_item); - COPYSEQ(sq_ass_slice); - COPYSEQ(sq_contains); - COPYSEQ(sq_inplace_concat); - COPYSEQ(sq_inplace_repeat); - } - - if (type->tp_as_mapping != NULL && base->tp_as_mapping != NULL) { - basebase = base->tp_base; - if (basebase->tp_as_mapping == NULL) - basebase = NULL; - COPYMAP(mp_length); - COPYMAP(mp_subscript); - COPYMAP(mp_ass_subscript); - } - - if (type->tp_as_buffer != NULL && base->tp_as_buffer != NULL) { - basebase = base->tp_base; - if (basebase->tp_as_buffer == NULL) - basebase = NULL; - COPYBUF(bf_getreadbuffer); - COPYBUF(bf_getwritebuffer); - COPYBUF(bf_getsegcount); - COPYBUF(bf_getcharbuffer); - } - - basebase = base->tp_base; - - COPYSLOT(tp_dealloc); - COPYSLOT(tp_print); - if (type->tp_getattr == NULL && type->tp_getattro == NULL) { - type->tp_getattr = base->tp_getattr; - type->tp_getattro = base->tp_getattro; - } - if (type->tp_setattr == NULL && type->tp_setattro == NULL) { - type->tp_setattr = base->tp_setattr; - type->tp_setattro = base->tp_setattro; - } - /* tp_compare see tp_richcompare */ - COPYSLOT(tp_repr); - /* tp_hash see tp_richcompare */ - COPYSLOT(tp_call); - COPYSLOT(tp_str); - if (type->tp_flags & base->tp_flags & Py_TPFLAGS_HAVE_RICHCOMPARE) { - if (type->tp_compare == NULL && - type->tp_richcompare == NULL && - type->tp_hash == NULL) - { - type->tp_compare = base->tp_compare; - type->tp_richcompare = base->tp_richcompare; - type->tp_hash = base->tp_hash; - } - } - else { - COPYSLOT(tp_compare); - } - if (type->tp_flags & base->tp_flags & Py_TPFLAGS_HAVE_ITER) { - COPYSLOT(tp_iter); - COPYSLOT(tp_iternext); - } - if (type->tp_flags & base->tp_flags & Py_TPFLAGS_HAVE_CLASS) { - COPYSLOT(tp_descr_get); - COPYSLOT(tp_descr_set); - COPYSLOT(tp_dictoffset); - COPYSLOT(tp_init); - COPYSLOT(tp_alloc); - COPYSLOT(tp_is_gc); - if ((type->tp_flags & Py_TPFLAGS_HAVE_GC) == - (base->tp_flags & Py_TPFLAGS_HAVE_GC)) { - /* They agree about gc. */ - COPYSLOT(tp_free); - } - else if ((type->tp_flags & Py_TPFLAGS_HAVE_GC) && - type->tp_free == NULL && - base->tp_free == _PyObject_Del) { - /* A bit of magic to plug in the correct default - * tp_free function when a derived class adds gc, - * didn't define tp_free, and the base uses the - * default non-gc tp_free. - */ - type->tp_free = PyObject_GC_Del; - } - /* else they didn't agree about gc, and there isn't something - * obvious to be done -- the type is on its own. - */ - } -} - -static int add_operators(PyTypeObject *); - -int -PyType_Ready(PyTypeObject *type) -{ - PyObject *dict, *bases; - PyTypeObject *base; - int i, n; - - if (type->tp_flags & Py_TPFLAGS_READY) { - assert(type->tp_dict != NULL); - return 0; - } - assert((type->tp_flags & Py_TPFLAGS_READYING) == 0); - - type->tp_flags |= Py_TPFLAGS_READYING; - -#ifdef Py_TRACE_REFS - /* PyType_Ready is the closest thing we have to a choke point - * for type objects, so is the best place I can think of to try - * to get type objects into the doubly-linked list of all objects. - * Still, not all type objects go thru PyType_Ready. - */ - _Py_AddToAllObjects((PyObject *)type, 0); -#endif - - /* Initialize tp_base (defaults to BaseObject unless that's us) */ - base = type->tp_base; - if (base == NULL && type != &PyBaseObject_Type) - base = type->tp_base = &PyBaseObject_Type; - - /* Initialize the base class */ - if (base && base->tp_dict == NULL) { - if (PyType_Ready(base) < 0) - goto error; - } - - /* Initialize ob_type if NULL. This means extensions that want to be - compilable separately on Windows can call PyType_Ready() instead of - initializing the ob_type field of their type objects. */ - if (type->ob_type == NULL) - type->ob_type = base->ob_type; - - /* Initialize tp_bases */ - bases = type->tp_bases; - if (bases == NULL) { - if (base == NULL) - bases = PyTuple_New(0); - else - bases = Py_BuildValue("(O)", base); - if (bases == NULL) - goto error; - type->tp_bases = bases; - } - - /* Initialize tp_dict */ - dict = type->tp_dict; - if (dict == NULL) { - dict = PyDict_New(); - if (dict == NULL) - goto error; - type->tp_dict = dict; - } - - /* Add type-specific descriptors to tp_dict */ - if (add_operators(type) < 0) - goto error; - if (type->tp_methods != NULL) { - if (add_methods(type, type->tp_methods) < 0) - goto error; - } - if (type->tp_members != NULL) { - if (add_members(type, type->tp_members) < 0) - goto error; - } - if (type->tp_getset != NULL) { - if (add_getset(type, type->tp_getset) < 0) - goto error; - } - - /* Calculate method resolution order */ - if (mro_internal(type) < 0) { - goto error; - } - - /* Inherit special flags from dominant base */ - if (type->tp_base != NULL) - inherit_special(type, type->tp_base); - - /* Initialize tp_dict properly */ - bases = type->tp_mro; - assert(bases != NULL); - assert(PyTuple_Check(bases)); - n = PyTuple_GET_SIZE(bases); - for (i = 1; i < n; i++) { - PyObject *b = PyTuple_GET_ITEM(bases, i); - if (PyType_Check(b)) - inherit_slots(type, (PyTypeObject *)b); - } - - /* Sanity check for tp_free. */ - if (PyType_IS_GC(type) && (type->tp_flags & Py_TPFLAGS_BASETYPE) && - (type->tp_free == NULL || type->tp_free == PyObject_Del)) { - /* This base class needs to call tp_free, but doesn't have - * one, or its tp_free is for non-gc'ed objects. - */ - PyErr_Format(PyExc_TypeError, "type '%.100s' participates in " - "gc and is a base type but has inappropriate " - "tp_free slot", - type->tp_name); - goto error; - } - - /* if the type dictionary doesn't contain a __doc__, set it from - the tp_doc slot. - */ - if (PyDict_GetItemString(type->tp_dict, "__doc__") == NULL) { - if (type->tp_doc != NULL) { - PyObject *doc = PyString_FromString(type->tp_doc); - PyDict_SetItemString(type->tp_dict, "__doc__", doc); - Py_DECREF(doc); - } else { - PyDict_SetItemString(type->tp_dict, - "__doc__", Py_None); - } - } - - /* Some more special stuff */ - base = type->tp_base; - if (base != NULL) { - if (type->tp_as_number == NULL) - type->tp_as_number = base->tp_as_number; - if (type->tp_as_sequence == NULL) - type->tp_as_sequence = base->tp_as_sequence; - if (type->tp_as_mapping == NULL) - type->tp_as_mapping = base->tp_as_mapping; - if (type->tp_as_buffer == NULL) - type->tp_as_buffer = base->tp_as_buffer; - } - - /* Link into each base class's list of subclasses */ - bases = type->tp_bases; - n = PyTuple_GET_SIZE(bases); - for (i = 0; i < n; i++) { - PyObject *b = PyTuple_GET_ITEM(bases, i); - if (PyType_Check(b) && - add_subclass((PyTypeObject *)b, type) < 0) - goto error; - } - - /* All done -- set the ready flag */ - assert(type->tp_dict != NULL); - type->tp_flags = - (type->tp_flags & ~Py_TPFLAGS_READYING) | Py_TPFLAGS_READY; - return 0; - - error: - type->tp_flags &= ~Py_TPFLAGS_READYING; - return -1; -} - -static int -add_subclass(PyTypeObject *base, PyTypeObject *type) -{ - int i; - PyObject *list, *ref, *new; - - list = base->tp_subclasses; - if (list == NULL) { - base->tp_subclasses = list = PyList_New(0); - if (list == NULL) - return -1; - } - assert(PyList_Check(list)); - new = PyWeakref_NewRef((PyObject *)type, NULL); - i = PyList_GET_SIZE(list); - while (--i >= 0) { - ref = PyList_GET_ITEM(list, i); - assert(PyWeakref_CheckRef(ref)); - if (PyWeakref_GET_OBJECT(ref) == Py_None) - return PyList_SetItem(list, i, new); - } - i = PyList_Append(list, new); - Py_DECREF(new); - return i; -} - -static void -remove_subclass(PyTypeObject *base, PyTypeObject *type) -{ - int i; - PyObject *list, *ref; - - list = base->tp_subclasses; - if (list == NULL) { - return; - } - assert(PyList_Check(list)); - i = PyList_GET_SIZE(list); - while (--i >= 0) { - ref = PyList_GET_ITEM(list, i); - assert(PyWeakref_CheckRef(ref)); - if (PyWeakref_GET_OBJECT(ref) == (PyObject*)type) { - /* this can't fail, right? */ - PySequence_DelItem(list, i); - return; - } - } -} - -/* Generic wrappers for overloadable 'operators' such as __getitem__ */ - -/* There's a wrapper *function* for each distinct function typedef used - for type object slots (e.g. binaryfunc, ternaryfunc, etc.). There's a - wrapper *table* for each distinct operation (e.g. __len__, __add__). - Most tables have only one entry; the tables for binary operators have two - entries, one regular and one with reversed arguments. */ - -static PyObject * -wrap_inquiry(PyObject *self, PyObject *args, void *wrapped) -{ - inquiry func = (inquiry)wrapped; - int res; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - res = (*func)(self); - if (res == -1 && PyErr_Occurred()) - return NULL; - return PyInt_FromLong((long)res); -} - -static PyObject * -wrap_inquirypred(PyObject *self, PyObject *args, void *wrapped) -{ - inquiry func = (inquiry)wrapped; - int res; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - res = (*func)(self); - if (res == -1 && PyErr_Occurred()) - return NULL; - return PyBool_FromLong((long)res); -} - -static PyObject * -wrap_binaryfunc(PyObject *self, PyObject *args, void *wrapped) -{ - binaryfunc func = (binaryfunc)wrapped; - PyObject *other; - - if (!PyArg_ParseTuple(args, "O", &other)) - return NULL; - return (*func)(self, other); -} - -static PyObject * -wrap_binaryfunc_l(PyObject *self, PyObject *args, void *wrapped) -{ - binaryfunc func = (binaryfunc)wrapped; - PyObject *other; - - if (!PyArg_ParseTuple(args, "O", &other)) - return NULL; - if (!(self->ob_type->tp_flags & Py_TPFLAGS_CHECKTYPES) && - !PyType_IsSubtype(other->ob_type, self->ob_type)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - return (*func)(self, other); -} - -static PyObject * -wrap_binaryfunc_r(PyObject *self, PyObject *args, void *wrapped) -{ - binaryfunc func = (binaryfunc)wrapped; - PyObject *other; - - if (!PyArg_ParseTuple(args, "O", &other)) - return NULL; - if (!(self->ob_type->tp_flags & Py_TPFLAGS_CHECKTYPES) && - !PyType_IsSubtype(other->ob_type, self->ob_type)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - return (*func)(other, self); -} - -static PyObject * -wrap_coercefunc(PyObject *self, PyObject *args, void *wrapped) -{ - coercion func = (coercion)wrapped; - PyObject *other, *res; - int ok; - - if (!PyArg_ParseTuple(args, "O", &other)) - return NULL; - ok = func(&self, &other); - if (ok < 0) - return NULL; - if (ok > 0) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - res = PyTuple_New(2); - if (res == NULL) { - Py_DECREF(self); - Py_DECREF(other); - return NULL; - } - PyTuple_SET_ITEM(res, 0, self); - PyTuple_SET_ITEM(res, 1, other); - return res; -} - -static PyObject * -wrap_ternaryfunc(PyObject *self, PyObject *args, void *wrapped) -{ - ternaryfunc func = (ternaryfunc)wrapped; - PyObject *other; - PyObject *third = Py_None; - - /* Note: This wrapper only works for __pow__() */ - - if (!PyArg_ParseTuple(args, "O|O", &other, &third)) - return NULL; - return (*func)(self, other, third); -} - -static PyObject * -wrap_ternaryfunc_r(PyObject *self, PyObject *args, void *wrapped) -{ - ternaryfunc func = (ternaryfunc)wrapped; - PyObject *other; - PyObject *third = Py_None; - - /* Note: This wrapper only works for __pow__() */ - - if (!PyArg_ParseTuple(args, "O|O", &other, &third)) - return NULL; - return (*func)(other, self, third); -} - -static PyObject * -wrap_unaryfunc(PyObject *self, PyObject *args, void *wrapped) -{ - unaryfunc func = (unaryfunc)wrapped; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - return (*func)(self); -} - -static PyObject * -wrap_intargfunc(PyObject *self, PyObject *args, void *wrapped) -{ - intargfunc func = (intargfunc)wrapped; - int i; - - if (!PyArg_ParseTuple(args, "i", &i)) - return NULL; - return (*func)(self, i); -} - -static int -getindex(PyObject *self, PyObject *arg) -{ - int i; - - i = PyInt_AsLong(arg); - if (i == -1 && PyErr_Occurred()) - return -1; - if (i < 0) { - PySequenceMethods *sq = self->ob_type->tp_as_sequence; - if (sq && sq->sq_length) { - int n = (*sq->sq_length)(self); - if (n < 0) - return -1; - i += n; - } - } - return i; -} - -static PyObject * -wrap_sq_item(PyObject *self, PyObject *args, void *wrapped) -{ - intargfunc func = (intargfunc)wrapped; - PyObject *arg; - int i; - - if (PyTuple_GET_SIZE(args) == 1) { - arg = PyTuple_GET_ITEM(args, 0); - i = getindex(self, arg); - if (i == -1 && PyErr_Occurred()) - return NULL; - return (*func)(self, i); - } - PyArg_ParseTuple(args, "O", &arg); - assert(PyErr_Occurred()); - return NULL; -} - -static PyObject * -wrap_intintargfunc(PyObject *self, PyObject *args, void *wrapped) -{ - intintargfunc func = (intintargfunc)wrapped; - int i, j; - - if (!PyArg_ParseTuple(args, "ii", &i, &j)) - return NULL; - return (*func)(self, i, j); -} - -static PyObject * -wrap_sq_setitem(PyObject *self, PyObject *args, void *wrapped) -{ - intobjargproc func = (intobjargproc)wrapped; - int i, res; - PyObject *arg, *value; - - if (!PyArg_ParseTuple(args, "OO", &arg, &value)) - return NULL; - i = getindex(self, arg); - if (i == -1 && PyErr_Occurred()) - return NULL; - res = (*func)(self, i, value); - if (res == -1 && PyErr_Occurred()) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -wrap_sq_delitem(PyObject *self, PyObject *args, void *wrapped) -{ - intobjargproc func = (intobjargproc)wrapped; - int i, res; - PyObject *arg; - - if (!PyArg_ParseTuple(args, "O", &arg)) - return NULL; - i = getindex(self, arg); - if (i == -1 && PyErr_Occurred()) - return NULL; - res = (*func)(self, i, NULL); - if (res == -1 && PyErr_Occurred()) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -wrap_intintobjargproc(PyObject *self, PyObject *args, void *wrapped) -{ - intintobjargproc func = (intintobjargproc)wrapped; - int i, j, res; - PyObject *value; - - if (!PyArg_ParseTuple(args, "iiO", &i, &j, &value)) - return NULL; - res = (*func)(self, i, j, value); - if (res == -1 && PyErr_Occurred()) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -wrap_delslice(PyObject *self, PyObject *args, void *wrapped) -{ - intintobjargproc func = (intintobjargproc)wrapped; - int i, j, res; - - if (!PyArg_ParseTuple(args, "ii", &i, &j)) - return NULL; - res = (*func)(self, i, j, NULL); - if (res == -1 && PyErr_Occurred()) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -/* XXX objobjproc is a misnomer; should be objargpred */ -static PyObject * -wrap_objobjproc(PyObject *self, PyObject *args, void *wrapped) -{ - objobjproc func = (objobjproc)wrapped; - int res; - PyObject *value; - - if (!PyArg_ParseTuple(args, "O", &value)) - return NULL; - res = (*func)(self, value); - if (res == -1 && PyErr_Occurred()) - return NULL; - else - return PyBool_FromLong(res); -} - -static PyObject * -wrap_objobjargproc(PyObject *self, PyObject *args, void *wrapped) -{ - objobjargproc func = (objobjargproc)wrapped; - int res; - PyObject *key, *value; - - if (!PyArg_ParseTuple(args, "OO", &key, &value)) - return NULL; - res = (*func)(self, key, value); - if (res == -1 && PyErr_Occurred()) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -wrap_delitem(PyObject *self, PyObject *args, void *wrapped) -{ - objobjargproc func = (objobjargproc)wrapped; - int res; - PyObject *key; - - if (!PyArg_ParseTuple(args, "O", &key)) - return NULL; - res = (*func)(self, key, NULL); - if (res == -1 && PyErr_Occurred()) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -wrap_cmpfunc(PyObject *self, PyObject *args, void *wrapped) -{ - cmpfunc func = (cmpfunc)wrapped; - int res; - PyObject *other; - - if (!PyArg_ParseTuple(args, "O", &other)) - return NULL; - if (other->ob_type->tp_compare != func && - !PyType_IsSubtype(other->ob_type, self->ob_type)) { - PyErr_Format( - PyExc_TypeError, - "%s.__cmp__(x,y) requires y to be a '%s', not a '%s'", - self->ob_type->tp_name, - self->ob_type->tp_name, - other->ob_type->tp_name); - return NULL; - } - res = (*func)(self, other); - if (PyErr_Occurred()) - return NULL; - return PyInt_FromLong((long)res); -} - -/* Helper to check for object.__setattr__ or __delattr__ applied to a type. - This is called the Carlo Verre hack after its discoverer. */ -static int -hackcheck(PyObject *self, setattrofunc func, char *what) -{ - PyTypeObject *type = self->ob_type; - while (type && type->tp_flags & Py_TPFLAGS_HEAPTYPE) - type = type->tp_base; - if (type->tp_setattro != func) { - PyErr_Format(PyExc_TypeError, - "can't apply this %s to %s object", - what, - type->tp_name); - return 0; - } - return 1; -} - -static PyObject * -wrap_setattr(PyObject *self, PyObject *args, void *wrapped) -{ - setattrofunc func = (setattrofunc)wrapped; - int res; - PyObject *name, *value; - - if (!PyArg_ParseTuple(args, "OO", &name, &value)) - return NULL; - if (!hackcheck(self, func, "__setattr__")) - return NULL; - res = (*func)(self, name, value); - if (res < 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -wrap_delattr(PyObject *self, PyObject *args, void *wrapped) -{ - setattrofunc func = (setattrofunc)wrapped; - int res; - PyObject *name; - - if (!PyArg_ParseTuple(args, "O", &name)) - return NULL; - if (!hackcheck(self, func, "__delattr__")) - return NULL; - res = (*func)(self, name, NULL); - if (res < 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -wrap_hashfunc(PyObject *self, PyObject *args, void *wrapped) -{ - hashfunc func = (hashfunc)wrapped; - long res; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - res = (*func)(self); - if (res == -1 && PyErr_Occurred()) - return NULL; - return PyInt_FromLong(res); -} - -static PyObject * -wrap_call(PyObject *self, PyObject *args, void *wrapped, PyObject *kwds) -{ - ternaryfunc func = (ternaryfunc)wrapped; - - return (*func)(self, args, kwds); -} - -static PyObject * -wrap_richcmpfunc(PyObject *self, PyObject *args, void *wrapped, int op) -{ - richcmpfunc func = (richcmpfunc)wrapped; - PyObject *other; - - if (!PyArg_ParseTuple(args, "O", &other)) - return NULL; - return (*func)(self, other, op); -} - -#undef RICHCMP_WRAPPER -#define RICHCMP_WRAPPER(NAME, OP) \ -static PyObject * \ -richcmp_##NAME(PyObject *self, PyObject *args, void *wrapped) \ -{ \ - return wrap_richcmpfunc(self, args, wrapped, OP); \ -} - -RICHCMP_WRAPPER(lt, Py_LT) -RICHCMP_WRAPPER(le, Py_LE) -RICHCMP_WRAPPER(eq, Py_EQ) -RICHCMP_WRAPPER(ne, Py_NE) -RICHCMP_WRAPPER(gt, Py_GT) -RICHCMP_WRAPPER(ge, Py_GE) - -static PyObject * -wrap_next(PyObject *self, PyObject *args, void *wrapped) -{ - unaryfunc func = (unaryfunc)wrapped; - PyObject *res; - - if (!PyArg_ParseTuple(args, "")) - return NULL; - res = (*func)(self); - if (res == NULL && !PyErr_Occurred()) - PyErr_SetNone(PyExc_StopIteration); - return res; -} - -static PyObject * -wrap_descr_get(PyObject *self, PyObject *args, void *wrapped) -{ - descrgetfunc func = (descrgetfunc)wrapped; - PyObject *obj; - PyObject *type = NULL; - - if (!PyArg_ParseTuple(args, "O|O", &obj, &type)) - return NULL; - if (obj == Py_None) - obj = NULL; - if (type == Py_None) - type = NULL; - if (type == NULL &&obj == NULL) { - PyErr_SetString(PyExc_TypeError, - "__get__(None, None) is invalid"); - return NULL; - } - return (*func)(self, obj, type); -} - -static PyObject * -wrap_descr_set(PyObject *self, PyObject *args, void *wrapped) -{ - descrsetfunc func = (descrsetfunc)wrapped; - PyObject *obj, *value; - int ret; - - if (!PyArg_ParseTuple(args, "OO", &obj, &value)) - return NULL; - ret = (*func)(self, obj, value); - if (ret < 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -wrap_descr_delete(PyObject *self, PyObject *args, void *wrapped) -{ - descrsetfunc func = (descrsetfunc)wrapped; - PyObject *obj; - int ret; - - if (!PyArg_ParseTuple(args, "O", &obj)) - return NULL; - ret = (*func)(self, obj, NULL); - if (ret < 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -wrap_init(PyObject *self, PyObject *args, void *wrapped, PyObject *kwds) -{ - initproc func = (initproc)wrapped; - - if (func(self, args, kwds) < 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -tp_new_wrapper(PyObject *self, PyObject *args, PyObject *kwds) -{ - PyTypeObject *type, *subtype, *staticbase; - PyObject *arg0, *res; - - if (self == NULL || !PyType_Check(self)) - Py_FatalError("__new__() called with non-type 'self'"); - type = (PyTypeObject *)self; - if (!PyTuple_Check(args) || PyTuple_GET_SIZE(args) < 1) { - PyErr_Format(PyExc_TypeError, - "%s.__new__(): not enough arguments", - type->tp_name); - return NULL; - } - arg0 = PyTuple_GET_ITEM(args, 0); - if (!PyType_Check(arg0)) { - PyErr_Format(PyExc_TypeError, - "%s.__new__(X): X is not a type object (%s)", - type->tp_name, - arg0->ob_type->tp_name); - return NULL; - } - subtype = (PyTypeObject *)arg0; - if (!PyType_IsSubtype(subtype, type)) { - PyErr_Format(PyExc_TypeError, - "%s.__new__(%s): %s is not a subtype of %s", - type->tp_name, - subtype->tp_name, - subtype->tp_name, - type->tp_name); - return NULL; - } - - /* Check that the use doesn't do something silly and unsafe like - object.__new__(dict). To do this, we check that the - most derived base that's not a heap type is this type. */ - staticbase = subtype; - while (staticbase && (staticbase->tp_flags & Py_TPFLAGS_HEAPTYPE)) - staticbase = staticbase->tp_base; - if (staticbase->tp_new != type->tp_new) { - PyErr_Format(PyExc_TypeError, - "%s.__new__(%s) is not safe, use %s.__new__()", - type->tp_name, - subtype->tp_name, - staticbase == NULL ? "?" : staticbase->tp_name); - return NULL; - } - - args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args)); - if (args == NULL) - return NULL; - res = type->tp_new(subtype, args, kwds); - Py_DECREF(args); - return res; -} - -static struct PyMethodDef tp_new_methoddef[] = { - {"__new__", (PyCFunction)tp_new_wrapper, METH_KEYWORDS, - PyDoc_STR("T.__new__(S, ...) -> " - "a new object with type S, a subtype of T")}, - {0} -}; - -static int -add_tp_new_wrapper(PyTypeObject *type) -{ - PyObject *func; - - if (PyDict_GetItemString(type->tp_dict, "__new__") != NULL) - return 0; - func = PyCFunction_New(tp_new_methoddef, (PyObject *)type); - if (func == NULL) - return -1; - return PyDict_SetItemString(type->tp_dict, "__new__", func); -} - -/* Slot wrappers that call the corresponding __foo__ slot. See comments - below at override_slots() for more explanation. */ - -#define SLOT0(FUNCNAME, OPSTR) \ -static PyObject * \ -FUNCNAME(PyObject *self) \ -{ \ - static PyObject *cache_str; \ - return call_method(self, OPSTR, &cache_str, "()"); \ -} - -#define SLOT1(FUNCNAME, OPSTR, ARG1TYPE, ARGCODES) \ -static PyObject * \ -FUNCNAME(PyObject *self, ARG1TYPE arg1) \ -{ \ - static PyObject *cache_str; \ - return call_method(self, OPSTR, &cache_str, "(" ARGCODES ")", arg1); \ -} - -/* Boolean helper for SLOT1BINFULL(). - right.__class__ is a nontrivial subclass of left.__class__. */ -static int -method_is_overloaded(PyObject *left, PyObject *right, char *name) -{ - PyObject *a, *b; - int ok; - - b = PyObject_GetAttrString((PyObject *)(right->ob_type), name); - if (b == NULL) { - PyErr_Clear(); - /* If right doesn't have it, it's not overloaded */ - return 0; - } - - a = PyObject_GetAttrString((PyObject *)(left->ob_type), name); - if (a == NULL) { - PyErr_Clear(); - Py_DECREF(b); - /* If right has it but left doesn't, it's overloaded */ - return 1; - } - - ok = PyObject_RichCompareBool(a, b, Py_NE); - Py_DECREF(a); - Py_DECREF(b); - if (ok < 0) { - PyErr_Clear(); - return 0; - } - - return ok; -} - - -#define SLOT1BINFULL(FUNCNAME, TESTFUNC, SLOTNAME, OPSTR, ROPSTR) \ -static PyObject * \ -FUNCNAME(PyObject *self, PyObject *other) \ -{ \ - static PyObject *cache_str, *rcache_str; \ - int do_other = self->ob_type != other->ob_type && \ - other->ob_type->tp_as_number != NULL && \ - other->ob_type->tp_as_number->SLOTNAME == TESTFUNC; \ - if (self->ob_type->tp_as_number != NULL && \ - self->ob_type->tp_as_number->SLOTNAME == TESTFUNC) { \ - PyObject *r; \ - if (do_other && \ - PyType_IsSubtype(other->ob_type, self->ob_type) && \ - method_is_overloaded(self, other, ROPSTR)) { \ - r = call_maybe( \ - other, ROPSTR, &rcache_str, "(O)", self); \ - if (r != Py_NotImplemented) \ - return r; \ - Py_DECREF(r); \ - do_other = 0; \ - } \ - r = call_maybe( \ - self, OPSTR, &cache_str, "(O)", other); \ - if (r != Py_NotImplemented || \ - other->ob_type == self->ob_type) \ - return r; \ - Py_DECREF(r); \ - } \ - if (do_other) { \ - return call_maybe( \ - other, ROPSTR, &rcache_str, "(O)", self); \ - } \ - Py_INCREF(Py_NotImplemented); \ - return Py_NotImplemented; \ -} - -#define SLOT1BIN(FUNCNAME, SLOTNAME, OPSTR, ROPSTR) \ - SLOT1BINFULL(FUNCNAME, FUNCNAME, SLOTNAME, OPSTR, ROPSTR) - -#define SLOT2(FUNCNAME, OPSTR, ARG1TYPE, ARG2TYPE, ARGCODES) \ -static PyObject * \ -FUNCNAME(PyObject *self, ARG1TYPE arg1, ARG2TYPE arg2) \ -{ \ - static PyObject *cache_str; \ - return call_method(self, OPSTR, &cache_str, \ - "(" ARGCODES ")", arg1, arg2); \ -} - -static int -slot_sq_length(PyObject *self) -{ - static PyObject *len_str; - PyObject *res = call_method(self, "__len__", &len_str, "()"); - int len; - - if (res == NULL) - return -1; - len = (int)PyInt_AsLong(res); - Py_DECREF(res); - if (len == -1 && PyErr_Occurred()) - return -1; - if (len < 0) { - PyErr_SetString(PyExc_ValueError, - "__len__() should return >= 0"); - return -1; - } - return len; -} - -SLOT1(slot_sq_concat, "__add__", PyObject *, "O") -SLOT1(slot_sq_repeat, "__mul__", int, "i") - -/* Super-optimized version of slot_sq_item. - Other slots could do the same... */ -static PyObject * -slot_sq_item(PyObject *self, int i) -{ - static PyObject *getitem_str; - PyObject *func, *args = NULL, *ival = NULL, *retval = NULL; - descrgetfunc f; - - if (getitem_str == NULL) { - getitem_str = PyString_InternFromString("__getitem__"); - if (getitem_str == NULL) - return NULL; - } - func = _PyType_Lookup(self->ob_type, getitem_str); - if (func != NULL) { - if ((f = func->ob_type->tp_descr_get) == NULL) - Py_INCREF(func); - else { - func = f(func, self, (PyObject *)(self->ob_type)); - if (func == NULL) { - return NULL; - } - } - ival = PyInt_FromLong(i); - if (ival != NULL) { - args = PyTuple_New(1); - if (args != NULL) { - PyTuple_SET_ITEM(args, 0, ival); - retval = PyObject_Call(func, args, NULL); - Py_XDECREF(args); - Py_XDECREF(func); - return retval; - } - } - } - else { - PyErr_SetObject(PyExc_AttributeError, getitem_str); - } - Py_XDECREF(args); - Py_XDECREF(ival); - Py_XDECREF(func); - return NULL; -} - -SLOT2(slot_sq_slice, "__getslice__", int, int, "ii") - -static int -slot_sq_ass_item(PyObject *self, int index, PyObject *value) -{ - PyObject *res; - static PyObject *delitem_str, *setitem_str; - - if (value == NULL) - res = call_method(self, "__delitem__", &delitem_str, - "(i)", index); - else - res = call_method(self, "__setitem__", &setitem_str, - "(iO)", index, value); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; -} - -static int -slot_sq_ass_slice(PyObject *self, int i, int j, PyObject *value) -{ - PyObject *res; - static PyObject *delslice_str, *setslice_str; - - if (value == NULL) - res = call_method(self, "__delslice__", &delslice_str, - "(ii)", i, j); - else - res = call_method(self, "__setslice__", &setslice_str, - "(iiO)", i, j, value); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; -} - -static int -slot_sq_contains(PyObject *self, PyObject *value) -{ - PyObject *func, *res, *args; - int result = -1; - - static PyObject *contains_str; - - func = lookup_maybe(self, "__contains__", &contains_str); - if (func != NULL) { - args = Py_BuildValue("(O)", value); - if (args == NULL) - res = NULL; - else { - res = PyObject_Call(func, args, NULL); - Py_DECREF(args); - } - Py_DECREF(func); - if (res != NULL) { - result = PyObject_IsTrue(res); - Py_DECREF(res); - } - } - else if (! PyErr_Occurred()) { - result = _PySequence_IterSearch(self, value, - PY_ITERSEARCH_CONTAINS); - } - return result; -} - -SLOT1(slot_sq_inplace_concat, "__iadd__", PyObject *, "O") -SLOT1(slot_sq_inplace_repeat, "__imul__", int, "i") - -#define slot_mp_length slot_sq_length - -SLOT1(slot_mp_subscript, "__getitem__", PyObject *, "O") - -static int -slot_mp_ass_subscript(PyObject *self, PyObject *key, PyObject *value) -{ - PyObject *res; - static PyObject *delitem_str, *setitem_str; - - if (value == NULL) - res = call_method(self, "__delitem__", &delitem_str, - "(O)", key); - else - res = call_method(self, "__setitem__", &setitem_str, - "(OO)", key, value); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; -} - -SLOT1BIN(slot_nb_add, nb_add, "__add__", "__radd__") -SLOT1BIN(slot_nb_subtract, nb_subtract, "__sub__", "__rsub__") -SLOT1BIN(slot_nb_multiply, nb_multiply, "__mul__", "__rmul__") -SLOT1BIN(slot_nb_divide, nb_divide, "__div__", "__rdiv__") -SLOT1BIN(slot_nb_remainder, nb_remainder, "__mod__", "__rmod__") -SLOT1BIN(slot_nb_divmod, nb_divmod, "__divmod__", "__rdivmod__") - -static PyObject *slot_nb_power(PyObject *, PyObject *, PyObject *); - -SLOT1BINFULL(slot_nb_power_binary, slot_nb_power, - nb_power, "__pow__", "__rpow__") - -static PyObject * -slot_nb_power(PyObject *self, PyObject *other, PyObject *modulus) -{ - static PyObject *pow_str; - - if (modulus == Py_None) - return slot_nb_power_binary(self, other); - /* Three-arg power doesn't use __rpow__. But ternary_op - can call this when the second argument's type uses - slot_nb_power, so check before calling self.__pow__. */ - if (self->ob_type->tp_as_number != NULL && - self->ob_type->tp_as_number->nb_power == slot_nb_power) { - return call_method(self, "__pow__", &pow_str, - "(OO)", other, modulus); - } - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; -} - -SLOT0(slot_nb_negative, "__neg__") -SLOT0(slot_nb_positive, "__pos__") -SLOT0(slot_nb_absolute, "__abs__") - -static int -slot_nb_nonzero(PyObject *self) -{ - PyObject *func, *args; - static PyObject *nonzero_str, *len_str; - int result = -1; - - func = lookup_maybe(self, "__nonzero__", &nonzero_str); - if (func == NULL) { - if (PyErr_Occurred()) - return -1; - func = lookup_maybe(self, "__len__", &len_str); - if (func == NULL) - return PyErr_Occurred() ? -1 : 1; - } - args = PyTuple_New(0); - if (args != NULL) { - PyObject *temp = PyObject_Call(func, args, NULL); - Py_DECREF(args); - if (temp != NULL) { - if (PyInt_CheckExact(temp) || PyBool_Check(temp)) - result = PyObject_IsTrue(temp); - else { - PyErr_Format(PyExc_TypeError, - "__nonzero__ should return " - "bool or int, returned %s", - temp->ob_type->tp_name); - result = -1; - } - Py_DECREF(temp); - } - } - Py_DECREF(func); - return result; -} - -SLOT0(slot_nb_invert, "__invert__") -SLOT1BIN(slot_nb_lshift, nb_lshift, "__lshift__", "__rlshift__") -SLOT1BIN(slot_nb_rshift, nb_rshift, "__rshift__", "__rrshift__") -SLOT1BIN(slot_nb_and, nb_and, "__and__", "__rand__") -SLOT1BIN(slot_nb_xor, nb_xor, "__xor__", "__rxor__") -SLOT1BIN(slot_nb_or, nb_or, "__or__", "__ror__") - -static int -slot_nb_coerce(PyObject **a, PyObject **b) -{ - static PyObject *coerce_str; - PyObject *self = *a, *other = *b; - - if (self->ob_type->tp_as_number != NULL && - self->ob_type->tp_as_number->nb_coerce == slot_nb_coerce) { - PyObject *r; - r = call_maybe( - self, "__coerce__", &coerce_str, "(O)", other); - if (r == NULL) - return -1; - if (r == Py_NotImplemented) { - Py_DECREF(r); - } - else { - if (!PyTuple_Check(r) || PyTuple_GET_SIZE(r) != 2) { - PyErr_SetString(PyExc_TypeError, - "__coerce__ didn't return a 2-tuple"); - Py_DECREF(r); - return -1; - } - *a = PyTuple_GET_ITEM(r, 0); - Py_INCREF(*a); - *b = PyTuple_GET_ITEM(r, 1); - Py_INCREF(*b); - Py_DECREF(r); - return 0; - } - } - if (other->ob_type->tp_as_number != NULL && - other->ob_type->tp_as_number->nb_coerce == slot_nb_coerce) { - PyObject *r; - r = call_maybe( - other, "__coerce__", &coerce_str, "(O)", self); - if (r == NULL) - return -1; - if (r == Py_NotImplemented) { - Py_DECREF(r); - return 1; - } - if (!PyTuple_Check(r) || PyTuple_GET_SIZE(r) != 2) { - PyErr_SetString(PyExc_TypeError, - "__coerce__ didn't return a 2-tuple"); - Py_DECREF(r); - return -1; - } - *a = PyTuple_GET_ITEM(r, 1); - Py_INCREF(*a); - *b = PyTuple_GET_ITEM(r, 0); - Py_INCREF(*b); - Py_DECREF(r); - return 0; - } - return 1; -} - -SLOT0(slot_nb_int, "__int__") -SLOT0(slot_nb_long, "__long__") -SLOT0(slot_nb_float, "__float__") -SLOT0(slot_nb_oct, "__oct__") -SLOT0(slot_nb_hex, "__hex__") -SLOT1(slot_nb_inplace_add, "__iadd__", PyObject *, "O") -SLOT1(slot_nb_inplace_subtract, "__isub__", PyObject *, "O") -SLOT1(slot_nb_inplace_multiply, "__imul__", PyObject *, "O") -SLOT1(slot_nb_inplace_divide, "__idiv__", PyObject *, "O") -SLOT1(slot_nb_inplace_remainder, "__imod__", PyObject *, "O") -SLOT1(slot_nb_inplace_power, "__ipow__", PyObject *, "O") -SLOT1(slot_nb_inplace_lshift, "__ilshift__", PyObject *, "O") -SLOT1(slot_nb_inplace_rshift, "__irshift__", PyObject *, "O") -SLOT1(slot_nb_inplace_and, "__iand__", PyObject *, "O") -SLOT1(slot_nb_inplace_xor, "__ixor__", PyObject *, "O") -SLOT1(slot_nb_inplace_or, "__ior__", PyObject *, "O") -SLOT1BIN(slot_nb_floor_divide, nb_floor_divide, - "__floordiv__", "__rfloordiv__") -SLOT1BIN(slot_nb_true_divide, nb_true_divide, "__truediv__", "__rtruediv__") -SLOT1(slot_nb_inplace_floor_divide, "__ifloordiv__", PyObject *, "O") -SLOT1(slot_nb_inplace_true_divide, "__itruediv__", PyObject *, "O") - -static int -half_compare(PyObject *self, PyObject *other) -{ - PyObject *func, *args, *res; - static PyObject *cmp_str; - int c; - - func = lookup_method(self, "__cmp__", &cmp_str); - if (func == NULL) { - PyErr_Clear(); - } - else { - args = Py_BuildValue("(O)", other); - if (args == NULL) - res = NULL; - else { - res = PyObject_Call(func, args, NULL); - Py_DECREF(args); - } - Py_DECREF(func); - if (res != Py_NotImplemented) { - if (res == NULL) - return -2; - c = PyInt_AsLong(res); - Py_DECREF(res); - if (c == -1 && PyErr_Occurred()) - return -2; - return (c < 0) ? -1 : (c > 0) ? 1 : 0; - } - Py_DECREF(res); - } - return 2; -} - -/* This slot is published for the benefit of try_3way_compare in object.c */ -int -_PyObject_SlotCompare(PyObject *self, PyObject *other) -{ - int c; - - if (self->ob_type->tp_compare == _PyObject_SlotCompare) { - c = half_compare(self, other); - if (c <= 1) - return c; - } - if (other->ob_type->tp_compare == _PyObject_SlotCompare) { - c = half_compare(other, self); - if (c < -1) - return -2; - if (c <= 1) - return -c; - } - return (void *)self < (void *)other ? -1 : - (void *)self > (void *)other ? 1 : 0; -} - -static PyObject * -slot_tp_repr(PyObject *self) -{ - PyObject *func, *res; - static PyObject *repr_str; - - func = lookup_method(self, "__repr__", &repr_str); - if (func != NULL) { - res = PyEval_CallObject(func, NULL); - Py_DECREF(func); - return res; - } - PyErr_Clear(); - return PyString_FromFormat("<%s object at %p>", - self->ob_type->tp_name, self); -} - -static PyObject * -slot_tp_str(PyObject *self) -{ - PyObject *func, *res; - static PyObject *str_str; - - func = lookup_method(self, "__str__", &str_str); - if (func != NULL) { - res = PyEval_CallObject(func, NULL); - Py_DECREF(func); - return res; - } - else { - PyErr_Clear(); - return slot_tp_repr(self); - } -} - -static long -slot_tp_hash(PyObject *self) -{ - PyObject *func; - static PyObject *hash_str, *eq_str, *cmp_str; - long h; - - func = lookup_method(self, "__hash__", &hash_str); - - if (func != NULL) { - PyObject *res = PyEval_CallObject(func, NULL); - Py_DECREF(func); - if (res == NULL) - return -1; - h = PyInt_AsLong(res); - Py_DECREF(res); - } - else { - PyErr_Clear(); - func = lookup_method(self, "__eq__", &eq_str); - if (func == NULL) { - PyErr_Clear(); - func = lookup_method(self, "__cmp__", &cmp_str); - } - if (func != NULL) { - Py_DECREF(func); - PyErr_SetString(PyExc_TypeError, "unhashable type"); - return -1; - } - PyErr_Clear(); - h = _Py_HashPointer((void *)self); - } - if (h == -1 && !PyErr_Occurred()) - h = -2; - return h; -} - -static PyObject * -slot_tp_call(PyObject *self, PyObject *args, PyObject *kwds) -{ - static PyObject *call_str; - PyObject *meth = lookup_method(self, "__call__", &call_str); - PyObject *res; - - if (meth == NULL) - return NULL; - res = PyObject_Call(meth, args, kwds); - Py_DECREF(meth); - return res; -} - -/* There are two slot dispatch functions for tp_getattro. - - - slot_tp_getattro() is used when __getattribute__ is overridden - but no __getattr__ hook is present; - - - slot_tp_getattr_hook() is used when a __getattr__ hook is present. - - The code in update_one_slot() always installs slot_tp_getattr_hook(); this - detects the absence of __getattr__ and then installs the simpler slot if - necessary. */ - -static PyObject * -slot_tp_getattro(PyObject *self, PyObject *name) -{ - static PyObject *getattribute_str = NULL; - return call_method(self, "__getattribute__", &getattribute_str, - "(O)", name); -} - -static PyObject * -slot_tp_getattr_hook(PyObject *self, PyObject *name) -{ - PyTypeObject *tp = self->ob_type; - PyObject *getattr, *getattribute, *res; - static PyObject *getattribute_str = NULL; - static PyObject *getattr_str = NULL; - - if (getattr_str == NULL) { - getattr_str = PyString_InternFromString("__getattr__"); - if (getattr_str == NULL) - return NULL; - } - if (getattribute_str == NULL) { - getattribute_str = - PyString_InternFromString("__getattribute__"); - if (getattribute_str == NULL) - return NULL; - } - getattr = _PyType_Lookup(tp, getattr_str); - if (getattr == NULL) { - /* No __getattr__ hook: use a simpler dispatcher */ - tp->tp_getattro = slot_tp_getattro; - return slot_tp_getattro(self, name); - } - getattribute = _PyType_Lookup(tp, getattribute_str); - if (getattribute == NULL || - (getattribute->ob_type == &PyWrapperDescr_Type && - ((PyWrapperDescrObject *)getattribute)->d_wrapped == - (void *)PyObject_GenericGetAttr)) - res = PyObject_GenericGetAttr(self, name); - else - res = PyObject_CallFunction(getattribute, "OO", self, name); - if (res == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Clear(); - res = PyObject_CallFunction(getattr, "OO", self, name); - } - return res; -} - -static int -slot_tp_setattro(PyObject *self, PyObject *name, PyObject *value) -{ - PyObject *res; - static PyObject *delattr_str, *setattr_str; - - if (value == NULL) - res = call_method(self, "__delattr__", &delattr_str, - "(O)", name); - else - res = call_method(self, "__setattr__", &setattr_str, - "(OO)", name, value); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; -} - -/* Map rich comparison operators to their __xx__ namesakes */ -static char *name_op[] = { - "__lt__", - "__le__", - "__eq__", - "__ne__", - "__gt__", - "__ge__", -}; - -static PyObject * -half_richcompare(PyObject *self, PyObject *other, int op) -{ - PyObject *func, *args, *res; - static PyObject *op_str[6]; - - func = lookup_method(self, name_op[op], &op_str[op]); - if (func == NULL) { - PyErr_Clear(); - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - args = Py_BuildValue("(O)", other); - if (args == NULL) - res = NULL; - else { - res = PyObject_Call(func, args, NULL); - Py_DECREF(args); - } - Py_DECREF(func); - return res; -} - -/* Map rich comparison operators to their swapped version, e.g. LT --> GT */ -static int swapped_op[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE}; - -static PyObject * -slot_tp_richcompare(PyObject *self, PyObject *other, int op) -{ - PyObject *res; - - if (self->ob_type->tp_richcompare == slot_tp_richcompare) { - res = half_richcompare(self, other, op); - if (res != Py_NotImplemented) - return res; - Py_DECREF(res); - } - if (other->ob_type->tp_richcompare == slot_tp_richcompare) { - res = half_richcompare(other, self, swapped_op[op]); - if (res != Py_NotImplemented) { - return res; - } - Py_DECREF(res); - } - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; -} - -static PyObject * -slot_tp_iter(PyObject *self) -{ - PyObject *func, *res; - static PyObject *iter_str, *getitem_str; - - func = lookup_method(self, "__iter__", &iter_str); - if (func != NULL) { - PyObject *args; - args = res = PyTuple_New(0); - if (args != NULL) { - res = PyObject_Call(func, args, NULL); - Py_DECREF(args); - } - Py_DECREF(func); - return res; - } - PyErr_Clear(); - func = lookup_method(self, "__getitem__", &getitem_str); - if (func == NULL) { - PyErr_SetString(PyExc_TypeError, - "iteration over non-sequence"); - return NULL; - } - Py_DECREF(func); - return PySeqIter_New(self); -} - -static PyObject * -slot_tp_iternext(PyObject *self) -{ - static PyObject *next_str; - return call_method(self, "next", &next_str, "()"); -} - -static PyObject * -slot_tp_descr_get(PyObject *self, PyObject *obj, PyObject *type) -{ - PyTypeObject *tp = self->ob_type; - PyObject *get; - static PyObject *get_str = NULL; - - if (get_str == NULL) { - get_str = PyString_InternFromString("__get__"); - if (get_str == NULL) - return NULL; - } - get = _PyType_Lookup(tp, get_str); - if (get == NULL) { - /* Avoid further slowdowns */ - if (tp->tp_descr_get == slot_tp_descr_get) - tp->tp_descr_get = NULL; - Py_INCREF(self); - return self; - } - if (obj == NULL) - obj = Py_None; - if (type == NULL) - type = Py_None; - return PyObject_CallFunction(get, "OOO", self, obj, type); -} - -static int -slot_tp_descr_set(PyObject *self, PyObject *target, PyObject *value) -{ - PyObject *res; - static PyObject *del_str, *set_str; - - if (value == NULL) - res = call_method(self, "__delete__", &del_str, - "(O)", target); - else - res = call_method(self, "__set__", &set_str, - "(OO)", target, value); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; -} - -static int -slot_tp_init(PyObject *self, PyObject *args, PyObject *kwds) -{ - static PyObject *init_str; - PyObject *meth = lookup_method(self, "__init__", &init_str); - PyObject *res; - - if (meth == NULL) - return -1; - res = PyObject_Call(meth, args, kwds); - Py_DECREF(meth); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; -} - -static PyObject * -slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - static PyObject *new_str; - PyObject *func; - PyObject *newargs, *x; - int i, n; - - if (new_str == NULL) { - new_str = PyString_InternFromString("__new__"); - if (new_str == NULL) - return NULL; - } - func = PyObject_GetAttr((PyObject *)type, new_str); - if (func == NULL) - return NULL; - assert(PyTuple_Check(args)); - n = PyTuple_GET_SIZE(args); - newargs = PyTuple_New(n+1); - if (newargs == NULL) - return NULL; - Py_INCREF(type); - PyTuple_SET_ITEM(newargs, 0, (PyObject *)type); - for (i = 0; i < n; i++) { - x = PyTuple_GET_ITEM(args, i); - Py_INCREF(x); - PyTuple_SET_ITEM(newargs, i+1, x); - } - x = PyObject_Call(func, newargs, kwds); - Py_DECREF(newargs); - Py_DECREF(func); - return x; -} - -static void -slot_tp_del(PyObject *self) -{ - static PyObject *del_str = NULL; - PyObject *del, *res; - PyObject *error_type, *error_value, *error_traceback; - - /* Temporarily resurrect the object. */ - assert(self->ob_refcnt == 0); - self->ob_refcnt = 1; - - /* Save the current exception, if any. */ - PyErr_Fetch(&error_type, &error_value, &error_traceback); - - /* Execute __del__ method, if any. */ - del = lookup_maybe(self, "__del__", &del_str); - if (del != NULL) { - res = PyEval_CallObject(del, NULL); - if (res == NULL) - PyErr_WriteUnraisable(del); - else - Py_DECREF(res); - Py_DECREF(del); - } - - /* Restore the saved exception. */ - PyErr_Restore(error_type, error_value, error_traceback); - - /* Undo the temporary resurrection; can't use DECREF here, it would - * cause a recursive call. - */ - assert(self->ob_refcnt > 0); - if (--self->ob_refcnt == 0) - return; /* this is the normal path out */ - - /* __del__ resurrected it! Make it look like the original Py_DECREF - * never happened. - */ - { - int refcnt = self->ob_refcnt; - _Py_NewReference(self); - self->ob_refcnt = refcnt; - } - assert(!PyType_IS_GC(self->ob_type) || - _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); - /* If Py_REF_DEBUG, the original decref dropped _Py_RefTotal, but - * _Py_NewReference bumped it again, so that's a wash. - * If Py_TRACE_REFS, _Py_NewReference re-added self to the object - * chain, so no more to do there either. - * If COUNT_ALLOCS, the original decref bumped tp_frees, and - * _Py_NewReference bumped tp_allocs: both of those need to be - * undone. - */ -#ifdef COUNT_ALLOCS - --self->ob_type->tp_frees; - --self->ob_type->tp_allocs; -#endif -} - - -/* Table mapping __foo__ names to tp_foo offsets and slot_tp_foo wrapper - functions. The offsets here are relative to the 'PyHeapTypeObject' - structure, which incorporates the additional structures used for numbers, - sequences and mappings. - Note that multiple names may map to the same slot (e.g. __eq__, - __ne__ etc. all map to tp_richcompare) and one name may map to multiple - slots (e.g. __str__ affects tp_str as well as tp_repr). The table is - terminated with an all-zero entry. (This table is further initialized and - sorted in init_slotdefs() below.) */ - -typedef struct wrapperbase slotdef; - -#undef TPSLOT -#undef FLSLOT -#undef ETSLOT -#undef SQSLOT -#undef MPSLOT -#undef NBSLOT -#undef UNSLOT -#undef IBSLOT -#undef BINSLOT -#undef RBINSLOT - -#define TPSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ - {NAME, offsetof(PyTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \ - PyDoc_STR(DOC)} -#define FLSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC, FLAGS) \ - {NAME, offsetof(PyTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \ - PyDoc_STR(DOC), FLAGS} -#define ETSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ - {NAME, offsetof(PyHeapTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \ - PyDoc_STR(DOC)} -#define SQSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ - ETSLOT(NAME, as_sequence.SLOT, FUNCTION, WRAPPER, DOC) -#define MPSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ - ETSLOT(NAME, as_mapping.SLOT, FUNCTION, WRAPPER, DOC) -#define NBSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ - ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, DOC) -#define UNSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ - ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, \ - "x." NAME "() <==> " DOC) -#define IBSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ - ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, \ - "x." NAME "(y) <==> x" DOC "y") -#define BINSLOT(NAME, SLOT, FUNCTION, DOC) \ - ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_l, \ - "x." NAME "(y) <==> x" DOC "y") -#define RBINSLOT(NAME, SLOT, FUNCTION, DOC) \ - ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_r, \ - "x." NAME "(y) <==> y" DOC "x") - -static slotdef slotdefs[] = { - SQSLOT("__len__", sq_length, slot_sq_length, wrap_inquiry, - "x.__len__() <==> len(x)"), - SQSLOT("__add__", sq_concat, slot_sq_concat, wrap_binaryfunc, - "x.__add__(y) <==> x+y"), - SQSLOT("__mul__", sq_repeat, slot_sq_repeat, wrap_intargfunc, - "x.__mul__(n) <==> x*n"), - SQSLOT("__rmul__", sq_repeat, slot_sq_repeat, wrap_intargfunc, - "x.__rmul__(n) <==> n*x"), - SQSLOT("__getitem__", sq_item, slot_sq_item, wrap_sq_item, - "x.__getitem__(y) <==> x[y]"), - SQSLOT("__getslice__", sq_slice, slot_sq_slice, wrap_intintargfunc, - "x.__getslice__(i, j) <==> x[i:j]\n\ - \n\ - Use of negative indices is not supported."), - SQSLOT("__setitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_setitem, - "x.__setitem__(i, y) <==> x[i]=y"), - SQSLOT("__delitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_delitem, - "x.__delitem__(y) <==> del x[y]"), - SQSLOT("__setslice__", sq_ass_slice, slot_sq_ass_slice, - wrap_intintobjargproc, - "x.__setslice__(i, j, y) <==> x[i:j]=y\n\ - \n\ - Use of negative indices is not supported."), - SQSLOT("__delslice__", sq_ass_slice, slot_sq_ass_slice, wrap_delslice, - "x.__delslice__(i, j) <==> del x[i:j]\n\ - \n\ - Use of negative indices is not supported."), - SQSLOT("__contains__", sq_contains, slot_sq_contains, wrap_objobjproc, - "x.__contains__(y) <==> y in x"), - SQSLOT("__iadd__", sq_inplace_concat, slot_sq_inplace_concat, - wrap_binaryfunc, "x.__iadd__(y) <==> x+=y"), - SQSLOT("__imul__", sq_inplace_repeat, slot_sq_inplace_repeat, - wrap_intargfunc, "x.__imul__(y) <==> x*=y"), - - MPSLOT("__len__", mp_length, slot_mp_length, wrap_inquiry, - "x.__len__() <==> len(x)"), - MPSLOT("__getitem__", mp_subscript, slot_mp_subscript, - wrap_binaryfunc, - "x.__getitem__(y) <==> x[y]"), - MPSLOT("__setitem__", mp_ass_subscript, slot_mp_ass_subscript, - wrap_objobjargproc, - "x.__setitem__(i, y) <==> x[i]=y"), - MPSLOT("__delitem__", mp_ass_subscript, slot_mp_ass_subscript, - wrap_delitem, - "x.__delitem__(y) <==> del x[y]"), - - BINSLOT("__add__", nb_add, slot_nb_add, - "+"), - RBINSLOT("__radd__", nb_add, slot_nb_add, - "+"), - BINSLOT("__sub__", nb_subtract, slot_nb_subtract, - "-"), - RBINSLOT("__rsub__", nb_subtract, slot_nb_subtract, - "-"), - BINSLOT("__mul__", nb_multiply, slot_nb_multiply, - "*"), - RBINSLOT("__rmul__", nb_multiply, slot_nb_multiply, - "*"), - BINSLOT("__div__", nb_divide, slot_nb_divide, - "/"), - RBINSLOT("__rdiv__", nb_divide, slot_nb_divide, - "/"), - BINSLOT("__mod__", nb_remainder, slot_nb_remainder, - "%"), - RBINSLOT("__rmod__", nb_remainder, slot_nb_remainder, - "%"), - BINSLOT("__divmod__", nb_divmod, slot_nb_divmod, - "divmod(x, y)"), - RBINSLOT("__rdivmod__", nb_divmod, slot_nb_divmod, - "divmod(y, x)"), - NBSLOT("__pow__", nb_power, slot_nb_power, wrap_ternaryfunc, - "x.__pow__(y[, z]) <==> pow(x, y[, z])"), - NBSLOT("__rpow__", nb_power, slot_nb_power, wrap_ternaryfunc_r, - "y.__rpow__(x[, z]) <==> pow(x, y[, z])"), - UNSLOT("__neg__", nb_negative, slot_nb_negative, wrap_unaryfunc, "-x"), - UNSLOT("__pos__", nb_positive, slot_nb_positive, wrap_unaryfunc, "+x"), - UNSLOT("__abs__", nb_absolute, slot_nb_absolute, wrap_unaryfunc, - "abs(x)"), - UNSLOT("__nonzero__", nb_nonzero, slot_nb_nonzero, wrap_inquirypred, - "x != 0"), - UNSLOT("__invert__", nb_invert, slot_nb_invert, wrap_unaryfunc, "~x"), - BINSLOT("__lshift__", nb_lshift, slot_nb_lshift, "<<"), - RBINSLOT("__rlshift__", nb_lshift, slot_nb_lshift, "<<"), - BINSLOT("__rshift__", nb_rshift, slot_nb_rshift, ">>"), - RBINSLOT("__rrshift__", nb_rshift, slot_nb_rshift, ">>"), - BINSLOT("__and__", nb_and, slot_nb_and, "&"), - RBINSLOT("__rand__", nb_and, slot_nb_and, "&"), - BINSLOT("__xor__", nb_xor, slot_nb_xor, "^"), - RBINSLOT("__rxor__", nb_xor, slot_nb_xor, "^"), - BINSLOT("__or__", nb_or, slot_nb_or, "|"), - RBINSLOT("__ror__", nb_or, slot_nb_or, "|"), - NBSLOT("__coerce__", nb_coerce, slot_nb_coerce, wrap_coercefunc, - "x.__coerce__(y) <==> coerce(x, y)"), - UNSLOT("__int__", nb_int, slot_nb_int, wrap_unaryfunc, - "int(x)"), - UNSLOT("__long__", nb_long, slot_nb_long, wrap_unaryfunc, - "long(x)"), - UNSLOT("__float__", nb_float, slot_nb_float, wrap_unaryfunc, - "float(x)"), - UNSLOT("__oct__", nb_oct, slot_nb_oct, wrap_unaryfunc, - "oct(x)"), - UNSLOT("__hex__", nb_hex, slot_nb_hex, wrap_unaryfunc, - "hex(x)"), - IBSLOT("__iadd__", nb_inplace_add, slot_nb_inplace_add, - wrap_binaryfunc, "+"), - IBSLOT("__isub__", nb_inplace_subtract, slot_nb_inplace_subtract, - wrap_binaryfunc, "-"), - IBSLOT("__imul__", nb_inplace_multiply, slot_nb_inplace_multiply, - wrap_binaryfunc, "*"), - IBSLOT("__idiv__", nb_inplace_divide, slot_nb_inplace_divide, - wrap_binaryfunc, "/"), - IBSLOT("__imod__", nb_inplace_remainder, slot_nb_inplace_remainder, - wrap_binaryfunc, "%"), - IBSLOT("__ipow__", nb_inplace_power, slot_nb_inplace_power, - wrap_binaryfunc, "**"), - IBSLOT("__ilshift__", nb_inplace_lshift, slot_nb_inplace_lshift, - wrap_binaryfunc, "<<"), - IBSLOT("__irshift__", nb_inplace_rshift, slot_nb_inplace_rshift, - wrap_binaryfunc, ">>"), - IBSLOT("__iand__", nb_inplace_and, slot_nb_inplace_and, - wrap_binaryfunc, "&"), - IBSLOT("__ixor__", nb_inplace_xor, slot_nb_inplace_xor, - wrap_binaryfunc, "^"), - IBSLOT("__ior__", nb_inplace_or, slot_nb_inplace_or, - wrap_binaryfunc, "|"), - BINSLOT("__floordiv__", nb_floor_divide, slot_nb_floor_divide, "//"), - RBINSLOT("__rfloordiv__", nb_floor_divide, slot_nb_floor_divide, "//"), - BINSLOT("__truediv__", nb_true_divide, slot_nb_true_divide, "/"), - RBINSLOT("__rtruediv__", nb_true_divide, slot_nb_true_divide, "/"), - IBSLOT("__ifloordiv__", nb_inplace_floor_divide, - slot_nb_inplace_floor_divide, wrap_binaryfunc, "//"), - IBSLOT("__itruediv__", nb_inplace_true_divide, - slot_nb_inplace_true_divide, wrap_binaryfunc, "/"), - - TPSLOT("__str__", tp_str, slot_tp_str, wrap_unaryfunc, - "x.__str__() <==> str(x)"), - TPSLOT("__str__", tp_print, NULL, NULL, ""), - TPSLOT("__repr__", tp_repr, slot_tp_repr, wrap_unaryfunc, - "x.__repr__() <==> repr(x)"), - TPSLOT("__repr__", tp_print, NULL, NULL, ""), - TPSLOT("__cmp__", tp_compare, _PyObject_SlotCompare, wrap_cmpfunc, - "x.__cmp__(y) <==> cmp(x,y)"), - TPSLOT("__hash__", tp_hash, slot_tp_hash, wrap_hashfunc, - "x.__hash__() <==> hash(x)"), - FLSLOT("__call__", tp_call, slot_tp_call, (wrapperfunc)wrap_call, - "x.__call__(...) <==> x(...)", PyWrapperFlag_KEYWORDS), - TPSLOT("__getattribute__", tp_getattro, slot_tp_getattr_hook, - wrap_binaryfunc, "x.__getattribute__('name') <==> x.name"), - TPSLOT("__getattribute__", tp_getattr, NULL, NULL, ""), - TPSLOT("__getattr__", tp_getattro, slot_tp_getattr_hook, NULL, ""), - TPSLOT("__getattr__", tp_getattr, NULL, NULL, ""), - TPSLOT("__setattr__", tp_setattro, slot_tp_setattro, wrap_setattr, - "x.__setattr__('name', value) <==> x.name = value"), - TPSLOT("__setattr__", tp_setattr, NULL, NULL, ""), - TPSLOT("__delattr__", tp_setattro, slot_tp_setattro, wrap_delattr, - "x.__delattr__('name') <==> del x.name"), - TPSLOT("__delattr__", tp_setattr, NULL, NULL, ""), - TPSLOT("__lt__", tp_richcompare, slot_tp_richcompare, richcmp_lt, - "x.__lt__(y) <==> x x<=y"), - TPSLOT("__eq__", tp_richcompare, slot_tp_richcompare, richcmp_eq, - "x.__eq__(y) <==> x==y"), - TPSLOT("__ne__", tp_richcompare, slot_tp_richcompare, richcmp_ne, - "x.__ne__(y) <==> x!=y"), - TPSLOT("__gt__", tp_richcompare, slot_tp_richcompare, richcmp_gt, - "x.__gt__(y) <==> x>y"), - TPSLOT("__ge__", tp_richcompare, slot_tp_richcompare, richcmp_ge, - "x.__ge__(y) <==> x>=y"), - TPSLOT("__iter__", tp_iter, slot_tp_iter, wrap_unaryfunc, - "x.__iter__() <==> iter(x)"), - TPSLOT("next", tp_iternext, slot_tp_iternext, wrap_next, - "x.next() -> the next value, or raise StopIteration"), - TPSLOT("__get__", tp_descr_get, slot_tp_descr_get, wrap_descr_get, - "descr.__get__(obj[, type]) -> value"), - TPSLOT("__set__", tp_descr_set, slot_tp_descr_set, wrap_descr_set, - "descr.__set__(obj, value)"), - TPSLOT("__delete__", tp_descr_set, slot_tp_descr_set, - wrap_descr_delete, "descr.__delete__(obj)"), - FLSLOT("__init__", tp_init, slot_tp_init, (wrapperfunc)wrap_init, - "x.__init__(...) initializes x; " - "see x.__class__.__doc__ for signature", - PyWrapperFlag_KEYWORDS), - TPSLOT("__new__", tp_new, slot_tp_new, NULL, ""), - TPSLOT("__del__", tp_del, slot_tp_del, NULL, ""), - {NULL} -}; - -/* Given a type pointer and an offset gotten from a slotdef entry, return a - pointer to the actual slot. This is not quite the same as simply adding - the offset to the type pointer, since it takes care to indirect through the - proper indirection pointer (as_buffer, etc.); it returns NULL if the - indirection pointer is NULL. */ -static void ** -slotptr(PyTypeObject *type, int offset) -{ - char *ptr; - - /* Note: this depends on the order of the members of PyHeapTypeObject! */ - assert(offset >= 0); - assert(offset < offsetof(PyHeapTypeObject, as_buffer)); - if (offset >= offsetof(PyHeapTypeObject, as_sequence)) { - ptr = (void *)type->tp_as_sequence; - offset -= offsetof(PyHeapTypeObject, as_sequence); - } - else if (offset >= offsetof(PyHeapTypeObject, as_mapping)) { - ptr = (void *)type->tp_as_mapping; - offset -= offsetof(PyHeapTypeObject, as_mapping); - } - else if (offset >= offsetof(PyHeapTypeObject, as_number)) { - ptr = (void *)type->tp_as_number; - offset -= offsetof(PyHeapTypeObject, as_number); - } - else { - ptr = (void *)type; - } - if (ptr != NULL) - ptr += offset; - return (void **)ptr; -} - -/* Length of array of slotdef pointers used to store slots with the - same __name__. There should be at most MAX_EQUIV-1 slotdef entries with - the same __name__, for any __name__. Since that's a static property, it is - appropriate to declare fixed-size arrays for this. */ -#define MAX_EQUIV 10 - -/* Return a slot pointer for a given name, but ONLY if the attribute has - exactly one slot function. The name must be an interned string. */ -static void ** -resolve_slotdups(PyTypeObject *type, PyObject *name) -{ - /* XXX Maybe this could be optimized more -- but is it worth it? */ - - /* pname and ptrs act as a little cache */ - static PyObject *pname; - static slotdef *ptrs[MAX_EQUIV]; - slotdef *p, **pp; - void **res, **ptr; - - if (pname != name) { - /* Collect all slotdefs that match name into ptrs. */ - pname = name; - pp = ptrs; - for (p = slotdefs; p->name_strobj; p++) { - if (p->name_strobj == name) - *pp++ = p; - } - *pp = NULL; - } - - /* Look in all matching slots of the type; if exactly one of these has - a filled-in slot, return its value. Otherwise return NULL. */ - res = NULL; - for (pp = ptrs; *pp; pp++) { - ptr = slotptr(type, (*pp)->offset); - if (ptr == NULL || *ptr == NULL) - continue; - if (res != NULL) - return NULL; - res = ptr; - } - return res; -} - -/* Common code for update_slots_callback() and fixup_slot_dispatchers(). This - does some incredibly complex thinking and then sticks something into the - slot. (It sees if the adjacent slotdefs for the same slot have conflicting - interests, and then stores a generic wrapper or a specific function into - the slot.) Return a pointer to the next slotdef with a different offset, - because that's convenient for fixup_slot_dispatchers(). */ -static slotdef * -update_one_slot(PyTypeObject *type, slotdef *p) -{ - PyObject *descr; - PyWrapperDescrObject *d; - void *generic = NULL, *specific = NULL; - int use_generic = 0; - int offset = p->offset; - void **ptr = slotptr(type, offset); - - if (ptr == NULL) { - do { - ++p; - } while (p->offset == offset); - return p; - } - do { - descr = _PyType_Lookup(type, p->name_strobj); - if (descr == NULL) - continue; - if (descr->ob_type == &PyWrapperDescr_Type) { - void **tptr = resolve_slotdups(type, p->name_strobj); - if (tptr == NULL || tptr == ptr) - generic = p->function; - d = (PyWrapperDescrObject *)descr; - if (d->d_base->wrapper == p->wrapper && - PyType_IsSubtype(type, d->d_type)) - { - if (specific == NULL || - specific == d->d_wrapped) - specific = d->d_wrapped; - else - use_generic = 1; - } - } - else if (descr->ob_type == &PyCFunction_Type && - PyCFunction_GET_FUNCTION(descr) == - (PyCFunction)tp_new_wrapper && - strcmp(p->name, "__new__") == 0) - { - /* The __new__ wrapper is not a wrapper descriptor, - so must be special-cased differently. - If we don't do this, creating an instance will - always use slot_tp_new which will look up - __new__ in the MRO which will call tp_new_wrapper - which will look through the base classes looking - for a static base and call its tp_new (usually - PyType_GenericNew), after performing various - sanity checks and constructing a new argument - list. Cut all that nonsense short -- this speeds - up instance creation tremendously. */ - specific = (void *)type->tp_new; - /* XXX I'm not 100% sure that there isn't a hole - in this reasoning that requires additional - sanity checks. I'll buy the first person to - point out a bug in this reasoning a beer. */ - } - else { - use_generic = 1; - generic = p->function; - } - } while ((++p)->offset == offset); - if (specific && !use_generic) - *ptr = specific; - else - *ptr = generic; - return p; -} - -/* In the type, update the slots whose slotdefs are gathered in the pp array. - This is a callback for update_subclasses(). */ -static int -update_slots_callback(PyTypeObject *type, void *data) -{ - slotdef **pp = (slotdef **)data; - - for (; *pp; pp++) - update_one_slot(type, *pp); - return 0; -} - -/* Comparison function for qsort() to compare slotdefs by their offset, and - for equal offset by their address (to force a stable sort). */ -static int -slotdef_cmp(const void *aa, const void *bb) -{ - const slotdef *a = (const slotdef *)aa, *b = (const slotdef *)bb; - int c = a->offset - b->offset; - if (c != 0) - return c; - else - return a - b; -} - -/* Initialize the slotdefs table by adding interned string objects for the - names and sorting the entries. */ -static void -init_slotdefs(void) -{ - slotdef *p; - static int initialized = 0; - - if (initialized) - return; - for (p = slotdefs; p->name; p++) { - p->name_strobj = PyString_InternFromString(p->name); - if (!p->name_strobj) - Py_FatalError("Out of memory interning slotdef names"); - } - qsort((void *)slotdefs, (size_t)(p-slotdefs), sizeof(slotdef), - slotdef_cmp); - initialized = 1; -} - -/* Update the slots after assignment to a class (type) attribute. */ -static int -update_slot(PyTypeObject *type, PyObject *name) -{ - slotdef *ptrs[MAX_EQUIV]; - slotdef *p; - slotdef **pp; - int offset; - - init_slotdefs(); - pp = ptrs; - for (p = slotdefs; p->name; p++) { - /* XXX assume name is interned! */ - if (p->name_strobj == name) - *pp++ = p; - } - *pp = NULL; - for (pp = ptrs; *pp; pp++) { - p = *pp; - offset = p->offset; - while (p > slotdefs && (p-1)->offset == offset) - --p; - *pp = p; - } - if (ptrs[0] == NULL) - return 0; /* Not an attribute that affects any slots */ - return update_subclasses(type, name, - update_slots_callback, (void *)ptrs); -} - -/* Store the proper functions in the slot dispatches at class (type) - definition time, based upon which operations the class overrides in its - dict. */ -static void -fixup_slot_dispatchers(PyTypeObject *type) -{ - slotdef *p; - - init_slotdefs(); - for (p = slotdefs; p->name; ) - p = update_one_slot(type, p); -} - -static void -update_all_slots(PyTypeObject* type) -{ - slotdef *p; - - init_slotdefs(); - for (p = slotdefs; p->name; p++) { - /* update_slot returns int but can't actually fail */ - update_slot(type, p->name_strobj); - } -} - -/* recurse_down_subclasses() and update_subclasses() are mutually - recursive functions to call a callback for all subclasses, - but refraining from recursing into subclasses that define 'name'. */ - -static int -update_subclasses(PyTypeObject *type, PyObject *name, - update_callback callback, void *data) -{ - if (callback(type, data) < 0) - return -1; - return recurse_down_subclasses(type, name, callback, data); -} - -static int -recurse_down_subclasses(PyTypeObject *type, PyObject *name, - update_callback callback, void *data) -{ - PyTypeObject *subclass; - PyObject *ref, *subclasses, *dict; - int i, n; - - subclasses = type->tp_subclasses; - if (subclasses == NULL) - return 0; - assert(PyList_Check(subclasses)); - n = PyList_GET_SIZE(subclasses); - for (i = 0; i < n; i++) { - ref = PyList_GET_ITEM(subclasses, i); - assert(PyWeakref_CheckRef(ref)); - subclass = (PyTypeObject *)PyWeakref_GET_OBJECT(ref); - assert(subclass != NULL); - if ((PyObject *)subclass == Py_None) - continue; - assert(PyType_Check(subclass)); - /* Avoid recursing down into unaffected classes */ - dict = subclass->tp_dict; - if (dict != NULL && PyDict_Check(dict) && - PyDict_GetItem(dict, name) != NULL) - continue; - if (update_subclasses(subclass, name, callback, data) < 0) - return -1; - } - return 0; -} - -/* This function is called by PyType_Ready() to populate the type's - dictionary with method descriptors for function slots. For each - function slot (like tp_repr) that's defined in the type, one or more - corresponding descriptors are added in the type's tp_dict dictionary - under the appropriate name (like __repr__). Some function slots - cause more than one descriptor to be added (for example, the nb_add - slot adds both __add__ and __radd__ descriptors) and some function - slots compete for the same descriptor (for example both sq_item and - mp_subscript generate a __getitem__ descriptor). - - In the latter case, the first slotdef entry encoutered wins. Since - slotdef entries are sorted by the offset of the slot in the - PyHeapTypeObject, this gives us some control over disambiguating - between competing slots: the members of PyHeapTypeObject are listed - from most general to least general, so the most general slot is - preferred. In particular, because as_mapping comes before as_sequence, - for a type that defines both mp_subscript and sq_item, mp_subscript - wins. - - This only adds new descriptors and doesn't overwrite entries in - tp_dict that were previously defined. The descriptors contain a - reference to the C function they must call, so that it's safe if they - are copied into a subtype's __dict__ and the subtype has a different - C function in its slot -- calling the method defined by the - descriptor will call the C function that was used to create it, - rather than the C function present in the slot when it is called. - (This is important because a subtype may have a C function in the - slot that calls the method from the dictionary, and we want to avoid - infinite recursion here.) */ - -static int -add_operators(PyTypeObject *type) -{ - PyObject *dict = type->tp_dict; - slotdef *p; - PyObject *descr; - void **ptr; - - init_slotdefs(); - for (p = slotdefs; p->name; p++) { - if (p->wrapper == NULL) - continue; - ptr = slotptr(type, p->offset); - if (!ptr || !*ptr) - continue; - if (PyDict_GetItem(dict, p->name_strobj)) - continue; - descr = PyDescr_NewWrapper(type, p, *ptr); - if (descr == NULL) - return -1; - if (PyDict_SetItem(dict, p->name_strobj, descr) < 0) - return -1; - Py_DECREF(descr); - } - if (type->tp_new != NULL) { - if (add_tp_new_wrapper(type) < 0) - return -1; - } - return 0; -} - - -/* Cooperative 'super' */ - -typedef struct { - PyObject_HEAD - PyTypeObject *type; - PyObject *obj; - PyTypeObject *obj_type; -} superobject; - -static PyMemberDef super_members[] = { - {"__thisclass__", T_OBJECT, offsetof(superobject, type), READONLY, - "the class invoking super()"}, - {"__self__", T_OBJECT, offsetof(superobject, obj), READONLY, - "the instance invoking super(); may be None"}, - {"__self_class__", T_OBJECT, offsetof(superobject, obj_type), READONLY, - "the type of the instance invoking super(); may be None"}, - {0} -}; - -static void -super_dealloc(PyObject *self) -{ - superobject *su = (superobject *)self; - - _PyObject_GC_UNTRACK(self); - Py_XDECREF(su->obj); - Py_XDECREF(su->type); - Py_XDECREF(su->obj_type); - self->ob_type->tp_free(self); -} - -static PyObject * -super_repr(PyObject *self) -{ - superobject *su = (superobject *)self; - - if (su->obj_type) - return PyString_FromFormat( - ", <%s object>>", - su->type ? su->type->tp_name : "NULL", - su->obj_type->tp_name); - else - return PyString_FromFormat( - ", NULL>", - su->type ? su->type->tp_name : "NULL"); -} - -static PyObject * -super_getattro(PyObject *self, PyObject *name) -{ - superobject *su = (superobject *)self; - int skip = su->obj_type == NULL; - - if (!skip) { - /* We want __class__ to return the class of the super object - (i.e. super, or a subclass), not the class of su->obj. */ - skip = (PyString_Check(name) && - PyString_GET_SIZE(name) == 9 && - strcmp(PyString_AS_STRING(name), "__class__") == 0); - } - - if (!skip) { - PyObject *mro, *res, *tmp, *dict; - PyTypeObject *starttype; - descrgetfunc f; - int i, n; - - starttype = su->obj_type; - mro = starttype->tp_mro; - - if (mro == NULL) - n = 0; - else { - assert(PyTuple_Check(mro)); - n = PyTuple_GET_SIZE(mro); - } - for (i = 0; i < n; i++) { - if ((PyObject *)(su->type) == PyTuple_GET_ITEM(mro, i)) - break; - } - i++; - res = NULL; - for (; i < n; i++) { - tmp = PyTuple_GET_ITEM(mro, i); - if (PyType_Check(tmp)) - dict = ((PyTypeObject *)tmp)->tp_dict; - else if (PyClass_Check(tmp)) - dict = ((PyClassObject *)tmp)->cl_dict; - else - continue; - res = PyDict_GetItem(dict, name); - if (res != NULL) { - Py_INCREF(res); - f = res->ob_type->tp_descr_get; - if (f != NULL) { - tmp = f(res, su->obj, - (PyObject *)starttype); - Py_DECREF(res); - res = tmp; - } - return res; - } - } - } - return PyObject_GenericGetAttr(self, name); -} - -static PyTypeObject * -supercheck(PyTypeObject *type, PyObject *obj) -{ - /* Check that a super() call makes sense. Return a type object. - - obj can be a new-style class, or an instance of one: - - - If it is a class, it must be a subclass of 'type'. This case is - used for class methods; the return value is obj. - - - If it is an instance, it must be an instance of 'type'. This is - the normal case; the return value is obj.__class__. - - But... when obj is an instance, we want to allow for the case where - obj->ob_type is not a subclass of type, but obj.__class__ is! - This will allow using super() with a proxy for obj. - */ - - /* Check for first bullet above (special case) */ - if (PyType_Check(obj) && PyType_IsSubtype((PyTypeObject *)obj, type)) { - Py_INCREF(obj); - return (PyTypeObject *)obj; - } - - /* Normal case */ - if (PyType_IsSubtype(obj->ob_type, type)) { - Py_INCREF(obj->ob_type); - return obj->ob_type; - } - else { - /* Try the slow way */ - static PyObject *class_str = NULL; - PyObject *class_attr; - - if (class_str == NULL) { - class_str = PyString_FromString("__class__"); - if (class_str == NULL) - return NULL; - } - - class_attr = PyObject_GetAttr(obj, class_str); - - if (class_attr != NULL && - PyType_Check(class_attr) && - (PyTypeObject *)class_attr != obj->ob_type) - { - int ok = PyType_IsSubtype( - (PyTypeObject *)class_attr, type); - if (ok) - return (PyTypeObject *)class_attr; - } - - if (class_attr == NULL) - PyErr_Clear(); - else - Py_DECREF(class_attr); - } - - PyErr_SetString(PyExc_TypeError, - "super(type, obj): " - "obj must be an instance or subtype of type"); - return NULL; -} - -static PyObject * -super_descr_get(PyObject *self, PyObject *obj, PyObject *type) -{ - superobject *su = (superobject *)self; - superobject *new; - - if (obj == NULL || obj == Py_None || su->obj != NULL) { - /* Not binding to an object, or already bound */ - Py_INCREF(self); - return self; - } - if (su->ob_type != &PySuper_Type) - /* If su is not an instance of a subclass of super, - call its type */ - return PyObject_CallFunction((PyObject *)su->ob_type, - "OO", su->type, obj); - else { - /* Inline the common case */ - PyTypeObject *obj_type = supercheck(su->type, obj); - if (obj_type == NULL) - return NULL; - new = (superobject *)PySuper_Type.tp_new(&PySuper_Type, - NULL, NULL); - if (new == NULL) - return NULL; - Py_INCREF(su->type); - Py_INCREF(obj); - new->type = su->type; - new->obj = obj; - new->obj_type = obj_type; - return (PyObject *)new; - } -} - -static int -super_init(PyObject *self, PyObject *args, PyObject *kwds) -{ - superobject *su = (superobject *)self; - PyTypeObject *type; - PyObject *obj = NULL; - PyTypeObject *obj_type = NULL; - - if (!PyArg_ParseTuple(args, "O!|O:super", &PyType_Type, &type, &obj)) - return -1; - if (obj == Py_None) - obj = NULL; - if (obj != NULL) { - obj_type = supercheck(type, obj); - if (obj_type == NULL) - return -1; - Py_INCREF(obj); - } - Py_INCREF(type); - su->type = type; - su->obj = obj; - su->obj_type = obj_type; - return 0; -} - -PyDoc_STRVAR(super_doc, -"super(type) -> unbound super object\n" -"super(type, obj) -> bound super object; requires isinstance(obj, type)\n" -"super(type, type2) -> bound super object; requires issubclass(type2, type)\n" -"Typical use to call a cooperative superclass method:\n" -"class C(B):\n" -" def meth(self, arg):\n" -" super(C, self).meth(arg)"); - -static int -super_traverse(PyObject *self, visitproc visit, void *arg) -{ - superobject *su = (superobject *)self; - int err; - -#define VISIT(SLOT) \ - if (SLOT) { \ - err = visit((PyObject *)(SLOT), arg); \ - if (err) \ - return err; \ - } - - VISIT(su->obj); - VISIT(su->type); - VISIT(su->obj_type); - -#undef VISIT - - return 0; -} - -PyTypeObject PySuper_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "super", /* tp_name */ - sizeof(superobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - super_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - super_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - super_getattro, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - super_doc, /* tp_doc */ - super_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - super_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - super_descr_get, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - super_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - PyObject_GC_Del, /* tp_free */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/unicodectype.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/unicodectype.c deleted file mode 100644 index ede86130..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/unicodectype.c +++ /dev/null @@ -1,423 +0,0 @@ -/* - Unicode character type helpers. - - Written by Marc-Andre Lemburg (mal@lemburg.com). - Modified for Python 2.0 by Fredrik Lundh (fredrik@pythonware.com) - - Copyright (c) Corporation for National Research Initiatives. - -*/ - -#include "Python.h" -#include "unicodeobject.h" - -#define ALPHA_MASK 0x01 -#define DECIMAL_MASK 0x02 -#define DIGIT_MASK 0x04 -#define LOWER_MASK 0x08 -#define LINEBREAK_MASK 0x10 -#define SPACE_MASK 0x20 -#define TITLE_MASK 0x40 -#define UPPER_MASK 0x80 - -typedef struct { - const unsigned short flags; - const Py_UNICODE upper; - const Py_UNICODE lower; - const Py_UNICODE title; - const unsigned char decimal; - const unsigned char digit; -} _PyUnicode_TypeRecord; - -#include "unicodetype_db.h" - -static const _PyUnicode_TypeRecord * -gettyperecord(Py_UNICODE code) -{ - int index; - - if (code >= 0x110000) - index = 0; - else { - index = index1[(code>>SHIFT)]; - index = index2[(index<flags & LINEBREAK_MASK) != 0; -} - -/* Returns the titlecase Unicode characters corresponding to ch or just - ch if no titlecase mapping is known. */ - -Py_UNICODE _PyUnicode_ToTitlecase(register Py_UNICODE ch) -{ - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); - int delta; - - if (ctype->title) - delta = ctype->title; - else - delta = ctype->upper; - - if (delta >= 32768) - delta -= 65536; - - return ch + delta; -} - -/* Returns 1 for Unicode characters having the category 'Lt', 0 - otherwise. */ - -int _PyUnicode_IsTitlecase(Py_UNICODE ch) -{ - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); - - return (ctype->flags & TITLE_MASK) != 0; -} - -/* Returns the integer decimal (0-9) for Unicode characters having - this property, -1 otherwise. */ - -int _PyUnicode_ToDecimalDigit(Py_UNICODE ch) -{ - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); - - return (ctype->flags & DECIMAL_MASK) ? ctype->decimal : -1; -} - -int _PyUnicode_IsDecimalDigit(Py_UNICODE ch) -{ - if (_PyUnicode_ToDecimalDigit(ch) < 0) - return 0; - return 1; -} - -/* Returns the integer digit (0-9) for Unicode characters having - this property, -1 otherwise. */ - -int _PyUnicode_ToDigit(Py_UNICODE ch) -{ - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); - - return (ctype->flags & DIGIT_MASK) ? ctype->digit : -1; -} - -int _PyUnicode_IsDigit(Py_UNICODE ch) -{ - if (_PyUnicode_ToDigit(ch) < 0) - return 0; - return 1; -} - -/* Returns the numeric value as double for Unicode characters having - this property, -1.0 otherwise. */ - -/* TODO: replace with unicodetype_db.h table */ - -double _PyUnicode_ToNumeric(Py_UNICODE ch) -{ - switch (ch) { - case 0x3007: - return (double) 0; - case 0x09F4: - case 0x215F: - case 0x2160: - case 0x2170: - case 0x3021: - case 0x3280: - return (double) 1; - case 0x00BD: - return (double) 1 / 2; - case 0x2153: - return (double) 1 / 3; - case 0x00BC: - return (double) 1 / 4; - case 0x2155: - return (double) 1 / 5; - case 0x2159: - return (double) 1 / 6; - case 0x215B: - return (double) 1 / 8; - case 0x0BF0: - case 0x1372: - case 0x2169: - case 0x2179: - case 0x2469: - case 0x247D: - case 0x2491: - case 0x277F: - case 0x2789: - case 0x2793: - case 0x3038: - case 0x3289: - return (double) 10; - case 0x0BF1: - case 0x137B: - case 0x216D: - case 0x217D: - return (double) 100; - case 0x0BF2: - case 0x216F: - case 0x217F: - case 0x2180: - return (double) 1000; - case 0x137C: - case 0x2182: - return (double) 10000; - case 0x216A: - case 0x217A: - case 0x246A: - case 0x247E: - case 0x2492: - return (double) 11; - case 0x216B: - case 0x217B: - case 0x246B: - case 0x247F: - case 0x2493: - return (double) 12; - case 0x246C: - case 0x2480: - case 0x2494: - return (double) 13; - case 0x246D: - case 0x2481: - case 0x2495: - return (double) 14; - case 0x246E: - case 0x2482: - case 0x2496: - return (double) 15; - case 0x09F9: - case 0x246F: - case 0x2483: - case 0x2497: - return (double) 16; - case 0x16EE: - case 0x2470: - case 0x2484: - case 0x2498: - return (double) 17; - case 0x16EF: - case 0x2471: - case 0x2485: - case 0x2499: - return (double) 18; - case 0x16F0: - case 0x2472: - case 0x2486: - case 0x249A: - return (double) 19; - case 0x09F5: - case 0x2161: - case 0x2171: - case 0x3022: - case 0x3281: - return (double) 2; - case 0x2154: - return (double) 2 / 3; - case 0x2156: - return (double) 2 / 5; - case 0x1373: - case 0x2473: - case 0x2487: - case 0x249B: - case 0x3039: - return (double) 20; - case 0x09F6: - case 0x2162: - case 0x2172: - case 0x3023: - case 0x3282: - return (double) 3; - case 0x00BE: - return (double) 3 / 4; - case 0x2157: - return (double) 3 / 5; - case 0x215C: - return (double) 3 / 8; - case 0x1374: - case 0x303A: - return (double) 30; - case 0x09F7: - case 0x2163: - case 0x2173: - case 0x3024: - case 0x3283: - return (double) 4; - case 0x2158: - return (double) 4 / 5; - case 0x1375: - return (double) 40; - case 0x2164: - case 0x2174: - case 0x3025: - case 0x3284: - return (double) 5; - case 0x215A: - return (double) 5 / 6; - case 0x215D: - return (double) 5 / 8; - case 0x1376: - case 0x216C: - case 0x217C: - return (double) 50; - case 0x216E: - case 0x217E: - return (double) 500; - case 0x2181: - return (double) 5000; - case 0x2165: - case 0x2175: - case 0x3026: - case 0x3285: - return (double) 6; - case 0x1377: - return (double) 60; - case 0x2166: - case 0x2176: - case 0x3027: - case 0x3286: - return (double) 7; - case 0x215E: - return (double) 7 / 8; - case 0x1378: - return (double) 70; - case 0x2167: - case 0x2177: - case 0x3028: - case 0x3287: - return (double) 8; - case 0x1379: - return (double) 80; - case 0x2168: - case 0x2178: - case 0x3029: - case 0x3288: - return (double) 9; - case 0x137A: - return (double) 90; - default: - return (double) _PyUnicode_ToDigit(ch); - } -} - -int _PyUnicode_IsNumeric(Py_UNICODE ch) -{ - if (_PyUnicode_ToNumeric(ch) < 0.0) - return 0; - return 1; -} - -#ifndef WANT_WCTYPE_FUNCTIONS - -/* Returns 1 for Unicode characters having the bidirectional type - 'WS', 'B' or 'S' or the category 'Zs', 0 otherwise. */ - -int _PyUnicode_IsWhitespace(Py_UNICODE ch) -{ - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); - - return (ctype->flags & SPACE_MASK) != 0; -} - -/* Returns 1 for Unicode characters having the category 'Ll', 0 - otherwise. */ - -int _PyUnicode_IsLowercase(Py_UNICODE ch) -{ - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); - - return (ctype->flags & LOWER_MASK) != 0; -} - -/* Returns 1 for Unicode characters having the category 'Lu', 0 - otherwise. */ - -int _PyUnicode_IsUppercase(Py_UNICODE ch) -{ - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); - - return (ctype->flags & UPPER_MASK) != 0; -} - -/* Returns the uppercase Unicode characters corresponding to ch or just - ch if no uppercase mapping is known. */ - -Py_UNICODE _PyUnicode_ToUppercase(Py_UNICODE ch) -{ - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); - int delta = ctype->upper; - if (delta >= 32768) - delta -= 65536; - return ch + delta; -} - -/* Returns the lowercase Unicode characters corresponding to ch or just - ch if no lowercase mapping is known. */ - -Py_UNICODE _PyUnicode_ToLowercase(Py_UNICODE ch) -{ - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); - int delta = ctype->lower; - if (delta >= 32768) - delta -= 65536; - return ch + delta; -} - -/* Returns 1 for Unicode characters having the category 'Ll', 'Lu', 'Lt', - 'Lo' or 'Lm', 0 otherwise. */ - -int _PyUnicode_IsAlpha(Py_UNICODE ch) -{ - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); - - return (ctype->flags & ALPHA_MASK) != 0; -} - -#else - -/* Export the interfaces using the wchar_t type for portability - reasons: */ - -int _PyUnicode_IsWhitespace(Py_UNICODE ch) -{ - return iswspace(ch); -} - -int _PyUnicode_IsLowercase(Py_UNICODE ch) -{ - return iswlower(ch); -} - -int _PyUnicode_IsUppercase(Py_UNICODE ch) -{ - return iswupper(ch); -} - -Py_UNICODE _PyUnicode_ToLowercase(Py_UNICODE ch) -{ - return towlower(ch); -} - -Py_UNICODE _PyUnicode_ToUppercase(Py_UNICODE ch) -{ - return towupper(ch); -} - -int _PyUnicode_IsAlpha(Py_UNICODE ch) -{ - return iswalpha(ch); -} - -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/unicodeobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/unicodeobject.c deleted file mode 100644 index 6a4ee505..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/unicodeobject.c +++ /dev/null @@ -1,6859 +0,0 @@ -/* - -Unicode implementation based on original code by Fredrik Lundh, -modified by Marc-Andre Lemburg according to the -Unicode Integration Proposal (see file Misc/unicode.txt). - -Copyright (c) Corporation for National Research Initiatives. - --------------------------------------------------------------------- -The original string type implementation is: - - Copyright (c) 1999 by Secret Labs AB - Copyright (c) 1999 by Fredrik Lundh - -By obtaining, using, and/or copying this software and/or its -associated documentation, you agree that you have read, understood, -and will comply with the following terms and conditions: - -Permission to use, copy, modify, and distribute this software and its -associated documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies, and that both that copyright notice and this permission notice -appear in supporting documentation, and that the name of Secret Labs -AB or the author not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR -ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --------------------------------------------------------------------- - -*/ - -#include "Python.h" - -#include "unicodeobject.h" -#include "ucnhash.h" - -#ifdef MS_WINDOWS -#ifdef MS_XBOX -#include -#else -#include -#endif -#endif - -/* Limit for the Unicode object free list */ - -#define MAX_UNICODE_FREELIST_SIZE 1024 - -/* Limit for the Unicode object free list stay alive optimization. - - The implementation will keep allocated Unicode memory intact for - all objects on the free list having a size less than this - limit. This reduces malloc() overhead for small Unicode objects. - - At worst this will result in MAX_UNICODE_FREELIST_SIZE * - (sizeof(PyUnicodeObject) + KEEPALIVE_SIZE_LIMIT + - malloc()-overhead) bytes of unused garbage. - - Setting the limit to 0 effectively turns the feature off. - - Note: This is an experimental feature ! If you get core dumps when - using Unicode objects, turn this feature off. - -*/ - -#define KEEPALIVE_SIZE_LIMIT 9 - -/* Endianness switches; defaults to little endian */ - -#ifdef WORDS_BIGENDIAN -# define BYTEORDER_IS_BIG_ENDIAN -#else -# define BYTEORDER_IS_LITTLE_ENDIAN -#endif - -/* --- Globals ------------------------------------------------------------ - - The globals are initialized by the _PyUnicode_Init() API and should - not be used before calling that API. - -*/ - -/* Free list for Unicode objects */ -static PyUnicodeObject *unicode_freelist; -static int unicode_freelist_size; - -/* The empty Unicode object is shared to improve performance. */ -static PyUnicodeObject *unicode_empty; - -/* Single character Unicode strings in the Latin-1 range are being - shared as well. */ -static PyUnicodeObject *unicode_latin1[256]; - -/* Default encoding to use and assume when NULL is passed as encoding - parameter; it is initialized by _PyUnicode_Init(). - - Always use the PyUnicode_SetDefaultEncoding() and - PyUnicode_GetDefaultEncoding() APIs to access this global. - -*/ -static char unicode_default_encoding[100]; - -Py_UNICODE -PyUnicode_GetMax(void) -{ -#ifdef Py_UNICODE_WIDE - return 0x10FFFF; -#else - /* This is actually an illegal character, so it should - not be passed to unichr. */ - return 0xFFFF; -#endif -} - -/* --- Unicode Object ----------------------------------------------------- */ - -static -int unicode_resize(register PyUnicodeObject *unicode, - int length) -{ - void *oldstr; - - /* Shortcut if there's nothing much to do. */ - if (unicode->length == length) - goto reset; - - /* Resizing shared object (unicode_empty or single character - objects) in-place is not allowed. Use PyUnicode_Resize() - instead ! */ - if (unicode == unicode_empty || - (unicode->length == 1 && - /* MvL said unicode->str[] may be signed. Python generally assumes - * an int contains at least 32 bits, and we don't use more than - * 32 bits even in a UCS4 build, so casting to unsigned int should - * be correct. - */ - (unsigned int)unicode->str[0] < 256U && - unicode_latin1[unicode->str[0]] == unicode)) { - PyErr_SetString(PyExc_SystemError, - "can't resize shared unicode objects"); - return -1; - } - - /* We allocate one more byte to make sure the string is - Ux0000 terminated -- XXX is this needed ? */ - oldstr = unicode->str; - PyMem_RESIZE(unicode->str, Py_UNICODE, length + 1); - if (!unicode->str) { - unicode->str = oldstr; - PyErr_NoMemory(); - return -1; - } - unicode->str[length] = 0; - unicode->length = length; - - reset: - /* Reset the object caches */ - if (unicode->defenc) { - Py_DECREF(unicode->defenc); - unicode->defenc = NULL; - } - unicode->hash = -1; - - return 0; -} - -/* We allocate one more byte to make sure the string is - Ux0000 terminated -- XXX is this needed ? - - XXX This allocator could further be enhanced by assuring that the - free list never reduces its size below 1. - -*/ - -static -PyUnicodeObject *_PyUnicode_New(int length) -{ - register PyUnicodeObject *unicode; - - /* Optimization for empty strings */ - if (length == 0 && unicode_empty != NULL) { - Py_INCREF(unicode_empty); - return unicode_empty; - } - - /* Unicode freelist & memory allocation */ - if (unicode_freelist) { - unicode = unicode_freelist; - unicode_freelist = *(PyUnicodeObject **)unicode; - unicode_freelist_size--; - if (unicode->str) { - /* Keep-Alive optimization: we only upsize the buffer, - never downsize it. */ - if ((unicode->length < length) && - unicode_resize(unicode, length)) { - PyMem_DEL(unicode->str); - goto onError; - } - } - else { - unicode->str = PyMem_NEW(Py_UNICODE, length + 1); - } - PyObject_INIT(unicode, &PyUnicode_Type); - } - else { - unicode = PyObject_New(PyUnicodeObject, &PyUnicode_Type); - if (unicode == NULL) - return NULL; - unicode->str = PyMem_NEW(Py_UNICODE, length + 1); - } - - if (!unicode->str) { - PyErr_NoMemory(); - goto onError; - } - /* Initialize the first element to guard against cases where - * the caller fails before initializing str -- unicode_resize() - * reads str[0], and the Keep-Alive optimization can keep memory - * allocated for str alive across a call to unicode_dealloc(unicode). - * We don't want unicode_resize to read uninitialized memory in - * that case. - */ - unicode->str[0] = 0; - unicode->str[length] = 0; - unicode->length = length; - unicode->hash = -1; - unicode->defenc = NULL; - return unicode; - - onError: - _Py_ForgetReference((PyObject *)unicode); - PyObject_Del(unicode); - return NULL; -} - -static -void unicode_dealloc(register PyUnicodeObject *unicode) -{ - if (PyUnicode_CheckExact(unicode) && - unicode_freelist_size < MAX_UNICODE_FREELIST_SIZE) { - /* Keep-Alive optimization */ - if (unicode->length >= KEEPALIVE_SIZE_LIMIT) { - PyMem_DEL(unicode->str); - unicode->str = NULL; - unicode->length = 0; - } - if (unicode->defenc) { - Py_DECREF(unicode->defenc); - unicode->defenc = NULL; - } - /* Add to free list */ - *(PyUnicodeObject **)unicode = unicode_freelist; - unicode_freelist = unicode; - unicode_freelist_size++; - } - else { - PyMem_DEL(unicode->str); - Py_XDECREF(unicode->defenc); - unicode->ob_type->tp_free((PyObject *)unicode); - } -} - -int PyUnicode_Resize(PyObject **unicode, - int length) -{ - register PyUnicodeObject *v; - - /* Argument checks */ - if (unicode == NULL) { - PyErr_BadInternalCall(); - return -1; - } - v = (PyUnicodeObject *)*unicode; - if (v == NULL || !PyUnicode_Check(v) || v->ob_refcnt != 1 || length < 0) { - PyErr_BadInternalCall(); - return -1; - } - - /* Resizing unicode_empty and single character objects is not - possible since these are being shared. We simply return a fresh - copy with the same Unicode content. */ - if (v->length != length && - (v == unicode_empty || v->length == 1)) { - PyUnicodeObject *w = _PyUnicode_New(length); - if (w == NULL) - return -1; - Py_UNICODE_COPY(w->str, v->str, - length < v->length ? length : v->length); - Py_DECREF(*unicode); - *unicode = (PyObject *)w; - return 0; - } - - /* Note that we don't have to modify *unicode for unshared Unicode - objects, since we can modify them in-place. */ - return unicode_resize(v, length); -} - -/* Internal API for use in unicodeobject.c only ! */ -#define _PyUnicode_Resize(unicodevar, length) \ - PyUnicode_Resize(((PyObject **)(unicodevar)), length) - -PyObject *PyUnicode_FromUnicode(const Py_UNICODE *u, - int size) -{ - PyUnicodeObject *unicode; - - /* If the Unicode data is known at construction time, we can apply - some optimizations which share commonly used objects. */ - if (u != NULL) { - - /* Optimization for empty strings */ - if (size == 0 && unicode_empty != NULL) { - Py_INCREF(unicode_empty); - return (PyObject *)unicode_empty; - } - - /* Single character Unicode objects in the Latin-1 range are - shared when using this constructor */ - if (size == 1 && *u < 256) { - unicode = unicode_latin1[*u]; - if (!unicode) { - unicode = _PyUnicode_New(1); - if (!unicode) - return NULL; - unicode->str[0] = *u; - unicode_latin1[*u] = unicode; - } - Py_INCREF(unicode); - return (PyObject *)unicode; - } - } - - unicode = _PyUnicode_New(size); - if (!unicode) - return NULL; - - /* Copy the Unicode data into the new object */ - if (u != NULL) - Py_UNICODE_COPY(unicode->str, u, size); - - return (PyObject *)unicode; -} - -#ifdef HAVE_WCHAR_H - -PyObject *PyUnicode_FromWideChar(register const wchar_t *w, - int size) -{ - PyUnicodeObject *unicode; - - if (w == NULL) { - PyErr_BadInternalCall(); - return NULL; - } - - unicode = _PyUnicode_New(size); - if (!unicode) - return NULL; - - /* Copy the wchar_t data into the new object */ -#ifdef HAVE_USABLE_WCHAR_T - memcpy(unicode->str, w, size * sizeof(wchar_t)); -#else - { - register Py_UNICODE *u; - register int i; - u = PyUnicode_AS_UNICODE(unicode); - for (i = size; i >= 0; i--) - *u++ = *w++; - } -#endif - - return (PyObject *)unicode; -} - -int PyUnicode_AsWideChar(PyUnicodeObject *unicode, - register wchar_t *w, - int size) -{ - if (unicode == NULL) { - PyErr_BadInternalCall(); - return -1; - } - if (size > PyUnicode_GET_SIZE(unicode)) - size = PyUnicode_GET_SIZE(unicode); -#ifdef HAVE_USABLE_WCHAR_T - memcpy(w, unicode->str, size * sizeof(wchar_t)); -#else - { - register Py_UNICODE *u; - register int i; - u = PyUnicode_AS_UNICODE(unicode); - for (i = size; i >= 0; i--) - *w++ = *u++; - } -#endif - - return size; -} - -#endif - -PyObject *PyUnicode_FromOrdinal(int ordinal) -{ - Py_UNICODE s[2]; - -#ifdef Py_UNICODE_WIDE - if (ordinal < 0 || ordinal > 0x10ffff) { - PyErr_SetString(PyExc_ValueError, - "unichr() arg not in range(0x110000) " - "(wide Python build)"); - return NULL; - } -#else - if (ordinal < 0 || ordinal > 0xffff) { - PyErr_SetString(PyExc_ValueError, - "unichr() arg not in range(0x10000) " - "(narrow Python build)"); - return NULL; - } -#endif - - if (ordinal <= 0xffff) { - /* UCS-2 character */ - s[0] = (Py_UNICODE) ordinal; - return PyUnicode_FromUnicode(s, 1); - } - else { -#ifndef Py_UNICODE_WIDE - /* UCS-4 character. store as two surrogate characters */ - ordinal -= 0x10000L; - s[0] = 0xD800 + (Py_UNICODE) (ordinal >> 10); - s[1] = 0xDC00 + (Py_UNICODE) (ordinal & 0x03FF); - return PyUnicode_FromUnicode(s, 2); -#else - s[0] = (Py_UNICODE)ordinal; - return PyUnicode_FromUnicode(s, 1); -#endif - } -} - -PyObject *PyUnicode_FromObject(register PyObject *obj) -{ - /* XXX Perhaps we should make this API an alias of - PyObject_Unicode() instead ?! */ - if (PyUnicode_CheckExact(obj)) { - Py_INCREF(obj); - return obj; - } - if (PyUnicode_Check(obj)) { - /* For a Unicode subtype that's not a Unicode object, - return a true Unicode object with the same data. */ - return PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(obj), - PyUnicode_GET_SIZE(obj)); - } - return PyUnicode_FromEncodedObject(obj, NULL, "strict"); -} - -PyObject *PyUnicode_FromEncodedObject(register PyObject *obj, - const char *encoding, - const char *errors) -{ - const char *s = NULL; - int len; - PyObject *v; - - if (obj == NULL) { - PyErr_BadInternalCall(); - return NULL; - } - -#if 0 - /* For b/w compatibility we also accept Unicode objects provided - that no encodings is given and then redirect to - PyObject_Unicode() which then applies the additional logic for - Unicode subclasses. - - NOTE: This API should really only be used for object which - represent *encoded* Unicode ! - - */ - if (PyUnicode_Check(obj)) { - if (encoding) { - PyErr_SetString(PyExc_TypeError, - "decoding Unicode is not supported"); - return NULL; - } - return PyObject_Unicode(obj); - } -#else - if (PyUnicode_Check(obj)) { - PyErr_SetString(PyExc_TypeError, - "decoding Unicode is not supported"); - return NULL; - } -#endif - - /* Coerce object */ - if (PyString_Check(obj)) { - s = PyString_AS_STRING(obj); - len = PyString_GET_SIZE(obj); - } - else if (PyObject_AsCharBuffer(obj, &s, &len)) { - /* Overwrite the error message with something more useful in - case of a TypeError. */ - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_Format(PyExc_TypeError, - "coercing to Unicode: need string or buffer, " - "%.80s found", - obj->ob_type->tp_name); - goto onError; - } - - /* Convert to Unicode */ - if (len == 0) { - Py_INCREF(unicode_empty); - v = (PyObject *)unicode_empty; - } - else - v = PyUnicode_Decode(s, len, encoding, errors); - - return v; - - onError: - return NULL; -} - -PyObject *PyUnicode_Decode(const char *s, - int size, - const char *encoding, - const char *errors) -{ - PyObject *buffer = NULL, *unicode; - - if (encoding == NULL) - encoding = PyUnicode_GetDefaultEncoding(); - - /* Shortcuts for common default encodings */ - if (strcmp(encoding, "utf-8") == 0) - return PyUnicode_DecodeUTF8(s, size, errors); - else if (strcmp(encoding, "latin-1") == 0) - return PyUnicode_DecodeLatin1(s, size, errors); -#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) - else if (strcmp(encoding, "mbcs") == 0) - return PyUnicode_DecodeMBCS(s, size, errors); -#endif - else if (strcmp(encoding, "ascii") == 0) - return PyUnicode_DecodeASCII(s, size, errors); - - /* Decode via the codec registry */ - buffer = PyBuffer_FromMemory((void *)s, size); - if (buffer == NULL) - goto onError; - unicode = PyCodec_Decode(buffer, encoding, errors); - if (unicode == NULL) - goto onError; - if (!PyUnicode_Check(unicode)) { - PyErr_Format(PyExc_TypeError, - "decoder did not return an unicode object (type=%.400s)", - unicode->ob_type->tp_name); - Py_DECREF(unicode); - goto onError; - } - Py_DECREF(buffer); - return unicode; - - onError: - Py_XDECREF(buffer); - return NULL; -} - -PyObject *PyUnicode_Encode(const Py_UNICODE *s, - int size, - const char *encoding, - const char *errors) -{ - PyObject *v, *unicode; - - unicode = PyUnicode_FromUnicode(s, size); - if (unicode == NULL) - return NULL; - v = PyUnicode_AsEncodedString(unicode, encoding, errors); - Py_DECREF(unicode); - return v; -} - -PyObject *PyUnicode_AsEncodedString(PyObject *unicode, - const char *encoding, - const char *errors) -{ - PyObject *v; - - if (!PyUnicode_Check(unicode)) { - PyErr_BadArgument(); - goto onError; - } - - if (encoding == NULL) - encoding = PyUnicode_GetDefaultEncoding(); - - /* Shortcuts for common default encodings */ - if (errors == NULL) { - if (strcmp(encoding, "utf-8") == 0) - return PyUnicode_AsUTF8String(unicode); - else if (strcmp(encoding, "latin-1") == 0) - return PyUnicode_AsLatin1String(unicode); -#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) - else if (strcmp(encoding, "mbcs") == 0) - return PyUnicode_AsMBCSString(unicode); -#endif - else if (strcmp(encoding, "ascii") == 0) - return PyUnicode_AsASCIIString(unicode); - } - - /* Encode via the codec registry */ - v = PyCodec_Encode(unicode, encoding, errors); - if (v == NULL) - goto onError; - /* XXX Should we really enforce this ? */ - if (!PyString_Check(v)) { - PyErr_Format(PyExc_TypeError, - "encoder did not return a string object (type=%.400s)", - v->ob_type->tp_name); - Py_DECREF(v); - goto onError; - } - return v; - - onError: - return NULL; -} - -PyObject *_PyUnicode_AsDefaultEncodedString(PyObject *unicode, - const char *errors) -{ - PyObject *v = ((PyUnicodeObject *)unicode)->defenc; - - if (v) - return v; - v = PyUnicode_AsEncodedString(unicode, NULL, errors); - if (v && errors == NULL) - ((PyUnicodeObject *)unicode)->defenc = v; - return v; -} - -Py_UNICODE *PyUnicode_AsUnicode(PyObject *unicode) -{ - if (!PyUnicode_Check(unicode)) { - PyErr_BadArgument(); - goto onError; - } - return PyUnicode_AS_UNICODE(unicode); - - onError: - return NULL; -} - -int PyUnicode_GetSize(PyObject *unicode) -{ - if (!PyUnicode_Check(unicode)) { - PyErr_BadArgument(); - goto onError; - } - return PyUnicode_GET_SIZE(unicode); - - onError: - return -1; -} - -const char *PyUnicode_GetDefaultEncoding(void) -{ - return unicode_default_encoding; -} - -int PyUnicode_SetDefaultEncoding(const char *encoding) -{ - PyObject *v; - - /* Make sure the encoding is valid. As side effect, this also - loads the encoding into the codec registry cache. */ - v = _PyCodec_Lookup(encoding); - if (v == NULL) - goto onError; - Py_DECREF(v); - strncpy(unicode_default_encoding, - encoding, - sizeof(unicode_default_encoding)); - return 0; - - onError: - return -1; -} - -/* error handling callback helper: - build arguments, call the callback and check the arguments, - if no exception occured, copy the replacement to the output - and adjust various state variables. - return 0 on success, -1 on error -*/ - -static -int unicode_decode_call_errorhandler(const char *errors, PyObject **errorHandler, - const char *encoding, const char *reason, - const char *input, int insize, int *startinpos, int *endinpos, PyObject **exceptionObject, const char **inptr, - PyObject **output, int *outpos, Py_UNICODE **outptr) -{ - static char *argparse = "O!i;decoding error handler must return (unicode, int) tuple"; - - PyObject *restuple = NULL; - PyObject *repunicode = NULL; - int outsize = PyUnicode_GET_SIZE(*output); - int requiredsize; - int newpos; - Py_UNICODE *repptr; - int repsize; - int res = -1; - - if (*errorHandler == NULL) { - *errorHandler = PyCodec_LookupError(errors); - if (*errorHandler == NULL) - goto onError; - } - - if (*exceptionObject == NULL) { - *exceptionObject = PyUnicodeDecodeError_Create( - encoding, input, insize, *startinpos, *endinpos, reason); - if (*exceptionObject == NULL) - goto onError; - } - else { - if (PyUnicodeDecodeError_SetStart(*exceptionObject, *startinpos)) - goto onError; - if (PyUnicodeDecodeError_SetEnd(*exceptionObject, *endinpos)) - goto onError; - if (PyUnicodeDecodeError_SetReason(*exceptionObject, reason)) - goto onError; - } - - restuple = PyObject_CallFunctionObjArgs(*errorHandler, *exceptionObject, NULL); - if (restuple == NULL) - goto onError; - if (!PyTuple_Check(restuple)) { - PyErr_Format(PyExc_TypeError, &argparse[4]); - goto onError; - } - if (!PyArg_ParseTuple(restuple, argparse, &PyUnicode_Type, &repunicode, &newpos)) - goto onError; - if (newpos<0) - newpos = insize+newpos; - if (newpos<0 || newpos>insize) { - PyErr_Format(PyExc_IndexError, "position %d from error handler out of bounds", newpos); - goto onError; - } - - /* need more space? (at least enough for what we - have+the replacement+the rest of the string (starting - at the new input position), so we won't have to check space - when there are no errors in the rest of the string) */ - repptr = PyUnicode_AS_UNICODE(repunicode); - repsize = PyUnicode_GET_SIZE(repunicode); - requiredsize = *outpos + repsize + insize-newpos; - if (requiredsize > outsize) { - if (requiredsize<2*outsize) - requiredsize = 2*outsize; - if (PyUnicode_Resize(output, requiredsize)) - goto onError; - *outptr = PyUnicode_AS_UNICODE(*output) + *outpos; - } - *endinpos = newpos; - *inptr = input + newpos; - Py_UNICODE_COPY(*outptr, repptr, repsize); - *outptr += repsize; - *outpos += repsize; - /* we made it! */ - res = 0; - - onError: - Py_XDECREF(restuple); - return res; -} - -/* --- UTF-7 Codec -------------------------------------------------------- */ - -/* see RFC2152 for details */ - -static -char utf7_special[128] = { - /* indicate whether a UTF-7 character is special i.e. cannot be directly - encoded: - 0 - not special - 1 - special - 2 - whitespace (optional) - 3 - RFC2152 Set O (optional) */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 3, 3, 3, 3, 3, 3, 0, 0, 0, 3, 1, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 0, - 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 3, 3, 3, - 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, - -}; - -#define SPECIAL(c, encodeO, encodeWS) \ - (((c)>127 || utf7_special[(c)] == 1) || \ - (encodeWS && (utf7_special[(c)] == 2)) || \ - (encodeO && (utf7_special[(c)] == 3))) - -#define B64(n) ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(n) & 0x3f]) -#define B64CHAR(c) (isalnum(c) || (c) == '+' || (c) == '/') -#define UB64(c) ((c) == '+' ? 62 : (c) == '/' ? 63 : (c) >= 'a' ? \ - (c) - 71 : (c) >= 'A' ? (c) - 65 : (c) + 4) - -#define ENCODE(out, ch, bits) \ - while (bits >= 6) { \ - *out++ = B64(ch >> (bits-6)); \ - bits -= 6; \ - } - -#define DECODE(out, ch, bits, surrogate) \ - while (bits >= 16) { \ - Py_UNICODE outCh = (Py_UNICODE) ((ch >> (bits-16)) & 0xffff); \ - bits -= 16; \ - if (surrogate) { \ - /* We have already generated an error for the high surrogate - so let's not bother seeing if the low surrogate is correct or not */\ - surrogate = 0; \ - } else if (0xDC00 <= outCh && outCh <= 0xDFFF) { \ - /* This is a surrogate pair. Unfortunately we can't represent \ - it in a 16-bit character */ \ - surrogate = 1; \ - errmsg = "code pairs are not supported"; \ - goto utf7Error; \ - } else { \ - *out++ = outCh; \ - } \ - } \ - -PyObject *PyUnicode_DecodeUTF7(const char *s, - int size, - const char *errors) -{ - const char *starts = s; - int startinpos; - int endinpos; - int outpos; - const char *e; - PyUnicodeObject *unicode; - Py_UNICODE *p; - const char *errmsg = ""; - int inShift = 0; - unsigned int bitsleft = 0; - unsigned long charsleft = 0; - int surrogate = 0; - PyObject *errorHandler = NULL; - PyObject *exc = NULL; - - unicode = _PyUnicode_New(size); - if (!unicode) - return NULL; - if (size == 0) - return (PyObject *)unicode; - - p = unicode->str; - e = s + size; - - while (s < e) { - Py_UNICODE ch; - restart: - ch = *s; - - if (inShift) { - if ((ch == '-') || !B64CHAR(ch)) { - inShift = 0; - s++; - - /* p, charsleft, bitsleft, surrogate = */ DECODE(p, charsleft, bitsleft, surrogate); - if (bitsleft >= 6) { - /* The shift sequence has a partial character in it. If - bitsleft < 6 then we could just classify it as padding - but that is not the case here */ - - errmsg = "partial character in shift sequence"; - goto utf7Error; - } - /* According to RFC2152 the remaining bits should be zero. We - choose to signal an error/insert a replacement character - here so indicate the potential of a misencoded character. */ - - /* On x86, a << b == a << (b%32) so make sure that bitsleft != 0 */ - if (bitsleft && charsleft << (sizeof(charsleft) * 8 - bitsleft)) { - errmsg = "non-zero padding bits in shift sequence"; - goto utf7Error; - } - - if (ch == '-') { - if ((s < e) && (*(s) == '-')) { - *p++ = '-'; - inShift = 1; - } - } else if (SPECIAL(ch,0,0)) { - errmsg = "unexpected special character"; - goto utf7Error; - } else { - *p++ = ch; - } - } else { - charsleft = (charsleft << 6) | UB64(ch); - bitsleft += 6; - s++; - /* p, charsleft, bitsleft, surrogate = */ DECODE(p, charsleft, bitsleft, surrogate); - } - } - else if ( ch == '+' ) { - startinpos = s-starts; - s++; - if (s < e && *s == '-') { - s++; - *p++ = '+'; - } else - { - inShift = 1; - bitsleft = 0; - } - } - else if (SPECIAL(ch,0,0)) { - errmsg = "unexpected special character"; - s++; - goto utf7Error; - } - else { - *p++ = ch; - s++; - } - continue; - utf7Error: - outpos = p-PyUnicode_AS_UNICODE(unicode); - endinpos = s-starts; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "utf7", errmsg, - starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&unicode, &outpos, &p)) - goto onError; - } - - if (inShift) { - outpos = p-PyUnicode_AS_UNICODE(unicode); - endinpos = size; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "utf7", "unterminated shift sequence", - starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&unicode, &outpos, &p)) - goto onError; - if (s < e) - goto restart; - } - - if (_PyUnicode_Resize(&unicode, p - PyUnicode_AS_UNICODE(unicode))) - goto onError; - - Py_XDECREF(errorHandler); - Py_XDECREF(exc); - return (PyObject *)unicode; - -onError: - Py_XDECREF(errorHandler); - Py_XDECREF(exc); - Py_DECREF(unicode); - return NULL; -} - - -PyObject *PyUnicode_EncodeUTF7(const Py_UNICODE *s, - int size, - int encodeSetO, - int encodeWhiteSpace, - const char *errors) -{ - PyObject *v; - /* It might be possible to tighten this worst case */ - unsigned int cbAllocated = 5 * size; - int inShift = 0; - int i = 0; - unsigned int bitsleft = 0; - unsigned long charsleft = 0; - char * out; - char * start; - - if (size == 0) - return PyString_FromStringAndSize(NULL, 0); - - v = PyString_FromStringAndSize(NULL, cbAllocated); - if (v == NULL) - return NULL; - - start = out = PyString_AS_STRING(v); - for (;i < size; ++i) { - Py_UNICODE ch = s[i]; - - if (!inShift) { - if (ch == '+') { - *out++ = '+'; - *out++ = '-'; - } else if (SPECIAL(ch, encodeSetO, encodeWhiteSpace)) { - charsleft = ch; - bitsleft = 16; - *out++ = '+'; - /* out, charsleft, bitsleft = */ ENCODE(out, charsleft, bitsleft); - inShift = bitsleft > 0; - } else { - *out++ = (char) ch; - } - } else { - if (!SPECIAL(ch, encodeSetO, encodeWhiteSpace)) { - *out++ = B64(charsleft << (6-bitsleft)); - charsleft = 0; - bitsleft = 0; - /* Characters not in the BASE64 set implicitly unshift the sequence - so no '-' is required, except if the character is itself a '-' */ - if (B64CHAR(ch) || ch == '-') { - *out++ = '-'; - } - inShift = 0; - *out++ = (char) ch; - } else { - bitsleft += 16; - charsleft = (charsleft << 16) | ch; - /* out, charsleft, bitsleft = */ ENCODE(out, charsleft, bitsleft); - - /* If the next character is special then we dont' need to terminate - the shift sequence. If the next character is not a BASE64 character - or '-' then the shift sequence will be terminated implicitly and we - don't have to insert a '-'. */ - - if (bitsleft == 0) { - if (i + 1 < size) { - Py_UNICODE ch2 = s[i+1]; - - if (SPECIAL(ch2, encodeSetO, encodeWhiteSpace)) { - - } else if (B64CHAR(ch2) || ch2 == '-') { - *out++ = '-'; - inShift = 0; - } else { - inShift = 0; - } - - } - else { - *out++ = '-'; - inShift = 0; - } - } - } - } - } - if (bitsleft) { - *out++= B64(charsleft << (6-bitsleft) ); - *out++ = '-'; - } - - _PyString_Resize(&v, out - start); - return v; -} - -#undef SPECIAL -#undef B64 -#undef B64CHAR -#undef UB64 -#undef ENCODE -#undef DECODE - -/* --- UTF-8 Codec -------------------------------------------------------- */ - -static -char utf8_code_length[256] = { - /* Map UTF-8 encoded prefix byte to sequence length. zero means - illegal prefix. see RFC 2279 for details */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0 -}; - -PyObject *PyUnicode_DecodeUTF8(const char *s, - int size, - const char *errors) -{ - const char *starts = s; - int n; - int startinpos; - int endinpos; - int outpos; - const char *e; - PyUnicodeObject *unicode; - Py_UNICODE *p; - const char *errmsg = ""; - PyObject *errorHandler = NULL; - PyObject *exc = NULL; - - /* Note: size will always be longer than the resulting Unicode - character count */ - unicode = _PyUnicode_New(size); - if (!unicode) - return NULL; - if (size == 0) - return (PyObject *)unicode; - - /* Unpack UTF-8 encoded data */ - p = unicode->str; - e = s + size; - - while (s < e) { - Py_UCS4 ch = (unsigned char)*s; - - if (ch < 0x80) { - *p++ = (Py_UNICODE)ch; - s++; - continue; - } - - n = utf8_code_length[ch]; - - if (s + n > e) { - errmsg = "unexpected end of data"; - startinpos = s-starts; - endinpos = size; - goto utf8Error; - } - - switch (n) { - - case 0: - errmsg = "unexpected code byte"; - startinpos = s-starts; - endinpos = startinpos+1; - goto utf8Error; - - case 1: - errmsg = "internal error"; - startinpos = s-starts; - endinpos = startinpos+1; - goto utf8Error; - - case 2: - if ((s[1] & 0xc0) != 0x80) { - errmsg = "invalid data"; - startinpos = s-starts; - endinpos = startinpos+2; - goto utf8Error; - } - ch = ((s[0] & 0x1f) << 6) + (s[1] & 0x3f); - if (ch < 0x80) { - startinpos = s-starts; - endinpos = startinpos+2; - errmsg = "illegal encoding"; - goto utf8Error; - } - else - *p++ = (Py_UNICODE)ch; - break; - - case 3: - if ((s[1] & 0xc0) != 0x80 || - (s[2] & 0xc0) != 0x80) { - errmsg = "invalid data"; - startinpos = s-starts; - endinpos = startinpos+3; - goto utf8Error; - } - ch = ((s[0] & 0x0f) << 12) + ((s[1] & 0x3f) << 6) + (s[2] & 0x3f); - if (ch < 0x0800) { - /* Note: UTF-8 encodings of surrogates are considered - legal UTF-8 sequences; - - XXX For wide builds (UCS-4) we should probably try - to recombine the surrogates into a single code - unit. - */ - errmsg = "illegal encoding"; - startinpos = s-starts; - endinpos = startinpos+3; - goto utf8Error; - } - else - *p++ = (Py_UNICODE)ch; - break; - - case 4: - if ((s[1] & 0xc0) != 0x80 || - (s[2] & 0xc0) != 0x80 || - (s[3] & 0xc0) != 0x80) { - errmsg = "invalid data"; - startinpos = s-starts; - endinpos = startinpos+4; - goto utf8Error; - } - ch = ((s[0] & 0x7) << 18) + ((s[1] & 0x3f) << 12) + - ((s[2] & 0x3f) << 6) + (s[3] & 0x3f); - /* validate and convert to UTF-16 */ - if ((ch < 0x10000) /* minimum value allowed for 4 - byte encoding */ - || (ch > 0x10ffff)) /* maximum value allowed for - UTF-16 */ - { - errmsg = "illegal encoding"; - startinpos = s-starts; - endinpos = startinpos+4; - goto utf8Error; - } -#ifdef Py_UNICODE_WIDE - *p++ = (Py_UNICODE)ch; -#else - /* compute and append the two surrogates: */ - - /* translate from 10000..10FFFF to 0..FFFF */ - ch -= 0x10000; - - /* high surrogate = top 10 bits added to D800 */ - *p++ = (Py_UNICODE)(0xD800 + (ch >> 10)); - - /* low surrogate = bottom 10 bits added to DC00 */ - *p++ = (Py_UNICODE)(0xDC00 + (ch & 0x03FF)); -#endif - break; - - default: - /* Other sizes are only needed for UCS-4 */ - errmsg = "unsupported Unicode code range"; - startinpos = s-starts; - endinpos = startinpos+n; - goto utf8Error; - } - s += n; - continue; - - utf8Error: - outpos = p-PyUnicode_AS_UNICODE(unicode); - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "utf8", errmsg, - starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&unicode, &outpos, &p)) - goto onError; - } - - /* Adjust length */ - if (_PyUnicode_Resize(&unicode, p - unicode->str)) - goto onError; - - Py_XDECREF(errorHandler); - Py_XDECREF(exc); - return (PyObject *)unicode; - -onError: - Py_XDECREF(errorHandler); - Py_XDECREF(exc); - Py_DECREF(unicode); - return NULL; -} - -/* Allocation strategy: if the string is short, convert into a stack buffer - and allocate exactly as much space needed at the end. Else allocate the - maximum possible needed (4 result bytes per Unicode character), and return - the excess memory at the end. -*/ -PyObject * -PyUnicode_EncodeUTF8(const Py_UNICODE *s, - int size, - const char *errors) -{ -#define MAX_SHORT_UNICHARS 300 /* largest size we'll do on the stack */ - - int i; /* index into s of next input byte */ - PyObject *v; /* result string object */ - char *p; /* next free byte in output buffer */ - int nallocated; /* number of result bytes allocated */ - int nneeded; /* number of result bytes needed */ - char stackbuf[MAX_SHORT_UNICHARS * 4]; - - assert(s != NULL); - assert(size >= 0); - - if (size <= MAX_SHORT_UNICHARS) { - /* Write into the stack buffer; nallocated can't overflow. - * At the end, we'll allocate exactly as much heap space as it - * turns out we need. - */ - nallocated = Py_SAFE_DOWNCAST(sizeof(stackbuf), size_t, int); - v = NULL; /* will allocate after we're done */ - p = stackbuf; - } - else { - /* Overallocate on the heap, and give the excess back at the end. */ - nallocated = size * 4; - if (nallocated / 4 != size) /* overflow! */ - return PyErr_NoMemory(); - v = PyString_FromStringAndSize(NULL, nallocated); - if (v == NULL) - return NULL; - p = PyString_AS_STRING(v); - } - - for (i = 0; i < size;) { - Py_UCS4 ch = s[i++]; - - if (ch < 0x80) - /* Encode ASCII */ - *p++ = (char) ch; - - else if (ch < 0x0800) { - /* Encode Latin-1 */ - *p++ = (char)(0xc0 | (ch >> 6)); - *p++ = (char)(0x80 | (ch & 0x3f)); - } - else { - /* Encode UCS2 Unicode ordinals */ - if (ch < 0x10000) { - /* Special case: check for high surrogate */ - if (0xD800 <= ch && ch <= 0xDBFF && i != size) { - Py_UCS4 ch2 = s[i]; - /* Check for low surrogate and combine the two to - form a UCS4 value */ - if (0xDC00 <= ch2 && ch2 <= 0xDFFF) { - ch = ((ch - 0xD800) << 10 | (ch2 - 0xDC00)) + 0x10000; - i++; - goto encodeUCS4; - } - /* Fall through: handles isolated high surrogates */ - } - *p++ = (char)(0xe0 | (ch >> 12)); - *p++ = (char)(0x80 | ((ch >> 6) & 0x3f)); - *p++ = (char)(0x80 | (ch & 0x3f)); - continue; - } -encodeUCS4: - /* Encode UCS4 Unicode ordinals */ - *p++ = (char)(0xf0 | (ch >> 18)); - *p++ = (char)(0x80 | ((ch >> 12) & 0x3f)); - *p++ = (char)(0x80 | ((ch >> 6) & 0x3f)); - *p++ = (char)(0x80 | (ch & 0x3f)); - } - } - - if (v == NULL) { - /* This was stack allocated. */ - nneeded = Py_SAFE_DOWNCAST(p - stackbuf, long, int); - assert(nneeded <= nallocated); - v = PyString_FromStringAndSize(stackbuf, nneeded); - } - else { - /* Cut back to size actually needed. */ - nneeded = Py_SAFE_DOWNCAST(p - PyString_AS_STRING(v), long, int); - assert(nneeded <= nallocated); - _PyString_Resize(&v, nneeded); - } - return v; - -#undef MAX_SHORT_UNICHARS -} - -PyObject *PyUnicode_AsUTF8String(PyObject *unicode) -{ - if (!PyUnicode_Check(unicode)) { - PyErr_BadArgument(); - return NULL; - } - return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode), - PyUnicode_GET_SIZE(unicode), - NULL); -} - -/* --- UTF-16 Codec ------------------------------------------------------- */ - -PyObject * -PyUnicode_DecodeUTF16(const char *s, - int size, - const char *errors, - int *byteorder) -{ - const char *starts = s; - int startinpos; - int endinpos; - int outpos; - PyUnicodeObject *unicode; - Py_UNICODE *p; - const unsigned char *q, *e; - int bo = 0; /* assume native ordering by default */ - const char *errmsg = ""; - /* Offsets from q for retrieving byte pairs in the right order. */ -#ifdef BYTEORDER_IS_LITTLE_ENDIAN - int ihi = 1, ilo = 0; -#else - int ihi = 0, ilo = 1; -#endif - PyObject *errorHandler = NULL; - PyObject *exc = NULL; - - /* Note: size will always be longer than the resulting Unicode - character count */ - unicode = _PyUnicode_New(size); - if (!unicode) - return NULL; - if (size == 0) - return (PyObject *)unicode; - - /* Unpack UTF-16 encoded data */ - p = unicode->str; - q = (unsigned char *)s; - e = q + size; - - if (byteorder) - bo = *byteorder; - - /* Check for BOM marks (U+FEFF) in the input and adjust current - byte order setting accordingly. In native mode, the leading BOM - mark is skipped, in all other modes, it is copied to the output - stream as-is (giving a ZWNBSP character). */ - if (bo == 0) { - const Py_UNICODE bom = (q[ihi] << 8) | q[ilo]; -#ifdef BYTEORDER_IS_LITTLE_ENDIAN - if (bom == 0xFEFF) { - q += 2; - bo = -1; - } - else if (bom == 0xFFFE) { - q += 2; - bo = 1; - } -#else - if (bom == 0xFEFF) { - q += 2; - bo = 1; - } - else if (bom == 0xFFFE) { - q += 2; - bo = -1; - } -#endif - } - - if (bo == -1) { - /* force LE */ - ihi = 1; - ilo = 0; - } - else if (bo == 1) { - /* force BE */ - ihi = 0; - ilo = 1; - } - - while (q < e) { - Py_UNICODE ch; - /* remaing bytes at the end? (size should be even) */ - if (e-q<2) { - errmsg = "truncated data"; - startinpos = ((const char *)q)-starts; - endinpos = ((const char *)e)-starts; - goto utf16Error; - /* The remaining input chars are ignored if the callback - chooses to skip the input */ - } - ch = (q[ihi] << 8) | q[ilo]; - - q += 2; - - if (ch < 0xD800 || ch > 0xDFFF) { - *p++ = ch; - continue; - } - - /* UTF-16 code pair: */ - if (q >= e) { - errmsg = "unexpected end of data"; - startinpos = (((const char *)q)-2)-starts; - endinpos = ((const char *)e)-starts; - goto utf16Error; - } - if (0xD800 <= ch && ch <= 0xDBFF) { - Py_UNICODE ch2 = (q[ihi] << 8) | q[ilo]; - q += 2; - if (0xDC00 <= ch2 && ch2 <= 0xDFFF) { -#ifndef Py_UNICODE_WIDE - *p++ = ch; - *p++ = ch2; -#else - *p++ = (((ch & 0x3FF)<<10) | (ch2 & 0x3FF)) + 0x10000; -#endif - continue; - } - else { - errmsg = "illegal UTF-16 surrogate"; - startinpos = (((const char *)q)-4)-starts; - endinpos = startinpos+2; - goto utf16Error; - } - - } - errmsg = "illegal encoding"; - startinpos = (((const char *)q)-2)-starts; - endinpos = startinpos+2; - /* Fall through to report the error */ - - utf16Error: - outpos = p-PyUnicode_AS_UNICODE(unicode); - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "utf16", errmsg, - starts, size, &startinpos, &endinpos, &exc, (const char **)&q, - (PyObject **)&unicode, &outpos, &p)) - goto onError; - } - - if (byteorder) - *byteorder = bo; - - /* Adjust length */ - if (_PyUnicode_Resize(&unicode, p - unicode->str)) - goto onError; - - Py_XDECREF(errorHandler); - Py_XDECREF(exc); - return (PyObject *)unicode; - -onError: - Py_DECREF(unicode); - Py_XDECREF(errorHandler); - Py_XDECREF(exc); - return NULL; -} - -PyObject * -PyUnicode_EncodeUTF16(const Py_UNICODE *s, - int size, - const char *errors, - int byteorder) -{ - PyObject *v; - unsigned char *p; - int i, pairs; - /* Offsets from p for storing byte pairs in the right order. */ -#ifdef BYTEORDER_IS_LITTLE_ENDIAN - int ihi = 1, ilo = 0; -#else - int ihi = 0, ilo = 1; -#endif - -#define STORECHAR(CH) \ - do { \ - p[ihi] = ((CH) >> 8) & 0xff; \ - p[ilo] = (CH) & 0xff; \ - p += 2; \ - } while(0) - - for (i = pairs = 0; i < size; i++) - if (s[i] >= 0x10000) - pairs++; - v = PyString_FromStringAndSize(NULL, - 2 * (size + pairs + (byteorder == 0))); - if (v == NULL) - return NULL; - - p = (unsigned char *)PyString_AS_STRING(v); - if (byteorder == 0) - STORECHAR(0xFEFF); - if (size == 0) - return v; - - if (byteorder == -1) { - /* force LE */ - ihi = 1; - ilo = 0; - } - else if (byteorder == 1) { - /* force BE */ - ihi = 0; - ilo = 1; - } - - while (size-- > 0) { - Py_UNICODE ch = *s++; - Py_UNICODE ch2 = 0; - if (ch >= 0x10000) { - ch2 = 0xDC00 | ((ch-0x10000) & 0x3FF); - ch = 0xD800 | ((ch-0x10000) >> 10); - } - STORECHAR(ch); - if (ch2) - STORECHAR(ch2); - } - return v; -#undef STORECHAR -} - -PyObject *PyUnicode_AsUTF16String(PyObject *unicode) -{ - if (!PyUnicode_Check(unicode)) { - PyErr_BadArgument(); - return NULL; - } - return PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(unicode), - PyUnicode_GET_SIZE(unicode), - NULL, - 0); -} - -/* --- Unicode Escape Codec ----------------------------------------------- */ - -static _PyUnicode_Name_CAPI *ucnhash_CAPI = NULL; - -PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, - int size, - const char *errors) -{ - const char *starts = s; - int startinpos; - int endinpos; - int outpos; - int i; - PyUnicodeObject *v; - Py_UNICODE *p; - const char *end; - char* message; - Py_UCS4 chr = 0xffffffff; /* in case 'getcode' messes up */ - PyObject *errorHandler = NULL; - PyObject *exc = NULL; - - /* Escaped strings will always be longer than the resulting - Unicode string, so we start with size here and then reduce the - length after conversion to the true value. - (but if the error callback returns a long replacement string - we'll have to allocate more space) */ - v = _PyUnicode_New(size); - if (v == NULL) - goto onError; - if (size == 0) - return (PyObject *)v; - - p = PyUnicode_AS_UNICODE(v); - end = s + size; - - while (s < end) { - unsigned char c; - Py_UNICODE x; - int digits; - - /* Non-escape characters are interpreted as Unicode ordinals */ - if (*s != '\\') { - *p++ = (unsigned char) *s++; - continue; - } - - startinpos = s-starts; - /* \ - Escapes */ - s++; - switch (*s++) { - - /* \x escapes */ - case '\n': break; - case '\\': *p++ = '\\'; break; - case '\'': *p++ = '\''; break; - case '\"': *p++ = '\"'; break; - case 'b': *p++ = '\b'; break; - case 'f': *p++ = '\014'; break; /* FF */ - case 't': *p++ = '\t'; break; - case 'n': *p++ = '\n'; break; - case 'r': *p++ = '\r'; break; - case 'v': *p++ = '\013'; break; /* VT */ - case 'a': *p++ = '\007'; break; /* BEL, not classic C */ - - /* \OOO (octal) escapes */ - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - x = s[-1] - '0'; - if ('0' <= *s && *s <= '7') { - x = (x<<3) + *s++ - '0'; - if ('0' <= *s && *s <= '7') - x = (x<<3) + *s++ - '0'; - } - *p++ = x; - break; - - /* hex escapes */ - /* \xXX */ - case 'x': - digits = 2; - message = "truncated \\xXX escape"; - goto hexescape; - - /* \uXXXX */ - case 'u': - digits = 4; - message = "truncated \\uXXXX escape"; - goto hexescape; - - /* \UXXXXXXXX */ - case 'U': - digits = 8; - message = "truncated \\UXXXXXXXX escape"; - hexescape: - chr = 0; - outpos = p-PyUnicode_AS_UNICODE(v); - if (s+digits>end) { - endinpos = size; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", "end of string in escape sequence", - starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) - goto onError; - goto nextByte; - } - for (i = 0; i < digits; ++i) { - c = (unsigned char) s[i]; - if (!isxdigit(c)) { - endinpos = (s+i+1)-starts; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", message, - starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) - goto onError; - goto nextByte; - } - chr = (chr<<4) & ~0xF; - if (c >= '0' && c <= '9') - chr += c - '0'; - else if (c >= 'a' && c <= 'f') - chr += 10 + c - 'a'; - else - chr += 10 + c - 'A'; - } - s += i; - if (chr == 0xffffffff) - /* _decoding_error will have already written into the - target buffer. */ - break; - store: - /* when we get here, chr is a 32-bit unicode character */ - if (chr <= 0xffff) - /* UCS-2 character */ - *p++ = (Py_UNICODE) chr; - else if (chr <= 0x10ffff) { - /* UCS-4 character. Either store directly, or as - surrogate pair. */ -#ifdef Py_UNICODE_WIDE - *p++ = chr; -#else - chr -= 0x10000L; - *p++ = 0xD800 + (Py_UNICODE) (chr >> 10); - *p++ = 0xDC00 + (Py_UNICODE) (chr & 0x03FF); -#endif - } else { - endinpos = s-starts; - outpos = p-PyUnicode_AS_UNICODE(v); - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", "illegal Unicode character", - starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) - goto onError; - } - break; - - /* \N{name} */ - case 'N': - message = "malformed \\N character escape"; - if (ucnhash_CAPI == NULL) { - /* load the unicode data module */ - PyObject *m, *v; - m = PyImport_ImportModule("unicodedata"); - if (m == NULL) - goto ucnhashError; - v = PyObject_GetAttrString(m, "ucnhash_CAPI"); - Py_DECREF(m); - if (v == NULL) - goto ucnhashError; - ucnhash_CAPI = PyCObject_AsVoidPtr(v); - Py_DECREF(v); - if (ucnhash_CAPI == NULL) - goto ucnhashError; - } - if (*s == '{') { - const char *start = s+1; - /* look for the closing brace */ - while (*s != '}' && s < end) - s++; - if (s > start && s < end && *s == '}') { - /* found a name. look it up in the unicode database */ - message = "unknown Unicode character name"; - s++; - if (ucnhash_CAPI->getcode(start, s-start-1, &chr)) - goto store; - } - } - endinpos = s-starts; - outpos = p-PyUnicode_AS_UNICODE(v); - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", message, - starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) - goto onError; - break; - - default: - if (s > end) { - message = "\\ at end of string"; - s--; - endinpos = s-starts; - outpos = p-PyUnicode_AS_UNICODE(v); - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", message, - starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) - goto onError; - } - else { - *p++ = '\\'; - *p++ = (unsigned char)s[-1]; - } - break; - } - nextByte: - ; - } - if (_PyUnicode_Resize(&v, (int)(p - PyUnicode_AS_UNICODE(v)))) - goto onError; - Py_XDECREF(errorHandler); - Py_XDECREF(exc); - return (PyObject *)v; - -ucnhashError: - PyErr_SetString( - PyExc_UnicodeError, - "\\N escapes not supported (can't load unicodedata module)" - ); - Py_XDECREF(errorHandler); - Py_XDECREF(exc); - return NULL; - -onError: - Py_XDECREF(v); - Py_XDECREF(errorHandler); - Py_XDECREF(exc); - return NULL; -} - -/* Return a Unicode-Escape string version of the Unicode object. - - If quotes is true, the string is enclosed in u"" or u'' quotes as - appropriate. - -*/ - -static const Py_UNICODE *findchar(const Py_UNICODE *s, - int size, - Py_UNICODE ch); - -static -PyObject *unicodeescape_string(const Py_UNICODE *s, - int size, - int quotes) -{ - PyObject *repr; - char *p; - - static const char *hexdigit = "0123456789abcdef"; - - repr = PyString_FromStringAndSize(NULL, 2 + 6*size + 1); - if (repr == NULL) - return NULL; - - p = PyString_AS_STRING(repr); - - if (quotes) { - *p++ = 'u'; - *p++ = (findchar(s, size, '\'') && - !findchar(s, size, '"')) ? '"' : '\''; - } - while (size-- > 0) { - Py_UNICODE ch = *s++; - - /* Escape quotes */ - if (quotes && - (ch == (Py_UNICODE) PyString_AS_STRING(repr)[1] || ch == '\\')) { - *p++ = '\\'; - *p++ = (char) ch; - continue; - } - -#ifdef Py_UNICODE_WIDE - /* Map 21-bit characters to '\U00xxxxxx' */ - else if (ch >= 0x10000) { - int offset = p - PyString_AS_STRING(repr); - - /* Resize the string if necessary */ - if (offset + 12 > PyString_GET_SIZE(repr)) { - if (_PyString_Resize(&repr, PyString_GET_SIZE(repr) + 100)) - return NULL; - p = PyString_AS_STRING(repr) + offset; - } - - *p++ = '\\'; - *p++ = 'U'; - *p++ = hexdigit[(ch >> 28) & 0x0000000F]; - *p++ = hexdigit[(ch >> 24) & 0x0000000F]; - *p++ = hexdigit[(ch >> 20) & 0x0000000F]; - *p++ = hexdigit[(ch >> 16) & 0x0000000F]; - *p++ = hexdigit[(ch >> 12) & 0x0000000F]; - *p++ = hexdigit[(ch >> 8) & 0x0000000F]; - *p++ = hexdigit[(ch >> 4) & 0x0000000F]; - *p++ = hexdigit[ch & 0x0000000F]; - continue; - } -#endif - /* Map UTF-16 surrogate pairs to Unicode \UXXXXXXXX escapes */ - else if (ch >= 0xD800 && ch < 0xDC00) { - Py_UNICODE ch2; - Py_UCS4 ucs; - - ch2 = *s++; - size--; - if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) { - ucs = (((ch & 0x03FF) << 10) | (ch2 & 0x03FF)) + 0x00010000; - *p++ = '\\'; - *p++ = 'U'; - *p++ = hexdigit[(ucs >> 28) & 0x0000000F]; - *p++ = hexdigit[(ucs >> 24) & 0x0000000F]; - *p++ = hexdigit[(ucs >> 20) & 0x0000000F]; - *p++ = hexdigit[(ucs >> 16) & 0x0000000F]; - *p++ = hexdigit[(ucs >> 12) & 0x0000000F]; - *p++ = hexdigit[(ucs >> 8) & 0x0000000F]; - *p++ = hexdigit[(ucs >> 4) & 0x0000000F]; - *p++ = hexdigit[ucs & 0x0000000F]; - continue; - } - /* Fall through: isolated surrogates are copied as-is */ - s--; - size++; - } - - /* Map 16-bit characters to '\uxxxx' */ - if (ch >= 256) { - *p++ = '\\'; - *p++ = 'u'; - *p++ = hexdigit[(ch >> 12) & 0x000F]; - *p++ = hexdigit[(ch >> 8) & 0x000F]; - *p++ = hexdigit[(ch >> 4) & 0x000F]; - *p++ = hexdigit[ch & 0x000F]; - } - - /* Map special whitespace to '\t', \n', '\r' */ - else if (ch == '\t') { - *p++ = '\\'; - *p++ = 't'; - } - else if (ch == '\n') { - *p++ = '\\'; - *p++ = 'n'; - } - else if (ch == '\r') { - *p++ = '\\'; - *p++ = 'r'; - } - - /* Map non-printable US ASCII to '\xhh' */ - else if (ch < ' ' || ch >= 0x7F) { - *p++ = '\\'; - *p++ = 'x'; - *p++ = hexdigit[(ch >> 4) & 0x000F]; - *p++ = hexdigit[ch & 0x000F]; - } - - /* Copy everything else as-is */ - else - *p++ = (char) ch; - } - if (quotes) - *p++ = PyString_AS_STRING(repr)[1]; - - *p = '\0'; - _PyString_Resize(&repr, p - PyString_AS_STRING(repr)); - return repr; -} - -PyObject *PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s, - int size) -{ - return unicodeescape_string(s, size, 0); -} - -PyObject *PyUnicode_AsUnicodeEscapeString(PyObject *unicode) -{ - if (!PyUnicode_Check(unicode)) { - PyErr_BadArgument(); - return NULL; - } - return PyUnicode_EncodeUnicodeEscape(PyUnicode_AS_UNICODE(unicode), - PyUnicode_GET_SIZE(unicode)); -} - -/* --- Raw Unicode Escape Codec ------------------------------------------- */ - -PyObject *PyUnicode_DecodeRawUnicodeEscape(const char *s, - int size, - const char *errors) -{ - const char *starts = s; - int startinpos; - int endinpos; - int outpos; - PyUnicodeObject *v; - Py_UNICODE *p; - const char *end; - const char *bs; - PyObject *errorHandler = NULL; - PyObject *exc = NULL; - - /* Escaped strings will always be longer than the resulting - Unicode string, so we start with size here and then reduce the - length after conversion to the true value. (But decoding error - handler might have to resize the string) */ - v = _PyUnicode_New(size); - if (v == NULL) - goto onError; - if (size == 0) - return (PyObject *)v; - p = PyUnicode_AS_UNICODE(v); - end = s + size; - while (s < end) { - unsigned char c; - Py_UCS4 x; - int i; - int count; - - /* Non-escape characters are interpreted as Unicode ordinals */ - if (*s != '\\') { - *p++ = (unsigned char)*s++; - continue; - } - startinpos = s-starts; - - /* \u-escapes are only interpreted iff the number of leading - backslashes if odd */ - bs = s; - for (;s < end;) { - if (*s != '\\') - break; - *p++ = (unsigned char)*s++; - } - if (((s - bs) & 1) == 0 || - s >= end || - (*s != 'u' && *s != 'U')) { - continue; - } - p--; - count = *s=='u' ? 4 : 8; - s++; - - /* \uXXXX with 4 hex digits, \Uxxxxxxxx with 8 */ - outpos = p-PyUnicode_AS_UNICODE(v); - for (x = 0, i = 0; i < count; ++i, ++s) { - c = (unsigned char)*s; - if (!isxdigit(c)) { - endinpos = s-starts; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "rawunicodeescape", "truncated \\uXXXX", - starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) - goto onError; - goto nextByte; - } - x = (x<<4) & ~0xF; - if (c >= '0' && c <= '9') - x += c - '0'; - else if (c >= 'a' && c <= 'f') - x += 10 + c - 'a'; - else - x += 10 + c - 'A'; - } -#ifndef Py_UNICODE_WIDE - if (x > 0x10000) { - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "rawunicodeescape", "\\Uxxxxxxxx out of range", - starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) - goto onError; - } -#endif - *p++ = x; - nextByte: - ; - } - if (_PyUnicode_Resize(&v, (int)(p - PyUnicode_AS_UNICODE(v)))) - goto onError; - Py_XDECREF(errorHandler); - Py_XDECREF(exc); - return (PyObject *)v; - - onError: - Py_XDECREF(v); - Py_XDECREF(errorHandler); - Py_XDECREF(exc); - return NULL; -} - -PyObject *PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s, - int size) -{ - PyObject *repr; - char *p; - char *q; - - static const char *hexdigit = "0123456789abcdef"; - -#ifdef Py_UNICODE_WIDE - repr = PyString_FromStringAndSize(NULL, 10 * size); -#else - repr = PyString_FromStringAndSize(NULL, 6 * size); -#endif - if (repr == NULL) - return NULL; - if (size == 0) - return repr; - - p = q = PyString_AS_STRING(repr); - while (size-- > 0) { - Py_UNICODE ch = *s++; -#ifdef Py_UNICODE_WIDE - /* Map 32-bit characters to '\Uxxxxxxxx' */ - if (ch >= 0x10000) { - *p++ = '\\'; - *p++ = 'U'; - *p++ = hexdigit[(ch >> 28) & 0xf]; - *p++ = hexdigit[(ch >> 24) & 0xf]; - *p++ = hexdigit[(ch >> 20) & 0xf]; - *p++ = hexdigit[(ch >> 16) & 0xf]; - *p++ = hexdigit[(ch >> 12) & 0xf]; - *p++ = hexdigit[(ch >> 8) & 0xf]; - *p++ = hexdigit[(ch >> 4) & 0xf]; - *p++ = hexdigit[ch & 15]; - } - else -#endif - /* Map 16-bit characters to '\uxxxx' */ - if (ch >= 256) { - *p++ = '\\'; - *p++ = 'u'; - *p++ = hexdigit[(ch >> 12) & 0xf]; - *p++ = hexdigit[(ch >> 8) & 0xf]; - *p++ = hexdigit[(ch >> 4) & 0xf]; - *p++ = hexdigit[ch & 15]; - } - /* Copy everything else as-is */ - else - *p++ = (char) ch; - } - *p = '\0'; - _PyString_Resize(&repr, p - q); - return repr; -} - -PyObject *PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode) -{ - if (!PyUnicode_Check(unicode)) { - PyErr_BadArgument(); - return NULL; - } - return PyUnicode_EncodeRawUnicodeEscape(PyUnicode_AS_UNICODE(unicode), - PyUnicode_GET_SIZE(unicode)); -} - -/* --- Latin-1 Codec ------------------------------------------------------ */ - -PyObject *PyUnicode_DecodeLatin1(const char *s, - int size, - const char *errors) -{ - PyUnicodeObject *v; - Py_UNICODE *p; - - /* Latin-1 is equivalent to the first 256 ordinals in Unicode. */ - if (size == 1 && *(unsigned char*)s < 256) { - Py_UNICODE r = *(unsigned char*)s; - return PyUnicode_FromUnicode(&r, 1); - } - - v = _PyUnicode_New(size); - if (v == NULL) - goto onError; - if (size == 0) - return (PyObject *)v; - p = PyUnicode_AS_UNICODE(v); - while (size-- > 0) - *p++ = (unsigned char)*s++; - return (PyObject *)v; - - onError: - Py_XDECREF(v); - return NULL; -} - -/* create or adjust a UnicodeEncodeError */ -static void make_encode_exception(PyObject **exceptionObject, - const char *encoding, - const Py_UNICODE *unicode, int size, - int startpos, int endpos, - const char *reason) -{ - if (*exceptionObject == NULL) { - *exceptionObject = PyUnicodeEncodeError_Create( - encoding, unicode, size, startpos, endpos, reason); - } - else { - if (PyUnicodeEncodeError_SetStart(*exceptionObject, startpos)) - goto onError; - if (PyUnicodeEncodeError_SetEnd(*exceptionObject, endpos)) - goto onError; - if (PyUnicodeEncodeError_SetReason(*exceptionObject, reason)) - goto onError; - return; - onError: - Py_DECREF(*exceptionObject); - *exceptionObject = NULL; - } -} - -/* raises a UnicodeEncodeError */ -static void raise_encode_exception(PyObject **exceptionObject, - const char *encoding, - const Py_UNICODE *unicode, int size, - int startpos, int endpos, - const char *reason) -{ - make_encode_exception(exceptionObject, - encoding, unicode, size, startpos, endpos, reason); - if (*exceptionObject != NULL) - PyCodec_StrictErrors(*exceptionObject); -} - -/* error handling callback helper: - build arguments, call the callback and check the arguments, - put the result into newpos and return the replacement string, which - has to be freed by the caller */ -static PyObject *unicode_encode_call_errorhandler(const char *errors, - PyObject **errorHandler, - const char *encoding, const char *reason, - const Py_UNICODE *unicode, int size, PyObject **exceptionObject, - int startpos, int endpos, - int *newpos) -{ - static char *argparse = "O!i;encoding error handler must return (unicode, int) tuple"; - - PyObject *restuple; - PyObject *resunicode; - - if (*errorHandler == NULL) { - *errorHandler = PyCodec_LookupError(errors); - if (*errorHandler == NULL) - return NULL; - } - - make_encode_exception(exceptionObject, - encoding, unicode, size, startpos, endpos, reason); - if (*exceptionObject == NULL) - return NULL; - - restuple = PyObject_CallFunctionObjArgs( - *errorHandler, *exceptionObject, NULL); - if (restuple == NULL) - return NULL; - if (!PyTuple_Check(restuple)) { - PyErr_Format(PyExc_TypeError, &argparse[4]); - Py_DECREF(restuple); - return NULL; - } - if (!PyArg_ParseTuple(restuple, argparse, &PyUnicode_Type, - &resunicode, newpos)) { - Py_DECREF(restuple); - return NULL; - } - if (*newpos<0) - *newpos = size+*newpos; - if (*newpos<0 || *newpos>size) { - PyErr_Format(PyExc_IndexError, "position %d from error handler out of bounds", *newpos); - Py_DECREF(restuple); - return NULL; - } - Py_INCREF(resunicode); - Py_DECREF(restuple); - return resunicode; -} - -static PyObject *unicode_encode_ucs1(const Py_UNICODE *p, - int size, - const char *errors, - int limit) -{ - /* output object */ - PyObject *res; - /* pointers to the beginning and end+1 of input */ - const Py_UNICODE *startp = p; - const Py_UNICODE *endp = p + size; - /* pointer to the beginning of the unencodable characters */ - /* const Py_UNICODE *badp = NULL; */ - /* pointer into the output */ - char *str; - /* current output position */ - int respos = 0; - int ressize; - char *encoding = (limit == 256) ? "latin-1" : "ascii"; - char *reason = (limit == 256) ? "ordinal not in range(256)" : "ordinal not in range(128)"; - PyObject *errorHandler = NULL; - PyObject *exc = NULL; - /* the following variable is used for caching string comparisons - * -1=not initialized, 0=unknown, 1=strict, 2=replace, 3=ignore, 4=xmlcharrefreplace */ - int known_errorHandler = -1; - - /* allocate enough for a simple encoding without - replacements, if we need more, we'll resize */ - res = PyString_FromStringAndSize(NULL, size); - if (res == NULL) - goto onError; - if (size == 0) - return res; - str = PyString_AS_STRING(res); - ressize = size; - - while (p=limit)) - ++collend; - /* cache callback name lookup (if not done yet, i.e. it's the first error) */ - if (known_errorHandler==-1) { - if ((errors==NULL) || (!strcmp(errors, "strict"))) - known_errorHandler = 1; - else if (!strcmp(errors, "replace")) - known_errorHandler = 2; - else if (!strcmp(errors, "ignore")) - known_errorHandler = 3; - else if (!strcmp(errors, "xmlcharrefreplace")) - known_errorHandler = 4; - else - known_errorHandler = 0; - } - switch (known_errorHandler) { - case 1: /* strict */ - raise_encode_exception(&exc, encoding, startp, size, collstart-startp, collend-startp, reason); - goto onError; - case 2: /* replace */ - while (collstart++ ressize) { - if (requiredsize<2*ressize) - requiredsize = 2*ressize; - if (_PyString_Resize(&res, requiredsize)) - goto onError; - str = PyString_AS_STRING(res) + respos; - ressize = requiredsize; - } - /* generate replacement (temporarily (mis)uses p) */ - for (p = collstart; p < collend; ++p) { - str += sprintf(str, "&#%d;", (int)*p); - } - p = collend; - break; - default: - repunicode = unicode_encode_call_errorhandler(errors, &errorHandler, - encoding, reason, startp, size, &exc, - collstart-startp, collend-startp, &newpos); - if (repunicode == NULL) - goto onError; - /* need more space? (at least enough for what we - have+the replacement+the rest of the string, so - we won't have to check space for encodable characters) */ - respos = str-PyString_AS_STRING(res); - repsize = PyUnicode_GET_SIZE(repunicode); - requiredsize = respos+repsize+(endp-collend); - if (requiredsize > ressize) { - if (requiredsize<2*ressize) - requiredsize = 2*ressize; - if (_PyString_Resize(&res, requiredsize)) { - Py_DECREF(repunicode); - goto onError; - } - str = PyString_AS_STRING(res) + respos; - ressize = requiredsize; - } - /* check if there is anything unencodable in the replacement - and copy it to the output */ - for (uni2 = PyUnicode_AS_UNICODE(repunicode);repsize-->0; ++uni2, ++str) { - c = *uni2; - if (c >= limit) { - raise_encode_exception(&exc, encoding, startp, size, - unicodepos, unicodepos+1, reason); - Py_DECREF(repunicode); - goto onError; - } - *str = (char)c; - } - p = startp + newpos; - Py_DECREF(repunicode); - } - } - } - /* Resize if we allocated to much */ - respos = str-PyString_AS_STRING(res); - if (respos 0 && usize==0) - return PyErr_SetFromWindowsErrWithFilename(0, NULL); - - v = _PyUnicode_New(usize); - if (v == NULL) - return NULL; - if (usize == 0) - return (PyObject *)v; - p = PyUnicode_AS_UNICODE(v); - if (0 == MultiByteToWideChar(CP_ACP, 0, s, size, p, usize)) { - Py_DECREF(v); - return PyErr_SetFromWindowsErrWithFilename(0, NULL); - } - - return (PyObject *)v; -} - -PyObject *PyUnicode_EncodeMBCS(const Py_UNICODE *p, - int size, - const char *errors) -{ - PyObject *repr; - char *s; - DWORD mbcssize; - - /* If there are no characters, bail now! */ - if (size==0) - return PyString_FromString(""); - - /* First get the size of the result */ - mbcssize = WideCharToMultiByte(CP_ACP, 0, p, size, NULL, 0, NULL, NULL); - if (mbcssize==0) - return PyErr_SetFromWindowsErrWithFilename(0, NULL); - - repr = PyString_FromStringAndSize(NULL, mbcssize); - if (repr == NULL) - return NULL; - if (mbcssize == 0) - return repr; - - /* Do the conversion */ - s = PyString_AS_STRING(repr); - if (0 == WideCharToMultiByte(CP_ACP, 0, p, size, s, mbcssize, NULL, NULL)) { - Py_DECREF(repr); - return PyErr_SetFromWindowsErrWithFilename(0, NULL); - } - return repr; -} - -PyObject *PyUnicode_AsMBCSString(PyObject *unicode) -{ - if (!PyUnicode_Check(unicode)) { - PyErr_BadArgument(); - return NULL; - } - return PyUnicode_EncodeMBCS(PyUnicode_AS_UNICODE(unicode), - PyUnicode_GET_SIZE(unicode), - NULL); -} - -#endif /* MS_WINDOWS */ - -/* --- Character Mapping Codec -------------------------------------------- */ - -PyObject *PyUnicode_DecodeCharmap(const char *s, - int size, - PyObject *mapping, - const char *errors) -{ - const char *starts = s; - int startinpos; - int endinpos; - int outpos; - const char *e; - PyUnicodeObject *v; - Py_UNICODE *p; - int extrachars = 0; - PyObject *errorHandler = NULL; - PyObject *exc = NULL; - - /* Default to Latin-1 */ - if (mapping == NULL) - return PyUnicode_DecodeLatin1(s, size, errors); - - v = _PyUnicode_New(size); - if (v == NULL) - goto onError; - if (size == 0) - return (PyObject *)v; - p = PyUnicode_AS_UNICODE(v); - e = s + size; - while (s < e) { - unsigned char ch = *s; - PyObject *w, *x; - - /* Get mapping (char ordinal -> integer, Unicode char or None) */ - w = PyInt_FromLong((long)ch); - if (w == NULL) - goto onError; - x = PyObject_GetItem(mapping, w); - Py_DECREF(w); - if (x == NULL) { - if (PyErr_ExceptionMatches(PyExc_LookupError)) { - /* No mapping found means: mapping is undefined. */ - PyErr_Clear(); - x = Py_None; - Py_INCREF(x); - } else - goto onError; - } - - /* Apply mapping */ - if (PyInt_Check(x)) { - long value = PyInt_AS_LONG(x); - if (value < 0 || value > 65535) { - PyErr_SetString(PyExc_TypeError, - "character mapping must be in range(65536)"); - Py_DECREF(x); - goto onError; - } - *p++ = (Py_UNICODE)value; - } - else if (x == Py_None) { - /* undefined mapping */ - outpos = p-PyUnicode_AS_UNICODE(v); - startinpos = s-starts; - endinpos = startinpos+1; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "charmap", "character maps to ", - starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) { - Py_DECREF(x); - goto onError; - } - continue; - } - else if (PyUnicode_Check(x)) { - int targetsize = PyUnicode_GET_SIZE(x); - - if (targetsize == 1) - /* 1-1 mapping */ - *p++ = *PyUnicode_AS_UNICODE(x); - - else if (targetsize > 1) { - /* 1-n mapping */ - if (targetsize > extrachars) { - /* resize first */ - int oldpos = (int)(p - PyUnicode_AS_UNICODE(v)); - int needed = (targetsize - extrachars) + \ - (targetsize << 2); - extrachars += needed; - if (_PyUnicode_Resize(&v, - PyUnicode_GET_SIZE(v) + needed)) { - Py_DECREF(x); - goto onError; - } - p = PyUnicode_AS_UNICODE(v) + oldpos; - } - Py_UNICODE_COPY(p, - PyUnicode_AS_UNICODE(x), - targetsize); - p += targetsize; - extrachars -= targetsize; - } - /* 1-0 mapping: skip the character */ - } - else { - /* wrong return value */ - PyErr_SetString(PyExc_TypeError, - "character mapping must return integer, None or unicode"); - Py_DECREF(x); - goto onError; - } - Py_DECREF(x); - ++s; - } - if (p - PyUnicode_AS_UNICODE(v) < PyUnicode_GET_SIZE(v)) - if (_PyUnicode_Resize(&v, (int)(p - PyUnicode_AS_UNICODE(v)))) - goto onError; - Py_XDECREF(errorHandler); - Py_XDECREF(exc); - return (PyObject *)v; - - onError: - Py_XDECREF(errorHandler); - Py_XDECREF(exc); - Py_XDECREF(v); - return NULL; -} - -/* Lookup the character ch in the mapping. If the character - can't be found, Py_None is returned (or NULL, if another - error occured). */ -static PyObject *charmapencode_lookup(Py_UNICODE c, PyObject *mapping) -{ - PyObject *w = PyInt_FromLong((long)c); - PyObject *x; - - if (w == NULL) - return NULL; - x = PyObject_GetItem(mapping, w); - Py_DECREF(w); - if (x == NULL) { - if (PyErr_ExceptionMatches(PyExc_LookupError)) { - /* No mapping found means: mapping is undefined. */ - PyErr_Clear(); - x = Py_None; - Py_INCREF(x); - return x; - } else - return NULL; - } - else if (x == Py_None) - return x; - else if (PyInt_Check(x)) { - long value = PyInt_AS_LONG(x); - if (value < 0 || value > 255) { - PyErr_SetString(PyExc_TypeError, - "character mapping must be in range(256)"); - Py_DECREF(x); - return NULL; - } - return x; - } - else if (PyString_Check(x)) - return x; - else { - /* wrong return value */ - PyErr_SetString(PyExc_TypeError, - "character mapping must return integer, None or str"); - Py_DECREF(x); - return NULL; - } -} - -/* lookup the character, put the result in the output string and adjust - various state variables. Reallocate the output string if not enough - space is available. Return a new reference to the object that - was put in the output buffer, or Py_None, if the mapping was undefined - (in which case no character was written) or NULL, if a - reallocation error ocurred. The called must decref the result */ -static -PyObject *charmapencode_output(Py_UNICODE c, PyObject *mapping, - PyObject **outobj, int *outpos) -{ - PyObject *rep = charmapencode_lookup(c, mapping); - - if (rep==NULL) - return NULL; - else if (rep==Py_None) - return rep; - else { - char *outstart = PyString_AS_STRING(*outobj); - int outsize = PyString_GET_SIZE(*outobj); - if (PyInt_Check(rep)) { - int requiredsize = *outpos+1; - if (outsize0; ++uni2) { - x = charmapencode_output(*uni2, mapping, res, respos); - if (x==NULL) { - Py_DECREF(repunicode); - return -1; - } - else if (x==Py_None) { - Py_DECREF(repunicode); - Py_DECREF(x); - raise_encode_exception(exceptionObject, encoding, p, size, collstartpos, collendpos, reason); - return -1; - } - Py_DECREF(x); - } - *inpos = newpos; - Py_DECREF(repunicode); - } - return 0; -} - -PyObject *PyUnicode_EncodeCharmap(const Py_UNICODE *p, - int size, - PyObject *mapping, - const char *errors) -{ - /* output object */ - PyObject *res = NULL; - /* current input position */ - int inpos = 0; - /* current output position */ - int respos = 0; - PyObject *errorHandler = NULL; - PyObject *exc = NULL; - /* the following variable is used for caching string comparisons - * -1=not initialized, 0=unknown, 1=strict, 2=replace, - * 3=ignore, 4=xmlcharrefreplace */ - int known_errorHandler = -1; - - /* Default to Latin-1 */ - if (mapping == NULL) - return PyUnicode_EncodeLatin1(p, size, errors); - - /* allocate enough for a simple encoding without - replacements, if we need more, we'll resize */ - res = PyString_FromStringAndSize(NULL, size); - if (res == NULL) - goto onError; - if (size == 0) - return res; - - while (inpos adjust input position */ - ++inpos; - Py_DECREF(x); - } - - /* Resize if we allocated to much */ - if (respossize) { - PyErr_Format(PyExc_IndexError, "position %d from error handler out of bounds", *newpos); - Py_DECREF(restuple); - return NULL; - } - Py_INCREF(resunicode); - Py_DECREF(restuple); - return resunicode; -} - -/* Lookup the character ch in the mapping and put the result in result, - which must be decrefed by the caller. - Return 0 on success, -1 on error */ -static -int charmaptranslate_lookup(Py_UNICODE c, PyObject *mapping, PyObject **result) -{ - PyObject *w = PyInt_FromLong((long)c); - PyObject *x; - - if (w == NULL) - return -1; - x = PyObject_GetItem(mapping, w); - Py_DECREF(w); - if (x == NULL) { - if (PyErr_ExceptionMatches(PyExc_LookupError)) { - /* No mapping found means: use 1:1 mapping. */ - PyErr_Clear(); - *result = NULL; - return 0; - } else - return -1; - } - else if (x == Py_None) { - *result = x; - return 0; - } - else if (PyInt_Check(x)) { - long value = PyInt_AS_LONG(x); - long max = PyUnicode_GetMax(); - if (value < 0 || value > max) { - PyErr_Format(PyExc_TypeError, - "character mapping must be in range(0x%lx)", max+1); - Py_DECREF(x); - return -1; - } - *result = x; - return 0; - } - else if (PyUnicode_Check(x)) { - *result = x; - return 0; - } - else { - /* wrong return value */ - PyErr_SetString(PyExc_TypeError, - "character mapping must return integer, None or unicode"); - Py_DECREF(x); - return -1; - } -} -/* ensure that *outobj is at least requiredsize characters long, -if not reallocate and adjust various state variables. -Return 0 on success, -1 on error */ -static -int charmaptranslate_makespace(PyObject **outobj, Py_UNICODE **outp, - int requiredsize) -{ - int oldsize = PyUnicode_GET_SIZE(*outobj); - if (requiredsize > oldsize) { - /* remember old output position */ - int outpos = *outp-PyUnicode_AS_UNICODE(*outobj); - /* exponentially overallocate to minimize reallocations */ - if (requiredsize < 2 * oldsize) - requiredsize = 2 * oldsize; - if (_PyUnicode_Resize(outobj, requiredsize)) - return -1; - *outp = PyUnicode_AS_UNICODE(*outobj) + outpos; - } - return 0; -} -/* lookup the character, put the result in the output string and adjust - various state variables. Return a new reference to the object that - was put in the output buffer in *result, or Py_None, if the mapping was - undefined (in which case no character was written). - The called must decref result. - Return 0 on success, -1 on error. */ -static -int charmaptranslate_output(const Py_UNICODE *startinp, const Py_UNICODE *curinp, - int insize, PyObject *mapping, PyObject **outobj, Py_UNICODE **outp, - PyObject **res) -{ - if (charmaptranslate_lookup(*curinp, mapping, res)) - return -1; - if (*res==NULL) { - /* not found => default to 1:1 mapping */ - *(*outp)++ = *curinp; - } - else if (*res==Py_None) - ; - else if (PyInt_Check(*res)) { - /* no overflow check, because we know that the space is enough */ - *(*outp)++ = (Py_UNICODE)PyInt_AS_LONG(*res); - } - else if (PyUnicode_Check(*res)) { - int repsize = PyUnicode_GET_SIZE(*res); - if (repsize==1) { - /* no overflow check, because we know that the space is enough */ - *(*outp)++ = *PyUnicode_AS_UNICODE(*res); - } - else if (repsize!=0) { - /* more than one character */ - int requiredsize = (*outp-PyUnicode_AS_UNICODE(*outobj)) + - (insize - (*curinp-*startinp)) + - repsize - 1; - if (charmaptranslate_makespace(outobj, outp, requiredsize)) - return -1; - memcpy(*outp, PyUnicode_AS_UNICODE(*res), sizeof(Py_UNICODE)*repsize); - *outp += repsize; - } - } - else - return -1; - return 0; -} - -PyObject *PyUnicode_TranslateCharmap(const Py_UNICODE *p, - int size, - PyObject *mapping, - const char *errors) -{ - /* output object */ - PyObject *res = NULL; - /* pointers to the beginning and end+1 of input */ - const Py_UNICODE *startp = p; - const Py_UNICODE *endp = p + size; - /* pointer into the output */ - Py_UNICODE *str; - /* current output position */ - int respos = 0; - char *reason = "character maps to "; - PyObject *errorHandler = NULL; - PyObject *exc = NULL; - /* the following variable is used for caching string comparisons - * -1=not initialized, 0=unknown, 1=strict, 2=replace, - * 3=ignore, 4=xmlcharrefreplace */ - int known_errorHandler = -1; - - if (mapping == NULL) { - PyErr_BadArgument(); - return NULL; - } - - /* allocate enough for a simple 1:1 translation without - replacements, if we need more, we'll resize */ - res = PyUnicode_FromUnicode(NULL, size); - if (res == NULL) - goto onError; - if (size == 0) - return res; - str = PyUnicode_AS_UNICODE(res); - - while (p adjust input pointer */ - ++p; - else { /* untranslatable character */ - PyObject *repunicode = NULL; /* initialize to prevent gcc warning */ - int repsize; - int newpos; - Py_UNICODE *uni2; - /* startpos for collecting untranslatable chars */ - const Py_UNICODE *collstart = p; - const Py_UNICODE *collend = p+1; - const Py_UNICODE *coll; - - /* find all untranslatable characters */ - while (collend < endp) { - if (charmaptranslate_lookup(*collend, mapping, &x)) - goto onError; - Py_XDECREF(x); - if (x!=Py_None) - break; - ++collend; - } - /* cache callback name lookup - * (if not done yet, i.e. it's the first error) */ - if (known_errorHandler==-1) { - if ((errors==NULL) || (!strcmp(errors, "strict"))) - known_errorHandler = 1; - else if (!strcmp(errors, "replace")) - known_errorHandler = 2; - else if (!strcmp(errors, "ignore")) - known_errorHandler = 3; - else if (!strcmp(errors, "xmlcharrefreplace")) - known_errorHandler = 4; - else - known_errorHandler = 0; - } - switch (known_errorHandler) { - case 1: /* strict */ - raise_translate_exception(&exc, startp, size, collstart-startp, collend-startp, reason); - goto onError; - case 2: /* replace */ - /* No need to check for space, this is a 1:1 replacement */ - for (coll = collstart; coll0; ++uni2) - *str++ = *uni2; - p = startp + newpos; - Py_DECREF(repunicode); - } - } - } - /* Resize if we allocated to much */ - respos = str-PyUnicode_AS_UNICODE(res); - if (respos= 0) { - *output++ = '0' + decimal; - ++p; - continue; - } - if (0 < ch && ch < 256) { - *output++ = (char)ch; - ++p; - continue; - } - /* All other characters are considered unencodable */ - collstart = p; - collend = p+1; - while (collend < end) { - if ((0 < *collend && *collend < 256) || - !Py_UNICODE_ISSPACE(*collend) || - Py_UNICODE_TODECIMAL(*collend)) - break; - } - /* cache callback name lookup - * (if not done yet, i.e. it's the first error) */ - if (known_errorHandler==-1) { - if ((errors==NULL) || (!strcmp(errors, "strict"))) - known_errorHandler = 1; - else if (!strcmp(errors, "replace")) - known_errorHandler = 2; - else if (!strcmp(errors, "ignore")) - known_errorHandler = 3; - else if (!strcmp(errors, "xmlcharrefreplace")) - known_errorHandler = 4; - else - known_errorHandler = 0; - } - switch (known_errorHandler) { - case 1: /* strict */ - raise_encode_exception(&exc, encoding, s, length, collstart-s, collend-s, reason); - goto onError; - case 2: /* replace */ - for (p = collstart; p < collend; ++p) - *output++ = '?'; - /* fall through */ - case 3: /* ignore */ - p = collend; - break; - case 4: /* xmlcharrefreplace */ - /* generate replacement (temporarily (mis)uses p) */ - for (p = collstart; p < collend; ++p) - output += sprintf(output, "&#%d;", (int)*p); - p = collend; - break; - default: - repunicode = unicode_encode_call_errorhandler(errors, &errorHandler, - encoding, reason, s, length, &exc, - collstart-s, collend-s, &newpos); - if (repunicode == NULL) - goto onError; - /* generate replacement */ - repsize = PyUnicode_GET_SIZE(repunicode); - for (uni2 = PyUnicode_AS_UNICODE(repunicode); repsize-->0; ++uni2) { - Py_UNICODE ch = *uni2; - if (Py_UNICODE_ISSPACE(ch)) - *output++ = ' '; - else { - decimal = Py_UNICODE_TODECIMAL(ch); - if (decimal >= 0) - *output++ = '0' + decimal; - else if (0 < ch && ch < 256) - *output++ = (char)ch; - else { - Py_DECREF(repunicode); - raise_encode_exception(&exc, encoding, - s, length, collstart-s, collend-s, reason); - goto onError; - } - } - } - p = s + newpos; - Py_DECREF(repunicode); - } - } - /* 0-terminate the output string */ - *output++ = '\0'; - Py_XDECREF(exc); - Py_XDECREF(errorHandler); - return 0; - - onError: - Py_XDECREF(exc); - Py_XDECREF(errorHandler); - return -1; -} - -/* --- Helpers ------------------------------------------------------------ */ - -static -int count(PyUnicodeObject *self, - int start, - int end, - PyUnicodeObject *substring) -{ - int count = 0; - - if (start < 0) - start += self->length; - if (start < 0) - start = 0; - if (end > self->length) - end = self->length; - if (end < 0) - end += self->length; - if (end < 0) - end = 0; - - if (substring->length == 0) - return (end - start + 1); - - end -= substring->length; - - while (start <= end) - if (Py_UNICODE_MATCH(self, start, substring)) { - count++; - start += substring->length; - } else - start++; - - return count; -} - -int PyUnicode_Count(PyObject *str, - PyObject *substr, - int start, - int end) -{ - int result; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return -1; - substr = PyUnicode_FromObject(substr); - if (substr == NULL) { - Py_DECREF(str); - return -1; - } - - result = count((PyUnicodeObject *)str, - start, end, - (PyUnicodeObject *)substr); - - Py_DECREF(str); - Py_DECREF(substr); - return result; -} - -static -int findstring(PyUnicodeObject *self, - PyUnicodeObject *substring, - int start, - int end, - int direction) -{ - if (start < 0) - start += self->length; - if (start < 0) - start = 0; - - if (end > self->length) - end = self->length; - if (end < 0) - end += self->length; - if (end < 0) - end = 0; - - if (substring->length == 0) - return (direction > 0) ? start : end; - - end -= substring->length; - - if (direction < 0) { - for (; end >= start; end--) - if (Py_UNICODE_MATCH(self, end, substring)) - return end; - } else { - for (; start <= end; start++) - if (Py_UNICODE_MATCH(self, start, substring)) - return start; - } - - return -1; -} - -int PyUnicode_Find(PyObject *str, - PyObject *substr, - int start, - int end, - int direction) -{ - int result; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return -2; - substr = PyUnicode_FromObject(substr); - if (substr == NULL) { - Py_DECREF(str); - return -2; - } - - result = findstring((PyUnicodeObject *)str, - (PyUnicodeObject *)substr, - start, end, direction); - Py_DECREF(str); - Py_DECREF(substr); - return result; -} - -static -int tailmatch(PyUnicodeObject *self, - PyUnicodeObject *substring, - int start, - int end, - int direction) -{ - if (start < 0) - start += self->length; - if (start < 0) - start = 0; - - if (substring->length == 0) - return 1; - - if (end > self->length) - end = self->length; - if (end < 0) - end += self->length; - if (end < 0) - end = 0; - - end -= substring->length; - if (end < start) - return 0; - - if (direction > 0) { - if (Py_UNICODE_MATCH(self, end, substring)) - return 1; - } else { - if (Py_UNICODE_MATCH(self, start, substring)) - return 1; - } - - return 0; -} - -int PyUnicode_Tailmatch(PyObject *str, - PyObject *substr, - int start, - int end, - int direction) -{ - int result; - - str = PyUnicode_FromObject(str); - if (str == NULL) - return -1; - substr = PyUnicode_FromObject(substr); - if (substr == NULL) { - Py_DECREF(substr); - return -1; - } - - result = tailmatch((PyUnicodeObject *)str, - (PyUnicodeObject *)substr, - start, end, direction); - Py_DECREF(str); - Py_DECREF(substr); - return result; -} - -static -const Py_UNICODE *findchar(const Py_UNICODE *s, - int size, - Py_UNICODE ch) -{ - /* like wcschr, but doesn't stop at NULL characters */ - - while (size-- > 0) { - if (*s == ch) - return s; - s++; - } - - return NULL; -} - -/* Apply fixfct filter to the Unicode object self and return a - reference to the modified object */ - -static -PyObject *fixup(PyUnicodeObject *self, - int (*fixfct)(PyUnicodeObject *s)) -{ - - PyUnicodeObject *u; - - u = (PyUnicodeObject*) PyUnicode_FromUnicode(NULL, self->length); - if (u == NULL) - return NULL; - - Py_UNICODE_COPY(u->str, self->str, self->length); - - if (!fixfct(u) && PyUnicode_CheckExact(self)) { - /* fixfct should return TRUE if it modified the buffer. If - FALSE, return a reference to the original buffer instead - (to save space, not time) */ - Py_INCREF(self); - Py_DECREF(u); - return (PyObject*) self; - } - return (PyObject*) u; -} - -static -int fixupper(PyUnicodeObject *self) -{ - int len = self->length; - Py_UNICODE *s = self->str; - int status = 0; - - while (len-- > 0) { - register Py_UNICODE ch; - - ch = Py_UNICODE_TOUPPER(*s); - if (ch != *s) { - status = 1; - *s = ch; - } - s++; - } - - return status; -} - -static -int fixlower(PyUnicodeObject *self) -{ - int len = self->length; - Py_UNICODE *s = self->str; - int status = 0; - - while (len-- > 0) { - register Py_UNICODE ch; - - ch = Py_UNICODE_TOLOWER(*s); - if (ch != *s) { - status = 1; - *s = ch; - } - s++; - } - - return status; -} - -static -int fixswapcase(PyUnicodeObject *self) -{ - int len = self->length; - Py_UNICODE *s = self->str; - int status = 0; - - while (len-- > 0) { - if (Py_UNICODE_ISUPPER(*s)) { - *s = Py_UNICODE_TOLOWER(*s); - status = 1; - } else if (Py_UNICODE_ISLOWER(*s)) { - *s = Py_UNICODE_TOUPPER(*s); - status = 1; - } - s++; - } - - return status; -} - -static -int fixcapitalize(PyUnicodeObject *self) -{ - int len = self->length; - Py_UNICODE *s = self->str; - int status = 0; - - if (len == 0) - return 0; - if (Py_UNICODE_ISLOWER(*s)) { - *s = Py_UNICODE_TOUPPER(*s); - status = 1; - } - s++; - while (--len > 0) { - if (Py_UNICODE_ISUPPER(*s)) { - *s = Py_UNICODE_TOLOWER(*s); - status = 1; - } - s++; - } - return status; -} - -static -int fixtitle(PyUnicodeObject *self) -{ - register Py_UNICODE *p = PyUnicode_AS_UNICODE(self); - register Py_UNICODE *e; - int previous_is_cased; - - /* Shortcut for single character strings */ - if (PyUnicode_GET_SIZE(self) == 1) { - Py_UNICODE ch = Py_UNICODE_TOTITLE(*p); - if (*p != ch) { - *p = ch; - return 1; - } - else - return 0; - } - - e = p + PyUnicode_GET_SIZE(self); - previous_is_cased = 0; - for (; p < e; p++) { - register const Py_UNICODE ch = *p; - - if (previous_is_cased) - *p = Py_UNICODE_TOLOWER(ch); - else - *p = Py_UNICODE_TOTITLE(ch); - - if (Py_UNICODE_ISLOWER(ch) || - Py_UNICODE_ISUPPER(ch) || - Py_UNICODE_ISTITLE(ch)) - previous_is_cased = 1; - else - previous_is_cased = 0; - } - return 1; -} - -PyObject *PyUnicode_Join(PyObject *separator, - PyObject *seq) -{ - Py_UNICODE *sep; - int seplen; - PyUnicodeObject *res = NULL; - int reslen = 0; - Py_UNICODE *p; - int sz = 100; - int i; - PyObject *it; - - it = PyObject_GetIter(seq); - if (it == NULL) - return NULL; - - if (separator == NULL) { - Py_UNICODE blank = ' '; - sep = ␣ - seplen = 1; - } - else { - separator = PyUnicode_FromObject(separator); - if (separator == NULL) - goto onError; - sep = PyUnicode_AS_UNICODE(separator); - seplen = PyUnicode_GET_SIZE(separator); - } - - res = _PyUnicode_New(sz); - if (res == NULL) - goto onError; - p = PyUnicode_AS_UNICODE(res); - reslen = 0; - - for (i = 0; ; ++i) { - int itemlen; - PyObject *item = PyIter_Next(it); - if (item == NULL) { - if (PyErr_Occurred()) - goto onError; - break; - } - if (!PyUnicode_Check(item)) { - PyObject *v; - if (!PyString_Check(item)) { - PyErr_Format(PyExc_TypeError, - "sequence item %i: expected string or Unicode," - " %.80s found", - i, item->ob_type->tp_name); - Py_DECREF(item); - goto onError; - } - v = PyUnicode_FromObject(item); - Py_DECREF(item); - item = v; - if (item == NULL) - goto onError; - } - itemlen = PyUnicode_GET_SIZE(item); - while (reslen + itemlen + seplen >= sz) { - if (_PyUnicode_Resize(&res, sz*2)) { - Py_DECREF(item); - goto onError; - } - sz *= 2; - p = PyUnicode_AS_UNICODE(res) + reslen; - } - if (i > 0) { - Py_UNICODE_COPY(p, sep, seplen); - p += seplen; - reslen += seplen; - } - Py_UNICODE_COPY(p, PyUnicode_AS_UNICODE(item), itemlen); - p += itemlen; - reslen += itemlen; - Py_DECREF(item); - } - if (_PyUnicode_Resize(&res, reslen)) - goto onError; - - Py_XDECREF(separator); - Py_DECREF(it); - return (PyObject *)res; - - onError: - Py_XDECREF(separator); - Py_XDECREF(res); - Py_DECREF(it); - return NULL; -} - -static -PyUnicodeObject *pad(PyUnicodeObject *self, - int left, - int right, - Py_UNICODE fill) -{ - PyUnicodeObject *u; - - if (left < 0) - left = 0; - if (right < 0) - right = 0; - - if (left == 0 && right == 0 && PyUnicode_CheckExact(self)) { - Py_INCREF(self); - return self; - } - - u = _PyUnicode_New(left + self->length + right); - if (u) { - if (left) - Py_UNICODE_FILL(u->str, fill, left); - Py_UNICODE_COPY(u->str + left, self->str, self->length); - if (right) - Py_UNICODE_FILL(u->str + left + self->length, fill, right); - } - - return u; -} - -#define SPLIT_APPEND(data, left, right) \ - str = PyUnicode_FromUnicode(data + left, right - left); \ - if (!str) \ - goto onError; \ - if (PyList_Append(list, str)) { \ - Py_DECREF(str); \ - goto onError; \ - } \ - else \ - Py_DECREF(str); - -static -PyObject *split_whitespace(PyUnicodeObject *self, - PyObject *list, - int maxcount) -{ - register int i; - register int j; - int len = self->length; - PyObject *str; - - for (i = j = 0; i < len; ) { - /* find a token */ - while (i < len && Py_UNICODE_ISSPACE(self->str[i])) - i++; - j = i; - while (i < len && !Py_UNICODE_ISSPACE(self->str[i])) - i++; - if (j < i) { - if (maxcount-- <= 0) - break; - SPLIT_APPEND(self->str, j, i); - while (i < len && Py_UNICODE_ISSPACE(self->str[i])) - i++; - j = i; - } - } - if (j < len) { - SPLIT_APPEND(self->str, j, len); - } - return list; - - onError: - Py_DECREF(list); - return NULL; -} - -PyObject *PyUnicode_Splitlines(PyObject *string, - int keepends) -{ - register int i; - register int j; - int len; - PyObject *list; - PyObject *str; - Py_UNICODE *data; - - string = PyUnicode_FromObject(string); - if (string == NULL) - return NULL; - data = PyUnicode_AS_UNICODE(string); - len = PyUnicode_GET_SIZE(string); - - list = PyList_New(0); - if (!list) - goto onError; - - for (i = j = 0; i < len; ) { - int eol; - - /* Find a line and append it */ - while (i < len && !Py_UNICODE_ISLINEBREAK(data[i])) - i++; - - /* Skip the line break reading CRLF as one line break */ - eol = i; - if (i < len) { - if (data[i] == '\r' && i + 1 < len && - data[i+1] == '\n') - i += 2; - else - i++; - if (keepends) - eol = i; - } - SPLIT_APPEND(data, j, eol); - j = i; - } - if (j < len) { - SPLIT_APPEND(data, j, len); - } - - Py_DECREF(string); - return list; - - onError: - Py_DECREF(list); - Py_DECREF(string); - return NULL; -} - -static -PyObject *split_char(PyUnicodeObject *self, - PyObject *list, - Py_UNICODE ch, - int maxcount) -{ - register int i; - register int j; - int len = self->length; - PyObject *str; - - for (i = j = 0; i < len; ) { - if (self->str[i] == ch) { - if (maxcount-- <= 0) - break; - SPLIT_APPEND(self->str, j, i); - i = j = i + 1; - } else - i++; - } - if (j <= len) { - SPLIT_APPEND(self->str, j, len); - } - return list; - - onError: - Py_DECREF(list); - return NULL; -} - -static -PyObject *split_substring(PyUnicodeObject *self, - PyObject *list, - PyUnicodeObject *substring, - int maxcount) -{ - register int i; - register int j; - int len = self->length; - int sublen = substring->length; - PyObject *str; - - for (i = j = 0; i <= len - sublen; ) { - if (Py_UNICODE_MATCH(self, i, substring)) { - if (maxcount-- <= 0) - break; - SPLIT_APPEND(self->str, j, i); - i = j = i + sublen; - } else - i++; - } - if (j <= len) { - SPLIT_APPEND(self->str, j, len); - } - return list; - - onError: - Py_DECREF(list); - return NULL; -} - -#undef SPLIT_APPEND - -static -PyObject *split(PyUnicodeObject *self, - PyUnicodeObject *substring, - int maxcount) -{ - PyObject *list; - - if (maxcount < 0) - maxcount = INT_MAX; - - list = PyList_New(0); - if (!list) - return NULL; - - if (substring == NULL) - return split_whitespace(self,list,maxcount); - - else if (substring->length == 1) - return split_char(self,list,substring->str[0],maxcount); - - else if (substring->length == 0) { - Py_DECREF(list); - PyErr_SetString(PyExc_ValueError, "empty separator"); - return NULL; - } - else - return split_substring(self,list,substring,maxcount); -} - -static -PyObject *replace(PyUnicodeObject *self, - PyUnicodeObject *str1, - PyUnicodeObject *str2, - int maxcount) -{ - PyUnicodeObject *u; - - if (maxcount < 0) - maxcount = INT_MAX; - - if (str1->length == 1 && str2->length == 1) { - int i; - - /* replace characters */ - if (!findchar(self->str, self->length, str1->str[0]) && - PyUnicode_CheckExact(self)) { - /* nothing to replace, return original string */ - Py_INCREF(self); - u = self; - } else { - Py_UNICODE u1 = str1->str[0]; - Py_UNICODE u2 = str2->str[0]; - - u = (PyUnicodeObject*) PyUnicode_FromUnicode( - NULL, - self->length - ); - if (u != NULL) { - Py_UNICODE_COPY(u->str, self->str, - self->length); - for (i = 0; i < u->length; i++) - if (u->str[i] == u1) { - if (--maxcount < 0) - break; - u->str[i] = u2; - } - } - } - - } else { - int n, i; - Py_UNICODE *p; - - /* replace strings */ - n = count(self, 0, self->length, str1); - if (n > maxcount) - n = maxcount; - if (n == 0) { - /* nothing to replace, return original string */ - if (PyUnicode_CheckExact(self)) { - Py_INCREF(self); - u = self; - } - else { - u = (PyUnicodeObject *) - PyUnicode_FromUnicode(self->str, self->length); - } - } else { - u = _PyUnicode_New( - self->length + n * (str2->length - str1->length)); - if (u) { - i = 0; - p = u->str; - if (str1->length > 0) { - while (i <= self->length - str1->length) - if (Py_UNICODE_MATCH(self, i, str1)) { - /* replace string segment */ - Py_UNICODE_COPY(p, str2->str, str2->length); - p += str2->length; - i += str1->length; - if (--n <= 0) { - /* copy remaining part */ - Py_UNICODE_COPY(p, self->str+i, self->length-i); - break; - } - } else - *p++ = self->str[i++]; - } else { - while (n > 0) { - Py_UNICODE_COPY(p, str2->str, str2->length); - p += str2->length; - if (--n <= 0) - break; - *p++ = self->str[i++]; - } - Py_UNICODE_COPY(p, self->str+i, self->length-i); - } - } - } - } - - return (PyObject *) u; -} - -/* --- Unicode Object Methods --------------------------------------------- */ - -PyDoc_STRVAR(title__doc__, -"S.title() -> unicode\n\ -\n\ -Return a titlecased version of S, i.e. words start with title case\n\ -characters, all remaining cased characters have lower case."); - -static PyObject* -unicode_title(PyUnicodeObject *self) -{ - return fixup(self, fixtitle); -} - -PyDoc_STRVAR(capitalize__doc__, -"S.capitalize() -> unicode\n\ -\n\ -Return a capitalized version of S, i.e. make the first character\n\ -have upper case."); - -static PyObject* -unicode_capitalize(PyUnicodeObject *self) -{ - return fixup(self, fixcapitalize); -} - -#if 0 -PyDoc_STRVAR(capwords__doc__, -"S.capwords() -> unicode\n\ -\n\ -Apply .capitalize() to all words in S and return the result with\n\ -normalized whitespace (all whitespace strings are replaced by ' ')."); - -static PyObject* -unicode_capwords(PyUnicodeObject *self) -{ - PyObject *list; - PyObject *item; - int i; - - /* Split into words */ - list = split(self, NULL, -1); - if (!list) - return NULL; - - /* Capitalize each word */ - for (i = 0; i < PyList_GET_SIZE(list); i++) { - item = fixup((PyUnicodeObject *)PyList_GET_ITEM(list, i), - fixcapitalize); - if (item == NULL) - goto onError; - Py_DECREF(PyList_GET_ITEM(list, i)); - PyList_SET_ITEM(list, i, item); - } - - /* Join the words to form a new string */ - item = PyUnicode_Join(NULL, list); - -onError: - Py_DECREF(list); - return (PyObject *)item; -} -#endif - -PyDoc_STRVAR(center__doc__, -"S.center(width) -> unicode\n\ -\n\ -Return S centered in a Unicode string of length width. Padding is done\n\ -using spaces."); - -static PyObject * -unicode_center(PyUnicodeObject *self, PyObject *args) -{ - int marg, left; - int width; - - if (!PyArg_ParseTuple(args, "i:center", &width)) - return NULL; - - if (self->length >= width && PyUnicode_CheckExact(self)) { - Py_INCREF(self); - return (PyObject*) self; - } - - marg = width - self->length; - left = marg / 2 + (marg & width & 1); - - return (PyObject*) pad(self, left, marg - left, ' '); -} - -#if 0 - -/* This code should go into some future Unicode collation support - module. The basic comparison should compare ordinals on a naive - basis (this is what Java does and thus JPython too). */ - -/* speedy UTF-16 code point order comparison */ -/* gleaned from: */ -/* http://www-4.ibm.com/software/developer/library/utf16.html?dwzone=unicode */ - -static short utf16Fixup[32] = -{ - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0x2000, -0x800, -0x800, -0x800, -0x800 -}; - -static int -unicode_compare(PyUnicodeObject *str1, PyUnicodeObject *str2) -{ - int len1, len2; - - Py_UNICODE *s1 = str1->str; - Py_UNICODE *s2 = str2->str; - - len1 = str1->length; - len2 = str2->length; - - while (len1 > 0 && len2 > 0) { - Py_UNICODE c1, c2; - - c1 = *s1++; - c2 = *s2++; - - if (c1 > (1<<11) * 26) - c1 += utf16Fixup[c1>>11]; - if (c2 > (1<<11) * 26) - c2 += utf16Fixup[c2>>11]; - /* now c1 and c2 are in UTF-32-compatible order */ - - if (c1 != c2) - return (c1 < c2) ? -1 : 1; - - len1--; len2--; - } - - return (len1 < len2) ? -1 : (len1 != len2); -} - -#else - -static int -unicode_compare(PyUnicodeObject *str1, PyUnicodeObject *str2) -{ - register int len1, len2; - - Py_UNICODE *s1 = str1->str; - Py_UNICODE *s2 = str2->str; - - len1 = str1->length; - len2 = str2->length; - - while (len1 > 0 && len2 > 0) { - Py_UNICODE c1, c2; - - c1 = *s1++; - c2 = *s2++; - - if (c1 != c2) - return (c1 < c2) ? -1 : 1; - - len1--; len2--; - } - - return (len1 < len2) ? -1 : (len1 != len2); -} - -#endif - -int PyUnicode_Compare(PyObject *left, - PyObject *right) -{ - PyUnicodeObject *u = NULL, *v = NULL; - int result; - - /* Coerce the two arguments */ - u = (PyUnicodeObject *)PyUnicode_FromObject(left); - if (u == NULL) - goto onError; - v = (PyUnicodeObject *)PyUnicode_FromObject(right); - if (v == NULL) - goto onError; - - /* Shortcut for empty or interned objects */ - if (v == u) { - Py_DECREF(u); - Py_DECREF(v); - return 0; - } - - result = unicode_compare(u, v); - - Py_DECREF(u); - Py_DECREF(v); - return result; - -onError: - Py_XDECREF(u); - Py_XDECREF(v); - return -1; -} - -int PyUnicode_Contains(PyObject *container, - PyObject *element) -{ - PyUnicodeObject *u = NULL, *v = NULL; - int result, size; - register const Py_UNICODE *lhs, *end, *rhs; - - /* Coerce the two arguments */ - v = (PyUnicodeObject *)PyUnicode_FromObject(element); - if (v == NULL) { - PyErr_SetString(PyExc_TypeError, - "'in ' requires string as left operand"); - goto onError; - } - u = (PyUnicodeObject *)PyUnicode_FromObject(container); - if (u == NULL) - goto onError; - - size = PyUnicode_GET_SIZE(v); - rhs = PyUnicode_AS_UNICODE(v); - lhs = PyUnicode_AS_UNICODE(u); - - result = 0; - if (size == 1) { - end = lhs + PyUnicode_GET_SIZE(u); - while (lhs < end) { - if (*lhs++ == *rhs) { - result = 1; - break; - } - } - } - else { - end = lhs + (PyUnicode_GET_SIZE(u) - size); - while (lhs <= end) { - if (memcmp(lhs++, rhs, size * sizeof(Py_UNICODE)) == 0) { - result = 1; - break; - } - } - } - - Py_DECREF(u); - Py_DECREF(v); - return result; - -onError: - Py_XDECREF(u); - Py_XDECREF(v); - return -1; -} - -/* Concat to string or Unicode object giving a new Unicode object. */ - -PyObject *PyUnicode_Concat(PyObject *left, - PyObject *right) -{ - PyUnicodeObject *u = NULL, *v = NULL, *w; - - /* Coerce the two arguments */ - u = (PyUnicodeObject *)PyUnicode_FromObject(left); - if (u == NULL) - goto onError; - v = (PyUnicodeObject *)PyUnicode_FromObject(right); - if (v == NULL) - goto onError; - - /* Shortcuts */ - if (v == unicode_empty) { - Py_DECREF(v); - return (PyObject *)u; - } - if (u == unicode_empty) { - Py_DECREF(u); - return (PyObject *)v; - } - - /* Concat the two Unicode strings */ - w = _PyUnicode_New(u->length + v->length); - if (w == NULL) - goto onError; - Py_UNICODE_COPY(w->str, u->str, u->length); - Py_UNICODE_COPY(w->str + u->length, v->str, v->length); - - Py_DECREF(u); - Py_DECREF(v); - return (PyObject *)w; - -onError: - Py_XDECREF(u); - Py_XDECREF(v); - return NULL; -} - -PyDoc_STRVAR(count__doc__, -"S.count(sub[, start[, end]]) -> int\n\ -\n\ -Return the number of occurrences of substring sub in Unicode string\n\ -S[start:end]. Optional arguments start and end are\n\ -interpreted as in slice notation."); - -static PyObject * -unicode_count(PyUnicodeObject *self, PyObject *args) -{ - PyUnicodeObject *substring; - int start = 0; - int end = INT_MAX; - PyObject *result; - - if (!PyArg_ParseTuple(args, "O|O&O&:count", &substring, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) - return NULL; - - substring = (PyUnicodeObject *)PyUnicode_FromObject( - (PyObject *)substring); - if (substring == NULL) - return NULL; - - if (start < 0) - start += self->length; - if (start < 0) - start = 0; - if (end > self->length) - end = self->length; - if (end < 0) - end += self->length; - if (end < 0) - end = 0; - - result = PyInt_FromLong((long) count(self, start, end, substring)); - - Py_DECREF(substring); - return result; -} - -PyDoc_STRVAR(encode__doc__, -"S.encode([encoding[,errors]]) -> string\n\ -\n\ -Return an encoded string version of S. Default encoding is the current\n\ -default string encoding. errors may be given to set a different error\n\ -handling scheme. Default is 'strict' meaning that encoding errors raise\n\ -a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and\n\ -'xmlcharrefreplace' as well as any other name registered with\n\ -codecs.register_error that can handle UnicodeEncodeErrors."); - -static PyObject * -unicode_encode(PyUnicodeObject *self, PyObject *args) -{ - char *encoding = NULL; - char *errors = NULL; - if (!PyArg_ParseTuple(args, "|ss:encode", &encoding, &errors)) - return NULL; - return PyUnicode_AsEncodedString((PyObject *)self, encoding, errors); -} - -PyDoc_STRVAR(expandtabs__doc__, -"S.expandtabs([tabsize]) -> unicode\n\ -\n\ -Return a copy of S where all tab characters are expanded using spaces.\n\ -If tabsize is not given, a tab size of 8 characters is assumed."); - -static PyObject* -unicode_expandtabs(PyUnicodeObject *self, PyObject *args) -{ - Py_UNICODE *e; - Py_UNICODE *p; - Py_UNICODE *q; - int i, j; - PyUnicodeObject *u; - int tabsize = 8; - - if (!PyArg_ParseTuple(args, "|i:expandtabs", &tabsize)) - return NULL; - - /* First pass: determine size of output string */ - i = j = 0; - e = self->str + self->length; - for (p = self->str; p < e; p++) - if (*p == '\t') { - if (tabsize > 0) - j += tabsize - (j % tabsize); - } - else { - j++; - if (*p == '\n' || *p == '\r') { - i += j; - j = 0; - } - } - - /* Second pass: create output string and fill it */ - u = _PyUnicode_New(i + j); - if (!u) - return NULL; - - j = 0; - q = u->str; - - for (p = self->str; p < e; p++) - if (*p == '\t') { - if (tabsize > 0) { - i = tabsize - (j % tabsize); - j += i; - while (i--) - *q++ = ' '; - } - } - else { - j++; - *q++ = *p; - if (*p == '\n' || *p == '\r') - j = 0; - } - - return (PyObject*) u; -} - -PyDoc_STRVAR(find__doc__, -"S.find(sub [,start [,end]]) -> int\n\ -\n\ -Return the lowest index in S where substring sub is found,\n\ -such that sub is contained within s[start,end]. Optional\n\ -arguments start and end are interpreted as in slice notation.\n\ -\n\ -Return -1 on failure."); - -static PyObject * -unicode_find(PyUnicodeObject *self, PyObject *args) -{ - PyUnicodeObject *substring; - int start = 0; - int end = INT_MAX; - PyObject *result; - - if (!PyArg_ParseTuple(args, "O|O&O&:find", &substring, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) - return NULL; - substring = (PyUnicodeObject *)PyUnicode_FromObject( - (PyObject *)substring); - if (substring == NULL) - return NULL; - - result = PyInt_FromLong(findstring(self, substring, start, end, 1)); - - Py_DECREF(substring); - return result; -} - -static PyObject * -unicode_getitem(PyUnicodeObject *self, int index) -{ - if (index < 0 || index >= self->length) { - PyErr_SetString(PyExc_IndexError, "string index out of range"); - return NULL; - } - - return (PyObject*) PyUnicode_FromUnicode(&self->str[index], 1); -} - -static long -unicode_hash(PyUnicodeObject *self) -{ - /* Since Unicode objects compare equal to their ASCII string - counterparts, they should use the individual character values - as basis for their hash value. This is needed to assure that - strings and Unicode objects behave in the same way as - dictionary keys. */ - - register int len; - register Py_UNICODE *p; - register long x; - - if (self->hash != -1) - return self->hash; - len = PyUnicode_GET_SIZE(self); - p = PyUnicode_AS_UNICODE(self); - x = *p << 7; - while (--len >= 0) - x = (1000003*x) ^ *p++; - x ^= PyUnicode_GET_SIZE(self); - if (x == -1) - x = -2; - self->hash = x; - return x; -} - -PyDoc_STRVAR(index__doc__, -"S.index(sub [,start [,end]]) -> int\n\ -\n\ -Like S.find() but raise ValueError when the substring is not found."); - -static PyObject * -unicode_index(PyUnicodeObject *self, PyObject *args) -{ - int result; - PyUnicodeObject *substring; - int start = 0; - int end = INT_MAX; - - if (!PyArg_ParseTuple(args, "O|O&O&:index", &substring, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) - return NULL; - - substring = (PyUnicodeObject *)PyUnicode_FromObject( - (PyObject *)substring); - if (substring == NULL) - return NULL; - - result = findstring(self, substring, start, end, 1); - - Py_DECREF(substring); - if (result < 0) { - PyErr_SetString(PyExc_ValueError, "substring not found"); - return NULL; - } - return PyInt_FromLong(result); -} - -PyDoc_STRVAR(islower__doc__, -"S.islower() -> bool\n\ -\n\ -Return True if all cased characters in S are lowercase and there is\n\ -at least one cased character in S, False otherwise."); - -static PyObject* -unicode_islower(PyUnicodeObject *self) -{ - register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); - register const Py_UNICODE *e; - int cased; - - /* Shortcut for single character strings */ - if (PyUnicode_GET_SIZE(self) == 1) - return PyBool_FromLong(Py_UNICODE_ISLOWER(*p)); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyUnicode_GET_SIZE(self); - cased = 0; - for (; p < e; p++) { - register const Py_UNICODE ch = *p; - - if (Py_UNICODE_ISUPPER(ch) || Py_UNICODE_ISTITLE(ch)) - return PyBool_FromLong(0); - else if (!cased && Py_UNICODE_ISLOWER(ch)) - cased = 1; - } - return PyBool_FromLong(cased); -} - -PyDoc_STRVAR(isupper__doc__, -"S.isupper() -> bool\n\ -\n\ -Return True if all cased characters in S are uppercase and there is\n\ -at least one cased character in S, False otherwise."); - -static PyObject* -unicode_isupper(PyUnicodeObject *self) -{ - register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); - register const Py_UNICODE *e; - int cased; - - /* Shortcut for single character strings */ - if (PyUnicode_GET_SIZE(self) == 1) - return PyBool_FromLong(Py_UNICODE_ISUPPER(*p) != 0); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyUnicode_GET_SIZE(self); - cased = 0; - for (; p < e; p++) { - register const Py_UNICODE ch = *p; - - if (Py_UNICODE_ISLOWER(ch) || Py_UNICODE_ISTITLE(ch)) - return PyBool_FromLong(0); - else if (!cased && Py_UNICODE_ISUPPER(ch)) - cased = 1; - } - return PyBool_FromLong(cased); -} - -PyDoc_STRVAR(istitle__doc__, -"S.istitle() -> bool\n\ -\n\ -Return True if S is a titlecased string and there is at least one\n\ -character in S, i.e. upper- and titlecase characters may only\n\ -follow uncased characters and lowercase characters only cased ones.\n\ -Return False otherwise."); - -static PyObject* -unicode_istitle(PyUnicodeObject *self) -{ - register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); - register const Py_UNICODE *e; - int cased, previous_is_cased; - - /* Shortcut for single character strings */ - if (PyUnicode_GET_SIZE(self) == 1) - return PyBool_FromLong((Py_UNICODE_ISTITLE(*p) != 0) || - (Py_UNICODE_ISUPPER(*p) != 0)); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyUnicode_GET_SIZE(self); - cased = 0; - previous_is_cased = 0; - for (; p < e; p++) { - register const Py_UNICODE ch = *p; - - if (Py_UNICODE_ISUPPER(ch) || Py_UNICODE_ISTITLE(ch)) { - if (previous_is_cased) - return PyBool_FromLong(0); - previous_is_cased = 1; - cased = 1; - } - else if (Py_UNICODE_ISLOWER(ch)) { - if (!previous_is_cased) - return PyBool_FromLong(0); - previous_is_cased = 1; - cased = 1; - } - else - previous_is_cased = 0; - } - return PyBool_FromLong(cased); -} - -PyDoc_STRVAR(isspace__doc__, -"S.isspace() -> bool\n\ -\n\ -Return True if all characters in S are whitespace\n\ -and there is at least one character in S, False otherwise."); - -static PyObject* -unicode_isspace(PyUnicodeObject *self) -{ - register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); - register const Py_UNICODE *e; - - /* Shortcut for single character strings */ - if (PyUnicode_GET_SIZE(self) == 1 && - Py_UNICODE_ISSPACE(*p)) - return PyBool_FromLong(1); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyUnicode_GET_SIZE(self); - for (; p < e; p++) { - if (!Py_UNICODE_ISSPACE(*p)) - return PyBool_FromLong(0); - } - return PyBool_FromLong(1); -} - -PyDoc_STRVAR(isalpha__doc__, -"S.isalpha() -> bool\n\ -\n\ -Return True if all characters in S are alphabetic\n\ -and there is at least one character in S, False otherwise."); - -static PyObject* -unicode_isalpha(PyUnicodeObject *self) -{ - register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); - register const Py_UNICODE *e; - - /* Shortcut for single character strings */ - if (PyUnicode_GET_SIZE(self) == 1 && - Py_UNICODE_ISALPHA(*p)) - return PyBool_FromLong(1); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyUnicode_GET_SIZE(self); - for (; p < e; p++) { - if (!Py_UNICODE_ISALPHA(*p)) - return PyBool_FromLong(0); - } - return PyBool_FromLong(1); -} - -PyDoc_STRVAR(isalnum__doc__, -"S.isalnum() -> bool\n\ -\n\ -Return True if all characters in S are alphanumeric\n\ -and there is at least one character in S, False otherwise."); - -static PyObject* -unicode_isalnum(PyUnicodeObject *self) -{ - register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); - register const Py_UNICODE *e; - - /* Shortcut for single character strings */ - if (PyUnicode_GET_SIZE(self) == 1 && - Py_UNICODE_ISALNUM(*p)) - return PyBool_FromLong(1); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyUnicode_GET_SIZE(self); - for (; p < e; p++) { - if (!Py_UNICODE_ISALNUM(*p)) - return PyBool_FromLong(0); - } - return PyBool_FromLong(1); -} - -PyDoc_STRVAR(isdecimal__doc__, -"S.isdecimal() -> bool\n\ -\n\ -Return True if there are only decimal characters in S,\n\ -False otherwise."); - -static PyObject* -unicode_isdecimal(PyUnicodeObject *self) -{ - register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); - register const Py_UNICODE *e; - - /* Shortcut for single character strings */ - if (PyUnicode_GET_SIZE(self) == 1 && - Py_UNICODE_ISDECIMAL(*p)) - return PyBool_FromLong(1); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyUnicode_GET_SIZE(self); - for (; p < e; p++) { - if (!Py_UNICODE_ISDECIMAL(*p)) - return PyBool_FromLong(0); - } - return PyBool_FromLong(1); -} - -PyDoc_STRVAR(isdigit__doc__, -"S.isdigit() -> bool\n\ -\n\ -Return True if all characters in S are digits\n\ -and there is at least one character in S, False otherwise."); - -static PyObject* -unicode_isdigit(PyUnicodeObject *self) -{ - register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); - register const Py_UNICODE *e; - - /* Shortcut for single character strings */ - if (PyUnicode_GET_SIZE(self) == 1 && - Py_UNICODE_ISDIGIT(*p)) - return PyBool_FromLong(1); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyUnicode_GET_SIZE(self); - for (; p < e; p++) { - if (!Py_UNICODE_ISDIGIT(*p)) - return PyBool_FromLong(0); - } - return PyBool_FromLong(1); -} - -PyDoc_STRVAR(isnumeric__doc__, -"S.isnumeric() -> bool\n\ -\n\ -Return True if there are only numeric characters in S,\n\ -False otherwise."); - -static PyObject* -unicode_isnumeric(PyUnicodeObject *self) -{ - register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); - register const Py_UNICODE *e; - - /* Shortcut for single character strings */ - if (PyUnicode_GET_SIZE(self) == 1 && - Py_UNICODE_ISNUMERIC(*p)) - return PyBool_FromLong(1); - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - return PyBool_FromLong(0); - - e = p + PyUnicode_GET_SIZE(self); - for (; p < e; p++) { - if (!Py_UNICODE_ISNUMERIC(*p)) - return PyBool_FromLong(0); - } - return PyBool_FromLong(1); -} - -PyDoc_STRVAR(join__doc__, -"S.join(sequence) -> unicode\n\ -\n\ -Return a string which is the concatenation of the strings in the\n\ -sequence. The separator between elements is S."); - -static PyObject* -unicode_join(PyObject *self, PyObject *data) -{ - return PyUnicode_Join(self, data); -} - -static int -unicode_length(PyUnicodeObject *self) -{ - return self->length; -} - -PyDoc_STRVAR(ljust__doc__, -"S.ljust(width) -> unicode\n\ -\n\ -Return S left justified in a Unicode string of length width. Padding is\n\ -done using spaces."); - -static PyObject * -unicode_ljust(PyUnicodeObject *self, PyObject *args) -{ - int width; - if (!PyArg_ParseTuple(args, "i:ljust", &width)) - return NULL; - - if (self->length >= width && PyUnicode_CheckExact(self)) { - Py_INCREF(self); - return (PyObject*) self; - } - - return (PyObject*) pad(self, 0, width - self->length, ' '); -} - -PyDoc_STRVAR(lower__doc__, -"S.lower() -> unicode\n\ -\n\ -Return a copy of the string S converted to lowercase."); - -static PyObject* -unicode_lower(PyUnicodeObject *self) -{ - return fixup(self, fixlower); -} - -#define LEFTSTRIP 0 -#define RIGHTSTRIP 1 -#define BOTHSTRIP 2 - -/* Arrays indexed by above */ -static const char *stripformat[] = {"|O:lstrip", "|O:rstrip", "|O:strip"}; - -#define STRIPNAME(i) (stripformat[i]+3) - -static const Py_UNICODE * -unicode_memchr(const Py_UNICODE *s, Py_UNICODE c, size_t n) -{ - size_t i; - for (i = 0; i < n; ++i) - if (s[i] == c) - return s+i; - return NULL; -} - -/* externally visible for str.strip(unicode) */ -PyObject * -_PyUnicode_XStrip(PyUnicodeObject *self, int striptype, PyObject *sepobj) -{ - Py_UNICODE *s = PyUnicode_AS_UNICODE(self); - int len = PyUnicode_GET_SIZE(self); - Py_UNICODE *sep = PyUnicode_AS_UNICODE(sepobj); - int seplen = PyUnicode_GET_SIZE(sepobj); - int i, j; - - i = 0; - if (striptype != RIGHTSTRIP) { - while (i < len && unicode_memchr(sep, s[i], seplen)) { - i++; - } - } - - j = len; - if (striptype != LEFTSTRIP) { - do { - j--; - } while (j >= i && unicode_memchr(sep, s[j], seplen)); - j++; - } - - if (i == 0 && j == len && PyUnicode_CheckExact(self)) { - Py_INCREF(self); - return (PyObject*)self; - } - else - return PyUnicode_FromUnicode(s+i, j-i); -} - - -static PyObject * -do_strip(PyUnicodeObject *self, int striptype) -{ - Py_UNICODE *s = PyUnicode_AS_UNICODE(self); - int len = PyUnicode_GET_SIZE(self), i, j; - - i = 0; - if (striptype != RIGHTSTRIP) { - while (i < len && Py_UNICODE_ISSPACE(s[i])) { - i++; - } - } - - j = len; - if (striptype != LEFTSTRIP) { - do { - j--; - } while (j >= i && Py_UNICODE_ISSPACE(s[j])); - j++; - } - - if (i == 0 && j == len && PyUnicode_CheckExact(self)) { - Py_INCREF(self); - return (PyObject*)self; - } - else - return PyUnicode_FromUnicode(s+i, j-i); -} - - -static PyObject * -do_argstrip(PyUnicodeObject *self, int striptype, PyObject *args) -{ - PyObject *sep = NULL; - - if (!PyArg_ParseTuple(args, (char *)stripformat[striptype], &sep)) - return NULL; - - if (sep != NULL && sep != Py_None) { - if (PyUnicode_Check(sep)) - return _PyUnicode_XStrip(self, striptype, sep); - else if (PyString_Check(sep)) { - PyObject *res; - sep = PyUnicode_FromObject(sep); - if (sep==NULL) - return NULL; - res = _PyUnicode_XStrip(self, striptype, sep); - Py_DECREF(sep); - return res; - } - else { - PyErr_Format(PyExc_TypeError, - "%s arg must be None, unicode or str", - STRIPNAME(striptype)); - return NULL; - } - } - - return do_strip(self, striptype); -} - - -PyDoc_STRVAR(strip__doc__, -"S.strip([chars]) -> unicode\n\ -\n\ -Return a copy of the string S with leading and trailing\n\ -whitespace removed.\n\ -If chars is given and not None, remove characters in chars instead.\n\ -If chars is a str, it will be converted to unicode before stripping"); - -static PyObject * -unicode_strip(PyUnicodeObject *self, PyObject *args) -{ - if (PyTuple_GET_SIZE(args) == 0) - return do_strip(self, BOTHSTRIP); /* Common case */ - else - return do_argstrip(self, BOTHSTRIP, args); -} - - -PyDoc_STRVAR(lstrip__doc__, -"S.lstrip([chars]) -> unicode\n\ -\n\ -Return a copy of the string S with leading whitespace removed.\n\ -If chars is given and not None, remove characters in chars instead.\n\ -If chars is a str, it will be converted to unicode before stripping"); - -static PyObject * -unicode_lstrip(PyUnicodeObject *self, PyObject *args) -{ - if (PyTuple_GET_SIZE(args) == 0) - return do_strip(self, LEFTSTRIP); /* Common case */ - else - return do_argstrip(self, LEFTSTRIP, args); -} - - -PyDoc_STRVAR(rstrip__doc__, -"S.rstrip([chars]) -> unicode\n\ -\n\ -Return a copy of the string S with trailing whitespace removed.\n\ -If chars is given and not None, remove characters in chars instead.\n\ -If chars is a str, it will be converted to unicode before stripping"); - -static PyObject * -unicode_rstrip(PyUnicodeObject *self, PyObject *args) -{ - if (PyTuple_GET_SIZE(args) == 0) - return do_strip(self, RIGHTSTRIP); /* Common case */ - else - return do_argstrip(self, RIGHTSTRIP, args); -} - - -static PyObject* -unicode_repeat(PyUnicodeObject *str, int len) -{ - PyUnicodeObject *u; - Py_UNICODE *p; - int nchars; - size_t nbytes; - - if (len < 0) - len = 0; - - if (len == 1 && PyUnicode_CheckExact(str)) { - /* no repeat, return original string */ - Py_INCREF(str); - return (PyObject*) str; - } - - /* ensure # of chars needed doesn't overflow int and # of bytes - * needed doesn't overflow size_t - */ - nchars = len * str->length; - if (len && nchars / len != str->length) { - PyErr_SetString(PyExc_OverflowError, - "repeated string is too long"); - return NULL; - } - nbytes = (nchars + 1) * sizeof(Py_UNICODE); - if (nbytes / sizeof(Py_UNICODE) != (size_t)(nchars + 1)) { - PyErr_SetString(PyExc_OverflowError, - "repeated string is too long"); - return NULL; - } - u = _PyUnicode_New(nchars); - if (!u) - return NULL; - - p = u->str; - - while (len-- > 0) { - Py_UNICODE_COPY(p, str->str, str->length); - p += str->length; - } - - return (PyObject*) u; -} - -PyObject *PyUnicode_Replace(PyObject *obj, - PyObject *subobj, - PyObject *replobj, - int maxcount) -{ - PyObject *self; - PyObject *str1; - PyObject *str2; - PyObject *result; - - self = PyUnicode_FromObject(obj); - if (self == NULL) - return NULL; - str1 = PyUnicode_FromObject(subobj); - if (str1 == NULL) { - Py_DECREF(self); - return NULL; - } - str2 = PyUnicode_FromObject(replobj); - if (str2 == NULL) { - Py_DECREF(self); - Py_DECREF(str1); - return NULL; - } - result = replace((PyUnicodeObject *)self, - (PyUnicodeObject *)str1, - (PyUnicodeObject *)str2, - maxcount); - Py_DECREF(self); - Py_DECREF(str1); - Py_DECREF(str2); - return result; -} - -PyDoc_STRVAR(replace__doc__, -"S.replace (old, new[, maxsplit]) -> unicode\n\ -\n\ -Return a copy of S with all occurrences of substring\n\ -old replaced by new. If the optional argument maxsplit is\n\ -given, only the first maxsplit occurrences are replaced."); - -static PyObject* -unicode_replace(PyUnicodeObject *self, PyObject *args) -{ - PyUnicodeObject *str1; - PyUnicodeObject *str2; - int maxcount = -1; - PyObject *result; - - if (!PyArg_ParseTuple(args, "OO|i:replace", &str1, &str2, &maxcount)) - return NULL; - str1 = (PyUnicodeObject *)PyUnicode_FromObject((PyObject *)str1); - if (str1 == NULL) - return NULL; - str2 = (PyUnicodeObject *)PyUnicode_FromObject((PyObject *)str2); - if (str2 == NULL) { - Py_DECREF(str1); - return NULL; - } - - result = replace(self, str1, str2, maxcount); - - Py_DECREF(str1); - Py_DECREF(str2); - return result; -} - -static -PyObject *unicode_repr(PyObject *unicode) -{ - return unicodeescape_string(PyUnicode_AS_UNICODE(unicode), - PyUnicode_GET_SIZE(unicode), - 1); -} - -PyDoc_STRVAR(rfind__doc__, -"S.rfind(sub [,start [,end]]) -> int\n\ -\n\ -Return the highest index in S where substring sub is found,\n\ -such that sub is contained within s[start,end]. Optional\n\ -arguments start and end are interpreted as in slice notation.\n\ -\n\ -Return -1 on failure."); - -static PyObject * -unicode_rfind(PyUnicodeObject *self, PyObject *args) -{ - PyUnicodeObject *substring; - int start = 0; - int end = INT_MAX; - PyObject *result; - - if (!PyArg_ParseTuple(args, "O|O&O&:rfind", &substring, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) - return NULL; - substring = (PyUnicodeObject *)PyUnicode_FromObject( - (PyObject *)substring); - if (substring == NULL) - return NULL; - - result = PyInt_FromLong(findstring(self, substring, start, end, -1)); - - Py_DECREF(substring); - return result; -} - -PyDoc_STRVAR(rindex__doc__, -"S.rindex(sub [,start [,end]]) -> int\n\ -\n\ -Like S.rfind() but raise ValueError when the substring is not found."); - -static PyObject * -unicode_rindex(PyUnicodeObject *self, PyObject *args) -{ - int result; - PyUnicodeObject *substring; - int start = 0; - int end = INT_MAX; - - if (!PyArg_ParseTuple(args, "O|O&O&:rindex", &substring, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) - return NULL; - substring = (PyUnicodeObject *)PyUnicode_FromObject( - (PyObject *)substring); - if (substring == NULL) - return NULL; - - result = findstring(self, substring, start, end, -1); - - Py_DECREF(substring); - if (result < 0) { - PyErr_SetString(PyExc_ValueError, "substring not found"); - return NULL; - } - return PyInt_FromLong(result); -} - -PyDoc_STRVAR(rjust__doc__, -"S.rjust(width) -> unicode\n\ -\n\ -Return S right justified in a Unicode string of length width. Padding is\n\ -done using spaces."); - -static PyObject * -unicode_rjust(PyUnicodeObject *self, PyObject *args) -{ - int width; - if (!PyArg_ParseTuple(args, "i:rjust", &width)) - return NULL; - - if (self->length >= width && PyUnicode_CheckExact(self)) { - Py_INCREF(self); - return (PyObject*) self; - } - - return (PyObject*) pad(self, width - self->length, 0, ' '); -} - -static PyObject* -unicode_slice(PyUnicodeObject *self, int start, int end) -{ - /* standard clamping */ - if (start < 0) - start = 0; - if (end < 0) - end = 0; - if (end > self->length) - end = self->length; - if (start == 0 && end == self->length && PyUnicode_CheckExact(self)) { - /* full slice, return original string */ - Py_INCREF(self); - return (PyObject*) self; - } - if (start > end) - start = end; - /* copy slice */ - return (PyObject*) PyUnicode_FromUnicode(self->str + start, - end - start); -} - -PyObject *PyUnicode_Split(PyObject *s, - PyObject *sep, - int maxsplit) -{ - PyObject *result; - - s = PyUnicode_FromObject(s); - if (s == NULL) - return NULL; - if (sep != NULL) { - sep = PyUnicode_FromObject(sep); - if (sep == NULL) { - Py_DECREF(s); - return NULL; - } - } - - result = split((PyUnicodeObject *)s, (PyUnicodeObject *)sep, maxsplit); - - Py_DECREF(s); - Py_XDECREF(sep); - return result; -} - -PyDoc_STRVAR(split__doc__, -"S.split([sep [,maxsplit]]) -> list of strings\n\ -\n\ -Return a list of the words in S, using sep as the\n\ -delimiter string. If maxsplit is given, at most maxsplit\n\ -splits are done. If sep is not specified, any whitespace string\n\ -is a separator."); - -static PyObject* -unicode_split(PyUnicodeObject *self, PyObject *args) -{ - PyObject *substring = Py_None; - int maxcount = -1; - - if (!PyArg_ParseTuple(args, "|Oi:split", &substring, &maxcount)) - return NULL; - - if (substring == Py_None) - return split(self, NULL, maxcount); - else if (PyUnicode_Check(substring)) - return split(self, (PyUnicodeObject *)substring, maxcount); - else - return PyUnicode_Split((PyObject *)self, substring, maxcount); -} - -PyDoc_STRVAR(splitlines__doc__, -"S.splitlines([keepends]]) -> list of strings\n\ -\n\ -Return a list of the lines in S, breaking at line boundaries.\n\ -Line breaks are not included in the resulting list unless keepends\n\ -is given and true."); - -static PyObject* -unicode_splitlines(PyUnicodeObject *self, PyObject *args) -{ - int keepends = 0; - - if (!PyArg_ParseTuple(args, "|i:splitlines", &keepends)) - return NULL; - - return PyUnicode_Splitlines((PyObject *)self, keepends); -} - -static -PyObject *unicode_str(PyUnicodeObject *self) -{ - return PyUnicode_AsEncodedString((PyObject *)self, NULL, NULL); -} - -PyDoc_STRVAR(swapcase__doc__, -"S.swapcase() -> unicode\n\ -\n\ -Return a copy of S with uppercase characters converted to lowercase\n\ -and vice versa."); - -static PyObject* -unicode_swapcase(PyUnicodeObject *self) -{ - return fixup(self, fixswapcase); -} - -PyDoc_STRVAR(translate__doc__, -"S.translate(table) -> unicode\n\ -\n\ -Return a copy of the string S, where all characters have been mapped\n\ -through the given translation table, which must be a mapping of\n\ -Unicode ordinals to Unicode ordinals, Unicode strings or None.\n\ -Unmapped characters are left untouched. Characters mapped to None\n\ -are deleted."); - -static PyObject* -unicode_translate(PyUnicodeObject *self, PyObject *table) -{ - return PyUnicode_TranslateCharmap(self->str, - self->length, - table, - "ignore"); -} - -PyDoc_STRVAR(upper__doc__, -"S.upper() -> unicode\n\ -\n\ -Return a copy of S converted to uppercase."); - -static PyObject* -unicode_upper(PyUnicodeObject *self) -{ - return fixup(self, fixupper); -} - -PyDoc_STRVAR(zfill__doc__, -"S.zfill(width) -> unicode\n\ -\n\ -Pad a numeric string x with zeros on the left, to fill a field\n\ -of the specified width. The string x is never truncated."); - -static PyObject * -unicode_zfill(PyUnicodeObject *self, PyObject *args) -{ - int fill; - PyUnicodeObject *u; - - int width; - if (!PyArg_ParseTuple(args, "i:zfill", &width)) - return NULL; - - if (self->length >= width) { - if (PyUnicode_CheckExact(self)) { - Py_INCREF(self); - return (PyObject*) self; - } - else - return PyUnicode_FromUnicode( - PyUnicode_AS_UNICODE(self), - PyUnicode_GET_SIZE(self) - ); - } - - fill = width - self->length; - - u = pad(self, fill, 0, '0'); - - if (u == NULL) - return NULL; - - if (u->str[fill] == '+' || u->str[fill] == '-') { - /* move sign to beginning of string */ - u->str[0] = u->str[fill]; - u->str[fill] = '0'; - } - - return (PyObject*) u; -} - -#if 0 -static PyObject* -unicode_freelistsize(PyUnicodeObject *self) -{ - return PyInt_FromLong(unicode_freelist_size); -} -#endif - -PyDoc_STRVAR(startswith__doc__, -"S.startswith(prefix[, start[, end]]) -> bool\n\ -\n\ -Return True if S starts with the specified prefix, False otherwise.\n\ -With optional start, test S beginning at that position.\n\ -With optional end, stop comparing S at that position."); - -static PyObject * -unicode_startswith(PyUnicodeObject *self, - PyObject *args) -{ - PyUnicodeObject *substring; - int start = 0; - int end = INT_MAX; - PyObject *result; - - if (!PyArg_ParseTuple(args, "O|O&O&:startswith", &substring, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) - return NULL; - substring = (PyUnicodeObject *)PyUnicode_FromObject( - (PyObject *)substring); - if (substring == NULL) - return NULL; - - result = PyBool_FromLong(tailmatch(self, substring, start, end, -1)); - - Py_DECREF(substring); - return result; -} - - -PyDoc_STRVAR(endswith__doc__, -"S.endswith(suffix[, start[, end]]) -> bool\n\ -\n\ -Return True if S ends with the specified suffix, False otherwise.\n\ -With optional start, test S beginning at that position.\n\ -With optional end, stop comparing S at that position."); - -static PyObject * -unicode_endswith(PyUnicodeObject *self, - PyObject *args) -{ - PyUnicodeObject *substring; - int start = 0; - int end = INT_MAX; - PyObject *result; - - if (!PyArg_ParseTuple(args, "O|O&O&:endswith", &substring, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) - return NULL; - substring = (PyUnicodeObject *)PyUnicode_FromObject( - (PyObject *)substring); - if (substring == NULL) - return NULL; - - result = PyBool_FromLong(tailmatch(self, substring, start, end, +1)); - - Py_DECREF(substring); - return result; -} - - - -static PyObject * -unicode_getnewargs(PyUnicodeObject *v) -{ - return Py_BuildValue("(u#)", v->str, v->length); -} - - -static PyMethodDef unicode_methods[] = { - - /* Order is according to common usage: often used methods should - appear first, since lookup is done sequentially. */ - - {"encode", (PyCFunction) unicode_encode, METH_VARARGS, encode__doc__}, - {"replace", (PyCFunction) unicode_replace, METH_VARARGS, replace__doc__}, - {"split", (PyCFunction) unicode_split, METH_VARARGS, split__doc__}, - {"join", (PyCFunction) unicode_join, METH_O, join__doc__}, - {"capitalize", (PyCFunction) unicode_capitalize, METH_NOARGS, capitalize__doc__}, - {"title", (PyCFunction) unicode_title, METH_NOARGS, title__doc__}, - {"center", (PyCFunction) unicode_center, METH_VARARGS, center__doc__}, - {"count", (PyCFunction) unicode_count, METH_VARARGS, count__doc__}, - {"expandtabs", (PyCFunction) unicode_expandtabs, METH_VARARGS, expandtabs__doc__}, - {"find", (PyCFunction) unicode_find, METH_VARARGS, find__doc__}, - {"index", (PyCFunction) unicode_index, METH_VARARGS, index__doc__}, - {"ljust", (PyCFunction) unicode_ljust, METH_VARARGS, ljust__doc__}, - {"lower", (PyCFunction) unicode_lower, METH_NOARGS, lower__doc__}, - {"lstrip", (PyCFunction) unicode_lstrip, METH_VARARGS, lstrip__doc__}, -/* {"maketrans", (PyCFunction) unicode_maketrans, METH_VARARGS, maketrans__doc__}, */ - {"rfind", (PyCFunction) unicode_rfind, METH_VARARGS, rfind__doc__}, - {"rindex", (PyCFunction) unicode_rindex, METH_VARARGS, rindex__doc__}, - {"rjust", (PyCFunction) unicode_rjust, METH_VARARGS, rjust__doc__}, - {"rstrip", (PyCFunction) unicode_rstrip, METH_VARARGS, rstrip__doc__}, - {"splitlines", (PyCFunction) unicode_splitlines, METH_VARARGS, splitlines__doc__}, - {"strip", (PyCFunction) unicode_strip, METH_VARARGS, strip__doc__}, - {"swapcase", (PyCFunction) unicode_swapcase, METH_NOARGS, swapcase__doc__}, - {"translate", (PyCFunction) unicode_translate, METH_O, translate__doc__}, - {"upper", (PyCFunction) unicode_upper, METH_NOARGS, upper__doc__}, - {"startswith", (PyCFunction) unicode_startswith, METH_VARARGS, startswith__doc__}, - {"endswith", (PyCFunction) unicode_endswith, METH_VARARGS, endswith__doc__}, - {"islower", (PyCFunction) unicode_islower, METH_NOARGS, islower__doc__}, - {"isupper", (PyCFunction) unicode_isupper, METH_NOARGS, isupper__doc__}, - {"istitle", (PyCFunction) unicode_istitle, METH_NOARGS, istitle__doc__}, - {"isspace", (PyCFunction) unicode_isspace, METH_NOARGS, isspace__doc__}, - {"isdecimal", (PyCFunction) unicode_isdecimal, METH_NOARGS, isdecimal__doc__}, - {"isdigit", (PyCFunction) unicode_isdigit, METH_NOARGS, isdigit__doc__}, - {"isnumeric", (PyCFunction) unicode_isnumeric, METH_NOARGS, isnumeric__doc__}, - {"isalpha", (PyCFunction) unicode_isalpha, METH_NOARGS, isalpha__doc__}, - {"isalnum", (PyCFunction) unicode_isalnum, METH_NOARGS, isalnum__doc__}, - {"zfill", (PyCFunction) unicode_zfill, METH_VARARGS, zfill__doc__}, -#if 0 - {"capwords", (PyCFunction) unicode_capwords, METH_NOARGS, capwords__doc__}, -#endif - -#if 0 - /* This one is just used for debugging the implementation. */ - {"freelistsize", (PyCFunction) unicode_freelistsize, METH_NOARGS}, -#endif - - {"__getnewargs__", (PyCFunction)unicode_getnewargs, METH_NOARGS}, - {NULL, NULL} -}; - -static PyObject * -unicode_mod(PyObject *v, PyObject *w) -{ - if (!PyUnicode_Check(v)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - return PyUnicode_Format(v, w); -} - -static PyNumberMethods unicode_as_number = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - 0, /*nb_divide*/ - unicode_mod, /*nb_remainder*/ -}; - -static PySequenceMethods unicode_as_sequence = { - (inquiry) unicode_length, /* sq_length */ - (binaryfunc) PyUnicode_Concat, /* sq_concat */ - (intargfunc) unicode_repeat, /* sq_repeat */ - (intargfunc) unicode_getitem, /* sq_item */ - (intintargfunc) unicode_slice, /* sq_slice */ - 0, /* sq_ass_item */ - 0, /* sq_ass_slice */ - (objobjproc)PyUnicode_Contains, /*sq_contains*/ -}; - -static PyObject* -unicode_subscript(PyUnicodeObject* self, PyObject* item) -{ - if (PyInt_Check(item)) { - long i = PyInt_AS_LONG(item); - if (i < 0) - i += PyString_GET_SIZE(self); - return unicode_getitem(self, i); - } else if (PyLong_Check(item)) { - long i = PyLong_AsLong(item); - if (i == -1 && PyErr_Occurred()) - return NULL; - if (i < 0) - i += PyString_GET_SIZE(self); - return unicode_getitem(self, i); - } else if (PySlice_Check(item)) { - int start, stop, step, slicelength, cur, i; - Py_UNICODE* source_buf; - Py_UNICODE* result_buf; - PyObject* result; - - if (PySlice_GetIndicesEx((PySliceObject*)item, PyString_GET_SIZE(self), - &start, &stop, &step, &slicelength) < 0) { - return NULL; - } - - if (slicelength <= 0) { - return PyUnicode_FromUnicode(NULL, 0); - } else { - source_buf = PyUnicode_AS_UNICODE((PyObject*)self); - result_buf = PyMem_MALLOC(slicelength*sizeof(Py_UNICODE)); - - for (cur = start, i = 0; i < slicelength; cur += step, i++) { - result_buf[i] = source_buf[cur]; - } - - result = PyUnicode_FromUnicode(result_buf, slicelength); - PyMem_FREE(result_buf); - return result; - } - } else { - PyErr_SetString(PyExc_TypeError, "string indices must be integers"); - return NULL; - } -} - -static PyMappingMethods unicode_as_mapping = { - (inquiry)unicode_length, /* mp_length */ - (binaryfunc)unicode_subscript, /* mp_subscript */ - (objobjargproc)0, /* mp_ass_subscript */ -}; - -static int -unicode_buffer_getreadbuf(PyUnicodeObject *self, - int index, - const void **ptr) -{ - if (index != 0) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent unicode segment"); - return -1; - } - *ptr = (void *) self->str; - return PyUnicode_GET_DATA_SIZE(self); -} - -static int -unicode_buffer_getwritebuf(PyUnicodeObject *self, int index, - const void **ptr) -{ - PyErr_SetString(PyExc_TypeError, - "cannot use unicode as modifiable buffer"); - return -1; -} - -static int -unicode_buffer_getsegcount(PyUnicodeObject *self, - int *lenp) -{ - if (lenp) - *lenp = PyUnicode_GET_DATA_SIZE(self); - return 1; -} - -static int -unicode_buffer_getcharbuf(PyUnicodeObject *self, - int index, - const void **ptr) -{ - PyObject *str; - - if (index != 0) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent unicode segment"); - return -1; - } - str = _PyUnicode_AsDefaultEncodedString((PyObject *)self, NULL); - if (str == NULL) - return -1; - *ptr = (void *) PyString_AS_STRING(str); - return PyString_GET_SIZE(str); -} - -/* Helpers for PyUnicode_Format() */ - -static PyObject * -getnextarg(PyObject *args, int arglen, int *p_argidx) -{ - int argidx = *p_argidx; - if (argidx < arglen) { - (*p_argidx)++; - if (arglen < 0) - return args; - else - return PyTuple_GetItem(args, argidx); - } - PyErr_SetString(PyExc_TypeError, - "not enough arguments for format string"); - return NULL; -} - -#define F_LJUST (1<<0) -#define F_SIGN (1<<1) -#define F_BLANK (1<<2) -#define F_ALT (1<<3) -#define F_ZERO (1<<4) - -static -int usprintf(register Py_UNICODE *buffer, char *format, ...) -{ - register int i; - int len; - va_list va; - char *charbuffer; - va_start(va, format); - - /* First, format the string as char array, then expand to Py_UNICODE - array. */ - charbuffer = (char *)buffer; - len = vsprintf(charbuffer, format, va); - for (i = len - 1; i >= 0; i--) - buffer[i] = (Py_UNICODE) charbuffer[i]; - - va_end(va); - return len; -} - -/* XXX To save some code duplication, formatfloat/long/int could have been - shared with stringobject.c, converting from 8-bit to Unicode after the - formatting is done. */ - -static int -formatfloat(Py_UNICODE *buf, - size_t buflen, - int flags, - int prec, - int type, - PyObject *v) -{ - /* fmt = '%#.' + `prec` + `type` - worst case length = 3 + 10 (len of INT_MAX) + 1 = 14 (use 20)*/ - char fmt[20]; - double x; - - x = PyFloat_AsDouble(v); - if (x == -1.0 && PyErr_Occurred()) - return -1; - if (prec < 0) - prec = 6; - if (type == 'f' && (fabs(x) / 1e25) >= 1e25) - type = 'g'; - /* Worst case length calc to ensure no buffer overrun: - - 'g' formats: - fmt = %#.g - buf = '-' + [0-9]*prec + '.' + 'e+' + (longest exp - for any double rep.) - len = 1 + prec + 1 + 2 + 5 = 9 + prec - - 'f' formats: - buf = '-' + [0-9]*x + '.' + [0-9]*prec (with x < 50) - len = 1 + 50 + 1 + prec = 52 + prec - - If prec=0 the effective precision is 1 (the leading digit is - always given), therefore increase the length by one. - - */ - if ((type == 'g' && buflen <= (size_t)10 + (size_t)prec) || - (type == 'f' && buflen <= (size_t)53 + (size_t)prec)) { - PyErr_SetString(PyExc_OverflowError, - "formatted float is too long (precision too large?)"); - return -1; - } - PyOS_snprintf(fmt, sizeof(fmt), "%%%s.%d%c", - (flags&F_ALT) ? "#" : "", - prec, type); - return usprintf(buf, fmt, x); -} - -static PyObject* -formatlong(PyObject *val, int flags, int prec, int type) -{ - char *buf; - int i, len; - PyObject *str; /* temporary string object. */ - PyUnicodeObject *result; - - str = _PyString_FormatLong(val, flags, prec, type, &buf, &len); - if (!str) - return NULL; - result = _PyUnicode_New(len); - for (i = 0; i < len; i++) - result->str[i] = buf[i]; - result->str[len] = 0; - Py_DECREF(str); - return (PyObject*)result; -} - -static int -formatint(Py_UNICODE *buf, - size_t buflen, - int flags, - int prec, - int type, - PyObject *v) -{ - /* fmt = '%#.' + `prec` + 'l' + `type` - * worst case length = 3 + 19 (worst len of INT_MAX on 64-bit machine) - * + 1 + 1 - * = 24 - */ - char fmt[64]; /* plenty big enough! */ - long x; - - x = PyInt_AsLong(v); - if (x == -1 && PyErr_Occurred()) - return -1; - if (x < 0 && type != 'd' && type != 'i') { - if (PyErr_Warn(PyExc_FutureWarning, - "%u/%o/%x/%X of negative int will return " - "a signed string in Python 2.4 and up") < 0) - return -1; - } - if (prec < 0) - prec = 1; - - /* buf = '+'/'-'/'0'/'0x' + '[0-9]'*max(prec,len(x in octal)) - * worst case buf = '0x' + [0-9]*prec, where prec >= 11 - */ - if (buflen <= 13 || buflen <= (size_t)2 + (size_t)prec) { - PyErr_SetString(PyExc_OverflowError, - "formatted integer is too long (precision too large?)"); - return -1; - } - - if ((flags & F_ALT) && - (type == 'x' || type == 'X')) { - /* When converting under %#x or %#X, there are a number - * of issues that cause pain: - * - when 0 is being converted, the C standard leaves off - * the '0x' or '0X', which is inconsistent with other - * %#x/%#X conversions and inconsistent with Python's - * hex() function - * - there are platforms that violate the standard and - * convert 0 with the '0x' or '0X' - * (Metrowerks, Compaq Tru64) - * - there are platforms that give '0x' when converting - * under %#X, but convert 0 in accordance with the - * standard (OS/2 EMX) - * - * We can achieve the desired consistency by inserting our - * own '0x' or '0X' prefix, and substituting %x/%X in place - * of %#x/%#X. - * - * Note that this is the same approach as used in - * formatint() in stringobject.c - */ - PyOS_snprintf(fmt, sizeof(fmt), "0%c%%.%dl%c", - type, prec, type); - } - else { - PyOS_snprintf(fmt, sizeof(fmt), "%%%s.%dl%c", - (flags&F_ALT) ? "#" : "", - prec, type); - } - return usprintf(buf, fmt, x); -} - -static int -formatchar(Py_UNICODE *buf, - size_t buflen, - PyObject *v) -{ - /* presume that the buffer is at least 2 characters long */ - if (PyUnicode_Check(v)) { - if (PyUnicode_GET_SIZE(v) != 1) - goto onError; - buf[0] = PyUnicode_AS_UNICODE(v)[0]; - } - - else if (PyString_Check(v)) { - if (PyString_GET_SIZE(v) != 1) - goto onError; - buf[0] = (Py_UNICODE)PyString_AS_STRING(v)[0]; - } - - else { - /* Integer input truncated to a character */ - long x; - x = PyInt_AsLong(v); - if (x == -1 && PyErr_Occurred()) - goto onError; -#ifdef Py_UNICODE_WIDE - if (x < 0 || x > 0x10ffff) { - PyErr_SetString(PyExc_OverflowError, - "%c arg not in range(0x110000) " - "(wide Python build)"); - return -1; - } -#else - if (x < 0 || x > 0xffff) { - PyErr_SetString(PyExc_OverflowError, - "%c arg not in range(0x10000) " - "(narrow Python build)"); - return -1; - } -#endif - buf[0] = (Py_UNICODE) x; - } - buf[1] = '\0'; - return 1; - - onError: - PyErr_SetString(PyExc_TypeError, - "%c requires int or char"); - return -1; -} - -/* fmt%(v1,v2,...) is roughly equivalent to sprintf(fmt, v1, v2, ...) - - FORMATBUFLEN is the length of the buffer in which the floats, ints, & - chars are formatted. XXX This is a magic number. Each formatting - routine does bounds checking to ensure no overflow, but a better - solution may be to malloc a buffer of appropriate size for each - format. For now, the current solution is sufficient. -*/ -#define FORMATBUFLEN (size_t)120 - -PyObject *PyUnicode_Format(PyObject *format, - PyObject *args) -{ - Py_UNICODE *fmt, *res; - int fmtcnt, rescnt, reslen, arglen, argidx; - int args_owned = 0; - PyUnicodeObject *result = NULL; - PyObject *dict = NULL; - PyObject *uformat; - - if (format == NULL || args == NULL) { - PyErr_BadInternalCall(); - return NULL; - } - uformat = PyUnicode_FromObject(format); - if (uformat == NULL) - return NULL; - fmt = PyUnicode_AS_UNICODE(uformat); - fmtcnt = PyUnicode_GET_SIZE(uformat); - - reslen = rescnt = fmtcnt + 100; - result = _PyUnicode_New(reslen); - if (result == NULL) - goto onError; - res = PyUnicode_AS_UNICODE(result); - - if (PyTuple_Check(args)) { - arglen = PyTuple_Size(args); - argidx = 0; - } - else { - arglen = -1; - argidx = -2; - } - if (args->ob_type->tp_as_mapping && !PyTuple_Check(args) && - !PyObject_TypeCheck(args, &PyBaseString_Type)) - dict = args; - - while (--fmtcnt >= 0) { - if (*fmt != '%') { - if (--rescnt < 0) { - rescnt = fmtcnt + 100; - reslen += rescnt; - if (_PyUnicode_Resize(&result, reslen) < 0) - return NULL; - res = PyUnicode_AS_UNICODE(result) + reslen - rescnt; - --rescnt; - } - *res++ = *fmt++; - } - else { - /* Got a format specifier */ - int flags = 0; - int width = -1; - int prec = -1; - Py_UNICODE c = '\0'; - Py_UNICODE fill; - PyObject *v = NULL; - PyObject *temp = NULL; - Py_UNICODE *pbuf; - Py_UNICODE sign; - int len; - Py_UNICODE formatbuf[FORMATBUFLEN]; /* For format{float,int,char}() */ - - fmt++; - if (*fmt == '(') { - Py_UNICODE *keystart; - int keylen; - PyObject *key; - int pcount = 1; - - if (dict == NULL) { - PyErr_SetString(PyExc_TypeError, - "format requires a mapping"); - goto onError; - } - ++fmt; - --fmtcnt; - keystart = fmt; - /* Skip over balanced parentheses */ - while (pcount > 0 && --fmtcnt >= 0) { - if (*fmt == ')') - --pcount; - else if (*fmt == '(') - ++pcount; - fmt++; - } - keylen = fmt - keystart - 1; - if (fmtcnt < 0 || pcount > 0) { - PyErr_SetString(PyExc_ValueError, - "incomplete format key"); - goto onError; - } -#if 0 - /* keys are converted to strings using UTF-8 and - then looked up since Python uses strings to hold - variables names etc. in its namespaces and we - wouldn't want to break common idioms. */ - key = PyUnicode_EncodeUTF8(keystart, - keylen, - NULL); -#else - key = PyUnicode_FromUnicode(keystart, keylen); -#endif - if (key == NULL) - goto onError; - if (args_owned) { - Py_DECREF(args); - args_owned = 0; - } - args = PyObject_GetItem(dict, key); - Py_DECREF(key); - if (args == NULL) { - goto onError; - } - args_owned = 1; - arglen = -1; - argidx = -2; - } - while (--fmtcnt >= 0) { - switch (c = *fmt++) { - case '-': flags |= F_LJUST; continue; - case '+': flags |= F_SIGN; continue; - case ' ': flags |= F_BLANK; continue; - case '#': flags |= F_ALT; continue; - case '0': flags |= F_ZERO; continue; - } - break; - } - if (c == '*') { - v = getnextarg(args, arglen, &argidx); - if (v == NULL) - goto onError; - if (!PyInt_Check(v)) { - PyErr_SetString(PyExc_TypeError, - "* wants int"); - goto onError; - } - width = PyInt_AsLong(v); - if (width < 0) { - flags |= F_LJUST; - width = -width; - } - if (--fmtcnt >= 0) - c = *fmt++; - } - else if (c >= '0' && c <= '9') { - width = c - '0'; - while (--fmtcnt >= 0) { - c = *fmt++; - if (c < '0' || c > '9') - break; - if ((width*10) / 10 != width) { - PyErr_SetString(PyExc_ValueError, - "width too big"); - goto onError; - } - width = width*10 + (c - '0'); - } - } - if (c == '.') { - prec = 0; - if (--fmtcnt >= 0) - c = *fmt++; - if (c == '*') { - v = getnextarg(args, arglen, &argidx); - if (v == NULL) - goto onError; - if (!PyInt_Check(v)) { - PyErr_SetString(PyExc_TypeError, - "* wants int"); - goto onError; - } - prec = PyInt_AsLong(v); - if (prec < 0) - prec = 0; - if (--fmtcnt >= 0) - c = *fmt++; - } - else if (c >= '0' && c <= '9') { - prec = c - '0'; - while (--fmtcnt >= 0) { - c = Py_CHARMASK(*fmt++); - if (c < '0' || c > '9') - break; - if ((prec*10) / 10 != prec) { - PyErr_SetString(PyExc_ValueError, - "prec too big"); - goto onError; - } - prec = prec*10 + (c - '0'); - } - } - } /* prec */ - if (fmtcnt >= 0) { - if (c == 'h' || c == 'l' || c == 'L') { - if (--fmtcnt >= 0) - c = *fmt++; - } - } - if (fmtcnt < 0) { - PyErr_SetString(PyExc_ValueError, - "incomplete format"); - goto onError; - } - if (c != '%') { - v = getnextarg(args, arglen, &argidx); - if (v == NULL) - goto onError; - } - sign = 0; - fill = ' '; - switch (c) { - - case '%': - pbuf = formatbuf; - /* presume that buffer length is at least 1 */ - pbuf[0] = '%'; - len = 1; - break; - - case 's': - case 'r': - if (PyUnicode_Check(v) && c == 's') { - temp = v; - Py_INCREF(temp); - } - else { - PyObject *unicode; - if (c == 's') - temp = PyObject_Str(v); - else - temp = PyObject_Repr(v); - if (temp == NULL) - goto onError; - if (!PyString_Check(temp)) { - /* XXX Note: this should never happen, since - PyObject_Repr() and PyObject_Str() assure - this */ - Py_DECREF(temp); - PyErr_SetString(PyExc_TypeError, - "%s argument has non-string str()"); - goto onError; - } - unicode = PyUnicode_Decode(PyString_AS_STRING(temp), - PyString_GET_SIZE(temp), - NULL, - "strict"); - Py_DECREF(temp); - temp = unicode; - if (temp == NULL) - goto onError; - } - pbuf = PyUnicode_AS_UNICODE(temp); - len = PyUnicode_GET_SIZE(temp); - if (prec >= 0 && len > prec) - len = prec; - break; - - case 'i': - case 'd': - case 'u': - case 'o': - case 'x': - case 'X': - if (c == 'i') - c = 'd'; - if (PyLong_Check(v)) { - temp = formatlong(v, flags, prec, c); - if (!temp) - goto onError; - pbuf = PyUnicode_AS_UNICODE(temp); - len = PyUnicode_GET_SIZE(temp); - /* unbounded ints can always produce - a sign character! */ - sign = 1; - } - else { - pbuf = formatbuf; - len = formatint(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), - flags, prec, c, v); - if (len < 0) - goto onError; - /* only d conversion is signed */ - sign = c == 'd'; - } - if (flags & F_ZERO) - fill = '0'; - break; - - case 'e': - case 'E': - case 'f': - case 'F': - case 'g': - case 'G': - if (c == 'F') - c = 'f'; - pbuf = formatbuf; - len = formatfloat(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), - flags, prec, c, v); - if (len < 0) - goto onError; - sign = 1; - if (flags & F_ZERO) - fill = '0'; - break; - - case 'c': - pbuf = formatbuf; - len = formatchar(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), v); - if (len < 0) - goto onError; - break; - - default: - PyErr_Format(PyExc_ValueError, - "unsupported format character '%c' (0x%x) " - "at index %i", - (31<=c && c<=126) ? (char)c : '?', - (int)c, - (int)(fmt -1 - PyUnicode_AS_UNICODE(uformat))); - goto onError; - } - if (sign) { - if (*pbuf == '-' || *pbuf == '+') { - sign = *pbuf++; - len--; - } - else if (flags & F_SIGN) - sign = '+'; - else if (flags & F_BLANK) - sign = ' '; - else - sign = 0; - } - if (width < len) - width = len; - if (rescnt - (sign != 0) < width) { - reslen -= rescnt; - rescnt = width + fmtcnt + 100; - reslen += rescnt; - if (reslen < 0) { - Py_DECREF(result); - return PyErr_NoMemory(); - } - if (_PyUnicode_Resize(&result, reslen) < 0) - return NULL; - res = PyUnicode_AS_UNICODE(result) - + reslen - rescnt; - } - if (sign) { - if (fill != ' ') - *res++ = sign; - rescnt--; - if (width > len) - width--; - } - if ((flags & F_ALT) && (c == 'x' || c == 'X')) { - assert(pbuf[0] == '0'); - assert(pbuf[1] == c); - if (fill != ' ') { - *res++ = *pbuf++; - *res++ = *pbuf++; - } - rescnt -= 2; - width -= 2; - if (width < 0) - width = 0; - len -= 2; - } - if (width > len && !(flags & F_LJUST)) { - do { - --rescnt; - *res++ = fill; - } while (--width > len); - } - if (fill == ' ') { - if (sign) - *res++ = sign; - if ((flags & F_ALT) && (c == 'x' || c == 'X')) { - assert(pbuf[0] == '0'); - assert(pbuf[1] == c); - *res++ = *pbuf++; - *res++ = *pbuf++; - } - } - Py_UNICODE_COPY(res, pbuf, len); - res += len; - rescnt -= len; - while (--width >= len) { - --rescnt; - *res++ = ' '; - } - if (dict && (argidx < arglen) && c != '%') { - PyErr_SetString(PyExc_TypeError, - "not all arguments converted during string formatting"); - goto onError; - } - Py_XDECREF(temp); - } /* '%' */ - } /* until end */ - if (argidx < arglen && !dict) { - PyErr_SetString(PyExc_TypeError, - "not all arguments converted during string formatting"); - goto onError; - } - - if (args_owned) { - Py_DECREF(args); - } - Py_DECREF(uformat); - if (_PyUnicode_Resize(&result, reslen - rescnt)) - goto onError; - return (PyObject *)result; - - onError: - Py_XDECREF(result); - Py_DECREF(uformat); - if (args_owned) { - Py_DECREF(args); - } - return NULL; -} - -static PyBufferProcs unicode_as_buffer = { - (getreadbufferproc) unicode_buffer_getreadbuf, - (getwritebufferproc) unicode_buffer_getwritebuf, - (getsegcountproc) unicode_buffer_getsegcount, - (getcharbufferproc) unicode_buffer_getcharbuf, -}; - -static PyObject * -unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); - -static PyObject * -unicode_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *x = NULL; - static char *kwlist[] = {"string", "encoding", "errors", 0}; - char *encoding = NULL; - char *errors = NULL; - - if (type != &PyUnicode_Type) - return unicode_subtype_new(type, args, kwds); - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:unicode", - kwlist, &x, &encoding, &errors)) - return NULL; - if (x == NULL) - return (PyObject *)_PyUnicode_New(0); - if (encoding == NULL && errors == NULL) - return PyObject_Unicode(x); - else - return PyUnicode_FromEncodedObject(x, encoding, errors); -} - -static PyObject * -unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyUnicodeObject *tmp, *pnew; - int n; - - assert(PyType_IsSubtype(type, &PyUnicode_Type)); - tmp = (PyUnicodeObject *)unicode_new(&PyUnicode_Type, args, kwds); - if (tmp == NULL) - return NULL; - assert(PyUnicode_Check(tmp)); - pnew = (PyUnicodeObject *) type->tp_alloc(type, n = tmp->length); - if (pnew == NULL) { - Py_DECREF(tmp); - return NULL; - } - pnew->str = PyMem_NEW(Py_UNICODE, n+1); - if (pnew->str == NULL) { - _Py_ForgetReference((PyObject *)pnew); - PyObject_Del(pnew); - Py_DECREF(tmp); - return PyErr_NoMemory(); - } - Py_UNICODE_COPY(pnew->str, tmp->str, n+1); - pnew->length = n; - pnew->hash = tmp->hash; - Py_DECREF(tmp); - return (PyObject *)pnew; -} - -PyDoc_STRVAR(unicode_doc, -"unicode(string [, encoding[, errors]]) -> object\n\ -\n\ -Create a new Unicode object from the given encoded string.\n\ -encoding defaults to the current default string encoding.\n\ -errors can be 'strict', 'replace' or 'ignore' and defaults to 'strict'."); - -PyTypeObject PyUnicode_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "unicode", /* tp_name */ - sizeof(PyUnicodeObject), /* tp_size */ - 0, /* tp_itemsize */ - /* Slots */ - (destructor)unicode_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc) unicode_compare, /* tp_compare */ - (reprfunc) unicode_repr, /* tp_repr */ - &unicode_as_number, /* tp_as_number */ - &unicode_as_sequence, /* tp_as_sequence */ - &unicode_as_mapping, /* tp_as_mapping */ - (hashfunc) unicode_hash, /* tp_hash*/ - 0, /* tp_call*/ - (reprfunc) unicode_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - &unicode_as_buffer, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - unicode_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - unicode_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - &PyBaseString_Type, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - unicode_new, /* tp_new */ - PyObject_Del, /* tp_free */ -}; - -/* Initialize the Unicode implementation */ - -void _PyUnicode_Init(void) -{ - int i; - - /* Init the implementation */ - unicode_freelist = NULL; - unicode_freelist_size = 0; - unicode_empty = _PyUnicode_New(0); - strcpy(unicode_default_encoding, "ascii"); - for (i = 0; i < 256; i++) - unicode_latin1[i] = NULL; - if (PyType_Ready(&PyUnicode_Type) < 0) - Py_FatalError("Can't initialize 'unicode'"); -} - -/* Finalize the Unicode implementation */ - -void -_PyUnicode_Fini(void) -{ - PyUnicodeObject *u; - int i; - - Py_XDECREF(unicode_empty); - unicode_empty = NULL; - - for (i = 0; i < 256; i++) { - if (unicode_latin1[i]) { - Py_DECREF(unicode_latin1[i]); - unicode_latin1[i] = NULL; - } - } - - for (u = unicode_freelist; u != NULL;) { - PyUnicodeObject *v = u; - u = *(PyUnicodeObject **)u; - if (v->str) - PyMem_DEL(v->str); - Py_XDECREF(v->defenc); - PyObject_Del(v); - } - unicode_freelist = NULL; - unicode_freelist_size = 0; -} - -/* -Local variables: -c-basic-offset: 4 -indent-tabs-mode: nil -End: -*/ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/unicodetype_db.h b/SDKs/XPlatform/Cypython-2.3.3/Objects/unicodetype_db.h deleted file mode 100644 index 0e72ae27..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/unicodetype_db.h +++ /dev/null @@ -1,1090 +0,0 @@ -/* this file was generated by Tools/unicode/makeunicodedata.py 2.2 */ - -/* a list of unique character type descriptors */ -const _PyUnicode_TypeRecord _PyUnicode_TypeRecords[] = { - {0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0}, - {32, 0, 0, 0, 0, 0}, - {48, 0, 0, 0, 0, 0}, - {6, 0, 0, 0, 0, 0}, - {6, 0, 0, 0, 1, 1}, - {6, 0, 0, 0, 2, 2}, - {6, 0, 0, 0, 3, 3}, - {6, 0, 0, 0, 4, 4}, - {6, 0, 0, 0, 5, 5}, - {6, 0, 0, 0, 6, 6}, - {6, 0, 0, 0, 7, 7}, - {6, 0, 0, 0, 8, 8}, - {6, 0, 0, 0, 9, 9}, - {129, 0, 32, 0, 0, 0}, - {9, 65504, 0, 65504, 0, 0}, - {9, 0, 0, 0, 0, 0}, - {9, 743, 0, 743, 0, 0}, - {9, 121, 0, 121, 0, 0}, - {129, 0, 1, 0, 0, 0}, - {9, 65535, 0, 65535, 0, 0}, - {129, 0, 65337, 0, 0, 0}, - {9, 65304, 0, 65304, 0, 0}, - {129, 0, 65415, 0, 0, 0}, - {9, 65236, 0, 65236, 0, 0}, - {129, 0, 210, 0, 0, 0}, - {129, 0, 206, 0, 0, 0}, - {129, 0, 205, 0, 0, 0}, - {129, 0, 79, 0, 0, 0}, - {129, 0, 202, 0, 0, 0}, - {129, 0, 203, 0, 0, 0}, - {129, 0, 207, 0, 0, 0}, - {9, 97, 0, 97, 0, 0}, - {129, 0, 211, 0, 0, 0}, - {129, 0, 209, 0, 0, 0}, - {129, 0, 213, 0, 0, 0}, - {9, 130, 0, 130, 0, 0}, - {129, 0, 214, 0, 0, 0}, - {129, 0, 218, 0, 0, 0}, - {129, 0, 217, 0, 0, 0}, - {129, 0, 219, 0, 0, 0}, - {1, 0, 0, 0, 0, 0}, - {9, 56, 0, 56, 0, 0}, - {129, 0, 2, 1, 0, 0}, - {65, 65535, 1, 0, 0, 0}, - {9, 65534, 0, 65535, 0, 0}, - {9, 65457, 0, 65457, 0, 0}, - {129, 0, 65439, 0, 0, 0}, - {129, 0, 65480, 0, 0, 0}, - {129, 0, 65406, 0, 0, 0}, - {9, 65326, 0, 65326, 0, 0}, - {9, 65330, 0, 65330, 0, 0}, - {9, 65331, 0, 65331, 0, 0}, - {9, 65334, 0, 65334, 0, 0}, - {9, 65333, 0, 65333, 0, 0}, - {9, 65329, 0, 65329, 0, 0}, - {9, 65327, 0, 65327, 0, 0}, - {9, 65325, 0, 65325, 0, 0}, - {9, 65323, 0, 65323, 0, 0}, - {9, 65322, 0, 65322, 0, 0}, - {9, 65318, 0, 65318, 0, 0}, - {9, 65319, 0, 65319, 0, 0}, - {9, 65317, 0, 65317, 0, 0}, - {0, 84, 0, 84, 0, 0}, - {129, 0, 38, 0, 0, 0}, - {129, 0, 37, 0, 0, 0}, - {129, 0, 64, 0, 0, 0}, - {129, 0, 63, 0, 0, 0}, - {9, 65498, 0, 65498, 0, 0}, - {9, 65499, 0, 65499, 0, 0}, - {9, 65505, 0, 65505, 0, 0}, - {9, 65472, 0, 65472, 0, 0}, - {9, 65473, 0, 65473, 0, 0}, - {9, 65474, 0, 65474, 0, 0}, - {9, 65479, 0, 65479, 0, 0}, - {129, 0, 0, 0, 0, 0}, - {9, 65489, 0, 65489, 0, 0}, - {9, 65482, 0, 65482, 0, 0}, - {9, 65450, 0, 65450, 0, 0}, - {9, 65456, 0, 65456, 0, 0}, - {129, 0, 65476, 0, 0, 0}, - {9, 65440, 0, 65440, 0, 0}, - {129, 0, 80, 0, 0, 0}, - {129, 0, 48, 0, 0, 0}, - {9, 65488, 0, 65488, 0, 0}, - {9, 65477, 0, 65477, 0, 0}, - {9, 8, 0, 8, 0, 0}, - {129, 0, 65528, 0, 0, 0}, - {9, 74, 0, 74, 0, 0}, - {9, 86, 0, 86, 0, 0}, - {9, 100, 0, 100, 0, 0}, - {9, 128, 0, 128, 0, 0}, - {9, 112, 0, 112, 0, 0}, - {9, 126, 0, 126, 0, 0}, - {65, 0, 65528, 0, 0, 0}, - {9, 9, 0, 9, 0, 0}, - {129, 0, 65462, 0, 0, 0}, - {65, 0, 65527, 0, 0, 0}, - {9, 58331, 0, 58331, 0, 0}, - {129, 0, 65450, 0, 0, 0}, - {129, 0, 65436, 0, 0, 0}, - {9, 7, 0, 7, 0, 0}, - {129, 0, 65424, 0, 0, 0}, - {129, 0, 65529, 0, 0, 0}, - {129, 0, 65408, 0, 0, 0}, - {129, 0, 65410, 0, 0, 0}, - {129, 0, 58019, 0, 0, 0}, - {129, 0, 57153, 0, 0, 0}, - {129, 0, 57274, 0, 0, 0}, - {0, 0, 16, 0, 0, 0}, - {0, 65520, 0, 65520, 0, 0}, - {4, 0, 0, 0, 0, 1}, - {4, 0, 0, 0, 0, 2}, - {4, 0, 0, 0, 0, 3}, - {4, 0, 0, 0, 0, 4}, - {4, 0, 0, 0, 0, 5}, - {4, 0, 0, 0, 0, 6}, - {4, 0, 0, 0, 0, 7}, - {4, 0, 0, 0, 0, 8}, - {4, 0, 0, 0, 0, 9}, - {0, 0, 26, 0, 0, 0}, - {0, 65510, 0, 65510, 0, 0}, - {4, 0, 0, 0, 0, 0}, - {129, 0, 40, 0, 0, 0}, - {9, 65496, 0, 65496, 0, 0}, -}; - -/* type indexes */ -#define SHIFT 8 -static unsigned char index1[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 8, 8, 8, 8, 8, 25, 26, 27, 28, 29, 30, 31, 29, 32, 33, - 29, 29, 29, 8, 8, 8, 34, 35, 36, 37, 38, 39, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 40, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 41, 21, 21, 21, 21, 42, 8, 8, 8, - 8, 8, 8, 8, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 43, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 21, 44, 45, 21, 46, 47, 48, 8, 8, 8, 49, - 50, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 51, 52, 8, 8, 53, 54, 55, 56, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 57, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 21, 21, 58, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 59, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 60, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 60, -}; - -static unsigned char index2[] = { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 3, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 1, 1, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 1, 1, 1, 1, 1, 1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 1, 1, 1, - 1, 1, 1, 1, 6, 7, 1, 17, 1, 1, 1, 5, 16, 1, 1, 1, 1, 1, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 1, 14, 14, 14, 14, 14, 14, 14, 16, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 15, 15, - 15, 15, 15, 15, 15, 18, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 21, 22, 19, 20, 19, 20, 19, 20, 16, 19, 20, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 16, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 23, 19, 20, 19, 20, 19, 20, 24, 16, 25, 19, 20, 19, 20, 26, 19, 20, 27, - 27, 19, 20, 16, 28, 29, 30, 19, 20, 27, 31, 32, 33, 34, 19, 20, 16, 16, - 33, 35, 36, 37, 19, 20, 19, 20, 19, 20, 38, 19, 20, 38, 16, 16, 19, 20, - 38, 19, 20, 39, 39, 19, 20, 19, 20, 40, 19, 20, 16, 41, 19, 20, 16, 42, - 41, 41, 41, 41, 43, 44, 45, 43, 44, 45, 43, 44, 45, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 46, 19, 20, 19, 20, 19, 20, - 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 16, 43, 44, 45, 19, 20, - 47, 48, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 19, 20, 19, 20, 19, 20, 49, 0, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 19, 20, 19, 20, 19, 20, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 50, 51, 16, 52, 52, - 16, 53, 16, 54, 16, 16, 16, 16, 52, 16, 16, 55, 16, 16, 16, 16, 56, 57, - 16, 16, 16, 16, 16, 57, 16, 16, 58, 16, 16, 59, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 60, 16, 16, 60, 16, 16, 16, 16, 60, 16, 61, 61, 16, 16, - 16, 16, 16, 16, 62, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 1, 1, 41, 41, 41, 41, 41, 41, 41, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 41, 41, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 41, 41, 41, 41, 41, 1, 1, 1, 1, 1, 1, 1, 1, 1, 41, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 63, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 41, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, - 1, 64, 1, 65, 65, 65, 0, 66, 0, 67, 67, 16, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 0, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 68, 69, 69, 69, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 70, 15, 15, 15, 15, 15, 15, 15, 15, 15, 71, 72, - 72, 0, 73, 74, 75, 75, 75, 76, 77, 16, 19, 20, 19, 20, 19, 20, 19, 20, - 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 78, 79, - 46, 16, 80, 81, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 82, 82, 82, 82, 82, 82, - 82, 82, 82, 82, 82, 82, 82, 82, 82, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 1, 1, 1, 1, - 1, 0, 1, 1, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 75, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 0, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 0, 0, 19, 20, 0, 0, 0, 0, 0, 0, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, - 0, 0, 41, 1, 1, 1, 1, 1, 1, 0, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 16, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 0, 0, 0, 0, 0, 41, 41, 41, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, 1, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, 0, 0, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, - 1, 1, 41, 41, 1, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 1, 41, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 41, 41, 1, 1, 1, 1, 1, 1, 1, 0, 0, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 41, 41, 41, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 0, 1, 41, 1, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 41, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 0, 0, 1, 41, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 41, 1, - 1, 1, 1, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 1, 1, 1, 1, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 1, 0, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 41, 41, 0, 0, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, 0, 41, 0, 0, 0, 41, 41, - 41, 41, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 41, 41, 0, 41, 41, 41, 1, 1, 0, 0, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 41, 41, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 41, 41, 41, 41, 41, 41, 0, 0, 0, 0, 41, 41, 0, 0, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 0, 41, 41, 0, - 41, 41, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 0, 41, 0, 0, 0, 0, 0, 0, 0, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 41, 41, 41, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 0, 41, 41, 41, 41, 41, 41, 41, 0, 41, 0, 41, 41, 41, - 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 0, 41, 41, - 41, 41, 41, 0, 0, 1, 41, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, - 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 0, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 41, 41, 0, - 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 0, 0, 41, - 41, 41, 41, 0, 0, 1, 41, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 41, 41, 0, 41, 41, 41, 0, 0, 0, - 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 41, 0, 41, 41, 41, 41, 41, 41, 0, 0, 0, 41, 41, 41, - 0, 41, 41, 41, 41, 0, 0, 0, 41, 41, 0, 41, 0, 41, 41, 0, 0, 0, 41, 41, 0, - 0, 0, 41, 41, 41, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, - 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 0, 41, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, 0, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, - 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 0, 0, 0, 0, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 41, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, 0, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, - 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 41, 0, 41, 41, 0, 0, 0, 0, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 0, 41, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, 0, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 0, 0, 0, 0, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 0, 41, 0, 0, 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, 1, 0, - 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 1, 41, - 41, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 41, 41, 41, 41, 41, 41, 41, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 0, 41, 0, 0, 41, 41, 0, 41, 0, 0, 41, - 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, 0, 41, - 41, 41, 0, 41, 0, 41, 0, 0, 41, 41, 0, 41, 41, 41, 41, 1, 41, 41, 1, 1, - 1, 1, 1, 1, 0, 1, 1, 41, 0, 0, 41, 41, 41, 41, 41, 0, 41, 0, 1, 1, 1, 1, - 1, 1, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 41, 41, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 41, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 41, - 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 41, 41, 41, 41, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, 0, 41, 41, 0, 1, - 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 1, 41, 41, 41, 41, 41, 41, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 1, 0, 0, 0, 0, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, - 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, - 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, 0, 0, 0, 41, 41, 41, - 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 41, 0, 41, 41, - 41, 41, 0, 0, 41, 41, 41, 41, 41, 41, 41, 0, 41, 0, 41, 41, 41, 41, 0, 0, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 0, 41, 0, 41, 41, 41, 41, 0, 0, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 0, 41, 0, 41, 41, 41, 41, 0, 0, 41, 41, 41, 41, - 41, 41, 41, 0, 41, 0, 41, 41, 41, 41, 0, 0, 41, 41, 41, 41, 41, 41, 41, - 0, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 41, 0, 41, 41, 41, 41, 0, 0, 41, - 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 1, 1, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 2, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 1, 1, 0, 0, 0, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, 41, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 0, 41, 41, 41, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 41, 1, 1, 1, 1, 41, 0, 0, 0, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, - 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 16, - 16, 16, 16, 16, 85, 0, 0, 0, 0, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19, 20, - 19, 20, 19, 20, 19, 20, 19, 20, 0, 0, 0, 0, 0, 0, 86, 86, 86, 86, 86, 86, - 86, 86, 87, 87, 87, 87, 87, 87, 87, 87, 86, 86, 86, 86, 86, 86, 0, 0, 87, - 87, 87, 87, 87, 87, 0, 0, 86, 86, 86, 86, 86, 86, 86, 86, 87, 87, 87, 87, - 87, 87, 87, 87, 86, 86, 86, 86, 86, 86, 86, 86, 87, 87, 87, 87, 87, 87, - 87, 87, 86, 86, 86, 86, 86, 86, 0, 0, 87, 87, 87, 87, 87, 87, 0, 0, 16, - 86, 16, 86, 16, 86, 16, 86, 0, 87, 0, 87, 0, 87, 0, 87, 86, 86, 86, 86, - 86, 86, 86, 86, 87, 87, 87, 87, 87, 87, 87, 87, 88, 88, 89, 89, 89, 89, - 90, 90, 91, 91, 92, 92, 93, 93, 0, 0, 86, 86, 86, 86, 86, 86, 86, 86, 94, - 94, 94, 94, 94, 94, 94, 94, 86, 86, 86, 86, 86, 86, 86, 86, 94, 94, 94, - 94, 94, 94, 94, 94, 86, 86, 86, 86, 86, 86, 86, 86, 94, 94, 94, 94, 94, - 94, 94, 94, 86, 86, 16, 95, 16, 0, 16, 16, 87, 87, 96, 96, 97, 1, 98, 1, - 1, 1, 16, 95, 16, 0, 16, 16, 99, 99, 99, 99, 97, 1, 1, 1, 86, 86, 16, 16, - 0, 0, 16, 16, 87, 87, 100, 100, 0, 1, 1, 1, 86, 86, 16, 16, 16, 101, 16, - 16, 87, 87, 102, 102, 103, 1, 1, 1, 0, 0, 16, 95, 16, 0, 16, 16, 104, - 104, 105, 105, 97, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 3, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, - 1, 4, 16, 0, 0, 8, 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 16, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 75, 1, 1, 1, 1, 75, 1, 1, 16, 75, 75, 75, 16, 16, 75, - 75, 75, 16, 1, 75, 1, 1, 1, 75, 75, 75, 75, 75, 1, 1, 1, 1, 1, 1, 75, 1, - 106, 1, 75, 1, 107, 108, 75, 75, 1, 16, 75, 75, 1, 75, 16, 41, 41, 41, - 41, 16, 1, 0, 0, 16, 75, 75, 1, 1, 1, 1, 1, 75, 16, 16, 16, 16, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 110, - 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, - 110, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 113, 114, - 115, 116, 117, 118, 119, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 111, 112, - 113, 114, 115, 116, 117, 118, 119, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, - 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 121, 121, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 122, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 111, 112, 113, 114, 115, 116, 117, 118, 119, 1, 0, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, - 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 111, 112, 113, 114, 115, 116, 117, 118, - 119, 1, 111, 112, 113, 114, 115, 116, 117, 118, 119, 1, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 2, 1, 1, 1, 1, 41, 41, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 41, 41, 41, 41, 41, 1, 1, 1, 1, 1, 41, 41, 1, 1, - 1, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 1, 1, - 1, 1, 41, 41, 41, 1, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 1, 41, 41, 41, 41, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, - 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 16, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, - 41, 1, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 1, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, 0, 41, 0, 41, 41, 0, - 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, - 41, 41, 41, 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 1, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 1, 1, 1, 1, 1, 1, 1, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 1, 1, 1, 1, - 1, 1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, - 41, 41, 41, 41, 41, 41, 0, 0, 41, 41, 41, 41, 41, 41, 0, 0, 41, 41, 41, - 41, 41, 41, 0, 0, 41, 41, 41, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, - 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, - 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, - 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 0, - 0, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 16, 16, 16, 16, 16, - 16, 16, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 75, 0, 75, 75, 0, 0, 75, 0, 0, 75, 75, 0, 0, 75, 75, 75, 75, 0, 75, - 75, 75, 75, 75, 75, 75, 75, 16, 16, 16, 16, 0, 16, 0, 16, 16, 16, 16, 0, - 16, 16, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 75, 75, 0, 75, 75, 75, - 75, 0, 0, 75, 75, 75, 75, 75, 75, 75, 75, 0, 75, 75, 75, 75, 75, 75, 75, - 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 75, 75, 0, 75, 75, 75, 75, 0, 75, 75, - 75, 75, 75, 0, 75, 0, 0, 0, 75, 75, 75, 75, 75, 75, 75, 0, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 1, 16, 16, 16, 16, 16, 16, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 1, 16, 16, - 16, 16, 16, 16, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 1, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 1, 16, 16, 16, 16, 16, 16, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 1, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 1, 16, 16, 16, 16, 16, 16, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 1, 16, 16, 16, 16, 16, 16, 0, 0, 0, - 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 0, -}; - diff --git a/SDKs/XPlatform/Cypython-2.3.3/Objects/weakrefobject.c b/SDKs/XPlatform/Cypython-2.3.3/Objects/weakrefobject.c deleted file mode 100644 index bae98cc9..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Objects/weakrefobject.c +++ /dev/null @@ -1,783 +0,0 @@ -#include "Python.h" -#include "structmember.h" - - -#define GET_WEAKREFS_LISTPTR(o) \ - ((PyWeakReference **) PyObject_GET_WEAKREFS_LISTPTR(o)) - - -long -_PyWeakref_GetWeakrefCount(PyWeakReference *head) -{ - long count = 0; - - while (head != NULL) { - ++count; - head = head->wr_next; - } - return count; -} - - -static PyWeakReference * -new_weakref(PyObject *ob, PyObject *callback) -{ - PyWeakReference *result; - - result = PyObject_GC_New(PyWeakReference, &_PyWeakref_RefType); - if (result) { - result->hash = -1; - result->wr_object = ob; - Py_XINCREF(callback); - result->wr_callback = callback; - PyObject_GC_Track(result); - } - return result; -} - - -/* This function clears the passed-in reference and removes it from the - * list of weak references for the referent. This is the only code that - * removes an item from the doubly-linked list of weak references for an - * object; it is also responsible for clearing the callback slot. - */ -static void -clear_weakref(PyWeakReference *self) -{ - PyObject *callback = self->wr_callback; - - if (PyWeakref_GET_OBJECT(self) != Py_None) { - PyWeakReference **list = GET_WEAKREFS_LISTPTR( - PyWeakref_GET_OBJECT(self)); - - if (*list == self) - *list = self->wr_next; - self->wr_object = Py_None; - if (self->wr_prev != NULL) - self->wr_prev->wr_next = self->wr_next; - if (self->wr_next != NULL) - self->wr_next->wr_prev = self->wr_prev; - self->wr_prev = NULL; - self->wr_next = NULL; - } - if (callback != NULL) { - Py_DECREF(callback); - self->wr_callback = NULL; - } -} - -/* Cyclic gc uses this to *just* clear the passed-in reference, leaving - * the callback intact and uncalled. It must be possible to call self's - * tp_dealloc() after calling this, so self has to be left in a sane enough - * state for that to work. We expect tp_dealloc to decref the callback - * then. The reason for not letting clear_weakref() decref the callback - * right now is that if the callback goes away, that may in turn trigger - * another callback (if a weak reference to the callback exists) -- running - * arbitrary Python code in the middle of gc is a disaster. The convolution - * here allows gc to delay triggering such callbacks until the world is in - * a sane state again. - */ -void -_PyWeakref_ClearRef(PyWeakReference *self) -{ - PyObject *callback; - - assert(self != NULL); - assert(PyWeakref_Check(self)); - /* Preserve and restore the callback around clear_weakref. */ - callback = self->wr_callback; - self->wr_callback = NULL; - clear_weakref(self); - self->wr_callback = callback; -} - -static void -weakref_dealloc(PyWeakReference *self) -{ - PyObject_GC_UnTrack((PyObject *)self); - clear_weakref(self); - PyObject_GC_Del(self); -} - - -static int -gc_traverse(PyWeakReference *self, visitproc visit, void *arg) -{ - if (self->wr_callback != NULL) - return visit(self->wr_callback, arg); - return 0; -} - - -static int -gc_clear(PyWeakReference *self) -{ - clear_weakref(self); - return 0; -} - - -static PyObject * -weakref_call(PyWeakReference *self, PyObject *args, PyObject *kw) -{ - static char *argnames[] = {NULL}; - - if (PyArg_ParseTupleAndKeywords(args, kw, ":__call__", argnames)) { - PyObject *object = PyWeakref_GET_OBJECT(self); - Py_INCREF(object); - return (object); - } - return NULL; -} - - -static long -weakref_hash(PyWeakReference *self) -{ - if (self->hash != -1) - return self->hash; - if (PyWeakref_GET_OBJECT(self) == Py_None) { - PyErr_SetString(PyExc_TypeError, "weak object has gone away"); - return -1; - } - self->hash = PyObject_Hash(PyWeakref_GET_OBJECT(self)); - return self->hash; -} - - -static PyObject * -weakref_repr(PyWeakReference *self) -{ - char buffer[256]; - if (PyWeakref_GET_OBJECT(self) == Py_None) { - PyOS_snprintf(buffer, sizeof(buffer), "", self); - } - else { - char *name = NULL; - PyObject *nameobj = PyObject_GetAttrString(PyWeakref_GET_OBJECT(self), - "__name__"); - if (nameobj == NULL) - PyErr_Clear(); - else if (PyString_Check(nameobj)) - name = PyString_AS_STRING(nameobj); - PyOS_snprintf(buffer, sizeof(buffer), - name ? "" - : "", - self, - PyWeakref_GET_OBJECT(self)->ob_type->tp_name, - PyWeakref_GET_OBJECT(self), - name); - Py_XDECREF(nameobj); - } - return PyString_FromString(buffer); -} - -/* Weak references only support equality, not ordering. Two weak references - are equal if the underlying objects are equal. If the underlying object has - gone away, they are equal if they are identical. */ - -static PyObject * -weakref_richcompare(PyWeakReference* self, PyWeakReference* other, int op) -{ - if (op != Py_EQ || self->ob_type != other->ob_type) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - if (PyWeakref_GET_OBJECT(self) == Py_None - || PyWeakref_GET_OBJECT(other) == Py_None) { - PyObject *res = self==other ? Py_True : Py_False; - Py_INCREF(res); - return res; - } - return PyObject_RichCompare(PyWeakref_GET_OBJECT(self), - PyWeakref_GET_OBJECT(other), op); -} - - -PyTypeObject -_PyWeakref_RefType = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "weakref", - sizeof(PyWeakReference), - 0, - (destructor)weakref_dealloc,/*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - (reprfunc)weakref_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)weakref_hash, /*tp_hash*/ - (ternaryfunc)weakref_call, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_RICHCOMPARE, - 0, /*tp_doc*/ - (traverseproc)gc_traverse, /*tp_traverse*/ - (inquiry)gc_clear, /*tp_clear*/ - (richcmpfunc)weakref_richcompare, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ -}; - - -static int -proxy_checkref(PyWeakReference *proxy) -{ - if (PyWeakref_GET_OBJECT(proxy) == Py_None) { - PyErr_SetString(PyExc_ReferenceError, - "weakly-referenced object no longer exists"); - return 0; - } - return 1; -} - - -/* If a parameter is a proxy, check that it is still "live" and wrap it, - * replacing the original value with the raw object. Raises ReferenceError - * if the param is a dead proxy. - */ -#define UNWRAP(o) \ - if (PyWeakref_CheckProxy(o)) { \ - if (!proxy_checkref((PyWeakReference *)o)) \ - return NULL; \ - o = PyWeakref_GET_OBJECT(o); \ - } - -#define UNWRAP_I(o) \ - if (PyWeakref_CheckProxy(o)) { \ - if (!proxy_checkref((PyWeakReference *)o)) \ - return -1; \ - o = PyWeakref_GET_OBJECT(o); \ - } - -#define WRAP_UNARY(method, generic) \ - static PyObject * \ - method(PyObject *proxy) { \ - UNWRAP(proxy); \ - return generic(proxy); \ - } - -#define WRAP_BINARY(method, generic) \ - static PyObject * \ - method(PyObject *x, PyObject *y) { \ - UNWRAP(x); \ - UNWRAP(y); \ - return generic(x, y); \ - } - -/* Note that the third arg needs to be checked for NULL since the tp_call - * slot can receive NULL for this arg. - */ -#define WRAP_TERNARY(method, generic) \ - static PyObject * \ - method(PyObject *proxy, PyObject *v, PyObject *w) { \ - UNWRAP(proxy); \ - UNWRAP(v); \ - if (w != NULL) \ - UNWRAP(w); \ - return generic(proxy, v, w); \ - } - - -/* direct slots */ - -WRAP_BINARY(proxy_getattr, PyObject_GetAttr) -WRAP_UNARY(proxy_str, PyObject_Str) -WRAP_TERNARY(proxy_call, PyEval_CallObjectWithKeywords) - -static PyObject * -proxy_repr(PyWeakReference *proxy) -{ - char buf[160]; - PyOS_snprintf(buf, sizeof(buf), - "", proxy, - PyWeakref_GET_OBJECT(proxy)->ob_type->tp_name, - PyWeakref_GET_OBJECT(proxy)); - return PyString_FromString(buf); -} - - -static int -proxy_setattr(PyWeakReference *proxy, PyObject *name, PyObject *value) -{ - if (!proxy_checkref(proxy)) - return -1; - return PyObject_SetAttr(PyWeakref_GET_OBJECT(proxy), name, value); -} - -static int -proxy_compare(PyObject *proxy, PyObject *v) -{ - UNWRAP_I(proxy); - UNWRAP_I(v); - return PyObject_Compare(proxy, v); -} - -/* number slots */ -WRAP_BINARY(proxy_add, PyNumber_Add) -WRAP_BINARY(proxy_sub, PyNumber_Subtract) -WRAP_BINARY(proxy_mul, PyNumber_Multiply) -WRAP_BINARY(proxy_div, PyNumber_Divide) -WRAP_BINARY(proxy_mod, PyNumber_Remainder) -WRAP_BINARY(proxy_divmod, PyNumber_Divmod) -WRAP_TERNARY(proxy_pow, PyNumber_Power) -WRAP_UNARY(proxy_neg, PyNumber_Negative) -WRAP_UNARY(proxy_pos, PyNumber_Positive) -WRAP_UNARY(proxy_abs, PyNumber_Absolute) -WRAP_UNARY(proxy_invert, PyNumber_Invert) -WRAP_BINARY(proxy_lshift, PyNumber_Lshift) -WRAP_BINARY(proxy_rshift, PyNumber_Rshift) -WRAP_BINARY(proxy_and, PyNumber_And) -WRAP_BINARY(proxy_xor, PyNumber_Xor) -WRAP_BINARY(proxy_or, PyNumber_Or) -WRAP_UNARY(proxy_int, PyNumber_Int) -WRAP_UNARY(proxy_long, PyNumber_Long) -WRAP_UNARY(proxy_float, PyNumber_Float) -WRAP_BINARY(proxy_iadd, PyNumber_InPlaceAdd) -WRAP_BINARY(proxy_isub, PyNumber_InPlaceSubtract) -WRAP_BINARY(proxy_imul, PyNumber_InPlaceMultiply) -WRAP_BINARY(proxy_idiv, PyNumber_InPlaceDivide) -WRAP_BINARY(proxy_imod, PyNumber_InPlaceRemainder) -WRAP_TERNARY(proxy_ipow, PyNumber_InPlacePower) -WRAP_BINARY(proxy_ilshift, PyNumber_InPlaceLshift) -WRAP_BINARY(proxy_irshift, PyNumber_InPlaceRshift) -WRAP_BINARY(proxy_iand, PyNumber_InPlaceAnd) -WRAP_BINARY(proxy_ixor, PyNumber_InPlaceXor) -WRAP_BINARY(proxy_ior, PyNumber_InPlaceOr) - -static int -proxy_nonzero(PyWeakReference *proxy) -{ - PyObject *o = PyWeakref_GET_OBJECT(proxy); - if (!proxy_checkref(proxy)) - return 1; - if (o->ob_type->tp_as_number && - o->ob_type->tp_as_number->nb_nonzero) - return (*o->ob_type->tp_as_number->nb_nonzero)(o); - else - return 1; -} - -/* sequence slots */ - -static PyObject * -proxy_slice(PyWeakReference *proxy, int i, int j) -{ - if (!proxy_checkref(proxy)) - return NULL; - return PySequence_GetSlice(PyWeakref_GET_OBJECT(proxy), i, j); -} - -static int -proxy_ass_slice(PyWeakReference *proxy, int i, int j, PyObject *value) -{ - if (!proxy_checkref(proxy)) - return -1; - return PySequence_SetSlice(PyWeakref_GET_OBJECT(proxy), i, j, value); -} - -static int -proxy_contains(PyWeakReference *proxy, PyObject *value) -{ - if (!proxy_checkref(proxy)) - return -1; - return PySequence_Contains(PyWeakref_GET_OBJECT(proxy), value); -} - - -/* mapping slots */ - -static int -proxy_length(PyWeakReference *proxy) -{ - if (!proxy_checkref(proxy)) - return -1; - return PyObject_Length(PyWeakref_GET_OBJECT(proxy)); -} - -WRAP_BINARY(proxy_getitem, PyObject_GetItem) - -static int -proxy_setitem(PyWeakReference *proxy, PyObject *key, PyObject *value) -{ - if (!proxy_checkref(proxy)) - return -1; - - if (value == NULL) - return PyObject_DelItem(PyWeakref_GET_OBJECT(proxy), key); - else - return PyObject_SetItem(PyWeakref_GET_OBJECT(proxy), key, value); -} - -/* iterator slots */ - -static PyObject * -proxy_iter(PyWeakReference *proxy) -{ - if (!proxy_checkref(proxy)) - return NULL; - return PyObject_GetIter(PyWeakref_GET_OBJECT(proxy)); -} - -static PyObject * -proxy_iternext(PyWeakReference *proxy) -{ - if (!proxy_checkref(proxy)) - return NULL; - return PyIter_Next(PyWeakref_GET_OBJECT(proxy)); -} - - -static PyNumberMethods proxy_as_number = { - (binaryfunc)proxy_add, /*nb_add*/ - (binaryfunc)proxy_sub, /*nb_subtract*/ - (binaryfunc)proxy_mul, /*nb_multiply*/ - (binaryfunc)proxy_div, /*nb_divide*/ - (binaryfunc)proxy_mod, /*nb_remainder*/ - (binaryfunc)proxy_divmod, /*nb_divmod*/ - (ternaryfunc)proxy_pow, /*nb_power*/ - (unaryfunc)proxy_neg, /*nb_negative*/ - (unaryfunc)proxy_pos, /*nb_positive*/ - (unaryfunc)proxy_abs, /*nb_absolute*/ - (inquiry)proxy_nonzero, /*nb_nonzero*/ - (unaryfunc)proxy_invert, /*nb_invert*/ - (binaryfunc)proxy_lshift, /*nb_lshift*/ - (binaryfunc)proxy_rshift, /*nb_rshift*/ - (binaryfunc)proxy_and, /*nb_and*/ - (binaryfunc)proxy_xor, /*nb_xor*/ - (binaryfunc)proxy_or, /*nb_or*/ - (coercion)0, /*nb_coerce*/ - (unaryfunc)proxy_int, /*nb_int*/ - (unaryfunc)proxy_long, /*nb_long*/ - (unaryfunc)proxy_float, /*nb_float*/ - (unaryfunc)0, /*nb_oct*/ - (unaryfunc)0, /*nb_hex*/ - (binaryfunc)proxy_iadd, /*nb_inplace_add*/ - (binaryfunc)proxy_isub, /*nb_inplace_subtract*/ - (binaryfunc)proxy_imul, /*nb_inplace_multiply*/ - (binaryfunc)proxy_idiv, /*nb_inplace_divide*/ - (binaryfunc)proxy_imod, /*nb_inplace_remainder*/ - (ternaryfunc)proxy_ipow, /*nb_inplace_power*/ - (binaryfunc)proxy_ilshift, /*nb_inplace_lshift*/ - (binaryfunc)proxy_irshift, /*nb_inplace_rshift*/ - (binaryfunc)proxy_iand, /*nb_inplace_and*/ - (binaryfunc)proxy_ixor, /*nb_inplace_xor*/ - (binaryfunc)proxy_ior, /*nb_inplace_or*/ -}; - -static PySequenceMethods proxy_as_sequence = { - (inquiry)proxy_length, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - (intintargfunc)proxy_slice, /*sq_slice*/ - 0, /*sq_ass_item*/ - (intintobjargproc)proxy_ass_slice, /*sq_ass_slice*/ - (objobjproc)proxy_contains, /* sq_contains */ -}; - -static PyMappingMethods proxy_as_mapping = { - (inquiry)proxy_length, /*mp_length*/ - (binaryfunc)proxy_getitem, /*mp_subscript*/ - (objobjargproc)proxy_setitem, /*mp_ass_subscript*/ -}; - - -PyTypeObject -_PyWeakref_ProxyType = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "weakproxy", - sizeof(PyWeakReference), - 0, - /* methods */ - (destructor)weakref_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - proxy_compare, /* tp_compare */ - (unaryfunc)proxy_repr, /* tp_repr */ - &proxy_as_number, /* tp_as_number */ - &proxy_as_sequence, /* tp_as_sequence */ - &proxy_as_mapping, /* tp_as_mapping */ - 0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (unaryfunc)proxy_str, /* tp_str */ - (getattrofunc)proxy_getattr, /* tp_getattro */ - (setattrofunc)proxy_setattr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC - | Py_TPFLAGS_CHECKTYPES, /* tp_flags */ - 0, /* tp_doc */ - (traverseproc)gc_traverse, /* tp_traverse */ - (inquiry)gc_clear, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc)proxy_iter, /* tp_iter */ - (iternextfunc)proxy_iternext, /* tp_iternext */ -}; - - -PyTypeObject -_PyWeakref_CallableProxyType = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "weakcallableproxy", - sizeof(PyWeakReference), - 0, - /* methods */ - (destructor)weakref_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - proxy_compare, /* tp_compare */ - (unaryfunc)proxy_repr, /* tp_repr */ - &proxy_as_number, /* tp_as_number */ - &proxy_as_sequence, /* tp_as_sequence */ - &proxy_as_mapping, /* tp_as_mapping */ - 0, /* tp_hash */ - (ternaryfunc)proxy_call, /* tp_call */ - (unaryfunc)proxy_str, /* tp_str */ - (getattrofunc)proxy_getattr, /* tp_getattro */ - (setattrofunc)proxy_setattr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC - | Py_TPFLAGS_CHECKTYPES, /* tp_flags */ - 0, /* tp_doc */ - (traverseproc)gc_traverse, /* tp_traverse */ - (inquiry)gc_clear, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc)proxy_iter, /* tp_iter */ - (iternextfunc)proxy_iternext, /* tp_iternext */ -}; - - -/* Given the head of an object's list of weak references, extract the - * two callback-less refs (ref and proxy). Used to determine if the - * shared references exist and to determine the back link for newly - * inserted references. - */ -static void -get_basic_refs(PyWeakReference *head, - PyWeakReference **refp, PyWeakReference **proxyp) -{ - *refp = NULL; - *proxyp = NULL; - - if (head != NULL && head->wr_callback == NULL) { - if (head->ob_type == &_PyWeakref_RefType) { - *refp = head; - head = head->wr_next; - } - if (head != NULL && head->wr_callback == NULL) { - *proxyp = head; - head = head->wr_next; - } - } -} - -/* Insert 'newref' in the list after 'prev'. Both must be non-NULL. */ -static void -insert_after(PyWeakReference *newref, PyWeakReference *prev) -{ - newref->wr_prev = prev; - newref->wr_next = prev->wr_next; - if (prev->wr_next != NULL) - prev->wr_next->wr_prev = newref; - prev->wr_next = newref; -} - -/* Insert 'newref' at the head of the list; 'list' points to the variable - * that stores the head. - */ -static void -insert_head(PyWeakReference *newref, PyWeakReference **list) -{ - PyWeakReference *next = *list; - - newref->wr_prev = NULL; - newref->wr_next = next; - if (next != NULL) - next->wr_prev = newref; - *list = newref; -} - - -PyObject * -PyWeakref_NewRef(PyObject *ob, PyObject *callback) -{ - PyWeakReference *result = NULL; - PyWeakReference **list; - PyWeakReference *ref, *proxy; - - if (!PyType_SUPPORTS_WEAKREFS(ob->ob_type)) { - PyErr_Format(PyExc_TypeError, - "cannot create weak reference to '%s' object", - ob->ob_type->tp_name); - return NULL; - } - list = GET_WEAKREFS_LISTPTR(ob); - get_basic_refs(*list, &ref, &proxy); - if (callback == NULL || callback == Py_None) - /* return existing weak reference if it exists */ - result = ref; - if (result != NULL) - Py_XINCREF(result); - else { - result = new_weakref(ob, callback); - if (result != NULL) { - if (callback == NULL) { - insert_head(result, list); - } - else { - PyWeakReference *prev = (proxy == NULL) ? ref : proxy; - - if (prev == NULL) - insert_head(result, list); - else - insert_after(result, prev); - } - } - } - return (PyObject *) result; -} - - -PyObject * -PyWeakref_NewProxy(PyObject *ob, PyObject *callback) -{ - PyWeakReference *result = NULL; - PyWeakReference **list; - PyWeakReference *ref, *proxy; - - if (!PyType_SUPPORTS_WEAKREFS(ob->ob_type)) { - PyErr_Format(PyExc_TypeError, - "cannot create weak reference to '%s' object", - ob->ob_type->tp_name); - return NULL; - } - list = GET_WEAKREFS_LISTPTR(ob); - get_basic_refs(*list, &ref, &proxy); - if (callback == NULL) - /* attempt to return an existing weak reference if it exists */ - result = proxy; - if (result != NULL) - Py_XINCREF(result); - else { - result = new_weakref(ob, callback); - if (result != NULL) { - PyWeakReference *prev; - - if (PyCallable_Check(ob)) - result->ob_type = &_PyWeakref_CallableProxyType; - else - result->ob_type = &_PyWeakref_ProxyType; - if (callback == NULL) - prev = ref; - else - prev = (proxy == NULL) ? ref : proxy; - - if (prev == NULL) - insert_head(result, list); - else - insert_after(result, prev); - } - } - return (PyObject *) result; -} - - -PyObject * -PyWeakref_GetObject(PyObject *ref) -{ - if (ref == NULL || !PyWeakref_Check(ref)) { - PyErr_BadInternalCall(); - return NULL; - } - return PyWeakref_GET_OBJECT(ref); -} - - -static void -handle_callback(PyWeakReference *ref, PyObject *callback) -{ - PyObject *cbresult = PyObject_CallFunction(callback, "O", ref); - - if (cbresult == NULL) - PyErr_WriteUnraisable(callback); - else - Py_DECREF(cbresult); -} - -/* This function is called by the tp_dealloc handler to clear weak references. - * - * This iterates through the weak references for 'object' and calls callbacks - * for those references which have one. It returns when all callbacks have - * been attempted. - */ -void -PyObject_ClearWeakRefs(PyObject *object) -{ - PyWeakReference **list; - - if (object == NULL - || !PyType_SUPPORTS_WEAKREFS(object->ob_type) - || object->ob_refcnt != 0) { - PyErr_BadInternalCall(); - return; - } - list = GET_WEAKREFS_LISTPTR(object); - /* Remove the callback-less basic and proxy references */ - if (*list != NULL && (*list)->wr_callback == NULL) { - clear_weakref(*list); - if (*list != NULL && (*list)->wr_callback == NULL) - clear_weakref(*list); - } - if (*list != NULL) { - PyWeakReference *current = *list; - int count = _PyWeakref_GetWeakrefCount(current); - int restore_error = PyErr_Occurred() ? 1 : 0; - PyObject *err_type, *err_value, *err_tb; - - if (restore_error) - PyErr_Fetch(&err_type, &err_value, &err_tb); - if (count == 1) { - PyObject *callback = current->wr_callback; - - current->wr_callback = NULL; - clear_weakref(current); - handle_callback(current, callback); - Py_DECREF(callback); - } - else { - PyObject *tuple = PyTuple_New(count * 2); - int i = 0; - - for (i = 0; i < count; ++i) { - PyWeakReference *next = current->wr_next; - - Py_INCREF(current); - PyTuple_SET_ITEM(tuple, i * 2, (PyObject *) current); - PyTuple_SET_ITEM(tuple, i * 2 + 1, current->wr_callback); - current->wr_callback = NULL; - clear_weakref(current); - current = next; - } - for (i = 0; i < count; ++i) { - PyObject *current = PyTuple_GET_ITEM(tuple, i * 2); - PyObject *callback = PyTuple_GET_ITEM(tuple, i * 2 + 1); - - handle_callback((PyWeakReference *)current, callback); - } - Py_DECREF(tuple); - } - if (restore_error) - PyErr_Restore(err_type, err_value, err_tb); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/.cvsignore b/SDKs/XPlatform/Cypython-2.3.3/PC/.cvsignore deleted file mode 100644 index 34fd700b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -pythonnt_rc.h -pythonnt_rc_d.h diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/PlasmaPack.cpp b/SDKs/XPlatform/Cypython-2.3.3/PC/PlasmaPack.cpp deleted file mode 100644 index c5fe8ca2..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/PlasmaPack.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// gateway to cpp code - - -#include "Python.h" -#include "plPythonPack.h" - -#include "PlasmaPack.h" - -PyObject* Pl_OpenPacked(const char* fileName) -{ - return PythonPack::OpenPythonPacked(fileName); -} - -int Pl_IsItPacked(const char* fileName) -{ - return PythonPack::IsItPythonPacked(fileName); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/PlasmaPack.h b/SDKs/XPlatform/Cypython-2.3.3/PC/PlasmaPack.h deleted file mode 100644 index a13b00c8..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/PlasmaPack.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef PlasmaPack_h_inc -#define PlasmaPack_h_inc - -#ifdef __cplusplus -extern "C" { -#endif - -extern PyObject* Pl_OpenPacked(const char* fileName); -extern int Pl_IsItPacked(const char* fileName); - -#ifdef __cplusplus -} -#endif - -#endif // PlasmaPack_h_inc diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/WinMain.c b/SDKs/XPlatform/Cypython-2.3.3/PC/WinMain.c deleted file mode 100644 index c4ee86de..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/WinMain.c +++ /dev/null @@ -1,16 +0,0 @@ -/* Minimal main program -- everything is loaded from the library. */ - -#define WIN32_LEAN_AND_MEAN -#include - -#include "Python.h" - -int WINAPI WinMain( - HINSTANCE hInstance, /* handle to current instance */ - HINSTANCE hPrevInstance, /* handle to previous instance */ - LPSTR lpCmdLine, /* pointer to command line */ - int nCmdShow /* show state of window */ -) -{ - return Py_Main(__argc, __argv); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/_winreg.c b/SDKs/XPlatform/Cypython-2.3.3/PC/_winreg.c deleted file mode 100644 index a0f7d085..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/_winreg.c +++ /dev/null @@ -1,1526 +0,0 @@ -/* - _winreg.c - - Windows Registry access module for Python. - - * Simple registry access written by Mark Hammond in win32api - module circa 1995. - * Bill Tutt expanded the support significantly not long after. - * Numerous other people have submitted patches since then. - * Ripped from win32api module 03-Feb-2000 by Mark Hammond, and - basic Unicode support added. - -*/ - -#include "windows.h" -#include "Python.h" -#include "structmember.h" -#include "malloc.h" /* for alloca */ - -static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK); -static PyObject *PyHKEY_FromHKEY(HKEY h); -static BOOL PyHKEY_Close(PyObject *obHandle); - -static char errNotAHandle[] = "Object is not a handle"; - -/* The win32api module reports the function name that failed, - but this concept is not in the Python core. - Hopefully it will one day, and in the meantime I dont - want to lose this info... -*/ -#define PyErr_SetFromWindowsErrWithFunction(rc, fnname) \ - PyErr_SetFromWindowsErr(rc) - -/* Forward declares */ - -/* Doc strings */ -PyDoc_STRVAR(module_doc, -"This module provides access to the Windows registry API.\n" -"\n" -"Functions:\n" -"\n" -"CloseKey() - Closes a registry key.\n" -"ConnectRegistry() - Establishes a connection to a predefined registry handle\n" -" on another computer.\n" -"CreateKey() - Creates the specified key, or opens it if it already exists.\n" -"DeleteKey() - Deletes the specified key.\n" -"DeleteValue() - Removes a named value from the specified registry key.\n" -"EnumKey() - Enumerates subkeys of the specified open registry key.\n" -"EnumValue() - Enumerates values of the specified open registry key.\n" -"FlushKey() - Writes all the attributes of the specified key to the registry.\n" -"LoadKey() - Creates a subkey under HKEY_USER or HKEY_LOCAL_MACHINE and stores\n" -" registration information from a specified file into that subkey.\n" -"OpenKey() - Alias for \n" -"OpenKeyEx() - Opens the specified key.\n" -"QueryValue() - Retrieves the value associated with the unnamed value for a\n" -" specified key in the registry.\n" -"QueryValueEx() - Retrieves the type and data for a specified value name\n" -" associated with an open registry key.\n" -"QueryInfoKey() - Returns information about the specified key.\n" -"SaveKey() - Saves the specified key, and all its subkeys a file.\n" -"SetValue() - Associates a value with a specified key.\n" -"SetValueEx() - Stores data in the value field of an open registry key.\n" -"\n" -"Special objects:\n" -"\n" -"HKEYType -- type object for HKEY objects\n" -"error -- exception raised for Win32 errors\n" -"\n" -"Integer constants:\n" -"Many constants are defined - see the documentation for each function\n" -"to see what constants are used, and where."); - - -PyDoc_STRVAR(CloseKey_doc, -"CloseKey(hkey) - Closes a previously opened registry key.\n" -"\n" -"The hkey argument specifies a previously opened key.\n" -"\n" -"Note that if the key is not closed using this method, it will be\n" -"closed when the hkey object is destroyed by Python."); - -PyDoc_STRVAR(ConnectRegistry_doc, -"key = ConnectRegistry(computer_name, key) - " -"Establishes a connection to a predefined registry handle on another computer.\n" -"\n" -"computer_name is the name of the remote computer, of the form \\\\computername.\n" -" If None, the local computer is used.\n" -"key is the predefined handle to connect to.\n" -"\n" -"The return value is the handle of the opened key.\n" -"If the function fails, an EnvironmentError exception is raised."); - -PyDoc_STRVAR(CreateKey_doc, -"key = CreateKey(key, sub_key) - Creates or opens the specified key.\n" -"\n" -"key is an already open key, or one of the predefined HKEY_* constants\n" -"sub_key is a string that names the key this method opens or creates.\n" -" If key is one of the predefined keys, sub_key may be None. In that case,\n" -" the handle returned is the same key handle passed in to the function.\n" -"\n" -"If the key already exists, this function opens the existing key\n" -"\n" -"The return value is the handle of the opened key.\n" -"If the function fails, an exception is raised."); - -PyDoc_STRVAR(DeleteKey_doc, -"DeleteKey(key, sub_key) - Deletes the specified key.\n" -"\n" -"key is an already open key, or any one of the predefined HKEY_* constants.\n" -"sub_key is a string that must be a subkey of the key identified by the key parameter.\n" -" This value must not be None, and the key may not have subkeys.\n" -"\n" -"This method can not delete keys with subkeys.\n" -"\n" -"If the method succeeds, the entire key, including all of its values,\n" -"is removed. If the method fails, an EnvironmentError exception is raised."); - -PyDoc_STRVAR(DeleteValue_doc, -"DeleteValue(key, value) - Removes a named value from a registry key.\n" -"\n" -"key is an already open key, or any one of the predefined HKEY_* constants.\n" -"value is a string that identifies the value to remove."); - -PyDoc_STRVAR(EnumKey_doc, -"string = EnumKey(key, index) - Enumerates subkeys of an open registry key.\n" -"\n" -"key is an already open key, or any one of the predefined HKEY_* constants.\n" -"index is an integer that identifies the index of the key to retrieve.\n" -"\n" -"The function retrieves the name of one subkey each time it is called.\n" -"It is typically called repeatedly until an EnvironmentError exception is\n" -"raised, indicating no more values are available."); - -PyDoc_STRVAR(EnumValue_doc, -"tuple = EnumValue(key, index) - Enumerates values of an open registry key.\n" -"key is an already open key, or any one of the predefined HKEY_* constants.\n" -"index is an integer that identifies the index of the value to retrieve.\n" -"\n" -"The function retrieves the name of one subkey each time it is called.\n" -"It is typically called repeatedly, until an EnvironmentError exception\n" -"is raised, indicating no more values.\n" -"\n" -"The result is a tuple of 3 items:\n" -"value_name is a string that identifies the value.\n" -"value_data is an object that holds the value data, and whose type depends\n" -" on the underlying registry type.\n" -"data_type is an integer that identifies the type of the value data."); - -PyDoc_STRVAR(FlushKey_doc, -"FlushKey(key) - Writes all the attributes of a key to the registry.\n" -"\n" -"key is an already open key, or any one of the predefined HKEY_* constants.\n" -"\n" -"It is not necessary to call RegFlushKey to change a key.\n" -"Registry changes are flushed to disk by the registry using its lazy flusher.\n" -"Registry changes are also flushed to disk at system shutdown.\n" -"Unlike CloseKey(), the FlushKey() method returns only when all the data has\n" -"been written to the registry.\n" -"An application should only call FlushKey() if it requires absolute certainty that registry changes are on disk.\n" -"If you don't know whether a FlushKey() call is required, it probably isn't."); - -PyDoc_STRVAR(LoadKey_doc, -"LoadKey(key, sub_key, file_name) - Creates a subkey under the specified key\n" -"and stores registration information from a specified file into that subkey.\n" -"\n" -"key is an already open key, or any one of the predefined HKEY_* constants.\n" -"sub_key is a string that identifies the sub_key to load\n" -"file_name is the name of the file to load registry data from.\n" -" This file must have been created with the SaveKey() function.\n" -" Under the file allocation table (FAT) file system, the filename may not\n" -"have an extension.\n" -"\n" -"A call to LoadKey() fails if the calling process does not have the\n" -"SE_RESTORE_PRIVILEGE privilege.\n" -"\n" -"If key is a handle returned by ConnectRegistry(), then the path specified\n" -"in fileName is relative to the remote computer.\n" -"\n" -"The docs imply key must be in the HKEY_USER or HKEY_LOCAL_MACHINE tree"); - -PyDoc_STRVAR(OpenKey_doc, -"key = OpenKey(key, sub_key, res = 0, sam = KEY_READ) - Opens the specified key.\n" -"\n" -"key is an already open key, or any one of the predefined HKEY_* constants.\n" -"sub_key is a string that identifies the sub_key to open\n" -"res is a reserved integer, and must be zero. Default is zero.\n" -"sam is an integer that specifies an access mask that describes the desired\n" -" security access for the key. Default is KEY_READ\n" -"\n" -"The result is a new handle to the specified key\n" -"If the function fails, an EnvironmentError exception is raised."); - -PyDoc_STRVAR(OpenKeyEx_doc, "See OpenKey()"); - -PyDoc_STRVAR(QueryInfoKey_doc, -"tuple = QueryInfoKey(key) - Returns information about a key.\n" -"\n" -"key is an already open key, or any one of the predefined HKEY_* constants.\n" -"\n" -"The result is a tuple of 3 items:" -"An integer that identifies the number of sub keys this key has.\n" -"An integer that identifies the number of values this key has.\n" -"A long integer that identifies when the key was last modified (if available)\n" -" as 100's of nanoseconds since Jan 1, 1600."); - -PyDoc_STRVAR(QueryValue_doc, -"string = QueryValue(key, sub_key) - retrieves the unnamed value for a key.\n" -"\n" -"key is an already open key, or any one of the predefined HKEY_* constants.\n" -"sub_key is a string that holds the name of the subkey with which the value\n" -" is associated. If this parameter is None or empty, the function retrieves\n" -" the value set by the SetValue() method for the key identified by key." -"\n" -"Values in the registry have name, type, and data components. This method\n" -"retrieves the data for a key's first value that has a NULL name.\n" -"But the underlying API call doesn't return the type, Lame Lame Lame, DONT USE THIS!!!"); - -PyDoc_STRVAR(QueryValueEx_doc, -"value,type_id = QueryValueEx(key, value_name) - Retrieves the type and data for a specified value name associated with an open registry key.\n" -"\n" -"key is an already open key, or any one of the predefined HKEY_* constants.\n" -"value_name is a string indicating the value to query"); - -PyDoc_STRVAR(SaveKey_doc, -"SaveKey(key, file_name) - Saves the specified key, and all its subkeys to the specified file.\n" -"\n" -"key is an already open key, or any one of the predefined HKEY_* constants.\n" -"file_name is the name of the file to save registry data to.\n" -" This file cannot already exist. If this filename includes an extension,\n" -" it cannot be used on file allocation table (FAT) file systems by the\n" -" LoadKey(), ReplaceKey() or RestoreKey() methods.\n" -"\n" -"If key represents a key on a remote computer, the path described by\n" -"file_name is relative to the remote computer.\n" -"The caller of this method must possess the SeBackupPrivilege security privilege.\n" -"This function passes NULL for security_attributes to the API."); - -PyDoc_STRVAR(SetValue_doc, -"SetValue(key, sub_key, type, value) - Associates a value with a specified key.\n" -"\n" -"key is an already open key, or any one of the predefined HKEY_* constants.\n" -"sub_key is a string that names the subkey with which the value is associated.\n" -"type is an integer that specifies the type of the data. Currently this\n" -" must be REG_SZ, meaning only strings are supported.\n" -"value is a string that specifies the new value.\n" -"\n" -"If the key specified by the sub_key parameter does not exist, the SetValue\n" -"function creates it.\n" -"\n" -"Value lengths are limited by available memory. Long values (more than\n" -"2048 bytes) should be stored as files with the filenames stored in \n" -"the configuration registry. This helps the registry perform efficiently.\n" -"\n" -"The key identified by the key parameter must have been opened with\n" -"KEY_SET_VALUE access."); - -PyDoc_STRVAR(SetValueEx_doc, -"SetValueEx(key, value_name, reserved, type, value) - Stores data in the value field of an open registry key.\n" -"\n" -"key is an already open key, or any one of the predefined HKEY_* constants.\n" -"value_name is a string containing the name of the value to set, or None\n" -"type is an integer that specifies the type of the data. This should be one of:\n" -" REG_BINARY -- Binary data in any form.\n" -" REG_DWORD -- A 32-bit number.\n" -" REG_DWORD_LITTLE_ENDIAN -- A 32-bit number in little-endian format.\n" -" REG_DWORD_BIG_ENDIAN -- A 32-bit number in big-endian format.\n" -" REG_EXPAND_SZ -- A null-terminated string that contains unexpanded references\n" -" to environment variables (for example, %PATH%).\n" -" REG_LINK -- A Unicode symbolic link.\n" -" REG_MULTI_SZ -- An sequence of null-terminated strings, terminated by\n" -" two null characters. Note that Python handles this\n" -" termination automatically.\n" -" REG_NONE -- No defined value type.\n" -" REG_RESOURCE_LIST -- A device-driver resource list.\n" -" REG_SZ -- A null-terminated string.\n" -"reserved can be anything - zero is always passed to the API.\n" -"value is a string that specifies the new value.\n" -"\n" -"This method can also set additional value and type information for the\n" -"specified key. The key identified by the key parameter must have been\n" -"opened with KEY_SET_VALUE access.\n" -"\n" -"To open the key, use the CreateKeyEx() or OpenKeyEx() methods.\n" -"\n" -"Value lengths are limited by available memory. Long values (more than\n" -"2048 bytes) should be stored as files with the filenames stored in \n" -"the configuration registry. This helps the registry perform efficiently."); - -/* PyHKEY docstrings */ -PyDoc_STRVAR(PyHKEY_doc, -"PyHKEY Object - A Python object, representing a win32 registry key.\n" -"\n" -"This object wraps a Windows HKEY object, automatically closing it when\n" -"the object is destroyed. To guarantee cleanup, you can call either\n" -"the Close() method on the PyHKEY, or the CloseKey() method.\n" -"\n" -"All functions which accept a handle object also accept an integer - \n" -"however, use of the handle object is encouraged.\n" -"\n" -"Functions:\n" -"Close() - Closes the underlying handle.\n" -"Detach() - Returns the integer Win32 handle, detaching it from the object\n" -"\n" -"Properties:\n" -"handle - The integer Win32 handle.\n" -"\n" -"Operations:\n" -"__nonzero__ - Handles with an open object return true, otherwise false.\n" -"__int__ - Converting a handle to an integer returns the Win32 handle.\n" -"__cmp__ - Handle objects are compared using the handle value."); - - -PyDoc_STRVAR(PyHKEY_Close_doc, -"key.Close() - Closes the underlying Windows handle.\n" -"\n" -"If the handle is already closed, no error is raised."); - -PyDoc_STRVAR(PyHKEY_Detach_doc, -"int = key.Detach() - Detaches the Windows handle from the handle object.\n" -"\n" -"The result is the value of the handle before it is detached. If the\n" -"handle is already detached, this will return zero.\n" -"\n" -"After calling this function, the handle is effectively invalidated,\n" -"but the handle is not closed. You would call this function when you\n" -"need the underlying win32 handle to exist beyond the lifetime of the\n" -"handle object.\n" -"On 64 bit windows, the result of this function is a long integer"); - - -/************************************************************************ - - The PyHKEY object definition - -************************************************************************/ -typedef struct { - PyObject_VAR_HEAD - HKEY hkey; -} PyHKEYObject; - -#define PyHKEY_Check(op) ((op)->ob_type == &PyHKEY_Type) - -static char *failMsg = "bad operand type"; - -static PyObject * -PyHKEY_unaryFailureFunc(PyObject *ob) -{ - PyErr_SetString(PyExc_TypeError, failMsg); - return NULL; -} -static PyObject * -PyHKEY_binaryFailureFunc(PyObject *ob1, PyObject *ob2) -{ - PyErr_SetString(PyExc_TypeError, failMsg); - return NULL; -} -static PyObject * -PyHKEY_ternaryFailureFunc(PyObject *ob1, PyObject *ob2, PyObject *ob3) -{ - PyErr_SetString(PyExc_TypeError, failMsg); - return NULL; -} - -static void -PyHKEY_deallocFunc(PyObject *ob) -{ - /* Can not call PyHKEY_Close, as the ob->tp_type - has already been cleared, thus causing the type - check to fail! - */ - PyHKEYObject *obkey = (PyHKEYObject *)ob; - if (obkey->hkey) - RegCloseKey((HKEY)obkey->hkey); - PyObject_DEL(ob); -} - -static int -PyHKEY_nonzeroFunc(PyObject *ob) -{ - return ((PyHKEYObject *)ob)->hkey != 0; -} - -static PyObject * -PyHKEY_intFunc(PyObject *ob) -{ - PyHKEYObject *pyhkey = (PyHKEYObject *)ob; - return PyLong_FromVoidPtr(pyhkey->hkey); -} - -static int -PyHKEY_printFunc(PyObject *ob, FILE *fp, int flags) -{ - PyHKEYObject *pyhkey = (PyHKEYObject *)ob; - char resBuf[160]; - wsprintf(resBuf, "", - ob, pyhkey->hkey); - fputs(resBuf, fp); - return 0; -} - -static PyObject * -PyHKEY_strFunc(PyObject *ob) -{ - PyHKEYObject *pyhkey = (PyHKEYObject *)ob; - char resBuf[160]; - wsprintf(resBuf, "", pyhkey->hkey); - return PyString_FromString(resBuf); -} - -static int -PyHKEY_compareFunc(PyObject *ob1, PyObject *ob2) -{ - PyHKEYObject *pyhkey1 = (PyHKEYObject *)ob1; - PyHKEYObject *pyhkey2 = (PyHKEYObject *)ob2; - return pyhkey1 == pyhkey2 ? 0 : - (pyhkey1 < pyhkey2 ? -1 : 1); -} - -static long -PyHKEY_hashFunc(PyObject *ob) -{ - /* Just use the address. - XXX - should we use the handle value? - */ - return _Py_HashPointer(ob); -} - - -static PyNumberMethods PyHKEY_NumberMethods = -{ - PyHKEY_binaryFailureFunc, /* nb_add */ - PyHKEY_binaryFailureFunc, /* nb_subtract */ - PyHKEY_binaryFailureFunc, /* nb_multiply */ - PyHKEY_binaryFailureFunc, /* nb_divide */ - PyHKEY_binaryFailureFunc, /* nb_remainder */ - PyHKEY_binaryFailureFunc, /* nb_divmod */ - PyHKEY_ternaryFailureFunc, /* nb_power */ - PyHKEY_unaryFailureFunc, /* nb_negative */ - PyHKEY_unaryFailureFunc, /* nb_positive */ - PyHKEY_unaryFailureFunc, /* nb_absolute */ - PyHKEY_nonzeroFunc, /* nb_nonzero */ - PyHKEY_unaryFailureFunc, /* nb_invert */ - PyHKEY_binaryFailureFunc, /* nb_lshift */ - PyHKEY_binaryFailureFunc, /* nb_rshift */ - PyHKEY_binaryFailureFunc, /* nb_and */ - PyHKEY_binaryFailureFunc, /* nb_xor */ - PyHKEY_binaryFailureFunc, /* nb_or */ - 0, /* nb_coerce (allowed to be zero) */ - PyHKEY_intFunc, /* nb_int */ - PyHKEY_unaryFailureFunc, /* nb_long */ - PyHKEY_unaryFailureFunc, /* nb_float */ - PyHKEY_unaryFailureFunc, /* nb_oct */ - PyHKEY_unaryFailureFunc, /* nb_hex */ -}; - - -/* fwd declare __getattr__ */ -static PyObject *PyHKEY_getattr(PyObject *self, char *name); - -/* The type itself */ -PyTypeObject PyHKEY_Type = -{ - PyObject_HEAD_INIT(0) /* fill in type at module init */ - 0, - "PyHKEY", - sizeof(PyHKEYObject), - 0, - PyHKEY_deallocFunc, /* tp_dealloc */ - PyHKEY_printFunc, /* tp_print */ - PyHKEY_getattr, /* tp_getattr */ - 0, /* tp_setattr */ - PyHKEY_compareFunc, /* tp_compare */ - 0, /* tp_repr */ - &PyHKEY_NumberMethods, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - PyHKEY_hashFunc, /* tp_hash */ - 0, /* tp_call */ - PyHKEY_strFunc, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - 0, /* tp_flags */ - PyHKEY_doc, /* tp_doc */ -}; - -#define OFF(e) offsetof(PyHKEYObject, e) - -static struct memberlist PyHKEY_memberlist[] = { - {"handle", T_INT, OFF(hkey)}, - {NULL} /* Sentinel */ -}; - -/************************************************************************ - - The PyHKEY object methods - -************************************************************************/ -static PyObject * -PyHKEY_CloseMethod(PyObject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":Close")) - return NULL; - if (!PyHKEY_Close(self)) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -PyHKEY_DetachMethod(PyObject *self, PyObject *args) -{ - void* ret; - PyHKEYObject *pThis = (PyHKEYObject *)self; - if (!PyArg_ParseTuple(args, ":Detach")) - return NULL; - ret = (void*)pThis->hkey; - pThis->hkey = 0; - return PyLong_FromVoidPtr(ret); -} - -static struct PyMethodDef PyHKEY_methods[] = { - {"Close", PyHKEY_CloseMethod, METH_VARARGS, PyHKEY_Close_doc}, - {"Detach", PyHKEY_DetachMethod, METH_VARARGS, PyHKEY_Detach_doc}, - {NULL} -}; - -/*static*/ PyObject * -PyHKEY_getattr(PyObject *self, char *name) -{ - PyObject *res; - - res = Py_FindMethod(PyHKEY_methods, self, name); - if (res != NULL) - return res; - PyErr_Clear(); - if (strcmp(name, "handle") == 0) - return PyLong_FromVoidPtr(((PyHKEYObject *)self)->hkey); - return PyMember_Get((char *)self, PyHKEY_memberlist, name); -} - -/************************************************************************ - The public PyHKEY API (well, not public yet :-) -************************************************************************/ -PyObject * -PyHKEY_New(HKEY hInit) -{ - PyHKEYObject *key = PyObject_NEW(PyHKEYObject, &PyHKEY_Type); - if (key) - key->hkey = hInit; - return (PyObject *)key; -} - -BOOL -PyHKEY_Close(PyObject *ob_handle) -{ - LONG rc; - PyHKEYObject *key; - - if (!PyHKEY_Check(ob_handle)) { - PyErr_SetString(PyExc_TypeError, "bad operand type"); - return FALSE; - } - key = (PyHKEYObject *)ob_handle; - rc = key->hkey ? RegCloseKey((HKEY)key->hkey) : ERROR_SUCCESS; - key->hkey = 0; - if (rc != ERROR_SUCCESS) - PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); - return rc == ERROR_SUCCESS; -} - -BOOL -PyHKEY_AsHKEY(PyObject *ob, HKEY *pHANDLE, BOOL bNoneOK) -{ - if (ob == Py_None) { - if (!bNoneOK) { - PyErr_SetString( - PyExc_TypeError, - "None is not a valid HKEY in this context"); - return FALSE; - } - *pHANDLE = (HKEY)0; - } - else if (PyHKEY_Check(ob)) { - PyHKEYObject *pH = (PyHKEYObject *)ob; - *pHANDLE = pH->hkey; - } - else if (PyInt_Check(ob) || PyLong_Check(ob)) { - /* We also support integers */ - PyErr_Clear(); - *pHANDLE = (HKEY)PyLong_AsVoidPtr(ob); - if (PyErr_Occurred()) - return FALSE; - } - else { - PyErr_SetString( - PyExc_TypeError, - "The object is not a PyHKEY object"); - return FALSE; - } - return TRUE; -} - -PyObject * -PyHKEY_FromHKEY(HKEY h) -{ - PyHKEYObject *op; - - /* Inline PyObject_New */ - op = (PyHKEYObject *) PyObject_MALLOC(sizeof(PyHKEYObject)); - if (op == NULL) - return PyErr_NoMemory(); - PyObject_INIT(op, &PyHKEY_Type); - op->hkey = h; - return (PyObject *)op; -} - - -/************************************************************************ - The module methods -************************************************************************/ -BOOL -PyWinObject_CloseHKEY(PyObject *obHandle) -{ - BOOL ok; - if (PyHKEY_Check(obHandle)) { - ok = PyHKEY_Close(obHandle); - } -#if SIZEOF_LONG >= SIZEOF_HKEY - else if (PyInt_Check(obHandle)) { - long rc = RegCloseKey((HKEY)PyInt_AsLong(obHandle)); - ok = (rc == ERROR_SUCCESS); - if (!ok) - PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); - } -#else - else if (PyLong_Check(obHandle)) { - long rc = RegCloseKey((HKEY)PyLong_AsVoidPtr(obHandle)); - ok = (rc == ERROR_SUCCESS); - if (!ok) - PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); - } -#endif - else { - PyErr_SetString( - PyExc_TypeError, - "A handle must be a HKEY object or an integer"); - return FALSE; - } - return ok; -} - - -/* - Private Helper functions for the registry interfaces - -** Note that fixupMultiSZ and countString have both had changes -** made to support "incorrect strings". The registry specification -** calls for strings to be terminated with 2 null bytes. It seems -** some commercial packages install strings which dont conform, -** causing this code to fail - however, "regedit" etc still work -** with these strings (ie only we dont!). -*/ -static void -fixupMultiSZ(char **str, char *data, int len) -{ - char *P; - int i; - char *Q; - - Q = data + len; - for (P = data, i = 0; P < Q && *P != '\0'; P++, i++) { - str[i] = P; - for(; *P != '\0'; P++) - ; - } -} - -static int -countStrings(char *data, int len) -{ - int strings; - char *P; - char *Q = data + len; - - for (P = data, strings = 0; P < Q && *P != '\0'; P++, strings++) - for (; P < Q && *P != '\0'; P++) - ; - return strings; -} - -/* Convert PyObject into Registry data. - Allocates space as needed. */ -static BOOL -Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) -{ - int i,j; - switch (typ) { - case REG_DWORD: - if (value != Py_None && !PyInt_Check(value)) - return FALSE; - *retDataBuf = (BYTE *)PyMem_NEW(DWORD, sizeof(DWORD)); - if (*retDataBuf==NULL){ - PyErr_NoMemory(); - return FALSE; - } - *retDataSize = sizeof(DWORD); - if (value == Py_None) { - DWORD zero = 0; - memcpy(*retDataBuf, &zero, sizeof(DWORD)); - } - else - memcpy(*retDataBuf, - &PyInt_AS_LONG((PyIntObject *)value), - sizeof(DWORD)); - break; - case REG_SZ: - case REG_EXPAND_SZ: - { - int need_decref = 0; - if (value == Py_None) - *retDataSize = 1; - else { - if (PyUnicode_Check(value)) { - value = PyUnicode_AsEncodedString( - value, - "mbcs", - NULL); - if (value==NULL) - return FALSE; - need_decref = 1; - } - if (!PyString_Check(value)) - return FALSE; - *retDataSize = 1 + strlen( - PyString_AS_STRING( - (PyStringObject *)value)); - } - *retDataBuf = (BYTE *)PyMem_NEW(DWORD, *retDataSize); - if (*retDataBuf==NULL){ - PyErr_NoMemory(); - return FALSE; - } - if (value == Py_None) - strcpy((char *)*retDataBuf, ""); - else - strcpy((char *)*retDataBuf, - PyString_AS_STRING( - (PyStringObject *)value)); - if (need_decref) - Py_DECREF(value); - break; - } - case REG_MULTI_SZ: - { - DWORD size = 0; - char *P; - PyObject **obs = NULL; - - if (value == Py_None) - i = 0; - else { - if (!PyList_Check(value)) - return FALSE; - i = PyList_Size(value); - } - obs = malloc(sizeof(PyObject *) * i); - memset(obs, 0, sizeof(PyObject *) * i); - for (j = 0; j < i; j++) - { - PyObject *t; - t = PyList_GET_ITEM( - (PyListObject *)value,j); - if (PyString_Check(t)) { - obs[j] = t; - Py_INCREF(t); - } else if (PyUnicode_Check(t)) { - obs[j] = PyUnicode_AsEncodedString( - t, - "mbcs", - NULL); - if (obs[j]==NULL) - goto reg_multi_fail; - } else - goto reg_multi_fail; - size += 1 + strlen( - PyString_AS_STRING( - (PyStringObject *)obs[j])); - } - - *retDataSize = size + 1; - *retDataBuf = (BYTE *)PyMem_NEW(char, - *retDataSize); - if (*retDataBuf==NULL){ - PyErr_NoMemory(); - goto reg_multi_fail; - } - P = (char *)*retDataBuf; - - for (j = 0; j < i; j++) - { - PyObject *t; - t = obs[j]; - strcpy(P, - PyString_AS_STRING( - (PyStringObject *)t)); - P += 1 + strlen( - PyString_AS_STRING( - (PyStringObject *)t)); - Py_DECREF(obs[j]); - } - /* And doubly-terminate the list... */ - *P = '\0'; - free(obs); - break; - reg_multi_fail: - if (obs) { - for (j = 0; j < i; j++) - Py_XDECREF(obs[j]); - - free(obs); - } - return FALSE; - } - case REG_BINARY: - /* ALSO handle ALL unknown data types here. Even if we can't - support it natively, we should handle the bits. */ - default: - if (value == Py_None) - *retDataSize = 0; - else { - void *src_buf; - PyBufferProcs *pb = value->ob_type->tp_as_buffer; - if (pb==NULL) { - PyErr_Format(PyExc_TypeError, - "Objects of type '%s' can not " - "be used as binary registry values", - value->ob_type->tp_name); - return FALSE; - } - *retDataSize = (*pb->bf_getreadbuffer)(value, 0, &src_buf); - *retDataBuf = (BYTE *)PyMem_NEW(char, - *retDataSize); - if (*retDataBuf==NULL){ - PyErr_NoMemory(); - return FALSE; - } - memcpy(*retDataBuf, src_buf, *retDataSize); - } - break; - } - return TRUE; -} - -/* Convert Registry data into PyObject*/ -static PyObject * -Reg2Py(char *retDataBuf, DWORD retDataSize, DWORD typ) -{ - PyObject *obData; - - switch (typ) { - case REG_DWORD: - if (retDataSize == 0) - obData = Py_BuildValue("i", 0); - else - obData = Py_BuildValue("i", - *(int *)retDataBuf); - break; - case REG_SZ: - case REG_EXPAND_SZ: - /* retDataBuf may or may not have a trailing NULL in - the buffer. */ - if (retDataSize && retDataBuf[retDataSize-1] == '\0') - --retDataSize; - if (retDataSize ==0) - retDataBuf = ""; - obData = PyUnicode_DecodeMBCS(retDataBuf, - retDataSize, - NULL); - break; - case REG_MULTI_SZ: - if (retDataSize == 0) - obData = PyList_New(0); - else - { - int index = 0; - int s = countStrings(retDataBuf, retDataSize); - char **str = (char **)malloc(sizeof(char *)*s); - if (str == NULL) - return PyErr_NoMemory(); - - fixupMultiSZ(str, retDataBuf, retDataSize); - obData = PyList_New(s); - if (obData == NULL) - return NULL; - for (index = 0; index < s; index++) - { - size_t len = _mbstrlen(str[index]); - if (len > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "registry string is too long for a Python string"); - Py_DECREF(obData); - return NULL; - } - PyList_SetItem(obData, - index, - PyUnicode_DecodeMBCS( - (const char *)str[index], - (int)len, - NULL) - ); - } - free(str); - - break; - } - case REG_BINARY: - /* ALSO handle ALL unknown data types here. Even if we can't - support it natively, we should handle the bits. */ - default: - if (retDataSize == 0) { - Py_INCREF(Py_None); - obData = Py_None; - } - else - obData = Py_BuildValue("s#", - (char *)retDataBuf, - retDataSize); - break; - } - if (obData == NULL) - return NULL; - else - return obData; -} - -/* The Python methods */ - -static PyObject * -PyCloseKey(PyObject *self, PyObject *args) -{ - PyObject *obKey; - if (!PyArg_ParseTuple(args, "O:CloseKey", &obKey)) - return NULL; - if (!PyHKEY_Close(obKey)) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -PyConnectRegistry(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - char *szCompName = NULL; - HKEY retKey; - long rc; - if (!PyArg_ParseTuple(args, "zO:ConnectRegistry", &szCompName, &obKey)) - return NULL; - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - rc = RegConnectRegistry(szCompName, hKey, &retKey); - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "ConnectRegistry"); - return PyHKEY_FromHKEY(retKey); -} - -static PyObject * -PyCreateKey(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - char *subKey; - HKEY retKey; - long rc; - if (!PyArg_ParseTuple(args, "Oz:CreateKey", &obKey, &subKey)) - return NULL; - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - rc = RegCreateKey(hKey, subKey, &retKey); - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "CreateKey"); - return PyHKEY_FromHKEY(retKey); -} - -static PyObject * -PyDeleteKey(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - char *subKey; - long rc; - if (!PyArg_ParseTuple(args, "Os:DeleteKey", &obKey, &subKey)) - return NULL; - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - rc = RegDeleteKey(hKey, subKey ); - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKey"); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -PyDeleteValue(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - char *subKey; - long rc; - if (!PyArg_ParseTuple(args, "Oz:DeleteValue", &obKey, &subKey)) - return NULL; - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - Py_BEGIN_ALLOW_THREADS - rc = RegDeleteValue(hKey, subKey); - Py_END_ALLOW_THREADS - if (rc !=ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegDeleteValue"); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -PyEnumKey(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - int index; - long rc; - PyObject *retStr; - char *retBuf; - DWORD len; - - if (!PyArg_ParseTuple(args, "Oi:EnumKey", &obKey, &index)) - return NULL; - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - - if ((rc = RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, &len, - NULL, NULL, NULL, NULL, NULL, NULL)) - != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegQueryInfoKey"); - ++len; /* include null terminator */ - retStr = PyString_FromStringAndSize(NULL, len); - if (retStr == NULL) - return NULL; - retBuf = PyString_AS_STRING(retStr); - - if ((rc = RegEnumKey(hKey, index, retBuf, len)) != ERROR_SUCCESS) { - Py_DECREF(retStr); - return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKey"); - } - _PyString_Resize(&retStr, strlen(retBuf)); - return retStr; -} - -static PyObject * -PyEnumValue(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - int index; - long rc; - char *retValueBuf; - char *retDataBuf; - DWORD retValueSize; - DWORD retDataSize; - DWORD typ; - PyObject *obData; - PyObject *retVal; - - if (!PyArg_ParseTuple(args, "Oi:EnumValue", &obKey, &index)) - return NULL; - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - - if ((rc = RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, - &retValueSize, &retDataSize, NULL, NULL)) - != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegQueryInfoKey"); - ++retValueSize; /* include null terminators */ - ++retDataSize; - retValueBuf = (char *)PyMem_Malloc(retValueSize); - if (retValueBuf == NULL) - return PyErr_NoMemory(); - retDataBuf = (char *)PyMem_Malloc(retDataSize); - if (retDataBuf == NULL) { - PyMem_Free(retValueBuf); - return PyErr_NoMemory(); - } - - Py_BEGIN_ALLOW_THREADS - rc = RegEnumValue(hKey, - index, - retValueBuf, - &retValueSize, - NULL, - &typ, - (BYTE *)retDataBuf, - &retDataSize); - Py_END_ALLOW_THREADS - - if (rc != ERROR_SUCCESS) { - retVal = PyErr_SetFromWindowsErrWithFunction(rc, - "PyRegEnumValue"); - goto fail; - } - obData = Reg2Py(retDataBuf, retDataSize, typ); - if (obData == NULL) { - retVal = NULL; - goto fail; - } - retVal = Py_BuildValue("sOi", retValueBuf, obData, typ); - Py_DECREF(obData); - fail: - PyMem_Free(retValueBuf); - PyMem_Free(retDataBuf); - return retVal; -} - -static PyObject * -PyFlushKey(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - long rc; - if (!PyArg_ParseTuple(args, "O:FlushKey", &obKey)) - return NULL; - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - Py_BEGIN_ALLOW_THREADS - rc = RegFlushKey(hKey); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "RegFlushKey"); - Py_INCREF(Py_None); - return Py_None; -} -static PyObject * -PyLoadKey(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - char *subKey; - char *fileName; - - long rc; - if (!PyArg_ParseTuple(args, "Oss:LoadKey", &obKey, &subKey, &fileName)) - return NULL; - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - Py_BEGIN_ALLOW_THREADS - rc = RegLoadKey(hKey, subKey, fileName ); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "RegLoadKey"); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -PyOpenKey(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - - char *subKey; - int res = 0; - HKEY retKey; - long rc; - REGSAM sam = KEY_READ; - if (!PyArg_ParseTuple(args, "Oz|ii:OpenKey", &obKey, &subKey, - &res, &sam)) - return NULL; - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - - Py_BEGIN_ALLOW_THREADS - rc = RegOpenKeyEx(hKey, subKey, res, sam, &retKey); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "RegOpenKeyEx"); - return PyHKEY_FromHKEY(retKey); -} - - -static PyObject * -PyQueryInfoKey(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - long rc; - DWORD nSubKeys, nValues; - FILETIME ft; - LARGE_INTEGER li; - PyObject *l; - PyObject *ret; - if (!PyArg_ParseTuple(args, "O:QueryInfoKey", &obKey)) - return NULL; - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - if ((rc = RegQueryInfoKey(hKey, NULL, NULL, 0, &nSubKeys, NULL, NULL, - &nValues, NULL, NULL, NULL, &ft)) - != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryInfoKey"); - li.LowPart = ft.dwLowDateTime; - li.HighPart = ft.dwHighDateTime; - l = PyLong_FromLongLong(li.QuadPart); - if (l == NULL) - return NULL; - ret = Py_BuildValue("iiO", nSubKeys, nValues, l); - Py_DECREF(l); - return ret; -} - -static PyObject * -PyQueryValue(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - char *subKey; - long rc; - PyObject *retStr; - char *retBuf; - long bufSize = 0; - - if (!PyArg_ParseTuple(args, "Oz:QueryValue", &obKey, &subKey)) - return NULL; - - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - if ((rc = RegQueryValue(hKey, subKey, NULL, &bufSize)) - != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegQueryValue"); - retStr = PyString_FromStringAndSize(NULL, bufSize); - if (retStr == NULL) - return NULL; - retBuf = PyString_AS_STRING(retStr); - if ((rc = RegQueryValue(hKey, subKey, retBuf, &bufSize)) - != ERROR_SUCCESS) { - Py_DECREF(retStr); - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegQueryValue"); - } - _PyString_Resize(&retStr, strlen(retBuf)); - return retStr; -} - -static PyObject * -PyQueryValueEx(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - char *valueName; - - long rc; - char *retBuf; - DWORD bufSize = 0; - DWORD typ; - PyObject *obData; - PyObject *result; - - if (!PyArg_ParseTuple(args, "Oz:QueryValueEx", &obKey, &valueName)) - return NULL; - - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - if ((rc = RegQueryValueEx(hKey, valueName, - NULL, NULL, NULL, - &bufSize)) - != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegQueryValueEx"); - retBuf = (char *)PyMem_Malloc(bufSize); - if (retBuf == NULL) - return PyErr_NoMemory(); - if ((rc = RegQueryValueEx(hKey, valueName, NULL, - &typ, (BYTE *)retBuf, &bufSize)) - != ERROR_SUCCESS) { - PyMem_Free(retBuf); - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegQueryValueEx"); - } - obData = Reg2Py(retBuf, bufSize, typ); - PyMem_Free((void *)retBuf); - if (obData == NULL) - return NULL; - result = Py_BuildValue("Oi", obData, typ); - Py_DECREF(obData); - return result; -} - - -static PyObject * -PySaveKey(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - char *fileName; - LPSECURITY_ATTRIBUTES pSA = NULL; - - long rc; - if (!PyArg_ParseTuple(args, "Os:SaveKey", &obKey, &fileName)) - return NULL; - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; -/* One day we may get security into the core? - if (!PyWinObject_AsSECURITY_ATTRIBUTES(obSA, &pSA, TRUE)) - return NULL; -*/ - Py_BEGIN_ALLOW_THREADS - rc = RegSaveKey(hKey, fileName, pSA ); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "RegSaveKey"); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -PySetValue(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - char *subKey; - char *str; - DWORD typ; - DWORD len; - long rc; - PyObject *obStrVal; - PyObject *obSubKey; - if (!PyArg_ParseTuple(args, "OOiO:SetValue", - &obKey, - &obSubKey, - &typ, - &obStrVal)) - return NULL; - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - if (typ != REG_SZ) { - PyErr_SetString(PyExc_TypeError, - "Type must be _winreg.REG_SZ"); - return NULL; - } - /* XXX - need Unicode support */ - str = PyString_AsString(obStrVal); - if (str == NULL) - return NULL; - len = PyString_Size(obStrVal); - if (obSubKey == Py_None) - subKey = NULL; - else { - subKey = PyString_AsString(obSubKey); - if (subKey == NULL) - return NULL; - } - Py_BEGIN_ALLOW_THREADS - rc = RegSetValue(hKey, subKey, REG_SZ, str, len+1); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "RegSetValue"); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -PySetValueEx(PyObject *self, PyObject *args) -{ - HKEY hKey; - PyObject *obKey; - char *valueName; - PyObject *obRes; - PyObject *value; - BYTE *data; - DWORD len; - DWORD typ; - - LONG rc; - - if (!PyArg_ParseTuple(args, "OzOiO:SetValueEx", - &obKey, - &valueName, - &obRes, - &typ, - &value)) - return NULL; - if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - if (!Py2Reg(value, typ, &data, &len)) - { - if (!PyErr_Occurred()) - PyErr_SetString(PyExc_ValueError, - "Could not convert the data to the specified type."); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - rc = RegSetValueEx(hKey, valueName, 0, typ, data, len); - Py_END_ALLOW_THREADS - PyMem_DEL(data); - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegSetValueEx"); - Py_INCREF(Py_None); - return Py_None; -} - -static struct PyMethodDef winreg_methods[] = { - {"CloseKey", PyCloseKey, METH_VARARGS, CloseKey_doc}, - {"ConnectRegistry", PyConnectRegistry, METH_VARARGS, ConnectRegistry_doc}, - {"CreateKey", PyCreateKey, METH_VARARGS, CreateKey_doc}, - {"DeleteKey", PyDeleteKey, METH_VARARGS, DeleteKey_doc}, - {"DeleteValue", PyDeleteValue, METH_VARARGS, DeleteValue_doc}, - {"EnumKey", PyEnumKey, METH_VARARGS, EnumKey_doc}, - {"EnumValue", PyEnumValue, METH_VARARGS, EnumValue_doc}, - {"FlushKey", PyFlushKey, METH_VARARGS, FlushKey_doc}, - {"LoadKey", PyLoadKey, METH_VARARGS, LoadKey_doc}, - {"OpenKey", PyOpenKey, METH_VARARGS, OpenKey_doc}, - {"OpenKeyEx", PyOpenKey, METH_VARARGS, OpenKeyEx_doc}, - {"QueryValue", PyQueryValue, METH_VARARGS, QueryValue_doc}, - {"QueryValueEx", PyQueryValueEx, METH_VARARGS, QueryValueEx_doc}, - {"QueryInfoKey", PyQueryInfoKey, METH_VARARGS, QueryInfoKey_doc}, - {"SaveKey", PySaveKey, METH_VARARGS, SaveKey_doc}, - {"SetValue", PySetValue, METH_VARARGS, SetValue_doc}, - {"SetValueEx", PySetValueEx, METH_VARARGS, SetValueEx_doc}, - NULL, -}; - -static void -insint(PyObject * d, char * name, long value) -{ - PyObject *v = PyInt_FromLong(value); - if (!v || PyDict_SetItemString(d, name, v)) - PyErr_Clear(); - Py_XDECREF(v); -} - -#define ADD_INT(val) insint(d, #val, val) - -static void -inskey(PyObject * d, char * name, HKEY key) -{ - PyObject *v = PyLong_FromVoidPtr(key); - if (!v || PyDict_SetItemString(d, name, v)) - PyErr_Clear(); - Py_XDECREF(v); -} - -#define ADD_KEY(val) inskey(d, #val, val) - -PyMODINIT_FUNC init_winreg(void) -{ - PyObject *m, *d; - m = Py_InitModule3("_winreg", winreg_methods, module_doc); - d = PyModule_GetDict(m); - PyHKEY_Type.ob_type = &PyType_Type; - PyHKEY_Type.tp_doc = PyHKEY_doc; - Py_INCREF(&PyHKEY_Type); - if (PyDict_SetItemString(d, "HKEYType", - (PyObject *)&PyHKEY_Type) != 0) - return; - Py_INCREF(PyExc_WindowsError); - if (PyDict_SetItemString(d, "error", - PyExc_WindowsError) != 0) - return; - - /* Add the relevant constants */ - ADD_KEY(HKEY_CLASSES_ROOT); - ADD_KEY(HKEY_CURRENT_USER); - ADD_KEY(HKEY_LOCAL_MACHINE); - ADD_KEY(HKEY_USERS); - ADD_KEY(HKEY_PERFORMANCE_DATA); -#ifdef HKEY_CURRENT_CONFIG - ADD_KEY(HKEY_CURRENT_CONFIG); -#endif -#ifdef HKEY_DYN_DATA - ADD_KEY(HKEY_DYN_DATA); -#endif - ADD_INT(KEY_QUERY_VALUE); - ADD_INT(KEY_SET_VALUE); - ADD_INT(KEY_CREATE_SUB_KEY); - ADD_INT(KEY_ENUMERATE_SUB_KEYS); - ADD_INT(KEY_NOTIFY); - ADD_INT(KEY_CREATE_LINK); - ADD_INT(KEY_READ); - ADD_INT(KEY_WRITE); - ADD_INT(KEY_EXECUTE); - ADD_INT(KEY_ALL_ACCESS); - ADD_INT(REG_OPTION_RESERVED); - ADD_INT(REG_OPTION_NON_VOLATILE); - ADD_INT(REG_OPTION_VOLATILE); - ADD_INT(REG_OPTION_CREATE_LINK); - ADD_INT(REG_OPTION_BACKUP_RESTORE); - ADD_INT(REG_OPTION_OPEN_LINK); - ADD_INT(REG_LEGAL_OPTION); - ADD_INT(REG_CREATED_NEW_KEY); - ADD_INT(REG_OPENED_EXISTING_KEY); - ADD_INT(REG_WHOLE_HIVE_VOLATILE); - ADD_INT(REG_REFRESH_HIVE); - ADD_INT(REG_NO_LAZY_FLUSH); - ADD_INT(REG_NOTIFY_CHANGE_NAME); - ADD_INT(REG_NOTIFY_CHANGE_ATTRIBUTES); - ADD_INT(REG_NOTIFY_CHANGE_LAST_SET); - ADD_INT(REG_NOTIFY_CHANGE_SECURITY); - ADD_INT(REG_LEGAL_CHANGE_FILTER); - ADD_INT(REG_NONE); - ADD_INT(REG_SZ); - ADD_INT(REG_EXPAND_SZ); - ADD_INT(REG_BINARY); - ADD_INT(REG_DWORD); - ADD_INT(REG_DWORD_LITTLE_ENDIAN); - ADD_INT(REG_DWORD_BIG_ENDIAN); - ADD_INT(REG_LINK); - ADD_INT(REG_MULTI_SZ); - ADD_INT(REG_RESOURCE_LIST); - ADD_INT(REG_FULL_RESOURCE_DESCRIPTOR); - ADD_INT(REG_RESOURCE_REQUIREMENTS_LIST); -} - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/.cvsignore b/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/.cvsignore deleted file mode 100644 index 6030df50..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -temp-debug -temp-release -wininst.ncb -wininst.plg diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/PythonPowered.bmp b/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/PythonPowered.bmp deleted file mode 100644 index dd70709da61c3014d300147201498a653d15c483..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2582 zcmdT_u}<7T5S>UVNUB9TTa?#;f|SN3-PuJTNGa}`fGGoQy5tK`{(wHsxuv5+*X0u^ zucb5HN%+t?@6C8^?;Vj)ib(NkXJ=<`_U-JxXJ?<{x1!H?*mr1O(cYuIlGm^zKi_B< zn7Xdz{{CL(^SRvJ-O26ktz2GSN|t4EaBv_=lF0u4zU=Jmh;vT1wzfp(wM@U*GUeYr z@^@+F|CaYq*Q^vBoSx+{jO)0q5A!R`Gp%0rEQeuS$3Bk;m{%ap>Y4R8*YSDv&5U{V zO;OBh3@|i5j2E2l=Pf5^M5rcdmcyP-Xw&SB@m2YtJ|hSPd5hs5^QKNDx}Lg$qZQfv zh4`w}_?}wfxZ7tnI!4-ZoTO=zkHJmaG|hYQTxZ>JkhgFVw!Rof#neTB1E3pReEU(j z80#&D>g#MARL0e-(c$O=eus#p*@^Chv*tfy+~4N{#Yn`}f!zG47x>pWSkA(a zQQ{_Ens9aE9ZgOQ&jB^BFajR@<7&K7-{9ih?V?K77Z-)rcMdDj72=!)_LY<8@bnBD z)FVAxASHUjcFt+CjyGfhdS_9AJHvhIT^7Ru5G_tSSgUVIDi}v{as*AevjlZ~9DK<> zubn5!Sj<+QlW=C&4W2?VMGKrcoxGryjlftvo zUM)Rkt8u8~W>0@DUbCuU8Cx6MaWlv>1yb@*0B{tmK_Y65I-9!-@=Sqs1+nLLPpUeq zKs9nWZn+ucnF7HfZRdnP-YO9pq3yJ(Z9Pt{qwxvb$G{| diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/README.txt b/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/README.txt deleted file mode 100644 index 3571d2b1..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/README.txt +++ /dev/null @@ -1,5 +0,0 @@ - -XXX Write description -XXX Dont't forget to mention upx - -XXX Add pointer to this file into PC/README.txt diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/archive.h b/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/archive.h deleted file mode 100644 index 8b1f8639..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/archive.h +++ /dev/null @@ -1,96 +0,0 @@ -#pragma pack(1) - -/* zip-archive headers - * See: http://www.pkware.com/appnote.html - */ - -struct eof_cdir { - long tag; /* must be 0x06054b50 */ - short disknum; - short firstdisk; - short nTotalCDirThis; - short nTotalCDir; - long nBytesCDir; - long ofsCDir; - short commentlen; -}; - -struct cdir { - long tag; /* must be 0x02014b50 */ - short version_made; - short version_extract; - short gp_bitflag; - short comp_method; - short last_mod_file_time; - short last_mod_file_date; - long crc32; - long comp_size; - long uncomp_size; - short fname_length; - short extra_length; - short comment_length; - short disknum_start; - short int_file_attr; - long ext_file_attr; - long ofs_local_header; -}; - -struct fhdr { - long tag; /* must be 0x04034b50 */ - short version_needed; - short flags; - short method; - short last_mod_file_time; - short last_mod_file_date; - long crc32; - long comp_size; - long uncomp_size; - short fname_length; - short extra_length; -}; - - -struct meta_data_hdr { - int tag; - int uncomp_size; - int bitmap_size; -}; - -#pragma pack() - -/* installation scheme */ - -typedef struct tagSCHEME { - char *name; - char *prefix; -} SCHEME; - -typedef int (*NOTIFYPROC)(int code, LPSTR text, ...); - -extern BOOL -extract_file(char *dst, char *src, int method, int comp_size, - int uncomp_size, NOTIFYPROC notify); - -extern BOOL -unzip_archive(SCHEME *scheme, char *dirname, char *data, - DWORD size, NOTIFYPROC notify); - -extern char * -map_new_file(DWORD flags, char *filename, char - *pathname_part, int size, - WORD wFatDate, WORD wFatTime, - NOTIFYPROC callback); - -extern BOOL -ensure_directory (char *pathname, char *new_part, - NOTIFYPROC callback); - -/* codes for NOITIFYPROC */ -#define DIR_CREATED 1 -#define CAN_OVERWRITE 2 -#define FILE_CREATED 3 -#define ZLIB_ERROR 4 -#define SYSTEM_ERROR 5 -#define NUM_FILES 6 -#define FILE_OVERWRITTEN 7 - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/extract.c b/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/extract.c deleted file mode 100644 index abfe23ec..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/extract.c +++ /dev/null @@ -1,312 +0,0 @@ -#include - -#include "zlib.h" - -#include -#include - -#include "archive.h" - -/* Convert unix-path to dos-path */ -static void normpath(char *path) -{ - while (path && *path) { - if (*path == '/') - *path = '\\'; - ++path; - } -} - -BOOL ensure_directory(char *pathname, char *new_part, NOTIFYPROC notify) -{ - while (new_part && *new_part && (new_part = strchr(new_part, '\\'))) { - DWORD attr; - *new_part = '\0'; - attr = GetFileAttributes(pathname); - if (attr == -1) { - /* nothing found */ - if (!CreateDirectory(pathname, NULL) && notify) - notify(SYSTEM_ERROR, - "CreateDirectory (%s)", pathname); - else - notify(DIR_CREATED, pathname); - } - if (attr & FILE_ATTRIBUTE_DIRECTORY) { - ; - } else { - SetLastError(183); - if (notify) - notify(SYSTEM_ERROR, - "CreateDirectory (%s)", pathname); - } - *new_part = '\\'; - ++new_part; - } - return TRUE; -} - -/* XXX Should better explicitely specify - * uncomp_size and file_times instead of pfhdr! - */ -char *map_new_file(DWORD flags, char *filename, - char *pathname_part, int size, - WORD wFatDate, WORD wFatTime, - NOTIFYPROC notify) -{ - HANDLE hFile, hFileMapping; - char *dst; - FILETIME ft; - - try_again: - if (!flags) - flags = CREATE_NEW; - hFile = CreateFile(filename, - GENERIC_WRITE | GENERIC_READ, - 0, NULL, - flags, - FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile == INVALID_HANDLE_VALUE) { - DWORD x = GetLastError(); - switch (x) { - case ERROR_FILE_EXISTS: - if (notify && notify(CAN_OVERWRITE, filename)) - hFile = CreateFile(filename, - GENERIC_WRITE|GENERIC_READ, - 0, NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - else { - if (notify) - notify(FILE_OVERWRITTEN, filename); - return NULL; - } - break; - case ERROR_PATH_NOT_FOUND: - if (ensure_directory(filename, pathname_part, notify)) - goto try_again; - else - return FALSE; - break; - default: - SetLastError(x); - break; - } - } - if (hFile == INVALID_HANDLE_VALUE) { - if (notify) - notify (SYSTEM_ERROR, "CreateFile (%s)", filename); - return NULL; - } - - if (notify) - notify(FILE_CREATED, filename); - - DosDateTimeToFileTime(wFatDate, wFatTime, &ft); - SetFileTime(hFile, &ft, &ft, &ft); - - - if (size == 0) { - /* We cannot map a zero-length file (Also it makes - no sense */ - CloseHandle(hFile); - return NULL; - } - - hFileMapping = CreateFileMapping(hFile, - NULL, PAGE_READWRITE, 0, size, NULL); - - CloseHandle(hFile); - - if (hFileMapping == INVALID_HANDLE_VALUE) { - if (notify) - notify(SYSTEM_ERROR, - "CreateFileMapping (%s)", filename); - return NULL; - } - - dst = MapViewOfFile(hFileMapping, - FILE_MAP_WRITE, 0, 0, 0); - - CloseHandle(hFileMapping); - - if (!dst) { - if (notify) - notify(SYSTEM_ERROR, "MapViewOfFile (%s)", filename); - return NULL; - } - return dst; -} - - -BOOL -extract_file(char *dst, char *src, int method, int comp_size, - int uncomp_size, NOTIFYPROC notify) -{ - z_stream zstream; - int result; - - if (method == Z_DEFLATED) { - int x; - memset(&zstream, 0, sizeof(zstream)); - zstream.next_in = src; - zstream.avail_in = comp_size+1; - zstream.next_out = dst; - zstream.avail_out = uncomp_size; - -/* Apparently an undocumented feature of zlib: Set windowsize - to negative values to supress the gzip header and be compatible with - zip! */ - result = TRUE; - if (Z_OK != (x = inflateInit2(&zstream, -15))) { - if (notify) - notify(ZLIB_ERROR, - "inflateInit2 returns %d", x); - result = FALSE; - goto cleanup; - } - if (Z_STREAM_END != (x = inflate(&zstream, Z_FINISH))) { - if (notify) - notify(ZLIB_ERROR, - "inflate returns %d", x); - result = FALSE; - } - cleanup: - if (Z_OK != (x = inflateEnd(&zstream))) { - if (notify) - notify (ZLIB_ERROR, - "inflateEnd returns %d", x); - result = FALSE; - } - } else if (method == 0) { - memcpy(dst, src, uncomp_size); - result = TRUE; - } else - result = FALSE; - UnmapViewOfFile(dst); - return result; -} - -/* Open a zip-compatible archive and extract all files - * into the specified directory (which is assumed to exist) - */ -BOOL -unzip_archive(SCHEME *scheme, char *dirname, char *data, DWORD size, - NOTIFYPROC notify) -{ - int n; - char pathname[MAX_PATH]; - char *new_part; - - /* read the end of central directory record */ - struct eof_cdir *pe = (struct eof_cdir *)&data[size - sizeof - (struct eof_cdir)]; - - int arc_start = size - sizeof (struct eof_cdir) - pe->nBytesCDir - - pe->ofsCDir; - - /* set position to start of central directory */ - int pos = arc_start + pe->ofsCDir; - - /* make sure this is a zip file */ - if (pe->tag != 0x06054b50) - return FALSE; - - /* Loop through the central directory, reading all entries */ - for (n = 0; n < pe->nTotalCDir; ++n) { - int i; - char *fname; - char *pcomp; - char *dst; - struct cdir *pcdir; - struct fhdr *pfhdr; - - pcdir = (struct cdir *)&data[pos]; - pfhdr = (struct fhdr *)&data[pcdir->ofs_local_header + - arc_start]; - - if (pcdir->tag != 0x02014b50) - return FALSE; - if (pfhdr->tag != 0x04034b50) - return FALSE; - pos += sizeof(struct cdir); - fname = (char *)&data[pos]; /* This is not null terminated! */ - pos += pcdir->fname_length + pcdir->extra_length + - pcdir->comment_length; - - pcomp = &data[pcdir->ofs_local_header - + sizeof(struct fhdr) - + arc_start - + pfhdr->fname_length - + pfhdr->extra_length]; - - /* dirname is the Python home directory (prefix) */ - strcpy(pathname, dirname); - if (pathname[strlen(pathname)-1] != '\\') - strcat(pathname, "\\"); - new_part = &pathname[lstrlen(pathname)]; - /* we must now match the first part of the pathname - * in the archive to a component in the installation - * scheme (PURELIB, PLATLIB, HEADERS, SCRIPTS, or DATA) - * and replace this part by the one in the scheme to use - */ - for (i = 0; scheme[i].name; ++i) { - if (0 == strnicmp(scheme[i].name, fname, - strlen(scheme[i].name))) { - char *rest; - int len; - - /* length of the replaced part */ - int namelen = strlen(scheme[i].name); - - strcat(pathname, scheme[i].prefix); - - rest = fname + namelen; - len = pfhdr->fname_length - namelen; - - if ((pathname[strlen(pathname)-1] != '\\') - && (pathname[strlen(pathname)-1] != '/')) - strcat(pathname, "\\"); - /* Now that pathname ends with a separator, - * we must make sure rest does not start with - * an additional one. - */ - if ((rest[0] == '\\') || (rest[0] == '/')) { - ++rest; - --len; - } - - strncat(pathname, rest, len); - goto Done; - } - } - /* no prefix to replace found, go unchanged */ - strncat(pathname, fname, pfhdr->fname_length); - Done: - normpath(pathname); - if (pathname[strlen(pathname)-1] != '\\') { - /* - * The local file header (pfhdr) does not always - * contain the compressed and uncompressed sizes of - * the data depending on bit 3 of the flags field. So - * it seems better to use the data from the central - * directory (pcdir). - */ - dst = map_new_file(0, pathname, new_part, - pcdir->uncomp_size, - pcdir->last_mod_file_date, - pcdir->last_mod_file_time, notify); - if (dst) { - if (!extract_file(dst, pcomp, pfhdr->method, - pcdir->comp_size, - pcdir->uncomp_size, - notify)) - return FALSE; - } /* else ??? */ - } - if (notify) - notify(NUM_FILES, new_part, (int)pe->nTotalCDir, - (int)n+1); - } - return TRUE; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/install.c b/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/install.c deleted file mode 100644 index a71b738e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/install.c +++ /dev/null @@ -1,2294 +0,0 @@ -/* - * Written by Thomas Heller, May 2000 - * - * $Id: install.c,v 1.1 2002/11/22 20:39:33 theller Exp $ - */ - -/* - * Windows Installer program for distutils. - * - * (a kind of self-extracting zip-file) - * - * At runtime, the exefile has appended: - * - compressed setup-data in ini-format, containing the following sections: - * [metadata] - * author=Greg Ward - * author_email=gward@python.net - * description=Python Distribution Utilities - * licence=Python - * name=Distutils - * url=http://www.python.org/sigs/distutils-sig/ - * version=0.9pre - * - * [Setup] - * info= text to be displayed in the edit-box - * title= to be displayed by this program - * target_version = if present, python version required - * pyc_compile = if 0, do not compile py to pyc - * pyo_compile = if 0, do not compile py to pyo - * - * - a struct meta_data_hdr, describing the above - * - a zip-file, containing the modules to be installed. - * for the format see http://www.pkware.com/appnote.html - * - * What does this program do? - * - the setup-data is uncompressed and written to a temporary file. - * - setup-data is queried with GetPrivateProfile... calls - * - [metadata] - info is displayed in the dialog box - * - The registry is searched for installations of python - * - The user can select the python version to use. - * - The python-installation directory (sys.prefix) is displayed - * - When the start-button is pressed, files from the zip-archive - * are extracted to the file system. All .py filenames are stored - * in a list. - */ -/* - * Includes now an uninstaller. - */ - -/* - * To Do: - * - * display some explanation when no python version is found - * instead showing the user an empty listbox to select something from. - * - * Finish the code so that we can use other python installations - * additionaly to those found in the registry, - * and then #define USE_OTHER_PYTHON_VERSIONS - * - * - install a help-button, which will display something meaningful - * to the poor user. - * text to the user - * - should there be a possibility to display a README file - * before starting the installation (if one is present in the archive) - * - more comments about what the code does(?) - * - * - evolve this into a full blown installer (???) - */ - -#include -#include -#include -#include -#include -#include -#include "resource.h" - -#include -#include -#include -#include -#include - -#include "archive.h" - -/* Only for debugging! - static int dprintf(char *fmt, ...) - { - char Buffer[4096]; - va_list marker; - int result; - - va_start(marker, fmt); - result = wvsprintf(Buffer, fmt, marker); - OutputDebugString(Buffer); - return result; - } -*/ - -/* Bah: global variables */ -FILE *logfile; - -char modulename[MAX_PATH]; - -HWND hwndMain; -HWND hDialog; - -char *ini_file; /* Full pathname of ini-file */ -/* From ini-file */ -char info[4096]; /* [Setup] info= */ -char title[80]; /* [Setup] title=, contains package name - including version: "Distutils-1.0.1" */ -char target_version[10]; /* [Setup] target_version=, required python - version or empty string */ -char build_info[80]; /* [Setup] build_info=, distutils version - and build date */ - -char meta_name[80]; /* package name without version like - 'Distutils' */ -char install_script[MAX_PATH]; - - -int py_major, py_minor; /* Python version selected for installation */ - -char *arc_data; /* memory mapped archive */ -DWORD arc_size; /* number of bytes in archive */ -int exe_size; /* number of bytes for exe-file portion */ -char python_dir[MAX_PATH]; -char pythondll[MAX_PATH]; -BOOL pyc_compile, pyo_compile; - -BOOL success; /* Installation successfull? */ - -HANDLE hBitmap; -char *bitmap_bytes; - - -#define WM_NUMFILES WM_USER+1 -/* wParam: 0, lParam: total number of files */ -#define WM_NEXTFILE WM_USER+2 -/* wParam: number of this file */ -/* lParam: points to pathname */ - -enum { UNSPECIFIED, ALWAYS, NEVER } allow_overwrite = UNSPECIFIED; - -static BOOL notify(int code, char *fmt, ...); - -/* Note: If scheme.prefix is nonempty, it must end with a '\'! */ -/* Note: purelib must be the FIRST entry! */ -SCHEME old_scheme[] = { - { "PURELIB", "" }, - { "PLATLIB", "" }, - { "HEADERS", "" }, /* 'Include/dist_name' part already in archive */ - { "SCRIPTS", "Scripts\\" }, - { "DATA", "" }, - { NULL, NULL }, -}; - -SCHEME new_scheme[] = { - { "PURELIB", "Lib\\site-packages\\" }, - { "PLATLIB", "Lib\\site-packages\\" }, - { "HEADERS", "" }, /* 'Include/dist_name' part already in archive */ - { "SCRIPTS", "Scripts\\" }, - { "DATA", "" }, - { NULL, NULL }, -}; - -static void unescape(char *dst, char *src, unsigned size) -{ - char *eon; - char ch; - - while (src && *src && (size > 2)) { - if (*src == '\\') { - switch (*++src) { - case 'n': - ++src; - *dst++ = '\r'; - *dst++ = '\n'; - size -= 2; - break; - case 'r': - ++src; - *dst++ = '\r'; - --size; - break; - case '0': case '1': case '2': case '3': - ch = (char)strtol(src, &eon, 8); - if (ch == '\n') { - *dst++ = '\r'; - --size; - } - *dst++ = ch; - --size; - src = eon; - } - } else { - *dst++ = *src++; - --size; - } - } - *dst = '\0'; -} - -static struct tagFile { - char *path; - struct tagFile *next; -} *file_list = NULL; - -static void add_to_filelist(char *path) -{ - struct tagFile *p; - p = (struct tagFile *)malloc(sizeof(struct tagFile)); - p->path = strdup(path); - p->next = file_list; - file_list = p; -} - -static int do_compile_files(int (__cdecl * PyRun_SimpleString)(char *), - int optimize) -{ - struct tagFile *p; - int total, n; - char Buffer[MAX_PATH + 64]; - int errors = 0; - - total = 0; - p = file_list; - while (p) { - ++total; - p = p->next; - } - SendDlgItemMessage(hDialog, IDC_PROGRESS, PBM_SETRANGE, 0, - MAKELPARAM(0, total)); - SendDlgItemMessage(hDialog, IDC_PROGRESS, PBM_SETPOS, 0, 0); - - n = 0; - p = file_list; - while (p) { - ++n; - wsprintf(Buffer, - "import py_compile; py_compile.compile (r'%s')", - p->path); - if (PyRun_SimpleString(Buffer)) { - ++errors; - } - /* We send the notification even if the files could not - * be created so that the uninstaller will remove them - * in case they are created later. - */ - wsprintf(Buffer, "%s%c", p->path, optimize ? 'o' : 'c'); - notify(FILE_CREATED, Buffer); - - SendDlgItemMessage(hDialog, IDC_PROGRESS, PBM_SETPOS, n, 0); - SetDlgItemText(hDialog, IDC_INFO, p->path); - p = p->next; - } - return errors; -} - -#define DECLPROC(dll, result, name, args)\ - typedef result (*__PROC__##name) args;\ - result (*name)args = (__PROC__##name)GetProcAddress(dll, #name) - - -#define DECLVAR(dll, type, name)\ - type *name = (type*)GetProcAddress(dll, #name) - -typedef void PyObject; - - -/* - * Returns number of files which failed to compile, - * -1 if python could not be loaded at all - */ -static int compile_filelist(HINSTANCE hPython, BOOL optimize_flag) -{ - DECLPROC(hPython, void, Py_Initialize, (void)); - DECLPROC(hPython, void, Py_SetProgramName, (char *)); - DECLPROC(hPython, void, Py_Finalize, (void)); - DECLPROC(hPython, int, PyRun_SimpleString, (char *)); - DECLPROC(hPython, PyObject *, PySys_GetObject, (char *)); - DECLVAR(hPython, int, Py_OptimizeFlag); - - int errors = 0; - struct tagFile *p = file_list; - - if (!p) - return 0; - - if (!Py_Initialize || !Py_SetProgramName || !Py_Finalize) - return -1; - - if (!PyRun_SimpleString || !PySys_GetObject || !Py_OptimizeFlag) - return -1; - - *Py_OptimizeFlag = optimize_flag ? 1 : 0; - Py_SetProgramName(modulename); - Py_Initialize(); - - errors += do_compile_files(PyRun_SimpleString, optimize_flag); - Py_Finalize(); - - return errors; -} - -typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); - -struct PyMethodDef { - char *ml_name; - PyCFunction ml_meth; - int ml_flags; - char *ml_doc; -}; -typedef struct PyMethodDef PyMethodDef; - -void *(*g_Py_BuildValue)(char *, ...); -int (*g_PyArg_ParseTuple)(PyObject *, char *, ...); - -PyObject *g_PyExc_ValueError; -PyObject *g_PyExc_OSError; - -PyObject *(*g_PyErr_Format)(PyObject *, char *, ...); - -#define DEF_CSIDL(name) { name, #name } - -struct { - int nFolder; - char *name; -} csidl_names[] = { - /* Startup menu for all users. - NT only */ - DEF_CSIDL(CSIDL_COMMON_STARTMENU), - /* Startup menu. */ - DEF_CSIDL(CSIDL_STARTMENU), - -/* DEF_CSIDL(CSIDL_COMMON_APPDATA), */ -/* DEF_CSIDL(CSIDL_LOCAL_APPDATA), */ - /* Repository for application-specific data. - Needs Internet Explorer 4.0 */ - DEF_CSIDL(CSIDL_APPDATA), - - /* The desktop for all users. - NT only */ - DEF_CSIDL(CSIDL_COMMON_DESKTOPDIRECTORY), - /* The desktop. */ - DEF_CSIDL(CSIDL_DESKTOPDIRECTORY), - - /* Startup folder for all users. - NT only */ - DEF_CSIDL(CSIDL_COMMON_STARTUP), - /* Startup folder. */ - DEF_CSIDL(CSIDL_STARTUP), - - /* Programs item in the start menu for all users. - NT only */ - DEF_CSIDL(CSIDL_COMMON_PROGRAMS), - /* Program item in the user's start menu. */ - DEF_CSIDL(CSIDL_PROGRAMS), - -/* DEF_CSIDL(CSIDL_PROGRAM_FILES_COMMON), */ -/* DEF_CSIDL(CSIDL_PROGRAM_FILES), */ - - /* Virtual folder containing fonts. */ - DEF_CSIDL(CSIDL_FONTS), -}; - -#define DIM(a) (sizeof(a) / sizeof((a)[0])) - -static PyObject *FileCreated(PyObject *self, PyObject *args) -{ - char *path; - if (!g_PyArg_ParseTuple(args, "s", &path)) - return NULL; - notify(FILE_CREATED, path); - return g_Py_BuildValue(""); -} - -static PyObject *DirectoryCreated(PyObject *self, PyObject *args) -{ - char *path; - if (!g_PyArg_ParseTuple(args, "s", &path)) - return NULL; - notify(DIR_CREATED, path); - return g_Py_BuildValue(""); -} - -static PyObject *GetSpecialFolderPath(PyObject *self, PyObject *args) -{ - char *name; - char lpszPath[MAX_PATH]; - int i; - static HRESULT (WINAPI *My_SHGetSpecialFolderPath)(HWND hwnd, - LPTSTR lpszPath, - int nFolder, - BOOL fCreate); - - if (!My_SHGetSpecialFolderPath) { - HINSTANCE hLib = LoadLibrary("shell32.dll"); - if (!hLib) { - g_PyErr_Format(g_PyExc_OSError, - "function not available"); - return NULL; - } - My_SHGetSpecialFolderPath = (BOOL (WINAPI *)(HWND, LPTSTR, - int, BOOL)) - GetProcAddress(hLib, - "SHGetSpecialFolderPathA"); - } - - if (!g_PyArg_ParseTuple(args, "s", &name)) - return NULL; - - if (!My_SHGetSpecialFolderPath) { - g_PyErr_Format(g_PyExc_OSError, "function not available"); - return NULL; - } - - for (i = 0; i < DIM(csidl_names); ++i) { - if (0 == strcmpi(csidl_names[i].name, name)) { - int nFolder; - nFolder = csidl_names[i].nFolder; - if (My_SHGetSpecialFolderPath(NULL, lpszPath, - nFolder, 0)) - return g_Py_BuildValue("s", lpszPath); - else { - g_PyErr_Format(g_PyExc_OSError, - "no such folder (%s)", name); - return NULL; - } - - } - }; - g_PyErr_Format(g_PyExc_ValueError, "unknown CSIDL (%s)", name); - return NULL; -} - -static PyObject *CreateShortcut(PyObject *self, PyObject *args) -{ - char *path; /* path and filename */ - char *description; - char *filename; - - char *arguments = NULL; - char *iconpath = NULL; - int iconindex = 0; - char *workdir = NULL; - - WCHAR wszFilename[MAX_PATH]; - - IShellLink *ps1 = NULL; - IPersistFile *pPf = NULL; - - HRESULT hr; - - hr = CoInitialize(NULL); - if (FAILED(hr)) { - g_PyErr_Format(g_PyExc_OSError, - "CoInitialize failed, error 0x%x", hr); - goto error; - } - - if (!g_PyArg_ParseTuple(args, "sss|sssi", - &path, &description, &filename, - &arguments, &workdir, &iconpath, &iconindex)) - return NULL; - - hr = CoCreateInstance(&CLSID_ShellLink, - NULL, - CLSCTX_INPROC_SERVER, - &IID_IShellLink, - &ps1); - if (FAILED(hr)) { - g_PyErr_Format(g_PyExc_OSError, - "CoCreateInstance failed, error 0x%x", hr); - goto error; - } - - hr = ps1->lpVtbl->QueryInterface(ps1, &IID_IPersistFile, - (void **)&pPf); - if (FAILED(hr)) { - g_PyErr_Format(g_PyExc_OSError, - "QueryInterface(IPersistFile) error 0x%x", hr); - goto error; - } - - - hr = ps1->lpVtbl->SetPath(ps1, path); - if (FAILED(hr)) { - g_PyErr_Format(g_PyExc_OSError, - "SetPath() failed, error 0x%x", hr); - goto error; - } - - hr = ps1->lpVtbl->SetDescription(ps1, description); - if (FAILED(hr)) { - g_PyErr_Format(g_PyExc_OSError, - "SetDescription() failed, error 0x%x", hr); - goto error; - } - - if (arguments) { - hr = ps1->lpVtbl->SetArguments(ps1, arguments); - if (FAILED(hr)) { - g_PyErr_Format(g_PyExc_OSError, - "SetArguments() error 0x%x", hr); - goto error; - } - } - - if (iconpath) { - hr = ps1->lpVtbl->SetIconLocation(ps1, iconpath, iconindex); - if (FAILED(hr)) { - g_PyErr_Format(g_PyExc_OSError, - "SetIconLocation() error 0x%x", hr); - goto error; - } - } - - if (workdir) { - hr = ps1->lpVtbl->SetWorkingDirectory(ps1, workdir); - if (FAILED(hr)) { - g_PyErr_Format(g_PyExc_OSError, - "SetWorkingDirectory() error 0x%x", hr); - goto error; - } - } - - MultiByteToWideChar(CP_ACP, 0, - filename, -1, - wszFilename, MAX_PATH); - - hr = pPf->lpVtbl->Save(pPf, wszFilename, TRUE); - if (FAILED(hr)) { - g_PyErr_Format(g_PyExc_OSError, - "Save() failed, error 0x%x", hr); - goto error; - } - - pPf->lpVtbl->Release(pPf); - ps1->lpVtbl->Release(ps1); - CoUninitialize(); - return g_Py_BuildValue(""); - - error: - if (pPf) - pPf->lpVtbl->Release(pPf); - - if (ps1) - ps1->lpVtbl->Release(ps1); - - CoUninitialize(); - - return NULL; -} - -#define METH_VARARGS 0x0001 - -PyMethodDef meth[] = { - {"create_shortcut", CreateShortcut, METH_VARARGS, NULL}, - {"get_special_folder_path", GetSpecialFolderPath, METH_VARARGS, NULL}, - {"file_created", FileCreated, METH_VARARGS, NULL}, - {"directory_created", DirectoryCreated, METH_VARARGS, NULL}, -}; - -/* - * This function returns one of the following error codes: - * 1 if the Python-dll does not export the functions we need - * 2 if no install-script is specified in pathname - * 3 if the install-script file could not be opened - * the return value of PyRun_SimpleFile() otherwise, - * which is 0 if everything is ok, -1 if an exception had occurred - * in the install-script. - */ - -static int -run_installscript(HINSTANCE hPython, char *pathname, int argc, char **argv) -{ - DECLPROC(hPython, void, Py_Initialize, (void)); - DECLPROC(hPython, int, PySys_SetArgv, (int, char **)); - DECLPROC(hPython, int, PyRun_SimpleFile, (FILE *, char *)); - DECLPROC(hPython, void, Py_Finalize, (void)); - DECLPROC(hPython, PyObject *, PyImport_ImportModule, (char *)); - DECLPROC(hPython, int, PyObject_SetAttrString, - (PyObject *, char *, PyObject *)); - DECLPROC(hPython, PyObject *, PyObject_GetAttrString, - (PyObject *, char *)); - DECLPROC(hPython, PyObject *, Py_BuildValue, (char *, ...)); - DECLPROC(hPython, PyObject *, PyCFunction_New, - (PyMethodDef *, PyObject *)); - DECLPROC(hPython, int, PyArg_ParseTuple, (PyObject *, char *, ...)); - DECLPROC(hPython, PyObject *, PyErr_Format, (PyObject *, char *)); - - PyObject *mod; - - int result = 0; - FILE *fp; - - if (!Py_Initialize || !PySys_SetArgv - || !PyRun_SimpleFile || !Py_Finalize) - return 1; - - if (!PyImport_ImportModule || !PyObject_SetAttrString - || !Py_BuildValue) - return 1; - - if (!PyCFunction_New || !PyArg_ParseTuple || !PyErr_Format) - return 1; - - if (!PyObject_GetAttrString) - return 1; - - g_Py_BuildValue = Py_BuildValue; - g_PyArg_ParseTuple = PyArg_ParseTuple; - g_PyErr_Format = PyErr_Format; - - if (pathname == NULL || pathname[0] == '\0') - return 2; - - fp = fopen(pathname, "r"); - if (!fp) { - fprintf(stderr, "Could not open postinstall-script %s\n", - pathname); - return 3; - } - - SetDlgItemText(hDialog, IDC_INFO, "Running Script..."); - - Py_Initialize(); - - mod = PyImport_ImportModule("__builtin__"); - if (mod) { - int i; - - g_PyExc_ValueError = PyObject_GetAttrString(mod, - "ValueError"); - g_PyExc_OSError = PyObject_GetAttrString(mod, "OSError"); - for (i = 0; i < DIM(meth); ++i) { - PyObject_SetAttrString(mod, meth[i].ml_name, - PyCFunction_New(&meth[i], NULL)); - } - } - - PySys_SetArgv(argc, argv); - result = PyRun_SimpleFile(fp, pathname); - Py_Finalize(); - - fclose(fp); - - return result; -} - -static BOOL SystemError(int error, char *msg) -{ - char Buffer[1024]; - int n; - - if (error) { - LPVOID lpMsgBuf; - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - error, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPSTR)&lpMsgBuf, - 0, - NULL - ); - strncpy(Buffer, lpMsgBuf, sizeof(Buffer)); - LocalFree(lpMsgBuf); - } else - Buffer[0] = '\0'; - n = lstrlen(Buffer); - _snprintf(Buffer+n, sizeof(Buffer)-n, msg); - MessageBox(hwndMain, Buffer, "Runtime Error", MB_OK | MB_ICONSTOP); - return FALSE; -} - -static BOOL AskOverwrite(char *filename) -{ - int result; - again: - if (allow_overwrite == ALWAYS) - return TRUE; - if (allow_overwrite == NEVER) - return FALSE; - result = MessageBox(hDialog, - "Overwrite existing files?\n" - "\n" - "Press YES to ALWAYS overwrite existing files,\n" - "press NO to NEVER overwrite existing files.", - "Overwrite options", - MB_YESNO | MB_ICONQUESTION); - if (result == IDYES) - allow_overwrite = ALWAYS; - else if (result == IDNO) - allow_overwrite = NEVER; - goto again; -} - -static BOOL notify (int code, char *fmt, ...) -{ - char Buffer[1024]; - va_list marker; - BOOL result = TRUE; - int a, b; - char *cp; - - va_start(marker, fmt); - _vsnprintf(Buffer, sizeof(Buffer), fmt, marker); - - switch (code) { -/* Questions */ - case CAN_OVERWRITE: - result = AskOverwrite(Buffer); - break; - -/* Information notification */ - case DIR_CREATED: - if (logfile) - fprintf(logfile, "100 Made Dir: %s\n", fmt); - break; - - case FILE_CREATED: - if (logfile) - fprintf(logfile, "200 File Copy: %s\n", fmt); - goto add_to_filelist_label; - break; - - case FILE_OVERWRITTEN: - if (logfile) - fprintf(logfile, "200 File Overwrite: %s\n", fmt); - add_to_filelist_label: - if ((cp = strrchr(fmt, '.')) && (0 == strcmp (cp, ".py"))) - add_to_filelist(fmt); - break; - -/* Error Messages */ - case ZLIB_ERROR: - MessageBox(GetFocus(), Buffer, "Error", - MB_OK | MB_ICONWARNING); - break; - - case SYSTEM_ERROR: - SystemError(GetLastError(), Buffer); - break; - - case NUM_FILES: - a = va_arg(marker, int); - b = va_arg(marker, int); - SendMessage(hDialog, WM_NUMFILES, 0, MAKELPARAM(0, a)); - SendMessage(hDialog, WM_NEXTFILE, b,(LPARAM)fmt); - } - va_end(marker); - - return result; -} - -static char *MapExistingFile(char *pathname, DWORD *psize) -{ - HANDLE hFile, hFileMapping; - DWORD nSizeLow, nSizeHigh; - char *data; - - hFile = CreateFile(pathname, - GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile == INVALID_HANDLE_VALUE) - return NULL; - nSizeLow = GetFileSize(hFile, &nSizeHigh); - hFileMapping = CreateFileMapping(hFile, - NULL, PAGE_READONLY, 0, 0, NULL); - CloseHandle(hFile); - - if (hFileMapping == INVALID_HANDLE_VALUE) - return NULL; - - data = MapViewOfFile(hFileMapping, - FILE_MAP_READ, 0, 0, 0); - - CloseHandle(hFileMapping); - *psize = nSizeLow; - return data; -} - - -static void create_bitmap(HWND hwnd) -{ - BITMAPFILEHEADER *bfh; - BITMAPINFO *bi; - HDC hdc; - - if (!bitmap_bytes) - return; - - if (hBitmap) - return; - - hdc = GetDC(hwnd); - - bfh = (BITMAPFILEHEADER *)bitmap_bytes; - bi = (BITMAPINFO *)(bitmap_bytes + sizeof(BITMAPFILEHEADER)); - - hBitmap = CreateDIBitmap(hdc, - &bi->bmiHeader, - CBM_INIT, - bitmap_bytes + bfh->bfOffBits, - bi, - DIB_RGB_COLORS); - ReleaseDC(hwnd, hdc); -} - -static char *ExtractIniFile(char *data, DWORD size, int *pexe_size) -{ - /* read the end of central directory record */ - struct eof_cdir *pe = (struct eof_cdir *)&data[size - sizeof - (struct eof_cdir)]; - - int arc_start = size - sizeof (struct eof_cdir) - pe->nBytesCDir - - pe->ofsCDir; - - int ofs = arc_start - sizeof (struct meta_data_hdr); - - /* read meta_data info */ - struct meta_data_hdr *pmd = (struct meta_data_hdr *)&data[ofs]; - char *src, *dst; - char *ini_file; - char tempdir[MAX_PATH]; - - if (pe->tag != 0x06054b50) { - return NULL; - } - - if (pmd->tag != 0x1234567A || ofs < 0) { - return NULL; - } - - if (pmd->bitmap_size) { - /* Store pointer to bitmap bytes */ - bitmap_bytes = (char *)pmd - pmd->uncomp_size - pmd->bitmap_size; - } - - *pexe_size = ofs - pmd->uncomp_size - pmd->bitmap_size; - - src = ((char *)pmd) - pmd->uncomp_size; - ini_file = malloc(MAX_PATH); /* will be returned, so do not free it */ - if (!ini_file) - return NULL; - if (!GetTempPath(sizeof(tempdir), tempdir) - || !GetTempFileName(tempdir, "~du", 0, ini_file)) { - SystemError(GetLastError(), - "Could not create temporary file"); - return NULL; - } - - dst = map_new_file(CREATE_ALWAYS, ini_file, NULL, pmd->uncomp_size, - 0, 0, NULL/*notify*/); - if (!dst) - return NULL; - memcpy(dst, src, pmd->uncomp_size); - UnmapViewOfFile(dst); - return ini_file; -} - -static void PumpMessages(void) -{ - MSG msg; - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } -} - -LRESULT CALLBACK -WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - HFONT hFont; - int h; - PAINTSTRUCT ps; - switch (msg) { - case WM_PAINT: - hdc = BeginPaint(hwnd, &ps); - h = GetSystemMetrics(SM_CYSCREEN) / 10; - hFont = CreateFont(h, 0, 0, 0, 700, TRUE, - 0, 0, 0, 0, 0, 0, 0, "Times Roman"); - hFont = SelectObject(hdc, hFont); - SetBkMode(hdc, TRANSPARENT); - TextOut(hdc, 15, 15, title, strlen(title)); - SetTextColor(hdc, RGB(255, 255, 255)); - TextOut(hdc, 10, 10, title, strlen(title)); - DeleteObject(SelectObject(hdc, hFont)); - EndPaint(hwnd, &ps); - return 0; - } - return DefWindowProc(hwnd, msg, wParam, lParam); -} - -static HWND CreateBackground(char *title) -{ - WNDCLASS wc; - HWND hwnd; - char buffer[4096]; - - wc.style = CS_VREDRAW | CS_HREDRAW; - wc.lpfnWndProc = WindowProc; - wc.cbWndExtra = 0; - wc.cbClsExtra = 0; - wc.hInstance = GetModuleHandle(NULL); - wc.hIcon = NULL; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 128)); - wc.lpszMenuName = NULL; - wc.lpszClassName = "SetupWindowClass"; - - if (!RegisterClass(&wc)) - MessageBox(hwndMain, - "Could not register window class", - "Setup.exe", MB_OK); - - wsprintf(buffer, "Setup %s", title); - hwnd = CreateWindow("SetupWindowClass", - buffer, - 0, - 0, 0, - GetSystemMetrics(SM_CXFULLSCREEN), - GetSystemMetrics(SM_CYFULLSCREEN), - NULL, - NULL, - GetModuleHandle(NULL), - NULL); - ShowWindow(hwnd, SW_SHOWMAXIMIZED); - UpdateWindow(hwnd); - return hwnd; -} - -/* - * Center a window on the screen - */ -static void CenterWindow(HWND hwnd) -{ - RECT rc; - int w, h; - - GetWindowRect(hwnd, &rc); - w = GetSystemMetrics(SM_CXSCREEN); - h = GetSystemMetrics(SM_CYSCREEN); - MoveWindow(hwnd, - (w - (rc.right-rc.left))/2, - (h - (rc.bottom-rc.top))/2, - rc.right-rc.left, rc.bottom-rc.top, FALSE); -} - -#include - -BOOL CALLBACK -IntroDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - LPNMHDR lpnm; - char Buffer[4096]; - - switch (msg) { - case WM_INITDIALOG: - create_bitmap(hwnd); - if(hBitmap) - SendDlgItemMessage(hwnd, IDC_BITMAP, STM_SETIMAGE, - IMAGE_BITMAP, (LPARAM)hBitmap); - CenterWindow(GetParent(hwnd)); - wsprintf(Buffer, - "This Wizard will install %s on your computer. " - "Click Next to continue " - "or Cancel to exit the Setup Wizard.", - meta_name); - SetDlgItemText(hwnd, IDC_TITLE, Buffer); - SetDlgItemText(hwnd, IDC_INTRO_TEXT, info); - SetDlgItemText(hwnd, IDC_BUILD_INFO, build_info); - return FALSE; - - case WM_NOTIFY: - lpnm = (LPNMHDR) lParam; - - switch (lpnm->code) { - case PSN_SETACTIVE: - PropSheet_SetWizButtons(GetParent(hwnd), PSWIZB_NEXT); - break; - - case PSN_WIZNEXT: - break; - - case PSN_RESET: - break; - - default: - break; - } - } - return FALSE; -} - -#ifdef USE_OTHER_PYTHON_VERSIONS -/* These are really private variables used to communicate - * between StatusRoutine and CheckPythonExe - */ -char bound_image_dll[_MAX_PATH]; -int bound_image_major; -int bound_image_minor; - -static BOOL __stdcall StatusRoutine(IMAGEHLP_STATUS_REASON reason, - PSTR ImageName, - PSTR DllName, - ULONG Va, - ULONG Parameter) -{ - char fname[_MAX_PATH]; - int int_version; - - switch(reason) { - case BindOutOfMemory: - case BindRvaToVaFailed: - case BindNoRoomInImage: - case BindImportProcedureFailed: - break; - - case BindImportProcedure: - case BindForwarder: - case BindForwarderNOT: - case BindImageModified: - case BindExpandFileHeaders: - case BindImageComplete: - case BindSymbolsNotUpdated: - case BindMismatchedSymbols: - case BindImportModuleFailed: - break; - - case BindImportModule: - if (1 == sscanf(DllName, "python%d", &int_version)) { - SearchPath(NULL, DllName, NULL, sizeof(fname), - fname, NULL); - strcpy(bound_image_dll, fname); - bound_image_major = int_version / 10; - bound_image_minor = int_version % 10; - OutputDebugString("BOUND "); - OutputDebugString(fname); - OutputDebugString("\n"); - } - break; - } - return TRUE; -} - -/* - */ -static LPSTR get_sys_prefix(LPSTR exe, LPSTR dll) -{ - void (__cdecl * Py_Initialize)(void); - void (__cdecl * Py_SetProgramName)(char *); - void (__cdecl * Py_Finalize)(void); - void* (__cdecl * PySys_GetObject)(char *); - void (__cdecl * PySys_SetArgv)(int, char **); - char* (__cdecl * Py_GetPrefix)(void); - char* (__cdecl * Py_GetPath)(void); - HINSTANCE hPython; - LPSTR prefix = NULL; - int (__cdecl * PyRun_SimpleString)(char *); - - { - char Buffer[256]; - wsprintf(Buffer, "PYTHONHOME=%s", exe); - *strrchr(Buffer, '\\') = '\0'; -// MessageBox(GetFocus(), Buffer, "PYTHONHOME", MB_OK); - _putenv(Buffer); - _putenv("PYTHONPATH="); - } - - hPython = LoadLibrary(dll); - if (!hPython) - return NULL; - Py_Initialize = (void (*)(void))GetProcAddress - (hPython,"Py_Initialize"); - - PySys_SetArgv = (void (*)(int, char **))GetProcAddress - (hPython,"PySys_SetArgv"); - - PyRun_SimpleString = (int (*)(char *))GetProcAddress - (hPython,"PyRun_SimpleString"); - - Py_SetProgramName = (void (*)(char *))GetProcAddress - (hPython,"Py_SetProgramName"); - - PySys_GetObject = (void* (*)(char *))GetProcAddress - (hPython,"PySys_GetObject"); - - Py_GetPrefix = (char * (*)(void))GetProcAddress - (hPython,"Py_GetPrefix"); - - Py_GetPath = (char * (*)(void))GetProcAddress - (hPython,"Py_GetPath"); - - Py_Finalize = (void (*)(void))GetProcAddress(hPython, - "Py_Finalize"); - Py_SetProgramName(exe); - Py_Initialize(); - PySys_SetArgv(1, &exe); - - MessageBox(GetFocus(), Py_GetPrefix(), "PREFIX", MB_OK); - MessageBox(GetFocus(), Py_GetPath(), "PATH", MB_OK); - - Py_Finalize(); - FreeLibrary(hPython); - - return prefix; -} - -static BOOL -CheckPythonExe(LPSTR pathname, LPSTR version, int *pmajor, int *pminor) -{ - bound_image_dll[0] = '\0'; - if (!BindImageEx(BIND_NO_BOUND_IMPORTS | BIND_NO_UPDATE | BIND_ALL_IMAGES, - pathname, - NULL, - NULL, - StatusRoutine)) - return SystemError(0, "Could not bind image"); - if (bound_image_dll[0] == '\0') - return SystemError(0, "Does not seem to be a python executable"); - *pmajor = bound_image_major; - *pminor = bound_image_minor; - if (version && *version) { - char core_version[12]; - wsprintf(core_version, "%d.%d", bound_image_major, bound_image_minor); - if (strcmp(version, core_version)) - return SystemError(0, "Wrong Python version"); - } - get_sys_prefix(pathname, bound_image_dll); - return TRUE; -} - -/* - * Browse for other python versions. Insert it into the listbox specified - * by hwnd. version, if not NULL or empty, is the version required. - */ -static BOOL GetOtherPythonVersion(HWND hwnd, LPSTR version) -{ - char vers_name[_MAX_PATH + 80]; - DWORD itemindex; - OPENFILENAME of; - char pathname[_MAX_PATH]; - DWORD result; - - strcpy(pathname, "python.exe"); - - memset(&of, 0, sizeof(of)); - of.lStructSize = sizeof(OPENFILENAME); - of.hwndOwner = GetParent(hwnd); - of.hInstance = NULL; - of.lpstrFilter = "python.exe\0python.exe\0"; - of.lpstrCustomFilter = NULL; - of.nMaxCustFilter = 0; - of.nFilterIndex = 1; - of.lpstrFile = pathname; - of.nMaxFile = sizeof(pathname); - of.lpstrFileTitle = NULL; - of.nMaxFileTitle = 0; - of.lpstrInitialDir = NULL; - of.lpstrTitle = "Python executable"; - of.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; - of.lpstrDefExt = "exe"; - - result = GetOpenFileName(&of); - if (result) { - int major, minor; - if (!CheckPythonExe(pathname, version, &major, &minor)) { - return FALSE; - } - *strrchr(pathname, '\\') = '\0'; - wsprintf(vers_name, "Python Version %d.%d in %s", - major, minor, pathname); - itemindex = SendMessage(hwnd, LB_INSERTSTRING, -1, - (LPARAM)(LPSTR)vers_name); - SendMessage(hwnd, LB_SETCURSEL, itemindex, 0); - SendMessage(hwnd, LB_SETITEMDATA, itemindex, - (LPARAM)(LPSTR)strdup(pathname)); - return TRUE; - } - return FALSE; -} -#endif /* USE_OTHER_PYTHON_VERSIONS */ - - -/* - * Fill the listbox specified by hwnd with all python versions found - * in the registry. version, if not NULL or empty, is the version - * required. - */ -static BOOL GetPythonVersions(HWND hwnd, HKEY hkRoot, LPSTR version) -{ - DWORD index = 0; - char core_version[80]; - HKEY hKey; - BOOL result = TRUE; - DWORD bufsize; - - if (ERROR_SUCCESS != RegOpenKeyEx(hkRoot, - "Software\\Python\\PythonCore", - 0, KEY_READ, &hKey)) - return FALSE; - bufsize = sizeof(core_version); - while (ERROR_SUCCESS == RegEnumKeyEx(hKey, index, - core_version, &bufsize, NULL, - NULL, NULL, NULL)) { - char subkey_name[80], vers_name[80], prefix_buf[MAX_PATH+1]; - int itemindex; - DWORD value_size; - HKEY hk; - - bufsize = sizeof(core_version); - ++index; - if (version && *version && strcmp(version, core_version)) - continue; - - wsprintf(vers_name, "Python Version %s (found in registry)", - core_version); - wsprintf(subkey_name, - "Software\\Python\\PythonCore\\%s\\InstallPath", - core_version); - value_size = sizeof(subkey_name); - if (ERROR_SUCCESS == RegOpenKeyEx(hkRoot, subkey_name, 0, KEY_READ, &hk)) { - if (ERROR_SUCCESS == RegQueryValueEx(hk, NULL, NULL, NULL, prefix_buf, - &value_size)) { - itemindex = SendMessage(hwnd, LB_ADDSTRING, 0, - (LPARAM)(LPSTR)vers_name); - SendMessage(hwnd, LB_SETITEMDATA, itemindex, - (LPARAM)(LPSTR)strdup(prefix_buf)); - } - RegCloseKey(hk); - } - } - RegCloseKey(hKey); - return result; -} - -/* Return the installation scheme depending on Python version number */ -SCHEME *GetScheme(int major, int minor) -{ - if (major > 2) - return new_scheme; - else if((major == 2) && (minor >= 2)) - return new_scheme; - return old_scheme; -} - -BOOL CALLBACK -SelectPythonDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - LPNMHDR lpnm; - - switch (msg) { - case WM_INITDIALOG: - if (hBitmap) - SendDlgItemMessage(hwnd, IDC_BITMAP, STM_SETIMAGE, - IMAGE_BITMAP, (LPARAM)hBitmap); - GetPythonVersions(GetDlgItem(hwnd, IDC_VERSIONS_LIST), - HKEY_LOCAL_MACHINE, target_version); - GetPythonVersions(GetDlgItem(hwnd, IDC_VERSIONS_LIST), - HKEY_CURRENT_USER, target_version); - { /* select the last entry which is the highest python - version found */ - int count; - count = SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, - LB_GETCOUNT, 0, 0); - if (count && count != LB_ERR) - SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, LB_SETCURSEL, - count-1, 0); - - /* If a specific Python version is required, - * display a prominent notice showing this fact. - */ - if (target_version && target_version[0]) { - char buffer[4096]; - wsprintf(buffer, - "Python %s is required for this package. " - "Select installation to use:", - target_version); - SetDlgItemText(hwnd, IDC_TITLE, buffer); - } - - if (count == 0) { - char Buffer[4096]; - char *msg; - if (target_version && target_version[0]) { - wsprintf(Buffer, - "Python version %s required, which was not found" - " in the registry.", target_version); - msg = Buffer; - } else - msg = "No Python installation found in the registry."; - MessageBox(hwnd, msg, "Cannot install", - MB_OK | MB_ICONSTOP); - } - } - goto UpdateInstallDir; - break; - - case WM_COMMAND: - switch (LOWORD(wParam)) { -/* - case IDC_OTHERPYTHON: - if (GetOtherPythonVersion(GetDlgItem(hwnd, IDC_VERSIONS_LIST), - target_version)) - goto UpdateInstallDir; - break; -*/ - case IDC_VERSIONS_LIST: - switch (HIWORD(wParam)) { - int id; - char *cp; - case LBN_SELCHANGE: - UpdateInstallDir: - PropSheet_SetWizButtons(GetParent(hwnd), - PSWIZB_BACK | PSWIZB_NEXT); - id = SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, - LB_GETCURSEL, 0, 0); - if (id == LB_ERR) { - PropSheet_SetWizButtons(GetParent(hwnd), - PSWIZB_BACK); - SetDlgItemText(hwnd, IDC_PATH, ""); - SetDlgItemText(hwnd, IDC_INSTALL_PATH, ""); - strcpy(python_dir, ""); - strcpy(pythondll, ""); - } else { - char *pbuf; - int result; - PropSheet_SetWizButtons(GetParent(hwnd), - PSWIZB_BACK | PSWIZB_NEXT); - /* Get the python directory */ - cp = (LPSTR)SendDlgItemMessage(hwnd, - IDC_VERSIONS_LIST, - LB_GETITEMDATA, - id, - 0); - strcpy(python_dir, cp); - SetDlgItemText(hwnd, IDC_PATH, python_dir); - /* retrieve the python version and pythondll to use */ - result = SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, - LB_GETTEXTLEN, (WPARAM)id, 0); - pbuf = (char *)malloc(result + 1); - if (pbuf) { - /* guess the name of the python-dll */ - SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, - LB_GETTEXT, (WPARAM)id, - (LPARAM)pbuf); - result = sscanf(pbuf, "Python Version %d.%d", - &py_major, &py_minor); - if (result == 2) -#ifdef _DEBUG - wsprintf(pythondll, "c:\\python22\\PCBuild\\python%d%d_d.dll", - py_major, py_minor); -#else - wsprintf(pythondll, "python%d%d.dll", - py_major, py_minor); -#endif - free(pbuf); - } else - strcpy(pythondll, ""); - /* retrieve the scheme for this version */ - { - char install_path[_MAX_PATH]; - SCHEME *scheme = GetScheme(py_major, py_minor); - strcpy(install_path, python_dir); - if (install_path[strlen(install_path)-1] != '\\') - strcat(install_path, "\\"); - strcat(install_path, scheme[0].prefix); - SetDlgItemText(hwnd, IDC_INSTALL_PATH, install_path); - } - } - } - break; - } - return 0; - - case WM_NOTIFY: - lpnm = (LPNMHDR) lParam; - - switch (lpnm->code) { - int id; - case PSN_SETACTIVE: - id = SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, - LB_GETCURSEL, 0, 0); - if (id == LB_ERR) - PropSheet_SetWizButtons(GetParent(hwnd), - PSWIZB_BACK); - else - PropSheet_SetWizButtons(GetParent(hwnd), - PSWIZB_BACK | PSWIZB_NEXT); - break; - - case PSN_WIZNEXT: - break; - - case PSN_WIZFINISH: - break; - - case PSN_RESET: - break; - - default: - break; - } - } - return 0; -} - -static BOOL OpenLogfile(char *dir) -{ - char buffer[_MAX_PATH+1]; - time_t ltime; - struct tm *now; - long result; - HKEY hKey, hSubkey; - char subkey_name[256]; - static char KeyName[] = - "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; - DWORD disposition; - - result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - KeyName, - 0, - KEY_CREATE_SUB_KEY, - &hKey); - if (result != ERROR_SUCCESS) { - if (result == ERROR_ACCESS_DENIED) { - MessageBox(GetFocus(), - "You do not seem to have sufficient access rights\n" - "on this machine to install this software", - NULL, - MB_OK | MB_ICONSTOP); - return FALSE; - } else { - MessageBox(GetFocus(), KeyName, "Could not open key", MB_OK); - } - } - - sprintf(buffer, "%s\\%s-wininst.log", dir, meta_name); - logfile = fopen(buffer, "a"); - time(<ime); - now = localtime(<ime); - strftime(buffer, sizeof(buffer), - "*** Installation started %Y/%m/%d %H:%M ***\n", - localtime(<ime)); - fprintf(logfile, buffer); - fprintf(logfile, "Source: %s\n", modulename); - - sprintf(subkey_name, "%s-py%d.%d", meta_name, py_major, py_minor); - - result = RegCreateKeyEx(hKey, subkey_name, - 0, NULL, 0, - KEY_WRITE, - NULL, - &hSubkey, - &disposition); - - if (result != ERROR_SUCCESS) - MessageBox(GetFocus(), subkey_name, "Could not create key", MB_OK); - - RegCloseKey(hKey); - - if (disposition == REG_CREATED_NEW_KEY) - fprintf(logfile, "020 Reg DB Key: [%s]%s\n", KeyName, subkey_name); - - sprintf(buffer, "Python %d.%d %s", py_major, py_minor, title); - - result = RegSetValueEx(hSubkey, "DisplayName", - 0, - REG_SZ, - buffer, - strlen(buffer)+1); - - if (result != ERROR_SUCCESS) - MessageBox(GetFocus(), buffer, "Could not set key value", MB_OK); - - fprintf(logfile, "040 Reg DB Value: [%s\\%s]%s=%s\n", - KeyName, subkey_name, "DisplayName", buffer); - - { - FILE *fp; - sprintf(buffer, "%s\\Remove%s.exe", dir, meta_name); - fp = fopen(buffer, "wb"); - fwrite(arc_data, exe_size, 1, fp); - fclose(fp); - - sprintf(buffer, "\"%s\\Remove%s.exe\" -u \"%s\\%s-wininst.log\"", - dir, meta_name, dir, meta_name); - - result = RegSetValueEx(hSubkey, "UninstallString", - 0, - REG_SZ, - buffer, - strlen(buffer)+1); - - if (result != ERROR_SUCCESS) - MessageBox(GetFocus(), buffer, "Could not set key value", MB_OK); - - fprintf(logfile, "040 Reg DB Value: [%s\\%s]%s=%s\n", - KeyName, subkey_name, "UninstallString", buffer); - } - return TRUE; -} - -static void CloseLogfile(void) -{ - char buffer[_MAX_PATH+1]; - time_t ltime; - struct tm *now; - - time(<ime); - now = localtime(<ime); - strftime(buffer, sizeof(buffer), - "*** Installation finished %Y/%m/%d %H:%M ***\n", - localtime(<ime)); - fprintf(logfile, buffer); - if (logfile) - fclose(logfile); -} - -BOOL CALLBACK -InstallFilesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - LPNMHDR lpnm; - char Buffer[4096]; - SCHEME *scheme; - - switch (msg) { - case WM_INITDIALOG: - if (hBitmap) - SendDlgItemMessage(hwnd, IDC_BITMAP, STM_SETIMAGE, - IMAGE_BITMAP, (LPARAM)hBitmap); - wsprintf(Buffer, - "Click Next to begin the installation of %s. " - "If you want to review or change any of your " - " installation settings, click Back. " - "Click Cancel to exit the wizard.", - meta_name); - SetDlgItemText(hwnd, IDC_TITLE, Buffer); - break; - - case WM_NUMFILES: - SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0, lParam); - PumpMessages(); - return TRUE; - - case WM_NEXTFILE: - SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, wParam, - 0); - SetDlgItemText(hwnd, IDC_INFO, (LPSTR)lParam); - PumpMessages(); - return TRUE; - - case WM_NOTIFY: - lpnm = (LPNMHDR) lParam; - - switch (lpnm->code) { - case PSN_SETACTIVE: - PropSheet_SetWizButtons(GetParent(hwnd), - PSWIZB_BACK | PSWIZB_NEXT); - break; - - case PSN_WIZFINISH: - break; - - case PSN_WIZNEXT: - /* Handle a Next button click here */ - hDialog = hwnd; - - /* Make sure the installation directory name ends in a */ - /* backslash */ - if (python_dir[strlen(python_dir)-1] != '\\') - strcat(python_dir, "\\"); - /* Strip the trailing backslash again */ - python_dir[strlen(python_dir)-1] = '\0'; - - if (!OpenLogfile(python_dir)) - break; - -/* - * The scheme we have to use depends on the Python version... - if sys.version < "2.2": - WINDOWS_SCHEME = { - 'purelib': '$base', - 'platlib': '$base', - 'headers': '$base/Include/$dist_name', - 'scripts': '$base/Scripts', - 'data' : '$base', - } - else: - WINDOWS_SCHEME = { - 'purelib': '$base/Lib/site-packages', - 'platlib': '$base/Lib/site-packages', - 'headers': '$base/Include/$dist_name', - 'scripts': '$base/Scripts', - 'data' : '$base', - } -*/ - scheme = GetScheme(py_major, py_minor); - - /* Extract all files from the archive */ - SetDlgItemText(hwnd, IDC_TITLE, "Installing files..."); - success = unzip_archive(scheme, - python_dir, arc_data, - arc_size, notify); - /* Compile the py-files */ - if (pyc_compile) { - int errors; - HINSTANCE hPython; - SetDlgItemText(hwnd, IDC_TITLE, - "Compiling files to .pyc..."); - - SetDlgItemText(hDialog, IDC_INFO, "Loading python..."); - hPython = LoadLibrary(pythondll); - if (hPython) { - errors = compile_filelist(hPython, FALSE); - FreeLibrary(hPython); - } - /* Compilation errors are intentionally ignored: - * Python2.0 contains a bug which will result - * in sys.path containing garbage under certain - * circumstances, and an error message will only - * confuse the user. - */ - } - if (pyo_compile) { - int errors; - HINSTANCE hPython; - SetDlgItemText(hwnd, IDC_TITLE, - "Compiling files to .pyo..."); - - SetDlgItemText(hDialog, IDC_INFO, "Loading python..."); - hPython = LoadLibrary(pythondll); - if (hPython) { - errors = compile_filelist(hPython, TRUE); - FreeLibrary(hPython); - } - /* Errors ignored: see above */ - } - - - break; - - case PSN_RESET: - break; - - default: - break; - } - } - return 0; -} - - -BOOL CALLBACK -FinishedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - LPNMHDR lpnm; - - switch (msg) { - case WM_INITDIALOG: - if (hBitmap) - SendDlgItemMessage(hwnd, IDC_BITMAP, STM_SETIMAGE, - IMAGE_BITMAP, (LPARAM)hBitmap); - if (!success) - SetDlgItemText(hwnd, IDC_INFO, "Installation failed."); - - /* async delay: will show the dialog box completely before - the install_script is started */ - PostMessage(hwnd, WM_USER, 0, 0L); - return TRUE; - - case WM_USER: - - if (install_script && install_script[0]) { - char fname[MAX_PATH]; - char *tempname; - FILE *fp; - char buffer[4096]; - int n; - HCURSOR hCursor; - HINSTANCE hPython; - - char *argv[3] = {NULL, "-install", NULL}; - - SetDlgItemText(hwnd, IDC_TITLE, - "Please wait while running postinstall script..."); - strcpy(fname, python_dir); - strcat(fname, "\\Scripts\\"); - strcat(fname, install_script); - - if (logfile) - fprintf(logfile, "300 Run Script: [%s]%s\n", pythondll, fname); - - tempname = tmpnam(NULL); - - if (!freopen(tempname, "a", stderr)) - MessageBox(GetFocus(), "freopen stderr", NULL, MB_OK); - if (!freopen(tempname, "a", stdout)) - MessageBox(GetFocus(), "freopen stdout", NULL, MB_OK); -/* - if (0 != setvbuf(stdout, NULL, _IONBF, 0)) - MessageBox(GetFocus(), "setvbuf stdout", NULL, MB_OK); -*/ - hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); - - argv[0] = fname; - - hPython = LoadLibrary(pythondll); - if (hPython) { - int result; - result = run_installscript(hPython, fname, 2, argv); - if (-1 == result) { - fprintf(stderr, "*** run_installscript: internal error 0x%X ***\n", result); - } - FreeLibrary(hPython); - } else { - fprintf(stderr, "*** Could not load Python ***"); - } - fflush(stderr); - fflush(stdout); - - fp = fopen(tempname, "rb"); - n = fread(buffer, 1, sizeof(buffer), fp); - fclose(fp); - remove(tempname); - - buffer[n] = '\0'; - - SetDlgItemText(hwnd, IDC_INFO, buffer); - SetDlgItemText(hwnd, IDC_TITLE, - "Postinstall script finished.\n" - "Click the Finish button to exit the Setup wizard."); - - SetCursor(hCursor); - CloseLogfile(); - } - - return TRUE; - - case WM_NOTIFY: - lpnm = (LPNMHDR) lParam; - - switch (lpnm->code) { - case PSN_SETACTIVE: /* Enable the Finish button */ - PropSheet_SetWizButtons(GetParent(hwnd), PSWIZB_FINISH); - break; - - case PSN_WIZNEXT: - break; - - case PSN_WIZFINISH: - break; - - case PSN_RESET: - break; - - default: - break; - } - } - return 0; -} - -void RunWizard(HWND hwnd) -{ - PROPSHEETPAGE psp = {0}; - HPROPSHEETPAGE ahpsp[4] = {0}; - PROPSHEETHEADER psh = {0}; - - /* Display module information */ - psp.dwSize = sizeof(psp); - psp.dwFlags = PSP_DEFAULT|PSP_HIDEHEADER; - psp.hInstance = GetModuleHandle (NULL); - psp.lParam = 0; - psp.pfnDlgProc = IntroDlgProc; - psp.pszTemplate = MAKEINTRESOURCE(IDD_INTRO); - - ahpsp[0] = CreatePropertySheetPage(&psp); - - /* Select python version to use */ - psp.dwFlags = PSP_DEFAULT|PSP_HIDEHEADER; - psp.pszTemplate = MAKEINTRESOURCE(IDD_SELECTPYTHON); - psp.pfnDlgProc = SelectPythonDlgProc; - - ahpsp[1] = CreatePropertySheetPage(&psp); - - /* Install the files */ - psp.dwFlags = PSP_DEFAULT|PSP_HIDEHEADER; - psp.pszTemplate = MAKEINTRESOURCE(IDD_INSTALLFILES); - psp.pfnDlgProc = InstallFilesDlgProc; - - ahpsp[2] = CreatePropertySheetPage(&psp); - - /* Show success or failure */ - psp.dwFlags = PSP_DEFAULT|PSP_HIDEHEADER; - psp.pszTemplate = MAKEINTRESOURCE(IDD_FINISHED); - psp.pfnDlgProc = FinishedDlgProc; - - ahpsp[3] = CreatePropertySheetPage(&psp); - - /* Create the property sheet */ - psh.dwSize = sizeof(psh); - psh.hInstance = GetModuleHandle(NULL); - psh.hwndParent = hwnd; - psh.phpage = ahpsp; - psh.dwFlags = PSH_WIZARD/*97*//*|PSH_WATERMARK|PSH_HEADER*/; - psh.pszbmWatermark = NULL; - psh.pszbmHeader = NULL; - psh.nStartPage = 0; - psh.nPages = 4; - - PropertySheet(&psh); -} - -int DoInstall(void) -{ - char ini_buffer[4096]; - - /* Read installation information */ - GetPrivateProfileString("Setup", "title", "", ini_buffer, - sizeof(ini_buffer), ini_file); - unescape(title, ini_buffer, sizeof(title)); - - GetPrivateProfileString("Setup", "info", "", ini_buffer, - sizeof(ini_buffer), ini_file); - unescape(info, ini_buffer, sizeof(info)); - - GetPrivateProfileString("Setup", "build_info", "", build_info, - sizeof(build_info), ini_file); - - pyc_compile = GetPrivateProfileInt("Setup", "target_compile", 1, - ini_file); - pyo_compile = GetPrivateProfileInt("Setup", "target_optimize", 1, - ini_file); - - GetPrivateProfileString("Setup", "target_version", "", - target_version, sizeof(target_version), - ini_file); - - GetPrivateProfileString("metadata", "name", "", - meta_name, sizeof(meta_name), - ini_file); - - GetPrivateProfileString("Setup", "install_script", "", - install_script, sizeof(install_script), - ini_file); - - - hwndMain = CreateBackground(title); - - RunWizard(hwndMain); - - /* Clean up */ - UnmapViewOfFile(arc_data); - if (ini_file) - DeleteFile(ini_file); - - if (hBitmap) - DeleteObject(hBitmap); - - return 0; -} - -/*********************** uninstall section ******************************/ - -static int compare(const void *p1, const void *p2) -{ - return strcmp(*(char **)p2, *(char **)p1); -} - -/* - * Commit suicide (remove the uninstaller itself). - * - * Create a batch file to first remove the uninstaller - * (will succeed after it has finished), then the batch file itself. - * - * This technique has been demonstrated by Jeff Richter, - * MSJ 1/1996 - */ -void remove_exe(void) -{ - char exename[_MAX_PATH]; - char batname[_MAX_PATH]; - FILE *fp; - STARTUPINFO si; - PROCESS_INFORMATION pi; - - GetModuleFileName(NULL, exename, sizeof(exename)); - sprintf(batname, "%s.bat", exename); - fp = fopen(batname, "w"); - fprintf(fp, ":Repeat\n"); - fprintf(fp, "del \"%s\"\n", exename); - fprintf(fp, "if exist \"%s\" goto Repeat\n", exename); - fprintf(fp, "del \"%s\"\n", batname); - fclose(fp); - - ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); - si.dwFlags = STARTF_USESHOWWINDOW; - si.wShowWindow = SW_HIDE; - if (CreateProcess(NULL, - batname, - NULL, - NULL, - FALSE, - CREATE_SUSPENDED | IDLE_PRIORITY_CLASS, - NULL, - "\\", - &si, - &pi)) { - SetThreadPriority(pi.hThread, THREAD_PRIORITY_IDLE); - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); - SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); - CloseHandle(pi.hProcess); - ResumeThread(pi.hThread); - CloseHandle(pi.hThread); - } -} - -void DeleteRegistryKey(char *string) -{ - char *keyname; - char *subkeyname; - char *delim; - HKEY hKey; - long result; - char *line; - - line = strdup(string); /* so we can change it */ - - keyname = strchr(line, '['); - if (!keyname) - return; - ++keyname; - - subkeyname = strchr(keyname, ']'); - if (!subkeyname) - return; - *subkeyname++='\0'; - delim = strchr(subkeyname, '\n'); - if (delim) - *delim = '\0'; - - result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - keyname, - 0, - KEY_WRITE, - &hKey); - - if (result != ERROR_SUCCESS) - MessageBox(GetFocus(), string, "Could not open key", MB_OK); - else { - result = RegDeleteKey(hKey, subkeyname); - if (result != ERROR_SUCCESS) - MessageBox(GetFocus(), string, "Could not delete key", MB_OK); - RegCloseKey(hKey); - } - free(line); -} - -void DeleteRegistryValue(char *string) -{ - char *keyname; - char *valuename; - char *value; - HKEY hKey; - long result; - char *line; - - line = strdup(string); /* so we can change it */ - -/* Format is 'Reg DB Value: [key]name=value' */ - keyname = strchr(line, '['); - if (!keyname) - return; - ++keyname; - valuename = strchr(keyname, ']'); - if (!valuename) - return; - *valuename++ = '\0'; - value = strchr(valuename, '='); - if (!value) - return; - - *value++ = '\0'; - - result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - keyname, - 0, - KEY_WRITE, - &hKey); - if (result != ERROR_SUCCESS) - MessageBox(GetFocus(), string, "Could not open key", MB_OK); - else { - result = RegDeleteValue(hKey, valuename); - if (result != ERROR_SUCCESS) - MessageBox(GetFocus(), string, "Could not delete value", MB_OK); - RegCloseKey(hKey); - } - free(line); -} - -BOOL MyDeleteFile(char *line) -{ - char *pathname = strchr(line, ':'); - if (!pathname) - return FALSE; - ++pathname; - while (isspace(*pathname)) - ++pathname; - return DeleteFile(pathname); -} - -BOOL MyRemoveDirectory(char *line) -{ - char *pathname = strchr(line, ':'); - if (!pathname) - return FALSE; - ++pathname; - while (isspace(*pathname)) - ++pathname; - return RemoveDirectory(pathname); -} - -BOOL Run_RemoveScript(char *line) -{ - char *dllname; - char *scriptname; - static char lastscript[MAX_PATH]; - -/* Format is 'Run Scripts: [pythondll]scriptname' */ -/* XXX Currently, pythondll carries no path!!! */ - dllname = strchr(line, '['); - if (!dllname) - return FALSE; - ++dllname; - scriptname = strchr(dllname, ']'); - if (!scriptname) - return FALSE; - *scriptname++ = '\0'; - /* this function may be called more than one time with the same - script, only run it one time */ - if (strcmp(lastscript, scriptname)) { - HINSTANCE hPython; - char *argv[3] = {NULL, "-remove", NULL}; - char buffer[4096]; - FILE *fp; - char *tempname; - int n; - - argv[0] = scriptname; - - tempname = tmpnam(NULL); - - if (!freopen(tempname, "a", stderr)) - MessageBox(GetFocus(), "freopen stderr", NULL, MB_OK); - if (!freopen(tempname, "a", stdout)) - MessageBox(GetFocus(), "freopen stdout", NULL, MB_OK); - - hPython = LoadLibrary(dllname); - if (hPython) { - if (0x80000000 == run_installscript(hPython, scriptname, 2, argv)) - fprintf(stderr, "*** Could not load Python ***"); - FreeLibrary(hPython); - } - - fflush(stderr); - fflush(stdout); - - fp = fopen(tempname, "rb"); - n = fread(buffer, 1, sizeof(buffer), fp); - fclose(fp); - remove(tempname); - - buffer[n] = '\0'; - if (buffer[0]) - MessageBox(GetFocus(), buffer, "uninstall-script", MB_OK); - - strcpy(lastscript, scriptname); - } - return TRUE; -} - -int DoUninstall(int argc, char **argv) -{ - FILE *logfile; - char buffer[4096]; - int nLines = 0; - int i; - char *cp; - int nFiles = 0; - int nDirs = 0; - int nErrors = 0; - char **lines; - int lines_buffer_size = 10; - - if (argc != 3) { - MessageBox(NULL, - "Wrong number of args", - NULL, - MB_OK); - return 1; /* Error */ - } - if (strcmp(argv[1], "-u")) { - MessageBox(NULL, - "2. arg is not -u", - NULL, - MB_OK); - return 1; /* Error */ - } - - { - DWORD result; - HKEY hKey; - static char KeyName[] = - "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; - - result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - KeyName, - 0, - KEY_CREATE_SUB_KEY, - &hKey); - if (result == ERROR_ACCESS_DENIED) { - MessageBox(GetFocus(), - "You do not seem to have sufficient access rights\n" - "on this machine to uninstall this software", - NULL, - MB_OK | MB_ICONSTOP); - return 1; /* Error */ - } - RegCloseKey(hKey); - } - - logfile = fopen(argv[2], "r"); - if (!logfile) { - MessageBox(NULL, - "could not open logfile", - NULL, - MB_OK); - return 1; /* Error */ - } - - lines = (char **)malloc(sizeof(char *) * lines_buffer_size); - if (!lines) - return SystemError(0, "Out of memory"); - - /* Read the whole logfile, realloacting the buffer */ - while (fgets(buffer, sizeof(buffer), logfile)) { - int len = strlen(buffer); - /* remove trailing white space */ - while (isspace(buffer[len-1])) - len -= 1; - buffer[len] = '\0'; - lines[nLines++] = strdup(buffer); - if (nLines >= lines_buffer_size) { - lines_buffer_size += 10; - lines = (char **)realloc(lines, - sizeof(char *) * lines_buffer_size); - if (!lines) - return SystemError(0, "Out of memory"); - } - } - fclose(logfile); - - /* Sort all the lines, so that highest 3-digit codes are first */ - qsort(&lines[0], nLines, sizeof(char *), - compare); - - if (IDYES != MessageBox(NULL, - "Are you sure you want to remove\n" - "this package from your computer?", - "Please confirm", - MB_YESNO | MB_ICONQUESTION)) - return 0; - - cp = ""; - for (i = 0; i < nLines; ++i) { - /* Ignore duplicate lines */ - if (strcmp(cp, lines[i])) { - int ign; - cp = lines[i]; - /* Parse the lines */ - if (2 == sscanf(cp, "%d Made Dir: %s", &ign, &buffer)) { - if (MyRemoveDirectory(cp)) - ++nDirs; - else { - int code = GetLastError(); - if (code != 2 && code != 3) { /* file or path not found */ - ++nErrors; - } - } - } else if (2 == sscanf(cp, "%d File Copy: %s", &ign, &buffer)) { - if (MyDeleteFile(cp)) - ++nFiles; - else { - int code = GetLastError(); - if (code != 2 && code != 3) { /* file or path not found */ - ++nErrors; - } - } - } else if (2 == sscanf(cp, "%d File Overwrite: %s", &ign, &buffer)) { - if (MyDeleteFile(cp)) - ++nFiles; - else { - int code = GetLastError(); - if (code != 2 && code != 3) { /* file or path not found */ - ++nErrors; - } - } - } else if (2 == sscanf(cp, "%d Reg DB Key: %s", &ign, &buffer)) { - DeleteRegistryKey(cp); - } else if (2 == sscanf(cp, "%d Reg DB Value: %s", &ign, &buffer)) { - DeleteRegistryValue(cp); - } else if (2 == sscanf(cp, "%d Run Script: %s", &ign, &buffer)) { - Run_RemoveScript(cp); - } - } - } - - if (DeleteFile(argv[2])) { - ++nFiles; - } else { - ++nErrors; - SystemError(GetLastError(), argv[2]); - } - if (nErrors) - wsprintf(buffer, - "%d files and %d directories removed\n" - "%d files or directories could not be removed", - nFiles, nDirs, nErrors); - else - wsprintf(buffer, "%d files and %d directories removed", - nFiles, nDirs); - MessageBox(NULL, buffer, "Uninstall Finished!", - MB_OK | MB_ICONINFORMATION); - remove_exe(); - return 0; -} - -int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, - LPSTR lpszCmdLine, INT nCmdShow) -{ - extern int __argc; - extern char **__argv; - char *basename; - - GetModuleFileName(NULL, modulename, sizeof(modulename)); - - /* Map the executable file to memory */ - arc_data = MapExistingFile(modulename, &arc_size); - if (!arc_data) { - SystemError(GetLastError(), "Could not open archive"); - return 1; - } - - /* OK. So this program can act as installer (self-extracting - * zip-file, or as uninstaller when started with '-u logfile' - * command line flags. - * - * The installer is usually started without command line flags, - * and the uninstaller is usually started with the '-u logfile' - * flag. What to do if some innocent user double-clicks the - * exe-file? - * The following implements a defensive strategy... - */ - - /* Try to extract the configuration data into a temporary file */ - ini_file = ExtractIniFile(arc_data, arc_size, &exe_size); - - if (ini_file) - return DoInstall(); - - if (!ini_file && __argc > 1) { - return DoUninstall(__argc, __argv); - } - - - basename = strrchr(modulename, '\\'); - if (basename) - ++basename; - - /* Last guess about the purpose of this program */ - if (basename && (0 == strncmp(basename, "Remove", 6))) - SystemError(0, "This program is normally started by windows"); - else - SystemError(0, "Setup program invalid or damaged"); - return 1; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/install.rc b/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/install.rc deleted file mode 100644 index b145e336..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/install.rc +++ /dev/null @@ -1,220 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Neutral resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_BITMAP BITMAP DISCARDABLE "PythonPowered.bmp" -#endif // Neutral resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// German (Germany) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -#ifdef _WIN32 -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // German (Germany) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_INTRO DIALOGEX 0, 0, 379, 178 -STYLE WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Setup" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - LTEXT "This Wizard will install %s on your computer. Click Next to continue or Cancel to exit the Setup Wizard.", - IDC_TITLE,125,10,247,20,NOT WS_GROUP - EDITTEXT IDC_INTRO_TEXT,125,31,247,131,ES_MULTILINE | ES_READONLY | - WS_VSCROLL | WS_HSCROLL | NOT WS_TABSTOP - CONTROL 110,IDC_BITMAP,"Static",SS_BITMAP | SS_CENTERIMAGE,6,8, - 104,163,WS_EX_CLIENTEDGE - LTEXT "",IDC_BUILD_INFO,125,163,247,8 -END - -IDD_SELECTPYTHON DIALOGEX 0, 0, 379, 178 -STYLE WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Setup" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - LTEXT "Select python installation to use:",IDC_TITLE,125,10, - 247,12,NOT WS_GROUP - EDITTEXT IDC_PATH,191,136,181,14,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Python Directory:",IDC_STATIC,125,137,55,8 - LISTBOX IDC_VERSIONS_LIST,125,24,247,106,LBS_SORT | - LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - CONTROL 110,IDC_BITMAP,"Static",SS_BITMAP | SS_CENTERIMAGE,6,8, - 104,163,WS_EX_CLIENTEDGE - EDITTEXT IDC_INSTALL_PATH,191,157,181,14,ES_AUTOHSCROLL | - ES_READONLY - LTEXT "Installation Directory:",IDC_STATIC,125,158,66,8 - PUSHBUTTON "Find other ...",IDC_OTHERPYTHON,322,7,50,14,NOT - WS_VISIBLE -END - -IDD_INSTALLFILES DIALOGEX 0, 0, 379, 178 -STYLE WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Setup" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - LTEXT "Click Next to begin the installation. If you want to review or change any of your installation settings, click Back. Click Cancel to exit the Wizard.", - IDC_TITLE,125,10,246,31,NOT WS_GROUP - CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER, - 125,157,246,14 - CTEXT "Installation progress:",IDC_INFO,125,137,246,8 - CONTROL 110,IDC_BITMAP,"Static",SS_BITMAP | SS_CENTERIMAGE,6,8, - 104,163,WS_EX_CLIENTEDGE -END - -IDD_FINISHED DIALOGEX 0, 0, 379, 178 -STYLE WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Setup" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Click the Finish button to exit the Setup wizard.", - IDC_TITLE,125,10,247,31,NOT WS_GROUP - CONTROL 110,IDC_BITMAP,"Static",SS_BITMAP | SS_CENTERIMAGE,6,8, - 104,163,WS_EX_CLIENTEDGE - EDITTEXT IDC_INFO,125,40,247,131,ES_MULTILINE | ES_READONLY | - WS_VSCROLL | WS_HSCROLL | NOT WS_TABSTOP -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_INTRO, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 372 - VERTGUIDE, 125 - VERTGUIDE, 372 - TOPMARGIN, 7 - BOTTOMMARGIN, 171 - HORZGUIDE, 8 - HORZGUIDE, 31 - END - - IDD_SELECTPYTHON, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 372 - VERTGUIDE, 125 - VERTGUIDE, 372 - TOPMARGIN, 7 - BOTTOMMARGIN, 171 - HORZGUIDE, 8 - HORZGUIDE, 41 - END - - IDD_INSTALLFILES, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 372 - VERTGUIDE, 125 - VERTGUIDE, 371 - TOPMARGIN, 7 - BOTTOMMARGIN, 171 - HORZGUIDE, 8 - HORZGUIDE, 41 - END - - IDD_FINISHED, DIALOG - BEGIN - LEFTMARGIN, 6 - RIGHTMARGIN, 372 - VERTGUIDE, 125 - VERTGUIDE, 372 - TOPMARGIN, 7 - BOTTOMMARGIN, 171 - HORZGUIDE, 8 - HORZGUIDE, 41 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/resource.h b/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/resource.h deleted file mode 100644 index 709fe425..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/resource.h +++ /dev/null @@ -1,38 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by install.rc -// -#define IDD_DIALOG1 101 -#define IDB_BITMAP1 103 -#define IDD_INTRO 107 -#define IDD_SELECTPYTHON 108 -#define IDD_INSTALLFILES 109 -#define IDD_FINISHED 110 -#define IDB_BITMAP 110 -#define IDC_EDIT1 1000 -#define IDC_TITLE 1000 -#define IDC_START 1001 -#define IDC_PROGRESS 1003 -#define IDC_INFO 1004 -#define IDC_PYTHON15 1006 -#define IDC_PATH 1007 -#define IDC_PYTHON16 1008 -#define IDC_INSTALL_PATH 1008 -#define IDC_PYTHON20 1009 -#define IDC_BROWSE 1010 -#define IDC_INTRO_TEXT 1021 -#define IDC_VERSIONS_LIST 1022 -#define IDC_BUILD_INFO 1024 -#define IDC_BITMAP 1025 -#define IDC_OTHERPYTHON 1026 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 112 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1028 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/wininst.dsp b/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/wininst.dsp deleted file mode 100644 index ef92e503..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/wininst.dsp +++ /dev/null @@ -1,128 +0,0 @@ -# Microsoft Developer Studio Project File - Name="wininst" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=wininst - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "wininst.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "wininst.mak" CFG="wininst - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "wininst - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "wininst - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "wininst - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\..\lib\distutils\command" -# PROP Intermediate_Dir "temp-release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /O1 /I "..\..\Include" /I "..\..\..\zlib-1.1.4" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x407 /d "NDEBUG" -# ADD RSC /l 0x407 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 ..\..\..\zlib-1.1.4\zlib.lib imagehlp.lib comdlg32.lib ole32.lib comctl32.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"LIBC" -# Begin Special Build Tool -TargetPath=\sf\python\dist\src\lib\distutils\command\wininst.exe -SOURCE="$(InputPath)" -PostBuild_Cmds=upx.exe --best $(TARGETPATH) || echo "wininst.exe not compressed" -# End Special Build Tool - -!ELSEIF "$(CFG)" == "wininst - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "temp-debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MD /W3 /Z7 /Od /I "..\..\Include" /I "..\..\..\zlib-1.1.4" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x407 /d "_DEBUG" -# ADD RSC /l 0x407 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ..\..\..\zlib-1.1.4\zlib.lib imagehlp.lib comdlg32.lib ole32.lib comctl32.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /pdb:none /debug /machine:I386 /nodefaultlib:"LIBC" /out:"./wininst_d.exe" - -!ENDIF - -# Begin Target - -# Name "wininst - Win32 Release" -# Name "wininst - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\extract.c -# End Source File -# Begin Source File - -SOURCE=.\install.c -# End Source File -# Begin Source File - -SOURCE=.\install.rc -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\archive.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# Begin Source File - -SOURCE=.\PythonPowered.bmp -# End Source File -# End Group -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/wininst.dsw b/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/wininst.dsw deleted file mode 100644 index fbc66aa9..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/bdist_wininst/wininst.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "wininst"=.\wininst.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/config.c b/SDKs/XPlatform/Cypython-2.3.3/PC/config.c deleted file mode 100644 index ca86e7b2..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/config.c +++ /dev/null @@ -1,127 +0,0 @@ -/* Module configuration */ - -/* This file contains the table of built-in modules. - See init_builtin() in import.c. */ - -#include "Python.h" - -extern void initarray(void); -#ifndef MS_WIN64 -extern void initaudioop(void); -#endif -extern void initbinascii(void); -extern void initcmath(void); -extern void initerrno(void); -extern void initgc(void); -#ifndef MS_WIN64 -extern void initimageop(void); -#endif -extern void initmath(void); -extern void initmd5(void); -extern void initnt(void); -extern void initoperator(void); -extern void initregex(void); -#ifndef MS_WIN64 -extern void initrgbimg(void); -#endif -extern void initrotor(void); -extern void initsignal(void); -extern void initsha(void); -extern void initstrop(void); -extern void initstruct(void); -extern void inittime(void); -extern void initthread(void); -extern void initcStringIO(void); -extern void initcPickle(void); -extern void initpcre(void); -#ifdef WIN32 -extern void initmsvcrt(void); -extern void init_locale(void); -#endif -extern void init_codecs(void); -extern void initxreadlines(void); -extern void init_weakref(void); -extern void init_hotshot(void); -extern void initxxsubtype(void); -extern void initzipimport(void); -extern void init_random(void); -extern void inititertools(void); - -/* tools/freeze/makeconfig.py marker for additional "extern" */ -/* -- ADDMODULE MARKER 1 -- */ - -extern void init_sre(void); - -extern void PyMarshal_Init(void); -extern void initimp(void); - -struct _inittab _PyImport_Inittab[] = { - - {"array", initarray}, -#ifdef MS_WINDOWS -#ifndef MS_WIN64 - {"audioop", initaudioop}, -#endif -#endif - {"binascii", initbinascii}, - {"cmath", initcmath}, - {"errno", initerrno}, - {"gc", initgc}, -#ifndef MS_WIN64 - {"imageop", initimageop}, -#endif - {"math", initmath}, - {"md5", initmd5}, - {"nt", initnt}, /* Use the NT os functions, not posix */ - {"operator", initoperator}, - {"regex", initregex}, -#ifndef MS_WIN64 - {"rgbimg", initrgbimg}, -#endif - {"rotor", initrotor}, - {"signal", initsignal}, - {"sha", initsha}, - {"strop", initstrop}, - {"struct", initstruct}, - {"time", inittime}, -#ifdef WITH_THREAD - {"thread", initthread}, -#endif - {"cStringIO", initcStringIO}, - {"cPickle", initcPickle}, - {"pcre", initpcre}, -#ifdef WIN32 - {"msvcrt", initmsvcrt}, - {"_locale", init_locale}, -#endif - - {"_codecs", init_codecs}, - {"xreadlines", initxreadlines}, - {"_weakref", init_weakref}, - {"_hotshot", init_hotshot}, - {"_random", init_random}, - {"itertools", inititertools}, - - {"xxsubtype", initxxsubtype}, - {"zipimport", initzipimport}, - -/* tools/freeze/makeconfig.py marker for additional "_inittab" entries */ -/* -- ADDMODULE MARKER 2 -- */ - - {"_sre", init_sre}, - - /* This module "lives in" with marshal.c */ - {"marshal", PyMarshal_Init}, - - /* This lives it with import.c */ - {"imp", initimp}, - - /* These entries are here for sys.builtin_module_names */ - {"__main__", NULL}, - {"__builtin__", NULL}, - {"sys", NULL}, - {"exceptions", NULL}, - - /* Sentinel */ - {0, 0} -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/dl_nt.c b/SDKs/XPlatform/Cypython-2.3.3/PC/dl_nt.c deleted file mode 100644 index c688938a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/dl_nt.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - -Entry point for the Windows NT DLL. - -About the only reason for having this, is so initall() can automatically -be called, removing that burden (and possible source of frustration if -forgotten) from the programmer. - -*/ -/* NT and Python share these */ -#include "pyconfig.h" -#include "Python.h" - -#ifndef MS_XBOX -#include "windows.h" -#else -#include -#endif - -char dllVersionBuffer[16] = ""; // a private buffer - -// Python Globals -HMODULE PyWin_DLLhModule = NULL; -const char *PyWin_DLLVersionString = dllVersionBuffer; - -#if 0 // Static linking makes this not necessary -BOOL WINAPI DllMain (HANDLE hInst, - ULONG ul_reason_for_call, - LPVOID lpReserved) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - PyWin_DLLhModule = hInst; - // 1000 is a magic number I picked out of the air. Could do with a #define, I spose... - LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer)); - //initall(); - break; - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} -#endif /* 0 */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/dllbase_nt.txt b/SDKs/XPlatform/Cypython-2.3.3/PC/dllbase_nt.txt deleted file mode 100644 index 4220b28e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/dllbase_nt.txt +++ /dev/null @@ -1,76 +0,0 @@ -In Win32, DLL's are "pre-linked" using a specified base address. -When the DLL is loaded, an attempt is made to place it at -that address. If that address is already in use, a new base address -is selected, and the DLL subject to fixups. Apparently, these -fixups are very slow, and significant performance gains can be -made by selecting a good base address. - -This document is to allocate base addresses to core Python -and Python .PYD files, to give a better change of optimal performance. -This base address is passed to the linker using the /BASE -command line switch. - - -Python.exe/Pythonw.exe - 1d000000 - 1e000000 (-1) -Python.dll - 1e000000 - 1e100000 (-1) - -Standard Extension Modules 1e100000 - 1e200000 "" - - _symtable 1e100000 - 1e110000 - - bsddb 1e180000 - 1e188000 "" - - _tkinter 1e190000 - 1e1A0000 - - parser 1e1A0000 - 1e1B0000 - - zlib 1e1B0000 - 1e1C0000 - - winreg 1e1C0000 - 1e1D0000 - - _socket 1e1D0000 - 1e1E0000 - - _sre 1e1E0000 - 1e1F0000 - - mmap 1e1F0000 - 1e1FFFFF - -More standard extensions 1D100000 - 1e000000 - - pyexpat 1D100000 - 1D110000 - - select 1D110000 - 1D120000 - - unicodedata 1D120000 - 1D160000 - - winsound 1D160000 - 1D170000 - - bZ2 1D170000 - 1D180000 - - datetime 1D180000 - 1D190000 - - _csv 1D190000 - 1D1A0000 - -Other extension modules - - win32api 1e200000 - 1e220000 - - win32ras 1e220000 - 1e230000 - - win32lz 1e230000 - 1e240000 - - timer 1e240000 - 1e250000 - - mmapfile 1e250000 - 1e260000 - - win32pipe 1e260000 - 1e270000 - - avl 1e270000 - 1e270000 - - dbhash 1e280000 - 1e290000 - - win32net 1e290000 - 1e2A0000 - - win32security 1e2A0000 - 1e2B0000 - - win32print 1e2B0000 - 1e2c0000 - - 1e2d0000 - 1e2e0000 - - win32gui 1e2e0000 - 1e2f0000 - - _imaging 1e2f0000 - 1e300000 - - multiarray 1e300000 - 1e310000 - - win32help 1e310000 - 1e320000 - - win32clipboard 1e320000 - 1e330000 - - win2kras 1e330000 - 1e340000 - - pythoncom 1e340000 - 1e400000 - - win32ui 1e400000 - 1e500000 - - win32uiole 1e500000 - 1e600000 - - pywintypes 1e600000 - 1e700000 - - win32process 1e700000 - 1e800000 - - odbc 1e710000 - 1e720000 - - dbi 1e720000 - 1e730000 - - win32file 1e730000 - 1e740000 - - win32wnet 1e740000 - 1e750000 - - win32com.shell 1e750000 - 1e760000 - - win32com.internet 1e760000 - 1e770000 - - win32com.exchange 1e770000 - 1e780000 - - win32com.exchdapi 1e780000 - 1e790000 - - win32com.axscript 1e790000 - 1e7a0000 - - win32com.axdebug 1e7b0000 - 1e7c0000 - - win32com.adsi 1e7f0000 - 1e800000 - - win32event 1e810000 - 1e820000 - - win32evtlog 1e820000 - 1e830000 - - win32com.axcontrol 1e830000 - 1e840000 - - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/.cvsignore b/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/.cvsignore deleted file mode 100644 index ca624eac..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -? example.ncb -? release -? debug -? .c -? example.mdp diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.c b/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.c deleted file mode 100644 index 6cff0ae2..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "Python.h" - -static PyObject * -ex_foo(PyObject *self, PyObject *args) -{ - printf("Hello, world\n"); - Py_INCREF(Py_None); - return Py_None; -} - -static PyMethodDef example_methods[] = { - {"foo", ex_foo, 1, "foo() doc string"}, - {NULL, NULL} -}; - -void -initexample(void) -{ - Py_InitModule("example", example_methods); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.def b/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.def deleted file mode 100644 index 1dce3522..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.def +++ /dev/null @@ -1,2 +0,0 @@ -EXPORTS - initexample diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.dsp b/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.dsp deleted file mode 100644 index 13ae887b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.dsp +++ /dev/null @@ -1,117 +0,0 @@ -# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=example - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "example.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "example - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir ".\Release" -# PROP BASE Intermediate_Dir ".\Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir ".\Release" -# PROP Intermediate_Dir ".\Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\Include" /I "..\PC" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib python22.lib /nologo /subsystem:windows /dll /machine:I386 /libpath:"..\PCbuild" /export:initexample -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "example - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir ".\Debug" -# PROP BASE Intermediate_Dir ".\Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir ".\Debug" -# PROP Intermediate_Dir ".\Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\Include" /I "..\PC" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib python22_d.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:".\Debug/example_d.dll" /libpath:"..\PCbuild" /export:initexample -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "example - Win32 Release" -# Name "example - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90" -# Begin Source File - -SOURCE=.\example.c -# End Source File -# Begin Source File - -SOURCE=.\example.def -# End Source File -# Begin Source File - -SOURCE=.\readme.txt -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.dsw b/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.dsw deleted file mode 100644 index 8ddad803..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/example.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "example"=.\example.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/readme.txt b/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/readme.txt deleted file mode 100644 index aa2b3091..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/example_nt/readme.txt +++ /dev/null @@ -1,165 +0,0 @@ -Example Python extension for Windows NT -======================================= - -This directory contains everything needed (except for the Python -distribution!) to build a Python extension module using Microsoft VC++ -("Developer Studio") version 6. It has been tested with VC++ 6.0 on Python -2.2c1. You can also use earlier versions of VC to build Python extensions, -but the sample VC project file (example.dsw in this directory) is in VC 6 -format. - -COPY THIS DIRECTORY! --------------------- -This "example_nt" directory is a subdirectory of the PC directory, in order -to keep all the PC-specific files under the same directory. However, the -example_nt directory can't actually be used from this location. You first -need to copy or move it up one level, so that example_nt is a direct -sibling of the PC\ and Include\ directories. Do all your work from within -this new location -- sorry, but you'll be sorry if you don't. - -OPEN THE PROJECT ----------------- -From VC 6.x, use the - File -> Open Workspace... -dialog (*not* the "File -> Open..." dialog!). Navigate to and select the -file "example.dsw", in the *copy* of the example_nt directory you made -above. -Click Open. - -BUILD THE EXAMPLE DLL ---------------------- -In order to check that everything is set up right, try building: - -1. Select a configuration. This step is optional. Do - Build -> Select Active Configuration... - and select either "example - Win32 Release" or "example - Win32 Debug". - If you skip this step, you'll use the Debug configuration by default. - -2. Build the DLL. Do - Build -> Build example_d.dll - in Debug mode, or - Build -> Build example.dll - in Release mode. - This creates all intermediate and result files in a subdirectory which - is called either Debug or Release, depending on which configuration you - picked in the preceding step. - -TESTING THE DEBUG-MODE DLL --------------------------- -Once the Debug build has succeeded, bring up a DOS box, and cd to -example_nt\Debug. You should now be able to repeat the following session -("C>" is the DOS prompt, ">>>" is the Python prompt) (note that various -debug output from Python may not match this screen dump exactly): - - C>..\..\PCbuild\python_d - Adding parser accelerators ... - Done. - Python 2.2c1+ (#28, Dec 14 2001, 18:06:39) [MSC 32 bit (Intel)] on win32 - Type "help", "copyright", "credits" or "license" for more information. - >>> import example - [7052 refs] - >>> example.foo() - Hello, world - [7052 refs] - >>> - -TESTING THE RELEASE-MODE DLL ----------------------------- -Once the Release build has succeeded, bring up a DOS box, and cd to -example_nt\Release. You should now be able to repeat the following session -("C>" is the DOS prompt, ">>>" is the Python prompt): - - C>..\..\PCbuild\python - Python 2.2c1+ (#28, Dec 14 2001, 18:06:04) [MSC 32 bit (Intel)] on win32 - Type "help", "copyright", "credits" or "license" for more information. - >>> import example - >>> example.foo() - Hello, world - >>> - -Congratulations! You've successfully built your first Python extension -module. - -CREATING YOUR OWN PROJECT -------------------------- -Choose a name ("spam" is always a winner :-) and create a directory for -it. Copy your C sources into it. Note that the module source file name -does not necessarily have to match the module name, but the "init" function -name should match the module name -- i.e. you can only import a module -"spam" if its init function is called "initspam()", and it should call -Py_InitModule with the string "spam" as its first argument (use the minimal -example.c in this directory as a guide). By convention, it lives in a file -called "spam.c" or "spammodule.c". The output file should be called -"spam.dll" or "spam.pyd" (the latter is supported to avoid confusion with a -system library "spam.dll" to which your module could be a Python interface) -in Release mode, or spam_d.dll or spam_d.pyd in Debug mode. - -Now your options are: - -1) Copy example.dsw and example.dsp, rename them to spam.*, and edit them -by hand. - -or - -2) Create a brand new project; instructions are below. - -In either case, copy example_nt\example.def to spam\spam.def, and edit the -new spam.def so its second line contains the string "initspam". If you -created a new project yourself, add the file spam.def to the project now. -(This is an annoying little file with only two lines. An alternative -approach is to forget about the .def file, and add the option -"/export:initspam" somewhere to the Link settings, by manually editing the -"Project Options" box). - -You are now all set to build your extension, unless it requires other -external libraries, include files, etc. See Python's Extending and -Embedding manual for instructions on how to write an extension. - - -CREATING A BRAND NEW PROJECT ----------------------------- -Use the - File -> New... -> Projects -dialog to create a new Project Workspace. Select "Win32 Dynamic-Link -Library", enter the name ("spam"), and make sure the "Location" is set to -the spam directory you have created (which should be a direct subdirectory -of the Python build tree, a sibling of Include and PC). Select Win32 as the -platform (in my version, this is the only choice). Make sure the "Create -new workspace" radio button is selected. Click OK. - -Now open the - Project -> Settings... -dialog. (Impressive, isn't it? :-) You only need to change a few -settings. Make sure "All Configurations" is selected from the "Settings -for:" dropdown list. Select the "C/C++" tab. Choose the "Preprocessor" -category in the popup menu at the top. Type the following text in the -entry box labeled "Addditional include directories:" - - ..\Include,..\PC - -Then, choose the "Input" category in the Link tab, and enter - ..\PCbuild -in the "Additional library path:" box. - -Now you need to add some mode-specific settings: - -Select "Win32 Release" in the "Settings for:" dropdown list. Click the -"Link" tab, choose the "Input" Category, and append "python22.lib" to the -list in the "Object/library modules:" box. - -Select "Win32 Debug" in the "Settings for:" dropdown list, and append -"python22_d.lib" to the list in the "Object/library modules:" box. Then -click on the C/C++ tab, select "Code Generation" from the "Category:" -dropdown list, and select "Debug Multithreaded DLL" from the "Use run-time -library:" dropdown list. - -Select "Win32 Release" again from the "Settings for:" dropdown list. -Select "Multithreaded DLL" from the "Use run-time library:" dropdown list. - -That's all . - -You should now create the file spam.def as instructed in the previous -section. Then chose the - Insert -> Files into Project... -dialog. Set the pattern to *.* and select both spam.c and spam.def and -click OK. (Inserting them one by one is fine too.) diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/frozen_dllmain.c b/SDKs/XPlatform/Cypython-2.3.3/PC/frozen_dllmain.c deleted file mode 100644 index f99b0061..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/frozen_dllmain.c +++ /dev/null @@ -1,134 +0,0 @@ -/* FreezeDLLMain.cpp - -This is a DLLMain suitable for frozen applications/DLLs on -a Windows platform. - -The general problem is that many Python extension modules may define -DLL main functions, but when statically linked together to form -a frozen application, this DLLMain symbol exists multiple times. - -The solution is: -* Each module checks for a frozen build, and if so, defines its DLLMain - function as "__declspec(dllexport) DllMain%module%" - (eg, DllMainpythoncom, or DllMainpywintypes) - -* The frozen .EXE/.DLL links against this module, which provides - the single DllMain. - -* This DllMain attempts to locate and call the DllMain for each - of the extension modules. - -* This code also has hooks to "simulate" DllMain when used from - a frozen .EXE. - -At this stage, there is a static table of "possibly embedded modules". -This should change to something better, but it will work OK for now. - -Note that this scheme does not handle dependencies in the order -of DllMain calls - except it does call pywintypes first :-) - -As an example of how an extension module with a DllMain should be -changed, here is a snippet from the pythoncom extension module. - - // end of example code from pythoncom's DllMain.cpp - #ifndef BUILD_FREEZE - #define DLLMAIN DllMain - #define DLLMAIN_DECL - #else - #define DLLMAIN DllMainpythoncom - #define DLLMAIN_DECL __declspec(dllexport) - #endif - - extern "C" DLLMAIN_DECL - BOOL WINAPI DLLMAIN(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) - // end of example code from pythoncom's DllMain.cpp - -***************************************************************************/ -#include "windows.h" - -static char *possibleModules[] = { - "pywintypes", - "pythoncom", - "win32ui", - NULL, -}; - -BOOL CallModuleDllMain(char *modName, DWORD dwReason); - - -/* - Called by a frozen .EXE only, so that built-in extension - modules are initialized correctly -*/ -void PyWinFreeze_ExeInit(void) -{ - char **modName; - for (modName = possibleModules;*modName;*modName++) { -/* printf("Initialising '%s'\n", *modName); */ - CallModuleDllMain(*modName, DLL_PROCESS_ATTACH); - } -} - -/* - Called by a frozen .EXE only, so that built-in extension - modules are cleaned up -*/ -void PyWinFreeze_ExeTerm(void) -{ - // Must go backwards - char **modName; - for (modName = possibleModules+(sizeof(possibleModules) / sizeof(char *))-2; - modName >= possibleModules; - *modName--) { -/* printf("Terminating '%s'\n", *modName);*/ - CallModuleDllMain(*modName, DLL_PROCESS_DETACH); - } -} - -BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) -{ - BOOL ret = TRUE; - switch (dwReason) { - case DLL_PROCESS_ATTACH: - { - char **modName; - for (modName = possibleModules;*modName;*modName++) { - BOOL ok = CallModuleDllMain(*modName, dwReason); - if (!ok) - ret = FALSE; - } - break; - } - case DLL_PROCESS_DETACH: - { - // Must go backwards - char **modName; - for (modName = possibleModules+(sizeof(possibleModules) / sizeof(char *))-2; - modName >= possibleModules; - *modName--) - CallModuleDllMain(*modName, DLL_PROCESS_DETACH); - break; - } - } - return ret; -} - -BOOL CallModuleDllMain(char *modName, DWORD dwReason) -{ - BOOL (WINAPI * pfndllmain)(HINSTANCE, DWORD, LPVOID); - - char funcName[255]; - HMODULE hmod = GetModuleHandle(NULL); - strcpy(funcName, "_DllMain"); - strcat(funcName, modName); - strcat(funcName, "@12"); // stdcall convention. - pfndllmain = (BOOL (WINAPI *)(HINSTANCE, DWORD, LPVOID))GetProcAddress(hmod, funcName); - if (pfndllmain==NULL) { - /* No function by that name exported - then that module does - not appear in our frozen program - return OK - */ - return TRUE; - } - return (*pfndllmain)(hmod, dwReason, NULL); -} - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/getpathp.c b/SDKs/XPlatform/Cypython-2.3.3/PC/getpathp.c deleted file mode 100644 index 9ecce810..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/getpathp.c +++ /dev/null @@ -1,686 +0,0 @@ - -/* Return the initial module search path. */ -/* Used by DOS, OS/2, Windows 3.1, Windows 95/98, Windows NT. */ - -/* ---------------------------------------------------------------- - PATH RULES FOR WINDOWS: - This describes how sys.path is formed on Windows. It describes the - functionality, not the implementation (ie, the order in which these - are actually fetched is different) - - * Python always adds an empty entry at the start, which corresponds - to the current directory. - - * If the PYTHONPATH env. var. exists, it's entries are added next. - - * We look in the registry for "application paths" - that is, sub-keys - under the main PythonPath registry key. These are added next (the - order of sub-key processing is undefined). - HKEY_CURRENT_USER is searched and added first. - HKEY_LOCAL_MACHINE is searched and added next. - (Note that all known installers only use HKLM, so HKCU is typically - empty) - - * We attempt to locate the "Python Home" - if the PYTHONHOME env var - is set, we believe it. Otherwise, we use the path of our host .EXE's - to try and locate our "landmark" (lib\\os.py) and deduce our home. - - If we DO have a Python Home: The relevant sub-directories (Lib, - plat-win, lib-tk, etc) are based on the Python Home - - If we DO NOT have a Python Home, the core Python Path is - loaded from the registry. This is the main PythonPath key, - and both HKLM and HKCU are combined to form the path) - - * Iff - we can not locate the Python Home, have not had a PYTHONPATH - specified, and can't locate any Registry entries (ie, we have _nothing_ - we can assume is a good path), a default path with relative entries is - used (eg. .\Lib;.\plat-win, etc) - - - The end result of all this is: - * When running python.exe, or any other .exe in the main Python directory - (either an installed version, or directly from the PCbuild directory), - the core path is deduced, and the core paths in the registry are - ignored. Other "application paths" in the registry are always read. - - * When Python is hosted in another exe (different directory, embedded via - COM, etc), the Python Home will not be deduced, so the core path from - the registry is used. Other "application paths" in the registry are - always read. - - * If Python can't find its home and there is no registry (eg, frozen - exe, some very strange installation setup) you get a path with - some default, but relative, paths. - - ---------------------------------------------------------------- */ - - -#include "Python.h" -#include "osdefs.h" - -#ifdef MS_WINDOWS -#ifdef MS_XBOX -#include -#else -#include -#endif -#include -#endif - -#include -#include -#include - -/* Search in some common locations for the associated Python libraries. - * - * Py_GetPath() tries to return a sensible Python module search path. - * - * The approach is an adaptation for Windows of the strategy used in - * ../Modules/getpath.c; it uses the Windows Registry as one of its - * information sources. - */ - -#ifndef LANDMARK -#define LANDMARK "lib\\os.py" -#endif - -static char prefix[MAXPATHLEN+1]; -static char progpath[MAXPATHLEN+1]; -static char dllpath[MAXPATHLEN+1]; -static char *module_search_path = NULL; - - -static int -is_sep(char ch) /* determine if "ch" is a separator character */ -{ -#ifdef ALTSEP - return ch == SEP || ch == ALTSEP; -#else - return ch == SEP; -#endif -} - -/* assumes 'dir' null terminated in bounds. Never writes - beyond existing terminator. -*/ -static void -reduce(char *dir) -{ - size_t i = strlen(dir); - while (i > 0 && !is_sep(dir[i])) - --i; - dir[i] = '\0'; -} - - -static int -exists(char *filename) -{ - struct stat buf; - return stat(filename, &buf) == 0; -} - -/* Assumes 'filename' MAXPATHLEN+1 bytes long - - may extend 'filename' by one character. -*/ -static int -ismodule(char *filename) /* Is module -- check for .pyc/.pyo too */ -{ - if (exists(filename)) - return 1; - - /* Check for the compiled version of prefix. */ - if (strlen(filename) < MAXPATHLEN) { - strcat(filename, Py_OptimizeFlag ? "o" : "c"); - if (exists(filename)) - return 1; - } - return 0; -} - -/* guarantees buffer will never overflow MAXPATHLEN+1 bytes */ -static void -join(char *buffer, char *stuff) -{ - size_t n, k; - if (is_sep(stuff[0])) - n = 0; - else { - n = strlen(buffer); - if (n > 0 && !is_sep(buffer[n-1]) && n < MAXPATHLEN) - buffer[n++] = SEP; - } - k = strlen(stuff); - if (n + k > MAXPATHLEN) - k = MAXPATHLEN - n; - strncpy(buffer+n, stuff, k); - buffer[n+k] = '\0'; -} - -/* gotlandmark only called by search_for_prefix, which ensures - 'prefix' is null terminated in bounds. join() ensures - 'landmark' can not overflow prefix if too long. -*/ -static int -gotlandmark(char *landmark) -{ - int n, ok; - - n = strlen(prefix); - join(prefix, landmark); - ok = ismodule(prefix); - prefix[n] = '\0'; - return ok; -} - -/* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd. - assumption provided by only caller, calculate_path() */ -static int -search_for_prefix(char *argv0_path, char *landmark) -{ - /* Search from argv0_path, until landmark is found */ - strcpy(prefix, argv0_path); - do { - if (gotlandmark(landmark)) - return 1; - reduce(prefix); - } while (prefix[0]); - return 0; -} - -#if defined(MS_WINDOWS) && !defined(MS_XBOX) - -/* a string loaded from the DLL at startup.*/ -extern const char *PyWin_DLLVersionString; - - -/* Load a PYTHONPATH value from the registry. - Load from either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER. - - Works in both Unicode and 8bit environments. Only uses the - Ex family of functions so it also works with Windows CE. - - Returns NULL, or a pointer that should be freed. - - XXX - this code is pretty strange, as it used to also - work on Win16, where the buffer sizes werent available - in advance. It could be simplied now Win16/Win32s is dead! -*/ - -static char * -getpythonregpath(HKEY keyBase, int skipcore) -{ - HKEY newKey = 0; - DWORD dataSize = 0; - DWORD numKeys = 0; - LONG rc; - char *retval = NULL; - TCHAR *dataBuf = NULL; - static const TCHAR keyPrefix[] = _T("Software\\Python\\PythonCore\\"); - static const TCHAR keySuffix[] = _T("\\PythonPath"); - size_t versionLen; - DWORD index; - TCHAR *keyBuf = NULL; - TCHAR *keyBufPtr; - TCHAR **ppPaths = NULL; - - /* Tried to use sysget("winver") but here is too early :-( */ - versionLen = _tcslen(PyWin_DLLVersionString); - /* Space for all the chars, plus one \0 */ - keyBuf = keyBufPtr = malloc(sizeof(keyPrefix) + - sizeof(TCHAR)*(versionLen-1) + - sizeof(keySuffix)); - if (keyBuf==NULL) goto done; - - memcpy(keyBufPtr, keyPrefix, sizeof(keyPrefix)-sizeof(TCHAR)); - keyBufPtr += sizeof(keyPrefix)/sizeof(TCHAR) - 1; - memcpy(keyBufPtr, PyWin_DLLVersionString, versionLen * sizeof(TCHAR)); - keyBufPtr += versionLen; - /* NULL comes with this one! */ - memcpy(keyBufPtr, keySuffix, sizeof(keySuffix)); - /* Open the root Python key */ - rc=RegOpenKeyEx(keyBase, - keyBuf, /* subkey */ - 0, /* reserved */ - KEY_READ, - &newKey); - if (rc!=ERROR_SUCCESS) goto done; - /* Find out how big our core buffer is, and how many subkeys we have */ - rc = RegQueryInfoKey(newKey, NULL, NULL, NULL, &numKeys, NULL, NULL, - NULL, NULL, &dataSize, NULL, NULL); - if (rc!=ERROR_SUCCESS) goto done; - if (skipcore) dataSize = 0; /* Only count core ones if we want them! */ - /* Allocate a temp array of char buffers, so we only need to loop - reading the registry once - */ - ppPaths = malloc( sizeof(TCHAR *) * numKeys ); - if (ppPaths==NULL) goto done; - memset(ppPaths, 0, sizeof(TCHAR *) * numKeys); - /* Loop over all subkeys, allocating a temp sub-buffer. */ - for(index=0;index 0) { - *(szCur++) = _T(';'); - dataSize--; - } - if (ppPaths[index]) { - int len = _tcslen(ppPaths[index]); - _tcsncpy(szCur, ppPaths[index], len); - szCur += len; - dataSize -= len; - } - } - if (skipcore) - *szCur = '\0'; - else { - /* If we have no values, we dont need a ';' */ - if (numKeys) { - *(szCur++) = _T(';'); - dataSize--; - } - /* Now append the core path entries - - this will include the NULL - */ - rc = RegQueryValueEx(newKey, NULL, 0, NULL, - (LPBYTE)szCur, &dataSize); - } - /* And set the result - caller must free - If MBCS, it is fine as is. If Unicode, allocate new - buffer and convert. - */ -#ifdef UNICODE - retval = (char *)malloc(reqdSize+1); - if (retval) - WideCharToMultiByte(CP_ACP, 0, - dataBuf, -1, /* source */ - retval, reqdSize+1, /* dest */ - NULL, NULL); - free(dataBuf); -#else - retval = dataBuf; -#endif - } -done: - /* Loop freeing my temp buffers */ - if (ppPaths) { - for(index=0;index 4) { - zip_path[len-3] = 'z'; /* change ending to "zip" */ - zip_path[len-2] = 'i'; - zip_path[len-1] = 'p'; - } - else { - zip_path[0] = 0; - } - - skiphome = pythonhome==NULL ? 0 : 1; - machinepath = getpythonregpath(HKEY_LOCAL_MACHINE, skiphome); - userpath = getpythonregpath(HKEY_CURRENT_USER, skiphome); - /* We only use the default relative PYTHONPATH if we havent - anything better to use! */ - skipdefault = envpath!=NULL || pythonhome!=NULL || \ - machinepath!=NULL || userpath!=NULL; -#elif defined(MS_XBOX) - skipdefault = 1; -#endif - - /* We need to construct a path from the following parts. - (1) the PYTHONPATH environment variable, if set; - (2) for Win32, the zip archive file path; - (3) for Win32, the machinepath and userpath, if set; - (4) the PYTHONPATH config macro, with the leading "." - of each component replaced with pythonhome, if set; - (5) the directory containing the executable (argv0_path). - The length calculation calculates #4 first. - Extra rules: - - If PYTHONHOME is set (in any way) item (3) is ignored. - - If registry values are used, (4) and (5) are ignored. - */ - - /* Calculate size of return buffer */ - if (pythonhome != NULL) { - char *p; - bufsz = 1; - for (p = PYTHONPATH; *p; p++) { - if (*p == DELIM) - bufsz++; /* number of DELIM plus one */ - } - bufsz *= strlen(pythonhome); - } - else - bufsz = 0; - bufsz += strlen(PYTHONPATH) + 1; - bufsz += strlen(argv0_path) + 1; -#ifdef MS_WINDOWS - if (userpath) - bufsz += strlen(userpath) + 1; - if (machinepath) - bufsz += strlen(machinepath) + 1; - bufsz += strlen(zip_path) + 1; -#endif - if (envpath != NULL) - bufsz += strlen(envpath) + 1; - - module_search_path = buf = malloc(bufsz); - if (buf == NULL) { - /* We can't exit, so print a warning and limp along */ - fprintf(stderr, "Can't malloc dynamic PYTHONPATH.\n"); - if (envpath) { - fprintf(stderr, "Using environment $PYTHONPATH.\n"); - module_search_path = envpath; - } - else { - fprintf(stderr, "Using default static path.\n"); - module_search_path = PYTHONPATH; - } -#ifdef MS_WINDOWS - if (machinepath) - free(machinepath); - if (userpath) - free(userpath); -#endif /* MS_WINDOWS */ - return; - } - - if (envpath) { - strcpy(buf, envpath); - buf = strchr(buf, '\0'); - *buf++ = DELIM; - } -#ifdef MS_WINDOWS - if (zip_path[0]) { - strcpy(buf, zip_path); - buf = strchr(buf, '\0'); - *buf++ = DELIM; - } - if (userpath) { - strcpy(buf, userpath); - buf = strchr(buf, '\0'); - *buf++ = DELIM; - free(userpath); - } - if (machinepath) { - strcpy(buf, machinepath); - buf = strchr(buf, '\0'); - *buf++ = DELIM; - free(machinepath); - } - if (pythonhome == NULL) { - if (!skipdefault) { - strcpy(buf, PYTHONPATH); - buf = strchr(buf, '\0'); - } - } -#else - if (pythonhome == NULL) { - strcpy(buf, PYTHONPATH); - buf = strchr(buf, '\0'); - } -#endif /* MS_WINDOWS */ - else { - char *p = PYTHONPATH; - char *q; - size_t n; - for (;;) { - q = strchr(p, DELIM); - if (q == NULL) - n = strlen(p); - else - n = q-p; - if (p[0] == '.' && is_sep(p[1])) { - strcpy(buf, pythonhome); - buf = strchr(buf, '\0'); - p++; - n--; - } - strncpy(buf, p, n); - buf += n; - if (q == NULL) - break; - *buf++ = DELIM; - p = q+1; - } - } - if (argv0_path) { - *buf++ = DELIM; - strcpy(buf, argv0_path); - buf = strchr(buf, '\0'); - } - *buf = '\0'; - /* Now to pull one last hack/trick. If sys.prefix is - empty, then try and find it somewhere on the paths - we calculated. We scan backwards, as our general policy - is that Python core directories are at the *end* of - sys.path. We assume that our "lib" directory is - on the path, and that our 'prefix' directory is - the parent of that. - */ - if (*prefix=='\0') { - char lookBuf[MAXPATHLEN+1]; - char *look = buf - 1; /* 'buf' is at the end of the buffer */ - while (1) { - int nchars; - char *lookEnd = look; - /* 'look' will end up one character before the - start of the path in question - even if this - is one character before the start of the buffer - */ - while (*look != DELIM && look >= module_search_path) - look--; - nchars = lookEnd-look; - strncpy(lookBuf, look+1, nchars); - lookBuf[nchars] = '\0'; - /* Up one level to the parent */ - reduce(lookBuf); - if (search_for_prefix(lookBuf, LANDMARK)) { - break; - } - /* If we are out of paths to search - give up */ - if (look < module_search_path) - break; - look--; - } - } -} - - -/* External interface */ - -char * -Py_GetPath(void) -{ - if (!module_search_path) - calculate_path(); - return module_search_path; -} - -char * -Py_GetPrefix(void) -{ - if (!module_search_path) - calculate_path(); - return prefix; -} - -char * -Py_GetExecPrefix(void) -{ - return Py_GetPrefix(); -} - -char * -Py_GetProgramFullPath(void) -{ - if (!module_search_path) - calculate_path(); - return progpath; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/import_nt.c b/SDKs/XPlatform/Cypython-2.3.3/PC/import_nt.c deleted file mode 100644 index d464a0fa..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/import_nt.c +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************** - - import_nt.c - - Win32 specific import code. - -*/ - -#include "Python.h" -#include "osdefs.h" -#ifdef MS_XBOX -#include -#else -#include -#endif -#include "importdl.h" -#include "malloc.h" /* for alloca */ - -/* a string loaded from the DLL at startup */ -extern const char *PyWin_DLLVersionString; - -FILE *PyWin_FindRegisteredModule(const char *moduleName, - struct filedescr **ppFileDesc, - char *pathBuf, - int pathLen) -{ -#ifndef MS_XBOX - char *moduleKey; - const char keyPrefix[] = "Software\\Python\\PythonCore\\"; - const char keySuffix[] = "\\Modules\\"; -#ifdef _DEBUG - /* In debugging builds, we _must_ have the debug version - * registered. - */ - const char debugString[] = "\\Debug"; -#else - const char debugString[] = ""; -#endif - struct filedescr *fdp = NULL; - FILE *fp; - HKEY keyBase = HKEY_CURRENT_USER; - int modNameSize; - long regStat; - - /* Calculate the size for the sprintf buffer. - * Get the size of the chars only, plus 1 NULL. - */ - size_t bufSize = sizeof(keyPrefix)-1 + - strlen(PyWin_DLLVersionString) + - sizeof(keySuffix) + - strlen(moduleName) + - sizeof(debugString) - 1; - /* alloca == no free required, but memory only local to fn, - * also no heap fragmentation! - */ - moduleKey = alloca(bufSize); - PyOS_snprintf(moduleKey, bufSize, - "Software\\Python\\PythonCore\\%s\\Modules\\%s%s", - PyWin_DLLVersionString, moduleName, debugString); - - modNameSize = pathLen; - regStat = RegQueryValue(keyBase, moduleKey, pathBuf, &modNameSize); - if (regStat != ERROR_SUCCESS) { - /* No user setting - lookup in machine settings */ - keyBase = HKEY_LOCAL_MACHINE; - /* be anal - failure may have reset size param */ - modNameSize = pathLen; - regStat = RegQueryValue(keyBase, moduleKey, - pathBuf, &modNameSize); - - if (regStat != ERROR_SUCCESS) - return NULL; - } - /* use the file extension to locate the type entry. */ - for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) { - size_t extLen = strlen(fdp->suffix); - assert(modNameSize >= 0); /* else cast to size_t is wrong */ - if ((size_t)modNameSize > extLen && - strnicmp(pathBuf + ((size_t)modNameSize-extLen-1), - fdp->suffix, - extLen) == 0) - break; - } - if (fdp->suffix == NULL) - return NULL; - fp = fopen(pathBuf, fdp->mode); - if (fp != NULL) - *ppFileDesc = fdp; - return fp; -#else - return NULL; -#endif -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/make_versioninfo.c b/SDKs/XPlatform/Cypython-2.3.3/PC/make_versioninfo.c deleted file mode 100644 index b12a445c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/make_versioninfo.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include "patchlevel.h" -/* - * This program prints out an include file containing fields required to build - * the version info resource of pythonxx.dll because the resource compiler - * cannot do the arithmetic. - */ -/* - * FIELD3 is the third field of the version number. - * This is what we'd like FIELD3 to be: - * - * #define FIELD3 (PY_MICRO_VERSION*1000 + PY_RELEASE_LEVEL*10 + PY_RELEASE_SERIAL) - * - * but that neither gives an error nor comes anywhere close to working. - * - * For 2.4a0, - * PY_MICRO_VERSION = 0 - * PY_RELEASE_LEVEL = 'alpha' = 0xa - * PY_RELEASE_SERIAL = 0 - * - * gives FIELD3 = 0*1000 + 10*10 + 0 = 100 - */ -int main(int argc, char **argv) -{ - printf("/* This file created by make_versioninfo.exe */\n"); - printf("#define FIELD3 %d\n", - PY_MICRO_VERSION*1000 + PY_RELEASE_LEVEL*10 + PY_RELEASE_SERIAL); - printf("#define MS_DLL_ID \"%d.%d\"\n", - PY_MAJOR_VERSION, PY_MINOR_VERSION); - printf("#define PYTHON_DLL_NAME \"python%d%d.dll\"\n", - PY_MAJOR_VERSION, PY_MINOR_VERSION); - return 0; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/msvcrtmodule.c b/SDKs/XPlatform/Cypython-2.3.3/PC/msvcrtmodule.c deleted file mode 100644 index 1be12cc3..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/msvcrtmodule.c +++ /dev/null @@ -1,232 +0,0 @@ -/********************************************************* - - msvcrtmodule.c - - A Python interface to the Microsoft Visual C Runtime - Library, providing access to those non-portable, but - still useful routines. - - Only ever compiled with an MS compiler, so no attempt - has been made to avoid MS language extensions, etc... - - This may only work on NT or 95... - - Author: Mark Hammond and Guido van Rossum. - Maintenance: Guido van Rossum. - -***********************************************************/ - -#include "Python.h" -#include "malloc.h" -#include -#include -#include - -// Force the malloc heap to clean itself up, and free unused blocks -// back to the OS. (According to the docs, only works on NT.) -static PyObject * -msvcrt_heapmin(PyObject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, ":heapmin")) - return NULL; - - if (_heapmin() != 0) - return PyErr_SetFromErrno(PyExc_IOError); - - Py_INCREF(Py_None); - return Py_None; -} - -// Perform locking operations on a C runtime file descriptor. -static PyObject * -msvcrt_locking(PyObject *self, PyObject *args) -{ - int fd; - int mode; - long nbytes; - int err; - - if (!PyArg_ParseTuple(args, "iil:locking", &fd, &mode, &nbytes)) - return NULL; - - Py_BEGIN_ALLOW_THREADS - err = _locking(fd, mode, nbytes); - Py_END_ALLOW_THREADS - if (err != 0) - return PyErr_SetFromErrno(PyExc_IOError); - - Py_INCREF(Py_None); - return Py_None; -} - -// Set the file translation mode for a C runtime file descriptor. -static PyObject * -msvcrt_setmode(PyObject *self, PyObject *args) -{ - int fd; - int flags; - if (!PyArg_ParseTuple(args,"ii:setmode", &fd, &flags)) - return NULL; - - flags = _setmode(fd, flags); - if (flags == -1) - return PyErr_SetFromErrno(PyExc_IOError); - - return PyInt_FromLong(flags); -} - -// Convert an OS file handle to a C runtime file descriptor. -static PyObject * -msvcrt_open_osfhandle(PyObject *self, PyObject *args) -{ - long handle; - int flags; - int fd; - - if (!PyArg_ParseTuple(args, "li:open_osfhandle", &handle, &flags)) - return NULL; - - fd = _open_osfhandle(handle, flags); - if (fd == -1) - return PyErr_SetFromErrno(PyExc_IOError); - - return PyInt_FromLong(fd); -} - -// Convert a C runtime file descriptor to an OS file handle. -static PyObject * -msvcrt_get_osfhandle(PyObject *self, PyObject *args) -{ - int fd; - Py_intptr_t handle; - - if (!PyArg_ParseTuple(args,"i:get_osfhandle", &fd)) - return NULL; - - handle = _get_osfhandle(fd); - if (handle == -1) - return PyErr_SetFromErrno(PyExc_IOError); - - /* technically 'handle' is not a pointer, but a integer as - large as a pointer, Python's *VoidPtr interface is the - most appropriate here */ - return PyLong_FromVoidPtr((void*)handle); -} - -/* Console I/O */ - -static PyObject * -msvcrt_kbhit(PyObject *self, PyObject *args) -{ - int ok; - - if (!PyArg_ParseTuple(args, ":kbhit")) - return NULL; - - ok = _kbhit(); - return PyInt_FromLong(ok); -} - -static PyObject * -msvcrt_getch(PyObject *self, PyObject *args) -{ - int ch; - char s[1]; - - if (!PyArg_ParseTuple(args, ":getch")) - return NULL; - - Py_BEGIN_ALLOW_THREADS - ch = _getch(); - Py_END_ALLOW_THREADS - s[0] = ch; - return PyString_FromStringAndSize(s, 1); -} - -static PyObject * -msvcrt_getche(PyObject *self, PyObject *args) -{ - int ch; - char s[1]; - - if (!PyArg_ParseTuple(args, ":getche")) - return NULL; - - Py_BEGIN_ALLOW_THREADS - ch = _getche(); - Py_END_ALLOW_THREADS - s[0] = ch; - return PyString_FromStringAndSize(s, 1); -} - -static PyObject * -msvcrt_putch(PyObject *self, PyObject *args) -{ - char ch; - - if (!PyArg_ParseTuple(args, "c:putch", &ch)) - return NULL; - - _putch(ch); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -msvcrt_ungetch(PyObject *self, PyObject *args) -{ - char ch; - - if (!PyArg_ParseTuple(args, "c:ungetch", &ch)) - return NULL; - - if (_ungetch(ch) == EOF) - return PyErr_SetFromErrno(PyExc_IOError); - Py_INCREF(Py_None); - return Py_None; -} - - -static void -insertint(PyObject *d, char *name, int value) -{ - PyObject *v = PyInt_FromLong((long) value); - if (v == NULL) { - /* Don't bother reporting this error */ - PyErr_Clear(); - } - else { - PyDict_SetItemString(d, name, v); - Py_DECREF(v); - } -} - - -/* List of functions exported by this module */ -static struct PyMethodDef msvcrt_functions[] = { - {"heapmin", msvcrt_heapmin, METH_VARARGS}, - {"locking", msvcrt_locking, METH_VARARGS}, - {"setmode", msvcrt_setmode, METH_VARARGS}, - {"open_osfhandle", msvcrt_open_osfhandle, METH_VARARGS}, - {"get_osfhandle", msvcrt_get_osfhandle, METH_VARARGS}, - {"kbhit", msvcrt_kbhit, METH_VARARGS}, - {"getch", msvcrt_getch, METH_VARARGS}, - {"getche", msvcrt_getche, METH_VARARGS}, - {"putch", msvcrt_putch, METH_VARARGS}, - {"ungetch", msvcrt_ungetch, METH_VARARGS}, - {NULL, NULL} -}; - -__declspec(dllexport) void -initmsvcrt(void) -{ - PyObject *m = Py_InitModule("msvcrt", msvcrt_functions); - PyObject *d = PyModule_GetDict(m); - - /* constants for the locking() function's mode argument */ - insertint(d, "LK_LOCK", _LK_LOCK); - insertint(d, "LK_NBLCK", _LK_NBLCK); - insertint(d, "LK_NBRLCK", _LK_NBRLCK); - insertint(d, "LK_RLCK", _LK_RLCK); - insertint(d, "LK_UNLCK", _LK_UNLCK); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/Makefile b/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/Makefile deleted file mode 100644 index 59713b25..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/Makefile +++ /dev/null @@ -1,671 +0,0 @@ -#####################==================---------------- -# -# Top-Level Makefile for Building Python 2.3 for OS/2 using GCC/EMX -# Originally written by Andrew Zabolotny, for Python 1.5.2 -# Modified by Andrew MacIntyre, for Python 2.3 -# -# This makefile was developed for use with [P]GCC/EMX compiler any -# version and GNU Make. -# -# The output of the build is a largish Python23.DLL containing the -# essential modules of Python and a small Python.exe program to start -# the interpreter. When embedding Python within another program, only -# Python23.DLL is needed. We also build python_s.a static library (which -# can be converted into OMF (.lib) format using emxomf tool) and both -# python.a and python.lib import libraries. Then the optional -# extension modules, which are OS/2 DLLs renamed with a PYD file extension. -# -# Recommended build order: -# make depend (if you have makedep) -# make all -# make lx (if you have lxlite) -# make test (optional) -# -#####################==================---------------- - -# === Compilation mode: debug or release === -MODE= optimize -#MODE= debug -# === Assert() enabled === -ASSERTIONS=no -#ASSERTIONS=yes -# === Hard-wire installation location === -FIXED_PYHOME=no -#FIXED_PYHOME=yes - -# === Optional modules === -# Do you have the InfoZip compression library installed? -HAVE_ZLIB= no -# Do you have the Ultra Fast Crypt (UFC) library installed? -HAVE_UFC= no -# Do you have the Tcl/Tk library installed? -HAVE_TCLTK= no -# Do you have the GNU multiprecision library installed? -HAVE_GMPZ= no -# Do you have the GNU readline library installed? -# NOTE: I'm using a modified version of Kai Uwe Rommel's port that -# - is compiled with multithreading enabled -# - is linked statically -# I have had no success trying to use a DLL version, even when -# compiled with multithreading enabled. -HAVE_GREADLINE= no -# Do you have the BSD DB library (v1.85) as included in the EMXBSD package? -# NOTE: this library needs to be recompiled with a structure member -# renamed to avoid problems with the multithreaded errno support -# (there is a structure member called errno, used for shadowing the -# real errno, which conflicts with the errno redefinition of -Zmt) -HAVE_BSDDB= no -# Do you have the ncurses library installed? EMX's BSD curses aren't enough! -HAVE_NCURSES= no -# Do you have the GDBM library installed? -HAVE_GDBM= no -# Do you have the BZ2 compression library installed? -HAVE_BZ2= no - -# === install locations === -# default value of PYTHONHOME -LIB_DIR=C:/Python23 -# default is to have everything in or under PYTHONHOME -EXE_DIR=$(LIB_DIR) -DLL_DIR=$(EXE_DIR) - - -# === The Tools === -CC= gcc -CFLAGS= -Zmt -Wall $(INCLUDE) -CFLAGS.LIB= $(CFLAGS) -LD= gcc -LDFLAGS= -Zmt -Zcrtdll -L. -lgcc -LDFLAGS.EXE= $(LDFLAGS) -LDFLAGS.DLL= $(LDFLAGS) -Zdll -LDFLAGS.A= $(LDFLAGS) $(LIBS) -ARFLAGS= crs -IMPLIB= emximp -EXPLIB= emxexp -EXEOPT= emxbind -PY_DEF= -DPy_BUILD_CORE - - -# adjust C compiler settings based on build options -ifeq ($(MODE),debug) - CFLAGS+= -g -O - LDFLAGS+= -g -else - CFLAGS+= -s -O3 -fomit-frame-pointer -mprobe - LDFLAGS+= -s -endif -CFLAGS+= $(PY_DEF) -ifeq ($(ASSERTIONS),no) - CFLAGS+= -DNDEBUG -endif -ifeq ($(FIXED_PYHOME),yes) - CFLAGS+= -DPREFIX=$(DQUOTE)$(LIB_DIR)$(DQUOTE) -endif - -# We're using the OMF format since EMX's ld has a obscure bug -# because of which it sometimes fails to build relocations -# in .data segment that point to another .data locations -# (except for the final linking if the .EXEs) -OMF= yes - -# if fork() support is required, the main executable must be linked with ld -EXEOMF= no - -# File extensions -MODULE.EXT= .pyd -MODLIB.EXT= .dll -ifeq ($(OMF),yes) - O= .obj - A= .lib - AR= emxomfar - CFLAGS+= -Zomf - LDFLAGS+= -Zomf - ifeq ($(MODE),debug) - ARFLAGS= -p64 crs - else - ARFLAGS= -p32 crs - endif -else - O= .o - A= .a - AR= ar -endif - -# EMX's default number of file handles is 40, which is sometimes insufficient -# (the tempfile regression test tries to create 100 temporary files) -NFILES=250 - -# Source file paths -SRCPATH=.;../../Python;../../Parser;../../Objects;../../Include;../../Modules -# Python contains the central core, containing the builtins and interpreter. -# Parser contains Python's Internal Parser and -# Standalone Parser Generator Program (Shares Some of Python's Modules) -# Objects contains Python Object Types -# Modules contains extension Modules (Built-In or as Separate DLLs) - -# Unix shells tend to use "$" as delimiter for variable names. -# Test for this behaviour and set $(BUCK) variable correspondigly ... -__TMP__:=$(shell echo $$$$) -ifeq ($(__TMP__),$$$$) - BUCK= $$ - BRO= ( - BRC= ) -else - BUCK= \$$ - BRO= \( - BRC= \) -endif -# Compute the "double quote" variable -__TMP__:=$(shell echo "") -ifeq ($(__TMP__),"") - DQUOTE= " -else - DQUOTE= \" -endif - -# Include paths -#INCLUDE= -I$(subst ;, -I, $(SRCPATH)) -INCLUDE= -I. -I../../Include - -# Path to search for .c files -vpath %.c .;..;$(SRCPATH) - -# Top of the package tree -TOP= ../../ - -# Directory for output files -OUTBASE= out/ -OUT= $(OUTBASE)$(MODE)/ - -# Additional libraries -LIBS= -lsocket - -# Utility macro: replacement for $^ -^^= $(filter-out %$A,$^) -# Use $(L^) to link with all libraries specified as dependencies -L^= $(addprefix -l,$(basename $(notdir $(filter %$A,$+)))) - -# Build rules -$(OUT)%$O: %.c - $(CC) $(CFLAGS.LIB) -c $< -o $@ - -%.a: - $(LD) $(LDFLAGS.A) -o $@ $(^^) $(L^) - -%.dll: - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) - -%.pyd: $(OUT)%module$O $(OUT)%_m.def - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(PYTHON.IMPLIB) $(LIBS) - -%.exe: - $(LD) $(LDFLAGS.EXE) -o $@ $(^^) $(L^) - -%_m.def: - @echo Creating .DEF file: $@ - @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@ - ifeq ($(DESCRIPTION.$(notdir $*)$(MODULE.EXT)),) - @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@ - else - @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODULE.EXT))$(DQUOTE) >>$@ - endif - @echo DATA MULTIPLE NONSHARED >>$@ - @echo EXPORTS >>$@ - @echo init$(notdir $*) >>$@ - -%.def: - @echo Creating .DEF file: $@ - @echo NAME $(notdir $*) $(EXETYPE.$(notdir $*).exe) >$@ - @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*).exe)$(DQUOTE) >>$@ - @echo STACKSIZE 1572864 >>$@ - -# Output file names -PYTHON_VER= 2.3 -PYTHON_LIB= python23 -PYTHON.LIB= $(PYTHON_LIB)_s$A -PYTHON.IMPLIB= $(PYTHON_LIB)$A -ifeq ($(EXEOMF),yes) - PYTHON.EXEIMP= $(PYTHON.IMPLIB) - LDMODE.EXE= -Zomf -else - PYTHON.EXEIMP= $(PYTHON_LIB).a - LDMODE.EXE = -endif -PYTHON.DLL= $(PYTHON_LIB).dll -PYTHON.DEF= $(PYTHON_LIB).def -PYTHON.EXE= python.exe -PYTHONPM.EXE= pythonpm.exe -PGEN.EXE= pgen.exe -LIBRARY= $(PYTHON.LIB) -LD_LIBRARY= $(PYTHON.IMPLIB) - -# Additional executable parameters -EXETYPE.$(PYTHON.EXE)= WINDOWCOMPAT -EXETYPE.$(PYTHONPM.EXE)= WINDOWAPI -EXETYPE.$(PGEN.EXE)= WINDOWCOMPAT -DESCRIPTION.$(PYTHON.EXE)= Python object-oriented programming language interpreter for OS/2 -DESCRIPTION.$(PYTHONPM.EXE)= $(DESCRIPTION.$(PYTHON.EXE)) -DESCRIPTION.$(PGEN.EXE)= Python object-oriented programming language parser generator for OS/2 - -# Module descriptions -DESCRIPTION.zlib$(MODULE.EXT)= Python Extension DLL for accessing the InfoZip compression library -DESCRIPTION.crypt$(MODULE.EXT)= Python Extension DLL implementing the crypt$(BRO)$(BRC) function -DESCRIPTION._tkinter$(MODULE.EXT)= Python Extension DLL for access to Tcl/Tk Environment -DESCRIPTION.mpz$(MODULE.EXT)= Python Extension DLL for access to GNU multi-precision library -DESCRIPTION.readline$(MODULE.EXT)= Python Extension DLL for access to GNU ReadLine library -DESCRIPTION.bsddb185$(MODULE.EXT)= Python Extension DLL for access to BSD DB (v1.85) library -DESCRIPTION._curses$(MODLIB.EXT)= Python Extension DLL for access to ncurses library -DESCRIPTION.pyexpat$(MODULE.EXT)= Python Extension DLL for access to expat library -DESCRIPTION.bz2$(MODULE.EXT)= Python Extension DLL for accessing the bz2 compression library - -# Source files -SRC.OS2EMX= config.c dlfcn.c getpathp.c -SRC.MAIN= $(addprefix $(TOP), \ - Modules/getbuildinfo.c \ - Modules/main.c) -SRC.MODULES= $(addprefix $(TOP), \ - Modules/gcmodule.c \ - Modules/signalmodule.c \ - Modules/posixmodule.c \ - Modules/threadmodule.c \ - Modules/arraymodule.c \ - Modules/binascii.c \ - Modules/cmathmodule.c \ - Modules/_codecsmodule.c \ - Modules/cPickle.c \ - Modules/cStringIO.c \ - Modules/_csv.c \ - Modules/datetimemodule.c \ - Modules/dlmodule.c \ - Modules/errnomodule.c \ - Modules/fcntlmodule.c \ - Modules/imageop.c \ - Modules/itertoolsmodule.c \ - Modules/_localemodule.c \ - Modules/mathmodule.c \ - Modules/md5c.c \ - Modules/md5module.c \ - Modules/operator.c \ - Modules/pcremodule.c \ - Modules/pypcre.c \ - Modules/_randommodule.c \ - Modules/regexmodule.c \ - Modules/regexpr.c \ - Modules/rgbimgmodule.c \ - Modules/shamodule.c \ - Modules/_sre.c \ - Modules/stropmodule.c \ - Modules/structmodule.c \ - Modules/symtablemodule.c \ - Modules/termios.c \ - Modules/timemodule.c \ - Modules/timingmodule.c \ - Modules/_weakref.c \ - Modules/xreadlinesmodule.c \ - Modules/xxsubtype.c \ - Modules/zipimport.c) -SRC.PARSE1= $(addprefix $(TOP), \ - Parser/acceler.c \ - Parser/grammar1.c \ - Parser/listnode.c \ - Parser/node.c \ - Parser/parser.c \ - Parser/parsetok.c \ - Parser/bitset.c \ - Parser/metagrammar.c) -SRC.PARSE2= $(addprefix $(TOP), \ - Parser/tokenizer.c \ - Parser/myreadline.c) -SRC.PARSER= $(SRC.PARSE1) \ - $(SRC.PARSE2) -SRC.PYTHON= $(addprefix $(TOP), \ - Python/bltinmodule.c \ - Python/exceptions.c \ - Python/ceval.c \ - Python/compile.c \ - Python/codecs.c \ - Python/errors.c \ - Python/frozen.c \ - Python/frozenmain.c \ - Python/future.c \ - Python/getargs.c \ - Python/getcompiler.c \ - Python/getcopyright.c \ - Python/getmtime.c \ - Python/getplatform.c \ - Python/getversion.c \ - Python/graminit.c \ - Python/import.c \ - Python/importdl.c \ - Python/marshal.c \ - Python/modsupport.c \ - Python/mysnprintf.c \ - Python/mystrtoul.c \ - Python/pyfpe.c \ - Python/pystate.c \ - Python/pythonrun.c \ - Python/structmember.c \ - Python/symtable.c \ - Python/sysmodule.c \ - Python/traceback.c \ - Python/getopt.c \ - Python/dynload_shlib.c \ - Python/thread.c) -SRC.OBJECT= $(addprefix $(TOP), \ - Objects/abstract.c \ - Objects/boolobject.c \ - Objects/bufferobject.c \ - Objects/cellobject.c \ - Objects/classobject.c \ - Objects/cobject.c \ - Objects/complexobject.c \ - Objects/descrobject.c \ - Objects/dictobject.c \ - Objects/enumobject.c \ - Objects/fileobject.c \ - Objects/floatobject.c \ - Objects/frameobject.c \ - Objects/funcobject.c \ - Objects/intobject.c \ - Objects/iterobject.c \ - Objects/listobject.c \ - Objects/longobject.c \ - Objects/methodobject.c \ - Objects/moduleobject.c \ - Objects/object.c \ - Objects/obmalloc.c \ - Objects/rangeobject.c \ - Objects/sliceobject.c \ - Objects/stringobject.c \ - Objects/structseq.c \ - Objects/tupleobject.c \ - Objects/typeobject.c \ - Objects/unicodeobject.c \ - Objects/unicodectype.c \ - Objects/weakrefobject.c) - -SRC.LIB= $(SRC.OS2EMX) \ - $(SRC.MAIN) \ - $(SRC.PARSER) \ - $(SRC.OBJECT) \ - $(SRC.PYTHON) \ - $(SRC.MODULES) -OBJ.LIB= $(addprefix $(OUT),$(notdir $(SRC.LIB:.c=$O))) - -SRC.PGEN= $(SRC.PARSE1) \ - $(addprefix $(TOP), \ - Objects/obmalloc.c) \ - $(addprefix $(TOP), \ - Python/mysnprintf.c) \ - $(addprefix $(TOP), \ - Parser/tokenizer_pgen.c \ - Parser/pgenmain.c \ - Parser/pgen.c \ - Parser/printgrammar.c \ - Parser/grammar.c \ - Parser/firstsets.c) \ - -OBJ.PGEN= $(addprefix $(OUT),$(notdir $(SRC.PGEN:.c=$O))) - -SRC.EXE= $(TOP)Modules/python.c -SRC.PMEXE= pythonpm.c - -# Python modules to be dynamically loaded that: -# 1) have only single source file and require no extra libs -# 2) use the standard module naming convention -# (the 'module' in ?????module.c is assumed) -# - these can be built with implicit rules -EASYEXTMODULES= fpectl \ - fpetest \ - parser \ - pwd \ - rotor \ - select - -# Python modules to be dynamically loaded that need explicit build rules -# (either multiple source files and/or non-standard module naming) -# (NOTE: use shortened names for modules affected by 8 char name limit) -HARDEXTMODULES= _hotshot \ - _socket \ - _testcap \ - unicoded - -# Python modules that are used as libraries and therefore must use -# a .DLL extension -LIBEXTMODULES= - -# Python external ($(MODULE.EXT)) modules - can be EASY or HARD -ifeq ($(HAVE_ZLIB),yes) - HARDEXTMODULES+= zlib -endif -ifeq ($(HAVE_UFC),yes) - HARDEXTMODULES+= crypt -endif -ifeq ($(HAVE_TCLTK),yes) - HARDEXTMODULES+= _tkinter - CFLAGS+= -DHAS_DIRENT -I/TclTk80/include - TK_LIBS+= -L/TclTk80/lib -ltcl80 -ltk80 -endif -ifeq ($(HAVE_GMPZ),yes) - HARDEXTMODULES+= mpz -endif -ifeq ($(HAVE_GREADLINE),yes) - HARDEXTMODULES+= readline -endif -ifeq ($(HAVE_BSDDB),yes) - HARDEXTMODULES+= bsddb185 -endif -ifeq ($(HAVE_NCURSES),yes) - LIBEXTMODULES+= _curses - HARDEXTMODULES+= _curses_ -endif -ifeq ($(HAVE_GDBM),yes) - HARDEXTMODULES+= gdbm dbm -endif -ifeq ($(HAVE_BZ2),yes) - HARDEXTMODULES+= bz2 -endif - -# Expat is now distributed with the Python source -HARDEXTMODULES+= pyexpat -EXPAT.INC= -I../../Modules/expat -EXPAT.DEF= -DHAVE_EXPAT_H -DXML_NS=1 -DXML_DTD=1 -DXML_BYTE_ORDER=12 \ - -DXML_CONTENT_BYTES=1024 -EXPAT.SRC= $(addprefix ../../Modules/expat/, \ - xmlparse.c \ - xmlrole.c \ - xmltok.c) - -# all the external modules -EXTERNDLLS= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(EASYEXTMODULES))) -EXTERNDLLS+= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(HARDEXTMODULES))) -EXTERNDLLS+= $(addsuffix $(MODLIB.EXT),$(patsubst %module,%,$(LIBEXTMODULES))) - -# Targets -all: $(OUT) $(PYTHON.LIB) $(PYTHON.DEF) $(PYTHON.IMPLIB) $(PYTHON.DLL) \ - python_noncore - -python_noncore: - make PY_DEF= $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) $(EXTERNDLLS) - -clean: - rm -f $(OUT)* - rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \ - $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT) - find ../../Lib -name "*.py[co]" -exec rm {} ";" - -lx: - @echo Packing everything with lxLite... - lxlite $(PYTHON.DLL) $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) - -depend: $(OUTBASE) - makedep -f $(OUTBASE)python.dep -o $(BUCK)O -p $(BUCK)\(OUT\) \ - -r -c $(INCLUDE) $(SRC.LIB) $(SRC.PGEN) - -$(OUT): $(OUTBASE) - -$(OUT) $(OUTBASE): - mkdir.exe $@ - -$(PYTHON.LIB): $(OBJ.LIB) - rm.exe -f $@ - $(AR) $(ARFLAGS) $@ $^ - -# the Python core DLL .def file needs to have a number of non-static -# symbols that aren't part of the Python C API removed (commented out) -# from the DLL export list. -$(PYTHON.DEF): $(PYTHON.LIB) - @echo Creating .DEF file: $@ - @echo LIBRARY $(PYTHON_LIB) INITINSTANCE TERMINSTANCE >$@ - @echo DESCRIPTION $(DQUOTE)Python $(PYTHON_VER) Core DLL$(DQUOTE) >>$@ - @echo PROTMODE >>$@ - @echo DATA MULTIPLE NONSHARED >>$@ - @echo EXPORTS >>$@ - $(EXPLIB) -u $(PYTHON.LIB) |\ - sed -e "/^ .init.*/s/^ /; /" \ - -e "/^ .pcre_.*/s/^ /; /" \ - -e "/^ .array_methods/s/^ /; /" \ - -e "/^ .fast_save_leave/s/^ /; /" \ - -e "/^ .dlopen/s/^ /; /" \ - -e "/^ .dlsym/s/^ /; /" \ - -e "/^ .dlclose/s/^ /; /" \ - -e "/^ .dlerror/s/^ /; /" \ - -e "/^ ._Py_re_.*/s/^ /; /" \ - -e "/^ ._Py_MD5.*/s/^ /; /" >>$@ - -$(PYTHON.IMPLIB): $(PYTHON.DEF) - $(IMPLIB) -o $@ $^ - -$(PYTHON.EXEIMP): $(PYTHON.DEF) - $(IMPLIB) -o $@ $^ - -$(PYTHON.DLL): $(OUT)dllentry$O $(PYTHON.LIB) $(PYTHON.DEF) - -# Explicit make targets for the .EXEs to be able to use LD to link -# (so that fork() will work if required) - -$(PYTHON.EXE): $(SRC.EXE) $(PYTHON.EXEIMP) $(OUT)python.def - $(CC) -Zmt $(LDMODE.EXE) -Zcrtdll -Wall $(INCLUDE) -L. -lgcc -o $@ $(SRC.EXE) $(PYTHON.EXEIMP) $(LIBS) $(OUT)python.def - $(EXEOPT) -aq $(PYTHON.EXE) -h$(NFILES) - -$(PYTHONPM.EXE): $(SRC.PMEXE) $(PYTHON.EXEIMP) $(OUT)pythonpm.def - $(CC) -Zmt $(LDMODE.EXE) -Zcrtdll -Wall $(INCLUDE) -L. -lgcc -o $@ $(SRC.PMEXE) $(PYTHON.EXEIMP) $(LIBS) $(OUT)pythonpm.def - $(EXEOPT) -aq $(PYTHONPM.EXE) -h$(NFILES) - -$(PGEN.EXE): $(OBJ.PGEN) $(OUT)pgen.def - -# Explicit building instructions for those external modules that require -# awkward handling (due e.g. to non-std naming, or multiple source files) -# - standard modules - -_hotshot$(MODULE.EXT): $(OUT)_hotshot$O $(OUT)_hotshot_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) - -_socket$(MODULE.EXT): $(OUT)socketmodule$O $(OUT)_socket_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) - -# _testcapi needs to be renamed to be useful -_testcapi$(MODULE.EXT): $(OUT)_testcapimodule$O $(OUT)_testcapi_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) - -_testcap$(MODULE.EXT): _testcapi$(MODULE.EXT) - cp $^ $@ - -# unicodedata needs to be renamed to be useful -unicodedata$(MODULE.EXT): $(OUT)unicodedata$O $(OUT)unicodedata_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(MODULE_LIBS) - -unicoded$(MODULE.EXT): unicodedata$(MODULE.EXT) - cp $^ $@ - -# - optional modules (requiring other software to be installed) -bsddb185$(MODULE.EXT): $(OUT)bsddbmodule$O $(OUT)bsddb185_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -ldb $(LIBS) - -crypt$(MODULE.EXT): $(OUT)cryptmodule$O $(OUT)crypt_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -lufc $(LIBS) - -# The _curses_panel module requires a couple of ncurses library entry -# points, which are best exposed as exports from the _curses module DLL -$(OUT)_curses_m.def: - @echo Creating .DEF file: $@ - @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@ - @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODLIB.EXT))$(DQUOTE) >>$@ - @echo DATA MULTIPLE NONSHARED >>$@ - @echo EXPORTS >>$@ - @echo init_curses >>$@ - @echo wnoutrefresh >>$@ - @echo _nc_panelhook >>$@ - @echo is_linetouched >>$@ - @echo mvwin >>$@ - @echo stdscr >>$@ - @echo wtouchln >>$@ - -$(OUT)_curses_panel_m.def: - @echo Creating .DEF file: $@ - @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@ - @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@ - @echo DATA MULTIPLE NONSHARED >>$@ - @echo IMPORTS >>$@ - @echo _curses.wnoutrefresh >>$@ - @echo _curses._nc_panelhook >>$@ - @echo _curses.is_linetouched >>$@ - @echo _curses.mvwin >>$@ - @echo _curses.stdscr >>$@ - @echo _curses.wtouchln >>$@ - @echo EXPORTS >>$@ - @echo init_curses_panel >>$@ - -_curses$(MODLIB.EXT): $(OUT)_cursesmodule$O $(OUT)_curses_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lncurses - -# curses_panel needs to be renamed to be useful -_curses_panel$(MODULE.EXT): $(OUT)_curses_panel$O $(OUT)_curses_panel_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lpanel - -_curses_$(MODULE.EXT): _curses_panel$(MODULE.EXT) - cp $^ $@ - -dbm$(MODULE.EXT): $(OUT)dbmmodule$O $(OUT)dbm_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm - -gdbm$(MODULE.EXT): $(OUT)gdbmmodule$O $(OUT)gdbm_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm - -mpz$(MODULE.EXT): $(OUT)mpzmodule$O $(OUT)mpz_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgmp - -# Expat is now distributed with Python, so use the included version -$(OUT)pyexpat$O: ../../Modules/pyexpat.c - $(CC) $(CFLAGS) $(EXPAT.INC) -c -o $@ $^ -$(OUT)xmlparse$O: ../../Modules/expat/xmlparse.c - $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^ -$(OUT)xmlrole$O: ../../Modules/expat/xmlrole.c - $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^ -$(OUT)xmltok$O: ../../Modules/expat/xmltok.c - $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^ -pyexpat$(MODULE.EXT): $(OUT)pyexpat$O $(OUT)xmlparse$O $(OUT)xmlrole$O \ - $(OUT)xmltok$O $(OUT)pyexpat_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) - -readline$(MODULE.EXT): $(OUT)readline$O $(OUT)readline_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lreadline -lncurses - -#_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O $(OUT)tkappinit$O -_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O \ - $(OUT)_tkinter_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(TK_LIBS) - -zlib$(MODULE.EXT): $(OUT)zlibmodule$O $(OUT)zlib_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lz - -bz2$(MODULE.EXT): $(OUT)bz2module$O $(OUT)bz2_m.def $(PYTHON.IMPLIB) - $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lbz2 - -# the test target -test: - -find ../../Lib -name "*.py[co]" -exec rm {} ";" - -./python -E -tt ../../lib/test/regrtest.py -l -u "network" - ./python -E -tt ../../lib/test/regrtest.py -l -u "network" - --include $(OUTBASE)python.dep diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/README.os2emx b/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/README.os2emx deleted file mode 100644 index de8a3a0e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/README.os2emx +++ /dev/null @@ -1,671 +0,0 @@ -This is a port of Python 2.3.3 to OS/2 using the EMX development tools -========================================================================= - -What's new since the previous release -------------------------------------- - -Another day, another version... - - -Licenses and info about Python and EMX --------------------------------------- - -Please read the file README.Python-2.3.3 included in this package for -information about Python 2.3.3. This file is the README file from the -Python 2.3.3 source distribution available via http://www.python.org/ -and its mirrors. The file LICENCE.Python-2.3.3 is the text of the Licence -from the Python 2.3.3 source distribution. - -Note that the EMX package that this package depends on is released under -the GNU General Public Licence. Please refer to the documentation -accompanying the EMX Runtime libraries for more information about the -implications of this. A copy of version 2 of the GPL is included as the -file COPYING.gpl2. - -Readline and GDBM are covered by the GNU General Public Licence. I think -Eberhard Mattes' porting changes to BSD DB v1.85 are also GPL'ed (BSD DB -itself is BSD Licenced). ncurses and expat appear to be covered by MIT -style licences - please refer to the source distributions for more detail. -zlib is distributable under a very free license. GNU MP and GNU UFC are -under the GNU LGPL (see file COPYING.lib). - -My patches to the Python-2.x source distributions, and any other packages -used in this port, are placed in the public domain. - -This software is provided 'as-is', without any express or implied warranty. -In no event will the author be held liable for any damages arising from the -use of the software. - -I do hope however that it proves useful to someone. - - -Other ports ------------ - -There have been ports of previous versions of Python to OS/2. - -The best known would be that by Jeff Rush, most recently of version -1.5.2. Jeff used IBM's Visual Age C++ (v3) for his ports, and his -patches have been included in the Python 2.3.3 source distribution. - -Andy Zabolotny implemented a port of Python v1.5.2 using the EMX -development tools. His patches against the Python v1.5.2 source -distribution have become the core of this port, and without his efforts -this port wouldn't exist. Andy's port also appears to have been -compiled with his port of gcc 2.95.2 to EMX, which I have but have -chosen not to use for the binary distribution of this port (see item 16 -of the "YOU HAVE BEEN WARNED" section below). - -It is possible to have these earlier ports still usable after installing -this port - see the README.os2emx.multiple_versions file, contributed by -Dr David Mertz, for a suggested approach to achieving this. - - -Software requirements ---------------------- - -This package requires the EMX Runtime package, available from the -Hobbes (http://hobbes.nmsu.edu/) and LEO (http://archiv.leo.org/) -archives of OS/2 software. I have used EMX version 0.9d fix04 in -developing this port. - -My development system is running OS/2 v4 with fixpack 12. - -3rd party software which has been linked into dynamically loaded modules: -- ncurses (see http://dickey.his.com/ for more info, v5.2) -- GNU Readline (Kai Uwe Rommel's port available from Hobbes or LEO, v2.1) -- GNU GDBM (Kai Uwe Rommel's port available from Hobbes or LEO, v1.7.3) -- zlib (derived from Hung-Chi Chu's port of v1.1.3, v1.1.4) -- expat (distributed with Python, v1.95.6) -- GNU MP (Peter Meerwald's port available from LEO, v2.0.2) -- GNU UFC (Kai Uwe Rommel's port available from LEO, v2.0.4) - - -About this port ---------------- - -I have attempted to make this port as complete and functional as I can, -notwithstanding the issues in the "YOU HAVE BEEN WARNED" section below. - -Core components: - -Python.exe is linked as an a.out executable, ie using EMX method E1 -to compile & link the executable. This is so that fork() works (see -"YOU HAVE BEEN WARNED" item 1). - -Python23.dll is created as a normal OMF DLL, with an OMF import -library and module definition file. There is also an a.out (.a) import -library to support linking the DLL to a.out executables. The DLL -requires the EMX runtime DLLs. - -This port has been built with complete support for multithreading. - -Modules: - -With the exception of modules that have a significant code size, or are -not recommended or desired for normal use, the standard modules are now -built into the core DLL rather than configured as dynamically loadable -modules. This is for both reasons of performance (startup time) and -memory use (lots of small DLLs fragment the address space). - -I haven't yet changed the building of Python's dynamically loadable -modules over to using the DistUtils. - -See "YOU HAVE BEEN WARNED" item 3 for notes about the fcntl module, and -"YOU HAVE BEEN WARNED" item 10 for notes about the pwd and grp modules. - -This port supports case sensitive module import semantics, matching -the Windows release. This can be deactivated by setting the PYTHONCASEOK -environment variable (the value doesn't matter) - see "YOU HAVE BEEN WARNED" -item 12. - -Optional modules: - -Where I've been able to locate the required 3rd party packages already -ported to OS/2, I've built and included them. - -These include ncurses (_curses, _curses_panel), BSD DB (bsddb185), -GNU GDBM (gdbm, dbm), zlib (zlib), GNU Readline (readline), GNU MP (mpz) -and GNU UFC (crypt). - -Expat is now included in the Python release sourceball, and the pyexpat -module is always built. - -I have built these modules statically linked against the 3rd party -libraries. Unfortunately my attempts to use the dll version of GNU -readline have been a dismal failure, in that when the dynamically -linked readline module is active other modules immediately provoke a -core dump when imported. - -Only the BSD DB package (part of the BSD package distributed with EMX) -needs source modifications to be used for this port, pertaining to use -of errno with multithreading. - -The other packages, except for ncurses and zlib, needed Makefile changes -for multithreading support but no source changes. - -The _curses_panel module is a potential problem - see "YOU HAVE BEEN -WARNED" item 13. - -Upstream source patches: - -No updates to the Python 2.3.3 release have become available. - -Eberhard Mattes' EMXFIX04 update to his EMX 0.9d tools suite includes -bug fixes for the BSD DB library. The bsddb module included in this -port incorporates these fixes. - -Library and other distributed Python code: - -The Python standard library lives in the Lib directory. All the standard -library code included with the Python 2.3.3 source distribution is included -in the binary archive, with the exception of the dos-8x3 and tkinter -subdirectories which have been omitted to reduce the size of the binary -archive - the dos-8x3 components are unnecessary duplicates and Tkinter -is not supported by this port (yet). All the plat-* subdirectories in the -source distribution have also been omitted, except for the plat-os2emx -subdirectory. - -The Tools and Demo directories contain a collection of Python scripts. -To reduce the size of the binary archive, the Demo/sgi, Demo/Tix, -Demo/tkinter, Tools/audiopy and Tools/IDLE subdirectories have been -omitted as not being supported by this port. The Misc directory has -also been omitted. - -All subdirectories omitted from the binary archive can be reconstituted -from the Python 2.3.3 source distribution, if desired. - -Support for building Python extensions: - -The Config subdirectory contains the files describing the configuration -of the interpreter and the Makefile, import libraries for the Python DLL, -and the module definition file used to create the Python DLL. The -Include subdirectory contains all the standard Python header files -needed for building extensions. - -As I don't have the Visual Age C++ compiler, I've made no attempt to -have this port support extensions built with that compiler. - - -Packaging ---------- - -This port is packaged as follows: -- python-2.3.3-os2emx-bin-03????.zip (binaries, library modules) -- python-2.3.3-os2emx-src-03???? (patches+makefiles for non-Python code) - -As all the Python specific patches for the port are now part of the -Python release tarball, only the patches and makefiles involved in -building external libraries for optional extensions are included in -the source archive. - -Documentation for the Python language, as well as the Python 2.3.3 -source distibution, can be obtained from the Python website -(http://www.python.org/) or the Python project pages at Sourceforge -(http://sf.net/projects/python/). - - -Installation ------------- - -Obtain and install, as per the included instructions, the EMX runtime -package. - -Unpack this archive, preserving the subdirectories, in the root directory -of the drive where you want Python to live. - -Add the Python directory (eg C:\Python23) to the PATH and LIBPATH -variables in CONFIG.SYS. - -You should then set the PYTHONHOME and PYTHONPATH environment variables -in CONFIG.SYS. - -PYTHONHOME should be set to Python's top level directory. PYTHONPATH -should be set to the semicolon separated list of principal Python library -directories. -I use: - SET PYTHONHOME=F:/Python23 - SET PYTHONPATH=F:/Python23/Lib;F:/Python23/Lib/plat-os2emx; - F:/Python23/Lib/lib-dynload;F:/Python23/Lib/site-packages - -NOTE!: the PYTHONPATH setting above is linewrapped for this document - it -should all be on one line in CONFIG.SYS! - -If you wish to use the curses module, you should set the TERM and TERMINFO -environment variables appropriately. - -If you don't already have ncurses installed, I have included a copy of the -EMX subset of the Terminfo database included with the ncurses-5.2 source -distribution. This can be used by setting the TERMINFO environment variable -to the path of the Terminfo subdirectory below the Python home directory. -On my system this looks like: - SET TERMINFO=F:/Python23/Terminfo - -For the TERM environment variable, I would try one of the following: - SET TERM=ansi - SET TERM=os2 - SET TERM=window - -You will have to reboot your system for these changes to CONFIG.SYS to take -effect. - -If you wish to compile all the included Python library modules to bytecode, -you can change into the Python home directory and run the COMPILEALL.CMD -batch file. - -You can execute the regression tests included with the Python 2.3.3 source -distribution by changing to the Python 2.3.3 home directory and executing the -REGRTEST.CMD batch file. The following tests are known to fail at this -time: -- test_mhlib (I don't know of any port of MH to OS/2); -- test_strptime (see "YOU HAVE BEEN WARNED" item 22); -- test_time (see "YOU HAVE BEEN WARNED" item 22); -- test_posixpath (see "YOU HAVE BEEN WARNED" item 23). - -Note that some of the network related tests expect the loopback interface -(interface "lo", with IP address 127.0.0.1) to be enabled, which from my -experience is not the default configuration. Additionally, test_popen2 -expects the "cat" utility (such as found in ports of the GNU tools) to -be installed. - - -Building from source --------------------- - -With the EMX port now checked into Python's CVS repository, the build -infrastructure is part of the Python release sourceball. - -Prerequisites - -First and foremost, you need an operational EMX development installation - -EMX v0.9d with fix04 (the latest at time of writing) & the gcc 2.8.1 -compiler released by Eberhard Mattes is the recommended setup. - -If you have a different version of gcc installed, see "YOU HAVE BEEN -WARNED" item 16. - -Other items of software required:- - -- GNU make (I'm using v3.76.1) -- rm, cp, mkdir from the GNU file utilities package -- GNU find -- GNU sed - -Procedure - -0. all changes mentioned apply to files in the PC/os2emx subdirectory - of the Python release source tree. make is also executed from this - directory, so change into this directory before proceeding. - -1. decide if you need to change the location of the Python installation. - If you wish to do this, set the value of the Makefile variable LIB_DIR - to the directory you wish to use for PYTHONHOME - (eg /usr/local/lib/python2.3.3). - - If you want Python to find its library without the PYTHONHOME - environment variable set, set the value of the Makefile variable - FIXED_PYHOME to "yes" (uncomment the appropriate line). - -2. If you wish the Python executables (python.exe, pythonpm.exe & pgen.exe) - to be installed in a directory other than the PYTHONHOME directory, set - the value of the Makefile variable EXE_DIR to the appropriate directory. - -3. If you wish the Python core DLL (python23.dll) to be installed in a - directory other than the directory in which the Python executables are - installed (by default, the PYTHONHOME directory), set the value of the - Makefile variable DLL_DIR to the appropriate directory. This DLL must - be placed in a directory on the system's LIBPATH, or that gets set - with BEGINLIBPATH or ENDLIBPATH. - -4. If you have installed any of the libraries that can be used to build - optional Python modules, set the value of the relevant HAVE_ - Makefile variable to "yes". The Makefile currently supports: - - library Makefile variable - ........................................ - zlib (1.1.4) HAVE_ZLIB - GNU UltraFast Crypt HAVE_UFC - Tcl/Tk HAVE_TCLTK (not known to work) - GNU MP HAVE_GMPZ - GNU Readline HAVE_GREADLINE - BSD DB (v1.85) HAVE_BSDDB - ncurses HAVE_NCURSES - GNU gdbm HAVE_GDBM - libbz2 HAVE_BZ2 - - Please note that you need to check that what you have installed - is compatible with Python's build options. In particular, the - BSD DB v1.85 library needs to be rebuilt with a source patch for - multithread support (doesn't change the library's reentrant status - but allows it to be linked to Python which is multithreaded). - Widely available binary packages of other librarys & DLLs are - not built/linked with multithread support. Beware! - - Also note that the Makefile currently expects any libraries to be - found with the default library search path. You may need to add - -L switches to the LDFLAGS Makefile variable if you have installed - libraries in directories not in the default search path (which can - be controlled by the LIBRARY_PATH environment variable used by EMX). - -5. make - - It is usually a good idea to redirect the stdout and stderr streams - of the make process to log files, so that you can review any messages. - -6. make test - - This runs the Python regression tests, and completion is a sign of - a usable build. You should check the list of skipped modules to - ensure that any optional modules you selected have been built; - checking the list of failures against the list of known failures - elsewhere in this document is also prudent. - -7. make install - >>>>>> NOT YET COMPLETE <<<<<< - -8. change to a directory outside the Python source tree and start Python. - Check the version and build date to confirm satisfactory installation. - - -YOU HAVE BEEN WARNED!! ----------------------- - -I know about a number of nasties in this port. - -1. Eberhard Mattes, author of EMX, writes in his documentation that fork() -is very inefficient in the OS/2 environment. It also requires that the -executable be linked in a.out format rather than OMF. Use the os.exec -and/or the os.spawn family of functions where possible. - -2. In the absence of GNU Readline, terminating the interpreter requires a -control-Z (^Z) followed by a carriage return. Jeff Rush documented this -problem in his Python 1.5.2 port. With Readline, a control-D (^D) works -as per the standard Unix environment. - -3. EMX only has a partial implementation of fcntl(). The fcntl module -in this port supports what EMX supports. If fcntl is important to you, -please review the EMX C Library Reference (included in .INF format in the -EMXVIEW.ZIP archive as part of the complete EMX development tools suite). -Because of other side-effects I have modified the test_fcntl.py test -script to deactivate the exercising of the missing functionality. - -4. the PyBSDDB3 module has been imported into the Python standard -library, with the intent of superceding the BSDDB 1.85 module (bsddb). -As I don't yet have a satisfactory port of Sleepcat's more recent DB -library (3.3.x/4.0.x/4.1.x), I haven't included a binary of this -module. I have left the Python part of the PyBSDDB package in this -distribution for completeness. - -5. As a consequence of the PyBSDDB3 module being imported, the former -BSD DB (bsddb) module, linked against the DB v1.85 library from EMX, -has been renamed bsddb185. The bsddb185 module will not be built by -default on most platforms, but in the absence of a PyBSDDB3 module I -have retained it in the EMX port. - -Version 1.85 of the DB library is widely known to have bugs, although -some patches have become available (and are incorporated into the -included bsddb185 module). Unless you have problems with software -licenses which would rule out GDBM (and the dbm module because it is -linked against the GDBM library) or need it for file format compatibility, -you may be better off deleting it and relying on GDBM. - -Any code you have which uses the v1.85 bsddb module can be modified to -use the renamed module by changing - - import bsddb - -to - - import bsddb185 as bsddb - -6. The readline module has been linked against ncurses rather than the -termcap library supplied with EMX. - -7. I have configured this port to use "/" as the preferred path separator -character, rather than "\" ('\\'), in line with the convention supported -by EMX. Backslashes are still supported of course, and still appear in -unexpected places due to outside sources that don't get normalised. - -8. While the DistUtils components are now functional, other -packaging/binary handling tools and utilities such as those included in -the Demo and Tools directories - freeze in particular - are unlikely to -work. If you do get them going, I'd like to know about your success. - -9. I haven't set out to support the [BEGIN|END]LIBPATH functionality -supported by one of the earlier ports (Rush's??). If it works let me know. - -10. As a result of the limitations imposed by EMX's library routines, the -standard extension module pwd only synthesises a simple passwd database, -and the grp module cannot be supported at all. - -I have written pure Python substitutes for pwd and grp, which can process -real passwd and group files for those applications (such as MailMan) that -require more than EMX emulates. I have placed pwd.py and grp.py in -Lib/plat-os2emx, which is usually before Lib/lib-dynload (which contains -pwd.pyd) in the PYTHONPATH. If you have become attached to what pwd.pyd -supports, you can put Lib/lib-dynload before Lib/plat-os2emx in PYTHONPATH -or delete/rename pwd.py & grp.py. - -pwd.py & grp.py support locating their data files by looking in the -environment for them in the following sequence: -pwd.py: $ETC_PASSWD (%ETC_PASSWD%) - $ETC/passwd (%ETC%/passwd) - $PYTHONHOME/Etc/passwd (%PYTHONHOME%/Etc/passwd) -grp.py: $ETC_GROUP (%ETC_GROUP%) - $ETC/group (%ETC%/group) - $PYTHONHOME/Etc/group (%PYTHONHOME%/Etc/group) - -The ETC_PASSWD and ETC_GROUP environment variables are intended to allow -support for multiple passwd/grp files, where other applications may not -support as wide a variety of input variations (drive remappings, -separators etc). - -Both modules support using either the ":" character (Unix standard) or -";" (OS/2, DOS, Windows standard) field separator character, and pwd.py -implements the following drive letter conversions for the home_directory and -shell fields (for the ":" separator only): - $x -> x: - x; -> x: - -Example versions of passwd and group are in the Etc subdirectory. The -regression tests (test_pwd and test_grp) will fail if valid password and -group files cannot be found, but should pass otherwise. - -Be aware that Python's pwd & group modules are for reading password and -group information only. - -11. EMX's termios routines don't support all of the functionality now -exposed by the termios module - refer to the EMX documentation to find -out what is supported. - -12. The case sensitive import semantics introduced in Python 2.1 for other -case insensitive but case preserving file/operating systems (Windows etc), -have been incorporated into this port, and are active by default. Setting -the PYTHONCASEOK environment variable (to any value) reverts to the -previous (case insensitive) semantics. This can be an issue with some -file management utilities that do not preserve the case of file and -directory names. - -13. Because I am statically linking ncurses, the _curses_panel -module has potential problems arising from separate library data areas. -To avoid this, I have configured the _curses_.pyd (imported as -"_curses_panel") to import the ncurses symbols it needs from _curses.dll -(which is the curses module, but with a .dll extension rather than .pyd -so that the dynamic loader can actually import the symbols from it as a -DLL). - -The site module (Lib/site.py) has code added to tweak BEGINLIBPATH so -that _curses.dll is found when _curses_panel is imported. If you have -problems attempting to use the _curses_panel support please let me know, -and I'll have another look at this. - -14. sys.platform reports "os2emx" instead of "os2". os.name still -reports "os2". This change was to make it easier to distinguish between -the VAC++ build (formerly maintained by Michael Muller) and the EMX build -(this port), principally for DistUtils. - -15. it appears that the %W substitution in the EMX strftime() routine has -an off-by-one bug. strftime was listed as passing the regression tests -in previous releases, but this fact appears to have been an oversight in -the regression test suite. To fix this really requires a portable -strftime routine - I'm looking into using one from FreeBSD, but its not -ready yet. - -16. I have successfully built this port with Andy Zabolotny's ports of -pgcc 2.95 and gcc 3.2.1, in addition to EM's gcc 2.8.1. To use the -bsddb185 module with the gcc 3.2.1 build, I had to recompile the DB library -with gcc 3.2.1 - I don't know why, but trying to import the module built -against a DB library compiled with gcc 2.8.1 would result in a SYS3175 -error. - -I have not attempted to compile Python with any version of gcc prior to -v2.8.1. - -This release sees the default optimisation change to -"-O3 -fomit-frame-pointer -mprobe". This works fine too for pgcc 2.95 -but not for gcc 3.2.1. - -With gcc 3.2.1, -O3 causes 2 unexpected test failures: test_format and -test_unicode. Both these tests pass if -O2 is instead of -O3 with this -compiler, and the performance difference is negligible (in contrast to -gcc 2.8.1 and pgcc 2.95, where the performance difference between the -2 optimisation settings approaches 10%). - -17. os.spawnv() and os.spawnve() expose EMX's library routines rather -than use the emulation in os.py. - -In order to make use of some of the features this makes available in -the OS/2 environment, you should peruse the relevant EMX documentation -(EMXLIB.INF in the EMXVIEW.ZIP archive accompanying the EMX archives -on Hobbes or LEO). Be aware that I have exposed all the "mode" options -supported by EMX, but there are combinations that either cannot be -practically used by/in Python or have the potential to compromise your -system's stability. - -18. pythonpm.exe used to be just python.exe with the WINDOWAPI linker -option set in the pythonpm.def file. In practice, this turns out to do -nothing useful. - -I have written a replacement which wraps the Python DLL in a genuine -Presentation Manager application. This version actually runs the -Python interpreter in a separate thread from the PM shell, in order -that PythonPM has a functioning message queue as good PM apps should. -In its current state, PythonPM's window is hidden. It can be displayed, -although it will have no content as nothing is ever written to the -window. Only the "hide" button is available. Although the code -has support for shutting PythonPM down when the Python interpreter is -still busy (via the "control" menu), this is not well tested and given -comments I've come across in EMX documentation suggesting that the -thread killing operation has problems I would suggest caution in -relying on this capability. - -PythonPM processes commandline parameters normally. The standard input, -output and error streams are only useful if redirected, as PythonPM's -window is not a console in any form and so cannot accept or display -anything. This means that the -i option is ineffective. - -Because the Python thread doesn't create its own message queue, creating -PM Windows and performing most PM operations is not possible from within -this thread. How this will affect supporting PM extensions (such as -Tkinter using a PM port of Tcl/Tk, or wxPython using the PM port of -WxWindows) is still being researched. - -Note that os.fork() _DOES_NOT_WORK_ in PythonPM - SYS3175s are the result -of trying. os.spawnv() _does_ work. PythonPM passes all regression tests -that the standard Python interpreter (python.exe) passes, with the exception -of test_fork1 and test_socket which both attempt to use os.fork(). - -I very much want feedback on the performance, behaviour and utility of -PythonPM. I would like to add a PM console capability to it, but that -will be a non-trivial effort. I may be able to leverage the code in -Illya Vaes' Tcl/Tk port, which would make it easier. - -19. os.chdir() uses EMX's _chdir2(), which supports changing both drive -and directory at once. Similarly, os.getcwd() uses EMX's _getcwd() -which returns drive as well as path. - -20. pyconfig.h is installed in the Include subdirectory with all -other include files. - -21. the default build explicitly sets the number of file handles -available to a Python process to 250. EMX default is 40, which is -insufficient for the tempfile regression test (test_tempfile) which -tries to create 100 temporary files. - -This setting can be overridden via the EMXOPT environment variable: - set EMXOPT=-h250 -is equivalent to the setting currently used. The emxbind utility (if you -have it installed) can also be used to permanently change the setting in -python.exe - please refer to the EMX documentation for more information. - -22. a pure python strptime module is now part of the Python standard -library, superceding a platform specific extension module. This module -leverages the strftime module, and as a result test_strptime fails -due to the EMX strftime bug in item 20 above. - -23. test_posixpath attempts to exercise various Posix path related -functionality. Most of the sub-tests pass, but the "ismount" and -"samestat" subtests fail: -- EMX provides not satisfactory mount point emulation, so "ismount" - cannot succeed; -- EMX documents that successive stat() calls will produce different - results, so "samestat" cannot succeed. - -test_posixpath should skip these tests on EMX. - -24. I have had a report that attempting to use the Bittorrent package -(http://bitconjurer.org/BitTorrent/) with this port causes traps not -long after starting the download; this using the "headless" download -script on eCS v1.1. I have not been able to duplicate this myself, -but the indications I have suggest a failure in the 32 bit TCP/IP -stack (v4.3.2? on eCS v1.1) - on my v4.0 FP12 system with MPTS fixpack -WR8425 applied (16 bit TCP/IP stack v4.02), BitTorrent appears to work -normally in testing on a 100Mbit LAN. With the curses.panel fix (see -item 13 above), the BitTorrent curses downloader works too. I'd -appreciate any success or failure reports with BitTorrent, though -I've regretfully recommended that the person who reported the failure -take this up with eCS support. Since this report, I have received a -followup which suggests that the problem may have been a buggy network -card driver. I think it suffices to say that BitTorrent is a fair stress -test of a system's networking capability. - -... probably other issues that I've not encountered, or don't remember :-( - -If you encounter other difficulties with this port, which can be -characterised as peculiar to this port rather than to the Python release, -I would like to hear about them. However I cannot promise to be able to do -anything to resolve such problems. See the Contact section below... - - -To do... --------- - -In no particular order of apparent importance or likelihood... - -- support Tkinter and/or alternative GUI (wxWindows??) - - -Credits -------- - -In addition to people identified above, I'd like to thank: -- the BDFL, Guido van Rossum, and crew for Python; -- Dr David Mertz, for trying out a pre-release of this port; -- the Python-list/comp.lang.python community; -- John Poltorak, for input about pwd/grp. - -Contact -------- - -Constructive feedback, negative or positive, about this port is welcome -and should be addressed to me at the e-mail addresses below. - -I have a private mailing list for announcements of fixes & updates to -this port. If you wish to receive such e-mail announcments, please send -me an e-mail requesting that you be added to this list. - -Andrew MacIntyre -E-mail: andymac@bullseye.apana.org.au, or andymac@pcug.org.au -Web: http://www.andymac.org/ - -2 December, 2003. diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/config.c b/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/config.c deleted file mode 100644 index 5dbe29cd..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/config.c +++ /dev/null @@ -1,180 +0,0 @@ -/* -*- C -*- *********************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI or Corporation for National Research Initiatives or -CNRI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -While CWI is the initial source for this software, a modified version -is made available by the Corporation for National Research Initiatives -(CNRI) at the Internet address ftp://ftp.python.org. - -STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH -CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Module configuration */ - -/* This file contains the table of built-in modules. - See init_builtin() in import.c. */ - -#include "Python.h" - -extern void initos2(); -extern void initsignal(); -#ifdef WITH_THREAD -extern void initthread(); -#endif -extern void init_codecs(); -extern void init_csv(); -extern void init_locale(); -extern void init_random(); -extern void init_sre(); -extern void init_symtable(); -extern void init_weakref(); -extern void initarray(); -extern void initbinascii(); -extern void initcPickle(); -extern void initcStringIO(); -extern void initcmath(); -extern void initdatetime(); -extern void initdl(); -extern void initerrno(); -extern void initfcntl(); -extern void initimageop(); -extern void inititertools(); -extern void initmath(); -extern void initmd5(); -extern void initoperator(); -extern void initpcre(); -extern void initregex(); -extern void initrgbimg(); -extern void initsha(); -extern void initstrop(); -extern void initstruct(); -extern void inittermios(); -extern void inittime(); -extern void inittiming(); -extern void initxreadlines(); -extern void initxxsubtype(); -extern void initzipimport(); -#if !HAVE_DYNAMIC_LOADING -extern void init_curses(); -extern void init_curses_panel(); -extern void init_hotshot(); -extern void init_testcapi(); -extern void initbsddb185(); -extern void initbz2(); -extern void initfpectl(); -extern void initfpetest(); -extern void initparser(); -extern void initpwd(); -extern void initrotor(); -extern void initunicodedata(); -extern void initzlib(); -#ifdef USE_SOCKET -extern void init_socket(); -extern void initselect(); -#endif -#endif -/* -- ADDMODULE MARKER 1 -- */ - -extern void PyMarshal_Init(); -extern void initimp(); -extern void initgc(); - -struct _inittab _PyImport_Inittab[] = { - - {"os2", initos2}, - {"signal", initsignal}, -#ifdef WITH_THREAD - {"thread", initthread}, -#endif - {"_codecs", init_codecs}, - {"_csv", init_csv}, - {"_locale", init_locale}, - {"_random", init_random}, - {"_sre", init_sre}, - {"_symtable", init_symtable}, - {"_weakref", init_weakref}, - {"array", initarray}, - {"binascii", initbinascii}, - {"cPickle", initcPickle}, - {"cStringIO", initcStringIO}, - {"cmath", initcmath}, - {"datetime", initdatetime}, - {"dl", initdl}, - {"errno", initerrno}, - {"fcntl", initfcntl}, - {"imageop", initimageop}, - {"itertools", inititertools}, - {"math", initmath}, - {"md5", initmd5}, - {"operator", initoperator}, - {"pcre", initpcre}, - {"regex", initregex}, - {"rgbimg", initrgbimg}, - {"sha", initsha}, - {"strop", initstrop}, - {"struct", initstruct}, - {"termios", inittermios}, - {"time", inittime}, - {"timing", inittiming}, - {"xreadlines", initxreadlines}, - {"xxsubtype", initxxsubtype}, - {"zipimport", initzipimport}, -#if !HAVE_DYNAMIC_LOADING - {"_curses", init_curses}, - {"_curses_panel", init_curses_panel}, - {"_hotshot", init_hotshot}, - {"_testcapi", init_testcapi}, - {"bsddb185", initbsddb185}, - {"bz2", initbz2}, - {"fpectl", initfpectl}, - {"fpetest", initfpetest}, - {"parser", initparser}, - {"pwd", initpwd}, - {"rotor", initrotor}, - {"unicodedata", initunicodedata}, - {"zlib", initzlib}, -#ifdef USE_SOCKET - {"_socket", init_socket}, - {"select", initselect}, -#endif -#endif -/* -- ADDMODULE MARKER 2 -- */ - - /* This module "lives in" with marshal.c */ - {"marshal", PyMarshal_Init}, - - /* This lives it with import.c */ - {"imp", initimp}, - - /* These entries are here for sys.builtin_module_names */ - {"__main__", NULL}, - {"__builtin__", NULL}, - {"sys", NULL}, - {"exceptions", NULL}, - - /* This lives in gcmodule.c */ - {"gc", initgc}, - - /* Sentinel */ - {0, 0} -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/dlfcn.c b/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/dlfcn.c deleted file mode 100644 index 25a805fe..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/dlfcn.c +++ /dev/null @@ -1,223 +0,0 @@ -/* -*- C -*- *********************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI or Corporation for National Research Initiatives or -CNRI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -While CWI is the initial source for this software, a modified version -is made available by the Corporation for National Research Initiatives -(CNRI) at the Internet address ftp://ftp.python.org. - -STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH -CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* This library implements dlopen() - Unix-like dynamic linking - * emulation functions for OS/2 using DosLoadModule() and company. - */ - -#define INCL_DOS -#define INCL_DOSERRORS -#define INCL_DOSSESMGR -#define INCL_WINPROGRAMLIST -#define INCL_WINFRAMEMGR -#include - -#include -#include -#include -#include - -typedef struct _track_rec { - char *name; - HMODULE handle; - void *id; - struct _track_rec *next; -} tDLLchain, *DLLchain; - -static DLLchain dlload = NULL; /* A simple chained list of DLL names */ -static char dlerr [256]; /* last error text string */ -static void *last_id; - -static DLLchain find_id(void *id) -{ - DLLchain tmp; - - for (tmp = dlload; tmp; tmp = tmp->next) - if (id == tmp->id) - return tmp; - - return NULL; -} - -/* load a dynamic-link library and return handle */ -void *dlopen(char *filename, int flags) -{ - HMODULE hm; - DLLchain tmp; - char err[256]; - char *errtxt; - int rc = 0, set_chain = 0; - - for (tmp = dlload; tmp; tmp = tmp->next) - if (strnicmp(tmp->name, filename, 999) == 0) - break; - - if (!tmp) - { - tmp = (DLLchain) malloc(sizeof(tDLLchain)); - if (!tmp) - goto nomem; - tmp->name = strdup(filename); - tmp->next = dlload; - set_chain = 1; - } - - switch (rc = DosLoadModule((PSZ)&err, sizeof(err), filename, &hm)) - { - case NO_ERROR: - tmp->handle = hm; - if (set_chain) - { - do - last_id++; - while ((last_id == 0) || (find_id(last_id))); - tmp->id = last_id; - dlload = tmp; - } - return tmp->id; - case ERROR_FILE_NOT_FOUND: - case ERROR_PATH_NOT_FOUND: - errtxt = "module `%s' not found"; - break; - case ERROR_TOO_MANY_OPEN_FILES: - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_SHARING_BUFFER_EXCEEDED: -nomem: - errtxt = "out of system resources"; - break; - case ERROR_ACCESS_DENIED: - errtxt = "access denied"; - break; - case ERROR_BAD_FORMAT: - case ERROR_INVALID_SEGMENT_NUMBER: - case ERROR_INVALID_ORDINAL: - case ERROR_INVALID_MODULETYPE: - case ERROR_INVALID_EXE_SIGNATURE: - case ERROR_EXE_MARKED_INVALID: - case ERROR_ITERATED_DATA_EXCEEDS_64K: - case ERROR_INVALID_MINALLOCSIZE: - case ERROR_INVALID_SEGDPL: - case ERROR_AUTODATASEG_EXCEEDS_64K: - case ERROR_RELOCSRC_CHAIN_EXCEEDS_SEGLIMIT: - errtxt = "invalid module format"; - break; - case ERROR_INVALID_NAME: - errtxt = "filename doesn't match module name"; - break; - case ERROR_SHARING_VIOLATION: - case ERROR_LOCK_VIOLATION: - errtxt = "sharing violation"; - break; - case ERROR_INIT_ROUTINE_FAILED: - errtxt = "module initialization failed"; - break; - default: - errtxt = "cause `%s', error code = %d"; - break; - } - snprintf(dlerr, sizeof(dlerr), errtxt, &err, rc); - if (tmp) - { - if (tmp->name) - free(tmp->name); - free(tmp); - } - return 0; -} - -/* return a pointer to the `symbol' in DLL */ -void *dlsym(void *handle, char *symbol) -{ - int rc = 0; - PFN addr; - char *errtxt; - int symord = 0; - DLLchain tmp = find_id(handle); - - if (!tmp) - goto inv_handle; - - if (*symbol == '#') - symord = atoi(symbol + 1); - - switch (rc = DosQueryProcAddr(tmp->handle, symord, symbol, &addr)) - { - case NO_ERROR: - return (void *)addr; - case ERROR_INVALID_HANDLE: -inv_handle: - errtxt = "invalid module handle"; - break; - case ERROR_PROC_NOT_FOUND: - case ERROR_INVALID_NAME: - errtxt = "no symbol `%s' in module"; - break; - default: - errtxt = "symbol `%s', error code = %d"; - break; - } - snprintf(dlerr, sizeof(dlerr), errtxt, symbol, rc); - return NULL; -} - -/* free dynamicaly-linked library */ -int dlclose(void *handle) -{ - int rc; - DLLchain tmp = find_id(handle); - - if (!tmp) - goto inv_handle; - - switch (rc = DosFreeModule(tmp->handle)) - { - case NO_ERROR: - free(tmp->name); - dlload = tmp->next; - free(tmp); - return 0; - case ERROR_INVALID_HANDLE: -inv_handle: - strcpy(dlerr, "invalid module handle"); - return -1; - case ERROR_INVALID_ACCESS: - strcpy(dlerr, "access denied"); - return -1; - default: - return -1; - } -} - -/* return a string describing last occured dl error */ -char *dlerror() -{ - return dlerr; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/dlfcn.h b/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/dlfcn.h deleted file mode 100644 index 833ef9b0..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/dlfcn.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- C -*- *********************************************** -Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI or Corporation for National Research Initiatives or -CNRI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -While CWI is the initial source for this software, a modified version -is made available by the Corporation for National Research Initiatives -(CNRI) at the Internet address ftp://ftp.python.org. - -STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH -CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* This library implements dlopen() - Unix-like dynamic linking - * emulation functions for OS/2 using DosLoadModule() and company. - */ - -#ifndef _DLFCN_H -#define _DLFCN_H - -/* load a dynamic-link library and return handle */ -void *dlopen(char *filename, int flags); - -/* return a pointer to the `symbol' in DLL */ -void *dlsym(void *handle, char *symbol); - -/* free dynamicaly-linked library */ -int dlclose(void *handle); - -/* return a string describing last occured dl error */ -char *dlerror(void); - -#endif /* !_DLFCN_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/dllentry.c b/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/dllentry.c deleted file mode 100644 index 20baff37..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/dllentry.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This is the entry point for the Python 2.3 core DLL. - */ - -#define NULL 0 - -#define REF(s) extern void s(); void *____ref_##s = &s; - -/* Make references to imported symbols to pull them from static library */ -REF(Py_Main); - -#include - -extern int _CRT_init(void); -extern void _CRT_term(void); -extern void __ctordtorInit(void); -extern void __ctordtorTerm(void); - -unsigned long _DLL_InitTerm(unsigned long mod_handle, unsigned long flag) -{ - switch (flag) - { - case 0: - if (_CRT_init()) - return 0; - __ctordtorInit(); - - /* Ignore fatal signals */ - signal(SIGSEGV, SIG_IGN); - signal(SIGFPE, SIG_IGN); - - return 1; - - case 1: - __ctordtorTerm(); - _CRT_term(); - return 1; - - default: - return 0; - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/getpathp.c b/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/getpathp.c deleted file mode 100644 index 183ce703..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/getpathp.c +++ /dev/null @@ -1,407 +0,0 @@ - -/* Return the initial module search path. */ -/* This version used by OS/2+EMX */ - -/* ---------------------------------------------------------------- - PATH RULES FOR OS/2+EMX: - This describes how sys.path is formed on OS/2+EMX. It describes the - functionality, not the implementation (ie, the order in which these - are actually fetched is different) - - * Python always adds an empty entry at the start, which corresponds - to the current directory. - - * If the PYTHONPATH env. var. exists, it's entries are added next. - - * We attempt to locate the "Python Home" - if the PYTHONHOME env var - is set, we believe it. Otherwise, we use the path of our host .EXE's - to try and locate our "landmark" (lib\\os.py) and deduce our home. - - If we DO have a Python Home: The relevant sub-directories (Lib, - plat-win, lib-tk, etc) are based on the Python Home - - If we DO NOT have a Python Home, the core Python Path is - loaded from the registry. This is the main PythonPath key, - and both HKLM and HKCU are combined to form the path) - - * Iff - we can not locate the Python Home, and have not had a PYTHONPATH - specified (ie, we have _nothing_ we can assume is a good path), a - default path with relative entries is used (eg. .\Lib;.\plat-win, etc) - - - The end result of all this is: - * When running python.exe, or any other .exe in the main Python directory - (either an installed version, or directly from the PCbuild directory), - the core path is deduced. - - * When Python is hosted in another exe (different directory, embedded via - COM, etc), the Python Home will not be deduced, so the core path from - the registry is used. Other "application paths "in the registry are - always read. - - * If Python can't find its home and there is no registry (eg, frozen - exe, some very strange installation setup) you get a path with - some default, but relative, paths. - - ---------------------------------------------------------------- */ - - -#include "Python.h" -#include "osdefs.h" - -#ifndef PYOS_OS2 -#error This file only compilable on OS/2 -#endif - -#define INCL_DOS -#include - -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#endif /* HAVE_UNISTD_H */ - -/* Search in some common locations for the associated Python libraries. - * - * Py_GetPath() tries to return a sensible Python module search path. - * - * The approach is an adaptation for Windows of the strategy used in - * ../Modules/getpath.c; it uses the Windows Registry as one of its - * information sources. - */ - -#ifndef LANDMARK -#if defined(PYCC_GCC) -#define LANDMARK "lib/os.py" -#else -#define LANDMARK "lib\\os.py" -#endif -#endif - -static char prefix[MAXPATHLEN+1]; -static char progpath[MAXPATHLEN+1]; -static char *module_search_path = NULL; - - -static int -is_sep(char ch) /* determine if "ch" is a separator character */ -{ -#ifdef ALTSEP - return ch == SEP || ch == ALTSEP; -#else - return ch == SEP; -#endif -} - -/* assumes 'dir' null terminated in bounds. - * Never writes beyond existing terminator. - */ -static void -reduce(char *dir) -{ - size_t i = strlen(dir); - while (i > 0 && !is_sep(dir[i])) - --i; - dir[i] = '\0'; -} - -static int -exists(char *filename) -{ - struct stat buf; - return stat(filename, &buf) == 0; -} - -/* Is module (check for .pyc/.pyo too) - * Assumes 'filename' MAXPATHLEN+1 bytes long - - * may extend 'filename' by one character. - */ -static int -ismodule(char *filename) -{ - if (exists(filename)) - return 1; - - /* Check for the compiled version of prefix. */ - if (strlen(filename) < MAXPATHLEN) { - strcat(filename, Py_OptimizeFlag ? "o" : "c"); - if (exists(filename)) - return 1; - } - return 0; -} - -/* guarantees buffer will never overflow MAXPATHLEN+1 bytes */ -static void -join(char *buffer, char *stuff) -{ - size_t n, k; - if (is_sep(stuff[0])) - n = 0; - else { - n = strlen(buffer); - if (n > 0 && !is_sep(buffer[n-1]) && n < MAXPATHLEN) - buffer[n++] = SEP; - } - k = strlen(stuff); - if (n + k > MAXPATHLEN) - k = MAXPATHLEN - n; - strncpy(buffer+n, stuff, k); - buffer[n+k] = '\0'; -} - -/* gotlandmark only called by search_for_prefix, which ensures - * 'prefix' is null terminated in bounds. join() ensures - * 'landmark' can not overflow prefix if too long. - */ -static int -gotlandmark(char *landmark) -{ - int n, ok; - - n = strlen(prefix); - join(prefix, landmark); - ok = ismodule(prefix); - prefix[n] = '\0'; - return ok; -} - -/* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd. - * assumption provided by only caller, calculate_path() - */ -static int -search_for_prefix(char *argv0_path, char *landmark) -{ - /* Search from argv0_path, until landmark is found */ - strcpy(prefix, argv0_path); - do { - if (gotlandmark(landmark)) - return 1; - reduce(prefix); - } while (prefix[0]); - return 0; -} - - -static void -get_progpath(void) -{ - extern char *Py_GetProgramName(void); - char *path = getenv("PATH"); - char *prog = Py_GetProgramName(); - - PPIB pib; - if ((DosGetInfoBlocks(NULL, &pib) == 0) && - (DosQueryModuleName(pib->pib_hmte, sizeof(progpath), progpath) == 0)) - return; - - if (prog == NULL || *prog == '\0') - prog = "python"; - - /* If there is no slash in the argv0 path, then we have to - * assume python is on the user's $PATH, since there's no - * other way to find a directory to start the search from. If - * $PATH isn't exported, you lose. - */ -#ifdef ALTSEP - if (strchr(prog, SEP) || strchr(prog, ALTSEP)) -#else - if (strchr(prog, SEP)) -#endif - strncpy(progpath, prog, MAXPATHLEN); - else if (path) { - while (1) { - char *delim = strchr(path, DELIM); - - if (delim) { - size_t len = delim - path; - /* ensure we can't overwrite buffer */ -#if !defined(PYCC_GCC) - len = min(MAXPATHLEN,len); -#else - len = MAXPATHLEN < len ? MAXPATHLEN : len; -#endif - strncpy(progpath, path, len); - *(progpath + len) = '\0'; - } - else - strncpy(progpath, path, MAXPATHLEN); - - /* join() is safe for MAXPATHLEN+1 size buffer */ - join(progpath, prog); - if (exists(progpath)) - break; - - if (!delim) { - progpath[0] = '\0'; - break; - } - path = delim + 1; - } - } - else - progpath[0] = '\0'; -} - -static void -calculate_path(void) -{ - char argv0_path[MAXPATHLEN+1]; - char *buf; - size_t bufsz; - char *pythonhome = Py_GetPythonHome(); - char *envpath = getenv("PYTHONPATH"); - char zip_path[MAXPATHLEN+1]; - size_t len; - - get_progpath(); - /* progpath guaranteed \0 terminated in MAXPATH+1 bytes. */ - strcpy(argv0_path, progpath); - reduce(argv0_path); - if (pythonhome == NULL || *pythonhome == '\0') { - if (search_for_prefix(argv0_path, LANDMARK)) - pythonhome = prefix; - else - pythonhome = NULL; - } - else - strncpy(prefix, pythonhome, MAXPATHLEN); - - if (envpath && *envpath == '\0') - envpath = NULL; - - /* Calculate zip archive path */ - strncpy(zip_path, progpath, MAXPATHLEN); - zip_path[MAXPATHLEN] = '\0'; - len = strlen(zip_path); - if (len > 4) { - zip_path[len-3] = 'z'; /* change ending to "zip" */ - zip_path[len-2] = 'i'; - zip_path[len-1] = 'p'; - } - else { - zip_path[0] = 0; - } - - /* We need to construct a path from the following parts. - * (1) the PYTHONPATH environment variable, if set; - * (2) the zip archive file path; - * (3) the PYTHONPATH config macro, with the leading "." - * of each component replaced with pythonhome, if set; - * (4) the directory containing the executable (argv0_path). - * The length calculation calculates #3 first. - */ - - /* Calculate size of return buffer */ - if (pythonhome != NULL) { - char *p; - bufsz = 1; - for (p = PYTHONPATH; *p; p++) { - if (*p == DELIM) - bufsz++; /* number of DELIM plus one */ - } - bufsz *= strlen(pythonhome); - } - else - bufsz = 0; - bufsz += strlen(PYTHONPATH) + 1; - bufsz += strlen(argv0_path) + 1; - bufsz += strlen(zip_path) + 1; - if (envpath != NULL) - bufsz += strlen(envpath) + 1; - - module_search_path = buf = malloc(bufsz); - if (buf == NULL) { - /* We can't exit, so print a warning and limp along */ - fprintf(stderr, "Can't malloc dynamic PYTHONPATH.\n"); - if (envpath) { - fprintf(stderr, "Using environment $PYTHONPATH.\n"); - module_search_path = envpath; - } - else { - fprintf(stderr, "Using default static path.\n"); - module_search_path = PYTHONPATH; - } - return; - } - - if (envpath) { - strcpy(buf, envpath); - buf = strchr(buf, '\0'); - *buf++ = DELIM; - } - if (zip_path[0]) { - strcpy(buf, zip_path); - buf = strchr(buf, '\0'); - *buf++ = DELIM; - } - - if (pythonhome == NULL) { - strcpy(buf, PYTHONPATH); - buf = strchr(buf, '\0'); - } - else { - char *p = PYTHONPATH; - char *q; - size_t n; - for (;;) { - q = strchr(p, DELIM); - if (q == NULL) - n = strlen(p); - else - n = q-p; - if (p[0] == '.' && is_sep(p[1])) { - strcpy(buf, pythonhome); - buf = strchr(buf, '\0'); - p++; - n--; - } - strncpy(buf, p, n); - buf += n; - if (q == NULL) - break; - *buf++ = DELIM; - p = q+1; - } - } - if (argv0_path) { - *buf++ = DELIM; - strcpy(buf, argv0_path); - buf = strchr(buf, '\0'); - } - *buf = '\0'; -} - - -/* External interface */ - -char * -Py_GetPath(void) -{ - if (!module_search_path) - calculate_path(); - return module_search_path; -} - -char * -Py_GetPrefix(void) -{ - if (!module_search_path) - calculate_path(); - return prefix; -} - -char * -Py_GetExecPrefix(void) -{ - return Py_GetPrefix(); -} - -char * -Py_GetProgramFullPath(void) -{ - if (!module_search_path) - calculate_path(); - return progpath; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/pyconfig.h b/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/pyconfig.h deleted file mode 100644 index 79d54cb0..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/pyconfig.h +++ /dev/null @@ -1,327 +0,0 @@ -#ifndef Py_CONFIG_H -#define Py_CONFIG_H - -/* config.h. - * At some time in the past, generated automatically by/from configure. - * now maintained manually. - */ - -/* build environment */ -#define PLATFORM "os2emx" -#define COMPILER "[EMX GCC " __VERSION__ "]" -#define PYOS_OS2 1 -#define PYCC_GCC 1 - -/* default location(s) */ -#ifndef PREFIX -#define PREFIX "" -#endif -#ifndef PYTHONPATH -#define PYTHONPATH "./Lib;./Lib/plat-" PLATFORM \ - ";./Lib/lib-dynload;./Lib/site-packages" -#endif - -/* Debugging */ -#ifndef Py_DEBUG -/*#define Py_DEBUG 1*/ -#endif - -/* if building an extension or wrapper executable, - * mark Python API symbols "extern" so that symbols - * imported from the Python core DLL aren't duplicated. - */ -#ifdef Py_BUILD_CORE -# define PyAPI_FUNC(RTYPE) RTYPE -#else -# define PyAPI_FUNC(RTYPE) extern RTYPE -#endif -#define PyAPI_DATA(RTYPE) extern RTYPE -#define PyMODINIT_FUNC void - -/* Use OS/2 flavour of threads */ -#define WITH_THREAD 1 -#define OS2_THREADS 1 - -/* We want sockets */ -#define TCPIPV4 1 -#define USE_SOCKET 1 -#define socklen_t int - -/* enable the Python object allocator */ -#define WITH_PYMALLOC 1 - -/* enable the GC module */ -#define WITH_CYCLE_GC 1 - -/* Define if you want to read files with foreign newlines. */ -#define WITH_UNIVERSAL_NEWLINES 1 - -/* Define if you want documentation strings in extension modules */ -#define WITH_DOC_STRINGS 1 - -/* Unicode related */ -#define Py_USING_UNICODE 1 -#define PY_UNICODE_TYPE wchar_t -#define Py_UNICODE_SIZE SIZEOF_SHORT - -/* system capabilities */ -#define HAVE_TTYNAME 1 -#define HAVE_WAIT 1 -#define HAVE_GETEGID 1 -#define HAVE_GETEUID 1 -#define HAVE_GETGID 1 -#define HAVE_GETPPID 1 -#define HAVE_GETUID 1 -#define HAVE_OPENDIR 1 -#define HAVE_PIPE 1 -#define HAVE_POPEN 1 -#define HAVE_SYSTEM 1 -#define HAVE_TTYNAME 1 -#define HAVE_DYNAMIC_LOADING 1 - -/* if port of GDBM installed, it includes NDBM emulation */ -#define HAVE_NDBM_H 1 - -/* need this for spawnv code in posixmodule (cloned from WIN32 def'n) */ -typedef long intptr_t; - -/* we don't have tm_zone but do have the external array tzname */ -#define HAVE_TZNAME 1 - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - -/* Define this if you have the type long long. */ -#define HAVE_LONG_LONG 1 - -/* Define if your compiler supports function prototypes. */ -#define HAVE_PROTOTYPES 1 - -/* Define if your compiler supports variable length function prototypes - * (e.g. void fprintf(FILE *, char *, ...);) *and* . - */ -#define HAVE_STDARG_PROTOTYPES 1 - -/* Define if malloc(0) returns a NULL pointer. */ -#define MALLOC_ZERO_RETURNS_NULL 1 - -/* Define to force use of thread-safe errno, h_errno, and other functions. */ -#define _REENTRANT 1 - -/* Define if you can safely include both and - * (which you can't on SCO ODT 3.0). - */ -#define SYS_SELECT_WITH_SYS_TIME 1 - -/* The number of bytes in an off_t. */ -#define SIZEOF_OFF_T 4 - -/* The number of bytes in an time_t. */ -#define SIZEOF_TIME_T 4 - -/* The number of bytes in a short. */ -#define SIZEOF_SHORT 2 - -/* The number of bytes in a int. */ -#define SIZEOF_INT 4 - -/* The number of bytes in a long. */ -#define SIZEOF_LONG 4 - -/* The number of bytes in a long long. */ -#define SIZEOF_LONG_LONG 8 - -/* The number of bytes in a void *. */ -#define SIZEOF_VOID_P 4 - -/* Define if you have the alarm function. */ -#define HAVE_ALARM 1 - -/* Define if you have the clock function. */ -#define HAVE_CLOCK 1 - -/* Define if you have the dup2 function. */ -#define HAVE_DUP2 1 - -/* Define if you have the execv function. */ -#define HAVE_EXECV 1 - -/* Define if you have the spawnv function. */ -#define HAVE_SPAWNV 1 - -/* Define if you have the flock function. */ -#define HAVE_FLOCK 1 - -/* Define if you have the fork function. */ -#define HAVE_FORK 1 - -/* Define if you have the fsync function. */ -#define HAVE_FSYNC 1 - -/* Define if you have the ftime function. */ -#define HAVE_FTIME 1 - -/* Define if you have the ftruncate function. */ -#define HAVE_FTRUNCATE 1 - -/* Define if you have the getcwd function. */ -#define HAVE_GETCWD 1 - -/* Define if you have the getpeername function. */ -#define HAVE_GETPEERNAME 1 - -/* Define if you have the getpgrp function. */ -#define HAVE_GETPGRP 1 - -/* Define if you have the getpid function. */ -#define HAVE_GETPID 1 - -/* Define if you have the getpwent function. */ -#define HAVE_GETPWENT 1 - -/* Define if you have the gettimeofday function. */ -#define HAVE_GETTIMEOFDAY 1 - -/* Define if you have the getwd function. */ -#define HAVE_GETWD 1 - -/* Define if you have the hypot function. */ -#define HAVE_HYPOT 1 - -/* Define if you have the kill function. */ -#define HAVE_KILL 1 - -/* Define if you have the memmove function. */ -#define HAVE_MEMMOVE 1 - -/* Define if you have the mktime function. */ -#define HAVE_MKTIME 1 - -/* Define if you have the pause function. */ -#define HAVE_PAUSE 1 - -/* Define if you have the putenv function. */ -#define HAVE_PUTENV 1 - -/* Define if you have the select function. */ -#define HAVE_SELECT 1 - -/* Define if you have the setgid function. */ -#define HAVE_SETGID 1 - -/* Define if you have the setlocale function. */ -#define HAVE_SETLOCALE 1 - -/* Define if you have the setpgid function. */ -#define HAVE_SETPGID 1 - -/* Define if you have the setuid function. */ -#define HAVE_SETUID 1 - -/* Define if you have the setvbuf function. */ -#define HAVE_SETVBUF 1 - -/* Define if you have the sigaction function. */ -#define HAVE_SIGACTION 1 - -/* Define if you have the strdup function. */ -#define HAVE_STRDUP 1 - -/* Define if you have the strerror function. */ -#define HAVE_STRERROR 1 - -/* Define if you have the strftime function. */ -#define HAVE_STRFTIME 1 - -/* Define if you have the strptime function. */ -#define HAVE_STRPTIME 1 - -/* Define if you have the tcgetpgrp function. */ -#define HAVE_TCGETPGRP 1 - -/* Define if you have the tcsetpgrp function. */ -#define HAVE_TCSETPGRP 1 - -/* Define if you have the tmpfile function. */ -#define HAVE_TMPFILE 1 - -/* Define if you have the times function. */ -#define HAVE_TIMES 1 - -/* Define if you have the truncate function. */ -#define HAVE_TRUNCATE 1 - -/* Define if you have the uname function. */ -#define HAVE_UNAME 1 - -/* Define if you have the waitpid function. */ -#define HAVE_WAITPID 1 - -/* Define if you have the header file. */ -#define HAVE_DIRENT_H 1 - -/* Define if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define if you have the header file. */ -#define HAVE_LOCALE_H 1 - -/* Define if you have the header file. */ -#define HAVE_NCURSES_H 1 - -/* Define if you have the header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDARG_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_SELECT_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_TIMES_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_UN_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_UTSNAME_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the header file. */ -#define HAVE_UTIME_H 1 - -/* EMX has an snprintf(). */ -#define HAVE_SNPRINTF 1 - -#endif /* !Py_CONFIG_H */ - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/python23.def b/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/python23.def deleted file mode 100644 index c2050d37..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/python23.def +++ /dev/null @@ -1,1161 +0,0 @@ -LIBRARY python23 INITINSTANCE TERMINSTANCE -DESCRIPTION "Python 2.3 Core DLL" -PROTMODE -DATA MULTIPLE NONSHARED -EXPORTS - -; From python23_s.lib(config) - "_PyImport_Inittab" - -; From python23_s.lib(dlfcn) -; "dlopen" -; "dlsym" -; "dlclose" -; "dlerror" - -; From python23_s.lib(getpathp) - "Py_GetProgramFullPath" - "Py_GetPrefix" - "Py_GetExecPrefix" - "Py_GetPath" - -; From python23_s.lib(getbuildinfo) - "Py_GetBuildInfo" - -; From python23_s.lib(main) - "Py_Main" - "Py_GetArgcArgv" - -; From python23_s.lib(acceler) - "PyGrammar_AddAccelerators" - "PyGrammar_RemoveAccelerators" - -; From python23_s.lib(grammar1) - "PyGrammar_FindDFA" - "PyGrammar_LabelRepr" - -; From python23_s.lib(listnode) - "PyNode_ListTree" - -; From python23_s.lib(node) - "PyNode_AddChild" - "PyNode_New" - "PyNode_Free" - -; From python23_s.lib(parser) - "PyParser_AddToken" - "PyParser_New" - "PyParser_Delete" - -; From python23_s.lib(parsetok) - "Py_TabcheckFlag" - "PyParser_ParseString" - "PyParser_ParseStringFlags" - "PyParser_ParseFile" - "PyParser_ParseFileFlags" - "PyParser_ParseStringFlagsFilename" - -; From python23_s.lib(bitset) - "_Py_newbitset" - "_Py_delbitset" - "_Py_addbit" - "_Py_samebitset" - "_Py_mergebitset" - -; From python23_s.lib(metagrammar) - "_Py_meta_grammar" - "Py_meta_grammar" - -; From python23_s.lib(tokenizer) - "PyToken_OneChar" - "PyToken_TwoChars" - "PyToken_ThreeChars" - "PyTokenizer_FromString" - "PyTokenizer_FromFile" - "PyTokenizer_Free" - "PyTokenizer_Get" - "_PyParser_TokenNames" - -; From python23_s.lib(myreadline) - "PyOS_ReadlineFunctionPointer" - "PyOS_StdioReadline" - "PyOS_Readline" - "PyOS_InputHook" - -; From python23_s.lib(abstract) - "PyObject_GetItem" - "PySequence_GetItem" - "PyObject_SetItem" - "PySequence_SetItem" - "PyObject_DelItem" - "PySequence_DelItem" - "PyNumber_Multiply" - "PyNumber_InPlaceAdd" - "PyNumber_InPlaceMultiply" - "PyNumber_Int" - "PyNumber_Long" - "PyNumber_Float" - "PySequence_GetSlice" - "PySequence_SetSlice" - "PySequence_Tuple" - "PyObject_GetIter" - "PyIter_Next" - "PySequence_List" - "_PySequence_IterSearch" - "PyObject_CallFunction" - "PyObject_CallMethod" - "PyObject_CallMethodObjArgs" - "PyObject_CallFunctionObjArgs" - "PyObject_IsInstance" - "PyObject_IsSubclass" - "PyObject_Cmp" - "PyObject_Call" - "PyObject_CallObject" - "PyObject_Type" - "PyObject_Size" - "PyMapping_Size" - "PyObject_Length" - "PyObject_DelItemString" - "PyObject_AsCharBuffer" - "PyObject_CheckReadBuffer" - "PyObject_AsReadBuffer" - "PyObject_AsWriteBuffer" - "PyNumber_Check" - "PyNumber_Add" - "PyNumber_Subtract" - "PyNumber_Divide" - "PyNumber_FloorDivide" - "PyNumber_TrueDivide" - "PyNumber_Remainder" - "PyNumber_Divmod" - "PyNumber_Power" - "PyNumber_Negative" - "PyNumber_Positive" - "PyNumber_Absolute" - "PyNumber_Invert" - "PyNumber_Lshift" - "PyNumber_Rshift" - "PyNumber_And" - "PyNumber_Xor" - "PyNumber_Or" - "PyNumber_InPlaceSubtract" - "PyNumber_InPlaceDivide" - "PyNumber_InPlaceFloorDivide" - "PyNumber_InPlaceTrueDivide" - "PyNumber_InPlaceRemainder" - "PyNumber_InPlacePower" - "PyNumber_InPlaceLshift" - "PyNumber_InPlaceRshift" - "PyNumber_InPlaceAnd" - "PyNumber_InPlaceXor" - "PyNumber_InPlaceOr" - "PySequence_Check" - "PySequence_Size" - "PySequence_Length" - "PySequence_Concat" - "PySequence_Repeat" - "PySequence_DelSlice" - "PySequence_Fast" - "PySequence_Count" - "PySequence_Contains" - "PySequence_In" - "PySequence_Index" - "PySequence_InPlaceConcat" - "PySequence_InPlaceRepeat" - "PyMapping_Check" - "PyMapping_Length" - "PyMapping_HasKeyString" - "PyMapping_HasKey" - "PyMapping_GetItemString" - "PyMapping_SetItemString" - -; From python23_s.lib(boolobject) - "PyBool_FromLong" - "PyBool_Type" - "_Py_ZeroStruct" - "_Py_TrueStruct" - -; From python23_s.lib(bufferobject) - "PyBuffer_FromObject" - "PyBuffer_FromReadWriteObject" - "PyBuffer_FromMemory" - "PyBuffer_FromReadWriteMemory" - "PyBuffer_New" - "PyBuffer_Type" - -; From python23_s.lib(cellobject) - "PyCell_New" - "PyCell_Get" - "PyCell_Set" - "PyCell_Type" - -; From python23_s.lib(classobject) - "PyClass_New" - "PyClass_IsSubclass" - "PyInstance_New" - "PyInstance_NewRaw" - "PyMethod_New" - "PyMethod_Function" - "PyMethod_Self" - "PyMethod_Class" - "_PyInstance_Lookup" - "PyMethod_Fini" - "PyClass_Type" - "PyInstance_Type" - "PyMethod_Type" - -; From python23_s.lib(cobject) - "PyCObject_FromVoidPtr" - "PyCObject_FromVoidPtrAndDesc" - "PyCObject_AsVoidPtr" - "PyCObject_GetDesc" - "PyCObject_Import" - "PyCObject_Type" - -; From python23_s.lib(complexobject) - "_Py_c_pow" - "_Py_c_sum" - "_Py_c_diff" - "_Py_c_neg" - "_Py_c_prod" - "_Py_c_quot" - "PyComplex_FromCComplex" - "PyComplex_FromDoubles" - "PyComplex_RealAsDouble" - "PyComplex_ImagAsDouble" - "PyComplex_AsCComplex" - "PyComplex_Type" - -; From python23_s.lib(descrobject) - "PyWrapper_New" - "PyDescr_NewMethod" - "PyDescr_NewClassMethod" - "PyDescr_NewMember" - "PyDescr_NewGetSet" - "PyDescr_NewWrapper" - "PyDictProxy_New" - "PyWrapperDescr_Type" - "PyProperty_Type" - -; From python23_s.lib(dictobject) - "PyDict_SetItem" - "PyDict_DelItem" - "PyDict_Clear" - "PyDict_MergeFromSeq2" - "PyDict_Merge" - "PyDict_Copy" - "PyDict_Keys" - "PyDict_Values" - "PyDict_New" - "PyDict_GetItem" - "PyDict_Next" - "PyDict_Items" - "PyDict_Size" - "PyDict_Update" - "PyDict_GetItemString" - "PyDict_SetItemString" - "PyDict_DelItemString" - "PyDict_Type" - "PyDictIter_Type" - -; From python23_s.lib(enumobject) - "PyEnum_Type" - -; From python23_s.lib(fileobject) - "Py_UniversalNewlineFread" - "PyFile_GetLine" - "PyFile_SoftSpace" - "PyFile_WriteObject" - "PyFile_WriteString" - "PyObject_AsFileDescriptor" - "Py_UniversalNewlineFgets" - "PyFile_FromString" - "PyFile_SetBufSize" - "PyFile_SetEncoding" - "PyFile_FromFile" - "PyFile_AsFile" - "PyFile_Name" - "PyFile_Type" - -; From python23_s.lib(floatobject) - "PyFloat_FromString" - "PyFloat_AsDouble" - "PyFloat_Fini" - "_PyFloat_Pack4" - "_PyFloat_Pack8" - "PyFloat_FromDouble" - "PyFloat_AsReprString" - "PyFloat_AsString" - "_PyFloat_Unpack4" - "_PyFloat_Unpack8" - "PyFloat_AsStringEx" - "PyFloat_Type" - -; From python23_s.lib(frameobject) - "PyFrame_New" - "PyFrame_FastToLocals" - "PyFrame_LocalsToFast" - "_PyFrame_Init" - "PyFrame_Fini" - "PyFrame_BlockSetup" - "PyFrame_BlockPop" - "PyFrame_Type" - -; From python23_s.lib(funcobject) - "PyFunction_New" - "PyFunction_GetCode" - "PyFunction_GetGlobals" - "PyFunction_GetModule" - "PyFunction_GetDefaults" - "PyFunction_SetDefaults" - "PyFunction_GetClosure" - "PyFunction_SetClosure" - "PyClassMethod_New" - "PyStaticMethod_New" - "PyFunction_Type" - "PyClassMethod_Type" - "PyStaticMethod_Type" - -; From python23_s.lib(intobject) - "PyInt_AsLong" - "PyInt_AsUnsignedLongMask" - "PyInt_AsUnsignedLongLongMask" - "PyInt_FromString" - "PyInt_Fini" - "PyInt_FromUnicode" - "PyInt_FromLong" - "PyInt_GetMax" - "_PyInt_Init" - "PyInt_Type" - -; From python23_s.lib(iterobject) - "PySeqIter_New" - "PyCallIter_New" - "PySeqIter_Type" - "PyCallIter_Type" - -; From python23_s.lib(listobject) - "PyList_New" - "PyList_Insert" - "PyList_Append" - "PyList_Size" - "PyList_GetItem" - "PyList_SetItem" - "PyList_GetSlice" - "PyList_SetSlice" - "PyList_Sort" - "PyList_Reverse" - "PyList_AsTuple" - "PyList_Type" - "PyListIter_Type" - -; From python23_s.lib(longobject) - "PyLong_FromDouble" - "PyLong_AsLong" - "_PyLong_FromByteArray" - "_PyLong_AsByteArray" - "PyLong_AsDouble" - "PyLong_FromString" - "PyLong_FromLong" - "PyLong_FromUnsignedLong" - "PyLong_AsUnsignedLong" - "PyLong_AsUnsignedLongMask" - "_PyLong_AsScaledDouble" - "PyLong_FromVoidPtr" - "PyLong_AsVoidPtr" - "PyLong_FromLongLong" - "PyLong_FromUnsignedLongLong" - "PyLong_AsLongLong" - "PyLong_AsUnsignedLongLong" - "PyLong_AsUnsignedLongLongMask" - "PyLong_FromUnicode" - "_PyLong_Sign" - "_PyLong_NumBits" - "_PyLong_New" - "_PyLong_Copy" - "PyLong_Type" - -; From python23_s.lib(methodobject) - "PyCFunction_Call" - "Py_FindMethodInChain" - "PyCFunction_GetFunction" - "PyCFunction_GetSelf" - "PyCFunction_GetFlags" - "Py_FindMethod" - "PyCFunction_NewEx" - "PyCFunction_Fini" - "PyCFunction_New" - "PyCFunction_Type" - -; From python23_s.lib(moduleobject) - "PyModule_New" - "_PyModule_Clear" - "PyModule_GetDict" - "PyModule_GetName" - "PyModule_GetFilename" - "PyModule_Type" - -; From python23_s.lib(object) - "Py_DivisionWarningFlag" - "PyObject_Str" - "PyObject_Repr" - "PyObject_Unicode" - "PyObject_GetAttr" - "PyObject_IsTrue" - "PyNumber_CoerceEx" - "PyObject_Compare" - "PyObject_RichCompare" - "_Py_HashDouble" - "PyObject_Hash" - "PyObject_SetAttr" - "PyObject_GenericGetAttr" - "PyObject_GenericSetAttr" - "PyCallable_Check" - "PyObject_Dir" - "PyMem_Malloc" - "PyMem_Realloc" - "PyMem_Free" - "PyObject_Print" - "_PyObject_Dump" - "PyObject_RichCompareBool" - "PyObject_GetAttrString" - "PyObject_SetAttrString" - "PyObject_HasAttrString" - "PyObject_HasAttr" - "_PyObject_GetDictPtr" - "PyObject_SelfIter" - "PyObject_Not" - "PyNumber_Coerce" - "Py_ReprEnter" - "Py_ReprLeave" - "_Py_HashPointer" - "_PyTrash_deposit_object" - "_PyTrash_destroy_chain" - "PyObject_Init" - "PyObject_InitVar" - "_PyObject_New" - "_PyObject_NewVar" - "_PyObject_Del" - "_Py_ReadyTypes" - "_Py_NotImplementedStruct" - "_Py_NoneStruct" - "_Py_cobject_hack" - "_Py_abstract_hack" - "_PyTrash_delete_nesting" - "_PyTrash_delete_later" - -; From python23_s.lib(obmalloc) - "PyObject_Malloc" - "PyObject_Realloc" - "PyObject_Free" - -; From python23_s.lib(rangeobject) - "PyRange_New" - "PyRange_Type" - -; From python23_s.lib(sliceobject) - "PySlice_GetIndices" - "PySlice_GetIndicesEx" - "PySlice_New" - "_Py_EllipsisObject" - "PySlice_Type" - -; From python23_s.lib(stringobject) - "PyString_FromStringAndSize" - "PyString_InternInPlace" - "PyString_FromString" - "PyString_FromFormatV" - "PyString_AsString" - "_PyString_Resize" - "PyString_FromFormat" - "PyString_AsDecodedString" - "PyString_AsEncodedString" - "PyString_DecodeEscape" - "PyString_Size" - "PyString_Repr" - "PyString_AsStringAndSize" - "_PyString_FormatLong" - "PyString_Format" - "_Py_ReleaseInternedStrings" - "PyString_Concat" - "PyString_ConcatAndDel" - "_PyString_Eq" - "PyString_InternImmortal" - "PyString_InternFromString" - "_PyString_Join" - "PyString_Decode" - "PyString_Encode" - "PyString_AsEncodedObject" - "PyString_AsDecodedObject" - "PyString_Fini" - "PyString_Type" - "PyBaseString_Type" - -; From python23_s.lib(structseq) - "PyStructSequence_InitType" - "PyStructSequence_New" - "PyStructSequence_UnnamedField" - -; From python23_s.lib(tupleobject) - "PyTuple_New" - "_PyTuple_Resize" - "PyTuple_Size" - "PyTuple_GetItem" - "PyTuple_SetItem" - "PyTuple_GetSlice" - "PyTuple_Fini" - "PyTuple_Type" - "PyTupleIter_Type" - -; From python23_s.lib(typeobject) - "PyType_IsSubtype" - "_PyType_Lookup" - "PyType_Ready" - "PyType_GenericAlloc" - "_PyObject_SlotCompare" - "PyType_GenericNew" - "PyType_Type" - "PyBaseObject_Type" - "PySuper_Type" - -; From python23_s.lib(unicodeobject) - "PyUnicodeUCS2_Resize" - "PyUnicodeUCS2_FromOrdinal" - "PyUnicodeUCS2_FromObject" - "PyUnicodeUCS2_FromEncodedObject" - "PyUnicodeUCS2_Decode" - "PyUnicodeUCS2_GetDefaultEncoding" - "PyUnicodeUCS2_DecodeUTF8" - "PyUnicodeUCS2_DecodeLatin1" - "PyUnicodeUCS2_DecodeASCII" - "PyUnicodeUCS2_AsEncodedString" - "PyUnicodeUCS2_AsUTF8String" - "PyUnicodeUCS2_AsLatin1String" - "PyUnicodeUCS2_AsASCIIString" - "PyUnicode_DecodeUTF7" - "PyUnicode_EncodeUTF7" - "PyUnicodeUCS2_EncodeUTF8" - "PyUnicodeUCS2_DecodeUTF16" - "PyUnicodeUCS2_AsUTF16String" - "PyUnicodeUCS2_DecodeUnicodeEscape" - "PyUnicodeUCS2_DecodeRawUnicodeEscape" - "PyUnicodeUCS2_EncodeRawUnicodeEscape" - "PyUnicodeUCS2_DecodeCharmap" - "PyUnicodeUCS2_EncodeCharmap" - "PyUnicodeUCS2_TranslateCharmap" - "PyUnicodeUCS2_EncodeDecimal" - "PyUnicodeUCS2_Count" - "PyUnicodeUCS2_Find" - "PyUnicodeUCS2_Tailmatch" - "PyUnicodeUCS2_Join" - "PyUnicodeUCS2_Splitlines" - "PyUnicodeUCS2_Compare" - "PyUnicodeUCS2_Contains" - "PyUnicodeUCS2_Concat" - "_PyUnicode_XStrip" - "PyUnicodeUCS2_Replace" - "PyUnicodeUCS2_Split" - "PyUnicodeUCS2_Format" - "_PyUnicodeUCS2_Fini" - "PyUnicodeUCS2_FromUnicode" - "PyUnicodeUCS2_AsUnicode" - "PyUnicodeUCS2_GetSize" - "PyUnicodeUCS2_GetMax" - "_PyUnicodeUCS2_AsDefaultEncodedString" - "PyUnicodeUCS2_SetDefaultEncoding" - "PyUnicodeUCS2_Encode" - "PyUnicodeUCS2_EncodeUTF16" - "PyUnicodeUCS2_AsUnicodeEscapeString" - "PyUnicodeUCS2_EncodeUnicodeEscape" - "PyUnicodeUCS2_AsRawUnicodeEscapeString" - "PyUnicodeUCS2_EncodeLatin1" - "PyUnicodeUCS2_EncodeASCII" - "PyUnicodeUCS2_AsCharmapString" - "PyUnicodeUCS2_Translate" - "_PyUnicodeUCS2_Init" - "PyUnicode_Type" - -; From python23_s.lib(unicodectype) - "_PyUnicode_TypeRecords" - "_PyUnicodeUCS2_ToNumeric" - "_PyUnicodeUCS2_IsLowercase" - "_PyUnicodeUCS2_IsUppercase" - "_PyUnicodeUCS2_IsTitlecase" - "_PyUnicodeUCS2_IsWhitespace" - "_PyUnicodeUCS2_IsLinebreak" - "_PyUnicodeUCS2_ToLowercase" - "_PyUnicodeUCS2_ToUppercase" - "_PyUnicodeUCS2_ToTitlecase" - "_PyUnicodeUCS2_ToDecimalDigit" - "_PyUnicodeUCS2_ToDigit" - "_PyUnicodeUCS2_IsDecimalDigit" - "_PyUnicodeUCS2_IsDigit" - "_PyUnicodeUCS2_IsNumeric" - "_PyUnicodeUCS2_IsAlpha" - -; From python23_s.lib(weakrefobject) - "PyWeakref_NewRef" - "PyWeakref_NewProxy" - "PyObject_ClearWeakRefs" - "PyWeakref_GetObject" - "_PyWeakref_GetWeakrefCount" - "_PyWeakref_RefType" - "_PyWeakref_ProxyType" - "_PyWeakref_CallableProxyType" - -; From python23_s.lib(bltinmodule) - "_PyBuiltin_Init" - "Py_FileSystemDefaultEncoding" - -; From python23_s.lib(exceptions) - "PyExc_Exception" - "PyExc_TypeError" - "PyExc_StopIteration" - "PyExc_StandardError" - "PyExc_SystemExit" - "PyExc_KeyboardInterrupt" - "PyExc_ImportError" - "PyExc_EnvironmentError" - "PyExc_IOError" - "PyExc_OSError" - "PyExc_EOFError" - "PyExc_RuntimeError" - "PyExc_NotImplementedError" - "PyExc_NameError" - "PyExc_UnboundLocalError" - "PyExc_AttributeError" - "PyExc_SyntaxError" - "PyExc_IndentationError" - "PyExc_TabError" - "PyExc_AssertionError" - "PyExc_LookupError" - "PyExc_IndexError" - "PyExc_KeyError" - "PyExc_ArithmeticError" - "PyExc_OverflowError" - "PyExc_ZeroDivisionError" - "PyExc_FloatingPointError" - "PyExc_ValueError" - "PyExc_UnicodeError" - "PyExc_UnicodeEncodeError" - "PyExc_UnicodeDecodeError" - "PyExc_UnicodeTranslateError" - "PyExc_ReferenceError" - "PyExc_SystemError" - "PyExc_MemoryError" - "PyExc_Warning" - "PyExc_UserWarning" - "PyExc_DeprecationWarning" - "PyExc_PendingDeprecationWarning" - "PyExc_SyntaxWarning" - "PyExc_OverflowWarning" - "PyExc_RuntimeWarning" - "PyExc_FutureWarning" - "PyExc_MemoryErrorInst" - "PyUnicodeEncodeError_GetStart" - "PyUnicodeDecodeError_GetStart" - "PyUnicodeEncodeError_GetEnd" - "PyUnicodeDecodeError_GetEnd" - "_PyExc_Init" - "_PyExc_Fini" - "PyUnicodeDecodeError_Create" - "PyUnicodeEncodeError_Create" - "PyUnicodeTranslateError_Create" - "PyUnicodeEncodeError_GetEncoding" - "PyUnicodeDecodeError_GetEncoding" - "PyUnicodeEncodeError_GetObject" - "PyUnicodeDecodeError_GetObject" - "PyUnicodeTranslateError_GetObject" - "PyUnicodeTranslateError_GetStart" - "PyUnicodeEncodeError_SetStart" - "PyUnicodeDecodeError_SetStart" - "PyUnicodeTranslateError_SetStart" - "PyUnicodeTranslateError_GetEnd" - "PyUnicodeEncodeError_SetEnd" - "PyUnicodeDecodeError_SetEnd" - "PyUnicodeTranslateError_SetEnd" - "PyUnicodeEncodeError_GetReason" - "PyUnicodeDecodeError_GetReason" - "PyUnicodeTranslateError_GetReason" - "PyUnicodeEncodeError_SetReason" - "PyUnicodeDecodeError_SetReason" - "PyUnicodeTranslateError_SetReason" - -; From python23_s.lib(ceval) - "PyEval_CallObjectWithKeywords" - "PyEval_EvalCodeEx" - "_PyEval_SliceIndex" - "PyEval_GetFrame" - "PyEval_CallObject" - "PyEval_SetProfile" - "PyEval_SetTrace" - "PyEval_GetBuiltins" - "PyEval_GetGlobals" - "PyEval_GetLocals" - "PyEval_GetRestricted" - "PyEval_MergeCompilerFlags" - "Py_FlushLine" - "Py_AddPendingCall" - "Py_MakePendingCalls" - "Py_SetRecursionLimit" - "Py_GetRecursionLimit" - "PyEval_GetFuncName" - "PyEval_GetFuncDesc" - "PyEval_GetCallStats" - "PyEval_SaveThread" - "PyEval_RestoreThread" - "PyEval_InitThreads" - "PyEval_AcquireLock" - "PyEval_ReleaseLock" - "PyEval_AcquireThread" - "PyEval_ReleaseThread" - "PyEval_ReInitThreads" - "PyEval_EvalCode" - "_PyEval_CallTracing" - "_Py_CheckInterval" - "_Py_Ticker" - -; From python23_s.lib(compile) - "PyCode_New" - "PySymtable_Free" - "_Py_Mangle" - "PyNode_Compile" - "PyNode_CompileFlags" - "PyCode_Addr2Line" - "PyNode_CompileSymtable" - "Py_OptimizeFlag" - "PyCode_Type" - -; From python23_s.lib(codecs) - "_PyCodec_Lookup" - "PyCodec_StreamReader" - "PyCodec_StreamWriter" - "PyCodec_Encode" - "PyCodec_Decode" - "PyCodec_IgnoreErrors" - "PyCodec_ReplaceErrors" - "PyCodec_XMLCharRefReplaceErrors" - "PyCodec_BackslashReplaceErrors" - "PyCodec_Register" - "PyCodec_Encoder" - "PyCodec_Decoder" - "PyCodec_RegisterError" - "PyCodec_LookupError" - "PyCodec_StrictErrors" - -; From python23_s.lib(errors) - "PyErr_SetNone" - "PyErr_SetString" - "PyErr_ExceptionMatches" - "PyErr_GivenExceptionMatches" - "PyErr_NormalizeException" - "PyErr_Fetch" - "PyErr_Clear" - "PyErr_NoMemory" - "PyErr_SetFromErrnoWithFilenameObject" - "PyErr_Format" - "PyErr_NewException" - "PyErr_WriteUnraisable" - "PyErr_SyntaxLocation" - "PyErr_ProgramText" - "PyErr_SetObject" - "PyErr_Occurred" - "PyErr_Restore" - "PyErr_BadArgument" - "PyErr_SetFromErrno" - "PyErr_SetFromErrnoWithFilename" - "PyErr_BadInternalCall" - "_PyErr_BadInternalCall" - "PyErr_Warn" - "PyErr_WarnExplicit" - -; From python23_s.lib(frozen) - "PyImport_FrozenModules" - -; From python23_s.lib(frozenmain) - "Py_FrozenMain" - -; From python23_s.lib(future) - "PyNode_Future" - -; From python23_s.lib(getargs) - "PyArg_Parse" - "PyArg_ParseTuple" - "PyArg_ParseTupleAndKeywords" - "PyArg_UnpackTuple" - "PyArg_VaParse" - -; From python23_s.lib(getcompiler) - "Py_GetCompiler" - -; From python23_s.lib(getcopyright) - "Py_GetCopyright" - -; From python23_s.lib(getmtime) - "PyOS_GetLastModificationTime" - -; From python23_s.lib(getplatform) - "Py_GetPlatform" - -; From python23_s.lib(getversion) - "Py_GetVersion" - -; From python23_s.lib(graminit) - "_PyParser_Grammar" - -; From python23_s.lib(import) - "_PyImport_Init" - "_PyImportHooks_Init" - "PyImport_ImportModule" - "PyImport_Cleanup" - "_PyImport_FixupExtension" - "PyImport_AddModule" - "PyImport_ExecCodeModuleEx" - "PyImport_ImportFrozenModule" - "PyImport_ImportModuleEx" - "PyImport_ReloadModule" - "PyImport_Import" -; "initimp" - "_PyImport_Fini" - "PyImport_GetMagicNumber" - "PyImport_ExecCodeModule" - "PyImport_GetModuleDict" - "_PyImport_FindExtension" - "PyImport_AppendInittab" - "PyImport_ExtendInittab" - "PyImport_Inittab" - "_PyImport_Filetab" - -; From python23_s.lib(importdl) - "_PyImport_LoadDynamicModule" - -; From python23_s.lib(marshal) - "PyMarshal_ReadLongFromFile" - "PyMarshal_ReadLastObjectFromFile" - "PyMarshal_ReadObjectFromString" - "PyMarshal_ReadObjectFromFile" - "PyMarshal_WriteObjectToString" - "PyMarshal_WriteLongToFile" - "PyMarshal_WriteObjectToFile" - "PyMarshal_ReadShortFromFile" - "PyMarshal_Init" - -; From python23_s.lib(modsupport) - "Py_InitModule4" - "Py_BuildValue" - "Py_VaBuildValue" - "PyEval_CallFunction" - "PyEval_CallMethod" - "PyModule_AddObject" - "PyModule_AddIntConstant" - "PyModule_AddStringConstant" - "_Py_PackageContext" - -; From python23_s.lib(mysnprintf) - "PyOS_snprintf" - "PyOS_vsnprintf" - -; From python23_s.lib(mystrtoul) - "PyOS_strtoul" - "PyOS_strtol" - -; From python23_s.lib(pyfpe) - "PyFPE_dummy" - -; From python23_s.lib(pystate) - "PyInterpreterState_Clear" - "PyThreadState_Clear" - "PyGILState_Ensure" - "PyGILState_Release" - "PyInterpreterState_New" - "PyInterpreterState_Delete" - "PyThreadState_Delete" - "PyThreadState_New" - "PyThreadState_DeleteCurrent" - "PyThreadState_Get" - "PyThreadState_Swap" - "PyThreadState_GetDict" - "PyThreadState_SetAsyncExc" - "PyGILState_GetThisThreadState" - "PyInterpreterState_Head" - "PyInterpreterState_Next" - "PyInterpreterState_ThreadHead" - "PyThreadState_Next" - "_PyGILState_Init" - "_PyGILState_Fini" - "_PyThreadState_Current" - "_PyThreadState_GetFrame" - -; From python23_s.lib(pythonrun) - "Py_IgnoreEnvironmentFlag" - "Py_DebugFlag" - "Py_VerboseFlag" - "Py_NoSiteFlag" - "Py_InteractiveFlag" - "Py_FrozenFlag" - "Py_Initialize" - "Py_FatalError" - "Py_NewInterpreter" - "PyErr_Print" - "PyRun_InteractiveOneFlags" - "PyRun_SimpleFileExFlags" - "PyRun_FileExFlags" - "Py_Exit" - "PyErr_PrintEx" - "PyErr_Display" - "Py_SetProgramName" - "Py_GetProgramName" - "Py_SetPythonHome" - "Py_GetPythonHome" - "Py_Finalize" - "Py_IsInitialized" - "Py_EndInterpreter" - "PyRun_AnyFile" - "PyRun_AnyFileExFlags" - "PyRun_AnyFileEx" - "PyRun_AnyFileFlags" - "Py_FdIsInteractive" - "PyRun_InteractiveLoopFlags" - "PyRun_SimpleString" - "PyRun_SimpleStringFlags" - "PyRun_StringFlags" - "PyRun_SimpleFile" - "PyRun_SimpleFileEx" - "PyRun_InteractiveOne" - "PyRun_InteractiveLoop" - "PyParser_SimpleParseString" - "PyParser_SimpleParseFile" - "PyParser_SimpleParseStringFlags" - "PyParser_SimpleParseStringFlagsFilename" - "PyParser_SimpleParseFileFlags" - "PyRun_String" - "PyRun_File" - "PyRun_FileEx" - "PyRun_FileFlags" - "Py_CompileString" - "Py_CompileStringFlags" - "Py_SymtableString" - "Py_AtExit" - "PyOS_getsig" - "PyOS_setsig" - "PyParser_SetError" - "PyParser_SimpleParseStringFilename" - "Py_UseClassExceptionsFlag" - "Py_UnicodeFlag" - "_Py_QnewFlag" - "PyModule_WarningsModule" - "_PyThread_Started" - -; From python23_s.lib(structmember) - "PyMember_Get" - "PyMember_GetOne" - "PyMember_SetOne" - "PyMember_Set" - -; From python23_s.lib(symtable) - "PySymtableEntry_New" - "PySymtableEntry_Type" - -; From python23_s.lib(sysmodule) - "_PySys_Init" - "PySys_SetPath" - "PySys_SetArgv" - "PySys_WriteStdout" - "PySys_WriteStderr" - "PySys_GetObject" - "PySys_SetObject" - "PySys_GetFile" - "PySys_ResetWarnOptions" - "PySys_AddWarnOption" - -; From python23_s.lib(traceback) - "PyTraceBack_Here" - "PyTraceBack_Print" - "PyTraceBack_Type" - -; From python23_s.lib(getopt) - "_PyOS_GetOpt" - "_PyOS_opterr" - "_PyOS_optind" - "_PyOS_optarg" - -; From python23_s.lib(dynload_shlib) - "_PyImport_DynLoadFiletab" - "_PyImport_GetDynLoadFunc" - -; From python23_s.lib(thread) - "PyThread_delete_key_value" - "PyThread_init_thread" - "PyThread_start_new_thread" - "PyThread_exit_thread" - "PyThread_get_thread_ident" - "PyThread_allocate_lock" - "PyThread_free_lock" - "PyThread_acquire_lock" - "PyThread_release_lock" - "PyThread_create_key" - "PyThread_delete_key" - "PyThread_set_key_value" - "PyThread_get_key_value" - "PyThread__exit_thread" - -; From python23_s.lib(gcmodule) -; "initgc" - "_PyObject_GC_New" - "_PyObject_GC_NewVar" - "PyGC_Collect" - "_PyObject_GC_Resize" - "_PyObject_GC_Malloc" - "PyObject_GC_Track" - "PyObject_GC_UnTrack" - "PyObject_GC_Del" - "_PyGC_Dump" - "_PyObject_GC_Track" - "_PyObject_GC_UnTrack" - "_PyObject_GC_Del" - "_PyGC_generation0" - -; From python23_s.lib(signalmodule) -; "initsignal" - "PyErr_CheckSignals" - "PyErr_SetInterrupt" - "PyOS_FiniInterrupts" - "PyOS_InterruptOccurred" - "PyOS_InitInterrupts" - "PyOS_AfterFork" - -; From python23_s.lib(posixmodule) -; "initos2" - -; From python23_s.lib(threadmodule) -; "initthread" - -; From python23_s.lib(arraymodule) -; "initarray" -; "array_methods" - -; From python23_s.lib(binascii) -; "initbinascii" - -; From python23_s.lib(cmathmodule) -; "initcmath" - -; From python23_s.lib(_codecsmodule) -; "init_codecs" - -; From python23_s.lib(cPickle) -; "initcPickle" -; "fast_save_leave" - -; From python23_s.lib(cStringIO) -; "initcStringIO" - -; From python23_s.lib(_csv) -; "init_csv" - -; From python23_s.lib(datetimemodule) -; "initdatetime" - -; From python23_s.lib(dlmodule) -; "initdl" - -; From python23_s.lib(errnomodule) -; "initerrno" - -; From python23_s.lib(fcntlmodule) -; "initfcntl" - -; From python23_s.lib(imageop) -; "initimageop" - -; From python23_s.lib(itertoolsmodule) -; "inititertools" - -; From python23_s.lib(_localemodule) -; "init_locale" - -; From python23_s.lib(mathmodule) -; "initmath" - -; From python23_s.lib(md5c) -; "_Py_MD5Final" -; "_Py_MD5Init" -; "_Py_MD5Update" - -; From python23_s.lib(md5module) -; "initmd5" - -; From python23_s.lib(operator) -; "initoperator" - -; From python23_s.lib(pcremodule) -; "initpcre" - -; From python23_s.lib(pypcre) -; "pcre_study" -; "pcre_compile" -; "pcre_exec" -; "pcre_info" -; "pcre_version" -; "pcre_lcc" -; "pcre_fcc" -; "pcre_cbits" -; "pcre_ctypes" -; "pcre_malloc" -; "pcre_free" - -; From python23_s.lib(_randommodule) -; "init_random" - -; From python23_s.lib(regexmodule) -; "initregex" - -; From python23_s.lib(regexpr) -; "_Py_re_syntax_table" -; "_Py_re_compile_initialize" -; "_Py_re_compile_pattern" -; "_Py_re_match" -; "_Py_re_search" -; "_Py_re_set_syntax" -; "_Py_re_compile_fastmap" -; "_Py_re_syntax" - -; From python23_s.lib(rgbimgmodule) -; "initrgbimg" - -; From python23_s.lib(shamodule) -; "initsha" - -; From python23_s.lib(_sre) -; "init_sre" - -; From python23_s.lib(stropmodule) -; "initstrop" - -; From python23_s.lib(structmodule) -; "initstruct" - -; From python23_s.lib(symtablemodule) -; "init_symtable" - -; From python23_s.lib(termios) -; "inittermios" - -; From python23_s.lib(timemodule) -; "inittime" -; "inittimezone" - -; From python23_s.lib(timingmodule) -; "inittiming" - -; From python23_s.lib(_weakref) -; "init_weakref" - -; From python23_s.lib(xreadlinesmodule) -; "initxreadlines" - -; From python23_s.lib(xxsubtype) -; "initxxsubtype" - -; From python23_s.lib(zipimport) -; "initzipimport" diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/pythonpm.c b/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/pythonpm.c deleted file mode 100644 index 2d7e7a5e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2emx/pythonpm.c +++ /dev/null @@ -1,124 +0,0 @@ -/* OS/2 PM main program - creates a hidden window, and starts Python - * interpreter in a separate thread, so that Python scripts can be - * run in PM process space without a console Window. The interpreter - * is incorporated by linking in the Python DLL. - * - * As it stands, I don't think this is adequate for supporting Python - * GUI modules, as the Python thread doesn't have its own message - * queue - which is required of threads that want to create/use - * PM windows. - * - * This code owes a lot to "OS/2 Presentation Manager Programming", by - * Charles Petzold. - * - * Andrew MacIntyre , August 2001. - * Released under the terms of the Python 2.1.1 licence - see the LICENCE - * file in the Python v2.1.1 (or later) source distribution. - * Copyright assigned to the Python Software Foundation, 2001. - */ - -#define INCL_DOS -#define INCL_WIN -#include -#include - -#include "Python.h" - -/* use structure to pass command line to Python thread */ -typedef struct -{ - int argc; - char **argv; - HWND Frame; - int running; -} arglist; - -/* make this a global to simplify access. - * it should only be set from the Python thread, or by the code that - * initiates the Python thread when the thread cannot be created. - */ -int PythonRC; - -extern DL_EXPORT(int) Py_Main(int, char **); -void PythonThread(void *); - -int -main(int argc, char **argv) -{ - ULONG FrameFlags = FCF_TITLEBAR | - FCF_SYSMENU | - FCF_SIZEBORDER | - FCF_HIDEBUTTON | - FCF_SHELLPOSITION | - FCF_TASKLIST; - HAB hab; - HMQ hmq; - HWND Client; - QMSG qmsg; - arglist args; - int python_tid; - - /* init PM and create message queue */ - hab = WinInitialize(0); - hmq = WinCreateMsgQueue(hab, 0); - - /* create a (hidden) Window to house the window procedure */ - args.Frame = WinCreateStdWindow(HWND_DESKTOP, - 0, - &FrameFlags, - NULL, - "PythonPM", - 0L, - 0, - 0, - &Client); - - /* run Python interpreter in a thread */ - args.argc = argc; - args.argv = argv; - args.running = 0; - if (-1 == (python_tid = _beginthread(PythonThread, NULL, 1024 * 1024, &args))) - { - /* couldn't start thread */ - WinAlarm(HWND_DESKTOP, WA_ERROR); - PythonRC = 1; - } - else - { - /* process PM messages, until Python exits */ - while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0)) - WinDispatchMsg(hab, &qmsg); - if (args.running > 0) - DosKillThread(python_tid); - } - - /* destroy window, shutdown message queue and PM */ - WinDestroyWindow(args.Frame); - WinDestroyMsgQueue(hmq); - WinTerminate(hab); - - return PythonRC; -} - -void PythonThread(void *argl) -{ - HAB hab; - arglist *args; - - /* PM initialisation */ - hab = WinInitialize(0); - - /* start Python */ - args = (arglist *)argl; - args->running = 1; - PythonRC = Py_Main(args->argc, args->argv); - - /* enter a critical section and send the termination message */ - DosEnterCritSec(); - args->running = 0; - WinPostMsg(args->Frame, WM_QUIT, NULL, NULL); - - /* shutdown PM and terminate thread */ - WinTerminate(hab); - _endthread(); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/_tkinter.def b/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/_tkinter.def deleted file mode 100644 index 9df56968..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/_tkinter.def +++ /dev/null @@ -1,8 +0,0 @@ -LIBRARY _TKINTER INITINSTANCE TERMINSTANCE -DESCRIPTION 'Python Extension DLL v1.0 for Access to Tcl/Tk Environment' -PROTMODE -DATA MULTIPLE NONSHARED - -EXPORTS - init_tkinter - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/config.c b/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/config.c deleted file mode 100644 index e4b61b13..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/config.c +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- C -*- *********************************************** -Copyright (c) 2000, BeOpen.com. -Copyright (c) 1995-2000, Corporation for National Research Initiatives. -Copyright (c) 1990-1995, Stichting Mathematisch Centrum. -All rights reserved. - -See the file "Misc/COPYRIGHT" for information on usage and -redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. -******************************************************************/ - -/* Module configuration */ - -/* This file contains the table of built-in modules. - See init_builtin() in import.c. */ - -#include "Python.h" - -extern void initarray(void); -extern void initaudioop(void); -extern void initbinascii(void); -extern void initcmath(void); -extern void initerrno(void); -extern void initimageop(void); -extern void initmath(void); -extern void initmd5(void); -extern void initnt(void); -extern void initos2(void); -extern void initoperator(void); -extern void initposix(void); -extern void initregex(void); -extern void initrgbimg(void); -extern void initrotor(void); -extern void initsignal(void); -extern void initselect(void); -extern void init_socket(void); -extern void initstrop(void); -extern void initstruct(void); -extern void inittime(void); -extern void initthread(void); -extern void initcStringIO(void); -extern void initcPickle(void); -extern void initpcre(void); -#ifdef WIN32 -extern void initmsvcrt(void); -#endif - -/* -- ADDMODULE MARKER 1 -- */ - -extern void PyMarshal_Init(void); -extern void initimp(void); - -struct _inittab _PyImport_Inittab[] = { - - {"array", initarray}, -#ifdef M_I386 - {"audioop", initaudioop}, -#endif - {"binascii", initbinascii}, - {"cmath", initcmath}, - {"errno", initerrno}, -// {"imageop", initimageop}, - {"math", initmath}, - {"md5", initmd5}, -#if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) - {"nt", initnt}, /* Use the NT os functions, not posix */ -#else -#if defined(PYOS_OS2) - {"os2", initos2}, -#else - {"posix", initposix}, -#endif -#endif - {"operator", initoperator}, - {"regex", initregex}, -// {"rgbimg", initrgbimg}, -// {"rotor", initrotor}, - {"signal", initsignal}, -#ifdef USE_SOCKET - {"_socket", init_socket}, - {"select", initselect}, -#endif - {"strop", initstrop}, - {"struct", initstruct}, - {"time", inittime}, -#ifdef WITH_THREAD - {"thread", initthread}, -#endif - {"cStringIO", initcStringIO}, - {"cPickle", initcPickle}, - {"pcre", initpcre}, -#ifdef WIN32 - {"msvcrt", initmsvcrt}, -#endif - -/* -- ADDMODULE MARKER 2 -- */ - - /* This module "lives in" with marshal.c */ - {"marshal", PyMarshal_Init}, - - /* This lives it with import.c */ - {"imp", initimp}, - - /* These entries are here for sys.builtin_module_names */ - {"__main__", NULL}, - {"__builtin__", NULL}, - {"sys", NULL}, - - /* Sentinel */ - {0, 0} -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/getpathp.c b/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/getpathp.c deleted file mode 100644 index 33cf112c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/getpathp.c +++ /dev/null @@ -1,471 +0,0 @@ - -/* Return the initial module search path. */ -/* Used by DOS, OS/2, Windows 3.1. Works on NT too. */ - -#include "Python.h" -#include "osdefs.h" - -#ifdef MS_WIN32 -#include -extern BOOL PyWin_IsWin32s(void); -#endif - -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#endif /* HAVE_UNISTD_H */ - -/* Search in some common locations for the associated Python libraries. - * - * Two directories must be found, the platform independent directory - * (prefix), containing the common .py and .pyc files, and the platform - * dependent directory (exec_prefix), containing the shared library - * modules. Note that prefix and exec_prefix can be the same directory, - * but for some installations, they are different. - * - * Py_GetPath() tries to return a sensible Python module search path. - * - * First, we look to see if the executable is in a subdirectory of - * the Python build directory. We calculate the full path of the - * directory containing the executable as progpath. We work backwards - * along progpath and look for $dir/Modules/Setup.in, a distinctive - * landmark. If found, we use $dir/Lib as $root. The returned - * Python path is the compiled #define PYTHONPATH with all the initial - * "./lib" replaced by $root. - * - * Otherwise, if there is a PYTHONPATH environment variable, we return that. - * - * Otherwise we try to find $progpath/lib/os.py, and if found, then - * root is $progpath/lib, and we return Python path as compiled PYTHONPATH - * with all "./lib" replaced by $root (as above). - * - */ - -#ifndef LANDMARK -#define LANDMARK "lib\\os.py" -#endif - -static char prefix[MAXPATHLEN+1]; -static char exec_prefix[MAXPATHLEN+1]; -static char progpath[MAXPATHLEN+1]; -static char *module_search_path = NULL; - - -static int -is_sep(char ch) /* determine if "ch" is a separator character */ -{ -#ifdef ALTSEP - return ch == SEP || ch == ALTSEP; -#else - return ch == SEP; -#endif -} - - -static void -reduce(char *dir) -{ - int i = strlen(dir); - while (i > 0 && !is_sep(dir[i])) - --i; - dir[i] = '\0'; -} - - -static int -exists(char *filename) -{ - struct stat buf; - return stat(filename, &buf) == 0; -} - - -static void -join(char *buffer, char *stuff) -{ - int n, k; - if (is_sep(stuff[0])) - n = 0; - else { - n = strlen(buffer); - if (n > 0 && !is_sep(buffer[n-1]) && n < MAXPATHLEN) - buffer[n++] = SEP; - } - k = strlen(stuff); - if (n + k > MAXPATHLEN) - k = MAXPATHLEN - n; - strncpy(buffer+n, stuff, k); - buffer[n+k] = '\0'; -} - - -static int -search_for_prefix(char *argv0_path, char *landmark) -{ - int n; - - /* Search from argv0_path, until root is found */ - strcpy(prefix, argv0_path); - do { - n = strlen(prefix); - join(prefix, landmark); - if (exists(prefix)) { - prefix[n] = '\0'; - return 1; - } - prefix[n] = '\0'; - reduce(prefix); - } while (prefix[0]); - return 0; -} - -#ifdef MS_WIN32 -#include "malloc.h" // for alloca - see comments below! -extern const char *PyWin_DLLVersionString; // a string loaded from the DLL at startup. - - -/* Load a PYTHONPATH value from the registry. - Load from either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER. - - Returns NULL, or a pointer that should be freed. -*/ - -static char * -getpythonregpath(HKEY keyBase, BOOL bWin32s) -{ - HKEY newKey = 0; - DWORD nameSize = 0; - DWORD dataSize = 0; - DWORD numEntries = 0; - LONG rc; - char *retval = NULL; - char *dataBuf; - const char keyPrefix[] = "Software\\Python\\PythonCore\\"; - const char keySuffix[] = "\\PythonPath"; - int versionLen; - char *keyBuf; - - // Tried to use sysget("winver") but here is too early :-( - versionLen = strlen(PyWin_DLLVersionString); - // alloca == no free required, but memory only local to fn. - // also no heap fragmentation! Am I being silly? - keyBuf = alloca(sizeof(keyPrefix)-1 + versionLen + sizeof(keySuffix)); // chars only, plus 1 NULL. - // lots of constants here for the compiler to optimize away :-) - memcpy(keyBuf, keyPrefix, sizeof(keyPrefix)-1); - memcpy(keyBuf+sizeof(keyPrefix)-1, PyWin_DLLVersionString, versionLen); - memcpy(keyBuf+sizeof(keyPrefix)-1+versionLen, keySuffix, sizeof(keySuffix)); // NULL comes with this one! - - rc=RegOpenKey(keyBase, - keyBuf, - &newKey); - if (rc==ERROR_SUCCESS) { - RegQueryInfoKey(newKey, NULL, NULL, NULL, NULL, NULL, NULL, - &numEntries, &nameSize, &dataSize, NULL, NULL); - } - if (bWin32s && numEntries==0 && dataSize==0) { - /* must hardcode for Win32s */ - numEntries = 1; - dataSize = 511; - } - if (numEntries) { - /* Loop over all subkeys. */ - /* Win32s doesnt know how many subkeys, so we do - it twice */ - char keyBuf[MAX_PATH+1]; - int index = 0; - int off = 0; - for(index=0;;index++) { - long reqdSize = 0; - DWORD rc = RegEnumKey(newKey, - index, keyBuf, MAX_PATH+1); - if (rc) break; - rc = RegQueryValue(newKey, keyBuf, NULL, &reqdSize); - if (rc) break; - if (bWin32s && reqdSize==0) reqdSize = 512; - dataSize += reqdSize + 1; /* 1 for the ";" */ - } - dataBuf = malloc(dataSize+1); - if (dataBuf==NULL) - return NULL; /* pretty serious? Raise error? */ - /* Now loop over, grabbing the paths. - Subkeys before main library */ - for(index=0;;index++) { - int adjust; - long reqdSize = dataSize; - DWORD rc = RegEnumKey(newKey, - index, keyBuf,MAX_PATH+1); - if (rc) break; - rc = RegQueryValue(newKey, - keyBuf, dataBuf+off, &reqdSize); - if (rc) break; - if (reqdSize>1) { - /* If Nothing, or only '\0' copied. */ - adjust = strlen(dataBuf+off); - dataSize -= adjust; - off += adjust; - dataBuf[off++] = ';'; - dataBuf[off] = '\0'; - dataSize--; - } - } - /* Additionally, win32s doesnt work as expected, so - the specific strlen() is required for 3.1. */ - rc = RegQueryValue(newKey, "", dataBuf+off, &dataSize); - if (rc==ERROR_SUCCESS) { - if (strlen(dataBuf)==0) - free(dataBuf); - else - retval = dataBuf; /* caller will free */ - } - else - free(dataBuf); - } - - if (newKey) - RegCloseKey(newKey); - return retval; -} -#endif /* MS_WIN32 */ - -static void -get_progpath(void) -{ - extern char *Py_GetProgramName(void); - char *path = getenv("PATH"); - char *prog = Py_GetProgramName(); - -#ifdef MS_WIN32 - if (GetModuleFileName(NULL, progpath, MAXPATHLEN)) - return; -#endif - if (prog == NULL || *prog == '\0') - prog = "python"; - - /* If there is no slash in the argv0 path, then we have to - * assume python is on the user's $PATH, since there's no - * other way to find a directory to start the search from. If - * $PATH isn't exported, you lose. - */ -#ifdef ALTSEP - if (strchr(prog, SEP) || strchr(prog, ALTSEP)) -#else - if (strchr(prog, SEP)) -#endif - strcpy(progpath, prog); - else if (path) { - while (1) { - char *delim = strchr(path, DELIM); - - if (delim) { - int len = delim - path; - strncpy(progpath, path, len); - *(progpath + len) = '\0'; - } - else - strcpy(progpath, path); - - join(progpath, prog); - if (exists(progpath)) - break; - - if (!delim) { - progpath[0] = '\0'; - break; - } - path = delim + 1; - } - } - else - progpath[0] = '\0'; -} - -static void -calculate_path(void) -{ - char argv0_path[MAXPATHLEN+1]; - char *buf; - int bufsz; - char *pythonhome = Py_GetPythonHome(); - char *envpath = Py_GETENV("PYTHONPATH"); -#ifdef MS_WIN32 - char *machinepath, *userpath; - - /* Are we running under Windows 3.1(1) Win32s? */ - if (PyWin_IsWin32s()) { - /* Only CLASSES_ROOT is supported */ - machinepath = getpythonregpath(HKEY_CLASSES_ROOT, TRUE); - userpath = NULL; - } else { - machinepath = getpythonregpath(HKEY_LOCAL_MACHINE, FALSE); - userpath = getpythonregpath(HKEY_CURRENT_USER, FALSE); - } -#endif - - get_progpath(); - strcpy(argv0_path, progpath); - reduce(argv0_path); - if (pythonhome == NULL || *pythonhome == '\0') { - if (search_for_prefix(argv0_path, LANDMARK)) - pythonhome = prefix; - else - pythonhome = NULL; - } - else { - char *delim; - - strcpy(prefix, pythonhome); - - /* Extract Any Optional Trailing EXEC_PREFIX */ - /* e.g. PYTHONHOME=: */ - delim = strchr(prefix, DELIM); - if (delim) { - *delim = '\0'; - strcpy(exec_prefix, delim+1); - } else - strcpy(exec_prefix, EXEC_PREFIX); - } - - if (envpath && *envpath == '\0') - envpath = NULL; - - /* We need to construct a path from the following parts: - (1) the PYTHONPATH environment variable, if set; - (2) for Win32, the machinepath and userpath, if set; - (3) the PYTHONPATH config macro, with the leading "." - of each component replaced with pythonhome, if set; - (4) the directory containing the executable (argv0_path). - The length calculation calculates #3 first. - */ - - /* Calculate size of return buffer */ - if (pythonhome != NULL) { - char *p; - bufsz = 1; - for (p = PYTHONPATH; *p; p++) { - if (*p == DELIM) - bufsz++; /* number of DELIM plus one */ - } - bufsz *= strlen(pythonhome); - } - else - bufsz = 0; - bufsz += strlen(PYTHONPATH) + 1; - if (envpath != NULL) - bufsz += strlen(envpath) + 1; - bufsz += strlen(argv0_path) + 1; -#ifdef MS_WIN32 - if (machinepath) - bufsz += strlen(machinepath) + 1; - if (userpath) - bufsz += strlen(userpath) + 1; -#endif - - module_search_path = buf = malloc(bufsz); - if (buf == NULL) { - /* We can't exit, so print a warning and limp along */ - fprintf(stderr, "Can't malloc dynamic PYTHONPATH.\n"); - if (envpath) { - fprintf(stderr, "Using default static $PYTHONPATH.\n"); - module_search_path = envpath; - } - else { - fprintf(stderr, "Using environment $PYTHONPATH.\n"); - module_search_path = PYTHONPATH; - } - return; - } - - if (envpath) { - strcpy(buf, envpath); - buf = strchr(buf, '\0'); - *buf++ = DELIM; - } -#ifdef MS_WIN32 - if (machinepath) { - strcpy(buf, machinepath); - buf = strchr(buf, '\0'); - *buf++ = DELIM; - } - if (userpath) { - strcpy(buf, userpath); - buf = strchr(buf, '\0'); - *buf++ = DELIM; - } -#endif - if (pythonhome == NULL) { - strcpy(buf, PYTHONPATH); - buf = strchr(buf, '\0'); - } - else { - char *p = PYTHONPATH; - char *q; - int n; - for (;;) { - q = strchr(p, DELIM); - if (q == NULL) - n = strlen(p); - else - n = q-p; - if (p[0] == '.' && is_sep(p[1])) { - strcpy(buf, pythonhome); - buf = strchr(buf, '\0'); - p++; - n--; - } - strncpy(buf, p, n); - buf += n; - if (q == NULL) - break; - *buf++ = DELIM; - p = q+1; - } - } - if (argv0_path) { - *buf++ = DELIM; - strcpy(buf, argv0_path); - buf = strchr(buf, '\0'); - } - *buf = '\0'; -} - - -/* External interface */ - -char * -Py_GetPath(void) -{ - if (!module_search_path) - calculate_path(); - - return module_search_path; -} - -char * -Py_GetPrefix(void) -{ - if (!module_search_path) - calculate_path(); - - return prefix; -} - -char * -Py_GetExecPrefix(void) -{ - if (!module_search_path) - calculate_path(); - - return exec_prefix; -} - -char * -Py_GetProgramFullPath(void) -{ - if (!module_search_path) - calculate_path(); - - return progpath; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/makefile b/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/makefile deleted file mode 100644 index e4a71e8b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/makefile +++ /dev/null @@ -1,1928 +0,0 @@ -###################################################################### -# -# Top-Level Makefile for Building Python for OS/2 -# -# This makefile was developed for use with IBM's VisualAge C/C++ -# for OS/2 compiler, version 3.0, with Fixpack 8 applied. It uses -# version 4.0 of the NMAKE tool that comes with that package. -# -# The output of the build is a largish Python23.DLL containing the -# essential modules of Python and a small Python.exe program to start -# the interpreter. When embedding Python within another program, only -# Python23.DLL is needed. -# -# These two binaries can be statically linked with the VisualAge C/C++ -# runtime library (producing larger binaries), or dynamically linked -# to make smaller ones that require the compiler to be installed on -# any system Python is used on. Review the /Gd+ compiler option for -# how to do this. -# -# NOTE: IBM's NMAKE 4.0 is rather dumb, requiring this makefile to -# be much more complicated than necessary. I use OpusMAKE -# myself for a much more powerful MAKE tool but not everyone -# wishes to buy it. However, as a result I didn't hook in -# the dependencies on the include files as NMAKE has no easy -# way to do this without explicitly spelling it all out. -# -# History (Most Recent First) -# -# 26-Sep-98 jrr Retested and adjusted for building w/Python 1.5.2a1 -# 20-Nov-97 jrr Cleaned Up for Applying to Distribution -# 29-Oct-97 jrr Modified for Use with Python 1.5 Alpha 4 -# 03-Aug-96 jrr Original for Use with Python 1.4 Release -# -###################################################################### - -################### -# Places and Things -################### -PY_MODULES = ..\..\Modules -PY_OBJECTS = ..\..\Objects -PY_PARSER = ..\..\Parser -PY_PYTHON = ..\..\Python -PY_INCLUDE = ..\..\Include -PY_INCLUDES = .;$(PY_INCLUDE);$(PY_MODULES);$(PY_OBJECTS);$(PY_PARSER);$(PY_PYTHON) - -# File to Collect Wordy Compiler Output re Errors -ERRS = make.out - -# Where to Find the IBM TCP/IP Socket Includes and Libraries -OS2TCPIP = C:\MPTN - -# Where to Find the Tcl/Tk Base Directory for Libs/Includes -TCLTK = D:\TclTk -TCLBASE = D:\Tcl7.6\OS2 -TKBASE = D:\Tk4.2\OS2 - -# Where to Put the .OBJ Files, To Keep Them Out of the Way -PATHOBJ = obj - -# Search Path for Include Files -PROJINCLUDE = .;$(TCLBASE);$(TKBASE);$(OS2TCPIP)\Include;$(PY_INCLUDES) - -# Place to Search for Sources re OpusMAKE Dependency Generator (Commercial) -MKMF_SRCS = $(PY_MODULES)\*.c $(PY_OBJECTS)\*.c $(PY_PARSER)\*.c $(PY_PYTHON)\*.c - -#.HDRPATH.c := $(PROJINCLUDE,;= ) $(.HDRPATH.c) -#.PATH.c = .;$(PY_MODULES);$(PY_OBJECTS);$(PY_PARSER);$(PY_PYTHON) -OTHERLIBS = so32dll.lib tcp32dll.lib # Tcl76.lib Tk42.lib - -################# -# Inference Rules -################# -{$(PY_MODULES)\}.c{$(PATHOBJ)\}.obj: # Compile C Code into a .OBJ File - @ Echo Compiling $< - @ $(CC) -c $(CFLAGS) -Fo$@ $< >>$(ERRS) - -{$(PY_OBJECTS)\}.c{$(PATHOBJ)\}.obj: # Compile C Code into a .OBJ File - @ Echo Compiling $< - @ $(CC) -c $(CFLAGS) -Fo$@ $< >>$(ERRS) - -{$(PY_PARSER)\}.c{$(PATHOBJ)\}.obj: # Compile C Code into a .OBJ File - @ Echo Compiling $< - @ $(CC) -c $(CFLAGS) -Fo$@ $< >>$(ERRS) - -{$(PY_PYTHON)\}.c{$(PATHOBJ)\}.obj: # Compile C Code into a .OBJ File - @ Echo Compiling $< - @ $(CC) -c $(CFLAGS) -Fo$@ $< >>$(ERRS) - -.c{$(PATHOBJ)\}.obj: # Compile C Code into a .OBJ File - @ Echo Compiling $< - @ $(CC) -c $(CFLAGS) -Fo$@ $< >>$(ERRS) - -################### -# Python Subsystems -################### - -# PYTHON is the central core, containing the builtins and interpreter. -PYTHON = \ - $(PATHOBJ)\BltinModule.obj \ - $(PATHOBJ)\CEval.obj \ - $(PATHOBJ)\Compile.obj \ - $(PATHOBJ)\Errors.obj \ - $(PATHOBJ)\Frozen.obj \ - $(PATHOBJ)\Getargs.obj \ - $(PATHOBJ)\GetCompiler.obj \ - $(PATHOBJ)\GetCopyright.obj \ - $(PATHOBJ)\GetMTime.obj \ - $(PATHOBJ)\GetOpt.obj \ - $(PATHOBJ)\GetPlatform.obj \ - $(PATHOBJ)\GetVersion.obj \ - $(PATHOBJ)\GramInit.obj \ - $(PATHOBJ)\Import.obj \ - $(PATHOBJ)\ImportDL.obj \ - $(PATHOBJ)\Marshal.obj \ - $(PATHOBJ)\ModSupport.obj \ - $(PATHOBJ)\MyStrtoul.obj \ - $(PATHOBJ)\PyState.obj \ - $(PATHOBJ)\PythonRun.obj \ - $(PATHOBJ)\StructMember.obj \ - $(PATHOBJ)\SysModule.obj \ - $(PATHOBJ)\Thread.obj \ - $(PATHOBJ)\TraceBack.obj \ - $(PATHOBJ)\FrozenMain.obj \ - $(PATHOBJ)\exceptions.obj \ - $(PATHOBJ)\symtable.obj \ - $(PATHOBJ)\codecs.obj \ - $(PATHOBJ)\future.obj \ - $(PATHOBJ)\dynload_os2.obj \ - $(PATHOBJ)\mysnprintf.obj \ - $(PATHOBJ)\iterobject.obj - -# Python's Internal Parser -PARSER = \ - $(PATHOBJ)\Acceler.obj \ - $(PATHOBJ)\Grammar1.obj \ - $(PATHOBJ)\ListNode.obj \ - $(PATHOBJ)\Node.obj \ - $(PATHOBJ)\Parser.obj \ - $(PATHOBJ)\ParseTok.obj \ - $(PATHOBJ)\BitSet.obj \ - $(PATHOBJ)\MetaGrammar.obj \ - $(PATHOBJ)\Tokenizer.obj \ - $(PATHOBJ)\MyReadline.obj - -# Python Object Types -OBJECTS = \ - $(PATHOBJ)\Abstract.obj \ - $(PATHOBJ)\BoolObject.obj \ - $(PATHOBJ)\BufferObject.obj \ - $(PATHOBJ)\CellObject.obj \ - $(PATHOBJ)\ClassObject.obj \ - $(PATHOBJ)\CObject.obj \ - $(PATHOBJ)\ComplexObject.obj \ - $(PATHOBJ)\DescrObject.obj \ - $(PATHOBJ)\DictObject.obj \ - $(PATHOBJ)\EnumObject.obj \ - $(PATHOBJ)\FileObject.obj \ - $(PATHOBJ)\FloatObject.obj \ - $(PATHOBJ)\FrameObject.obj \ - $(PATHOBJ)\FuncObject.obj \ - $(PATHOBJ)\IntObject.obj \ - $(PATHOBJ)\IterObject.obj \ - $(PATHOBJ)\ListObject.obj \ - $(PATHOBJ)\LongObject.obj \ - $(PATHOBJ)\MethodObject.obj \ - $(PATHOBJ)\ModuleObject.obj \ - $(PATHOBJ)\Object.obj \ - $(PATHOBJ)\RangeObject.obj \ - $(PATHOBJ)\SliceObject.obj \ - $(PATHOBJ)\StringObject.obj \ - $(PATHOBJ)\StructSeq.obj \ - $(PATHOBJ)\TupleObject.obj \ - $(PATHOBJ)\TypeObject.obj \ - $(PATHOBJ)\UnicodeObject.obj \ - $(PATHOBJ)\UnicodeCType.obj \ - $(PATHOBJ)\WeakrefObject.obj - -# Extension Modules (Built-In or as Separate DLLs) -MODULES = \ - $(PATHOBJ)\ArrayModule.obj \ - $(PATHOBJ)\BinAscii.obj \ - $(PATHOBJ)\CMathModule.obj \ - $(PATHOBJ)\cPickle.obj \ - $(PATHOBJ)\cStringIO.obj \ - $(PATHOBJ)\ErrnoModule.obj \ - $(PATHOBJ)\GCModule.obj \ - $(PATHOBJ)\GetBuildInfo.obj \ - $(PATHOBJ)\GetPathP.obj \ - $(PATHOBJ)\Main.obj \ - $(PATHOBJ)\MathModule.obj \ - $(PATHOBJ)\MD5c.obj \ - $(PATHOBJ)\MD5Module.obj \ - $(PATHOBJ)\Operator.obj \ - $(PATHOBJ)\PCREModule.obj \ - $(PATHOBJ)\PyPCRE.obj \ - $(PATHOBJ)\RotorModule.obj \ - $(PATHOBJ)\PosixModule.obj \ - $(PATHOBJ)\RegexModule.obj \ - $(PATHOBJ)\RegExpr.obj \ - $(PATHOBJ)\SelectModule.obj \ - $(PATHOBJ)\SignalModule.obj \ - $(PATHOBJ)\SocketModule.obj \ - $(PATHOBJ)\StropModule.obj \ - $(PATHOBJ)\StructModule.obj \ - $(PATHOBJ)\TimeModule.obj \ - $(PATHOBJ)\ThreadModule.obj \ - $(PATHOBJ)\YUVConvert.obj - -# Standalone Parser Generator Program (Shares Some of Python's Modules) -PGEN = \ - $(PATHOBJ)\PGen.obj \ - $(PATHOBJ)\PGenMain.obj \ - $(PATHOBJ)\MySNPrintf.obj \ - $(PATHOBJ)\Tokenizer_Pgen.obj \ - $(PATHOBJ)\PrintGrammar.obj \ - $(PATHOBJ)\Grammar.obj \ - $(PATHOBJ)\FirstSets.obj - -################## -# Macros and Flags -################## -_BASE = /Q /W2 /I$(PROJINCLUDE) - # /Q = Omit IBM Copyright - # /W2 = Show Warnings/Errors Only - -_GEN = /G4 /Gm /Gd- - # /G4 = Generate Code for 486 (Use 386 for Debugger) - # /Gm = Use Multithread Runtime - # /Gd = Dynamically Load Runtime - # /Ms = Use _System Calling Convention (vs _Optlink) - # (to allow non-VAC++ code to call into Python23.dll) - -_OPT = /O /Gl - # /O = Enable Speed-Optimizations - # /Ol = Pass Code Thru Intermediate Linker - # /Gu = Advise Linker All Ext Data is ID'd - # /Gl = Have Linker Remove Unused Fns - -_DBG = /Wpro- /Ti- /DHAVE_CONFIG_H /DUSE_SOCKET - # /Wpro= Generate Compiler Warnings re Missing Prototypes - # /Ti = Embed Debugger/Analyzer Recs - # /Tm = Enable Debug Memory Fns - # /Tx = Request Full Dump Upon Exception - # /DHAVE_CONFIG_H = Causes Use of CONFIG.H Settings - # /DUSE_SOCKET = Enables Building In of Socket API - -_OUT = - # /Fb = Embed Browser Recs - # /Gh = Generate Code for Profiler Hooks - # /Fl = Output C/C++ Listing Files - # /Lf = Provide Full (Detailed) Listing Files - # /Fm. = Output Linker Map File - # /Ft. = Output C++ Template Resolution Files - -_MAP = /FmNoise\$(@R).map - -_DLL = /Ge- -_EXE = /Ge - # /Ge = Create an EXE, not DLL - -CFLAGS = $(_BASE) $(_GEN) $(_OPT) $(_DBG) $(_OUT) $(_EXE) /Ss - -################### -# Primary Target(s) -################### -All: obj noise PyCore.lib Python23.lib PGen.exe \ - Python.exe PythonPM.exe Python23.dll # _tkinter.dll - -Modules: $(MODULES) -Objects: $(OBJECTS) -Parser: $(PARSER) -Python: $(PYTHON) - -# Directory to Keep .OBJ Files Out of the Way -obj: - @-mkdir obj >>NUL - -# Directory to Keep .MAP and Such Text Files Out of the Way -noise: - @-mkdir noise >>NUL - -############## -# -############## - -# Python Extension DLL: Tcl/Tk Interface -#_tkinter.dll: $(PATHOBJ)\_tkinter.obj Python23.lib _tkinter.def -# @ Echo Linking $@ As DLL -# @ $(CC) $(CFLAGS) /B"/NOE" $(_DLL) /Fe$@ $(_MAP) $** $(OTHERLIBS) >>$(ERRS) - -#$(PATHOBJ)\_tkinter.obj: $(PY_MODULES)\_tkinter.c -# @ Echo Compiling $** -# @ $(CC) -c $(CFLAGS) $(_DLL) -Fo$@ $** >>$(ERRS) - -# Object Library of All Essential Python Routines -PyCore.lib: $(MODULES) $(OBJECTS) $(PARSER) $(PYTHON) $(PATHOBJ)\Config.obj - @ Echo Adding Updated Object Files to Link Library $@ - @ ! ILIB $@ /NOLOGO /NOBACKUP -+$? ; >>$(ERRS) - -Python23.dll: $(PATHOBJ)\Compile.obj PyCore.lib Python.def - @ Echo Linking $@ As DLL - @ $(CC) $(CFLAGS) /B"/NOE" $(_DLL) /Fe$@ $(_MAP) $** $(OTHERLIBS) >>$(ERRS) -# @ Echo Compressing $@ with LxLite -# @ lxlite $@ - -# IBM Linker Requires One Explicit .OBJ To Build a .DLL from a .LIB -$(PATHOBJ)\Compile.obj: $(PY_PYTHON)\Compile.c - @ Echo Compiling $** - @ $(CC) -c $(CFLAGS) $(_DLL) -Fo$@ $** >>$(ERRS) - -# Import Library for Using the Python23.dll -Python23.lib: Python.def - @ Echo Making $@ - @ IMPLIB /NOLOGO /NOIGNORE $@ $** >>$(ERRS) - @ ILIB /NOLOGO /CONVFORMAT /NOEXTDICTIONARY /NOBROWSE /NOBACKUP $@; >>$(ERRS) - -# Small Command-Line Program to Start Interpreter in Python23.dll -Python.exe: $(PATHOBJ)\Python.obj Python23.lib - @ Echo Linking $@ As EXE - @ $(CC) $(CFLAGS) $(_EXE) /B"/PM:VIO /STACK:360000" /Fe$@ $(_MAP) $** $(OTHERLIBS) >>$(ERRS) - -# Small PM-GUI Program to Start Interpreter in Python23.dll -PythonPM.exe: $(PATHOBJ)\Python.obj Python23.lib - @ Echo Linking $@ As EXE - @ $(CC) $(CFLAGS) $(_EXE) /B"/PM:PM /STACK:360000" /Fe$@ $(_MAP) $** $(OTHERLIBS) >>$(ERRS) - -PGen.exe: $(PGEN) PyCore.lib - @ Echo Linking $@ As EXE - @ $(CC) $(CFLAGS) $(_EXE) /B"/STACK:360000" /Fe$@ $(_MAP) $** $(OTHERLIBS) >>$(ERRS) - -####################### -# Miscellaneous Targets -####################### - -# Remove Intermediate Targets but Leave Executable Binaries -clean: - -- Del /Q $(PATHOBJ)\*.obj >NUL 2>&1 - -- Del /Q /Y Noise >NUL 2>&1 - -- Del /Q $(ERRS) >NUL 2>&1 - -# Remove All Targets, Including Final Binaries -distclean: clean - -- Del /Q PyCore.lib Python23.lib >NUL 2>&1 - -- Del /Q Python23.dll Python.exe PGen.exe >NUL 2>&1 - -release: Python.exe Python23.dll Python23.lib - -- @Echo Y | copy /U Python.exe D:\EXEs - -- @Echo Y | copy /U Python23.dll D:\DLLs - -- @Echo Y | copy /U Python23.lib E:\Tau\Lib - -- @Echo Y | copy /U _tkinter.dll D:\Python - -test: - python ..\..\lib\test\regrtest.py - -# Update Dependencies on Targets (Uses OpusMAKE Commercial Product) -depend: - D:\OpusMake\os2mkmf -c -s - -### OPUS MKMF: Do not remove this line! Generated dependencies follow. - -_tkinter.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -almodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -arraymodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -audioop.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\mymath.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -binascii.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -bsddbmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -cdmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -cgensupport.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_MODULES)\cgensupport.h $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h \ - $(PY_INCLUDE)\complexobject.h pyconfig.h $(PY_INCLUDE)\dictobject.h \ - $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h \ - $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h \ - $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -clmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -cmathmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\mymath.h $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h \ - $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -cpickle.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\cstringio.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\mymath.h $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h \ - $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -cryptmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -cstringio.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\cstringio.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -cursesmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -dbmmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -dlmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -errno.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -errnomodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -fcntlmodule.obj: $(PY_INCLUDE)\abstract.h $(OS2TCPIP)\Include\sys\ioctl.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -flmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\structmember.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -fmmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -fpectlmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -fpetestmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -gdbmmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -getbuildinfo.obj: pyconfig.h - -getpath.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\osdefs.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -glmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_MODULES)\cgensupport.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -grpmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(OS2TCPIP)\Include\grp.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -imageop.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -imgfile.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -main.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -mathmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\mymath.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -md5c.obj: pyconfig.h $(PY_MODULES)\md5.h - -md5module.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_MODULES)\md5.h $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -mpzmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longintrepr.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -nismodule.obj: $(PY_INCLUDE)\abstract.h $(OS2TCPIP)\Include\sys\time.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -operator.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -parsermodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h \ - $(PY_INCLUDE)\complexobject.h pyconfig.h $(PY_INCLUDE)\dictobject.h \ - $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h \ - $(PY_INCLUDE)\graminit.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\node.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\token.h \ - $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -pcremodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_MODULES)\pcre-internal.h \ - $(PY_MODULES)\pcre.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -posix.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\mytime.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -posixmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\mytime.h $(PY_INCLUDE)\object.h \ - $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -puremodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -pwdmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(OS2TCPIP)\Include\pwd.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -pypcre.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\graminit.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_MODULES)\pcre-internal.h $(PY_MODULES)\pcre.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -readline.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -regexmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_MODULES)\regexpr.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -regexpr.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_MODULES)\regexpr.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -resource.obj: $(PY_INCLUDE)\abstract.h $(OS2TCPIP)\Include\sys\time.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -rgbimgmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -rotormodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\mymath.h $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h \ - $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -selectmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\myselect.h $(PY_INCLUDE)\mytime.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -sgimodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -signalmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -socketmodule.obj: $(PY_INCLUDE)\abstract.h $(OS2TCPIP)\Include\netinet\in.h \ - $(OS2TCPIP)\Include\sys\socket.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\mytime.h $(OS2TCPIP)\Include\netdb.h $(PY_INCLUDE)\object.h \ - $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -soundex.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -stdwinmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -stropmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -structmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\mymath.h $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h \ - $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -sunaudiodev.obj: $(PY_INCLUDE)\abstract.h $(OS2TCPIP)\Include\sys\ioctl.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\structmember.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -svmodule.obj: $(PY_INCLUDE)\abstract.h $(OS2TCPIP)\Include\sys\time.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h \ - $(PY_INCLUDE)\complexobject.h pyconfig.h $(PY_INCLUDE)\dictobject.h \ - $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h \ - $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h \ - $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h \ - $(PY_MODULES)\yuv.h - -syslogmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(OS2TCPIP)\Include\syslog.h $(PY_INCLUDE)\sysmodule.h \ - $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -termios.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -threadmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\thread.h \ - $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -timemodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\mytime.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -timingmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_MODULES)\timing.h \ - $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -xxmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -yuvconvert.obj: $(PY_MODULES)\yuv.h - -zlibmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -abstract.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -classobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\structmember.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -cobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -complexobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\mymath.h $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h \ - $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -dictobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -fileobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\structmember.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -floatobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\mymath.h $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h \ - $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -frameobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h \ - $(PY_INCLUDE)\complexobject.h pyconfig.h $(PY_INCLUDE)\dictobject.h \ - $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\frameobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\opcode.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\structmember.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -funcobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\structmember.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -intobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -listobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -longobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longintrepr.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\mymath.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -methodobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\token.h \ - $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -moduleobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -object.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -rangeobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -sliceobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -stringobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\mymath.h $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h \ - $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -tupleobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -typeobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -xxobject.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -acceler.obj: $(PY_INCLUDE)\bitset.h pyconfig.h $(PY_INCLUDE)\grammar.h \ - $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\node.h \ - $(PY_PARSER)\parser.h $(PY_INCLUDE)\pgenheaders.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\token.h - -bitset.obj: $(PY_INCLUDE)\bitset.h pyconfig.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\pgenheaders.h $(PY_INCLUDE)\pydebug.h - -firstsets.obj: $(PY_INCLUDE)\bitset.h pyconfig.h $(PY_INCLUDE)\grammar.h \ - $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\pgenheaders.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\token.h - -grammar.obj: $(PY_INCLUDE)\bitset.h pyconfig.h \ - $(PY_INCLUDE)\grammar.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\pgenheaders.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\token.h - -grammar1.obj: $(PY_INCLUDE)\bitset.h pyconfig.h \ - $(PY_INCLUDE)\grammar.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\pgenheaders.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\token.h - -intrcheck.obj: pyconfig.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h - -listnode.obj: pyconfig.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\node.h $(PY_INCLUDE)\pgenheaders.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\token.h - -metagrammar.obj: $(PY_INCLUDE)\bitset.h pyconfig.h $(PY_INCLUDE)\grammar.h \ - $(PY_INCLUDE)\metagrammar.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_PARSER)\pgen.h $(PY_INCLUDE)\pgenheaders.h $(PY_INCLUDE)\pydebug.h - -myreadline.obj: pyconfig.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h - -node.obj: pyconfig.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\node.h \ - $(PY_INCLUDE)\pgenheaders.h $(PY_INCLUDE)\pydebug.h - -parser.obj: $(PY_INCLUDE)\bitset.h pyconfig.h $(PY_INCLUDE)\errcode.h \ - $(PY_INCLUDE)\grammar.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\node.h $(PY_PARSER)\parser.h $(PY_INCLUDE)\pgenheaders.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\token.h - -parsetok.obj: $(PY_INCLUDE)\bitset.h pyconfig.h $(PY_INCLUDE)\errcode.h \ - $(PY_INCLUDE)\grammar.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\node.h $(PY_PARSER)\parser.h $(PY_INCLUDE)\parsetok.h \ - $(PY_INCLUDE)\pgenheaders.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\token.h \ - $(PY_PARSER)\tokenizer.h - -pgen.obj: $(PY_INCLUDE)\bitset.h pyconfig.h $(PY_INCLUDE)\grammar.h \ - $(PY_INCLUDE)\metagrammar.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\node.h $(PY_PARSER)\pgen.h $(PY_INCLUDE)\pgenheaders.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\token.h - -pgenmain.obj: $(PY_INCLUDE)\bitset.h pyconfig.h $(PY_INCLUDE)\grammar.h \ - $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\node.h \ - $(PY_INCLUDE)\parsetok.h $(PY_PARSER)\pgen.h $(PY_INCLUDE)\pgenheaders.h \ - $(PY_INCLUDE)\pydebug.h - -printgrammar.obj: $(PY_INCLUDE)\bitset.h pyconfig.h $(PY_INCLUDE)\grammar.h \ - $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\pgenheaders.h \ - $(PY_INCLUDE)\pydebug.h - -tokenizer.obj: pyconfig.h $(PY_INCLUDE)\errcode.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\pgenheaders.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\token.h $(PY_PARSER)\tokenizer.h - -atof.obj: pyconfig.h - -bltinmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h \ - $(PY_INCLUDE)\complexobject.h pyconfig.h $(PY_INCLUDE)\dictobject.h \ - $(PY_INCLUDE)\eval.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\mymath.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\node.h $(PY_INCLUDE)\object.h \ - $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -ceval.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\eval.h \ - $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\frameobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\opcode.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -compile.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\graminit.h \ - $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h \ - $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\node.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\opcode.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\structmember.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\token.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -errors.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -fmod.obj: pyconfig.h $(PY_INCLUDE)\mymath.h - -frozen.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -frozenmain.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -getargs.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -getcompiler.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -getcopyright.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -getmtime.obj: pyconfig.h - -getplatform.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -getversion.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\patchlevel.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -graminit.obj: $(PY_INCLUDE)\bitset.h pyconfig.h $(PY_INCLUDE)\grammar.h \ - $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\pgenheaders.h \ - $(PY_INCLUDE)\pydebug.h - -hypot.obj: pyconfig.h $(PY_INCLUDE)\mymath.h $(PY_INCLUDE)\myproto.h - -import.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\errcode.h $(PY_INCLUDE)\eval.h \ - $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h \ - $(PY_INCLUDE)\import.h $(PY_PYTHON)\importdl.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\marshal.h $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\node.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\osdefs.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\token.h \ - $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -importdl.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_PYTHON)\importdl.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\osdefs.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -marshal.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longintrepr.h $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\marshal.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -modsupport.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -mystrtoul.obj: pyconfig.h - -pyfpe.obj: pyconfig.h $(PY_INCLUDE)\pyfpe.h - -pystate.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -pythonrun.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\bitset.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h \ - $(PY_INCLUDE)\complexobject.h pyconfig.h $(PY_INCLUDE)\dictobject.h \ - $(PY_INCLUDE)\errcode.h $(PY_INCLUDE)\eval.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\grammar.h \ - $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h \ - $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\marshal.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\node.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\parsetok.h $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h \ - $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h \ - $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -sigcheck.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\pydebug.h \ - $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \ - $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ - $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -strdup.obj: pyconfig.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h - -strtod.obj: pyconfig.h - -structmember.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ - $(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\structmember.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - -sysmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \ - $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\osdefs.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h - -thread.obj: pyconfig.h $(PY_INCLUDE)\thread.h - -traceback.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\frameobject.h \ - $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h $(PY_INCLUDE)\intobject.h \ - $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h $(PY_INCLUDE)\longobject.h \ - $(PY_INCLUDE)\methodobject.h $(PY_INCLUDE)\modsupport.h \ - $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h $(PY_INCLUDE)\myproto.h \ - $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h $(PY_INCLUDE)\osdefs.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\structmember.h \ - $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/makefile.omk b/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/makefile.omk deleted file mode 100644 index 28c5de45..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/makefile.omk +++ /dev/null @@ -1,1301 +0,0 @@ -###################################################################### -# -# Top-Level Makefile for Building Python for OS/2 -# -# This makefile was developed for use with IBM's VisualAge C/C++ -# for OS/2 compiler, version 3.0, with Fixpack 8 applied. It uses -# the commercial OpusMAKE tool. -# -# The output of the build is a largish Python15.DLL containing the -# essential modules of Python and a small Python.exe program to start -# the interpreter. When embedding Python within another program, only -# Python15.DLL is needed. -# -# These two binaries can be statically linked with the VisualAge C/C++ -# runtime library (producing larger binaries), or dynamically linked -# to make smaller ones that require the compiler to be installed on -# any system Python is used on. -# -# History (Most Recent First) -# -# 20-Nov-97 jrr Cleaned Up for Applying to Distribution -# 29-Oct-97 jrr Modified for Use with Python 1.5 Alpha 4 -# 03-Aug-96 jrr Original for Use with Python 1.4 Release -# -###################################################################### - -################### -# Places and Things -################### -PY_MODULES = ..\..\Modules -PY_OBJECTS = ..\..\Objects -PY_PARSER = ..\..\Parser -PY_PYTHON = ..\..\Python -PY_INCLUDE = ..\..\Include -PY_INCLUDES = .;$(PY_INCLUDE);$(PY_MODULES);$(PY_OBJECTS);$(PY_PARSER);$(PY_PYTHON) - -# Where to Find the IBM TCP/IP Socket Includes and Libraries -OS2TCPIP = C:\MPTN - -# Where to Put the .OBJ Files, To Keep Them Out of the Way -.PATH.obj = obj - -# Search Path for Include Files -PROJINCLUDE = .;$(OS2TCPIP)\Include;$(PY_INCLUDES) - -# Place to Search for Sources re OpusMAKE Dependency Generator (Commercial) -MKMF_SRCS = $(PY_MODULES)\*.c $(PY_OBJECTS)\*.c $(PY_PARSER)\*.c $(PY_PYTHON)\*.c - -.HDRPATH.c := $(PROJINCLUDE,;= ) $(.HDRPATH.c) -.PATH.c = .;$(PY_MODULES);$(PY_OBJECTS);$(PY_PARSER);$(PY_PYTHON) -OTHERLIBS = $(OS2TCPIP)\lib\so32dll.lib $(OS2TCPIP)\lib\tcp32dll.lib - -################# -# Inference Rules -################# - - -################### -# Python Subsystems -################### - -# PYTHON is the central core, containing the builtins and interpreter. -PYTHON = \ - BltinModule.obj \ - CEval.obj \ - Compile.obj \ - Errors.obj \ - Frozen.obj \ - Getargs.obj \ - GetCompiler.obj \ - GetCopyright.obj \ - GetMTime.obj \ - GetOpt.obj \ - GetPlatform.obj \ - GetVersion.obj \ - GramInit.obj \ - Import.obj \ - ImportDL.obj \ - Marshal.obj \ - ModSupport.obj \ - MyStrtoul.obj \ - PyState.obj \ - PythonRun.obj \ - StructMember.obj \ - SysModule.obj \ - Thread.obj \ - TraceBack.obj \ - FrozenMain.obj - -# Omitted Python Elements (and Reason): - # atof.c -- Implementation for Platforms w/o This Function - # dup2.c -- Implementation for Platforms w/o This Function - # fmod.c -- Implementation for Platforms w/o This Function - # getcwd.c -- Implementation for Platforms w/o This Function - # hypot.c -- Implementation for Platforms w/o This Function - # memmove.c -- Implementation for Platforms w/o This Function - # strdup.c -- Implementation for Platforms w/o This Function - # strerror.c -- Implementation for Platforms w/o This Function - # strtod.c -- Implementation for Platforms w/o This Function - - # sigcheck.c -- Primitive Signal Catcher (SignalModule.c Used Instead) - # pyfpe.c -- Primitive FPE Catcher (Not Referenced by Anyone) - # frozenmain.c - -# Python's Internal Parser -PARSER = \ - Acceler.obj \ - Grammar1.obj \ - MyReadline.obj \ - Node.obj \ - Parser.obj \ - ParseTok.obj \ - Tokenizer.obj - -# Python Object Types -OBJECTS = \ - Abstract.obj \ - ClassObject.obj \ - CObject.obj \ - ComplexObject.obj \ - DictObject.obj \ - FileObject.obj \ - FloatObject.obj \ - FrameObject.obj \ - FuncObject.obj \ - IntObject.obj \ - ListObject.obj \ - LongObject.obj \ - MethodObject.obj \ - ModuleObject.obj \ - Object.obj \ - RangeObject.obj \ - SliceObject.obj \ - StringObject.obj \ - TupleObject.obj \ - TypeObject.obj - -# Omitted Objects (and Reason): - # xxobject.c -- Template to Create Your Own Object Types - -# Extension Modules (Built-In or as Separate DLLs) -MODULES = \ - ArrayModule.obj \ - BinAscii.obj \ - CMathModule.obj \ - cPickle.obj \ - cStringIO.obj \ - ErrnoModule.obj \ - GetBuildInfo.obj \ - GetPathP.obj \ - Main.obj \ - MathModule.obj \ - MD5c.obj \ - MD5Module.obj \ - Operator.obj \ - PosixModule.obj \ - RegexModule.obj \ - RegExpr.obj \ - ReopModule.obj \ - SelectModule.obj \ - SignalModule.obj \ - SocketModule.obj \ - SoundEx.obj \ - StropModule.obj \ - StructModule.obj \ - TimeModule.obj \ - ThreadModule.obj \ - YUVConvert.obj - -# Omitted Modules (and Description/Reason): - # - # Multimedia: - # almodule.c -- Non-OS/2 Audio Channel Facility (?) - # cdmodule.c -- Wrapper of Non-OS/2 CD Audio Functions - # audioop.c -- Various Compute Operations on Audio Samples - # imageop.c -- Various Compute Operations on Video Samples - # imgfile.c -- Wrapper of SGI ImageLib API - # rgbimgmodule.c -- Non-OS/2 Image Read/Write Capability (Primitive) - # sunaudiodev.c -- Wrapper of Sun Audio Device API - # clmodule.c -- Wrapper of SGI Image/Audio Compression API - - # Database: - # dbmmodule.c -- Wrapper of DBM Database API (Generic Flavor) - # bsddbmodule.c -- Wrapper of DBM Database API (BSD Flavor) - # gdbmmodule.c -- Wrapper of DBM Database API (GNU Flavor) - - # Cryptography: - # cryptmodule.c -- Simple Wrapper for crypt() Function - # rotormodule.c -- Implementation of Enigma Crypto Based on Rotors - -# cgensupport.obj \ -# fcntlmodule.obj \ -# fmmodule.obj \ -# fpectlmodule.obj \ -# fpetestmodule.obj \ -# Unix-Specific getpath.obj \ -# glmodule.obj \ -# grpmodule.obj \ -# mpzmodule.obj \ -# nismodule.obj \ -# parsermodule.obj \ -# pcremodule.obj \ -# pwdmodule.obj \ -# pypcre.obj \ -# readline.obj \ -# resource.obj \ -# sgimodule.obj \ -# svmodule.obj \ -# syslogmodule.obj \ -# termios.obj \ -# timingmodule.obj \ - - # User Interface: -# _tkinter.obj \ -# stdwinmodule.obj \ -# cursesmodule.obj \ -# tclNotify.obj \ -# tkappinit.obj \ - # flmodule.c -- Wrapper of FORMS Library (Screen Forms) - - # zlibmodule.c -- Wrapper of ZLib Compression API (GZip Format) - # puremodule.c -- Wrapper of Purify Debugging API (Probably Non-OS/2) - # dlmodule.c -- Some Wierd Form of Data Processing Module - # xxmodule.c -- Template to Create Your Own Module - -# -# Standalone Parser Generator Program (Shares Some of Python's Modules) -PGEN = \ - PGenMain.obj \ - PGen.obj \ - PrintGrammar.obj \ - ListNode.obj \ - Grammar.obj \ - BitSet.obj \ - FirstSets.obj \ - MetaGrammar.obj - -# Omitted Parser Elements (and Reason): - # intrcheck.c -- Not Referenced by Anyone (?) - -################## -# Macros and Flags -################## -_BASE = /Q /W2 /I$(PROJINCLUDE) - # /Q = Omit IBM Copyright - # /W2 = Show Warnings/Errors Only - # /Fi = Create Precompiled Headers - # /Si = Utilize Precompiled Headers - -_GEN = /G4 /Gm /Gd /B"/STACK:360000" - # /G4 = Generate Code for 486 (Use 386 for Debugger) - # /Gm = Use Multithread Runtime - # /Gd = Dynamically Load Runtime - # /Gs = Remove Code for Stack Probes - # /Gx = Remove C++ Exception-Handling Info - # /Tdp = Generate Code for C++ Templates - # /Rn = Generate Code without a Runtime - # /B"/STACK:n" = Set Stack Size - -_OPT = /O /Gl - # /O = Enable Speed-Optimizations - # /Ol = Pass Code Thru Intermediate Linker - # /Gu = Advise Linker All Ext Data is ID'd - # /Gl = Have Linker Remove Unused Fns - -_DBG = /DHAVE_CONFIG_H /DUSE_SOCKET - # /Ti = Embed Debugger/Analyzer Recs - # /Tm = Enable Debug Memory Fns - # /Tx = Request Full Dump Upon Exception - # /DDEBUG = Enable App-Internal Debugging Code - # /DUSE_SOCKET = - # /DUSE_DL_EXPORT = - -_OUT = - # /Fb = Embed Browser Recs - # /Gh = Generate Code for Profiler Hooks - # /Fl = Output C/C++ Listing Files - # /Lf = Provide Full (Detailed) Listing Files - # /Fm. = Output Linker Map File - # /Ft. = Output C++ Template Resolution Files - -_MAP = /FmNoise\$(.TARGET,B,>.map) - -_DLL = /Ge- -_EXE = /Ge - # /Ge = Create an EXE, not DLL - -CFLAGS = $(_BASE) $(_GEN) $(_OPT) $(_DBG) $(_OUT) $(_EXE) /Ss -CPPFLAGS = $(_BASE) $(_GEN) $(_OPT) $(_DBG) $(_OUT) $(_EXE) - -################### -# Primary Target(s) -################### -All: obj noise PyCore.lib Python15.lib Python15.dll Python.exe PGen.exe - -############## -# -############## - -# Object Library of All Essential Python Routines -PyCore.lib: $(MODULES) $(OBJECTS) $(PARSER) $(PYTHON) Config.obj - %do "%.lib" - -Python15.dll: Compile.obj PyCore.lib Python.def - %do "%.dll" CPPFLAGS+=/B"/NOE" CPPFLAGS+=$(_MAP) - -Compile.obj: Compile.c - %do ".c.obj" CFLAGS+=$(_DLL) - -# Import Library for Using the Python15.dll -Python15.lib: Python.def - %do ".def.lib" - -# Small Program to Start Interpreter in Python15.dll -Python.exe: Python.obj Python15.lib - %do "%.exe" CPPFLAGS+=$(_MAP) - -#Python.obj: Python.c -# %do ".c.obj" CFLAGS+=$(_EXE) - -PGen.exe: $(PGEN) PyCore.lib - %do "%.exe" CPPFLAGS+=$(_MAP) - -####################### -# Miscellaneous Targets -####################### - -# Remove Intermediate Targets but Leave Executable Binaries -clean: - -- Del /Q $(.PATH.obj)\*.obj >NUL 2>&1 - -- Del /Q /Y Noise >NUL 2>&1 - -- Del /Q $(ERRS) >NUL 2>&1 - -# Remove All Targets, Including Final Binaries -distclean: clean - -- Del /Q PyCore.lib Python15.lib >NUL 2>&1 - -- Del /Q Python15.dll Python.exe >NUL 2>&1 - -release: Python.exe Python15.dll Python15.lib - -- @Echo Y | copy /U $(.SOURCES,M"*.exe") D:\EXEs - -- @Echo Y | copy /U $(.SOURCES,M"*.dll") D:\DLLs - -- @Echo Y | copy /U $(.SOURCES,M"*.lib") E:\Tau\Lib - -test: - python ..\..\lib\test\regrtest.py - -# Update Dependencies on Targets (Uses OpusMAKE Commercial Product) -depend: - D:\OpusMake\os2mkmf -c -s - -### OPUS MKMF: Do not remove this line! Generated dependencies follow. - -_tkinter.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -almodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -arraymodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -audioop.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h mymath.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -binascii.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -bsddbmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -cdmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -cgensupport.obj: abstract.h ceval.h cgensupport.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -clmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -cmathmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h mymath.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -cpickle.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h cstringio.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - mymath.h myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -cryptmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -cstringio.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h cstringio.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -cursesmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -dbmmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -dlmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -errno.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -errnomodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -fcntlmodule.obj: abstract.h c:\mptn\include\sys\ioctl.h ceval.h \ - classobject.h cobject.h complexobject.h pyconfig.h dictobject.h \ - fileobject.h floatobject.h funcobject.h import.h intobject.h \ - intrcheck.h listobject.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h myproto.h object.h objimpl.h pydebug.h \ - pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ - sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h - -flmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h \ - structmember.h sysmodule.h traceback.h tupleobject.h - -fmmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -fpectlmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -fpetestmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -gdbmmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -getbuildinfo.obj: pyconfig.h - -getpath.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h osdefs.h pydebug.h pyerrors.h pyfpe.h pystate.h \ - python.h pythonrun.h rangeobject.h sliceobject.h stringobject.h \ - sysmodule.h traceback.h tupleobject.h - -glmodule.obj: abstract.h ceval.h cgensupport.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -grpmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - grp.h import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -imageop.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -imgfile.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -main.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -mathmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h mymath.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -md5c.obj: pyconfig.h md5.h - -md5module.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h md5.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -mpzmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longintrepr.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h myproto.h object.h objimpl.h pydebug.h \ - pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ - sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h - -nismodule.obj: abstract.h c:\mptn\include\sys\time.h ceval.h classobject.h \ - cobject.h complexobject.h pyconfig.h dictobject.h fileobject.h \ - floatobject.h funcobject.h import.h intobject.h intrcheck.h \ - listobject.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h myproto.h object.h objimpl.h pydebug.h \ - pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ - sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h - -operator.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -parsermodule.obj: abstract.h ceval.h classobject.h cobject.h compile.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h graminit.h import.h intobject.h intrcheck.h \ - listobject.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h myproto.h node.h object.h objimpl.h \ - pydebug.h pyerrors.h pyfpe.h pystate.h python.h pythonrun.h \ - rangeobject.h sliceobject.h stringobject.h sysmodule.h token.h \ - traceback.h tupleobject.h - -pcremodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pcre-internal.h pcre.h pydebug.h pyerrors.h \ - pyfpe.h pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -posix.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - mytime.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h \ - python.h pythonrun.h rangeobject.h sliceobject.h stringobject.h \ - sysmodule.h traceback.h tupleobject.h - -posixmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - mytime.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h \ - python.h pythonrun.h rangeobject.h sliceobject.h stringobject.h \ - sysmodule.h traceback.h tupleobject.h - -puremodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -pwdmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pwd.h pydebug.h pyerrors.h pyfpe.h pystate.h \ - python.h pythonrun.h rangeobject.h sliceobject.h stringobject.h \ - sysmodule.h traceback.h tupleobject.h - -pypcre.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - graminit.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pcre-internal.h pcre.h pydebug.h \ - pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ - sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h - -readline.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -regexmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h regexpr.h sliceobject.h stringobject.h \ - sysmodule.h traceback.h tupleobject.h - -regexpr.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h regexpr.h \ - sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h - -reopmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h regexpr.h sliceobject.h stringobject.h \ - sysmodule.h traceback.h tupleobject.h - -resource.obj: abstract.h c:\mptn\include\sys\time.h ceval.h classobject.h \ - cobject.h complexobject.h pyconfig.h dictobject.h fileobject.h \ - floatobject.h funcobject.h import.h intobject.h intrcheck.h \ - listobject.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h myproto.h object.h objimpl.h pydebug.h \ - pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ - sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h - -rgbimgmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -rotormodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h mymath.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -selectmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h myselect.h mytime.h object.h objimpl.h pydebug.h \ - pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ - sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h - -sgimodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -signalmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -socketmodule.obj: abstract.h c:\mptn\include\netinet\in.h \ - c:\mptn\include\sys\socket.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h mytime.h netdb.h object.h objimpl.h pydebug.h pyerrors.h \ - pyfpe.h pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -soundex.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -stdwinmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -stropmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -structmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - mymath.h myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -sunaudiodev.obj: abstract.h c:\mptn\include\sys\ioctl.h ceval.h \ - classobject.h cobject.h complexobject.h pyconfig.h dictobject.h \ - fileobject.h floatobject.h funcobject.h import.h intobject.h \ - intrcheck.h listobject.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h myproto.h object.h objimpl.h pydebug.h \ - pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ - sliceobject.h stringobject.h structmember.h sysmodule.h \ - traceback.h tupleobject.h - -svmodule.obj: abstract.h c:\mptn\include\sys\time.h ceval.h classobject.h \ - cobject.h compile.h complexobject.h pyconfig.h dictobject.h \ - fileobject.h floatobject.h funcobject.h import.h intobject.h \ - intrcheck.h listobject.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h myproto.h object.h objimpl.h pydebug.h \ - pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ - sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h \ - yuv.h - -syslogmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h syslog.h sysmodule.h traceback.h tupleobject.h - -termios.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -threadmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h thread.h traceback.h tupleobject.h - -timemodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - mytime.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h \ - python.h pythonrun.h rangeobject.h sliceobject.h stringobject.h \ - sysmodule.h traceback.h tupleobject.h - -timingmodule.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h timing.h traceback.h tupleobject.h - -xxmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -yuvconvert.obj: yuv.h - -zlibmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -abstract.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -classobject.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h \ - structmember.h sysmodule.h traceback.h tupleobject.h - -cobject.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -complexobject.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - mymath.h myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -dictobject.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -fileobject.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h \ - structmember.h sysmodule.h traceback.h tupleobject.h - -floatobject.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h mymath.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -frameobject.obj: abstract.h ceval.h classobject.h cobject.h compile.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - frameobject.h funcobject.h import.h intobject.h intrcheck.h \ - listobject.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h myproto.h object.h objimpl.h opcode.h \ - pydebug.h pyerrors.h pyfpe.h pystate.h python.h pythonrun.h \ - rangeobject.h sliceobject.h stringobject.h structmember.h \ - sysmodule.h traceback.h tupleobject.h - -funcobject.obj: abstract.h ceval.h classobject.h cobject.h compile.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h structmember.h sysmodule.h traceback.h \ - tupleobject.h - -intobject.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -listobject.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -longobject.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longintrepr.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h mymath.h myproto.h object.h objimpl.h \ - pydebug.h pyerrors.h pyfpe.h pystate.h python.h pythonrun.h \ - rangeobject.h sliceobject.h stringobject.h sysmodule.h traceback.h \ - tupleobject.h - -methodobject.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h token.h traceback.h tupleobject.h - -moduleobject.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -object.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -rangeobject.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -sliceobject.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -stringobject.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - mymath.h myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -tupleobject.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -typeobject.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -xxobject.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -acceler.obj: bitset.h pyconfig.h grammar.h mymalloc.h myproto.h node.h \ - parser.h pgenheaders.h pydebug.h token.h - -bitset.obj: bitset.h pyconfig.h mymalloc.h myproto.h pgenheaders.h pydebug.h - -firstsets.obj: bitset.h pyconfig.h grammar.h mymalloc.h myproto.h \ - pgenheaders.h pydebug.h token.h - -grammar.obj: bitset.h pyconfig.h grammar.h mymalloc.h myproto.h \ - pgenheaders.h pydebug.h token.h - -grammar1.obj: bitset.h pyconfig.h grammar.h mymalloc.h myproto.h \ - pgenheaders.h pydebug.h token.h - -intrcheck.obj: pyconfig.h intrcheck.h mymalloc.h myproto.h - -listnode.obj: pyconfig.h mymalloc.h myproto.h node.h pgenheaders.h pydebug.h \ - token.h - -metagrammar.obj: bitset.h pyconfig.h grammar.h metagrammar.h mymalloc.h \ - myproto.h pgen.h pgenheaders.h pydebug.h - -myreadline.obj: pyconfig.h intrcheck.h mymalloc.h myproto.h - -node.obj: pyconfig.h mymalloc.h myproto.h node.h pgenheaders.h pydebug.h - -parser.obj: bitset.h pyconfig.h errcode.h grammar.h mymalloc.h \ - myproto.h node.h parser.h pgenheaders.h pydebug.h token.h - -parsetok.obj: bitset.h pyconfig.h errcode.h grammar.h mymalloc.h myproto.h \ - node.h parser.h parsetok.h pgenheaders.h pydebug.h token.h \ - tokenizer.h - -pgen.obj: bitset.h pyconfig.h grammar.h metagrammar.h mymalloc.h \ - myproto.h node.h pgen.h pgenheaders.h pydebug.h token.h - -pgenmain.obj: bitset.h pyconfig.h grammar.h mymalloc.h myproto.h node.h \ - parsetok.h pgen.h pgenheaders.h pydebug.h - -printgrammar.obj: bitset.h pyconfig.h grammar.h mymalloc.h myproto.h \ - pgenheaders.h pydebug.h - -tokenizer.obj: pyconfig.h errcode.h mymalloc.h myproto.h pgenheaders.h \ - pydebug.h token.h tokenizer.h - -atof.obj: pyconfig.h - -bltinmodule.obj: abstract.h ceval.h classobject.h cobject.h compile.h \ - complexobject.h pyconfig.h dictobject.h eval.h fileobject.h \ - floatobject.h funcobject.h import.h intobject.h intrcheck.h \ - listobject.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h mymath.h myproto.h node.h object.h \ - objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -ceval.obj: abstract.h ceval.h classobject.h cobject.h compile.h \ - complexobject.h pyconfig.h dictobject.h eval.h fileobject.h \ - floatobject.h frameobject.h funcobject.h import.h intobject.h \ - intrcheck.h listobject.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h myproto.h object.h objimpl.h opcode.h \ - pydebug.h pyerrors.h pyfpe.h pystate.h python.h pythonrun.h \ - rangeobject.h sliceobject.h stringobject.h sysmodule.h traceback.h \ - tupleobject.h - -compile.obj: abstract.h ceval.h classobject.h cobject.h compile.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h graminit.h import.h intobject.h intrcheck.h \ - listobject.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h myproto.h node.h object.h objimpl.h \ - opcode.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h \ - structmember.h sysmodule.h token.h traceback.h tupleobject.h - -errors.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -fmod.obj: pyconfig.h mymath.h - -frozen.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -frozenmain.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -getargs.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -getcompiler.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -getcopyright.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -getmtime.obj: pyconfig.h - -getplatform.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -getversion.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h patchlevel.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -graminit.obj: bitset.h pyconfig.h grammar.h mymalloc.h myproto.h \ - pgenheaders.h pydebug.h - -hypot.obj: pyconfig.h mymath.h myproto.h - -import.obj: abstract.h ceval.h classobject.h cobject.h compile.h \ - complexobject.h pyconfig.h dictobject.h errcode.h eval.h \ - fileobject.h floatobject.h funcobject.h import.h importdl.h \ - intobject.h intrcheck.h listobject.h longobject.h marshal.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - node.h object.h objimpl.h osdefs.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h token.h traceback.h tupleobject.h - -importdl.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h importdl.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h osdefs.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -marshal.obj: abstract.h ceval.h classobject.h cobject.h compile.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longintrepr.h longobject.h marshal.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h myproto.h object.h objimpl.h pydebug.h \ - pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ - sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h - -modsupport.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -mystrtoul.obj: pyconfig.h - -pyfpe.obj: pyconfig.h pyfpe.h - -pystate.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -pythonrun.obj: abstract.h bitset.h ceval.h classobject.h cobject.h \ - compile.h complexobject.h pyconfig.h dictobject.h errcode.h eval.h \ - fileobject.h floatobject.h funcobject.h grammar.h import.h \ - intobject.h intrcheck.h listobject.h longobject.h marshal.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - node.h object.h objimpl.h parsetok.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h - -sigcheck.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h pydebug.h pyerrors.h pyfpe.h pystate.h python.h \ - pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ - traceback.h tupleobject.h - -strdup.obj: pyconfig.h mymalloc.h myproto.h - -strtod.obj: pyconfig.h - -structmember.obj: abstract.h ceval.h classobject.h cobject.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h structmember.h sysmodule.h traceback.h \ - tupleobject.h - -sysmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ - pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ - import.h intobject.h intrcheck.h listobject.h longobject.h \ - methodobject.h modsupport.h moduleobject.h mymalloc.h myproto.h \ - object.h objimpl.h osdefs.h pydebug.h pyerrors.h pyfpe.h pystate.h \ - python.h pythonrun.h rangeobject.h sliceobject.h stringobject.h \ - sysmodule.h traceback.h tupleobject.h - -thread.obj: pyconfig.h thread.h - -traceback.obj: abstract.h ceval.h classobject.h cobject.h compile.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - frameobject.h funcobject.h import.h intobject.h intrcheck.h \ - listobject.h longobject.h methodobject.h modsupport.h \ - moduleobject.h mymalloc.h myproto.h object.h objimpl.h osdefs.h \ - pydebug.h pyerrors.h pyfpe.h pystate.h python.h pythonrun.h \ - rangeobject.h sliceobject.h stringobject.h structmember.h \ - sysmodule.h traceback.h tupleobject.h diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/pyconfig.h b/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/pyconfig.h deleted file mode 100644 index b834fa73..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/pyconfig.h +++ /dev/null @@ -1,213 +0,0 @@ -#ifndef Py_CONFIG_H -#define Py_CONFIG_H - -/********************************************************************** - * pyconfig.h. NOT Generated automatically by configure. - * - * This is a manually maintained version used for the IBM VisualAge - * C/C++ compiler on the OS/2 platform. It is a standard part of - * the Python distribution. - * - * FILESYSTEM DEFINES: - * The code specific to a particular way of naming files and - * directory paths should be wrapped around one of the following - * #defines: - * - * DOSFILESYS PCDOS-Style (for PCDOS, Windows and OS/2) - * MACFILESYS Macintosh-Style - * UNIXFILESYS Unix-Style - * AMIGAFILESYS AmigaDOS-Style - * - * Because of the different compilers and operating systems in - * use on the Intel platform, neither the compiler name nor - * the operating system name is sufficient. - * - * OS/2 DEFINES: - * The code specific to OS/2's Program API should be wrapped around - * - * __TOS_OS2__ Target Operating System, OS/2 - * - * Any code specific to the compiler itself should be wrapped with - * - * __IBMC__ IBM C Compiler - * __IBMCPP__ IBM C++ Compiler - * - * Note that since the VisualAge C/C++ compiler is also available - * for the Windows platform, it may be necessary to use both a - * __TOS_OS2__ and a __IBMC__ to select a very specific environment. - * - **********************************************************************/ - -/* - * Some systems require special declarations for data items imported - * or exported from dynamic link libraries. Note that the definition - * of DL_IMPORT covers both cases. Define USE_DL_IMPORT for the client - * of a DLL. Define USE_DL_EXPORT when making a DLL. - */ - -#include - -/* Configuration Options for Finding Modules */ -#define PREFIX "" -#define EXEC_PREFIX "" - -/* Provide a default library so writers of extension modules - * won't have to explicitly specify it anymore - */ -#pragma library("Python22.lib") - -/***************************************************/ -/* 32-Bit IBM VisualAge C/C++ v3.0 for OS/2 */ -/* (Convert Compiler Flags into Useful Switches) */ -/***************************************************/ -#define PLATFORM "os2" -#define COMPILER "[VisualAge C/C++]" -#define PYOS_OS2 /* Define Indicator of Operating System */ -#define PYCC_VACPP /* Define Indicator of C Compiler */ - - /* Platform Filesystem */ -#define PYTHONPATH ".;.\\lib;.\\lib\\plat-win;.\\lib\\lib-tk" -#define DOSFILESYS /* OS/2 Uses the DOS File Naming Conventions */ -/* #define IMPORT_8x3_NAMES (let's move up to long filenames) */ - - /* Platform CPU-Mode Dependencies */ -#define WORD_BIT 32 /* OS/2 is a 32-Bit Operating System */ -#define LONG_BIT 32 -#define SIZEOF_INT 4 /* Count of Bytes in an (int) */ -#define SIZEOF_LONG 4 /* Count of Bytes in a (long) */ -#define SIZEOF_VOID_P 4 /* Count of Bytes in a (void *) */ -/* #define HAVE_LONG_LONG 1 */ /* VAC++ does not support (long long) */ -/* #define SIZEOF_LONG_LONG 8 */ /* Count of Bytes in a (long long) */ - -/* unicode definines */ -#define Py_USING_UNICODE -#define PY_UNICODE_TYPE wchar_t -#define Py_UNICODE_SIZE SIZEOF_SHORT - -/* dynamic loading */ -#define HAVE_DYNAMIC_LOADING 1 - -/* Define if type char is unsigned and you are not using gcc. */ -#ifndef __CHAR_UNSIGNED__ -/* #undef __CHAR_UNSIGNED__ */ -#endif - -typedef int mode_t; -typedef int uid_t; -typedef int gid_t; -typedef int pid_t; - -#if defined(__MULTI__) /* If Compiler /Gt+ Multithread Option Enabled, */ - #define WITH_THREAD 1 /* Enable Threading Throughout Python */ - #define OS2_THREADS 1 /* And Use the OS/2 Flavor of Threads */ -/* #define _REENTRANT 1 */ /* Use thread-safe errno, h_errno, and other fns */ -#endif - - /* Compiler Runtime Library Capabilities */ -#include -#include -/* #undef BAD_STATIC_FORWARD */ /* if compiler botches static fwd decls */ - -#define STDC_HEADERS 1 /* VAC++ is an ANSI C Compiler */ -#define HAVE_LIMITS_H 1 /* #include */ -#define HAVE_STDLIB_H 1 /* #include */ -#define HAVE_HYPOT 1 /* hypot() */ -#define HAVE_PUTENV 1 /* putenv() */ -#define HAVE_STDDEF_H 1 /* #include */ -/* #define VA_LIST_IS_ARRAY 1 */ /* if va_list is an array of some kind */ - - /* Variable-Arguments/Prototypes */ -#define HAVE_PROTOTYPES 1 /* VAC++ supports C Function Prototypes */ -#define HAVE_STDARG_H 1 /* #include */ -#define HAVE_STDARG_PROTOTYPES 1 /* Our has prototypes */ - - /* String/Memory/Locale Operations */ -#define HAVE_STRDUP 1 /* strdup() */ -#define HAVE_MEMMOVE 1 /* memmove() */ -#define HAVE_STRERROR 1 /* strerror() */ -#define HAVE_SETLOCALE 1 /* setlocale() */ -#define HAVE_LOCALE_H 1 /* #include */ -#define MALLOC_ZERO_RETURNS_NULL 1 /* Our malloc(0) returns a NULL ptr */ - - /* Signal Handling */ -#define RETSIGTYPE void /* Return type of handlers (int or void) */ -#define HAVE_SIGNAL_H 1 /* #include */ -/* #undef WANT_SIGFPE_HANDLER */ /* Handle SIGFPE (see Include/pyfpe.h) */ -/* #define HAVE_ALARM 1 */ /* alarm() */ -/* #define HAVE_SIGINTERRUPT 1 */ /* siginterrupt() */ -/* #define HAVE_SIGRELSE 1 */ /* sigrelse() */ -#define DONT_HAVE_SIG_ALARM 1 -#define DONT_HAVE_SIG_PAUSE 1 - - /* Clock/Time Support */ -#define HAVE_FTIME 1 /* We have ftime() in */ -#define HAVE_CLOCK 1 /* clock() */ -#define HAVE_STRFTIME 1 /* strftime() */ -#define HAVE_STRPTIME 1 /* strptime() */ -#define HAVE_MKTIME 1 /* mktime() */ -#define HAVE_TZNAME 1 /* No tm_zone but do have tzname[] */ -#define HAVE_TIMES 1 /* #include */ -#define HAVE_SYS_UTIME_H 1 /* #include */ -/* #define HAVE_UTIME_H 1 */ /* #include */ -#define HAVE_SYS_TIME_H 1 /* #include */ -/* #define TM_IN_SYS_TIME 1 */ /* declares struct tm */ -#define HAVE_GETTIMEOFDAY 1 /* gettimeofday() */ -/* #define GETTIMEOFDAY_NO_TZ 1 */ /* gettimeofday() does not have 2nd arg */ -/* #define HAVE_TIMEGM 1 */ /* timegm() */ -#define TIME_WITH_SYS_TIME 1 /* Mix and */ -#define SYS_SELECT_WITH_SYS_TIME 1 /* Mix and */ -/* #define HAVE_ALTZONE 1 */ /* if defines altzone */ - - /* Network/Sockets Support */ -#define HAVE_SYS_SELECT_H 1 /* #include */ -#define BSD_SELECT 1 /* Use BSD versus OS/2 form of select() */ -#define HAVE_SELECT 1 /* select() */ -#define HAVE_GETPEERNAME 1 /* getpeername() */ -/* #undef HAVE_GETHOSTNAME_R 1 */ /* gethostname_r() */ - - /* File I/O */ -#define HAVE_DUP2 1 /* dup2() */ -#define HAVE_EXECV 1 /* execv() */ -#define HAVE_SETVBUF 1 /* setvbuf() */ -#define HAVE_GETCWD 1 /* getcwd() */ -#define HAVE_PIPE 1 /* pipe() [OS/2-specific code added] */ -#define HAVE_FCNTL_H 1 /* #include */ -/* #define HAVE_FLOCK 1 */ /* flock() */ -/* #define HAVE_TRUNCATE 1 */ /* truncate() */ -/* #define HAVE_FTRUNCATE 1 */ /* ftruncate() */ -/* #define HAVE_LSTAT 1 */ /* lstat() */ -/* #define HAVE_DIRENT_H 1 */ /* #include */ -/* #define HAVE_OPENDIR 1 */ /* opendir() */ - - /* Process Operations */ -#define HAVE_GETPID 1 /* getpid() */ -#define HAVE_SYSTEM 1 /* system() */ -#define HAVE_WAIT 1 /* wait() */ -#define HAVE_KILL 1 /* kill() [OS/2-specific code added] */ -#define HAVE_POPEN 1 /* popen() [OS/2-specific code added] */ -/* #define HAVE_GETPPID 1 */ /* getppid() */ -/* #define HAVE_WAITPID 1 */ /* waitpid() */ -/* #define HAVE_FORK 1 */ /* fork() */ - - /* User/Group ID Queries */ -/* #define HAVE_GETEGID 1 */ -/* #define HAVE_GETEUID 1 */ -/* #define HAVE_GETGID 1 */ -/* #define HAVE_GETUID 1 */ - - /* Unix-Specific */ -/* #define HAVE_SYS_UN_H 1 /* #include */ -/* #define HAVE_SYS_UTSNAME_H 1 */ /* #include */ -/* #define HAVE_SYS_WAIT_H 1 */ /* #include */ -/* #define HAVE_UNISTD_H 1 */ /* #include */ -/* #define HAVE_UNAME 1 */ /* uname () */ - -/* Define if you want documentation strings in extension modules */ -#define WITH_DOC_STRINGS 1 - -#ifdef USE_DL_EXPORT - #define DL_IMPORT(RTYPE) RTYPE _System -#endif - -#endif /* !Py_CONFIG_H */ - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/python.def b/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/python.def deleted file mode 100644 index b75cb151..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/python.def +++ /dev/null @@ -1,480 +0,0 @@ -LIBRARY PYTHON22 INITINSTANCE TERMINSTANCE -DESCRIPTION 'Python 2.2 Core DLL' -PROTMODE -DATA MULTIPLE NONSHARED - -EXPORTS - ; Data - PyCFunction_Type - PyCObject_Type - PyClass_Type - PyCode_Type - PyComplex_Type - PyDict_Type - PyExc_ArithmeticError - PyExc_AssertionError - PyExc_AttributeError - PyExc_EOFError - PyExc_EnvironmentError - PyExc_Exception - PyExc_FloatingPointError - PyExc_IOError - PyExc_ImportError - PyExc_IndexError - PyExc_KeyError - PyExc_KeyboardInterrupt - PyExc_LookupError - PyExc_MemoryError - PyExc_MemoryErrorInst - PyExc_NameError - PyExc_OSError - PyExc_OverflowError - PyExc_RuntimeError - PyExc_StandardError - PyExc_SyntaxError - PyExc_SystemError - PyExc_SystemExit - PyExc_TypeError - PyExc_ValueError - PyExc_ZeroDivisionError - PyFile_Type - PyFloat_Type - PyFrame_Type - PyFunction_Type - PyImport_FrozenModules - PyImport_Inittab - PyInstance_Type - PyInt_Type - PyList_Type - PyLong_Type - PyMethod_Type - PyModule_Type - PyOS_InputHook - PyOS_ReadlineFunctionPointer - PyRange_Type - PySlice_Type - PyString_Type - PyTraceBack_Type - PyTuple_Type - PyType_Type - Py_DebugFlag - Py_FrozenFlag - Py_InteractiveFlag - Py_NoSiteFlag - Py_OptimizeFlag - Py_TabcheckFlag - Py_UseClassExceptionsFlag - Py_VerboseFlag - _PyImport_Filetab - _PyImport_Inittab - _PyParser_Grammar - _PyParser_TokenNames - _PyThread_Started - _Py_EllipsisObject - _Py_NoneStruct - _Py_PackageContext - _Py_TrueStruct - _Py_ZeroStruct - _Py_abstract_hack - _Py_cobject_hack - _Py_re_syntax - _Py_re_syntax_table - - ; Code - PyArg_Parse - PyArg_ParseTuple - PyArg_ParseTupleAndKeywords - PyArg_VaParse - PyCFunction_Fini - PyCFunction_GetFlags - PyCFunction_GetFunction - PyCFunction_GetSelf - PyCFunction_New - PyCObject_AsVoidPtr - PyCObject_FromVoidPtrAndDesc - PyCObject_FromVoidPtr - PyCObject_GetDesc - PyCObject_Import - PyCallable_Check - PyClass_IsSubclass - PyClass_New - PyCode_Addr2Line - PyCode_New - PyComplex_AsCComplex - PyComplex_FromCComplex - PyComplex_FromDoubles - PyComplex_ImagAsDouble - PyComplex_RealAsDouble - PyDict_Clear - PyDict_DelItem - PyDict_DelItemString - PyDict_GetItem - PyDict_GetItemString - PyDict_Items - PyDict_Keys - PyDict_New - PyDict_Next - PyDict_SetItem - PyDict_SetItemString - PyDict_Size - PyDict_Values - PyErr_BadArgument - PyErr_BadInternalCall - PyErr_CheckSignals - PyErr_Clear - PyErr_ExceptionMatches - PyErr_Fetch - PyErr_Format - PyErr_GivenExceptionMatches - PyErr_NewException - PyErr_NoMemory - PyErr_NormalizeException - PyErr_Occurred - PyErr_Print - PyErr_PrintEx - PyErr_Restore - PyErr_SetFromErrno - PyErr_SetFromErrnoWithFilename - PyErr_SetInterrupt - PyErr_SetNone - PyErr_SetObject - PyErr_SetString - PyEval_AcquireLock - PyEval_AcquireThread - PyEval_CallFunction - PyEval_CallMethod - PyEval_CallObject - PyEval_CallObjectWithKeywords - PyEval_EvalCode - PyEval_GetBuiltins - PyEval_GetFrame - PyEval_GetGlobals - PyEval_GetLocals - PyEval_GetRestricted - PyEval_InitThreads - PyEval_ReleaseLock - PyEval_ReleaseThread - PyEval_RestoreThread - PyEval_SaveThread - PyFile_AsFile - PyFile_FromFile - PyFile_FromString - PyFile_GetLine - PyFile_Name - PyFile_SetBufSize - PyFile_SoftSpace - PyFile_WriteObject - PyFile_WriteString - PyFloat_AsDouble - PyFloat_AsString - PyFloat_Fini - PyFloat_FromDouble - PyFrame_BlockPop - PyFrame_BlockSetup - PyFrame_FastToLocals - PyFrame_Fini - PyFrame_LocalsToFast - PyFrame_New - PyFunction_GetCode - PyFunction_GetDefaults - PyFunction_GetGlobals - PyFunction_New - PyFunction_SetDefaults - PyGrammar_AddAccelerators - PyGrammar_FindDFA - PyGrammar_LabelRepr - PyGrammar_RemoveAccelerators - PyImport_AddModule - PyImport_AppendInittab - PyImport_Cleanup - PyImport_ExecCodeModule - PyImport_ExecCodeModuleEx - PyImport_ExtendInittab - PyImport_GetMagicNumber - PyImport_GetModuleDict - PyImport_Import - PyImport_ImportFrozenModule - PyImport_ImportModule - PyImport_ImportModuleEx - PyImport_ReloadModule - PyInstance_DoBinOp - PyInstance_New - PyInt_AsLong - PyInt_Fini - PyInt_FromLong - PyInt_GetMax - PyInterpreterState_Clear - PyInterpreterState_Delete - PyInterpreterState_New - PyList_Append - PyList_AsTuple - PyList_GetItem - PyList_GetSlice - PyList_Insert - PyList_New - PyList_Reverse - PyList_SetItem - PyList_SetSlice - PyList_Size - PyList_Sort - PyLong_AsDouble - PyLong_AsLong -; PyLong_AsLongLong - PyLong_AsUnsignedLong -; PyLong_AsUnsignedLongLong - PyLong_AsVoidPtr - PyLong_FromDouble - PyLong_FromLong -; PyLong_FromLongLong - PyLong_FromString - PyLong_FromUnsignedLong -; PyLong_FromUnsignedLongLong - PyLong_FromVoidPtr - PyMapping_Check - PyMapping_GetItemString - PyMapping_HasKey - PyMapping_HasKeyString - PyMapping_Length - PyMapping_SetItemString - PyMarshal_Init - PyMarshal_ReadLongFromFile - PyMarshal_ReadObjectFromFile - PyMarshal_ReadObjectFromString - PyMarshal_WriteLongToFile - PyMarshal_WriteObjectToFile - PyMarshal_WriteObjectToString - PyMem_Free - PyMem_Malloc - PyMem_Realloc - PyMember_Get - PyMember_Set - PyMethod_Class - PyMethod_Fini - PyMethod_Function - PyMethod_New - PyMethod_Self - PyModule_GetDict - PyModule_GetName - PyModule_New - PyNode_AddChild - PyNode_Compile - PyNode_Free -; PyNode_ListTree - PyNode_New - PyNumber_Absolute - PyNumber_Add - PyNumber_And - PyNumber_Check - PyNumber_Coerce - PyNumber_CoerceEx - PyNumber_Divide - PyNumber_Divmod - PyNumber_Float - PyNumber_Int - PyNumber_Invert - PyNumber_Long - PyNumber_Lshift - PyNumber_Multiply - PyNumber_Negative - PyNumber_Or - PyNumber_Positive - PyNumber_Power - PyNumber_Remainder - PyNumber_Rshift - PyNumber_Subtract - PyNumber_Xor - PyOS_AfterFork - PyOS_FiniInterrupts - PyOS_GetLastModificationTime - PyOS_InitInterrupts - PyOS_InterruptOccurred - PyOS_Readline - PyOS_StdioReadline - PyOS_strtol - PyOS_strtoul - PyObject_CallFunction - PyObject_CallMethod - PyObject_CallObject - PyObject_Cmp - PyObject_Compare - PyObject_DelItem - PyObject_GetAttr - PyObject_GetAttrString - PyObject_GetItem - PyObject_HasAttr - PyObject_HasAttrString - PyObject_Hash - PyObject_IsTrue - PyObject_Length - PyObject_Not - PyObject_Print - PyObject_Repr - PyObject_SetAttr - PyObject_SetAttrString - PyObject_SetItem - PyObject_Str - PyObject_Type - PyParser_AddToken - PyParser_Delete - PyParser_New - PyParser_ParseFile - PyParser_ParseString - PyParser_SimpleParseFile - PyParser_SimpleParseString - PyRange_New - PyRun_AnyFile - PyRun_File - PyRun_InteractiveLoop - PyRun_InteractiveOne - PyRun_SimpleFile - PyRun_SimpleString - PyRun_String - PySequence_Check - PySequence_Concat - PySequence_Contains - PySequence_Count - PySequence_DelItem - PySequence_DelSlice - PySequence_GetItem - PySequence_GetSlice - PySequence_In - PySequence_Index - PySequence_Length - PySequence_List - PySequence_Repeat - PySequence_SetItem - PySequence_SetSlice - PySequence_Tuple - PySlice_GetIndices - PySlice_New - PyString_AsString - PyString_Concat - PyString_ConcatAndDel - PyString_Fini - PyString_Format - PyString_FromString - PyString_FromStringAndSize - PyString_InternFromString - PyString_InternInPlace - PyString_Size - PySys_GetFile - PySys_GetObject - PySys_SetArgv - PySys_SetObject - PySys_SetPath - PySys_WriteStderr - PySys_WriteStdout - PyThreadState_Clear - PyThreadState_Delete - PyThreadState_Get - PyThreadState_GetDict - PyThreadState_New - PyThreadState_Swap - PyThread__exit_thread - PyThread_acquire_lock - PyThread_allocate_lock - PyThread_allocate_sema - PyThread_down_sema - PyThread_exit_thread - PyThread_free_lock - PyThread_free_sema - PyThread_get_thread_ident - PyThread_init_thread - PyThread_release_lock - PyThread_start_new_thread - PyThread_up_sema - PyToken_OneChar - PyToken_TwoChars - PyTokenizer_Free - PyTokenizer_FromFile - PyTokenizer_FromString - PyTokenizer_Get - PyTraceBack_Here - PyTraceBack_Print - PyTuple_Fini - PyTuple_GetItem - PyTuple_GetSlice - PyTuple_New - PyTuple_SetItem - PyTuple_Size - Py_AddPendingCall - Py_AtExit - Py_BuildValue - Py_CompileString - Py_EndInterpreter - Py_Exit - Py_FatalError - Py_FdIsInteractive - Py_Finalize - Py_FindMethod - Py_FindMethodInChain - Py_FlushLine - Py_Free - Py_GetArgcArgv - Py_GetBuildInfo - Py_GetCompiler - Py_GetCopyright - Py_GetExecPrefix - Py_GetPath - Py_GetPlatform - Py_GetPrefix - Py_GetProgramFullPath - Py_GetProgramName - Py_GetPythonHome - Py_GetVersion - Py_InitModule4 - Py_Initialize - Py_IsInitialized - Py_Main - Py_MakePendingCalls - Py_Malloc - Py_NewInterpreter - Py_Realloc - Py_ReprEnter - Py_ReprLeave - Py_SetProgramName - Py_SetPythonHome - Py_VaBuildValue - _PyBuiltin_Fini_1 - _PyBuiltin_Fini_2 - _PyBuiltin_Init_1 - _PyBuiltin_Init_2 - _PyImport_FindExtension - _PyImport_Fini - _PyImport_FixupExtension - _PyImport_Init - _PyImport_LoadDynamicModule - _PyLong_New - _PyModule_Clear - _PyObject_New - _PyObject_NewVar - _PyString_Resize - _PySys_Init - _PyTuple_Resize - _Py_MD5Final - _Py_MD5Init - _Py_MD5Update -; _Py_addbit - _Py_c_diff - _Py_c_neg - _Py_c_pow - _Py_c_prod - _Py_c_quot - _Py_c_sum -; _Py_delbitset -; _Py_mergebitset -; _Py_meta_grammar -; _Py_newbitset - _Py_re_compile_fastmap - _Py_re_compile_initialize - _Py_re_compile_pattern - _Py_re_match - _Py_re_search - _Py_re_set_syntax -; _Py_samebitset - PyBuffer_Type - PyBuffer_FromObject - PyBuffer_FromMemory - PyBuffer_FromReadWriteMemory - PyBuffer_New - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/readme.txt b/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/readme.txt deleted file mode 100644 index 6fa178eb..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/os2vacpp/readme.txt +++ /dev/null @@ -1,119 +0,0 @@ -IBM VisualAge C/C++ for OS/2 -============================ - -To build Python for OS/2, change into ./os2vacpp and issue an 'NMAKE' -command. This will build a PYTHON15.DLL containing the set of Python -modules listed in config.c and a small PYTHON.EXE to start the -interpreter. - -By changing the C compiler flag /Gd- in the makefile to /Gd+, you can -reduce the size of these by causing Python to dynamically link to the -C runtime DLLs instead of including their bulk in your binaries. -However, this means that any system on which you run Python must have -the VAC++ compiler installed in order to have those DLLs available. - -During the build process you may see a couple of harmless warnings: - - From the C Compiler, "No function prototype given for XXX", which - comes from the use of K&R parameters within Python for portability. - - From the ILIB librarian, "Module Not Found (XXX)", which comes - from its attempt to perform the (-+) operation, which removes and - then adds a .OBJ to the library. The first time a build is done, - it obviously cannot remove what is not yet built. - -This build includes support for most Python functionality as well as -TCP/IP sockets. It omits the Posix ability to 'fork' a process but -supports threads using OS/2 native capabilities. I have tried to -support everything possible but here are a few usage notes. - - --- os.popen() Usage Warnings - -With respect to my implementation of popen() under OS/2: - - import os - - fd = os.popen("pkzip.exe -@ junk.zip", 'wb') - fd.write("file1.txt\n") - fd.write("file2.txt\n") - fd.write("file3.txt\n") - fd.write("\x1a") # Should Not Be Necessary But Is - fd.close() - -There is a bug, either in the VAC++ compiler or OS/2 itself, where the -simple closure of the write-side of a pipe -to- a process does not -send an EOF to that process. I find I must explicitly write a -control-Z (EOF) before closing the pipe. This is not a problem when -using popen() in read mode. - -One other slight difference with my popen() is that I return None -from the close(), instead of the Unix convention of the return code -of the spawned program. I could find no easy way to do this under -OS/2. - - --- BEGINLIBPATH/ENDLIBPATH - -With respect to environment variables, this OS/2 port supports the -special-to-OS/2 magic names of 'BEGINLIBPATH' and 'ENDLIBPATH' to -control where to load conventional DLLs from. Those names are -intercepted and converted to calls on the OS/2 kernel APIs and -are inherited by child processes, whether Python-based or not. - -A few new attributes have been added to the os module: - - os.meminstalled # Count of Bytes of RAM Installed on Machine - os.memkernel # Count of Bytes of RAM Reserved (Non-Swappable) - os.memvirtual # Count of Bytes of Virtual RAM Possible - os.timeslice # Duration of Scheduler Timeslice, in Milliseconds - os.maxpathlen # Maximum Length of a Path Specification, in chars - os.maxnamelen # Maximum Length of a Single Dir/File Name, in chars - os.version # Version of OS/2 Being Run e.g. "4.00" - os.revision # Revision of OS/2 Being Run (usually zero) - os.bootdrive # Drive that System Booted From e.g. "C:" - # (useful to find the CONFIG.SYS used to boot with) - - --- Using Python as the Default OS/2 Batch Language - -Note that OS/2 supports the Unix technique of putting the special -comment line at the time of scripts e.g. "#!/usr/bin/python" in -a different syntactic form. To do this, put your script into a file -with a .CMD extension and added 'extproc' to the top as follows: - - extproc C:\Python\Python.exe -x - import os - print "Hello from Python" - -The '-x' option tells Python to skip the first line of the file -while processing the rest as normal Python source. - - --- Suggested Environment Variable Setup - -With respect to the environment variables for Python, I use the -following setup: - - Set PYTHONHOME=E:\Tau\Projects\Python;D:\DLLs - Set PYTHONPATH=.;E:\Tau\Projects\Python\Lib; \ - E:\Tau\Projects\Python\Lib\plat-win - -The EXEC_PREFIX (optional second pathspec on PYTHONHOME) is where -you put any Python extension DLLs you may create/obtain. There -are none provided with this release. - - --- Contact Info - -Jeff Rush is no longer supporting the VACPP port :-( - -I don't have the VACPP compiler, so can't reliably maintain this port. - -Anyone with VACPP who can contribute patches to keep this port buildable -should upload them to the Python Patch Manager at Sourceforge and -assign them to me for review/checkin. - -Andrew MacIntyre -aimacintyre at users.sourceforge.net -August 18, 2002. diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/py.ico b/SDKs/XPlatform/Cypython-2.3.3/PC/py.ico deleted file mode 100644 index f714eea446e4b6bd28f9e0f1c8f75f6c81fba9c6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 766 zcmaJm8xh$y8nAma-W z^$0#H>2kty>X)hwIrlE-S<5+vz&A`n&h*v18|y+>sjix$aZle8p4@4^r5n6eZnc>@ zG>`3+P&u~b2-=|v7s{bGs2nePG0P+8gx8LOTO>dQCQJqF(DmA(7NnHmI`9r7=bX7` z!W?&ubNbFr2j~zfBlk1694)bC>aTGXW{#1EPUo#Q3jUW;)Gsjwb=$3Xc0uvBe*c&M z&1daA>)3`jT()1f=0DJg9L%!}boam$VF^QEz=~*YKd>1d7=z`x4td24G7-ucUwk-LUlMo|)S>aP%-HcSLQWP)fJ3>Qx5~j;^zT?g4lvGQtrUup;u!2e!jgxH*Q;-1_^>`fF$XC9#49 b{Z1!vP?klQ!5>}z&#rx-Gx`)Kw9yD5f& diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/pycon.ico b/SDKs/XPlatform/Cypython-2.3.3/PC/pycon.ico deleted file mode 100644 index a54682d91c85164fe9c910f5831935bd7fd6983c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 766 zcmah{t!~3G7`)7rqGq5)qYE62WM;HS*&~dF6j&+f*hV`PDa@#R11{P?rM^Pp9-*L8 zc3*y6cbe8q&Y$nQvtuOz5?*;egW&rLxMjU3bMk>qaLp00^!|pWNypm0aO9M<@ZQsC zyBlpQGm@9IWVnR1jPL{;o+B)&U%1VHgJ@<(Ogp_2nK`YCUQga!4d_PeUSrirgMmR$ zUKJav88uc=PIl=1%$NdAt<0bu!9ehxF~%`4uGd-{Q)f;M`9do;T+s9-5wz+Wx(?^* z8%kq1AD}>mpl{ai>mt_v!~d&)<+)VFdGLhnb^A+=u{{G&?vCxQ-5%NgoR`4z 64 -# error "PY_MICRO_VERSION > 64" -#endif -#if PY_RELEASE_LEVEL > 99 -# error "PY_RELEASE_LEVEL > 99" -#endif -#if PY_RELEASE_SERIAL > 9 -# error "PY_RELEASE_SERIAL > 9" -#endif -#define PYVERSION64 PY_MAJOR_VERSION, PY_MINOR_VERSION, FIELD3, PYTHON_API_VERSION - -// String Tables -STRINGTABLE DISCARDABLE -BEGIN - 1000, MS_DLL_ID -END - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION PYVERSION64 - PRODUCTVERSION PYVERSION64 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", "PythonLabs at Zope Corporation\0" - VALUE "FileDescription", "Python Core\0" - VALUE "FileVersion", PYTHON_VERSION - VALUE "InternalName", "Python DLL\0" - VALUE "LegalCopyright", "Copyright © 2001-2003 Python Software Foundation. Copyright © 2000 BeOpen.com. Copyright © 1995-2001 CNRI. Copyright © 1991-1995 SMC.\0" - VALUE "OriginalFilename", PYTHON_DLL_NAME "\0" - VALUE "ProductName", "Python\0" - VALUE "ProductVersion", PYTHON_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/pythonnt_rc.h b/SDKs/XPlatform/Cypython-2.3.3/PC/pythonnt_rc.h deleted file mode 100644 index 57b4d393..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/pythonnt_rc.h +++ /dev/null @@ -1,4 +0,0 @@ -/* This file created by make_versioninfo.exe */ -#define FIELD3 3150 -#define MS_DLL_ID "2.3" -#define PYTHON_DLL_NAME "python23.dll" diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/pythonnt_rc_d.h b/SDKs/XPlatform/Cypython-2.3.3/PC/pythonnt_rc_d.h deleted file mode 100644 index 57b4d393..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/pythonnt_rc_d.h +++ /dev/null @@ -1,4 +0,0 @@ -/* This file created by make_versioninfo.exe */ -#define FIELD3 3150 -#define MS_DLL_ID "2.3" -#define PYTHON_DLL_NAME "python23.dll" diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/readme.txt b/SDKs/XPlatform/Cypython-2.3.3/PC/readme.txt deleted file mode 100644 index 08266990..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/readme.txt +++ /dev/null @@ -1,95 +0,0 @@ -Welcome to the "PC" subdirectory of the Python distribution -*********************************************************** - -*** Note: the project files for MS VC++ 6.0 are now in the -*** PCbuild directory. See the file readme.txt there for build -*** instructions. There is some information below that might -*** still be relevant. - -This "PC" subdirectory contains complete project files to make -several older PC ports of Python, as well as all the PC-specific -Python source files. It should be located in the root of the -Python distribution, and there should be directories "Modules", -"Objects", "Python", etc. in the parent directory of this "PC" -subdirectory. Be sure to read the documentation in the Python -distribution. - -Python requires library files such as string.py to be available in -one or more library directories. The search path of libraries is -set up when Python starts. To see the current Python library search -path, start Python and enter "import sys" and "print sys.path". - -All PC ports use this scheme to try to set up a module search path: - - 1) The script location; the current directory without script. - 2) The PYTHONPATH variable, if set. - 3) For Win32 platforms (NT/95), paths specified in the Registry. - 4) Default directories lib, lib/win, lib/test, lib/tkinter; - these are searched relative to the environment variable - PYTHONHOME, if set, or relative to the executable and its - ancestors, if a landmark file (Lib/string.py) is found , - or the current directory (not useful). - 5) The directory containing the executable. - -The best installation strategy is to put the Python executable (and -DLL, for Win32 platforms) in some convenient directory such as -C:/python, and copy all library files and subdirectories (using XCOPY) -to C:/python/lib. Then you don't need to set PYTHONPATH. Otherwise, -set the environment variable PYTHONPATH to your Python search path. -For example, - set PYTHONPATH=.;d:\python\lib;d:\python\lib\win;d:\python\lib\dos-8x3 - -There are several add-in modules to build Python programs which use -the native Windows operating environment. The ports here just make -"QuickWin" and DOS Python versions which support a character-mode -(console) environment. Look in www.python.org for Tkinter, PythonWin, -WPY and wxPython. - -To make a Python port, start the Integrated Development Environment -(IDE) of your compiler, and read in the native "project file" -(or makefile) provided. This will enable you to change any source -files or build settings so you can make custom builds. - -pyconfig.h An important configuration file specific to PC's. - -config.c The list of C modules to include in the Python PC - version. Manually edit this file to add or - remove Python modules. - -testpy.py A Python test program. Run this to test your - Python port. It should produce copious output, - ending in a report on how many tests were OK, how many - failed, and how many were skipped. Don't worry about - skipped tests (these test unavailable optional features). - - -Additional files and subdirectories for 32-bit Windows -====================================================== - -python_nt.rc Resource compiler input for python15.dll. - -dl_nt.c, import_nt.c - Additional sources used for 32-bit Windows features. - -getpathp.c Default sys.path calculations (for all PC platforms). - -dllbase_nt.txt A (manually maintained) list of base addresses for - various DLLs, to avoid run-time relocation. - -example_nt A subdirectory showing how to build an extension as a - DLL. - - -IBM VisualAge C/C++ for OS/2 -============================ - -See os2vacpp/readme.txt. This platform is supported by Jeff Rush. - - -Note for Windows 3.x and DOS users -================================== - -Neither Windows 3.x nor DOS is supported any more. The last Python -version that supported these was Python 1.5.2; the support files were -present in Python 2.0 but weren't updated, and it is not our intention -to support these platforms for Python 2.x. diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/testpy.py b/SDKs/XPlatform/Cypython-2.3.3/PC/testpy.py deleted file mode 100644 index ef8ba7ae..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/testpy.py +++ /dev/null @@ -1,32 +0,0 @@ -import sys - -# This is a test module for Python. It looks in the standard -# places for various *.py files. If these are moved, you must -# change this module too. - -try: - import string -except: - print """Could not import the standard "string" module. -Please check your PYTHONPATH environment variable.""" - sys.exit(1) - -try: - import regex_syntax -except: - print """Could not import the standard "regex_syntax" module. If this is -a PC, you should add the dos_8x3 directory to your PYTHONPATH.""" - sys.exit(1) - -import os - -for dir in sys.path: - file = os.path.join(dir, "string.py") - if os.path.isfile(file): - test = os.path.join(dir, "test") - if os.path.isdir(test): - # Add the "test" directory to PYTHONPATH. - sys.path = sys.path + [test] - -import regrtest # Standard Python tester. -regrtest.main() diff --git a/SDKs/XPlatform/Cypython-2.3.3/PC/w9xpopen.c b/SDKs/XPlatform/Cypython-2.3.3/PC/w9xpopen.c deleted file mode 100644 index 8f074c55..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PC/w9xpopen.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * w9xpopen.c - * - * Serves as an intermediate stub Win32 console application to - * avoid a hanging pipe when redirecting 16-bit console based - * programs (including MS-DOS console based programs and batch - * files) on Window 95 and Windows 98. - * - * This program is to be launched with redirected standard - * handles. It will launch the command line specified 16-bit - * console based application in the same console, forwarding - * it's own redirected standard handles to the 16-bit child. - - * AKA solution to the problem described in KB: Q150956. - */ - -#define WIN32_LEAN_AND_MEAN -#include -#include -#include /* for malloc and its friends */ - -const char *usage = -"This program is used by Python's os.popen function\n" -"to work around a limitation in Windows 95/98. It is\n" -"not designed to be used as a stand-alone program."; - -int main(int argc, char *argv[]) -{ - BOOL bRet; - STARTUPINFO si; - PROCESS_INFORMATION pi; - DWORD exit_code=0; - int cmdlen = 0; - int i; - char *cmdline, *cmdlinefill; - - if (argc < 2) { - if (GetFileType(GetStdHandle(STD_INPUT_HANDLE))==FILE_TYPE_CHAR) - /* Attached to a console, and therefore not executed by Python - Display a message box for the inquisitive user - */ - MessageBox(NULL, usage, argv[0], MB_OK); - else { - /* Eeek - executed by Python, but args are screwed! - Write an error message to stdout so there is at - least some clue for the end user when it appears - in their output. - A message box would be hidden and blocks the app. - */ - fprintf(stdout, "Internal popen error - no args specified\n%s\n", usage); - } - return 1; - } - /* Build up the command-line from the args. - Args with a space are quoted, existing quotes are escaped. - To keep things simple calculating the buffer size, we assume - every character is a quote - ie, we allocate double what we need - in the worst case. As this is only double the command line passed - to us, there is a good chance this is reasonably small, so the total - allocation will almost always be < 512 bytes. - */ - for (i=1;i - * - * Copyright (c) 1999 Toby Dickenson - * - * Permission to use this software in any way is granted without - * fee, provided that the copyright notice above appears in all - * copies. This software is provided "as is" without any warranty. - */ - -/* Modified by Guido van Rossum */ -/* Beep added by Mark Hammond */ -/* Win9X Beep and platform identification added by Uncle Timmy */ - -/* Example: - - import winsound - import time - - # Play wav file - winsound.PlaySound('c:/windows/media/Chord.wav', winsound.SND_FILENAME) - - # Play sound from control panel settings - winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS) - - # Play wav file from memory - data=open('c:/windows/media/Chimes.wav',"rb").read() - winsound.PlaySound(data, winsound.SND_MEMORY) - - # Start playing the first bit of wav file asynchronously - winsound.PlaySound('c:/windows/media/Chord.wav', - winsound.SND_FILENAME|winsound.SND_ASYNC) - # But dont let it go for too long... - time.sleep(0.1) - # ...Before stopping it - winsound.PlaySound(None, 0) -*/ - -#include -#include -#include /* port functions on Win9x */ -#include - -PyDoc_STRVAR(sound_playsound_doc, -"PlaySound(sound, flags) - a wrapper around the Windows PlaySound API\n" -"\n" -"The sound argument can be a filename, data, or None.\n" -"For flag values, ored together, see module documentation."); - -PyDoc_STRVAR(sound_beep_doc, -"Beep(frequency, duration) - a wrapper around the Windows Beep API\n" -"\n" -"The frequency argument specifies frequency, in hertz, of the sound.\n" -"This parameter must be in the range 37 through 32,767.\n" -"The duration argument specifies the number of milliseconds.\n" -"On WinNT and 2000, the platform Beep API is used directly. Else funky\n" -"code doing direct port manipulation is used; it's unknown whether that\n" -"will work on all systems."); - -PyDoc_STRVAR(sound_msgbeep_doc, -"MessageBeep(x) - call Windows MessageBeep(x). x defaults to MB_OK."); - -PyDoc_STRVAR(sound_module_doc, -"PlaySound(sound, flags) - play a sound\n" -"SND_FILENAME - sound is a wav file name\n" -"SND_ALIAS - sound is a registry sound association name\n" -"SND_LOOP - Play the sound repeatedly; must also specify SND_ASYNC\n" -"SND_MEMORY - sound is a memory image of a wav file\n" -"SND_PURGE - stop all instances of the specified sound\n" -"SND_ASYNC - PlaySound returns immediately\n" -"SND_NODEFAULT - Do not play a default beep if the sound can not be found\n" -"SND_NOSTOP - Do not interrupt any sounds currently playing\n" // Raising RuntimeError if needed -"SND_NOWAIT - Return immediately if the sound driver is busy\n" // Without any errors -"\n" -"Beep(frequency, duration) - Make a beep through the PC speaker."); - -static PyObject * -sound_playsound(PyObject *s, PyObject *args) -{ - const char *sound; - int flags; - int length; - int ok; - - if(!PyArg_ParseTuple(args,"z#i:PlaySound",&sound,&length,&flags)) { - return NULL; - } - - if(flags&SND_ASYNC && flags &SND_MEMORY) { - /* Sidestep reference counting headache; unfortunately this also - prevent SND_LOOP from memory. */ - PyErr_SetString(PyExc_RuntimeError,"Cannot play asynchronously from memory"); - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - ok = PlaySound(sound,NULL,flags); - Py_END_ALLOW_THREADS - if(!ok) - { - PyErr_SetString(PyExc_RuntimeError,"Failed to play sound"); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -enum OSType {Win9X, WinNT2000}; -static enum OSType whichOS; /* set by module init */ - -static PyObject * -sound_beep(PyObject *self, PyObject *args) -{ - int freq; - int dur; - - if (!PyArg_ParseTuple(args, "ii:Beep", &freq, &dur)) - return NULL; - - if (freq < 37 || freq > 32767) { - PyErr_SetString(PyExc_ValueError, - "frequency must be in 37 thru 32767"); - return NULL; - } - - /* On NT and 2000, the SDK Beep() function does the whole job. - * But while Beep() exists before NT, it ignores its arguments and - * plays the system default sound. Sheesh ... - * The Win9X code is mondo bizarre. I (Tim) pieced it together from - * crap all over the web. The original IBM PC used some particular - * pieces of hardware (Intel 8255 and 8254 chips) hardwired to - * particular port addresses and running at particular clock speeds, - * and the poor sound card folks have been forced to emulate that in - * all particulars ever since. But NT and 2000 don't support port - * manipulation. Don't know about WinME; guessing it's like 98. - */ - - if (whichOS == WinNT2000) { - BOOL ok; - Py_BEGIN_ALLOW_THREADS - ok = Beep(freq, dur); - Py_END_ALLOW_THREADS - if (!ok) { - PyErr_SetString(PyExc_RuntimeError,"Failed to beep"); - return NULL; - } - } - else if (whichOS == Win9X) { - int speaker_state; - /* Force timer into oscillator mode via timer control port. */ - _outp(0x43, 0xb6); - /* Compute ratio of ancient hardcoded timer frequency to - * frequency we want. Then feed that ratio (lowest byte - * first) into timer data port. - */ - freq = 1193180 / freq; - _outp(0x42, freq & 0xff); - _outp(0x42, (freq >> 8) & 0xff); - /* Get speaker control state. */ - speaker_state = _inp(0x61); - /* Turn the speaker on (bit 1) - * and drive speaker from timer (bit 0). - */ - _outp(0x61, speaker_state | 0x3); - /* Let it blast in peace for the duration. */ - Py_BEGIN_ALLOW_THREADS - Sleep(dur); - Py_END_ALLOW_THREADS - /* Restore speaker control to original state. */ - _outp(0x61, speaker_state); - } - else { - assert(!"winsound's whichOS has insane value"); - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -sound_msgbeep(PyObject *self, PyObject *args) -{ - int x = MB_OK; - if (!PyArg_ParseTuple(args, "|i:MessageBeep", &x)) - return NULL; - MessageBeep(x); - Py_INCREF(Py_None); - return Py_None; -} - -static struct PyMethodDef sound_methods[] = -{ - {"PlaySound", sound_playsound, METH_VARARGS, sound_playsound_doc}, - {"Beep", sound_beep, METH_VARARGS, sound_beep_doc}, - {"MessageBeep", sound_msgbeep, METH_VARARGS, sound_msgbeep_doc}, - {NULL, NULL} -}; - -static void -add_define(PyObject *dict, const char *key, long value) -{ - PyObject *k=PyString_FromString(key); - PyObject *v=PyLong_FromLong(value); - if(v&&k) - { - PyDict_SetItem(dict,k,v); - } - Py_XDECREF(k); - Py_XDECREF(v); -} - -#define ADD_DEFINE(tok) add_define(dict,#tok,tok) - -PyMODINIT_FUNC -initwinsound(void) -{ - OSVERSIONINFO version; - - PyObject *module = Py_InitModule3("winsound", - sound_methods, - sound_module_doc); - PyObject *dict = PyModule_GetDict(module); - - ADD_DEFINE(SND_ASYNC); - ADD_DEFINE(SND_NODEFAULT); - ADD_DEFINE(SND_NOSTOP); - ADD_DEFINE(SND_NOWAIT); - ADD_DEFINE(SND_ALIAS); - ADD_DEFINE(SND_FILENAME); - ADD_DEFINE(SND_MEMORY); - ADD_DEFINE(SND_PURGE); - ADD_DEFINE(SND_LOOP); - ADD_DEFINE(SND_APPLICATION); - - ADD_DEFINE(MB_OK); - ADD_DEFINE(MB_ICONASTERISK); - ADD_DEFINE(MB_ICONEXCLAMATION); - ADD_DEFINE(MB_ICONHAND); - ADD_DEFINE(MB_ICONQUESTION); - - version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&version); - whichOS = Win9X; - if (version.dwPlatformId != VER_PLATFORM_WIN32s && - version.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) - whichOS = WinNT2000; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/.cvsignore b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/.cvsignore deleted file mode 100644 index b7dd0a14..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/.cvsignore +++ /dev/null @@ -1,14 +0,0 @@ -*.WSM -*.bsc -*.dbg -*.dll -*.exe -*.exp -*.ilk -*.lib -*.ncb -*.opt -*.pdb -*.plg -*.pyd -*-temp-* diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/BUILDno.txt b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/BUILDno.txt deleted file mode 100644 index 09df129e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/BUILDno.txt +++ /dev/null @@ -1,137 +0,0 @@ -Python has a "build number" scheme on Unix-like systems that's hard to -explain: - -Python 2.0b1 (#4, Sep 7 2000, 02:40:55) [MSC 32 bit (Intel)] on win32 - ^^ -The build number there is "#4". - -Each developer's unique build tree generates its own "build numbers", -starting at 0, and increasing by 1 each time a build is done in that tree. -These numbers are never checked in, or coordinated in any other way. It's -just handy for a developer to distinguish among their own personal builds. - -The makefile tricks used to accomplish this under Unix-like systems don't -work under MSDev. Here we fake it by hand, but much less frequently, and -do check it in. The build number only changes often enough to distinguish -releases from each other, and from the long "in between" stretches of CVS -development. An account of all Windows BUILD numbers follows; when you -check in a new one, please add an entry to the top of the list. - -How to change the Windows build number: - -+ Right-click on getbuildinfo.c from within MSDev. Select Settings ... -+ Select the General category of the C/C++ tab. -+ In "Settings For:" select "Multiple Configurations ...". -+ Check the "Win32 Release" and "Win32 Debug" boxes and click OK. -+ In the Preprocessor Definitions box, increment the number after BUILD=. -+ Click OK. -+ This is not enough to convince MSDev to recompile getbuildinfo.c, - so force that and relink. -+ Verify that the new build number shows up in both release and debug - builds. - - -Windows Python BUILD numbers ----------------------------- - 51 2.3.3 - 19-Dec-2003 - 50 2.3.3c1 - 5-Dec-2003 - 49 2.3.2 (final) - 3-Oct-2003 - 48 2.3.2c1 - 30-Sep-2003 - 47 2.3.1 (final) - 23-Sep-2003 - 46 2.3 (final) - 29-Jul-2003 - 45 2.3c2 - 24-Jul-2003 - 44 2.3c1 - 18-Jul-2003 - 43 2.3b2 - 29-Jun-2003 - 42 2.2.3 (final) - 30-May-2003 - 41 2.2.3c1 - 22-May-2003 - 40 2.3b1 - 25-Apr-2003 - 39 2.3a2 - 19-Feb-2003 - 38 2.3a1 - 31-Dec-2002 - 37 2.2.2 (final) - 14-Oct-2002 - 36 2.2.2b1 - 7-Oct-2002 - 35 2.1.3 (final) - 8-Apr-2002 - 34 2.2.1 (final) - 10-Apr-2002 - 33 2.2.1c2 - 26-Mar-2002 - 32 2.2.1c1 - 18-Mar-2002 - 31 2.1.2 final - 16-Jan-2002 - 30 2.1.2c1 - 10-Jan-2002 - 29 CVS development - 21-Dec-2001 - 28 2.2 final - 21-Dec-2001 - 27 2.2c1 - 14-Dec-2001 - 26 2.2b2 - 16-Nov-2001 - 25 2.2b1 - 19-Oct-2001 - 24 2.2a4 - 28-Sep-2001 - 23 2.2a3 - 07-Sep-2001 - 22 2.2a2 - 22-Aug-2001 - 21 2.2a1 - 18-Jul-2001 - 20 2.1.1 - 20-Jul-2001 - 19 2.1.1c1 - 13-Jul-2001 - 18 2.0.1 - 22-Jun-2001 - 17 2.0.1c1 - 13-Jun-2001 - 16 CVS development - 18-Apr-2001 - 15 2.1 final - 16-Apr-2001 - 14 2.1c2 - 15-Apr-2001 - 13 2.1c1 - 12-Apr-2001 - 12 2.1b2 - 20-Mar-2001 - 11 2.1b1 - 28-Feb-2001 - 10 2.1a2 - 1-Feb-2001 - 9 2.1a1 - 17-Jan-2001 - 8 2.0 (final) - 14-Oct-2000 - 7 2.0c1 - 07-Oct-2000 - 6 2.0b2 - 26-Sep-2000 - 5 CVS development - 07-Sep-2000 - 4 2.0b1 repaired to include Lib\xml + Lib\lib-old + Lib\test\*.xml - 07-Sep-2000 - 3 2.0b1 - 05-Sep-2000 - 2 CVS development - 1 unused - 0 2.0b1p1 and 2.0b1p2 - 01-Sep-2000 for both -- this scheme hadn't started yet diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/Uninstal.wse b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/Uninstal.wse deleted file mode 100644 index 306f3bc3..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/Uninstal.wse +++ /dev/null @@ -1,514 +0,0 @@ -Document Type: WSE -item: Global - Version=8.14 - Flags=00000100 - Split=1420 - Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - Copy Default=1 - Japanese Font Name=MS Gothic - Japanese Font Size=10 - Start Gradient=0 0 255 - End Gradient=0 0 0 - Windows Flags=00000000000000000000101000001000 - Message Font=MS Sans Serif - Font Size=8 - Disk Label=GLBS - Disk Filename=INSTALL - Patch Flags=0000000000000001 - Patch Threshold=200 - Patch Memory=4096 - Per-User Version ID=1 - Crystal Format=10111100101100000010001001001001 - Step View=&Properties -end -item: Remark - Text=Note from Tim: This is a verbatim copy of Wise's Uninstal.wse, altered at the end to write -end -item: Remark - Text=uninstall info under HKCU instead of HKLM if our DOADMIN var is false. -end -item: Remark -end -item: Remark - Text= Install Support for uninstalling the application. -end -item: Remark -end -item: Set Variable - Variable=UNINSTALL_PATH - Value=%_LOGFILE_PATH_% - Flags=00000010 -end -item: Set Variable - Variable=UNINSTALL_PATH - Value=%UNINSTALL_PATH%\UNWISE.EXE -end -item: Compiler Variable If - Variable=_EXE_OS_TYPE_ - Value=WIN32 -end -item: Install File - Source=%_WISE_%\UNWISE32.EXE - Destination=%UNINSTALL_PATH% - Flags=0000000000000010 -end -item: Compiler Variable Else -end -item: Install File - Source=%_WISE_%\UNWISE.EXE - Destination=%UNINSTALL_PATH% - Flags=0000000000000010 -end -item: Compiler Variable End -end -item: Remark -end -item: Remark - Text= Install Support for multiple languages -end -item: Remark -end -item: Set Variable - Variable=UNINSTALL_LANG - Value=%UNINSTALL_PATH% - Flags=00000010 -end -item: Set Variable - Variable=UNINSTALL_LANG - Value=%UNINSTALL_LANG%\UNWISE.INI -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=C - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.FRA - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_C_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.FRA - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=D - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.FRA - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_D_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.FRA - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=E - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.DEU - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_E_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.DEU - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=F - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.PTG - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_F_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.PTG - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=G - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ESP - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_G_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ESP - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=H - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ESP - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_H_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ESP - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=I - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ITA - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_I_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ITA - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=J - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.DAN - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_J_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.DAN - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=K - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.FIN - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_K_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.FIN - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=L - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ISL - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_L_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ISL - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=M - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.NLD - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_M_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.NLD - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=N - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.NOR - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_N_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.NOR - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=O - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.SVE - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_O_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.SVE - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=P - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.JPN - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_P_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.JPN - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Remark -end -item: Remark - Text= Install the add/remove or uninstall icon -end -item: Remark -end -item: Set Variable - Variable=UNINSTALL_PATH - Value=%UNINSTALL_PATH% - Flags=00010100 -end -item: Set Variable - Variable=INST_LOG_PATH - Value=%_LOGFILE_PATH_% - Flags=00010100 -end -item: Check Configuration - Flags=10111011 -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Remark - Text=Write uninstall info under HKLM. This if/else/end block added by Tim. -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%APPTITLE% - Value Name=DisplayName - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%UNINSTALL_PATH% %INST_LOG_PATH% - New Value= - Value Name=UninstallString - Root=2 -end -item: Else Statement -end -item: Remark - Text=The same, but write under HKCU instead. -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%APPTITLE% - Value Name=DisplayName - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%UNINSTALL_PATH% %INST_LOG_PATH% - New Value= - Value Name=UninstallString - Root=1 -end -item: End Block -end -item: Else Statement -end -item: Add ProgMan Icon - Group=%GROUP% - Icon Name=Uninstall %APPTITLE% - Command Line=%UNINSTALL_PATH% %INST_LOG_PATH% -end -item: End Block -end -item: Check Configuration - Flags=11110010 -end -item: If/While Statement - Variable=DOBRAND - Value=1 -end -item: Edit Registry - Total Keys=2 - item: Key - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%COMPANY% - Value Name=RegCompany - Root=2 - end - item: Key - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%NAME% - Value Name=RegOwner - Root=2 - end -end -item: End Block -end -item: End Block -end diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_bsddb.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_bsddb.dsp deleted file mode 100644 index ea13a157..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_bsddb.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_bsddb" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_bsddb - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_bsddb.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_bsddb.mak" CFG="_bsddb - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_bsddb - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_bsddb - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_bsddb - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_bsddb" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\..\db-4.1.25\build_win32" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\db-4.1.25\build_win32\Release_static\libdb41s.lib /nologo /base:"0x1e180000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt" /out:"./_bsddb.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_bsddb - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_bsddb" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\..\db-4.1.25\build_win32" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\db-4.1.25\build_win32\Release_static\libdb41s.lib /nologo /base:"0x1e180000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrtd" /out:"./_bsddb_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_bsddb - Win32 Release" -# Name "_bsddb - Win32 Debug" -# Begin Source File - -SOURCE=..\Modules\_bsddb.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_csv.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_csv.dsp deleted file mode 100644 index f9b9c306..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_csv.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_csv" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_csv - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_csv.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_csv.mak" CFG="_csv - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_csv - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_csv - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_csv - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_csv" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "C:\Program Files\Tcl\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_csv.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_csv - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_csv" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "C:\Program Files\Tcl\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_csv_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_csv - Win32 Release" -# Name "_csv - Win32 Debug" -# Begin Source File - -SOURCE=..\Modules\_csv.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_socket.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_socket.dsp deleted file mode 100644 index cdc6932f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_socket.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_socket" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_socket - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_socket.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_socket.mak" CFG="_socket - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_socket - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_socket - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_socket - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_socket" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /base:"0x1e1D0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_socket.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_socket - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_socket" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /base:"0x1e1D0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_socket_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_socket - Win32 Release" -# Name "_socket - Win32 Debug" -# Begin Source File - -SOURCE=..\Modules\socketmodule.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_sre.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_sre.dsp deleted file mode 100644 index 381ec11a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_sre.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_sre" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_sre - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_sre.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_sre.mak" CFG="_sre - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_sre - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_sre - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_sre - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_sre" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "C:\Program Files\Tcl\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1e0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_sre.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_sre - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_sre" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "C:\Program Files\Tcl\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1e0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_sre_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_sre - Win32 Release" -# Name "_sre - Win32 Debug" -# Begin Source File - -SOURCE=..\Modules\_sre.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_sre_static.vcproj b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_sre_static.vcproj deleted file mode 100644 index 569e03f3..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_sre_static.vcproj +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_ssl.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_ssl.dsp deleted file mode 100644 index 22447ebb..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_ssl.dsp +++ /dev/null @@ -1,89 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_ssl" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) External Target" 0x0106 - -CFG=_ssl - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_ssl.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_ssl.mak" CFG="_ssl - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_ssl - Win32 Release" (based on "Win32 (x86) External Target") -!MESSAGE "_ssl - Win32 Debug" (based on "Win32 (x86) External Target") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" - -!IF "$(CFG)" == "_ssl - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Cmd_Line "NMAKE /f _ssl.mak" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "_ssl.exe" -# PROP BASE Bsc_Name "_ssl.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_ssl" -# PROP Cmd_Line "python build_ssl.py" -# PROP Rebuild_Opt "-a" -# PROP Target_File "_ssl.pyd" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ELSEIF "$(CFG)" == "_ssl - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "x86-temp-debug\_ssl" -# PROP BASE Intermediate_Dir "x86-temp-debug\_ssl" -# PROP BASE Cmd_Line "NMAKE /f _ssl.mak" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "_ssl_d.pyd" -# PROP BASE Bsc_Name "_ssl_d.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_ssl" -# PROP Cmd_Line "python_d -u build_ssl.py -d" -# PROP Rebuild_Opt "-a" -# PROP Target_File "_ssl_d.pyd" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ENDIF - -# Begin Target - -# Name "_ssl - Win32 Release" -# Name "_ssl - Win32 Debug" - -!IF "$(CFG)" == "_ssl - Win32 Release" - -!ELSEIF "$(CFG)" == "_ssl - Win32 Debug" - -!ENDIF - -# Begin Source File - -SOURCE=..\Modules\_ssl.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_ssl.mak b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_ssl.mak deleted file mode 100644 index 62f1cf10..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_ssl.mak +++ /dev/null @@ -1,21 +0,0 @@ - -!IFDEF DEBUG -MODULE=_ssl_d.pyd -TEMP_DIR=x86-temp-debug/_ssl -CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG -SSL_LIB_DIR=$(SSL_DIR)/out32.dbg -!ELSE -MODULE=_ssl.pyd -TEMP_DIR=x86-temp-release/_ssl -CFLAGS=/Ox /MD /LD -SSL_LIB_DIR=$(SSL_DIR)/out32 -!ENDIF - -INCLUDES=-I ../Include -I ../PC -I $(SSL_DIR)/inc32 -LIBS=gdi32.lib wsock32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib - -SOURCE=../Modules/_ssl.c $(SSL_LIB_DIR)/libeay32.lib $(SSL_LIB_DIR)/ssleay32.lib - -$(MODULE): $(SOURCE) ../PC/*.h ../Include/*.h - @if not exist "$(TEMP_DIR)/." mkdir "$(TEMP_DIR)" - cl /nologo $(SOURCE) $(CFLAGS) /Fo$(TEMP_DIR)\$*.obj $(INCLUDES) /link /out:$(MODULE) $(LIBS) diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_symtable.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_symtable.dsp deleted file mode 100644 index 949192e2..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_symtable.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_symtable" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_symtable - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_symtable.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_symtable.mak" CFG="_symtable - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_symtable - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_symtable - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_symtable - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_symtable" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\Include" /I "..\PC" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "NDEBUG" -# ADD RSC /l 0xc09 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e100000" /dll /machine:I386 /out:"./_symtable.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_symtable - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_symtable" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "_DEBUG" -# ADD RSC /l 0xc09 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e100000" /dll /debug /machine:I386 /out:"./_symtable_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_symtable - Win32 Release" -# Name "_symtable - Win32 Debug" -# Begin Source File - -SOURCE=..\Modules\symtablemodule.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_testcapi.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_testcapi.dsp deleted file mode 100644 index 2b0e2e85..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_testcapi.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_testcapi" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_testcapi - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_testcapi.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_testcapi.mak" CFG="_testcapi - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_testcapi - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_testcapi - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_testcapi - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_testcapi" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\Include" /I "..\PC" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "NDEBUG" -# ADD RSC /l 0xc09 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1F0000" /dll /machine:I386 /out:"./_testcapi.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_testcapi - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_testcapi" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "_DEBUG" -# ADD RSC /l 0xc09 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1F0000" /dll /debug /machine:I386 /out:"./_testcapi_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_testcapi - Win32 Release" -# Name "_testcapi - Win32 Debug" -# Begin Source File - -SOURCE=..\Modules\_testcapimodule.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_tkinter.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_tkinter.dsp deleted file mode 100644 index dd39ea22..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/_tkinter.dsp +++ /dev/null @@ -1,103 +0,0 @@ -# Microsoft Developer Studio Project File - Name="_tkinter" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=_tkinter - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "_tkinter.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "_tkinter.mak" CFG="_tkinter - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "_tkinter - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "_tkinter - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "_tkinter - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\_tkinter" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\tcl84\include" /I "..\Include" /I "..\PC" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ..\..\tcl84\lib\tk84.lib ..\..\tcl84\lib\tcl84.lib odbc32.lib odbccp32.lib user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1e190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_tkinter_d.pyd" /pdbtype:sept /libpath:"C:\Program Files\Tcl\lib" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "_tkinter - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\_tkinter" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\tcl84\include" /I "..\Include" /I "..\PC" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 ..\..\tcl84\lib\tk84.lib ..\..\tcl84\lib\tcl84.lib odbc32.lib odbccp32.lib user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1e190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_tkinter.pyd" /libpath:"C:\Program Files\Tcl\lib" -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "_tkinter - Win32 Debug" -# Name "_tkinter - Win32 Release" -# Begin Source File - -SOURCE=..\Modules\_tkinter.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\tkappinit.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/build_ssl.py b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/build_ssl.py deleted file mode 100644 index ff7b70c3..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/build_ssl.py +++ /dev/null @@ -1,163 +0,0 @@ -# Script for building the _ssl module for Windows. -# Uses Perl to setup the OpenSSL environment correctly -# and build OpenSSL, then invokes a simple nmake session -# for _ssl.pyd itself. - -# THEORETICALLY, you can: -# * Unpack the latest SSL release one level above your main Python source -# directory. It is likely you will already find the zlib library and -# any other external packages there. -# * Install ActivePerl and ensure it is somewhere on your path. -# * Run this script from the PCBuild directory. -# -# it should configure and build SSL, then build the ssl Python extension -# without intervention. - -import os, sys, re - -# Find all "foo.exe" files on the PATH. -def find_all_on_path(filename, extras = None): - entries = os.environ["PATH"].split(os.pathsep) - ret = [] - for p in entries: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - if extras: - for p in extras: - fname = os.path.abspath(os.path.join(p, filename)) - if os.path.isfile(fname) and fname not in ret: - ret.append(fname) - return ret - -# Find a suitable Perl installation for OpenSSL. -# cygwin perl does *not* work. ActivePerl does. -# Being a Perl dummy, the simplest way I can check is if the "Win32" package -# is available. -def find_working_perl(perls): - for perl in perls: - fh = os.popen(perl + ' -e "use Win32;"') - fh.read() - rc = fh.close() - if rc: - continue - return perl - print "Can not find a suitable PERL:" - if perls: - print " the following perl interpreters were found:" - for p in perls: - print " ", p - print " None of these versions appear suitable for building OpenSSL" - else: - print " NO perl interpreters were found on this machine at all!" - print " Please install ActivePerl and ensure it appears on your path" - print "The Python SSL module was not built" - return None - -# Locate the best SSL directory given a few roots to look into. -def find_best_ssl_dir(sources): - candidates = [] - for s in sources: - try: - s = os.path.abspath(s) - fnames = os.listdir(s) - except os.error: - fnames = [] - for fname in fnames: - fqn = os.path.join(s, fname) - if os.path.isdir(fqn) and fname.startswith("openssl-"): - candidates.append(fqn) - # Now we have all the candidates, locate the best. - best_parts = [] - best_name = None - for c in candidates: - parts = re.split("[.-]", os.path.basename(c))[1:] - # eg - openssl-0.9.7-beta1 - ignore all "beta" or any other qualifiers - if len(parts) >= 4: - continue - if parts > best_parts: - best_parts = parts - best_name = c - if best_name is not None: - print "Found an SSL directory at '%s'" % (best_name,) - else: - print "Could not find an SSL directory in '%s'" % (sources,) - return best_name - -def main(): - debug = "-d" in sys.argv - build_all = "-a" in sys.argv - make_flags = "" - if build_all: - make_flags = "-a" - # perl should be on the path, but we also look in "\perl" and "c:\\perl" - # as "well known" locations - perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) - perl = find_working_perl(perls) - if perl is None: - sys.exit(1) - - print "Found a working perl at '%s'" % (perl,) - # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. - ssl_dir = find_best_ssl_dir(("../..",)) - if ssl_dir is None: - sys.exit(1) - - old_cd = os.getcwd() - try: - os.chdir(ssl_dir) - # If the ssl makefiles do not exist, we invoke Perl to generate them. - if not os.path.isfile(os.path.join(ssl_dir, "32.mak")) or \ - not os.path.isfile(os.path.join(ssl_dir, "d32.mak")): - print "Creating the makefiles..." - # Put our working Perl at the front of our path - os.environ["PATH"] = os.path.split(perl)[0] + \ - os.pathsep + \ - os.environ["PATH"] - # ms\32all.bat will reconfigure OpenSSL and then try to build - # all outputs (debug/nondebug/dll/lib). So we filter the file - # to exclude any "nmake" commands and then execute. - tempname = "ms\\32all_py.bat" - - in_bat = open("ms\\32all.bat") - temp_bat = open(tempname,"w") - while 1: - cmd = in_bat.readline() - print 'cmd', repr(cmd) - if not cmd: break - if cmd.strip()[:5].lower() == "nmake": - continue - temp_bat.write(cmd) - in_bat.close() - temp_bat.close() - os.system(tempname) - try: - os.remove(tempname) - except: - pass - - # Now run make. - print "Executing nmake over the ssl makefiles..." - if debug: - rc = os.system("nmake /nologo -f d32.mak") - if rc: - print "Executing d32.mak failed" - print rc - sys.exit(rc) - else: - rc = os.system("nmake /nologo -f 32.mak") - if rc: - print "Executing 32.mak failed" - print rc - sys.exit(rc) - finally: - os.chdir(old_cd) - # And finally, we can build the _ssl module itself for Python. - defs = "SSL_DIR=%s" % (ssl_dir,) - if debug: - defs = defs + " " + "DEBUG=1" - rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) - sys.exit(rc) - -if __name__=='__main__': - main() diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/bz2.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/bz2.dsp deleted file mode 100644 index e6f72ec1..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/bz2.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="bz2" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=bz2 - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "bz2.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "bz2.mak" CFG="bz2 - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "bz2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "bz2 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "bz2 - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\bz2" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\..\bzip2-1.0.2" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 ..\..\bzip2-1.0.2\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./bz2.pyd" -# SUBTRACT LINK32 /pdb:none /nodefaultlib - -!ELSEIF "$(CFG)" == "bz2 - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\bz2" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\..\bzip2-1.0.2" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ..\..\bzip2-1.0.2\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt" /nodefaultlib:"libc" /out:"./bz2_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "bz2 - Win32 Release" -# Name "bz2 - Win32 Debug" -# Begin Source File - -SOURCE=..\Modules\bz2module.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/datetime.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/datetime.dsp deleted file mode 100644 index 8d786ab9..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/datetime.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="datetime" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=datetime - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "datetime.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "datetime.mak" CFG="datetime - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "datetime - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "datetime - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "datetime - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\datetime" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /base:"0x1D180000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./datetime.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "datetime - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\datetime" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /base:"0x1D180000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /nodefaultlib:"msvcrt" /out:"./datetime_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "datetime - Win32 Release" -# Name "datetime - Win32 Debug" -# Begin Source File - -SOURCE=..\Modules\datetimemodule.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/field3.py b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/field3.py deleted file mode 100644 index 8ed94e93..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/field3.py +++ /dev/null @@ -1,35 +0,0 @@ -# An absurd workaround for the lack of arithmetic in MS's resource compiler. -# After building Python, run this, then paste the output into the appropriate -# part of PC\python_nt.rc. -# Example output: -# -# * For 2.3a0, -# * PY_MICRO_VERSION = 0 -# * PY_RELEASE_LEVEL = 'alpha' = 0xA -# * PY_RELEASE_SERIAL = 1 -# * -# * and 0*1000 + 10*10 + 1 = 101. -# */ -# #define FIELD3 101 - -import sys - -major, minor, micro, level, serial = sys.version_info -levelnum = {'alpha': 0xA, - 'beta': 0xB, - 'candidate': 0xC, - 'final': 0xF, - }[level] -string = sys.version.split()[0] # like '2.3a0' - -print " * For %s," % string -print " * PY_MICRO_VERSION = %d" % micro -print " * PY_RELEASE_LEVEL = %r = %s" % (level, hex(levelnum)) -print " * PY_RELEASE_SERIAL = %d" % serial -print " *" - -field3 = micro * 1000 + levelnum * 10 + serial - -print " * and %d*1000 + %d*10 + %d = %d" % (micro, levelnum, serial, field3) -print " */" -print "#define FIELD3", field3 diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/installer.bmp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/installer.bmp deleted file mode 100644 index 6c5656931f85304b213633fa9b6836cc36d3db03..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 50324 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 -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=mmap - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "mmap.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "mmap.mak" CFG="mmap - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "mmap - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "mmap - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "mmap - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\mmap" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\Include" /I "..\PC" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "NDEBUG" -# ADD RSC /l 0xc09 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1F0000" /dll /machine:I386 /out:"./mmap.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "mmap - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\mmap" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "_DEBUG" -# ADD RSC /l 0xc09 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1F0000" /dll /debug /machine:I386 /out:"./mmap_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "mmap - Win32 Release" -# Name "mmap - Win32 Debug" -# Begin Source File - -SOURCE=..\Modules\mmapmodule.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/parser.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/parser.dsp deleted file mode 100644 index 267b2d29..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/parser.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="parser" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=parser - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "parser.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "parser.mak" CFG="parser - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "parser - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "parser - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "parser - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\parser" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "C:\Program Files\Tcl\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1A0000" /subsystem:windows /dll /debug /machine:I386 /out:"./parser.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "parser - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\parser" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "C:\Program Files\Tcl\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1A0000" /subsystem:windows /dll /debug /machine:I386 /out:"./parser_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "parser - Win32 Release" -# Name "parser - Win32 Debug" -# Begin Source File - -SOURCE=..\Modules\parsermodule.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pcbuild.dsw b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pcbuild.dsw deleted file mode 100644 index a90316bd..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pcbuild.dsw +++ /dev/null @@ -1,359 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "_bsddb"=".\_bsddb.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_csv"=".\_csv.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_socket"=".\_socket.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_sre"=".\_sre.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_ssl"=".\_ssl.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency - Begin Project Dependency - Project_Dep_Name _sre - End Project Dependency - Begin Project Dependency - Project_Dep_Name python - End Project Dependency - Begin Project Dependency - Project_Dep_Name w9xpopen - End Project Dependency -}}} - -############################################################################### - -Project: "_symtable"=".\_symtable.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_testcapi"=".\_testcapi.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "_tkinter"=".\_tkinter.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "bz2"=".\bz2.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "datetime"=".\datetime.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "make_versioninfo"=".\make_versioninfo.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "mmap"=".\mmap.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "parser"=".\parser.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "pyexpat"=".\pyexpat.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "python"=".\python.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "pythoncore"=".\pythoncore.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "pythonw"=".\pythonw.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "select"=".\select.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "unicodedata"=".\unicodedata.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "w9xpopen"=".\w9xpopen.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "winreg"=".\winreg.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "winsound"=".\winsound.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Project: "zlib"=".\zlib.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pythoncore - End Project Dependency -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pyexpat.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pyexpat.dsp deleted file mode 100644 index 50df6015..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pyexpat.dsp +++ /dev/null @@ -1,111 +0,0 @@ -# Microsoft Developer Studio Project File - Name="pyexpat" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=pyexpat - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pyexpat.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pyexpat.mak" CFG="pyexpat - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pyexpat - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "pyexpat - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pyexpat - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\pyexpat" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\Modules\expat" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1D100000" /subsystem:windows /dll /debug /machine:I386 /out:"./pyexpat.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "pyexpat - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\pyexpat" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\Modules\expat" /D "_DEBUG" /D "HAVE_EXPAT_H" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1D100000" /subsystem:windows /dll /debug /machine:I386 /out:"./pyexpat_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "pyexpat - Win32 Release" -# Name "pyexpat - Win32 Debug" -# Begin Source File - -SOURCE=..\Modules\pyexpat.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\expat\xmlparse.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\expat\xmlrole.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\expat\xmltok.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/python.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/python.dsp deleted file mode 100644 index c34a0b00..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/python.dsp +++ /dev/null @@ -1,100 +0,0 @@ -# Microsoft Developer Studio Project File - Name="python" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=python - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "python.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "python.mak" CFG="python - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "python - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "python - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "python - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\python" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1d000000" /subsystem:console /debug /machine:I386 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "python - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\python" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\Include" /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1d000000" /subsystem:console /debug /machine:I386 /out:"./python_d.exe" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "python - Win32 Release" -# Name "python - Win32 Debug" -# Begin Source File - -SOURCE=..\PC\pycon.ico -# End Source File -# Begin Source File - -SOURCE=..\Modules\python.c -# End Source File -# Begin Source File - -SOURCE=..\PC\python_exe.rc -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/python.iss b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/python.iss deleted file mode 100644 index ff63a3e5..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/python.iss +++ /dev/null @@ -1,241 +0,0 @@ -; Script generated by the Inno Setup Script Wizard. -; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! - -; This is the whole ball of wax for an Inno installer for Python. -; To use, download Inno Setup from http://www.jrsoftware.org/isdl.htm/, -; install it, and double-click on this file. That launches the Inno -; script compiler. The GUI is extemely simple, and has only one button -; you may not recognize instantly: click it. You're done. It builds -; the installer into PCBuild/Python-2.2a1.exe. Size and speed of the -; installer are competitive with the Wise installer; Inno uninstall -; seems much quicker than Wise (but also feebler, and the uninstall -; log is in some un(human)readable binary format). -; -; What's Done -; ----------- -; All the usual Windows Python files are installed by this now. -; All the usual Windows Python Start menu entries are created and -; work fine. -; .py, .pyw, .pyc and .pyo extensions are registered. -; PROBLEM: Inno uninstall does not restore their previous registry -; associations (if any). Wise did. This will make life -; difficult for alpha (etc) testers. -; The Python install is fully functional for "typical" uses. -; -; What's Not Done -; --------------- -; None of "Mark Hammond's" registry entries are written. -; No installation of files is done into the system dir: -; The MS DLLs aren't handled at all by this yet. -; Python22.dll is unpacked into the main Python dir. -; -; Inno can't do different things on NT/2000 depending on whether the user -; has Admin privileges, so I don't know how to "solve" either of those, -; short of building two installers (one *requiring* Admin privs, the -; other not doing anything that needs Admin privs). -; -; Inno has no concept of variables, so lots of lines in this file need -; to be fiddled by hand across releases. Simplest way out: stick this -; file in a giant triple-quoted r-string (note that backslashes are -; required all over the place here -- forward slashes DON'T WORK in -; Inno), and use %(yadda)s string interpolation to do substitutions; i.e., -; write a very simple Python program to *produce* this script. - -[Setup] -; Note: we *want* the version number to show up everywhere. -; Which of these controls App Path??? -AppName=Python 2.2 alpha 1 -AppVerName=Python 2.2 alpha 1 -AppId=Python 2.2 -AppVersion=2.2a1 -AppCopyright=Copyright © 2001 Python Software Foundation - -; Default install dir; value of {app} later (unless user overrides). -; {sd} = system root drive, probably "C:". -DefaultDirName={sd}\Python22 - -; Start menu folder name; value of {group} later (unless user overrides). -DefaultGroupName=Python 2.2 - -; Point SourceDir to one above PCBuild = src. -; YAY! That actually worked: means this script can run unchanged from anyone's -; CVS tree, no matter what they called the top-level directories. Wise -; required hardcoded absolute paths all over the place. -SourceDir=.. -OutputDir=PCBuild -OutputBaseFilename=Python-2.2a1 - -AppPublisher=PythonLabs at Zope Corporation -AppPublisherURL=http://www.python.org -AppSupportURL=http://www.python.org -AppUpdatesURL=http://www.python.org - -AlwaysCreateUninstallIcon=yes -ChangesAssociations=yes -UninstallLogMode=new - -; The fewer screens the better; leave these commented. -;LicenseFile=LICENSE -;InfoBeforeFile=Misc\NEWS - -; uncomment the following line if you want your installation to run on NT 3.51 too. -; MinVersion=4,3.51 - -[Types] -Name: normal; Description: "Select desired components"; Flags: iscustom - -[Components] -Name: main; Description: "Python interpreter, library and Tk"; Types: normal -Name: docs; Description: "Python documentation (HTML)"; Types: normal -Name: tools; Description: "Python utility scripts (Tools\)"; Types: normal -Name: test; Description: "Python test suite (Lib\test\)"; Types: normal - -[Tasks] -Name: startmenu; Description: "Create Start menu shortcuts"; Components: main docs tools -Name: extensions; Description: "Register file extensions (.py, .pyw, .pyc, .pyo)"; Components: main - -[Files] -; Caution: Using forward slashes instead screws up in amazing ways. -; Unknown: By the time Components (and other attrs) are added to these lines, they're -; going to get awfully long. But don't see a way to continue logical lines across -; physical lines. - -Source: LICENSE; DestDir: "{app}"; DestName: LICENSE.txt; CopyMode: alwaysoverwrite -Source: README; DestDir: "{app}"; DestName: README.txt; CopyMode: alwaysoverwrite -Source: Misc\News; DestDir: "{app}"; DestName: NEWS.txt; CopyMode: alwaysoverwrite -Source: PC\*.ico; DestDir: "{app}"; CopyMode: alwaysoverwrite; Components: main - - -Source: PCbuild\python.exe; DestDir: "{app}"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\pythonw.exe; DestDir: "{app}"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\w9xpopen.exe; DestDir: "{app}"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\python22.dll; DestDir: "{app}"; CopyMode: alwaysoverwrite; Components: main - -Source: ..\tcl\bin\tcl83.dll; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: ..\tcl\bin\tk83.dll; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: ..\tcl\lib\*.*; DestDir: "{app}\tcl"; CopyMode: alwaysoverwrite; Components: main; Flags: recursesubdirs - -Source: PCbuild\_socket.pyd; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\_socket.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\_sre.pyd; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\_sre.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\_symtable.pyd; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\_symtable.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\_testcapi.pyd; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\_testcapi.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\_tkinter.pyd; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\_tkinter.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\bsddb.pyd; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\bsddb.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\mmap.pyd; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\mmap.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\parser.pyd; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\parser.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\pyexpat.pyd; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\pyexpat.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\select.pyd; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\select.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\unicodedata.pyd; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\unicodedata.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\_winreg.pyd; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\_winreg.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\winsound.pyd; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\winsound.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\zlib.pyd; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main -Source: PCbuild\zlib.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: PCbuild\python22.lib; DestDir: "{app}\libs"; CopyMode: alwaysoverwrite; Components: main - -Source: ..\expat\Libs\expat.dll; DestDir: "{app}\DLLs"; CopyMode: alwaysoverwrite; Components: main - -Source: Lib\*.py; DestDir: "{app}\Lib"; CopyMode: alwaysoverwrite; Components: main -Source: Lib\lib-tk\*.py; DestDir: "{app}\Lib\lib-tk"; CopyMode: alwaysoverwrite; Components: main - -Source: Lib\encodings\*.py; DestDir: "{app}\Lib\encodings"; CopyMode: alwaysoverwrite; Components: main -Source: Lib\distutils\*.py; DestDir: "{app}\Lib\distutils"; CopyMode: alwaysoverwrite; Components: main -Source: Lib\xml\*.py; DestDir: "{app}\Lib\xml"; CopyMode: alwaysoverwrite; Flags: recursesubdirs; Components: main -Source: Lib\lib-old\*.py; DestDir: "{app}\Lib\lib-old"; CopyMode: alwaysoverwrite; Components: main -Source: Lib\site-packages\README; DestDir: "{app}\Lib\site-packages"; DestName: README.txt; CopyMode: alwaysoverwrite; Components: main -Source: Include\*.h; DestDir: "{app}\include"; CopyMode: alwaysoverwrite; Components: main -Source: PC\pyconfig.h; DestDir: "{app}\include"; CopyMode: alwaysoverwrite; Components: main - -Source: Tools\scripts\*.py; DestDir: "{app}\Tools\Scripts"; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\scripts\*.pyw; DestDir: "{app}\Tools\Scripts"; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\scripts\*.doc; DestDir: "{app}\Tools\Scripts"; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\scripts\README; DestDir: "{app}\Tools\Scripts"; DestName: README.txt; CopyMode: alwaysoverwrite; Components: tools - -Source: Tools\webchecker\*.py; DestDir: "{app}\Tools\webchecker"; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\webchecker\README; DestDir: "{app}\Tools\webchecker"; DestName: README.txt; CopyMode: alwaysoverwrite; Components: tools - -Source: Tools\versioncheck\*.py; DestDir: "{app}\Tools\versioncheck"; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\versioncheck\README; DestDir: "{app}\Tools\versioncheck"; DestName: README.txt; CopyMode: alwaysoverwrite; Components: tools - -Source: Tools\idle\*.py; DestDir: "{app}\Tools\idle"; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\idle\idle.pyw; DestDir: "{app}\Tools\idle"; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\idle\*.txt; DestDir: "{app}\Tools\idle"; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\idle\Icons\*.*; DestDir: "{app}\Tools\idle\Icons"; CopyMode: alwaysoverwrite; Components: tools - -Source: Tools\compiler\*.py; DestDir: "{app}\Tools\compiler"; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\compiler\README; DestDir: "{app}\Tools\compiler"; DestName: README.txt; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\compiler\compiler\*.py; DestDir: "{app}\Tools\compiler\compiler"; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\compiler\compiler\*.txt; DestDir: "{app}\Tools\compiler\compiler"; CopyMode: alwaysoverwrite; Components: tools - -Source: Tools\pynche\*.py; DestDir: "{app}\Tools\pynche"; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\pynche\pynche.pyw; DestDir: "{app}\Tools\pynche"; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\pynche\X\*.txt; DestDir: "{app}\Tools\pynche\X"; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\pynche\README; DestDir: "{app}\Tools\pynche"; DestName: README.txt; CopyMode: alwaysoverwrite; Components: tools -Source: Tools\pynche\pynche; DestDir: "{app}\Tools\pynche"; DestName: pynche.py; CopyMode: alwaysoverwrite; Components: tools - -Source: html\*.*; DestDir: "{app}\Doc"; CopyMode: alwaysoverwrite; Flags: recursesubdirs; Components: docs - -Source: Lib\test\*.py; DestDir: "{app}\Lib\test"; CopyMode: alwaysoverwrite; Components: test -Source: Lib\test\*.uue; DestDir: "{app}\Lib\test"; CopyMode: alwaysoverwrite; Components: test -Source: Lib\test\*.xml; DestDir: "{app}\Lib\test"; CopyMode: alwaysoverwrite; Components: test -Source: Lib\test\*.out; DestDir: "{app}\Lib\test"; CopyMode: alwaysoverwrite; Components: test -Source: Lib\test\audiotest.au; DestDir: "{app}\Lib\test"; CopyMode: alwaysoverwrite; Components: test -Source: Lib\test\output\*.*; DestDir: "{app}\Lib\test\output"; CopyMode: alwaysoverwrite; Components: test - -[Icons] -Tasks: startmenu; Name: "{group}\IDLE (Python GUI)"; Filename: "{app}\pythonw.exe"; WorkingDir: "{app}"; Parameters: """{app}\Tools\idle\idle.pyw"""; Components: tools -Tasks: startmenu; Name: "{group}\Module Docs"; Filename: "{app}\pythonw.exe"; WorkingDir: "{app}"; Parameters: """{app}\Tools\Scripts\pydoc.pyw"""; Components: tools -Tasks: startmenu; Name: "{group}\Python (command line)"; Filename: "{app}\python.exe"; WorkingDir: "{app}"; Components: main -Tasks: startmenu; Name: "{group}\Python Manuals"; Filename: "{app}\Doc\index.html"; WorkingDir: "{app}"; Components: docs - -[Registry] -; Register .py -Tasks: extensions; Root: HKCR; Subkey: ".py"; ValueType: string; ValueName: ""; ValueData: "Python File"; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: ".py"; ValueType: string; ValueName: "Content Type"; ValueData: "text/plain"; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: "Python File"; ValueType: string; ValueName: ""; ValueData: "Python File"; Flags: uninsdeletekey -Tasks: extensions; Root: HKCR; Subkey: "Python File\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\Py.ico" -Tasks: extensions; Root: HKCR; Subkey: "Python File\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\python.exe"" ""%1"" %*" - -; Register .pyc -Tasks: extensions; Root: HKCR; Subkey: ".pyc"; ValueType: string; ValueName: ""; ValueData: "Python CompiledFile"; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: "Python CompiledFile"; ValueType: string; ValueName: ""; ValueData: "Compiled Python File"; Flags: uninsdeletekey -Tasks: extensions; Root: HKCR; Subkey: "Python CompiledFile\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\pyc.ico" -Tasks: extensions; Root: HKCR; Subkey: "Python CompiledFile\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\python.exe"" ""%1"" %*" - -; Register .pyo -Tasks: extensions; Root: HKCR; Subkey: ".pyo"; ValueType: string; ValueName: ""; ValueData: "Python CompiledFile"; Flags: uninsdeletevalue - -; Register .pyw -Tasks: extensions; Root: HKCR; Subkey: ".pyw"; ValueType: string; ValueName: ""; ValueData: "Python NoConFile"; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: ".pyw"; ValueType: string; ValueName: "Content Type"; ValueData: "text/plain"; Flags: uninsdeletevalue -Tasks: extensions; Root: HKCR; Subkey: "Python NoConFile"; ValueType: string; ValueName: ""; ValueData: "Python File (no console)"; Flags: uninsdeletekey -Tasks: extensions; Root: HKCR; Subkey: "Python NoConFile\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\Py.ico" -Tasks: extensions; Root: HKCR; Subkey: "Python NoConFile\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\pythonw.exe"" ""%1"" %*" - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/python20.wse b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/python20.wse deleted file mode 100644 index 69b1677d..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/python20.wse +++ /dev/null @@ -1,3168 +0,0 @@ -Document Type: WSE -item: Global - Version=9.0 - Title=Python 2.3.3 - Flags=00010100 - Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - Japanese Font Name=MS Gothic - Japanese Font Size=10 - Start Gradient=0 255 0 - End Gradient=0 128 0 - Windows Flags=00000100000011010010010100001010 - Log Pathname=%MAINDIR%\INSTALL.LOG - Message Font=MS Sans Serif - Font Size=8 - Pages Modified=00010000011101000000000100000111 - Extra Pages=00000000000000000000000010110010 - Disk Filename=SETUP - Patch Flags=0000000000001001 - Patch Threshold=85 - Patch Memory=4000 - MIF PDF Version=1.0 - MIF SMS Version=2.0 - EXE Filename=Python-2.3.3.exe - Dialogs Version=8 - Version File=2.3.3 - Version Description=Python Programming Language - Version Copyright=©2001-2003 Python Software Foundation - Version Company=PythonLabs at Zope Corporation - Crystal Format=10111100101100000010001001001001 - Step View=&All - Variable Name1=_WISE_ - Variable Description1=WISE root directory - Variable Default1=C:\Programme\Wise Installation System - Variable Flags1=00001000 - Variable Name2=_TCLDIR_ - Variable Description2=The directory in which the Tcl/Tk installation - Variable Description2=lives. This must be a sibling of the Python - Variable Description2=directory. - Variable Default2=tcl84 - Variable Flags2=00001000 - Variable Name3=_DOC_ - Variable Description3=The unpacked HTML doc directory. - Variable Default3=..\chm - Variable Flags3=00001001 - Variable Name4=_SYS_ - Variable Description4=VC redistributables directory (where to find MSVCRT.DLL). - Variable Description4= - Variable Description4=NEVER USE A SYSTEM DIRECTORY! - Variable Default4=C:\VCREDIST\VC6SP5 - Variable Values4=C:\Code\MSDLLs - Variable Values4=C:\VCREDIST\VC6SP5 - Variable Flags4=00000010 - Variable Name5=_PYMAJOR_ - Variable Description5=Python major version number; the 2 in 2.3. - Variable Default5=2 - Variable Flags5=00001000 - Variable Name6=_PYMINOR_ - Variable Description6=Python minor version number; the 3 in 2.3 - Variable Default6=3 - Variable Flags6=00001000 - Variable Name7=_DOADMIN_ - Variable Description7=The initial value for %DOADMIN%. - Variable Description7=When 0, we never try to write under HKLM, - Variable Description7=and install the Python + MS runtime DLLs in - Variable Description7=the Python directory instead of the system dir. - Variable Default7=1 - Variable Values7=1 - Variable Values7=0 - Variable Flags7=00001010 - Variable Name8=_ALIASNAME_ - Variable Flags8=00001000 - Variable Name9=_ALIASPATH_ - Variable Flags9=00001000 - Variable Name10=_ALIASTYPE_ - Variable Flags10=00001000 -end -item: Set Variable - Variable=PYVER_STRING - Value=2.3.3 -end -item: Remark -end -item: Remark - Text=When the version number changes, set the compiler -end -item: Remark - Text=vrbls _PYMAJOR_ and _PYMINOR_. -end -item: Remark - Text=Nothing in the script below should need fiddling then. -end -item: Remark - Text=Other things that need fiddling: -end -item: Remark - Text= PYVER_STRING above. -end -item: Remark - Text= The "Title:" in the upper left corner of the GUI. -end -item: Remark - Text= Build Settings and Version Resource on step 6 (Finish) of the Installation Expert -end -item: Remark - Text= Be sure to select Steps->All or you may not see these! -end -item: Remark -end -item: Remark - Text=When the version of Tcl/Tk changes, the compiler vrbl -end -item: Remark - Text=_TCLDIR_ may also need to be changed. -end -item: Remark -end -item: Set Variable - Variable=APPTITLE - Value=Python %PYVER_STRING% -end -item: Remark - Text=PY_VERSION should be major.minor only; used to create the registry key; must match MS_DLL_ID in python_nt.rc -end -item: Set Variable - Variable=PY_VERSION - Value=%_PYMAJOR_%.%_PYMINOR_% -end -item: Remark - Text=GROUP is the Start menu group name; user can override. -end -item: Set Variable - Variable=GROUP - Value=Python %PY_VERSION% - Flags=10000000 -end -item: Remark - Text=MAINDIR is the app directory; user can override. -end -item: Set Variable - Variable=MAINDIR - Value=Python%_PYMAJOR_%%_PYMINOR_% -end -item: Remark -end -item: Set Variable - Variable=DOADMIN - Value=%_DOADMIN_% -end -item: Remark - Text=Give non-admin users a chance to abort. -end -item: Check Configuration - Flags=10011111 -end -item: Set Variable - Variable=DOADMIN - Value=0 -end -item: Display Message - Title=Doing non-admin install - Text=The current login does not have Administrator Privileges on this machine. Python will install its registry information into the per-user area only for the current login, instead of into the per-machine area for every account on this machine. Some advanced uses of Python may not work as a result (for example, running a Python script as a service). - Text= - Text=If this is not what you want, please click Cancel to abort this installation, log on as an Administrator, and start the installation again. - Flags=00001000 -end -item: End Block -end -item: Remark -end -item: Remark - Text=BEGIN WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark - Text=Note from Tim: the "stop" on the next line is actually "pause". -end -item: Open/Close INSTALL.LOG - Flags=00000001 -end -item: Remark - Text=If the destination system does not have a writable Windows\System directory, system files will be written to the Windows\ directory -end -item: Check if File/Dir Exists - Pathname=%SYS% - Flags=10000100 -end -item: Set Variable - Variable=SYS - Value=%WIN% -end -item: End Block -end -item: Check Configuration - Flags=10111011 -end -item: Get Registry Key Value - Variable=COMMON - Key=SOFTWARE\Microsoft\Windows\CurrentVersion - Default=C:\Program Files\Common Files - Value Name=CommonFilesDir - Flags=00000100 -end -item: Get Registry Key Value - Variable=PROGRAM_FILES - Key=SOFTWARE\Microsoft\Windows\CurrentVersion - Default=C:\Program Files - Value Name=ProgramFilesDir - Flags=00000100 -end -item: Set Variable - Variable=EXPLORER - Value=1 -end -item: End Block -end -item: Remark - Text=Note from Tim: The Wizard hardcod "C:" at the start of the replacement text for MAINDIR. -end -item: Remark - Text=That's not appropriate if the system drive doesn't happen to be C:. -end -item: Remark - Text=I removed the "C:", and that did the right thing for two people who tested it on non-C: machines, -end -item: Remark - Text=but it's unclear whether it will always do the right thing. -end -item: Set Variable - Variable=MAINDIR - Value=\%MAINDIR% - Flags=00001100 -end -item: Remark - Text=BACKUP is the variable that holds the path that all backup files will be copied to when overwritten -end -item: Set Variable - Variable=BACKUP - Value=%MAINDIR%\BACKUP - Flags=10000000 -end -item: Remark - Text=DOBACKUP determines if a backup will be performed. The possible values are A (do backup) or B (do not do backup) -end -item: Set Variable - Variable=DOBACKUP - Value=A -end -item: Remark - Text=BRANDING determines if the installation will be branded with a name and company. By default, this is written to the INST directory (installation media). -end -item: Set Variable - Variable=BRANDING - Value=0 -end -item: If/While Statement - Variable=BRANDING - Value=1 -end -item: Read INI Value - Variable=NAME - Pathname=%INST%\CUSTDATA.INI - Section=Registration - Item=Name -end -item: Read INI Value - Variable=COMPANY - Pathname=%INST%\CUSTDATA.INI - Section=Registration - Item=Company -end -item: If/While Statement - Variable=NAME -end -item: Set Variable - Variable=DOBRAND - Value=1 -end -item: Get System Information - Variable=NAME - Flags=00000110 -end -item: Get System Information - Variable=COMPANY - Flags=00000111 -end -item: End Block -end -item: End Block -end -item: Remark - Text=END WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark -end -item: Remark - Text=Set vrbls for the "Advanced Options" subdialog of Components. -end -item: Set Variable - Variable=SELECT_ADMIN - Value=A -end -item: If/While Statement - Variable=DOADMIN - Value=0 -end -item: Set Variable - Variable=SELECT_ADMIN - Value=B -end -item: End Block -end -item: Remark -end -item: Remark - Text=TASKS values: -end -item: Remark - Text=A: Register file extensions -end -item: Remark - Text=B: Create Start Menu shortcuts -end -item: Remark - Text=C: Compile Python library files -end -item: Set Variable - Variable=TASKS - Value=AB -end -item: Remark -end -item: Remark - Text=COMPONENTS values: -end -item: Remark - Text=A: interpreter and libraries -end -item: Remark - Text=B: Tcl/Tk -end -item: Remark - Text=C: docs -end -item: Remark - Text=D: tools -end -item: Remark - Text=E: test suite -end -item: Set Variable - Variable=COMPONENTS - Value=ABCDE -end -item: Remark -end -item: Remark - Text=March thru the user GUI. -end -item: Wizard Block - Direction Variable=DIRECTION - Display Variable=DISPLAY - Bitmap Pathname=.\installer.bmp - X Position=9 - Y Position=10 - Filler Color=11173759 - Dialog=Select Destination Directory - Dialog=Backup Replaced Files - Dialog=Select Components - Dialog=Select Program Manager Group - Variable= - Variable= - Variable= - Variable=TASKS - Value= - Value= - Value= - Value=B - Compare=0 - Compare=0 - Compare=0 - Compare=3 - Flags=00000011 -end -item: If/While Statement - Variable=DISPLAY - Value=Start Installation -end -item: Set Variable - Variable=SUMMARY - Value=Install directory: %MAINDIR%%CRLF% -end -item: Remark -end -item: If/While Statement - Variable=SELECT_ADMIN - Value=A -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Doing admin install.%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Doing non-admin install.%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=DOBACKUP - Value=A -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Make backups, into %BACKUP%%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Don't make backups.%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Components:%CRLF% - Flags=00000001 -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Python interpreter and libraries%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Tcl/Tk (Tkinter, IDLE, pydoc)%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Python documentation%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=D - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Tool and utility scripts%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=E - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Python test suite%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=TASKS - Value=A - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Register file extensions.%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Don't register file extensions.%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Start Menu group: %GROUP%%CRLF% - Flags=00000001 -end -item: If/While Statement - Variable=TASKS - Value=B - Flags=00000010 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%No Start Menu shortcuts.%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=TASKS - Value=C - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Compile Python files%CRLF% - Flags=00000001 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Custom Dialog Set - Name=Select Destination Directory - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalación de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 11 323 33 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Select Destination Directory - Text French=Sélectionner le répertoire de destination - Text German=Zielverzeichnis wählen - Text Spanish=Seleccione el directorio de destino - Text Italian=Selezionare Directory di destinazione - end - item: Listbox - Rectangle=108 58 321 219 - Variable=MAINDIR - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000100000010000000101000001 - Flags=0000110000001010 - Text=%MAINDIR% - Text= - end - item: Static - Rectangle=108 40 313 58 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=Please select a directory for the %APPTITLE% files. - end - end - item: Dialog - Title=Select Destination Directory - Title French=Sélectionner le répertoire de destination - Title German=Zielverzeichnis wählen - Title Spanish=Seleccione el directorio de destino - Title Italian=Selezionare Directory di destinazione - Width=276 - Height=216 - Font Name=Helv - Font Size=8 - item: Listbox - Rectangle=6 6 204 186 - Variable=MAINDIR - Create Flags=01010000100000010000000101000000 - Flags=0000110000100010 - Text=%MAINDIR% - Text French=%MAINDIR% - Text German=%MAINDIR% - Text Spanish=%MAINDIR% - Text Italian=%MAINDIR% - end - item: Push Button - Rectangle=209 8 265 26 - Create Flags=01010000000000010000000000000001 - Text=OK - Text French=OK - Text German=OK - Text Spanish=Aceptar - Text Italian=OK - end - item: Push Button - Rectangle=209 31 265 50 - Variable=MAINDIR - Value=%MAINDIR_SAVE% - Create Flags=01010000000000010000000000000000 - Flags=0000000000000001 - Text=Cancel - Text French=Annuler - Text German=Abbrechen - Text Spanish=Cancelar - Text Italian=Annulla - end - end -end -item: Custom Dialog Set - Name=Backup Replaced Files - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Fichiers de Sauvegarde Remplacés - Title German=Sicherungskopie von ersetzten Dateien erstellen - Title Portuguese=Ficheiros substituídos de segurança - Title Spanish=Copias de seguridad de los archivos reemplazados - Title Italian=Backup file sostituiti - Title Danish=Sikkerhedskopiering af erstattede filer - Title Dutch=Vervangen bestanden kopiëren - Title Norwegian=Sikkerhetskopiere erstattede filer - Title Swedish=Säkerhetskopiera utbytta filer - Width=350 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 251 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suivant> - Text German=&Weiter> - Text Portuguese=&Próximo> - Text Spanish=&Siguiente > - Text Italian=&Avanti > - Text Danish=&Næste> - Text Dutch=&Volgende> - Text Norwegian=&Neste> - Text Swedish=&Nästa > - end - item: Push Button - Rectangle=131 234 188 251 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Text=< &Back - Text French=<&Retour - Text German=<&Zurück - Text Portuguese=<&Retornar - Text Spanish=<&Retroceder - Text Italian=< &Indietro - Text Danish=<&Tilbage - Text Dutch=<&Terug - Text Norwegian=<&Tilbake - Text Swedish=< &Tillbaka - end - item: Push Button - Rectangle=278 234 330 251 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=Cancel - Text French=Annuler - Text German=Abbrechen - Text Portuguese=Cancelar - Text Spanish=Cancelar - Text Italian=Annulla - Text Danish=Annuller - Text Dutch=Annuleren - Text Norwegian=Avbryt - Text Swedish=Avbryt - end - item: Static - Rectangle=11 221 329 223 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 46 320 98 - Create Flags=01010000000000000000000000000000 - Text=This installation program can create backup copies of all files replaced during the installation. These files will be used when the software is uninstalled and a rollback is requested. If backup copies are not created, you will only be able to uninstall the software and not roll the system back to a previous state. - Text= - Text=Do you want to create backups of replaced files? - Text French=Le programme d'installation peut créer des copies de sauvegarde de tous les fichiers remplacés pendant l'installation. Ces fichiers sont utilisés au cas où le logiciel est désinstallé et que l'on procède à la reprise du système. Si les copies de sauvegarde ne sont pas créées, on ne pourra que désinstaller le logiciel sans reprendre le système à un état précédent. Voulez-vous créer une sauvegarde des fichiers remplacés ? - Text German=Dieses Installationsprogramm kann Sicherungskopien von allen während der Installation ersetzten Dateien erstellen. Diese Dateien werden zur Rückgängigmachung der Installation und bei Anforderung eines Rollbacks verwendet. Ohne Sicherungskopien ist nur eine Rückgängigmachung der Installation möglich, nicht aber ein Rollback des Systems. Sicherungskopien der ersetzten Dateien erstellen? - Text Portuguese=Este programa de instalação pode criar cópias de segurança de todos os ficheiros substituídos durante a instalação. Estes ficheiros serão utilizados quando o programa for desinstalado e for requisitada uma retomada. Se as cópias de segurança não forem criadas, só poderá desinstalar o programa e não pode retomar um estado anterior do sistema. Deseja criar cópias de segurança dos ficheiros substituídos? - Text Spanish=Este programa de instalación puede crear copias de seguridad de todos los archivos reemplazados durante la instalación. Estos archivos se utilizarán cuando se desinstale el software y se solicite volver al estado anterior. Si no se crean copias de seguridad, únicamente podrá desinstalar el software y no podrá devolver el sistema al estado anterior. ¿Desea crear archivos de seguridad de los archivos reemplazados? - Text Italian=Questo programma di installazione può creare copie di backup di tutti i file sostituiti durante l’installazione. Questi file saranno usati quando il software sarà disinstallato e sarà richiesto un ritorno allo stato precedente. Se non crei le copie di backup, potrai solo disinstallare il software, ma non potrai riportare il sistema allo stato precedente. Vuoi creare i file di backup dei file sostituiti? - Text Danish=Dette installationsprogram kan oprette sikkerhedskopier af alle filer, som erstattes under installationen. Disse filer benyttes, når softwaren fjernes, og den tidligere systemkonfiguration genetableres. Hvis der ikke oprettes sikkerhedskopier, kan du kun fjerne den installerede software og ikke genetablere den tidligere systemkonfiguration. Vil du oprette sikkerhedskopier af filer, som erstattes? - Text Dutch=Dit installatieprogramma kan kopieën maken van alle bestanden die tijdens de installatie worden vervangen. Deze worden dan gebruikt als de software-installatie ongedaan wordt gemaakt en u het systeem wilt laten terugkeren naar de oorspronkelijke staat. Als er geen back-up kopieën worden gemaakt, kunt u de software enkel verwijderen maar het systeem niet in de oorspronkelijke staat terugbrengen. Wilt u een back-up maken van de vervangen bestanden? - Text Norwegian=Dette installasjonsprogrammet kan lage sikkerhetskopier av alle filer som blir erstattet under installasjonen. Disse filene vil tas i bruk når programvaren er avinstallert og det er behov for tilbakestilling. Hvis det ikke er laget sikkerhetskopier, kan du kun avinstallere programvaren og ikke stille systemet tilbake til tidligere status. Ønsker du å lage sikkerhetskopier av de filene som blir erstattet nå? - Text Swedish=Installationsprogrammet kan skapa säkerhetskopior av alla filer som byts ut under installationen. Dessa filer kan sedan användas när programvaran avinstalleras och du begär rollback. Om du då inte har några säkerhetskopior kan du bara avinstallera programvaran, inte återskapa systemet i dess tidigare skick. Vill du göra säkerhetskopior av de ersatta filerna? - end - item: Radio Button - Rectangle=141 106 265 136 - Variable=DOBACKUP - Create Flags=01010000000000010000000000001001 - Text=&Yes, make backups - Text=N&o, do not make backups - Text= - Text French=&Oui - Text French=N&on - Text French= - Text German=&Ja - Text German=N&ein - Text German= - Text Portuguese=&Sim - Text Portuguese=Nã&o - Text Portuguese= - Text Spanish=&Sí - Text Spanish=N&o - Text Spanish= - Text Italian=&Sì - Text Italian=N&o - Text Italian= - Text Danish=&Ja - Text Danish=&Nej - Text Danish= - Text Dutch=&Ja - Text Dutch=N&ee - Text Dutch= - Text Norwegian=&Ja - Text Norwegian=&Nei - Text Norwegian= - Text Swedish=&Ja - Text Swedish=N&ej - Text Swedish= - end - item: Static - Control Name=BACK2 - Rectangle=108 173 320 208 - Action=1 - Create Flags=01010000000000000000000000000111 - Text=Backup File Destination Directory - Text French=Répertoire de destination des fichiers de sauvegarde - Text German=Zielverzeichnis für die Sicherungsdatei - Text Portuguese=Directório de destino de ficheiro de segurança - Text Spanish=Directorio de Destino de los Archivos de Seguridad - Text Italian=Directory di destinazione dei file di backup - Text Danish=Destinationsbibliotek til sikkerhedskopier - Text Dutch=Doeldirectory backup-bestand - Text Norwegian=Målkatalog for sikkerhetskopier - Text Swedish=Katalog för säkerhetskopierade filer - end - item: Push Button - Control Name=BACK3 - Rectangle=265 185 318 203 - Variable=BACKUP_SAVE - Value=%BACKUP% - Destination Dialog=1 - Action=2 - Create Flags=01010000000000010000000000000000 - Text=B&rowse... - Text French=P&arcourir - Text German=B&lättern... - Text Portuguese=P&rocurar - Text Spanish=V&isualizar... - Text Italian=Sfoglia... - Text Danish=&Gennemse... - Text Dutch=B&laderen... - Text Norwegian=Bla igjennom - Text Swedish=&Bläddra - end - item: Static - Control Name=BACK4 - Rectangle=129 188 254 200 - Destination Dialog=2 - Create Flags=01010000000000000000000000000000 - Text=%BACKUP% - Text French=%BACKUP% - Text German=%BACKUP% - Text Portuguese=%BACKUP% - Text Spanish=%BACKUP% - Text Italian=%BACKUP% - Text Danish=%BACKUP% - Text Dutch=%BACKUP% - Text Norwegian=%BACKUP% - Text Swedish=%BACKUP% - end - item: Static - Rectangle=108 11 323 36 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Backup Replaced Files - Text French=Sélectionner les composants - Text German=Komponenten auswählen - Text Spanish=Seleccione componentes - Text Italian=Selezionare i componenti - end - item: If/While Statement - Variable=DOBACKUP - Value=B - end - item: Set Control Attribute - Control Name=BACK3 - Operation=1 - end - item: Set Control Attribute - Control Name=BACK4 - Operation=1 - end - item: Else Statement - end - item: Set Control Attribute - Control Name=BACK3 - end - item: Set Control Attribute - Control Name=BACK4 - end - item: End Block - end - end - item: Dialog - Title=Select Destination Directory - Title French=Choisissez le répertoire de destination - Title German=Zielverzeichnis wählen - Title Portuguese=Seleccionar Directório de Destino - Title Spanish=Seleccione el Directorio de Destino - Title Italian=Seleziona Directory di destinazione - Title Danish=Vælg Destinationsbibliotek - Title Dutch=Kies Doeldirectory - Title Norwegian=Velg målkatalog - Title Swedish=Välj destinationskalatog - Width=276 - Height=216 - Font Name=Helv - Font Size=8 - item: Listbox - Rectangle=6 3 200 186 - Variable=BACKUP - Create Flags=01010000100000010000000101000000 - Flags=0000110000100010 - Text=%BACKUP% - Text= - Text French=%BACKUP% - Text French= - Text German=%BACKUP% - Text German= - Text Portuguese=%BACKUP% - Text Portuguese= - Text Spanish=%BACKUP% - Text Spanish= - Text Italian=%BACKUP% - Text Italian= - Text Danish=%BACKUP% - Text Danish= - Text Dutch=%BACKUP% - Text Dutch= - Text Norwegian=%BACKUP% - Text Norwegian= - Text Swedish=%BACKUP% - Text Swedish= - end - item: Push Button - Rectangle=209 8 265 26 - Create Flags=01010000000000010000000000000001 - Text=OK - Text French=OK - Text German=OK - Text Portuguese=OK - Text Spanish=ACEPTAR - Text Italian=OK - Text Danish=OK - Text Dutch=OK - Text Norwegian=OK - Text Swedish=OK - end - item: Push Button - Rectangle=209 31 265 50 - Variable=BACKUP - Value=%BACKUP_SAVE% - Create Flags=01010000000000010000000000000000 - Flags=0000000000000001 - Text=Cancel - Text French=Annuler - Text German=Abbrechen - Text Portuguese=Cancelar - Text Spanish=Cancelar - Text Italian=Annulla - Text Danish=Slet - Text Dutch=Annuleren - Text Norwegian=Avbryt - Text Swedish=Avbryt - end - end -end -item: Custom Dialog Set - Name=Select Components - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalación de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=131 234 188 253 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Text=< &Back - Text French=< &Retour - Text German=< &Zurück - Text Spanish=< &Atrás - Text Italian=< &Indietro - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Checkbox - Rectangle=108 66 313 156 - Variable=COMPONENTS - Create Flags=01010000000000010000000000000011 - Flags=0000000000000110 - Text=Python interpreter and libraries - Text=Tcl/Tk (Tkinter, IDLE, pydoc) - Text=Python HTMLHelp file - Text=Python utility scripts (Tools/) - Text=Python test suite (Lib/test/) - Text= - Text French=Python interpreter, library and IDLE - Text French=Python HTML docs - Text French=Python utility scripts (Tools/) - Text French=Python test suite (Lib/test/) - Text French= - Text German=Python interpreter, library and IDLE - Text German=Python HTML docs - Text German=Python utility scripts (Tools/) - Text German=Python test suite (Lib/test/) - Text German= - Text Spanish=Python interpreter, library and IDLE - Text Spanish=Python HTML docs - Text Spanish=Python utility scripts (Tools/) - Text Spanish=Python test suite (Lib/test/) - Text Spanish= - Text Italian=Python interpreter, library and IDLE - Text Italian=Python HTML docs - Text Italian=Python utility scripts (Tools/) - Text Italian=Python test suite (Lib/test/) - Text Italian= - end - item: Static - Rectangle=108 45 320 63 - Create Flags=01010000000000000000000000000000 - Text=Choose which components to install by checking the boxes below. - Text French=Choisissez les composants que vous voulez installer en cochant les cases ci-dessous. - Text German=Wählen Sie die zu installierenden Komponenten, indem Sie in die entsprechenden Kästchen klicken. - Text Spanish=Elija los componentes que desee instalar marcando los cuadros de abajo. - Text Italian=Scegliere quali componenti installare selezionando le caselle sottostanti. - end - item: Push Button - Rectangle=188 203 269 220 - Destination Dialog=1 - Action=2 - Enabled Color=00000000000000000000000011111111 - Create Flags=01010000000000010000000000000000 - Text=Advanced Options ... - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 10 323 43 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Select Components - Text French=Sélectionner les composants - Text German=Komponenten auswählen - Text Spanish=Seleccione componentes - Text Italian=Selezionare i componenti - end - item: Static - Rectangle=251 180 311 193 - Variable=COMPONENTS - Value=MAINDIR - Create Flags=01010000000000000000000000000010 - end - item: Static - Rectangle=251 168 311 179 - Variable=COMPONENTS - Create Flags=01010000000000000000000000000010 - end - item: Static - Rectangle=123 168 234 181 - Create Flags=01010000000000000000000000000000 - Text=Disk Space Required: - Text French=Espace disque requis : - Text German=Notwendiger Speicherplatz: - Text Spanish=Espacio requerido en el disco: - Text Italian=Spazio su disco necessario: - end - item: Static - Rectangle=123 180 234 193 - Create Flags=01010000000000000000000000000000 - Text=Disk Space Remaining: - Text French=Espace disque disponible : - Text German=Verbleibender Speicherplatz: - Text Spanish=Espacio en disco disponible: - Text Italian=Spazio su disco disponibile: - end - item: Static - Rectangle=108 158 320 196 - Action=1 - Create Flags=01010000000000000000000000000111 - end - item: If/While Statement - Variable=DLG_EVENT_TYPE - Value=VERIFY - end - item: Remark - Text=If they're installing Tcl/Tk, Tools, or the test suite, doesn't make much sense unless they're installing Python too. - end - item: If/While Statement - Variable=COMPONENTS - Value=BDE - Flags=00001010 - end - item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000011 - end - item: Display Message - Title=Are you sure? - Text=Installing Tcl/Tk, Tools or the test suite doesn't make much sense unless you install the Python interpreter and libraries too. - Text= - Text=Click Yes if that's really what you want. - Flags=00101101 - end - item: Remark - Text=Nothing -- just proceed to the next dialog. - end - item: Else Statement - end - item: Remark - Text=Return to the dialog. - end - item: Set Variable - Variable=DLG_EVENT_TYPE - end - item: End Block - end - item: End Block - end - item: End Block - end - item: End Block - end - end - item: Dialog - Title=Advanced Options - Width=339 - Height=213 - Font Name=Helv - Font Size=8 - item: Radio Button - Control Name=ADMIN2 - Rectangle=11 46 90 76 - Variable=SELECT_ADMIN - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000010000000000001001 - Text=Admin install - Text=Non-Admin installl - Text= - end - item: Push Button - Rectangle=188 170 244 189 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=OK - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Static - Rectangle=5 3 326 83 - Action=1 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000111 - end - item: Static - Control Name=ADMIN1 - Rectangle=11 11 321 45 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=By default, the install records settings in the per-machine area of the registry (HKLM), and installs the Python and C runtime DLLs to %SYS32%. Choose "Non-Admin install" if you would prefer settings made in the per-user registry (HKCU), and DLLs installed in %MAINDIR%. - end - item: Static - Rectangle=5 90 326 157 - Action=1 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000111 - end - item: Checkbox - Rectangle=11 121 243 151 - Variable=TASKS - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000010000000000000011 - Text=Register file extensions (.py, .pyw, .pyc, .pyo) - Text=Create Start Menu shortcuts - Text=Compile Python files to .pyc - Text= - end - item: Static - Rectangle=11 103 320 121 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=Choose tasks to perform by checking the boxes below. - end - item: If/While Statement - Variable=DLG_EVENT_TYPE - Value=INIT - end - item: If/While Statement - Variable=DOADMIN - Value=1 - end - item: Set Control Attribute - Control Name=ADMIN2 - end - item: Else Statement - end - item: Set Control Text - Control Name=ADMIN1 - Control Text=This section is available only if logged in to an account with Administrator privileges. - end - item: Set Control Attribute - Control Name=ADMIN2 - Operation=1 - end - item: End Block - end - item: End Block - end - end -end -item: Custom Dialog Set - Name=Select Program Manager Group - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalación de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=131 234 188 253 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Flags=0000000000000001 - Text=< &Back - Text French=< &Retour - Text German=< &Zurück - Text Spanish=< &Atrás - Text Italian=< &Indietro - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 10 323 53 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Select Start Menu Group - Text French=Sélectionner le groupe du Gestionnaire de programme - Text German=Bestimmung der Programm-Managergruppe - Text Spanish=Seleccione grupo del Administrador de programas - Text Italian=Selezionare il gruppo ProgMan - end - item: Static - Rectangle=108 35 320 65 - Create Flags=01010000000000000000000000000000 - Text=Enter the name of the Start Menu program group to which to add the %APPTITLE% icons: - Text French=Entrez le nom du groupe du Gestionnaire de programme dans lequel vous souhaitez ajouter les icônes de %APPTITLE% : - Text German=Geben Sie den Namen der Programmgruppe ein, der das Symbol %APPTITLE% hinzugefügt werden soll: - Text Spanish=Escriba el nombre del grupo del Administrador de programas en el que desea agregar los iconos de %APPTITLE%: - Text Italian=Inserire il nome del gruppo Program Manager per aggiungere le icone %APPTITLE% a: - end - item: Combobox - Rectangle=108 56 320 219 - Variable=GROUP - Create Flags=01010000001000010000001100000001 - Flags=0000000000000001 - Text=%GROUP% - Text= - Text French=%GROUP% - Text German=%GROUP% - Text Spanish=%GROUP% - Text Italian=%GROUP% - end - end -end -item: Custom Dialog Set - Name=Start Installation - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalación de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=131 234 188 253 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Text=< &Back - Text French=< &Retour - Text German=< &Zurück - Text Spanish=< &Atrás - Text Italian=< &Indietro - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 10 323 53 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Ready to Install! - Text French=Prêt à installer ! - Text German=Installationsbereit! - Text Spanish=¡Preparado para la instalación! - Text Italian=Pronto per l'installazione! - end - item: Static - Rectangle=108 40 320 62 - Create Flags=01010000000000000000000000000000 - Text=Click the Next button to install %APPTITLE%, or the Back button to change choices: - Text French=Vous êtes maintenant prêt à installer les fichiers %APPTITLE%. - Text French= - Text French=Cliquez sur le bouton Suite pour commencer l'installation ou sur le bouton Retour pour entrer les informations d'installation à nouveau. - Text German=Sie können %APPTITLE% nun installieren. - Text German= - Text German=Klicken Sie auf "Weiter", um mit der Installation zu beginnen. Klicken Sie auf "Zurück", um die Installationsinformationen neu einzugeben. - Text Spanish=Ya está listo para instalar %APPTITLE%. - Text Spanish= - Text Spanish=Presione el botón Siguiente para comenzar la instalación o presione Atrás para volver a ingresar la información para la instalación. - Text Italian=Ora è possibile installare %APPTITLE%. - Text Italian= - Text Italian=Premere il pulsante Avanti per avviare l'installazione o il pulsante Indietro per reinserire le informazioni di installazione. - end - item: Editbox - Rectangle=108 66 324 219 - Help Context=16711681 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000100000000001100011000100 - Text=%SUMMARY% - end - end -end -item: Remark -end -item: If/While Statement - Variable=DISPLAY - Value=Select Destination Directory -end -item: Remark - Text=User may have changed MAINDIR, so reset BACKUP to match. -end -item: Set Variable - Variable=BACKUP - Value=%MAINDIR%\BACKUP -end -item: End Block -end -item: Remark -end -item: End Block -end -item: Remark -end -item: Remark - Text=BEGIN WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark - Text=When the BACKUP feature is enabled, the BACKUPDIR is initialized -end -item: If/While Statement - Variable=DOBACKUP - Value=A -end -item: Set Variable - Variable=BACKUPDIR - Value=%BACKUP% -end -item: End Block -end -item: Remark - Text=The BRANDING information is written to the INI file on the installation media. -end -item: If/While Statement - Variable=BRANDING - Value=1 -end -item: If/While Statement - Variable=DOBRAND - Value=1 -end -item: Edit INI File - Pathname=%INST%\CUSTDATA.INI - Settings=[Registration] - Settings=NAME=%NAME% - Settings=COMPANY=%COMPANY% - Settings= -end -item: End Block -end -item: End Block -end -item: Remark - Text=Begin writing to the INSTALL.LOG -end -item: Open/Close INSTALL.LOG -end -item: Remark - Text=Check free disk space calculates free disk space as well as component sizes. -end -item: Remark - Text=It should be located before all Install File actions. -end -item: Check Disk Space - Component=COMPONENTS -end -item: Remark - Text=This include script allows uninstall support -end -item: Remark - Text=Note from Tim: this is our own Uninstal.wse, a copy of Wise's except -end -item: Remark - Text=it writes to HKCU (instead of HKLM) if the user doesn't have admin privs. -end -item: Include Script - Pathname=.\Uninstal.wse -end -item: Remark - Text=Note from Tim: these seeming no-ops actually convert to short filenames. -end -item: Set Variable - Variable=COMMON - Value=%COMMON% - Flags=00010100 -end -item: Set Variable - Variable=MAINDIR - Value=%MAINDIR% - Flags=00010100 -end -item: Remark - Text=This IF/THEN/ELSE reads the correct registry entries for shortcut/icon placement -end -item: Check Configuration - Flags=10111011 -end -item: Get Registry Key Value - Variable=STARTUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Start Menu\Programs\StartUp - Value Name=StartUp - Flags=00000010 -end -item: Get Registry Key Value - Variable=DESKTOPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Desktop - Value Name=Desktop - Flags=00000010 -end -item: Get Registry Key Value - Variable=STARTMENUDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Start Menu - Value Name=Start Menu - Flags=00000010 -end -item: Get Registry Key Value - Variable=GROUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Start Menu\Programs - Value Name=Programs - Flags=00000010 -end -item: Get Registry Key Value - Variable=CSTARTUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%STARTUPDIR% - Value Name=Common Startup - Flags=00000100 -end -item: Get Registry Key Value - Variable=CDESKTOPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%DESKTOPDIR% - Value Name=Common Desktop - Flags=00000100 -end -item: Get Registry Key Value - Variable=CSTARTMENUDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%STARTMENUDIR% - Value Name=Common Start Menu - Flags=00000100 -end -item: Get Registry Key Value - Variable=CGROUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%GROUPDIR% - Value Name=Common Programs - Flags=00000100 -end -item: Else Statement -end -item: Remark - Text=Note from Tim: the Wizard left this block empty! -end -item: Remark - Text=Perhaps it's only relevant on Windows 3.1. -end -item: End Block -end -item: Remark - Text=END WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark -end -item: If/While Statement - Variable=SELECT_ADMIN - Value=B -end -item: Remark - Text=The user chose a non-admin install in "Advanced Options". -end -item: Remark - Text=This should come after the include of Uninstal.wse above, because -end -item: Remark - Text=writing uninstall info to HKCU is ineffective except under Win2K. -end -item: Set Variable - Variable=DOADMIN - Value=0 -end -item: End Block -end -item: Remark -end -item: Set Variable - Variable=CGROUP_SAVE - Value=%GROUP% -end -item: If/While Statement - Variable=TASKS - Value=B - Flags=00000010 -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Set Variable - Variable=GROUP - Value=%CGROUPDIR%\%GROUP% -end -item: Else Statement -end -item: Set Variable - Variable=GROUP - Value=%GROUPDIR%\%GROUP% -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Long section to install files. -end -item: Remark -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Set Variable - Variable=DLLDEST - Value=%SYS32% -end -item: Else Statement -end -item: Set Variable - Variable=DLLDEST - Value=%MAINDIR% -end -item: End Block -end -item: Remark -end -item: Remark - Text=Install the license even if they deselect everything . -end -item: Install File - Source=..\license - Destination=%MAINDIR%\LICENSE.txt - Flags=0000000000000010 -end -item: Install File - Source=..\readme - Destination=%MAINDIR%\README.txt - Flags=0000000000000010 -end -item: Install File - Source=..\misc\news - Destination=%MAINDIR%\NEWS.txt - Flags=0000000000000010 -end -item: Remark - Text=Icons -- always install so that the uninstaller can use them for its own display. -end -item: Install File - Source=..\pc\pycon.ico - Destination=%MAINDIR%\pycon.ico - Flags=0000000010000010 -end -item: Install File - Source=..\pc\pyc.ico - Destination=%MAINDIR%\pyc.ico - Flags=0000000010000010 -end -item: Install File - Source=..\pc\py.ico - Destination=%MAINDIR%\py.ico - Flags=0000000010000010 -end -item: Remark -end -item: Remark - Text=These arrange to (recursively!) delete all .pyc and .pyo files at uninstall time. -end -item: Remark - Text=This "does the right thing": any directories left empty at the end are removed. -end -item: Add Text to INSTALL.LOG - Text=File Tree: %MAINDIR%\*.pyc -end -item: Add Text to INSTALL.LOG - Text=File Tree: %MAINDIR%\*.pyo -end -item: Remark -end -item: Remark - Text=A: interpreter and libraries -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: Remark - Text=Executables -end -item: Install File - Source=.\python.exe - Destination=%MAINDIR%\python.exe - Flags=0000000000000010 -end -item: Install File - Source=.\pythonw.exe - Destination=%MAINDIR%\pythonw.exe - Flags=0000000000000010 -end -item: Install File - Source=.\w9xpopen.exe - Destination=%MAINDIR%\w9xpopen.exe - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Extension module DLLs (.pyd); keep in synch with libs directory next -end -item: Install File - Source=.\_winreg.pyd - Destination=%MAINDIR%\DLLs\_winreg.pyd - Description=Extension modules - Flags=0000000000000010 -end -item: Install File - Source=.\_csv.pyd - Destination=%MAINDIR%\DLLs\_csv.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_sre.pyd - Destination=%MAINDIR%\DLLs\_sre.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_ssl.pyd - Destination=%MAINDIR%\DLLs\_ssl.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_symtable.pyd - Destination=%MAINDIR%\DLLs\_symtable.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_testcapi.pyd - Destination=%MAINDIR%\DLLs\_testcapi.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_tkinter.pyd - Destination=%MAINDIR%\DLLs\_tkinter.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_socket.pyd - Destination=%MAINDIR%\DLLs\_socket.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_bsddb.pyd - Destination=%MAINDIR%\DLLs\_bsddb.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\bz2.pyd - Destination=%MAINDIR%\DLLs\bz2.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\datetime.pyd - Destination=%MAINDIR%\DLLs\datetime.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\mmap.pyd - Destination=%MAINDIR%\DLLs\mmap.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\parser.pyd - Destination=%MAINDIR%\DLLs\parser.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\pyexpat.pyd - Destination=%MAINDIR%\DLLs\pyexpat.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\select.pyd - Destination=%MAINDIR%\DLLs\select.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\unicodedata.pyd - Destination=%MAINDIR%\DLLs\unicodedata.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\winsound.pyd - Destination=%MAINDIR%\DLLs\winsound.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\zlib.pyd - Destination=%MAINDIR%\DLLs\zlib.pyd - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Link libraries (.lib); keep in synch with DLLs above, except that the Python lib lives here. -end -item: Install File - Source=.\_winreg.lib - Destination=%MAINDIR%\libs\_winreg.lib - Description=Link library files - Flags=0000000000000010 -end -item: Install File - Source=.\_csv.lib - Destination=%MAINDIR%\libs\_csv.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_sre.lib - Destination=%MAINDIR%\libs\_sre.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_ssl.lib - Destination=%MAINDIR%\libs\_ssl.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_symtable.lib - Destination=%MAINDIR%\libs\_symtable.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_testcapi.lib - Destination=%MAINDIR%\libs\_testcapi.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_tkinter.lib - Destination=%MAINDIR%\libs\_tkinter.lib - Description=Extension modules - Flags=0000000000000010 -end -item: Install File - Source=.\_socket.lib - Destination=%MAINDIR%\libs\_socket.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_bsddb.lib - Destination=%MAINDIR%\libs\_bsddb.lib - Flags=0000000000000010 -end -item: Install File - Source=.\bz2.lib - Destination=%MAINDIR%\libs\bz2.lib - Flags=0000000000000010 -end -item: Install File - Source=.\datetime.lib - Destination=%MAINDIR%\libs\datetime.lib - Flags=0000000000000010 -end -item: Install File - Source=.\mmap.lib - Destination=%MAINDIR%\libs\mmap.lib - Flags=0000000000000010 -end -item: Install File - Source=.\parser.lib - Destination=%MAINDIR%\libs\parser.lib - Flags=0000000000000010 -end -item: Install File - Source=.\pyexpat.lib - Destination=%MAINDIR%\libs\pyexpat.lib - Flags=0000000000000010 -end -item: Install File - Source=.\select.lib - Destination=%MAINDIR%\libs\select.lib - Flags=0000000000000010 -end -item: Install File - Source=.\unicodedata.lib - Destination=%MAINDIR%\libs\unicodedata.lib - Flags=0000000000000010 -end -item: Install File - Source=.\winsound.lib - Destination=%MAINDIR%\libs\winsound.lib - Flags=0000000000000010 -end -item: Install File - Source=.\zlib.lib - Destination=%MAINDIR%\libs\zlib.lib - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=.\python%_pymajor_%%_pyminor_%.lib - Destination=%MAINDIR%\libs\python%_PYMAJOR_%%_PYMINOR_%.lib - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Main Python DLL -end -item: Remark - Text=Tell Wise it's OK to delete the Python DLL at uninstall time, -end -item: Remark - Text=despite that we (may) write it into a system directory. -end -item: Add Text to INSTALL.LOG - Text=Non-System File: -end -item: Install File - Source=.\python%_pymajor_%%_pyminor_%.dll - Destination=%DLLDEST%\python%_PYMAJOR_%%_PYMINOR_%.dll - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Libraries (Lib/) -end -item: Install File - Source=..\lib\*.py - Destination=%MAINDIR%\Lib - Description=Library Modules - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\bsddb\*.py - Destination=%MAINDIR%\Lib\bsddb - Description=Berkeley database package - Flags=0000000100000010 -end -item: Remark -end -item: Install File - Source=..\lib\compiler\*.py - Destination=%MAINDIR%\Lib\compiler - Description=Python compiler written in Python - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\distutils\*.py - Destination=%MAINDIR%\Lib\distutils - Description=Distribution utility modules - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\readme - Destination=%MAINDIR%\Lib\distutils\README.txt - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\command\*.py - Destination=%MAINDIR%\Lib\distutils\command - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\command\wininst.exe - Destination=%MAINDIR%\Lib\distutils\command\wininst.exe - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\command\command_template - Destination=%MAINDIR%\Lib\distutils\command\command_template - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\email\*.py - Destination=%MAINDIR%\Lib\email - Description=Library email package - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\*.py - Destination=%MAINDIR%\Lib\email\test - Description=email tests - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\data\*.txt - Destination=%MAINDIR%\Lib\email\test\data - Description=email test data - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\data\*.gif - Destination=%MAINDIR%\Lib\email\test\data - Description=email test data - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\data\*.au - Destination=%MAINDIR%\Lib\email\test\data - Description=email test data - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\encodings\*.py - Destination=%MAINDIR%\Lib\encodings - Description=Unicode encoding tables - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\hotshot\*.py - Destination=%MAINDIR%\Lib\hotshot - Description=Fast Python profiler - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\lib-old\*.py - Destination=%MAINDIR%\Lib\lib-old - Description=Obsolete modules - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\lib-tk\*.py - Destination=%MAINDIR%\Lib\lib-tk - Description=Tkinter related library modules - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\logging\*.py - Destination=%MAINDIR%\Lib\logging - Description=Logging package - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\site-packages\readme - Destination=%MAINDIR%\Lib\site-packages\README.txt - Description=Site packages - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\xml\*.py - Destination=%MAINDIR%\Lib\xml - Description=XML support packages - Flags=0000000000000010 -end -item: Install File - Source=..\lib\xml\dom\*.py - Destination=%MAINDIR%\Lib\xml\dom - Flags=0000000000000010 -end -item: Install File - Source=..\lib\xml\parsers\*.py - Destination=%MAINDIR%\Lib\xml\parsers - Flags=0000000000000010 -end -item: Install File - Source=..\lib\xml\sax\*.py - Destination=%MAINDIR%\Lib\xml\sax - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=C Include files -end -item: Install File - Source=..\include\*.h - Destination=%MAINDIR%\include - Description=Header files - Flags=0000000000000010 -end -item: Install File - Source=..\pc\pyconfig.h - Destination=%MAINDIR%\include\pyconfig.h - Description=Header files (pyconfig.h) - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Microsoft C runtime libraries -end -item: Install File - Source=%_SYS_%\MSVCIRT.DLL - Destination=%DLLDEST%\MSVCIRT.DLL - Description=Visual C++ Runtime DLLs - Flags=0000011000010011 -end -item: Install File - Source=%_SYS_%\MSVCRT.DLL - Destination=%DLLDEST%\MSVCRT.DLL - Description=Visual C++ Runtime DLLs - Flags=0000011000010011 -end -item: End Block -end -item: Remark -end -item: Remark - Text=B: Tcl/Tk (Tkinter, IDLE, pydoc) -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: Remark - Text=Tcl/Tk -end -item: Install File - Source=..\..\%_tcldir_%\bin\*.dll - Destination=%MAINDIR%\DLLs - Description=Tcl/Tk binaries and libraries - Flags=0000000000000010 -end -item: Install File - Source=..\..\%_tcldir_%\lib\*.* - Destination=%MAINDIR%\tcl - Description=Tcl/Tk binaries and libraries - Flags=0000000100000010 -end -item: Remark -end -item: Remark - Text=IDLE -end -item: Install File - Source=..\Lib\idlelib\*.py - Destination=%MAINDIR%\Lib\idlelib - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Lib\idlelib\*.txt - Destination=%MAINDIR%\Lib\idlelib - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Lib\idlelib\*.def - Destination=%MAINDIR%\Lib\idlelib - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Lib\idlelib\Icons\* - Destination=%MAINDIR%\Lib\idlelib\Icons - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Tools\scripts\idle - Destination=%MAINDIR%\Lib\idlelib\idle.pyw - Description=IDLE bootstrap script - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Windows pydoc driver -end -item: Install File - Source=..\tools\scripts\*.pyw - Destination=%MAINDIR%\Tools\Scripts - Description=Windows pydoc driver - Flags=0000000000000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=C: docs -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: Install File - Source=%_DOC_%\Python%_PYMAJOR_%%_PYMINOR_%.chm - Destination=%MAINDIR%\Doc\Python%_PYMAJOR_%%_PYMINOR_%.chm - Description=Python Documentation (HTMLHelp) - Flags=0000000000000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=D: tools -end -item: If/While Statement - Variable=COMPONENTS - Value=D - Flags=00000010 -end -item: Install File - Source=..\tools\scripts\*.py - Destination=%MAINDIR%\Tools\Scripts - Description=Utility Scripts - Flags=0000000000000010 -end -item: Install File - Source=..\tools\scripts\*.doc - Destination=%MAINDIR%\Tools\Scripts - Description=Utility Scripts - Flags=0000000000000010 -end -item: Install File - Source=..\tools\scripts\readme - Destination=%MAINDIR%\Tools\Scripts\README.txt - Description=Utility Scripts - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\tools\webchecker\*.py - Destination=%MAINDIR%\Tools\webchecker - Description=Web checker tool - Flags=0000000000000010 -end -item: Install File - Source=..\tools\webchecker\readme - Destination=%MAINDIR%\Tools\webchecker\README.txt - Description=Web checker tool - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\tools\versioncheck\*.py - Destination=%MAINDIR%\Tools\versioncheck - Description=Version checker tool - Flags=0000000000000010 -end -item: Install File - Source=..\tools\versioncheck\readme - Destination=%MAINDIR%\Tools\versioncheck\README.txt - Description=Version checker tool - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\tools\pynche\*.py - Destination=%MAINDIR%\Tools\pynche - Description=pynche color editor - Flags=0000000000000010 -end -item: Install File - Source=..\tools\pynche\*.txt - Destination=%MAINDIR%\Tools\pynche - Description=pynche color editor - Flags=0000000000000010 -end -item: Install File - Source=..\tools\pynche\x\*.txt - Destination=%MAINDIR%\Tools\pynche\X - Description=pynche color editor - X files - Flags=0000000000000010 -end -item: Install File - Source=..\tools\pynche\readme - Destination=%MAINDIR%\Tools\pynche\README.txt - Description=pynche color editor - README - Flags=0000000100000010 -end -item: Install File - Source=..\tools\pynche\pynche - Destination=%MAINDIR%\Tools\pynche\pynche.py - Description=pynche color editor - main - Flags=0000000100000010 -end -item: Install File - Source=..\tools\pynche\pynche.pyw - Destination=%MAINDIR%\Tools\pynche\pynche.pyw - Description=pynche color editor - noconsole main - Flags=0000000100000010 -end -item: Remark -end -item: Install File - Source=..\tools\i18n\*.py - Destination=%MAINDIR%\Tools\i18n - Description=Internationalization helpers - Flags=0000000000000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=E: test suite -end -item: If/While Statement - Variable=COMPONENTS - Value=E - Flags=00000010 -end -item: Install File - Source=..\lib\test\audiotest.au - Destination=%MAINDIR%\Lib\test\audiotest.au - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.uue - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.py - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.xml - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.out - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.bz2 - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.tar - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.gz - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.txt - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\test\output\*.* - Destination=%MAINDIR%\Lib\test\output - Description=Python Test output files - Flags=0000000000000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=DONE with file copying. -end -item: Remark - Text=The rest is registry and Start Menu fiddling. -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: If/While Statement - Variable=TASKS - Value=A - Flags=00000010 -end -item: Remark - Text=Register file extensions. As usual, Admin privs get in the way, but with a twist: -end -item: Remark - Text=You don't need admin privs to write to HKEY_CLASSES_ROOT *except* under Win2K. -end -item: Remark - Text=On Win2K, a user without Admin privs has to register extensions under HKCU\Software\CLASSES instead. -end -item: Remark - Text=But while you can *do* that under other flavors of Windows too, it has no useful effect except in Win2K. -end -item: Set Variable - Variable=USE_HKCR - Value=1 -end -item: Check Configuration - Flags=11110010 -end -item: If/While Statement - Variable=DOADMIN - Value=0 -end -item: Set Variable - Variable=USE_HKCR - Value=0 -end -item: End Block -end -item: End Block -end -item: If/While Statement - Variable=USE_HKCR - Value=1 -end -item: Remark - Text=File types. -end -item: Edit Registry - Total Keys=1 - Key=Python.File - New Value=Python File -end -item: Edit Registry - Total Keys=1 - Key=Python.File\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* -end -item: Edit Registry - Total Keys=1 - Key=Python.File\DefaultIcon - New Value=%MAINDIR%\Py.ico -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile - New Value=Python File (no console) -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile\shell\open\command - New Value=%MAINDIR%\pythonw.exe "%%1" %%* -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile\DefaultIcon - New Value=%MAINDIR%\Py.ico -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Python.CompiledFile - New Value=Compiled Python File -end -item: Edit Registry - Total Keys=1 - Key=Python.CompiledFile\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* -end -item: Edit Registry - Total Keys=1 - Key=Python.CompiledFile\DefaultIcon - New Value=%MAINDIR%\pyc.ico -end -item: Remark -end -item: Remark - Text=File extensions. -end -item: Edit Registry - Total Keys=1 - Key=.py - New Value=Python.File -end -item: Edit Registry - Total Keys=1 - Key=.py - New Value=text/plain - Value Name=Content Type -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=.pyw - New Value=Python.NoConFile -end -item: Edit Registry - Total Keys=1 - Key=.pyw - New Value=text/plain - Value Name=Content Type -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=.pyc - New Value=Python.CompiledFile -end -item: Edit Registry - Total Keys=1 - Key=.pyo - New Value=Python.CompiledFile -end -item: Else Statement -end -item: Remark - Text=File types. -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File - New Value=Python File - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File\DefaultIcon - New Value=%MAINDIR%\Py.ico - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile - New Value=Python File (no console) - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile\shell\open\command - New Value=%MAINDIR%\pythonw.exe "%%1" %%* - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile\DefaultIcon - New Value=%MAINDIR%\Py.ico - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.CompiledFile - New Value=Compiled Python File - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.CompiledFile\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.CompiledFile\DefaultIcon - New Value=%MAINDIR%\pyc.ico - Root=1 -end -item: Remark -end -item: Remark - Text=File extensions. -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.py - New Value=Python.File - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.py - New Value=text/plain - Value Name=Content Type - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyw - New Value=Python.NoConFile - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyw - New Value=text/plain - Value Name=Content Type - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyc - New Value=Python.CompiledFile - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyo - New Value=Python.CompiledFile - Root=1 -end -item: End Block -end -item: Remark -end -item: Remark - Text=If we're installing IDLE, also set an Edit context menu action to use IDLE, for .py and .pyw files. -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: If/While Statement - Variable=USE_HKCR - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" -end -item: Edit Registry - Total Keys=1 - Key=Python.File\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" - Root=1 -end -item: End Block -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Register Python paths. -end -item: Remark - Text=Write to HKLM for admin, else HKCU. Keep these blocks otherwise identical! -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\CurrentVersion - Root=130 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath - New Value=%MAINDIR% - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath\InstallGroup - New Value=%CGROUP_SAVE% - New Value= - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\PythonPath - New Value=%MAINDIR%\Lib;%MAINDIR%\DLLs;%MAINDIR%\Lib\lib-tk - New Value= - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Modules - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe - New Value=%MAINDIR%\Python.exe - Root=2 -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\CurrentVersion - Root=129 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath - New Value=%MAINDIR% - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath\InstallGroup - New Value=%CGROUP_SAVE% - New Value= - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\PythonPath - New Value=%MAINDIR%\Lib;%MAINDIR%\DLLs;%MAINDIR%\Lib\lib-tk - New Value= - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Modules - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe - New Value=%MAINDIR%\Python.exe - Root=1 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Registry fiddling for docs. -end -item: Remark - Text=Write to HKLM for admin, else HKCU. Keep these blocks otherwise identical! -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Help\Main Python Documentation - New Value=%MAINDIR%\Doc\Python%_PYMAJOR_%%_PYMINOR_%.chm - New Value= - Root=2 -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Help\Main Python Documentation - New Value=%MAINDIR%\Doc\Python%_PYMAJOR_%%_PYMINOR_%.chm - New Value= - Root=1 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Set the app publisher and URL entries for Win2K add/remove. -end -item: Remark - Text=It doesn't hurt on other systems. -end -item: Remark - Text=As usual, write to HKLM or HKCU depending on Admin privs. -end -item: Remark - Text=CAUTION: If you set this info on the "Windows 2000" page (step 6) of the -end -item: Remark - Text=Installation Expert, it only shows up in the "If" block below. Keep in synch! -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=HelpLink - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=PythonLabs at Zope Corporation - Value Name=Publisher - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=URLInfoAbout - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%PYVER_STRING% - Value Name=DisplayVersion - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%MAINDIR%\py.ico,-0 - Value Name=DisplayIcon - Root=2 -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=HelpLink - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=PythonLabs at Zope Corporation - Value Name=Publisher - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=URLInfoAbout - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%PYVER_STRING% - Value Name=DisplayVersion - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%MAINDIR%\py.ico,-0 - Value Name=DisplayIcon - Root=1 -end -item: End Block -end -item: Remark -end -item: Remark - Text=Populate Start Menu group -end -item: If/While Statement - Variable=TASKS - Value=B - Flags=00000010 -end -item: Remark - Text=Shortcut to installer no matter what. -end -item: Create Shortcut - Source=%MAINDIR%\unwise.exe - Destination=%GROUP%\Uninstall Python.lnk - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: Create Shortcut - Source=%MAINDIR%\python.exe - Destination=%GROUP%\Python (command line).lnk - Working Directory=%MAINDIR% - Icon Pathname=%MAINDIR%\pycon.ico - Key Type=1536 - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: Create Shortcut - Source=%MAINDIR%\pythonw.exe - Destination=%GROUP%\IDLE (Python GUI).lnk - Command Options="%MAINDIR%\Lib\idlelib\idle.pyw" - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: Create Shortcut - Source=%MAINDIR%\pythonw.exe - Destination=%GROUP%\Module Docs.lnk - Command Options="%MAINDIR%\Tools\Scripts\pydocgui.pyw" - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: Create Shortcut - Source=%MAINDIR%\Doc\Python%_PYMAJOR_%%_PYMINOR_%.chm - Destination=%GROUP%\Python Manuals.lnk - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=I don't think we need this, but have always done it. -end -item: Self-Register OCXs/DLLs - Description=Updating System Configuration, Please Wait... -end -item: Remark -end -item: Remark - Text=Compile to .pyc -end -item: If/While Statement - Variable=TASKS - Value=C - Flags=00000010 -end -item: Execute Program - Pathname=%MAINDIR%\Python.exe - Command Line=%MAINDIR%\Lib\compileall.py -f -x .*\\Lib\\test.* %MAINDIR%\Lib - Default Directory=%MAINDIR%\Lib - Flags=00000010 -end -item: End Block -end -item: Remark -end -remarked item: Remark - Text=Don't enable "Delete in-use files". Here's what happens: -end -remarked item: Remark - Text=Install Python; uninstall Python; install Python again. Reboot the machine. -end -remarked item: Remark - Text=Now UNWISE.EXE is missing. I think this is a Wise bug, but so it goes. -end -remarked item: Add Text to INSTALL.LOG - Text=Delete in-use files: On -end -item: Remark -end -item: Wizard Block - Direction Variable=DIRECTION - Display Variable=DISPLAY - Bitmap Pathname=.\installer.bmp - X Position=9 - Y Position=10 - Filler Color=11173759 - Flags=00000011 -end -item: Custom Dialog Set - Name=Finished - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalación de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Finish - Text French=&Fin - Text German=&Weiter - Text Spanish=&Terminar - Text Italian=&Fine - end - item: Push Button - Rectangle=264 234 320 253 - Variable=DISABLED - Value=! - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=108 10 323 48 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Installation Completed! - Text French=Installation terminée ! - Text German=Die Installation ist abgeschlossen! - Text Spanish=¡Instalación terminada! - Text Italian=Installazione completata! - end - item: Static - Rectangle=108 44 320 82 - Create Flags=01010000000000000000000000000000 - Text=%APPTITLE% has been successfully installed. - Text= - Text=Press the Finish button to exit this installation. - Text French=%APPTITLE% est maintenant installé. - Text French= - Text French=Cliquez sur le bouton Fin pour quitter l'installation. - Text German=%APPTITLE% wurde erfolgreich installiert. - Text German= - Text German=Klicken Sie auf "Weiter", um die Installation zu beenden. - Text Spanish=%APPTITLE% se ha instalado con éxito. - Text Spanish= - Text Spanish=Presione el botón Terminar para salir de esta instalación. - Text Italian=L'installazione %APPTITLE% è stata portata a termine con successo. - Text Italian= - Text Italian=Premere il pulsante Fine per uscire dall'installazione. - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=106 105 312 210 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=Special Windows thanks to: - Text= - Text= - Text=LettError, Erik van Blokland, for the Python for Windows graphic. - Text= http://www.letterror.com/ - Text= - Text= - Text=Mark Hammond, without whose years of freely shared Windows expertise, Python for Windows would still be Python for DOS. - end - item: Static - Rectangle=106 95 312 96 - Action=3 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000001001 - end - end -end -item: End Block -end -item: New Event - Name=Cancel -end -item: Remark - Text=This include script supports a rollback to preinstallation state if the user chooses to cancel before the installation is complete. -end -item: Include Script - Pathname=%_WISE_%\INCLUDE\rollback.wse -end diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore.dsp deleted file mode 100644 index 4867ca79..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore.dsp +++ /dev/null @@ -1,592 +0,0 @@ -# Microsoft Developer Studio Project File - Name="pythoncore" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=pythoncore - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pythoncore.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pythoncore.mak" CFG="pythoncore - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pythoncore - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "pythoncore - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pythoncore - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\pythoncore" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "../Include" /I "../PC" /I "../Python" /I "../Modules" /I "../../StaticSDKs/XPlatform/zlib" /I "../../../../Sources/Plasma/FeatureLib/pfPython" /I "../../../../Sources/Plasma/CoreLib" /I "../../../../Sources/Plasma/PubUtilLib/plFile" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_DL_EXPORT" /YX /FD /Zm200 /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\Include" /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 largeint.lib kernel32.lib user32.lib advapi32.lib shell32.lib /nologo /base:"0x1e000000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./cypython23.dll" -# SUBTRACT LINK32 /pdb:none -# Begin Special Build Tool -TargetPath=.\cypython23.dll -SOURCE="$(InputPath)" -PostBuild_Cmds=xcopy /Y $(TargetPath) ..\..\..\..\test\ -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pythoncore - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\pythoncore" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "../Include" /I "../PC" /I "../Python" /I "../Modules" /I "../../StaticSDKs/XPlatform/zlib" /I "../../../../Sources/Plasma/FeatureLib/pfPython" /I "../../../../Sources/Plasma/CoreLib" /I "../../../../Sources/Plasma/PubUtilLib/plFile" /D "_DEBUG" /D "USE_DL_EXPORT" /D "WIN32" /D "_WINDOWS" /FD /Zm200 /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\Include" /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 largeint.lib kernel32.lib user32.lib advapi32.lib shell32.lib /nologo /base:"0x1e000000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./cypython23_d.dll" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none -# Begin Special Build Tool -TargetPath=.\cypython23_d.dll -SOURCE="$(InputPath)" -PostBuild_Cmds=xcopy /Y $(TargetPath) ..\..\..\..\test\ -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "pythoncore - Win32 Release" -# Name "pythoncore - Win32 Debug" -# Begin Group "header files" - -# PROP Default_Filter ".h" -# End Group -# Begin Group "source files" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\Modules\_codecsmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\_hotshot.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\_localemodule.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\_randommodule.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\_weakref.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\abstract.c -# End Source File -# Begin Source File - -SOURCE=..\Parser\acceler.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\arraymodule.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\audioop.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\binascii.c -# End Source File -# Begin Source File - -SOURCE=..\Parser\bitset.c -# End Source File -# Begin Source File - -SOURCE=..\Python\bltinmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\boolobject.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\bufferobject.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\cellobject.c -# End Source File -# Begin Source File - -SOURCE=..\Python\ceval.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\classobject.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\cmathmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\cobject.c -# End Source File -# Begin Source File - -SOURCE=..\Python\codecs.c -# End Source File -# Begin Source File - -SOURCE=..\Python\compile.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\complexobject.c -# End Source File -# Begin Source File - -SOURCE=..\PC\config.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\cPickle.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\cStringIO.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\descrobject.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\dictobject.c -# End Source File -# Begin Source File - -SOURCE=..\PC\dl_nt.c -# End Source File -# Begin Source File - -SOURCE=..\Python\dynload_win.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\enumobject.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\errnomodule.c -# End Source File -# Begin Source File - -SOURCE=..\Python\errors.c -# End Source File -# Begin Source File - -SOURCE=..\Python\exceptions.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\fileobject.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\floatobject.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\frameobject.c -# End Source File -# Begin Source File - -SOURCE=..\Python\frozen.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\funcobject.c -# End Source File -# Begin Source File - -SOURCE=..\Python\future.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\gcmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Python\getargs.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\getbuildinfo.c -# ADD CPP /D BUILD=51 -# End Source File -# Begin Source File - -SOURCE=..\Python\getcompiler.c -# End Source File -# Begin Source File - -SOURCE=..\Python\getcopyright.c -# End Source File -# Begin Source File - -SOURCE=..\Python\getmtime.c -# End Source File -# Begin Source File - -SOURCE=..\Python\getopt.c -# End Source File -# Begin Source File - -SOURCE=..\PC\getpathp.c -# End Source File -# Begin Source File - -SOURCE=..\Python\getplatform.c -# End Source File -# Begin Source File - -SOURCE=..\Python\getversion.c -# End Source File -# Begin Source File - -SOURCE=..\Python\graminit.c -# End Source File -# Begin Source File - -SOURCE=..\Parser\grammar1.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\imageop.c -# End Source File -# Begin Source File - -SOURCE=..\Python\import.c -# End Source File -# Begin Source File - -SOURCE=..\PC\import_nt.c -# ADD CPP /I "..\Python" -# End Source File -# Begin Source File - -SOURCE=..\Python\importdl.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\intobject.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\iterobject.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\itertoolsmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Parser\listnode.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\listobject.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\longobject.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\main.c -# End Source File -# Begin Source File - -SOURCE=..\Python\marshal.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\mathmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\md5c.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\md5module.c -# End Source File -# Begin Source File - -SOURCE=..\Parser\metagrammar.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\methodobject.c -# End Source File -# Begin Source File - -SOURCE=..\Python\modsupport.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\moduleobject.c -# End Source File -# Begin Source File - -SOURCE=..\PC\msvcrtmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Parser\myreadline.c -# End Source File -# Begin Source File - -SOURCE=..\Python\mysnprintf.c -# End Source File -# Begin Source File - -SOURCE=..\Python\mystrtoul.c -# End Source File -# Begin Source File - -SOURCE=..\Parser\node.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\object.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\obmalloc.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\operator.c -# End Source File -# Begin Source File - -SOURCE=..\Parser\parser.c -# End Source File -# Begin Source File - -SOURCE=..\Parser\parsetok.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\pcremodule.c -# End Source File -# Begin Source File - -SOURCE=..\PC\PlasmaPack.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\Sources\Plasma\PubUtilLib\plFile\plEncryptedStream.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\Sources\Plasma\FeatureLib\pfPython\plPythonPack.cpp -# End Source File -# Begin Source File - -SOURCE=..\Modules\posixmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Python\pyfpe.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\pypcre.c -# End Source File -# Begin Source File - -SOURCE=..\Python\pystate.c -# End Source File -# Begin Source File - -SOURCE=..\PC\python_nt.rc -# End Source File -# Begin Source File - -SOURCE=..\Python\pythonrun.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\rangeobject.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\regexmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\regexpr.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\rgbimgmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\rotormodule.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\shamodule.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\signalmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\sliceobject.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\stringobject.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\stropmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Python\structmember.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\structmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\structseq.c -# End Source File -# Begin Source File - -SOURCE=..\Python\symtable.c -# End Source File -# Begin Source File - -SOURCE=..\Python\sysmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Python\thread.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\threadmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\timemodule.c -# End Source File -# Begin Source File - -SOURCE=..\Parser\tokenizer.c -# End Source File -# Begin Source File - -SOURCE=..\Python\traceback.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\tupleobject.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\typeobject.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\unicodectype.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\unicodeobject.c -# End Source File -# Begin Source File - -SOURCE=..\Objects\weakrefobject.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\xreadlinesmodule.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\xxsubtype.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\yuvconvert.c -# End Source File -# Begin Source File - -SOURCE=..\Modules\zipimport.c -# End Source File -# End Group -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore.vcproj b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore.vcproj deleted file mode 100644 index 49d54a5e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore.vcproj +++ /dev/null @@ -1,2427 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore_dyn_server.vcproj b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore_dyn_server.vcproj deleted file mode 100644 index e5d7f5f8..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore_dyn_server.vcproj +++ /dev/null @@ -1,4337 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore_static.vcproj b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore_static.vcproj deleted file mode 100644 index 8b6671df..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythoncore_static.vcproj +++ /dev/null @@ -1,549 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythonw.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythonw.dsp deleted file mode 100644 index ee3750e2..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/pythonw.dsp +++ /dev/null @@ -1,101 +0,0 @@ -# Microsoft Developer Studio Project File - Name="pythonw" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=pythonw - Win32 Alpha Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pythonw.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pythonw.mak" CFG="pythonw - Win32 Alpha Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pythonw - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "pythonw - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pythonw - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\pythonw" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d000000" /subsystem:windows /debug /machine:I386 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "pythonw - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\pythonw" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1d000000" /subsystem:windows /debug /machine:I386 /out:"./pythonw_d.exe" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "pythonw - Win32 Release" -# Name "pythonw - Win32 Debug" -# Begin Source File - -SOURCE=..\PC\python_exe.rc -# End Source File -# Begin Source File - -SOURCE=..\PC\WinMain.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/readme.txt b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/readme.txt deleted file mode 100644 index a3518244..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/readme.txt +++ /dev/null @@ -1,314 +0,0 @@ -Building Python using VC++ 6.0 or 5.0 -------------------------------------- -This directory is used to build Python for Win32 platforms, e.g. Windows -95, 98 and NT. It requires Microsoft Visual C++ 6.x or 5.x. -(For other Windows platforms and compilers, see ../PC/readme.txt.) - -All you need to do is open the workspace "pcbuild.dsw" in MSVC++, select -the Debug or Release setting (using Build -> Set Active Configuration...), -and build the projects. - -The proper order to build subprojects: - -1) pythoncore (this builds the main Python DLL and library files, - python21.{dll, lib} in Release mode) - NOTE: in previous releases, this subproject was - named after the release number, e.g. python20. - -2) python (this builds the main Python executable, - python.exe in Release mode) - -3) the other subprojects, as desired or needed (note: you probably don't - want to build most of the other subprojects, unless you're building an - entire Python distribution from scratch, or specifically making changes - to the subsystems they implement; see SUBPROJECTS below) - -When using the Debug setting, the output files have a _d added to -their name: python21_d.dll, python_d.exe, parser_d.pyd, and so on. - -SUBPROJECTS ------------ -These subprojects should build out of the box. Subprojects other than the -main ones (pythoncore, python, pythonw) generally build a DLL (renamed to -.pyd) from a specific module so that users don't have to load the code -supporting that module unless they import the module. - -pythoncore - .dll and .lib -python - .exe -pythonw - pythonw.exe, a variant of python.exe that doesn't pop up a DOS box -_csv - C support for the comma-separated values module -_socket - socketmodule.c -_sre - Unicode-aware regular expression engine -_symtable - the _symtable module, symtablemodule.c -_testcapi - tests of the Python C API, run via Lib/test/test_capi.py, and - implemented by module Modules/_testcapimodule.c -datetime - datetimemodule.c -mmap - mmapmodule.c -parser - the parser module -pyexpat - Python wrapper for accelerated XML parsing, which incorporates stable - code from the Expat project: http://sourceforge.net/projects/expat/ -select - selectmodule.c -unicodedata - large tables of Unicode data -winreg - Windows registry API -winsound - play sounds (typically .wav files) under Windows - -The following subprojects will generally NOT build out of the box. They -wrap code Python doesn't control, and you'll need to download the base -packages first and unpack them into siblings of PCbuilds's parent -directory; for example, if your PCbuild is .......\dist\src\PCbuild\, -unpack into new subdirectories of dist\. - -_tkinter - Python wrapper for the Tk windowing system. Requires building - Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.3: - - Get source - ---------- - Go to - http://prdownloads.sourceforge.net/tcl/ - and download - tcl843-src.zip - tk843-src.zip - Unzip into - dist\tcl8.4.3\ - dist\tk8.4.3\ - respectively. - - Build Tcl first (done here w/ MSVC 6 on Win98SE) - --------------- - cd dist\tcl8.4.3\win - run vcvars32.bat [necessary even on Win2K] - nmake -f makefile.vc - nmake -f makefile.vc INSTALLDIR=..\..\tcl84 install - - XXX Should we compile with OPTS=threads? - - XXX Some tests failed in "nmake -f makefile.vc test". - XXX all.tcl: Total 10480 Passed 9743 Skipped 719 Failed 18 - XXX - XXX That was on Win98SE. On Win2K: - XXX all.tcl Total 10480 Passed 9781 Skipped 698 Failed 1 - - Build Tk - -------- - cd dist\tk8.4.3\win - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.3 - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.3 INSTALLDIR=..\..\tcl84 install - - XXX Should we compile with OPTS=threads? - - XXX I have no idea whether "nmake -f makefile.vc test" passed or - XXX failed. It popped up tons of little windows, and did lots of - XXX stuff, and nothing blew up. - - XXX Our installer copies a lot of stuff out of the Tcl/Tk install - XXX directory. Is all of that really needed for Python use of Tcl/Tk? - - Make sure the installer matches - ------------------------------- - Ensure that the Wise compiler vrbl _TCLDIR_ is set to the name of - the common Tcl/Tk installation directory (tcl84 for the instructions - above). This is needed so the installer can copy various Tcl/Tk - files into the Python distribution. - - -zlib - Python wrapper for the zlib compression library. Get the source code - for version 1.1.4 from a convenient mirror at: - http://www.gzip.org/zlib/ - Unpack into dist\zlib-1.1.4. - A custom pre-link step in the zlib project settings should manage to - build zlib-1.1.4\zlib.lib by magic before zlib.pyd (or zlib_d.pyd) is - linked in PCbuild\. - However, the zlib project is not smart enough to remove anything under - zlib-1.1.4\ when you do a clean, so if you want to rebuild zlib.lib - you need to clean up zlib-1.1.4\ by hand. - -bz2 - Python wrapper for the libbz2 compression library. Homepage - http://sources.redhat.com/bzip2/ - Download the source tarball, bzip2-1.0.2.tar.gz. - Unpack into dist\bzip2-1.0.2. WARNING: If you're using WinZip, you - must disable its "TAR file smart CR/LF conversion" feature (under - Options -> Configuration -> Miscellaneous -> Other) for the duration. - - Don't bother trying to use libbz2.dsp with MSVC. After 10 minutes - of fiddling, I couldn't get it to work. Perhaps it works with - MSVC 5 (I used MSVC 6). It's better to run the by-hand makefile - anyway, because it runs a helpful test step at the end. - - cd into dist\bzip2-1.0.2, and run - nmake -f makefile.msc - [Note that if you're running Win9X, you'll need to run vcvars32.bat - before running nmake (this batch file is in your MSVC installation). - TODO: make this work like zlib (in particular, MSVC runs the prelink - step in an enviroment that already has the correct envars set up). - ] - The make step shouldn't yield any warnings or errors, and should end - by displaying 6 blocks each terminated with - FC: no differences encountered - If FC finds differences, see the warning abou WinZip above (when I - first tried it, sample3.ref failed due to CRLF conversion). - - All of this managed to build bzip2-1.0.2\libbz2.lib, which the Python - project links in. - - -_bsddb - Go to Sleepycat's download page: - http://www.sleepycat.com/download/ - - and download version 4.1.25. The file name is db-4.1.25.NC.zip. - XXX with or without strong cryptography? I picked "without". - - Unpack into - dist\db-4.1.25 - - [If using WinZip to unpack the db-4.1.25.NC distro, that requires - renaming the directory (to remove ".NC") after unpacking. - ] - - Open - dist\db-4.1.25\docs\index.html - - and follow the Windows instructions for building the Sleepycat - software. Note that Berkeley_DB.dsw is in the build_win32 subdirectory. - Build the Release version ("build_all -- Win32 Release"). - - XXX We're actually linking against Release_static\libdb41s.lib. - XXX This yields the following warnings: -""" -Compiling... -_bsddb.c -Linking... - Creating library ./_bsddb.lib and object ./_bsddb.exp -LINK : warning LNK4049: locally defined symbol "_malloc" imported -LINK : warning LNK4049: locally defined symbol "_free" imported -LINK : warning LNK4049: locally defined symbol "_fclose" imported -LINK : warning LNK4049: locally defined symbol "_fopen" imported -_bsddb.pyd - 0 error(s), 4 warning(s) -""" - XXX This isn't encouraging, but I don't know what to do about it. - - To run extensive tests, pass "-u bsddb" to regrtest.py. test_bsddb3.py - is then enabled. Running in verbose mode may be helpful. - - XXX The test_bsddb3 tests don't always pass, on Windows (according to - XXX me) or on Linux (according to Barry). I had much better luck - XXX on Win2K than on Win98SE. The common failure mode across platforms - XXX is - XXX DBAgainError: (11, 'Resource temporarily unavailable -- unable - XXX to join the environment') - XXX - XXX and it appears timing-dependent. On Win2K I also saw this once: - XXX - XXX test02_SimpleLocks (bsddb.test.test_thread.HashSimpleThreaded) ... - XXX Exception in thread reader 1: - XXX Traceback (most recent call last): - XXX File "C:\Code\python\lib\threading.py", line 411, in __bootstrap - XXX self.run() - XXX File "C:\Code\python\lib\threading.py", line 399, in run - XXX apply(self.__target, self.__args, self.__kwargs) - XXX File "C:\Code\python\lib\bsddb\test\test_thread.py", line 268, in - XXX readerThread - XXX rec = c.next() - XXX DBLockDeadlockError: (-30996, 'DB_LOCK_DEADLOCK: Locker killed - XXX to resolve a deadlock') - XXX - XXX I'm told that DBLockDeadlockError is expected at times. It - XXX doesn't cause a test to fail when it happens (exceptions in - XXX threads are invisible to unittest). - - -_ssl - Python wrapper for the secure sockets library. - - Get the latest source code for OpenSSL from - http://www.openssl.org - - You (probably) don't want the "engine" code. For example, get - openssl-0.9.7b.tar.gz - not - openssl-engine-0.9.7b.tar.gz - - Unpack into the "dist" directory, retaining the folder name from - the archive - for example, the latest stable OpenSSL will install as - dist/openssl-0.9.7b - - You can (theoretically) use any version of OpenSSL you like - the - build process will automatically select the latest version. - - You must also install ActivePerl from - http://www.activestate.com/Products/ActivePerl/ - as this is used by the OpenSSL build process. Complain to them . - - The MSVC project simply invokes PCBuild/build_ssl.py to perform - the build. This Python script locates and builds your OpenSSL - installation, then invokes a simple makefile to build the final .pyd. - - Win9x users: see "Win9x note" below. - - build_ssl.py attempts to catch the most common errors (such as not - being able to find OpenSSL sources, or not being able to find a Perl - that works with OpenSSL) and give a reasonable error message. - If you have a problem that doesn't seem to be handled correctly - (eg, you know you have ActivePerl but we can't find it), please take - a peek at build_ssl.py and suggest patches. Note that build_ssl.py - should be able to be run directly from the command-line. - - build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do - this by hand. - - Win9x note: If, near the start of the build process, you see - something like - - C:\Code\openssl-0.9.7b>set OPTS=no-asm - Out of environment space - - then you're in trouble, and will probably also see these errors near - the end of the process: - - NMAKE : fatal error U1073: don't know how to make - 'crypto\md5\asm\m5_win32.asm' - Stop. - NMAKE : fatal error U1073: don't know how to make - 'C:\Code\openssl-0.9.7b/out32/libeay32.lib' - Stop. - - You need more environment space. Win9x only has room for 256 bytes - by default, and especially after installing ActivePerl (which fiddles - the PATH envar), you're likely to run out. KB Q230205 - - http://support.microsoft.com/default.aspx?scid=KB;en-us;q230205 - - explains how to edit CONFIG.SYS to cure this. - - -YOUR OWN EXTENSION DLLs ------------------------ -If you want to create your own extension module DLL, there's an example -with easy-to-follow instructions in ../PC/example/; read the file -readme.txt there first. - -HTML Help ---------- - -The compiled HTML help file is built from the HTML pages by the script -Doc/tools/prechm.py. This creates project files which must be compiled -with MS HTML Help Workshop. diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/rmpyc.py b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/rmpyc.py deleted file mode 100644 index 95de0f6b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/rmpyc.py +++ /dev/null @@ -1,25 +0,0 @@ -# Remove all the .pyc and .pyo files under ../Lib. - - -def deltree(root): - import os - from os.path import join - - npyc = npyo = 0 - for root, dirs, files in os.walk(root): - for name in files: - delete = False - if name.endswith('.pyc'): - delete = True - npyc += 1 - elif name.endswith('.pyo'): - delete = True - npyo += 1 - - if delete: - os.remove(join(root, name)) - - return npyc, npyo - -npyc, npyo = deltree("../Lib") -print npyc, ".pyc deleted,", npyo, ".pyo deleted" diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/rt.bat b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/rt.bat deleted file mode 100644 index 67a28a63..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/rt.bat +++ /dev/null @@ -1,41 +0,0 @@ -@rem Run Tests. Run the regression test suite. -@rem Usage: rt [-d] [-O] [-q] regrtest_args -@rem -d Run Debug build (python_d.exe). Else release build. -@rem -O Run python.exe or python_d.exe (see -d) with -O. -@rem -q "quick" -- normally the tests are run twice, the first time -@rem after deleting all the .py[co] files reachable from Lib/. -@rem -q runs the tests just once, and without deleting .py[co] files. -@rem All leading instances of these switches are shifted off, and -@rem whatever remains is passed to regrtest.py. For example, -@rem rt -O -d -x test_thread -@rem runs -@rem python_d -O ../lib/test/regrtest.py -x test_thread -@rem twice, and -@rem rt -q -g test_binascii -@rem runs -@rem python_d ../lib/test/regrtest.py -g test_binascii -@rem to generate the expected-output file for binascii quickly. -@set _exe=python -@set _qmode=no -@set _dashO= -@goto CheckOpts -:Again -@shift -:CheckOpts -@if "%1"=="-O" set _dashO=-O -@if "%1"=="-O" goto Again -@if "%1"=="-q" set _qmode=yes -@if "%1"=="-q" goto Again -@if "%1"=="-d" set _exe=python_d -@if "%1"=="-d" goto Again -@if "%_qmode%"=="yes" goto Qmode -@echo Deleting .pyc/.pyo files ... -@%_exe% rmpyc.py -%_exe% %_dashO% -E -tt ../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 -@echo About to run again without deleting .pyc/.pyo first: -@pause -:Qmode -%_exe% %_dashO% -E -tt ../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 -@set _exe= -@set _qmode= -@set _dashO= diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/select.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/select.dsp deleted file mode 100644 index 12bc846c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/select.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="select" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=select - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "select.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "select.mak" CFG="select - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "select - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "select - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "select - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\select" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\..\select113" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /base:"0x1D110000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./select.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "select - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\select" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\..\select113" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /base:"0x1D110000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /nodefaultlib:"msvcrt" /out:"./select_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "select - Win32 Release" -# Name "select - Win32 Debug" -# Begin Source File - -SOURCE=..\Modules\selectmodule.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/unicodedata.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/unicodedata.dsp deleted file mode 100644 index 0ad5645e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/unicodedata.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="unicodedata" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=unicodedata - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "unicodedata.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "unicodedata.mak" CFG="unicodedata - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "unicodedata - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "unicodedata - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "unicodedata - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\unicodedata" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\Include" /I "..\PC" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "NDEBUG" -# ADD RSC /l 0xc09 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1D120000" /dll /machine:I386 /out:"./unicodedata.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "unicodedata - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\unicodedata" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "_DEBUG" -# ADD RSC /l 0xc09 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1D120000" /dll /debug /machine:I386 /out:"./unicodedata_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "unicodedata - Win32 Release" -# Name "unicodedata - Win32 Debug" -# Begin Source File - -SOURCE=..\Modules\unicodedata.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/w9xpopen.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/w9xpopen.dsp deleted file mode 100644 index 9c50ba0f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/w9xpopen.dsp +++ /dev/null @@ -1,97 +0,0 @@ -# Microsoft Developer Studio Project File - Name="w9xpopen" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=w9xpopen - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "w9xpopen.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "w9xpopen.mak" CFG="w9xpopen - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "w9xpopen - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "w9xpopen - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "w9xpopen - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\w9xpopen" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "NDEBUG" -# ADD RSC /l 0xc09 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 user32.lib /nologo /machine:I386 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "w9xpopen - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\w9xpopen" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "_DEBUG" -# ADD RSC /l 0xc09 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib /nologo /debug /machine:I386 /out:"./w9xpopen_d.exe" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "w9xpopen - Win32 Release" -# Name "w9xpopen - Win32 Debug" -# Begin Source File - -SOURCE=..\PC\w9xpopen.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/winreg.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/winreg.dsp deleted file mode 100644 index af40f437..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/winreg.dsp +++ /dev/null @@ -1,108 +0,0 @@ -# Microsoft Developer Studio Project File - Name="winreg" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=winreg - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "winreg.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "winreg.mak" CFG="winreg - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "winreg - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "winreg - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "winreg - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\winreg" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "winreg_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\Include" /I "..\PC" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "NDEBUG" -# ADD RSC /l 0xc09 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1C0000" /dll /machine:I386 /out:"_winreg.pyd" - -!ELSEIF "$(CFG)" == "winreg - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\winreg" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "winreg_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "..\Include" /I "..\PC" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "_DEBUG" -# ADD RSC /l 0xc09 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1C0000" /dll /debug /machine:I386 /out:"_winreg_d.pyd" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "winreg - Win32 Release" -# Name "winreg - Win32 Debug" -# Begin Source File - -SOURCE=..\PC\_winreg.c - -!IF "$(CFG)" == "winreg - Win32 Release" - -# ADD CPP /MD - -!ELSEIF "$(CFG)" == "winreg - Win32 Debug" - -# ADD CPP /MDd - -!ENDIF - -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/winsound.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/winsound.dsp deleted file mode 100644 index a6ae658c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/winsound.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="winsound" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=winsound - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "winsound.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "winsound.mak" CFG="winsound - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "winsound - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "winsound - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "winsound - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\winsound" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\Include" /I "..\PC" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "NDEBUG" -# ADD RSC /l 0xc09 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib winmm.lib user32.lib /nologo /base:"0x1D160000" /dll /machine:I386 /out:"./winsound.pyd" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "winsound - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\winsound" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0xc09 /d "_DEBUG" -# ADD RSC /l 0xc09 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib kernel32.lib winmm.lib /nologo /base:"0x1D160000" /dll /debug /machine:I386 /out:"./winsound_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "winsound - Win32 Release" -# Name "winsound - Win32 Debug" -# Begin Source File - -SOURCE=..\PC\winsound.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/zlib.dsp b/SDKs/XPlatform/Cypython-2.3.3/PCbuild/zlib.dsp deleted file mode 100644 index c997bc48..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/PCbuild/zlib.dsp +++ /dev/null @@ -1,109 +0,0 @@ -# Microsoft Developer Studio Project File - Name="zlib" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=zlib - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "zlib.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "zlib.mak" CFG="zlib - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "zlib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "zlib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "zlib - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-release\zlib" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\..\zlib-1.1.4" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 ..\..\zlib-1.1.4\zlib.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib.pyd" -# SUBTRACT LINK32 /pdb:none -# Begin Special Build Tool -SOURCE="$(InputPath)" -PreLink_Desc=Checking static zlib has been built -PreLink_Cmds=cd ..\..\zlib-1.1.4 nmake -nologo -f msdos\makefile.w32 zlib.lib -# End Special Build Tool - -!ELSEIF "$(CFG)" == "zlib - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "x86-temp-debug\zlib" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -F90=df.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\..\zlib-1.1.4" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ..\..\zlib-1.1.4\zlib.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib_d.pyd" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none -# Begin Special Build Tool -SOURCE="$(InputPath)" -PreLink_Desc=Checking static zlib has been built -PreLink_Cmds=cd ..\..\zlib-1.1.4 nmake -nologo -f msdos\makefile.w32 zlib.lib -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "zlib - Win32 Release" -# Name "zlib - Win32 Debug" -# Begin Source File - -SOURCE=..\Modules\zlibmodule.c -# End Source File -# End Target -# End Project diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/.cvsignore b/SDKs/XPlatform/Cypython-2.3.3/Parser/.cvsignore deleted file mode 100644 index 0be9f1a7..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile -pgen -add2lib diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/acceler.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/acceler.c deleted file mode 100644 index b33e8786..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/acceler.c +++ /dev/null @@ -1,138 +0,0 @@ - -/* Parser accelerator module */ - -/* The parser as originally conceived had disappointing performance. - This module does some precomputation that speeds up the selection - of a DFA based upon a token, turning a search through an array - into a simple indexing operation. The parser now cannot work - without the accelerators installed. Note that the accelerators - are installed dynamically when the parser is initialized, they - are not part of the static data structure written on graminit.[ch] - by the parser generator. */ - -#include "pgenheaders.h" -#include "grammar.h" -#include "node.h" -#include "token.h" -#include "parser.h" - -/* Forward references */ -static void fixdfa(grammar *, dfa *); -static void fixstate(grammar *, state *); - -void -PyGrammar_AddAccelerators(grammar *g) -{ - dfa *d; - int i; - d = g->g_dfa; - for (i = g->g_ndfas; --i >= 0; d++) - fixdfa(g, d); - g->g_accel = 1; -} - -void -PyGrammar_RemoveAccelerators(grammar *g) -{ - dfa *d; - int i; - g->g_accel = 0; - d = g->g_dfa; - for (i = g->g_ndfas; --i >= 0; d++) { - state *s; - int j; - s = d->d_state; - for (j = 0; j < d->d_nstates; j++, s++) { - if (s->s_accel) - PyObject_FREE(s->s_accel); - s->s_accel = NULL; - } - } -} - -static void -fixdfa(grammar *g, dfa *d) -{ - state *s; - int j; - s = d->d_state; - for (j = 0; j < d->d_nstates; j++, s++) - fixstate(g, s); -} - -static void -fixstate(grammar *g, state *s) -{ - arc *a; - int k; - int *accel; - int nl = g->g_ll.ll_nlabels; - s->s_accept = 0; - accel = (int *) PyObject_MALLOC(nl * sizeof(int)); - for (k = 0; k < nl; k++) - accel[k] = -1; - a = s->s_arc; - for (k = s->s_narcs; --k >= 0; a++) { - int lbl = a->a_lbl; - label *l = &g->g_ll.ll_label[lbl]; - int type = l->lb_type; - if (a->a_arrow >= (1 << 7)) { - printf("XXX too many states!\n"); - continue; - } - if (ISNONTERMINAL(type)) { - dfa *d1 = PyGrammar_FindDFA(g, type); - int ibit; - if (type - NT_OFFSET >= (1 << 7)) { - printf("XXX too high nonterminal number!\n"); - continue; - } - for (ibit = 0; ibit < g->g_ll.ll_nlabels; ibit++) { - if (testbit(d1->d_first, ibit)) { -#ifdef applec -#define MPW_881_BUG /* Undefine if bug below is fixed */ -#endif -#ifdef MPW_881_BUG - /* In 881 mode MPW 3.1 has a code - generation bug which seems to - set the upper bits; fix this by - explicitly masking them off */ - int temp; -#endif - if (accel[ibit] != -1) - printf("XXX ambiguity!\n"); -#ifdef MPW_881_BUG - temp = 0xFFFF & - (a->a_arrow | (1 << 7) | - ((type - NT_OFFSET) << 8)); - accel[ibit] = temp; -#else - accel[ibit] = a->a_arrow | (1 << 7) | - ((type - NT_OFFSET) << 8); -#endif - } - } - } - else if (lbl == EMPTY) - s->s_accept = 1; - else if (lbl >= 0 && lbl < nl) - accel[lbl] = a->a_arrow; - } - while (nl > 0 && accel[nl-1] == -1) - nl--; - for (k = 0; k < nl && accel[k] == -1;) - k++; - if (k < nl) { - int i; - s->s_accel = (int *) PyObject_MALLOC((nl-k) * sizeof(int)); - if (s->s_accel == NULL) { - fprintf(stderr, "no mem to add parser accelerators\n"); - exit(1); - } - s->s_lower = k; - s->s_upper = nl; - for (i = 0; k < nl; i++, k++) - s->s_accel[i] = accel[k]; - } - PyObject_FREE(accel); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/bitset.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/bitset.c deleted file mode 100644 index 1597c9a0..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/bitset.c +++ /dev/null @@ -1,66 +0,0 @@ - -/* Bitset primitives used by the parser generator */ - -#include "pgenheaders.h" -#include "bitset.h" - -bitset -newbitset(int nbits) -{ - int nbytes = NBYTES(nbits); - bitset ss = PyMem_NEW(BYTE, nbytes); - - if (ss == NULL) - Py_FatalError("no mem for bitset"); - - ss += nbytes; - while (--nbytes >= 0) - *--ss = 0; - return ss; -} - -void -delbitset(bitset ss) -{ - PyMem_DEL(ss); -} - -int -addbit(bitset ss, int ibit) -{ - int ibyte = BIT2BYTE(ibit); - BYTE mask = BIT2MASK(ibit); - - if (ss[ibyte] & mask) - return 0; /* Bit already set */ - ss[ibyte] |= mask; - return 1; -} - -#if 0 /* Now a macro */ -int -testbit(bitset ss, int ibit) -{ - return (ss[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0; -} -#endif - -int -samebitset(bitset ss1, bitset ss2, int nbits) -{ - int i; - - for (i = NBYTES(nbits); --i >= 0; ) - if (*ss1++ != *ss2++) - return 0; - return 1; -} - -void -mergebitset(bitset ss1, bitset ss2, int nbits) -{ - int i; - - for (i = NBYTES(nbits); --i >= 0; ) - *ss1++ |= *ss2++; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/firstsets.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/firstsets.c deleted file mode 100644 index f2531f8e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/firstsets.c +++ /dev/null @@ -1,110 +0,0 @@ - -/* Computation of FIRST stets */ - -#include "pgenheaders.h" -#include "grammar.h" -#include "token.h" - -extern int Py_DebugFlag; - -/* Forward */ -static void calcfirstset(grammar *, dfa *); - -void -addfirstsets(grammar *g) -{ - int i; - dfa *d; - - if (Py_DebugFlag) - printf("Adding FIRST sets ...\n"); - for (i = 0; i < g->g_ndfas; i++) { - d = &g->g_dfa[i]; - if (d->d_first == NULL) - calcfirstset(g, d); - } -} - -static void -calcfirstset(grammar *g, dfa *d) -{ - int i, j; - state *s; - arc *a; - int nsyms; - int *sym; - int nbits; - static bitset dummy; - bitset result; - int type; - dfa *d1; - label *l0; - - if (Py_DebugFlag) - printf("Calculate FIRST set for '%s'\n", d->d_name); - - if (dummy == NULL) - dummy = newbitset(1); - if (d->d_first == dummy) { - fprintf(stderr, "Left-recursion for '%s'\n", d->d_name); - return; - } - if (d->d_first != NULL) { - fprintf(stderr, "Re-calculating FIRST set for '%s' ???\n", - d->d_name); - } - d->d_first = dummy; - - l0 = g->g_ll.ll_label; - nbits = g->g_ll.ll_nlabels; - result = newbitset(nbits); - - sym = PyMem_NEW(int, 1); - if (sym == NULL) - Py_FatalError("no mem for new sym in calcfirstset"); - nsyms = 1; - sym[0] = findlabel(&g->g_ll, d->d_type, (char *)NULL); - - s = &d->d_state[d->d_initial]; - for (i = 0; i < s->s_narcs; i++) { - a = &s->s_arc[i]; - for (j = 0; j < nsyms; j++) { - if (sym[j] == a->a_lbl) - break; - } - if (j >= nsyms) { /* New label */ - PyMem_RESIZE(sym, int, nsyms + 1); - if (sym == NULL) - Py_FatalError( - "no mem to resize sym in calcfirstset"); - sym[nsyms++] = a->a_lbl; - type = l0[a->a_lbl].lb_type; - if (ISNONTERMINAL(type)) { - d1 = PyGrammar_FindDFA(g, type); - if (d1->d_first == dummy) { - fprintf(stderr, - "Left-recursion below '%s'\n", - d->d_name); - } - else { - if (d1->d_first == NULL) - calcfirstset(g, d1); - mergebitset(result, - d1->d_first, nbits); - } - } - else if (ISTERMINAL(type)) { - addbit(result, a->a_lbl); - } - } - } - d->d_first = result; - if (Py_DebugFlag) { - printf("FIRST set for '%s': {", d->d_name); - for (i = 0; i < nbits; i++) { - if (testbit(result, i)) - printf(" %s", PyGrammar_LabelRepr(&l0[i])); - } - printf(" }\n"); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/grammar.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/grammar.c deleted file mode 100644 index 2b467059..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/grammar.c +++ /dev/null @@ -1,246 +0,0 @@ - -/* Grammar implementation */ - -#include "Python.h" -#include "pgenheaders.h" - -#include - -#include "token.h" -#include "grammar.h" - -#ifdef RISCOS -#include -#endif - -extern int Py_DebugFlag; - -grammar * -newgrammar(int start) -{ - grammar *g; - - g = PyMem_NEW(grammar, 1); - if (g == NULL) - Py_FatalError("no mem for new grammar"); - g->g_ndfas = 0; - g->g_dfa = NULL; - g->g_start = start; - g->g_ll.ll_nlabels = 0; - g->g_ll.ll_label = NULL; - g->g_accel = 0; - return g; -} - -dfa * -adddfa(grammar *g, int type, char *name) -{ - dfa *d; - - PyMem_RESIZE(g->g_dfa, dfa, g->g_ndfas + 1); - if (g->g_dfa == NULL) - Py_FatalError("no mem to resize dfa in adddfa"); - d = &g->g_dfa[g->g_ndfas++]; - d->d_type = type; - d->d_name = strdup(name); - d->d_nstates = 0; - d->d_state = NULL; - d->d_initial = -1; - d->d_first = NULL; - return d; /* Only use while fresh! */ -} - -int -addstate(dfa *d) -{ - state *s; - - PyMem_RESIZE(d->d_state, state, d->d_nstates + 1); - if (d->d_state == NULL) - Py_FatalError("no mem to resize state in addstate"); - s = &d->d_state[d->d_nstates++]; - s->s_narcs = 0; - s->s_arc = NULL; - s->s_lower = 0; - s->s_upper = 0; - s->s_accel = NULL; - s->s_accept = 0; - return s - d->d_state; -} - -void -addarc(dfa *d, int from, int to, int lbl) -{ - state *s; - arc *a; - - assert(0 <= from && from < d->d_nstates); - assert(0 <= to && to < d->d_nstates); - - s = &d->d_state[from]; - PyMem_RESIZE(s->s_arc, arc, s->s_narcs + 1); - if (s->s_arc == NULL) - Py_FatalError("no mem to resize arc list in addarc"); - a = &s->s_arc[s->s_narcs++]; - a->a_lbl = lbl; - a->a_arrow = to; -} - -int -addlabel(labellist *ll, int type, char *str) -{ - int i; - label *lb; - - for (i = 0; i < ll->ll_nlabels; i++) { - if (ll->ll_label[i].lb_type == type && - strcmp(ll->ll_label[i].lb_str, str) == 0) - return i; - } - PyMem_RESIZE(ll->ll_label, label, ll->ll_nlabels + 1); - if (ll->ll_label == NULL) - Py_FatalError("no mem to resize labellist in addlabel"); - lb = &ll->ll_label[ll->ll_nlabels++]; - lb->lb_type = type; - lb->lb_str = strdup(str); - if (Py_DebugFlag) - printf("Label @ %08x, %d: %s\n", (unsigned)ll, ll->ll_nlabels, - PyGrammar_LabelRepr(lb)); - return lb - ll->ll_label; -} - -/* Same, but rather dies than adds */ - -int -findlabel(labellist *ll, int type, char *str) -{ - int i; - - for (i = 0; i < ll->ll_nlabels; i++) { - if (ll->ll_label[i].lb_type == type /*&& - strcmp(ll->ll_label[i].lb_str, str) == 0*/) - return i; - } - fprintf(stderr, "Label %d/'%s' not found\n", type, str); - Py_FatalError("grammar.c:findlabel()"); - return 0; /* Make gcc -Wall happy */ -} - -/* Forward */ -static void translabel(grammar *, label *); - -void -translatelabels(grammar *g) -{ - int i; - -#ifdef Py_DEBUG - printf("Translating labels ...\n"); -#endif - /* Don't translate EMPTY */ - for (i = EMPTY+1; i < g->g_ll.ll_nlabels; i++) - translabel(g, &g->g_ll.ll_label[i]); -} - -static void -translabel(grammar *g, label *lb) -{ - int i; - - if (Py_DebugFlag) - printf("Translating label %s ...\n", PyGrammar_LabelRepr(lb)); - - if (lb->lb_type == NAME) { - for (i = 0; i < g->g_ndfas; i++) { - if (strcmp(lb->lb_str, g->g_dfa[i].d_name) == 0) { - if (Py_DebugFlag) - printf( - "Label %s is non-terminal %d.\n", - lb->lb_str, - g->g_dfa[i].d_type); - lb->lb_type = g->g_dfa[i].d_type; - free(lb->lb_str); - lb->lb_str = NULL; - return; - } - } - for (i = 0; i < (int)N_TOKENS; i++) { - if (strcmp(lb->lb_str, _PyParser_TokenNames[i]) == 0) { - if (Py_DebugFlag) - printf("Label %s is terminal %d.\n", - lb->lb_str, i); - lb->lb_type = i; - free(lb->lb_str); - lb->lb_str = NULL; - return; - } - } - printf("Can't translate NAME label '%s'\n", lb->lb_str); - return; - } - - if (lb->lb_type == STRING) { - if (isalpha((int)(lb->lb_str[1])) || lb->lb_str[1] == '_') { - char *p; - char *src; - char *dest; - size_t name_len; - if (Py_DebugFlag) - printf("Label %s is a keyword\n", lb->lb_str); - lb->lb_type = NAME; - src = lb->lb_str + 1; - p = strchr(src, '\''); - if (p) - name_len = p - src; - else - name_len = strlen(src); - dest = malloc(name_len + 1); - strncpy(dest, src, name_len); - dest[name_len] = '\0'; - free(lb->lb_str); - lb->lb_str = dest; - } - else if (lb->lb_str[2] == lb->lb_str[0]) { - int type = (int) PyToken_OneChar(lb->lb_str[1]); - if (type != OP) { - lb->lb_type = type; - free(lb->lb_str); - lb->lb_str = NULL; - } - else - printf("Unknown OP label %s\n", - lb->lb_str); - } - else if (lb->lb_str[2] && lb->lb_str[3] == lb->lb_str[0]) { - int type = (int) PyToken_TwoChars(lb->lb_str[1], - lb->lb_str[2]); - if (type != OP) { - lb->lb_type = type; - free(lb->lb_str); - lb->lb_str = NULL; - } - else - printf("Unknown OP label %s\n", - lb->lb_str); - } - else if (lb->lb_str[2] && lb->lb_str[3] && lb->lb_str[4] == lb->lb_str[0]) { - int type = (int) PyToken_ThreeChars(lb->lb_str[1], - lb->lb_str[2], - lb->lb_str[3]); - if (type != OP) { - lb->lb_type = type; - free(lb->lb_str); - lb->lb_str = NULL; - } - else - printf("Unknown OP label %s\n", - lb->lb_str); - } - else - printf("Can't translate STRING label %s\n", - lb->lb_str); - } - else - printf("Can't translate label '%s'\n", - PyGrammar_LabelRepr(lb)); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/grammar.mak b/SDKs/XPlatform/Cypython-2.3.3/Parser/grammar.mak deleted file mode 100644 index 45413a3e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/grammar.mak +++ /dev/null @@ -1,45 +0,0 @@ -# This manages to rebuild graminit.{h, c} under MSVC 6 (Windows), via -# -# nmake /f grammar.mak -# -# You may also need to copy python23.dll into this directory, or get -# it on your search path. -# -# The intermediate files can be nuked afterwards: -# -# nmake /f grammar.mak clean -# -# I don't understand the maze of preprocessor #define's on Windows, and -# as a result this requires linking with python23.lib, so it's of no use -# for bootstrapping (the cause appears to be a useless-- in this -# particular case --pragma in PC\pyconfig.h, which demands that -# python23.lib get linked in). - -LIBS= ..\PCbuild\python23.lib - -CFLAGS= /I ..\Include /I ..\PC /D MS_NO_COREDLL /D PGEN /MD - -GRAMMAR_H= ..\Include\graminit.h -GRAMMAR_C= ..\Python\graminit.c -GRAMMAR_INPUT= ..\Grammar\Grammar - -PGEN= pgen.exe - -POBJS= acceler.obj grammar1.obj listnode.obj node.obj parser.obj \ - parsetok.obj tokenizer.obj bitset.obj metagrammar.obj - -PARSER_OBJS= $(POBJS) myreadline.obj - -PGOBJS= firstsets.obj grammar.obj pgen.obj printgrammar.obj pgenmain.obj - -PGENOBJS= $(POBJS) $(PGOBJS) - -$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT) - $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) - -$(PGEN): $(PGENOBJS) - $(CC) $(PGENOBJS) $(LIBS) /Fe$(PGEN) - -clean: - del *.obj - del $(PGEN) diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/grammar1.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/grammar1.c deleted file mode 100644 index b1fe0c18..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/grammar1.c +++ /dev/null @@ -1,57 +0,0 @@ - -/* Grammar subroutines needed by parser */ - -#include "Python.h" -#include "pgenheaders.h" -#include "grammar.h" -#include "token.h" - -/* Return the DFA for the given type */ - -dfa * -PyGrammar_FindDFA(grammar *g, register int type) -{ - register dfa *d; -#if 1 - /* Massive speed-up */ - d = &g->g_dfa[type - NT_OFFSET]; - assert(d->d_type == type); - return d; -#else - /* Old, slow version */ - register int i; - - for (i = g->g_ndfas, d = g->g_dfa; --i >= 0; d++) { - if (d->d_type == type) - return d; - } - assert(0); - /* NOTREACHED */ -#endif -} - -char * -PyGrammar_LabelRepr(label *lb) -{ - static char buf[100]; - - if (lb->lb_type == ENDMARKER) - return "EMPTY"; - else if (ISNONTERMINAL(lb->lb_type)) { - if (lb->lb_str == NULL) { - PyOS_snprintf(buf, sizeof(buf), "NT%d", lb->lb_type); - return buf; - } - else - return lb->lb_str; - } - else { - if (lb->lb_str == NULL) - return _PyParser_TokenNames[lb->lb_type]; - else { - PyOS_snprintf(buf, sizeof(buf), "%.32s(%.32s)", - _PyParser_TokenNames[lb->lb_type], lb->lb_str); - return buf; - } - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/intrcheck.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/intrcheck.c deleted file mode 100644 index 4935dcff..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/intrcheck.c +++ /dev/null @@ -1,193 +0,0 @@ - -/* Check for interrupts */ - -#include "Python.h" - -#ifdef QUICKWIN - -#include - -void -PyOS_InitInterrupts(void) -{ -} - -void -PyOS_FiniInterrupts(void) -{ -} - -int -PyOS_InterruptOccurred(void) -{ - _wyield(); -} - -#define OK - -#endif /* QUICKWIN */ - -#if defined(_M_IX86) && !defined(__QNX__) -#include -#endif - -#if defined(MSDOS) && !defined(QUICKWIN) - -#ifdef __GNUC__ - -/* This is for DJGPP's GO32 extender. I don't know how to trap - * control-C (There's no API for ctrl-C, and I don't want to mess with - * the interrupt vectors.) However, this DOES catch control-break. - * --Amrit - */ - -#include - -void -PyOS_InitInterrupts(void) -{ - _go32_want_ctrl_break(1 /* TRUE */); -} - -void -PyOS_FiniInterrupts(void) -{ -} - -int -PyOS_InterruptOccurred(void) -{ - return _go32_was_ctrl_break_hit(); -} - -#else /* !__GNUC__ */ - -/* This might work for MS-DOS (untested though): */ - -void -PyOS_InitInterrupts(void) -{ -} - -void -PyOS_FiniInterrupts(void) -{ -} - -int -PyOS_InterruptOccurred(void) -{ - int interrupted = 0; - while (kbhit()) { - if (getch() == '\003') - interrupted = 1; - } - return interrupted; -} - -#endif /* __GNUC__ */ - -#define OK - -#endif /* MSDOS && !QUICKWIN */ - - -#ifdef macintosh - -/* The Mac interrupt code has moved to macglue.c */ -#define OK - -#endif /* macintosh */ - - -#ifndef OK - -/* Default version -- for real operating systems and for Standard C */ - -#include -#include -#include - -static int interrupted; - -void -PyErr_SetInterrupt(void) -{ - interrupted = 1; -} - -extern int PyErr_CheckSignals(void); - -static int -checksignals_witharg(void * arg) -{ - return PyErr_CheckSignals(); -} - -static void -intcatcher(int sig) -{ - extern void Py_Exit(int); - static char message[] = -"python: to interrupt a truly hanging Python program, interrupt once more.\n"; - switch (interrupted++) { - case 0: - break; - case 1: -#ifdef RISCOS - fprintf(stderr, message); -#else - write(2, message, strlen(message)); -#endif - break; - case 2: - interrupted = 0; - Py_Exit(1); - break; - } - signal(SIGINT, intcatcher); - Py_AddPendingCall(checksignals_witharg, NULL); -} - -static void (*old_siginthandler)(int) = SIG_DFL; - -void -PyOS_InitInterrupts(void) -{ - if ((old_siginthandler = signal(SIGINT, SIG_IGN)) != SIG_IGN) - signal(SIGINT, intcatcher); -#ifdef HAVE_SIGINTERRUPT - /* This is for SunOS and other modern BSD derivatives. - It means that system calls (like read()) are not restarted - after an interrupt. This is necessary so interrupting a - read() or readline() call works as expected. - XXX On old BSD (pure 4.2 or older) you may have to do this - differently! */ - siginterrupt(SIGINT, 1); -#endif /* HAVE_SIGINTERRUPT */ -} - -void -PyOS_FiniInterrupts(void) -{ - signal(SIGINT, old_siginthandler); -} - -int -PyOS_InterruptOccurred(void) -{ - if (!interrupted) - return 0; - interrupted = 0; - return 1; -} - -#endif /* !OK */ - -void -PyOS_AfterFork(void) -{ -#ifdef WITH_THREAD - PyEval_ReInitThreads(); -#endif -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/listnode.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/listnode.c deleted file mode 100644 index 0e9fa450..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/listnode.c +++ /dev/null @@ -1,66 +0,0 @@ - -/* List a node on a file */ - -#include "pgenheaders.h" -#include "token.h" -#include "node.h" - -/* Forward */ -static void list1node(FILE *, node *); -static void listnode(FILE *, node *); - -void -PyNode_ListTree(node *n) -{ - listnode(stdout, n); -} - -static int level, atbol; - -static void -listnode(FILE *fp, node *n) -{ - level = 0; - atbol = 1; - list1node(fp, n); -} - -static void -list1node(FILE *fp, node *n) -{ - if (n == 0) - return; - if (ISNONTERMINAL(TYPE(n))) { - int i; - for (i = 0; i < NCH(n); i++) - list1node(fp, CHILD(n, i)); - } - else if (ISTERMINAL(TYPE(n))) { - switch (TYPE(n)) { - case INDENT: - ++level; - break; - case DEDENT: - --level; - break; - default: - if (atbol) { - int i; - for (i = 0; i < level; ++i) - fprintf(fp, "\t"); - atbol = 0; - } - if (TYPE(n) == NEWLINE) { - if (STR(n) != NULL) - fprintf(fp, "%s", STR(n)); - fprintf(fp, "\n"); - atbol = 1; - } - else - fprintf(fp, "%s ", STR(n)); - break; - } - } - else - fprintf(fp, "? "); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/metagrammar.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/metagrammar.c deleted file mode 100644 index 20cc7c8b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/metagrammar.c +++ /dev/null @@ -1,159 +0,0 @@ - -#include "pgenheaders.h" -#include "metagrammar.h" -#include "grammar.h" -#include "pgen.h" -static arc arcs_0_0[3] = { - {2, 0}, - {3, 0}, - {4, 1}, -}; -static arc arcs_0_1[1] = { - {0, 1}, -}; -static state states_0[2] = { - {3, arcs_0_0}, - {1, arcs_0_1}, -}; -static arc arcs_1_0[1] = { - {5, 1}, -}; -static arc arcs_1_1[1] = { - {6, 2}, -}; -static arc arcs_1_2[1] = { - {7, 3}, -}; -static arc arcs_1_3[1] = { - {3, 4}, -}; -static arc arcs_1_4[1] = { - {0, 4}, -}; -static state states_1[5] = { - {1, arcs_1_0}, - {1, arcs_1_1}, - {1, arcs_1_2}, - {1, arcs_1_3}, - {1, arcs_1_4}, -}; -static arc arcs_2_0[1] = { - {8, 1}, -}; -static arc arcs_2_1[2] = { - {9, 0}, - {0, 1}, -}; -static state states_2[2] = { - {1, arcs_2_0}, - {2, arcs_2_1}, -}; -static arc arcs_3_0[1] = { - {10, 1}, -}; -static arc arcs_3_1[2] = { - {10, 1}, - {0, 1}, -}; -static state states_3[2] = { - {1, arcs_3_0}, - {2, arcs_3_1}, -}; -static arc arcs_4_0[2] = { - {11, 1}, - {13, 2}, -}; -static arc arcs_4_1[1] = { - {7, 3}, -}; -static arc arcs_4_2[3] = { - {14, 4}, - {15, 4}, - {0, 2}, -}; -static arc arcs_4_3[1] = { - {12, 4}, -}; -static arc arcs_4_4[1] = { - {0, 4}, -}; -static state states_4[5] = { - {2, arcs_4_0}, - {1, arcs_4_1}, - {3, arcs_4_2}, - {1, arcs_4_3}, - {1, arcs_4_4}, -}; -static arc arcs_5_0[3] = { - {5, 1}, - {16, 1}, - {17, 2}, -}; -static arc arcs_5_1[1] = { - {0, 1}, -}; -static arc arcs_5_2[1] = { - {7, 3}, -}; -static arc arcs_5_3[1] = { - {18, 1}, -}; -static state states_5[4] = { - {3, arcs_5_0}, - {1, arcs_5_1}, - {1, arcs_5_2}, - {1, arcs_5_3}, -}; -static dfa dfas[6] = { - {256, "MSTART", 0, 2, states_0, - "\070\000\000"}, - {257, "RULE", 0, 5, states_1, - "\040\000\000"}, - {258, "RHS", 0, 2, states_2, - "\040\010\003"}, - {259, "ALT", 0, 2, states_3, - "\040\010\003"}, - {260, "ITEM", 0, 5, states_4, - "\040\010\003"}, - {261, "ATOM", 0, 4, states_5, - "\040\000\003"}, -}; -static label labels[19] = { - {0, "EMPTY"}, - {256, 0}, - {257, 0}, - {4, 0}, - {0, 0}, - {1, 0}, - {11, 0}, - {258, 0}, - {259, 0}, - {18, 0}, - {260, 0}, - {9, 0}, - {10, 0}, - {261, 0}, - {16, 0}, - {14, 0}, - {3, 0}, - {7, 0}, - {8, 0}, -}; -static grammar _PyParser_Grammar = { - 6, - dfas, - {19, labels}, - 256 -}; - -grammar * -meta_grammar(void) -{ - return &_PyParser_Grammar; -} - -grammar * -Py_meta_grammar(void) -{ - return meta_grammar(); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/myreadline.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/myreadline.c deleted file mode 100644 index f5122306..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/myreadline.c +++ /dev/null @@ -1,191 +0,0 @@ - -/* Readline interface for tokenizer.c and [raw_]input() in bltinmodule.c. - By default, or when stdin is not a tty device, we have a super - simple my_readline function using fgets. - Optionally, we can use the GNU readline library. - my_readline() has a different return value from GNU readline(): - - NULL if an interrupt occurred or if an error occurred - - a malloc'ed empty string if EOF was read - - a malloc'ed string ending in \n normally -*/ - -#include "Python.h" -#ifdef MS_WINDOWS -#ifdef MS_XBOX -#include -#else -#define WIN32_LEAN_AND_MEAN -#include "windows.h" -#endif -#endif /* MS_WINDOWS */ - -#ifdef __VMS -extern char* vms__StdioReadline(FILE *sys_stdin, FILE *sys_stdout, char *prompt); -#endif - -int (*PyOS_InputHook)(void) = NULL; - -#ifdef RISCOS -int Py_RISCOSWimpFlag; -#endif - -/* This function restarts a fgets() after an EINTR error occurred - except if PyOS_InterruptOccurred() returns true. */ - -static int -my_fgets(char *buf, int len, FILE *fp) -{ - char *p; - for (;;) { - if (PyOS_InputHook != NULL) - (void)(PyOS_InputHook)(); - errno = 0; - p = fgets(buf, len, fp); - if (p != NULL) - return 0; /* No error */ -#ifdef MS_WINDOWS - /* In the case of a Ctrl+C or some other external event - interrupting the operation: - Win2k/NT: ERROR_OPERATION_ABORTED is the most recent Win32 - error code (and feof() returns TRUE). - Win9x: Ctrl+C seems to have no effect on fgets() returning - early - the signal handler is called, but the fgets() - only returns "normally" (ie, when Enter hit or feof()) - */ - if (GetLastError()==ERROR_OPERATION_ABORTED) { - /* Signals come asynchronously, so we sleep a brief - moment before checking if the handler has been - triggered (we cant just return 1 before the - signal handler has been called, as the later - signal may be treated as a separate interrupt). - */ - Sleep(1); - if (PyOS_InterruptOccurred()) { - return 1; /* Interrupt */ - } - /* Either the sleep wasn't long enough (need a - short loop retrying?) or not interrupted at all - (in which case we should revisit the whole thing!) - Logging some warning would be nice. assert is not - viable as under the debugger, the various dialogs - mean the condition is not true. - */ - } -#endif /* MS_WINDOWS */ - if (feof(fp)) { - return -1; /* EOF */ - } -#ifdef EINTR - if (errno == EINTR) { - if (PyOS_InterruptOccurred()) { - return 1; /* Interrupt */ - } - continue; - } -#endif - if (PyOS_InterruptOccurred()) { - return 1; /* Interrupt */ - } - return -2; /* Error */ - } - /* NOTREACHED */ -} - - -/* Readline implementation using fgets() */ - -char * -PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) -{ - size_t n; - char *p; - n = 100; - if ((p = PyMem_MALLOC(n)) == NULL) - return NULL; - fflush(sys_stdout); -#ifndef RISCOS - if (prompt) - fprintf(stderr, "%s", prompt); -#else - if (prompt) { - if(Py_RISCOSWimpFlag) - fprintf(stderr, "\x0cr%s\x0c", prompt); - else - fprintf(stderr, "%s", prompt); - } -#endif - fflush(stderr); - switch (my_fgets(p, (int)n, sys_stdin)) { - case 0: /* Normal case */ - break; - case 1: /* Interrupt */ - PyMem_FREE(p); - return NULL; - case -1: /* EOF */ - case -2: /* Error */ - default: /* Shouldn't happen */ - *p = '\0'; - break; - } -#ifdef MPW - /* Hack for MPW C where the prompt comes right back in the input */ - /* XXX (Actually this would be rather nice on most systems...) */ - n = strlen(prompt); - if (strncmp(p, prompt, n) == 0) - memmove(p, p + n, strlen(p) - n + 1); -#endif - n = strlen(p); - while (n > 0 && p[n-1] != '\n') { - size_t incr = n+2; - p = PyMem_REALLOC(p, n + incr); - if (p == NULL) - return NULL; - if (incr > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, "input line too long"); - } - if (my_fgets(p+n, (int)incr, sys_stdin) != 0) - break; - n += strlen(p+n); - } - return PyMem_REALLOC(p, n+1); -} - - -/* By initializing this function pointer, systems embedding Python can - override the readline function. - - Note: Python expects in return a buffer allocated with PyMem_Malloc. */ - -char *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *); - - -/* Interface used by tokenizer.c and bltinmodule.c */ - -char * -PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) -{ - char *rv; - - if (PyOS_ReadlineFunctionPointer == NULL) { -#ifdef __VMS - PyOS_ReadlineFunctionPointer = vms__StdioReadline; -#else - PyOS_ReadlineFunctionPointer = PyOS_StdioReadline; -#endif - } - - Py_BEGIN_ALLOW_THREADS - - /* This is needed to handle the unlikely case that the - * interpreter is in interactive mode *and* stdin/out are not - * a tty. This can happen, for example if python is run like - * this: python -i < test1.py - */ - if (!isatty (fileno (sys_stdin)) || !isatty (fileno (sys_stdout))) - rv = PyOS_StdioReadline (sys_stdin, sys_stdout, prompt); - else - rv = (*PyOS_ReadlineFunctionPointer)(sys_stdin, sys_stdout, - prompt); - Py_END_ALLOW_THREADS - return rv; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/node.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/node.c deleted file mode 100644 index 8d786e09..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/node.c +++ /dev/null @@ -1,134 +0,0 @@ -/* Parse tree node implementation */ - -#include "Python.h" -#include "node.h" -#include "errcode.h" - -node * -PyNode_New(int type) -{ - node *n = (node *) PyObject_MALLOC(1 * sizeof(node)); - if (n == NULL) - return NULL; - n->n_type = type; - n->n_str = NULL; - n->n_lineno = 0; - n->n_nchildren = 0; - n->n_child = NULL; - return n; -} - -/* See comments at XXXROUNDUP below. Returns -1 on overflow. */ -static int -fancy_roundup(int n) -{ - /* Round up to the closest power of 2 >= n. */ - int result = 256; - assert(n > 128); - while (result < n) { - result <<= 1; - if (result <= 0) - return -1; - } - return result; -} - -/* A gimmick to make massive numbers of reallocs quicker. The result is - * a number >= the input. In PyNode_AddChild, it's used like so, when - * we're about to add child number current_size + 1: - * - * if XXXROUNDUP(current_size) < XXXROUNDUP(current_size + 1): - * allocate space for XXXROUNDUP(current_size + 1) total children - * else: - * we already have enough space - * - * Since a node starts out empty, we must have - * - * XXXROUNDUP(0) < XXXROUNDUP(1) - * - * so that we allocate space for the first child. One-child nodes are very - * common (presumably that would change if we used a more abstract form - * of syntax tree), so to avoid wasting memory it's desirable that - * XXXROUNDUP(1) == 1. That in turn forces XXXROUNDUP(0) == 0. - * - * Else for 2 <= n <= 128, we round up to the closest multiple of 4. Why 4? - * Rounding up to a multiple of an exact power of 2 is very efficient, and - * most nodes with more than one child have <= 4 kids. - * - * Else we call fancy_roundup() to grow proportionately to n. We've got an - * extreme case then (like test_longexp.py), and on many platforms doing - * anything less than proportional growth leads to exorbitant runtime - * (e.g., MacPython), or extreme fragmentation of user address space (e.g., - * Win98). - * - * In a run of compileall across the 2.3a0 Lib directory, Andrew MacIntyre - * reported that, with this scheme, 89% of PyMem_RESIZE calls in - * PyNode_AddChild passed 1 for the size, and 9% passed 4. So this usually - * wastes very little memory, but is very effective at sidestepping - * platform-realloc disasters on vulnernable platforms. - * - * Note that this would be straightforward if a node stored its current - * capacity. The code is tricky to avoid that. - */ -#define XXXROUNDUP(n) ((n) <= 1 ? (n) : \ - (n) <= 128 ? (((n) + 3) & ~3) : \ - fancy_roundup(n)) - - -int -PyNode_AddChild(register node *n1, int type, char *str, int lineno) -{ - const int nch = n1->n_nchildren; - int current_capacity; - int required_capacity; - node *n; - - if (nch == INT_MAX || nch < 0) - return E_OVERFLOW; - - current_capacity = XXXROUNDUP(nch); - required_capacity = XXXROUNDUP(nch + 1); - if (current_capacity < 0 || required_capacity < 0) - return E_OVERFLOW; - if (current_capacity < required_capacity) { - n = n1->n_child; - n = (node *) PyObject_REALLOC(n, - required_capacity * sizeof(node)); - if (n == NULL) - return E_NOMEM; - n1->n_child = n; - } - - n = &n1->n_child[n1->n_nchildren++]; - n->n_type = type; - n->n_str = str; - n->n_lineno = lineno; - n->n_nchildren = 0; - n->n_child = NULL; - return 0; -} - -/* Forward */ -static void freechildren(node *); - - -void -PyNode_Free(node *n) -{ - if (n != NULL) { - freechildren(n); - PyObject_FREE(n); - } -} - -static void -freechildren(node *n) -{ - int i; - for (i = NCH(n); --i >= 0; ) - freechildren(CHILD(n, i)); - if (n->n_child != NULL) - PyObject_FREE(n->n_child); - if (STR(n) != NULL) - PyObject_FREE(STR(n)); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/parser.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/parser.c deleted file mode 100644 index 855b254a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/parser.c +++ /dev/null @@ -1,418 +0,0 @@ - -/* Parser implementation */ - -/* For a description, see the comments at end of this file */ - -/* XXX To do: error recovery */ - -#include "Python.h" -#include "pgenheaders.h" -#include "token.h" -#include "grammar.h" -#include "node.h" -#include "parser.h" -#include "errcode.h" - - -#ifdef Py_DEBUG -extern int Py_DebugFlag; -#define D(x) if (!Py_DebugFlag); else x -#else -#define D(x) -#endif - - -/* STACK DATA TYPE */ - -static void s_reset(stack *); - -static void -s_reset(stack *s) -{ - s->s_top = &s->s_base[MAXSTACK]; -} - -#define s_empty(s) ((s)->s_top == &(s)->s_base[MAXSTACK]) - -static int -s_push(register stack *s, dfa *d, node *parent) -{ - register stackentry *top; - if (s->s_top == s->s_base) { - fprintf(stderr, "s_push: parser stack overflow\n"); - return E_NOMEM; - } - top = --s->s_top; - top->s_dfa = d; - top->s_parent = parent; - top->s_state = 0; - return 0; -} - -#ifdef Py_DEBUG - -static void -s_pop(register stack *s) -{ - if (s_empty(s)) - Py_FatalError("s_pop: parser stack underflow -- FATAL"); - s->s_top++; -} - -#else /* !Py_DEBUG */ - -#define s_pop(s) (s)->s_top++ - -#endif - - -/* PARSER CREATION */ - -parser_state * -PyParser_New(grammar *g, int start) -{ - parser_state *ps; - - if (!g->g_accel) - PyGrammar_AddAccelerators(g); - ps = PyMem_NEW(parser_state, 1); - if (ps == NULL) - return NULL; - ps->p_grammar = g; -#if 0 /* future keyword */ - ps->p_generators = 0; -#endif - ps->p_tree = PyNode_New(start); - if (ps->p_tree == NULL) { - PyMem_DEL(ps); - return NULL; - } - s_reset(&ps->p_stack); - (void) s_push(&ps->p_stack, PyGrammar_FindDFA(g, start), ps->p_tree); - return ps; -} - -void -PyParser_Delete(parser_state *ps) -{ - /* NB If you want to save the parse tree, - you must set p_tree to NULL before calling delparser! */ - PyNode_Free(ps->p_tree); - PyMem_DEL(ps); -} - - -/* PARSER STACK OPERATIONS */ - -static int -shift(register stack *s, int type, char *str, int newstate, int lineno) -{ - int err; - assert(!s_empty(s)); - err = PyNode_AddChild(s->s_top->s_parent, type, str, lineno); - if (err) - return err; - s->s_top->s_state = newstate; - return 0; -} - -static int -push(register stack *s, int type, dfa *d, int newstate, int lineno) -{ - int err; - register node *n; - n = s->s_top->s_parent; - assert(!s_empty(s)); - err = PyNode_AddChild(n, type, (char *)NULL, lineno); - if (err) - return err; - s->s_top->s_state = newstate; - return s_push(s, d, CHILD(n, NCH(n)-1)); -} - - -/* PARSER PROPER */ - -static int -classify(parser_state *ps, int type, char *str) -{ - grammar *g = ps->p_grammar; - register int n = g->g_ll.ll_nlabels; - - if (type == NAME) { - register char *s = str; - register label *l = g->g_ll.ll_label; - register int i; - for (i = n; i > 0; i--, l++) { - if (l->lb_type == NAME && l->lb_str != NULL && - l->lb_str[0] == s[0] && - strcmp(l->lb_str, s) == 0) { -#if 0 /* future keyword */ - if (!ps->p_generators && - s[0] == 'y' && - strcmp(s, "yield") == 0) - break; /* not a keyword */ -#endif - D(printf("It's a keyword\n")); - return n - i; - } - } - } - - { - register label *l = g->g_ll.ll_label; - register int i; - for (i = n; i > 0; i--, l++) { - if (l->lb_type == type && l->lb_str == NULL) { - D(printf("It's a token we know\n")); - return n - i; - } - } - } - - D(printf("Illegal token\n")); - return -1; -} - -#if 0 /* future keyword */ -static void -future_hack(parser_state *ps) -{ - node *n = ps->p_stack.s_top->s_parent; - node *ch; - int i; - - if (strcmp(STR(CHILD(n, 0)), "from") != 0) - return; - ch = CHILD(n, 1); - if (strcmp(STR(CHILD(ch, 0)), "__future__") != 0) - return; - for (i = 3; i < NCH(n); i += 2) { - ch = CHILD(n, i); - if (NCH(ch) >= 1 && TYPE(CHILD(ch, 0)) == NAME && - strcmp(STR(CHILD(ch, 0)), "generators") == 0) { - ps->p_generators = 1; - break; - } - } -} -#endif /* future keyword */ - -int -PyParser_AddToken(register parser_state *ps, register int type, char *str, - int lineno, int *expected_ret) -{ - register int ilabel; - int err; - - D(printf("Token %s/'%s' ... ", _PyParser_TokenNames[type], str)); - - /* Find out which label this token is */ - ilabel = classify(ps, type, str); - if (ilabel < 0) - return E_SYNTAX; - - /* Loop until the token is shifted or an error occurred */ - for (;;) { - /* Fetch the current dfa and state */ - register dfa *d = ps->p_stack.s_top->s_dfa; - register state *s = &d->d_state[ps->p_stack.s_top->s_state]; - - D(printf(" DFA '%s', state %d:", - d->d_name, ps->p_stack.s_top->s_state)); - - /* Check accelerator */ - if (s->s_lower <= ilabel && ilabel < s->s_upper) { - register int x = s->s_accel[ilabel - s->s_lower]; - if (x != -1) { - if (x & (1<<7)) { - /* Push non-terminal */ - int nt = (x >> 8) + NT_OFFSET; - int arrow = x & ((1<<7)-1); - dfa *d1 = PyGrammar_FindDFA( - ps->p_grammar, nt); - if ((err = push(&ps->p_stack, nt, d1, - arrow, lineno)) > 0) { - D(printf(" MemError: push\n")); - return err; - } - D(printf(" Push ...\n")); - continue; - } - - /* Shift the token */ - if ((err = shift(&ps->p_stack, type, str, - x, lineno)) > 0) { - D(printf(" MemError: shift.\n")); - return err; - } - D(printf(" Shift.\n")); - /* Pop while we are in an accept-only state */ - while (s = &d->d_state - [ps->p_stack.s_top->s_state], - s->s_accept && s->s_narcs == 1) { - D(printf(" DFA '%s', state %d: " - "Direct pop.\n", - d->d_name, - ps->p_stack.s_top->s_state)); -#if 0 /* future keyword */ - if (d->d_name[0] == 'i' && - strcmp(d->d_name, - "import_stmt") == 0) - future_hack(ps); -#endif - s_pop(&ps->p_stack); - if (s_empty(&ps->p_stack)) { - D(printf(" ACCEPT.\n")); - return E_DONE; - } - d = ps->p_stack.s_top->s_dfa; - } - return E_OK; - } - } - - if (s->s_accept) { -#if 0 /* future keyword */ - if (d->d_name[0] == 'i' && - strcmp(d->d_name, "import_stmt") == 0) - future_hack(ps); -#endif - /* Pop this dfa and try again */ - s_pop(&ps->p_stack); - D(printf(" Pop ...\n")); - if (s_empty(&ps->p_stack)) { - D(printf(" Error: bottom of stack.\n")); - return E_SYNTAX; - } - continue; - } - - /* Stuck, report syntax error */ - D(printf(" Error.\n")); - if (expected_ret) { - if (s->s_lower == s->s_upper - 1) { - /* Only one possible expected token */ - *expected_ret = ps->p_grammar-> - g_ll.ll_label[s->s_lower].lb_type; - } - else - *expected_ret = -1; - } - return E_SYNTAX; - } -} - - -#ifdef Py_DEBUG - -/* DEBUG OUTPUT */ - -void -dumptree(grammar *g, node *n) -{ - int i; - - if (n == NULL) - printf("NIL"); - else { - label l; - l.lb_type = TYPE(n); - l.lb_str = STR(n); - printf("%s", PyGrammar_LabelRepr(&l)); - if (ISNONTERMINAL(TYPE(n))) { - printf("("); - for (i = 0; i < NCH(n); i++) { - if (i > 0) - printf(","); - dumptree(g, CHILD(n, i)); - } - printf(")"); - } - } -} - -void -showtree(grammar *g, node *n) -{ - int i; - - if (n == NULL) - return; - if (ISNONTERMINAL(TYPE(n))) { - for (i = 0; i < NCH(n); i++) - showtree(g, CHILD(n, i)); - } - else if (ISTERMINAL(TYPE(n))) { - printf("%s", _PyParser_TokenNames[TYPE(n)]); - if (TYPE(n) == NUMBER || TYPE(n) == NAME) - printf("(%s)", STR(n)); - printf(" "); - } - else - printf("? "); -} - -void -printtree(parser_state *ps) -{ - if (Py_DebugFlag) { - printf("Parse tree:\n"); - dumptree(ps->p_grammar, ps->p_tree); - printf("\n"); - printf("Tokens:\n"); - showtree(ps->p_grammar, ps->p_tree); - printf("\n"); - } - printf("Listing:\n"); - PyNode_ListTree(ps->p_tree); - printf("\n"); -} - -#endif /* Py_DEBUG */ - -/* - -Description ------------ - -The parser's interface is different than usual: the function addtoken() -must be called for each token in the input. This makes it possible to -turn it into an incremental parsing system later. The parsing system -constructs a parse tree as it goes. - -A parsing rule is represented as a Deterministic Finite-state Automaton -(DFA). A node in a DFA represents a state of the parser; an arc represents -a transition. Transitions are either labeled with terminal symbols or -with non-terminals. When the parser decides to follow an arc labeled -with a non-terminal, it is invoked recursively with the DFA representing -the parsing rule for that as its initial state; when that DFA accepts, -the parser that invoked it continues. The parse tree constructed by the -recursively called parser is inserted as a child in the current parse tree. - -The DFA's can be constructed automatically from a more conventional -language description. An extended LL(1) grammar (ELL(1)) is suitable. -Certain restrictions make the parser's life easier: rules that can produce -the empty string should be outlawed (there are other ways to put loops -or optional parts in the language). To avoid the need to construct -FIRST sets, we can require that all but the last alternative of a rule -(really: arc going out of a DFA's state) must begin with a terminal -symbol. - -As an example, consider this grammar: - -expr: term (OP term)* -term: CONSTANT | '(' expr ')' - -The DFA corresponding to the rule for expr is: - -------->.---term-->.-------> - ^ | - | | - \----OP----/ - -The parse tree generated for the input a+b is: - -(expr: (term: (NAME: a)), (OP: +), (term: (NAME: b))) - -*/ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/parser.h b/SDKs/XPlatform/Cypython-2.3.3/Parser/parser.h deleted file mode 100644 index 141fe8b0..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/parser.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef Py_PARSER_H -#define Py_PARSER_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Parser interface */ - -#define MAXSTACK 500 - -typedef struct { - int s_state; /* State in current DFA */ - dfa *s_dfa; /* Current DFA */ - struct _node *s_parent; /* Where to add next node */ -} stackentry; - -typedef struct { - stackentry *s_top; /* Top entry */ - stackentry s_base[MAXSTACK];/* Array of stack entries */ - /* NB The stack grows down */ -} stack; - -typedef struct { - stack p_stack; /* Stack of parser states */ - grammar *p_grammar; /* Grammar to use */ - node *p_tree; /* Top of parse tree */ -#if 0 /* future keyword */ - int p_generators; /* 1 if yield is a keyword */ -#endif -} parser_state; - -parser_state *PyParser_New(grammar *g, int start); -void PyParser_Delete(parser_state *ps); -int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno, - int *expected_ret); -void PyGrammar_AddAccelerators(grammar *g); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PARSER_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/parsetok.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/parsetok.c deleted file mode 100644 index c5ee455b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/parsetok.c +++ /dev/null @@ -1,222 +0,0 @@ - -/* Parser-tokenizer link implementation */ - -#include "pgenheaders.h" -#include "tokenizer.h" -#include "node.h" -#include "grammar.h" -#include "parser.h" -#include "parsetok.h" -#include "errcode.h" -#include "graminit.h" - -int Py_TabcheckFlag; - - -/* Forward */ -static node *parsetok(struct tok_state *, grammar *, int, perrdetail *, int); -static void initerr(perrdetail *err_ret, const char* filename); - -/* Parse input coming from a string. Return error code, print some errors. */ -node * -PyParser_ParseString(const char *s, grammar *g, int start, perrdetail *err_ret) -{ - return PyParser_ParseStringFlags(s, g, start, err_ret, 0); -} - -node * -PyParser_ParseStringFlags(const char *s, grammar *g, int start, - perrdetail *err_ret, int flags) -{ - return PyParser_ParseStringFlagsFilename(s, NULL, - g, start, err_ret, 0); -} - -node * -PyParser_ParseStringFlagsFilename(const char *s, const char *filename, - grammar *g, int start, - perrdetail *err_ret, int flags) -{ - struct tok_state *tok; - - initerr(err_ret, filename); - - if ((tok = PyTokenizer_FromString(s)) == NULL) { - err_ret->error = E_NOMEM; - return NULL; - } - - tok->filename = filename ? filename : ""; - if (Py_TabcheckFlag || Py_VerboseFlag) { - tok->altwarning = (tok->filename != NULL); - if (Py_TabcheckFlag >= 2) - tok->alterror++; - } - - return parsetok(tok, g, start, err_ret, flags); -} - - -/* Parse input coming from a file. Return error code, print some errors. */ - -node * -PyParser_ParseFile(FILE *fp, const char *filename, grammar *g, int start, - char *ps1, char *ps2, perrdetail *err_ret) -{ - return PyParser_ParseFileFlags(fp, filename, g, start, ps1, ps2, - err_ret, 0); -} - -node * -PyParser_ParseFileFlags(FILE *fp, const char *filename, grammar *g, int start, - char *ps1, char *ps2, perrdetail *err_ret, int flags) -{ - struct tok_state *tok; - - initerr(err_ret, filename); - - if ((tok = PyTokenizer_FromFile(fp, ps1, ps2)) == NULL) { - err_ret->error = E_NOMEM; - return NULL; - } - tok->filename = filename; - if (Py_TabcheckFlag || Py_VerboseFlag) { - tok->altwarning = (filename != NULL); - if (Py_TabcheckFlag >= 2) - tok->alterror++; - } - - - return parsetok(tok, g, start, err_ret, flags); -} - -/* Parse input coming from the given tokenizer structure. - Return error code. */ - -#if 0 /* future keyword */ -static char yield_msg[] = -"%s:%d: Warning: 'yield' will become a reserved keyword in the future\n"; -#endif - -static node * -parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, - int flags) -{ - parser_state *ps; - node *n; - int started = 0; - - if ((ps = PyParser_New(g, start)) == NULL) { - fprintf(stderr, "no mem for new parser\n"); - err_ret->error = E_NOMEM; - return NULL; - } -#if 0 /* future keyword */ - if (flags & PyPARSE_YIELD_IS_KEYWORD) - ps->p_generators = 1; -#endif - - for (;;) { - char *a, *b; - int type; - size_t len; - char *str; - - type = PyTokenizer_Get(tok, &a, &b); - if (type == ERRORTOKEN) { - err_ret->error = tok->done; - break; - } - if (type == ENDMARKER && started) { - type = NEWLINE; /* Add an extra newline */ - started = 0; - /* Add the right number of dedent tokens, - except if a certain flag is given -- - codeop.py uses this. */ - if (tok->indent && - !(flags & PyPARSE_DONT_IMPLY_DEDENT)) - { - tok->pendin = -tok->indent; - tok->indent = 0; - } - } - else - started = 1; - len = b - a; /* XXX this may compute NULL - NULL */ - str = (char *) PyObject_MALLOC(len + 1); - if (str == NULL) { - fprintf(stderr, "no mem for next token\n"); - err_ret->error = E_NOMEM; - break; - } - if (len > 0) - strncpy(str, a, len); - str[len] = '\0'; - -#if 0 /* future keyword */ - /* Warn about yield as NAME */ - if (type == NAME && !ps->p_generators && - len == 5 && str[0] == 'y' && strcmp(str, "yield") == 0) - PySys_WriteStderr(yield_msg, - err_ret->filename==NULL ? - "" : err_ret->filename, - tok->lineno); -#endif - - if ((err_ret->error = - PyParser_AddToken(ps, (int)type, str, tok->lineno, - &(err_ret->expected))) != E_OK) { - if (err_ret->error != E_DONE) - PyObject_FREE(str); - break; - } - } - - if (err_ret->error == E_DONE) { - n = ps->p_tree; - ps->p_tree = NULL; - } - else - n = NULL; - - PyParser_Delete(ps); - - if (n == NULL) { - if (tok->lineno <= 1 && tok->done == E_EOF) - err_ret->error = E_EOF; - err_ret->lineno = tok->lineno; - err_ret->offset = tok->cur - tok->buf; - if (tok->buf != NULL) { - size_t len = tok->inp - tok->buf; - err_ret->text = (char *) PyObject_MALLOC(len + 1); - if (err_ret->text != NULL) { - if (len > 0) - strncpy(err_ret->text, tok->buf, len); - err_ret->text[len] = '\0'; - } - } - } else if (tok->encoding != NULL) { - node* r = PyNode_New(encoding_decl); - r->n_str = tok->encoding; - r->n_nchildren = 1; - r->n_child = n; - tok->encoding = NULL; - n = r; - } - - PyTokenizer_Free(tok); - - return n; -} - -static void -initerr(perrdetail *err_ret, const char* filename) -{ - err_ret->error = E_OK; - err_ret->filename = filename; - err_ret->lineno = 0; - err_ret->offset = 0; - err_ret->text = NULL; - err_ret->token = -1; - err_ret->expected = -1; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/pgen.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/pgen.c deleted file mode 100644 index b1ac446a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/pgen.c +++ /dev/null @@ -1,706 +0,0 @@ - -/* Parser generator */ -/* XXX This file is not yet fully PROTOized */ - -/* For a description, see the comments at end of this file */ - -#include "Python.h" -#include "pgenheaders.h" -#include "token.h" -#include "node.h" -#include "grammar.h" -#include "metagrammar.h" -#include "pgen.h" - -extern int Py_DebugFlag; -extern int Py_IgnoreEnvironmentFlag; /* needed by Py_GETENV */ - - -/* PART ONE -- CONSTRUCT NFA -- Cf. Algorithm 3.2 from [Aho&Ullman 77] */ - -typedef struct _nfaarc { - int ar_label; - int ar_arrow; -} nfaarc; - -typedef struct _nfastate { - int st_narcs; - nfaarc *st_arc; -} nfastate; - -typedef struct _nfa { - int nf_type; - char *nf_name; - int nf_nstates; - nfastate *nf_state; - int nf_start, nf_finish; -} nfa; - -/* Forward */ -static void compile_rhs(labellist *ll, - nfa *nf, node *n, int *pa, int *pb); -static void compile_alt(labellist *ll, - nfa *nf, node *n, int *pa, int *pb); -static void compile_item(labellist *ll, - nfa *nf, node *n, int *pa, int *pb); -static void compile_atom(labellist *ll, - nfa *nf, node *n, int *pa, int *pb); - -static int -addnfastate(nfa *nf) -{ - nfastate *st; - - PyMem_RESIZE(nf->nf_state, nfastate, nf->nf_nstates + 1); - if (nf->nf_state == NULL) - Py_FatalError("out of mem"); - st = &nf->nf_state[nf->nf_nstates++]; - st->st_narcs = 0; - st->st_arc = NULL; - return st - nf->nf_state; -} - -static void -addnfaarc(nfa *nf, int from, int to, int lbl) -{ - nfastate *st; - nfaarc *ar; - - st = &nf->nf_state[from]; - PyMem_RESIZE(st->st_arc, nfaarc, st->st_narcs + 1); - if (st->st_arc == NULL) - Py_FatalError("out of mem"); - ar = &st->st_arc[st->st_narcs++]; - ar->ar_label = lbl; - ar->ar_arrow = to; -} - -static nfa * -newnfa(char *name) -{ - nfa *nf; - static int type = NT_OFFSET; /* All types will be disjunct */ - - nf = PyMem_NEW(nfa, 1); - if (nf == NULL) - Py_FatalError("no mem for new nfa"); - nf->nf_type = type++; - nf->nf_name = name; /* XXX strdup(name) ??? */ - nf->nf_nstates = 0; - nf->nf_state = NULL; - nf->nf_start = nf->nf_finish = -1; - return nf; -} - -typedef struct _nfagrammar { - int gr_nnfas; - nfa **gr_nfa; - labellist gr_ll; -} nfagrammar; - -/* Forward */ -static void compile_rule(nfagrammar *gr, node *n); - -static nfagrammar * -newnfagrammar(void) -{ - nfagrammar *gr; - - gr = PyMem_NEW(nfagrammar, 1); - if (gr == NULL) - Py_FatalError("no mem for new nfa grammar"); - gr->gr_nnfas = 0; - gr->gr_nfa = NULL; - gr->gr_ll.ll_nlabels = 0; - gr->gr_ll.ll_label = NULL; - addlabel(&gr->gr_ll, ENDMARKER, "EMPTY"); - return gr; -} - -static nfa * -addnfa(nfagrammar *gr, char *name) -{ - nfa *nf; - - nf = newnfa(name); - PyMem_RESIZE(gr->gr_nfa, nfa *, gr->gr_nnfas + 1); - if (gr->gr_nfa == NULL) - Py_FatalError("out of mem"); - gr->gr_nfa[gr->gr_nnfas++] = nf; - addlabel(&gr->gr_ll, NAME, nf->nf_name); - return nf; -} - -#ifdef Py_DEBUG - -static char REQNFMT[] = "metacompile: less than %d children\n"; - -#define REQN(i, count) \ - if (i < count) { \ - fprintf(stderr, REQNFMT, count); \ - Py_FatalError("REQN"); \ - } else - -#else -#define REQN(i, count) /* empty */ -#endif - -static nfagrammar * -metacompile(node *n) -{ - nfagrammar *gr; - int i; - - if (Py_DebugFlag) - printf("Compiling (meta-) parse tree into NFA grammar\n"); - gr = newnfagrammar(); - REQ(n, MSTART); - i = n->n_nchildren - 1; /* Last child is ENDMARKER */ - n = n->n_child; - for (; --i >= 0; n++) { - if (n->n_type != NEWLINE) - compile_rule(gr, n); - } - return gr; -} - -static void -compile_rule(nfagrammar *gr, node *n) -{ - nfa *nf; - - REQ(n, RULE); - REQN(n->n_nchildren, 4); - n = n->n_child; - REQ(n, NAME); - nf = addnfa(gr, n->n_str); - n++; - REQ(n, COLON); - n++; - REQ(n, RHS); - compile_rhs(&gr->gr_ll, nf, n, &nf->nf_start, &nf->nf_finish); - n++; - REQ(n, NEWLINE); -} - -static void -compile_rhs(labellist *ll, nfa *nf, node *n, int *pa, int *pb) -{ - int i; - int a, b; - - REQ(n, RHS); - i = n->n_nchildren; - REQN(i, 1); - n = n->n_child; - REQ(n, ALT); - compile_alt(ll, nf, n, pa, pb); - if (--i <= 0) - return; - n++; - a = *pa; - b = *pb; - *pa = addnfastate(nf); - *pb = addnfastate(nf); - addnfaarc(nf, *pa, a, EMPTY); - addnfaarc(nf, b, *pb, EMPTY); - for (; --i >= 0; n++) { - REQ(n, VBAR); - REQN(i, 1); - --i; - n++; - REQ(n, ALT); - compile_alt(ll, nf, n, &a, &b); - addnfaarc(nf, *pa, a, EMPTY); - addnfaarc(nf, b, *pb, EMPTY); - } -} - -static void -compile_alt(labellist *ll, nfa *nf, node *n, int *pa, int *pb) -{ - int i; - int a, b; - - REQ(n, ALT); - i = n->n_nchildren; - REQN(i, 1); - n = n->n_child; - REQ(n, ITEM); - compile_item(ll, nf, n, pa, pb); - --i; - n++; - for (; --i >= 0; n++) { - if (n->n_type == COMMA) { /* XXX Temporary */ - REQN(i, 1); - --i; - n++; - } - REQ(n, ITEM); - compile_item(ll, nf, n, &a, &b); - addnfaarc(nf, *pb, a, EMPTY); - *pb = b; - } -} - -static void -compile_item(labellist *ll, nfa *nf, node *n, int *pa, int *pb) -{ - int i; - int a, b; - - REQ(n, ITEM); - i = n->n_nchildren; - REQN(i, 1); - n = n->n_child; - if (n->n_type == LSQB) { - REQN(i, 3); - n++; - REQ(n, RHS); - *pa = addnfastate(nf); - *pb = addnfastate(nf); - addnfaarc(nf, *pa, *pb, EMPTY); - compile_rhs(ll, nf, n, &a, &b); - addnfaarc(nf, *pa, a, EMPTY); - addnfaarc(nf, b, *pb, EMPTY); - REQN(i, 1); - n++; - REQ(n, RSQB); - } - else { - compile_atom(ll, nf, n, pa, pb); - if (--i <= 0) - return; - n++; - addnfaarc(nf, *pb, *pa, EMPTY); - if (n->n_type == STAR) - *pb = *pa; - else - REQ(n, PLUS); - } -} - -static void -compile_atom(labellist *ll, nfa *nf, node *n, int *pa, int *pb) -{ - int i; - - REQ(n, ATOM); - i = n->n_nchildren; - REQN(i, 1); - n = n->n_child; - if (n->n_type == LPAR) { - REQN(i, 3); - n++; - REQ(n, RHS); - compile_rhs(ll, nf, n, pa, pb); - n++; - REQ(n, RPAR); - } - else if (n->n_type == NAME || n->n_type == STRING) { - *pa = addnfastate(nf); - *pb = addnfastate(nf); - addnfaarc(nf, *pa, *pb, addlabel(ll, n->n_type, n->n_str)); - } - else - REQ(n, NAME); -} - -static void -dumpstate(labellist *ll, nfa *nf, int istate) -{ - nfastate *st; - int i; - nfaarc *ar; - - printf("%c%2d%c", - istate == nf->nf_start ? '*' : ' ', - istate, - istate == nf->nf_finish ? '.' : ' '); - st = &nf->nf_state[istate]; - ar = st->st_arc; - for (i = 0; i < st->st_narcs; i++) { - if (i > 0) - printf("\n "); - printf("-> %2d %s", ar->ar_arrow, - PyGrammar_LabelRepr(&ll->ll_label[ar->ar_label])); - ar++; - } - printf("\n"); -} - -static void -dumpnfa(labellist *ll, nfa *nf) -{ - int i; - - printf("NFA '%s' has %d states; start %d, finish %d\n", - nf->nf_name, nf->nf_nstates, nf->nf_start, nf->nf_finish); - for (i = 0; i < nf->nf_nstates; i++) - dumpstate(ll, nf, i); -} - - -/* PART TWO -- CONSTRUCT DFA -- Algorithm 3.1 from [Aho&Ullman 77] */ - -static void -addclosure(bitset ss, nfa *nf, int istate) -{ - if (addbit(ss, istate)) { - nfastate *st = &nf->nf_state[istate]; - nfaarc *ar = st->st_arc; - int i; - - for (i = st->st_narcs; --i >= 0; ) { - if (ar->ar_label == EMPTY) - addclosure(ss, nf, ar->ar_arrow); - ar++; - } - } -} - -typedef struct _ss_arc { - bitset sa_bitset; - int sa_arrow; - int sa_label; -} ss_arc; - -typedef struct _ss_state { - bitset ss_ss; - int ss_narcs; - ss_arc *ss_arc; - int ss_deleted; - int ss_finish; - int ss_rename; -} ss_state; - -typedef struct _ss_dfa { - int sd_nstates; - ss_state *sd_state; -} ss_dfa; - -/* Forward */ -static void printssdfa(int xx_nstates, ss_state *xx_state, int nbits, - labellist *ll, char *msg); -static void simplify(int xx_nstates, ss_state *xx_state); -static void convert(dfa *d, int xx_nstates, ss_state *xx_state); - -static void -makedfa(nfagrammar *gr, nfa *nf, dfa *d) -{ - int nbits = nf->nf_nstates; - bitset ss; - int xx_nstates; - ss_state *xx_state, *yy; - ss_arc *zz; - int istate, jstate, iarc, jarc, ibit; - nfastate *st; - nfaarc *ar; - - ss = newbitset(nbits); - addclosure(ss, nf, nf->nf_start); - xx_state = PyMem_NEW(ss_state, 1); - if (xx_state == NULL) - Py_FatalError("no mem for xx_state in makedfa"); - xx_nstates = 1; - yy = &xx_state[0]; - yy->ss_ss = ss; - yy->ss_narcs = 0; - yy->ss_arc = NULL; - yy->ss_deleted = 0; - yy->ss_finish = testbit(ss, nf->nf_finish); - if (yy->ss_finish) - printf("Error: nonterminal '%s' may produce empty.\n", - nf->nf_name); - - /* This algorithm is from a book written before - the invention of structured programming... */ - - /* For each unmarked state... */ - for (istate = 0; istate < xx_nstates; ++istate) { - yy = &xx_state[istate]; - ss = yy->ss_ss; - /* For all its states... */ - for (ibit = 0; ibit < nf->nf_nstates; ++ibit) { - if (!testbit(ss, ibit)) - continue; - st = &nf->nf_state[ibit]; - /* For all non-empty arcs from this state... */ - for (iarc = 0; iarc < st->st_narcs; iarc++) { - ar = &st->st_arc[iarc]; - if (ar->ar_label == EMPTY) - continue; - /* Look up in list of arcs from this state */ - for (jarc = 0; jarc < yy->ss_narcs; ++jarc) { - zz = &yy->ss_arc[jarc]; - if (ar->ar_label == zz->sa_label) - goto found; - } - /* Add new arc for this state */ - PyMem_RESIZE(yy->ss_arc, ss_arc, - yy->ss_narcs + 1); - if (yy->ss_arc == NULL) - Py_FatalError("out of mem"); - zz = &yy->ss_arc[yy->ss_narcs++]; - zz->sa_label = ar->ar_label; - zz->sa_bitset = newbitset(nbits); - zz->sa_arrow = -1; - found: ; - /* Add destination */ - addclosure(zz->sa_bitset, nf, ar->ar_arrow); - } - } - /* Now look up all the arrow states */ - for (jarc = 0; jarc < xx_state[istate].ss_narcs; jarc++) { - zz = &xx_state[istate].ss_arc[jarc]; - for (jstate = 0; jstate < xx_nstates; jstate++) { - if (samebitset(zz->sa_bitset, - xx_state[jstate].ss_ss, nbits)) { - zz->sa_arrow = jstate; - goto done; - } - } - PyMem_RESIZE(xx_state, ss_state, xx_nstates + 1); - if (xx_state == NULL) - Py_FatalError("out of mem"); - zz->sa_arrow = xx_nstates; - yy = &xx_state[xx_nstates++]; - yy->ss_ss = zz->sa_bitset; - yy->ss_narcs = 0; - yy->ss_arc = NULL; - yy->ss_deleted = 0; - yy->ss_finish = testbit(yy->ss_ss, nf->nf_finish); - done: ; - } - } - - if (Py_DebugFlag) - printssdfa(xx_nstates, xx_state, nbits, &gr->gr_ll, - "before minimizing"); - - simplify(xx_nstates, xx_state); - - if (Py_DebugFlag) - printssdfa(xx_nstates, xx_state, nbits, &gr->gr_ll, - "after minimizing"); - - convert(d, xx_nstates, xx_state); - - /* XXX cleanup */ -} - -static void -printssdfa(int xx_nstates, ss_state *xx_state, int nbits, - labellist *ll, char *msg) -{ - int i, ibit, iarc; - ss_state *yy; - ss_arc *zz; - - printf("Subset DFA %s\n", msg); - for (i = 0; i < xx_nstates; i++) { - yy = &xx_state[i]; - if (yy->ss_deleted) - continue; - printf(" Subset %d", i); - if (yy->ss_finish) - printf(" (finish)"); - printf(" { "); - for (ibit = 0; ibit < nbits; ibit++) { - if (testbit(yy->ss_ss, ibit)) - printf("%d ", ibit); - } - printf("}\n"); - for (iarc = 0; iarc < yy->ss_narcs; iarc++) { - zz = &yy->ss_arc[iarc]; - printf(" Arc to state %d, label %s\n", - zz->sa_arrow, - PyGrammar_LabelRepr( - &ll->ll_label[zz->sa_label])); - } - } -} - - -/* PART THREE -- SIMPLIFY DFA */ - -/* Simplify the DFA by repeatedly eliminating states that are - equivalent to another oner. This is NOT Algorithm 3.3 from - [Aho&Ullman 77]. It does not always finds the minimal DFA, - but it does usually make a much smaller one... (For an example - of sub-optimal behavior, try S: x a b+ | y a b+.) -*/ - -static int -samestate(ss_state *s1, ss_state *s2) -{ - int i; - - if (s1->ss_narcs != s2->ss_narcs || s1->ss_finish != s2->ss_finish) - return 0; - for (i = 0; i < s1->ss_narcs; i++) { - if (s1->ss_arc[i].sa_arrow != s2->ss_arc[i].sa_arrow || - s1->ss_arc[i].sa_label != s2->ss_arc[i].sa_label) - return 0; - } - return 1; -} - -static void -renamestates(int xx_nstates, ss_state *xx_state, int from, int to) -{ - int i, j; - - if (Py_DebugFlag) - printf("Rename state %d to %d.\n", from, to); - for (i = 0; i < xx_nstates; i++) { - if (xx_state[i].ss_deleted) - continue; - for (j = 0; j < xx_state[i].ss_narcs; j++) { - if (xx_state[i].ss_arc[j].sa_arrow == from) - xx_state[i].ss_arc[j].sa_arrow = to; - } - } -} - -static void -simplify(int xx_nstates, ss_state *xx_state) -{ - int changes; - int i, j; - - do { - changes = 0; - for (i = 1; i < xx_nstates; i++) { - if (xx_state[i].ss_deleted) - continue; - for (j = 0; j < i; j++) { - if (xx_state[j].ss_deleted) - continue; - if (samestate(&xx_state[i], &xx_state[j])) { - xx_state[i].ss_deleted++; - renamestates(xx_nstates, xx_state, - i, j); - changes++; - break; - } - } - } - } while (changes); -} - - -/* PART FOUR -- GENERATE PARSING TABLES */ - -/* Convert the DFA into a grammar that can be used by our parser */ - -static void -convert(dfa *d, int xx_nstates, ss_state *xx_state) -{ - int i, j; - ss_state *yy; - ss_arc *zz; - - for (i = 0; i < xx_nstates; i++) { - yy = &xx_state[i]; - if (yy->ss_deleted) - continue; - yy->ss_rename = addstate(d); - } - - for (i = 0; i < xx_nstates; i++) { - yy = &xx_state[i]; - if (yy->ss_deleted) - continue; - for (j = 0; j < yy->ss_narcs; j++) { - zz = &yy->ss_arc[j]; - addarc(d, yy->ss_rename, - xx_state[zz->sa_arrow].ss_rename, - zz->sa_label); - } - if (yy->ss_finish) - addarc(d, yy->ss_rename, yy->ss_rename, 0); - } - - d->d_initial = 0; -} - - -/* PART FIVE -- GLUE IT ALL TOGETHER */ - -static grammar * -maketables(nfagrammar *gr) -{ - int i; - nfa *nf; - dfa *d; - grammar *g; - - if (gr->gr_nnfas == 0) - return NULL; - g = newgrammar(gr->gr_nfa[0]->nf_type); - /* XXX first rule must be start rule */ - g->g_ll = gr->gr_ll; - - for (i = 0; i < gr->gr_nnfas; i++) { - nf = gr->gr_nfa[i]; - if (Py_DebugFlag) { - printf("Dump of NFA for '%s' ...\n", nf->nf_name); - dumpnfa(&gr->gr_ll, nf); - printf("Making DFA for '%s' ...\n", nf->nf_name); - } - d = adddfa(g, nf->nf_type, nf->nf_name); - makedfa(gr, gr->gr_nfa[i], d); - } - - return g; -} - -grammar * -pgen(node *n) -{ - nfagrammar *gr; - grammar *g; - - gr = metacompile(n); - g = maketables(gr); - translatelabels(g); - addfirstsets(g); - return g; -} - -grammar * -Py_pgen(node *n) -{ - return pgen(n); -} - -/* - -Description ------------ - -Input is a grammar in extended BNF (using * for repetition, + for -at-least-once repetition, [] for optional parts, | for alternatives and -() for grouping). This has already been parsed and turned into a parse -tree. - -Each rule is considered as a regular expression in its own right. -It is turned into a Non-deterministic Finite Automaton (NFA), which -is then turned into a Deterministic Finite Automaton (DFA), which is then -optimized to reduce the number of states. See [Aho&Ullman 77] chapter 3, -or similar compiler books (this technique is more often used for lexical -analyzers). - -The DFA's are used by the parser as parsing tables in a special way -that's probably unique. Before they are usable, the FIRST sets of all -non-terminals are computed. - -Reference ---------- - -[Aho&Ullman 77] - Aho&Ullman, Principles of Compiler Design, Addison-Wesley 1977 - (first edition) - -*/ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/pgenmain.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/pgenmain.c deleted file mode 100644 index 6c823c32..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/pgenmain.c +++ /dev/null @@ -1,212 +0,0 @@ - -/* Parser generator main program */ - -/* This expects a filename containing the grammar as argv[1] (UNIX) - or asks the console for such a file name (THINK C). - It writes its output on two files in the current directory: - - "graminit.c" gets the grammar as a bunch of initialized data - - "graminit.h" gets the grammar's non-terminals as #defines. - Error messages and status info during the generation process are - written to stdout, or sometimes to stderr. */ - -/* XXX TO DO: - - check for duplicate definitions of names (instead of fatal err) -*/ - -#include "Python.h" -#include "pgenheaders.h" -#include "grammar.h" -#include "node.h" -#include "parsetok.h" -#include "pgen.h" - -int Py_DebugFlag; -int Py_VerboseFlag; -int Py_IgnoreEnvironmentFlag; - -/* Forward */ -grammar *getgrammar(char *filename); -#ifdef THINK_C -int main(int, char **); -char *askfile(void); -#endif - -void -Py_Exit(int sts) -{ - //exit(sts); - - // Force crash instead of just terminating the process...this way - // we get a stack dump if something goes wrong - char* fatal = NULL; - *fatal = 1; -} - -int -main(int argc, char **argv) -{ - grammar *g; - FILE *fp; - char *filename, *graminit_h, *graminit_c; - -#ifdef THINK_C - filename = askfile(); - graminit_h = askfile(); - graminit_c = askfile(); -#else - if (argc != 4) { - fprintf(stderr, - "usage: %s grammar graminit.h graminit.c\n", argv[0]); - Py_Exit(2); - } - filename = argv[1]; - graminit_h = argv[2]; - graminit_c = argv[3]; -#endif - g = getgrammar(filename); - fp = fopen(graminit_c, "w"); - if (fp == NULL) { - perror(graminit_c); - Py_Exit(1); - } - if (Py_DebugFlag) - printf("Writing %s ...\n", graminit_c); - printgrammar(g, fp); - fclose(fp); - fp = fopen(graminit_h, "w"); - if (fp == NULL) { - perror(graminit_h); - Py_Exit(1); - } - if (Py_DebugFlag) - printf("Writing %s ...\n", graminit_h); - printnonterminals(g, fp); - fclose(fp); - Py_Exit(0); - return 0; /* Make gcc -Wall happy */ -} - -grammar * -getgrammar(char *filename) -{ - FILE *fp; - node *n; - grammar *g0, *g; - perrdetail err; - - fp = fopen(filename, "r"); - if (fp == NULL) { - perror(filename); - Py_Exit(1); - } - g0 = meta_grammar(); - n = PyParser_ParseFile(fp, filename, g0, g0->g_start, - (char *)NULL, (char *)NULL, &err); - fclose(fp); - if (n == NULL) { - fprintf(stderr, "Parsing error %d, line %d.\n", - err.error, err.lineno); - if (err.text != NULL) { - size_t i; - fprintf(stderr, "%s", err.text); - i = strlen(err.text); - if (i == 0 || err.text[i-1] != '\n') - fprintf(stderr, "\n"); - for (i = 0; i < err.offset; i++) { - if (err.text[i] == '\t') - putc('\t', stderr); - else - putc(' ', stderr); - } - fprintf(stderr, "^\n"); - PyMem_DEL(err.text); - } - Py_Exit(1); - } - g = pgen(n); - if (g == NULL) { - printf("Bad grammar.\n"); - Py_Exit(1); - } - return g; -} - -#ifdef THINK_C -char * -askfile(void) -{ - char buf[256]; - static char name[256]; - printf("Input file name: "); - if (fgets(buf, sizeof buf, stdin) == NULL) { - printf("EOF\n"); - Py_Exit(1); - } - /* XXX The (unsigned char *) case is needed by THINK C 3.0 */ - if (sscanf(/*(unsigned char *)*/buf, " %s ", name) != 1) { - printf("No file\n"); - Py_Exit(1); - } - return name; -} -#endif - -void -Py_FatalError(const char *msg) -{ - fprintf(stderr, "pgen: FATAL ERROR: %s\n", msg); - Py_Exit(1); -} - -#ifdef macintosh -/* ARGSUSED */ -int -guesstabsize(char *path) -{ - return 4; -} -#endif - -/* No-nonsense my_readline() for tokenizer.c */ - -char * -PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) -{ - size_t n = 1000; - char *p = PyMem_MALLOC(n); - char *q; - if (p == NULL) - return NULL; - fprintf(stderr, "%s", prompt); - q = fgets(p, n, sys_stdin); - if (q == NULL) { - *p = '\0'; - return p; - } - n = strlen(p); - if (n > 0 && p[n-1] != '\n') - p[n-1] = '\n'; - return PyMem_REALLOC(p, n+1); -} - -#ifdef WITH_UNIVERSAL_NEWLINES -/* No-nonsense fgets */ -char * -Py_UniversalNewlineFgets(char *buf, int n, FILE *stream, PyObject *fobj) -{ - return fgets(buf, n, stream); -} -#endif - - -#include - -void -PySys_WriteStderr(const char *format, ...) -{ - va_list va; - - va_start(va, format); - vfprintf(stderr, format, va); - va_end(va); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/printgrammar.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/printgrammar.c deleted file mode 100644 index 76ce49df..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/printgrammar.c +++ /dev/null @@ -1,113 +0,0 @@ - -/* Print a bunch of C initializers that represent a grammar */ - -#include "pgenheaders.h" -#include "grammar.h" - -/* Forward */ -static void printarcs(int, dfa *, FILE *); -static void printstates(grammar *, FILE *); -static void printdfas(grammar *, FILE *); -static void printlabels(grammar *, FILE *); - -void -printgrammar(grammar *g, FILE *fp) -{ - fprintf(fp, "#include \"pgenheaders.h\"\n"); - fprintf(fp, "#include \"grammar.h\"\n"); - printdfas(g, fp); - printlabels(g, fp); - fprintf(fp, "grammar _PyParser_Grammar = {\n"); - fprintf(fp, "\t%d,\n", g->g_ndfas); - fprintf(fp, "\tdfas,\n"); - fprintf(fp, "\t{%d, labels},\n", g->g_ll.ll_nlabels); - fprintf(fp, "\t%d\n", g->g_start); - fprintf(fp, "};\n"); -} - -void -printnonterminals(grammar *g, FILE *fp) -{ - dfa *d; - int i; - - d = g->g_dfa; - for (i = g->g_ndfas; --i >= 0; d++) - fprintf(fp, "#define %s %d\n", d->d_name, d->d_type); -} - -static void -printarcs(int i, dfa *d, FILE *fp) -{ - arc *a; - state *s; - int j, k; - - s = d->d_state; - for (j = 0; j < d->d_nstates; j++, s++) { - fprintf(fp, "static arc arcs_%d_%d[%d] = {\n", - i, j, s->s_narcs); - a = s->s_arc; - for (k = 0; k < s->s_narcs; k++, a++) - fprintf(fp, "\t{%d, %d},\n", a->a_lbl, a->a_arrow); - fprintf(fp, "};\n"); - } -} - -static void -printstates(grammar *g, FILE *fp) -{ - state *s; - dfa *d; - int i, j; - - d = g->g_dfa; - for (i = 0; i < g->g_ndfas; i++, d++) { - printarcs(i, d, fp); - fprintf(fp, "static state states_%d[%d] = {\n", - i, d->d_nstates); - s = d->d_state; - for (j = 0; j < d->d_nstates; j++, s++) - fprintf(fp, "\t{%d, arcs_%d_%d},\n", - s->s_narcs, i, j); - fprintf(fp, "};\n"); - } -} - -static void -printdfas(grammar *g, FILE *fp) -{ - dfa *d; - int i, j; - - printstates(g, fp); - fprintf(fp, "static dfa dfas[%d] = {\n", g->g_ndfas); - d = g->g_dfa; - for (i = 0; i < g->g_ndfas; i++, d++) { - fprintf(fp, "\t{%d, \"%s\", %d, %d, states_%d,\n", - d->d_type, d->d_name, d->d_initial, d->d_nstates, i); - fprintf(fp, "\t \""); - for (j = 0; j < NBYTES(g->g_ll.ll_nlabels); j++) - fprintf(fp, "\\%03o", d->d_first[j] & 0xff); - fprintf(fp, "\"},\n"); - } - fprintf(fp, "};\n"); -} - -static void -printlabels(grammar *g, FILE *fp) -{ - label *l; - int i; - - fprintf(fp, "static label labels[%d] = {\n", g->g_ll.ll_nlabels); - l = g->g_ll.ll_label; - for (i = g->g_ll.ll_nlabels; --i >= 0; l++) { - if (l->lb_str == NULL) - fprintf(fp, "\t{%d, 0},\n", l->lb_type); - else - fprintf(fp, "\t{%d, \"%s\"},\n", - l->lb_type, l->lb_str); - } - fprintf(fp, "};\n"); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/tokenizer.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/tokenizer.c deleted file mode 100644 index e8f82643..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/tokenizer.c +++ /dev/null @@ -1,1432 +0,0 @@ - -/* Tokenizer implementation */ - -#include "Python.h" -#include "pgenheaders.h" - -#include -#include - -#include "tokenizer.h" -#include "errcode.h" - -#ifndef PGEN -#include "unicodeobject.h" -#include "stringobject.h" -#include "fileobject.h" -#include "codecs.h" -#include "abstract.h" -#endif /* PGEN */ - -extern char *PyOS_Readline(FILE *, FILE *, char *); -/* Return malloc'ed string including trailing \n; - empty malloc'ed string for EOF; - NULL if interrupted */ - -/* Don't ever change this -- it would break the portability of Python code */ -#define TABSIZE 8 - -/* Convert a possibly signed character to a nonnegative int */ -/* XXX This assumes characters are 8 bits wide */ -#ifdef __CHAR_UNSIGNED__ -#define Py_CHARMASK(c) (c) -#else -#define Py_CHARMASK(c) ((c) & 0xff) -#endif - -/* Forward */ -static struct tok_state *tok_new(void); -static int tok_nextc(struct tok_state *tok); -static void tok_backup(struct tok_state *tok, int c); - -/* Token names */ - -char *_PyParser_TokenNames[] = { - "ENDMARKER", - "NAME", - "NUMBER", - "STRING", - "NEWLINE", - "INDENT", - "DEDENT", - "LPAR", - "RPAR", - "LSQB", - "RSQB", - "COLON", - "COMMA", - "SEMI", - "PLUS", - "MINUS", - "STAR", - "SLASH", - "VBAR", - "AMPER", - "LESS", - "GREATER", - "EQUAL", - "DOT", - "PERCENT", - "BACKQUOTE", - "LBRACE", - "RBRACE", - "EQEQUAL", - "NOTEQUAL", - "LESSEQUAL", - "GREATEREQUAL", - "TILDE", - "CIRCUMFLEX", - "LEFTSHIFT", - "RIGHTSHIFT", - "DOUBLESTAR", - "PLUSEQUAL", - "MINEQUAL", - "STAREQUAL", - "SLASHEQUAL", - "PERCENTEQUAL", - "AMPEREQUAL", - "VBAREQUAL", - "CIRCUMFLEXEQUAL", - "LEFTSHIFTEQUAL", - "RIGHTSHIFTEQUAL", - "DOUBLESTAREQUAL", - "DOUBLESLASH", - "DOUBLESLASHEQUAL", - /* This table must match the #defines in token.h! */ - "OP", - "", - "" -}; - - -/* Create and initialize a new tok_state structure */ - -static struct tok_state * -tok_new(void) -{ - struct tok_state *tok = PyMem_NEW(struct tok_state, 1); - if (tok == NULL) - return NULL; - tok->buf = tok->cur = tok->end = tok->inp = tok->start = NULL; - tok->done = E_OK; - tok->fp = NULL; - tok->tabsize = TABSIZE; - tok->indent = 0; - tok->indstack[0] = 0; - tok->atbol = 1; - tok->pendin = 0; - tok->prompt = tok->nextprompt = NULL; - tok->lineno = 0; - tok->level = 0; - tok->filename = NULL; - tok->altwarning = 0; - tok->alterror = 0; - tok->alttabsize = 1; - tok->altindstack[0] = 0; - tok->decoding_state = 0; - tok->decoding_erred = 0; - tok->read_coding_spec = 0; - tok->issued_encoding_warning = 0; - tok->encoding = NULL; - tok->cont_line = 0; -#ifndef PGEN - tok->decoding_readline = NULL; - tok->decoding_buffer = NULL; -#endif - return tok; -} - -#ifdef PGEN - -static char * -decoding_fgets(char *s, int size, struct tok_state *tok) -{ - return fgets(s, size, tok->fp); -} - -static int -decoding_feof(struct tok_state *tok) -{ - return feof(tok->fp); -} - -static const char * -decode_str(const char *str, struct tok_state *tok) -{ - return str; -} - -#else /* PGEN */ - -static char * -error_ret(struct tok_state *tok) /* XXX */ -{ - tok->decoding_erred = 1; - if (tok->fp != NULL && tok->buf != NULL) /* see PyTokenizer_Free */ - PyMem_DEL(tok->buf); - tok->buf = NULL; - return NULL; /* as if it were EOF */ -} - -static char * -new_string(const char *s, int len) -{ - char* result = PyMem_NEW(char, len + 1); - if (result != NULL) { - memcpy(result, s, len); - result[len] = '\0'; - } - return result; -} - -static char * -get_normal_name(char *s) /* for utf-8 and latin-1 */ -{ - char buf[13]; - int i; - for (i = 0; i < 12; i++) { - int c = s[i]; - if (c == '\0') break; - else if (c == '_') buf[i] = '-'; - else buf[i] = tolower(c); - } - buf[i] = '\0'; - if (strcmp(buf, "utf-8") == 0 || - strncmp(buf, "utf-8-", 6) == 0) return "utf-8"; - else if (strcmp(buf, "latin-1") == 0 || - strcmp(buf, "iso-8859-1") == 0 || - strcmp(buf, "iso-latin-1") == 0 || - strncmp(buf, "latin-1-", 8) == 0 || - strncmp(buf, "iso-8859-1-", 11) == 0 || - strncmp(buf, "iso-latin-1-", 12) == 0) return "iso-8859-1"; - else return s; -} - -/* Return the coding spec in S, or NULL if none is found. */ - -static char * -get_coding_spec(const char *s, int size) -{ - int i; - /* Coding spec must be in a comment, and that comment must be - * the only statement on the source code line. */ - for (i = 0; i < size - 6; i++) { - if (s[i] == '#') - break; - if (s[i] != ' ' && s[i] != '\t' && s[i] != '\014') - return NULL; - } - for (; i < size - 6; i++) { /* XXX inefficient search */ - const char* t = s + i; - if (strncmp(t, "coding", 6) == 0) { - const char* begin = NULL; - t += 6; - if (t[0] != ':' && t[0] != '=') - continue; - do { - t++; - } while (t[0] == '\x20' || t[0] == '\t'); - - begin = t; - while (isalnum((int)t[0]) || - t[0] == '-' || t[0] == '_' || t[0] == '.') - t++; - - if (begin < t) { - char* r = new_string(begin, t - begin); - char* q = get_normal_name(r); - if (r != q) { - PyMem_DEL(r); - r = new_string(q, strlen(q)); - } - return r; - } - } - } - return NULL; -} - -/* Check whether the line contains a coding spec. If it does, - invoke the set_readline function for the new encoding. - This function receives the tok_state and the new encoding. - Return 1 on success, 0 on failure. */ - -static int -check_coding_spec(const char* line, int size, struct tok_state *tok, - int set_readline(struct tok_state *, const char *)) -{ - char * cs; - int r = 1; - - if (tok->cont_line) - /* It's a continuation line, so it can't be a coding spec. */ - return 1; - cs = get_coding_spec(line, size); - if (cs != NULL) { - tok->read_coding_spec = 1; - if (tok->encoding == NULL) { - assert(tok->decoding_state == 1); /* raw */ - if (strcmp(cs, "utf-8") == 0 || - strcmp(cs, "iso-8859-1") == 0) { - tok->encoding = cs; - } else { -#ifdef Py_USING_UNICODE - r = set_readline(tok, cs); - if (r) { - tok->encoding = cs; - tok->decoding_state = -1; - } -#else - /* Without Unicode support, we cannot - process the coding spec. Since there - won't be any Unicode literals, that - won't matter. */ -#endif - } - } else { /* then, compare cs with BOM */ - r = (strcmp(tok->encoding, cs) == 0); - PyMem_DEL(cs); - } - } - return r; -} - -/* See whether the file starts with a BOM. If it does, - invoke the set_readline function with the new encoding. - Return 1 on success, 0 on failure. */ - -static int -check_bom(int get_char(struct tok_state *), - void unget_char(int, struct tok_state *), - int set_readline(struct tok_state *, const char *), - struct tok_state *tok) -{ - int ch = get_char(tok); - tok->decoding_state = 1; - if (ch == EOF) { - return 1; - } else if (ch == 0xEF) { - ch = get_char(tok); if (ch != 0xBB) goto NON_BOM; - ch = get_char(tok); if (ch != 0xBF) goto NON_BOM; -#if 0 - /* Disable support for UTF-16 BOMs until a decision - is made whether this needs to be supported. */ - } else if (ch == 0xFE) { - ch = get_char(tok); if (ch != 0xFF) goto NON_BOM; - if (!set_readline(tok, "utf-16-be")) return 0; - tok->decoding_state = -1; - } else if (ch == 0xFF) { - ch = get_char(tok); if (ch != 0xFE) goto NON_BOM; - if (!set_readline(tok, "utf-16-le")) return 0; - tok->decoding_state = -1; -#endif - } else { - unget_char(ch, tok); - return 1; - } - tok->encoding = new_string("utf-8", 5); /* resulting is in utf-8 */ - return 1; - NON_BOM: - /* any token beginning with '\xEF', '\xFE', '\xFF' is a bad token */ - unget_char(0xFF, tok); /* XXX this will cause a syntax error */ - return 1; -} - -/* Read a line of text from TOK into S, using the stream in TOK. - Return NULL on failure, else S. */ - -static char * -fp_readl(char *s, int size, struct tok_state *tok) -{ -#ifndef Py_USING_UNICODE - /* In a non-Unicode built, this should never be called. */ - Py_FatalError("fp_readl should not be called in this build."); - return NULL; /* Keep compiler happy (not reachable) */ -#else - PyObject* utf8; - PyObject* buf = tok->decoding_buffer; - if (buf == NULL) { - /* Ask for one less byte so we can terminate it */ - PyObject *args = Py_BuildValue("(i)", size-1); - if (args == NULL) - return error_ret(tok); - buf = PyObject_Call(tok->decoding_readline, args, NULL); - Py_DECREF(args); - if (buf == NULL) - return error_ret(tok); - } else { - tok->decoding_buffer = NULL; - } - utf8 = PyUnicode_AsUTF8String(buf); - Py_DECREF(buf); - if (utf8 == NULL) - return error_ret(tok); - else { - const char* str = PyString_AsString(utf8); - assert(strlen(str) < (size_t)size); /* XXX */ - strcpy(s, str); - Py_DECREF(utf8); - if (s[0] == '\0') return NULL; /* EOF */ - return s; - } -#endif -} - -/* Set the readline function for TOK to a StreamReader's - readline function. The StreamReader is named ENC. - - This function is called from check_bom and check_coding_spec. - - ENC is usually identical to the future value of tok->encoding, - except for the (currently unsupported) case of UTF-16. - - Return 1 on success, 0 on failure. */ - -static int -fp_setreadl(struct tok_state *tok, const char* enc) -{ - PyObject *reader, *stream, *readline; - - /* XXX: constify filename argument. */ - stream = PyFile_FromFile(tok->fp, (char*)tok->filename, "rb", NULL); - if (stream == NULL) - return 0; - - reader = PyCodec_StreamReader(enc, stream, NULL); - Py_DECREF(stream); - if (reader == NULL) - return 0; - - readline = PyObject_GetAttrString(reader, "readline"); - Py_DECREF(reader); - if (readline == NULL) - return 0; - - tok->decoding_readline = readline; - return 1; -} - -/* Fetch the next byte from TOK. */ - -static int fp_getc(struct tok_state *tok) { - return getc(tok->fp); -} - -/* Unfetch the last byte back into TOK. */ - -static void fp_ungetc(int c, struct tok_state *tok) { - ungetc(c, tok->fp); -} - -/* Read a line of input from TOK. Determine encoding - if necessary. */ - -static char * -decoding_fgets(char *s, int size, struct tok_state *tok) -{ - char *line = NULL; - int warn = 0, badchar = 0; - for (;;) { - if (tok->decoding_state < 0) { - /* We already have a codec associated with - this input. */ - line = fp_readl(s, size, tok); - break; - } else if (tok->decoding_state > 0) { - /* We want a 'raw' read. */ - line = Py_UniversalNewlineFgets(s, size, - tok->fp, NULL); - warn = 1; - break; - } else { - /* We have not yet determined the encoding. - If an encoding is found, use the file-pointer - reader functions from now on. */ - if (!check_bom(fp_getc, fp_ungetc, fp_setreadl, tok)) - return error_ret(tok); - assert(tok->decoding_state != 0); - } - } - if (line != NULL && tok->lineno < 2 && !tok->read_coding_spec) { - if (!check_coding_spec(line, strlen(line), tok, fp_setreadl)) { - return error_ret(tok); - } - } -#ifndef PGEN - if (warn && line && !tok->issued_encoding_warning && !tok->encoding) { - unsigned char *c; - for (c = (unsigned char *)line; *c; c++) - if (*c > 127) { - badchar = *c; - break; - } - } - if (badchar) { - char buf[500]; - /* Need to add 1 to the line number, since this line - has not been counted, yet. */ - sprintf(buf, - "Non-ASCII character '\\x%.2x' " - "in file %.200s on line %i, " - "but no encoding declared; " - "see http://www.python.org/peps/pep-0263.html for details", - badchar, tok->filename, tok->lineno + 1); - /* We don't use PyErr_WarnExplicit() here because - printing the line in question to e.g. a log file - could result in sensitive information being - exposed. */ - PyErr_Warn(PyExc_DeprecationWarning, buf); - tok->issued_encoding_warning = 1; - } -#endif - return line; -} - -static int -decoding_feof(struct tok_state *tok) -{ - if (tok->decoding_state >= 0) { - return feof(tok->fp); - } else { - PyObject* buf = tok->decoding_buffer; - if (buf == NULL) { - PyObject *args = PyTuple_New(0); - if (args == NULL) { - error_ret(tok); - return 1; - } - buf = PyObject_Call(tok->decoding_readline, - args, NULL); - Py_DECREF(args); - if (buf == NULL) { - error_ret(tok); - return 1; - } else { - tok->decoding_buffer = buf; - } - } - return PyObject_Length(buf) == 0; - } -} - -/* Fetch a byte from TOK, using the string buffer. */ - -static int buf_getc(struct tok_state *tok) { - return Py_CHARMASK(*tok->str++); -} - -/* Unfetch a byte from TOK, using the string buffer. */ - -static void buf_ungetc(int c, struct tok_state *tok) { - tok->str--; - assert(Py_CHARMASK(*tok->str) == c); /* tok->cur may point to read-only segment */ -} - -/* Set the readline function for TOK to ENC. For the string-based - tokenizer, this means to just record the encoding. */ - -static int buf_setreadl(struct tok_state *tok, const char* enc) { - tok->enc = enc; - return 1; -} - -/* Return a UTF-8 encoding Python string object from the - C byte string STR, which is encoded with ENC. */ - -#ifdef Py_USING_UNICODE -static PyObject * -translate_into_utf8(const char* str, const char* enc) { - PyObject *utf8; - PyObject* buf = PyUnicode_Decode(str, strlen(str), enc, NULL); - if (buf == NULL) - return NULL; - utf8 = PyUnicode_AsUTF8String(buf); - Py_DECREF(buf); - return utf8; -} -#endif - -/* Decode a byte string STR for use as the buffer of TOK. - Look for encoding declarations inside STR, and record them - inside TOK. */ - -static const char * -decode_str(const char *str, struct tok_state *tok) -{ - PyObject* utf8 = NULL; - const char *s; - int lineno = 0; - tok->enc = NULL; - tok->str = str; - if (!check_bom(buf_getc, buf_ungetc, buf_setreadl, tok)) - return NULL; - str = tok->str; /* string after BOM if any */ - assert(str); -#ifdef Py_USING_UNICODE - if (tok->enc != NULL) { - utf8 = translate_into_utf8(str, tok->enc); - if (utf8 == NULL) - return NULL; - str = PyString_AsString(utf8); - } -#endif - for (s = str;; s++) { - if (*s == '\0') break; - else if (*s == '\n') { - lineno++; - if (lineno == 2) break; - } - } - tok->enc = NULL; - if (!check_coding_spec(str, s - str, tok, buf_setreadl)) - return NULL; -#ifdef Py_USING_UNICODE - if (tok->enc != NULL) { - assert(utf8 == NULL); - utf8 = translate_into_utf8(str, tok->enc); - if (utf8 == NULL) - return NULL; - str = PyString_AsString(utf8); - } -#endif - assert(tok->decoding_buffer == NULL); - tok->decoding_buffer = utf8; /* CAUTION */ - return str; -} - -#endif /* PGEN */ - -/* Set up tokenizer for string */ - -struct tok_state * -PyTokenizer_FromString(const char *str) -{ - struct tok_state *tok = tok_new(); - if (tok == NULL) - return NULL; - str = (char *)decode_str(str, tok); - if (str == NULL) - return NULL; - /* XXX: constify members. */ - tok->buf = tok->cur = tok->end = tok->inp = (char*)str; - return tok; -} - - -/* Set up tokenizer for file */ - -struct tok_state * -PyTokenizer_FromFile(FILE *fp, char *ps1, char *ps2) -{ - struct tok_state *tok = tok_new(); - if (tok == NULL) - return NULL; - if ((tok->buf = PyMem_NEW(char, BUFSIZ)) == NULL) { - PyMem_DEL(tok); - return NULL; - } - tok->cur = tok->inp = tok->buf; - tok->end = tok->buf + BUFSIZ; - tok->fp = fp; - tok->prompt = ps1; - tok->nextprompt = ps2; - return tok; -} - - -/* Free a tok_state structure */ - -void -PyTokenizer_Free(struct tok_state *tok) -{ - if (tok->encoding != NULL) - PyMem_DEL(tok->encoding); -#ifndef PGEN - Py_XDECREF(tok->decoding_readline); - Py_XDECREF(tok->decoding_buffer); -#endif - if (tok->fp != NULL && tok->buf != NULL) - PyMem_DEL(tok->buf); - PyMem_DEL(tok); -} - - -/* Get next char, updating state; error code goes into tok->done */ - -static int -tok_nextc(register struct tok_state *tok) -{ - for (;;) { - if (tok->cur != tok->inp) { - return Py_CHARMASK(*tok->cur++); /* Fast path */ - } - if (tok->done != E_OK) - return EOF; - if (tok->fp == NULL) { - char *end = strchr(tok->inp, '\n'); - if (end != NULL) - end++; - else { - end = strchr(tok->inp, '\0'); - if (end == tok->inp) { - tok->done = E_EOF; - return EOF; - } - } - if (tok->start == NULL) - tok->buf = tok->cur; - tok->lineno++; - tok->inp = end; - return Py_CHARMASK(*tok->cur++); - } - if (tok->prompt != NULL) { - char *new = PyOS_Readline(stdin, stdout, tok->prompt); - if (tok->nextprompt != NULL) - tok->prompt = tok->nextprompt; - if (new == NULL) - tok->done = E_INTR; - else if (*new == '\0') { - PyMem_FREE(new); - tok->done = E_EOF; - } - else if (tok->start != NULL) { - size_t start = tok->start - tok->buf; - size_t oldlen = tok->cur - tok->buf; - size_t newlen = oldlen + strlen(new); - char *buf = tok->buf; - PyMem_RESIZE(buf, char, newlen+1); - tok->lineno++; - if (buf == NULL) { - PyMem_DEL(tok->buf); - tok->buf = NULL; - PyMem_FREE(new); - tok->done = E_NOMEM; - return EOF; - } - tok->buf = buf; - tok->cur = tok->buf + oldlen; - strcpy(tok->buf + oldlen, new); - PyMem_FREE(new); - tok->inp = tok->buf + newlen; - tok->end = tok->inp + 1; - tok->start = tok->buf + start; - } - else { - tok->lineno++; - if (tok->buf != NULL) - PyMem_DEL(tok->buf); - tok->buf = new; - tok->cur = tok->buf; - tok->inp = strchr(tok->buf, '\0'); - tok->end = tok->inp + 1; - } - } - else { - int done = 0; - int cur = 0; - char *pt; - if (tok->start == NULL) { - if (tok->buf == NULL) { - tok->buf = PyMem_NEW(char, BUFSIZ); - if (tok->buf == NULL) { - tok->done = E_NOMEM; - return EOF; - } - tok->end = tok->buf + BUFSIZ; - } - if (decoding_fgets(tok->buf, (int)(tok->end - tok->buf), - tok) == NULL) { - tok->done = E_EOF; - done = 1; - } - else { - tok->done = E_OK; - tok->inp = strchr(tok->buf, '\0'); - done = tok->inp[-1] == '\n'; - } - } - else { - cur = tok->cur - tok->buf; - if (decoding_feof(tok)) { - tok->done = E_EOF; - done = 1; - } - else - tok->done = E_OK; - } - tok->lineno++; - /* Read until '\n' or EOF */ - while (!done) { - int curstart = tok->start == NULL ? -1 : - tok->start - tok->buf; - int curvalid = tok->inp - tok->buf; - int newsize = curvalid + BUFSIZ; - char *newbuf = tok->buf; - PyMem_RESIZE(newbuf, char, newsize); - if (newbuf == NULL) { - tok->done = E_NOMEM; - tok->cur = tok->inp; - return EOF; - } - tok->buf = newbuf; - tok->inp = tok->buf + curvalid; - tok->end = tok->buf + newsize; - tok->start = curstart < 0 ? NULL : - tok->buf + curstart; - if (decoding_fgets(tok->inp, - (int)(tok->end - tok->inp), - tok) == NULL) { - /* Last line does not end in \n, - fake one */ - strcpy(tok->inp, "\n"); - } - tok->inp = strchr(tok->inp, '\0'); - done = tok->inp[-1] == '\n'; - } - tok->cur = tok->buf + cur; -#ifndef macintosh - /* replace "\r\n" with "\n" */ - /* For Mac we leave the \r, giving a syntax error */ - pt = tok->inp - 2; - if (pt >= tok->buf && *pt == '\r') { - *pt++ = '\n'; - *pt = '\0'; - tok->inp = pt; - } -#endif - } - if (tok->done != E_OK) { - if (tok->prompt != NULL) - PySys_WriteStderr("\n"); - tok->cur = tok->inp; - return EOF; - } - } - /*NOTREACHED*/ -} - - -/* Back-up one character */ - -static void -tok_backup(register struct tok_state *tok, register int c) -{ - if (c != EOF) { - if (--tok->cur < tok->buf) - Py_FatalError("tok_backup: begin of buffer"); - if (*tok->cur != c) - *tok->cur = c; - } -} - - -/* Return the token corresponding to a single character */ - -int -PyToken_OneChar(int c) -{ - switch (c) { - case '(': return LPAR; - case ')': return RPAR; - case '[': return LSQB; - case ']': return RSQB; - case ':': return COLON; - case ',': return COMMA; - case ';': return SEMI; - case '+': return PLUS; - case '-': return MINUS; - case '*': return STAR; - case '/': return SLASH; - case '|': return VBAR; - case '&': return AMPER; - case '<': return LESS; - case '>': return GREATER; - case '=': return EQUAL; - case '.': return DOT; - case '%': return PERCENT; - case '`': return BACKQUOTE; - case '{': return LBRACE; - case '}': return RBRACE; - case '^': return CIRCUMFLEX; - case '~': return TILDE; - default: return OP; - } -} - - -int -PyToken_TwoChars(int c1, int c2) -{ - switch (c1) { - case '=': - switch (c2) { - case '=': return EQEQUAL; - } - break; - case '!': - switch (c2) { - case '=': return NOTEQUAL; - } - break; - case '<': - switch (c2) { - case '>': return NOTEQUAL; - case '=': return LESSEQUAL; - case '<': return LEFTSHIFT; - } - break; - case '>': - switch (c2) { - case '=': return GREATEREQUAL; - case '>': return RIGHTSHIFT; - } - break; - case '+': - switch (c2) { - case '=': return PLUSEQUAL; - } - break; - case '-': - switch (c2) { - case '=': return MINEQUAL; - } - break; - case '*': - switch (c2) { - case '*': return DOUBLESTAR; - case '=': return STAREQUAL; - } - break; - case '/': - switch (c2) { - case '/': return DOUBLESLASH; - case '=': return SLASHEQUAL; - } - break; - case '|': - switch (c2) { - case '=': return VBAREQUAL; - } - break; - case '%': - switch (c2) { - case '=': return PERCENTEQUAL; - } - break; - case '&': - switch (c2) { - case '=': return AMPEREQUAL; - } - break; - case '^': - switch (c2) { - case '=': return CIRCUMFLEXEQUAL; - } - break; - } - return OP; -} - -int -PyToken_ThreeChars(int c1, int c2, int c3) -{ - switch (c1) { - case '<': - switch (c2) { - case '<': - switch (c3) { - case '=': - return LEFTSHIFTEQUAL; - } - break; - } - break; - case '>': - switch (c2) { - case '>': - switch (c3) { - case '=': - return RIGHTSHIFTEQUAL; - } - break; - } - break; - case '*': - switch (c2) { - case '*': - switch (c3) { - case '=': - return DOUBLESTAREQUAL; - } - break; - } - break; - case '/': - switch (c2) { - case '/': - switch (c3) { - case '=': - return DOUBLESLASHEQUAL; - } - break; - } - break; - } - return OP; -} - -static int -indenterror(struct tok_state *tok) -{ - if (tok->alterror) { - tok->done = E_TABSPACE; - tok->cur = tok->inp; - return 1; - } - if (tok->altwarning) { - PySys_WriteStderr("%s: inconsistent use of tabs and spaces " - "in indentation\n", tok->filename); - tok->altwarning = 0; - } - return 0; -} - - -/* Get next token, after space stripping etc. */ - -static int -tok_get(register struct tok_state *tok, char **p_start, char **p_end) -{ - register int c; - int blankline; - - *p_start = *p_end = NULL; - nextline: - tok->start = NULL; - blankline = 0; - - /* Get indentation level */ - if (tok->atbol) { - register int col = 0; - register int altcol = 0; - tok->atbol = 0; - for (;;) { - c = tok_nextc(tok); - if (c == ' ') - col++, altcol++; - else if (c == '\t') { - col = (col/tok->tabsize + 1) * tok->tabsize; - altcol = (altcol/tok->alttabsize + 1) - * tok->alttabsize; - } - else if (c == '\014') /* Control-L (formfeed) */ - col = altcol = 0; /* For Emacs users */ - else - break; - } - tok_backup(tok, c); - if (c == '#' || c == '\n') { - /* Lines with only whitespace and/or comments - shouldn't affect the indentation and are - not passed to the parser as NEWLINE tokens, - except *totally* empty lines in interactive - mode, which signal the end of a command group. */ - if (col == 0 && c == '\n' && tok->prompt != NULL) - blankline = 0; /* Let it through */ - else - blankline = 1; /* Ignore completely */ - /* We can't jump back right here since we still - may need to skip to the end of a comment */ - } - if (!blankline && tok->level == 0) { - if (col == tok->indstack[tok->indent]) { - /* No change */ - if (altcol != tok->altindstack[tok->indent]) { - if (indenterror(tok)) - return ERRORTOKEN; - } - } - else if (col > tok->indstack[tok->indent]) { - /* Indent -- always one */ - if (tok->indent+1 >= MAXINDENT) { - tok->done = E_TOODEEP; - tok->cur = tok->inp; - return ERRORTOKEN; - } - if (altcol <= tok->altindstack[tok->indent]) { - if (indenterror(tok)) - return ERRORTOKEN; - } - tok->pendin++; - tok->indstack[++tok->indent] = col; - tok->altindstack[tok->indent] = altcol; - } - else /* col < tok->indstack[tok->indent] */ { - /* Dedent -- any number, must be consistent */ - while (tok->indent > 0 && - col < tok->indstack[tok->indent]) { - tok->pendin--; - tok->indent--; - } - if (col != tok->indstack[tok->indent]) { - tok->done = E_DEDENT; - tok->cur = tok->inp; - return ERRORTOKEN; - } - if (altcol != tok->altindstack[tok->indent]) { - if (indenterror(tok)) - return ERRORTOKEN; - } - } - } - } - - tok->start = tok->cur; - - /* Return pending indents/dedents */ - if (tok->pendin != 0) { - if (tok->pendin < 0) { - tok->pendin++; - return DEDENT; - } - else { - tok->pendin--; - return INDENT; - } - } - - again: - tok->start = NULL; - /* Skip spaces */ - do { - c = tok_nextc(tok); - } while (c == ' ' || c == '\t' || c == '\014'); - - /* Set start of current token */ - tok->start = tok->cur - 1; - - /* Skip comment, while looking for tab-setting magic */ - if (c == '#') { - static char *tabforms[] = { - "tab-width:", /* Emacs */ - ":tabstop=", /* vim, full form */ - ":ts=", /* vim, abbreviated form */ - "set tabsize=", /* will vi never die? */ - /* more templates can be added here to support other editors */ - }; - char cbuf[80]; - char *tp, **cp; - tp = cbuf; - do { - *tp++ = c = tok_nextc(tok); - } while (c != EOF && c != '\n' && - tp - cbuf + 1 < sizeof(cbuf)); - *tp = '\0'; - for (cp = tabforms; - cp < tabforms + sizeof(tabforms)/sizeof(tabforms[0]); - cp++) { - if ((tp = strstr(cbuf, *cp))) { - int newsize = atoi(tp + strlen(*cp)); - - if (newsize >= 1 && newsize <= 40) { - tok->tabsize = newsize; - if (Py_VerboseFlag) - PySys_WriteStderr( - "Tab size set to %d\n", - newsize); - } - } - } - while (c != EOF && c != '\n') - c = tok_nextc(tok); - } - - /* Check for EOF and errors now */ - if (c == EOF) { - return tok->done == E_EOF ? ENDMARKER : ERRORTOKEN; - } - - /* Identifier (most frequent token!) */ - if (isalpha(c) || c == '_') { - /* Process r"", u"" and ur"" */ - switch (c) { - case 'r': - case 'R': - c = tok_nextc(tok); - if (c == '"' || c == '\'') - goto letter_quote; - break; - case 'u': - case 'U': - c = tok_nextc(tok); - if (c == 'r' || c == 'R') - c = tok_nextc(tok); - if (c == '"' || c == '\'') - goto letter_quote; - break; - } - while (isalnum(c) || c == '_') { - c = tok_nextc(tok); - } - tok_backup(tok, c); - *p_start = tok->start; - *p_end = tok->cur; - return NAME; - } - - /* Newline */ - if (c == '\n') { - tok->atbol = 1; - if (blankline || tok->level > 0) - goto nextline; - *p_start = tok->start; - *p_end = tok->cur - 1; /* Leave '\n' out of the string */ - tok->cont_line = 0; - return NEWLINE; - } - -#ifdef macintosh - if (c == '\r') { - PySys_WriteStderr( - "File contains \\r characters (incorrect line endings?)\n"); - tok->done = E_TOKEN; - tok->cur = tok->inp; - return ERRORTOKEN; - } -#endif - /* Period or number starting with period? */ - if (c == '.') { - c = tok_nextc(tok); - if (isdigit(c)) { - goto fraction; - } - else { - tok_backup(tok, c); - *p_start = tok->start; - *p_end = tok->cur; - return DOT; - } - } - - /* Number */ - if (isdigit(c)) { - if (c == '0') { - /* Hex or octal -- maybe. */ - c = tok_nextc(tok); - if (c == '.') - goto fraction; -#ifndef WITHOUT_COMPLEX - if (c == 'j' || c == 'J') - goto imaginary; -#endif - if (c == 'x' || c == 'X') { - /* Hex */ - do { - c = tok_nextc(tok); - } while (isxdigit(c)); - } - else { - int found_decimal = 0; - /* Octal; c is first char of it */ - /* There's no 'isoctdigit' macro, sigh */ - while ('0' <= c && c < '8') { - c = tok_nextc(tok); - } - if (isdigit(c)) { - found_decimal = 1; - do { - c = tok_nextc(tok); - } while (isdigit(c)); - } - if (c == '.') - goto fraction; - else if (c == 'e' || c == 'E') - goto exponent; -#ifndef WITHOUT_COMPLEX - else if (c == 'j' || c == 'J') - goto imaginary; -#endif - else if (found_decimal) { - tok->done = E_TOKEN; - tok_backup(tok, c); - return ERRORTOKEN; - } - } - if (c == 'l' || c == 'L') - c = tok_nextc(tok); - } - else { - /* Decimal */ - do { - c = tok_nextc(tok); - } while (isdigit(c)); - if (c == 'l' || c == 'L') - c = tok_nextc(tok); - else { - /* Accept floating point numbers. */ - if (c == '.') { - fraction: - /* Fraction */ - do { - c = tok_nextc(tok); - } while (isdigit(c)); - } - if (c == 'e' || c == 'E') { - exponent: - /* Exponent part */ - c = tok_nextc(tok); - if (c == '+' || c == '-') - c = tok_nextc(tok); - if (!isdigit(c)) { - tok->done = E_TOKEN; - tok_backup(tok, c); - return ERRORTOKEN; - } - do { - c = tok_nextc(tok); - } while (isdigit(c)); - } -#ifndef WITHOUT_COMPLEX - if (c == 'j' || c == 'J') - /* Imaginary part */ - imaginary: - c = tok_nextc(tok); -#endif - } - } - tok_backup(tok, c); - *p_start = tok->start; - *p_end = tok->cur; - return NUMBER; - } - - letter_quote: - /* String */ - if (c == '\'' || c == '"') { - int quote2 = tok->cur - tok->start + 1; - int quote = c; - int triple = 0; - int tripcount = 0; - for (;;) { - c = tok_nextc(tok); - if (c == '\n') { - if (!triple) { - tok->done = E_EOLS; - tok_backup(tok, c); - return ERRORTOKEN; - } - tripcount = 0; - tok->cont_line = 1; /* multiline string. */ - } - else if (c == EOF) { - if (triple) - tok->done = E_EOFS; - else - tok->done = E_EOLS; - tok->cur = tok->inp; - return ERRORTOKEN; - } - else if (c == quote) { - tripcount++; - if (tok->cur - tok->start == quote2) { - c = tok_nextc(tok); - if (c == quote) { - triple = 1; - tripcount = 0; - continue; - } - tok_backup(tok, c); - } - if (!triple || tripcount == 3) - break; - } - else if (c == '\\') { - tripcount = 0; - c = tok_nextc(tok); - if (c == EOF) { - tok->done = E_EOLS; - tok->cur = tok->inp; - return ERRORTOKEN; - } - } - else - tripcount = 0; - } - *p_start = tok->start; - *p_end = tok->cur; - return STRING; - } - - /* Line continuation */ - if (c == '\\') { - c = tok_nextc(tok); - if (c != '\n') { - tok->done = E_TOKEN; - tok->cur = tok->inp; - return ERRORTOKEN; - } - tok->cont_line = 1; - goto again; /* Read next line */ - } - - /* Check for two-character token */ - { - int c2 = tok_nextc(tok); - int token = PyToken_TwoChars(c, c2); - if (token != OP) { - int c3 = tok_nextc(tok); - int token3 = PyToken_ThreeChars(c, c2, c3); - if (token3 != OP) { - token = token3; - } else { - tok_backup(tok, c3); - } - *p_start = tok->start; - *p_end = tok->cur; - return token; - } - tok_backup(tok, c2); - } - - /* Keep track of parentheses nesting level */ - switch (c) { - case '(': - case '[': - case '{': - tok->level++; - break; - case ')': - case ']': - case '}': - tok->level--; - break; - } - - /* Punctuation character */ - *p_start = tok->start; - *p_end = tok->cur; - return PyToken_OneChar(c); -} - -int -PyTokenizer_Get(struct tok_state *tok, char **p_start, char **p_end) -{ - int result = tok_get(tok, p_start, p_end); - if (tok->decoding_erred) { - result = ERRORTOKEN; - tok->done = E_DECODE; - } - return result; -} - -#ifdef Py_DEBUG - -void -tok_dump(int type, char *start, char *end) -{ - printf("%s", _PyParser_TokenNames[type]); - if (type == NAME || type == NUMBER || type == STRING || type == OP) - printf("(%.*s)", (int)(end - start), start); -} - -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/tokenizer.h b/SDKs/XPlatform/Cypython-2.3.3/Parser/tokenizer.h deleted file mode 100644 index 342e7fa9..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/tokenizer.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef Py_TOKENIZER_H -#define Py_TOKENIZER_H -#ifdef __cplusplus -extern "C" { -#endif - -#include "object.h" - -/* Tokenizer interface */ - -#include "token.h" /* For token types */ - -#define MAXINDENT 100 /* Max indentation level */ - -/* Tokenizer state */ -struct tok_state { - /* Input state; buf <= cur <= inp <= end */ - /* NB an entire line is held in the buffer */ - char *buf; /* Input buffer, or NULL; malloc'ed if fp != NULL */ - char *cur; /* Next character in buffer */ - char *inp; /* End of data in buffer */ - char *end; /* End of input buffer if buf != NULL */ - char *start; /* Start of current token if not NULL */ - int done; /* E_OK normally, E_EOF at EOF, otherwise error code */ - /* NB If done != E_OK, cur must be == inp!!! */ - FILE *fp; /* Rest of input; NULL if tokenizing a string */ - int tabsize; /* Tab spacing */ - int indent; /* Current indentation index */ - int indstack[MAXINDENT]; /* Stack of indents */ - int atbol; /* Nonzero if at begin of new line */ - int pendin; /* Pending indents (if > 0) or dedents (if < 0) */ - char *prompt, *nextprompt; /* For interactive prompting */ - int lineno; /* Current line number */ - int level; /* () [] {} Parentheses nesting level */ - /* Used to allow free continuations inside them */ - /* Stuff for checking on different tab sizes */ - const char *filename; /* For error messages */ - int altwarning; /* Issue warning if alternate tabs don't match */ - int alterror; /* Issue error if alternate tabs don't match */ - int alttabsize; /* Alternate tab spacing */ - int altindstack[MAXINDENT]; /* Stack of alternate indents */ - /* Stuff for PEP 0263 */ - int decoding_state; /* -1:decoding, 0:init, 1:raw */ - int decoding_erred; /* whether erred in decoding */ - int read_coding_spec; /* whether 'coding:...' has been read */ - int issued_encoding_warning; /* whether non-ASCII warning was issued */ - char *encoding; - int cont_line; /* whether we are in a continuation line. */ -#ifndef PGEN - PyObject *decoding_readline; /* codecs.open(...).readline */ - PyObject *decoding_buffer; -#endif - const char* enc; - const char* str; -}; - -extern struct tok_state *PyTokenizer_FromString(const char *); -extern struct tok_state *PyTokenizer_FromFile(FILE *, char *, char *); -extern void PyTokenizer_Free(struct tok_state *); -extern int PyTokenizer_Get(struct tok_state *, char **, char **); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_TOKENIZER_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Parser/tokenizer_pgen.c b/SDKs/XPlatform/Cypython-2.3.3/Parser/tokenizer_pgen.c deleted file mode 100644 index ecbda9c4..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Parser/tokenizer_pgen.c +++ /dev/null @@ -1,2 +0,0 @@ -#define PGEN -#include "tokenizer.c" diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/.cvsignore b/SDKs/XPlatform/Cypython-2.3.3/Python/.cvsignore deleted file mode 100644 index 100224c1..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -add2lib diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/atof.c b/SDKs/XPlatform/Cypython-2.3.3/Python/atof.c deleted file mode 100644 index c83c3c1c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/atof.c +++ /dev/null @@ -1,50 +0,0 @@ - -/* Just in case you haven't got an atof() around... - This one doesn't check for bad syntax or overflow, - and is slow and inaccurate. - But it's good enough for the occasional string literal... */ - -#include "pyconfig.h" - -#include - -double atof(char *s) -{ - double a = 0.0; - int e = 0; - int c; - while ((c = *s++) != '\0' && isdigit(c)) { - a = a*10.0 + (c - '0'); - } - if (c == '.') { - while ((c = *s++) != '\0' && isdigit(c)) { - a = a*10.0 + (c - '0'); - e = e-1; - } - } - if (c == 'e' || c == 'E') { - int sign = 1; - int i = 0; - c = *s++; - if (c == '+') - c = *s++; - else if (c == '-') { - c = *s++; - sign = -1; - } - while (isdigit(c)) { - i = i*10 + (c - '0'); - c = *s++; - } - e += i*sign; - } - while (e > 0) { - a *= 10.0; - e--; - } - while (e < 0) { - a *= 0.1; - e++; - } - return a; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/bltinmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Python/bltinmodule.c deleted file mode 100644 index ece30f11..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/bltinmodule.c +++ /dev/null @@ -1,2406 +0,0 @@ - -/* Built-in functions */ - -#include "Python.h" - -#include "node.h" -#include "compile.h" -#include "eval.h" - -#include - -#ifdef RISCOS -#include "unixstuff.h" -#endif - -/* The default encoding used by the platform file system APIs - Can remain NULL for all platforms that don't have such a concept -*/ -#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) -const char *Py_FileSystemDefaultEncoding = "mbcs"; -#elif defined(__APPLE__) -const char *Py_FileSystemDefaultEncoding = "utf-8"; -#else -const char *Py_FileSystemDefaultEncoding = NULL; /* use default */ -#endif - -/* Forward */ -static PyObject *filterstring(PyObject *, PyObject *); -#ifdef Py_USING_UNICODE -static PyObject *filterunicode(PyObject *, PyObject *); -#endif -static PyObject *filtertuple (PyObject *, PyObject *); - -static PyObject * -builtin___import__(PyObject *self, PyObject *args) -{ - char *name; - PyObject *globals = NULL; - PyObject *locals = NULL; - PyObject *fromlist = NULL; - - if (!PyArg_ParseTuple(args, "s|OOO:__import__", - &name, &globals, &locals, &fromlist)) - return NULL; - return PyImport_ImportModuleEx(name, globals, locals, fromlist); -} - -PyDoc_STRVAR(import_doc, -"__import__(name, globals, locals, fromlist) -> module\n\ -\n\ -Import a module. The globals are only used to determine the context;\n\ -they are not modified. The locals are currently unused. The fromlist\n\ -should be a list of names to emulate ``from name import ...'', or an\n\ -empty list to emulate ``import name''.\n\ -When importing a module from a package, note that __import__('A.B', ...)\n\ -returns package A when fromlist is empty, but its submodule B when\n\ -fromlist is not empty."); - - -static PyObject * -builtin_abs(PyObject *self, PyObject *v) -{ - return PyNumber_Absolute(v); -} - -PyDoc_STRVAR(abs_doc, -"abs(number) -> number\n\ -\n\ -Return the absolute value of the argument."); - - -static PyObject * -builtin_apply(PyObject *self, PyObject *args) -{ - PyObject *func, *alist = NULL, *kwdict = NULL; - PyObject *t = NULL, *retval = NULL; - - if (!PyArg_UnpackTuple(args, "apply", 1, 3, &func, &alist, &kwdict)) - return NULL; - if (alist != NULL) { - if (!PyTuple_Check(alist)) { - if (!PySequence_Check(alist)) { - PyErr_Format(PyExc_TypeError, - "apply() arg 2 expected sequence, found %s", - alist->ob_type->tp_name); - return NULL; - } - t = PySequence_Tuple(alist); - if (t == NULL) - return NULL; - alist = t; - } - } - if (kwdict != NULL && !PyDict_Check(kwdict)) { - PyErr_Format(PyExc_TypeError, - "apply() arg 3 expected dictionary, found %s", - kwdict->ob_type->tp_name); - goto finally; - } - retval = PyEval_CallObjectWithKeywords(func, alist, kwdict); - finally: - Py_XDECREF(t); - return retval; -} - -PyDoc_STRVAR(apply_doc, -"apply(object[, args[, kwargs]]) -> value\n\ -\n\ -Call a callable object with positional arguments taken from the tuple args,\n\ -and keyword arguments taken from the optional dictionary kwargs.\n\ -Note that classes are callable, as are instances with a __call__() method.\n\ -\n\ -Deprecated since release 2.3. Instead, use the extended call syntax:\n\ - function(*args, **keywords)."); - - -static PyObject * -builtin_callable(PyObject *self, PyObject *v) -{ - return PyBool_FromLong((long)PyCallable_Check(v)); -} - -PyDoc_STRVAR(callable_doc, -"callable(object) -> bool\n\ -\n\ -Return whether the object is callable (i.e., some kind of function).\n\ -Note that classes are callable, as are instances with a __call__() method."); - - -static PyObject * -builtin_filter(PyObject *self, PyObject *args) -{ - PyObject *func, *seq, *result, *it, *arg; - int len; /* guess for result list size */ - register int j; - - if (!PyArg_UnpackTuple(args, "filter", 2, 2, &func, &seq)) - return NULL; - - /* Strings and tuples return a result of the same type. */ - if (PyString_Check(seq)) - return filterstring(func, seq); -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(seq)) - return filterunicode(func, seq); -#endif - if (PyTuple_Check(seq)) - return filtertuple(func, seq); - - /* Get iterator. */ - it = PyObject_GetIter(seq); - if (it == NULL) - return NULL; - - /* Guess a result list size. */ - len = -1; /* unknown */ - if (PySequence_Check(seq) && - seq->ob_type->tp_as_sequence->sq_length) { - len = PySequence_Size(seq); - if (len < 0) - PyErr_Clear(); - } - if (len < 0) - len = 8; /* arbitrary */ - - /* Pre-allocate argument list tuple. */ - arg = PyTuple_New(1); - if (arg == NULL) - goto Fail_arg; - - /* Get a result list. */ - if (PyList_Check(seq) && seq->ob_refcnt == 1) { - /* Eww - can modify the list in-place. */ - Py_INCREF(seq); - result = seq; - } - else { - result = PyList_New(len); - if (result == NULL) - goto Fail_it; - } - - /* Build the result list. */ - j = 0; - for (;;) { - PyObject *item; - int ok; - - item = PyIter_Next(it); - if (item == NULL) { - if (PyErr_Occurred()) - goto Fail_result_it; - break; - } - - if (func == Py_None) { - ok = PyObject_IsTrue(item); - } - else { - PyObject *good; - PyTuple_SET_ITEM(arg, 0, item); - good = PyObject_Call(func, arg, NULL); - PyTuple_SET_ITEM(arg, 0, NULL); - if (good == NULL) { - Py_DECREF(item); - goto Fail_result_it; - } - ok = PyObject_IsTrue(good); - Py_DECREF(good); - } - if (ok) { - if (j < len) - PyList_SET_ITEM(result, j, item); - else { - int status = PyList_Append(result, item); - Py_DECREF(item); - if (status < 0) - goto Fail_result_it; - } - ++j; - } - else - Py_DECREF(item); - } - - - /* Cut back result list if len is too big. */ - if (j < len && PyList_SetSlice(result, j, len, NULL) < 0) - goto Fail_result_it; - - Py_DECREF(it); - Py_DECREF(arg); - return result; - -Fail_result_it: - Py_DECREF(result); -Fail_it: - Py_DECREF(it); -Fail_arg: - Py_DECREF(arg); - return NULL; -} - -PyDoc_STRVAR(filter_doc, -"filter(function or None, sequence) -> list, tuple, or string\n" -"\n" -"Return those items of sequence for which function(item) is true. If\n" -"function is None, return the items that are true. If sequence is a tuple\n" -"or string, return the same type, else return a list."); - -static PyObject * -builtin_chr(PyObject *self, PyObject *args) -{ - long x; - char s[1]; - - if (!PyArg_ParseTuple(args, "l:chr", &x)) - return NULL; - if (x < 0 || x >= 256) { - PyErr_SetString(PyExc_ValueError, - "chr() arg not in range(256)"); - return NULL; - } - s[0] = (char)x; - return PyString_FromStringAndSize(s, 1); -} - -PyDoc_STRVAR(chr_doc, -"chr(i) -> character\n\ -\n\ -Return a string of one character with ordinal i; 0 <= i < 256."); - - -#ifdef Py_USING_UNICODE -static PyObject * -builtin_unichr(PyObject *self, PyObject *args) -{ - long x; - - if (!PyArg_ParseTuple(args, "l:unichr", &x)) - return NULL; - - return PyUnicode_FromOrdinal(x); -} - -PyDoc_STRVAR(unichr_doc, -"unichr(i) -> Unicode character\n\ -\n\ -Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff."); -#endif - - -static PyObject * -builtin_cmp(PyObject *self, PyObject *args) -{ - PyObject *a, *b; - int c; - - if (!PyArg_UnpackTuple(args, "cmp", 2, 2, &a, &b)) - return NULL; - if (PyObject_Cmp(a, b, &c) < 0) - return NULL; - return PyInt_FromLong((long)c); -} - -PyDoc_STRVAR(cmp_doc, -"cmp(x, y) -> integer\n\ -\n\ -Return negative if xy."); - - -static PyObject * -builtin_coerce(PyObject *self, PyObject *args) -{ - PyObject *v, *w; - PyObject *res; - - if (!PyArg_UnpackTuple(args, "coerce", 2, 2, &v, &w)) - return NULL; - if (PyNumber_Coerce(&v, &w) < 0) - return NULL; - res = Py_BuildValue("(OO)", v, w); - Py_DECREF(v); - Py_DECREF(w); - return res; -} - -PyDoc_STRVAR(coerce_doc, -"coerce(x, y) -> None or (x1, y1)\n\ -\n\ -When x and y can be coerced to values of the same type, return a tuple\n\ -containing the coerced values. When they can't be coerced, return None."); - - -static PyObject * -builtin_compile(PyObject *self, PyObject *args) -{ - char *str; - char *filename; - char *startstr; - int start; - int dont_inherit = 0; - int supplied_flags = 0; - PyCompilerFlags cf; - PyObject *result, *cmd, *tmp = NULL; - int length; - - if (!PyArg_ParseTuple(args, "Oss|ii:compile", &cmd, &filename, - &startstr, &supplied_flags, &dont_inherit)) - return NULL; - - cf.cf_flags = supplied_flags; - -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(cmd)) { - tmp = PyUnicode_AsUTF8String(cmd); - if (tmp == NULL) - return NULL; - cmd = tmp; - cf.cf_flags |= PyCF_SOURCE_IS_UTF8; - } -#endif - if (PyObject_AsReadBuffer(cmd, (const void **)&str, &length)) - return NULL; - if ((size_t)length != strlen(str)) { - PyErr_SetString(PyExc_TypeError, - "compile() expected string without null bytes"); - return NULL; - } - - if (strcmp(startstr, "exec") == 0) - start = Py_file_input; - else if (strcmp(startstr, "eval") == 0) - start = Py_eval_input; - else if (strcmp(startstr, "single") == 0) - start = Py_single_input; - else { - PyErr_SetString(PyExc_ValueError, - "compile() arg 3 must be 'exec' or 'eval' or 'single'"); - return NULL; - } - - if (supplied_flags & - ~(PyCF_MASK | PyCF_MASK_OBSOLETE | PyCF_DONT_IMPLY_DEDENT)) - { - PyErr_SetString(PyExc_ValueError, - "compile(): unrecognised flags"); - return NULL; - } - /* XXX Warn if (supplied_flags & PyCF_MASK_OBSOLETE) != 0? */ - - if (!dont_inherit) { - PyEval_MergeCompilerFlags(&cf); - } - result = Py_CompileStringFlags(str, filename, start, &cf); - Py_XDECREF(tmp); - return result; -} - -PyDoc_STRVAR(compile_doc, -"compile(source, filename, mode[, flags[, dont_inherit]]) -> code object\n\ -\n\ -Compile the source string (a Python module, statement or expression)\n\ -into a code object that can be executed by the exec statement or eval().\n\ -The filename will be used for run-time error messages.\n\ -The mode must be 'exec' to compile a module, 'single' to compile a\n\ -single (interactive) statement, or 'eval' to compile an expression.\n\ -The flags argument, if present, controls which future statements influence\n\ -the compilation of the code.\n\ -The dont_inherit argument, if non-zero, stops the compilation inheriting\n\ -the effects of any future statements in effect in the code calling\n\ -compile; if absent or zero these statements do influence the compilation,\n\ -in addition to any features explicitly specified."); - -static PyObject * -builtin_dir(PyObject *self, PyObject *args) -{ - PyObject *arg = NULL; - - if (!PyArg_UnpackTuple(args, "dir", 0, 1, &arg)) - return NULL; - return PyObject_Dir(arg); -} - -PyDoc_STRVAR(dir_doc, -"dir([object]) -> list of strings\n" -"\n" -"Return an alphabetized list of names comprising (some of) the attributes\n" -"of the given object, and of attributes reachable from it:\n" -"\n" -"No argument: the names in the current scope.\n" -"Module object: the module attributes.\n" -"Type or class object: its attributes, and recursively the attributes of\n" -" its bases.\n" -"Otherwise: its attributes, its class's attributes, and recursively the\n" -" attributes of its class's base classes."); - -static PyObject * -builtin_divmod(PyObject *self, PyObject *args) -{ - PyObject *v, *w; - - if (!PyArg_UnpackTuple(args, "divmod", 2, 2, &v, &w)) - return NULL; - return PyNumber_Divmod(v, w); -} - -PyDoc_STRVAR(divmod_doc, -"divmod(x, y) -> (div, mod)\n\ -\n\ -Return the tuple ((x-x%y)/y, x%y). Invariant: div*y + mod == x."); - - -static PyObject * -builtin_eval(PyObject *self, PyObject *args) -{ - PyObject *cmd, *result, *tmp = NULL; - PyObject *globals = Py_None, *locals = Py_None; - char *str; - PyCompilerFlags cf; - - if (!PyArg_ParseTuple(args, "O|O!O!:eval", - &cmd, - &PyDict_Type, &globals, - &PyDict_Type, &locals)) - return NULL; - if (globals == Py_None) { - globals = PyEval_GetGlobals(); - if (locals == Py_None) - locals = PyEval_GetLocals(); - } - else if (locals == Py_None) - locals = globals; - - if (PyDict_GetItemString(globals, "__builtins__") == NULL) { - if (PyDict_SetItemString(globals, "__builtins__", - PyEval_GetBuiltins()) != 0) - return NULL; - } - - if (PyCode_Check(cmd)) { - if (PyCode_GetNumFree((PyCodeObject *)cmd) > 0) { - PyErr_SetString(PyExc_TypeError, - "code object passed to eval() may not contain free variables"); - return NULL; - } - return PyEval_EvalCode((PyCodeObject *) cmd, globals, locals); - } - - if (!PyString_Check(cmd) && - !PyUnicode_Check(cmd)) { - PyErr_SetString(PyExc_TypeError, - "eval() arg 1 must be a string or code object"); - return NULL; - } - cf.cf_flags = 0; - -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(cmd)) { - tmp = PyUnicode_AsUTF8String(cmd); - if (tmp == NULL) - return NULL; - cmd = tmp; - cf.cf_flags |= PyCF_SOURCE_IS_UTF8; - } -#endif - if (PyString_AsStringAndSize(cmd, &str, NULL)) - return NULL; - while (*str == ' ' || *str == '\t') - str++; - - (void)PyEval_MergeCompilerFlags(&cf); - result = PyRun_StringFlags(str, Py_eval_input, globals, locals, &cf); - Py_XDECREF(tmp); - return result; -} - -PyDoc_STRVAR(eval_doc, -"eval(source[, globals[, locals]]) -> value\n\ -\n\ -Evaluate the source in the context of globals and locals.\n\ -The source may be a string representing a Python expression\n\ -or a code object as returned by compile().\n\ -The globals and locals are dictionaries, defaulting to the current\n\ -globals and locals. If only globals is given, locals defaults to it."); - - -static PyObject * -builtin_execfile(PyObject *self, PyObject *args) -{ - char *filename; - PyObject *globals = Py_None, *locals = Py_None; - PyObject *res; - FILE* fp = NULL; - PyCompilerFlags cf; - int exists; - - if (!PyArg_ParseTuple(args, "s|O!O!:execfile", - &filename, - &PyDict_Type, &globals, - &PyDict_Type, &locals)) - return NULL; - if (globals == Py_None) { - globals = PyEval_GetGlobals(); - if (locals == Py_None) - locals = PyEval_GetLocals(); - } - else if (locals == Py_None) - locals = globals; - if (PyDict_GetItemString(globals, "__builtins__") == NULL) { - if (PyDict_SetItemString(globals, "__builtins__", - PyEval_GetBuiltins()) != 0) - return NULL; - } - - exists = 0; - /* Test for existence or directory. */ -#if defined(PLAN9) - { - Dir *d; - - if ((d = dirstat(filename))!=nil) { - if(d->mode & DMDIR) - werrstr("is a directory"); - else - exists = 1; - free(d); - } - } -#elif defined(RISCOS) - if (object_exists(filename)) { - if (isdir(filename)) - errno = EISDIR; - else - exists = 1; - } -#else /* standard Posix */ - { - struct stat s; - if (stat(filename, &s) == 0) { - if (S_ISDIR(s.st_mode)) -# if defined(PY_OS2) && defined(PYCC_VACPP) - errno = EOS2ERR; -# else - errno = EISDIR; -# endif - else - exists = 1; - } - } -#endif - - if (exists) { - Py_BEGIN_ALLOW_THREADS - fp = fopen(filename, "r" PY_STDIOTEXTMODE); - Py_END_ALLOW_THREADS - - if (fp == NULL) { - exists = 0; - } - } - - if (!exists) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, filename); - return NULL; - } - cf.cf_flags = 0; - if (PyEval_MergeCompilerFlags(&cf)) - res = PyRun_FileExFlags(fp, filename, Py_file_input, globals, - locals, 1, &cf); - else - res = PyRun_FileEx(fp, filename, Py_file_input, globals, - locals, 1); - return res; -} - -PyDoc_STRVAR(execfile_doc, -"execfile(filename[, globals[, locals]])\n\ -\n\ -Read and execute a Python script from a file.\n\ -The globals and locals are dictionaries, defaulting to the current\n\ -globals and locals. If only globals is given, locals defaults to it."); - - -static PyObject * -builtin_getattr(PyObject *self, PyObject *args) -{ - PyObject *v, *result, *dflt = NULL; - PyObject *name; - - if (!PyArg_UnpackTuple(args, "getattr", 2, 3, &v, &name, &dflt)) - return NULL; -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(name)) { - name = _PyUnicode_AsDefaultEncodedString(name, NULL); - if (name == NULL) - return NULL; - } -#endif - - if (!PyString_Check(name)) { - PyErr_SetString(PyExc_TypeError, - "getattr(): attribute name must be string"); - return NULL; - } - result = PyObject_GetAttr(v, name); - if (result == NULL && dflt != NULL && - PyErr_ExceptionMatches(PyExc_AttributeError)) - { - PyErr_Clear(); - Py_INCREF(dflt); - result = dflt; - } - return result; -} - -PyDoc_STRVAR(getattr_doc, -"getattr(object, name[, default]) -> value\n\ -\n\ -Get a named attribute from an object; getattr(x, 'y') is equivalent to x.y.\n\ -When a default argument is given, it is returned when the attribute doesn't\n\ -exist; without it, an exception is raised in that case."); - - -static PyObject * -builtin_globals(PyObject *self) -{ - PyObject *d; - - d = PyEval_GetGlobals(); - Py_INCREF(d); - return d; -} - -PyDoc_STRVAR(globals_doc, -"globals() -> dictionary\n\ -\n\ -Return the dictionary containing the current scope's global variables."); - - -static PyObject * -builtin_hasattr(PyObject *self, PyObject *args) -{ - PyObject *v; - PyObject *name; - - if (!PyArg_UnpackTuple(args, "hasattr", 2, 2, &v, &name)) - return NULL; -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(name)) { - name = _PyUnicode_AsDefaultEncodedString(name, NULL); - if (name == NULL) - return NULL; - } -#endif - - if (!PyString_Check(name)) { - PyErr_SetString(PyExc_TypeError, - "hasattr(): attribute name must be string"); - return NULL; - } - v = PyObject_GetAttr(v, name); - if (v == NULL) { - PyErr_Clear(); - Py_INCREF(Py_False); - return Py_False; - } - Py_DECREF(v); - Py_INCREF(Py_True); - return Py_True; -} - -PyDoc_STRVAR(hasattr_doc, -"hasattr(object, name) -> bool\n\ -\n\ -Return whether the object has an attribute with the given name.\n\ -(This is done by calling getattr(object, name) and catching exceptions.)"); - - -static PyObject * -builtin_id(PyObject *self, PyObject *v) -{ - return PyLong_FromVoidPtr(v); -} - -PyDoc_STRVAR(id_doc, -"id(object) -> integer\n\ -\n\ -Return the identity of an object. This is guaranteed to be unique among\n\ -simultaneously existing objects. (Hint: it's the object's memory address.)"); - - -static PyObject * -builtin_map(PyObject *self, PyObject *args) -{ - typedef struct { - PyObject *it; /* the iterator object */ - int saw_StopIteration; /* bool: did the iterator end? */ - } sequence; - - PyObject *func, *result; - sequence *seqs = NULL, *sqp; - int n, len; - register int i, j; - - n = PyTuple_Size(args); - if (n < 2) { - PyErr_SetString(PyExc_TypeError, - "map() requires at least two args"); - return NULL; - } - - func = PyTuple_GetItem(args, 0); - n--; - - if (func == Py_None && n == 1) { - /* map(None, S) is the same as list(S). */ - return PySequence_List(PyTuple_GetItem(args, 1)); - } - - /* Get space for sequence descriptors. Must NULL out the iterator - * pointers so that jumping to Fail_2 later doesn't see trash. - */ - if ((seqs = PyMem_NEW(sequence, n)) == NULL) { - PyErr_NoMemory(); - return NULL; - } - for (i = 0; i < n; ++i) { - seqs[i].it = (PyObject*)NULL; - seqs[i].saw_StopIteration = 0; - } - - /* Do a first pass to obtain iterators for the arguments, and set len - * to the largest of their lengths. - */ - len = 0; - for (i = 0, sqp = seqs; i < n; ++i, ++sqp) { - PyObject *curseq; - int curlen; - - /* Get iterator. */ - curseq = PyTuple_GetItem(args, i+1); - sqp->it = PyObject_GetIter(curseq); - if (sqp->it == NULL) { - static char errmsg[] = - "argument %d to map() must support iteration"; - char errbuf[sizeof(errmsg) + 25]; - PyOS_snprintf(errbuf, sizeof(errbuf), errmsg, i+2); - PyErr_SetString(PyExc_TypeError, errbuf); - goto Fail_2; - } - - /* Update len. */ - curlen = -1; /* unknown */ - if (PySequence_Check(curseq) && - curseq->ob_type->tp_as_sequence->sq_length) { - curlen = PySequence_Size(curseq); - if (curlen < 0) - PyErr_Clear(); - } - if (curlen < 0) - curlen = 8; /* arbitrary */ - if (curlen > len) - len = curlen; - } - - /* Get space for the result list. */ - if ((result = (PyObject *) PyList_New(len)) == NULL) - goto Fail_2; - - /* Iterate over the sequences until all have stopped. */ - for (i = 0; ; ++i) { - PyObject *alist, *item=NULL, *value; - int numactive = 0; - - if (func == Py_None && n == 1) - alist = NULL; - else if ((alist = PyTuple_New(n)) == NULL) - goto Fail_1; - - for (j = 0, sqp = seqs; j < n; ++j, ++sqp) { - if (sqp->saw_StopIteration) { - Py_INCREF(Py_None); - item = Py_None; - } - else { - item = PyIter_Next(sqp->it); - if (item) - ++numactive; - else { - if (PyErr_Occurred()) { - Py_XDECREF(alist); - goto Fail_1; - } - Py_INCREF(Py_None); - item = Py_None; - sqp->saw_StopIteration = 1; - } - } - if (alist) - PyTuple_SET_ITEM(alist, j, item); - else - break; - } - - if (!alist) - alist = item; - - if (numactive == 0) { - Py_DECREF(alist); - break; - } - - if (func == Py_None) - value = alist; - else { - value = PyEval_CallObject(func, alist); - Py_DECREF(alist); - if (value == NULL) - goto Fail_1; - } - if (i >= len) { - int status = PyList_Append(result, value); - Py_DECREF(value); - if (status < 0) - goto Fail_1; - } - else if (PyList_SetItem(result, i, value) < 0) - goto Fail_1; - } - - if (i < len && PyList_SetSlice(result, i, len, NULL) < 0) - goto Fail_1; - - goto Succeed; - -Fail_1: - Py_DECREF(result); -Fail_2: - result = NULL; -Succeed: - assert(seqs); - for (i = 0; i < n; ++i) - Py_XDECREF(seqs[i].it); - PyMem_DEL(seqs); - return result; -} - -PyDoc_STRVAR(map_doc, -"map(function, sequence[, sequence, ...]) -> list\n\ -\n\ -Return a list of the results of applying the function to the items of\n\ -the argument sequence(s). If more than one sequence is given, the\n\ -function is called with an argument list consisting of the corresponding\n\ -item of each sequence, substituting None for missing values when not all\n\ -sequences have the same length. If the function is None, return a list of\n\ -the items of the sequence (or a list of tuples if more than one sequence)."); - - -static PyObject * -builtin_setattr(PyObject *self, PyObject *args) -{ - PyObject *v; - PyObject *name; - PyObject *value; - - if (!PyArg_UnpackTuple(args, "setattr", 3, 3, &v, &name, &value)) - return NULL; - if (PyObject_SetAttr(v, name, value) != 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(setattr_doc, -"setattr(object, name, value)\n\ -\n\ -Set a named attribute on an object; setattr(x, 'y', v) is equivalent to\n\ -``x.y = v''."); - - -static PyObject * -builtin_delattr(PyObject *self, PyObject *args) -{ - PyObject *v; - PyObject *name; - - if (!PyArg_UnpackTuple(args, "delattr", 2, 2, &v, &name)) - return NULL; - if (PyObject_SetAttr(v, name, (PyObject *)NULL) != 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(delattr_doc, -"delattr(object, name)\n\ -\n\ -Delete a named attribute on an object; delattr(x, 'y') is equivalent to\n\ -``del x.y''."); - - -static PyObject * -builtin_hash(PyObject *self, PyObject *v) -{ - long x; - - x = PyObject_Hash(v); - if (x == -1) - return NULL; - return PyInt_FromLong(x); -} - -PyDoc_STRVAR(hash_doc, -"hash(object) -> integer\n\ -\n\ -Return a hash value for the object. Two objects with the same value have\n\ -the same hash value. The reverse is not necessarily true, but likely."); - - -static PyObject * -builtin_hex(PyObject *self, PyObject *v) -{ - PyNumberMethods *nb; - - if ((nb = v->ob_type->tp_as_number) == NULL || - nb->nb_hex == NULL) { - PyErr_SetString(PyExc_TypeError, - "hex() argument can't be converted to hex"); - return NULL; - } - return (*nb->nb_hex)(v); -} - -PyDoc_STRVAR(hex_doc, -"hex(number) -> string\n\ -\n\ -Return the hexadecimal representation of an integer or long integer."); - - -static PyObject *builtin_raw_input(PyObject *, PyObject *); - -static PyObject * -builtin_input(PyObject *self, PyObject *args) -{ - PyObject *line; - char *str; - PyObject *res; - PyObject *globals, *locals; - - line = builtin_raw_input(self, args); - if (line == NULL) - return line; - if (!PyArg_Parse(line, "s;embedded '\\0' in input line", &str)) - return NULL; - while (*str == ' ' || *str == '\t') - str++; - globals = PyEval_GetGlobals(); - locals = PyEval_GetLocals(); - if (PyDict_GetItemString(globals, "__builtins__") == NULL) { - if (PyDict_SetItemString(globals, "__builtins__", - PyEval_GetBuiltins()) != 0) - return NULL; - } - res = PyRun_String(str, Py_eval_input, globals, locals); - Py_DECREF(line); - return res; -} - -PyDoc_STRVAR(input_doc, -"input([prompt]) -> value\n\ -\n\ -Equivalent to eval(raw_input(prompt))."); - - -static PyObject * -builtin_intern(PyObject *self, PyObject *args) -{ - PyObject *s; - if (!PyArg_ParseTuple(args, "S:intern", &s)) - return NULL; - Py_INCREF(s); - PyString_InternInPlace(&s); - return s; -} - -PyDoc_STRVAR(intern_doc, -"intern(string) -> string\n\ -\n\ -``Intern'' the given string. This enters the string in the (global)\n\ -table of interned strings whose purpose is to speed up dictionary lookups.\n\ -Return the string itself or the previously interned string object with the\n\ -same value."); - - -static PyObject * -builtin_iter(PyObject *self, PyObject *args) -{ - PyObject *v, *w = NULL; - - if (!PyArg_UnpackTuple(args, "iter", 1, 2, &v, &w)) - return NULL; - if (w == NULL) - return PyObject_GetIter(v); - if (!PyCallable_Check(v)) { - PyErr_SetString(PyExc_TypeError, - "iter(v, w): v must be callable"); - return NULL; - } - return PyCallIter_New(v, w); -} - -PyDoc_STRVAR(iter_doc, -"iter(collection) -> iterator\n\ -iter(callable, sentinel) -> iterator\n\ -\n\ -Get an iterator from an object. In the first form, the argument must\n\ -supply its own iterator, or be a sequence.\n\ -In the second form, the callable is called until it returns the sentinel."); - - -static PyObject * -builtin_len(PyObject *self, PyObject *v) -{ - long res; - - res = PyObject_Size(v); - if (res < 0 && PyErr_Occurred()) - return NULL; - return PyInt_FromLong(res); -} - -PyDoc_STRVAR(len_doc, -"len(object) -> integer\n\ -\n\ -Return the number of items of a sequence or mapping."); - - -static PyObject * -builtin_locals(PyObject *self) -{ - PyObject *d; - - d = PyEval_GetLocals(); - Py_INCREF(d); - return d; -} - -PyDoc_STRVAR(locals_doc, -"locals() -> dictionary\n\ -\n\ -Update and return a dictionary containing the current scope's local variables."); - - -static PyObject * -min_max(PyObject *args, int op) -{ - PyObject *v, *w, *x, *it; - - if (PyTuple_Size(args) > 1) - v = args; - else if (!PyArg_UnpackTuple(args, (op==Py_LT) ? "min" : "max", 1, 1, &v)) - return NULL; - - it = PyObject_GetIter(v); - if (it == NULL) - return NULL; - - w = NULL; /* the result */ - for (;;) { - x = PyIter_Next(it); - if (x == NULL) { - if (PyErr_Occurred()) { - Py_XDECREF(w); - Py_DECREF(it); - return NULL; - } - break; - } - - if (w == NULL) - w = x; - else { - int cmp = PyObject_RichCompareBool(x, w, op); - if (cmp > 0) { - Py_DECREF(w); - w = x; - } - else if (cmp < 0) { - Py_DECREF(x); - Py_DECREF(w); - Py_DECREF(it); - return NULL; - } - else - Py_DECREF(x); - } - } - if (w == NULL) - PyErr_SetString(PyExc_ValueError, - "min() or max() arg is an empty sequence"); - Py_DECREF(it); - return w; -} - -static PyObject * -builtin_min(PyObject *self, PyObject *v) -{ - return min_max(v, Py_LT); -} - -PyDoc_STRVAR(min_doc, -"min(sequence) -> value\n\ -min(a, b, c, ...) -> value\n\ -\n\ -With a single sequence argument, return its smallest item.\n\ -With two or more arguments, return the smallest argument."); - - -static PyObject * -builtin_max(PyObject *self, PyObject *v) -{ - return min_max(v, Py_GT); -} - -PyDoc_STRVAR(max_doc, -"max(sequence) -> value\n\ -max(a, b, c, ...) -> value\n\ -\n\ -With a single sequence argument, return its largest item.\n\ -With two or more arguments, return the largest argument."); - - -static PyObject * -builtin_oct(PyObject *self, PyObject *v) -{ - PyNumberMethods *nb; - - if (v == NULL || (nb = v->ob_type->tp_as_number) == NULL || - nb->nb_oct == NULL) { - PyErr_SetString(PyExc_TypeError, - "oct() argument can't be converted to oct"); - return NULL; - } - return (*nb->nb_oct)(v); -} - -PyDoc_STRVAR(oct_doc, -"oct(number) -> string\n\ -\n\ -Return the octal representation of an integer or long integer."); - - -static PyObject * -builtin_ord(PyObject *self, PyObject* obj) -{ - long ord; - int size; - - if (PyString_Check(obj)) { - size = PyString_GET_SIZE(obj); - if (size == 1) { - ord = (long)((unsigned char)*PyString_AS_STRING(obj)); - return PyInt_FromLong(ord); - } -#ifdef Py_USING_UNICODE - } else if (PyUnicode_Check(obj)) { - size = PyUnicode_GET_SIZE(obj); - if (size == 1) { - ord = (long)*PyUnicode_AS_UNICODE(obj); - return PyInt_FromLong(ord); - } -#endif - } else { - PyErr_Format(PyExc_TypeError, - "ord() expected string of length 1, but " \ - "%.200s found", obj->ob_type->tp_name); - return NULL; - } - - PyErr_Format(PyExc_TypeError, - "ord() expected a character, " - "but string of length %d found", - size); - return NULL; -} - -PyDoc_STRVAR(ord_doc, -"ord(c) -> integer\n\ -\n\ -Return the integer ordinal of a one-character string."); - - -static PyObject * -builtin_pow(PyObject *self, PyObject *args) -{ - PyObject *v, *w, *z = Py_None; - - if (!PyArg_UnpackTuple(args, "pow", 2, 3, &v, &w, &z)) - return NULL; - return PyNumber_Power(v, w, z); -} - -PyDoc_STRVAR(pow_doc, -"pow(x, y[, z]) -> number\n\ -\n\ -With two arguments, equivalent to x**y. With three arguments,\n\ -equivalent to (x**y) % z, but may be more efficient (e.g. for longs)."); - - - -/* Return number of items in range (lo, hi, step), when arguments are - * PyInt or PyLong objects. step > 0 required. Return a value < 0 if - * & only if the true value is too large to fit in a signed long. - * Arguments MUST return 1 with either PyInt_Check() or - * PyLong_Check(). Return -1 when there is an error. - */ -static long -get_len_of_range_longs(PyObject *lo, PyObject *hi, PyObject *step) -{ - /* ------------------------------------------------------------- - Algorithm is equal to that of get_len_of_range(), but it operates - on PyObjects (which are assumed to be PyLong or PyInt objects). - ---------------------------------------------------------------*/ - long n; - PyObject *diff = NULL; - PyObject *one = NULL; - PyObject *tmp1 = NULL, *tmp2 = NULL, *tmp3 = NULL; - /* holds sub-expression evaluations */ - - /* if (lo >= hi), return length of 0. */ - if (PyObject_Compare(lo, hi) >= 0) - return 0; - - if ((one = PyLong_FromLong(1L)) == NULL) - goto Fail; - - if ((tmp1 = PyNumber_Subtract(hi, lo)) == NULL) - goto Fail; - - if ((diff = PyNumber_Subtract(tmp1, one)) == NULL) - goto Fail; - - if ((tmp2 = PyNumber_FloorDivide(diff, step)) == NULL) - goto Fail; - - if ((tmp3 = PyNumber_Add(tmp2, one)) == NULL) - goto Fail; - - n = PyLong_AsLong(tmp3); - if (PyErr_Occurred()) { /* Check for Overflow */ - PyErr_Clear(); - goto Fail; - } - - Py_DECREF(tmp3); - Py_DECREF(tmp2); - Py_DECREF(diff); - Py_DECREF(tmp1); - Py_DECREF(one); - return n; - - Fail: - Py_XDECREF(tmp3); - Py_XDECREF(tmp2); - Py_XDECREF(diff); - Py_XDECREF(tmp1); - Py_XDECREF(one); - return -1; -} - -/* An extension of builtin_range() that handles the case when PyLong - * arguments are given. */ -static PyObject * -handle_range_longs(PyObject *self, PyObject *args) -{ - PyObject *ilow; - PyObject *ihigh = NULL; - PyObject *istep = NULL; - - PyObject *curnum = NULL; - PyObject *v = NULL; - long bign; - int i, n; - int cmp_result; - - PyObject *zero = PyLong_FromLong(0); - - if (zero == NULL) - return NULL; - - if (!PyArg_UnpackTuple(args, "range", 1, 3, &ilow, &ihigh, &istep)) { - Py_DECREF(zero); - return NULL; - } - - /* Figure out which way we were called, supply defaults, and be - * sure to incref everything so that the decrefs at the end - * are correct. - */ - assert(ilow != NULL); - if (ihigh == NULL) { - /* only 1 arg -- it's the upper limit */ - ihigh = ilow; - ilow = NULL; - } - assert(ihigh != NULL); - Py_INCREF(ihigh); - - /* ihigh correct now; do ilow */ - if (ilow == NULL) - ilow = zero; - Py_INCREF(ilow); - - /* ilow and ihigh correct now; do istep */ - if (istep == NULL) { - istep = PyLong_FromLong(1L); - if (istep == NULL) - goto Fail; - } - else { - Py_INCREF(istep); - } - - if (!PyInt_Check(ilow) && !PyLong_Check(ilow)) { - PyErr_Format(PyExc_TypeError, - "range() integer start argument expected, got %s.", - ilow->ob_type->tp_name); - goto Fail; - } - - if (!PyInt_Check(ihigh) && !PyLong_Check(ihigh)) { - PyErr_Format(PyExc_TypeError, - "range() integer end argument expected, got %s.", - ihigh->ob_type->tp_name); - goto Fail; - } - - if (!PyInt_Check(istep) && !PyLong_Check(istep)) { - PyErr_Format(PyExc_TypeError, - "range() integer step argument expected, got %s.", - istep->ob_type->tp_name); - goto Fail; - } - - if (PyObject_Cmp(istep, zero, &cmp_result) == -1) - goto Fail; - if (cmp_result == 0) { - PyErr_SetString(PyExc_ValueError, - "range() step argument must not be zero"); - goto Fail; - } - - if (cmp_result > 0) - bign = get_len_of_range_longs(ilow, ihigh, istep); - else { - PyObject *neg_istep = PyNumber_Negative(istep); - if (neg_istep == NULL) - goto Fail; - bign = get_len_of_range_longs(ihigh, ilow, neg_istep); - Py_DECREF(neg_istep); - } - - n = (int)bign; - if (bign < 0 || (long)n != bign) { - PyErr_SetString(PyExc_OverflowError, - "range() result has too many items"); - goto Fail; - } - - v = PyList_New(n); - if (v == NULL) - goto Fail; - - curnum = ilow; - Py_INCREF(curnum); - - for (i = 0; i < n; i++) { - PyObject *w = PyNumber_Long(curnum); - PyObject *tmp_num; - if (w == NULL) - goto Fail; - - PyList_SET_ITEM(v, i, w); - - tmp_num = PyNumber_Add(curnum, istep); - if (tmp_num == NULL) - goto Fail; - - Py_DECREF(curnum); - curnum = tmp_num; - } - Py_DECREF(ilow); - Py_DECREF(ihigh); - Py_DECREF(istep); - Py_DECREF(zero); - Py_DECREF(curnum); - return v; - - Fail: - Py_DECREF(ilow); - Py_DECREF(ihigh); - Py_XDECREF(istep); - Py_DECREF(zero); - Py_XDECREF(curnum); - Py_XDECREF(v); - return NULL; -} - -/* Return number of items in range/xrange (lo, hi, step). step > 0 - * required. Return a value < 0 if & only if the true value is too - * large to fit in a signed long. - */ -static long -get_len_of_range(long lo, long hi, long step) -{ - /* ------------------------------------------------------------- - If lo >= hi, the range is empty. - Else if n values are in the range, the last one is - lo + (n-1)*step, which must be <= hi-1. Rearranging, - n <= (hi - lo - 1)/step + 1, so taking the floor of the RHS gives - the proper value. Since lo < hi in this case, hi-lo-1 >= 0, so - the RHS is non-negative and so truncation is the same as the - floor. Letting M be the largest positive long, the worst case - for the RHS numerator is hi=M, lo=-M-1, and then - hi-lo-1 = M-(-M-1)-1 = 2*M. Therefore unsigned long has enough - precision to compute the RHS exactly. - ---------------------------------------------------------------*/ - long n = 0; - if (lo < hi) { - unsigned long uhi = (unsigned long)hi; - unsigned long ulo = (unsigned long)lo; - unsigned long diff = uhi - ulo - 1; - n = (long)(diff / (unsigned long)step + 1); - } - return n; -} - -static PyObject * -builtin_range(PyObject *self, PyObject *args) -{ - long ilow = 0, ihigh = 0, istep = 1; - long bign; - int i, n; - - PyObject *v; - - if (PyTuple_Size(args) <= 1) { - if (!PyArg_ParseTuple(args, - "l;range() requires 1-3 int arguments", - &ihigh)) { - PyErr_Clear(); - return handle_range_longs(self, args); - } - } - else { - if (!PyArg_ParseTuple(args, - "ll|l;range() requires 1-3 int arguments", - &ilow, &ihigh, &istep)) { - PyErr_Clear(); - return handle_range_longs(self, args); - } - } - if (istep == 0) { - PyErr_SetString(PyExc_ValueError, - "range() step argument must not be zero"); - return NULL; - } - if (istep > 0) - bign = get_len_of_range(ilow, ihigh, istep); - else - bign = get_len_of_range(ihigh, ilow, -istep); - n = (int)bign; - if (bign < 0 || (long)n != bign) { - PyErr_SetString(PyExc_OverflowError, - "range() result has too many items"); - return NULL; - } - v = PyList_New(n); - if (v == NULL) - return NULL; - for (i = 0; i < n; i++) { - PyObject *w = PyInt_FromLong(ilow); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyList_SET_ITEM(v, i, w); - ilow += istep; - } - return v; -} - -PyDoc_STRVAR(range_doc, -"range([start,] stop[, step]) -> list of integers\n\ -\n\ -Return a list containing an arithmetic progression of integers.\n\ -range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.\n\ -When step is given, it specifies the increment (or decrement).\n\ -For example, range(4) returns [0, 1, 2, 3]. The end point is omitted!\n\ -These are exactly the valid indices for a list of 4 elements."); - - -static PyObject * -builtin_raw_input(PyObject *self, PyObject *args) -{ - PyObject *v = NULL; - PyObject *fin = PySys_GetObject("stdin"); - PyObject *fout = PySys_GetObject("stdout"); - - if (!PyArg_UnpackTuple(args, "[raw_]input", 0, 1, &v)) - return NULL; - - if (fin == NULL) { - PyErr_SetString(PyExc_RuntimeError, "[raw_]input: lost sys.stdin"); - return NULL; - } - if (fout == NULL) { - PyErr_SetString(PyExc_RuntimeError, "[raw_]input: lost sys.stdout"); - return NULL; - } - if (PyFile_SoftSpace(fout, 0)) { - if (PyFile_WriteString(" ", fout) != 0) - return NULL; - } - if (PyFile_Check (fin) && PyFile_Check (fout) - && isatty(fileno(PyFile_AsFile(fin))) - && isatty(fileno(PyFile_AsFile(fout)))) { - PyObject *po; - char *prompt; - char *s; - PyObject *result; - if (v != NULL) { - po = PyObject_Str(v); - if (po == NULL) - return NULL; - prompt = PyString_AsString(po); - if (prompt == NULL) - return NULL; - } - else { - po = NULL; - prompt = ""; - } - s = PyOS_Readline(PyFile_AsFile (fin), PyFile_AsFile (fout), - prompt); - Py_XDECREF(po); - if (s == NULL) { - PyErr_SetNone(PyExc_KeyboardInterrupt); - return NULL; - } - if (*s == '\0') { - PyErr_SetNone(PyExc_EOFError); - result = NULL; - } - else { /* strip trailing '\n' */ - size_t len = strlen(s); - if (len > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "[raw_]input: input too long"); - result = NULL; - } - else { - result = PyString_FromStringAndSize(s, - (int)(len-1)); - } - } - PyMem_FREE(s); - return result; - } - if (v != NULL) { - if (PyFile_WriteObject(v, fout, Py_PRINT_RAW) != 0) - return NULL; - } - return PyFile_GetLine(fin, -1); -} - -PyDoc_STRVAR(raw_input_doc, -"raw_input([prompt]) -> string\n\ -\n\ -Read a string from standard input. The trailing newline is stripped.\n\ -If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.\n\ -On Unix, GNU readline is used if enabled. The prompt string, if given,\n\ -is printed without a trailing newline before reading."); - - -static PyObject * -builtin_reduce(PyObject *self, PyObject *args) -{ - PyObject *seq, *func, *result = NULL, *it; - - if (!PyArg_UnpackTuple(args, "reduce", 2, 3, &func, &seq, &result)) - return NULL; - if (result != NULL) - Py_INCREF(result); - - it = PyObject_GetIter(seq); - if (it == NULL) { - PyErr_SetString(PyExc_TypeError, - "reduce() arg 2 must support iteration"); - Py_XDECREF(result); - return NULL; - } - - if ((args = PyTuple_New(2)) == NULL) - goto Fail; - - for (;;) { - PyObject *op2; - - if (args->ob_refcnt > 1) { - Py_DECREF(args); - if ((args = PyTuple_New(2)) == NULL) - goto Fail; - } - - op2 = PyIter_Next(it); - if (op2 == NULL) { - if (PyErr_Occurred()) - goto Fail; - break; - } - - if (result == NULL) - result = op2; - else { - PyTuple_SetItem(args, 0, result); - PyTuple_SetItem(args, 1, op2); - if ((result = PyEval_CallObject(func, args)) == NULL) - goto Fail; - } - } - - Py_DECREF(args); - - if (result == NULL) - PyErr_SetString(PyExc_TypeError, - "reduce() of empty sequence with no initial value"); - - Py_DECREF(it); - return result; - -Fail: - Py_XDECREF(args); - Py_XDECREF(result); - Py_DECREF(it); - return NULL; -} - -PyDoc_STRVAR(reduce_doc, -"reduce(function, sequence[, initial]) -> value\n\ -\n\ -Apply a function of two arguments cumulatively to the items of a sequence,\n\ -from left to right, so as to reduce the sequence to a single value.\n\ -For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates\n\ -((((1+2)+3)+4)+5). If initial is present, it is placed before the items\n\ -of the sequence in the calculation, and serves as a default when the\n\ -sequence is empty."); - - -static PyObject * -builtin_reload(PyObject *self, PyObject *v) -{ - return PyImport_ReloadModule(v); -} - -PyDoc_STRVAR(reload_doc, -"reload(module) -> module\n\ -\n\ -Reload the module. The module must have been successfully imported before."); - - -static PyObject * -builtin_repr(PyObject *self, PyObject *v) -{ - return PyObject_Repr(v); -} - -PyDoc_STRVAR(repr_doc, -"repr(object) -> string\n\ -\n\ -Return the canonical string representation of the object.\n\ -For most object types, eval(repr(object)) == object."); - - -static PyObject * -builtin_round(PyObject *self, PyObject *args) -{ - double x; - double f; - int ndigits = 0; - int i; - - if (!PyArg_ParseTuple(args, "d|i:round", &x, &ndigits)) - return NULL; - f = 1.0; - i = abs(ndigits); - while (--i >= 0) - f = f*10.0; - if (ndigits < 0) - x /= f; - else - x *= f; - if (x >= 0.0) - x = floor(x + 0.5); - else - x = ceil(x - 0.5); - if (ndigits < 0) - x *= f; - else - x /= f; - return PyFloat_FromDouble(x); -} - -PyDoc_STRVAR(round_doc, -"round(number[, ndigits]) -> floating point number\n\ -\n\ -Round a number to a given precision in decimal digits (default 0 digits).\n\ -This always returns a floating point number. Precision may be negative."); - - -static PyObject * -builtin_vars(PyObject *self, PyObject *args) -{ - PyObject *v = NULL; - PyObject *d; - - if (!PyArg_UnpackTuple(args, "vars", 0, 1, &v)) - return NULL; - if (v == NULL) { - d = PyEval_GetLocals(); - if (d == NULL) { - if (!PyErr_Occurred()) - PyErr_SetString(PyExc_SystemError, - "vars(): no locals!?"); - } - else - Py_INCREF(d); - } - else { - d = PyObject_GetAttrString(v, "__dict__"); - if (d == NULL) { - PyErr_SetString(PyExc_TypeError, - "vars() argument must have __dict__ attribute"); - return NULL; - } - } - return d; -} - -PyDoc_STRVAR(vars_doc, -"vars([object]) -> dictionary\n\ -\n\ -Without arguments, equivalent to locals().\n\ -With an argument, equivalent to object.__dict__."); - - -static PyObject* -builtin_sum(PyObject *self, PyObject *args) -{ - PyObject *seq; - PyObject *result = NULL; - PyObject *temp, *item, *iter; - - if (!PyArg_ParseTuple(args, "O|O:sum", &seq, &result)) - return NULL; - - iter = PyObject_GetIter(seq); - if (iter == NULL) - return NULL; - - if (result == NULL) { - result = PyInt_FromLong(0); - if (result == NULL) { - Py_DECREF(iter); - return NULL; - } - } else { - /* reject string values for 'start' parameter */ - if (PyObject_TypeCheck(result, &PyBaseString_Type)) { - PyErr_SetString(PyExc_TypeError, - "sum() can't sum strings [use ''.join(seq) instead]"); - Py_DECREF(iter); - return NULL; - } - Py_INCREF(result); - } - - for(;;) { - item = PyIter_Next(iter); - if (item == NULL) { - /* error, or end-of-sequence */ - if (PyErr_Occurred()) { - Py_DECREF(result); - result = NULL; - } - break; - } - temp = PyNumber_Add(result, item); - Py_DECREF(result); - Py_DECREF(item); - result = temp; - if (result == NULL) - break; - } - Py_DECREF(iter); - return result; -} - -PyDoc_STRVAR(sum_doc, -"sum(sequence, start=0) -> value\n\ -\n\ -Returns the sum of a sequence of numbers (NOT strings) plus the value\n\ -of parameter 'start'. When the sequence is empty, returns start."); - - -static PyObject * -builtin_isinstance(PyObject *self, PyObject *args) -{ - PyObject *inst; - PyObject *cls; - int retval; - - if (!PyArg_UnpackTuple(args, "isinstance", 2, 2, &inst, &cls)) - return NULL; - - retval = PyObject_IsInstance(inst, cls); - if (retval < 0) - return NULL; - return PyBool_FromLong(retval); -} - -PyDoc_STRVAR(isinstance_doc, -"isinstance(object, class-or-type-or-tuple) -> bool\n\ -\n\ -Return whether an object is an instance of a class or of a subclass thereof.\n\ -With a type as second argument, return whether that is the object's type.\n\ -The form using a tuple, isinstance(x, (A, B, ...)), is a shortcut for\n\ -isinstance(x, A) or isinstance(x, B) or ... (etc.)."); - - -static PyObject * -builtin_issubclass(PyObject *self, PyObject *args) -{ - PyObject *derived; - PyObject *cls; - int retval; - - if (!PyArg_UnpackTuple(args, "issubclass", 2, 2, &derived, &cls)) - return NULL; - - retval = PyObject_IsSubclass(derived, cls); - if (retval < 0) - return NULL; - return PyBool_FromLong(retval); -} - -PyDoc_STRVAR(issubclass_doc, -"issubclass(C, B) -> bool\n\ -\n\ -Return whether class C is a subclass (i.e., a derived class) of class B.\n\ -When using a tuple as the second argument issubclass(X, (A, B, ...)),\n\ -is a shortcut for issubclass(X, A) or issubclass(X, B) or ... (etc.)."); - - -static PyObject* -builtin_zip(PyObject *self, PyObject *args) -{ - PyObject *ret; - const int itemsize = PySequence_Length(args); - int i; - PyObject *itlist; /* tuple of iterators */ - int len; /* guess at result length */ - - if (itemsize < 1) { - PyErr_SetString(PyExc_TypeError, - "zip() requires at least one sequence"); - return NULL; - } - /* args must be a tuple */ - assert(PyTuple_Check(args)); - - /* Guess at result length: the shortest of the input lengths. - If some argument refuses to say, we refuse to guess too, lest - an argument like xrange(sys.maxint) lead us astray.*/ - len = -1; /* unknown */ - for (i = 0; i < itemsize; ++i) { - PyObject *item = PyTuple_GET_ITEM(args, i); - int thislen = PySequence_Length(item); - if (thislen < 0) { - PyErr_Clear(); - len = -1; - break; - } - else if (len < 0 || thislen < len) - len = thislen; - } - - /* allocate result list */ - if (len < 0) - len = 10; /* arbitrary */ - if ((ret = PyList_New(len)) == NULL) - return NULL; - - /* obtain iterators */ - itlist = PyTuple_New(itemsize); - if (itlist == NULL) - goto Fail_ret; - for (i = 0; i < itemsize; ++i) { - PyObject *item = PyTuple_GET_ITEM(args, i); - PyObject *it = PyObject_GetIter(item); - if (it == NULL) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_Format(PyExc_TypeError, - "zip argument #%d must support iteration", - i+1); - goto Fail_ret_itlist; - } - PyTuple_SET_ITEM(itlist, i, it); - } - - /* build result into ret list */ - for (i = 0; ; ++i) { - int j; - PyObject *next = PyTuple_New(itemsize); - if (!next) - goto Fail_ret_itlist; - - for (j = 0; j < itemsize; j++) { - PyObject *it = PyTuple_GET_ITEM(itlist, j); - PyObject *item = PyIter_Next(it); - if (!item) { - if (PyErr_Occurred()) { - Py_DECREF(ret); - ret = NULL; - } - Py_DECREF(next); - Py_DECREF(itlist); - goto Done; - } - PyTuple_SET_ITEM(next, j, item); - } - - if (i < len) - PyList_SET_ITEM(ret, i, next); - else { - int status = PyList_Append(ret, next); - Py_DECREF(next); - ++len; - if (status < 0) - goto Fail_ret_itlist; - } - } - -Done: - if (ret != NULL && i < len) { - /* The list is too big. */ - if (PyList_SetSlice(ret, i, len, NULL) < 0) - return NULL; - } - return ret; - -Fail_ret_itlist: - Py_DECREF(itlist); -Fail_ret: - Py_DECREF(ret); - return NULL; -} - - -PyDoc_STRVAR(zip_doc, -"zip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)]\n\ -\n\ -Return a list of tuples, where each tuple contains the i-th element\n\ -from each of the argument sequences. The returned list is truncated\n\ -in length to the length of the shortest argument sequence."); - - -static PyMethodDef builtin_methods[] = { - {"__import__", builtin___import__, METH_VARARGS, import_doc}, - {"abs", builtin_abs, METH_O, abs_doc}, - {"apply", builtin_apply, METH_VARARGS, apply_doc}, - {"callable", builtin_callable, METH_O, callable_doc}, - {"chr", builtin_chr, METH_VARARGS, chr_doc}, - {"cmp", builtin_cmp, METH_VARARGS, cmp_doc}, - {"coerce", builtin_coerce, METH_VARARGS, coerce_doc}, - {"compile", builtin_compile, METH_VARARGS, compile_doc}, - {"delattr", builtin_delattr, METH_VARARGS, delattr_doc}, - {"dir", builtin_dir, METH_VARARGS, dir_doc}, - {"divmod", builtin_divmod, METH_VARARGS, divmod_doc}, - {"eval", builtin_eval, METH_VARARGS, eval_doc}, - {"execfile", builtin_execfile, METH_VARARGS, execfile_doc}, - {"filter", builtin_filter, METH_VARARGS, filter_doc}, - {"getattr", builtin_getattr, METH_VARARGS, getattr_doc}, - {"globals", (PyCFunction)builtin_globals, METH_NOARGS, globals_doc}, - {"hasattr", builtin_hasattr, METH_VARARGS, hasattr_doc}, - {"hash", builtin_hash, METH_O, hash_doc}, - {"hex", builtin_hex, METH_O, hex_doc}, - {"id", builtin_id, METH_O, id_doc}, - {"input", builtin_input, METH_VARARGS, input_doc}, - {"intern", builtin_intern, METH_VARARGS, intern_doc}, - {"isinstance", builtin_isinstance, METH_VARARGS, isinstance_doc}, - {"issubclass", builtin_issubclass, METH_VARARGS, issubclass_doc}, - {"iter", builtin_iter, METH_VARARGS, iter_doc}, - {"len", builtin_len, METH_O, len_doc}, - {"locals", (PyCFunction)builtin_locals, METH_NOARGS, locals_doc}, - {"map", builtin_map, METH_VARARGS, map_doc}, - {"max", builtin_max, METH_VARARGS, max_doc}, - {"min", builtin_min, METH_VARARGS, min_doc}, - {"oct", builtin_oct, METH_O, oct_doc}, - {"ord", builtin_ord, METH_O, ord_doc}, - {"pow", builtin_pow, METH_VARARGS, pow_doc}, - {"range", builtin_range, METH_VARARGS, range_doc}, - {"raw_input", builtin_raw_input, METH_VARARGS, raw_input_doc}, - {"reduce", builtin_reduce, METH_VARARGS, reduce_doc}, - {"reload", builtin_reload, METH_O, reload_doc}, - {"repr", builtin_repr, METH_O, repr_doc}, - {"round", builtin_round, METH_VARARGS, round_doc}, - {"setattr", builtin_setattr, METH_VARARGS, setattr_doc}, - {"sum", builtin_sum, METH_VARARGS, sum_doc}, -#ifdef Py_USING_UNICODE - {"unichr", builtin_unichr, METH_VARARGS, unichr_doc}, -#endif - {"vars", builtin_vars, METH_VARARGS, vars_doc}, - {"zip", builtin_zip, METH_VARARGS, zip_doc}, - {NULL, NULL}, -}; - -PyDoc_STRVAR(builtin_doc, -"Built-in functions, exceptions, and other objects.\n\ -\n\ -Noteworthy: None is the `nil' object; Ellipsis represents `...' in slices."); - -PyObject * -_PyBuiltin_Init(void) -{ - PyObject *mod, *dict, *debug; - mod = Py_InitModule4("__builtin__", builtin_methods, - builtin_doc, (PyObject *)NULL, - PYTHON_API_VERSION); - if (mod == NULL) - return NULL; - dict = PyModule_GetDict(mod); - -#ifdef Py_TRACE_REFS - /* __builtin__ exposes a number of statically allocated objects - * that, before this code was added in 2.3, never showed up in - * the list of "all objects" maintained by Py_TRACE_REFS. As a - * result, programs leaking references to None and False (etc) - * couldn't be diagnosed by examining sys.getobjects(0). - */ -#define ADD_TO_ALL(OBJECT) _Py_AddToAllObjects((PyObject *)(OBJECT), 0) -#else -#define ADD_TO_ALL(OBJECT) (void)0 -#endif - -#define SETBUILTIN(NAME, OBJECT) \ - if (PyDict_SetItemString(dict, NAME, (PyObject *)OBJECT) < 0) \ - return NULL; \ - ADD_TO_ALL(OBJECT) - - SETBUILTIN("None", Py_None); - SETBUILTIN("Ellipsis", Py_Ellipsis); - SETBUILTIN("NotImplemented", Py_NotImplemented); - SETBUILTIN("False", Py_False); - SETBUILTIN("True", Py_True); - SETBUILTIN("basestring", &PyBaseString_Type); - SETBUILTIN("bool", &PyBool_Type); - SETBUILTIN("buffer", &PyBuffer_Type); - SETBUILTIN("classmethod", &PyClassMethod_Type); -#ifndef WITHOUT_COMPLEX - SETBUILTIN("complex", &PyComplex_Type); -#endif - SETBUILTIN("dict", &PyDict_Type); - SETBUILTIN("enumerate", &PyEnum_Type); - SETBUILTIN("float", &PyFloat_Type); - SETBUILTIN("property", &PyProperty_Type); - SETBUILTIN("int", &PyInt_Type); - SETBUILTIN("list", &PyList_Type); - SETBUILTIN("long", &PyLong_Type); - SETBUILTIN("object", &PyBaseObject_Type); - SETBUILTIN("slice", &PySlice_Type); - SETBUILTIN("staticmethod", &PyStaticMethod_Type); - SETBUILTIN("str", &PyString_Type); - SETBUILTIN("super", &PySuper_Type); - SETBUILTIN("tuple", &PyTuple_Type); - SETBUILTIN("type", &PyType_Type); - SETBUILTIN("xrange", &PyRange_Type); - - /* Note that open() is just an alias of file(). */ - SETBUILTIN("open", &PyFile_Type); - SETBUILTIN("file", &PyFile_Type); -#ifdef Py_USING_UNICODE - SETBUILTIN("unicode", &PyUnicode_Type); -#endif - debug = PyBool_FromLong(Py_OptimizeFlag == 0); - if (PyDict_SetItemString(dict, "__debug__", debug) < 0) { - Py_XDECREF(debug); - return NULL; - } - Py_XDECREF(debug); - - return mod; -#undef ADD_TO_ALL -#undef SETBUILTIN -} - -/* Helper for filter(): filter a tuple through a function */ - -static PyObject * -filtertuple(PyObject *func, PyObject *tuple) -{ - PyObject *result; - register int i, j; - int len = PyTuple_Size(tuple); - - if (len == 0) { - if (PyTuple_CheckExact(tuple)) - Py_INCREF(tuple); - else - tuple = PyTuple_New(0); - return tuple; - } - - if ((result = PyTuple_New(len)) == NULL) - return NULL; - - for (i = j = 0; i < len; ++i) { - PyObject *item, *good; - int ok; - - if (tuple->ob_type->tp_as_sequence && - tuple->ob_type->tp_as_sequence->sq_item) { - item = tuple->ob_type->tp_as_sequence->sq_item(tuple, i); - if (item == NULL) - goto Fail_1; - } else { - PyErr_SetString(PyExc_TypeError, "filter(): unsubscriptable tuple"); - goto Fail_1; - } - if (func == Py_None) { - Py_INCREF(item); - good = item; - } - else { - PyObject *arg = Py_BuildValue("(O)", item); - if (arg == NULL) { - Py_DECREF(item); - goto Fail_1; - } - good = PyEval_CallObject(func, arg); - Py_DECREF(arg); - if (good == NULL) { - Py_DECREF(item); - goto Fail_1; - } - } - ok = PyObject_IsTrue(good); - Py_DECREF(good); - if (ok) { - if (PyTuple_SetItem(result, j++, item) < 0) - goto Fail_1; - } - else - Py_DECREF(item); - } - - if (_PyTuple_Resize(&result, j) < 0) - return NULL; - - return result; - -Fail_1: - Py_DECREF(result); - return NULL; -} - - -/* Helper for filter(): filter a string through a function */ - -static PyObject * -filterstring(PyObject *func, PyObject *strobj) -{ - PyObject *result; - register int i, j; - int len = PyString_Size(strobj); - int outlen = len; - - if (func == Py_None) { - /* If it's a real string we can return the original, - * as no character is ever false and __getitem__ - * does return this character. If it's a subclass - * we must go through the __getitem__ loop */ - if (PyString_CheckExact(strobj)) { - Py_INCREF(strobj); - return strobj; - } - } - if ((result = PyString_FromStringAndSize(NULL, len)) == NULL) - return NULL; - - for (i = j = 0; i < len; ++i) { - PyObject *item; - int ok; - - item = (*strobj->ob_type->tp_as_sequence->sq_item)(strobj, i); - if (item == NULL) - goto Fail_1; - if (func==Py_None) { - ok = 1; - } else { - PyObject *arg, *good; - arg = Py_BuildValue("(O)", item); - if (arg == NULL) { - Py_DECREF(item); - goto Fail_1; - } - good = PyEval_CallObject(func, arg); - Py_DECREF(arg); - if (good == NULL) { - Py_DECREF(item); - goto Fail_1; - } - ok = PyObject_IsTrue(good); - Py_DECREF(good); - } - if (ok) { - int reslen; - if (!PyString_Check(item)) { - PyErr_SetString(PyExc_TypeError, "can't filter str to str:" - " __getitem__ returned different type"); - Py_DECREF(item); - goto Fail_1; - } - reslen = PyString_GET_SIZE(item); - if (reslen == 1) { - PyString_AS_STRING(result)[j++] = - PyString_AS_STRING(item)[0]; - } else { - /* do we need more space? */ - int need = j + reslen + len-i-1; - if (need > outlen) { - /* overallocate, to avoid reallocations */ - if (need<2*outlen) - need = 2*outlen; - if (_PyString_Resize(&result, need)) { - Py_DECREF(item); - return NULL; - } - outlen = need; - } - memcpy( - PyString_AS_STRING(result) + j, - PyString_AS_STRING(item), - reslen - ); - j += reslen; - } - } - Py_DECREF(item); - } - - if (j < outlen) - _PyString_Resize(&result, j); - - return result; - -Fail_1: - Py_DECREF(result); - return NULL; -} - -#ifdef Py_USING_UNICODE -/* Helper for filter(): filter a Unicode object through a function */ - -static PyObject * -filterunicode(PyObject *func, PyObject *strobj) -{ - PyObject *result; - register int i, j; - int len = PyUnicode_GetSize(strobj); - int outlen = len; - - if (func == Py_None) { - /* If it's a real string we can return the original, - * as no character is ever false and __getitem__ - * does return this character. If it's a subclass - * we must go through the __getitem__ loop */ - if (PyUnicode_CheckExact(strobj)) { - Py_INCREF(strobj); - return strobj; - } - } - if ((result = PyUnicode_FromUnicode(NULL, len)) == NULL) - return NULL; - - for (i = j = 0; i < len; ++i) { - PyObject *item, *arg, *good; - int ok; - - item = (*strobj->ob_type->tp_as_sequence->sq_item)(strobj, i); - if (item == NULL) - goto Fail_1; - if (func == Py_None) { - ok = 1; - } else { - arg = Py_BuildValue("(O)", item); - if (arg == NULL) { - Py_DECREF(item); - goto Fail_1; - } - good = PyEval_CallObject(func, arg); - Py_DECREF(arg); - if (good == NULL) { - Py_DECREF(item); - goto Fail_1; - } - ok = PyObject_IsTrue(good); - Py_DECREF(good); - } - if (ok) { - int reslen; - if (!PyUnicode_Check(item)) { - PyErr_SetString(PyExc_TypeError, "can't filter unicode to unicode:" - " __getitem__ returned different type"); - Py_DECREF(item); - goto Fail_1; - } - reslen = PyUnicode_GET_SIZE(item); - if (reslen == 1) { - PyUnicode_AS_UNICODE(result)[j++] = - PyUnicode_AS_UNICODE(item)[0]; - } else { - /* do we need more space? */ - int need = j + reslen + len-i-1; - if (need > outlen) { - /* overallocate, to avoid reallocations */ - if (need<2*outlen) - need = 2*outlen; - if (PyUnicode_Resize(&result, need)) { - Py_DECREF(item); - goto Fail_1; - } - outlen = need; - } - memcpy( - PyUnicode_AS_UNICODE(result) + j, - PyUnicode_AS_UNICODE(item), - reslen*sizeof(Py_UNICODE) - ); - j += reslen; - } - } - Py_DECREF(item); - } - - if (j < outlen) - PyUnicode_Resize(&result, j); - - return result; - -Fail_1: - Py_DECREF(result); - return NULL; -} -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/ceval.c b/SDKs/XPlatform/Cypython-2.3.3/Python/ceval.c deleted file mode 100644 index 6a865ab5..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/ceval.c +++ /dev/null @@ -1,4142 +0,0 @@ - -/* Execute compiled code */ - -/* XXX TO DO: - XXX speed up searching for keywords by using a dictionary - XXX document it! - */ - -#include "Python.h" - -#include "compile.h" -#include "frameobject.h" -#include "eval.h" -#include "opcode.h" -#include "structmember.h" - -#ifdef macintosh -#include "macglue.h" -#endif - -#include - -/* Turn this on if your compiler chokes on the big switch: */ -/* #define CASE_TOO_BIG 1 */ - -#ifdef Py_DEBUG -/* For debugging the interpreter: */ -#define LLTRACE 1 /* Low-level trace feature */ -#define CHECKEXC 1 /* Double-check exception checking */ -#endif - -typedef PyObject *(*callproc)(PyObject *, PyObject *, PyObject *); - -/* Forward declarations */ -static PyObject *eval_frame(PyFrameObject *); -static PyObject *call_function(PyObject ***, int); -static PyObject *fast_function(PyObject *, PyObject ***, int, int, int); -static PyObject *do_call(PyObject *, PyObject ***, int, int); -static PyObject *ext_do_call(PyObject *, PyObject ***, int, int, int); -static PyObject *update_keyword_args(PyObject *, int, PyObject ***,PyObject *); -static PyObject *update_star_args(int, int, PyObject *, PyObject ***); -static PyObject *load_args(PyObject ***, int); -#define CALL_FLAG_VAR 1 -#define CALL_FLAG_KW 2 - -#ifdef LLTRACE -static int prtrace(PyObject *, char *); -#endif -static int call_trace(Py_tracefunc, PyObject *, PyFrameObject *, - int, PyObject *); -static void call_trace_protected(Py_tracefunc, PyObject *, - PyFrameObject *, int); -static void call_exc_trace(Py_tracefunc, PyObject *, PyFrameObject *); -static int maybe_call_line_trace(Py_tracefunc, PyObject *, - PyFrameObject *, int *, int *); - -static PyObject *apply_slice(PyObject *, PyObject *, PyObject *); -static int assign_slice(PyObject *, PyObject *, - PyObject *, PyObject *); -static PyObject *cmp_outcome(int, PyObject *, PyObject *); -static PyObject *import_from(PyObject *, PyObject *); -static int import_all_from(PyObject *, PyObject *); -static PyObject *build_class(PyObject *, PyObject *, PyObject *); -static int exec_statement(PyFrameObject *, - PyObject *, PyObject *, PyObject *); -static void set_exc_info(PyThreadState *, PyObject *, PyObject *, PyObject *); -static void reset_exc_info(PyThreadState *); -static void format_exc_check_arg(PyObject *, char *, PyObject *); - -#define NAME_ERROR_MSG \ - "name '%.200s' is not defined" -#define GLOBAL_NAME_ERROR_MSG \ - "global name '%.200s' is not defined" -#define UNBOUNDLOCAL_ERROR_MSG \ - "local variable '%.200s' referenced before assignment" -#define UNBOUNDFREE_ERROR_MSG \ - "free variable '%.200s' referenced before assignment" \ - " in enclosing scope" - -/* Dynamic execution profile */ -#ifdef DYNAMIC_EXECUTION_PROFILE -#ifdef DXPAIRS -static long dxpairs[257][256]; -#define dxp dxpairs[256] -#else -static long dxp[256]; -#endif -#endif - -/* Function call profile */ -#ifdef CALL_PROFILE -#define PCALL_NUM 11 -static int pcall[PCALL_NUM]; - -#define PCALL_ALL 0 -#define PCALL_FUNCTION 1 -#define PCALL_FAST_FUNCTION 2 -#define PCALL_FASTER_FUNCTION 3 -#define PCALL_METHOD 4 -#define PCALL_BOUND_METHOD 5 -#define PCALL_CFUNCTION 6 -#define PCALL_TYPE 7 -#define PCALL_GENERATOR 8 -#define PCALL_OTHER 9 -#define PCALL_POP 10 - -/* Notes about the statistics - - PCALL_FAST stats - - FAST_FUNCTION means no argument tuple needs to be created. - FASTER_FUNCTION means that the fast-path frame setup code is used. - - If there is a method call where the call can be optimized by changing - the argument tuple and calling the function directly, it gets recorded - twice. - - As a result, the relationship among the statistics appears to be - PCALL_ALL == PCALL_FUNCTION + PCALL_METHOD - PCALL_BOUND_METHOD + - PCALL_CFUNCTION + PCALL_TYPE + PCALL_GENERATOR + PCALL_OTHER - PCALL_FUNCTION > PCALL_FAST_FUNCTION > PCALL_FASTER_FUNCTION - PCALL_METHOD > PCALL_BOUND_METHOD -*/ - -#define PCALL(POS) pcall[POS]++ - -PyObject * -PyEval_GetCallStats(PyObject *self) -{ - return Py_BuildValue("iiiiiiiiii", - pcall[0], pcall[1], pcall[2], pcall[3], - pcall[4], pcall[5], pcall[6], pcall[7], - pcall[8], pcall[9]); -} -#else -#define PCALL(O) - -PyObject * -PyEval_GetCallStats(PyObject *self) -{ - Py_INCREF(Py_None); - return Py_None; -} -#endif - -static PyTypeObject gentype; - -typedef struct { - PyObject_HEAD - /* The gi_ prefix is intended to remind of generator-iterator. */ - - PyFrameObject *gi_frame; - - /* True if generator is being executed. */ - int gi_running; - - /* List of weak reference. */ - PyObject *gi_weakreflist; -} genobject; - -static PyObject * -gen_new(PyFrameObject *f) -{ - genobject *gen = PyObject_GC_New(genobject, &gentype); - if (gen == NULL) { - Py_DECREF(f); - return NULL; - } - gen->gi_frame = f; - gen->gi_running = 0; - gen->gi_weakreflist = NULL; - _PyObject_GC_TRACK(gen); - return (PyObject *)gen; -} - -static int -gen_traverse(genobject *gen, visitproc visit, void *arg) -{ - return visit((PyObject *)gen->gi_frame, arg); -} - -static void -gen_dealloc(genobject *gen) -{ - _PyObject_GC_UNTRACK(gen); - if (gen->gi_weakreflist != NULL) - PyObject_ClearWeakRefs((PyObject *) gen); - Py_DECREF(gen->gi_frame); - PyObject_GC_Del(gen); -} - -static PyObject * -gen_iternext(genobject *gen) -{ - PyThreadState *tstate = PyThreadState_GET(); - PyFrameObject *f = gen->gi_frame; - PyObject *result; - - if (gen->gi_running) { - PyErr_SetString(PyExc_ValueError, - "generator already executing"); - return NULL; - } - if (f->f_stacktop == NULL) - return NULL; - - /* Generators always return to their most recent caller, not - * necessarily their creator. */ - Py_XINCREF(tstate->frame); - assert(f->f_back == NULL); - f->f_back = tstate->frame; - - gen->gi_running = 1; - result = eval_frame(f); - gen->gi_running = 0; - - /* Don't keep the reference to f_back any longer than necessary. It - * may keep a chain of frames alive or it could create a reference - * cycle. */ - Py_XDECREF(f->f_back); - f->f_back = NULL; - - /* If the generator just returned (as opposed to yielding), signal - * that the generator is exhausted. */ - if (result == Py_None && f->f_stacktop == NULL) { - Py_DECREF(result); - result = NULL; - } - - return result; -} - -static PyObject * -gen_getiter(PyObject *gen) -{ - Py_INCREF(gen); - return gen; -} - -static PyMemberDef gen_memberlist[] = { - {"gi_frame", T_OBJECT, offsetof(genobject, gi_frame), RO}, - {"gi_running", T_INT, offsetof(genobject, gi_running), RO}, - {NULL} /* Sentinel */ -}; - -static PyTypeObject gentype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "generator", /* tp_name */ - sizeof(genobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)gen_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - 0, /* tp_doc */ - (traverseproc)gen_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - offsetof(genobject, gi_weakreflist), /* tp_weaklistoffset */ - (getiterfunc)gen_getiter, /* tp_iter */ - (iternextfunc)gen_iternext, /* tp_iternext */ - 0, /* tp_methods */ - gen_memberlist, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ -}; - - -#ifdef WITH_THREAD - -#ifndef DONT_HAVE_ERRNO_H -#include -#endif -#include "pythread.h" - -extern int _PyThread_Started; /* Flag for Py_Exit */ - -static PyThread_type_lock interpreter_lock = 0; /* This is the GIL */ -static long main_thread = 0; - -void -PyEval_InitThreads(void) -{ - if (interpreter_lock) - return; - _PyThread_Started = 1; - interpreter_lock = PyThread_allocate_lock(); - PyThread_acquire_lock(interpreter_lock, 1); - main_thread = PyThread_get_thread_ident(); -} - -void -PyEval_AcquireLock(void) -{ - PyThread_acquire_lock(interpreter_lock, 1); -} - -void -PyEval_ReleaseLock(void) -{ - PyThread_release_lock(interpreter_lock); -} - -void -PyEval_AcquireThread(PyThreadState *tstate) -{ - if (tstate == NULL) - Py_FatalError("PyEval_AcquireThread: NULL new thread state"); - /* Check someone has called PyEval_InitThreads() to create the lock */ - assert(interpreter_lock); - PyThread_acquire_lock(interpreter_lock, 1); - if (PyThreadState_Swap(tstate) != NULL) - Py_FatalError( - "PyEval_AcquireThread: non-NULL old thread state"); -} - -void -PyEval_ReleaseThread(PyThreadState *tstate) -{ - if (tstate == NULL) - Py_FatalError("PyEval_ReleaseThread: NULL thread state"); - if (PyThreadState_Swap(NULL) != tstate) - Py_FatalError("PyEval_ReleaseThread: wrong thread state"); - PyThread_release_lock(interpreter_lock); -} - -/* This function is called from PyOS_AfterFork to ensure that newly - created child processes don't hold locks referring to threads which - are not running in the child process. (This could also be done using - pthread_atfork mechanism, at least for the pthreads implementation.) */ - -void -PyEval_ReInitThreads(void) -{ - if (!interpreter_lock) - return; - /*XXX Can't use PyThread_free_lock here because it does too - much error-checking. Doing this cleanly would require - adding a new function to each thread_*.h. Instead, just - create a new lock and waste a little bit of memory */ - interpreter_lock = PyThread_allocate_lock(); - PyThread_acquire_lock(interpreter_lock, 1); - main_thread = PyThread_get_thread_ident(); -} -#endif - -/* Functions save_thread and restore_thread are always defined so - dynamically loaded modules needn't be compiled separately for use - with and without threads: */ - -PyThreadState * -PyEval_SaveThread(void) -{ - PyThreadState *tstate = PyThreadState_Swap(NULL); - if (tstate == NULL) - Py_FatalError("PyEval_SaveThread: NULL tstate"); -#ifdef WITH_THREAD - if (interpreter_lock) - PyThread_release_lock(interpreter_lock); -#endif - return tstate; -} - -void -PyEval_RestoreThread(PyThreadState *tstate) -{ - if (tstate == NULL) - Py_FatalError("PyEval_RestoreThread: NULL tstate"); -#ifdef WITH_THREAD - if (interpreter_lock) { - int err = errno; - PyThread_acquire_lock(interpreter_lock, 1); - errno = err; - } -#endif - PyThreadState_Swap(tstate); -} - - -/* Mechanism whereby asynchronously executing callbacks (e.g. UNIX - signal handlers or Mac I/O completion routines) can schedule calls - to a function to be called synchronously. - The synchronous function is called with one void* argument. - It should return 0 for success or -1 for failure -- failure should - be accompanied by an exception. - - If registry succeeds, the registry function returns 0; if it fails - (e.g. due to too many pending calls) it returns -1 (without setting - an exception condition). - - Note that because registry may occur from within signal handlers, - or other asynchronous events, calling malloc() is unsafe! - -#ifdef WITH_THREAD - Any thread can schedule pending calls, but only the main thread - will execute them. -#endif - - XXX WARNING! ASYNCHRONOUSLY EXECUTING CODE! - There are two possible race conditions: - (1) nested asynchronous registry calls; - (2) registry calls made while pending calls are being processed. - While (1) is very unlikely, (2) is a real possibility. - The current code is safe against (2), but not against (1). - The safety against (2) is derived from the fact that only one - thread (the main thread) ever takes things out of the queue. - - XXX Darn! With the advent of thread state, we should have an array - of pending calls per thread in the thread state! Later... -*/ - -#define NPENDINGCALLS 32 -static struct { - int (*func)(void *); - void *arg; -} pendingcalls[NPENDINGCALLS]; -static volatile int pendingfirst = 0; -static volatile int pendinglast = 0; -static volatile int things_to_do = 0; - -int -Py_AddPendingCall(int (*func)(void *), void *arg) -{ - static int busy = 0; - int i, j; - /* XXX Begin critical section */ - /* XXX If you want this to be safe against nested - XXX asynchronous calls, you'll have to work harder! */ - if (busy) - return -1; - busy = 1; - i = pendinglast; - j = (i + 1) % NPENDINGCALLS; - if (j == pendingfirst) { - busy = 0; - return -1; /* Queue full */ - } - pendingcalls[i].func = func; - pendingcalls[i].arg = arg; - pendinglast = j; - - _Py_Ticker = 0; - things_to_do = 1; /* Signal main loop */ - busy = 0; - /* XXX End critical section */ - return 0; -} - -int -Py_MakePendingCalls(void) -{ - static int busy = 0; -#ifdef WITH_THREAD - if (main_thread && PyThread_get_thread_ident() != main_thread) - return 0; -#endif - if (busy) - return 0; - busy = 1; - things_to_do = 0; - for (;;) { - int i; - int (*func)(void *); - void *arg; - i = pendingfirst; - if (i == pendinglast) - break; /* Queue empty */ - func = pendingcalls[i].func; - arg = pendingcalls[i].arg; - pendingfirst = (i + 1) % NPENDINGCALLS; - if (func(arg) < 0) { - busy = 0; - things_to_do = 1; /* We're not done yet */ - return -1; - } - } - busy = 0; - return 0; -} - - -/* The interpreter's recursion limit */ - -static int recursion_limit = 1000; - -int -Py_GetRecursionLimit(void) -{ - return recursion_limit; -} - -void -Py_SetRecursionLimit(int new_limit) -{ - recursion_limit = new_limit; -} - -/* Status code for main loop (reason for stack unwind) */ - -enum why_code { - WHY_NOT, /* No error */ - WHY_EXCEPTION, /* Exception occurred */ - WHY_RERAISE, /* Exception re-raised by 'finally' */ - WHY_RETURN, /* 'return' statement */ - WHY_BREAK, /* 'break' statement */ - WHY_CONTINUE, /* 'continue' statement */ - WHY_YIELD /* 'yield' operator */ -}; - -static enum why_code do_raise(PyObject *, PyObject *, PyObject *); -static int unpack_iterable(PyObject *, int, PyObject **); - -/* for manipulating the thread switch and periodic "stuff" - used to be - per thread, now just a pair o' globals */ -int _Py_CheckInterval = 100; -volatile int _Py_Ticker = 100; - -PyObject * -PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals) -{ - /* XXX raise SystemError if globals is NULL */ - return PyEval_EvalCodeEx(co, - globals, locals, - (PyObject **)NULL, 0, - (PyObject **)NULL, 0, - (PyObject **)NULL, 0, - NULL); -} - - -/* Interpreter main loop */ - -static PyObject * -eval_frame(PyFrameObject *f) -{ -#ifdef DXPAIRS - int lastopcode = 0; -#endif - PyObject **stack_pointer; /* Next free slot in value stack */ - register unsigned char *next_instr; - register int opcode=0; /* Current opcode */ - register int oparg=0; /* Current opcode argument, if any */ - register enum why_code why; /* Reason for block stack unwind */ - register int err; /* Error status -- nonzero if error */ - register PyObject *x; /* Result object -- NULL if error */ - register PyObject *v; /* Temporary objects popped off stack */ - register PyObject *w; - register PyObject *u; - register PyObject *t; - register PyObject *stream = NULL; /* for PRINT opcodes */ - register PyObject **fastlocals, **freevars; - PyObject *retval = NULL; /* Return value */ - PyThreadState *tstate = PyThreadState_GET(); - PyCodeObject *co; - - /* when tracing we set things up so that - - not (instr_lb <= current_bytecode_offset < instr_ub) - - is true when the line being executed has changed. The - initial values are such as to make this false the first - time it is tested. */ - int instr_ub = -1, instr_lb = 0; - - unsigned char *first_instr; - PyObject *names; - PyObject *consts; -#ifdef LLTRACE - int lltrace; -#endif -#if defined(Py_DEBUG) || defined(LLTRACE) - /* Make it easier to find out where we are with a debugger */ - char *filename; -#endif - -/* Tuple access macros */ - -#ifndef Py_DEBUG -#define GETITEM(v, i) PyTuple_GET_ITEM((PyTupleObject *)(v), (i)) -#else -#define GETITEM(v, i) PyTuple_GetItem((v), (i)) -#endif - -/* Code access macros */ - -#define INSTR_OFFSET() (next_instr - first_instr) -#define NEXTOP() (*next_instr++) -#define NEXTARG() (next_instr += 2, (next_instr[-1]<<8) + next_instr[-2]) -#define JUMPTO(x) (next_instr = first_instr + (x)) -#define JUMPBY(x) (next_instr += (x)) - -/* OpCode prediction macros - Some opcodes tend to come in pairs thus making it possible to predict - the second code when the first is run. For example, COMPARE_OP is often - followed by JUMP_IF_FALSE or JUMP_IF_TRUE. And, those opcodes are often - followed by a POP_TOP. - - Verifying the prediction costs a single high-speed test of register - variable against a constant. If the pairing was good, then the - processor has a high likelihood of making its own successful branch - prediction which results in a nearly zero overhead transition to the - next opcode. - - A successful prediction saves a trip through the eval-loop including - its two unpredictable branches, the HASARG test and the switch-case. -*/ - -#define PREDICT(op) if (*next_instr == op) goto PRED_##op -#define PREDICTED(op) PRED_##op: next_instr++ -#define PREDICTED_WITH_ARG(op) PRED_##op: oparg = (next_instr[2]<<8) + \ - next_instr[1]; next_instr += 3 - -/* Stack manipulation macros */ - -#define STACK_LEVEL() (stack_pointer - f->f_valuestack) -#define EMPTY() (STACK_LEVEL() == 0) -#define TOP() (stack_pointer[-1]) -#define SECOND() (stack_pointer[-2]) -#define THIRD() (stack_pointer[-3]) -#define FOURTH() (stack_pointer[-4]) -#define SET_TOP(v) (stack_pointer[-1] = (v)) -#define SET_SECOND(v) (stack_pointer[-2] = (v)) -#define SET_THIRD(v) (stack_pointer[-3] = (v)) -#define SET_FOURTH(v) (stack_pointer[-4] = (v)) -#define BASIC_STACKADJ(n) (stack_pointer += n) -#define BASIC_PUSH(v) (*stack_pointer++ = (v)) -#define BASIC_POP() (*--stack_pointer) - -#ifdef LLTRACE -#define PUSH(v) { (void)(BASIC_PUSH(v), \ - lltrace && prtrace(TOP(), "push")); \ - assert(STACK_LEVEL() <= f->f_stacksize); } -#define POP() ((void)(lltrace && prtrace(TOP(), "pop")), BASIC_POP()) -#define STACKADJ(n) { (void)(BASIC_STACKADJ(n), \ - lltrace && prtrace(TOP(), "stackadj")); \ - assert(STACK_LEVEL() <= f->f_stacksize); } -#else -#define PUSH(v) BASIC_PUSH(v) -#define POP() BASIC_POP() -#define STACKADJ(n) BASIC_STACKADJ(n) -#endif - -/* Local variable macros */ - -#define GETLOCAL(i) (fastlocals[i]) - -/* The SETLOCAL() macro must not DECREF the local variable in-place and - then store the new value; it must copy the old value to a temporary - value, then store the new value, and then DECREF the temporary value. - This is because it is possible that during the DECREF the frame is - accessed by other code (e.g. a __del__ method or gc.collect()) and the - variable would be pointing to already-freed memory. */ -#define SETLOCAL(i, value) do { PyObject *tmp = GETLOCAL(i); \ - GETLOCAL(i) = value; \ - Py_XDECREF(tmp); } while (0) - -/* Start of code */ - - if (f == NULL) - return NULL; - -#ifdef USE_STACKCHECK - if (tstate->recursion_depth%10 == 0 && PyOS_CheckStack()) { - PyErr_SetString(PyExc_MemoryError, "Stack overflow"); - return NULL; - } -#endif - - /* push frame */ - if (++tstate->recursion_depth > recursion_limit) { - --tstate->recursion_depth; - PyErr_SetString(PyExc_RuntimeError, - "maximum recursion depth exceeded"); - tstate->frame = f->f_back; - return NULL; - } - - tstate->frame = f; - - if (tstate->use_tracing) { - if (tstate->c_tracefunc != NULL) { - /* tstate->c_tracefunc, if defined, is a - function that will be called on *every* entry - to a code block. Its return value, if not - None, is a function that will be called at - the start of each executed line of code. - (Actually, the function must return itself - in order to continue tracing.) The trace - functions are called with three arguments: - a pointer to the current frame, a string - indicating why the function is called, and - an argument which depends on the situation. - The global trace function is also called - whenever an exception is detected. */ - if (call_trace(tstate->c_tracefunc, tstate->c_traceobj, - f, PyTrace_CALL, Py_None)) { - /* Trace function raised an error */ - --tstate->recursion_depth; - tstate->frame = f->f_back; - return NULL; - } - } - if (tstate->c_profilefunc != NULL) { - /* Similar for c_profilefunc, except it needn't - return itself and isn't called for "line" events */ - if (call_trace(tstate->c_profilefunc, - tstate->c_profileobj, - f, PyTrace_CALL, Py_None)) { - /* Profile function raised an error */ - --tstate->recursion_depth; - tstate->frame = f->f_back; - return NULL; - } - } - } - - co = f->f_code; - names = co->co_names; - consts = co->co_consts; - fastlocals = f->f_localsplus; - freevars = f->f_localsplus + f->f_nlocals; - _PyCode_GETCODEPTR(co, &first_instr); - /* An explanation is in order for the next line. - - f->f_lasti now refers to the index of the last instruction - executed. You might think this was obvious from the name, but - this wasn't always true before 2.3! PyFrame_New now sets - f->f_lasti to -1 (i.e. the index *before* the first instruction) - and YIELD_VALUE doesn't fiddle with f_lasti any more. So this - does work. Promise. */ - next_instr = first_instr + f->f_lasti + 1; - stack_pointer = f->f_stacktop; - assert(stack_pointer != NULL); - f->f_stacktop = NULL; /* remains NULL unless yield suspends frame */ - -#ifdef LLTRACE - lltrace = PyDict_GetItemString(f->f_globals,"__lltrace__") != NULL; -#endif -#if defined(Py_DEBUG) || defined(LLTRACE) - filename = PyString_AsString(co->co_filename); -#endif - - why = WHY_NOT; - err = 0; - x = Py_None; /* Not a reference, just anything non-NULL */ - w = NULL; - - for (;;) { - assert(stack_pointer >= f->f_valuestack); /* else underflow */ - assert(STACK_LEVEL() <= f->f_stacksize); /* else overflow */ - - /* Do periodic things. Doing this every time through - the loop would add too much overhead, so we do it - only every Nth instruction. We also do it if - ``things_to_do'' is set, i.e. when an asynchronous - event needs attention (e.g. a signal handler or - async I/O handler); see Py_AddPendingCall() and - Py_MakePendingCalls() above. */ - - if (--_Py_Ticker < 0) { - if (*next_instr == SETUP_FINALLY) { - /* Make the last opcode before - a try: finally: block uninterruptable. */ - goto fast_next_opcode; - } - _Py_Ticker = _Py_CheckInterval; - tstate->tick_counter++; - if (things_to_do) { - if (Py_MakePendingCalls() < 0) { - why = WHY_EXCEPTION; - goto on_error; - } - } -#if !defined(HAVE_SIGNAL_H) || defined(macintosh) - /* If we have true signals, the signal handler - will call Py_AddPendingCall() so we don't - have to call PyErr_CheckSignals(). On the - Mac and DOS, alas, we have to call it. */ - if (PyErr_CheckSignals()) { - why = WHY_EXCEPTION; - goto on_error; - } -#endif - -#ifdef WITH_THREAD - if (interpreter_lock) { - /* Give another thread a chance */ - - if (PyThreadState_Swap(NULL) != tstate) - Py_FatalError("ceval: tstate mix-up"); - PyThread_release_lock(interpreter_lock); - - /* Other threads may run now */ - - PyThread_acquire_lock(interpreter_lock, 1); - if (PyThreadState_Swap(tstate) != NULL) - Py_FatalError("ceval: orphan tstate"); - - /* Check for thread interrupts */ - - if (tstate->async_exc != NULL) { - x = tstate->async_exc; - tstate->async_exc = NULL; - PyErr_SetNone(x); - Py_DECREF(x); - why = WHY_EXCEPTION; - goto on_error; - } - } -#endif - } - - fast_next_opcode: - f->f_lasti = INSTR_OFFSET(); - - /* line-by-line tracing support */ - - if (tstate->c_tracefunc != NULL && !tstate->tracing) { - /* see maybe_call_line_trace - for expository comments */ - f->f_stacktop = stack_pointer; - - err = maybe_call_line_trace(tstate->c_tracefunc, - tstate->c_traceobj, - f, &instr_lb, &instr_ub); - /* Reload possibly changed frame fields */ - JUMPTO(f->f_lasti); - if (f->f_stacktop != NULL) { - stack_pointer = f->f_stacktop; - f->f_stacktop = NULL; - } - if (err) { - /* trace function raised an exception */ - goto on_error; - } - } - - /* Extract opcode and argument */ - - opcode = NEXTOP(); - if (HAS_ARG(opcode)) - oparg = NEXTARG(); - dispatch_opcode: -#ifdef DYNAMIC_EXECUTION_PROFILE -#ifdef DXPAIRS - dxpairs[lastopcode][opcode]++; - lastopcode = opcode; -#endif - dxp[opcode]++; -#endif - -#ifdef LLTRACE - /* Instruction tracing */ - - if (lltrace) { - if (HAS_ARG(opcode)) { - printf("%d: %d, %d\n", - f->f_lasti, opcode, oparg); - } - else { - printf("%d: %d\n", - f->f_lasti, opcode); - } - } -#endif - - /* Main switch on opcode */ - - switch (opcode) { - - /* BEWARE! - It is essential that any operation that fails sets either - x to NULL, err to nonzero, or why to anything but WHY_NOT, - and that no operation that succeeds does this! */ - - /* case STOP_CODE: this is an error! */ - - case LOAD_FAST: - x = GETLOCAL(oparg); - if (x != NULL) { - Py_INCREF(x); - PUSH(x); - goto fast_next_opcode; - } - format_exc_check_arg(PyExc_UnboundLocalError, - UNBOUNDLOCAL_ERROR_MSG, - PyTuple_GetItem(co->co_varnames, oparg)); - break; - - case LOAD_CONST: - x = GETITEM(consts, oparg); - Py_INCREF(x); - PUSH(x); - goto fast_next_opcode; - - PREDICTED_WITH_ARG(STORE_FAST); - case STORE_FAST: - v = POP(); - SETLOCAL(oparg, v); - goto fast_next_opcode; - - PREDICTED(POP_TOP); - case POP_TOP: - v = POP(); - Py_DECREF(v); - goto fast_next_opcode; - - case ROT_TWO: - v = TOP(); - w = SECOND(); - SET_TOP(w); - SET_SECOND(v); - goto fast_next_opcode; - - case ROT_THREE: - v = TOP(); - w = SECOND(); - x = THIRD(); - SET_TOP(w); - SET_SECOND(x); - SET_THIRD(v); - goto fast_next_opcode; - - case ROT_FOUR: - u = TOP(); - v = SECOND(); - w = THIRD(); - x = FOURTH(); - SET_TOP(v); - SET_SECOND(w); - SET_THIRD(x); - SET_FOURTH(u); - goto fast_next_opcode; - - case DUP_TOP: - v = TOP(); - Py_INCREF(v); - PUSH(v); - goto fast_next_opcode; - - case DUP_TOPX: - if (oparg == 2) { - x = TOP(); - Py_INCREF(x); - w = SECOND(); - Py_INCREF(w); - STACKADJ(2); - SET_TOP(x); - SET_SECOND(w); - goto fast_next_opcode; - } else if (oparg == 3) { - x = TOP(); - Py_INCREF(x); - w = SECOND(); - Py_INCREF(w); - v = THIRD(); - Py_INCREF(v); - STACKADJ(3); - SET_TOP(x); - SET_SECOND(w); - SET_THIRD(v); - goto fast_next_opcode; - } - Py_FatalError("invalid argument to DUP_TOPX" - " (bytecode corruption?)"); - break; - - case UNARY_POSITIVE: - v = TOP(); - x = PyNumber_Positive(v); - Py_DECREF(v); - SET_TOP(x); - if (x != NULL) continue; - break; - - case UNARY_NEGATIVE: - v = TOP(); - x = PyNumber_Negative(v); - Py_DECREF(v); - SET_TOP(x); - if (x != NULL) continue; - break; - - case UNARY_NOT: - v = TOP(); - err = PyObject_IsTrue(v); - Py_DECREF(v); - if (err == 0) { - Py_INCREF(Py_True); - SET_TOP(Py_True); - continue; - } - else if (err > 0) { - Py_INCREF(Py_False); - SET_TOP(Py_False); - err = 0; - continue; - } - STACKADJ(-1); - break; - - case UNARY_CONVERT: - v = TOP(); - x = PyObject_Repr(v); - Py_DECREF(v); - SET_TOP(x); - if (x != NULL) continue; - break; - - case UNARY_INVERT: - v = TOP(); - x = PyNumber_Invert(v); - Py_DECREF(v); - SET_TOP(x); - if (x != NULL) continue; - break; - - case BINARY_POWER: - w = POP(); - v = TOP(); - x = PyNumber_Power(v, w, Py_None); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case BINARY_MULTIPLY: - w = POP(); - v = TOP(); - x = PyNumber_Multiply(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case BINARY_DIVIDE: - if (!_Py_QnewFlag) { - w = POP(); - v = TOP(); - x = PyNumber_Divide(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - } - /* -Qnew is in effect: fall through to - BINARY_TRUE_DIVIDE */ - case BINARY_TRUE_DIVIDE: - w = POP(); - v = TOP(); - x = PyNumber_TrueDivide(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case BINARY_FLOOR_DIVIDE: - w = POP(); - v = TOP(); - x = PyNumber_FloorDivide(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case BINARY_MODULO: - w = POP(); - v = TOP(); - x = PyNumber_Remainder(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case BINARY_ADD: - w = POP(); - v = TOP(); - if (PyInt_CheckExact(v) && PyInt_CheckExact(w)) { - /* INLINE: int + int */ - register long a, b, i; - a = PyInt_AS_LONG(v); - b = PyInt_AS_LONG(w); - i = a + b; - if ((i^a) < 0 && (i^b) < 0) - goto slow_add; - x = PyInt_FromLong(i); - } - else { - slow_add: - x = PyNumber_Add(v, w); - } - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case BINARY_SUBTRACT: - w = POP(); - v = TOP(); - if (PyInt_CheckExact(v) && PyInt_CheckExact(w)) { - /* INLINE: int - int */ - register long a, b, i; - a = PyInt_AS_LONG(v); - b = PyInt_AS_LONG(w); - i = a - b; - if ((i^a) < 0 && (i^~b) < 0) - goto slow_sub; - x = PyInt_FromLong(i); - } - else { - slow_sub: - x = PyNumber_Subtract(v, w); - } - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case BINARY_SUBSCR: - w = POP(); - v = TOP(); - if (PyList_CheckExact(v) && PyInt_CheckExact(w)) { - /* INLINE: list[int] */ - long i = PyInt_AsLong(w); - if (i < 0) - i += PyList_GET_SIZE(v); - if (i < 0 || - i >= PyList_GET_SIZE(v)) { - PyErr_SetString(PyExc_IndexError, - "list index out of range"); - x = NULL; - } - else { - x = PyList_GET_ITEM(v, i); - Py_INCREF(x); - } - } - else - x = PyObject_GetItem(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case BINARY_LSHIFT: - w = POP(); - v = TOP(); - x = PyNumber_Lshift(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case BINARY_RSHIFT: - w = POP(); - v = TOP(); - x = PyNumber_Rshift(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case BINARY_AND: - w = POP(); - v = TOP(); - x = PyNumber_And(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case BINARY_XOR: - w = POP(); - v = TOP(); - x = PyNumber_Xor(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case BINARY_OR: - w = POP(); - v = TOP(); - x = PyNumber_Or(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case INPLACE_POWER: - w = POP(); - v = TOP(); - x = PyNumber_InPlacePower(v, w, Py_None); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case INPLACE_MULTIPLY: - w = POP(); - v = TOP(); - x = PyNumber_InPlaceMultiply(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case INPLACE_DIVIDE: - if (!_Py_QnewFlag) { - w = POP(); - v = TOP(); - x = PyNumber_InPlaceDivide(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - } - /* -Qnew is in effect: fall through to - INPLACE_TRUE_DIVIDE */ - case INPLACE_TRUE_DIVIDE: - w = POP(); - v = TOP(); - x = PyNumber_InPlaceTrueDivide(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case INPLACE_FLOOR_DIVIDE: - w = POP(); - v = TOP(); - x = PyNumber_InPlaceFloorDivide(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case INPLACE_MODULO: - w = POP(); - v = TOP(); - x = PyNumber_InPlaceRemainder(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case INPLACE_ADD: - w = POP(); - v = TOP(); - if (PyInt_CheckExact(v) && PyInt_CheckExact(w)) { - /* INLINE: int + int */ - register long a, b, i; - a = PyInt_AS_LONG(v); - b = PyInt_AS_LONG(w); - i = a + b; - if ((i^a) < 0 && (i^b) < 0) - goto slow_iadd; - x = PyInt_FromLong(i); - } - else { - slow_iadd: - x = PyNumber_InPlaceAdd(v, w); - } - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case INPLACE_SUBTRACT: - w = POP(); - v = TOP(); - if (PyInt_CheckExact(v) && PyInt_CheckExact(w)) { - /* INLINE: int - int */ - register long a, b, i; - a = PyInt_AS_LONG(v); - b = PyInt_AS_LONG(w); - i = a - b; - if ((i^a) < 0 && (i^~b) < 0) - goto slow_isub; - x = PyInt_FromLong(i); - } - else { - slow_isub: - x = PyNumber_InPlaceSubtract(v, w); - } - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case INPLACE_LSHIFT: - w = POP(); - v = TOP(); - x = PyNumber_InPlaceLshift(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case INPLACE_RSHIFT: - w = POP(); - v = TOP(); - x = PyNumber_InPlaceRshift(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case INPLACE_AND: - w = POP(); - v = TOP(); - x = PyNumber_InPlaceAnd(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case INPLACE_XOR: - w = POP(); - v = TOP(); - x = PyNumber_InPlaceXor(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case INPLACE_OR: - w = POP(); - v = TOP(); - x = PyNumber_InPlaceOr(v, w); - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case SLICE+0: - case SLICE+1: - case SLICE+2: - case SLICE+3: - if ((opcode-SLICE) & 2) - w = POP(); - else - w = NULL; - if ((opcode-SLICE) & 1) - v = POP(); - else - v = NULL; - u = TOP(); - x = apply_slice(u, v, w); - Py_DECREF(u); - Py_XDECREF(v); - Py_XDECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case STORE_SLICE+0: - case STORE_SLICE+1: - case STORE_SLICE+2: - case STORE_SLICE+3: - if ((opcode-STORE_SLICE) & 2) - w = POP(); - else - w = NULL; - if ((opcode-STORE_SLICE) & 1) - v = POP(); - else - v = NULL; - u = POP(); - t = POP(); - err = assign_slice(u, v, w, t); /* u[v:w] = t */ - Py_DECREF(t); - Py_DECREF(u); - Py_XDECREF(v); - Py_XDECREF(w); - if (err == 0) continue; - break; - - case DELETE_SLICE+0: - case DELETE_SLICE+1: - case DELETE_SLICE+2: - case DELETE_SLICE+3: - if ((opcode-DELETE_SLICE) & 2) - w = POP(); - else - w = NULL; - if ((opcode-DELETE_SLICE) & 1) - v = POP(); - else - v = NULL; - u = POP(); - err = assign_slice(u, v, w, (PyObject *)NULL); - /* del u[v:w] */ - Py_DECREF(u); - Py_XDECREF(v); - Py_XDECREF(w); - if (err == 0) continue; - break; - - case STORE_SUBSCR: - w = TOP(); - v = SECOND(); - u = THIRD(); - STACKADJ(-3); - /* v[w] = u */ - err = PyObject_SetItem(v, w, u); - Py_DECREF(u); - Py_DECREF(v); - Py_DECREF(w); - if (err == 0) continue; - break; - - case DELETE_SUBSCR: - w = TOP(); - v = SECOND(); - STACKADJ(-2); - /* del v[w] */ - err = PyObject_DelItem(v, w); - Py_DECREF(v); - Py_DECREF(w); - if (err == 0) continue; - break; - - case PRINT_EXPR: - v = POP(); - w = PySys_GetObject("displayhook"); - if (w == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "lost sys.displayhook"); - err = -1; - x = NULL; - } - if (err == 0) { - x = Py_BuildValue("(O)", v); - if (x == NULL) - err = -1; - } - if (err == 0) { - w = PyEval_CallObject(w, x); - Py_XDECREF(w); - if (w == NULL) - err = -1; - } - Py_DECREF(v); - Py_XDECREF(x); - break; - - case PRINT_ITEM_TO: - w = stream = POP(); - /* fall through to PRINT_ITEM */ - - case PRINT_ITEM: - v = POP(); - if (stream == NULL || stream == Py_None) { - w = PySys_GetObject("stdout"); - if (w == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "lost sys.stdout"); - err = -1; - } - } - /* PyFile_SoftSpace() can exececute arbitrary code - if sys.stdout is an instance with a __getattr__. - If __getattr__ raises an exception, w will - be freed, so we need to prevent that temporarily. */ - Py_XINCREF(w); - if (w != NULL && PyFile_SoftSpace(w, 0)) - err = PyFile_WriteString(" ", w); - if (err == 0) - err = PyFile_WriteObject(v, w, Py_PRINT_RAW); - if (err == 0) { - /* XXX move into writeobject() ? */ - if (PyString_Check(v)) { - char *s = PyString_AS_STRING(v); - int len = PyString_GET_SIZE(v); - if (len == 0 || - !isspace(Py_CHARMASK(s[len-1])) || - s[len-1] == ' ') - PyFile_SoftSpace(w, 1); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(v)) { - Py_UNICODE *s = PyUnicode_AS_UNICODE(v); - int len = PyUnicode_GET_SIZE(v); - if (len == 0 || - !Py_UNICODE_ISSPACE(s[len-1]) || - s[len-1] == ' ') - PyFile_SoftSpace(w, 1); - } -#endif - else - PyFile_SoftSpace(w, 1); - } - Py_XDECREF(w); - Py_DECREF(v); - Py_XDECREF(stream); - stream = NULL; - if (err == 0) - continue; - break; - - case PRINT_NEWLINE_TO: - w = stream = POP(); - /* fall through to PRINT_NEWLINE */ - - case PRINT_NEWLINE: - if (stream == NULL || stream == Py_None) { - w = PySys_GetObject("stdout"); - if (w == NULL) - PyErr_SetString(PyExc_RuntimeError, - "lost sys.stdout"); - } - if (w != NULL) { - err = PyFile_WriteString("\n", w); - if (err == 0) - PyFile_SoftSpace(w, 0); - } - Py_XDECREF(stream); - stream = NULL; - break; - - -#ifdef CASE_TOO_BIG - default: switch (opcode) { -#endif - case BREAK_LOOP: - why = WHY_BREAK; - break; - - case CONTINUE_LOOP: - retval = PyInt_FromLong(oparg); - why = WHY_CONTINUE; - break; - - case RAISE_VARARGS: - u = v = w = NULL; - switch (oparg) { - case 3: - u = POP(); /* traceback */ - /* Fallthrough */ - case 2: - v = POP(); /* value */ - /* Fallthrough */ - case 1: - w = POP(); /* exc */ - case 0: /* Fallthrough */ - why = do_raise(w, v, u); - break; - default: - PyErr_SetString(PyExc_SystemError, - "bad RAISE_VARARGS oparg"); - why = WHY_EXCEPTION; - break; - } - break; - - case LOAD_LOCALS: - if ((x = f->f_locals) == NULL) { - PyErr_SetString(PyExc_SystemError, - "no locals"); - break; - } - Py_INCREF(x); - PUSH(x); - break; - - case RETURN_VALUE: - retval = POP(); - why = WHY_RETURN; - break; - - case YIELD_VALUE: - retval = POP(); - f->f_stacktop = stack_pointer; - why = WHY_YIELD; - break; - - - case EXEC_STMT: - w = TOP(); - v = SECOND(); - u = THIRD(); - STACKADJ(-3); - err = exec_statement(f, u, v, w); - Py_DECREF(u); - Py_DECREF(v); - Py_DECREF(w); - break; - - case POP_BLOCK: - { - PyTryBlock *b = PyFrame_BlockPop(f); - while (STACK_LEVEL() > b->b_level) { - v = POP(); - Py_DECREF(v); - } - } - break; - - case END_FINALLY: - v = POP(); - if (PyInt_Check(v)) { - why = (enum why_code) PyInt_AS_LONG(v); - if (why == WHY_RETURN || - why == WHY_YIELD || - why == WHY_CONTINUE) - retval = POP(); - } - else if (PyString_Check(v) || PyClass_Check(v)) { - w = POP(); - u = POP(); - PyErr_Restore(v, w, u); - why = WHY_RERAISE; - break; - } - else if (v != Py_None) { - PyErr_SetString(PyExc_SystemError, - "'finally' pops bad exception"); - why = WHY_EXCEPTION; - } - Py_DECREF(v); - break; - - case BUILD_CLASS: - u = TOP(); - v = SECOND(); - w = THIRD(); - STACKADJ(-2); - x = build_class(u, v, w); - SET_TOP(x); - Py_DECREF(u); - Py_DECREF(v); - Py_DECREF(w); - break; - - case STORE_NAME: - w = GETITEM(names, oparg); - v = POP(); - if ((x = f->f_locals) == NULL) { - PyErr_Format(PyExc_SystemError, - "no locals found when storing %s", - PyObject_REPR(w)); - break; - } - err = PyDict_SetItem(x, w, v); - Py_DECREF(v); - break; - - case DELETE_NAME: - w = GETITEM(names, oparg); - if ((x = f->f_locals) == NULL) { - PyErr_Format(PyExc_SystemError, - "no locals when deleting %s", - PyObject_REPR(w)); - break; - } - if ((err = PyDict_DelItem(x, w)) != 0) - format_exc_check_arg(PyExc_NameError, - NAME_ERROR_MSG ,w); - break; - - PREDICTED_WITH_ARG(UNPACK_SEQUENCE); - case UNPACK_SEQUENCE: - v = POP(); - if (PyTuple_CheckExact(v)) { - if (PyTuple_Size(v) != oparg) { - PyErr_SetString(PyExc_ValueError, - "unpack tuple of wrong size"); - why = WHY_EXCEPTION; - } - else { - for (; --oparg >= 0; ) { - w = PyTuple_GET_ITEM(v, oparg); - Py_INCREF(w); - PUSH(w); - } - } - } - else if (PyList_CheckExact(v)) { - if (PyList_Size(v) != oparg) { - PyErr_SetString(PyExc_ValueError, - "unpack list of wrong size"); - why = WHY_EXCEPTION; - } - else { - for (; --oparg >= 0; ) { - w = PyList_GET_ITEM(v, oparg); - Py_INCREF(w); - PUSH(w); - } - } - } - else if (unpack_iterable(v, oparg, - stack_pointer + oparg)) - stack_pointer += oparg; - else { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_SetString(PyExc_TypeError, - "unpack non-sequence"); - why = WHY_EXCEPTION; - } - Py_DECREF(v); - break; - - case STORE_ATTR: - w = GETITEM(names, oparg); - v = TOP(); - u = SECOND(); - STACKADJ(-2); - err = PyObject_SetAttr(v, w, u); /* v.w = u */ - Py_DECREF(v); - Py_DECREF(u); - break; - - case DELETE_ATTR: - w = GETITEM(names, oparg); - v = POP(); - err = PyObject_SetAttr(v, w, (PyObject *)NULL); - /* del v.w */ - Py_DECREF(v); - break; - - case STORE_GLOBAL: - w = GETITEM(names, oparg); - v = POP(); - err = PyDict_SetItem(f->f_globals, w, v); - Py_DECREF(v); - break; - - case DELETE_GLOBAL: - w = GETITEM(names, oparg); - if ((err = PyDict_DelItem(f->f_globals, w)) != 0) - format_exc_check_arg( - PyExc_NameError, GLOBAL_NAME_ERROR_MSG, w); - break; - - case LOAD_NAME: - w = GETITEM(names, oparg); - if ((x = f->f_locals) == NULL) { - PyErr_Format(PyExc_SystemError, - "no locals when loading %s", - PyObject_REPR(w)); - break; - } - x = PyDict_GetItem(x, w); - if (x == NULL) { - x = PyDict_GetItem(f->f_globals, w); - if (x == NULL) { - x = PyDict_GetItem(f->f_builtins, w); - if (x == NULL) { - format_exc_check_arg( - PyExc_NameError, - NAME_ERROR_MSG ,w); - break; - } - } - } - Py_INCREF(x); - PUSH(x); - break; - - case LOAD_GLOBAL: - w = GETITEM(names, oparg); - if (PyString_CheckExact(w)) { - /* Inline the PyDict_GetItem() calls. - WARNING: this is an extreme speed hack. - Do not try this at home. */ - long hash = ((PyStringObject *)w)->ob_shash; - if (hash != -1) { - PyDictObject *d; - d = (PyDictObject *)(f->f_globals); - x = d->ma_lookup(d, w, hash)->me_value; - if (x != NULL) { - Py_INCREF(x); - PUSH(x); - continue; - } - d = (PyDictObject *)(f->f_builtins); - x = d->ma_lookup(d, w, hash)->me_value; - if (x != NULL) { - Py_INCREF(x); - PUSH(x); - continue; - } - goto load_global_error; - } - } - /* This is the un-inlined version of the code above */ - x = PyDict_GetItem(f->f_globals, w); - if (x == NULL) { - x = PyDict_GetItem(f->f_builtins, w); - if (x == NULL) { - load_global_error: - format_exc_check_arg( - PyExc_NameError, - GLOBAL_NAME_ERROR_MSG, w); - break; - } - } - Py_INCREF(x); - PUSH(x); - break; - - case DELETE_FAST: - x = GETLOCAL(oparg); - if (x == NULL) { - format_exc_check_arg( - PyExc_UnboundLocalError, - UNBOUNDLOCAL_ERROR_MSG, - PyTuple_GetItem(co->co_varnames, oparg) - ); - break; - } - SETLOCAL(oparg, NULL); - continue; - - case LOAD_CLOSURE: - x = freevars[oparg]; - Py_INCREF(x); - PUSH(x); - break; - - case LOAD_DEREF: - x = freevars[oparg]; - w = PyCell_Get(x); - if (w == NULL) { - err = -1; - /* Don't stomp existing exception */ - if (PyErr_Occurred()) - break; - if (oparg < f->f_ncells) { - v = PyTuple_GetItem(co->co_cellvars, - oparg); - format_exc_check_arg( - PyExc_UnboundLocalError, - UNBOUNDLOCAL_ERROR_MSG, - v); - } else { - v = PyTuple_GetItem( - co->co_freevars, - oparg - f->f_ncells); - format_exc_check_arg( - PyExc_NameError, - UNBOUNDFREE_ERROR_MSG, - v); - } - break; - } - PUSH(w); - break; - - case STORE_DEREF: - w = POP(); - x = freevars[oparg]; - PyCell_Set(x, w); - Py_DECREF(w); - continue; - - case BUILD_TUPLE: - x = PyTuple_New(oparg); - if (x != NULL) { - for (; --oparg >= 0;) { - w = POP(); - PyTuple_SET_ITEM(x, oparg, w); - } - PUSH(x); - continue; - } - break; - - case BUILD_LIST: - x = PyList_New(oparg); - if (x != NULL) { - for (; --oparg >= 0;) { - w = POP(); - PyList_SET_ITEM(x, oparg, w); - } - PUSH(x); - continue; - } - break; - - case BUILD_MAP: - x = PyDict_New(); - PUSH(x); - if (x != NULL) continue; - break; - - case LOAD_ATTR: - w = GETITEM(names, oparg); - v = TOP(); - x = PyObject_GetAttr(v, w); - Py_DECREF(v); - SET_TOP(x); - if (x != NULL) continue; - break; - - case COMPARE_OP: - w = POP(); - v = TOP(); - if (PyInt_CheckExact(w) && PyInt_CheckExact(v)) { - /* INLINE: cmp(int, int) */ - register long a, b; - register int res; - a = PyInt_AS_LONG(v); - b = PyInt_AS_LONG(w); - switch (oparg) { - case PyCmp_LT: res = a < b; break; - case PyCmp_LE: res = a <= b; break; - case PyCmp_EQ: res = a == b; break; - case PyCmp_NE: res = a != b; break; - case PyCmp_GT: res = a > b; break; - case PyCmp_GE: res = a >= b; break; - case PyCmp_IS: res = v == w; break; - case PyCmp_IS_NOT: res = v != w; break; - default: goto slow_compare; - } - x = res ? Py_True : Py_False; - Py_INCREF(x); - } - else { - slow_compare: - x = cmp_outcome(oparg, v, w); - } - Py_DECREF(v); - Py_DECREF(w); - SET_TOP(x); - if (x == NULL) break; - PREDICT(JUMP_IF_FALSE); - PREDICT(JUMP_IF_TRUE); - continue; - - case IMPORT_NAME: - w = GETITEM(names, oparg); - x = PyDict_GetItemString(f->f_builtins, "__import__"); - if (x == NULL) { - PyErr_SetString(PyExc_ImportError, - "__import__ not found"); - break; - } - u = TOP(); - w = Py_BuildValue("(OOOO)", - w, - f->f_globals, - f->f_locals == NULL ? - Py_None : f->f_locals, - u); - Py_DECREF(u); - if (w == NULL) { - u = POP(); - x = NULL; - break; - } - x = PyEval_CallObject(x, w); - Py_DECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case IMPORT_STAR: - v = POP(); - PyFrame_FastToLocals(f); - if ((x = f->f_locals) == NULL) { - PyErr_SetString(PyExc_SystemError, - "no locals found during 'import *'"); - break; - } - err = import_all_from(x, v); - PyFrame_LocalsToFast(f, 0); - Py_DECREF(v); - if (err == 0) continue; - break; - - case IMPORT_FROM: - w = GETITEM(names, oparg); - v = TOP(); - x = import_from(v, w); - PUSH(x); - if (x != NULL) continue; - break; - - case JUMP_FORWARD: - JUMPBY(oparg); - goto fast_next_opcode; - - PREDICTED_WITH_ARG(JUMP_IF_FALSE); - case JUMP_IF_FALSE: - w = TOP(); - if (w == Py_True) { - PREDICT(POP_TOP); - goto fast_next_opcode; - } - if (w == Py_False) { - JUMPBY(oparg); - goto fast_next_opcode; - } - err = PyObject_IsTrue(w); - if (err > 0) - err = 0; - else if (err == 0) - JUMPBY(oparg); - else - break; - continue; - - PREDICTED_WITH_ARG(JUMP_IF_TRUE); - case JUMP_IF_TRUE: - w = TOP(); - if (w == Py_False) { - PREDICT(POP_TOP); - goto fast_next_opcode; - } - if (w == Py_True) { - JUMPBY(oparg); - goto fast_next_opcode; - } - err = PyObject_IsTrue(w); - if (err > 0) { - err = 0; - JUMPBY(oparg); - } - else if (err == 0) - ; - else - break; - continue; - - case JUMP_ABSOLUTE: - JUMPTO(oparg); - continue; - - case GET_ITER: - /* before: [obj]; after [getiter(obj)] */ - v = TOP(); - x = PyObject_GetIter(v); - Py_DECREF(v); - if (x != NULL) { - SET_TOP(x); - PREDICT(FOR_ITER); - continue; - } - STACKADJ(-1); - break; - - PREDICTED_WITH_ARG(FOR_ITER); - case FOR_ITER: - /* before: [iter]; after: [iter, iter()] *or* [] */ - v = TOP(); - x = PyIter_Next(v); - if (x != NULL) { - PUSH(x); - PREDICT(STORE_FAST); - PREDICT(UNPACK_SEQUENCE); - continue; - } - if (!PyErr_Occurred()) { - /* iterator ended normally */ - x = v = POP(); - Py_DECREF(v); - JUMPBY(oparg); - continue; - } - break; - - case SETUP_LOOP: - case SETUP_EXCEPT: - case SETUP_FINALLY: - PyFrame_BlockSetup(f, opcode, INSTR_OFFSET() + oparg, - STACK_LEVEL()); - continue; - - case CALL_FUNCTION: - PCALL(PCALL_ALL); - x = call_function(&stack_pointer, oparg); - PUSH(x); - if (x != NULL) - continue; - break; - - case CALL_FUNCTION_VAR: - case CALL_FUNCTION_KW: - case CALL_FUNCTION_VAR_KW: - { - int na = oparg & 0xff; - int nk = (oparg>>8) & 0xff; - int flags = (opcode - CALL_FUNCTION) & 3; - int n = na + 2 * nk; - PyObject **pfunc, *func; - PCALL(PCALL_ALL); - if (flags & CALL_FLAG_VAR) - n++; - if (flags & CALL_FLAG_KW) - n++; - pfunc = stack_pointer - n - 1; - func = *pfunc; - - if (PyMethod_Check(func) - && PyMethod_GET_SELF(func) != NULL) { - PyObject *self = PyMethod_GET_SELF(func); - Py_INCREF(self); - func = PyMethod_GET_FUNCTION(func); - Py_INCREF(func); - Py_DECREF(*pfunc); - *pfunc = self; - na++; - n++; - } else - Py_INCREF(func); - x = ext_do_call(func, &stack_pointer, flags, na, nk); - Py_DECREF(func); - - while (stack_pointer > pfunc) { - w = POP(); - Py_DECREF(w); - } - PUSH(x); - if (x != NULL) - continue; - break; - } - - case MAKE_FUNCTION: - v = POP(); /* code object */ - x = PyFunction_New(v, f->f_globals); - Py_DECREF(v); - /* XXX Maybe this should be a separate opcode? */ - if (x != NULL && oparg > 0) { - v = PyTuple_New(oparg); - if (v == NULL) { - Py_DECREF(x); - x = NULL; - break; - } - while (--oparg >= 0) { - w = POP(); - PyTuple_SET_ITEM(v, oparg, w); - } - err = PyFunction_SetDefaults(x, v); - Py_DECREF(v); - } - PUSH(x); - break; - - case MAKE_CLOSURE: - { - int nfree; - v = POP(); /* code object */ - x = PyFunction_New(v, f->f_globals); - nfree = PyCode_GetNumFree((PyCodeObject *)v); - Py_DECREF(v); - /* XXX Maybe this should be a separate opcode? */ - if (x != NULL && nfree > 0) { - v = PyTuple_New(nfree); - if (v == NULL) { - Py_DECREF(x); - x = NULL; - break; - } - while (--nfree >= 0) { - w = POP(); - PyTuple_SET_ITEM(v, nfree, w); - } - err = PyFunction_SetClosure(x, v); - Py_DECREF(v); - } - if (x != NULL && oparg > 0) { - v = PyTuple_New(oparg); - if (v == NULL) { - Py_DECREF(x); - x = NULL; - break; - } - while (--oparg >= 0) { - w = POP(); - PyTuple_SET_ITEM(v, oparg, w); - } - err = PyFunction_SetDefaults(x, v); - Py_DECREF(v); - } - PUSH(x); - break; - } - - case BUILD_SLICE: - if (oparg == 3) - w = POP(); - else - w = NULL; - v = POP(); - u = TOP(); - x = PySlice_New(u, v, w); - Py_DECREF(u); - Py_DECREF(v); - Py_XDECREF(w); - SET_TOP(x); - if (x != NULL) continue; - break; - - case EXTENDED_ARG: - opcode = NEXTOP(); - oparg = oparg<<16 | NEXTARG(); - goto dispatch_opcode; - - default: - fprintf(stderr, - "XXX lineno: %d, opcode: %d\n", - PyCode_Addr2Line(f->f_code, f->f_lasti), - opcode); - PyErr_SetString(PyExc_SystemError, "unknown opcode"); - why = WHY_EXCEPTION; - break; - -#ifdef CASE_TOO_BIG - } -#endif - - } /* switch */ - - on_error: - - /* Quickly continue if no error occurred */ - - if (why == WHY_NOT) { - if (err == 0 && x != NULL) { -#ifdef CHECKEXC - /* This check is expensive! */ - if (PyErr_Occurred()) - fprintf(stderr, - "XXX undetected error\n"); - else -#endif - continue; /* Normal, fast path */ - } - why = WHY_EXCEPTION; - x = Py_None; - err = 0; - } - - /* Double-check exception status */ - - if (why == WHY_EXCEPTION || why == WHY_RERAISE) { - if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_SystemError, - "error return without exception set"); - why = WHY_EXCEPTION; - } - } -#ifdef CHECKEXC - else { - /* This check is expensive! */ - if (PyErr_Occurred()) { - fprintf(stderr, - "XXX undetected error (why=%d)\n", - why); - why = WHY_EXCEPTION; - } - } -#endif - - /* Log traceback info if this is a real exception */ - - if (why == WHY_EXCEPTION) { - PyTraceBack_Here(f); - - if (tstate->c_tracefunc != NULL) - call_exc_trace(tstate->c_tracefunc, - tstate->c_traceobj, f); - } - - /* For the rest, treat WHY_RERAISE as WHY_EXCEPTION */ - - if (why == WHY_RERAISE) - why = WHY_EXCEPTION; - - /* Unwind stacks if a (pseudo) exception occurred */ - - while (why != WHY_NOT && why != WHY_YIELD && f->f_iblock > 0) { - PyTryBlock *b = PyFrame_BlockPop(f); - - if (b->b_type == SETUP_LOOP && why == WHY_CONTINUE) { - /* For a continue inside a try block, - don't pop the block for the loop. */ - PyFrame_BlockSetup(f, b->b_type, b->b_handler, - b->b_level); - why = WHY_NOT; - JUMPTO(PyInt_AS_LONG(retval)); - Py_DECREF(retval); - break; - } - - while (STACK_LEVEL() > b->b_level) { - v = POP(); - Py_XDECREF(v); - } - if (b->b_type == SETUP_LOOP && why == WHY_BREAK) { - why = WHY_NOT; - JUMPTO(b->b_handler); - break; - } - if (b->b_type == SETUP_FINALLY || - (b->b_type == SETUP_EXCEPT && - why == WHY_EXCEPTION)) { - if (why == WHY_EXCEPTION) { - PyObject *exc, *val, *tb; - PyErr_Fetch(&exc, &val, &tb); - if (val == NULL) { - val = Py_None; - Py_INCREF(val); - } - /* Make the raw exception data - available to the handler, - so a program can emulate the - Python main loop. Don't do - this for 'finally'. */ - if (b->b_type == SETUP_EXCEPT) { - PyErr_NormalizeException( - &exc, &val, &tb); - set_exc_info(tstate, - exc, val, tb); - } - if (tb == NULL) { - Py_INCREF(Py_None); - PUSH(Py_None); - } else - PUSH(tb); - PUSH(val); - PUSH(exc); - } - else { - if (why == WHY_RETURN || - why == WHY_CONTINUE) - PUSH(retval); - v = PyInt_FromLong((long)why); - PUSH(v); - } - why = WHY_NOT; - JUMPTO(b->b_handler); - break; - } - } /* unwind stack */ - - /* End the loop if we still have an error (or return) */ - - if (why != WHY_NOT) - break; - - } /* main loop */ - - if (why != WHY_YIELD) { - /* Pop remaining stack entries -- but when yielding */ - while (!EMPTY()) { - v = POP(); - Py_XDECREF(v); - } - } - - if (why != WHY_RETURN && why != WHY_YIELD) - retval = NULL; - - if (tstate->use_tracing) { - if (tstate->c_tracefunc - && (why == WHY_RETURN || why == WHY_YIELD)) { - if (call_trace(tstate->c_tracefunc, - tstate->c_traceobj, f, - PyTrace_RETURN, retval)) { - Py_XDECREF(retval); - retval = NULL; - why = WHY_EXCEPTION; - } - } - if (tstate->c_profilefunc) { - if (why == WHY_EXCEPTION) - call_trace_protected(tstate->c_profilefunc, - tstate->c_profileobj, f, - PyTrace_RETURN); - else if (call_trace(tstate->c_profilefunc, - tstate->c_profileobj, f, - PyTrace_RETURN, retval)) { - Py_XDECREF(retval); - retval = NULL; - why = WHY_EXCEPTION; - } - } - } - - reset_exc_info(tstate); - - /* pop frame */ - --tstate->recursion_depth; - tstate->frame = f->f_back; - - return retval; -} - -PyObject * -PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, - PyObject **args, int argcount, PyObject **kws, int kwcount, - PyObject **defs, int defcount, PyObject *closure) -{ - register PyFrameObject *f; - register PyObject *retval = NULL; - register PyObject **fastlocals, **freevars; - PyThreadState *tstate = PyThreadState_GET(); - PyObject *x, *u; - - if (globals == NULL) { - PyErr_SetString(PyExc_SystemError, - "PyEval_EvalCodeEx: NULL globals"); - return NULL; - } - - assert(globals != NULL); - f = PyFrame_New(tstate, co, globals, locals); - if (f == NULL) - return NULL; - - fastlocals = f->f_localsplus; - freevars = f->f_localsplus + f->f_nlocals; - - if (co->co_argcount > 0 || - co->co_flags & (CO_VARARGS | CO_VARKEYWORDS)) { - int i; - int n = argcount; - PyObject *kwdict = NULL; - if (co->co_flags & CO_VARKEYWORDS) { - kwdict = PyDict_New(); - if (kwdict == NULL) - goto fail; - i = co->co_argcount; - if (co->co_flags & CO_VARARGS) - i++; - SETLOCAL(i, kwdict); - } - if (argcount > co->co_argcount) { - if (!(co->co_flags & CO_VARARGS)) { - PyErr_Format(PyExc_TypeError, - "%.200s() takes %s %d " - "%sargument%s (%d given)", - PyString_AsString(co->co_name), - defcount ? "at most" : "exactly", - co->co_argcount, - kwcount ? "non-keyword " : "", - co->co_argcount == 1 ? "" : "s", - argcount); - goto fail; - } - n = co->co_argcount; - } - for (i = 0; i < n; i++) { - x = args[i]; - Py_INCREF(x); - SETLOCAL(i, x); - } - if (co->co_flags & CO_VARARGS) { - u = PyTuple_New(argcount - n); - if (u == NULL) - goto fail; - SETLOCAL(co->co_argcount, u); - for (i = n; i < argcount; i++) { - x = args[i]; - Py_INCREF(x); - PyTuple_SET_ITEM(u, i-n, x); - } - } - for (i = 0; i < kwcount; i++) { - PyObject *keyword = kws[2*i]; - PyObject *value = kws[2*i + 1]; - int j; - if (keyword == NULL || !PyString_Check(keyword)) { - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", - PyString_AsString(co->co_name)); - goto fail; - } - /* XXX slow -- speed up using dictionary? */ - for (j = 0; j < co->co_argcount; j++) { - PyObject *nm = PyTuple_GET_ITEM( - co->co_varnames, j); - int cmp = PyObject_RichCompareBool( - keyword, nm, Py_EQ); - if (cmp > 0) - break; - else if (cmp < 0) - goto fail; - } - /* Check errors from Compare */ - if (PyErr_Occurred()) - goto fail; - if (j >= co->co_argcount) { - if (kwdict == NULL) { - PyErr_Format(PyExc_TypeError, - "%.200s() got an unexpected " - "keyword argument '%.400s'", - PyString_AsString(co->co_name), - PyString_AsString(keyword)); - goto fail; - } - PyDict_SetItem(kwdict, keyword, value); - } - else { - if (GETLOCAL(j) != NULL) { - PyErr_Format(PyExc_TypeError, - "%.200s() got multiple " - "values for keyword " - "argument '%.400s'", - PyString_AsString(co->co_name), - PyString_AsString(keyword)); - goto fail; - } - Py_INCREF(value); - SETLOCAL(j, value); - } - } - if (argcount < co->co_argcount) { - int m = co->co_argcount - defcount; - for (i = argcount; i < m; i++) { - if (GETLOCAL(i) == NULL) { - PyErr_Format(PyExc_TypeError, - "%.200s() takes %s %d " - "%sargument%s (%d given)", - PyString_AsString(co->co_name), - ((co->co_flags & CO_VARARGS) || - defcount) ? "at least" - : "exactly", - m, kwcount ? "non-keyword " : "", - m == 1 ? "" : "s", i); - goto fail; - } - } - if (n > m) - i = n - m; - else - i = 0; - for (; i < defcount; i++) { - if (GETLOCAL(m+i) == NULL) { - PyObject *def = defs[i]; - Py_INCREF(def); - SETLOCAL(m+i, def); - } - } - } - } - else { - if (argcount > 0 || kwcount > 0) { - PyErr_Format(PyExc_TypeError, - "%.200s() takes no arguments (%d given)", - PyString_AsString(co->co_name), - argcount + kwcount); - goto fail; - } - } - /* Allocate and initialize storage for cell vars, and copy free - vars into frame. This isn't too efficient right now. */ - if (f->f_ncells) { - int i = 0, j = 0, nargs, found; - char *cellname, *argname; - PyObject *c; - - nargs = co->co_argcount; - if (co->co_flags & CO_VARARGS) - nargs++; - if (co->co_flags & CO_VARKEYWORDS) - nargs++; - - /* Check for cells that shadow args */ - for (i = 0; i < f->f_ncells && j < nargs; ++i) { - cellname = PyString_AS_STRING( - PyTuple_GET_ITEM(co->co_cellvars, i)); - found = 0; - while (j < nargs) { - argname = PyString_AS_STRING( - PyTuple_GET_ITEM(co->co_varnames, j)); - if (strcmp(cellname, argname) == 0) { - c = PyCell_New(GETLOCAL(j)); - if (c == NULL) - goto fail; - GETLOCAL(f->f_nlocals + i) = c; - found = 1; - break; - } - j++; - } - if (found == 0) { - c = PyCell_New(NULL); - if (c == NULL) - goto fail; - SETLOCAL(f->f_nlocals + i, c); - } - } - /* Initialize any that are left */ - while (i < f->f_ncells) { - c = PyCell_New(NULL); - if (c == NULL) - goto fail; - SETLOCAL(f->f_nlocals + i, c); - i++; - } - } - if (f->f_nfreevars) { - int i; - for (i = 0; i < f->f_nfreevars; ++i) { - PyObject *o = PyTuple_GET_ITEM(closure, i); - Py_INCREF(o); - freevars[f->f_ncells + i] = o; - } - } - - if (co->co_flags & CO_GENERATOR) { - /* Don't need to keep the reference to f_back, it will be set - * when the generator is resumed. */ - Py_XDECREF(f->f_back); - f->f_back = NULL; - - PCALL(PCALL_GENERATOR); - - /* Create a new generator that owns the ready to run frame - * and return that as the value. */ - return gen_new(f); - } - - retval = eval_frame(f); - - fail: /* Jump here from prelude on failure */ - - /* decref'ing the frame can cause __del__ methods to get invoked, - which can call back into Python. While we're done with the - current Python frame (f), the associated C stack is still in use, - so recursion_depth must be boosted for the duration. - */ - assert(tstate != NULL); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; - return retval; -} - - -/* Implementation notes for set_exc_info() and reset_exc_info(): - -- Below, 'exc_ZZZ' stands for 'exc_type', 'exc_value' and - 'exc_traceback'. These always travel together. - -- tstate->curexc_ZZZ is the "hot" exception that is set by - PyErr_SetString(), cleared by PyErr_Clear(), and so on. - -- Once an exception is caught by an except clause, it is transferred - from tstate->curexc_ZZZ to tstate->exc_ZZZ, from which sys.exc_info() - can pick it up. This is the primary task of set_exc_info(). - -- Now let me explain the complicated dance with frame->f_exc_ZZZ. - - Long ago, when none of this existed, there were just a few globals: - one set corresponding to the "hot" exception, and one set - corresponding to sys.exc_ZZZ. (Actually, the latter weren't C - globals; they were simply stored as sys.exc_ZZZ. For backwards - compatibility, they still are!) The problem was that in code like - this: - - try: - "something that may fail" - except "some exception": - "do something else first" - "print the exception from sys.exc_ZZZ." - - if "do something else first" invoked something that raised and caught - an exception, sys.exc_ZZZ were overwritten. That was a frequent - cause of subtle bugs. I fixed this by changing the semantics as - follows: - - - Within one frame, sys.exc_ZZZ will hold the last exception caught - *in that frame*. - - - But initially, and as long as no exception is caught in a given - frame, sys.exc_ZZZ will hold the last exception caught in the - previous frame (or the frame before that, etc.). - - The first bullet fixed the bug in the above example. The second - bullet was for backwards compatibility: it was (and is) common to - have a function that is called when an exception is caught, and to - have that function access the caught exception via sys.exc_ZZZ. - (Example: traceback.print_exc()). - - At the same time I fixed the problem that sys.exc_ZZZ weren't - thread-safe, by introducing sys.exc_info() which gets it from tstate; - but that's really a separate improvement. - - The reset_exc_info() function in ceval.c restores the tstate->exc_ZZZ - variables to what they were before the current frame was called. The - set_exc_info() function saves them on the frame so that - reset_exc_info() can restore them. The invariant is that - frame->f_exc_ZZZ is NULL iff the current frame never caught an - exception (where "catching" an exception applies only to successful - except clauses); and if the current frame ever caught an exception, - frame->f_exc_ZZZ is the exception that was stored in tstate->exc_ZZZ - at the start of the current frame. - -*/ - -static void -set_exc_info(PyThreadState *tstate, - PyObject *type, PyObject *value, PyObject *tb) -{ - PyFrameObject *frame; - PyObject *tmp_type, *tmp_value, *tmp_tb; - - frame = tstate->frame; - if (frame->f_exc_type == NULL) { - /* This frame didn't catch an exception before */ - /* Save previous exception of this thread in this frame */ - if (tstate->exc_type == NULL) { - Py_INCREF(Py_None); - tstate->exc_type = Py_None; - } - tmp_type = frame->f_exc_type; - tmp_value = frame->f_exc_value; - tmp_tb = frame->f_exc_traceback; - Py_XINCREF(tstate->exc_type); - Py_XINCREF(tstate->exc_value); - Py_XINCREF(tstate->exc_traceback); - frame->f_exc_type = tstate->exc_type; - frame->f_exc_value = tstate->exc_value; - frame->f_exc_traceback = tstate->exc_traceback; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); - } - /* Set new exception for this thread */ - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - Py_XINCREF(type); - Py_XINCREF(value); - Py_XINCREF(tb); - tstate->exc_type = type; - tstate->exc_value = value; - tstate->exc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); - /* For b/w compatibility */ - PySys_SetObject("exc_type", type); - PySys_SetObject("exc_value", value); - PySys_SetObject("exc_traceback", tb); -} - -static void -reset_exc_info(PyThreadState *tstate) -{ - PyFrameObject *frame; - PyObject *tmp_type, *tmp_value, *tmp_tb; - frame = tstate->frame; - if (frame->f_exc_type != NULL) { - /* This frame caught an exception */ - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - Py_XINCREF(frame->f_exc_type); - Py_XINCREF(frame->f_exc_value); - Py_XINCREF(frame->f_exc_traceback); - tstate->exc_type = frame->f_exc_type; - tstate->exc_value = frame->f_exc_value; - tstate->exc_traceback = frame->f_exc_traceback; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); - /* For b/w compatibility */ - PySys_SetObject("exc_type", frame->f_exc_type); - PySys_SetObject("exc_value", frame->f_exc_value); - PySys_SetObject("exc_traceback", frame->f_exc_traceback); - } - tmp_type = frame->f_exc_type; - tmp_value = frame->f_exc_value; - tmp_tb = frame->f_exc_traceback; - frame->f_exc_type = NULL; - frame->f_exc_value = NULL; - frame->f_exc_traceback = NULL; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} - -/* Logic for the raise statement (too complicated for inlining). - This *consumes* a reference count to each of its arguments. */ -static enum why_code -do_raise(PyObject *type, PyObject *value, PyObject *tb) -{ - if (type == NULL) { - /* Reraise */ - PyThreadState *tstate = PyThreadState_Get(); - type = tstate->exc_type == NULL ? Py_None : tstate->exc_type; - value = tstate->exc_value; - tb = tstate->exc_traceback; - Py_XINCREF(type); - Py_XINCREF(value); - Py_XINCREF(tb); - } - - /* We support the following forms of raise: - raise , - raise , - raise , None - raise , - raise , None - raise , - raise , None - - An omitted second argument is the same as None. - - In addition, raise , is the same as - raising the tuple's first item (and it better have one!); - this rule is applied recursively. - - Finally, an optional third argument can be supplied, which - gives the traceback to be substituted (useful when - re-raising an exception after examining it). */ - - /* First, check the traceback argument, replacing None with - NULL. */ - if (tb == Py_None) { - Py_DECREF(tb); - tb = NULL; - } - else if (tb != NULL && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - - /* Next, replace a missing value with None */ - if (value == NULL) { - value = Py_None; - Py_INCREF(value); - } - - /* Next, repeatedly, replace a tuple exception with its first item */ - while (PyTuple_Check(type) && PyTuple_Size(type) > 0) { - PyObject *tmp = type; - type = PyTuple_GET_ITEM(type, 0); - Py_INCREF(type); - Py_DECREF(tmp); - } - - if (PyString_CheckExact(type)) - /* Raising builtin string is deprecated but still allowed -- - * do nothing. Raising an instance of a new-style str - * subclass is right out. */ - PyErr_Warn(PyExc_PendingDeprecationWarning, - "raising a string exception is deprecated"); - - else if (PyClass_Check(type)) - PyErr_NormalizeException(&type, &value, &tb); - - else if (PyInstance_Check(type)) { - /* Raising an instance. The value should be a dummy. */ - if (value != Py_None) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; - } - else { - /* Normalize to raise , */ - Py_DECREF(value); - value = type; - type = (PyObject*) ((PyInstanceObject*)type)->in_class; - Py_INCREF(type); - } - } - else { - /* Not something you can raise. You get an exception - anyway, just not what you specified :-) */ - PyErr_Format(PyExc_TypeError, - "exceptions must be classes, instances, or " - "strings (deprecated), not %s", - type->ob_type->tp_name); - goto raise_error; - } - PyErr_Restore(type, value, tb); - if (tb == NULL) - return WHY_EXCEPTION; - else - return WHY_RERAISE; - raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return WHY_EXCEPTION; -} - -/* Iterate v argcnt times and store the results on the stack (via decreasing - sp). Return 1 for success, 0 if error. */ - -static int -unpack_iterable(PyObject *v, int argcnt, PyObject **sp) -{ - int i = 0; - PyObject *it; /* iter(v) */ - PyObject *w; - - assert(v != NULL); - - it = PyObject_GetIter(v); - if (it == NULL) - goto Error; - - for (; i < argcnt; i++) { - w = PyIter_Next(it); - if (w == NULL) { - /* Iterator done, via error or exhaustion. */ - if (!PyErr_Occurred()) { - PyErr_Format(PyExc_ValueError, - "need more than %d value%s to unpack", - i, i == 1 ? "" : "s"); - } - goto Error; - } - *--sp = w; - } - - /* We better have exhausted the iterator now. */ - w = PyIter_Next(it); - if (w == NULL) { - if (PyErr_Occurred()) - goto Error; - Py_DECREF(it); - return 1; - } - Py_DECREF(w); - PyErr_SetString(PyExc_ValueError, "too many values to unpack"); - /* fall through */ -Error: - for (; i > 0; i--, sp++) - Py_DECREF(*sp); - Py_XDECREF(it); - return 0; -} - - -#ifdef LLTRACE -static int -prtrace(PyObject *v, char *str) -{ - printf("%s ", str); - if (PyObject_Print(v, stdout, 0) != 0) - PyErr_Clear(); /* Don't know what else to do */ - printf("\n"); - return 1; -} -#endif - -static void -call_exc_trace(Py_tracefunc func, PyObject *self, PyFrameObject *f) -{ - PyObject *type, *value, *traceback, *arg; - int err; - PyErr_Fetch(&type, &value, &traceback); - if (value == NULL) { - value = Py_None; - Py_INCREF(value); - } - arg = Py_BuildValue("(OOO)", type, value, traceback); - if (arg == NULL) { - PyErr_Restore(type, value, traceback); - return; - } - err = call_trace(func, self, f, PyTrace_EXCEPTION, arg); - Py_DECREF(arg); - if (err == 0) - PyErr_Restore(type, value, traceback); - else { - Py_XDECREF(type); - Py_XDECREF(value); - Py_XDECREF(traceback); - } -} - -static void -call_trace_protected(Py_tracefunc func, PyObject *obj, PyFrameObject *frame, - int what) -{ - PyObject *type, *value, *traceback; - int err; - PyErr_Fetch(&type, &value, &traceback); - err = call_trace(func, obj, frame, what, NULL); - if (err == 0) - PyErr_Restore(type, value, traceback); - else { - Py_XDECREF(type); - Py_XDECREF(value); - Py_XDECREF(traceback); - } -} - -static int -call_trace(Py_tracefunc func, PyObject *obj, PyFrameObject *frame, - int what, PyObject *arg) -{ - register PyThreadState *tstate = frame->f_tstate; - int result; - if (tstate->tracing) - return 0; - tstate->tracing++; - tstate->use_tracing = 0; - result = func(obj, frame, what, arg); - tstate->use_tracing = ((tstate->c_tracefunc != NULL) - || (tstate->c_profilefunc != NULL)); - tstate->tracing--; - return result; -} - -PyObject * -_PyEval_CallTracing(PyObject *func, PyObject *args) -{ - PyFrameObject *frame = PyEval_GetFrame(); - PyThreadState *tstate = frame->f_tstate; - int save_tracing = tstate->tracing; - int save_use_tracing = tstate->use_tracing; - PyObject *result; - - tstate->tracing = 0; - tstate->use_tracing = ((tstate->c_tracefunc != NULL) - || (tstate->c_profilefunc != NULL)); - result = PyObject_Call(func, args, NULL); - tstate->tracing = save_tracing; - tstate->use_tracing = save_use_tracing; - return result; -} - -static int -maybe_call_line_trace(Py_tracefunc func, PyObject *obj, - PyFrameObject *frame, int *instr_lb, int *instr_ub) -{ - /* The theory of SET_LINENO-less tracing. - - In a nutshell, we use the co_lnotab field of the code object - to tell when execution has moved onto a different line. - - As mentioned above, the basic idea is so set things up so - that - - *instr_lb <= frame->f_lasti < *instr_ub - - is true so long as execution does not change lines. - - This is all fairly simple. Digging the information out of - co_lnotab takes some work, but is conceptually clear. - - Somewhat harder to explain is why we don't *always* call the - line trace function when the above test fails. - - Consider this code: - - 1: def f(a): - 2: if a: - 3: print 1 - 4: else: - 5: print 2 - - which compiles to this: - - 2 0 LOAD_FAST 0 (a) - 3 JUMP_IF_FALSE 9 (to 15) - 6 POP_TOP - - 3 7 LOAD_CONST 1 (1) - 10 PRINT_ITEM - 11 PRINT_NEWLINE - 12 JUMP_FORWARD 6 (to 21) - >> 15 POP_TOP - - 5 16 LOAD_CONST 2 (2) - 19 PRINT_ITEM - 20 PRINT_NEWLINE - >> 21 LOAD_CONST 0 (None) - 24 RETURN_VALUE - - If 'a' is false, execution will jump to instruction at offset - 15 and the co_lnotab will claim that execution has moved to - line 3. This is at best misleading. In this case we could - associate the POP_TOP with line 4, but that doesn't make - sense in all cases (I think). - - What we do is only call the line trace function if the co_lnotab - indicates we have jumped to the *start* of a line, i.e. if the - current instruction offset matches the offset given for the - start of a line by the co_lnotab. - - This also takes care of the situation where 'a' is true. - Execution will jump from instruction offset 12 to offset 21. - Then the co_lnotab would imply that execution has moved to line - 5, which is again misleading. - - Why do we set f_lineno when tracing? Well, consider the code - above when 'a' is true. If stepping through this with 'n' in - pdb, you would stop at line 1 with a "call" type event, then - line events on lines 2 and 3, then a "return" type event -- but - you would be shown line 5 during this event. This is a change - from the behaviour in 2.2 and before, and I've found it - confusing in practice. By setting and using f_lineno when - tracing, one can report a line number different from that - suggested by f_lasti on this one occasion where it's desirable. - */ - - int result = 0; - - if ((frame->f_lasti < *instr_lb || frame->f_lasti >= *instr_ub)) { - PyCodeObject* co = frame->f_code; - int size, addr, line; - unsigned char* p; - - size = PyString_GET_SIZE(co->co_lnotab) / 2; - p = (unsigned char*)PyString_AS_STRING(co->co_lnotab); - - addr = 0; - line = co->co_firstlineno; - - /* possible optimization: if f->f_lasti == instr_ub - (likely to be a common case) then we already know - instr_lb -- if we stored the matching value of p - somwhere we could skip the first while loop. */ - - /* see comments in compile.c for the description of - co_lnotab. A point to remember: increments to p - should come in pairs -- although we don't care about - the line increments here, treating them as byte - increments gets confusing, to say the least. */ - - while (size > 0) { - if (addr + *p > frame->f_lasti) - break; - addr += *p++; - if (*p) *instr_lb = addr; - line += *p++; - --size; - } - - if (addr == frame->f_lasti) { - frame->f_lineno = line; - result = call_trace(func, obj, frame, - PyTrace_LINE, Py_None); - } - - if (size > 0) { - while (--size >= 0) { - addr += *p++; - if (*p++) - break; - } - *instr_ub = addr; - } - else { - *instr_ub = INT_MAX; - } - } - - return result; -} - -void -PyEval_SetProfile(Py_tracefunc func, PyObject *arg) -{ - PyThreadState *tstate = PyThreadState_Get(); - PyObject *temp = tstate->c_profileobj; - Py_XINCREF(arg); - tstate->c_profilefunc = NULL; - tstate->c_profileobj = NULL; - tstate->use_tracing = tstate->c_tracefunc != NULL; - Py_XDECREF(temp); - tstate->c_profilefunc = func; - tstate->c_profileobj = arg; - tstate->use_tracing = (func != NULL) || (tstate->c_tracefunc != NULL); -} - -void -PyEval_SetTrace(Py_tracefunc func, PyObject *arg) -{ - PyThreadState *tstate = PyThreadState_Get(); - PyObject *temp = tstate->c_traceobj; - Py_XINCREF(arg); - tstate->c_tracefunc = NULL; - tstate->c_traceobj = NULL; - tstate->use_tracing = tstate->c_profilefunc != NULL; - Py_XDECREF(temp); - tstate->c_tracefunc = func; - tstate->c_traceobj = arg; - tstate->use_tracing = ((func != NULL) - || (tstate->c_profilefunc != NULL)); -} - -PyObject * -PyEval_GetBuiltins(void) -{ - PyFrameObject *current_frame = PyEval_GetFrame(); - if (current_frame == NULL) - return PyThreadState_Get()->interp->builtins; - else - return current_frame->f_builtins; -} - -PyObject * -PyEval_GetLocals(void) -{ - PyFrameObject *current_frame = PyEval_GetFrame(); - if (current_frame == NULL) - return NULL; - PyFrame_FastToLocals(current_frame); - return current_frame->f_locals; -} - -PyObject * -PyEval_GetGlobals(void) -{ - PyFrameObject *current_frame = PyEval_GetFrame(); - if (current_frame == NULL) - return NULL; - else - return current_frame->f_globals; -} - -PyFrameObject * -PyEval_GetFrame(void) -{ - PyThreadState *tstate = PyThreadState_Get(); - return _PyThreadState_GetFrame(tstate); -} - -int -PyEval_GetRestricted(void) -{ - PyFrameObject *current_frame = PyEval_GetFrame(); - return current_frame == NULL ? 0 : current_frame->f_restricted; -} - -int -PyEval_MergeCompilerFlags(PyCompilerFlags *cf) -{ - PyFrameObject *current_frame = PyEval_GetFrame(); - int result = cf->cf_flags != 0; - - if (current_frame != NULL) { - const int codeflags = current_frame->f_code->co_flags; - const int compilerflags = codeflags & PyCF_MASK; - if (compilerflags) { - result = 1; - cf->cf_flags |= compilerflags; - } -#if 0 /* future keyword */ - if (codeflags & CO_GENERATOR_ALLOWED) { - result = 1; - cf->cf_flags |= CO_GENERATOR_ALLOWED; - } -#endif - } - return result; -} - -int -Py_FlushLine(void) -{ - PyObject *f = PySys_GetObject("stdout"); - if (f == NULL) - return 0; - if (!PyFile_SoftSpace(f, 0)) - return 0; - return PyFile_WriteString("\n", f); -} - - -/* External interface to call any callable object. - The arg must be a tuple or NULL. */ - -#undef PyEval_CallObject -/* for backward compatibility: export this interface */ - -PyObject * -PyEval_CallObject(PyObject *func, PyObject *arg) -{ - return PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL); -} -#define PyEval_CallObject(func,arg) \ - PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL) - -PyObject * -PyEval_CallObjectWithKeywords(PyObject *func, PyObject *arg, PyObject *kw) -{ - PyObject *result; - - if (arg == NULL) - arg = PyTuple_New(0); - else if (!PyTuple_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "argument list must be a tuple"); - return NULL; - } - else - Py_INCREF(arg); - - if (kw != NULL && !PyDict_Check(kw)) { - PyErr_SetString(PyExc_TypeError, - "keyword list must be a dictionary"); - Py_DECREF(arg); - return NULL; - } - - result = PyObject_Call(func, arg, kw); - Py_DECREF(arg); - return result; -} - -char * -PyEval_GetFuncName(PyObject *func) -{ - if (PyMethod_Check(func)) - return PyEval_GetFuncName(PyMethod_GET_FUNCTION(func)); - else if (PyFunction_Check(func)) - return PyString_AsString(((PyFunctionObject*)func)->func_name); - else if (PyCFunction_Check(func)) - return ((PyCFunctionObject*)func)->m_ml->ml_name; - else if (PyClass_Check(func)) - return PyString_AsString(((PyClassObject*)func)->cl_name); - else if (PyInstance_Check(func)) { - return PyString_AsString( - ((PyInstanceObject*)func)->in_class->cl_name); - } else { - return func->ob_type->tp_name; - } -} - -char * -PyEval_GetFuncDesc(PyObject *func) -{ - if (PyMethod_Check(func)) - return "()"; - else if (PyFunction_Check(func)) - return "()"; - else if (PyCFunction_Check(func)) - return "()"; - else if (PyClass_Check(func)) - return " constructor"; - else if (PyInstance_Check(func)) { - return " instance"; - } else { - return " object"; - } -} - -#define EXT_POP(STACK_POINTER) (*--(STACK_POINTER)) - -static void -err_args(PyObject *func, int flags, int nargs) -{ - if (flags & METH_NOARGS) - PyErr_Format(PyExc_TypeError, - "%.200s() takes no arguments (%d given)", - ((PyCFunctionObject *)func)->m_ml->ml_name, - nargs); - else - PyErr_Format(PyExc_TypeError, - "%.200s() takes exactly one argument (%d given)", - ((PyCFunctionObject *)func)->m_ml->ml_name, - nargs); -} - -static PyObject * -call_function(PyObject ***pp_stack, int oparg) -{ - int na = oparg & 0xff; - int nk = (oparg>>8) & 0xff; - int n = na + 2 * nk; - PyObject **pfunc = (*pp_stack) - n - 1; - PyObject *func = *pfunc; - PyObject *x, *w; - - /* Always dispatch PyCFunction first, because these are - presumed to be the most frequent callable object. - */ - if (PyCFunction_Check(func) && nk == 0) { - int flags = PyCFunction_GET_FLAGS(func); - PCALL(PCALL_CFUNCTION); - if (flags & (METH_NOARGS | METH_O)) { - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - if (flags & METH_NOARGS && na == 0) - x = (*meth)(self, NULL); - else if (flags & METH_O && na == 1) { - PyObject *arg = EXT_POP(*pp_stack); - x = (*meth)(self, arg); - Py_DECREF(arg); - } - else { - err_args(func, flags, na); - x = NULL; - } - } - else { - PyObject *callargs; - callargs = load_args(pp_stack, na); - x = PyCFunction_Call(func, callargs, NULL); - Py_XDECREF(callargs); - } - } else { - if (PyMethod_Check(func) && PyMethod_GET_SELF(func) != NULL) { - /* optimize access to bound methods */ - PyObject *self = PyMethod_GET_SELF(func); - PCALL(PCALL_METHOD); - PCALL(PCALL_BOUND_METHOD); - Py_INCREF(self); - func = PyMethod_GET_FUNCTION(func); - Py_INCREF(func); - Py_DECREF(*pfunc); - *pfunc = self; - na++; - n++; - } else - Py_INCREF(func); - if (PyFunction_Check(func)) - x = fast_function(func, pp_stack, n, na, nk); - else - x = do_call(func, pp_stack, na, nk); - Py_DECREF(func); - } - - /* What does this do? */ - while ((*pp_stack) > pfunc) { - w = EXT_POP(*pp_stack); - Py_DECREF(w); - PCALL(PCALL_POP); - } - return x; -} - -/* The fast_function() function optimize calls for which no argument - tuple is necessary; the objects are passed directly from the stack. - For the simplest case -- a function that takes only positional - arguments and is called with only positional arguments -- it - inlines the most primitive frame setup code from - PyEval_EvalCodeEx(), which vastly reduces the checks that must be - done before evaluating the frame. -*/ - -static PyObject * -fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk) -{ - PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); - PyObject *globals = PyFunction_GET_GLOBALS(func); - PyObject *argdefs = PyFunction_GET_DEFAULTS(func); - PyObject **d = NULL; - int nd = 0; - - PCALL(PCALL_FUNCTION); - PCALL(PCALL_FAST_FUNCTION); - if (argdefs == NULL && co->co_argcount == n && nk==0 && - co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { - PyFrameObject *f; - PyObject *retval = NULL; - PyThreadState *tstate = PyThreadState_GET(); - PyObject **fastlocals, **stack; - int i; - - PCALL(PCALL_FASTER_FUNCTION); - assert(globals != NULL); - /* XXX Perhaps we should create a specialized - PyFrame_New() that doesn't take locals, but does - take builtins without sanity checking them. - */ - f = PyFrame_New(tstate, co, globals, NULL); - if (f == NULL) - return NULL; - - fastlocals = f->f_localsplus; - stack = (*pp_stack) - n; - - for (i = 0; i < n; i++) { - Py_INCREF(*stack); - fastlocals[i] = *stack++; - } - retval = eval_frame(f); - assert(tstate != NULL); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; - return retval; - } - if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); - nd = ((PyTupleObject *)argdefs)->ob_size; - } - return PyEval_EvalCodeEx(co, globals, - (PyObject *)NULL, (*pp_stack)-n, na, - (*pp_stack)-2*nk, nk, d, nd, - PyFunction_GET_CLOSURE(func)); -} - -static PyObject * -update_keyword_args(PyObject *orig_kwdict, int nk, PyObject ***pp_stack, - PyObject *func) -{ - PyObject *kwdict = NULL; - if (orig_kwdict == NULL) - kwdict = PyDict_New(); - else { - kwdict = PyDict_Copy(orig_kwdict); - Py_DECREF(orig_kwdict); - } - if (kwdict == NULL) - return NULL; - while (--nk >= 0) { - int err; - PyObject *value = EXT_POP(*pp_stack); - PyObject *key = EXT_POP(*pp_stack); - if (PyDict_GetItem(kwdict, key) != NULL) { - PyErr_Format(PyExc_TypeError, - "%.200s%s got multiple values " - "for keyword argument '%.200s'", - PyEval_GetFuncName(func), - PyEval_GetFuncDesc(func), - PyString_AsString(key)); - Py_DECREF(key); - Py_DECREF(value); - Py_DECREF(kwdict); - return NULL; - } - err = PyDict_SetItem(kwdict, key, value); - Py_DECREF(key); - Py_DECREF(value); - if (err) { - Py_DECREF(kwdict); - return NULL; - } - } - return kwdict; -} - -static PyObject * -update_star_args(int nstack, int nstar, PyObject *stararg, - PyObject ***pp_stack) -{ - PyObject *callargs, *w; - - callargs = PyTuple_New(nstack + nstar); - if (callargs == NULL) { - return NULL; - } - if (nstar) { - int i; - for (i = 0; i < nstar; i++) { - PyObject *a = PyTuple_GET_ITEM(stararg, i); - Py_INCREF(a); - PyTuple_SET_ITEM(callargs, nstack + i, a); - } - } - while (--nstack >= 0) { - w = EXT_POP(*pp_stack); - PyTuple_SET_ITEM(callargs, nstack, w); - } - return callargs; -} - -static PyObject * -load_args(PyObject ***pp_stack, int na) -{ - PyObject *args = PyTuple_New(na); - PyObject *w; - - if (args == NULL) - return NULL; - while (--na >= 0) { - w = EXT_POP(*pp_stack); - PyTuple_SET_ITEM(args, na, w); - } - return args; -} - -static PyObject * -do_call(PyObject *func, PyObject ***pp_stack, int na, int nk) -{ - PyObject *callargs = NULL; - PyObject *kwdict = NULL; - PyObject *result = NULL; - - if (nk > 0) { - kwdict = update_keyword_args(NULL, nk, pp_stack, func); - if (kwdict == NULL) - goto call_fail; - } - callargs = load_args(pp_stack, na); - if (callargs == NULL) - goto call_fail; -#ifdef CALL_PROFILE - /* At this point, we have to look at the type of func to - update the call stats properly. Do it here so as to avoid - exposing the call stats machinery outside ceval.c - */ - if (PyFunction_Check(func)) - PCALL(PCALL_FUNCTION); - else if (PyMethod_Check(func)) - PCALL(PCALL_METHOD); - else if (PyType_Check(func)) - PCALL(PCALL_TYPE); - else - PCALL(PCALL_OTHER); -#endif - result = PyObject_Call(func, callargs, kwdict); - call_fail: - Py_XDECREF(callargs); - Py_XDECREF(kwdict); - return result; -} - -static PyObject * -ext_do_call(PyObject *func, PyObject ***pp_stack, int flags, int na, int nk) -{ - int nstar = 0; - PyObject *callargs = NULL; - PyObject *stararg = NULL; - PyObject *kwdict = NULL; - PyObject *result = NULL; - - if (flags & CALL_FLAG_KW) { - kwdict = EXT_POP(*pp_stack); - if (!(kwdict && PyDict_Check(kwdict))) { - PyErr_Format(PyExc_TypeError, - "%s%s argument after ** " - "must be a dictionary", - PyEval_GetFuncName(func), - PyEval_GetFuncDesc(func)); - goto ext_call_fail; - } - } - if (flags & CALL_FLAG_VAR) { - stararg = EXT_POP(*pp_stack); - if (!PyTuple_Check(stararg)) { - PyObject *t = NULL; - t = PySequence_Tuple(stararg); - if (t == NULL) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) { - PyErr_Format(PyExc_TypeError, - "%s%s argument after * " - "must be a sequence", - PyEval_GetFuncName(func), - PyEval_GetFuncDesc(func)); - } - goto ext_call_fail; - } - Py_DECREF(stararg); - stararg = t; - } - nstar = PyTuple_GET_SIZE(stararg); - } - if (nk > 0) { - kwdict = update_keyword_args(kwdict, nk, pp_stack, func); - if (kwdict == NULL) - goto ext_call_fail; - } - callargs = update_star_args(na, nstar, stararg, pp_stack); - if (callargs == NULL) - goto ext_call_fail; -#ifdef CALL_PROFILE - /* At this point, we have to look at the type of func to - update the call stats properly. Do it here so as to avoid - exposing the call stats machinery outside ceval.c - */ - if (PyFunction_Check(func)) - PCALL(PCALL_FUNCTION); - else if (PyMethod_Check(func)) - PCALL(PCALL_METHOD); - else if (PyType_Check(func)) - PCALL(PCALL_TYPE); - else - PCALL(PCALL_OTHER); -#endif - result = PyObject_Call(func, callargs, kwdict); - ext_call_fail: - Py_XDECREF(callargs); - Py_XDECREF(kwdict); - Py_XDECREF(stararg); - return result; -} - -#define SLICE_ERROR_MSG \ - "standard sequence type does not support step size other than one" - -/* Extract a slice index from a PyInt or PyLong, and store in *pi. - Silently reduce values larger than INT_MAX to INT_MAX, and silently - boost values less than -INT_MAX to 0. Return 0 on error, 1 on success. -*/ -/* Note: If v is NULL, return success without storing into *pi. This - is because_PyEval_SliceIndex() is called by apply_slice(), which can be - called by the SLICE opcode with v and/or w equal to NULL. -*/ -int -_PyEval_SliceIndex(PyObject *v, int *pi) -{ - if (v != NULL) { - long x; - if (PyInt_Check(v)) { - x = PyInt_AsLong(v); - } else if (PyLong_Check(v)) { - x = PyLong_AsLong(v); - if (x==-1 && PyErr_Occurred()) { - PyObject *long_zero; - int cmp; - - if (!PyErr_ExceptionMatches( - PyExc_OverflowError)) { - /* It's not an overflow error, so just - signal an error */ - return 0; - } - - /* Clear the OverflowError */ - PyErr_Clear(); - - /* It's an overflow error, so we need to - check the sign of the long integer, - set the value to INT_MAX or -INT_MAX, - and clear the error. */ - - /* Create a long integer with a value of 0 */ - long_zero = PyLong_FromLong(0L); - if (long_zero == NULL) - return 0; - - /* Check sign */ - cmp = PyObject_RichCompareBool(v, long_zero, - Py_GT); - Py_DECREF(long_zero); - if (cmp < 0) - return 0; - else if (cmp) - x = INT_MAX; - else - x = -INT_MAX; - } - } else { - PyErr_SetString(PyExc_TypeError, - "slice indices must be integers"); - return 0; - } - /* Truncate -- very long indices are truncated anyway */ - if (x > INT_MAX) - x = INT_MAX; - else if (x < -INT_MAX) - x = -INT_MAX; - *pi = x; - } - return 1; -} - -#undef ISINT -#define ISINT(x) ((x) == NULL || PyInt_Check(x) || PyLong_Check(x)) - -static PyObject * -apply_slice(PyObject *u, PyObject *v, PyObject *w) /* return u[v:w] */ -{ - PyTypeObject *tp = u->ob_type; - PySequenceMethods *sq = tp->tp_as_sequence; - - if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) { - int ilow = 0, ihigh = INT_MAX; - if (!_PyEval_SliceIndex(v, &ilow)) - return NULL; - if (!_PyEval_SliceIndex(w, &ihigh)) - return NULL; - return PySequence_GetSlice(u, ilow, ihigh); - } - else { - PyObject *slice = PySlice_New(v, w, NULL); - if (slice != NULL) { - PyObject *res = PyObject_GetItem(u, slice); - Py_DECREF(slice); - return res; - } - else - return NULL; - } -} - -static int -assign_slice(PyObject *u, PyObject *v, PyObject *w, PyObject *x) - /* u[v:w] = x */ -{ - PyTypeObject *tp = u->ob_type; - PySequenceMethods *sq = tp->tp_as_sequence; - - if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) { - int ilow = 0, ihigh = INT_MAX; - if (!_PyEval_SliceIndex(v, &ilow)) - return -1; - if (!_PyEval_SliceIndex(w, &ihigh)) - return -1; - if (x == NULL) - return PySequence_DelSlice(u, ilow, ihigh); - else - return PySequence_SetSlice(u, ilow, ihigh, x); - } - else { - PyObject *slice = PySlice_New(v, w, NULL); - if (slice != NULL) { - int res; - if (x != NULL) - res = PyObject_SetItem(u, slice, x); - else - res = PyObject_DelItem(u, slice); - Py_DECREF(slice); - return res; - } - else - return -1; - } -} - -static PyObject * -cmp_outcome(int op, register PyObject *v, register PyObject *w) -{ - int res = 0; - switch (op) { - case PyCmp_IS: - res = (v == w); - break; - case PyCmp_IS_NOT: - res = (v != w); - break; - case PyCmp_IN: - res = PySequence_Contains(w, v); - if (res < 0) - return NULL; - break; - case PyCmp_NOT_IN: - res = PySequence_Contains(w, v); - if (res < 0) - return NULL; - res = !res; - break; - case PyCmp_EXC_MATCH: - res = PyErr_GivenExceptionMatches(v, w); - break; - default: - return PyObject_RichCompare(v, w, op); - } - v = res ? Py_True : Py_False; - Py_INCREF(v); - return v; -} - -static PyObject * -import_from(PyObject *v, PyObject *name) -{ - PyObject *x; - - x = PyObject_GetAttr(v, name); - if (x == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Format(PyExc_ImportError, - "cannot import name %.230s", - PyString_AsString(name)); - } - return x; -} - -static int -import_all_from(PyObject *locals, PyObject *v) -{ - PyObject *all = PyObject_GetAttrString(v, "__all__"); - PyObject *dict, *name, *value; - int skip_leading_underscores = 0; - int pos, err; - - if (all == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return -1; /* Unexpected error */ - PyErr_Clear(); - dict = PyObject_GetAttrString(v, "__dict__"); - if (dict == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return -1; - PyErr_SetString(PyExc_ImportError, - "from-import-* object has no __dict__ and no __all__"); - return -1; - } - all = PyMapping_Keys(dict); - Py_DECREF(dict); - if (all == NULL) - return -1; - skip_leading_underscores = 1; - } - - for (pos = 0, err = 0; ; pos++) { - name = PySequence_GetItem(all, pos); - if (name == NULL) { - if (!PyErr_ExceptionMatches(PyExc_IndexError)) - err = -1; - else - PyErr_Clear(); - break; - } - if (skip_leading_underscores && - PyString_Check(name) && - PyString_AS_STRING(name)[0] == '_') - { - Py_DECREF(name); - continue; - } - value = PyObject_GetAttr(v, name); - if (value == NULL) - err = -1; - else - err = PyDict_SetItem(locals, name, value); - Py_DECREF(name); - Py_XDECREF(value); - if (err != 0) - break; - } - Py_DECREF(all); - return err; -} - -static PyObject * -build_class(PyObject *methods, PyObject *bases, PyObject *name) -{ - PyObject *metaclass = NULL, *result, *base; - - if (PyDict_Check(methods)) - metaclass = PyDict_GetItemString(methods, "__metaclass__"); - if (metaclass != NULL) - Py_INCREF(metaclass); - else if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) { - base = PyTuple_GET_ITEM(bases, 0); - metaclass = PyObject_GetAttrString(base, "__class__"); - if (metaclass == NULL) { - PyErr_Clear(); - metaclass = (PyObject *)base->ob_type; - Py_INCREF(metaclass); - } - } - else { - PyObject *g = PyEval_GetGlobals(); - if (g != NULL && PyDict_Check(g)) - metaclass = PyDict_GetItemString(g, "__metaclass__"); - if (metaclass == NULL) - metaclass = (PyObject *) &PyClass_Type; - Py_INCREF(metaclass); - } - result = PyObject_CallFunction(metaclass, "OOO", name, bases, methods); - Py_DECREF(metaclass); - return result; -} - -static int -exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals, - PyObject *locals) -{ - int n; - PyObject *v; - int plain = 0; - - if (PyTuple_Check(prog) && globals == Py_None && locals == Py_None && - ((n = PyTuple_Size(prog)) == 2 || n == 3)) { - /* Backward compatibility hack */ - globals = PyTuple_GetItem(prog, 1); - if (n == 3) - locals = PyTuple_GetItem(prog, 2); - prog = PyTuple_GetItem(prog, 0); - } - if (globals == Py_None) { - globals = PyEval_GetGlobals(); - if (locals == Py_None) { - locals = PyEval_GetLocals(); - plain = 1; - } - } - else if (locals == Py_None) - locals = globals; - if (!PyString_Check(prog) && - !PyUnicode_Check(prog) && - !PyCode_Check(prog) && - !PyFile_Check(prog)) { - PyErr_SetString(PyExc_TypeError, - "exec: arg 1 must be a string, file, or code object"); - return -1; - } - if (!PyDict_Check(globals)) { - PyErr_SetString(PyExc_TypeError, - "exec: arg 2 must be a dictionary or None"); - return -1; - } - if (!PyDict_Check(locals)) { - PyErr_SetString(PyExc_TypeError, - "exec: arg 3 must be a dictionary or None"); - return -1; - } - if (PyDict_GetItemString(globals, "__builtins__") == NULL) - PyDict_SetItemString(globals, "__builtins__", f->f_builtins); - if (PyCode_Check(prog)) { - if (PyCode_GetNumFree((PyCodeObject *)prog) > 0) { - PyErr_SetString(PyExc_TypeError, - "code object passed to exec may not contain free variables"); - return -1; - } - v = PyEval_EvalCode((PyCodeObject *) prog, globals, locals); - } - else if (PyFile_Check(prog)) { - FILE *fp = PyFile_AsFile(prog); - char *name = PyString_AsString(PyFile_Name(prog)); - PyCompilerFlags cf; - cf.cf_flags = 0; - if (PyEval_MergeCompilerFlags(&cf)) - v = PyRun_FileFlags(fp, name, Py_file_input, globals, - locals, &cf); - else - v = PyRun_File(fp, name, Py_file_input, globals, - locals); - } - else { - PyObject *tmp = NULL; - char *str; - PyCompilerFlags cf; - cf.cf_flags = 0; -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(prog)) { - tmp = PyUnicode_AsUTF8String(prog); - if (tmp == NULL) - return -1; - prog = tmp; - cf.cf_flags |= PyCF_SOURCE_IS_UTF8; - } -#endif - if (PyString_AsStringAndSize(prog, &str, NULL)) - return -1; - if (PyEval_MergeCompilerFlags(&cf)) - v = PyRun_StringFlags(str, Py_file_input, globals, - locals, &cf); - else - v = PyRun_String(str, Py_file_input, globals, locals); - Py_XDECREF(tmp); - } - if (plain) - PyFrame_LocalsToFast(f, 0); - if (v == NULL) - return -1; - Py_DECREF(v); - return 0; -} - -static void -format_exc_check_arg(PyObject *exc, char *format_str, PyObject *obj) -{ - char *obj_str; - - if (!obj) - return; - - obj_str = PyString_AsString(obj); - if (!obj_str) - return; - - PyErr_Format(exc, format_str, obj_str); -} - -#ifdef DYNAMIC_EXECUTION_PROFILE - -static PyObject * -getarray(long a[256]) -{ - int i; - PyObject *l = PyList_New(256); - if (l == NULL) return NULL; - for (i = 0; i < 256; i++) { - PyObject *x = PyInt_FromLong(a[i]); - if (x == NULL) { - Py_DECREF(l); - return NULL; - } - PyList_SetItem(l, i, x); - } - for (i = 0; i < 256; i++) - a[i] = 0; - return l; -} - -PyObject * -_Py_GetDXProfile(PyObject *self, PyObject *args) -{ -#ifndef DXPAIRS - return getarray(dxp); -#else - int i; - PyObject *l = PyList_New(257); - if (l == NULL) return NULL; - for (i = 0; i < 257; i++) { - PyObject *x = getarray(dxpairs[i]); - if (x == NULL) { - Py_DECREF(l); - return NULL; - } - PyList_SetItem(l, i, x); - } - return l; -#endif -} - -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/codecs.c b/SDKs/XPlatform/Cypython-2.3.3/Python/codecs.c deleted file mode 100644 index cb15126f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/codecs.c +++ /dev/null @@ -1,831 +0,0 @@ -/* ------------------------------------------------------------------------ - - Python Codec Registry and support functions - -Written by Marc-Andre Lemburg (mal@lemburg.com). - -Copyright (c) Corporation for National Research Initiatives. - - ------------------------------------------------------------------------ */ - -#include "Python.h" -#include - -/* --- Codec Registry ----------------------------------------------------- */ - -/* Import the standard encodings package which will register the first - codec search function. - - This is done in a lazy way so that the Unicode implementation does - not downgrade startup time of scripts not needing it. - - ImportErrors are silently ignored by this function. Only one try is - made. - -*/ - -static int _PyCodecRegistry_Init(void); /* Forward */ - -int PyCodec_Register(PyObject *search_function) -{ - PyInterpreterState *interp = PyThreadState_Get()->interp; - if (interp->codec_search_path == NULL && _PyCodecRegistry_Init()) - goto onError; - if (search_function == NULL) { - PyErr_BadArgument(); - goto onError; - } - if (!PyCallable_Check(search_function)) { - PyErr_SetString(PyExc_TypeError, - "argument must be callable"); - goto onError; - } - return PyList_Append(interp->codec_search_path, search_function); - - onError: - return -1; -} - -/* Convert a string to a normalized Python string: all characters are - converted to lower case, spaces are replaced with underscores. */ - -static -PyObject *normalizestring(const char *string) -{ - register size_t i; - size_t len = strlen(string); - char *p; - PyObject *v; - - if (len > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, "string is too large"); - return NULL; - } - - v = PyString_FromStringAndSize(NULL, (int)len); - if (v == NULL) - return NULL; - p = PyString_AS_STRING(v); - for (i = 0; i < len; i++) { - register char ch = string[i]; - if (ch == ' ') - ch = '-'; - else - ch = tolower(ch); - p[i] = ch; - } - return v; -} - -/* Lookup the given encoding and return a tuple providing the codec - facilities. - - The encoding string is looked up converted to all lower-case - characters. This makes encodings looked up through this mechanism - effectively case-insensitive. - - If no codec is found, a LookupError is set and NULL returned. - - As side effect, this tries to load the encodings package, if not - yet done. This is part of the lazy load strategy for the encodings - package. - -*/ - -PyObject *_PyCodec_Lookup(const char *encoding) -{ - PyInterpreterState *interp; - PyObject *result, *args = NULL, *v; - int i, len; - - if (encoding == NULL) { - PyErr_BadArgument(); - goto onError; - } - - interp = PyThreadState_Get()->interp; - if (interp->codec_search_path == NULL && _PyCodecRegistry_Init()) - goto onError; - - /* Convert the encoding to a normalized Python string: all - characters are converted to lower case, spaces and hyphens are - replaced with underscores. */ - v = normalizestring(encoding); - if (v == NULL) - goto onError; - PyString_InternInPlace(&v); - - /* First, try to lookup the name in the registry dictionary */ - result = PyDict_GetItem(interp->codec_search_cache, v); - if (result != NULL) { - Py_INCREF(result); - Py_DECREF(v); - return result; - } - - /* Next, scan the search functions in order of registration */ - args = PyTuple_New(1); - if (args == NULL) - goto onError; - PyTuple_SET_ITEM(args,0,v); - - len = PyList_Size(interp->codec_search_path); - if (len < 0) - goto onError; - if (len == 0) { - PyErr_SetString(PyExc_LookupError, - "no codec search functions registered: " - "can't find encoding"); - goto onError; - } - - for (i = 0; i < len; i++) { - PyObject *func; - - func = PyList_GetItem(interp->codec_search_path, i); - if (func == NULL) - goto onError; - result = PyEval_CallObject(func, args); - if (result == NULL) - goto onError; - if (result == Py_None) { - Py_DECREF(result); - continue; - } - if (!PyTuple_Check(result) || PyTuple_GET_SIZE(result) != 4) { - PyErr_SetString(PyExc_TypeError, - "codec search functions must return 4-tuples"); - Py_DECREF(result); - goto onError; - } - break; - } - if (i == len) { - /* XXX Perhaps we should cache misses too ? */ - PyErr_Format(PyExc_LookupError, - "unknown encoding: %s", encoding); - goto onError; - } - - /* Cache and return the result */ - PyDict_SetItem(interp->codec_search_cache, v, result); - Py_DECREF(args); - return result; - - onError: - Py_XDECREF(args); - return NULL; -} - -static -PyObject *args_tuple(PyObject *object, - const char *errors) -{ - PyObject *args; - - args = PyTuple_New(1 + (errors != NULL)); - if (args == NULL) - return NULL; - Py_INCREF(object); - PyTuple_SET_ITEM(args,0,object); - if (errors) { - PyObject *v; - - v = PyString_FromString(errors); - if (v == NULL) { - Py_DECREF(args); - return NULL; - } - PyTuple_SET_ITEM(args, 1, v); - } - return args; -} - -/* Build a codec by calling factory(stream[,errors]) or just - factory(errors) depending on whether the given parameters are - non-NULL. */ - -static -PyObject *build_stream_codec(PyObject *factory, - PyObject *stream, - const char *errors) -{ - PyObject *args, *codec; - - args = args_tuple(stream, errors); - if (args == NULL) - return NULL; - - codec = PyEval_CallObject(factory, args); - Py_DECREF(args); - return codec; -} - -/* Convenience APIs to query the Codec registry. - - All APIs return a codec object with incremented refcount. - - */ - -PyObject *PyCodec_Encoder(const char *encoding) -{ - PyObject *codecs; - PyObject *v; - - codecs = _PyCodec_Lookup(encoding); - if (codecs == NULL) - goto onError; - v = PyTuple_GET_ITEM(codecs,0); - Py_DECREF(codecs); - Py_INCREF(v); - return v; - - onError: - return NULL; -} - -PyObject *PyCodec_Decoder(const char *encoding) -{ - PyObject *codecs; - PyObject *v; - - codecs = _PyCodec_Lookup(encoding); - if (codecs == NULL) - goto onError; - v = PyTuple_GET_ITEM(codecs,1); - Py_DECREF(codecs); - Py_INCREF(v); - return v; - - onError: - return NULL; -} - -PyObject *PyCodec_StreamReader(const char *encoding, - PyObject *stream, - const char *errors) -{ - PyObject *codecs, *ret; - - codecs = _PyCodec_Lookup(encoding); - if (codecs == NULL) - goto onError; - ret = build_stream_codec(PyTuple_GET_ITEM(codecs,2),stream,errors); - Py_DECREF(codecs); - return ret; - - onError: - return NULL; -} - -PyObject *PyCodec_StreamWriter(const char *encoding, - PyObject *stream, - const char *errors) -{ - PyObject *codecs, *ret; - - codecs = _PyCodec_Lookup(encoding); - if (codecs == NULL) - goto onError; - ret = build_stream_codec(PyTuple_GET_ITEM(codecs,3),stream,errors); - Py_DECREF(codecs); - return ret; - - onError: - return NULL; -} - -/* Encode an object (e.g. an Unicode object) using the given encoding - and return the resulting encoded object (usually a Python string). - - errors is passed to the encoder factory as argument if non-NULL. */ - -PyObject *PyCodec_Encode(PyObject *object, - const char *encoding, - const char *errors) -{ - PyObject *encoder = NULL; - PyObject *args = NULL, *result; - PyObject *v; - - encoder = PyCodec_Encoder(encoding); - if (encoder == NULL) - goto onError; - - args = args_tuple(object, errors); - if (args == NULL) - goto onError; - - result = PyEval_CallObject(encoder,args); - if (result == NULL) - goto onError; - - if (!PyTuple_Check(result) || - PyTuple_GET_SIZE(result) != 2) { - PyErr_SetString(PyExc_TypeError, - "encoder must return a tuple (object,integer)"); - goto onError; - } - v = PyTuple_GET_ITEM(result,0); - Py_INCREF(v); - /* We don't check or use the second (integer) entry. */ - - Py_DECREF(args); - Py_DECREF(encoder); - Py_DECREF(result); - return v; - - onError: - Py_XDECREF(args); - Py_XDECREF(encoder); - return NULL; -} - -/* Decode an object (usually a Python string) using the given encoding - and return an equivalent object (e.g. an Unicode object). - - errors is passed to the decoder factory as argument if non-NULL. */ - -PyObject *PyCodec_Decode(PyObject *object, - const char *encoding, - const char *errors) -{ - PyObject *decoder = NULL; - PyObject *args = NULL, *result = NULL; - PyObject *v; - - decoder = PyCodec_Decoder(encoding); - if (decoder == NULL) - goto onError; - - args = args_tuple(object, errors); - if (args == NULL) - goto onError; - - result = PyEval_CallObject(decoder,args); - if (result == NULL) - goto onError; - if (!PyTuple_Check(result) || - PyTuple_GET_SIZE(result) != 2) { - PyErr_SetString(PyExc_TypeError, - "decoder must return a tuple (object,integer)"); - goto onError; - } - v = PyTuple_GET_ITEM(result,0); - Py_INCREF(v); - /* We don't check or use the second (integer) entry. */ - - Py_DECREF(args); - Py_DECREF(decoder); - Py_DECREF(result); - return v; - - onError: - Py_XDECREF(args); - Py_XDECREF(decoder); - Py_XDECREF(result); - return NULL; -} - -/* Register the error handling callback function error under the name - name. This function will be called by the codec when it encounters - an unencodable characters/undecodable bytes and doesn't know the - callback name, when name is specified as the error parameter - in the call to the encode/decode function. - Return 0 on success, -1 on error */ -int PyCodec_RegisterError(const char *name, PyObject *error) -{ - PyInterpreterState *interp = PyThreadState_Get()->interp; - if (interp->codec_search_path == NULL && _PyCodecRegistry_Init()) - return -1; - if (!PyCallable_Check(error)) { - PyErr_SetString(PyExc_TypeError, "handler must be callable"); - return -1; - } - return PyDict_SetItemString(interp->codec_error_registry, - (char *)name, error); -} - -/* Lookup the error handling callback function registered under the - name error. As a special case NULL can be passed, in which case - the error handling callback for strict encoding will be returned. */ -PyObject *PyCodec_LookupError(const char *name) -{ - PyObject *handler = NULL; - - PyInterpreterState *interp = PyThreadState_Get()->interp; - if (interp->codec_search_path == NULL && _PyCodecRegistry_Init()) - return NULL; - - if (name==NULL) - name = "strict"; - handler = PyDict_GetItemString(interp->codec_error_registry, (char *)name); - if (!handler) - PyErr_Format(PyExc_LookupError, "unknown error handler name '%.400s'", name); - else - Py_INCREF(handler); - return handler; -} - -static void wrong_exception_type(PyObject *exc) -{ - PyObject *type = PyObject_GetAttrString(exc, "__class__"); - if (type != NULL) { - PyObject *name = PyObject_GetAttrString(type, "__name__"); - Py_DECREF(type); - if (name != NULL) { - PyObject *string = PyObject_Str(name); - Py_DECREF(name); - if (string != NULL) { - PyErr_Format(PyExc_TypeError, - "don't know how to handle %.400s in error callback", - PyString_AS_STRING(string)); - Py_DECREF(string); - } - } - } -} - -PyObject *PyCodec_StrictErrors(PyObject *exc) -{ - if (PyInstance_Check(exc)) - PyErr_SetObject((PyObject*)((PyInstanceObject*)exc)->in_class, - exc); - else - PyErr_SetString(PyExc_TypeError, "codec must pass exception instance"); - return NULL; -} - - -#ifdef Py_USING_UNICODE -PyObject *PyCodec_IgnoreErrors(PyObject *exc) -{ - int end; - if (PyObject_IsInstance(exc, PyExc_UnicodeEncodeError)) { - if (PyUnicodeEncodeError_GetEnd(exc, &end)) - return NULL; - } - else if (PyObject_IsInstance(exc, PyExc_UnicodeDecodeError)) { - if (PyUnicodeDecodeError_GetEnd(exc, &end)) - return NULL; - } - else if (PyObject_IsInstance(exc, PyExc_UnicodeTranslateError)) { - if (PyUnicodeTranslateError_GetEnd(exc, &end)) - return NULL; - } - else { - wrong_exception_type(exc); - return NULL; - } - /* ouch: passing NULL, 0, pos gives None instead of u'' */ - return Py_BuildValue("(u#i)", &end, 0, end); -} - - -PyObject *PyCodec_ReplaceErrors(PyObject *exc) -{ - PyObject *restuple; - int start; - int end; - int i; - - if (PyObject_IsInstance(exc, PyExc_UnicodeEncodeError)) { - PyObject *res; - Py_UNICODE *p; - if (PyUnicodeEncodeError_GetStart(exc, &start)) - return NULL; - if (PyUnicodeEncodeError_GetEnd(exc, &end)) - return NULL; - res = PyUnicode_FromUnicode(NULL, end-start); - if (res == NULL) - return NULL; - for (p = PyUnicode_AS_UNICODE(res), i = start; - i0) { - *outp++ = '0' + c/base; - c %= base; - base /= 10; - } - *outp++ = ';'; - } - restuple = Py_BuildValue("(Oi)", res, end); - Py_DECREF(res); - Py_DECREF(object); - return restuple; - } - else { - wrong_exception_type(exc); - return NULL; - } -} - -static Py_UNICODE hexdigits[] = { - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' -}; - -PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc) -{ - if (PyObject_IsInstance(exc, PyExc_UnicodeEncodeError)) { - PyObject *restuple; - PyObject *object; - int start; - int end; - PyObject *res; - Py_UNICODE *p; - Py_UNICODE *startp; - Py_UNICODE *outp; - int ressize; - if (PyUnicodeEncodeError_GetStart(exc, &start)) - return NULL; - if (PyUnicodeEncodeError_GetEnd(exc, &end)) - return NULL; - if (!(object = PyUnicodeEncodeError_GetObject(exc))) - return NULL; - startp = PyUnicode_AS_UNICODE(object); - for (p = startp+start, ressize = 0; p < startp+end; ++p) { - if (*p >= 0x00010000) - ressize += 1+1+8; - else if (*p >= 0x100) { - ressize += 1+1+4; - } - else - ressize += 1+1+2; - } - res = PyUnicode_FromUnicode(NULL, ressize); - if (res==NULL) - return NULL; - for (p = startp+start, outp = PyUnicode_AS_UNICODE(res); - p < startp+end; ++p) { - Py_UNICODE c = *p; - *outp++ = '\\'; - if (c >= 0x00010000) { - *outp++ = 'U'; - *outp++ = hexdigits[(c>>28)&0xf]; - *outp++ = hexdigits[(c>>24)&0xf]; - *outp++ = hexdigits[(c>>20)&0xf]; - *outp++ = hexdigits[(c>>16)&0xf]; - *outp++ = hexdigits[(c>>12)&0xf]; - *outp++ = hexdigits[(c>>8)&0xf]; - } - else if (c >= 0x100) { - *outp++ = 'u'; - *outp++ = hexdigits[(c>>12)&0xf]; - *outp++ = hexdigits[(c>>8)&0xf]; - } - else - *outp++ = 'x'; - *outp++ = hexdigits[(c>>4)&0xf]; - *outp++ = hexdigits[c&0xf]; - } - - restuple = Py_BuildValue("(Oi)", res, end); - Py_DECREF(res); - Py_DECREF(object); - return restuple; - } - else { - wrong_exception_type(exc); - return NULL; - } -} -#endif - -static PyObject *strict_errors(PyObject *self, PyObject *exc) -{ - return PyCodec_StrictErrors(exc); -} - - -#ifdef Py_USING_UNICODE -static PyObject *ignore_errors(PyObject *self, PyObject *exc) -{ - return PyCodec_IgnoreErrors(exc); -} - - -static PyObject *replace_errors(PyObject *self, PyObject *exc) -{ - return PyCodec_ReplaceErrors(exc); -} - - -static PyObject *xmlcharrefreplace_errors(PyObject *self, PyObject *exc) -{ - return PyCodec_XMLCharRefReplaceErrors(exc); -} - - -static PyObject *backslashreplace_errors(PyObject *self, PyObject *exc) -{ - return PyCodec_BackslashReplaceErrors(exc); -} -#endif - -static int _PyCodecRegistry_Init(void) -{ - static struct { - char *name; - PyMethodDef def; - } methods[] = - { - { - "strict", - { - "strict_errors", - strict_errors, - METH_O - } - }, -#ifdef Py_USING_UNICODE - { - "ignore", - { - "ignore_errors", - ignore_errors, - METH_O - } - }, - { - "replace", - { - "replace_errors", - replace_errors, - METH_O - } - }, - { - "xmlcharrefreplace", - { - "xmlcharrefreplace_errors", - xmlcharrefreplace_errors, - METH_O - } - }, - { - "backslashreplace", - { - "backslashreplace_errors", - backslashreplace_errors, - METH_O - } - } -#endif - }; - - PyInterpreterState *interp = PyThreadState_Get()->interp; - PyObject *mod; - int i; - - if (interp->codec_search_path != NULL) - return 0; - - interp->codec_search_path = PyList_New(0); - interp->codec_search_cache = PyDict_New(); - interp->codec_error_registry = PyDict_New(); - - if (interp->codec_error_registry) { - for (i = 0; i < sizeof(methods)/sizeof(methods[0]); ++i) { - PyObject *func = PyCFunction_New(&methods[i].def, NULL); - int res; - if (!func) - Py_FatalError("can't initialize codec error registry"); - res = PyCodec_RegisterError(methods[i].name, func); - Py_DECREF(func); - if (res) - Py_FatalError("can't initialize codec error registry"); - } - } - - if (interp->codec_search_path == NULL || - interp->codec_search_cache == NULL || - interp->codec_error_registry == NULL) - Py_FatalError("can't initialize codec registry"); - - mod = PyImport_ImportModuleEx("encodings", NULL, NULL, NULL); - if (mod == NULL) { - if (PyErr_ExceptionMatches(PyExc_ImportError)) { - /* Ignore ImportErrors... this is done so that - distributions can disable the encodings package. Note - that other errors are not masked, e.g. SystemErrors - raised to inform the user of an error in the Python - configuration are still reported back to the user. */ - PyErr_Clear(); - return 0; - } - return -1; - } - Py_DECREF(mod); - return 0; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/compile.c b/SDKs/XPlatform/Cypython-2.3.3/Python/compile.c deleted file mode 100644 index 463bf91f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/compile.c +++ /dev/null @@ -1,5779 +0,0 @@ -/* Compile an expression node to intermediate code */ - -/* XXX TO DO: - XXX add __doc__ attribute == co_doc to code object attributes? - XXX (it's currently the first item of the co_const tuple) - XXX Generate simple jump for break/return outside 'try...finally' - XXX Allow 'continue' inside finally clause of try-finally - XXX New opcode for loading the initial index for a for loop - XXX other JAR tricks? -*/ - -#include "Python.h" - -#include "node.h" -#include "token.h" -#include "graminit.h" -#include "compile.h" -#include "symtable.h" -#include "opcode.h" -#include "structmember.h" - -#include - -/* Three symbols from graminit.h are also defined in Python.h, with - Py_ prefixes to their names. Python.h can't include graminit.h - (which defines too many confusing symbols), but we can check here - that they haven't changed (which is very unlikely, but possible). */ -#if Py_single_input != single_input - #error "single_input has changed -- update Py_single_input in Python.h" -#endif -#if Py_file_input != file_input - #error "file_input has changed -- update Py_file_input in Python.h" -#endif -#if Py_eval_input != eval_input - #error "eval_input has changed -- update Py_eval_input in Python.h" -#endif - -int Py_OptimizeFlag = 0; - -#define OP_DELETE 0 -#define OP_ASSIGN 1 -#define OP_APPLY 2 - -#define VAR_LOAD 0 -#define VAR_STORE 1 -#define VAR_DELETE 2 - -#define DEL_CLOSURE_ERROR \ -"can not delete variable '%.400s' referenced in nested scope" - -#define DUPLICATE_ARGUMENT \ -"duplicate argument '%s' in function definition" - -#define ILLEGAL_DYNAMIC_SCOPE \ -"%.100s: exec or 'import *' makes names ambiguous in nested scope" - -#define GLOBAL_AFTER_ASSIGN \ -"name '%.400s' is assigned to before global declaration" - -#define GLOBAL_AFTER_USE \ -"name '%.400s' is used prior to global declaration" - -#define LOCAL_GLOBAL \ -"name '%.400s' is a function parameter and declared global" - -#define LATE_FUTURE \ -"from __future__ imports must occur at the beginning of the file" - -#define ASSIGN_DEBUG \ -"can not assign to __debug__" - -#define MANGLE_LEN 256 - -#define OFF(x) offsetof(PyCodeObject, x) - -static PyMemberDef code_memberlist[] = { - {"co_argcount", T_INT, OFF(co_argcount), READONLY}, - {"co_nlocals", T_INT, OFF(co_nlocals), READONLY}, - {"co_stacksize",T_INT, OFF(co_stacksize), READONLY}, - {"co_flags", T_INT, OFF(co_flags), READONLY}, - {"co_code", T_OBJECT, OFF(co_code), READONLY}, - {"co_consts", T_OBJECT, OFF(co_consts), READONLY}, - {"co_names", T_OBJECT, OFF(co_names), READONLY}, - {"co_varnames", T_OBJECT, OFF(co_varnames), READONLY}, - {"co_freevars", T_OBJECT, OFF(co_freevars), READONLY}, - {"co_cellvars", T_OBJECT, OFF(co_cellvars), READONLY}, - {"co_filename", T_OBJECT, OFF(co_filename), READONLY}, - {"co_name", T_OBJECT, OFF(co_name), READONLY}, - {"co_firstlineno", T_INT, OFF(co_firstlineno), READONLY}, - {"co_lnotab", T_OBJECT, OFF(co_lnotab), READONLY}, - {NULL} /* Sentinel */ -}; - -PyDoc_STRVAR(code_doc, -"code(argcount, nlocals, stacksize, flags, codestring, constants, names,\n\ - varnames, filename, name, firstlineno, lnotab[, freevars[, cellvars]])\n\ -\n\ -Create a code object. Not for the faint of heart."); - -static PyObject * -code_new(PyTypeObject *type, PyObject *args, PyObject *kw) -{ - int argcount; - int nlocals; - int stacksize; - int flags; - PyObject *co; - PyObject *empty = NULL; - PyObject *code; - PyObject *consts; - PyObject *names; - PyObject *varnames; - PyObject *freevars = NULL; - PyObject *cellvars = NULL; - PyObject *filename; - PyObject *name; - int firstlineno; - PyObject *lnotab; - - if (!PyArg_ParseTuple(args, "iiiiSO!O!O!SSiS|O!O!:code", - &argcount, &nlocals, &stacksize, &flags, - &code, - &PyTuple_Type, &consts, - &PyTuple_Type, &names, - &PyTuple_Type, &varnames, - &filename, &name, - &firstlineno, &lnotab, - &PyTuple_Type, &freevars, - &PyTuple_Type, &cellvars)) - return NULL; - - if (!PyObject_CheckReadBuffer(code)) { - PyErr_SetString(PyExc_TypeError, - "bytecode object must be a single-segment read-only buffer"); - return NULL; - } - - if (freevars == NULL || cellvars == NULL) { - empty = PyTuple_New(0); - if (empty == NULL) - return NULL; - if (freevars == NULL) - freevars = empty; - if (cellvars == NULL) - cellvars = empty; - } - - co = (PyObject *) PyCode_New(argcount, nlocals, stacksize, flags, - code, consts, names, varnames, - freevars, cellvars, filename, name, - firstlineno, lnotab); - Py_XDECREF(empty); - return co; -} - -static void -code_dealloc(PyCodeObject *co) -{ - Py_XDECREF(co->co_code); - Py_XDECREF(co->co_consts); - Py_XDECREF(co->co_names); - Py_XDECREF(co->co_varnames); - Py_XDECREF(co->co_freevars); - Py_XDECREF(co->co_cellvars); - Py_XDECREF(co->co_filename); - Py_XDECREF(co->co_name); - Py_XDECREF(co->co_lnotab); - PyObject_DEL(co); -} - -static PyObject * -code_repr(PyCodeObject *co) -{ - char buf[500]; - int lineno = -1; - char *filename = "???"; - char *name = "???"; - - if (co->co_firstlineno != 0) - lineno = co->co_firstlineno; - if (co->co_filename && PyString_Check(co->co_filename)) - filename = PyString_AS_STRING(co->co_filename); - if (co->co_name && PyString_Check(co->co_name)) - name = PyString_AS_STRING(co->co_name); - PyOS_snprintf(buf, sizeof(buf), - "", - name, co, filename, lineno); - return PyString_FromString(buf); -} - -static int -code_compare(PyCodeObject *co, PyCodeObject *cp) -{ - int cmp; - cmp = PyObject_Compare(co->co_name, cp->co_name); - if (cmp) return cmp; - cmp = co->co_argcount - cp->co_argcount; - if (cmp) return (cmp<0)?-1:1; - cmp = co->co_nlocals - cp->co_nlocals; - if (cmp) return (cmp<0)?-1:1; - cmp = co->co_flags - cp->co_flags; - if (cmp) return (cmp<0)?-1:1; - cmp = PyObject_Compare(co->co_code, cp->co_code); - if (cmp) return cmp; - cmp = PyObject_Compare(co->co_consts, cp->co_consts); - if (cmp) return cmp; - cmp = PyObject_Compare(co->co_names, cp->co_names); - if (cmp) return cmp; - cmp = PyObject_Compare(co->co_varnames, cp->co_varnames); - if (cmp) return cmp; - cmp = PyObject_Compare(co->co_freevars, cp->co_freevars); - if (cmp) return cmp; - cmp = PyObject_Compare(co->co_cellvars, cp->co_cellvars); - return cmp; -} - -static long -code_hash(PyCodeObject *co) -{ - long h, h0, h1, h2, h3, h4, h5, h6; - h0 = PyObject_Hash(co->co_name); - if (h0 == -1) return -1; - h1 = PyObject_Hash(co->co_code); - if (h1 == -1) return -1; - h2 = PyObject_Hash(co->co_consts); - if (h2 == -1) return -1; - h3 = PyObject_Hash(co->co_names); - if (h3 == -1) return -1; - h4 = PyObject_Hash(co->co_varnames); - if (h4 == -1) return -1; - h5 = PyObject_Hash(co->co_freevars); - if (h5 == -1) return -1; - h6 = PyObject_Hash(co->co_cellvars); - if (h6 == -1) return -1; - h = h0 ^ h1 ^ h2 ^ h3 ^ h4 ^ h5 ^ h6 ^ - co->co_argcount ^ co->co_nlocals ^ co->co_flags; - if (h == -1) h = -2; - return h; -} - -/* XXX code objects need to participate in GC? */ - -PyTypeObject PyCode_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "code", - sizeof(PyCodeObject), - 0, - (destructor)code_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc)code_compare, /* tp_compare */ - (reprfunc)code_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)code_hash, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - code_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - code_memberlist, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - code_new, /* tp_new */ -}; - -#define NAME_CHARS \ - "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" - -/* all_name_chars(s): true iff all chars in s are valid NAME_CHARS */ - -static int -all_name_chars(unsigned char *s) -{ - static char ok_name_char[256]; - static unsigned char *name_chars = (unsigned char *)NAME_CHARS; - - if (ok_name_char[*name_chars] == 0) { - unsigned char *p; - for (p = name_chars; *p; p++) - ok_name_char[*p] = 1; - } - while (*s) { - if (ok_name_char[*s++] == 0) - return 0; - } - return 1; -} - -static int -intern_strings(PyObject *tuple) -{ - int i; - - for (i = PyTuple_GET_SIZE(tuple); --i >= 0; ) { - PyObject *v = PyTuple_GET_ITEM(tuple, i); - if (v == NULL || !PyString_Check(v)) { - Py_FatalError("non-string found in code slot"); - PyErr_BadInternalCall(); - return -1; - } - PyString_InternInPlace(&PyTuple_GET_ITEM(tuple, i)); - } - return 0; -} - -#define GETARG(arr, i) ((int)((arr[i+2]<<8) + arr[i+1])) -#define UNCONDITIONAL_JUMP(op) (op==JUMP_ABSOLUTE || op==JUMP_FORWARD) -#define ABSOLUTE_JUMP(op) (op==JUMP_ABSOLUTE || op==CONTINUE_LOOP) -#define GETJUMPTGT(arr, i) (GETARG(arr,i) + (ABSOLUTE_JUMP(arr[i]) ? 0 : i+3)) -#define SETARG(arr, i, val) arr[i+2] = val>>8; arr[i+1] = val & 255 - -static PyObject * -optimize_code(PyObject *code, PyObject* consts) -{ - int i, j, codelen; - int tgt, tgttgt, opcode; - unsigned char *codestr; - - /* Make a modifiable copy of the code string */ - if (!PyString_Check(code)) - goto exitUnchanged; - codelen = PyString_Size(code); - codestr = PyMem_Malloc(codelen); - if (codestr == NULL) - goto exitUnchanged; - codestr = memcpy(codestr, PyString_AS_STRING(code), codelen); - assert(PyTuple_Check(consts)); - - for (i=0 ; i= 0; ) { - PyObject *v = PyTuple_GetItem(consts, i); - if (!PyString_Check(v)) - continue; - if (!all_name_chars((unsigned char *)PyString_AS_STRING(v))) - continue; - PyString_InternInPlace(&PyTuple_GET_ITEM(consts, i)); - } - co = PyObject_NEW(PyCodeObject, &PyCode_Type); - if (co != NULL) { - co->co_argcount = argcount; - co->co_nlocals = nlocals; - co->co_stacksize = stacksize; - co->co_flags = flags; - co->co_code = optimize_code(code, consts); - Py_INCREF(consts); - co->co_consts = consts; - Py_INCREF(names); - co->co_names = names; - Py_INCREF(varnames); - co->co_varnames = varnames; - Py_INCREF(freevars); - co->co_freevars = freevars; - Py_INCREF(cellvars); - co->co_cellvars = cellvars; - Py_INCREF(filename); - co->co_filename = filename; - Py_INCREF(name); - co->co_name = name; - co->co_firstlineno = firstlineno; - Py_INCREF(lnotab); - co->co_lnotab = lnotab; - if (PyTuple_GET_SIZE(freevars) == 0 && - PyTuple_GET_SIZE(cellvars) == 0) - co->co_flags |= CO_NOFREE; - } - return co; -} - - -/* Data structure used internally */ - -/* The compiler uses two passes to generate bytecodes. The first pass - builds the symbol table. The second pass generates the bytecode. - - The first pass uses a single symtable struct. The second pass uses - a compiling struct for each code block. The compiling structs - share a reference to the symtable. - - The two passes communicate via symtable_load_symbols() and via - is_local() and is_global(). The former initializes several slots - in the compiling struct: c_varnames, c_locals, c_nlocals, - c_argcount, c_globals, and c_flags. -*/ - -/* All about c_lnotab. - -c_lnotab is an array of unsigned bytes disguised as a Python string. Since -version 2.3, SET_LINENO opcodes are never generated and bytecode offsets are -mapped to source code line #s via c_lnotab instead. - -The array is conceptually a list of - (bytecode offset increment, line number increment) -pairs. The details are important and delicate, best illustrated by example: - - byte code offset source code line number - 0 1 - 6 2 - 50 7 - 350 307 - 361 308 - -The first trick is that these numbers aren't stored, only the increments -from one row to the next (this doesn't really work, but it's a start): - - 0, 1, 6, 1, 44, 5, 300, 300, 11, 1 - -The second trick is that an unsigned byte can't hold negative values, or -values larger than 255, so (a) there's a deep assumption that byte code -offsets and their corresponding line #s both increase monotonically, and (b) -if at least one column jumps by more than 255 from one row to the next, more -than one pair is written to the table. In case #b, there's no way to know -from looking at the table later how many were written. That's the delicate -part. A user of c_lnotab desiring to find the source line number -corresponding to a bytecode address A should do something like this - - lineno = addr = 0 - for addr_incr, line_incr in c_lnotab: - addr += addr_incr - if addr > A: - return lineno - lineno += line_incr - -In order for this to work, when the addr field increments by more than 255, -the line # increment in each pair generated must be 0 until the remaining addr -increment is < 256. So, in the example above, com_set_lineno should not (as -was actually done until 2.2) expand 300, 300 to 255, 255, 45, 45, but to -255, 0, 45, 255, 0, 45. -*/ - -struct compiling { - PyObject *c_code; /* string */ - PyObject *c_consts; /* list of objects */ - PyObject *c_const_dict; /* inverse of c_consts */ - PyObject *c_names; /* list of strings (names) */ - PyObject *c_name_dict; /* inverse of c_names */ - PyObject *c_globals; /* dictionary (value=None or True) */ - PyObject *c_locals; /* dictionary (value=localID) */ - PyObject *c_varnames; /* list (inverse of c_locals) */ - PyObject *c_freevars; /* dictionary (value=None) */ - PyObject *c_cellvars; /* list */ - int c_nlocals; /* index of next local */ - int c_argcount; /* number of top-level arguments */ - int c_flags; /* same as co_flags */ - int c_nexti; /* index into c_code */ - int c_errors; /* counts errors occurred */ - int c_infunction; /* set when compiling a function */ - int c_interactive; /* generating code for interactive command */ - int c_loops; /* counts nested loops */ - int c_begin; /* begin of current loop, for 'continue' */ - int c_block[CO_MAXBLOCKS]; /* stack of block types */ - int c_nblocks; /* current block stack level */ - const char *c_filename; /* filename of current node */ - char *c_name; /* name of object (e.g. function) */ - int c_lineno; /* Current line number */ - int c_stacklevel; /* Current stack level */ - int c_maxstacklevel; /* Maximum stack level */ - int c_firstlineno; - PyObject *c_lnotab; /* Table mapping address to line number */ - int c_last_addr, c_last_line, c_lnotab_next; - char *c_private; /* for private name mangling */ - int c_tmpname; /* temporary local name counter */ - int c_nested; /* Is block nested funcdef or lamdef? */ - int c_closure; /* Is nested w/freevars? */ - struct symtable *c_symtable; /* pointer to module symbol table */ - PyFutureFeatures *c_future; /* pointer to module's __future__ */ - char *c_encoding; /* source encoding (a borrowed reference) */ -}; - -static int -is_free(int v) -{ - if ((v & (USE | DEF_FREE)) - && !(v & (DEF_LOCAL | DEF_PARAM | DEF_GLOBAL))) - return 1; - if (v & DEF_FREE_CLASS) - return 1; - return 0; -} - -static void -com_error(struct compiling *c, PyObject *exc, char *msg) -{ - PyObject *t = NULL, *v = NULL, *w = NULL, *line = NULL; - - if (c == NULL) { - /* Error occurred via symtable call to - is_constant_false */ - PyErr_SetString(exc, msg); - return; - } - c->c_errors++; - if (c->c_lineno < 1 || c->c_interactive) { - /* Unknown line number or interactive input */ - PyErr_SetString(exc, msg); - return; - } - v = PyString_FromString(msg); - if (v == NULL) - return; /* MemoryError, too bad */ - - line = PyErr_ProgramText(c->c_filename, c->c_lineno); - if (line == NULL) { - Py_INCREF(Py_None); - line = Py_None; - } - if (exc == PyExc_SyntaxError) { - t = Py_BuildValue("(ziOO)", c->c_filename, c->c_lineno, - Py_None, line); - if (t == NULL) - goto exit; - w = Py_BuildValue("(OO)", v, t); - if (w == NULL) - goto exit; - PyErr_SetObject(exc, w); - } else { - /* Make sure additional exceptions are printed with - file and line, also. */ - PyErr_SetObject(exc, v); - PyErr_SyntaxLocation(c->c_filename, c->c_lineno); - } - exit: - Py_XDECREF(t); - Py_XDECREF(v); - Py_XDECREF(w); - Py_XDECREF(line); -} - -/* Interface to the block stack */ - -static void -block_push(struct compiling *c, int type) -{ - if (c->c_nblocks >= CO_MAXBLOCKS) { - com_error(c, PyExc_SystemError, - "too many statically nested blocks"); - } - else { - c->c_block[c->c_nblocks++] = type; - } -} - -static void -block_pop(struct compiling *c, int type) -{ - if (c->c_nblocks > 0) - c->c_nblocks--; - if (c->c_block[c->c_nblocks] != type && c->c_errors == 0) { - com_error(c, PyExc_SystemError, "bad block pop"); - } -} - -/* Prototype forward declarations */ - -static int issue_warning(const char *, const char *, int); -static int com_init(struct compiling *, const char *); -static void com_free(struct compiling *); -static void com_push(struct compiling *, int); -static void com_pop(struct compiling *, int); -static void com_done(struct compiling *); -static void com_node(struct compiling *, node *); -static void com_factor(struct compiling *, node *); -static void com_addbyte(struct compiling *, int); -static void com_addint(struct compiling *, int); -static void com_addoparg(struct compiling *, int, int); -static void com_addfwref(struct compiling *, int, int *); -static void com_backpatch(struct compiling *, int); -static int com_add(struct compiling *, PyObject *, PyObject *, PyObject *); -static int com_addconst(struct compiling *, PyObject *); -static int com_addname(struct compiling *, PyObject *); -static void com_addopname(struct compiling *, int, node *); -static void com_list(struct compiling *, node *, int); -static void com_list_iter(struct compiling *, node *, node *, char *); -static int com_argdefs(struct compiling *, node *); -static void com_assign(struct compiling *, node *, int, node *); -static void com_assign_name(struct compiling *, node *, int); -static PyCodeObject *icompile(node *, struct compiling *); -static PyCodeObject *jcompile(node *, const char *, struct compiling *, - PyCompilerFlags *); -static PyObject *parsestrplus(struct compiling*, node *); -static PyObject *parsestr(struct compiling *, char *); -static node *get_rawdocstring(node *); - -static int get_ref_type(struct compiling *, char *); - -/* symtable operations */ -static struct symtable *symtable_build(node *, PyFutureFeatures *, - const char *filename); -static int symtable_load_symbols(struct compiling *); -static struct symtable *symtable_init(void); -static void symtable_enter_scope(struct symtable *, char *, int, int); -static int symtable_exit_scope(struct symtable *); -static int symtable_add_def(struct symtable *, char *, int); -static int symtable_add_def_o(struct symtable *, PyObject *, PyObject *, int); - -static void symtable_node(struct symtable *, node *); -static void symtable_funcdef(struct symtable *, node *); -static void symtable_default_args(struct symtable *, node *); -static void symtable_params(struct symtable *, node *); -static void symtable_params_fplist(struct symtable *, node *n); -static void symtable_global(struct symtable *, node *); -static void symtable_import(struct symtable *, node *); -static void symtable_assign(struct symtable *, node *, int); -static void symtable_list_comprehension(struct symtable *, node *); -static void symtable_list_for(struct symtable *, node *); - -static int symtable_update_free_vars(struct symtable *); -static int symtable_undo_free(struct symtable *, PyObject *, PyObject *); -static int symtable_check_global(struct symtable *, PyObject *, PyObject *); - -/* helper */ -static void -do_pad(int pad) -{ - int i; - for (i = 0; i < pad; ++i) - fprintf(stderr, " "); -} - -static void -dump(node *n, int pad, int depth) -{ - int i; - if (depth == 0) - return; - do_pad(pad); - fprintf(stderr, "%d: %s\n", TYPE(n), STR(n)); - if (depth > 0) - depth--; - for (i = 0; i < NCH(n); ++i) - dump(CHILD(n, i), pad + 1, depth); -} - -#define DUMP(N) dump(N, 0, -1) - -static int -com_init(struct compiling *c, const char *filename) -{ - memset((void *)c, '\0', sizeof(struct compiling)); - if ((c->c_code = PyString_FromStringAndSize((char *)NULL, - 1000)) == NULL) - goto fail; - if ((c->c_consts = PyList_New(0)) == NULL) - goto fail; - if ((c->c_const_dict = PyDict_New()) == NULL) - goto fail; - if ((c->c_names = PyList_New(0)) == NULL) - goto fail; - if ((c->c_name_dict = PyDict_New()) == NULL) - goto fail; - if ((c->c_locals = PyDict_New()) == NULL) - goto fail; - if ((c->c_lnotab = PyString_FromStringAndSize((char *)NULL, - 1000)) == NULL) - goto fail; - c->c_globals = NULL; - c->c_varnames = NULL; - c->c_freevars = NULL; - c->c_cellvars = NULL; - c->c_nlocals = 0; - c->c_argcount = 0; - c->c_flags = 0; - c->c_nexti = 0; - c->c_errors = 0; - c->c_infunction = 0; - c->c_interactive = 0; - c->c_loops = 0; - c->c_begin = 0; - c->c_nblocks = 0; - c->c_filename = filename; - c->c_name = "?"; - c->c_lineno = 0; - c->c_stacklevel = 0; - c->c_maxstacklevel = 0; - c->c_firstlineno = 0; - c->c_last_addr = 0; - c->c_last_line = 0; - c->c_lnotab_next = 0; - c->c_tmpname = 0; - c->c_nested = 0; - c->c_closure = 0; - c->c_symtable = NULL; - return 1; - - fail: - com_free(c); - return 0; -} - -static void -com_free(struct compiling *c) -{ - Py_XDECREF(c->c_code); - Py_XDECREF(c->c_consts); - Py_XDECREF(c->c_const_dict); - Py_XDECREF(c->c_names); - Py_XDECREF(c->c_name_dict); - Py_XDECREF(c->c_globals); - Py_XDECREF(c->c_locals); - Py_XDECREF(c->c_varnames); - Py_XDECREF(c->c_freevars); - Py_XDECREF(c->c_cellvars); - Py_XDECREF(c->c_lnotab); - if (c->c_future) - PyObject_FREE((void *)c->c_future); -} - -static void -com_push(struct compiling *c, int n) -{ - c->c_stacklevel += n; - if (c->c_stacklevel > c->c_maxstacklevel) { - c->c_maxstacklevel = c->c_stacklevel; - /* - fprintf(stderr, "%s:%s:%d max stack nexti=%d level=%d n=%d\n", - c->c_filename, c->c_name, c->c_lineno, - c->c_nexti, c->c_stacklevel, n); - */ - } -} - -static void -com_pop(struct compiling *c, int n) -{ - if (c->c_stacklevel < n) - c->c_stacklevel = 0; - else - c->c_stacklevel -= n; -} - -static void -com_done(struct compiling *c) -{ - if (c->c_code != NULL) - _PyString_Resize(&c->c_code, c->c_nexti); - if (c->c_lnotab != NULL) - _PyString_Resize(&c->c_lnotab, c->c_lnotab_next); -} - -static int -com_check_size(PyObject **s, int offset) -{ - int len = PyString_GET_SIZE(*s); - if (offset >= len) - return _PyString_Resize(s, len * 2); - return 0; -} - -static void -com_addbyte(struct compiling *c, int byte) -{ - /*fprintf(stderr, "%3d: %3d\n", c->c_nexti, byte);*/ - assert(byte >= 0 && byte <= 255); - assert(c->c_code != 0); - if (com_check_size(&c->c_code, c->c_nexti)) { - c->c_errors++; - return; - } - PyString_AS_STRING(c->c_code)[c->c_nexti++] = byte; -} - -static void -com_addint(struct compiling *c, int x) -{ - com_addbyte(c, x & 0xff); - com_addbyte(c, x >> 8); /* XXX x should be positive */ -} - -static void -com_add_lnotab(struct compiling *c, int addr, int line) -{ - char *p; - if (c->c_lnotab == NULL) - return; - if (com_check_size(&c->c_lnotab, c->c_lnotab_next + 2)) { - c->c_errors++; - return; - } - p = PyString_AS_STRING(c->c_lnotab) + c->c_lnotab_next; - *p++ = addr; - *p++ = line; - c->c_lnotab_next += 2; -} - -static void -com_set_lineno(struct compiling *c, int lineno) -{ - c->c_lineno = lineno; - if (c->c_firstlineno == 0) { - c->c_firstlineno = c->c_last_line = lineno; - } - else { - int incr_addr = c->c_nexti - c->c_last_addr; - int incr_line = lineno - c->c_last_line; - while (incr_addr > 255) { - com_add_lnotab(c, 255, 0); - incr_addr -= 255; - } - while (incr_line > 255) { - com_add_lnotab(c, incr_addr, 255); - incr_line -=255; - incr_addr = 0; - } - if (incr_addr > 0 || incr_line > 0) - com_add_lnotab(c, incr_addr, incr_line); - c->c_last_addr = c->c_nexti; - c->c_last_line = lineno; - } -} - -static void -com_addoparg(struct compiling *c, int op, int arg) -{ - int extended_arg = arg >> 16; - if (extended_arg){ - com_addbyte(c, EXTENDED_ARG); - com_addint(c, extended_arg); - arg &= 0xffff; - } - com_addbyte(c, op); - com_addint(c, arg); -} - -static void -com_addfwref(struct compiling *c, int op, int *p_anchor) -{ - /* Compile a forward reference for backpatching */ - int here; - int anchor; - com_addbyte(c, op); - here = c->c_nexti; - anchor = *p_anchor; - *p_anchor = here; - com_addint(c, anchor == 0 ? 0 : here - anchor); -} - -static void -com_backpatch(struct compiling *c, int anchor) -{ - unsigned char *code = (unsigned char *) PyString_AS_STRING(c->c_code); - int target = c->c_nexti; - int dist; - int prev; - for (;;) { - /* Make the JUMP instruction at anchor point to target */ - prev = code[anchor] + (code[anchor+1] << 8); - dist = target - (anchor+2); - code[anchor] = dist & 0xff; - dist >>= 8; - code[anchor+1] = dist; - dist >>= 8; - if (dist) { - com_error(c, PyExc_SystemError, - "com_backpatch: offset too large"); - break; - } - if (!prev) - break; - anchor -= prev; - } -} - -/* Handle literals and names uniformly */ - -static int -com_add(struct compiling *c, PyObject *list, PyObject *dict, PyObject *v) -{ - PyObject *w, *t, *np=NULL; - long n; - - t = Py_BuildValue("(OO)", v, v->ob_type); - if (t == NULL) - goto fail; - w = PyDict_GetItem(dict, t); - if (w != NULL) { - n = PyInt_AsLong(w); - } else { - n = PyList_Size(list); - np = PyInt_FromLong(n); - if (np == NULL) - goto fail; - if (PyList_Append(list, v) != 0) - goto fail; - if (PyDict_SetItem(dict, t, np) != 0) - goto fail; - Py_DECREF(np); - } - Py_DECREF(t); - return n; - fail: - Py_XDECREF(np); - Py_XDECREF(t); - c->c_errors++; - return 0; -} - -static int -com_addconst(struct compiling *c, PyObject *v) -{ - return com_add(c, c->c_consts, c->c_const_dict, v); -} - -static int -com_addname(struct compiling *c, PyObject *v) -{ - return com_add(c, c->c_names, c->c_name_dict, v); -} - -int -_Py_Mangle(char *p, char *name, char *buffer, size_t maxlen) -{ - /* Name mangling: __private becomes _classname__private. - This is independent from how the name is used. */ - size_t nlen, plen; - if (p == NULL || name == NULL || name[0] != '_' || name[1] != '_') - return 0; - nlen = strlen(name); - if (nlen+2 >= maxlen) - return 0; /* Don't mangle __extremely_long_names */ - if (name[nlen-1] == '_' && name[nlen-2] == '_') - return 0; /* Don't mangle __whatever__ */ - /* Strip leading underscores from class name */ - while (*p == '_') - p++; - if (*p == '\0') - return 0; /* Don't mangle if class is just underscores */ - plen = strlen(p); - if (plen + nlen >= maxlen) - plen = maxlen-nlen-2; /* Truncate class name if too long */ - /* buffer = "_" + p[:plen] + name # i.e. 1+plen+nlen bytes */ - buffer[0] = '_'; - strncpy(buffer+1, p, plen); - strcpy(buffer+1+plen, name); - return 1; -} - -static void -com_addop_name(struct compiling *c, int op, char *name) -{ - PyObject *v; - int i; - char buffer[MANGLE_LEN]; - - if (_Py_Mangle(c->c_private, name, buffer, sizeof(buffer))) - name = buffer; - if (name == NULL || (v = PyString_InternFromString(name)) == NULL) { - c->c_errors++; - i = 255; - } - else { - i = com_addname(c, v); - Py_DECREF(v); - } - com_addoparg(c, op, i); -} - -#define NAME_LOCAL 0 -#define NAME_GLOBAL 1 -#define NAME_DEFAULT 2 -#define NAME_CLOSURE 3 - -static int -com_lookup_arg(PyObject *dict, PyObject *name) -{ - PyObject *v = PyDict_GetItem(dict, name); - if (v == NULL) - return -1; - else - return PyInt_AS_LONG(v); -} - -static int -none_assignment_check(struct compiling *c, char *name, int assigning) -{ - if (name[0] == 'N' && strcmp(name, "None") == 0) { - char *msg; - if (assigning) - msg = "assignment to None"; - else - msg = "deleting None"; - if (issue_warning(msg, c->c_filename, c->c_lineno) < 0) { - c->c_errors++; - return -1; - } - } - return 0; -} - -static void -com_addop_varname(struct compiling *c, int kind, char *name) -{ - PyObject *v; - int i, reftype; - int scope = NAME_DEFAULT; - int op = STOP_CODE; - char buffer[MANGLE_LEN]; - - if (kind != VAR_LOAD && - none_assignment_check(c, name, kind == VAR_STORE)) - { - c->c_errors++; - i = 255; - goto done; - } - if (_Py_Mangle(c->c_private, name, buffer, sizeof(buffer))) - name = buffer; - if (name == NULL || (v = PyString_InternFromString(name)) == NULL) { - c->c_errors++; - i = 255; - goto done; - } - - reftype = get_ref_type(c, name); - switch (reftype) { - case LOCAL: - if (c->c_symtable->st_cur->ste_type == TYPE_FUNCTION) - scope = NAME_LOCAL; - break; - case GLOBAL_EXPLICIT: - scope = NAME_GLOBAL; - break; - case GLOBAL_IMPLICIT: - if (c->c_flags & CO_OPTIMIZED) - scope = NAME_GLOBAL; - break; - case FREE: - case CELL: - scope = NAME_CLOSURE; - break; - } - - i = com_addname(c, v); - if (scope == NAME_LOCAL) - i = com_lookup_arg(c->c_locals, v); - else if (reftype == FREE) - i = com_lookup_arg(c->c_freevars, v); - else if (reftype == CELL) - i = com_lookup_arg(c->c_cellvars, v); - if (i == -1) { - c->c_errors++; /* XXX no exception set */ - i = 255; - goto done; - } - Py_DECREF(v); - - switch (kind) { - case VAR_LOAD: - switch (scope) { - case NAME_LOCAL: - op = LOAD_FAST; - break; - case NAME_GLOBAL: - op = LOAD_GLOBAL; - break; - case NAME_DEFAULT: - op = LOAD_NAME; - break; - case NAME_CLOSURE: - op = LOAD_DEREF; - break; - } - break; - case VAR_STORE: - switch (scope) { - case NAME_LOCAL: - op = STORE_FAST; - break; - case NAME_GLOBAL: - op = STORE_GLOBAL; - break; - case NAME_DEFAULT: - op = STORE_NAME; - break; - case NAME_CLOSURE: - op = STORE_DEREF; - break; - } - break; - case VAR_DELETE: - switch (scope) { - case NAME_LOCAL: - op = DELETE_FAST; - break; - case NAME_GLOBAL: - op = DELETE_GLOBAL; - break; - case NAME_DEFAULT: - op = DELETE_NAME; - break; - case NAME_CLOSURE: { - char buf[500]; - PyOS_snprintf(buf, sizeof(buf), - DEL_CLOSURE_ERROR, name); - com_error(c, PyExc_SyntaxError, buf); - i = 255; - break; - } - } - break; - } -done: - com_addoparg(c, op, i); -} - -static void -com_addopname(struct compiling *c, int op, node *n) -{ - char *name; - char buffer[1000]; - /* XXX it is possible to write this code without the 1000 - chars on the total length of dotted names, I just can't be - bothered right now */ - if (TYPE(n) == STAR) - name = "*"; - else if (TYPE(n) == dotted_name) { - char *p = buffer; - int i; - name = buffer; - for (i = 0; i < NCH(n); i += 2) { - char *s = STR(CHILD(n, i)); - if (p + strlen(s) > buffer + (sizeof buffer) - 2) { - com_error(c, PyExc_MemoryError, - "dotted_name too long"); - name = NULL; - break; - } - if (p != buffer) - *p++ = '.'; - strcpy(p, s); - p = strchr(p, '\0'); - } - } - else { - REQ(n, NAME); - name = STR(n); - } - com_addop_name(c, op, name); -} - -static PyObject * -parsenumber(struct compiling *c, char *s) -{ - char *end; - long x; - double dx; -#ifndef WITHOUT_COMPLEX - int imflag; -#endif - - errno = 0; - end = s + strlen(s) - 1; -#ifndef WITHOUT_COMPLEX - imflag = *end == 'j' || *end == 'J'; -#endif - if (*end == 'l' || *end == 'L') - return PyLong_FromString(s, (char **)0, 0); - if (s[0] == '0') { - x = (long) PyOS_strtoul(s, &end, 0); - if (x < 0 && errno == 0) { - if (PyErr_WarnExplicit( - PyExc_FutureWarning, - "hex/oct constants > sys.maxint " - "will return positive values " - "in Python 2.4 and up", - /* XXX: Give WarnExplicit - a const char* argument. */ - (char*)c->c_filename, - c->c_lineno, - NULL, - NULL) < 0) - return NULL; - errno = 0; /* Might be changed by PyErr_Warn() */ - } - } - else - x = PyOS_strtol(s, &end, 0); - if (*end == '\0') { - if (errno != 0) - return PyLong_FromString(s, (char **)0, 0); - return PyInt_FromLong(x); - } - /* XXX Huge floats may silently fail */ -#ifndef WITHOUT_COMPLEX - if (imflag) { - Py_complex z; - z.real = 0.; - PyFPE_START_PROTECT("atof", return 0) - z.imag = atof(s); - PyFPE_END_PROTECT(z) - return PyComplex_FromCComplex(z); - } - else -#endif - { - PyFPE_START_PROTECT("atof", return 0) - dx = atof(s); - PyFPE_END_PROTECT(dx) - return PyFloat_FromDouble(dx); - } -} - -static PyObject * -decode_utf8(char **sPtr, char *end, char* encoding) -{ -#ifndef Py_USING_UNICODE - Py_FatalError("decode_utf8 should not be called in this build."); - return NULL; -#else - PyObject *u, *v; - char *s, *t; - t = s = *sPtr; - /* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */ - while (s < end && (*s & 0x80)) s++; - *sPtr = s; - u = PyUnicode_DecodeUTF8(t, s - t, NULL); - if (u == NULL) - return NULL; - v = PyUnicode_AsEncodedString(u, encoding, NULL); - Py_DECREF(u); - return v; -#endif -} - -/* compiler.transformer.Transformer.decode_literal depends on what - might seem like minor details of this function -- changes here - must be reflected there. */ -static PyObject * -parsestr(struct compiling *c, char *s) -{ - PyObject *v; - size_t len; - int quote = *s; - int rawmode = 0; - char* encoding = ((c == NULL) ? NULL : c->c_encoding); - int need_encoding; - int unicode = 0; - - if (isalpha(quote) || quote == '_') { - if (quote == 'u' || quote == 'U') { - quote = *++s; - unicode = 1; - } - if (quote == 'r' || quote == 'R') { - quote = *++s; - rawmode = 1; - } - } - if (quote != '\'' && quote != '\"') { - PyErr_BadInternalCall(); - return NULL; - } - s++; - len = strlen(s); - if (len > INT_MAX) { - com_error(c, PyExc_OverflowError, - "string to parse is too long"); - return NULL; - } - if (s[--len] != quote) { - PyErr_BadInternalCall(); - return NULL; - } - if (len >= 4 && s[0] == quote && s[1] == quote) { - s += 2; - len -= 2; - if (s[--len] != quote || s[--len] != quote) { - PyErr_BadInternalCall(); - return NULL; - } - } -#ifdef Py_USING_UNICODE - if (unicode || Py_UnicodeFlag) { - PyObject *u, *w; - char *buf; - char *p; - char *end; - if (encoding == NULL) { - buf = s; - u = NULL; - } else if (strcmp(encoding, "iso-8859-1") == 0) { - buf = s; - u = NULL; - } else { - /* "\XX" may become "\u005c\uHHLL" (12 bytes) */ - u = PyString_FromStringAndSize((char *)NULL, len * 4); - if (u == NULL) - return NULL; - p = buf = PyString_AsString(u); - end = s + len; - while (s < end) { - if (*s == '\\') { - *p++ = *s++; - if (*s & 0x80) { - strcpy(p, "u005c"); - p += 5; - } - } - if (*s & 0x80) { /* XXX inefficient */ - char *r; - int rn, i; - w = decode_utf8(&s, end, "utf-16-be"); - if (w == NULL) { - Py_DECREF(u); - return NULL; - } - r = PyString_AsString(w); - rn = PyString_Size(w); - assert(rn % 2 == 0); - for (i = 0; i < rn; i += 2) { - sprintf(p, "\\u%02x%02x", - r[i + 0] & 0xFF, - r[i + 1] & 0xFF); - p += 6; - } - Py_DECREF(w); - } else { - *p++ = *s++; - } - } - len = p - buf; - } - if (rawmode) - v = PyUnicode_DecodeRawUnicodeEscape(buf, len, NULL); - else - v = PyUnicode_DecodeUnicodeEscape(buf, len, NULL); - Py_XDECREF(u); - if (v == NULL) - PyErr_SyntaxLocation(c->c_filename, c->c_lineno); - return v; - - } -#endif - need_encoding = (encoding != NULL && - strcmp(encoding, "utf-8") != 0 && - strcmp(encoding, "iso-8859-1") != 0); - if (rawmode || strchr(s, '\\') == NULL) { - if (need_encoding) { -#ifndef Py_USING_UNICODE - /* This should not happen - we never see any other - encoding. */ - Py_FatalError("cannot deal with encodings in this build."); -#else - PyObject* u = PyUnicode_DecodeUTF8(s, len, NULL); - if (u == NULL) - return NULL; - v = PyUnicode_AsEncodedString(u, encoding, NULL); - Py_DECREF(u); - return v; -#endif - } else { - return PyString_FromStringAndSize(s, len); - } - } - - v = PyString_DecodeEscape(s, len, NULL, unicode, - need_encoding ? encoding : NULL); - if (v == NULL) - PyErr_SyntaxLocation(c->c_filename, c->c_lineno); - return v; -} - -static PyObject * -parsestrplus(struct compiling* c, node *n) -{ - PyObject *v; - int i; - REQ(CHILD(n, 0), STRING); - if ((v = parsestr(c, STR(CHILD(n, 0)))) != NULL) { - /* String literal concatenation */ - for (i = 1; i < NCH(n); i++) { - PyObject *s; - s = parsestr(c, STR(CHILD(n, i))); - if (s == NULL) - goto onError; - if (PyString_Check(v) && PyString_Check(s)) { - PyString_ConcatAndDel(&v, s); - if (v == NULL) - goto onError; - } -#ifdef Py_USING_UNICODE - else { - PyObject *temp; - temp = PyUnicode_Concat(v, s); - Py_DECREF(s); - if (temp == NULL) - goto onError; - Py_DECREF(v); - v = temp; - } -#endif - } - } - return v; - - onError: - Py_XDECREF(v); - return NULL; -} - -static void -com_list_for(struct compiling *c, node *n, node *e, char *t) -{ - int anchor = 0; - int save_begin = c->c_begin; - - /* list_iter: for v in expr [list_iter] */ - com_node(c, CHILD(n, 3)); /* expr */ - com_addbyte(c, GET_ITER); - c->c_begin = c->c_nexti; - com_addfwref(c, FOR_ITER, &anchor); - com_push(c, 1); - com_assign(c, CHILD(n, 1), OP_ASSIGN, NULL); - c->c_loops++; - com_list_iter(c, n, e, t); - c->c_loops--; - com_addoparg(c, JUMP_ABSOLUTE, c->c_begin); - c->c_begin = save_begin; - com_backpatch(c, anchor); - com_pop(c, 1); /* FOR_ITER has popped this */ -} - -static void -com_list_if(struct compiling *c, node *n, node *e, char *t) -{ - int anchor = 0; - int a = 0; - /* list_iter: 'if' test [list_iter] */ - com_node(c, CHILD(n, 1)); - com_addfwref(c, JUMP_IF_FALSE, &a); - com_addbyte(c, POP_TOP); - com_pop(c, 1); - com_list_iter(c, n, e, t); - com_addfwref(c, JUMP_FORWARD, &anchor); - com_backpatch(c, a); - /* We jump here with an extra entry which we now pop */ - com_addbyte(c, POP_TOP); - com_backpatch(c, anchor); -} - -static void -com_list_iter(struct compiling *c, - node *p, /* parent of list_iter node */ - node *e, /* element expression node */ - char *t /* name of result list temp local */) -{ - /* list_iter is the last child in a listmaker, list_for, or list_if */ - node *n = CHILD(p, NCH(p)-1); - if (TYPE(n) == list_iter) { - n = CHILD(n, 0); - switch (TYPE(n)) { - case list_for: - com_list_for(c, n, e, t); - break; - case list_if: - com_list_if(c, n, e, t); - break; - default: - com_error(c, PyExc_SystemError, - "invalid list_iter node type"); - } - } - else { - com_addop_varname(c, VAR_LOAD, t); - com_push(c, 1); - com_node(c, e); - com_addoparg(c, CALL_FUNCTION, 1); - com_addbyte(c, POP_TOP); - com_pop(c, 2); - } -} - -static void -com_list_comprehension(struct compiling *c, node *n) -{ - /* listmaker: test list_for */ - char tmpname[30]; - - REQ(n, listmaker); - PyOS_snprintf(tmpname, sizeof(tmpname), "_[%d]", ++c->c_tmpname); - com_addoparg(c, BUILD_LIST, 0); - com_addbyte(c, DUP_TOP); /* leave the result on the stack */ - com_push(c, 2); - com_addop_name(c, LOAD_ATTR, "append"); - com_addop_varname(c, VAR_STORE, tmpname); - com_pop(c, 1); - com_list_for(c, CHILD(n, 1), CHILD(n, 0), tmpname); - com_addop_varname(c, VAR_DELETE, tmpname); - --c->c_tmpname; -} - -static void -com_listmaker(struct compiling *c, node *n) -{ - /* listmaker: test ( list_for | (',' test)* [','] ) */ - if (NCH(n) > 1 && TYPE(CHILD(n, 1)) == list_for) - com_list_comprehension(c, n); - else { - int len = 0; - int i; - for (i = 0; i < NCH(n); i += 2, len++) - com_node(c, CHILD(n, i)); - com_addoparg(c, BUILD_LIST, len); - com_pop(c, len-1); - } -} - -static void -com_dictmaker(struct compiling *c, node *n) -{ - int i; - /* dictmaker: test ':' test (',' test ':' value)* [','] */ - for (i = 0; i+2 < NCH(n); i += 4) { - /* We must arrange things just right for STORE_SUBSCR. - It wants the stack to look like (value) (dict) (key) */ - com_addbyte(c, DUP_TOP); - com_push(c, 1); - com_node(c, CHILD(n, i)); /* key */ - com_node(c, CHILD(n, i+2)); /* value */ - com_addbyte(c, ROT_THREE); - com_addbyte(c, STORE_SUBSCR); - com_pop(c, 3); - } -} - -static void -com_atom(struct compiling *c, node *n) -{ - node *ch; - PyObject *v; - int i; - REQ(n, atom); - ch = CHILD(n, 0); - switch (TYPE(ch)) { - case LPAR: - if (TYPE(CHILD(n, 1)) == RPAR) { - com_addoparg(c, BUILD_TUPLE, 0); - com_push(c, 1); - } - else - com_node(c, CHILD(n, 1)); - break; - case LSQB: /* '[' [listmaker] ']' */ - if (TYPE(CHILD(n, 1)) == RSQB) { - com_addoparg(c, BUILD_LIST, 0); - com_push(c, 1); - } - else - com_listmaker(c, CHILD(n, 1)); - break; - case LBRACE: /* '{' [dictmaker] '}' */ - com_addoparg(c, BUILD_MAP, 0); - com_push(c, 1); - if (TYPE(CHILD(n, 1)) == dictmaker) - com_dictmaker(c, CHILD(n, 1)); - break; - case BACKQUOTE: - com_node(c, CHILD(n, 1)); - com_addbyte(c, UNARY_CONVERT); - break; - case NUMBER: - if ((v = parsenumber(c, STR(ch))) == NULL) { - i = 255; - } - else { - i = com_addconst(c, v); - Py_DECREF(v); - } - com_addoparg(c, LOAD_CONST, i); - com_push(c, 1); - break; - case STRING: - v = parsestrplus(c, n); - if (v == NULL) { - c->c_errors++; - i = 255; - } - else { - i = com_addconst(c, v); - Py_DECREF(v); - } - com_addoparg(c, LOAD_CONST, i); - com_push(c, 1); - break; - case NAME: - com_addop_varname(c, VAR_LOAD, STR(ch)); - com_push(c, 1); - break; - default: - com_error(c, PyExc_SystemError, - "com_atom: unexpected node type"); - } -} - -static void -com_slice(struct compiling *c, node *n, int op) -{ - if (NCH(n) == 1) { - com_addbyte(c, op); - } - else if (NCH(n) == 2) { - if (TYPE(CHILD(n, 0)) != COLON) { - com_node(c, CHILD(n, 0)); - com_addbyte(c, op+1); - } - else { - com_node(c, CHILD(n, 1)); - com_addbyte(c, op+2); - } - com_pop(c, 1); - } - else { - com_node(c, CHILD(n, 0)); - com_node(c, CHILD(n, 2)); - com_addbyte(c, op+3); - com_pop(c, 2); - } -} - -static void -com_augassign_slice(struct compiling *c, node *n, int opcode, node *augn) -{ - if (NCH(n) == 1) { - com_addbyte(c, DUP_TOP); - com_push(c, 1); - com_addbyte(c, SLICE); - com_node(c, augn); - com_addbyte(c, opcode); - com_pop(c, 1); - com_addbyte(c, ROT_TWO); - com_addbyte(c, STORE_SLICE); - com_pop(c, 2); - } else if (NCH(n) == 2 && TYPE(CHILD(n, 0)) != COLON) { - com_node(c, CHILD(n, 0)); - com_addoparg(c, DUP_TOPX, 2); - com_push(c, 2); - com_addbyte(c, SLICE+1); - com_pop(c, 1); - com_node(c, augn); - com_addbyte(c, opcode); - com_pop(c, 1); - com_addbyte(c, ROT_THREE); - com_addbyte(c, STORE_SLICE+1); - com_pop(c, 3); - } else if (NCH(n) == 2) { - com_node(c, CHILD(n, 1)); - com_addoparg(c, DUP_TOPX, 2); - com_push(c, 2); - com_addbyte(c, SLICE+2); - com_pop(c, 1); - com_node(c, augn); - com_addbyte(c, opcode); - com_pop(c, 1); - com_addbyte(c, ROT_THREE); - com_addbyte(c, STORE_SLICE+2); - com_pop(c, 3); - } else { - com_node(c, CHILD(n, 0)); - com_node(c, CHILD(n, 2)); - com_addoparg(c, DUP_TOPX, 3); - com_push(c, 3); - com_addbyte(c, SLICE+3); - com_pop(c, 2); - com_node(c, augn); - com_addbyte(c, opcode); - com_pop(c, 1); - com_addbyte(c, ROT_FOUR); - com_addbyte(c, STORE_SLICE+3); - com_pop(c, 4); - } -} - -static void -com_argument(struct compiling *c, node *n, PyObject **pkeywords) -{ - node *m; - REQ(n, argument); /* [test '='] test; really [keyword '='] test */ - if (NCH(n) == 1) { - if (*pkeywords != NULL) { - com_error(c, PyExc_SyntaxError, - "non-keyword arg after keyword arg"); - } - else { - com_node(c, CHILD(n, 0)); - } - return; - } - m = n; - do { - m = CHILD(m, 0); - } while (NCH(m) == 1); - if (TYPE(m) != NAME) { - /* f(lambda x: x[0] = 3) ends up getting parsed with - * LHS test = lambda x: x[0], and RHS test = 3. - * SF bug 132313 points out that complaining about a keyword - * then is very confusing. - */ - com_error(c, PyExc_SyntaxError, - TYPE(m) == lambdef ? - "lambda cannot contain assignment" : - "keyword can't be an expression"); - } - else { - PyObject *v = PyString_InternFromString(STR(m)); - (void) none_assignment_check(c, STR(m), 1); - if (v != NULL && *pkeywords == NULL) - *pkeywords = PyDict_New(); - if (v == NULL) - c->c_errors++; - else if (*pkeywords == NULL) { - c->c_errors++; - Py_DECREF(v); - } else { - if (PyDict_GetItem(*pkeywords, v) != NULL) - com_error(c, PyExc_SyntaxError, - "duplicate keyword argument"); - else - if (PyDict_SetItem(*pkeywords, v, v) != 0) - c->c_errors++; - com_addoparg(c, LOAD_CONST, com_addconst(c, v)); - com_push(c, 1); - Py_DECREF(v); - } - } - com_node(c, CHILD(n, 2)); -} - -static void -com_call_function(struct compiling *c, node *n) -{ - if (TYPE(n) == RPAR) { - com_addoparg(c, CALL_FUNCTION, 0); - } - else { - PyObject *keywords = NULL; - int i, na, nk; - int lineno = n->n_lineno; - int star_flag = 0; - int starstar_flag = 0; - int opcode; - REQ(n, arglist); - na = 0; - nk = 0; - for (i = 0; i < NCH(n); i += 2) { - node *ch = CHILD(n, i); - if (TYPE(ch) == STAR || - TYPE(ch) == DOUBLESTAR) - break; - if (ch->n_lineno != lineno) { - lineno = ch->n_lineno; - com_set_lineno(c, lineno); - } - com_argument(c, ch, &keywords); - if (keywords == NULL) - na++; - else - nk++; - } - Py_XDECREF(keywords); - while (i < NCH(n)) { - node *tok = CHILD(n, i); - node *ch = CHILD(n, i+1); - i += 3; - switch (TYPE(tok)) { - case STAR: star_flag = 1; break; - case DOUBLESTAR: starstar_flag = 1; break; - } - com_node(c, ch); - } - if (na > 255 || nk > 255) { - com_error(c, PyExc_SyntaxError, - "more than 255 arguments"); - } - if (star_flag || starstar_flag) - opcode = CALL_FUNCTION_VAR - 1 + - star_flag + (starstar_flag << 1); - else - opcode = CALL_FUNCTION; - com_addoparg(c, opcode, na | (nk << 8)); - com_pop(c, na + 2*nk + star_flag + starstar_flag); - } -} - -static void -com_select_member(struct compiling *c, node *n) -{ - com_addopname(c, LOAD_ATTR, n); -} - -static void -com_sliceobj(struct compiling *c, node *n) -{ - int i=0; - int ns=2; /* number of slice arguments */ - node *ch; - - /* first argument */ - if (TYPE(CHILD(n,i)) == COLON) { - com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None)); - com_push(c, 1); - i++; - } - else { - com_node(c, CHILD(n,i)); - i++; - REQ(CHILD(n,i),COLON); - i++; - } - /* second argument */ - if (i < NCH(n) && TYPE(CHILD(n,i)) == test) { - com_node(c, CHILD(n,i)); - i++; - } - else { - com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None)); - com_push(c, 1); - } - /* remaining arguments */ - for (; i < NCH(n); i++) { - ns++; - ch=CHILD(n,i); - REQ(ch, sliceop); - if (NCH(ch) == 1) { - /* right argument of ':' missing */ - com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None)); - com_push(c, 1); - } - else - com_node(c, CHILD(ch,1)); - } - com_addoparg(c, BUILD_SLICE, ns); - com_pop(c, 1 + (ns == 3)); -} - -static void -com_subscript(struct compiling *c, node *n) -{ - node *ch; - REQ(n, subscript); - ch = CHILD(n,0); - /* check for rubber index */ - if (TYPE(ch) == DOT && TYPE(CHILD(n,1)) == DOT) { - com_addoparg(c, LOAD_CONST, com_addconst(c, Py_Ellipsis)); - com_push(c, 1); - } - else { - /* check for slice */ - if ((TYPE(ch) == COLON || NCH(n) > 1)) - com_sliceobj(c, n); - else { - REQ(ch, test); - com_node(c, ch); - } - } -} - -static void -com_subscriptlist(struct compiling *c, node *n, int assigning, node *augn) -{ - int i, op; - REQ(n, subscriptlist); - /* Check to make backward compatible slice behavior for '[i:j]' */ - if (NCH(n) == 1) { - node *sub = CHILD(n, 0); /* subscript */ - /* 'Basic' slice, should have exactly one colon. */ - if ((TYPE(CHILD(sub, 0)) == COLON - || (NCH(sub) > 1 && TYPE(CHILD(sub, 1)) == COLON)) - && (TYPE(CHILD(sub,NCH(sub)-1)) != sliceop)) - { - switch (assigning) { - case OP_DELETE: - op = DELETE_SLICE; - break; - case OP_ASSIGN: - op = STORE_SLICE; - break; - case OP_APPLY: - op = SLICE; - break; - default: - com_augassign_slice(c, sub, assigning, augn); - return; - } - com_slice(c, sub, op); - if (op == STORE_SLICE) - com_pop(c, 2); - else if (op == DELETE_SLICE) - com_pop(c, 1); - return; - } - } - /* Else normal subscriptlist. Compile each subscript. */ - for (i = 0; i < NCH(n); i += 2) - com_subscript(c, CHILD(n, i)); - /* Put multiple subscripts into a tuple */ - if (NCH(n) > 1) { - i = (NCH(n)+1) / 2; - com_addoparg(c, BUILD_TUPLE, i); - com_pop(c, i-1); - } - switch (assigning) { - case OP_DELETE: - op = DELETE_SUBSCR; - i = 2; - break; - default: - case OP_ASSIGN: - op = STORE_SUBSCR; - i = 3; - break; - case OP_APPLY: - op = BINARY_SUBSCR; - i = 1; - break; - } - if (assigning > OP_APPLY) { - com_addoparg(c, DUP_TOPX, 2); - com_push(c, 2); - com_addbyte(c, BINARY_SUBSCR); - com_pop(c, 1); - com_node(c, augn); - com_addbyte(c, assigning); - com_pop(c, 1); - com_addbyte(c, ROT_THREE); - } - com_addbyte(c, op); - com_pop(c, i); -} - -static void -com_apply_trailer(struct compiling *c, node *n) -{ - REQ(n, trailer); - switch (TYPE(CHILD(n, 0))) { - case LPAR: - com_call_function(c, CHILD(n, 1)); - break; - case DOT: - com_select_member(c, CHILD(n, 1)); - break; - case LSQB: - com_subscriptlist(c, CHILD(n, 1), OP_APPLY, NULL); - break; - default: - com_error(c, PyExc_SystemError, - "com_apply_trailer: unknown trailer type"); - } -} - -static void -com_power(struct compiling *c, node *n) -{ - int i; - REQ(n, power); - com_atom(c, CHILD(n, 0)); - for (i = 1; i < NCH(n); i++) { - if (TYPE(CHILD(n, i)) == DOUBLESTAR) { - com_factor(c, CHILD(n, i+1)); - com_addbyte(c, BINARY_POWER); - com_pop(c, 1); - break; - } - else - com_apply_trailer(c, CHILD(n, i)); - } -} - -static void -com_invert_constant(struct compiling *c, node *n) -{ - /* Compute the inverse of int and longs and use them directly, - but be prepared to generate code for all other - possibilities (invalid numbers, floats, complex). - */ - PyObject *num, *inv = NULL; - int i; - - REQ(n, NUMBER); - num = parsenumber(c, STR(n)); - if (num == NULL) - i = 255; - else { - inv = PyNumber_Invert(num); - if (inv == NULL) { - PyErr_Clear(); - i = com_addconst(c, num); - } else { - i = com_addconst(c, inv); - Py_DECREF(inv); - } - Py_DECREF(num); - } - com_addoparg(c, LOAD_CONST, i); - com_push(c, 1); - if (num != NULL && inv == NULL) - com_addbyte(c, UNARY_INVERT); -} - -static int -is_float_zero(const char *p) -{ - int found_radix_point = 0; - int ch; - while ((ch = Py_CHARMASK(*p++)) != '\0') { - switch (ch) { - case '0': - /* no reason to believe it's not 0 -- continue */ - break; - - case 'e': case 'E': case 'j': case 'J': - /* If this was a hex constant, we already would have - returned 0 due to the 'x' or 'X', so 'e' or 'E' - must be an exponent marker, and we haven't yet - seen a non-zero digit, and it doesn't matter what - the exponent is then. For 'j' or 'J' similarly, - except that this is an imaginary 0 then. */ - return 1; - - case '.': - found_radix_point = 1; - break; - - default: - return 0; - } - } - return found_radix_point; -} - -static void -com_factor(struct compiling *c, node *n) -{ - int childtype = TYPE(CHILD(n, 0)); - node *pfactor, *ppower, *patom, *pnum; - REQ(n, factor); - /* If the unary +, -, or ~ operator is applied to a constant, - don't generate a UNARY_xxx opcode. Just store the - approriate value as a constant. If the value is negative, - extend the string containing the constant and insert a - negative in the 0th position -- unless we're doing unary minus - of a floating zero! In that case the sign is significant, but - the const dict can't distinguish +0.0 from -0.0. - */ - if ((childtype == PLUS || childtype == MINUS || childtype == TILDE) - && NCH(n) == 2 - && TYPE((pfactor = CHILD(n, 1))) == factor - && NCH(pfactor) == 1 - && TYPE((ppower = CHILD(pfactor, 0))) == power - && NCH(ppower) == 1 - && TYPE((patom = CHILD(ppower, 0))) == atom - && TYPE((pnum = CHILD(patom, 0))) == NUMBER - && !(childtype == MINUS && - (STR(pnum)[0] == '0' || is_float_zero(STR(pnum))))) { - if (childtype == TILDE) { - com_invert_constant(c, pnum); - return; - } - if (childtype == MINUS) { - char *s = PyObject_MALLOC(strlen(STR(pnum)) + 2); - if (s == NULL) { - com_error(c, PyExc_MemoryError, ""); - com_addbyte(c, 255); - return; - } - s[0] = '-'; - strcpy(s + 1, STR(pnum)); - PyObject_FREE(STR(pnum)); - STR(pnum) = s; - } - com_atom(c, patom); - } - else if (childtype == PLUS) { - com_factor(c, CHILD(n, 1)); - com_addbyte(c, UNARY_POSITIVE); - } - else if (childtype == MINUS) { - com_factor(c, CHILD(n, 1)); - com_addbyte(c, UNARY_NEGATIVE); - } - else if (childtype == TILDE) { - com_factor(c, CHILD(n, 1)); - com_addbyte(c, UNARY_INVERT); - } - else { - com_power(c, CHILD(n, 0)); - } -} - -static void -com_term(struct compiling *c, node *n) -{ - int i; - int op; - REQ(n, term); - com_factor(c, CHILD(n, 0)); - for (i = 2; i < NCH(n); i += 2) { - com_factor(c, CHILD(n, i)); - switch (TYPE(CHILD(n, i-1))) { - case STAR: - op = BINARY_MULTIPLY; - break; - case SLASH: - if (c->c_flags & CO_FUTURE_DIVISION) - op = BINARY_TRUE_DIVIDE; - else - op = BINARY_DIVIDE; - break; - case PERCENT: - op = BINARY_MODULO; - break; - case DOUBLESLASH: - op = BINARY_FLOOR_DIVIDE; - break; - default: - com_error(c, PyExc_SystemError, - "com_term: operator not *, /, // or %"); - op = 255; - } - com_addbyte(c, op); - com_pop(c, 1); - } -} - -static void -com_arith_expr(struct compiling *c, node *n) -{ - int i; - int op; - REQ(n, arith_expr); - com_term(c, CHILD(n, 0)); - for (i = 2; i < NCH(n); i += 2) { - com_term(c, CHILD(n, i)); - switch (TYPE(CHILD(n, i-1))) { - case PLUS: - op = BINARY_ADD; - break; - case MINUS: - op = BINARY_SUBTRACT; - break; - default: - com_error(c, PyExc_SystemError, - "com_arith_expr: operator not + or -"); - op = 255; - } - com_addbyte(c, op); - com_pop(c, 1); - } -} - -static void -com_shift_expr(struct compiling *c, node *n) -{ - int i; - int op; - REQ(n, shift_expr); - com_arith_expr(c, CHILD(n, 0)); - for (i = 2; i < NCH(n); i += 2) { - com_arith_expr(c, CHILD(n, i)); - switch (TYPE(CHILD(n, i-1))) { - case LEFTSHIFT: - op = BINARY_LSHIFT; - break; - case RIGHTSHIFT: - op = BINARY_RSHIFT; - break; - default: - com_error(c, PyExc_SystemError, - "com_shift_expr: operator not << or >>"); - op = 255; - } - com_addbyte(c, op); - com_pop(c, 1); - } -} - -static void -com_and_expr(struct compiling *c, node *n) -{ - int i; - int op; - REQ(n, and_expr); - com_shift_expr(c, CHILD(n, 0)); - for (i = 2; i < NCH(n); i += 2) { - com_shift_expr(c, CHILD(n, i)); - if (TYPE(CHILD(n, i-1)) == AMPER) { - op = BINARY_AND; - } - else { - com_error(c, PyExc_SystemError, - "com_and_expr: operator not &"); - op = 255; - } - com_addbyte(c, op); - com_pop(c, 1); - } -} - -static void -com_xor_expr(struct compiling *c, node *n) -{ - int i; - int op; - REQ(n, xor_expr); - com_and_expr(c, CHILD(n, 0)); - for (i = 2; i < NCH(n); i += 2) { - com_and_expr(c, CHILD(n, i)); - if (TYPE(CHILD(n, i-1)) == CIRCUMFLEX) { - op = BINARY_XOR; - } - else { - com_error(c, PyExc_SystemError, - "com_xor_expr: operator not ^"); - op = 255; - } - com_addbyte(c, op); - com_pop(c, 1); - } -} - -static void -com_expr(struct compiling *c, node *n) -{ - int i; - int op; - REQ(n, expr); - com_xor_expr(c, CHILD(n, 0)); - for (i = 2; i < NCH(n); i += 2) { - com_xor_expr(c, CHILD(n, i)); - if (TYPE(CHILD(n, i-1)) == VBAR) { - op = BINARY_OR; - } - else { - com_error(c, PyExc_SystemError, - "com_expr: expr operator not |"); - op = 255; - } - com_addbyte(c, op); - com_pop(c, 1); - } -} - -static enum cmp_op -cmp_type(node *n) -{ - REQ(n, comp_op); - /* comp_op: '<' | '>' | '>=' | '<=' | '<>' | '!=' | '==' - | 'in' | 'not' 'in' | 'is' | 'is' not' */ - if (NCH(n) == 1) { - n = CHILD(n, 0); - switch (TYPE(n)) { - case LESS: return PyCmp_LT; - case GREATER: return PyCmp_GT; - case EQEQUAL: return PyCmp_EQ; - case LESSEQUAL: return PyCmp_LE; - case GREATEREQUAL: return PyCmp_GE; - case NOTEQUAL: return PyCmp_NE; /* <> or != */ - case NAME: if (strcmp(STR(n), "in") == 0) return PyCmp_IN; - if (strcmp(STR(n), "is") == 0) return PyCmp_IS; - } - } - else if (NCH(n) == 2) { - switch (TYPE(CHILD(n, 0))) { - case NAME: if (strcmp(STR(CHILD(n, 1)), "in") == 0) - return PyCmp_NOT_IN; - if (strcmp(STR(CHILD(n, 0)), "is") == 0) - return PyCmp_IS_NOT; - } - } - return PyCmp_BAD; -} - -static void -com_comparison(struct compiling *c, node *n) -{ - int i; - enum cmp_op op; - int anchor; - REQ(n, comparison); /* comparison: expr (comp_op expr)* */ - com_expr(c, CHILD(n, 0)); - if (NCH(n) == 1) - return; - - /**************************************************************** - The following code is generated for all but the last - comparison in a chain: - - label: on stack: opcode: jump to: - - a - a, b DUP_TOP - a, b, b ROT_THREE - b, a, b COMPARE_OP - b, 0-or-1 JUMP_IF_FALSE L1 - b, 1 POP_TOP - b - - We are now ready to repeat this sequence for the next - comparison in the chain. - - For the last we generate: - - b - b, c COMPARE_OP - 0-or-1 - - If there were any jumps to L1 (i.e., there was more than one - comparison), we generate: - - 0-or-1 JUMP_FORWARD L2 - L1: b, 0 ROT_TWO - 0, b POP_TOP - 0 - L2: 0-or-1 - ****************************************************************/ - - anchor = 0; - - for (i = 2; i < NCH(n); i += 2) { - com_expr(c, CHILD(n, i)); - if (i+2 < NCH(n)) { - com_addbyte(c, DUP_TOP); - com_push(c, 1); - com_addbyte(c, ROT_THREE); - } - op = cmp_type(CHILD(n, i-1)); - if (op == PyCmp_BAD) { - com_error(c, PyExc_SystemError, - "com_comparison: unknown comparison op"); - } - com_addoparg(c, COMPARE_OP, op); - com_pop(c, 1); - if (i+2 < NCH(n)) { - com_addfwref(c, JUMP_IF_FALSE, &anchor); - com_addbyte(c, POP_TOP); - com_pop(c, 1); - } - } - - if (anchor) { - int anchor2 = 0; - com_addfwref(c, JUMP_FORWARD, &anchor2); - com_backpatch(c, anchor); - com_addbyte(c, ROT_TWO); - com_addbyte(c, POP_TOP); - com_backpatch(c, anchor2); - } -} - -static void -com_not_test(struct compiling *c, node *n) -{ - REQ(n, not_test); /* 'not' not_test | comparison */ - if (NCH(n) == 1) { - com_comparison(c, CHILD(n, 0)); - } - else { - com_not_test(c, CHILD(n, 1)); - com_addbyte(c, UNARY_NOT); - } -} - -static void -com_and_test(struct compiling *c, node *n) -{ - int i; - int anchor; - REQ(n, and_test); /* not_test ('and' not_test)* */ - anchor = 0; - i = 0; - for (;;) { - com_not_test(c, CHILD(n, i)); - if ((i += 2) >= NCH(n)) - break; - com_addfwref(c, JUMP_IF_FALSE, &anchor); - com_addbyte(c, POP_TOP); - com_pop(c, 1); - } - if (anchor) - com_backpatch(c, anchor); -} - -static int -com_make_closure(struct compiling *c, PyCodeObject *co) -{ - int i, free = PyCode_GetNumFree(co); - if (free == 0) - return 0; - for (i = 0; i < free; ++i) { - /* Bypass com_addop_varname because it will generate - LOAD_DEREF but LOAD_CLOSURE is needed. - */ - PyObject *name = PyTuple_GET_ITEM(co->co_freevars, i); - int arg, reftype; - - /* Special case: If a class contains a method with a - free variable that has the same name as a method, - the name will be considered free *and* local in the - class. It should be handled by the closure, as - well as by the normal name loookup logic. - */ - reftype = get_ref_type(c, PyString_AS_STRING(name)); - if (reftype == CELL) - arg = com_lookup_arg(c->c_cellvars, name); - else /* (reftype == FREE) */ - arg = com_lookup_arg(c->c_freevars, name); - if (arg == -1) { - fprintf(stderr, "lookup %s in %s %d %d\n" - "freevars of %s: %s\n", - PyObject_REPR(name), - c->c_name, - reftype, arg, - PyString_AS_STRING(co->co_name), - PyObject_REPR(co->co_freevars)); - Py_FatalError("com_make_closure()"); - } - com_addoparg(c, LOAD_CLOSURE, arg); - - } - com_push(c, free); - return 1; -} - -static void -com_test(struct compiling *c, node *n) -{ - REQ(n, test); /* and_test ('or' and_test)* | lambdef */ - if (NCH(n) == 1 && TYPE(CHILD(n, 0)) == lambdef) { - PyCodeObject *co; - int i, closure; - int ndefs = com_argdefs(c, CHILD(n, 0)); - symtable_enter_scope(c->c_symtable, "lambda", lambdef, - n->n_lineno); - co = icompile(CHILD(n, 0), c); - if (co == NULL) { - c->c_errors++; - return; - } - symtable_exit_scope(c->c_symtable); - i = com_addconst(c, (PyObject *)co); - closure = com_make_closure(c, co); - com_addoparg(c, LOAD_CONST, i); - com_push(c, 1); - if (closure) { - com_addoparg(c, MAKE_CLOSURE, ndefs); - com_pop(c, PyCode_GetNumFree(co)); - } else - com_addoparg(c, MAKE_FUNCTION, ndefs); - Py_DECREF(co); - com_pop(c, ndefs); - } - else { - int anchor = 0; - int i = 0; - for (;;) { - com_and_test(c, CHILD(n, i)); - if ((i += 2) >= NCH(n)) - break; - com_addfwref(c, JUMP_IF_TRUE, &anchor); - com_addbyte(c, POP_TOP); - com_pop(c, 1); - } - if (anchor) - com_backpatch(c, anchor); - } -} - -static void -com_list(struct compiling *c, node *n, int toplevel) -{ - /* exprlist: expr (',' expr)* [',']; likewise for testlist */ - if (NCH(n) == 1 && !toplevel) { - com_node(c, CHILD(n, 0)); - } - else { - int i; - int len; - len = (NCH(n) + 1) / 2; - for (i = 0; i < NCH(n); i += 2) - com_node(c, CHILD(n, i)); - com_addoparg(c, BUILD_TUPLE, len); - com_pop(c, len-1); - } -} - - -/* Begin of assignment compilation */ - - -static void -com_augassign_attr(struct compiling *c, node *n, int opcode, node *augn) -{ - com_addbyte(c, DUP_TOP); - com_push(c, 1); - com_addopname(c, LOAD_ATTR, n); - com_node(c, augn); - com_addbyte(c, opcode); - com_pop(c, 1); - com_addbyte(c, ROT_TWO); - com_addopname(c, STORE_ATTR, n); - com_pop(c, 2); -} - -static void -com_assign_attr(struct compiling *c, node *n, int assigning) -{ - if (none_assignment_check(c, STR(n), assigning)) - return; - com_addopname(c, assigning ? STORE_ATTR : DELETE_ATTR, n); - com_pop(c, assigning ? 2 : 1); -} - -static void -com_assign_trailer(struct compiling *c, node *n, int assigning, node *augn) -{ - REQ(n, trailer); - switch (TYPE(CHILD(n, 0))) { - case LPAR: /* '(' [exprlist] ')' */ - if (assigning == OP_DELETE) - com_error(c, PyExc_SyntaxError, - "can't delete function call"); - else - com_error(c, PyExc_SyntaxError, - "can't assign to function call"); - break; - case DOT: /* '.' NAME */ - if (assigning > OP_APPLY) - com_augassign_attr(c, CHILD(n, 1), assigning, augn); - else - com_assign_attr(c, CHILD(n, 1), assigning); - break; - case LSQB: /* '[' subscriptlist ']' */ - com_subscriptlist(c, CHILD(n, 1), assigning, augn); - break; - default: - com_error(c, PyExc_SystemError, "unknown trailer type"); - } -} - -static void -com_assign_sequence(struct compiling *c, node *n, int assigning) -{ - int i; - if (TYPE(n) != testlist && TYPE(n) != listmaker) - REQ(n, exprlist); - if (assigning) { - i = (NCH(n)+1)/2; - com_addoparg(c, UNPACK_SEQUENCE, i); - com_push(c, i-1); - } - for (i = 0; i < NCH(n); i += 2) - com_assign(c, CHILD(n, i), assigning, NULL); -} - -static void -com_augassign_name(struct compiling *c, node *n, int opcode, node *augn) -{ - REQ(n, NAME); - com_addop_varname(c, VAR_LOAD, STR(n)); - com_push(c, 1); - com_node(c, augn); - com_addbyte(c, opcode); - com_pop(c, 1); - com_assign_name(c, n, OP_ASSIGN); -} - -static void -com_assign_name(struct compiling *c, node *n, int assigning) -{ - REQ(n, NAME); - com_addop_varname(c, assigning ? VAR_STORE : VAR_DELETE, STR(n)); - if (assigning) - com_pop(c, 1); -} - -static void -com_assign(struct compiling *c, node *n, int assigning, node *augn) -{ - /* Loop to avoid trivial recursion */ - for (;;) { - switch (TYPE(n)) { - - case exprlist: - case testlist: - case testlist1: - if (NCH(n) > 1) { - if (assigning > OP_APPLY) { - com_error(c, PyExc_SyntaxError, - "augmented assign to tuple not possible"); - return; - } - com_assign_sequence(c, n, assigning); - return; - } - n = CHILD(n, 0); - break; - - case test: - case and_test: - case not_test: - case comparison: - case expr: - case xor_expr: - case and_expr: - case shift_expr: - case arith_expr: - case term: - case factor: - if (NCH(n) > 1) { - com_error(c, PyExc_SyntaxError, - "can't assign to operator"); - return; - } - n = CHILD(n, 0); - break; - - case power: /* atom trailer* ('**' power)* - ('+'|'-'|'~') factor | atom trailer* */ - if (TYPE(CHILD(n, 0)) != atom) { - com_error(c, PyExc_SyntaxError, - "can't assign to operator"); - return; - } - if (NCH(n) > 1) { /* trailer or exponent present */ - int i; - com_node(c, CHILD(n, 0)); - for (i = 1; i+1 < NCH(n); i++) { - if (TYPE(CHILD(n, i)) == DOUBLESTAR) { - com_error(c, PyExc_SyntaxError, - "can't assign to operator"); - return; - } - com_apply_trailer(c, CHILD(n, i)); - } /* NB i is still alive */ - com_assign_trailer(c, - CHILD(n, i), assigning, augn); - return; - } - n = CHILD(n, 0); - break; - - case atom: - switch (TYPE(CHILD(n, 0))) { - case LPAR: - n = CHILD(n, 1); - if (TYPE(n) == RPAR) { - /* XXX Should allow () = () ??? */ - com_error(c, PyExc_SyntaxError, - "can't assign to ()"); - return; - } - if (assigning > OP_APPLY) { - com_error(c, PyExc_SyntaxError, - "augmented assign to tuple literal not possible"); - return; - } - break; - case LSQB: - n = CHILD(n, 1); - if (TYPE(n) == RSQB) { - com_error(c, PyExc_SyntaxError, - "can't assign to []"); - return; - } - if (assigning > OP_APPLY) { - com_error(c, PyExc_SyntaxError, - "augmented assign to list literal not possible"); - return; - } - if (NCH(n) > 1 - && TYPE(CHILD(n, 1)) == list_for) { - com_error(c, PyExc_SyntaxError, - "can't assign to list comprehension"); - return; - } - com_assign_sequence(c, n, assigning); - return; - case NAME: - if (assigning > OP_APPLY) - com_augassign_name(c, CHILD(n, 0), - assigning, augn); - else - com_assign_name(c, CHILD(n, 0), - assigning); - return; - default: - com_error(c, PyExc_SyntaxError, - "can't assign to literal"); - return; - } - break; - - case lambdef: - com_error(c, PyExc_SyntaxError, - "can't assign to lambda"); - return; - - default: - com_error(c, PyExc_SystemError, - "com_assign: bad node"); - return; - - } - } -} - -static void -com_augassign(struct compiling *c, node *n) -{ - int opcode; - - switch (STR(CHILD(CHILD(n, 1), 0))[0]) { - case '+': opcode = INPLACE_ADD; break; - case '-': opcode = INPLACE_SUBTRACT; break; - case '/': - if (STR(CHILD(CHILD(n, 1), 0))[1] == '/') - opcode = INPLACE_FLOOR_DIVIDE; - else if (c->c_flags & CO_FUTURE_DIVISION) - opcode = INPLACE_TRUE_DIVIDE; - else - opcode = INPLACE_DIVIDE; - break; - case '%': opcode = INPLACE_MODULO; break; - case '<': opcode = INPLACE_LSHIFT; break; - case '>': opcode = INPLACE_RSHIFT; break; - case '&': opcode = INPLACE_AND; break; - case '^': opcode = INPLACE_XOR; break; - case '|': opcode = INPLACE_OR; break; - case '*': - if (STR(CHILD(CHILD(n, 1), 0))[1] == '*') - opcode = INPLACE_POWER; - else - opcode = INPLACE_MULTIPLY; - break; - default: - com_error(c, PyExc_SystemError, "com_augassign: bad operator"); - return; - } - com_assign(c, CHILD(n, 0), opcode, CHILD(n, 2)); -} - -static void -com_expr_stmt(struct compiling *c, node *n) -{ - REQ(n, expr_stmt); - /* testlist (('=' testlist)* | augassign testlist) */ - /* Forget it if we have just a doc string here */ - if (!c->c_interactive && NCH(n) == 1 && get_rawdocstring(n) != NULL) - return; - if (NCH(n) == 1) { - com_node(c, CHILD(n, NCH(n)-1)); - if (c->c_interactive) - com_addbyte(c, PRINT_EXPR); - else - com_addbyte(c, POP_TOP); - com_pop(c, 1); - } - else if (TYPE(CHILD(n,1)) == augassign) - com_augassign(c, n); - else { - int i; - com_node(c, CHILD(n, NCH(n)-1)); - for (i = 0; i < NCH(n)-2; i+=2) { - if (i+2 < NCH(n)-2) { - com_addbyte(c, DUP_TOP); - com_push(c, 1); - } - com_assign(c, CHILD(n, i), OP_ASSIGN, NULL); - } - } -} - -static void -com_assert_stmt(struct compiling *c, node *n) -{ - int a = 0; - int i; - REQ(n, assert_stmt); /* 'assert' test [',' test] */ - if (Py_OptimizeFlag) - return; - /* Generate code like - - if not : - raise AssertionError [, ] - - where is the second test, if present. - */ - com_node(c, CHILD(n, 1)); - com_addfwref(c, JUMP_IF_TRUE, &a); - com_addbyte(c, POP_TOP); - com_pop(c, 1); - /* Raise that exception! */ - com_addop_name(c, LOAD_GLOBAL, "AssertionError"); - com_push(c, 1); - i = NCH(n)/2; /* Either 2 or 4 */ - if (i > 1) - com_node(c, CHILD(n, 3)); - com_addoparg(c, RAISE_VARARGS, i); - com_pop(c, i); - /* The interpreter does not fall through */ - /* Jump ends up here */ - com_backpatch(c, a); - com_addbyte(c, POP_TOP); -} - -static void -com_print_stmt(struct compiling *c, node *n) -{ - int i = 1; - node* stream = NULL; - - REQ(n, print_stmt); /* 'print' (test ',')* [test] */ - - /* are we using the extended print form? */ - if (NCH(n) >= 2 && TYPE(CHILD(n, 1)) == RIGHTSHIFT) { - stream = CHILD(n, 2); - com_node(c, stream); - /* stack: [...] => [... stream] */ - com_push(c, 1); - if (NCH(n) > 3 && TYPE(CHILD(n, 3)) == COMMA) - i = 4; - else - i = 3; - } - for (; i < NCH(n); i += 2) { - if (stream != NULL) { - com_addbyte(c, DUP_TOP); - /* stack: [stream] => [stream stream] */ - com_push(c, 1); - com_node(c, CHILD(n, i)); - /* stack: [stream stream] => [stream stream obj] */ - com_addbyte(c, ROT_TWO); - /* stack: [stream stream obj] => [stream obj stream] */ - com_addbyte(c, PRINT_ITEM_TO); - /* stack: [stream obj stream] => [stream] */ - com_pop(c, 2); - } - else { - com_node(c, CHILD(n, i)); - /* stack: [...] => [... obj] */ - com_addbyte(c, PRINT_ITEM); - com_pop(c, 1); - } - } - /* XXX Alternatively, LOAD_CONST '\n' and then PRINT_ITEM */ - if (TYPE(CHILD(n, NCH(n)-1)) == COMMA) { - if (stream != NULL) { - /* must pop the extra stream object off the stack */ - com_addbyte(c, POP_TOP); - /* stack: [... stream] => [...] */ - com_pop(c, 1); - } - } - else { - if (stream != NULL) { - /* this consumes the last stream object on stack */ - com_addbyte(c, PRINT_NEWLINE_TO); - /* stack: [... stream] => [...] */ - com_pop(c, 1); - } - else - com_addbyte(c, PRINT_NEWLINE); - } -} - -static void -com_return_stmt(struct compiling *c, node *n) -{ - REQ(n, return_stmt); /* 'return' [testlist] */ - if (!c->c_infunction) { - com_error(c, PyExc_SyntaxError, "'return' outside function"); - } - if (c->c_flags & CO_GENERATOR) { - if (NCH(n) > 1) { - com_error(c, PyExc_SyntaxError, - "'return' with argument inside generator"); - } - } - if (NCH(n) < 2) { - com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None)); - com_push(c, 1); - } - else - com_node(c, CHILD(n, 1)); - com_addbyte(c, RETURN_VALUE); - com_pop(c, 1); -} - -static void -com_yield_stmt(struct compiling *c, node *n) -{ - int i; - REQ(n, yield_stmt); /* 'yield' testlist */ - if (!c->c_infunction) { - com_error(c, PyExc_SyntaxError, "'yield' outside function"); - } - - for (i = 0; i < c->c_nblocks; ++i) { - if (c->c_block[i] == SETUP_FINALLY) { - com_error(c, PyExc_SyntaxError, - "'yield' not allowed in a 'try' block " - "with a 'finally' clause"); - return; - } - } - com_node(c, CHILD(n, 1)); - com_addbyte(c, YIELD_VALUE); - com_pop(c, 1); -} - -static void -com_raise_stmt(struct compiling *c, node *n) -{ - int i; - REQ(n, raise_stmt); /* 'raise' [test [',' test [',' test]]] */ - if (NCH(n) > 1) { - com_node(c, CHILD(n, 1)); - if (NCH(n) > 3) { - com_node(c, CHILD(n, 3)); - if (NCH(n) > 5) - com_node(c, CHILD(n, 5)); - } - } - i = NCH(n)/2; - com_addoparg(c, RAISE_VARARGS, i); - com_pop(c, i); -} - -static void -com_from_import(struct compiling *c, node *n) -{ - com_addopname(c, IMPORT_FROM, CHILD(n, 0)); - com_push(c, 1); - if (NCH(n) > 1) { - if (strcmp(STR(CHILD(n, 1)), "as") != 0) { - com_error(c, PyExc_SyntaxError, "invalid syntax"); - return; - } - com_addop_varname(c, VAR_STORE, STR(CHILD(n, 2))); - } else - com_addop_varname(c, VAR_STORE, STR(CHILD(n, 0))); - com_pop(c, 1); -} - -static void -com_import_stmt(struct compiling *c, node *n) -{ - int i; - REQ(n, import_stmt); - /* 'import' dotted_name (',' dotted_name)* | - 'from' dotted_name 'import' ('*' | NAME (',' NAME)*) */ - if (STR(CHILD(n, 0))[0] == 'f') { - PyObject *tup; - /* 'from' dotted_name 'import' ... */ - REQ(CHILD(n, 1), dotted_name); - - if (TYPE(CHILD(n, 3)) == STAR) { - tup = Py_BuildValue("(s)", "*"); - } else { - tup = PyTuple_New((NCH(n) - 2)/2); - for (i = 3; i < NCH(n); i += 2) { - PyTuple_SET_ITEM(tup, (i-3)/2, - PyString_FromString(STR( - CHILD(CHILD(n, i), 0)))); - } - } - com_addoparg(c, LOAD_CONST, com_addconst(c, tup)); - Py_DECREF(tup); - com_push(c, 1); - com_addopname(c, IMPORT_NAME, CHILD(n, 1)); - if (TYPE(CHILD(n, 3)) == STAR) - com_addbyte(c, IMPORT_STAR); - else { - for (i = 3; i < NCH(n); i += 2) - com_from_import(c, CHILD(n, i)); - com_addbyte(c, POP_TOP); - } - com_pop(c, 1); - } - else { - /* 'import' ... */ - for (i = 1; i < NCH(n); i += 2) { - node *subn = CHILD(n, i); - REQ(subn, dotted_as_name); - com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None)); - com_push(c, 1); - com_addopname(c, IMPORT_NAME, CHILD(subn, 0)); - if (NCH(subn) > 1) { - int j; - if (strcmp(STR(CHILD(subn, 1)), "as") != 0) { - com_error(c, PyExc_SyntaxError, - "invalid syntax"); - return; - } - for (j=2 ; j < NCH(CHILD(subn, 0)); j += 2) - com_addopname(c, LOAD_ATTR, - CHILD(CHILD(subn, 0), - j)); - com_addop_varname(c, VAR_STORE, - STR(CHILD(subn, 2))); - } else - com_addop_varname(c, VAR_STORE, - STR(CHILD(CHILD(subn, 0), - 0))); - com_pop(c, 1); - } - } -} - -static void -com_exec_stmt(struct compiling *c, node *n) -{ - REQ(n, exec_stmt); - /* exec_stmt: 'exec' expr ['in' expr [',' expr]] */ - com_node(c, CHILD(n, 1)); - if (NCH(n) >= 4) - com_node(c, CHILD(n, 3)); - else { - com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None)); - com_push(c, 1); - } - if (NCH(n) >= 6) - com_node(c, CHILD(n, 5)); - else { - com_addbyte(c, DUP_TOP); - com_push(c, 1); - } - com_addbyte(c, EXEC_STMT); - com_pop(c, 3); -} - -static int -is_constant_false(struct compiling *c, node *n) -{ - PyObject *v; - int i; - /* argument c will be NULL when called from symtable_node() */ - - /* Label to avoid tail recursion */ - next: - switch (TYPE(n)) { - - case suite: - if (NCH(n) == 1) { - n = CHILD(n, 0); - goto next; - } - /* Fall through */ - case file_input: - for (i = 0; i < NCH(n); i++) { - node *ch = CHILD(n, i); - if (TYPE(ch) == stmt) { - n = ch; - goto next; - } - } - break; - - case stmt: - case simple_stmt: - case small_stmt: - n = CHILD(n, 0); - goto next; - - case expr_stmt: - case testlist: - case testlist1: - case test: - case and_test: - case not_test: - case comparison: - case expr: - case xor_expr: - case and_expr: - case shift_expr: - case arith_expr: - case term: - case factor: - case power: - case atom: - if (NCH(n) == 1) { - n = CHILD(n, 0); - goto next; - } - break; - - case NAME: - if (Py_OptimizeFlag && strcmp(STR(n), "__debug__") == 0) - return 1; - break; - - case NUMBER: - v = parsenumber(c, STR(n)); - if (v == NULL) { - PyErr_Clear(); - break; - } - i = PyObject_IsTrue(v); - Py_DECREF(v); - return i == 0; - - case STRING: - v = parsestr(c, STR(n)); - if (v == NULL) { - PyErr_Clear(); - break; - } - i = PyObject_IsTrue(v); - Py_DECREF(v); - return i == 0; - - } - return 0; -} - - -/* Look under n for a return stmt with an expression. - * This hack is used to find illegal returns under "if 0:" blocks in - * functions already known to be generators (as determined by the symtable - * pass). - * Return the offending return node if found, else NULL. - */ -static node * -look_for_offending_return(node *n) -{ - int i; - - for (i = 0; i < NCH(n); ++i) { - node *kid = CHILD(n, i); - - switch (TYPE(kid)) { - case classdef: - case funcdef: - case lambdef: - /* Stuff in nested functions & classes doesn't - affect the code block we started in. */ - return NULL; - - case return_stmt: - if (NCH(kid) > 1) - return kid; - break; - - default: { - node *bad = look_for_offending_return(kid); - if (bad != NULL) - return bad; - } - } - } - - return NULL; -} - -static void -com_if_stmt(struct compiling *c, node *n) -{ - int i; - int anchor = 0; - REQ(n, if_stmt); - /*'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] */ - for (i = 0; i+3 < NCH(n); i+=4) { - int a = 0; - node *ch = CHILD(n, i+1); - if (is_constant_false(c, ch)) { - /* We're going to skip this block. However, if this - is a generator, we have to check the dead code - anyway to make sure there aren't any return stmts - with expressions, in the same scope. */ - if (c->c_flags & CO_GENERATOR) { - node *p = look_for_offending_return(n); - if (p != NULL) { - int savelineno = c->c_lineno; - c->c_lineno = p->n_lineno; - com_error(c, PyExc_SyntaxError, - "'return' with argument " - "inside generator"); - c->c_lineno = savelineno; - } - } - continue; - } - if (i > 0) - com_set_lineno(c, ch->n_lineno); - com_node(c, ch); - com_addfwref(c, JUMP_IF_FALSE, &a); - com_addbyte(c, POP_TOP); - com_pop(c, 1); - com_node(c, CHILD(n, i+3)); - com_addfwref(c, JUMP_FORWARD, &anchor); - com_backpatch(c, a); - /* We jump here with an extra entry which we now pop */ - com_addbyte(c, POP_TOP); - } - if (i+2 < NCH(n)) - com_node(c, CHILD(n, i+2)); - if (anchor) - com_backpatch(c, anchor); -} - -static void -com_while_stmt(struct compiling *c, node *n) -{ - int break_anchor = 0; - int anchor = 0; - int save_begin = c->c_begin; - REQ(n, while_stmt); /* 'while' test ':' suite ['else' ':' suite] */ - com_addfwref(c, SETUP_LOOP, &break_anchor); - block_push(c, SETUP_LOOP); - c->c_begin = c->c_nexti; - com_set_lineno(c, n->n_lineno); - com_node(c, CHILD(n, 1)); - com_addfwref(c, JUMP_IF_FALSE, &anchor); - com_addbyte(c, POP_TOP); - com_pop(c, 1); - c->c_loops++; - com_node(c, CHILD(n, 3)); - c->c_loops--; - com_addoparg(c, JUMP_ABSOLUTE, c->c_begin); - c->c_begin = save_begin; - com_backpatch(c, anchor); - /* We jump here with one entry more on the stack */ - com_addbyte(c, POP_TOP); - com_addbyte(c, POP_BLOCK); - block_pop(c, SETUP_LOOP); - if (NCH(n) > 4) - com_node(c, CHILD(n, 6)); - com_backpatch(c, break_anchor); -} - -static void -com_for_stmt(struct compiling *c, node *n) -{ - int break_anchor = 0; - int anchor = 0; - int save_begin = c->c_begin; - REQ(n, for_stmt); - /* 'for' exprlist 'in' exprlist ':' suite ['else' ':' suite] */ - com_addfwref(c, SETUP_LOOP, &break_anchor); - block_push(c, SETUP_LOOP); - com_node(c, CHILD(n, 3)); - com_addbyte(c, GET_ITER); - c->c_begin = c->c_nexti; - com_set_lineno(c, c->c_last_line); - com_addfwref(c, FOR_ITER, &anchor); - com_push(c, 1); - com_assign(c, CHILD(n, 1), OP_ASSIGN, NULL); - c->c_loops++; - com_node(c, CHILD(n, 5)); - c->c_loops--; - com_addoparg(c, JUMP_ABSOLUTE, c->c_begin); - c->c_begin = save_begin; - com_backpatch(c, anchor); - com_pop(c, 1); /* FOR_ITER has popped this */ - com_addbyte(c, POP_BLOCK); - block_pop(c, SETUP_LOOP); - if (NCH(n) > 8) - com_node(c, CHILD(n, 8)); - com_backpatch(c, break_anchor); -} - -/* Code generated for "try: S finally: Sf" is as follows: - - SETUP_FINALLY L - - POP_BLOCK - LOAD_CONST - L: - END_FINALLY - - The special instructions use the block stack. Each block - stack entry contains the instruction that created it (here - SETUP_FINALLY), the level of the value stack at the time the - block stack entry was created, and a label (here L). - - SETUP_FINALLY: - Pushes the current value stack level and the label - onto the block stack. - POP_BLOCK: - Pops en entry from the block stack, and pops the value - stack until its level is the same as indicated on the - block stack. (The label is ignored.) - END_FINALLY: - Pops a variable number of entries from the *value* stack - and re-raises the exception they specify. The number of - entries popped depends on the (pseudo) exception type. - - The block stack is unwound when an exception is raised: - when a SETUP_FINALLY entry is found, the exception is pushed - onto the value stack (and the exception condition is cleared), - and the interpreter jumps to the label gotten from the block - stack. - - Code generated for "try: S except E1, V1: S1 except E2, V2: S2 ...": - (The contents of the value stack is shown in [], with the top - at the right; 'tb' is trace-back info, 'val' the exception's - associated value, and 'exc' the exception.) - - Value stack Label Instruction Argument - [] SETUP_EXCEPT L1 - [] - [] POP_BLOCK - [] JUMP_FORWARD L0 - - [tb, val, exc] L1: DUP ) - [tb, val, exc, exc] ) - [tb, val, exc, exc, E1] COMPARE_OP EXC_MATCH ) only if E1 - [tb, val, exc, 1-or-0] JUMP_IF_FALSE L2 ) - [tb, val, exc, 1] POP ) - [tb, val, exc] POP - [tb, val] (or POP if no V1) - [tb] POP - [] - JUMP_FORWARD L0 - - [tb, val, exc, 0] L2: POP - [tb, val, exc] DUP - .............................etc....................... - - [tb, val, exc, 0] Ln+1: POP - [tb, val, exc] END_FINALLY # re-raise exception - - [] L0: - - Of course, parts are not generated if Vi or Ei is not present. -*/ - -static void -com_try_except(struct compiling *c, node *n) -{ - int except_anchor = 0; - int end_anchor = 0; - int else_anchor = 0; - int i; - node *ch; - - com_addfwref(c, SETUP_EXCEPT, &except_anchor); - block_push(c, SETUP_EXCEPT); - com_node(c, CHILD(n, 2)); - com_addbyte(c, POP_BLOCK); - block_pop(c, SETUP_EXCEPT); - com_addfwref(c, JUMP_FORWARD, &else_anchor); - com_backpatch(c, except_anchor); - for (i = 3; - i < NCH(n) && TYPE(ch = CHILD(n, i)) == except_clause; - i += 3) { - /* except_clause: 'except' [expr [',' var]] */ - if (except_anchor == 0) { - com_error(c, PyExc_SyntaxError, - "default 'except:' must be last"); - break; - } - except_anchor = 0; - com_push(c, 3); /* tb, val, exc pushed by exception */ - com_set_lineno(c, ch->n_lineno); - if (NCH(ch) > 1) { - com_addbyte(c, DUP_TOP); - com_push(c, 1); - com_node(c, CHILD(ch, 1)); - com_addoparg(c, COMPARE_OP, PyCmp_EXC_MATCH); - com_pop(c, 1); - com_addfwref(c, JUMP_IF_FALSE, &except_anchor); - com_addbyte(c, POP_TOP); - com_pop(c, 1); - } - com_addbyte(c, POP_TOP); - com_pop(c, 1); - if (NCH(ch) > 3) - com_assign(c, CHILD(ch, 3), OP_ASSIGN, NULL); - else { - com_addbyte(c, POP_TOP); - com_pop(c, 1); - } - com_addbyte(c, POP_TOP); - com_pop(c, 1); - com_node(c, CHILD(n, i+2)); - com_addfwref(c, JUMP_FORWARD, &end_anchor); - if (except_anchor) { - com_backpatch(c, except_anchor); - /* We come in with [tb, val, exc, 0] on the - stack; one pop and it's the same as - expected at the start of the loop */ - com_addbyte(c, POP_TOP); - } - } - /* We actually come in here with [tb, val, exc] but the - END_FINALLY will zap those and jump around. - The c_stacklevel does not reflect them so we need not pop - anything. */ - com_addbyte(c, END_FINALLY); - com_backpatch(c, else_anchor); - if (i < NCH(n)) - com_node(c, CHILD(n, i+2)); - com_backpatch(c, end_anchor); -} - -static void -com_try_finally(struct compiling *c, node *n) -{ - int finally_anchor = 0; - node *ch; - - com_addfwref(c, SETUP_FINALLY, &finally_anchor); - block_push(c, SETUP_FINALLY); - com_node(c, CHILD(n, 2)); - com_addbyte(c, POP_BLOCK); - block_pop(c, SETUP_FINALLY); - block_push(c, END_FINALLY); - com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None)); - /* While the generated code pushes only one item, - the try-finally handling can enter here with - up to three items. OK, here are the details: - 3 for an exception, 2 for RETURN, 1 for BREAK. */ - com_push(c, 3); - com_backpatch(c, finally_anchor); - ch = CHILD(n, NCH(n)-1); - com_set_lineno(c, ch->n_lineno); - com_node(c, ch); - com_addbyte(c, END_FINALLY); - block_pop(c, END_FINALLY); - com_pop(c, 3); /* Matches the com_push above */ -} - -static void -com_try_stmt(struct compiling *c, node *n) -{ - REQ(n, try_stmt); - /* 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite] - | 'try' ':' suite 'finally' ':' suite */ - if (TYPE(CHILD(n, 3)) != except_clause) - com_try_finally(c, n); - else - com_try_except(c, n); -} - -static node * -get_rawdocstring(node *n) -{ - int i; - - /* Label to avoid tail recursion */ - next: - switch (TYPE(n)) { - - case suite: - if (NCH(n) == 1) { - n = CHILD(n, 0); - goto next; - } - /* Fall through */ - case file_input: - for (i = 0; i < NCH(n); i++) { - node *ch = CHILD(n, i); - if (TYPE(ch) == stmt) { - n = ch; - goto next; - } - } - break; - - case stmt: - case simple_stmt: - case small_stmt: - n = CHILD(n, 0); - goto next; - - case expr_stmt: - case testlist: - case testlist1: - case test: - case and_test: - case not_test: - case comparison: - case expr: - case xor_expr: - case and_expr: - case shift_expr: - case arith_expr: - case term: - case factor: - case power: - if (NCH(n) == 1) { - n = CHILD(n, 0); - goto next; - } - break; - - case atom: - if (TYPE(CHILD(n, 0)) == STRING) - return n; - break; - - } - return NULL; -} - -static PyObject * -get_docstring(struct compiling *c, node *n) -{ - /* Don't generate doc-strings if run with -OO */ - if (Py_OptimizeFlag > 1) - return NULL; - n = get_rawdocstring(n); - if (n == NULL) - return NULL; - return parsestrplus(c, n); -} - -static void -com_suite(struct compiling *c, node *n) -{ - REQ(n, suite); - /* simple_stmt | NEWLINE INDENT NEWLINE* (stmt NEWLINE*)+ DEDENT */ - if (NCH(n) == 1) { - com_node(c, CHILD(n, 0)); - } - else { - int i; - for (i = 0; i < NCH(n) && c->c_errors == 0; i++) { - node *ch = CHILD(n, i); - if (TYPE(ch) == stmt) - com_node(c, ch); - } - } -} - -/* ARGSUSED */ -static void -com_continue_stmt(struct compiling *c, node *n) -{ - int i = c->c_nblocks; - if (i-- > 0 && c->c_block[i] == SETUP_LOOP) { - com_addoparg(c, JUMP_ABSOLUTE, c->c_begin); - } - else if (i <= 0) { - /* at the outer level */ - com_error(c, PyExc_SyntaxError, - "'continue' not properly in loop"); - } - else { - int j; - for (j = i-1; j >= 0; --j) { - if (c->c_block[j] == SETUP_LOOP) - break; - } - if (j >= 0) { - /* there is a loop, but something interferes */ - for (; i > j; --i) { - if (c->c_block[i] == SETUP_EXCEPT || - c->c_block[i] == SETUP_FINALLY) { - com_addoparg(c, CONTINUE_LOOP, - c->c_begin); - return; - } - if (c->c_block[i] == END_FINALLY) { - com_error(c, PyExc_SyntaxError, - "'continue' not supported inside 'finally' clause"); - return; - } - } - } - com_error(c, PyExc_SyntaxError, - "'continue' not properly in loop"); - } - /* XXX Could allow it inside a 'finally' clause - XXX if we could pop the exception still on the stack */ -} - -static int -com_argdefs(struct compiling *c, node *n) -{ - int i, nch, nargs, ndefs; - if (TYPE(n) == lambdef) { - /* lambdef: 'lambda' [varargslist] ':' test */ - n = CHILD(n, 1); - } - else { - REQ(n, funcdef); /* funcdef: 'def' NAME parameters ... */ - n = CHILD(n, 2); - REQ(n, parameters); /* parameters: '(' [varargslist] ')' */ - n = CHILD(n, 1); - } - if (TYPE(n) != varargslist) - return 0; - /* varargslist: - (fpdef ['=' test] ',')* '*' ....... | - fpdef ['=' test] (',' fpdef ['=' test])* [','] */ - nch = NCH(n); - nargs = 0; - ndefs = 0; - for (i = 0; i < nch; i++) { - int t; - if (TYPE(CHILD(n, i)) == STAR || - TYPE(CHILD(n, i)) == DOUBLESTAR) - break; - nargs++; - i++; - if (i >= nch) - t = RPAR; /* Anything except EQUAL or COMMA */ - else - t = TYPE(CHILD(n, i)); - if (t == EQUAL) { - i++; - ndefs++; - com_node(c, CHILD(n, i)); - i++; - if (i >= nch) - break; - t = TYPE(CHILD(n, i)); - } - else { - /* Treat "(a=1, b)" as an error */ - if (ndefs) - com_error(c, PyExc_SyntaxError, - "non-default argument follows default argument"); - } - if (t != COMMA) - break; - } - return ndefs; -} - -static void -com_funcdef(struct compiling *c, node *n) -{ - PyObject *co; - int ndefs; - REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */ - ndefs = com_argdefs(c, n); - symtable_enter_scope(c->c_symtable, STR(CHILD(n, 1)), TYPE(n), - n->n_lineno); - co = (PyObject *)icompile(n, c); - symtable_exit_scope(c->c_symtable); - if (co == NULL) - c->c_errors++; - else { - int closure = com_make_closure(c, (PyCodeObject *)co); - int i = com_addconst(c, co); - com_addoparg(c, LOAD_CONST, i); - com_push(c, 1); - if (closure) - com_addoparg(c, MAKE_CLOSURE, ndefs); - else - com_addoparg(c, MAKE_FUNCTION, ndefs); - com_pop(c, ndefs); - com_addop_varname(c, VAR_STORE, STR(CHILD(n, 1))); - com_pop(c, 1); - Py_DECREF(co); - } -} - -static void -com_bases(struct compiling *c, node *n) -{ - int i; - REQ(n, testlist); - /* testlist: test (',' test)* [','] */ - for (i = 0; i < NCH(n); i += 2) - com_node(c, CHILD(n, i)); - i = (NCH(n)+1) / 2; - com_addoparg(c, BUILD_TUPLE, i); - com_pop(c, i-1); -} - -static void -com_classdef(struct compiling *c, node *n) -{ - int i; - PyObject *v; - PyCodeObject *co; - char *name; - - REQ(n, classdef); - /* classdef: class NAME ['(' testlist ')'] ':' suite */ - if ((v = PyString_InternFromString(STR(CHILD(n, 1)))) == NULL) { - c->c_errors++; - return; - } - /* Push the class name on the stack */ - i = com_addconst(c, v); - com_addoparg(c, LOAD_CONST, i); - com_push(c, 1); - Py_DECREF(v); - /* Push the tuple of base classes on the stack */ - if (TYPE(CHILD(n, 2)) != LPAR) { - com_addoparg(c, BUILD_TUPLE, 0); - com_push(c, 1); - } - else - com_bases(c, CHILD(n, 3)); - name = STR(CHILD(n, 1)); - symtable_enter_scope(c->c_symtable, name, TYPE(n), n->n_lineno); - co = icompile(n, c); - symtable_exit_scope(c->c_symtable); - if (co == NULL) - c->c_errors++; - else { - int closure = com_make_closure(c, co); - i = com_addconst(c, (PyObject *)co); - com_addoparg(c, LOAD_CONST, i); - com_push(c, 1); - if (closure) { - com_addoparg(c, MAKE_CLOSURE, 0); - com_pop(c, PyCode_GetNumFree(co)); - } else - com_addoparg(c, MAKE_FUNCTION, 0); - com_addoparg(c, CALL_FUNCTION, 0); - com_addbyte(c, BUILD_CLASS); - com_pop(c, 2); - com_addop_varname(c, VAR_STORE, STR(CHILD(n, 1))); - com_pop(c, 1); - Py_DECREF(co); - } -} - -static void -com_node(struct compiling *c, node *n) -{ - loop: - if (c->c_errors) - return; - switch (TYPE(n)) { - - /* Definition nodes */ - - case funcdef: - com_funcdef(c, n); - break; - case classdef: - com_classdef(c, n); - break; - - /* Trivial parse tree nodes */ - - case stmt: - case small_stmt: - case flow_stmt: - n = CHILD(n, 0); - goto loop; - - case simple_stmt: - /* small_stmt (';' small_stmt)* [';'] NEWLINE */ - com_set_lineno(c, n->n_lineno); - { - int i; - for (i = 0; i < NCH(n)-1; i += 2) - com_node(c, CHILD(n, i)); - } - break; - - case compound_stmt: - com_set_lineno(c, n->n_lineno); - n = CHILD(n, 0); - goto loop; - - /* Statement nodes */ - - case expr_stmt: - com_expr_stmt(c, n); - break; - case print_stmt: - com_print_stmt(c, n); - break; - case del_stmt: /* 'del' exprlist */ - com_assign(c, CHILD(n, 1), OP_DELETE, NULL); - break; - case pass_stmt: - break; - case break_stmt: - if (c->c_loops == 0) { - com_error(c, PyExc_SyntaxError, - "'break' outside loop"); - } - com_addbyte(c, BREAK_LOOP); - break; - case continue_stmt: - com_continue_stmt(c, n); - break; - case return_stmt: - com_return_stmt(c, n); - break; - case yield_stmt: - com_yield_stmt(c, n); - break; - case raise_stmt: - com_raise_stmt(c, n); - break; - case import_stmt: - com_import_stmt(c, n); - break; - case global_stmt: - break; - case exec_stmt: - com_exec_stmt(c, n); - break; - case assert_stmt: - com_assert_stmt(c, n); - break; - case if_stmt: - com_if_stmt(c, n); - break; - case while_stmt: - com_while_stmt(c, n); - break; - case for_stmt: - com_for_stmt(c, n); - break; - case try_stmt: - com_try_stmt(c, n); - break; - case suite: - com_suite(c, n); - break; - - /* Expression nodes */ - - case testlist: - case testlist1: - case testlist_safe: - com_list(c, n, 0); - break; - case test: - com_test(c, n); - break; - case and_test: - com_and_test(c, n); - break; - case not_test: - com_not_test(c, n); - break; - case comparison: - com_comparison(c, n); - break; - case exprlist: - com_list(c, n, 0); - break; - case expr: - com_expr(c, n); - break; - case xor_expr: - com_xor_expr(c, n); - break; - case and_expr: - com_and_expr(c, n); - break; - case shift_expr: - com_shift_expr(c, n); - break; - case arith_expr: - com_arith_expr(c, n); - break; - case term: - com_term(c, n); - break; - case factor: - com_factor(c, n); - break; - case power: - com_power(c, n); - break; - case atom: - com_atom(c, n); - break; - - default: - com_error(c, PyExc_SystemError, - "com_node: unexpected node type"); - } -} - -static void com_fplist(struct compiling *, node *); - -static void -com_fpdef(struct compiling *c, node *n) -{ - REQ(n, fpdef); /* fpdef: NAME | '(' fplist ')' */ - if (TYPE(CHILD(n, 0)) == LPAR) - com_fplist(c, CHILD(n, 1)); - else { - com_addop_varname(c, VAR_STORE, STR(CHILD(n, 0))); - com_pop(c, 1); - } -} - -static void -com_fplist(struct compiling *c, node *n) -{ - REQ(n, fplist); /* fplist: fpdef (',' fpdef)* [','] */ - if (NCH(n) == 1) { - com_fpdef(c, CHILD(n, 0)); - } - else { - int i = (NCH(n)+1)/2; - com_addoparg(c, UNPACK_SEQUENCE, i); - com_push(c, i-1); - for (i = 0; i < NCH(n); i += 2) - com_fpdef(c, CHILD(n, i)); - } -} - -static void -com_arglist(struct compiling *c, node *n) -{ - int nch, i, narg; - int complex = 0; - char nbuf[30]; - REQ(n, varargslist); - /* varargslist: - (fpdef ['=' test] ',')* (fpdef ['=' test] | '*' .....) */ - nch = NCH(n); - /* Enter all arguments in table of locals */ - for (i = 0, narg = 0; i < nch; i++) { - node *ch = CHILD(n, i); - node *fp; - if (TYPE(ch) == STAR || TYPE(ch) == DOUBLESTAR) - break; - REQ(ch, fpdef); /* fpdef: NAME | '(' fplist ')' */ - fp = CHILD(ch, 0); - if (TYPE(fp) != NAME) { - PyOS_snprintf(nbuf, sizeof(nbuf), ".%d", i); - complex = 1; - } - narg++; - /* all name updates handled by symtable */ - if (++i >= nch) - break; - ch = CHILD(n, i); - if (TYPE(ch) == EQUAL) - i += 2; - else - REQ(ch, COMMA); - } - if (complex) { - /* Generate code for complex arguments only after - having counted the simple arguments */ - int ilocal = 0; - for (i = 0; i < nch; i++) { - node *ch = CHILD(n, i); - node *fp; - if (TYPE(ch) == STAR || TYPE(ch) == DOUBLESTAR) - break; - REQ(ch, fpdef); /* fpdef: NAME | '(' fplist ')' */ - fp = CHILD(ch, 0); - if (TYPE(fp) != NAME) { - com_addoparg(c, LOAD_FAST, ilocal); - com_push(c, 1); - com_fpdef(c, ch); - } - ilocal++; - if (++i >= nch) - break; - ch = CHILD(n, i); - if (TYPE(ch) == EQUAL) - i += 2; - else - REQ(ch, COMMA); - } - } -} - -static void -com_file_input(struct compiling *c, node *n) -{ - int i; - PyObject *doc; - REQ(n, file_input); /* (NEWLINE | stmt)* ENDMARKER */ - doc = get_docstring(c, n); - if (doc != NULL) { - int i = com_addconst(c, doc); - Py_DECREF(doc); - com_addoparg(c, LOAD_CONST, i); - com_push(c, 1); - com_addop_name(c, STORE_NAME, "__doc__"); - com_pop(c, 1); - } - for (i = 0; i < NCH(n); i++) { - node *ch = CHILD(n, i); - if (TYPE(ch) != ENDMARKER && TYPE(ch) != NEWLINE) - com_node(c, ch); - } -} - -/* Top-level compile-node interface */ - -static void -compile_funcdef(struct compiling *c, node *n) -{ - PyObject *doc; - node *ch; - REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */ - c->c_name = STR(CHILD(n, 1)); - doc = get_docstring(c, CHILD(n, 4)); - if (doc != NULL) { - (void) com_addconst(c, doc); - Py_DECREF(doc); - } - else - (void) com_addconst(c, Py_None); /* No docstring */ - ch = CHILD(n, 2); /* parameters: '(' [varargslist] ')' */ - ch = CHILD(ch, 1); /* ')' | varargslist */ - if (TYPE(ch) == varargslist) - com_arglist(c, ch); - c->c_infunction = 1; - com_node(c, CHILD(n, 4)); - c->c_infunction = 0; - com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None)); - com_push(c, 1); - com_addbyte(c, RETURN_VALUE); - com_pop(c, 1); -} - -static void -compile_lambdef(struct compiling *c, node *n) -{ - node *ch; - REQ(n, lambdef); /* lambdef: 'lambda' [varargslist] ':' test */ - c->c_name = ""; - - ch = CHILD(n, 1); - (void) com_addconst(c, Py_None); /* No docstring */ - if (TYPE(ch) == varargslist) { - com_arglist(c, ch); - ch = CHILD(n, 3); - } - else - ch = CHILD(n, 2); - com_node(c, ch); - com_addbyte(c, RETURN_VALUE); - com_pop(c, 1); -} - -static void -compile_classdef(struct compiling *c, node *n) -{ - node *ch; - PyObject *doc; - REQ(n, classdef); - /* classdef: 'class' NAME ['(' testlist ')'] ':' suite */ - c->c_name = STR(CHILD(n, 1)); - c->c_private = c->c_name; - /* Initialize local __module__ from global __name__ */ - com_addop_name(c, LOAD_GLOBAL, "__name__"); - com_addop_name(c, STORE_NAME, "__module__"); - ch = CHILD(n, NCH(n)-1); /* The suite */ - doc = get_docstring(c, ch); - if (doc != NULL) { - int i = com_addconst(c, doc); - Py_DECREF(doc); - com_addoparg(c, LOAD_CONST, i); - com_push(c, 1); - com_addop_name(c, STORE_NAME, "__doc__"); - com_pop(c, 1); - } - else - (void) com_addconst(c, Py_None); - com_node(c, ch); - com_addbyte(c, LOAD_LOCALS); - com_push(c, 1); - com_addbyte(c, RETURN_VALUE); - com_pop(c, 1); -} - -static void -compile_node(struct compiling *c, node *n) -{ - com_set_lineno(c, n->n_lineno); - - switch (TYPE(n)) { - - case single_input: /* One interactive command */ - /* NEWLINE | simple_stmt | compound_stmt NEWLINE */ - c->c_interactive++; - n = CHILD(n, 0); - if (TYPE(n) != NEWLINE) - com_node(c, n); - com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None)); - com_push(c, 1); - com_addbyte(c, RETURN_VALUE); - com_pop(c, 1); - c->c_interactive--; - break; - - case file_input: /* A whole file, or built-in function exec() */ - com_file_input(c, n); - com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None)); - com_push(c, 1); - com_addbyte(c, RETURN_VALUE); - com_pop(c, 1); - break; - - case eval_input: /* Built-in function input() */ - com_node(c, CHILD(n, 0)); - com_addbyte(c, RETURN_VALUE); - com_pop(c, 1); - break; - - case lambdef: /* anonymous function definition */ - compile_lambdef(c, n); - break; - - case funcdef: /* A function definition */ - compile_funcdef(c, n); - break; - - case classdef: /* A class definition */ - compile_classdef(c, n); - break; - - default: - com_error(c, PyExc_SystemError, - "compile_node: unexpected node type"); - } -} - -static PyObject * -dict_keys_inorder(PyObject *dict, int offset) -{ - PyObject *tuple, *k, *v; - int i, pos = 0, size = PyDict_Size(dict); - - tuple = PyTuple_New(size); - if (tuple == NULL) - return NULL; - while (PyDict_Next(dict, &pos, &k, &v)) { - i = PyInt_AS_LONG(v); - Py_INCREF(k); - assert((i - offset) < size); - PyTuple_SET_ITEM(tuple, i - offset, k); - } - return tuple; -} - -PyCodeObject * -PyNode_Compile(node *n, const char *filename) -{ - return PyNode_CompileFlags(n, filename, NULL); -} - -PyCodeObject * -PyNode_CompileFlags(node *n, const char *filename, PyCompilerFlags *flags) -{ - return jcompile(n, filename, NULL, flags); -} - -struct symtable * -PyNode_CompileSymtable(node *n, const char *filename) -{ - struct symtable *st; - PyFutureFeatures *ff; - - ff = PyNode_Future(n, filename); - if (ff == NULL) - return NULL; - st = symtable_build(n, ff, filename); - if (st == NULL) { - PyObject_FREE((void *)ff); - return NULL; - } - return st; -} - -static PyCodeObject * -icompile(node *n, struct compiling *base) -{ - return jcompile(n, base->c_filename, base, NULL); -} - -static PyCodeObject * -jcompile(node *n, const char *filename, struct compiling *base, - PyCompilerFlags *flags) -{ - struct compiling sc; - PyCodeObject *co; - if (!com_init(&sc, filename)) - return NULL; - if (flags && flags->cf_flags & PyCF_SOURCE_IS_UTF8) { - sc.c_encoding = "utf-8"; - } else if (TYPE(n) == encoding_decl) { - sc.c_encoding = STR(n); - n = CHILD(n, 0); - } else { - sc.c_encoding = NULL; - } - if (base) { - sc.c_private = base->c_private; - sc.c_symtable = base->c_symtable; - /* c_symtable still points to parent's symbols */ - if (base->c_nested - || (sc.c_symtable->st_cur->ste_type == TYPE_FUNCTION)) - sc.c_nested = 1; - sc.c_flags |= base->c_flags & PyCF_MASK; - if (base->c_encoding != NULL) { - assert(sc.c_encoding == NULL); - sc.c_encoding = base->c_encoding; - } - } else { - sc.c_private = NULL; - sc.c_future = PyNode_Future(n, filename); - if (sc.c_future == NULL) { - com_free(&sc); - return NULL; - } - if (flags) { - int merged = sc.c_future->ff_features | - flags->cf_flags; - sc.c_future->ff_features = merged; - flags->cf_flags = merged; - } - sc.c_symtable = symtable_build(n, sc.c_future, sc.c_filename); - if (sc.c_symtable == NULL) { - com_free(&sc); - return NULL; - } - /* reset symbol table for second pass */ - sc.c_symtable->st_nscopes = 1; - sc.c_symtable->st_pass = 2; - } - co = NULL; - if (symtable_load_symbols(&sc) < 0) { - sc.c_errors++; - goto exit; - } - compile_node(&sc, n); - com_done(&sc); - if (sc.c_errors == 0) { - PyObject *consts, *names, *varnames, *filename, *name, - *freevars, *cellvars; - consts = PyList_AsTuple(sc.c_consts); - names = PyList_AsTuple(sc.c_names); - varnames = PyList_AsTuple(sc.c_varnames); - cellvars = dict_keys_inorder(sc.c_cellvars, 0); - freevars = dict_keys_inorder(sc.c_freevars, - PyTuple_GET_SIZE(cellvars)); - filename = PyString_InternFromString(sc.c_filename); - name = PyString_InternFromString(sc.c_name); - if (!PyErr_Occurred()) - co = PyCode_New(sc.c_argcount, - sc.c_nlocals, - sc.c_maxstacklevel, - sc.c_flags, - sc.c_code, - consts, - names, - varnames, - freevars, - cellvars, - filename, - name, - sc.c_firstlineno, - sc.c_lnotab); - Py_XDECREF(consts); - Py_XDECREF(names); - Py_XDECREF(varnames); - Py_XDECREF(freevars); - Py_XDECREF(cellvars); - Py_XDECREF(filename); - Py_XDECREF(name); - } - else if (!PyErr_Occurred()) { - /* This could happen if someone called PyErr_Clear() after an - error was reported above. That's not supposed to happen, - but I just plugged one case and I'm not sure there can't be - others. In that case, raise SystemError so that at least - it gets reported instead dumping core. */ - PyErr_SetString(PyExc_SystemError, "lost syntax error"); - } - exit: - if (base == NULL) { - PySymtable_Free(sc.c_symtable); - sc.c_symtable = NULL; - } - com_free(&sc); - return co; -} - -int -PyCode_Addr2Line(PyCodeObject *co, int addrq) -{ - int size = PyString_Size(co->co_lnotab) / 2; - unsigned char *p = (unsigned char*)PyString_AsString(co->co_lnotab); - int line = co->co_firstlineno; - int addr = 0; - while (--size >= 0) { - addr += *p++; - if (addr > addrq) - break; - line += *p++; - } - return line; -} - -/* The test for LOCAL must come before the test for FREE in order to - handle classes where name is both local and free. The local var is - a method and the free var is a free var referenced within a method. -*/ - -static int -get_ref_type(struct compiling *c, char *name) -{ - char buf[350]; - PyObject *v; - - if (PyDict_GetItemString(c->c_cellvars, name) != NULL) - return CELL; - if (PyDict_GetItemString(c->c_locals, name) != NULL) - return LOCAL; - if (PyDict_GetItemString(c->c_freevars, name) != NULL) - return FREE; - v = PyDict_GetItemString(c->c_globals, name); - if (v) { - if (v == Py_None) - return GLOBAL_EXPLICIT; - else { - return GLOBAL_IMPLICIT; - } - } - PyOS_snprintf(buf, sizeof(buf), - "unknown scope for %.100s in %.100s(%s) " - "in %s\nsymbols: %s\nlocals: %s\nglobals: %s\n", - name, c->c_name, - PyObject_REPR(c->c_symtable->st_cur->ste_id), - c->c_filename, - PyObject_REPR(c->c_symtable->st_cur->ste_symbols), - PyObject_REPR(c->c_locals), - PyObject_REPR(c->c_globals) - ); - - Py_FatalError(buf); - return -1; -} - -/* Helper functions to issue warnings */ - -static int -issue_warning(const char *msg, const char *filename, int lineno) -{ - if (PyErr_Occurred()) { - /* This can happen because symtable_node continues - processing even after raising a SyntaxError. - Calling PyErr_WarnExplicit now would clobber the - pending exception; instead we fail and let that - exception propagate. - */ - return -1; - } - if (PyErr_WarnExplicit(PyExc_SyntaxWarning, msg, filename, - lineno, NULL, NULL) < 0) { - if (PyErr_ExceptionMatches(PyExc_SyntaxWarning)) { - PyErr_SetString(PyExc_SyntaxError, msg); - PyErr_SyntaxLocation(filename, lineno); - } - return -1; - } - return 0; -} - -static int -symtable_warn(struct symtable *st, char *msg) -{ - if (issue_warning(msg, st->st_filename, st->st_cur->ste_lineno) < 0) { - st->st_errors++; - return -1; - } - return 0; -} - -/* Helper function for setting lineno and filename */ - -static struct symtable * -symtable_build(node *n, PyFutureFeatures *ff, const char *filename) -{ - struct symtable *st; - - st = symtable_init(); - if (st == NULL) - return NULL; - st->st_future = ff; - st->st_filename = filename; - symtable_enter_scope(st, TOP, TYPE(n), n->n_lineno); - if (st->st_errors > 0) - goto fail; - symtable_node(st, n); - if (st->st_errors > 0) - goto fail; - return st; - fail: - if (!PyErr_Occurred()) { - /* This could happen because after a syntax error is - detected, the symbol-table-building continues for - a while, and PyErr_Clear() might erroneously be - called during that process. One such case has been - fixed, but there might be more (now or later). - */ - PyErr_SetString(PyExc_SystemError, "lost exception"); - } - st->st_future = NULL; - st->st_filename = NULL; - PySymtable_Free(st); - return NULL; -} - -static int -symtable_init_compiling_symbols(struct compiling *c) -{ - PyObject *varnames; - - varnames = c->c_symtable->st_cur->ste_varnames; - if (varnames == NULL) { - varnames = PyList_New(0); - if (varnames == NULL) - return -1; - c->c_symtable->st_cur->ste_varnames = varnames; - Py_INCREF(varnames); - } else - Py_INCREF(varnames); - c->c_varnames = varnames; - - c->c_globals = PyDict_New(); - if (c->c_globals == NULL) - return -1; - c->c_freevars = PyDict_New(); - if (c->c_freevars == NULL) - return -1; - c->c_cellvars = PyDict_New(); - if (c->c_cellvars == NULL) - return -1; - return 0; -} - -struct symbol_info { - int si_nlocals; - int si_ncells; - int si_nfrees; - int si_nimplicit; -}; - -static void -symtable_init_info(struct symbol_info *si) -{ - si->si_nlocals = 0; - si->si_ncells = 0; - si->si_nfrees = 0; - si->si_nimplicit = 0; -} - -static int -symtable_resolve_free(struct compiling *c, PyObject *name, int flags, - struct symbol_info *si) -{ - PyObject *dict, *v; - - /* Seperate logic for DEF_FREE. If it occurs in a function, - it indicates a local that we must allocate storage for (a - cell var). If it occurs in a class, then the class has a - method and a free variable with the same name. - */ - if (c->c_symtable->st_cur->ste_type == TYPE_FUNCTION) { - /* If it isn't declared locally, it can't be a cell. */ - if (!(flags & (DEF_LOCAL | DEF_PARAM))) - return 0; - v = PyInt_FromLong(si->si_ncells++); - dict = c->c_cellvars; - } else { - /* If it is free anyway, then there is no need to do - anything here. - */ - if (is_free(flags ^ DEF_FREE_CLASS) - || (flags == DEF_FREE_CLASS)) - return 0; - v = PyInt_FromLong(si->si_nfrees++); - dict = c->c_freevars; - } - if (v == NULL) - return -1; - if (PyDict_SetItem(dict, name, v) < 0) { - Py_DECREF(v); - return -1; - } - Py_DECREF(v); - return 0; -} - -/* If a variable is a cell and an argument, make sure that appears in - co_cellvars before any variable to its right in varnames. -*/ - - -static int -symtable_cellvar_offsets(PyObject **cellvars, int argcount, - PyObject *varnames, int flags) -{ - PyObject *v = NULL; - PyObject *w, *d, *list = NULL; - int i, pos; - - if (flags & CO_VARARGS) - argcount++; - if (flags & CO_VARKEYWORDS) - argcount++; - for (i = argcount; --i >= 0; ) { - v = PyList_GET_ITEM(varnames, i); - if (PyDict_GetItem(*cellvars, v)) { - if (list == NULL) { - list = PyList_New(1); - if (list == NULL) - return -1; - PyList_SET_ITEM(list, 0, v); - Py_INCREF(v); - } else { - if (PyList_Insert(list, 0, v) < 0) { - Py_DECREF(list); - return -1; - } - } - } - } - if (list == NULL) - return 0; - - /* There are cellvars that are also arguments. Create a dict - to replace cellvars and put the args at the front. - */ - d = PyDict_New(); - if (d == NULL) - return -1; - for (i = PyList_GET_SIZE(list); --i >= 0; ) { - v = PyInt_FromLong(i); - if (v == NULL) - goto fail; - if (PyDict_SetItem(d, PyList_GET_ITEM(list, i), v) < 0) - goto fail; - if (PyDict_DelItem(*cellvars, PyList_GET_ITEM(list, i)) < 0) - goto fail; - Py_DECREF(v); - } - pos = 0; - i = PyList_GET_SIZE(list); - Py_DECREF(list); - while (PyDict_Next(*cellvars, &pos, &v, &w)) { - w = PyInt_FromLong(i++); /* don't care about the old key */ - if (w == NULL) - goto fail; - if (PyDict_SetItem(d, v, w) < 0) { - Py_DECREF(w); - v = NULL; - goto fail; - } - Py_DECREF(w); - } - Py_DECREF(*cellvars); - *cellvars = d; - return 1; - fail: - Py_DECREF(d); - Py_XDECREF(v); - return -1; -} - -static int -symtable_freevar_offsets(PyObject *freevars, int offset) -{ - PyObject *name, *v; - int pos; - - /* The cell vars are the first elements of the closure, - followed by the free vars. Update the offsets in - c_freevars to account for number of cellvars. */ - pos = 0; - while (PyDict_Next(freevars, &pos, &name, &v)) { - int i = PyInt_AS_LONG(v) + offset; - PyObject *o = PyInt_FromLong(i); - if (o == NULL) - return -1; - if (PyDict_SetItem(freevars, name, o) < 0) { - Py_DECREF(o); - return -1; - } - Py_DECREF(o); - } - return 0; -} - -static int -symtable_check_unoptimized(struct compiling *c, - PySymtableEntryObject *ste, - struct symbol_info *si) -{ - char buf[300]; - - if (!(si->si_ncells || si->si_nfrees || ste->ste_child_free - || (ste->ste_nested && si->si_nimplicit))) - return 0; - -#define ILLEGAL_CONTAINS "contains a nested function with free variables" - -#define ILLEGAL_IS "is a nested function" - -#define ILLEGAL_IMPORT_STAR \ -"import * is not allowed in function '%.100s' because it %s" - -#define ILLEGAL_BARE_EXEC \ -"unqualified exec is not allowed in function '%.100s' it %s" - -#define ILLEGAL_EXEC_AND_IMPORT_STAR \ -"function '%.100s' uses import * and bare exec, which are illegal " \ -"because it %s" - - /* XXX perhaps the linenos for these opt-breaking statements - should be stored so the exception can point to them. */ - - if (ste->ste_child_free) { - if (ste->ste_optimized == OPT_IMPORT_STAR) - PyOS_snprintf(buf, sizeof(buf), - ILLEGAL_IMPORT_STAR, - PyString_AS_STRING(ste->ste_name), - ILLEGAL_CONTAINS); - else if (ste->ste_optimized == (OPT_BARE_EXEC | OPT_EXEC)) - PyOS_snprintf(buf, sizeof(buf), - ILLEGAL_BARE_EXEC, - PyString_AS_STRING(ste->ste_name), - ILLEGAL_CONTAINS); - else { - PyOS_snprintf(buf, sizeof(buf), - ILLEGAL_EXEC_AND_IMPORT_STAR, - PyString_AS_STRING(ste->ste_name), - ILLEGAL_CONTAINS); - } - } else { - if (ste->ste_optimized == OPT_IMPORT_STAR) - PyOS_snprintf(buf, sizeof(buf), - ILLEGAL_IMPORT_STAR, - PyString_AS_STRING(ste->ste_name), - ILLEGAL_IS); - else if (ste->ste_optimized == (OPT_BARE_EXEC | OPT_EXEC)) - PyOS_snprintf(buf, sizeof(buf), - ILLEGAL_BARE_EXEC, - PyString_AS_STRING(ste->ste_name), - ILLEGAL_IS); - else { - PyOS_snprintf(buf, sizeof(buf), - ILLEGAL_EXEC_AND_IMPORT_STAR, - PyString_AS_STRING(ste->ste_name), - ILLEGAL_IS); - } - } - - PyErr_SetString(PyExc_SyntaxError, buf); - PyErr_SyntaxLocation(c->c_symtable->st_filename, - ste->ste_opt_lineno); - return -1; -} - -static int -symtable_update_flags(struct compiling *c, PySymtableEntryObject *ste, - struct symbol_info *si) -{ - if (c->c_future) - c->c_flags |= c->c_future->ff_features; - if (ste->ste_generator) - c->c_flags |= CO_GENERATOR; - if (ste->ste_type != TYPE_MODULE) - c->c_flags |= CO_NEWLOCALS; - if (ste->ste_type == TYPE_FUNCTION) { - c->c_nlocals = si->si_nlocals; - if (ste->ste_optimized == 0) - c->c_flags |= CO_OPTIMIZED; - else if (ste->ste_optimized != OPT_EXEC) - return symtable_check_unoptimized(c, ste, si); - } - return 0; -} - -static int -symtable_error(struct symtable *st, int lineno) -{ - if (lineno == 0) - lineno = st->st_cur->ste_lineno; - PyErr_SyntaxLocation(st->st_filename, lineno); - st->st_errors++; - return -1; -} - -static int -symtable_load_symbols(struct compiling *c) -{ - struct symtable *st = c->c_symtable; - PySymtableEntryObject *ste = st->st_cur; - PyObject *name, *varnames, *v; - int i, flags, pos; - struct symbol_info si; - - v = NULL; - - if (symtable_init_compiling_symbols(c) < 0) - goto fail; - symtable_init_info(&si); - varnames = st->st_cur->ste_varnames; - si.si_nlocals = PyList_GET_SIZE(varnames); - c->c_argcount = si.si_nlocals; - - for (i = 0; i < si.si_nlocals; ++i) { - v = PyInt_FromLong(i); - if (v == NULL) - goto fail; - if (PyDict_SetItem(c->c_locals, - PyList_GET_ITEM(varnames, i), v) < 0) - goto fail; - Py_DECREF(v); - } - - /* XXX The cases below define the rules for whether a name is - local or global. The logic could probably be clearer. */ - pos = 0; - while (PyDict_Next(ste->ste_symbols, &pos, &name, &v)) { - flags = PyInt_AS_LONG(v); - - if (flags & DEF_FREE_GLOBAL) - /* undo the original DEF_FREE */ - flags &= ~(DEF_FREE | DEF_FREE_CLASS); - - /* Deal with names that need two actions: - 1. Cell variables that are also locals. - 2. Free variables in methods that are also class - variables or declared global. - */ - if (flags & (DEF_FREE | DEF_FREE_CLASS)) - symtable_resolve_free(c, name, flags, &si); - - if (flags & DEF_STAR) { - c->c_argcount--; - c->c_flags |= CO_VARARGS; - } else if (flags & DEF_DOUBLESTAR) { - c->c_argcount--; - c->c_flags |= CO_VARKEYWORDS; - } else if (flags & DEF_INTUPLE) - c->c_argcount--; - else if (flags & DEF_GLOBAL) { - if (flags & DEF_PARAM) { - PyErr_Format(PyExc_SyntaxError, LOCAL_GLOBAL, - PyString_AS_STRING(name)); - symtable_error(st, 0); - goto fail; - } - if (PyDict_SetItem(c->c_globals, name, Py_None) < 0) - goto fail; - } else if (flags & DEF_FREE_GLOBAL) { - si.si_nimplicit++; - if (PyDict_SetItem(c->c_globals, name, Py_True) < 0) - goto fail; - } else if ((flags & DEF_LOCAL) && !(flags & DEF_PARAM)) { - v = PyInt_FromLong(si.si_nlocals++); - if (v == NULL) - goto fail; - if (PyDict_SetItem(c->c_locals, name, v) < 0) - goto fail; - Py_DECREF(v); - if (ste->ste_type != TYPE_CLASS) - if (PyList_Append(c->c_varnames, name) < 0) - goto fail; - } else if (is_free(flags)) { - if (ste->ste_nested) { - v = PyInt_FromLong(si.si_nfrees++); - if (v == NULL) - goto fail; - if (PyDict_SetItem(c->c_freevars, name, v) < 0) - goto fail; - Py_DECREF(v); - } else { - si.si_nimplicit++; - if (PyDict_SetItem(c->c_globals, name, - Py_True) < 0) - goto fail; - if (st->st_nscopes != 1) { - v = PyInt_FromLong(flags); - if (v == NULL) - goto fail; - if (PyDict_SetItem(st->st_global, - name, v)) - goto fail; - Py_DECREF(v); - } - } - } - } - - assert(PyDict_Size(c->c_freevars) == si.si_nfrees); - - if (si.si_ncells > 1) { /* one cell is always in order */ - if (symtable_cellvar_offsets(&c->c_cellvars, c->c_argcount, - c->c_varnames, c->c_flags) < 0) - return -1; - } - if (symtable_freevar_offsets(c->c_freevars, si.si_ncells) < 0) - return -1; - return symtable_update_flags(c, ste, &si); - fail: - /* is this always the right thing to do? */ - Py_XDECREF(v); - return -1; -} - -static struct symtable * -symtable_init() -{ - struct symtable *st; - - st = (struct symtable *)PyObject_MALLOC(sizeof(struct symtable)); - if (st == NULL) - return NULL; - st->st_pass = 1; - - st->st_filename = NULL; - st->st_symbols = NULL; - if ((st->st_stack = PyList_New(0)) == NULL) - goto fail; - if ((st->st_symbols = PyDict_New()) == NULL) - goto fail; - st->st_cur = NULL; - st->st_nscopes = 0; - st->st_errors = 0; - st->st_private = NULL; - return st; - fail: - PySymtable_Free(st); - return NULL; -} - -void -PySymtable_Free(struct symtable *st) -{ - Py_XDECREF(st->st_symbols); - Py_XDECREF(st->st_stack); - Py_XDECREF(st->st_cur); - PyObject_FREE((void *)st); -} - -/* When the compiler exits a scope, it must should update the scope's - free variable information with the list of free variables in its - children. - - Variables that are free in children and defined in the current - scope are cellvars. - - If the scope being exited is defined at the top-level (ste_nested is - false), free variables in children that are not defined here are - implicit globals. - -*/ - -static int -symtable_update_free_vars(struct symtable *st) -{ - int i, j, def; - PyObject *o, *name, *list = NULL; - PySymtableEntryObject *child, *ste = st->st_cur; - - if (ste->ste_type == TYPE_CLASS) - def = DEF_FREE_CLASS; - else - def = DEF_FREE; - for (i = 0; i < PyList_GET_SIZE(ste->ste_children); ++i) { - int pos = 0; - - if (list && PyList_SetSlice(list, 0, - PyList_GET_SIZE(list), 0) < 0) - return -1; - child = (PySymtableEntryObject *) - PyList_GET_ITEM(ste->ste_children, i); - while (PyDict_Next(child->ste_symbols, &pos, &name, &o)) { - int flags = PyInt_AS_LONG(o); - if (!(is_free(flags))) - continue; /* avoids indentation */ - if (list == NULL) { - list = PyList_New(0); - if (list == NULL) - return -1; - } - ste->ste_child_free = 1; - if (PyList_Append(list, name) < 0) { - Py_DECREF(list); - return -1; - } - } - for (j = 0; list && j < PyList_GET_SIZE(list); j++) { - PyObject *v; - name = PyList_GET_ITEM(list, j); - v = PyDict_GetItem(ste->ste_symbols, name); - /* If a name N is declared global in scope A and - referenced in scope B contained (perhaps - indirectly) in A and there are no scopes - with bindings for N between B and A, then N - is global in B. Unless A is a class scope, - because class scopes are not considered for - nested scopes. - */ - if (v && (ste->ste_type != TYPE_CLASS)) { - int flags = PyInt_AS_LONG(v); - if (flags & DEF_GLOBAL) { - symtable_undo_free(st, child->ste_id, - name); - continue; - } - } - if (ste->ste_nested) { - if (symtable_add_def_o(st, ste->ste_symbols, - name, def) < 0) { - Py_DECREF(list); - return -1; - } - } else { - if (symtable_check_global(st, child->ste_id, - name) < 0) { - Py_DECREF(list); - return -1; - } - } - } - } - - Py_XDECREF(list); - return 0; -} - -/* If the current scope is a non-nested class or if name is not - defined in the current, non-nested scope, then it is an implicit - global in all nested scopes. -*/ - -static int -symtable_check_global(struct symtable *st, PyObject *child, PyObject *name) -{ - PyObject *o; - int v; - PySymtableEntryObject *ste = st->st_cur; - - if (ste->ste_type == TYPE_CLASS) - return symtable_undo_free(st, child, name); - o = PyDict_GetItem(ste->ste_symbols, name); - if (o == NULL) - return symtable_undo_free(st, child, name); - v = PyInt_AS_LONG(o); - - if (is_free(v) || (v & DEF_GLOBAL)) - return symtable_undo_free(st, child, name); - else - return symtable_add_def_o(st, ste->ste_symbols, - name, DEF_FREE); -} - -static int -symtable_undo_free(struct symtable *st, PyObject *id, - PyObject *name) -{ - int i, v, x; - PyObject *info; - PySymtableEntryObject *ste; - - ste = (PySymtableEntryObject *)PyDict_GetItem(st->st_symbols, id); - if (ste == NULL) - return -1; - - info = PyDict_GetItem(ste->ste_symbols, name); - if (info == NULL) - return 0; - v = PyInt_AS_LONG(info); - if (is_free(v)) { - if (symtable_add_def_o(st, ste->ste_symbols, name, - DEF_FREE_GLOBAL) < 0) - return -1; - } else - /* If the name is defined here or declared global, - then the recursion stops. */ - return 0; - - for (i = 0; i < PyList_GET_SIZE(ste->ste_children); ++i) { - PySymtableEntryObject *child; - child = (PySymtableEntryObject *) - PyList_GET_ITEM(ste->ste_children, i); - x = symtable_undo_free(st, child->ste_id, name); - if (x < 0) - return x; - } - return 0; -} - -/* symtable_enter_scope() gets a reference via PySymtableEntry_New(). - This reference is released when the scope is exited, via the DECREF - in symtable_exit_scope(). -*/ - -static int -symtable_exit_scope(struct symtable *st) -{ - int end; - - if (st->st_pass == 1) - symtable_update_free_vars(st); - Py_DECREF(st->st_cur); - end = PyList_GET_SIZE(st->st_stack) - 1; - st->st_cur = (PySymtableEntryObject *)PyList_GET_ITEM(st->st_stack, - end); - if (PySequence_DelItem(st->st_stack, end) < 0) - return -1; - return 0; -} - -static void -symtable_enter_scope(struct symtable *st, char *name, int type, - int lineno) -{ - PySymtableEntryObject *prev = NULL; - - if (st->st_cur) { - prev = st->st_cur; - if (PyList_Append(st->st_stack, (PyObject *)st->st_cur) < 0) { - st->st_errors++; - return; - } - } - st->st_cur = (PySymtableEntryObject *) - PySymtableEntry_New(st, name, type, lineno); - if (st->st_cur == NULL) { - st->st_errors++; - return; - } - if (strcmp(name, TOP) == 0) - st->st_global = st->st_cur->ste_symbols; - if (prev && st->st_pass == 1) { - if (PyList_Append(prev->ste_children, - (PyObject *)st->st_cur) < 0) - st->st_errors++; - } -} - -static int -symtable_lookup(struct symtable *st, char *name) -{ - char buffer[MANGLE_LEN]; - PyObject *v; - int flags; - - if (_Py_Mangle(st->st_private, name, buffer, sizeof(buffer))) - name = buffer; - v = PyDict_GetItemString(st->st_cur->ste_symbols, name); - if (v == NULL) { - if (PyErr_Occurred()) - return -1; - else - return 0; - } - - flags = PyInt_AS_LONG(v); - return flags; -} - -static int -symtable_add_def(struct symtable *st, char *name, int flag) -{ - PyObject *s; - char buffer[MANGLE_LEN]; - int ret; - - /* Warn about None, except inside a tuple (where the assignment - code already issues a warning). */ - if ((flag & DEF_PARAM) && !(flag & DEF_INTUPLE) && - *name == 'N' && strcmp(name, "None") == 0) - { - if (symtable_warn(st, "argument named None")) - return -1; - } - if (_Py_Mangle(st->st_private, name, buffer, sizeof(buffer))) - name = buffer; - if ((s = PyString_InternFromString(name)) == NULL) - return -1; - ret = symtable_add_def_o(st, st->st_cur->ste_symbols, s, flag); - Py_DECREF(s); - return ret; -} - -/* Must only be called with mangled names */ - -static int -symtable_add_def_o(struct symtable *st, PyObject *dict, - PyObject *name, int flag) -{ - PyObject *o; - int val; - - if ((o = PyDict_GetItem(dict, name))) { - val = PyInt_AS_LONG(o); - if ((flag & DEF_PARAM) && (val & DEF_PARAM)) { - PyErr_Format(PyExc_SyntaxError, DUPLICATE_ARGUMENT, - PyString_AsString(name)); - return symtable_error(st, 0); - } - val |= flag; - } else - val = flag; - o = PyInt_FromLong(val); - if (o == NULL) - return -1; - if (PyDict_SetItem(dict, name, o) < 0) { - Py_DECREF(o); - return -1; - } - Py_DECREF(o); - - if (flag & DEF_PARAM) { - if (PyList_Append(st->st_cur->ste_varnames, name) < 0) - return -1; - } else if (flag & DEF_GLOBAL) { - /* XXX need to update DEF_GLOBAL for other flags too; - perhaps only DEF_FREE_GLOBAL */ - if ((o = PyDict_GetItem(st->st_global, name))) { - val = PyInt_AS_LONG(o); - val |= flag; - } else - val = flag; - o = PyInt_FromLong(val); - if (o == NULL) - return -1; - if (PyDict_SetItem(st->st_global, name, o) < 0) { - Py_DECREF(o); - return -1; - } - Py_DECREF(o); - } - return 0; -} - -#define symtable_add_use(ST, NAME) symtable_add_def((ST), (NAME), USE) - -/* Look for a yield stmt under n. Return 1 if found, else 0. - This hack is used to look inside "if 0:" blocks (which are normally - ignored) in case those are the only places a yield occurs (so that this - function is a generator). */ -static int -look_for_yield(node *n) -{ - int i; - - for (i = 0; i < NCH(n); ++i) { - node *kid = CHILD(n, i); - - switch (TYPE(kid)) { - - case classdef: - case funcdef: - case lambdef: - /* Stuff in nested functions and classes can't make - the parent a generator. */ - return 0; - - case yield_stmt: - return 1; - - default: - if (look_for_yield(kid)) - return 1; - } - } - return 0; -} - -static void -symtable_node(struct symtable *st, node *n) -{ - int i; - - loop: - switch (TYPE(n)) { - case funcdef: { - char *func_name = STR(CHILD(n, 1)); - symtable_add_def(st, func_name, DEF_LOCAL); - symtable_default_args(st, CHILD(n, 2)); - symtable_enter_scope(st, func_name, TYPE(n), n->n_lineno); - symtable_funcdef(st, n); - symtable_exit_scope(st); - break; - } - case lambdef: - if (NCH(n) == 4) - symtable_default_args(st, CHILD(n, 1)); - symtable_enter_scope(st, "lambda", TYPE(n), n->n_lineno); - symtable_funcdef(st, n); - symtable_exit_scope(st); - break; - case classdef: { - char *tmp, *class_name = STR(CHILD(n, 1)); - symtable_add_def(st, class_name, DEF_LOCAL); - if (TYPE(CHILD(n, 2)) == LPAR) { - node *bases = CHILD(n, 3); - int i; - for (i = 0; i < NCH(bases); i += 2) { - symtable_node(st, CHILD(bases, i)); - } - } - symtable_enter_scope(st, class_name, TYPE(n), n->n_lineno); - tmp = st->st_private; - st->st_private = class_name; - symtable_node(st, CHILD(n, NCH(n) - 1)); - st->st_private = tmp; - symtable_exit_scope(st); - break; - } - case if_stmt: - for (i = 0; i + 3 < NCH(n); i += 4) { - if (is_constant_false(NULL, (CHILD(n, i + 1)))) { - if (st->st_cur->ste_generator == 0) - st->st_cur->ste_generator = - look_for_yield(CHILD(n, i+3)); - continue; - } - symtable_node(st, CHILD(n, i + 1)); - symtable_node(st, CHILD(n, i + 3)); - } - if (i + 2 < NCH(n)) - symtable_node(st, CHILD(n, i + 2)); - break; - case global_stmt: - symtable_global(st, n); - break; - case import_stmt: - symtable_import(st, n); - break; - case exec_stmt: { - st->st_cur->ste_optimized |= OPT_EXEC; - symtable_node(st, CHILD(n, 1)); - if (NCH(n) > 2) - symtable_node(st, CHILD(n, 3)); - else { - st->st_cur->ste_optimized |= OPT_BARE_EXEC; - st->st_cur->ste_opt_lineno = n->n_lineno; - } - if (NCH(n) > 4) - symtable_node(st, CHILD(n, 5)); - break; - - } - case assert_stmt: - if (Py_OptimizeFlag) - return; - if (NCH(n) == 2) { - n = CHILD(n, 1); - goto loop; - } else { - symtable_node(st, CHILD(n, 1)); - n = CHILD(n, 3); - goto loop; - } - case except_clause: - if (NCH(n) == 4) - symtable_assign(st, CHILD(n, 3), 0); - if (NCH(n) > 1) { - n = CHILD(n, 1); - goto loop; - } - break; - case del_stmt: - symtable_assign(st, CHILD(n, 1), 0); - break; - case yield_stmt: - st->st_cur->ste_generator = 1; - n = CHILD(n, 1); - goto loop; - case expr_stmt: - if (NCH(n) == 1) - n = CHILD(n, 0); - else { - if (TYPE(CHILD(n, 1)) == augassign) { - symtable_assign(st, CHILD(n, 0), 0); - symtable_node(st, CHILD(n, 2)); - break; - } else { - int i; - for (i = 0; i < NCH(n) - 2; i += 2) - symtable_assign(st, CHILD(n, i), 0); - n = CHILD(n, NCH(n) - 1); - } - } - goto loop; - case list_iter: - /* only occurs when there are multiple for loops - in a list comprehension */ - n = CHILD(n, 0); - if (TYPE(n) == list_for) - symtable_list_for(st, n); - else { - REQ(n, list_if); - symtable_node(st, CHILD(n, 1)); - if (NCH(n) == 3) { - n = CHILD(n, 2); - goto loop; - } - } - break; - case for_stmt: - symtable_assign(st, CHILD(n, 1), 0); - for (i = 3; i < NCH(n); ++i) - if (TYPE(CHILD(n, i)) >= single_input) - symtable_node(st, CHILD(n, i)); - break; - /* The remaining cases fall through to default except in - special circumstances. This requires the individual cases - to be coded with great care, even though they look like - rather innocuous. Each case must double-check TYPE(n). - */ - case argument: - if (TYPE(n) == argument && NCH(n) == 3) { - n = CHILD(n, 2); - goto loop; - } - /* fall through */ - case listmaker: - if (NCH(n) > 1 && TYPE(CHILD(n, 1)) == list_for) { - symtable_list_comprehension(st, n); - break; - } - /* fall through */ - case atom: - if (TYPE(n) == atom && TYPE(CHILD(n, 0)) == NAME) { - symtable_add_use(st, STR(CHILD(n, 0))); - break; - } - /* fall through */ - default: - /* Walk over every non-token child with a special case - for one child. - */ - if (NCH(n) == 1) { - n = CHILD(n, 0); - goto loop; - } - for (i = 0; i < NCH(n); ++i) - if (TYPE(CHILD(n, i)) >= single_input) - symtable_node(st, CHILD(n, i)); - } -} - -static void -symtable_funcdef(struct symtable *st, node *n) -{ - node *body; - - if (TYPE(n) == lambdef) { - if (NCH(n) == 4) - symtable_params(st, CHILD(n, 1)); - } else - symtable_params(st, CHILD(n, 2)); - body = CHILD(n, NCH(n) - 1); - symtable_node(st, body); -} - -/* The next two functions parse the argument tuple. - symtable_default_args() checks for names in the default arguments, - which are references in the defining scope. symtable_params() - parses the parameter names, which are defined in the function's - body. - - varargslist: - (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) - | fpdef ['=' test] (',' fpdef ['=' test])* [','] -*/ - -static void -symtable_default_args(struct symtable *st, node *n) -{ - node *c; - int i; - - if (TYPE(n) == parameters) { - n = CHILD(n, 1); - if (TYPE(n) == RPAR) - return; - } - REQ(n, varargslist); - for (i = 0; i < NCH(n); i += 2) { - c = CHILD(n, i); - if (TYPE(c) == STAR || TYPE(c) == DOUBLESTAR) { - break; - } - if (i > 0 && (TYPE(CHILD(n, i - 1)) == EQUAL)) - symtable_node(st, CHILD(n, i)); - } -} - -static void -symtable_params(struct symtable *st, node *n) -{ - int i, complex = -1, ext = 0; - node *c = NULL; - - if (TYPE(n) == parameters) { - n = CHILD(n, 1); - if (TYPE(n) == RPAR) - return; - } - REQ(n, varargslist); - for (i = 0; i < NCH(n); i += 2) { - c = CHILD(n, i); - if (TYPE(c) == STAR || TYPE(c) == DOUBLESTAR) { - ext = 1; - break; - } - if (TYPE(c) == test) { - continue; - } - if (TYPE(CHILD(c, 0)) == NAME) - symtable_add_def(st, STR(CHILD(c, 0)), DEF_PARAM); - else { - char nbuf[30]; - PyOS_snprintf(nbuf, sizeof(nbuf), ".%d", i); - symtable_add_def(st, nbuf, DEF_PARAM); - complex = i; - } - } - if (ext) { - c = CHILD(n, i); - if (TYPE(c) == STAR) { - i++; - symtable_add_def(st, STR(CHILD(n, i)), - DEF_PARAM | DEF_STAR); - i += 2; - if (i >= NCH(n)) - c = NULL; - else - c = CHILD(n, i); - } - if (c && TYPE(c) == DOUBLESTAR) { - i++; - symtable_add_def(st, STR(CHILD(n, i)), - DEF_PARAM | DEF_DOUBLESTAR); - } - } - if (complex >= 0) { - int j; - for (j = 0; j <= complex; j++) { - c = CHILD(n, j); - if (TYPE(c) == COMMA) - c = CHILD(n, ++j); - else if (TYPE(c) == EQUAL) - c = CHILD(n, j += 3); - if (TYPE(CHILD(c, 0)) == LPAR) - symtable_params_fplist(st, CHILD(c, 1)); - } - } -} - -static void -symtable_params_fplist(struct symtable *st, node *n) -{ - int i; - node *c; - - REQ(n, fplist); - for (i = 0; i < NCH(n); i += 2) { - c = CHILD(n, i); - REQ(c, fpdef); - if (NCH(c) == 1) - symtable_add_def(st, STR(CHILD(c, 0)), - DEF_PARAM | DEF_INTUPLE); - else - symtable_params_fplist(st, CHILD(c, 1)); - } - -} - -static void -symtable_global(struct symtable *st, node *n) -{ - int i; - - /* XXX It might be helpful to warn about module-level global - statements, but it's hard to tell the difference between - module-level and a string passed to exec. - */ - - for (i = 1; i < NCH(n); i += 2) { - char *name = STR(CHILD(n, i)); - int flags; - - flags = symtable_lookup(st, name); - if (flags < 0) - continue; - if (flags && flags != DEF_GLOBAL) { - char buf[500]; - if (flags & DEF_PARAM) { - PyErr_Format(PyExc_SyntaxError, - "name '%.400s' is local and global", - name); - symtable_error(st, 0); - return; - } - else { - if (flags & DEF_LOCAL) - PyOS_snprintf(buf, sizeof(buf), - GLOBAL_AFTER_ASSIGN, - name); - else - PyOS_snprintf(buf, sizeof(buf), - GLOBAL_AFTER_USE, name); - symtable_warn(st, buf); - } - } - symtable_add_def(st, name, DEF_GLOBAL); - } -} - -static void -symtable_list_comprehension(struct symtable *st, node *n) -{ - /* listmaker: test list_for */ - char tmpname[30]; - - REQ(n, listmaker); - PyOS_snprintf(tmpname, sizeof(tmpname), "_[%d]", - ++st->st_cur->ste_tmpname); - symtable_add_def(st, tmpname, DEF_LOCAL); - symtable_list_for(st, CHILD(n, 1)); - symtable_node(st, CHILD(n, 0)); - --st->st_cur->ste_tmpname; -} - -static void -symtable_list_for(struct symtable *st, node *n) -{ - REQ(n, list_for); - /* list_for: for v in expr [list_iter] */ - symtable_assign(st, CHILD(n, 1), 0); - symtable_node(st, CHILD(n, 3)); - if (NCH(n) == 5) - symtable_node(st, CHILD(n, 4)); -} - -static void -symtable_import(struct symtable *st, node *n) -{ - int i; - /* import_stmt: 'import' dotted_as_name (',' dotted_as_name)* - | 'from' dotted_name 'import' - ('*' | import_as_name (',' import_as_name)*) - import_as_name: NAME [NAME NAME] - */ - if (STR(CHILD(n, 0))[0] == 'f') { /* from */ - node *dotname = CHILD(n, 1); - if (strcmp(STR(CHILD(dotname, 0)), "__future__") == 0) { - /* check for bogus imports */ - if (n->n_lineno >= st->st_future->ff_last_lineno) { - PyErr_SetString(PyExc_SyntaxError, - LATE_FUTURE); - symtable_error(st, n->n_lineno); - return; - } - } - if (TYPE(CHILD(n, 3)) == STAR) { - if (st->st_cur->ste_type != TYPE_MODULE) { - if (symtable_warn(st, - "import * only allowed at module level") < 0) - return; - } - st->st_cur->ste_optimized |= OPT_IMPORT_STAR; - st->st_cur->ste_opt_lineno = n->n_lineno; - } else { - for (i = 3; i < NCH(n); i += 2) { - node *c = CHILD(n, i); - if (NCH(c) > 1) /* import as */ - symtable_assign(st, CHILD(c, 2), - DEF_IMPORT); - else - symtable_assign(st, CHILD(c, 0), - DEF_IMPORT); - } - } - } else { - for (i = 1; i < NCH(n); i += 2) { - symtable_assign(st, CHILD(n, i), DEF_IMPORT); - } - } -} - -/* The third argument to symatble_assign() is a flag to be passed to - symtable_add_def() if it is eventually called. The flag is useful - to specify the particular type of assignment that should be - recorded, e.g. an assignment caused by import. - */ - -static void -symtable_assign(struct symtable *st, node *n, int def_flag) -{ - node *tmp; - int i; - - loop: - switch (TYPE(n)) { - case lambdef: - /* invalid assignment, e.g. lambda x:x=2. The next - pass will catch this error. */ - return; - case power: - if (NCH(n) > 2) { - for (i = 2; i < NCH(n); ++i) - if (TYPE(CHILD(n, i)) != DOUBLESTAR) - symtable_node(st, CHILD(n, i)); - } - if (NCH(n) > 1) { - symtable_node(st, CHILD(n, 0)); - symtable_node(st, CHILD(n, 1)); - } else { - n = CHILD(n, 0); - goto loop; - } - return; - case listmaker: - if (NCH(n) > 1 && TYPE(CHILD(n, 1)) == list_for) { - /* XXX This is an error, but the next pass - will catch it. */ - return; - } else { - for (i = 0; i < NCH(n); i += 2) - symtable_assign(st, CHILD(n, i), def_flag); - } - return; - case exprlist: - case testlist: - case testlist1: - if (NCH(n) == 1) { - n = CHILD(n, 0); - goto loop; - } - else { - int i; - for (i = 0; i < NCH(n); i += 2) - symtable_assign(st, CHILD(n, i), def_flag); - return; - } - case atom: - tmp = CHILD(n, 0); - if (TYPE(tmp) == LPAR || TYPE(tmp) == LSQB) { - n = CHILD(n, 1); - goto loop; - } else if (TYPE(tmp) == NAME) { - if (strcmp(STR(tmp), "__debug__") == 0) { - PyErr_SetString(PyExc_SyntaxError, - ASSIGN_DEBUG); - symtable_error(st, n->n_lineno); - return; - } - symtable_add_def(st, STR(tmp), DEF_LOCAL | def_flag); - } - return; - case dotted_as_name: - if (NCH(n) == 3) - symtable_add_def(st, STR(CHILD(n, 2)), - DEF_LOCAL | def_flag); - else - symtable_add_def(st, - STR(CHILD(CHILD(n, - 0), 0)), - DEF_LOCAL | def_flag); - return; - case dotted_name: - symtable_add_def(st, STR(CHILD(n, 0)), DEF_LOCAL | def_flag); - return; - case NAME: - symtable_add_def(st, STR(n), DEF_LOCAL | def_flag); - return; - default: - if (NCH(n) == 0) - return; - if (NCH(n) == 1) { - n = CHILD(n, 0); - goto loop; - } - /* Should only occur for errors like x + 1 = 1, - which will be caught in the next pass. */ - for (i = 0; i < NCH(n); ++i) - if (TYPE(CHILD(n, i)) >= single_input) - symtable_assign(st, CHILD(n, i), def_flag); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/dup2.c b/SDKs/XPlatform/Cypython-2.3.3/Python/dup2.c deleted file mode 100644 index cc067e04..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/dup2.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Public domain dup2() lookalike - * by Curtis Jackson @ AT&T Technologies, Burlington, NC - * electronic address: burl!rcj - * - * dup2 performs the following functions: - * - * Check to make sure that fd1 is a valid open file descriptor. - * Check to see if fd2 is already open; if so, close it. - * Duplicate fd1 onto fd2; checking to make sure fd2 is a valid fd. - * Return fd2 if all went well; return BADEXIT otherwise. - */ - -#include - -#define BADEXIT -1 - -int -dup2(int fd1, int fd2) -{ - if (fd1 != fd2) { - if (fcntl(fd1, F_GETFL) < 0) - return BADEXIT; - if (fcntl(fd2, F_GETFL) >= 0) - close(fd2); - if (fcntl(fd1, F_DUPFD, fd2) < 0) - return BADEXIT; - } - return fd2; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_aix.c b/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_aix.c deleted file mode 100644 index f9a0b2ee..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_aix.c +++ /dev/null @@ -1,183 +0,0 @@ - -/* Support for dynamic loading of extension modules */ - -#include "Python.h" -#include "importdl.h" - -#include /* for isdigit() */ -#include /* for global errno */ -#include /* for strerror() */ -#include /* for malloc(), free() */ -#include - - -#ifdef AIX_GENUINE_CPLUSPLUS -#include "/usr/lpp/xlC/include/load.h" -#define aix_load loadAndInit -#else -#define aix_load load -#endif - - -extern char *Py_GetProgramName(void); - -typedef struct Module { - struct Module *next; - void *entry; -} Module, *ModulePtr; - -const struct filedescr _PyImport_DynLoadFiletab[] = { - {".so", "rb", C_EXTENSION}, - {"module.so", "rb", C_EXTENSION}, - {0, 0} -}; - -static int -aix_getoldmodules(void **modlistptr) -{ - register ModulePtr modptr, prevmodptr; - register struct ld_info *ldiptr; - register char *ldibuf; - register int errflag, bufsize = 1024; - register unsigned int offset; - char *progname = Py_GetProgramName(); - - /* - -- Get the list of loaded modules into ld_info structures. - */ - if ((ldibuf = malloc(bufsize)) == NULL) { - PyErr_SetString(PyExc_ImportError, strerror(errno)); - return -1; - } - while ((errflag = loadquery(L_GETINFO, ldibuf, bufsize)) == -1 - && errno == ENOMEM) { - free(ldibuf); - bufsize += 1024; - if ((ldibuf = malloc(bufsize)) == NULL) { - PyErr_SetString(PyExc_ImportError, strerror(errno)); - return -1; - } - } - if (errflag == -1) { - PyErr_SetString(PyExc_ImportError, strerror(errno)); - return -1; - } - /* - -- Make the modules list from the ld_info structures. - */ - ldiptr = (struct ld_info *)ldibuf; - prevmodptr = NULL; - do { - if (strstr(progname, ldiptr->ldinfo_filename) == NULL && - strstr(ldiptr->ldinfo_filename, "python") == NULL) { - /* - -- Extract only the modules belonging to the main - -- executable + those containing "python" as a - -- substring (like the "python[version]" binary or - -- "libpython[version].a" in case it's a shared lib). - */ - offset = (unsigned int)ldiptr->ldinfo_next; - ldiptr = (struct ld_info *)((char*)ldiptr + offset); - continue; - } - if ((modptr = (ModulePtr)malloc(sizeof(Module))) == NULL) { - PyErr_SetString(PyExc_ImportError, strerror(errno)); - while (*modlistptr) { - modptr = (ModulePtr)*modlistptr; - *modlistptr = (void *)modptr->next; - free(modptr); - } - return -1; - } - modptr->entry = ldiptr->ldinfo_dataorg; - modptr->next = NULL; - if (prevmodptr == NULL) - *modlistptr = (void *)modptr; - else - prevmodptr->next = modptr; - prevmodptr = modptr; - offset = (unsigned int)ldiptr->ldinfo_next; - ldiptr = (struct ld_info *)((char*)ldiptr + offset); - } while (offset); - free(ldibuf); - return 0; -} - - -static void -aix_loaderror(const char *pathname) -{ - - char *message[1024], errbuf[1024]; - register int i,j; - - struct errtab { - int errNo; - char *errstr; - } load_errtab[] = { - {L_ERROR_TOOMANY, "too many errors, rest skipped."}, - {L_ERROR_NOLIB, "can't load library:"}, - {L_ERROR_UNDEF, "can't find symbol in library:"}, - {L_ERROR_RLDBAD, - "RLD index out of range or bad relocation type:"}, - {L_ERROR_FORMAT, "not a valid, executable xcoff file:"}, - {L_ERROR_MEMBER, - "file not an archive or does not contain requested member:"}, - {L_ERROR_TYPE, "symbol table mismatch:"}, - {L_ERROR_ALIGN, "text alignment in file is wrong."}, - {L_ERROR_SYSTEM, "System error:"}, - {L_ERROR_ERRNO, NULL} - }; - -#define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0])) -#define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1) - - PyOS_snprintf(errbuf, sizeof(errbuf), "from module %.200s ", pathname); - - if (!loadquery(L_GETMESSAGES, &message[0], sizeof(message))) { - ERRBUF_APPEND(strerror(errno)); - ERRBUF_APPEND("\n"); - } - for(i = 0; message[i] && *message[i]; i++) { - int nerr = atoi(message[i]); - for (j=0; j -#include - -#include "Python.h" -#include "importdl.h" - - -const struct filedescr _PyImport_DynLoadFiletab[] = { - {".so", "rb", C_EXTENSION}, - {"module.so", "rb", C_EXTENSION}, - {0, 0} -}; - -dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, - const char *pathname, FILE *fp) -{ - void *p; - int lib; - char funcname[258]; - - if (Py_VerboseFlag) - printf("load_library %s\n", pathname); - - lib = load_library(pathname, 0); - if (lib < 0) { - char buf[512]; - if (Py_VerboseFlag) - perror(pathname); - PyOS_snprintf(buf, sizeof(buf), "Failed to load %.200s: %.200s", - pathname, strerror(errno)); - PyErr_SetString(PyExc_ImportError, buf); - return NULL; - } - PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname); - if (Py_VerboseFlag) - printf("get_symbol_address %s\n", funcname); - if (get_symbol_address(lib, funcname, -1, &p) < 0) { - p = NULL; - if (Py_VerboseFlag) - perror(funcname); - } - - return (dl_funcptr) p; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_beos.c b/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_beos.c deleted file mode 100644 index 4d6c3af3..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_beos.c +++ /dev/null @@ -1,254 +0,0 @@ - -/* Support for dynamic loading of extension modules */ - -#include -#include -#include - -#include "Python.h" -#include "importdl.h" - -const struct filedescr _PyImport_DynLoadFiletab[] = { - {".so", "rb", C_EXTENSION}, - {"module.so", "rb", C_EXTENSION}, - {0, 0} -}; - -#if defined(MAXPATHLEN) && !defined(_SYS_PARAM_H) -#undef MAXPATHLEN -#endif - -#ifdef WITH_THREAD -#include "pythread.h" -static PyThread_type_lock beos_dyn_lock; -#endif - -static PyObject *beos_dyn_images = NULL; - -/* ---------------------------------------------------------------------- - * BeOS dynamic loading support - * - * This uses shared libraries, but BeOS has its own way of doing things - * (much easier than dlfnc.h, from the look of things). We'll use a - * Python Dictionary object to store the images_ids so we can be very - * nice and unload them when we exit. - * - * Note that this is thread-safe. Probably irrelevent, because of losing - * systems... Python probably disables threads while loading modules. - * Note the use of "probably"! Better to be safe than sorry. [chrish] - * - * As of 1.5.1 this should also work properly when you've configured - * Python without thread support; the 1.5 version required it, which wasn't - * very friendly. Note that I haven't tested it without threading... why - * would you want to avoid threads on BeOS? [chrish] - * - * As of 1.5.2, the PyImport_BeImageID() function has been removed; Donn - * tells me it's not necessary anymore because of PyCObject_Import(). - * [chrish] - */ - -/* Whack an item; the item is an image_id in disguise, so we'll call - * unload_add_on() for it. - */ -static void beos_nuke_dyn( PyObject *item ) -{ - status_t retval; - - if( item ) { - image_id id = (image_id)PyInt_AsLong( item ); - - retval = unload_add_on( id ); - } -} - -/* atexit() handler that'll call unload_add_on() for every item in the - * dictionary. - */ -static void beos_cleanup_dyn( void ) -{ - if( beos_dyn_images ) { - int idx; - int list_size; - PyObject *id_list; - -#ifdef WITH_THREAD - PyThread_acquire_lock( beos_dyn_lock, 1 ); -#endif - - id_list = PyDict_Values( beos_dyn_images ); - - list_size = PyList_Size( id_list ); - for( idx = 0; idx < list_size; idx++ ) { - PyObject *the_item; - - the_item = PyList_GetItem( id_list, idx ); - beos_nuke_dyn( the_item ); - } - - PyDict_Clear( beos_dyn_images ); - -#ifdef WITH_THREAD - PyThread_free_lock( beos_dyn_lock ); -#endif - } -} - -/* - * Initialize our dictionary, and the dictionary mutex. - */ -static void beos_init_dyn( void ) -{ - /* We're protected from a race condition here by the atomic init_count - * variable. - */ - static int32 init_count = 0; - int32 val; - - val = atomic_add( &init_count, 1 ); - if( beos_dyn_images == NULL && val == 0 ) { - beos_dyn_images = PyDict_New(); -#ifdef WITH_THREAD - beos_dyn_lock = PyThread_allocate_lock(); -#endif - atexit( beos_cleanup_dyn ); - } -} - -/* - * Add an image_id to the dictionary; the module name of the loaded image - * is the key. Note that if the key is already in the dict, we unload - * that image; this should allow reload() to work on dynamically loaded - * modules (super-keen!). - */ -static void beos_add_dyn( char *name, image_id id ) -{ - int retval; - PyObject *py_id; - - if( beos_dyn_images == NULL ) { - beos_init_dyn(); - } - -#ifdef WITH_THREAD - retval = PyThread_acquire_lock( beos_dyn_lock, 1 ); -#endif - - /* If there's already an object with this key in the dictionary, - * we're doing a reload(), so let's nuke it. - */ - py_id = PyDict_GetItemString( beos_dyn_images, name ); - if( py_id ) { - beos_nuke_dyn( py_id ); - retval = PyDict_DelItemString( beos_dyn_images, name ); - } - - py_id = PyInt_FromLong( (long)id ); - if( py_id ) { - retval = PyDict_SetItemString( beos_dyn_images, name, py_id ); - } - -#ifdef WITH_THREAD - PyThread_release_lock( beos_dyn_lock ); -#endif -} - - - -dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, - const char *pathname, FILE *fp) -{ - dl_funcptr p; - image_id the_id; - status_t retval; - char fullpath[PATH_MAX]; - char funcname[258]; - - if( Py_VerboseFlag ) { - printf( "load_add_on( %s )\n", pathname ); - } - - /* Hmm, this old bug appears to have regenerated itself; if the - * path isn't absolute, load_add_on() will fail. Reported to Be - * April 21, 1998. - */ - if( pathname[0] != '/' ) { - (void)getcwd( fullpath, PATH_MAX ); - (void)strncat( fullpath, "/", PATH_MAX ); - (void)strncat( fullpath, pathname, PATH_MAX ); - - if( Py_VerboseFlag ) { - printf( "load_add_on( %s )\n", fullpath ); - } - } else { - (void)strcpy( fullpath, pathname ); - } - - the_id = load_add_on( fullpath ); - if( the_id < B_NO_ERROR ) { - /* It's too bad load_add_on() doesn't set errno or something... - */ - char buff[256]; /* hate hard-coded string sizes... */ - - if( Py_VerboseFlag ) { - printf( "load_add_on( %s ) failed", fullpath ); - } - - if( the_id == B_ERROR ) - PyOS_snprintf( buff, sizeof(buff), - "BeOS: Failed to load %.200s", - fullpath ); - else - PyOS_snprintf( buff, sizeof(buff), - "Unknown error loading %.200s", - fullpath ); - - PyErr_SetString( PyExc_ImportError, buff ); - return NULL; - } - - PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname); - if( Py_VerboseFlag ) { - printf( "get_image_symbol( %s )\n", funcname ); - } - - retval = get_image_symbol( the_id, funcname, B_SYMBOL_TYPE_TEXT, &p ); - if( retval != B_NO_ERROR || p == NULL ) { - /* That's bad, we can't find that symbol in the module... - */ - char buff[256]; /* hate hard-coded string sizes... */ - - if( Py_VerboseFlag ) { - printf( "get_image_symbol( %s ) failed", funcname ); - } - - switch( retval ) { - case B_BAD_IMAGE_ID: - PyOS_snprintf( buff, sizeof(buff), - "can't load init function for dynamic module: " - "Invalid image ID for %.180s", fullpath ); - break; - case B_BAD_INDEX: - PyOS_snprintf( buff, sizeof(buff), - "can't load init function for dynamic module: " - "Bad index for %.180s", funcname ); - break; - default: - PyOS_snprintf( buff, sizeof(buff), - "can't load init function for dynamic module: " - "Unknown error looking up %.180s", funcname ); - break; - } - - retval = unload_add_on( the_id ); - - PyErr_SetString( PyExc_ImportError, buff ); - return NULL; - } - - /* Save the module name and image ID for later so we can clean up - * gracefully. - */ - beos_add_dyn( fqname, the_id ); - - return p; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_dl.c b/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_dl.c deleted file mode 100644 index 794e3f8b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_dl.c +++ /dev/null @@ -1,26 +0,0 @@ - -/* Support for dynamic loading of extension modules */ - -#include "dl.h" - -#include "Python.h" -#include "importdl.h" - - -extern char *Py_GetProgramName(void); - -const struct filedescr _PyImport_DynLoadFiletab[] = { - {".o", "rb", C_EXTENSION}, - {"module.o", "rb", C_EXTENSION}, - {0, 0} -}; - - -dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, - const char *pathname, FILE *fp) -{ - char funcname[258]; - - PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname); - return dl_loadmod(Py_GetProgramName(), pathname, funcname); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_hpux.c b/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_hpux.c deleted file mode 100644 index 7909b927..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_hpux.c +++ /dev/null @@ -1,58 +0,0 @@ - -/* Support for dynamic loading of extension modules */ - -#include "dl.h" -#include - -#include "Python.h" -#include "importdl.h" - -#if defined(__hp9000s300) -#define FUNCNAME_PATTERN "_init%.200s" -#else -#define FUNCNAME_PATTERN "init%.200s" -#endif - -const struct filedescr _PyImport_DynLoadFiletab[] = { - {".sl", "rb", C_EXTENSION}, - {"module.sl", "rb", C_EXTENSION}, - {0, 0} -}; - -dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, - const char *pathname, FILE *fp) -{ - dl_funcptr p; - shl_t lib; - int flags; - char funcname[258]; - - flags = BIND_FIRST | BIND_DEFERRED; - if (Py_VerboseFlag) { - flags = BIND_FIRST | BIND_IMMEDIATE | - BIND_NONFATAL | BIND_VERBOSE; - printf("shl_load %s\n",pathname); - } - lib = shl_load(pathname, flags, 0); - /* XXX Chuck Blake once wrote that 0 should be BIND_NOSTART? */ - if (lib == NULL) { - char buf[256]; - if (Py_VerboseFlag) - perror(pathname); - PyOS_snprintf(buf, sizeof(buf), "Failed to load %.200s", - pathname); - PyErr_SetString(PyExc_ImportError, buf); - return NULL; - } - PyOS_snprintf(funcname, sizeof(funcname), FUNCNAME_PATTERN, shortname); - if (Py_VerboseFlag) - printf("shl_findsym %s\n", funcname); - if (shl_findsym(&lib, funcname, TYPE_UNDEFINED, (void *) &p) == -1) { - shl_unload(lib); - p = NULL; - } - if (p == NULL && Py_VerboseFlag) - perror(funcname); - - return p; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_mac.c b/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_mac.c deleted file mode 100644 index b39b167f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_mac.c +++ /dev/null @@ -1,113 +0,0 @@ - -/* Support for dynamic loading of extension modules */ - -#include "Python.h" -#include "importdl.h" - -#include -#include -#ifdef USE_GUSI1 -#include "TFileSpec.h" /* for Path2FSSpec() */ -#endif -#include -#include -#include "macdefs.h" -#include "macglue.h" - - -const struct filedescr _PyImport_DynLoadFiletab[] = { - {".slb", "rb", C_EXTENSION}, - {".carbon.slb", "rb", C_EXTENSION}, - {0, 0} -}; - - -dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, - const char *pathname, FILE *fp) -{ - dl_funcptr p; - char funcname[258]; - - /* - ** Dynamic loading of CFM shared libraries on the Mac. The - ** code has become more convoluted than it was, because we - ** want to be able to put multiple modules in a single - ** file. For this reason, we have to determine the fragment - ** name, and we cannot use the library entry point but we have - ** to locate the correct init routine "by hand". - */ - FSSpec libspec; - CFragConnectionID connID; - Ptr mainAddr; - Str255 errMessage; - OSErr err; -#ifndef USE_GUSI1 - Boolean isfolder, didsomething; -#endif - char buf[512]; - Str63 fragname; - Ptr symAddr; - CFragSymbolClass class; - - /* First resolve any aliases to find the real file */ -#ifdef USE_GUSI1 - err = Path2FSSpec(pathname, &libspec); -#else - c2pstrcpy((unsigned char *)buf, pathname); - (void)FSMakeFSSpec(0, 0, (unsigned char *)buf, &libspec); - err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething); -#endif - if ( err ) { - PyOS_snprintf(buf, sizeof(buf), - "%.200s: %.200s", pathname, PyMac_StrError(err)); - PyErr_SetString(PyExc_ImportError, buf); - return NULL; - } - /* Next, determine the fragment name, - by stripping '.slb' and 'module' */ - memcpy(fragname+1, libspec.name+1, libspec.name[0]); - fragname[0] = libspec.name[0]; - if( strncmp((char *)(fragname+1+fragname[0]-4), - ".slb", 4) == 0 ) - fragname[0] -= 4; - if ( strncmp((char *)(fragname+1+fragname[0]-6), - "module", 6) == 0 ) - fragname[0] -= 6; - /* Load the fragment - (or return the connID if it is already loaded */ - err = GetDiskFragment(&libspec, 0, 0, fragname, - kLoadCFrag, &connID, &mainAddr, - errMessage); - if ( err == cfragImportTooOldErr || err == cfragImportTooNewErr ) { - /* - ** Special-case code: if PythonCore is too old or too new this means - ** the dynamic module was meant for a different Python. - */ - if (errMessage[0] == 10 && strncmp((char *)errMessage+1, "PythonCore", 10) == 0 ) { - PyOS_snprintf(buf, sizeof(buf), - "Dynamic module was built for %s version of MacPython", - (err == cfragImportTooOldErr ? "a newer" : "an older")); - PyErr_SetString(PyExc_ImportError, buf); - return NULL; - } - } - if ( err ) { - PyOS_snprintf(buf, sizeof(buf), "%.*s: %.200s", - errMessage[0], errMessage+1, - PyMac_StrError(err)); - PyErr_SetString(PyExc_ImportError, buf); - return NULL; - } - /* Locate the address of the correct init function */ - PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname); - err = FindSymbol(connID, Pstring(funcname), &symAddr, &class); - if ( err ) { - PyOS_snprintf(buf, sizeof(buf), "%s: %.200s", - funcname, PyMac_StrError(err)); - PyErr_SetString(PyExc_ImportError, buf); - return NULL; - } - p = (dl_funcptr)symAddr; - - return p; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_next.c b/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_next.c deleted file mode 100644 index 4b8a1295..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_next.c +++ /dev/null @@ -1,114 +0,0 @@ - -/* Support for dynamic loading of extension modules on Mac OS X -** All references to "NeXT" are for historical reasons. -*/ - -#include "Python.h" -#include "importdl.h" - -#include - -const struct filedescr _PyImport_DynLoadFiletab[] = { - {".so", "rb", C_EXTENSION}, - {"module.so", "rb", C_EXTENSION}, - {0, 0} -}; - -/* -** Python modules are Mach-O MH_BUNDLE files. The best way to load these -** is each in a private namespace, so you can load, say, a module bar and a -** module foo.bar. If we load everything in the global namespace the two -** initbar() symbols will conflict. -** However, it seems some extension packages depend upon being able to access -** each others' global symbols. There seems to be no way to eat our cake and -** have it, so the USE_DYLD_GLOBAL_NAMESPACE define determines which behaviour -** you get. -*/ - -#ifdef USE_DYLD_GLOBAL_NAMESPACE -#define LINKOPTIONS NSLINKMODULE_OPTION_BINDNOW|NSLINKMODULE_OPTION_RETURN_ON_ERROR -#else -#define LINKOPTIONS NSLINKMODULE_OPTION_BINDNOW| \ - NSLINKMODULE_OPTION_RETURN_ON_ERROR|NSLINKMODULE_OPTION_PRIVATE -#endif -dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, - const char *pathname, FILE *fp) -{ - dl_funcptr p = NULL; - char funcname[258]; - NSObjectFileImageReturnCode rc; - NSObjectFileImage image; - NSModule newModule; - NSSymbol theSym; - const char *errString; - char errBuf[512]; - - PyOS_snprintf(funcname, sizeof(funcname), "_init%.200s", shortname); - -#ifdef USE_DYLD_GLOBAL_NAMESPACE - if (NSIsSymbolNameDefined(funcname)) { - theSym = NSLookupAndBindSymbol(funcname); - p = (dl_funcptr)NSAddressOfSymbol(theSym); - return p; - } -#endif - rc = NSCreateObjectFileImageFromFile(pathname, &image); - switch(rc) { - default: - case NSObjectFileImageFailure: - case NSObjectFileImageFormat: - /* for these a message is printed on stderr by dyld */ - errString = "Can't create object file image"; - break; - case NSObjectFileImageSuccess: - errString = NULL; - break; - case NSObjectFileImageInappropriateFile: - errString = "Inappropriate file type for dynamic loading"; - break; - case NSObjectFileImageArch: - errString = "Wrong CPU type in object file"; - break; - case NSObjectFileImageAccess: - errString = "Can't read object file (no access)"; - break; - } - if (errString == NULL) { - newModule = NSLinkModule(image, pathname, LINKOPTIONS); - if (newModule == NULL) { - int errNo; - const char *fileName, *moreErrorStr; - NSLinkEditErrors c; - NSLinkEditError( &c, &errNo, &fileName, &moreErrorStr ); - PyOS_snprintf(errBuf, 512, "Failure linking new module: %s: %s", - fileName, moreErrorStr); - errString = errBuf; - } - } - if (errString != NULL) { - PyErr_SetString(PyExc_ImportError, errString); - return NULL; - } -#ifdef USE_DYLD_GLOBAL_NAMESPACE - if (!NSIsSymbolNameDefined(funcname)) { - /* UnlinkModule() isn't implemented in current versions, but calling it does no harm */ - NSUnLinkModule(newModule, FALSE); - PyErr_Format(PyExc_ImportError, - "Loaded module does not contain symbol %.200s", - funcname); - return NULL; - } - theSym = NSLookupAndBindSymbol(funcname); -#else - theSym = NSLookupSymbolInModule(newModule, funcname); - if ( theSym == NULL ) { - NSUnLinkModule(newModule, FALSE); - PyErr_Format(PyExc_ImportError, - "Loaded module does not contain symbol %.200s", - funcname); - return NULL; - } -#endif - p = (dl_funcptr)NSAddressOfSymbol(theSym); - return p; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_os2.c b/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_os2.c deleted file mode 100644 index c43213a0..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_os2.c +++ /dev/null @@ -1,46 +0,0 @@ - -/* Support for dynamic loading of extension modules */ - -#define INCL_DOSERRORS -#define INCL_DOSMODULEMGR -#include - -#include "Python.h" -#include "importdl.h" - - -const struct filedescr _PyImport_DynLoadFiletab[] = { - {".pyd", "rb", C_EXTENSION}, - {".dll", "rb", C_EXTENSION}, - {0, 0} -}; - -dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, - const char *pathname, FILE *fp) -{ - dl_funcptr p; - APIRET rc; - HMODULE hDLL; - char failreason[256]; - char funcname[258]; - - rc = DosLoadModule(failreason, - sizeof(failreason), - pathname, - &hDLL); - - if (rc != NO_ERROR) { - char errBuf[256]; - PyOS_snprintf(errBuf, sizeof(errBuf), - "DLL load failed, rc = %d: %.200s", - rc, failreason); - PyErr_SetString(PyExc_ImportError, errBuf); - return NULL; - } - - PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname); - rc = DosQueryProcAddr(hDLL, 0L, funcname, &p); - if (rc != NO_ERROR) - p = NULL; /* Signify Failure to Acquire Entrypoint */ - return p; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_shlib.c b/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_shlib.c deleted file mode 100644 index eb59c394..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_shlib.c +++ /dev/null @@ -1,139 +0,0 @@ - -/* Support for dynamic loading of extension modules */ - -#include "Python.h" -#include "importdl.h" - -#include -#include - -#if defined(__NetBSD__) -#include -#if (NetBSD < 199712) -#include -#include -#define dlerror() "error in dynamic linking" -#endif -#endif /* NetBSD */ - -#ifdef HAVE_DLFCN_H -#include -#else -#if defined(PYOS_OS2) && defined(PYCC_GCC) -#include "dlfcn.h" -#endif -#endif - -#if (defined(__OpenBSD__) || defined(__NetBSD__)) && !defined(__ELF__) -#define LEAD_UNDERSCORE "_" -#else -#define LEAD_UNDERSCORE "" -#endif - - -const struct filedescr _PyImport_DynLoadFiletab[] = { -#ifdef __CYGWIN__ - {".dll", "rb", C_EXTENSION}, - {"module.dll", "rb", C_EXTENSION}, -#else -#if defined(PYOS_OS2) && defined(PYCC_GCC) - {".pyd", "rb", C_EXTENSION}, - {".dll", "rb", C_EXTENSION}, -#else -#ifdef __VMS - {".exe", "rb", C_EXTENSION}, - {".EXE", "rb", C_EXTENSION}, - {"module.exe", "rb", C_EXTENSION}, - {"MODULE.EXE", "rb", C_EXTENSION}, -#else - {".so", "rb", C_EXTENSION}, - {"module.so", "rb", C_EXTENSION}, -#endif -#endif -#endif - {0, 0} -}; - -static struct { - dev_t dev; -#ifdef __VMS - ino_t ino[3]; -#else - ino_t ino; -#endif - void *handle; -} handles[128]; -static int nhandles = 0; - - -dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, - const char *pathname, FILE *fp) -{ - dl_funcptr p; - void *handle; - char funcname[258]; - char pathbuf[260]; - int dlopenflags=0; - - if (strchr(pathname, '/') == NULL) { - /* Prefix bare filename with "./" */ - PyOS_snprintf(pathbuf, sizeof(pathbuf), "./%-.255s", pathname); - pathname = pathbuf; - } - - PyOS_snprintf(funcname, sizeof(funcname), - LEAD_UNDERSCORE "init%.200s", shortname); - - if (fp != NULL) { - int i; - struct stat statb; - fstat(fileno(fp), &statb); - for (i = 0; i < nhandles; i++) { - if (statb.st_dev == handles[i].dev && - statb.st_ino == handles[i].ino) { - p = (dl_funcptr) dlsym(handles[i].handle, - funcname); - return p; - } - } - if (nhandles < 128) { - handles[nhandles].dev = statb.st_dev; -#ifdef __VMS - handles[nhandles].ino[0] = statb.st_ino[0]; - handles[nhandles].ino[1] = statb.st_ino[1]; - handles[nhandles].ino[2] = statb.st_ino[2]; -#else - handles[nhandles].ino = statb.st_ino; -#endif - } - } - -#if !(defined(PYOS_OS2) && defined(PYCC_GCC)) - dlopenflags = PyThreadState_Get()->interp->dlopenflags; -#endif - - if (Py_VerboseFlag) - printf("dlopen(\"%s\", %x);\n", pathname, dlopenflags); - -#ifdef __VMS - /* VMS currently don't allow a pathname, use a logical name instead */ - /* Concatenate 'python_module_' and shortname */ - /* so "import vms.bar" will use the logical python_module_bar */ - /* As C module use only one name space this is probably not a */ - /* important limitation */ - PyOS_snprintf(pathbuf, sizeof(pathbuf), "python_module_%-.200s", - shortname); - pathname = pathbuf; -#endif - - handle = dlopen(pathname, dlopenflags); - - if (handle == NULL) { - PyErr_SetString(PyExc_ImportError, dlerror()); - return NULL; - } - if (fp != NULL && nhandles < 128) - handles[nhandles++].handle = handle; - p = (dl_funcptr) dlsym(handle, funcname); - return p; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_stub.c b/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_stub.c deleted file mode 100644 index 80f4abf8..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_stub.c +++ /dev/null @@ -1,11 +0,0 @@ - -/* This module provides the necessary stubs for when dynamic loading is - not present. */ - -#include "Python.h" -#include "importdl.h" - - -const struct filedescr _PyImport_DynLoadFiletab[] = { - {0, 0} -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_win.c b/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_win.c deleted file mode 100644 index 6ccac785..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/dynload_win.c +++ /dev/null @@ -1,252 +0,0 @@ - -/* Support for dynamic loading of extension modules */ - -#include "Python.h" - -#ifdef MS_XBOX -#include -#else -#include -#endif -#include -#include - -#include "importdl.h" - -const struct filedescr _PyImport_DynLoadFiletab[] = { -#ifdef _DEBUG - {"_d.pyd", "rb", C_EXTENSION}, - {"_d.dll", "rb", C_EXTENSION}, -#else - {".pyd", "rb", C_EXTENSION}, - {".dll", "rb", C_EXTENSION}, -#endif - {0, 0} -}; - - -/* Case insensitive string compare, to avoid any dependencies on particular - C RTL implementations */ - -static int strcasecmp (char *string1, char *string2) -{ - int first, second; - - do { - first = tolower(*string1); - second = tolower(*string2); - string1++; - string2++; - } while (first && first == second); - - return (first - second); -} - - -/* Function to return the name of the "python" DLL that the supplied module - directly imports. Looks through the list of imported modules and - returns the first entry that starts with "python" (case sensitive) and - is followed by nothing but numbers until the separator (period). - - Returns a pointer to the import name, or NULL if no matching name was - located. - - This function parses through the PE header for the module as loaded in - memory by the system loader. The PE header is accessed as documented by - Microsoft in the MSDN PE and COFF specification (2/99), and handles - both PE32 and PE32+. It only worries about the direct import table and - not the delay load import table since it's unlikely an extension is - going to be delay loading Python (after all, it's already loaded). - - If any magic values are not found (e.g., the PE header or optional - header magic), then this function simply returns NULL. */ - -#define DWORD_AT(mem) (*(DWORD *)(mem)) -#define WORD_AT(mem) (*(WORD *)(mem)) - -static char *GetPythonImport (HINSTANCE hModule) -{ - unsigned char *dllbase, *import_data, *import_name; - DWORD pe_offset, opt_offset; - WORD opt_magic; - int num_dict_off, import_off; - - /* Safety check input */ - if (hModule == NULL) { - return NULL; - } - - /* Module instance is also the base load address. First portion of - memory is the MS-DOS loader, which holds the offset to the PE - header (from the load base) at 0x3C */ - dllbase = (unsigned char *)hModule; - pe_offset = DWORD_AT(dllbase + 0x3C); - - /* The PE signature must be "PE\0\0" */ - if (memcmp(dllbase+pe_offset,"PE\0\0",4)) { - return NULL; - } - - /* Following the PE signature is the standard COFF header (20 - bytes) and then the optional header. The optional header starts - with a magic value of 0x10B for PE32 or 0x20B for PE32+ (PE32+ - uses 64-bits for some fields). It might also be 0x107 for a ROM - image, but we don't process that here. - - The optional header ends with a data dictionary that directly - points to certain types of data, among them the import entries - (in the second table entry). Based on the header type, we - determine offsets for the data dictionary count and the entry - within the dictionary pointing to the imports. */ - - opt_offset = pe_offset + 4 + 20; - opt_magic = WORD_AT(dllbase+opt_offset); - if (opt_magic == 0x10B) { - /* PE32 */ - num_dict_off = 92; - import_off = 104; - } else if (opt_magic == 0x20B) { - /* PE32+ */ - num_dict_off = 108; - import_off = 120; - } else { - /* Unsupported */ - return NULL; - } - - /* Now if an import table exists, offset to it and walk the list of - imports. The import table is an array (ending when an entry has - empty values) of structures (20 bytes each), which contains (at - offset 12) a relative address (to the module base) at which a - string constant holding the import name is located. */ - - if (DWORD_AT(dllbase + opt_offset + num_dict_off) >= 2) { - import_data = dllbase + DWORD_AT(dllbase + - opt_offset + - import_off); - while (DWORD_AT(import_data)) { - import_name = dllbase + DWORD_AT(import_data+12); - if (strlen(import_name) >= 6 && - !strncmp(import_name,"python",6)) { - char *pch; - - /* Ensure python prefix is followed only - by numbers to the end of the basename */ - pch = import_name + 6; - while (*pch && *pch != '.') { - if (*pch >= '0' && *pch <= '9') { - pch++; - } else { - pch = NULL; - break; - } - } - - if (pch) { - /* Found it - return the name */ - return import_name; - } - } - import_data += 20; - } - } - - return NULL; -} - - -dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, - const char *pathname, FILE *fp) -{ -#ifdef MS_XBOX - return NULL; -#else - dl_funcptr p; - char funcname[258], *import_python; - - PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname); - - { - HINSTANCE hDLL = NULL; - char pathbuf[260]; - LPTSTR dummy; - /* We use LoadLibraryEx so Windows looks for dependent DLLs - in directory of pathname first. However, Windows95 - can sometimes not work correctly unless the absolute - path is used. If GetFullPathName() fails, the LoadLibrary - will certainly fail too, so use its error code */ - if (GetFullPathName(pathname, - sizeof(pathbuf), - pathbuf, - &dummy)) - /* XXX This call doesn't exist in Windows CE */ - hDLL = LoadLibraryEx(pathname, NULL, - LOAD_WITH_ALTERED_SEARCH_PATH); - if (hDLL==NULL){ - char errBuf[256]; - unsigned int errorCode; - - /* Get an error string from Win32 error code */ - char theInfo[256]; /* Pointer to error text - from system */ - int theLength; /* Length of error text */ - - errorCode = GetLastError(); - - theLength = FormatMessage( - FORMAT_MESSAGE_FROM_SYSTEM, /* flags */ - NULL, /* message source */ - errorCode, /* the message (error) ID */ - 0, /* default language environment */ - (LPTSTR) theInfo, /* the buffer */ - sizeof(theInfo), /* the buffer size */ - NULL); /* no additional format args. */ - - /* Problem: could not get the error message. - This should not happen if called correctly. */ - if (theLength == 0) { - PyOS_snprintf(errBuf, sizeof(errBuf), - "DLL load failed with error code %d", - errorCode); - } else { - size_t len; - /* For some reason a \r\n - is appended to the text */ - if (theLength >= 2 && - theInfo[theLength-2] == '\r' && - theInfo[theLength-1] == '\n') { - theLength -= 2; - theInfo[theLength] = '\0'; - } - strcpy(errBuf, "DLL load failed: "); - len = strlen(errBuf); - strncpy(errBuf+len, theInfo, - sizeof(errBuf)-len); - errBuf[sizeof(errBuf)-1] = '\0'; - } - PyErr_SetString(PyExc_ImportError, errBuf); - return NULL; - } else { - char buffer[256]; - - PyOS_snprintf(buffer, sizeof(buffer), "python%d%d.dll", - PY_MAJOR_VERSION,PY_MINOR_VERSION); - import_python = GetPythonImport(hDLL); - - if (import_python && - strcasecmp(buffer,import_python)) { - PyOS_snprintf(buffer, sizeof(buffer), - "Module use of %.150s conflicts " - "with this version of Python.", - import_python); - PyErr_SetString(PyExc_ImportError,buffer); - FreeLibrary(hDLL); - return NULL; - } - } - p = GetProcAddress(hDLL, funcname); - } - - return p; -#endif -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/errors.c b/SDKs/XPlatform/Cypython-2.3.3/Python/errors.c deleted file mode 100644 index 5911fa78..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/errors.c +++ /dev/null @@ -1,785 +0,0 @@ - -/* Error handling */ - -#include "Python.h" - -#ifdef macintosh -extern char *PyMac_StrError(int); -#undef strerror -#define strerror PyMac_StrError -#endif /* macintosh */ - -#ifndef __STDC__ -#ifndef MS_WINDOWS -extern char *strerror(int); -#endif -#endif - -#ifdef MS_WINDOWS -#ifdef MS_XBOX -#include -#else -#include -#endif -#include "winbase.h" -#endif - -#include - -void -PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback) -{ - PyThreadState *tstate = PyThreadState_GET(); - PyObject *oldtype, *oldvalue, *oldtraceback; - - if (traceback != NULL && !PyTraceBack_Check(traceback)) { - /* XXX Should never happen -- fatal error instead? */ - Py_DECREF(traceback); - traceback = NULL; - } - - /* Save these in locals to safeguard against recursive - invocation through Py_XDECREF */ - oldtype = tstate->curexc_type; - oldvalue = tstate->curexc_value; - oldtraceback = tstate->curexc_traceback; - - tstate->curexc_type = type; - tstate->curexc_value = value; - tstate->curexc_traceback = traceback; - - Py_XDECREF(oldtype); - Py_XDECREF(oldvalue); - Py_XDECREF(oldtraceback); -} - -void -PyErr_SetObject(PyObject *exception, PyObject *value) -{ - Py_XINCREF(exception); - Py_XINCREF(value); - PyErr_Restore(exception, value, (PyObject *)NULL); -} - -void -PyErr_SetNone(PyObject *exception) -{ - PyErr_SetObject(exception, (PyObject *)NULL); -} - -void -PyErr_SetString(PyObject *exception, const char *string) -{ - PyObject *value = PyString_FromString(string); - PyErr_SetObject(exception, value); - Py_XDECREF(value); -} - - -PyObject * -PyErr_Occurred(void) -{ - PyThreadState *tstate = PyThreadState_GET(); - - return tstate->curexc_type; -} - - -int -PyErr_GivenExceptionMatches(PyObject *err, PyObject *exc) -{ - if (err == NULL || exc == NULL) { - /* maybe caused by "import exceptions" that failed early on */ - return 0; - } - if (PyTuple_Check(exc)) { - int i, n; - n = PyTuple_Size(exc); - for (i = 0; i < n; i++) { - /* Test recursively */ - if (PyErr_GivenExceptionMatches( - err, PyTuple_GET_ITEM(exc, i))) - { - return 1; - } - } - return 0; - } - /* err might be an instance, so check its class. */ - if (PyInstance_Check(err)) - err = (PyObject*)((PyInstanceObject*)err)->in_class; - - if (PyClass_Check(err) && PyClass_Check(exc)) - return PyClass_IsSubclass(err, exc); - - return err == exc; -} - - -int -PyErr_ExceptionMatches(PyObject *exc) -{ - return PyErr_GivenExceptionMatches(PyErr_Occurred(), exc); -} - - -/* Used in many places to normalize a raised exception, including in - eval_code2(), do_raise(), and PyErr_Print() -*/ -void -PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb) -{ - PyObject *type = *exc; - PyObject *value = *val; - PyObject *inclass = NULL; - PyObject *initial_tb = NULL; - - if (type == NULL) { - /* There was no exception, so nothing to do. */ - return; - } - - /* If PyErr_SetNone() was used, the value will have been actually - set to NULL. - */ - if (!value) { - value = Py_None; - Py_INCREF(value); - } - - if (PyInstance_Check(value)) - inclass = (PyObject*)((PyInstanceObject*)value)->in_class; - - /* Normalize the exception so that if the type is a class, the - value will be an instance. - */ - if (PyClass_Check(type)) { - /* if the value was not an instance, or is not an instance - whose class is (or is derived from) type, then use the - value as an argument to instantiation of the type - class. - */ - if (!inclass || !PyClass_IsSubclass(inclass, type)) { - PyObject *args, *res; - - if (value == Py_None) - args = Py_BuildValue("()"); - else if (PyTuple_Check(value)) { - Py_INCREF(value); - args = value; - } - else - args = Py_BuildValue("(O)", value); - - if (args == NULL) - goto finally; - res = PyEval_CallObject(type, args); - Py_DECREF(args); - if (res == NULL) - goto finally; - Py_DECREF(value); - value = res; - } - /* if the class of the instance doesn't exactly match the - class of the type, believe the instance - */ - else if (inclass != type) { - Py_DECREF(type); - type = inclass; - Py_INCREF(type); - } - } - *exc = type; - *val = value; - return; -finally: - Py_DECREF(type); - Py_DECREF(value); - /* If the new exception doesn't set a traceback and the old - exception had a traceback, use the old traceback for the - new exception. It's better than nothing. - */ - initial_tb = *tb; - PyErr_Fetch(exc, val, tb); - if (initial_tb != NULL) { - if (*tb == NULL) - *tb = initial_tb; - else - Py_DECREF(initial_tb); - } - /* normalize recursively */ - PyErr_NormalizeException(exc, val, tb); -} - - -void -PyErr_Fetch(PyObject **p_type, PyObject **p_value, PyObject **p_traceback) -{ - PyThreadState *tstate = PyThreadState_Get(); - - *p_type = tstate->curexc_type; - *p_value = tstate->curexc_value; - *p_traceback = tstate->curexc_traceback; - - tstate->curexc_type = NULL; - tstate->curexc_value = NULL; - tstate->curexc_traceback = NULL; -} - -void -PyErr_Clear(void) -{ - PyErr_Restore(NULL, NULL, NULL); -} - -/* Convenience functions to set a type error exception and return 0 */ - -int -PyErr_BadArgument(void) -{ - PyErr_SetString(PyExc_TypeError, - "bad argument type for built-in operation"); - return 0; -} - -PyObject * -PyErr_NoMemory(void) -{ - if (PyErr_ExceptionMatches(PyExc_MemoryError)) - /* already current */ - return NULL; - - /* raise the pre-allocated instance if it still exists */ - if (PyExc_MemoryErrorInst) - PyErr_SetObject(PyExc_MemoryError, PyExc_MemoryErrorInst); - else - /* this will probably fail since there's no memory and hee, - hee, we have to instantiate this class - */ - PyErr_SetNone(PyExc_MemoryError); - - return NULL; -} - -PyObject * -PyErr_SetFromErrnoWithFilenameObject(PyObject *exc, PyObject *filenameObject) -{ - PyObject *v; - char *s; - int i = errno; -#ifdef PLAN9 - char errbuf[ERRMAX]; -#endif -#ifdef MS_WINDOWS - char *s_buf = NULL; - char s_small_buf[28]; /* Room for "Windows Error 0xFFFFFFFF" */ -#endif -#ifdef EINTR - if (i == EINTR && PyErr_CheckSignals()) - return NULL; -#endif -#ifdef PLAN9 - rerrstr(errbuf, sizeof errbuf); - s = errbuf; -#else - if (i == 0) - s = "Error"; /* Sometimes errno didn't get set */ - else -#if defined(MS_XBOX) || !defined(MS_WINDOWS) - s = strerror(i); -#else - { - /* Note that the Win32 errors do not lineup with the - errno error. So if the error is in the MSVC error - table, we use it, otherwise we assume it really _is_ - a Win32 error code - */ - if (i > 0 && i < _sys_nerr) { - s = _sys_errlist[i]; - } - else { - int len = FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, /* no message source */ - i, - MAKELANGID(LANG_NEUTRAL, - SUBLANG_DEFAULT), - /* Default language */ - (LPTSTR) &s_buf, - 0, /* size not used */ - NULL); /* no args */ - if (len==0) { - /* Only ever seen this in out-of-mem - situations */ - sprintf(s_small_buf, "Windows Error 0x%X", i); - s = s_small_buf; - s_buf = NULL; - } else { - s = s_buf; - /* remove trailing cr/lf and dots */ - while (len > 0 && (s[len-1] <= ' ' || s[len-1] == '.')) - s[--len] = '\0'; - } - } - } -#endif /* Unix/Windows */ -#endif /* PLAN 9*/ - if (filenameObject != NULL) - v = Py_BuildValue("(isO)", i, s, filenameObject); - else - v = Py_BuildValue("(is)", i, s); - if (v != NULL) { - PyErr_SetObject(exc, v); - Py_DECREF(v); - } -#ifdef MS_WINDOWS - LocalFree(s_buf); -#endif - return NULL; -} - - -PyObject * -PyErr_SetFromErrnoWithFilename(PyObject *exc, char *filename) -{ - PyObject *name = filename ? PyString_FromString(filename) : NULL; - PyObject *result = PyErr_SetFromErrnoWithFilenameObject(exc, name); - Py_XDECREF(name); - return result; -} - -#ifdef Py_WIN_WIDE_FILENAMES -PyObject * -PyErr_SetFromErrnoWithUnicodeFilename(PyObject *exc, Py_UNICODE *filename) -{ - PyObject *name = filename ? - PyUnicode_FromUnicode(filename, wcslen(filename)) : - NULL; - PyObject *result = PyErr_SetFromErrnoWithFilenameObject(exc, name); - Py_XDECREF(name); - return result; -} -#endif /* Py_WIN_WIDE_FILENAMES */ - -PyObject * -PyErr_SetFromErrno(PyObject *exc) -{ - return PyErr_SetFromErrnoWithFilenameObject(exc, NULL); -} - -#ifdef MS_WINDOWS -/* Windows specific error code handling */ -PyObject *PyErr_SetExcFromWindowsErrWithFilenameObject( - PyObject *exc, - int ierr, - PyObject *filenameObject) -{ - int len; - char *s; - char *s_buf = NULL; /* Free via LocalFree */ - char s_small_buf[28]; /* Room for "Windows Error 0xFFFFFFFF" */ - PyObject *v; - DWORD err = (DWORD)ierr; - if (err==0) err = GetLastError(); -#ifdef MS_XBOX - len = 0; -#else - len = FormatMessage( - /* Error API error */ - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, /* no message source */ - err, - MAKELANGID(LANG_NEUTRAL, - SUBLANG_DEFAULT), /* Default language */ - (LPTSTR) &s_buf, - 0, /* size not used */ - NULL); /* no args */ -#endif // !MS_XBOX - if (len==0) { - /* Only seen this in out of mem situations */ - sprintf(s_small_buf, "Windows Error 0x%X", err); - s = s_small_buf; - s_buf = NULL; - } else { - s = s_buf; - /* remove trailing cr/lf and dots */ - while (len > 0 && (s[len-1] <= ' ' || s[len-1] == '.')) - s[--len] = '\0'; - } - if (filenameObject != NULL) - v = Py_BuildValue("(isO)", err, s, filenameObject); - else - v = Py_BuildValue("(is)", err, s); - if (v != NULL) { - PyErr_SetObject(exc, v); - Py_DECREF(v); - } - LocalFree(s_buf); - return NULL; -} - -PyObject *PyErr_SetExcFromWindowsErrWithFilename( - PyObject *exc, - int ierr, - const char *filename) -{ - PyObject *name = filename ? PyString_FromString(filename) : NULL; - PyObject *ret = PyErr_SetExcFromWindowsErrWithFilenameObject(exc, - ierr, - name); - Py_XDECREF(name); - return ret; -} - -#ifdef Py_WIN_WIDE_FILENAMES -PyObject *PyErr_SetExcFromWindowsErrWithUnicodeFilename( - PyObject *exc, - int ierr, - const Py_UNICODE *filename) -{ - PyObject *name = filename ? - PyUnicode_FromUnicode(filename, wcslen(filename)) : - NULL; - PyObject *ret = PyErr_SetExcFromWindowsErrWithFilenameObject(exc, - ierr, - name); - Py_XDECREF(name); - return ret; -} -#endif /* Py_WIN_WIDE_FILENAMES */ - -PyObject *PyErr_SetExcFromWindowsErr(PyObject *exc, int ierr) -{ - return PyErr_SetExcFromWindowsErrWithFilename(exc, ierr, NULL); -} - -PyObject *PyErr_SetFromWindowsErr(int ierr) -{ - return PyErr_SetExcFromWindowsErrWithFilename(PyExc_WindowsError, - ierr, NULL); -} -PyObject *PyErr_SetFromWindowsErrWithFilename( - int ierr, - const char *filename) -{ - PyObject *name = filename ? PyString_FromString(filename) : NULL; - PyObject *result = PyErr_SetExcFromWindowsErrWithFilenameObject( - PyExc_WindowsError, - ierr, name); - Py_XDECREF(name); - return result; -} - -#ifdef Py_WIN_WIDE_FILENAMES -PyObject *PyErr_SetFromWindowsErrWithUnicodeFilename( - int ierr, - const Py_UNICODE *filename) -{ - PyObject *name = filename ? - PyUnicode_FromUnicode(filename, wcslen(filename)) : - NULL; - PyObject *result = PyErr_SetExcFromWindowsErrWithFilenameObject( - PyExc_WindowsError, - ierr, name); - Py_XDECREF(name); - return result; -} -#endif /* Py_WIN_WIDE_FILENAMES */ -#endif /* MS_WINDOWS */ - -void -_PyErr_BadInternalCall(char *filename, int lineno) -{ - PyErr_Format(PyExc_SystemError, - "%s:%d: bad argument to internal function", - filename, lineno); -} - -/* Remove the preprocessor macro for PyErr_BadInternalCall() so that we can - export the entry point for existing object code: */ -#undef PyErr_BadInternalCall -void -PyErr_BadInternalCall(void) -{ - PyErr_Format(PyExc_SystemError, - "bad argument to internal function"); -} -#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__) - - - -PyObject * -PyErr_Format(PyObject *exception, const char *format, ...) -{ - va_list vargs; - PyObject* string; - -#ifdef HAVE_STDARG_PROTOTYPES - va_start(vargs, format); -#else - va_start(vargs); -#endif - - string = PyString_FromFormatV(format, vargs); - PyErr_SetObject(exception, string); - Py_XDECREF(string); - va_end(vargs); - return NULL; -} - - -PyObject * -PyErr_NewException(char *name, PyObject *base, PyObject *dict) -{ - char *dot; - PyObject *modulename = NULL; - PyObject *classname = NULL; - PyObject *mydict = NULL; - PyObject *bases = NULL; - PyObject *result = NULL; - dot = strrchr(name, '.'); - if (dot == NULL) { - PyErr_SetString(PyExc_SystemError, - "PyErr_NewException: name must be module.class"); - return NULL; - } - if (base == NULL) - base = PyExc_Exception; - if (!PyClass_Check(base)) { - /* Must be using string-based standard exceptions (-X) */ - return PyString_FromString(name); - } - if (dict == NULL) { - dict = mydict = PyDict_New(); - if (dict == NULL) - goto failure; - } - if (PyDict_GetItemString(dict, "__module__") == NULL) { - modulename = PyString_FromStringAndSize(name, (int)(dot-name)); - if (modulename == NULL) - goto failure; - if (PyDict_SetItemString(dict, "__module__", modulename) != 0) - goto failure; - } - classname = PyString_FromString(dot+1); - if (classname == NULL) - goto failure; - bases = Py_BuildValue("(O)", base); - if (bases == NULL) - goto failure; - result = PyClass_New(bases, dict, classname); - failure: - Py_XDECREF(bases); - Py_XDECREF(mydict); - Py_XDECREF(classname); - Py_XDECREF(modulename); - return result; -} - -/* Call when an exception has occurred but there is no way for Python - to handle it. Examples: exception in __del__ or during GC. */ -void -PyErr_WriteUnraisable(PyObject *obj) -{ - PyObject *f, *t, *v, *tb; - PyErr_Fetch(&t, &v, &tb); - f = PySys_GetObject("stderr"); - if (f != NULL) { - PyFile_WriteString("Exception ", f); - if (t) { - PyFile_WriteObject(t, f, Py_PRINT_RAW); - if (v && v != Py_None) { - PyFile_WriteString(": ", f); - PyFile_WriteObject(v, f, 0); - } - } - PyFile_WriteString(" in ", f); - PyFile_WriteObject(obj, f, 0); - PyFile_WriteString(" ignored\n", f); - PyErr_Clear(); /* Just in case */ - } - Py_XDECREF(t); - Py_XDECREF(v); - Py_XDECREF(tb); -} - -extern PyObject *PyModule_GetWarningsModule(); - -/* Function to issue a warning message; may raise an exception. */ -int -PyErr_Warn(PyObject *category, char *message) -{ - PyObject *dict, *func = NULL; - PyObject *warnings_module = PyModule_GetWarningsModule(); - - if (warnings_module != NULL) { - dict = PyModule_GetDict(warnings_module); - func = PyDict_GetItemString(dict, "warn"); - } - if (func == NULL) { - PySys_WriteStderr("warning: %s\n", message); - return 0; - } - else { - PyObject *args, *res; - - if (category == NULL) - category = PyExc_RuntimeWarning; - args = Py_BuildValue("(sO)", message, category); - if (args == NULL) - return -1; - res = PyEval_CallObject(func, args); - Py_DECREF(args); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; - } -} - - -/* Warning with explicit origin */ -int -PyErr_WarnExplicit(PyObject *category, const char *message, - const char *filename, int lineno, - const char *module, PyObject *registry) -{ - PyObject *mod, *dict, *func = NULL; - - mod = PyImport_ImportModule("warnings"); - if (mod != NULL) { - dict = PyModule_GetDict(mod); - func = PyDict_GetItemString(dict, "warn_explicit"); - Py_DECREF(mod); - } - if (func == NULL) { - PySys_WriteStderr("warning: %s\n", message); - return 0; - } - else { - PyObject *args, *res; - - if (category == NULL) - category = PyExc_RuntimeWarning; - if (registry == NULL) - registry = Py_None; - args = Py_BuildValue("(sOsizO)", message, category, - filename, lineno, module, registry); - if (args == NULL) - return -1; - res = PyEval_CallObject(func, args); - Py_DECREF(args); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; - } -} - - -/* Set file and line information for the current exception. - If the exception is not a SyntaxError, also sets additional attributes - to make printing of exceptions believe it is a syntax error. */ - -void -PyErr_SyntaxLocation(const char *filename, int lineno) -{ - PyObject *exc, *v, *tb, *tmp; - - /* add attributes for the line number and filename for the error */ - PyErr_Fetch(&exc, &v, &tb); - PyErr_NormalizeException(&exc, &v, &tb); - /* XXX check that it is, indeed, a syntax error */ - tmp = PyInt_FromLong(lineno); - if (tmp == NULL) - PyErr_Clear(); - else { - if (PyObject_SetAttrString(v, "lineno", tmp)) - PyErr_Clear(); - Py_DECREF(tmp); - } - if (filename != NULL) { - tmp = PyString_FromString(filename); - if (tmp == NULL) - PyErr_Clear(); - else { - if (PyObject_SetAttrString(v, "filename", tmp)) - PyErr_Clear(); - Py_DECREF(tmp); - } - - tmp = PyErr_ProgramText(filename, lineno); - if (tmp) { - PyObject_SetAttrString(v, "text", tmp); - Py_DECREF(tmp); - } - } - if (PyObject_SetAttrString(v, "offset", Py_None)) { - PyErr_Clear(); - } - if (exc != PyExc_SyntaxError) { - if (!PyObject_HasAttrString(v, "msg")) { - tmp = PyObject_Str(v); - if (tmp) { - if (PyObject_SetAttrString(v, "msg", tmp)) - PyErr_Clear(); - Py_DECREF(tmp); - } else { - PyErr_Clear(); - } - } - if (!PyObject_HasAttrString(v, "print_file_and_line")) { - if (PyObject_SetAttrString(v, "print_file_and_line", - Py_None)) - PyErr_Clear(); - } - } - PyErr_Restore(exc, v, tb); -} - -/* com_fetch_program_text will attempt to load the line of text that - the exception refers to. If it fails, it will return NULL but will - not set an exception. - - XXX The functionality of this function is quite similar to the - functionality in tb_displayline() in traceback.c. -*/ - -PyObject * -PyErr_ProgramText(const char *filename, int lineno) -{ - FILE *fp; - int i; - char linebuf[1000]; - - if (filename == NULL || lineno <= 0) - return NULL; - fp = fopen(filename, "r" PY_STDIOTEXTMODE); - if (fp == NULL) - return NULL; - for (i = 0; i < lineno; i++) { - char *pLastChar = &linebuf[sizeof(linebuf) - 2]; - do { - *pLastChar = '\0'; - if (Py_UniversalNewlineFgets(linebuf, sizeof linebuf, fp, NULL) == NULL) - break; - /* fgets read *something*; if it didn't get as - far as pLastChar, it must have found a newline - or hit the end of the file; if pLastChar is \n, - it obviously found a newline; else we haven't - yet seen a newline, so must continue */ - } while (*pLastChar != '\0' && *pLastChar != '\n'); - } - fclose(fp); - if (i == lineno) { - char *p = linebuf; - while (*p == ' ' || *p == '\t' || *p == '\014') - p++; - return PyString_FromString(p); - } - return NULL; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/exceptions.c b/SDKs/XPlatform/Cypython-2.3.3/Python/exceptions.c deleted file mode 100644 index 9a6bbba7..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/exceptions.c +++ /dev/null @@ -1,1857 +0,0 @@ -/* This module provides the suite of standard class-based exceptions for - * Python's builtin module. This is a complete C implementation of what, - * in Python 1.5.2, was contained in the exceptions.py module. The problem - * there was that if exceptions.py could not be imported for some reason, - * the entire interpreter would abort. - * - * By moving the exceptions into C and statically linking, we can guarantee - * that the standard exceptions will always be available. - * - * history: - * 98-08-19 fl created (for pyexe) - * 00-02-08 fl updated for 1.5.2 - * 26-May-2000 baw vetted for Python 1.6 - * - * written by Fredrik Lundh - * modifications, additions, cleanups, and proofreading by Barry Warsaw - * - * Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. - */ - -#include "Python.h" -#include "osdefs.h" - -/* Caution: MS Visual C++ 6 errors if a single string literal exceeds - * 2Kb. So the module docstring has been broken roughly in half, using - * compile-time literal concatenation. - */ - -/* NOTE: If the exception class hierarchy changes, don't forget to update - * Doc/lib/libexcs.tex! - */ - -PyDoc_STRVAR(module__doc__, -"Python's standard exception class hierarchy.\n\ -\n\ -Before Python 1.5, the standard exceptions were all simple string objects.\n\ -In Python 1.5, the standard exceptions were converted to classes organized\n\ -into a relatively flat hierarchy. String-based standard exceptions were\n\ -optional, or used as a fallback if some problem occurred while importing\n\ -the exception module. With Python 1.6, optional string-based standard\n\ -exceptions were removed (along with the -X command line flag).\n\ -\n\ -The class exceptions were implemented in such a way as to be almost\n\ -completely backward compatible. Some tricky uses of IOError could\n\ -potentially have broken, but by Python 1.6, all of these should have\n\ -been fixed. As of Python 1.6, the class-based standard exceptions are\n\ -now implemented in C, and are guaranteed to exist in the Python\n\ -interpreter.\n\ -\n\ -Here is a rundown of the class hierarchy. The classes found here are\n\ -inserted into both the exceptions module and the `built-in' module. It is\n\ -recommended that user defined class based exceptions be derived from the\n\ -`Exception' class, although this is currently not enforced.\n" - /* keep string pieces "small" */ -"\n\ -Exception\n\ - |\n\ - +-- SystemExit\n\ - +-- StopIteration\n\ - +-- StandardError\n\ - | |\n\ - | +-- KeyboardInterrupt\n\ - | +-- ImportError\n\ - | +-- EnvironmentError\n\ - | | |\n\ - | | +-- IOError\n\ - | | +-- OSError\n\ - | | |\n\ - | | +-- WindowsError\n\ - | | +-- VMSError\n\ - | |\n\ - | +-- EOFError\n\ - | +-- RuntimeError\n\ - | | |\n\ - | | +-- NotImplementedError\n\ - | |\n\ - | +-- NameError\n\ - | | |\n\ - | | +-- UnboundLocalError\n\ - | |\n\ - | +-- AttributeError\n\ - | +-- SyntaxError\n\ - | | |\n\ - | | +-- IndentationError\n\ - | | |\n\ - | | +-- TabError\n\ - | |\n\ - | +-- TypeError\n\ - | +-- AssertionError\n\ - | +-- LookupError\n\ - | | |\n\ - | | +-- IndexError\n\ - | | +-- KeyError\n\ - | |\n\ - | +-- ArithmeticError\n\ - | | |\n\ - | | +-- OverflowError\n\ - | | +-- ZeroDivisionError\n\ - | | +-- FloatingPointError\n\ - | |\n\ - | +-- ValueError\n\ - | | |\n\ - | | +-- UnicodeError\n\ - | | |\n\ - | | +-- UnicodeEncodeError\n\ - | | +-- UnicodeDecodeError\n\ - | | +-- UnicodeTranslateError\n\ - | |\n\ - | +-- ReferenceError\n\ - | +-- SystemError\n\ - | +-- MemoryError\n\ - |\n\ - +---Warning\n\ - |\n\ - +-- UserWarning\n\ - +-- DeprecationWarning\n\ - +-- PendingDeprecationWarning\n\ - +-- SyntaxWarning\n\ - +-- OverflowWarning\n\ - +-- RuntimeWarning\n\ - +-- FutureWarning" -); - - -/* Helper function for populating a dictionary with method wrappers. */ -static int -populate_methods(PyObject *klass, PyObject *dict, PyMethodDef *methods) -{ - PyObject *module; - int status = -1; - - if (!methods) - return 0; - - module = PyString_FromString("exceptions"); - if (!module) - return 0; - while (methods->ml_name) { - /* get a wrapper for the built-in function */ - PyObject *func = PyCFunction_NewEx(methods, NULL, module); - PyObject *meth; - - if (!func) - goto status; - - /* turn the function into an unbound method */ - if (!(meth = PyMethod_New(func, NULL, klass))) { - Py_DECREF(func); - goto status; - } - - /* add method to dictionary */ - status = PyDict_SetItemString(dict, methods->ml_name, meth); - Py_DECREF(meth); - Py_DECREF(func); - - /* stop now if an error occurred, otherwise do the next method */ - if (status) - goto status; - - methods++; - } - status = 0; - status: - Py_DECREF(module); - return status; -} - - - -/* This function is used to create all subsequent exception classes. */ -static int -make_class(PyObject **klass, PyObject *base, - char *name, PyMethodDef *methods, - char *docstr) -{ - PyObject *dict = PyDict_New(); - PyObject *str = NULL; - int status = -1; - - if (!dict) - return -1; - - /* If an error occurs from here on, goto finally instead of explicitly - * returning NULL. - */ - - if (docstr) { - if (!(str = PyString_FromString(docstr))) - goto finally; - if (PyDict_SetItemString(dict, "__doc__", str)) - goto finally; - } - - if (!(*klass = PyErr_NewException(name, base, dict))) - goto finally; - - if (populate_methods(*klass, dict, methods)) { - Py_DECREF(*klass); - *klass = NULL; - goto finally; - } - - status = 0; - - finally: - Py_XDECREF(dict); - Py_XDECREF(str); - return status; -} - - -/* Use this for *args signatures, otherwise just use PyArg_ParseTuple() */ -static PyObject * -get_self(PyObject *args) -{ - PyObject *self = PyTuple_GetItem(args, 0); - if (!self) { - /* Watch out for being called to early in the bootstrapping process */ - if (PyExc_TypeError) { - PyErr_SetString(PyExc_TypeError, - "unbound method must be called with instance as first argument"); - } - return NULL; - } - return self; -} - - - -/* Notes on bootstrapping the exception classes. - * - * First thing we create is the base class for all exceptions, called - * appropriately enough: Exception. Creation of this class makes no - * assumptions about the existence of any other exception class -- except - * for TypeError, which can conditionally exist. - * - * Next, StandardError is created (which is quite simple) followed by - * TypeError, because the instantiation of other exceptions can potentially - * throw a TypeError. Once these exceptions are created, all the others - * can be created in any order. See the static exctable below for the - * explicit bootstrap order. - * - * All classes after Exception can be created using PyErr_NewException(). - */ - -PyDoc_STRVAR(Exception__doc__, "Common base class for all exceptions."); - - -static PyObject * -Exception__init__(PyObject *self, PyObject *args) -{ - int status; - - if (!(self = get_self(args))) - return NULL; - - /* set args attribute */ - /* XXX size is only a hint */ - args = PySequence_GetSlice(args, 1, PySequence_Size(args)); - if (!args) - return NULL; - status = PyObject_SetAttrString(self, "args", args); - Py_DECREF(args); - if (status < 0) - return NULL; - - Py_INCREF(Py_None); - return Py_None; -} - - -static PyObject * -Exception__str__(PyObject *self, PyObject *args) -{ - PyObject *out; - - if (!PyArg_ParseTuple(args, "O:__str__", &self)) - return NULL; - - args = PyObject_GetAttrString(self, "args"); - if (!args) - return NULL; - - switch (PySequence_Size(args)) { - case 0: - out = PyString_FromString(""); - break; - case 1: - { - PyObject *tmp = PySequence_GetItem(args, 0); - if (tmp) { - out = PyObject_Str(tmp); - Py_DECREF(tmp); - } - else - out = NULL; - break; - } - case -1: - PyErr_Clear(); - /* Fall through */ - default: - out = PyObject_Str(args); - break; - } - - Py_DECREF(args); - return out; -} - - -static PyObject * -Exception__getitem__(PyObject *self, PyObject *args) -{ - PyObject *out; - PyObject *index; - - if (!PyArg_ParseTuple(args, "OO:__getitem__", &self, &index)) - return NULL; - - args = PyObject_GetAttrString(self, "args"); - if (!args) - return NULL; - - out = PyObject_GetItem(args, index); - Py_DECREF(args); - return out; -} - - -static PyMethodDef -Exception_methods[] = { - /* methods for the Exception class */ - { "__getitem__", Exception__getitem__, METH_VARARGS}, - { "__str__", Exception__str__, METH_VARARGS}, - { "__init__", Exception__init__, METH_VARARGS}, - { NULL, NULL } -}; - - -static int -make_Exception(char *modulename) -{ - PyObject *dict = PyDict_New(); - PyObject *str = NULL; - PyObject *name = NULL; - int status = -1; - - if (!dict) - return -1; - - /* If an error occurs from here on, goto finally instead of explicitly - * returning NULL. - */ - - if (!(str = PyString_FromString(modulename))) - goto finally; - if (PyDict_SetItemString(dict, "__module__", str)) - goto finally; - Py_DECREF(str); - if (!(str = PyString_FromString(Exception__doc__))) - goto finally; - if (PyDict_SetItemString(dict, "__doc__", str)) - goto finally; - - if (!(name = PyString_FromString("Exception"))) - goto finally; - - if (!(PyExc_Exception = PyClass_New(NULL, dict, name))) - goto finally; - - /* Now populate the dictionary with the method suite */ - if (populate_methods(PyExc_Exception, dict, Exception_methods)) - /* Don't need to reclaim PyExc_Exception here because that'll - * happen during interpreter shutdown. - */ - goto finally; - - status = 0; - - finally: - Py_XDECREF(dict); - Py_XDECREF(str); - Py_XDECREF(name); - return status; -} - - - -PyDoc_STRVAR(StandardError__doc__, -"Base class for all standard Python exceptions."); - -PyDoc_STRVAR(TypeError__doc__, "Inappropriate argument type."); - -PyDoc_STRVAR(StopIteration__doc__, "Signal the end from iterator.next()."); - - - -PyDoc_STRVAR(SystemExit__doc__, "Request to exit from the interpreter."); - - -static PyObject * -SystemExit__init__(PyObject *self, PyObject *args) -{ - PyObject *code; - int status; - - if (!(self = get_self(args))) - return NULL; - - /* Set args attribute. */ - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - status = PyObject_SetAttrString(self, "args", args); - if (status < 0) { - Py_DECREF(args); - return NULL; - } - - /* set code attribute */ - switch (PySequence_Size(args)) { - case 0: - Py_INCREF(Py_None); - code = Py_None; - break; - case 1: - code = PySequence_GetItem(args, 0); - break; - case -1: - PyErr_Clear(); - /* Fall through */ - default: - Py_INCREF(args); - code = args; - break; - } - - status = PyObject_SetAttrString(self, "code", code); - Py_DECREF(code); - Py_DECREF(args); - if (status < 0) - return NULL; - - Py_INCREF(Py_None); - return Py_None; -} - - -static PyMethodDef SystemExit_methods[] = { - { "__init__", SystemExit__init__, METH_VARARGS}, - {NULL, NULL} -}; - - - -PyDoc_STRVAR(KeyboardInterrupt__doc__, "Program interrupted by user."); - -PyDoc_STRVAR(ImportError__doc__, -"Import can't find module, or can't find name in module."); - - - -PyDoc_STRVAR(EnvironmentError__doc__, "Base class for I/O related errors."); - - -static PyObject * -EnvironmentError__init__(PyObject *self, PyObject *args) -{ - PyObject *item0 = NULL; - PyObject *item1 = NULL; - PyObject *item2 = NULL; - PyObject *subslice = NULL; - PyObject *rtnval = NULL; - - if (!(self = get_self(args))) - return NULL; - - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - if (PyObject_SetAttrString(self, "args", args) || - PyObject_SetAttrString(self, "errno", Py_None) || - PyObject_SetAttrString(self, "strerror", Py_None) || - PyObject_SetAttrString(self, "filename", Py_None)) - { - goto finally; - } - - switch (PySequence_Size(args)) { - case 3: - /* Where a function has a single filename, such as open() or some - * of the os module functions, PyErr_SetFromErrnoWithFilename() is - * called, giving a third argument which is the filename. But, so - * that old code using in-place unpacking doesn't break, e.g.: - * - * except IOError, (errno, strerror): - * - * we hack args so that it only contains two items. This also - * means we need our own __str__() which prints out the filename - * when it was supplied. - */ - item0 = PySequence_GetItem(args, 0); - item1 = PySequence_GetItem(args, 1); - item2 = PySequence_GetItem(args, 2); - if (!item0 || !item1 || !item2) - goto finally; - - if (PyObject_SetAttrString(self, "errno", item0) || - PyObject_SetAttrString(self, "strerror", item1) || - PyObject_SetAttrString(self, "filename", item2)) - { - goto finally; - } - - subslice = PySequence_GetSlice(args, 0, 2); - if (!subslice || PyObject_SetAttrString(self, "args", subslice)) - goto finally; - break; - - case 2: - /* Used when PyErr_SetFromErrno() is called and no filename - * argument is given. - */ - item0 = PySequence_GetItem(args, 0); - item1 = PySequence_GetItem(args, 1); - if (!item0 || !item1) - goto finally; - - if (PyObject_SetAttrString(self, "errno", item0) || - PyObject_SetAttrString(self, "strerror", item1)) - { - goto finally; - } - break; - - case -1: - PyErr_Clear(); - break; - } - - Py_INCREF(Py_None); - rtnval = Py_None; - - finally: - Py_DECREF(args); - Py_XDECREF(item0); - Py_XDECREF(item1); - Py_XDECREF(item2); - Py_XDECREF(subslice); - return rtnval; -} - - -static PyObject * -EnvironmentError__str__(PyObject *self, PyObject *args) -{ - PyObject *originalself = self; - PyObject *filename; - PyObject *serrno; - PyObject *strerror; - PyObject *rtnval = NULL; - - if (!PyArg_ParseTuple(args, "O:__str__", &self)) - return NULL; - - filename = PyObject_GetAttrString(self, "filename"); - serrno = PyObject_GetAttrString(self, "errno"); - strerror = PyObject_GetAttrString(self, "strerror"); - if (!filename || !serrno || !strerror) - goto finally; - - if (filename != Py_None) { - PyObject *fmt = PyString_FromString("[Errno %s] %s: %s"); - PyObject *repr = PyObject_Repr(filename); - PyObject *tuple = PyTuple_New(3); - - if (!fmt || !repr || !tuple) { - Py_XDECREF(fmt); - Py_XDECREF(repr); - Py_XDECREF(tuple); - goto finally; - } - - PyTuple_SET_ITEM(tuple, 0, serrno); - PyTuple_SET_ITEM(tuple, 1, strerror); - PyTuple_SET_ITEM(tuple, 2, repr); - - rtnval = PyString_Format(fmt, tuple); - - Py_DECREF(fmt); - Py_DECREF(tuple); - /* already freed because tuple owned only reference */ - serrno = NULL; - strerror = NULL; - } - else if (PyObject_IsTrue(serrno) && PyObject_IsTrue(strerror)) { - PyObject *fmt = PyString_FromString("[Errno %s] %s"); - PyObject *tuple = PyTuple_New(2); - - if (!fmt || !tuple) { - Py_XDECREF(fmt); - Py_XDECREF(tuple); - goto finally; - } - - PyTuple_SET_ITEM(tuple, 0, serrno); - PyTuple_SET_ITEM(tuple, 1, strerror); - - rtnval = PyString_Format(fmt, tuple); - - Py_DECREF(fmt); - Py_DECREF(tuple); - /* already freed because tuple owned only reference */ - serrno = NULL; - strerror = NULL; - } - else - /* The original Python code said: - * - * return StandardError.__str__(self) - * - * but there is no StandardError__str__() function; we happen to - * know that's just a pass through to Exception__str__(). - */ - rtnval = Exception__str__(originalself, args); - - finally: - Py_XDECREF(filename); - Py_XDECREF(serrno); - Py_XDECREF(strerror); - return rtnval; -} - - -static -PyMethodDef EnvironmentError_methods[] = { - {"__init__", EnvironmentError__init__, METH_VARARGS}, - {"__str__", EnvironmentError__str__, METH_VARARGS}, - {NULL, NULL} -}; - - - - -PyDoc_STRVAR(IOError__doc__, "I/O operation failed."); - -PyDoc_STRVAR(OSError__doc__, "OS system call failed."); - -#ifdef MS_WINDOWS -PyDoc_STRVAR(WindowsError__doc__, "MS-Windows OS system call failed."); -#endif /* MS_WINDOWS */ - -#ifdef __VMS -static char -VMSError__doc__[] = "OpenVMS OS system call failed."; -#endif - -PyDoc_STRVAR(EOFError__doc__, "Read beyond end of file."); - -PyDoc_STRVAR(RuntimeError__doc__, "Unspecified run-time error."); - -PyDoc_STRVAR(NotImplementedError__doc__, -"Method or function hasn't been implemented yet."); - -PyDoc_STRVAR(NameError__doc__, "Name not found globally."); - -PyDoc_STRVAR(UnboundLocalError__doc__, -"Local name referenced but not bound to a value."); - -PyDoc_STRVAR(AttributeError__doc__, "Attribute not found."); - - - -PyDoc_STRVAR(SyntaxError__doc__, "Invalid syntax."); - - -static int -SyntaxError__classinit__(PyObject *klass) -{ - int retval = 0; - PyObject *emptystring = PyString_FromString(""); - - /* Additional class-creation time initializations */ - if (!emptystring || - PyObject_SetAttrString(klass, "msg", emptystring) || - PyObject_SetAttrString(klass, "filename", Py_None) || - PyObject_SetAttrString(klass, "lineno", Py_None) || - PyObject_SetAttrString(klass, "offset", Py_None) || - PyObject_SetAttrString(klass, "text", Py_None) || - PyObject_SetAttrString(klass, "print_file_and_line", Py_None)) - { - retval = -1; - } - Py_XDECREF(emptystring); - return retval; -} - - -static PyObject * -SyntaxError__init__(PyObject *self, PyObject *args) -{ - PyObject *rtnval = NULL; - int lenargs; - - if (!(self = get_self(args))) - return NULL; - - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - if (PyObject_SetAttrString(self, "args", args)) - goto finally; - - lenargs = PySequence_Size(args); - if (lenargs >= 1) { - PyObject *item0 = PySequence_GetItem(args, 0); - int status; - - if (!item0) - goto finally; - status = PyObject_SetAttrString(self, "msg", item0); - Py_DECREF(item0); - if (status) - goto finally; - } - if (lenargs == 2) { - PyObject *info = PySequence_GetItem(args, 1); - PyObject *filename = NULL, *lineno = NULL; - PyObject *offset = NULL, *text = NULL; - int status = 1; - - if (!info) - goto finally; - - filename = PySequence_GetItem(info, 0); - if (filename != NULL) { - lineno = PySequence_GetItem(info, 1); - if (lineno != NULL) { - offset = PySequence_GetItem(info, 2); - if (offset != NULL) { - text = PySequence_GetItem(info, 3); - if (text != NULL) { - status = - PyObject_SetAttrString(self, "filename", filename) - || PyObject_SetAttrString(self, "lineno", lineno) - || PyObject_SetAttrString(self, "offset", offset) - || PyObject_SetAttrString(self, "text", text); - Py_DECREF(text); - } - Py_DECREF(offset); - } - Py_DECREF(lineno); - } - Py_DECREF(filename); - } - Py_DECREF(info); - - if (status) - goto finally; - } - Py_INCREF(Py_None); - rtnval = Py_None; - - finally: - Py_DECREF(args); - return rtnval; -} - - -/* This is called "my_basename" instead of just "basename" to avoid name - conflicts with glibc; basename is already prototyped if _GNU_SOURCE is - defined, and Python does define that. */ -static char * -my_basename(char *name) -{ - char *cp = name; - char *result = name; - - if (name == NULL) - return "???"; - while (*cp != '\0') { - if (*cp == SEP) - result = cp + 1; - ++cp; - } - return result; -} - - -static PyObject * -SyntaxError__str__(PyObject *self, PyObject *args) -{ - PyObject *msg; - PyObject *str; - PyObject *filename, *lineno, *result; - - if (!PyArg_ParseTuple(args, "O:__str__", &self)) - return NULL; - - if (!(msg = PyObject_GetAttrString(self, "msg"))) - return NULL; - - str = PyObject_Str(msg); - Py_DECREF(msg); - result = str; - - /* XXX -- do all the additional formatting with filename and - lineno here */ - - if (str != NULL && PyString_Check(str)) { - int have_filename = 0; - int have_lineno = 0; - char *buffer = NULL; - - if ((filename = PyObject_GetAttrString(self, "filename")) != NULL) - have_filename = PyString_Check(filename); - else - PyErr_Clear(); - - if ((lineno = PyObject_GetAttrString(self, "lineno")) != NULL) - have_lineno = PyInt_Check(lineno); - else - PyErr_Clear(); - - if (have_filename || have_lineno) { - int bufsize = PyString_GET_SIZE(str) + 64; - if (have_filename) - bufsize += PyString_GET_SIZE(filename); - - buffer = PyMem_MALLOC(bufsize); - if (buffer != NULL) { - if (have_filename && have_lineno) - PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)", - PyString_AS_STRING(str), - my_basename(PyString_AS_STRING(filename)), - PyInt_AsLong(lineno)); - else if (have_filename) - PyOS_snprintf(buffer, bufsize, "%s (%s)", - PyString_AS_STRING(str), - my_basename(PyString_AS_STRING(filename))); - else if (have_lineno) - PyOS_snprintf(buffer, bufsize, "%s (line %ld)", - PyString_AS_STRING(str), - PyInt_AsLong(lineno)); - - result = PyString_FromString(buffer); - PyMem_FREE(buffer); - - if (result == NULL) - result = str; - else - Py_DECREF(str); - } - } - Py_XDECREF(filename); - Py_XDECREF(lineno); - } - return result; -} - - -static PyMethodDef SyntaxError_methods[] = { - {"__init__", SyntaxError__init__, METH_VARARGS}, - {"__str__", SyntaxError__str__, METH_VARARGS}, - {NULL, NULL} -}; - - -static PyObject * -KeyError__str__(PyObject *self, PyObject *args) -{ - PyObject *argsattr; - PyObject *result; - - if (!PyArg_ParseTuple(args, "O:__str__", &self)) - return NULL; - - if (!(argsattr = PyObject_GetAttrString(self, "args"))) - return NULL; - - /* If args is a tuple of exactly one item, apply repr to args[0]. - This is done so that e.g. the exception raised by {}[''] prints - KeyError: '' - rather than the confusing - KeyError - alone. The downside is that if KeyError is raised with an explanatory - string, that string will be displayed in quotes. Too bad. - If args is anything else, use the default Exception__str__(). - */ - if (PyTuple_Check(argsattr) && PyTuple_GET_SIZE(argsattr) == 1) { - PyObject *key = PyTuple_GET_ITEM(argsattr, 0); - result = PyObject_Repr(key); - } - else - result = Exception__str__(self, args); - - Py_DECREF(argsattr); - return result; -} - -static PyMethodDef KeyError_methods[] = { - {"__str__", KeyError__str__, METH_VARARGS}, - {NULL, NULL} -}; - - -#ifdef Py_USING_UNICODE -static -int get_int(PyObject *exc, const char *name, int *value) -{ - PyObject *attr = PyObject_GetAttrString(exc, (char *)name); - - if (!attr) - return -1; - if (!PyInt_Check(attr)) { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be int", name); - Py_DECREF(attr); - return -1; - } - *value = PyInt_AS_LONG(attr); - Py_DECREF(attr); - return 0; -} - - -static -int set_int(PyObject *exc, const char *name, int value) -{ - PyObject *obj = PyInt_FromLong(value); - int result; - - if (!obj) - return -1; - result = PyObject_SetAttrString(exc, (char *)name, obj); - Py_DECREF(obj); - return result; -} - - -static -PyObject *get_string(PyObject *exc, const char *name) -{ - PyObject *attr = PyObject_GetAttrString(exc, (char *)name); - - if (!attr) - return NULL; - if (!PyString_Check(attr)) { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be str", name); - Py_DECREF(attr); - return NULL; - } - return attr; -} - - -static -int set_string(PyObject *exc, const char *name, const char *value) -{ - PyObject *obj = PyString_FromString(value); - int result; - - if (!obj) - return -1; - result = PyObject_SetAttrString(exc, (char *)name, obj); - Py_DECREF(obj); - return result; -} - - -static -PyObject *get_unicode(PyObject *exc, const char *name) -{ - PyObject *attr = PyObject_GetAttrString(exc, (char *)name); - - if (!attr) - return NULL; - if (!PyUnicode_Check(attr)) { - PyErr_Format(PyExc_TypeError, "%.200s attribute must be unicode", name); - Py_DECREF(attr); - return NULL; - } - return attr; -} - -PyObject * PyUnicodeEncodeError_GetEncoding(PyObject *exc) -{ - return get_string(exc, "encoding"); -} - -PyObject * PyUnicodeDecodeError_GetEncoding(PyObject *exc) -{ - return get_string(exc, "encoding"); -} - -PyObject *PyUnicodeEncodeError_GetObject(PyObject *exc) -{ - return get_unicode(exc, "object"); -} - -PyObject *PyUnicodeDecodeError_GetObject(PyObject *exc) -{ - return get_string(exc, "object"); -} - -PyObject *PyUnicodeTranslateError_GetObject(PyObject *exc) -{ - return get_unicode(exc, "object"); -} - -int PyUnicodeEncodeError_GetStart(PyObject *exc, int *start) -{ - if (!get_int(exc, "start", start)) { - PyObject *object = PyUnicodeEncodeError_GetObject(exc); - int size; - if (!object) - return -1; - size = PyUnicode_GET_SIZE(object); - if (*start<0) - *start = 0; - if (*start>=size) - *start = size-1; - Py_DECREF(object); - return 0; - } - return -1; -} - - -int PyUnicodeDecodeError_GetStart(PyObject *exc, int *start) -{ - if (!get_int(exc, "start", start)) { - PyObject *object = PyUnicodeDecodeError_GetObject(exc); - int size; - if (!object) - return -1; - size = PyString_GET_SIZE(object); - if (*start<0) - *start = 0; - if (*start>=size) - *start = size-1; - Py_DECREF(object); - return 0; - } - return -1; -} - - -int PyUnicodeTranslateError_GetStart(PyObject *exc, int *start) -{ - return PyUnicodeEncodeError_GetStart(exc, start); -} - - -int PyUnicodeEncodeError_SetStart(PyObject *exc, int start) -{ - return set_int(exc, "start", start); -} - - -int PyUnicodeDecodeError_SetStart(PyObject *exc, int start) -{ - return set_int(exc, "start", start); -} - - -int PyUnicodeTranslateError_SetStart(PyObject *exc, int start) -{ - return set_int(exc, "start", start); -} - - -int PyUnicodeEncodeError_GetEnd(PyObject *exc, int *end) -{ - if (!get_int(exc, "end", end)) { - PyObject *object = PyUnicodeEncodeError_GetObject(exc); - int size; - if (!object) - return -1; - size = PyUnicode_GET_SIZE(object); - if (*end<1) - *end = 1; - if (*end>size) - *end = size; - Py_DECREF(object); - return 0; - } - return -1; -} - - -int PyUnicodeDecodeError_GetEnd(PyObject *exc, int *end) -{ - if (!get_int(exc, "end", end)) { - PyObject *object = PyUnicodeDecodeError_GetObject(exc); - int size; - if (!object) - return -1; - size = PyString_GET_SIZE(object); - if (*end<1) - *end = 1; - if (*end>size) - *end = size; - Py_DECREF(object); - return 0; - } - return -1; -} - - -int PyUnicodeTranslateError_GetEnd(PyObject *exc, int *start) -{ - return PyUnicodeEncodeError_GetEnd(exc, start); -} - - -int PyUnicodeEncodeError_SetEnd(PyObject *exc, int end) -{ - return set_int(exc, "end", end); -} - - -int PyUnicodeDecodeError_SetEnd(PyObject *exc, int end) -{ - return set_int(exc, "end", end); -} - - -int PyUnicodeTranslateError_SetEnd(PyObject *exc, int end) -{ - return set_int(exc, "end", end); -} - - -PyObject *PyUnicodeEncodeError_GetReason(PyObject *exc) -{ - return get_string(exc, "reason"); -} - - -PyObject *PyUnicodeDecodeError_GetReason(PyObject *exc) -{ - return get_string(exc, "reason"); -} - - -PyObject *PyUnicodeTranslateError_GetReason(PyObject *exc) -{ - return get_string(exc, "reason"); -} - - -int PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason) -{ - return set_string(exc, "reason", reason); -} - - -int PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason) -{ - return set_string(exc, "reason", reason); -} - - -int PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason) -{ - return set_string(exc, "reason", reason); -} - - -static PyObject * -UnicodeError__init__(PyObject *self, PyObject *args, PyTypeObject *objecttype) -{ - PyObject *rtnval = NULL; - PyObject *encoding; - PyObject *object; - PyObject *start; - PyObject *end; - PyObject *reason; - - if (!(self = get_self(args))) - return NULL; - - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - if (!PyArg_ParseTuple(args, "O!O!O!O!O!", - &PyString_Type, &encoding, - objecttype, &object, - &PyInt_Type, &start, - &PyInt_Type, &end, - &PyString_Type, &reason)) - goto finally; - - if (PyObject_SetAttrString(self, "args", args)) - goto finally; - - if (PyObject_SetAttrString(self, "encoding", encoding)) - goto finally; - if (PyObject_SetAttrString(self, "object", object)) - goto finally; - if (PyObject_SetAttrString(self, "start", start)) - goto finally; - if (PyObject_SetAttrString(self, "end", end)) - goto finally; - if (PyObject_SetAttrString(self, "reason", reason)) - goto finally; - - Py_INCREF(Py_None); - rtnval = Py_None; - - finally: - Py_DECREF(args); - return rtnval; -} - - -static PyObject * -UnicodeEncodeError__init__(PyObject *self, PyObject *args) -{ - return UnicodeError__init__(self, args, &PyUnicode_Type); -} - -static PyObject * -UnicodeEncodeError__str__(PyObject *self, PyObject *arg) -{ - PyObject *encodingObj = NULL; - PyObject *objectObj = NULL; - int start; - int end; - PyObject *reasonObj = NULL; - char buffer[1000]; - PyObject *result = NULL; - - self = arg; - - if (!(encodingObj = PyUnicodeEncodeError_GetEncoding(self))) - goto error; - - if (!(objectObj = PyUnicodeEncodeError_GetObject(self))) - goto error; - - if (PyUnicodeEncodeError_GetStart(self, &start)) - goto error; - - if (PyUnicodeEncodeError_GetEnd(self, &end)) - goto error; - - if (!(reasonObj = PyUnicodeEncodeError_GetReason(self))) - goto error; - - if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(objectObj)[start]; - char *format; - if (badchar <= 0xff) - format = "'%.400s' codec can't encode character u'\\x%02x' in position %d: %.400s"; - else if (badchar <= 0xffff) - format = "'%.400s' codec can't encode character u'\\u%04x' in position %d: %.400s"; - else - format = "'%.400s' codec can't encode character u'\\U%08x' in position %d: %.400s"; - PyOS_snprintf(buffer, sizeof(buffer), - format, - PyString_AS_STRING(encodingObj), - badchar, - start, - PyString_AS_STRING(reasonObj) - ); - } - else { - PyOS_snprintf(buffer, sizeof(buffer), - "'%.400s' codec can't encode characters in position %d-%d: %.400s", - PyString_AS_STRING(encodingObj), - start, - end-1, - PyString_AS_STRING(reasonObj) - ); - } - result = PyString_FromString(buffer); - -error: - Py_XDECREF(reasonObj); - Py_XDECREF(objectObj); - Py_XDECREF(encodingObj); - return result; -} - -static PyMethodDef UnicodeEncodeError_methods[] = { - {"__init__", UnicodeEncodeError__init__, METH_VARARGS}, - {"__str__", UnicodeEncodeError__str__, METH_O}, - {NULL, NULL} -}; - - -PyObject * PyUnicodeEncodeError_Create( - const char *encoding, const Py_UNICODE *object, int length, - int start, int end, const char *reason) -{ - return PyObject_CallFunction(PyExc_UnicodeEncodeError, "su#iis", - encoding, object, length, start, end, reason); -} - - -static PyObject * -UnicodeDecodeError__init__(PyObject *self, PyObject *args) -{ - return UnicodeError__init__(self, args, &PyString_Type); -} - -static PyObject * -UnicodeDecodeError__str__(PyObject *self, PyObject *arg) -{ - PyObject *encodingObj = NULL; - PyObject *objectObj = NULL; - int start; - int end; - PyObject *reasonObj = NULL; - char buffer[1000]; - PyObject *result = NULL; - - self = arg; - - if (!(encodingObj = PyUnicodeDecodeError_GetEncoding(self))) - goto error; - - if (!(objectObj = PyUnicodeDecodeError_GetObject(self))) - goto error; - - if (PyUnicodeDecodeError_GetStart(self, &start)) - goto error; - - if (PyUnicodeDecodeError_GetEnd(self, &end)) - goto error; - - if (!(reasonObj = PyUnicodeDecodeError_GetReason(self))) - goto error; - - if (end==start+1) { - PyOS_snprintf(buffer, sizeof(buffer), - "'%.400s' codec can't decode byte 0x%02x in position %d: %.400s", - PyString_AS_STRING(encodingObj), - ((int)PyString_AS_STRING(objectObj)[start])&0xff, - start, - PyString_AS_STRING(reasonObj) - ); - } - else { - PyOS_snprintf(buffer, sizeof(buffer), - "'%.400s' codec can't decode bytes in position %d-%d: %.400s", - PyString_AS_STRING(encodingObj), - start, - end-1, - PyString_AS_STRING(reasonObj) - ); - } - result = PyString_FromString(buffer); - -error: - Py_XDECREF(reasonObj); - Py_XDECREF(objectObj); - Py_XDECREF(encodingObj); - return result; -} - -static PyMethodDef UnicodeDecodeError_methods[] = { - {"__init__", UnicodeDecodeError__init__, METH_VARARGS}, - {"__str__", UnicodeDecodeError__str__, METH_O}, - {NULL, NULL} -}; - - -PyObject * PyUnicodeDecodeError_Create( - const char *encoding, const char *object, int length, - int start, int end, const char *reason) -{ - return PyObject_CallFunction(PyExc_UnicodeDecodeError, "ss#iis", - encoding, object, length, start, end, reason); -} - - -static PyObject * -UnicodeTranslateError__init__(PyObject *self, PyObject *args) -{ - PyObject *rtnval = NULL; - PyObject *object; - PyObject *start; - PyObject *end; - PyObject *reason; - - if (!(self = get_self(args))) - return NULL; - - if (!(args = PySequence_GetSlice(args, 1, PySequence_Size(args)))) - return NULL; - - if (!PyArg_ParseTuple(args, "O!O!O!O!", - &PyUnicode_Type, &object, - &PyInt_Type, &start, - &PyInt_Type, &end, - &PyString_Type, &reason)) - goto finally; - - if (PyObject_SetAttrString(self, "args", args)) - goto finally; - - if (PyObject_SetAttrString(self, "object", object)) - goto finally; - if (PyObject_SetAttrString(self, "start", start)) - goto finally; - if (PyObject_SetAttrString(self, "end", end)) - goto finally; - if (PyObject_SetAttrString(self, "reason", reason)) - goto finally; - - Py_INCREF(Py_None); - rtnval = Py_None; - - finally: - Py_DECREF(args); - return rtnval; -} - - -static PyObject * -UnicodeTranslateError__str__(PyObject *self, PyObject *arg) -{ - PyObject *objectObj = NULL; - int start; - int end; - PyObject *reasonObj = NULL; - char buffer[1000]; - PyObject *result = NULL; - - self = arg; - - if (!(objectObj = PyUnicodeTranslateError_GetObject(self))) - goto error; - - if (PyUnicodeTranslateError_GetStart(self, &start)) - goto error; - - if (PyUnicodeTranslateError_GetEnd(self, &end)) - goto error; - - if (!(reasonObj = PyUnicodeTranslateError_GetReason(self))) - goto error; - - if (end==start+1) { - int badchar = (int)PyUnicode_AS_UNICODE(objectObj)[start]; - char *format; - if (badchar <= 0xff) - format = "can't translate character u'\\x%02x' in position %d: %.400s"; - else if (badchar <= 0xffff) - format = "can't translate character u'\\u%04x' in position %d: %.400s"; - else - format = "can't translate character u'\\U%08x' in position %d: %.400s"; - PyOS_snprintf(buffer, sizeof(buffer), - format, - badchar, - start, - PyString_AS_STRING(reasonObj) - ); - } - else { - PyOS_snprintf(buffer, sizeof(buffer), - "can't translate characters in position %d-%d: %.400s", - start, - end-1, - PyString_AS_STRING(reasonObj) - ); - } - result = PyString_FromString(buffer); - -error: - Py_XDECREF(reasonObj); - Py_XDECREF(objectObj); - return result; -} - -static PyMethodDef UnicodeTranslateError_methods[] = { - {"__init__", UnicodeTranslateError__init__, METH_VARARGS}, - {"__str__", UnicodeTranslateError__str__, METH_O}, - {NULL, NULL} -}; - - -PyObject * PyUnicodeTranslateError_Create( - const Py_UNICODE *object, int length, - int start, int end, const char *reason) -{ - return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#iis", - object, length, start, end, reason); -} -#endif - - - -/* Exception doc strings */ - -PyDoc_STRVAR(AssertionError__doc__, "Assertion failed."); - -PyDoc_STRVAR(LookupError__doc__, "Base class for lookup errors."); - -PyDoc_STRVAR(IndexError__doc__, "Sequence index out of range."); - -PyDoc_STRVAR(KeyError__doc__, "Mapping key not found."); - -PyDoc_STRVAR(ArithmeticError__doc__, "Base class for arithmetic errors."); - -PyDoc_STRVAR(OverflowError__doc__, "Result too large to be represented."); - -PyDoc_STRVAR(ZeroDivisionError__doc__, -"Second argument to a division or modulo operation was zero."); - -PyDoc_STRVAR(FloatingPointError__doc__, "Floating point operation failed."); - -PyDoc_STRVAR(ValueError__doc__, -"Inappropriate argument value (of correct type)."); - -PyDoc_STRVAR(UnicodeError__doc__, "Unicode related error."); - -#ifdef Py_USING_UNICODE -PyDoc_STRVAR(UnicodeEncodeError__doc__, "Unicode encoding error."); - -PyDoc_STRVAR(UnicodeDecodeError__doc__, "Unicode decoding error."); - -PyDoc_STRVAR(UnicodeTranslateError__doc__, "Unicode translation error."); -#endif - -PyDoc_STRVAR(SystemError__doc__, -"Internal error in the Python interpreter.\n\ -\n\ -Please report this to the Python maintainer, along with the traceback,\n\ -the Python version, and the hardware/OS platform and version."); - -PyDoc_STRVAR(ReferenceError__doc__, -"Weak ref proxy used after referent went away."); - -PyDoc_STRVAR(MemoryError__doc__, "Out of memory."); - -PyDoc_STRVAR(IndentationError__doc__, "Improper indentation."); - -PyDoc_STRVAR(TabError__doc__, "Improper mixture of spaces and tabs."); - -/* Warning category docstrings */ - -PyDoc_STRVAR(Warning__doc__, "Base class for warning categories."); - -PyDoc_STRVAR(UserWarning__doc__, -"Base class for warnings generated by user code."); - -PyDoc_STRVAR(DeprecationWarning__doc__, -"Base class for warnings about deprecated features."); - -PyDoc_STRVAR(PendingDeprecationWarning__doc__, -"Base class for warnings about features which will be deprecated " -"in the future."); - -PyDoc_STRVAR(SyntaxWarning__doc__, -"Base class for warnings about dubious syntax."); - -PyDoc_STRVAR(OverflowWarning__doc__, -"Base class for warnings about numeric overflow."); - -PyDoc_STRVAR(RuntimeWarning__doc__, -"Base class for warnings about dubious runtime behavior."); - -PyDoc_STRVAR(FutureWarning__doc__, -"Base class for warnings about constructs that will change semantically " -"in the future."); - - - -/* module global functions */ -static PyMethodDef functions[] = { - /* Sentinel */ - {NULL, NULL} -}; - - - -/* Global C API defined exceptions */ - -PyObject *PyExc_Exception; -PyObject *PyExc_StopIteration; -PyObject *PyExc_StandardError; -PyObject *PyExc_ArithmeticError; -PyObject *PyExc_LookupError; - -PyObject *PyExc_AssertionError; -PyObject *PyExc_AttributeError; -PyObject *PyExc_EOFError; -PyObject *PyExc_FloatingPointError; -PyObject *PyExc_EnvironmentError; -PyObject *PyExc_IOError; -PyObject *PyExc_OSError; -PyObject *PyExc_ImportError; -PyObject *PyExc_IndexError; -PyObject *PyExc_KeyError; -PyObject *PyExc_KeyboardInterrupt; -PyObject *PyExc_MemoryError; -PyObject *PyExc_NameError; -PyObject *PyExc_OverflowError; -PyObject *PyExc_RuntimeError; -PyObject *PyExc_NotImplementedError; -PyObject *PyExc_SyntaxError; -PyObject *PyExc_IndentationError; -PyObject *PyExc_TabError; -PyObject *PyExc_ReferenceError; -PyObject *PyExc_SystemError; -PyObject *PyExc_SystemExit; -PyObject *PyExc_UnboundLocalError; -PyObject *PyExc_UnicodeError; -PyObject *PyExc_UnicodeEncodeError; -PyObject *PyExc_UnicodeDecodeError; -PyObject *PyExc_UnicodeTranslateError; -PyObject *PyExc_TypeError; -PyObject *PyExc_ValueError; -PyObject *PyExc_ZeroDivisionError; -#ifdef MS_WINDOWS -PyObject *PyExc_WindowsError; -#endif -#ifdef __VMS -PyObject *PyExc_VMSError; -#endif - -/* Pre-computed MemoryError instance. Best to create this as early as - * possibly and not wait until a MemoryError is actually raised! - */ -PyObject *PyExc_MemoryErrorInst; - -/* Predefined warning categories */ -PyObject *PyExc_Warning; -PyObject *PyExc_UserWarning; -PyObject *PyExc_DeprecationWarning; -PyObject *PyExc_PendingDeprecationWarning; -PyObject *PyExc_SyntaxWarning; -PyObject *PyExc_OverflowWarning; -PyObject *PyExc_RuntimeWarning; -PyObject *PyExc_FutureWarning; - - - -/* mapping between exception names and their PyObject ** */ -static struct { - char *name; - PyObject **exc; - PyObject **base; /* NULL == PyExc_StandardError */ - char *docstr; - PyMethodDef *methods; - int (*classinit)(PyObject *); -} exctable[] = { - /* - * The first three classes MUST appear in exactly this order - */ - {"Exception", &PyExc_Exception}, - {"StopIteration", &PyExc_StopIteration, &PyExc_Exception, - StopIteration__doc__}, - {"StandardError", &PyExc_StandardError, &PyExc_Exception, - StandardError__doc__}, - {"TypeError", &PyExc_TypeError, 0, TypeError__doc__}, - /* - * The rest appear in depth-first order of the hierarchy - */ - {"SystemExit", &PyExc_SystemExit, &PyExc_Exception, SystemExit__doc__, - SystemExit_methods}, - {"KeyboardInterrupt", &PyExc_KeyboardInterrupt, 0, KeyboardInterrupt__doc__}, - {"ImportError", &PyExc_ImportError, 0, ImportError__doc__}, - {"EnvironmentError", &PyExc_EnvironmentError, 0, EnvironmentError__doc__, - EnvironmentError_methods}, - {"IOError", &PyExc_IOError, &PyExc_EnvironmentError, IOError__doc__}, - {"OSError", &PyExc_OSError, &PyExc_EnvironmentError, OSError__doc__}, -#ifdef MS_WINDOWS - {"WindowsError", &PyExc_WindowsError, &PyExc_OSError, - WindowsError__doc__}, -#endif /* MS_WINDOWS */ -#ifdef __VMS - {"VMSError", &PyExc_VMSError, &PyExc_OSError, - VMSError__doc__}, -#endif - {"EOFError", &PyExc_EOFError, 0, EOFError__doc__}, - {"RuntimeError", &PyExc_RuntimeError, 0, RuntimeError__doc__}, - {"NotImplementedError", &PyExc_NotImplementedError, - &PyExc_RuntimeError, NotImplementedError__doc__}, - {"NameError", &PyExc_NameError, 0, NameError__doc__}, - {"UnboundLocalError", &PyExc_UnboundLocalError, &PyExc_NameError, - UnboundLocalError__doc__}, - {"AttributeError", &PyExc_AttributeError, 0, AttributeError__doc__}, - {"SyntaxError", &PyExc_SyntaxError, 0, SyntaxError__doc__, - SyntaxError_methods, SyntaxError__classinit__}, - {"IndentationError", &PyExc_IndentationError, &PyExc_SyntaxError, - IndentationError__doc__}, - {"TabError", &PyExc_TabError, &PyExc_IndentationError, - TabError__doc__}, - {"AssertionError", &PyExc_AssertionError, 0, AssertionError__doc__}, - {"LookupError", &PyExc_LookupError, 0, LookupError__doc__}, - {"IndexError", &PyExc_IndexError, &PyExc_LookupError, - IndexError__doc__}, - {"KeyError", &PyExc_KeyError, &PyExc_LookupError, - KeyError__doc__, KeyError_methods}, - {"ArithmeticError", &PyExc_ArithmeticError, 0, ArithmeticError__doc__}, - {"OverflowError", &PyExc_OverflowError, &PyExc_ArithmeticError, - OverflowError__doc__}, - {"ZeroDivisionError", &PyExc_ZeroDivisionError, &PyExc_ArithmeticError, - ZeroDivisionError__doc__}, - {"FloatingPointError", &PyExc_FloatingPointError, &PyExc_ArithmeticError, - FloatingPointError__doc__}, - {"ValueError", &PyExc_ValueError, 0, ValueError__doc__}, - {"UnicodeError", &PyExc_UnicodeError, &PyExc_ValueError, UnicodeError__doc__}, -#ifdef Py_USING_UNICODE - {"UnicodeEncodeError", &PyExc_UnicodeEncodeError, &PyExc_UnicodeError, - UnicodeEncodeError__doc__, UnicodeEncodeError_methods}, - {"UnicodeDecodeError", &PyExc_UnicodeDecodeError, &PyExc_UnicodeError, - UnicodeDecodeError__doc__, UnicodeDecodeError_methods}, - {"UnicodeTranslateError", &PyExc_UnicodeTranslateError, &PyExc_UnicodeError, - UnicodeTranslateError__doc__, UnicodeTranslateError_methods}, -#endif - {"ReferenceError", &PyExc_ReferenceError, 0, ReferenceError__doc__}, - {"SystemError", &PyExc_SystemError, 0, SystemError__doc__}, - {"MemoryError", &PyExc_MemoryError, 0, MemoryError__doc__}, - /* Warning categories */ - {"Warning", &PyExc_Warning, &PyExc_Exception, Warning__doc__}, - {"UserWarning", &PyExc_UserWarning, &PyExc_Warning, UserWarning__doc__}, - {"DeprecationWarning", &PyExc_DeprecationWarning, &PyExc_Warning, - DeprecationWarning__doc__}, - {"PendingDeprecationWarning", &PyExc_PendingDeprecationWarning, &PyExc_Warning, - PendingDeprecationWarning__doc__}, - {"SyntaxWarning", &PyExc_SyntaxWarning, &PyExc_Warning, SyntaxWarning__doc__}, - {"OverflowWarning", &PyExc_OverflowWarning, &PyExc_Warning, - OverflowWarning__doc__}, - {"RuntimeWarning", &PyExc_RuntimeWarning, &PyExc_Warning, - RuntimeWarning__doc__}, - {"FutureWarning", &PyExc_FutureWarning, &PyExc_Warning, - FutureWarning__doc__}, - /* Sentinel */ - {NULL} -}; - - - -void -_PyExc_Init(void) -{ - char *modulename = "exceptions"; - int modnamesz = strlen(modulename); - int i; - PyObject *me, *mydict, *bltinmod, *bdict, *doc, *args; - - me = Py_InitModule(modulename, functions); - if (me == NULL) - goto err; - mydict = PyModule_GetDict(me); - if (mydict == NULL) - goto err; - bltinmod = PyImport_ImportModule("__builtin__"); - if (bltinmod == NULL) - goto err; - bdict = PyModule_GetDict(bltinmod); - if (bdict == NULL) - goto err; - doc = PyString_FromString(module__doc__); - if (doc == NULL) - goto err; - - i = PyDict_SetItemString(mydict, "__doc__", doc); - Py_DECREF(doc); - if (i < 0) { - err: - Py_FatalError("exceptions bootstrapping error."); - return; - } - - /* This is the base class of all exceptions, so make it first. */ - if (make_Exception(modulename) || - PyDict_SetItemString(mydict, "Exception", PyExc_Exception) || - PyDict_SetItemString(bdict, "Exception", PyExc_Exception)) - { - Py_FatalError("Base class `Exception' could not be created."); - } - - /* Now we can programmatically create all the remaining exceptions. - * Remember to start the loop at 1 to skip Exceptions. - */ - for (i=1; exctable[i].name; i++) { - int status; - char *cname = PyMem_NEW(char, modnamesz+strlen(exctable[i].name)+2); - PyObject *base; - - (void)strcpy(cname, modulename); - (void)strcat(cname, "."); - (void)strcat(cname, exctable[i].name); - - if (exctable[i].base == 0) - base = PyExc_StandardError; - else - base = *exctable[i].base; - - status = make_class(exctable[i].exc, base, cname, - exctable[i].methods, - exctable[i].docstr); - - PyMem_DEL(cname); - - if (status) - Py_FatalError("Standard exception classes could not be created."); - - if (exctable[i].classinit) { - status = (*exctable[i].classinit)(*exctable[i].exc); - if (status) - Py_FatalError("An exception class could not be initialized."); - } - - /* Now insert the class into both this module and the __builtin__ - * module. - */ - if (PyDict_SetItemString(mydict, exctable[i].name, *exctable[i].exc) || - PyDict_SetItemString(bdict, exctable[i].name, *exctable[i].exc)) - { - Py_FatalError("Module dictionary insertion problem."); - } - } - - /* Now we need to pre-allocate a MemoryError instance */ - args = Py_BuildValue("()"); - if (!args || - !(PyExc_MemoryErrorInst = PyEval_CallObject(PyExc_MemoryError, args))) - { - Py_FatalError("Cannot pre-allocate MemoryError instance\n"); - } - Py_DECREF(args); - - /* We're done with __builtin__ */ - Py_DECREF(bltinmod); -} - - -void -_PyExc_Fini(void) -{ - int i; - - Py_XDECREF(PyExc_MemoryErrorInst); - PyExc_MemoryErrorInst = NULL; - - for (i=0; exctable[i].name; i++) { - /* clear the class's dictionary, freeing up circular references - * between the class and its methods. - */ - PyObject* cdict = PyObject_GetAttrString(*exctable[i].exc, "__dict__"); - PyDict_Clear(cdict); - Py_DECREF(cdict); - - /* Now decref the exception class */ - Py_XDECREF(*exctable[i].exc); - *exctable[i].exc = NULL; - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/fmod.c b/SDKs/XPlatform/Cypython-2.3.3/Python/fmod.c deleted file mode 100644 index 5d45b68a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/fmod.c +++ /dev/null @@ -1,27 +0,0 @@ - -/* Portable fmod(x, y) implementation for systems that don't have it */ - -#include "pyconfig.h" - -#include "pyport.h" -#include - -double -fmod(double x, double y) -{ - double i, f; - - if (y == 0.0) { - errno = EDOM; - return 0.0; - } - - /* return f such that x = i*y + f for some integer i - such that |f| < |y| and f has the same sign as x */ - - i = floor(x/y); - f = x - i*y; - if ((x < 0.0) != (y < 0.0)) - f = f-y; - return f; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/frozen.c b/SDKs/XPlatform/Cypython-2.3.3/Python/frozen.c deleted file mode 100644 index c10d7d00..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/frozen.c +++ /dev/null @@ -1,38 +0,0 @@ - -/* Dummy frozen modules initializer */ - -#include "Python.h" - -/* In order to test the support for frozen modules, by default we - define a single frozen module, __hello__. Loading it will print - some famous words... */ - -/* To regenerate this data after the bytecode or marshal format has changed, - go to ../Tools/freeze/ and freeze the hello.py file; then copy and paste - the appropriate bytes from M___main__.c. */ - -static unsigned char M___hello__[] = { - 99,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0, - 0,115,9,0,0,0,100,0,0,71,72,100,1,0,83,40, - 2,0,0,0,115,14,0,0,0,72,101,108,108,111,32,119, - 111,114,108,100,46,46,46,78,40,0,0,0,0,40,0,0, - 0,0,40,0,0,0,0,40,0,0,0,0,115,8,0,0, - 0,104,101,108,108,111,46,112,121,115,1,0,0,0,63,1, - 0,0,0,115,0,0,0,0, -}; - -#define SIZE (int)sizeof(M___hello__) - -static struct _frozen _PyImport_FrozenModules[] = { - /* Test module */ - {"__hello__", M___hello__, SIZE}, - /* Test package (negative size indicates package-ness) */ - {"__phello__", M___hello__, -SIZE}, - {"__phello__.spam", M___hello__, SIZE}, - {0, 0, 0} /* sentinel */ -}; - -/* Embedding apps may change this pointer to point to their favorite - collection of frozen modules: */ - -struct _frozen *PyImport_FrozenModules = _PyImport_FrozenModules; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/frozenmain.c b/SDKs/XPlatform/Cypython-2.3.3/Python/frozenmain.c deleted file mode 100644 index b44b4b27..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/frozenmain.c +++ /dev/null @@ -1,68 +0,0 @@ - -/* Python interpreter main program for frozen scripts */ - -#include "Python.h" - -#ifdef MS_WINDOWS -extern void PyWinFreeze_ExeInit(void); -extern void PyWinFreeze_ExeTerm(void); -extern int PyInitFrozenExtensions(void); -#endif - -/* Main program */ - -int -Py_FrozenMain(int argc, char **argv) -{ - char *p; - int n, sts; - int inspect = 0; - int unbuffered = 0; - - Py_FrozenFlag = 1; /* Suppress errors from getpath.c */ - - if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\0') - inspect = 1; - if ((p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0') - unbuffered = 1; - - if (unbuffered) { - setbuf(stdin, (char *)NULL); - setbuf(stdout, (char *)NULL); - setbuf(stderr, (char *)NULL); - } - -#ifdef MS_WINDOWS - PyInitFrozenExtensions(); -#endif /* MS_WINDOWS */ - Py_SetProgramName(argv[0]); - Py_Initialize(); -#ifdef MS_WINDOWS - PyWinFreeze_ExeInit(); -#endif - - if (Py_VerboseFlag) - fprintf(stderr, "Python %s\n%s\n", - Py_GetVersion(), Py_GetCopyright()); - - PySys_SetArgv(argc, argv); - - n = PyImport_ImportFrozenModule("__main__"); - if (n == 0) - Py_FatalError("__main__ not frozen"); - if (n < 0) { - PyErr_Print(); - sts = 1; - } - else - sts = 0; - - if (inspect && isatty((int)fileno(stdin))) - sts = PyRun_AnyFile(stdin, "") != 0; - -#ifdef MS_WINDOWS - PyWinFreeze_ExeTerm(); -#endif - Py_Finalize(); - return sts; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/future.c b/SDKs/XPlatform/Cypython-2.3.3/Python/future.c deleted file mode 100644 index 2d06a443..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/future.c +++ /dev/null @@ -1,260 +0,0 @@ -#include "Python.h" -#include "node.h" -#include "token.h" -#include "graminit.h" -#include "compile.h" -#include "symtable.h" - -#define UNDEFINED_FUTURE_FEATURE "future feature %.100s is not defined" -#define FUTURE_IMPORT_STAR "future statement does not support import *" - -/* FUTURE_POSSIBLE() is provided to accomodate doc strings, which is - the only statement that can occur before a future statement. -*/ -#define FUTURE_POSSIBLE(FF) ((FF)->ff_last_lineno == -1) - -static int -future_check_features(PyFutureFeatures *ff, node *n, const char *filename) -{ - int i; - char *feature; - node *ch; - - REQ(n, import_stmt); /* must by from __future__ import ... */ - - for (i = 3; i < NCH(n); i += 2) { - ch = CHILD(n, i); - if (TYPE(ch) == STAR) { - PyErr_SetString(PyExc_SyntaxError, - FUTURE_IMPORT_STAR); - PyErr_SyntaxLocation(filename, ch->n_lineno); - return -1; - } - REQ(ch, import_as_name); - feature = STR(CHILD(ch, 0)); - if (strcmp(feature, FUTURE_NESTED_SCOPES) == 0) { - continue; - } else if (strcmp(feature, FUTURE_GENERATORS) == 0) { - continue; - } else if (strcmp(feature, FUTURE_DIVISION) == 0) { - ff->ff_features |= CO_FUTURE_DIVISION; - } else if (strcmp(feature, "braces") == 0) { - PyErr_SetString(PyExc_SyntaxError, - "not a chance"); - PyErr_SyntaxLocation(filename, CHILD(ch, 0)->n_lineno); - return -1; - } else { - PyErr_Format(PyExc_SyntaxError, - UNDEFINED_FUTURE_FEATURE, feature); - PyErr_SyntaxLocation(filename, CHILD(ch, 0)->n_lineno); - return -1; - } - } - return 0; -} - -static void -future_error(node *n, const char *filename) -{ - PyErr_SetString(PyExc_SyntaxError, - "from __future__ imports must occur at the " - "beginning of the file"); - PyErr_SyntaxLocation(filename, n->n_lineno); -} - -/* Relevant portions of the grammar: - -single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE -file_input: (NEWLINE | stmt)* ENDMARKER -stmt: simple_stmt | compound_stmt -simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE -small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt - | import_stmt | global_stmt | exec_stmt | assert_stmt -import_stmt: 'import' dotted_as_name (',' dotted_as_name)* - | 'from' dotted_name 'import' ('*' | import_as_name (',' import_as_name)*) -import_as_name: NAME [NAME NAME] -dotted_as_name: dotted_name [NAME NAME] -dotted_name: NAME ('.' NAME)* -*/ - -/* future_parse() finds future statements at the beginnning of a - module. The function calls itself recursively, rather than - factoring out logic for different kinds of statements into - different routines. - - Return values: - -1 indicates an error occurred, e.g. unknown feature name - 0 indicates no feature was found - 1 indicates a feature was found -*/ - -static int -future_parse(PyFutureFeatures *ff, node *n, const char *filename) -{ - int i, r; - loop: - - switch (TYPE(n)) { - - case single_input: - if (TYPE(CHILD(n, 0)) == simple_stmt) { - n = CHILD(n, 0); - goto loop; - } - return 0; - - case file_input: - /* Check each statement in the file, starting with the - first, and continuing until the first statement - that isn't a future statement. - */ - for (i = 0; i < NCH(n); i++) { - node *ch = CHILD(n, i); - if (TYPE(ch) == stmt) { - r = future_parse(ff, ch, filename); - /* Need to check both conditions below - to accomodate doc strings, which - causes r < 0. - */ - if (r < 1 && !FUTURE_POSSIBLE(ff)) - return r; - } - } - return 0; - - case simple_stmt: - if (NCH(n) == 2) { - REQ(CHILD(n, 0), small_stmt); - n = CHILD(n, 0); - goto loop; - } else { - /* Deal with the special case of a series of - small statements on a single line. If a - future statement follows some other - statement, the SyntaxError is raised here. - In all other cases, the symtable pass - raises the exception. - */ - int found = 0, end_of_future = 0; - - for (i = 0; i < NCH(n); i += 2) { - if (TYPE(CHILD(n, i)) == small_stmt) { - r = future_parse(ff, CHILD(n, i), - filename); - if (r < 1) - end_of_future = 1; - else { - found = 1; - if (end_of_future) { - future_error(n, - filename); - return -1; - } - } - } - } - - /* If we found one and only one, then the - current lineno is legal. - */ - if (found) - ff->ff_last_lineno = n->n_lineno + 1; - else - ff->ff_last_lineno = n->n_lineno; - - if (end_of_future && found) - return 1; - else - return 0; - } - - case stmt: - if (TYPE(CHILD(n, 0)) == simple_stmt) { - n = CHILD(n, 0); - goto loop; - } else if (TYPE(CHILD(n, 0)) == expr_stmt) { - n = CHILD(n, 0); - goto loop; - } else { - REQ(CHILD(n, 0), compound_stmt); - ff->ff_last_lineno = n->n_lineno; - return 0; - } - - case small_stmt: - n = CHILD(n, 0); - goto loop; - - case import_stmt: { - node *name; - - if (STR(CHILD(n, 0))[0] != 'f') { /* from */ - ff->ff_last_lineno = n->n_lineno; - return 0; - } - name = CHILD(n, 1); - if (strcmp(STR(CHILD(name, 0)), "__future__") != 0) - return 0; - if (future_check_features(ff, n, filename) < 0) - return -1; - ff->ff_last_lineno = n->n_lineno + 1; - return 1; - } - - /* The cases below -- all of them! -- are necessary to find - and skip doc strings. */ - case expr_stmt: - case testlist: - case test: - case and_test: - case not_test: - case comparison: - case expr: - case xor_expr: - case and_expr: - case shift_expr: - case arith_expr: - case term: - case factor: - case power: - if (NCH(n) == 1) { - n = CHILD(n, 0); - goto loop; - } - break; - - case atom: - if (TYPE(CHILD(n, 0)) == STRING - && ff->ff_found_docstring == 0) { - ff->ff_found_docstring = 1; - return 0; - } - ff->ff_last_lineno = n->n_lineno; - return 0; - - default: - ff->ff_last_lineno = n->n_lineno; - return 0; - } - return 0; -} - -PyFutureFeatures * -PyNode_Future(node *n, const char *filename) -{ - PyFutureFeatures *ff; - - ff = (PyFutureFeatures *)PyMem_Malloc(sizeof(PyFutureFeatures)); - if (ff == NULL) - return NULL; - ff->ff_found_docstring = 0; - ff->ff_last_lineno = -1; - ff->ff_features = 0; - - if (future_parse(ff, n, filename) < 0) { - PyMem_Free((void *)ff); - return NULL; - } - return ff; -} - diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/getargs.c b/SDKs/XPlatform/Cypython-2.3.3/Python/getargs.c deleted file mode 100644 index 47080b31..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/getargs.c +++ /dev/null @@ -1,1562 +0,0 @@ - -/* New getargs implementation */ - -#include "Python.h" - -#include - - -int PyArg_Parse(PyObject *, char *, ...); -int PyArg_ParseTuple(PyObject *, char *, ...); -int PyArg_VaParse(PyObject *, char *, va_list); - -int PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, - char *, char **, ...); - -/* Forward */ -static int vgetargs1(PyObject *, char *, va_list *, int); -static void seterror(int, char *, int *, char *, char *); -static char *convertitem(PyObject *, char **, va_list *, int *, char *, - size_t, PyObject **); -static char *converttuple(PyObject *, char **, va_list *, - int *, char *, size_t, int, PyObject **); -static char *convertsimple(PyObject *, char **, va_list *, char *, - size_t, PyObject **); -static int convertbuffer(PyObject *, void **p, char **); - -static int vgetargskeywords(PyObject *, PyObject *, - char *, char **, va_list *); -static char *skipitem(char **, va_list *); - -int -PyArg_Parse(PyObject *args, char *format, ...) -{ - int retval; - va_list va; - - va_start(va, format); - retval = vgetargs1(args, format, &va, 1); - va_end(va); - return retval; -} - - -int -PyArg_ParseTuple(PyObject *args, char *format, ...) -{ - int retval; - va_list va; - - va_start(va, format); - retval = vgetargs1(args, format, &va, 0); - va_end(va); - return retval; -} - - -int -PyArg_VaParse(PyObject *args, char *format, va_list va) -{ - va_list lva; - -#ifdef VA_LIST_IS_ARRAY - memcpy(lva, va, sizeof(va_list)); -#else -#ifdef __va_copy - __va_copy(lva, va); -#else - lva = va; -#endif -#endif - - return vgetargs1(args, format, &lva, 0); -} - - -/* Handle cleanup of allocated memory in case of exception */ - -static int -addcleanup(void *ptr, PyObject **freelist) -{ - PyObject *cobj; - if (!*freelist) { - *freelist = PyList_New(0); - if (!*freelist) { - PyMem_FREE(ptr); - return -1; - } - } - cobj = PyCObject_FromVoidPtr(ptr, NULL); - if (!cobj) { - PyMem_FREE(ptr); - return -1; - } - if(PyList_Append(*freelist, cobj)) { - PyMem_FREE(ptr); - Py_DECREF(cobj); - return -1; - } - Py_DECREF(cobj); - return 0; -} - -static int -cleanreturn(int retval, PyObject *freelist) -{ - if(freelist) { - if((retval) == 0) { - int len = PyList_GET_SIZE(freelist), i; - for (i = 0; i < len; i++) - PyMem_FREE(PyCObject_AsVoidPtr( - PyList_GET_ITEM(freelist, i))); - } - Py_DECREF(freelist); - } - return retval; -} - - -static int -vgetargs1(PyObject *args, char *format, va_list *p_va, int compat) -{ - char msgbuf[256]; - int levels[32]; - char *fname = NULL; - char *message = NULL; - int min = -1; - int max = 0; - int level = 0; - int endfmt = 0; - char *formatsave = format; - int i, len; - char *msg; - PyObject *freelist = NULL; - - assert(compat || (args != (PyObject*)NULL)); - - while (endfmt == 0) { - int c = *format++; - switch (c) { - case '(': - if (level == 0) - max++; - level++; - break; - case ')': - if (level == 0) - Py_FatalError("excess ')' in getargs format"); - else - level--; - break; - case '\0': - endfmt = 1; - break; - case ':': - fname = format; - endfmt = 1; - break; - case ';': - message = format; - endfmt = 1; - break; - default: - if (level == 0) { - if (c == 'O') - max++; - else if (isalpha(c)) { - if (c != 'e') /* skip encoded */ - max++; - } else if (c == '|') - min = max; - } - break; - } - } - - if (level != 0) - Py_FatalError(/* '(' */ "missing ')' in getargs format"); - - if (min < 0) - min = max; - - format = formatsave; - - if (compat) { - if (max == 0) { - if (args == NULL) - return 1; - PyOS_snprintf(msgbuf, sizeof(msgbuf), - "%.200s%s takes no arguments", - fname==NULL ? "function" : fname, - fname==NULL ? "" : "()"); - PyErr_SetString(PyExc_TypeError, msgbuf); - return 0; - } - else if (min == 1 && max == 1) { - if (args == NULL) { - PyOS_snprintf(msgbuf, sizeof(msgbuf), - "%.200s%s takes at least one argument", - fname==NULL ? "function" : fname, - fname==NULL ? "" : "()"); - PyErr_SetString(PyExc_TypeError, msgbuf); - return 0; - } - msg = convertitem(args, &format, p_va, levels, msgbuf, - sizeof(msgbuf), &freelist); - if (msg == NULL) - return cleanreturn(1, freelist); - seterror(levels[0], msg, levels+1, fname, message); - return cleanreturn(0, freelist); - } - else { - PyErr_SetString(PyExc_SystemError, - "old style getargs format uses new features"); - return 0; - } - } - - if (!PyTuple_Check(args)) { - PyErr_SetString(PyExc_SystemError, - "new style getargs format but argument is not a tuple"); - return 0; - } - - len = PyTuple_GET_SIZE(args); - - if (len < min || max < len) { - if (message == NULL) { - PyOS_snprintf(msgbuf, sizeof(msgbuf), - "%.150s%s takes %s %d argument%s " - "(%d given)", - fname==NULL ? "function" : fname, - fname==NULL ? "" : "()", - min==max ? "exactly" - : len < min ? "at least" : "at most", - len < min ? min : max, - (len < min ? min : max) == 1 ? "" : "s", - len); - message = msgbuf; - } - PyErr_SetString(PyExc_TypeError, message); - return 0; - } - - for (i = 0; i < len; i++) { - if (*format == '|') - format++; - msg = convertitem(PyTuple_GET_ITEM(args, i), &format, p_va, - levels, msgbuf, sizeof(msgbuf), &freelist); - if (msg) { - seterror(i+1, msg, levels, fname, message); - return cleanreturn(0, freelist); - } - } - - if (*format != '\0' && !isalpha((int)(*format)) && - *format != '(' && - *format != '|' && *format != ':' && *format != ';') { - PyErr_Format(PyExc_SystemError, - "bad format string: %.200s", formatsave); - return cleanreturn(0, freelist); - } - - return cleanreturn(1, freelist); -} - - - -static void -seterror(int iarg, char *msg, int *levels, char *fname, char *message) -{ - char buf[512]; - int i; - char *p = buf; - - if (PyErr_Occurred()) - return; - else if (message == NULL) { - if (fname != NULL) { - PyOS_snprintf(p, sizeof(buf), "%.200s() ", fname); - p += strlen(p); - } - if (iarg != 0) { - PyOS_snprintf(p, sizeof(buf) - (p - buf), - "argument %d", iarg); - i = 0; - p += strlen(p); - while (levels[i] > 0 && (int)(p-buf) < 220) { - PyOS_snprintf(p, sizeof(buf) - (buf - p), - ", item %d", levels[i]-1); - p += strlen(p); - i++; - } - } - else { - PyOS_snprintf(p, sizeof(buf) - (p - buf), "argument"); - p += strlen(p); - } - PyOS_snprintf(p, sizeof(buf) - (p - buf), " %.256s", msg); - message = buf; - } - PyErr_SetString(PyExc_TypeError, message); -} - - -/* Convert a tuple argument. - On entry, *p_format points to the character _after_ the opening '('. - On successful exit, *p_format points to the closing ')'. - If successful: - *p_format and *p_va are updated, - *levels and *msgbuf are untouched, - and NULL is returned. - If the argument is invalid: - *p_format is unchanged, - *p_va is undefined, - *levels is a 0-terminated list of item numbers, - *msgbuf contains an error message, whose format is: - "must be , not ", where: - is the name of the expected type, and - is the name of the actual type, - and msgbuf is returned. -*/ - -static char * -converttuple(PyObject *arg, char **p_format, va_list *p_va, int *levels, - char *msgbuf, size_t bufsize, int toplevel, PyObject **freelist) -{ - int level = 0; - int n = 0; - char *format = *p_format; - int i; - - for (;;) { - int c = *format++; - if (c == '(') { - if (level == 0) - n++; - level++; - } - else if (c == ')') { - if (level == 0) - break; - level--; - } - else if (c == ':' || c == ';' || c == '\0') - break; - else if (level == 0 && isalpha(c)) - n++; - } - - if (!PySequence_Check(arg) || PyString_Check(arg)) { - levels[0] = 0; - PyOS_snprintf(msgbuf, bufsize, - toplevel ? "expected %d arguments, not %.50s" : - "must be %d-item sequence, not %.50s", - n, - arg == Py_None ? "None" : arg->ob_type->tp_name); - return msgbuf; - } - - if ((i = PySequence_Size(arg)) != n) { - levels[0] = 0; - PyOS_snprintf(msgbuf, bufsize, - toplevel ? "expected %d arguments, not %d" : - "must be sequence of length %d, not %d", - n, i); - return msgbuf; - } - - format = *p_format; - for (i = 0; i < n; i++) { - char *msg; - PyObject *item; - item = PySequence_GetItem(arg, i); - msg = convertitem(item, &format, p_va, levels+1, msgbuf, - bufsize, freelist); - /* PySequence_GetItem calls tp->sq_item, which INCREFs */ - Py_XDECREF(item); - if (msg != NULL) { - levels[0] = i+1; - return msg; - } - } - - *p_format = format; - return NULL; -} - - -/* Convert a single item. */ - -static char * -convertitem(PyObject *arg, char **p_format, va_list *p_va, int *levels, - char *msgbuf, size_t bufsize, PyObject **freelist) -{ - char *msg; - char *format = *p_format; - - if (*format == '(' /* ')' */) { - format++; - msg = converttuple(arg, &format, p_va, levels, msgbuf, - bufsize, 0, freelist); - if (msg == NULL) - format++; - } - else { - msg = convertsimple(arg, &format, p_va, msgbuf, bufsize, - freelist); - if (msg != NULL) - levels[0] = 0; - } - if (msg == NULL) - *p_format = format; - return msg; -} - - - -#define UNICODE_DEFAULT_ENCODING(arg) \ - _PyUnicode_AsDefaultEncodedString(arg, NULL) - -/* Format an error message generated by convertsimple(). */ - -static char * -converterr(char *expected, PyObject *arg, char *msgbuf, size_t bufsize) -{ - assert(expected != NULL); - assert(arg != NULL); - PyOS_snprintf(msgbuf, bufsize, - "must be %.50s, not %.50s", expected, - arg == Py_None ? "None" : arg->ob_type->tp_name); - return msgbuf; -} - -#define CONV_UNICODE "(unicode conversion error)" - -/* explicitly check for float arguments when integers are expected. For now - * signal a warning. Returns true if an exception was raised. */ -static int -float_argument_error(PyObject *arg) -{ - if (PyFloat_Check(arg) && - PyErr_Warn(PyExc_DeprecationWarning, - "integer argument expected, got float" )) - return 1; - else - return 0; -} - -/* Convert a non-tuple argument. Return NULL if conversion went OK, - or a string with a message describing the failure. The message is - formatted as "must be , not ". - When failing, an exception may or may not have been raised. - Don't call if a tuple is expected. -*/ - -static char * -convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf, - size_t bufsize, PyObject **freelist) -{ - char *format = *p_format; - char c = *format++; -#ifdef Py_USING_UNICODE - PyObject *uarg; -#endif - - switch (c) { - - case 'b': { /* unsigned byte -- very short int */ - char *p = va_arg(*p_va, char *); - long ival; - if (float_argument_error(arg)) - return NULL; - ival = PyInt_AsLong(arg); - if (ival == -1 && PyErr_Occurred()) - return converterr("integer", arg, msgbuf, bufsize); - else if (ival < 0) { - PyErr_SetString(PyExc_OverflowError, - "unsigned byte integer is less than minimum"); - return converterr("integer", arg, msgbuf, bufsize); - } - else if (ival > UCHAR_MAX) { - PyErr_SetString(PyExc_OverflowError, - "unsigned byte integer is greater than maximum"); - return converterr("integer", arg, msgbuf, bufsize); - } - else - *p = (unsigned char) ival; - break; - } - - case 'B': {/* byte sized bitfield - both signed and unsigned - values allowed */ - char *p = va_arg(*p_va, char *); - long ival; - if (float_argument_error(arg)) - return NULL; - ival = PyInt_AsUnsignedLongMask(arg); - if (ival == -1 && PyErr_Occurred()) - return converterr("integer", arg, msgbuf, bufsize); - else - *p = (unsigned char) ival; - break; - } - - case 'h': {/* signed short int */ - short *p = va_arg(*p_va, short *); - long ival; - if (float_argument_error(arg)) - return NULL; - ival = PyInt_AsLong(arg); - if (ival == -1 && PyErr_Occurred()) - return converterr("integer", arg, msgbuf, bufsize); - else if (ival < SHRT_MIN) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is less than minimum"); - return converterr("integer", arg, msgbuf, bufsize); - } - else if (ival > SHRT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "signed short integer is greater than maximum"); - return converterr("integer", arg, msgbuf, bufsize); - } - else - *p = (short) ival; - break; - } - - case 'H': { /* short int sized bitfield, both signed and - unsigned allowed */ - unsigned short *p = va_arg(*p_va, unsigned short *); - long ival; - if (float_argument_error(arg)) - return NULL; - ival = PyInt_AsUnsignedLongMask(arg); - if (ival == -1 && PyErr_Occurred()) - return converterr("integer", arg, msgbuf, bufsize); - else - *p = (unsigned short) ival; - break; - } - - case 'i': {/* signed int */ - int *p = va_arg(*p_va, int *); - long ival; - if (float_argument_error(arg)) - return NULL; - ival = PyInt_AsLong(arg); - if (ival == -1 && PyErr_Occurred()) - return converterr("integer", arg, msgbuf, bufsize); - else if (ival > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "signed integer is greater than maximum"); - return converterr("integer", arg, msgbuf, bufsize); - } - else if (ival < INT_MIN) { - PyErr_SetString(PyExc_OverflowError, - "signed integer is less than minimum"); - return converterr("integer", arg, msgbuf, bufsize); - } - else - *p = ival; - break; - } - - case 'I': { /* int sized bitfield, both signed and - unsigned allowed */ - unsigned int *p = va_arg(*p_va, unsigned int *); - unsigned int ival; - if (float_argument_error(arg)) - return NULL; - ival = PyInt_AsUnsignedLongMask(arg); - if (ival == -1 && PyErr_Occurred()) - return converterr("integer", arg, msgbuf, bufsize); - else - *p = ival; - break; - } - - case 'l': {/* long int */ - long *p = va_arg(*p_va, long *); - long ival; - if (float_argument_error(arg)) - return NULL; - ival = PyInt_AsLong(arg); - if (ival == -1 && PyErr_Occurred()) - return converterr("integer", arg, msgbuf, bufsize); - else - *p = ival; - break; - } - - case 'k': { /* long sized bitfield */ - unsigned long *p = va_arg(*p_va, unsigned long *); - unsigned long ival; - if (PyInt_Check(arg)) - ival = PyInt_AsUnsignedLongMask(arg); - else if (PyLong_Check(arg)) - ival = PyLong_AsUnsignedLongMask(arg); - else - return converterr("integer", arg, msgbuf, bufsize); - *p = ival; - break; - } - -#ifdef HAVE_LONG_LONG - case 'L': {/* PY_LONG_LONG */ - PY_LONG_LONG *p = va_arg( *p_va, PY_LONG_LONG * ); - PY_LONG_LONG ival = PyLong_AsLongLong( arg ); - if( ival == (PY_LONG_LONG)-1 && PyErr_Occurred() ) { - return converterr("long", arg, msgbuf, bufsize); - } else { - *p = ival; - } - break; - } - - case 'K': { /* long long sized bitfield */ - unsigned PY_LONG_LONG *p = va_arg(*p_va, unsigned PY_LONG_LONG *); - unsigned PY_LONG_LONG ival; - if (float_argument_error(arg)) - return NULL; - if (PyInt_Check(arg)) - ival = PyInt_AsUnsignedLongMask(arg); - else if (PyLong_Check(arg)) - ival = PyLong_AsUnsignedLongLongMask(arg); - else - return converterr("integer", arg, msgbuf, bufsize); - *p = ival; - break; - } -#endif - - case 'f': {/* float */ - float *p = va_arg(*p_va, float *); - double dval = PyFloat_AsDouble(arg); - if (PyErr_Occurred()) - return converterr("float", arg, msgbuf, bufsize); - else - *p = (float) dval; - break; - } - - case 'd': {/* double */ - double *p = va_arg(*p_va, double *); - double dval = PyFloat_AsDouble(arg); - if (PyErr_Occurred()) - return converterr("float", arg, msgbuf, bufsize); - else - *p = dval; - break; - } - -#ifndef WITHOUT_COMPLEX - case 'D': {/* complex double */ - Py_complex *p = va_arg(*p_va, Py_complex *); - Py_complex cval; - cval = PyComplex_AsCComplex(arg); - if (PyErr_Occurred()) - return converterr("complex", arg, msgbuf, bufsize); - else - *p = cval; - break; - } -#endif /* WITHOUT_COMPLEX */ - - case 'c': {/* char */ - char *p = va_arg(*p_va, char *); - if (PyString_Check(arg) && PyString_Size(arg) == 1) - *p = PyString_AS_STRING(arg)[0]; - else - return converterr("char", arg, msgbuf, bufsize); - break; - } - - case 's': {/* string */ - if (*format == '#') { - void **p = (void **)va_arg(*p_va, char **); - int *q = va_arg(*p_va, int *); - - if (PyString_Check(arg)) { - *p = PyString_AS_STRING(arg); - *q = PyString_GET_SIZE(arg); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(arg)) { - uarg = UNICODE_DEFAULT_ENCODING(arg); - if (uarg == NULL) - return converterr(CONV_UNICODE, - arg, msgbuf, bufsize); - *p = PyString_AS_STRING(uarg); - *q = PyString_GET_SIZE(uarg); - } -#endif - else { /* any buffer-like object */ - char *buf; - int count = convertbuffer(arg, p, &buf); - if (count < 0) - return converterr(buf, arg, msgbuf, bufsize); - *q = count; - } - format++; - } else { - char **p = va_arg(*p_va, char **); - - if (PyString_Check(arg)) - *p = PyString_AS_STRING(arg); -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(arg)) { - uarg = UNICODE_DEFAULT_ENCODING(arg); - if (uarg == NULL) - return converterr(CONV_UNICODE, - arg, msgbuf, bufsize); - *p = PyString_AS_STRING(uarg); - } -#endif - else - return converterr("string", arg, msgbuf, bufsize); - if ((int)strlen(*p) != PyString_Size(arg)) - return converterr("string without null bytes", - arg, msgbuf, bufsize); - } - break; - } - - case 'z': {/* string, may be NULL (None) */ - if (*format == '#') { /* any buffer-like object */ - void **p = (void **)va_arg(*p_va, char **); - int *q = va_arg(*p_va, int *); - - if (arg == Py_None) { - *p = 0; - *q = 0; - } - else if (PyString_Check(arg)) { - *p = PyString_AS_STRING(arg); - *q = PyString_GET_SIZE(arg); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(arg)) { - uarg = UNICODE_DEFAULT_ENCODING(arg); - if (uarg == NULL) - return converterr(CONV_UNICODE, - arg, msgbuf, bufsize); - *p = PyString_AS_STRING(uarg); - *q = PyString_GET_SIZE(uarg); - } -#endif - else { /* any buffer-like object */ - char *buf; - int count = convertbuffer(arg, p, &buf); - if (count < 0) - return converterr(buf, arg, msgbuf, bufsize); - *q = count; - } - format++; - } else { - char **p = va_arg(*p_va, char **); - - if (arg == Py_None) - *p = 0; - else if (PyString_Check(arg)) - *p = PyString_AS_STRING(arg); -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(arg)) { - uarg = UNICODE_DEFAULT_ENCODING(arg); - if (uarg == NULL) - return converterr(CONV_UNICODE, - arg, msgbuf, bufsize); - *p = PyString_AS_STRING(uarg); - } -#endif - else - return converterr("string or None", - arg, msgbuf, bufsize); - if (*format == '#') { - int *q = va_arg(*p_va, int *); - if (arg == Py_None) - *q = 0; - else - *q = PyString_Size(arg); - format++; - } - else if (*p != NULL && - (int)strlen(*p) != PyString_Size(arg)) - return converterr( - "string without null bytes or None", - arg, msgbuf, bufsize); - } - break; - } - - case 'e': {/* encoded string */ - char **buffer; - const char *encoding; - PyObject *s; - int size, recode_strings; - - /* Get 'e' parameter: the encoding name */ - encoding = (const char *)va_arg(*p_va, const char *); -#ifdef Py_USING_UNICODE - if (encoding == NULL) - encoding = PyUnicode_GetDefaultEncoding(); -#endif - - /* Get output buffer parameter: - 's' (recode all objects via Unicode) or - 't' (only recode non-string objects) - */ - if (*format == 's') - recode_strings = 1; - else if (*format == 't') - recode_strings = 0; - else - return converterr( - "(unknown parser marker combination)", - arg, msgbuf, bufsize); - buffer = (char **)va_arg(*p_va, char **); - format++; - if (buffer == NULL) - return converterr("(buffer is NULL)", - arg, msgbuf, bufsize); - - /* Encode object */ - if (!recode_strings && PyString_Check(arg)) { - s = arg; - Py_INCREF(s); - } - else { -#ifdef Py_USING_UNICODE - PyObject *u; - - /* Convert object to Unicode */ - u = PyUnicode_FromObject(arg); - if (u == NULL) - return converterr( - "string or unicode or text buffer", - arg, msgbuf, bufsize); - - /* Encode object; use default error handling */ - s = PyUnicode_AsEncodedString(u, - encoding, - NULL); - Py_DECREF(u); - if (s == NULL) - return converterr("(encoding failed)", - arg, msgbuf, bufsize); - if (!PyString_Check(s)) { - Py_DECREF(s); - return converterr( - "(encoder failed to return a string)", - arg, msgbuf, bufsize); - } -#else - return converterr("string", arg, msgbuf, bufsize); -#endif - } - size = PyString_GET_SIZE(s); - - /* Write output; output is guaranteed to be 0-terminated */ - if (*format == '#') { - /* Using buffer length parameter '#': - - - if *buffer is NULL, a new buffer of the - needed size is allocated and the data - copied into it; *buffer is updated to point - to the new buffer; the caller is - responsible for PyMem_Free()ing it after - usage - - - if *buffer is not NULL, the data is - copied to *buffer; *buffer_len has to be - set to the size of the buffer on input; - buffer overflow is signalled with an error; - buffer has to provide enough room for the - encoded string plus the trailing 0-byte - - - in both cases, *buffer_len is updated to - the size of the buffer /excluding/ the - trailing 0-byte - - */ - int *buffer_len = va_arg(*p_va, int *); - - format++; - if (buffer_len == NULL) { - Py_DECREF(s); - return converterr( - "(buffer_len is NULL)", - arg, msgbuf, bufsize); - } - if (*buffer == NULL) { - *buffer = PyMem_NEW(char, size + 1); - if (*buffer == NULL) { - Py_DECREF(s); - return converterr( - "(memory error)", - arg, msgbuf, bufsize); - } - if(addcleanup(*buffer, freelist)) { - Py_DECREF(s); - return converterr( - "(cleanup problem)", - arg, msgbuf, bufsize); - } - } else { - if (size + 1 > *buffer_len) { - Py_DECREF(s); - return converterr( - "(buffer overflow)", - arg, msgbuf, bufsize); - } - } - memcpy(*buffer, - PyString_AS_STRING(s), - size + 1); - *buffer_len = size; - } else { - /* Using a 0-terminated buffer: - - - the encoded string has to be 0-terminated - for this variant to work; if it is not, an - error raised - - - a new buffer of the needed size is - allocated and the data copied into it; - *buffer is updated to point to the new - buffer; the caller is responsible for - PyMem_Free()ing it after usage - - */ - if ((int)strlen(PyString_AS_STRING(s)) != size) { - Py_DECREF(s); - return converterr( - "(encoded string without NULL bytes)", - arg, msgbuf, bufsize); - } - *buffer = PyMem_NEW(char, size + 1); - if (*buffer == NULL) { - Py_DECREF(s); - return converterr("(memory error)", - arg, msgbuf, bufsize); - } - if(addcleanup(*buffer, freelist)) { - Py_DECREF(s); - return converterr("(cleanup problem)", - arg, msgbuf, bufsize); - } - memcpy(*buffer, - PyString_AS_STRING(s), - size + 1); - } - Py_DECREF(s); - break; - } - -#ifdef Py_USING_UNICODE - case 'u': {/* raw unicode buffer (Py_UNICODE *) */ - if (*format == '#') { /* any buffer-like object */ - void **p = (void **)va_arg(*p_va, char **); - int *q = va_arg(*p_va, int *); - if (PyUnicode_Check(arg)) { - *p = PyUnicode_AS_UNICODE(arg); - *q = PyUnicode_GET_SIZE(arg); - } - else { - char *buf; - int count = convertbuffer(arg, p, &buf); - if (count < 0) - return converterr(buf, arg, msgbuf, bufsize); - *q = count/(sizeof(Py_UNICODE)); - } - format++; - } else { - Py_UNICODE **p = va_arg(*p_va, Py_UNICODE **); - if (PyUnicode_Check(arg)) - *p = PyUnicode_AS_UNICODE(arg); - else - return converterr("unicode", arg, msgbuf, bufsize); - } - break; - } -#endif - - case 'S': { /* string object */ - PyObject **p = va_arg(*p_va, PyObject **); - if (PyString_Check(arg)) - *p = arg; - else - return converterr("string", arg, msgbuf, bufsize); - break; - } - -#ifdef Py_USING_UNICODE - case 'U': { /* Unicode object */ - PyObject **p = va_arg(*p_va, PyObject **); - if (PyUnicode_Check(arg)) - *p = arg; - else - return converterr("unicode", arg, msgbuf, bufsize); - break; - } -#endif - - case 'O': { /* object */ - PyTypeObject *type; - PyObject **p; - if (*format == '!') { - type = va_arg(*p_va, PyTypeObject*); - p = va_arg(*p_va, PyObject **); - format++; - if (PyType_IsSubtype(arg->ob_type, type)) - *p = arg; - else - return converterr(type->tp_name, arg, msgbuf, bufsize); - - } - else if (*format == '?') { - inquiry pred = va_arg(*p_va, inquiry); - p = va_arg(*p_va, PyObject **); - format++; - if ((*pred)(arg)) - *p = arg; - else - return converterr("(unspecified)", - arg, msgbuf, bufsize); - - } - else if (*format == '&') { - typedef int (*converter)(PyObject *, void *); - converter convert = va_arg(*p_va, converter); - void *addr = va_arg(*p_va, void *); - format++; - if (! (*convert)(arg, addr)) - return converterr("(unspecified)", - arg, msgbuf, bufsize); - } - else { - p = va_arg(*p_va, PyObject **); - *p = arg; - } - break; - } - - - case 'w': { /* memory buffer, read-write access */ - void **p = va_arg(*p_va, void **); - PyBufferProcs *pb = arg->ob_type->tp_as_buffer; - int count; - - if (pb == NULL || - pb->bf_getwritebuffer == NULL || - pb->bf_getsegcount == NULL) - return converterr("read-write buffer", arg, msgbuf, bufsize); - if ((*pb->bf_getsegcount)(arg, NULL) != 1) - return converterr("single-segment read-write buffer", - arg, msgbuf, bufsize); - if ((count = pb->bf_getwritebuffer(arg, 0, p)) < 0) - return converterr("(unspecified)", arg, msgbuf, bufsize); - if (*format == '#') { - int *q = va_arg(*p_va, int *); - - *q = count; - format++; - } - break; - } - - case 't': { /* 8-bit character buffer, read-only access */ - const char **p = va_arg(*p_va, const char **); - PyBufferProcs *pb = arg->ob_type->tp_as_buffer; - int count; - - if (*format++ != '#') - return converterr( - "invalid use of 't' format character", - arg, msgbuf, bufsize); - if (!PyType_HasFeature(arg->ob_type, - Py_TPFLAGS_HAVE_GETCHARBUFFER) || - pb == NULL || pb->bf_getcharbuffer == NULL || - pb->bf_getsegcount == NULL) - return converterr( - "string or read-only character buffer", - arg, msgbuf, bufsize); - - if (pb->bf_getsegcount(arg, NULL) != 1) - return converterr( - "string or single-segment read-only buffer", - arg, msgbuf, bufsize); - - count = pb->bf_getcharbuffer(arg, 0, p); - if (count < 0) - return converterr("(unspecified)", arg, msgbuf, bufsize); - *va_arg(*p_va, int *) = count; - break; - } - - default: - return converterr("impossible", arg, msgbuf, bufsize); - - } - - *p_format = format; - return NULL; -} - -static int -convertbuffer(PyObject *arg, void **p, char **errmsg) -{ - PyBufferProcs *pb = arg->ob_type->tp_as_buffer; - int count; - if (pb == NULL || - pb->bf_getreadbuffer == NULL || - pb->bf_getsegcount == NULL) { - *errmsg = "string or read-only buffer"; - return -1; - } - if ((*pb->bf_getsegcount)(arg, NULL) != 1) { - *errmsg = "string or single-segment read-only buffer"; - return -1; - } - if ((count = (*pb->bf_getreadbuffer)(arg, 0, p)) < 0) { - *errmsg = "(unspecified)"; - } - return count; -} - -/* Support for keyword arguments donated by - Geoff Philbrick */ - -/* Return false (0) for error, else true. */ -int -PyArg_ParseTupleAndKeywords(PyObject *args, - PyObject *keywords, - char *format, - char **kwlist, ...) -{ - int retval; - va_list va; - - if ((args == NULL || !PyTuple_Check(args)) || - (keywords != NULL && !PyDict_Check(keywords)) || - format == NULL || - kwlist == NULL) - { - PyErr_BadInternalCall(); - return 0; - } - - va_start(va, kwlist); - retval = vgetargskeywords(args, keywords, format, kwlist, &va); - va_end(va); - return retval; -} - - -static int -vgetargskeywords(PyObject *args, PyObject *keywords, char *format, - char **kwlist, va_list *p_va) -{ - char msgbuf[512]; - int levels[32]; - char *fname, *message; - int min, max; - char *formatsave; - int i, len, nargs, nkeywords; - char *msg, **p; - PyObject *freelist = NULL; - - assert(args != NULL && PyTuple_Check(args)); - assert(keywords == NULL || PyDict_Check(keywords)); - assert(format != NULL); - assert(kwlist != NULL); - assert(p_va != NULL); - - /* Search the format: - message <- error msg, if any (else NULL). - fname <- routine name, if any (else NULL). - min <- # of required arguments, or -1 if all are required. - max <- most arguments (required + optional). - Check that kwlist has a non-NULL entry for each arg. - Raise error if a tuple arg spec is found. - */ - fname = message = NULL; - formatsave = format; - p = kwlist; - min = -1; - max = 0; - while ((i = *format++) != '\0') { - if (isalpha(i) && i != 'e') { - max++; - if (*p == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "more argument specifiers than " - "keyword list entries"); - return 0; - } - p++; - } - else if (i == '|') - min = max; - else if (i == ':') { - fname = format; - break; - } - else if (i == ';') { - message = format; - break; - } - else if (i == '(') { - PyErr_SetString(PyExc_RuntimeError, - "tuple found in format when using keyword " - "arguments"); - return 0; - } - } - format = formatsave; - if (*p != NULL) { - PyErr_SetString(PyExc_RuntimeError, - "more keyword list entries than " - "argument specifiers"); - return 0; - } - if (min < 0) { - /* All arguments are required. */ - min = max; - } - - nargs = PyTuple_GET_SIZE(args); - nkeywords = keywords == NULL ? 0 : PyDict_Size(keywords); - - /* make sure there are no duplicate values for an argument; - its not clear when to use the term "keyword argument vs. - keyword parameter in messages */ - if (nkeywords > 0) { - for (i = 0; i < nargs; i++) { - char *thiskw = kwlist[i]; - if (thiskw == NULL) - break; - if (PyDict_GetItemString(keywords, thiskw)) { - PyErr_Format(PyExc_TypeError, - "keyword parameter '%s' was given " - "by position and by name", - thiskw); - return 0; - } - else if (PyErr_Occurred()) - return 0; - } - } - - /* required arguments missing from args can be supplied by keyword - arguments; set len to the number of posiitional arguments, and, - if that's less than the minimum required, add in the number of - required arguments that are supplied by keywords */ - len = nargs; - if (nkeywords > 0 && nargs < min) { - for (i = nargs; i < min; i++) { - if (PyDict_GetItemString(keywords, kwlist[i])) - len++; - else if (PyErr_Occurred()) - return 0; - } - } - - /* make sure we got an acceptable number of arguments; the message - is a little confusing with keywords since keyword arguments - which are supplied, but don't match the required arguments - are not included in the "%d given" part of the message */ - if (len < min || max < len) { - if (message == NULL) { - PyOS_snprintf(msgbuf, sizeof(msgbuf), - "%.200s%s takes %s %d argument%s " - "(%d given)", - fname==NULL ? "function" : fname, - fname==NULL ? "" : "()", - min==max ? "exactly" - : len < min ? "at least" : "at most", - len < min ? min : max, - (len < min ? min : max) == 1 ? "" : "s", - len); - message = msgbuf; - } - PyErr_SetString(PyExc_TypeError, message); - return 0; - } - - /* convert the positional arguments */ - for (i = 0; i < nargs; i++) { - if (*format == '|') - format++; - msg = convertitem(PyTuple_GET_ITEM(args, i), &format, p_va, - levels, msgbuf, sizeof(msgbuf), &freelist); - if (msg) { - seterror(i+1, msg, levels, fname, message); - return cleanreturn(0, freelist); - } - } - - /* handle no keyword parameters in call */ - if (nkeywords == 0) - return cleanreturn(1, freelist); - - /* convert the keyword arguments; this uses the format - string where it was left after processing args */ - for (i = nargs; i < max; i++) { - PyObject *item; - if (*format == '|') - format++; - item = PyDict_GetItemString(keywords, kwlist[i]); - if (item != NULL) { - Py_INCREF(item); - msg = convertitem(item, &format, p_va, levels, msgbuf, - sizeof(msgbuf), &freelist); - Py_DECREF(item); - if (msg) { - seterror(i+1, msg, levels, fname, message); - return cleanreturn(0, freelist); - } - --nkeywords; - if (nkeywords == 0) - break; - } - else if (PyErr_Occurred()) - return cleanreturn(0, freelist); - else { - msg = skipitem(&format, p_va); - if (msg) { - seterror(i+1, msg, levels, fname, message); - return cleanreturn(0, freelist); - } - } - } - - /* make sure there are no extraneous keyword arguments */ - if (nkeywords > 0) { - PyObject *key, *value; - int pos = 0; - while (PyDict_Next(keywords, &pos, &key, &value)) { - int match = 0; - char *ks; - if (!PyString_Check(key)) { - PyErr_SetString(PyExc_TypeError, - "keywords must be strings"); - return cleanreturn(0, freelist); - } - ks = PyString_AsString(key); - for (i = 0; i < max; i++) { - if (!strcmp(ks, kwlist[i])) { - match = 1; - break; - } - } - if (!match) { - PyErr_Format(PyExc_TypeError, - "'%s' is an invalid keyword " - "argument for this function", - ks); - return cleanreturn(0, freelist); - } - } - } - - return cleanreturn(1, freelist); -} - - -static char * -skipitem(char **p_format, va_list *p_va) -{ - char *format = *p_format; - char c = *format++; - - switch (c) { - - case 'b': /* byte -- very short int */ - case 'B': /* byte as bitfield */ - { - (void) va_arg(*p_va, char *); - break; - } - - case 'h': /* short int */ - { - (void) va_arg(*p_va, short *); - break; - } - - case 'H': /* short int as bitfield */ - { - (void) va_arg(*p_va, unsigned short *); - break; - } - - case 'i': /* int */ - { - (void) va_arg(*p_va, int *); - break; - } - - case 'l': /* long int */ - { - (void) va_arg(*p_va, long *); - break; - } - -#ifdef HAVE_LONG_LONG - case 'L': /* PY_LONG_LONG int */ - { - (void) va_arg(*p_va, PY_LONG_LONG *); - break; - } -#endif - - case 'f': /* float */ - { - (void) va_arg(*p_va, float *); - break; - } - - case 'd': /* double */ - { - (void) va_arg(*p_va, double *); - break; - } - -#ifndef WITHOUT_COMPLEX - case 'D': /* complex double */ - { - (void) va_arg(*p_va, Py_complex *); - break; - } -#endif /* WITHOUT_COMPLEX */ - - case 'c': /* char */ - { - (void) va_arg(*p_va, char *); - break; - } - - case 's': /* string */ - { - (void) va_arg(*p_va, char **); - if (*format == '#') { - (void) va_arg(*p_va, int *); - format++; - } - break; - } - - case 'z': /* string */ - { - (void) va_arg(*p_va, char **); - if (*format == '#') { - (void) va_arg(*p_va, int *); - format++; - } - break; - } - - case 'S': /* string object */ - { - (void) va_arg(*p_va, PyObject **); - break; - } - - case 'O': /* object */ - { - if (*format == '!') { - format++; - (void) va_arg(*p_va, PyTypeObject*); - (void) va_arg(*p_va, PyObject **); - } -#if 0 -/* I don't know what this is for */ - else if (*format == '?') { - inquiry pred = va_arg(*p_va, inquiry); - format++; - if ((*pred)(arg)) { - (void) va_arg(*p_va, PyObject **); - } - } -#endif - else if (*format == '&') { - typedef int (*converter)(PyObject *, void *); - (void) va_arg(*p_va, converter); - (void) va_arg(*p_va, void *); - format++; - } - else { - (void) va_arg(*p_va, PyObject **); - } - break; - } - - default: - return "impossible"; - - } - - *p_format = format; - return NULL; -} - - -int -PyArg_UnpackTuple(PyObject *args, char *name, int min, int max, ...) -{ - int i, l; - PyObject **o; - va_list vargs; - -#ifdef HAVE_STDARG_PROTOTYPES - va_start(vargs, max); -#else - va_start(vargs); -#endif - - assert(min >= 0); - assert(min <= max); - if (!PyTuple_Check(args)) { - PyErr_SetString(PyExc_SystemError, - "PyArg_UnpackTuple() argument list is not a tuple"); - return 0; - } - l = PyTuple_GET_SIZE(args); - if (l < min) { - if (name != NULL) - PyErr_Format( - PyExc_TypeError, - "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at least "), min, l); - else - PyErr_Format( - PyExc_TypeError, - "unpacked tuple should have %s%d elements," - " but has %d", - (min == max ? "" : "at least "), min, l); - va_end(vargs); - return 0; - } - if (l > max) { - if (name != NULL) - PyErr_Format( - PyExc_TypeError, - "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at most "), max, l); - else - PyErr_Format( - PyExc_TypeError, - "unpacked tuple should have %s%d elements," - " but has %d", - (min == max ? "" : "at most "), max, l); - va_end(vargs); - return 0; - } - for (i = 0; i < l; i++) { - o = va_arg(vargs, PyObject **); - *o = PyTuple_GET_ITEM(args, i); - } - va_end(vargs); - return 1; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/getcompiler.c b/SDKs/XPlatform/Cypython-2.3.3/Python/getcompiler.c deleted file mode 100644 index 33a7639a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/getcompiler.c +++ /dev/null @@ -1,28 +0,0 @@ - -/* Return the compiler identification, if possible. */ - -#include "Python.h" - -#ifndef COMPILER - -#ifdef __GNUC__ -#define COMPILER "\n[GCC " __VERSION__ "]" -#endif - -#endif /* !COMPILER */ - -#ifndef COMPILER - -#ifdef __cplusplus -#define COMPILER "[C++]" -#else -#define COMPILER "[C]" -#endif - -#endif /* !COMPILER */ - -const char * -Py_GetCompiler(void) -{ - return COMPILER; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/getcopyright.c b/SDKs/XPlatform/Cypython-2.3.3/Python/getcopyright.c deleted file mode 100644 index e60c57ca..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/getcopyright.c +++ /dev/null @@ -1,23 +0,0 @@ -/* Return the copyright string. This is updated manually. */ - -#include "Python.h" - -static char cprt[] = -"\ -Copyright (c) 2001, 2002, 2003 Python Software Foundation.\n\ -All Rights Reserved.\n\ -\n\ -Copyright (c) 2000 BeOpen.com.\n\ -All Rights Reserved.\n\ -\n\ -Copyright (c) 1995-2001 Corporation for National Research Initiatives.\n\ -All Rights Reserved.\n\ -\n\ -Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n\ -All Rights Reserved."; - -const char * -Py_GetCopyright(void) -{ - return cprt; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/getcwd.c b/SDKs/XPlatform/Cypython-2.3.3/Python/getcwd.c deleted file mode 100644 index c53d8e38..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/getcwd.c +++ /dev/null @@ -1,79 +0,0 @@ - -/* Two PD getcwd() implementations. - Author: Guido van Rossum, CWI Amsterdam, Jan 1991, . */ - -#include -#include - -#ifdef HAVE_GETWD - -/* Version for BSD systems -- use getwd() */ - -#ifdef HAVE_SYS_PARAM_H -#include -#endif - -#ifndef MAXPATHLEN -#define MAXPATHLEN 1024 -#endif - -extern char *getwd(char *); - -char * -getcwd(char *buf, int size) -{ - char localbuf[MAXPATHLEN+1]; - char *ret; - - if (size <= 0) { - errno = EINVAL; - return NULL; - } - ret = getwd(localbuf); - if (ret != NULL && strlen(localbuf) >= (size_t)size) { - errno = ERANGE; - return NULL; - } - if (ret == NULL) { - errno = EACCES; /* Most likely error */ - return NULL; - } - strncpy(buf, localbuf, size); - return buf; -} - -#else /* !HAVE_GETWD */ - -/* Version for really old UNIX systems -- use pipe from pwd */ - -#ifndef PWD_CMD -#define PWD_CMD "/bin/pwd" -#endif - -char * -getcwd(char *buf, int size) -{ - FILE *fp; - char *p; - int sts; - if (size <= 0) { - errno = EINVAL; - return NULL; - } - if ((fp = popen(PWD_CMD, "r")) == NULL) - return NULL; - if (fgets(buf, size, fp) == NULL || (sts = pclose(fp)) != 0) { - errno = EACCES; /* Most likely error */ - return NULL; - } - for (p = buf; *p != '\n'; p++) { - if (*p == '\0') { - errno = ERANGE; - return NULL; - } - } - *p = '\0'; - return buf; -} - -#endif /* !HAVE_GETWD */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/getmtime.c b/SDKs/XPlatform/Cypython-2.3.3/Python/getmtime.c deleted file mode 100644 index 0c1eea21..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/getmtime.c +++ /dev/null @@ -1,21 +0,0 @@ - -/* Subroutine to get the last modification time of a file */ - -/* (A separate file because this may be OS dependent) */ - -#include "Python.h" -#include "pyconfig.h" - -time_t -PyOS_GetLastModificationTime(char *path, FILE *fp) -{ - struct stat st; - /*if (fstat(fileno(fp), &st) != 0) - return -1; - else - return st.st_mtime;*/ - if (stat(path, &st) != 0) // use stat because fstat breaks in debug (end result should be identical) - return -1; - else - return st.st_mtime; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/getopt.c b/SDKs/XPlatform/Cypython-2.3.3/Python/getopt.c deleted file mode 100644 index 2401a553..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/getopt.c +++ /dev/null @@ -1,83 +0,0 @@ -/*---------------------------------------------------------------------------* - * - * - * C++ Library - * - * Copyright 1992-1994, David Gottner - * - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice, this permission notice and - * the following disclaimer notice appear unmodified in all copies. - * - * I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL I - * BE LIABLE FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Nevertheless, I would like to know about bugs in this library or - * suggestions for improvment. Send bug reports and feedback to - * davegottner@delphi.com. - *---------------------------------------------------------------------------*/ - -#include -#include - -int _PyOS_opterr = 1; /* generate error messages */ -int _PyOS_optind = 1; /* index into argv array */ -char *_PyOS_optarg = NULL; /* optional argument */ - -int _PyOS_GetOpt(int argc, char **argv, char *optstring) -{ - static char *opt_ptr = ""; - char *ptr; - int option; - - if (*opt_ptr == '\0') { - - if (_PyOS_optind >= argc || argv[_PyOS_optind][0] != '-' || - argv[_PyOS_optind][1] == '\0' /* lone dash */ ) - return -1; - - else if (strcmp(argv[_PyOS_optind], "--") == 0) { - ++_PyOS_optind; - return -1; - } - - opt_ptr = &argv[_PyOS_optind++][1]; - } - - if ( (option = *opt_ptr++) == '\0') - return -1; - - if ((ptr = strchr(optstring, option)) == NULL) { - if (_PyOS_opterr) - fprintf(stderr, "Unknown option: -%c\n", option); - - return '?'; - } - - if (*(ptr + 1) == ':') { - if (*opt_ptr != '\0') { - _PyOS_optarg = opt_ptr; - opt_ptr = ""; - } - - else { - if (_PyOS_optind >= argc) { - if (_PyOS_opterr) - fprintf(stderr, - "Argument expected for the -%c option\n", option); - return '?'; - } - - _PyOS_optarg = argv[_PyOS_optind++]; - } - } - - return option; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/getplatform.c b/SDKs/XPlatform/Cypython-2.3.3/Python/getplatform.c deleted file mode 100644 index ce79ffe2..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/getplatform.c +++ /dev/null @@ -1,12 +0,0 @@ - -#include "Python.h" - -#ifndef PLATFORM -#define PLATFORM "unknown" -#endif - -const char * -Py_GetPlatform(void) -{ - return PLATFORM; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/getversion.c b/SDKs/XPlatform/Cypython-2.3.3/Python/getversion.c deleted file mode 100644 index 7c75348f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/getversion.c +++ /dev/null @@ -1,15 +0,0 @@ - -/* Return the full version string. */ - -#include "Python.h" - -#include "patchlevel.h" - -const char * -Py_GetVersion(void) -{ - static char version[250]; - PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.80s", - PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler()); - return version; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/graminit.c b/SDKs/XPlatform/Cypython-2.3.3/Python/graminit.c deleted file mode 100644 index d951abc3..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/graminit.c +++ /dev/null @@ -1,1770 +0,0 @@ -#include "pgenheaders.h" -#include "grammar.h" -static arc arcs_0_0[3] = { - {2, 1}, - {3, 1}, - {4, 2}, -}; -static arc arcs_0_1[1] = { - {0, 1}, -}; -static arc arcs_0_2[1] = { - {2, 1}, -}; -static state states_0[3] = { - {3, arcs_0_0}, - {1, arcs_0_1}, - {1, arcs_0_2}, -}; -static arc arcs_1_0[3] = { - {2, 0}, - {6, 0}, - {7, 1}, -}; -static arc arcs_1_1[1] = { - {0, 1}, -}; -static state states_1[2] = { - {3, arcs_1_0}, - {1, arcs_1_1}, -}; -static arc arcs_2_0[1] = { - {9, 1}, -}; -static arc arcs_2_1[2] = { - {2, 1}, - {7, 2}, -}; -static arc arcs_2_2[1] = { - {0, 2}, -}; -static state states_2[3] = { - {1, arcs_2_0}, - {2, arcs_2_1}, - {1, arcs_2_2}, -}; -static arc arcs_3_0[1] = { - {11, 1}, -}; -static arc arcs_3_1[1] = { - {12, 2}, -}; -static arc arcs_3_2[1] = { - {13, 3}, -}; -static arc arcs_3_3[1] = { - {14, 4}, -}; -static arc arcs_3_4[1] = { - {15, 5}, -}; -static arc arcs_3_5[1] = { - {0, 5}, -}; -static state states_3[6] = { - {1, arcs_3_0}, - {1, arcs_3_1}, - {1, arcs_3_2}, - {1, arcs_3_3}, - {1, arcs_3_4}, - {1, arcs_3_5}, -}; -static arc arcs_4_0[1] = { - {16, 1}, -}; -static arc arcs_4_1[2] = { - {17, 2}, - {18, 3}, -}; -static arc arcs_4_2[1] = { - {18, 3}, -}; -static arc arcs_4_3[1] = { - {0, 3}, -}; -static state states_4[4] = { - {1, arcs_4_0}, - {2, arcs_4_1}, - {1, arcs_4_2}, - {1, arcs_4_3}, -}; -static arc arcs_5_0[3] = { - {19, 1}, - {23, 2}, - {24, 3}, -}; -static arc arcs_5_1[3] = { - {20, 4}, - {22, 5}, - {0, 1}, -}; -static arc arcs_5_2[1] = { - {12, 6}, -}; -static arc arcs_5_3[1] = { - {12, 7}, -}; -static arc arcs_5_4[1] = { - {21, 8}, -}; -static arc arcs_5_5[4] = { - {19, 1}, - {23, 2}, - {24, 3}, - {0, 5}, -}; -static arc arcs_5_6[2] = { - {22, 9}, - {0, 6}, -}; -static arc arcs_5_7[1] = { - {0, 7}, -}; -static arc arcs_5_8[2] = { - {22, 5}, - {0, 8}, -}; -static arc arcs_5_9[1] = { - {24, 3}, -}; -static state states_5[10] = { - {3, arcs_5_0}, - {3, arcs_5_1}, - {1, arcs_5_2}, - {1, arcs_5_3}, - {1, arcs_5_4}, - {4, arcs_5_5}, - {2, arcs_5_6}, - {1, arcs_5_7}, - {2, arcs_5_8}, - {1, arcs_5_9}, -}; -static arc arcs_6_0[2] = { - {12, 1}, - {16, 2}, -}; -static arc arcs_6_1[1] = { - {0, 1}, -}; -static arc arcs_6_2[1] = { - {25, 3}, -}; -static arc arcs_6_3[1] = { - {18, 1}, -}; -static state states_6[4] = { - {2, arcs_6_0}, - {1, arcs_6_1}, - {1, arcs_6_2}, - {1, arcs_6_3}, -}; -static arc arcs_7_0[1] = { - {19, 1}, -}; -static arc arcs_7_1[2] = { - {22, 2}, - {0, 1}, -}; -static arc arcs_7_2[2] = { - {19, 1}, - {0, 2}, -}; -static state states_7[3] = { - {1, arcs_7_0}, - {2, arcs_7_1}, - {2, arcs_7_2}, -}; -static arc arcs_8_0[2] = { - {3, 1}, - {4, 1}, -}; -static arc arcs_8_1[1] = { - {0, 1}, -}; -static state states_8[2] = { - {2, arcs_8_0}, - {1, arcs_8_1}, -}; -static arc arcs_9_0[1] = { - {26, 1}, -}; -static arc arcs_9_1[2] = { - {27, 2}, - {2, 3}, -}; -static arc arcs_9_2[2] = { - {26, 1}, - {2, 3}, -}; -static arc arcs_9_3[1] = { - {0, 3}, -}; -static state states_9[4] = { - {1, arcs_9_0}, - {2, arcs_9_1}, - {2, arcs_9_2}, - {1, arcs_9_3}, -}; -static arc arcs_10_0[9] = { - {28, 1}, - {29, 1}, - {30, 1}, - {31, 1}, - {32, 1}, - {33, 1}, - {34, 1}, - {35, 1}, - {36, 1}, -}; -static arc arcs_10_1[1] = { - {0, 1}, -}; -static state states_10[2] = { - {9, arcs_10_0}, - {1, arcs_10_1}, -}; -static arc arcs_11_0[1] = { - {9, 1}, -}; -static arc arcs_11_1[3] = { - {37, 2}, - {20, 3}, - {0, 1}, -}; -static arc arcs_11_2[1] = { - {9, 4}, -}; -static arc arcs_11_3[1] = { - {9, 5}, -}; -static arc arcs_11_4[1] = { - {0, 4}, -}; -static arc arcs_11_5[2] = { - {20, 3}, - {0, 5}, -}; -static state states_11[6] = { - {1, arcs_11_0}, - {3, arcs_11_1}, - {1, arcs_11_2}, - {1, arcs_11_3}, - {1, arcs_11_4}, - {2, arcs_11_5}, -}; -static arc arcs_12_0[12] = { - {38, 1}, - {39, 1}, - {40, 1}, - {41, 1}, - {42, 1}, - {43, 1}, - {44, 1}, - {45, 1}, - {46, 1}, - {47, 1}, - {48, 1}, - {49, 1}, -}; -static arc arcs_12_1[1] = { - {0, 1}, -}; -static state states_12[2] = { - {12, arcs_12_0}, - {1, arcs_12_1}, -}; -static arc arcs_13_0[1] = { - {50, 1}, -}; -static arc arcs_13_1[3] = { - {21, 2}, - {51, 3}, - {0, 1}, -}; -static arc arcs_13_2[2] = { - {22, 4}, - {0, 2}, -}; -static arc arcs_13_3[1] = { - {21, 5}, -}; -static arc arcs_13_4[2] = { - {21, 2}, - {0, 4}, -}; -static arc arcs_13_5[2] = { - {22, 6}, - {0, 5}, -}; -static arc arcs_13_6[1] = { - {21, 7}, -}; -static arc arcs_13_7[2] = { - {22, 8}, - {0, 7}, -}; -static arc arcs_13_8[2] = { - {21, 7}, - {0, 8}, -}; -static state states_13[9] = { - {1, arcs_13_0}, - {3, arcs_13_1}, - {2, arcs_13_2}, - {1, arcs_13_3}, - {2, arcs_13_4}, - {2, arcs_13_5}, - {1, arcs_13_6}, - {2, arcs_13_7}, - {2, arcs_13_8}, -}; -static arc arcs_14_0[1] = { - {52, 1}, -}; -static arc arcs_14_1[1] = { - {53, 2}, -}; -static arc arcs_14_2[1] = { - {0, 2}, -}; -static state states_14[3] = { - {1, arcs_14_0}, - {1, arcs_14_1}, - {1, arcs_14_2}, -}; -static arc arcs_15_0[1] = { - {54, 1}, -}; -static arc arcs_15_1[1] = { - {0, 1}, -}; -static state states_15[2] = { - {1, arcs_15_0}, - {1, arcs_15_1}, -}; -static arc arcs_16_0[5] = { - {55, 1}, - {56, 1}, - {57, 1}, - {58, 1}, - {59, 1}, -}; -static arc arcs_16_1[1] = { - {0, 1}, -}; -static state states_16[2] = { - {5, arcs_16_0}, - {1, arcs_16_1}, -}; -static arc arcs_17_0[1] = { - {60, 1}, -}; -static arc arcs_17_1[1] = { - {0, 1}, -}; -static state states_17[2] = { - {1, arcs_17_0}, - {1, arcs_17_1}, -}; -static arc arcs_18_0[1] = { - {61, 1}, -}; -static arc arcs_18_1[1] = { - {0, 1}, -}; -static state states_18[2] = { - {1, arcs_18_0}, - {1, arcs_18_1}, -}; -static arc arcs_19_0[1] = { - {62, 1}, -}; -static arc arcs_19_1[2] = { - {9, 2}, - {0, 1}, -}; -static arc arcs_19_2[1] = { - {0, 2}, -}; -static state states_19[3] = { - {1, arcs_19_0}, - {2, arcs_19_1}, - {1, arcs_19_2}, -}; -static arc arcs_20_0[1] = { - {63, 1}, -}; -static arc arcs_20_1[1] = { - {9, 2}, -}; -static arc arcs_20_2[1] = { - {0, 2}, -}; -static state states_20[3] = { - {1, arcs_20_0}, - {1, arcs_20_1}, - {1, arcs_20_2}, -}; -static arc arcs_21_0[1] = { - {64, 1}, -}; -static arc arcs_21_1[2] = { - {21, 2}, - {0, 1}, -}; -static arc arcs_21_2[2] = { - {22, 3}, - {0, 2}, -}; -static arc arcs_21_3[1] = { - {21, 4}, -}; -static arc arcs_21_4[2] = { - {22, 5}, - {0, 4}, -}; -static arc arcs_21_5[1] = { - {21, 6}, -}; -static arc arcs_21_6[1] = { - {0, 6}, -}; -static state states_21[7] = { - {1, arcs_21_0}, - {2, arcs_21_1}, - {2, arcs_21_2}, - {1, arcs_21_3}, - {2, arcs_21_4}, - {1, arcs_21_5}, - {1, arcs_21_6}, -}; -static arc arcs_22_0[2] = { - {65, 1}, - {67, 2}, -}; -static arc arcs_22_1[1] = { - {66, 3}, -}; -static arc arcs_22_2[1] = { - {68, 4}, -}; -static arc arcs_22_3[2] = { - {22, 1}, - {0, 3}, -}; -static arc arcs_22_4[1] = { - {65, 5}, -}; -static arc arcs_22_5[2] = { - {23, 6}, - {69, 7}, -}; -static arc arcs_22_6[1] = { - {0, 6}, -}; -static arc arcs_22_7[2] = { - {22, 8}, - {0, 7}, -}; -static arc arcs_22_8[1] = { - {69, 7}, -}; -static state states_22[9] = { - {2, arcs_22_0}, - {1, arcs_22_1}, - {1, arcs_22_2}, - {2, arcs_22_3}, - {1, arcs_22_4}, - {2, arcs_22_5}, - {1, arcs_22_6}, - {2, arcs_22_7}, - {1, arcs_22_8}, -}; -static arc arcs_23_0[1] = { - {12, 1}, -}; -static arc arcs_23_1[2] = { - {12, 2}, - {0, 1}, -}; -static arc arcs_23_2[1] = { - {12, 3}, -}; -static arc arcs_23_3[1] = { - {0, 3}, -}; -static state states_23[4] = { - {1, arcs_23_0}, - {2, arcs_23_1}, - {1, arcs_23_2}, - {1, arcs_23_3}, -}; -static arc arcs_24_0[1] = { - {68, 1}, -}; -static arc arcs_24_1[2] = { - {12, 2}, - {0, 1}, -}; -static arc arcs_24_2[1] = { - {12, 3}, -}; -static arc arcs_24_3[1] = { - {0, 3}, -}; -static state states_24[4] = { - {1, arcs_24_0}, - {2, arcs_24_1}, - {1, arcs_24_2}, - {1, arcs_24_3}, -}; -static arc arcs_25_0[1] = { - {12, 1}, -}; -static arc arcs_25_1[2] = { - {70, 0}, - {0, 1}, -}; -static state states_25[2] = { - {1, arcs_25_0}, - {2, arcs_25_1}, -}; -static arc arcs_26_0[1] = { - {71, 1}, -}; -static arc arcs_26_1[1] = { - {12, 2}, -}; -static arc arcs_26_2[2] = { - {22, 1}, - {0, 2}, -}; -static state states_26[3] = { - {1, arcs_26_0}, - {1, arcs_26_1}, - {2, arcs_26_2}, -}; -static arc arcs_27_0[1] = { - {72, 1}, -}; -static arc arcs_27_1[1] = { - {73, 2}, -}; -static arc arcs_27_2[2] = { - {74, 3}, - {0, 2}, -}; -static arc arcs_27_3[1] = { - {21, 4}, -}; -static arc arcs_27_4[2] = { - {22, 5}, - {0, 4}, -}; -static arc arcs_27_5[1] = { - {21, 6}, -}; -static arc arcs_27_6[1] = { - {0, 6}, -}; -static state states_27[7] = { - {1, arcs_27_0}, - {1, arcs_27_1}, - {2, arcs_27_2}, - {1, arcs_27_3}, - {2, arcs_27_4}, - {1, arcs_27_5}, - {1, arcs_27_6}, -}; -static arc arcs_28_0[1] = { - {75, 1}, -}; -static arc arcs_28_1[1] = { - {21, 2}, -}; -static arc arcs_28_2[2] = { - {22, 3}, - {0, 2}, -}; -static arc arcs_28_3[1] = { - {21, 4}, -}; -static arc arcs_28_4[1] = { - {0, 4}, -}; -static state states_28[5] = { - {1, arcs_28_0}, - {1, arcs_28_1}, - {2, arcs_28_2}, - {1, arcs_28_3}, - {1, arcs_28_4}, -}; -static arc arcs_29_0[6] = { - {76, 1}, - {77, 1}, - {78, 1}, - {79, 1}, - {10, 1}, - {80, 1}, -}; -static arc arcs_29_1[1] = { - {0, 1}, -}; -static state states_29[2] = { - {6, arcs_29_0}, - {1, arcs_29_1}, -}; -static arc arcs_30_0[1] = { - {81, 1}, -}; -static arc arcs_30_1[1] = { - {21, 2}, -}; -static arc arcs_30_2[1] = { - {14, 3}, -}; -static arc arcs_30_3[1] = { - {15, 4}, -}; -static arc arcs_30_4[3] = { - {82, 1}, - {83, 5}, - {0, 4}, -}; -static arc arcs_30_5[1] = { - {14, 6}, -}; -static arc arcs_30_6[1] = { - {15, 7}, -}; -static arc arcs_30_7[1] = { - {0, 7}, -}; -static state states_30[8] = { - {1, arcs_30_0}, - {1, arcs_30_1}, - {1, arcs_30_2}, - {1, arcs_30_3}, - {3, arcs_30_4}, - {1, arcs_30_5}, - {1, arcs_30_6}, - {1, arcs_30_7}, -}; -static arc arcs_31_0[1] = { - {84, 1}, -}; -static arc arcs_31_1[1] = { - {21, 2}, -}; -static arc arcs_31_2[1] = { - {14, 3}, -}; -static arc arcs_31_3[1] = { - {15, 4}, -}; -static arc arcs_31_4[2] = { - {83, 5}, - {0, 4}, -}; -static arc arcs_31_5[1] = { - {14, 6}, -}; -static arc arcs_31_6[1] = { - {15, 7}, -}; -static arc arcs_31_7[1] = { - {0, 7}, -}; -static state states_31[8] = { - {1, arcs_31_0}, - {1, arcs_31_1}, - {1, arcs_31_2}, - {1, arcs_31_3}, - {2, arcs_31_4}, - {1, arcs_31_5}, - {1, arcs_31_6}, - {1, arcs_31_7}, -}; -static arc arcs_32_0[1] = { - {85, 1}, -}; -static arc arcs_32_1[1] = { - {53, 2}, -}; -static arc arcs_32_2[1] = { - {74, 3}, -}; -static arc arcs_32_3[1] = { - {9, 4}, -}; -static arc arcs_32_4[1] = { - {14, 5}, -}; -static arc arcs_32_5[1] = { - {15, 6}, -}; -static arc arcs_32_6[2] = { - {83, 7}, - {0, 6}, -}; -static arc arcs_32_7[1] = { - {14, 8}, -}; -static arc arcs_32_8[1] = { - {15, 9}, -}; -static arc arcs_32_9[1] = { - {0, 9}, -}; -static state states_32[10] = { - {1, arcs_32_0}, - {1, arcs_32_1}, - {1, arcs_32_2}, - {1, arcs_32_3}, - {1, arcs_32_4}, - {1, arcs_32_5}, - {2, arcs_32_6}, - {1, arcs_32_7}, - {1, arcs_32_8}, - {1, arcs_32_9}, -}; -static arc arcs_33_0[1] = { - {86, 1}, -}; -static arc arcs_33_1[1] = { - {14, 2}, -}; -static arc arcs_33_2[1] = { - {15, 3}, -}; -static arc arcs_33_3[2] = { - {87, 4}, - {88, 5}, -}; -static arc arcs_33_4[1] = { - {14, 6}, -}; -static arc arcs_33_5[1] = { - {14, 7}, -}; -static arc arcs_33_6[1] = { - {15, 8}, -}; -static arc arcs_33_7[1] = { - {15, 9}, -}; -static arc arcs_33_8[3] = { - {87, 4}, - {83, 5}, - {0, 8}, -}; -static arc arcs_33_9[1] = { - {0, 9}, -}; -static state states_33[10] = { - {1, arcs_33_0}, - {1, arcs_33_1}, - {1, arcs_33_2}, - {2, arcs_33_3}, - {1, arcs_33_4}, - {1, arcs_33_5}, - {1, arcs_33_6}, - {1, arcs_33_7}, - {3, arcs_33_8}, - {1, arcs_33_9}, -}; -static arc arcs_34_0[1] = { - {89, 1}, -}; -static arc arcs_34_1[2] = { - {21, 2}, - {0, 1}, -}; -static arc arcs_34_2[2] = { - {22, 3}, - {0, 2}, -}; -static arc arcs_34_3[1] = { - {21, 4}, -}; -static arc arcs_34_4[1] = { - {0, 4}, -}; -static state states_34[5] = { - {1, arcs_34_0}, - {2, arcs_34_1}, - {2, arcs_34_2}, - {1, arcs_34_3}, - {1, arcs_34_4}, -}; -static arc arcs_35_0[2] = { - {3, 1}, - {2, 2}, -}; -static arc arcs_35_1[1] = { - {0, 1}, -}; -static arc arcs_35_2[1] = { - {90, 3}, -}; -static arc arcs_35_3[1] = { - {6, 4}, -}; -static arc arcs_35_4[2] = { - {6, 4}, - {91, 1}, -}; -static state states_35[5] = { - {2, arcs_35_0}, - {1, arcs_35_1}, - {1, arcs_35_2}, - {1, arcs_35_3}, - {2, arcs_35_4}, -}; -static arc arcs_36_0[2] = { - {92, 1}, - {94, 2}, -}; -static arc arcs_36_1[2] = { - {93, 3}, - {0, 1}, -}; -static arc arcs_36_2[1] = { - {0, 2}, -}; -static arc arcs_36_3[1] = { - {92, 1}, -}; -static state states_36[4] = { - {2, arcs_36_0}, - {2, arcs_36_1}, - {1, arcs_36_2}, - {1, arcs_36_3}, -}; -static arc arcs_37_0[1] = { - {95, 1}, -}; -static arc arcs_37_1[2] = { - {96, 0}, - {0, 1}, -}; -static state states_37[2] = { - {1, arcs_37_0}, - {2, arcs_37_1}, -}; -static arc arcs_38_0[2] = { - {97, 1}, - {98, 2}, -}; -static arc arcs_38_1[1] = { - {95, 2}, -}; -static arc arcs_38_2[1] = { - {0, 2}, -}; -static state states_38[3] = { - {2, arcs_38_0}, - {1, arcs_38_1}, - {1, arcs_38_2}, -}; -static arc arcs_39_0[1] = { - {73, 1}, -}; -static arc arcs_39_1[2] = { - {99, 0}, - {0, 1}, -}; -static state states_39[2] = { - {1, arcs_39_0}, - {2, arcs_39_1}, -}; -static arc arcs_40_0[10] = { - {100, 1}, - {101, 1}, - {102, 1}, - {103, 1}, - {104, 1}, - {105, 1}, - {106, 1}, - {74, 1}, - {97, 2}, - {107, 3}, -}; -static arc arcs_40_1[1] = { - {0, 1}, -}; -static arc arcs_40_2[1] = { - {74, 1}, -}; -static arc arcs_40_3[2] = { - {97, 1}, - {0, 3}, -}; -static state states_40[4] = { - {10, arcs_40_0}, - {1, arcs_40_1}, - {1, arcs_40_2}, - {2, arcs_40_3}, -}; -static arc arcs_41_0[1] = { - {108, 1}, -}; -static arc arcs_41_1[2] = { - {109, 0}, - {0, 1}, -}; -static state states_41[2] = { - {1, arcs_41_0}, - {2, arcs_41_1}, -}; -static arc arcs_42_0[1] = { - {110, 1}, -}; -static arc arcs_42_1[2] = { - {111, 0}, - {0, 1}, -}; -static state states_42[2] = { - {1, arcs_42_0}, - {2, arcs_42_1}, -}; -static arc arcs_43_0[1] = { - {112, 1}, -}; -static arc arcs_43_1[2] = { - {113, 0}, - {0, 1}, -}; -static state states_43[2] = { - {1, arcs_43_0}, - {2, arcs_43_1}, -}; -static arc arcs_44_0[1] = { - {114, 1}, -}; -static arc arcs_44_1[3] = { - {115, 0}, - {51, 0}, - {0, 1}, -}; -static state states_44[2] = { - {1, arcs_44_0}, - {3, arcs_44_1}, -}; -static arc arcs_45_0[1] = { - {116, 1}, -}; -static arc arcs_45_1[3] = { - {117, 0}, - {118, 0}, - {0, 1}, -}; -static state states_45[2] = { - {1, arcs_45_0}, - {3, arcs_45_1}, -}; -static arc arcs_46_0[1] = { - {119, 1}, -}; -static arc arcs_46_1[5] = { - {23, 0}, - {120, 0}, - {121, 0}, - {122, 0}, - {0, 1}, -}; -static state states_46[2] = { - {1, arcs_46_0}, - {5, arcs_46_1}, -}; -static arc arcs_47_0[4] = { - {117, 1}, - {118, 1}, - {123, 1}, - {124, 2}, -}; -static arc arcs_47_1[1] = { - {119, 2}, -}; -static arc arcs_47_2[1] = { - {0, 2}, -}; -static state states_47[3] = { - {4, arcs_47_0}, - {1, arcs_47_1}, - {1, arcs_47_2}, -}; -static arc arcs_48_0[1] = { - {125, 1}, -}; -static arc arcs_48_1[3] = { - {126, 1}, - {24, 2}, - {0, 1}, -}; -static arc arcs_48_2[1] = { - {119, 3}, -}; -static arc arcs_48_3[1] = { - {0, 3}, -}; -static state states_48[4] = { - {1, arcs_48_0}, - {3, arcs_48_1}, - {1, arcs_48_2}, - {1, arcs_48_3}, -}; -static arc arcs_49_0[7] = { - {16, 1}, - {127, 2}, - {130, 3}, - {133, 4}, - {12, 5}, - {135, 5}, - {136, 6}, -}; -static arc arcs_49_1[2] = { - {9, 7}, - {18, 5}, -}; -static arc arcs_49_2[2] = { - {128, 8}, - {129, 5}, -}; -static arc arcs_49_3[2] = { - {131, 9}, - {132, 5}, -}; -static arc arcs_49_4[1] = { - {134, 10}, -}; -static arc arcs_49_5[1] = { - {0, 5}, -}; -static arc arcs_49_6[2] = { - {136, 6}, - {0, 6}, -}; -static arc arcs_49_7[1] = { - {18, 5}, -}; -static arc arcs_49_8[1] = { - {129, 5}, -}; -static arc arcs_49_9[1] = { - {132, 5}, -}; -static arc arcs_49_10[1] = { - {133, 5}, -}; -static state states_49[11] = { - {7, arcs_49_0}, - {2, arcs_49_1}, - {2, arcs_49_2}, - {2, arcs_49_3}, - {1, arcs_49_4}, - {1, arcs_49_5}, - {2, arcs_49_6}, - {1, arcs_49_7}, - {1, arcs_49_8}, - {1, arcs_49_9}, - {1, arcs_49_10}, -}; -static arc arcs_50_0[1] = { - {21, 1}, -}; -static arc arcs_50_1[3] = { - {137, 2}, - {22, 3}, - {0, 1}, -}; -static arc arcs_50_2[1] = { - {0, 2}, -}; -static arc arcs_50_3[2] = { - {21, 4}, - {0, 3}, -}; -static arc arcs_50_4[2] = { - {22, 3}, - {0, 4}, -}; -static state states_50[5] = { - {1, arcs_50_0}, - {3, arcs_50_1}, - {1, arcs_50_2}, - {2, arcs_50_3}, - {2, arcs_50_4}, -}; -static arc arcs_51_0[1] = { - {138, 1}, -}; -static arc arcs_51_1[2] = { - {17, 2}, - {14, 3}, -}; -static arc arcs_51_2[1] = { - {14, 3}, -}; -static arc arcs_51_3[1] = { - {21, 4}, -}; -static arc arcs_51_4[1] = { - {0, 4}, -}; -static state states_51[5] = { - {1, arcs_51_0}, - {2, arcs_51_1}, - {1, arcs_51_2}, - {1, arcs_51_3}, - {1, arcs_51_4}, -}; -static arc arcs_52_0[3] = { - {16, 1}, - {127, 2}, - {70, 3}, -}; -static arc arcs_52_1[2] = { - {139, 4}, - {18, 5}, -}; -static arc arcs_52_2[1] = { - {140, 6}, -}; -static arc arcs_52_3[1] = { - {12, 5}, -}; -static arc arcs_52_4[1] = { - {18, 5}, -}; -static arc arcs_52_5[1] = { - {0, 5}, -}; -static arc arcs_52_6[1] = { - {129, 5}, -}; -static state states_52[7] = { - {3, arcs_52_0}, - {2, arcs_52_1}, - {1, arcs_52_2}, - {1, arcs_52_3}, - {1, arcs_52_4}, - {1, arcs_52_5}, - {1, arcs_52_6}, -}; -static arc arcs_53_0[1] = { - {141, 1}, -}; -static arc arcs_53_1[2] = { - {22, 2}, - {0, 1}, -}; -static arc arcs_53_2[2] = { - {141, 1}, - {0, 2}, -}; -static state states_53[3] = { - {1, arcs_53_0}, - {2, arcs_53_1}, - {2, arcs_53_2}, -}; -static arc arcs_54_0[3] = { - {70, 1}, - {21, 2}, - {14, 3}, -}; -static arc arcs_54_1[1] = { - {70, 4}, -}; -static arc arcs_54_2[2] = { - {14, 3}, - {0, 2}, -}; -static arc arcs_54_3[3] = { - {21, 5}, - {142, 6}, - {0, 3}, -}; -static arc arcs_54_4[1] = { - {70, 6}, -}; -static arc arcs_54_5[2] = { - {142, 6}, - {0, 5}, -}; -static arc arcs_54_6[1] = { - {0, 6}, -}; -static state states_54[7] = { - {3, arcs_54_0}, - {1, arcs_54_1}, - {2, arcs_54_2}, - {3, arcs_54_3}, - {1, arcs_54_4}, - {2, arcs_54_5}, - {1, arcs_54_6}, -}; -static arc arcs_55_0[1] = { - {14, 1}, -}; -static arc arcs_55_1[2] = { - {21, 2}, - {0, 1}, -}; -static arc arcs_55_2[1] = { - {0, 2}, -}; -static state states_55[3] = { - {1, arcs_55_0}, - {2, arcs_55_1}, - {1, arcs_55_2}, -}; -static arc arcs_56_0[1] = { - {73, 1}, -}; -static arc arcs_56_1[2] = { - {22, 2}, - {0, 1}, -}; -static arc arcs_56_2[2] = { - {73, 1}, - {0, 2}, -}; -static state states_56[3] = { - {1, arcs_56_0}, - {2, arcs_56_1}, - {2, arcs_56_2}, -}; -static arc arcs_57_0[1] = { - {21, 1}, -}; -static arc arcs_57_1[2] = { - {22, 2}, - {0, 1}, -}; -static arc arcs_57_2[2] = { - {21, 1}, - {0, 2}, -}; -static state states_57[3] = { - {1, arcs_57_0}, - {2, arcs_57_1}, - {2, arcs_57_2}, -}; -static arc arcs_58_0[1] = { - {21, 1}, -}; -static arc arcs_58_1[2] = { - {22, 2}, - {0, 1}, -}; -static arc arcs_58_2[1] = { - {21, 3}, -}; -static arc arcs_58_3[2] = { - {22, 4}, - {0, 3}, -}; -static arc arcs_58_4[2] = { - {21, 3}, - {0, 4}, -}; -static state states_58[5] = { - {1, arcs_58_0}, - {2, arcs_58_1}, - {1, arcs_58_2}, - {2, arcs_58_3}, - {2, arcs_58_4}, -}; -static arc arcs_59_0[1] = { - {21, 1}, -}; -static arc arcs_59_1[1] = { - {14, 2}, -}; -static arc arcs_59_2[1] = { - {21, 3}, -}; -static arc arcs_59_3[2] = { - {22, 4}, - {0, 3}, -}; -static arc arcs_59_4[2] = { - {21, 1}, - {0, 4}, -}; -static state states_59[5] = { - {1, arcs_59_0}, - {1, arcs_59_1}, - {1, arcs_59_2}, - {2, arcs_59_3}, - {2, arcs_59_4}, -}; -static arc arcs_60_0[1] = { - {144, 1}, -}; -static arc arcs_60_1[1] = { - {12, 2}, -}; -static arc arcs_60_2[2] = { - {16, 3}, - {14, 4}, -}; -static arc arcs_60_3[1] = { - {9, 5}, -}; -static arc arcs_60_4[1] = { - {15, 6}, -}; -static arc arcs_60_5[1] = { - {18, 7}, -}; -static arc arcs_60_6[1] = { - {0, 6}, -}; -static arc arcs_60_7[1] = { - {14, 4}, -}; -static state states_60[8] = { - {1, arcs_60_0}, - {1, arcs_60_1}, - {2, arcs_60_2}, - {1, arcs_60_3}, - {1, arcs_60_4}, - {1, arcs_60_5}, - {1, arcs_60_6}, - {1, arcs_60_7}, -}; -static arc arcs_61_0[3] = { - {145, 1}, - {23, 2}, - {24, 3}, -}; -static arc arcs_61_1[2] = { - {22, 4}, - {0, 1}, -}; -static arc arcs_61_2[1] = { - {21, 5}, -}; -static arc arcs_61_3[1] = { - {21, 6}, -}; -static arc arcs_61_4[4] = { - {145, 1}, - {23, 2}, - {24, 3}, - {0, 4}, -}; -static arc arcs_61_5[2] = { - {22, 7}, - {0, 5}, -}; -static arc arcs_61_6[1] = { - {0, 6}, -}; -static arc arcs_61_7[1] = { - {24, 3}, -}; -static state states_61[8] = { - {3, arcs_61_0}, - {2, arcs_61_1}, - {1, arcs_61_2}, - {1, arcs_61_3}, - {4, arcs_61_4}, - {2, arcs_61_5}, - {1, arcs_61_6}, - {1, arcs_61_7}, -}; -static arc arcs_62_0[1] = { - {21, 1}, -}; -static arc arcs_62_1[2] = { - {20, 2}, - {0, 1}, -}; -static arc arcs_62_2[1] = { - {21, 3}, -}; -static arc arcs_62_3[1] = { - {0, 3}, -}; -static state states_62[4] = { - {1, arcs_62_0}, - {2, arcs_62_1}, - {1, arcs_62_2}, - {1, arcs_62_3}, -}; -static arc arcs_63_0[2] = { - {137, 1}, - {147, 1}, -}; -static arc arcs_63_1[1] = { - {0, 1}, -}; -static state states_63[2] = { - {2, arcs_63_0}, - {1, arcs_63_1}, -}; -static arc arcs_64_0[1] = { - {85, 1}, -}; -static arc arcs_64_1[1] = { - {53, 2}, -}; -static arc arcs_64_2[1] = { - {74, 3}, -}; -static arc arcs_64_3[1] = { - {143, 4}, -}; -static arc arcs_64_4[2] = { - {146, 5}, - {0, 4}, -}; -static arc arcs_64_5[1] = { - {0, 5}, -}; -static state states_64[6] = { - {1, arcs_64_0}, - {1, arcs_64_1}, - {1, arcs_64_2}, - {1, arcs_64_3}, - {2, arcs_64_4}, - {1, arcs_64_5}, -}; -static arc arcs_65_0[1] = { - {81, 1}, -}; -static arc arcs_65_1[1] = { - {21, 2}, -}; -static arc arcs_65_2[2] = { - {146, 3}, - {0, 2}, -}; -static arc arcs_65_3[1] = { - {0, 3}, -}; -static state states_65[4] = { - {1, arcs_65_0}, - {1, arcs_65_1}, - {2, arcs_65_2}, - {1, arcs_65_3}, -}; -static arc arcs_66_0[1] = { - {21, 1}, -}; -static arc arcs_66_1[2] = { - {22, 0}, - {0, 1}, -}; -static state states_66[2] = { - {1, arcs_66_0}, - {2, arcs_66_1}, -}; -static arc arcs_67_0[1] = { - {12, 1}, -}; -static arc arcs_67_1[1] = { - {0, 1}, -}; -static state states_67[2] = { - {1, arcs_67_0}, - {1, arcs_67_1}, -}; -static dfa dfas[68] = { - {256, "single_input", 0, 3, states_0, - "\004\030\001\000\000\000\124\360\213\011\162\000\002\000\140\210\244\005\001"}, - {257, "file_input", 0, 2, states_1, - "\204\030\001\000\000\000\124\360\213\011\162\000\002\000\140\210\244\005\001"}, - {258, "eval_input", 0, 3, states_2, - "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\244\005\000"}, - {259, "funcdef", 0, 6, states_3, - "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {260, "parameters", 0, 4, states_4, - "\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {261, "varargslist", 0, 10, states_5, - "\000\020\201\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {262, "fpdef", 0, 4, states_6, - "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {263, "fplist", 0, 3, states_7, - "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {264, "stmt", 0, 2, states_8, - "\000\030\001\000\000\000\124\360\213\011\162\000\002\000\140\210\244\005\001"}, - {265, "simple_stmt", 0, 4, states_9, - "\000\020\001\000\000\000\124\360\213\011\000\000\002\000\140\210\244\005\000"}, - {266, "small_stmt", 0, 2, states_10, - "\000\020\001\000\000\000\124\360\213\011\000\000\002\000\140\210\244\005\000"}, - {267, "expr_stmt", 0, 6, states_11, - "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\244\005\000"}, - {268, "augassign", 0, 2, states_12, - "\000\000\000\000\300\377\003\000\000\000\000\000\000\000\000\000\000\000\000"}, - {269, "print_stmt", 0, 9, states_13, - "\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000"}, - {270, "del_stmt", 0, 3, states_14, - "\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000"}, - {271, "pass_stmt", 0, 2, states_15, - "\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000"}, - {272, "flow_stmt", 0, 2, states_16, - "\000\000\000\000\000\000\000\360\001\000\000\000\000\000\000\000\000\000\000"}, - {273, "break_stmt", 0, 2, states_17, - "\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000"}, - {274, "continue_stmt", 0, 2, states_18, - "\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000"}, - {275, "return_stmt", 0, 3, states_19, - "\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000"}, - {276, "yield_stmt", 0, 3, states_20, - "\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000"}, - {277, "raise_stmt", 0, 7, states_21, - "\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000"}, - {278, "import_stmt", 0, 9, states_22, - "\000\000\000\000\000\000\000\000\012\000\000\000\000\000\000\000\000\000\000"}, - {279, "import_as_name", 0, 4, states_23, - "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {280, "dotted_as_name", 0, 4, states_24, - "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {281, "dotted_name", 0, 2, states_25, - "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {282, "global_stmt", 0, 3, states_26, - "\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000"}, - {283, "exec_stmt", 0, 7, states_27, - "\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000"}, - {284, "assert_stmt", 0, 5, states_28, - "\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000"}, - {285, "compound_stmt", 0, 2, states_29, - "\000\010\000\000\000\000\000\000\000\000\162\000\000\000\000\000\000\000\001"}, - {286, "if_stmt", 0, 8, states_30, - "\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000"}, - {287, "while_stmt", 0, 8, states_31, - "\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000"}, - {288, "for_stmt", 0, 10, states_32, - "\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"}, - {289, "try_stmt", 0, 10, states_33, - "\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000"}, - {290, "except_clause", 0, 5, states_34, - "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000"}, - {291, "suite", 0, 5, states_35, - "\004\020\001\000\000\000\124\360\213\011\000\000\002\000\140\210\244\005\000"}, - {292, "test", 0, 4, states_36, - "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\244\005\000"}, - {293, "and_test", 0, 2, states_37, - "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\244\001\000"}, - {294, "not_test", 0, 3, states_38, - "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\244\001\000"}, - {295, "comparison", 0, 2, states_39, - "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\244\001\000"}, - {296, "comp_op", 0, 4, states_40, - "\000\000\000\000\000\000\000\000\000\004\000\000\362\017\000\000\000\000\000"}, - {297, "expr", 0, 2, states_41, - "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\244\001\000"}, - {298, "xor_expr", 0, 2, states_42, - "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\244\001\000"}, - {299, "and_expr", 0, 2, states_43, - "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\244\001\000"}, - {300, "shift_expr", 0, 2, states_44, - "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\244\001\000"}, - {301, "arith_expr", 0, 2, states_45, - "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\244\001\000"}, - {302, "term", 0, 2, states_46, - "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\244\001\000"}, - {303, "factor", 0, 3, states_47, - "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\244\001\000"}, - {304, "power", 0, 4, states_48, - "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\200\244\001\000"}, - {305, "atom", 0, 11, states_49, - "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\200\244\001\000"}, - {306, "listmaker", 0, 5, states_50, - "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\244\005\000"}, - {307, "lambdef", 0, 5, states_51, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000"}, - {308, "trailer", 0, 7, states_52, - "\000\000\001\000\000\000\000\000\100\000\000\000\000\000\000\200\000\000\000"}, - {309, "subscriptlist", 0, 3, states_53, - "\000\120\001\000\000\000\000\000\100\000\000\000\002\000\140\210\244\005\000"}, - {310, "subscript", 0, 7, states_54, - "\000\120\001\000\000\000\000\000\100\000\000\000\002\000\140\210\244\005\000"}, - {311, "sliceop", 0, 3, states_55, - "\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {312, "exprlist", 0, 3, states_56, - "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\244\001\000"}, - {313, "testlist", 0, 3, states_57, - "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\244\005\000"}, - {314, "testlist_safe", 0, 5, states_58, - "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\244\005\000"}, - {315, "dictmaker", 0, 5, states_59, - "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\244\005\000"}, - {316, "classdef", 0, 8, states_60, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"}, - {317, "arglist", 0, 8, states_61, - "\000\020\201\001\000\000\000\000\000\000\000\000\002\000\140\210\244\005\000"}, - {318, "argument", 0, 4, states_62, - "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\244\005\000"}, - {319, "list_iter", 0, 2, states_63, - "\000\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000"}, - {320, "list_for", 0, 6, states_64, - "\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"}, - {321, "list_if", 0, 4, states_65, - "\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000"}, - {322, "testlist1", 0, 2, states_66, - "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\244\005\000"}, - {323, "encoding_decl", 0, 2, states_67, - "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, -}; -static label labels[149] = { - {0, "EMPTY"}, - {256, 0}, - {4, 0}, - {265, 0}, - {285, 0}, - {257, 0}, - {264, 0}, - {0, 0}, - {258, 0}, - {313, 0}, - {259, 0}, - {1, "def"}, - {1, 0}, - {260, 0}, - {11, 0}, - {291, 0}, - {7, 0}, - {261, 0}, - {8, 0}, - {262, 0}, - {22, 0}, - {292, 0}, - {12, 0}, - {16, 0}, - {36, 0}, - {263, 0}, - {266, 0}, - {13, 0}, - {267, 0}, - {269, 0}, - {270, 0}, - {271, 0}, - {272, 0}, - {278, 0}, - {282, 0}, - {283, 0}, - {284, 0}, - {268, 0}, - {37, 0}, - {38, 0}, - {39, 0}, - {40, 0}, - {41, 0}, - {42, 0}, - {43, 0}, - {44, 0}, - {45, 0}, - {46, 0}, - {47, 0}, - {49, 0}, - {1, "print"}, - {35, 0}, - {1, "del"}, - {312, 0}, - {1, "pass"}, - {273, 0}, - {274, 0}, - {275, 0}, - {277, 0}, - {276, 0}, - {1, "break"}, - {1, "continue"}, - {1, "return"}, - {1, "yield"}, - {1, "raise"}, - {1, "import"}, - {280, 0}, - {1, "from"}, - {281, 0}, - {279, 0}, - {23, 0}, - {1, "global"}, - {1, "exec"}, - {297, 0}, - {1, "in"}, - {1, "assert"}, - {286, 0}, - {287, 0}, - {288, 0}, - {289, 0}, - {316, 0}, - {1, "if"}, - {1, "elif"}, - {1, "else"}, - {1, "while"}, - {1, "for"}, - {1, "try"}, - {290, 0}, - {1, "finally"}, - {1, "except"}, - {5, 0}, - {6, 0}, - {293, 0}, - {1, "or"}, - {307, 0}, - {294, 0}, - {1, "and"}, - {1, "not"}, - {295, 0}, - {296, 0}, - {20, 0}, - {21, 0}, - {28, 0}, - {31, 0}, - {30, 0}, - {29, 0}, - {29, 0}, - {1, "is"}, - {298, 0}, - {18, 0}, - {299, 0}, - {33, 0}, - {300, 0}, - {19, 0}, - {301, 0}, - {34, 0}, - {302, 0}, - {14, 0}, - {15, 0}, - {303, 0}, - {17, 0}, - {24, 0}, - {48, 0}, - {32, 0}, - {304, 0}, - {305, 0}, - {308, 0}, - {9, 0}, - {306, 0}, - {10, 0}, - {26, 0}, - {315, 0}, - {27, 0}, - {25, 0}, - {322, 0}, - {2, 0}, - {3, 0}, - {320, 0}, - {1, "lambda"}, - {317, 0}, - {309, 0}, - {310, 0}, - {311, 0}, - {314, 0}, - {1, "class"}, - {318, 0}, - {319, 0}, - {321, 0}, - {323, 0}, -}; -grammar _PyParser_Grammar = { - 68, - dfas, - {149, labels}, - 256 -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/hypot.c b/SDKs/XPlatform/Cypython-2.3.3/Python/hypot.c deleted file mode 100644 index cdc430ec..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/hypot.c +++ /dev/null @@ -1,23 +0,0 @@ -/* hypot() replacement */ - -#include "pyconfig.h" -#include "pyport.h" - -double hypot(double x, double y) -{ - double yx; - - x = fabs(x); - y = fabs(y); - if (x < y) { - double temp = x; - x = y; - y = temp; - } - if (x == 0.) - return 0.; - else { - yx = y/x; - return x*sqrt(1.+yx*yx); - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/import.c b/SDKs/XPlatform/Cypython-2.3.3/Python/import.c deleted file mode 100644 index 1c35b5ed..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/import.c +++ /dev/null @@ -1,2920 +0,0 @@ - -/* Module definition and import implementation */ - -#include "Python.h" - -#include "node.h" -#include "token.h" -#include "errcode.h" -#include "marshal.h" -#include "compile.h" -#include "eval.h" -#include "osdefs.h" -#include "importdl.h" -#ifdef macintosh -#include "macglue.h" -#endif - -#ifdef HAVE_FCNTL_H -#include -#endif - -extern time_t PyOS_GetLastModificationTime(char *, FILE *); - /* In getmtime.c */ - -/* Magic word to reject .pyc files generated by other Python versions */ -/* Change for each incompatible change */ -/* The value of CR and LF is incorporated so if you ever read or write - a .pyc file in text mode the magic number will be wrong; also, the - Apple MPW compiler swaps their values, botching string constants. - XXX That probably isn't important anymore. -*/ -/* XXX Perhaps the magic number should be frozen and a version field - added to the .pyc file header? */ -/* New way to come up with the low 16 bits of the magic number: - (YEAR-1995) * 10000 + MONTH * 100 + DAY - where MONTH and DAY are 1-based. - XXX Whatever the "old way" may have been isn't documented. - XXX This scheme breaks in 2002, as (2002-1995)*10000 = 70000 doesn't - fit in 16 bits. - XXX Later, sometimes 1 gets added to MAGIC in order to record that - the Unicode -U option is in use. IMO (Tim's), that's a Bad Idea - (quite apart from that the -U option doesn't work so isn't used - anyway). - - XXX MAL, 2002-02-07: I had to modify the MAGIC due to a fix of the - UTF-8 encoder (it previously produced invalid UTF-8 for unpaired - high surrogates), so I simply bumped the month value to 20 (invalid - month) and set the day to 1. This should be recognizable by any - algorithm relying on the above scheme. Perhaps we should simply - start counting in increments of 10 from now on ?! - - MWH, 2002-08-03: Removed SET_LINENO. Couldn't be bothered figuring - out the MAGIC schemes, so just incremented it by 10. - - GvR, 2002-08-31: Because MWH changed the bytecode again, moved the - magic number *back* to 62011. This should get the snake-farm to - throw away its old .pyc files, amongst others. - - Known values: - Python 1.5: 20121 - Python 1.5.1: 20121 - Python 1.5.2: 20121 - Python 2.0: 50823 - Python 2.0.1: 50823 - Python 2.1: 60202 - Python 2.1.1: 60202 - Python 2.1.2: 60202 - Python 2.2: 60717 - Python 2.3a0: 62011 - Python 2.3a0: 62021 - Python 2.3a0: 62011 (!) -*/ -/* we'll make our own magic number.... the D'ni way (whatever that means)*/ -#define MAGIC (18686 | ((long)'\r'<<16) | ((long)'\n'<<24)) - -/* Magic word as global; note that _PyImport_Init() can change the - value of this global to accommodate for alterations of how the - compiler works which are enabled by command line switches. */ -static long pyc_magic = MAGIC; - -/* See _PyImport_FixupExtension() below */ -static PyObject *extensions = NULL; - -/* This table is defined in config.c: */ -extern struct _inittab _PyImport_Inittab[]; - -struct _inittab *PyImport_Inittab = _PyImport_Inittab; - -/* these tables define the module suffixes that Python recognizes */ -struct filedescr * _PyImport_Filetab = NULL; - -#ifdef RISCOS -static const struct filedescr _PyImport_StandardFiletab[] = { - {"/py", "U", PY_SOURCE}, - {"/pyc", "rb", PY_COMPILED}, - {0, 0} -}; -#else -static const struct filedescr _PyImport_StandardFiletab[] = { - {".py", "U", PY_SOURCE}, -#ifdef MS_WINDOWS - {".pyw", "U", PY_SOURCE}, -#endif - {".pyc", "rb", PY_COMPILED}, - {0, 0} -}; -#endif - -/* Initialize things */ - -void -_PyImport_Init(void) -{ - const struct filedescr *scan; - struct filedescr *filetab; - int countD = 0; - int countS = 0; - - /* prepare _PyImport_Filetab: copy entries from - _PyImport_DynLoadFiletab and _PyImport_StandardFiletab. - */ - for (scan = _PyImport_DynLoadFiletab; scan->suffix != NULL; ++scan) - ++countD; - for (scan = _PyImport_StandardFiletab; scan->suffix != NULL; ++scan) - ++countS; - filetab = PyMem_NEW(struct filedescr, countD + countS + 1); - memcpy(filetab, _PyImport_DynLoadFiletab, - countD * sizeof(struct filedescr)); - memcpy(filetab + countD, _PyImport_StandardFiletab, - countS * sizeof(struct filedescr)); - filetab[countD + countS].suffix = NULL; - - _PyImport_Filetab = filetab; - - if (Py_OptimizeFlag) { - /* Replace ".pyc" with ".pyo" in _PyImport_Filetab */ - for (; filetab->suffix != NULL; filetab++) { -#ifndef RISCOS - if (strcmp(filetab->suffix, ".pyc") == 0) - filetab->suffix = ".pyo"; -#else - if (strcmp(filetab->suffix, "/pyc") == 0) - filetab->suffix = "/pyo"; -#endif - } - } - - if (Py_UnicodeFlag) { - /* Fix the pyc_magic so that byte compiled code created - using the all-Unicode method doesn't interfere with - code created in normal operation mode. */ - pyc_magic = MAGIC + 1; - } -} - -void -_PyImportHooks_Init(void) -{ - PyObject *v, *path_hooks = NULL, *zimpimport; - int err = 0; - - /* adding sys.path_hooks and sys.path_importer_cache, setting up - zipimport */ - - if (Py_VerboseFlag) - PySys_WriteStderr("# installing zipimport hook\n"); - - v = PyList_New(0); - if (v == NULL) - goto error; - err = PySys_SetObject("meta_path", v); - Py_DECREF(v); - if (err) - goto error; - v = PyDict_New(); - if (v == NULL) - goto error; - err = PySys_SetObject("path_importer_cache", v); - Py_DECREF(v); - if (err) - goto error; - path_hooks = PyList_New(0); - if (path_hooks == NULL) - goto error; - err = PySys_SetObject("path_hooks", path_hooks); - if (err) { - error: - PyErr_Print(); - Py_FatalError("initializing sys.meta_path, sys.path_hooks or " - "path_importer_cache failed"); - } - zimpimport = PyImport_ImportModule("zipimport"); - if (zimpimport == NULL) { - PyErr_Clear(); /* No zip import module -- okay */ - if (Py_VerboseFlag) - PySys_WriteStderr("# can't import zipimport\n"); - } - else { - PyObject *zipimporter = PyObject_GetAttrString(zimpimport, - "zipimporter"); - Py_DECREF(zimpimport); - if (zipimporter == NULL) { - PyErr_Clear(); /* No zipimporter object -- okay */ - if (Py_VerboseFlag) - PySys_WriteStderr( - "# can't import zipimport.zipimporter\n"); - } - else { - /* sys.path_hooks.append(zipimporter) */ - err = PyList_Append(path_hooks, zipimporter); - Py_DECREF(zipimporter); - if (err) - goto error; - if (Py_VerboseFlag) - PySys_WriteStderr( - "# installed zipimport hook\n"); - } - } - Py_DECREF(path_hooks); -} - -void -_PyImport_Fini(void) -{ - Py_XDECREF(extensions); - extensions = NULL; - PyMem_DEL(_PyImport_Filetab); - _PyImport_Filetab = NULL; -} - - -/* Locking primitives to prevent parallel imports of the same module - in different threads to return with a partially loaded module. - These calls are serialized by the global interpreter lock. */ - -#ifdef WITH_THREAD - -#include "pythread.h" - -static PyThread_type_lock import_lock = 0; -static long import_lock_thread = -1; -static int import_lock_level = 0; - -static void -lock_import(void) -{ - long me = PyThread_get_thread_ident(); - if (me == -1) - return; /* Too bad */ - if (import_lock == NULL) - import_lock = PyThread_allocate_lock(); - if (import_lock_thread == me) { - import_lock_level++; - return; - } - if (import_lock_thread != -1 || !PyThread_acquire_lock(import_lock, 0)) - { - PyThreadState *tstate = PyEval_SaveThread(); - PyThread_acquire_lock(import_lock, 1); - PyEval_RestoreThread(tstate); - } - import_lock_thread = me; - import_lock_level = 1; -} - -static int -unlock_import(void) -{ - long me = PyThread_get_thread_ident(); - if (me == -1) - return 0; /* Too bad */ - if (import_lock_thread != me) - return -1; - import_lock_level--; - if (import_lock_level == 0) { - import_lock_thread = -1; - PyThread_release_lock(import_lock); - } - return 1; -} - -#else - -#define lock_import() -#define unlock_import() 0 - -#endif - -static PyObject * -imp_lock_held(PyObject *self, PyObject *noargs) -{ -#ifdef WITH_THREAD - return PyBool_FromLong(import_lock_thread != -1); -#else - return PyBool_FromLong(0); -#endif -} - -static PyObject * -imp_acquire_lock(PyObject *self, PyObject *noargs) -{ -#ifdef WITH_THREAD - lock_import(); -#endif - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -imp_release_lock(PyObject *self, PyObject *noargs) -{ -#ifdef WITH_THREAD - if (unlock_import() < 0) { - PyErr_SetString(PyExc_RuntimeError, - "not holding the import lock"); - return NULL; - } -#endif - Py_INCREF(Py_None); - return Py_None; -} - -/* Helper for sys */ - -PyObject * -PyImport_GetModuleDict(void) -{ - PyInterpreterState *interp = PyThreadState_Get()->interp; - if (interp->modules == NULL) - Py_FatalError("PyImport_GetModuleDict: no module dictionary!"); - return interp->modules; -} - - -/* List of names to clear in sys */ -static char* sys_deletes[] = { - "path", "argv", "ps1", "ps2", "exitfunc", - "exc_type", "exc_value", "exc_traceback", - "last_type", "last_value", "last_traceback", - "path_hooks", "path_importer_cache", "meta_path", - NULL -}; - -static char* sys_files[] = { - "stdin", "__stdin__", - "stdout", "__stdout__", - "stderr", "__stderr__", - NULL -}; - - -/* Un-initialize things, as good as we can */ - -void -PyImport_Cleanup(void) -{ - int pos, ndone; - char *name; - PyObject *key, *value, *dict; - PyInterpreterState *interp = PyThreadState_Get()->interp; - PyObject *modules = interp->modules; - - if (modules == NULL) - return; /* Already done */ - - /* Delete some special variables first. These are common - places where user values hide and people complain when their - destructors fail. Since the modules containing them are - deleted *last* of all, they would come too late in the normal - destruction order. Sigh. */ - - value = PyDict_GetItemString(modules, "__builtin__"); - if (value != NULL && PyModule_Check(value)) { - dict = PyModule_GetDict(value); - if (Py_VerboseFlag) - PySys_WriteStderr("# clear __builtin__._\n"); - PyDict_SetItemString(dict, "_", Py_None); - } - value = PyDict_GetItemString(modules, "sys"); - if (value != NULL && PyModule_Check(value)) { - char **p; - PyObject *v; - dict = PyModule_GetDict(value); - for (p = sys_deletes; *p != NULL; p++) { - if (Py_VerboseFlag) - PySys_WriteStderr("# clear sys.%s\n", *p); - PyDict_SetItemString(dict, *p, Py_None); - } - for (p = sys_files; *p != NULL; p+=2) { - if (Py_VerboseFlag) - PySys_WriteStderr("# restore sys.%s\n", *p); - v = PyDict_GetItemString(dict, *(p+1)); - if (v == NULL) - v = Py_None; - PyDict_SetItemString(dict, *p, v); - } - } - - /* First, delete __main__ */ - value = PyDict_GetItemString(modules, "__main__"); - if (value != NULL && PyModule_Check(value)) { - if (Py_VerboseFlag) - PySys_WriteStderr("# cleanup __main__\n"); - _PyModule_Clear(value); - PyDict_SetItemString(modules, "__main__", Py_None); - } - - /* The special treatment of __builtin__ here is because even - when it's not referenced as a module, its dictionary is - referenced by almost every module's __builtins__. Since - deleting a module clears its dictionary (even if there are - references left to it), we need to delete the __builtin__ - module last. Likewise, we don't delete sys until the very - end because it is implicitly referenced (e.g. by print). - - Also note that we 'delete' modules by replacing their entry - in the modules dict with None, rather than really deleting - them; this avoids a rehash of the modules dictionary and - also marks them as "non existent" so they won't be - re-imported. */ - - /* Next, repeatedly delete modules with a reference count of - one (skipping __builtin__ and sys) and delete them */ - do { - ndone = 0; - pos = 0; - while (PyDict_Next(modules, &pos, &key, &value)) { - if (value->ob_refcnt != 1) - continue; - if (PyString_Check(key) && PyModule_Check(value)) { - name = PyString_AS_STRING(key); - if (strcmp(name, "__builtin__") == 0) - continue; - if (strcmp(name, "sys") == 0) - continue; - if (Py_VerboseFlag) - PySys_WriteStderr( - "# cleanup[1] %s\n", name); - _PyModule_Clear(value); - PyDict_SetItem(modules, key, Py_None); - ndone++; - } - } - } while (ndone > 0); - - /* Next, delete all modules (still skipping __builtin__ and sys) */ - pos = 0; - while (PyDict_Next(modules, &pos, &key, &value)) { - if (PyString_Check(key) && PyModule_Check(value)) { - name = PyString_AS_STRING(key); - if (strcmp(name, "__builtin__") == 0) - continue; - if (strcmp(name, "sys") == 0) - continue; - if (Py_VerboseFlag) - PySys_WriteStderr("# cleanup[2] %s\n", name); - _PyModule_Clear(value); - PyDict_SetItem(modules, key, Py_None); - } - } - - /* Next, delete sys and __builtin__ (in that order) */ - value = PyDict_GetItemString(modules, "sys"); - if (value != NULL && PyModule_Check(value)) { - if (Py_VerboseFlag) - PySys_WriteStderr("# cleanup sys\n"); - _PyModule_Clear(value); - PyDict_SetItemString(modules, "sys", Py_None); - } - value = PyDict_GetItemString(modules, "__builtin__"); - if (value != NULL && PyModule_Check(value)) { - if (Py_VerboseFlag) - PySys_WriteStderr("# cleanup __builtin__\n"); - _PyModule_Clear(value); - PyDict_SetItemString(modules, "__builtin__", Py_None); - } - - /* Finally, clear and delete the modules directory */ - PyDict_Clear(modules); - interp->modules = NULL; - Py_DECREF(modules); -} - - -/* Helper for pythonrun.c -- return magic number */ - -long -PyImport_GetMagicNumber(void) -{ - return pyc_magic; -} - - -/* Magic for extension modules (built-in as well as dynamically - loaded). To prevent initializing an extension module more than - once, we keep a static dictionary 'extensions' keyed by module name - (for built-in modules) or by filename (for dynamically loaded - modules), containing these modules. A copy of the module's - dictionary is stored by calling _PyImport_FixupExtension() - immediately after the module initialization function succeeds. A - copy can be retrieved from there by calling - _PyImport_FindExtension(). */ - -PyObject * -_PyImport_FixupExtension(char *name, char *filename) -{ - PyObject *modules, *mod, *dict, *copy; - if (extensions == NULL) { - extensions = PyDict_New(); - if (extensions == NULL) - return NULL; - } - modules = PyImport_GetModuleDict(); - mod = PyDict_GetItemString(modules, name); - if (mod == NULL || !PyModule_Check(mod)) { - PyErr_Format(PyExc_SystemError, - "_PyImport_FixupExtension: module %.200s not loaded", name); - return NULL; - } - dict = PyModule_GetDict(mod); - if (dict == NULL) - return NULL; - copy = PyDict_Copy(dict); - if (copy == NULL) - return NULL; - PyDict_SetItemString(extensions, filename, copy); - Py_DECREF(copy); - return copy; -} - -PyObject * -_PyImport_FindExtension(char *name, char *filename) -{ - PyObject *dict, *mod, *mdict; - if (extensions == NULL) - return NULL; - dict = PyDict_GetItemString(extensions, filename); - if (dict == NULL) - return NULL; - mod = PyImport_AddModule(name); - if (mod == NULL) - return NULL; - mdict = PyModule_GetDict(mod); - if (mdict == NULL) - return NULL; - if (PyDict_Update(mdict, dict)) - return NULL; - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # previously loaded (%s)\n", - name, filename); - return mod; -} - - -/* Get the module object corresponding to a module name. - First check the modules dictionary if there's one there, - if not, create a new one and insert it in the modules dictionary. - Because the former action is most common, THIS DOES NOT RETURN A - 'NEW' REFERENCE! */ - -PyObject * -PyImport_AddModule(char *name) -{ - PyObject *modules = PyImport_GetModuleDict(); - PyObject *m; - - if ((m = PyDict_GetItemString(modules, name)) != NULL && - PyModule_Check(m)) - return m; - m = PyModule_New(name); - if (m == NULL) - return NULL; - if (PyDict_SetItemString(modules, name, m) != 0) { - Py_DECREF(m); - return NULL; - } - Py_DECREF(m); /* Yes, it still exists, in modules! */ - - return m; -} - - -/* Execute a code object in a module and return the module object - WITH INCREMENTED REFERENCE COUNT */ - -PyObject * -PyImport_ExecCodeModule(char *name, PyObject *co) -{ - return PyImport_ExecCodeModuleEx(name, co, (char *)NULL); -} - -PyObject * -PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname) -{ - PyObject *modules = PyImport_GetModuleDict(); - PyObject *m, *d, *v; - - m = PyImport_AddModule(name); - if (m == NULL) - return NULL; - d = PyModule_GetDict(m); - if (PyDict_GetItemString(d, "__builtins__") == NULL) { - if (PyDict_SetItemString(d, "__builtins__", - PyEval_GetBuiltins()) != 0) - return NULL; - } - /* Remember the filename as the __file__ attribute */ - v = NULL; - if (pathname != NULL) { - v = PyString_FromString(pathname); - if (v == NULL) - PyErr_Clear(); - } - if (v == NULL) { - v = ((PyCodeObject *)co)->co_filename; - Py_INCREF(v); - } - if (PyDict_SetItemString(d, "__file__", v) != 0) - PyErr_Clear(); /* Not important enough to report */ - Py_DECREF(v); - - v = PyEval_EvalCode((PyCodeObject *)co, d, d); - if (v == NULL) - return NULL; - Py_DECREF(v); - - if ((m = PyDict_GetItemString(modules, name)) == NULL) { - PyErr_Format(PyExc_ImportError, - "Loaded module %.200s not found in sys.modules", - name); - return NULL; - } - - Py_INCREF(m); - - return m; -} - - -/* Given a pathname for a Python source file, fill a buffer with the - pathname for the corresponding compiled file. Return the pathname - for the compiled file, or NULL if there's no space in the buffer. - Doesn't set an exception. */ - -static char * -make_compiled_pathname(char *pathname, char *buf, size_t buflen) -{ - size_t len = strlen(pathname); - if (len+2 > buflen) - return NULL; - -#ifdef MS_WINDOWS - /* Treat .pyw as if it were .py. The case of ".pyw" must match - that used in _PyImport_StandardFiletab. */ - if (len >= 4 && strcmp(&pathname[len-4], ".pyw") == 0) - --len; /* pretend 'w' isn't there */ -#endif - memcpy(buf, pathname, len); - buf[len] = Py_OptimizeFlag ? 'o' : 'c'; - buf[len+1] = '\0'; - - return buf; -} - - -/* Given a pathname for a Python source file, its time of last - modification, and a pathname for a compiled file, check whether the - compiled file represents the same version of the source. If so, - return a FILE pointer for the compiled file, positioned just after - the header; if not, return NULL. - Doesn't set an exception. */ - -static FILE * -check_compiled_module(char *pathname, long mtime, char *cpathname) -{ - FILE *fp; - long magic; - long pyc_mtime; - - fp = fopen(cpathname, "rb"); - if (fp == NULL) - return NULL; - magic = PyMarshal_ReadLongFromFile(fp); - if (magic != pyc_magic) { - if (Py_VerboseFlag) - PySys_WriteStderr("# %s has bad magic\n", cpathname); - fclose(fp); - return NULL; - } - pyc_mtime = PyMarshal_ReadLongFromFile(fp); - if (pyc_mtime != mtime) { - if (Py_VerboseFlag) - PySys_WriteStderr("# %s has bad mtime\n", cpathname); - fclose(fp); - return NULL; - } - if (Py_VerboseFlag) - PySys_WriteStderr("# %s matches %s\n", cpathname, pathname); - return fp; -} - - -/* Read a code object from a file and check it for validity */ - -static PyCodeObject * -read_compiled_module(char *cpathname, FILE *fp) -{ - PyObject *co; - - co = PyMarshal_ReadLastObjectFromFile(fp); - /* Ugly: rd_object() may return NULL with or without error */ - if (co == NULL || !PyCode_Check(co)) { - if (!PyErr_Occurred()) - PyErr_Format(PyExc_ImportError, - "Non-code object in %.200s", cpathname); - Py_XDECREF(co); - return NULL; - } - return (PyCodeObject *)co; -} - - -/* Load a module from a compiled file, execute it, and return its - module object WITH INCREMENTED REFERENCE COUNT */ - -static PyObject * -load_compiled_module(char *name, char *cpathname, FILE *fp) -{ - long magic; - PyCodeObject *co; - PyObject *m; - - magic = PyMarshal_ReadLongFromFile(fp); - if (magic != pyc_magic) { - PyErr_Format(PyExc_ImportError, - "Bad magic number in %.200s", cpathname); - return NULL; - } - (void) PyMarshal_ReadLongFromFile(fp); - co = read_compiled_module(cpathname, fp); - if (co == NULL) - return NULL; - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # precompiled from %s\n", - name, cpathname); - m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, cpathname); - Py_DECREF(co); - - return m; -} - -/* Parse a source file and return the corresponding code object */ - -static PyCodeObject * -parse_source_module(char *pathname, FILE *fp) -{ - PyCodeObject *co; - node *n; - - n = PyParser_SimpleParseFile(fp, pathname, Py_file_input); - if (n == NULL) - return NULL; - co = PyNode_Compile(n, pathname); - PyNode_Free(n); - - return co; -} - - -/* Helper to open a bytecode file for writing in exclusive mode */ - -static FILE * -open_exclusive(char *filename) -{ -#if defined(O_EXCL)&&defined(O_CREAT)&&defined(O_WRONLY)&&defined(O_TRUNC)&&!defined(_DEBUG) - /* Use O_EXCL to avoid a race condition when another process tries to - write the same file. When that happens, our open() call fails, - which is just fine (since it's only a cache). - XXX If the file exists and is writable but the directory is not - writable, the file will never be written. Oh well. - */ - int fd; - (void) unlink(filename); - fd = open(filename, O_EXCL|O_CREAT|O_WRONLY|O_TRUNC -#ifdef O_BINARY - |O_BINARY /* necessary for Windows */ -#endif -#ifdef __VMS - , 0666, "ctxt=bin", "shr=nil"); -#else - , 0666); -#endif - if (fd < 0) - return NULL; - return fdopen(fd, "wb"); -#else - /* Best we can do -- on Windows this can't happen anyway */ - return fopen(filename, "wb"); -#endif -} - - -/* Write a compiled module to a file, placing the time of last - modification of its source into the header. - Errors are ignored, if a write error occurs an attempt is made to - remove the file. */ - -static void -write_compiled_module(PyCodeObject *co, char *cpathname, long mtime) -{ - FILE *fp; - - fp = open_exclusive(cpathname); - if (fp == NULL) { - if (Py_VerboseFlag) - PySys_WriteStderr( - "# can't create %s\n", cpathname); - return; - } - PyMarshal_WriteLongToFile(pyc_magic, fp); - /* First write a 0 for mtime */ - PyMarshal_WriteLongToFile(0L, fp); - PyMarshal_WriteObjectToFile((PyObject *)co, fp); - if (ferror(fp)) { - if (Py_VerboseFlag) - PySys_WriteStderr("# can't write %s\n", cpathname); - /* Don't keep partial file */ - fclose(fp); - (void) unlink(cpathname); - return; - } - /* Now write the true mtime */ - fseek(fp, 4L, 0); - PyMarshal_WriteLongToFile(mtime, fp); - fflush(fp); - fclose(fp); - if (Py_VerboseFlag) - PySys_WriteStderr("# wrote %s\n", cpathname); -#ifdef macintosh - PyMac_setfiletype(cpathname, 'Pyth', 'PYC '); -#endif -} - - -/* Load a source module from a given file and return its module - object WITH INCREMENTED REFERENCE COUNT. If there's a matching - byte-compiled file, use that instead. */ - -static PyObject * -load_source_module(char *name, char *pathname, FILE *fp) -{ - time_t mtime; - FILE *fpc; - char buf[MAXPATHLEN+1]; - char *cpathname; - PyCodeObject *co; - PyObject *m; - - mtime = PyOS_GetLastModificationTime(pathname, fp); - if (mtime == (time_t)(-1)) - return NULL; -#if SIZEOF_TIME_T > 4 - /* Python's .pyc timestamp handling presumes that the timestamp fits - in 4 bytes. This will be fine until sometime in the year 2038, - when a 4-byte signed time_t will overflow. - */ - if (mtime >> 32) { - PyErr_SetString(PyExc_OverflowError, - "modification time overflows a 4 byte field"); - return NULL; - } -#endif - cpathname = make_compiled_pathname(pathname, buf, - (size_t)MAXPATHLEN + 1); - if (cpathname != NULL && - (fpc = check_compiled_module(pathname, mtime, cpathname))) { - co = read_compiled_module(cpathname, fpc); - fclose(fpc); - if (co == NULL) - return NULL; - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # precompiled from %s\n", - name, cpathname); - pathname = cpathname; - } - else { - co = parse_source_module(pathname, fp); - if (co == NULL) - return NULL; - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # from %s\n", - name, pathname); - write_compiled_module(co, cpathname, mtime); - } - m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, pathname); - Py_DECREF(co); - - return m; -} - - -/* Forward */ -static PyObject *load_module(char *, FILE *, char *, int, PyObject *); -static struct filedescr *find_module(char *, char *, PyObject *, - char *, size_t, FILE **, PyObject **); -static struct _frozen *find_frozen(char *name); - -/* Load a package and return its module object WITH INCREMENTED - REFERENCE COUNT */ - -static PyObject * -load_package(char *name, char *pathname) -{ - PyObject *m, *d, *file, *path; - int err; - char buf[MAXPATHLEN+1]; - FILE *fp = NULL; - struct filedescr *fdp; - - m = PyImport_AddModule(name); - if (m == NULL) - return NULL; - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # directory %s\n", - name, pathname); - d = PyModule_GetDict(m); - file = PyString_FromString(pathname); - if (file == NULL) - return NULL; - path = Py_BuildValue("[O]", file); - if (path == NULL) { - Py_DECREF(file); - return NULL; - } - err = PyDict_SetItemString(d, "__file__", file); - if (err == 0) - err = PyDict_SetItemString(d, "__path__", path); - if (err != 0) { - m = NULL; - goto cleanup; - } - buf[0] = '\0'; - fdp = find_module(name, "__init__", path, buf, sizeof(buf), &fp, NULL); - if (fdp == NULL) { - if (PyErr_ExceptionMatches(PyExc_ImportError)) { - PyErr_Clear(); - } - else - m = NULL; - goto cleanup; - } - m = load_module(name, fp, buf, fdp->type, NULL); - if (fp != NULL) - fclose(fp); - cleanup: - Py_XDECREF(path); - Py_XDECREF(file); - return m; -} - - -/* Helper to test for built-in module */ - -static int -is_builtin(char *name) -{ - int i; - for (i = 0; PyImport_Inittab[i].name != NULL; i++) { - if (strcmp(name, PyImport_Inittab[i].name) == 0) { - if (PyImport_Inittab[i].initfunc == NULL) - return -1; - else - return 1; - } - } - return 0; -} - - -/* Return an importer object for a sys.path/pkg.__path__ item 'p', - possibly by fetching it from the path_importer_cache dict. If it - wasn't yet cached, traverse path_hooks until it a hook is found - that can handle the path item. Return None if no hook could; - this tells our caller it should fall back to the builtin - import mechanism. Cache the result in path_importer_cache. - Returns a borrowed reference. */ - -static PyObject * -get_path_importer(PyObject *path_importer_cache, PyObject *path_hooks, - PyObject *p) -{ - PyObject *importer; - int j, nhooks; - - /* These conditions are the caller's responsibility: */ - assert(PyList_Check(path_hooks)); - assert(PyDict_Check(path_importer_cache)); - - nhooks = PyList_Size(path_hooks); - if (nhooks < 0) - return NULL; /* Shouldn't happen */ - - importer = PyDict_GetItem(path_importer_cache, p); - if (importer != NULL) - return importer; - - /* set path_importer_cache[p] to None to avoid recursion */ - if (PyDict_SetItem(path_importer_cache, p, Py_None) != 0) - return NULL; - - for (j = 0; j < nhooks; j++) { - PyObject *hook = PyList_GetItem(path_hooks, j); - if (hook == NULL) - return NULL; - importer = PyObject_CallFunction(hook, "O", p); - if (importer != NULL) - break; - - if (!PyErr_ExceptionMatches(PyExc_ImportError)) { - return NULL; - } - PyErr_Clear(); - } - if (importer == NULL) - importer = Py_None; - else if (importer != Py_None) { - int err = PyDict_SetItem(path_importer_cache, p, importer); - Py_DECREF(importer); - if (err != 0) - return NULL; - } - return importer; -} - -/* Search the path (default sys.path) for a module. Return the - corresponding filedescr struct, and (via return arguments) the - pathname and an open file. Return NULL if the module is not found. */ - -#ifdef MS_COREDLL -extern FILE *PyWin_FindRegisteredModule(const char *, struct filedescr **, - char *, int); -#endif - -static int case_ok(char *, int, int, char *); -static int find_init_module(char *); /* Forward */ -static struct filedescr importhookdescr = {"", "", IMP_HOOK}; - -static struct filedescr * -find_module(char *fullname, char *subname, PyObject *path, char *buf, - size_t buflen, FILE **p_fp, PyObject **p_loader) -{ - int i, npath; - size_t len, namelen; - struct filedescr *fdp = NULL; - char *filemode; - FILE *fp = NULL; - PyObject *path_hooks, *path_importer_cache; -#ifndef RISCOS - struct stat statbuf; -#endif - static struct filedescr fd_frozen = {"", "", PY_FROZEN}; - static struct filedescr fd_builtin = {"", "", C_BUILTIN}; - static struct filedescr fd_package = {"", "", PKG_DIRECTORY}; - char name[MAXPATHLEN+1]; -#if defined(PYOS_OS2) - size_t saved_len; - size_t saved_namelen; - char *saved_buf = NULL; -#endif - if (p_loader != NULL) - *p_loader = NULL; - - if (strlen(subname) > MAXPATHLEN) { - PyErr_SetString(PyExc_OverflowError, - "module name is too long"); - return NULL; - } - strcpy(name, subname); - - /* sys.meta_path import hook */ - if (p_loader != NULL) { - PyObject *meta_path; - - meta_path = PySys_GetObject("meta_path"); - if (meta_path == NULL || !PyList_Check(meta_path)) { - PyErr_SetString(PyExc_ImportError, - "sys.meta_path must be a list of " - "import hooks"); - return NULL; - } - Py_INCREF(meta_path); /* zap guard */ - npath = PyList_Size(meta_path); - for (i = 0; i < npath; i++) { - PyObject *loader; - PyObject *hook = PyList_GetItem(meta_path, i); - loader = PyObject_CallMethod(hook, "find_module", - "sO", fullname, - path != NULL ? - path : Py_None); - if (loader == NULL) { - Py_DECREF(meta_path); - return NULL; /* true error */ - } - if (loader != Py_None) { - /* a loader was found */ - *p_loader = loader; - Py_DECREF(meta_path); - return &importhookdescr; - } - Py_DECREF(loader); - } - Py_DECREF(meta_path); - } - - if (path != NULL && PyString_Check(path)) { - /* The only type of submodule allowed inside a "frozen" - package are other frozen modules or packages. */ - if (PyString_Size(path) + 1 + strlen(name) >= (size_t)buflen) { - PyErr_SetString(PyExc_ImportError, - "full frozen module name too long"); - return NULL; - } - strcpy(buf, PyString_AsString(path)); - strcat(buf, "."); - strcat(buf, name); - strcpy(name, buf); -#ifdef macintosh - /* Freezing on the mac works different, and the modules are - ** actually on sys.path. So we don't take the quick exit but - ** continue with the normal flow. - */ - path = NULL; -#else - if (find_frozen(name) != NULL) { - strcpy(buf, name); - return &fd_frozen; - } - PyErr_Format(PyExc_ImportError, - "No frozen submodule named %.200s", name); - return NULL; -#endif - } - if (path == NULL) { - if (is_builtin(name)) { - strcpy(buf, name); - return &fd_builtin; - } - if ((find_frozen(name)) != NULL) { - strcpy(buf, name); - return &fd_frozen; - } - -#ifdef MS_COREDLL - fp = PyWin_FindRegisteredModule(name, &fdp, buf, buflen); - if (fp != NULL) { - *p_fp = fp; - return fdp; - } -#endif - path = PySys_GetObject("path"); - } - if (path == NULL || !PyList_Check(path)) { - PyErr_SetString(PyExc_ImportError, - "sys.path must be a list of directory names"); - return NULL; - } - - path_hooks = PySys_GetObject("path_hooks"); - if (path_hooks == NULL || !PyList_Check(path_hooks)) { - PyErr_SetString(PyExc_ImportError, - "sys.path_hooks must be a list of " - "import hooks"); - return NULL; - } - path_importer_cache = PySys_GetObject("path_importer_cache"); - if (path_importer_cache == NULL || - !PyDict_Check(path_importer_cache)) { - PyErr_SetString(PyExc_ImportError, - "sys.path_importer_cache must be a dict"); - return NULL; - } - - npath = PyList_Size(path); - namelen = strlen(name); - for (i = 0; i < npath; i++) { - PyObject *copy = NULL; - PyObject *v = PyList_GetItem(path, i); -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(v)) { - copy = PyUnicode_Encode(PyUnicode_AS_UNICODE(v), - PyUnicode_GET_SIZE(v), Py_FileSystemDefaultEncoding, NULL); - if (copy == NULL) - return NULL; - v = copy; - } - else -#endif - if (!PyString_Check(v)) - continue; - len = PyString_Size(v); - if (len + 2 + namelen + MAXSUFFIXSIZE >= buflen) { - Py_XDECREF(copy); - continue; /* Too long */ - } - strcpy(buf, PyString_AsString(v)); - if (strlen(buf) != len) { - Py_XDECREF(copy); - continue; /* v contains '\0' */ - } - - /* sys.path_hooks import hook */ - if (p_loader != NULL) { - PyObject *importer; - - importer = get_path_importer(path_importer_cache, - path_hooks, v); - if (importer == NULL) - return NULL; - /* Note: importer is a borrowed reference */ - if (importer != Py_None) { - PyObject *loader; - loader = PyObject_CallMethod(importer, - "find_module", - "s", fullname); - if (loader == NULL) - return NULL; /* error */ - if (loader != Py_None) { - /* a loader was found */ - *p_loader = loader; - return &importhookdescr; - } - Py_DECREF(loader); - } - /* no hook was successful, use builtin import */ - } - -#ifdef macintosh - /* - ** Speedup: each sys.path item is interned, and - ** FindResourceModule remembers which items refer to - ** folders (so we don't have to bother trying to look - ** into them for resources). We only do this for string - ** items. - */ - if (PyString_Check(PyList_GET_ITEM(path, i))) { - PyString_InternInPlace(&PyList_GET_ITEM(path, i)); - v = PyList_GET_ITEM(path, i); - if (PyMac_FindResourceModule((PyStringObject *)v, name, buf)) { - static struct filedescr resfiledescr = - {"", "", PY_RESOURCE}; - - Py_XDECREF(copy); - return &resfiledescr; - } - if (PyMac_FindCodeResourceModule((PyStringObject *)v, name, buf)) { - static struct filedescr resfiledescr = - {"", "", PY_CODERESOURCE}; - - Py_XDECREF(copy); - return &resfiledescr; - } - } -#endif - if (len > 0 && buf[len-1] != SEP -#ifdef ALTSEP - && buf[len-1] != ALTSEP -#endif - ) - buf[len++] = SEP; - strcpy(buf+len, name); - len += namelen; - - /* Check for package import (buf holds a directory name, - and there's an __init__ module in that directory */ -#ifdef HAVE_STAT - if (stat(buf, &statbuf) == 0 && /* it exists */ - S_ISDIR(statbuf.st_mode) && /* it's a directory */ - find_init_module(buf) && /* it has __init__.py */ - case_ok(buf, len, namelen, name)) { /* and case matches */ - Py_XDECREF(copy); - return &fd_package; - } -#else - /* XXX How are you going to test for directories? */ -#ifdef RISCOS - if (isdir(buf) && - find_init_module(buf) && - case_ok(buf, len, namelen, name)) { - Py_XDECREF(copy); - return &fd_package; - } -#endif -#endif -#ifdef macintosh - fdp = PyMac_FindModuleExtension(buf, &len, name); - if (fdp) { -#else -#if defined(PYOS_OS2) - /* take a snapshot of the module spec for restoration - * after the 8 character DLL hackery - */ - saved_buf = strdup(buf); - saved_len = len; - saved_namelen = namelen; -#endif /* PYOS_OS2 */ - for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) { -#if defined(PYOS_OS2) - /* OS/2 limits DLLs to 8 character names (w/o - extension) - * so if the name is longer than that and its a - * dynamically loaded module we're going to try, - * truncate the name before trying - */ - if (strlen(subname) > 8) { - /* is this an attempt to load a C extension? */ - const struct filedescr *scan; - scan = _PyImport_DynLoadFiletab; - while (scan->suffix != NULL) { - if (!strcmp(scan->suffix, fdp->suffix)) - break; - else - scan++; - } - if (scan->suffix != NULL) { - /* yes, so truncate the name */ - namelen = 8; - len -= strlen(subname) - namelen; - buf[len] = '\0'; - } - } -#endif /* PYOS_OS2 */ - strcpy(buf+len, fdp->suffix); - if (Py_VerboseFlag > 1) - PySys_WriteStderr("# trying %s\n", buf); -#endif /* !macintosh */ - filemode = fdp->mode; - if (filemode[0] == 'U') - filemode = "r" PY_STDIOTEXTMODE; - fp = fopen(buf, filemode); - if (fp != NULL) { - if (case_ok(buf, len, namelen, name)) - break; - else { /* continue search */ - fclose(fp); - fp = NULL; - } - } -#if defined(PYOS_OS2) - /* restore the saved snapshot */ - strcpy(buf, saved_buf); - len = saved_len; - namelen = saved_namelen; -#endif - } -#if defined(PYOS_OS2) - /* don't need/want the module name snapshot anymore */ - if (saved_buf) - { - free(saved_buf); - saved_buf = NULL; - } -#endif - Py_XDECREF(copy); - if (fp != NULL) - break; - } - if (fp == NULL) { - PyErr_Format(PyExc_ImportError, - "No module named %.200s", name); - return NULL; - } - *p_fp = fp; - return fdp; -} - -/* case_ok(char* buf, int len, int namelen, char* name) - * The arguments here are tricky, best shown by example: - * /a/b/c/d/e/f/g/h/i/j/k/some_long_module_name.py\0 - * ^ ^ ^ ^ - * |--------------------- buf ---------------------| - * |------------------- len ------------------| - * |------ name -------| - * |----- namelen -----| - * buf is the full path, but len only counts up to (& exclusive of) the - * extension. name is the module name, also exclusive of extension. - * - * We've already done a successful stat() or fopen() on buf, so know that - * there's some match, possibly case-insensitive. - * - * case_ok() is to return 1 if there's a case-sensitive match for - * name, else 0. case_ok() is also to return 1 if envar PYTHONCASEOK - * exists. - * - * case_ok() is used to implement case-sensitive import semantics even - * on platforms with case-insensitive filesystems. It's trivial to implement - * for case-sensitive filesystems. It's pretty much a cross-platform - * nightmare for systems with case-insensitive filesystems. - */ - -/* First we may need a pile of platform-specific header files; the sequence - * of #if's here should match the sequence in the body of case_ok(). - */ -#if defined(MS_WINDOWS) || defined(__CYGWIN__) -#include -#ifdef __CYGWIN__ -#include -#endif - -#elif defined(DJGPP) -#include - -#elif defined(macintosh) -#include - -#elif defined(__MACH__) && defined(__APPLE__) && defined(HAVE_DIRENT_H) -#include -#include - -#elif defined(PYOS_OS2) -#define INCL_DOS -#define INCL_DOSERRORS -#define INCL_NOPMAPI -#include - -#elif defined(RISCOS) -#include "oslib/osfscontrol.h" -#endif - -static int -case_ok(char *buf, int len, int namelen, char *name) -{ -/* Pick a platform-specific implementation; the sequence of #if's here should - * match the sequence just above. - */ - -/* MS_WINDOWS || __CYGWIN__ */ -#if defined(MS_WINDOWS) || defined(__CYGWIN__) - WIN32_FIND_DATA data; - HANDLE h; -#ifdef __CYGWIN__ - char tempbuf[MAX_PATH]; -#endif - - if (Py_GETENV("PYTHONCASEOK") != NULL) - return 1; - -#ifdef __CYGWIN__ - cygwin32_conv_to_win32_path(buf, tempbuf); - h = FindFirstFile(tempbuf, &data); -#else - h = FindFirstFile(buf, &data); -#endif - if (h == INVALID_HANDLE_VALUE) { - PyErr_Format(PyExc_NameError, - "Can't find file for module %.100s\n(filename %.300s)", - name, buf); - return 0; - } - FindClose(h); - return strncmp(data.cFileName, name, namelen) == 0; - -/* DJGPP */ -#elif defined(DJGPP) - struct ffblk ffblk; - int done; - - if (Py_GETENV("PYTHONCASEOK") != NULL) - return 1; - - done = findfirst(buf, &ffblk, FA_ARCH|FA_RDONLY|FA_HIDDEN|FA_DIREC); - if (done) { - PyErr_Format(PyExc_NameError, - "Can't find file for module %.100s\n(filename %.300s)", - name, buf); - return 0; - } - return strncmp(ffblk.ff_name, name, namelen) == 0; - -/* macintosh */ -#elif defined(macintosh) - FSSpec fss; - OSErr err; - - if (Py_GETENV("PYTHONCASEOK") != NULL) - return 1; - - err = FSMakeFSSpec(0, 0, Pstring(buf), &fss); - if (err) { - PyErr_Format(PyExc_NameError, - "Can't find file for module %.100s\n(filename %.300s)", - name, buf); - return 0; - } - return fss.name[0] >= namelen && - strncmp(name, (char *)fss.name+1, namelen) == 0; - -/* new-fangled macintosh (macosx) */ -#elif defined(__MACH__) && defined(__APPLE__) && defined(HAVE_DIRENT_H) - DIR *dirp; - struct dirent *dp; - char dirname[MAXPATHLEN + 1]; - const int dirlen = len - namelen - 1; /* don't want trailing SEP */ - - if (Py_GETENV("PYTHONCASEOK") != NULL) - return 1; - - /* Copy the dir component into dirname; substitute "." if empty */ - if (dirlen <= 0) { - dirname[0] = '.'; - dirname[1] = '\0'; - } - else { - assert(dirlen <= MAXPATHLEN); - memcpy(dirname, buf, dirlen); - dirname[dirlen] = '\0'; - } - /* Open the directory and search the entries for an exact match. */ - dirp = opendir(dirname); - if (dirp) { - char *nameWithExt = buf + len - namelen; - while ((dp = readdir(dirp)) != NULL) { - const int thislen = -#ifdef _DIRENT_HAVE_D_NAMELEN - dp->d_namlen; -#else - strlen(dp->d_name); -#endif - if (thislen >= namelen && - strcmp(dp->d_name, nameWithExt) == 0) { - (void)closedir(dirp); - return 1; /* Found */ - } - } - (void)closedir(dirp); - } - return 0 ; /* Not found */ - -/* RISC OS */ -#elif defined(RISCOS) - char canon[MAXPATHLEN+1]; /* buffer for the canonical form of the path */ - char buf2[MAXPATHLEN+2]; - char *nameWithExt = buf+len-namelen; - int canonlen; - os_error *e; - - if (Py_GETENV("PYTHONCASEOK") != NULL) - return 1; - - /* workaround: - append wildcard, otherwise case of filename wouldn't be touched */ - strcpy(buf2, buf); - strcat(buf2, "*"); - - e = xosfscontrol_canonicalise_path(buf2,canon,0,0,MAXPATHLEN+1,&canonlen); - canonlen = MAXPATHLEN+1-canonlen; - if (e || canonlen<=0 || canonlen>(MAXPATHLEN+1) ) - return 0; - if (strcmp(nameWithExt, canon+canonlen-strlen(nameWithExt))==0) - return 1; /* match */ - - return 0; - -/* OS/2 */ -#elif defined(PYOS_OS2) - HDIR hdir = 1; - ULONG srchcnt = 1; - FILEFINDBUF3 ffbuf; - APIRET rc; - - if (Py_GETENV("PYTHONCASEOK") != NULL) - return 1; - - rc = DosFindFirst(buf, - &hdir, - FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY, - &ffbuf, sizeof(ffbuf), - &srchcnt, - FIL_STANDARD); - if (rc != NO_ERROR) - return 0; - return strncmp(ffbuf.achName, name, namelen) == 0; - -/* assuming it's a case-sensitive filesystem, so there's nothing to do! */ -#else - return 1; - -#endif -} - - -#ifdef HAVE_STAT -/* Helper to look for __init__.py or __init__.py[co] in potential package */ -static int -find_init_module(char *buf) -{ - const size_t save_len = strlen(buf); - size_t i = save_len; - char *pname; /* pointer to start of __init__ */ - struct stat statbuf; - -/* For calling case_ok(buf, len, namelen, name): - * /a/b/c/d/e/f/g/h/i/j/k/some_long_module_name.py\0 - * ^ ^ ^ ^ - * |--------------------- buf ---------------------| - * |------------------- len ------------------| - * |------ name -------| - * |----- namelen -----| - */ - if (save_len + 13 >= MAXPATHLEN) - return 0; - buf[i++] = SEP; - pname = buf + i; - strcpy(pname, "__init__.py"); - if (stat(buf, &statbuf) == 0) { - if (case_ok(buf, - save_len + 9, /* len("/__init__") */ - 8, /* len("__init__") */ - pname)) { - buf[save_len] = '\0'; - return 1; - } - } - i += strlen(pname); - strcpy(buf+i, Py_OptimizeFlag ? "o" : "c"); - if (stat(buf, &statbuf) == 0) { - if (case_ok(buf, - save_len + 9, /* len("/__init__") */ - 8, /* len("__init__") */ - pname)) { - buf[save_len] = '\0'; - return 1; - } - } - buf[save_len] = '\0'; - return 0; -} - -#else - -#ifdef RISCOS -static int -find_init_module(buf) - char *buf; -{ - int save_len = strlen(buf); - int i = save_len; - - if (save_len + 13 >= MAXPATHLEN) - return 0; - buf[i++] = SEP; - strcpy(buf+i, "__init__/py"); - if (isfile(buf)) { - buf[save_len] = '\0'; - return 1; - } - - if (Py_OptimizeFlag) - strcpy(buf+i, "o"); - else - strcpy(buf+i, "c"); - if (isfile(buf)) { - buf[save_len] = '\0'; - return 1; - } - buf[save_len] = '\0'; - return 0; -} -#endif /*RISCOS*/ - -#endif /* HAVE_STAT */ - - -static int init_builtin(char *); /* Forward */ - -/* Load an external module using the default search path and return - its module object WITH INCREMENTED REFERENCE COUNT */ - -static PyObject * -load_module(char *name, FILE *fp, char *buf, int type, PyObject *loader) -{ - PyObject *modules; - PyObject *m; - int err; - - /* First check that there's an open file (if we need one) */ - switch (type) { - case PY_SOURCE: - case PY_COMPILED: - if (fp == NULL) { - PyErr_Format(PyExc_ValueError, - "file object required for import (type code %d)", - type); - return NULL; - } - } - - switch (type) { - - case PY_SOURCE: - m = load_source_module(name, buf, fp); - break; - - case PY_COMPILED: - m = load_compiled_module(name, buf, fp); - break; - -#ifdef HAVE_DYNAMIC_LOADING - case C_EXTENSION: - m = _PyImport_LoadDynamicModule(name, buf, fp); - break; -#endif - -#ifdef macintosh - case PY_RESOURCE: - m = PyMac_LoadResourceModule(name, buf); - break; - case PY_CODERESOURCE: - m = PyMac_LoadCodeResourceModule(name, buf); - break; -#endif - - case PKG_DIRECTORY: - m = load_package(name, buf); - break; - - case C_BUILTIN: - case PY_FROZEN: - if (buf != NULL && buf[0] != '\0') - name = buf; - if (type == C_BUILTIN) - err = init_builtin(name); - else - err = PyImport_ImportFrozenModule(name); - if (err < 0) - return NULL; - if (err == 0) { - PyErr_Format(PyExc_ImportError, - "Purported %s module %.200s not found", - type == C_BUILTIN ? - "builtin" : "frozen", - name); - return NULL; - } - modules = PyImport_GetModuleDict(); - m = PyDict_GetItemString(modules, name); - if (m == NULL) { - PyErr_Format( - PyExc_ImportError, - "%s module %.200s not properly initialized", - type == C_BUILTIN ? - "builtin" : "frozen", - name); - return NULL; - } - Py_INCREF(m); - break; - - case IMP_HOOK: { - if (loader == NULL) { - PyErr_SetString(PyExc_ImportError, - "import hook without loader"); - return NULL; - } - m = PyObject_CallMethod(loader, "load_module", "s", name); - break; - } - - default: - PyErr_Format(PyExc_ImportError, - "Don't know how to import %.200s (type code %d)", - name, type); - m = NULL; - - } - - return m; -} - - -/* Initialize a built-in module. - Return 1 for succes, 0 if the module is not found, and -1 with - an exception set if the initialization failed. */ - -static int -init_builtin(char *name) -{ - struct _inittab *p; - - if (_PyImport_FindExtension(name, name) != NULL) - return 1; - - for (p = PyImport_Inittab; p->name != NULL; p++) { - if (strcmp(name, p->name) == 0) { - if (p->initfunc == NULL) { - PyErr_Format(PyExc_ImportError, - "Cannot re-init internal module %.200s", - name); - return -1; - } - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # builtin\n", name); - (*p->initfunc)(); - if (PyErr_Occurred()) - return -1; - if (_PyImport_FixupExtension(name, name) == NULL) - return -1; - return 1; - } - } - return 0; -} - - -/* Frozen modules */ - -static struct _frozen * -find_frozen(char *name) -{ - struct _frozen *p; - - for (p = PyImport_FrozenModules; ; p++) { - if (p->name == NULL) - return NULL; - if (strcmp(p->name, name) == 0) - break; - } - return p; -} - -static PyObject * -get_frozen_object(char *name) -{ - struct _frozen *p = find_frozen(name); - int size; - - if (p == NULL) { - PyErr_Format(PyExc_ImportError, - "No such frozen object named %.200s", - name); - return NULL; - } - if (p->code == NULL) { - PyErr_Format(PyExc_ImportError, - "Excluded frozen object named %.200s", - name); - return NULL; - } - size = p->size; - if (size < 0) - size = -size; - return PyMarshal_ReadObjectFromString((char *)p->code, size); -} - -/* Initialize a frozen module. - Return 1 for succes, 0 if the module is not found, and -1 with - an exception set if the initialization failed. - This function is also used from frozenmain.c */ - -int -PyImport_ImportFrozenModule(char *name) -{ - struct _frozen *p = find_frozen(name); - PyObject *co; - PyObject *m; - int ispackage; - int size; - - if (p == NULL) - return 0; - if (p->code == NULL) { - PyErr_Format(PyExc_ImportError, - "Excluded frozen object named %.200s", - name); - return -1; - } - size = p->size; - ispackage = (size < 0); - if (ispackage) - size = -size; - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # frozen%s\n", - name, ispackage ? " package" : ""); - co = PyMarshal_ReadObjectFromString((char *)p->code, size); - if (co == NULL) - return -1; - if (!PyCode_Check(co)) { - Py_DECREF(co); - PyErr_Format(PyExc_TypeError, - "frozen object %.200s is not a code object", - name); - return -1; - } - if (ispackage) { - /* Set __path__ to the package name */ - PyObject *d, *s; - int err; - m = PyImport_AddModule(name); - if (m == NULL) - return -1; - d = PyModule_GetDict(m); - s = PyString_InternFromString(name); - if (s == NULL) - return -1; - err = PyDict_SetItemString(d, "__path__", s); - Py_DECREF(s); - if (err != 0) - return err; - } - m = PyImport_ExecCodeModuleEx(name, co, ""); - Py_DECREF(co); - if (m == NULL) - return -1; - Py_DECREF(m); - return 1; -} - - -/* Import a module, either built-in, frozen, or external, and return - its module object WITH INCREMENTED REFERENCE COUNT */ - -PyObject * -PyImport_ImportModule(char *name) -{ - PyObject *pname; - PyObject *result; - - pname = PyString_FromString(name); - if (pname == NULL) - return NULL; - result = PyImport_Import(pname); - Py_DECREF(pname); - return result; -} - -/* Forward declarations for helper routines */ -static PyObject *get_parent(PyObject *globals, char *buf, int *p_buflen); -static PyObject *load_next(PyObject *mod, PyObject *altmod, - char **p_name, char *buf, int *p_buflen); -static int mark_miss(char *name); -static int ensure_fromlist(PyObject *mod, PyObject *fromlist, - char *buf, int buflen, int recursive); -static PyObject * import_submodule(PyObject *mod, char *name, char *fullname); - -/* The Magnum Opus of dotted-name import :-) */ - -static PyObject * -import_module_ex(char *name, PyObject *globals, PyObject *locals, - PyObject *fromlist) -{ - char buf[MAXPATHLEN+1]; - int buflen = 0; - PyObject *parent, *head, *next, *tail; - - parent = get_parent(globals, buf, &buflen); - if (parent == NULL) - return NULL; - - head = load_next(parent, Py_None, &name, buf, &buflen); - if (head == NULL) - return NULL; - - tail = head; - Py_INCREF(tail); - while (name) { - next = load_next(tail, tail, &name, buf, &buflen); - Py_DECREF(tail); - if (next == NULL) { - Py_DECREF(head); - return NULL; - } - tail = next; - } - - if (fromlist != NULL) { - if (fromlist == Py_None || !PyObject_IsTrue(fromlist)) - fromlist = NULL; - } - - if (fromlist == NULL) { - Py_DECREF(tail); - return head; - } - - Py_DECREF(head); - if (!ensure_fromlist(tail, fromlist, buf, buflen, 0)) { - Py_DECREF(tail); - return NULL; - } - - return tail; -} - -PyObject * -PyImport_ImportModuleEx(char *name, PyObject *globals, PyObject *locals, - PyObject *fromlist) -{ - PyObject *result; - lock_import(); - result = import_module_ex(name, globals, locals, fromlist); - if (unlock_import() < 0) { - Py_XDECREF(result); - PyErr_SetString(PyExc_RuntimeError, - "not holding the import lock"); - return NULL; - } - return result; -} - -static PyObject * -get_parent(PyObject *globals, char *buf, int *p_buflen) -{ - static PyObject *namestr = NULL; - static PyObject *pathstr = NULL; - PyObject *modname, *modpath, *modules, *parent; - - if (globals == NULL || !PyDict_Check(globals)) - return Py_None; - - if (namestr == NULL) { - namestr = PyString_InternFromString("__name__"); - if (namestr == NULL) - return NULL; - } - if (pathstr == NULL) { - pathstr = PyString_InternFromString("__path__"); - if (pathstr == NULL) - return NULL; - } - - *buf = '\0'; - *p_buflen = 0; - modname = PyDict_GetItem(globals, namestr); - if (modname == NULL || !PyString_Check(modname)) - return Py_None; - - modpath = PyDict_GetItem(globals, pathstr); - if (modpath != NULL) { - int len = PyString_GET_SIZE(modname); - if (len > MAXPATHLEN) { - PyErr_SetString(PyExc_ValueError, - "Module name too long"); - return NULL; - } - strcpy(buf, PyString_AS_STRING(modname)); - *p_buflen = len; - } - else { - char *start = PyString_AS_STRING(modname); - char *lastdot = strrchr(start, '.'); - size_t len; - if (lastdot == NULL) - return Py_None; - len = lastdot - start; - if (len >= MAXPATHLEN) { - PyErr_SetString(PyExc_ValueError, - "Module name too long"); - return NULL; - } - strncpy(buf, start, len); - buf[len] = '\0'; - *p_buflen = len; - } - - modules = PyImport_GetModuleDict(); - parent = PyDict_GetItemString(modules, buf); - if (parent == NULL) - parent = Py_None; - return parent; - /* We expect, but can't guarantee, if parent != None, that: - - parent.__name__ == buf - - parent.__dict__ is globals - If this is violated... Who cares? */ -} - -/* altmod is either None or same as mod */ -static PyObject * -load_next(PyObject *mod, PyObject *altmod, char **p_name, char *buf, - int *p_buflen) -{ - char *name = *p_name; - char *dot = strchr(name, '.'); - size_t len; - char *p; - PyObject *result; - - if (dot == NULL) { - *p_name = NULL; - len = strlen(name); - } - else { - *p_name = dot+1; - len = dot-name; - } - if (len == 0) { - PyErr_SetString(PyExc_ValueError, - "Empty module name"); - return NULL; - } - - p = buf + *p_buflen; - if (p != buf) - *p++ = '.'; - if (p+len-buf >= MAXPATHLEN) { - PyErr_SetString(PyExc_ValueError, - "Module name too long"); - return NULL; - } - strncpy(p, name, len); - p[len] = '\0'; - *p_buflen = p+len-buf; - - result = import_submodule(mod, p, buf); - if (result == Py_None && altmod != mod) { - Py_DECREF(result); - /* Here, altmod must be None and mod must not be None */ - result = import_submodule(altmod, p, p); - if (result != NULL && result != Py_None) { - if (mark_miss(buf) != 0) { - Py_DECREF(result); - return NULL; - } - strncpy(buf, name, len); - buf[len] = '\0'; - *p_buflen = len; - } - } - if (result == NULL) - return NULL; - - if (result == Py_None) { - Py_DECREF(result); - PyErr_Format(PyExc_ImportError, - "No module named %.200s", name); - return NULL; - } - - return result; -} - -static int -mark_miss(char *name) -{ - PyObject *modules = PyImport_GetModuleDict(); - return PyDict_SetItemString(modules, name, Py_None); -} - -static int -ensure_fromlist(PyObject *mod, PyObject *fromlist, char *buf, int buflen, - int recursive) -{ - int i; - - if (!PyObject_HasAttrString(mod, "__path__")) - return 1; - - for (i = 0; ; i++) { - PyObject *item = PySequence_GetItem(fromlist, i); - int hasit; - if (item == NULL) { - if (PyErr_ExceptionMatches(PyExc_IndexError)) { - PyErr_Clear(); - return 1; - } - return 0; - } - if (!PyString_Check(item)) { - PyErr_SetString(PyExc_TypeError, - "Item in ``from list'' not a string"); - Py_DECREF(item); - return 0; - } - if (PyString_AS_STRING(item)[0] == '*') { - PyObject *all; - Py_DECREF(item); - /* See if the package defines __all__ */ - if (recursive) - continue; /* Avoid endless recursion */ - all = PyObject_GetAttrString(mod, "__all__"); - if (all == NULL) - PyErr_Clear(); - else { - if (!ensure_fromlist(mod, all, buf, buflen, 1)) - return 0; - Py_DECREF(all); - } - continue; - } - hasit = PyObject_HasAttr(mod, item); - if (!hasit) { - char *subname = PyString_AS_STRING(item); - PyObject *submod; - char *p; - if (buflen + strlen(subname) >= MAXPATHLEN) { - PyErr_SetString(PyExc_ValueError, - "Module name too long"); - Py_DECREF(item); - return 0; - } - p = buf + buflen; - *p++ = '.'; - strcpy(p, subname); - submod = import_submodule(mod, subname, buf); - Py_XDECREF(submod); - if (submod == NULL) { - Py_DECREF(item); - return 0; - } - } - Py_DECREF(item); - } - - /* NOTREACHED */ -} - -static int -add_submodule(PyObject *mod, PyObject *submod, char *fullname, char *subname, - PyObject *modules) -{ - if (mod == Py_None) - return 1; - /* Irrespective of the success of this load, make a - reference to it in the parent package module. A copy gets - saved in the modules dictionary under the full name, so get a - reference from there, if need be. (The exception is when the - load failed with a SyntaxError -- then there's no trace in - sys.modules. In that case, of course, do nothing extra.) */ - if (submod == NULL) { - submod = PyDict_GetItemString(modules, fullname); - if (submod == NULL) - return 1; - } - if (PyModule_Check(mod)) { - /* We can't use setattr here since it can give a - * spurious warning if the submodule name shadows a - * builtin name */ - PyObject *dict = PyModule_GetDict(mod); - if (!dict) - return 0; - if (PyDict_SetItemString(dict, subname, submod) < 0) - return 0; - } - else { - if (PyObject_SetAttrString(mod, subname, submod) < 0) - return 0; - } - return 1; -} - -static PyObject * -import_submodule(PyObject *mod, char *subname, char *fullname) -{ - PyObject *modules = PyImport_GetModuleDict(); - PyObject *m = NULL; - - /* Require: - if mod == None: subname == fullname - else: mod.__name__ + "." + subname == fullname - */ - - if ((m = PyDict_GetItemString(modules, fullname)) != NULL) { - Py_INCREF(m); - } - else { - PyObject *path, *loader = NULL; - char buf[MAXPATHLEN+1]; - struct filedescr *fdp; - FILE *fp = NULL; - - if (mod == Py_None) - path = NULL; - else { - path = PyObject_GetAttrString(mod, "__path__"); - if (path == NULL) { - PyErr_Clear(); - Py_INCREF(Py_None); - return Py_None; - } - } - - buf[0] = '\0'; - fdp = find_module(fullname, subname, path, buf, MAXPATHLEN+1, - &fp, &loader); - Py_XDECREF(path); - if (fdp == NULL) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - return NULL; - PyErr_Clear(); - Py_INCREF(Py_None); - return Py_None; - } - m = load_module(fullname, fp, buf, fdp->type, loader); - Py_XDECREF(loader); - if (fp) - fclose(fp); - if (!add_submodule(mod, m, fullname, subname, modules)) { - Py_XDECREF(m); - m = NULL; - } - } - - return m; -} - - -/* Re-import a module of any kind and return its module object, WITH - INCREMENTED REFERENCE COUNT */ - -PyObject * -PyImport_ReloadModule(PyObject *m) -{ - PyObject *modules = PyImport_GetModuleDict(); - PyObject *path = NULL; - char *name, *subname; - char buf[MAXPATHLEN+1]; - struct filedescr *fdp; - FILE *fp = NULL; - - if (m == NULL || !PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, - "reload() argument must be module"); - return NULL; - } - name = PyModule_GetName(m); - if (name == NULL) - return NULL; - if (m != PyDict_GetItemString(modules, name)) { - PyErr_Format(PyExc_ImportError, - "reload(): module %.200s not in sys.modules", - name); - return NULL; - } - subname = strrchr(name, '.'); - if (subname == NULL) - subname = name; - else { - PyObject *parentname, *parent; - parentname = PyString_FromStringAndSize(name, (subname-name)); - if (parentname == NULL) - return NULL; - parent = PyDict_GetItem(modules, parentname); - Py_DECREF(parentname); - if (parent == NULL) { - PyErr_Format(PyExc_ImportError, - "reload(): parent %.200s not in sys.modules", - name); - return NULL; - } - subname++; - path = PyObject_GetAttrString(parent, "__path__"); - if (path == NULL) - PyErr_Clear(); - } - buf[0] = '\0'; - fdp = find_module(name, subname, path, buf, MAXPATHLEN+1, &fp, NULL); - Py_XDECREF(path); - if (fdp == NULL) - return NULL; - m = load_module(name, fp, buf, fdp->type, NULL); - if (fp) - fclose(fp); - return m; -} - - -/* Higher-level import emulator which emulates the "import" statement - more accurately -- it invokes the __import__() function from the - builtins of the current globals. This means that the import is - done using whatever import hooks are installed in the current - environment, e.g. by "rexec". - A dummy list ["__doc__"] is passed as the 4th argument so that - e.g. PyImport_Import(PyString_FromString("win32com.client.gencache")) - will return instead of . */ - -PyObject * -PyImport_Import(PyObject *module_name) -{ - static PyObject *silly_list = NULL; - static PyObject *builtins_str = NULL; - static PyObject *import_str = NULL; - PyObject *globals = NULL; - PyObject *import = NULL; - PyObject *builtins = NULL; - PyObject *r = NULL; - - /* Initialize constant string objects */ - if (silly_list == NULL) { - import_str = PyString_InternFromString("__import__"); - if (import_str == NULL) - return NULL; - builtins_str = PyString_InternFromString("__builtins__"); - if (builtins_str == NULL) - return NULL; - silly_list = Py_BuildValue("[s]", "__doc__"); - if (silly_list == NULL) - return NULL; - } - - /* Get the builtins from current globals */ - globals = PyEval_GetGlobals(); - if (globals != NULL) { - Py_INCREF(globals); - builtins = PyObject_GetItem(globals, builtins_str); - if (builtins == NULL) - goto err; - } - else { - /* No globals -- use standard builtins, and fake globals */ - PyErr_Clear(); - - builtins = PyImport_ImportModuleEx("__builtin__", - NULL, NULL, NULL); - if (builtins == NULL) - return NULL; - globals = Py_BuildValue("{OO}", builtins_str, builtins); - if (globals == NULL) - goto err; - } - - /* Get the __import__ function from the builtins */ - if (PyDict_Check(builtins)) { - import = PyObject_GetItem(builtins, import_str); - if (import == NULL) - PyErr_SetObject(PyExc_KeyError, import_str); - } - else - import = PyObject_GetAttr(builtins, import_str); - if (import == NULL) - goto err; - - /* Call the _import__ function with the proper argument list */ - r = PyObject_CallFunction(import, "OOOO", - module_name, globals, globals, silly_list); - - err: - Py_XDECREF(globals); - Py_XDECREF(builtins); - Py_XDECREF(import); - - return r; -} - - -/* Module 'imp' provides Python access to the primitives used for - importing modules. -*/ - -static PyObject * -imp_get_magic(PyObject *self, PyObject *noargs) -{ - char buf[4]; - - buf[0] = (char) ((pyc_magic >> 0) & 0xff); - buf[1] = (char) ((pyc_magic >> 8) & 0xff); - buf[2] = (char) ((pyc_magic >> 16) & 0xff); - buf[3] = (char) ((pyc_magic >> 24) & 0xff); - - return PyString_FromStringAndSize(buf, 4); -} - -static PyObject * -imp_get_suffixes(PyObject *self, PyObject *noargs) -{ - PyObject *list; - struct filedescr *fdp; - - list = PyList_New(0); - if (list == NULL) - return NULL; - for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) { - PyObject *item = Py_BuildValue("ssi", - fdp->suffix, fdp->mode, fdp->type); - if (item == NULL) { - Py_DECREF(list); - return NULL; - } - if (PyList_Append(list, item) < 0) { - Py_DECREF(list); - Py_DECREF(item); - return NULL; - } - Py_DECREF(item); - } - return list; -} - -static PyObject * -call_find_module(char *name, PyObject *path) -{ - extern int fclose(FILE *); - PyObject *fob, *ret; - struct filedescr *fdp; - char pathname[MAXPATHLEN+1]; - FILE *fp = NULL; - - pathname[0] = '\0'; - if (path == Py_None) - path = NULL; - fdp = find_module(NULL, name, path, pathname, MAXPATHLEN+1, &fp, NULL); - if (fdp == NULL) - return NULL; - if (fp != NULL) { - fob = PyFile_FromFile(fp, pathname, fdp->mode, fclose); - if (fob == NULL) { - fclose(fp); - return NULL; - } - } - else { - fob = Py_None; - Py_INCREF(fob); - } - ret = Py_BuildValue("Os(ssi)", - fob, pathname, fdp->suffix, fdp->mode, fdp->type); - Py_DECREF(fob); - return ret; -} - -static PyObject * -imp_find_module(PyObject *self, PyObject *args) -{ - char *name; - PyObject *path = NULL; - if (!PyArg_ParseTuple(args, "s|O:find_module", &name, &path)) - return NULL; - return call_find_module(name, path); -} - -static PyObject * -imp_init_builtin(PyObject *self, PyObject *args) -{ - char *name; - int ret; - PyObject *m; - if (!PyArg_ParseTuple(args, "s:init_builtin", &name)) - return NULL; - ret = init_builtin(name); - if (ret < 0) - return NULL; - if (ret == 0) { - Py_INCREF(Py_None); - return Py_None; - } - m = PyImport_AddModule(name); - Py_XINCREF(m); - return m; -} - -static PyObject * -imp_init_frozen(PyObject *self, PyObject *args) -{ - char *name; - int ret; - PyObject *m; - if (!PyArg_ParseTuple(args, "s:init_frozen", &name)) - return NULL; - ret = PyImport_ImportFrozenModule(name); - if (ret < 0) - return NULL; - if (ret == 0) { - Py_INCREF(Py_None); - return Py_None; - } - m = PyImport_AddModule(name); - Py_XINCREF(m); - return m; -} - -static PyObject * -imp_get_frozen_object(PyObject *self, PyObject *args) -{ - char *name; - - if (!PyArg_ParseTuple(args, "s:get_frozen_object", &name)) - return NULL; - return get_frozen_object(name); -} - -static PyObject * -imp_is_builtin(PyObject *self, PyObject *args) -{ - char *name; - if (!PyArg_ParseTuple(args, "s:is_builtin", &name)) - return NULL; - return PyInt_FromLong(is_builtin(name)); -} - -static PyObject * -imp_is_frozen(PyObject *self, PyObject *args) -{ - char *name; - struct _frozen *p; - if (!PyArg_ParseTuple(args, "s:is_frozen", &name)) - return NULL; - p = find_frozen(name); - return PyBool_FromLong((long) (p == NULL ? 0 : p->size)); -} - -static FILE * -get_file(char *pathname, PyObject *fob, char *mode) -{ - FILE *fp; - if (fob == NULL) { - if (mode[0] == 'U') - mode = "r" PY_STDIOTEXTMODE; - fp = fopen(pathname, mode); - if (fp == NULL) - PyErr_SetFromErrno(PyExc_IOError); - } - else { - fp = PyFile_AsFile(fob); - if (fp == NULL) - PyErr_SetString(PyExc_ValueError, - "bad/closed file object"); - } - return fp; -} - -static PyObject * -imp_load_compiled(PyObject *self, PyObject *args) -{ - char *name; - char *pathname; - PyObject *fob = NULL; - PyObject *m; - FILE *fp; - if (!PyArg_ParseTuple(args, "ss|O!:load_compiled", &name, &pathname, - &PyFile_Type, &fob)) - return NULL; - fp = get_file(pathname, fob, "rb"); - if (fp == NULL) - return NULL; - m = load_compiled_module(name, pathname, fp); - if (fob == NULL) - fclose(fp); - return m; -} - -#ifdef HAVE_DYNAMIC_LOADING - -static PyObject * -imp_load_dynamic(PyObject *self, PyObject *args) -{ - char *name; - char *pathname; - PyObject *fob = NULL; - PyObject *m; - FILE *fp = NULL; - if (!PyArg_ParseTuple(args, "ss|O!:load_dynamic", &name, &pathname, - &PyFile_Type, &fob)) - return NULL; - if (fob) { - fp = get_file(pathname, fob, "r"); - if (fp == NULL) - return NULL; - } - m = _PyImport_LoadDynamicModule(name, pathname, fp); - return m; -} - -#endif /* HAVE_DYNAMIC_LOADING */ - -static PyObject * -imp_load_source(PyObject *self, PyObject *args) -{ - char *name; - char *pathname; - PyObject *fob = NULL; - PyObject *m; - FILE *fp; - if (!PyArg_ParseTuple(args, "ss|O!:load_source", &name, &pathname, - &PyFile_Type, &fob)) - return NULL; - fp = get_file(pathname, fob, "r"); - if (fp == NULL) - return NULL; - m = load_source_module(name, pathname, fp); - if (fob == NULL) - fclose(fp); - return m; -} - -#ifdef macintosh -static PyObject * -imp_load_resource(PyObject *self, PyObject *args) -{ - char *name; - char *pathname; - PyObject *m; - - if (!PyArg_ParseTuple(args, "ss:load_resource", &name, &pathname)) - return NULL; - m = PyMac_LoadResourceModule(name, pathname); - return m; -} -#endif /* macintosh */ - -static PyObject * -imp_load_module(PyObject *self, PyObject *args) -{ - char *name; - PyObject *fob; - char *pathname; - char *suffix; /* Unused */ - char *mode; - int type; - FILE *fp; - - if (!PyArg_ParseTuple(args, "sOs(ssi):load_module", - &name, &fob, &pathname, - &suffix, &mode, &type)) - return NULL; - if (*mode) { - /* Mode must start with 'r' or 'U' and must not contain '+'. - Implicit in this test is the assumption that the mode - may contain other modifiers like 'b' or 't'. */ - - if (!(*mode == 'r' || *mode == 'U') || strchr(mode, '+')) { - PyErr_Format(PyExc_ValueError, - "invalid file open mode %.200s", mode); - return NULL; - } - } - if (fob == Py_None) - fp = NULL; - else { - if (!PyFile_Check(fob)) { - PyErr_SetString(PyExc_ValueError, - "load_module arg#2 should be a file or None"); - return NULL; - } - fp = get_file(pathname, fob, mode); - if (fp == NULL) - return NULL; - } - return load_module(name, fp, pathname, type, NULL); -} - -static PyObject * -imp_load_package(PyObject *self, PyObject *args) -{ - char *name; - char *pathname; - if (!PyArg_ParseTuple(args, "ss:load_package", &name, &pathname)) - return NULL; - return load_package(name, pathname); -} - -static PyObject * -imp_new_module(PyObject *self, PyObject *args) -{ - char *name; - if (!PyArg_ParseTuple(args, "s:new_module", &name)) - return NULL; - return PyModule_New(name); -} - -/* Doc strings */ - -PyDoc_STRVAR(doc_imp, -"This module provides the components needed to build your own\n\ -__import__ function. Undocumented functions are obsolete."); - -PyDoc_STRVAR(doc_find_module, -"find_module(name, [path]) -> (file, filename, (suffix, mode, type))\n\ -Search for a module. If path is omitted or None, search for a\n\ -built-in, frozen or special module and continue search in sys.path.\n\ -The module name cannot contain '.'; to search for a submodule of a\n\ -package, pass the submodule name and the package's __path__."); - -PyDoc_STRVAR(doc_load_module, -"load_module(name, file, filename, (suffix, mode, type)) -> module\n\ -Load a module, given information returned by find_module().\n\ -The module name must include the full package name, if any."); - -PyDoc_STRVAR(doc_get_magic, -"get_magic() -> string\n\ -Return the magic number for .pyc or .pyo files."); - -PyDoc_STRVAR(doc_get_suffixes, -"get_suffixes() -> [(suffix, mode, type), ...]\n\ -Return a list of (suffix, mode, type) tuples describing the files\n\ -that find_module() looks for."); - -PyDoc_STRVAR(doc_new_module, -"new_module(name) -> module\n\ -Create a new module. Do not enter it in sys.modules.\n\ -The module name must include the full package name, if any."); - -PyDoc_STRVAR(doc_lock_held, -"lock_held() -> 0 or 1\n\ -Return 1 if the import lock is currently held.\n\ -On platforms without threads, return 0."); - -PyDoc_STRVAR(doc_acquire_lock, -"acquire_lock() -> None\n\ -Acquires the interpreter's import lock for the current thread.\n\ -This lock should be used by import hooks to ensure thread-safety\n\ -when importing modules.\n\ -On platforms without threads, this function does nothing."); - -PyDoc_STRVAR(doc_release_lock, -"release_lock() -> None\n\ -Release the interpreter's import lock.\n\ -On platforms without threads, this function does nothing."); - -static PyMethodDef imp_methods[] = { - {"find_module", imp_find_module, METH_VARARGS, doc_find_module}, - {"get_magic", imp_get_magic, METH_NOARGS, doc_get_magic}, - {"get_suffixes", imp_get_suffixes, METH_NOARGS, doc_get_suffixes}, - {"load_module", imp_load_module, METH_VARARGS, doc_load_module}, - {"new_module", imp_new_module, METH_VARARGS, doc_new_module}, - {"lock_held", imp_lock_held, METH_NOARGS, doc_lock_held}, - {"acquire_lock", imp_acquire_lock, METH_NOARGS, doc_acquire_lock}, - {"release_lock", imp_release_lock, METH_NOARGS, doc_release_lock}, - /* The rest are obsolete */ - {"get_frozen_object", imp_get_frozen_object, METH_VARARGS}, - {"init_builtin", imp_init_builtin, METH_VARARGS}, - {"init_frozen", imp_init_frozen, METH_VARARGS}, - {"is_builtin", imp_is_builtin, METH_VARARGS}, - {"is_frozen", imp_is_frozen, METH_VARARGS}, - {"load_compiled", imp_load_compiled, METH_VARARGS}, -#ifdef HAVE_DYNAMIC_LOADING - {"load_dynamic", imp_load_dynamic, METH_VARARGS}, -#endif - {"load_package", imp_load_package, METH_VARARGS}, -#ifdef macintosh - {"load_resource", imp_load_resource, METH_VARARGS}, -#endif - {"load_source", imp_load_source, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - -static int -setint(PyObject *d, char *name, int value) -{ - PyObject *v; - int err; - - v = PyInt_FromLong((long)value); - err = PyDict_SetItemString(d, name, v); - Py_XDECREF(v); - return err; -} - -void -initimp(void) -{ - PyObject *m, *d; - - m = Py_InitModule4("imp", imp_methods, doc_imp, - NULL, PYTHON_API_VERSION); - d = PyModule_GetDict(m); - - if (setint(d, "SEARCH_ERROR", SEARCH_ERROR) < 0) goto failure; - if (setint(d, "PY_SOURCE", PY_SOURCE) < 0) goto failure; - if (setint(d, "PY_COMPILED", PY_COMPILED) < 0) goto failure; - if (setint(d, "C_EXTENSION", C_EXTENSION) < 0) goto failure; - if (setint(d, "PY_RESOURCE", PY_RESOURCE) < 0) goto failure; - if (setint(d, "PKG_DIRECTORY", PKG_DIRECTORY) < 0) goto failure; - if (setint(d, "C_BUILTIN", C_BUILTIN) < 0) goto failure; - if (setint(d, "PY_FROZEN", PY_FROZEN) < 0) goto failure; - if (setint(d, "PY_CODERESOURCE", PY_CODERESOURCE) < 0) goto failure; - if (setint(d, "IMP_HOOK", IMP_HOOK) < 0) goto failure; - - failure: - ; -} - - -/* API for embedding applications that want to add their own entries - to the table of built-in modules. This should normally be called - *before* Py_Initialize(). When the table resize fails, -1 is - returned and the existing table is unchanged. - - After a similar function by Just van Rossum. */ - -int -PyImport_ExtendInittab(struct _inittab *newtab) -{ - static struct _inittab *our_copy = NULL; - struct _inittab *p; - int i, n; - - /* Count the number of entries in both tables */ - for (n = 0; newtab[n].name != NULL; n++) - ; - if (n == 0) - return 0; /* Nothing to do */ - for (i = 0; PyImport_Inittab[i].name != NULL; i++) - ; - - /* Allocate new memory for the combined table */ - p = our_copy; - PyMem_RESIZE(p, struct _inittab, i+n+1); - if (p == NULL) - return -1; - - /* Copy the tables into the new memory */ - if (our_copy != PyImport_Inittab) - memcpy(p, PyImport_Inittab, (i+1) * sizeof(struct _inittab)); - PyImport_Inittab = our_copy = p; - memcpy(p+i, newtab, (n+1) * sizeof(struct _inittab)); - - return 0; -} - -/* Shorthand to add a single entry given a name and a function */ - -int -PyImport_AppendInittab(char *name, void (*initfunc)(void)) -{ - struct _inittab newtab[2]; - - memset(newtab, '\0', sizeof newtab); - - newtab[0].name = name; - newtab[0].initfunc = initfunc; - - return PyImport_ExtendInittab(newtab); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/import_pack.c b/SDKs/XPlatform/Cypython-2.3.3/Python/import_pack.c deleted file mode 100644 index 58d8155c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/import_pack.c +++ /dev/null @@ -1,2977 +0,0 @@ - -/* Module definition and import implementation */ - -#include "Python.h" - -#include "node.h" -#include "token.h" -#include "errcode.h" -#include "marshal.h" -#include "compile.h" -#include "eval.h" -#include "osdefs.h" -#include "importdl.h" -#ifdef macintosh -#include "macglue.h" -#endif - -#include "PlasmaPack.h" - -#ifdef HAVE_FCNTL_H -#include -#endif - -extern time_t PyOS_GetLastModificationTime(char *, FILE *); - /* In getmtime.c */ - -/* Magic word to reject .pyc files generated by other Python versions */ -/* Change for each incompatible change */ -/* The value of CR and LF is incorporated so if you ever read or write - a .pyc file in text mode the magic number will be wrong; also, the - Apple MPW compiler swaps their values, botching string constants. - XXX That probably isn't important anymore. -*/ -/* XXX Perhaps the magic number should be frozen and a version field - added to the .pyc file header? */ -/* New way to come up with the low 16 bits of the magic number: - (YEAR-1995) * 10000 + MONTH * 100 + DAY - where MONTH and DAY are 1-based. - XXX Whatever the "old way" may have been isn't documented. - XXX This scheme breaks in 2002, as (2002-1995)*10000 = 70000 doesn't - fit in 16 bits. - XXX Later, sometimes 1 gets added to MAGIC in order to record that - the Unicode -U option is in use. IMO (Tim's), that's a Bad Idea - (quite apart from that the -U option doesn't work so isn't used - anyway). - - XXX MAL, 2002-02-07: I had to modify the MAGIC due to a fix of the - UTF-8 encoder (it previously produced invalid UTF-8 for unpaired - high surrogates), so I simply bumped the month value to 20 (invalid - month) and set the day to 1. This should be recognizable by any - algorithm relying on the above scheme. Perhaps we should simply - start counting in increments of 10 from now on ?! - - MWH, 2002-08-03: Removed SET_LINENO. Couldn't be bothered figuring - out the MAGIC schemes, so just incremented it by 10. - - GvR, 2002-08-31: Because MWH changed the bytecode again, moved the - magic number *back* to 62011. This should get the snake-farm to - throw away its old .pyc files, amongst others. - - Known values: - Python 1.5: 20121 - Python 1.5.1: 20121 - Python 1.5.2: 20121 - Python 2.0: 50823 - Python 2.0.1: 50823 - Python 2.1: 60202 - Python 2.1.1: 60202 - Python 2.1.2: 60202 - Python 2.2: 60717 - Python 2.3a0: 62011 - Python 2.3a0: 62021 - Python 2.3a0: 62011 (!) -*/ -/* we'll make our own magic number.... the D'ni way (whatever that means)*/ -#define MAGIC (18686 | ((long)'\r'<<16) | ((long)'\n'<<24)) - -/* Magic word as global; note that _PyImport_Init() can change the - value of this global to accommodate for alterations of how the - compiler works which are enabled by command line switches. */ -static long pyc_magic = MAGIC; - -/* See _PyImport_FixupExtension() below */ -static PyObject *extensions = NULL; - -/* This table is defined in config.c: */ -extern struct _inittab _PyImport_Inittab[]; - -struct _inittab *PyImport_Inittab = _PyImport_Inittab; - -/* these tables define the module suffixes that Python recognizes */ -struct filedescr * _PyImport_Filetab = NULL; - -#ifdef RISCOS -static const struct filedescr _PyImport_StandardFiletab[] = { - {"/py", "U", PY_SOURCE}, - {"/pyc", "rb", PY_COMPILED}, - {0, 0} -}; -#else -static const struct filedescr _PyImport_StandardFiletab[] = { - {".py", "U", PY_SOURCE}, -#ifdef MS_WINDOWS - {".pyw", "U", PY_SOURCE}, -#endif - {".pyc", "rb", PY_COMPILED}, - {0, 0} -}; -#endif - -/* Initialize things */ - -void -_PyImport_Init(void) -{ - const struct filedescr *scan; - struct filedescr *filetab; - int countD = 0; - int countS = 0; - - /* prepare _PyImport_Filetab: copy entries from - _PyImport_DynLoadFiletab and _PyImport_StandardFiletab. - */ - for (scan = _PyImport_DynLoadFiletab; scan->suffix != NULL; ++scan) - ++countD; - for (scan = _PyImport_StandardFiletab; scan->suffix != NULL; ++scan) - ++countS; - filetab = PyMem_NEW(struct filedescr, countD + countS + 1); - memcpy(filetab, _PyImport_DynLoadFiletab, - countD * sizeof(struct filedescr)); - memcpy(filetab + countD, _PyImport_StandardFiletab, - countS * sizeof(struct filedescr)); - filetab[countD + countS].suffix = NULL; - - _PyImport_Filetab = filetab; - - if (Py_OptimizeFlag) { - /* Replace ".pyc" with ".pyo" in _PyImport_Filetab */ - for (; filetab->suffix != NULL; filetab++) { -#ifndef RISCOS - if (strcmp(filetab->suffix, ".pyc") == 0) - filetab->suffix = ".pyo"; -#else - if (strcmp(filetab->suffix, "/pyc") == 0) - filetab->suffix = "/pyo"; -#endif - } - } - - if (Py_UnicodeFlag) { - /* Fix the pyc_magic so that byte compiled code created - using the all-Unicode method doesn't interfere with - code created in normal operation mode. */ - pyc_magic = MAGIC + 1; - } -} - -void -_PyImportHooks_Init(void) -{ - PyObject *v, *path_hooks = NULL, *zimpimport; - int err = 0; - - /* adding sys.path_hooks and sys.path_importer_cache, setting up - zipimport */ - - if (Py_VerboseFlag) - PySys_WriteStderr("# installing zipimport hook\n"); - - v = PyList_New(0); - if (v == NULL) - goto error; - err = PySys_SetObject("meta_path", v); - Py_DECREF(v); - if (err) - goto error; - v = PyDict_New(); - if (v == NULL) - goto error; - err = PySys_SetObject("path_importer_cache", v); - Py_DECREF(v); - if (err) - goto error; - path_hooks = PyList_New(0); - if (path_hooks == NULL) - goto error; - err = PySys_SetObject("path_hooks", path_hooks); - if (err) { - error: - PyErr_Print(); - Py_FatalError("initializing sys.meta_path, sys.path_hooks or " - "path_importer_cache failed"); - } - zimpimport = PyImport_ImportModule("zipimport"); - if (zimpimport == NULL) { - PyErr_Clear(); /* No zip import module -- okay */ - if (Py_VerboseFlag) - PySys_WriteStderr("# can't import zipimport\n"); - } - else { - PyObject *zipimporter = PyObject_GetAttrString(zimpimport, - "zipimporter"); - Py_DECREF(zimpimport); - if (zipimporter == NULL) { - PyErr_Clear(); /* No zipimporter object -- okay */ - if (Py_VerboseFlag) - PySys_WriteStderr( - "# can't import zipimport.zipimporter\n"); - } - else { - /* sys.path_hooks.append(zipimporter) */ - err = PyList_Append(path_hooks, zipimporter); - Py_DECREF(zipimporter); - if (err) - goto error; - if (Py_VerboseFlag) - PySys_WriteStderr( - "# installed zipimport hook\n"); - } - } - Py_DECREF(path_hooks); -} - -void -_PyImport_Fini(void) -{ - Py_XDECREF(extensions); - extensions = NULL; - PyMem_DEL(_PyImport_Filetab); - _PyImport_Filetab = NULL; -} - - -/* Locking primitives to prevent parallel imports of the same module - in different threads to return with a partially loaded module. - These calls are serialized by the global interpreter lock. */ - -#ifdef WITH_THREAD - -#include "pythread.h" - -static PyThread_type_lock import_lock = 0; -static long import_lock_thread = -1; -static int import_lock_level = 0; - -static void -lock_import(void) -{ - long me = PyThread_get_thread_ident(); - if (me == -1) - return; /* Too bad */ - if (import_lock == NULL) - import_lock = PyThread_allocate_lock(); - if (import_lock_thread == me) { - import_lock_level++; - return; - } - if (import_lock_thread != -1 || !PyThread_acquire_lock(import_lock, 0)) - { - PyThreadState *tstate = PyEval_SaveThread(); - PyThread_acquire_lock(import_lock, 1); - PyEval_RestoreThread(tstate); - } - import_lock_thread = me; - import_lock_level = 1; -} - -static int -unlock_import(void) -{ - long me = PyThread_get_thread_ident(); - if (me == -1) - return 0; /* Too bad */ - if (import_lock_thread != me) - return -1; - import_lock_level--; - if (import_lock_level == 0) { - import_lock_thread = -1; - PyThread_release_lock(import_lock); - } - return 1; -} - -#else - -#define lock_import() -#define unlock_import() 0 - -#endif - -static PyObject * -imp_lock_held(PyObject *self, PyObject *noargs) -{ -#ifdef WITH_THREAD - return PyBool_FromLong(import_lock_thread != -1); -#else - return PyBool_FromLong(0); -#endif -} - -static PyObject * -imp_acquire_lock(PyObject *self, PyObject *noargs) -{ -#ifdef WITH_THREAD - lock_import(); -#endif - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -imp_release_lock(PyObject *self, PyObject *noargs) -{ -#ifdef WITH_THREAD - if (unlock_import() < 0) { - PyErr_SetString(PyExc_RuntimeError, - "not holding the import lock"); - return NULL; - } -#endif - Py_INCREF(Py_None); - return Py_None; -} - -/* Helper for sys */ - -PyObject * -PyImport_GetModuleDict(void) -{ - PyInterpreterState *interp = PyThreadState_Get()->interp; - if (interp->modules == NULL) - Py_FatalError("PyImport_GetModuleDict: no module dictionary!"); - return interp->modules; -} - - -/* List of names to clear in sys */ -static char* sys_deletes[] = { - "path", "argv", "ps1", "ps2", "exitfunc", - "exc_type", "exc_value", "exc_traceback", - "last_type", "last_value", "last_traceback", - "path_hooks", "path_importer_cache", "meta_path", - NULL -}; - -static char* sys_files[] = { - "stdin", "__stdin__", - "stdout", "__stdout__", - "stderr", "__stderr__", - NULL -}; - - -/* Un-initialize things, as good as we can */ - -void -PyImport_Cleanup(void) -{ - int pos, ndone; - char *name; - PyObject *key, *value, *dict; - PyInterpreterState *interp = PyThreadState_Get()->interp; - PyObject *modules = interp->modules; - - if (modules == NULL) - return; /* Already done */ - - /* Delete some special variables first. These are common - places where user values hide and people complain when their - destructors fail. Since the modules containing them are - deleted *last* of all, they would come too late in the normal - destruction order. Sigh. */ - - value = PyDict_GetItemString(modules, "__builtin__"); - if (value != NULL && PyModule_Check(value)) { - dict = PyModule_GetDict(value); - if (Py_VerboseFlag) - PySys_WriteStderr("# clear __builtin__._\n"); - PyDict_SetItemString(dict, "_", Py_None); - } - value = PyDict_GetItemString(modules, "sys"); - if (value != NULL && PyModule_Check(value)) { - char **p; - PyObject *v; - dict = PyModule_GetDict(value); - for (p = sys_deletes; *p != NULL; p++) { - if (Py_VerboseFlag) - PySys_WriteStderr("# clear sys.%s\n", *p); - PyDict_SetItemString(dict, *p, Py_None); - } - for (p = sys_files; *p != NULL; p+=2) { - if (Py_VerboseFlag) - PySys_WriteStderr("# restore sys.%s\n", *p); - v = PyDict_GetItemString(dict, *(p+1)); - if (v == NULL) - v = Py_None; - PyDict_SetItemString(dict, *p, v); - } - } - - /* First, delete __main__ */ - value = PyDict_GetItemString(modules, "__main__"); - if (value != NULL && PyModule_Check(value)) { - if (Py_VerboseFlag) - PySys_WriteStderr("# cleanup __main__\n"); - _PyModule_Clear(value); - PyDict_SetItemString(modules, "__main__", Py_None); - } - - /* The special treatment of __builtin__ here is because even - when it's not referenced as a module, its dictionary is - referenced by almost every module's __builtins__. Since - deleting a module clears its dictionary (even if there are - references left to it), we need to delete the __builtin__ - module last. Likewise, we don't delete sys until the very - end because it is implicitly referenced (e.g. by print). - - Also note that we 'delete' modules by replacing their entry - in the modules dict with None, rather than really deleting - them; this avoids a rehash of the modules dictionary and - also marks them as "non existent" so they won't be - re-imported. */ - - /* Next, repeatedly delete modules with a reference count of - one (skipping __builtin__ and sys) and delete them */ - do { - ndone = 0; - pos = 0; - while (PyDict_Next(modules, &pos, &key, &value)) { - if (value->ob_refcnt != 1) - continue; - if (PyString_Check(key) && PyModule_Check(value)) { - name = PyString_AS_STRING(key); - if (strcmp(name, "__builtin__") == 0) - continue; - if (strcmp(name, "sys") == 0) - continue; - if (Py_VerboseFlag) - PySys_WriteStderr( - "# cleanup[1] %s\n", name); - _PyModule_Clear(value); - PyDict_SetItem(modules, key, Py_None); - ndone++; - } - } - } while (ndone > 0); - - /* Next, delete all modules (still skipping __builtin__ and sys) */ - pos = 0; - while (PyDict_Next(modules, &pos, &key, &value)) { - if (PyString_Check(key) && PyModule_Check(value)) { - name = PyString_AS_STRING(key); - if (strcmp(name, "__builtin__") == 0) - continue; - if (strcmp(name, "sys") == 0) - continue; - if (Py_VerboseFlag) - PySys_WriteStderr("# cleanup[2] %s\n", name); - _PyModule_Clear(value); - PyDict_SetItem(modules, key, Py_None); - } - } - - /* Next, delete sys and __builtin__ (in that order) */ - value = PyDict_GetItemString(modules, "sys"); - if (value != NULL && PyModule_Check(value)) { - if (Py_VerboseFlag) - PySys_WriteStderr("# cleanup sys\n"); - _PyModule_Clear(value); - PyDict_SetItemString(modules, "sys", Py_None); - } - value = PyDict_GetItemString(modules, "__builtin__"); - if (value != NULL && PyModule_Check(value)) { - if (Py_VerboseFlag) - PySys_WriteStderr("# cleanup __builtin__\n"); - _PyModule_Clear(value); - PyDict_SetItemString(modules, "__builtin__", Py_None); - } - - /* Finally, clear and delete the modules directory */ - PyDict_Clear(modules); - interp->modules = NULL; - Py_DECREF(modules); -} - - -/* Helper for pythonrun.c -- return magic number */ - -long -PyImport_GetMagicNumber(void) -{ - return pyc_magic; -} - - -/* Magic for extension modules (built-in as well as dynamically - loaded). To prevent initializing an extension module more than - once, we keep a static dictionary 'extensions' keyed by module name - (for built-in modules) or by filename (for dynamically loaded - modules), containing these modules. A copy of the module's - dictionary is stored by calling _PyImport_FixupExtension() - immediately after the module initialization function succeeds. A - copy can be retrieved from there by calling - _PyImport_FindExtension(). */ - -PyObject * -_PyImport_FixupExtension(char *name, char *filename) -{ - PyObject *modules, *mod, *dict, *copy; - if (extensions == NULL) { - extensions = PyDict_New(); - if (extensions == NULL) - return NULL; - } - modules = PyImport_GetModuleDict(); - mod = PyDict_GetItemString(modules, name); - if (mod == NULL || !PyModule_Check(mod)) { - PyErr_Format(PyExc_SystemError, - "_PyImport_FixupExtension: module %.200s not loaded", name); - return NULL; - } - dict = PyModule_GetDict(mod); - if (dict == NULL) - return NULL; - copy = PyDict_Copy(dict); - if (copy == NULL) - return NULL; - PyDict_SetItemString(extensions, filename, copy); - Py_DECREF(copy); - return copy; -} - -PyObject * -_PyImport_FindExtension(char *name, char *filename) -{ - PyObject *dict, *mod, *mdict; - if (extensions == NULL) - return NULL; - dict = PyDict_GetItemString(extensions, filename); - if (dict == NULL) - return NULL; - mod = PyImport_AddModule(name); - if (mod == NULL) - return NULL; - mdict = PyModule_GetDict(mod); - if (mdict == NULL) - return NULL; - if (PyDict_Update(mdict, dict)) - return NULL; - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # previously loaded (%s)\n", - name, filename); - return mod; -} - - -/* Get the module object corresponding to a module name. - First check the modules dictionary if there's one there, - if not, create a new one and insert it in the modules dictionary. - Because the former action is most common, THIS DOES NOT RETURN A - 'NEW' REFERENCE! */ - -PyObject * -PyImport_AddModule(char *name) -{ - PyObject *modules = PyImport_GetModuleDict(); - PyObject *m; - - if ((m = PyDict_GetItemString(modules, name)) != NULL && - PyModule_Check(m)) - return m; - m = PyModule_New(name); - if (m == NULL) - return NULL; - if (PyDict_SetItemString(modules, name, m) != 0) { - Py_DECREF(m); - return NULL; - } - Py_DECREF(m); /* Yes, it still exists, in modules! */ - - return m; -} - - -/* Execute a code object in a module and return the module object - WITH INCREMENTED REFERENCE COUNT */ - -PyObject * -PyImport_ExecCodeModule(char *name, PyObject *co) -{ - return PyImport_ExecCodeModuleEx(name, co, (char *)NULL); -} - -PyObject * -PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname) -{ - PyObject *modules = PyImport_GetModuleDict(); - PyObject *m, *d, *v; - - m = PyImport_AddModule(name); - if (m == NULL) - return NULL; - d = PyModule_GetDict(m); - if (PyDict_GetItemString(d, "__builtins__") == NULL) { - if (PyDict_SetItemString(d, "__builtins__", - PyEval_GetBuiltins()) != 0) - return NULL; - } - /* Remember the filename as the __file__ attribute */ - v = NULL; - if (pathname != NULL) { - v = PyString_FromString(pathname); - if (v == NULL) - PyErr_Clear(); - } - if (v == NULL) { - v = ((PyCodeObject *)co)->co_filename; - Py_INCREF(v); - } - if (PyDict_SetItemString(d, "__file__", v) != 0) - PyErr_Clear(); /* Not important enough to report */ - Py_DECREF(v); - - v = PyEval_EvalCode((PyCodeObject *)co, d, d); - if (v == NULL) - return NULL; - Py_DECREF(v); - - if ((m = PyDict_GetItemString(modules, name)) == NULL) { - PyErr_Format(PyExc_ImportError, - "Loaded module %.200s not found in sys.modules", - name); - return NULL; - } - - Py_INCREF(m); - - return m; -} - - -/* Given a pathname for a Python source file, fill a buffer with the - pathname for the corresponding compiled file. Return the pathname - for the compiled file, or NULL if there's no space in the buffer. - Doesn't set an exception. */ - -static char * -make_compiled_pathname(char *pathname, char *buf, size_t buflen) -{ - size_t len = strlen(pathname); - if (len+2 > buflen) - return NULL; - -#ifdef MS_WINDOWS - /* Treat .pyw as if it were .py. The case of ".pyw" must match - that used in _PyImport_StandardFiletab. */ - if (len >= 4 && strcmp(&pathname[len-4], ".pyw") == 0) - --len; /* pretend 'w' isn't there */ -#endif - memcpy(buf, pathname, len); - buf[len] = Py_OptimizeFlag ? 'o' : 'c'; - buf[len+1] = '\0'; - - return buf; -} - - -/* Given a pathname for a Python source file, its time of last - modification, and a pathname for a compiled file, check whether the - compiled file represents the same version of the source. If so, - return a FILE pointer for the compiled file, positioned just after - the header; if not, return NULL. - Doesn't set an exception. */ - -static FILE * -check_compiled_module(char *pathname, long mtime, char *cpathname) -{ - FILE *fp; - long magic; - long pyc_mtime; - - fp = fopen(cpathname, "rb"); - if (fp == NULL) - return NULL; - magic = PyMarshal_ReadLongFromFile(fp); - if (magic != pyc_magic) { - if (Py_VerboseFlag) - PySys_WriteStderr("# %s has bad magic\n", cpathname); - fclose(fp); - return NULL; - } - pyc_mtime = PyMarshal_ReadLongFromFile(fp); - if (pyc_mtime != mtime) { - if (Py_VerboseFlag) - PySys_WriteStderr("# %s has bad mtime\n", cpathname); - fclose(fp); - return NULL; - } - if (Py_VerboseFlag) - PySys_WriteStderr("# %s matches %s\n", cpathname, pathname); - return fp; -} - - -/* Read a code object from a file and check it for validity */ - -static PyCodeObject * -read_compiled_module(char *cpathname, FILE *fp) -{ - PyObject *co; - - co = PyMarshal_ReadLastObjectFromFile(fp); - /* Ugly: rd_object() may return NULL with or without error */ - if (co == NULL || !PyCode_Check(co)) { - if (!PyErr_Occurred()) - PyErr_Format(PyExc_ImportError, - "Non-code object in %.200s", cpathname); - Py_XDECREF(co); - return NULL; - } - return (PyCodeObject *)co; -} - - -/* Load a module from a compiled file, execute it, and return its - module object WITH INCREMENTED REFERENCE COUNT */ - -static PyObject * -load_compiled_module(char *name, char *cpathname, FILE *fp) -{ - long magic; - PyCodeObject *co; - PyObject *m; - - magic = PyMarshal_ReadLongFromFile(fp); - if (magic != pyc_magic) { - PyErr_Format(PyExc_ImportError, - "Bad magic number in %.200s", cpathname); - return NULL; - } - (void) PyMarshal_ReadLongFromFile(fp); - co = read_compiled_module(cpathname, fp); - if (co == NULL) - return NULL; - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # precompiled from %s\n", - name, cpathname); - m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, cpathname); - Py_DECREF(co); - - return m; -} - -/* -Load a python Plasma packfile. -Its already compiled... just load and server -*/ -static PyObject * -load_plasmapacked_module(char *name, char *cpathname) -{ - PyObject *co; - PyObject *m; - - co = Pl_OpenPacked(name); - if (co == NULL) - return NULL; - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # precompiled from %s\n", - name, cpathname); - m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, cpathname); - Py_DECREF(co); - - return m; -} - -/* Parse a source file and return the corresponding code object */ - -static PyCodeObject * -parse_source_module(char *pathname, FILE *fp) -{ - PyCodeObject *co; - node *n; - - n = PyParser_SimpleParseFile(fp, pathname, Py_file_input); - if (n == NULL) - return NULL; - co = PyNode_Compile(n, pathname); - PyNode_Free(n); - - return co; -} - - -/* Helper to open a bytecode file for writing in exclusive mode */ - -static FILE * -open_exclusive(char *filename) -{ -#if defined(O_EXCL)&&defined(O_CREAT)&&defined(O_WRONLY)&&defined(O_TRUNC)&&!defined(_DEBUG) - /* Use O_EXCL to avoid a race condition when another process tries to - write the same file. When that happens, our open() call fails, - which is just fine (since it's only a cache). - XXX If the file exists and is writable but the directory is not - writable, the file will never be written. Oh well. - */ - int fd; - (void) unlink(filename); - fd = open(filename, O_EXCL|O_CREAT|O_WRONLY|O_TRUNC -#ifdef O_BINARY - |O_BINARY /* necessary for Windows */ -#endif -#ifdef __VMS - , 0666, "ctxt=bin", "shr=nil"); -#else - , 0666); -#endif - if (fd < 0) - return NULL; - return fdopen(fd, "wb"); -#else - /* Best we can do -- on Windows this can't happen anyway */ - return fopen(filename, "wb"); -#endif -} - - -/* Write a compiled module to a file, placing the time of last - modification of its source into the header. - Errors are ignored, if a write error occurs an attempt is made to - remove the file. */ - -static void -write_compiled_module(PyCodeObject *co, char *cpathname, long mtime) -{ - FILE *fp; - - fp = open_exclusive(cpathname); - if (fp == NULL) { - if (Py_VerboseFlag) - PySys_WriteStderr( - "# can't create %s\n", cpathname); - return; - } - PyMarshal_WriteLongToFile(pyc_magic, fp); - /* First write a 0 for mtime */ - PyMarshal_WriteLongToFile(0L, fp); - PyMarshal_WriteObjectToFile((PyObject *)co, fp); - if (ferror(fp)) { - if (Py_VerboseFlag) - PySys_WriteStderr("# can't write %s\n", cpathname); - /* Don't keep partial file */ - fclose(fp); - (void) unlink(cpathname); - return; - } - /* Now write the true mtime */ - fseek(fp, 4L, 0); - PyMarshal_WriteLongToFile(mtime, fp); - fflush(fp); - fclose(fp); - if (Py_VerboseFlag) - PySys_WriteStderr("# wrote %s\n", cpathname); -#ifdef macintosh - PyMac_setfiletype(cpathname, 'Pyth', 'PYC '); -#endif -} - - -/* Load a source module from a given file and return its module - object WITH INCREMENTED REFERENCE COUNT. If there's a matching - byte-compiled file, use that instead. */ - -static PyObject * -load_source_module(char *name, char *pathname, FILE *fp) -{ - time_t mtime; - FILE *fpc; - char buf[MAXPATHLEN+1]; - char *cpathname; - PyCodeObject *co; - PyObject *m; - - mtime = PyOS_GetLastModificationTime(pathname, fp); - if (mtime == (time_t)(-1)) - return NULL; -#if SIZEOF_TIME_T > 4 - /* Python's .pyc timestamp handling presumes that the timestamp fits - in 4 bytes. This will be fine until sometime in the year 2038, - when a 4-byte signed time_t will overflow. - */ - if (mtime >> 32) { - PyErr_SetString(PyExc_OverflowError, - "modification time overflows a 4 byte field"); - return NULL; - } -#endif - cpathname = make_compiled_pathname(pathname, buf, - (size_t)MAXPATHLEN + 1); - if (cpathname != NULL && - (fpc = check_compiled_module(pathname, mtime, cpathname))) { - co = read_compiled_module(cpathname, fpc); - fclose(fpc); - if (co == NULL) - return NULL; - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # precompiled from %s\n", - name, cpathname); - pathname = cpathname; - } - else { - co = parse_source_module(pathname, fp); - if (co == NULL) - return NULL; - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # from %s\n", - name, pathname); - write_compiled_module(co, cpathname, mtime); - } - m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, pathname); - Py_DECREF(co); - - return m; -} - - -/* Forward */ -static PyObject *load_module(char *, FILE *, char *, int, PyObject *); -static struct filedescr *find_module(char *, char *, PyObject *, - char *, size_t, FILE **, PyObject **); -static struct _frozen *find_frozen(char *name); - -/* Load a package and return its module object WITH INCREMENTED - REFERENCE COUNT */ - -static PyObject * -load_package(char *name, char *pathname) -{ - PyObject *m, *d, *file, *path; - int err; - char buf[MAXPATHLEN+1]; - FILE *fp = NULL; - struct filedescr *fdp; - - m = PyImport_AddModule(name); - if (m == NULL) - return NULL; - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # directory %s\n", - name, pathname); - d = PyModule_GetDict(m); - file = PyString_FromString(pathname); - if (file == NULL) - return NULL; - path = Py_BuildValue("[O]", file); - if (path == NULL) { - Py_DECREF(file); - return NULL; - } - err = PyDict_SetItemString(d, "__file__", file); - if (err == 0) - err = PyDict_SetItemString(d, "__path__", path); - if (err != 0) { - m = NULL; - goto cleanup; - } - buf[0] = '\0'; - fdp = find_module(name, "__init__", path, buf, sizeof(buf), &fp, NULL); - if (fdp == NULL) { - if (PyErr_ExceptionMatches(PyExc_ImportError)) { - PyErr_Clear(); - } - else - m = NULL; - goto cleanup; - } - m = load_module(name, fp, buf, fdp->type, NULL); - if (fp != NULL) - fclose(fp); - cleanup: - Py_XDECREF(path); - Py_XDECREF(file); - return m; -} - - -/* Helper to test for built-in module */ - -static int -is_builtin(char *name) -{ - int i; - for (i = 0; PyImport_Inittab[i].name != NULL; i++) { - if (strcmp(name, PyImport_Inittab[i].name) == 0) { - if (PyImport_Inittab[i].initfunc == NULL) - return -1; - else - return 1; - } - } - return 0; -} - - -/* Return an importer object for a sys.path/pkg.__path__ item 'p', - possibly by fetching it from the path_importer_cache dict. If it - wasn't yet cached, traverse path_hooks until it a hook is found - that can handle the path item. Return None if no hook could; - this tells our caller it should fall back to the builtin - import mechanism. Cache the result in path_importer_cache. - Returns a borrowed reference. */ - -static PyObject * -get_path_importer(PyObject *path_importer_cache, PyObject *path_hooks, - PyObject *p) -{ - PyObject *importer; - int j, nhooks; - - /* These conditions are the caller's responsibility: */ - assert(PyList_Check(path_hooks)); - assert(PyDict_Check(path_importer_cache)); - - nhooks = PyList_Size(path_hooks); - if (nhooks < 0) - return NULL; /* Shouldn't happen */ - - importer = PyDict_GetItem(path_importer_cache, p); - if (importer != NULL) - return importer; - - /* set path_importer_cache[p] to None to avoid recursion */ - if (PyDict_SetItem(path_importer_cache, p, Py_None) != 0) - return NULL; - - for (j = 0; j < nhooks; j++) { - PyObject *hook = PyList_GetItem(path_hooks, j); - if (hook == NULL) - return NULL; - importer = PyObject_CallFunction(hook, "O", p); - if (importer != NULL) - break; - - if (!PyErr_ExceptionMatches(PyExc_ImportError)) { - return NULL; - } - PyErr_Clear(); - } - if (importer == NULL) - importer = Py_None; - else if (importer != Py_None) { - int err = PyDict_SetItem(path_importer_cache, p, importer); - Py_DECREF(importer); - if (err != 0) - return NULL; - } - return importer; -} - -/* Search the path (default sys.path) for a module. Return the - corresponding filedescr struct, and (via return arguments) the - pathname and an open file. Return NULL if the module is not found. */ - -#ifdef MS_COREDLL -extern FILE *PyWin_FindRegisteredModule(const char *, struct filedescr **, - char *, int); -#endif - -static int case_ok(char *, int, int, char *); -static int find_init_module(char *); /* Forward */ -static struct filedescr importhookdescr = {"", "", IMP_HOOK}; - -static struct filedescr * -find_module(char *fullname, char *subname, PyObject *path, char *buf, - size_t buflen, FILE **p_fp, PyObject **p_loader) -{ - int i, npath; - size_t len, namelen; - struct filedescr *fdp = NULL; - char *filemode; - FILE *fp = NULL; - PyObject *path_hooks, *path_importer_cache; -#ifndef RISCOS - struct stat statbuf; -#endif - static struct filedescr fd_frozen = {"", "", PY_FROZEN}; - static struct filedescr fd_builtin = {"", "", C_BUILTIN}; - static struct filedescr fd_package = {"", "", PKG_DIRECTORY}; - static struct filedescr fd_plasmaPack = {"", "", PLASMA_PACKFILE}; - char name[MAXPATHLEN+1]; -#if defined(PYOS_OS2) - size_t saved_len; - size_t saved_namelen; - char *saved_buf = NULL; -#endif - // for plasma pak files (so we can override them with local python, if it exists) - int isPacked = 0; - char pakName[MAXPATHLEN+1]; - - if (p_loader != NULL) - *p_loader = NULL; - - if (strlen(subname) > MAXPATHLEN) { - PyErr_SetString(PyExc_OverflowError, - "module name is too long"); - return NULL; - } - strcpy(name, subname); - - /* sys.meta_path import hook */ - if (p_loader != NULL) { - PyObject *meta_path; - - meta_path = PySys_GetObject("meta_path"); - if (meta_path == NULL || !PyList_Check(meta_path)) { - PyErr_SetString(PyExc_ImportError, - "sys.meta_path must be a list of " - "import hooks"); - return NULL; - } - Py_INCREF(meta_path); /* zap guard */ - npath = PyList_Size(meta_path); - for (i = 0; i < npath; i++) { - PyObject *loader; - PyObject *hook = PyList_GetItem(meta_path, i); - loader = PyObject_CallMethod(hook, "find_module", - "sO", fullname, - path != NULL ? - path : Py_None); - if (loader == NULL) { - Py_DECREF(meta_path); - return NULL; /* true error */ - } - if (loader != Py_None) { - /* a loader was found */ - *p_loader = loader; - Py_DECREF(meta_path); - return &importhookdescr; - } - Py_DECREF(loader); - } - Py_DECREF(meta_path); - } - - if (path != NULL && PyString_Check(path)) { - /* The only type of submodule allowed inside a "frozen" - package are other frozen modules or packages. */ - if (PyString_Size(path) + 1 + strlen(name) >= (size_t)buflen) { - PyErr_SetString(PyExc_ImportError, - "full frozen module name too long"); - return NULL; - } - strcpy(buf, PyString_AsString(path)); - strcat(buf, "."); - strcat(buf, name); - strcpy(name, buf); -#ifdef macintosh - /* Freezing on the mac works different, and the modules are - ** actually on sys.path. So we don't take the quick exit but - ** continue with the normal flow. - */ - path = NULL; -#else - if (find_frozen(name) != NULL) { - strcpy(buf, name); - return &fd_frozen; - } - PyErr_Format(PyExc_ImportError, - "No frozen submodule named %.200s", name); - return NULL; -#endif - } - if (path == NULL) { - if (is_builtin(name)) { - strcpy(buf, name); - return &fd_builtin; - } - if ((find_frozen(name)) != NULL) { - strcpy(buf, name); - return &fd_frozen; - } - - // check to see if its in the plasma python pack file - if ( Pl_IsItPacked(name) ) { -#ifdef PLASMA_EXTERNAL_RELEASE - strcpy(buf, name); - return &fd_plasmaPack; -#else - // internal builds can override the pak file - isPacked = 1; - strcpy(pakName, name); -#endif - } - -#ifdef MS_COREDLL - fp = PyWin_FindRegisteredModule(name, &fdp, buf, buflen); - if (fp != NULL) { - *p_fp = fp; - return fdp; - } -#endif - path = PySys_GetObject("path"); - } - if (path == NULL || !PyList_Check(path)) { - PyErr_SetString(PyExc_ImportError, - "sys.path must be a list of directory names"); - return NULL; - } - - path_hooks = PySys_GetObject("path_hooks"); - if (path_hooks == NULL || !PyList_Check(path_hooks)) { - PyErr_SetString(PyExc_ImportError, - "sys.path_hooks must be a list of " - "import hooks"); - return NULL; - } - path_importer_cache = PySys_GetObject("path_importer_cache"); - if (path_importer_cache == NULL || - !PyDict_Check(path_importer_cache)) { - PyErr_SetString(PyExc_ImportError, - "sys.path_importer_cache must be a dict"); - return NULL; - } - - npath = PyList_Size(path); - namelen = strlen(name); - for (i = 0; i < npath; i++) { - PyObject *copy = NULL; - PyObject *v = PyList_GetItem(path, i); -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(v)) { - copy = PyUnicode_Encode(PyUnicode_AS_UNICODE(v), - PyUnicode_GET_SIZE(v), Py_FileSystemDefaultEncoding, NULL); - if (copy == NULL) - return NULL; - v = copy; - } - else -#endif - if (!PyString_Check(v)) - continue; - len = PyString_Size(v); - if (len + 2 + namelen + MAXSUFFIXSIZE >= buflen) { - Py_XDECREF(copy); - continue; /* Too long */ - } - strcpy(buf, PyString_AsString(v)); - if (strlen(buf) != len) { - Py_XDECREF(copy); - continue; /* v contains '\0' */ - } - - /* sys.path_hooks import hook */ - if (p_loader != NULL) { - PyObject *importer; - - importer = get_path_importer(path_importer_cache, - path_hooks, v); - if (importer == NULL) - return NULL; - /* Note: importer is a borrowed reference */ - if (importer != Py_None) { - PyObject *loader; - loader = PyObject_CallMethod(importer, - "find_module", - "s", fullname); - if (loader == NULL) - return NULL; /* error */ - if (loader != Py_None) { - /* a loader was found */ - *p_loader = loader; - return &importhookdescr; - } - Py_DECREF(loader); - } - /* no hook was successful, use builtin import */ - } - -#ifdef macintosh - /* - ** Speedup: each sys.path item is interned, and - ** FindResourceModule remembers which items refer to - ** folders (so we don't have to bother trying to look - ** into them for resources). We only do this for string - ** items. - */ - if (PyString_Check(PyList_GET_ITEM(path, i))) { - PyString_InternInPlace(&PyList_GET_ITEM(path, i)); - v = PyList_GET_ITEM(path, i); - if (PyMac_FindResourceModule((PyStringObject *)v, name, buf)) { - static struct filedescr resfiledescr = - {"", "", PY_RESOURCE}; - - Py_XDECREF(copy); - return &resfiledescr; - } - if (PyMac_FindCodeResourceModule((PyStringObject *)v, name, buf)) { - static struct filedescr resfiledescr = - {"", "", PY_CODERESOURCE}; - - Py_XDECREF(copy); - return &resfiledescr; - } - } -#endif - if (len > 0 && buf[len-1] != SEP -#ifdef ALTSEP - && buf[len-1] != ALTSEP -#endif - ) - buf[len++] = SEP; - strcpy(buf+len, name); - len += namelen; - - /* Check for package import (buf holds a directory name, - and there's an __init__ module in that directory */ -#ifdef HAVE_STAT - if (stat(buf, &statbuf) == 0 && /* it exists */ - S_ISDIR(statbuf.st_mode) && /* it's a directory */ - find_init_module(buf) && /* it has __init__.py */ - case_ok(buf, len, namelen, name)) { /* and case matches */ - Py_XDECREF(copy); - return &fd_package; - } -#else - /* XXX How are you going to test for directories? */ -#ifdef RISCOS - if (isdir(buf) && - find_init_module(buf) && - case_ok(buf, len, namelen, name)) { - Py_XDECREF(copy); - return &fd_package; - } -#endif -#endif -#ifdef macintosh - fdp = PyMac_FindModuleExtension(buf, &len, name); - if (fdp) { -#else -#if defined(PYOS_OS2) - /* take a snapshot of the module spec for restoration - * after the 8 character DLL hackery - */ - saved_buf = strdup(buf); - saved_len = len; - saved_namelen = namelen; -#endif /* PYOS_OS2 */ - for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) { -#if defined(PYOS_OS2) - /* OS/2 limits DLLs to 8 character names (w/o - extension) - * so if the name is longer than that and its a - * dynamically loaded module we're going to try, - * truncate the name before trying - */ - if (strlen(subname) > 8) { - /* is this an attempt to load a C extension? */ - const struct filedescr *scan; - scan = _PyImport_DynLoadFiletab; - while (scan->suffix != NULL) { - if (!strcmp(scan->suffix, fdp->suffix)) - break; - else - scan++; - } - if (scan->suffix != NULL) { - /* yes, so truncate the name */ - namelen = 8; - len -= strlen(subname) - namelen; - buf[len] = '\0'; - } - } -#endif /* PYOS_OS2 */ - strcpy(buf+len, fdp->suffix); - if (Py_VerboseFlag > 1) - PySys_WriteStderr("# trying %s\n", buf); -#endif /* !macintosh */ - filemode = fdp->mode; - if (filemode[0] == 'U') - filemode = "r" PY_STDIOTEXTMODE; - fp = fopen(buf, filemode); - if (fp != NULL) { - if (case_ok(buf, len, namelen, name)) - break; - else { /* continue search */ - fclose(fp); - fp = NULL; - } - } -#if defined(PYOS_OS2) - /* restore the saved snapshot */ - strcpy(buf, saved_buf); - len = saved_len; - namelen = saved_namelen; -#endif - } -#if defined(PYOS_OS2) - /* don't need/want the module name snapshot anymore */ - if (saved_buf) - { - free(saved_buf); - saved_buf = NULL; - } -#endif - Py_XDECREF(copy); - if (fp != NULL) - break; - } - if (fp == NULL) { -#ifndef PLASMA_EXTERNAL_RELEASE - if (isPacked) { - // we didn't find anything to override it, use the pak file - strcpy(buf, pakName); - return &fd_plasmaPack; - } -#endif - PyErr_Format(PyExc_ImportError, - "No module named %.200s", name); - return NULL; - } - *p_fp = fp; - return fdp; -} - -/* case_ok(char* buf, int len, int namelen, char* name) - * The arguments here are tricky, best shown by example: - * /a/b/c/d/e/f/g/h/i/j/k/some_long_module_name.py\0 - * ^ ^ ^ ^ - * |--------------------- buf ---------------------| - * |------------------- len ------------------| - * |------ name -------| - * |----- namelen -----| - * buf is the full path, but len only counts up to (& exclusive of) the - * extension. name is the module name, also exclusive of extension. - * - * We've already done a successful stat() or fopen() on buf, so know that - * there's some match, possibly case-insensitive. - * - * case_ok() is to return 1 if there's a case-sensitive match for - * name, else 0. case_ok() is also to return 1 if envar PYTHONCASEOK - * exists. - * - * case_ok() is used to implement case-sensitive import semantics even - * on platforms with case-insensitive filesystems. It's trivial to implement - * for case-sensitive filesystems. It's pretty much a cross-platform - * nightmare for systems with case-insensitive filesystems. - */ - -/* First we may need a pile of platform-specific header files; the sequence - * of #if's here should match the sequence in the body of case_ok(). - */ -#if defined(MS_WINDOWS) || defined(__CYGWIN__) -#ifdef MS_XBOX -#include -#else -#include -#endif -#ifdef __CYGWIN__ -#include -#endif - -#elif defined(DJGPP) -#include - -#elif defined(macintosh) -#include - -#elif defined(__MACH__) && defined(__APPLE__) && defined(HAVE_DIRENT_H) -#include -#include - -#elif defined(PYOS_OS2) -#define INCL_DOS -#define INCL_DOSERRORS -#define INCL_NOPMAPI -#include - -#elif defined(RISCOS) -#include "oslib/osfscontrol.h" -#endif - -static int -case_ok(char *buf, int len, int namelen, char *name) -{ -/* Pick a platform-specific implementation; the sequence of #if's here should - * match the sequence just above. - */ - -/* MS_WINDOWS || __CYGWIN__ */ -#if defined(MS_WINDOWS) || defined(__CYGWIN__) - WIN32_FIND_DATA data; - HANDLE h; -#ifdef __CYGWIN__ - char tempbuf[MAX_PATH]; -#endif - - if (Py_GETENV("PYTHONCASEOK") != NULL) - return 1; - -#ifdef __CYGWIN__ - cygwin32_conv_to_win32_path(buf, tempbuf); - h = FindFirstFile(tempbuf, &data); -#else - h = FindFirstFile(buf, &data); -#endif - if (h == INVALID_HANDLE_VALUE) { - PyErr_Format(PyExc_NameError, - "Can't find file for module %.100s\n(filename %.300s)", - name, buf); - return 0; - } - FindClose(h); - return strncmp(data.cFileName, name, namelen) == 0; - -/* DJGPP */ -#elif defined(DJGPP) - struct ffblk ffblk; - int done; - - if (Py_GETENV("PYTHONCASEOK") != NULL) - return 1; - - done = findfirst(buf, &ffblk, FA_ARCH|FA_RDONLY|FA_HIDDEN|FA_DIREC); - if (done) { - PyErr_Format(PyExc_NameError, - "Can't find file for module %.100s\n(filename %.300s)", - name, buf); - return 0; - } - return strncmp(ffblk.ff_name, name, namelen) == 0; - -/* macintosh */ -#elif defined(macintosh) - FSSpec fss; - OSErr err; - - if (Py_GETENV("PYTHONCASEOK") != NULL) - return 1; - - err = FSMakeFSSpec(0, 0, Pstring(buf), &fss); - if (err) { - PyErr_Format(PyExc_NameError, - "Can't find file for module %.100s\n(filename %.300s)", - name, buf); - return 0; - } - return fss.name[0] >= namelen && - strncmp(name, (char *)fss.name+1, namelen) == 0; - -/* new-fangled macintosh (macosx) */ -#elif defined(__MACH__) && defined(__APPLE__) && defined(HAVE_DIRENT_H) - DIR *dirp; - struct dirent *dp; - char dirname[MAXPATHLEN + 1]; - const int dirlen = len - namelen - 1; /* don't want trailing SEP */ - - if (Py_GETENV("PYTHONCASEOK") != NULL) - return 1; - - /* Copy the dir component into dirname; substitute "." if empty */ - if (dirlen <= 0) { - dirname[0] = '.'; - dirname[1] = '\0'; - } - else { - assert(dirlen <= MAXPATHLEN); - memcpy(dirname, buf, dirlen); - dirname[dirlen] = '\0'; - } - /* Open the directory and search the entries for an exact match. */ - dirp = opendir(dirname); - if (dirp) { - char *nameWithExt = buf + len - namelen; - while ((dp = readdir(dirp)) != NULL) { - const int thislen = -#ifdef _DIRENT_HAVE_D_NAMELEN - dp->d_namlen; -#else - strlen(dp->d_name); -#endif - if (thislen >= namelen && - strcmp(dp->d_name, nameWithExt) == 0) { - (void)closedir(dirp); - return 1; /* Found */ - } - } - (void)closedir(dirp); - } - return 0 ; /* Not found */ - -/* RISC OS */ -#elif defined(RISCOS) - char canon[MAXPATHLEN+1]; /* buffer for the canonical form of the path */ - char buf2[MAXPATHLEN+2]; - char *nameWithExt = buf+len-namelen; - int canonlen; - os_error *e; - - if (Py_GETENV("PYTHONCASEOK") != NULL) - return 1; - - /* workaround: - append wildcard, otherwise case of filename wouldn't be touched */ - strcpy(buf2, buf); - strcat(buf2, "*"); - - e = xosfscontrol_canonicalise_path(buf2,canon,0,0,MAXPATHLEN+1,&canonlen); - canonlen = MAXPATHLEN+1-canonlen; - if (e || canonlen<=0 || canonlen>(MAXPATHLEN+1) ) - return 0; - if (strcmp(nameWithExt, canon+canonlen-strlen(nameWithExt))==0) - return 1; /* match */ - - return 0; - -/* OS/2 */ -#elif defined(PYOS_OS2) - HDIR hdir = 1; - ULONG srchcnt = 1; - FILEFINDBUF3 ffbuf; - APIRET rc; - - if (Py_GETENV("PYTHONCASEOK") != NULL) - return 1; - - rc = DosFindFirst(buf, - &hdir, - FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY, - &ffbuf, sizeof(ffbuf), - &srchcnt, - FIL_STANDARD); - if (rc != NO_ERROR) - return 0; - return strncmp(ffbuf.achName, name, namelen) == 0; - -/* assuming it's a case-sensitive filesystem, so there's nothing to do! */ -#else - return 1; - -#endif -} - - -#ifdef HAVE_STAT -/* Helper to look for __init__.py or __init__.py[co] in potential package */ -static int -find_init_module(char *buf) -{ - const size_t save_len = strlen(buf); - size_t i = save_len; - char *pname; /* pointer to start of __init__ */ - struct stat statbuf; - -/* For calling case_ok(buf, len, namelen, name): - * /a/b/c/d/e/f/g/h/i/j/k/some_long_module_name.py\0 - * ^ ^ ^ ^ - * |--------------------- buf ---------------------| - * |------------------- len ------------------| - * |------ name -------| - * |----- namelen -----| - */ - if (save_len + 13 >= MAXPATHLEN) - return 0; - buf[i++] = SEP; - pname = buf + i; - strcpy(pname, "__init__.py"); - if (stat(buf, &statbuf) == 0) { - if (case_ok(buf, - save_len + 9, /* len("/__init__") */ - 8, /* len("__init__") */ - pname)) { - buf[save_len] = '\0'; - return 1; - } - } - i += strlen(pname); - strcpy(buf+i, Py_OptimizeFlag ? "o" : "c"); - if (stat(buf, &statbuf) == 0) { - if (case_ok(buf, - save_len + 9, /* len("/__init__") */ - 8, /* len("__init__") */ - pname)) { - buf[save_len] = '\0'; - return 1; - } - } - buf[save_len] = '\0'; - return 0; -} - -#else - -#ifdef RISCOS -static int -find_init_module(buf) - char *buf; -{ - int save_len = strlen(buf); - int i = save_len; - - if (save_len + 13 >= MAXPATHLEN) - return 0; - buf[i++] = SEP; - strcpy(buf+i, "__init__/py"); - if (isfile(buf)) { - buf[save_len] = '\0'; - return 1; - } - - if (Py_OptimizeFlag) - strcpy(buf+i, "o"); - else - strcpy(buf+i, "c"); - if (isfile(buf)) { - buf[save_len] = '\0'; - return 1; - } - buf[save_len] = '\0'; - return 0; -} -#endif /*RISCOS*/ - -#endif /* HAVE_STAT */ - - -static int init_builtin(char *); /* Forward */ - -/* Load an external module using the default search path and return - its module object WITH INCREMENTED REFERENCE COUNT */ - -static PyObject * -load_module(char *name, FILE *fp, char *buf, int type, PyObject *loader) -{ - PyObject *modules; - PyObject *m; - int err; - - /* First check that there's an open file (if we need one) */ - switch (type) { - case PY_SOURCE: - case PY_COMPILED: - if (fp == NULL) { - PyErr_Format(PyExc_ValueError, - "file object required for import (type code %d)", - type); - return NULL; - } - } - - switch (type) { - - case PY_SOURCE: - m = load_source_module(name, buf, fp); - break; - - case PY_COMPILED: - m = load_compiled_module(name, buf, fp); - break; - -#ifdef HAVE_DYNAMIC_LOADING - case C_EXTENSION: - m = _PyImport_LoadDynamicModule(name, buf, fp); - break; -#endif - -#ifdef macintosh - case PY_RESOURCE: - m = PyMac_LoadResourceModule(name, buf); - break; - case PY_CODERESOURCE: - m = PyMac_LoadCodeResourceModule(name, buf); - break; -#endif - - case PKG_DIRECTORY: - m = load_package(name, buf); - break; - - case C_BUILTIN: - case PY_FROZEN: - if (buf != NULL && buf[0] != '\0') - name = buf; - if (type == C_BUILTIN) - err = init_builtin(name); - else - err = PyImport_ImportFrozenModule(name); - if (err < 0) - return NULL; - if (err == 0) { - PyErr_Format(PyExc_ImportError, - "Purported %s module %.200s not found", - type == C_BUILTIN ? - "builtin" : "frozen", - name); - return NULL; - } - modules = PyImport_GetModuleDict(); - m = PyDict_GetItemString(modules, name); - if (m == NULL) { - PyErr_Format( - PyExc_ImportError, - "%s module %.200s not properly initialized", - type == C_BUILTIN ? - "builtin" : "frozen", - name); - return NULL; - } - Py_INCREF(m); - break; - - case IMP_HOOK: { - if (loader == NULL) { - PyErr_SetString(PyExc_ImportError, - "import hook without loader"); - return NULL; - } - m = PyObject_CallMethod(loader, "load_module", "s", name); - break; - } - - case PLASMA_PACKFILE: - m = load_plasmapacked_module(name, buf); - break; - - default: - PyErr_Format(PyExc_ImportError, - "Don't know how to import %.200s (type code %d)", - name, type); - m = NULL; - - } - - return m; -} - - -/* Initialize a built-in module. - Return 1 for succes, 0 if the module is not found, and -1 with - an exception set if the initialization failed. */ - -static int -init_builtin(char *name) -{ - struct _inittab *p; - - if (_PyImport_FindExtension(name, name) != NULL) - return 1; - - for (p = PyImport_Inittab; p->name != NULL; p++) { - if (strcmp(name, p->name) == 0) { - if (p->initfunc == NULL) { - PyErr_Format(PyExc_ImportError, - "Cannot re-init internal module %.200s", - name); - return -1; - } - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # builtin\n", name); - (*p->initfunc)(); - if (PyErr_Occurred()) - return -1; - if (_PyImport_FixupExtension(name, name) == NULL) - return -1; - return 1; - } - } - return 0; -} - - -/* Frozen modules */ - -static struct _frozen * -find_frozen(char *name) -{ - struct _frozen *p; - - for (p = PyImport_FrozenModules; ; p++) { - if (p->name == NULL) - return NULL; - if (strcmp(p->name, name) == 0) - break; - } - return p; -} - -static PyObject * -get_frozen_object(char *name) -{ - struct _frozen *p = find_frozen(name); - int size; - - if (p == NULL) { - PyErr_Format(PyExc_ImportError, - "No such frozen object named %.200s", - name); - return NULL; - } - if (p->code == NULL) { - PyErr_Format(PyExc_ImportError, - "Excluded frozen object named %.200s", - name); - return NULL; - } - size = p->size; - if (size < 0) - size = -size; - return PyMarshal_ReadObjectFromString((char *)p->code, size); -} - -/* Initialize a frozen module. - Return 1 for succes, 0 if the module is not found, and -1 with - an exception set if the initialization failed. - This function is also used from frozenmain.c */ - -int -PyImport_ImportFrozenModule(char *name) -{ - struct _frozen *p = find_frozen(name); - PyObject *co; - PyObject *m; - int ispackage; - int size; - - if (p == NULL) - return 0; - if (p->code == NULL) { - PyErr_Format(PyExc_ImportError, - "Excluded frozen object named %.200s", - name); - return -1; - } - size = p->size; - ispackage = (size < 0); - if (ispackage) - size = -size; - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # frozen%s\n", - name, ispackage ? " package" : ""); - co = PyMarshal_ReadObjectFromString((char *)p->code, size); - if (co == NULL) - return -1; - if (!PyCode_Check(co)) { - Py_DECREF(co); - PyErr_Format(PyExc_TypeError, - "frozen object %.200s is not a code object", - name); - return -1; - } - if (ispackage) { - /* Set __path__ to the package name */ - PyObject *d, *s; - int err; - m = PyImport_AddModule(name); - if (m == NULL) - return -1; - d = PyModule_GetDict(m); - s = PyString_InternFromString(name); - if (s == NULL) - return -1; - err = PyDict_SetItemString(d, "__path__", s); - Py_DECREF(s); - if (err != 0) - return err; - } - m = PyImport_ExecCodeModuleEx(name, co, ""); - Py_DECREF(co); - if (m == NULL) - return -1; - Py_DECREF(m); - return 1; -} - - -/* Import a module, either built-in, frozen, or external, and return - its module object WITH INCREMENTED REFERENCE COUNT */ - -PyObject * -PyImport_ImportModule(char *name) -{ - PyObject *pname; - PyObject *result; - - pname = PyString_FromString(name); - if (pname == NULL) - return NULL; - result = PyImport_Import(pname); - Py_DECREF(pname); - return result; -} - -/* Forward declarations for helper routines */ -static PyObject *get_parent(PyObject *globals, char *buf, int *p_buflen); -static PyObject *load_next(PyObject *mod, PyObject *altmod, - char **p_name, char *buf, int *p_buflen); -static int mark_miss(char *name); -static int ensure_fromlist(PyObject *mod, PyObject *fromlist, - char *buf, int buflen, int recursive); -static PyObject * import_submodule(PyObject *mod, char *name, char *fullname); - -/* The Magnum Opus of dotted-name import :-) */ - -static PyObject * -import_module_ex(char *name, PyObject *globals, PyObject *locals, - PyObject *fromlist) -{ - char buf[MAXPATHLEN+1]; - int buflen = 0; - PyObject *parent, *head, *next, *tail; - - parent = get_parent(globals, buf, &buflen); - if (parent == NULL) - return NULL; - - head = load_next(parent, Py_None, &name, buf, &buflen); - if (head == NULL) - return NULL; - - tail = head; - Py_INCREF(tail); - while (name) { - next = load_next(tail, tail, &name, buf, &buflen); - Py_DECREF(tail); - if (next == NULL) { - Py_DECREF(head); - return NULL; - } - tail = next; - } - - if (fromlist != NULL) { - if (fromlist == Py_None || !PyObject_IsTrue(fromlist)) - fromlist = NULL; - } - - if (fromlist == NULL) { - Py_DECREF(tail); - return head; - } - - Py_DECREF(head); - if (!ensure_fromlist(tail, fromlist, buf, buflen, 0)) { - Py_DECREF(tail); - return NULL; - } - - return tail; -} - -PyObject * -PyImport_ImportModuleEx(char *name, PyObject *globals, PyObject *locals, - PyObject *fromlist) -{ - PyObject *result; - lock_import(); - result = import_module_ex(name, globals, locals, fromlist); - if (unlock_import() < 0) { - Py_XDECREF(result); - PyErr_SetString(PyExc_RuntimeError, - "not holding the import lock"); - return NULL; - } - return result; -} - -static PyObject * -get_parent(PyObject *globals, char *buf, int *p_buflen) -{ - static PyObject *namestr = NULL; - static PyObject *pathstr = NULL; - PyObject *modname, *modpath, *modules, *parent; - - if (globals == NULL || !PyDict_Check(globals)) - return Py_None; - - if (namestr == NULL) { - namestr = PyString_InternFromString("__name__"); - if (namestr == NULL) - return NULL; - } - if (pathstr == NULL) { - pathstr = PyString_InternFromString("__path__"); - if (pathstr == NULL) - return NULL; - } - - *buf = '\0'; - *p_buflen = 0; - modname = PyDict_GetItem(globals, namestr); - if (modname == NULL || !PyString_Check(modname)) - return Py_None; - - modpath = PyDict_GetItem(globals, pathstr); - if (modpath != NULL) { - int len = PyString_GET_SIZE(modname); - if (len > MAXPATHLEN) { - PyErr_SetString(PyExc_ValueError, - "Module name too long"); - return NULL; - } - strcpy(buf, PyString_AS_STRING(modname)); - *p_buflen = len; - } - else { - char *start = PyString_AS_STRING(modname); - char *lastdot = strrchr(start, '.'); - size_t len; - if (lastdot == NULL) - return Py_None; - len = lastdot - start; - if (len >= MAXPATHLEN) { - PyErr_SetString(PyExc_ValueError, - "Module name too long"); - return NULL; - } - strncpy(buf, start, len); - buf[len] = '\0'; - *p_buflen = len; - } - - modules = PyImport_GetModuleDict(); - parent = PyDict_GetItemString(modules, buf); - if (parent == NULL) - parent = Py_None; - return parent; - /* We expect, but can't guarantee, if parent != None, that: - - parent.__name__ == buf - - parent.__dict__ is globals - If this is violated... Who cares? */ -} - -/* altmod is either None or same as mod */ -static PyObject * -load_next(PyObject *mod, PyObject *altmod, char **p_name, char *buf, - int *p_buflen) -{ - char *name = *p_name; - char *dot = strchr(name, '.'); - size_t len; - char *p; - PyObject *result; - - if (dot == NULL) { - *p_name = NULL; - len = strlen(name); - } - else { - *p_name = dot+1; - len = dot-name; - } - if (len == 0) { - PyErr_SetString(PyExc_ValueError, - "Empty module name"); - return NULL; - } - - p = buf + *p_buflen; - if (p != buf) - *p++ = '.'; - if (p+len-buf >= MAXPATHLEN) { - PyErr_SetString(PyExc_ValueError, - "Module name too long"); - return NULL; - } - strncpy(p, name, len); - p[len] = '\0'; - *p_buflen = p+len-buf; - - result = import_submodule(mod, p, buf); - if (result == Py_None && altmod != mod) { - Py_DECREF(result); - /* Here, altmod must be None and mod must not be None */ - result = import_submodule(altmod, p, p); - if (result != NULL && result != Py_None) { - if (mark_miss(buf) != 0) { - Py_DECREF(result); - return NULL; - } - strncpy(buf, name, len); - buf[len] = '\0'; - *p_buflen = len; - } - } - if (result == NULL) - return NULL; - - if (result == Py_None) { - Py_DECREF(result); - PyErr_Format(PyExc_ImportError, - "No module named %.200s", name); - return NULL; - } - - return result; -} - -static int -mark_miss(char *name) -{ - PyObject *modules = PyImport_GetModuleDict(); - return PyDict_SetItemString(modules, name, Py_None); -} - -static int -ensure_fromlist(PyObject *mod, PyObject *fromlist, char *buf, int buflen, - int recursive) -{ - int i; - - if (!PyObject_HasAttrString(mod, "__path__")) - return 1; - - for (i = 0; ; i++) { - PyObject *item = PySequence_GetItem(fromlist, i); - int hasit; - if (item == NULL) { - if (PyErr_ExceptionMatches(PyExc_IndexError)) { - PyErr_Clear(); - return 1; - } - return 0; - } - if (!PyString_Check(item)) { - PyErr_SetString(PyExc_TypeError, - "Item in ``from list'' not a string"); - Py_DECREF(item); - return 0; - } - if (PyString_AS_STRING(item)[0] == '*') { - PyObject *all; - Py_DECREF(item); - /* See if the package defines __all__ */ - if (recursive) - continue; /* Avoid endless recursion */ - all = PyObject_GetAttrString(mod, "__all__"); - if (all == NULL) - PyErr_Clear(); - else { - if (!ensure_fromlist(mod, all, buf, buflen, 1)) - return 0; - Py_DECREF(all); - } - continue; - } - hasit = PyObject_HasAttr(mod, item); - if (!hasit) { - char *subname = PyString_AS_STRING(item); - PyObject *submod; - char *p; - if (buflen + strlen(subname) >= MAXPATHLEN) { - PyErr_SetString(PyExc_ValueError, - "Module name too long"); - Py_DECREF(item); - return 0; - } - p = buf + buflen; - *p++ = '.'; - strcpy(p, subname); - submod = import_submodule(mod, subname, buf); - Py_XDECREF(submod); - if (submod == NULL) { - Py_DECREF(item); - return 0; - } - } - Py_DECREF(item); - } - - /* NOTREACHED */ -} - -static int -add_submodule(PyObject *mod, PyObject *submod, char *fullname, char *subname, - PyObject *modules) -{ - if (mod == Py_None) - return 1; - /* Irrespective of the success of this load, make a - reference to it in the parent package module. A copy gets - saved in the modules dictionary under the full name, so get a - reference from there, if need be. (The exception is when the - load failed with a SyntaxError -- then there's no trace in - sys.modules. In that case, of course, do nothing extra.) */ - if (submod == NULL) { - submod = PyDict_GetItemString(modules, fullname); - if (submod == NULL) - return 1; - } - if (PyModule_Check(mod)) { - /* We can't use setattr here since it can give a - * spurious warning if the submodule name shadows a - * builtin name */ - PyObject *dict = PyModule_GetDict(mod); - if (!dict) - return 0; - if (PyDict_SetItemString(dict, subname, submod) < 0) - return 0; - } - else { - if (PyObject_SetAttrString(mod, subname, submod) < 0) - return 0; - } - return 1; -} - -static PyObject * -import_submodule(PyObject *mod, char *subname, char *fullname) -{ - PyObject *modules = PyImport_GetModuleDict(); - PyObject *m = NULL; - - /* Require: - if mod == None: subname == fullname - else: mod.__name__ + "." + subname == fullname - */ - - if ((m = PyDict_GetItemString(modules, fullname)) != NULL) { - Py_INCREF(m); - } - else { - PyObject *path, *loader = NULL; - char buf[MAXPATHLEN+1]; - struct filedescr *fdp; - FILE *fp = NULL; - - if (mod == Py_None) - path = NULL; - else { - path = PyObject_GetAttrString(mod, "__path__"); - if (path == NULL) { - PyErr_Clear(); - Py_INCREF(Py_None); - return Py_None; - } - } - - buf[0] = '\0'; - fdp = find_module(fullname, subname, path, buf, MAXPATHLEN+1, - &fp, &loader); - Py_XDECREF(path); - if (fdp == NULL) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - return NULL; - PyErr_Clear(); - Py_INCREF(Py_None); - return Py_None; - } - m = load_module(fullname, fp, buf, fdp->type, loader); - Py_XDECREF(loader); - if (fp) - fclose(fp); - if (!add_submodule(mod, m, fullname, subname, modules)) { - Py_XDECREF(m); - m = NULL; - } - } - - return m; -} - - -/* Re-import a module of any kind and return its module object, WITH - INCREMENTED REFERENCE COUNT */ - -PyObject * -PyImport_ReloadModule(PyObject *m) -{ - PyObject *modules = PyImport_GetModuleDict(); - PyObject *path = NULL; - char *name, *subname; - char buf[MAXPATHLEN+1]; - struct filedescr *fdp; - FILE *fp = NULL; - - if (m == NULL || !PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, - "reload() argument must be module"); - return NULL; - } - name = PyModule_GetName(m); - if (name == NULL) - return NULL; - if (m != PyDict_GetItemString(modules, name)) { - PyErr_Format(PyExc_ImportError, - "reload(): module %.200s not in sys.modules", - name); - return NULL; - } - subname = strrchr(name, '.'); - if (subname == NULL) - subname = name; - else { - PyObject *parentname, *parent; - parentname = PyString_FromStringAndSize(name, (subname-name)); - if (parentname == NULL) - return NULL; - parent = PyDict_GetItem(modules, parentname); - Py_DECREF(parentname); - if (parent == NULL) { - PyErr_Format(PyExc_ImportError, - "reload(): parent %.200s not in sys.modules", - name); - return NULL; - } - subname++; - path = PyObject_GetAttrString(parent, "__path__"); - if (path == NULL) - PyErr_Clear(); - } - buf[0] = '\0'; - fdp = find_module(name, subname, path, buf, MAXPATHLEN+1, &fp, NULL); - Py_XDECREF(path); - if (fdp == NULL) - return NULL; - m = load_module(name, fp, buf, fdp->type, NULL); - if (fp) - fclose(fp); - return m; -} - - -/* Higher-level import emulator which emulates the "import" statement - more accurately -- it invokes the __import__() function from the - builtins of the current globals. This means that the import is - done using whatever import hooks are installed in the current - environment, e.g. by "rexec". - A dummy list ["__doc__"] is passed as the 4th argument so that - e.g. PyImport_Import(PyString_FromString("win32com.client.gencache")) - will return instead of . */ - -PyObject * -PyImport_Import(PyObject *module_name) -{ - static PyObject *silly_list = NULL; - static PyObject *builtins_str = NULL; - static PyObject *import_str = NULL; - PyObject *globals = NULL; - PyObject *import = NULL; - PyObject *builtins = NULL; - PyObject *r = NULL; - - /* Initialize constant string objects */ - if (silly_list == NULL) { - import_str = PyString_InternFromString("__import__"); - if (import_str == NULL) - return NULL; - builtins_str = PyString_InternFromString("__builtins__"); - if (builtins_str == NULL) - return NULL; - silly_list = Py_BuildValue("[s]", "__doc__"); - if (silly_list == NULL) - return NULL; - } - - /* Get the builtins from current globals */ - globals = PyEval_GetGlobals(); - if (globals != NULL) { - Py_INCREF(globals); - builtins = PyObject_GetItem(globals, builtins_str); - if (builtins == NULL) - goto err; - } - else { - /* No globals -- use standard builtins, and fake globals */ - PyErr_Clear(); - - builtins = PyImport_ImportModuleEx("__builtin__", - NULL, NULL, NULL); - if (builtins == NULL) - return NULL; - globals = Py_BuildValue("{OO}", builtins_str, builtins); - if (globals == NULL) - goto err; - } - - /* Get the __import__ function from the builtins */ - if (PyDict_Check(builtins)) { - import = PyObject_GetItem(builtins, import_str); - if (import == NULL) - PyErr_SetObject(PyExc_KeyError, import_str); - } - else - import = PyObject_GetAttr(builtins, import_str); - if (import == NULL) - goto err; - - /* Call the _import__ function with the proper argument list */ - r = PyObject_CallFunction(import, "OOOO", - module_name, globals, globals, silly_list); - - err: - Py_XDECREF(globals); - Py_XDECREF(builtins); - Py_XDECREF(import); - - return r; -} - - -/* Module 'imp' provides Python access to the primitives used for - importing modules. -*/ - -static PyObject * -imp_get_magic(PyObject *self, PyObject *noargs) -{ - char buf[4]; - - buf[0] = (char) ((pyc_magic >> 0) & 0xff); - buf[1] = (char) ((pyc_magic >> 8) & 0xff); - buf[2] = (char) ((pyc_magic >> 16) & 0xff); - buf[3] = (char) ((pyc_magic >> 24) & 0xff); - - return PyString_FromStringAndSize(buf, 4); -} - -static PyObject * -imp_get_suffixes(PyObject *self, PyObject *noargs) -{ - PyObject *list; - struct filedescr *fdp; - - list = PyList_New(0); - if (list == NULL) - return NULL; - for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) { - PyObject *item = Py_BuildValue("ssi", - fdp->suffix, fdp->mode, fdp->type); - if (item == NULL) { - Py_DECREF(list); - return NULL; - } - if (PyList_Append(list, item) < 0) { - Py_DECREF(list); - Py_DECREF(item); - return NULL; - } - Py_DECREF(item); - } - return list; -} - -static PyObject * -call_find_module(char *name, PyObject *path) -{ - extern int fclose(FILE *); - PyObject *fob, *ret; - struct filedescr *fdp; - char pathname[MAXPATHLEN+1]; - FILE *fp = NULL; - - pathname[0] = '\0'; - if (path == Py_None) - path = NULL; - fdp = find_module(NULL, name, path, pathname, MAXPATHLEN+1, &fp, NULL); - if (fdp == NULL) - return NULL; - if (fp != NULL) { - fob = PyFile_FromFile(fp, pathname, fdp->mode, fclose); - if (fob == NULL) { - fclose(fp); - return NULL; - } - } - else { - fob = Py_None; - Py_INCREF(fob); - } - ret = Py_BuildValue("Os(ssi)", - fob, pathname, fdp->suffix, fdp->mode, fdp->type); - Py_DECREF(fob); - return ret; -} - -static PyObject * -imp_find_module(PyObject *self, PyObject *args) -{ - char *name; - PyObject *path = NULL; - if (!PyArg_ParseTuple(args, "s|O:find_module", &name, &path)) - return NULL; - return call_find_module(name, path); -} - -static PyObject * -imp_init_builtin(PyObject *self, PyObject *args) -{ - char *name; - int ret; - PyObject *m; - if (!PyArg_ParseTuple(args, "s:init_builtin", &name)) - return NULL; - ret = init_builtin(name); - if (ret < 0) - return NULL; - if (ret == 0) { - Py_INCREF(Py_None); - return Py_None; - } - m = PyImport_AddModule(name); - Py_XINCREF(m); - return m; -} - -static PyObject * -imp_init_frozen(PyObject *self, PyObject *args) -{ - char *name; - int ret; - PyObject *m; - if (!PyArg_ParseTuple(args, "s:init_frozen", &name)) - return NULL; - ret = PyImport_ImportFrozenModule(name); - if (ret < 0) - return NULL; - if (ret == 0) { - Py_INCREF(Py_None); - return Py_None; - } - m = PyImport_AddModule(name); - Py_XINCREF(m); - return m; -} - -static PyObject * -imp_get_frozen_object(PyObject *self, PyObject *args) -{ - char *name; - - if (!PyArg_ParseTuple(args, "s:get_frozen_object", &name)) - return NULL; - return get_frozen_object(name); -} - -static PyObject * -imp_is_builtin(PyObject *self, PyObject *args) -{ - char *name; - if (!PyArg_ParseTuple(args, "s:is_builtin", &name)) - return NULL; - return PyInt_FromLong(is_builtin(name)); -} - -static PyObject * -imp_is_frozen(PyObject *self, PyObject *args) -{ - char *name; - struct _frozen *p; - if (!PyArg_ParseTuple(args, "s:is_frozen", &name)) - return NULL; - p = find_frozen(name); - return PyBool_FromLong((long) (p == NULL ? 0 : p->size)); -} - -static FILE * -get_file(char *pathname, PyObject *fob, char *mode) -{ - FILE *fp; - if (fob == NULL) { - if (mode[0] == 'U') - mode = "r" PY_STDIOTEXTMODE; - fp = fopen(pathname, mode); - if (fp == NULL) - PyErr_SetFromErrno(PyExc_IOError); - } - else { - fp = PyFile_AsFile(fob); - if (fp == NULL) - PyErr_SetString(PyExc_ValueError, - "bad/closed file object"); - } - return fp; -} - -static PyObject * -imp_load_compiled(PyObject *self, PyObject *args) -{ - char *name; - char *pathname; - PyObject *fob = NULL; - PyObject *m; - FILE *fp; - if (!PyArg_ParseTuple(args, "ss|O!:load_compiled", &name, &pathname, - &PyFile_Type, &fob)) - return NULL; - fp = get_file(pathname, fob, "rb"); - if (fp == NULL) - return NULL; - m = load_compiled_module(name, pathname, fp); - if (fob == NULL) - fclose(fp); - return m; -} - -#ifdef HAVE_DYNAMIC_LOADING - -static PyObject * -imp_load_dynamic(PyObject *self, PyObject *args) -{ - char *name; - char *pathname; - PyObject *fob = NULL; - PyObject *m; - FILE *fp = NULL; - if (!PyArg_ParseTuple(args, "ss|O!:load_dynamic", &name, &pathname, - &PyFile_Type, &fob)) - return NULL; - if (fob) { - fp = get_file(pathname, fob, "r"); - if (fp == NULL) - return NULL; - } - m = _PyImport_LoadDynamicModule(name, pathname, fp); - return m; -} - -#endif /* HAVE_DYNAMIC_LOADING */ - -static PyObject * -imp_load_source(PyObject *self, PyObject *args) -{ - char *name; - char *pathname; - PyObject *fob = NULL; - PyObject *m; - FILE *fp; - if (!PyArg_ParseTuple(args, "ss|O!:load_source", &name, &pathname, - &PyFile_Type, &fob)) - return NULL; - fp = get_file(pathname, fob, "r"); - if (fp == NULL) - return NULL; - m = load_source_module(name, pathname, fp); - if (fob == NULL) - fclose(fp); - return m; -} - -#ifdef macintosh -static PyObject * -imp_load_resource(PyObject *self, PyObject *args) -{ - char *name; - char *pathname; - PyObject *m; - - if (!PyArg_ParseTuple(args, "ss:load_resource", &name, &pathname)) - return NULL; - m = PyMac_LoadResourceModule(name, pathname); - return m; -} -#endif /* macintosh */ - -static PyObject * -imp_load_module(PyObject *self, PyObject *args) -{ - char *name; - PyObject *fob; - char *pathname; - char *suffix; /* Unused */ - char *mode; - int type; - FILE *fp; - - if (!PyArg_ParseTuple(args, "sOs(ssi):load_module", - &name, &fob, &pathname, - &suffix, &mode, &type)) - return NULL; - if (*mode) { - /* Mode must start with 'r' or 'U' and must not contain '+'. - Implicit in this test is the assumption that the mode - may contain other modifiers like 'b' or 't'. */ - - if (!(*mode == 'r' || *mode == 'U') || strchr(mode, '+')) { - PyErr_Format(PyExc_ValueError, - "invalid file open mode %.200s", mode); - return NULL; - } - } - if (fob == Py_None) - fp = NULL; - else { - if (!PyFile_Check(fob)) { - PyErr_SetString(PyExc_ValueError, - "load_module arg#2 should be a file or None"); - return NULL; - } - fp = get_file(pathname, fob, mode); - if (fp == NULL) - return NULL; - } - return load_module(name, fp, pathname, type, NULL); -} - -static PyObject * -imp_load_package(PyObject *self, PyObject *args) -{ - char *name; - char *pathname; - if (!PyArg_ParseTuple(args, "ss:load_package", &name, &pathname)) - return NULL; - return load_package(name, pathname); -} - -static PyObject * -imp_new_module(PyObject *self, PyObject *args) -{ - char *name; - if (!PyArg_ParseTuple(args, "s:new_module", &name)) - return NULL; - return PyModule_New(name); -} - -/* Doc strings */ - -PyDoc_STRVAR(doc_imp, -"This module provides the components needed to build your own\n\ -__import__ function. Undocumented functions are obsolete."); - -PyDoc_STRVAR(doc_find_module, -"find_module(name, [path]) -> (file, filename, (suffix, mode, type))\n\ -Search for a module. If path is omitted or None, search for a\n\ -built-in, frozen or special module and continue search in sys.path.\n\ -The module name cannot contain '.'; to search for a submodule of a\n\ -package, pass the submodule name and the package's __path__."); - -PyDoc_STRVAR(doc_load_module, -"load_module(name, file, filename, (suffix, mode, type)) -> module\n\ -Load a module, given information returned by find_module().\n\ -The module name must include the full package name, if any."); - -PyDoc_STRVAR(doc_get_magic, -"get_magic() -> string\n\ -Return the magic number for .pyc or .pyo files."); - -PyDoc_STRVAR(doc_get_suffixes, -"get_suffixes() -> [(suffix, mode, type), ...]\n\ -Return a list of (suffix, mode, type) tuples describing the files\n\ -that find_module() looks for."); - -PyDoc_STRVAR(doc_new_module, -"new_module(name) -> module\n\ -Create a new module. Do not enter it in sys.modules.\n\ -The module name must include the full package name, if any."); - -PyDoc_STRVAR(doc_lock_held, -"lock_held() -> 0 or 1\n\ -Return 1 if the import lock is currently held.\n\ -On platforms without threads, return 0."); - -PyDoc_STRVAR(doc_acquire_lock, -"acquire_lock() -> None\n\ -Acquires the interpreter's import lock for the current thread.\n\ -This lock should be used by import hooks to ensure thread-safety\n\ -when importing modules.\n\ -On platforms without threads, this function does nothing."); - -PyDoc_STRVAR(doc_release_lock, -"release_lock() -> None\n\ -Release the interpreter's import lock.\n\ -On platforms without threads, this function does nothing."); - -static PyMethodDef imp_methods[] = { - {"find_module", imp_find_module, METH_VARARGS, doc_find_module}, - {"get_magic", imp_get_magic, METH_NOARGS, doc_get_magic}, - {"get_suffixes", imp_get_suffixes, METH_NOARGS, doc_get_suffixes}, - {"load_module", imp_load_module, METH_VARARGS, doc_load_module}, - {"new_module", imp_new_module, METH_VARARGS, doc_new_module}, - {"lock_held", imp_lock_held, METH_NOARGS, doc_lock_held}, - {"acquire_lock", imp_acquire_lock, METH_NOARGS, doc_acquire_lock}, - {"release_lock", imp_release_lock, METH_NOARGS, doc_release_lock}, - /* The rest are obsolete */ - {"get_frozen_object", imp_get_frozen_object, METH_VARARGS}, - {"init_builtin", imp_init_builtin, METH_VARARGS}, - {"init_frozen", imp_init_frozen, METH_VARARGS}, - {"is_builtin", imp_is_builtin, METH_VARARGS}, - {"is_frozen", imp_is_frozen, METH_VARARGS}, - {"load_compiled", imp_load_compiled, METH_VARARGS}, -#ifdef HAVE_DYNAMIC_LOADING - {"load_dynamic", imp_load_dynamic, METH_VARARGS}, -#endif - {"load_package", imp_load_package, METH_VARARGS}, -#ifdef macintosh - {"load_resource", imp_load_resource, METH_VARARGS}, -#endif - {"load_source", imp_load_source, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - -static int -setint(PyObject *d, char *name, int value) -{ - PyObject *v; - int err; - - v = PyInt_FromLong((long)value); - err = PyDict_SetItemString(d, name, v); - Py_XDECREF(v); - return err; -} - -void -initimp(void) -{ - PyObject *m, *d; - - m = Py_InitModule4("imp", imp_methods, doc_imp, - NULL, PYTHON_API_VERSION); - d = PyModule_GetDict(m); - - if (setint(d, "SEARCH_ERROR", SEARCH_ERROR) < 0) goto failure; - if (setint(d, "PY_SOURCE", PY_SOURCE) < 0) goto failure; - if (setint(d, "PY_COMPILED", PY_COMPILED) < 0) goto failure; - if (setint(d, "C_EXTENSION", C_EXTENSION) < 0) goto failure; - if (setint(d, "PY_RESOURCE", PY_RESOURCE) < 0) goto failure; - if (setint(d, "PKG_DIRECTORY", PKG_DIRECTORY) < 0) goto failure; - if (setint(d, "C_BUILTIN", C_BUILTIN) < 0) goto failure; - if (setint(d, "PY_FROZEN", PY_FROZEN) < 0) goto failure; - if (setint(d, "PY_CODERESOURCE", PY_CODERESOURCE) < 0) goto failure; - if (setint(d, "IMP_HOOK", IMP_HOOK) < 0) goto failure; - if (setint(d, "PLASMA_PACKFILE", PLASMA_PACKFILE) < 0) goto failure; - - failure: - ; -} - - -/* API for embedding applications that want to add their own entries - to the table of built-in modules. This should normally be called - *before* Py_Initialize(). When the table resize fails, -1 is - returned and the existing table is unchanged. - - After a similar function by Just van Rossum. */ - -int -PyImport_ExtendInittab(struct _inittab *newtab) -{ - static struct _inittab *our_copy = NULL; - struct _inittab *p; - int i, n; - - /* Count the number of entries in both tables */ - for (n = 0; newtab[n].name != NULL; n++) - ; - if (n == 0) - return 0; /* Nothing to do */ - for (i = 0; PyImport_Inittab[i].name != NULL; i++) - ; - - /* Allocate new memory for the combined table */ - p = our_copy; - PyMem_RESIZE(p, struct _inittab, i+n+1); - if (p == NULL) - return -1; - - /* Copy the tables into the new memory */ - if (our_copy != PyImport_Inittab) - memcpy(p, PyImport_Inittab, (i+1) * sizeof(struct _inittab)); - PyImport_Inittab = our_copy = p; - memcpy(p+i, newtab, (n+1) * sizeof(struct _inittab)); - - return 0; -} - -/* Shorthand to add a single entry given a name and a function */ - -int -PyImport_AppendInittab(char *name, void (*initfunc)(void)) -{ - struct _inittab newtab[2]; - - memset(newtab, '\0', sizeof newtab); - - newtab[0].name = name; - newtab[0].initfunc = initfunc; - - return PyImport_ExtendInittab(newtab); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/importdl.c b/SDKs/XPlatform/Cypython-2.3.3/Python/importdl.c deleted file mode 100644 index 5784a1c1..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/importdl.c +++ /dev/null @@ -1,78 +0,0 @@ - -/* Support for dynamic loading of extension modules */ - -#include "Python.h" - -/* ./configure sets HAVE_DYNAMIC_LOADING if dynamic loading of modules is - supported on this platform. configure will then compile and link in one - of the dynload_*.c files, as appropriate. We will call a function in - those modules to get a function pointer to the module's init function. -*/ -#ifdef HAVE_DYNAMIC_LOADING - -#include "importdl.h" - -extern dl_funcptr _PyImport_GetDynLoadFunc(const char *name, - const char *shortname, - const char *pathname, FILE *fp); - - - -PyObject * -_PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp) -{ - PyObject *m; - char *lastdot, *shortname, *packagecontext, *oldcontext; - dl_funcptr p; - - if ((m = _PyImport_FindExtension(name, pathname)) != NULL) { - Py_INCREF(m); - return m; - } - lastdot = strrchr(name, '.'); - if (lastdot == NULL) { - packagecontext = NULL; - shortname = name; - } - else { - packagecontext = name; - shortname = lastdot+1; - } - - p = _PyImport_GetDynLoadFunc(name, shortname, pathname, fp); - if (PyErr_Occurred()) - return NULL; - if (p == NULL) { - PyErr_Format(PyExc_ImportError, - "dynamic module does not define init function (init%.200s)", - shortname); - return NULL; - } - oldcontext = _Py_PackageContext; - _Py_PackageContext = packagecontext; - (*p)(); - _Py_PackageContext = oldcontext; - if (PyErr_Occurred()) - return NULL; - - m = PyDict_GetItemString(PyImport_GetModuleDict(), name); - if (m == NULL) { - PyErr_SetString(PyExc_SystemError, - "dynamic module not initialized properly"); - return NULL; - } - /* Remember the filename as the __file__ attribute */ - if (PyModule_AddStringConstant(m, "__file__", pathname) < 0) - PyErr_Clear(); /* Not important enough to report */ - - if (_PyImport_FixupExtension(name, pathname) == NULL) - return NULL; - if (Py_VerboseFlag) - PySys_WriteStderr( - "import %s # dynamically loaded from %s\n", - name, pathname); - Py_INCREF(m); - return m; -} - -#endif /* HAVE_DYNAMIC_LOADING */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/importdl.h b/SDKs/XPlatform/Cypython-2.3.3/Python/importdl.h deleted file mode 100644 index b2c2ea78..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/importdl.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef Py_IMPORTDL_H -#define Py_IMPORTDL_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Definitions for dynamic loading of extension modules */ -enum filetype { - SEARCH_ERROR, - PY_SOURCE, - PY_COMPILED, - C_EXTENSION, - PY_RESOURCE, /* Mac only */ - PKG_DIRECTORY, - C_BUILTIN, - PY_FROZEN, - PY_CODERESOURCE, /* Mac only */ - IMP_HOOK, - PLASMA_PACKFILE -}; - -struct filedescr { - char *suffix; - char *mode; - enum filetype type; -}; -extern struct filedescr * _PyImport_Filetab; -extern const struct filedescr _PyImport_DynLoadFiletab[]; - -extern PyObject *_PyImport_LoadDynamicModule(char *name, char *pathname, - FILE *); - -/* Max length of module suffix searched for -- accommodates "module.slb" */ -#define MAXSUFFIXSIZE 12 - -#if defined(MS_WINDOWS) && !defined(MS_XBOX) -#include -typedef FARPROC dl_funcptr; -#else -#if defined(PYOS_OS2) && !defined(PYCC_GCC) -#include -typedef int (* APIENTRY dl_funcptr)(); -#else -typedef void (*dl_funcptr)(void); -#endif -#endif - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_IMPORTDL_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/mactoolboxglue.c b/SDKs/XPlatform/Cypython-2.3.3/Python/mactoolboxglue.c deleted file mode 100644 index 2965bc25..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/mactoolboxglue.c +++ /dev/null @@ -1,621 +0,0 @@ -/*********************************************************** -Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - - -#include "Python.h" -#include "pymactoolbox.h" - -#ifdef WITHOUT_FRAMEWORKS -#include -#include -#endif - -/* -** Find out what the current script is. -** Donated by Fredrik Lund. -*/ -char *PyMac_getscript() -{ -#if TARGET_API_MAC_OSX - CFStringEncoding enc = CFStringGetSystemEncoding(); - static CFStringRef name = NULL; - /* Return the code name for the encodings for which we have codecs. */ - switch(enc) { - case kCFStringEncodingMacRoman: return "mac-roman"; - case kCFStringEncodingMacGreek: return "mac-greek"; - case kCFStringEncodingMacCyrillic: return "mac-cyrillic"; - case kCFStringEncodingMacTurkish: return "mac-turkish"; - case kCFStringEncodingMacIcelandic: return "mac-icelandic"; - /* XXX which one is mac-latin2? */ - } - if (!name) { - /* This leaks a an object. */ - name = CFStringConvertEncodingToIANACharSetName(enc); - } - return (char *)CFStringGetCStringPtr(name, 0); -#else - int font, script, lang; - font = 0; - font = GetSysFont(); - script = FontToScript(font); - switch (script) { - case smRoman: - lang = GetScriptVariable(script, smScriptLang); - if (lang == langIcelandic) - return "mac-iceland"; - else if (lang == langTurkish) - return "mac-turkish"; - else if (lang == langGreek) - return "mac-greek"; - else - return "mac-roman"; - break; -#if 0 - /* We don't have a codec for this, so don't return it */ - case smJapanese: - return "mac-japan"; -#endif - case smGreek: - return "mac-greek"; - case smCyrillic: - return "mac-cyrillic"; - default: - return "ascii"; /* better than nothing */ - } -#endif /* TARGET_API_MAC_OSX */ -} - -/* Like strerror() but for Mac OS error numbers */ -char *PyMac_StrError(int err) -{ - static char buf[256]; - Handle h; - char *str; - static int errors_loaded; - - h = GetResource('Estr', err); - if (!h && !errors_loaded) { - /* - ** Attempt to open the resource file containing the - ** Estr resources. We ignore all errors. We also try - ** this only once. - */ - PyObject *m, *rv; - errors_loaded = 1; - - m = PyImport_ImportModule("macresource"); - if (!m) { - if (Py_VerboseFlag) - PyErr_Print(); - PyErr_Clear(); - } else { - rv = PyObject_CallMethod(m, "open_error_resource", ""); - if (!rv) { - if (Py_VerboseFlag) - PyErr_Print(); - PyErr_Clear(); - } else { - Py_DECREF(rv); - /* And try again... */ - h = GetResource('Estr', err); - } - } - } - /* - ** Whether the code above succeeded or not, we won't try - ** again. - */ - errors_loaded = 1; - - if ( h ) { - HLock(h); - str = (char *)*h; - memcpy(buf, str+1, (unsigned char)str[0]); - buf[(unsigned char)str[0]] = '\0'; - HUnlock(h); - ReleaseResource(h); - } else { - PyOS_snprintf(buf, sizeof(buf), "Mac OS error code %d", err); - } - return buf; -} - -/* Exception object shared by all Mac specific modules for Mac OS errors */ -PyObject *PyMac_OSErrException; - -/* Initialize and return PyMac_OSErrException */ -PyObject * -PyMac_GetOSErrException(void) -{ - if (PyMac_OSErrException == NULL) - PyMac_OSErrException = PyErr_NewException("MacOS.Error", NULL, NULL); - return PyMac_OSErrException; -} - -/* Set a MAC-specific error from errno, and return NULL; return None if no error */ -PyObject * -PyErr_Mac(PyObject *eobj, int err) -{ - char *msg; - PyObject *v; - - if (err == 0 && !PyErr_Occurred()) { - Py_INCREF(Py_None); - return Py_None; - } - if (err == -1 && PyErr_Occurred()) - return NULL; - msg = PyMac_StrError(err); - v = Py_BuildValue("(is)", err, msg); - PyErr_SetObject(eobj, v); - Py_DECREF(v); - return NULL; -} - -/* Call PyErr_Mac with PyMac_OSErrException */ -PyObject * -PyMac_Error(OSErr err) -{ - return PyErr_Mac(PyMac_GetOSErrException(), err); -} - - -#if TARGET_API_MAC_OSX -OSErr -PyMac_GetFullPathname(FSSpec *fss, char *path, int len) -{ - FSRef fsr; - OSErr err; - - *path = '\0'; - err = FSpMakeFSRef(fss, &fsr); - if ( err == fnfErr ) { - /* FSSpecs can point to non-existing files, fsrefs can't. */ - FSSpec fss2; - int tocopy; - - err = FSMakeFSSpec(fss->vRefNum, fss->parID, "", &fss2); - if ( err ) return err; - err = FSpMakeFSRef(&fss2, &fsr); - if ( err ) return err; - err = (OSErr)FSRefMakePath(&fsr, path, len-1); - if ( err ) return err; - /* This part is not 100% safe: we append the filename part, but - ** I'm not sure that we don't run afoul of the various 8bit - ** encodings here. Will have to look this up at some point... - */ - strcat(path, "/"); - tocopy = fss->name[0]; - if ( strlen(path) + tocopy >= len ) - tocopy = len - strlen(path) - 1; - if ( tocopy > 0 ) - strncat(path, fss->name+1, tocopy); - } else { - if ( err ) return err; - err = (OSErr)FSRefMakePath(&fsr, path, len); - if ( err ) return err; - } - return 0; -} - -#endif /* TARGET_API_MAC_OSX */ - -#ifdef WITH_NEXT_FRAMEWORK -/* -** In a bundle, find a file "resourceName" of type "resourceType". Return the -** full pathname in "resourceURLCstr". -*/ -static int -locateResourcePy(CFStringRef resourceType, CFStringRef resourceName, char *resourceURLCStr, int length) -{ - CFBundleRef mainBundle = NULL; - CFURLRef URL, absoluteURL; - CFStringRef filenameString, filepathString; - CFIndex size, i; - CFArrayRef arrayRef = NULL; - int success = 0; - -#if TARGET_API_MAC_OSX - CFURLPathStyle thePathStyle = kCFURLPOSIXPathStyle; -#else - CFURLPathStyle thePathStyle = kCFURLHFSPathStyle; -#endif - - /* Get a reference to our main bundle */ - mainBundle = CFBundleGetMainBundle(); - - /* If we are running inside a bundle, look through it. Otherwise, do nothing. */ - if (mainBundle) { - - /* Look for py files in the main bundle by type */ - arrayRef = CFBundleCopyResourceURLsOfType( mainBundle, - resourceType, - NULL ); - - /* See if there are any filename matches */ - size = CFArrayGetCount(arrayRef); - for (i = 0; i < size; i++) { - URL = CFArrayGetValueAtIndex(arrayRef, i); - filenameString = CFURLCopyLastPathComponent(URL); - if (CFStringCompare(filenameString, resourceName, 0) == kCFCompareEqualTo) { - /* We found a match, get the file's full path */ - absoluteURL = CFURLCopyAbsoluteURL(URL); - filepathString = CFURLCopyFileSystemPath(absoluteURL, thePathStyle); - CFRelease(absoluteURL); - - /* Copy the full path into the caller's character buffer */ - success = CFStringGetCString(filepathString, resourceURLCStr, length, - kCFStringEncodingMacRoman); - - CFRelease(filepathString); - } - CFRelease(filenameString); - } - CFRelease(arrayRef); - } - return success; -} - -/* -** iff we are running in a .app framework then we could be -** the main program for an applet. In that case, return the -** script filename for the applet. -** Otherwise return NULL. -*/ -char * -PyMac_GetAppletScriptFile(void) -{ - static char scriptpath[1024]; - - /* First we see whether we have __rawmain__.py and run that if it - ** is there. This is used for applets that want sys.argv to be - ** unix-like: __rawmain__ will construct it (from the initial appleevent) - ** and then call __main__.py. - */ - if (locateResourcePy(CFSTR("py"), CFSTR("__rawmain__.py"), scriptpath, 1024)) { - return scriptpath; - } else if (locateResourcePy(CFSTR("pyc"), CFSTR("__rawmain__.pyc"), scriptpath, 1024)) { - return scriptpath; - } else if (locateResourcePy(CFSTR("py"), CFSTR("__main__.py"), scriptpath, 1024)) { - return scriptpath; - } else if (locateResourcePy(CFSTR("pyc"), CFSTR("__main__.pyc"), scriptpath, 1024)) { - return scriptpath; - } - return NULL; -} - -#endif - - -/* Convert a 4-char string object argument to an OSType value */ -int -PyMac_GetOSType(PyObject *v, OSType *pr) -{ - if (!PyString_Check(v) || PyString_Size(v) != 4) { - PyErr_SetString(PyExc_TypeError, - "OSType arg must be string of 4 chars"); - return 0; - } - memcpy((char *)pr, PyString_AsString(v), 4); - return 1; -} - -/* Convert an OSType value to a 4-char string object */ -PyObject * -PyMac_BuildOSType(OSType t) -{ - return PyString_FromStringAndSize((char *)&t, 4); -} - -/* Convert an NumVersion value to a 4-element tuple */ -PyObject * -PyMac_BuildNumVersion(NumVersion t) -{ - return Py_BuildValue("(hhhh)", t.majorRev, t.minorAndBugRev, t.stage, t.nonRelRev); -} - - -/* Convert a Python string object to a Str255 */ -int -PyMac_GetStr255(PyObject *v, Str255 pbuf) -{ - int len; - if (!PyString_Check(v) || (len = PyString_Size(v)) > 255) { - PyErr_SetString(PyExc_TypeError, - "Str255 arg must be string of at most 255 chars"); - return 0; - } - pbuf[0] = len; - memcpy((char *)(pbuf+1), PyString_AsString(v), len); - return 1; -} - -/* Convert a Str255 to a Python string object */ -PyObject * -PyMac_BuildStr255(Str255 s) -{ - if ( s == NULL ) { - PyErr_SetString(PyExc_SystemError, "Str255 pointer is NULL"); - return NULL; - } - return PyString_FromStringAndSize((char *)&s[1], (int)s[0]); -} - -PyObject * -PyMac_BuildOptStr255(Str255 s) -{ - if ( s == NULL ) { - Py_INCREF(Py_None); - return Py_None; - } - return PyString_FromStringAndSize((char *)&s[1], (int)s[0]); -} - - - -/* Convert a Python object to a Rect. - The object must be a (left, top, right, bottom) tuple. - (This differs from the order in the struct but is consistent with - the arguments to SetRect(), and also with STDWIN). */ -int -PyMac_GetRect(PyObject *v, Rect *r) -{ - return PyArg_Parse(v, "(hhhh)", &r->left, &r->top, &r->right, &r->bottom); -} - -/* Convert a Rect to a Python object */ -PyObject * -PyMac_BuildRect(Rect *r) -{ - return Py_BuildValue("(hhhh)", r->left, r->top, r->right, r->bottom); -} - - -/* Convert a Python object to a Point. - The object must be a (h, v) tuple. - (This differs from the order in the struct but is consistent with - the arguments to SetPoint(), and also with STDWIN). */ -int -PyMac_GetPoint(PyObject *v, Point *p) -{ - return PyArg_Parse(v, "(hh)", &p->h, &p->v); -} - -/* Convert a Point to a Python object */ -PyObject * -PyMac_BuildPoint(Point p) -{ - return Py_BuildValue("(hh)", p.h, p.v); -} - - -/* Convert a Python object to an EventRecord. - The object must be a (what, message, when, (v, h), modifiers) tuple. */ -int -PyMac_GetEventRecord(PyObject *v, EventRecord *e) -{ - return PyArg_Parse(v, "(Hkk(hh)H)", - &e->what, - &e->message, - &e->when, - &e->where.h, - &e->where.v, - &e->modifiers); -} - -/* Convert a Rect to an EventRecord object */ -PyObject * -PyMac_BuildEventRecord(EventRecord *e) -{ - return Py_BuildValue("(hll(hh)h)", - e->what, - e->message, - e->when, - e->where.h, - e->where.v, - e->modifiers); -} - -/* Convert Python object to Fixed */ -int -PyMac_GetFixed(PyObject *v, Fixed *f) -{ - double d; - - if( !PyArg_Parse(v, "d", &d)) - return 0; - *f = (Fixed)(d * 0x10000); - return 1; -} - -/* Convert a Fixed to a Python object */ -PyObject * -PyMac_BuildFixed(Fixed f) -{ - double d; - - d = f; - d = d / 0x10000; - return Py_BuildValue("d", d); -} - -/* Convert wide to/from Python int or (hi, lo) tuple. XXXX Should use Python longs */ -int -PyMac_Getwide(PyObject *v, wide *rv) -{ - if (PyInt_Check(v)) { - rv->hi = 0; - rv->lo = PyInt_AsLong(v); - if( rv->lo & 0x80000000 ) - rv->hi = -1; - return 1; - } - return PyArg_Parse(v, "(kk)", &rv->hi, &rv->lo); -} - - -PyObject * -PyMac_Buildwide(wide *w) -{ - if ( (w->hi == 0 && (w->lo & 0x80000000) == 0) || - (w->hi == -1 && (w->lo & 0x80000000) ) ) - return PyInt_FromLong(w->lo); - return Py_BuildValue("(ll)", w->hi, w->lo); -} - -#ifdef USE_TOOLBOX_OBJECT_GLUE -/* -** Glue together the toolbox objects. -** -** Because toolbox modules interdepend on each other, they use each others -** object types, on MacOSX/MachO this leads to the situation that they -** cannot be dynamically loaded (or they would all have to be lumped into -** a single .so, but this would be bad for extensibility). -** -** This file defines wrappers for all the _New and _Convert functions, -** which are the Py_BuildValue and PyArg_ParseTuple helpers. The wrappers -** check an indirection function pointer, and if it isn't filled in yet -** they import the appropriate module, whose init routine should fill in -** the pointer. -*/ - -#define GLUE_NEW(object, routinename, module) \ -PyObject *(*PyMacGluePtr_##routinename)(object); \ -\ -PyObject *routinename(object cobj) { \ - if (!PyMacGluePtr_##routinename) { \ - if (!PyImport_ImportModule(module)) return NULL; \ - if (!PyMacGluePtr_##routinename) { \ - PyErr_SetString(PyExc_ImportError, "Module did not provide routine: " module ": " #routinename); \ - return NULL; \ - } \ - } \ - return (*PyMacGluePtr_##routinename)(cobj); \ -} - -#define GLUE_CONVERT(object, routinename, module) \ -int (*PyMacGluePtr_##routinename)(PyObject *, object *); \ -\ -int routinename(PyObject *pyobj, object *cobj) { \ - if (!PyMacGluePtr_##routinename) { \ - if (!PyImport_ImportModule(module)) return NULL; \ - if (!PyMacGluePtr_##routinename) { \ - PyErr_SetString(PyExc_ImportError, "Module did not provide routine: " module ": " #routinename); \ - return NULL; \ - } \ - } \ - return (*PyMacGluePtr_##routinename)(pyobj, cobj); \ -} - -GLUE_NEW(FSSpec *, PyMac_BuildFSSpec, "Carbon.File") -GLUE_CONVERT(FSSpec, PyMac_GetFSSpec, "Carbon.File") -GLUE_NEW(FSRef *, PyMac_BuildFSRef, "Carbon.File") -GLUE_CONVERT(FSRef, PyMac_GetFSRef, "Carbon.File") - -GLUE_NEW(AppleEvent *, AEDesc_New, "Carbon.AE") /* XXXX Why by address? */ -GLUE_NEW(AppleEvent *, AEDesc_NewBorrowed, "Carbon.AE") -GLUE_CONVERT(AppleEvent, AEDesc_Convert, "Carbon.AE") - -GLUE_NEW(Component, CmpObj_New, "Carbon.Cm") -GLUE_CONVERT(Component, CmpObj_Convert, "Carbon.Cm") -GLUE_NEW(ComponentInstance, CmpInstObj_New, "Carbon.Cm") -GLUE_CONVERT(ComponentInstance, CmpInstObj_Convert, "Carbon.Cm") - -GLUE_NEW(ControlHandle, CtlObj_New, "Carbon.Ctl") -GLUE_CONVERT(ControlHandle, CtlObj_Convert, "Carbon.Ctl") - -GLUE_NEW(DialogPtr, DlgObj_New, "Carbon.Dlg") -GLUE_CONVERT(DialogPtr, DlgObj_Convert, "Carbon.Dlg") -GLUE_NEW(DialogPtr, DlgObj_WhichDialog, "Carbon.Dlg") - -GLUE_NEW(DragReference, DragObj_New, "Carbon.Drag") -GLUE_CONVERT(DragReference, DragObj_Convert, "Carbon.Drag") - -GLUE_NEW(ListHandle, ListObj_New, "Carbon.List") -GLUE_CONVERT(ListHandle, ListObj_Convert, "Carbon.List") - -GLUE_NEW(MenuHandle, MenuObj_New, "Carbon.Menu") -GLUE_CONVERT(MenuHandle, MenuObj_Convert, "Carbon.Menu") - -GLUE_NEW(GrafPtr, GrafObj_New, "Carbon.Qd") -GLUE_CONVERT(GrafPtr, GrafObj_Convert, "Carbon.Qd") -GLUE_NEW(BitMapPtr, BMObj_New, "Carbon.Qd") -GLUE_CONVERT(BitMapPtr, BMObj_Convert, "Carbon.Qd") -GLUE_NEW(RGBColor *, QdRGB_New, "Carbon.Qd") /* XXXX Why? */ -GLUE_CONVERT(RGBColor, QdRGB_Convert, "Carbon.Qd") - -GLUE_NEW(GWorldPtr, GWorldObj_New, "Carbon.Qdoffs") -GLUE_CONVERT(GWorldPtr, GWorldObj_Convert, "Carbon.Qdoffs") - -GLUE_NEW(Track, TrackObj_New, "Carbon.Qt") -GLUE_CONVERT(Track, TrackObj_Convert, "Carbon.Qt") -GLUE_NEW(Movie, MovieObj_New, "Carbon.Qt") -GLUE_CONVERT(Movie, MovieObj_Convert, "Carbon.Qt") -GLUE_NEW(MovieController, MovieCtlObj_New, "Carbon.Qt") -GLUE_CONVERT(MovieController, MovieCtlObj_Convert, "Carbon.Qt") -GLUE_NEW(TimeBase, TimeBaseObj_New, "Carbon.Qt") -GLUE_CONVERT(TimeBase, TimeBaseObj_Convert, "Carbon.Qt") -GLUE_NEW(UserData, UserDataObj_New, "Carbon.Qt") -GLUE_CONVERT(UserData, UserDataObj_Convert, "Carbon.Qt") -GLUE_NEW(Media, MediaObj_New, "Carbon.Qt") -GLUE_CONVERT(Media, MediaObj_Convert, "Carbon.Qt") - -GLUE_NEW(Handle, ResObj_New, "Carbon.Res") -GLUE_CONVERT(Handle, ResObj_Convert, "Carbon.Res") -GLUE_NEW(Handle, OptResObj_New, "Carbon.Res") -GLUE_CONVERT(Handle, OptResObj_Convert, "Carbon.Res") - -GLUE_NEW(TEHandle, TEObj_New, "Carbon.TE") -GLUE_CONVERT(TEHandle, TEObj_Convert, "Carbon.TE") - -GLUE_NEW(WindowPtr, WinObj_New, "Carbon.Win") -GLUE_CONVERT(WindowPtr, WinObj_Convert, "Carbon.Win") -GLUE_NEW(WindowPtr, WinObj_WhichWindow, "Carbon.Win") - -GLUE_CONVERT(CFTypeRef, CFObj_Convert, "Carbon.CF") -GLUE_NEW(CFTypeRef, CFObj_New, "Carbon.CF") - -GLUE_CONVERT(CFTypeRef, CFTypeRefObj_Convert, "Carbon.CF") -GLUE_NEW(CFTypeRef, CFTypeRefObj_New, "Carbon.CF") - -GLUE_CONVERT(CFStringRef, CFStringRefObj_Convert, "Carbon.CF") -GLUE_NEW(CFStringRef, CFStringRefObj_New, "Carbon.CF") -GLUE_CONVERT(CFMutableStringRef, CFMutableStringRefObj_Convert, "Carbon.CF") -GLUE_NEW(CFMutableStringRef, CFMutableStringRefObj_New, "Carbon.CF") - -GLUE_CONVERT(CFArrayRef, CFArrayRefObj_Convert, "Carbon.CF") -GLUE_NEW(CFArrayRef, CFArrayRefObj_New, "Carbon.CF") -GLUE_CONVERT(CFMutableArrayRef, CFMutableArrayRefObj_Convert, "Carbon.CF") -GLUE_NEW(CFMutableArrayRef, CFMutableArrayRefObj_New, "Carbon.CF") - -GLUE_CONVERT(CFDictionaryRef, CFDictionaryRefObj_Convert, "Carbon.CF") -GLUE_NEW(CFDictionaryRef, CFDictionaryRefObj_New, "Carbon.CF") -GLUE_CONVERT(CFMutableDictionaryRef, CFMutableDictionaryRefObj_Convert, "Carbon.CF") -GLUE_NEW(CFMutableDictionaryRef, CFMutableDictionaryRefObj_New, "Carbon.CF") - -GLUE_CONVERT(CFURLRef, CFURLRefObj_Convert, "Carbon.CF") -GLUE_CONVERT(CFURLRef, OptionalCFURLRefObj_Convert, "Carbon.CF") -GLUE_NEW(CFURLRef, CFURLRefObj_New, "Carbon.CF") - -#endif /* USE_TOOLBOX_OBJECT_GLUE */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/marshal.c b/SDKs/XPlatform/Cypython-2.3.3/Python/marshal.c deleted file mode 100644 index c478aff7..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/marshal.c +++ /dev/null @@ -1,882 +0,0 @@ - -/* Write Python objects to files and read them back. - This is intended for writing and reading compiled Python code only; - a true persistent storage facility would be much harder, since - it would have to take circular links and sharing into account. */ - -#include "Python.h" -#include "longintrepr.h" -#include "compile.h" -#include "marshal.h" - -/* High water mark to determine when the marshalled object is dangerously deep - * and risks coring the interpreter. When the object stack gets this deep, - * raise an exception instead of continuing. - */ -#define MAX_MARSHAL_STACK_DEPTH 5000 - -#define TYPE_NULL '0' -#define TYPE_NONE 'N' -#define TYPE_FALSE 'F' -#define TYPE_TRUE 'T' -#define TYPE_STOPITER 'S' -#define TYPE_ELLIPSIS '.' -#define TYPE_INT 'i' -#define TYPE_INT64 'I' -#define TYPE_FLOAT 'f' -#define TYPE_COMPLEX 'x' -#define TYPE_LONG 'l' -#define TYPE_STRING 's' -#define TYPE_TUPLE '(' -#define TYPE_LIST '[' -#define TYPE_DICT '{' -#define TYPE_CODE 'c' -#define TYPE_UNICODE 'u' -#define TYPE_UNKNOWN '?' - -typedef struct { - FILE *fp; - int error; - int depth; - /* If fp == NULL, the following are valid: */ - PyObject *str; - char *ptr; - char *end; -} WFILE; - -#define w_byte(c, p) if (((p)->fp)) putc((c), (p)->fp); \ - else if ((p)->ptr != (p)->end) *(p)->ptr++ = (c); \ - else w_more(c, p) - -static void -w_more(int c, WFILE *p) -{ - int size, newsize; - if (p->str == NULL) - return; /* An error already occurred */ - size = PyString_Size(p->str); - newsize = size + 1024; - if (_PyString_Resize(&p->str, newsize) != 0) { - p->ptr = p->end = NULL; - } - else { - p->ptr = PyString_AS_STRING((PyStringObject *)p->str) + size; - p->end = - PyString_AS_STRING((PyStringObject *)p->str) + newsize; - *p->ptr++ = Py_SAFE_DOWNCAST(c, int, char); - } -} - -static void -w_string(char *s, int n, WFILE *p) -{ - if (p->fp != NULL) { - fwrite(s, 1, n, p->fp); - } - else { - while (--n >= 0) { - w_byte(*s, p); - s++; - } - } -} - -static void -w_short(int x, WFILE *p) -{ - w_byte((char)( x & 0xff), p); - w_byte((char)((x>> 8) & 0xff), p); -} - -static void -w_long(long x, WFILE *p) -{ - w_byte((char)( x & 0xff), p); - w_byte((char)((x>> 8) & 0xff), p); - w_byte((char)((x>>16) & 0xff), p); - w_byte((char)((x>>24) & 0xff), p); -} - -#if SIZEOF_LONG > 4 -static void -w_long64(long x, WFILE *p) -{ - w_long(x, p); - w_long(x>>32, p); -} -#endif - -static void -w_object(PyObject *v, WFILE *p) -{ - int i, n; - - p->depth++; - - if (p->depth > MAX_MARSHAL_STACK_DEPTH) { - p->error = 2; - } - else if (v == NULL) { - w_byte(TYPE_NULL, p); - } - else if (v == Py_None) { - w_byte(TYPE_NONE, p); - } - else if (v == PyExc_StopIteration) { - w_byte(TYPE_STOPITER, p); - } - else if (v == Py_Ellipsis) { - w_byte(TYPE_ELLIPSIS, p); - } - else if (v == Py_False) { - w_byte(TYPE_FALSE, p); - } - else if (v == Py_True) { - w_byte(TYPE_TRUE, p); - } - else if (PyInt_Check(v)) { - long x = PyInt_AS_LONG((PyIntObject *)v); -#if SIZEOF_LONG > 4 - long y = Py_ARITHMETIC_RIGHT_SHIFT(long, x, 31); - if (y && y != -1) { - w_byte(TYPE_INT64, p); - w_long64(x, p); - } - else -#endif - { - w_byte(TYPE_INT, p); - w_long(x, p); - } - } - else if (PyLong_Check(v)) { - PyLongObject *ob = (PyLongObject *)v; - w_byte(TYPE_LONG, p); - n = ob->ob_size; - w_long((long)n, p); - if (n < 0) - n = -n; - for (i = 0; i < n; i++) - w_short(ob->ob_digit[i], p); - } - else if (PyFloat_Check(v)) { - char buf[256]; /* Plenty to format any double */ - PyFloat_AsReprString(buf, (PyFloatObject *)v); - n = strlen(buf); - w_byte(TYPE_FLOAT, p); - w_byte(n, p); - w_string(buf, n, p); - } -#ifndef WITHOUT_COMPLEX - else if (PyComplex_Check(v)) { - char buf[256]; /* Plenty to format any double */ - PyFloatObject *temp; - w_byte(TYPE_COMPLEX, p); - temp = (PyFloatObject*)PyFloat_FromDouble( - PyComplex_RealAsDouble(v)); - PyFloat_AsReprString(buf, temp); - Py_DECREF(temp); - n = strlen(buf); - w_byte(n, p); - w_string(buf, n, p); - temp = (PyFloatObject*)PyFloat_FromDouble( - PyComplex_ImagAsDouble(v)); - PyFloat_AsReprString(buf, temp); - Py_DECREF(temp); - n = strlen(buf); - w_byte(n, p); - w_string(buf, n, p); - } -#endif - else if (PyString_Check(v)) { - w_byte(TYPE_STRING, p); - n = PyString_GET_SIZE(v); - w_long((long)n, p); - w_string(PyString_AS_STRING(v), n, p); - } -#ifdef Py_USING_UNICODE - else if (PyUnicode_Check(v)) { - PyObject *utf8; - utf8 = PyUnicode_AsUTF8String(v); - if (utf8 == NULL) { - p->depth--; - p->error = 1; - return; - } - w_byte(TYPE_UNICODE, p); - n = PyString_GET_SIZE(utf8); - w_long((long)n, p); - w_string(PyString_AS_STRING(utf8), n, p); - Py_DECREF(utf8); - } -#endif - else if (PyTuple_Check(v)) { - w_byte(TYPE_TUPLE, p); - n = PyTuple_Size(v); - w_long((long)n, p); - for (i = 0; i < n; i++) { - w_object(PyTuple_GET_ITEM(v, i), p); - } - } - else if (PyList_Check(v)) { - w_byte(TYPE_LIST, p); - n = PyList_GET_SIZE(v); - w_long((long)n, p); - for (i = 0; i < n; i++) { - w_object(PyList_GET_ITEM(v, i), p); - } - } - else if (PyDict_Check(v)) { - int pos; - PyObject *key, *value; - w_byte(TYPE_DICT, p); - /* This one is NULL object terminated! */ - pos = 0; - while (PyDict_Next(v, &pos, &key, &value)) { - w_object(key, p); - w_object(value, p); - } - w_object((PyObject *)NULL, p); - } - else if (PyCode_Check(v)) { - PyCodeObject *co = (PyCodeObject *)v; - w_byte(TYPE_CODE, p); - w_long(co->co_argcount, p); - w_long(co->co_nlocals, p); - w_long(co->co_stacksize, p); - w_long(co->co_flags, p); - w_object(co->co_code, p); - w_object(co->co_consts, p); - w_object(co->co_names, p); - w_object(co->co_varnames, p); - w_object(co->co_freevars, p); - w_object(co->co_cellvars, p); - w_object(co->co_filename, p); - w_object(co->co_name, p); - w_long(co->co_firstlineno, p); - w_object(co->co_lnotab, p); - } - else if (PyObject_CheckReadBuffer(v)) { - /* Write unknown buffer-style objects as a string */ - char *s; - PyBufferProcs *pb = v->ob_type->tp_as_buffer; - w_byte(TYPE_STRING, p); - n = (*pb->bf_getreadbuffer)(v, 0, (void **)&s); - w_long((long)n, p); - w_string(s, n, p); - } - else { - w_byte(TYPE_UNKNOWN, p); - p->error = 1; - } - - p->depth--; -} - -void -PyMarshal_WriteLongToFile(long x, FILE *fp) -{ - WFILE wf; - wf.fp = fp; - wf.error = 0; - wf.depth = 0; - w_long(x, &wf); -} - -void -PyMarshal_WriteObjectToFile(PyObject *x, FILE *fp) -{ - WFILE wf; - wf.fp = fp; - wf.error = 0; - wf.depth = 0; - w_object(x, &wf); -} - -typedef WFILE RFILE; /* Same struct with different invariants */ - -#define rs_byte(p) (((p)->ptr != (p)->end) ? (unsigned char)*(p)->ptr++ : EOF) - -#define r_byte(p) ((p)->fp ? getc((p)->fp) : rs_byte(p)) - -static int -r_string(char *s, int n, RFILE *p) -{ - if (p->fp != NULL) - return fread(s, 1, n, p->fp); - if (p->end - p->ptr < n) - n = p->end - p->ptr; - memcpy(s, p->ptr, n); - p->ptr += n; - return n; -} - -static int -r_short(RFILE *p) -{ - register short x; - x = r_byte(p); - x |= r_byte(p) << 8; - /* Sign-extension, in case short greater than 16 bits */ - x |= -(x & 0x8000); - return x; -} - -static long -r_long(RFILE *p) -{ - register long x; - register FILE *fp = p->fp; - if (fp) { - x = getc(fp); - x |= (long)getc(fp) << 8; - x |= (long)getc(fp) << 16; - x |= (long)getc(fp) << 24; - } - else { - x = rs_byte(p); - x |= (long)rs_byte(p) << 8; - x |= (long)rs_byte(p) << 16; - x |= (long)rs_byte(p) << 24; - } -#if SIZEOF_LONG > 4 - /* Sign extension for 64-bit machines */ - x |= -(x & 0x80000000L); -#endif - return x; -} - -/* r_long64 deals with the TYPE_INT64 code. On a machine with - sizeof(long) > 4, it returns a Python int object, else a Python long - object. Note that w_long64 writes out TYPE_INT if 32 bits is enough, - so there's no inefficiency here in returning a PyLong on 32-bit boxes - for everything written via TYPE_INT64 (i.e., if an int is written via - TYPE_INT64, it *needs* more than 32 bits). -*/ -static PyObject * -r_long64(RFILE *p) -{ - long lo4 = r_long(p); - long hi4 = r_long(p); -#if SIZEOF_LONG > 4 - long x = (hi4 << 32) | (lo4 & 0xFFFFFFFFL); - return PyInt_FromLong(x); -#else - unsigned char buf[8]; - int one = 1; - int is_little_endian = (int)*(char*)&one; - if (is_little_endian) { - memcpy(buf, &lo4, 4); - memcpy(buf+4, &hi4, 4); - } - else { - memcpy(buf, &hi4, 4); - memcpy(buf+4, &lo4, 4); - } - return _PyLong_FromByteArray(buf, 8, is_little_endian, 1); -#endif -} - -static PyObject * -r_object(RFILE *p) -{ - PyObject *v, *v2; - long i, n; - int type = r_byte(p); - - switch (type) { - - case EOF: - PyErr_SetString(PyExc_EOFError, - "EOF read where object expected"); - return NULL; - - case TYPE_NULL: - return NULL; - - case TYPE_NONE: - Py_INCREF(Py_None); - return Py_None; - - case TYPE_STOPITER: - Py_INCREF(PyExc_StopIteration); - return PyExc_StopIteration; - - case TYPE_ELLIPSIS: - Py_INCREF(Py_Ellipsis); - return Py_Ellipsis; - - case TYPE_FALSE: - Py_INCREF(Py_False); - return Py_False; - - case TYPE_TRUE: - Py_INCREF(Py_True); - return Py_True; - - case TYPE_INT: - return PyInt_FromLong(r_long(p)); - - case TYPE_INT64: - return r_long64(p); - - case TYPE_LONG: - { - int size; - PyLongObject *ob; - n = r_long(p); - size = n<0 ? -n : n; - ob = _PyLong_New(size); - if (ob == NULL) - return NULL; - ob->ob_size = n; - for (i = 0; i < size; i++) - ob->ob_digit[i] = r_short(p); - return (PyObject *)ob; - } - - case TYPE_FLOAT: - { - char buf[256]; - double dx; - n = r_byte(p); - if (r_string(buf, (int)n, p) != n) { - PyErr_SetString(PyExc_EOFError, - "EOF read where object expected"); - return NULL; - } - buf[n] = '\0'; - PyFPE_START_PROTECT("atof", return 0) - dx = atof(buf); - PyFPE_END_PROTECT(dx) - return PyFloat_FromDouble(dx); - } - -#ifndef WITHOUT_COMPLEX - case TYPE_COMPLEX: - { - char buf[256]; - Py_complex c; - n = r_byte(p); - if (r_string(buf, (int)n, p) != n) { - PyErr_SetString(PyExc_EOFError, - "EOF read where object expected"); - return NULL; - } - buf[n] = '\0'; - PyFPE_START_PROTECT("atof", return 0) - c.real = atof(buf); - PyFPE_END_PROTECT(c) - n = r_byte(p); - if (r_string(buf, (int)n, p) != n) { - PyErr_SetString(PyExc_EOFError, - "EOF read where object expected"); - return NULL; - } - buf[n] = '\0'; - PyFPE_START_PROTECT("atof", return 0) - c.imag = atof(buf); - PyFPE_END_PROTECT(c) - return PyComplex_FromCComplex(c); - } -#endif - - case TYPE_STRING: - n = r_long(p); - if (n < 0) { - PyErr_SetString(PyExc_ValueError, "bad marshal data"); - return NULL; - } - v = PyString_FromStringAndSize((char *)NULL, n); - if (v != NULL) { - if (r_string(PyString_AS_STRING(v), (int)n, p) != n) { - Py_DECREF(v); - v = NULL; - PyErr_SetString(PyExc_EOFError, - "EOF read where object expected"); - } - } - return v; - -#ifdef Py_USING_UNICODE - case TYPE_UNICODE: - { - char *buffer; - - n = r_long(p); - if (n < 0) { - PyErr_SetString(PyExc_ValueError, "bad marshal data"); - return NULL; - } - buffer = PyMem_NEW(char, n); - if (buffer == NULL) - return PyErr_NoMemory(); - if (r_string(buffer, (int)n, p) != n) { - PyMem_DEL(buffer); - PyErr_SetString(PyExc_EOFError, - "EOF read where object expected"); - return NULL; - } - v = PyUnicode_DecodeUTF8(buffer, n, NULL); - PyMem_DEL(buffer); - return v; - } -#endif - - case TYPE_TUPLE: - n = r_long(p); - if (n < 0) { - PyErr_SetString(PyExc_ValueError, "bad marshal data"); - return NULL; - } - v = PyTuple_New((int)n); - if (v == NULL) - return v; - for (i = 0; i < n; i++) { - v2 = r_object(p); - if ( v2 == NULL ) { - Py_DECREF(v); - v = NULL; - break; - } - PyTuple_SET_ITEM(v, (int)i, v2); - } - return v; - - case TYPE_LIST: - n = r_long(p); - if (n < 0) { - PyErr_SetString(PyExc_ValueError, "bad marshal data"); - return NULL; - } - v = PyList_New((int)n); - if (v == NULL) - return v; - for (i = 0; i < n; i++) { - v2 = r_object(p); - if ( v2 == NULL ) { - Py_DECREF(v); - v = NULL; - break; - } - PyList_SetItem(v, (int)i, v2); - } - return v; - - case TYPE_DICT: - v = PyDict_New(); - if (v == NULL) - return NULL; - for (;;) { - PyObject *key, *val; - key = r_object(p); - if (key == NULL) - break; /* XXX Assume TYPE_NULL, not an error */ - val = r_object(p); - if (val != NULL) - PyDict_SetItem(v, key, val); - Py_DECREF(key); - Py_XDECREF(val); - } - return v; - - case TYPE_CODE: - if (PyEval_GetRestricted()) { - PyErr_SetString(PyExc_RuntimeError, - "cannot unmarshal code objects in " - "restricted execution mode"); - return NULL; - } - else { - int argcount = r_long(p); - int nlocals = r_long(p); - int stacksize = r_long(p); - int flags = r_long(p); - PyObject *code = NULL; - PyObject *consts = NULL; - PyObject *names = NULL; - PyObject *varnames = NULL; - PyObject *freevars = NULL; - PyObject *cellvars = NULL; - PyObject *filename = NULL; - PyObject *name = NULL; - int firstlineno = 0; - PyObject *lnotab = NULL; - - code = r_object(p); - if (code) consts = r_object(p); - if (consts) names = r_object(p); - if (names) varnames = r_object(p); - if (varnames) freevars = r_object(p); - if (freevars) cellvars = r_object(p); - if (cellvars) filename = r_object(p); - if (filename) name = r_object(p); - if (name) { - firstlineno = r_long(p); - lnotab = r_object(p); - } - - if (!PyErr_Occurred()) { - v = (PyObject *) PyCode_New( - argcount, nlocals, stacksize, flags, - code, consts, names, varnames, - freevars, cellvars, filename, name, - firstlineno, lnotab); - } - else - v = NULL; - Py_XDECREF(code); - Py_XDECREF(consts); - Py_XDECREF(names); - Py_XDECREF(varnames); - Py_XDECREF(freevars); - Py_XDECREF(cellvars); - Py_XDECREF(filename); - Py_XDECREF(name); - Py_XDECREF(lnotab); - - } - return v; - - default: - /* Bogus data got written, which isn't ideal. - This will let you keep working and recover. */ - PyErr_SetString(PyExc_ValueError, "bad marshal data"); - return NULL; - - } -} - -int -PyMarshal_ReadShortFromFile(FILE *fp) -{ - RFILE rf; - rf.fp = fp; - return r_short(&rf); -} - -long -PyMarshal_ReadLongFromFile(FILE *fp) -{ - RFILE rf; - rf.fp = fp; - return r_long(&rf); -} - -#ifdef HAVE_FSTAT -/* Return size of file in bytes; < 0 if unknown. */ -static off_t -getfilesize(FILE *fp) -{ - struct stat st; - if (fstat(fileno(fp), &st) != 0) - return -1; - else - return st.st_size; -} -#endif - -/* If we can get the size of the file up-front, and it's reasonably small, - * read it in one gulp and delegate to ...FromString() instead. Much quicker - * than reading a byte at a time from file; speeds .pyc imports. - * CAUTION: since this may read the entire remainder of the file, don't - * call it unless you know you're done with the file. - */ -PyObject * -PyMarshal_ReadLastObjectFromFile(FILE *fp) -{ -/* 75% of 2.1's .pyc files can exploit SMALL_FILE_LIMIT. - * REASONABLE_FILE_LIMIT is by defn something big enough for Tkinter.pyc. - */ -#define SMALL_FILE_LIMIT (1L << 14) -#define REASONABLE_FILE_LIMIT (1L << 18) -#ifdef HAVE_FSTAT - off_t filesize; -#endif - if (PyErr_Occurred()) { - fprintf(stderr, "XXX rd_object called with exception set\n"); - return NULL; - } -#ifdef HAVE_FSTAT - filesize = getfilesize(fp); - if (filesize > 0) { - char buf[SMALL_FILE_LIMIT]; - char* pBuf = NULL; - if (filesize <= SMALL_FILE_LIMIT) - pBuf = buf; - else if (filesize <= REASONABLE_FILE_LIMIT) - pBuf = (char *)PyMem_MALLOC(filesize); - if (pBuf != NULL) { - PyObject* v; - size_t n = fread(pBuf, 1, filesize, fp); - v = PyMarshal_ReadObjectFromString(pBuf, n); - if (pBuf != buf) - PyMem_FREE(pBuf); - return v; - } - - } -#endif - /* We don't have fstat, or we do but the file is larger than - * REASONABLE_FILE_LIMIT or malloc failed -- read a byte at a time. - */ - return PyMarshal_ReadObjectFromFile(fp); - -#undef SMALL_FILE_LIMIT -#undef REASONABLE_FILE_LIMIT -} - -PyObject * -PyMarshal_ReadObjectFromFile(FILE *fp) -{ - RFILE rf; - if (PyErr_Occurred()) { - fprintf(stderr, "XXX rd_object called with exception set\n"); - return NULL; - } - rf.fp = fp; - return r_object(&rf); -} - -PyObject * -PyMarshal_ReadObjectFromString(char *str, int len) -{ - RFILE rf; - if (PyErr_Occurred()) { - fprintf(stderr, "XXX rds_object called with exception set\n"); - return NULL; - } - rf.fp = NULL; - rf.str = NULL; - rf.ptr = str; - rf.end = str + len; - return r_object(&rf); -} - -PyObject * -PyMarshal_WriteObjectToString(PyObject *x) /* wrs_object() */ -{ - WFILE wf; - wf.fp = NULL; - wf.str = PyString_FromStringAndSize((char *)NULL, 50); - if (wf.str == NULL) - return NULL; - wf.ptr = PyString_AS_STRING((PyStringObject *)wf.str); - wf.end = wf.ptr + PyString_Size(wf.str); - wf.error = 0; - wf.depth = 0; - w_object(x, &wf); - if (wf.str != NULL) - _PyString_Resize(&wf.str, - (int) (wf.ptr - - PyString_AS_STRING((PyStringObject *)wf.str))); - if (wf.error) { - Py_XDECREF(wf.str); - PyErr_SetString(PyExc_ValueError, - (wf.error==1)?"unmarshallable object" - :"object too deeply nested to marshal"); - return NULL; - } - return wf.str; -} - -/* And an interface for Python programs... */ - -static PyObject * -marshal_dump(PyObject *self, PyObject *args) -{ - WFILE wf; - PyObject *x; - PyObject *f; - if (!PyArg_ParseTuple(args, "OO:dump", &x, &f)) - return NULL; - if (!PyFile_Check(f)) { - PyErr_SetString(PyExc_TypeError, - "marshal.dump() 2nd arg must be file"); - return NULL; - } - wf.fp = PyFile_AsFile(f); - wf.str = NULL; - wf.ptr = wf.end = NULL; - wf.error = 0; - wf.depth = 0; - w_object(x, &wf); - if (wf.error) { - PyErr_SetString(PyExc_ValueError, - (wf.error==1)?"unmarshallable object" - :"object too deeply nested to marshal"); - return NULL; - } - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -marshal_load(PyObject *self, PyObject *args) -{ - RFILE rf; - PyObject *f; - PyObject *v; - if (!PyArg_ParseTuple(args, "O:load", &f)) - return NULL; - if (!PyFile_Check(f)) { - PyErr_SetString(PyExc_TypeError, - "marshal.load() arg must be file"); - return NULL; - } - rf.fp = PyFile_AsFile(f); - rf.str = NULL; - rf.ptr = rf.end = NULL; - PyErr_Clear(); - v = r_object(&rf); - if (PyErr_Occurred()) { - Py_XDECREF(v); - v = NULL; - } - return v; -} - -static PyObject * -marshal_dumps(PyObject *self, PyObject *args) -{ - PyObject *x; - if (!PyArg_ParseTuple(args, "O:dumps", &x)) - return NULL; - return PyMarshal_WriteObjectToString(x); -} - -static PyObject * -marshal_loads(PyObject *self, PyObject *args) -{ - RFILE rf; - PyObject *v; - char *s; - int n; - if (!PyArg_ParseTuple(args, "s#:loads", &s, &n)) - return NULL; - rf.fp = NULL; - rf.str = args; - rf.ptr = s; - rf.end = s + n; - PyErr_Clear(); - v = r_object(&rf); - if (PyErr_Occurred()) { - Py_XDECREF(v); - v = NULL; - } - return v; -} - -static PyMethodDef marshal_methods[] = { - {"dump", marshal_dump, METH_VARARGS}, - {"load", marshal_load, METH_VARARGS}, - {"dumps", marshal_dumps, METH_VARARGS}, - {"loads", marshal_loads, METH_VARARGS}, - {NULL, NULL} /* sentinel */ -}; - -void -PyMarshal_Init(void) -{ - (void) Py_InitModule("marshal", marshal_methods); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/memmove.c b/SDKs/XPlatform/Cypython-2.3.3/Python/memmove.c deleted file mode 100644 index fc4b2afa..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/memmove.c +++ /dev/null @@ -1,25 +0,0 @@ - -/* A perhaps slow but I hope correct implementation of memmove */ - -extern char *memcpy(char *, char *, int); - -char * -memmove(char *dst, char *src, int n) -{ - char *realdst = dst; - if (n <= 0) - return dst; - if (src >= dst+n || dst >= src+n) - return memcpy(dst, src, n); - if (src > dst) { - while (--n >= 0) - *dst++ = *src++; - } - else if (src < dst) { - src += n; - dst += n; - while (--n >= 0) - *--dst = *--src; - } - return realdst; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/modsupport.c b/SDKs/XPlatform/Cypython-2.3.3/Python/modsupport.c deleted file mode 100644 index a3aee329..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/modsupport.c +++ /dev/null @@ -1,551 +0,0 @@ - -/* Module support implementation */ - -#include "Python.h" - -#ifdef MPW /* MPW pushes 'extended' for float and double types with varargs */ -typedef extended va_double; -#else -typedef double va_double; -#endif - -/* Package context -- the full module name for package imports */ -char *_Py_PackageContext = NULL; - -/* Py_InitModule4() parameters: - - name is the module name - - methods is the list of top-level functions - - doc is the documentation string - - passthrough is passed as self to functions defined in the module - - api_version is the value of PYTHON_API_VERSION at the time the - module was compiled - - Return value is a borrowed reference to the module object; or NULL - if an error occurred (in Python 1.4 and before, errors were fatal). - Errors may still leak memory. -*/ - -static char api_version_warning[] = -"Python C API version mismatch for module %.100s:\ - This Python has API version %d, module %.100s has version %d."; - -PyObject * -Py_InitModule4(char *name, PyMethodDef *methods, char *doc, - PyObject *passthrough, int module_api_version) -{ - PyObject *m, *d, *v, *n; - PyMethodDef *ml; - if (!Py_IsInitialized()) - Py_FatalError("Interpreter not initialized (version mismatch?)"); - if (module_api_version != PYTHON_API_VERSION) { - char message[512]; - PyOS_snprintf(message, sizeof(message), - api_version_warning, name, - PYTHON_API_VERSION, name, - module_api_version); - if (PyErr_Warn(PyExc_RuntimeWarning, message)) - return NULL; - } - /* Make sure name is fully qualified. - - This is a bit of a hack: when the shared library is loaded, - the module name is "package.module", but the module calls - Py_InitModule*() with just "module" for the name. The shared - library loader squirrels away the true name of the module in - _Py_PackageContext, and Py_InitModule*() will substitute this - (if the name actually matches). - */ - if (_Py_PackageContext != NULL) { - char *p = strrchr(_Py_PackageContext, '.'); - if (p != NULL && strcmp(name, p+1) == 0) { - name = _Py_PackageContext; - _Py_PackageContext = NULL; - } - } - if ((m = PyImport_AddModule(name)) == NULL) - return NULL; - d = PyModule_GetDict(m); - if (methods != NULL) { - n = PyString_FromString(name); - if (n == NULL) - return NULL; - for (ml = methods; ml->ml_name != NULL; ml++) { - if ((ml->ml_flags & METH_CLASS) || - (ml->ml_flags & METH_STATIC)) { - PyErr_SetString(PyExc_ValueError, - "module functions cannot set" - " METH_CLASS or METH_STATIC"); - return NULL; - } - v = PyCFunction_NewEx(ml, passthrough, n); - if (v == NULL) - return NULL; - if (PyDict_SetItemString(d, ml->ml_name, v) != 0) { - Py_DECREF(v); - return NULL; - } - Py_DECREF(v); - } - } - if (doc != NULL) { - v = PyString_FromString(doc); - if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0) { - Py_XDECREF(v); - return NULL; - } - Py_DECREF(v); - } - return m; -} - - -/* Helper for mkvalue() to scan the length of a format */ - -static int -countformat(char *format, int endchar) -{ - int count = 0; - int level = 0; - while (level > 0 || *format != endchar) { - switch (*format) { - case '\0': - /* Premature end */ - PyErr_SetString(PyExc_SystemError, - "unmatched paren in format"); - return -1; - case '(': - case '[': - case '{': - if (level == 0) - count++; - level++; - break; - case ')': - case ']': - case '}': - level--; - break; - case '#': - case '&': - case ',': - case ':': - case ' ': - case '\t': - break; - default: - if (level == 0) - count++; - } - format++; - } - return count; -} - - -/* Generic function to create a value -- the inverse of getargs() */ -/* After an original idea and first implementation by Steven Miale */ - -static PyObject *do_mktuple(char**, va_list *, int, int); -static PyObject *do_mklist(char**, va_list *, int, int); -static PyObject *do_mkdict(char**, va_list *, int, int); -static PyObject *do_mkvalue(char**, va_list *); - - -static PyObject * -do_mkdict(char **p_format, va_list *p_va, int endchar, int n) -{ - PyObject *d; - int i; - if (n < 0) - return NULL; - if ((d = PyDict_New()) == NULL) - return NULL; - for (i = 0; i < n; i+= 2) { - PyObject *k, *v; - int err; - k = do_mkvalue(p_format, p_va); - if (k == NULL) { - Py_DECREF(d); - return NULL; - } - v = do_mkvalue(p_format, p_va); - if (v == NULL) { - Py_DECREF(k); - Py_DECREF(d); - return NULL; - } - err = PyDict_SetItem(d, k, v); - Py_DECREF(k); - Py_DECREF(v); - if (err < 0) { - Py_DECREF(d); - return NULL; - } - } - if (d != NULL && **p_format != endchar) { - Py_DECREF(d); - d = NULL; - PyErr_SetString(PyExc_SystemError, - "Unmatched paren in format"); - } - else if (endchar) - ++*p_format; - return d; -} - -static PyObject * -do_mklist(char **p_format, va_list *p_va, int endchar, int n) -{ - PyObject *v; - int i; - if (n < 0) - return NULL; - if ((v = PyList_New(n)) == NULL) - return NULL; - for (i = 0; i < n; i++) { - PyObject *w = do_mkvalue(p_format, p_va); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyList_SetItem(v, i, w); - } - if (v != NULL && **p_format != endchar) { - Py_DECREF(v); - v = NULL; - PyErr_SetString(PyExc_SystemError, - "Unmatched paren in format"); - } - else if (endchar) - ++*p_format; - return v; -} - -#ifdef Py_USING_UNICODE -static int -_ustrlen(Py_UNICODE *u) -{ - int i = 0; - Py_UNICODE *v = u; - while (*v != 0) { i++; v++; } - return i; -} -#endif - -static PyObject * -do_mktuple(char **p_format, va_list *p_va, int endchar, int n) -{ - PyObject *v; - int i; - if (n < 0) - return NULL; - if ((v = PyTuple_New(n)) == NULL) - return NULL; - for (i = 0; i < n; i++) { - PyObject *w = do_mkvalue(p_format, p_va); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyTuple_SetItem(v, i, w); - } - if (v != NULL && **p_format != endchar) { - Py_DECREF(v); - v = NULL; - PyErr_SetString(PyExc_SystemError, - "Unmatched paren in format"); - } - else if (endchar) - ++*p_format; - return v; -} - -static PyObject * -do_mkvalue(char **p_format, va_list *p_va) -{ - for (;;) { - switch (*(*p_format)++) { - case '(': - return do_mktuple(p_format, p_va, ')', - countformat(*p_format, ')')); - - case '[': - return do_mklist(p_format, p_va, ']', - countformat(*p_format, ']')); - - case '{': - return do_mkdict(p_format, p_va, '}', - countformat(*p_format, '}')); - - case 'b': - case 'B': - case 'h': - case 'i': - return PyInt_FromLong((long)va_arg(*p_va, int)); - - case 'H': - return PyInt_FromLong((long)va_arg(*p_va, unsigned int)); - - case 'l': - return PyInt_FromLong((long)va_arg(*p_va, long)); - - case 'k': - return PyInt_FromLong((long)va_arg(*p_va, unsigned long)); - -#ifdef HAVE_LONG_LONG - case 'L': - return PyLong_FromLongLong((PY_LONG_LONG)va_arg(*p_va, PY_LONG_LONG)); - - case 'K': - return PyLong_FromLongLong((PY_LONG_LONG)va_arg(*p_va, unsigned PY_LONG_LONG)); -#endif -#ifdef Py_USING_UNICODE - case 'u': - { - PyObject *v; - Py_UNICODE *u = va_arg(*p_va, Py_UNICODE *); - int n; - if (**p_format == '#') { - ++*p_format; - n = va_arg(*p_va, int); - } - else - n = -1; - if (u == NULL) { - v = Py_None; - Py_INCREF(v); - } - else { - if (n < 0) - n = _ustrlen(u); - v = PyUnicode_FromUnicode(u, n); - } - return v; - } -#endif - case 'f': - case 'd': - return PyFloat_FromDouble( - (double)va_arg(*p_va, va_double)); - -#ifndef WITHOUT_COMPLEX - case 'D': - return PyComplex_FromCComplex( - *((Py_complex *)va_arg(*p_va, Py_complex *))); -#endif /* WITHOUT_COMPLEX */ - - case 'c': - { - char p[1]; - p[0] = va_arg(*p_va, int); - return PyString_FromStringAndSize(p, 1); - } - - case 's': - case 'z': - { - PyObject *v; - char *str = va_arg(*p_va, char *); - int n; - if (**p_format == '#') { - ++*p_format; - n = va_arg(*p_va, int); - } - else - n = -1; - if (str == NULL) { - v = Py_None; - Py_INCREF(v); - } - else { - if (n < 0) { - size_t m = strlen(str); - if (m > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "string too long for Python string"); - return NULL; - } - n = (int)m; - } - v = PyString_FromStringAndSize(str, n); - } - return v; - } - - case 'N': - case 'S': - case 'O': - if (**p_format == '&') { - typedef PyObject *(*converter)(void *); - converter func = va_arg(*p_va, converter); - void *arg = va_arg(*p_va, void *); - ++*p_format; - return (*func)(arg); - } - else { - PyObject *v; - v = va_arg(*p_va, PyObject *); - if (v != NULL) { - if (*(*p_format - 1) != 'N') - Py_INCREF(v); - } - else if (!PyErr_Occurred()) - /* If a NULL was passed - * because a call that should - * have constructed a value - * failed, that's OK, and we - * pass the error on; but if - * no error occurred it's not - * clear that the caller knew - * what she was doing. */ - PyErr_SetString(PyExc_SystemError, - "NULL object passed to Py_BuildValue"); - return v; - } - - case ':': - case ',': - case ' ': - case '\t': - break; - - default: - PyErr_SetString(PyExc_SystemError, - "bad format char passed to Py_BuildValue"); - return NULL; - - } - } -} - - -PyObject * -Py_BuildValue(char *format, ...) -{ - va_list va; - PyObject* retval; - va_start(va, format); - retval = Py_VaBuildValue(format, va); - va_end(va); - return retval; -} - -PyObject * -Py_VaBuildValue(char *format, va_list va) -{ - char *f = format; - int n = countformat(f, '\0'); - va_list lva; - -#ifdef VA_LIST_IS_ARRAY - memcpy(lva, va, sizeof(va_list)); -#else -#ifdef __va_copy - __va_copy(lva, va); -#else - lva = va; -#endif -#endif - - if (n < 0) - return NULL; - if (n == 0) { - Py_INCREF(Py_None); - return Py_None; - } - if (n == 1) - return do_mkvalue(&f, &lva); - return do_mktuple(&f, &lva, '\0', n); -} - - -PyObject * -PyEval_CallFunction(PyObject *obj, char *format, ...) -{ - va_list vargs; - PyObject *args; - PyObject *res; - - va_start(vargs, format); - - args = Py_VaBuildValue(format, vargs); - va_end(vargs); - - if (args == NULL) - return NULL; - - res = PyEval_CallObject(obj, args); - Py_DECREF(args); - - return res; -} - - -PyObject * -PyEval_CallMethod(PyObject *obj, char *methodname, char *format, ...) -{ - va_list vargs; - PyObject *meth; - PyObject *args; - PyObject *res; - - meth = PyObject_GetAttrString(obj, methodname); - if (meth == NULL) - return NULL; - - va_start(vargs, format); - - args = Py_VaBuildValue(format, vargs); - va_end(vargs); - - if (args == NULL) { - Py_DECREF(meth); - return NULL; - } - - res = PyEval_CallObject(meth, args); - Py_DECREF(meth); - Py_DECREF(args); - - return res; -} - -int -PyModule_AddObject(PyObject *m, char *name, PyObject *o) -{ - PyObject *dict; - if (!PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs module as first arg"); - return -1; - } - if (!o) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs non-NULL value"); - return -1; - } - - dict = PyModule_GetDict(m); - if (dict == NULL) { - /* Internal error -- modules must have a dict! */ - PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", - PyModule_GetName(m)); - return -1; - } - if (PyDict_SetItemString(dict, name, o)) - return -1; - Py_DECREF(o); - return 0; -} - -int -PyModule_AddIntConstant(PyObject *m, char *name, long value) -{ - return PyModule_AddObject(m, name, PyInt_FromLong(value)); -} - -int -PyModule_AddStringConstant(PyObject *m, char *name, char *value) -{ - return PyModule_AddObject(m, name, PyString_FromString(value)); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/mysnprintf.c b/SDKs/XPlatform/Cypython-2.3.3/Python/mysnprintf.c deleted file mode 100644 index 4e6da179..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/mysnprintf.c +++ /dev/null @@ -1,93 +0,0 @@ -#include "Python.h" -#include - -/* snprintf() wrappers. If the platform has vsnprintf, we use it, else we - emulate it in a half-hearted way. Even if the platform has it, we wrap - it because platforms differ in what vsnprintf does in case the buffer - is too small: C99 behavior is to return the number of characters that - would have been written had the buffer not been too small, and to set - the last byte of the buffer to \0. At least MS _vsnprintf returns a - negative value instead, and fills the entire buffer with non-\0 data. - - The wrappers ensure that str[size-1] is always \0 upon return. - - PyOS_snprintf and PyOS_vsnprintf never write more than size bytes - (including the trailing '\0') into str. - - If the platform doesn't have vsnprintf, and the buffer size needed to - avoid truncation exceeds size by more than 512, Python aborts with a - Py_FatalError. - - Return value (rv): - - When 0 <= rv < size, the output conversion was unexceptional, and - rv characters were written to str (excluding a trailing \0 byte at - str[rv]). - - When rv >= size, output conversion was truncated, and a buffer of - size rv+1 would have been needed to avoid truncation. str[size-1] - is \0 in this case. - - When rv < 0, "something bad happened". str[size-1] is \0 in this - case too, but the rest of str is unreliable. It could be that - an error in format codes was detected by libc, or on platforms - with a non-C99 vsnprintf simply that the buffer wasn't big enough - to avoid truncation, or on platforms without any vsnprintf that - PyMem_Malloc couldn't obtain space for a temp buffer. - - CAUTION: Unlike C99, str != NULL and size > 0 are required. -*/ - -int -PyOS_snprintf(char *str, size_t size, const char *format, ...) -{ - int rc; - va_list va; - - va_start(va, format); - rc = PyOS_vsnprintf(str, size, format, va); - va_end(va); - return rc; -} - -int -PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) -{ - int len; /* # bytes written, excluding \0 */ -#ifndef HAVE_SNPRINTF - char *buffer; -#endif - assert(str != NULL); - assert(size > 0); - assert(format != NULL); - -#ifdef HAVE_SNPRINTF - len = vsnprintf(str, size, format, va); -#else - /* Emulate it. */ - buffer = PyMem_MALLOC(size + 512); - if (buffer == NULL) { - len = -666; - goto Done; - } - - len = vsprintf(buffer, format, va); - if (len < 0) - /* ignore the error */; - - else if ((size_t)len >= size + 512) - Py_FatalError("Buffer overflow in PyOS_snprintf/PyOS_vsnprintf"); - - else { - const size_t to_copy = (size_t)len < size ? - (size_t)len : size - 1; - assert(to_copy < size); - memcpy(str, buffer, to_copy); - str[to_copy] = '\0'; - } - PyMem_FREE(buffer); -Done: -#endif - str[size-1] = '\0'; - return len; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/mystrtoul.c b/SDKs/XPlatform/Cypython-2.3.3/Python/mystrtoul.c deleted file mode 100644 index bc624928..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/mystrtoul.c +++ /dev/null @@ -1,153 +0,0 @@ - -#include "Python.h" - -#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE) -#define _SGI_MP_SOURCE -#endif - -/* Convert a possibly signed character to a nonnegative int */ -/* XXX This assumes characters are 8 bits wide */ -#ifdef __CHAR_UNSIGNED__ -#define Py_CHARMASK(c) (c) -#else -#define Py_CHARMASK(c) ((c) & 0xff) -#endif - -/* strtol and strtoul, renamed to avoid conflicts */ - -/* -** strtoul -** This is a general purpose routine for converting -** an ascii string to an integer in an arbitrary base. -** Leading white space is ignored. If 'base' is zero -** it looks for a leading 0, 0x or 0X to tell which -** base. If these are absent it defaults to 10. -** Base must be 0 or between 2 and 36 (inclusive). -** If 'ptr' is non-NULL it will contain a pointer to -** the end of the scan. -** Errors due to bad pointers will probably result in -** exceptions - we don't check for them. -*/ - -#include -#ifndef DONT_HAVE_ERRNO_H -#include -#endif - -unsigned long -PyOS_strtoul(register char *str, char **ptr, int base) -{ - register unsigned long result; /* return value of the function */ - register int c; /* current input character */ - register unsigned long temp; /* used in overflow testing */ - int ovf; /* true if overflow occurred */ - - result = 0; - ovf = 0; - -/* catch silly bases */ - if (base != 0 && (base < 2 || base > 36)) - { - if (ptr) - *ptr = str; - return 0; - } - -/* skip leading white space */ - while (*str && isspace(Py_CHARMASK(*str))) - str++; - -/* check for leading 0 or 0x for auto-base or base 16 */ - switch (base) - { - case 0: /* look for leading 0, 0x or 0X */ - if (*str == '0') - { - str++; - if (*str == 'x' || *str == 'X') - { - str++; - base = 16; - } - else - base = 8; - } - else - base = 10; - break; - - case 16: /* skip leading 0x or 0X */ - if (*str == '0' && (*(str+1) == 'x' || *(str+1) == 'X')) - str += 2; - break; - } - -/* do the conversion */ - while ((c = Py_CHARMASK(*str)) != '\0') - { - if (isdigit(c) && c - '0' < base) - c -= '0'; - else - { - if (isupper(c)) - c = tolower(c); - if (c >= 'a' && c <= 'z') - c -= 'a' - 10; - else /* non-"digit" character */ - break; - if (c >= base) /* non-"digit" character */ - break; - } - temp = result; - result = result * base + c; -#ifndef MPW - if(base == 10) { - if(((long)(result - c) / base != (long)temp)) /* overflow */ - ovf = 1; - } - else { - if ((result - c) / base != temp) /* overflow */ - ovf = 1; - } -#endif - str++; - } - -/* set pointer to point to the last character scanned */ - if (ptr) - *ptr = str; - if (ovf) - { - result = (unsigned long) ~0L; - errno = ERANGE; - } - return result; -} - -long -PyOS_strtol(char *str, char **ptr, int base) -{ - long result; - char sign; - - while (*str && isspace(Py_CHARMASK(*str))) - str++; - - sign = *str; - if (sign == '+' || sign == '-') - str++; - - result = (long) PyOS_strtoul(str, ptr, base); - - /* Signal overflow if the result appears negative, - except for the largest negative integer */ - if (result < 0 && !(sign == '-' && result == -result)) { - errno = ERANGE; - result = 0x7fffffff; - } - - if (sign == '-') - result = -result; - - return result; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/pyfpe.c b/SDKs/XPlatform/Cypython-2.3.3/Python/pyfpe.c deleted file mode 100644 index 7b686d24..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/pyfpe.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "pyconfig.h" -#include "pyfpe.h" -/* - * The signal handler for SIGFPE is actually declared in an external - * module fpectl, or as preferred by the user. These variable - * definitions are required in order to compile Python without - * getting missing externals, but to actually handle SIGFPE requires - * defining a handler and enabling generation of SIGFPE. - */ - -#ifdef WANT_SIGFPE_HANDLER -jmp_buf PyFPE_jbuf; -int PyFPE_counter = 0; -#endif - -/* Have this outside the above #ifdef, since some picky ANSI compilers issue a - warning when compiling an empty file. */ - -double -PyFPE_dummy(void *dummy) -{ - return 1.0; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/pystate.c b/SDKs/XPlatform/Cypython-2.3.3/Python/pystate.c deleted file mode 100644 index 1f173e1b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/pystate.c +++ /dev/null @@ -1,483 +0,0 @@ - -/* Thread and interpreter state structures and their interfaces */ - -#include "Python.h" - -#ifdef HAVE_DLOPEN -#ifdef HAVE_DLFCN_H -#include -#endif -#ifndef RTLD_LAZY -#define RTLD_LAZY 1 -#endif -#endif - - -#define ZAP(x) { \ - PyObject *tmp = (PyObject *)(x); \ - (x) = NULL; \ - Py_XDECREF(tmp); \ -} - - -#ifdef WITH_THREAD -#include "pythread.h" -static PyThread_type_lock head_mutex = NULL; /* Protects interp->tstate_head */ -#define HEAD_INIT() (void)(head_mutex || (head_mutex = PyThread_allocate_lock())) -#define HEAD_LOCK() PyThread_acquire_lock(head_mutex, WAIT_LOCK) -#define HEAD_UNLOCK() PyThread_release_lock(head_mutex) -#else -#define HEAD_INIT() /* Nothing */ -#define HEAD_LOCK() /* Nothing */ -#define HEAD_UNLOCK() /* Nothing */ -#endif - -static PyInterpreterState *interp_head = NULL; - -PyThreadState *_PyThreadState_Current = NULL; -PyThreadFrameGetter _PyThreadState_GetFrame = NULL; - - -PyInterpreterState * -PyInterpreterState_New(void) -{ - PyInterpreterState *interp = PyMem_NEW(PyInterpreterState, 1); - - if (interp != NULL) { - HEAD_INIT(); - interp->modules = NULL; - interp->sysdict = NULL; - interp->builtins = NULL; - interp->tstate_head = NULL; - interp->codec_search_path = NULL; - interp->codec_search_cache = NULL; - interp->codec_error_registry = NULL; -#ifdef HAVE_DLOPEN -#ifdef RTLD_NOW - interp->dlopenflags = RTLD_NOW; -#else - interp->dlopenflags = RTLD_LAZY; -#endif -#endif - - HEAD_LOCK(); - interp->next = interp_head; - interp_head = interp; - HEAD_UNLOCK(); - } - - return interp; -} - - -void -PyInterpreterState_Clear(PyInterpreterState *interp) -{ - PyThreadState *p; - HEAD_LOCK(); - for (p = interp->tstate_head; p != NULL; p = p->next) - PyThreadState_Clear(p); - HEAD_UNLOCK(); - ZAP(interp->codec_search_path); - ZAP(interp->codec_search_cache); - ZAP(interp->codec_error_registry); - ZAP(interp->modules); - ZAP(interp->sysdict); - ZAP(interp->builtins); -} - - -static void -zapthreads(PyInterpreterState *interp) -{ - PyThreadState *p; - /* No need to lock the mutex here because this should only happen - when the threads are all really dead (XXX famous last words). */ - while ((p = interp->tstate_head) != NULL) { - PyThreadState_Delete(p); - } -} - - -void -PyInterpreterState_Delete(PyInterpreterState *interp) -{ - PyInterpreterState **p; - zapthreads(interp); - HEAD_LOCK(); - for (p = &interp_head; ; p = &(*p)->next) { - if (*p == NULL) - Py_FatalError( - "PyInterpreterState_Delete: invalid interp"); - if (*p == interp) - break; - } - if (interp->tstate_head != NULL) - Py_FatalError("PyInterpreterState_Delete: remaining threads"); - *p = interp->next; - HEAD_UNLOCK(); - PyMem_DEL(interp); -} - - -/* Default implementation for _PyThreadState_GetFrame */ -static struct _frame * -threadstate_getframe(PyThreadState *self) -{ - return self->frame; -} - -PyThreadState * -PyThreadState_New(PyInterpreterState *interp) -{ - PyThreadState *tstate = PyMem_NEW(PyThreadState, 1); - if (_PyThreadState_GetFrame == NULL) - _PyThreadState_GetFrame = threadstate_getframe; - - if (tstate != NULL) { - tstate->interp = interp; - - tstate->frame = NULL; - tstate->recursion_depth = 0; - tstate->tracing = 0; - tstate->use_tracing = 0; - tstate->tick_counter = 0; - tstate->gilstate_counter = 0; - tstate->async_exc = NULL; -#ifdef WITH_THREAD - tstate->thread_id = PyThread_get_thread_ident(); -#else - tstate->thread_id = 0; -#endif - - tstate->dict = NULL; - - tstate->curexc_type = NULL; - tstate->curexc_value = NULL; - tstate->curexc_traceback = NULL; - - tstate->exc_type = NULL; - tstate->exc_value = NULL; - tstate->exc_traceback = NULL; - - tstate->c_profilefunc = NULL; - tstate->c_tracefunc = NULL; - tstate->c_profileobj = NULL; - tstate->c_traceobj = NULL; - - HEAD_LOCK(); - tstate->next = interp->tstate_head; - interp->tstate_head = tstate; - HEAD_UNLOCK(); - } - - return tstate; -} - - -void -PyThreadState_Clear(PyThreadState *tstate) -{ - if (Py_VerboseFlag && tstate->frame != NULL) - fprintf(stderr, - "PyThreadState_Clear: warning: thread still has a frame\n"); - - ZAP(tstate->frame); - - ZAP(tstate->dict); - ZAP(tstate->async_exc); - - ZAP(tstate->curexc_type); - ZAP(tstate->curexc_value); - ZAP(tstate->curexc_traceback); - - ZAP(tstate->exc_type); - ZAP(tstate->exc_value); - ZAP(tstate->exc_traceback); - - tstate->c_profilefunc = NULL; - tstate->c_tracefunc = NULL; - ZAP(tstate->c_profileobj); - ZAP(tstate->c_traceobj); -} - - -/* Common code for PyThreadState_Delete() and PyThreadState_DeleteCurrent() */ -static void -tstate_delete_common(PyThreadState *tstate) -{ - PyInterpreterState *interp; - PyThreadState **p; - if (tstate == NULL) - Py_FatalError("PyThreadState_Delete: NULL tstate"); - interp = tstate->interp; - if (interp == NULL) - Py_FatalError("PyThreadState_Delete: NULL interp"); - HEAD_LOCK(); - for (p = &interp->tstate_head; ; p = &(*p)->next) { - if (*p == NULL) - Py_FatalError( - "PyThreadState_Delete: invalid tstate"); - if (*p == tstate) - break; - } - *p = tstate->next; - HEAD_UNLOCK(); - PyMem_DEL(tstate); -} - - -void -PyThreadState_Delete(PyThreadState *tstate) -{ - if (tstate == _PyThreadState_Current) - Py_FatalError("PyThreadState_Delete: tstate is still current"); - tstate_delete_common(tstate); -} - - -#ifdef WITH_THREAD -void -PyThreadState_DeleteCurrent() -{ - PyThreadState *tstate = _PyThreadState_Current; - if (tstate == NULL) - Py_FatalError( - "PyThreadState_DeleteCurrent: no current tstate"); - _PyThreadState_Current = NULL; - tstate_delete_common(tstate); - PyEval_ReleaseLock(); -} -#endif /* WITH_THREAD */ - - -PyThreadState * -PyThreadState_Get(void) -{ - if (_PyThreadState_Current == NULL) - Py_FatalError("PyThreadState_Get: no current thread"); - - return _PyThreadState_Current; -} - - -PyThreadState * -PyThreadState_Swap(PyThreadState *new) -{ - PyThreadState *old = _PyThreadState_Current; - - _PyThreadState_Current = new; - /* It should not be possible for more than one thread state - to be used for a thread. Check this the best we can in debug - builds. - */ -#if defined(Py_DEBUG) && defined(WITH_THREAD) - if (new) { - PyThreadState *check = PyGILState_GetThisThreadState(); - if (check && check != new) - Py_FatalError("Invalid thread state for this thread"); - } -#endif - return old; -} - -/* An extension mechanism to store arbitrary additional per-thread state. - PyThreadState_GetDict() returns a dictionary that can be used to hold such - state; the caller should pick a unique key and store its state there. If - PyThreadState_GetDict() returns NULL, an exception has *not* been raised - and the caller should assume no per-thread state is available. */ - -PyObject * -PyThreadState_GetDict(void) -{ - if (_PyThreadState_Current == NULL) - return NULL; - - if (_PyThreadState_Current->dict == NULL) { - PyObject *d; - _PyThreadState_Current->dict = d = PyDict_New(); - if (d == NULL) - PyErr_Clear(); - } - return _PyThreadState_Current->dict; -} - - -/* Asynchronously raise an exception in a thread. - Requested by Just van Rossum and Alex Martelli. - To prevent naive misuse, you must write your own exception - to call this. Must be called with the GIL held. - Returns the number of tstates modified; if it returns a number - greater than one, you're in trouble, and you should call it again - with exc=NULL to revert the effect. This raises no exceptions. */ - -int -PyThreadState_SetAsyncExc(long id, PyObject *exc) { - PyThreadState *tstate = PyThreadState_Get(); - PyInterpreterState *interp = tstate->interp; - PyThreadState *p; - int count = 0; - for (p = interp->tstate_head; p != NULL; p = p->next) { - if (p->thread_id != id) - continue; - ZAP(p->async_exc); - Py_XINCREF(exc); - p->async_exc = exc; - count += 1; - } - return count; -} - - -/* Routines for advanced debuggers, requested by David Beazley. - Don't use unless you know what you are doing! */ - -PyInterpreterState * -PyInterpreterState_Head(void) -{ - return interp_head; -} - -PyInterpreterState * -PyInterpreterState_Next(PyInterpreterState *interp) { - return interp->next; -} - -PyThreadState * -PyInterpreterState_ThreadHead(PyInterpreterState *interp) { - return interp->tstate_head; -} - -PyThreadState * -PyThreadState_Next(PyThreadState *tstate) { - return tstate->next; -} - - -/* Python "auto thread state" API. */ -#ifdef WITH_THREAD - -/* Keep this as a static, as it is not reliable! It can only - ever be compared to the state for the *current* thread. - * If not equal, then it doesn't matter that the actual - value may change immediately after comparison, as it can't - possibly change to the current thread's state. - * If equal, then the current thread holds the lock, so the value can't - change until we yield the lock. -*/ -static int -PyThreadState_IsCurrent(PyThreadState *tstate) -{ - /* Must be the tstate for this thread */ - assert(PyGILState_GetThisThreadState()==tstate); - /* On Windows at least, simple reads and writes to 32 bit values - are atomic. - */ - return tstate == _PyThreadState_Current; -} - -/* The single PyInterpreterState used by this process' - GILState implementation -*/ -static PyInterpreterState *autoInterpreterState = NULL; -static int autoTLSkey = 0; - -/* Internal initialization/finalization functions called by - Py_Initialize/Py_Finalize -*/ -void _PyGILState_Init(PyInterpreterState *i, PyThreadState *t) -{ - assert(i && t); /* must init with a valid states */ - autoTLSkey = PyThread_create_key(); - autoInterpreterState = i; - /* Now stash the thread state for this thread in TLS */ - PyThread_set_key_value(autoTLSkey, (void *)t); - assert(t->gilstate_counter==0); /* must be a new thread state */ - t->gilstate_counter = 1; -} - -void _PyGILState_Fini(void) -{ - PyThread_delete_key(autoTLSkey); - autoTLSkey = 0; - autoInterpreterState = NULL;; -} - -/* The public functions */ -PyThreadState *PyGILState_GetThisThreadState(void) -{ - if (autoInterpreterState==NULL || autoTLSkey==0) - return NULL; - return (PyThreadState *) PyThread_get_key_value(autoTLSkey); -} - -PyGILState_STATE PyGILState_Ensure(void) -{ - int current; - PyThreadState *tcur; - /* Note that we do not auto-init Python here - apart from - potential races with 2 threads auto-initializing, pep-311 - spells out other issues. Embedders are expected to have - called Py_Initialize() and usually PyEval_InitThreads(). - */ - assert(autoInterpreterState); /* Py_Initialize() hasn't been called! */ - tcur = PyThread_get_key_value(autoTLSkey); - if (tcur==NULL) { - /* Create a new thread state for this thread */ - tcur = PyThreadState_New(autoInterpreterState); - if (tcur==NULL) - Py_FatalError("Couldn't create thread-state for new thread"); - PyThread_set_key_value(autoTLSkey, (void *)tcur); - current = 0; /* new thread state is never current */ - } else - current = PyThreadState_IsCurrent(tcur); - if (!current) - PyEval_RestoreThread(tcur); - /* Update our counter in the thread-state - no need for locks: - - tcur will remain valid as we hold the GIL. - - the counter is safe as we are the only thread "allowed" - to modify this value - */ - tcur->gilstate_counter++; - return current ? PyGILState_LOCKED : PyGILState_UNLOCKED; -} - -void PyGILState_Release(PyGILState_STATE oldstate) -{ - PyThreadState *tcur = PyThread_get_key_value(autoTLSkey); - if (tcur==NULL) - Py_FatalError("auto-releasing thread-state, " - "but no thread-state for this thread"); - /* We must hold the GIL and have our thread state current */ - /* XXX - remove the check - the assert should be fine, - but while this is very new (April 2003), the extra check - by release-only users can't hurt. - */ - if (!PyThreadState_IsCurrent(tcur)) - Py_FatalError("This thread state must be current when releasing"); - assert (PyThreadState_IsCurrent(tcur)); - tcur->gilstate_counter -= 1; - assert (tcur->gilstate_counter >= 0); /* illegal counter value */ - - /* If we are about to destroy this thread-state, we must - clear it while the lock is held, as destructors may run - */ - if (tcur->gilstate_counter==0) { - /* can't have been locked when we created it */ - assert(oldstate==PyGILState_UNLOCKED); - PyThreadState_Clear(tcur); - } - - /* Release the lock if necessary */ - if (oldstate==PyGILState_UNLOCKED) - PyEval_ReleaseThread(tcur); - - /* Now complete destruction of the thread if necessary */ - if (tcur->gilstate_counter==0) { - /* Delete this thread from our TLS */ - PyThread_delete_key_value(autoTLSkey); - /* Delete the thread-state */ - PyThreadState_Delete(tcur); - } -} -#endif /* WITH_THREAD */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/pythonrun.c b/SDKs/XPlatform/Cypython-2.3.3/Python/pythonrun.c deleted file mode 100644 index 9854e859..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/pythonrun.c +++ /dev/null @@ -1,1724 +0,0 @@ - -/* Python interpreter top-level routines, including init/exit */ - -#include "Python.h" - -#include "grammar.h" -#include "node.h" -#include "token.h" -#include "parsetok.h" -#include "errcode.h" -#include "compile.h" -#include "symtable.h" -#include "eval.h" -#include "marshal.h" - -#ifdef HAVE_SIGNAL_H -#include -#endif - -#ifdef HAVE_LANGINFO_H -#include -#include -#endif - -#ifdef MS_WINDOWS -#undef BYTE -#ifdef MS_XBOX -#include -#else -#include "windows.h" -#endif -#endif - -#ifdef macintosh -#include "macglue.h" -#endif -extern char *Py_GetPath(void); - -extern grammar _PyParser_Grammar; /* From graminit.c */ - -/* Forward */ -static void initmain(void); -static void initsite(void); -static PyObject *run_err_node(node *, const char *, PyObject *, PyObject *, - PyCompilerFlags *); -static PyObject *run_node(node *, const char *, PyObject *, PyObject *, - PyCompilerFlags *); -static PyObject *run_pyc_file(FILE *, const char *, PyObject *, PyObject *, - PyCompilerFlags *); -static void err_input(perrdetail *); -static void initsigs(void); -static void call_sys_exitfunc(void); -static void call_ll_exitfuncs(void); -extern void _PyUnicode_Init(void); -extern void _PyUnicode_Fini(void); - -#ifdef WITH_THREAD -extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *); -extern void _PyGILState_Fini(void); -#endif /* WITH_THREAD */ - -int Py_DebugFlag; /* Needed by parser.c */ -int Py_VerboseFlag; /* Needed by import.c */ -int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */ -int Py_NoSiteFlag; /* Suppress 'import site' */ -int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */ -int Py_FrozenFlag; /* Needed by getpath.c */ -int Py_UnicodeFlag = 0; /* Needed by compile.c */ -int Py_IgnoreEnvironmentFlag; /* e.g. PYTHONPATH, PYTHONHOME */ -/* _XXX Py_QnewFlag should go away in 2.3. It's true iff -Qnew is passed, - on the command line, and is used in 2.2 by ceval.c to make all "/" divisions - true divisions (which they will be in 2.3). */ -int _Py_QnewFlag = 0; - -/* Reference to 'warnings' module, to avoid importing it - on the fly when the import lock may be held. See 683658/771097 -*/ -static PyObject *warnings_module = NULL; - -/* Returns a borrowed reference to the 'warnings' module, or NULL. - If the module is returned, it is guaranteed to have been obtained - without acquiring the import lock -*/ -PyObject *PyModule_GetWarningsModule(void) -{ - PyObject *typ, *val, *tb; - PyObject *all_modules; - /* If we managed to get the module at init time, just use it */ - if (warnings_module) - return warnings_module; - /* If it wasn't available at init time, it may be available - now in sys.modules (common scenario is frozen apps: import - at init time fails, but the frozen init code sets up sys.path - correctly, then does an implicit import of warnings for us - */ - /* Save and restore any exceptions */ - PyErr_Fetch(&typ, &val, &tb); - - all_modules = PySys_GetObject("modules"); - if (all_modules) { - warnings_module = PyDict_GetItemString(all_modules, "warnings"); - /* We keep a ref in the global */ - Py_XINCREF(warnings_module); - } - PyErr_Restore(typ, val, tb); - return warnings_module; -} - -static int initialized = 0; - -/* API to access the initialized flag -- useful for esoteric use */ - -int -Py_IsInitialized(void) -{ - return initialized; -} - -/* Global initializations. Can be undone by Py_Finalize(). Don't - call this twice without an intervening Py_Finalize() call. When - initializations fail, a fatal error is issued and the function does - not return. On return, the first thread and interpreter state have - been created. - - Locking: you must hold the interpreter lock while calling this. - (If the lock has not yet been initialized, that's equivalent to - having the lock, but you cannot use multiple threads.) - -*/ - -static int -add_flag(int flag, const char *envs) -{ - int env = atoi(envs); - if (flag < env) - flag = env; - if (flag < 1) - flag = 1; - return flag; -} - -void -Py_Initialize(void) -{ - PyInterpreterState *interp; - PyThreadState *tstate; - PyObject *bimod, *sysmod; - char *p; -#if defined(Py_USING_UNICODE) && defined(HAVE_LANGINFO_H) && defined(CODESET) - char *codeset; - char *saved_locale; - PyObject *sys_stream, *sys_isatty; -#endif - extern void _Py_ReadyTypes(void); - - if (initialized) - return; - initialized = 1; - - if ((p = Py_GETENV("PYTHONDEBUG")) && *p != '\0') - Py_DebugFlag = add_flag(Py_DebugFlag, p); - if ((p = Py_GETENV("PYTHONVERBOSE")) && *p != '\0') - Py_VerboseFlag = add_flag(Py_VerboseFlag, p); - if ((p = Py_GETENV("PYTHONOPTIMIZE")) && *p != '\0') - Py_OptimizeFlag = add_flag(Py_OptimizeFlag, p); - - interp = PyInterpreterState_New(); - if (interp == NULL) - Py_FatalError("Py_Initialize: can't make first interpreter"); - - tstate = PyThreadState_New(interp); - if (tstate == NULL) - Py_FatalError("Py_Initialize: can't make first thread"); - (void) PyThreadState_Swap(tstate); - - _Py_ReadyTypes(); - - if (!_PyFrame_Init()) - Py_FatalError("Py_Initialize: can't init frames"); - - if (!_PyInt_Init()) - Py_FatalError("Py_Initialize: can't init ints"); - - interp->modules = PyDict_New(); - if (interp->modules == NULL) - Py_FatalError("Py_Initialize: can't make modules dictionary"); - -#ifdef Py_USING_UNICODE - /* Init Unicode implementation; relies on the codec registry */ - _PyUnicode_Init(); -#endif - - bimod = _PyBuiltin_Init(); - if (bimod == NULL) - Py_FatalError("Py_Initialize: can't initialize __builtin__"); - interp->builtins = PyModule_GetDict(bimod); - Py_INCREF(interp->builtins); - - sysmod = _PySys_Init(); - if (sysmod == NULL) - Py_FatalError("Py_Initialize: can't initialize sys"); - interp->sysdict = PyModule_GetDict(sysmod); - Py_INCREF(interp->sysdict); - _PyImport_FixupExtension("sys", "sys"); - PySys_SetPath(Py_GetPath()); - PyDict_SetItemString(interp->sysdict, "modules", - interp->modules); - - _PyImport_Init(); - - /* initialize builtin exceptions */ - _PyExc_Init(); - _PyImport_FixupExtension("exceptions", "exceptions"); - - /* phase 2 of builtins */ - _PyImport_FixupExtension("__builtin__", "__builtin__"); - - _PyImportHooks_Init(); - - initsigs(); /* Signal handling stuff, including initintr() */ - - initmain(); /* Module __main__ */ - if (!Py_NoSiteFlag) - initsite(); /* Module site */ - - /* auto-thread-state API, if available */ -#ifdef WITH_THREAD - _PyGILState_Init(interp, tstate); -#endif /* WITH_THREAD */ - - warnings_module = PyImport_ImportModule("warnings"); - if (!warnings_module) - PyErr_Clear(); - -#if defined(Py_USING_UNICODE) && defined(HAVE_LANGINFO_H) && defined(CODESET) - /* On Unix, set the file system encoding according to the - user's preference, if the CODESET names a well-known - Python codec, and Py_FileSystemDefaultEncoding isn't - initialized by other means. Also set the encoding of - stdin and stdout if these are terminals. */ - - saved_locale = strdup(setlocale(LC_CTYPE, NULL)); - setlocale(LC_CTYPE, ""); - codeset = nl_langinfo(CODESET); - if (codeset && *codeset) { - PyObject *enc = PyCodec_Encoder(codeset); - if (enc) { - codeset = strdup(codeset); - Py_DECREF(enc); - } else { - codeset = NULL; - PyErr_Clear(); - } - } else - codeset = NULL; - setlocale(LC_CTYPE, saved_locale); - free(saved_locale); - - if (codeset) { - sys_stream = PySys_GetObject("stdin"); - sys_isatty = PyObject_CallMethod(sys_stream, "isatty", ""); - if (!sys_isatty) - PyErr_Clear(); - if(sys_isatty && PyObject_IsTrue(sys_isatty)) { - if (!PyFile_SetEncoding(sys_stream, codeset)) - Py_FatalError("Cannot set codeset of stdin"); - } - Py_XDECREF(sys_isatty); - - sys_stream = PySys_GetObject("stdout"); - sys_isatty = PyObject_CallMethod(sys_stream, "isatty", ""); - if (!sys_isatty) - PyErr_Clear(); - if(sys_isatty && PyObject_IsTrue(sys_isatty)) { - if (!PyFile_SetEncoding(sys_stream, codeset)) - Py_FatalError("Cannot set codeset of stdout"); - } - Py_XDECREF(sys_isatty); - - if (!Py_FileSystemDefaultEncoding) - Py_FileSystemDefaultEncoding = codeset; - else - free(codeset); - } -#endif -} - -#ifdef COUNT_ALLOCS -extern void dump_counts(void); -#endif - -/* Undo the effect of Py_Initialize(). - - Beware: if multiple interpreter and/or thread states exist, these - are not wiped out; only the current thread and interpreter state - are deleted. But since everything else is deleted, those other - interpreter and thread states should no longer be used. - - (XXX We should do better, e.g. wipe out all interpreters and - threads.) - - Locking: as above. - -*/ - -void -Py_Finalize(void) -{ - PyInterpreterState *interp; - PyThreadState *tstate; - - if (!initialized) - return; - - /* The interpreter is still entirely intact at this point, and the - * exit funcs may be relying on that. In particular, if some thread - * or exit func is still waiting to do an import, the import machinery - * expects Py_IsInitialized() to return true. So don't say the - * interpreter is uninitialized until after the exit funcs have run. - * Note that Threading.py uses an exit func to do a join on all the - * threads created thru it, so this also protects pending imports in - * the threads created via Threading. - */ - call_sys_exitfunc(); - initialized = 0; - - /* Get current thread state and interpreter pointer */ - tstate = PyThreadState_Get(); - interp = tstate->interp; - - /* Disable signal handling */ - PyOS_FiniInterrupts(); - - /* drop module references we saved */ - Py_XDECREF(warnings_module); - warnings_module = NULL; - - /* Collect garbage. This may call finalizers; it's nice to call these - * before all modules are destroyed. - * XXX If a __del__ or weakref callback is triggered here, and tries to - * XXX import a module, bad things can happen, because Python no - * XXX longer believes it's initialized. - * XXX Fatal Python error: Interpreter not initialized (version mismatch?) - * XXX is easy to provoke that way. I've also seen, e.g., - * XXX Exception exceptions.ImportError: 'No module named sha' - * XXX in ignored - * XXX but I'm unclear on exactly how that one happens. In any case, - * XXX I haven't seen a real-life report of either of these. - */ - PyGC_Collect(); - - /* Destroy all modules */ - PyImport_Cleanup(); - - /* Collect final garbage. This disposes of cycles created by - * new-style class definitions, for example. - * XXX This is disabled because it caused too many problems. If - * XXX a __del__ or weakref callback triggers here, Python code has - * XXX a hard time running, because even the sys module has been - * XXX cleared out (sys.stdout is gone, sys.excepthook is gone, etc). - * XXX One symptom is a sequence of information-free messages - * XXX coming from threads (if a __del__ or callback is invoked, - * XXX other threads can execute too, and any exception they encounter - * XXX triggers a comedy of errors as subsystem after subsystem - * XXX fails to find what it *expects* to find in sys to help report - * XXX the exception and consequent unexpected failures). I've also - * XXX seen segfaults then, after adding print statements to the - * XXX Python code getting called. - */ -#if 0 - PyGC_Collect(); -#endif - - /* Destroy the database used by _PyImport_{Fixup,Find}Extension */ - _PyImport_Fini(); - - /* Debugging stuff */ -#ifdef COUNT_ALLOCS - dump_counts(); -#endif - -#ifdef Py_REF_DEBUG - fprintf(stderr, "[%ld refs]\n", _Py_RefTotal); -#endif - -#ifdef Py_TRACE_REFS - /* Display all objects still alive -- this can invoke arbitrary - * __repr__ overrides, so requires a mostly-intact interpreter. - * Alas, a lot of stuff may still be alive now that will be cleaned - * up later. - */ - if (Py_GETENV("PYTHONDUMPREFS")) - _Py_PrintReferences(stderr); -#endif /* Py_TRACE_REFS */ - - /* Now we decref the exception classes. After this point nothing - can raise an exception. That's okay, because each Fini() method - below has been checked to make sure no exceptions are ever - raised. - */ - _PyExc_Fini(); - - /* Cleanup auto-thread-state */ -#ifdef WITH_THREAD - _PyGILState_Fini(); -#endif /* WITH_THREAD */ - - /* Clear interpreter state */ - PyInterpreterState_Clear(interp); - - /* Delete current thread */ - PyThreadState_Swap(NULL); - PyInterpreterState_Delete(interp); - - /* Sundry finalizers */ - PyMethod_Fini(); - PyFrame_Fini(); - PyCFunction_Fini(); - PyTuple_Fini(); - PyString_Fini(); - PyInt_Fini(); - PyFloat_Fini(); - -#ifdef Py_USING_UNICODE - /* Cleanup Unicode implementation */ - _PyUnicode_Fini(); -#endif - - /* XXX Still allocated: - - various static ad-hoc pointers to interned strings - - int and float free list blocks - - whatever various modules and libraries allocate - */ - - PyGrammar_RemoveAccelerators(&_PyParser_Grammar); - -#ifdef Py_TRACE_REFS - /* Display addresses (& refcnts) of all objects still alive. - * An address can be used to find the repr of the object, printed - * above by _Py_PrintReferences. - */ - if (Py_GETENV("PYTHONDUMPREFS")) - _Py_PrintReferenceAddresses(stderr); -#endif /* Py_TRACE_REFS */ -#ifdef PYMALLOC_DEBUG - if (Py_GETENV("PYTHONMALLOCSTATS")) - _PyObject_DebugMallocStats(); -#endif - - call_ll_exitfuncs(); -} - -/* Create and initialize a new interpreter and thread, and return the - new thread. This requires that Py_Initialize() has been called - first. - - Unsuccessful initialization yields a NULL pointer. Note that *no* - exception information is available even in this case -- the - exception information is held in the thread, and there is no - thread. - - Locking: as above. - -*/ - -PyThreadState * -Py_NewInterpreter(void) -{ - PyInterpreterState *interp; - PyThreadState *tstate, *save_tstate; - PyObject *bimod, *sysmod; - - if (!initialized) - Py_FatalError("Py_NewInterpreter: call Py_Initialize first"); - - interp = PyInterpreterState_New(); - if (interp == NULL) - return NULL; - - tstate = PyThreadState_New(interp); - if (tstate == NULL) { - PyInterpreterState_Delete(interp); - return NULL; - } - - save_tstate = PyThreadState_Swap(tstate); - - /* XXX The following is lax in error checking */ - - interp->modules = PyDict_New(); - - bimod = _PyImport_FindExtension("__builtin__", "__builtin__"); - if (bimod != NULL) { - interp->builtins = PyModule_GetDict(bimod); - Py_INCREF(interp->builtins); - } - sysmod = _PyImport_FindExtension("sys", "sys"); - if (bimod != NULL && sysmod != NULL) { - interp->sysdict = PyModule_GetDict(sysmod); - Py_INCREF(interp->sysdict); - PySys_SetPath(Py_GetPath()); - PyDict_SetItemString(interp->sysdict, "modules", - interp->modules); - _PyImportHooks_Init(); - initmain(); - if (!Py_NoSiteFlag) - initsite(); - } - - if (!PyErr_Occurred()) - return tstate; - - /* Oops, it didn't work. Undo it all. */ - - PyErr_Print(); - PyThreadState_Clear(tstate); - PyThreadState_Swap(save_tstate); - PyThreadState_Delete(tstate); - PyInterpreterState_Delete(interp); - - return NULL; -} - -/* Delete an interpreter and its last thread. This requires that the - given thread state is current, that the thread has no remaining - frames, and that it is its interpreter's only remaining thread. - It is a fatal error to violate these constraints. - - (Py_Finalize() doesn't have these constraints -- it zaps - everything, regardless.) - - Locking: as above. - -*/ - -void -Py_EndInterpreter(PyThreadState *tstate) -{ - PyInterpreterState *interp = tstate->interp; - - if (tstate != PyThreadState_Get()) - Py_FatalError("Py_EndInterpreter: thread is not current"); - if (tstate->frame != NULL) - Py_FatalError("Py_EndInterpreter: thread still has a frame"); - if (tstate != interp->tstate_head || tstate->next != NULL) - Py_FatalError("Py_EndInterpreter: not the last thread"); - - PyImport_Cleanup(); - PyInterpreterState_Clear(interp); - PyThreadState_Swap(NULL); - PyInterpreterState_Delete(interp); -} - -static char *progname = "python"; - -void -Py_SetProgramName(char *pn) -{ - if (pn && *pn) - progname = pn; -} - -char * -Py_GetProgramName(void) -{ - return progname; -} - -static char *default_home = NULL; - -void -Py_SetPythonHome(char *home) -{ - default_home = home; -} - -char * -Py_GetPythonHome(void) -{ - char *home = default_home; - if (home == NULL && !Py_IgnoreEnvironmentFlag) - home = Py_GETENV("PYTHONHOME"); - return home; -} - -/* Create __main__ module */ - -static void -initmain(void) -{ - PyObject *m, *d; - m = PyImport_AddModule("__main__"); - if (m == NULL) - Py_FatalError("can't create __main__ module"); - d = PyModule_GetDict(m); - if (PyDict_GetItemString(d, "__builtins__") == NULL) { - PyObject *bimod = PyImport_ImportModule("__builtin__"); - if (bimod == NULL || - PyDict_SetItemString(d, "__builtins__", bimod) != 0) - Py_FatalError("can't add __builtins__ to __main__"); - Py_DECREF(bimod); - } -} - -/* Import the site module (not into __main__ though) */ - -static void -initsite(void) -{ - PyObject *m, *f; - m = PyImport_ImportModule("site"); - if (m == NULL) { - f = PySys_GetObject("stderr"); - if (Py_VerboseFlag) { - PyFile_WriteString( - "'import site' failed; traceback:\n", f); - PyErr_Print(); - } - else { - PyFile_WriteString( - "'import site' failed; use -v for traceback\n", f); - PyErr_Clear(); - } - } - else { - Py_DECREF(m); - } -} - -/* Parse input from a file and execute it */ - -int -PyRun_AnyFile(FILE *fp, const char *filename) -{ - return PyRun_AnyFileExFlags(fp, filename, 0, NULL); -} - -int -PyRun_AnyFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags) -{ - return PyRun_AnyFileExFlags(fp, filename, 0, flags); -} - -int -PyRun_AnyFileEx(FILE *fp, const char *filename, int closeit) -{ - return PyRun_AnyFileExFlags(fp, filename, closeit, NULL); -} - -int -PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, - PyCompilerFlags *flags) -{ - if (filename == NULL) - filename = "???"; - if (Py_FdIsInteractive(fp, filename)) { - int err = PyRun_InteractiveLoopFlags(fp, filename, flags); - if (closeit) - fclose(fp); - return err; - } - else - return PyRun_SimpleFileExFlags(fp, filename, closeit, flags); -} - -int -PyRun_InteractiveLoop(FILE *fp, const char *filename) -{ - return PyRun_InteractiveLoopFlags(fp, filename, NULL); -} - -int -PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags) -{ - PyObject *v; - int ret; - PyCompilerFlags local_flags; - - if (flags == NULL) { - flags = &local_flags; - local_flags.cf_flags = 0; - } - v = PySys_GetObject("ps1"); - if (v == NULL) { - PySys_SetObject("ps1", v = PyString_FromString(">>> ")); - Py_XDECREF(v); - } - v = PySys_GetObject("ps2"); - if (v == NULL) { - PySys_SetObject("ps2", v = PyString_FromString("... ")); - Py_XDECREF(v); - } - for (;;) { - ret = PyRun_InteractiveOneFlags(fp, filename, flags); -#ifdef Py_REF_DEBUG - fprintf(stderr, "[%ld refs]\n", _Py_RefTotal); -#endif - if (ret == E_EOF) - return 0; - /* - if (ret == E_NOMEM) - return -1; - */ - } -} - -int -PyRun_InteractiveOne(FILE *fp, const char *filename) -{ - return PyRun_InteractiveOneFlags(fp, filename, NULL); -} - -/* compute parser flags based on compiler flags */ -#define PARSER_FLAGS(flags) \ - (((flags) && (flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \ - PyPARSE_DONT_IMPLY_DEDENT : 0) - -int -PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags) -{ - PyObject *m, *d, *v, *w; - node *n; - perrdetail err; - char *ps1 = "", *ps2 = ""; - - v = PySys_GetObject("ps1"); - if (v != NULL) { - v = PyObject_Str(v); - if (v == NULL) - PyErr_Clear(); - else if (PyString_Check(v)) - ps1 = PyString_AsString(v); - } - w = PySys_GetObject("ps2"); - if (w != NULL) { - w = PyObject_Str(w); - if (w == NULL) - PyErr_Clear(); - else if (PyString_Check(w)) - ps2 = PyString_AsString(w); - } - n = PyParser_ParseFileFlags(fp, filename, &_PyParser_Grammar, - Py_single_input, ps1, ps2, &err, - PARSER_FLAGS(flags)); - Py_XDECREF(v); - Py_XDECREF(w); - if (n == NULL) { - if (err.error == E_EOF) { - if (err.text) - PyMem_DEL(err.text); - return E_EOF; - } - err_input(&err); - PyErr_Print(); - return err.error; - } - m = PyImport_AddModule("__main__"); - if (m == NULL) - return -1; - d = PyModule_GetDict(m); - v = run_node(n, filename, d, d, flags); - if (v == NULL) { - PyErr_Print(); - return -1; - } - Py_DECREF(v); - if (Py_FlushLine()) - PyErr_Clear(); - return 0; -} - -int -PyRun_SimpleFile(FILE *fp, const char *filename) -{ - return PyRun_SimpleFileEx(fp, filename, 0); -} - -/* Check whether a file maybe a pyc file: Look at the extension, - the file type, and, if we may close it, at the first few bytes. */ - -static int -maybe_pyc_file(FILE *fp, const char* filename, const char* ext, int closeit) -{ - if (strcmp(ext, ".pyc") == 0 || strcmp(ext, ".pyo") == 0) - return 1; - -#ifdef macintosh - /* On a mac, we also assume a pyc file for types 'PYC ' and 'APPL' */ - if (PyMac_getfiletype((char *)filename) == 'PYC ' - || PyMac_getfiletype((char *)filename) == 'APPL') - return 1; -#endif /* macintosh */ - - /* Only look into the file if we are allowed to close it, since - it then should also be seekable. */ - if (closeit) { - /* Read only two bytes of the magic. If the file was opened in - text mode, the bytes 3 and 4 of the magic (\r\n) might not - be read as they are on disk. */ - unsigned int halfmagic = PyImport_GetMagicNumber() & 0xFFFF; - unsigned char buf[2]; - /* Mess: In case of -x, the stream is NOT at its start now, - and ungetc() was used to push back the first newline, - which makes the current stream position formally undefined, - and a x-platform nightmare. - Unfortunately, we have no direct way to know whether -x - was specified. So we use a terrible hack: if the current - stream position is not 0, we assume -x was specified, and - give up. Bug 132850 on SourceForge spells out the - hopelessness of trying anything else (fseek and ftell - don't work predictably x-platform for text-mode files). - */ - int ispyc = 0; - if (ftell(fp) == 0) { - if (fread(buf, 1, 2, fp) == 2 && - ((unsigned int)buf[1]<<8 | buf[0]) == halfmagic) - ispyc = 1; - rewind(fp); - } - return ispyc; - } - return 0; -} - -int -PyRun_SimpleFileEx(FILE *fp, const char *filename, int closeit) -{ - return PyRun_SimpleFileExFlags(fp, filename, closeit, NULL); -} - -int -PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, - PyCompilerFlags *flags) -{ - PyObject *m, *d, *v; - const char *ext; - - m = PyImport_AddModule("__main__"); - if (m == NULL) - return -1; - d = PyModule_GetDict(m); - if (PyDict_GetItemString(d, "__file__") == NULL) { - PyObject *f = PyString_FromString(filename); - if (f == NULL) - return -1; - if (PyDict_SetItemString(d, "__file__", f) < 0) { - Py_DECREF(f); - return -1; - } - Py_DECREF(f); - } - ext = filename + strlen(filename) - 4; - if (maybe_pyc_file(fp, filename, ext, closeit)) { - /* Try to run a pyc file. First, re-open in binary */ - if (closeit) - fclose(fp); - if ((fp = fopen(filename, "rb")) == NULL) { - fprintf(stderr, "python: Can't reopen .pyc file\n"); - return -1; - } - /* Turn on optimization if a .pyo file is given */ - if (strcmp(ext, ".pyo") == 0) - Py_OptimizeFlag = 1; - v = run_pyc_file(fp, filename, d, d, flags); - } else { - v = PyRun_FileExFlags(fp, filename, Py_file_input, d, d, - closeit, flags); - } - if (v == NULL) { - PyErr_Print(); - return -1; - } - Py_DECREF(v); - if (Py_FlushLine()) - PyErr_Clear(); - return 0; -} - -int -PyRun_SimpleString(const char *command) -{ - return PyRun_SimpleStringFlags(command, NULL); -} - -int -PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags) -{ - PyObject *m, *d, *v; - m = PyImport_AddModule("__main__"); - if (m == NULL) - return -1; - d = PyModule_GetDict(m); - v = PyRun_StringFlags(command, Py_file_input, d, d, flags); - if (v == NULL) { - PyErr_Print(); - return -1; - } - Py_DECREF(v); - if (Py_FlushLine()) - PyErr_Clear(); - return 0; -} - -static int -parse_syntax_error(PyObject *err, PyObject **message, const char **filename, - int *lineno, int *offset, const char **text) -{ - long hold; - PyObject *v; - - /* old style errors */ - if (PyTuple_Check(err)) - return PyArg_ParseTuple(err, "O(ziiz)", message, filename, - lineno, offset, text); - - /* new style errors. `err' is an instance */ - - if (! (v = PyObject_GetAttrString(err, "msg"))) - goto finally; - *message = v; - - if (!(v = PyObject_GetAttrString(err, "filename"))) - goto finally; - if (v == Py_None) - *filename = NULL; - else if (! (*filename = PyString_AsString(v))) - goto finally; - - Py_DECREF(v); - if (!(v = PyObject_GetAttrString(err, "lineno"))) - goto finally; - hold = PyInt_AsLong(v); - Py_DECREF(v); - v = NULL; - if (hold < 0 && PyErr_Occurred()) - goto finally; - *lineno = (int)hold; - - if (!(v = PyObject_GetAttrString(err, "offset"))) - goto finally; - if (v == Py_None) { - *offset = -1; - Py_DECREF(v); - v = NULL; - } else { - hold = PyInt_AsLong(v); - Py_DECREF(v); - v = NULL; - if (hold < 0 && PyErr_Occurred()) - goto finally; - *offset = (int)hold; - } - - if (!(v = PyObject_GetAttrString(err, "text"))) - goto finally; - if (v == Py_None) - *text = NULL; - else if (! (*text = PyString_AsString(v))) - goto finally; - Py_DECREF(v); - return 1; - -finally: - Py_XDECREF(v); - return 0; -} - -void -PyErr_Print(void) -{ - PyErr_PrintEx(1); -} - -static void -print_error_text(PyObject *f, int offset, const char *text) -{ - char *nl; - if (offset >= 0) { - if (offset > 0 && offset == (int)strlen(text)) - offset--; - for (;;) { - nl = strchr(text, '\n'); - if (nl == NULL || nl-text >= offset) - break; - offset -= (nl+1-text); - text = nl+1; - } - while (*text == ' ' || *text == '\t') { - text++; - offset--; - } - } - PyFile_WriteString(" ", f); - PyFile_WriteString(text, f); - if (*text == '\0' || text[strlen(text)-1] != '\n') - PyFile_WriteString("\n", f); - if (offset == -1) - return; - PyFile_WriteString(" ", f); - offset--; - while (offset > 0) { - PyFile_WriteString(" ", f); - offset--; - } - PyFile_WriteString("^\n", f); -} - -static void -handle_system_exit(void) -{ - PyObject *exception, *value, *tb; - int exitcode = 0; - - PyErr_Fetch(&exception, &value, &tb); - if (Py_FlushLine()) - PyErr_Clear(); - fflush(stdout); - if (value == NULL || value == Py_None) - goto done; - if (PyInstance_Check(value)) { - /* The error code should be in the `code' attribute. */ - PyObject *code = PyObject_GetAttrString(value, "code"); - if (code) { - Py_DECREF(value); - value = code; - if (value == Py_None) - goto done; - } - /* If we failed to dig out the 'code' attribute, - just let the else clause below print the error. */ - } - if (PyInt_Check(value)) - exitcode = (int)PyInt_AsLong(value); - else { - PyObject_Print(value, stderr, Py_PRINT_RAW); - PySys_WriteStderr("\n"); - exitcode = 1; - } - done: - /* Restore and clear the exception info, in order to properly decref - * the exception, value, and traceback. If we just exit instead, - * these leak, which confuses PYTHONDUMPREFS output, and may prevent - * some finalizers from running. - */ - PyErr_Restore(exception, value, tb); - PyErr_Clear(); - Py_Exit(exitcode); - /* NOTREACHED */ -} - -void -PyErr_PrintEx(int set_sys_last_vars) -{ - PyObject *exception, *v, *tb, *hook; - - if (PyErr_ExceptionMatches(PyExc_SystemExit)) { - handle_system_exit(); - } - PyErr_Fetch(&exception, &v, &tb); - PyErr_NormalizeException(&exception, &v, &tb); - if (exception == NULL) - return; - if (set_sys_last_vars) { - PySys_SetObject("last_type", exception); - PySys_SetObject("last_value", v); - PySys_SetObject("last_traceback", tb); - } - hook = PySys_GetObject("excepthook"); - if (hook) { - PyObject *args = Py_BuildValue("(OOO)", - exception, v ? v : Py_None, tb ? tb : Py_None); - PyObject *result = PyEval_CallObject(hook, args); - if (result == NULL) { - PyObject *exception2, *v2, *tb2; - if (PyErr_ExceptionMatches(PyExc_SystemExit)) { - handle_system_exit(); - } - PyErr_Fetch(&exception2, &v2, &tb2); - PyErr_NormalizeException(&exception2, &v2, &tb2); - if (Py_FlushLine()) - PyErr_Clear(); - fflush(stdout); - PySys_WriteStderr("Error in sys.excepthook:\n"); - PyErr_Display(exception2, v2, tb2); - PySys_WriteStderr("\nOriginal exception was:\n"); - PyErr_Display(exception, v, tb); - Py_XDECREF(exception2); - Py_XDECREF(v2); - Py_XDECREF(tb2); - } - Py_XDECREF(result); - Py_XDECREF(args); - } else { - PySys_WriteStderr("sys.excepthook is missing\n"); - PyErr_Display(exception, v, tb); - } - Py_XDECREF(exception); - Py_XDECREF(v); - Py_XDECREF(tb); -} - -void PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb) -{ - int err = 0; - PyObject *v = value; - PyObject *f = PySys_GetObject("stderr"); - if (f == NULL) - fprintf(stderr, "lost sys.stderr\n"); - else { - if (Py_FlushLine()) - PyErr_Clear(); - fflush(stdout); - if (tb && tb != Py_None) - err = PyTraceBack_Print(tb, f); - if (err == 0 && - PyObject_HasAttrString(v, "print_file_and_line")) - { - PyObject *message; - const char *filename, *text; - int lineno, offset; - if (!parse_syntax_error(v, &message, &filename, - &lineno, &offset, &text)) - PyErr_Clear(); - else { - char buf[10]; - PyFile_WriteString(" File \"", f); - if (filename == NULL) - PyFile_WriteString("", f); - else - PyFile_WriteString(filename, f); - PyFile_WriteString("\", line ", f); - PyOS_snprintf(buf, sizeof(buf), "%d", lineno); - PyFile_WriteString(buf, f); - PyFile_WriteString("\n", f); - if (text != NULL) - print_error_text(f, offset, text); - v = message; - /* Can't be bothered to check all those - PyFile_WriteString() calls */ - if (PyErr_Occurred()) - err = -1; - } - } - if (err) { - /* Don't do anything else */ - } - else if (PyClass_Check(exception)) { - PyClassObject* exc = (PyClassObject*)exception; - PyObject* className = exc->cl_name; - PyObject* moduleName = - PyDict_GetItemString(exc->cl_dict, "__module__"); - - if (moduleName == NULL) - err = PyFile_WriteString("", f); - else { - char* modstr = PyString_AsString(moduleName); - if (modstr && strcmp(modstr, "exceptions")) - { - err = PyFile_WriteString(modstr, f); - err += PyFile_WriteString(".", f); - } - } - if (err == 0) { - if (className == NULL) - err = PyFile_WriteString("", f); - else - err = PyFile_WriteObject(className, f, - Py_PRINT_RAW); - } - } - else - err = PyFile_WriteObject(exception, f, Py_PRINT_RAW); - if (err == 0) { - if (v != NULL && v != Py_None) { - PyObject *s = PyObject_Str(v); - /* only print colon if the str() of the - object is not the empty string - */ - if (s == NULL) - err = -1; - else if (!PyString_Check(s) || - PyString_GET_SIZE(s) != 0) - err = PyFile_WriteString(": ", f); - if (err == 0) - err = PyFile_WriteObject(s, f, Py_PRINT_RAW); - Py_XDECREF(s); - } - } - if (err == 0) - err = PyFile_WriteString("\n", f); - } - /* If an error happened here, don't show it. - XXX This is wrong, but too many callers rely on this behavior. */ - if (err != 0) - PyErr_Clear(); -} - -PyObject * -PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals) -{ - return run_err_node(PyParser_SimpleParseString(str, start), - "", globals, locals, NULL); -} - -PyObject * -PyRun_File(FILE *fp, const char *filename, int start, PyObject *globals, - PyObject *locals) -{ - return PyRun_FileEx(fp, filename, start, globals, locals, 0); -} - -PyObject * -PyRun_FileEx(FILE *fp, const char *filename, int start, PyObject *globals, - PyObject *locals, int closeit) -{ - node *n = PyParser_SimpleParseFile(fp, filename, start); - if (closeit) - fclose(fp); - return run_err_node(n, filename, globals, locals, NULL); -} - -PyObject * -PyRun_StringFlags(const char *str, int start, PyObject *globals, PyObject *locals, - PyCompilerFlags *flags) -{ - return run_err_node(PyParser_SimpleParseStringFlags( - str, start, PARSER_FLAGS(flags)), - "", globals, locals, flags); -} - -PyObject * -PyRun_FileFlags(FILE *fp, const char *filename, int start, PyObject *globals, - PyObject *locals, PyCompilerFlags *flags) -{ - return PyRun_FileExFlags(fp, filename, start, globals, locals, 0, - flags); -} - -PyObject * -PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, - PyObject *locals, int closeit, PyCompilerFlags *flags) -{ - node *n = PyParser_SimpleParseFileFlags(fp, filename, start, - PARSER_FLAGS(flags)); - if (closeit) - fclose(fp); - return run_err_node(n, filename, globals, locals, flags); -} - -static PyObject * -run_err_node(node *n, const char *filename, PyObject *globals, PyObject *locals, - PyCompilerFlags *flags) -{ - if (n == NULL) - return NULL; - return run_node(n, filename, globals, locals, flags); -} - -static PyObject * -run_node(node *n, const char *filename, PyObject *globals, PyObject *locals, - PyCompilerFlags *flags) -{ - PyCodeObject *co; - PyObject *v; - co = PyNode_CompileFlags(n, filename, flags); - PyNode_Free(n); - if (co == NULL) - return NULL; - v = PyEval_EvalCode(co, globals, locals); - Py_DECREF(co); - return v; -} - -static PyObject * -run_pyc_file(FILE *fp, const char *filename, PyObject *globals, PyObject *locals, - PyCompilerFlags *flags) -{ - PyCodeObject *co; - PyObject *v; - long magic; - long PyImport_GetMagicNumber(void); - - magic = PyMarshal_ReadLongFromFile(fp); - if (magic != PyImport_GetMagicNumber()) { - PyErr_SetString(PyExc_RuntimeError, - "Bad magic number in .pyc file"); - return NULL; - } - (void) PyMarshal_ReadLongFromFile(fp); - v = PyMarshal_ReadLastObjectFromFile(fp); - fclose(fp); - if (v == NULL || !PyCode_Check(v)) { - Py_XDECREF(v); - PyErr_SetString(PyExc_RuntimeError, - "Bad code object in .pyc file"); - return NULL; - } - co = (PyCodeObject *)v; - v = PyEval_EvalCode(co, globals, locals); - if (v && flags) - flags->cf_flags |= (co->co_flags & PyCF_MASK); - Py_DECREF(co); - return v; -} - -PyObject * -Py_CompileString(const char *str, const char *filename, int start) -{ - return Py_CompileStringFlags(str, filename, start, NULL); -} - -PyObject * -Py_CompileStringFlags(const char *str, const char *filename, int start, - PyCompilerFlags *flags) -{ - node *n; - PyCodeObject *co; - - n = PyParser_SimpleParseStringFlagsFilename(str, filename, start, - PARSER_FLAGS(flags)); - if (n == NULL) - return NULL; - co = PyNode_CompileFlags(n, filename, flags); - PyNode_Free(n); - return (PyObject *)co; -} - -struct symtable * -Py_SymtableString(const char *str, const char *filename, int start) -{ - node *n; - struct symtable *st; - n = PyParser_SimpleParseStringFlagsFilename(str, filename, - start, 0); - if (n == NULL) - return NULL; - st = PyNode_CompileSymtable(n, filename); - PyNode_Free(n); - return st; -} - -/* Simplified interface to parsefile -- return node or set exception */ - -node * -PyParser_SimpleParseFileFlags(FILE *fp, const char *filename, int start, int flags) -{ - node *n; - perrdetail err; - n = PyParser_ParseFileFlags(fp, filename, &_PyParser_Grammar, start, - (char *)0, (char *)0, &err, flags); - if (n == NULL) - err_input(&err); - return n; -} - -node * -PyParser_SimpleParseFile(FILE *fp, const char *filename, int start) -{ - return PyParser_SimpleParseFileFlags(fp, filename, start, 0); -} - -/* Simplified interface to parsestring -- return node or set exception */ - -node * -PyParser_SimpleParseStringFlags(const char *str, int start, int flags) -{ - node *n; - perrdetail err; - n = PyParser_ParseStringFlags(str, &_PyParser_Grammar, start, &err, - flags); - if (n == NULL) - err_input(&err); - return n; -} - -node * -PyParser_SimpleParseString(const char *str, int start) -{ - return PyParser_SimpleParseStringFlags(str, start, 0); -} - -node * -PyParser_SimpleParseStringFlagsFilename(const char *str, const char *filename, - int start, int flags) -{ - node *n; - perrdetail err; - - n = PyParser_ParseStringFlagsFilename(str, filename, - &_PyParser_Grammar, - start, &err, flags); - if (n == NULL) - err_input(&err); - return n; -} - -node * -PyParser_SimpleParseStringFilename(const char *str, const char *filename, int start) -{ - return PyParser_SimpleParseStringFlagsFilename(str, filename, - start, 0); -} - -/* May want to move a more generalized form of this to parsetok.c or - even parser modules. */ - -void -PyParser_SetError(perrdetail *err) -{ - err_input(err); -} - -/* Set the error appropriate to the given input error code (see errcode.h) */ - -static void -err_input(perrdetail *err) -{ - PyObject *v, *w, *errtype; - PyObject* u = NULL; - char *msg = NULL; - errtype = PyExc_SyntaxError; - v = Py_BuildValue("(ziiz)", err->filename, - err->lineno, err->offset, err->text); - if (err->text != NULL) { - PyMem_DEL(err->text); - err->text = NULL; - } - switch (err->error) { - case E_SYNTAX: - errtype = PyExc_IndentationError; - if (err->expected == INDENT) - msg = "expected an indented block"; - else if (err->token == INDENT) - msg = "unexpected indent"; - else if (err->token == DEDENT) - msg = "unexpected unindent"; - else { - errtype = PyExc_SyntaxError; - msg = "invalid syntax"; - } - break; - case E_TOKEN: - msg = "invalid token"; - break; - case E_EOFS: - msg = "EOF while scanning triple-quoted string"; - break; - case E_EOLS: - msg = "EOL while scanning single-quoted string"; - break; - case E_INTR: - PyErr_SetNone(PyExc_KeyboardInterrupt); - Py_XDECREF(v); - return; - case E_NOMEM: - PyErr_NoMemory(); - Py_XDECREF(v); - return; - case E_EOF: - msg = "unexpected EOF while parsing"; - break; - case E_TABSPACE: - errtype = PyExc_TabError; - msg = "inconsistent use of tabs and spaces in indentation"; - break; - case E_OVERFLOW: - msg = "expression too long"; - break; - case E_DEDENT: - errtype = PyExc_IndentationError; - msg = "unindent does not match any outer indentation level"; - break; - case E_TOODEEP: - errtype = PyExc_IndentationError; - msg = "too many levels of indentation"; - break; - case E_DECODE: { /* XXX */ - PyThreadState* tstate = PyThreadState_Get(); - PyObject* value = tstate->curexc_value; - if (value != NULL) { - u = PyObject_Repr(value); - if (u != NULL) { - msg = PyString_AsString(u); - break; - } - } - } - default: - fprintf(stderr, "error=%d\n", err->error); - msg = "unknown parsing error"; - break; - } - w = Py_BuildValue("(sO)", msg, v); - Py_XDECREF(u); - Py_XDECREF(v); - PyErr_SetObject(errtype, w); - Py_XDECREF(w); -} - -/* Print fatal error message and abort */ - -void -Py_FatalError(const char *msg) -{ - char *crash = NULL; - fprintf(stderr, "Fatal Python error: %s\n", msg); -#ifdef MS_WINDOWS - OutputDebugString("Fatal Python error: "); - OutputDebugString(msg); - OutputDebugString("\n"); -#ifdef _DEBUG - DebugBreak(); -#endif -#endif /* MS_WINDOWS */ - // crash the game instead of aborting, which allows our exception handler to catch it - *crash = 1; - //abort(); -} - -/* Clean up and exit */ - -#ifdef WITH_THREAD -#include "pythread.h" -int _PyThread_Started = 0; /* Set by threadmodule.c and maybe others */ -#endif - -#define NEXITFUNCS 32 -static void (*exitfuncs[NEXITFUNCS])(void); -static int nexitfuncs = 0; - -int Py_AtExit(void (*func)(void)) -{ - if (nexitfuncs >= NEXITFUNCS) - return -1; - exitfuncs[nexitfuncs++] = func; - return 0; -} - -static void -call_sys_exitfunc(void) -{ - PyObject *exitfunc = PySys_GetObject("exitfunc"); - - if (exitfunc) { - PyObject *res; - Py_INCREF(exitfunc); - PySys_SetObject("exitfunc", (PyObject *)NULL); - res = PyEval_CallObject(exitfunc, (PyObject *)NULL); - if (res == NULL) { - if (!PyErr_ExceptionMatches(PyExc_SystemExit)) { - PySys_WriteStderr("Error in sys.exitfunc:\n"); - } - PyErr_Print(); - } - Py_DECREF(exitfunc); - } - - if (Py_FlushLine()) - PyErr_Clear(); -} - -static void -call_ll_exitfuncs(void) -{ - while (nexitfuncs > 0) - (*exitfuncs[--nexitfuncs])(); - - fflush(stdout); - fflush(stderr); -} - -void -Py_Exit(int sts) -{ - char* fatal = NULL; - - Py_Finalize(); - -#ifdef macintosh - PyMac_Exit(sts); -#else - //exit(sts); - - // Force crash instead of just terminating the process...this way - // we get a stack dump if something goes wrong - *fatal = 1; -#endif -} - -static void -initsigs(void) -{ -#ifdef HAVE_SIGNAL_H -#ifdef SIGPIPE - signal(SIGPIPE, SIG_IGN); -#endif -#ifdef SIGXFZ - signal(SIGXFZ, SIG_IGN); -#endif -#ifdef SIGXFSZ - signal(SIGXFSZ, SIG_IGN); -#endif -#endif /* HAVE_SIGNAL_H */ - PyOS_InitInterrupts(); /* May imply initsignal() */ -} - -#ifdef MPW - -/* Check for file descriptor connected to interactive device. - Pretend that stdin is always interactive, other files never. */ - -int -isatty(int fd) -{ - return fd == fileno(stdin); -} - -#endif - -/* - * The file descriptor fd is considered ``interactive'' if either - * a) isatty(fd) is TRUE, or - * b) the -i flag was given, and the filename associated with - * the descriptor is NULL or "" or "???". - */ -int -Py_FdIsInteractive(FILE *fp, const char *filename) -{ - if (isatty((int)fileno(fp))) - return 1; - if (!Py_InteractiveFlag) - return 0; - return (filename == NULL) || - (strcmp(filename, "") == 0) || - (strcmp(filename, "???") == 0); -} - - -#if defined(USE_STACKCHECK) -#if defined(WIN32) && defined(_MSC_VER) - -/* Stack checking for Microsoft C */ - -#include -#include - -/* - * Return non-zero when we run out of memory on the stack; zero otherwise. - */ -int -PyOS_CheckStack(void) -{ - __try { - /* alloca throws a stack overflow exception if there's - not enough space left on the stack */ - alloca(PYOS_STACK_MARGIN * sizeof(void*)); - return 0; - } __except (EXCEPTION_EXECUTE_HANDLER) { - /* just ignore all errors */ - } - return 1; -} - -#endif /* WIN32 && _MSC_VER */ - -/* Alternate implementations can be added here... */ - -#endif /* USE_STACKCHECK */ - - -/* Wrappers around sigaction() or signal(). */ - -PyOS_sighandler_t -PyOS_getsig(int sig) -{ -#ifdef MS_XBOX - /* Xbox blows up sometimes when signal is called. Until that gets figured out, - * just pretend every signal is invalid. - */ - return SIG_ERR; - -#else - -#ifdef HAVE_SIGACTION - struct sigaction context; - /* Initialize context.sa_handler to SIG_ERR which makes about as - * much sense as anything else. It should get overwritten if - * sigaction actually succeeds and otherwise we avoid an - * uninitialized memory read. - */ - context.sa_handler = SIG_ERR; - sigaction(sig, NULL, &context); - return context.sa_handler; -#else - PyOS_sighandler_t handler; - handler = signal(sig, SIG_IGN); - signal(sig, handler); - return handler; -#endif - -#endif -} - -PyOS_sighandler_t -PyOS_setsig(int sig, PyOS_sighandler_t handler) -{ -#ifdef HAVE_SIGACTION - struct sigaction context; - PyOS_sighandler_t oldhandler; - /* Initialize context.sa_handler to SIG_ERR which makes about as - * much sense as anything else. It should get overwritten if - * sigaction actually succeeds and otherwise we avoid an - * uninitialized memory read. - */ - context.sa_handler = SIG_ERR; - sigaction(sig, NULL, &context); - oldhandler = context.sa_handler; - context.sa_handler = handler; - sigaction(sig, &context, NULL); - return oldhandler; -#else - return signal(sig, handler); -#endif -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/sigcheck.c b/SDKs/XPlatform/Cypython-2.3.3/Python/sigcheck.c deleted file mode 100644 index 730cd2e2..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/sigcheck.c +++ /dev/null @@ -1,19 +0,0 @@ - -/* Sigcheck is similar to intrcheck() but sets an exception when an - interrupt occurs. It can't be in the intrcheck.c file since that - file (and the whole directory it is in) doesn't know about objects - or exceptions. It can't be in errors.c because it can be - overridden (at link time) by a more powerful version implemented in - signalmodule.c. */ - -#include "Python.h" - -/* ARGSUSED */ -int -PyErr_CheckSignals(void) -{ - if (!PyOS_InterruptOccurred()) - return 0; - PyErr_SetNone(PyExc_KeyboardInterrupt); - return -1; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/strdup.c b/SDKs/XPlatform/Cypython-2.3.3/Python/strdup.c deleted file mode 100644 index deef5342..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/strdup.c +++ /dev/null @@ -1,14 +0,0 @@ -/* strdup() replacement (from stdwin, if you must know) */ - -#include "pgenheaders.h" - -char * -strdup(const char *str) -{ - if (str != NULL) { - register char *copy = malloc(strlen(str) + 1); - if (copy != NULL) - return strcpy(copy, str); - } - return NULL; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/strerror.c b/SDKs/XPlatform/Cypython-2.3.3/Python/strerror.c deleted file mode 100644 index 1365894b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/strerror.c +++ /dev/null @@ -1,24 +0,0 @@ - -/* PD implementation of strerror() for systems that don't have it. - Author: Guido van Rossum, CWI Amsterdam, Oct. 1990, . */ - -#include -#include "Python.h" - -extern int sys_nerr; -extern char *sys_errlist[]; - -char * -strerror(int err) -{ - static char buf[20]; - if (err >= 0 && err < sys_nerr) - return sys_errlist[err]; - PyOS_snprintf(buf, sizeof(buf), "Unknown errno %d", err); - return buf; -} - -#ifdef macintosh -int sys_nerr = 0; -char *sys_errlist[1] = 0; -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/strtod.c b/SDKs/XPlatform/Cypython-2.3.3/Python/strtod.c deleted file mode 100644 index d06e613a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/strtod.c +++ /dev/null @@ -1,156 +0,0 @@ -#include "pyconfig.h" - -/* comp.sources.misc strtod(), as posted in comp.lang.tcl, - with bugfix for "123000.0" and acceptance of space after 'e' sign nuked. - - ************************************************************ - * YOU MUST EDIT THE MACHINE-DEPENDENT DEFINITIONS BELOW!!! * - ************************************************************ -*/ - -/* File : stdtod.c (Modified version of str2dbl.c) - Author : Richard A. O'Keefe @ Quintus Computer Systems, Inc. - Updated: Tuesday August 2nd, 1988 - Defines: double strtod (char *str, char**ptr) -*/ - -/* This is an implementation of the strtod() function described in the - System V manuals, with a different name to avoid linker problems. - All that str2dbl() does itself is check that the argument is well-formed - and is in range. It leaves the work of conversion to atof(), which is - assumed to exist and deliver correct results (if they can be represented). - - There are two reasons why this should be provided to the net: - (a) some UNIX systems do not yet have strtod(), or do not have it - available in the BSD "universe" (but they do have atof()). - (b) some of the UNIX systems that *do* have it get it wrong. - (some crash with large arguments, some assign the wrong *ptr value). - There is a reason why *we* are providing it: we need a correct version - of strtod(), and if we give this one away maybe someone will look for - mistakes in it and fix them for us (:-). -*/ - -/* The following constants are machine-specific. MD{MIN,MAX}EXPT are - integers and MD{MIN,MAX}FRAC are strings such that - 0.${MDMAXFRAC}e${MDMAXEXPT} is the largest representable double, - 0.${MDMINFRAC}e${MDMINEXPT} is the smallest representable +ve double - MD{MIN,MAX}FRAC must not have any trailing zeros. - The values here are for IEEE-754 64-bit floats. - It is not perfectly clear to me whether an IEEE infinity should be - returned for overflow, nor what a portable way of writing one is, - so HUGE is just 0.MAXFRAC*10**MAXEXPT (this seems still to be the - UNIX convention). - - I do know about , but the whole point of this file is that - we can't always trust that stuff to be there or to be correct. -*/ -static int MDMINEXPT = {-323}; -static char MDMINFRAC[] = "494065645841246544"; -static double ZERO = 0.0; - -static int MDMAXEXPT = { 309}; -static char MDMAXFRAC[] = "17976931348623157"; -static double HUGE = 1.7976931348623157e308; - -extern double atof(const char *); /* Only called when result known to be ok */ - -#ifndef DONT_HAVE_ERRNO_H -#include -#endif -extern int errno; - -double strtod(char *str, char **ptr) -{ - int sign, scale, dotseen; - int esign, expt; - char *save; - register char *sp, *dp; - register int c; - char *buforg, *buflim; - char buffer[64]; /* 45-digit significant + */ - /* 13-digit exponent */ - sp = str; - while (*sp == ' ') sp++; - sign = 1; - if (*sp == '-') sign -= 2, sp++; - dotseen = 0, scale = 0; - dp = buffer; - *dp++ = '0'; *dp++ = '.'; - buforg = dp, buflim = buffer+48; - for (save = sp; c = *sp; sp++) - if (c == '.') { - if (dotseen) break; - dotseen++; - } else - if ((unsigned)(c-'0') > (unsigned)('9'-'0')) { - break; - } else - if (c == '0') { - if (dp != buforg) { - /* This is not the first digit, so we want to keep it */ - if (dp < buflim) *dp++ = c; - if (!dotseen) scale++; - } else { - /* No non-zero digits seen yet */ - /* If a . has been seen, scale must be adjusted */ - if (dotseen) scale--; - } - } else { - /* This is a nonzero digit, so we want to keep it */ - if (dp < buflim) *dp++ = c; - /* If it precedes a ., scale must be adjusted */ - if (!dotseen) scale++; - } - if (sp == save) { - if (ptr) *ptr = str; - errno = EDOM; /* what should this be? */ - return ZERO; - } - - while (dp > buforg && dp[-1] == '0') --dp; - if (dp == buforg) *dp++ = '0'; - *dp = '\0'; - /* Now the contents of buffer are - +--+--------+-+--------+ - |0.|fraction|\|leftover| - +--+--------+-+--------+ - ^dp points here - where fraction begins with 0 iff it is "0", and has at most - 45 digits in it, and leftover is at least 16 characters. - */ - save = sp, expt = 0, esign = 1; - do { - c = *sp++; - if (c != 'e' && c != 'E') break; - c = *sp++; - if (c == '-') esign -= 2, c = *sp++; else - if (c == '+' /* || c == ' ' */ ) c = *sp++; - if ((unsigned)(c-'0') > (unsigned)('9'-'0')) break; - while (c == '0') c = *sp++; - for (; (unsigned)(c-'0') <= (unsigned)('9'-'0'); c = *sp++) - expt = expt*10 + c-'0'; - if (esign < 0) expt = -expt; - save = sp-1; - } while (0); - if (ptr) *ptr = save; - expt += scale; - /* Now the number is sign*0.fraction*10**expt */ - errno = ERANGE; - if (expt > MDMAXEXPT) { - return HUGE*sign; - } else - if (expt == MDMAXEXPT) { - if (strcmp(buforg, MDMAXFRAC) > 0) return HUGE*sign; - } else - if (expt < MDMINEXPT) { - return ZERO*sign; - } else - if (expt == MDMINEXPT) { - if (strcmp(buforg, MDMINFRAC) < 0) return ZERO*sign; - } - /* We have now established that the number can be */ - /* represented without overflow or underflow */ - (void) sprintf(dp, "E%d", expt); - errno = 0; - return atof(buffer)*sign; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/structmember.c b/SDKs/XPlatform/Cypython-2.3.3/Python/structmember.c deleted file mode 100644 index a3c6dc0f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/structmember.c +++ /dev/null @@ -1,276 +0,0 @@ - -/* Map C struct members to Python object attributes */ - -#include "Python.h" - -#include "structmember.h" - -static PyObject * -listmembers(struct memberlist *mlist) -{ - int i, n; - PyObject *v; - for (n = 0; mlist[n].name != NULL; n++) - ; - v = PyList_New(n); - if (v != NULL) { - for (i = 0; i < n; i++) - PyList_SetItem(v, i, - PyString_FromString(mlist[i].name)); - if (PyErr_Occurred()) { - Py_DECREF(v); - v = NULL; - } - else { - PyList_Sort(v); - } - } - return v; -} - -PyObject * -PyMember_Get(char *addr, struct memberlist *mlist, char *name) -{ - struct memberlist *l; - - if (strcmp(name, "__members__") == 0) - return listmembers(mlist); - for (l = mlist; l->name != NULL; l++) { - if (strcmp(l->name, name) == 0) { - PyMemberDef copy; - copy.name = l->name; - copy.type = l->type; - copy.offset = l->offset; - copy.flags = l->flags; - copy.doc = NULL; - return PyMember_GetOne(addr, ©); - } - } - PyErr_SetString(PyExc_AttributeError, name); - return NULL; -} - -PyObject * -PyMember_GetOne(char *addr, PyMemberDef *l) -{ - PyObject *v; - if ((l->flags & READ_RESTRICTED) && - PyEval_GetRestricted()) { - PyErr_SetString(PyExc_RuntimeError, "restricted attribute"); - return NULL; - } - addr += l->offset; - switch (l->type) { - case T_BYTE: - v = PyInt_FromLong( - (long) (((*(char*)addr & 0xff) ^ 0x80) - 0x80)); - break; - case T_UBYTE: - v = PyInt_FromLong((long) *(char*)addr & 0xff); - break; - case T_SHORT: - v = PyInt_FromLong((long) *(short*)addr); - break; - case T_USHORT: - v = PyInt_FromLong((long) *(unsigned short*)addr); - break; - case T_INT: - v = PyInt_FromLong((long) *(int*)addr); - break; - case T_UINT: - v = PyInt_FromLong((long) *(unsigned int*)addr); - break; - case T_LONG: - v = PyInt_FromLong(*(long*)addr); - break; - case T_ULONG: - v = PyLong_FromDouble((double) *(unsigned long*)addr); - break; - case T_FLOAT: - v = PyFloat_FromDouble((double)*(float*)addr); - break; - case T_DOUBLE: - v = PyFloat_FromDouble(*(double*)addr); - break; - case T_STRING: - if (*(char**)addr == NULL) { - Py_INCREF(Py_None); - v = Py_None; - } - else - v = PyString_FromString(*(char**)addr); - break; - case T_STRING_INPLACE: - v = PyString_FromString((char*)addr); - break; -#ifdef macintosh - case T_PSTRING: - if (*(char**)addr == NULL) { - Py_INCREF(Py_None); - v = Py_None; - } - else - v = PyString_FromStringAndSize( - (*(char**)addr)+1, - **(unsigned char**)addr); - break; - case T_PSTRING_INPLACE: - v = PyString_FromStringAndSize( - ((char*)addr)+1, - *(unsigned char*)addr); - break; -#endif /* macintosh */ - case T_CHAR: - v = PyString_FromStringAndSize((char*)addr, 1); - break; - case T_OBJECT: - v = *(PyObject **)addr; - if (v == NULL) - v = Py_None; - Py_INCREF(v); - break; - case T_OBJECT_EX: - v = *(PyObject **)addr; - if (v == NULL) - PyErr_SetString(PyExc_AttributeError, l->name); - Py_XINCREF(v); - break; - default: - PyErr_SetString(PyExc_SystemError, "bad memberdescr type"); - v = NULL; - } - return v; -} - -int -PyMember_Set(char *addr, struct memberlist *mlist, char *name, PyObject *v) -{ - struct memberlist *l; - - for (l = mlist; l->name != NULL; l++) { - if (strcmp(l->name, name) == 0) { - PyMemberDef copy; - copy.name = l->name; - copy.type = l->type; - copy.offset = l->offset; - copy.flags = l->flags; - copy.doc = NULL; - return PyMember_SetOne(addr, ©, v); - } - } - - PyErr_SetString(PyExc_AttributeError, name); - return -1; -} - -int -PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) -{ - PyObject *oldv; - - if ((l->flags & READONLY) || l->type == T_STRING -#ifdef macintosh - || l->type == T_PSTRING -#endif - ) - { - PyErr_SetString(PyExc_TypeError, "readonly attribute"); - return -1; - } - if ((l->flags & WRITE_RESTRICTED) && PyEval_GetRestricted()) { - PyErr_SetString(PyExc_RuntimeError, "restricted attribute"); - return -1; - } - if (v == NULL && l->type != T_OBJECT_EX && l->type != T_OBJECT) { - PyErr_SetString(PyExc_TypeError, - "can't delete numeric/char attribute"); - return -1; - } - addr += l->offset; - switch (l->type) { - case T_BYTE: - case T_UBYTE: - if (!PyInt_Check(v)) { - PyErr_BadArgument(); - return -1; - } - *(char*)addr = (char) PyInt_AsLong(v); - break; - case T_SHORT: - case T_USHORT: - if (!PyInt_Check(v)) { - PyErr_BadArgument(); - return -1; - } - *(short*)addr = (short) PyInt_AsLong(v); - break; - case T_UINT: - case T_INT: - if (!PyInt_Check(v)) { - PyErr_BadArgument(); - return -1; - } - *(int*)addr = (int) PyInt_AsLong(v); - break; - case T_LONG: - if (!PyInt_Check(v)) { - PyErr_BadArgument(); - return -1; - } - *(long*)addr = PyInt_AsLong(v); - break; - case T_ULONG: - if (PyInt_Check(v)) - *(long*)addr = PyInt_AsLong(v); - else if (PyLong_Check(v)) - *(long*)addr = PyLong_AsLong(v); - else { - PyErr_BadArgument(); - return -1; - } - break; - case T_FLOAT: - if (PyInt_Check(v)) - *(float*)addr = - (float) PyInt_AsLong(v); - else if (PyFloat_Check(v)) - *(float*)addr = - (float) PyFloat_AsDouble(v); - else { - PyErr_BadArgument(); - return -1; - } - break; - case T_DOUBLE: - if (PyInt_Check(v)) - *(double*)addr = (double) PyInt_AsLong(v); - else if (PyFloat_Check(v)) - *(double*)addr = PyFloat_AsDouble(v); - else { - PyErr_BadArgument(); - return -1; - } - break; - case T_OBJECT: - case T_OBJECT_EX: - Py_XINCREF(v); - oldv = *(PyObject **)addr; - *(PyObject **)addr = v; - Py_XDECREF(oldv); - break; - case T_CHAR: - if (PyString_Check(v) && PyString_Size(v) == 1) { - *(char*)addr = PyString_AsString(v)[0]; - } - else { - PyErr_BadArgument(); - return -1; - } - break; - default: - PyErr_Format(PyExc_SystemError, - "bad memberdescr type for %s", l->name); - return -1; - } - return 0; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/symtable.c b/SDKs/XPlatform/Cypython-2.3.3/Python/symtable.c deleted file mode 100644 index 65cf7987..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/symtable.c +++ /dev/null @@ -1,180 +0,0 @@ -#include "Python.h" -#include "compile.h" -#include "symtable.h" -#include "graminit.h" -#include "structmember.h" - -/* The compiler uses this function to load a PySymtableEntry object - for a code block. Each block is loaded twice, once during the - symbol table pass and once during the code gen pass. Entries - created during the first pass are cached for the second pass, using - the st_symbols dictionary. - - The cache is keyed by st_nscopes. Each code block node in a - module's parse tree can be assigned a unique id based on the order - in which the nodes are visited by the compiler. This strategy - works so long as the symbol table and codegen passes visit the same - nodes in the same order. -*/ - - -PyObject * -PySymtableEntry_New(struct symtable *st, char *name, int type, int lineno) -{ - PySymtableEntryObject *ste = NULL; - PyObject *k, *v; - - k = PyInt_FromLong(st->st_nscopes++); - if (k == NULL) - goto fail; - v = PyDict_GetItem(st->st_symbols, k); - if (v) { - Py_DECREF(k); - Py_INCREF(v); - return v; - } - - ste = (PySymtableEntryObject *)PyObject_New(PySymtableEntryObject, - &PySymtableEntry_Type); - ste->ste_table = st; - ste->ste_id = k; - - v = PyString_FromString(name); - if (v == NULL) - goto fail; - ste->ste_name = v; - - v = PyDict_New(); - if (v == NULL) - goto fail; - ste->ste_symbols = v; - - v = PyList_New(0); - if (v == NULL) - goto fail; - ste->ste_varnames = v; - - v = PyList_New(0); - if (v == NULL) - goto fail; - ste->ste_children = v; - - ste->ste_optimized = 0; - ste->ste_opt_lineno = 0; - ste->ste_tmpname = 0; - ste->ste_lineno = lineno; - switch (type) { - case funcdef: - case lambdef: - ste->ste_type = TYPE_FUNCTION; - break; - case classdef: - ste->ste_type = TYPE_CLASS; - break; - case single_input: - case eval_input: - case file_input: - ste->ste_type = TYPE_MODULE; - break; - } - - if (st->st_cur == NULL) - ste->ste_nested = 0; - else if (st->st_cur->ste_nested - || st->st_cur->ste_type == TYPE_FUNCTION) - ste->ste_nested = 1; - else - ste->ste_nested = 0; - ste->ste_child_free = 0; - ste->ste_generator = 0; - - if (PyDict_SetItem(st->st_symbols, ste->ste_id, (PyObject *)ste) < 0) - goto fail; - - return (PyObject *)ste; - fail: - Py_XDECREF(ste); - return NULL; -} - -static PyObject * -ste_repr(PySymtableEntryObject *ste) -{ - char buf[256]; - - PyOS_snprintf(buf, sizeof(buf), - "", - PyString_AS_STRING(ste->ste_name), - PyInt_AS_LONG(ste->ste_id), - ste->ste_lineno); - return PyString_FromString(buf); -} - -static void -ste_dealloc(PySymtableEntryObject *ste) -{ - ste->ste_table = NULL; - Py_XDECREF(ste->ste_id); - Py_XDECREF(ste->ste_name); - Py_XDECREF(ste->ste_symbols); - Py_XDECREF(ste->ste_varnames); - Py_XDECREF(ste->ste_children); - PyObject_Del(ste); -} - -#define OFF(x) offsetof(PySymtableEntryObject, x) - -static PyMemberDef ste_memberlist[] = { - {"id", T_OBJECT, OFF(ste_id), READONLY}, - {"name", T_OBJECT, OFF(ste_name), READONLY}, - {"symbols", T_OBJECT, OFF(ste_symbols), READONLY}, - {"varnames", T_OBJECT, OFF(ste_varnames), READONLY}, - {"children", T_OBJECT, OFF(ste_children), READONLY}, - {"type", T_INT, OFF(ste_type), READONLY}, - {"lineno", T_INT, OFF(ste_lineno), READONLY}, - {"optimized",T_INT, OFF(ste_optimized), READONLY}, - {"nested", T_INT, OFF(ste_nested), READONLY}, - {NULL} -}; - -PyTypeObject PySymtableEntry_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "symtable entry", - sizeof(PySymtableEntryObject), - 0, - (destructor)ste_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)ste_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - 0, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - ste_memberlist, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ -}; diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/sysmodule.c b/SDKs/XPlatform/Cypython-2.3.3/Python/sysmodule.c deleted file mode 100644 index 5e0e7b31..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/sysmodule.c +++ /dev/null @@ -1,1298 +0,0 @@ - -/* System module */ - -/* -Various bits of information used by the interpreter are collected in -module 'sys'. -Function member: -- exit(sts): raise SystemExit -Data members: -- stdin, stdout, stderr: standard file objects -- modules: the table of modules (dictionary) -- path: module search path (list of strings) -- argv: script arguments (list of strings) -- ps1, ps2: optional primary and secondary prompts (strings) -*/ - -#include "Python.h" -#include "compile.h" -#include "frameobject.h" -#include "eval.h" - -#include "osdefs.h" - -#ifdef MS_WINDOWS -#ifdef MS_XBOX -#include -#else -#define WIN32_LEAN_AND_MEAN -#include -#endif -#endif - -#ifdef MS_COREDLL -extern void *PyWin_DLLhModule; -/* A string loaded from the DLL at startup: */ -extern const char *PyWin_DLLVersionString; -#endif - -#ifdef __VMS -#include -#endif - -#ifdef HAVE_LANGINFO_H -#include -#include -#endif - -PyObject * -PySys_GetObject(char *name) -{ - PyThreadState *tstate = PyThreadState_Get(); - PyObject *sd = tstate->interp->sysdict; - if (sd == NULL) - return NULL; - return PyDict_GetItemString(sd, name); -} - -FILE * -PySys_GetFile(char *name, FILE *def) -{ - FILE *fp = NULL; - PyObject *v = PySys_GetObject(name); - if (v != NULL && PyFile_Check(v)) - fp = PyFile_AsFile(v); - if (fp == NULL) - fp = def; - return fp; -} - -int -PySys_SetObject(char *name, PyObject *v) -{ - PyThreadState *tstate = PyThreadState_Get(); - PyObject *sd = tstate->interp->sysdict; - if (v == NULL) { - if (PyDict_GetItemString(sd, name) == NULL) - return 0; - else - return PyDict_DelItemString(sd, name); - } - else - return PyDict_SetItemString(sd, name, v); -} - -static PyObject * -sys_displayhook(PyObject *self, PyObject *o) -{ - PyObject *outf; - PyInterpreterState *interp = PyThreadState_Get()->interp; - PyObject *modules = interp->modules; - PyObject *builtins = PyDict_GetItemString(modules, "__builtin__"); - - if (builtins == NULL) { - PyErr_SetString(PyExc_RuntimeError, "lost __builtin__"); - return NULL; - } - - /* Print value except if None */ - /* After printing, also assign to '_' */ - /* Before, set '_' to None to avoid recursion */ - if (o == Py_None) { - Py_INCREF(Py_None); - return Py_None; - } - if (PyObject_SetAttrString(builtins, "_", Py_None) != 0) - return NULL; - if (Py_FlushLine() != 0) - return NULL; - outf = PySys_GetObject("stdout"); - if (outf == NULL) { - PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); - return NULL; - } - if (PyFile_WriteObject(o, outf, 0) != 0) - return NULL; - PyFile_SoftSpace(outf, 1); - if (Py_FlushLine() != 0) - return NULL; - if (PyObject_SetAttrString(builtins, "_", o) != 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(displayhook_doc, -"displayhook(object) -> None\n" -"\n" -"Print an object to sys.stdout and also save it in __builtin__._\n" -); - -static PyObject * -sys_excepthook(PyObject* self, PyObject* args) -{ - PyObject *exc, *value, *tb; - if (!PyArg_UnpackTuple(args, "excepthook", 3, 3, &exc, &value, &tb)) - return NULL; - PyErr_Display(exc, value, tb); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(excepthook_doc, -"excepthook(exctype, value, traceback) -> None\n" -"\n" -"Handle an exception by displaying it with a traceback on sys.stderr.\n" -); - -static PyObject * -sys_exc_info(PyObject *self, PyObject *noargs) -{ - PyThreadState *tstate; - tstate = PyThreadState_Get(); - return Py_BuildValue( - "(OOO)", - tstate->exc_type != NULL ? tstate->exc_type : Py_None, - tstate->exc_value != NULL ? tstate->exc_value : Py_None, - tstate->exc_traceback != NULL ? - tstate->exc_traceback : Py_None); -} - -PyDoc_STRVAR(exc_info_doc, -"exc_info() -> (type, value, traceback)\n\ -\n\ -Return information about the most recent exception caught by an except\n\ -clause in the current stack frame or in an older stack frame." -); - -static PyObject * -sys_exc_clear(PyObject *self, PyObject *noargs) -{ - PyThreadState *tstate = PyThreadState_Get(); - PyObject *tmp_type, *tmp_value, *tmp_tb; - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = NULL; - tstate->exc_value = NULL; - tstate->exc_traceback = NULL; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); - /* For b/w compatibility */ - PySys_SetObject("exc_type", Py_None); - PySys_SetObject("exc_value", Py_None); - PySys_SetObject("exc_traceback", Py_None); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(exc_clear_doc, -"exc_clear() -> None\n\ -\n\ -Clear global information on the current exception. Subsequent calls to\n\ -exc_info() will return (None,None,None) until another exception is raised\n\ -in the current thread or the execution stack returns to a frame where\n\ -another exception is being handled." -); - -static PyObject * -sys_exit(PyObject *self, PyObject *args) -{ - PyObject *exit_code = 0; - if (!PyArg_ParseTuple(args, "|O:exit", &exit_code)) - return NULL; - /* Raise SystemExit so callers may catch it or clean up. */ - PyErr_SetObject(PyExc_SystemExit, exit_code); - return NULL; -} - -PyDoc_STRVAR(exit_doc, -"exit([status])\n\ -\n\ -Exit the interpreter by raising SystemExit(status).\n\ -If the status is omitted or None, it defaults to zero (i.e., success).\n\ -If the status is numeric, it will be used as the system exit status.\n\ -If it is another kind of object, it will be printed and the system\n\ -exit status will be one (i.e., failure)." -); - -#ifdef Py_USING_UNICODE - -static PyObject * -sys_getdefaultencoding(PyObject *self) -{ - return PyString_FromString(PyUnicode_GetDefaultEncoding()); -} - -PyDoc_STRVAR(getdefaultencoding_doc, -"getdefaultencoding() -> string\n\ -\n\ -Return the current default string encoding used by the Unicode \n\ -implementation." -); - -static PyObject * -sys_setdefaultencoding(PyObject *self, PyObject *args) -{ - char *encoding; - if (!PyArg_ParseTuple(args, "s:setdefaultencoding", &encoding)) - return NULL; - if (PyUnicode_SetDefaultEncoding(encoding)) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(setdefaultencoding_doc, -"setdefaultencoding(encoding)\n\ -\n\ -Set the current default string encoding used by the Unicode implementation." -); - -static PyObject * -sys_getfilesystemencoding(PyObject *self) -{ - if (Py_FileSystemDefaultEncoding) - return PyString_FromString(Py_FileSystemDefaultEncoding); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(getfilesystemencoding_doc, -"getfilesystemencoding() -> string\n\ -\n\ -Return the encoding used to convert Unicode filenames in\n\ -operating system filenames." -); - -#endif - -/* - * Cached interned string objects used for calling the profile and - * trace functions. Initialized by trace_init(). - */ -static PyObject *whatstrings[4] = {NULL, NULL, NULL, NULL}; - -static int -trace_init(void) -{ - static char *whatnames[4] = {"call", "exception", "line", "return"}; - PyObject *name; - int i; - for (i = 0; i < 4; ++i) { - if (whatstrings[i] == NULL) { - name = PyString_InternFromString(whatnames[i]); - if (name == NULL) - return -1; - whatstrings[i] = name; - } - } - return 0; -} - - -static PyObject * -call_trampoline(PyThreadState *tstate, PyObject* callback, - PyFrameObject *frame, int what, PyObject *arg) -{ - PyObject *args = PyTuple_New(3); - PyObject *whatstr; - PyObject *result; - - if (args == NULL) - return NULL; - Py_INCREF(frame); - whatstr = whatstrings[what]; - Py_INCREF(whatstr); - if (arg == NULL) - arg = Py_None; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, (PyObject *)frame); - PyTuple_SET_ITEM(args, 1, whatstr); - PyTuple_SET_ITEM(args, 2, arg); - - /* call the Python-level function */ - PyFrame_FastToLocals(frame); - result = PyEval_CallObject(callback, args); - PyFrame_LocalsToFast(frame, 1); - if (result == NULL) - PyTraceBack_Here(frame); - - /* cleanup */ - Py_DECREF(args); - return result; -} - -static int -profile_trampoline(PyObject *self, PyFrameObject *frame, - int what, PyObject *arg) -{ - PyThreadState *tstate = frame->f_tstate; - PyObject *result; - - if (arg == NULL) - arg = Py_None; - result = call_trampoline(tstate, self, frame, what, arg); - if (result == NULL) { - PyEval_SetProfile(NULL, NULL); - return -1; - } - Py_DECREF(result); - return 0; -} - -static int -trace_trampoline(PyObject *self, PyFrameObject *frame, - int what, PyObject *arg) -{ - PyThreadState *tstate = frame->f_tstate; - PyObject *callback; - PyObject *result; - - if (what == PyTrace_CALL) - callback = self; - else - callback = frame->f_trace; - if (callback == NULL) - return 0; - result = call_trampoline(tstate, callback, frame, what, arg); - if (result == NULL) { - PyEval_SetTrace(NULL, NULL); - Py_XDECREF(frame->f_trace); - frame->f_trace = NULL; - return -1; - } - if (result != Py_None) { - PyObject *temp = frame->f_trace; - frame->f_trace = NULL; - Py_XDECREF(temp); - frame->f_trace = result; - } - else { - Py_DECREF(result); - } - return 0; -} - -static PyObject * -sys_settrace(PyObject *self, PyObject *args) -{ - if (trace_init() == -1) - return NULL; - if (args == Py_None) - PyEval_SetTrace(NULL, NULL); - else - PyEval_SetTrace(trace_trampoline, args); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(settrace_doc, -"settrace(function)\n\ -\n\ -Set the global debug tracing function. It will be called on each\n\ -function call. See the debugger chapter in the library manual." -); - -static PyObject * -sys_setprofile(PyObject *self, PyObject *args) -{ - if (trace_init() == -1) - return NULL; - if (args == Py_None) - PyEval_SetProfile(NULL, NULL); - else - PyEval_SetProfile(profile_trampoline, args); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(setprofile_doc, -"setprofile(function)\n\ -\n\ -Set the profiling function. It will be called on each function call\n\ -and return. See the profiler chapter in the library manual." -); - -static PyObject * -sys_setcheckinterval(PyObject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_Py_CheckInterval)) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(setcheckinterval_doc, -"setcheckinterval(n)\n\ -\n\ -Tell the Python interpreter to check for asynchronous events every\n\ -n instructions. This also affects how often thread switches occur." -); - -static PyObject * -sys_getcheckinterval(PyObject *self, PyObject *args) -{ - return PyInt_FromLong(_Py_CheckInterval); -} - -PyDoc_STRVAR(getcheckinterval_doc, -"getcheckinterval() -> current check interval; see setcheckinterval()." -); - -static PyObject * -sys_setrecursionlimit(PyObject *self, PyObject *args) -{ - int new_limit; - if (!PyArg_ParseTuple(args, "i:setrecursionlimit", &new_limit)) - return NULL; - if (new_limit <= 0) { - PyErr_SetString(PyExc_ValueError, - "recursion limit must be positive"); - return NULL; - } - Py_SetRecursionLimit(new_limit); - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(setrecursionlimit_doc, -"setrecursionlimit(n)\n\ -\n\ -Set the maximum depth of the Python interpreter stack to n. This\n\ -limit prevents infinite recursion from causing an overflow of the C\n\ -stack and crashing Python. The highest possible limit is platform-\n\ -dependent." -); - -static PyObject * -sys_getrecursionlimit(PyObject *self) -{ - return PyInt_FromLong(Py_GetRecursionLimit()); -} - -PyDoc_STRVAR(getrecursionlimit_doc, -"getrecursionlimit()\n\ -\n\ -Return the current value of the recursion limit, the maximum depth\n\ -of the Python interpreter stack. This limit prevents infinite\n\ -recursion from causing an overflow of the C stack and crashing Python." -); - -#ifdef MS_WINDOWS -PyDoc_STRVAR(getwindowsversion_doc, -"getwindowsversion()\n\ -\n\ -Return information about the running version of Windows.\n\ -The result is a tuple of (major, minor, build, platform, text)\n\ -All elements are numbers, except text which is a string.\n\ -Platform may be 0 for win32s, 1 for Windows 9x/ME, 2 for Windows NT/2000/XP\n\ -" -); - -static PyObject * -sys_getwindowsversion(PyObject *self) -{ -#ifdef MS_XBOX - return PyErr_SetFromWindowsErr(0); -#else - OSVERSIONINFO ver; - ver.dwOSVersionInfoSize = sizeof(ver); - if (!GetVersionEx(&ver)) - return PyErr_SetFromWindowsErr(0); - return Py_BuildValue("HHHHs", - ver.dwMajorVersion, - ver.dwMinorVersion, - ver.dwBuildNumber, - ver.dwPlatformId, - ver.szCSDVersion); -#endif -} - -#endif /* MS_WINDOWS */ - -#ifdef HAVE_DLOPEN -static PyObject * -sys_setdlopenflags(PyObject *self, PyObject *args) -{ - int new_val; - PyThreadState *tstate = PyThreadState_Get(); - if (!PyArg_ParseTuple(args, "i:setdlopenflags", &new_val)) - return NULL; - if (!tstate) - return NULL; - tstate->interp->dlopenflags = new_val; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(setdlopenflags_doc, -"setdlopenflags(n) -> None\n\ -\n\ -Set the flags that will be used for dlopen() calls. Among other\n\ -things, this will enable a lazy resolving of symbols when importing\n\ -a module, if called as sys.setdlopenflags(0)\n\ -To share symbols across extension modules, call as\n\ -sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)" -); - -static PyObject * -sys_getdlopenflags(PyObject *self, PyObject *args) -{ - PyThreadState *tstate = PyThreadState_Get(); - if (!tstate) - return NULL; - return PyInt_FromLong(tstate->interp->dlopenflags); -} - -PyDoc_STRVAR(getdlopenflags_doc, -"getdlopenflags() -> int\n\ -\n\ -Return the current value of the flags that are used for dlopen()\n\ -calls. The flag constants are defined in the dl module." -); -#endif - -#ifdef USE_MALLOPT -/* Link with -lmalloc (or -lmpc) on an SGI */ -#include - -static PyObject * -sys_mdebug(PyObject *self, PyObject *args) -{ - int flag; - if (!PyArg_ParseTuple(args, "i:mdebug", &flag)) - return NULL; - mallopt(M_DEBUG, flag); - Py_INCREF(Py_None); - return Py_None; -} -#endif /* USE_MALLOPT */ - -static PyObject * -sys_getrefcount(PyObject *self, PyObject *arg) -{ - return PyInt_FromLong(arg->ob_refcnt); -} - -#ifdef Py_REF_DEBUG -static PyObject * -sys_gettotalrefcount(PyObject *self) -{ - return PyInt_FromLong(_Py_RefTotal); -} - -#endif /* Py_TRACE_REFS */ - -PyDoc_STRVAR(getrefcount_doc, -"getrefcount(object) -> integer\n\ -\n\ -Return the reference count of object. The count returned is generally\n\ -one higher than you might expect, because it includes the (temporary)\n\ -reference as an argument to getrefcount()." -); - -#ifdef COUNT_ALLOCS -static PyObject * -sys_getcounts(PyObject *self) -{ - extern PyObject *get_counts(void); - - return get_counts(); -} -#endif - -PyDoc_STRVAR(getframe_doc, -"_getframe([depth]) -> frameobject\n\ -\n\ -Return a frame object from the call stack. If optional integer depth is\n\ -given, return the frame object that many calls below the top of the stack.\n\ -If that is deeper than the call stack, ValueError is raised. The default\n\ -for depth is zero, returning the frame at the top of the call stack.\n\ -\n\ -This function should be used for internal and specialized\n\ -purposes only." -); - -static PyObject * -sys_getframe(PyObject *self, PyObject *args) -{ - PyFrameObject *f = PyThreadState_Get()->frame; - int depth = -1; - - if (!PyArg_ParseTuple(args, "|i:_getframe", &depth)) - return NULL; - - while (depth > 0 && f != NULL) { - f = f->f_back; - --depth; - } - if (f == NULL) { - PyErr_SetString(PyExc_ValueError, - "call stack is not deep enough"); - return NULL; - } - Py_INCREF(f); - return (PyObject*)f; -} - -PyDoc_STRVAR(call_tracing_doc, -"call_tracing(func, args) -> object\n\ -\n\ -Call func(*args), while tracing is enabled. The tracing state is\n\ -saved, and restored afterwards. This is intended to be called from\n\ -a debugger from a checkpoint, to recursively debug some other code." -); - -static PyObject * -sys_call_tracing(PyObject *self, PyObject *args) -{ - PyObject *func, *funcargs; - if (!PyArg_ParseTuple(args, "OO:call_tracing", &func, &funcargs)) - return NULL; - return _PyEval_CallTracing(func, funcargs); -} - -PyDoc_STRVAR(callstats_doc, -"callstats() -> tuple of integers\n\ -\n\ -Return a tuple of function call statistics, if CALL_PROFILE was defined\n\ -when Python was built. Otherwise, return None.\n\ -\n\ -When enabled, this function returns detailed, implementation-specific\n\ -details about the number of function calls executed. The return value is\n\ -a 11-tuple where the entries in the tuple are counts of:\n\ -0. all function calls\n\ -1. calls to PyFunction_Type objects\n\ -2. PyFunction calls that do not create an argument tuple\n\ -3. PyFunction calls that do not create an argument tuple\n\ - and bypass PyEval_EvalCodeEx()\n\ -4. PyMethod calls\n\ -5. PyMethod calls on bound methods\n\ -6. PyType calls\n\ -7. PyCFunction calls\n\ -8. generator calls\n\ -9. All other calls\n\ -10. Number of stack pops performed by call_function()" -); - -#ifdef Py_TRACE_REFS -/* Defined in objects.c because it uses static globals if that file */ -extern PyObject *_Py_GetObjects(PyObject *, PyObject *); -#endif - -#ifdef DYNAMIC_EXECUTION_PROFILE -/* Defined in ceval.c because it uses static globals if that file */ -extern PyObject *_Py_GetDXProfile(PyObject *, PyObject *); -#endif - -static PyMethodDef sys_methods[] = { - /* Might as well keep this in alphabetic order */ - {"callstats", (PyCFunction)PyEval_GetCallStats, METH_NOARGS, - callstats_doc}, - {"displayhook", sys_displayhook, METH_O, displayhook_doc}, - {"exc_info", sys_exc_info, METH_NOARGS, exc_info_doc}, - {"exc_clear", sys_exc_clear, METH_NOARGS, exc_clear_doc}, - {"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc}, - {"exit", sys_exit, METH_VARARGS, exit_doc}, -#ifdef Py_USING_UNICODE - {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, - METH_NOARGS, getdefaultencoding_doc}, -#endif -#ifdef HAVE_DLOPEN - {"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS, - getdlopenflags_doc}, -#endif -#ifdef COUNT_ALLOCS - {"getcounts", (PyCFunction)sys_getcounts, METH_NOARGS}, -#endif -#ifdef DYNAMIC_EXECUTION_PROFILE - {"getdxp", _Py_GetDXProfile, METH_VARARGS}, -#endif -#ifdef Py_USING_UNICODE - {"getfilesystemencoding", (PyCFunction)sys_getfilesystemencoding, - METH_NOARGS, getfilesystemencoding_doc}, -#endif -#ifdef Py_TRACE_REFS - {"getobjects", _Py_GetObjects, METH_VARARGS}, -#endif -#ifdef Py_REF_DEBUG - {"gettotalrefcount", (PyCFunction)sys_gettotalrefcount, METH_NOARGS}, -#endif - {"getrefcount", (PyCFunction)sys_getrefcount, METH_O, getrefcount_doc}, - {"getrecursionlimit", (PyCFunction)sys_getrecursionlimit, METH_NOARGS, - getrecursionlimit_doc}, - {"_getframe", sys_getframe, METH_VARARGS, getframe_doc}, -#ifdef MS_WINDOWS - {"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS, - getwindowsversion_doc}, -#endif /* MS_WINDOWS */ -#ifdef USE_MALLOPT - {"mdebug", sys_mdebug, METH_VARARGS}, -#endif -#ifdef Py_USING_UNICODE - {"setdefaultencoding", sys_setdefaultencoding, METH_VARARGS, - setdefaultencoding_doc}, -#endif - {"setcheckinterval", sys_setcheckinterval, METH_VARARGS, - setcheckinterval_doc}, - {"getcheckinterval", sys_getcheckinterval, METH_NOARGS, - getcheckinterval_doc}, -#ifdef HAVE_DLOPEN - {"setdlopenflags", sys_setdlopenflags, METH_VARARGS, - setdlopenflags_doc}, -#endif - {"setprofile", sys_setprofile, METH_O, setprofile_doc}, - {"setrecursionlimit", sys_setrecursionlimit, METH_VARARGS, - setrecursionlimit_doc}, - {"settrace", sys_settrace, METH_O, settrace_doc}, - {"call_tracing", sys_call_tracing, METH_VARARGS, call_tracing_doc}, - {NULL, NULL} /* sentinel */ -}; - -static PyObject * -list_builtin_module_names(void) -{ - PyObject *list = PyList_New(0); - int i; - if (list == NULL) - return NULL; - for (i = 0; PyImport_Inittab[i].name != NULL; i++) { - PyObject *name = PyString_FromString( - PyImport_Inittab[i].name); - if (name == NULL) - break; - PyList_Append(list, name); - Py_DECREF(name); - } - if (PyList_Sort(list) != 0) { - Py_DECREF(list); - list = NULL; - } - if (list) { - PyObject *v = PyList_AsTuple(list); - Py_DECREF(list); - list = v; - } - return list; -} - -static PyObject *warnoptions = NULL; - -void -PySys_ResetWarnOptions(void) -{ - if (warnoptions == NULL || !PyList_Check(warnoptions)) - return; - PyList_SetSlice(warnoptions, 0, PyList_GET_SIZE(warnoptions), NULL); -} - -void -PySys_AddWarnOption(char *s) -{ - PyObject *str; - - if (warnoptions == NULL || !PyList_Check(warnoptions)) { - Py_XDECREF(warnoptions); - warnoptions = PyList_New(0); - if (warnoptions == NULL) - return; - } - str = PyString_FromString(s); - if (str != NULL) { - PyList_Append(warnoptions, str); - Py_DECREF(str); - } -} - -/* XXX This doc string is too long to be a single string literal in VC++ 5.0. - Two literals concatenated works just fine. If you have a K&R compiler - or other abomination that however *does* understand longer strings, - get rid of the !!! comment in the middle and the quotes that surround it. */ -PyDoc_VAR(sys_doc) = -PyDoc_STR( -"This module provides access to some objects used or maintained by the\n\ -interpreter and to functions that interact strongly with the interpreter.\n\ -\n\ -Dynamic objects:\n\ -\n\ -argv -- command line arguments; argv[0] is the script pathname if known\n\ -path -- module search path; path[0] is the script directory, else ''\n\ -modules -- dictionary of loaded modules\n\ -\n\ -displayhook -- called to show results in an interactive session\n\ -excepthook -- called to handle any uncaught exception other than SystemExit\n\ - To customize printing in an interactive session or to install a custom\n\ - top-level exception handler, assign other functions to replace these.\n\ -\n\ -exitfunc -- if sys.exitfunc exists, this routine is called when Python exits\n\ - Assigning to sys.exitfunc is deprecated; use the atexit module instead.\n\ -\n\ -stdin -- standard input file object; used by raw_input() and input()\n\ -stdout -- standard output file object; used by the print statement\n\ -stderr -- standard error object; used for error messages\n\ - By assigning other file objects (or objects that behave like files)\n\ - to these, it is possible to redirect all of the interpreter's I/O.\n\ -\n\ -last_type -- type of last uncaught exception\n\ -last_value -- value of last uncaught exception\n\ -last_traceback -- traceback of last uncaught exception\n\ - These three are only available in an interactive session after a\n\ - traceback has been printed.\n\ -\n\ -exc_type -- type of exception currently being handled\n\ -exc_value -- value of exception currently being handled\n\ -exc_traceback -- traceback of exception currently being handled\n\ - The function exc_info() should be used instead of these three,\n\ - because it is thread-safe.\n\ -" -) -/* concatenating string here */ -PyDoc_STR( -"\n\ -Static objects:\n\ -\n\ -maxint -- the largest supported integer (the smallest is -maxint-1)\n\ -maxunicode -- the largest supported character\n\ -builtin_module_names -- tuple of module names built into this interpreter\n\ -version -- the version of this interpreter as a string\n\ -version_info -- version information as a tuple\n\ -hexversion -- version information encoded as a single integer\n\ -copyright -- copyright notice pertaining to this interpreter\n\ -platform -- platform identifier\n\ -executable -- pathname of this Python interpreter\n\ -prefix -- prefix used to find the Python library\n\ -exec_prefix -- prefix used to find the machine-specific Python library\n\ -" -) -#ifdef MS_WINDOWS -/* concatenating string here */ -PyDoc_STR( -"dllhandle -- [Windows only] integer handle of the Python DLL\n\ -winver -- [Windows only] version number of the Python DLL\n\ -" -) -#endif /* MS_WINDOWS */ -PyDoc_STR( -"__stdin__ -- the original stdin; don't touch!\n\ -__stdout__ -- the original stdout; don't touch!\n\ -__stderr__ -- the original stderr; don't touch!\n\ -__displayhook__ -- the original displayhook; don't touch!\n\ -__excepthook__ -- the original excepthook; don't touch!\n\ -\n\ -Functions:\n\ -\n\ -displayhook() -- print an object to the screen, and save it in __builtin__._\n\ -excepthook() -- print an exception and its traceback to sys.stderr\n\ -exc_info() -- return thread-safe information about the current exception\n\ -exc_clear() -- clear the exception state for the current thread\n\ -exit() -- exit the interpreter by raising SystemExit\n\ -getdlopenflags() -- returns flags to be used for dlopen() calls\n\ -getrefcount() -- return the reference count for an object (plus one :-)\n\ -getrecursionlimit() -- return the max recursion depth for the interpreter\n\ -setcheckinterval() -- control how often the interpreter checks for events\n\ -setdlopenflags() -- set the flags to be used for dlopen() calls\n\ -setprofile() -- set the global profiling function\n\ -setrecursionlimit() -- set the max recursion depth for the interpreter\n\ -settrace() -- set the global debug tracing function\n\ -" -) -/* end of sys_doc */ ; - -PyObject * -_PySys_Init(void) -{ - PyObject *m, *v, *sysdict; - PyObject *sysin, *sysout, *syserr; - char *s; -#ifdef MS_WINDOWS - char buf[10]; -#endif - - m = Py_InitModule3("sys", sys_methods, sys_doc); - sysdict = PyModule_GetDict(m); - - sysin = PyFile_FromFile(stdin, "", "r", NULL); - sysout = PyFile_FromFile(stdout, "", "w", NULL); - syserr = PyFile_FromFile(stderr, "", "w", NULL); - if (PyErr_Occurred()) - return NULL; -#if defined(MS_WINDOWS) && !defined(MS_XBOX) - if(isatty(_fileno(stdin))){ - sprintf(buf, "cp%d", GetConsoleCP()); - if (!PyFile_SetEncoding(sysin, buf)) - return NULL; - } - if(isatty(_fileno(stdout))) { - sprintf(buf, "cp%d", GetConsoleOutputCP()); - if (!PyFile_SetEncoding(sysout, buf)) - return NULL; - } -#endif - - PyDict_SetItemString(sysdict, "stdin", sysin); - PyDict_SetItemString(sysdict, "stdout", sysout); - PyDict_SetItemString(sysdict, "stderr", syserr); - /* Make backup copies for cleanup */ - PyDict_SetItemString(sysdict, "__stdin__", sysin); - PyDict_SetItemString(sysdict, "__stdout__", sysout); - PyDict_SetItemString(sysdict, "__stderr__", syserr); - PyDict_SetItemString(sysdict, "__displayhook__", - PyDict_GetItemString(sysdict, "displayhook")); - PyDict_SetItemString(sysdict, "__excepthook__", - PyDict_GetItemString(sysdict, "excepthook")); - Py_XDECREF(sysin); - Py_XDECREF(sysout); - Py_XDECREF(syserr); - PyDict_SetItemString(sysdict, "version", - v = PyString_FromString(Py_GetVersion())); - Py_XDECREF(v); - PyDict_SetItemString(sysdict, "hexversion", - v = PyInt_FromLong(PY_VERSION_HEX)); - Py_XDECREF(v); - /* - * These release level checks are mutually exclusive and cover - * the field, so don't get too fancy with the pre-processor! - */ -#if PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_ALPHA - s = "alpha"; -#elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_BETA - s = "beta"; -#elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_GAMMA - s = "candidate"; -#elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_FINAL - s = "final"; -#endif - PyDict_SetItemString(sysdict, "version_info", - v = Py_BuildValue("iiisi", PY_MAJOR_VERSION, - PY_MINOR_VERSION, - PY_MICRO_VERSION, s, - PY_RELEASE_SERIAL)); - Py_XDECREF(v); - PyDict_SetItemString(sysdict, "api_version", - v = PyInt_FromLong(PYTHON_API_VERSION)); - Py_XDECREF(v); - PyDict_SetItemString(sysdict, "copyright", - v = PyString_FromString(Py_GetCopyright())); - Py_XDECREF(v); - PyDict_SetItemString(sysdict, "platform", - v = PyString_FromString(Py_GetPlatform())); - Py_XDECREF(v); - PyDict_SetItemString(sysdict, "executable", - v = PyString_FromString(Py_GetProgramFullPath())); - Py_XDECREF(v); - PyDict_SetItemString(sysdict, "prefix", - v = PyString_FromString(Py_GetPrefix())); - Py_XDECREF(v); - PyDict_SetItemString(sysdict, "exec_prefix", - v = PyString_FromString(Py_GetExecPrefix())); - Py_XDECREF(v); - PyDict_SetItemString(sysdict, "maxint", - v = PyInt_FromLong(PyInt_GetMax())); - Py_XDECREF(v); -#ifdef Py_USING_UNICODE - PyDict_SetItemString(sysdict, "maxunicode", - v = PyInt_FromLong(PyUnicode_GetMax())); - Py_XDECREF(v); -#endif - PyDict_SetItemString(sysdict, "builtin_module_names", - v = list_builtin_module_names()); - Py_XDECREF(v); - { - /* Assumes that longs are at least 2 bytes long. - Should be safe! */ - unsigned long number = 1; - char *value; - - s = (char *) &number; - if (s[0] == 0) - value = "big"; - else - value = "little"; - PyDict_SetItemString(sysdict, "byteorder", - v = PyString_FromString(value)); - Py_XDECREF(v); - } -#ifdef MS_COREDLL - PyDict_SetItemString(sysdict, "dllhandle", - v = PyLong_FromVoidPtr(PyWin_DLLhModule)); - Py_XDECREF(v); - PyDict_SetItemString(sysdict, "winver", - v = PyString_FromString(PyWin_DLLVersionString)); - Py_XDECREF(v); -#endif - if (warnoptions == NULL) { - warnoptions = PyList_New(0); - } - else { - Py_INCREF(warnoptions); - } - if (warnoptions != NULL) { - PyDict_SetItemString(sysdict, "warnoptions", warnoptions); - } - - if (PyErr_Occurred()) - return NULL; - return m; -} - -static PyObject * -makepathobject(char *path, int delim) -{ - int i, n; - char *p; - PyObject *v, *w; - - n = 1; - p = path; - while ((p = strchr(p, delim)) != NULL) { - n++; - p++; - } - v = PyList_New(n); - if (v == NULL) - return NULL; - for (i = 0; ; i++) { - p = strchr(path, delim); - if (p == NULL) - p = strchr(path, '\0'); /* End of string */ - w = PyString_FromStringAndSize(path, (int) (p - path)); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyList_SetItem(v, i, w); - if (*p == '\0') - break; - path = p+1; - } - return v; -} - -void -PySys_SetPath(char *path) -{ - PyObject *v; - if ((v = makepathobject(path, DELIM)) == NULL) - Py_FatalError("can't create sys.path"); - if (PySys_SetObject("path", v) != 0) - Py_FatalError("can't assign sys.path"); - Py_DECREF(v); -} - -static PyObject * -makeargvobject(int argc, char **argv) -{ - PyObject *av; - if (argc <= 0 || argv == NULL) { - /* Ensure at least one (empty) argument is seen */ - static char *empty_argv[1] = {""}; - argv = empty_argv; - argc = 1; - } - av = PyList_New(argc); - if (av != NULL) { - int i; - for (i = 0; i < argc; i++) { -#ifdef __VMS - PyObject *v; - - /* argv[0] is the script pathname if known */ - if (i == 0) { - char* fn = decc$translate_vms(argv[0]); - if ((fn == (char *)0) || fn == (char *)-1) - v = PyString_FromString(argv[0]); - else - v = PyString_FromString( - decc$translate_vms(argv[0])); - } else - v = PyString_FromString(argv[i]); -#else - PyObject *v = PyString_FromString(argv[i]); -#endif - if (v == NULL) { - Py_DECREF(av); - av = NULL; - break; - } - PyList_SetItem(av, i, v); - } - } - return av; -} - -void -PySys_SetArgv(int argc, char **argv) -{ -#if defined(HAVE_REALPATH) - char fullpath[MAXPATHLEN]; -#elif defined(MS_WINDOWS) - char fullpath[MAX_PATH]; -#endif - PyObject *av = makeargvobject(argc, argv); - PyObject *path = PySys_GetObject("path"); - if (av == NULL) - Py_FatalError("no mem for sys.argv"); - if (PySys_SetObject("argv", av) != 0) - Py_FatalError("can't assign sys.argv"); - if (path != NULL) { - char *argv0 = argv[0]; - char *p = NULL; - int n = 0; - PyObject *a; -#ifdef HAVE_READLINK - char link[MAXPATHLEN+1]; - char argv0copy[2*MAXPATHLEN+1]; - int nr = 0; - if (argc > 0 && argv0 != NULL) - nr = readlink(argv0, link, MAXPATHLEN); - if (nr > 0) { - /* It's a symlink */ - link[nr] = '\0'; - if (link[0] == SEP) - argv0 = link; /* Link to absolute path */ - else if (strchr(link, SEP) == NULL) - ; /* Link without path */ - else { - /* Must join(dirname(argv0), link) */ - char *q = strrchr(argv0, SEP); - if (q == NULL) - argv0 = link; /* argv0 without path */ - else { - /* Must make a copy */ - strcpy(argv0copy, argv0); - q = strrchr(argv0copy, SEP); - strcpy(q+1, link); - argv0 = argv0copy; - } - } - } -#endif /* HAVE_READLINK */ -#if SEP == '\\' /* Special case for MS filename syntax */ - if (argc > 0 && argv0 != NULL) { - char *q; -#if defined(MS_WINDOWS) && !defined(MS_XBOX) - char *ptemp; - if (GetFullPathName(argv0, - sizeof(fullpath), - fullpath, - &ptemp)) { - argv0 = fullpath; - } -#endif - p = strrchr(argv0, SEP); - /* Test for alternate separator */ - q = strrchr(p ? p : argv0, '/'); - if (q != NULL) - p = q; - if (p != NULL) { - n = p + 1 - argv0; - if (n > 1 && p[-1] != ':') - n--; /* Drop trailing separator */ - } - } -#else /* All other filename syntaxes */ - if (argc > 0 && argv0 != NULL) { -#if defined(HAVE_REALPATH) - if (realpath(argv0, fullpath)) { - argv0 = fullpath; - } -#endif - p = strrchr(argv0, SEP); - } - if (p != NULL) { -#ifndef RISCOS - n = p + 1 - argv0; -#else /* don't include trailing separator */ - n = p - argv0; -#endif /* RISCOS */ -#if SEP == '/' /* Special case for Unix filename syntax */ - if (n > 1) - n--; /* Drop trailing separator */ -#endif /* Unix */ - } -#endif /* All others */ - a = PyString_FromStringAndSize(argv0, n); - if (a == NULL) - Py_FatalError("no mem for sys.path insertion"); - if (PyList_Insert(path, 0, a) < 0) - Py_FatalError("sys.path.insert(0) failed"); - Py_DECREF(a); - } - Py_DECREF(av); -} - - -/* APIs to write to sys.stdout or sys.stderr using a printf-like interface. - Adapted from code submitted by Just van Rossum. - - PySys_WriteStdout(format, ...) - PySys_WriteStderr(format, ...) - - The first function writes to sys.stdout; the second to sys.stderr. When - there is a problem, they write to the real (C level) stdout or stderr; - no exceptions are raised. - - Both take a printf-style format string as their first argument followed - by a variable length argument list determined by the format string. - - *** WARNING *** - - The format should limit the total size of the formatted output string to - 1000 bytes. In particular, this means that no unrestricted "%s" formats - should occur; these should be limited using "%.s where is a - decimal number calculated so that plus the maximum size of other - formatted text does not exceed 1000 bytes. Also watch out for "%f", - which can print hundreds of digits for very large numbers. - - */ - -static void -mywrite(char *name, FILE *fp, const char *format, va_list va) -{ - PyObject *file; - PyObject *error_type, *error_value, *error_traceback; - - PyErr_Fetch(&error_type, &error_value, &error_traceback); - file = PySys_GetObject(name); - if (file == NULL || PyFile_AsFile(file) == fp) - vfprintf(fp, format, va); - else { - char buffer[1001]; - const int written = PyOS_vsnprintf(buffer, sizeof(buffer), - format, va); - if (PyFile_WriteString(buffer, file) != 0) { - PyErr_Clear(); - fputs(buffer, fp); - } - if (written < 0 || written >= sizeof(buffer)) { - const char *truncated = "... truncated"; - if (PyFile_WriteString(truncated, file) != 0) { - PyErr_Clear(); - fputs(truncated, fp); - } - } - } - PyErr_Restore(error_type, error_value, error_traceback); -} - -void -PySys_WriteStdout(const char *format, ...) -{ - va_list va; - - va_start(va, format); - mywrite("stdout", stdout, format, va); - va_end(va); -} - -void -PySys_WriteStderr(const char *format, ...) -{ - va_list va; - - va_start(va, format); - mywrite("stderr", stderr, format, va); - va_end(va); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/thread.c b/SDKs/XPlatform/Cypython-2.3.3/Python/thread.c deleted file mode 100644 index 0e61581b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/thread.c +++ /dev/null @@ -1,248 +0,0 @@ - -/* Thread package. - This is intended to be usable independently from Python. - The implementation for system foobar is in a file thread_foobar.h - which is included by this file dependent on config settings. - Stuff shared by all thread_*.h files is collected here. */ - -#include "Python.h" - -#ifndef DONT_HAVE_STDIO_H -#include -#endif - -#ifdef HAVE_STDLIB_H -#include -#else -#ifdef Py_DEBUG -extern char *getenv(const char *); -#endif -#endif - -#ifdef __DGUX -#define _USING_POSIX4A_DRAFT6 -#endif - -#ifdef __sgi -#ifndef HAVE_PTHREAD_H /* XXX Need to check in configure.in */ -#undef _POSIX_THREADS -#endif -#endif - -#include "pythread.h" - -#ifndef _POSIX_THREADS - -#ifdef __sgi -#define SGI_THREADS -#endif - -#ifdef HAVE_THREAD_H -#define SOLARIS_THREADS -#endif - -#if defined(sun) && !defined(SOLARIS_THREADS) -#define SUN_LWP -#endif - -#if defined(__MWERKS__) && !defined(__BEOS__) -#define _POSIX_THREADS -#endif - -#endif /* _POSIX_THREADS */ - - -#ifdef Py_DEBUG -static int thread_debug = 0; -#define dprintf(args) (void)((thread_debug & 1) && printf args) -#define d2printf(args) ((thread_debug & 8) && printf args) -#else -#define dprintf(args) -#define d2printf(args) -#endif - -static int initialized; - -static void PyThread__init_thread(void); /* Forward */ - -void PyThread_init_thread(void) -{ -#ifdef Py_DEBUG - char *p = Py_GETENV("THREADDEBUG"); - - if (p) { - if (*p) - thread_debug = atoi(p); - else - thread_debug = 1; - } -#endif /* Py_DEBUG */ - if (initialized) - return; - initialized = 1; - dprintf(("PyThread_init_thread called\n")); - PyThread__init_thread(); -} - -#ifdef SGI_THREADS -#include "thread_sgi.h" -#endif - -#ifdef SOLARIS_THREADS -#include "thread_solaris.h" -#endif - -#ifdef SUN_LWP -#include "thread_lwp.h" -#endif - -#ifdef HAVE_PTH -#include "thread_pth.h" -#undef _POSIX_THREADS -#endif - -#ifdef _POSIX_THREADS -#include "thread_pthread.h" -#endif - -#ifdef C_THREADS -#include "thread_cthread.h" -#endif - -#ifdef NT_THREADS -#include "thread_nt.h" -#endif - -#ifdef OS2_THREADS -#include "thread_os2.h" -#endif - -#ifdef BEOS_THREADS -#include "thread_beos.h" -#endif - -#ifdef WINCE_THREADS -#include "thread_wince.h" -#endif - -#ifdef PLAN9_THREADS -#include "thread_plan9.h" -#endif - -#ifdef ATHEOS_THREADS -#include "thread_atheos.h" -#endif - -/* -#ifdef FOOBAR_THREADS -#include "thread_foobar.h" -#endif -*/ - -#ifndef Py_HAVE_NATIVE_TLS -/* If the platform has not supplied a platform specific - TLS implementation, provide our own. - - This code stolen from "thread_sgi.h", where it was the only - implementation of an existing Python TLS API. -*/ -/* - * Per-thread data ("key") support. - */ - -struct key { - struct key *next; - long id; - int key; - void *value; -}; - -static struct key *keyhead = NULL; -static int nkeys = 0; -static PyThread_type_lock keymutex = NULL; - -static struct key *find_key(int key, void *value) -{ - struct key *p; - long id = PyThread_get_thread_ident(); - for (p = keyhead; p != NULL; p = p->next) { - if (p->id == id && p->key == key) - return p; - } - if (value == NULL) - return NULL; - p = (struct key *)malloc(sizeof(struct key)); - if (p != NULL) { - p->id = id; - p->key = key; - p->value = value; - PyThread_acquire_lock(keymutex, 1); - p->next = keyhead; - keyhead = p; - PyThread_release_lock(keymutex); - } - return p; -} - -int PyThread_create_key(void) -{ - if (keymutex == NULL) - keymutex = PyThread_allocate_lock(); - return ++nkeys; -} - -void PyThread_delete_key(int key) -{ - struct key *p, **q; - PyThread_acquire_lock(keymutex, 1); - q = &keyhead; - while ((p = *q) != NULL) { - if (p->key == key) { - *q = p->next; - free((void *)p); - /* NB This does *not* free p->value! */ - } - else - q = &p->next; - } - PyThread_release_lock(keymutex); -} - -int PyThread_set_key_value(int key, void *value) -{ - struct key *p = find_key(key, value); - if (p == NULL) - return -1; - else - return 0; -} - -void *PyThread_get_key_value(int key) -{ - struct key *p = find_key(key, NULL); - if (p == NULL) - return NULL; - else - return p->value; -} - -void PyThread_delete_key_value(int key) -{ - long id = PyThread_get_thread_ident(); - struct key *p, **q; - PyThread_acquire_lock(keymutex, 1); - q = &keyhead; - while ((p = *q) != NULL) { - if (p->key == key && p->id == id) { - *q = p->next; - free((void *)p); - /* NB This does *not* free p->value! */ - break; - } - else - q = &p->next; - } - PyThread_release_lock(keymutex); -} - -#endif /* Py_HAVE_NATIVE_TLS */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_atheos.h b/SDKs/XPlatform/Cypython-2.3.3/Python/thread_atheos.h deleted file mode 100644 index e3dd7331..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_atheos.h +++ /dev/null @@ -1,300 +0,0 @@ -/* Threading for AtheOS. - Based on thread_beos.h. */ - -#include -#include -#include -#include -#include - -/* Missing decl from threads.h */ -extern int exit_thread(int); - - -/* Undefine FASTLOCK to play with simple semaphores. */ -#define FASTLOCK - - -#ifdef FASTLOCK - -/* Use an atomic counter and a semaphore for maximum speed. */ -typedef struct fastmutex { - sem_id sem; - atomic_t count; -} fastmutex_t; - - -static int fastmutex_create(const char *name, fastmutex_t * mutex); -static int fastmutex_destroy(fastmutex_t * mutex); -static int fastmutex_lock(fastmutex_t * mutex); -static int fastmutex_timedlock(fastmutex_t * mutex, bigtime_t timeout); -static int fastmutex_unlock(fastmutex_t * mutex); - - -static int fastmutex_create(const char *name, fastmutex_t * mutex) -{ - mutex->count = 0; - mutex->sem = create_semaphore(name, 0, 0); - return (mutex->sem < 0) ? -1 : 0; -} - - -static int fastmutex_destroy(fastmutex_t * mutex) -{ - if (fastmutex_timedlock(mutex, 0) == 0 || errno == EWOULDBLOCK) { - return delete_semaphore(mutex->sem); - } - return 0; -} - - -static int fastmutex_lock(fastmutex_t * mutex) -{ - atomic_t prev = atomic_add(&mutex->count, 1); - if (prev > 0) - return lock_semaphore(mutex->sem); - return 0; -} - - -static int fastmutex_timedlock(fastmutex_t * mutex, bigtime_t timeout) -{ - atomic_t prev = atomic_add(&mutex->count, 1); - if (prev > 0) - return lock_semaphore_x(mutex->sem, 1, 0, timeout); - return 0; -} - - -static int fastmutex_unlock(fastmutex_t * mutex) -{ - atomic_t prev = atomic_add(&mutex->count, -1); - if (prev > 1) - return unlock_semaphore(mutex->sem); - return 0; -} - - -#endif /* FASTLOCK */ - - -/* - * Initialization. - * - */ -static void PyThread__init_thread(void) -{ - /* Do nothing. */ - return; -} - - -/* - * Thread support. - * - */ - -static atomic_t thread_count = 0; - -long PyThread_start_new_thread(void (*func) (void *), void *arg) -{ - status_t success = -1; - thread_id tid; - char name[OS_NAME_LENGTH]; - atomic_t this_thread; - - dprintf(("PyThread_start_new_thread called\n")); - - this_thread = atomic_add(&thread_count, 1); - PyOS_snprintf(name, sizeof(name), "python thread (%d)", this_thread); - - tid = spawn_thread(name, func, NORMAL_PRIORITY, 0, arg); - if (tid < 0) { - dprintf(("PyThread_start_new_thread spawn_thread failed: %s\n", strerror(errno))); - } else { - success = resume_thread(tid); - if (success < 0) { - dprintf(("PyThread_start_new_thread resume_thread failed: %s\n", strerror(errno))); - } - } - - return (success < 0 ? -1 : tid); -} - - -long PyThread_get_thread_ident(void) -{ - return get_thread_id(NULL); -} - - -static void do_PyThread_exit_thread(int no_cleanup) -{ - dprintf(("PyThread_exit_thread called\n")); - - /* Thread-safe way to read a variable without a mutex: */ - if (atomic_add(&thread_count, 0) == 0) { - /* No threads around, so exit main(). */ - if (no_cleanup) - _exit(0); - else - exit(0); - } else { - /* We're a thread */ - exit_thread(0); - } -} - - -void PyThread_exit_thread(void) -{ - do_PyThread_exit_thread(0); -} - - -void PyThread__exit_thread(void) -{ - do_PyThread_exit_thread(1); -} - - -#ifndef NO_EXIT_PROG -static void do_PyThread_exit_prog(int status, int no_cleanup) -{ - dprintf(("PyThread_exit_prog(%d) called\n", status)); - - /* No need to do anything, the threads get torn down if main()exits. */ - if (no_cleanup) - _exit(status); - else - exit(status); -} - - -void PyThread_exit_prog(int status) -{ - do_PyThread_exit_prog(status, 0); -} - - -void PyThread__exit_prog(int status) -{ - do_PyThread_exit_prog(status, 1); -} -#endif /* NO_EXIT_PROG */ - - -/* - * Lock support. - * - */ - -static atomic_t lock_count = 0; - -PyThread_type_lock PyThread_allocate_lock(void) -{ -#ifdef FASTLOCK - fastmutex_t *lock; -#else - sem_id sema; -#endif - char name[OS_NAME_LENGTH]; - atomic_t this_lock; - - dprintf(("PyThread_allocate_lock called\n")); - -#ifdef FASTLOCK - lock = (fastmutex_t *) malloc(sizeof(fastmutex_t)); - if (lock == NULL) { - dprintf(("PyThread_allocate_lock failed: out of memory\n")); - return (PyThread_type_lock) NULL; - } -#endif - this_lock = atomic_add(&lock_count, 1); - PyOS_snprintf(name, sizeof(name), "python lock (%d)", this_lock); - -#ifdef FASTLOCK - if (fastmutex_create(name, lock) < 0) { - dprintf(("PyThread_allocate_lock failed: %s\n", - strerror(errno))); - free(lock); - lock = NULL; - } - dprintf(("PyThread_allocate_lock()-> %p\n", lock)); - return (PyThread_type_lock) lock; -#else - sema = create_semaphore(name, 1, 0); - if (sema < 0) { - dprintf(("PyThread_allocate_lock failed: %s\n", - strerror(errno))); - sema = 0; - } - dprintf(("PyThread_allocate_lock()-> %p\n", sema)); - return (PyThread_type_lock) sema; -#endif -} - - -void PyThread_free_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_free_lock(%p) called\n", lock)); - -#ifdef FASTLOCK - if (fastmutex_destroy((fastmutex_t *) lock) < 0) { - dprintf(("PyThread_free_lock(%p) failed: %s\n", lock, - strerror(errno))); - } - free(lock); -#else - if (delete_semaphore((sem_id) lock) < 0) { - dprintf(("PyThread_free_lock(%p) failed: %s\n", lock, - strerror(errno))); - } -#endif -} - - -int PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) -{ - int retval; - - dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, - waitflag)); - -#ifdef FASTLOCK - if (waitflag) - retval = fastmutex_lock((fastmutex_t *) lock); - else - retval = fastmutex_timedlock((fastmutex_t *) lock, 0); -#else - if (waitflag) - retval = lock_semaphore((sem_id) lock); - else - retval = lock_semaphore_x((sem_id) lock, 1, 0, 0); -#endif - if (retval < 0) { - dprintf(("PyThread_acquire_lock(%p, %d) failed: %s\n", - lock, waitflag, strerror(errno))); - } - dprintf(("PyThread_acquire_lock(%p, %d)-> %d\n", lock, waitflag, - retval)); - return retval < 0 ? 0 : 1; -} - - -void PyThread_release_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_release_lock(%p) called\n", lock)); - -#ifdef FASTLOCK - if (fastmutex_unlock((fastmutex_t *) lock) < 0) { - dprintf(("PyThread_release_lock(%p) failed: %s\n", lock, - strerror(errno))); - } -#else - if (unlock_semaphore((sem_id) lock) < 0) { - dprintf(("PyThread_release_lock(%p) failed: %s\n", lock, - strerror(errno))); - } -#endif -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_beos.h b/SDKs/XPlatform/Cypython-2.3.3/Python/thread_beos.h deleted file mode 100644 index 7ac48034..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_beos.h +++ /dev/null @@ -1,287 +0,0 @@ -#include -#include -#include - -/* ---------------------------------------------------------------------- - * Fast locking mechanism described by Benoit Schillings (benoit@be.com) - * in the Be Developer's Newsletter, Issue #26 (http://www.be.com/). - */ -typedef struct benaphore { - sem_id _sem; - int32 _atom; -} benaphore_t; - -static status_t benaphore_create( const char *name, benaphore_t *ben ); -static status_t benaphore_destroy( benaphore_t *ben ); -static status_t benaphore_lock( benaphore_t *ben ); -static status_t benaphore_timedlock( benaphore_t *ben, bigtime_t micros ); -static status_t benaphore_unlock( benaphore_t *ben ); - -static status_t benaphore_create( const char *name, benaphore_t *ben ) -{ - if( ben != NULL ) { - ben->_atom = 0; - ben->_sem = create_sem( 0, name ); - - if( ben->_sem < B_NO_ERROR ) { - return B_BAD_SEM_ID; - } - } else { - return EFAULT; - } - - return EOK; -} - -static status_t benaphore_destroy( benaphore_t *ben ) -{ - if( ben->_sem >= B_NO_ERROR ) { - status_t retval = benaphore_timedlock( ben, 0 ); - - if( retval == EOK || retval == EWOULDBLOCK ) { - status_t del_retval = delete_sem( ben->_sem ); - - return del_retval; - } - } - - return B_BAD_SEM_ID; -} - -static status_t benaphore_lock( benaphore_t *ben ) -{ - int32 prev = atomic_add( &(ben->_atom), 1 ); - - if( prev > 0 ) { - return acquire_sem( ben->_sem ); - } - - return EOK; -} - -static status_t benaphore_timedlock( benaphore_t *ben, bigtime_t micros ) -{ - int32 prev = atomic_add( &(ben->_atom), 1 ); - - if( prev > 0 ) { - status_t retval = acquire_sem_etc( ben->_sem, 1, B_TIMEOUT, micros ); - - switch( retval ) { - case B_WOULD_BLOCK: /* Fall through... */ - case B_TIMED_OUT: - return EWOULDBLOCK; - break; - case B_OK: - return EOK; - break; - default: - return retval; - break; - } - } - - return EOK; -} - -static status_t benaphore_unlock( benaphore_t *ben ) -{ - int32 prev = atomic_add( &(ben->_atom), -1 ); - - if( prev > 1 ) { - return release_sem( ben->_sem ); - } - - return EOK; -} - -/* ---------------------------------------------------------------------- - * Initialization. - */ -static void PyThread__init_thread( void ) -{ - /* Do nothing. */ - return; -} - -/* ---------------------------------------------------------------------- - * Thread support. - * - * Only ANSI C, renamed functions here; you can't use K&R on BeOS, - * and there's no legacy thread module to support. - */ - -static int32 thread_count = 0; - -long PyThread_start_new_thread( void (*func)(void *), void *arg ) -{ - status_t success = 0; - thread_id tid; - char name[B_OS_NAME_LENGTH]; - int32 this_thread; - - dprintf(("PyThread_start_new_thread called\n")); - - /* We are so very thread-safe... */ - this_thread = atomic_add( &thread_count, 1 ); - PyOS_snprintf(name, sizeof(name), - "python thread (%d)", this_thread ); - - tid = spawn_thread( (thread_func)func, name, - B_NORMAL_PRIORITY, arg ); - if( tid > B_NO_ERROR ) { - success = resume_thread( tid ); - } - - return ( success == B_NO_ERROR ? tid : -1 ); -} - -long PyThread_get_thread_ident( void ) -{ - /* Presumed to return the current thread's ID... */ - thread_id tid; - tid = find_thread( NULL ); - - return ( tid != B_NAME_NOT_FOUND ? tid : -1 ); -} - -static void do_PyThread_exit_thread( int no_cleanup ) -{ - int32 threads; - - dprintf(("PyThread_exit_thread called\n")); - - /* Thread-safe way to read a variable without a mutex: */ - threads = atomic_add( &thread_count, 0 ); - - if( threads == 0 ) { - /* No threads around, so exit main(). */ - if( no_cleanup ) { - _exit(0); - } else { - exit(0); - } - } else { - /* Oh, we're a thread, let's try to exit gracefully... */ - exit_thread( B_NO_ERROR ); - } -} - -void PyThread_exit_thread( void ) -{ - do_PyThread_exit_thread(0); -} - -void PyThread__exit_thread( void ) -{ - do_PyThread_exit_thread(1); -} - -#ifndef NO_EXIT_PROG -static void do_PyThread_exit_prog( int status, int no_cleanup ) -{ - dprintf(("PyThread_exit_prog(%d) called\n", status)); - - /* No need to do anything, the threads get torn down if main() exits. */ - - if (no_cleanup) { - _exit(status); - } else { - exit(status); - } -} - -void PyThread_exit_prog( int status ) -{ - do_PyThread_exit_prog(status, 0); -} - -void PyThread__exit_prog( int status ) -{ - do_PyThread_exit_prog(status, 1); -} -#endif /* NO_EXIT_PROG */ - -/* ---------------------------------------------------------------------- - * Lock support. - */ - -static int32 lock_count = 0; - -PyThread_type_lock PyThread_allocate_lock( void ) -{ - benaphore_t *lock; - status_t retval; - char name[B_OS_NAME_LENGTH]; - int32 this_lock; - - dprintf(("PyThread_allocate_lock called\n")); - - lock = (benaphore_t *)malloc( sizeof( benaphore_t ) ); - if( lock == NULL ) { - /* TODO: that's bad, raise MemoryError */ - return (PyThread_type_lock)NULL; - } - - this_lock = atomic_add( &lock_count, 1 ); - PyOS_snprintf(name, sizeof(name), "python lock (%d)", this_lock); - - retval = benaphore_create( name, lock ); - if( retval != EOK ) { - /* TODO: that's bad, raise an exception */ - return (PyThread_type_lock)NULL; - } - - dprintf(("PyThread_allocate_lock() -> %p\n", lock)); - return (PyThread_type_lock) lock; -} - -void PyThread_free_lock( PyThread_type_lock lock ) -{ - status_t retval; - - dprintf(("PyThread_free_lock(%p) called\n", lock)); - - retval = benaphore_destroy( (benaphore_t *)lock ); - if( retval != EOK ) { - /* TODO: that's bad, raise an exception */ - return; - } -} - -int PyThread_acquire_lock( PyThread_type_lock lock, int waitflag ) -{ - int success; - status_t retval; - - dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); - - if( waitflag ) { - retval = benaphore_lock( (benaphore_t *)lock ); - } else { - retval = benaphore_timedlock( (benaphore_t *)lock, 0 ); - } - - if( retval == EOK ) { - success = 1; - } else { - success = 0; - - /* TODO: that's bad, raise an exception */ - } - - dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); - return success; -} - -void PyThread_release_lock( PyThread_type_lock lock ) -{ - status_t retval; - - dprintf(("PyThread_release_lock(%p) called\n", lock)); - - retval = benaphore_unlock( (benaphore_t *)lock ); - if( retval != EOK ) { - /* TODO: that's bad, raise an exception */ - return; - } -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_cthread.h b/SDKs/XPlatform/Cypython-2.3.3/Python/thread_cthread.h deleted file mode 100644 index 763599d9..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_cthread.h +++ /dev/null @@ -1,156 +0,0 @@ - -#ifdef MACH_C_THREADS -#include -#endif - -#ifdef HURD_C_THREADS -#include -#endif - -/* - * Initialization. - */ -static void -PyThread__init_thread(void) -{ -#ifndef HURD_C_THREADS - /* Roland McGrath said this should not be used since this is - done while linking to threads */ - cthread_init(); -#else -/* do nothing */ - ; -#endif -} - -/* - * Thread support. - */ -long -PyThread_start_new_thread(void (*func)(void *), void *arg) -{ - int success = 0; /* init not needed when SOLARIS_THREADS and */ - /* C_THREADS implemented properly */ - - dprintf(("PyThread_start_new_thread called\n")); - if (!initialized) - PyThread_init_thread(); - /* looks like solaris detaches the thread to never rejoin - * so well do it here - */ - cthread_detach(cthread_fork((cthread_fn_t) func, arg)); - return success < 0 ? -1 : 0; -} - -long -PyThread_get_thread_ident(void) -{ - if (!initialized) - PyThread_init_thread(); - return (long) cthread_self(); -} - -static void -do_PyThread_exit_thread(int no_cleanup) -{ - dprintf(("PyThread_exit_thread called\n")); - if (!initialized) - if (no_cleanup) - _exit(0); - else - exit(0); - cthread_exit(0); -} - -void -PyThread_exit_thread(void) -{ - do_PyThread_exit_thread(0); -} - -void -PyThread__exit_thread(void) -{ - do_PyThread_exit_thread(1); -} - -#ifndef NO_EXIT_PROG -static -void do_PyThread_exit_prog(int status, int no_cleanup) -{ - dprintf(("PyThread_exit_prog(%d) called\n", status)); - if (!initialized) - if (no_cleanup) - _exit(status); - else - exit(status); - if (no_cleanup) - _exit(status); - else - exit(status); -} - -void -PyThread_exit_prog(int status) -{ - do_PyThread_exit_prog(status, 0); -} - -void -PyThread__exit_prog(int status) -{ - do_PyThread_exit_prog(status, 1); -} -#endif /* NO_EXIT_PROG */ - -/* - * Lock support. - */ -PyThread_type_lock -PyThread_allocate_lock(void) -{ - mutex_t lock; - - dprintf(("PyThread_allocate_lock called\n")); - if (!initialized) - PyThread_init_thread(); - - lock = mutex_alloc(); - if (mutex_init(lock)) { - perror("mutex_init"); - free((void *) lock); - lock = 0; - } - dprintf(("PyThread_allocate_lock() -> %p\n", lock)); - return (PyThread_type_lock) lock; -} - -void -PyThread_free_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_free_lock(%p) called\n", lock)); - mutex_free(lock); -} - -int -PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) -{ - int success = FALSE; - - dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); - if (waitflag) { /* blocking */ - mutex_lock((mutex_t)lock); - success = TRUE; - } else { /* non blocking */ - success = mutex_try_lock((mutex_t)lock); - } - dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); - return success; -} - -void -PyThread_release_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_release_lock(%p) called\n", lock)); - mutex_unlock((mutex_t )lock); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_foobar.h b/SDKs/XPlatform/Cypython-2.3.3/Python/thread_foobar.h deleted file mode 100644 index 1cbc77bc..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_foobar.h +++ /dev/null @@ -1,115 +0,0 @@ - -/* - * Initialization. - */ -static void -PyThread__init_thread(void) -{ -} - -/* - * Thread support. - */ -long -PyThread_start_new_thread(void (*func)(void *), void *arg) -{ - int success = 0; /* init not needed when SOLARIS_THREADS and */ - /* C_THREADS implemented properly */ - - dprintf(("PyThread_start_new_thread called\n")); - if (!initialized) - PyThread_init_thread(); - return success < 0 ? -1 : 0; -} - -long -PyThread_get_thread_ident(void) -{ - if (!initialized) - PyThread_init_thread(); -} - -static -void do_PyThread_exit_thread(int no_cleanup) -{ - dprintf(("PyThread_exit_thread called\n")); - if (!initialized) - if (no_cleanup) - _exit(0); - else - exit(0); -} - -void -PyThread_exit_thread(void) -{ - do_PyThread_exit_thread(0); -} - -void -PyThread__exit_thread(void) -{ - do_PyThread_exit_thread(1); -} - -#ifndef NO_EXIT_PROG -static -void do_PyThread_exit_prog(int status, int no_cleanup) -{ - dprintf(("PyThread_exit_prog(%d) called\n", status)); - if (!initialized) - if (no_cleanup) - _exit(status); - else - exit(status); -} - -void -PyThread_exit_prog(int status) -{ - do_PyThread_exit_prog(status, 0); -} - -void -PyThread__exit_prog(int status) -{ - do_PyThread_exit_prog(status, 1); -} -#endif /* NO_EXIT_PROG */ - -/* - * Lock support. - */ -PyThread_type_lock -PyThread_allocate_lock(void) -{ - - dprintf(("PyThread_allocate_lock called\n")); - if (!initialized) - PyThread_init_thread(); - - dprintf(("PyThread_allocate_lock() -> %p\n", lock)); - return (PyThread_type_lock) lock; -} - -void -PyThread_free_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_free_lock(%p) called\n", lock)); -} - -int -PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) -{ - int success; - - dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); - dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); - return success; -} - -void -PyThread_release_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_release_lock(%p) called\n", lock)); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_lwp.h b/SDKs/XPlatform/Cypython-2.3.3/Python/thread_lwp.h deleted file mode 100644 index d24445b1..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_lwp.h +++ /dev/null @@ -1,149 +0,0 @@ - -#include -#include -#include - -#define STACKSIZE 1000 /* stacksize for a thread */ -#define NSTACKS 2 /* # stacks to be put in cache initially */ - -struct lock { - int lock_locked; - cv_t lock_condvar; - mon_t lock_monitor; -}; - - -/* - * Initialization. - */ -static void PyThread__init_thread(void) -{ - lwp_setstkcache(STACKSIZE, NSTACKS); -} - -/* - * Thread support. - */ - - -long PyThread_start_new_thread(void (*func)(void *), void *arg) -{ - thread_t tid; - int success; - dprintf(("PyThread_start_new_thread called\n")); - if (!initialized) - PyThread_init_thread(); - success = lwp_create(&tid, func, MINPRIO, 0, lwp_newstk(), 1, arg); - return success < 0 ? -1 : 0; -} - -long PyThread_get_thread_ident(void) -{ - thread_t tid; - if (!initialized) - PyThread_init_thread(); - if (lwp_self(&tid) < 0) - return -1; - return tid.thread_id; -} - -static void do_PyThread_exit_thread(int no_cleanup) -{ - dprintf(("PyThread_exit_thread called\n")); - if (!initialized) - if (no_cleanup) - _exit(0); - else - exit(0); - lwp_destroy(SELF); -} - -void PyThread_exit_thread(void) -{ - do_PyThread_exit_thread(0); -} - -void PyThread__exit_thread(void) -{ - do_PyThread_exit_thread(1); -} - -#ifndef NO_EXIT_PROG -static void do_PyThread_exit_prog(int status, int no_cleanup) -{ - dprintf(("PyThread_exit_prog(%d) called\n", status)); - if (!initialized) - if (no_cleanup) - _exit(status); - else - exit(status); - pod_exit(status); -} - -void PyThread_exit_prog(int status) -{ - do_PyThread_exit_prog(status, 0); -} - -void PyThread__exit_prog(int status) -{ - do_PyThread_exit_prog(status, 1); -} -#endif /* NO_EXIT_PROG */ - -/* - * Lock support. - */ -PyThread_type_lock PyThread_allocate_lock(void) -{ - struct lock *lock; - extern char *malloc(size_t); - - dprintf(("PyThread_allocate_lock called\n")); - if (!initialized) - PyThread_init_thread(); - - lock = (struct lock *) malloc(sizeof(struct lock)); - lock->lock_locked = 0; - (void) mon_create(&lock->lock_monitor); - (void) cv_create(&lock->lock_condvar, lock->lock_monitor); - dprintf(("PyThread_allocate_lock() -> %p\n", lock)); - return (PyThread_type_lock) lock; -} - -void PyThread_free_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_free_lock(%p) called\n", lock)); - mon_destroy(((struct lock *) lock)->lock_monitor); - free((char *) lock); -} - -int PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) -{ - int success; - - dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); - success = 0; - - (void) mon_enter(((struct lock *) lock)->lock_monitor); - if (waitflag) - while (((struct lock *) lock)->lock_locked) - cv_wait(((struct lock *) lock)->lock_condvar); - if (!((struct lock *) lock)->lock_locked) { - success = 1; - ((struct lock *) lock)->lock_locked = 1; - } - cv_broadcast(((struct lock *) lock)->lock_condvar); - mon_exit(((struct lock *) lock)->lock_monitor); - dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); - return success; -} - -void PyThread_release_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_release_lock(%p) called\n", lock)); - (void) mon_enter(((struct lock *) lock)->lock_monitor); - ((struct lock *) lock)->lock_locked = 0; - cv_broadcast(((struct lock *) lock)->lock_condvar); - mon_exit(((struct lock *) lock)->lock_monitor); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_nt.h b/SDKs/XPlatform/Cypython-2.3.3/Python/thread_nt.h deleted file mode 100644 index 23a311a4..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_nt.h +++ /dev/null @@ -1,324 +0,0 @@ - -/* This code implemented by Dag.Gruneau@elsa.preseco.comm.se */ -/* Fast NonRecursiveMutex support by Yakov Markovitch, markovitch@iso.ru */ -/* Eliminated some memory leaks, gsw@agere.com */ - -#ifdef MS_XBOX -#include -#else -#define WIN32_LEAN_AND_MEAN -#include -#endif -#include -#include - -typedef struct NRMUTEX { - LONG owned ; - DWORD thread_id ; - HANDLE hevent ; -} NRMUTEX, *PNRMUTEX ; - -typedef PVOID WINAPI interlocked_cmp_xchg_t(PVOID *dest, PVOID exc, PVOID comperand) ; - -/* Sorry mate, but we haven't got InterlockedCompareExchange in Win95! */ -static PVOID WINAPI interlocked_cmp_xchg(PVOID *dest, PVOID exc, PVOID comperand) -{ - static LONG spinlock = 0 ; - PVOID result ; - DWORD dwSleep = 0; - - /* Acqire spinlock (yielding control to other threads if cant aquire for the moment) */ - while(InterlockedExchange(&spinlock, 1)) - { - // Using Sleep(0) can cause a priority inversion. - // Sleep(0) only yields the processor if there's - // another thread of the same priority that's - // ready to run. If a high-priority thread is - // trying to acquire the lock, which is held by - // a low-priority thread, then the low-priority - // thread may never get scheduled and hence never - // free the lock. NT attempts to avoid priority - // inversions by temporarily boosting the priority - // of low-priority runnable threads, but the problem - // can still occur if there's a medium-priority - // thread that's always runnable. If Sleep(1) is used, - // then the thread unconditionally yields the CPU. We - // only do this for the second and subsequent even - // iterations, since a millisecond is a long time to wait - // if the thread can be scheduled in again sooner - // (~100,000 instructions). - // Avoid priority inversion: 0, 1, 0, 1,... - Sleep(dwSleep); - dwSleep = !dwSleep; - } - result = *dest ; - if (result == comperand) - *dest = exc ; - /* Release spinlock */ - spinlock = 0 ; - return result ; -} ; - -static interlocked_cmp_xchg_t *ixchg ; -BOOL InitializeNonRecursiveMutex(PNRMUTEX mutex) -{ -#ifndef MS_XBOX - if (!ixchg) - { - /* Sorely, Win95 has no InterlockedCompareExchange API (Win98 has), so we have to use emulation */ - HANDLE kernel = GetModuleHandle("kernel32.dll") ; - if (!kernel || (ixchg = (interlocked_cmp_xchg_t *)GetProcAddress(kernel, "InterlockedCompareExchange")) == NULL) - ixchg = interlocked_cmp_xchg ; - } -#endif - - mutex->owned = -1 ; /* No threads have entered NonRecursiveMutex */ - mutex->thread_id = 0 ; - mutex->hevent = CreateEvent(NULL, FALSE, FALSE, NULL) ; - return mutex->hevent != NULL ; /* TRUE if the mutex is created */ -} - -#ifndef MS_XBOX -# ifdef InterlockedCompareExchange -# undef InterlockedCompareExchange -# endif -# define InterlockedCompareExchange(dest,exchange,comperand) (ixchg((dest), (exchange), (comperand))) -#endif // !MS_XBOX - -VOID DeleteNonRecursiveMutex(PNRMUTEX mutex) -{ - /* No in-use check */ - CloseHandle(mutex->hevent) ; - mutex->hevent = NULL ; /* Just in case */ -} - -DWORD EnterNonRecursiveMutex(PNRMUTEX mutex, BOOL wait) -{ - /* Assume that the thread waits successfully */ - DWORD ret ; - - /* InterlockedIncrement(&mutex->owned) == 0 means that no thread currently owns the mutex */ - if (!wait) - { - if (InterlockedCompareExchange((PVOID *)&mutex->owned, (PVOID)0, (PVOID)-1) != (PVOID)-1) - return WAIT_TIMEOUT ; - ret = WAIT_OBJECT_0 ; - } - else - ret = InterlockedIncrement(&mutex->owned) ? - /* Some thread owns the mutex, let's wait... */ - WaitForSingleObject(mutex->hevent, INFINITE) : WAIT_OBJECT_0 ; - - mutex->thread_id = GetCurrentThreadId() ; /* We own it */ - return ret ; -} - -BOOL LeaveNonRecursiveMutex(PNRMUTEX mutex) -{ - /* We don't own the mutex */ - mutex->thread_id = 0 ; - return - InterlockedDecrement(&mutex->owned) < 0 || - SetEvent(mutex->hevent) ; /* Other threads are waiting, wake one on them up */ -} - -PNRMUTEX AllocNonRecursiveMutex(void) -{ - PNRMUTEX mutex = (PNRMUTEX)malloc(sizeof(NRMUTEX)) ; - if (mutex && !InitializeNonRecursiveMutex(mutex)) - { - free(mutex) ; - mutex = NULL ; - } - return mutex ; -} - -void FreeNonRecursiveMutex(PNRMUTEX mutex) -{ - if (mutex) - { - DeleteNonRecursiveMutex(mutex) ; - free(mutex) ; - } -} - -long PyThread_get_thread_ident(void); - -/* - * Initialization of the C package, should not be needed. - */ -static void PyThread__init_thread(void) -{ -} - -/* - * Thread support. - */ - -typedef struct { - void (*func)(void*); - void *arg; - long id; - HANDLE done; -} callobj; - -static int -bootstrap(void *call) -{ - callobj *obj = (callobj*)call; - /* copy callobj since other thread might free it before we're done */ - void (*func)(void*) = obj->func; - void *arg = obj->arg; - - obj->id = PyThread_get_thread_ident(); - ReleaseSemaphore(obj->done, 1, NULL); - func(arg); - return 0; -} - -long -PyThread_start_new_thread(void (*func)(void *), void *arg) -{ - unsigned long rv; - callobj obj; - - dprintf(("%ld: PyThread_start_new_thread called\n", - PyThread_get_thread_ident())); - if (!initialized) - PyThread_init_thread(); - - obj.id = -1; /* guilty until proved innocent */ - obj.func = func; - obj.arg = arg; - obj.done = CreateSemaphore(NULL, 0, 1, NULL); - if (obj.done == NULL) - return -1; - - rv = _beginthread(bootstrap, 0, &obj); /* use default stack size */ - if (rv == (unsigned long)-1) { - /* I've seen errno == EAGAIN here, which means "there are - * too many threads". - */ - dprintf(("%ld: PyThread_start_new_thread failed: %p errno %d\n", - PyThread_get_thread_ident(), rv, errno)); - obj.id = -1; - } - else { - dprintf(("%ld: PyThread_start_new_thread succeeded: %p\n", - PyThread_get_thread_ident(), rv)); - /* wait for thread to initialize, so we can get its id */ - WaitForSingleObject(obj.done, INFINITE); - assert(obj.id != -1); - } - CloseHandle((HANDLE)obj.done); - return obj.id; -} - -/* - * Return the thread Id instead of an handle. The Id is said to uniquely identify the - * thread in the system - */ -long PyThread_get_thread_ident(void) -{ - if (!initialized) - PyThread_init_thread(); - - return GetCurrentThreadId(); -} - -static void do_PyThread_exit_thread(int no_cleanup) -{ - dprintf(("%ld: PyThread_exit_thread called\n", PyThread_get_thread_ident())); - if (!initialized) - if (no_cleanup) - _exit(0); - else - exit(0); - _endthread(); -} - -void PyThread_exit_thread(void) -{ - do_PyThread_exit_thread(0); -} - -void PyThread__exit_thread(void) -{ - do_PyThread_exit_thread(1); -} - -#ifndef NO_EXIT_PROG -static void do_PyThread_exit_prog(int status, int no_cleanup) -{ - dprintf(("PyThread_exit_prog(%d) called\n", status)); - if (!initialized) - if (no_cleanup) - _exit(status); - else - exit(status); -} - -void PyThread_exit_prog(int status) -{ - do_PyThread_exit_prog(status, 0); -} - -void PyThread__exit_prog(int status) -{ - do_PyThread_exit_prog(status, 1); -} -#endif /* NO_EXIT_PROG */ - -/* - * Lock support. It has too be implemented as semaphores. - * I [Dag] tried to implement it with mutex but I could find a way to - * tell whether a thread already own the lock or not. - */ -PyThread_type_lock PyThread_allocate_lock(void) -{ - PNRMUTEX aLock; - - dprintf(("PyThread_allocate_lock called\n")); - if (!initialized) - PyThread_init_thread(); - - aLock = AllocNonRecursiveMutex() ; - - dprintf(("%ld: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock)); - - return (PyThread_type_lock) aLock; -} - -void PyThread_free_lock(PyThread_type_lock aLock) -{ - dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); - - FreeNonRecursiveMutex(aLock) ; -} - -/* - * Return 1 on success if the lock was acquired - * - * and 0 if the lock was not acquired. This means a 0 is returned - * if the lock has already been acquired by this thread! - */ -int PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag) -{ - int success ; - - dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", PyThread_get_thread_ident(),aLock, waitflag)); - - success = aLock && EnterNonRecursiveMutex((PNRMUTEX) aLock, (waitflag == 1 ? INFINITE : 0)) == WAIT_OBJECT_0 ; - - dprintf(("%ld: PyThread_acquire_lock(%p, %d) -> %d\n", PyThread_get_thread_ident(),aLock, waitflag, success)); - - return success; -} - -void PyThread_release_lock(PyThread_type_lock aLock) -{ - dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); - - if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock))) - dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", PyThread_get_thread_ident(), aLock, GetLastError())); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_os2.h b/SDKs/XPlatform/Cypython-2.3.3/Python/thread_os2.h deleted file mode 100644 index a22fcd0c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_os2.h +++ /dev/null @@ -1,272 +0,0 @@ -/* This code implemented by cvale@netcom.com */ - -#define INCL_DOSPROCESS -#define INCL_DOSSEMAPHORES -#include "os2.h" -#include "limits.h" - -#include "process.h" - -#if defined(PYCC_GCC) -#include -#include -#else -long PyThread_get_thread_ident(void); -#endif - -/* - * Initialization of the C package, should not be needed. - */ -static void -PyThread__init_thread(void) -{ -} - -/* - * Thread support. - */ -long -PyThread_start_new_thread(void (*func)(void *), void *arg) -{ - int aThread; - int success = 0; - - aThread = _beginthread(func,NULL,65536,arg); - - if (aThread == -1) { - success = -1; - fprintf(stderr, "aThread failed == %d", aThread); - dprintf(("_beginthread failed. return %ld\n", errno)); - } - - return success; -} - -long -PyThread_get_thread_ident(void) -{ -#if !defined(PYCC_GCC) - PPIB pib; - PTIB tib; -#endif - - if (!initialized) - PyThread_init_thread(); - -#if defined(PYCC_GCC) - return _gettid(); -#else - DosGetInfoBlocks(&tib, &pib); - return tib->tib_ptib2->tib2_ultid; -#endif -} - -static void -do_PyThread_exit_thread(int no_cleanup) -{ - dprintf(("%ld: PyThread_exit_thread called\n", - PyThread_get_thread_ident())); - if (!initialized) - if (no_cleanup) - _exit(0); - else - exit(0); - _endthread(); -} - -void -PyThread_exit_thread(void) -{ - do_PyThread_exit_thread(0); -} - -void -PyThread__exit_thread(void) -{ - do_PyThread_exit_thread(1); -} - -#ifndef NO_EXIT_PROG -static void -do_PyThread_exit_prog(int status, int no_cleanup) -{ - dprintf(("PyThread_exit_prog(%d) called\n", status)); - if (!initialized) - if (no_cleanup) - _exit(status); - else - exit(status); -} - -void -PyThread_exit_prog(int status) -{ - do_PyThread_exit_prog(status, 0); -} - -void -PyThread__exit_prog(int status) -{ - do_PyThread_exit_prog(status, 1); -} -#endif /* NO_EXIT_PROG */ - -/* - * Lock support. This is implemented with an event semaphore and critical - * sections to make it behave more like a posix mutex than its OS/2 - * counterparts. - */ - -typedef struct os2_lock_t { - int is_set; - HEV changed; -} *type_os2_lock; - -PyThread_type_lock -PyThread_allocate_lock(void) -{ -#if defined(PYCC_GCC) - _fmutex *sem = malloc(sizeof(_fmutex)); - if (!initialized) - PyThread_init_thread(); - dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", - PyThread_get_thread_ident(), - (long)sem)); - if (_fmutex_create(sem, 0)) { - free(sem); - sem = NULL; - } - return (PyThread_type_lock)sem; -#else - APIRET rc; - type_os2_lock lock = (type_os2_lock)malloc(sizeof(struct os2_lock_t)); - - dprintf(("PyThread_allocate_lock called\n")); - if (!initialized) - PyThread_init_thread(); - - lock->is_set = 0; - - DosCreateEventSem(NULL, &lock->changed, 0, 0); - - dprintf(("%ld: PyThread_allocate_lock() -> %p\n", - PyThread_get_thread_ident(), - lock->changed)); - - return (PyThread_type_lock)lock; -#endif -} - -void -PyThread_free_lock(PyThread_type_lock aLock) -{ -#if !defined(PYCC_GCC) - type_os2_lock lock = (type_os2_lock)aLock; -#endif - - dprintf(("%ld: PyThread_free_lock(%p) called\n", - PyThread_get_thread_ident(),aLock)); - -#if defined(PYCC_GCC) - if (aLock) { - _fmutex_close((_fmutex *)aLock); - free((_fmutex *)aLock); - } -#else - DosCloseEventSem(lock->changed); - free(aLock); -#endif -} - -/* - * Return 1 on success if the lock was acquired - * - * and 0 if the lock was not acquired. - */ -int -PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag) -{ -#if !defined(PYCC_GCC) - int done = 0; - ULONG count; - PID pid = 0; - TID tid = 0; - type_os2_lock lock = (type_os2_lock)aLock; -#endif - - dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", - PyThread_get_thread_ident(), - aLock, - waitflag)); - -#if defined(PYCC_GCC) - /* always successful if the lock doesn't exist */ - if (aLock && - _fmutex_request((_fmutex *)aLock, waitflag ? 0 : _FMR_NOWAIT)) - return 0; -#else - while (!done) { - /* if the lock is currently set, we have to wait for - * the state to change - */ - if (lock->is_set) { - if (!waitflag) - return 0; - DosWaitEventSem(lock->changed, SEM_INDEFINITE_WAIT); - } - - /* enter a critical section and try to get the semaphore. If - * it is still locked, we will try again. - */ - if (DosEnterCritSec()) - return 0; - - if (!lock->is_set) { - lock->is_set = 1; - DosResetEventSem(lock->changed, &count); - done = 1; - } - - DosExitCritSec(); - } -#endif - - return 1; -} - -void PyThread_release_lock(PyThread_type_lock aLock) -{ -#if !defined(PYCC_GCC) - type_os2_lock lock = (type_os2_lock)aLock; -#endif - - dprintf(("%ld: PyThread_release_lock(%p) called\n", - PyThread_get_thread_ident(), - aLock)); - -#if defined(PYCC_GCC) - if (aLock) - _fmutex_release((_fmutex *)aLock); -#else - if (!lock->is_set) { - dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", - PyThread_get_thread_ident(), - aLock, - GetLastError())); - return; - } - - if (DosEnterCritSec()) { - dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", - PyThread_get_thread_ident(), - aLock, - GetLastError())); - return; - } - - lock->is_set = 0; - DosPostEventSem(lock->changed); - - DosExitCritSec(); -#endif -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_pth.h b/SDKs/XPlatform/Cypython-2.3.3/Python/thread_pth.h deleted file mode 100644 index afcfb03a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_pth.h +++ /dev/null @@ -1,213 +0,0 @@ - -/* GNU pth threads interface - http://www.gnu.org/software/pth - 2000-05-03 Andy Dustman - - Adapted from Posix threads interface - 12 May 1997 -- david arnold - */ - -#include -#include -#include - -/* A pth mutex isn't sufficient to model the Python lock type - * because pth mutexes can be acquired multiple times by the - * same thread. - * - * The pth_lock struct implements a Python lock as a "locked?" bit - * and a pair. In general, if the bit can be acquired - * instantly, it is, else the pair is used to block the thread until the - * bit is cleared. - */ - -typedef struct { - char locked; /* 0=unlocked, 1=locked */ - /* a pair to handle an acquire of a locked lock */ - pth_cond_t lock_released; - pth_mutex_t mut; -} pth_lock; - -#define CHECK_STATUS(name) if (status == -1) { printf("%d ", status); perror(name); error = 1; } - -pth_attr_t PyThread_attr; - -/* - * Initialization. - */ - -static void PyThread__init_thread(void) -{ - pth_init(); - PyThread_attr = pth_attr_new(); - pth_attr_set(PyThread_attr, PTH_ATTR_STACK_SIZE, 1<<18); - pth_attr_set(PyThread_attr, PTH_ATTR_JOINABLE, FALSE); -} - -/* - * Thread support. - */ - - -long PyThread_start_new_thread(void (*func)(void *), void *arg) -{ - pth_t th; - dprintf(("PyThread_start_new_thread called\n")); - if (!initialized) - PyThread_init_thread(); - - th = pth_spawn(PyThread_attr, - (void* (*)(void *))func, - (void *)arg - ); - - return th; -} - -long PyThread_get_thread_ident(void) -{ - volatile pth_t threadid; - if (!initialized) - PyThread_init_thread(); - /* Jump through some hoops for Alpha OSF/1 */ - threadid = pth_self(); - return (long) *(long *) &threadid; -} - -static void do_PyThread_exit_thread(int no_cleanup) -{ - dprintf(("PyThread_exit_thread called\n")); - if (!initialized) { - if (no_cleanup) - _exit(0); - else - exit(0); - } -} - -void PyThread_exit_thread(void) -{ - do_PyThread_exit_thread(0); -} - -void PyThread__exit_thread(void) -{ - do_PyThread_exit_thread(1); -} - -#ifndef NO_EXIT_PROG -static void do_PyThread_exit_prog(int status, int no_cleanup) -{ - dprintf(("PyThread_exit_prog(%d) called\n", status)); - if (!initialized) - if (no_cleanup) - _exit(status); - else - exit(status); -} - -void PyThread_exit_prog(int status) -{ - do_PyThread_exit_prog(status, 0); -} - -void PyThread__exit_prog(int status) -{ - do_PyThread_exit_prog(status, 1); -} -#endif /* NO_EXIT_PROG */ - -/* - * Lock support. - */ -PyThread_type_lock PyThread_allocate_lock(void) -{ - pth_lock *lock; - int status, error = 0; - - dprintf(("PyThread_allocate_lock called\n")); - if (!initialized) - PyThread_init_thread(); - - lock = (pth_lock *) malloc(sizeof(pth_lock)); - memset((void *)lock, '\0', sizeof(pth_lock)); - if (lock) { - lock->locked = 0; - status = pth_mutex_init(&lock->mut); - CHECK_STATUS("pth_mutex_init"); - status = pth_cond_init(&lock->lock_released); - CHECK_STATUS("pth_cond_init"); - if (error) { - free((void *)lock); - lock = NULL; - } - } - dprintf(("PyThread_allocate_lock() -> %p\n", lock)); - return (PyThread_type_lock) lock; -} - -void PyThread_free_lock(PyThread_type_lock lock) -{ - pth_lock *thelock = (pth_lock *)lock; - - dprintf(("PyThread_free_lock(%p) called\n", lock)); - - free((void *)thelock); -} - -int PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) -{ - int success; - pth_lock *thelock = (pth_lock *)lock; - int status, error = 0; - - dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); - - status = pth_mutex_acquire(&thelock->mut, !waitflag, NULL); - CHECK_STATUS("pth_mutex_acquire[1]"); - success = thelock->locked == 0; - if (success) thelock->locked = 1; - status = pth_mutex_release( &thelock->mut ); - CHECK_STATUS("pth_mutex_release[1]"); - - if ( !success && waitflag ) { - /* continue trying until we get the lock */ - - /* mut must be locked by me -- part of the condition - * protocol */ - status = pth_mutex_acquire( &thelock->mut, !waitflag, NULL ); - CHECK_STATUS("pth_mutex_acquire[2]"); - while ( thelock->locked ) { - status = pth_cond_await(&thelock->lock_released, - &thelock->mut, NULL); - CHECK_STATUS("pth_cond_await"); - } - thelock->locked = 1; - status = pth_mutex_release( &thelock->mut ); - CHECK_STATUS("pth_mutex_release[2]"); - success = 1; - } - if (error) success = 0; - dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); - return success; -} - -void PyThread_release_lock(PyThread_type_lock lock) -{ - pth_lock *thelock = (pth_lock *)lock; - int status, error = 0; - - dprintf(("PyThread_release_lock(%p) called\n", lock)); - - status = pth_mutex_acquire( &thelock->mut, 0, NULL ); - CHECK_STATUS("pth_mutex_acquire[3]"); - - thelock->locked = 0; - - status = pth_mutex_release( &thelock->mut ); - CHECK_STATUS("pth_mutex_release[3]"); - - /* wake up someone (anyone, if any) waiting on the lock */ - status = pth_cond_notify( &thelock->lock_released, 0 ); - CHECK_STATUS("pth_cond_notify"); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_pthread.h b/SDKs/XPlatform/Cypython-2.3.3/Python/thread_pthread.h deleted file mode 100644 index 71b6805f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_pthread.h +++ /dev/null @@ -1,545 +0,0 @@ - -/* Posix threads interface */ - -#include -#include -#if defined(__APPLE__) || defined(HAVE_PTHREAD_DESTRUCTOR) -#define destructor xxdestructor -#endif -#include -#if defined(__APPLE__) || defined(HAVE_PTHREAD_DESTRUCTOR) -#undef destructor -#endif -#include - -/* The POSIX spec says that implementations supporting the sem_* - family of functions must indicate this by defining - _POSIX_SEMAPHORES. */ -#ifdef _POSIX_SEMAPHORES -#include -#include -#endif - - -/* try to determine what version of the Pthread Standard is installed. - * this is important, since all sorts of parameter types changed from - * draft to draft and there are several (incompatible) drafts in - * common use. these macros are a start, at least. - * 12 May 1997 -- david arnold - */ - -#if defined(__ultrix) && defined(__mips) && defined(_DECTHREADS_) -/* _DECTHREADS_ is defined in cma.h which is included by pthread.h */ -# define PY_PTHREAD_D4 -# error Systems with PY_PTHREAD_D4 are unsupported. See README. - -#elif defined(__osf__) && defined (__alpha) -/* _DECTHREADS_ is defined in cma.h which is included by pthread.h */ -# if !defined(_PTHREAD_ENV_ALPHA) || defined(_PTHREAD_USE_D4) || defined(PTHREAD_USE_D4) -# define PY_PTHREAD_D4 -# error Systems with PY_PTHREAD_D4 are unsupported. See README. -# else -# define PY_PTHREAD_STD -# endif - -#elif defined(_AIX) -/* SCHED_BG_NP is defined if using AIX DCE pthreads - * but it is unsupported by AIX 4 pthreads. Default - * attributes for AIX 4 pthreads equal to NULL. For - * AIX DCE pthreads they should be left unchanged. - */ -# if !defined(SCHED_BG_NP) -# define PY_PTHREAD_STD -# else -# define PY_PTHREAD_D7 -# error Systems with PY_PTHREAD_D7 are unsupported. See README. -# endif - -#elif defined(__DGUX) -# define PY_PTHREAD_D6 -# error Systems with PY_PTHREAD_D6 are unsupported. See README. - -#elif defined(__hpux) && defined(_DECTHREADS_) -# define PY_PTHREAD_D4 -# error Systems with PY_PTHREAD_D4 are unsupported. See README. - -#else /* Default case */ -# define PY_PTHREAD_STD - -#endif - -#ifdef USE_GUSI -/* The Macintosh GUSI I/O library sets the stackspace to -** 20KB, much too low. We up it to 64K. -*/ -#define THREAD_STACK_SIZE 0x10000 -#endif - - -/* set default attribute object for different versions */ - -#if defined(PY_PTHREAD_D4) || defined(PY_PTHREAD_D7) -#if !defined(pthread_attr_default) -# define pthread_attr_default pthread_attr_default -#endif -#if !defined(pthread_mutexattr_default) -# define pthread_mutexattr_default pthread_mutexattr_default -#endif -#if !defined(pthread_condattr_default) -# define pthread_condattr_default pthread_condattr_default -#endif -#elif defined(PY_PTHREAD_STD) || defined(PY_PTHREAD_D6) -#if !defined(pthread_attr_default) -# define pthread_attr_default ((pthread_attr_t *)NULL) -#endif -#if !defined(pthread_mutexattr_default) -# define pthread_mutexattr_default ((pthread_mutexattr_t *)NULL) -#endif -#if !defined(pthread_condattr_default) -# define pthread_condattr_default ((pthread_condattr_t *)NULL) -#endif -#endif - - -/* Whether or not to use semaphores directly rather than emulating them with - * mutexes and condition variables: - */ -#if defined(_POSIX_SEMAPHORES) && !defined(HAVE_BROKEN_POSIX_SEMAPHORES) -# define USE_SEMAPHORES -#else -# undef USE_SEMAPHORES -#endif - - -/* On platforms that don't use standard POSIX threads pthread_sigmask() - * isn't present. DEC threads uses sigprocmask() instead as do most - * other UNIX International compliant systems that don't have the full - * pthread implementation. - */ -#if defined(HAVE_PTHREAD_SIGMASK) && !defined(HAVE_BROKEN_PTHREAD_SIGMASK) -# define SET_THREAD_SIGMASK pthread_sigmask -#else -# define SET_THREAD_SIGMASK sigprocmask -#endif - - -/* A pthread mutex isn't sufficient to model the Python lock type - * because, according to Draft 5 of the docs (P1003.4a/D5), both of the - * following are undefined: - * -> a thread tries to lock a mutex it already has locked - * -> a thread tries to unlock a mutex locked by a different thread - * pthread mutexes are designed for serializing threads over short pieces - * of code anyway, so wouldn't be an appropriate implementation of - * Python's locks regardless. - * - * The pthread_lock struct implements a Python lock as a "locked?" bit - * and a pair. In general, if the bit can be acquired - * instantly, it is, else the pair is used to block the thread until the - * bit is cleared. 9 May 1994 tim@ksr.com - */ - -typedef struct { - char locked; /* 0=unlocked, 1=locked */ - /* a pair to handle an acquire of a locked lock */ - pthread_cond_t lock_released; - pthread_mutex_t mut; -} pthread_lock; - -#define CHECK_STATUS(name) if (status != 0) { perror(name); error = 1; } - -/* - * Initialization. - */ - -#ifdef _HAVE_BSDI -static -void _noop(void) -{ -} - -static void -PyThread__init_thread(void) -{ - /* DO AN INIT BY STARTING THE THREAD */ - static int dummy = 0; - pthread_t thread1; - pthread_create(&thread1, NULL, (void *) _noop, &dummy); - pthread_join(thread1, NULL); -} - -#else /* !_HAVE_BSDI */ - -static void -PyThread__init_thread(void) -{ -#if defined(_AIX) && defined(__GNUC__) - pthread_init(); -#endif -} - -#endif /* !_HAVE_BSDI */ - -/* - * Thread support. - */ - - -long -PyThread_start_new_thread(void (*func)(void *), void *arg) -{ - pthread_t th; - int status; - sigset_t oldmask, newmask; -#if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) - pthread_attr_t attrs; -#endif - dprintf(("PyThread_start_new_thread called\n")); - if (!initialized) - PyThread_init_thread(); - -#if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) - pthread_attr_init(&attrs); -#endif -#ifdef THREAD_STACK_SIZE - pthread_attr_setstacksize(&attrs, THREAD_STACK_SIZE); -#endif -#ifdef PTHREAD_SYSTEM_SCHED_SUPPORTED - pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM); -#endif - - /* Mask all signals in the current thread before creating the new - * thread. This causes the new thread to start with all signals - * blocked. - */ - sigfillset(&newmask); - SET_THREAD_SIGMASK(SIG_BLOCK, &newmask, &oldmask); - - status = pthread_create(&th, -#if defined(PY_PTHREAD_D4) - pthread_attr_default, - (pthread_startroutine_t)func, - (pthread_addr_t)arg -#elif defined(PY_PTHREAD_D6) - pthread_attr_default, - (void* (*)(void *))func, - arg -#elif defined(PY_PTHREAD_D7) - pthread_attr_default, - func, - arg -#elif defined(PY_PTHREAD_STD) -#if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) - &attrs, -#else - (pthread_attr_t*)NULL, -#endif - (void* (*)(void *))func, - (void *)arg -#endif - ); - - /* Restore signal mask for original thread */ - SET_THREAD_SIGMASK(SIG_SETMASK, &oldmask, NULL); - -#if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) - pthread_attr_destroy(&attrs); -#endif - if (status != 0) - return -1; - -#if defined(PY_PTHREAD_D4) || defined(PY_PTHREAD_D6) || defined(PY_PTHREAD_D7) - pthread_detach(&th); -#elif defined(PY_PTHREAD_STD) - pthread_detach(th); -#endif - -#if SIZEOF_PTHREAD_T <= SIZEOF_LONG - return (long) th; -#else - return (long) *(long *) &th; -#endif -} - -/* XXX This implementation is considered (to quote Tim Peters) "inherently - hosed" because: - - It does not guanrantee the promise that a non-zero integer is returned. - - The cast to long is inherently unsafe. - - It is not clear that the 'volatile' (for AIX?) and ugly casting in the - latter return statement (for Alpha OSF/1) are any longer necessary. -*/ -long -PyThread_get_thread_ident(void) -{ - volatile pthread_t threadid; - if (!initialized) - PyThread_init_thread(); - /* Jump through some hoops for Alpha OSF/1 */ - threadid = pthread_self(); -#if SIZEOF_PTHREAD_T <= SIZEOF_LONG - return (long) threadid; -#else - return (long) *(long *) &threadid; -#endif -} - -static void -do_PyThread_exit_thread(int no_cleanup) -{ - dprintf(("PyThread_exit_thread called\n")); - if (!initialized) { - if (no_cleanup) - _exit(0); - else - exit(0); - } -} - -void -PyThread_exit_thread(void) -{ - do_PyThread_exit_thread(0); -} - -void -PyThread__exit_thread(void) -{ - do_PyThread_exit_thread(1); -} - -#ifndef NO_EXIT_PROG -static void -do_PyThread_exit_prog(int status, int no_cleanup) -{ - dprintf(("PyThread_exit_prog(%d) called\n", status)); - if (!initialized) - if (no_cleanup) - _exit(status); - else - exit(status); -} - -void -PyThread_exit_prog(int status) -{ - do_PyThread_exit_prog(status, 0); -} - -void -PyThread__exit_prog(int status) -{ - do_PyThread_exit_prog(status, 1); -} -#endif /* NO_EXIT_PROG */ - -#ifdef USE_SEMAPHORES - -/* - * Lock support. - */ - -PyThread_type_lock -PyThread_allocate_lock(void) -{ - sem_t *lock; - int status, error = 0; - - dprintf(("PyThread_allocate_lock called\n")); - if (!initialized) - PyThread_init_thread(); - - lock = (sem_t *)malloc(sizeof(sem_t)); - - if (lock) { - status = sem_init(lock,0,1); - CHECK_STATUS("sem_init"); - - if (error) { - free((void *)lock); - lock = NULL; - } - } - - dprintf(("PyThread_allocate_lock() -> %p\n", lock)); - return (PyThread_type_lock)lock; -} - -void -PyThread_free_lock(PyThread_type_lock lock) -{ - sem_t *thelock = (sem_t *)lock; - int status, error = 0; - - dprintf(("PyThread_free_lock(%p) called\n", lock)); - - if (!thelock) - return; - - status = sem_destroy(thelock); - CHECK_STATUS("sem_destroy"); - - free((void *)thelock); -} - -/* - * As of February 2002, Cygwin thread implementations mistakenly report error - * codes in the return value of the sem_ calls (like the pthread_ functions). - * Correct implementations return -1 and put the code in errno. This supports - * either. - */ -static int -fix_status(int status) -{ - return (status == -1) ? errno : status; -} - -int -PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) -{ - int success; - sem_t *thelock = (sem_t *)lock; - int status, error = 0; - - dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); - - do { - if (waitflag) - status = fix_status(sem_wait(thelock)); - else - status = fix_status(sem_trywait(thelock)); - } while (status == EINTR); /* Retry if interrupted by a signal */ - - if (waitflag) { - CHECK_STATUS("sem_wait"); - } else if (status != EAGAIN) { - CHECK_STATUS("sem_trywait"); - } - - success = (status == 0) ? 1 : 0; - - dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); - return success; -} - -void -PyThread_release_lock(PyThread_type_lock lock) -{ - sem_t *thelock = (sem_t *)lock; - int status, error = 0; - - dprintf(("PyThread_release_lock(%p) called\n", lock)); - - status = sem_post(thelock); - CHECK_STATUS("sem_post"); -} - -#else /* USE_SEMAPHORES */ - -/* - * Lock support. - */ -PyThread_type_lock -PyThread_allocate_lock(void) -{ - pthread_lock *lock; - int status, error = 0; - - dprintf(("PyThread_allocate_lock called\n")); - if (!initialized) - PyThread_init_thread(); - - lock = (pthread_lock *) malloc(sizeof(pthread_lock)); - memset((void *)lock, '\0', sizeof(pthread_lock)); - if (lock) { - lock->locked = 0; - - status = pthread_mutex_init(&lock->mut, - pthread_mutexattr_default); - CHECK_STATUS("pthread_mutex_init"); - - status = pthread_cond_init(&lock->lock_released, - pthread_condattr_default); - CHECK_STATUS("pthread_cond_init"); - - if (error) { - free((void *)lock); - lock = 0; - } - } - - dprintf(("PyThread_allocate_lock() -> %p\n", lock)); - return (PyThread_type_lock) lock; -} - -void -PyThread_free_lock(PyThread_type_lock lock) -{ - pthread_lock *thelock = (pthread_lock *)lock; - int status, error = 0; - - dprintf(("PyThread_free_lock(%p) called\n", lock)); - - status = pthread_mutex_destroy( &thelock->mut ); - CHECK_STATUS("pthread_mutex_destroy"); - - status = pthread_cond_destroy( &thelock->lock_released ); - CHECK_STATUS("pthread_cond_destroy"); - - free((void *)thelock); -} - -int -PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) -{ - int success; - pthread_lock *thelock = (pthread_lock *)lock; - int status, error = 0; - - dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); - - status = pthread_mutex_lock( &thelock->mut ); - CHECK_STATUS("pthread_mutex_lock[1]"); - success = thelock->locked == 0; - - if ( !success && waitflag ) { - /* continue trying until we get the lock */ - - /* mut must be locked by me -- part of the condition - * protocol */ - while ( thelock->locked ) { - status = pthread_cond_wait(&thelock->lock_released, - &thelock->mut); - CHECK_STATUS("pthread_cond_wait"); - } - success = 1; - } - if (success) thelock->locked = 1; - status = pthread_mutex_unlock( &thelock->mut ); - CHECK_STATUS("pthread_mutex_unlock[1]"); - - if (error) success = 0; - dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); - return success; -} - -void -PyThread_release_lock(PyThread_type_lock lock) -{ - pthread_lock *thelock = (pthread_lock *)lock; - int status, error = 0; - - dprintf(("PyThread_release_lock(%p) called\n", lock)); - - status = pthread_mutex_lock( &thelock->mut ); - CHECK_STATUS("pthread_mutex_lock[3]"); - - thelock->locked = 0; - - status = pthread_mutex_unlock( &thelock->mut ); - CHECK_STATUS("pthread_mutex_unlock[3]"); - - /* wake up someone (anyone, if any) waiting on the lock */ - status = pthread_cond_signal( &thelock->lock_released ); - CHECK_STATUS("pthread_cond_signal"); -} - -#endif /* USE_SEMAPHORES */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_sgi.h b/SDKs/XPlatform/Cypython-2.3.3/Python/thread_sgi.h deleted file mode 100644 index 04e6cbb8..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_sgi.h +++ /dev/null @@ -1,379 +0,0 @@ - -#ifdef WITH_SGI_DL -#define USE_DL -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#define HDR_SIZE 2680 /* sizeof(ushdr_t) */ -#define MAXPROC 100 /* max # of threads that can be started */ - -static usptr_t *shared_arena; -static ulock_t count_lock; /* protection for some variables */ -static ulock_t wait_lock; /* lock used to wait for other threads */ -static int waiting_for_threads; /* protected by count_lock */ -static int nthreads; /* protected by count_lock */ -static int exit_status; -#ifndef NO_EXIT_PROG -static int do_exit; /* indicates that the program is to exit */ -#endif -static int exiting; /* we're already exiting (for maybe_exit) */ -static pid_t my_pid; /* PID of main thread */ -static struct pidlist { - pid_t parent; - pid_t child; -} pidlist[MAXPROC]; /* PIDs of other threads; protected by count_lock */ -static int maxpidindex; /* # of PIDs in pidlist */ - -#ifndef NO_EXIT_PROG -/* - * This routine is called as a signal handler when another thread - * exits. When that happens, we must see whether we have to exit as - * well (because of an PyThread_exit_prog()) or whether we should continue on. - */ -static void exit_sig(void) -{ - d2printf(("exit_sig called\n")); - if (exiting && getpid() == my_pid) { - d2printf(("already exiting\n")); - return; - } - if (do_exit) { - d2printf(("exiting in exit_sig\n")); -#ifdef Py_DEBUG - if ((thread_debug & 8) == 0) - thread_debug &= ~1; /* don't produce debug messages */ -#endif - PyThread_exit_thread(); - } -} - -/* - * This routine is called when a process calls exit(). If that wasn't - * done from the library, we do as if an PyThread_exit_prog() was intended. - */ -static void maybe_exit(void) -{ - dprintf(("maybe_exit called\n")); - if (exiting) { - dprintf(("already exiting\n")); - return; - } - PyThread_exit_prog(0); -} -#endif /* NO_EXIT_PROG */ - -/* - * Initialization. - */ -static void PyThread__init_thread(void) -{ -#ifndef NO_EXIT_PROG - struct sigaction s; -#endif /* NO_EXIT_PROG */ -#ifdef USE_DL - long addr, size; -#endif /* USE_DL */ - - -#ifdef USE_DL - if ((size = usconfig(CONF_INITSIZE, 64*1024)) < 0) - perror("usconfig - CONF_INITSIZE (check)"); - if (usconfig(CONF_INITSIZE, size) < 0) - perror("usconfig - CONF_INITSIZE (reset)"); - addr = (long) dl_getrange(size + HDR_SIZE); - dprintf(("trying to use addr %p-%p for shared arena\n", addr, addr+size)); - errno = 0; - if ((addr = usconfig(CONF_ATTACHADDR, addr)) < 0 && errno != 0) - perror("usconfig - CONF_ATTACHADDR (set)"); -#endif /* USE_DL */ - if (usconfig(CONF_INITUSERS, 16) < 0) - perror("usconfig - CONF_INITUSERS"); - my_pid = getpid(); /* so that we know which is the main thread */ -#ifndef NO_EXIT_PROG - atexit(maybe_exit); - s.sa_handler = exit_sig; - sigemptyset(&s.sa_mask); - /*sigaddset(&s.sa_mask, SIGUSR1);*/ - s.sa_flags = 0; - sigaction(SIGUSR1, &s, 0); - if (prctl(PR_SETEXITSIG, SIGUSR1) < 0) - perror("prctl - PR_SETEXITSIG"); -#endif /* NO_EXIT_PROG */ - if (usconfig(CONF_ARENATYPE, US_SHAREDONLY) < 0) - perror("usconfig - CONF_ARENATYPE"); - usconfig(CONF_LOCKTYPE, US_DEBUG); /* XXX */ -#ifdef Py_DEBUG - if (thread_debug & 4) - usconfig(CONF_LOCKTYPE, US_DEBUGPLUS); - else if (thread_debug & 2) - usconfig(CONF_LOCKTYPE, US_DEBUG); -#endif /* Py_DEBUG */ - if ((shared_arena = usinit(tmpnam(0))) == 0) - perror("usinit"); -#ifdef USE_DL - if (usconfig(CONF_ATTACHADDR, addr) < 0) /* reset address */ - perror("usconfig - CONF_ATTACHADDR (reset)"); -#endif /* USE_DL */ - if ((count_lock = usnewlock(shared_arena)) == NULL) - perror("usnewlock (count_lock)"); - (void) usinitlock(count_lock); - if ((wait_lock = usnewlock(shared_arena)) == NULL) - perror("usnewlock (wait_lock)"); - dprintf(("arena start: %p, arena size: %ld\n", shared_arena, (long) usconfig(CONF_GETSIZE, shared_arena))); -} - -/* - * Thread support. - */ - -static void clean_threads(void) -{ - int i, j; - pid_t mypid, pid; - - /* clean up any exited threads */ - mypid = getpid(); - i = 0; - while (i < maxpidindex) { - if (pidlist[i].parent == mypid && (pid = pidlist[i].child) > 0) { - pid = waitpid(pid, 0, WNOHANG); - if (pid > 0) { - /* a thread has exited */ - pidlist[i] = pidlist[--maxpidindex]; - /* remove references to children of dead proc */ - for (j = 0; j < maxpidindex; j++) - if (pidlist[j].parent == pid) - pidlist[j].child = -1; - continue; /* don't increment i */ - } - } - i++; - } - /* clean up the list */ - i = 0; - while (i < maxpidindex) { - if (pidlist[i].child == -1) { - pidlist[i] = pidlist[--maxpidindex]; - continue; /* don't increment i */ - } - i++; - } -} - -long PyThread_start_new_thread(void (*func)(void *), void *arg) -{ -#ifdef USE_DL - long addr, size; - static int local_initialized = 0; -#endif /* USE_DL */ - int success = 0; /* init not needed when SOLARIS_THREADS and */ - /* C_THREADS implemented properly */ - - dprintf(("PyThread_start_new_thread called\n")); - if (!initialized) - PyThread_init_thread(); - switch (ussetlock(count_lock)) { - case 0: return 0; - case -1: perror("ussetlock (count_lock)"); - } - if (maxpidindex >= MAXPROC) - success = -1; - else { -#ifdef USE_DL - if (!local_initialized) { - if ((size = usconfig(CONF_INITSIZE, 64*1024)) < 0) - perror("usconfig - CONF_INITSIZE (check)"); - if (usconfig(CONF_INITSIZE, size) < 0) - perror("usconfig - CONF_INITSIZE (reset)"); - addr = (long) dl_getrange(size + HDR_SIZE); - dprintf(("trying to use addr %p-%p for sproc\n", - addr, addr+size)); - errno = 0; - if ((addr = usconfig(CONF_ATTACHADDR, addr)) < 0 && - errno != 0) - perror("usconfig - CONF_ATTACHADDR (set)"); - } -#endif /* USE_DL */ - clean_threads(); - if ((success = sproc(func, PR_SALL, arg)) < 0) - perror("sproc"); -#ifdef USE_DL - if (!local_initialized) { - if (usconfig(CONF_ATTACHADDR, addr) < 0) - /* reset address */ - perror("usconfig - CONF_ATTACHADDR (reset)"); - local_initialized = 1; - } -#endif /* USE_DL */ - if (success >= 0) { - nthreads++; - pidlist[maxpidindex].parent = getpid(); - pidlist[maxpidindex++].child = success; - dprintf(("pidlist[%d] = %d\n", - maxpidindex-1, success)); - } - } - if (usunsetlock(count_lock) < 0) - perror("usunsetlock (count_lock)"); - return success; -} - -long PyThread_get_thread_ident(void) -{ - return getpid(); -} - -static void do_PyThread_exit_thread(int no_cleanup) -{ - dprintf(("PyThread_exit_thread called\n")); - if (!initialized) - if (no_cleanup) - _exit(0); - else - exit(0); - if (ussetlock(count_lock) < 0) - perror("ussetlock (count_lock)"); - nthreads--; - if (getpid() == my_pid) { - /* main thread; wait for other threads to exit */ - exiting = 1; -#ifndef NO_EXIT_PROG - if (do_exit) { - int i; - - /* notify other threads */ - clean_threads(); - if (nthreads >= 0) { - dprintf(("kill other threads\n")); - for (i = 0; i < maxpidindex; i++) - if (pidlist[i].child > 0) - (void) kill(pidlist[i].child, - SIGKILL); - _exit(exit_status); - } - } -#endif /* NO_EXIT_PROG */ - waiting_for_threads = 1; - if (ussetlock(wait_lock) < 0) - perror("ussetlock (wait_lock)"); - for (;;) { - if (nthreads < 0) { - dprintf(("really exit (%d)\n", exit_status)); - if (no_cleanup) - _exit(exit_status); - else - exit(exit_status); - } - if (usunsetlock(count_lock) < 0) - perror("usunsetlock (count_lock)"); - dprintf(("waiting for other threads (%d)\n", nthreads)); - if (ussetlock(wait_lock) < 0) - perror("ussetlock (wait_lock)"); - if (ussetlock(count_lock) < 0) - perror("ussetlock (count_lock)"); - } - } - /* not the main thread */ - if (waiting_for_threads) { - dprintf(("main thread is waiting\n")); - if (usunsetlock(wait_lock) < 0) - perror("usunsetlock (wait_lock)"); - } -#ifndef NO_EXIT_PROG - else if (do_exit) - (void) kill(my_pid, SIGUSR1); -#endif /* NO_EXIT_PROG */ - if (usunsetlock(count_lock) < 0) - perror("usunsetlock (count_lock)"); - _exit(0); -} - -void PyThread_exit_thread(void) -{ - do_PyThread_exit_thread(0); -} - -void PyThread__exit_thread(void) -{ - do_PyThread_exit_thread(1); -} - -#ifndef NO_EXIT_PROG -static void do_PyThread_exit_prog(int status, int no_cleanup) -{ - dprintf(("PyThread_exit_prog(%d) called\n", status)); - if (!initialized) - if (no_cleanup) - _exit(status); - else - exit(status); - do_exit = 1; - exit_status = status; - do_PyThread_exit_thread(no_cleanup); -} - -void PyThread_exit_prog(int status) -{ - do_PyThread_exit_prog(status, 0); -} - -void PyThread__exit_prog(int status) -{ - do_PyThread_exit_prog(status, 1); -} -#endif /* NO_EXIT_PROG */ - -/* - * Lock support. - */ -PyThread_type_lock PyThread_allocate_lock(void) -{ - ulock_t lock; - - dprintf(("PyThread_allocate_lock called\n")); - if (!initialized) - PyThread_init_thread(); - - if ((lock = usnewlock(shared_arena)) == NULL) - perror("usnewlock"); - (void) usinitlock(lock); - dprintf(("PyThread_allocate_lock() -> %p\n", lock)); - return (PyThread_type_lock) lock; -} - -void PyThread_free_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_free_lock(%p) called\n", lock)); - usfreelock((ulock_t) lock, shared_arena); -} - -int PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) -{ - int success; - - dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); - errno = 0; /* clear it just in case */ - if (waitflag) - success = ussetlock((ulock_t) lock); - else - success = uscsetlock((ulock_t) lock, 1); /* Try it once */ - if (success < 0) - perror(waitflag ? "ussetlock" : "uscsetlock"); - dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); - return success; -} - -void PyThread_release_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_release_lock(%p) called\n", lock)); - if (usunsetlock((ulock_t) lock) < 0) - perror("usunsetlock"); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_solaris.h b/SDKs/XPlatform/Cypython-2.3.3/Python/thread_solaris.h deleted file mode 100644 index fee210f4..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_solaris.h +++ /dev/null @@ -1,174 +0,0 @@ - -#include -#include -#include -#include -#undef _POSIX_THREADS - - -/* - * Initialization. - */ -static void PyThread__init_thread(void) -{ -} - -/* - * Thread support. - */ -struct func_arg { - void (*func)(void *); - void *arg; -}; - -static void * -new_func(void *funcarg) -{ - void (*func)(void *); - void *arg; - - func = ((struct func_arg *) funcarg)->func; - arg = ((struct func_arg *) funcarg)->arg; - free(funcarg); - (*func)(arg); - return 0; -} - - -long -PyThread_start_new_thread(void (*func)(void *), void *arg) -{ - thread_t tid; - struct func_arg *funcarg; - - dprintf(("PyThread_start_new_thread called\n")); - if (!initialized) - PyThread_init_thread(); - funcarg = (struct func_arg *) malloc(sizeof(struct func_arg)); - funcarg->func = func; - funcarg->arg = arg; - if (thr_create(0, 0, new_func, funcarg, - THR_DETACHED | THR_NEW_LWP, &tid)) { - perror("thr_create"); - free((void *) funcarg); - return -1; - } - return tid; -} - -long -PyThread_get_thread_ident(void) -{ - if (!initialized) - PyThread_init_thread(); - return thr_self(); -} - -static void -do_PyThread_exit_thread(int no_cleanup) -{ - dprintf(("PyThread_exit_thread called\n")); - if (!initialized) - if (no_cleanup) - _exit(0); - else - exit(0); - thr_exit(0); -} - -void -PyThread_exit_thread(void) -{ - do_PyThread_exit_thread(0); -} - -void -PyThread__exit_thread(void) -{ - do_PyThread_exit_thread(1); -} - -#ifndef NO_EXIT_PROG -static void -do_PyThread_exit_prog(int status, int no_cleanup) -{ - dprintf(("PyThread_exit_prog(%d) called\n", status)); - if (!initialized) - if (no_cleanup) - _exit(status); - else - exit(status); - if (no_cleanup) - _exit(status); - else - exit(status); -} - -void -PyThread_exit_prog(int status) -{ - do_PyThread_exit_prog(status, 0); -} - -void -PyThread__exit_prog(int status) -{ - do_PyThread_exit_prog(status, 1); -} -#endif /* NO_EXIT_PROG */ - -/* - * Lock support. - */ -PyThread_type_lock -PyThread_allocate_lock(void) -{ - mutex_t *lock; - - dprintf(("PyThread_allocate_lock called\n")); - if (!initialized) - PyThread_init_thread(); - - lock = (mutex_t *) malloc(sizeof(mutex_t)); - if (mutex_init(lock, USYNC_THREAD, 0)) { - perror("mutex_init"); - free((void *) lock); - lock = 0; - } - dprintf(("PyThread_allocate_lock() -> %p\n", lock)); - return (PyThread_type_lock) lock; -} - -void -PyThread_free_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_free_lock(%p) called\n", lock)); - mutex_destroy((mutex_t *) lock); - free((void *) lock); -} - -int -PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) -{ - int success; - - dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); - if (waitflag) - success = mutex_lock((mutex_t *) lock); - else - success = mutex_trylock((mutex_t *) lock); - if (success < 0) - perror(waitflag ? "mutex_lock" : "mutex_trylock"); - else - success = !success; /* solaris does it the other way round */ - dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); - return success; -} - -void -PyThread_release_lock(PyThread_type_lock lock) -{ - dprintf(("PyThread_release_lock(%p) called\n", lock)); - if (mutex_unlock((mutex_t *) lock)) - perror("mutex_unlock"); -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_wince.h b/SDKs/XPlatform/Cypython-2.3.3/Python/thread_wince.h deleted file mode 100644 index 44d5ee1a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/thread_wince.h +++ /dev/null @@ -1,171 +0,0 @@ - -/* This code implemented by Mark Hammond (MHammond@skippinet.com.au) */ - -#include -#include -#include - -long PyThread_get_thread_ident(void); - -/* - * Change all headers to pure ANSI as no one will use K&R style on an - * NT - */ - -/* - * Initialization of the C package, should not be needed. - */ -static void PyThread__init_thread(void) -{ -} - -/* - * Thread support. - */ -long PyThread_start_new_thread(void (*func)(void *), void *arg) -{ - long rv; - int success = -1; - - dprintf(("%ld: PyThread_start_new_thread called\n", PyThread_get_thread_ident())); - if (!initialized) - PyThread_init_thread(); - - rv = _beginthread(func, 0, arg); /* use default stack size */ - - if (rv != -1) { - success = 0; - dprintf(("%ld: PyThread_start_new_thread succeeded:\n", PyThread_get_thread_ident())); - } - - return success; -} - -/* - * Return the thread Id instead of an handle. The Id is said to uniquely identify the - * thread in the system - */ -long PyThread_get_thread_ident(void) -{ - if (!initialized) - PyThread_init_thread(); - - return GetCurrentThreadId(); -} - -static void do_PyThread_exit_thread(int no_cleanup) -{ - dprintf(("%ld: do_PyThread_exit_thread called\n", PyThread_get_thread_ident())); - if (!initialized) - if (no_cleanup) - exit(0); /* XXX - was _exit()!! */ - else - exit(0); - _endthread(); -} - -void PyThread_exit_thread(void) -{ - do_PyThread_exit_thread(0); -} - -void PyThread__exit_thread(void) -{ - do_PyThread_exit_thread(1); -} - -#ifndef NO_EXIT_PROG -static void do_PyThread_exit_prog(int status, int no_cleanup) -{ - dprintf(("PyThread_exit_prog(%d) called\n", status)); - if (!initialized) - if (no_cleanup) - _exit(status); - else - exit(status); -} - -void PyThread_exit_prog(int status) -{ - do_PyThread_exit_prog(status, 0); -} - -void PyThread__exit_prog(int status) -{ - do_PyThread_exit_prog(status, 1); -} -#endif /* NO_EXIT_PROG */ - -/* - * Lock support. It has to be implemented using Mutexes, as - * CE doesnt support semaphores. Therefore we use some hacks to - * simulate the non reentrant requirements of Python locks - */ -PyThread_type_lock PyThread_allocate_lock(void) -{ - HANDLE aLock; - - dprintf(("PyThread_allocate_lock called\n")); - if (!initialized) - PyThread_init_thread(); - - aLock = CreateEvent(NULL, /* Security attributes */ - 0, /* Manual-Reset */ - 1, /* Is initially signalled */ - NULL); /* Name of event */ - - dprintf(("%ld: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock)); - - return (PyThread_type_lock) aLock; -} - -void PyThread_free_lock(PyThread_type_lock aLock) -{ - dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); - - CloseHandle(aLock); -} - -/* - * Return 1 on success if the lock was acquired - * - * and 0 if the lock was not acquired. This means a 0 is returned - * if the lock has already been acquired by this thread! - */ -int PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag) -{ - int success = 1; - DWORD waitResult; - - dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", PyThread_get_thread_ident(),aLock, waitflag)); - -#ifndef DEBUG - waitResult = WaitForSingleObject(aLock, (waitflag == 1 ? INFINITE : 0)); -#else - /* To aid in debugging, we regularly wake up. This allows us to - break into the debugger */ - while (TRUE) { - waitResult = WaitForSingleObject(aLock, waitflag ? 3000 : 0); - if (waitflag==0 || (waitflag==1 && waitResult == WAIT_OBJECT_0)) - break; - } -#endif - - if (waitResult != WAIT_OBJECT_0) { - success = 0; /* We failed */ - } - - dprintf(("%ld: PyThread_acquire_lock(%p, %d) -> %d\n", PyThread_get_thread_ident(),aLock, waitflag, success)); - - return success; -} - -void PyThread_release_lock(PyThread_type_lock aLock) -{ - dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); - - if (!SetEvent(aLock)) - dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", PyThread_get_thread_ident(), aLock, GetLastError())); -} - - diff --git a/SDKs/XPlatform/Cypython-2.3.3/Python/traceback.c b/SDKs/XPlatform/Cypython-2.3.3/Python/traceback.c deleted file mode 100644 index 96333be2..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/Python/traceback.c +++ /dev/null @@ -1,277 +0,0 @@ - -/* Traceback implementation */ - -#include "Python.h" - -#include "compile.h" -#include "frameobject.h" -#include "structmember.h" -#include "osdefs.h" - -typedef struct _tracebackobject { - PyObject_HEAD - struct _tracebackobject *tb_next; - PyFrameObject *tb_frame; - int tb_lasti; - int tb_lineno; -} tracebackobject; - -#define OFF(x) offsetof(tracebackobject, x) - -static struct memberlist tb_memberlist[] = { - {"tb_next", T_OBJECT, OFF(tb_next)}, - {"tb_frame", T_OBJECT, OFF(tb_frame)}, - {"tb_lasti", T_INT, OFF(tb_lasti)}, - {"tb_lineno", T_INT, OFF(tb_lineno)}, - {NULL} /* Sentinel */ -}; - -static PyObject * -tb_getattr(tracebackobject *tb, char *name) -{ - return PyMember_Get((char *)tb, tb_memberlist, name); -} - -static void -tb_dealloc(tracebackobject *tb) -{ - PyObject_GC_UnTrack(tb); - Py_TRASHCAN_SAFE_BEGIN(tb) - Py_XDECREF(tb->tb_next); - Py_XDECREF(tb->tb_frame); - PyObject_GC_Del(tb); - Py_TRASHCAN_SAFE_END(tb) -} - -static int -tb_traverse(tracebackobject *tb, visitproc visit, void *arg) -{ - int err = 0; - if (tb->tb_next) { - err = visit((PyObject *)tb->tb_next, arg); - if (err) - return err; - } - if (tb->tb_frame) - err = visit((PyObject *)tb->tb_frame, arg); - return err; -} - -static void -tb_clear(tracebackobject *tb) -{ - Py_XDECREF(tb->tb_next); - Py_XDECREF(tb->tb_frame); - tb->tb_next = NULL; - tb->tb_frame = NULL; -} - -PyTypeObject PyTraceBack_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "traceback", - sizeof(tracebackobject), - 0, - (destructor)tb_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)tb_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - 0, /* tp_doc */ - (traverseproc)tb_traverse, /* tp_traverse */ - (inquiry)tb_clear, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ -}; - -static tracebackobject * -newtracebackobject(tracebackobject *next, PyFrameObject *frame) -{ - tracebackobject *tb; - if ((next != NULL && !PyTraceBack_Check(next)) || - frame == NULL || !PyFrame_Check(frame)) { - PyErr_BadInternalCall(); - return NULL; - } - tb = PyObject_GC_New(tracebackobject, &PyTraceBack_Type); - if (tb != NULL) { - Py_XINCREF(next); - tb->tb_next = next; - Py_XINCREF(frame); - tb->tb_frame = frame; - tb->tb_lasti = frame->f_lasti; - tb->tb_lineno = PyCode_Addr2Line(frame->f_code, - frame->f_lasti); - PyObject_GC_Track(tb); - } - return tb; -} - -int -PyTraceBack_Here(PyFrameObject *frame) -{ - PyThreadState *tstate = frame->f_tstate; - tracebackobject *oldtb = (tracebackobject *) tstate->curexc_traceback; - tracebackobject *tb = newtracebackobject(oldtb, frame); - if (tb == NULL) - return -1; - tstate->curexc_traceback = (PyObject *)tb; - Py_XDECREF(oldtb); - return 0; -} - -static int -tb_displayline(PyObject *f, char *filename, int lineno, char *name) -{ - int err = 0; - FILE *xfp; - char linebuf[2000]; - int i; - if (filename == NULL || name == NULL) - return -1; -#ifdef MPW - /* This is needed by MPW's File and Line commands */ -#define FMT " File \"%.500s\"; line %d # in %.500s\n" -#else - /* This is needed by Emacs' compile command */ -#define FMT " File \"%.500s\", line %d, in %.500s\n" -#endif - xfp = fopen(filename, "r" PY_STDIOTEXTMODE); - if (xfp == NULL) { - /* Search tail of filename in sys.path before giving up */ - PyObject *path; - char *tail = strrchr(filename, SEP); - if (tail == NULL) - tail = filename; - else - tail++; - path = PySys_GetObject("path"); - if (path != NULL && PyList_Check(path)) { - int npath = PyList_Size(path); - size_t taillen = strlen(tail); - char namebuf[MAXPATHLEN+1]; - for (i = 0; i < npath; i++) { - PyObject *v = PyList_GetItem(path, i); - if (v == NULL) { - PyErr_Clear(); - break; - } - if (PyString_Check(v)) { - size_t len; - len = PyString_Size(v); - if (len + 1 + taillen >= MAXPATHLEN) - continue; /* Too long */ - strcpy(namebuf, PyString_AsString(v)); - if (strlen(namebuf) != len) - continue; /* v contains '\0' */ - if (len > 0 && namebuf[len-1] != SEP) - namebuf[len++] = SEP; - strcpy(namebuf+len, tail); - xfp = fopen(namebuf, "r" PY_STDIOTEXTMODE); - if (xfp != NULL) { - filename = namebuf; - break; - } - } - } - } - } - PyOS_snprintf(linebuf, sizeof(linebuf), FMT, filename, lineno, name); - err = PyFile_WriteString(linebuf, f); - if (xfp == NULL || err != 0) - return err; - for (i = 0; i < lineno; i++) { - char* pLastChar = &linebuf[sizeof(linebuf)-2]; - do { - *pLastChar = '\0'; - if (Py_UniversalNewlineFgets(linebuf, sizeof linebuf, xfp, NULL) == NULL) - break; - /* fgets read *something*; if it didn't get as - far as pLastChar, it must have found a newline - or hit the end of the file; if pLastChar is \n, - it obviously found a newline; else we haven't - yet seen a newline, so must continue */ - } while (*pLastChar != '\0' && *pLastChar != '\n'); - } - if (i == lineno) { - char *p = linebuf; - while (*p == ' ' || *p == '\t' || *p == '\014') - p++; - err = PyFile_WriteString(" ", f); - if (err == 0) { - err = PyFile_WriteString(p, f); - if (err == 0 && strchr(p, '\n') == NULL) - err = PyFile_WriteString("\n", f); - } - } - fclose(xfp); - return err; -} - -static int -tb_printinternal(tracebackobject *tb, PyObject *f, int limit) -{ - int err = 0; - int depth = 0; - tracebackobject *tb1 = tb; - while (tb1 != NULL) { - depth++; - tb1 = tb1->tb_next; - } - while (tb != NULL && err == 0) { - if (depth <= limit) { - err = tb_displayline(f, - PyString_AsString( - tb->tb_frame->f_code->co_filename), - tb->tb_lineno, - PyString_AsString(tb->tb_frame->f_code->co_name)); - } - depth--; - tb = tb->tb_next; - if (err == 0) - err = PyErr_CheckSignals(); - } - return err; -} - -int -PyTraceBack_Print(PyObject *v, PyObject *f) -{ - int err; - PyObject *limitv; - int limit = 1000; - if (v == NULL) - return 0; - if (!PyTraceBack_Check(v)) { - PyErr_BadInternalCall(); - return -1; - } - limitv = PySys_GetObject("tracebacklimit"); - if (limitv && PyInt_Check(limitv)) { - limit = PyInt_AsLong(limitv); - if (limit <= 0) - return 0; - } - err = PyFile_WriteString("Traceback (most recent call last):\n", f); - if (!err) - err = tb_printinternal((tracebackobject *)v, f, limit); - return err; -} diff --git a/SDKs/XPlatform/Cypython-2.3.3/README b/SDKs/XPlatform/Cypython-2.3.3/README deleted file mode 100644 index 7f6b0edd..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/README +++ /dev/null @@ -1,1199 +0,0 @@ -This is Python version 2.3.3 -============================ - -Copyright (c) 2001, 2002, 2003 Python Software Foundation. -All rights reserved. - -Copyright (c) 2000 BeOpen.com. -All rights reserved. - -Copyright (c) 1995-2001 Corporation for National Research Initiatives. -All rights reserved. - -Copyright (c) 1991-1995 Stichting Mathematisch Centrum. -All rights reserved. - - -License information -------------------- - -See the file "LICENSE" for information on the history of this -software, terms & conditions for usage, and a DISCLAIMER OF ALL -WARRANTIES. - -This Python distribution contains no GNU General Public Licensed -(GPLed) code so it may be used in proprietary projects just like prior -Python distributions. There are interfaces to some GNU code but these -are entirely optional. - -All trademarks referenced herein are property of their respective -holders. - - -What's new in this release? ---------------------------- - -See the file "Misc/NEWS". - - -If you don't read instructions ------------------------------- - -Congratulations on getting this far. :-) - -To start building right away (on UNIX): type "./configure" in the -current directory and when it finishes, type "make". This creates an -executable "./python"; to install in /usr/local, first do "su root" -and then "make install". - -The section `Build instructions' below is still recommended reading, -especially the part on customizing Modules/Setup. - - -What is Python anyway? ----------------------- - -Python is an interpreted object-oriented programming language suitable -(amongst other uses) for distributed application development, -scripting, numeric computing and system testing. Python is often -compared to Tcl, Perl, Java, JavaScript, Visual Basic or Scheme. To -find out more about what Python can do for you, point your browser to -http://www.python.org/. - - -How do I learn Python? ----------------------- - -The official tutorial is still a good place to start; see -http://www.python.org/doc/ for online and downloadable versions, as -well as a list of other introductions, and reference documentation. - -There's a quickly growing set of books on Python. See -http://www.python.org/cgi-bin/moinmoin/PythonBooks for a list. - - -Documentation -------------- - -All documentation is provided online in a variety of formats. In -order of importance for new users: Tutorial, Library Reference, -Language Reference, Extending & Embedding, and the Python/C API. The -Library Reference is especially of immense value since much of -Python's power is described there, including the built-in data types -and functions! - -All documentation is also available online at the Python web site -(http://www.python.org/doc/, see below). It is available online for -occasional reference, or can be downloaded in many formats for faster -access. The documentation is available in HTML, PostScript, PDF, and -LaTeX formats; the LaTeX version is primarily for documentation -authors, translators, and people with special formatting requirements. - -The best documentation for the new (in Python 2.2) type/class -unification features is Guido's tutorial introduction, at - - http://www.python.org/2.2.1/descrintro.html - - -Web sites ---------- - -New Python releases and related technologies are published at -http://www.python.org/. Come visit us! - -There's also a Python community web site at -http://starship.python.net/. - - -Newsgroups and Mailing Lists ----------------------------- - -Read comp.lang.python, a high-volume discussion newsgroup about -Python, or comp.lang.python.announce, a low-volume moderated newsgroup -for Python-related announcements. These are also accessible as -mailing lists: see http://www.python.org/psa/MailingLists.html for an -overview of the many Python-related mailing lists. - -Archives are accessible via the Google Groups usenet archive; see -http://groups.google.com/. The mailing lists are also archived, see -http://www.python.org/psa/MailingLists.html for details. - - -Bug reports ------------ - -To report or search for bugs, please use the Python Bug -Tracker at http://sourceforge.net/bugs/?group_id=5470. - - -Patches and contributions -------------------------- - -To submit a patch or other contribution, please use the Python Patch -Manager at http://sourceforge.net/patch/?group_id=5470. Guidelines -for patch submission may be found at http://www.python.org/patches/. - -If you have a proposal to change Python, it's best to submit a Python -Enhancement Proposal (PEP) first. All current PEPs, as well as -guidelines for submitting a new PEP, are listed at -http://python.sourceforge.net/peps/. - - -Questions ---------- - -For help, if you can't find it in the manuals or on the web site, it's -best to post to the comp.lang.python or the Python mailing list (see -above). If you specifically don't want to involve the newsgroup or -mailing list, send questions to help@python.org (a group of volunteers -who answer questions as they can). The newsgroup is the most -efficient way to ask public questions. - - -Build instructions -================== - -Before you can build Python, you must first configure it. -Fortunately, the configuration and build process has been automated -for Unix and Linux installations, so all you usually have to do is -type a few commands and sit back. There are some platforms where -things are not quite as smooth; see the platform specific notes below. -If you want to build for multiple platforms sharing the same source -tree, see the section on VPATH below. - -Start by running the script "./configure", which determines your -system configuration and creates the Makefile. (It takes a minute or -two -- please be patient!) You may want to pass options to the -configure script -- see the section below on configuration options and -variables. When it's done, you are ready to run make. - -To build Python, you normally type "make" in the toplevel directory. -If you have changed the configuration, the Makefile may have to be -rebuilt. In this case you may have to run make again to correctly -build your desired target. The interpreter executable is built in the -top level directory. - -Once you have built a Python interpreter, see the subsections below on -testing and installation. If you run into trouble, see the next -section. - -Previous versions of Python used a manual configuration process that -involved editing the file Modules/Setup. While this file still exists -and manual configuration is still supported, it is rarely needed any -more: almost all modules are automatically built as appropriate under -guidance of the setup.py script, which is run by Make after the -interpreter has been built. - - -Troubleshooting ---------------- - -See also the platform specific notes in the next section. - -If you run into other trouble, see section 3 of the FAQ -(http://www.python.org/cgi-bin/faqw.py or -http://www.python.org/doc/FAQ.html) for hints on what can go wrong, -and how to fix it. - -If you rerun the configure script with different options, remove all -object files by running "make clean" before rebuilding. Believe it or -not, "make clean" sometimes helps to clean up other inexplicable -problems as well. Try it before sending in a bug report! - -If the configure script fails or doesn't seem to find things that -should be there, inspect the config.log file. When you fix a -configure problem, be sure to remove config.cache! - -If you get a warning for every file about the -Olimit option being no -longer supported, you can ignore it. There's no foolproof way to know -whether this option is needed; all we can do is test whether it is -accepted without error. On some systems, e.g. older SGI compilers, it -is essential for performance (specifically when compiling ceval.c, -which has more basic blocks than the default limit of 1000). If the -warning bothers you, edit the Makefile to remove "-Olimit 1500" from -the OPT variable. - -If you get failures in test_long, or sys.maxint gets set to -1, you -are probably experiencing compiler bugs, usually related to -optimization. This is a common problem with some versions of gcc, and -some vendor-supplied compilers, which can sometimes be worked around -by turning off optimization. Consider switching to stable versions -(gcc 2.95.2, or contact your vendor.) - -From Python 2.0 onward, all Python C code is ANSI C. Compiling using -old K&R-C-only compilers is no longer possible. ANSI C compilers are -available for all modern systems, either in the form of updated -compilers from the vendor, or one of the free compilers (gcc). - - -Unsupported systems -------------------- - -A number of features are not supported in Python 2.3 anymore. Some -support code is still present, but will be removed in Python 2.4. -If you still need to use current Python versions on these systems, -please send a message to python-dev@python.org indicating that you -volunteer to support this system. - -More specifically, the following systems are not supported any -longer: -- SunOS 4 -- DYNIX -- dgux -- Minix -- Irix 4 and --with-sgi-dl -- Linux 1 -- Systems defining __d6_pthread_create (configure.in) -- Systems defining PY_PTHREAD_D4, PY_PTHREAD_D6, - or PY_PTHREAD_D7 in thread_pthread.h -- Systems using --with-dl-dld -- Systems using --without-universal-newlines - - -Platform specific notes ------------------------ - -(Some of these may no longer apply. If you find you can build Python -on these platforms without the special directions mentioned here, -submit a documentation bug report to SourceForge (see Bug Reports -above) so we can remove them!) - -Unix platforms: If your vendor still ships (and you still use) Berkeley DB - 1.85 you will need to edit Modules/Setup to build the bsddb185 - module and add a line to sitecustomize.py which makes it the - default. In Modules/Setup a line like - - bsddb185 bsddbmodule.c - - should work. (You may need to add -I, -L or -l flags to direct the - compiler and linker to your include files and libraries.) You can - then force it to be the version people import by adding - - import bsddb185 as bsddb - - in sitecustomize.py. - -64-bit platforms: The modules audioop, imageop and rgbimg don't work. - The setup.py script disables them on 64-bit installations. - Don't try to enable them in the Modules/Setup file. They - contain code that is quite wordsize sensitive. (If you have a - fix, let us know!) - -Solaris: When using Sun's C compiler with threads, at least on Solaris - 2.5.1, you need to add the "-mt" compiler option (the simplest - way is probably to specify the compiler with this option as - the "CC" environment variable when running the configure - script). - - When using GCC on Solaris, beware of binutils 2.13 or GCC - versions built using it. This mistakenly enables the - -zcombreloc option which creates broken shared libraries on - Solaris. binutils 2.12 works, and the binutils maintainers - are aware of the problem. Binutils 2.13.1 only partially - fixed things. It appears that 2.13.2 solves the problem - completely. This problem is known to occur with Solaris 2.7 - and 2.8, but may also affect earlier and later versions of the - OS. - - When the dynamic loader complains about errors finding shared - libraries, such as - - ld.so.1: ./python: fatal: libstdc++.so.5: open failed: - No such file or directory - - you need to first make sure that the library is available on - your system. Then, you need to instruct the dynamic loader how - to find it. You can choose any of the following strategies: - - 1. When compiling Python, set LD_RUN_PATH to the directories - containing missing libraries. - 2. When running Python, set LD_LIBRARY_PATH to these directories. - 3. Use crle(8) to extend the search path of the loader. - 4. Modify the installed GCC specs file, adding -R options into the - *link: section. - -Linux: A problem with threads and fork() was tracked down to a bug in - the pthreads code in glibc version 2.0.5; glibc version 2.0.7 - solves the problem. This causes the popen2 test to fail; - problem and solution reported by Pablo Bleyer. - - Under Linux systems using GNU libc 2 (aka libc6), the crypt - module now needs the -lcrypt option. The setup.py script - takes care of this automatically. - -Red Hat Linux: Red Hat 9 built Python2.2 in UCS-4 mode and hacked - Tcl to support it. To compile Python2.3 with Tkinter, you will - need to pass --enable-unicode=ucs4 flag to ./configure. - - There's an executable /usr/bin/python which is Python - 1.5.2 on most older Red Hat installations; several key Red Hat tools - require this version. Python 2.1.x may be installed as - /usr/bin/python2. The Makefile installs Python as - /usr/local/bin/python, which may or may not take precedence - over /usr/bin/python, depending on how you have set up $PATH. - -FreeBSD 3.x and probably platforms with NCurses that use libmytinfo or - similar: When using cursesmodule, the linking is not done in - the correct order with the defaults. Remove "-ltermcap" from - the readline entry in Setup, and use as curses entry: "curses - cursesmodule.c -lmytinfo -lncurses -ltermcap" - "mytinfo" (so - called on FreeBSD) should be the name of the auxiliary library - required on your platform. Normally, it would be linked - automatically, but not necessarily in the correct order. - -BSDI: BSDI versions before 4.1 have known problems with threads, - which can cause strange errors in a number of modules (for - instance, the 'test_signal' test script will hang forever.) - Turning off threads (with --with-threads=no) or upgrading to - BSDI 4.1 solves this problem. - -DEC Unix: Run configure with --with-dec-threads, or with - --with-threads=no if no threads are desired (threads are on by - default). When using GCC, it is possible to get an internal - compiler error if optimization is used. This was reported for - GCC 2.7.2.3 on selectmodule.c. Manually compile the affected - file without optimization to solve the problem. - -DEC Ultrix: compile with GCC to avoid bugs in the native compiler, - and pass SHELL=/bin/sh5 to Make when installing. - -AIX: A complete overhaul of the shared library support is now in - place. See Misc/AIX-NOTES for some notes on how it's done. - (The optimizer bug reported at this place in previous releases - has been worked around by a minimal code change.) If you get - errors about pthread_* functions, during compile or during - testing, try setting CC to a thread-safe (reentrant) compiler, - like "cc_r". For full C++ module support, set CC="xlC_r" (or - CC="xlC" without thread support). - -HP-UX: When using threading, you may have to add -D_REENTRANT to the - OPT variable in the top-level Makefile; reported by Pat Knight, - this seems to make a difference (at least for HP-UX 10.20) - even though pyconfig.h defines it. This seems unnecessary when - using HP/UX 11 and later - threading works "out of the box". - -HP-UX ia64: When building on the ia64 (Itanium) platform using HP's - compiler, some experience has shown that the compiler's - optimiser produces a completely broken version of python - (see http://www.python.org/sf/814976). To work around this, - edit the Makefile and remove -O from the OPT line. - -HP PA-RISC 2.0: A recent bug report (http://www.python.org/sf/546117) - suggests that the C compiler in this 64-bit system has bugs - in the optimizer that break Python. Compiling without - optimization solves the problems. - -SCO: The following apply to SCO 3 only; Python builds out of the box - on SCO 5 (or so we've heard). - - 1) Everything works much better if you add -U__STDC__ to the - defs. This is because all the SCO header files are broken. - Anything that isn't mentioned in the C standard is - conditionally excluded when __STDC__ is defined. - - 2) Due to the U.S. export restrictions, SCO broke the crypt - stuff out into a separate library, libcrypt_i.a so the LIBS - needed be set to: - - LIBS=' -lsocket -lcrypt_i' - -UnixWare: There are known bugs in the math library of the system, as well as - problems in the handling of threads (calling fork in one - thread may interrupt system calls in others). Therefore, test_math and - tests involving threads will fail until those problems are fixed. - -SunOS 4.x: When using the SunPro C compiler, you may want to use the - '-Xa' option instead of '-Xc', to enable some needed non-ANSI - Sunisms. - THIS SYSTEM IS NO LONGER SUPPORTED. - -NeXT: Not supported anymore. Start with the MacOSX/Darwin code if you - want to revive it. - -QNX: Chris Herborth (chrish@qnx.com) writes: - configure works best if you use GNU bash; a port is available on - ftp.qnx.com in /usr/free. I used the following process to build, - test and install Python 1.5.x under QNX: - - 1) CONFIG_SHELL=/usr/local/bin/bash CC=cc RANLIB=: \ - ./configure --verbose --without-gcc --with-libm="" - - 2) edit Modules/Setup to activate everything that makes sense for - your system... tested here at QNX with the following modules: - - array, audioop, binascii, cPickle, cStringIO, cmath, - crypt, curses, errno, fcntl, gdbm, grp, imageop, - _locale, math, md5, new, operator, parser, pcre, - posix, pwd, readline, regex, reop, rgbimg, rotor, - select, signal, socket, soundex, strop, struct, - syslog, termios, time, timing, zlib, audioop, imageop, rgbimg - - 3) make SHELL=/usr/local/bin/bash - - or, if you feel the need for speed: - - make SHELL=/usr/local/bin/bash OPT="-5 -Oil+nrt" - - 4) make SHELL=/usr/local/bin/bash test - - Using GNU readline 2.2 seems to behave strangely, but I - think that's a problem with my readline 2.2 port. :-\ - - 5) make SHELL=/usr/local/bin/bash install - - If you get SIGSEGVs while running Python (I haven't yet, but - I've only run small programs and the test cases), you're - probably running out of stack; the default 32k could be a - little tight. To increase the stack size, edit the Makefile - to read: LDFLAGS = -N 48k - -BeOS: See Misc/BeOS-NOTES for notes about compiling/installing - Python on BeOS R3 or later. Note that only the PowerPC - platform is supported for R3; both PowerPC and x86 are - supported for R4. - -Cray T3E: Mark Hadfield (m.hadfield@niwa.co.nz) writes: - Python can be built satisfactorily on a Cray T3E but based on - my experience with the NIWA T3E (2002-05-22, version 2.2.1) - there are a few bugs and gotchas. For more information see a - thread on comp.lang.python in May 2002 entitled "Building - Python on Cray T3E". - - 1) Use Cray's cc and not gcc. The latter was reported not to - work by Konrad Hinsen. It may work now, but it may not. - - 2) To set sys.platform to something sensible, pass the - following environment variable to the configure script: - - MACHDEP=unicosmk - - 2) Run configure with option "--enable-unicode=ucs4". - - 3) The Cray T3E does not support dynamic linking, so extension - modules have to be built by adding (or uncommenting) lines - in Modules/Setup. The minimum set of modules is - - posix, new, _sre, unicodedata - - On NIWA's vanilla T3E system the following have also been - included successfully: - - _codecs, _locale, _socket, _symtable, _testcapi, _weakref - array, binascii, cmath, cPickle, crypt, cStringIO, dbm - errno, fcntl, grp, math, md5, operator, parser, pcre, pwd - regex, rotor, select, struct, strop, syslog, termios - time, timing, xreadlines - - 4) Once the python executable and library have been built, make - will execute setup.py, which will attempt to build remaining - extensions and link them dynamically. Each of these attempts - will fail but should not halt the make process. This is - normal. - - 5) Running "make test" uses a lot of resources and causes - problems on our system. You might want to try running tests - singly or in small groups. - -SGI: SGI's standard "make" utility (/bin/make or /usr/bin/make) - does not check whether a command actually changed the file it - is supposed to build. This means that whenever you say "make" - it will redo the link step. The remedy is to use SGI's much - smarter "smake" utility (/usr/sbin/smake), or GNU make. If - you set the first line of the Makefile to #!/usr/sbin/smake - smake will be invoked by make (likewise for GNU make). - - WARNING: There are bugs in the optimizer of some versions of - SGI's compilers that can cause bus errors or other strange - behavior, especially on numerical operations. To avoid this, - try building with "make OPT=". - -OS/2: If you are running Warp3 or Warp4 and have IBM's VisualAge C/C++ - compiler installed, just change into the pc\os2vacpp directory - and type NMAKE. Threading and sockets are supported by default - in the resulting binaries of PYTHON15.DLL and PYTHON.EXE. - -Monterey (64-bit AIX): The current Monterey C compiler (Visual Age) - uses the OBJECT_MODE={32|64} environment variable to set the - compilation mode to either 32-bit or 64-bit (32-bit mode is - the default). Presumably you want 64-bit compilation mode for - this 64-bit OS. As a result you must first set OBJECT_MODE=64 - in your environment before configuring (./configure) or - building (make) Python on Monterey. - -Reliant UNIX: The thread support does not compile on Reliant UNIX, and - there is a (minor) problem in the configure script for that - platform as well. This should be resolved in time for a - future release. - -MacOSX: The tests will crash on both 10.1 and 10.2 with SEGV in - test_re and test_sre due to the small default stack size. If - you set the stack size to 2048 before doing a "make test" the - failure can be avoided. If you're using the tcsh (the default - on OSX), or csh shells use "limit stacksize 2048" and for the - bash shell, use "ulimit -s 2048". - - On naked Darwin you may want to add the configure option - "--disable-toolbox-glue" to disable the glue code for the Carbon - interface modules. The modules themselves are currently only built - if you add the --enable-framework option, see below. - - On a clean OSX /usr/local does not exist. Do a - "sudo mkdir -m 775 /usr/local" - before you do a make install. It is probably not a good idea to - do "sudo make install" which installs everything as superuser, - as this may later cause problems when installing distutils-based - additions. - - Some people have reported problems building Python after using "fink" - to install additional unix software. Disabling fink (remove all references - to /sw from your .profile or .login) should solve this. - - You may want to try the configure option "--enable-framework" - which installs Python as a framework. The location can be set - as argument to the --enable-framework option (default - /Library/Frameworks). A framework install is probably needed if you - want to use any Aqua-based GUI toolkit (whether Tkinter, wxPython, - Carbon, Cocoa or anything else). - - See Mac/OSX/README for more information on framework builds. - -Cygwin: With recent (relative to the time of writing, 2001-12-19) - Cygwin installations, there are problems with the interaction - of dynamic linking and fork(). This manifests itself in build - failures during the execution of setup.py. - - There are two workarounds that both enable Python (albeit - without threading support) to build and pass all tests on - NT/2000 (and most likely XP as well, though reports of testing - on XP would be appreciated). - - The workarounds: - - (a) the band-aid fix is to link the _socket module statically - rather than dynamically (which is the default). - - To do this, run "./configure --with-threads=no" including any - other options you need (--prefix, etc.). Then in Modules/Setup - uncomment the lines: - - #SSL=/usr/local/ssl - #_socket socketmodule.c \ - # -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ - # -L$(SSL)/lib -lssl -lcrypto - - and remove "local/" from the SSL variable. Finally, just run - "make"! - - (b) The "proper" fix is to rebase the Cygwin DLLs to prevent - base address conflicts. Details on how to do this can be - found in the following mail: - - http://sources.redhat.com/ml/cygwin/2001-12/msg00894.html - - It is hoped that a version of this solution will be - incorporated into the Cygwin distribution fairly soon. - - Two additional problems: - - (1) Threading support should still be disabled due to a known - bug in Cygwin pthreads that causes test_threadedtempfile to - hang. - - (2) The _curses module does not build. This is a known - Cygwin ncurses problem that should be resolved the next time - that this package is released. - - On older versions of Cygwin, test_poll may hang and test_strftime - may fail. - - The situation on 9X/Me is not accurately known at present. - Some time ago, there were reports that the following - regression tests failed: - - test_pwd - test_select (hang) - test_socket - - Due to the test_select hang on 9X/Me, one should run the - regression test using the following: - - make TESTOPTS='-l -x test_select' test - - News regarding these platforms with more recent Cygwin - versions would be appreciated! - -AtheOS: From Octavian Cerna : - - Before building: - - Make sure you have shared versions of the libraries you - want to use with Python. You will have to compile them - yourself, or download precompiled packages. - - Recommended libraries: - - ncurses-4.2 - readline-4.2a - zlib-1.1.4 - - Build: - - $ ./configure --prefix=/usr/python - $ make - - Python is always built as a shared library, otherwise - dynamic loading would not work. - - Testing: - - $ make test - - Install: - - # make install - # pkgmanager -a /usr/python - - - AtheOS issues: - - - large file support: due to a stdio bug in glibc/libio, - access to large files may not work correctly. fseeko() - tries to seek to a negative offset. ftello() returns a - negative offset, it looks like a 32->64bit - sign-extension issue. The lowlevel functions (open, - lseek, etc) are OK. - - sockets: AF_UNIX is defined in the C library and in - Python, but not implemented in the system. - - select: poll is available in the C library, but does not - work (It does not return POLLNVAL for bad fds and - hangs). - - posix: statvfs and fstatvfs always return ENOSYS. - - disabled modules: - - mmap: not yet implemented in AtheOS - - nis: broken (on an unconfigured system - yp_get_default_domain() returns junk instead of - error) - - dl: dynamic loading doesn't work via dlopen() - - resource: getrimit and setrlimit are not yet - implemented - - - if you are getting segmentation faults, you probably are - low on memory. AtheOS doesn't handle very well an - out-of-memory condition and simply SEGVs the process. - - Tested on: - - AtheOS-0.3.7 - gcc-2.95 - binutils-2.10 - make-3.78 - - -Configuring the bsddb and dbm modules -------------------------------------- - -Beginning with Python version 2.3, the PyBsddb package - was adopted into Python as the bsddb package, -exposing a set of package-level functions which provide -backwards-compatible behavior. Only versions 3.1 through 4.1 of -Sleepycat's libraries provide the necessary API, so older versions -aren't supported through this interface. The old bsddb module has -been retained as bsddb185, though it is not built by default. Users -wishing to use it will have to tweak Modules/Setup to build it. The -dbm module will still be built against the Sleepycat libraries if -other preferred alternatives (ndbm, gdbm) are not found, though -versions of the Sleepycat library prior to 3.1 are not considered. - - -Configuring threads -------------------- - -As of Python 2.0, threads are enabled by default. If you wish to -compile without threads, or if your thread support is broken, pass the ---with-threads=no switch to configure. Unfortunately, on some -platforms, additional compiler and/or linker options are required for -threads to work properly. Below is a table of those options, -collected by Bill Janssen. We would love to automate this process -more, but the information below is not enough to write a patch for the -configure.in file, so manual intervention is required. If you patch -the configure.in file and are confident that the patch works, please -send in the patch. (Don't bother patching the configure script itself --- it is regenerated each time the configure.in file changes.) - -Compiler switches for threads -............................. - -The definition of _REENTRANT should be configured automatically, if -that does not work on your system, or if _REENTRANT is defined -incorrectly, please report that as a bug. - - OS/Compiler/threads Switches for use with threads - (POSIX is draft 10, DCE is draft 4) compile & link - - SunOS 5.{1-5}/{gcc,SunPro cc}/solaris -mt - SunOS 5.5/{gcc,SunPro cc}/POSIX (nothing) - DEC OSF/1 3.x/cc/DCE -threads - (butenhof@zko.dec.com) - Digital UNIX 4.x/cc/DCE -threads - (butenhof@zko.dec.com) - Digital UNIX 4.x/cc/POSIX -pthread - (butenhof@zko.dec.com) - AIX 4.1.4/cc_r/d7 (nothing) - (buhrt@iquest.net) - AIX 4.1.4/cc_r4/DCE (nothing) - (buhrt@iquest.net) - IRIX 6.2/cc/POSIX (nothing) - (robertl@cwi.nl) - - -Linker (ld) libraries and flags for threads -........................................... - - OS/threads Libraries/switches for use with threads - - SunOS 5.{1-5}/solaris -lthread - SunOS 5.5/POSIX -lpthread - DEC OSF/1 3.x/DCE -lpthreads -lmach -lc_r -lc - (butenhof@zko.dec.com) - Digital UNIX 4.x/DCE -lpthreads -lpthread -lmach -lexc -lc - (butenhof@zko.dec.com) - Digital UNIX 4.x/POSIX -lpthread -lmach -lexc -lc - (butenhof@zko.dec.com) - AIX 4.1.4/{draft7,DCE} (nothing) - (buhrt@iquest.net) - IRIX 6.2/POSIX -lpthread - (jph@emilia.engr.sgi.com) - - -Building a shared libpython ---------------------------- - -Starting with Python 2.3, the majority of the interpreter can be built -into a shared library, which can then be used by the interpreter -executable, and by applications embedding Python. To enable this feature, -configure with --enable-shared. - -If you enable this feature, the same object files will be used to create -a static library. In particular, the static library will contain object -files using position-independent code (PIC) on platforms where PIC flags -are needed for the shared library. - - -Configuring additional built-in modules ---------------------------------------- - -Starting with Python 2.1, the setup.py script at the top of the source -distribution attempts to detect which modules can be built and -automatically compiles them. Autodetection doesn't always work, so -you can still customize the configuration by editing the Modules/Setup -file; but this should be considered a last resort. The rest of this -section only applies if you decide to edit the Modules/Setup file. -You also need this to enable static linking of certain modules (which -is needed to enable profiling on some systems). - -This file is initially copied from Setup.dist by the configure script; -if it does not exist yet, create it by copying Modules/Setup.dist -yourself (configure will never overwrite it). Never edit Setup.dist --- always edit Setup or Setup.local (see below). Read the comments in -the file for information on what kind of edits are allowed. When you -have edited Setup in the Modules directory, the interpreter will -automatically be rebuilt the next time you run make (in the toplevel -directory). - -Many useful modules can be built on any Unix system, but some optional -modules can't be reliably autodetected. Often the quickest way to -determine whether a particular module works or not is to see if it -will build: enable it in Setup, then if you get compilation or link -errors, disable it -- you're either missing support or need to adjust -the compilation and linking parameters for that module. - -On SGI IRIX, there are modules that interface to many SGI specific -system libraries, e.g. the GL library and the audio hardware. These -modules will not be built by the setup.py script. - -In addition to the file Setup, you can also edit the file Setup.local. -(the makesetup script processes both). You may find it more -convenient to edit Setup.local and leave Setup alone. Then, when -installing a new Python version, you can copy your old Setup.local -file. - - -Setting the optimization/debugging options ------------------------------------------- - -If you want or need to change the optimization/debugging options for -the C compiler, assign to the OPT variable on the toplevel make -command; e.g. "make OPT=-g" will build a debugging version of Python -on most platforms. The default is OPT=-O; a value for OPT in the -environment when the configure script is run overrides this default -(likewise for CC; and the initial value for LIBS is used as the base -set of libraries to link with). - -When compiling with GCC, the default value of OPT will also include -the -Wall and -Wstrict-prototypes options. - -Additional debugging code to help debug memory management problems can -be enabled by using the --with-pydebug option to the configure script. - - -Profiling ---------- - -If you want C profiling turned on, the easiest way is to run configure -with the CC environment variable to the necessary compiler -invocation. For example, on Linux, this works for profiling using -gprof(1): - - CC="gcc -pg" ./configure - -Note that on Linux, gprof apparently does not work for shared -libraries. The Makefile/Setup mechanism can be used to compile and -link most extension modules statically. - - -Testing -------- - -To test the interpreter, type "make test" in the top-level directory. -This runs the test set twice (once with no compiled files, once with -the compiled files left by the previous test run). The test set -produces some output. You can generally ignore the messages about -skipped tests due to optional features which can't be imported. -If a message is printed about a failed test or a traceback or core -dump is produced, something is wrong. On some Linux systems (those -that are not yet using glibc 6), test_strftime fails due to a -non-standard implementation of strftime() in the C library. Please -ignore this, or upgrade to glibc version 6. - -IMPORTANT: If the tests fail and you decide to mail a bug report, -*don't* include the output of "make test". It is useless. Run the -failing test manually, as follows: - - ./python ./Lib/test/test_whatever.py - -(substituting the top of the source tree for '.' if you built in a -different directory). This runs the test in verbose mode. - - -Installing ----------- - -To install the Python binary, library modules, shared library modules -(see below), include files, configuration files, and the manual page, -just type - - make install - -This will install all platform-independent files in subdirectories of -the directory given with the --prefix option to configure or to the -`prefix' Make variable (default /usr/local). All binary and other -platform-specific files will be installed in subdirectories if the -directory given by --exec-prefix or the `exec_prefix' Make variable -(defaults to the --prefix directory) is given. - -If DESTDIR is set, it will be taken as the root directory of the -installation, and files will be installed into $(DESTDIR)$(prefix), -$(DESTDIR)$(exec_prefix), etc. - -All subdirectories created will have Python's version number in their -name, e.g. the library modules are installed in -"/usr/local/lib/python/" by default, where is the -. release number (e.g. "2.1"). The Python binary is -installed as "python" and a hard link named "python" is -created. The only file not installed with a version number in its -name is the manual page, installed as "/usr/local/man/man1/python.1" -by default. - -If you have a previous installation of Python that you don't -want to replace yet, use - - make altinstall - -This installs the same set of files as "make install" except it -doesn't create the hard link to "python" named "python" and -it doesn't install the manual page at all. - -The only thing you may have to install manually is the Python mode for -Emacs found in Misc/python-mode.el. (But then again, more recent -versions of Emacs may already have it.) Follow the instructions that -came with Emacs for installation of site-specific files. - -On Mac OS X, if you have configured Python with --enable-framework, you -should use "make frameworkinstall" to do the installation. Note that this -installs the Python executable in a place that is not normally on your -PATH, you may want to set up a symlink in /usr/local/bin. - - -Configuration options and variables ------------------------------------ - -Some special cases are handled by passing options to the configure -script. - -WARNING: if you rerun the configure script with different options, you -must run "make clean" before rebuilding. Exceptions to this rule: -after changing --prefix or --exec-prefix, all you need to do is remove -Modules/getpath.o. - ---with(out)-gcc: The configure script uses gcc (the GNU C compiler) if - it finds it. If you don't want this, or if this compiler is - installed but broken on your platform, pass the option - --without-gcc. You can also pass "CC=cc" (or whatever the - name of the proper C compiler is) in the environment, but the - advantage of using --without-gcc is that this option is - remembered by the config.status script for its --recheck - option. - ---prefix, --exec-prefix: If you want to install the binaries and the - Python library somewhere else than in /usr/local/{bin,lib}, - you can pass the option --prefix=DIRECTORY; the interpreter - binary will be installed as DIRECTORY/bin/python and the - library files as DIRECTORY/lib/python/*. If you pass - --exec-prefix=DIRECTORY (as well) this overrides the - installation prefix for architecture-dependent files (like the - interpreter binary). Note that --prefix=DIRECTORY also - affects the default module search path (sys.path), when - Modules/config.c is compiled. Passing make the option - prefix=DIRECTORY (and/or exec_prefix=DIRECTORY) overrides the - prefix set at configuration time; this may be more convenient - than re-running the configure script if you change your mind - about the install prefix. - ---with-readline: This option is no longer supported. GNU - readline is automatically enabled by setup.py when present. - ---with-threads: On most Unix systems, you can now use multiple - threads, and support for this is enabled by default. To - disable this, pass --with-threads=no. If the library required - for threads lives in a peculiar place, you can use - --with-thread=DIRECTORY. IMPORTANT: run "make clean" after - changing (either enabling or disabling) this option, or you - will get link errors! Note: for DEC Unix use - --with-dec-threads instead. - ---with-sgi-dl: On SGI IRIX 4, dynamic loading of extension modules is - supported by the "dl" library by Jack Jansen, which is - ftp'able from ftp://ftp.cwi.nl/pub/dynload/dl-1.6.tar.Z. - This is enabled (after you've ftp'ed and compiled the dl - library) by passing --with-sgi-dl=DIRECTORY where DIRECTORY - is the absolute pathname of the dl library. (Don't bother on - IRIX 5, it already has dynamic linking using SunOS style - shared libraries.) THIS OPTION IS UNSUPPORTED. - ---with-dl-dld: Dynamic loading of modules is rumored to be supported - on some other systems: VAX (Ultrix), Sun3 (SunOS 3.4), Sequent - Symmetry (Dynix), and Atari ST. This is done using a - combination of the GNU dynamic loading package - (ftp://ftp.cwi.nl/pub/dynload/dl-dld-1.1.tar.Z) and an - emulation of the SGI dl library mentioned above (the emulation - can be found at - ftp://ftp.cwi.nl/pub/dynload/dld-3.2.3.tar.Z). To - enable this, ftp and compile both libraries, then call - configure, passing it the option - --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY where DL_DIRECTORY is - the absolute pathname of the dl emulation library and - DLD_DIRECTORY is the absolute pathname of the GNU dld library. - (Don't bother on SunOS 4 or 5, they already have dynamic - linking using shared libraries.) THIS OPTION IS UNSUPPORTED. - ---with-libm, --with-libc: It is possible to specify alternative - versions for the Math library (default -lm) and the C library - (default the empty string) using the options - --with-libm=STRING and --with-libc=STRING, respectively. For - example, if your system requires that you pass -lc_s to the C - compiler to use the shared C library, you can pass - --with-libc=-lc_s. These libraries are passed after all other - libraries, the C library last. - ---with-libs='libs': Add 'libs' to the LIBS that the python interpreter - is linked against. - ---with-cxx=: Some C++ compilers require that main() is - compiled with the C++ if there is any C++ code in the application. - Specifically, g++ on a.out systems may require that to support - construction of global objects. With this option, the main() function - of Python will be compiled with ; use that only if you - plan to use C++ extension modules, and if your compiler requires - compilation of main() as a C++ program. - - ---with-pydebug: Enable additional debugging code to help track down - memory management problems. This allows printing a list of all - live objects when the interpreter terminates. - ---with(out)-universal-newlines: enable reading of text files with - foreign newline convention (default: enabled). In other words, - any of \r, \n or \r\n is acceptable as end-of-line character. - If enabled import and execfile will automatically accept any newline - in files. Python code can open a file with open(file, 'U') to - read it in universal newline mode. THIS OPTION IS UNSUPPORTED. - - -Building for multiple architectures (using the VPATH feature) -------------------------------------------------------------- - -If your file system is shared between multiple architectures, it -usually is not necessary to make copies of the sources for each -architecture you want to support. If the make program supports the -VPATH feature, you can create an empty build directory for each -architecture, and in each directory run the configure script (on the -appropriate machine with the appropriate options). This creates the -necessary subdirectories and the Makefiles therein. The Makefiles -contain a line VPATH=... which points to a directory containing the -actual sources. (On SGI systems, use "smake -J1" instead of "make" if -you use VPATH -- don't try gnumake.) - -For example, the following is all you need to build a minimal Python -in /usr/tmp/python (assuming ~guido/src/python is the toplevel -directory and you want to build in /usr/tmp/python): - - $ mkdir /usr/tmp/python - $ cd /usr/tmp/python - $ ~guido/src/python/configure - [...] - $ make - [...] - $ - -Note that configure copies the original Setup file to the build -directory if it finds no Setup file there. This means that you can -edit the Setup file for each architecture independently. For this -reason, subsequent changes to the original Setup file are not tracked -automatically, as they might overwrite local changes. To force a copy -of a changed original Setup file, delete the target Setup file. (The -makesetup script supports multiple input files, so if you want to be -fancy you can change the rules to create an empty Setup.local if it -doesn't exist and run it with arguments $(srcdir)/Setup Setup.local; -however this assumes that you only need to add modules.) - - -Building on non-UNIX systems ----------------------------- - -For Windows (2000/NT/ME/98/95), assuming you have MS VC++ 6.0, the -project files are in PCbuild, the workspace is pcbuild.dsw. See -PCbuild\readme.txt for detailed instructions. - -For other non-Unix Windows compilers, in particular Windows 3.1 and -for OS/2, enter the directory "PC" and read the file "readme.txt". - -For the Mac, a separate source distribution will be made available, -for use with the CodeWarrior compiler. If you are interested in Mac -development, join the PythonMac Special Interest Group -(http://www.python.org/sigs/pythonmac-sig/, or send email to -pythonmac-sig-request@python.org). - -Of course, there are also binary distributions available for these -platforms -- see http://www.python.org/. - -To port Python to a new non-UNIX system, you will have to fake the -effect of running the configure script manually (for Mac and PC, this -has already been done for you). A good start is to copy the file -pyconfig.h.in to pyconfig.h and edit the latter to reflect the actual -configuration of your system. Most symbols must simply be defined as -1 only if the corresponding feature is present and can be left alone -otherwise; however the *_t type symbols must be defined as some -variant of int if they need to be defined at all. - -For all platforms, it's important that the build arrange to define the -preprocessor symbol NDEBUG on the compiler command line in a release -build of Python (else assert() calls remain in the code, hurting -release-build performance). The Unix, Windows and Mac builds already -do this. - - -Miscellaneous issues -==================== - -Emacs mode ----------- - -There's an excellent Emacs editing mode for Python code; see the file -Misc/python-mode.el. Originally written by the famous Tim Peters, it -is now maintained by the equally famous Barry Warsaw (it's no -coincidence that they now both work on the same team). The latest -version, along with various other contributed Python-related Emacs -goodies, is online at http://www.python.org/emacs/python-mode. And -if you are planning to edit the Python C code, please pick up the -latest version of CC Mode http://www.python.org/emacs/cc-mode; it -contains a "python" style used throughout most of the Python C source -files. (Newer versions of Emacs or XEmacs may already come with the -latest version of python-mode.) - - -Tkinter -------- - -The setup.py script automatically configures this when it detects a -usable Tcl/Tk installation. This requires Tcl/Tk version 8.0 or -higher. - -For more Tkinter information, see the Tkinter Resource page: -http://www.python.org/topics/tkinter/ - -There are demos in the Demo/tkinter directory, in the subdirectories -guido, matt and www (the matt and guido subdirectories have been -overhauled to use more recent Tkinter coding conventions). - -Note that there's a Python module called "Tkinter" (capital T) which -lives in Lib/lib-tk/Tkinter.py, and a C module called "_tkinter" -(lower case t and leading underscore) which lives in -Modules/_tkinter.c. Demos and normal Tk applications import only the -Python Tkinter module -- only the latter imports the C _tkinter -module. In order to find the C _tkinter module, it must be compiled -and linked into the Python interpreter -- the setup.py script does -this. In order to find the Python Tkinter module, sys.path must be -set correctly -- normal installation takes care of this. - - -Distribution structure ----------------------- - -Most subdirectories have their own README files. Most files have -comments. - -.cvsignore Additional filename matching patterns for CVS to ignore -BeOS/ Files specific to the BeOS port -Demo/ Demonstration scripts, modules and programs -Doc/ Documentation sources (LaTeX) -Grammar/ Input for the parser generator -Include/ Public header files -LICENSE Licensing information -Lib/ Python library modules -Mac/ Macintosh specific resources -Makefile.pre.in Source from which config.status creates the Makefile.pre -Misc/ Miscellaneous useful files -Modules/ Implementation of most built-in modules -Objects/ Implementation of most built-in object types -PC/ Files specific to PC ports (DOS, Windows, OS/2) -PCbuild/ Build directory for Microsoft Visual C++ -Parser/ The parser and tokenizer and their input handling -Python/ The byte-compiler and interpreter -README The file you're reading now -Tools/ Some useful programs written in Python -pyconfig.h.in Source from which pyconfig.h is created (GNU autoheader output) -configure Configuration shell script (GNU autoconf output) -configure.in Configuration specification (input for GNU autoconf) -install-sh Shell script used to install files - -The following files will (may) be created in the toplevel directory by -the configuration and build processes: - -Makefile Build rules -Makefile.pre Build rules before running Modules/makesetup -buildno Keeps track of the build number -config.cache Cache of configuration variables -pyconfig.h Configuration header -config.log Log from last configure run -config.status Status from last run of the configure script -getbuildinfo.o Object file from Modules/getbuildinfo.c -libpython.a The library archive -python The executable interpreter -tags, TAGS Tags files for vi and Emacs - - -That's all, folks! ------------------- - - ---Guido van Rossum (home page: http://www.python.org/~guido/) diff --git a/SDKs/XPlatform/Cypython-2.3.3/XboxBuild/_sre_static.vcproj b/SDKs/XPlatform/Cypython-2.3.3/XboxBuild/_sre_static.vcproj deleted file mode 100644 index 885517c2..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/XboxBuild/_sre_static.vcproj +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SDKs/XPlatform/Cypython-2.3.3/XboxBuild/pythoncore_static.vcproj b/SDKs/XPlatform/Cypython-2.3.3/XboxBuild/pythoncore_static.vcproj deleted file mode 100644 index 549e9127..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/XboxBuild/pythoncore_static.vcproj +++ /dev/null @@ -1,562 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/Python.h b/SDKs/XPlatform/Cypython-2.3.3/include/Python.h deleted file mode 100644 index d2b9b613..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/Python.h +++ /dev/null @@ -1,157 +0,0 @@ -#ifndef Py_PYTHON_H -#define Py_PYTHON_H -/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */ - -/* Include nearly all Python header files */ - -#include "patchlevel.h" -#include "pyconfig.h" - -/* Cyclic gc is always enabled, starting with release 2.3a1. Supply the - * old symbol for the benefit of extension modules written before then - * that may be conditionalizing on it. The core doesn't use it anymore. - */ -#ifndef WITH_CYCLE_GC -#define WITH_CYCLE_GC 1 -#endif - -#ifdef HAVE_LIMITS_H -#include -#else -#error "limits.h is required by std C -- why isn't HAVE_LIMITS_H defined?" -#endif - -#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE) -#define _SGI_MP_SOURCE -#endif - -#include -#ifndef NULL -# error "Python.h requires that stdio.h define NULL." -#endif - -#include -#include -#ifdef HAVE_STDLIB_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif - -/* CAUTION: Build setups should ensure that NDEBUG is defined on the - * compiler command line when building Python in release mode; else - * assert() calls won't be removed. - */ -#include - -#include "pyport.h" - -/* pyconfig.h or pyport.h may or may not define DL_IMPORT */ -#ifndef DL_IMPORT /* declarations for DLL import/export */ -#define DL_IMPORT(RTYPE) RTYPE -#endif -#ifndef DL_EXPORT /* declarations for DLL import/export */ -#define DL_EXPORT(RTYPE) RTYPE -#endif - -/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG. - * PYMALLOC_DEBUG is in error if pymalloc is not in use. - */ -#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG) -#define PYMALLOC_DEBUG -#endif -#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC) -#error "PYMALLOC_DEBUG requires WITH_PYMALLOC" -#endif -#include "pymem.h" - -#include "object.h" -#include "objimpl.h" - -#include "pydebug.h" - -#include "unicodeobject.h" -#include "intobject.h" -#include "boolobject.h" -#include "longobject.h" -#include "floatobject.h" -#ifndef WITHOUT_COMPLEX -#include "complexobject.h" -#endif -#include "rangeobject.h" -#include "stringobject.h" -#include "bufferobject.h" -#include "tupleobject.h" -#include "listobject.h" -#include "dictobject.h" -#include "enumobject.h" -#include "methodobject.h" -#include "moduleobject.h" -#include "funcobject.h" -#include "classobject.h" -#include "fileobject.h" -#include "cobject.h" -#include "traceback.h" -#include "sliceobject.h" -#include "cellobject.h" -#include "iterobject.h" -#include "descrobject.h" -#include "weakrefobject.h" - -#include "codecs.h" -#include "pyerrors.h" - -#include "pystate.h" - -#include "modsupport.h" -#include "pythonrun.h" -#include "ceval.h" -#include "sysmodule.h" -#include "intrcheck.h" -#include "import.h" - -#include "abstract.h" - -/* _Py_Mangle is defined in compile.c */ -PyAPI_FUNC(int) _Py_Mangle(char *p, char *name, \ - char *buffer, size_t maxlen); - -/* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */ -#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a)) - -/* PyArg_NoArgs should not be necessary. - Set ml_flags in the PyMethodDef to METH_NOARGS. */ -#define PyArg_NoArgs(v) PyArg_Parse(v, "") - -/* Convert a possibly signed character to a nonnegative int */ -/* XXX This assumes characters are 8 bits wide */ -#ifdef __CHAR_UNSIGNED__ -#define Py_CHARMASK(c) (c) -#else -#define Py_CHARMASK(c) ((c) & 0xff) -#endif - -#include "pyfpe.h" - -/* These definitions must match corresponding definitions in graminit.h. - There's code in compile.c that checks that they are the same. */ -#define Py_single_input 256 -#define Py_file_input 257 -#define Py_eval_input 258 - -#ifdef HAVE_PTH -/* GNU pth user-space thread support */ -#include -#endif - -/* Define macros for inline documentation. */ -#define PyDoc_VAR(name) static char name[] -#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) -#ifdef WITH_DOC_STRINGS -#define PyDoc_STR(str) str -#else -#define PyDoc_STR(str) "" -#endif - -#endif /* !Py_PYTHON_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/abstract.h b/SDKs/XPlatform/Cypython-2.3.3/include/abstract.h deleted file mode 100644 index d23a860c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/abstract.h +++ /dev/null @@ -1,1217 +0,0 @@ -#ifndef Py_ABSTRACTOBJECT_H -#define Py_ABSTRACTOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -/* Abstract Object Interface (many thanks to Jim Fulton) */ - -/* - PROPOSAL: A Generic Python Object Interface for Python C Modules - -Problem - - Python modules written in C that must access Python objects must do - so through routines whose interfaces are described by a set of - include files. Unfortunately, these routines vary according to the - object accessed. To use these routines, the C programmer must check - the type of the object being used and must call a routine based on - the object type. For example, to access an element of a sequence, - the programmer must determine whether the sequence is a list or a - tuple: - - if(is_tupleobject(o)) - e=gettupleitem(o,i) - else if(is_listitem(o)) - e=getlistitem(o,i) - - If the programmer wants to get an item from another type of object - that provides sequence behavior, there is no clear way to do it - correctly. - - The persistent programmer may peruse object.h and find that the - _typeobject structure provides a means of invoking up to (currently - about) 41 special operators. So, for example, a routine can get an - item from any object that provides sequence behavior. However, to - use this mechanism, the programmer must make their code dependent on - the current Python implementation. - - Also, certain semantics, especially memory management semantics, may - differ by the type of object being used. Unfortunately, these - semantics are not clearly described in the current include files. - An abstract interface providing more consistent semantics is needed. - -Proposal - - I propose the creation of a standard interface (with an associated - library of routines and/or macros) for generically obtaining the - services of Python objects. This proposal can be viewed as one - components of a Python C interface consisting of several components. - - From the viewpoint of C access to Python services, we have (as - suggested by Guido in off-line discussions): - - - "Very high level layer": two or three functions that let you exec or - eval arbitrary Python code given as a string in a module whose name is - given, passing C values in and getting C values out using - mkvalue/getargs style format strings. This does not require the user - to declare any variables of type "PyObject *". This should be enough - to write a simple application that gets Python code from the user, - execs it, and returns the output or errors. (Error handling must also - be part of this API.) - - - "Abstract objects layer": which is the subject of this proposal. - It has many functions operating on objects, and lest you do many - things from C that you can also write in Python, without going - through the Python parser. - - - "Concrete objects layer": This is the public type-dependent - interface provided by the standard built-in types, such as floats, - strings, and lists. This interface exists and is currently - documented by the collection of include files provided with the - Python distributions. - - From the point of view of Python accessing services provided by C - modules: - - - "Python module interface": this interface consist of the basic - routines used to define modules and their members. Most of the - current extensions-writing guide deals with this interface. - - - "Built-in object interface": this is the interface that a new - built-in type must provide and the mechanisms and rules that a - developer of a new built-in type must use and follow. - - This proposal is a "first-cut" that is intended to spur - discussion. See especially the lists of notes. - - The Python C object interface will provide four protocols: object, - numeric, sequence, and mapping. Each protocol consists of a - collection of related operations. If an operation that is not - provided by a particular type is invoked, then a standard exception, - NotImplementedError is raised with a operation name as an argument. - In addition, for convenience this interface defines a set of - constructors for building objects of built-in types. This is needed - so new objects can be returned from C functions that otherwise treat - objects generically. - -Memory Management - - For all of the functions described in this proposal, if a function - retains a reference to a Python object passed as an argument, then the - function will increase the reference count of the object. It is - unnecessary for the caller to increase the reference count of an - argument in anticipation of the object's retention. - - All Python objects returned from functions should be treated as new - objects. Functions that return objects assume that the caller will - retain a reference and the reference count of the object has already - been incremented to account for this fact. A caller that does not - retain a reference to an object that is returned from a function - must decrement the reference count of the object (using - DECREF(object)) to prevent memory leaks. - - Note that the behavior mentioned here is different from the current - behavior for some objects (e.g. lists and tuples) when certain - type-specific routines are called directly (e.g. setlistitem). The - proposed abstraction layer will provide a consistent memory - management interface, correcting for inconsistent behavior for some - built-in types. - -Protocols - -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ - -/* Object Protocol: */ - - /* Implemented elsewhere: - - int PyObject_Print(PyObject *o, FILE *fp, int flags); - - Print an object, o, on file, fp. Returns -1 on - error. The flags argument is used to enable certain printing - options. The only option currently supported is Py_Print_RAW. - - (What should be said about Py_Print_RAW?) - - */ - - /* Implemented elsewhere: - - int PyObject_HasAttrString(PyObject *o, char *attr_name); - - Returns 1 if o has the attribute attr_name, and 0 otherwise. - This is equivalent to the Python expression: - hasattr(o,attr_name). - - This function always succeeds. - - */ - - /* Implemented elsewhere: - - PyObject* PyObject_GetAttrString(PyObject *o, char *attr_name); - - Retrieve an attributed named attr_name form object o. - Returns the attribute value on success, or NULL on failure. - This is the equivalent of the Python expression: o.attr_name. - - */ - - /* Implemented elsewhere: - - int PyObject_HasAttr(PyObject *o, PyObject *attr_name); - - Returns 1 if o has the attribute attr_name, and 0 otherwise. - This is equivalent to the Python expression: - hasattr(o,attr_name). - - This function always succeeds. - - */ - - /* Implemented elsewhere: - - PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name); - - Retrieve an attributed named attr_name form object o. - Returns the attribute value on success, or NULL on failure. - This is the equivalent of the Python expression: o.attr_name. - - */ - - - /* Implemented elsewhere: - - int PyObject_SetAttrString(PyObject *o, char *attr_name, PyObject *v); - - Set the value of the attribute named attr_name, for object o, - to the value, v. Returns -1 on failure. This is - the equivalent of the Python statement: o.attr_name=v. - - */ - - /* Implemented elsewhere: - - int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v); - - Set the value of the attribute named attr_name, for object o, - to the value, v. Returns -1 on failure. This is - the equivalent of the Python statement: o.attr_name=v. - - */ - - /* implemented as a macro: - - int PyObject_DelAttrString(PyObject *o, char *attr_name); - - Delete attribute named attr_name, for object o. Returns - -1 on failure. This is the equivalent of the Python - statement: del o.attr_name. - - */ -#define PyObject_DelAttrString(O,A) PyObject_SetAttrString((O),(A),NULL) - - /* implemented as a macro: - - int PyObject_DelAttr(PyObject *o, PyObject *attr_name); - - Delete attribute named attr_name, for object o. Returns -1 - on failure. This is the equivalent of the Python - statement: del o.attr_name. - - */ -#define PyObject_DelAttr(O,A) PyObject_SetAttr((O),(A),NULL) - - PyAPI_FUNC(int) PyObject_Cmp(PyObject *o1, PyObject *o2, int *result); - - /* - Compare the values of o1 and o2 using a routine provided by - o1, if one exists, otherwise with a routine provided by o2. - The result of the comparison is returned in result. Returns - -1 on failure. This is the equivalent of the Python - statement: result=cmp(o1,o2). - - */ - - /* Implemented elsewhere: - - int PyObject_Compare(PyObject *o1, PyObject *o2); - - Compare the values of o1 and o2 using a routine provided by - o1, if one exists, otherwise with a routine provided by o2. - Returns the result of the comparison on success. On error, - the value returned is undefined. This is equivalent to the - Python expression: cmp(o1,o2). - - */ - - /* Implemented elsewhere: - - PyObject *PyObject_Repr(PyObject *o); - - Compute the string representation of object, o. Returns the - string representation on success, NULL on failure. This is - the equivalent of the Python expression: repr(o). - - Called by the repr() built-in function and by reverse quotes. - - */ - - /* Implemented elsewhere: - - PyObject *PyObject_Str(PyObject *o); - - Compute the string representation of object, o. Returns the - string representation on success, NULL on failure. This is - the equivalent of the Python expression: str(o).) - - Called by the str() built-in function and by the print - statement. - - */ - - /* Implemented elsewhere: - - PyObject *PyObject_Unicode(PyObject *o); - - Compute the unicode representation of object, o. Returns the - unicode representation on success, NULL on failure. This is - the equivalent of the Python expression: unistr(o).) - - Called by the unistr() built-in function. - - */ - - PyAPI_FUNC(int) PyCallable_Check(PyObject *o); - - /* - Determine if the object, o, is callable. Return 1 if the - object is callable and 0 otherwise. - - This function always succeeds. - - */ - - - - PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable_object, - PyObject *args, PyObject *kw); - - /* - Call a callable Python object, callable_object, with - arguments and keywords arguments. The 'args' argument can not be - NULL, but the 'kw' argument can be NULL. - - */ - - PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable_object, - PyObject *args); - - /* - Call a callable Python object, callable_object, with - arguments given by the tuple, args. If no arguments are - needed, then args may be NULL. Returns the result of the - call on success, or NULL on failure. This is the equivalent - of the Python expression: apply(o,args). - - */ - - PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable_object, - char *format, ...); - - /* - Call a callable Python object, callable_object, with a - variable number of C arguments. The C arguments are described - using a mkvalue-style format string. The format may be NULL, - indicating that no arguments are provided. Returns the - result of the call on success, or NULL on failure. This is - the equivalent of the Python expression: apply(o,args). - - */ - - - PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *o, char *m, - char *format, ...); - - /* - Call the method named m of object o with a variable number of - C arguments. The C arguments are described by a mkvalue - format string. The format may be NULL, indicating that no - arguments are provided. Returns the result of the call on - success, or NULL on failure. This is the equivalent of the - Python expression: o.method(args). - */ - - - PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable, - ...); - - /* - Call a callable Python object, callable_object, with a - variable number of C arguments. The C arguments are provided - as PyObject * values, terminated by a NULL. Returns the - result of the call on success, or NULL on failure. This is - the equivalent of the Python expression: apply(o,args). - */ - - - PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(PyObject *o, - PyObject *m, ...); - - /* - Call the method named m of object o with a variable number of - C arguments. The C arguments are provided as PyObject * - values, terminated by NULL. Returns the result of the call - on success, or NULL on failure. This is the equivalent of - the Python expression: o.method(args). - */ - - - /* Implemented elsewhere: - - long PyObject_Hash(PyObject *o); - - Compute and return the hash, hash_value, of an object, o. On - failure, return -1. This is the equivalent of the Python - expression: hash(o). - - */ - - - /* Implemented elsewhere: - - int PyObject_IsTrue(PyObject *o); - - Returns 1 if the object, o, is considered to be true, 0 if o is - considered to be false and -1 on failure. This is equivalent to the - Python expression: not not o - - */ - - /* Implemented elsewhere: - - int PyObject_Not(PyObject *o); - - Returns 0 if the object, o, is considered to be true, 1 if o is - considered to be false and -1 on failure. This is equivalent to the - Python expression: not o - - */ - - PyAPI_FUNC(PyObject *) PyObject_Type(PyObject *o); - - /* - On success, returns a type object corresponding to the object - type of object o. On failure, returns NULL. This is - equivalent to the Python expression: type(o). - */ - - PyAPI_FUNC(int) PyObject_Size(PyObject *o); - - /* - Return the size of object o. If the object, o, provides - both sequence and mapping protocols, the sequence size is - returned. On error, -1 is returned. This is the equivalent - to the Python expression: len(o). - - */ - - /* For DLL compatibility */ -#undef PyObject_Length - PyAPI_FUNC(int) PyObject_Length(PyObject *o); -#define PyObject_Length PyObject_Size - - - PyAPI_FUNC(PyObject *) PyObject_GetItem(PyObject *o, PyObject *key); - - /* - Return element of o corresponding to the object, key, or NULL - on failure. This is the equivalent of the Python expression: - o[key]. - - */ - - PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v); - - /* - Map the object, key, to the value, v. Returns - -1 on failure. This is the equivalent of the Python - statement: o[key]=v. - */ - - PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, char *key); - - /* - Remove the mapping for object, key, from the object *o. - Returns -1 on failure. This is equivalent to - the Python statement: del o[key]. - */ - - PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key); - - /* - Delete the mapping for key from *o. Returns -1 on failure. - This is the equivalent of the Python statement: del o[key]. - */ - - PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj, - const char **buffer, - int *buffer_len); - - /* - Takes an arbitrary object which must support the (character, - single segment) buffer interface and returns a pointer to a - read-only memory location useable as character based input - for subsequent processing. - - 0 is returned on success. buffer and buffer_len are only - set in case no error occurs. Otherwise, -1 is returned and - an exception set. - - */ - - PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj); - - /* - Checks whether an arbitrary object supports the (character, - single segment) buffer interface. Returns 1 on success, 0 - on failure. - - */ - - PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj, - const void **buffer, - int *buffer_len); - - /* - Same as PyObject_AsCharBuffer() except that this API expects - (readable, single segment) buffer interface and returns a - pointer to a read-only memory location which can contain - arbitrary data. - - 0 is returned on success. buffer and buffer_len are only - set in case no error occurrs. Otherwise, -1 is returned and - an exception set. - - */ - - PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj, - void **buffer, - int *buffer_len); - - /* - Takes an arbitrary object which must support the (writeable, - single segment) buffer interface and returns a pointer to a - writeable memory location in buffer of size buffer_len. - - 0 is returned on success. buffer and buffer_len are only - set in case no error occurrs. Otherwise, -1 is returned and - an exception set. - - */ - -/* Iterators */ - - PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *); - /* Takes an object and returns an iterator for it. - This is typically a new iterator but if the argument - is an iterator, this returns itself. */ - -#define PyIter_Check(obj) \ - (PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_ITER) && \ - (obj)->ob_type->tp_iternext != NULL) - - PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *); - /* Takes an iterator object and calls its tp_iternext slot, - returning the next value. If the iterator is exhausted, - this returns NULL without setting an exception. - NULL with an exception means an error occurred. */ - -/* Number Protocol:*/ - - PyAPI_FUNC(int) PyNumber_Check(PyObject *o); - - /* - Returns 1 if the object, o, provides numeric protocols, and - false otherwise. - - This function always succeeds. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Add(PyObject *o1, PyObject *o2); - - /* - Returns the result of adding o1 and o2, or null on failure. - This is the equivalent of the Python expression: o1+o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Subtract(PyObject *o1, PyObject *o2); - - /* - Returns the result of subtracting o2 from o1, or null on - failure. This is the equivalent of the Python expression: - o1-o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Multiply(PyObject *o1, PyObject *o2); - - /* - Returns the result of multiplying o1 and o2, or null on - failure. This is the equivalent of the Python expression: - o1*o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Divide(PyObject *o1, PyObject *o2); - - /* - Returns the result of dividing o1 by o2, or null on failure. - This is the equivalent of the Python expression: o1/o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2); - - /* - Returns the result of dividing o1 by o2 giving an integral result, - or null on failure. - This is the equivalent of the Python expression: o1//o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_TrueDivide(PyObject *o1, PyObject *o2); - - /* - Returns the result of dividing o1 by o2 giving a float result, - or null on failure. - This is the equivalent of the Python expression: o1/o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Remainder(PyObject *o1, PyObject *o2); - - /* - Returns the remainder of dividing o1 by o2, or null on - failure. This is the equivalent of the Python expression: - o1%o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Divmod(PyObject *o1, PyObject *o2); - - /* - See the built-in function divmod. Returns NULL on failure. - This is the equivalent of the Python expression: - divmod(o1,o2). - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Power(PyObject *o1, PyObject *o2, - PyObject *o3); - - /* - See the built-in function pow. Returns NULL on failure. - This is the equivalent of the Python expression: - pow(o1,o2,o3), where o3 is optional. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Negative(PyObject *o); - - /* - Returns the negation of o on success, or null on failure. - This is the equivalent of the Python expression: -o. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Positive(PyObject *o); - - /* - Returns the (what?) of o on success, or NULL on failure. - This is the equivalent of the Python expression: +o. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Absolute(PyObject *o); - - /* - Returns the absolute value of o, or null on failure. This is - the equivalent of the Python expression: abs(o). - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Invert(PyObject *o); - - /* - Returns the bitwise negation of o on success, or NULL on - failure. This is the equivalent of the Python expression: - ~o. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Lshift(PyObject *o1, PyObject *o2); - - /* - Returns the result of left shifting o1 by o2 on success, or - NULL on failure. This is the equivalent of the Python - expression: o1 << o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Rshift(PyObject *o1, PyObject *o2); - - /* - Returns the result of right shifting o1 by o2 on success, or - NULL on failure. This is the equivalent of the Python - expression: o1 >> o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_And(PyObject *o1, PyObject *o2); - - /* - Returns the result of bitwise and of o1 and o2 on success, or - NULL on failure. This is the equivalent of the Python - expression: o1&o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Xor(PyObject *o1, PyObject *o2); - - /* - Returns the bitwise exclusive or of o1 by o2 on success, or - NULL on failure. This is the equivalent of the Python - expression: o1^o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2); - - /* - Returns the result of bitwise or on o1 and o2 on success, or - NULL on failure. This is the equivalent of the Python - expression: o1|o2. - - */ - - /* Implemented elsewhere: - - int PyNumber_Coerce(PyObject **p1, PyObject **p2); - - This function takes the addresses of two variables of type - PyObject*. - - If the objects pointed to by *p1 and *p2 have the same type, - increment their reference count and return 0 (success). - If the objects can be converted to a common numeric type, - replace *p1 and *p2 by their converted value (with 'new' - reference counts), and return 0. - If no conversion is possible, or if some other error occurs, - return -1 (failure) and don't increment the reference counts. - The call PyNumber_Coerce(&o1, &o2) is equivalent to the Python - statement o1, o2 = coerce(o1, o2). - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Int(PyObject *o); - - /* - Returns the o converted to an integer object on success, or - NULL on failure. This is the equivalent of the Python - expression: int(o). - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o); - - /* - Returns the o converted to a long integer object on success, - or NULL on failure. This is the equivalent of the Python - expression: long(o). - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Float(PyObject *o); - - /* - Returns the o converted to a float object on success, or NULL - on failure. This is the equivalent of the Python expression: - float(o). - */ - -/* In-place variants of (some of) the above number protocol functions */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2); - - /* - Returns the result of adding o2 to o1, possibly in-place, or null - on failure. This is the equivalent of the Python expression: - o1 += o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2); - - /* - Returns the result of subtracting o2 from o1, possibly in-place or - null on failure. This is the equivalent of the Python expression: - o1 -= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2); - - /* - Returns the result of multiplying o1 by o2, possibly in-place, or - null on failure. This is the equivalent of the Python expression: - o1 *= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2); - - /* - Returns the result of dividing o1 by o2, possibly in-place, or null - on failure. This is the equivalent of the Python expression: - o1 /= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1, - PyObject *o2); - - /* - Returns the result of dividing o1 by o2 giving an integral result, - possibly in-place, or null on failure. - This is the equivalent of the Python expression: - o1 /= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceTrueDivide(PyObject *o1, - PyObject *o2); - - /* - Returns the result of dividing o1 by o2 giving a float result, - possibly in-place, or null on failure. - This is the equivalent of the Python expression: - o1 /= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2); - - /* - Returns the remainder of dividing o1 by o2, possibly in-place, or - null on failure. This is the equivalent of the Python expression: - o1 %= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlacePower(PyObject *o1, PyObject *o2, - PyObject *o3); - - /* - Returns the result of raising o1 to the power of o2, possibly - in-place, or null on failure. This is the equivalent of the Python - expression: o1 **= o2, or pow(o1, o2, o3) if o3 is present. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2); - - /* - Returns the result of left shifting o1 by o2, possibly in-place, or - null on failure. This is the equivalent of the Python expression: - o1 <<= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2); - - /* - Returns the result of right shifting o1 by o2, possibly in-place or - null on failure. This is the equivalent of the Python expression: - o1 >>= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2); - - /* - Returns the result of bitwise and of o1 and o2, possibly in-place, - or null on failure. This is the equivalent of the Python - expression: o1 &= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceXor(PyObject *o1, PyObject *o2); - - /* - Returns the bitwise exclusive or of o1 by o2, possibly in-place, or - null on failure. This is the equivalent of the Python expression: - o1 ^= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceOr(PyObject *o1, PyObject *o2); - - /* - Returns the result of bitwise or of o1 and o2, possibly in-place, - or null on failure. This is the equivalent of the Python - expression: o1 |= o2. - - */ - - -/* Sequence protocol:*/ - - PyAPI_FUNC(int) PySequence_Check(PyObject *o); - - /* - Return 1 if the object provides sequence protocol, and zero - otherwise. - - This function always succeeds. - - */ - - PyAPI_FUNC(int) PySequence_Size(PyObject *o); - - /* - Return the size of sequence object o, or -1 on failure. - - */ - - /* For DLL compatibility */ -#undef PySequence_Length - PyAPI_FUNC(int) PySequence_Length(PyObject *o); -#define PySequence_Length PySequence_Size - - - PyAPI_FUNC(PyObject *) PySequence_Concat(PyObject *o1, PyObject *o2); - - /* - Return the concatenation of o1 and o2 on success, and NULL on - failure. This is the equivalent of the Python - expression: o1+o2. - - */ - - PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, int count); - - /* - Return the result of repeating sequence object o count times, - or NULL on failure. This is the equivalent of the Python - expression: o1*count. - - */ - - PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, int i); - - /* - Return the ith element of o, or NULL on failure. This is the - equivalent of the Python expression: o[i]. - */ - - PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, int i1, int i2); - - /* - Return the slice of sequence object o between i1 and i2, or - NULL on failure. This is the equivalent of the Python - expression: o[i1:i2]. - - */ - - PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, int i, PyObject *v); - - /* - Assign object v to the ith element of o. Returns - -1 on failure. This is the equivalent of the Python - statement: o[i]=v. - - */ - - PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, int i); - - /* - Delete the ith element of object v. Returns - -1 on failure. This is the equivalent of the Python - statement: del o[i]. - */ - - PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, int i1, int i2, - PyObject *v); - - /* - Assign the sequence object, v, to the slice in sequence - object, o, from i1 to i2. Returns -1 on failure. This is the - equivalent of the Python statement: o[i1:i2]=v. - */ - - PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, int i1, int i2); - - /* - Delete the slice in sequence object, o, from i1 to i2. - Returns -1 on failure. This is the equivalent of the Python - statement: del o[i1:i2]. - */ - - PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o); - - /* - Returns the sequence, o, as a tuple on success, and NULL on failure. - This is equivalent to the Python expression: tuple(o) - */ - - - PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o); - /* - Returns the sequence, o, as a list on success, and NULL on failure. - This is equivalent to the Python expression: list(o) - */ - - PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m); - /* - Returns the sequence, o, as a tuple, unless it's already a - tuple or list. Use PySequence_Fast_GET_ITEM to access the - members of this list, and PySequence_Fast_GET_SIZE to get its length. - - Returns NULL on failure. If the object does not support iteration, - raises a TypeError exception with m as the message text. - */ - -#define PySequence_Fast_GET_SIZE(o) \ - (PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o)) - /* - Return the size of o, assuming that o was returned by - PySequence_Fast and is not NULL. - */ - -#define PySequence_Fast_GET_ITEM(o, i)\ - (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i)) - /* - Return the ith element of o, assuming that o was returned by - PySequence_Fast, and that i is within bounds. - */ - -#define PySequence_ITEM(o, i)\ - ( o->ob_type->tp_as_sequence->sq_item(o, i) ) - /* Assume tp_as_sequence and sq_item exist and that i does not - need to be corrected for a negative index - */ - - PyAPI_FUNC(int) PySequence_Count(PyObject *o, PyObject *value); - - /* - Return the number of occurrences on value on o, that is, - return the number of keys for which o[key]==value. On - failure, return -1. This is equivalent to the Python - expression: o.count(value). - */ - - PyAPI_FUNC(int) PySequence_Contains(PyObject *seq, PyObject *ob); - /* - Return -1 if error; 1 if ob in seq; 0 if ob not in seq. - Use __contains__ if possible, else _PySequence_IterSearch(). - */ - -#define PY_ITERSEARCH_COUNT 1 -#define PY_ITERSEARCH_INDEX 2 -#define PY_ITERSEARCH_CONTAINS 3 - PyAPI_FUNC(int) _PySequence_IterSearch(PyObject *seq, PyObject *obj, - int operation); - /* - Iterate over seq. Result depends on the operation: - PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if - error. - PY_ITERSEARCH_INDEX: return 0-based index of first occurrence of - obj in seq; set ValueError and return -1 if none found; - also return -1 on error. - PY_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on - error. - */ - -/* For DLL-level backwards compatibility */ -#undef PySequence_In - PyAPI_FUNC(int) PySequence_In(PyObject *o, PyObject *value); - -/* For source-level backwards compatibility */ -#define PySequence_In PySequence_Contains - - /* - Determine if o contains value. If an item in o is equal to - X, return 1, otherwise return 0. On error, return -1. This - is equivalent to the Python expression: value in o. - */ - - PyAPI_FUNC(int) PySequence_Index(PyObject *o, PyObject *value); - - /* - Return the first index for which o[i]=value. On error, - return -1. This is equivalent to the Python - expression: o.index(value). - */ - -/* In-place versions of some of the above Sequence functions. */ - - PyAPI_FUNC(PyObject *) PySequence_InPlaceConcat(PyObject *o1, PyObject *o2); - - /* - Append o2 to o1, in-place when possible. Return the resulting - object, which could be o1, or NULL on failure. This is the - equivalent of the Python expression: o1 += o2. - - */ - - PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, int count); - - /* - Repeat o1 by count, in-place when possible. Return the resulting - object, which could be o1, or NULL on failure. This is the - equivalent of the Python expression: o1 *= count. - - */ - -/* Mapping protocol:*/ - - PyAPI_FUNC(int) PyMapping_Check(PyObject *o); - - /* - Return 1 if the object provides mapping protocol, and zero - otherwise. - - This function always succeeds. - */ - - PyAPI_FUNC(int) PyMapping_Size(PyObject *o); - - /* - Returns the number of keys in object o on success, and -1 on - failure. For objects that do not provide sequence protocol, - this is equivalent to the Python expression: len(o). - */ - - /* For DLL compatibility */ -#undef PyMapping_Length - PyAPI_FUNC(int) PyMapping_Length(PyObject *o); -#define PyMapping_Length PyMapping_Size - - - /* implemented as a macro: - - int PyMapping_DelItemString(PyObject *o, char *key); - - Remove the mapping for object, key, from the object *o. - Returns -1 on failure. This is equivalent to - the Python statement: del o[key]. - */ -#define PyMapping_DelItemString(O,K) PyObject_DelItemString((O),(K)) - - /* implemented as a macro: - - int PyMapping_DelItem(PyObject *o, PyObject *key); - - Remove the mapping for object, key, from the object *o. - Returns -1 on failure. This is equivalent to - the Python statement: del o[key]. - */ -#define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K)) - - PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, char *key); - - /* - On success, return 1 if the mapping object has the key, key, - and 0 otherwise. This is equivalent to the Python expression: - o.has_key(key). - - This function always succeeds. - */ - - PyAPI_FUNC(int) PyMapping_HasKey(PyObject *o, PyObject *key); - - /* - Return 1 if the mapping object has the key, key, - and 0 otherwise. This is equivalent to the Python expression: - o.has_key(key). - - This function always succeeds. - - */ - - /* Implemented as macro: - - PyObject *PyMapping_Keys(PyObject *o); - - On success, return a list of the keys in object o. On - failure, return NULL. This is equivalent to the Python - expression: o.keys(). - */ -#define PyMapping_Keys(O) PyObject_CallMethod(O,"keys",NULL) - - /* Implemented as macro: - - PyObject *PyMapping_Values(PyObject *o); - - On success, return a list of the values in object o. On - failure, return NULL. This is equivalent to the Python - expression: o.values(). - */ -#define PyMapping_Values(O) PyObject_CallMethod(O,"values",NULL) - - /* Implemented as macro: - - PyObject *PyMapping_Items(PyObject *o); - - On success, return a list of the items in object o, where - each item is a tuple containing a key-value pair. On - failure, return NULL. This is equivalent to the Python - expression: o.items(). - - */ -#define PyMapping_Items(O) PyObject_CallMethod(O,"items",NULL) - - PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o, char *key); - - /* - Return element of o corresponding to the object, key, or NULL - on failure. This is the equivalent of the Python expression: - o[key]. - */ - - PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, char *key, - PyObject *value); - - /* - Map the object, key, to the value, v. Returns - -1 on failure. This is the equivalent of the Python - statement: o[key]=v. - */ - - -PyAPI_FUNC(int) PyObject_IsInstance(PyObject *object, PyObject *typeorclass); - /* isinstance(object, typeorclass) */ - -PyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass); - /* issubclass(object, typeorclass) */ - - -#ifdef __cplusplus -} -#endif -#endif /* Py_ABSTRACTOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/bitset.h b/SDKs/XPlatform/Cypython-2.3.3/include/bitset.h deleted file mode 100644 index 028acdf0..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/bitset.h +++ /dev/null @@ -1,32 +0,0 @@ - -#ifndef Py_BITSET_H -#define Py_BITSET_H -#ifdef __cplusplus -extern "C" { -#endif - -/* Bitset interface */ - -#define BYTE char - -typedef BYTE *bitset; - -bitset newbitset(int nbits); -void delbitset(bitset bs); -#define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0) -int addbit(bitset bs, int ibit); /* Returns 0 if already set */ -int samebitset(bitset bs1, bitset bs2, int nbits); -void mergebitset(bitset bs1, bitset bs2, int nbits); - -#define BITSPERBYTE (8*sizeof(BYTE)) -#define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE) - -#define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE) -#define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE) -#define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit)) -#define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_BITSET_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/boolobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/boolobject.h deleted file mode 100644 index 28da1d0b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/boolobject.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Boolean object interface */ - -#ifndef Py_BOOLOBJECT_H -#define Py_BOOLOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - - -typedef PyIntObject PyBoolObject; - -PyAPI_DATA(PyTypeObject) PyBool_Type; - -#define PyBool_Check(x) ((x)->ob_type == &PyBool_Type) - -/* Py_False and Py_True are the only two bools in existence. -Don't forget to apply Py_INCREF() when returning either!!! */ - -/* Don't use these directly */ -PyAPI_DATA(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct; - -/* Use these macros */ -#define Py_False ((PyObject *) &_Py_ZeroStruct) -#define Py_True ((PyObject *) &_Py_TrueStruct) - -/* Function to return a bool from a C long */ -PyAPI_FUNC(PyObject *) PyBool_FromLong(long); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_BOOLOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/bufferobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/bufferobject.h deleted file mode 100644 index 5d6a16b9..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/bufferobject.h +++ /dev/null @@ -1,33 +0,0 @@ - -/* Buffer object interface */ - -/* Note: the object's structure is private */ - -#ifndef Py_BUFFEROBJECT_H -#define Py_BUFFEROBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - - -PyAPI_DATA(PyTypeObject) PyBuffer_Type; - -#define PyBuffer_Check(op) ((op)->ob_type == &PyBuffer_Type) - -#define Py_END_OF_BUFFER (-1) - -PyAPI_FUNC(PyObject *) PyBuffer_FromObject(PyObject *base, - int offset, int size); -PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base, - int offset, - int size); - -PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, int size); -PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, int size); - -PyAPI_FUNC(PyObject *) PyBuffer_New(int size); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_BUFFEROBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/cStringIO.h b/SDKs/XPlatform/Cypython-2.3.3/include/cStringIO.h deleted file mode 100644 index 6754b13f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/cStringIO.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef Py_CSTRINGIO_H -#define Py_CSTRINGIO_H -#ifdef __cplusplus -extern "C" { -#endif -/* - - This header provides access to cStringIO objects from C. - Functions are provided for calling cStringIO objects and - macros are provided for testing whether you have cStringIO - objects. - - Before calling any of the functions or macros, you must initialize - the routines with: - - PycString_IMPORT - - This would typically be done in your init function. - -*/ -#define PycString_IMPORT \ - PycStringIO = (struct PycStringIO_CAPI*)PyCObject_Import("cStringIO", \ - "cStringIO_CAPI") - -/* Basic functions to manipulate cStringIO objects from C */ - -static struct PycStringIO_CAPI { - - /* Read a string from an input object. If the last argument - is -1, the remainder will be read. - */ - int(*cread)(PyObject *, char **, int); - - /* Read a line from an input object. Returns the length of the read - line as an int and a pointer inside the object buffer as char** (so - the caller doesn't have to provide its own buffer as destination). - */ - int(*creadline)(PyObject *, char **); - - /* Write a string to an output object*/ - int(*cwrite)(PyObject *, char *, int); - - /* Get the output object as a Python string (returns new reference). */ - PyObject *(*cgetvalue)(PyObject *); - - /* Create a new output object */ - PyObject *(*NewOutput)(int); - - /* Create an input object from a Python string - (copies the Python string reference). - */ - PyObject *(*NewInput)(PyObject *); - - /* The Python types for cStringIO input and output objects. - Note that you can do input on an output object. - */ - PyTypeObject *InputType, *OutputType; - -} *PycStringIO; - -/* These can be used to test if you have one */ -#define PycStringIO_InputCheck(O) \ - ((O)->ob_type==PycStringIO->InputType) -#define PycStringIO_OutputCheck(O) \ - ((O)->ob_type==PycStringIO->OutputType) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_CSTRINGIO_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/cellobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/cellobject.h deleted file mode 100644 index cd2a4566..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/cellobject.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Cell object interface */ - -#ifndef Py_CELLOBJECT_H -#define Py_CELLOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - PyObject_HEAD - PyObject *ob_ref; -} PyCellObject; - -PyAPI_DATA(PyTypeObject) PyCell_Type; - -#define PyCell_Check(op) ((op)->ob_type == &PyCell_Type) - -PyAPI_FUNC(PyObject *) PyCell_New(PyObject *); -PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *); -PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *); - -#define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref) -#define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_TUPLEOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/ceval.h b/SDKs/XPlatform/Cypython-2.3.3/include/ceval.h deleted file mode 100644 index 1e7dba3e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/ceval.h +++ /dev/null @@ -1,138 +0,0 @@ -#ifndef Py_CEVAL_H -#define Py_CEVAL_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Interface to random parts in ceval.c */ - -PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords( - PyObject *, PyObject *, PyObject *); - -/* DLL-level Backwards compatibility: */ -#undef PyEval_CallObject -PyAPI_FUNC(PyObject *) PyEval_CallObject(PyObject *, PyObject *); - -/* Inline this */ -#define PyEval_CallObject(func,arg) \ - PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL) - -PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj, char *format, ...); -PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj, - char *methodname, char *format, ...); - -PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *); -PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *); - -struct _frame; /* Avoid including frameobject.h */ - -PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void); -PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void); -PyAPI_FUNC(PyObject *) PyEval_GetLocals(void); -PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void); -PyAPI_FUNC(int) PyEval_GetRestricted(void); - -/* Look at the current frame's (if any) code's co_flags, and turn on - the corresponding compiler flags in cf->cf_flags. Return 1 if any - flag was set, else return 0. */ -PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf); - -PyAPI_FUNC(int) Py_FlushLine(void); - -PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg); -PyAPI_FUNC(int) Py_MakePendingCalls(void); - -PyAPI_FUNC(void) Py_SetRecursionLimit(int); -PyAPI_FUNC(int) Py_GetRecursionLimit(void); - -PyAPI_FUNC(char *) PyEval_GetFuncName(PyObject *); -PyAPI_FUNC(char *) PyEval_GetFuncDesc(PyObject *); - -PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *); - -/* this used to be handled on a per-thread basis - now just two globals */ -PyAPI_DATA(volatile int) _Py_Ticker; -PyAPI_DATA(int) _Py_CheckInterval; - -/* Interface for threads. - - A module that plans to do a blocking system call (or something else - that lasts a long time and doesn't touch Python data) can allow other - threads to run as follows: - - ...preparations here... - Py_BEGIN_ALLOW_THREADS - ...blocking system call here... - Py_END_ALLOW_THREADS - ...interpret result here... - - The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a - {}-surrounded block. - To leave the block in the middle (e.g., with return), you must insert - a line containing Py_BLOCK_THREADS before the return, e.g. - - if (...premature_exit...) { - Py_BLOCK_THREADS - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - - An alternative is: - - Py_BLOCK_THREADS - if (...premature_exit...) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - Py_UNBLOCK_THREADS - - For convenience, that the value of 'errno' is restored across - Py_END_ALLOW_THREADS and Py_BLOCK_THREADS. - - WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND - Py_END_ALLOW_THREADS!!! - - The function PyEval_InitThreads() should be called only from - initthread() in "threadmodule.c". - - Note that not yet all candidates have been converted to use this - mechanism! -*/ - -PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void); -PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *); - -#ifdef WITH_THREAD - -PyAPI_FUNC(void) PyEval_InitThreads(void); -PyAPI_FUNC(void) PyEval_AcquireLock(void); -PyAPI_FUNC(void) PyEval_ReleaseLock(void); -PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate); -PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate); -PyAPI_FUNC(void) PyEval_ReInitThreads(void); - -#define Py_BEGIN_ALLOW_THREADS { \ - PyThreadState *_save; \ - _save = PyEval_SaveThread(); -#define Py_BLOCK_THREADS PyEval_RestoreThread(_save); -#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread(); -#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \ - } - -#else /* !WITH_THREAD */ - -#define Py_BEGIN_ALLOW_THREADS { -#define Py_BLOCK_THREADS -#define Py_UNBLOCK_THREADS -#define Py_END_ALLOW_THREADS } - -#endif /* !WITH_THREAD */ - -PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, int *); - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_CEVAL_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/classobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/classobject.h deleted file mode 100644 index 7262ad7a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/classobject.h +++ /dev/null @@ -1,81 +0,0 @@ - -/* Class object interface */ - -/* Revealing some structures (not for general use) */ - -#ifndef Py_CLASSOBJECT_H -#define Py_CLASSOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - PyObject_HEAD - PyObject *cl_bases; /* A tuple of class objects */ - PyObject *cl_dict; /* A dictionary */ - PyObject *cl_name; /* A string */ - /* The following three are functions or NULL */ - PyObject *cl_getattr; - PyObject *cl_setattr; - PyObject *cl_delattr; -} PyClassObject; - -typedef struct { - PyObject_HEAD - PyClassObject *in_class; /* The class object */ - PyObject *in_dict; /* A dictionary */ - PyObject *in_weakreflist; /* List of weak references */ -} PyInstanceObject; - -typedef struct { - PyObject_HEAD - PyObject *im_func; /* The callable object implementing the method */ - PyObject *im_self; /* The instance it is bound to, or NULL */ - PyObject *im_class; /* The class that asked for the method */ - PyObject *im_weakreflist; /* List of weak references */ -} PyMethodObject; - -PyAPI_DATA(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type; - -#define PyClass_Check(op) ((op)->ob_type == &PyClass_Type) -#define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type) -#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type) - -PyAPI_FUNC(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyInstance_New(PyObject *, PyObject *, - PyObject *); -PyAPI_FUNC(PyObject *) PyInstance_NewRaw(PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *); - -PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *); -PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *); -PyAPI_FUNC(PyObject *) PyMethod_Class(PyObject *); - -/* Look up attribute with name (a string) on instance object pinst, using - * only the instance and base class dicts. If a descriptor is found in - * a class dict, the descriptor is returned without calling it. - * Returns NULL if nothing found, else a borrowed reference to the - * value associated with name in the dict in which name was found. - * The point of this routine is that it never calls arbitrary Python - * code, so is always "safe": all it does is dict lookups. The function - * can't fail, never sets an exception, and NULL is not an error (it just - * means "not found"). - */ -PyAPI_FUNC(PyObject *) _PyInstance_Lookup(PyObject *pinst, PyObject *name); - -/* Macros for direct access to these values. Type checks are *not* - done, so use with care. */ -#define PyMethod_GET_FUNCTION(meth) \ - (((PyMethodObject *)meth) -> im_func) -#define PyMethod_GET_SELF(meth) \ - (((PyMethodObject *)meth) -> im_self) -#define PyMethod_GET_CLASS(meth) \ - (((PyMethodObject *)meth) -> im_class) - -PyAPI_FUNC(int) PyClass_IsSubclass(PyObject *, PyObject *); - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_CLASSOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/cobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/cobject.h deleted file mode 100644 index b5f6a944..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/cobject.h +++ /dev/null @@ -1,51 +0,0 @@ - -/* C objects to be exported from one extension module to another. - - C objects are used for communication between extension modules. - They provide a way for an extension module to export a C interface - to other extension modules, so that extension modules can use the - Python import mechanism to link to one another. - -*/ - -#ifndef Py_COBJECT_H -#define Py_COBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(PyTypeObject) PyCObject_Type; - -#define PyCObject_Check(op) ((op)->ob_type == &PyCObject_Type) - -/* Create a PyCObject from a pointer to a C object and an optional - destructor function. If the second argument is non-null, then it - will be called with the first argument if and when the PyCObject is - destroyed. - -*/ -PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr( - void *cobj, void (*destruct)(void*)); - - -/* Create a PyCObject from a pointer to a C object, a description object, - and an optional destructor function. If the third argument is non-null, - then it will be called with the first and second arguments if and when - the PyCObject is destroyed. -*/ -PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtrAndDesc( - void *cobj, void *desc, void (*destruct)(void*,void*)); - -/* Retrieve a pointer to a C object from a PyCObject. */ -PyAPI_FUNC(void *) PyCObject_AsVoidPtr(PyObject *); - -/* Retrieve a pointer to a description object from a PyCObject. */ -PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject *); - -/* Import a pointer to a C object from a module using a PyCObject. */ -PyAPI_FUNC(void *) PyCObject_Import(char *module_name, char *cobject_name); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_COBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/codecs.h b/SDKs/XPlatform/Cypython-2.3.3/include/codecs.h deleted file mode 100644 index e61fc0bd..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/codecs.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef Py_CODECREGISTRY_H -#define Py_CODECREGISTRY_H -#ifdef __cplusplus -extern "C" { -#endif - -/* ------------------------------------------------------------------------ - - Python Codec Registry and support functions - - -Written by Marc-Andre Lemburg (mal@lemburg.com). - -Copyright (c) Corporation for National Research Initiatives. - - ------------------------------------------------------------------------ */ - -/* Register a new codec search function. - - As side effect, this tries to load the encodings package, if not - yet done, to make sure that it is always first in the list of - search functions. - - The search_function's refcount is incremented by this function. */ - -PyAPI_FUNC(int) PyCodec_Register( - PyObject *search_function - ); - -/* Codec register lookup API. - - Looks up the given encoding and returns a tuple (encoder, decoder, - stream reader, stream writer) of functions which implement the - different aspects of processing the encoding. - - The encoding string is looked up converted to all lower-case - characters. This makes encodings looked up through this mechanism - effectively case-insensitive. - - If no codec is found, a KeyError is set and NULL returned. - - As side effect, this tries to load the encodings package, if not - yet done. This is part of the lazy load strategy for the encodings - package. - - */ - -PyAPI_FUNC(PyObject *) _PyCodec_Lookup( - const char *encoding - ); - -/* Generic codec based encoding API. - - object is passed through the encoder function found for the given - encoding using the error handling method defined by errors. errors - may be NULL to use the default method defined for the codec. - - Raises a LookupError in case no encoder can be found. - - */ - -PyAPI_FUNC(PyObject *) PyCodec_Encode( - PyObject *object, - const char *encoding, - const char *errors - ); - -/* Generic codec based decoding API. - - object is passed through the decoder function found for the given - encoding using the error handling method defined by errors. errors - may be NULL to use the default method defined for the codec. - - Raises a LookupError in case no encoder can be found. - - */ - -PyAPI_FUNC(PyObject *) PyCodec_Decode( - PyObject *object, - const char *encoding, - const char *errors - ); - -/* --- Codec Lookup APIs -------------------------------------------------- - - All APIs return a codec object with incremented refcount and are - based on _PyCodec_Lookup(). The same comments w/r to the encoding - name also apply to these APIs. - -*/ - -/* Get an encoder function for the given encoding. */ - -PyAPI_FUNC(PyObject *) PyCodec_Encoder( - const char *encoding - ); - -/* Get a decoder function for the given encoding. */ - -PyAPI_FUNC(PyObject *) PyCodec_Decoder( - const char *encoding - ); - -/* Get a StreamReader factory function for the given encoding. */ - -PyAPI_FUNC(PyObject *) PyCodec_StreamReader( - const char *encoding, - PyObject *stream, - const char *errors - ); - -/* Get a StreamWriter factory function for the given encoding. */ - -PyAPI_FUNC(PyObject *) PyCodec_StreamWriter( - const char *encoding, - PyObject *stream, - const char *errors - ); - -/* Unicode encoding error handling callback registry API */ - -/* Register the error handling callback function error under the name - name. This function will be called by the codec when it encounters - unencodable characters/undecodable bytes and doesn't know the - callback name, when name is specified as the error parameter - in the call to the encode/decode function. - Return 0 on success, -1 on error */ -PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error); - -/* Lookup the error handling callback function registered under the - name error. As a special case NULL can be passed, in which case - the error handling callback for "strict" will be returned. */ -PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name); - -/* raise exc as an exception */ -PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc); - -/* ignore the unicode error, skipping the faulty input */ -PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc); - -/* replace the unicode error with ? or U+FFFD */ -PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc); - -/* replace the unicode encode error with XML character references */ -PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc); - -/* replace the unicode encode error with backslash escapes (\x, \u and \U) */ -PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_CODECREGISTRY_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/compile.h b/SDKs/XPlatform/Cypython-2.3.3/include/compile.h deleted file mode 100644 index e9b44efa..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/compile.h +++ /dev/null @@ -1,92 +0,0 @@ - -/* Definitions for bytecode */ - -#ifndef Py_COMPILE_H -#define Py_COMPILE_H -#ifdef __cplusplus -extern "C" { -#endif - -/* Bytecode object */ -typedef struct { - PyObject_HEAD - int co_argcount; /* #arguments, except *args */ - int co_nlocals; /* #local variables */ - int co_stacksize; /* #entries needed for evaluation stack */ - int co_flags; /* CO_..., see below */ - PyObject *co_code; /* instruction opcodes */ - PyObject *co_consts; /* list (constants used) */ - PyObject *co_names; /* list of strings (names used) */ - PyObject *co_varnames; /* tuple of strings (local variable names) */ - PyObject *co_freevars; /* tuple of strings (free variable names) */ - PyObject *co_cellvars; /* tuple of strings (cell variable names) */ - /* The rest doesn't count for hash/cmp */ - PyObject *co_filename; /* string (where it was loaded from) */ - PyObject *co_name; /* string (name, for reference) */ - int co_firstlineno; /* first source line number */ - PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) */ -} PyCodeObject; - -/* Masks for co_flags above */ -#define CO_OPTIMIZED 0x0001 -#define CO_NEWLOCALS 0x0002 -#define CO_VARARGS 0x0004 -#define CO_VARKEYWORDS 0x0008 -#define CO_NESTED 0x0010 -#define CO_GENERATOR 0x0020 -/* The CO_NOFREE flag is set if there are no free or cell variables. - This information is redundant, but it allows a single flag test - to determine whether there is any extra work to be done when the - call frame it setup. -*/ -#define CO_NOFREE 0x0040 -/* XXX Temporary hack. Until generators are a permanent part of the - language, we need a way for a code object to record that generators - were *possible* when it was compiled. This is so code dynamically - compiled *by* a code object knows whether to allow yield stmts. In - effect, this passes on the "from __future__ import generators" state - in effect when the code block was compiled. */ -#define CO_GENERATOR_ALLOWED 0x1000 /* no longer used in an essential way */ -#define CO_FUTURE_DIVISION 0x2000 - -PyAPI_DATA(PyTypeObject) PyCode_Type; - -#define PyCode_Check(op) ((op)->ob_type == &PyCode_Type) -#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars)) - -#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */ - -/* Public interface */ -struct _node; /* Declare the existence of this type */ -PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *); -PyAPI_FUNC(PyCodeObject *) PyCode_New( - int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *, - PyObject *, PyObject *, PyObject *, PyObject *, int, PyObject *); - /* same as struct above */ -PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int); - -/* Future feature support */ - -typedef struct { - int ff_found_docstring; - int ff_last_lineno; - int ff_features; -} PyFutureFeatures; - -PyAPI_FUNC(PyFutureFeatures *) PyNode_Future(struct _node *, const char *); -PyAPI_FUNC(PyCodeObject *) PyNode_CompileFlags(struct _node *, const char *, - PyCompilerFlags *); - -#define FUTURE_NESTED_SCOPES "nested_scopes" -#define FUTURE_GENERATORS "generators" -#define FUTURE_DIVISION "division" - -/* for internal use only */ -#define _PyCode_GETCODEPTR(co, pp) \ - ((*(co)->co_code->ob_type->tp_as_buffer->bf_getreadbuffer) \ - ((co)->co_code, 0, (void **)(pp))) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_COMPILE_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/complexobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/complexobject.h deleted file mode 100644 index 68216c45..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/complexobject.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Complex number structure */ - -#ifndef Py_COMPLEXOBJECT_H -#define Py_COMPLEXOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - double real; - double imag; -} Py_complex; - -/* Operations on complex numbers from complexmodule.c */ - -#define c_sum _Py_c_sum -#define c_diff _Py_c_diff -#define c_neg _Py_c_neg -#define c_prod _Py_c_prod -#define c_quot _Py_c_quot -#define c_pow _Py_c_pow - -PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex); -PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex); -PyAPI_FUNC(Py_complex) c_neg(Py_complex); -PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex); -PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex); -PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex); - - -/* Complex object interface */ - -/* -PyComplexObject represents a complex number with double-precision -real and imaginary parts. -*/ - -typedef struct { - PyObject_HEAD - Py_complex cval; -} PyComplexObject; - -PyAPI_DATA(PyTypeObject) PyComplex_Type; - -#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type) -#define PyComplex_CheckExact(op) ((op)->ob_type == &PyComplex_Type) - -PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex); -PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag); - -PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op); -PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op); -PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_COMPLEXOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/datetime.h b/SDKs/XPlatform/Cypython-2.3.3/include/datetime.h deleted file mode 100644 index df814751..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/datetime.h +++ /dev/null @@ -1,150 +0,0 @@ -/* datetime.h - */ - -#ifndef DATETIME_H -#define DATETIME_H - -/* Fields are packed into successive bytes, each viewed as unsigned and - * big-endian, unless otherwise noted: - * - * byte offset - * 0 year 2 bytes, 1-9999 - * 2 month 1 byte, 1-12 - * 3 day 1 byte, 1-31 - * 4 hour 1 byte, 0-23 - * 5 minute 1 byte, 0-59 - * 6 second 1 byte, 0-59 - * 7 usecond 3 bytes, 0-999999 - * 10 - */ - -/* # of bytes for year, month, and day. */ -#define _PyDateTime_DATE_DATASIZE 4 - -/* # of bytes for hour, minute, second, and usecond. */ -#define _PyDateTime_TIME_DATASIZE 6 - -/* # of bytes for year, month, day, hour, minute, second, and usecond. */ -#define _PyDateTime_DATETIME_DATASIZE 10 - - -typedef struct -{ - PyObject_HEAD - long hashcode; /* -1 when unknown */ - int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */ - int seconds; /* 0 <= seconds < 24*3600 is invariant */ - int microseconds; /* 0 <= microseconds < 1000000 is invariant */ -} PyDateTime_Delta; - -typedef struct -{ - PyObject_HEAD /* a pure abstract base clase */ -} PyDateTime_TZInfo; - - -/* The datetime and time types have hashcodes, and an optional tzinfo member, - * present if and only if hastzinfo is true. - */ -#define _PyTZINFO_HEAD \ - PyObject_HEAD \ - long hashcode; \ - char hastzinfo; /* boolean flag */ - -/* No _PyDateTime_BaseTZInfo is allocated; it's just to have something - * convenient to cast to, when getting at the hastzinfo member of objects - * starting with _PyTZINFO_HEAD. - */ -typedef struct -{ - _PyTZINFO_HEAD -} _PyDateTime_BaseTZInfo; - -/* All time objects are of PyDateTime_TimeType, but that can be allocated - * in two ways, with or without a tzinfo member. Without is the same as - * tzinfo == None, but consumes less memory. _PyDateTime_BaseTime is an - * internal struct used to allocate the right amount of space for the - * "without" case. - */ -#define _PyDateTime_TIMEHEAD \ - _PyTZINFO_HEAD \ - unsigned char data[_PyDateTime_TIME_DATASIZE]; - -typedef struct -{ - _PyDateTime_TIMEHEAD -} _PyDateTime_BaseTime; /* hastzinfo false */ - -typedef struct -{ - _PyDateTime_TIMEHEAD - PyObject *tzinfo; -} PyDateTime_Time; /* hastzinfo true */ - - -/* All datetime objects are of PyDateTime_DateTimeType, but that can be - * allocated in two ways too, just like for time objects above. In addition, - * the plain date type is a base class for datetime, so it must also have - * a hastzinfo member (although it's unused there). - */ -typedef struct -{ - _PyTZINFO_HEAD - unsigned char data[_PyDateTime_DATE_DATASIZE]; -} PyDateTime_Date; - -#define _PyDateTime_DATETIMEHEAD \ - _PyTZINFO_HEAD \ - unsigned char data[_PyDateTime_DATETIME_DATASIZE]; - -typedef struct -{ - _PyDateTime_DATETIMEHEAD -} _PyDateTime_BaseDateTime; /* hastzinfo false */ - -typedef struct -{ - _PyDateTime_DATETIMEHEAD - PyObject *tzinfo; -} PyDateTime_DateTime; /* hastzinfo true */ - - -/* Apply for date and datetime instances. */ -#define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)o)->data[0] << 8) | \ - ((PyDateTime_Date*)o)->data[1]) -#define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)o)->data[2]) -#define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)o)->data[3]) - -#define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)o)->data[4]) -#define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)o)->data[5]) -#define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)o)->data[6]) -#define PyDateTime_DATE_GET_MICROSECOND(o) \ - ((((PyDateTime_DateTime*)o)->data[7] << 16) | \ - (((PyDateTime_DateTime*)o)->data[8] << 8) | \ - ((PyDateTime_DateTime*)o)->data[9]) - -/* Apply for time instances. */ -#define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)o)->data[0]) -#define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)o)->data[1]) -#define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)o)->data[2]) -#define PyDateTime_TIME_GET_MICROSECOND(o) \ - ((((PyDateTime_Time*)o)->data[3] << 16) | \ - (((PyDateTime_Time*)o)->data[4] << 8) | \ - ((PyDateTime_Time*)o)->data[5]) - -#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType) -#define PyDate_CheckExact(op) ((op)->ob_type == &PyDateTime_DateType) - -#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType) -#define PyDateTime_CheckExact(op) ((op)->ob_type == &PyDateTime_DateTimeType) - -#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType) -#define PyTime_CheckExact(op) ((op)->ob_type == &PyDateTime_TimeType) - -#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType) -#define PyDelta_CheckExact(op) ((op)->ob_type == &PyDateTime_DeltaType) - -#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType) -#define PyTZInfo_CheckExact(op) ((op)->ob_type == &PyDateTime_TZInfoType) - -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/descrobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/descrobject.h deleted file mode 100644 index ae0503ec..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/descrobject.h +++ /dev/null @@ -1,91 +0,0 @@ -/* Descriptors */ -#ifndef Py_DESCROBJECT_H -#define Py_DESCROBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef PyObject *(*getter)(PyObject *, void *); -typedef int (*setter)(PyObject *, PyObject *, void *); - -typedef struct PyGetSetDef { - char *name; - getter get; - setter set; - char *doc; - void *closure; -} PyGetSetDef; - -typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args, - void *wrapped); - -typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args, - void *wrapped, PyObject *kwds); - -struct wrapperbase { - char *name; - int offset; - void *function; - wrapperfunc wrapper; - char *doc; - int flags; - PyObject *name_strobj; -}; - -/* Flags for above struct */ -#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */ - -/* Various kinds of descriptor objects */ - -#define PyDescr_COMMON \ - PyObject_HEAD \ - PyTypeObject *d_type; \ - PyObject *d_name - -typedef struct { - PyDescr_COMMON; -} PyDescrObject; - -typedef struct { - PyDescr_COMMON; - PyMethodDef *d_method; -} PyMethodDescrObject; - -typedef struct { - PyDescr_COMMON; - struct PyMemberDef *d_member; -} PyMemberDescrObject; - -typedef struct { - PyDescr_COMMON; - PyGetSetDef *d_getset; -} PyGetSetDescrObject; - -typedef struct { - PyDescr_COMMON; - struct wrapperbase *d_base; - void *d_wrapped; /* This can be any function pointer */ -} PyWrapperDescrObject; - -PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type; - -PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *); -PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *); -PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, - struct PyMemberDef *); -PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, - struct PyGetSetDef *); -PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *, - struct wrapperbase *, void *); -#define PyDescr_IsData(d) ((d)->ob_type->tp_descr_set != NULL) - -PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *); -PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *); - - -PyAPI_DATA(PyTypeObject) PyProperty_Type; -#ifdef __cplusplus -} -#endif -#endif /* !Py_DESCROBJECT_H */ - diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/dictobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/dictobject.h deleted file mode 100644 index 85b77314..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/dictobject.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef Py_DICTOBJECT_H -#define Py_DICTOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Dictionary object type -- mapping from hashable object to object */ - -/* The distribution includes a separate file, Objects/dictnotes.txt, - describing explorations into dictionary design and optimization. - It covers typical dictionary use patterns, the parameters for - tuning dictionaries, and several ideas for possible optimizations. -*/ - -/* -There are three kinds of slots in the table: - -1. Unused. me_key == me_value == NULL - Does not hold an active (key, value) pair now and never did. Unused can - transition to Active upon key insertion. This is the only case in which - me_key is NULL, and is each slot's initial state. - -2. Active. me_key != NULL and me_key != dummy and me_value != NULL - Holds an active (key, value) pair. Active can transition to Dummy upon - key deletion. This is the only case in which me_value != NULL. - -3. Dummy. me_key == dummy and me_value == NULL - Previously held an active (key, value) pair, but that was deleted and an - active pair has not yet overwritten the slot. Dummy can transition to - Active upon key insertion. Dummy slots cannot be made Unused again - (cannot have me_key set to NULL), else the probe sequence in case of - collision would have no way to know they were once active. - -Note: .popitem() abuses the me_hash field of an Unused or Dummy slot to -hold a search finger. The me_hash field of Unused or Dummy slots has no -meaning otherwise. -*/ - -/* PyDict_MINSIZE is the minimum size of a dictionary. This many slots are - * allocated directly in the dict object (in the ma_smalltable member). - * It must be a power of 2, and at least 4. 8 allows dicts with no more - * than 5 active entries to live in ma_smalltable (and so avoid an - * additional malloc); instrumentation suggested this suffices for the - * majority of dicts (consisting mostly of usually-small instance dicts and - * usually-small dicts created to pass keyword arguments). - */ -#define PyDict_MINSIZE 8 - -typedef struct { - long me_hash; /* cached hash code of me_key */ - PyObject *me_key; - PyObject *me_value; -} PyDictEntry; - -/* -To ensure the lookup algorithm terminates, there must be at least one Unused -slot (NULL key) in the table. -The value ma_fill is the number of non-NULL keys (sum of Active and Dummy); -ma_used is the number of non-NULL, non-dummy keys (== the number of non-NULL -values == the number of Active items). -To avoid slowing down lookups on a near-full table, we resize the table when -it's two-thirds full. -*/ -typedef struct _dictobject PyDictObject; -struct _dictobject { - PyObject_HEAD - int ma_fill; /* # Active + # Dummy */ - int ma_used; /* # Active */ - - /* The table contains ma_mask + 1 slots, and that's a power of 2. - * We store the mask instead of the size because the mask is more - * frequently needed. - */ - int ma_mask; - - /* ma_table points to ma_smalltable for small tables, else to - * additional malloc'ed memory. ma_table is never NULL! This rule - * saves repeated runtime null-tests in the workhorse getitem and - * setitem calls. - */ - PyDictEntry *ma_table; - PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, long hash); - PyDictEntry ma_smalltable[PyDict_MINSIZE]; -}; - -PyAPI_DATA(PyTypeObject) PyDict_Type; - -#define PyDict_Check(op) PyObject_TypeCheck(op, &PyDict_Type) - -PyAPI_FUNC(PyObject *) PyDict_New(void); -PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key); -PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item); -PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key); -PyAPI_FUNC(void) PyDict_Clear(PyObject *mp); -PyAPI_FUNC(int) PyDict_Next( - PyObject *mp, int *pos, PyObject **key, PyObject **value); -PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp); -PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp); -PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp); -PyAPI_FUNC(int) PyDict_Size(PyObject *mp); -PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp); - -/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */ -PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other); - -/* PyDict_Merge updates/merges from a mapping object (an object that - supports PyMapping_Keys() and PyObject_GetItem()). If override is true, - the last occurrence of a key wins, else the first. The Python - dict.update(other) is equivalent to PyDict_Merge(dict, other, 1). -*/ -PyAPI_FUNC(int) PyDict_Merge(PyObject *mp, - PyObject *other, - int override); - -/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing - iterable objects of length 2. If override is true, the last occurrence - of a key wins, else the first. The Python dict constructor dict(seq2) - is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1). -*/ -PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d, - PyObject *seq2, - int override); - -PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key); -PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item); -PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_DICTOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/enumobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/enumobject.h deleted file mode 100644 index 4a48b96d..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/enumobject.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef Py_ENUMOBJECT_H -#define Py_ENUMOBJECT_H - -/* Enumerate Object */ - -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(PyTypeObject) PyEnum_Type; - -#ifdef __cplusplus -} -#endif - -#endif /* !Py_ENUMOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/errcode.h b/SDKs/XPlatform/Cypython-2.3.3/include/errcode.h deleted file mode 100644 index a61ebb54..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/errcode.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef Py_ERRCODE_H -#define Py_ERRCODE_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Error codes passed around between file input, tokenizer, parser and - interpreter. This is necessary so we can turn them into Python - exceptions at a higher level. Note that some errors have a - slightly different meaning when passed from the tokenizer to the - parser than when passed from the parser to the interpreter; e.g. - the parser only returns E_EOF when it hits EOF immediately, and it - never returns E_OK. */ - -#define E_OK 10 /* No error */ -#define E_EOF 11 /* End Of File */ -#define E_INTR 12 /* Interrupted */ -#define E_TOKEN 13 /* Bad token */ -#define E_SYNTAX 14 /* Syntax error */ -#define E_NOMEM 15 /* Ran out of memory */ -#define E_DONE 16 /* Parsing complete */ -#define E_ERROR 17 /* Execution error */ -#define E_TABSPACE 18 /* Inconsistent mixing of tabs and spaces */ -#define E_OVERFLOW 19 /* Node had too many children */ -#define E_TOODEEP 20 /* Too many indentation levels */ -#define E_DEDENT 21 /* No matching outer block for dedent */ -#define E_DECODE 22 /* Error in decoding into Unicode */ -#define E_EOFS 23 /* EOF in triple-quoted string */ -#define E_EOLS 24 /* EOL in single-quoted string */ - -#ifdef __cplusplus -} -#endif -#endif /* !Py_ERRCODE_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/eval.h b/SDKs/XPlatform/Cypython-2.3.3/include/eval.h deleted file mode 100644 index fe1d47ae..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/eval.h +++ /dev/null @@ -1,25 +0,0 @@ - -/* Interface to execute compiled code */ - -#ifndef Py_EVAL_H -#define Py_EVAL_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyCodeObject *, PyObject *, PyObject *); - -PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyCodeObject *co, - PyObject *globals, - PyObject *locals, - PyObject **args, int argc, - PyObject **kwds, int kwdc, - PyObject **defs, int defc, - PyObject *closure); - -PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_EVAL_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/fileobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/fileobject.h deleted file mode 100644 index 9c78c6e7..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/fileobject.h +++ /dev/null @@ -1,70 +0,0 @@ - -/* File object interface */ - -#ifndef Py_FILEOBJECT_H -#define Py_FILEOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - PyObject_HEAD - FILE *f_fp; - PyObject *f_name; - PyObject *f_mode; - int (*f_close)(FILE *); - int f_softspace; /* Flag used by 'print' command */ - int f_binary; /* Flag which indicates whether the file is - open in binary (1) or text (0) mode */ - char* f_buf; /* Allocated readahead buffer */ - char* f_bufend; /* Points after last occupied position */ - char* f_bufptr; /* Current buffer position */ - char *f_setbuf; /* Buffer for setbuf(3) and setvbuf(3) */ -#ifdef WITH_UNIVERSAL_NEWLINES - int f_univ_newline; /* Handle any newline convention */ - int f_newlinetypes; /* Types of newlines seen */ - int f_skipnextlf; /* Skip next \n */ -#endif - PyObject *f_encoding; -} PyFileObject; - -PyAPI_DATA(PyTypeObject) PyFile_Type; - -#define PyFile_Check(op) PyObject_TypeCheck(op, &PyFile_Type) -#define PyFile_CheckExact(op) ((op)->ob_type == &PyFile_Type) - -PyAPI_FUNC(PyObject *) PyFile_FromString(char *, char *); -PyAPI_FUNC(void) PyFile_SetBufSize(PyObject *, int); -PyAPI_FUNC(int) PyFile_SetEncoding(PyObject *, const char *); -PyAPI_FUNC(PyObject *) PyFile_FromFile(FILE *, char *, char *, - int (*)(FILE *)); -PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject *); -PyAPI_FUNC(PyObject *) PyFile_Name(PyObject *); -PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int); -PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int); -PyAPI_FUNC(int) PyFile_SoftSpace(PyObject *, int); -PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *); -PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *); - -/* The default encoding used by the platform file system APIs - If non-NULL, this is different than the default encoding for strings -*/ -PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding; - -#ifdef WITH_UNIVERSAL_NEWLINES -/* Routines to replace fread() and fgets() which accept any of \r, \n - or \r\n as line terminators. -*/ -#define PY_STDIOTEXTMODE "b" -char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *); -size_t Py_UniversalNewlineFread(char *, size_t, FILE *, PyObject *); -#else -#define PY_STDIOTEXTMODE "" -#define Py_UniversalNewlineFgets(buf, len, fp, obj) fgets((buf), (len), (fp)) -#define Py_UniversalNewlineFread(buf, len, fp, obj) \ - fread((buf), 1, (len), (fp)) -#endif /* WITH_UNIVERSAL_NEWLINES */ -#ifdef __cplusplus -} -#endif -#endif /* !Py_FILEOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/floatobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/floatobject.h deleted file mode 100644 index a0207976..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/floatobject.h +++ /dev/null @@ -1,95 +0,0 @@ - -/* Float object interface */ - -/* -PyFloatObject represents a (double precision) floating point number. -*/ - -#ifndef Py_FLOATOBJECT_H -#define Py_FLOATOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - PyObject_HEAD - double ob_fval; -} PyFloatObject; - -PyAPI_DATA(PyTypeObject) PyFloat_Type; - -#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type) -#define PyFloat_CheckExact(op) ((op)->ob_type == &PyFloat_Type) - -/* Return Python float from string PyObject. Second argument ignored on - input, and, if non-NULL, NULL is stored into *junk (this tried to serve a - purpose once but can't be made to work as intended). */ -PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*, char** junk); - -/* Return Python float from C double. */ -PyAPI_FUNC(PyObject *) PyFloat_FromDouble(double); - -/* Extract C double from Python float. The macro version trades safety for - speed. */ -PyAPI_FUNC(double) PyFloat_AsDouble(PyObject *); -#define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval) - -/* Write repr(v) into the char buffer argument, followed by null byte. The - buffer must be "big enough"; >= 100 is very safe. - PyFloat_AsReprString(buf, x) strives to print enough digits so that - PyFloat_FromString(buf) then reproduces x exactly. */ -PyAPI_FUNC(void) PyFloat_AsReprString(char*, PyFloatObject *v); - -/* Write str(v) into the char buffer argument, followed by null byte. The - buffer must be "big enough"; >= 100 is very safe. Note that it's - unusual to be able to get back the float you started with from - PyFloat_AsString's result -- use PyFloat_AsReprString() if you want to - preserve precision across conversions. */ -PyAPI_FUNC(void) PyFloat_AsString(char*, PyFloatObject *v); - -/* _PyFloat_{Pack,Unpack}{4,8} - * - * The struct and pickle (at least) modules need an efficient platform- - * independent way to store floating-point values as byte strings. - * The Pack routines produce a string from a C double, and the Unpack - * routines produce a C double from such a string. The suffix (4 or 8) - * specifies the number of bytes in the string. - * - * Excepting NaNs and infinities (which aren't handled correctly), the 4- - * byte format is identical to the IEEE-754 single precision format, and - * the 8-byte format to the IEEE-754 double precision format. On non- - * IEEE platforms with more precision, or larger dynamic range, than - * 754 supports, not all values can be packed; on non-IEEE platforms with - * less precision, or smaller dynamic range, not all values can be - * unpacked. What happens in such cases is partly accidental (alas). - */ - -/* The pack routines write 4 or 8 bytes, starting at p. le is a bool - * argument, true if you want the string in little-endian format (exponent - * last, at p+3 or p+7), false if you want big-endian format (exponent - * first, at p). - * Return value: 0 if all is OK, -1 if error (and an exception is - * set, most likely OverflowError). - * Bug: What this does is undefined if x is a NaN or infinity. - * Bug: -0.0 and +0.0 produce the same string. - */ -PyAPI_FUNC(int) _PyFloat_Pack4(double x, unsigned char *p, int le); -PyAPI_FUNC(int) _PyFloat_Pack8(double x, unsigned char *p, int le); - -/* The unpack routines read 4 or 8 bytes, starting at p. le is a bool - * argument, true if the string is in little-endian format (exponent - * last, at p+3 or p+7), false if big-endian (exponent first, at p). - * Return value: The unpacked double. On error, this is -1.0 and - * PyErr_Occurred() is true (and an exception is set, most likely - * OverflowError). - * Bug: What this does is undefined if the string represents a NaN or - * infinity. - */ -PyAPI_FUNC(double) _PyFloat_Unpack4(const unsigned char *p, int le); -PyAPI_FUNC(double) _PyFloat_Unpack8(const unsigned char *p, int le); - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_FLOATOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/frameobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/frameobject.h deleted file mode 100644 index d25393dc..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/frameobject.h +++ /dev/null @@ -1,76 +0,0 @@ - -/* Frame object interface */ - -#ifndef Py_FRAMEOBJECT_H -#define Py_FRAMEOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - int b_type; /* what kind of block this is */ - int b_handler; /* where to jump to find handler */ - int b_level; /* value stack level to pop to */ -} PyTryBlock; - -typedef struct _frame { - PyObject_VAR_HEAD - struct _frame *f_back; /* previous frame, or NULL */ - PyCodeObject *f_code; /* code segment */ - PyObject *f_builtins; /* builtin symbol table (PyDictObject) */ - PyObject *f_globals; /* global symbol table (PyDictObject) */ - PyObject *f_locals; /* local symbol table (PyDictObject) */ - PyObject **f_valuestack; /* points after the last local */ - /* Next free slot in f_valuestack. Frame creation sets to f_valuestack. - Frame evaluation usually NULLs it, but a frame that yields sets it - to the current stack top. */ - PyObject **f_stacktop; - PyObject *f_trace; /* Trace function */ - PyObject *f_exc_type, *f_exc_value, *f_exc_traceback; - PyThreadState *f_tstate; - int f_lasti; /* Last instruction if called */ - /* As of 2.3 f_lineno is only valid when tracing is active (i.e. when - f_trace is set) -- at other times use PyCode_Addr2Line instead. */ - int f_lineno; /* Current line number */ - int f_restricted; /* Flag set if restricted operations - in this scope */ - int f_iblock; /* index in f_blockstack */ - PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ - int f_nlocals; /* number of locals */ - int f_ncells; - int f_nfreevars; - int f_stacksize; /* size of value stack */ - PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ -} PyFrameObject; - - -/* Standard object interface */ - -PyAPI_DATA(PyTypeObject) PyFrame_Type; - -#define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type) - -PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *, - PyObject *, PyObject *); - - -/* The rest of the interface is specific for frame objects */ - -/* Block management functions */ - -PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int); -PyAPI_FUNC(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *); - -/* Extend the value stack */ - -PyAPI_FUNC(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int); - -/* Conversions between "fast locals" and locals in dictionary */ - -PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int); -PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_FRAMEOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/funcobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/funcobject.h deleted file mode 100644 index 4927da59..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/funcobject.h +++ /dev/null @@ -1,59 +0,0 @@ - -/* Function object interface */ - -#ifndef Py_FUNCOBJECT_H -#define Py_FUNCOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - PyObject_HEAD - PyObject *func_code; - PyObject *func_globals; - PyObject *func_defaults; - PyObject *func_closure; - PyObject *func_doc; - PyObject *func_name; - PyObject *func_dict; - PyObject *func_weakreflist; - PyObject *func_module; -} PyFunctionObject; - -PyAPI_DATA(PyTypeObject) PyFunction_Type; - -#define PyFunction_Check(op) ((op)->ob_type == &PyFunction_Type) - -PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *); -PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *); -PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *); -PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *); -PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *); -PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *); - -/* Macros for direct access to these values. Type checks are *not* - done, so use with care. */ -#define PyFunction_GET_CODE(func) \ - (((PyFunctionObject *)func) -> func_code) -#define PyFunction_GET_GLOBALS(func) \ - (((PyFunctionObject *)func) -> func_globals) -#define PyFunction_GET_MODULE(func) \ - (((PyFunctionObject *)func) -> func_module) -#define PyFunction_GET_DEFAULTS(func) \ - (((PyFunctionObject *)func) -> func_defaults) -#define PyFunction_GET_CLOSURE(func) \ - (((PyFunctionObject *)func) -> func_closure) - -/* The classmethod and staticmethod types lives here, too */ -PyAPI_DATA(PyTypeObject) PyClassMethod_Type; -PyAPI_DATA(PyTypeObject) PyStaticMethod_Type; - -PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *); -PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_FUNCOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/graminit.h b/SDKs/XPlatform/Cypython-2.3.3/include/graminit.h deleted file mode 100644 index e0d2cb6c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/graminit.h +++ /dev/null @@ -1,68 +0,0 @@ -#define single_input 256 -#define file_input 257 -#define eval_input 258 -#define funcdef 259 -#define parameters 260 -#define varargslist 261 -#define fpdef 262 -#define fplist 263 -#define stmt 264 -#define simple_stmt 265 -#define small_stmt 266 -#define expr_stmt 267 -#define augassign 268 -#define print_stmt 269 -#define del_stmt 270 -#define pass_stmt 271 -#define flow_stmt 272 -#define break_stmt 273 -#define continue_stmt 274 -#define return_stmt 275 -#define yield_stmt 276 -#define raise_stmt 277 -#define import_stmt 278 -#define import_as_name 279 -#define dotted_as_name 280 -#define dotted_name 281 -#define global_stmt 282 -#define exec_stmt 283 -#define assert_stmt 284 -#define compound_stmt 285 -#define if_stmt 286 -#define while_stmt 287 -#define for_stmt 288 -#define try_stmt 289 -#define except_clause 290 -#define suite 291 -#define test 292 -#define and_test 293 -#define not_test 294 -#define comparison 295 -#define comp_op 296 -#define expr 297 -#define xor_expr 298 -#define and_expr 299 -#define shift_expr 300 -#define arith_expr 301 -#define term 302 -#define factor 303 -#define power 304 -#define atom 305 -#define listmaker 306 -#define lambdef 307 -#define trailer 308 -#define subscriptlist 309 -#define subscript 310 -#define sliceop 311 -#define exprlist 312 -#define testlist 313 -#define testlist_safe 314 -#define dictmaker 315 -#define classdef 316 -#define arglist 317 -#define argument 318 -#define list_iter 319 -#define list_for 320 -#define list_if 321 -#define testlist1 322 -#define encoding_decl 323 diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/grammar.h b/SDKs/XPlatform/Cypython-2.3.3/include/grammar.h deleted file mode 100644 index 369d4a34..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/grammar.h +++ /dev/null @@ -1,93 +0,0 @@ - -/* Grammar interface */ - -#ifndef Py_GRAMMAR_H -#define Py_GRAMMAR_H -#ifdef __cplusplus -extern "C" { -#endif - -#include "bitset.h" /* Sigh... */ - -/* A label of an arc */ - -typedef struct { - int lb_type; - char *lb_str; -} label; - -#define EMPTY 0 /* Label number 0 is by definition the empty label */ - -/* A list of labels */ - -typedef struct { - int ll_nlabels; - label *ll_label; -} labellist; - -/* An arc from one state to another */ - -typedef struct { - short a_lbl; /* Label of this arc */ - short a_arrow; /* State where this arc goes to */ -} arc; - -/* A state in a DFA */ - -typedef struct { - int s_narcs; - arc *s_arc; /* Array of arcs */ - - /* Optional accelerators */ - int s_lower; /* Lowest label index */ - int s_upper; /* Highest label index */ - int *s_accel; /* Accelerator */ - int s_accept; /* Nonzero for accepting state */ -} state; - -/* A DFA */ - -typedef struct { - int d_type; /* Non-terminal this represents */ - char *d_name; /* For printing */ - int d_initial; /* Initial state */ - int d_nstates; - state *d_state; /* Array of states */ - bitset d_first; -} dfa; - -/* A grammar */ - -typedef struct { - int g_ndfas; - dfa *g_dfa; /* Array of DFAs */ - labellist g_ll; - int g_start; /* Start symbol of the grammar */ - int g_accel; /* Set if accelerators present */ -} grammar; - -/* FUNCTIONS */ - -grammar *newgrammar(int start); -dfa *adddfa(grammar *g, int type, char *name); -int addstate(dfa *d); -void addarc(dfa *d, int from, int to, int lbl); -dfa *PyGrammar_FindDFA(grammar *g, int type); - -int addlabel(labellist *ll, int type, char *str); -int findlabel(labellist *ll, int type, char *str); -char *PyGrammar_LabelRepr(label *lb); -void translatelabels(grammar *g); - -void addfirstsets(grammar *g); - -void PyGrammar_AddAccelerators(grammar *g); -void PyGrammar_RemoveAccelerators(grammar *); - -void printgrammar(grammar *g, FILE *fp); -void printnonterminals(grammar *g, FILE *fp); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_GRAMMAR_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/import.h b/SDKs/XPlatform/Cypython-2.3.3/include/import.h deleted file mode 100644 index 27bbf68c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/import.h +++ /dev/null @@ -1,51 +0,0 @@ - -/* Module definition and import interface */ - -#ifndef Py_IMPORT_H -#define Py_IMPORT_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(long) PyImport_GetMagicNumber(void); -PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(char *name, PyObject *co); -PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx( - char *name, PyObject *co, char *pathname); -PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void); -PyAPI_FUNC(PyObject *) PyImport_AddModule(char *name); -PyAPI_FUNC(PyObject *) PyImport_ImportModule(char *name); -PyAPI_FUNC(PyObject *) PyImport_ImportModuleEx( - char *name, PyObject *globals, PyObject *locals, PyObject *fromlist); -PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name); -PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m); -PyAPI_FUNC(void) PyImport_Cleanup(void); -PyAPI_FUNC(int) PyImport_ImportFrozenModule(char *); - -PyAPI_FUNC(PyObject *)_PyImport_FindExtension(char *, char *); -PyAPI_FUNC(PyObject *)_PyImport_FixupExtension(char *, char *); - -struct _inittab { - char *name; - void (*initfunc)(void); -}; - -PyAPI_DATA(struct _inittab *) PyImport_Inittab; - -PyAPI_FUNC(int) PyImport_AppendInittab(char *name, void (*initfunc)(void)); -PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab); - -struct _frozen { - char *name; - unsigned char *code; - int size; -}; - -/* Embedding apps may change this pointer to point to their favorite - collection of frozen modules: */ - -PyAPI_DATA(struct _frozen *) PyImport_FrozenModules; - -#ifdef __cplusplus -} -#endif -#endif /* !Py_IMPORT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/intobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/intobject.h deleted file mode 100644 index 2551b39d..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/intobject.h +++ /dev/null @@ -1,61 +0,0 @@ - -/* Integer object interface */ - -/* -PyIntObject represents a (long) integer. This is an immutable object; -an integer cannot change its value after creation. - -There are functions to create new integer objects, to test an object -for integer-ness, and to get the integer value. The latter functions -returns -1 and sets errno to EBADF if the object is not an PyIntObject. -None of the functions should be applied to nil objects. - -The type PyIntObject is (unfortunately) exposed here so we can declare -_Py_TrueStruct and _Py_ZeroStruct below; don't use this. -*/ - -#ifndef Py_INTOBJECT_H -#define Py_INTOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - PyObject_HEAD - long ob_ival; -} PyIntObject; - -PyAPI_DATA(PyTypeObject) PyInt_Type; - -#define PyInt_Check(op) PyObject_TypeCheck(op, &PyInt_Type) -#define PyInt_CheckExact(op) ((op)->ob_type == &PyInt_Type) - -PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int); -#ifdef Py_USING_UNICODE -PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, int, int); -#endif -PyAPI_FUNC(PyObject *) PyInt_FromLong(long); -PyAPI_FUNC(long) PyInt_AsLong(PyObject *); -PyAPI_FUNC(unsigned long) PyInt_AsUnsignedLongMask(PyObject *); -#ifdef HAVE_LONG_LONG -PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *); -#endif - -PyAPI_FUNC(long) PyInt_GetMax(void); - -/* Macro, trading safety for speed */ -#define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival) - -/* These aren't really part of the Int object, but they're handy; the protos - * are necessary for systems that need the magic of PyAPI_FUNC and that want - * to have stropmodule as a dynamically loaded module instead of building it - * into the main Python shared library/DLL. Guido thinks I'm weird for - * building it this way. :-) [cjh] - */ -PyAPI_FUNC(unsigned long) PyOS_strtoul(char *, char **, int); -PyAPI_FUNC(long) PyOS_strtol(char *, char **, int); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_INTOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/intrcheck.h b/SDKs/XPlatform/Cypython-2.3.3/include/intrcheck.h deleted file mode 100644 index 11d759e4..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/intrcheck.h +++ /dev/null @@ -1,15 +0,0 @@ - -#ifndef Py_INTRCHECK_H -#define Py_INTRCHECK_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(int) PyOS_InterruptOccurred(void); -PyAPI_FUNC(void) PyOS_InitInterrupts(void); -PyAPI_FUNC(void) PyOS_AfterFork(void); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_INTRCHECK_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/iterobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/iterobject.h deleted file mode 100644 index ba507d30..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/iterobject.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef Py_ITEROBJECT_H -#define Py_ITEROBJECT_H -/* Iterators (the basic kind, over a sequence) */ -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(PyTypeObject) PySeqIter_Type; - -#define PySeqIter_Check(op) ((op)->ob_type == &PySeqIter_Type) - -PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *); - -PyAPI_DATA(PyTypeObject) PyCallIter_Type; - -#define PyCallIter_Check(op) ((op)->ob_type == &PyCallIter_Type) - -PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *); -#ifdef __cplusplus -} -#endif -#endif /* !Py_ITEROBJECT_H */ - diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/listobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/listobject.h deleted file mode 100644 index 0e820ffa..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/listobject.h +++ /dev/null @@ -1,52 +0,0 @@ - -/* List object interface */ - -/* -Another generally useful object type is an list of object pointers. -This is a mutable type: the list items can be changed, and items can be -added or removed. Out-of-range indices or non-list objects are ignored. - -*** WARNING *** PyList_SetItem does not increment the new item's reference -count, but does decrement the reference count of the item it replaces, -if not nil. It does *decrement* the reference count if it is *not* -inserted in the list. Similarly, PyList_GetItem does not increment the -returned item's reference count. -*/ - -#ifndef Py_LISTOBJECT_H -#define Py_LISTOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - PyObject_VAR_HEAD - PyObject **ob_item; -} PyListObject; - -PyAPI_DATA(PyTypeObject) PyList_Type; - -#define PyList_Check(op) PyObject_TypeCheck(op, &PyList_Type) -#define PyList_CheckExact(op) ((op)->ob_type == &PyList_Type) - -PyAPI_FUNC(PyObject *) PyList_New(int size); -PyAPI_FUNC(int) PyList_Size(PyObject *); -PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, int); -PyAPI_FUNC(int) PyList_SetItem(PyObject *, int, PyObject *); -PyAPI_FUNC(int) PyList_Insert(PyObject *, int, PyObject *); -PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, int, int); -PyAPI_FUNC(int) PyList_SetSlice(PyObject *, int, int, PyObject *); -PyAPI_FUNC(int) PyList_Sort(PyObject *); -PyAPI_FUNC(int) PyList_Reverse(PyObject *); -PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *); - -/* Macro, trading safety for speed */ -#define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i]) -#define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v)) -#define PyList_GET_SIZE(op) (((PyListObject *)(op))->ob_size) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_LISTOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/longintrepr.h b/SDKs/XPlatform/Cypython-2.3.3/include/longintrepr.h deleted file mode 100644 index 9d375a90..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/longintrepr.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef Py_LONGINTREPR_H -#define Py_LONGINTREPR_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* This is published for the benefit of "friend" marshal.c only. */ - -/* Parameters of the long integer representation. - These shouldn't have to be changed as C should guarantee that a short - contains at least 16 bits, but it's made changeable anyway. - Note: 'digit' should be able to hold 2*MASK+1, and 'twodigits' - should be able to hold the intermediate results in 'mul' - (at most MASK << SHIFT). - Also, x_sub assumes that 'digit' is an unsigned type, and overflow - is handled by taking the result mod 2**N for some N > SHIFT. - And, at some places it is assumed that MASK fits in an int, as well. */ - -typedef unsigned short digit; -typedef unsigned int wdigit; /* digit widened to parameter size */ -#define BASE_TWODIGITS_TYPE long -typedef unsigned BASE_TWODIGITS_TYPE twodigits; -typedef BASE_TWODIGITS_TYPE stwodigits; /* signed variant of twodigits */ - -#define SHIFT 15 -#define BASE ((digit)1 << SHIFT) -#define MASK ((int)(BASE - 1)) - -/* Long integer representation. - The absolute value of a number is equal to - SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i) - Negative numbers are represented with ob_size < 0; - zero is represented by ob_size == 0. - In a normalized number, ob_digit[abs(ob_size)-1] (the most significant - digit) is never zero. Also, in all cases, for all valid i, - 0 <= ob_digit[i] <= MASK. - The allocation function takes care of allocating extra memory - so that ob_digit[0] ... ob_digit[abs(ob_size)-1] are actually available. - - CAUTION: Generic code manipulating subtypes of PyVarObject has to - aware that longs abuse ob_size's sign bit. -*/ - -struct _longobject { - PyObject_VAR_HEAD - digit ob_digit[1]; -}; - -PyAPI_FUNC(PyLongObject *) _PyLong_New(int); - -/* Return a copy of src. */ -PyAPI_FUNC(PyObject *) _PyLong_Copy(PyLongObject *src); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_LONGINTREPR_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/longobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/longobject.h deleted file mode 100644 index 4647eda4..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/longobject.h +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef Py_LONGOBJECT_H -#define Py_LONGOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Long (arbitrary precision) integer object interface */ - -typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */ - -PyAPI_DATA(PyTypeObject) PyLong_Type; - -#define PyLong_Check(op) PyObject_TypeCheck(op, &PyLong_Type) -#define PyLong_CheckExact(op) ((op)->ob_type == &PyLong_Type) - -PyAPI_FUNC(PyObject *) PyLong_FromLong(long); -PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long); -PyAPI_FUNC(PyObject *) PyLong_FromDouble(double); -PyAPI_FUNC(long) PyLong_AsLong(PyObject *); -PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); -PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); - -/* _PyLong_AsScaledDouble returns a double x and an exponent e such that - the true value is approximately equal to x * 2**(SHIFT*e). e is >= 0. - x is 0.0 if and only if the input is 0 (in which case, e and x are both - zeroes). Overflow is impossible. Note that the exponent returned must - be multiplied by SHIFT! There may not be enough room in an int to store - e*SHIFT directly. */ -PyAPI_FUNC(double) _PyLong_AsScaledDouble(PyObject *vv, int *e); - -PyAPI_FUNC(double) PyLong_AsDouble(PyObject *); -PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *); -PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *); - -#ifdef HAVE_LONG_LONG -PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG); -PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG); -PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *); -PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *); -PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *); -#endif /* HAVE_LONG_LONG */ - -PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int); -#ifdef Py_USING_UNICODE -PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, int, int); -#endif - -/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0. - v must not be NULL, and must be a normalized long. - There are no error cases. -*/ -PyAPI_FUNC(int) _PyLong_Sign(PyObject *v); - - -PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v); -/* _PyLong_NumBits. Return the number of bits needed to represent the - absolute value of a long. For example, this returns 1 for 1 and -1, 2 - for 2 and -2, and 2 for 3 and -3. It returns 0 for 0. - v must not be NULL, and must be a normalized long. - (size_t)-1 is returned and OverflowError set if the true result doesn't - fit in a size_t. -*/ -PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v); - -/* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in - base 256, and return a Python long with the same numeric value. - If n is 0, the integer is 0. Else: - If little_endian is 1/true, bytes[n-1] is the MSB and bytes[0] the LSB; - else (little_endian is 0/false) bytes[0] is the MSB and bytes[n-1] the - LSB. - If is_signed is 0/false, view the bytes as a non-negative integer. - If is_signed is 1/true, view the bytes as a 2's-complement integer, - non-negative if bit 0x80 of the MSB is clear, negative if set. - Error returns: - + Return NULL with the appropriate exception set if there's not - enough memory to create the Python long. -*/ -PyAPI_FUNC(PyObject *) _PyLong_FromByteArray( - const unsigned char* bytes, size_t n, - int little_endian, int is_signed); - -/* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long - v to a base-256 integer, stored in array bytes. Normally return 0, - return -1 on error. - If little_endian is 1/true, store the MSB at bytes[n-1] and the LSB at - bytes[0]; else (little_endian is 0/false) store the MSB at bytes[0] and - the LSB at bytes[n-1]. - If is_signed is 0/false, it's an error if v < 0; else (v >= 0) n bytes - are filled and there's nothing special about bit 0x80 of the MSB. - If is_signed is 1/true, bytes is filled with the 2's-complement - representation of v's value. Bit 0x80 of the MSB is the sign bit. - Error returns (-1): - + is_signed is 0 and v < 0. TypeError is set in this case, and bytes - isn't altered. - + n isn't big enough to hold the full mathematical value of v. For - example, if is_signed is 0 and there are more digits in the v than - fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of - being large enough to hold a sign bit. OverflowError is set in this - case, but bytes holds the least-signficant n bytes of the true value. -*/ -PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v, - unsigned char* bytes, size_t n, - int little_endian, int is_signed); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_LONGOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/marshal.h b/SDKs/XPlatform/Cypython-2.3.3/include/marshal.h deleted file mode 100644 index 87fcf5f2..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/marshal.h +++ /dev/null @@ -1,23 +0,0 @@ - -/* Interface for marshal.c */ - -#ifndef Py_MARSHAL_H -#define Py_MARSHAL_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *); -PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *); -PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *); - -PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *); -PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *); -PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *); -PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *); -PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, int); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_MARSHAL_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/metagrammar.h b/SDKs/XPlatform/Cypython-2.3.3/include/metagrammar.h deleted file mode 100644 index 1fb471a0..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/metagrammar.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef Py_METAGRAMMAR_H -#define Py_METAGRAMMAR_H -#ifdef __cplusplus -extern "C" { -#endif - - -#define MSTART 256 -#define RULE 257 -#define RHS 258 -#define ALT 259 -#define ITEM 260 -#define ATOM 261 - -#ifdef __cplusplus -} -#endif -#endif /* !Py_METAGRAMMAR_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/methodobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/methodobject.h deleted file mode 100644 index 5298c5a3..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/methodobject.h +++ /dev/null @@ -1,79 +0,0 @@ - -/* Method object interface */ - -#ifndef Py_METHODOBJECT_H -#define Py_METHODOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(PyTypeObject) PyCFunction_Type; - -#define PyCFunction_Check(op) ((op)->ob_type == &PyCFunction_Type) - -typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); -typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *, - PyObject *); -typedef PyObject *(*PyNoArgsFunction)(PyObject *); - -PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *); -PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *); -PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *); - -/* Macros for direct access to these values. Type checks are *not* - done, so use with care. */ -#define PyCFunction_GET_FUNCTION(func) \ - (((PyCFunctionObject *)func) -> m_ml -> ml_meth) -#define PyCFunction_GET_SELF(func) \ - (((PyCFunctionObject *)func) -> m_self) -#define PyCFunction_GET_FLAGS(func) \ - (((PyCFunctionObject *)func) -> m_ml -> ml_flags) -PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *); - -struct PyMethodDef { - char *ml_name; - PyCFunction ml_meth; - int ml_flags; - char *ml_doc; -}; -typedef struct PyMethodDef PyMethodDef; - -PyAPI_FUNC(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, char *); - -#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL) -PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *, - PyObject *); - -/* Flag passed to newmethodobject */ -#define METH_OLDARGS 0x0000 -#define METH_VARARGS 0x0001 -#define METH_KEYWORDS 0x0002 -/* METH_NOARGS and METH_O must not be combined with the flags above. */ -#define METH_NOARGS 0x0004 -#define METH_O 0x0008 - -/* METH_CLASS and METH_STATIC are a little different; these control - the construction of methods for a class. These cannot be used for - functions in modules. */ -#define METH_CLASS 0x0010 -#define METH_STATIC 0x0020 - -typedef struct PyMethodChain { - PyMethodDef *methods; /* Methods of this type */ - struct PyMethodChain *link; /* NULL or base type */ -} PyMethodChain; - -PyAPI_FUNC(PyObject *) Py_FindMethodInChain(PyMethodChain *, PyObject *, - char *); - -typedef struct { - PyObject_HEAD - PyMethodDef *m_ml; - PyObject *m_self; - PyObject *m_module; -} PyCFunctionObject; - -#ifdef __cplusplus -} -#endif -#endif /* !Py_METHODOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/modsupport.h b/SDKs/XPlatform/Cypython-2.3.3/include/modsupport.h deleted file mode 100644 index f38ec203..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/modsupport.h +++ /dev/null @@ -1,101 +0,0 @@ - -#ifndef Py_MODSUPPORT_H -#define Py_MODSUPPORT_H -#ifdef __cplusplus -extern "C" { -#endif - -/* Module support interface */ - -#include - -PyAPI_FUNC(int) PyArg_Parse(PyObject *, char *, ...); -PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, char *, ...); -PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, - char *, char **, ...); -PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, char *, int, int, ...); -PyAPI_FUNC(PyObject *) Py_BuildValue(char *, ...); - -PyAPI_FUNC(int) PyArg_VaParse(PyObject *, char *, va_list); -PyAPI_FUNC(PyObject *) Py_VaBuildValue(char *, va_list); - -PyAPI_FUNC(int) PyModule_AddObject(PyObject *, char *, PyObject *); -PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, char *, long); -PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, char *, char *); - -#define PYTHON_API_VERSION 1012 -#define PYTHON_API_STRING "1012" -/* The API version is maintained (independently from the Python version) - so we can detect mismatches between the interpreter and dynamically - loaded modules. These are diagnosed by an error message but - the module is still loaded (because the mismatch can only be tested - after loading the module). The error message is intended to - explain the core dump a few seconds later. - - The symbol PYTHON_API_STRING defines the same value as a string - literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. *** - - Please add a line or two to the top of this log for each API - version change: - - 19-Aug-2002 GvR 1012 Changes to string object struct for - interning changes, saving 3 bytes. - - 17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side - - 25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and - PyFrame_New(); Python 2.1a2 - - 14-Mar-2000 GvR 1009 Unicode API added - - 3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!) - - 3-Dec-1998 GvR 1008 Python 1.5.2b1 - - 18-Jan-1997 GvR 1007 string interning and other speedups - - 11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-( - - 30-Jul-1996 GvR Slice and ellipses syntax added - - 23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-) - - 7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( ) - - 10-Jan-1995 GvR Renamed globals to new naming scheme - - 9-Jan-1995 GvR Initial version (incompatible with older API) -*/ - -#ifdef MS_WINDOWS -/* Special defines for Windows versions used to live here. Things - have changed, and the "Version" is now in a global string variable. - Reason for this is that this for easier branding of a "custom DLL" - without actually needing a recompile. */ -#endif /* MS_WINDOWS */ - -#ifdef Py_TRACE_REFS -/* When we are tracing reference counts, rename Py_InitModule4 so - modules compiled with incompatible settings will generate a - link-time error. */ -#define Py_InitModule4 Py_InitModule4TraceRefs -#endif - -PyAPI_FUNC(PyObject *) Py_InitModule4(char *name, PyMethodDef *methods, - char *doc, PyObject *self, - int apiver); - -#define Py_InitModule(name, methods) \ - Py_InitModule4(name, methods, (char *)NULL, (PyObject *)NULL, \ - PYTHON_API_VERSION) - -#define Py_InitModule3(name, methods, doc) \ - Py_InitModule4(name, methods, doc, (PyObject *)NULL, \ - PYTHON_API_VERSION) - -PyAPI_DATA(char *) _Py_PackageContext; - -#ifdef __cplusplus -} -#endif -#endif /* !Py_MODSUPPORT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/moduleobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/moduleobject.h deleted file mode 100644 index 2047929f..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/moduleobject.h +++ /dev/null @@ -1,24 +0,0 @@ - -/* Module object interface */ - -#ifndef Py_MODULEOBJECT_H -#define Py_MODULEOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(PyTypeObject) PyModule_Type; - -#define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type) -#define PyModule_CheckExact(op) ((op)->ob_type == &PyModule_Type) - -PyAPI_FUNC(PyObject *) PyModule_New(char *); -PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *); -PyAPI_FUNC(char *) PyModule_GetName(PyObject *); -PyAPI_FUNC(char *) PyModule_GetFilename(PyObject *); -PyAPI_FUNC(void) _PyModule_Clear(PyObject *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_MODULEOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/node.h b/SDKs/XPlatform/Cypython-2.3.3/include/node.h deleted file mode 100644 index ce9a97dd..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/node.h +++ /dev/null @@ -1,37 +0,0 @@ - -/* Parse tree node interface */ - -#ifndef Py_NODE_H -#define Py_NODE_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _node { - short n_type; - char *n_str; - int n_lineno; - int n_nchildren; - struct _node *n_child; -} node; - -PyAPI_FUNC(node *) PyNode_New(int type); -PyAPI_FUNC(int) PyNode_AddChild(node *n, int type, - char *str, int lineno); -PyAPI_FUNC(void) PyNode_Free(node *n); - -/* Node access functions */ -#define NCH(n) ((n)->n_nchildren) -#define CHILD(n, i) (&(n)->n_child[i]) -#define TYPE(n) ((n)->n_type) -#define STR(n) ((n)->n_str) - -/* Assert that the type of a node is what we expect */ -#define REQ(n, type) assert(TYPE(n) == (type)) - -PyAPI_FUNC(void) PyNode_ListTree(node *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_NODE_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/object.h b/SDKs/XPlatform/Cypython-2.3.3/include/object.h deleted file mode 100644 index e0de808c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/object.h +++ /dev/null @@ -1,783 +0,0 @@ -#ifndef Py_OBJECT_H -#define Py_OBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Object and type object interface */ - -/* -Objects are structures allocated on the heap. Special rules apply to -the use of objects to ensure they are properly garbage-collected. -Objects are never allocated statically or on the stack; they must be -accessed through special macros and functions only. (Type objects are -exceptions to the first rule; the standard types are represented by -statically initialized type objects, although work on type/class unification -for Python 2.2 made it possible to have heap-allocated type objects too). - -An object has a 'reference count' that is increased or decreased when a -pointer to the object is copied or deleted; when the reference count -reaches zero there are no references to the object left and it can be -removed from the heap. - -An object has a 'type' that determines what it represents and what kind -of data it contains. An object's type is fixed when it is created. -Types themselves are represented as objects; an object contains a -pointer to the corresponding type object. The type itself has a type -pointer pointing to the object representing the type 'type', which -contains a pointer to itself!). - -Objects do not float around in memory; once allocated an object keeps -the same size and address. Objects that must hold variable-size data -can contain pointers to variable-size parts of the object. Not all -objects of the same type have the same size; but the size cannot change -after allocation. (These restrictions are made so a reference to an -object can be simply a pointer -- moving an object would require -updating all the pointers, and changing an object's size would require -moving it if there was another object right next to it.) - -Objects are always accessed through pointers of the type 'PyObject *'. -The type 'PyObject' is a structure that only contains the reference count -and the type pointer. The actual memory allocated for an object -contains other data that can only be accessed after casting the pointer -to a pointer to a longer structure type. This longer type must start -with the reference count and type fields; the macro PyObject_HEAD should be -used for this (to accommodate for future changes). The implementation -of a particular object type can cast the object pointer to the proper -type and back. - -A standard interface exists for objects that contain an array of items -whose size is determined when the object is allocated. -*/ - -/* Py_DEBUG implies Py_TRACE_REFS. */ -#if defined(Py_DEBUG) && !defined(Py_TRACE_REFS) -#define Py_TRACE_REFS -#endif - -/* Py_TRACE_REFS implies Py_REF_DEBUG. */ -#if defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) -#define Py_REF_DEBUG -#endif - -#ifdef Py_TRACE_REFS -/* Define pointers to support a doubly-linked list of all live heap objects. */ -#define _PyObject_HEAD_EXTRA \ - struct _object *_ob_next; \ - struct _object *_ob_prev; - -#define _PyObject_EXTRA_INIT 0, 0, - -#else -#define _PyObject_HEAD_EXTRA -#define _PyObject_EXTRA_INIT -#endif - -/* PyObject_HEAD defines the initial segment of every PyObject. */ -#define PyObject_HEAD \ - _PyObject_HEAD_EXTRA \ - int ob_refcnt; \ - struct _typeobject *ob_type; - -#define PyObject_HEAD_INIT(type) \ - _PyObject_EXTRA_INIT \ - 1, type, - -/* PyObject_VAR_HEAD defines the initial segment of all variable-size - * container objects. These end with a declaration of an array with 1 - * element, but enough space is malloc'ed so that the array actually - * has room for ob_size elements. Note that ob_size is an element count, - * not necessarily a byte count. - */ -#define PyObject_VAR_HEAD \ - PyObject_HEAD \ - int ob_size; /* Number of items in variable part */ - -/* Nothing is actually declared to be a PyObject, but every pointer to - * a Python object can be cast to a PyObject*. This is inheritance built - * by hand. Similarly every pointer to a variable-size Python object can, - * in addition, be cast to PyVarObject*. - */ -typedef struct _object { - PyObject_HEAD -} PyObject; - -typedef struct { - PyObject_VAR_HEAD -} PyVarObject; - - -/* -Type objects contain a string containing the type name (to help somewhat -in debugging), the allocation parameters (see PyObject_New() and -PyObject_NewVar()), -and methods for accessing objects of the type. Methods are optional, a -nil pointer meaning that particular kind of access is not available for -this type. The Py_DECREF() macro uses the tp_dealloc method without -checking for a nil pointer; it should always be implemented except if -the implementation can guarantee that the reference count will never -reach zero (e.g., for statically allocated type objects). - -NB: the methods for certain type groups are now contained in separate -method blocks. -*/ - -typedef PyObject * (*unaryfunc)(PyObject *); -typedef PyObject * (*binaryfunc)(PyObject *, PyObject *); -typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *); -typedef int (*inquiry)(PyObject *); -typedef int (*coercion)(PyObject **, PyObject **); -typedef PyObject *(*intargfunc)(PyObject *, int); -typedef PyObject *(*intintargfunc)(PyObject *, int, int); -typedef int(*intobjargproc)(PyObject *, int, PyObject *); -typedef int(*intintobjargproc)(PyObject *, int, int, PyObject *); -typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *); -typedef int (*getreadbufferproc)(PyObject *, int, void **); -typedef int (*getwritebufferproc)(PyObject *, int, void **); -typedef int (*getsegcountproc)(PyObject *, int *); -typedef int (*getcharbufferproc)(PyObject *, int, const char **); -typedef int (*objobjproc)(PyObject *, PyObject *); -typedef int (*visitproc)(PyObject *, void *); -typedef int (*traverseproc)(PyObject *, visitproc, void *); - -typedef struct { - /* For numbers without flag bit Py_TPFLAGS_CHECKTYPES set, all - arguments are guaranteed to be of the object's type (modulo - coercion hacks -- i.e. if the type's coercion function - returns other types, then these are allowed as well). Numbers that - have the Py_TPFLAGS_CHECKTYPES flag bit set should check *both* - arguments for proper type and implement the necessary conversions - in the slot functions themselves. */ - - binaryfunc nb_add; - binaryfunc nb_subtract; - binaryfunc nb_multiply; - binaryfunc nb_divide; - binaryfunc nb_remainder; - binaryfunc nb_divmod; - ternaryfunc nb_power; - unaryfunc nb_negative; - unaryfunc nb_positive; - unaryfunc nb_absolute; - inquiry nb_nonzero; - unaryfunc nb_invert; - binaryfunc nb_lshift; - binaryfunc nb_rshift; - binaryfunc nb_and; - binaryfunc nb_xor; - binaryfunc nb_or; - coercion nb_coerce; - unaryfunc nb_int; - unaryfunc nb_long; - unaryfunc nb_float; - unaryfunc nb_oct; - unaryfunc nb_hex; - /* Added in release 2.0 */ - binaryfunc nb_inplace_add; - binaryfunc nb_inplace_subtract; - binaryfunc nb_inplace_multiply; - binaryfunc nb_inplace_divide; - binaryfunc nb_inplace_remainder; - ternaryfunc nb_inplace_power; - binaryfunc nb_inplace_lshift; - binaryfunc nb_inplace_rshift; - binaryfunc nb_inplace_and; - binaryfunc nb_inplace_xor; - binaryfunc nb_inplace_or; - - /* Added in release 2.2 */ - /* The following require the Py_TPFLAGS_HAVE_CLASS flag */ - binaryfunc nb_floor_divide; - binaryfunc nb_true_divide; - binaryfunc nb_inplace_floor_divide; - binaryfunc nb_inplace_true_divide; -} PyNumberMethods; - -typedef struct { - inquiry sq_length; - binaryfunc sq_concat; - intargfunc sq_repeat; - intargfunc sq_item; - intintargfunc sq_slice; - intobjargproc sq_ass_item; - intintobjargproc sq_ass_slice; - objobjproc sq_contains; - /* Added in release 2.0 */ - binaryfunc sq_inplace_concat; - intargfunc sq_inplace_repeat; -} PySequenceMethods; - -typedef struct { - inquiry mp_length; - binaryfunc mp_subscript; - objobjargproc mp_ass_subscript; -} PyMappingMethods; - -typedef struct { - getreadbufferproc bf_getreadbuffer; - getwritebufferproc bf_getwritebuffer; - getsegcountproc bf_getsegcount; - getcharbufferproc bf_getcharbuffer; -} PyBufferProcs; - - -typedef void (*freefunc)(void *); -typedef void (*destructor)(PyObject *); -typedef int (*printfunc)(PyObject *, FILE *, int); -typedef PyObject *(*getattrfunc)(PyObject *, char *); -typedef PyObject *(*getattrofunc)(PyObject *, PyObject *); -typedef int (*setattrfunc)(PyObject *, char *, PyObject *); -typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *); -typedef int (*cmpfunc)(PyObject *, PyObject *); -typedef PyObject *(*reprfunc)(PyObject *); -typedef long (*hashfunc)(PyObject *); -typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); -typedef PyObject *(*getiterfunc) (PyObject *); -typedef PyObject *(*iternextfunc) (PyObject *); -typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *); -typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *); -typedef int (*initproc)(PyObject *, PyObject *, PyObject *); -typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *); -typedef PyObject *(*allocfunc)(struct _typeobject *, int); - -typedef struct _typeobject { - PyObject_VAR_HEAD - char *tp_name; /* For printing, in format "." */ - int tp_basicsize, tp_itemsize; /* For allocation */ - - /* Methods to implement standard operations */ - - destructor tp_dealloc; - printfunc tp_print; - getattrfunc tp_getattr; - setattrfunc tp_setattr; - cmpfunc tp_compare; - reprfunc tp_repr; - - /* Method suites for standard classes */ - - PyNumberMethods *tp_as_number; - PySequenceMethods *tp_as_sequence; - PyMappingMethods *tp_as_mapping; - - /* More standard operations (here for binary compatibility) */ - - hashfunc tp_hash; - ternaryfunc tp_call; - reprfunc tp_str; - getattrofunc tp_getattro; - setattrofunc tp_setattro; - - /* Functions to access object as input/output buffer */ - PyBufferProcs *tp_as_buffer; - - /* Flags to define presence of optional/expanded features */ - long tp_flags; - - char *tp_doc; /* Documentation string */ - - /* Assigned meaning in release 2.0 */ - /* call function for all accessible objects */ - traverseproc tp_traverse; - - /* delete references to contained objects */ - inquiry tp_clear; - - /* Assigned meaning in release 2.1 */ - /* rich comparisons */ - richcmpfunc tp_richcompare; - - /* weak reference enabler */ - long tp_weaklistoffset; - - /* Added in release 2.2 */ - /* Iterators */ - getiterfunc tp_iter; - iternextfunc tp_iternext; - - /* Attribute descriptor and subclassing stuff */ - struct PyMethodDef *tp_methods; - struct PyMemberDef *tp_members; - struct PyGetSetDef *tp_getset; - struct _typeobject *tp_base; - PyObject *tp_dict; - descrgetfunc tp_descr_get; - descrsetfunc tp_descr_set; - long tp_dictoffset; - initproc tp_init; - allocfunc tp_alloc; - newfunc tp_new; - freefunc tp_free; /* Low-level free-memory routine */ - inquiry tp_is_gc; /* For PyObject_IS_GC */ - PyObject *tp_bases; - PyObject *tp_mro; /* method resolution order */ - PyObject *tp_cache; - PyObject *tp_subclasses; - PyObject *tp_weaklist; - destructor tp_del; - -#ifdef COUNT_ALLOCS - /* these must be last and never explicitly initialized */ - int tp_allocs; - int tp_frees; - int tp_maxalloc; - struct _typeobject *tp_next; -#endif -} PyTypeObject; - - -/* The *real* layout of a type object when allocated on the heap */ -typedef struct _heaptypeobject { - /* Note: there's a dependency on the order of these members - in slotptr() in typeobject.c . */ - PyTypeObject type; - PyNumberMethods as_number; - PyMappingMethods as_mapping; - PySequenceMethods as_sequence; /* as_sequence comes after as_mapping, - so that the mapping wins when both - the mapping and the sequence define - a given operator (e.g. __getitem__). - see add_operators() in typeobject.c . */ - PyBufferProcs as_buffer; - PyObject *name, *slots; - /* here are optional user slots, followed by the members. */ -} PyHeapTypeObject; - -/* access macro to the members which are floating "behind" the object */ -#define PyHeapType_GET_MEMBERS(etype) \ - ((PyMemberDef *)(((char *)etype) + (etype)->type.ob_type->tp_basicsize)) - - -/* Generic type check */ -PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *); -#define PyObject_TypeCheck(ob, tp) \ - ((ob)->ob_type == (tp) || PyType_IsSubtype((ob)->ob_type, (tp))) - -PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */ -PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */ -PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */ - -#define PyType_Check(op) PyObject_TypeCheck(op, &PyType_Type) -#define PyType_CheckExact(op) ((op)->ob_type == &PyType_Type) - -PyAPI_FUNC(int) PyType_Ready(PyTypeObject *); -PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, int); -PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *, - PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *); - -/* Generic operations on objects */ -PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int); -PyAPI_FUNC(void) _PyObject_Dump(PyObject *); -PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *); -PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *); -#ifdef Py_USING_UNICODE -PyAPI_FUNC(PyObject *) PyObject_Unicode(PyObject *); -#endif -PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int); -PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int); -PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, char *); -PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, char *, PyObject *); -PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, char *); -PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *); -PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *); -PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *); -PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *); -PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *); -PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *); -PyAPI_FUNC(int) PyObject_GenericSetAttr(PyObject *, - PyObject *, PyObject *); -PyAPI_FUNC(long) PyObject_Hash(PyObject *); -PyAPI_FUNC(int) PyObject_IsTrue(PyObject *); -PyAPI_FUNC(int) PyObject_Not(PyObject *); -PyAPI_FUNC(int) PyCallable_Check(PyObject *); -PyAPI_FUNC(int) PyNumber_Coerce(PyObject **, PyObject **); -PyAPI_FUNC(int) PyNumber_CoerceEx(PyObject **, PyObject **); - -PyAPI_FUNC(void) PyObject_ClearWeakRefs(PyObject *); - -/* A slot function whose address we need to compare */ -extern int _PyObject_SlotCompare(PyObject *, PyObject *); - - -/* PyObject_Dir(obj) acts like Python __builtin__.dir(obj), returning a - list of strings. PyObject_Dir(NULL) is like __builtin__.dir(), - returning the names of the current locals. In this case, if there are - no current locals, NULL is returned, and PyErr_Occurred() is false. -*/ -PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *); - - -/* Helpers for printing recursive container types */ -PyAPI_FUNC(int) Py_ReprEnter(PyObject *); -PyAPI_FUNC(void) Py_ReprLeave(PyObject *); - -/* Helpers for hash functions */ -PyAPI_FUNC(long) _Py_HashDouble(double); -PyAPI_FUNC(long) _Py_HashPointer(void*); - -/* Helper for passing objects to printf and the like */ -#define PyObject_REPR(obj) PyString_AS_STRING(PyObject_Repr(obj)) - -/* Flag bits for printing: */ -#define Py_PRINT_RAW 1 /* No string quotes etc. */ - -/* -`Type flags (tp_flags) - -These flags are used to extend the type structure in a backwards-compatible -fashion. Extensions can use the flags to indicate (and test) when a given -type structure contains a new feature. The Python core will use these when -introducing new functionality between major revisions (to avoid mid-version -changes in the PYTHON_API_VERSION). - -Arbitration of the flag bit positions will need to be coordinated among -all extension writers who publically release their extensions (this will -be fewer than you might expect!).. - -Python 1.5.2 introduced the bf_getcharbuffer slot into PyBufferProcs. - -Type definitions should use Py_TPFLAGS_DEFAULT for their tp_flags value. - -Code can use PyType_HasFeature(type_ob, flag_value) to test whether the -given type object has a specified feature. -*/ - -/* PyBufferProcs contains bf_getcharbuffer */ -#define Py_TPFLAGS_HAVE_GETCHARBUFFER (1L<<0) - -/* PySequenceMethods contains sq_contains */ -#define Py_TPFLAGS_HAVE_SEQUENCE_IN (1L<<1) - -/* This is here for backwards compatibility. Extensions that use the old GC - * API will still compile but the objects will not be tracked by the GC. */ -#define Py_TPFLAGS_GC 0 /* used to be (1L<<2) */ - -/* PySequenceMethods and PyNumberMethods contain in-place operators */ -#define Py_TPFLAGS_HAVE_INPLACEOPS (1L<<3) - -/* PyNumberMethods do their own coercion */ -#define Py_TPFLAGS_CHECKTYPES (1L<<4) - -/* tp_richcompare is defined */ -#define Py_TPFLAGS_HAVE_RICHCOMPARE (1L<<5) - -/* Objects which are weakly referencable if their tp_weaklistoffset is >0 */ -#define Py_TPFLAGS_HAVE_WEAKREFS (1L<<6) - -/* tp_iter is defined */ -#define Py_TPFLAGS_HAVE_ITER (1L<<7) - -/* New members introduced by Python 2.2 exist */ -#define Py_TPFLAGS_HAVE_CLASS (1L<<8) - -/* Set if the type object is dynamically allocated */ -#define Py_TPFLAGS_HEAPTYPE (1L<<9) - -/* Set if the type allows subclassing */ -#define Py_TPFLAGS_BASETYPE (1L<<10) - -/* Set if the type is 'ready' -- fully initialized */ -#define Py_TPFLAGS_READY (1L<<12) - -/* Set while the type is being 'readied', to prevent recursive ready calls */ -#define Py_TPFLAGS_READYING (1L<<13) - -/* Objects support garbage collection (see objimp.h) */ -#define Py_TPFLAGS_HAVE_GC (1L<<14) - -/* These two bits are preserved for Stackless Python, next after this is 16 */ -#ifdef STACKLESS -#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION (3L<<15) -#else -#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0 -#endif - -#define Py_TPFLAGS_DEFAULT ( \ - Py_TPFLAGS_HAVE_GETCHARBUFFER | \ - Py_TPFLAGS_HAVE_SEQUENCE_IN | \ - Py_TPFLAGS_HAVE_INPLACEOPS | \ - Py_TPFLAGS_HAVE_RICHCOMPARE | \ - Py_TPFLAGS_HAVE_WEAKREFS | \ - Py_TPFLAGS_HAVE_ITER | \ - Py_TPFLAGS_HAVE_CLASS | \ - Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \ - 0) - -#define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0) - - -/* -The macros Py_INCREF(op) and Py_DECREF(op) are used to increment or decrement -reference counts. Py_DECREF calls the object's deallocator function when -the refcount falls to 0; for -objects that don't contain references to other objects or heap memory -this can be the standard function free(). Both macros can be used -wherever a void expression is allowed. The argument must not be a -NIL pointer. If it may be NIL, use Py_XINCREF/Py_XDECREF instead. -The macro _Py_NewReference(op) initialize reference counts to 1, and -in special builds (Py_REF_DEBUG, Py_TRACE_REFS) performs additional -bookkeeping appropriate to the special build. - -We assume that the reference count field can never overflow; this can -be proven when the size of the field is the same as the pointer size, so -we ignore the possibility. Provided a C int is at least 32 bits (which -is implicitly assumed in many parts of this code), that's enough for -about 2**31 references to an object. - -XXX The following became out of date in Python 2.2, but I'm not sure -XXX what the full truth is now. Certainly, heap-allocated type objects -XXX can and should be deallocated. -Type objects should never be deallocated; the type pointer in an object -is not considered to be a reference to the type object, to save -complications in the deallocation function. (This is actually a -decision that's up to the implementer of each new type so if you want, -you can count such references to the type object.) - -*** WARNING*** The Py_DECREF macro must have a side-effect-free argument -since it may evaluate its argument multiple times. (The alternative -would be to mace it a proper function or assign it to a global temporary -variable first, both of which are slower; and in a multi-threaded -environment the global variable trick is not safe.) -*/ - -/* First define a pile of simple helper macros, one set per special - * build symbol. These either expand to the obvious things, or to - * nothing at all when the special mode isn't in effect. The main - * macros can later be defined just once then, yet expand to different - * things depending on which special build options are and aren't in effect. - * Trust me : while painful, this is 20x easier to understand than, - * e.g, defining _Py_NewReference five different times in a maze of nested - * #ifdefs (we used to do that -- it was impenetrable). - */ -#ifdef Py_REF_DEBUG -PyAPI_DATA(long) _Py_RefTotal; -PyAPI_FUNC(void) _Py_NegativeRefcount(const char *fname, - int lineno, PyObject *op); -#define _Py_INC_REFTOTAL _Py_RefTotal++ -#define _Py_DEC_REFTOTAL _Py_RefTotal-- -#define _Py_REF_DEBUG_COMMA , -#define _Py_CHECK_REFCNT(OP) \ -{ if ((OP)->ob_refcnt < 0) \ - _Py_NegativeRefcount(__FILE__, __LINE__, \ - (PyObject *)(OP)); \ -} -#else -#define _Py_INC_REFTOTAL -#define _Py_DEC_REFTOTAL -#define _Py_REF_DEBUG_COMMA -#define _Py_CHECK_REFCNT(OP) /* a semicolon */; -#endif /* Py_REF_DEBUG */ - -#ifdef COUNT_ALLOCS -PyAPI_FUNC(void) inc_count(PyTypeObject *); -#define _Py_INC_TPALLOCS(OP) inc_count((OP)->ob_type) -#define _Py_INC_TPFREES(OP) (OP)->ob_type->tp_frees++ -#define _Py_DEC_TPFREES(OP) (OP)->ob_type->tp_frees-- -#define _Py_COUNT_ALLOCS_COMMA , -#else -#define _Py_INC_TPALLOCS(OP) -#define _Py_INC_TPFREES(OP) -#define _Py_DEC_TPFREES(OP) -#define _Py_COUNT_ALLOCS_COMMA -#endif /* COUNT_ALLOCS */ - -#ifdef Py_TRACE_REFS -/* Py_TRACE_REFS is such major surgery that we call external routines. */ -PyAPI_FUNC(void) _Py_NewReference(PyObject *); -PyAPI_FUNC(void) _Py_ForgetReference(PyObject *); -PyAPI_FUNC(void) _Py_Dealloc(PyObject *); -PyAPI_FUNC(void) _Py_PrintReferences(FILE *); -PyAPI_FUNC(void) _Py_PrintReferenceAddresses(FILE *); -PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force); - -#else -/* Without Py_TRACE_REFS, there's little enough to do that we expand code - * inline. - */ -#define _Py_NewReference(op) ( \ - _Py_INC_TPALLOCS(op) _Py_COUNT_ALLOCS_COMMA \ - _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ - (op)->ob_refcnt = 1) - -#define _Py_ForgetReference(op) _Py_INC_TPFREES(op) - -#define _Py_Dealloc(op) ( \ - _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA \ - (*(op)->ob_type->tp_dealloc)((PyObject *)(op))) -#endif /* !Py_TRACE_REFS */ - -#define Py_INCREF(op) ( \ - _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ - (op)->ob_refcnt++) - -#define Py_DECREF(op) \ - if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \ - --(op)->ob_refcnt != 0) \ - _Py_CHECK_REFCNT(op) \ - else \ - _Py_Dealloc((PyObject *)(op)) - -/* Macros to use in case the object pointer may be NULL: */ -#define Py_XINCREF(op) if ((op) == NULL) ; else Py_INCREF(op) -#define Py_XDECREF(op) if ((op) == NULL) ; else Py_DECREF(op) - -/* -_Py_NoneStruct is an object of undefined type which can be used in contexts -where NULL (nil) is not suitable (since NULL often means 'error'). - -Don't forget to apply Py_INCREF() when returning this value!!! -*/ -PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */ -#define Py_None (&_Py_NoneStruct) - -/* -Py_NotImplemented is a singleton used to signal that an operation is -not implemented for a given type combination. -*/ -PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */ -#define Py_NotImplemented (&_Py_NotImplementedStruct) - -/* Rich comparison opcodes */ -#define Py_LT 0 -#define Py_LE 1 -#define Py_EQ 2 -#define Py_NE 3 -#define Py_GT 4 -#define Py_GE 5 - -/* -Define staticforward and statichere for source compatibility with old -C extensions. - -The staticforward define was needed to support certain broken C -compilers (notably SCO ODT 3.0, perhaps early AIX as well) botched the -static keyword when it was used with a forward declaration of a static -initialized structure. Standard C allows the forward declaration with -static, and we've decided to stop catering to broken C compilers. -(In fact, we expect that the compilers are all fixed eight years later.) -*/ - -#define staticforward static -#define statichere static - - -/* -More conventions -================ - -Argument Checking ------------------ - -Functions that take objects as arguments normally don't check for nil -arguments, but they do check the type of the argument, and return an -error if the function doesn't apply to the type. - -Failure Modes -------------- - -Functions may fail for a variety of reasons, including running out of -memory. This is communicated to the caller in two ways: an error string -is set (see errors.h), and the function result differs: functions that -normally return a pointer return NULL for failure, functions returning -an integer return -1 (which could be a legal return value too!), and -other functions return 0 for success and -1 for failure. -Callers should always check for errors before using the result. If -an error was set, the caller must either explicitly clear it, or pass -the error on to its caller. - -Reference Counts ----------------- - -It takes a while to get used to the proper usage of reference counts. - -Functions that create an object set the reference count to 1; such new -objects must be stored somewhere or destroyed again with Py_DECREF(). -Some functions that 'store' objects, such as PyTuple_SetItem() and -PyList_SetItem(), -don't increment the reference count of the object, since the most -frequent use is to store a fresh object. Functions that 'retrieve' -objects, such as PyTuple_GetItem() and PyDict_GetItemString(), also -don't increment -the reference count, since most frequently the object is only looked at -quickly. Thus, to retrieve an object and store it again, the caller -must call Py_INCREF() explicitly. - -NOTE: functions that 'consume' a reference count, like -PyList_SetItem(), consume the reference even if the object wasn't -successfully stored, to simplify error handling. - -It seems attractive to make other functions that take an object as -argument consume a reference count; however, this may quickly get -confusing (even the current practice is already confusing). Consider -it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at -times. -*/ - - -/* Trashcan mechanism, thanks to Christian Tismer. - -When deallocating a container object, it's possible to trigger an unbounded -chain of deallocations, as each Py_DECREF in turn drops the refcount on "the -next" object in the chain to 0. This can easily lead to stack faults, and -especially in threads (which typically have less stack space to work with). - -A container object that participates in cyclic gc can avoid this by -bracketing the body of its tp_dealloc function with a pair of macros: - -static void -mytype_dealloc(mytype *p) -{ - ... declarations go here ... - - PyObject_GC_UnTrack(p); // must untrack first - Py_TRASHCAN_SAFE_BEGIN(p) - ... The body of the deallocator goes here, including all calls ... - ... to Py_DECREF on contained objects. ... - Py_TRASHCAN_SAFE_END(p) -} - -CAUTION: Never return from the middle of the body! If the body needs to -"get out early", put a label immediately before the Py_TRASHCAN_SAFE_END -call, and goto it. Else the call-depth counter (see below) will stay -above 0 forever, and the trashcan will never get emptied. - -How it works: The BEGIN macro increments a call-depth counter. So long -as this counter is small, the body of the deallocator is run directly without -further ado. But if the counter gets large, it instead adds p to a list of -objects to be deallocated later, skips the body of the deallocator, and -resumes execution after the END macro. The tp_dealloc routine then returns -without deallocating anything (and so unbounded call-stack depth is avoided). - -When the call stack finishes unwinding again, code generated by the END macro -notices this, and calls another routine to deallocate all the objects that -may have been added to the list of deferred deallocations. In effect, a -chain of N deallocations is broken into N / PyTrash_UNWIND_LEVEL pieces, -with the call stack never exceeding a depth of PyTrash_UNWIND_LEVEL. -*/ - -PyAPI_FUNC(void) _PyTrash_deposit_object(PyObject*); -PyAPI_FUNC(void) _PyTrash_destroy_chain(void); -PyAPI_DATA(int) _PyTrash_delete_nesting; -PyAPI_DATA(PyObject *) _PyTrash_delete_later; - -#define PyTrash_UNWIND_LEVEL 50 - -#define Py_TRASHCAN_SAFE_BEGIN(op) \ - if (_PyTrash_delete_nesting < PyTrash_UNWIND_LEVEL) { \ - ++_PyTrash_delete_nesting; - /* The body of the deallocator is here. */ -#define Py_TRASHCAN_SAFE_END(op) \ - --_PyTrash_delete_nesting; \ - if (_PyTrash_delete_later && _PyTrash_delete_nesting <= 0) \ - _PyTrash_destroy_chain(); \ - } \ - else \ - _PyTrash_deposit_object((PyObject*)op); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_OBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/objimpl.h b/SDKs/XPlatform/Cypython-2.3.3/include/objimpl.h deleted file mode 100644 index 19773097..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/objimpl.h +++ /dev/null @@ -1,326 +0,0 @@ -/* The PyObject_ memory family: high-level object memory interfaces. - See pymem.h for the low-level PyMem_ family. -*/ - -#ifndef Py_OBJIMPL_H -#define Py_OBJIMPL_H - -#include "pymem.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* BEWARE: - - Each interface exports both functions and macros. Extension modules should - use the functions, to ensure binary compatibility across Python versions. - Because the Python implementation is free to change internal details, and - the macros may (or may not) expose details for speed, if you do use the - macros you must recompile your extensions with each Python release. - - Never mix calls to PyObject_ memory functions with calls to the platform - malloc/realloc/ calloc/free, or with calls to PyMem_. -*/ - -/* -Functions and macros for modules that implement new object types. - - - PyObject_New(type, typeobj) allocates memory for a new object of the given - type, and initializes part of it. 'type' must be the C structure type used - to represent the object, and 'typeobj' the address of the corresponding - type object. Reference count and type pointer are filled in; the rest of - the bytes of the object are *undefined*! The resulting expression type is - 'type *'. The size of the object is determined by the tp_basicsize field - of the type object. - - - PyObject_NewVar(type, typeobj, n) is similar but allocates a variable-size - object with room for n items. In addition to the refcount and type pointer - fields, this also fills in the ob_size field. - - - PyObject_Del(op) releases the memory allocated for an object. It does not - run a destructor -- it only frees the memory. PyObject_Free is identical. - - - PyObject_Init(op, typeobj) and PyObject_InitVar(op, typeobj, n) don't - allocate memory. Instead of a 'type' parameter, they take a pointer to a - new object (allocated by an arbitrary allocator), and initialize its object - header fields. - -Note that objects created with PyObject_{New, NewVar} are allocated using the -specialized Python allocator (implemented in obmalloc.c), if WITH_PYMALLOC is -enabled. In addition, a special debugging allocator is used if PYMALLOC_DEBUG -is also #defined. - -In case a specific form of memory management is needed (for example, if you -must use the platform malloc heap(s), or shared memory, or C++ local storage or -operator new), you must first allocate the object with your custom allocator, -then pass its pointer to PyObject_{Init, InitVar} for filling in its Python- -specific fields: reference count, type pointer, possibly others. You should -be aware that Python no control over these objects because they don't -cooperate with the Python memory manager. Such objects may not be eligible -for automatic garbage collection and you have to make sure that they are -released accordingly whenever their destructor gets called (cf. the specific -form of memory management you're using). - -Unless you have specific memory management requirements, use -PyObject_{New, NewVar, Del}. -*/ - -/* - * Raw object memory interface - * =========================== - */ - -/* Functions to call the same malloc/realloc/free as used by Python's - object allocator. If WITH_PYMALLOC is enabled, these may differ from - the platform malloc/realloc/free. The Python object allocator is - designed for fast, cache-conscious allocation of many "small" objects, - and with low hidden memory overhead. - - PyObject_Malloc(0) returns a unique non-NULL pointer if possible. - - PyObject_Realloc(NULL, n) acts like PyObject_Malloc(n). - PyObject_Realloc(p != NULL, 0) does not return NULL, or free the memory - at p. - - Returned pointers must be checked for NULL explicitly; no action is - performed on failure other than to return NULL (no warning it printed, no - exception is set, etc). - - For allocating objects, use PyObject_{New, NewVar} instead whenever - possible. The PyObject_{Malloc, Realloc, Free} family is exposed - so that you can exploit Python's small-block allocator for non-object - uses. If you must use these routines to allocate object memory, make sure - the object gets initialized via PyObject_{Init, InitVar} after obtaining - the raw memory. -*/ -PyAPI_FUNC(void *) PyObject_Malloc(size_t); -PyAPI_FUNC(void *) PyObject_Realloc(void *, size_t); -PyAPI_FUNC(void) PyObject_Free(void *); - - -/* Macros */ -#ifdef WITH_PYMALLOC -#ifdef PYMALLOC_DEBUG -PyAPI_FUNC(void *) _PyObject_DebugMalloc(size_t nbytes); -PyAPI_FUNC(void *) _PyObject_DebugRealloc(void *p, size_t nbytes); -PyAPI_FUNC(void) _PyObject_DebugFree(void *p); -PyAPI_FUNC(void) _PyObject_DebugDumpAddress(const void *p); -PyAPI_FUNC(void) _PyObject_DebugCheckAddress(const void *p); -PyAPI_FUNC(void) _PyObject_DebugMallocStats(void); -#define PyObject_MALLOC _PyObject_DebugMalloc -#define PyObject_Malloc _PyObject_DebugMalloc -#define PyObject_REALLOC _PyObject_DebugRealloc -#define PyObject_Realloc _PyObject_DebugRealloc -#define PyObject_FREE _PyObject_DebugFree -#define PyObject_Free _PyObject_DebugFree - -#else /* WITH_PYMALLOC && ! PYMALLOC_DEBUG */ -#define PyObject_MALLOC PyObject_Malloc -#define PyObject_REALLOC PyObject_Realloc -#define PyObject_FREE PyObject_Free -#endif - -#else /* ! WITH_PYMALLOC */ -#define PyObject_MALLOC PyMem_MALLOC -#define PyObject_REALLOC PyMem_REALLOC -/* This is an odd one! For backward compatability with old extensions, the - PyMem "release memory" functions have to invoke the object allocator's - free() function. When pymalloc isn't enabled, that leaves us using - the platform free(). */ -#define PyObject_FREE free - -#endif /* WITH_PYMALLOC */ - -#define PyObject_Del PyObject_Free -#define PyObject_DEL PyObject_FREE - -/* for source compatibility with 2.2 */ -#define _PyObject_Del PyObject_Free - -/* - * Generic object allocator interface - * ================================== - */ - -/* Functions */ -PyAPI_FUNC(PyObject *) PyObject_Init(PyObject *, PyTypeObject *); -PyAPI_FUNC(PyVarObject *) PyObject_InitVar(PyVarObject *, - PyTypeObject *, int); -PyAPI_FUNC(PyObject *) _PyObject_New(PyTypeObject *); -PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, int); - -#define PyObject_New(type, typeobj) \ - ( (type *) _PyObject_New(typeobj) ) -#define PyObject_NewVar(type, typeobj, n) \ - ( (type *) _PyObject_NewVar((typeobj), (n)) ) - -/* Macros trading binary compatibility for speed. See also pymem.h. - Note that these macros expect non-NULL object pointers.*/ -#define PyObject_INIT(op, typeobj) \ - ( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) -#define PyObject_INIT_VAR(op, typeobj, size) \ - ( (op)->ob_size = (size), PyObject_INIT((op), (typeobj)) ) - -#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize ) - -/* _PyObject_VAR_SIZE returns the number of bytes (as size_t) allocated for a - vrbl-size object with nitems items, exclusive of gc overhead (if any). The - value is rounded up to the closest multiple of sizeof(void *), in order to - ensure that pointer fields at the end of the object are correctly aligned - for the platform (this is of special importance for subclasses of, e.g., - str or long, so that pointers can be stored after the embedded data). - - Note that there's no memory wastage in doing this, as malloc has to - return (at worst) pointer-aligned memory anyway. -*/ -#if ((SIZEOF_VOID_P - 1) & SIZEOF_VOID_P) != 0 -# error "_PyObject_VAR_SIZE requires SIZEOF_VOID_P be a power of 2" -#endif - -#define _PyObject_VAR_SIZE(typeobj, nitems) \ - (size_t) \ - ( ( (typeobj)->tp_basicsize + \ - (nitems)*(typeobj)->tp_itemsize + \ - (SIZEOF_VOID_P - 1) \ - ) & ~(SIZEOF_VOID_P - 1) \ - ) - -#define PyObject_NEW(type, typeobj) \ -( (type *) PyObject_Init( \ - (PyObject *) PyObject_MALLOC( _PyObject_SIZE(typeobj) ), (typeobj)) ) - -#define PyObject_NEW_VAR(type, typeobj, n) \ -( (type *) PyObject_InitVar( \ - (PyVarObject *) PyObject_MALLOC(_PyObject_VAR_SIZE((typeobj),(n)) ),\ - (typeobj), (n)) ) - -/* This example code implements an object constructor with a custom - allocator, where PyObject_New is inlined, and shows the important - distinction between two steps (at least): - 1) the actual allocation of the object storage; - 2) the initialization of the Python specific fields - in this storage with PyObject_{Init, InitVar}. - - PyObject * - YourObject_New(...) - { - PyObject *op; - - op = (PyObject *) Your_Allocator(_PyObject_SIZE(YourTypeStruct)); - if (op == NULL) - return PyErr_NoMemory(); - - PyObject_Init(op, &YourTypeStruct); - - op->ob_field = value; - ... - return op; - } - - Note that in C++, the use of the new operator usually implies that - the 1st step is performed automatically for you, so in a C++ class - constructor you would start directly with PyObject_Init/InitVar -*/ - -/* - * Garbage Collection Support - * ========================== - */ - -/* C equivalent of gc.collect(). */ -long PyGC_Collect(void); - -/* Test if a type has a GC head */ -#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC) - -/* Test if an object has a GC head */ -#define PyObject_IS_GC(o) (PyType_IS_GC((o)->ob_type) && \ - ((o)->ob_type->tp_is_gc == NULL || (o)->ob_type->tp_is_gc(o))) - -PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, int); -#define PyObject_GC_Resize(type, op, n) \ - ( (type *) _PyObject_GC_Resize((PyVarObject *)(op), (n)) ) - -/* for source compatibility with 2.2 */ -#define _PyObject_GC_Del PyObject_GC_Del - -/* GC information is stored BEFORE the object structure. */ -typedef union _gc_head { - struct { - union _gc_head *gc_next; - union _gc_head *gc_prev; - int gc_refs; - } gc; - long double dummy; /* force worst-case alignment */ -} PyGC_Head; - -extern PyGC_Head *_PyGC_generation0; - -#define _Py_AS_GC(o) ((PyGC_Head *)(o)-1) - -#define _PyGC_REFS_UNTRACKED (-2) -#define _PyGC_REFS_REACHABLE (-3) -#define _PyGC_REFS_TENTATIVELY_UNREACHABLE (-4) - -/* Tell the GC to track this object. NB: While the object is tracked the - * collector it must be safe to call the ob_traverse method. */ -#define _PyObject_GC_TRACK(o) do { \ - PyGC_Head *g = _Py_AS_GC(o); \ - if (g->gc.gc_refs != _PyGC_REFS_UNTRACKED) \ - Py_FatalError("GC object already tracked"); \ - g->gc.gc_refs = _PyGC_REFS_REACHABLE; \ - g->gc.gc_next = _PyGC_generation0; \ - g->gc.gc_prev = _PyGC_generation0->gc.gc_prev; \ - g->gc.gc_prev->gc.gc_next = g; \ - _PyGC_generation0->gc.gc_prev = g; \ - } while (0); - -/* Tell the GC to stop tracking this object. - * gc_next doesn't need to be set to NULL, but doing so is a good - * way to provoke memory errors if calling code is confused. - */ -#define _PyObject_GC_UNTRACK(o) do { \ - PyGC_Head *g = _Py_AS_GC(o); \ - assert(g->gc.gc_refs != _PyGC_REFS_UNTRACKED); \ - g->gc.gc_refs = _PyGC_REFS_UNTRACKED; \ - g->gc.gc_prev->gc.gc_next = g->gc.gc_next; \ - g->gc.gc_next->gc.gc_prev = g->gc.gc_prev; \ - g->gc.gc_next = NULL; \ - } while (0); - -PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t); -PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *); -PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, int); -PyAPI_FUNC(void) PyObject_GC_Track(void *); -PyAPI_FUNC(void) PyObject_GC_UnTrack(void *); -PyAPI_FUNC(void) PyObject_GC_Del(void *); - -#define PyObject_GC_New(type, typeobj) \ - ( (type *) _PyObject_GC_New(typeobj) ) -#define PyObject_GC_NewVar(type, typeobj, n) \ - ( (type *) _PyObject_GC_NewVar((typeobj), (n)) ) - - -/* This is here for the sake of backwards compatibility. Extensions that - * use the old GC API will still compile but the objects will not be - * tracked by the GC. */ -#define PyGC_HEAD_SIZE 0 -#define PyObject_GC_Init(op) -#define PyObject_GC_Fini(op) -#define PyObject_AS_GC(op) (op) -#define PyObject_FROM_GC(op) (op) - - -/* Test if a type supports weak references */ -#define PyType_SUPPORTS_WEAKREFS(t) \ - (PyType_HasFeature((t), Py_TPFLAGS_HAVE_WEAKREFS) \ - && ((t)->tp_weaklistoffset > 0)) - -#define PyObject_GET_WEAKREFS_LISTPTR(o) \ - ((PyObject **) (((char *) (o)) + (o)->ob_type->tp_weaklistoffset)) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_OBJIMPL_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/opcode.h b/SDKs/XPlatform/Cypython-2.3.3/include/opcode.h deleted file mode 100644 index 684f5714..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/opcode.h +++ /dev/null @@ -1,151 +0,0 @@ -#ifndef Py_OPCODE_H -#define Py_OPCODE_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Instruction opcodes for compiled code */ - -#define STOP_CODE 0 -#define POP_TOP 1 -#define ROT_TWO 2 -#define ROT_THREE 3 -#define DUP_TOP 4 -#define ROT_FOUR 5 - -#define UNARY_POSITIVE 10 -#define UNARY_NEGATIVE 11 -#define UNARY_NOT 12 -#define UNARY_CONVERT 13 - -#define UNARY_INVERT 15 - -#define BINARY_POWER 19 - -#define BINARY_MULTIPLY 20 -#define BINARY_DIVIDE 21 -#define BINARY_MODULO 22 -#define BINARY_ADD 23 -#define BINARY_SUBTRACT 24 -#define BINARY_SUBSCR 25 -#define BINARY_FLOOR_DIVIDE 26 -#define BINARY_TRUE_DIVIDE 27 -#define INPLACE_FLOOR_DIVIDE 28 -#define INPLACE_TRUE_DIVIDE 29 - -#define SLICE 30 -/* Also uses 31-33 */ - -#define STORE_SLICE 40 -/* Also uses 41-43 */ - -#define DELETE_SLICE 50 -/* Also uses 51-53 */ - -#define INPLACE_ADD 55 -#define INPLACE_SUBTRACT 56 -#define INPLACE_MULTIPLY 57 -#define INPLACE_DIVIDE 58 -#define INPLACE_MODULO 59 -#define STORE_SUBSCR 60 -#define DELETE_SUBSCR 61 - -#define BINARY_LSHIFT 62 -#define BINARY_RSHIFT 63 -#define BINARY_AND 64 -#define BINARY_XOR 65 -#define BINARY_OR 66 -#define INPLACE_POWER 67 -#define GET_ITER 68 - -#define PRINT_EXPR 70 -#define PRINT_ITEM 71 -#define PRINT_NEWLINE 72 -#define PRINT_ITEM_TO 73 -#define PRINT_NEWLINE_TO 74 -#define INPLACE_LSHIFT 75 -#define INPLACE_RSHIFT 76 -#define INPLACE_AND 77 -#define INPLACE_XOR 78 -#define INPLACE_OR 79 -#define BREAK_LOOP 80 - -#define LOAD_LOCALS 82 -#define RETURN_VALUE 83 -#define IMPORT_STAR 84 -#define EXEC_STMT 85 -#define YIELD_VALUE 86 - -#define POP_BLOCK 87 -#define END_FINALLY 88 -#define BUILD_CLASS 89 - -#define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */ - -#define STORE_NAME 90 /* Index in name list */ -#define DELETE_NAME 91 /* "" */ -#define UNPACK_SEQUENCE 92 /* Number of sequence items */ -#define FOR_ITER 93 - -#define STORE_ATTR 95 /* Index in name list */ -#define DELETE_ATTR 96 /* "" */ -#define STORE_GLOBAL 97 /* "" */ -#define DELETE_GLOBAL 98 /* "" */ -#define DUP_TOPX 99 /* number of items to duplicate */ -#define LOAD_CONST 100 /* Index in const list */ -#define LOAD_NAME 101 /* Index in name list */ -#define BUILD_TUPLE 102 /* Number of tuple items */ -#define BUILD_LIST 103 /* Number of list items */ -#define BUILD_MAP 104 /* Always zero for now */ -#define LOAD_ATTR 105 /* Index in name list */ -#define COMPARE_OP 106 /* Comparison operator */ -#define IMPORT_NAME 107 /* Index in name list */ -#define IMPORT_FROM 108 /* Index in name list */ - -#define JUMP_FORWARD 110 /* Number of bytes to skip */ -#define JUMP_IF_FALSE 111 /* "" */ -#define JUMP_IF_TRUE 112 /* "" */ -#define JUMP_ABSOLUTE 113 /* Target byte offset from beginning of code */ - -#define LOAD_GLOBAL 116 /* Index in name list */ - -#define CONTINUE_LOOP 119 /* Start of loop (absolute) */ -#define SETUP_LOOP 120 /* Target address (absolute) */ -#define SETUP_EXCEPT 121 /* "" */ -#define SETUP_FINALLY 122 /* "" */ - -#define LOAD_FAST 124 /* Local variable number */ -#define STORE_FAST 125 /* Local variable number */ -#define DELETE_FAST 126 /* Local variable number */ - -#define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */ -/* CALL_FUNCTION_XXX opcodes defined below depend on this definition */ -#define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */ -#define MAKE_FUNCTION 132 /* #defaults */ -#define BUILD_SLICE 133 /* Number of items */ - -#define MAKE_CLOSURE 134 /* #free vars */ -#define LOAD_CLOSURE 135 /* Load free variable from closure */ -#define LOAD_DEREF 136 /* Load and dereference from closure cell */ -#define STORE_DEREF 137 /* Store into cell */ - -/* The next 3 opcodes must be contiguous and satisfy - (CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */ -#define CALL_FUNCTION_VAR 140 /* #args + (#kwargs<<8) */ -#define CALL_FUNCTION_KW 141 /* #args + (#kwargs<<8) */ -#define CALL_FUNCTION_VAR_KW 142 /* #args + (#kwargs<<8) */ - -/* Support for opargs more than 16 bits long */ -#define EXTENDED_ARG 143 - - -enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, PyCmp_GT=Py_GT, PyCmp_GE=Py_GE, - PyCmp_IN, PyCmp_NOT_IN, PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD}; - -#define HAS_ARG(op) ((op) >= HAVE_ARGUMENT) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_OPCODE_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/osdefs.h b/SDKs/XPlatform/Cypython-2.3.3/include/osdefs.h deleted file mode 100644 index c2411141..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/osdefs.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef Py_OSDEFS_H -#define Py_OSDEFS_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Operating system dependencies */ - -#ifdef macintosh -#define SEP ':' -#define MAXPATHLEN 256 -/* Mod by Jack: newline is less likely to occur in filenames than space */ -#define DELIM '\n' -#endif - -/* Mod by chrish: QNX has WATCOM, but isn't DOS */ -#if !defined(__QNX__) -#if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__) || defined(PYOS_OS2) -#if defined(PYOS_OS2) && defined(PYCC_GCC) -#define MAXPATHLEN 260 -#define SEP '/' -#define ALTSEP '\\' -#else -#define SEP '\\' -#define ALTSEP '/' -#define MAXPATHLEN 256 -#endif -#define DELIM ';' -#endif -#endif - -#ifdef RISCOS -#define SEP '.' -#define MAXPATHLEN 256 -#define DELIM ',' -#endif - - -/* Filename separator */ -#ifndef SEP -#define SEP '/' -#endif - -/* Max pathname length */ -#ifndef MAXPATHLEN -#define MAXPATHLEN 1024 -#endif - -/* Search path entry delimiter */ -#ifndef DELIM -#define DELIM ':' -#endif - -#ifdef __cplusplus -} -#endif -#endif /* !Py_OSDEFS_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/parsetok.h b/SDKs/XPlatform/Cypython-2.3.3/include/parsetok.h deleted file mode 100644 index 9e0ebb8c..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/parsetok.h +++ /dev/null @@ -1,48 +0,0 @@ - -/* Parser-tokenizer link interface */ - -#ifndef Py_PARSETOK_H -#define Py_PARSETOK_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - int error; - const char *filename; - int lineno; - int offset; - char *text; - int token; - int expected; -} perrdetail; - -#if 0 -#define PyPARSE_YIELD_IS_KEYWORD 0x0001 -#endif - -#define PyPARSE_DONT_IMPLY_DEDENT 0x0002 - -PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int, - perrdetail *); -PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int, - char *, char *, perrdetail *); - -PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int, - perrdetail *, int); -PyAPI_FUNC(node *) PyParser_ParseFileFlags(FILE *, const char *, grammar *, - int, char *, char *, - perrdetail *, int); - -PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(const char *, - const char *, - grammar *, int, - perrdetail *, int); - -/* Note that he following function is defined in pythonrun.c not parsetok.c. */ -PyAPI_FUNC(void) PyParser_SetError(perrdetail *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PARSETOK_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/patchlevel.h b/SDKs/XPlatform/Cypython-2.3.3/include/patchlevel.h deleted file mode 100644 index 582674cf..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/patchlevel.h +++ /dev/null @@ -1,37 +0,0 @@ - -/* Newfangled version identification scheme. - - This scheme was added in Python 1.5.2b2; before that time, only PATCHLEVEL - was available. To test for presence of the scheme, test for - defined(PY_MAJOR_VERSION). - - When the major or minor version changes, the VERSION variable in - configure.in must also be changed. - - There is also (independent) API version information in modsupport.h. -*/ - -/* Values for PY_RELEASE_LEVEL */ -#define PY_RELEASE_LEVEL_ALPHA 0xA -#define PY_RELEASE_LEVEL_BETA 0xB -#define PY_RELEASE_LEVEL_GAMMA 0xC -#define PY_RELEASE_LEVEL_FINAL 0xF /* Serial should be 0 here */ - /* Higher for patch releases */ - -/* Version parsed out into numeric values */ -#define PY_MAJOR_VERSION 2 -#define PY_MINOR_VERSION 3 -#define PY_MICRO_VERSION 3 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL -#define PY_RELEASE_SERIAL 0 - -/* Version as a string */ -#define PY_VERSION "2.3.3" - -/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. - Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */ -#define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \ - (PY_MINOR_VERSION << 16) | \ - (PY_MICRO_VERSION << 8) | \ - (PY_RELEASE_LEVEL << 4) | \ - (PY_RELEASE_SERIAL << 0)) diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/pgen.h b/SDKs/XPlatform/Cypython-2.3.3/include/pgen.h deleted file mode 100644 index af84852b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/pgen.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef Py_PGEN_H -#define Py_PGEN_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Parser generator interface */ - -extern grammar *meta_grammar(void); - -struct _node; -extern grammar *pgen(struct _node *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PGEN_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/pgenheaders.h b/SDKs/XPlatform/Cypython-2.3.3/include/pgenheaders.h deleted file mode 100644 index 7aac4e2b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/pgenheaders.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef Py_PGENHEADERS_H -#define Py_PGENHEADERS_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Include files and extern declarations used by most of the parser. */ - -#include "Python.h" - -PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); -PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); - -#define addarc _Py_addarc -#define addbit _Py_addbit -#define adddfa _Py_adddfa -#define addfirstsets _Py_addfirstsets -#define addlabel _Py_addlabel -#define addstate _Py_addstate -#define delbitset _Py_delbitset -#define dumptree _Py_dumptree -#define findlabel _Py_findlabel -#define mergebitset _Py_mergebitset -#define meta_grammar _Py_meta_grammar -#define newbitset _Py_newbitset -#define newgrammar _Py_newgrammar -#define pgen _Py_pgen -#define printgrammar _Py_printgrammar -#define printnonterminals _Py_printnonterminals -#define printtree _Py_printtree -#define samebitset _Py_samebitset -#define showtree _Py_showtree -#define tok_dump _Py_tok_dump -#define translatelabels _Py_translatelabels - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PGENHEADERS_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/py_curses.h b/SDKs/XPlatform/Cypython-2.3.3/include/py_curses.h deleted file mode 100644 index 71163db4..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/py_curses.h +++ /dev/null @@ -1,176 +0,0 @@ - -#ifndef Py_CURSES_H -#define Py_CURSES_H - -#ifdef __APPLE__ -/* -** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards -** against multiple definition of wchar_t. -*/ -#ifdef _BSD_WCHAR_T_DEFINED_ -#define _WCHAR_T -#endif -#endif - -#ifdef __FreeBSD__ -/* -** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards -** against multiple definition of wchar_t and wint_t. -*/ -#ifdef _XOPEN_SOURCE_EXTENDED -#ifndef __FreeBSD_version -#include -#endif -#if __FreeBSD_version >= 500000 -#ifndef __wchar_t -#define __wchar_t -#endif -#ifndef __wint_t -#define __wint_t -#endif -#else -#ifndef _WCHAR_T -#define _WCHAR_T -#endif -#ifndef _WINT_T -#define _WINT_T -#endif -#endif -#endif -#endif - -#ifdef HAVE_NCURSES_H -#include -#else -#include -#ifdef HAVE_TERM_H -/* for tigetstr, which is not declared in SysV curses */ -#include -#endif -#endif - -#ifdef HAVE_NCURSES_H -/* configure was checking , but we will - use , which has all these features. */ -#ifndef WINDOW_HAS_FLAGS -#define WINDOW_HAS_FLAGS 1 -#endif -#ifndef MVWDELCH_IS_EXPRESSION -#define MVWDELCH_IS_EXPRESSION 1 -#endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define PyCurses_API_pointers 4 - -/* Type declarations */ - -typedef struct { - PyObject_HEAD - WINDOW *win; -} PyCursesWindowObject; - -#define PyCursesWindow_Check(v) ((v)->ob_type == &PyCursesWindow_Type) - -#ifdef CURSES_MODULE -/* This section is used when compiling _cursesmodule.c */ - -#else -/* This section is used in modules that use the _cursesmodule API */ - -static void **PyCurses_API; - -#define PyCursesWindow_Type (*(PyTypeObject *) PyCurses_API[0]) -#define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;} -#define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;} -#define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;} - -#define import_curses() \ -{ \ - PyObject *module = PyImport_ImportModule("_curses"); \ - if (module != NULL) { \ - PyObject *module_dict = PyModule_GetDict(module); \ - PyObject *c_api_object = PyDict_GetItemString(module_dict, "_C_API"); \ - if (PyCObject_Check(c_api_object)) { \ - PyCurses_API = (void **)PyCObject_AsVoidPtr(c_api_object); \ - } \ - } \ -} -#endif - -/* general error messages */ -static char *catchall_ERR = "curses function returned ERR"; -static char *catchall_NULL = "curses function returned NULL"; - -/* Function Prototype Macros - They are ugly but very, very useful. ;-) - - X - function name - TYPE - parameter Type - ERGSTR - format string for construction of the return value - PARSESTR - format string for argument parsing - */ - -#define NoArgNoReturnFunction(X) \ -static PyObject *PyCurses_ ## X (PyObject *self) \ -{ \ - PyCursesInitialised \ - return PyCursesCheckERR(X(), # X); } - -#define NoArgOrFlagNoReturnFunction(X) \ -static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ -{ \ - int flag = 0; \ - PyCursesInitialised \ - switch(PyTuple_Size(args)) { \ - case 0: \ - return PyCursesCheckERR(X(), # X); \ - case 1: \ - if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL; \ - if (flag) return PyCursesCheckERR(X(), # X); \ - else return PyCursesCheckERR(no ## X (), # X); \ - default: \ - PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \ - return NULL; } } - -#define NoArgReturnIntFunction(X) \ -static PyObject *PyCurses_ ## X (PyObject *self) \ -{ \ - PyCursesInitialised \ - return PyInt_FromLong((long) X()); } - - -#define NoArgReturnStringFunction(X) \ -static PyObject *PyCurses_ ## X (PyObject *self) \ -{ \ - PyCursesInitialised \ - return PyString_FromString(X()); } - -#define NoArgTrueFalseFunction(X) \ -static PyObject *PyCurses_ ## X (PyObject *self) \ -{ \ - PyCursesInitialised \ - if (X () == FALSE) { \ - Py_INCREF(Py_False); \ - return Py_False; \ - } \ - Py_INCREF(Py_True); \ - return Py_True; } - -#define NoArgNoReturnVoidFunction(X) \ -static PyObject *PyCurses_ ## X (PyObject *self) \ -{ \ - PyCursesInitialised \ - X(); \ - Py_INCREF(Py_None); \ - return Py_None; } - -#ifdef __cplusplus -} -#endif - -#endif /* !defined(Py_CURSES_H) */ - - diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/pydebug.h b/SDKs/XPlatform/Cypython-2.3.3/include/pydebug.h deleted file mode 100644 index 9308a8d6..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/pydebug.h +++ /dev/null @@ -1,39 +0,0 @@ - -#ifndef Py_PYDEBUG_H -#define Py_PYDEBUG_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(int) Py_DebugFlag; -PyAPI_DATA(int) Py_VerboseFlag; -PyAPI_DATA(int) Py_InteractiveFlag; -PyAPI_DATA(int) Py_OptimizeFlag; -PyAPI_DATA(int) Py_NoSiteFlag; -PyAPI_DATA(int) Py_UseClassExceptionsFlag; -PyAPI_DATA(int) Py_FrozenFlag; -PyAPI_DATA(int) Py_TabcheckFlag; -PyAPI_DATA(int) Py_UnicodeFlag; -PyAPI_DATA(int) Py_IgnoreEnvironmentFlag; -PyAPI_DATA(int) Py_DivisionWarningFlag; -/* _XXX Py_QnewFlag should go away in 3.0. It's true iff -Qnew is passed, - on the command line, and is used in 2.2 by ceval.c to make all "/" divisions - true divisions (which they will be in 3.0). */ -PyAPI_DATA(int) _Py_QnewFlag; - -/* this is a wrapper around getenv() that pays attention to - Py_IgnoreEnvironmentFlag. It should be used for getting variables like - PYTHONPATH and PYTHONHOME from the environment */ -#if _XBOX -// Don't even have getenv in the code for Xbox, it'll cause a link error in release mode -#define Py_GETENV(s) NULL -#else -#define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s)) -#endif - -PyAPI_FUNC(void) Py_FatalError(const char *message); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PYDEBUG_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/pyerrors.h b/SDKs/XPlatform/Cypython-2.3.3/include/pyerrors.h deleted file mode 100644 index 38737127..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/pyerrors.h +++ /dev/null @@ -1,233 +0,0 @@ -#ifndef Py_ERRORS_H -#define Py_ERRORS_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Error handling definitions */ - -PyAPI_FUNC(void) PyErr_SetNone(PyObject *); -PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *); -PyAPI_FUNC(void) PyErr_SetString(PyObject *, const char *); -PyAPI_FUNC(PyObject *) PyErr_Occurred(void); -PyAPI_FUNC(void) PyErr_Clear(void); -PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **); -PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *); - -/* Error testing and normalization */ -PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *); -PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *); -PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**); - - -/* Predefined exceptions */ - -PyAPI_DATA(PyObject *) PyExc_Exception; -PyAPI_DATA(PyObject *) PyExc_StopIteration; -PyAPI_DATA(PyObject *) PyExc_StandardError; -PyAPI_DATA(PyObject *) PyExc_ArithmeticError; -PyAPI_DATA(PyObject *) PyExc_LookupError; - -PyAPI_DATA(PyObject *) PyExc_AssertionError; -PyAPI_DATA(PyObject *) PyExc_AttributeError; -PyAPI_DATA(PyObject *) PyExc_EOFError; -PyAPI_DATA(PyObject *) PyExc_FloatingPointError; -PyAPI_DATA(PyObject *) PyExc_EnvironmentError; -PyAPI_DATA(PyObject *) PyExc_IOError; -PyAPI_DATA(PyObject *) PyExc_OSError; -PyAPI_DATA(PyObject *) PyExc_ImportError; -PyAPI_DATA(PyObject *) PyExc_IndexError; -PyAPI_DATA(PyObject *) PyExc_KeyError; -PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt; -PyAPI_DATA(PyObject *) PyExc_MemoryError; -PyAPI_DATA(PyObject *) PyExc_NameError; -PyAPI_DATA(PyObject *) PyExc_OverflowError; -PyAPI_DATA(PyObject *) PyExc_RuntimeError; -PyAPI_DATA(PyObject *) PyExc_NotImplementedError; -PyAPI_DATA(PyObject *) PyExc_SyntaxError; -PyAPI_DATA(PyObject *) PyExc_IndentationError; -PyAPI_DATA(PyObject *) PyExc_TabError; -PyAPI_DATA(PyObject *) PyExc_ReferenceError; -PyAPI_DATA(PyObject *) PyExc_SystemError; -PyAPI_DATA(PyObject *) PyExc_SystemExit; -PyAPI_DATA(PyObject *) PyExc_TypeError; -PyAPI_DATA(PyObject *) PyExc_UnboundLocalError; -PyAPI_DATA(PyObject *) PyExc_UnicodeError; -PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError; -PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError; -PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError; -PyAPI_DATA(PyObject *) PyExc_ValueError; -PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError; -#ifdef MS_WINDOWS -PyAPI_DATA(PyObject *) PyExc_WindowsError; -#endif -#ifdef __VMS -PyAPI_DATA(PyObject *) PyExc_VMSError; -#endif - -PyAPI_DATA(PyObject *) PyExc_MemoryErrorInst; - -/* Predefined warning categories */ -PyAPI_DATA(PyObject *) PyExc_Warning; -PyAPI_DATA(PyObject *) PyExc_UserWarning; -PyAPI_DATA(PyObject *) PyExc_DeprecationWarning; -PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning; -PyAPI_DATA(PyObject *) PyExc_SyntaxWarning; -PyAPI_DATA(PyObject *) PyExc_OverflowWarning; -PyAPI_DATA(PyObject *) PyExc_RuntimeWarning; -PyAPI_DATA(PyObject *) PyExc_FutureWarning; - - -/* Convenience functions */ - -PyAPI_FUNC(int) PyErr_BadArgument(void); -PyAPI_FUNC(PyObject *) PyErr_NoMemory(void); -PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *); -PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject( - PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(PyObject *, char *); -#ifdef Py_WIN_WIDE_FILENAMES -PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename( - PyObject *, Py_UNICODE *); -#endif /* Py_WIN_WIDE_FILENAMES */ - -PyAPI_FUNC(PyObject *) PyErr_Format(PyObject *, const char *, ...) - Py_GCC_ATTRIBUTE((format(printf, 2, 3))); - -#ifdef MS_WINDOWS -PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenameObject( - int, const char *); -PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename( - int, const char *); -#ifdef Py_WIN_WIDE_FILENAMES -PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename( - int, const Py_UNICODE *); -#endif /* Py_WIN_WIDE_FILENAMES */ -PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int); -PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject( - PyObject *,int, PyObject *); -PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename( - PyObject *,int, const char *); -#ifdef Py_WIN_WIDE_FILENAMES -PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename( - PyObject *,int, const Py_UNICODE *); -#endif /* Py_WIN_WIDE_FILENAMES */ -PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int); -#endif /* MS_WINDOWS */ - -/* Export the old function so that the existing API remains available: */ -PyAPI_FUNC(void) PyErr_BadInternalCall(void); -PyAPI_FUNC(void) _PyErr_BadInternalCall(char *filename, int lineno); -/* Mask the old API with a call to the new API for code compiled under - Python 2.0: */ -#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__) - -/* Function to create a new exception */ -PyAPI_FUNC(PyObject *) PyErr_NewException(char *name, PyObject *base, - PyObject *dict); -PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *); - -/* Issue a warning or exception */ -PyAPI_FUNC(int) PyErr_Warn(PyObject *, char *); -PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *, - const char *, int, - const char *, PyObject *); - -/* In sigcheck.c or signalmodule.c */ -PyAPI_FUNC(int) PyErr_CheckSignals(void); -PyAPI_FUNC(void) PyErr_SetInterrupt(void); - -/* Support for adding program text to SyntaxErrors */ -PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int); -PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int); - -#ifdef Py_USING_UNICODE -/* The following functions are used to create and modify unicode - exceptions from C */ - -/* create a UnicodeDecodeError object */ -PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create( - const char *, const char *, int, int, int, const char *); - -/* create a UnicodeEncodeError object */ -PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create( - const char *, const Py_UNICODE *, int, int, int, const char *); - -/* create a UnicodeTranslateError object */ -PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create( - const Py_UNICODE *, int, int, int, const char *); - -/* get the encoding attribute */ -PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *); -PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *); - -/* get the object attribute */ -PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *); -PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *); -PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *); - -/* get the value of the start attribute (the int * may not be NULL) - return 0 on success, -1 on failure */ -PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, int *); -PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, int *); -PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, int *); - -/* assign a new value to the start attribute - return 0 on success, -1 on failure */ -PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, int); -PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, int); -PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, int); - -/* get the value of the end attribute (the int *may not be NULL) - return 0 on success, -1 on failure */ -PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, int *); -PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, int *); -PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, int *); - -/* assign a new value to the end attribute - return 0 on success, -1 on failure */ -PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, int); -PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, int); -PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, int); - -/* get the value of the reason attribute */ -PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetReason(PyObject *); -PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetReason(PyObject *); -PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *); - -/* assign a new value to the reason attribute - return 0 on success, -1 on failure */ -PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason( - PyObject *, const char *); -PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason( - PyObject *, const char *); -PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason( - PyObject *, const char *); -#endif - - -/* These APIs aren't really part of the error implementation, but - often needed to format error messages; the native C lib APIs are - not available on all platforms, which is why we provide emulations - for those platforms in Python/mysnprintf.c, - WARNING: The return value of snprintf varies across platforms; do - not rely on any particular behavior; eventually the C99 defn may - be reliable. -*/ -#if defined(MS_WIN32) && !defined(HAVE_SNPRINTF) -# define HAVE_SNPRINTF -# define snprintf _snprintf -# define vsnprintf _vsnprintf -#endif - -#include -PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 3, 4))); -PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) - Py_GCC_ATTRIBUTE((format(printf, 3, 0))); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_ERRORS_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/pyfpe.h b/SDKs/XPlatform/Cypython-2.3.3/include/pyfpe.h deleted file mode 100644 index 0793d9eb..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/pyfpe.h +++ /dev/null @@ -1,176 +0,0 @@ -#ifndef Py_PYFPE_H -#define Py_PYFPE_H -#ifdef __cplusplus -extern "C" { -#endif -/* - --------------------------------------------------------------------- - / Copyright (c) 1996. \ - | The Regents of the University of California. | - | All rights reserved. | - | | - | Permission to use, copy, modify, and distribute this software for | - | any purpose without fee is hereby granted, provided that this en- | - | tire notice is included in all copies of any software which is or | - | includes a copy or modification of this software and in all | - | copies of the supporting documentation for such software. | - | | - | This work was produced at the University of California, Lawrence | - | Livermore National Laboratory under contract no. W-7405-ENG-48 | - | between the U.S. Department of Energy and The Regents of the | - | University of California for the operation of UC LLNL. | - | | - | DISCLAIMER | - | | - | This software was prepared as an account of work sponsored by an | - | agency of the United States Government. Neither the United States | - | Government nor the University of California nor any of their em- | - | ployees, makes any warranty, express or implied, or assumes any | - | liability or responsibility for the accuracy, completeness, or | - | usefulness of any information, apparatus, product, or process | - | disclosed, or represents that its use would not infringe | - | privately-owned rights. Reference herein to any specific commer- | - | cial products, process, or service by trade name, trademark, | - | manufacturer, or otherwise, does not necessarily constitute or | - | imply its endorsement, recommendation, or favoring by the United | - | States Government or the University of California. The views and | - | opinions of authors expressed herein do not necessarily state or | - | reflect those of the United States Government or the University | - | of California, and shall not be used for advertising or product | - \ endorsement purposes. / - --------------------------------------------------------------------- -*/ - -/* - * Define macros for handling SIGFPE. - * Lee Busby, LLNL, November, 1996 - * busby1@llnl.gov - * - ********************************************* - * Overview of the system for handling SIGFPE: - * - * This file (Include/pyfpe.h) defines a couple of "wrapper" macros for - * insertion into your Python C code of choice. Their proper use is - * discussed below. The file Python/pyfpe.c defines a pair of global - * variables PyFPE_jbuf and PyFPE_counter which are used by the signal - * handler for SIGFPE to decide if a particular exception was protected - * by the macros. The signal handler itself, and code for enabling the - * generation of SIGFPE in the first place, is in a (new) Python module - * named fpectl. This module is standard in every respect. It can be loaded - * either statically or dynamically as you choose, and like any other - * Python module, has no effect until you import it. - * - * In the general case, there are three steps toward handling SIGFPE in any - * Python code: - * - * 1) Add the *_PROTECT macros to your C code as required to protect - * dangerous floating point sections. - * - * 2) Turn on the inclusion of the code by adding the ``--with-fpectl'' - * flag at the time you run configure. If the fpectl or other modules - * which use the *_PROTECT macros are to be dynamically loaded, be - * sure they are compiled with WANT_SIGFPE_HANDLER defined. - * - * 3) When python is built and running, import fpectl, and execute - * fpectl.turnon_sigfpe(). This sets up the signal handler and enables - * generation of SIGFPE whenever an exception occurs. From this point - * on, any properly trapped SIGFPE should result in the Python - * FloatingPointError exception. - * - * Step 1 has been done already for the Python kernel code, and should be - * done soon for the NumPy array package. Step 2 is usually done once at - * python install time. Python's behavior with respect to SIGFPE is not - * changed unless you also do step 3. Thus you can control this new - * facility at compile time, or run time, or both. - * - ******************************** - * Using the macros in your code: - * - * static PyObject *foobar(PyObject *self,PyObject *args) - * { - * .... - * PyFPE_START_PROTECT("Error in foobar", return 0) - * result = dangerous_op(somearg1, somearg2, ...); - * PyFPE_END_PROTECT(result) - * .... - * } - * - * If a floating point error occurs in dangerous_op, foobar returns 0 (NULL), - * after setting the associated value of the FloatingPointError exception to - * "Error in foobar". ``Dangerous_op'' can be a single operation, or a block - * of code, function calls, or any combination, so long as no alternate - * return is possible before the PyFPE_END_PROTECT macro is reached. - * - * The macros can only be used in a function context where an error return - * can be recognized as signaling a Python exception. (Generally, most - * functions that return a PyObject * will qualify.) - * - * Guido's original design suggestion for PyFPE_START_PROTECT and - * PyFPE_END_PROTECT had them open and close a local block, with a locally - * defined jmp_buf and jmp_buf pointer. This would allow recursive nesting - * of the macros. The Ansi C standard makes it clear that such local - * variables need to be declared with the "volatile" type qualifier to keep - * setjmp from corrupting their values. Some current implementations seem - * to be more restrictive. For example, the HPUX man page for setjmp says - * - * Upon the return from a setjmp() call caused by a longjmp(), the - * values of any non-static local variables belonging to the routine - * from which setjmp() was called are undefined. Code which depends on - * such values is not guaranteed to be portable. - * - * I therefore decided on a more limited form of nesting, using a counter - * variable (PyFPE_counter) to keep track of any recursion. If an exception - * occurs in an ``inner'' pair of macros, the return will apparently - * come from the outermost level. - * - */ - -#ifdef WANT_SIGFPE_HANDLER -#include -#include -#include -extern jmp_buf PyFPE_jbuf; -extern int PyFPE_counter; -extern double PyFPE_dummy(void *); - -#define PyFPE_START_PROTECT(err_string, leave_stmt) \ -if (!PyFPE_counter++ && setjmp(PyFPE_jbuf)) { \ - PyErr_SetString(PyExc_FloatingPointError, err_string); \ - PyFPE_counter = 0; \ - leave_stmt; \ -} - -/* - * This (following) is a heck of a way to decrement a counter. However, - * unless the macro argument is provided, code optimizers will sometimes move - * this statement so that it gets executed *before* the unsafe expression - * which we're trying to protect. That pretty well messes things up, - * of course. - * - * If the expression(s) you're trying to protect don't happen to return a - * value, you will need to manufacture a dummy result just to preserve the - * correct ordering of statements. Note that the macro passes the address - * of its argument (so you need to give it something which is addressable). - * If your expression returns multiple results, pass the last such result - * to PyFPE_END_PROTECT. - * - * Note that PyFPE_dummy returns a double, which is cast to int. - * This seeming insanity is to tickle the Floating Point Unit (FPU). - * If an exception has occurred in a preceding floating point operation, - * some architectures (notably Intel 80x86) will not deliver the interrupt - * until the *next* floating point operation. This is painful if you've - * already decremented PyFPE_counter. - */ -#define PyFPE_END_PROTECT(v) PyFPE_counter -= (int)PyFPE_dummy(&(v)); - -#else - -#define PyFPE_START_PROTECT(err_string, leave_stmt) -#define PyFPE_END_PROTECT(v) - -#endif - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PYFPE_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/pygetopt.h b/SDKs/XPlatform/Cypython-2.3.3/include/pygetopt.h deleted file mode 100644 index 8031346d..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/pygetopt.h +++ /dev/null @@ -1,17 +0,0 @@ - -#ifndef Py_PYGETOPT_H -#define Py_PYGETOPT_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(int) _PyOS_opterr; -PyAPI_DATA(int) _PyOS_optind; -PyAPI_DATA(char *) _PyOS_optarg; - -PyAPI_FUNC(int) _PyOS_GetOpt(int argc, char **argv, char *optstring); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PYGETOPT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/pymactoolbox.h b/SDKs/XPlatform/Cypython-2.3.3/include/pymactoolbox.h deleted file mode 100644 index 7770f945..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/pymactoolbox.h +++ /dev/null @@ -1,204 +0,0 @@ -/* -** pymactoolbox.h - globals defined in mactoolboxglue.c -*/ -#ifndef Py_PYMACTOOLBOX_H -#define Py_PYMACTOOLBOX_H -#ifdef __cplusplus - extern "C" { -#endif - -#ifdef WITHOUT_FRAMEWORKS -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#else -#include -#include -#endif - -/* -** Helper routines for error codes and such. -*/ -char *PyMac_getscript(void); /* Get the default encoding for our 8bit character set */ -char *PyMac_StrError(int); /* strerror with mac errors */ -PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */ -PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */ -extern OSErr PyMac_GetFullPathname(FSSpec *, char *, int); /* convert fsspec->path */ -#ifdef WITH_NEXT_FRAMEWORK -extern char *PyMac_GetAppletScriptFile(void); /* Return applet script file or NULL */ -#endif -/* -** These conversion routines are defined in mactoolboxglue.c itself. -*/ -int PyMac_GetOSType(PyObject *, OSType *); /* argument parser for OSType */ -PyObject *PyMac_BuildOSType(OSType); /* Convert OSType to PyObject */ - -PyObject *PyMac_BuildNumVersion(NumVersion);/* Convert NumVersion to PyObject */ - -int PyMac_GetStr255(PyObject *, Str255); /* argument parser for Str255 */ -PyObject *PyMac_BuildStr255(Str255); /* Convert Str255 to PyObject */ -PyObject *PyMac_BuildOptStr255(Str255); /* Convert Str255 to PyObject, NULL to None */ - -int PyMac_GetRect(PyObject *, Rect *); /* argument parser for Rect */ -PyObject *PyMac_BuildRect(Rect *); /* Convert Rect to PyObject */ - -int PyMac_GetPoint(PyObject *, Point *); /* argument parser for Point */ -PyObject *PyMac_BuildPoint(Point); /* Convert Point to PyObject */ - -int PyMac_GetEventRecord(PyObject *, EventRecord *); /* argument parser for EventRecord */ -PyObject *PyMac_BuildEventRecord(EventRecord *); /* Convert EventRecord to PyObject */ - -int PyMac_GetFixed(PyObject *, Fixed *); /* argument parser for Fixed */ -PyObject *PyMac_BuildFixed(Fixed); /* Convert Fixed to PyObject */ -int PyMac_Getwide(PyObject *, wide *); /* argument parser for wide */ -PyObject *PyMac_Buildwide(wide *); /* Convert wide to PyObject */ - -/* -** The rest of the routines are implemented by extension modules. If they are -** dynamically loaded mactoolboxglue will contain a stub implementation of the -** routine, which imports the module, whereupon the module's init routine will -** communicate the routine pointer back to the stub. -** If USE_TOOLBOX_OBJECT_GLUE is not defined there is no glue code, and the -** extension modules simply declare the routine. This is the case for static -** builds (and could be the case for MacPython CFM builds, because CFM extension -** modules can reference each other without problems). -*/ - -#ifdef USE_TOOLBOX_OBJECT_GLUE -/* -** These macros are used in the module init code. If we use toolbox object glue -** it sets the function pointer to point to the real function. -*/ -#define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) { \ - extern PyObject *(*PyMacGluePtr_##rtn)(object); \ - PyMacGluePtr_##rtn = _##rtn; \ -} -#define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) { \ - extern int (*PyMacGluePtr_##rtn)(PyObject *, object *); \ - PyMacGluePtr_##rtn = _##rtn; \ -} -#else -/* -** If we don't use toolbox object glue the init macros are empty. Moreover, we define -** _xxx_New to be the same as xxx_New, and the code in mactoolboxglue isn't included. -*/ -#define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) -#define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) -#endif /* USE_TOOLBOX_OBJECT_GLUE */ - -/* macfs exports */ -int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */ -PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */ - -int PyMac_GetFSRef(PyObject *, FSRef *); /* argument parser for FSRef */ -PyObject *PyMac_BuildFSRef(FSRef *); /* Convert FSRef to PyObject */ - -/* AE exports */ -extern PyObject *AEDesc_New(AppleEvent *); /* XXXX Why passed by address?? */ -extern PyObject *AEDesc_NewBorrowed(AppleEvent *); -extern int AEDesc_Convert(PyObject *, AppleEvent *); - -/* Cm exports */ -extern PyObject *CmpObj_New(Component); -extern int CmpObj_Convert(PyObject *, Component *); -extern PyObject *CmpInstObj_New(ComponentInstance); -extern int CmpInstObj_Convert(PyObject *, ComponentInstance *); - -/* Ctl exports */ -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); - -/* Dlg exports */ -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyObject *DlgObj_WhichDialog(DialogPtr); - -/* Drag exports */ -extern PyObject *DragObj_New(DragReference); -extern int DragObj_Convert(PyObject *, DragReference *); - -/* List exports */ -extern PyObject *ListObj_New(ListHandle); -extern int ListObj_Convert(PyObject *, ListHandle *); - -/* Menu exports */ -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); - -/* Qd exports */ -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); -extern PyObject *QdRGB_New(RGBColor *); -extern int QdRGB_Convert(PyObject *, RGBColor *); - -/* Qdoffs exports */ -extern PyObject *GWorldObj_New(GWorldPtr); -extern int GWorldObj_Convert(PyObject *, GWorldPtr *); - -/* Qt exports */ -extern PyObject *TrackObj_New(Track); -extern int TrackObj_Convert(PyObject *, Track *); -extern PyObject *MovieObj_New(Movie); -extern int MovieObj_Convert(PyObject *, Movie *); -extern PyObject *MovieCtlObj_New(MovieController); -extern int MovieCtlObj_Convert(PyObject *, MovieController *); -extern PyObject *TimeBaseObj_New(TimeBase); -extern int TimeBaseObj_Convert(PyObject *, TimeBase *); -extern PyObject *UserDataObj_New(UserData); -extern int UserDataObj_Convert(PyObject *, UserData *); -extern PyObject *MediaObj_New(Media); -extern int MediaObj_Convert(PyObject *, Media *); - -/* Res exports */ -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -/* TE exports */ -extern PyObject *TEObj_New(TEHandle); -extern int TEObj_Convert(PyObject *, TEHandle *); - -/* Win exports */ -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyObject *WinObj_WhichWindow(WindowPtr); - -/* CF exports */ -extern PyObject *CFObj_New(CFTypeRef); -extern int CFObj_Convert(PyObject *, CFTypeRef *); -extern PyObject *CFTypeRefObj_New(CFTypeRef); -extern int CFTypeRefObj_Convert(PyObject *, CFTypeRef *); -extern PyObject *CFStringRefObj_New(CFStringRef); -extern int CFStringRefObj_Convert(PyObject *, CFStringRef *); -extern PyObject *CFMutableStringRefObj_New(CFMutableStringRef); -extern int CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *); -extern PyObject *CFArrayRefObj_New(CFArrayRef); -extern int CFArrayRefObj_Convert(PyObject *, CFArrayRef *); -extern PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef); -extern int CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *); -extern PyObject *CFDictionaryRefObj_New(CFDictionaryRef); -extern int CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *); -extern PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef); -extern int CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *); -extern PyObject *CFURLRefObj_New(CFURLRef); -extern int CFURLRefObj_Convert(PyObject *, CFURLRef *); -extern int OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *); - -#ifdef __cplusplus - } -#endif -#endif diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/pymem.h b/SDKs/XPlatform/Cypython-2.3.3/include/pymem.h deleted file mode 100644 index a78fed55..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/pymem.h +++ /dev/null @@ -1,108 +0,0 @@ -/* The PyMem_ family: low-level memory allocation interfaces. - See objimpl.h for the PyObject_ memory family. -*/ - -#ifndef Py_PYMEM_H -#define Py_PYMEM_H - -#include "pyport.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* BEWARE: - - Each interface exports both functions and macros. Extension modules should - use the functions, to ensure binary compatibility across Python versions. - Because the Python implementation is free to change internal details, and - the macros may (or may not) expose details for speed, if you do use the - macros you must recompile your extensions with each Python release. - - Never mix calls to PyMem_ with calls to the platform malloc/realloc/ - calloc/free. For example, on Windows different DLLs may end up using - different heaps, and if you use PyMem_Malloc you'll get the memory from the - heap used by the Python DLL; it could be a disaster if you free()'ed that - directly in your own extension. Using PyMem_Free instead ensures Python - can return the memory to the proper heap. As another example, in - PYMALLOC_DEBUG mode, Python wraps all calls to all PyMem_ and PyObject_ - memory functions in special debugging wrappers that add additional - debugging info to dynamic memory blocks. The system routines have no idea - what to do with that stuff, and the Python wrappers have no idea what to do - with raw blocks obtained directly by the system routines then. -*/ - -/* - * Raw memory interface - * ==================== - */ - -/* Functions - - Functions supplying platform-independent semantics for malloc/realloc/ - free. These functions make sure that allocating 0 bytes returns a distinct - non-NULL pointer (whenever possible -- if we're flat out of memory, NULL - may be returned), even if the platform malloc and realloc don't. - Returned pointers must be checked for NULL explicitly. No action is - performed on failure (no exception is set, no warning is printed, etc). -*/ - -PyAPI_FUNC(void *) PyMem_Malloc(size_t); -PyAPI_FUNC(void *) PyMem_Realloc(void *, size_t); -PyAPI_FUNC(void) PyMem_Free(void *); - -/* Starting from Python 1.6, the wrappers Py_{Malloc,Realloc,Free} are - no longer supported. They used to call PyErr_NoMemory() on failure. */ - -/* Macros. */ -#ifdef PYMALLOC_DEBUG -/* Redirect all memory operations to Python's debugging allocator. */ -#define PyMem_MALLOC PyObject_MALLOC -#define PyMem_REALLOC PyObject_REALLOC - -#else /* ! PYMALLOC_DEBUG */ - -/* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL - for malloc(0), which would be treated as an error. Some platforms - would return a pointer with no memory behind it, which would break - pymalloc. To solve these problems, allocate an extra byte. */ -#define PyMem_MALLOC(n) malloc((n) ? (n) : 1) -#define PyMem_REALLOC(p, n) realloc((p), (n) ? (n) : 1) - -#endif /* PYMALLOC_DEBUG */ - -/* In order to avoid breaking old code mixing PyObject_{New, NEW} with - PyMem_{Del, DEL} and PyMem_{Free, FREE}, the PyMem "release memory" - functions have to be redirected to the object deallocator. */ -#define PyMem_FREE PyObject_FREE - -/* - * Type-oriented memory interface - * ============================== - * - * These are carried along for historical reasons. There's rarely a good - * reason to use them anymore (you can just as easily do the multiply and - * cast yourself). - */ - -#define PyMem_New(type, n) \ - ( (type *) PyMem_Malloc((n) * sizeof(type)) ) -#define PyMem_NEW(type, n) \ - ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) - -#define PyMem_Resize(p, type, n) \ - ( (p) = (type *) PyMem_Realloc((p), (n) * sizeof(type)) ) -#define PyMem_RESIZE(p, type, n) \ - ( (p) = (type *) PyMem_REALLOC((p), (n) * sizeof(type)) ) - -/* In order to avoid breaking old code mixing PyObject_{New, NEW} with - PyMem_{Del, DEL} and PyMem_{Free, FREE}, the PyMem "release memory" - functions have to be redirected to the object deallocator. */ -#define PyMem_Del PyObject_Free -#define PyMem_DEL PyObject_FREE - -#ifdef __cplusplus -} -#endif - -#endif /* !Py_PYMEM_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/pyport.h b/SDKs/XPlatform/Cypython-2.3.3/include/pyport.h deleted file mode 100644 index e60aa514..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/pyport.h +++ /dev/null @@ -1,572 +0,0 @@ -#ifndef Py_PYPORT_H -#define Py_PYPORT_H - -#include "pyconfig.h" /* include for defines */ - -/************************************************************************** -Symbols and macros to supply platform-independent interfaces to basic -C language & library operations whose spellings vary across platforms. - -Please try to make documentation here as clear as possible: by definition, -the stuff here is trying to illuminate C's darkest corners. - -Config #defines referenced here: - -SIGNED_RIGHT_SHIFT_ZERO_FILLS -Meaning: To be defined iff i>>j does not extend the sign bit when i is a - signed integral type and i < 0. -Used in: Py_ARITHMETIC_RIGHT_SHIFT - -Py_DEBUG -Meaning: Extra checks compiled in for debug mode. -Used in: Py_SAFE_DOWNCAST - -HAVE_UINTPTR_T -Meaning: The C9X type uintptr_t is supported by the compiler -Used in: Py_uintptr_t - -HAVE_LONG_LONG -Meaning: The compiler supports the C type "long long" -Used in: PY_LONG_LONG - -**************************************************************************/ - - -/* For backward compatibility only. Obsolete, do not use. */ -#ifdef HAVE_PROTOTYPES -#define Py_PROTO(x) x -#else -#define Py_PROTO(x) () -#endif -#ifndef Py_FPROTO -#define Py_FPROTO(x) Py_PROTO(x) -#endif - -/* typedefs for some C9X-defined synonyms for integral types. - * - * The names in Python are exactly the same as the C9X names, except with a - * Py_ prefix. Until C9X is universally implemented, this is the only way - * to ensure that Python gets reliable names that don't conflict with names - * in non-Python code that are playing their own tricks to define the C9X - * names. - * - * NOTE: don't go nuts here! Python has no use for *most* of the C9X - * integral synonyms. Only define the ones we actually need. - */ - -#ifdef HAVE_LONG_LONG -#ifndef PY_LONG_LONG -#define PY_LONG_LONG long long -#endif -#endif /* HAVE_LONG_LONG */ - -/* uintptr_t is the C9X name for an unsigned integral type such that a - * legitimate void* can be cast to uintptr_t and then back to void* again - * without loss of information. Similarly for intptr_t, wrt a signed - * integral type. - */ -#ifdef HAVE_UINTPTR_T -typedef uintptr_t Py_uintptr_t; -typedef intptr_t Py_intptr_t; - -#elif SIZEOF_VOID_P <= SIZEOF_INT -typedef unsigned int Py_uintptr_t; -typedef int Py_intptr_t; - -#elif SIZEOF_VOID_P <= SIZEOF_LONG -typedef unsigned long Py_uintptr_t; -typedef long Py_intptr_t; - -#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG) -typedef unsigned PY_LONG_LONG Py_uintptr_t; -typedef PY_LONG_LONG Py_intptr_t; - -#else -# error "Python needs a typedef for Py_uintptr_t in pyport.h." -#endif /* HAVE_UINTPTR_T */ - -#ifdef HAVE_STDLIB_H -#include -#endif - -#include /* Moved here from the math section, before extern "C" */ - -/******************************************** - * WRAPPER FOR and/or * - ********************************************/ - -#ifdef TIME_WITH_SYS_TIME -#include -#include -#else /* !TIME_WITH_SYS_TIME */ -#ifdef HAVE_SYS_TIME_H -#include -#else /* !HAVE_SYS_TIME_H */ -#include -#endif /* !HAVE_SYS_TIME_H */ -#endif /* !TIME_WITH_SYS_TIME */ - - -/****************************** - * WRAPPER FOR * - ******************************/ - -/* NB caller must include */ - -#ifdef HAVE_SYS_SELECT_H - -#include - -#endif /* !HAVE_SYS_SELECT_H */ - -/******************************* - * stat() and fstat() fiddling * - *******************************/ - -/* We expect that stat and fstat exist on most systems. - * It's confirmed on Unix, Mac and Windows. - * If you don't have them, add - * #define DONT_HAVE_STAT - * and/or - * #define DONT_HAVE_FSTAT - * to your pyconfig.h. Python code beyond this should check HAVE_STAT and - * HAVE_FSTAT instead. - * Also - * #define DONT_HAVE_SYS_STAT_H - * if doesn't exist on your platform, and - * #define HAVE_STAT_H - * if does (don't look at me -- ths mess is inherited). - */ -#ifndef DONT_HAVE_STAT -#define HAVE_STAT -#endif - -#ifndef DONT_HAVE_FSTAT -#define HAVE_FSTAT -#endif - -#ifdef RISCOS -#include -#include "unixstuff.h" -#endif - -#ifndef DONT_HAVE_SYS_STAT_H -#if defined(PYOS_OS2) && defined(PYCC_GCC) -#include -#endif -#include -#elif defined(HAVE_STAT_H) -#include -#endif - -#if defined(PYCC_VACPP) -/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */ -#define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG) -#endif - -#ifndef S_ISREG -#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) -#endif - -#ifndef S_ISDIR -#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) -#endif - - -#ifdef __cplusplus -/* Move this down here since some C++ #include's don't like to be included - inside an extern "C" */ -extern "C" { -#endif - - -/* Py_ARITHMETIC_RIGHT_SHIFT - * C doesn't define whether a right-shift of a signed integer sign-extends - * or zero-fills. Here a macro to force sign extension: - * Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) - * Return I >> J, forcing sign extension. - * Requirements: - * I is of basic signed type TYPE (char, short, int, long, or long long). - * TYPE is one of char, short, int, long, or long long, although long long - * must not be used except on platforms that support it. - * J is an integer >= 0 and strictly less than the number of bits in TYPE - * (because C doesn't define what happens for J outside that range either). - * Caution: - * I may be evaluated more than once. - */ -#ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS -#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \ - ((I) < 0 ? ~((~(unsigned TYPE)(I)) >> (J)) : (I) >> (J)) -#else -#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J)) -#endif - -/* Py_FORCE_EXPANSION(X) - * "Simply" returns its argument. However, macro expansions within the - * argument are evaluated. This unfortunate trickery is needed to get - * token-pasting to work as desired in some cases. - */ -#define Py_FORCE_EXPANSION(X) X - -/* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) - * Cast VALUE to type NARROW from type WIDE. In Py_DEBUG mode, this - * assert-fails if any information is lost. - * Caution: - * VALUE may be evaluated more than once. - */ -#ifdef Py_DEBUG -#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \ - (assert((WIDE)(NARROW)(VALUE) == (VALUE)), (NARROW)(VALUE)) -#else -#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE) -#endif - -/* Py_IS_INFINITY(X) - * Return 1 if float or double arg is an infinity, else 0. - * Caution: - * X is evaluated more than once. - * This implementation may set the underflow flag if |X| is very small; - * it really can't be implemented correctly (& easily) before C99. - */ -#define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X)) - -/* HUGE_VAL is supposed to expand to a positive double infinity. Python - * uses Py_HUGE_VAL instead because some platforms are broken in this - * respect. We used to embed code in pyport.h to try to worm around that, - * but different platforms are broken in conflicting ways. If you're on - * a platform where HUGE_VAL is defined incorrectly, fiddle your Python - * config to #define Py_HUGE_VAL to something that works on your platform. - */ -#ifndef Py_HUGE_VAL -#define Py_HUGE_VAL HUGE_VAL -#endif - -/* Py_OVERFLOWED(X) - * Return 1 iff a libm function overflowed. Set errno to 0 before calling - * a libm function, and invoke this macro after, passing the function - * result. - * Caution: - * This isn't reliable. C99 no longer requires libm to set errno under - * any exceptional condition, but does require +- HUGE_VAL return - * values on overflow. A 754 box *probably* maps HUGE_VAL to a - * double infinity, and we're cool if that's so, unless the input - * was an infinity and an infinity is the expected result. A C89 - * system sets errno to ERANGE, so we check for that too. We're - * out of luck if a C99 754 box doesn't map HUGE_VAL to +Inf, or - * if the returned result is a NaN, or if a C89 box returns HUGE_VAL - * in non-overflow cases. - * X is evaluated more than once. - * Some platforms have better way to spell this, so expect some #ifdef'ery. - * - * OpenBSD uses 'isinf()' because a compiler bug on that platform causes - * the longer macro version to be mis-compiled. This isn't optimal, and - * should be removed once a newer compiler is available on that platform. - * The system that had the failure was running OpenBSD 3.2 on Intel, with - * gcc 2.95.3. - * - * According to Tim's checkin, the FreeBSD systems use isinf() to work - * around a FPE bug on that platform. - */ -#if defined(__FreeBSD__) || defined(__OpenBSD__) -#define Py_OVERFLOWED(X) isinf(X) -#else -#define Py_OVERFLOWED(X) ((X) != 0.0 && (errno == ERANGE || \ - (X) == Py_HUGE_VAL || \ - (X) == -Py_HUGE_VAL)) -#endif - -/* Py_SET_ERANGE_ON_OVERFLOW(x) - * If a libm function did not set errno, but it looks like the result - * overflowed, set errno to ERANGE. Set errno to 0 before calling a libm - * function, and invoke this macro after, passing the function result. - * Caution: - * This isn't reliable. See Py_OVERFLOWED comments. - * X is evaluated more than once. - */ -#define Py_SET_ERANGE_IF_OVERFLOW(X) \ - do { \ - if (errno == 0 && ((X) == Py_HUGE_VAL || \ - (X) == -Py_HUGE_VAL)) \ - errno = ERANGE; \ - } while(0) - -/* Py_ADJUST_ERANGE1(x) - * Py_ADJUST_ERANGE2(x, y) - * Set errno to 0 before calling a libm function, and invoke one of these - * macros after, passing the function result(s) (Py_ADJUST_ERANGE2 is useful - * for functions returning complex results). This makes two kinds of - * adjustments to errno: (A) If it looks like the platform libm set - * errno=ERANGE due to underflow, clear errno. (B) If it looks like the - * platform libm overflowed but didn't set errno, force errno to ERANGE. In - * effect, we're trying to force a useful implementation of C89 errno - * behavior. - * Caution: - * This isn't reliable. See Py_OVERFLOWED comments. - * X and Y may be evaluated more than once. - */ -#define Py_ADJUST_ERANGE1(X) \ - do { \ - if (errno == 0) { \ - if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ - errno = ERANGE; \ - } \ - else if (errno == ERANGE && (X) == 0.0) \ - errno = 0; \ - } while(0) - -#define Py_ADJUST_ERANGE2(X, Y) \ - do { \ - if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL || \ - (Y) == Py_HUGE_VAL || (Y) == -Py_HUGE_VAL) { \ - if (errno == 0) \ - errno = ERANGE; \ - } \ - else if (errno == ERANGE) \ - errno = 0; \ - } while(0) - -/* Py_DEPRECATED(version) - * Declare a variable, type, or function deprecated. - * Usage: - * extern int old_var Py_DEPRECATED(2.3); - * typedef int T1 Py_DEPRECATED(2.4); - * extern int x() Py_DEPRECATED(2.5); - */ -#if defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) -#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__)) -#else -#define Py_DEPRECATED(VERSION_UNUSED) -#endif - -/************************************************************************** -Prototypes that are missing from the standard include files on some systems -(and possibly only some versions of such systems.) - -Please be conservative with adding new ones, document them and enclose them -in platform-specific #ifdefs. -**************************************************************************/ - -#ifdef SOLARIS -/* Unchecked */ -extern int gethostname(char *, int); -#endif - -#ifdef __BEOS__ -/* Unchecked */ -/* It's in the libs, but not the headers... - [cjh] */ -int shutdown( int, int ); -#endif - -#ifdef HAVE__GETPTY -#include /* we need to import mode_t */ -extern char * _getpty(int *, int, mode_t, int); -#endif - -#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) -#if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) -/* BSDI does not supply a prototype for the 'openpty' and 'forkpty' - functions, even though they are included in libutil. */ -#include -extern int openpty(int *, int *, char *, struct termios *, struct winsize *); -extern int forkpty(int *, char *, struct termios *, struct winsize *); -#endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */ -#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */ - - -/* These are pulled from various places. It isn't obvious on what platforms - they are necessary, nor what the exact prototype should look like (which - is likely to vary between platforms!) If you find you need one of these - declarations, please move them to a platform-specific block and include - proper prototypes. */ -#if 0 - -/* From Modules/resource.c */ -extern int getrusage(); -extern int getpagesize(); - -/* From Python/sysmodule.c and Modules/posixmodule.c */ -extern int fclose(FILE *); - -/* From Modules/posixmodule.c */ -extern int fdatasync(int); -/* XXX These are supposedly for SunOS4.1.3 but "shouldn't hurt elsewhere" */ -extern int rename(const char *, const char *); -extern int pclose(FILE *); -extern int lstat(const char *, struct stat *); -extern int symlink(const char *, const char *); -extern int fsync(int fd); - -#endif /* 0 */ - - -/************************ - * WRAPPER FOR * - ************************/ - -#ifndef HAVE_HYPOT -extern double hypot(double, double); -#endif - -/* Declarations for symbol visibility. - - PyAPI_FUNC(type): Declares a public Python API function and return type - PyAPI_DATA(type): Declares public Python data and its type - PyMODINIT_FUNC: A Python module init function. If these functions are - inside the Python core, they are private to the core. - If in an extension module, it may be declared with - external linkage depending on the platform. - - As a number of platforms support/require "__declspec(dllimport/dllexport)", - we support a HAVE_DECLSPEC_DLL macro to save duplication. -*/ - -/* - All windows ports, except cygwin, are handled in PC/pyconfig.h. - - BeOS and cygwin are the only other autoconf platform requiring special - linkage handling and both of these use __declspec(). -*/ -#if defined(__CYGWIN__) || defined(__BEOS__) -# define HAVE_DECLSPEC_DLL -#endif - -#if defined(Py_ENABLE_SHARED) /* only get special linkage if built as shared */ -# if defined(HAVE_DECLSPEC_DLL) -# ifdef Py_BUILD_CORE -# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE -# define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE - /* module init functions inside the core need no external linkage */ -# define PyMODINIT_FUNC void -# else /* Py_BUILD_CORE */ - /* Building an extension module, or an embedded situation */ - /* public Python functions and data are imported */ - /* Under Cygwin, auto-import functions to prevent compilation */ - /* failures similar to http://python.org/doc/FAQ.html#3.24 */ -# if !defined(__CYGWIN__) -# define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE -# endif /* !__CYGWIN__ */ -# define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE - /* module init functions outside the core must be exported */ -# if defined(__cplusplus) -# define PyMODINIT_FUNC extern "C" __declspec(dllexport) void -# else /* __cplusplus */ -# define PyMODINIT_FUNC __declspec(dllexport) void -# endif /* __cplusplus */ -# endif /* Py_BUILD_CORE */ -# endif /* HAVE_DECLSPEC */ -#endif /* Py_ENABLE_SHARED */ - -/* If no external linkage macros defined by now, create defaults */ -#ifndef PyAPI_FUNC -# define PyAPI_FUNC(RTYPE) RTYPE -#endif -#ifndef PyAPI_DATA -# define PyAPI_DATA(RTYPE) extern RTYPE -#endif -#ifndef PyMODINIT_FUNC -# if defined(__cplusplus) -# define PyMODINIT_FUNC extern "C" void -# else /* __cplusplus */ -# define PyMODINIT_FUNC void -# endif /* __cplusplus */ -#endif - -/* Deprecated DL_IMPORT and DL_EXPORT macros */ -#if defined(Py_ENABLE_SHARED) && defined (HAVE_DECLSPEC_DLL) -# if defined(Py_BUILD_CORE) -# define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE -# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE -# else -# define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE -# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE -# endif -#endif -#ifndef DL_EXPORT -# define DL_EXPORT(RTYPE) RTYPE -#endif -#ifndef DL_IMPORT -# define DL_IMPORT(RTYPE) RTYPE -#endif -/* End of deprecated DL_* macros */ - -/* If the fd manipulation macros aren't defined, - here is a set that should do the job */ - -#if 0 /* disabled and probably obsolete */ - -#ifndef FD_SETSIZE -#define FD_SETSIZE 256 -#endif - -#ifndef FD_SET - -typedef long fd_mask; - -#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ -#ifndef howmany -#define howmany(x, y) (((x)+((y)-1))/(y)) -#endif /* howmany */ - -typedef struct fd_set { - fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; -} fd_set; - -#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) -#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) -#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) -#define FD_ZERO(p) memset((char *)(p), '\0', sizeof(*(p))) - -#endif /* FD_SET */ - -#endif /* fd manipulation macros */ - - -/* limits.h constants that may be missing */ - -#ifndef INT_MAX -#define INT_MAX 2147483647 -#endif - -#ifndef LONG_MAX -#if SIZEOF_LONG == 4 -#define LONG_MAX 0X7FFFFFFFL -#elif SIZEOF_LONG == 8 -#define LONG_MAX 0X7FFFFFFFFFFFFFFFL -#else -#error "could not set LONG_MAX in pyport.h" -#endif -#endif - -#ifndef LONG_MIN -#define LONG_MIN (-LONG_MAX-1) -#endif - -#ifndef LONG_BIT -#define LONG_BIT (8 * SIZEOF_LONG) -#endif - -#if LONG_BIT != 8 * SIZEOF_LONG -/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent - * 32-bit platforms using gcc. We try to catch that here at compile-time - * rather than waiting for integer multiplication to trigger bogus - * overflows. - */ -#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." -#endif - -#ifdef __cplusplus -} -#endif - -/* - * Hide GCC attributes from compilers that don't support them. - */ -#if (!defined(__GNUC__) || __GNUC__ < 2 || \ - (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ) && \ - !defined(RISCOS) -#define Py_GCC_ATTRIBUTE(x) -#else -#define Py_GCC_ATTRIBUTE(x) __attribute__(x) -#endif - -#endif /* Py_PYPORT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/pystate.h b/SDKs/XPlatform/Cypython-2.3.3/include/pystate.h deleted file mode 100644 index 70e5ac88..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/pystate.h +++ /dev/null @@ -1,172 +0,0 @@ - -/* Thread and interpreter state structures and their interfaces */ - - -#ifndef Py_PYSTATE_H -#define Py_PYSTATE_H -#ifdef __cplusplus -extern "C" { -#endif - -/* State shared between threads */ - -struct _ts; /* Forward */ -struct _is; /* Forward */ - -typedef struct _is { - - struct _is *next; - struct _ts *tstate_head; - - PyObject *modules; - PyObject *sysdict; - PyObject *builtins; - - PyObject *codec_search_path; - PyObject *codec_search_cache; - PyObject *codec_error_registry; - -#ifdef HAVE_DLOPEN - int dlopenflags; -#endif - -} PyInterpreterState; - - -/* State unique per thread */ - -struct _frame; /* Avoid including frameobject.h */ - -/* Py_tracefunc return -1 when raising an exception, or 0 for success. */ -typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *); - -/* The following values are used for 'what' for tracefunc functions: */ -#define PyTrace_CALL 0 -#define PyTrace_EXCEPTION 1 -#define PyTrace_LINE 2 -#define PyTrace_RETURN 3 - -typedef struct _ts { - - struct _ts *next; - PyInterpreterState *interp; - - struct _frame *frame; - int recursion_depth; - int tracing; - int use_tracing; - - Py_tracefunc c_profilefunc; - Py_tracefunc c_tracefunc; - PyObject *c_profileobj; - PyObject *c_traceobj; - - PyObject *curexc_type; - PyObject *curexc_value; - PyObject *curexc_traceback; - - PyObject *exc_type; - PyObject *exc_value; - PyObject *exc_traceback; - - PyObject *dict; - - int tick_counter; - int gilstate_counter; - - PyObject *async_exc; /* Asynchronous exception to raise */ - long thread_id; /* Thread id where this tstate was created */ - - /* XXX signal handlers should also be here */ - -} PyThreadState; - - -PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void); -PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *); -PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *); - -PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *); -PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *); -PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *); -#ifdef WITH_THREAD -PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void); -#endif - -PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void); -PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *); -PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void); -PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *); - - -/* Variable and macro for in-line access to current thread state */ - -PyAPI_DATA(PyThreadState *) _PyThreadState_Current; - -#ifdef Py_DEBUG -#define PyThreadState_GET() PyThreadState_Get() -#else -#define PyThreadState_GET() (_PyThreadState_Current) -#endif - -typedef - enum {PyGILState_LOCKED, PyGILState_UNLOCKED} - PyGILState_STATE; - -/* Ensure that the current thread is ready to call the Python - C API, regardless of the current state of Python, or of its - thread lock. This may be called as many times as desired - by a thread so long as each call is matched with a call to - PyGILState_Release(). In general, other thread-state APIs may - be used between _Ensure() and _Release() calls, so long as the - thread-state is restored to its previous state before the Release(). - For example, normal use of the Py_BEGIN_ALLOW_THREADS/ - Py_END_ALLOW_THREADS macros are acceptable. - - The return value is an opaque "handle" to the thread state when - PyGILState_Acquire() was called, and must be passed to - PyGILState_Release() to ensure Python is left in the same state. Even - though recursive calls are allowed, these handles can *not* be shared - - each unique call to PyGILState_Ensure must save the handle for its - call to PyGILState_Release. - - When the function returns, the current thread will hold the GIL. - - Failure is a fatal error. -*/ -PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void); - -/* Release any resources previously acquired. After this call, Python's - state will be the same as it was prior to the corresponding - PyGILState_Acquire call (but generally this state will be unknown to - the caller, hence the use of the GILState API.) - - Every call to PyGILState_Ensure must be matched by a call to - PyGILState_Release on the same thread. -*/ -PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE); - -/* Helper/diagnostic function - get the current thread state for - this thread. May return NULL if no GILState API has been used - on the current thread. Note the main thread always has such a - thread-state, even if no auto-thread-state call has been made - on the main thread. -*/ -PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void); - -/* Routines for advanced debuggers, requested by David Beazley. - Don't use unless you know what you are doing! */ -PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void); -PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *); -PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *); -PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *); - -typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_); - -/* hook for PyEval_GetFrame(), requested for Psyco */ -PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame; - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PYSTATE_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/pythonrun.h b/SDKs/XPlatform/Cypython-2.3.3/include/pythonrun.h deleted file mode 100644 index db1c1a4a..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/pythonrun.h +++ /dev/null @@ -1,149 +0,0 @@ - -/* Interfaces to parse and execute pieces of python code */ - -#ifndef Py_PYTHONRUN_H -#define Py_PYTHONRUN_H -#ifdef __cplusplus -extern "C" { -#endif - -#define PyCF_MASK (CO_FUTURE_DIVISION) -#define PyCF_MASK_OBSOLETE (CO_GENERATOR_ALLOWED | CO_NESTED) -#define PyCF_SOURCE_IS_UTF8 0x0100 -#define PyCF_DONT_IMPLY_DEDENT 0x0200 - -typedef struct { - int cf_flags; /* bitmask of CO_xxx flags relevant to future */ -} PyCompilerFlags; - -PyAPI_FUNC(void) Py_SetProgramName(char *); -PyAPI_FUNC(char *) Py_GetProgramName(void); - -PyAPI_FUNC(void) Py_SetPythonHome(char *); -PyAPI_FUNC(char *) Py_GetPythonHome(void); - -PyAPI_FUNC(void) Py_Initialize(void); -PyAPI_FUNC(void) Py_Finalize(void); -PyAPI_FUNC(int) Py_IsInitialized(void); -PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void); -PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *); - -PyAPI_FUNC(int) PyRun_AnyFile(FILE *, const char *); -PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *, const char *, int); - -PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *); -PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, const char *, int, PyCompilerFlags *); - -PyAPI_FUNC(int) PyRun_SimpleString(const char *); -PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *); -PyAPI_FUNC(int) PyRun_SimpleFile(FILE *, const char *); -PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *, const char *, int); -PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFlags *); -PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *, const char *); -PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *); -PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *, const char *); -PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *); - -PyAPI_FUNC(struct _node *) PyParser_SimpleParseString(const char *, int); -PyAPI_FUNC(struct _node *) PyParser_SimpleParseFile(FILE *, const char *, int); -PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int, int); -PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlagsFilename(const char *, - const char *, - int, - int); -PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *, - int, int); - -PyAPI_FUNC(PyObject *) PyRun_String(const char *, int, PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyRun_File(FILE *, const char *, int, PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *, const char *, int, - PyObject *, PyObject *, int); -PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *, PyObject *, - PyCompilerFlags *); -PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *, const char *, int, PyObject *, - PyObject *, PyCompilerFlags *); -PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int, PyObject *, - PyObject *, int, PyCompilerFlags *); - -PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int); -PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int, - PyCompilerFlags *); -PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int); - -PyAPI_FUNC(void) PyErr_Print(void); -PyAPI_FUNC(void) PyErr_PrintEx(int); -PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *); - -PyAPI_FUNC(int) Py_AtExit(void (*func)(void)); - -PyAPI_FUNC(void) Py_Exit(int); - -PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *); - -/* Bootstrap */ -PyAPI_FUNC(int) Py_Main(int argc, char **argv); - -/* In getpath.c */ -PyAPI_FUNC(char *) Py_GetProgramFullPath(void); -PyAPI_FUNC(char *) Py_GetPrefix(void); -PyAPI_FUNC(char *) Py_GetExecPrefix(void); -PyAPI_FUNC(char *) Py_GetPath(void); - -/* In their own files */ -PyAPI_FUNC(const char *) Py_GetVersion(void); -PyAPI_FUNC(const char *) Py_GetPlatform(void); -PyAPI_FUNC(const char *) Py_GetCopyright(void); -PyAPI_FUNC(const char *) Py_GetCompiler(void); -PyAPI_FUNC(const char *) Py_GetBuildInfo(void); - -/* Internal -- various one-time initializations */ -PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void); -PyAPI_FUNC(PyObject *) _PySys_Init(void); -PyAPI_FUNC(void) _PyImport_Init(void); -PyAPI_FUNC(void) _PyExc_Init(void); -PyAPI_FUNC(void) _PyImportHooks_Init(void); -PyAPI_FUNC(int) _PyFrame_Init(void); -PyAPI_FUNC(int) _PyInt_Init(void); - -/* Various internal finalizers */ -PyAPI_FUNC(void) _PyExc_Fini(void); -PyAPI_FUNC(void) _PyImport_Fini(void); -PyAPI_FUNC(void) PyMethod_Fini(void); -PyAPI_FUNC(void) PyFrame_Fini(void); -PyAPI_FUNC(void) PyCFunction_Fini(void); -PyAPI_FUNC(void) PyTuple_Fini(void); -PyAPI_FUNC(void) PyString_Fini(void); -PyAPI_FUNC(void) PyInt_Fini(void); -PyAPI_FUNC(void) PyFloat_Fini(void); -PyAPI_FUNC(void) PyOS_FiniInterrupts(void); - -/* Stuff with no proper home (yet) */ -PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *); -PyAPI_DATA(int) (*PyOS_InputHook)(void); -PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *); - -/* Stack size, in "pointers" (so we get extra safety margins - on 64-bit platforms). On a 32-bit platform, this translates - to a 8k margin. */ -#define PYOS_STACK_MARGIN 2048 - -#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) -/* Enable stack checking under Microsoft C */ -#define USE_STACKCHECK -#endif - -#ifdef USE_STACKCHECK -/* Check that we aren't overflowing our stack */ -PyAPI_FUNC(int) PyOS_CheckStack(void); -#endif - -/* Signals */ -typedef void (*PyOS_sighandler_t)(int); -PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int); -PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t); - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PYTHONRUN_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/pythread.h b/SDKs/XPlatform/Cypython-2.3.3/include/pythread.h deleted file mode 100644 index e980f7ae..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/pythread.h +++ /dev/null @@ -1,44 +0,0 @@ - -#ifndef Py_PYTHREAD_H -#define Py_PYTHREAD_H - -#define NO_EXIT_PROG /* don't define PyThread_exit_prog() */ - /* (the result is no use of signals on SGI) */ - -typedef void *PyThread_type_lock; -typedef void *PyThread_type_sema; - -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(void) PyThread_init_thread(void); -PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *); -PyAPI_FUNC(void) PyThread_exit_thread(void); -PyAPI_FUNC(void) PyThread__PyThread_exit_thread(void); -PyAPI_FUNC(long) PyThread_get_thread_ident(void); - -PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void); -PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock); -PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int); -#define WAIT_LOCK 1 -#define NOWAIT_LOCK 0 -PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock); - -#ifndef NO_EXIT_PROG -PyAPI_FUNC(void) PyThread_exit_prog(int); -PyAPI_FUNC(void) PyThread__PyThread_exit_prog(int); -#endif - -/* Thread Local Storage (TLS) API */ -PyAPI_FUNC(int) PyThread_create_key(void); -PyAPI_FUNC(void) PyThread_delete_key(int); -PyAPI_FUNC(int) PyThread_set_key_value(int, void *); -PyAPI_FUNC(void *) PyThread_get_key_value(int); -PyAPI_FUNC(void) PyThread_delete_key_value(int key); - -#ifdef __cplusplus -} -#endif - -#endif /* !Py_PYTHREAD_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/rangeobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/rangeobject.h deleted file mode 100644 index fc97d05b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/rangeobject.h +++ /dev/null @@ -1,27 +0,0 @@ - -/* Range object interface */ - -#ifndef Py_RANGEOBJECT_H -#define Py_RANGEOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -/* -A range object represents an integer range. This is an immutable object; -a range cannot change its value after creation. - -Range objects behave like the corresponding tuple objects except that -they are represented by a start, stop, and step datamembers. -*/ - -PyAPI_DATA(PyTypeObject) PyRange_Type; - -#define PyRange_Check(op) ((op)->ob_type == &PyRange_Type) - -PyAPI_FUNC(PyObject *) PyRange_New(long, long, long, int); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_RANGEOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/sliceobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/sliceobject.h deleted file mode 100644 index 67049f48..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/sliceobject.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef Py_SLICEOBJECT_H -#define Py_SLICEOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -/* The unique ellipsis object "..." */ - -PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */ - -#define Py_Ellipsis (&_Py_EllipsisObject) - -/* Slice object interface */ - -/* - -A slice object containing start, stop, and step data members (the -names are from range). After much talk with Guido, it was decided to -let these be any arbitrary python type. -*/ - -typedef struct { - PyObject_HEAD - PyObject *start, *stop, *step; -} PySliceObject; - -PyAPI_DATA(PyTypeObject) PySlice_Type; - -#define PySlice_Check(op) ((op)->ob_type == &PySlice_Type) - -PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop, - PyObject* step); -PyAPI_FUNC(int) PySlice_GetIndices(PySliceObject *r, int length, - int *start, int *stop, int *step); -PyAPI_FUNC(int) PySlice_GetIndicesEx(PySliceObject *r, int length, - int *start, int *stop, - int *step, int *slicelength); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_SLICEOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/stringobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/stringobject.h deleted file mode 100644 index a013f47b..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/stringobject.h +++ /dev/null @@ -1,174 +0,0 @@ - -/* String object interface */ - -#ifndef Py_STRINGOBJECT_H -#define Py_STRINGOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* -Type PyStringObject represents a character string. An extra zero byte is -reserved at the end to ensure it is zero-terminated, but a size is -present so strings with null bytes in them can be represented. This -is an immutable object type. - -There are functions to create new string objects, to test -an object for string-ness, and to get the -string value. The latter function returns a null pointer -if the object is not of the proper type. -There is a variant that takes an explicit size as well as a -variant that assumes a zero-terminated string. Note that none of the -functions should be applied to nil objects. -*/ - -/* Caching the hash (ob_shash) saves recalculation of a string's hash value. - Interning strings (ob_sstate) tries to ensure that only one string - object with a given value exists, so equality tests can be one pointer - comparison. This is generally restricted to strings that "look like" - Python identifiers, although the intern() builtin can be used to force - interning of any string. - Together, these sped the interpreter by up to 20%. */ - -typedef struct { - PyObject_VAR_HEAD - long ob_shash; - int ob_sstate; - char ob_sval[1]; -} PyStringObject; - -#define SSTATE_NOT_INTERNED 0 -#define SSTATE_INTERNED_MORTAL 1 -#define SSTATE_INTERNED_IMMORTAL 2 - -PyAPI_DATA(PyTypeObject) PyBaseString_Type; -PyAPI_DATA(PyTypeObject) PyString_Type; - -#define PyString_Check(op) PyObject_TypeCheck(op, &PyString_Type) -#define PyString_CheckExact(op) ((op)->ob_type == &PyString_Type) - -PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, int); -PyAPI_FUNC(PyObject *) PyString_FromString(const char *); -PyAPI_FUNC(PyObject *) PyString_FromFormatV(const char*, va_list) - Py_GCC_ATTRIBUTE((format(printf, 1, 0))); -PyAPI_FUNC(PyObject *) PyString_FromFormat(const char*, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); -PyAPI_FUNC(int) PyString_Size(PyObject *); -PyAPI_FUNC(char *) PyString_AsString(PyObject *); -PyAPI_FUNC(PyObject *) PyString_Repr(PyObject *, int); -PyAPI_FUNC(void) PyString_Concat(PyObject **, PyObject *); -PyAPI_FUNC(void) PyString_ConcatAndDel(PyObject **, PyObject *); -PyAPI_FUNC(int) _PyString_Resize(PyObject **, int); -PyAPI_FUNC(int) _PyString_Eq(PyObject *, PyObject*); -PyAPI_FUNC(PyObject *) PyString_Format(PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) _PyString_FormatLong(PyObject*, int, int, - int, char**, int*); -PyAPI_FUNC(PyObject *) PyString_DecodeEscape(const char *, int, - const char *, int, - const char *); - -PyAPI_FUNC(void) PyString_InternInPlace(PyObject **); -PyAPI_FUNC(void) PyString_InternImmortal(PyObject **); -PyAPI_FUNC(PyObject *) PyString_InternFromString(const char *); -PyAPI_FUNC(void) _Py_ReleaseInternedStrings(void); - -/* Use only if you know it's a string */ -#define PyString_CHECK_INTERNED(op) (((PyStringObject *)(op))->ob_sstate) - -/* Macro, trading safety for speed */ -#define PyString_AS_STRING(op) (((PyStringObject *)(op))->ob_sval) -#define PyString_GET_SIZE(op) (((PyStringObject *)(op))->ob_size) - -/* _PyString_Join(sep, x) is like sep.join(x). sep must be PyStringObject*, - x must be an iterable object. */ -PyAPI_FUNC(PyObject *) _PyString_Join(PyObject *sep, PyObject *x); - -/* --- Generic Codecs ----------------------------------------------------- */ - -/* Create an object by decoding the encoded string s of the - given size. */ - -PyAPI_FUNC(PyObject*) PyString_Decode( - const char *s, /* encoded string */ - int size, /* size of buffer */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Encodes a char buffer of the given size and returns a - Python object. */ - -PyAPI_FUNC(PyObject*) PyString_Encode( - const char *s, /* string char buffer */ - int size, /* number of chars to encode */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Encodes a string object and returns the result as Python - object. */ - -PyAPI_FUNC(PyObject*) PyString_AsEncodedObject( - PyObject *str, /* string object */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Encodes a string object and returns the result as Python string - object. - - If the codec returns an Unicode object, the object is converted - back to a string using the default encoding. - - DEPRECATED - use PyString_AsEncodedObject() instead. */ - -PyAPI_FUNC(PyObject*) PyString_AsEncodedString( - PyObject *str, /* string object */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Decodes a string object and returns the result as Python - object. */ - -PyAPI_FUNC(PyObject*) PyString_AsDecodedObject( - PyObject *str, /* string object */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Decodes a string object and returns the result as Python string - object. - - If the codec returns an Unicode object, the object is converted - back to a string using the default encoding. - - DEPRECATED - use PyString_AsDecodedObject() instead. */ - -PyAPI_FUNC(PyObject*) PyString_AsDecodedString( - PyObject *str, /* string object */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Provides access to the internal data buffer and size of a string - object or the default encoded version of an Unicode object. Passing - NULL as *len parameter will force the string buffer to be - 0-terminated (passing a string with embedded NULL characters will - cause an exception). */ - -PyAPI_FUNC(int) PyString_AsStringAndSize( - register PyObject *obj, /* string or Unicode object */ - register char **s, /* pointer to buffer variable */ - register int *len /* pointer to length variable or NULL - (only possible for 0-terminated - strings) */ - ); - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_STRINGOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/structmember.h b/SDKs/XPlatform/Cypython-2.3.3/include/structmember.h deleted file mode 100644 index 1a4942d8..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/structmember.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef Py_STRUCTMEMBER_H -#define Py_STRUCTMEMBER_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Interface to map C struct members to Python object attributes */ - -#ifdef HAVE_STDDEF_H -#include /* For offsetof */ -#endif - -/* The offsetof() macro calculates the offset of a structure member - in its structure. Unfortunately this cannot be written down - portably, hence it is provided by a Standard C header file. - For pre-Standard C compilers, here is a version that usually works - (but watch out!): */ - -#ifndef offsetof -#define offsetof(type, member) ( (int) & ((type*)0) -> member ) -#endif - -/* An array of memberlist structures defines the name, type and offset - of selected members of a C structure. These can be read by - PyMember_Get() and set by PyMember_Set() (except if their READONLY flag - is set). The array must be terminated with an entry whose name - pointer is NULL. */ - -struct memberlist { - /* Obsolete version, for binary backwards compatibility */ - char *name; - int type; - int offset; - int flags; -}; - -typedef struct PyMemberDef { - /* Current version, use this */ - char *name; - int type; - int offset; - int flags; - char *doc; -} PyMemberDef; - -/* Types */ -#define T_SHORT 0 -#define T_INT 1 -#define T_LONG 2 -#define T_FLOAT 3 -#define T_DOUBLE 4 -#define T_STRING 5 -#define T_OBJECT 6 -/* XXX the ordering here is weird for binary compatibility */ -#define T_CHAR 7 /* 1-character string */ -#define T_BYTE 8 /* 8-bit signed int */ -/* unsigned variants: */ -#define T_UBYTE 9 -#define T_USHORT 10 -#define T_UINT 11 -#define T_ULONG 12 - -/* Added by Jack: strings contained in the structure */ -#define T_STRING_INPLACE 13 -#ifdef macintosh -#define T_PSTRING 14 /* macintosh pascal-style counted string */ -#define T_PSTRING_INPLACE 15 -#endif /* macintosh */ - -#define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError - when the value is NULL, instead of - converting to None. */ - -/* Flags */ -#define READONLY 1 -#define RO READONLY /* Shorthand */ -#define READ_RESTRICTED 2 -#define WRITE_RESTRICTED 4 -#define RESTRICTED (READ_RESTRICTED | WRITE_RESTRICTED) - - -/* Obsolete API, for binary backwards compatibility */ -PyAPI_FUNC(PyObject *) PyMember_Get(char *, struct memberlist *, char *); -PyAPI_FUNC(int) PyMember_Set(char *, struct memberlist *, char *, PyObject *); - -/* Current API, use this */ -PyAPI_FUNC(PyObject *) PyMember_GetOne(char *, struct PyMemberDef *); -PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *); - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_STRUCTMEMBER_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/structseq.h b/SDKs/XPlatform/Cypython-2.3.3/include/structseq.h deleted file mode 100644 index 74b1a881..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/structseq.h +++ /dev/null @@ -1,41 +0,0 @@ - -/* Tuple object interface */ - -#ifndef Py_STRUCTSEQ_H -#define Py_STRUCTSEQ_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct PyStructSequence_Field { - char *name; - char *doc; -} PyStructSequence_Field; - -typedef struct PyStructSequence_Desc { - char *name; - char *doc; - struct PyStructSequence_Field *fields; - int n_in_sequence; -} PyStructSequence_Desc; - -extern char* PyStructSequence_UnnamedField; - -PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type, - PyStructSequence_Desc *desc); - -PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type); - -typedef struct { - PyObject_VAR_HEAD - PyObject *ob_item[1]; -} PyStructSequence; - -/* Macro, *only* to be used to fill in brand new objects */ -#define PyStructSequence_SET_ITEM(op, i, v) \ - (((PyStructSequence *)(op))->ob_item[i] = v) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_STRUCTSEQ_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/symtable.h b/SDKs/XPlatform/Cypython-2.3.3/include/symtable.h deleted file mode 100644 index 1c38e296..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/symtable.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef Py_SYMTABLE_H -#define Py_SYMTABLE_H -#ifdef __cplusplus -extern "C" { -#endif - -/* A symbol table is constructed each time PyNode_Compile() is - called. The table walks the entire parse tree and identifies each - use or definition of a variable. - - The symbol table contains a dictionary for each code block in a - module: The symbol dictionary for the block. They keys of these - dictionaries are the name of all variables used or defined in the - block; the integer values are used to store several flags, - e.g. DEF_PARAM indicates that a variable is a parameter to a - function. -*/ - -struct _symtable_entry; - -struct symtable { - int st_pass; /* pass == 1 or 2 */ - const char *st_filename; /* name of file being compiled */ - struct _symtable_entry *st_cur; /* current symbol table entry */ - PyObject *st_symbols; /* dictionary of symbol table entries */ - PyObject *st_stack; /* stack of namespace info */ - PyObject *st_global; /* borrowed ref to MODULE in st_symbols */ - int st_nscopes; /* number of scopes */ - int st_errors; /* number of errors */ - char *st_private; /* name of current class or NULL */ - PyFutureFeatures *st_future; /* module's future features */ -}; - -typedef struct _symtable_entry { - PyObject_HEAD - PyObject *ste_id; /* int: key in st_symbols) */ - PyObject *ste_symbols; /* dict: name to flags) */ - PyObject *ste_name; /* string: name of scope */ - PyObject *ste_varnames; /* list of variable names */ - PyObject *ste_children; /* list of child ids */ - int ste_type; /* module, class, or function */ - int ste_lineno; /* first line of scope */ - int ste_optimized; /* true if namespace can't be optimized */ - int ste_nested; /* true if scope is nested */ - int ste_child_free; /* true if a child scope has free variables, - including free refs to globals */ - int ste_generator; /* true if namespace is a generator */ - int ste_opt_lineno; /* lineno of last exec or import * */ - int ste_tmpname; /* temporary name counter */ - struct symtable *ste_table; -} PySymtableEntryObject; - -PyAPI_DATA(PyTypeObject) PySymtableEntry_Type; - -#define PySymtableEntry_Check(op) ((op)->ob_type == &PySymtableEntry_Type) - -PyAPI_FUNC(PyObject *) PySymtableEntry_New(struct symtable *, - char *, int, int); - -PyAPI_FUNC(struct symtable *) PyNode_CompileSymtable(struct _node *, const char *); -PyAPI_FUNC(void) PySymtable_Free(struct symtable *); - - -#define TOP "global" - -/* Flags for def-use information */ - -#define DEF_GLOBAL 1 /* global stmt */ -#define DEF_LOCAL 2 /* assignment in code block */ -#define DEF_PARAM 2<<1 /* formal parameter */ -#define USE 2<<2 /* name is used */ -#define DEF_STAR 2<<3 /* parameter is star arg */ -#define DEF_DOUBLESTAR 2<<4 /* parameter is star-star arg */ -#define DEF_INTUPLE 2<<5 /* name defined in tuple in parameters */ -#define DEF_FREE 2<<6 /* name used but not defined in nested scope */ -#define DEF_FREE_GLOBAL 2<<7 /* free variable is actually implicit global */ -#define DEF_FREE_CLASS 2<<8 /* free variable from class's method */ -#define DEF_IMPORT 2<<9 /* assignment occurred via import */ - -#define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT) - -#define TYPE_FUNCTION 1 -#define TYPE_CLASS 2 -#define TYPE_MODULE 3 - -#define LOCAL 1 -#define GLOBAL_EXPLICIT 2 -#define GLOBAL_IMPLICIT 3 -#define FREE 4 -#define CELL 5 - -#define OPT_IMPORT_STAR 1 -#define OPT_EXEC 2 -#define OPT_BARE_EXEC 4 - -#ifdef __cplusplus -} -#endif -#endif /* !Py_SYMTABLE_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/sysmodule.h b/SDKs/XPlatform/Cypython-2.3.3/include/sysmodule.h deleted file mode 100644 index 449b5496..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/sysmodule.h +++ /dev/null @@ -1,30 +0,0 @@ - -/* System module interface */ - -#ifndef Py_SYSMODULE_H -#define Py_SYSMODULE_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(PyObject *) PySys_GetObject(char *); -PyAPI_FUNC(int) PySys_SetObject(char *, PyObject *); -PyAPI_FUNC(FILE *) PySys_GetFile(char *, FILE *); -PyAPI_FUNC(void) PySys_SetArgv(int, char **); -PyAPI_FUNC(void) PySys_SetPath(char *); - -PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); -PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); - -PyAPI_DATA(PyObject *) _PySys_TraceFunc, *_PySys_ProfileFunc; -PyAPI_DATA(int) _PySys_CheckInterval; - -PyAPI_FUNC(void) PySys_ResetWarnOptions(void); -PyAPI_FUNC(void) PySys_AddWarnOption(char *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_SYSMODULE_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/token.h b/SDKs/XPlatform/Cypython-2.3.3/include/token.h deleted file mode 100644 index 51f8cbfb..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/token.h +++ /dev/null @@ -1,82 +0,0 @@ - -/* Token types */ - -#ifndef Py_TOKEN_H -#define Py_TOKEN_H -#ifdef __cplusplus -extern "C" { -#endif - -#define ENDMARKER 0 -#define NAME 1 -#define NUMBER 2 -#define STRING 3 -#define NEWLINE 4 -#define INDENT 5 -#define DEDENT 6 -#define LPAR 7 -#define RPAR 8 -#define LSQB 9 -#define RSQB 10 -#define COLON 11 -#define COMMA 12 -#define SEMI 13 -#define PLUS 14 -#define MINUS 15 -#define STAR 16 -#define SLASH 17 -#define VBAR 18 -#define AMPER 19 -#define LESS 20 -#define GREATER 21 -#define EQUAL 22 -#define DOT 23 -#define PERCENT 24 -#define BACKQUOTE 25 -#define LBRACE 26 -#define RBRACE 27 -#define EQEQUAL 28 -#define NOTEQUAL 29 -#define LESSEQUAL 30 -#define GREATEREQUAL 31 -#define TILDE 32 -#define CIRCUMFLEX 33 -#define LEFTSHIFT 34 -#define RIGHTSHIFT 35 -#define DOUBLESTAR 36 -#define PLUSEQUAL 37 -#define MINEQUAL 38 -#define STAREQUAL 39 -#define SLASHEQUAL 40 -#define PERCENTEQUAL 41 -#define AMPEREQUAL 42 -#define VBAREQUAL 43 -#define CIRCUMFLEXEQUAL 44 -#define LEFTSHIFTEQUAL 45 -#define RIGHTSHIFTEQUAL 46 -#define DOUBLESTAREQUAL 47 -#define DOUBLESLASH 48 -#define DOUBLESLASHEQUAL 49 -/* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ -#define OP 50 -#define ERRORTOKEN 51 -#define N_TOKENS 52 - -/* Special definitions for cooperation with parser */ - -#define NT_OFFSET 256 - -#define ISTERMINAL(x) ((x) < NT_OFFSET) -#define ISNONTERMINAL(x) ((x) >= NT_OFFSET) -#define ISEOF(x) ((x) == ENDMARKER) - - -PyAPI_DATA(char *) _PyParser_TokenNames[]; /* Token names */ -PyAPI_FUNC(int) PyToken_OneChar(int); -PyAPI_FUNC(int) PyToken_TwoChars(int, int); -PyAPI_FUNC(int) PyToken_ThreeChars(int, int, int); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_TOKEN_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/traceback.h b/SDKs/XPlatform/Cypython-2.3.3/include/traceback.h deleted file mode 100644 index 94875951..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/traceback.h +++ /dev/null @@ -1,22 +0,0 @@ - -#ifndef Py_TRACEBACK_H -#define Py_TRACEBACK_H -#ifdef __cplusplus -extern "C" { -#endif - -/* Traceback interface */ - -struct _frame; - -PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *); -PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *); - -/* Reveal traceback type so we can typecheck traceback objects */ -PyAPI_DATA(PyTypeObject) PyTraceBack_Type; -#define PyTraceBack_Check(v) ((v)->ob_type == &PyTraceBack_Type) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_TRACEBACK_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/tupleobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/tupleobject.h deleted file mode 100644 index 251f4abe..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/tupleobject.h +++ /dev/null @@ -1,49 +0,0 @@ - -/* Tuple object interface */ - -#ifndef Py_TUPLEOBJECT_H -#define Py_TUPLEOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -/* -Another generally useful object type is an tuple of object pointers. -This is a mutable type: the tuple items can be changed (but not their -number). Out-of-range indices or non-tuple objects are ignored. - -*** WARNING *** PyTuple_SetItem does not increment the new item's reference -count, but does decrement the reference count of the item it replaces, -if not nil. It does *decrement* the reference count if it is *not* -inserted in the tuple. Similarly, PyTuple_GetItem does not increment the -returned item's reference count. -*/ - -typedef struct { - PyObject_VAR_HEAD - PyObject *ob_item[1]; -} PyTupleObject; - -PyAPI_DATA(PyTypeObject) PyTuple_Type; - -#define PyTuple_Check(op) PyObject_TypeCheck(op, &PyTuple_Type) -#define PyTuple_CheckExact(op) ((op)->ob_type == &PyTuple_Type) - -PyAPI_FUNC(PyObject *) PyTuple_New(int size); -PyAPI_FUNC(int) PyTuple_Size(PyObject *); -PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, int); -PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, int, PyObject *); -PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, int, int); -PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, int); - -/* Macro, trading safety for speed */ -#define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i]) -#define PyTuple_GET_SIZE(op) (((PyTupleObject *)(op))->ob_size) - -/* Macro, *only* to be used to fill in brand new tuples */ -#define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_TUPLEOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/ucnhash.h b/SDKs/XPlatform/Cypython-2.3.3/include/ucnhash.h deleted file mode 100644 index 6d02989e..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/ucnhash.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Unicode name database interface */ - -#ifndef Py_UCNHASH_H -#define Py_UCNHASH_H -#ifdef __cplusplus -extern "C" { -#endif - -/* revised ucnhash CAPI interface (exported through a PyCObject) */ - -typedef struct { - - /* Size of this struct */ - int size; - - /* Get name for a given character code. Returns non-zero if - success, zero if not. Does not set Python exceptions. */ - int (*getname)(Py_UCS4 code, char* buffer, int buflen); - - /* Get character code for a given name. Same error handling - as for getname. */ - int (*getcode)(const char* name, int namelen, Py_UCS4* code); - -} _PyUnicode_Name_CAPI; - -#ifdef __cplusplus -} -#endif -#endif /* !Py_UCNHASH_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/unicodeobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/unicodeobject.h deleted file mode 100644 index 614b02e1..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/unicodeobject.h +++ /dev/null @@ -1,1138 +0,0 @@ -#ifndef Py_UNICODEOBJECT_H -#define Py_UNICODEOBJECT_H - -/* - -Unicode implementation based on original code by Fredrik Lundh, -modified by Marc-Andre Lemburg (mal@lemburg.com) according to the -Unicode Integration Proposal (see file Misc/unicode.txt). - -Copyright (c) Corporation for National Research Initiatives. - - - Original header: - -------------------------------------------------------------------- - - * Yet another Unicode string type for Python. This type supports the - * 16-bit Basic Multilingual Plane (BMP) only. - * - * Written by Fredrik Lundh, January 1999. - * - * Copyright (c) 1999 by Secret Labs AB. - * Copyright (c) 1999 by Fredrik Lundh. - * - * fredrik@pythonware.com - * http://www.pythonware.com - * - * -------------------------------------------------------------------- - * This Unicode String Type is - * - * Copyright (c) 1999 by Secret Labs AB - * Copyright (c) 1999 by Fredrik Lundh - * - * By obtaining, using, and/or copying this software and/or its - * associated documentation, you agree that you have read, understood, - * and will comply with the following terms and conditions: - * - * Permission to use, copy, modify, and distribute this software and its - * associated documentation for any purpose and without fee is hereby - * granted, provided that the above copyright notice appears in all - * copies, and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of Secret Labs - * AB or the author not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. - * - * SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * -------------------------------------------------------------------- */ - -#include - -/* === Internal API ======================================================= */ - -/* --- Internal Unicode Format -------------------------------------------- */ - -#ifndef Py_USING_UNICODE - -#define PyUnicode_Check(op) 0 -#define PyUnicode_CheckExact(op) 0 - -#else - -/* FIXME: MvL's new implementation assumes that Py_UNICODE_SIZE is - properly set, but the default rules below doesn't set it. I'll - sort this out some other day -- fredrik@pythonware.com */ - -#ifndef Py_UNICODE_SIZE -#error Must define Py_UNICODE_SIZE -#endif - -/* Setting Py_UNICODE_WIDE enables UCS-4 storage. Otherwise, Unicode - strings are stored as UCS-2 (with limited support for UTF-16) */ - -#if Py_UNICODE_SIZE >= 4 -#define Py_UNICODE_WIDE -#endif - -/* Set these flags if the platform has "wchar.h", "wctype.h" and the - wchar_t type is a 16-bit unsigned type */ -/* #define HAVE_WCHAR_H */ -/* #define HAVE_USABLE_WCHAR_T */ - -/* Defaults for various platforms */ -#ifndef PY_UNICODE_TYPE - -/* Windows has a usable wchar_t type (unless we're using UCS-4) */ -# if defined(MS_WIN32) && Py_UNICODE_SIZE == 2 -# define HAVE_USABLE_WCHAR_T -# define PY_UNICODE_TYPE wchar_t -# endif - -# if defined(Py_UNICODE_WIDE) -# define PY_UNICODE_TYPE Py_UCS4 -# endif - -#endif - -/* If the compiler provides a wchar_t type we try to support it - through the interface functions PyUnicode_FromWideChar() and - PyUnicode_AsWideChar(). */ - -#ifdef HAVE_USABLE_WCHAR_T -# ifndef HAVE_WCHAR_H -# define HAVE_WCHAR_H -# endif -#endif - -#ifdef HAVE_WCHAR_H -/* Work around a cosmetic bug in BSDI 4.x wchar.h; thanks to Thomas Wouters */ -# ifdef _HAVE_BSDI -# include -# endif -# include -#endif - -/* - * Use this typedef when you need to represent a UTF-16 surrogate pair - * as single unsigned integer. - */ -#if SIZEOF_INT >= 4 -typedef unsigned int Py_UCS4; -#elif SIZEOF_LONG >= 4 -typedef unsigned long Py_UCS4; -#endif - -typedef PY_UNICODE_TYPE Py_UNICODE; - -/* --- UCS-2/UCS-4 Name Mangling ------------------------------------------ */ - -/* Unicode API names are mangled to assure that UCS-2 and UCS-4 builds - produce different external names and thus cause import errors in - case Python interpreters and extensions with mixed compiled in - Unicode width assumptions are combined. */ - -#ifndef Py_UNICODE_WIDE - -# define PyUnicode_AsASCIIString PyUnicodeUCS2_AsASCIIString -# define PyUnicode_AsCharmapString PyUnicodeUCS2_AsCharmapString -# define PyUnicode_AsEncodedString PyUnicodeUCS2_AsEncodedString -# define PyUnicode_AsLatin1String PyUnicodeUCS2_AsLatin1String -# define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS2_AsRawUnicodeEscapeString -# define PyUnicode_AsUTF16String PyUnicodeUCS2_AsUTF16String -# define PyUnicode_AsUTF8String PyUnicodeUCS2_AsUTF8String -# define PyUnicode_AsUnicode PyUnicodeUCS2_AsUnicode -# define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS2_AsUnicodeEscapeString -# define PyUnicode_AsWideChar PyUnicodeUCS2_AsWideChar -# define PyUnicode_Compare PyUnicodeUCS2_Compare -# define PyUnicode_Concat PyUnicodeUCS2_Concat -# define PyUnicode_Contains PyUnicodeUCS2_Contains -# define PyUnicode_Count PyUnicodeUCS2_Count -# define PyUnicode_Decode PyUnicodeUCS2_Decode -# define PyUnicode_DecodeASCII PyUnicodeUCS2_DecodeASCII -# define PyUnicode_DecodeCharmap PyUnicodeUCS2_DecodeCharmap -# define PyUnicode_DecodeLatin1 PyUnicodeUCS2_DecodeLatin1 -# define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS2_DecodeRawUnicodeEscape -# define PyUnicode_DecodeUTF16 PyUnicodeUCS2_DecodeUTF16 -# define PyUnicode_DecodeUTF8 PyUnicodeUCS2_DecodeUTF8 -# define PyUnicode_DecodeUnicodeEscape PyUnicodeUCS2_DecodeUnicodeEscape -# define PyUnicode_Encode PyUnicodeUCS2_Encode -# define PyUnicode_EncodeASCII PyUnicodeUCS2_EncodeASCII -# define PyUnicode_EncodeCharmap PyUnicodeUCS2_EncodeCharmap -# define PyUnicode_EncodeDecimal PyUnicodeUCS2_EncodeDecimal -# define PyUnicode_EncodeLatin1 PyUnicodeUCS2_EncodeLatin1 -# define PyUnicode_EncodeRawUnicodeEscape PyUnicodeUCS2_EncodeRawUnicodeEscape -# define PyUnicode_EncodeUTF16 PyUnicodeUCS2_EncodeUTF16 -# define PyUnicode_EncodeUTF8 PyUnicodeUCS2_EncodeUTF8 -# define PyUnicode_EncodeUnicodeEscape PyUnicodeUCS2_EncodeUnicodeEscape -# define PyUnicode_Find PyUnicodeUCS2_Find -# define PyUnicode_Format PyUnicodeUCS2_Format -# define PyUnicode_FromEncodedObject PyUnicodeUCS2_FromEncodedObject -# define PyUnicode_FromObject PyUnicodeUCS2_FromObject -# define PyUnicode_FromOrdinal PyUnicodeUCS2_FromOrdinal -# define PyUnicode_FromUnicode PyUnicodeUCS2_FromUnicode -# define PyUnicode_FromWideChar PyUnicodeUCS2_FromWideChar -# define PyUnicode_GetDefaultEncoding PyUnicodeUCS2_GetDefaultEncoding -# define PyUnicode_GetMax PyUnicodeUCS2_GetMax -# define PyUnicode_GetSize PyUnicodeUCS2_GetSize -# define PyUnicode_Join PyUnicodeUCS2_Join -# define PyUnicode_Replace PyUnicodeUCS2_Replace -# define PyUnicode_Resize PyUnicodeUCS2_Resize -# define PyUnicode_SetDefaultEncoding PyUnicodeUCS2_SetDefaultEncoding -# define PyUnicode_Split PyUnicodeUCS2_Split -# define PyUnicode_Splitlines PyUnicodeUCS2_Splitlines -# define PyUnicode_Tailmatch PyUnicodeUCS2_Tailmatch -# define PyUnicode_Translate PyUnicodeUCS2_Translate -# define PyUnicode_TranslateCharmap PyUnicodeUCS2_TranslateCharmap -# define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS2_AsDefaultEncodedString -# define _PyUnicode_Fini _PyUnicodeUCS2_Fini -# define _PyUnicode_Init _PyUnicodeUCS2_Init -# define _PyUnicode_IsAlpha _PyUnicodeUCS2_IsAlpha -# define _PyUnicode_IsDecimalDigit _PyUnicodeUCS2_IsDecimalDigit -# define _PyUnicode_IsDigit _PyUnicodeUCS2_IsDigit -# define _PyUnicode_IsLinebreak _PyUnicodeUCS2_IsLinebreak -# define _PyUnicode_IsLowercase _PyUnicodeUCS2_IsLowercase -# define _PyUnicode_IsNumeric _PyUnicodeUCS2_IsNumeric -# define _PyUnicode_IsTitlecase _PyUnicodeUCS2_IsTitlecase -# define _PyUnicode_IsUppercase _PyUnicodeUCS2_IsUppercase -# define _PyUnicode_IsWhitespace _PyUnicodeUCS2_IsWhitespace -# define _PyUnicode_ToDecimalDigit _PyUnicodeUCS2_ToDecimalDigit -# define _PyUnicode_ToDigit _PyUnicodeUCS2_ToDigit -# define _PyUnicode_ToLowercase _PyUnicodeUCS2_ToLowercase -# define _PyUnicode_ToNumeric _PyUnicodeUCS2_ToNumeric -# define _PyUnicode_ToTitlecase _PyUnicodeUCS2_ToTitlecase -# define _PyUnicode_ToUppercase _PyUnicodeUCS2_ToUppercase - -#else - -# define PyUnicode_AsASCIIString PyUnicodeUCS4_AsASCIIString -# define PyUnicode_AsCharmapString PyUnicodeUCS4_AsCharmapString -# define PyUnicode_AsEncodedString PyUnicodeUCS4_AsEncodedString -# define PyUnicode_AsLatin1String PyUnicodeUCS4_AsLatin1String -# define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS4_AsRawUnicodeEscapeString -# define PyUnicode_AsUTF16String PyUnicodeUCS4_AsUTF16String -# define PyUnicode_AsUTF8String PyUnicodeUCS4_AsUTF8String -# define PyUnicode_AsUnicode PyUnicodeUCS4_AsUnicode -# define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS4_AsUnicodeEscapeString -# define PyUnicode_AsWideChar PyUnicodeUCS4_AsWideChar -# define PyUnicode_Compare PyUnicodeUCS4_Compare -# define PyUnicode_Concat PyUnicodeUCS4_Concat -# define PyUnicode_Contains PyUnicodeUCS4_Contains -# define PyUnicode_Count PyUnicodeUCS4_Count -# define PyUnicode_Decode PyUnicodeUCS4_Decode -# define PyUnicode_DecodeASCII PyUnicodeUCS4_DecodeASCII -# define PyUnicode_DecodeCharmap PyUnicodeUCS4_DecodeCharmap -# define PyUnicode_DecodeLatin1 PyUnicodeUCS4_DecodeLatin1 -# define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS4_DecodeRawUnicodeEscape -# define PyUnicode_DecodeUTF16 PyUnicodeUCS4_DecodeUTF16 -# define PyUnicode_DecodeUTF8 PyUnicodeUCS4_DecodeUTF8 -# define PyUnicode_DecodeUnicodeEscape PyUnicodeUCS4_DecodeUnicodeEscape -# define PyUnicode_Encode PyUnicodeUCS4_Encode -# define PyUnicode_EncodeASCII PyUnicodeUCS4_EncodeASCII -# define PyUnicode_EncodeCharmap PyUnicodeUCS4_EncodeCharmap -# define PyUnicode_EncodeDecimal PyUnicodeUCS4_EncodeDecimal -# define PyUnicode_EncodeLatin1 PyUnicodeUCS4_EncodeLatin1 -# define PyUnicode_EncodeRawUnicodeEscape PyUnicodeUCS4_EncodeRawUnicodeEscape -# define PyUnicode_EncodeUTF16 PyUnicodeUCS4_EncodeUTF16 -# define PyUnicode_EncodeUTF8 PyUnicodeUCS4_EncodeUTF8 -# define PyUnicode_EncodeUnicodeEscape PyUnicodeUCS4_EncodeUnicodeEscape -# define PyUnicode_Find PyUnicodeUCS4_Find -# define PyUnicode_Format PyUnicodeUCS4_Format -# define PyUnicode_FromEncodedObject PyUnicodeUCS4_FromEncodedObject -# define PyUnicode_FromObject PyUnicodeUCS4_FromObject -# define PyUnicode_FromOrdinal PyUnicodeUCS4_FromOrdinal -# define PyUnicode_FromUnicode PyUnicodeUCS4_FromUnicode -# define PyUnicode_FromWideChar PyUnicodeUCS4_FromWideChar -# define PyUnicode_GetDefaultEncoding PyUnicodeUCS4_GetDefaultEncoding -# define PyUnicode_GetMax PyUnicodeUCS4_GetMax -# define PyUnicode_GetSize PyUnicodeUCS4_GetSize -# define PyUnicode_Join PyUnicodeUCS4_Join -# define PyUnicode_Replace PyUnicodeUCS4_Replace -# define PyUnicode_Resize PyUnicodeUCS4_Resize -# define PyUnicode_SetDefaultEncoding PyUnicodeUCS4_SetDefaultEncoding -# define PyUnicode_Split PyUnicodeUCS4_Split -# define PyUnicode_Splitlines PyUnicodeUCS4_Splitlines -# define PyUnicode_Tailmatch PyUnicodeUCS4_Tailmatch -# define PyUnicode_Translate PyUnicodeUCS4_Translate -# define PyUnicode_TranslateCharmap PyUnicodeUCS4_TranslateCharmap -# define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS4_AsDefaultEncodedString -# define _PyUnicode_Fini _PyUnicodeUCS4_Fini -# define _PyUnicode_Init _PyUnicodeUCS4_Init -# define _PyUnicode_IsAlpha _PyUnicodeUCS4_IsAlpha -# define _PyUnicode_IsDecimalDigit _PyUnicodeUCS4_IsDecimalDigit -# define _PyUnicode_IsDigit _PyUnicodeUCS4_IsDigit -# define _PyUnicode_IsLinebreak _PyUnicodeUCS4_IsLinebreak -# define _PyUnicode_IsLowercase _PyUnicodeUCS4_IsLowercase -# define _PyUnicode_IsNumeric _PyUnicodeUCS4_IsNumeric -# define _PyUnicode_IsTitlecase _PyUnicodeUCS4_IsTitlecase -# define _PyUnicode_IsUppercase _PyUnicodeUCS4_IsUppercase -# define _PyUnicode_IsWhitespace _PyUnicodeUCS4_IsWhitespace -# define _PyUnicode_ToDecimalDigit _PyUnicodeUCS4_ToDecimalDigit -# define _PyUnicode_ToDigit _PyUnicodeUCS4_ToDigit -# define _PyUnicode_ToLowercase _PyUnicodeUCS4_ToLowercase -# define _PyUnicode_ToNumeric _PyUnicodeUCS4_ToNumeric -# define _PyUnicode_ToTitlecase _PyUnicodeUCS4_ToTitlecase -# define _PyUnicode_ToUppercase _PyUnicodeUCS4_ToUppercase - - -#endif - -/* --- Internal Unicode Operations ---------------------------------------- */ - -/* If you want Python to use the compiler's wctype.h functions instead - of the ones supplied with Python, define WANT_WCTYPE_FUNCTIONS or - configure Python using --with-ctype-functions. This reduces the - interpreter's code size. */ - -#if defined(HAVE_USABLE_WCHAR_T) && defined(WANT_WCTYPE_FUNCTIONS) - -#include - -#define Py_UNICODE_ISSPACE(ch) iswspace(ch) - -#define Py_UNICODE_ISLOWER(ch) iswlower(ch) -#define Py_UNICODE_ISUPPER(ch) iswupper(ch) -#define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) -#define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) - -#define Py_UNICODE_TOLOWER(ch) towlower(ch) -#define Py_UNICODE_TOUPPER(ch) towupper(ch) -#define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) - -#define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) -#define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) -#define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) - -#define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) -#define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) -#define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) - -#define Py_UNICODE_ISALPHA(ch) iswalpha(ch) - -#else - -#define Py_UNICODE_ISSPACE(ch) _PyUnicode_IsWhitespace(ch) - -#define Py_UNICODE_ISLOWER(ch) _PyUnicode_IsLowercase(ch) -#define Py_UNICODE_ISUPPER(ch) _PyUnicode_IsUppercase(ch) -#define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) -#define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) - -#define Py_UNICODE_TOLOWER(ch) _PyUnicode_ToLowercase(ch) -#define Py_UNICODE_TOUPPER(ch) _PyUnicode_ToUppercase(ch) -#define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) - -#define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) -#define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) -#define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) - -#define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) -#define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) -#define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) - -#define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch) - -#endif - -#define Py_UNICODE_ISALNUM(ch) \ - (Py_UNICODE_ISALPHA(ch) || \ - Py_UNICODE_ISDECIMAL(ch) || \ - Py_UNICODE_ISDIGIT(ch) || \ - Py_UNICODE_ISNUMERIC(ch)) - -#define Py_UNICODE_COPY(target, source, length)\ - (memcpy((target), (source), (length)*sizeof(Py_UNICODE))) - -#define Py_UNICODE_FILL(target, value, length) do\ - {int i; for (i = 0; i < (length); i++) (target)[i] = (value);}\ - while (0) - -#define Py_UNICODE_MATCH(string, offset, substring)\ - ((*((string)->str + (offset)) == *((substring)->str)) &&\ - !memcmp((string)->str + (offset), (substring)->str,\ - (substring)->length*sizeof(Py_UNICODE))) - -#ifdef __cplusplus -extern "C" { -#endif - -/* --- Unicode Type ------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - int length; /* Length of raw Unicode data in buffer */ - Py_UNICODE *str; /* Raw Unicode buffer */ - long hash; /* Hash value; -1 if not set */ - PyObject *defenc; /* (Default) Encoded version as Python - string, or NULL; this is used for - implementing the buffer protocol */ -} PyUnicodeObject; - -PyAPI_DATA(PyTypeObject) PyUnicode_Type; - -#define PyUnicode_Check(op) PyObject_TypeCheck(op, &PyUnicode_Type) -#define PyUnicode_CheckExact(op) ((op)->ob_type == &PyUnicode_Type) - -/* Fast access macros */ -#define PyUnicode_GET_SIZE(op) \ - (((PyUnicodeObject *)(op))->length) -#define PyUnicode_GET_DATA_SIZE(op) \ - (((PyUnicodeObject *)(op))->length * sizeof(Py_UNICODE)) -#define PyUnicode_AS_UNICODE(op) \ - (((PyUnicodeObject *)(op))->str) -#define PyUnicode_AS_DATA(op) \ - ((const char *)((PyUnicodeObject *)(op))->str) - -/* --- Constants ---------------------------------------------------------- */ - -/* This Unicode character will be used as replacement character during - decoding if the errors argument is set to "replace". Note: the - Unicode character U+FFFD is the official REPLACEMENT CHARACTER in - Unicode 3.0. */ - -#define Py_UNICODE_REPLACEMENT_CHARACTER ((Py_UNICODE) 0xFFFD) - -/* === Public API ========================================================= */ - -/* --- Plain Py_UNICODE --------------------------------------------------- */ - -/* Create a Unicode Object from the Py_UNICODE buffer u of the given - size. - - u may be NULL which causes the contents to be undefined. It is the - user's responsibility to fill in the needed data afterwards. Note - that modifying the Unicode object contents after construction is - only allowed if u was set to NULL. - - The buffer is copied into the new object. */ - -PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode( - const Py_UNICODE *u, /* Unicode buffer */ - int size /* size of buffer */ - ); - -/* Return a read-only pointer to the Unicode object's internal - Py_UNICODE buffer. */ - -PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode( - PyObject *unicode /* Unicode object */ - ); - -/* Get the length of the Unicode object. */ - -PyAPI_FUNC(int) PyUnicode_GetSize( - PyObject *unicode /* Unicode object */ - ); - -/* Get the maximum ordinal for a Unicode character. */ -PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void); - -/* Resize an already allocated Unicode object to the new size length. - - *unicode is modified to point to the new (resized) object and 0 - returned on success. - - This API may only be called by the function which also called the - Unicode constructor. The refcount on the object must be 1. Otherwise, - an error is returned. - - Error handling is implemented as follows: an exception is set, -1 - is returned and *unicode left untouched. - -*/ - -PyAPI_FUNC(int) PyUnicode_Resize( - PyObject **unicode, /* Pointer to the Unicode object */ - int length /* New length */ - ); - -/* Coerce obj to an Unicode object and return a reference with - *incremented* refcount. - - Coercion is done in the following way: - - 1. String and other char buffer compatible objects are decoded - under the assumptions that they contain data using the current - default encoding. Decoding is done in "strict" mode. - - 2. All other objects (including Unicode objects) raise an - exception. - - The API returns NULL in case of an error. The caller is responsible - for decref'ing the returned objects. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_FromEncodedObject( - register PyObject *obj, /* Object */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Coerce obj to an Unicode object and return a reference with - *incremented* refcount. - - Unicode objects are passed back as-is (subclasses are converted to - true Unicode objects), all other objects are delegated to - PyUnicode_FromEncodedObject(obj, NULL, "strict") which results in - using the default encoding as basis for decoding the object. - - The API returns NULL in case of an error. The caller is responsible - for decref'ing the returned objects. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_FromObject( - register PyObject *obj /* Object */ - ); - -/* --- wchar_t support for platforms which support it --------------------- */ - -#ifdef HAVE_WCHAR_H - -/* Create a Unicode Object from the whcar_t buffer w of the given - size. - - The buffer is copied into the new object. */ - -PyAPI_FUNC(PyObject*) PyUnicode_FromWideChar( - register const wchar_t *w, /* wchar_t buffer */ - int size /* size of buffer */ - ); - -/* Copies the Unicode Object contents into the whcar_t buffer w. At - most size wchar_t characters are copied. - - Returns the number of wchar_t characters copied or -1 in case of an - error. */ - -PyAPI_FUNC(int) PyUnicode_AsWideChar( - PyUnicodeObject *unicode, /* Unicode object */ - register wchar_t *w, /* wchar_t buffer */ - int size /* size of buffer */ - ); - -#endif - -/* --- Unicode ordinals --------------------------------------------------- */ - -/* Create a Unicode Object from the given Unicode code point ordinal. - - The ordinal must be in range(0x10000) on narrow Python builds - (UCS2), and range(0x110000) on wide builds (UCS4). A ValueError is - raised in case it is not. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_FromOrdinal(int ordinal); - -/* === Builtin Codecs ===================================================== - - Many of these APIs take two arguments encoding and errors. These - parameters encoding and errors have the same semantics as the ones - of the builtin unicode() API. - - Setting encoding to NULL causes the default encoding to be used. - - Error handling is set by errors which may also be set to NULL - meaning to use the default handling defined for the codec. Default - error handling for all builtin codecs is "strict" (ValueErrors are - raised). - - The codecs all use a similar interface. Only deviation from the - generic ones are documented. - -*/ - -/* --- Manage the default encoding ---------------------------------------- */ - -/* Return a Python string holding the default encoded value of the - Unicode object. - - The resulting string is cached in the Unicode object for subsequent - usage by this function. The cached version is needed to implement - the character buffer interface and will live (at least) as long as - the Unicode object itself. - - The refcount of the string is *not* incremented. - - *** Exported for internal use by the interpreter only !!! *** - -*/ - -PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString( - PyObject *, const char *); - -/* Returns the currently active default encoding. - - The default encoding is currently implemented as run-time settable - process global. This may change in future versions of the - interpreter to become a parameter which is managed on a per-thread - basis. - - */ - -PyAPI_FUNC(const char*) PyUnicode_GetDefaultEncoding(void); - -/* Sets the currently active default encoding. - - Returns 0 on success, -1 in case of an error. - - */ - -PyAPI_FUNC(int) PyUnicode_SetDefaultEncoding( - const char *encoding /* Encoding name in standard form */ - ); - -/* --- Generic Codecs ----------------------------------------------------- */ - -/* Create a Unicode object by decoding the encoded string s of the - given size. */ - -PyAPI_FUNC(PyObject*) PyUnicode_Decode( - const char *s, /* encoded string */ - int size, /* size of buffer */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Encodes a Py_UNICODE buffer of the given size and returns a - Python string object. */ - -PyAPI_FUNC(PyObject*) PyUnicode_Encode( - const Py_UNICODE *s, /* Unicode char buffer */ - int size, /* number of Py_UNICODE chars to encode */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Encodes a Unicode object and returns the result as Python string - object. */ - -PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString( - PyObject *unicode, /* Unicode object */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* --- UTF-7 Codecs ------------------------------------------------------- */ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7( - const char *string, /* UTF-7 encoded string */ - int length, /* size of string */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7( - const Py_UNICODE *data, /* Unicode char buffer */ - int length, /* number of Py_UNICODE chars to encode */ - int encodeSetO, /* force the encoder to encode characters in - Set O, as described in RFC2152 */ - int encodeWhiteSpace, /* force the encoder to encode space, tab, - carriage return and linefeed characters */ - const char *errors /* error handling */ - ); - -/* --- UTF-8 Codecs ------------------------------------------------------- */ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8( - const char *string, /* UTF-8 encoded string */ - int length, /* size of string */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String( - PyObject *unicode /* Unicode object */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8( - const Py_UNICODE *data, /* Unicode char buffer */ - int length, /* number of Py_UNICODE chars to encode */ - const char *errors /* error handling */ - ); - -/* --- UTF-16 Codecs ------------------------------------------------------ */ - -/* Decodes length bytes from a UTF-16 encoded buffer string and returns - the corresponding Unicode object. - - errors (if non-NULL) defines the error handling. It defaults - to "strict". - - If byteorder is non-NULL, the decoder starts decoding using the - given byte order: - - *byteorder == -1: little endian - *byteorder == 0: native order - *byteorder == 1: big endian - - In native mode, the first two bytes of the stream are checked for a - BOM mark. If found, the BOM mark is analysed, the byte order - adjusted and the BOM skipped. In the other modes, no BOM mark - interpretation is done. After completion, *byteorder is set to the - current byte order at the end of input data. - - If byteorder is NULL, the codec starts in native order mode. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16( - const char *string, /* UTF-16 encoded string */ - int length, /* size of string */ - const char *errors, /* error handling */ - int *byteorder /* pointer to byteorder to use - 0=native;-1=LE,1=BE; updated on - exit */ - ); - -/* Returns a Python string using the UTF-16 encoding in native byte - order. The string always starts with a BOM mark. */ - -PyAPI_FUNC(PyObject*) PyUnicode_AsUTF16String( - PyObject *unicode /* Unicode object */ - ); - -/* Returns a Python string object holding the UTF-16 encoded value of - the Unicode data. - - If byteorder is not 0, output is written according to the following - byte order: - - byteorder == -1: little endian - byteorder == 0: native byte order (writes a BOM mark) - byteorder == 1: big endian - - If byteorder is 0, the output string will always start with the - Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is - prepended. - - Note that Py_UNICODE data is being interpreted as UTF-16 reduced to - UCS-2. This trick makes it possible to add full UTF-16 capabilities - at a later point without compromising the APIs. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16( - const Py_UNICODE *data, /* Unicode char buffer */ - int length, /* number of Py_UNICODE chars to encode */ - const char *errors, /* error handling */ - int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ - ); - -/* --- Unicode-Escape Codecs ---------------------------------------------- */ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeUnicodeEscape( - const char *string, /* Unicode-Escape encoded string */ - int length, /* size of string */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_AsUnicodeEscapeString( - PyObject *unicode /* Unicode object */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape( - const Py_UNICODE *data, /* Unicode char buffer */ - int length /* Number of Py_UNICODE chars to encode */ - ); - -/* --- Raw-Unicode-Escape Codecs ------------------------------------------ */ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeRawUnicodeEscape( - const char *string, /* Raw-Unicode-Escape encoded string */ - int length, /* size of string */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_AsRawUnicodeEscapeString( - PyObject *unicode /* Unicode object */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape( - const Py_UNICODE *data, /* Unicode char buffer */ - int length /* Number of Py_UNICODE chars to encode */ - ); - -/* --- Latin-1 Codecs ----------------------------------------------------- - - Note: Latin-1 corresponds to the first 256 Unicode ordinals. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeLatin1( - const char *string, /* Latin-1 encoded string */ - int length, /* size of string */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_AsLatin1String( - PyObject *unicode /* Unicode object */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1( - const Py_UNICODE *data, /* Unicode char buffer */ - int length, /* Number of Py_UNICODE chars to encode */ - const char *errors /* error handling */ - ); - -/* --- ASCII Codecs ------------------------------------------------------- - - Only 7-bit ASCII data is excepted. All other codes generate errors. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeASCII( - const char *string, /* ASCII encoded string */ - int length, /* size of string */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_AsASCIIString( - PyObject *unicode /* Unicode object */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII( - const Py_UNICODE *data, /* Unicode char buffer */ - int length, /* Number of Py_UNICODE chars to encode */ - const char *errors /* error handling */ - ); - -/* --- Character Map Codecs ----------------------------------------------- - - This codec uses mappings to encode and decode characters. - - Decoding mappings must map single string characters to single - Unicode characters, integers (which are then interpreted as Unicode - ordinals) or None (meaning "undefined mapping" and causing an - error). - - Encoding mappings must map single Unicode characters to single - string characters, integers (which are then interpreted as Latin-1 - ordinals) or None (meaning "undefined mapping" and causing an - error). - - If a character lookup fails with a LookupError, the character is - copied as-is meaning that its ordinal value will be interpreted as - Unicode or Latin-1 ordinal resp. Because of this mappings only need - to contain those mappings which map characters to different code - points. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeCharmap( - const char *string, /* Encoded string */ - int length, /* size of string */ - PyObject *mapping, /* character mapping - (char ordinal -> unicode ordinal) */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_AsCharmapString( - PyObject *unicode, /* Unicode object */ - PyObject *mapping /* character mapping - (unicode ordinal -> char ordinal) */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap( - const Py_UNICODE *data, /* Unicode char buffer */ - int length, /* Number of Py_UNICODE chars to encode */ - PyObject *mapping, /* character mapping - (unicode ordinal -> char ordinal) */ - const char *errors /* error handling */ - ); - -/* Translate a Py_UNICODE buffer of the given length by applying a - character mapping table to it and return the resulting Unicode - object. - - The mapping table must map Unicode ordinal integers to Unicode - ordinal integers or None (causing deletion of the character). - - Mapping tables may be dictionaries or sequences. Unmapped character - ordinals (ones which cause a LookupError) are left untouched and - are copied as-is. - -*/ - -PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap( - const Py_UNICODE *data, /* Unicode char buffer */ - int length, /* Number of Py_UNICODE chars to encode */ - PyObject *table, /* Translate table */ - const char *errors /* error handling */ - ); - -#ifdef MS_WIN32 - -/* --- MBCS codecs for Windows -------------------------------------------- */ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCS( - const char *string, /* MBCS encoded string */ - int length, /* size of string */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_AsMBCSString( - PyObject *unicode /* Unicode object */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS( - const Py_UNICODE *data, /* Unicode char buffer */ - int length, /* Number of Py_UNICODE chars to encode */ - const char *errors /* error handling */ - ); - -#endif /* MS_WIN32 */ - -/* --- Decimal Encoder ---------------------------------------------------- */ - -/* Takes a Unicode string holding a decimal value and writes it into - an output buffer using standard ASCII digit codes. - - The output buffer has to provide at least length+1 bytes of storage - area. The output string is 0-terminated. - - The encoder converts whitespace to ' ', decimal characters to their - corresponding ASCII digit and all other Latin-1 characters except - \0 as-is. Characters outside this range (Unicode ordinals 1-256) - are treated as errors. This includes embedded NULL bytes. - - Error handling is defined by the errors argument: - - NULL or "strict": raise a ValueError - "ignore": ignore the wrong characters (these are not copied to the - output buffer) - "replace": replaces illegal characters with '?' - - Returns 0 on success, -1 on failure. - -*/ - -PyAPI_FUNC(int) PyUnicode_EncodeDecimal( - Py_UNICODE *s, /* Unicode buffer */ - int length, /* Number of Py_UNICODE chars to encode */ - char *output, /* Output buffer; must have size >= length */ - const char *errors /* error handling */ - ); - -/* --- Methods & Slots ---------------------------------------------------- - - These are capable of handling Unicode objects and strings on input - (we refer to them as strings in the descriptions) and return - Unicode objects or integers as apporpriate. */ - -/* Concat two strings giving a new Unicode string. */ - -PyAPI_FUNC(PyObject*) PyUnicode_Concat( - PyObject *left, /* Left string */ - PyObject *right /* Right string */ - ); - -/* Split a string giving a list of Unicode strings. - - If sep is NULL, splitting will be done at all whitespace - substrings. Otherwise, splits occur at the given separator. - - At most maxsplit splits will be done. If negative, no limit is set. - - Separators are not included in the resulting list. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_Split( - PyObject *s, /* String to split */ - PyObject *sep, /* String separator */ - int maxsplit /* Maxsplit count */ - ); - -/* Dito, but split at line breaks. - - CRLF is considered to be one line break. Line breaks are not - included in the resulting list. */ - -PyAPI_FUNC(PyObject*) PyUnicode_Splitlines( - PyObject *s, /* String to split */ - int keepends /* If true, line end markers are included */ - ); - -/* Translate a string by applying a character mapping table to it and - return the resulting Unicode object. - - The mapping table must map Unicode ordinal integers to Unicode - ordinal integers or None (causing deletion of the character). - - Mapping tables may be dictionaries or sequences. Unmapped character - ordinals (ones which cause a LookupError) are left untouched and - are copied as-is. - -*/ - -PyAPI_FUNC(PyObject *) PyUnicode_Translate( - PyObject *str, /* String */ - PyObject *table, /* Translate table */ - const char *errors /* error handling */ - ); - -/* Join a sequence of strings using the given separator and return - the resulting Unicode string. */ - -PyAPI_FUNC(PyObject*) PyUnicode_Join( - PyObject *separator, /* Separator string */ - PyObject *seq /* Sequence object */ - ); - -/* Return 1 if substr matches str[start:end] at the given tail end, 0 - otherwise. */ - -PyAPI_FUNC(int) PyUnicode_Tailmatch( - PyObject *str, /* String */ - PyObject *substr, /* Prefix or Suffix string */ - int start, /* Start index */ - int end, /* Stop index */ - int direction /* Tail end: -1 prefix, +1 suffix */ - ); - -/* Return the first position of substr in str[start:end] using the - given search direction or -1 if not found. -2 is returned in case - an error occurred and an exception is set. */ - -PyAPI_FUNC(int) PyUnicode_Find( - PyObject *str, /* String */ - PyObject *substr, /* Substring to find */ - int start, /* Start index */ - int end, /* Stop index */ - int direction /* Find direction: +1 forward, -1 backward */ - ); - -/* Count the number of occurrences of substr in str[start:end]. */ - -PyAPI_FUNC(int) PyUnicode_Count( - PyObject *str, /* String */ - PyObject *substr, /* Substring to count */ - int start, /* Start index */ - int end /* Stop index */ - ); - -/* Replace at most maxcount occurrences of substr in str with replstr - and return the resulting Unicode object. */ - -PyAPI_FUNC(PyObject *) PyUnicode_Replace( - PyObject *str, /* String */ - PyObject *substr, /* Substring to find */ - PyObject *replstr, /* Substring to replace */ - int maxcount /* Max. number of replacements to apply; - -1 = all */ - ); - -/* Compare two strings and return -1, 0, 1 for less than, equal, - greater than resp. */ - -PyAPI_FUNC(int) PyUnicode_Compare( - PyObject *left, /* Left string */ - PyObject *right /* Right string */ - ); - -/* Apply a argument tuple or dictionary to a format string and return - the resulting Unicode string. */ - -PyAPI_FUNC(PyObject *) PyUnicode_Format( - PyObject *format, /* Format string */ - PyObject *args /* Argument tuple or dictionary */ - ); - -/* Checks whether element is contained in container and return 1/0 - accordingly. - - element has to coerce to an one element Unicode string. -1 is - returned in case of an error. */ - -PyAPI_FUNC(int) PyUnicode_Contains( - PyObject *container, /* Container string */ - PyObject *element /* Element string */ - ); - -/* Externally visible for str.strip(unicode) */ -PyAPI_FUNC(PyObject *) _PyUnicode_XStrip( - PyUnicodeObject *self, - int striptype, - PyObject *sepobj - ); - -/* === Characters Type APIs =============================================== */ - -/* These should not be used directly. Use the Py_UNICODE_IS* and - Py_UNICODE_TO* macros instead. - - These APIs are implemented in Objects/unicodectype.c. - -*/ - -PyAPI_FUNC(int) _PyUnicode_IsLowercase( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsUppercase( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsTitlecase( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsWhitespace( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsLinebreak( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToLowercase( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToUppercase( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToTitlecase( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_ToDecimalDigit( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_ToDigit( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(double) _PyUnicode_ToNumeric( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsDecimalDigit( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsDigit( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsNumeric( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsAlpha( - Py_UNICODE ch /* Unicode character */ - ); - -#ifdef __cplusplus -} -#endif -#endif /* Py_USING_UNICODE */ -#endif /* !Py_UNICODEOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/include/weakrefobject.h b/SDKs/XPlatform/Cypython-2.3.3/include/weakrefobject.h deleted file mode 100644 index e6e89d35..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/include/weakrefobject.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Weak references objects for Python. */ - -#ifndef Py_WEAKREFOBJECT_H -#define Py_WEAKREFOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct _PyWeakReference PyWeakReference; - -struct _PyWeakReference { - PyObject_HEAD - PyObject *wr_object; - PyObject *wr_callback; - long hash; - PyWeakReference *wr_prev; - PyWeakReference *wr_next; -}; - -PyAPI_DATA(PyTypeObject) _PyWeakref_RefType; -PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType; -PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType; - -#define PyWeakref_CheckRef(op) \ - ((op)->ob_type == &_PyWeakref_RefType) -#define PyWeakref_CheckProxy(op) \ - (((op)->ob_type == &_PyWeakref_ProxyType) || \ - ((op)->ob_type == &_PyWeakref_CallableProxyType)) -#define PyWeakref_Check(op) \ - (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op)) - - -PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob, - PyObject *callback); -PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob, - PyObject *callback); -PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref); - -PyAPI_FUNC(long) _PyWeakref_GetWeakrefCount(PyWeakReference *head); - -PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self); - -#define PyWeakref_GET_OBJECT(ref) (((PyWeakReference *)(ref))->wr_object) - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_WEAKREFOBJECT_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/pyconfig_dyn/pyconfig.h b/SDKs/XPlatform/Cypython-2.3.3/pyconfig_dyn/pyconfig.h deleted file mode 100644 index a328f275..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/pyconfig_dyn/pyconfig.h +++ /dev/null @@ -1,596 +0,0 @@ -#ifndef Py_CONFIG_H -#define Py_CONFIG_H - -/* pyconfig.h. NOT Generated automatically by configure. - -This is a manually maintained version used for the Watcom, -Borland and Microsoft Visual C++ compilers. It is a -standard part of the Python distribution. - -WINDOWS DEFINES: -The code specific to Windows should be wrapped around one of -the following #defines - -MS_WIN64 - Code specific to the MS Win64 API -MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs) -MS_WINDOWS - Code specific to Windows, but all versions. -Py_ENABLE_SHARED - Code if the Python core is built as a DLL. - -Also note that neither "_M_IX86" or "_MSC_VER" should be used for -any purpose other than "Windows Intel x86 specific" and "Microsoft -compiler specific". Therefore, these should be very rare. - - -NOTE: The following symbols are deprecated: -NT, WIN32, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT -MS_CORE_DLL. - -*/ - -#include -#define HAVE_LIMITS_H -#define HAVE_SYS_UTIME_H -#define HAVE_HYPOT -#define HAVE_TEMPNAM -#define HAVE_TMPFILE -#define HAVE_TMPNAM -#define HAVE_CLOCK -#define HAVE_STRFTIME -#define HAVE_STRERROR -#define DONT_HAVE_SIG_ALARM -#define DONT_HAVE_SIG_PAUSE -#define LONG_BIT 32 -#define WORD_BIT 32 -#define PREFIX "" -#define EXEC_PREFIX "" - -#define MS_WIN32 /* only support win32 and greater. */ -#define MS_WINDOWS -#if _XBOX -#define MS_XBOX -#endif - -#ifndef PYTHONPATH -# define PYTHONPATH ".\\DLLs;.\\lib;.\\lib\\plat-win;.\\lib\\lib-tk" -#endif -#define NT_THREADS -#define WITH_THREAD -#ifndef NETSCAPE_PI -#define USE_SOCKET -#endif - -/* Compiler specific defines */ - -/* ------------------------------------------------------------------------*/ -/* Microsoft C defines _MSC_VER */ -#ifdef _MSC_VER - -/* We want COMPILER to expand to a string containing _MSC_VER's *value*. - * This is horridly tricky, because the stringization operator only works - * on macro arguments, and doesn't evaluate macros passed *as* arguments. - * Attempts simpler than the following appear doomed to produce "_MSC_VER" - * literally in the string. - */ -#define _Py_PASTE_VERSION(SUFFIX) \ - ("[MSC v." _Py_STRINGIZE(_MSC_VER) " " SUFFIX "]") -/* e.g., this produces, after compile-time string catenation, - * ("[MSC v.1200 32 bit (Intel)]") - * - * _Py_STRINGIZE(_MSC_VER) expands to - * _Py_STRINGIZE1((_MSC_VER)) expands to - * _Py_STRINGIZE2(_MSC_VER) but as this call is the result of token-pasting - * it's scanned again for macros and so further expands to (under MSVC 6) - * _Py_STRINGIZE2(1200) which then expands to - * "1200" - */ -#define _Py_STRINGIZE(X) _Py_STRINGIZE1((X)) -#define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X -#define _Py_STRINGIZE2(X) #X - -/* MSVC defines _WINxx to differentiate the windows platform types - - Note that for compatibility reasons _WIN32 is defined on Win32 - *and* on Win64. For the same reasons, in Python, MS_WIN32 is - defined on Win32 *and* Win64. Win32 only code must therefore be - guarded as follows: - #if defined(MS_WIN32) && !defined(MS_WIN64) -*/ -#ifdef _WIN64 -#define MS_WIN64 -#endif - -/* set the COMPILER */ -#ifdef MS_WIN64 -#ifdef _M_IX86 -#define COMPILER _Py_PASTE_VERSION("64 bit (Intel)") -#else -#define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)") -#endif -#endif /* MS_WIN64 */ - -#if defined(MS_WIN32) && !defined(MS_WIN64) -#ifdef _M_IX86 -#define COMPILER _Py_PASTE_VERSION("32 bit (Intel)") -#else -#define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)") -#endif -#endif /* MS_WIN32 && !MS_WIN64 */ - -typedef int pid_t; -#define hypot _hypot - -#endif /* _MSC_VER */ - -/* define some ANSI types that are not defined in earlier Win headers */ -#if defined(_MSC_VER) && _MSC_VER >= 1200 -/* This file only exists in VC 6.0 or higher */ -#include -#endif - -/* ------------------------------------------------------------------------*/ -/* The Borland compiler defines __BORLANDC__ */ -/* XXX These defines are likely incomplete, but should be easy to fix. */ -#ifdef __BORLANDC__ -#define COMPILER "[Borland]" - -#ifdef _WIN32 -/* tested with BCC 5.5 (__BORLANDC__ >= 0x0550) - */ - -typedef int pid_t; -/* BCC55 seems to understand __declspec(dllimport), it is used in its - own header files (winnt.h, ...) - so we can do nothing and get the default*/ - -#undef HAVE_SYS_UTIME_H -#define HAVE_UTIME_H -#define HAVE_DIRENT_H - -/* rename a few functions for the Borland compiler */ -#include -#define _chsize chsize -#define _setmode setmode - -#else /* !_WIN32 */ -#error "Only Win32 and later are supported" -#endif /* !_WIN32 */ - -#endif /* BORLANDC */ - -/* ------------------------------------------------------------------------*/ -/* egcs/gnu-win32 defines __GNUC__ and _WIN32 */ -#if defined(__GNUC__) && defined(_WIN32) -/* XXX These defines are likely incomplete, but should be easy to fix. - They should be complete enough to build extension modules. */ -/* Suggested by Rene Liebscher to avoid a GCC 2.91.* - bug that requires structure imports. More recent versions of the - compiler don't exhibit this bug. -*/ -#if (__GNUC__==2) && (__GNUC_MINOR__<=91) -#warning "Please use an up-to-date version of gcc! (>2.91 recommended)" -#endif - -#define COMPILER "[gcc]" -#define hypot _hypot -#define PY_LONG_LONG long long -#endif /* GNUC */ - -/* ------------------------------------------------------------------------*/ -/* lcc-win32 defines __LCC__ */ -#if defined(__LCC__) -/* XXX These defines are likely incomplete, but should be easy to fix. - They should be complete enough to build extension modules. */ - -#define COMPILER "[lcc-win32]" -typedef int pid_t; -/* __declspec() is supported here too - do nothing to get the defaults */ - -#endif /* LCC */ - -/* ------------------------------------------------------------------------*/ -/* End of compilers - finish up */ - -#ifndef NO_STDIO_H -# include -#endif - -/* 64 bit ints are usually spelt __int64 unless compiler has overridden */ -#define HAVE_LONG_LONG 1 -#ifndef PY_LONG_LONG -# define PY_LONG_LONG __int64 -#endif - -/* For Windows the Python core is in a DLL by default. Test -Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ -#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED) -# define Py_ENABLE_SHARED 1 /* standard symbol for shared library */ -# define MS_COREDLL /* deprecated old symbol */ -#endif /* !MS_NO_COREDLL && ... */ - -/* Deprecated USE_DL_EXPORT macro - please use Py_BUILD_CORE */ -#ifdef USE_DL_EXPORT -# define Py_BUILD_CORE -#endif /* USE_DL_EXPORT */ - -/* All windows compilers that use this header support __declspec */ -#define HAVE_DECLSPEC_DLL - -/* For an MSVC DLL, we can nominate the .lib files used by extensions */ -#ifdef MS_COREDLL -# ifndef Py_BUILD_CORE /* not building the core - must be an ext */ -# if defined(_MSC_VER) - /* So MSVC users need not specify the .lib file in - their Makefile (other compilers are generally - taken care of by distutils.) */ -# if 0 // we don't want help! -# ifdef _DEBUG -# pragma comment(lib,"python23_d.lib") -# else -# pragma comment(lib,"python23.lib") -# endif /* _DEBUG */ -# endif /* 0 */ -# endif /* _MSC_VER */ -# endif /* Py_BUILD_CORE */ -#endif /* MS_COREDLL */ - -#if defined(MS_WIN64) -/* maintain "win32" sys.platform for backward compatibility of Python code, - the Win64 API should be close enough to the Win32 API to make this - preferable */ -# define PLATFORM "win32" -# define SIZEOF_VOID_P 8 -# define SIZEOF_TIME_T 8 -# define SIZEOF_OFF_T 4 -# define SIZEOF_FPOS_T 8 -# define SIZEOF_HKEY 8 -/* configure.in defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG, - sizeof(off_t) > sizeof(long), and sizeof(PY_LONG_LONG) >= sizeof(off_t). - On Win64 the second condition is not true, but if fpos_t replaces off_t - then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64 - should define this. */ -# define HAVE_LARGEFILE_SUPPORT -#elif defined(MS_WIN32) -# define PLATFORM "win32" -# define HAVE_LARGEFILE_SUPPORT -# define SIZEOF_VOID_P 4 -# define SIZEOF_TIME_T 4 -# define SIZEOF_OFF_T 4 -# define SIZEOF_FPOS_T 8 -# define SIZEOF_HKEY 4 -#endif - -#ifdef _DEBUG -# define Py_DEBUG -#endif - - -#ifdef MS_WIN32 - -#define SIZEOF_SHORT 2 -#define SIZEOF_INT 4 -#define SIZEOF_LONG 4 -#define SIZEOF_LONG_LONG 8 - -#endif - -/* Fairly standard from here! */ - -/* Define if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -/* #undef _ALL_SOURCE */ -#endif - -/* Define to empty if the keyword does not work. */ -/* #define const */ - -/* Define if you have dirent.h. */ -/* #define DIRENT 1 */ - -/* Define to the type of elements in the array set by `getgroups'. - Usually this is either `int' or `gid_t'. */ -/* #undef GETGROUPS_T */ - -/* Define to `int' if doesn't define. */ -/* #undef gid_t */ - -/* Define if your struct tm has tm_zone. */ -/* #undef HAVE_TM_ZONE */ - -/* Define if you don't have tm_zone but do have the external array - tzname. */ -#define HAVE_TZNAME - -/* Define if on MINIX. */ -/* #undef _MINIX */ - -/* Define to `int' if doesn't define. */ -/* #undef mode_t */ - -/* Define if you don't have dirent.h, but have ndir.h. */ -/* #undef NDIR */ - -/* Define to `long' if doesn't define. */ -/* #undef off_t */ - -/* Define to `int' if doesn't define. */ -/* #undef pid_t */ - -/* Define if the system does not provide POSIX.1 features except - with this defined. */ -/* #undef _POSIX_1_SOURCE */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* Define to `int' if doesn't define. */ -#if _MSC_VER + 0 >= 1300 -/* VC.NET typedefs socklen_t in ws2tcpip.h. */ -#else -#define socklen_t int -#endif - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you don't have dirent.h, but have sys/dir.h. */ -/* #undef SYSDIR */ - -/* Define if you don't have dirent.h, but have sys/ndir.h. */ -/* #undef SYSNDIR */ - -/* Define if you can safely include both and . */ -/* #undef TIME_WITH_SYS_TIME */ - -/* Define if your declares struct tm. */ -/* #define TM_IN_SYS_TIME 1 */ - -/* Define to `int' if doesn't define. */ -/* #undef uid_t */ - -/* Define if the closedir function returns void instead of int. */ -/* #undef VOID_CLOSEDIR */ - -/* Define if your contains bad prototypes for exec*() - (as it does on SGI IRIX 4.x) */ -/* #undef BAD_EXEC_PROTOTYPES */ - -/* Define if getpgrp() must be called as getpgrp(0) - and (consequently) setpgrp() as setpgrp(0, 0). */ -/* #undef GETPGRP_HAVE_ARGS */ - -/* Define this if your time.h defines altzone */ -/* #define HAVE_ALTZONE */ - -/* Define if you have the putenv function. */ -#ifndef MS_XBOX -#define HAVE_PUTENV -#endif - -/* Define if your compiler supports function prototypes */ -#define HAVE_PROTOTYPES - -/* Define if you can safely include both and - (which you can't on SCO ODT 3.0). */ -/* #undef SYS_SELECT_WITH_SYS_TIME */ - -/* Define if you want to use SGI (IRIX 4) dynamic linking. - This requires the "dl" library by Jack Jansen, - ftp://ftp.cwi.nl/pub/dynload/dl-1.6.tar.Z. - Don't bother on IRIX 5, it already has dynamic linking using SunOS - style shared libraries */ -/* #undef WITH_SGI_DL */ - -/* Define if you want to emulate SGI (IRIX 4) dynamic linking. - This is rumoured to work on VAX (Ultrix), Sun3 (SunOS 3.4), - Sequent Symmetry (Dynix), and Atari ST. - This requires the "dl-dld" library, - ftp://ftp.cwi.nl/pub/dynload/dl-dld-1.1.tar.Z, - as well as the "GNU dld" library, - ftp://ftp.cwi.nl/pub/dynload/dld-3.2.3.tar.Z. - Don't bother on SunOS 4 or 5, they already have dynamic linking using - shared libraries */ -/* #undef WITH_DL_DLD */ - -/* Define if you want documentation strings in extension modules */ -#define WITH_DOC_STRINGS 1 - -/* Define if you want to compile in rudimentary thread support */ -/* #undef WITH_THREAD */ - -/* Define if you want to use the GNU readline library */ -/* #define WITH_READLINE 1 */ - -/* Define if you want to have a Unicode type. */ -#define Py_USING_UNICODE - -/* Define as the integral type used for Unicode representation. */ -#define PY_UNICODE_TYPE unsigned short - -/* Define as the size of the unicode type. */ -#define Py_UNICODE_SIZE SIZEOF_SHORT - -/* Define if you have a useable wchar_t type defined in wchar.h; useable - means wchar_t must be 16-bit unsigned type. (see - Include/unicodeobject.h). */ -#if Py_UNICODE_SIZE == 2 -#define HAVE_USABLE_WCHAR_T - -/* Define to indicate that the Python Unicode representation can be passed - as-is to Win32 Wide API. */ -#ifndef MS_XBOX -#define Py_WIN_WIDE_FILENAMES -#endif -#endif - -/* Use Python's own small-block memory-allocator. */ -#define WITH_PYMALLOC 1 - -/* Enable \n, \r, \r\n line ends on import; also the 'U' mode flag for open. */ -#define WITH_UNIVERSAL_NEWLINES 1 - -/* Define if you have clock. */ -/* #define HAVE_CLOCK */ - -/* Define when any dynamic module loading is enabled */ -#define HAVE_DYNAMIC_LOADING - -/* Define if you have ftime. */ -#define HAVE_FTIME - -/* Define if you have getpeername. */ -#define HAVE_GETPEERNAME - -/* Define if you have getpgrp. */ -/* #undef HAVE_GETPGRP */ - -/* Define if you have getpid. */ -#define HAVE_GETPID - -/* Define if you have gettimeofday. */ -/* #undef HAVE_GETTIMEOFDAY */ - -/* Define if you have getwd. */ -/* #undef HAVE_GETWD */ - -/* Define if you have lstat. */ -/* #undef HAVE_LSTAT */ - -/* Define if you have the mktime function. */ -#define HAVE_MKTIME - -/* Define if you have nice. */ -/* #undef HAVE_NICE */ - -/* Define if you have readlink. */ -/* #undef HAVE_READLINK */ - -/* Define if you have select. */ -/* #undef HAVE_SELECT */ - -/* Define if you have setpgid. */ -/* #undef HAVE_SETPGID */ - -/* Define if you have setpgrp. */ -/* #undef HAVE_SETPGRP */ - -/* Define if you have setsid. */ -/* #undef HAVE_SETSID */ - -/* Define if you have setvbuf. */ -#define HAVE_SETVBUF - -/* Define if you have siginterrupt. */ -/* #undef HAVE_SIGINTERRUPT */ - -/* Define if you have symlink. */ -/* #undef HAVE_SYMLINK */ - -/* Define if you have tcgetpgrp. */ -/* #undef HAVE_TCGETPGRP */ - -/* Define if you have tcsetpgrp. */ -/* #undef HAVE_TCSETPGRP */ - -/* Define if you have times. */ -/* #undef HAVE_TIMES */ - -/* Define if you have uname. */ -/* #undef HAVE_UNAME */ - -/* Define if you have waitpid. */ -/* #undef HAVE_WAITPID */ - -/* Define to 1 if you have the `wcscoll' function. */ -#define HAVE_WCSCOLL 1 - -/* Define if you have the header file. */ -/* #undef HAVE_DLFCN_H */ - -/* Define if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDARG_H 1 - -/* Define if you have the prototypes. */ -#define HAVE_STDARG_PROTOTYPES - -/* Define if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_AUDIOIO_H */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_PARAM_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_SELECT_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_TIME_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_TIMES_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_UN_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_UTIME_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_UTSNAME_H 1 */ - -/* Define if you have the header file. */ -/* #undef HAVE_THREAD_H */ - -/* Define if you have the header file. */ -/* #define HAVE_UNISTD_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_UTIME_H 1 */ - -/* Define if the compiler provides a wchar.h header file. */ -#define HAVE_WCHAR_H 1 - -/* Define if you have the dl library (-ldl). */ -/* #undef HAVE_LIBDL */ - -/* Define if you have the mpc library (-lmpc). */ -/* #undef HAVE_LIBMPC */ - -/* Define if you have the nsl library (-lnsl). */ -#define HAVE_LIBNSL 1 - -/* Define if you have the seq library (-lseq). */ -/* #undef HAVE_LIBSEQ */ - -/* Define if you have the socket library (-lsocket). */ -#define HAVE_LIBSOCKET 1 - -/* Define if you have the sun library (-lsun). */ -/* #undef HAVE_LIBSUN */ - -/* Define if you have the termcap library (-ltermcap). */ -/* #undef HAVE_LIBTERMCAP */ - -/* Define if you have the termlib library (-ltermlib). */ -/* #undef HAVE_LIBTERMLIB */ - -/* Define if you have the thread library (-lthread). */ -/* #undef HAVE_LIBTHREAD */ -#endif /* !Py_CONFIG_H */ diff --git a/SDKs/XPlatform/Cypython-2.3.3/pyconfig_static/pyconfig.h b/SDKs/XPlatform/Cypython-2.3.3/pyconfig_static/pyconfig.h deleted file mode 100644 index 39165f93..00000000 --- a/SDKs/XPlatform/Cypython-2.3.3/pyconfig_static/pyconfig.h +++ /dev/null @@ -1,600 +0,0 @@ -#ifndef Py_CONFIG_H -#define Py_CONFIG_H - -/* pyconfig.h. NOT Generated automatically by configure. - -This is a manually maintained version used for the Watcom, -Borland and Microsoft Visual C++ compilers. It is a -standard part of the Python distribution. - -WINDOWS DEFINES: -The code specific to Windows should be wrapped around one of -the following #defines - -MS_WIN64 - Code specific to the MS Win64 API -MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs) -MS_WINDOWS - Code specific to Windows, but all versions. -Py_ENABLE_SHARED - Code if the Python core is built as a DLL. - -Also note that neither "_M_IX86" or "_MSC_VER" should be used for -any purpose other than "Windows Intel x86 specific" and "Microsoft -compiler specific". Therefore, these should be very rare. - - -NOTE: The following symbols are deprecated: -NT, WIN32, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT -MS_CORE_DLL. - -*/ - -#include -#define HAVE_LIMITS_H -#define HAVE_SYS_UTIME_H -#define HAVE_HYPOT -#define HAVE_TEMPNAM -#define HAVE_TMPFILE -#define HAVE_TMPNAM -#define HAVE_CLOCK -#define HAVE_STRFTIME -#define HAVE_STRERROR -#define DONT_HAVE_SIG_ALARM -#define DONT_HAVE_SIG_PAUSE -#define LONG_BIT 32 -#define WORD_BIT 32 -#define PREFIX "" -#define EXEC_PREFIX "" - -#define MS_WIN32 /* only support win32 and greater. */ -#define MS_WINDOWS -#if _XBOX -#define MS_XBOX -#endif - -#ifndef PYTHONPATH -# define PYTHONPATH ".\\DLLs;.\\lib;.\\lib\\plat-win;.\\lib\\lib-tk" -#endif -#define NT_THREADS -#define WITH_THREAD -#ifndef NETSCAPE_PI -#define USE_SOCKET -#endif - -/* Compiler specific defines */ - -/* ------------------------------------------------------------------------*/ -/* Microsoft C defines _MSC_VER */ -#ifdef _MSC_VER - -/* We want COMPILER to expand to a string containing _MSC_VER's *value*. - * This is horridly tricky, because the stringization operator only works - * on macro arguments, and doesn't evaluate macros passed *as* arguments. - * Attempts simpler than the following appear doomed to produce "_MSC_VER" - * literally in the string. - */ -#define _Py_PASTE_VERSION(SUFFIX) \ - ("[MSC v." _Py_STRINGIZE(_MSC_VER) " " SUFFIX "]") -/* e.g., this produces, after compile-time string catenation, - * ("[MSC v.1200 32 bit (Intel)]") - * - * _Py_STRINGIZE(_MSC_VER) expands to - * _Py_STRINGIZE1((_MSC_VER)) expands to - * _Py_STRINGIZE2(_MSC_VER) but as this call is the result of token-pasting - * it's scanned again for macros and so further expands to (under MSVC 6) - * _Py_STRINGIZE2(1200) which then expands to - * "1200" - */ -#define _Py_STRINGIZE(X) _Py_STRINGIZE1((X)) -#define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X -#define _Py_STRINGIZE2(X) #X - -/* MSVC defines _WINxx to differentiate the windows platform types - - Note that for compatibility reasons _WIN32 is defined on Win32 - *and* on Win64. For the same reasons, in Python, MS_WIN32 is - defined on Win32 *and* Win64. Win32 only code must therefore be - guarded as follows: - #if defined(MS_WIN32) && !defined(MS_WIN64) -*/ -#ifdef _WIN64 -#define MS_WIN64 -#endif - -/* set the COMPILER */ -#ifdef MS_WIN64 -#ifdef _M_IX86 -#define COMPILER _Py_PASTE_VERSION("64 bit (Intel)") -#else -#define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)") -#endif -#endif /* MS_WIN64 */ - -#if defined(MS_WIN32) && !defined(MS_WIN64) -#ifdef _M_IX86 -#define COMPILER _Py_PASTE_VERSION("32 bit (Intel)") -#else -#define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)") -#endif -#endif /* MS_WIN32 && !MS_WIN64 */ - -typedef int pid_t; -#define hypot _hypot - -#endif /* _MSC_VER */ - -/* define some ANSI types that are not defined in earlier Win headers */ -#if defined(_MSC_VER) && _MSC_VER >= 1200 -/* This file only exists in VC 6.0 or higher */ -#include -#endif - -/* ------------------------------------------------------------------------*/ -/* The Borland compiler defines __BORLANDC__ */ -/* XXX These defines are likely incomplete, but should be easy to fix. */ -#ifdef __BORLANDC__ -#define COMPILER "[Borland]" - -#ifdef _WIN32 -/* tested with BCC 5.5 (__BORLANDC__ >= 0x0550) - */ - -typedef int pid_t; -/* BCC55 seems to understand __declspec(dllimport), it is used in its - own header files (winnt.h, ...) - so we can do nothing and get the default*/ - -#undef HAVE_SYS_UTIME_H -#define HAVE_UTIME_H -#define HAVE_DIRENT_H - -/* rename a few functions for the Borland compiler */ -#include -#define _chsize chsize -#define _setmode setmode - -#else /* !_WIN32 */ -#error "Only Win32 and later are supported" -#endif /* !_WIN32 */ - -#endif /* BORLANDC */ - -/* ------------------------------------------------------------------------*/ -/* egcs/gnu-win32 defines __GNUC__ and _WIN32 */ -#if defined(__GNUC__) && defined(_WIN32) -/* XXX These defines are likely incomplete, but should be easy to fix. - They should be complete enough to build extension modules. */ -/* Suggested by Rene Liebscher to avoid a GCC 2.91.* - bug that requires structure imports. More recent versions of the - compiler don't exhibit this bug. -*/ -#if (__GNUC__==2) && (__GNUC_MINOR__<=91) -#warning "Please use an up-to-date version of gcc! (>2.91 recommended)" -#endif - -#define COMPILER "[gcc]" -#define hypot _hypot -#define PY_LONG_LONG long long -#endif /* GNUC */ - -/* ------------------------------------------------------------------------*/ -/* lcc-win32 defines __LCC__ */ -#if defined(__LCC__) -/* XXX These defines are likely incomplete, but should be easy to fix. - They should be complete enough to build extension modules. */ - -#define COMPILER "[lcc-win32]" -typedef int pid_t; -/* __declspec() is supported here too - do nothing to get the defaults */ - -#endif /* LCC */ - -/* ------------------------------------------------------------------------*/ -/* End of compilers - finish up */ - -#ifndef NO_STDIO_H -# include -#endif - -/* 64 bit ints are usually spelt __int64 unless compiler has overridden */ -#define HAVE_LONG_LONG 1 -#ifndef PY_LONG_LONG -# define PY_LONG_LONG __int64 -#endif - -#if !defined(Py_NO_ENABLE_SHARED) -# define Py_NO_ENABLE_SHARED // HACK because this file seems to ignore our pre-processor definitions -#endif - -/* For Windows the Python core is in a DLL by default. Test -Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ -#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED) -# define Py_ENABLE_SHARED 1 /* standard symbol for shared library */ -# define MS_COREDLL /* deprecated old symbol */ -#endif /* !MS_NO_COREDLL && ... */ - -/* Deprecated USE_DL_EXPORT macro - please use Py_BUILD_CORE */ -#ifdef USE_DL_EXPORT -# define Py_BUILD_CORE -#endif /* USE_DL_EXPORT */ - -/* All windows compilers that use this header support __declspec */ -#define HAVE_DECLSPEC_DLL - -/* For an MSVC DLL, we can nominate the .lib files used by extensions */ -#ifdef MS_COREDLL -# ifndef Py_BUILD_CORE /* not building the core - must be an ext */ -# if defined(_MSC_VER) - /* So MSVC users need not specify the .lib file in - their Makefile (other compilers are generally - taken care of by distutils.) */ -# if 0 // we don't want help! -# ifdef _DEBUG -# pragma comment(lib,"python23_d.lib") -# else -# pragma comment(lib,"python23.lib") -# endif /* _DEBUG */ -# endif /* 0 */ -# endif /* _MSC_VER */ -# endif /* Py_BUILD_CORE */ -#endif /* MS_COREDLL */ - -#if defined(MS_WIN64) -/* maintain "win32" sys.platform for backward compatibility of Python code, - the Win64 API should be close enough to the Win32 API to make this - preferable */ -# define PLATFORM "win32" -# define SIZEOF_VOID_P 8 -# define SIZEOF_TIME_T 8 -# define SIZEOF_OFF_T 4 -# define SIZEOF_FPOS_T 8 -# define SIZEOF_HKEY 8 -/* configure.in defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG, - sizeof(off_t) > sizeof(long), and sizeof(PY_LONG_LONG) >= sizeof(off_t). - On Win64 the second condition is not true, but if fpos_t replaces off_t - then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64 - should define this. */ -# define HAVE_LARGEFILE_SUPPORT -#elif defined(MS_WIN32) -# define PLATFORM "win32" -# define HAVE_LARGEFILE_SUPPORT -# define SIZEOF_VOID_P 4 -# define SIZEOF_TIME_T 4 -# define SIZEOF_OFF_T 4 -# define SIZEOF_FPOS_T 8 -# define SIZEOF_HKEY 4 -#endif - -#ifdef _DEBUG -# define Py_DEBUG -#endif - - -#ifdef MS_WIN32 - -#define SIZEOF_SHORT 2 -#define SIZEOF_INT 4 -#define SIZEOF_LONG 4 -#define SIZEOF_LONG_LONG 8 - -#endif - -/* Fairly standard from here! */ - -/* Define if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -/* #undef _ALL_SOURCE */ -#endif - -/* Define to empty if the keyword does not work. */ -/* #define const */ - -/* Define if you have dirent.h. */ -/* #define DIRENT 1 */ - -/* Define to the type of elements in the array set by `getgroups'. - Usually this is either `int' or `gid_t'. */ -/* #undef GETGROUPS_T */ - -/* Define to `int' if doesn't define. */ -/* #undef gid_t */ - -/* Define if your struct tm has tm_zone. */ -/* #undef HAVE_TM_ZONE */ - -/* Define if you don't have tm_zone but do have the external array - tzname. */ -#define HAVE_TZNAME - -/* Define if on MINIX. */ -/* #undef _MINIX */ - -/* Define to `int' if doesn't define. */ -/* #undef mode_t */ - -/* Define if you don't have dirent.h, but have ndir.h. */ -/* #undef NDIR */ - -/* Define to `long' if doesn't define. */ -/* #undef off_t */ - -/* Define to `int' if doesn't define. */ -/* #undef pid_t */ - -/* Define if the system does not provide POSIX.1 features except - with this defined. */ -/* #undef _POSIX_1_SOURCE */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* Define to `int' if doesn't define. */ -#if _MSC_VER + 0 >= 1300 -/* VC.NET typedefs socklen_t in ws2tcpip.h. */ -#else -#define socklen_t int -#endif - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you don't have dirent.h, but have sys/dir.h. */ -/* #undef SYSDIR */ - -/* Define if you don't have dirent.h, but have sys/ndir.h. */ -/* #undef SYSNDIR */ - -/* Define if you can safely include both and . */ -/* #undef TIME_WITH_SYS_TIME */ - -/* Define if your declares struct tm. */ -/* #define TM_IN_SYS_TIME 1 */ - -/* Define to `int' if doesn't define. */ -/* #undef uid_t */ - -/* Define if the closedir function returns void instead of int. */ -/* #undef VOID_CLOSEDIR */ - -/* Define if your contains bad prototypes for exec*() - (as it does on SGI IRIX 4.x) */ -/* #undef BAD_EXEC_PROTOTYPES */ - -/* Define if getpgrp() must be called as getpgrp(0) - and (consequently) setpgrp() as setpgrp(0, 0). */ -/* #undef GETPGRP_HAVE_ARGS */ - -/* Define this if your time.h defines altzone */ -/* #define HAVE_ALTZONE */ - -/* Define if you have the putenv function. */ -#ifndef MS_XBOX -#define HAVE_PUTENV -#endif - -/* Define if your compiler supports function prototypes */ -#define HAVE_PROTOTYPES - -/* Define if you can safely include both and - (which you can't on SCO ODT 3.0). */ -/* #undef SYS_SELECT_WITH_SYS_TIME */ - -/* Define if you want to use SGI (IRIX 4) dynamic linking. - This requires the "dl" library by Jack Jansen, - ftp://ftp.cwi.nl/pub/dynload/dl-1.6.tar.Z. - Don't bother on IRIX 5, it already has dynamic linking using SunOS - style shared libraries */ -/* #undef WITH_SGI_DL */ - -/* Define if you want to emulate SGI (IRIX 4) dynamic linking. - This is rumoured to work on VAX (Ultrix), Sun3 (SunOS 3.4), - Sequent Symmetry (Dynix), and Atari ST. - This requires the "dl-dld" library, - ftp://ftp.cwi.nl/pub/dynload/dl-dld-1.1.tar.Z, - as well as the "GNU dld" library, - ftp://ftp.cwi.nl/pub/dynload/dld-3.2.3.tar.Z. - Don't bother on SunOS 4 or 5, they already have dynamic linking using - shared libraries */ -/* #undef WITH_DL_DLD */ - -/* Define if you want documentation strings in extension modules */ -#define WITH_DOC_STRINGS 1 - -/* Define if you want to compile in rudimentary thread support */ -/* #undef WITH_THREAD */ - -/* Define if you want to use the GNU readline library */ -/* #define WITH_READLINE 1 */ - -/* Define if you want to have a Unicode type. */ -#define Py_USING_UNICODE - -/* Define as the integral type used for Unicode representation. */ -#define PY_UNICODE_TYPE unsigned short - -/* Define as the size of the unicode type. */ -#define Py_UNICODE_SIZE SIZEOF_SHORT - -/* Define if you have a useable wchar_t type defined in wchar.h; useable - means wchar_t must be 16-bit unsigned type. (see - Include/unicodeobject.h). */ -#if Py_UNICODE_SIZE == 2 -#define HAVE_USABLE_WCHAR_T - -/* Define to indicate that the Python Unicode representation can be passed - as-is to Win32 Wide API. */ -#ifndef MS_XBOX -#define Py_WIN_WIDE_FILENAMES -#endif -#endif - -/* Use Python's own small-block memory-allocator. */ -#define WITH_PYMALLOC 1 - -/* Enable \n, \r, \r\n line ends on import; also the 'U' mode flag for open. */ -#define WITH_UNIVERSAL_NEWLINES 1 - -/* Define if you have clock. */ -/* #define HAVE_CLOCK */ - -/* Define when any dynamic module loading is enabled */ -#define HAVE_DYNAMIC_LOADING - -/* Define if you have ftime. */ -#define HAVE_FTIME - -/* Define if you have getpeername. */ -#define HAVE_GETPEERNAME - -/* Define if you have getpgrp. */ -/* #undef HAVE_GETPGRP */ - -/* Define if you have getpid. */ -#define HAVE_GETPID - -/* Define if you have gettimeofday. */ -/* #undef HAVE_GETTIMEOFDAY */ - -/* Define if you have getwd. */ -/* #undef HAVE_GETWD */ - -/* Define if you have lstat. */ -/* #undef HAVE_LSTAT */ - -/* Define if you have the mktime function. */ -#define HAVE_MKTIME - -/* Define if you have nice. */ -/* #undef HAVE_NICE */ - -/* Define if you have readlink. */ -/* #undef HAVE_READLINK */ - -/* Define if you have select. */ -/* #undef HAVE_SELECT */ - -/* Define if you have setpgid. */ -/* #undef HAVE_SETPGID */ - -/* Define if you have setpgrp. */ -/* #undef HAVE_SETPGRP */ - -/* Define if you have setsid. */ -/* #undef HAVE_SETSID */ - -/* Define if you have setvbuf. */ -#define HAVE_SETVBUF - -/* Define if you have siginterrupt. */ -/* #undef HAVE_SIGINTERRUPT */ - -/* Define if you have symlink. */ -/* #undef HAVE_SYMLINK */ - -/* Define if you have tcgetpgrp. */ -/* #undef HAVE_TCGETPGRP */ - -/* Define if you have tcsetpgrp. */ -/* #undef HAVE_TCSETPGRP */ - -/* Define if you have times. */ -/* #undef HAVE_TIMES */ - -/* Define if you have uname. */ -/* #undef HAVE_UNAME */ - -/* Define if you have waitpid. */ -/* #undef HAVE_WAITPID */ - -/* Define to 1 if you have the `wcscoll' function. */ -#define HAVE_WCSCOLL 1 - -/* Define if you have the header file. */ -/* #undef HAVE_DLFCN_H */ - -/* Define if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDARG_H 1 - -/* Define if you have the prototypes. */ -#define HAVE_STDARG_PROTOTYPES - -/* Define if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_AUDIOIO_H */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_PARAM_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_SELECT_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_TIME_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_TIMES_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_UN_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_UTIME_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_UTSNAME_H 1 */ - -/* Define if you have the header file. */ -/* #undef HAVE_THREAD_H */ - -/* Define if you have the header file. */ -/* #define HAVE_UNISTD_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_UTIME_H 1 */ - -/* Define if the compiler provides a wchar.h header file. */ -#define HAVE_WCHAR_H 1 - -/* Define if you have the dl library (-ldl). */ -/* #undef HAVE_LIBDL */ - -/* Define if you have the mpc library (-lmpc). */ -/* #undef HAVE_LIBMPC */ - -/* Define if you have the nsl library (-lnsl). */ -#define HAVE_LIBNSL 1 - -/* Define if you have the seq library (-lseq). */ -/* #undef HAVE_LIBSEQ */ - -/* Define if you have the socket library (-lsocket). */ -#define HAVE_LIBSOCKET 1 - -/* Define if you have the sun library (-lsun). */ -/* #undef HAVE_LIBSUN */ - -/* Define if you have the termcap library (-ltermcap). */ -/* #undef HAVE_LIBTERMCAP */ - -/* Define if you have the termlib library (-ltermlib). */ -/* #undef HAVE_LIBTERMLIB */ - -/* Define if you have the thread library (-lthread). */ -/* #undef HAVE_LIBTHREAD */ -#endif /* !Py_CONFIG_H */ diff --git a/Scripts/Installer/LargeMOUL.nsi b/Scripts/Installer/LargeMOUL.nsi deleted file mode 100644 index e16fa902..00000000 --- a/Scripts/Installer/LargeMOUL.nsi +++ /dev/null @@ -1,149 +0,0 @@ -!include nsDialogs.nsh - -;-------------------------------- - -!macro BIMAGE IMAGE PARMS - Push $0 - GetTempFileName $0 - File /oname=$0 "${IMAGE}" - SetBrandingImage ${PARMS} $0 - Delete $0 - Pop $0 -!macroend - - -; The name of the installer -Name "Myst Online: Uru Live" - -; The file to write -OutFile "MOULInstaller.exe" - -XPStyle on - -; Add branding image to the installer (an image placeholder on the side). -; It is not enough to just add the placeholder, we must set the image too... -; We will later set the image in every pre-page function. -; We can also set just one persistent image in .onGUIInit -AddBrandingImage top 56 - -Function .onInit - ClearErrors - ReadRegStr $0 HKLM SOFTWARE\MOUL "Install_Dir" - IfErrors init.done - MessageBox MB_YESNO|MB_ICONQUESTION "Myst Online: Uru Live has already been installed on this system.$\nWould you like to proceed with this installation?" \ - IDYES init.done - Quit -init.done: -FunctionEnd - - -Function .onInstSuccess - - Exec "$INSTDIR\UruLauncher.exe" - -FunctionEnd - - -;LicenseText "Here is some text" -LicenseData "..\..\Docs\ReleaseNotes\TOS.txt" - -; The default installation directory -InstallDir "$PROGRAMFILES\Uru Live" -; Registry key to check for directory (so if you install again, it will -; overwrite the old one automatically) -InstallDirRegKey HKLM SOFTWARE\MOUL "Install_Dir" - -; Request application privileges for Windows Vista -RequestExecutionLevel admin - -; pages -Page custom nsDialogsWelcome -Page license licenseImage -Page directory dirImage -Page instfiles instImage - - - -Function nsDialogsWelcome - nsDialogs::Create 1018 - Pop $0 - - !insertmacro BIMAGE "..\..\Sources\Plasma\Apps\plClient\res\banner.bmp" /RESIZETOFIT - - ${NSD_CreateLabel} 0 0u 75% 100u "Welcome to Myst Online: Uru Live!$\r$\nCyan Worlds is proud to restore Myst Online: Uru Live back to the players!$\r$\n$\r$\nThis version is free for all to enjoy, explore, solve, and share with others.$\r$\n$\r$\nSign up at http://www.urulive.com $\r$\n$\r$\nEnjoy!" - Pop $0 - - nsDialogs::Show -FunctionEnd - -Function licenseImage - !insertmacro BIMAGE "..\..\Sources\Plasma\Apps\plClient\res\banner.bmp" /RESIZETOFIT -FunctionEnd - -Function dirImage - !insertmacro BIMAGE "..\..\Sources\Plasma\Apps\plClient\res\banner.bmp" /RESIZETOFIT -FunctionEnd - -Function instImage - !insertmacro BIMAGE "..\..\Sources\Plasma\Apps\plClient\res\banner.bmp" /RESIZETOFIT -FunctionEnd - - -; The stuff to install -Section "Myst Online: Uru Live (required)" - ; Set output path to the installation directory. - SetOutPath $INSTDIR - ; Put file there - File UruLauncher.exe - File /r avi - File /r sfx - File /r dat - - ; Write the installation path into the registry - WriteRegStr HKLM SOFTWARE\MOUL "Install_Dir" "$INSTDIR" - - ; Write the uninstall keys for Windows - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MOUL" "DisplayName" "Myst Online: Uru Live (remove only)" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MOUL" "UninstallString" '"$INSTDIR\uninstall.exe"' - WriteUninstaller "uninstall.exe" - - ; write the run as admin for UruLauncher.exe - WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\layers" "$INSTDIR\UruLauncher.exe" "RUNASADMIN" - - ; Create desktop shortcuts - CreateShortCut "$DESKTOP\Myst Online - Uru Live.lnk" "$INSTDIR\UruLauncher.exe" "" "$INSTDIR\UruLauncher.exe" 0 - - ; Create Start Menu items - CreateDirectory "$SMPROGRAMS\Uru Live" - CreateShortCut "$SMPROGRAMS\Uru Live\Myst Online - Uru Live.lnk" "$INSTDIR\UruLauncher.exe" "" "$INSTDIR\UruLauncher.exe" 0 - CreateShortCut "$SMPROGRAMS\Uru Live\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 -SectionEnd - -; uninstall stuff -UninstallText "This will remove all the Myst Online: Uru Live files from your computer.$\r$\nHowever, this will not remove your settings files in My Documents/Uru Live. Additionally, it will not remove your Myst Online: Uru Live account and your online progress will be preserved." - -; special uninstall section. -Section "Uninstall" - ; remove registry keys - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MOUL" - DeleteRegKey HKLM SOFTWARE\MOUL - - ; remove files - Delete "$INSTDIR\avi\*.*" - RMDir "$INSTDIR\avi" - Delete "$INSTDIR\dat\*.*" - RMDir "$INSTDIR\dat" - Delete "$INSTDIR\sfx\StreamingCache\*.*" - RMDir "$INSTDIR\sfx\StreamingCache" - Delete "$INSTDIR\sfx\*.*" - RMDir "$INSTDIR\sfx" - ; remove shortcuts, if any. - Delete "$DESKTOP\Myst Online - Uru Live.lnk" - Delete "$SMPROGRAMS\Uru Live\*.*" - RMDir "$SMPROGRAMS\Uru Live" - ; remove all the files at the root of the program - Delete "$INSTDIR\*.*" - - - RMDir "$INSTDIR" -SectionEnd diff --git a/Scripts/Installer/MOUL.nsi b/Scripts/Installer/MOUL.nsi deleted file mode 100644 index ae53c399..00000000 --- a/Scripts/Installer/MOUL.nsi +++ /dev/null @@ -1,147 +0,0 @@ -!include nsDialogs.nsh - -;-------------------------------- - -!macro BIMAGE IMAGE PARMS - Push $0 - GetTempFileName $0 - File /oname=$0 "${IMAGE}" - SetBrandingImage ${PARMS} $0 - Delete $0 - Pop $0 -!macroend - - -; The name of the installer -Name "Myst Online: Uru Live" - -; The file to write -OutFile "MOULInstaller.exe" - -XPStyle on - -; Add branding image to the installer (an image placeholder on the side). -; It is not enough to just add the placeholder, we must set the image too... -; We will later set the image in every pre-page function. -; We can also set just one persistent image in .onGUIInit -AddBrandingImage top 56 - -Function .onInit - ClearErrors - ReadRegStr $0 HKLM SOFTWARE\MOUL "Install_Dir" - IfErrors init.done - MessageBox MB_YESNO|MB_ICONQUESTION "Myst Online: Uru Live has already been installed on this system.$\nWould you like to proceed with this installation?" \ - IDYES init.done - Quit -init.done: -FunctionEnd - - -Function .onInstSuccess - - Exec "$INSTDIR\UruLauncher.exe" - -FunctionEnd - - -;LicenseText "Here is some text" -LicenseData "..\..\Docs\ReleaseNotes\TOS.txt" - -; The default installation directory -InstallDir "$PROGRAMFILES\Uru Live" -; Registry key to check for directory (so if you install again, it will -; overwrite the old one automatically) -InstallDirRegKey HKLM SOFTWARE\MOUL "Install_Dir" - -; Request application privileges for Windows Vista -RequestExecutionLevel admin - -; pages -Page custom nsDialogsWelcome -Page license licenseImage -Page directory dirImage -Page instfiles instImage - - - -Function nsDialogsWelcome - nsDialogs::Create 1018 - Pop $0 - - !insertmacro BIMAGE "..\..\Sources\Plasma\Apps\plClient\res\banner.bmp" /RESIZETOFIT - - ${NSD_CreateLabel} 0 0u 75% 100u "Welcome to Myst Online: Uru Live!$\r$\nCyan Worlds is proud to restore Myst Online: Uru Live back to the players!$\r$\n$\r$\nThis version is free for all to enjoy, explore, solve, and share with others.$\r$\n$\r$\nSign up at http://www.urulive.com $\r$\n$\r$\nEnjoy!" - Pop $0 - - nsDialogs::Show -FunctionEnd - -Function licenseImage - !insertmacro BIMAGE "..\..\Sources\Plasma\Apps\plClient\res\banner.bmp" /RESIZETOFIT -FunctionEnd - -Function dirImage - !insertmacro BIMAGE "..\..\Sources\Plasma\Apps\plClient\res\banner.bmp" /RESIZETOFIT -FunctionEnd - -Function instImage - !insertmacro BIMAGE "..\..\Sources\Plasma\Apps\plClient\res\banner.bmp" /RESIZETOFIT -FunctionEnd - - -; The stuff to install -Section "Myst Online: Uru Live (required)" - ; Set output path to the installation directory. - SetOutPath $INSTDIR - ; Put file there - File UruLauncher.exe - AddSize 680000 - - ; Write the installation path into the registry - WriteRegStr HKLM SOFTWARE\MOUL "Install_Dir" "$INSTDIR" - - ; Write the uninstall keys for Windows - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MOUL" "DisplayName" "Myst Online: Uru Live (remove only)" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MOUL" "UninstallString" '"$INSTDIR\uninstall.exe"' - WriteUninstaller "uninstall.exe" - - ; write the run as admin for UruLauncher.exe - WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\layers" "$INSTDIR\UruLauncher.exe" "RUNASADMIN" - - ; Create desktop shortcuts - CreateShortCut "$DESKTOP\Myst Online - Uru Live.lnk" "$INSTDIR\UruLauncher.exe" "" "$INSTDIR\UruLauncher.exe" 0 - - ; Create Start Menu items - CreateDirectory "$SMPROGRAMS\Uru Live" - CreateShortCut "$SMPROGRAMS\Uru Live\Myst Online - Uru Live.lnk" "$INSTDIR\UruLauncher.exe" "" "$INSTDIR\UruLauncher.exe" 0 - CreateShortCut "$SMPROGRAMS\Uru Live\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 -SectionEnd - -; uninstall stuff -UninstallText "This will remove all the Myst Online: Uru Live files from your computer.$\r$\nHowever, this will not remove your settings files in My Documents/Uru Live. Additionally, it will not remove your Myst Online: Uru Live account and your online progress will be preserved." - -; special uninstall section. -Section "Uninstall" - ; remove registry keys - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MOUL" - DeleteRegKey HKLM SOFTWARE\MOUL - - ; remove files - Delete "$INSTDIR\avi\*.*" - RMDir "$INSTDIR\avi" - Delete "$INSTDIR\dat\*.*" - RMDir "$INSTDIR\dat" - Delete "$INSTDIR\sfx\StreamingCache\*.*" - RMDir "$INSTDIR\sfx\StreamingCache" - Delete "$INSTDIR\sfx\*.*" - RMDir "$INSTDIR\sfx" - ; remove shortcuts, if any. - Delete "$DESKTOP\Myst Online - Uru Live.lnk" - Delete "$SMPROGRAMS\Uru Live\*.*" - RMDir "$SMPROGRAMS\Uru Live" - ; remove all the files at the root of the program - Delete "$INSTDIR\*.*" - - - RMDir "$INSTDIR" -SectionEnd diff --git a/Scripts/Installer/MOULInstaller.exe b/Scripts/Installer/MOULInstaller.exe deleted file mode 100644 index ae6da08bd5b9153cdc1034292cae2c28d726d0f8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 431262 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
    ht3uo|P}}k9EC?6@riv@Ike#pa<%h0h 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≪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
    0ERB)h%aKX1V zEl2RL-V^C02Q&sRR>!kI@I=5t`SYHXre2>tES*8#)vBlrV3vrddsO2lx^kq74KPWQ zFu7I2gc-+2HRNhbpRKQ+jW1KY*S*wvaR_5*7)doF!SVsP1(U_^qgH;$T9wjYO6Eg_ zjey%jTDjA#gS7YV|5`qiu@9%xs7U_ct>LNs&z50>d-f4@tJq(U0g|MtiTe8(w*WWw zZpi=)<`hP0=MlR`J<0I+;)IPkeZq++`%~Z;#UkLheQHbYn+=wFYg!=|#|f`E3tFtg z@YX!DVVZFoW+~E`^%?}M1Johe^bP6I$Q=6Nvowyzw^x~F6%+7Mx%e5q8u5uPeCM{6 z;J766dRX=VIzhqXubx5sdqc6YnCexB*zvx4RV6*^rbZ7MR^u`?0hcT1&5$VQL3_6AFiD`!4-8j1@p$;-13|y#p zq3F^+b>IqSPw|)u_-{1~Lsg-Z3~r9)?}a**P}wI+za)PItMrIC4@yIV^I$sjAWdZpQz`ld%0}j zR!t~`=!_G~asFcmKec@!0+Z5@QRvy{6tN7D{<0GEh+5*;3=1El=#oT~k6I&k1eq!HMY- zksgouE#D<0k~U-BYw`J};`2+<6X{L8>cRdJgpj6b6}h+oHg%_}NfLa&nNA5^(PxGIc+aT2BVdrb2un~fkf-fV{I%;9Wd^Tzdcf zX={3+0acJ^g}cp2&)bUaGN05sE`l)dUW+?CqktmFY~WkSfQgyZ-b~EDSsvGIU*Hav zdyGnkR#kFm=g1@rD&cJ)Lz?cXtJlyc4^e&b0fS^xCR)N-qnz(A&d6;=Sk-;xiS|Y; zYd8_N4@`AU$2J7g6no6H5fu|)0zZ{37{?anrfjv3Xx4#SwKlz$-th#ecQhKk5_oJD z+nw$3Gi}dpp$M6d?0+UVJf)(Je<2ir53!&q=7pwq+(I#11tN_Ymaj zIW*QxJFby*bm*MqCe=x`?9c>IP&?1lJV2sAE*j{$kZ{zN+9TAqnZxVo&6|TO8IqK8 z8#SD4pL1bT)#Y(bB-v}~BxBH4BbAA*iQphfEa(R1m4GvLK-#PR2#W;@bnGJ>qhxW3 zcD^m1{1V_-fT0 zkSfOTIT9xHdk!OeWdf@6zwpY3Ic}8xuk%b#LO!2&(|4bar>FT%i3AhZmc;A6_I@BM z;1VeDsax!pl7g5fouvUS$@Y`PPkyLq`SC1$?JLP2y_picAW_FyB@cGHly0_C?yu5v z1VOP!VZ|e9k&>t0VTKhi4BedDgP&I>^M}#_KDW6!k|s?tO6|yyC!Rc(V3?Sg|Fy#6 z+z%2LI1e#2BB4$gELxmz=nVzCD&ylba^88X^9?G0ftOQR^!BOQLfv{JW?IbqpM_1^ z0%JpWXWAEzVf%1cFZjZDn-Q{Qzn2U`x?`pZl?1F8>a~DvF2s(_w6VXVqjjpuY)CR% z(Cv#IY=hFaC|&&H5MiAow~g&(7NwC%(&C$tiY#=>ULLMABi!)_xZ}NvOZ*&+pSvi5 zw##DL2hqI=kXrf$*ML`Y+W;{XgqbKp4_w%4HW}u~a1@F8HZ2q;Fto=OI(ycqzN-W+ zi;*DN(v_p$ow@ayr=NcMp@T)OneMmzma;Ay z$qweW`#Fvg#m7Lhy`IHaFxb-7MP@_f@H+Q1&0B&1j2>)>*h3} zv-Z|0Wjpg1 z9|=q%JC(OB9!3(HJ>}{JN+wp#jlmOh!sabiz5NN@nM2cDWN!%<*<VTF zMFYr&@jZ%};b57VJ@+Ub(_prYDO9_i?*}h69Yr=>6nl{DYQP=WATWlwj}3Fw7S1h) ziC;_=ZKH~&WI9_HeGS3B%jl)|$Yu7#;viChZKZtz3Gc6l#dg<~FuCr;#-J>6EVN`yBWyldRhi5`koj48X6Urt>jM@}AuOC?rqvc%I1YDZw=7*`#I(p^I_f;R z_#)h<9uTZ@BffG#p_aof@#00>I=C9%)xmY44z6c<7+gPLT)vu`BS3wg5>S>zK=CC& z0|9A_#fyWBmEdCM3ILh7SKttljNpYO`JZ_mbl=@H)~ z+g}+^k2$w6BFOb!G~uPj1`EjsPJzUgK`3+OSv{VPIX<3F$%y{q4}8>3M+NZpZ5i#I zU_hcuk)y4M+X4U4Q&0XZ7TAOK^fi>{CbWEpmvagOJ)hw__nj-Bp=>F%Jcp@*ognku z`!uSMBL|o*2WY2sOP#;$HW-rgClWsQw)cZ`wuhXW@Qxvw@ z60dzuK!YS-2b(+8X4Rku`1vH@#DX(Yv)&hK$?_)uh`#X{rq&GiuX&Bainb$Q7sJJM zgyG^kWDrv^Ar!?sT)Ig&&l*OO=*Sva<(6&&&$#I@Iwp4h%V5~u*Wbep7!D(DID<;X z0Z#6Bb^@E%Tz5dVAV9c1NJ@72h+1>E1KY6?kxk%ca_B!0q(lP5?d87Fd@8LR0Y0PO z%6-@QKFIDK&L^K-#I)DhYzzH^fU#qLr(V8&5jBx!YED&r(Qv-YU9fN$Ol{hh3I?c# z5Y;M1tdRBxGvL4iv002eDpM$=rbUE4qXQ$nO|wkf!w5gc#+R#4QFItf?k=dGk{jZWSx@r~k0TIYn}m$|PB?xXM{h3Q;n?1)L-*_Zof^XW9_ zJ7Mc9QZIxMo|Z*7Bgq=cD8#aev=~FNFeo*O=AP!B9j6EEHU;&`a^y9zt0z6V-QIHX zG@Gkg=TvD8xz$MSDL2JC%Zsq;u*`?xK^Ae~->lDv=$cZxm5YV^US{mQc>G(D0{_U- z8hTqks>AKR1CXuT=~KSnO>spl4)@{&KyBhY1Gd^@gcCdQ=l~vhExG%fPn%xD6kn2i z+Ifai!b-bkQVG+W&h56)AkuB_+y9wfKBA$-b{tz>_P%c{8p-u&SV5g2ji^0_7$!!H zBjWTjo_KV>%uATU?x*^i86trMnY_mvuIMOJBZwxPc~VB6nt}V+w8G~1iG2h=^gdaK z%rKKfT5{9v*b)X4cXx1^h8s{+9x=f!tsN+_3fUj69_l=bPvlLLJz>i{_d3dMMxCaSekg8rD0oVF41Ea^E9+ zL_Lv~pz%~PF15q|9%a;HgiDBDeoSW4=-V+jWE$_n9q-673d3U|6E#5Q562iX)CzcM zpSXeF9}^$KY)-2Dn2+_Pr)sk_%gf){W}y97spr_P_0RGr?S_AUY^zKLO3vIR>A(p`0S2eR!N%tWcZocqkhv z<_1V#(xWwzLf^18#rm5?X(mpvyQbG0uF5WVD@)9}EX7v$Aql~qWj7WV+v?t?-}kay z!&XN}a0J|{!C|O$od?Fd>qv;v`{M7Y_GKIFw)=j~A+HciWd(^I>=ZM@Ly=MJwmJfJ zb!ge^5T`##;`Hmuny;NS3N^#U#=B&ohgSH52Ii?1ufw3DbO*&PsMt;MkxTa}C03Z6 zRx1nX!9f>Xf0kt&O5ca~4^7%ZdIF3oT(Pdq{r6vQWg%j%CNW&cT{3&btWUK351Ifd zQA|D40yi%NEAn7BrXHsS-?nY3==R@80r9pE=bpkJ>tn`l+0Pf$($^uDsMx_7opw`J z?TURA$9bB$8s-DlN{OASARFD8maH9gZJ+Mb~E(5_+o=d|3%1jlqVn zr$-(sKZGi&`7`sYBye!<0map}|AkJZTtTQ#$&XH`II`%Q>h$N$s`>daY~)JY%fh9b zAyX7%`7ndsenY4=qlm1zjx25~7Y}^OlMdLDbaI_LCg?**C7-#hGmys5YYJ(QTmU1y z<<`LMy(9cKr>5HAf7}=wTHRqD8a#>N?T4X-ntNz;h@&b7VSosu?0=aS`Mhp%*Qc7* zgRSmURM0g9Nr$>D+HlsW%&CIuUV=Gl^h{Shm_I&eYQo9F|rlT za={L5-Il&gyS52gLr+lz7TW_9p%wkY!2xH~B5i7rN!d9&5-E*+8r|w`3PdW7A z-$6A|Ad{Y(4;GsHc|O}h1*``Pt^F0SQvt`pLPv@Mp{DE`ZFP&-+iNR;fxW=Ff7vyf zd<}1B?StHL?mqLusryp(V6t=nJ?;G7VgD8#ZWt)-Mqe(L3ZM*lk#N4ThG9kZ_QKi& z!4tIIg&!ovi`c@cIu36%hUc0rn4>^ujd_ZkF|q4oZMuRcJo$SuC4oO;`FmE5+rQy8 z-SukA-#H9NjoBk#dgNoxc-2;WF`LpHDiBsHucVCf*jR)q`o@xQ}cUR~U3xK3m;5 zBPTc*nkZcd5|)YYab7aBpFD%e1&!)NpEq)!;ay{^qv+oLsZA~^vgRZ`*oV&Z7be}Z z)e3T4C3}SxF(10W>9_9DN-06Rt@bqod!j9k75f7zB<_)#LeThCkW-nP+3b*DT{+jFj+}LlGI(|`y$rV&2eJ#v%@9XH1d%2-%VDqZ6H zqlMru3&7&4l9zM{uSOPZ1O}4@2y3=Y}&Xqkb@fCxJhPNHTx1sTCbn&Pbu{kS zo;wBa+mrbRs!p^R=LAMWWgfgt_M4*hAL%q|Hfh&r4pA(fHMa1~`MxMy^3yD3t4a0$XrbB8p!r`FY& z5)gM-lbmpeJQHkNo?tk!lxB_e`>{RO#){^}=^RED0fs0V9z4a%q>r;2vhJ{L zS(TY4jm}U19Lc*q;;$Vf;u^;;X}LQtJgq)5krBEK&x{>(K1hLoQZnKvuWW>1z|^#L zu%Uy0D-l9vHBGSCzyZM#$wOhRx7Gdx9j=+)Q!agc9a{(Dlnz=t9Lu zQ?0DNfO@lKr|mg9$Jw^*vpx3+y-}?&Y&4`-9w8S|F{8tXva2P~>?L?dSv8JJ70AVX z0oV;7_}cAlj5oBr6-I$BhrDBCVPBz66joc=I-JcVSFxF|MO{rz5tsT1wId^0sjG5m zP7a)WkYB?s~NIFad+bX5|ylRd)--bsh7LS1Nq3IHS^nJP@qG9kdQG8q{Ody-c?`kGsmm25v1={rB=2@_Of%s+_J)I3bk zt<9LAN;3!Q%M$mzC(UrI&NJ}U(#>$ldL}R#<~k}OSyAjkY_qWL#}ArHM>3lK;Gg}n$t1=AWht!aL@eNyYu3O~} zUAv>hyLKe!J1;UP%pU{-y~rAm4|1Sl%sB!@n02@bA+f_KSZyee~6s)uS*C zB0nOr8SF9~r$8)gpk??iG0&s6J&f+CM$kFuzTl-O9xfh8l8O4i%UItLv)T&d4e}zA zvW3>FzO8BeisUrfG9E{jfq`!E@4rZXBgJ^sm3c|)+nl_V?zUB9 zG-@nP9+ClET2j_WoZB<6_shBI{99%M|Hkwq0mj4`#FGwnB~kx_{Mk!mbb^BSZCh44 zm0;@gZ zZ!(`FoWAOQZ_s!2GV&C(MBuRVV((+NIKsR>LXDZ)NII+YTg3A8nBGT#E`GT1mqb?E z7kxdq#o4yx+v;j=vBK){5u$xhuQK>8&L{ll@y}iFI)->2YPN`}jrK%A&S7 zZcwg|ha^l14!PTV*GVFM&2*&57poIkn0CilBi$gJmu4>(iM8+a<(L+>Bymj3+3&uz zT|9M$tS&pqEkNazTOX*yw$ee=X%EhjpusF~4nH$Fa`@jO+OkLTD&mSBjxKn)RuJMW z-iS$tdEvVnv9SlolbI8YMKy+tV%a5$Udh(Tzng0oe>=lb1uxXO>=ec2B)G+-gUrA% zlOtIZ*Aevd#>;lVnRQj(|Am{fL4p-#whe65ObhW)KC8|^Wv6DKvL(NCL5zWt{2(({ zIs=u%)6tVko0qIm*7k?s>G=Jj?fd82A1HoUByZse3Q0X+Yx_E;(Cr^hYw1c?lF?7x^HX>}B*pXU(4>tKa?^n83&J8k{Cu%Ixsmy=rOmje_d20I zdPlr6HK{%f77jM`jjTk(T{_t}#u;Fd4Or6k!|~U0f5FKQD`VUnkSA^YDHNEn4-~co z{p3UO5b43rQD{k>e^-AFZApnGnAUXxj%#Wfh!y#gQxMG9WmZakY^*=?6Z&)S{(keb zP*CUNI@gA5e&j$z_Qu`47bWmG9!XKsd+Ut2MecsqXsE+vnfMn*=R(m&Ruuwml`<4oY@qILKzAW4*Gxkx&J)!>`dt!-zLiYC zddHJZ>QFL^_}7&@dI~Oru<`J$6EE9Hy8GTDa4{_yK;sC>B0@83lSU9#9}0$WG< zM`TI^$mkh+WD>W5;Bi9RjSyiW9;wsS1JzZj#Z(%xy*ljV0bqy86{)v(y@$S;N_$#y zh=*$pWq+mIVZfq}Xc-1XXhe>RAkgCRy_#2fHwRox5&seKmMJDVjpxI^C61?C92qLd zvv^9sJ-h_-3Qd=7i}|LL`yg6_5RQc--C`zQ?%G#FqG2&*D6y5P+s}l2UY|}VLU#-z z+=zshMF7U1X*Yj{DVpGl*zUhiT0(rrbAQCG!?iRLYR1NHov*>Qne-?a0WBorYEb;w+MZ5VXcF6sLNANU{Kp0qRE#gKHo;5J7Ox#!%Lk&uJ z(bI3w98|A!pd=v`J=Kc&rmll@?;CtCqTNGRZCfnO9}IwsdaRb3mS(Y=XAu+M?Q}&J zWpWtp9yyEhH&^&h@7hd(|KE(m7a0F`lVTUEz-!f3!D?+4aMG&2tDv&-tF3}%|JPOU z$nJhtK@$ESNHv~rv1+g!&+>j(!Lt5W!Ht7^SHYygNvlBOkCzcBq9f1`29W#-IJd=h z{Br69^Y9dB%|ee$1`vl*dK|&AZP92o;08VAah%vzKhCUt@HmzFE~NX;ZrlC!65C1> zv5ns61#@t2Yzl}%(s11L5G&>|t(e1DF?5abwwec_3QU4!*Eb$NoTn>%_ zLful7bQICxyZL2DQSwqs+@Cpfo|%vc2pox0*4rMSoSCx@r87g;cehS{-`eMW>;LF| zOP}{G|M`8L-?G#8Ushmyu_=*W^nEUazW35kE73GfXO!@G4DoqH~yJLgp36V)`l@p|xzAiC z&_6m8)uhGIhw2p6I*y)kr}uvlcbatcBM<1Uzqj^@ar|RkePn}r?h5;>Pac^K8kf@( z@1KhDlu({|nucNZ6=ziW(_^ZK1fZv(^h|w;39U9vHrBh&u(}n$)9QIgM`MgHBI|$m-1YyD;Fqx9G6aW6 z2)-MC9%W44%nlUh)cGtdyc1ar5SfD}gn`)DX}~lPIwc*5W94lxvh(TM=K9iTxB`*= zjI>?Yxi4{V$n)?`DbB-S!rx+SCM%nt^XfV@mpP6B;dxcQ{G7PMRU(CqZYK_vcpTI%O9d51ox9v%}R z4~=OgA&ARbt+Lr|L_CdN<0zqZBffs~|Ehk6tY1YY3ab7Ys{UYXlyUWo`8}G&lf_eG z?ni(U-ycg-e=J|AKj+K-{N21y+HFy%eoLKtyB~V>|FiM0`|9JDM7&4LJ1af3=(mS{ zf85vKQsXB}kBfUDh2@SN7Xkjst2AI?+uev_k%ThYUM0r=Y5Zfq*DXo%Nb7%+N0M1= z>h^l&ZKXYJMP|7)d)g*jH0fBIp7m{q-%VkGD5wB3!E9tnU#kAd@yhyTfK8(E9t40NS%P|y z+`-iofBw+tM}tleL#IcF4lXT;=XD+4g>sr`PAu{9GWdDi{u`U0CT)Hm`z&F8V)e;d z2)l`HFZ!Jp#;%9d=@me^&|OyAViHE&|N9eP|BCO+^`coI(7|}A)esm?doN%nwmlUS ziMWop6*XbB-epDiZ~_&S|Zuc!%eBzLtlL17BgsVQqH%|mDGfM?2-H% zZ3R}3xaU=EE9;SHge-w3{N|#R^G3UAiMvTN=&Z0Tx-y1gs5A7T9U5RsQat{wzfw3Y zLaQ?Ijo-=uV3IKC=SO)yWxzl~LtyHfq{HXuEphOPRe$om3lE%pk0C@ii76=)SF~uZ zA(6!V+;aZ7b~tNN%S#&z{y0jAsewpbtCiJWJ@Bf;%nHisCAnVol{%die=BZ&X$EHMll#!C+T=#K z6*-q;pUfpmk_sB+?RuderZgV?{_kFnbtXxEs?lR@1eZwiLYX@HFrG(nLML}lroT8({GiWy!owo)Zk-9~jxEV?>&FC^h2Ne z!XJ9L=i>MNzULbn>}f|l(#4;*rtXQ?-+#U-l?BRI<7ZRD|Np!EFVlBB=(~=3yZfF` z?D9b3yvdP-YBb=p&lwB}CltF!EE}P1#Sv_uCV8x*O(vovWP}kiq9bI45HcQ<;^Dg> z0lp7D*AINZ%6Te&G|EkOl~q}C_&lSF9FXq?& zpEeJE7}=vew8tJgbQcZcjWUVLV0B=(IysXGWW=Lu9HD>~YrYjbp0Lu7*eU!-j=vRy zhu$P{f10U+_~-An!&F4vai~A~lI4{HA~n6+;q=%Sl5kutA-OE;V!3~sPMt1Y$8#s! zoi59wp)y%^E}h;)R|d<41Z{4(yP3`DHo1WTS#~)AbklC4PIfD9J6*!EvB(aC zy2Y9Ly&m2@__+05xraJS904EqM{X#V+|r&2rNg8GWXBs{X@Qea{dIQI6z#IoOR zW@~?G)3|5}QJQ;nL!Lb=`@uK6S3@{jbD6mw2X$#!{0+E@X`?4bGS+g0`L2j$!ob2` ztTj&KieR|T$&SUPJYmEZho`5Jn0LZW_QiuGdShC;BzBUONqCk;8d#v+ZrOEucQQfk zj!eooOi-iB7_hi>&?SPR7CAJ)%6lYNLzdeLtBHF_Ad8dzqnM>KK^~at)ixk}#_;1f z<3~5)$8p9FLLZ(n6pi%a2Wk2lKaOY+l6WNdF}sO5XI_Im(M8-$geLmhI8H-ObYv0J zKVVvHqGQN*oX(4r?OhIP5f%$ETsjV@RHoRk(S7Kgctf&l1glVoWDh|yNgl>D%n^H# zlKvIibBi2oT#-T^b8dOu?7g}?F80u_KV0FkXcnm`urgD>IHx|Tw@R_JJ;nJK&k*`3^7GlO8y}Jd=sPRn$B96|3swxXKk;1BcjQF&LQCWpUOk| zT&+n9mi}H_ZSp|tcupgQ5MbF^BA}IX$I7*>j6phKc2>k-o>Koln(dc5lEhB?jj>Y% zD|1%8!rq4+YDEX-bf0Xug`SajLfg1m+p15vud|cRVRe{d@48C< zu2zRt<0@NTL9ItCiOJ?+W{|{`7d5)s!F&l?>R`SEwro<9h9w$NIMkns+O4v)A+)=s13 zK6g$y+vjZGXa8k1VXT+P9w%x%|Btb~T;nc!bnYTqUeGH)+RA7bAiZVi&R$vJOkE=M zqvv|f%Z{_i#~SLeOKTWby&jjn03Yz>A9$TZOL&GvJY@1GkuZUKPTl@_x)4sb`ZWfP zwd)?PpG0-dpAByQa4eJpo#+{>o&Hw5<{&DB(UrQqVnveH+|HtQQuQAf6{0*tf_nuEI8Y3uv@MJ1kYHz$u z_{Sls?TQKTu4@33NAWaH#`bHp8Fm{r|86Zj9~|g%xBE+I`-u3rVxJFB{T4+o6La&K z&LI0oRBc~=!5UOR~>M&T63k4=o3`b~saGu&LFGb!jY6YPB-`ZgZcosj1_O-n8l~#TT7&0F2012kphZVSaTy~`=cCE^r3{1qHz$S7`1v-(J2njja(;#urB5P zUPHsXT1FL30T)X$TyR5z;$$i?So;Nor4JZ59@)wx77M3F48IUTaDG=sIk?YZy*vy z`936l!t~^B2P6@X>UY4=R;`2@)x(R*hkNj_VP3TB@jm%hh>t|DMUnOML0Yc{A;mVA7<2kQyi%@SX3PrB<5Na;vl49xU#y zZkkq|NRxpu#gO>wG=R@GbG;;hKqgBgV%w={6pe6R4D#fqR!?zy?|%i%qkBTY-IjK%f@5-ImT_^cYWV>1#IlFM_EIgmlo zIEpNN?O*r>ibw0}S?Ocfvm|;d{jvFnA zxY=cO7FmM>G|zoR>B~XP`jL3aT~;nuBcB8Er50JJ|FBxKl#ute<=$Uc&A~2^8z(o3 z#gpIlWkNi88V?~a+O%kMf)P;{N@zsrLP^4iwvJ7V55M)TeXfM-j-=}~r>7-c7wmT> z#h3Tj@2Awe_z+i-#z`z~Bny})S)T-1Ei!UvQiIx1kaJ9FE3k3hY0l!5zIBO- z{rj8q0h&UmA5QhYc#dgkC+S66hVB{+(gm0c}F zc!rUgxGk5DRt9vt<*U~RFI{!OO_&;=^*_}}{_rm%8WfP7Dbj7O~XNkdwMl|+Hz&>})i=+AJ>(;tpK;yK{>SoTRPB9!qUG`&l*-s!EmOiuePsI-X_}IXVb68hhYy zjKBvc{q%#fU+|BBIr?_jM~xeRzSx|?Yb+FZX$3W|PA@R4;|kQpW;Lt8)J72d!C4NR3e~=ON;5YQGWskzegNLfL3J8Pcd<-Ai*PfSxY)EkCjnQDL zoM`s*7Fajm#8cv>;BCOuXsIRmDxJJtM-o!CChAK7uWM4nD*=z> zeDuX8eg1T8!kv*PR#-74BZ4y4(+@=Rb$1Q%ueh?vAhz8vxh}F%W10Zgij*MYPnYYS zr4Vn$l7nHv@GN_fP%E1}3}Cggo^EJOzu!#|>M&{lse_!eO7`>H zS~pL8dG2nWtCxR>@8z;H+{>*wLod5gSH3GlkD7^R*onBO9!L+7T*ELlu#=yXvLd|I?v81!^KxH7ky3LrtJJ3Hw z;Q(>!4ix7fs8&Z+gTJ{x_awd$e<_Rjcaj6+<~OP*IEDrXp}OkO#G!_us189mF^s|> zhMLm2#RI_|loKqa|ALxP9V$RnJsb}7)Rln>ju)z44EDZSb%u6E`MO%Q-&pN@Coq&+ z9gDiLcDlN*U>_mJqOVnlqL)H15Nb(N_fM`RZwTdLh!GK|=FRHR^@iXkH6#CE^@Pko zmFABGPaVV}8LT2c;{5lu_AGV$9}3Q6ZQ6oXgy zD?_=Rjqon2-5D6d1G_Ysju*ihFk4HiC>+{mgU7EsI43v=$D0f(Zi*9gCCAH0Za17m zMl@7d8!R)fe!89buQlP3bz0t(T#0PXsfnxF|w!nw_mdOY79@qSynXRh4o1Ec?Dca6{_%2UWLC zU2@hCR|AjF5myDjzvzF|e&6?%_5YLh8D1nh0mw3|)jWXfnxLZ^03Sri+e{D>T#apu zp?ZR`^1`N2M_Nhm`-BKIMWM6C#rB3YLOf$&z>FeXFG0}J%76(z;=Srjm?lpIK#FLsA{(f$=JN0zM*sW+*!#@a(&^833CR~p z4f3|y0!Hp$NmEp={bKm%U6;^69)PkVxUL4Ad zrtOd}wJ=@<%YS1ymhe{?u1#t)JQs(7-c^Ngj|)q-oekP_dIdv`<9yF<05 zmhiSdKgjFm^#z8MbN)`+wY31+4$5%h7T3wU#LM`9LEPiZdBpDd>)#|)`xc?vhAcL) zC0y%{=7jSm6dB6>bMd_EO0~jKR_@QnZ{(Pr%Nwqv>udg=1AOCVzG3aMm-~0iI}`X0 z1tS8x16neS)qY5ZyV(=6)#l^>EjzU{@I zK8(IZbJo`4>%?DdjRd;(Dp26>%!xe&LRtT>VZFO z$}%-iSZWCXsj8CvA+tFm9b|~ZAm{UyDM5riK|Tz2+3Fx#O&odt&isQ2kp*8xI%Gop zGYVCz_t+hwDB@&Oq~NXr;I&Q2MDKjpR_DMC=c&Ljex1uggoM}uCg^%5kaGFBZPj5; zs?kkutk;m0l6jQri;Xs0-5)s-rX%dQ#QBEpKI~-%I&;`3(FeGjx+wUXz&PhATj+jH z5{gW>(j3s|DGLl0qfar4gN^-R*Kl$Aw00F3(=`XY&evI;VwO4S!j3ytOPNRfJEFf* zz#I`0DtaB@aC6@&qkJ3IrD_`Tk36SW6&$WsI!Gs8dOVjxd^06` zM>vlACC_4b8x(`?LsfAV$(5o$I1`nVtc3u8$@eyrV$J7Fn)sOR;z=mL#J|sLlCRdYOF+ zA$AL_+!8G;I)LO*H`hS$<1cybmCBFaha*QhWOInnMm&#=$(i4cLH!M0gpY5Qym>gE*5ofH3foibDaRyn?(7k z+e0pE8r+cMJC^gMHki6MSj{B$BhHu!Lx)h#%6F#yu8mdt$Ng=~)ls)F{ef&%Iro_}GFxi*a4< z%fCWu;1(Xr>QHFyBX8HAUvrv+EevQV%%n17o3#8l@|cuI$!m6C9>A6bhS}AKp6~T= z=wDg-qWPDD$2Bu3s(Q~e(0?&Lg1cpuB#ikwNeGe0{plELMq;Shc|3-iQG-mrg@n`> zLK%i4Wvq8vOaU+3Auc8K?D~VsZxb$zAzY~cLdS&>(0zSLson9;haBb-d2wgvU{^sF zvCE*)LLw&Bm!+ET(+YC!nOuA4EE1>>RflPPivupajPx7zq)z76Yb?}Qxl5Kft%H#c;ut- z-=b+K$CAx(63Os_y8FbJCuH`jp%AXDBq2`*M?96-wPv_x>u6DKP`u`<36+*bCRANH zCow;R_I{D}zD0lEE#H^I@x%zvN%HZ^6!Jv}N65~P5;uZu6U(U+%X*aMc4fIkS#DL9 zXDiEdl;v4~MtM04QVCj6{wu)lgD$6MRE2V^**P*SSstE7_`}EAnijQn3 z4qk8&8*wWneLi-kv_U1KWmZ?G^_*>y{PJBc>ro4IEEm9sdh+@HHKn1Co9|Wgib+#;oJm#<)x!<$$ zqvBaq!!KPz1R3Rrt@zNk;&d7$dfqI>{O4(f@NvOApHd-ZdFJBFPJ$GP__8vUJlgB0P{A70T{9ZGq|$jgohmZS$O~- z1Tz;19ijFgQpF97ZQ_u3Rhx{J{n(R16tVp#isCYw&Sg^6SOCF~%5s*gAjJ449TlYf z7!U}iZ=1`xD=bpBdlP|#$_78c@dvwm(19AJ#%j18HC(I7k5a#%slQ(xT6%VFU?7ZR z=F--2lUkaI3MN&n*N`}FJSw`TI)oA!;n}N$5RgD@Ko99E{Z(0Oo)p^MM1>&u`iC0K z!n-$Wohd>clhBK+xRtB86&j(|KkoERI#%@QDkOn_mzF#6@<$6{2_Z-ZzcZ2$BVHJn(gi94x<%?-|LVyN-x&usWk_l*ZzSwl1k^-RxqNx@a@0vov^+d=9Lyx<`}u zPnv58Os$@DwIOgrwOT}g##7{iIa;mW5MwbI@kq&zGhMZE1Iz!T!RKq6z(fWHOKErb zjjTH{X%b(5*|{&{T(bgPm8w? zB`fOa$gPc1Z+^19uRLAXkH6fvjCS6%5VinrJ`He%)oO7Xk3ECN9?Vl))wjiioM4x- z&36aNbGPr06iyTaB?hkPcbP2&lpa{hch;nD$yS=ofF>Nl!Jq&t8MQ!DO0Crd1w`ZtF>gpk&Snfo$c3yNQXs+ftP( zdxQp$TQlVO#p=@zE004U061R4gR_Ri&+;K7I&uf;At8C|4xI&`*b^Kk*HdQ>y~Xsp zfywKPfU=Z5|!B&1{;3M_TRSwHwY5$s`CNgF^; zZaN_(cdDf{y8eASC*Z%E1fv%W;7OIo>lXH%c}mKEkY;yH12?b{sre|2;6`w#Ct3jW zC3Im9q@QT91b!Tw&8*(p49w=49Hh@=phQEZcG=&A!T4CnVb}K;9*eraOu(PiP#&(M zYn+vC;SFa@FZSsGogIwt2-%or^^m&Ra_$)iOcSc#CRTU zv-=Cm$QO9&J8-=6QdTfAk>yI6Rh7N=`YVr6Xb1q3O-kwvXL-N|tbVc&C80!xJ?;^) zHri9Tzn+i@h2#ChWqnedu*?cUOXdlgC^@liuV^}@-Cs-h%ka2|0Ou8ta;@X4QZQiA z%Xb58ef7OZ0hl~f-?R-ZueY-O|FD|t{iFZJHg}Ims+XFcllX=NF4C&ZCQlV2P$tN*`%mZJyw4U3@-B+lOZ77YozF=7EYyHJRG9=lKWJR&u=x z{8eqv-CkvCt&EvqYx?{F3I+YfdOH1p7O*yuEzfThtt|~UfRHh%@F#pvf6j)qUQPM` zDjkx!JeeH~n^7h<#Ok>PgD=cu+ree1vvQBQ1d|t0!G=2zzP2qpJc##on64_|OAfV?wXSe;u|ZR}{-uLuPL-+n zah|T4Ogi0Erb&ViZSeZDoCqr#g-UxY>Cz~MV5s2w;P4vKQj@&F@DIssm?&E|Sgwwz=n3=#OnI7@lbujLtxfD#1G8avr(GkxY_!C!qu;}(u;X2P zAeW~>EHFwZuhu^EMP?*!k*)H}efV2x452m?xs6ZURwebf^Eyx77H==qK=87cH?%jL zQTJ=_s4dMM(4@2=l`FF~Pgl)}TMyP)x%{Ty5^?!6o*bFV-gDdQuuFr!OPBf;{(>XX ztbdtoEL$u4i^l`{%WkiBNP@|}1mqPP4)c~sR=KD%qWy<~ZJ=Or~q z@MEJTFv=g&qI&UvXR%vZDF16^s`v&gkC>C%>p2^1?_C6*U)PKd*UKCgt?6`O6dN)) zS+kjQMX>@lDnC|@MU^ge zw!-9v56N-mhsDZ|pz>+4OBh*n84K&0Dg(o7t^z;MpjTwV!p(0=hKIHva{ws0$3kkB zBX-Z~3E z=cn^J-+GjlDT;io-F)rQWb={U`hF%~$Zwh;U(xD2s=Zo^$8BbQLjSb8KYlcY{SU@x z)jf8QXqNE3hw#r#__zB#?We|FfcZF14AQOtpfuMYty$q$=#F@k)Jk(w;kQoy?Bp-= zK$PK@C~qLAAa0xsq5Vj#{RiID+OeY@+!jAfY=`XQ5ve}Zv@aC7cFB)zFRsX(L*@{5 zZ+)joQ}Jvv@@E=9Hp2Ob@_7>-(T@(Fs7Nz=@|no z1MTwPpuyH5Lv8kc|HA~)>u9{I>*kdNu%czy^aUhpI03a%hKkYG=E z#(X6C9rFoFwq?+8#H-~@Q#Hk7EFKl{$8Jcsi*%WDAN?ZXH%zRGkO-6_2*$I;oxfb$ z$G-;Z-RE5Pnhd}Dkc;zdPm9Dj3i+IF-p4mBsr)U-be?*2@9SE0;D`v&&r!s^x5GGw z)NRNgE*`ALfl4UVF`4z8WR{&I>oXux@*yj|5sB~k0`_3Tkg9ZeTd{PJUJftRK&DSb zub?F8KJh6Zf~=b2rb_0)micUZKah^KL<7N<%#v!x5*nvdRqdei_ zyyUy__ORC6ZeRiElemIYSy@fgy48?MzO9{p)a{Fh(P0QaCJh(YXBOTVj8x7Eo3F2m zdyn%GkN!KEch84bhe-GkwRk#qnEUt;2kqE=GKx}`&#hLLPY*4hN(E-*0d;TD3rv*- z3Q-_WEzZ{UKk~7zw;Nrh?y2k?^0TB3K+oTokl%H{iGJZL`K_%f^g&Z=hWpnb-zqYS zA@6}rX04(}t*%1`QM&*KYF9f{vYT{v%(DuvJ1xi%f{gkopl_Y8gFw*czs zV}pggFr8s2f(&Yadn^4 zRlC9Caz==C?g=|AbHdhwD#dGsLm+F@I3}seT4?pn+7Tt&vo^onz!k1F#JkO%; z%H6@e*h>pQxaon{VtR+H1iqjLxhK8l;@d2@w9cv0sx4Pr%E@|bkNCWYly~H=PLf*O z%WX&b^D8MO=Lk>OaYLC`T*z-{#@@6ovv@kf0WO4MAH zK=icy-F?ps>?l}bmM((u9jzy?(#$pktxcsQTPev=N=7Rsg@5M7=AK%ul;kNTa~1b| z{F>fxfJ-eOb&B2Q6>zcIOU+uPU}QSe^BjLQG2+SrdjGPB#47BewUjg~SwR`@)wIk|+Nl+5=)b zccHEmsB5t$_o%5`nb)q&JJjZSs|gTRC}F~3B`DzX`l_3x2T1Plme@$F=1}A@ayHxQ zCZ)0BVCC7_cz#a@J+H@eeA`~^7R&GxaRzKJw%h7PpyY{`4qM$I{CJi2ZL+UI`PnEm zBlvIn`PVrYCt;q2- zH^~pZ4jg$RY(qf&4q8%>0lva2CKJRWbl{7o1ty20Uj`?tns>m9?wrS#I;4Aduur%r7AyA`$)YeDWJV#D0C~pK@aYZ*epiTQ@!T zUZc(!ufi_WdnFCHt=J(gktpMLasu(zbjKOUGh#Q(x7FiXyigyFHfEingEilPJVE>s z_aH||@-LR<>w3$>QhL)=v?L$gQ_oC$3t#1*5VvdB`um%ViS;2C5cM*4dy}z`eK7G$ z|4!gX-#KzFeu?ts(yT2fU*qX*v>9ikn>UK?2BUOU=Na0otXi99(B09Hxz8$7#)|Xl zmBrbxDX`U8+2&KM%9o0Xy<%cB9_|(6n>n~jUwaF6WhvpxLoS+C%;)%U(FDw{qs-0I z>PQ_g`<79C_p40Wx8X0|Kxi+r*~ zNqXpzfS8Eb;lvD(YIROF4tO@C;dUK@0rN{^JI9bM#F0Ipg7G$kK0Uyo*?@Ni6vT1NbOg9D{*VI zN4a^tGUZCqN*O8;Iz2oy3oP4|YsBSfp|wH3EUVKEXgLbsoPB;yf;=Y+_ZkbE ziVZTzg<5+44DBvv+4T}2bEF1`{Yy2JS7jOnh3c&$ZW zStI>)FC0G1sz&kkJbir~dWANi9#Ue6Ki-uxe))eG?`NS@q<4=k^PK!@AiJid+pWwc#pi?JKp9yQ;rw(A#+rJ@fF%KUdIAcmtR?@8`}o5 z!_&xfS^V)89x`pf8L)ZZOY(&)d8O>pBPsmh^8OSeJp*V3tRSG@i zZ(%iX#d3?*2*Q*_%!?kQIcph@Ixokc{U^!3T@Wzpzl_QAS&(8rYpzD&LgfjN%(~Xz>m7%|g7N!{~`Q>K8w?_;fSOYcg_k40{{jXGUX{JN9e3_KTyROs1?_|0z-n#mCHec(cn;*?)cq^ziLe_;rMgkQ3`Dzghq9^ySAokJB|Ty9gfekz zyCiO{Nk+$ZnoH<^CnRE{-H<{)Mt$zZ$4@^zr~Hw-rNjIsS+ueV=9jQRyVWN)s<-~Uq=T&hC3gx0JG|uaYIPs!%lq)2sqz7w=sGNZv(Jj2Z zk2~+D9xt}K!w>RW&cx!R$O&}*u7k4+`CF>55!?|L;kM`)i_UQJB$!S^ARh$1^;Ngs zpTPqbt+))2E5=&PZ717dTU{4P?+)5leWV*f!G<$@KO6GEKbMO01@!nUv^ws?&Cnas z+obp%QI|SW+0TA-P8<`igJH8AQ$RNldrvNkgt)ITi z`L$8DEyZcgAKFd(=(R_4;$M4Gd+itTuZ8)wp|&kv#9_0W-k{eW9Nqg`@F(zK_#qYN zD{JVCF*vtj7gBY0Swd%qE<|!!;7267f+raXRo2jtMR~P5)rhT@jd+m;{eHT+a00Dj z1o-zk5N9rpO)tR|OKzB=NT|yqUHju4fRt$|3Z8rY{owt6*I(zHlgav)e)os_;`WDc z6Jo#ikCgkv`7(R~*>RNVehfKhlJcLj2J{GXqS>){gOYnqN2_hzDhDM>9JD$yuXo&WW2O;9wrX}Vk5&~N)Rs;^SYOSx zzJ?@q>LYZRuSqKtA5adXN5b-GG+EsaD{h4^7Y?mSugMS(Nsrd9@#{#W08!wGm~3Pq z$wLv2x9j{cN6`_NKOe`7j)K}}xc0!B{NU20_*uQumtoYqRdnJa32tmco}fD-r}?bL zRi0iF)mZ!v{8FAEApNfZ6wFXAiZQcd{gQat{N;QeyZF^zMnf($#*;QeO|`_Ou2yhS z1f4FR#lIJQODsVtXN$(qrq_?4t(4?LfYKqjUQKvn8SkOE3`4xrHC}mwUR0i-GF|W0 zWB}MX=Sg7e0DbF^{Q&f(*n_G$DL^Xqo#0=~z0VtM_uofh-E!)ly{m`~67q-JqyjJi*~$j5bvOuX5mVUq^mUi=fQP*m(cra8L)f2jK(xTwmse;l7-1{h#qMnxsV zq@=RY!q5#GC{PD6g$B_E< zz&~4}ZfR;!>()Ju8KnU#GT--g-Dd_ct><|@pYQMc`sr&p=iKK$_y0fFef@b~q`QW+ zSl*#MV?s|9sePg6x$){KL=v%Q$TU(0u3v#t+=$=9_&tx`FCS$51^3DEbSjW}KJsKR z&oJbv2D-v05kE_@tCQ&lM=cw8){){2trs7EV>M7yL)|{<8{O{zyE=*pIW6=I$dL@Se}DO6(S zIs`cod3+3AB??d*SD_L0RUbXN|e@x4&{aqI<=_^Q4@5EoHt97@r!y=y_6;X$!DEQ)N_T zgk+QIMAdLs=ZX;VRivL~m03Q5EHu2=;P@L78h?>u6%-!)pUCkVT4BWx@KJ*uHos-A zYc?iJ*69`N#ht_5y83Sn}Sq-^6cQY+)GP^#rrUgP_jBD zm>L}1A?CwLouFUuvJy~ial9IvKy$_szcGnxZT37|%BKq&?qc|r)KRqBirbU{od+$I zN`0~CVPXl0{g7(N&0227o%hrDD;8T34(;)Zq$*<3RWXas$ooSAV!eOACgPZXsS%0x z!buYP7f^bG%7}PD+NnbMamAI=Fj>`fGQ$B;2KZQ8s_!Ab(>?%$y=_Y8VN|jY*1ALgrJJ*KS2m+tL3{ z=o5*T?hGnbN4xuOa)rD5Zd0N-j`AV7`!uQXPow@h*lcL00p+w_bbc=);MRqS=$BiTvbhLm#hn`)d3q>0;QBZL zUEk=sUZf4mXC>4_AY18jRwSGNJ*gMTN95sZIu=lz7ruUr1ubO@)xGn5;-~#2s;2Lq zLz?DsWQ+lAfOP5P4SH+9uf3RKZ@!d1P-V8e(bSqF&QMbQ_Vt*5 zotKz@^CHb^@%FFi_*rpS3-1W3Zfrrg6AsfW!z%K6r|T*W6-(&? zQiRv&TYpB2Q!+ka;M6wgVI$GtlzbhJ81R=~fQw#F>LvNlPrx*NgAJC%Fsw2DZ z0L=TYIV@vr`pG4vK_n02w@Ux_BoA_tJcwW1`x8wbL{E?hE%?b`c@Wx1%)5VJ*MiFm zvHK3N=vJ$-JP>v(%d&`EtbtPBk7$j1)Wx)3p*RBF8jUh9+sv~JrerIGEyMf%TT-cl+jzyzU>niH>yEkJL{?P^N=KtaX;(M9_o zh(1e{RPUL4>2#5)Nh_T07VC_{iVYx;og!+RCY^xL@%X*p)JH02xK`!njoY~YNT92b z3eV#hJhBsib+2~knM{4m&yeUs3+Rc)h2P*mk^GIYe5QjduS}9D%)K`>K4423WXfCq z5M;`C$!NDDnrGz%b>##sWu}FiX>-G`UT3_5gtXn&=k(BpMy(;QlN_oZ63n3f_fY+_ zD-DD%;Sm3N7-PO5yHF%P$on?obs)w!jilxLG>yDGe|_jiP&#b3Xq zK3MlV-@$*KIP#MC00ks)+i-#p*#Dq)qwF2ptZCr|ou{0Hp}tm!n=9eh8h!j`ob-H} zZ*G`t)r#L5QGJ3mdM0`bCfEP+b?GX(D}=s$rzLpsz6|~{;a!ZpEI&2jKcst?%|rzw zLi1F7^nRNrZNxSBW#V$qLT5sVfnc~;dhLd43y2M??H6y@R7 zd}?0k8UfQ-@majaz+A1Jbeb`*39pUX>9~B^tgT0HZwd{;BfK6#!-;1Sc$gno5Q`v~ z$VK%~69=Av6EATBrpZbif>(k>B~Q@bAkoTjkqdHLE5b}Jf|-h7q9T-mS1LL&xYrr)a4kNe5_hbYXeqRi@H#gidN0c!bur)iTPo%GB`N>fnaxS(DjcHBs;* zV*Jc^#S_`8A4Ug+0K@gLsi-s4NvFYzq}m+b>t~C;hiIB4dUCT7QHzBLDjULLh*`TeB{Z|-G?8XX6Z(v3X%AIV?Ce5=Wi;0>vX1hL|u6x zpq)qd1<&962A;on_VW3A=l}Hlz4O0!{%*VI{N1LVzp0Fy=s}!bLg(*&BXIuy=NO%s z^E*0lzazH&maYfI6WMfqPaONLJb)kN1NetHfb(J8?0tkN4V7^4aV&Qj=}`U!9naG| zb5GNI`#uLw-QC{D=xAKwK=T#Ww65l}_*|UD{nSn(Zpgs1_;;<3kjY?~&c)F?5eEmk zREqP9={P$n*hV;CZ0uUW36@;n_T30(M(iIBMOV&{GGJk43$x_H2O zdSCE-yDxN}KF8;29)F=(Eru>0aGu^8I#17!;`8*h-{U;J^%Cc4&amZ&{paa#=4U!5 z&(nhzkTT!KAIkGI@eBUdH-KMonf;j0*En9kq}O(3M@5Z1UbnVh_IQ1)|9Cyp`zW(r zhQPv}M1RF5Pa(8^VDw-n#h*eb48{l5YI5Sm$1!wdrUgz!mJcMT`;Y0|;`L^@%)SZLQ$Huo4(PD-_SRD(Q=ZX?i#{Rc?o>^lH^@G69$hE-y7k& zi}d?SeYffdz`su;+Zzhx&9Je_QS^lL-N=!zc z)fFMr;*29@#{VwUQhu*AMB|6jf4TI(nSSDTr@!(N=@$)1|At`tgnY+oUnWJNC3syZ zK{>uRUH*KvkIz>(c+GVtQ{PI_q(lsIVfd8SoiL{55HN1ZT z6T9kr;#b(jI1I;-dlr!AJb)T7EJ2aDXCY4JqiIx1Gk-%fzyYpRBW8odb|esFDxvul zi%k;gQDdb1=a&~VQoxJS?AidqrmDZNbnRS))&BD z0LLqC8)B$IgPM2M+$2xI4dTbYB;CIoyv8TFMKJ-2f2k2(*1@VQ(%&hqS91sHD_`IE zZR=H#UxbAFp5%zKJ+Gcmos>Y378~!S#wpY6Ri9>kadW{pAFb1_8^o*k& zPEk$J3?PqBBASQP+zOc=AIs188#mE)11&2+?t;gy0xKhJ+1gyuXo4sv=HzTFEA{>U zZcSeX?Y;jJ>uZ9StXW{7@)7AI&+RBu_c+-k(Cv%#z-@B=3COOFdFK-LHq33j`Jbyh zprh;-c#E(gY5=1Tah~<1y<+s;+N`N-d&*A8F=aBu}DJ^oO)%8c1ne5VYl+6 z?3HIqaAYezVX2$U5JV^7H?#Ie#uGT^HO2)yLQM}jDeCVBIsEXz8N_=FFtmXW$$qea zb*gNZBip|r&r(b1o(;LlDECxAZVya3VW9h?U=O1O`@1*)B>EPVB{!w-4l<*idrX}* z0*9&*mq;UcsDiWX{u32C4BiIp9Wssc7|!CQ`H*$zUJLT;Q9pr|a4mpO2UW_@z_HZs z@1uzmkAdUcMPL1F{(z?S{hfedOFNahsscz1R{DeOT-Q*tP>)q-OvHc#ri!(nMAhUQBQGi6 z5dR6uHxBiYeB;y_mT!#v8zkRI4azq-M)Tau$T#@yll|WV@_*?p8T!~P?^A(R5+`2|+56~wLh{@p3E#A*B$OT#nR;3)-ee$geD1lc5WET^ zcs<2)h2!-Q%}Zo&Kh1lsI=!SwT{yRLBAm+EO=9|K364=VQI^6}Fk${6$~X6{wgDPj zrmBv@dN0F`2pzx=08x>)^HjG zJZ67hG=TqbtS`uaINHPWcqhCIbLd6$SZ(rx(KOV1ryjLt@4PziooC^9=1yafzv!+q zn_Wg=X*83h5#Y&iSSg<93JMl4;qP%WkC$gZ#dz8FT4=nqqptfl9u8=Ows7+7foDuj zt~tQIteU=G-T(dL{QU{}eIzD7zAL%3{ZeYeCFj5H)6o1s7U22+AkY8oPcNST4{Gz@ zSg}f%r^BU`@fg- zpF1zm_%kg8TR+vzxE!xC z#2Ds(RVTbY_Di&eRHl&s1z4Q6M$#xED;Y96hh^sU2{;K<{56=4=dOu3E&!P?r0?+x zw)^Rm5vkDKVus{>{;TBN^V+Yq1tRI9mEqgV+c==Slf{NtE?eI5DDTEoRNm@A<*nEe zDk+s5Y}>+MNoR9OQGDZU;%dP@<`pU_;|E--q`~uY;QwU(8h!q9>({XJgVrx&!)4bm zu)MH@h1ZX!Ipi6AnE%qW6d!_hPy}(z%6W1z<3agZ0T#2a@ScFSjM0tlG?uZ6av7sY zp3yXx#XE?aUTP|HU7aynAb{4dE6?!yW%OeGqA;vqAhE>!LH@_!@pyp#M9-J~Yf}g> zj&L|UkFFxQM_U+*RfN3w&NDeL_&f-yZlHdmL#6@Cn`gfqyza^IbN?mBPel)~0xFVx z+Hn8=-!H@B8CE$A44xl=XVn_lRwnnOm5d6UJQuYx}DL2%pkI46pIUtYQ#gV%%0l;?^8 z<(VjQE?=JED9;owj~G;*P)Q0Vh$-Juk^%O5WZTUwT{!??V{4y<^_0c|hS8505YY=> zM22@gNnJd*sSl6`SM>o?ICH=sG*NFj0B$74lTM-2NO%>q#oE6y_6N3-y45HZhRa_N z;(d}HW>-AnW6hvwUObZ*mdSB=bS4|zy{H$nr(Bw!aryT9<$(5^AoMR@w*9U``-Oc* z?Pv7a2aC^RI={8qHk$O@D6!s4^Mf}|l8tt`{e0ti`TlbJVu*E++WAGO5 zyXWL3>>n;Oe#C(FDMvK@<+9_494YMhl*Z3i-@y3?tutB@OkU?iPc*F$IJQG#c_&#C zh34iIv-q#iFE_|G-ivztFZCJL=Uqmh;SY}oh4@u@-_U0mb*As~`V6sW2JM1<4_&+q zhW0;W{b(9vp3$lNcfFqen)vS|4jIpXXYpSe#G=VZyQ5K*6w2L^`*YuP-W^>uTxoZt z8{QrN-N(BlFHoa-hk9wcwmXi^7`+GqKq8p|dF)BvA5YX_f27ch_D7jZ`SgDI;-IXg zJhM;A7bzE(FVZ(M8$UvY3!N_!%e8RfGgRAtWs~F5lZ1Q3z_aOwREkY$#j2xQM!As55iE%bQy-~ zAxf8YD+B7*%DFiF{CwS?{0=P&o#XvqJFwwTumkG(XY9de8XUAa1>RB6<0d zJj8f2Q|2)yl!y3JCc)|t%13#o8XOPhN&m0=i=rPK1;{^yLjyaXK&7=J35_XwfY&Xq zx?M*&x#Wpjm~Urmo6#al29m4kO0(FBdX~VCAtS^X-AhjBsQm-LMT2M9s(8YVg$LC~ zF$zn-;dAHr21FENKXi!w$fDU@bwcNgMnWwpd5PaF{*)C;zL`6TSWG=YDlU%=pjq5Y zdH|P-lM2D)R_eX>7zcsxG6opCTiQy1L8}3pZ13IOT#<>o1cqBTaD$Ji82=dq|C;4< z1jd#zu%G`9&m`#VN|QKEJBmwi#zym8(exxBZ@G)f?t zIQdep?k(frb1{Bw@2FocABncVLyd!SX&7w3@oD$6&k;1f;`^V&H~VM^QMc<}glMAW zErBm>ttHDX12gJg1|e&IZQ&HSELtV2v;PG4 z`#-9%q5@k@_#^aa(vpfqdXA^(FR2r`2MNw6qsppW?cw~9yZCt@;Y(1Fs;n*(%Gq@r zHJ|XKJDb_7t1HseCb zn(7qyp!d~j$%!S-N~5#lSAWf+1_kurEGP@*qT)Kji-tF3SlGDCa2aou9xIeF(sh7( z*eS9mlJ#hbE3!yDjyy{!yD+u2Y#~clp$Q>rW56H=6zCjvIHY^hwSfAYLgE=fhbbN6 z-Kng=Ue^V{i&2666RUtr*U>^g9q1EuTHF+>FS%;ojoE|gQtW;w(3NX;yCyls-;)Ua zzDI1Hg}zu}72&gFYK>Llh~*y&|5wsY*m~67U7mIXu?a==Xm1$*!7}O0c3HE+B({H9)7#A z1o~s^Bd2?+4rfLyyIUf4oV}S>J-Af6ji?ez`3*Cd!dg*JrFaD4BD{dqj86~@vN#$+ z<064^U;Woo3D7T?>1LX4u34HluE9%c6(vr?Y@tj$nHwDCtTX=u`Tv+W-x}?Ex~i#Ct(=~Uvc(c*xEWAv>_?+ z{dK&?$p}4oO(-{Z214(}93bAaEtZaWKo^^qY;@-t0hOGMMa2XLPg`QMY)OoblY(BS~}c%DSpd3N{Q4>G=dVJ0s6n6>iHjtqG^MkhmwfGK4JS3EUPB> zDx*&MvdnkW92q&!SSH6|0uM0v52;++e=w+5caD+J8d;==VL`KLPO{Y# z#?G*ssf(s1TOE~s6&sMi;sDQf?O2I7N$Nb4y3~wbaoq$;DA_g6J86Y#e%UiCnV>b@ zt6xTahgJ~!v^wo&lOSW4z?_#&{^rGxF)Y1wPJm`mp41b|(eh!;^io=AXLB4^ajjTEG|r|fs{fVYw5 z1+SCT13pP$e_(hU?886ZNK|Y|i82yaE5Q_=3**fpCgs_8g-w~dVbemoTtpbHn{53^S!QEEe-N$#^ zaJMgt?iz7dgs@FJanmfCiMR0}t*5J#jk--wfoOAui;)O8`myGBBFTNC^GM^7Imrnh zu1>aocyF>510#V(1Nkccz*l$Rfvb)rCadP;nlDk<>Y65^4cz;6h!*cYp!1K{-pcU9 zGW>m=Kb~&7cTlLZ^~i$c1p49h^1@{D=xS;foA}0zN%l1ER5_H=x@_jJE70$*t8(3a z6PA7HK09n#viofE$}wUYqP1q5V&%kJOdpxQz87&}`B~Onb9NhEEE`dCb`P#A$6@z8Rh(0u5R~u?{2#ignWhx;jms;fv^Ig}LUF zz*>ATc@7@Qb*Q=KZC!ORpsB-T*s*C|6!C?eY8D-60`HaAr03ra@9KG(hPIjvhn;pc zxRgoAiqVsDVO9)T`iFaz6aMSnuhWJQx8f`K6nKe12>o&H2V8M0KBi|u2qI55Vl0B} zd>TFqOR(^nDifJlEfJqhX7FVqxA_PlCZ;h3Ae?v8iz-v)mEvW35g2|3<=V89=2QYi zwVR$rdBwf+v{)wL<!KP#HZBBtwT2-Y^{Eete_$c&ZL%C?}K%7+RoP#2@g-pAsU*kAWDE z{a%n5SF4WE*^?swgd%$gdl*wuZS^jx6_Y?K4?cEWxMjexgDh4{oMIzpYY8zZ`cE2L zX%xJXdWn<9b(c74P+F@laMN|7nw|*%h>MOK4)O4{mpg1Y#N8JkHYQ9Sc-VOID=Eb< zB1t_TH!PwSj5~SU09jcXI&CaT4xKi#QQ3*K9L2i}jL@$E#R8(d1ZNGnmgLhxg0n*Z zMvkQXO!Dl3$|Uw5H4Y?)jvCh?zml}ZvY^wK0spdq;jddB*L~Qq6GnPymV@iB4p%}h;qh#{0l^Tx(x%F$UFUk1l1 z1dQa5u(ec0sx6!7O(hP7W5&vzWYY`r*bc73QOz@%-ie4oFTyKF%`0n8JMel3Rv3Ty zMhf(p;c_tv+g8olMQ;Ip`Lnd$|LDYP$jqDE9b=mM!qrKyZWxva6}(2(_%M4TM57zr z(E<04q@0>_jyLgDJ6gI~^nx*0okd4~%zxjW5;}2!Q0D9aZ82ngv@FtwxGVGpdBQjfslk+Q&lO~VLxi@p|aWa~#FN4HP!xzieT%2QiG4OdFS1jnGOA{}C-( znU5iXw`;pxH+Jvf5)Y*-ioDYkN~PR060L=Y`r z!er~QJhU29Mr*rxRKxwT!F|@W?1t0N0~;~32?wv%e;8O_)3^-2R}F?X=#V)Y2|Cd` z3$NGXx*w107vax3{9eRwY&&?Xkqxa<5sc&0se0#|{n z!1W}qCvok>wG-DfxSqka2iG24dvWdc8oi9(*lFkqwnl&|JqN!<__-*=ZYo>2yLmm8 zaNxbHy%vHp4r&oJM=-9}HL=&bI-^(XgXI1`h`n(7`CjCEcn9U%eFQCCzk}-=?31&y zPg1B)jx}+gP~`O|sU2{Wj$cErVQhQ-bc6d8x84`rdVe2~G?h(@)8AL85R-eMen8Ci z1L7f4f1jPgtf3-X9&%!z8=Uq!T%N%1S^S>E?*;r`!EYOW@9f~dNkm&G;+lXf2-!#D zamA|gs1;YNACH=G1q0zx6Rsv)jkp>I_l;~Lfxn&j>6&wN@y!GJCf9&c59kYi9^4ND z!v^)8B)Z97r?}Eovi%TAFseFEKM!F89|n5~4LYE7VspY46c~PT1Nj&u&I$H|MMj-_ zkqPXf9(>l!PR_wlY>l8t#1L}nnRR=KY|Rt z;K)x(Roo9CQ9Y&NiVECs6w#x3nI;4aoXd26nVI+(S&#?iJ}WNt1?4`zO5B5AorH*D z%k@}P;Q%E850!D^nQOIuSY2Tx$&^$4C6PjC!=)3cXu6&_#c|@zWXX5`Qv7{jHkSTu z2CY9uSbhF|Jpkgd0(GY~e)ZSxBZj?dAC{%l|J9HSPuaIk53CG_U6wDbyIpOXPi-Hx z7j_mwmj~NLOk-92blO$A4|l(hql*V&9=XXR2Hz$0ze~is;5J1kr1;P_W!1K+!~ABB z+{D`b?MHZTL{i|{T(`yE@f5vYD>N5b%dXJgDe=~uyjeM1Co zH<8+&l!86(=E3{Y_uc=dT`3d|F>ZDHu`2~P3c2#QMg$YF)IOyP?FpaBL|pPEKI;l@ zWuXo1ci*~!jmHLdm9~MI`!_IuLe0k{0K#1y?sR+yA1|D0S|g*l0M}Ssn|gK`+&UKrzE>nx!E*A3D$@;XjQZQj(a?tknK;vy-@EK4;sUBo zt|*KqrI(zcI*N!z{=giKMeh0@5q&xEc3?Q{Pk;wZIyd(ON?g~}8&Hg?0pcX}l04H= zw}KA_R#4p#nH89=aNP~hoJiR0_v1Oqe+p-nRGOxiWNNy2arA4F?y&4`01x)_KFxY` zFq>j{GE>I!qMN>wYY<3sB?#EDyhfAqw@`Vr%{|U-McgGiafUT|)>lB*_$_sM_ zGAyUqL~x?H(CaUGz~t`eMHGMhX1&V__lD-Kokk_HH8+6>?P46V;;AuIGzPpB5(Yqk zkkZvAf1G&fi{Oz4A`K}i$fl}I8mnU-n6AHS!Ft^(+2I%0D{Cy*%Ou8dy(GX$kZ*|- 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

    r>ALqoP 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

    sPt#~e7svQq9Zs5(1bSwFzF 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�p}v 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 T1or_`zzpy=@;Y&aV#%CO%Arw4 diff --git a/Scripts/Max/PlasmaExport.ms b/Scripts/Max/PlasmaExport.ms deleted file mode 100644 index 2d608dbc..00000000 --- a/Scripts/Max/PlasmaExport.ms +++ /dev/null @@ -1,39 +0,0 @@ --- Export function, takes an input dir (where max scene files are), --- and an output dir, where the exported files should go --- - -function ExportScenes = -( - scnInDir = GetSavePath caption:"Choose Max Source Directory" - if scnInDir == undefined then return "Cancel" - scnInDir = scnInDir + "\\" - - scnOutFile = GetSaveFileName caption:"Choose Dest File" types:"PRD(*.prd)|*.prd|" - if scnOutFile == undefined then return "Cancel" - scnOutDir = getFileNamePath(scnOutFile) + "dat\\" - - makeDir scnOutDir - files = getFiles (scnInDir + "*.max") - start = timeStamp() - for f in files do - ( - format "Exporting file % to %\n" f scnOutFile - loadMAXFile f - exportFile scnOutFile #noPrompt - ) - end = TimeStamp() - format "Exporting took % minutes\n" (( end - start) / 60000.0) -) - - --- --- main --- -utility main_panel "Build Data" -( - button convert_scenes "Plasma Exporter" - on convert_scenes pressed do - ( - ExportScenes () - ) -) \ No newline at end of file diff --git a/Scripts/Python/plasma/Plasma.py b/Scripts/Python/plasma/Plasma.py deleted file mode 100644 index 1b44a157..00000000 --- a/Scripts/Python/plasma/Plasma.py +++ /dev/null @@ -1,9688 +0,0 @@ -""" *==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program 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 this program. If not, see . - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - - *==LICENSE==* """ -def PtAcceptInviteInGame(friendName,inviteKey): - """Sends a VaultTask to the server to perform the invite""" - pass - -def PtAmCCR(): - """Returns true if local player is a CCR""" - pass - -def PtAtTimeCallback(selfkey,time,id): - """This will create a timer callback that will call OnTimer when complete -- 'selfkey' is the ptKey of the PythonFile component -- 'time' is how much time from now (in seconds) to call back -- 'id' is an integer id that will be returned in the OnTimer call""" - pass - -def PtAttachObject(child,parent): - """Attach child to parent based on ptKey or ptSceneobject -- childKey is the ptKey or ptSceneobject of the one being attached -- parentKey is the ptKey or ptSceneobject of the one being attached to -(both arguments must be ptKeys or ptSceneobjects, you cannot mix types)""" - pass - -def PtAvatarEnterAFK(): - """Tells the local avatar to enter AwayFromKeyboard idle loop (netpropagated)""" - pass - -def PtAvatarEnterLookingAtKI(): - """Tells the local avatar to enter looking at KI idle loop (netpropagated)""" - pass - -def PtAvatarEnterUsePersBook(): - """Tells the local avatar to enter using their personal book idle loop (netpropagated)""" - pass - -def PtAvatarExitAFK(): - """Tells the local avatar to exit AwayFromKeyboard idle loop (netpropagated)""" - pass - -def PtAvatarExitLookingAtKI(): - """Tells the local avatar to exit looking at KI idle loop (netpropagated)""" - pass - -def PtAvatarExitUsePersBook(): - """Tells the local avatar to exit using their personal book idle loop (netpropagated)""" - pass - -def PtAvatarSitOnGround(): - """Tells the local avatar to sit on ground and enter sit idle loop (netpropagated)""" - pass - -def PtAvatarSpawnNext(): - """Send the avatar to the next spawn point""" - pass - -def PtCanShadowCast(): - """Can we cast shadows?""" - pass - -def PtChangeAvatar(gender): - """Change the local avatar's gender (or clothing type)""" - pass - -def PtChangePassword(password): - """Changes the current account's password""" - pass - -def PtChangePlayerName(name): - """Change the local avatar's name""" - pass - -def PtCheckVisLOS(startPoint,endPoint): - """Does LOS check from start to end""" - pass - -def PtCheckVisLOSFromCursor(): - """Does LOS check from where the mouse cursor is, into the screen""" - pass - -def PtClearCameraStack(): - """clears all cameras""" - pass - -def PtClearOfferBookMode(): - """Cancel the offer book interface""" - pass - -def PtClearPrivateChatList(memberKey): - """Remove the local avatar from private vox messaging, and / or clear members from his chat list""" - pass - -def PtClearTimerCallbacks(key): - """This will remove timer callbacks to the specified key""" - pass - -def PtConsole(command): - """This will execute 'command' as if it were typed into the Plasma console.""" - pass - -def PtConsoleNet(command,netForce): - """This will execute 'command' on the console, over the network, on all clients. -If 'netForce' is true then force command to be sent over the network.""" - pass - -def PtCreateDir(directory): - """Creates the directory and all parent folders. Returns false on failure""" - pass - -def PtCreatePlayer(playerName, avatarShape, invitation): - """Creates a new player""" - pass - -def PtCreatePlayerW(playerName, avatarShape, invitation): - """Unicode version of PtCreatePlayer""" - pass - -def PtCreatePublicAge(ageInfo, cbObject=None): - """Create a public instance of the given age. -cbObject, if supplied should have a member called publicAgeCreated(self,ageInfo)""" - pass - -def PtDebugAssert(cond, msg): - """Debug only: Assert if condition is false.""" - pass - -def PtDeletePlayer(playerInt): - """Deletes a player associated with the current account""" - pass - -def PtDetachObject(child,parent): - """Detach child from parent based on ptKey or ptSceneobject -- child is the ptKey or ptSceneobject of the one being detached -- parent is the ptKey or ptSceneobject of the one being detached from -(both arguments must be ptKeys or ptSceneobjects, you cannot mix types)""" - pass - -def PtDirtySynchClients(selfKey,SDLStateName,flags): - """DO NOT USE - handled by ptSDL""" - pass - -def PtDirtySynchState(selfKey,SDLStateName,flags): - """DO NOT USE - handled by ptSDL""" - pass - -def PtDisableAvatarCursorFade(): - """Disable the avatar cursor fade""" - pass - -def PtDisableAvatarJump(): - """Disable the ability of the avatar to jump""" - pass - -def PtDisableControlKeyEvents(selfKey): - """Disable the control key events from calling OnControlKeyEvent""" - pass - -def PtDisableForwardMovement(): - """Disable the ability of the avatar to move forward""" - pass - -def PtDisableMouseMovement(): - """Disable avatar mouse movement input""" - pass - -def PtDisableMovementKeys(): - """Disable avatar movement input""" - pass - -def PtDisableRenderScene(): - """UNKNOWN""" - pass - -def PtDisableShadows(): - """Turns shadows off""" - pass - -def PtDumpLogs(folder): - """Dumps all current log files to the specified folder (a sub-folder to the log folder)""" - pass - -def PtEmoteAvatar(emote): - """Play an emote on the local avatar (netpropagated)""" - pass - -def PtEnableAvatarCursorFade(): - """Enable the avatar cursor fade""" - pass - -def PtEnableAvatarJump(): - """Enable the ability of the avatar to jump""" - pass - -def PtEnableControlKeyEvents(selfKey): - """Enable control key events to call OnControlKeyEvent(controlKey,activateFlag)""" - pass - -def PtEnableForwardMovement(): - """Enable the ability of the avatar to move forward""" - pass - -def PtEnableMouseMovement(): - """Enable avatar mouse movement input""" - pass - -def PtEnableMovementKeys(): - """Enable avatar movement input""" - pass - -def PtEnablePlanarReflections(on): - """Enables/disables planar reflections""" - pass - -def PtEnableRenderScene(): - """UNKNOWN""" - pass - -def PtEnableShadows(): - """Turns shadows on""" - pass - -def PtExcludeRegionSet(senderKey,regionKey,state): - """This will set the state of an exclude region -- 'senderKey' is a ptKey of the PythonFile component -- 'regionKey' is a ptKey of the exclude region -- 'state' is either kExRegRelease or kExRegClear""" - pass - -def PtExcludeRegionSetNow(senderKey,regionKey,state): - """This will set the state of an exclude region immediately on the server -- 'senderKey' is a ptKey of the PythonFile component -- 'regionKey' is a ptKey of the exclude region -- 'state' is either kExRegRelease or kExRegClear""" - pass - -def PtFadeIn(lenTime, holdFlag, noSound=0): - """Fades screen in for lenTime seconds""" - pass - -def PtFadeLocalAvatar(fade): - """Fade (or unfade) the local avatar""" - pass - -def PtFadeOut(lenTime, holdFlag, noSound=0): - """Fades screen out for lenTime seconds""" - pass - -def PtFakeLinkAvatarToObject(avatar,object): - """Pseudo-links avatar to object within the same age -""" - pass - -def PtFileExists(filename): - """Returns true if the specified file exists""" - pass - -def PtFindSceneobject(name,ageName): - """This will try to find a sceneobject based on its name and what age its in -- it will return a ptSceneObject if found- if not found then a NameError exception will happen""" - pass - -def PtFirstPerson(): - """is the local avatar in first person mode""" - pass - -def PtFogSetDefColor(color): - """Sets default fog color""" - pass - -def PtFogSetDefExp(end,density): - """Set exp fog values""" - pass - -def PtFogSetDefExp2(end,density): - """Set exp2 fog values""" - pass - -def PtFogSetDefLinear(start,end,density): - """Set linear fog values""" - pass - -def PtForceCursorHidden(): - """Forces the cursor to hide, overriding everything. -Only call if other methods won't work. The only way to show the cursor after this call is PtForceMouseShown()""" - pass - -def PtForceCursorShown(): - """Forces the cursor to show, overriding everything. -Only call if other methods won't work. This is the only way to show the cursor after a call to PtForceMouseHidden()""" - pass - -def PtGMTtoDniTime(gtime): - """Converts GMT time (passed in) to D'Ni time""" - pass - -def PtGUICursorDimmed(): - """Dimms the GUI cursor""" - pass - -def PtGUICursorOff(): - """Turns the GUI cursor off""" - pass - -def PtGUICursorOn(): - """Turns the GUI cursor on""" - pass - -def PtGetAccountName(): - """Returns the account name for the current account""" - pass - -def PtGetAccountPlayerList(): - """Returns list of players associated with the current account""" - pass - -def PtGetAgeInfo(): - """Returns ptAgeInfoStruct of the current Age""" - pass - -def PtGetAgeName(): - """DEPRECIATED - use ptDniInfoSource instead""" - pass - -def PtGetAgeSDL(): - """Returns the global ptSDL for the current Age""" - pass - -def PtGetAgeTime(): - """DEPRECIATED - use ptDniInfoSource instead""" - pass - -def PtGetAgeTimeOfDayPercent(): - """Returns the current age time of day as a percent (0 to 1)""" - pass - -def PtGetAvatarKeyFromClientID(clientID): - """From an integer that is the clientID, find the avatar and return its ptKey""" - pass - -def PtGetCameraNumber(x): - """Returns camera x's name from stack""" - pass - -def PtGetClientIDFromAvatarKey(avatarKey): - """From a ptKey that points at an avatar, return the players clientID (integer)""" - pass - -def PtGetClientName(avatarKey=None): - """This will return the name of the client that is owned by the avatar -- avatarKey is the ptKey of the avatar to get the client name of. -If avatarKey is omitted then the local avatar is used""" - pass - -def PtGetControlEvents(on, key): - """Registers or unregisters for control event messages""" - pass - -def PtGetDefaultDisplayParams(): - """Returns the default resolution and display settings""" - pass - -def PtGetDefaultSpawnPoint(): - """Returns the default spawnpoint definition (as a ptSpawnPointInfo)""" - pass - -def PtGetDesktopColorDepth(): - """Returns desktop ColorDepth""" - pass - -def PtGetDesktopHeight(): - """Returns desktop height""" - pass - -def PtGetDesktopWidth(): - """Returns desktop width""" - pass - -def PtGetDialogFromString(dialogName): - """Get a ptGUIDialog from its name""" - pass - -def PtGetDialogFromTagID(tagID): - """Returns the dialog associated with the tagID""" - pass - -def PtGetDniTime(): - """Returns current D'Ni time""" - pass - -def PtGetFrameDeltaTime(): - """Returns the amount of time that has elapsed since last frame.""" - pass - -def PtGetGameTime(): - """Returns the system game time (frame based) in seconds.""" - pass - -def PtGetInitPath(): - """Returns the unicode path to the client's init directory. Do NOT convert to a standard string.""" - pass - -def PtGetLanguage(): - """Returns the current language as a PtLanguage enum""" - pass - -def PtGetLocalAvatar(): - """This will return a ptSceneobject of the local avatar -- if there is no local avatar a NameError exception will happen.""" - pass - -def PtGetLocalClientID(): - """Returns our local client ID number""" - pass - -def PtGetLocalKILevel(): - """returns local player's ki level""" - pass - -def PtGetLocalPlayer(): - """Returns a ptPlayer object of the local player""" - pass - -def PtGetLocalizedString(name, arguments=None): - """Returns the localized string specified by name (format is Age.Set.Name) and substitutes the arguments in the list of strings passed in as arguments.""" - pass - -def PtGetMouseTurnSensitivity(): - """Returns the sensitivity""" - pass - -def PtGetNumCameras(): - """returns camera stack size""" - pass - -def PtGetNumParticles(key): - """Key is the key of scene object host to particle system""" - pass - -def PtGetNumRemotePlayers(): - """Returns the number of remote players in this Age with you.""" - pass - -def PtGetPlayerList(): - """Returns a list of ptPlayer objects of all the remote players""" - pass - -def PtGetPlayerListDistanceSorted(): - """Returns a list of ptPlayers, sorted by distance""" - pass - -def PtGetPrevAgeInfo(): - """Returns ptAgeInfoStruct of previous age visited""" - pass - -def PtGetPrevAgeName(): - """Returns filename of previous age visited""" - pass - -def PtGetPublicAgeList(ageName, cbObject=None): - """Get list of public ages for the given age name. -cbObject, if supplied should have a method called gotPublicAgeList(self,ageList). ageList is a list of tuple(ptAgeInfoStruct,nPlayersInAge)""" - pass - -def PtGetPythonLoggingLevel(): - """Returns the current level of python logging""" - pass - -def PtGetServerTime(): - """Returns the current time on the server (which is GMT)""" - pass - -def PtGetShadowVisDistance(): - """Returns the maximum shadow visibility distance""" - pass - -def PtGetSupportedDisplayModes(): - """Returns a list of supported resolutions""" - pass - -def PtGetTime(): - """Returns the number of seconds since the game was started.""" - pass - -def PtGetUserPath(): - """Returns the unicode path to the client's root user directory. Do NOT convert to a standard string.""" - pass - -def PtHideDialog(dialogName): - """Hide a GUI dialog by name (does not unload dialog)""" - pass - -def PtIsActivePlayerSet(): - """Returns whether or not an active player is set""" - pass - -def PtIsCCRAway(): - """Returns current status of CCR dept""" - pass - -def PtIsClickToTurn(): - """Is click-to-turn on?""" - pass - -def PtIsCurrentBrainHuman(): - """Returns whether the local avatar current brain is the human brain""" - pass - -def PtIsDemoMode(): - """Returns whether the game is in Demo mode or not""" - pass - -def PtIsDialogLoaded(dialogName): - """Test to see if a GUI dialog is loaded, by name""" - pass - -def PtIsEnterChatModeKeyBound(): - """Returns whether the EnterChatMode is bound to a key""" - pass - -def PtIsGUIModal(): - """Returns true if the GUI is displaying a modal dialog and blocking input""" - pass - -def PtIsInternalRelease(): - """Returns whether the client is an internal build or not""" - pass - -def PtIsMouseInverted(): - """Is the mouse currently inverted?""" - pass - -def PtIsShadowsEnabled(): - """Returns whether shadows are currently turned on""" - pass - -def PtIsSinglePlayerMode(): - """Returns whether the game is in single player mode or not""" - pass - -def PtIsSubscriptionActive(): - """Returns true if the current player is a paying subscriber""" - pass - -def PtKillParticles(timeRemaining,pctToKill,particleSystem): - """Tells particleSystem to kill pctToKill percent of its particles""" - pass - -def PtLimitAvatarLOD(LODlimit): - """Sets avatar's LOD limit""" - pass - -def PtLoadAvatarModel(modelName, spawnPoint, userStr = ""): - """Loads an avatar model at the given spawn point. Assigns the user specified string to it.""" - pass - -def PtLoadBookGUI(guiName): - """Loads the gui specified, a gui must be loaded before it can be used. If the gui is already loaded, doesn't do anything""" - pass - -def PtLoadDialog(dialogName,selfKey=None,ageName=""): - """Loads a GUI dialog by name and optionally set the Notify proc key -If the dialog is already loaded then it won't load it again""" - pass - -def PtLoadJPEGFromDisk(filename,width,height): - """The image will be resized to fit the width and height arguments. Set to 0 if resizing is not desired. -Returns a pyImage of the specified file.""" - pass - -def PtLocalAvatarIsMoving(): - """Returns true if the local avatar is moving (a movement key is held down)""" - pass - -def PtLocalAvatarRunKeyDown(): - """Returns true if the run key is being held down for the local avatar""" - pass - -def PtMaxListenDistSq(): - """Returns the maximum distance (squared) of the listen range""" - pass - -def PtMaxListenListSize(): - """Returns the maximum listen number of players""" - pass - -def PtNotifyOffererLinkAccepted(offerer): - """Tell the offerer that we accepted the link offer""" - pass - -def PtNotifyOffererLinkCompleted(offerer): - """Tell the offerer that we completed the link""" - pass - -def PtNotifyOffererLinkRejected(offerer): - """Tell the offerer that we rejected the link offer""" - pass - -def PtPageInNode(nodeName, ageName=""): - """Pages in node, or a list of nodes""" - pass - -def PtPageOutNode(nodeName): - """Pages out a node""" - pass - -def PtPrintToScreen(message): - """Prints 'message' to the status log, for debug only.""" - pass - -def PtRateIt(chronicleName,dialogPrompt,onceFlag): - """Shows a dialog with dialogPrompt and stores user input rating into chronicleName""" - pass - -def PtRebuildCameraStack(name,ageName): - """Push camera with this name on the stack""" - pass - -def PtRecenterCamera(): - """re-centers the camera""" - pass - -def PtRemovePublicAge(ageInstanceGuid, cbObject=None): - """Remove a public instance of the given age. -cbObject, if supplied should have a member called publicAgeRemoved(self,ageInstanceGuid)""" - pass - -def PtRequestLOSScreen(selfKey,ID,xPos,yPos,distance,what,reportType): - """Request a LOS check from a point on the screen""" - pass - -def PtSaveScreenShot(fileName,width=640,height=480,quality=75): - """Takes a screenshot with the specified filename, size, and quality""" - pass - -def PtSendChatToCCR(message,CCRPlayerID): - """Sends a chat message to a CCR that has contacted this player""" - pass - -def PtSendKIGZMarkerMsg(markerNumber,sender): - """Same as PtSendKIMessageInt except 'sender' could get a notify message back -""" - pass - -def PtSendKIMessage(command,value): - """Sends a command message to the KI frontend. -See PlasmaKITypes.py for list of commands""" - pass - -def PtSendKIMessageInt(command,value): - """Same as PtSendKIMessage except the value is guaranteed to be a UInt32 -(for things like player IDs)""" - pass - -def PtSendPetitionToCCR(message,reason=0,title=""): - """Sends a petition with a message to the CCR group""" - pass - -def PtSendPrivateChatList(chatList): - """Lock the local avatar into private vox messaging, and / or add new members to his chat list""" - pass - -def PtSendRTChat(fromPlayer,toPlayerList,message,flags): - """Sends a realtime chat message to the list of ptPlayers -If toPlayerList is an empty list, it is a broadcast message""" - pass - -def PtSetActivePlayer(playerInt): - """Sets the active player associated with the current account""" - pass - -def PtSetAlarm(secs, cbObject, cbContext): - """secs is the amount of time before your alarm goes off. -cbObject is a python object with the method onAlarm(int context) -cbContext is an integer.""" - pass - -def PtSetBehaviorLoopCount(behaviorKey,stage,loopCount,netForce): - """This will set the loop count for a particular stage in a multistage behavior""" - pass - -def PtSetBehaviorNetFlags(behKey, netForce, netProp): - """Sets net flags on the associated behavior""" - pass - -def PtSetClearColor(red,green,blue): - """Set the clear color""" - pass - -def PtSetClickToTurn(state): - """Turns on click-to-turn""" - pass - -def PtSetGamma2(gamma): - """Set the gamma with gamma2 rules""" - pass - -def PtSetGlobalClickability(enable): - """Enable or disable all clickables on the local client""" - pass - -def PtSetGraphicsOptions(width, height, colordepth, windowed, numAAsamples, numAnisoSamples, VSync): - """Set the graphics options""" - pass - -def PtSetLightAnimStart(key,name,start): - """ Key is the key of scene object host to light, start is a bool. Name is the name of the light to manipulate""" - pass - -def PtSetLightValue(key,name,r,g,b,a): - """ Key is the key of scene object host to light. Name is the name of the light to manipulate""" - pass - -def PtSetMouseInverted(): - """Inverts the mouse""" - pass - -def PtSetMouseTurnSensitivity(sensitivity): - """Set the mouse sensitivity""" - pass - -def PtSetMouseUninverted(): - """Uninverts the mouse""" - pass - -def PtSetOfferBookMode(selfkey,ageFilename,ageInstanceName): - """Put us into the offer book interface""" - pass - -def PtSetParticleDissentPoint(x, y, z, particlesys): - """Sets the dissent point of the particlesys to x,y,z""" - pass - -def PtSetParticleOffset(x,y,z,particlesys): - """Sets the particlesys particle system's offset""" - pass - -def PtSetPythonLoggingLevel(level): - """Sets the current level of python logging""" - pass - -def PtSetShadowVisDistance(distance): - """Set the maximum shadow visibility distance""" - pass - -def PtSetShareSpawnPoint(spawnPoint): - """This sets the desired spawn point for the receiver to link to""" - pass - -def PtShootBulletFromObject(selfkey, gunObj, radius, range): - """Shoots a bullet from an object""" - pass - -def PtShootBulletFromScreen(selfkey, xPos, yPos, radius, range): - """Shoots a bullet from a position on the screen""" - pass - -def PtShowDialog(dialogName): - """Show a GUI dialog by name (does not load dialog)""" - pass - -def PtStartScreenCapture(selfKey,width=800,height=600): - """Starts a capture of the screen""" - pass - -def PtToggleAvatarClickability(on): - """Turns on and off our avatar's clickability""" - pass - -def PtTransferParticlesToObject(objFrom, objTo, num): - """Transfers num particles from objFrom to objTo""" - pass - -def PtUnLoadAvatarModel(avatarKey): - """Unloads the specified avatar model""" - pass - -def PtUnloadAllBookGUIs(): - """Unloads all loaded guis except for the default one""" - pass - -def PtUnloadBookGUI(guiName): - """Unloads the gui specified. If the gui isn't loaded, doesn't do anything""" - pass - -def PtUnloadDialog(dialogName): - """This will unload the GUI dialog by name. If not loaded then nothing will happen""" - pass - -def PtUpgradeVisitorToExplorer(playerInt): - """Upgrades the player to explorer status""" - pass - -def PtUsingUnicode(): - """Returns true if the current language is a unicode language (like Japanese)""" - pass - -def PtValidateKey(key): - """Returns true(1) if 'key' is valid and loaded, -otherwise returns false(0)""" - pass - -def PtWasLocallyNotified(selfKey): - """Returns 1 if the last notify was local or 0 if the notify originated on the network""" - pass - -def PtWearDefaultClothing(key): - """Forces the avatar to wear the default clothing set""" - pass - -def PtWearDefaultClothingType(key,type): - """Forces the avatar to wear the default clothing of the specified type""" - pass - -def PtWearMaintainerSuit(key,wearOrNot): - """Wears or removes the maintainer suit of clothes""" - pass - -def PtWhatGUIControlType(guiKey): - """Returns the control type of the key passed in""" - pass - -def PtYesNoDialog(selfkey,dialogMessage): - """This will display a Yes/No dialog to the user with the text dialogMessage -This dialog _has_ to be answered by the user. -And their answer will be returned in a Notify message.""" - pass - -class ptAgeInfoStruct: - """Class to hold AgeInfo struct data""" - def __init__(self): - """None""" - pass - - def copyFrom(self,other): - """Copies data from one ptAgeInfoStruct or ptAgeInfoStructRef to this one""" - pass - - def getAgeFilename(self): - """Gets the Age's filename""" - pass - - def getAgeInstanceGuid(self): - """Get the Age's instance GUID""" - pass - - def getAgeInstanceName(self): - """Get the instance name of the Age""" - pass - - def getAgeLanguage(self): - """Gets the age's language (integer)""" - pass - - def getAgeSequenceNumber(self): - """Gets the unique sequence number""" - pass - - def getAgeUserDefinedName(self): - """Gets the user defined part of the Age name""" - pass - - def getDisplayName(self): - """Returns a string that is the displayable name of the age instance""" - pass - - def setAgeFilename(self,filename): - """Sets the filename of the Age""" - pass - - def setAgeInstanceGuid(self,guid): - """Sets the Age instance's GUID""" - pass - - def setAgeInstanceName(self,instanceName): - """Sets the instance name of the Age""" - pass - - def setAgeLanguage(self,lang): - """Sets the age's language (integer)""" - pass - - def setAgeSequenceNumber(self,seqNumber): - """Sets the unique sequence number""" - pass - - def setAgeUserDefinedName(self,udName): - """Sets the user defined part of the Age""" - pass - -class ptAgeInfoStructRef: - """Class to hold AgeInfo struct data""" - def __init__(self): - """None""" - pass - - def copyFrom(self,other): - """Copies data from one ptAgeInfoStruct or ptAgeInfoStructRef to this one""" - pass - - def getAgeFilename(self): - """Gets the Age's filename""" - pass - - def getAgeInstanceGuid(self): - """Get the Age's instance GUID""" - pass - - def getAgeInstanceName(self): - """Get the instance name of the Age""" - pass - - def getAgeSequenceNumber(self): - """Gets the unique sequence number""" - pass - - def getAgeUserDefinedName(self): - """Gets the user defined part of the Age name""" - pass - - def getDisplayName(self): - """Returns a string that is the displayable name of the age instance""" - pass - - def setAgeFilename(self,filename): - """Sets the filename of the Age""" - pass - - def setAgeInstanceGuid(self,guid): - """Sets the Age instance's GUID""" - pass - - def setAgeInstanceName(self,instanceName): - """Sets the instance name of the Age""" - pass - - def setAgeSequenceNumber(self,seqNumber): - """Sets the unique sequence number""" - pass - - def setAgeUserDefinedName(self,udName): - """Sets the user defined part of the Age""" - pass - -class ptAgeLinkStruct: - """Class to hold the data of the AgeLink structure""" - def __init__(self): - """None""" - pass - - def copyFrom(self,other): - """Copies data from one ptAgeLinkStruct or ptAgeLinkStructRef to this one""" - pass - - def getAgeInfo(self): - """Returns a ptAgeInfoStructRef of the AgeInfo for this link""" - pass - - def getLinkingRules(self): - """Returns the linking rules of this link""" - pass - - def getParentAgeFilename(self): - """Returns a string of the parent age filename""" - pass - - def getSpawnPoint(self): - """Gets the spawn point ptSpawnPointInfoRef of this link""" - pass - - def setAgeInfo(self,ageInfo): - """Sets the AgeInfoStruct from the data in ageInfo (a ptAgeInfoStruct)""" - pass - - def setLinkingRules(self,rule): - """Sets the linking rules for this link""" - pass - - def setParentAgeFilename(self,filename): - """Sets the parent age filename for child age links""" - pass - - def setSpawnPoint(self,spawnPtInfo): - """Sets the spawn point of this link (a ptSpawnPointInfo or ptSpawnPointInfoRef)""" - pass - -class ptAgeLinkStructRef: - """Class to hold the data of the AgeLink structure""" - def __init__(self): - """None""" - pass - - def copyFrom(self,other): - """Copies data from one ptAgeLinkStruct or ptAgeLinkStructRef to this one""" - pass - - def getAgeInfo(self): - """Returns a ptAgeInfoStructRef of the AgeInfo for this link""" - pass - - def getLinkingRules(self): - """Returns the linking rules of this link""" - pass - - def getSpawnPoint(self): - """Gets the spawn point ptSpawnPointInfoRef of this link""" - pass - - def setAgeInfo(self,ageInfo): - """Sets the AgeInfoStruct from the data in ageInfo (a ptAgeInfoStruct)""" - pass - - def setLinkingRules(self,rule): - """Sets the linking rules for this link""" - pass - - def setSpawnPoint(self,spawnPtInfo): - """Sets the spawn point of this link (a ptSpawnPointInfo or ptSpawnPointInfoRef)""" - pass - -class ptAgeVault: - """Accessor class to the Age's vault""" - def __init__(self): - """None""" - pass - - def addChronicleEntry(self,name,type,value): - """Adds a chronicle entry with the specified type and value""" - pass - - def addDevice(self,deviceName,cb=None,cbContext=0): - """Adds a device to the age""" - pass - - def findChronicleEntry(self,entryName): - """Returns the named ptVaultChronicleNode""" - pass - - def getAgeDevicesFolder(self): - """Returns a ptVaultFolderNode of the inboxes for the devices in this Age.""" - pass - - def getAgeGuid(self): - """Returns the current Age's guid as a string.""" - pass - - def getAgeInfo(self): - """Returns a ptVaultAgeInfoNode of the this Age""" - pass - - def getAgeSDL(self): - """Returns the age's SDL (ptSDLStateDataRecord)""" - pass - - def getAgesIOwnFolder(self): - """(depreciated, use getBookshelfFolder) Returns a ptVaultFolderNode that contain the Ages I own""" - pass - - def getBookshelfFolder(self): - """Personal age only: Returns a ptVaultFolderNode that contains the owning player's AgesIOwn age list""" - pass - - def getChronicleFolder(self): - """Returns a ptVaultFolderNode""" - pass - - def getDevice(self,deviceName): - """Returns the specified device (ptVaultTextNoteNode)""" - pass - - def getDeviceInbox(self,deviceName): - """Returns a ptVaultFolderNode of the inbox for the named device in this age.""" - pass - - def getPeopleIKnowAboutFolder(self): - """Returns a ptVaultPlayerInfoListNode of the players the Age knows about(?).""" - pass - - def getPublicAgesFolder(self): - """Returns a ptVaultFolderNode that contains all the public Ages""" - pass - - def getSubAgeLink(self,ageInfo): - """Returns a ptVaultAgeLinkNode to 'ageInfo' (a ptAgeInfoStruct) for this Age.""" - pass - - def getSubAgesFolder(self): - """Returns a ptVaultFolderNode of sub Age's folder.""" - pass - - def hasDevice(self,deviceName): - """Does a device with this name exist?""" - pass - - def removeDevice(self,deviceName): - """Removes a device from the age""" - pass - - def setDeviceInbox(self,deviceName,inboxName,cb=None,cbContext=0): - """Set's the device's inbox""" - pass - - def updateAgeSDL(self,pyrec): - """Updates the age's SDL""" - pass - -class ptAnimation: - """Plasma animation class""" - def __init__(self,key=None): - """None""" - pass - - def addKey(self,key): - """Adds an animation modifier to the list of receiver keys""" - pass - - def backwards(self,backwardsFlag): - """Turn on and off playing the animation backwards""" - pass - - def getFirstKey(self): - """This will return a ptKey object that is the first receiver (target) -However, if the parent is not a modifier or not loaded, then None is returned.""" - pass - - def incrementBackward(self): - """Step the animation backward a frame""" - pass - - def incrementForward(self): - """Step the animation forward a frame""" - pass - - def looped(self,loopedFlag): - """Turn on and off looping of the animation""" - pass - - def netForce(self,forceFlag): - """Specify whether this object needs to use messages that are forced to the network -- This is to be used if your Python program is running on only one client -Such as a game master, only running on the client that owns a particular object""" - pass - - def play(self): - """Plays the animation""" - pass - - def playRange(self,start,end): - """Play the animation from start to end""" - pass - - def playToPercentage(self,zeroToOne): - """Play the animation to the specified percentage (0 to 1)""" - pass - - def playToTime(self,time): - """Play the animation to the specified time""" - pass - - def resume(self): - """Resumes the animation from where it was stopped last""" - pass - - def sender(self,selfKey): - """Sets the sender of the messages being sent to the animation modifier""" - pass - - def setAnimName(self,name): - """Sets the animation notetrack name (or (Entire Animation))""" - pass - - def setLoopEnd(self,loopEnd): - """Sets the loop ending position -- 'loopEnd' is the number of seconds from the absolute beginning of the animation""" - pass - - def setLoopStart(self,loopStart): - """Sets the loop starting position -- 'loopStart' is the number of seconds from the absolute beginning of the animation""" - pass - - def skipToBegin(self): - """Skip to the beginning of the animation (don't play)""" - pass - - def skipToEnd(self): - """Skip to the end of the animation (don't play)""" - pass - - def skipToLoopBegin(self): - """Skip to the beginning of the animation loop (don't play)""" - pass - - def skipToLoopEnd(self): - """Skip to the end of the animation loop (don't play)""" - pass - - def skipToTime(self,time): - """Skip the animation to time (don't play)""" - pass - - def speed(self,speed): - """Sets the animation playback speed""" - pass - - def stop(self): - """Stops the animation""" - pass - -class ptAudioControl: - """Accessor class to the Audio controls""" - def __init__(self): - """None""" - pass - - def canSetMicLevel(self): - """Can the microphone level be set? Returns 1 if true otherwise returns 0.""" - pass - - def disable(self): - """Disabled audio""" - pass - - def enable(self): - """Enables audio""" - pass - - def enableVoiceChat(self,state): - """Enables or disables voice chat.""" - pass - - def enableVoiceCompression(self,state): - """Enables or disables voice compression.""" - pass - - def enableVoiceNetBroadcast(self,state): - """Enables or disables voice over network broadcast.""" - pass - - def enableVoiceRecording(self,state): - """Enables or disables voice recording.""" - pass - - def getAmbienceVolume(self): - """Returns the volume (0.0 to 1.0) for the Ambiance.""" - pass - - def getAudioDeviceName(self,index): - """Gets the name of audio device for the given index""" - pass - - def getDeviceName(self): - """Gets the name for the device being used by the audio system""" - pass - - def getGUIVolume(self): - """Returns the volume (0.0 to 1.0) for the GUI dialogs.""" - pass - - def getHighestMode(self): - """Gets the highest possible audio system mode""" - pass - - def getMicLevel(self): - """Returns the microphone recording level (0.0 to 1.0).""" - pass - - def getMode(self): - """Gets the audio system mode""" - pass - - def getMusicVolume(self): - """Returns the volume (0.0 to 1.0) for the Music.""" - pass - - def getNPCVoiceVolume(self): - """Returns the volume (0.0 to 1.0) for the NPC's voice.""" - pass - - def getNumAudioDevices(self): - """Returns the number of available audio devices.""" - pass - - def getPriorityCutoff(self): - """Returns current sound priority""" - pass - - def getSoundFXVolume(self): - """Returns the volume (0.0 to 1.0) for the Sound FX.""" - pass - - def getVoiceVolume(self): - """Returns the volume (0.0 to 1.0) for the Voices.""" - pass - - def hideIcons(self): - """Hides (disables) the voice recording icons.""" - pass - - def isEnabled(self): - """Is the audio enabled? Returns 1 if true otherwise returns 0.""" - pass - - def isHardwareAccelerated(self): - """Is audio hardware acceleration enabled? Returns 1 if true otherwise returns 0.""" - pass - - def isMuted(self): - """Are all sounds muted? Returns 1 if true otherwise returns 0.""" - pass - - def isUsingEAXAcceleration(self): - """Is EAX sound acceleration enabled? Returns 1 if true otherwise returns 0.""" - pass - - def isVoiceCompressionEnabled(self): - """Is voice compression enabled? Returns 1 if true otherwise returns 0.""" - pass - - def isVoiceNetBroadcastEnabled(self): - """Is voice over net enabled? Returns 1 if true otherwise returns 0.""" - pass - - def isVoiceRecordingEnabled(self): - """Is voice recording enabled? Returns 1 if true otherwise returns 0.""" - pass - - def muteAll(self): - """Mutes all sounds.""" - pass - - def pushToTalk(self,state): - """Enables or disables 'push-to-talk'.""" - pass - - def recordFrame(self,size): - """Sets the voice packet frame size.""" - pass - - def recordSampleRate(self,sampleRate): - """Sets the recording sample rate.""" - pass - - def setAmbienceVolume(self,volume): - """Sets the Ambience volume (0.0 to 1.0) for the game. -This only sets the volume for this game session.""" - pass - - def setDeviceName(self,devicename,restart): - """Sets the device name for the audio system, and optionally restarts it""" - pass - - def setGUIVolume(self,volume): - """Sets the GUI dialog volume (0.0 to 1.0) for the game. -This only sets the volume for this game session.""" - pass - - def setLoadOnDemand(self,state): - """Enables or disables the load on demand for sounds.""" - pass - - def setMicLevel(self,level): - """Sets the microphone recording level (0.0 to 1.0).""" - pass - - def setMode(self,mode): - """Sets the audio system mode""" - pass - - def setMusicVolume(self,volume): - """Sets the Music volume (0.0 to 1.0) for the game. -This only sets the volume for this game session.""" - pass - - def setNPCVoiceVolume(self,volume): - """Sets the NPC's voice volume (0.0 to 1.0) for the game. -This only sets the volume for this game session.""" - pass - - def setPriorityCutoff(self,priority): - """Sets the sound priority""" - pass - - def setSoundFXVolume(self,volume): - """Sets the SoundFX volume (0.0 to 1.0) for the game. -This only sets the volume for this game session.""" - pass - - def setTwoStageLOD(self,state): - """Enables or disables two-stage LOD, where sounds can be loaded into RAM but not into sound buffers. -...Less of a performance hit, harder on memory.""" - pass - - def setVoiceVolume(self,volume): - """Sets the Voice volume (0.0 to 1.0) for the game. -This only sets the volume for this game session.""" - pass - - def showIcons(self): - """Shows (enables) the voice recording icons.""" - pass - - def squelchLevel(self,level): - """Sets the squelch level.""" - pass - - def supportsEAX(self): - """Returns true or false based on whether or not a the device specified supports EAX""" - pass - - def unmuteAll(self): - """Unmutes all sounds.""" - pass - - def useEAXAcceleration(self,state): - """Enables or disables EAX sound acceleration (requires hardware acceleration).""" - pass - - def useHardwareAcceleration(self,state): - """Enables or disables audio hardware acceleration.""" - pass - -class ptAvatar: - """Plasma avatar class""" - def __init__(self): - """None""" - pass - - def addWardrobeClothingItem(self,clothing_name,tint1,tint2): - """To add a clothing item to the avatar's wardrobe (closet)""" - pass - - def enterSubWorld(self,sceneobject): - """Places the avatar into the subworld of the ptSceneObject specified""" - pass - - def exitSubWorld(self): - """Exits the avatar from the subWorld where it was""" - pass - - def getAllWithSameMesh(self,clothing_name): - """Returns a lilst of all clothing items that use the same mesh as the specified one""" - pass - - def getAvatarClothingGroup(self): - """Returns what clothing group the avatar belongs to. -It is also a means to determine if avatar is male or female""" - pass - - def getAvatarClothingList(self): - """Returns a list of clothes that the avatar is currently wearing.""" - pass - - def getClosetClothingList(self,clothing_type): - """Returns a list of clothes for the avatar that are in specified clothing group.""" - pass - - def getCurrentMode(self): - """Returns current brain mode for avatar""" - pass - - def getEntireClothingList(self,clothing_type): - """Gets the entire list of clothing available. 'clothing_type' not used -NOTE: should use getClosetClothingList""" - pass - - def getMatchingClothingItem(self,clothingName): - """Finds the matching clothing item that goes with 'clothingName' -Used to find matching left and right gloves and shoes.""" - pass - - def getMorph(self,clothing_name,layer): - """Get the current morph value""" - pass - - def getSkinBlend(self,layer): - """Get the current skin blend value""" - pass - - def getTintClothingItem(self,clothing_name,layer=1): - """Returns a ptColor of a particular item of clothing that the avatar is wearing. -The color will be a ptColor object.""" - pass - - def getTintSkin(self): - """Returns a ptColor of the current skin tint for the avatar""" - pass - - def getUniqueMeshList(self,clothing_type): - """Returns a list of unique clothing items of the desired type (different meshes)""" - pass - - def getWardrobeClothingList(self): - """Return a list of items that are in the avatars closet""" - pass - - def gotoStage(self,behaviorKey,stage,transitionTime,setTimeFlag,newTime,SetDirectionFlag,isForward,netForce): - """Tells a multistage behavior to go to a particular stage""" - pass - - def netForce(self,forceFlag): - """Specify whether this object needs to use messages that are forced to the network -- This is to be used if your Python program is running on only one client -Such as a game master, only running on the client that owns a particular object""" - pass - - def nextStage(self,behaviorKey,transitionTime,setTimeFlag,newTime,SetDirectionFlag,isForward,netForce): - """Tells a multistage behavior to go to the next stage (Why does Matt like so many parameters?)""" - pass - - def oneShot(self,seekKey,duration,usePhysicsFlag,animationName,drivableFlag,reversibleFlag): - """Plays a one-shot animation on the avatar""" - pass - - def playSimpleAnimation(self,animName): - """Play simple animation on avatar""" - pass - - def previousStage(self,behaviorKey,transitionTime,setTimeFlag,newTime,SetDirectionFlag,isForward,netForce): - """Tells a multistage behavior to go to the previous stage""" - pass - - def registerForBehaviorNotify(self,selfKey): - """This will register for behavior notifies from the avatar""" - pass - - def removeClothingItem(self,clothing_name,update=1): - """Tells the avatar to remove a particular item of clothing.""" - pass - - def runBehavior(self,behaviorKey,netForceFlag): - """Runs a behavior on the avatar. Can be a single or multi-stage behavior.""" - pass - - def runBehaviorSetNotify(self,behaviorKey,replyKey,netForceFlag): - """Same as runBehavior, except send notifications to specified keyed object""" - pass - - def saveClothing(self): - """Saves the current clothing options (including morphs) to the vault""" - pass - - def setMorph(self,clothing_name,layer,value): - """Set the morph value (clipped between -1 and 1)""" - pass - - def setReplyKey(self,key): - """Sets the sender's key""" - pass - - def setSkinBlend(self,layer,value): - """Set the skin blend (value between 0 and 1)""" - pass - - def tintClothingItem(self,clothing_name,tint,update=1): - """Tells the avatar to tint(color) a particular item of clothing that they are already wearing. -'tint' is a ptColor object""" - pass - - def tintClothingItemLayer(self,clothing_name,tint,layer,update=1): - """Tells the avatar to tint(color) a particular layer of a particular item of clothing.""" - pass - - def tintSkin(self,tint,update=1): - """Tints all of the skin on the avatar, with the ptColor tint""" - pass - - def unRegisterForBehaviorNotify(self,selfKey): - """This will unregister behavior notifications""" - pass - - def wearClothingItem(self,clothing_name,update=1): - """Tells the avatar to wear a particular item of clothing. -And optionally hold update until later (for applying tinting before wearing).""" - pass - -class ptBook: - """Creates a new book""" - def __init__(self,esHTMLSource,coverImage=None,callbackKey=None,guiName=''): - """None""" - pass - - def allowPageTurning(self,allow): - """Turns on and off the ability to flip the pages in a book""" - pass - - def close(self): - """Closes the book""" - pass - - def closeAndHide(self): - """Closes the book and hides it once it finishes animating""" - pass - - def getCurrentPage(self): - """Returns the currently shown page""" - pass - - def getEditableText(self): - """Returns the editable text currently contained in the book.""" - pass - - def getMovie(self,index): - """Grabs a ptAnimation object representing the movie indexed by index. The index is the index of the movie in the source code""" - pass - - def goToPage(self,page): - """Flips the book to the specified page""" - pass - - def hide(self): - """Hides the book""" - pass - - def nextPage(self): - """Flips the book to the next page""" - pass - - def open(self,startingPage): - """Opens the book to the specified page""" - pass - - def previousPage(self): - """Flips the book to the previous page""" - pass - - def setEditable(self,editable): - """Turn book editing on or off. If the book GUI does not support editing, nothing will happen""" - pass - - def setEditableText(self,text): - """Sets the book's editable text.""" - pass - - def setGUI(self,guiName): - """Sets the gui to be used by the book, if the requested gui is not loaded, it will use the default -Do not call while the book is open!""" - pass - - def setPageMargin(self,margin): - """Sets the text margin for the book""" - pass - - def setSize(self,width,height): - """Sets the size of the book (width and height are floats from 0 to 1)""" - pass - - def show(self,startOpened): - """Shows the book closed, or open if the the startOpened flag is true""" - pass - -class ptCamera: - """Plasma camera class""" - def __init__(self): - """None""" - pass - - def controlKey(self,controlKey,activateFlag): - """Send a control key to the camera as if it was hit by the user. -This is for sending things like pan-up, pan-down, zoom-in, etc.""" - pass - - def disableFirstPersonOverride(self): - """Does _not_ allow the user to override the camera to go to first person camera.""" - pass - - def enableFirstPersonOverride(self): - """Allows the user to override the camera and go to a first person camera.""" - pass - - def getFOV(self): - """Returns the current camera's FOV(h)""" - pass - - def isSmootherCam(self): - """Returns true if we are using the faster cams thing""" - pass - - def isStayInFirstPerson(self): - """Are we staying in first person?""" - pass - - def isWalkAndVerticalPan(self): - """Returns true if we are walking and chewing gum""" - pass - - def restore(self,cameraKey): - """Restores camera to saved one""" - pass - - def save(self,cameraKey): - """Saves the current camera and sets the camera to cameraKey""" - pass - - def set(self,cameraKey,time,save): - """DO NOT USE""" - pass - - def setFOV(self,fov, time): - """Sets the current cameras FOV (based on h)""" - pass - - def setSmootherCam(self,state): - """Set the faster cams thing""" - pass - - def setStayInFirstPerson(self,state): - """Set Stay In First Person Always""" - pass - - def setWalkAndVerticalPan(self,state): - """Set Walk and chew gum""" - pass - - def undoFirstPerson(self): - """If the user has overridden the camera to be in first person, this will take them out of first person. -If the user didn't override the camera, then this will do nothing.""" - pass - -class ptCluster: - """Creates a new ptCluster""" - def __init__(self,ey): - """None""" - pass - - def setVisible(self,isible): - """Shows or hides the cluster object""" - pass - -class ptColor: - """Plasma color class""" - def __init__(self,red=0, green=0, blue=0, alpha=0): - """None""" - pass - - def black(self): - """Sets the color to be black -Example: black = ptColor().black()""" - pass - - def blue(self): - """Sets the color to be blue -Example: blue = ptColor().blue()""" - pass - - def brown(self): - """Sets the color to be brown -Example: brown = ptColor().brown()""" - pass - - def cyan(self): - """Sets the color to be cyan -Example: cyan = ptColor.cyan()""" - pass - - def darkbrown(self): - """Sets the color to be darkbrown -Example: darkbrown = ptColor().darkbrown()""" - pass - - def darkgreen(self): - """Sets the color to be darkgreen -Example: darkgreen = ptColor().darkgreen()""" - pass - - def darkpurple(self): - """Sets the color to be darkpurple -Example: darkpurple = ptColor().darkpurple()""" - pass - - def getAlpha(self): - """Get the alpha blend component of the color""" - pass - - def getBlue(self): - """Get the blue component of the color""" - pass - - def getGreen(self): - """Get the green component of the color""" - pass - - def getRed(self): - """Get the red component of the color""" - pass - - def gray(self): - """Sets the color to be gray -Example: gray = ptColor().gray()""" - pass - - def green(self): - """Sets the color to be green -Example: green = ptColor().green()""" - pass - - def magenta(self): - """Sets the color to be magenta -Example: magenta = ptColor().magenta()""" - pass - - def maroon(self): - """Sets the color to be maroon -Example: maroon = ptColor().maroon()""" - pass - - def navyblue(self): - """Sets the color to be navyblue -Example: navyblue = ptColor().navyblue()""" - pass - - def orange(self): - """Sets the color to be orange -Example: orange = ptColor().orange()""" - pass - - def pink(self): - """Sets the color to be pink -Example: pink = ptColor().pink()""" - pass - - def red(self): - """Sets the color to be red -Example: red = ptColor().red()""" - pass - - def setAlpha(self,alpha): - """Set the alpha blend component of the color. 0.0 to 1.0""" - pass - - def setBlue(self,blue): - """Set the blue component of the color. 0.0 to 1.0""" - pass - - def setGreen(self,green): - """Set the green component of the color. 0.0 to 1.0""" - pass - - def setRed(self,red): - """Set the red component of the color. 0.0 to 1.0""" - pass - - def slateblue(self): - """Sets the color to be slateblue -Example: slateblue = ptColor().slateblue()""" - pass - - def steelblue(self): - """Sets the color to be steelblue -Example: steelblue = ptColor().steelblue()""" - pass - - def tan(self): - """Sets the color to be tan -Example: tan = ptColor().tan()""" - pass - - def white(self): - """Sets the color to be white -Example: white = ptColor().white()""" - pass - - def yellow(self): - """Sets the color to be yellow -Example: yellow = ptColor().yellow()""" - pass - -class ptCritterBrain: - """Object to manipulate critter brains""" - def __init__(self): - """None""" - pass - - def addBehavior(self,animName, behaviorName, loop = 1, randomStartPos = 1, fadeInLen = 2.0, fadeOutLen = 2.0): - """Adds a new animation to the brain as a behavior with the specified name and parameters. If multiple animations are assigned to the same behavior, they will be randomly picked from when started.""" - pass - - def addReceiver(self,key): - """Tells the brain that the specified key wants AI messages""" - pass - - def animationName(self,behavior): - """Returns the animation name associated with the specified integral behavior.""" - pass - - def atGoal(self): - """Are we currently are our final destination?""" - pass - - def avoidingAvatars(self): - """Are we currently avoiding avatars while pathfinding?""" - pass - - def behaviorName(self,behavior): - """Returns the behavior name associated with the specified integral behavior.""" - pass - - def canHearAvatar(self,avatarID): - """Returns whether this brain can hear the avatar with the specified id.""" - pass - - def canSeeAvatar(self,avatarID): - """Returns whether this brain can see the avatar with the specified id.""" - pass - - def curBehavior(self): - """Returns the current integral behavior the brain is running.""" - pass - - def currentGoal(self): - """Returns the current ptPoint that the brain is running towards.""" - pass - - def getHearingDistance(self): - """Returns how far away the brain can hear.""" - pass - - def getLocallyControlled(self): - """Are we the one making AI decisions? NOTE: Not set automatically, some python script needs to tell the brain this using setLocallyControlled().""" - pass - - def getSightCone(self): - """Returns the width of the brain's field of view in radians.""" - pass - - def getSightDistance(self): - """Returns how far the brain can see.""" - pass - - def getStopDistance(self): - """Returns how far away from the goal we could be and still be considered there.""" - pass - - def goToGoal(self,newGoal, avoidingAvatars = 0): - """Tells the brain to start running towards the specified location, avoiding avatars it can see or hear if told to.""" - pass - - def idleBehaviorName(self): - """Returns the name of the brain's idle behavior.""" - pass - - def nextBehavior(self): - """Returns the behavior the brain will be switching to next frame. (-1 if no change)""" - pass - - def playersICanHear(self): - """Returns a list of player ids which this brain can hear.""" - pass - - def playersICanSee(self): - """Returns a list of player ids which this brain can see.""" - pass - - def removeReceiver(self,key): - """Tells the brain that the specified key no longer wants AI messages""" - pass - - def runBehaviorName(self): - """Returns the name of the brain's run behavior.""" - pass - - def runningBehavior(self,behaviorName): - """Returns true if the named behavior is running.""" - pass - - def setHearingDistance(self,dist): - """Set how far away the brain can hear (360 degree field of hearing).""" - pass - - def setLocallyControlled(self,local): - """Tells the brain that we are the ones making all the AI decisions, and to prop location and other information to the server.""" - pass - - def setSightCone(self,radians): - """Set how wide the brain's field of view is in radians. Note that it is the total angle of the cone, half on one side of the brain's line of sight, half on the other.""" - pass - - def setSightDistance(self,dist): - """Set how far away the brain can see.""" - pass - - def setStopDistance(self,dist): - """Set how far away from the goal we should be when we are considered there and stop running.""" - pass - - def startBehavior(self,behaviorName, fade = 1): - """Starts playing the named behavior. If fade is true, it will fade out the previous behavior and fade in the new one. If false, they will immediately switch.""" - pass - - def vectorToPlayer(self,avatarID): - """Returns the vector between us and the specified player.""" - pass - -class ptDniCoordinates: - """Constructor for a D'Ni coordinate""" - def __init__(self): - """None""" - pass - - def fromPoint(self,pt): - """Update these coordinates with the specified ptPoint3""" - pass - - def getHSpans(self): - """Returns the HSpans component of the coordinate""" - pass - - def getTorans(self): - """Returns the Torans component of the coordinate""" - pass - - def getVSpans(self): - """Returns the VSpans component of the coordinate""" - pass - - def update(self): - """Update these coordinates with the players current position""" - pass - -class ptDniInfoSource: - """DO NOT USE""" - def __init__(self): - """None""" - pass - - def getAgeCoords(self): - """Current coords of the player in current age as a ptDniCoordinates""" - pass - - def getAgeGuid(self): - """Unique identifier for this age instance""" - pass - - def getAgeName(self): - """Name of current age""" - pass - - def getAgeTime(self): - """Current time in current age (tbd)""" - pass - -class ptDraw: - """Plasma Draw class""" - def __init__(self): - """None""" - pass - - def disable(self): - """Disables the draw on the sceneobject attached -In other words, makes it invisible""" - pass - - def enable(self,state=1): - """Sets the draw enable for the sceneobject attached""" - pass - - def netForce(self,forceFlag): - """Specify whether this object needs to use messages that are forced to the network -- This is to be used if your Python program is running on only one client -Such as a game master, only running on the client that owns a particular object""" - pass - -class ptDynamicMap: - """Creates a ptDynamicMap object""" - def __init__(self,key=None): - """None""" - pass - - def addKey(self,key): - """Add a receiver... in other words a DynamicMap""" - pass - - def calcTextExtents(self,text): - """Calculates the extent of the specified text, returns it as a (width, height) tuple""" - pass - - def clearKeys(self): - """Clears the receiver list""" - pass - - def clearToColor(self,color): - """Clear the DynamicMap to the specified color -- 'color' is a ptColor object""" - pass - - def drawImage(self,x,y,image,respectAlphaFlag): - """Draws a ptImage object on the dynamicTextmap starting at the location x,y""" - pass - - def drawImageClipped(self,x,y,image,cx,cy,cw,ch,respectAlphaFlag): - """Draws a ptImage object clipped to cx,cy with cw(width),ch(height)""" - pass - - def drawText(self,x,y,text): - """Draw text at a specified location -- x,y is the point to start drawing the text -- 'text' is a string of the text to be drawn""" - pass - - def drawTextW(self,x,y,text): - """Unicode version of drawText""" - pass - - def fillRect(self,left,top,right,bottom,color): - """Fill in the specified rectangle with a color -- left,top,right,bottom define the rectangle -- 'color' is a ptColor object""" - pass - - def flush(self): - """Flush all the commands that were issued since the last flush()""" - pass - - def frameRect(self,left,top,right,bottom,color): - """Frame a rectangle with a specified color -- left,top,right,bottom define the rectangle -- 'color' is a ptColor object""" - pass - - def getHeight(self): - """Returns the height of the dynamicTextmap""" - pass - - def getImage(self): - """Returns a pyImage associated with the dynamicTextmap""" - pass - - def getWidth(self): - """Returns the width of the dynamicTextmap""" - pass - - def netForce(self,forceFlag): - """Specify whether this object needs to use messages that are forced to the network -- This is to be used if your Python program is running on only one client -Such as a game master, only running on the client that owns a particular object -This only applies when NetPropagate is set to true""" - pass - - def netPropagate(self,propagateFlag): - """Specify whether this object needs to use messages that are sent on the network -- The default is for this to be false.""" - pass - - def purgeImage(self): - """Purge the DynamicTextMap images""" - pass - - def sender(self,sender): - """Set the sender of the message being sent to the DynamicMap""" - pass - - def setClipping(self,clipLeft,clipTop,clipRight,clipBottom): - """Sets the clipping rectangle -- All drawtext will be clipped to this until the -unsetClipping() is called""" - pass - - def setFont(self,facename,size): - """Set the font of the text to be written -- 'facename' is a string with the name of the font -- 'size' is the point size of the font to use""" - pass - - def setJustify(self,justify): - """Sets the justification of the text. (justify is a PtJustify)""" - pass - - def setLineSpacing(self,spacing): - """Sets the line spacing (in pixels)""" - pass - - def setTextColor(self,color, blockRGB=0): - """Set the color of the text to be written -- 'color' is a ptColor object -- 'blockRGB' must be true if you're trying to render onto a transparent or semi-transparent color""" - pass - - def setWrapping(self,wrapWidth,wrapHeight): - """Set where text will be wrapped horizontally and vertically -- All drawtext commands will be wrapped until the -unsetWrapping() is called""" - pass - - def unsetClipping(self): - """Stop the clipping of text""" - pass - - def unsetWrapping(self): - """Stop text wrapping""" - pass - -class ptGUIControl: - """Base class for all GUI controls""" - def __init__(self,controlKey): - """None""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - -class ptGUIControlButton(ptGUIControl): - """Plasma GUI Control Button class""" - def __init__(self,ctrlKey): - """None""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getNotifyType(self): - """Returns this button's notify type. See PtButtonNotifyTypes""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def isButtonDown(self): - """Is the button down? Returns 1 for true otherwise returns 0""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setNotifyType(self,kind): - """Sets this button's notify type. See PtButtonNotifyTypes""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - -class ptGUIControlCheckBox(ptGUIControl): - """Plasma GUI Control Checkbox class""" - def __init__(self,ctrlKey): - """None""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def isChecked(self): - """Is this checkbox checked? Returns 1 for true otherwise returns 0""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setChecked(self,checkedState): - """Sets this checkbox to the 'checkedState'""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - -class ptGUIControlClickMap(ptGUIControl): - """Plasma GUI control Click Map""" - def __init__(self,ctrlKey): - """None""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getLastMouseDragPoint(self): - """Returns the last point the mouse was dragged to""" - pass - - def getLastMousePoint(self): - """Returns the last point the mouse was at""" - pass - - def getLastMouseUpPoint(self): - """Returns the last point the mouse was released at""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - -class ptGUIControlDragBar(ptGUIControl): - """Plasma GUI Control DragBar class""" - def __init__(self,ctrlKey): - """None""" - pass - - def anchor(self): - """Don't allow this dragbar object to be moved by the user. -Drop anchor!""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def isAnchored(self): - """Is this dragbar control anchored? Returns 1 if true otherwise returns 0""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - - def unanchor(self): - """Allow the user to drag this control around the screen. -Raise anchor.""" - pass - -class ptGUIControlDraggable(ptGUIControl): - """Plasma GUI control for something draggable""" - def __init__(self,ctrlKey): - """None""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getLastMousePoint(self): - """Returns the last point we were dragged to""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def stopDragging(self,cancelFlag): - """UNKNOWN""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - -class ptGUIControlDynamicText(ptGUIControl): - """Plasma GUI Control DynamicText class""" - def __init__(self,ctrlKey): - """None""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getMap(self,index): - """Returns a specific ptDynamicText attached to this contol -If there is no map at 'index' then a KeyError exception will be raised""" - pass - - def getNumMaps(self): - """Returns the number of ptDynamicText maps attached""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - -class ptGUIControlEditBox(ptGUIControl): - """Plasma GUI Control Editbox class""" - def __init__(self,ctrlKey): - """None""" - pass - - def clearString(self): - """Clears the editbox.""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def end(self): - """Sets the cursor in the editbox to the after the last character.""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getLastKeyCaptured(self): - """Gets the last capture key""" - pass - - def getLastModifiersCaptured(self): - """Gets the last modifiers flags captured""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getString(self): - """Returns the sting that the user typed in.""" - pass - - def getStringW(self): - """Unicode version of getString.""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def home(self): - """Sets the cursor in the editbox to before the first character.""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setChatMode(self,state): - """Set the Chat mode on this control""" - pass - - def setColor(self,foreColor,backColor): - """Sets the fore and back color of the editbox.""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setLastKeyCapture(self,key, modifiers): - """Set last key captured""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setSelectionColor(self,foreColor,backColor): - """Sets the selection color of the editbox.""" - pass - - def setSpecialCaptureKeyMode(self,state): - """Set the Capture mode on this control""" - pass - - def setString(self,text): - """Pre-sets the editbox to a atring.""" - pass - - def setStringSize(self,size): - """Sets the maximum size of the string that can be inputted by the user.""" - pass - - def setStringW(self,text): - """Unicode version of setString.""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - - def wasEscaped(self): - """If the editbox was escaped then return 1 else return 0""" - pass - -class ptGUIControlValue(ptGUIControl): - """Plasma GUI Control Value class - knobs, spinners""" - def __init__(self,ctrlKey): - """None""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getMax(self): - """Returns the maximum of the control.""" - pass - - def getMin(self): - """Returns the minimum of the control.""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getStep(self): - """Returns the step increment of the control.""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def getValue(self): - """Returns the current value of the control.""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setRange(self,minimum,maximum): - """Sets the minimum and maximum range of the control.""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setStep(self,step): - """Sets the step increment of the control.""" - pass - - def setValue(self,value): - """Sets the current value of the control.""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - -class ptGUIControlKnob(ptGUIControlValue): - """Plasma GUI control for knob""" - def __init__(self,ctrlKey): - """None""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getMax(self): - """Returns the maximum of the control.""" - pass - - def getMin(self): - """Returns the minimum of the control.""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getStep(self): - """Returns the step increment of the control.""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def getValue(self): - """Returns the current value of the control.""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setRange(self,minimum,maximum): - """Sets the minimum and maximum range of the control.""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setStep(self,step): - """Sets the step increment of the control.""" - pass - - def setValue(self,value): - """Sets the current value of the control.""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - -class ptGUIControlListBox(ptGUIControl): - """Plasma GUI Control List Box class""" - def __init__(self,ctrlKey): - """None""" - pass - - def add2StringsWithColors(self,text1,color1,text2,color2,respectAlpha): - """Doesn't work right - DONT USE""" - pass - - def addBranch(self,name,initiallyOpen): - """UNKNOWN""" - pass - - def addBranchW(self,name,initiallyOpen): - """Unicode version of addBranch""" - pass - - def addImage(self,image,respectAlphaFlag): - """Appends an image item to the listbox""" - pass - - def addImageAndSwatchesInBox(self,image,x,y,width,height,respectAlpha,primary,secondary): - """Add the image and color swatches to the list""" - pass - - def addImageInBox(self,image,x,y,width,height,respectAlpha): - """Appends an image item to the listbox, centering within the box dimension.""" - pass - - def addSelection(self,item): - """Adds item to selection list""" - pass - - def addString(self,text): - """Appends a list item 'text' to the listbox.""" - pass - - def addStringInBox(self,text,min_width,min_height): - """Adds a text list item that has a minimum width and height""" - pass - - def addStringW(self,text): - """Unicode version of addString.""" - pass - - def addStringWithColor(self,text,color,inheritAlpha): - """Adds a colored string to the list box""" - pass - - def addStringWithColorWithSize(self,text,color,inheritAlpha,fontsize): - """Adds a text list item with a color and different font size""" - pass - - def allowNoSelect(self): - """Allows the listbox to have no selection""" - pass - - def clearAllElements(self): - """Removes all the items from the listbox, making it empty.""" - pass - - def clickable(self): - """Sets this listbox to be clickable by the user.""" - pass - - def closeBranch(self): - """UNKNOWN""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def disallowNoSelect(self): - """The listbox must always have a selection""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def findString(self,text): - """Finds and returns the index of the item that matches 'text' in the listbox.""" - pass - - def findStringW(self,text): - """Unicode version of findString.""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getBranchList(self): - """get a list of branches in this list (index,isShowingChildren)""" - pass - - def getElement(self,index): - """Get the string of the item at 'index' in the listbox.""" - pass - - def getElementW(self,index): - """Unicode version of getElement.""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getNumElements(self): - """Return the number of items in the listbox.""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getScrollPos(self): - """Returns the current scroll position in the listbox.""" - pass - - def getScrollRange(self): - """Returns the max scroll position""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getSelection(self): - """Returns the currently selected list item in the listbox.""" - pass - - def getSelectionList(self): - """Returns the current selection list""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def lock(self): - """Locks the updates to a listbox, so a number of operations can be performed -NOTE: an unlock() call must be made before the next lock() can be.""" - pass - - def refresh(self): - """Refresh the display of the listbox (after updating contents).""" - pass - - def removeElement(self,index): - """Removes element at 'index' in the listbox.""" - pass - - def removeSelection(self,item): - """Removes item from selection list""" - pass - - def scrollToBegin(self): - """Scrolls the listbox to the beginning of the list""" - pass - - def scrollToEnd(self): - """Scrolls the listbox to the end of the list""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setElement(self,index,text): - """Set a particular item in the listbox to a string.""" - pass - - def setElementW(self,index,text): - """Unicode version of setElement.""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setGlobalSwatchEdgeOffset(self,offset): - """Sets the edge offset of the color swatches""" - pass - - def setGlobalSwatchSize(self,size): - """Sets the size of the color swatches""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setScrollPos(self,pos): - """Sets the scroll position of the listbox to 'pos'""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setSelection(self,selectionIndex): - """Sets the current selection in the listbox.""" - pass - - def setStringJustify(self,index,justify): - """Sets the text justification""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - - def unclickable(self): - """Makes this listbox not clickable by the user. -Useful when just displaying a list that is not really selectable.""" - pass - - def unlock(self): - """Unlocks updates to a listbox and does any saved up changes""" - pass - -class ptGUIControlMultiLineEdit(ptGUIControl): - """Plasma GUI Control Multi-line edit class""" - def __init__(self,ctrlKey): - """None""" - pass - - def clearBuffer(self): - """Clears all text from the multi-line edit control.""" - pass - - def clickable(self): - """Sets this listbox to be clickable by the user.""" - pass - - def deleteChar(self): - """Deletes a character at the current cursor position.""" - pass - - def deleteLinesFromTop(self,numLines): - """Deletes the specified number of lines from the top of the text buffer""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def disableScrollControl(self): - """Disables the scroll control if there is one""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def enableScrollControl(self): - """Enables the scroll control if there is one""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getBufferLimit(self): - """Returns the current buffer limit""" - pass - - def getBufferSize(self): - """Returns the size of the buffer""" - pass - - def getEncodedBuffer(self): - """Returns the encoded buffer in a python buffer object. Do NOT use result with setEncodedBufferW.""" - pass - - def getEncodedBufferW(self): - """Unicode version of getEncodedBuffer. Do NOT use result with setEncodedBuffer.""" - pass - - def getFontSize(self): - """Returns the current default font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getString(self): - """Gets the string of the edit control.""" - pass - - def getStringW(self): - """Unicode version of getString.""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def insertChar(self,c): - """Inserts a character at the current cursor position.""" - pass - - def insertCharW(self,c): - """Unicode version of insertChar.""" - pass - - def insertColor(self,color): - """Inserts an encoded color object at the current cursor position. -'color' is a ptColor object.""" - pass - - def insertString(self,string): - """Inserts a string at the current cursor position.""" - pass - - def insertStringW(self,string): - """Unicode version of insertString""" - pass - - def insertStyle(self,style): - """Inserts an encoded font style at the current cursor position.""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isLocked(self): - """Is the multi-line edit control locked? Returns 1 if true otherwise returns 0""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def lock(self): - """Locks the multi-line edit control so the user cannot make changes.""" - pass - - def moveCursor(self,direction): - """Move the cursor in the specified direction (see PtGUIMultiLineDirection)""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setBufferLimit(self,bufferLimit): - """Sets the buffer max for the editbox""" - pass - - def setEncodedBuffer(self,bufferObject): - """Sets the edit control to the encoded buffer in the python buffer object. Do NOT use with a result from getEncodedBufferW.""" - pass - - def setEncodedBufferW(self,bufferObject): - """Unicode version of setEncodedBuffer. Do NOT use with a result from getEncodedBuffer.""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the default font size for the edit control""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setScrollPosition(self,topLine): - """Sets the what line is the top line.""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setString(self,asciiText): - """Sets the multi-line edit control string.""" - pass - - def setStringW(self,unicodeText): - """Unicode version of setString.""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - - def unclickable(self): - """Makes this listbox not clickable by the user. -Useful when just displaying a list that is not really selectable.""" - pass - - def unlock(self): - """Unlocks the multi-line edit control so that the user can make changes.""" - pass - -class ptGUIControlProgress(ptGUIControlValue): - """Plasma GUI control for progress bar""" - def __init__(self,ctrlKey): - """None""" - pass - - def animateToPercent(self,percent): - """Sets the value of the control and animates to that point.""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getMax(self): - """Returns the maximum of the control.""" - pass - - def getMin(self): - """Returns the minimum of the control.""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getStep(self): - """Returns the step increment of the control.""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def getValue(self): - """Returns the current value of the control.""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setRange(self,minimum,maximum): - """Sets the minimum and maximum range of the control.""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setStep(self,step): - """Sets the step increment of the control.""" - pass - - def setValue(self,value): - """Sets the current value of the control.""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - -class ptGUIControlRadioGroup(ptGUIControl): - """Plasma GUI Control Radio Group class""" - def __init__(self,ctrlKey): - """None""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def getValue(self): - """Returns the current selection of the radio group.""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setValue(self,value): - """Sets the current selection to 'value'""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - -class ptGUIControlTextBox(ptGUIControl): - """Plasma GUI Control Textbox class""" - def __init__(self,ctrlKey): - """None""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the current forecolor""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getString(self): - """Returns the string that the TextBox is set to (in case you forgot)""" - pass - - def getStringJustify(self): - """Returns current justify""" - pass - - def getStringW(self): - """Unicode version of getString""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,color): - """Sets the text backcolor to 'color', which is a ptColor object.""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,size): - """Don't use""" - pass - - def setForeColor(self,color): - """Sets the text forecolor to 'color', which is a ptColor object.""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setString(self,text): - """Sets the textbox string to 'text'""" - pass - - def setStringJustify(self,justify): - """Sets current justify""" - pass - - def setStringW(self,text): - """Unicode version of setString""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - -class ptGUIControlUpDownPair(ptGUIControlValue): - """Plasma GUI control for up/down pair""" - def __init__(self,ctrlKey): - """None""" - pass - - def disable(self): - """Disables this GUI control""" - pass - - def enable(self,flag=1): - """Enables this GUI control""" - pass - - def focus(self): - """Gets focus for this GUI control""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns the ptKey for this GUI control""" - pass - - def getMax(self): - """Returns the maximum of the control.""" - pass - - def getMin(self): - """Returns the minimum of the control.""" - pass - - def getObjectCenter(self): - """Returns ptPoint3 of the center of the GUI control object""" - pass - - def getOwnerDialog(self): - """Returns a ptGUIDialog of the dialog that owns this GUI control""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getStep(self): - """Returns the step increment of the control.""" - pass - - def getTagID(self): - """Returns the Tag ID for this GUI control""" - pass - - def getValue(self): - """Returns the current value of the control.""" - pass - - def hide(self): - """Hides this GUI control""" - pass - - def isEnabled(self): - """Returns whether this GUI control is enabled""" - pass - - def isFocused(self): - """Returns whether this GUI control has focus""" - pass - - def isInteresting(self): - """Returns whether this GUI control is interesting at the moment""" - pass - - def isVisible(self): - """Returns whether this GUI control is visible""" - pass - - def refresh(self): - """UNKNOWN""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setFocus(self,state): - """Sets the state of the focus of this GUI control""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setNotifyOnInteresting(self,state): - """Sets whether this control should send interesting events or not""" - pass - - def setObjectCenter(self,point): - """Sets the GUI controls object center to 'point'""" - pass - - def setRange(self,minimum,maximum): - """Sets the minimum and maximum range of the control.""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def setStep(self,step): - """Sets the step increment of the control.""" - pass - - def setValue(self,value): - """Sets the current value of the control.""" - pass - - def setVisible(self,state): - """Sets the state of visibility of this GUI control""" - pass - - def show(self): - """Shows this GUI control""" - pass - - def unFocus(self): - """Releases focus for this GUI control""" - pass - -class ptGUIDialog: - """Plasma GUI dialog class""" - def __init__(self,dialogKey): - """None""" - pass - - def disable(self): - """Disables this dialog""" - pass - - def enable(self,enableFlag=1): - """Enable this dialog""" - pass - - def getBackColor(self): - """Returns the back color as a ptColor object""" - pass - - def getBackSelectColor(self): - """Returns the select back color as a ptColor object""" - pass - - def getControlFromIndex(self,index): - """Returns the ptKey of the control with the specified index (not tag ID!)""" - pass - - def getControlFromTag(self,tagID): - """Returns the ptKey of the control with the specified tag ID""" - pass - - def getFontSize(self): - """Returns the font size""" - pass - - def getForeColor(self): - """Returns the fore color as a ptColor object""" - pass - - def getKey(self): - """Returns this dialog's ptKey""" - pass - - def getName(self): - """Returns the dialog's name""" - pass - - def getNumControls(self): - """Returns the number of controls in this dialog""" - pass - - def getSelectColor(self): - """Returns the select color as a ptColor object""" - pass - - def getTagID(self): - """Returns this dialog's tag ID""" - pass - - def getVersion(self): - """UNKNOWN""" - pass - - def hide(self): - """Hides the dialog""" - pass - - def isEnabled(self): - """Is this dialog currently enabled?""" - pass - - def noFocus(self): - """Makes sure no control has input focus""" - pass - - def refreshAllControls(self): - """Tells the dialog to redraw all its controls""" - pass - - def setBackColor(self,red,green,blue,alpha): - """Sets the back color, -1 means don't change""" - pass - - def setBackSelectColor(self,red,green,blue,alpha): - """Sets the select back color, -1 means don't change""" - pass - - def setFocus(self,ctrlKey): - """Sets the control that has input focus""" - pass - - def setFontSize(self,fontSize): - """Sets the font size""" - pass - - def setForeColor(self,red,green,blue,alpha): - """Sets the fore color, -1 means don't change""" - pass - - def setSelectColor(self,red,green,blue,alpha): - """Sets the select color, -1 means don't change""" - pass - - def show(self): - """Shows the dialog""" - pass - - def showNoReset(self): - """Show dialog without resetting clickables""" - pass - - def updateAllBounds(self): - """Tells the dialog to recompute all the bounds for its controls""" - pass - -class ptGUIPopUpMenu: - """Takes three diferent argument lists: -gckey -name,screenOriginX,screenOriginY -name,parent,screenOriginX,screenOriginY""" - def __init__(self,arg1,arg2=None,arg3=None,arg4=None): - """None""" - pass - - def addConsoleCmdItem(self,name,consoleCmd): - """Adds a new item to the menu that fires a console command""" - pass - - def addConsoleCmdItemW(self,name,consoleCmd): - """Unicode version of addConsoleCmdItem""" - pass - - def addNotifyItem(self,name): - """Adds a new item ot the mneu""" - pass - - def addNotifyItemW(self,name): - """Unicode version of addNotifyItem""" - pass - - def addSubMenuItem(self,name,subMenu): - """Adds a submenu to this menu""" - pass - - def addSubMenuItemW(self,name,subMenu): - """Unicode version of addSubMenuItem""" - pass - - def disable(self): - """Disables this menu""" - pass - - def enable(self,state=1): - """Enables/disables this menu""" - pass - - def getBackColor(self): - """Returns the background color""" - pass - - def getBackSelectColor(self): - """Returns the background selection color""" - pass - - def getForeColor(self): - """Returns the foreground color""" - pass - - def getKey(self): - """Returns this menu's key""" - pass - - def getName(self): - """Returns this menu's name""" - pass - - def getSelectColor(self): - """Returns the selection color""" - pass - - def getTagID(self): - """Returns this menu's tag id""" - pass - - def getVersion(self): - """UNKNOWN""" - pass - - def hide(self): - """Hides this menu""" - pass - - def isEnabled(self): - """Returns whether this menu is enabled or not""" - pass - - def setBackColor(self,r,g,b,a): - """Sets the background color""" - pass - - def setBackSelectColor(self,r,g,b,a): - """Sets the selection background color""" - pass - - def setForeColor(self,r,g,b,a): - """Sets the foreground color""" - pass - - def setSelectColor(self,r,g,b,a): - """Sets the selection color""" - pass - - def show(self): - """Shows this menu""" - pass - -class ptGUISkin: - """Plasma GUI Skin object""" - def __init__(self,key): - """None""" - pass - - def getKey(self): - """Returns this object's ptKey""" - pass - -class ptGameScore: - """Game score manager""" - def __init__(self): - """None""" - pass - - def addPoints(self,numPoints): - """Adds points to the score""" - pass - - def getCreatedTime(self): - """Returns a the score creation time.""" - pass - - def getGameName(self): - """Returns a the score game name.""" - pass - - def getGameType(self): - """Returns a the score game type.""" - pass - - def getOwnerID(self): - """Returns a the score owner id.""" - pass - - def getScoreID(self): - """Returns the score id.""" - pass - - def getValue(self): - """Returns a the score owner value.""" - pass - - def setPoints(self,numPoints): - """Sets the number of points in the score -Don't use to add/remove points, use only to reset values!""" - pass - - def transferPoints(self,dest, numPoints): - """Transfers points from one score to another""" - pass - -class ptGrassShader: - """Plasma Grass Shader class""" - def __init__(self,key): - """None""" - pass - - def getWaveDirection(self,waveNum): - """Gets the wave waveNum's direction as a tuple of x,y. waveNum must be between 0 and plGrassShaderMod::kNumWaves-1 (currently 3) inclusive""" - pass - - def getWaveDistortion(self,waveNum): - """Gets the wave waveNum's distortion as a tuple of x,y,z. waveNum must be between 0 and plGrassShaderMod::kNumWaves-1 (currently 3) inclusive""" - pass - - def getWaveSpeed(self,waveNum): - """Gets the wave waveNum's speed as a float. waveNum must be between 0 and plGrassShaderMod::kNumWaves-1 (currently 3) inclusive""" - pass - - def resetWaves(self): - """Resets wave data to 0""" - pass - - def setWaveDirection(self,waveNum, direction): - """Sets the wave waveNum's direction as a tuple of x,y. waveNum must be between 0 and plGrassShaderMod::kNumWaves-1 (currently 3) inclusive""" - pass - - def setWaveDistortion(self,waveNum, distortion): - """Sets the wave waveNum's distortion as a tuple of x,y,z. waveNum must be between 0 and plGrassShaderMod::kNumWaves-1 (currently 3) inclusive""" - pass - - def setWaveSpeed(self,waveNum, speed): - """Sets the wave waveNum's speed as a float. waveNum must be between 0 and plGrassShaderMod::kNumWaves-1 (currently 3) inclusive""" - pass - -class ptImage: - """Plasma image class""" - def __init__(self,imgKey): - """None""" - pass - - def getColorLoc(self,color): - """Returns the ptPoint3 where the specified color is located""" - pass - - def getHeight(self): - """Returns the height of the image""" - pass - - def getPixelColor(self,x,y): - """Returns the ptColor at the specified location (float from 0 to 1)""" - pass - - def getWidth(self): - """Returns the width of the image""" - pass - - def saveAsJPEG(self,filename,quality=75): - """Saves this image to disk as a JPEG file""" - pass - -class ptInputInterface: - """Plasma input interface class""" - def __init__(self): - """None""" - pass - - def popTelescope(self): - """pops off the telescope interface and gos back to previous interface""" - pass - - def pushTelescope(self): - """pushes on the telescope interface""" - pass - -class ptKey: - """Plasma Key class""" - def __init__(self): - """None""" - pass - - def disable(self): - """Sends a disable message to whatever this ptKey is pointing to""" - pass - - def enable(self): - """Sends an enable message to whatever this ptKey is pointing to""" - pass - - def getName(self): - """Get the name of the object that this ptKey is pointing to""" - pass - - def getParentKey(self): - """This will return a ptKey object that is the parent of this modifer -However, if the parent is not a modifier or not loaded, then None is returned.""" - pass - - def getSceneObject(self): - """This will return a ptSceneobject object that is associated with this ptKey -However, if this ptKey is _not_ a sceneobject, then unpredicatable results will ensue""" - pass - - def isAttachedToClone(self): - """Returns whether the python file mod is attached to a clone""" - pass - - def netForce(self,forceFlag): - """Specify whether this object needs to use messages that are forced to the network -- This is to be used if your Python program is running on only one client -Such as a game master, only running on the client that owns a particular object""" - pass - -class ptKeyMap: - """Accessor class to the Key Mapping functions""" - def __init__(self): - """None""" - pass - - def bindKey(self): - """Params key1,key2,action -Bind keys to an action""" - pass - - def bindKeyToConsoleCommand(self,keyStr1, command): - """Binds key to console command""" - pass - - def convertCharToControlCode(self,controlCodeString): - """Convert string version of control code to number""" - pass - - def convertCharToFlags(self,charString): - """Convert char string to flags""" - pass - - def convertCharToVKey(self,charString): - """Convert char string to virtual key""" - pass - - def convertControlCodeToString(self): - """Params controlCode -Convert control code to character string""" - pass - - def convertVKeyToChar(self,virtualKey,flags): - """Convert virtual key and shift flags to string""" - pass - - def getBindingFlags1(self): - """Params controlCode -Returns modifier flags for controlCode""" - pass - - def getBindingFlags2(self): - """Params controlCode -Returns modifier flags for controlCode""" - pass - - def getBindingFlagsConsole(self,command): - """Returns modifier flags for the console command mapping""" - pass - - def getBindingKey1(self): - """Params controlCode -Returns key code for controlCode""" - pass - - def getBindingKey2(self): - """Params controlCode -Returns key code for controlCode""" - pass - - def getBindingKeyConsole(self,command): - """Returns key for console command mapping""" - pass - - def writeKeyMap(self): - """Forces write of the keymap file""" - pass - -class ptMarkerMgr: - """Marker manager accessor class""" - def __init__(self): - """None""" - pass - - def addMarker(self,x, y, z, id, justCreated): - """Add a marker in the specified location with the specified id""" - pass - - def areLocalMarkersShowing(self): - """Returns true if we are showing the markers on this local machine""" - pass - - def captureQuestMarker(self,id, captured): - """Sets a marker as captured or not""" - pass - - def captureTeamMarker(self,id, team): - """Sets a marker as captured by the specified team (0 = not captured)""" - pass - - def clearSelectedMarker(self): - """Unselects the selected marker""" - pass - - def getMarkersRespawn(self): - """Returns whether markers respawn after being captured, or not""" - pass - - def getSelectedMarker(self): - """Returns the id of the selected marker""" - pass - - def hideMarkersLocal(self): - """Hides the markers on your machine, so you can no longer see where they are""" - pass - - def removeAllMarkers(self): - """Removes all markers""" - pass - - def removeMarker(self,id): - """Removes the specified marker from the game""" - pass - - def setMarkersRespawn(self,respawn): - """Sets whether markers respawn after being captured, or not""" - pass - - def setSelectedMarker(self,id): - """Sets the selected marker to the one with the specified id""" - pass - - def showMarkersLocal(self): - """Shows the markers on your machine, so you can see where they are""" - pass - -class ptMatrix44: - """Plasma Matrix44 class""" - def __init__(self): - """None""" - pass - - def copy(self): - """Copies the matrix and returns the copy""" - pass - - def getAdjoint(self,adjointMat): - """Returns the adjoint of the matrix""" - pass - - def getData(self): - """Returns the matrix in tuple form""" - pass - - def getDeterminant(self): - """Get the matrix's determinant""" - pass - - def getInverse(self,inverseMat): - """Returns the inverse of the matrix""" - pass - - def getParity(self): - """Get the parity of the matrix""" - pass - - def getTranslate(self,vector): - """Returns the translate vector of the matrix (and sets vector to it as well)""" - pass - - def getTranspose(self,transposeMat): - """Returns the transpose of the matrix""" - pass - - def make(self,fromPt, atPt, upVec): - """Creates the matrix from from and at points, and the up vector""" - pass - - def makeRotateMat(self,axis,radians): - """Makes the matrix a rotation matrix""" - pass - - def makeScaleMat(self,scale): - """Makes the matrix a scaling matrix""" - pass - - def makeTranslateMat(self,trans): - """Makes the matrix a translation matrix""" - pass - - def makeUpPreserving(self,fromPt, atPt, upVec): - """Creates the matrix from from and at points, and the up vector (perserving the up vector)""" - pass - - def reset(self): - """Reset the matrix to identity""" - pass - - def right(self): - """Returns the right vector of the matrix""" - pass - - def rotate(self,axis,radians): - """Rotates the matrix by radians around the axis""" - pass - - def scale(self,scale): - """Scales the matrix by the vector""" - pass - - def setData(self,mat): - """Sets the matrix using tuples""" - pass - - def translate(self,vector): - """Translates the matrix by the vector""" - pass - - def up(self): - """Returns the up vector of the matrix""" - pass - - def view(self): - """Returns the view vector of the matrix""" - pass - -class ptMoviePlayer: - """Accessor class to play in the MoviePlayer""" - def __init__(self,movieName,selfKey): - """None""" - pass - - def pause(self): - """Pauses the movie""" - pass - - def play(self): - """Plays the movie""" - pass - - def playPaused(self): - """Plays movie, but pauses at first frame""" - pass - - def resume(self): - """Resumes movie after pausing""" - pass - - def setCenter(self,x,y): - """Sets the center of the movie""" - pass - - def setColor(self,color): - """Sets the color of the movie""" - pass - - def setOpacity(self,opacity): - """Sets the opacity of the movie""" - pass - - def setScale(self,width,height): - """Sets the width and height scale of the movie""" - pass - - def setVolume(self,volume): - """Set the volume of the movie""" - pass - - def stop(self): - """Stops the movie""" - pass - -class ptNetLinkingMgr: - """Constructor to get access to the net link manager""" - def __init__(self): - """None""" - pass - - def getCurrAgeLink(self): - """Get the ptAgeLinkStruct for the current age""" - pass - - def getPrevAgeLink(self): - """Get the ptAgeLinkStruct for the previous age""" - pass - - def isEnabled(self): - """True if linking is enabled.""" - pass - - def linkPlayerHere(self,pid): - """link player(pid) to where I am""" - pass - - def linkPlayerToAge(self,ageLink,pid): - """Link player(pid) to ageLink""" - pass - - def linkToAge(self,ageLink): - """Links to ageLink (ptAgeLinkStruct)""" - pass - - def linkToMyNeighborhoodAge(self): - """Link to my Neighborhood Age""" - pass - - def linkToMyPersonalAge(self): - """Link to my Personal Age""" - pass - - def linkToMyPersonalAgeWithYeeshaBook(self): - """Link to my Personal Age with the YeeshaBook""" - pass - - def linkToPlayersAge(self,pid): - """Link me to where player(pid) is""" - pass - - def setEnabled(self,enable): - """Enable/Disable linking.""" - pass - -class ptNotify: - """Creates a Notify message -- selfKey is ptKey of your PythonFile modifier""" - def __init__(self,selfKey): - """None""" - pass - - def addActivateEvent(self,activeFlag,activateFlag): - """Add an activate event record to the notify message""" - pass - - def addCallbackEvent(self,eventNumber): - """Add a callback event record to the notify message""" - pass - - def addCollisionEvent(self,enterFlag,hitterKey,hitteeKey): - """Add a collision event record to the Notify message""" - pass - - def addContainerEvent(self,enteringFlag,containerKey,containedKey): - """Add a container event record to the notify message""" - pass - - def addControlKeyEvent(self,keynumber,downFlag): - """Add a keyboard event record to the Notify message""" - pass - - def addFacingEvent(self,enabledFlag,facerKey, faceeKey, dotProduct): - """Add a facing event record to the Notify message""" - pass - - def addPickEvent(self,enabledFlag,pickerKey,pickeeKey,hitPoint): - """Add a pick event record to the Notify message""" - pass - - def addReceiver(self,key): - """Add a receivers key to receive this Notify message""" - pass - - def addResponderState(self,state): - """Add a responder state event record to the notify message""" - pass - - def addVarKey(self,name,key): - """Add a ptKey variable event record to the Notify message -This event record is used to pass a ptKey variable to another python program""" - pass - - def addVarNumber(self,name,number): - """Add a number variable event record to the Notify message -This event record is used to pass a number variable to another python program""" - pass - - def clearReceivers(self): - """Remove all the receivers that this Notify message has -- receivers are automatically added if from a ptAttribActivator""" - pass - - def netForce(self,forceFlag): - """Specify whether this object needs to use messages that are forced to the network -- This is to be used if your Python program is running on only one client -Such as a game master, only running on the client that owns a particular object""" - pass - - def netPropagate(self,netFlag): - """Sets the net propagate flag - default to set""" - pass - - def send(self): - """Send the notify message""" - pass - - def setActivate(self,state): - """Set the activate state to true(1.0) or false(0.0)""" - pass - - def setType(self,type): - """Sets the message type""" - pass - -class ptParticle: - """Plasma particle system class""" - def __init__(self): - """None""" - pass - - def netForce(self,forceFlag): - """Specify whether this object needs to use messages that are forced to the network -- This is to be used if your Python program is running on only one client -Such as a game master, only running on the client that owns a particular object""" - pass - - def setGeneratorLife(self,value): - """NEEDS DOCSTRING""" - pass - - def setHeightSize(self,value): - """NEEDS DOCSTRING""" - pass - - def setInitPitchRange(self,value): - """NEEDS DOCSTRING""" - pass - - def setInitYawRange(self,value): - """NEEDS DOCSTRING""" - pass - - def setParticleLifeMaximum(self,value): - """NEEDS DOCSTRING""" - pass - - def setParticleLifeMinimum(self,value): - """NEEDS DOCSTRING""" - pass - - def setParticlesPerSecond(self,value): - """NEEDS DOCSTRING""" - pass - - def setScaleMaximum(self,value): - """NEEDS DOCSTRING""" - pass - - def setScaleMinimum(self,value): - """NEEDS DOCSTRING""" - pass - - def setVelocityMaximum(self,value): - """NEEDS DOCSTRING""" - pass - - def setVelocityMinimum(self,value): - """NEEDS DOCSTRING""" - pass - - def setWidthSize(self,value): - """NEEDS DOCSTRING""" - pass - -class ptPhysics: - """Plasma physics class""" - def __init__(self): - """None""" - pass - - def angularImpulse(self,impulseVector): - """Add the given vector (representing a rotation axis and magnitude) to -the attached sceneobject's velocity""" - pass - - def damp(self,damp): - """Reduce all velocities on the object (0 = all stop, 1 = no effect)""" - pass - - def disable(self): - """Disables physics on the sceneobject attached""" - pass - - def disableCollision(self): - """Disables collision detection on the attached sceneobject""" - pass - - def enable(self,state=1): - """Sets the physics enable state for the sceneobject attached""" - pass - - def enableCollision(self): - """Enables collision detection on the attached sceneobject""" - pass - - def force(self,forceVector): - """Applies the specified force to the attached sceneobject""" - pass - - def forceWithOffset(self,forceVector,offsetPt): - """Applies the specified offsetted force to the attached sceneobject""" - pass - - def impulse(self,impulseVector): - """Adds the given vector to the attached sceneobject's velocity""" - pass - - def impulseWithOffset(self,impulseVector,offsetPt): - """Adds the given vector to the attached sceneobject's velocity -with the specified offset""" - pass - - def move(self,direction,distance): - """Moves the attached sceneobject the specified distance in the specified direction""" - pass - - def netForce(self,forceFlag): - """Specify whether this object needs to use messages that are forced to the network -- This is to be used if your Python program is running on only one client -Such as a game master, only running on the client that owns a particular object""" - pass - - def rotate(self,radians,axis): - """Rotates the attached sceneobject the specified radians around the specified axis""" - pass - - def shiftMass(self,offsetVector): - """Shifts the attached sceneobject's center to mass in the specified direction and distance""" - pass - - def suppress(self,doSuppress): - """Completely remove the physical, but keep it around so it -can be added back later.""" - pass - - def torque(self,torqueVector): - """Applies the specified torque to the attached sceneobject""" - pass - - def warp(self,position): - """Warps the sceneobject to a specified location. -'position' can be a ptPoint3 or a ptMatrix44""" - pass - - def warpObj(self,objkey): - """Warps the sceneobject to match the location and orientation of the specified object""" - pass - -class ptPlayer: - """And optionally __init__(name,playerID)""" - def __init__(self,avkey,name,playerID,distanceSq): - """None""" - pass - - def getDistanceSq(self): - """Returns the distance to remote player from local player""" - pass - - def getPlayerID(self): - """Returns the unique player ID""" - pass - - def getPlayerName(self): - """Returns the name of the player""" - pass - - def isCCR(self): - """Is this player a CCR?""" - pass - - def isServer(self): - """Is this player a server?""" - pass - -class ptPoint3: - """Plasma Point class""" - def __init__(self,x=0, y=0, z=0): - """None""" - pass - - def copy(self): - """Returns a copy of the point in another ptPoint3 object""" - pass - - def distance(self,other): - """Computes the distance from this point to 'other' point""" - pass - - def distanceSq(self,other): - """Computes the distance squared from this point to 'other' point -- this function is faster than distance(other)""" - pass - - def getX(self): - """Returns the 'x' component of the point""" - pass - - def getY(self): - """Returns the 'y' component of the point""" - pass - - def getZ(self): - """Returns the 'z' component of the point""" - pass - - def setX(self,x): - """Sets the 'x' component of the point""" - pass - - def setY(self,y): - """Sets the 'y' component of the point""" - pass - - def setZ(self,z): - """Sets the 'z' component of the point""" - pass - - def zero(self): - """Sets the 'x','y' and the 'z' component to zero""" - pass - -class ptSDL: - """SDL accessor""" - def __init__(self): - """None""" - pass - - def sendToClients(self,key): - """Sets it so changes to this key are sent to the -server AND the clients. (Normally it just goes -to the server.)""" - pass - - def setDefault(self,key,value): - """Like setitem, but doesn't broadcast over the net. -Only use for setting defaults that everyone will -already know (from reading it off disk)""" - pass - - def setFlags(self,name,sendImmediate,skipOwnershipCheck): - """Sets the flags for a variable in this SDL""" - pass - - def setIndex(self,key,idx,value): - """Sets the value at a specific index in the tuple, -so you don't have to pass the whole thing in""" - pass - - def setIndexNow(self,key,idx,value): - """Same as setIndex but sends immediately""" - pass - - def setNotify(self,selfkey,key,tolerance): - """Sets the OnSDLNotify to be called when 'key' -SDL variable changes by 'tolerance' (if number)""" - pass - - def setTagString(self,name,tag): - """Sets the tag string for a variable""" - pass - -class ptSDLStateDataRecord: - """Basic SDL state data record class""" - def __init__(self): - """None""" - pass - - def findVar(self,name): - """Finds and returns the specified ptSimpleStateVariable""" - pass - - def getName(self): - """Returns our record's name""" - pass - - def getVarList(self): - """Returns the names of the vars we hold as a list of strings""" - pass - - def setFromDefaults(self,timeStampNow): - """Sets all our vars to their defaults""" - pass - -class ptSceneobject: - """Plasma Sceneobject class""" - def __init__(self,objKey, selfKey): - """None""" - pass - - def addKey(self,key): - """Mostly used internally. -Add another sceneobject ptKey""" - pass - - def animate(self): - """If we can animate, start animating""" - pass - - def avatarVelocity(self): - """Returns the velocity of the first attached avatar scene object""" - pass - - def fastForwardAttachedResponder(self,state): - """Fast forward the attached responder to the specified state""" - pass - - def findObject(self,name): - """Find a particular object in just the sceneobjects that are attached""" - pass - - def getKey(self): - """Get the ptKey of this sceneobject -If there are more then one attached, get the first one""" - pass - - def getLocalToParent(self): - """Returns ptMatrix44 of the local to parent transform for this sceneobject -- If there is more than one sceneobject attached, returns just the first one""" - pass - - def getLocalToWorld(self): - """Returns ptMatrix44 of the local to world transform for this sceneobject -- If there is more than one sceneobject attached, returns just the first one""" - pass - - def getName(self): - """Returns the name of the sceneobject (Max name) -- If there are more than one sceneobject attached, return just the first one""" - pass - - def getParentToLocal(self): - """Returns ptMatrix44 of the parent to local transform for this sceneobject -- If there is more than one sceneobject attached, returns just the first one""" - pass - - def getPythonMods(self): - """Returns list of ptKeys of the python modifiers attached to this sceneobject""" - pass - - def getResponderState(self): - """Return the responder state (if we are a responder)""" - pass - - def getResponders(self): - """Returns list of ptKeys of the responders attached to this sceneobject""" - pass - - def getSoundIndex(self,sndComponentName): - """Get the index of the requested sound component""" - pass - - def getWorldToLocal(self): - """Returns ptMatrix44 of the world to local transform for this sceneobject -- If there is more than one sceneobject attached, returns just the first one""" - pass - - def isAvatar(self): - """Returns true if the scene object is an avatar""" - pass - - def isHuman(self): - """Returns true if the scene object is a human avatar""" - pass - - def isLocallyOwned(self): - """Returns true(1) if this object is locally owned by this client -or returns false(0) if it is not or don't know""" - pass - - def netForce(self,forceFlag): - """Specify whether this object needs to use messages that are forced to the network -- This is to be used if your Python program is running on only one client -Such as a game master, only running on the client that owns a particular object -- Setting the netForce flag on a sceneobject will also set the netForce flag on -its draw, physics, avatar, particle objects""" - pass - - def playAnimNamed(self,animName): - """Play the attached named animation""" - pass - - def popCamera(self,avKey): - """Pop the camera stack and go back to the previous camera""" - pass - - def popCutsceneCamera(self,avKey): - """Pop the camera stack and go back to previous camera.""" - pass - - def position(self): - """Returns the scene object's current position""" - pass - - def pushCamera(self,avKey): - """Switch to this object (if it is a camera)""" - pass - - def pushCameraCut(self,avKey): - """Switch to this object, cutting the view (if it is a camera)""" - pass - - def pushCutsceneCamera(self,cutFlag,avKey): - """Switch to this object (assuming that it is actually a camera)""" - pass - - def rewindAnimNamed(self,animName): - """Rewind the attached named animation""" - pass - - def right(self): - """Returns the scene object's current right vector""" - pass - - def runAttachedResponder(self,state): - """Run the attached responder to the specified state""" - pass - - def setSoundFilename(self,index, filename, isCompressed): - """Sets the sound attached to this sceneobject to use the specified sound file.""" - pass - - def setTransform(self,local2world,world2local): - """Set our current transforms""" - pass - - def stopAnimNamed(self,animName): - """Stop the attached named animation""" - pass - - def up(self): - """Returns the scene object's current up vector""" - pass - - def view(self): - """Returns the scene object's current view vector""" - pass - - def volumeSensorIgnoreExtraEnters(self,ignore): - """Tells the volume sensor attached to this object to ignore extra enters (default), or not (hack for garrison).""" - pass - -class ptScoreMgr: - """Game score manager""" - def __init__(self): - """None""" - pass - - def createGlobalScore(self,gameName, gameType, value): - """Creates a score and returns it""" - pass - - def createNeighborhoodScore(self,gameName, gameType, value): - """Creates a score and returns it""" - pass - - def createPlayerScore(self,gameName, gameType, value): - """Creates a score and returns it""" - pass - - def deleteScore(self,scoreId): - """Deletes the specified score""" - pass - - def getGlobalScores(self,gameName): - """Returns a list of scores associated with the specified game.""" - pass - - def getNeighborhoodScores(self,gameName): - """Returns a list of scores associated with the specified game.""" - pass - - def getPlayerScores(self,gameName): - """Returns a list of scores associated with the specified game.""" - pass - - def getRankList(self,ownerInfoId, scoreGroup, parentFolderId, gameName, timePeriod, numResults, pageNumber, sortDesc): - """Returns a list of scores and rank""" - pass - -class ptSimpleStateVariable: - """Basic SDL state data record class""" - def __init__(self): - """None""" - pass - - def getBool(self,idx=0): - """Returns a boolean variable's value""" - pass - - def getByte(self,idx=0): - """Returns a byte variable's value""" - pass - - def getDefault(self): - """Returns the variable's default""" - pass - - def getDisplayOptions(self): - """Returns the variable's display options""" - pass - - def getDouble(self,idx=0): - """Returns a double variable's value""" - pass - - def getFloat(self,idx=0): - """Returns a float variable's value""" - pass - - def getInt(self,idx=0): - """Returns an int variable's value""" - pass - - def getShort(self,idx=0): - """Returns a short variable's value""" - pass - - def getString(self,idx=0): - """Returns a string variable's value""" - pass - - def getType(self): - """Returns the variable's type""" - pass - - def isAlwaysNew(self): - """Is this variable always new?""" - pass - - def isInternal(self): - """Is this an internal variable?""" - pass - - def setBool(self,val,idx=0): - """Sets a boolean variable's value""" - pass - - def setByte(self,val,idx=0): - """Sets a byte variable's value""" - pass - - def setDouble(self,val,idx=0): - """Sets a double variable's value""" - pass - - def setFloat(self,val,idx=0): - """Sets a float variable's value""" - pass - - def setInt(self,val,idx=0): - """Sets an int variable's value""" - pass - - def setShort(self,val,idx=0): - """Sets a short variable's value""" - pass - - def setString(self,val,idx=0): - """Sets a string variable's value""" - pass - -class ptSpawnPointInfo: - """Class to hold spawn point data""" - def __init__(self,title=None,spawnPt=None): - """None""" - pass - - def getCameraStack(self): - """Returns the camera stack for this spawnpoint as a string""" - pass - - def getName(self): - """Returns the spawnpoint's name""" - pass - - def getTitle(self): - """Returns the spawnpoint's title""" - pass - - def setCameraStack(self,stack): - """Sets the spawnpoint's camera stack (as a string)""" - pass - - def setName(self,name): - """Sets the spawnpoint's name""" - pass - - def setTitle(self,title): - """Sets the spawnpoint's title""" - pass - -class ptSpawnPointInfoRef: - """Class to hold spawn point data""" - def __init__(self): - """None""" - pass - - def getCameraStack(self): - """Returns the camera stack for this spawnpoint as a string""" - pass - - def getName(self): - """Returns the spawnpoint's name""" - pass - - def getTitle(self): - """Returns the spawnpoint's title""" - pass - - def setCameraStack(self,stack): - """Sets the spawnpoint's camera stack (as a string)""" - pass - - def setName(self,name): - """Sets the spawnpoint's name""" - pass - - def setTitle(self,title): - """Sets the spawnpoint's title""" - pass - -class ptStatusLog: - """A status log class""" - def __init__(self): - """None""" - pass - - def close(self): - """Close the status log file""" - pass - - def isOpen(self): - """Returns whether the status log is currently opened""" - pass - - def open(self,logName,numLines,flags): - """Open a status log for writing to -'logname' is the name of the log file (example: special.log) -'numLines' is the number of lines to display on debug screen -'flags' is a PlasmaConstants.PtStatusLogFlags""" - pass - - def write(self,text,color=None): - """If the status log is open, write 'text' to log -'color' is the display color in debug screen""" - pass - -class ptStream: - """A basic stream class""" - def __init__(self): - """None""" - pass - - def close(self): - """Close the status log file""" - pass - - def isOpen(self): - """Returns whether the stream file is currently opened""" - pass - - def open(self,fileName,flags): - """Open a stream file for reading or writing""" - pass - - def readlines(self): - """Reads a list of strings from the file""" - pass - - def writelines(self,lines): - """Write a list of strings to the file""" - pass - -class ptSwimCurrentInterface: - """Creates a new ptSwimCurrentInterface""" - def __init__(self,key): - """None""" - pass - - def disable(self): - """UNKNOWN""" - pass - - def enable(self): - """UNKNOWN""" - pass - -class ptVault: - """Accessor class to the player's vault""" - def __init__(self): - """None""" - pass - - def addChronicleEntry(self,entryName,type,string): - """Adds an entry to the player's chronicle with a value of 'string'.""" - pass - - def amAgeCzar(self,ageInfo): - """Are we the czar (WTH is this?) of the specified age?""" - pass - - def amAgeOwner(self,ageInfo): - """Are we the owner of the specified age?""" - pass - - def amCzarOfCurrentAge(self): - """Are we the czar (WTH is this?) of the current age?""" - pass - - def amOwnerOfCurrentAge(self): - """Are we the owner of the current age?""" - pass - - def createNeighborhood(self): - """Creates a new neighborhood""" - pass - - def findChronicleEntry(self,entryName): - """Returns a ptVaultNode of type kNodeTypeChronicle of the current player's chronicle entry by entryName.""" - pass - - def findNode(self,templateNode): - """Find the node matching the template""" - pass - - def getAgeJournalsFolder(self): - """Returns a ptVaultFolderNode of the current player's age journals folder.""" - pass - - def getAgesICanVisitFolder(self): - """Returns a ptVaultFolderNode of ages I can visit""" - pass - - def getAgesIOwnFolder(self): - """Returns a ptVaultFolderNode of ages that I own""" - pass - - def getAvatarClosetFolder(self): - """Do not use. -Returns a ptVaultFolderNode of the avatars outfit in their closet.""" - pass - - def getAvatarOutfitFolder(self): - """Do not use. -Returns a ptVaultFolderNode of the avatars outfit.""" - pass - - def getBuddyListFolder(self): - """Returns a ptVaultPlayerInfoListNode of the current player's buddy list folder.""" - pass - - def getChronicleFolder(self): - """Returns a ptVaultFolderNode of the current player's chronicle folder.""" - pass - - def getGlobalInbox(self): - """Returns a ptVaultFolderNode of the global inbox folder.""" - pass - - def getIgnoreListFolder(self): - """Returns a ptVaultPlayerInfoListNode of the current player's ignore list folder.""" - pass - - def getInbox(self): - """Returns a ptVaultFolderNode of the current player's inbox folder.""" - pass - - def getInviteFolder(self): - """Returns a ptVaultFolderNode of invites""" - pass - - def getKIUsage(self): - """Returns a tuple with usage statistics of the KI (# of pics, # of text notes, # of marker games)""" - pass - - def getLinkToCity(self): - """Returns a ptVaultAgeLinkNode that will go to the city""" - pass - - def getLinkToMyNeighborhood(self): - """Returns a ptVaultAgeLinkNode that will go to my neighborhood""" - pass - - def getOwnedAgeLink(self,ageInfo): - """Returns a ptVaultAgeLinkNode to my owned age(ageInfo)""" - pass - - def getPeopleIKnowAboutFolder(self): - """Returns a ptVaultPlayerInfoListNode of the current player's people I know about (Recent) list folder.""" - pass - - def getPlayerInfo(self): - """Returns a ptVaultNode of type kNodeTypePlayerInfo of the current player""" - pass - - def getPsnlAgeSDL(self): - """Returns the personal age SDL""" - pass - - def getVisitAgeLink(self,ageInfo): - """Returns a ptVaultAgeLinkNode for a visitor to age(ageInfo)""" - pass - - def inMyNeighborhoodAge(self): - """Are we in the player's neighborhood age?""" - pass - - def inMyPersonalAge(self): - """Are we in the player's personal age?""" - pass - - def invitePlayerToAge(self,link,playerID): - """Sends an invitation to visit the age to the specified player""" - pass - - def offerLinkToPlayer(self,link,playerID): - """Offer a one-time link to the specified player""" - pass - - def registerMTStation(self,stationName,mtSpawnPoint): - """Registers this player at the specified mass-transit point""" - pass - - def registerOwnedAge(self,link): - """Registers the specified age as owned by the player""" - pass - - def registerVisitAge(self,link): - """Register this age as visitable by this player""" - pass - - def sendToDevice(self,node,deviceName): - """Sends a ptVaultNode object to an Age's device by deviceName.""" - pass - - def setAgePublic(self,ageInfo,makePublic): - """Makes the specified age public or private""" - pass - - def unInvitePlayerToAge(self,guid,playerID): - """Revokes the invitation to visit the age""" - pass - - def unRegisterOwnedAge(self,ageFilename): - """Unregisters the specified age so it's no longer owned by this player""" - pass - - def unRegisterVisitAge(self,guid): - """Unregisters the specified age so it can no longer be visited by this player""" - pass - - def updatePsnlAgeSDL(self,pyrec): - """Updates the personal age SDL to the specified data""" - pass - -class ptVaultNode: - """Vault node class""" - def __init__(self): - """None""" - pass - - def addNode(self,node,cb=None,cbContext=0): - """Adds 'node'(ptVaultNode) as a child to this node.""" - pass - - def findNode(self,templateNode): - """Returns ptVaultNode if child node found matching template, or None""" - pass - - def getChildNodeCount(self): - """Returns how many children this node has.""" - pass - - def getChildNodeRefList(self): - """Returns a list of ptVaultNodeRef that are the children of this node.""" - pass - - def getClientID(self): - """Returns the client's ID.""" - pass - - def getCreateAgeCoords(self): - """Returns the location in the Age where this node was created.""" - pass - - def getCreateAgeGuid(self): - """Returns the guid as a string of the Age where this node was created.""" - pass - - def getCreateAgeName(self): - """Returns the name of the Age where this node was created.""" - pass - - def getCreateAgeTime(self): - """Returns the time in the Age that the node was created...(?)""" - pass - - def getCreateTime(self): - """Returns the when this node was created, that is useable by python's time library.""" - pass - - def getCreatorNode(self): - """Returns the creator's node""" - pass - - def getCreatorNodeID(self): - """Returns the creator's node ID""" - pass - - def getID(self): - """Returns the unique ID of this ptVaultNode.""" - pass - - def getModifyTime(self): - """Returns the modified time of this node, that is useable by python's time library.""" - pass - - def getNode(self,id): - """Returns ptVaultNodeRef if is a child node, or None""" - pass - - def getOwnerNode(self): - """Returns a ptVaultNode of the owner of this node""" - pass - - def getOwnerNodeID(self): - """Returns the node ID of the owner of this node""" - pass - - def getType(self): - """Returns the type of ptVaultNode this is. -See PlasmaVaultTypes.py""" - pass - - def hasNode(self,id): - """Returns true if node if a child node""" - pass - - def linkToNode(self,nodeID,cb=None,cbContext=0): - """Adds a link to the node designated by nodeID""" - pass - - def removeAllNodes(self): - """Removes all the child nodes on this node.""" - pass - - def removeNode(self,node,cb=None,cbContext=0): - """Removes the child 'node'(ptVaultNode) from this node.""" - pass - - def save(self,cb=None,cbContext=0): - """Save the changes made to this node.""" - pass - - def saveAll(self,cb=None,cbContext=0): - """Saves this node and all its children nodes.""" - pass - - def sendTo(self,destID,cb=None,cbContext=0): - """Send this node to inbox at 'destID'""" - pass - - def setCreateAgeGuid(self,guid): - """Set guid as a string of the Age where this node was created.""" - pass - - def setCreateAgeName(self,name): - """Set name of the Age where this node was created.""" - pass - - def setCreatorNodeID(self,id): - """Set creator's node ID""" - pass - - def setID(self,id): - """Sets ID of this ptVaultNode.""" - pass - - def setOwnerNodeID(self,id): - """Set node ID of the owner of this node""" - pass - - def setType(self,type): - """Set the type of ptVaultNode this is.""" - pass - - def upcastToAgeInfoListNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoListNode""" - pass - - def upcastToAgeInfoNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoNode""" - pass - - def upcastToAgeLinkNode(self): - """Returns this ptVaultNode as ptVaultAgeLinkNode""" - pass - - def upcastToChronicleNode(self): - """Returns this ptVaultNode as ptVaultChronicleNode""" - pass - - def upcastToFolderNode(self): - """Returns this ptVaultNode as ptVaultFolderNode""" - pass - - def upcastToImageNode(self): - """Returns this ptVaultNode as ptVaultImageNode""" - pass - - def upcastToMarkerGameNode(self): - """Returns this ptVaultNode as ptVaultMarkerNode""" - pass - - def upcastToPlayerInfoListNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoListNode""" - pass - - def upcastToPlayerInfoNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoNode""" - pass - - def upcastToPlayerNode(self): - """Returns this ptVaultNode as a ptVaultPlayerNode""" - pass - - def upcastToSDLNode(self): - """Returns this ptVaultNode as a ptVaultSDLNode""" - pass - - def upcastToSystemNode(self): - """Returns this ptVaultNode as a ptVaultSystemNode""" - pass - - def upcastToTextNoteNode(self): - """Returns this ptVaultNode as ptVaultTextNoteNode""" - pass - -class ptVaultFolderNode(ptVaultNode): - """Plasma vault folder node""" - def __init__(self,n=0): - """None""" - pass - - def addNode(self,node,cb=None,cbContext=0): - """Adds 'node'(ptVaultNode) as a child to this node.""" - pass - - def findNode(self,templateNode): - """Returns ptVaultNode if child node found matching template, or None""" - pass - - def folderGetName(self): - """LEGACY -Returns the folder's name""" - pass - - def folderGetType(self): - """LEGACY -Returns the folder type (of the standard folder types)""" - pass - - def folderSetName(self,name): - """LEGACY -Set the folder name""" - pass - - def folderSetType(self,type): - """LEGACY -Set the folder type""" - pass - - def getChildNodeCount(self): - """Returns how many children this node has.""" - pass - - def getChildNodeRefList(self): - """Returns a list of ptVaultNodeRef that are the children of this node.""" - pass - - def getClientID(self): - """Returns the client's ID.""" - pass - - def getCreateAgeCoords(self): - """Returns the location in the Age where this node was created.""" - pass - - def getCreateAgeGuid(self): - """Returns the guid as a string of the Age where this node was created.""" - pass - - def getCreateAgeName(self): - """Returns the name of the Age where this node was created.""" - pass - - def getCreateAgeTime(self): - """Returns the time in the Age that the node was created...(?)""" - pass - - def getCreateTime(self): - """Returns the when this node was created, that is useable by python's time library.""" - pass - - def getCreatorNode(self): - """Returns the creator's node""" - pass - - def getCreatorNodeID(self): - """Returns the creator's node ID""" - pass - - def getFolderName(self): - """Returns the folder's name""" - pass - - def getFolderNameW(self): - """Unicode version of getFolerName""" - pass - - def getFolderType(self): - """Returns the folder type (of the standard folder types)""" - pass - - def getID(self): - """Returns the unique ID of this ptVaultNode.""" - pass - - def getModifyTime(self): - """Returns the modified time of this node, that is useable by python's time library.""" - pass - - def getNode(self,id): - """Returns ptVaultNodeRef if is a child node, or None""" - pass - - def getOwnerNode(self): - """Returns a ptVaultNode of the owner of this node""" - pass - - def getOwnerNodeID(self): - """Returns the node ID of the owner of this node""" - pass - - def getType(self): - """Returns the type of ptVaultNode this is. -See PlasmaVaultTypes.py""" - pass - - def hasNode(self,id): - """Returns true if node if a child node""" - pass - - def linkToNode(self,nodeID,cb=None,cbContext=0): - """Adds a link to the node designated by nodeID""" - pass - - def removeAllNodes(self): - """Removes all the child nodes on this node.""" - pass - - def removeNode(self,node,cb=None,cbContext=0): - """Removes the child 'node'(ptVaultNode) from this node.""" - pass - - def save(self,cb=None,cbContext=0): - """Save the changes made to this node.""" - pass - - def saveAll(self,cb=None,cbContext=0): - """Saves this node and all its children nodes.""" - pass - - def sendTo(self,destID,cb=None,cbContext=0): - """Send this node to inbox at 'destID'""" - pass - - def setCreateAgeGuid(self,guid): - """Set guid as a string of the Age where this node was created.""" - pass - - def setCreateAgeName(self,name): - """Set name of the Age where this node was created.""" - pass - - def setCreatorNodeID(self,id): - """Set creator's node ID""" - pass - - def setFolderName(self,name): - """Set the folder name""" - pass - - def setFolderNameW(self,name): - """Unicode version of setFolderName""" - pass - - def setFolderType(self,type): - """Set the folder type""" - pass - - def setID(self,id): - """Sets ID of this ptVaultNode.""" - pass - - def setOwnerNodeID(self,id): - """Set node ID of the owner of this node""" - pass - - def setType(self,type): - """Set the type of ptVaultNode this is.""" - pass - - def upcastToAgeInfoListNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoListNode""" - pass - - def upcastToAgeInfoNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoNode""" - pass - - def upcastToAgeLinkNode(self): - """Returns this ptVaultNode as ptVaultAgeLinkNode""" - pass - - def upcastToChronicleNode(self): - """Returns this ptVaultNode as ptVaultChronicleNode""" - pass - - def upcastToFolderNode(self): - """Returns this ptVaultNode as ptVaultFolderNode""" - pass - - def upcastToImageNode(self): - """Returns this ptVaultNode as ptVaultImageNode""" - pass - - def upcastToMarkerGameNode(self): - """Returns this ptVaultNode as ptVaultMarkerNode""" - pass - - def upcastToPlayerInfoListNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoListNode""" - pass - - def upcastToPlayerInfoNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoNode""" - pass - - def upcastToPlayerNode(self): - """Returns this ptVaultNode as a ptVaultPlayerNode""" - pass - - def upcastToSDLNode(self): - """Returns this ptVaultNode as a ptVaultSDLNode""" - pass - - def upcastToSystemNode(self): - """Returns this ptVaultNode as a ptVaultSystemNode""" - pass - - def upcastToTextNoteNode(self): - """Returns this ptVaultNode as ptVaultTextNoteNode""" - pass - -class ptVaultAgeInfoListNode(ptVaultFolderNode): - """Plasma vault age info list node""" - def __init__(self,n=0): - """None""" - pass - - def addAge(self,ageID): - """Adds ageID to list of ages""" - pass - - def addNode(self,node,cb=None,cbContext=0): - """Adds 'node'(ptVaultNode) as a child to this node.""" - pass - - def findNode(self,templateNode): - """Returns ptVaultNode if child node found matching template, or None""" - pass - - def folderGetName(self): - """LEGACY -Returns the folder's name""" - pass - - def folderGetType(self): - """LEGACY -Returns the folder type (of the standard folder types)""" - pass - - def folderSetName(self,name): - """LEGACY -Set the folder name""" - pass - - def folderSetType(self,type): - """LEGACY -Set the folder type""" - pass - - def getChildNodeCount(self): - """Returns how many children this node has.""" - pass - - def getChildNodeRefList(self): - """Returns a list of ptVaultNodeRef that are the children of this node.""" - pass - - def getClientID(self): - """Returns the client's ID.""" - pass - - def getCreateAgeCoords(self): - """Returns the location in the Age where this node was created.""" - pass - - def getCreateAgeGuid(self): - """Returns the guid as a string of the Age where this node was created.""" - pass - - def getCreateAgeName(self): - """Returns the name of the Age where this node was created.""" - pass - - def getCreateAgeTime(self): - """Returns the time in the Age that the node was created...(?)""" - pass - - def getCreateTime(self): - """Returns the when this node was created, that is useable by python's time library.""" - pass - - def getCreatorNode(self): - """Returns the creator's node""" - pass - - def getCreatorNodeID(self): - """Returns the creator's node ID""" - pass - - def getFolderName(self): - """Returns the folder's name""" - pass - - def getFolderNameW(self): - """Unicode version of getFolerName""" - pass - - def getFolderType(self): - """Returns the folder type (of the standard folder types)""" - pass - - def getID(self): - """Returns the unique ID of this ptVaultNode.""" - pass - - def getModifyTime(self): - """Returns the modified time of this node, that is useable by python's time library.""" - pass - - def getNode(self,id): - """Returns ptVaultNodeRef if is a child node, or None""" - pass - - def getOwnerNode(self): - """Returns a ptVaultNode of the owner of this node""" - pass - - def getOwnerNodeID(self): - """Returns the node ID of the owner of this node""" - pass - - def getType(self): - """Returns the type of ptVaultNode this is. -See PlasmaVaultTypes.py""" - pass - - def hasAge(self,ageID): - """Returns whether ageID is in the list of ages""" - pass - - def hasNode(self,id): - """Returns true if node if a child node""" - pass - - def linkToNode(self,nodeID,cb=None,cbContext=0): - """Adds a link to the node designated by nodeID""" - pass - - def removeAge(self,ageID): - """Removes ageID from list of ages""" - pass - - def removeAllNodes(self): - """Removes all the child nodes on this node.""" - pass - - def removeNode(self,node,cb=None,cbContext=0): - """Removes the child 'node'(ptVaultNode) from this node.""" - pass - - def save(self,cb=None,cbContext=0): - """Save the changes made to this node.""" - pass - - def saveAll(self,cb=None,cbContext=0): - """Saves this node and all its children nodes.""" - pass - - def sendTo(self,destID,cb=None,cbContext=0): - """Send this node to inbox at 'destID'""" - pass - - def setCreateAgeGuid(self,guid): - """Set guid as a string of the Age where this node was created.""" - pass - - def setCreateAgeName(self,name): - """Set name of the Age where this node was created.""" - pass - - def setCreatorNodeID(self,id): - """Set creator's node ID""" - pass - - def setFolderName(self,name): - """Set the folder name""" - pass - - def setFolderNameW(self,name): - """Unicode version of setFolderName""" - pass - - def setFolderType(self,type): - """Set the folder type""" - pass - - def setID(self,id): - """Sets ID of this ptVaultNode.""" - pass - - def setOwnerNodeID(self,id): - """Set node ID of the owner of this node""" - pass - - def setType(self,type): - """Set the type of ptVaultNode this is.""" - pass - - def upcastToAgeInfoListNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoListNode""" - pass - - def upcastToAgeInfoNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoNode""" - pass - - def upcastToAgeLinkNode(self): - """Returns this ptVaultNode as ptVaultAgeLinkNode""" - pass - - def upcastToChronicleNode(self): - """Returns this ptVaultNode as ptVaultChronicleNode""" - pass - - def upcastToFolderNode(self): - """Returns this ptVaultNode as ptVaultFolderNode""" - pass - - def upcastToImageNode(self): - """Returns this ptVaultNode as ptVaultImageNode""" - pass - - def upcastToMarkerGameNode(self): - """Returns this ptVaultNode as ptVaultMarkerNode""" - pass - - def upcastToPlayerInfoListNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoListNode""" - pass - - def upcastToPlayerInfoNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoNode""" - pass - - def upcastToPlayerNode(self): - """Returns this ptVaultNode as a ptVaultPlayerNode""" - pass - - def upcastToSDLNode(self): - """Returns this ptVaultNode as a ptVaultSDLNode""" - pass - - def upcastToSystemNode(self): - """Returns this ptVaultNode as a ptVaultSystemNode""" - pass - - def upcastToTextNoteNode(self): - """Returns this ptVaultNode as ptVaultTextNoteNode""" - pass - -class ptVaultAgeInfoNode(ptVaultNode): - """Plasma vault age info node""" - def __init__(self,n=0): - """None""" - pass - - def addNode(self,node,cb=None,cbContext=0): - """Adds 'node'(ptVaultNode) as a child to this node.""" - pass - - def asAgeInfoStruct(self): - """Returns this ptVaultAgeInfoNode as a ptAgeInfoStruct""" - pass - - def findNode(self,templateNode): - """Returns ptVaultNode if child node found matching template, or None""" - pass - - def getAgeDescription(self): - """Returns the description of the age""" - pass - - def getAgeFilename(self): - """Returns the age filename""" - pass - - def getAgeID(self): - """Returns the age ID""" - pass - - def getAgeInstanceGuid(self): - """Returns the age instance guid""" - pass - - def getAgeInstanceName(self): - """Returns the instance name of the age""" - pass - - def getAgeLanguage(self): - """Returns the age's language (integer)""" - pass - - def getAgeOwnersFolder(self): - """Returns a ptVaultPlayerInfoList of the players that own this age""" - pass - - def getAgeSDL(self): - """Returns a ptVaultSDLNode of the age's SDL""" - pass - - def getAgeSequenceNumber(self): - """Returns the sequence number of this instance of the age""" - pass - - def getAgeUserDefinedName(self): - """Returns the user define part of the age name""" - pass - - def getCanVisitFolder(self): - """Returns a ptVaultPlayerInfoList of the players that can visit this age""" - pass - - def getChildAgesFolder(self): - """Returns a ptVaultFolderNode of the child ages of this age""" - pass - - def getChildNodeCount(self): - """Returns how many children this node has.""" - pass - - def getChildNodeRefList(self): - """Returns a list of ptVaultNodeRef that are the children of this node.""" - pass - - def getClientID(self): - """Returns the client's ID.""" - pass - - def getCreateAgeCoords(self): - """Returns the location in the Age where this node was created.""" - pass - - def getCreateAgeGuid(self): - """Returns the guid as a string of the Age where this node was created.""" - pass - - def getCreateAgeName(self): - """Returns the name of the Age where this node was created.""" - pass - - def getCreateAgeTime(self): - """Returns the time in the Age that the node was created...(?)""" - pass - - def getCreateTime(self): - """Returns the when this node was created, that is useable by python's time library.""" - pass - - def getCreatorNode(self): - """Returns the creator's node""" - pass - - def getCreatorNodeID(self): - """Returns the creator's node ID""" - pass - - def getCzar(self): - """Returns ptVaultPlayerInfoNode of the player that is the Czar""" - pass - - def getCzarID(self): - """Returns the ID of the age's czar""" - pass - - def getDisplayName(self): - """Returns the displayable version of the age name""" - pass - - def getID(self): - """Returns the unique ID of this ptVaultNode.""" - pass - - def getModifyTime(self): - """Returns the modified time of this node, that is useable by python's time library.""" - pass - - def getNode(self,id): - """Returns ptVaultNodeRef if is a child node, or None""" - pass - - def getOwnerNode(self): - """Returns a ptVaultNode of the owner of this node""" - pass - - def getOwnerNodeID(self): - """Returns the node ID of the owner of this node""" - pass - - def getParentAgeLink(self): - """Returns ptVaultAgeLinkNode of the age's parent age, or None if not a child age""" - pass - - def getType(self): - """Returns the type of ptVaultNode this is. -See PlasmaVaultTypes.py""" - pass - - def hasNode(self,id): - """Returns true if node if a child node""" - pass - - def isPublic(self): - """Returns whether the age is Public or Not""" - pass - - def linkToNode(self,nodeID,cb=None,cbContext=0): - """Adds a link to the node designated by nodeID""" - pass - - def removeAllNodes(self): - """Removes all the child nodes on this node.""" - pass - - def removeNode(self,node,cb=None,cbContext=0): - """Removes the child 'node'(ptVaultNode) from this node.""" - pass - - def save(self,cb=None,cbContext=0): - """Save the changes made to this node.""" - pass - - def saveAll(self,cb=None,cbContext=0): - """Saves this node and all its children nodes.""" - pass - - def sendTo(self,destID,cb=None,cbContext=0): - """Send this node to inbox at 'destID'""" - pass - - def setAgeDescription(self,description): - """Sets the description of the age""" - pass - - def setAgeFilename(self,fileName): - """Sets the filename""" - pass - - def setAgeID(self,ageID): - """Sets the age ID""" - pass - - def setAgeInstanceGuid(self,guid): - """Sets the age instance GUID""" - pass - - def setAgeInstanceName(self,instanceName): - """Sets the instance name""" - pass - - def setAgeLanguage(self,lang): - """Sets the age's language (integer)""" - pass - - def setAgeSequenceNumber(self,seqNumber): - """Sets the sequence number""" - pass - - def setAgeUserDefinedName(self,udname): - """Sets the user defined part of the name""" - pass - - def setCreateAgeGuid(self,guid): - """Set guid as a string of the Age where this node was created.""" - pass - - def setCreateAgeName(self,name): - """Set name of the Age where this node was created.""" - pass - - def setCreatorNodeID(self,id): - """Set creator's node ID""" - pass - - def setID(self,id): - """Sets ID of this ptVaultNode.""" - pass - - def setOwnerNodeID(self,id): - """Set node ID of the owner of this node""" - pass - - def setType(self,type): - """Set the type of ptVaultNode this is.""" - pass - - def upcastToAgeInfoListNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoListNode""" - pass - - def upcastToAgeInfoNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoNode""" - pass - - def upcastToAgeLinkNode(self): - """Returns this ptVaultNode as ptVaultAgeLinkNode""" - pass - - def upcastToChronicleNode(self): - """Returns this ptVaultNode as ptVaultChronicleNode""" - pass - - def upcastToFolderNode(self): - """Returns this ptVaultNode as ptVaultFolderNode""" - pass - - def upcastToImageNode(self): - """Returns this ptVaultNode as ptVaultImageNode""" - pass - - def upcastToMarkerGameNode(self): - """Returns this ptVaultNode as ptVaultMarkerNode""" - pass - - def upcastToPlayerInfoListNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoListNode""" - pass - - def upcastToPlayerInfoNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoNode""" - pass - - def upcastToPlayerNode(self): - """Returns this ptVaultNode as a ptVaultPlayerNode""" - pass - - def upcastToSDLNode(self): - """Returns this ptVaultNode as a ptVaultSDLNode""" - pass - - def upcastToSystemNode(self): - """Returns this ptVaultNode as a ptVaultSystemNode""" - pass - - def upcastToTextNoteNode(self): - """Returns this ptVaultNode as ptVaultTextNoteNode""" - pass - -class ptVaultAgeLinkNode(ptVaultNode): - """Plasma vault age link node""" - def __init__(self,n=0): - """None""" - pass - - def addNode(self,node,cb=None,cbContext=0): - """Adds 'node'(ptVaultNode) as a child to this node.""" - pass - - def addSpawnPoint(self,point): - """Adds the specified ptSpawnPointInfo or ptSpawnPointInfoRef""" - pass - - def asAgeLinkStruct(self): - """Returns this ptVaultAgeLinkNode as a ptAgeLinkStruct""" - pass - - def findNode(self,templateNode): - """Returns ptVaultNode if child node found matching template, or None""" - pass - - def getAgeInfo(self): - """Returns the ageInfo as a ptAgeInfoStruct""" - pass - - def getChildNodeCount(self): - """Returns how many children this node has.""" - pass - - def getChildNodeRefList(self): - """Returns a list of ptVaultNodeRef that are the children of this node.""" - pass - - def getClientID(self): - """Returns the client's ID.""" - pass - - def getCreateAgeCoords(self): - """Returns the location in the Age where this node was created.""" - pass - - def getCreateAgeGuid(self): - """Returns the guid as a string of the Age where this node was created.""" - pass - - def getCreateAgeName(self): - """Returns the name of the Age where this node was created.""" - pass - - def getCreateAgeTime(self): - """Returns the time in the Age that the node was created...(?)""" - pass - - def getCreateTime(self): - """Returns the when this node was created, that is useable by python's time library.""" - pass - - def getCreatorNode(self): - """Returns the creator's node""" - pass - - def getCreatorNodeID(self): - """Returns the creator's node ID""" - pass - - def getID(self): - """Returns the unique ID of this ptVaultNode.""" - pass - - def getLocked(self): - """Returns whether the link is locked or not""" - pass - - def getModifyTime(self): - """Returns the modified time of this node, that is useable by python's time library.""" - pass - - def getNode(self,id): - """Returns ptVaultNodeRef if is a child node, or None""" - pass - - def getOwnerNode(self): - """Returns a ptVaultNode of the owner of this node""" - pass - - def getOwnerNodeID(self): - """Returns the node ID of the owner of this node""" - pass - - def getSpawnPoints(self): - """Returns a list of ptSpawnPointInfo objects""" - pass - - def getType(self): - """Returns the type of ptVaultNode this is. -See PlasmaVaultTypes.py""" - pass - - def getVolatile(self): - """Returns whether the link is volatile or not""" - pass - - def hasNode(self,id): - """Returns true if node if a child node""" - pass - - def hasSpawnPoint(self,spawnPtName): - """Returns true if this link has the specified spawn point""" - pass - - def linkToNode(self,nodeID,cb=None,cbContext=0): - """Adds a link to the node designated by nodeID""" - pass - - def removeAllNodes(self): - """Removes all the child nodes on this node.""" - pass - - def removeNode(self,node,cb=None,cbContext=0): - """Removes the child 'node'(ptVaultNode) from this node.""" - pass - - def removeSpawnPoint(self,point): - """Removes the specified spawn point based on a ptSpawnPointInfo, ptSpawnPointInfoRef, or string""" - pass - - def save(self,cb=None,cbContext=0): - """Save the changes made to this node.""" - pass - - def saveAll(self,cb=None,cbContext=0): - """Saves this node and all its children nodes.""" - pass - - def sendTo(self,destID,cb=None,cbContext=0): - """Send this node to inbox at 'destID'""" - pass - - def setCreateAgeGuid(self,guid): - """Set guid as a string of the Age where this node was created.""" - pass - - def setCreateAgeName(self,name): - """Set name of the Age where this node was created.""" - pass - - def setCreatorNodeID(self,id): - """Set creator's node ID""" - pass - - def setID(self,id): - """Sets ID of this ptVaultNode.""" - pass - - def setLocked(self,state): - """Sets whether the link is locked or not""" - pass - - def setOwnerNodeID(self,id): - """Set node ID of the owner of this node""" - pass - - def setType(self,type): - """Set the type of ptVaultNode this is.""" - pass - - def setVolatile(self,state): - """Sets the state of the volitility of the link""" - pass - - def upcastToAgeInfoListNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoListNode""" - pass - - def upcastToAgeInfoNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoNode""" - pass - - def upcastToAgeLinkNode(self): - """Returns this ptVaultNode as ptVaultAgeLinkNode""" - pass - - def upcastToChronicleNode(self): - """Returns this ptVaultNode as ptVaultChronicleNode""" - pass - - def upcastToFolderNode(self): - """Returns this ptVaultNode as ptVaultFolderNode""" - pass - - def upcastToImageNode(self): - """Returns this ptVaultNode as ptVaultImageNode""" - pass - - def upcastToMarkerGameNode(self): - """Returns this ptVaultNode as ptVaultMarkerNode""" - pass - - def upcastToPlayerInfoListNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoListNode""" - pass - - def upcastToPlayerInfoNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoNode""" - pass - - def upcastToPlayerNode(self): - """Returns this ptVaultNode as a ptVaultPlayerNode""" - pass - - def upcastToSDLNode(self): - """Returns this ptVaultNode as a ptVaultSDLNode""" - pass - - def upcastToSystemNode(self): - """Returns this ptVaultNode as a ptVaultSystemNode""" - pass - - def upcastToTextNoteNode(self): - """Returns this ptVaultNode as ptVaultTextNoteNode""" - pass - -class ptVaultChronicleNode(ptVaultNode): - """Plasma vault chronicle node""" - def __init__(self,n=0): - """None""" - pass - - def addNode(self,node,cb=None,cbContext=0): - """Adds 'node'(ptVaultNode) as a child to this node.""" - pass - - def chronicleGetName(self): - """LEGACY: Returns the name of the chronicle node.""" - pass - - def chronicleGetType(self): - """LEGACY: Returns the user defined type of the chronicle node.""" - pass - - def chronicleGetValue(self): - """LEGACY: Returns the value as a string of this chronicle node.""" - pass - - def chronicleSetName(self,name): - """LEGACY: Sets the name of the chronicle node.""" - pass - - def chronicleSetType(self,type): - """LEGACY: Sets this chronicle node to a user defined type.""" - pass - - def chronicleSetValue(self,value): - """LEGACY: Sets the chronicle to a value that is a string""" - pass - - def findNode(self,templateNode): - """Returns ptVaultNode if child node found matching template, or None""" - pass - - def getChildNodeCount(self): - """Returns how many children this node has.""" - pass - - def getChildNodeRefList(self): - """Returns a list of ptVaultNodeRef that are the children of this node.""" - pass - - def getClientID(self): - """Returns the client's ID.""" - pass - - def getCreateAgeCoords(self): - """Returns the location in the Age where this node was created.""" - pass - - def getCreateAgeGuid(self): - """Returns the guid as a string of the Age where this node was created.""" - pass - - def getCreateAgeName(self): - """Returns the name of the Age where this node was created.""" - pass - - def getCreateAgeTime(self): - """Returns the time in the Age that the node was created...(?)""" - pass - - def getCreateTime(self): - """Returns the when this node was created, that is useable by python's time library.""" - pass - - def getCreatorNode(self): - """Returns the creator's node""" - pass - - def getCreatorNodeID(self): - """Returns the creator's node ID""" - pass - - def getEntryType(self): - """Returns the user defined type of the chronicle node.""" - pass - - def getID(self): - """Returns the unique ID of this ptVaultNode.""" - pass - - def getModifyTime(self): - """Returns the modified time of this node, that is useable by python's time library.""" - pass - - def getName(self): - """Returns the name of the chronicle node.""" - pass - - def getNode(self,id): - """Returns ptVaultNodeRef if is a child node, or None""" - pass - - def getOwnerNode(self): - """Returns a ptVaultNode of the owner of this node""" - pass - - def getOwnerNodeID(self): - """Returns the node ID of the owner of this node""" - pass - - def getType(self): - """Returns the type of ptVaultNode this is. -See PlasmaVaultTypes.py""" - pass - - def getValue(self): - """Returns the value as a string of this chronicle node.""" - pass - - def hasNode(self,id): - """Returns true if node if a child node""" - pass - - def linkToNode(self,nodeID,cb=None,cbContext=0): - """Adds a link to the node designated by nodeID""" - pass - - def removeAllNodes(self): - """Removes all the child nodes on this node.""" - pass - - def removeNode(self,node,cb=None,cbContext=0): - """Removes the child 'node'(ptVaultNode) from this node.""" - pass - - def save(self,cb=None,cbContext=0): - """Save the changes made to this node.""" - pass - - def saveAll(self,cb=None,cbContext=0): - """Saves this node and all its children nodes.""" - pass - - def sendTo(self,destID,cb=None,cbContext=0): - """Send this node to inbox at 'destID'""" - pass - - def setCreateAgeGuid(self,guid): - """Set guid as a string of the Age where this node was created.""" - pass - - def setCreateAgeName(self,name): - """Set name of the Age where this node was created.""" - pass - - def setCreatorNodeID(self,id): - """Set creator's node ID""" - pass - - def setEntryType(self,type): - """Sets this chronicle node to a user defined type.""" - pass - - def setID(self,id): - """Sets ID of this ptVaultNode.""" - pass - - def setName(self,name): - """Sets the name of the chronicle node.""" - pass - - def setOwnerNodeID(self,id): - """Set node ID of the owner of this node""" - pass - - def setType(self,type): - """Set the type of ptVaultNode this is.""" - pass - - def setValue(self,value): - """Sets the chronicle to a value that is a string""" - pass - - def upcastToAgeInfoListNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoListNode""" - pass - - def upcastToAgeInfoNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoNode""" - pass - - def upcastToAgeLinkNode(self): - """Returns this ptVaultNode as ptVaultAgeLinkNode""" - pass - - def upcastToChronicleNode(self): - """Returns this ptVaultNode as ptVaultChronicleNode""" - pass - - def upcastToFolderNode(self): - """Returns this ptVaultNode as ptVaultFolderNode""" - pass - - def upcastToImageNode(self): - """Returns this ptVaultNode as ptVaultImageNode""" - pass - - def upcastToMarkerGameNode(self): - """Returns this ptVaultNode as ptVaultMarkerNode""" - pass - - def upcastToPlayerInfoListNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoListNode""" - pass - - def upcastToPlayerInfoNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoNode""" - pass - - def upcastToPlayerNode(self): - """Returns this ptVaultNode as a ptVaultPlayerNode""" - pass - - def upcastToSDLNode(self): - """Returns this ptVaultNode as a ptVaultSDLNode""" - pass - - def upcastToSystemNode(self): - """Returns this ptVaultNode as a ptVaultSystemNode""" - pass - - def upcastToTextNoteNode(self): - """Returns this ptVaultNode as ptVaultTextNoteNode""" - pass - -class ptVaultImageNode(ptVaultNode): - """Plasma vault image node""" - def __init__(self,n=0): - """None""" - pass - - def addNode(self,node,cb=None,cbContext=0): - """Adds 'node'(ptVaultNode) as a child to this node.""" - pass - - def findNode(self,templateNode): - """Returns ptVaultNode if child node found matching template, or None""" - pass - - def getChildNodeCount(self): - """Returns how many children this node has.""" - pass - - def getChildNodeRefList(self): - """Returns a list of ptVaultNodeRef that are the children of this node.""" - pass - - def getClientID(self): - """Returns the client's ID.""" - pass - - def getCreateAgeCoords(self): - """Returns the location in the Age where this node was created.""" - pass - - def getCreateAgeGuid(self): - """Returns the guid as a string of the Age where this node was created.""" - pass - - def getCreateAgeName(self): - """Returns the name of the Age where this node was created.""" - pass - - def getCreateAgeTime(self): - """Returns the time in the Age that the node was created...(?)""" - pass - - def getCreateTime(self): - """Returns the when this node was created, that is useable by python's time library.""" - pass - - def getCreatorNode(self): - """Returns the creator's node""" - pass - - def getCreatorNodeID(self): - """Returns the creator's node ID""" - pass - - def getID(self): - """Returns the unique ID of this ptVaultNode.""" - pass - - def getImage(self): - """Returns the image(ptImage) of this image node""" - pass - - def getModifyTime(self): - """Returns the modified time of this node, that is useable by python's time library.""" - pass - - def getNode(self,id): - """Returns ptVaultNodeRef if is a child node, or None""" - pass - - def getOwnerNode(self): - """Returns a ptVaultNode of the owner of this node""" - pass - - def getOwnerNodeID(self): - """Returns the node ID of the owner of this node""" - pass - - def getTitle(self): - """Returns the title (caption) of this image node""" - pass - - def getTitleW(self): - """Unicode version of getTitle""" - pass - - def getType(self): - """Returns the type of ptVaultNode this is. -See PlasmaVaultTypes.py""" - pass - - def hasNode(self,id): - """Returns true if node if a child node""" - pass - - def imageGetImage(self): - """LEGACY -Returns the image(ptImage) of this image node""" - pass - - def imageGetTitle(self): - """LEGACY -Returns the title (caption) of this image node""" - pass - - def imageSetImage(self,image): - """LEGACY -Sets the image(ptImage) of this image node""" - pass - - def imageSetTitle(self,title): - """LEGACY -Sets the title (caption) of this image node""" - pass - - def linkToNode(self,nodeID,cb=None,cbContext=0): - """Adds a link to the node designated by nodeID""" - pass - - def removeAllNodes(self): - """Removes all the child nodes on this node.""" - pass - - def removeNode(self,node,cb=None,cbContext=0): - """Removes the child 'node'(ptVaultNode) from this node.""" - pass - - def save(self,cb=None,cbContext=0): - """Save the changes made to this node.""" - pass - - def saveAll(self,cb=None,cbContext=0): - """Saves this node and all its children nodes.""" - pass - - def sendTo(self,destID,cb=None,cbContext=0): - """Send this node to inbox at 'destID'""" - pass - - def setCreateAgeGuid(self,guid): - """Set guid as a string of the Age where this node was created.""" - pass - - def setCreateAgeName(self,name): - """Set name of the Age where this node was created.""" - pass - - def setCreatorNodeID(self,id): - """Set creator's node ID""" - pass - - def setID(self,id): - """Sets ID of this ptVaultNode.""" - pass - - def setImage(self,image): - """Sets the image(ptImage) of this image node""" - pass - - def setImageFromBuf(self,buf): - """Sets our image from a buffer""" - pass - - def setImageFromScrShot(self): - """Grabs a screenshot and stuffs it into this node""" - pass - - def setOwnerNodeID(self,id): - """Set node ID of the owner of this node""" - pass - - def setTitle(self,title): - """Sets the title (caption) of this image node""" - pass - - def setTitleW(self,title): - """Unicode version of setTitle""" - pass - - def setType(self,type): - """Set the type of ptVaultNode this is.""" - pass - - def upcastToAgeInfoListNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoListNode""" - pass - - def upcastToAgeInfoNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoNode""" - pass - - def upcastToAgeLinkNode(self): - """Returns this ptVaultNode as ptVaultAgeLinkNode""" - pass - - def upcastToChronicleNode(self): - """Returns this ptVaultNode as ptVaultChronicleNode""" - pass - - def upcastToFolderNode(self): - """Returns this ptVaultNode as ptVaultFolderNode""" - pass - - def upcastToImageNode(self): - """Returns this ptVaultNode as ptVaultImageNode""" - pass - - def upcastToMarkerGameNode(self): - """Returns this ptVaultNode as ptVaultMarkerNode""" - pass - - def upcastToPlayerInfoListNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoListNode""" - pass - - def upcastToPlayerInfoNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoNode""" - pass - - def upcastToPlayerNode(self): - """Returns this ptVaultNode as a ptVaultPlayerNode""" - pass - - def upcastToSDLNode(self): - """Returns this ptVaultNode as a ptVaultSDLNode""" - pass - - def upcastToSystemNode(self): - """Returns this ptVaultNode as a ptVaultSystemNode""" - pass - - def upcastToTextNoteNode(self): - """Returns this ptVaultNode as ptVaultTextNoteNode""" - pass - -class ptVaultMarkerGameNode(ptVaultNode): - """Plasma vault age info node""" - def __init__(self,n=0): - """None""" - pass - - def addNode(self,node,cb=None,cbContext=0): - """Adds 'node'(ptVaultNode) as a child to this node.""" - pass - - def findNode(self,templateNode): - """Returns ptVaultNode if child node found matching template, or None""" - pass - - def getChildNodeCount(self): - """Returns how many children this node has.""" - pass - - def getChildNodeRefList(self): - """Returns a list of ptVaultNodeRef that are the children of this node.""" - pass - - def getClientID(self): - """Returns the client's ID.""" - pass - - def getCreateAgeCoords(self): - """Returns the location in the Age where this node was created.""" - pass - - def getCreateAgeGuid(self): - """Returns the guid as a string of the Age where this node was created.""" - pass - - def getCreateAgeName(self): - """Returns the name of the Age where this node was created.""" - pass - - def getCreateAgeTime(self): - """Returns the time in the Age that the node was created...(?)""" - pass - - def getCreateTime(self): - """Returns the when this node was created, that is useable by python's time library.""" - pass - - def getCreatorNode(self): - """Returns the creator's node""" - pass - - def getCreatorNodeID(self): - """Returns the creator's node ID""" - pass - - def getGameGuid(self): - """Returns the marker game's guid""" - pass - - def getGameName(self): - """Returns the marker game's name""" - pass - - def getID(self): - """Returns the unique ID of this ptVaultNode.""" - pass - - def getModifyTime(self): - """Returns the modified time of this node, that is useable by python's time library.""" - pass - - def getNode(self,id): - """Returns ptVaultNodeRef if is a child node, or None""" - pass - - def getOwnerNode(self): - """Returns a ptVaultNode of the owner of this node""" - pass - - def getOwnerNodeID(self): - """Returns the node ID of the owner of this node""" - pass - - def getType(self): - """Returns the type of ptVaultNode this is. -See PlasmaVaultTypes.py""" - pass - - def hasNode(self,id): - """Returns true if node if a child node""" - pass - - def linkToNode(self,nodeID,cb=None,cbContext=0): - """Adds a link to the node designated by nodeID""" - pass - - def removeAllNodes(self): - """Removes all the child nodes on this node.""" - pass - - def removeNode(self,node,cb=None,cbContext=0): - """Removes the child 'node'(ptVaultNode) from this node.""" - pass - - def save(self,cb=None,cbContext=0): - """Save the changes made to this node.""" - pass - - def saveAll(self,cb=None,cbContext=0): - """Saves this node and all its children nodes.""" - pass - - def sendTo(self,destID,cb=None,cbContext=0): - """Send this node to inbox at 'destID'""" - pass - - def setCreateAgeGuid(self,guid): - """Set guid as a string of the Age where this node was created.""" - pass - - def setCreateAgeName(self,name): - """Set name of the Age where this node was created.""" - pass - - def setCreatorNodeID(self,id): - """Set creator's node ID""" - pass - - def setGameGuid(self,guid): - """Sets the marker game's guid""" - pass - - def setGameName(self,name): - """Sets marker game's name""" - pass - - def setID(self,id): - """Sets ID of this ptVaultNode.""" - pass - - def setOwnerNodeID(self,id): - """Set node ID of the owner of this node""" - pass - - def setType(self,type): - """Set the type of ptVaultNode this is.""" - pass - - def upcastToAgeInfoListNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoListNode""" - pass - - def upcastToAgeInfoNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoNode""" - pass - - def upcastToAgeLinkNode(self): - """Returns this ptVaultNode as ptVaultAgeLinkNode""" - pass - - def upcastToChronicleNode(self): - """Returns this ptVaultNode as ptVaultChronicleNode""" - pass - - def upcastToFolderNode(self): - """Returns this ptVaultNode as ptVaultFolderNode""" - pass - - def upcastToImageNode(self): - """Returns this ptVaultNode as ptVaultImageNode""" - pass - - def upcastToMarkerGameNode(self): - """Returns this ptVaultNode as ptVaultMarkerNode""" - pass - - def upcastToPlayerInfoListNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoListNode""" - pass - - def upcastToPlayerInfoNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoNode""" - pass - - def upcastToPlayerNode(self): - """Returns this ptVaultNode as a ptVaultPlayerNode""" - pass - - def upcastToSDLNode(self): - """Returns this ptVaultNode as a ptVaultSDLNode""" - pass - - def upcastToSystemNode(self): - """Returns this ptVaultNode as a ptVaultSystemNode""" - pass - - def upcastToTextNoteNode(self): - """Returns this ptVaultNode as ptVaultTextNoteNode""" - pass - -class ptVaultNodeRef: - """Vault node relationship pseudo class""" - def __init__(self): - """None""" - pass - - def beenSeen(self): - """Returns true until we reimplement this""" - pass - - def getChild(self): - """Returns a ptVaultNode that is the child of this reference""" - pass - - def getChildID(self): - """Returns id of the child node""" - pass - - def getParent(self): - """Returns a ptVaultNode that is the parent of the reference""" - pass - - def getParentID(self): - """Returns id of the parent node""" - pass - - def getSaver(self): - """Returns a ptVaultPlayerInfoNode of player that created this relationship""" - pass - - def getSaverID(self): - """Returns id of player that created this relationship""" - pass - - def setSeen(self): - """Does nothing until we reimplement this""" - pass - -class ptVaultPlayerInfoListNode(ptVaultFolderNode): - """Plasma vault player info list node""" - def __init__(self,n=0): - """None""" - pass - - def addNode(self,node,cb=None,cbContext=0): - """Adds 'node'(ptVaultNode) as a child to this node.""" - pass - - def addPlayer(self,playerID): - """Adds playerID player to this player info list node.""" - pass - - def findNode(self,templateNode): - """Returns ptVaultNode if child node found matching template, or None""" - pass - - def folderGetName(self): - """LEGACY -Returns the folder's name""" - pass - - def folderGetType(self): - """LEGACY -Returns the folder type (of the standard folder types)""" - pass - - def folderSetName(self,name): - """LEGACY -Set the folder name""" - pass - - def folderSetType(self,type): - """LEGACY -Set the folder type""" - pass - - def getChildNodeCount(self): - """Returns how many children this node has.""" - pass - - def getChildNodeRefList(self): - """Returns a list of ptVaultNodeRef that are the children of this node.""" - pass - - def getClientID(self): - """Returns the client's ID.""" - pass - - def getCreateAgeCoords(self): - """Returns the location in the Age where this node was created.""" - pass - - def getCreateAgeGuid(self): - """Returns the guid as a string of the Age where this node was created.""" - pass - - def getCreateAgeName(self): - """Returns the name of the Age where this node was created.""" - pass - - def getCreateAgeTime(self): - """Returns the time in the Age that the node was created...(?)""" - pass - - def getCreateTime(self): - """Returns the when this node was created, that is useable by python's time library.""" - pass - - def getCreatorNode(self): - """Returns the creator's node""" - pass - - def getCreatorNodeID(self): - """Returns the creator's node ID""" - pass - - def getFolderName(self): - """Returns the folder's name""" - pass - - def getFolderNameW(self): - """Unicode version of getFolerName""" - pass - - def getFolderType(self): - """Returns the folder type (of the standard folder types)""" - pass - - def getID(self): - """Returns the unique ID of this ptVaultNode.""" - pass - - def getModifyTime(self): - """Returns the modified time of this node, that is useable by python's time library.""" - pass - - def getNode(self,id): - """Returns ptVaultNodeRef if is a child node, or None""" - pass - - def getOwnerNode(self): - """Returns a ptVaultNode of the owner of this node""" - pass - - def getOwnerNodeID(self): - """Returns the node ID of the owner of this node""" - pass - - def getPlayer(self,playerID): - """Gets the player info node for the specified player.""" - pass - - def getType(self): - """Returns the type of ptVaultNode this is. -See PlasmaVaultTypes.py""" - pass - - def hasNode(self,id): - """Returns true if node if a child node""" - pass - - def hasPlayer(self,playerID): - """Returns whether the 'playerID' is a member of this player info list node.""" - pass - - def linkToNode(self,nodeID,cb=None,cbContext=0): - """Adds a link to the node designated by nodeID""" - pass - - def playerlistAddPlayer(self,playerID): - """LEGACY: Adds playerID player to this player info list node.""" - pass - - def playerlistGetPlayer(self,playerID): - """LEGACY: Gets the player info node for the specified player.""" - pass - - def playerlistHasPlayer(self,playerID): - """LEGACY: Returns whether the 'playerID' is a member of this player info list node.""" - pass - - def playerlistRemovePlayer(self,playerID): - """LEGACY: Removes playerID player from this player info list node.""" - pass - - def removeAllNodes(self): - """Removes all the child nodes on this node.""" - pass - - def removeNode(self,node,cb=None,cbContext=0): - """Removes the child 'node'(ptVaultNode) from this node.""" - pass - - def removePlayer(self,playerID): - """Removes playerID player from this player info list node.""" - pass - - def save(self,cb=None,cbContext=0): - """Save the changes made to this node.""" - pass - - def saveAll(self,cb=None,cbContext=0): - """Saves this node and all its children nodes.""" - pass - - def sendTo(self,destID,cb=None,cbContext=0): - """Send this node to inbox at 'destID'""" - pass - - def setCreateAgeGuid(self,guid): - """Set guid as a string of the Age where this node was created.""" - pass - - def setCreateAgeName(self,name): - """Set name of the Age where this node was created.""" - pass - - def setCreatorNodeID(self,id): - """Set creator's node ID""" - pass - - def setFolderName(self,name): - """Set the folder name""" - pass - - def setFolderNameW(self,name): - """Unicode version of setFolderName""" - pass - - def setFolderType(self,type): - """Set the folder type""" - pass - - def setID(self,id): - """Sets ID of this ptVaultNode.""" - pass - - def setOwnerNodeID(self,id): - """Set node ID of the owner of this node""" - pass - - def setType(self,type): - """Set the type of ptVaultNode this is.""" - pass - - def sort(self): - """Sorts the player list by some means...?""" - pass - - def upcastToAgeInfoListNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoListNode""" - pass - - def upcastToAgeInfoNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoNode""" - pass - - def upcastToAgeLinkNode(self): - """Returns this ptVaultNode as ptVaultAgeLinkNode""" - pass - - def upcastToChronicleNode(self): - """Returns this ptVaultNode as ptVaultChronicleNode""" - pass - - def upcastToFolderNode(self): - """Returns this ptVaultNode as ptVaultFolderNode""" - pass - - def upcastToImageNode(self): - """Returns this ptVaultNode as ptVaultImageNode""" - pass - - def upcastToMarkerGameNode(self): - """Returns this ptVaultNode as ptVaultMarkerNode""" - pass - - def upcastToPlayerInfoListNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoListNode""" - pass - - def upcastToPlayerInfoNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoNode""" - pass - - def upcastToPlayerNode(self): - """Returns this ptVaultNode as a ptVaultPlayerNode""" - pass - - def upcastToSDLNode(self): - """Returns this ptVaultNode as a ptVaultSDLNode""" - pass - - def upcastToSystemNode(self): - """Returns this ptVaultNode as a ptVaultSystemNode""" - pass - - def upcastToTextNoteNode(self): - """Returns this ptVaultNode as ptVaultTextNoteNode""" - pass - -class ptVaultPlayerInfoNode(ptVaultNode): - """Plasma vault folder node""" - def __init__(self): - """None""" - pass - - def addNode(self,node,cb=None,cbContext=0): - """Adds 'node'(ptVaultNode) as a child to this node.""" - pass - - def findNode(self,templateNode): - """Returns ptVaultNode if child node found matching template, or None""" - pass - - def getChildNodeCount(self): - """Returns how many children this node has.""" - pass - - def getChildNodeRefList(self): - """Returns a list of ptVaultNodeRef that are the children of this node.""" - pass - - def getClientID(self): - """Returns the client's ID.""" - pass - - def getCreateAgeCoords(self): - """Returns the location in the Age where this node was created.""" - pass - - def getCreateAgeGuid(self): - """Returns the guid as a string of the Age where this node was created.""" - pass - - def getCreateAgeName(self): - """Returns the name of the Age where this node was created.""" - pass - - def getCreateAgeTime(self): - """Returns the time in the Age that the node was created...(?)""" - pass - - def getCreateTime(self): - """Returns the when this node was created, that is useable by python's time library.""" - pass - - def getCreatorNode(self): - """Returns the creator's node""" - pass - - def getCreatorNodeID(self): - """Returns the creator's node ID""" - pass - - def getID(self): - """Returns the unique ID of this ptVaultNode.""" - pass - - def getModifyTime(self): - """Returns the modified time of this node, that is useable by python's time library.""" - pass - - def getNode(self,id): - """Returns ptVaultNodeRef if is a child node, or None""" - pass - - def getOwnerNode(self): - """Returns a ptVaultNode of the owner of this node""" - pass - - def getOwnerNodeID(self): - """Returns the node ID of the owner of this node""" - pass - - def getType(self): - """Returns the type of ptVaultNode this is. -See PlasmaVaultTypes.py""" - pass - - def hasNode(self,id): - """Returns true if node if a child node""" - pass - - def linkToNode(self,nodeID,cb=None,cbContext=0): - """Adds a link to the node designated by nodeID""" - pass - - def playerGetAgeGuid(self): - """Returns the guid as a string of where the player is for this player info node.""" - pass - - def playerGetAgeInstanceName(self): - """Returns the name of the Age where the player is for this player info node.""" - pass - - def playerGetCCRLevel(self): - """Returns the ccr level of the player for this player info node.""" - pass - - def playerGetID(self): - """Returns the player ID for this player info node.""" - pass - - def playerGetName(self): - """Returns the player name of this player info node.""" - pass - - def playerIsOnline(self): - """Returns the online status of the player for this player info node.""" - pass - - def playerSetAgeGuid(self,guidString): - """Not sure this should be used. Sets the guid for this player info node.""" - pass - - def playerSetAgeInstanceName(self,name): - """Not sure this should be used. Sets the name of the age where the player is for this player info node.""" - pass - - def playerSetID(self,playerID): - """Not sure this should be used. Sets the playerID for this player info node.""" - pass - - def playerSetName(self,name): - """Not sure this should be used. Sets the player name of this player info node.""" - pass - - def playerSetOnline(self,state): - """Not sure this should be used. Sets the state of the player online status for this player info node.""" - pass - - def removeAllNodes(self): - """Removes all the child nodes on this node.""" - pass - - def removeNode(self,node,cb=None,cbContext=0): - """Removes the child 'node'(ptVaultNode) from this node.""" - pass - - def save(self,cb=None,cbContext=0): - """Save the changes made to this node.""" - pass - - def saveAll(self,cb=None,cbContext=0): - """Saves this node and all its children nodes.""" - pass - - def sendTo(self,destID,cb=None,cbContext=0): - """Send this node to inbox at 'destID'""" - pass - - def setCreateAgeGuid(self,guid): - """Set guid as a string of the Age where this node was created.""" - pass - - def setCreateAgeName(self,name): - """Set name of the Age where this node was created.""" - pass - - def setCreatorNodeID(self,id): - """Set creator's node ID""" - pass - - def setID(self,id): - """Sets ID of this ptVaultNode.""" - pass - - def setOwnerNodeID(self,id): - """Set node ID of the owner of this node""" - pass - - def setType(self,type): - """Set the type of ptVaultNode this is.""" - pass - - def upcastToAgeInfoListNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoListNode""" - pass - - def upcastToAgeInfoNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoNode""" - pass - - def upcastToAgeLinkNode(self): - """Returns this ptVaultNode as ptVaultAgeLinkNode""" - pass - - def upcastToChronicleNode(self): - """Returns this ptVaultNode as ptVaultChronicleNode""" - pass - - def upcastToFolderNode(self): - """Returns this ptVaultNode as ptVaultFolderNode""" - pass - - def upcastToImageNode(self): - """Returns this ptVaultNode as ptVaultImageNode""" - pass - - def upcastToMarkerGameNode(self): - """Returns this ptVaultNode as ptVaultMarkerNode""" - pass - - def upcastToPlayerInfoListNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoListNode""" - pass - - def upcastToPlayerInfoNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoNode""" - pass - - def upcastToPlayerNode(self): - """Returns this ptVaultNode as a ptVaultPlayerNode""" - pass - - def upcastToSDLNode(self): - """Returns this ptVaultNode as a ptVaultSDLNode""" - pass - - def upcastToSystemNode(self): - """Returns this ptVaultNode as a ptVaultSystemNode""" - pass - - def upcastToTextNoteNode(self): - """Returns this ptVaultNode as ptVaultTextNoteNode""" - pass - -class ptVaultSDLNode(ptVaultNode): - """Plasma vault SDL node""" - def __init__(self): - """None""" - pass - - def addNode(self,node,cb=None,cbContext=0): - """Adds 'node'(ptVaultNode) as a child to this node.""" - pass - - def findNode(self,templateNode): - """Returns ptVaultNode if child node found matching template, or None""" - pass - - def getChildNodeCount(self): - """Returns how many children this node has.""" - pass - - def getChildNodeRefList(self): - """Returns a list of ptVaultNodeRef that are the children of this node.""" - pass - - def getClientID(self): - """Returns the client's ID.""" - pass - - def getCreateAgeCoords(self): - """Returns the location in the Age where this node was created.""" - pass - - def getCreateAgeGuid(self): - """Returns the guid as a string of the Age where this node was created.""" - pass - - def getCreateAgeName(self): - """Returns the name of the Age where this node was created.""" - pass - - def getCreateAgeTime(self): - """Returns the time in the Age that the node was created...(?)""" - pass - - def getCreateTime(self): - """Returns the when this node was created, that is useable by python's time library.""" - pass - - def getCreatorNode(self): - """Returns the creator's node""" - pass - - def getCreatorNodeID(self): - """Returns the creator's node ID""" - pass - - def getID(self): - """Returns the unique ID of this ptVaultNode.""" - pass - - def getIdent(self): - """UNKNOWN""" - pass - - def getModifyTime(self): - """Returns the modified time of this node, that is useable by python's time library.""" - pass - - def getNode(self,id): - """Returns ptVaultNodeRef if is a child node, or None""" - pass - - def getOwnerNode(self): - """Returns a ptVaultNode of the owner of this node""" - pass - - def getOwnerNodeID(self): - """Returns the node ID of the owner of this node""" - pass - - def getStateDataRecord(self): - """Returns the ptSDLStateDataRecord associated with this node""" - pass - - def getType(self): - """Returns the type of ptVaultNode this is. -See PlasmaVaultTypes.py""" - pass - - def hasNode(self,id): - """Returns true if node if a child node""" - pass - - def initStateDataRecord(self,filename,flags): - """Read the SDL Rec from File if needed""" - pass - - def linkToNode(self,nodeID,cb=None,cbContext=0): - """Adds a link to the node designated by nodeID""" - pass - - def removeAllNodes(self): - """Removes all the child nodes on this node.""" - pass - - def removeNode(self,node,cb=None,cbContext=0): - """Removes the child 'node'(ptVaultNode) from this node.""" - pass - - def save(self,cb=None,cbContext=0): - """Save the changes made to this node.""" - pass - - def saveAll(self,cb=None,cbContext=0): - """Saves this node and all its children nodes.""" - pass - - def sendTo(self,destID,cb=None,cbContext=0): - """Send this node to inbox at 'destID'""" - pass - - def setCreateAgeGuid(self,guid): - """Set guid as a string of the Age where this node was created.""" - pass - - def setCreateAgeName(self,name): - """Set name of the Age where this node was created.""" - pass - - def setCreatorNodeID(self,id): - """Set creator's node ID""" - pass - - def setID(self,id): - """Sets ID of this ptVaultNode.""" - pass - - def setIdent(self,v): - """UNKNOWN""" - pass - - def setOwnerNodeID(self,id): - """Set node ID of the owner of this node""" - pass - - def setStateDataRecord(self,rec,writeOptions=0): - """Sets the ptSDLStateDataRecord""" - pass - - def setType(self,type): - """Set the type of ptVaultNode this is.""" - pass - - def upcastToAgeInfoListNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoListNode""" - pass - - def upcastToAgeInfoNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoNode""" - pass - - def upcastToAgeLinkNode(self): - """Returns this ptVaultNode as ptVaultAgeLinkNode""" - pass - - def upcastToChronicleNode(self): - """Returns this ptVaultNode as ptVaultChronicleNode""" - pass - - def upcastToFolderNode(self): - """Returns this ptVaultNode as ptVaultFolderNode""" - pass - - def upcastToImageNode(self): - """Returns this ptVaultNode as ptVaultImageNode""" - pass - - def upcastToMarkerGameNode(self): - """Returns this ptVaultNode as ptVaultMarkerNode""" - pass - - def upcastToPlayerInfoListNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoListNode""" - pass - - def upcastToPlayerInfoNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoNode""" - pass - - def upcastToPlayerNode(self): - """Returns this ptVaultNode as a ptVaultPlayerNode""" - pass - - def upcastToSDLNode(self): - """Returns this ptVaultNode as a ptVaultSDLNode""" - pass - - def upcastToSystemNode(self): - """Returns this ptVaultNode as a ptVaultSystemNode""" - pass - - def upcastToTextNoteNode(self): - """Returns this ptVaultNode as ptVaultTextNoteNode""" - pass - -class ptVaultSystemNode(ptVaultNode): - """Plasma vault system node""" - def __init__(self): - """None""" - pass - - def addNode(self,node,cb=None,cbContext=0): - """Adds 'node'(ptVaultNode) as a child to this node.""" - pass - - def findNode(self,templateNode): - """Returns ptVaultNode if child node found matching template, or None""" - pass - - def getChildNodeCount(self): - """Returns how many children this node has.""" - pass - - def getChildNodeRefList(self): - """Returns a list of ptVaultNodeRef that are the children of this node.""" - pass - - def getClientID(self): - """Returns the client's ID.""" - pass - - def getCreateAgeCoords(self): - """Returns the location in the Age where this node was created.""" - pass - - def getCreateAgeGuid(self): - """Returns the guid as a string of the Age where this node was created.""" - pass - - def getCreateAgeName(self): - """Returns the name of the Age where this node was created.""" - pass - - def getCreateAgeTime(self): - """Returns the time in the Age that the node was created...(?)""" - pass - - def getCreateTime(self): - """Returns the when this node was created, that is useable by python's time library.""" - pass - - def getCreatorNode(self): - """Returns the creator's node""" - pass - - def getCreatorNodeID(self): - """Returns the creator's node ID""" - pass - - def getID(self): - """Returns the unique ID of this ptVaultNode.""" - pass - - def getModifyTime(self): - """Returns the modified time of this node, that is useable by python's time library.""" - pass - - def getNode(self,id): - """Returns ptVaultNodeRef if is a child node, or None""" - pass - - def getOwnerNode(self): - """Returns a ptVaultNode of the owner of this node""" - pass - - def getOwnerNodeID(self): - """Returns the node ID of the owner of this node""" - pass - - def getType(self): - """Returns the type of ptVaultNode this is. -See PlasmaVaultTypes.py""" - pass - - def hasNode(self,id): - """Returns true if node if a child node""" - pass - - def linkToNode(self,nodeID,cb=None,cbContext=0): - """Adds a link to the node designated by nodeID""" - pass - - def removeAllNodes(self): - """Removes all the child nodes on this node.""" - pass - - def removeNode(self,node,cb=None,cbContext=0): - """Removes the child 'node'(ptVaultNode) from this node.""" - pass - - def save(self,cb=None,cbContext=0): - """Save the changes made to this node.""" - pass - - def saveAll(self,cb=None,cbContext=0): - """Saves this node and all its children nodes.""" - pass - - def sendTo(self,destID,cb=None,cbContext=0): - """Send this node to inbox at 'destID'""" - pass - - def setCreateAgeGuid(self,guid): - """Set guid as a string of the Age where this node was created.""" - pass - - def setCreateAgeName(self,name): - """Set name of the Age where this node was created.""" - pass - - def setCreatorNodeID(self,id): - """Set creator's node ID""" - pass - - def setID(self,id): - """Sets ID of this ptVaultNode.""" - pass - - def setOwnerNodeID(self,id): - """Set node ID of the owner of this node""" - pass - - def setType(self,type): - """Set the type of ptVaultNode this is.""" - pass - - def upcastToAgeInfoListNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoListNode""" - pass - - def upcastToAgeInfoNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoNode""" - pass - - def upcastToAgeLinkNode(self): - """Returns this ptVaultNode as ptVaultAgeLinkNode""" - pass - - def upcastToChronicleNode(self): - """Returns this ptVaultNode as ptVaultChronicleNode""" - pass - - def upcastToFolderNode(self): - """Returns this ptVaultNode as ptVaultFolderNode""" - pass - - def upcastToImageNode(self): - """Returns this ptVaultNode as ptVaultImageNode""" - pass - - def upcastToMarkerGameNode(self): - """Returns this ptVaultNode as ptVaultMarkerNode""" - pass - - def upcastToPlayerInfoListNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoListNode""" - pass - - def upcastToPlayerInfoNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoNode""" - pass - - def upcastToPlayerNode(self): - """Returns this ptVaultNode as a ptVaultPlayerNode""" - pass - - def upcastToSDLNode(self): - """Returns this ptVaultNode as a ptVaultSDLNode""" - pass - - def upcastToSystemNode(self): - """Returns this ptVaultNode as a ptVaultSystemNode""" - pass - - def upcastToTextNoteNode(self): - """Returns this ptVaultNode as ptVaultTextNoteNode""" - pass - -class ptVaultTextNoteNode(ptVaultNode): - """Plasma vault text note node""" - def __init__(self): - """None""" - pass - - def addNode(self,node,cb=None,cbContext=0): - """Adds 'node'(ptVaultNode) as a child to this node.""" - pass - - def findNode(self,templateNode): - """Returns ptVaultNode if child node found matching template, or None""" - pass - - def getChildNodeCount(self): - """Returns how many children this node has.""" - pass - - def getChildNodeRefList(self): - """Returns a list of ptVaultNodeRef that are the children of this node.""" - pass - - def getClientID(self): - """Returns the client's ID.""" - pass - - def getCreateAgeCoords(self): - """Returns the location in the Age where this node was created.""" - pass - - def getCreateAgeGuid(self): - """Returns the guid as a string of the Age where this node was created.""" - pass - - def getCreateAgeName(self): - """Returns the name of the Age where this node was created.""" - pass - - def getCreateAgeTime(self): - """Returns the time in the Age that the node was created...(?)""" - pass - - def getCreateTime(self): - """Returns the when this node was created, that is useable by python's time library.""" - pass - - def getCreatorNode(self): - """Returns the creator's node""" - pass - - def getCreatorNodeID(self): - """Returns the creator's node ID""" - pass - - def getDeviceInbox(self): - """Returns a ptVaultFolderNode""" - pass - - def getID(self): - """Returns the unique ID of this ptVaultNode.""" - pass - - def getModifyTime(self): - """Returns the modified time of this node, that is useable by python's time library.""" - pass - - def getNode(self,id): - """Returns ptVaultNodeRef if is a child node, or None""" - pass - - def getOwnerNode(self): - """Returns a ptVaultNode of the owner of this node""" - pass - - def getOwnerNodeID(self): - """Returns the node ID of the owner of this node""" - pass - - def getSubType(self): - """Returns the subtype of this text note node.""" - pass - - def getText(self): - """Returns the text of this text note node.""" - pass - - def getTextW(self): - """Unicode version of getText.""" - pass - - def getTitle(self): - """Returns the title of this text note node.""" - pass - - def getTitleW(self): - """Unicode version of getTitle""" - pass - - def getType(self): - """Returns the type of text note for this text note node.""" - pass - - def hasNode(self,id): - """Returns true if node if a child node""" - pass - - def linkToNode(self,nodeID,cb=None,cbContext=0): - """Adds a link to the node designated by nodeID""" - pass - - def noteGetSubType(self): - """LEGACY -Returns the subtype of this text note node.""" - pass - - def noteGetText(self): - """LEGACY -Returns the text of this text note node.""" - pass - - def noteGetTitle(self): - """LEGACY -Returns the title of this text note node.""" - pass - - def noteGetType(self): - """LEGACY -Returns the type of text note for this text note node.""" - pass - - def noteSetSubType(self,subType): - """LEGACY -Sets the subtype of the this text note node.""" - pass - - def noteSetText(self,text): - """LEGACY -Sets text of the this text note node.""" - pass - - def noteSetTitle(self,title): - """LEGACY -Sets the title of this text note node.""" - pass - - def noteSetType(self,type): - """LEGACY -Sets the type of text note for this text note node.""" - pass - - def removeAllNodes(self): - """Removes all the child nodes on this node.""" - pass - - def removeNode(self,node,cb=None,cbContext=0): - """Removes the child 'node'(ptVaultNode) from this node.""" - pass - - def save(self,cb=None,cbContext=0): - """Save the changes made to this node.""" - pass - - def saveAll(self,cb=None,cbContext=0): - """Saves this node and all its children nodes.""" - pass - - def sendTo(self,destID,cb=None,cbContext=0): - """Send this node to inbox at 'destID'""" - pass - - def setCreateAgeGuid(self,guid): - """Set guid as a string of the Age where this node was created.""" - pass - - def setCreateAgeName(self,name): - """Set name of the Age where this node was created.""" - pass - - def setCreatorNodeID(self,id): - """Set creator's node ID""" - pass - - def setDeviceInbox(self,inboxName,cb=None,cbContext=0): - """Sets the device inbox""" - pass - - def setID(self,id): - """Sets ID of this ptVaultNode.""" - pass - - def setOwnerNodeID(self,id): - """Set node ID of the owner of this node""" - pass - - def setSubType(self,subType): - """Sets the subtype of the this text note node.""" - pass - - def setText(self,text): - """Sets text of the this text note node.""" - pass - - def setTextW(self,text): - """Unicode version of setText""" - pass - - def setTitle(self,title): - """Sets the title of this text note node.""" - pass - - def setTitleW(self,title): - """Unicode version of setTitle""" - pass - - def setType(self,type): - """Sets the type of text note for this text note node.""" - pass - - def upcastToAgeInfoListNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoListNode""" - pass - - def upcastToAgeInfoNode(self): - """Returns this ptVaultNode as ptVaultAgeInfoNode""" - pass - - def upcastToAgeLinkNode(self): - """Returns this ptVaultNode as ptVaultAgeLinkNode""" - pass - - def upcastToChronicleNode(self): - """Returns this ptVaultNode as ptVaultChronicleNode""" - pass - - def upcastToFolderNode(self): - """Returns this ptVaultNode as ptVaultFolderNode""" - pass - - def upcastToImageNode(self): - """Returns this ptVaultNode as ptVaultImageNode""" - pass - - def upcastToMarkerGameNode(self): - """Returns this ptVaultNode as ptVaultMarkerNode""" - pass - - def upcastToPlayerInfoListNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoListNode""" - pass - - def upcastToPlayerInfoNode(self): - """Returns this ptVaultNode as ptVaultPlayerInfoNode""" - pass - - def upcastToPlayerNode(self): - """Returns this ptVaultNode as a ptVaultPlayerNode""" - pass - - def upcastToSDLNode(self): - """Returns this ptVaultNode as a ptVaultSDLNode""" - pass - - def upcastToSystemNode(self): - """Returns this ptVaultNode as a ptVaultSystemNode""" - pass - - def upcastToTextNoteNode(self): - """Returns this ptVaultNode as ptVaultTextNoteNode""" - pass - -class ptVector3: - """Plasma Point class""" - def __init__(self,x=0, y=0, z=0): - """None""" - pass - - def add(self,other): - """Adds other to the current vector""" - pass - - def copy(self): - """Copies the vector into another one (which it returns)""" - pass - - def crossProduct(self,other): - """Finds the cross product between other and this vector""" - pass - - def dotProduct(self,other): - """Finds the dot product between other and this vector""" - pass - - def getX(self): - """Returns the 'x' component of the vector""" - pass - - def getY(self): - """Returns the 'y' component of the vector""" - pass - - def getZ(self): - """Returns the 'z' component of the vector""" - pass - - def length(self): - """Returns the length of the vector""" - pass - - def lengthSq(self): - """Returns the length of the vector, squared -- this function is faster then length(other)""" - pass - - def normalize(self): - """Normalizes the vector to length 1""" - pass - - def scale(self,scale): - """Scale the vector by scale""" - pass - - def setX(self,x): - """Sets the 'x' component of the vector""" - pass - - def setY(self,y): - """Sets the 'y' component of the vector""" - pass - - def setZ(self,z): - """Sets the 'z' component of the vector""" - pass - - def subtract(self,other): - """Subtracts other from the current vector""" - pass - - def zero(self): - """Zeros the vector's components""" - pass - -class ptWaveSet: - """Creates a new ptWaveSet""" - def __init__(self,ey): - """None""" - pass - - def getDepthFalloff(self): - """Returns the attribute's value""" - pass - - def getEnvCenter(self): - """Returns the attribute's value""" - pass - - def getEnvRadius(self): - """Returns the attribute's value""" - pass - - def getGeoAmpOverLen(self): - """Returns the attribute's value""" - pass - - def getGeoAngleDev(self): - """Returns the attribute's value""" - pass - - def getGeoChop(self): - """Returns the attribute's value""" - pass - - def getGeoMaxLength(self): - """Returns the attribute's value""" - pass - - def getGeoMinLength(self): - """Returns the attribute's value""" - pass - - def getMaxAtten(self): - """Returns the attribute's value""" - pass - - def getMinAtten(self): - """Returns the attribute's value""" - pass - - def getOpacFalloff(self): - """Returns the attribute's value""" - pass - - def getOpacOffset(self): - """Returns the attribute's value""" - pass - - def getReflFalloff(self): - """Returns the attribute's value""" - pass - - def getReflOffset(self): - """Returns the attribute's value""" - pass - - def getRippleScale(self): - """Returns the attribute's value""" - pass - - def getSpecularEnd(self): - """Returns the attribute's value""" - pass - - def getSpecularMute(self): - """Returns the attribute's value""" - pass - - def getSpecularNoise(self): - """Returns the attribute's value""" - pass - - def getSpecularStart(self): - """Returns the attribute's value""" - pass - - def getSpecularTint(self): - """Returns the attribute's value""" - pass - - def getTexAmpOverLen(self): - """Returns the attribute's value""" - pass - - def getTexAngleDev(self): - """Returns the attribute's value""" - pass - - def getTexChop(self): - """Returns the attribute's value""" - pass - - def getTexMaxLength(self): - """Returns the attribute's value""" - pass - - def getTexMinLength(self): - """Returns the attribute's value""" - pass - - def getWaterHeight(self): - """Returns the attribute's value""" - pass - - def getWaterOffset(self): - """Returns the attribute's value""" - pass - - def getWaterOpacity(self): - """Returns the attribute's value""" - pass - - def getWaterTint(self): - """Returns the attribute's value""" - pass - - def getWaveFalloff(self): - """Returns the attribute's value""" - pass - - def getWaveOffset(self): - """Returns the attribute's value""" - pass - - def getWindDir(self): - """Returns the attribute's value""" - pass - - def setDepthFalloff(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setEnvCenter(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setEnvRadius(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setGeoAmpOverLen(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setGeoAngleDev(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setGeoChop(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setGeoMaxLength(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setGeoMinLength(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setMaxAtten(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setMinAtten(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setOpacFalloff(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setOpacOffset(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setReflFalloff(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setReflOffset(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setRippleScale(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setSpecularEnd(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setSpecularMute(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setSpecularNoise(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setSpecularStart(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setSpecularTint(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setTexAmpOverLen(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setTexAngleDev(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setTexChop(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setTexMaxLength(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setTexMinLength(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setWaterHeight(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setWaterOffset(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setWaterOpacity(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setWaterTint(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setWaveFalloff(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setWaveOffset(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - - def setWindDir(self,s, secs = 0): - """Sets the attribute to s over secs time""" - pass - diff --git a/Scripts/Python/plasma/PlasmaConstants.py b/Scripts/Python/plasma/PlasmaConstants.py deleted file mode 100644 index 4e2ec11a..00000000 --- a/Scripts/Python/plasma/PlasmaConstants.py +++ /dev/null @@ -1,256 +0,0 @@ -""" *==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program 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 this program. If not, see . - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - - *==LICENSE==* """ -class Enum: - """Enum base class""" - def __init__(self): - """None""" - pass - -class EnumValue: - """A basic enumeration value""" - def __init__(self): - """None""" - pass - -class PtAIMsgType: - """(none)""" - kUnknown = 0 - kBrainCreated = 1 - kArrivedAtGoal = 2 - -class PtAccountUpdateType: - """(none)""" - kCreatePlayer = 1 - kDeletePlayer = 2 - kUpgradePlayer = 3 - kActivePlayer = 4 - kChangePassword = 5 - -class PtBehaviorTypes: - """(none)""" - kBehaviorTypeFall = 8192 - kBehaviorTypeIdle = 32 - kBehaviorTypeWalkingJump = 2 - kBehaviorTypeSidestepRight = 4096 - kBehaviorTypeRunningJump = 4 - kBehaviorTypeLinkIn = 65536 - kBehaviorTypeAnyJump = 7 - kBehaviorTypeRunningImpact = 8 - kBehaviorTypeWalk = 64 - kBehaviorTypeRun = 128 - kBehaviorTypeTurnRight = 1024 - kBehaviorTypeWalkBack = 256 - kBehaviorTypeMovingTurnLeft = 16384 - kBehaviorTypeGroundImpact = 16 - kBehaviorTypeStandingJump = 1 - kBehaviorTypeTurnLeft = 512 - kBehaviorTypeAnyImpact = 24 - kBehaviorTypeSidestepLeft = 2048 - kBehaviorTypeMovingTurnRight = 32768 - kBehaviorTypeLinkOut = 131072 - -class PtBookEventTypes: - """(none)""" - kNotifyImageLink = 0 - kNotifyShow = 1 - kNotifyHide = 2 - kNotifyNextPage = 3 - kNotifyPreviousPage = 4 - kNotifyCheckUnchecked = 5 - kNotifyClose = 6 - -class PtBrainModes: - """(none)""" - kGeneric = 0 - kLadder = 1 - kSit = 2 - kEmote = 3 - kAFK = 4 - kNonGeneric = 5 - -class PtButtonNotifyTypes: - """(none)""" - kNotifyOnUp = 0 - kNotifyOnDown = 1 - kNotifyOnUpAndDown = 2 - -class PtCCRPetitionType: - """(none)""" - kGeneralHelp = 0 - kBug = 1 - kFeedback = 2 - kExploit = 3 - kHarass = 4 - kStuck = 5 - kTechnical = 6 - -class PtEventType: - """(none)""" - kCollision = 1 - kPicked = 2 - kControlKey = 3 - kVariable = 4 - kFacing = 5 - kContained = 6 - kActivate = 7 - kCallback = 8 - kResponderState = 9 - kMultiStage = 10 - kSpawned = 11 - kClickDrag = 12 - kOfferLinkingBook = 14 - kBook = 15 - -class PtGUIMultiLineDirection: - """(none)""" - kLineStart = 1 - kLineEnd = 2 - kBufferStart = 3 - kBufferEnd = 4 - kOneBack = 5 - kOneForward = 6 - kOneWordBack = 7 - kOneWordForward = 8 - kOneLineUp = 9 - kOneLineDown = 10 - kPageUp = 11 - kPageDown = 12 - -class PtGameScoreTypes: - """(none)""" - kFixed = 0 - kAccumulative = 1 - kAccumAllowNegative = 2 - -class PtJustify: - """(none)""" - kLeftJustify = 0 - kCenter = 1 - kRightJustify = 2 - -class PtLOSObjectType: - """(none)""" - kClickables = 0 - kCameraBlockers = 1 - kCustom = 2 - kShootable = 3 - -class PtLOSReportType: - """(none)""" - kReportHit = 0 - kReportMiss = 1 - kReportHitOrMiss = 2 - -class PtLanguage: - """(none)""" - kEnglish = 0 - kFrench = 1 - kGerman = 2 - kSpanish = 3 - kItalian = 4 - kJapanese = 5 - kNumLanguages = 6 - -class PtMarkerMsgType: - """(none)""" - kMarkerCaptured = 0 - -class PtMovieEventReason: - """(none)""" - kMovieDone = 0 - -class PtMultiStageEventType: - """(none)""" - kEnterStage = 1 - kBeginingOfLoop = 2 - kAdvanceNextStage = 3 - kRegressPrevStage = 4 - -class PtNotificationType: - """(none)""" - kActivator = 0 - kVarNotification = 1 - kNotifySelf = 2 - kResponderFF = 3 - kResponderChangeState = 4 - -class PtNotifyDataType: - """(none)""" - kNumber = 1 - kKey = 2 - -class PtSDLReadWriteOptions: - """(none)""" - kTimeStampOnRead = 16 - kDirtyOnly = 1 - kSkipNotificationInfo = 2 - kBroadcast = 4 - -class PtSDLVarType: - """(none)""" - kInt = 0 - kFloat = 1 - kBool = 2 - kString32 = 3 - kKey = 4 - kStateDescriptor = 5 - kCreatable = 6 - kDouble = 7 - kTime = 8 - kByte = 9 - kShort = 10 - kVector3 = 50 - kPoint3 = 51 - kRGB = 52 - kRGBA = 53 - kQuaternion = 54 - kNone = -1 - -class PtScoreRankGroups: - """(none)""" - kIndividual = 0 - kNeighborhood = 1 - -class PtScoreTimePeriods: - """(none)""" - kOverall = 0 - kYear = 1 - kMonth = 2 - kDay = 3 - -class PtStatusLogFlags: - """(none)""" - kDebugOutput = 32 - kFilledBackground = 1 - kAppendToLast = 2 - kDontWriteFile = 4 - kDeleteForMe = 8 - kTimestamp = 64 - kStdout = 128 - kTimeInSeconds = 256 - kAlignToTop = 16 - kTimeAsDouble = 512 - diff --git a/Scripts/Python/plasma/PlasmaControlKeys.py b/Scripts/Python/plasma/PlasmaControlKeys.py deleted file mode 100644 index 11b56e69..00000000 --- a/Scripts/Python/plasma/PlasmaControlKeys.py +++ /dev/null @@ -1,108 +0,0 @@ -""" *==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program 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 this program. If not, see . - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - - *==LICENSE==* """ -""" -This module is the constants for the controlKeys that are is a parameter in the OnKeyEvent callback -""" - -# OnControlKeyEvent controlKey types -kKeyAction=0 -kKeyActionMouse=1 -kKeyJump=2 -kKeyMoveForward=3 -kKeyMoveBackward=4 -kKeyStrafeLeft=5 -kKeyStrafeRight=6 -kKeyMoveUp=7 -kKeyMoveDown=8 -kKeyRotateLeft=9 -kKeyRotateRight=10 -kKeyRotateUp=11 -kKeyRotateDown=12 -kKeyModFast=13 -kKeyAlwaysRun=14 -kKeyEquip=15 -kKeyDrop=16 -kKeyTurnTo=17 -kKeyDriveMode=18 -kKeyCamMoveForward=19 -kKeyCamMoveBackward=20 -kKeyCamMoveUp=21 -kKeyCamMoveDown=22 -kKeyCamMoveLeft=23 -kKeyCamMoveRight=24 -kKeyCamPanUp=25 -kKeyCamPanDown=26 -kKeyCamPanLeft=27 -kKeyCamPanRight=28 -kKeyCamMoveFast=29 -kKeyCamRotateRight=30 -kKeyCamRotateLeft=31 -kKeyCamRotateUp=32 -kKeyCamRotateDown=33 -kKeyCamRecenter=34 -kKeyCamSpeedUp=35 -kKeyCamSpeedDown=36 -kKeyCamZoomIn=37 -kKeyCamZoomOut=38 -kKeyCamConsoleMode=39 -kKeyConsoleCommand=40 -kKeyTogglePhysical=41 -kKeyPick=42 -# axis controls -kKeyMove=43 -kKeyTurn=44 -kKeyMouseX=45 -kKeyMouseY=46 -# special controls -kKeySetCursorUp=47 -kKeySetCursorDown=48 -kKeySetCursorRight=49 -kKeySetCursorLeft=50 -kKeySetCursorPoised=51 -kKeySetCursorHidden=52 -kKeySetCursorUnhidden=53 -kKeySetCursorArrow=54 -kKeySearchForPickable=55 -kKeyIncreaseMicVol=56 -kKeyDecreaseMicVol=57 -kKeyPushToTalk=58 -kKeySetThirdPersonMode=59 -kKeySetFirstPersonMode=60 -kKeySetWalkMode=61 -kKeySetFreeLook=62 -kKeySetConsoleSingle=63 -kKeySetConsoleHidden=64 -# Inventory controls -dead__kKeySetEquipedState=65 -dead__kKeyScrollUpList=66 -dead__kKeyScrollDownList=67 -dead__kKeySetInventoryActive=68 -dead__kKeySetInventoryDisActive=69 -dead__kKeyRemoveInventoryObject=70 -dead__kKeyEnableObject=71 -# Avatar emote controls -kKeyEmote=72 -kKeyExitMode=73 diff --git a/Scripts/Python/plasma/PlasmaGame.py b/Scripts/Python/plasma/PlasmaGame.py deleted file mode 100644 index 8a709a95..00000000 --- a/Scripts/Python/plasma/PlasmaGame.py +++ /dev/null @@ -1,2615 +0,0 @@ -""" *==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program 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 this program. If not, see . - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - - *==LICENSE==* """ -def PtCreateMarkerGame(callbackKey, gameType, gameName = "", timeLimit = 0, templateId = ""): - """Creates a new Marker game with the specified callback key, game type (from PtMarkerGameTypes), time limit (in ms), and template id (guid string)""" - pass - -def PtCreateTTTGame(callbackKey, numPlayers): - """Creates a new TicTacToe game with the specified callback key and number of players (1 or 2)""" - pass - -def PtGetGameCli(gameID): - """Returns a ptGameCli associated with the specified id""" - pass - -def PtGetGameIDs(): - """Returns a list of game IDs that the player is currently joined to""" - pass - -def PtGetGameNameByTypeID(guid): - """Returns the name of the game represented by guid passed in as a string""" - pass - -def PtIsBlueSpiralGame(typeID): - """Returns true if the specifed typeID (guid as a string) is a BlueSpiral game""" - pass - -def PtIsClimbingWallGame(typeID): - """Returns true if the specifed typeID (guid as a string) is a ClimbingWall game""" - pass - -def PtIsHeekGame(typeID): - """Returns true if the specifed typeID (guid as a string) is a Heek game""" - pass - -def PtIsMarkerGame(typeID): - """Returns true if the specifed typeID (guid as a string) is a Marker game""" - pass - -def PtIsTTTGame(typeID): - """Returns true if the specifed typeID (guid as a string) is a TicTacToe game""" - pass - -def PtIsVarSyncGame(typeID): - """Returns true if the specifed typeID (guid as a string) is a VarSync game""" - pass - -def PtJoinCommonBlueSpiralGame(callbackKey, gameID): - """Joins a common BlueSpiral game with the specified ID. If one doesn't exist, it creates it""" - pass - -def PtJoinCommonClimbingWallGame(callbackKey, gameID): - """Joins a common ClimbingWall game with the specified ID. If one doesn't exist, it creates it""" - pass - -def PtJoinCommonHeekGame(callbackKey, gameID): - """Joins a common Heek game with the specified ID. If one doesn't exist, it creates it""" - pass - -def PtJoinCommonTTTGame(callbackKey, gameID, numPlayers): - """Joins a common TicTacToe game with the specified ID. If one doesn't exist, it creates it with the specified number of players""" - pass - -def PtJoinCommonVarSyncGame(callbackKey): - """Joins the common VarSync game. If one doesn't exist, it creates it""" - pass - -def PtJoinGame(callbackKey, gameID): - """Sends a join request to the specified game. Messages are sent to the callback key""" - pass - -class ptGameCliMsg: - """Message from the game server from a game""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptBlueSpiralMsg(ptGameCliMsg): - """Base class for BlueSpiral game messages""" - def __init__(self): - """None""" - pass - - def getBlueSpiralMsgType(self): - """Returns the type of the BlueSpiral message (see PtBlueSpiralMsgTypes)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalBlueSpiralMsg(self): - """Returns this message as the BlueSpiral message it really is""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptBlueSpiralClothOrderMsg(ptBlueSpiralMsg): - """BlueSpiral message received when the game is started and the cloth order is set""" - def __init__(self): - """None""" - pass - - def getBlueSpiralMsgType(self): - """Returns the type of the BlueSpiral message (see PtBlueSpiralMsgTypes)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def order(self): - """Returns a list of numbers indicating the correct order to hit the clothes in""" - pass - - def upcastToFinalBlueSpiralMsg(self): - """Returns this message as the BlueSpiral message it really is""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptGameCli: - """Base class for all game client interfaces""" - def __init__(self): - """None""" - pass - - def gameID(self): - """Returns the ID number for this game""" - pass - - def gameTypeID(self): - """Returns the game type ID for this game (as a guid string)""" - pass - - def invitePlayer(self,playerID): - """Invites the specified player to join the game""" - pass - - def leaveGame(self): - """Leaves this game""" - pass - - def name(self): - """Returns the name of the game""" - pass - - def playerCount(self): - """Returns the current number of players""" - pass - - def uninvitePlayer(self,playerID): - """Revokes the invitation for the specified player""" - pass - - def upcastToBlueSpiralGame(self): - """Returns this game client as a ptBlueSpiralGame""" - pass - - def upcastToClimbingWallGame(self): - """Returns this game client as a ptClimbingWallGame""" - pass - - def upcastToHeekGame(self): - """Returns this game client as a ptHeekGame""" - pass - - def upcastToMarkerGame(self): - """Returns this game client as a ptMarkerGame""" - pass - - def upcastToTTTGame(self): - """Returns this game client as a ptTTTGame""" - pass - - def upcastToVarSyncGame(self): - """Returns this game client as a ptVarSyncGame""" - pass - -class ptBlueSpiralGame(ptGameCli): - """Game client for the BlueSpiral game""" - def __init__(self): - """None""" - pass - - def gameID(self): - """Returns the ID number for this game""" - pass - - def gameTypeID(self): - """Returns the game type ID for this game (as a guid string)""" - pass - - def hitCloth(self,clothNum): - """Tells the server you hit the specified cloth""" - pass - - def invitePlayer(self,playerID): - """Invites the specified player to join the game""" - pass - - def leaveGame(self): - """Leaves this game""" - pass - - def name(self): - """Returns the name of the game""" - pass - - def playerCount(self): - """Returns the current number of players""" - pass - - def startGame(self): - """Starts a new game""" - pass - - def uninvitePlayer(self,playerID): - """Revokes the invitation for the specified player""" - pass - - def upcastToBlueSpiralGame(self): - """Returns this game client as a ptBlueSpiralGame""" - pass - - def upcastToClimbingWallGame(self): - """Returns this game client as a ptClimbingWallGame""" - pass - - def upcastToHeekGame(self): - """Returns this game client as a ptHeekGame""" - pass - - def upcastToMarkerGame(self): - """Returns this game client as a ptMarkerGame""" - pass - - def upcastToTTTGame(self): - """Returns this game client as a ptTTTGame""" - pass - - def upcastToVarSyncGame(self): - """Returns this game client as a ptVarSyncGame""" - pass - -class ptBlueSpiralGameOverMsg(ptBlueSpiralMsg): - """BlueSpiral message received when the timer runs out, someone hits the wrong cloth, or the game is restarted (before a game start msg in that last case)""" - def __init__(self): - """None""" - pass - - def getBlueSpiralMsgType(self): - """Returns the type of the BlueSpiral message (see PtBlueSpiralMsgTypes)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalBlueSpiralMsg(self): - """Returns this message as the BlueSpiral message it really is""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptBlueSpiralGameStartedMsg(ptBlueSpiralMsg): - """BlueSpiral message received when someone starts the game (or when you join a game that is running)""" - def __init__(self): - """None""" - pass - - def getBlueSpiralMsgType(self): - """Returns the type of the BlueSpiral message (see PtBlueSpiralMsgTypes)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def startSpin(self): - """Returns true if you are supposed to start spinning the door thingy""" - pass - - def upcastToFinalBlueSpiralMsg(self): - """Returns this message as the BlueSpiral message it really is""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptBlueSpiralGameWonMsg(ptBlueSpiralMsg): - """BlueSpiral message received when the last cloth is successfully hit""" - def __init__(self): - """None""" - pass - - def getBlueSpiralMsgType(self): - """Returns the type of the BlueSpiral message (see PtBlueSpiralMsgTypes)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalBlueSpiralMsg(self): - """Returns this message as the BlueSpiral message it really is""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptBlueSpiralSuccessfulHitMsg(ptBlueSpiralMsg): - """BlueSpiral message received when a cloth is hit in the correct order""" - def __init__(self): - """None""" - pass - - def getBlueSpiralMsgType(self): - """Returns the type of the BlueSpiral message (see PtBlueSpiralMsgTypes)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalBlueSpiralMsg(self): - """Returns this message as the BlueSpiral message it really is""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptClimbingWallMsg(ptGameCliMsg): - """Base class for ClimbingWall game messages""" - def __init__(self): - """None""" - pass - - def getClimbingWallMsgType(self): - """Returns the type of the ClimbingWall message (see PtClimbingWallMsgTypes)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalClimbingWallMsg(self): - """Returns this message as the ClimbingWall msg it is""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptClimbingWallBlockersChangedMsg(ptClimbingWallMsg): - """ClimbingWall message received when the blocker state changes""" - def __init__(self): - """None""" - pass - - def blockersSet(self): - """Returns an array of blocker indicies denoting which blockers are set""" - pass - - def getClimbingWallMsgType(self): - """Returns the type of the ClimbingWall message (see PtClimbingWallMsgTypes)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def localOnly(self): - """Returns true if we are only supposed to adjust our stuff locally, and not net-prop it""" - pass - - def teamNumber(self): - """The team that this message is for""" - pass - - def upcastToFinalClimbingWallMsg(self): - """Returns this message as the ClimbingWall msg it is""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptClimbingWallGame(ptGameCli): - """Game client for the ClimbingWall game""" - def __init__(self): - """None""" - pass - - def changeBlocker(self,teamNumber, blockerNumber, added): - """Changes the specified marker's state for the specified team""" - pass - - def changeNumBlockers(self,amountToAdjust): - """Adjusts the number of blockers we are playing with""" - pass - - def finishedGame(self): - """Tells the server you reached the top of the wall""" - pass - - def gameID(self): - """Returns the ID number for this game""" - pass - - def gameTypeID(self): - """Returns the game type ID for this game (as a guid string)""" - pass - - def invitePlayer(self,playerID): - """Invites the specified player to join the game""" - pass - - def leaveGame(self): - """Leaves this game""" - pass - - def name(self): - """Returns the name of the game""" - pass - - def panic(self): - """Tells the server you are panicking and want your blockers reset""" - pass - - def playerCount(self): - """Returns the current number of players""" - pass - - def playerEntered(self,teamNumber): - """Tells the server that you are trying to play the game for the specified team""" - pass - - def ready(self,readyType, teamNumber): - """Marks the specified team as ready for the specified type (See PtClimbingWallReadyTypes)""" - pass - - def reset(self): - """Attempts to reset the game's control panel""" - pass - - def uninvitePlayer(self,playerID): - """Revokes the invitation for the specified player""" - pass - - def upcastToBlueSpiralGame(self): - """Returns this game client as a ptBlueSpiralGame""" - pass - - def upcastToClimbingWallGame(self): - """Returns this game client as a ptClimbingWallGame""" - pass - - def upcastToHeekGame(self): - """Returns this game client as a ptHeekGame""" - pass - - def upcastToMarkerGame(self): - """Returns this game client as a ptMarkerGame""" - pass - - def upcastToTTTGame(self): - """Returns this game client as a ptTTTGame""" - pass - - def upcastToVarSyncGame(self): - """Returns this game client as a ptVarSyncGame""" - pass - -class ptClimbingWallGameOverMsg(ptClimbingWallMsg): - """ClimbingWall message received when the game is over""" - def __init__(self): - """None""" - pass - - def getClimbingWallMsgType(self): - """Returns the type of the ClimbingWall message (see PtClimbingWallMsgTypes)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def localOnly(self): - """Returns true if we are only supposed to adjust our stuff locally, and not net-prop it""" - pass - - def team1Blockers(self): - """Returns an array of blocker indicies denoting which blockers team 1 set""" - pass - - def team2Blockers(self): - """Returns an array of blocker indicies denoting which blockers team 2 set""" - pass - - def teamWon(self): - """The team that won the game""" - pass - - def upcastToFinalClimbingWallMsg(self): - """Returns this message as the ClimbingWall msg it is""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptClimbingWallNumBlockersChangedMsg(ptClimbingWallMsg): - """ClimbingWall message received when the number of blockers is changed""" - def __init__(self): - """None""" - pass - - def getClimbingWallMsgType(self): - """Returns the type of the ClimbingWall message (see PtClimbingWallMsgTypes)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def localOnly(self): - """Returns true if we are only supposed to adjust our stuff locally, and not net-prop it""" - pass - - def newBlockerCount(self): - """Returns the number of blockers this game is current running with""" - pass - - def upcastToFinalClimbingWallMsg(self): - """Returns this message as the ClimbingWall msg it is""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptClimbingWallPlayerEnteredMsg(ptClimbingWallMsg): - """ClimbingWall message received when you successfully enter the suit machine""" - def __init__(self): - """None""" - pass - - def getClimbingWallMsgType(self): - """Returns the type of the ClimbingWall message (see PtClimbingWallMsgTypes)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalClimbingWallMsg(self): - """Returns this message as the ClimbingWall msg it is""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptClimbingWallReadyMsg(ptClimbingWallMsg): - """ClimbingWall message received when the ready state of the teams is changed""" - def __init__(self): - """None""" - pass - - def getClimbingWallMsgType(self): - """Returns the type of the ClimbingWall message (see PtClimbingWallMsgTypes)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def localOnly(self): - """Returns true if we are only supposed to adjust our stuff locally, and not net-prop it""" - pass - - def readyType(self): - """The type of ready message this represents (see PtClimbingWallReadyTypes)""" - pass - - def team1Ready(self): - """Whether team 1 is ready or not""" - pass - - def team2Ready(self): - """Whether team 2 is ready or not""" - pass - - def upcastToFinalClimbingWallMsg(self): - """Returns this message as the ClimbingWall msg it is""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptClimbingWallSuitMachineLockedMsg(ptClimbingWallMsg): - """ClimbingWall message received when the locked state of the suit machines is changed""" - def __init__(self): - """None""" - pass - - def getClimbingWallMsgType(self): - """Returns the type of the ClimbingWall message (see PtClimbingWallMsgTypes)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def localOnly(self): - """Returns true if we are only supposed to adjust our stuff locally, and not net-prop it""" - pass - - def team1MachineLocked(self): - """Whether team 1's suit machine is locked or not""" - pass - - def team2MachineLocked(self): - """Whether team 2's suit machine is locked or not""" - pass - - def upcastToFinalClimbingWallMsg(self): - """Returns this message as the ClimbingWall msg it is""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptGameCliInviteFailedMsg(ptGameCliMsg): - """Game client message when an invite failed message is received""" - def __init__(self): - """None""" - pass - - def error(self): - """Returns the error value (See PtGameCliInviteErrors)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def inviteeID(self): - """Returns the invitee's ID number""" - pass - - def operationID(self): - """Returns the operation's ID number""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptGameCliOwnerChangeMsg(ptGameCliMsg): - """Game client message when a owner change message is received""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def ownerID(self): - """Returns the owner's ID number""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptGameCliPlayerJoinedMsg(ptGameCliMsg): - """Game client message when a player joined message is received""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def playerID(self): - """Returns the player's ID number""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptGameCliPlayerLeftMsg(ptGameCliMsg): - """Game client message when a player left message is received""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def playerID(self): - """Returns the player's ID number""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptGameMgrMsg: - """Message from the game manager""" - def __init__(self): - """None""" - pass - - def getType(self): - """Returns the type of the message (see PtGameMgrMsgTypes)""" - pass - - def upcastToInviteReceivedMsg(self): - """Returns this message as a ptGameMgrInviteReceivedMsg""" - pass - - def upcastToInviteRevokedMsg(self): - """Returns this message as a ptGameMgrInviteRevokedMsg""" - pass - -class ptGameMgrInviteReceivedMsg(ptGameMgrMsg): - """Game manager message when an invite is received""" - def __init__(self): - """None""" - pass - - def gameTypeID(self): - """Returns the game type ID (as a guid string)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameMgrMsgTypes)""" - pass - - def inviterID(self): - """Returns the inviter's ID number""" - pass - - def newGameID(self): - """Returns the new game's ID number""" - pass - - def upcastToInviteReceivedMsg(self): - """Returns this message as a ptGameMgrInviteReceivedMsg""" - pass - - def upcastToInviteRevokedMsg(self): - """Returns this message as a ptGameMgrInviteRevokedMsg""" - pass - -class ptGameMgrInviteRevokedMsg(ptGameMgrMsg): - """Game manager message when an invite is received""" - def __init__(self): - """None""" - pass - - def gameTypeID(self): - """Returns the game type ID (as a guid string)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameMgrMsgTypes)""" - pass - - def inviterID(self): - """Returns the inviter's ID number""" - pass - - def newGameID(self): - """Returns the new game's ID number""" - pass - - def upcastToInviteReceivedMsg(self): - """Returns this message as a ptGameMgrInviteReceivedMsg""" - pass - - def upcastToInviteRevokedMsg(self): - """Returns this message as a ptGameMgrInviteRevokedMsg""" - pass - -class ptHeekMsg(ptGameCliMsg): - """Base class for Heek game messages""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getHeekMsgType(self): - """Returns the type of the Heek message (see PtHeekMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalHeekMsg(self): - """Returns this message as the Heek message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptHeekCountdownStateMsg(ptHeekMsg): - """Heek message received by game admin when the countdown state needs to change""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getHeekMsgType(self): - """Returns the type of the Heek message (see PtHeekMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def state(self): - """Returns state the countdown should be switched to (see PtHeekCountdownStates)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalHeekMsg(self): - """Returns this message as the Heek message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptHeekDropMsg(ptHeekMsg): - """Heek message received when another player's position needs to be reset/modified""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getHeekMsgType(self): - """Returns the type of the Heek message (see PtHeekMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def position(self): - """Returns player position to cleanup and dump""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalHeekMsg(self): - """Returns this message as the Heek message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptHeekGame(ptGameCli): - """Game client for the Heek game""" - def __init__(self): - """None""" - pass - - def choose(self,choice): - """Makes the specified move (see PtHeekGameChoice)""" - pass - - def gameID(self): - """Returns the ID number for this game""" - pass - - def gameTypeID(self): - """Returns the game type ID for this game (as a guid string)""" - pass - - def invitePlayer(self,playerID): - """Invites the specified player to join the game""" - pass - - def leaveGame(self): - """Leaves this game (puts us into "observer" mode""" - pass - - def name(self): - """Returns the name of the game""" - pass - - def playGame(self,position, points, name): - """Requests to start playing the game in the specified position""" - pass - - def playerCount(self): - """Returns the current number of players""" - pass - - def sequenceFinished(self,sequence): - """Tells the server that the specified animation finished (see PtHeekGameSeq)""" - pass - - def uninvitePlayer(self,playerID): - """Revokes the invitation for the specified player""" - pass - - def upcastToBlueSpiralGame(self): - """Returns this game client as a ptBlueSpiralGame""" - pass - - def upcastToClimbingWallGame(self): - """Returns this game client as a ptClimbingWallGame""" - pass - - def upcastToHeekGame(self): - """Returns this game client as a ptHeekGame""" - pass - - def upcastToMarkerGame(self): - """Returns this game client as a ptMarkerGame""" - pass - - def upcastToTTTGame(self): - """Returns this game client as a ptTTTGame""" - pass - - def upcastToVarSyncGame(self): - """Returns this game client as a ptVarSyncGame""" - pass - -class ptHeekGameWinMsg(ptHeekMsg): - """Heek message received by game admin when a game is won""" - def __init__(self): - """None""" - pass - - def choice(self): - """Returns the choice that won (see PtHeekGameChoice)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getHeekMsgType(self): - """Returns the type of the Heek message (see PtHeekMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalHeekMsg(self): - """Returns this message as the Heek message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptHeekGoodbyeMsg(ptHeekMsg): - """Heek message received when the server processes leave request""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getHeekMsgType(self): - """Returns the type of the Heek message (see PtHeekMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalHeekMsg(self): - """Returns this message as the Heek message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptHeekInterfaceStateMsg(ptHeekMsg): - """Heek message received when your interface buttons need to enable or disable""" - def __init__(self): - """None""" - pass - - def buttonsEnabled(self): - """Returns whether your buttons should be enabled""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getHeekMsgType(self): - """Returns the type of the Heek message (see PtHeekMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalHeekMsg(self): - """Returns this message as the Heek message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptHeekLightStateMsg(ptHeekMsg): - """Heek message received when one of your local lights needs to change state""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getHeekMsgType(self): - """Returns the type of the Heek message (see PtHeekMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def lightNum(self): - """Returns the index of the light this refers to""" - pass - - def state(self): - """Returns state the light should be switched to (see PtHeekLightStates)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalHeekMsg(self): - """Returns this message as the Heek message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptHeekPlayGameMsg(ptHeekMsg): - """Heek message received when the server processes your play game request""" - def __init__(self): - """None""" - pass - - def enableButtons(self): - """Returns true if we should enable the buttons at the place we sat down""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getHeekMsgType(self): - """Returns the type of the Heek message (see PtHeekMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def isPlaying(self): - """Returns true if the server accepted the play game request""" - pass - - def isSinglePlayer(self): - """Returns true if you are the only player at the table""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalHeekMsg(self): - """Returns this message as the Heek message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptHeekPointUpdateMsg(ptHeekMsg): - """Heek message received when the number of points you have needs to be changed""" - def __init__(self): - """None""" - pass - - def displayUpdate(self): - """Returns whether you should display a message to the user""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getHeekMsgType(self): - """Returns the type of the Heek message (see PtHeekMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def points(self): - """Returns your new amount of points""" - pass - - def rank(self): - """Returns your new rank""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalHeekMsg(self): - """Returns this message as the Heek message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptHeekSetupMsg(ptHeekMsg): - """Heek message for setting up each position's state""" - def __init__(self): - """None""" - pass - - def buttonState(self): - """Returns whether the buttons are enabled or not""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getHeekMsgType(self): - """Returns the type of the Heek message (see PtHeekMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def lightOn(self): - """Returns a list of bools representing lights on or off""" - pass - - def position(self): - """Returns the position this message is for""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalHeekMsg(self): - """Returns this message as the Heek message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptHeekWelcomeMsg(ptHeekMsg): - """Heek message received when a new player sits down""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getHeekMsgType(self): - """Returns the type of the Heek message (see PtHeekMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def name(self): - """Returns the new player's name""" - pass - - def points(self): - """Returns the new player's points""" - pass - - def rank(self): - """Returns the new player's rank""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalHeekMsg(self): - """Returns this message as the Heek message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptHeekWinLoseMsg(ptHeekMsg): - """Heek message received when the round is over and you won or lost""" - def __init__(self): - """None""" - pass - - def choice(self): - """Returns the choice that won or lost (see PtHeekGameChoice)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getHeekMsgType(self): - """Returns the type of the Heek message (see PtHeekMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalHeekMsg(self): - """Returns this message as the Heek message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - - def win(self): - """Returns true if you won""" - pass - -class ptMarkerGame(ptGameCli): - """Game client for the Marker game""" - def __init__(self): - """None""" - pass - - def addMarker(self,x, y, z, name = "", age = ""): - """Adds a marker to the game. Age is ignored in a non-quest game. Won't work if you're not the owner/creator""" - pass - - def captureMarker(self,markerId): - """Captures the specified marker""" - pass - - def changeGameName(self,newName): - """Changes the name of the game. Won't work if you're not the game owner/creator""" - pass - - def changeMarkerName(self,markerId, newName): - """Changes the name of the specified marker. Won't work if you're not the game owner/creator""" - pass - - def changeTimeLimit(self,newTimeLimit): - """Changes the time limit on the game (in ms). Won't work if you're not the game owner/creator, or if it's a quest game""" - pass - - def deleteGame(self): - """Tells the server to delete the game. Won't work if you're not the game owner/creator""" - pass - - def deleteMarker(self,markerId): - """Deletes the specified marker from the game. Won't work if you're not the game owner/creator""" - pass - - def gameID(self): - """Returns the ID number for this game""" - pass - - def gameTypeID(self): - """Returns the game type ID for this game (as a guid string)""" - pass - - def invitePlayer(self,playerID): - """Invites the specified player to join the game""" - pass - - def leaveGame(self): - """Leaves this game""" - pass - - def name(self): - """Returns the name of the game""" - pass - - def pauseGame(self): - """Pauses the game. Won't work on MP games if you're not the owner/creator""" - pass - - def playerCount(self): - """Returns the current number of players""" - pass - - def resetGame(self): - """Resets the game. Won't work on MP games if you're not the owner/creator""" - pass - - def startGame(self): - """Starts the game. Won't work on MP games if you're not the owner/creator""" - pass - - def uninvitePlayer(self,playerID): - """Revokes the invitation for the specified player""" - pass - - def upcastToBlueSpiralGame(self): - """Returns this game client as a ptBlueSpiralGame""" - pass - - def upcastToClimbingWallGame(self): - """Returns this game client as a ptClimbingWallGame""" - pass - - def upcastToHeekGame(self): - """Returns this game client as a ptHeekGame""" - pass - - def upcastToMarkerGame(self): - """Returns this game client as a ptMarkerGame""" - pass - - def upcastToTTTGame(self): - """Returns this game client as a ptTTTGame""" - pass - - def upcastToVarSyncGame(self): - """Returns this game client as a ptVarSyncGame""" - pass - -class ptMarkerMsg(ptGameCliMsg): - """Base class for Marker game messages""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptMarkerGameDeletedMsg(ptMarkerMsg): - """Marker message received when the game is deleted""" - def __init__(self): - """None""" - pass - - def failed(self): - """Returns whether the delete succeeded or not""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptMarkerGameNameChangedMsg(ptMarkerMsg): - """Marker message received when the game name is changed""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def name(self): - """Returns the new game name""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptMarkerGameOverMsg(ptMarkerMsg): - """Marker message received when the server determines the game is over (usually via timeout)""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptMarkerGamePausedMsg(ptMarkerMsg): - """Marker message received when the game is paused by the owner""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def timeLeft(self): - """Returns the amount of time left on the server clock""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptMarkerGameResetMsg(ptMarkerMsg): - """Marker message received when the game is reset by the owner""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptMarkerGameStartedMsg(ptMarkerMsg): - """Marker message received when the game is started by the owner""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptMarkerGameTypeMsg(ptMarkerMsg): - """Marker message received when you are assigned a team number""" - def __init__(self): - """None""" - pass - - def gameType(self): - """Returns the type of the game you just joined""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptMarkerMarkerAddedMsg(ptMarkerMsg): - """Marker message received when a marker is added to the game""" - def __init__(self): - """None""" - pass - - def age(self): - """Returns the age the marker was created in""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def markerId(self): - """Returns the id number of the marker""" - pass - - def name(self): - """Returns the name of the marker""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - - def x(self): - """Returns x coord of the marker""" - pass - - def y(self): - """Returns y coord of the marker""" - pass - - def z(self): - """Returns z coord of the marker""" - pass - -class ptMarkerMarkerCapturedMsg(ptMarkerMsg): - """Marker message received when a marker is captured""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def markerId(self): - """Returns id of the marker which was captured""" - pass - - def team(self): - """Returns the team number of the team that captured it (0 for no team, or a quest game)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptMarkerMarkerDeletedMsg(ptMarkerMsg): - """Marker message received when a marker is deleted""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def markerId(self): - """Returns id of the marker that was deleted""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptMarkerMarkerNameChangedMsg(ptMarkerMsg): - """Marker message received when the name of a marker is changed""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def markerId(self): - """Returns id of the marker who's name was changed""" - pass - - def name(self): - """Returns the new name""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptMarkerTeamAssignedMsg(ptMarkerMsg): - """Marker message received when you are assigned a team number""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def teamNumber(self): - """Returns the number of the team you were assigned to""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptMarkerTemplateCreatedMsg(ptMarkerMsg): - """Marker message received when a quest game template is created""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def templateID(self): - """Returns the ID number of the template that was created""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptMarkerTimeLimitChangedMsg(ptMarkerMsg): - """Marker message received when the game name is changed""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getMarkerMsgType(self): - """Returns the type of the Marker message (see PtMarkerMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def timeLimit(self): - """Returns the new time limit (in ms)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalMarkerMsg(self): - """Returns this message as the Marker message it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptTTTGame(ptGameCli): - """Game client for the TicTacToe game""" - def __init__(self): - """None""" - pass - - def gameID(self): - """Returns the ID number for this game""" - pass - - def gameTypeID(self): - """Returns the game type ID for this game (as a guid string)""" - pass - - def invitePlayer(self,playerID): - """Invites the specified player to join the game""" - pass - - def leaveGame(self): - """Leaves this game""" - pass - - def makeMove(self,row, col): - """Makes a move in the specified spot""" - pass - - def name(self): - """Returns the name of the game""" - pass - - def playerCount(self): - """Returns the current number of players""" - pass - - def showBoard(self): - """Prints the current board layout to the console""" - pass - - def uninvitePlayer(self,playerID): - """Revokes the invitation for the specified player""" - pass - - def upcastToBlueSpiralGame(self): - """Returns this game client as a ptBlueSpiralGame""" - pass - - def upcastToClimbingWallGame(self): - """Returns this game client as a ptClimbingWallGame""" - pass - - def upcastToHeekGame(self): - """Returns this game client as a ptHeekGame""" - pass - - def upcastToMarkerGame(self): - """Returns this game client as a ptMarkerGame""" - pass - - def upcastToTTTGame(self): - """Returns this game client as a ptTTTGame""" - pass - - def upcastToVarSyncGame(self): - """Returns this game client as a ptVarSyncGame""" - pass - -class ptTTTMsg(ptGameCliMsg): - """Base class for TicTacToe game messages""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getTTTMsgType(self): - """Returns the type of the TTT message (see PtTTTMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalTTTMsg(self): - """Returns this message as the TTT msg it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptTTTGameOverMsg(ptTTTMsg): - """TicTacToe message received when the game is over""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getTTTMsgType(self): - """Returns the type of the TTT message (see PtTTTMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def result(self): - """Returns the result of the game (see PtTTTGameResult)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalTTTMsg(self): - """Returns this message as the TTT msg it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - - def winnerID(self): - """Returns the winner's ID""" - pass - -class ptTTTGameStartedMsg(ptTTTMsg): - """TicTacToe message received when the game is started""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getTTTMsgType(self): - """Returns the type of the TTT message (see PtTTTMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalTTTMsg(self): - """Returns this message as the TTT msg it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - - def yourTurn(self): - """Returns true if you are the first player (and therefore it's your turn)""" - pass - -class ptTTTMoveMadeMsg(ptTTTMsg): - """TicTacToe message received when someone makes a move""" - def __init__(self): - """None""" - pass - - def col(self): - """Returns the col index of the move (1..3)""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getTTTMsgType(self): - """Returns the type of the TTT message (see PtTTTMsgTypes)""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def playerID(self): - """Returns the the ID of the player that just moved""" - pass - - def row(self): - """Returns the row index of the move (1..3)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalTTTMsg(self): - """Returns this message as the TTT msg it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptVarSyncMsg(ptGameCliMsg): - """Base class for VarSync game messages""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def getVarSyncMsgType(self): - """Returns the type of the VarSync message (see PtVarSyncMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalVarSyncMsg(self): - """Returns this message as the VarSync msg it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptVarSyncAllVarsSentMsg(ptVarSyncMsg): - """VarSync message received after the last var is sent to you when you join the game, or request a list of vars""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def getVarSyncMsgType(self): - """Returns the type of the VarSync message (see PtVarSyncMsgTypes)""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalVarSyncMsg(self): - """Returns this message as the VarSync msg it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - -class ptVarSyncGame(ptGameCli): - """Game client for the VarSync game""" - def __init__(self): - """None""" - pass - - def createNumericVar(self,varName, value): - """Attempts to create a new numeric variable and set it to the specified number (clipped to double)""" - pass - - def createStringVar(self,varName, value): - """Attempts to create a new string variable and set it to the specified string (clipped to 255 chars)""" - pass - - def gameID(self): - """Returns the ID number for this game""" - pass - - def gameTypeID(self): - """Returns the game type ID for this game (as a guid string)""" - pass - - def invitePlayer(self,playerID): - """Invites the specified player to join the game""" - pass - - def leaveGame(self): - """Leaves this game""" - pass - - def name(self): - """Returns the name of the game""" - pass - - def playerCount(self): - """Returns the current number of players""" - pass - - def requestAllVars(self): - """Requests all the vars the server knows about""" - pass - - def setNumericVar(self,varID, value): - """Attempts to set a numeric variable to the specified number (clipped to double)""" - pass - - def setStringVar(self,varID, value): - """Attempts to set a string variable to the specified string (clipped to 255 chars)""" - pass - - def uninvitePlayer(self,playerID): - """Revokes the invitation for the specified player""" - pass - - def upcastToBlueSpiralGame(self): - """Returns this game client as a ptBlueSpiralGame""" - pass - - def upcastToClimbingWallGame(self): - """Returns this game client as a ptClimbingWallGame""" - pass - - def upcastToHeekGame(self): - """Returns this game client as a ptHeekGame""" - pass - - def upcastToMarkerGame(self): - """Returns this game client as a ptMarkerGame""" - pass - - def upcastToTTTGame(self): - """Returns this game client as a ptTTTGame""" - pass - - def upcastToVarSyncGame(self): - """Returns this game client as a ptVarSyncGame""" - pass - -class ptVarSyncNumericVarChangedMsg(ptVarSyncMsg): - """VarSync message received when a numeric variable's value changes""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def getVarSyncMsgType(self): - """Returns the type of the VarSync message (see PtVarSyncMsgTypes)""" - pass - - def id(self): - """Returns the id of the var that changed""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalVarSyncMsg(self): - """Returns this message as the VarSync msg it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - - def value(self): - """Returns the variable's new value""" - pass - -class ptVarSyncNumericVarCreatedMsg(ptVarSyncMsg): - """VarSync message received when a numeric variable is created and assigned an id""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def getVarSyncMsgType(self): - """Returns the type of the VarSync message (see PtVarSyncMsgTypes)""" - pass - - def id(self): - """Returns the id assigned to this variable""" - pass - - def name(self): - """Returns the name of the var that was created""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalVarSyncMsg(self): - """Returns this message as the VarSync msg it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - - def value(self): - """Returns the variable's new value""" - pass - -class ptVarSyncStringVarChangedMsg(ptVarSyncMsg): - """VarSync message received when a string variable's value changes""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def getVarSyncMsgType(self): - """Returns the type of the VarSync message (see PtVarSyncMsgTypes)""" - pass - - def id(self): - """Returns the id of the var that changed""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalVarSyncMsg(self): - """Returns this message as the VarSync msg it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - - def value(self): - """Returns the variable's new value""" - pass - -class ptVarSyncStringVarCreatedMsg(ptVarSyncMsg): - """VarSync message received when a string variable is created and assigned an id""" - def __init__(self): - """None""" - pass - - def getGameCli(self): - """Returns the game client associated with this message""" - pass - - def getType(self): - """Returns the type of the message (see PtGameCliMsgTypes)""" - pass - - def getVarSyncMsgType(self): - """Returns the type of the VarSync message (see PtVarSyncMsgTypes)""" - pass - - def id(self): - """Returns the id that was assigned to this variable""" - pass - - def name(self): - """Returns the name of the var that was created""" - pass - - def upcastToFinalGameCliMsg(self): - """Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)""" - pass - - def upcastToFinalVarSyncMsg(self): - """Returns this message as the VarSync msg it is""" - pass - - def upcastToGameMsg(self): - """Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)""" - pass - - def value(self): - """Returns the variable's new value""" - pass - diff --git a/Scripts/Python/plasma/PlasmaGameConstants.py b/Scripts/Python/plasma/PlasmaGameConstants.py deleted file mode 100644 index 064a6043..00000000 --- a/Scripts/Python/plasma/PlasmaGameConstants.py +++ /dev/null @@ -1,159 +0,0 @@ -""" *==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program 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 this program. If not, see . - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - - *==LICENSE==* """ -class PtBlueSpiralMsgTypes: - """(none)""" - kBlueSpiralGameStarted = 8 - kBlueSpiralClothOrder = 4 - kBlueSpiralSuccessfulHit = 5 - kBlueSpiralGameWon = 6 - kBlueSpiralGameOver = 7 - -class PtClimbingWallMsgTypes: - """(none)""" - kClimbingWallNumBlockersChanged = 4 - kClimbingWallReadyMsg = 5 - kClimbingWallBlockersChanged = 6 - kClimbingWallPlayerEntered = 7 - kClimbingWallSuitMachineLocked = 8 - kClimbingWallGameOver = 9 - -class PtClimbingWallReadyTypes: - """(none)""" - kClimbingWallReadyNumBlockers = 0 - kClimbingWallReadyBlockers = 1 - -class PtGameCliInviteErrors: - """(none)""" - kGameInviteSuccess = 0 - kGameInviteErrNotOwner = 1 - kGameInviteErrAlreadyInvited = 2 - kGameInviteErrAlreadyJoined = 3 - kGameInviteErrGameStarted = 4 - kGameInviteErrGameOver = 5 - kGameInviteErrGameFull = 6 - kGameInviteErrNoJoin = 7 - -class PtGameCliMsgTypes: - """(none)""" - kGameCliPlayerJoinedMsg = 0 - kGameCliPlayerLeftMsg = 1 - kGameCliInviteFailedMsg = 2 - kGameCliOwnerChangeMsg = 3 - kGameCliTTTMsg = 4 - kGameCliHeekMsg = 5 - kGameCliMarkerMsg = 6 - kGameCliBlueSpiralMsg = 7 - kGameCliClimbingWallMsg = 8 - kGameCliVarSyncMsg = 9 - -class PtGameMgrMsgTypes: - """(none)""" - kGameMgrInviteReceivedMsg = 1 - kGameMgrInviteRevokedMsg = 2 - -class PtHeekCountdownStates: - """(none)""" - kHeekCountdownStart = 0 - kHeekCountdownStop = 1 - kHeekCountdownIdle = 2 - -class PtHeekGameChoice: - """(none)""" - kHeekGameChoiceRock = 0 - kHeekGameChoicePaper = 1 - kHeekGameChoiceScissors = 2 - -class PtHeekGameSeq: - """(none)""" - kHeekGameSeqCountdown = 0 - kHeekGameSeqChoiceAnim = 1 - kHeekGameSeqGameWinAnim = 2 - -class PtHeekLightStates: - """(none)""" - kHeekLightOn = 0 - kHeekLightOff = 1 - kHeekLightFlash = 2 - -class PtHeekMsgTypes: - """(none)""" - kHeekPlayGame = 4 - kHeekGoodbye = 5 - kHeekWelcome = 6 - kHeekDrop = 7 - kHeekSetup = 8 - kHeekLightState = 9 - kHeekInterfaceState = 10 - kHeekCountdownState = 11 - kHeekWinLose = 12 - kHeekGameWin = 13 - kHeekPointUpdate = 14 - -class PtMarkerGameTypes: - """(none)""" - kMarkerGameQuest = 0 - kMarkerGameCGZ = 1 - kMarkerGameCapture = 2 - kMarkerGameCaptureAndHold = 3 - -class PtMarkerMsgTypes: - """(none)""" - kMarkerTemplateCreated = 4 - kMarkerTeamAssigned = 5 - kMarkerGameType = 6 - kMarkerGameStarted = 7 - kMarkerGamePaused = 8 - kMarkerGameReset = 9 - kMarkerGameOver = 10 - kMarkerGameNameChanged = 11 - kMarkerTimeLimitChanged = 12 - kMarkerGameDeleted = 13 - kMarkerMarkerAdded = 14 - kMarkerMarkerDeleted = 15 - kMarkerMarkerNameChanged = 16 - kMarkerMarkerCaptured = 17 - -class PtTTTGameResult: - """(none)""" - kTTTGameResultWinner = 0 - kTTTGameResultTied = 1 - kTTTGameResultGave = 2 - kTTTGameResultError = 3 - -class PtTTTMsgTypes: - """(none)""" - kTTTGameStarted = 4 - kTTTGameOver = 5 - kTTTMoveMade = 6 - -class PtVarSyncMsgTypes: - """(none)""" - kVarSyncNumericVarCreated = 8 - kVarSyncStringVarChanged = 4 - kVarSyncNumericVarChanged = 5 - kVarSyncAllVarsSent = 6 - kVarSyncStringVarCreated = 7 - diff --git a/Scripts/Python/plasma/PlasmaKITypes.py b/Scripts/Python/plasma/PlasmaKITypes.py deleted file mode 100644 index 44f82e6d..00000000 --- a/Scripts/Python/plasma/PlasmaKITypes.py +++ /dev/null @@ -1,469 +0,0 @@ -""" *==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program 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 this program. If not, see . - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - - *==LICENSE==* """ -""" -This module is contains the datatypes and constants for -interfacing with the KI subsytem -""" - -# OnKIMsg and PtSendKIMessage command types -kEnterChatMode=1 # start chat mode on KI, 'value' doesn't matter -kSetChatFadeDelay=2 # set the chat fade time, 'value' is the delay in seconds -kSetTextChatAdminMode=3 # set self to be admin mode, 'value' is 1 to go into Admin mode, 0 remove -kDisableKIandBB=4 # disable the KI and the blackbar, 'value' doesn't matter -kEnableKIandBB=5 # enable the KI and the blackbar, 'value' doesn't matter -kYesNoDialog=6 # request that the KI put up a yes/no dialog for someone else -kAddPlayerDevice=7 # add player interactive device to list of devices, 'value' is device name -kRemovePlayerDevice=8 # remove player interactive device from list, 'value' is device name -kUpgradeKILevel=9 # upgrade new level of KI (if already at that level, nevermind), 'value' is the new level -kDowngradeKILevel=10 # remove (drop) the KI level (if not at that level, nevermind), 'value' is the level to remove -kRateIt=11 # request for the KI to ask the user to Rate something -kSetPrivateChatChannel=12 # sets the private chat channel to number, for private rooms -kUnsetPrivateChatChannel=13 # undoes the the private chat channel. -kStartBookAlert=14 # start the book alert -kMiniBigKIToggle=15 # shortcut to toggling the miniKI/bigKI -kKIPutAway=16 # shortcut to hiding all of the KI -kChatAreaPageUp=17 # shortcut to paging up the chat area -kChatAreaPageDown=18 # shortcut to paging down the chat area -kChatAreaGoToBegin=19 # shortcut to going to the beginning of the chat area -kChatAreaGoToEnd=20 # shortcut to going to the end of the chat area -kKITakePicture=21 # shortcut to taking a picture in the KI -kKICreateJournalNote=22 # shortcut to creating a journal note in the KI -kKIToggleFade=23 # shortcut to toggle fade mode in the miniKI (only if miniKI only) -kKIToggleFadeEnable=24 # shortcut to toggling the enable flag for fading chat -kKIChatStatusMsg=25 # display a status message (net propagated) in the chat window -kKILocalChatStatusMsg=26 # display a status message (local only) in the chat window -kKIUpSizeFont=27 # up size the font in the KI (chatarea) -kKIDownSizeFont=28 # down size the font in the KI (chatarea) -kKIOpenYeehsaBook=29 # open the Yeehsa book, if not already open -kKIOpenKI=30 # open the KI a little at a time -kKIShowCCRHelp=31 # show the CCR help dialog -kKICreateMarker=32 # create a marker -kKICreateMarkerFolder=33 # create a marker folder(node) game in the current Age's journal folder -kKILocalChatErrorMsg=34 # display an error message (local only) in the chat window -kKIPhasedAllOn=35 # turn on all the phased KI functionality -kKIPhasedAllOff=36 # turn off all the phased KI functionality -kKIOKDialog=37 # display an OK dialog box (localized) -kDisableYeeshaBook=38 # don't allow linking with the Yeesha book (gameplay) -kEnableYeeshaBook=39 # re-allow linking with the Yeesha book -kQuitDialog=40 # put up Quit dialog -kTempDisableKIandBB=41 # temp disable KI and blackbar (done by av system) -kTempEnableKIandBB=42 # temp re-enable the KI and blackbar (done by av system) -kDisableEntireYeeshaBook=43 # disable the entire Yeeshabook, not for gameplay, but prevent linking -kEnableEntireYeeshaBook=44 # enable the entire Yeeshabook, not for gameplay -kKIOKDialogNoQuit=45 # display OK dialog in the KI without quiting afterwards -kGZUpdated=46 # the GZ game was updated -kGZInRange=47 # a GZ marker is in range -kGZOutRange=48 # GZ markers are out of range -kUpgradeKIMarkerLevel=49 # upgrade the KI marker level -kKIShowMiniKI=50 # force the miniKI up -kGZFlashUpdate=51 # flash update to the GZ display on the miniKI (without saving) -kStartJournalAlert = 52 # start the journal alert -kAddJournalBook = 53 # add the journal book to the BB -kRemoveJournalBook = 54 # remove the journal book from the BB -kKIOpenJournalBook = 55 # show the journal book -kMGStartCGZGame = 56 # Start CGZ Marker Game -kMGStopCGZGame = 57 # Stop CGZ Marker Game -kKICreateMarkerNode = 58 #Creates the marker game vault Node -kStartKIAlert = 59 # start the KI alert -kUpdatePelletScore = 60 # Updates the pellet score -kFriendInviteSent = 61 # Result of friend invite received -kRegisterImager = 62 # Imagers send to register themselves with the KI - -# kUpgradeKILevel and kDowngradeKILevel levels -kNanoKI=0 -kMicroKI=1 -kNormalKI=2 -kLowestKILevel = kNanoKI -kHighestKILevel = kNormalKI - -# Upgrade levels for the KI marker -kKIMarkerNotUpgraded = 0 -kKIMarkerFirstLevel = 1 # can play marker tag, but no GPS, can play first set of GZMarkers -kKIMarkerSecondLevel = 2 # can get to back room in GreatZero and play second set of GZmarkers -kKIMarkerNormalLevel = 3 # complete both GZmarker trials - has GPS - -# GZ Marker and Calibration GZ Marker status -kGZMarkerInactive = "0" -kGZMarkerAvailable = "1" -kGZMarkerCaptured = "2" -kGZMarkerUploaded = "3" - -# Calibration GZ Marker Games -kCGZMarkerInactive = "0" -kCGZMarkerAvailable = "1" -kCGZMarkerCaptured = "2" -kCGZMarkerUploaded = "3" -gCGZAllStates = [ kCGZMarkerInactive, kCGZMarkerAvailable, kCGZMarkerCaptured, kCGZMarkerUploaded ] -kCGZFirstGame = 0 -kCGZFinalGame = 3 -kCGZToransGame = 0 -kCGZHSpansGame = 1 -kCGZVSpansGame = 2 -kCGZActivateGZ = 3 - - -# -- chronicle names and types -kChronicleKILevel = "PlayerKILevel" -kChronicleKILevelType = 2 -kChronicleCensorLevel = "PlayerCensorLevel" -kChronicleCensorLevelType = 2 -kChronicleKIMarkerLevel = "KIMarkerLevel" -kChronicleKIMarkerLevelType = 2 -kChronicleGZGames = "GZGames" -kChronicleGZGamesType = 1 -kChronicleGZMarkersAquired = "GZMarkersAquired" -kChronicleGZMarkersAquiredType = 1 -kChronicleCalGZMarkersAquired = "CalGZMarkers" -kChronicleCalGZMarkersAquiredType = 1 - - -def PtDetermineKILevel(): - "Get the KILevel" - # assume that they have none... - import Plasma - import string - vault = Plasma.ptVault() - entry = vault.findChronicleEntry(kChronicleKILevel) - if type(entry) != type(None): - level = string.atoi(entry.chronicleGetValue()) - # make sure it is a valid level - if level >= kLowestKILevel and level <= kHighestKILevel: - return level - # if couldn't be determine... just assume lowest form - return kNanoKI - -def PtDetermineCensorLevel(): - "Get the KILevel" - # assume that they have none... - import Plasma - import string - vault = Plasma.ptVault() - entry = vault.findChronicleEntry(kChronicleCensorLevel) - if type(entry) != type(None): - level = string.atoi(entry.chronicleGetValue()) - return level - # if couldn't be determine... just assume lowest form - return 0 - -def PtDetermineKIMarkerLevel(): - "Get the KIMarkerLevel" - # assume that they have none... - import Plasma - import string - vault = Plasma.ptVault() - entry = vault.findChronicleEntry(kChronicleKIMarkerLevel) - if type(entry) != type(None): - level = string.atoi(entry.chronicleGetValue()) - return level - # if couldn't be determine... just assume lowest form - return kKIMarkerNotUpgraded - -def PtGetCGZGameState(whichGame): - "Get the CGZ Game level" - # assume that they have none... - import Plasma - import PlasmaTypes - if whichGame >= kCGZFirstGame and whichGame <= kCGZFinalGame: - vault = Plasma.ptVault() - entry = vault.findChronicleEntry(kChronicleCalGZMarkersAquired) - if type(entry) != type(None): - allStates = entry.chronicleGetValue() - PlasmaTypes.PtDebugPrint("PlasmaKITypes:PtGetCGZGameLevel current chronicle is %s"%(allStates),level=PlasmaTypes.kDebugDumpLevel) - state = kCGZMarkerInactive # assume inactive - try: - state = allStates[whichGame] - except LookupError: - PlasmaTypes.PtDebugPrint("PlasmaKITypes:PtGetCGZGameLevel - CGZ marker game not there? chron=%s"%(allStates),level=PlasmaTypes.kErrorLevel) - pass - return state - else: - PlasmaTypes.PtDebugPrint("PlasmaKITypes:PtGetCGZGameLevel no chronicle yet",level=PlasmaTypes.kDebugDumpLevel) - else: - PlasmaTypes.PtDebugPrint("PlasmaKITypes:PtGetCGZGameLevel - invalid CGZ game of %d"%(whichGame),level=PlasmaTypes.kErrorLevel) - pass - # if couldn't be determine... just assume lowest form - return kCGZMarkerInactive - -def PtSetCGZGameState(whichGame,state): - "Get the CGZ Game level" - # assume that they have none... - import Plasma - import PlasmaTypes - if whichGame >= kCGZFirstGame and whichGame <= kCGZFinalGame: - if type(state) == type("") and state in gCGZAllStates: - PlasmaTypes.PtDebugPrint("PlasmaKITypes:PtSetCGZGameLevel - setting game %d to %s"%(whichGame,state),level=PlasmaTypes.kDebugDumpLevel) - vault = Plasma.ptVault() - entry = vault.findChronicleEntry(kChronicleCalGZMarkersAquired) - if type(entry) != type(None): - allStates = entry.chronicleGetValue() - newStates = "" - for idx in range(kCGZFinalGame+1): - if idx == whichGame: - newStates += state - else: - try: - newStates += allStates[idx] - except LookupError: - newStates += kCGZMarkerInactive - # make sure we get whatever is beyond this - newStates += allStates[kCGZFinalGame+1:] - entry.chronicleSetValue(newStates) - entry.save() - else: - # create a new one - newStates = "" - for idx in range(kCGZFinalGame+1): - if idx == whichGame: - newStates += state - else: - newStates += kCGZMarkerInactive - vault.addChronicleEntry(kChronicleCalGZMarkersAquired,kChronicleCalGZMarkersAquiredType,newStates) - else: - PlasmaTypes.PtDebugPrint("PlasmaKITypes:PtSetCGZGameLevel - invalid CGZ game state of:",state,level=PlasmaTypes.kErrorLevel) - pass - else: - PlasmaTypes.PtDebugPrint("PlasmaKITypes:PtSetCGZGameLevel - invalid CGZ game of %d"%(whichGame),level=PlasmaTypes.kErrorLevel) - pass - -def PtWhichCGZPlaying(): - "Has the player completed the CGZ stuff" - import Plasma - whichGame = -1 - state = kCGZMarkerInactive - vault = Plasma.ptVault() - entry = vault.findChronicleEntry(kChronicleCalGZMarkersAquired) - if type(entry) != type(None): - allStates = entry.chronicleGetValue() - if len(allStates) > kCGZFinalGame: - state = kCGZMarkerUploaded - for i in range(kCGZFinalGame+1): - if allStates[i] == kCGZMarkerAvailable or allStates[i] == kCGZMarkerCaptured: - whichGame = i - state = allStates[i] - break - if allStates[i] != kCGZMarkerUploaded: - state = kCGZMarkerInactive - return (whichGame,state) - -def PtIsCGZDone(): - "Has the player completed the CGZ stuff" - import Plasma - isDone = 0 - vault = Plasma.ptVault() - entry = vault.findChronicleEntry(kChronicleCalGZMarkersAquired) - if type(entry) != type(None): - allStates = entry.chronicleGetValue() - if len(allStates) > kCGZFinalGame: - # assume that we are going to find them all - isDone = 1 - for i in range(kCGZFinalGame+1): - if allStates[i] != kCGZMarkerUploaded: - isDone = 0 - break - return isDone - -def PtDetermineGZ(): - "Get the current GZ states" - import Plasma - import PlasmaTypes - import string - GZPlaying = 0 - MarkerToGetColor = 'off' - MarkerGottenColor = 'off' - MarkerToGetNumber = 0 - MarkerGottenNumber = 0 - KIMarkerLevel = PtDetermineKIMarkerLevel() - if KIMarkerLevel > kKIMarkerNotUpgraded: - # see if they are playing a CGZ game - (whichGame,state) = PtWhichCGZPlaying() - if KIMarkerLevel < kKIMarkerNormalLevel or (KIMarkerLevel == kKIMarkerNormalLevel and whichGame != -1): - vault = Plasma.ptVault() - # is there a chronicle for the GZ games? - entry = vault.findChronicleEntry(kChronicleGZGames) - if type(entry) != type(None): - gameString = entry.chronicleGetValue() - PlasmaTypes.PtDebugPrint("PtDetermineGZ: - game string is %s" % (gameString),level=PlasmaTypes.kDebugDumpLevel) - args = gameString.split() - if len(args) == 3: - try: - GZPlaying = string.atoi(args[0]) - colors = args[1].split(':') - MarkerGottenColor = colors[0] - MarkerToGetColor = colors[1] - outof = args[2].split(':') - MarkerGottenNumber = string.atoi(outof[0]) - MarkerToGetNumber = string.atoi(outof[1]) - except ValueError: - PlasmaTypes.PtDebugPrint("xKI:GZ - error trying to read GZGames Chronicle",level=PlasmaTypes.kErrorLevel) - # we don't know which one it errored on, so just reset them all - GZPlaying = 0 - MarkerToGetColor = 'off' - MarkerGottenColor = 'off' - MarkerToGetNumber = 0 - MarkerGottenNumber = 0 - else: - PlasmaTypes.PtDebugPrint("xKI:GZ - error GZGames string formation error",level=PlasmaTypes.kErrorLevel) - pass - else: - # can't be playing a GZGame! - # ...might be a MarkerTag game... let the KI determine that. - pass - PlasmaTypes.PtDebugPrint("PtDetermineGZ: - returning game=%d colors=%s:%s markers=%d:%d" % (GZPlaying, MarkerGottenColor, MarkerToGetColor ,MarkerGottenNumber, MarkerToGetNumber),level=PlasmaTypes.kDebugDumpLevel) - return (GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber) - -def PtCaptureGZMarker(GZMarkerInRange): - import Plasma - import PlasmaTypes - # get current GZ Game state - (GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber) = PtDetermineGZ() - # make sure there is room for the capture marker - if GZPlaying and MarkerToGetNumber > MarkerGottenNumber: - # set the marker status to 'gotten' - # ...in the GZ marker chronicle - vault = Plasma.ptVault() - # is there a chronicle for the GZ games? - entry = vault.findChronicleEntry(kChronicleGZMarkersAquired) - if type(entry) != type(None): - markers = entry.chronicleGetValue() - markerIdx = GZMarkerInRange - 1 - if markerIdx >= 0 and markerIdx < len(markers): - # Set the marker to "captured" - PlasmaTypes.PtDebugPrint("PtCaptureGZMarker: starting with '%s' changing %d to '%s'" % (markers,GZMarkerInRange,kGZMarkerCaptured),level=PlasmaTypes.kDebugDumpLevel) - if len(markers)-(markerIdx+1) != 0: - markers = markers[:markerIdx] + kGZMarkerCaptured + markers[-(len(markers)-(markerIdx+1)):] - else: - markers = markers[:markerIdx] + kGZMarkerCaptured - #PlasmaTypes.PtDebugPrint("xKI: out string is '%s'" % (markers),level=PlasmaTypes.kDebugDumpLevel) - entry.chronicleSetValue(markers) - entry.save() - # update the marker Gotten count - totalGotten = markers.count(kGZMarkerCaptured) - KIMarkerLevel = PtDetermineKIMarkerLevel() - if KIMarkerLevel > kKIMarkerFirstLevel: - # if this is the second wave of markers (or beyond) - totalGotten -= 5 - if totalGotten < 0: - totalGotten = 0 - if totalGotten > MarkerToGetNumber: - totalGotten = MarkerToGetNumber - MarkerGottenNumber = totalGotten - # save update to chronicle - PtUpdateGZGamesChonicles(GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber) - else: - PlasmaTypes.PtDebugPrint("PtCaptureGZMarker: invalid marker serial number of %d" % (gGZMarkerInRange),level=PlasmaTypes.kErrorLevel ) - pass - else: - PlasmaTypes.PtDebugPrint("PtCaptureGZMarker: no chronicle entry found",level=PlasmaTypes.kErrorLevel ) - pass - else: - PlasmaTypes.PtDebugPrint("PtCaptureGZMarker: no game or this game is complete",level=PlasmaTypes.kErrorLevel ) - pass - -def PtVerifyGZMarker(): - import Plasma - import PlasmaTypes - # get current GZ Game state - (GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber) = PtDetermineGZ() - # make sure there is room for the capture marker - if GZPlaying: - # set the marker status to 'gotten' - # ...in the GZ marker chronicle - vault = Plasma.ptVault() - # is there a chronicle for the GZ games? - entry = vault.findChronicleEntry(kChronicleGZMarkersAquired) - if type(entry) != type(None): - markers = entry.chronicleGetValue() - # get what was really gotten - totalGotten = markers.count(kGZMarkerCaptured) - KIMarkerLevel = PtDetermineKIMarkerLevel() - if KIMarkerLevel > kKIMarkerFirstLevel: - # if this is the second wave of markers (or beyond) - totalGotten -= 5 - if totalGotten < 0: - totalGotten = 0 - if totalGotten > MarkerToGetNumber: - totalGotten = MarkerToGetNumber - if totalGotten != MarkerGottenNumber: - PlasmaTypes.PtDebugPrint("PtVerifyGZMarker: Error! Gotten different than real. They say=%d We say=%d"%(MarkerGottenNumber,totalGotten),level=PlasmaTypes.kErrorLevel ) - MarkerGottenNumber = totalGotten - # save update to chronicle - PtUpdateGZGamesChonicles(GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber) - Plasma.PtSendKIMessage(kGZUpdated,0) - return (GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber) - -def PtUpdateGZGamesChonicles(GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber): - "Update the GZ chronicle variable" - import Plasma - import PlasmaTypes - vault = Plasma.ptVault() - # is there a chronicle for the GZ games? - entry = vault.findChronicleEntry(kChronicleGZGames) - try: - upstring = "%d %s:%s %d:%d" % (GZPlaying,MarkerGottenColor,MarkerToGetColor,MarkerGottenNumber,MarkerToGetNumber) - if type(entry) != type(None): - entry.chronicleSetValue(upstring) - entry.save() - else: - # if there is none, then just add another entry - vault.addChronicleEntry(kChronicleGZGames,kChronicleGZGamesType,upstring) - except TypeError: - if type(GZPlaying) != type(0): - PlasmaTypes.PtDebugPrint("PtUpdateGZGamesChronicle: GZPlaying wrong type (should be integer)",level=PlasmaTypes.kErrorLevel ) - pass - if type(MarkerToGetColor) != type(""): - PlasmaTypes.PtDebugPrint("PtUpdateGZGamesChronicle: GZPlaying wrong type (should be string)",level=PlasmaTypes.kErrorLevel ) - pass - if type(MarkerGottenColor) != type(""): - PlasmaTypes.PtDebugPrint("PtUpdateGZGamesChronicle: GZPlaying wrong type (should be string)",level=PlasmaTypes.kErrorLevel ) - pass - if type(MarkerToGetNumber) != type(0): - PlasmaTypes.PtDebugPrint("PtUpdateGZGamesChronicle: GZPlaying wrong type (should be integer)",level=PlasmaTypes.kErrorLevel ) - pass - if type(MarkerGottenNumber) != type(0): - PlasmaTypes.PtDebugPrint("PtUpdateGZGamesChronicle: GZPlaying wrong type (should be integer)",level=PlasmaTypes.kErrorLevel ) - pass - pass - - -# OnRTChat flags -# NOTE: kRTChatInterAge = 8 is being used in cyMisc.cpp SendRTChat (hard coded) so don't change here unless you change that too -kRTChatPrivate=1 -kRTChatAdmin=2 -kRTChatPrivateAdmin=3 -kRTChatInterAge=8 -kRTChatStatusMsg=16 -kRTChatNeighborsMsg=32 - -# flags channel mask -kRTChatFlagMask = 65535 -kRTChatChannelMask = 65280 -kRTChatNoChannel = 255 - -# OnCCRMsg flags -kCCRBeginCommunication=1 -kCCRChat=2 -kCCREndCommunication=3 -kCCRReturnChatMsg=4 diff --git a/Scripts/Python/plasma/PlasmaNetConstants.py b/Scripts/Python/plasma/PlasmaNetConstants.py deleted file mode 100644 index 18136ee6..00000000 --- a/Scripts/Python/plasma/PlasmaNetConstants.py +++ /dev/null @@ -1,34 +0,0 @@ -""" *==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program 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 this program. If not, see . - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - - *==LICENSE==* """ -class PtLinkingRules: - """(none)""" - kBasicLink = 0 - kOriginalBook = 1 - kSubAgeBook = 2 - kOwnedBook = 3 - kVisitBook = 4 - kChildAgeBook = 5 - diff --git a/Scripts/Python/plasma/PlasmaTypes.py b/Scripts/Python/plasma/PlasmaTypes.py deleted file mode 100644 index c62638a6..00000000 --- a/Scripts/Python/plasma/PlasmaTypes.py +++ /dev/null @@ -1,820 +0,0 @@ -""" *==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program 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 this program. If not, see . - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - - *==LICENSE==* """ -""" -This module is contains the datatypes and constants for -interfacing with the Plasma 2.0 engine. -""" -from Plasma import * -from PlasmaConstants import * - -#################################### -# Utility functions -#################################### -false=0 -true=1 - -# OnNotify Event enums -kCollisionEvent=PtEventType.kCollision # [1]=enter flag, [2]=hitter(probably avatar), [3]=hittee -kPickedEvent=PtEventType.kPicked # [1]=enter flag, [2]=picker(probably avatar), [3]=pickee, [4]=hitpoint(world) [5]=hitpoint(local) -kControlKeyEvent=PtEventType.kControlKey # [1]=key id, [2]=down flag -kVariableEvent=PtEventType.kVariable # [1]=name, [2]=data type, [3]=data -kFacingEvent=PtEventType.kFacing # [1]=enabled flag, [2]=facer(probably avatar), [3]=facee, [4]=dot product -kContainedEvent=PtEventType.kContained # [1]=entering flag, [2]=contained(probably avatar), [3]=container -kActivateEvent=PtEventType.kActivate # [1]=active flag, [2]=activate flag -kCallbackEvent=PtEventType.kCallback # [1]=callback id -kResponderStateEvent=PtEventType.kResponderState # [1]=state id -kMultiStageEvent=PtEventType.kMultiStage # [1]=what stage, [2]=event(see below), [3]=avatar -kSpawnedEvent=PtEventType.kSpawned # [1]=spawner, [2]=spawnee (usually avatar) -kClickDragEvent=PtEventType.kClickDrag # not used yet -kOfferLinkingBook=PtEventType.kOfferLinkingBook # [1]=offerer, [2]=link panel ID of age offered - - -# OnNotify Var Event Data Types -kVarNumberType=PtNotifyDataType.kNumber -kVarKeyType=PtNotifyDataType.kKey -# OnNotify MultiStageEvent - what event types -kEnterStage=PtMultiStageEventType.kEnterStage -kBeginingOfLoop=PtMultiStageEventType.kBeginingOfLoop -kAdvanceNextStage=PtMultiStageEventType.kAdvanceNextStage -kRegressPrevStage=PtMultiStageEventType.kRegressPrevStage -# Behavior - gotoStage -kStageExitBrain=-1 # sending ptAttribBehavior to stage -1 will exit brain - -# OnGUINotify Control Types -kDialog=1 -kButton=2 -kDraggable=3 -kListBox=4 -kTextBox=5 -kEditBox=6 -kUpDownPair=7 -kKnob=8 -kDragBar=9 -kCheckBox=10 -kRadioGroup=11 -kDynamicTextControl=12 -kMultiLineEdit=13 -# GUIControlListBox String Justify Types -kLeftJustify=1 -kRightJustify=2 -# GUIControlListBox String inherit flag -kNoInherit=0 -kInheritFromNormal=1 -kInheritFromSelect=2 -kSelectDetermined=3 -kSelectUseGUIColor=4 -# GUIControlMultiLineEdit style flags (additive) -kFontBold=1 -kFontItalic=2 -kFontShadowed=4 - -# OnGUINotify Event Types -kShowHide=1 # show or hide change (only on kDialog) -kAction=2 # kButton clicked, kListBox item clicked on, kEditBox hit enter -kValueChanged=3 # value changed in control (could be from kUpDownPair,kKnob,kCheckBox,kRadioGroup -kDialogLoaded=4 # the dialog has just been loaded -kFocusChange=5 # the focus changed from one control to another, or none, within the dialog -kExitMode = 6 # Modal dialog received an exit mode command -kInterestingEvent = 7 # an interesting event happened - -# OnRoomLoad 'what' types -kLoaded=1 -kUnloaded=2 - -# Clothing group Types and clothing types -kMaleClothingGroup=0 -kFemaleClothingGroup=1 -kAnyClothingItem=-1 -kPantsClothingItem=0 -kShirtClothingItem=1 -kLeftHandClothingItem=2 -kRightHandClothingItem=3 -kFaceClothingItem=4 -kHairClothingItem=5 -kLeftFootClothingItem=6 -kRightFootClothingItem=7 -kAccessoryClothingItem=8 - -#Debug print levels -kDebugDumpLevel = 1 -kWarningLevel = 2 -kErrorLevel = 3 -kAssertLevel = 4 - - -def PtAssert(cond, msg): - "Plasma assert. Just like the Python one but we can set it to NOP in release" - assert cond,msg - -def PtDebugPrint(*msgs,**keywords): - "Plasma debug print. Will be NOP'd when released" - try: - level = keywords['level'] - except LookupError: - level = kErrorLevel - if level >= PtGetPythonLoggingLevel(): - if level == 4: - PtAssert(0,msgs[0]) - else: - for msg in msgs: - print msg - -def PtGetObjectName(obj): - "Given a ptSceneobject, return its name" - if isinstance(obj,ptSceneobject): - if type(obj.getKey()) != type(None): - return obj.getKey().getName() - return "nil" - -# add an event that is in the form of a list -# ...to a notify message -def PtAddEvent(notify,event): - "Add an event of any type to a ptNotify message object" - if type(event) != type([]): - print "Unrecognized event record structure" - return - if event[0] == kCollisionEvent: - notify.addCollisionEvent(event[1],event[2].getKey(),event[3].getKey()) - elif event[0] == kPickedEvent: - notify.addPickEvent(event[1],event[2].getKey(),event[3].getKey(),event[4]) - elif event[0] == kControlKeyEvent: - notify.addControlKeyEvent(event[1],event[2]) - elif event[0] == kVariableEvent: - if event[2] == kVarNumberType: - notify.addVarNumber(event[1],event[3]) - elif event[2] == kVarKeyType: - notify.addVarKey(event[1],event[3]) - elif event[0] == kFacingEvent: - notify.addFacingEvent(event[1],event[2].getKey(),event[3].getKey(),event[4]) - elif event[0] == kContainedEvent: - notify.addContainerEvent(event[1],event[2].getKey(),event[3].getKey()) - elif event[0] == kActivateEvent: - notify.addActivateEvent(event[1],event[2]) - elif event[0] == kCallbackEvent: - notify.addCallbackEvent(event[1]) - elif event[0] == kResponderStateEvent: - notify.addResponderState(event[1]) - else: - print "Unrecognized event type %d" % (event[0]) - -# add a list of events into a ptNotify message -def PtAddEvents(notify, events): - "Add a list of events to a ptNotify message object" - if type(events) == type([]): - for event in events: - PtAddEvent(notify,event) - -# find the avatar in event record list -def PtFindAvatar(events): - "Find the avatar in one of the event records" - for event in events: - if event[0]==kCollisionEvent or event[0]==kPickedEvent or event[0]==kFacingEvent or event[0]==kContainedEvent or event[0]==kSpawnedEvent: - return event[2] - if event[0] == kMultiStageEvent: - return event[3] - # didn't find one - return None - -#################################### -# Exceptions -#################################### -import exceptions -class ptResponderStateError(exceptions.Exception): - def __init__(self,args=None): - self.args = args - -# -# Attributes that will be exposed in Max to be filled in by - -#################################### -# base class for all attributes -#################################### -# (This makes it easy to find all the attributes in a module) -class ptAttribute: - def __init__(self,id,name, vislistid = -1, visliststates = []): - self.id = id - self.name = name - self.vis_id = vislistid - self.vis_states = visliststates - - def setVisInfo(self, id, stateslist): - self.vis_id = id - self.vis_states = stateslist - - def getVisInfo(self): - return (self.vis_id, self.vis_states) - -# base class for all list attributes -# (This makes it easy to find all the attributes that are a list) -class ptAttributeList(ptAttribute): - def __init__(self,id,name): - ptAttribute.__init__(self,id,name) - -# Boolean attribute (Checkbox) -class ptAttribBoolean(ptAttribute): - def __init__(self,id,name=None, default=0): - ptAttribute.__init__(self,id,name) - self.value = default - def getdef(self): - return (self.id,self.name,1,self.value) - -# Integer attribute (Spinner) -class ptAttribInt(ptAttribute): - def __init__(self,id,name=None,default=0,rang=None): - ptAttribute.__init__(self,id,name) - self.value = default - self.rang = rang - def getdef(self): - return (self.id,self.name,2,self.value,self.rang) - -# Floating point number attribute (Spinner) -class ptAttribFloat(ptAttribute): - def __init__(self,id,name=None,default=0.0,rang=None): - ptAttribute.__init__(self,id,name) - self.value = default - self.rang = rang - def getdef(self): - return (self.id,self.name,3,self.value,self.rang) - -# String attribute (Edit box) -class ptAttribString(ptAttribute): - def __init__(self,id,name=None,default=""): - ptAttribute.__init__(self,id,name) - self.value = default - def getdef(self): - return (self.id,self.name,4,self.value) - -# Drop-down list attribute (Drop-down list combo box) -class ptAttribDropDownList(ptAttribute): - def __init__(self,id,name=None,options=None): - ptAttribute.__init__(self,id,name) - self.options = options - def getdef(self): - return (self.id,self.name,20,self.options) - -# Sceneobject attribute (pick single sceneobject box) -class ptAttribSceneobject(ptAttribute): - def __init__(self,id,name=None,netForce=0): - ptAttribute.__init__(self,id,name) - self.value = None - self.sceneobject = None - self.netForce = netForce - def getdef(self): - return (self.id,self.name,5) - def __setvalue__(self,value): - if self.netForce: - value.netForce(1) - self.value = value - self.sceneobject = self.value - -# Sceneobject list attribute (pick multiple sceneobjects box) -class ptAttribSceneobjectList(ptAttributeList): - def __init__(self,id,name=None,byObject=0,netForce=0): - ptAttributeList.__init__(self,id,name) - self.value = [] # start as an empty list - self.sceneobject = self.value - self.netForce = netForce - if byObject: - self.byObject = {} - else: - self.byObject = None - def getdef(self): - return (self.id,self.name,6) - def __setvalue__(self,value): - if self.netForce: - value.netForce(1) - self.value.append(value) - if type(self.byObject) == type({}): - name = value.getName() - self.byObject[name] = value - -# attribute list of keys -class ptAttributeKeyList(ptAttributeList): - def __init__(self,id,name=None,byObject=0,netForce=0): - ptAttributeList.__init__(self,id,name) - self.value = [] - self.netForce = netForce - if byObject: - self.byObject = {} - else: - self.byObject = None - def enable(self,objectName=None): - if self.value != None: - if type(objectName) != type(None) and type(self.byObject) != type(None): - pkey = self.byObject[objectName] - if self.netForce: - pkey.netForce(1) - pkey.enable() - elif type(self.value)==type([]): - for pkey in self.value: - if self.netForce: - pkey.netForce(1) - pkey.enable() - else: - if self.netForce: - self.value.netForce(1) - self.value.enable() - def disable(self,objectName=None): - if self.value != None: - if type(objectName) != type(None) and type(self.byObject) != type(None): - pkey = self.byObject[objectName] - if self.netForce: - pkey.netForce(1) - pkey.disable() - elif type(self.value)==type([]): - for pkey in self.value: - if self.netForce: - pkey.netForce(1) - pkey.disable() - else: - if self.netForce: - self.value.netForce(1) - self.value.disable() - def __setvalue__(self,value): - if self.netForce: - value.netForce(1) - self.value.append(value) - if type(self.byObject) == type({}): - name = value.getName() - self.byObject[name] = value - -# Activator attribute (pick activator types box) -class ptAttribActivator(ptAttributeKeyList): - def getdef(self): - return (self.id,self.name,8) - def enableActivator(self): - for key in self.value: - key.getSceneObject().physics.enable() - def disableActivator(self): - for key in self.value: - key.getSceneObject().physics.disable() - def volumeSensorIgnoreExtraEnters(self,state): - for key in self.value: - key.getSceneObject().volumeSensorIgnoreExtraEnters(state) - -# Activator attribute (pick activator types box) -class ptAttribActivatorList(ptAttributeKeyList): - def getdef(self): - return (self.id,self.name,7) - -# Responder attribute (pick responder types box) -class ptAttribResponder(ptAttributeKeyList): - def __init__(self,id,name=None,statelist=None,byObject=0,netForce=0): - ptAttributeKeyList.__init__(self,id,name,byObject,netForce) - self.state_list = statelist - def getdef(self): - return (self.id,self.name,9) - def run(self,key,state=None,events=None,avatar=None,objectName=None,netForce=0,netPropagate=1,fastforward=0): - # has the value been set? - if type(self.value) != type(None): - nt = ptNotify(key) - nt.clearReceivers() - # see if the value is a list or byObject or a single - if type(objectName) != type(None) and type(self.byObject) != type(None): - nt.addReceiver(self.byObject[objectName]) - elif type(self.value)==type([]): - for resp in self.value: - nt.addReceiver(resp) - else: - nt.addReceiver(self.value) - if not netPropagate: - nt.netPropagate(0) - # ptNotify defaults to netPropagate=1 - if netForce or self.netForce: - nt.netForce(1) - # see if the state is specified - if type(state) == type(0): - raise ptResponderStateError,"Specifying state as a number is no longer supported" - elif type(state) == type(''): - if type(self.state_list) != type(None): - try: - idx = self.state_list.index(state) - nt.addResponderState(idx) - except ValueError: - raise ptResponderStateError, "There is no state called '%s'"%(state) - else: - raise ptResponderStateError,"There is no state list provided" - # see if there are events to pass on - if type(events) != type(None): - PtAddEvents(nt,events) - if type(avatar) != type(None): - nt.addCollisionEvent(1,avatar.getKey(),avatar.getKey()) - if fastforward: - nt.setType(PtNotificationType.kResponderFF) - # if fast forwarding, then only do it on the local client - nt.netPropagate(0) - nt.netForce(0) - nt.setActivate(1.0) - nt.send() - def setState(self,key,state,objectName=None,netForce=0,netPropagate=1): - # has the value been set? - if type(self.value) != type(None): - nt = ptNotify(key) - nt.clearReceivers() - # see if the value is a list or byObject or a single - if type(objectName) != type(None) and type(self.byObject) != type(None): - nt.addReceiver(self.byObject[objectName]) - elif type(self.value)==type([]): - for resp in self.value: - nt.addReceiver(resp) - else: - nt.addReceiver(self.value) - if not netPropagate: - nt.netPropagate(0) - # ptNotify defaults to netPropagate=1 - if netForce or self.netForce: - nt.netForce(1) - # see if the state is specified - if type(state) == type(0): - raise ptResponderStateError,"Specifying state as a number is no longer supported" - elif type(state) == type(''): - if type(self.state_list) != type(None): - try: - idx = self.state_list.index(state) - nt.addResponderState(idx) - except ValueError: - raise ptResponderStateError, "There is no state called '%s'"%(state) - else: - raise ptResponderStateError,"There is no state list provided" - # see if there are events to pass on - nt.setType(PtNotificationType.kResponderChangeState) - nt.setActivate(1.0) - nt.send() - - def getState(self): - if (type(self.value) != type(None)): - if type(self.value)==type([]): - for resp in self.value: - obj = resp.getSceneObject() - idx = obj.getResponderState() - curState = self.state_list[idx] - return curState - else: - obj = self.value.getSceneObject() - idx = obj.getResponderState() - curState = self.state_list[idx] - return curState - - -# Responder attribute List -class ptAttribResponderList(ptAttribResponder): - def getdef(self): - return (self.id,self.name,10) - -# Activator attribute (pick activator types box) -class ptAttribNamedActivator(ptAttribActivator): - def getdef(self): - # get attribute as a string, then we will turn it into an activator later - return (self.id,self.name,4,self.value) - -# Responder attribute (pick responder types box) -class ptAttribNamedResponder(ptAttribResponder): - def getdef(self): - # get attribute as a string, then we will turn it into an responder later - return (self.id,self.name,4,self.value) - -# DynamicText attribute pick button -class ptAttribDynamicMap(ptAttribute): - def __init__(self,id,name=None,netForce=0): - ptAttribute.__init__(self,id,name) - self.value = None - self.textmap = None - self.netForce = netForce - # this is to set the value via method (only called if defined) - def __setvalue__(self,value): - # has a ptDynamicText already been made - try: - self.textmap.addKey(value) - except AttributeError: - self.textmap = ptDynamicMap(value) - if self.netForce: - self.textmap.netForce(1) - self.value = self.textmap - def getdef(self): - return (self.id,self.name,11) - -# a GUI Dialogbox attribute -class ptAttribGUIDialog(ptAttribute): - def __init__(self,id,name=None): - ptAttribute.__init__(self,id,name) - self.dialog = None - self.value = None - def getdef(self): - return (self.id,self.name,12) - def __setvalue__(self,value): - self.dialog = ptGUIDialog(value) - self.value = self.dialog - -# a Exclude region attribute -kExRegRelease = 0 -kExRegClear = 1 -class ptAttribExcludeRegion(ptAttribute): - def __init__(self,id,name=None): - ptAttribute.__init__(self,id,name) - self.value = None - def getdef(self): - return (self.id,self.name,13) - def clear(self,sender): - if type(self.value) != type(None): - PtExcludeRegionSet(sender,self.value,kExRegClear) - def release(self,sender): - if type(self.value) != type(None): - PtExcludeRegionSet(sender,self.value,kExRegRelease) - def enable(self): - self.sceneobject.physics.enable() - def disable(self): - self.sceneobject.physics.disable() - def clearNow(self,sender): - if type(self.value) != type(None): - PtExcludeRegionSetNow(sender,self.value,kExRegClear) - def releaseNow(self,sender): - if type(self.value) != type(None): - PtExcludeRegionSetNow(sender,self.value,kExRegRelease) - -class ptAttribWaveSet(ptAttribute): - def __init__(self,id,name=None): - ptAttribute.__init__(self,id,name) - self.value = None - def getdef(self): - return (self.id,self.name,19) - def __setvalue__(self,value): - self.waveset = ptWaveSet(value) - self.value = self.waveset - -class ptAttribSwimCurrent(ptAttribute): - def __init__(self,id,name=None): - ptAttribute.__init__(self,id,name) - self.value = None - self.current = None - def getdef(self): - return (self.id,self.name,21) - def __setvalue__(self,value): - self.current = ptSwimCurrentInterface(value) - self.value = self.current - -class ptAttribClusterList(ptAttributeList): - def __init__(self,id,name=None): - ptAttribute.__init__(self,id,name) - self.value = [] - def getdef(self): - return (self.id,self.name,22) - def __setvalue__(self,value): - self.value.append(ptCluster(value)) - -# special class for byObject that gets the parents name of the values when someone first asks for them -class ptByAnimObject(dict): - def __init__(self): - dict.__init__(self) - self.gotParentKeys = 0 - def getParentKeys(self): - # if we haven't got the parent keys yet, then add them to the dict - if not self.gotParentKeys: - for anim in dict.values(self): - # get the animation target key - aKey = anim.getFirstKey() - if aKey: - # get its parent key - pKey = aKey.getParentKey() - if pKey: - # only add this key once - if not pKey.getName() in self: - dict.__setitem__(self,pKey.getName(),anim) - self.gotParentKeys = 1 - def __getitem__(self,key): - self.getParentKeys() - return dict.__getitem__(self,key) - def keys(self): - self.getParentKeys() - return dict.keys(self) - def get(self, key, *args): - self.getParentKeys() - return dict.get(self, key, *args) - -# an Animation attribute -kAnimEaseNoEase = 0 -kAnimEaseConstAccel = 1 -kAnimEaseSpline = 2 -class ptAttribAnimation(ptAttribute): - def __init__(self,id,name=None,byObject=0,netForce=0): - ptAttribute.__init__(self,id,name) - self.value = None - self.animName = "" - self.netForce = netForce - if byObject: - self.byObject = ptByAnimObject() - else: - self.byObject = None - # this is to set the value via method (only called if defined) - def __setvalue__(self,value): - # has a ptAnimation already been made - if type(value) == type(""): - self.animName = value - try: - self.animation.setAnimName(value) - # then if there are animations by object then set those, too - if isinstance(self.byObject,ptByAnimObject): - for anim in self.byObject.values(): - anim.setAnimName(value) - except AttributeError: - self.animation = ptAnimation() - self.animation.setAnimName(value) - if self.netForce: - self.animation.netForce(1) - self.value = self.animation - elif isinstance(value,ptKey): - try: - self.animation.addKey(value) - except AttributeError: - self.animation = ptAnimation() - self.animation.addKey(value) - if self.netForce: - self.animation.netForce(1) - self.value = self.animation - if isinstance(self.byObject,ptByAnimObject): - singleAnim = ptAnimation() - singleAnim.addKey(value) - if self.netForce: - singleAnim.netForce(1) - # set name if known - if self.animName != "": - singleAnim.setAnimName(self.animName) - name = value.getName() - self.byObject[name] = singleAnim - def getdef(self): - return (self.id,self.name,14) - -# a Behavior attribute -class ptAttribBehavior(ptAttribute): - "Attribute for specifying behaviors, including multistage Behaviors" - def __init__(self,id,name=None,netForce=1,netProp=1): - ptAttribute.__init__(self,id,name) - self.value = None - self.netForce = netForce - self.netProp = netProp - def __setvalue__(self,value): - self.value = value - PtSetBehaviorNetFlags(self.value, self.netForce, self.netProp) - def getdef(self): - return (self.id,self.name,15) - def run(self,avatar): - "This will run the behavior on said avatar" - if type(self.value) != type(None): - if self.netForce: - self.value.netForce(1) - avatar.avatar.netForce(1) - avatar.avatar.runBehavior(self.value,self.netForce,self.netProp) - def nextStage(self,avatar,transitionTime=1.0,setTimeFlag=1,newTime=0.0,dirFlag=0,isForward=1): - "This will go to the next stage in a multi-stage behavior" - if type(self.value) != type(None): - if self.netForce: - self.value.netForce(1) - avatar.avatar.netForce(1) - avatar.avatar.nextStage(self.value,transitionTime,setTimeFlag,newTime,dirFlag,isForward,self.netForce) - def previousStage(self,avatar,transitionTime=1.0,setTimeFlag=1,newTime=0.0,dirFlag=0,isForward=1): - "This will go to the next stage in a multi-stage behavior" - if type(self.value) != type(None): - if self.netForce: - self.value.netForce(1) - avatar.avatar.netForce(1) - avatar.avatar.previousStage(self.value,transitionTime,setTimeFlag,newTime,dirFlag,isForward,self.netForce) - def gotoStage(self,avatar,stage,transitionTime=1.0,setTimeFlag=1,newTime=0.0,dirFlag=0,isForward=1): - "This will go to the next stage in a multi-stage behavior" - if type(self.value) != type(None): - if self.netForce: - self.value.netForce(1) - avatar.avatar.netForce(1) - avatar.avatar.gotoStage(self.value,stage,transitionTime,setTimeFlag,newTime,dirFlag,isForward,self.netForce) - def setLoopCount(self,stage,loopCount): - "This will set the loop count for a stage" - if type(self.value) != type(None): - PtSetBehaviorLoopCount(self.value,stage,loopCount,self.netForce) - -# Material texture attribute pick button -class ptAttribMaterial(ptAttribute): - def __init__(self,id,name=None): - ptAttribute.__init__(self,id,name) - self.value = None - self.map = None - # this is to set the value via method (only called if defined) - def __setvalue__(self,value): - self.map = ptImage(value) - self.value = self.map - def getdef(self): - return (self.id,self.name,16) - -class ptAttribMaterialAnimation(ptAttribute): - def __init__(self, id, name = None): - ptAttribute.__init__(self, id, name) - self.value = None - self.animation = None - - def __setvalue__(self, value): - if type(self.animation) == type(None): - self.animation = ptAnimation() - self.animation.addKey(value) - self.value = self.animation - else: - self.animation.addKey(value) - - def getdef(self): - return (self.id, self.name, 23) - - -# Sceneobject list attribute (pick multiple sceneobjects box) -class ptAttribMaterialList(ptAttributeList): - def __init__(self,id,name=None,byObject=0,netForce=0): - ptAttributeList.__init__(self,id,name) - self.value = [] # start as an empty list - self.map = self.value - self.netForce = netForce - if byObject: - self.byObject = {} - else: - self.byObject = None - def getdef(self): - return (self.id,self.name,6) - def __setvalue__(self,value): - if self.netForce: - value.netForce(1) - self.value.append(value) - if type(self.byObject) == type({}): - name = value.getName() - self.byObject[name] = value - -# a GUI PopUpMenu attribute -class ptAttribGUIPopUpMenu(ptAttribute): - def __init__(self,id,name=None): - ptAttribute.__init__(self,id,name) - self.value = None - def getdef(self): - return (self.id,self.name,17) - def __setvalue__(self,value): - self.menu = ptGUIPopUpMenu(value) - self.value = self.menu - -# a GUI Skin attribute -class ptAttribGUISkin(ptAttribute): - def __init__(self,id,name=None): - ptAttribute.__init__(self,id,name) - self.value = None - def getdef(self): - return (self.id,self.name,18) - def __setvalue__(self,value): - self.skin = ptGUISkin(value) - self.value = self.skin - -# a Grass Shader attribute -class ptAttribGrassShader(ptAttribute): - def __init__(self,id,name=None): - ptAttribute.__init__(self,id,name) - self.value = None - def getdef(self): - return (self.id,self.name,24) - def __setvalue__(self,value): - self.shader = ptGrassShader(value) - self.value = self.shader - - -# -# ptModifier - class for creating a Plasma modifier, such as a responder - -# base class -class ptModifier: - def __init__(self): - self.key = None - self.SDL = None - self.version = 0 - -class ptResponder(ptModifier): - # this modifier will get a plNotifyMsg as an OnNotify - def __init__(self): - ptModifier.__init__(self) - self.sceneobject = None - -class ptMultiModifier(ptModifier): - # this modifier can be attached to multiple object, but only one module - def __init__(self): - ptModifier.__init__(self) diff --git a/Scripts/Python/plasma/PlasmaVaultConstants.py b/Scripts/Python/plasma/PlasmaVaultConstants.py deleted file mode 100644 index 22e8edd0..00000000 --- a/Scripts/Python/plasma/PlasmaVaultConstants.py +++ /dev/null @@ -1,98 +0,0 @@ -""" *==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program 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 this program. If not, see . - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - - *==LICENSE==* """ -class PtVaultCallbackTypes: - """(none)""" - kVaultConnected = 1 - kVaultNodeSaved = 2 - kVaultNodeRefAdded = 3 - kVaultRemovingNodeRef = 4 - kVaultNodeRefRemoved = 5 - kVaultNodeInitialized = 6 - kVaultOperationFailed = 7 - kVaultNodeAdded = 8 - kVaultDisconnected = 9 - -class PtVaultNodeTypes: - """(none)""" - kInvalidNode = 0 - kAgeInfoNode = 33 - kAgeInfoListNode = 34 - kMarkerGameNode = 35 - kVNodeMgrPlayerNode = 2 - kVNodeMgrAgeNode = 3 - kFolderNode = 22 - kPlayerInfoNode = 23 - kImageNode = 25 - kTextNoteNode = 26 - kSDLNode = 27 - kAgeLinkNode = 28 - kChronicleNode = 29 - kPlayerInfoListNode = 30 - -class PtVaultNotifyTypes: - """(none)""" - kRegisteredOwnedAge = 9 - kUnRegisteredOwnedAge = 10 - kRegisteredVisitAge = 11 - kUnRegisteredVisitAge = 12 - kPublicAgeCreated = 13 - kPublicAgeRemoved = 14 - -class PtVaultStandardNodes: - """(none)""" - kUserDefinedNode = 0 - kInboxFolder = 1 - kBuddyListFolder = 2 - kIgnoreListFolder = 3 - kPeopleIKnowAboutFolder = 4 - kChronicleFolder = 6 - kAvatarOutfitFolder = 7 - kAgeTypeJournalFolder = 8 - kSubAgesFolder = 9 - kHoodMembersFolder = 11 - kAllPlayersFolder = 12 - kAgeMembersFolder = 13 - kAgeJournalsFolder = 14 - kAgeInstanceSDLNode = 16 - kCanVisitFolder = 18 - kAgeOwnersFolder = 19 - kAllAgeGlobalSDLNodesFolder = 20 - kPlayerInfoNode = 21 - kPublicAgesFolder = 22 - kAgesIOwnFolder = 23 - kAgesICanVisitFolder = 24 - kAvatarClosetFolder = 25 - kGlobalInboxFolder = 30 - -class PtVaultTextNoteSubTypes: - """(none)""" - kGeneric = 0 - -class PtVaultTextNoteTypes: - """(none)""" - kGeneric = 0 - kCCRPetition = 1 - diff --git a/Scripts/Python/plasma/glue.py b/Scripts/Python/plasma/glue.py deleted file mode 100644 index f9aa14cb..00000000 --- a/Scripts/Python/plasma/glue.py +++ /dev/null @@ -1,208 +0,0 @@ -""" *==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program 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 this program. If not, see . - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - - *==LICENSE==* """ -# glue code in python for the glue code in C++ -# This assumes that this will be loaded into the module that we are trying to do -# with an execfile('.\\python\\system\\glue.py') at the end of the module (after everything is defined) -# SPECIAL WARNING(1): This glue code returns the attributes in reverse ID order! -glue_cl = None # the class of the modifier -glue_inst = None # instance of the class modifier -glue_params = None # parameters dictionary: mapped id to instance -glue_paramKeys = None # this is the parameter ID list, that should be sorted -try: - x = glue_verbose -except NameError: - glue_verbose = 0 -def glue_getClass(): - global glue_cl - if glue_cl == None: - try: - cl = eval(glue_name) - if issubclass(cl,ptModifier): - glue_cl = cl - else: - if glue_verbose: - print "Class %s is not derived from modifier" % (cl.__name__) - except NameError: - if glue_verbose: - try: - print "Could not find class %s" % (glue_name) - except NameError: - print "Filename/classname not set!" - return glue_cl -def glue_getInst(): - global glue_inst - if type(glue_inst) == type(None): - cl = glue_getClass() - if cl != None: - glue_inst = cl() - return glue_inst -def glue_delInst(): - global glue_inst - global glue_cl - global glue_params - global glue_paramKeys - if type(glue_inst) != type(None): - del glue_inst - # remove our references - glue_cl = None - glue_params = None - glue_paramKeys = None -def glue_getVersion(): - inst = glue_getInst() - ver = inst.version - glue_delInst() - return ver -def glue_findAndAddAttribs(obj, glue_params): - if isinstance(obj,ptAttribute): - if glue_params.has_key(obj.id): - if glue_verbose: - print "WARNING: Duplicate attribute ids!" - print "%s has id %d which is already defined in %s" % (obj.name, obj.id, glue_params[obj.id].name) - else: - glue_params[obj.id] = obj - elif type(obj) == type([]): - for o in obj: - glue_findAndAddAttribs(o, glue_params) - elif type(obj) == type({}): - for o in obj.values(): - glue_findAndAddAttribs(o, glue_params) - elif type(obj) == type( () ): - for o in obj: - glue_findAndAddAttribs(o, glue_params) - -def glue_getParamDict(): - global glue_params - global glue_paramKeys - if type(glue_params) == type(None): - glue_params = {} - gd = globals() - for obj in gd.values(): - glue_findAndAddAttribs(obj, glue_params) - # rebuild the parameter sorted key list - glue_paramKeys = glue_params.keys() - glue_paramKeys.sort() - glue_paramKeys.reverse() # reserve the order because PlasmaMax will ask for them in reverse order - return glue_params -def glue_getClassName(): - cl = glue_getClass() - if cl != None: - return cl.__name__ - if glue_verbose: - print "Class not found in %s.py" % (glue_name) - return None -def glue_getBlockID(): - inst = glue_getInst() - if inst != None: - return inst.id - if glue_verbose: - print "Instance could not be created in %s.py" % (glue_name) - return None -def glue_getNumParams(): - pd = glue_getParamDict() - if pd != None: - return len(pd) - if glue_verbose: - print "No attributes found in %s.py" % (glue_name) - return 0 -def glue_getParam(number): - global glue_paramKeys - pd = glue_getParamDict() - if pd != None: - # see if there is a paramKey list - if type(glue_paramKeys) == type([]): - if number >= 0 and number < len(glue_paramKeys): - return pd[glue_paramKeys[number]].getdef() - else: - print "glue_getParam: Error! %d out of range of attribute list" % (number) - else: - pl = pd.values() - if number >= 0 and number < len(pl): - return pl[number].getdef() - else: - if glue_verbose: - print "glue_getParam: Error! %d out of range of attribute list" % (number) - if glue_verbose: - print "GLUE: Attribute list error" - return None -def glue_setParam(id,value): - pd = glue_getParamDict() - if pd != None: - if pd.has_key(id): - # first try to set the attribute via function call (if there is one) - try: - pd[id].__setvalue__(value) - except AttributeError: - if isinstance(pd[id],ptAttributeList): - try: - if type(pd[id].value) != type([]): - pd[id].value = [] # make sure that the value starts as an empty list - except AttributeError: - pd[id].value = [] # or if value hasn't been defined yet, then do it now - pd[id].value.append(value) # add in new value to list - else: - pd[id].value = value - else: - if glue_verbose: - print "setParam: can't find id=",id - else: - print "setParma: Something terribly has gone wrong. Head for the cover." -def glue_isNamedAttribute(id): - pd = glue_getParamDict() - if pd != None: - try: - if isinstance(pd[id],ptAttribNamedActivator): - return 1 - if isinstance(pd[id],ptAttribNamedResponder): - return 2 - except KeyError: - if glue_verbose: - print "Could not find id=%d attribute" % (id) - return 0 -def glue_isMultiModifier(): - inst = glue_getInst() - if isinstance(inst,ptMultiModifier): - return 1 - return 0 -def glue_getVisInfo(number): - global glue_paramKeys - pd = glue_getParamDict() - if pd != None: - # see if there is a paramKey list - if type(glue_paramKeys) == type([]): - if number >= 0 and number < len(glue_paramKeys): - return pd[glue_paramKeys[number]].getVisInfo() - else: - print "glue_getVisInfo: Error! %d out of range of attribute list" % (number) - else: - pl = pd.values() - if number >= 0 and number < len(pl): - return pl[number].getVisInfo() - else: - if glue_verbose: - print "glue_getVisInfo: Error! %d out of range of attribute list" % (number) - if glue_verbose: - print "GLUE: Attribute list error" - return None diff --git a/Scripts/Python/plasma/pch.py b/Scripts/Python/plasma/pch.py deleted file mode 100644 index b113f645..00000000 --- a/Scripts/Python/plasma/pch.py +++ /dev/null @@ -1,286 +0,0 @@ -""" *==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program 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 this program. If not, see . - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - - *==LICENSE==* """ -""" pch - Plasma Console Helper -This module aids in the using the plasma console to debug PythonFileComponents. -""" -# plasma console helper -import Plasma -import PlasmaTypes -import sys - -# globals for the outside and inside to grab -__pmods = [] -__sel = 0 -__selattr = 0 - -# help! -def help(): - "display help" - print "functions:" - print " getmods() - gets all the modules available" - print " showmods() - show the modules (and the current selected module)" - print " selmod(i) - selects module 'i'; returns module object" - print " showmod() - shows detail of the module selected" - print " showdoc() - shows the doc field of the module selected" - print " showattribs() - shows all the plasma attributes of the module selected" - print " selattrib(id) - selects attribute 'id' in the selected module;" - print " returns attribute object" - print " setattrib(value) - sets the selected attribute to 'value'" - print " showglobals() - shows the globals for the selected module" - print " setglobal(name,value) - set global 'name' to 'value' in selected module" - print " getglobal(name) - returns global object" - print " showinst() - shows the instance of the ptModifier class for the selected" - print " module" - print " getinst() - returns the instance object" - print " showvars(inst) - shows the instance variables of the ptModifier class of" - print " the selected module" - print " showmethods(inst) - shows the methods of the ptModifier class of the" - print " selected module" - print " showfunc(method) - decompiles a method or function and shows source" - print " setvar(name,value) - sets instance variable 'name' to 'value' in the" - print " selected module" - print " getvar(name) - returns the instance variable object (in selected module)" -# modules -def getmods(): - "get all the PythonFileComponent modules" - global __pmods,__sel - __pmods = [] # wipe the module list clean - print "Plasma modules:" - for modname in sys.modules.keys(): - mod = sys.modules[modname] - if hasattr(mod,"glue_inst"): - if __sel == len(__pmods): - print "*%d. %s" % (len(__pmods),modname[:-13]) - else: - print " %d. %s" % (len(__pmods),modname[:-13]) - __pmods.append([modname,mod]) -def showmods(): - "show all the PythonFileComponent modules" - global __pmods - global __sel - idx = 0 - print "Plasma modules:" - for mod in __pmods: - if idx == __sel: - print "*%d. %s" % (idx,mod[0][:-13]) - else: - print " %d. %s" % (idx,mod[0][:-13]) - idx += 1 -def selmod(idx=None): - "select a module from the list" - global __pmods - global __sel - if type(idx) == type(None): - idx = __sel - elif type(idx) == type(""): - # its a string, then find it by module name - i = 0 - for mod in __pmods: - if mod[0][:-13] == idx: - break - i += 1 - # if we didn't find the module - if i == len(__pmods): - print "Module %s not found" % idx - return - idx = i - if idx < len(__pmods): - __sel = idx - print "%s selected" % (__pmods[idx][0][:-13]) - return __pmods[__sel][1] - else: - print "Error: index not valid. There are %d modules" % (len(__pmods)) -# find attributes -def showmod(): - "show details of the selected module" - global __pmods - global __sel - print "Module: %s" % (__pmods[__sel][0][:-13]) - showdoc() - showattribs() - showglobals() - showinst() -def showdoc(): - "show the doc of the module selected" - global __pmods - global __sel - print "Doc:" - print __pmods[__sel][1].__doc__ -def showattribs(): - "show the plasma attributes of the module selected" - global __pmods - global __sel - global __selattr - print "Attributes in %s:" % (__pmods[__sel][0][:-13]) - for name in __pmods[__sel][1].__dict__.keys(): - ist = __pmods[__sel][1].__dict__[name] - if isinstance(ist,PlasmaTypes.ptAttribute): - if __selattr == ist.id: - print "*(%d) %s(%s) =" % (ist.id,name,ist.__class__.__name__),ist.value - else: - print " (%d) %s(%s) =" % (ist.id,name,ist.__class__.__name__),ist.value -def selattrib(id=None): - "select a plasma attribute by id in the selected module" - global __pmods - global __sel - global __selattr - if type(id) == type(None): - id = __selattr - for name in __pmods[__sel][1].__dict__.keys(): - ist = __pmods[__sel][1].__dict__[name] - if isinstance(ist,PlasmaTypes.ptAttribute): - if id == ist.id: - __selattr = ist.id - print "%s(%s) =" % (name,ist.__class__.__name__),ist.value - return ist - print "Error: Attribute ID %d not found" % (id) -def setattrib(value): - "set the value of the selected plasma attribute in the selected module" - global __pmods - global __sel - global __selattr - for name in __pmods[__sel][1].__dict__.keys(): - ist = __pmods[__sel][1].__dict__[name] - if isinstance(ist,PlasmaTypes.ptAttribute): - if __selattr == ist.id: - if type(ist.value) == type(None) or type(ist.value) == type(value): - # see if there is a __setvalue__ method - try: - ist.__setvalue__(value) - except AttributeError: - ist.value = value - else: - print "Error: value is not same type as attribute" - return - print "Error: Attribute ID %d not found" % (id) -# find globals -def showglobals(): - "show the global variables of the selected module" - global __pmods - global __sel - print "Globals:" - for name in __pmods[__sel][1].__dict__.keys(): - ist = __pmods[__sel][1].__dict__[name] - # make sure that its not something we already know about - if not hasattr(Plasma,name) and not hasattr(PlasmaTypes,name): - if not isinstance(ist,PlasmaTypes.ptAttribute) and not isinstance(ist,PlasmaTypes.ptModifier): - if name[:2] != '__' and name[:4] != 'glue': - if type(ist) != type(sys) and type(ist) != type(PlasmaTypes.ptAttribute): - print " %s =" % (name),ist -def setglobal(name,value): - "set a global variable to a value with in the selected module" - global __pmods - global __sel - # first see if there is already a glabal by that name - if not __pmods[__sel][1].__dict__.has_key(name): - print "Warning: creating new global!" - __pmods[__sel][1].__dict__[name] = value - print "%s = " % (name),__pmods[__sel][1].__dict__[name] -def getglobal(name): - "get a global variable with in the selected module" - global __pmods - global __sel - return __pmods[__sel][1].__dict__[name] -# find instance -def showinst(): - "show details of the instance of the ptModifier class in the selected module" - global __pmods - global __sel - for name in __pmods[__sel][1].__dict__.keys(): - ist = __pmods[__sel][1].__dict__[name] - if isinstance(ist,PlasmaTypes.ptModifier): - print "Instance of %s in module %s:" % (ist.__class__.__name__,__pmods[__sel][1].__name__[:-13]) - print " Doc: ",ist.__doc__ - showvars(ist) - showmethods(ist) -def getinst(): - "gets the instance of the ptModifier class in the selected module" - global __pmods - global __sel - for name in __pmods[__sel][1].__dict__.keys(): - ist = __pmods[__sel][1].__dict__[name] - if isinstance(ist,PlasmaTypes.ptModifier): - return ist -def showvars(instance): - "shows the variables of the instance" - print " Variables:" - if len(instance.__dict__) > 0: - for vname in instance.__dict__.keys(): - print " %s =" % (vname),instance.__dict__[vname] - else: - print " (none)" -def showmethods(instance): - "shows the methods of the instance" - print " Methods:" - for mname in instance.__class__.__dict__.keys(): - mist = instance.__class__.__dict__[mname] - # is it a function... see if it has code - if hasattr(mist,'func_code'): - # gather arguments - args = "(" - for i in range(mist.func_code.co_argcount): - args += mist.func_code.co_varnames[i] - if i+1 < mist.func_code.co_argcount: - args += "," - args += ")" - print " %s%s" % (mist.__name__,args) - print " Doc:", mist.__doc__ -def showfunc(f): - "decompiles function" - import decompyle - if hasattr(f,'func_code'): - # create the argument list - argstr = "(" - argcount = 0 - for arg in f.func_code.co_varnames[:f.func_code.co_argcount]: - argstr += arg - argcount += 1 - if argcount < f.func_code.co_argcount: - argstr += "," - argstr += ")" - print "%s%s" % (f.func_name,argstr) - print " Doc:",f.__doc__ - decompyle.decompyle(f.func_code) -def setvar(vname,value): - "set a variable within the instance of the ptModifier class in the selected module" - global __pmods - global __sel - for name in __pmods[__sel][1].__dict__.keys(): - ist = __pmods[__sel][1].__dict__[name] - if isinstance(ist,PlasmaTypes.ptModifier): - # first see if there is already a glabal by that name - if not ist.__dict__.has_key(vname): - print "Warning: creating new class variable!" - ist.__dict__[vname] = value - print "%s = " % (vname),ist.__dict__[vname] -def getvar(vname): - "get the variable in the instance of the ptModifier class in the selected module" - global __pmods - global __sel - for name in __pmods[__sel][1].__dict__.keys(): - ist = __pmods[__sel][1].__dict__[name] - if isinstance(ist,PlasmaTypes.ptModifier): - return ist.__dict__[vname] diff --git a/Scripts/Python/plasma/ptWordFilter.py b/Scripts/Python/plasma/ptWordFilter.py deleted file mode 100644 index 4fa59cfc..00000000 --- a/Scripts/Python/plasma/ptWordFilter.py +++ /dev/null @@ -1,140 +0,0 @@ -""" *==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program 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 this program. If not, see . - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - - *==LICENSE==* """ -""" -This module is the word filter to be used... -""" -import string -import re - -# Rating levels -xRatedG = 0 -xRatedPG = 1 -xRatedPG13 = 2 -xRatedR = 3 -xRatedX = 4 - -class LanguageFilter: - def __init__(self): - pass - def test(self,sentence): - "returns censored sentence" - return xRatedG - def censor(self,sentence,censorLevel): - "returns censored sentence" - return sentence - -class ExactMatchListFilter(LanguageFilter): - def __init__(self,wordlist): - self.wordlist = wordlist - def test(self,sentence): - "return the rating of sentence in question" - rated = xRatedG # assume rated lowest level - startidx = 0 - for endidx in range(len(sentence)): - if sentence[endidx] in string.whitespace or sentence[endidx] in string.punctuation: - if startidx != endidx: - try: - # find and get rating and substitute - rating = self.wordlist[string.lower(sentence[startidx:endidx])] - except LookupError: - # couldn't find word - rating = None - if rating != None and rating.rating > rated: - # substitute into string - rated = rating.rating - startidx = endidx + 1 - if startidx < len(sentence): - try: - # find and get rating and substitute - rating = self.wordlist[string.lower(sentence[startidx:])] - except LookupError: - # couldn't find word - rating = None - if rating != None and rating.rating > rated: - # substitute into string - rated = rating.rating - return rated - - def censor(self,sentence,censorLevel): - "censors a sentence to a rating" - # break into words, but perserve original punctuation - censored = "" - startidx = 0 - for endidx in range(len(sentence)): - if sentence[endidx] in string.whitespace or sentence[endidx] in string.punctuation: - if startidx != endidx: - try: - # find and get rating and substitute - rating = self.wordlist[string.lower(sentence[startidx:endidx])] - except LookupError: - # couldn't find word - rating = None - if rating != None and rating.rating > censorLevel: - # substitute into string - censored += rating.substitute + sentence[endidx] - else: - censored += sentence[startidx:endidx] + sentence[endidx] - else: - censored += sentence[startidx] - startidx = endidx + 1 - if startidx < len(sentence): - # Special after loop processing! - try: - # find and get rating and substitute - rating = self.wordlist[string.lower(sentence[startidx:])] - except LookupError: - # couldn't find word - rating = None - if rating != None and rating.rating > censorLevel: - # substitute into string - censored += rating.substitute - else: - censored += sentence[startidx:] - return censored - -class REFilter(LanguageFilter): - def __init__(self,regexp,rating): - self.compiledRE = re.compile(regexp, re.IGNORECASE | re.MULTILINE ) - if not isinstance(rating,Rating): - PtDebugPrint("ptWordFilter: rating for %s not of type Rating" % (regexp)) - self.rating = rating - def test(self,sentence): - "return the rating of sentence in question" - if self.compiledRE.search(sentence) != None: - return self.rating.rating - return xRatedG - def censor(self,sentence,censorLevel): - "censors a sentence to a rating" - if self.rating.rating > censorLevel: - if self.compiledRE.search(sentence) != None: - return self.compiledRE.sub(self.rating.substitute,sentence) - return sentence - -class Rating: - "substitute can be string for exact substitute or number of splat replacement" - def __init__(self,rating,subtitute="*****"): - self.rating = rating - self.substitute = subtitute diff --git a/Scripts/Python/system/Bastion.py b/Scripts/Python/system/Bastion.py deleted file mode 100644 index ae2db74c..00000000 --- a/Scripts/Python/system/Bastion.py +++ /dev/null @@ -1,177 +0,0 @@ -"""Bastionification utility. - -A bastion (for another object -- the 'original') is an object that has -the same methods as the original but does not give access to its -instance variables. Bastions have a number of uses, but the most -obvious one is to provide code executing in restricted mode with a -safe interface to an object implemented in unrestricted mode. - -The bastionification routine has an optional second argument which is -a filter function. Only those methods for which the filter method -(called with the method name as argument) returns true are accessible. -The default filter method returns true unless the method name begins -with an underscore. - -There are a number of possible implementations of bastions. We use a -'lazy' approach where the bastion's __getattr__() discipline does all -the work for a particular method the first time it is used. This is -usually fastest, especially if the user doesn't call all available -methods. The retrieved methods are stored as instance variables of -the bastion, so the overhead is only occurred on the first use of each -method. - -Detail: the bastion class has a __repr__() discipline which includes -the repr() of the original object. This is precomputed when the -bastion is created. - -""" - -__all__ = ["BastionClass", "Bastion"] - -from types import MethodType - - -class BastionClass: - - """Helper class used by the Bastion() function. - - You could subclass this and pass the subclass as the bastionclass - argument to the Bastion() function, as long as the constructor has - the same signature (a get() function and a name for the object). - - """ - - def __init__(self, get, name): - """Constructor. - - Arguments: - - get - a function that gets the attribute value (by name) - name - a human-readable name for the original object - (suggestion: use repr(object)) - - """ - self._get_ = get - self._name_ = name - - def __repr__(self): - """Return a representation string. - - This includes the name passed in to the constructor, so that - if you print the bastion during debugging, at least you have - some idea of what it is. - - """ - return "" % self._name_ - - def __getattr__(self, name): - """Get an as-yet undefined attribute value. - - This calls the get() function that was passed to the - constructor. The result is stored as an instance variable so - that the next time the same attribute is requested, - __getattr__() won't be invoked. - - If the get() function raises an exception, this is simply - passed on -- exceptions are not cached. - - """ - attribute = self._get_(name) - self.__dict__[name] = attribute - return attribute - - -def Bastion(object, filter = lambda name: name[:1] != '_', - name=None, bastionclass=BastionClass): - """Create a bastion for an object, using an optional filter. - - See the Bastion module's documentation for background. - - Arguments: - - object - the original object - filter - a predicate that decides whether a function name is OK; - by default all names are OK that don't start with '_' - name - the name of the object; default repr(object) - bastionclass - class used to create the bastion; default BastionClass - - """ - - raise RuntimeError, "This code is not secure in Python 2.2 and 2.3" - - # Note: we define *two* ad-hoc functions here, get1 and get2. - # Both are intended to be called in the same way: get(name). - # It is clear that the real work (getting the attribute - # from the object and calling the filter) is done in get1. - # Why can't we pass get1 to the bastion? Because the user - # would be able to override the filter argument! With get2, - # overriding the default argument is no security loophole: - # all it does is call it. - # Also notice that we can't place the object and filter as - # instance variables on the bastion object itself, since - # the user has full access to all instance variables! - - def get1(name, object=object, filter=filter): - """Internal function for Bastion(). See source comments.""" - if filter(name): - attribute = getattr(object, name) - if type(attribute) == MethodType: - return attribute - raise AttributeError, name - - def get2(name, get1=get1): - """Internal function for Bastion(). See source comments.""" - return get1(name) - - if name is None: - name = `object` - return bastionclass(get2, name) - - -def _test(): - """Test the Bastion() function.""" - class Original: - def __init__(self): - self.sum = 0 - def add(self, n): - self._add(n) - def _add(self, n): - self.sum = self.sum + n - def total(self): - return self.sum - o = Original() - b = Bastion(o) - testcode = """if 1: - b.add(81) - b.add(18) - print "b.total() =", b.total() - try: - print "b.sum =", b.sum, - except: - print "inaccessible" - else: - print "accessible" - try: - print "b._add =", b._add, - except: - print "inaccessible" - else: - print "accessible" - try: - print "b._get_.func_defaults =", map(type, b._get_.func_defaults), - except: - print "inaccessible" - else: - print "accessible" - \n""" - exec testcode - print '='*20, "Using rexec:", '='*20 - import rexec - r = rexec.RExec() - m = r.add_module('__main__') - m.b = b - r.r_exec(testcode) - - -if __name__ == '__main__': - _test() diff --git a/Scripts/Python/system/ConfigParser.py b/Scripts/Python/system/ConfigParser.py deleted file mode 100644 index d98993af..00000000 --- a/Scripts/Python/system/ConfigParser.py +++ /dev/null @@ -1,616 +0,0 @@ -"""Configuration file parser. - -A setup file consists of sections, lead by a "[section]" header, -and followed by "name: value" entries, with continuations and such in -the style of RFC 822. - -The option values can contain format strings which refer to other values in -the same section, or values in a special [DEFAULT] section. - -For example: - - something: %(dir)s/whatever - -would resolve the "%(dir)s" to the value of dir. All reference -expansions are done late, on demand. - -Intrinsic defaults can be specified by passing them into the -ConfigParser constructor as a dictionary. - -class: - -ConfigParser -- responsible for parsing a list of - configuration files, and managing the parsed database. - - methods: - - __init__(defaults=None) - create the parser and specify a dictionary of intrinsic defaults. The - keys must be strings, the values must be appropriate for %()s string - interpolation. Note that `__name__' is always an intrinsic default; - it's value is the section's name. - - sections() - return all the configuration section names, sans DEFAULT - - has_section(section) - return whether the given section exists - - has_option(section, option) - return whether the given option exists in the given section - - options(section) - return list of configuration options for the named section - - read(filenames) - read and parse the list of named configuration files, given by - name. A single filename is also allowed. Non-existing files - are ignored. - - readfp(fp, filename=None) - read and parse one configuration file, given as a file object. - The filename defaults to fp.name; it is only used in error - messages (if fp has no `name' attribute, the string `' is used). - - get(section, option, raw=False, vars=None) - return a string value for the named option. All % interpolations are - expanded in the return values, based on the defaults passed into the - constructor and the DEFAULT section. Additional substitutions may be - provided using the `vars' argument, which must be a dictionary whose - contents override any pre-existing defaults. - - getint(section, options) - like get(), but convert value to an integer - - getfloat(section, options) - like get(), but convert value to a float - - getboolean(section, options) - like get(), but convert value to a boolean (currently case - insensitively defined as 0, false, no, off for False, and 1, true, - yes, on for True). Returns False or True. - - items(section, raw=False, vars=None) - return a list of tuples with (name, value) for each option - in the section. - - remove_section(section) - remove the given file section and all its options - - remove_option(section, option) - remove the given option from the given section - - set(section, option, value) - set the given option - - write(fp) - write the configuration state in .ini format -""" - -import re - -__all__ = ["NoSectionError", "DuplicateSectionError", "NoOptionError", - "InterpolationError", "InterpolationDepthError", - "InterpolationSyntaxError", "ParsingError", - "MissingSectionHeaderError", "ConfigParser", "SafeConfigParser", - "DEFAULTSECT", "MAX_INTERPOLATION_DEPTH"] - -DEFAULTSECT = "DEFAULT" - -MAX_INTERPOLATION_DEPTH = 10 - - - -# exception classes -class Error(Exception): - """Base class for ConfigParser exceptions.""" - - def __init__(self, msg=''): - self.message = msg - Exception.__init__(self, msg) - - def __repr__(self): - return self.message - - __str__ = __repr__ - -class NoSectionError(Error): - """Raised when no section matches a requested option.""" - - def __init__(self, section): - Error.__init__(self, 'No section: ' + `section`) - self.section = section - -class DuplicateSectionError(Error): - """Raised when a section is multiply-created.""" - - def __init__(self, section): - Error.__init__(self, "Section %r already exists" % section) - self.section = section - -class NoOptionError(Error): - """A requested option was not found.""" - - def __init__(self, option, section): - Error.__init__(self, "No option %r in section: %r" % - (option, section)) - self.option = option - self.section = section - -class InterpolationError(Error): - """Base class for interpolation-related exceptions.""" - - def __init__(self, option, section, msg): - Error.__init__(self, msg) - self.option = option - self.section = section - -class InterpolationMissingOptionError(InterpolationError): - """A string substitution required a setting which was not available.""" - - def __init__(self, option, section, rawval, reference): - msg = ("Bad value substitution:\n" - "\tsection: [%s]\n" - "\toption : %s\n" - "\tkey : %s\n" - "\trawval : %s\n" - % (section, option, reference, rawval)) - InterpolationError.__init__(self, option, section, msg) - self.reference = reference - -class InterpolationSyntaxError(InterpolationError): - """Raised when the source text into which substitutions are made - does not conform to the required syntax.""" - -class InterpolationDepthError(InterpolationError): - """Raised when substitutions are nested too deeply.""" - - def __init__(self, option, section, rawval): - msg = ("Value interpolation too deeply recursive:\n" - "\tsection: [%s]\n" - "\toption : %s\n" - "\trawval : %s\n" - % (section, option, rawval)) - InterpolationError.__init__(self, option, section, msg) - -class ParsingError(Error): - """Raised when a configuration file does not follow legal syntax.""" - - def __init__(self, filename): - Error.__init__(self, 'File contains parsing errors: %s' % filename) - self.filename = filename - self.errors = [] - - def append(self, lineno, line): - self.errors.append((lineno, line)) - self.message += '\n\t[line %2d]: %s' % (lineno, line) - -class MissingSectionHeaderError(ParsingError): - """Raised when a key-value pair is found before any section header.""" - - def __init__(self, filename, lineno, line): - Error.__init__( - self, - 'File contains no section headers.\nfile: %s, line: %d\n%s' % - (filename, lineno, line)) - self.filename = filename - self.lineno = lineno - self.line = line - - - -class RawConfigParser: - def __init__(self, defaults=None): - self._sections = {} - if defaults is None: - self._defaults = {} - else: - self._defaults = defaults - - def defaults(self): - return self._defaults - - def sections(self): - """Return a list of section names, excluding [DEFAULT]""" - # self._sections will never have [DEFAULT] in it - return self._sections.keys() - - def add_section(self, section): - """Create a new section in the configuration. - - Raise DuplicateSectionError if a section by the specified name - already exists. - """ - if section in self._sections: - raise DuplicateSectionError(section) - self._sections[section] = {} - - def has_section(self, section): - """Indicate whether the named section is present in the configuration. - - The DEFAULT section is not acknowledged. - """ - return section in self._sections - - def options(self, section): - """Return a list of option names for the given section name.""" - try: - opts = self._sections[section].copy() - except KeyError: - raise NoSectionError(section) - opts.update(self._defaults) - if '__name__' in opts: - del opts['__name__'] - return opts.keys() - - def read(self, filenames): - """Read and parse a filename or a list of filenames. - - Files that cannot be opened are silently ignored; this is - designed so that you can specify a list of potential - configuration file locations (e.g. current directory, user's - home directory, systemwide directory), and all existing - configuration files in the list will be read. A single - filename may also be given. - """ - if isinstance(filenames, basestring): - filenames = [filenames] - for filename in filenames: - try: - fp = open(filename) - except IOError: - continue - self._read(fp, filename) - fp.close() - - def readfp(self, fp, filename=None): - """Like read() but the argument must be a file-like object. - - The `fp' argument must have a `readline' method. Optional - second argument is the `filename', which if not given, is - taken from fp.name. If fp has no `name' attribute, `' is - used. - - """ - if filename is None: - try: - filename = fp.name - except AttributeError: - filename = '' - self._read(fp, filename) - - def get(self, section, option): - opt = self.optionxform(option) - if section not in self._sections: - if section != DEFAULTSECT: - raise NoSectionError(section) - if opt in self._defaults: - return self._defaults[opt] - else: - raise NoOptionError(option, section) - elif opt in self._sections[section]: - return self._sections[section][opt] - elif opt in self._defaults: - return self._defaults[opt] - else: - raise NoOptionError(option, section) - - def items(self, section): - try: - d2 = self._sections[section] - except KeyError: - if section != DEFAULTSECT: - raise NoSectionError(section) - d2 = {} - d = self._defaults.copy() - d.update(d2) - if "__name__" in d: - del d["__name__"] - return d.items() - - def _get(self, section, conv, option): - return conv(self.get(section, option)) - - def getint(self, section, option): - return self._get(section, int, option) - - def getfloat(self, section, option): - return self._get(section, float, option) - - _boolean_states = {'1': True, 'yes': True, 'true': True, 'on': True, - '0': False, 'no': False, 'false': False, 'off': False} - - def getboolean(self, section, option): - v = self.get(section, option) - if v.lower() not in self._boolean_states: - raise ValueError, 'Not a boolean: %s' % v - return self._boolean_states[v.lower()] - - def optionxform(self, optionstr): - return optionstr.lower() - - def has_option(self, section, option): - """Check for the existence of a given option in a given section.""" - if not section or section == DEFAULTSECT: - option = self.optionxform(option) - return option in self._defaults - elif section not in self._sections: - return False - else: - option = self.optionxform(option) - return (option in self._sections[section] - or option in self._defaults) - - def set(self, section, option, value): - """Set an option.""" - if not section or section == DEFAULTSECT: - sectdict = self._defaults - else: - try: - sectdict = self._sections[section] - except KeyError: - raise NoSectionError(section) - sectdict[self.optionxform(option)] = value - - def write(self, fp): - """Write an .ini-format representation of the configuration state.""" - if self._defaults: - fp.write("[%s]\n" % DEFAULTSECT) - for (key, value) in self._defaults.items(): - fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) - fp.write("\n") - for section in self._sections: - fp.write("[%s]\n" % section) - for (key, value) in self._sections[section].items(): - if key != "__name__": - fp.write("%s = %s\n" % - (key, str(value).replace('\n', '\n\t'))) - fp.write("\n") - - def remove_option(self, section, option): - """Remove an option.""" - if not section or section == DEFAULTSECT: - sectdict = self._defaults - else: - try: - sectdict = self._sections[section] - except KeyError: - raise NoSectionError(section) - option = self.optionxform(option) - existed = option in sectdict - if existed: - del sectdict[option] - return existed - - def remove_section(self, section): - """Remove a file section.""" - existed = section in self._sections - if existed: - del self._sections[section] - return existed - - # - # Regular expressions for parsing section headers and options. - # - SECTCRE = re.compile( - r'\[' # [ - r'(?P
    [^]]+)' # very permissive! - r'\]' # ] - ) - OPTCRE = re.compile( - r'(?P
    [^]]+)' # very permissive! - r'\]' # ] - ) - OPTCRE = re.compile( - r'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 diff --git a/Scripts/ServerPython/python/system/atexit.py b/Scripts/ServerPython/python/system/atexit.py deleted file mode 100644 index 372876f2..00000000 --- a/Scripts/ServerPython/python/system/atexit.py +++ /dev/null @@ -1,50 +0,0 @@ -""" -atexit.py - allow programmer to define multiple exit functions to be executed -upon normal program termination. - -One public function, register, is defined. -""" - -__all__ = ["register"] - -_exithandlers = [] -def _run_exitfuncs(): - """run any registered exit functions - - _exithandlers is traversed in reverse order so functions are executed - last in, first out. - """ - - while _exithandlers: - func, targs, kargs = _exithandlers.pop() - apply(func, targs, kargs) - -def register(func, *targs, **kargs): - """register a function to be executed upon normal program termination - - func - function to be called at exit - targs - optional arguments to pass to func - kargs - optional keyword arguments to pass to func - """ - _exithandlers.append((func, targs, kargs)) - -import sys -if hasattr(sys, "exitfunc"): - # Assume it's another registered exit function - append it to our list - register(sys.exitfunc) -sys.exitfunc = _run_exitfuncs - -del sys - -if __name__ == "__main__": - def x1(): - print "running x1" - def x2(n): - print "running x2(%s)" % `n` - def x3(n, kwd=None): - print "running x3(%s, kwd=%s)" % (`n`, `kwd`) - - register(x1) - register(x2, 12) - register(x3, 5, "bar") - register(x3, "no kwd args") diff --git a/Scripts/ServerPython/python/system/bdb.py b/Scripts/ServerPython/python/system/bdb.py deleted file mode 100644 index f4f83836..00000000 --- a/Scripts/ServerPython/python/system/bdb.py +++ /dev/null @@ -1,563 +0,0 @@ -"""Debugger basics""" - -import sys -import os -import types - -__all__ = ["BdbQuit","Bdb","Breakpoint"] - -BdbQuit = 'bdb.BdbQuit' # Exception to give up completely - - -class Bdb: - - """Generic Python debugger base class. - - This class takes care of details of the trace facility; - a derived class should implement user interaction. - The standard debugger class (pdb.Pdb) is an example. - """ - - def __init__(self): - self.breaks = {} - self.fncache = {} - - def canonic(self, filename): - if filename == "<" + filename[1:-1] + ">": - return filename - canonic = self.fncache.get(filename) - if not canonic: - canonic = os.path.abspath(filename) - canonic = os.path.normcase(canonic) - self.fncache[filename] = canonic - return canonic - - def reset(self): - import linecache - linecache.checkcache() - self.botframe = None - self.stopframe = None - self.returnframe = None - self.quitting = 0 - - def trace_dispatch(self, frame, event, arg): - if self.quitting: - return # None - if event == 'line': - return self.dispatch_line(frame) - if event == 'call': - return self.dispatch_call(frame, arg) - if event == 'return': - return self.dispatch_return(frame, arg) - if event == 'exception': - return self.dispatch_exception(frame, arg) - print 'bdb.Bdb.dispatch: unknown debugging event:', `event` - return self.trace_dispatch - - def dispatch_line(self, frame): - if self.stop_here(frame) or self.break_here(frame): - self.user_line(frame) - if self.quitting: raise BdbQuit - return self.trace_dispatch - - def dispatch_call(self, frame, arg): - # XXX 'arg' is no longer used - if self.botframe is None: - # First call of dispatch since reset() - self.botframe = frame.f_back # (CT) Note that this may also be None! - return self.trace_dispatch - if not (self.stop_here(frame) or self.break_anywhere(frame)): - # No need to trace this function - return # None - self.user_call(frame, arg) - if self.quitting: raise BdbQuit - return self.trace_dispatch - - def dispatch_return(self, frame, arg): - if self.stop_here(frame) or frame == self.returnframe: - self.user_return(frame, arg) - if self.quitting: raise BdbQuit - return self.trace_dispatch - - def dispatch_exception(self, frame, arg): - if self.stop_here(frame): - self.user_exception(frame, arg) - if self.quitting: raise BdbQuit - return self.trace_dispatch - - # Normally derived classes don't override the following - # methods, but they may if they want to redefine the - # definition of stopping and breakpoints. - - def stop_here(self, frame): - # (CT) stopframe may now also be None, see dispatch_call. - # (CT) the former test for None is therefore removed from here. - if frame is self.stopframe: - return 1 - while frame is not None and frame is not self.stopframe: - if frame is self.botframe: - return 1 - frame = frame.f_back - return 0 - - def break_here(self, frame): - filename = self.canonic(frame.f_code.co_filename) - if not self.breaks.has_key(filename): - return 0 - lineno = frame.f_lineno - if not lineno in self.breaks[filename]: - return 0 - # flag says ok to delete temp. bp - (bp, flag) = effective(filename, lineno, frame) - if bp: - self.currentbp = bp.number - if (flag and bp.temporary): - self.do_clear(str(bp.number)) - return 1 - else: - return 0 - - def do_clear(self, arg): - raise NotImplementedError, "subclass of bdb must implement do_clear()" - - def break_anywhere(self, frame): - return self.breaks.has_key( - self.canonic(frame.f_code.co_filename)) - - # Derived classes should override the user_* methods - # to gain control. - - def user_call(self, frame, argument_list): - """This method is called when there is the remote possibility - that we ever need to stop in this function.""" - pass - - def user_line(self, frame): - """This method is called when we stop or break at this line.""" - pass - - def user_return(self, frame, return_value): - """This method is called when a return trap is set here.""" - pass - - def user_exception(self, frame, (exc_type, exc_value, exc_traceback)): - """This method is called if an exception occurs, - but only if we are to stop at or just below this level.""" - pass - - # Derived classes and clients can call the following methods - # to affect the stepping state. - - def set_step(self): - """Stop after one line of code.""" - self.stopframe = None - self.returnframe = None - self.quitting = 0 - - def set_next(self, frame): - """Stop on the next line in or below the given frame.""" - self.stopframe = frame - self.returnframe = None - self.quitting = 0 - - def set_return(self, frame): - """Stop when returning from the given frame.""" - self.stopframe = frame.f_back - self.returnframe = frame - self.quitting = 0 - - def set_trace(self): - """Start debugging from here.""" - frame = sys._getframe().f_back - self.reset() - while frame: - frame.f_trace = self.trace_dispatch - self.botframe = frame - frame = frame.f_back - self.set_step() - sys.settrace(self.trace_dispatch) - - def set_continue(self): - # Don't stop except at breakpoints or when finished - self.stopframe = self.botframe - self.returnframe = None - self.quitting = 0 - if not self.breaks: - # no breakpoints; run without debugger overhead - sys.settrace(None) - frame = sys._getframe().f_back - while frame and frame is not self.botframe: - del frame.f_trace - frame = frame.f_back - - def set_quit(self): - self.stopframe = self.botframe - self.returnframe = None - self.quitting = 1 - sys.settrace(None) - - # Derived classes and clients can call the following methods - # to manipulate breakpoints. These methods return an - # error message is something went wrong, None if all is well. - # Set_break prints out the breakpoint line and file:lineno. - # Call self.get_*break*() to see the breakpoints or better - # for bp in Breakpoint.bpbynumber: if bp: bp.bpprint(). - - def set_break(self, filename, lineno, temporary=0, cond = None): - filename = self.canonic(filename) - import linecache # Import as late as possible - line = linecache.getline(filename, lineno) - if not line: - return 'Line %s:%d does not exist' % (filename, - lineno) - if not self.breaks.has_key(filename): - self.breaks[filename] = [] - list = self.breaks[filename] - if not lineno in list: - list.append(lineno) - bp = Breakpoint(filename, lineno, temporary, cond) - - def clear_break(self, filename, lineno): - filename = self.canonic(filename) - if not self.breaks.has_key(filename): - return 'There are no breakpoints in %s' % filename - if lineno not in self.breaks[filename]: - return 'There is no breakpoint at %s:%d' % (filename, - lineno) - # If there's only one bp in the list for that file,line - # pair, then remove the breaks entry - for bp in Breakpoint.bplist[filename, lineno][:]: - bp.deleteMe() - if not Breakpoint.bplist.has_key((filename, lineno)): - self.breaks[filename].remove(lineno) - if not self.breaks[filename]: - del self.breaks[filename] - - def clear_bpbynumber(self, arg): - try: - number = int(arg) - except: - return 'Non-numeric breakpoint number (%s)' % arg - try: - bp = Breakpoint.bpbynumber[number] - except IndexError: - return 'Breakpoint number (%d) out of range' % number - if not bp: - return 'Breakpoint (%d) already deleted' % number - self.clear_break(bp.file, bp.line) - - def clear_all_file_breaks(self, filename): - filename = self.canonic(filename) - if not self.breaks.has_key(filename): - return 'There are no breakpoints in %s' % filename - for line in self.breaks[filename]: - blist = Breakpoint.bplist[filename, line] - for bp in blist: - bp.deleteMe() - del self.breaks[filename] - - def clear_all_breaks(self): - if not self.breaks: - return 'There are no breakpoints' - for bp in Breakpoint.bpbynumber: - if bp: - bp.deleteMe() - self.breaks = {} - - def get_break(self, filename, lineno): - filename = self.canonic(filename) - return self.breaks.has_key(filename) and \ - lineno in self.breaks[filename] - - def get_breaks(self, filename, lineno): - filename = self.canonic(filename) - return self.breaks.has_key(filename) and \ - lineno in self.breaks[filename] and \ - Breakpoint.bplist[filename, lineno] or [] - - def get_file_breaks(self, filename): - filename = self.canonic(filename) - if self.breaks.has_key(filename): - return self.breaks[filename] - else: - return [] - - def get_all_breaks(self): - return self.breaks - - # Derived classes and clients can call the following method - # to get a data structure representing a stack trace. - - def get_stack(self, f, t): - stack = [] - if t and t.tb_frame is f: - t = t.tb_next - while f is not None: - stack.append((f, f.f_lineno)) - if f is self.botframe: - break - f = f.f_back - stack.reverse() - i = max(0, len(stack) - 1) - while t is not None: - stack.append((t.tb_frame, t.tb_lineno)) - t = t.tb_next - return stack, i - - # - - def format_stack_entry(self, frame_lineno, lprefix=': '): - import linecache, repr - frame, lineno = frame_lineno - filename = self.canonic(frame.f_code.co_filename) - s = filename + '(' + `lineno` + ')' - if frame.f_code.co_name: - s = s + frame.f_code.co_name - else: - s = s + "" - if frame.f_locals.has_key('__args__'): - args = frame.f_locals['__args__'] - else: - args = None - if args: - s = s + repr.repr(args) - else: - s = s + '()' - if frame.f_locals.has_key('__return__'): - rv = frame.f_locals['__return__'] - s = s + '->' - s = s + repr.repr(rv) - line = linecache.getline(filename, lineno) - if line: s = s + lprefix + line.strip() - return s - - # The following two methods can be called by clients to use - # a debugger to debug a statement, given as a string. - - def run(self, cmd, globals=None, locals=None): - if globals is None: - import __main__ - globals = __main__.__dict__ - if locals is None: - locals = globals - self.reset() - sys.settrace(self.trace_dispatch) - if not isinstance(cmd, types.CodeType): - cmd = cmd+'\n' - try: - try: - exec cmd in globals, locals - except BdbQuit: - pass - finally: - self.quitting = 1 - sys.settrace(None) - - def runeval(self, expr, globals=None, locals=None): - if globals is None: - import __main__ - globals = __main__.__dict__ - if locals is None: - locals = globals - self.reset() - sys.settrace(self.trace_dispatch) - if not isinstance(expr, types.CodeType): - expr = expr+'\n' - try: - try: - return eval(expr, globals, locals) - except BdbQuit: - pass - finally: - self.quitting = 1 - sys.settrace(None) - - def runctx(self, cmd, globals, locals): - # B/W compatibility - self.run(cmd, globals, locals) - - # This method is more useful to debug a single function call. - - def runcall(self, func, *args): - self.reset() - sys.settrace(self.trace_dispatch) - res = None - try: - try: - res = apply(func, args) - except BdbQuit: - pass - finally: - self.quitting = 1 - sys.settrace(None) - return res - - -def set_trace(): - Bdb().set_trace() - - -class Breakpoint: - - """Breakpoint class - - Implements temporary breakpoints, ignore counts, disabling and - (re)-enabling, and conditionals. - - Breakpoints are indexed by number through bpbynumber and by - the file,line tuple using bplist. The former points to a - single instance of class Breakpoint. The latter points to a - list of such instances since there may be more than one - breakpoint per line. - - """ - - # XXX Keeping state in the class is a mistake -- this means - # you cannot have more than one active Bdb instance. - - next = 1 # Next bp to be assigned - bplist = {} # indexed by (file, lineno) tuple - bpbynumber = [None] # Each entry is None or an instance of Bpt - # index 0 is unused, except for marking an - # effective break .... see effective() - - def __init__(self, file, line, temporary=0, cond = None): - self.file = file # This better be in canonical form! - self.line = line - self.temporary = temporary - self.cond = cond - self.enabled = 1 - self.ignore = 0 - self.hits = 0 - self.number = Breakpoint.next - Breakpoint.next = Breakpoint.next + 1 - # Build the two lists - self.bpbynumber.append(self) - if self.bplist.has_key((file, line)): - self.bplist[file, line].append(self) - else: - self.bplist[file, line] = [self] - - - def deleteMe(self): - index = (self.file, self.line) - self.bpbynumber[self.number] = None # No longer in list - self.bplist[index].remove(self) - if not self.bplist[index]: - # No more bp for this f:l combo - del self.bplist[index] - - def enable(self): - self.enabled = 1 - - def disable(self): - self.enabled = 0 - - def bpprint(self): - if self.temporary: - disp = 'del ' - else: - disp = 'keep ' - if self.enabled: - disp = disp + 'yes' - else: - disp = disp + 'no ' - print '%-4dbreakpoint %s at %s:%d' % (self.number, disp, - self.file, self.line) - if self.cond: - print '\tstop only if %s' % (self.cond,) - if self.ignore: - print '\tignore next %d hits' % (self.ignore) - if (self.hits): - if (self.hits > 1): ss = 's' - else: ss = '' - print ('\tbreakpoint already hit %d time%s' % - (self.hits, ss)) - -# -----------end of Breakpoint class---------- - -# Determines if there is an effective (active) breakpoint at this -# line of code. Returns breakpoint number or 0 if none -def effective(file, line, frame): - """Determine which breakpoint for this file:line is to be acted upon. - - Called only if we know there is a bpt at this - location. Returns breakpoint that was triggered and a flag - that indicates if it is ok to delete a temporary bp. - - """ - possibles = Breakpoint.bplist[file,line] - for i in range(0, len(possibles)): - b = possibles[i] - if b.enabled == 0: - continue - # Count every hit when bp is enabled - b.hits = b.hits + 1 - if not b.cond: - # If unconditional, and ignoring, - # go on to next, else break - if b.ignore > 0: - b.ignore = b.ignore -1 - continue - else: - # breakpoint and marker that's ok - # to delete if temporary - return (b,1) - else: - # Conditional bp. - # Ignore count applies only to those bpt hits where the - # condition evaluates to true. - try: - val = eval(b.cond, frame.f_globals, - frame.f_locals) - if val: - if b.ignore > 0: - b.ignore = b.ignore -1 - # continue - else: - return (b,1) - # else: - # continue - except: - # if eval fails, most conservative - # thing is to stop on breakpoint - # regardless of ignore count. - # Don't delete temporary, - # as another hint to user. - return (b,0) - return (None, None) - -# -------------------- testing -------------------- - -class Tdb(Bdb): - def user_call(self, frame, args): - name = frame.f_code.co_name - if not name: name = '???' - print '+++ call', name, args - def user_line(self, frame): - import linecache - name = frame.f_code.co_name - if not name: name = '???' - fn = self.canonic(frame.f_code.co_filename) - line = linecache.getline(fn, frame.f_lineno) - print '+++', fn, frame.f_lineno, name, ':', line.strip() - def user_return(self, frame, retval): - print '+++ return', retval - def user_exception(self, frame, exc_stuff): - print '+++ exception', exc_stuff - self.set_continue() - -def foo(n): - print 'foo(', n, ')' - x = bar(n*10) - print 'bar returned', x - -def bar(a): - print 'bar(', a, ')' - return a/2 - -def test(): - t = Tdb() - t.run('import bdb; bdb.foo(10)') - -# end diff --git a/Scripts/ServerPython/python/system/bisect.py b/Scripts/ServerPython/python/system/bisect.py deleted file mode 100644 index 5c1661ae..00000000 --- a/Scripts/ServerPython/python/system/bisect.py +++ /dev/null @@ -1,78 +0,0 @@ -"""Bisection algorithms.""" - -def insort_right(a, x, lo=0, hi=None): - """Insert item x in list a, and keep it sorted assuming a is sorted. - - If x is already in a, insert it to the right of the rightmost x. - - Optional args lo (default 0) and hi (default len(a)) bound the - slice of a to be searched. - """ - - if hi is None: - hi = len(a) - while lo < hi: - mid = (lo+hi)//2 - if x < a[mid]: hi = mid - else: lo = mid+1 - a.insert(lo, x) - -insort = insort_right # backward compatibility - -def bisect_right(a, x, lo=0, hi=None): - """Return the index where to insert item x in list a, assuming a is sorted. - - The return value i is such that all e in a[:i] have e <= x, and all e in - a[i:] have e > x. So if x already appears in the list, i points just - beyond the rightmost x already there. - - Optional args lo (default 0) and hi (default len(a)) bound the - slice of a to be searched. - """ - - if hi is None: - hi = len(a) - while lo < hi: - mid = (lo+hi)//2 - if x < a[mid]: hi = mid - else: lo = mid+1 - return lo - -bisect = bisect_right # backward compatibility - -def insort_left(a, x, lo=0, hi=None): - """Insert item x in list a, and keep it sorted assuming a is sorted. - - If x is already in a, insert it to the left of the leftmost x. - - Optional args lo (default 0) and hi (default len(a)) bound the - slice of a to be searched. - """ - - if hi is None: - hi = len(a) - while lo < hi: - mid = (lo+hi)//2 - if a[mid] < x: lo = mid+1 - else: hi = mid - a.insert(lo, x) - - -def bisect_left(a, x, lo=0, hi=None): - """Return the index where to insert item x in list a, assuming a is sorted. - - The return value i is such that all e in a[:i] have e < x, and all e in - a[i:] have e >= x. So if x already appears in the list, i points just - before the leftmost x already there. - - Optional args lo (default 0) and hi (default len(a)) bound the - slice of a to be searched. - """ - - if hi is None: - hi = len(a) - while lo < hi: - mid = (lo+hi)//2 - if a[mid] < x: lo = mid+1 - else: hi = mid - return lo diff --git a/Scripts/ServerPython/python/system/calendar.py b/Scripts/ServerPython/python/system/calendar.py deleted file mode 100644 index 83e6274b..00000000 --- a/Scripts/ServerPython/python/system/calendar.py +++ /dev/null @@ -1,246 +0,0 @@ -"""Calendar printing functions - -Note when comparing these calendars to the ones printed by cal(1): By -default, these calendars have Monday as the first day of the week, and -Sunday as the last (the European convention). Use setfirstweekday() to -set the first day of the week (0=Monday, 6=Sunday).""" - -# Revision 2: uses functions from built-in time module - -# Import functions and variables from time module -from time import localtime, mktime, strftime -from types import SliceType - -__all__ = ["error","setfirstweekday","firstweekday","isleap", - "leapdays","weekday","monthrange","monthcalendar", - "prmonth","month","prcal","calendar","timegm", - "month_name", "month_abbr", "day_name", "day_abbr"] - -# Exception raised for bad input (with string parameter for details) -error = ValueError - -# Constants for months referenced later -January = 1 -February = 2 - -# Number of days per month (except for February in leap years) -mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] - -# This module used to have hard-coded lists of day and month names, as -# English strings. The classes following emulate a read-only version of -# that, but supply localized names. Note that the values are computed -# fresh on each call, in case the user changes locale between calls. - -class _indexer: - def __getitem__(self, i): - if isinstance(i, SliceType): - return self.data[i.start : i.stop] - else: - # May raise an appropriate exception. - return self.data[i] - -class _localized_month(_indexer): - def __init__(self, format): - self.format = format - - def __getitem__(self, i): - self.data = [strftime(self.format, (2001, j, 1, 12, 0, 0, 1, 1, 0)) - for j in range(1, 13)] - self.data.insert(0, "") - return _indexer.__getitem__(self, i) - - def __len__(self): - return 13 - -class _localized_day(_indexer): - def __init__(self, format): - self.format = format - - def __getitem__(self, i): - # January 1, 2001, was a Monday. - self.data = [strftime(self.format, (2001, 1, j+1, 12, 0, 0, j, j+1, 0)) - for j in range(7)] - return _indexer.__getitem__(self, i) - - def __len__(self_): - return 7 - -# Full and abbreviated names of weekdays -day_name = _localized_day('%A') -day_abbr = _localized_day('%a') - -# Full and abbreviated names of months (1-based arrays!!!) -month_name = _localized_month('%B') -month_abbr = _localized_month('%b') - -# Constants for weekdays -(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY) = range(7) - -_firstweekday = 0 # 0 = Monday, 6 = Sunday - -def firstweekday(): - return _firstweekday - -def setfirstweekday(weekday): - """Set weekday (Monday=0, Sunday=6) to start each week.""" - global _firstweekday - if not MONDAY <= weekday <= SUNDAY: - raise ValueError, \ - 'bad weekday number; must be 0 (Monday) to 6 (Sunday)' - _firstweekday = weekday - -def isleap(year): - """Return 1 for leap years, 0 for non-leap years.""" - return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) - -def leapdays(y1, y2): - """Return number of leap years in range [y1, y2). - Assume y1 <= y2.""" - y1 -= 1 - y2 -= 1 - return (y2/4 - y1/4) - (y2/100 - y1/100) + (y2/400 - y1/400) - -def weekday(year, month, day): - """Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12), - day (1-31).""" - secs = mktime((year, month, day, 0, 0, 0, 0, 0, 0)) - tuple = localtime(secs) - return tuple[6] - -def monthrange(year, month): - """Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for - year, month.""" - if not 1 <= month <= 12: - raise ValueError, 'bad month number' - day1 = weekday(year, month, 1) - ndays = mdays[month] + (month == February and isleap(year)) - return day1, ndays - -def monthcalendar(year, month): - """Return a matrix representing a month's calendar. - Each row represents a week; days outside this month are zero.""" - day1, ndays = monthrange(year, month) - rows = [] - r7 = range(7) - day = (_firstweekday - day1 + 6) % 7 - 5 # for leading 0's in first week - while day <= ndays: - row = [0, 0, 0, 0, 0, 0, 0] - for i in r7: - if 1 <= day <= ndays: row[i] = day - day = day + 1 - rows.append(row) - return rows - -def _center(str, width): - """Center a string in a field.""" - n = width - len(str) - if n <= 0: - return str - return ' '*((n+1)/2) + str + ' '*((n)/2) - -def prweek(theweek, width): - """Print a single week (no newline).""" - print week(theweek, width), - -def week(theweek, width): - """Returns a single week in a string (no newline).""" - days = [] - for day in theweek: - if day == 0: - s = '' - else: - s = '%2i' % day # right-align single-digit days - days.append(_center(s, width)) - return ' '.join(days) - -def weekheader(width): - """Return a header for a week.""" - if width >= 9: - names = day_name - else: - names = day_abbr - days = [] - for i in range(_firstweekday, _firstweekday + 7): - days.append(_center(names[i%7][:width], width)) - return ' '.join(days) - -def prmonth(theyear, themonth, w=0, l=0): - """Print a month's calendar.""" - print month(theyear, themonth, w, l), - -def month(theyear, themonth, w=0, l=0): - """Return a month's calendar string (multi-line).""" - w = max(2, w) - l = max(1, l) - s = (_center(month_name[themonth] + ' ' + `theyear`, - 7 * (w + 1) - 1).rstrip() + - '\n' * l + weekheader(w).rstrip() + '\n' * l) - for aweek in monthcalendar(theyear, themonth): - s = s + week(aweek, w).rstrip() + '\n' * l - return s[:-l] + '\n' - -# Spacing of month columns for 3-column year calendar -_colwidth = 7*3 - 1 # Amount printed by prweek() -_spacing = 6 # Number of spaces between columns - -def format3c(a, b, c, colwidth=_colwidth, spacing=_spacing): - """Prints 3-column formatting for year calendars""" - print format3cstring(a, b, c, colwidth, spacing) - -def format3cstring(a, b, c, colwidth=_colwidth, spacing=_spacing): - """Returns a string formatted from 3 strings, centered within 3 columns.""" - return (_center(a, colwidth) + ' ' * spacing + _center(b, colwidth) + - ' ' * spacing + _center(c, colwidth)) - -def prcal(year, w=0, l=0, c=_spacing): - """Print a year's calendar.""" - print calendar(year, w, l, c), - -def calendar(year, w=0, l=0, c=_spacing): - """Returns a year's calendar as a multi-line string.""" - w = max(2, w) - l = max(1, l) - c = max(2, c) - colwidth = (w + 1) * 7 - 1 - s = _center(`year`, colwidth * 3 + c * 2).rstrip() + '\n' * l - header = weekheader(w) - header = format3cstring(header, header, header, colwidth, c).rstrip() - for q in range(January, January+12, 3): - s = (s + '\n' * l + - format3cstring(month_name[q], month_name[q+1], month_name[q+2], - colwidth, c).rstrip() + - '\n' * l + header + '\n' * l) - data = [] - height = 0 - for amonth in range(q, q + 3): - cal = monthcalendar(year, amonth) - if len(cal) > height: - height = len(cal) - data.append(cal) - for i in range(height): - weeks = [] - for cal in data: - if i >= len(cal): - weeks.append('') - else: - weeks.append(week(cal[i], w)) - s = s + format3cstring(weeks[0], weeks[1], weeks[2], - colwidth, c).rstrip() + '\n' * l - return s[:-l] + '\n' - -EPOCH = 1970 -def timegm(tuple): - """Unrelated but handy function to calculate Unix timestamp from GMT.""" - year, month, day, hour, minute, second = tuple[:6] - assert year >= EPOCH - assert 1 <= month <= 12 - days = 365*(year-EPOCH) + leapdays(EPOCH, year) - for i in range(1, month): - days = days + mdays[i] - if month > 2 and isleap(year): - days = days + 1 - days = days + day - 1 - hours = days*24 + hour - minutes = hours*60 + minute - seconds = minutes*60 + second - return seconds diff --git a/Scripts/ServerPython/python/system/cmd.py b/Scripts/ServerPython/python/system/cmd.py deleted file mode 100644 index 1fb752d4..00000000 --- a/Scripts/ServerPython/python/system/cmd.py +++ /dev/null @@ -1,330 +0,0 @@ -"""A generic class to build line-oriented command interpreters. - -Interpreters constructed with this class obey the following conventions: - -1. End of file on input is processed as the command 'EOF'. -2. A command is parsed out of each line by collecting the prefix composed - of characters in the identchars member. -3. A command `foo' is dispatched to a method 'do_foo()'; the do_ method - is passed a single argument consisting of the remainder of the line. -4. Typing an empty line repeats the last command. (Actually, it calls the - method `emptyline', which may be overridden in a subclass.) -5. There is a predefined `help' method. Given an argument `topic', it - calls the command `help_topic'. With no arguments, it lists all topics - with defined help_ functions, broken into up to three topics; documented - commands, miscellaneous help topics, and undocumented commands. -6. The command '?' is a synonym for `help'. The command '!' is a synonym - for `shell', if a do_shell method exists. -7. If completion is enabled, completing commands will be done automatically, - and completing of commands args is done by calling complete_foo() with - arguments text, line, begidx, endidx. text is string we are matching - against, all returned matches must begin with it. line is the current - input line (lstripped), begidx and endidx are the beginning and end - indexes of the text being matched, which could be used to provide - different completion depending upon which position the argument is in. - -The `default' method may be overridden to intercept commands for which there -is no do_ method. - -The `completedefault' method may be overridden to intercept completions for -commands that have no complete_ method. - -The data member `self.ruler' sets the character used to draw separator lines -in the help messages. If empty, no ruler line is drawn. It defaults to "=". - -If the value of `self.intro' is nonempty when the cmdloop method is called, -it is printed out on interpreter startup. This value may be overridden -via an optional argument to the cmdloop() method. - -The data members `self.doc_header', `self.misc_header', and -`self.undoc_header' set the headers used for the help function's -listings of documented functions, miscellaneous topics, and undocumented -functions respectively. - -These interpreters use raw_input; thus, if the readline module is loaded, -they automatically support Emacs-like command history and editing features. -""" - -import string, sys - -__all__ = ["Cmd"] - -PROMPT = '(Cmd) ' -IDENTCHARS = string.ascii_letters + string.digits + '_' - -class Cmd: - """A simple framework for writing line-oriented command interpreters. - - These are often useful for test harnesses, administrative tools, and - prototypes that will later be wrapped in a more sophisticated interface. - - A Cmd instance or subclass instance is a line-oriented interpreter - framework. There is no good reason to instantiate Cmd itself; rather, - it's useful as a superclass of an interpreter class you define yourself - in order to inherit Cmd's methods and encapsulate action methods. - - """ - prompt = PROMPT - identchars = IDENTCHARS - ruler = '=' - lastcmd = '' - cmdqueue = [] - intro = None - doc_leader = "" - doc_header = "Documented commands (type help ):" - misc_header = "Miscellaneous help topics:" - undoc_header = "Undocumented commands:" - nohelp = "*** No help on %s" - use_rawinput = 1 - - def __init__(self, completekey='tab'): - """Instantiate a line-oriented interpreter framework. - - The optional argument is the readline name of a completion key; - it defaults to the Tab key. If completekey is not None and the - readline module is available, command completion is done - automatically. - - """ - if completekey: - try: - import readline - readline.set_completer(self.complete) - readline.parse_and_bind(completekey+": complete") - except ImportError: - pass - - def cmdloop(self, intro=None): - """Repeatedly issue a prompt, accept input, parse an initial prefix - off the received input, and dispatch to action methods, passing them - the remainder of the line as argument. - - """ - - self.preloop() - if intro is not None: - self.intro = intro - if self.intro: - print self.intro - stop = None - while not stop: - if self.cmdqueue: - line = self.cmdqueue[0] - del self.cmdqueue[0] - else: - if self.use_rawinput: - try: - line = raw_input(self.prompt) - except EOFError: - line = 'EOF' - else: - sys.stdout.write(self.prompt) - sys.stdout.flush() - line = sys.stdin.readline() - if not len(line): - line = 'EOF' - else: - line = line[:-1] # chop \n - line = self.precmd(line) - stop = self.onecmd(line) - stop = self.postcmd(stop, line) - self.postloop() - - def precmd(self, line): - """Hook method executed just before the command line is - interpreted, but after the input prompt is generated and issued. - - """ - return line - - def postcmd(self, stop, line): - """Hook method executed just after a command dispatch is finished.""" - return stop - - def preloop(self): - """Hook method executed once when the cmdloop() method is called.""" - pass - - def postloop(self): - """Hook method executed once when the cmdloop() method is about to - return. - - """ - pass - - def parseline(self, line): - line = line.strip() - if not line: - return None, None, line - elif line[0] == '?': - line = 'help ' + line[1:] - elif line[0] == '!': - if hasattr(self, 'do_shell'): - line = 'shell ' + line[1:] - else: - return None, None, line - i, n = 0, len(line) - while i < n and line[i] in self.identchars: i = i+1 - cmd, arg = line[:i], line[i:].strip() - return cmd, arg, line - - def onecmd(self, line): - """Interpret the argument as though it had been typed in response - to the prompt. - - This may be overridden, but should not normally need to be; - see the precmd() and postcmd() methods for useful execution hooks. - The return value is a flag indicating whether interpretation of - commands by the interpreter should stop. - - """ - cmd, arg, line = self.parseline(line) - if not line: - return self.emptyline() - if cmd is None: - return self.default(line) - self.lastcmd = line - if cmd == '': - return self.default(line) - else: - try: - func = getattr(self, 'do_' + cmd) - except AttributeError: - return self.default(line) - return func(arg) - - def emptyline(self): - """Called when an empty line is entered in response to the prompt. - - If this method is not overridden, it repeats the last nonempty - command entered. - - """ - if self.lastcmd: - return self.onecmd(self.lastcmd) - - def default(self, line): - """Called on an input line when the command prefix is not recognized. - - If this method is not overridden, it prints an error message and - returns. - - """ - print '*** Unknown syntax:', line - - def completedefault(self, *ignored): - """Method called to complete an input line when no command-specific - complete_*() method is available. - - By default, it returns an empty list. - - """ - return [] - - def completenames(self, text, *ignored): - dotext = 'do_'+text - return [a[3:] for a in self.get_names() if a.startswith(dotext)] - - def complete(self, text, state): - """Return the next possible completion for 'text'. - - If a command has not been entered, then complete against command list. - Otherwise try to call complete_ to get list of completions. - """ - if state == 0: - import readline - origline = readline.get_line_buffer() - line = origline.lstrip() - stripped = len(origline) - len(line) - begidx = readline.get_begidx() - stripped - endidx = readline.get_endidx() - stripped - if begidx>0: - cmd, args, foo = self.parseline(line) - if cmd == '': - compfunc = self.completedefault - else: - try: - compfunc = getattr(self, 'complete_' + cmd) - except AttributeError: - compfunc = self.completedefault - else: - compfunc = self.completenames - self.completion_matches = compfunc(text, line, begidx, endidx) - try: - return self.completion_matches[state] - except IndexError: - return None - - def get_names(self): - # Inheritance says we have to look in class and - # base classes; order is not important. - names = [] - classes = [self.__class__] - while classes: - aclass = classes[0] - if aclass.__bases__: - classes = classes + list(aclass.__bases__) - names = names + dir(aclass) - del classes[0] - return names - - def complete_help(self, *args): - return self.completenames(*args) - - def do_help(self, arg): - if arg: - # XXX check arg syntax - try: - func = getattr(self, 'help_' + arg) - except: - try: - doc=getattr(self, 'do_' + arg).__doc__ - if doc: - print doc - return - except: - pass - print self.nohelp % (arg,) - return - func() - else: - names = self.get_names() - cmds_doc = [] - cmds_undoc = [] - help = {} - for name in names: - if name[:5] == 'help_': - help[name[5:]]=1 - names.sort() - # There can be duplicates if routines overridden - prevname = '' - for name in names: - if name[:3] == 'do_': - if name == prevname: - continue - prevname = name - cmd=name[3:] - if help.has_key(cmd): - cmds_doc.append(cmd) - del help[cmd] - elif getattr(self, name).__doc__: - cmds_doc.append(cmd) - else: - cmds_undoc.append(cmd) - print self.doc_leader - self.print_topics(self.doc_header, cmds_doc, 15,80) - self.print_topics(self.misc_header, help.keys(),15,80) - self.print_topics(self.undoc_header, cmds_undoc, 15,80) - - def print_topics(self, header, cmds, cmdlen, maxcol): - if cmds: - print header - if self.ruler: - print self.ruler * len(header) - (cmds_per_line,junk)=divmod(maxcol,cmdlen) - col=cmds_per_line - for cmd in cmds: - if col==0: print - print (("%-"+`cmdlen`+"s") % cmd), - col = (col+1) % cmds_per_line - print "\n" diff --git a/Scripts/ServerPython/python/system/codecs.py b/Scripts/ServerPython/python/system/codecs.py deleted file mode 100644 index c81cfff9..00000000 --- a/Scripts/ServerPython/python/system/codecs.py +++ /dev/null @@ -1,636 +0,0 @@ -""" codecs -- Python Codec Registry, API and helpers. - - -Written by Marc-Andre Lemburg (mal@lemburg.com). - -(c) Copyright CNRI, All Rights Reserved. NO WARRANTY. - -"""#" - -import struct, __builtin__ - -### Registry and builtin stateless codec functions - -try: - from _codecs import * -except ImportError, why: - raise SystemError,\ - 'Failed to load the builtin codecs: %s' % why - -__all__ = ["register", "lookup", "open", "EncodedFile", "BOM", "BOM_BE", - "BOM_LE", "BOM32_BE", "BOM32_LE", "BOM64_BE", "BOM64_LE"] - -### Constants - -# -# Byte Order Mark (BOM) and its possible values (BOM_BE, BOM_LE) -# -BOM = struct.pack('=H', 0xFEFF) -# -BOM_BE = BOM32_BE = '\376\377' -# corresponds to Unicode U+FEFF in UTF-16 on big endian -# platforms == ZERO WIDTH NO-BREAK SPACE -BOM_LE = BOM32_LE = '\377\376' -# corresponds to Unicode U+FFFE in UTF-16 on little endian -# platforms == defined as being an illegal Unicode character - -# -# 64-bit Byte Order Marks -# -BOM64_BE = '\000\000\376\377' -# corresponds to Unicode U+0000FEFF in UCS-4 -BOM64_LE = '\377\376\000\000' -# corresponds to Unicode U+0000FFFE in UCS-4 - - -### Codec base classes (defining the API) - -class Codec: - - """ Defines the interface for stateless encoders/decoders. - - The .encode()/.decode() methods may implement different error - handling schemes by providing the errors argument. These - string values are defined: - - 'strict' - raise a ValueError error (or a subclass) - 'ignore' - ignore the character and continue with the next - 'replace' - replace with a suitable replacement character; - Python will use the official U+FFFD REPLACEMENT - CHARACTER for the builtin Unicode codecs. - - """ - def encode(self, input, errors='strict'): - - """ Encodes the object input and returns a tuple (output - object, length consumed). - - errors defines the error handling to apply. It defaults to - 'strict' handling. - - The method may not store state in the Codec instance. Use - StreamCodec for codecs which have to keep state in order to - make encoding/decoding efficient. - - The encoder must be able to handle zero length input and - return an empty object of the output object type in this - situation. - - """ - raise NotImplementedError - - def decode(self, input, errors='strict'): - - """ Decodes the object input and returns a tuple (output - object, length consumed). - - input must be an object which provides the bf_getreadbuf - buffer slot. Python strings, buffer objects and memory - mapped files are examples of objects providing this slot. - - errors defines the error handling to apply. It defaults to - 'strict' handling. - - The method may not store state in the Codec instance. Use - StreamCodec for codecs which have to keep state in order to - make encoding/decoding efficient. - - The decoder must be able to handle zero length input and - return an empty object of the output object type in this - situation. - - """ - raise NotImplementedError - -# -# The StreamWriter and StreamReader class provide generic working -# interfaces which can be used to implement new encoding submodules -# very easily. See encodings/utf_8.py for an example on how this is -# done. -# - -class StreamWriter(Codec): - - def __init__(self, stream, errors='strict'): - - """ Creates a StreamWriter instance. - - stream must be a file-like object open for writing - (binary) data. - - The StreamWriter may implement different error handling - schemes by providing the errors keyword argument. These - parameters are defined: - - 'strict' - raise a ValueError (or a subclass) - 'ignore' - ignore the character and continue with the next - 'replace'- replace with a suitable replacement character - - """ - self.stream = stream - self.errors = errors - - def write(self, object): - - """ Writes the object's contents encoded to self.stream. - """ - data, consumed = self.encode(object, self.errors) - self.stream.write(data) - - def writelines(self, list): - - """ Writes the concatenated list of strings to the stream - using .write(). - """ - self.write(''.join(list)) - - def reset(self): - - """ Flushes and resets the codec buffers used for keeping state. - - Calling this method should ensure that the data on the - output is put into a clean state, that allows appending - of new fresh data without having to rescan the whole - stream to recover state. - - """ - pass - - def __getattr__(self, name, - getattr=getattr): - - """ Inherit all other methods from the underlying stream. - """ - return getattr(self.stream, name) - -### - -class StreamReader(Codec): - - def __init__(self, stream, errors='strict'): - - """ Creates a StreamReader instance. - - stream must be a file-like object open for reading - (binary) data. - - The StreamReader may implement different error handling - schemes by providing the errors keyword argument. These - parameters are defined: - - 'strict' - raise a ValueError (or a subclass) - 'ignore' - ignore the character and continue with the next - 'replace'- replace with a suitable replacement character; - - """ - self.stream = stream - self.errors = errors - - def read(self, size=-1): - - """ Decodes data from the stream self.stream and returns the - resulting object. - - size indicates the approximate maximum number of bytes to - read from the stream for decoding purposes. The decoder - can modify this setting as appropriate. The default value - -1 indicates to read and decode as much as possible. size - is intended to prevent having to decode huge files in one - step. - - The method should use a greedy read strategy meaning that - it should read as much data as is allowed within the - definition of the encoding and the given size, e.g. if - optional encoding endings or state markers are available - on the stream, these should be read too. - - """ - # Unsliced reading: - if size < 0: - return self.decode(self.stream.read(), self.errors)[0] - - # Sliced reading: - read = self.stream.read - decode = self.decode - data = read(size) - i = 0 - while 1: - try: - object, decodedbytes = decode(data, self.errors) - except ValueError, why: - # This method is slow but should work under pretty much - # all conditions; at most 10 tries are made - i = i + 1 - newdata = read(1) - if not newdata or i > 10: - raise - data = data + newdata - else: - return object - - def readline(self, size=None): - - """ Read one line from the input stream and return the - decoded data. - - Note: Unlike the .readlines() method, this method inherits - the line breaking knowledge from the underlying stream's - .readline() method -- there is currently no support for - line breaking using the codec decoder due to lack of line - buffering. Sublcasses should however, if possible, try to - implement this method using their own knowledge of line - breaking. - - size, if given, is passed as size argument to the stream's - .readline() method. - - """ - if size is None: - line = self.stream.readline() - else: - line = self.stream.readline(size) - return self.decode(line, self.errors)[0] - - - def readlines(self, sizehint=None): - - """ Read all lines available on the input stream - and return them as list of lines. - - Line breaks are implemented using the codec's decoder - method and are included in the list entries. - - sizehint, if given, is passed as size argument to the - stream's .read() method. - - """ - if sizehint is None: - data = self.stream.read() - else: - data = self.stream.read(sizehint) - return self.decode(data, self.errors)[0].splitlines(1) - - def reset(self): - - """ Resets the codec buffers used for keeping state. - - Note that no stream repositioning should take place. - This method is primarily intended to be able to recover - from decoding errors. - - """ - pass - - def __getattr__(self, name, - getattr=getattr): - - """ Inherit all other methods from the underlying stream. - """ - return getattr(self.stream, name) - -### - -class StreamReaderWriter: - - """ StreamReaderWriter instances allow wrapping streams which - work in both read and write modes. - - The design is such that one can use the factory functions - returned by the codec.lookup() function to construct the - instance. - - """ - # Optional attributes set by the file wrappers below - encoding = 'unknown' - - def __init__(self, stream, Reader, Writer, errors='strict'): - - """ Creates a StreamReaderWriter instance. - - stream must be a Stream-like object. - - Reader, Writer must be factory functions or classes - providing the StreamReader, StreamWriter interface resp. - - Error handling is done in the same way as defined for the - StreamWriter/Readers. - - """ - self.stream = stream - self.reader = Reader(stream, errors) - self.writer = Writer(stream, errors) - self.errors = errors - - def read(self, size=-1): - - return self.reader.read(size) - - def readline(self, size=None): - - return self.reader.readline(size) - - def readlines(self, sizehint=None): - - return self.reader.readlines(sizehint) - - def write(self, data): - - return self.writer.write(data) - - def writelines(self, list): - - return self.writer.writelines(list) - - def reset(self): - - self.reader.reset() - self.writer.reset() - - def __getattr__(self, name, - getattr=getattr): - - """ Inherit all other methods from the underlying stream. - """ - return getattr(self.stream, name) - -### - -class StreamRecoder: - - """ StreamRecoder instances provide a frontend - backend - view of encoding data. - - They use the complete set of APIs returned by the - codecs.lookup() function to implement their task. - - Data written to the stream is first decoded into an - intermediate format (which is dependent on the given codec - combination) and then written to the stream using an instance - of the provided Writer class. - - In the other direction, data is read from the stream using a - Reader instance and then return encoded data to the caller. - - """ - # Optional attributes set by the file wrappers below - data_encoding = 'unknown' - file_encoding = 'unknown' - - def __init__(self, stream, encode, decode, Reader, Writer, - errors='strict'): - - """ Creates a StreamRecoder instance which implements a two-way - conversion: encode and decode work on the frontend (the - input to .read() and output of .write()) while - Reader and Writer work on the backend (reading and - writing to the stream). - - You can use these objects to do transparent direct - recodings from e.g. latin-1 to utf-8 and back. - - stream must be a file-like object. - - encode, decode must adhere to the Codec interface, Reader, - Writer must be factory functions or classes providing the - StreamReader, StreamWriter interface resp. - - encode and decode are needed for the frontend translation, - Reader and Writer for the backend translation. Unicode is - used as intermediate encoding. - - Error handling is done in the same way as defined for the - StreamWriter/Readers. - - """ - self.stream = stream - self.encode = encode - self.decode = decode - self.reader = Reader(stream, errors) - self.writer = Writer(stream, errors) - self.errors = errors - - def read(self, size=-1): - - data = self.reader.read(size) - data, bytesencoded = self.encode(data, self.errors) - return data - - def readline(self, size=None): - - if size is None: - data = self.reader.readline() - else: - data = self.reader.readline(size) - data, bytesencoded = self.encode(data, self.errors) - return data - - def readlines(self, sizehint=None): - - if sizehint is None: - data = self.reader.read() - else: - data = self.reader.read(sizehint) - data, bytesencoded = self.encode(data, self.errors) - return data.splitlines(1) - - def write(self, data): - - data, bytesdecoded = self.decode(data, self.errors) - return self.writer.write(data) - - def writelines(self, list): - - data = ''.join(list) - data, bytesdecoded = self.decode(data, self.errors) - return self.writer.write(data) - - def reset(self): - - self.reader.reset() - self.writer.reset() - - def __getattr__(self, name, - getattr=getattr): - - """ Inherit all other methods from the underlying stream. - """ - return getattr(self.stream, name) - -### Shortcuts - -def open(filename, mode='rb', encoding=None, errors='strict', buffering=1): - - """ Open an encoded file using the given mode and return - a wrapped version providing transparent encoding/decoding. - - Note: The wrapped version will only accept the object format - defined by the codecs, i.e. Unicode objects for most builtin - codecs. Output is also codec dependent and will usually by - Unicode as well. - - Files are always opened in binary mode, even if no binary mode - was specified. Thisis done to avoid data loss due to encodings - using 8-bit values. The default file mode is 'rb' meaning to - open the file in binary read mode. - - encoding specifies the encoding which is to be used for the - the file. - - errors may be given to define the error handling. It defaults - to 'strict' which causes ValueErrors to be raised in case an - encoding error occurs. - - buffering has the same meaning as for the builtin open() API. - It defaults to line buffered. - - The returned wrapped file object provides an extra attribute - .encoding which allows querying the used encoding. This - attribute is only available if an encoding was specified as - parameter. - - """ - if encoding is not None and \ - 'b' not in mode: - # Force opening of the file in binary mode - mode = mode + 'b' - file = __builtin__.open(filename, mode, buffering) - if encoding is None: - return file - (e, d, sr, sw) = lookup(encoding) - srw = StreamReaderWriter(file, sr, sw, errors) - # Add attributes to simplify introspection - srw.encoding = encoding - return srw - -def EncodedFile(file, data_encoding, file_encoding=None, errors='strict'): - - """ Return a wrapped version of file which provides transparent - encoding translation. - - Strings written to the wrapped file are interpreted according - to the given data_encoding and then written to the original - file as string using file_encoding. The intermediate encoding - will usually be Unicode but depends on the specified codecs. - - Strings are read from the file using file_encoding and then - passed back to the caller as string using data_encoding. - - If file_encoding is not given, it defaults to data_encoding. - - errors may be given to define the error handling. It defaults - to 'strict' which causes ValueErrors to be raised in case an - encoding error occurs. - - The returned wrapped file object provides two extra attributes - .data_encoding and .file_encoding which reflect the given - parameters of the same name. The attributes can be used for - introspection by Python programs. - - """ - if file_encoding is None: - file_encoding = data_encoding - encode, decode = lookup(data_encoding)[:2] - Reader, Writer = lookup(file_encoding)[2:] - sr = StreamRecoder(file, - encode, decode, Reader, Writer, - errors) - # Add attributes to simplify introspection - sr.data_encoding = data_encoding - sr.file_encoding = file_encoding - return sr - -### Helpers for codec lookup - -def getencoder(encoding): - - """ Lookup up the codec for the given encoding and return - its encoder function. - - Raises a LookupError in case the encoding cannot be found. - - """ - return lookup(encoding)[0] - -def getdecoder(encoding): - - """ Lookup up the codec for the given encoding and return - its decoder function. - - Raises a LookupError in case the encoding cannot be found. - - """ - return lookup(encoding)[1] - -def getreader(encoding): - - """ Lookup up the codec for the given encoding and return - its StreamReader class or factory function. - - Raises a LookupError in case the encoding cannot be found. - - """ - return lookup(encoding)[2] - -def getwriter(encoding): - - """ Lookup up the codec for the given encoding and return - its StreamWriter class or factory function. - - Raises a LookupError in case the encoding cannot be found. - - """ - return lookup(encoding)[3] - -### Helpers for charmap-based codecs - -def make_identity_dict(rng): - - """ make_identity_dict(rng) -> dict - - Return a dictionary where elements of the rng sequence are - mapped to themselves. - - """ - res = {} - for i in rng: - res[i]=i - return res - -def make_encoding_map(decoding_map): - - """ Creates an encoding map from a decoding map. - - If a target mapping in the decoding map occurrs multiple - times, then that target is mapped to None (undefined mapping), - causing an exception when encountered by the charmap codec - during translation. - - One example where this happens is cp875.py which decodes - multiple character to \u001a. - - """ - m = {} - for k,v in decoding_map.items(): - if not m.has_key(v): - m[v] = k - else: - m[v] = None - return m - -# Tell modulefinder that using codecs probably needs the encodings -# package -_false = 0 -if _false: - import encodings - -### Tests - -if __name__ == '__main__': - - import sys - - # Make stdout translate Latin-1 output into UTF-8 output - sys.stdout = EncodedFile(sys.stdout, 'latin-1', 'utf-8') - - # Have stdin translate Latin-1 input into UTF-8 input - sys.stdin = EncodedFile(sys.stdin, 'utf-8', 'latin-1') diff --git a/Scripts/ServerPython/python/system/colorsys.py b/Scripts/ServerPython/python/system/colorsys.py deleted file mode 100644 index 4e8c13c9..00000000 --- a/Scripts/ServerPython/python/system/colorsys.py +++ /dev/null @@ -1,123 +0,0 @@ -"""Conversion functions between RGB and other color systems. - -This modules provides two functions for each color system ABC: - - rgb_to_abc(r, g, b) --> a, b, c - abc_to_rgb(a, b, c) --> r, g, b - -All inputs and outputs are triples of floats in the range [0.0...1.0]. -Inputs outside this range may cause exceptions or invalid outputs. - -Supported color systems: -RGB: Red, Green, Blue components -YIQ: used by composite video signals -HLS: Hue, Luminance, Saturation -HSV: Hue, Saturation, Value -""" -# References: -# XXX Where's the literature? - -__all__ = ["rgb_to_yiq","yiq_to_rgb","rgb_to_hls","hls_to_rgb", - "rgb_to_hsv","hsv_to_rgb"] - -# Some floating point constants - -ONE_THIRD = 1.0/3.0 -ONE_SIXTH = 1.0/6.0 -TWO_THIRD = 2.0/3.0 - - -# YIQ: used by composite video signals (linear combinations of RGB) -# Y: perceived grey level (0.0 == black, 1.0 == white) -# I, Q: color components - -def rgb_to_yiq(r, g, b): - y = 0.30*r + 0.59*g + 0.11*b - i = 0.60*r - 0.28*g - 0.32*b - q = 0.21*r - 0.52*g + 0.31*b - return (y, i, q) - -def yiq_to_rgb(y, i, q): - r = y + 0.948262*i + 0.624013*q - g = y - 0.276066*i - 0.639810*q - b = y - 1.105450*i + 1.729860*q - if r < 0.0: r = 0.0 - if g < 0.0: g = 0.0 - if b < 0.0: b = 0.0 - if r > 1.0: r = 1.0 - if g > 1.0: g = 1.0 - if b > 1.0: b = 1.0 - return (r, g, b) - - -# HLS: Hue, Luminance, S??? -# H: position in the spectrum -# L: ??? -# S: ??? - -def rgb_to_hls(r, g, b): - maxc = max(r, g, b) - minc = min(r, g, b) - # XXX Can optimize (maxc+minc) and (maxc-minc) - l = (minc+maxc)/2.0 - if minc == maxc: return 0.0, l, 0.0 - if l <= 0.5: s = (maxc-minc) / (maxc+minc) - else: s = (maxc-minc) / (2.0-maxc-minc) - rc = (maxc-r) / (maxc-minc) - gc = (maxc-g) / (maxc-minc) - bc = (maxc-b) / (maxc-minc) - if r == maxc: h = bc-gc - elif g == maxc: h = 2.0+rc-bc - else: h = 4.0+gc-rc - h = (h/6.0) % 1.0 - return h, l, s - -def hls_to_rgb(h, l, s): - if s == 0.0: return l, l, l - if l <= 0.5: m2 = l * (1.0+s) - else: m2 = l+s-(l*s) - m1 = 2.0*l - m2 - return (_v(m1, m2, h+ONE_THIRD), _v(m1, m2, h), _v(m1, m2, h-ONE_THIRD)) - -def _v(m1, m2, hue): - hue = hue % 1.0 - if hue < ONE_SIXTH: return m1 + (m2-m1)*hue*6.0 - if hue < 0.5: return m2 - if hue < TWO_THIRD: return m1 + (m2-m1)*(TWO_THIRD-hue)*6.0 - return m1 - - -# HSV: Hue, Saturation, Value(?) -# H: position in the spectrum -# S: ??? -# V: ??? - -def rgb_to_hsv(r, g, b): - maxc = max(r, g, b) - minc = min(r, g, b) - v = maxc - if minc == maxc: return 0.0, 0.0, v - s = (maxc-minc) / maxc - rc = (maxc-r) / (maxc-minc) - gc = (maxc-g) / (maxc-minc) - bc = (maxc-b) / (maxc-minc) - if r == maxc: h = bc-gc - elif g == maxc: h = 2.0+rc-bc - else: h = 4.0+gc-rc - h = (h/6.0) % 1.0 - return h, s, v - -def hsv_to_rgb(h, s, v): - if s == 0.0: return v, v, v - i = int(h*6.0) # XXX assume int() truncates! - f = (h*6.0) - i - p = v*(1.0 - s) - q = v*(1.0 - s*f) - t = v*(1.0 - s*(1.0-f)) - if i%6 == 0: return v, t, p - if i == 1: return q, v, p - if i == 2: return p, v, t - if i == 3: return p, q, v - if i == 4: return t, p, v - if i == 5: return v, p, q - # Cannot get here diff --git a/Scripts/ServerPython/python/system/commands.py b/Scripts/ServerPython/python/system/commands.py deleted file mode 100644 index 02b4e5ae..00000000 --- a/Scripts/ServerPython/python/system/commands.py +++ /dev/null @@ -1,84 +0,0 @@ -"""Execute shell commands via os.popen() and return status, output. - -Interface summary: - - import commands - - outtext = commands.getoutput(cmd) - (exitstatus, outtext) = commands.getstatusoutput(cmd) - outtext = commands.getstatus(file) # returns output of "ls -ld file" - -A trailing newline is removed from the output string. - -Encapsulates the basic operation: - - pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r') - text = pipe.read() - sts = pipe.close() - - [Note: it would be nice to add functions to interpret the exit status.] -""" - -__all__ = ["getstatusoutput","getoutput","getstatus"] - -# Module 'commands' -# -# Various tools for executing commands and looking at their output and status. -# -# NB This only works (and is only relevant) for UNIX. - - -# Get 'ls -l' status for an object into a string -# -def getstatus(file): - """Return output of "ls -ld " in a string.""" - return getoutput('ls -ld' + mkarg(file)) - - -# Get the output from a shell command into a string. -# The exit status is ignored; a trailing newline is stripped. -# Assume the command will work with '{ ... ; } 2>&1' around it.. -# -def getoutput(cmd): - """Return output (stdout or stderr) of executing cmd in a shell.""" - return getstatusoutput(cmd)[1] - - -# Ditto but preserving the exit status. -# Returns a pair (sts, output) -# -def getstatusoutput(cmd): - """Return (status, output) of executing cmd in a shell.""" - import os - pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r') - text = pipe.read() - sts = pipe.close() - if sts is None: sts = 0 - if text[-1:] == '\n': text = text[:-1] - return sts, text - - -# Make command argument from directory and pathname (prefix space, add quotes). -# -def mk2arg(head, x): - import os - return mkarg(os.path.join(head, x)) - - -# Make a shell command argument from a string. -# Return a string beginning with a space followed by a shell-quoted -# version of the argument. -# Two strategies: enclose in single quotes if it contains none; -# otherwise, enclose in double quotes and prefix quotable characters -# with backslash. -# -def mkarg(x): - if '\'' not in x: - return ' \'' + x + '\'' - s = ' "' - for c in x: - if c in '\\$"`': - s = s + '\\' - s = s + c - s = s + '"' - return s diff --git a/Scripts/ServerPython/python/system/compileall.py b/Scripts/ServerPython/python/system/compileall.py deleted file mode 100644 index 60e04791..00000000 --- a/Scripts/ServerPython/python/system/compileall.py +++ /dev/null @@ -1,148 +0,0 @@ -"""Module/script to "compile" all .py files to .pyc (or .pyo) file. - -When called as a script with arguments, this compiles the directories -given as arguments recursively; the -l option prevents it from -recursing into directories. - -Without arguments, if compiles all modules on sys.path, without -recursing into subdirectories. (Even though it should do so for -packages -- for now, you'll have to deal with packages separately.) - -See module py_compile for details of the actual byte-compilation. - -""" - -import os -import stat -import sys -import py_compile - -__all__ = ["compile_dir","compile_path"] - -def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None): - """Byte-compile all modules in the given directory tree. - - Arguments (only dir is required): - - dir: the directory to byte-compile - maxlevels: maximum recursion level (default 10) - ddir: if given, purported directory name (this is the - directory name that will show up in error messages) - force: if 1, force compilation, even if timestamps are up-to-date - - """ - print 'Listing', dir, '...' - try: - names = os.listdir(dir) - except os.error: - print "Can't list", dir - names = [] - names.sort() - success = 1 - for name in names: - fullname = os.path.join(dir, name) - if ddir: - dfile = os.path.join(ddir, name) - else: - dfile = None - if rx: - mo = rx.search(fullname) - if mo: - continue - if os.path.isfile(fullname): - head, tail = name[:-3], name[-3:] - if tail == '.py': - cfile = fullname + (__debug__ and 'c' or 'o') - ftime = os.stat(fullname)[stat.ST_MTIME] - try: ctime = os.stat(cfile)[stat.ST_MTIME] - except os.error: ctime = 0 - if (ctime > ftime) and not force: continue - print 'Compiling', fullname, '...' - try: - ok = py_compile.compile(fullname, None, dfile) - except KeyboardInterrupt: - raise KeyboardInterrupt - except: - # XXX py_compile catches SyntaxErrors - if type(sys.exc_type) == type(''): - exc_type_name = sys.exc_type - else: exc_type_name = sys.exc_type.__name__ - print 'Sorry:', exc_type_name + ':', - print sys.exc_value - success = 0 - else: - if ok == 0: - success = 0 - elif maxlevels > 0 and \ - name != os.curdir and name != os.pardir and \ - os.path.isdir(fullname) and \ - not os.path.islink(fullname): - if not compile_dir(fullname, maxlevels - 1, dfile, force, rx): - success = 0 - return success - -def compile_path(skip_curdir=1, maxlevels=0, force=0): - """Byte-compile all module on sys.path. - - Arguments (all optional): - - skip_curdir: if true, skip current directory (default true) - maxlevels: max recursion level (default 0) - force: as for compile_dir() (default 0) - - """ - success = 1 - for dir in sys.path: - if (not dir or dir == os.curdir) and skip_curdir: - print 'Skipping current directory' - else: - success = success and compile_dir(dir, maxlevels, None, force) - return success - -def main(): - """Script main program.""" - import getopt - try: - opts, args = getopt.getopt(sys.argv[1:], 'lfd:x:') - except getopt.error, msg: - print msg - print "usage: python compileall.py [-l] [-f] [-d destdir] " \ - "[-s regexp] [directory ...]" - print "-l: don't recurse down" - print "-f: force rebuild even if timestamps are up-to-date" - print "-d destdir: purported directory name for error messages" - print " if no directory arguments, -l sys.path is assumed" - print "-x regexp: skip files matching the regular expression regexp" - print " the regexp is search for in the full path of the file" - sys.exit(2) - maxlevels = 10 - ddir = None - force = 0 - rx = None - for o, a in opts: - if o == '-l': maxlevels = 0 - if o == '-d': ddir = a - if o == '-f': force = 1 - if o == '-x': - import re - rx = re.compile(a) - if ddir: - if len(args) != 1: - print "-d destdir require exactly one directory argument" - sys.exit(2) - success = 1 - try: - if args: - for dir in args: - if not compile_dir(dir, maxlevels, ddir, force, rx): - success = 0 - else: - success = compile_path() - except KeyboardInterrupt: - print "\n[interrupt]" - success = 0 - return success - -if __name__ == '__main__': - exit_status = not main() - sys.exit(exit_status) diff --git a/Scripts/ServerPython/python/system/copy.py b/Scripts/ServerPython/python/system/copy.py deleted file mode 100644 index 17b40337..00000000 --- a/Scripts/ServerPython/python/system/copy.py +++ /dev/null @@ -1,378 +0,0 @@ -"""Generic (shallow and deep) copying operations. - -Interface summary: - - import copy - - x = copy.copy(y) # make a shallow copy of y - x = copy.deepcopy(y) # make a deep copy of y - -For module specific errors, copy.error is raised. - -The difference between shallow and deep copying is only relevant for -compound objects (objects that contain other objects, like lists or -class instances). - -- A shallow copy constructs a new compound object and then (to the - extent possible) inserts *the same objects* into in that the - original contains. - -- A deep copy constructs a new compound object and then, recursively, - inserts *copies* into it of the objects found in the original. - -Two problems often exist with deep copy operations that don't exist -with shallow copy operations: - - a) recursive objects (compound objects that, directly or indirectly, - contain a reference to themselves) may cause a recursive loop - - b) because deep copy copies *everything* it may copy too much, e.g. - administrative data structures that should be shared even between - copies - -Python's deep copy operation avoids these problems by: - - a) keeping a table of objects already copied during the current - copying pass - - b) letting user-defined classes override the copying operation or the - set of components copied - -This version does not copy types like module, class, function, method, -nor stack trace, stack frame, nor file, socket, window, nor array, nor -any similar types. - -Classes can use the same interfaces to control copying that they use -to control pickling: they can define methods called __getinitargs__(), -__getstate__() and __setstate__(). See the documentation for module -"pickle" for information on these methods. -""" - -# XXX need to support copy_reg here too... - -import types - -class Error(Exception): - pass -error = Error # backward compatibility - -try: - from org.python.core import PyStringMap -except ImportError: - PyStringMap = None - -__all__ = ["Error", "error", "copy", "deepcopy"] - -def copy(x): - """Shallow copy operation on arbitrary Python objects. - - See the module's __doc__ string for more info. - """ - - try: - copierfunction = _copy_dispatch[type(x)] - except KeyError: - try: - copier = x.__copy__ - except AttributeError: - try: - reductor = x.__reduce__ - except AttributeError: - raise error, \ - "un(shallow)copyable object of type %s" % type(x) - else: - y = _reconstruct(x, reductor(), 0) - else: - y = copier() - else: - y = copierfunction(x) - return y - -_copy_dispatch = d = {} - -def _copy_atomic(x): - return x -d[types.NoneType] = _copy_atomic -d[types.IntType] = _copy_atomic -d[types.LongType] = _copy_atomic -d[types.FloatType] = _copy_atomic -try: - d[types.ComplexType] = _copy_atomic -except AttributeError: - pass -d[types.StringType] = _copy_atomic -try: - d[types.UnicodeType] = _copy_atomic -except AttributeError: - pass -try: - d[types.CodeType] = _copy_atomic -except AttributeError: - pass -d[types.TypeType] = _copy_atomic -d[types.XRangeType] = _copy_atomic -d[types.ClassType] = _copy_atomic - -def _copy_list(x): - return x[:] -d[types.ListType] = _copy_list - -def _copy_tuple(x): - return x[:] -d[types.TupleType] = _copy_tuple - -def _copy_dict(x): - return x.copy() -d[types.DictionaryType] = _copy_dict -if PyStringMap is not None: - d[PyStringMap] = _copy_dict - -def _copy_inst(x): - if hasattr(x, '__copy__'): - return x.__copy__() - if hasattr(x, '__getinitargs__'): - args = x.__getinitargs__() - y = apply(x.__class__, args) - else: - y = _EmptyClass() - y.__class__ = x.__class__ - if hasattr(x, '__getstate__'): - state = x.__getstate__() - else: - state = x.__dict__ - if hasattr(y, '__setstate__'): - y.__setstate__(state) - else: - y.__dict__.update(state) - return y -d[types.InstanceType] = _copy_inst - -del d - -def deepcopy(x, memo = None): - """Deep copy operation on arbitrary Python objects. - - See the module's __doc__ string for more info. - """ - - if memo is None: - memo = {} - d = id(x) - if memo.has_key(d): - return memo[d] - try: - copierfunction = _deepcopy_dispatch[type(x)] - except KeyError: - try: - issc = issubclass(type(x), type) - except TypeError: - issc = 0 - if issc: - y = _deepcopy_dispatch[type](x, memo) - else: - try: - copier = x.__deepcopy__ - except AttributeError: - try: - reductor = x.__reduce__ - except AttributeError: - raise error, \ - "un-deep-copyable object of type %s" % type(x) - else: - y = _reconstruct(x, reductor(), 1, memo) - else: - y = copier(memo) - else: - y = copierfunction(x, memo) - memo[d] = y - _keep_alive(x, memo) # Make sure x lives at least as long as d - return y - -_deepcopy_dispatch = d = {} - -def _deepcopy_atomic(x, memo): - return x -d[types.NoneType] = _deepcopy_atomic -d[types.IntType] = _deepcopy_atomic -d[types.LongType] = _deepcopy_atomic -d[types.FloatType] = _deepcopy_atomic -try: - d[types.ComplexType] = _deepcopy_atomic -except AttributeError: - pass -d[types.StringType] = _deepcopy_atomic -try: - d[types.UnicodeType] = _deepcopy_atomic -except AttributeError: - pass -try: - d[types.CodeType] = _deepcopy_atomic -except AttributeError: - pass -d[types.TypeType] = _deepcopy_atomic -d[types.XRangeType] = _deepcopy_atomic - -def _deepcopy_list(x, memo): - y = [] - memo[id(x)] = y - for a in x: - y.append(deepcopy(a, memo)) - return y -d[types.ListType] = _deepcopy_list - -def _deepcopy_tuple(x, memo): - y = [] - for a in x: - y.append(deepcopy(a, memo)) - d = id(x) - try: - return memo[d] - except KeyError: - pass - for i in range(len(x)): - if x[i] is not y[i]: - y = tuple(y) - break - else: - y = x - memo[d] = y - return y -d[types.TupleType] = _deepcopy_tuple - -def _deepcopy_dict(x, memo): - y = {} - memo[id(x)] = y - for key in x.keys(): - y[deepcopy(key, memo)] = deepcopy(x[key], memo) - return y -d[types.DictionaryType] = _deepcopy_dict -if PyStringMap is not None: - d[PyStringMap] = _deepcopy_dict - -def _keep_alive(x, memo): - """Keeps a reference to the object x in the memo. - - Because we remember objects by their id, we have - to assure that possibly temporary objects are kept - alive by referencing them. - We store a reference at the id of the memo, which should - normally not be used unless someone tries to deepcopy - the memo itself... - """ - try: - memo[id(memo)].append(x) - except KeyError: - # aha, this is the first one :-) - memo[id(memo)]=[x] - -def _deepcopy_inst(x, memo): - if hasattr(x, '__deepcopy__'): - return x.__deepcopy__(memo) - if hasattr(x, '__getinitargs__'): - args = x.__getinitargs__() - args = deepcopy(args, memo) - y = apply(x.__class__, args) - else: - y = _EmptyClass() - y.__class__ = x.__class__ - memo[id(x)] = y - if hasattr(x, '__getstate__'): - state = x.__getstate__() - else: - state = x.__dict__ - state = deepcopy(state, memo) - if hasattr(y, '__setstate__'): - y.__setstate__(state) - else: - y.__dict__.update(state) - return y -d[types.InstanceType] = _deepcopy_inst - -def _reconstruct(x, info, deep, memo=None): - if isinstance(info, str): - return x - assert isinstance(info, tuple) - if memo is None: - memo = {} - n = len(info) - assert n in (2, 3) - callable, args = info[:2] - if n > 2: - state = info[2] - else: - state = {} - if deep: - args = deepcopy(args, memo) - y = callable(*args) - if state: - if deep: - state = deepcopy(state, memo) - if hasattr(y, '__setstate__'): - y.__setstate__(state) - else: - y.__dict__.update(state) - return y - -del d - -del types - -# Helper for instance creation without calling __init__ -class _EmptyClass: - pass - -def _test(): - l = [None, 1, 2L, 3.14, 'xyzzy', (1, 2L), [3.14, 'abc'], - {'abc': 'ABC'}, (), [], {}] - l1 = copy(l) - print l1==l - l1 = map(copy, l) - print l1==l - l1 = deepcopy(l) - print l1==l - class C: - def __init__(self, arg=None): - self.a = 1 - self.arg = arg - if __name__ == '__main__': - import sys - file = sys.argv[0] - else: - file = __file__ - self.fp = open(file) - self.fp.close() - def __getstate__(self): - return {'a': self.a, 'arg': self.arg} - def __setstate__(self, state): - for key in state.keys(): - setattr(self, key, state[key]) - def __deepcopy__(self, memo = None): - new = self.__class__(deepcopy(self.arg, memo)) - new.a = self.a - return new - c = C('argument sketch') - l.append(c) - l2 = copy(l) - print l == l2 - print l - print l2 - l2 = deepcopy(l) - print l == l2 - print l - print l2 - l.append({l[1]: l, 'xyz': l[2]}) - l3 = copy(l) - import repr - print map(repr.repr, l) - print map(repr.repr, l1) - print map(repr.repr, l2) - print map(repr.repr, l3) - l3 = deepcopy(l) - import repr - print map(repr.repr, l) - print map(repr.repr, l1) - print map(repr.repr, l2) - print map(repr.repr, l3) - -if __name__ == '__main__': - _test() diff --git a/Scripts/ServerPython/python/system/copy_reg.py b/Scripts/ServerPython/python/system/copy_reg.py deleted file mode 100644 index 93fab1d6..00000000 --- a/Scripts/ServerPython/python/system/copy_reg.py +++ /dev/null @@ -1,72 +0,0 @@ -"""Helper to provide extensibility for pickle/cPickle. - -This is only useful to add pickle support for extension types defined in -C, not for instances of user-defined classes. -""" - -from types import ClassType as _ClassType - -__all__ = ["pickle","constructor"] - -dispatch_table = {} -safe_constructors = {} - -def pickle(ob_type, pickle_function, constructor_ob=None): - if type(ob_type) is _ClassType: - raise TypeError("copy_reg is not intended for use with classes") - - if not callable(pickle_function): - raise TypeError("reduction functions must be callable") - dispatch_table[ob_type] = pickle_function - - if constructor_ob is not None: - constructor(constructor_ob) - -def constructor(object): - if not callable(object): - raise TypeError("constructors must be callable") - safe_constructors[object] = 1 - -# Example: provide pickling support for complex numbers. - -def pickle_complex(c): - return complex, (c.real, c.imag) - -pickle(type(1j), pickle_complex, complex) - -# Support for picking new-style objects - -def _reconstructor(cls, base, state): - obj = base.__new__(cls, state) - base.__init__(obj, state) - return obj -_reconstructor.__safe_for_unpickling__ = 1 - -_HEAPTYPE = 1<<9 - -def _reduce(self): - for base in self.__class__.__mro__: - if hasattr(base, '__flags__') and not base.__flags__ & _HEAPTYPE: - break - else: - base = object # not really reachable - if base is object: - state = None - else: - if base is self.__class__: - raise TypeError, "can't pickle %s objects" % base.__name__ - state = base(self) - args = (self.__class__, base, state) - try: - getstate = self.__getstate__ - except AttributeError: - try: - dict = self.__dict__ - except AttributeError: - dict = None - else: - dict = getstate() - if dict: - return _reconstructor, args, dict - else: - return _reconstructor, args diff --git a/Scripts/ServerPython/python/system/decompyle.py b/Scripts/ServerPython/python/system/decompyle.py deleted file mode 100644 index ec63f1b2..00000000 --- a/Scripts/ServerPython/python/system/decompyle.py +++ /dev/null @@ -1,1500 +0,0 @@ -# Copyright (c) 1999 John Aycock -# Copyright (c) 2000 by hartmut Goebel -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# See 'CHANGES' for a list of changes -# -# NB. This is not a masterpiece of software, but became more like a hack. -# Probably a complete write would be sensefull. hG/2000-12-27 -# - -import re, sys, os, types -import dis, imp, marshal -import string -import cStringIO - - -def _load_file(filename): - """ - load a Python source file and compile it to byte-code - _load_module(filename: string): code_object - - filename: name of file containing Python source code - (normally a .py) - code_object: code_object compiled from this source code - - This function does NOT write any file! - """ - fp = open(filename, 'rb') - source = fp.read()+'\n' - try: - co = compile(source, filename, 'exec') - except SyntaxError: - sys.stderr.writelines( ['>>Syntax error in ', filename, '\n'] ) - raise - fp.close() - return co - -def _load_module(filename): - """ - load a module without importing it - _load_module(filename: string): code_object - - filename: name of file containing Python byte-code object - (normally a .pyc) - code_object: code_object from this file - """ - fp = open(filename, 'rb') - if fp.read(4) != imp.get_magic(): - raise ImportError, "Bad magic number in %s" % filename - fp.read(4) - co = marshal.load(fp) - fp.close() - return co - - -#-- start of (de-)compiler - -# -# Scanning -# - -class Code: - """Class for representing code-objects. - - This is similar to the original code object, but additionally - the diassembled code is stored in the attribute '_tokens'. - """ - def __init__(self, co): - for i in dir(co): - exec 'self.%s = co.%s' % (i, i) - self._tokens, self._customize = disassemble(co) - -class Token: - """Class representing a byte-code token. - A byte-code token is equivalent to the contents of one line - as output by dis.dis(). - """ - def __init__(self, type, attr=None, pattr=None, offset=-1): - self.type = intern(type) - self.attr = attr - self.pattr = pattr - self.offset = offset - - def __cmp__(self, o): - if isinstance(o, Token): - # both are tokens: compare type and pattr - return cmp(self.type, o.type) \ - or cmp(self.pattr, o.pattr) - else: - return cmp(self.type, o) - - def __repr__(self): return str(self.type) - def __str__(self): - if self.pattr: pattr = self.pattr - else: pattr = '' - return '%s\t%-17s %s' % (self.offset, self.type, pattr) - def __hash__(self): return hash(self.type) - def __getitem__(self, i): raise IndexError - -_JUMP_OPS_ = map(lambda op: dis.opname[op], dis.hasjrel + dis.hasjabs) - -def disassemble(co): - """Disassemble a code object, returning a list of Token. - - The main part of this procedure is modelled after - dis.diaassemble(). - """ - rv = [] - customize = {} - - code = co.co_code - cf = find_jump_targets(code) - n = len(code) - i = 0 - while i < n: - offset = i - if cf.has_key(offset): - for j in range(cf[offset]): - rv.append(Token('COME_FROM', - offset="%s_%d" % (offset, j) )) - - c = code[i] - op = ord(c) - opname = dis.opname[op] - i = i+1 - oparg = None; pattr = None - if op >= dis.HAVE_ARGUMENT: - oparg = ord(code[i]) + ord(code[i+1])*256 - i = i+2 - if op in dis.hasconst: - const = co.co_consts[oparg] - if type(const) == types.CodeType: - oparg = const - if const.co_name == '': - assert opname == 'LOAD_CONST' - opname = 'LOAD_LAMBDA' - # verify uses 'pattr' for - # comparism, since 'attr' now - # hold Code(const) and thus - # can not be used for - # comparism (todo: thinkg - # about changing this) - #pattr = 'code_object @ 0x%x %s->%s' %\ - # (id(const), const.co_filename, const.co_name) - pattr = 'code_object ' + const.co_name - else: - pattr = `const` - elif op in dis.hasname: - pattr = co.co_names[oparg] - elif op in dis.hasjrel: - pattr = `i + oparg` - elif op in dis.haslocal: - pattr = co.co_varnames[oparg] - elif op in dis.hascompare: - pattr = dis.cmp_op[oparg] - - if opname == 'SET_LINENO': - continue - elif opname in ('BUILD_LIST', 'BUILD_TUPLE', 'BUILD_SLICE', - 'UNPACK_LIST', 'UNPACK_TUPLE', - 'UNPACK_SEQUENCE', - 'MAKE_FUNCTION', 'CALL_FUNCTION', - 'CALL_FUNCTION_VAR', 'CALL_FUNCTION_KW', - 'CALL_FUNCTION_VAR_KW', 'DUP_TOPX', - ): - opname = '%s_%d' % (opname, oparg) - customize[opname] = oparg - - rv.append(Token(opname, oparg, pattr, offset)) - - return rv, customize - - -def find_jump_targets(code): - """Detect all offsets in a byte code which are jump targets. - - Return the list of offsets. - - This procedure is modelled after dis.findlables(), but here - for each target the number of jumps are counted. - """ - targets = {} - n = len(code) - i = 0 - while i < n: - c = code[i] - op = ord(c) - i = i+1 - if op >= dis.HAVE_ARGUMENT: - oparg = ord(code[i]) + ord(code[i+1])*256 - i = i+2 - label = -1 - if op in dis.hasjrel: - label = i+oparg - # todo: absolut jumps - #elif op in dis.hasjabs: - # label = oparg - if label >= 0: - targets[label] = targets.get(label, 0) + 1 - return targets - - -# -# Parsing -# - -class AST: - def __init__(self, type, kids=None): - self.type = intern(type) - if kids == None: kids = [] - self._kids = kids - - def append(self, o): self._kids.append(o) - def pop(self): return self._kids.pop() - def __getitem__(self, i): return self._kids[i] - def __setitem__(self, i, val): self._kids[i] = val - def __delitem__(self, i): del self._kids[i] - def __len__(self): return len(self._kids) - def __getslice__(self, low, high): return self._kids[low:high] - def __setslice__(self, low, high, seq): self._kids[low:high] = seq - def __delslice__(self, low, high): del self._kids[low:high] - def __cmp__(self, o): - if isinstance(o, AST): - return cmp(self.type, o.type) \ - or cmp(self._kids, o._kids) - else: - return cmp(self.type, o) - - def __hash__(self): return hash(self.type) - - def __repr__(self): - rv = str(self.type) - for k in self._kids: - rv = rv + '\n' + string.replace(str(k), '\n', '\n ') - return rv - -# Some ASTs used for comparing code fragments (like 'return None' at -# the end of functions). - -RETURN_LOCALS = AST('stmt', - [ AST('return_stmt', - [ AST('expr', [ Token('LOAD_LOCALS') ]), - Token('RETURN_VALUE')]) ]) - -RETURN_NONE = AST('stmt', - [ AST('return_stmt', - [ AST('expr', [ Token('LOAD_CONST', pattr='None') ]), - Token('RETURN_VALUE')]) ]) - -ASSIGN_DOC_STRING = lambda doc_string: \ - AST('stmt', - [ AST('assign', - [ AST('expr', [ Token('LOAD_CONST', pattr=`doc_string`) ]), - AST('designator', [ Token('STORE_NAME', pattr='__doc__')]) - ])]) - -BUILD_TUPLE_0 = AST('expr', - [ Token('BUILD_TUPLE_0') ] ) - -from spark import GenericASTBuilder, GenericASTMatcher - -class Parser(GenericASTBuilder): - def __init__(self): - GenericASTBuilder.__init__(self, AST, 'code') - self.customized = {} - - def cleanup(self): - """ - Remove recursive references to allow garbage - collector to collect this object. - """ - for dict in (self.rule2func, self.rules, self.rule2name, self.first): - for i in dict.keys(): - dict[i] = None - for i in dir(self): - setattr(self, i, None) - - def error(self, token): - # output offset, too - print "Syntax error at or near `%s' token at offset %s" % \ - (`token`, token.offset) - raise SystemExit - - def typestring(self, token): - return token.type - - def p_funcdef(self, args): - ''' - stmt ::= funcdef - funcdef ::= mkfunc STORE_FAST - funcdef ::= mkfunc STORE_NAME - ''' - -# new for Python2.0 -# -# UNPACK_SEQUENCE # number of tuple items -# EXTENDED_ARG - - def p_list_comprehension(self, args): - ''' - expr ::= list_compr - list_compr ::= lc_prep lc_for lc_cleanup - lc_prep ::= BUILD_LIST_0 DUP_TOP LOAD_ATTR STORE_NAME - lc_prep ::= BUILD_LIST_0 DUP_TOP LOAD_ATTR STORE_FAST - - lc_for ::= expr LOAD_CONST - FOR_LOOP designator - lc_for JUMP_ABSOLUTE - COME_FROM - lc_for ::= expr LOAD_CONST - FOR_LOOP designator - lc_if JUMP_ABSOLUTE - COME_FROM - lc_for ::= expr LOAD_CONST - FOR_LOOP designator - lc_body JUMP_ABSOLUTE - COME_FROM - lc_if ::= expr condjmp lc_body - JUMP_FORWARD COME_FROM POP_TOP - COME_FROM - lc_body ::= LOAD_NAME expr CALL_FUNCTION_1 POP_TOP - lc_body ::= LOAD_FAST expr CALL_FUNCTION_1 POP_TOP - lc_cleanup ::= DELETE_NAME - lc_cleanup ::= DELETE_FAST - ''' - - def p_augmented_assign(self, args): - ''' - stmt ::= augassign1 - stmt ::= augassign2 - augassign1 ::= expr expr inplace_op designator - augassign1 ::= expr expr inplace_op ROT_THREE STORE_SUBSCR - augassign1 ::= expr expr inplace_op ROT_TWO STORE_SLICE+0 - augassign1 ::= expr expr inplace_op ROT_THREE STORE_SLICE+1 - augassign1 ::= expr expr inplace_op ROT_THREE STORE_SLICE+2 - augassign1 ::= expr expr inplace_op ROT_FOUR STORE_SLICE+3 - augassign2 ::= expr DUP_TOP LOAD_ATTR expr - inplace_op ROT_TWO STORE_ATTR - - inplace_op ::= INPLACE_ADD - inplace_op ::= INPLACE_SUBTRACT - inplace_op ::= INPLACE_MULTIPLY - inplace_op ::= INPLACE_DIVIDE - inplace_op ::= INPLACE_MODULO - inplace_op ::= INPLACE_POWER - inplace_op ::= INPLACE_LSHIFT - inplace_op ::= INPLACE_RSHIFT - inplace_op ::= INPLACE_AND - inplace_op ::= INPLACE_XOR - inplace_op ::= INPLACE_OR - ''' - - def p_assign(self, args): - ''' - stmt ::= assign - assign ::= expr DUP_TOP designList - assign ::= expr designator - ''' - - def p_print(self, args): - ''' - stmt ::= print_stmt - stmt ::= print_stmt_nl - stmt ::= print_nl_stmt - print_stmt ::= expr PRINT_ITEM - print_nl_stmt ::= PRINT_NEWLINE - print_stmt_nl ::= print_stmt print_nl_stmt - ''' - - def p_print_to(self, args): - ''' - stmt ::= print_to - stmt ::= print_to_nl - stmt ::= print_nl_to - print_to ::= expr print_to_items POP_TOP - print_to_nl ::= expr print_to_items PRINT_NEWLINE_TO - print_nl_to ::= expr PRINT_NEWLINE_TO - print_to_items ::= print_to_items print_to_item - print_to_items ::= print_to_item - print_to_item ::= DUP_TOP expr ROT_TWO PRINT_ITEM_TO - ''' - # expr print_to* POP_TOP - # expr { print_to* } PRINT_NEWLINE_TO - - def p_import15(self, args): - ''' - stmt ::= importstmt - stmt ::= importfrom - - importstmt ::= IMPORT_NAME STORE_FAST - importstmt ::= IMPORT_NAME STORE_NAME - - importfrom ::= IMPORT_NAME importlist POP_TOP - importlist ::= importlist IMPORT_FROM - importlist ::= IMPORT_FROM - ''' - - def p_import20(self, args): - ''' - stmt ::= importstmt2 - stmt ::= importfrom2 - stmt ::= importstar2 - - importstmt2 ::= LOAD_CONST import_as - importstar2 ::= LOAD_CONST IMPORT_NAME IMPORT_STAR - - importfrom2 ::= LOAD_CONST IMPORT_NAME importlist2 POP_TOP - importlist2 ::= importlist2 import_as - importlist2 ::= import_as - import_as ::= IMPORT_NAME STORE_FAST - import_as ::= IMPORT_NAME STORE_NAME - import_as ::= IMPORT_NAME LOAD_ATTR STORE_FAST - import_as ::= IMPORT_NAME LOAD_ATTR STORE_NAME - import_as ::= IMPORT_FROM STORE_FAST - import_as ::= IMPORT_FROM STORE_NAME - ''' - # 'import_as' can't use designator, since n_import_as() - # needs to compare both kids' pattr - - def p_grammar(self, args): - ''' - code ::= stmts - code ::= - - stmts ::= stmts stmt - stmts ::= stmt - - stmts_opt ::= stmts - stmts_opt ::= passstmt - passstmt ::= - - designList ::= designator designator - designList ::= designator DUP_TOP designList - - designator ::= STORE_FAST - designator ::= STORE_NAME - designator ::= STORE_GLOBAL - designator ::= expr STORE_ATTR - designator ::= expr STORE_SLICE+0 - designator ::= expr expr STORE_SLICE+1 - designator ::= expr expr STORE_SLICE+2 - designator ::= expr expr expr STORE_SLICE+3 - designator ::= store_subscr - store_subscr ::= expr expr STORE_SUBSCR - designator ::= unpack - designator ::= unpack_list - - stmt ::= classdef - stmt ::= call_stmt - call_stmt ::= expr POP_TOP - - stmt ::= return_stmt - return_stmt ::= expr RETURN_VALUE - - stmt ::= break_stmt - break_stmt ::= BREAK_LOOP - - stmt ::= continue_stmt - continue_stmt ::= JUMP_ABSOLUTE - - stmt ::= raise_stmt - raise_stmt ::= exprlist RAISE_VARARGS - raise_stmt ::= nullexprlist RAISE_VARARGS - - stmt ::= exec_stmt - exec_stmt ::= expr exprlist DUP_TOP EXEC_STMT - exec_stmt ::= expr exprlist EXEC_STMT - - stmt ::= assert - stmt ::= assert2 - stmt ::= ifstmt - stmt ::= ifelsestmt - stmt ::= whilestmt - stmt ::= whileelsestmt - stmt ::= forstmt - stmt ::= forelsestmt - stmt ::= trystmt - stmt ::= tryfinallystmt - - stmt ::= DELETE_FAST - stmt ::= DELETE_NAME - stmt ::= DELETE_GLOBAL - stmt ::= expr DELETE_SLICE+0 - stmt ::= expr expr DELETE_SLICE+1 - stmt ::= expr expr DELETE_SLICE+2 - stmt ::= expr expr expr DELETE_SLICE+3 - stmt ::= delete_subscr - delete_subscr ::= expr expr DELETE_SUBSCR - stmt ::= expr DELETE_ATTR - - kwarg ::= LOAD_CONST expr - - classdef ::= LOAD_CONST expr mkfunc - CALL_FUNCTION_0 BUILD_CLASS STORE_NAME - classdef ::= LOAD_CONST expr mkfunc - CALL_FUNCTION_0 BUILD_CLASS STORE_FAST - - condjmp ::= JUMP_IF_FALSE POP_TOP - condjmp ::= JUMP_IF_TRUE POP_TOP - - assert ::= expr JUMP_IF_FALSE POP_TOP - expr JUMP_IF_TRUE POP_TOP - LOAD_GLOBAL RAISE_VARARGS - COME_FROM COME_FROM POP_TOP - assert2 ::= expr JUMP_IF_FALSE POP_TOP - expr JUMP_IF_TRUE POP_TOP - LOAD_GLOBAL expr RAISE_VARARGS - COME_FROM COME_FROM POP_TOP - - ifstmt ::= expr condjmp stmts_opt - JUMP_FORWARD COME_FROM POP_TOP - COME_FROM - - ifelsestmt ::= expr condjmp stmts_opt - JUMP_FORWARD COME_FROM - POP_TOP stmts COME_FROM - - trystmt ::= SETUP_EXCEPT stmts_opt - POP_BLOCK JUMP_FORWARD - COME_FROM except_stmt - - try_end ::= END_FINALLY COME_FROM - try_end ::= except_else - except_else ::= END_FINALLY COME_FROM stmts - - except_stmt ::= except_cond except_stmt COME_FROM - except_stmt ::= except_conds try_end COME_FROM - except_stmt ::= except try_end COME_FROM - except_stmt ::= try_end - - except_conds ::= except_cond except_conds COME_FROM - except_conds ::= - - except_cond ::= except_cond1 - except_cond ::= except_cond2 - except_cond1 ::= DUP_TOP expr COMPARE_OP - JUMP_IF_FALSE - POP_TOP POP_TOP POP_TOP POP_TOP - stmts_opt JUMP_FORWARD COME_FROM - POP_TOP - except_cond2 ::= DUP_TOP expr COMPARE_OP - JUMP_IF_FALSE - POP_TOP POP_TOP designator POP_TOP - stmts_opt JUMP_FORWARD COME_FROM - POP_TOP - except ::= POP_TOP POP_TOP POP_TOP - stmts_opt JUMP_FORWARD - - tryfinallystmt ::= SETUP_FINALLY stmts_opt - POP_BLOCK LOAD_CONST - COME_FROM stmts_opt END_FINALLY - - whilestmt ::= SETUP_LOOP - expr JUMP_IF_FALSE POP_TOP - stmts_opt JUMP_ABSOLUTE - COME_FROM POP_TOP POP_BLOCK COME_FROM - whileelsestmt ::= SETUP_LOOP - expr JUMP_IF_FALSE POP_TOP - stmts_opt JUMP_ABSOLUTE - COME_FROM POP_TOP POP_BLOCK - stmts COME_FROM - - forstmt ::= SETUP_LOOP expr LOAD_CONST - FOR_LOOP designator - stmts_opt JUMP_ABSOLUTE - COME_FROM POP_BLOCK COME_FROM - forelsestmt ::= SETUP_LOOP expr LOAD_CONST - FOR_LOOP designator - stmts_opt JUMP_ABSOLUTE - COME_FROM POP_BLOCK stmts COME_FROM - ''' - - def p_expr(self, args): - ''' - expr ::= mklambda - expr ::= mkfunc - expr ::= SET_LINENO - expr ::= LOAD_FAST - expr ::= LOAD_NAME - expr ::= LOAD_CONST - expr ::= LOAD_GLOBAL - expr ::= LOAD_LOCALS - expr ::= expr LOAD_ATTR - expr ::= binary_expr - - binary_expr ::= expr expr binary_op - binary_op ::= BINARY_ADD - binary_op ::= BINARY_SUBTRACT - binary_op ::= BINARY_MULTIPLY - binary_op ::= BINARY_DIVIDE - binary_op ::= BINARY_MODULO - binary_op ::= BINARY_LSHIFT - binary_op ::= BINARY_RSHIFT - binary_op ::= BINARY_AND - binary_op ::= BINARY_OR - binary_op ::= BINARY_XOR - binary_op ::= BINARY_POWER - - expr ::= binary_subscr - binary_subscr ::= expr expr BINARY_SUBSCR - expr ::= expr expr DUP_TOPX_2 BINARY_SUBSCR - expr ::= cmp - expr ::= expr UNARY_POSITIVE - expr ::= expr UNARY_NEGATIVE - expr ::= expr UNARY_CONVERT - expr ::= expr UNARY_INVERT - expr ::= expr UNARY_NOT - expr ::= mapexpr - expr ::= expr SLICE+0 - expr ::= expr expr SLICE+1 - expr ::= expr expr SLICE+2 - expr ::= expr expr expr SLICE+3 - expr ::= expr DUP_TOP SLICE+0 - expr ::= expr expr DUP_TOPX_2 SLICE+1 - expr ::= expr expr DUP_TOPX_2 SLICE+2 - expr ::= expr expr expr DUP_TOPX_3 SLICE+3 - expr ::= and - expr ::= or - or ::= expr JUMP_IF_TRUE POP_TOP expr COME_FROM - and ::= expr JUMP_IF_FALSE POP_TOP expr COME_FROM - - cmp ::= cmp_list - cmp ::= compare - compare ::= expr expr COMPARE_OP - cmp_list ::= expr cmp_list1 ROT_TWO POP_TOP - COME_FROM - cmp_list1 ::= expr DUP_TOP ROT_THREE - COMPARE_OP JUMP_IF_FALSE POP_TOP - cmp_list1 COME_FROM - cmp_list1 ::= expr DUP_TOP ROT_THREE - COMPARE_OP JUMP_IF_FALSE POP_TOP - cmp_list2 COME_FROM - cmp_list2 ::= expr COMPARE_OP JUMP_FORWARD - - mapexpr ::= BUILD_MAP kvlist - - kvlist ::= kvlist kv - kvlist ::= - - kv ::= DUP_TOP expr ROT_TWO expr STORE_SUBSCR - - exprlist ::= exprlist expr - exprlist ::= expr - - nullexprlist ::= - ''' - - def nonterminal(self, nt, args): - collect = ('stmts', 'exprlist', 'kvlist') - - if nt in collect and len(args) > 1: - # - # Collect iterated thingies together. - # - rv = args[0] - rv.append(args[1]) - else: - rv = GenericASTBuilder.nonterminal(self, nt, args) - return rv - - def __ambiguity(self, children): - # only for debugging! to be removed hG/2000-10-15 - print children - return GenericASTBuilder.ambiguity(self, children) - - def resolve(self, list): - if len(list) == 2 and 'funcdef' in list and 'assign' in list: - return 'funcdef' - #sys.stderr.writelines( ['resolve ', str(list), '\n'] ) - return GenericASTBuilder.resolve(self, list) - -nop = lambda self, args: None - -def parse(tokens, customize): - p = Parser() - # - # Special handling for opcodes that take a variable number - # of arguments -- we add a new rule for each: - # - # expr ::= {expr}^n BUILD_LIST_n - # expr ::= {expr}^n BUILD_TUPLE_n - # expr ::= {expr}^n BUILD_SLICE_n - # unpack_list ::= UNPACK_LIST {expr}^n - # unpack ::= UNPACK_TUPLE {expr}^n - # unpack ::= UNPACK_SEQEUENE {expr}^n - # mkfunc ::= {expr}^n LOAD_CONST MAKE_FUNCTION_n - # expr ::= expr {expr}^n CALL_FUNCTION_n - # expr ::= expr {expr}^n CALL_FUNCTION_VAR_n POP_TOP - # expr ::= expr {expr}^n CALL_FUNCTION_VAR_KW_n POP_TOP - # expr ::= expr {expr}^n CALL_FUNCTION_KW_n POP_TOP - # - for k, v in customize.items(): - ## avoid adding the same rule twice to this parser - #if p.customized.has_key(k): - # continue - #p.customized[k] = None - - #nop = lambda self, args: None - op = k[:string.rfind(k, '_')] - if op in ('BUILD_LIST', 'BUILD_TUPLE', 'BUILD_SLICE'): - rule = 'expr ::= ' + 'expr '*v + k - elif op in ('UNPACK_TUPLE', 'UNPACK_SEQUENCE'): - rule = 'unpack ::= ' + k + ' designator'*v - elif op == 'UNPACK_LIST': - rule = 'unpack_list ::= ' + k + ' designator'*v - elif op == 'DUP_TOPX': - # no need to add a rule - pass - #rule = 'dup_topx ::= ' + 'expr '*v + k - elif op == 'MAKE_FUNCTION': - p.addRule('mklambda ::= %s LOAD_LAMBDA %s' % - ('expr '*v, k), nop) - rule = 'mkfunc ::= %s LOAD_CONST %s' % ('expr '*v, k) - elif op in ('CALL_FUNCTION', 'CALL_FUNCTION_VAR', - 'CALL_FUNCTION_VAR_KW', 'CALL_FUNCTION_KW'): - na = (v & 0xff) # positional parameters - nk = (v >> 8) & 0xff # keyword parameters - # number of apply equiv arguments: - nak = ( len(op)-len('CALL_FUNCTION') ) / 3 - rule = 'expr ::= expr ' + 'expr '*na + 'kwarg '*nk \ - + 'expr ' * nak + k - else: - raise 'unknown customize token %s' % k - p.addRule(rule, nop) - ast = p.parse(tokens) - p.cleanup() - return ast - -# -# Decompilation (walking AST) -# -# All table-driven. Step 1 determines a table (T) and a path to a -# table key (K) from the node type (N) (other nodes are shown as O): -# -# N N N&K -# / | ... \ / | ... \ / | ... \ -# O O O O O K O O O -# | -# K -# -# MAP_R0 (TABLE_R0) MAP_R (TABLE_R) MAP_DIRECT (TABLE_DIRECT) -# -# The default is a direct mapping. The key K is then extracted from the -# subtree and used to find a table entry T[K], if any. The result is a -# format string and arguments (a la printf()) for the formatting engine. -# Escapes in the format string are: -# -# %c evaluate N[A] recursively* -# %C evaluate N[A[0]]..N[A[1]] recursively, separate by A[2]* -# %, print ',' if last %C only printed one item (for tuples) -# %| tab to current indentation level -# %+ increase current indentation level -# %- decrease current indentation level -# %{...} evaluate ... in context of N -# %% literal '%' -# -# * indicates an argument (A) required. -# -# The '%' may optionally be followed by a number (C) in square brackets, which -# makes the engine walk down to N[C] before evaluating the escape code. -# - -from spark import GenericASTTraversal - -#TAB = '\t' # as God intended -TAB = ' ' *4 # is less spacy than "\t" - -TABLE_R = { - 'build_tuple2': ( '%C', (0,-1,', ') ), - 'POP_TOP': ( '%|%c\n', 0 ), - 'STORE_ATTR': ( '%c.%[1]{pattr}', 0), -# 'STORE_SUBSCR': ( '%c[%c]', 0, 1 ), - 'STORE_SLICE+0':( '%c[:]', 0 ), - 'STORE_SLICE+1':( '%c[%c:]', 0, 1 ), - 'STORE_SLICE+2':( '%c[:%c]', 0, 1 ), - 'STORE_SLICE+3':( '%c[%c:%c]', 0, 1, 2 ), - 'JUMP_ABSOLUTE':( '%|continue\n', ), - 'DELETE_SLICE+0':( '%|del %c[:]\n', 0 ), - 'DELETE_SLICE+1':( '%|del %c[%c:]\n', 0, 1 ), - 'DELETE_SLICE+2':( '%|del %c[:%c]\n', 0, 1 ), - 'DELETE_SLICE+3':( '%|del %c[%c:%c]\n', 0, 1, 2 ), - 'DELETE_ATTR': ( '%|del %c.%[-1]{pattr}\n', 0 ), - #'EXEC_STMT': ( '%|exec %c in %[1]C\n', 0, (0,sys.maxint,', ') ), - 'BINARY_SUBSCR':( '%c[%c]', 0, 1), # required for augmented assign - 'UNARY_POSITIVE':( '+%c', 0 ), - 'UNARY_NEGATIVE':( '-%c', 0 ), - 'UNARY_CONVERT':( '`%c`', 0 ), - 'UNARY_INVERT': ( '~%c', 0 ), - 'UNARY_NOT': ( '(not %c)', 0 ), - 'SLICE+0': ( '%c[:]', 0 ), - 'SLICE+1': ( '%c[%c:]', 0, 1 ), - 'SLICE+2': ( '%c[:%c]', 0, 1 ), - 'SLICE+3': ( '%c[%c:%c]', 0, 1, 2 ), -} -TABLE_R0 = { -# 'BUILD_LIST': ( '[%C]', (0,-1,', ') ), -# 'BUILD_TUPLE': ( '(%C)', (0,-1,', ') ), -# 'CALL_FUNCTION':( '%c(%C)', 0, (1,-1,', ') ), -} -TABLE_DIRECT = { - 'BINARY_ADD': ( '+' ,), - 'BINARY_SUBTRACT': ( '-' ,), - 'BINARY_MULTIPLY': ( '*' ,), - 'BINARY_DIVIDE': ( '/' ,), - 'BINARY_MODULO': ( '%%',), - 'BINARY_POWER': ( '**',), - 'BINARY_LSHIFT': ( '<<',), - 'BINARY_RSHIFT': ( '>>',), - 'BINARY_AND': ( '&' ,), - 'BINARY_OR': ( '|' ,), - 'BINARY_XOR': ( '^' ,), - 'INPLACE_ADD': ( '+=' ,), - 'INPLACE_SUBTRACT': ( '-=' ,), - 'INPLACE_MULTIPLY': ( '*=' ,), - 'INPLACE_DIVIDE': ( '/=' ,), - 'INPLACE_MODULO': ( '%%=',), - 'INPLACE_POWER': ( '**=',), - 'INPLACE_LSHIFT': ( '<<=',), - 'INPLACE_RSHIFT': ( '>>=',), - 'INPLACE_AND': ( '&=' ,), - 'INPLACE_OR': ( '|=' ,), - 'INPLACE_XOR': ( '^=' ,), - 'binary_expr': ( '(%c %c %c)', 0, -1, 1 ), - - 'IMPORT_FROM': ( '%{pattr}', ), - 'LOAD_ATTR': ( '.%{pattr}', ), - 'LOAD_FAST': ( '%{pattr}', ), - 'LOAD_NAME': ( '%{pattr}', ), - 'LOAD_GLOBAL': ( '%{pattr}', ), - 'LOAD_LOCALS': ( 'locals()', ), - #'LOAD_CONST': ( '%{pattr}', ), handled below - 'DELETE_FAST': ( '%|del %{pattr}\n', ), - 'DELETE_NAME': ( '%|del %{pattr}\n', ), - 'DELETE_GLOBAL':( '%|del %{pattr}\n', ), - 'delete_subscr':( '%|del %c[%c]\n', 0, 1,), - 'binary_subscr':( '%c[%c]', 0, 1), - 'store_subscr': ( '%c[%c]', 0, 1), - 'STORE_FAST': ( '%{pattr}', ), - 'STORE_NAME': ( '%{pattr}', ), - 'STORE_GLOBAL': ( '%{pattr}', ), - 'unpack': ( '(%C,)', (1, sys.maxint, ', ') ), - 'unpack_list': ( '[%C]', (1, sys.maxint, ', ') ), - - 'list_compr': ( '[ %c ]', 1), -# 'lc_for': ( ' for %c in %c', 3, 0 ), - 'lc_for_nest': ( ' for %c in %c%c', 3, 0, 4 ), - 'lc_if': ( ' if %c', 0 ), - 'lc_body': ( '%c', 1), - 'lc_body__': ( '', ), - - 'assign': ( '%|%c = %c\n', -1, 0 ), - 'augassign1': ( '%|%c %c %c\n', 0, 2, 1), - 'augassign2': ( '%|%c%c %c %c\n', 0, 2, -3, -4), - #'dup_topx': ('%c', 0), - 'designList': ( '%c = %c', 0, -1 ), - 'and': ( '(%c and %c)', 0, 3 ), - 'or': ( '(%c or %c)', 0, 3 ), - 'compare': ( '(%c %[-1]{pattr} %c)', 0, 1 ), - 'cmp_list': ('%c %c', 0, 1), - 'cmp_list1': ('%[3]{pattr} %c %c', 0, -2), - 'cmp_list2': ('%[1]{pattr} %c', 0), - 'classdef': ( '\n%|class %[0]{pattr[1:-1]}%c:\n%+%{build_class}%-', 1 ), - 'funcdef': ( '\n%|def %c\n', 0), - 'kwarg': ( '%[0]{pattr[1:-1]}=%c', 1), - 'importstmt': ( '%|import %[0]{pattr}\n', ), - 'importfrom': ( '%|from %[0]{pattr} import %c\n', 1 ), - 'importlist': ( '%C', (0, sys.maxint, ', ') ), - 'importstmt2': ( '%|import %c\n', 1), - 'importstar2': ( '%|from %[1]{pattr} import *\n', ), - 'importfrom2': ( '%|from %[1]{pattr} import %c\n', 2 ), - 'importlist2': ( '%C', (0, sys.maxint, ', ') ), - 'assert': ( '%|assert %c\n' , 3 ), - 'assert2': ( '%|assert %c, %c\n' , 3, -5 ), - - 'print_stmt': ( '%|print %c,\n', 0 ), - 'print_stmt_nl': ( '%|print %[0]C\n', (0,1, None) ), - 'print_nl_stmt': ( '%|print\n', ), - 'print_to': ( '%|print >> %c, %c,\n', 0, 1 ), - 'print_to_nl': ( '%|print >> %c, %c\n', 0, 1 ), - 'print_nl_to': ( '%|print >> %c\n', 0 ), - 'print_to_items': ( '%C', (0, 2, ', ') ), - - 'call_stmt': ( '%|%c\n', 0), - 'break_stmt': ( '%|break\n', ), - 'continue_stmt':( '%|continue\n', ), - 'raise_stmt': ( '%|raise %[0]C\n', (0,sys.maxint,', ') ), - 'return_stmt': ( '%|return %c\n', 0), - 'return_lambda': ( '%c', 0), - - 'ifstmt': ( '%|if %c:\n%+%c%-', 0, 2 ), - 'ifelsestmt': ( '%|if %c:\n%+%c%-%|else:\n%+%c%-', 0, 2, -2 ), - 'ifelifstmt': ( '%|if %c:\n%+%c%-%c', 0, 2, -2 ), - 'elifelifstmt': ( '%|elif %c:\n%+%c%-%c', 0, 2, -2 ), - 'elifstmt': ( '%|elif %c:\n%+%c%-', 0, 2 ), - 'elifelsestmt': ( '%|elif %c:\n%+%c%-%|else:\n%+%c%-', 0, 2, -2 ), - - 'whilestmt': ( '%|while %c:\n%+%c%-\n', 1, 4 ), - 'whileelsestmt':( '%|while %c:\n%+%c%-\n%|else:\n%+%c%-\n', 1, 4, 9 ), - 'forstmt': ( '%|for %c in %c:\n%+%c%-\n', 4, 1, 5 ), - 'forelsestmt': ( - '%|for %c in %c:\n%+%c%-\n%|else:\n%+%c%-\n', 4, 1, 5, 9 - ), - 'trystmt': ( '%|try:\n%+%c%-%c', 1, 5 ), - 'except': ( '%|except:\n%+%c%-', 3 ), - 'except_cond1': ( '%|except %c:\n%+%c%-', 1, 8 ), - 'except_cond2': ( '%|except %c, %c:\n%+%c%-', 1, 6, 8 ), - 'except_else': ( '%|else:\n%+%c%-', 2 ), - 'tryfinallystmt':( '%|try:\n%+%c%-\n%|finally:\n%+%c%-\n', 1, 5 ), - 'passstmt': ( '%|pass\n', ), - 'STORE_FAST': ( '%{pattr}', ), - 'kv': ( '%c: %c', 3, 1 ), - 'mapexpr': ( '{%[1]C}', (0,sys.maxint,', ') ), -} - - -MAP_DIRECT = (TABLE_DIRECT, ) -MAP_R0 = (TABLE_R0, -1, 0) -MAP_R = (TABLE_R, -1) - -MAP = { - 'stmt': MAP_R, - 'designator': MAP_R, - 'expr': MAP_R, - 'exprlist': MAP_R0, -} - - -ASSIGN_TUPLE_PARAM = lambda param_name: \ - AST('expr', [ Token('LOAD_FAST', pattr=param_name) ]) - - -def get_tuple_parameter(ast, name): - """ - If the name of the formal parameter starts with dot, - it's a tuple parameter, like this: - def MyFunc(xx, (a,b,c), yy): - print a, b*2, c*42 - In byte-code, the whole tuple is assigned to parameter '.1' and - then the tuple gets unpacked to 'a', 'b' and 'c'. - - Since identifiers starting with a dot are illegal in Python, - we can search for the byte-code equivalent to '(a,b,c) = .1' - """ - assert ast == 'code' and ast[0] == 'stmts' - for i in xrange(len(ast[0])): - # search for an assign-statement - assert ast[0][i] == 'stmt' - node = ast[0][i][0] - if node == 'assign' \ - and node[0] == ASSIGN_TUPLE_PARAM(name): - # okay, this assigns '.n' to something - del ast[0][i] - # walk lhs; this - # returns a tuple of identifiers as used - # within the function definition - assert node[1] == 'designator' - # if lhs is not a UNPACK_TUPLE (or equiv.), - # add parenteses to make this a tuple - if node[1][0] not in ('unpack', 'unpack_list'): - return '(' + walk(node[1]) + ')' - return walk(node[1]) - raise "Can't find tuple parameter" % name - -def make_function(self, code, defparams, isLambda, nested=1): - """Dump function defintion, doc string, and function body.""" - - def build_param(ast, name, default): - """build parameters: - - handle defaults - - handle format tuple parameters - """ - # if formal parameter is a tuple, the paramater name - # starts with a dot (eg. '.1', '.2') - if name[0] == '.': - # replace the name with the tuple-string - name = get_tuple_parameter(ast, name) - - if default: - if Showast: - print '--', name - print default - print '--' - result = '%s = %s' % ( name, walk(default, indent=0) ) - ##w = Walk(default, 0) - ##result = '%s = %s' % ( name, w.traverse() ) - ##del w # hg/2000-09-03 - if result[-2:] == '= ': # default was 'LOAD_CONST None' - result = result + 'None' - return result - else: - return name - - def writeParams(self, params): - for i in range(len(params)): - if i > 0: self.f.write(', ') - self.f.write(params[i]) - - assert type(code) == types.CodeType - code = Code(code) - #assert isinstance(code, Code) - - ast = _build_ast(self.f, code._tokens, code._customize) - code._tokens = None # save memory - assert ast == 'code' and ast[0] == 'stmts' - if isLambda: - # convert 'return' statement to expression - #assert len(ast[0]) == 1 wrong, see 'lambda (r,b): r,b,g' - assert ast[-1][-1] == 'stmt' - assert len(ast[-1][-1]) == 1 - assert ast[-1][-1][0] == 'return_stmt' - ast[-1][-1][0].type = 'return_lambda' - else: - if ast[0][-1] == RETURN_NONE: - # Python adds a 'return None' to the - # end of any function; remove it - ast[0].pop() # remove last node - - # add defaults values to parameter names - argc = code.co_argcount - paramnames = list(code.co_varnames[:argc]) - - # defaults are for last n parameters, thus reverse - paramnames.reverse(); defparams.reverse() - - # build parameters - # - ##This would be a nicer piece of code, but I can't get this to work - ## now, have to find a usable lambda constuct hG/2000-09-05 - ##params = map(lambda name, default: build_param(ast, name, default), - ## paramnames, defparams) - params = [] - for name, default in map(lambda a,b: (a,b), paramnames, defparams): - params.append( build_param(ast, name, default) ) - - params.reverse() # back to correct order - - if 4 & code.co_flags: # flag 2 -> variable number of args - params.append('*%s' % code.co_varnames[argc]) - argc = argc +1 - if 8 & code.co_flags: # flag 3 -> keyword args - params.append('**%s' % code.co_varnames[argc]) - argc = argc +1 - - # dump parameter list (with default values) - indent = TAB * self.indent - if isLambda: - self.f.write('lambda ') - writeParams(self, params) - self.f.write(': ') - else: - self.f.write('(') - writeParams(self, params) - self.f.write('):\n') - #self.f.write('%s#flags:\t%i\n' % (indent, code.co_flags)) - - if code.co_consts[0] != None: # docstring exists, dump it - self.f.writelines([indent, `code.co_consts[0]`, '\n']) - - _gen_source(self.f, ast, code._customize, self.indent, - isLambda=isLambda) - code._tokens = None; code._customize = None # save memory - - -def build_class(self, code): - """Dump class definition, duc string and class body.""" - - assert type(code) == types.CodeType - code = Code(code) - #assert isinstance(code, Code) - - indent = TAB * self.indent - #self.f.write('%s#flags:\t%i\n' % (indent, code.co_flags)) - ast = _build_ast(self.f, code._tokens, code._customize) - code._tokens = None # save memory - assert ast == 'code' and ast[0] == 'stmts' - - # if docstring exists, dump it - if code.co_consts[0] != None \ - and ast[0][0] == ASSIGN_DOC_STRING(code.co_consts[0]): - #print '\n\n>>-->>doc string set\n\n' - self.f.writelines( [indent,repr(code.co_consts[0]), '\n'] ) - del ast[0][0] - - # the function defining a class normally returns locals(); we - # don't want this to show up in the source, thus remove the node - if ast[0][-1] == RETURN_LOCALS: - ast[0].pop() # remove last node - - _gen_source(self.f, ast, code._customize, self.indent) - code._tokens = None; code._customize = None # save memory - -__globals_tokens__ = ('STORE_GLOBAL', 'DELETE_GLOBAL') # 'LOAD_GLOBAL' - -def find_globals(node, globals): - """Find globals in this statement.""" - for n in node: - if isinstance(n, AST): - if n != 'stmt': # skip nested statements - globals = find_globals(n, globals) - elif n.type in __globals_tokens__: - globals[n.pattr] = None - return globals - - -class Walk(GenericASTTraversal): - def __init__(self, ast, indent=0, isLambda=0): - GenericASTTraversal.__init__(self, ast) - self._globals = {} - self.f = cStringIO.StringIO() - self.f.seek(0) - self.indent = indent - self.isLambda = isLambda - - def __del__(self): - self.f.close() - - def traverse(self, node=None): - self.preorder(node) - return self.f.getvalue() - - def n_LOAD_CONST(self, node): - data = node.pattr - if data == 'None': - # LOAD_CONST 'None' only occurs, when None is - # implicit eg. in 'return' w/o params - pass - elif data == 'Ellipsis': - self.f.write('...') - elif data[0] == '-': # assume negative integer constant - # convert to hex, since decimal representation - # would result in 'LOAD_CONST; UNARY_NEGATIVE' - self.f.write('0x%x' % int(data)) - else: - self.f.write(data) - - def n_delete_subscr(self, node): - #print >>self.f, '>#', node - #print >>self.f, '---' - maybe_tuple = node[-2][-1] - #print >>self.f, '##', maybe_tuple, maybe_tuple.type[:11] - if maybe_tuple.type[:11] == 'BUILD_TUPLE': - maybe_tuple.type = 'build_tuple2' - #print >>self.f, '##', node - #print >>self.f, '##', maybe_tuple.type - self.default(node) - - n_store_subscr = n_binary_subscr = n_delete_subscr - - def __n_stmts(self, node): - # optimize "print 1, ; print" - last = None; i = 0 - while i < len(node): - n = node[i] - assert(n == 'stmt') - if n[0] == 'print_nl_stmt' and \ - last is not None and \ - last[0] == 'print_stmt': - last[0].type = 'print_stmt_nl' - del node[i] - last = None - else: - last = n - i = i + 1 - self.default(node) - - def n_stmt(self, node): - if not self.isLambda: - indent = TAB * self.indent - for g in find_globals(node, {}).keys(): - self.f.writelines( [indent, - 'global ', - g, '\n'] ) - ## nice output does not work since engine() - ## creates a new Walk instance when recursing - ## TODO: reconsider this: engine() no longer - ## creates a new Walk instancew hG/2000-12-31 - ## if not self._globals.has_key(g): - ## self._globals[g] = None - ## self.f.writelines( [TAB * self.indent, - ## 'global ', - ## g, '\n'] ) - self.default(node) - - def n_exec_stmt(self, node): - """ - exec_stmt ::= expr exprlist DUP_TOP EXEC_STMT - exec_stmt ::= expr exprlist EXEC_STMT - """ - w = Walk(node, indent=self.indent) - w.engine(( '%|exec %c in %[1]C', 0, (0,sys.maxint,', ') ), - node) - s = w.f.getvalue() - del w - if s[-3:] == 'in ': - s = s[:-3] - self.f.writelines( [s, '\n'] ) - node[:] = [] # avoid print out when recursive descenting - - def n_ifelsestmt(self, node, preprocess=0): - if len(node[-2]) == 1: - ifnode = node[-2][0][0] - if ifnode == 'ifelsestmt': - node.type = 'ifelifstmt' - self.n_ifelsestmt(ifnode, preprocess=1) - if ifnode == 'ifelifstmt': - ifnode.type = 'elifelifstmt' - elif ifnode == 'ifelsestmt': - ifnode.type = 'elifelsestmt' - elif ifnode == 'ifstmt': - node.type = 'ifelifstmt' - ifnode.type = 'elifstmt' - if not preprocess: - self.default(node) - - def n_import_as(self, node): - iname = node[0].pattr; sname = node[-1].pattr - if iname == sname \ - or iname[:len(sname)+1] == (sname+'.'): - self.f.write(iname) - else: - self.f.writelines([iname, ' as ', sname]) - node[:] = [] # avoid print out when recursive descenting - - def n_mkfunc(self, node): - defparams = node[0:-2] - code = node[-2].attr - node[:] = [] # avoid print out when recursive descenting - self.indent = self.indent + 1 - self.f.write(code.co_name) - make_function(self, code, defparams, isLambda=0) - self.indent = self.indent - 1 - - def n_mklambda(self, node): - defparams = node[0:-2] - code = node[-2].attr - node[:] = [] # avoid print out when recursive descenting - make_function(self, code, defparams, isLambda=1) - - def n_classdef(self, node): - self.f.writelines(['\n', TAB * self.indent, 'class ']) - self.f.write(node[0].pattr[1:-1]) - node._code = node[-4][0].attr - # avoid print out when recursive descenting - if node[1] == BUILD_TUPLE_0: - node[:] = [] - else: - node[:] = [ node[1] ] - - def n_classdef_exit(self, node): - self.f.write(':\n') - self.indent = self.indent +1 - # '\n%|class %[0]{pattr[1:-1]}%c:\n%+%{build_class}%-', 1 ), - # -4 -> MAKE_FUNCTION; -2 -> LOAD_CONST (code) - build_class(self,node._code) - self.indent = self.indent -1 - node._code = None # save memory - - def n_lc_for(self, node): - node.type = 'lc_for_nest' - content = node[4] - while content == 'lc_for': - content.type = 'lc_for_nest' - content = content[4] - while content == 'lc_if': - content = content[2] - assert content == 'lc_body' - self.preorder(content) - content.type = 'lc_body__' - self.default(node) - - def engine(self, entry, startnode): - #self.f.write("-----\n") - #self.f.write(str(startnode.__dict__)); self.f.write('\n') - escape = re.compile(r''' - % ( \[ (?P -? \d+ ) \] )? - ((?P [^{] ) | - ( [{] (?P [^}]* ) [}] )) - ''', re.VERBOSE) - - fmt = entry[0] - n = len(fmt) - lastC = 0 - arg = 1 - i = 0 - - while i < n: - m = escape.match(fmt, i) - if m is None: - self.f.write(fmt[i]) - i = i + 1 - continue - - i = m.end() - typ = m.group('type') or '{' - - node = startnode - try: - if m.group('child'): - node = node[string.atoi(m.group('child'))] - except: - print node.__dict__ - raise - - if typ == '%': - self.f.write('%') - elif typ == '+': - self.indent = self.indent + 1 - elif typ == '-': - self.indent = self.indent - 1 - elif typ == '|': - self.f.write(TAB * self.indent) - elif typ == ',': - if lastC == 1: - self.f.write(',') - elif typ == 'c': - self.traverse(node[entry[arg]]) - ##w = Walk(node[entry[arg]], self.indent) - ##self.f.write(w.traverse()) - ##del w # hg/2000-09-03 - arg = arg + 1 - elif typ == 'C': - low, high, sep = entry[arg] - lastC = remaining = len(node[low:high]) - for subnode in node[low:high]: - self.traverse(subnode) - ##w = Walk(subnode, self.indent) - ##self.f.write(w.traverse()) - ##del w # hg/2000-09-03 - remaining = remaining - 1 - if remaining > 0: - self.f.write(sep) - arg = arg + 1 - elif typ == '{': - d = node.__dict__ - expr = m.group('expr') - if expr == 'build_class': - # -4 -> MAKE_FUNCTION; -2 -> LOAD_CONST (code) - build_class(self,node[-4][-2].attr) - else: - try: - self.f.write(eval(expr, d, d)) - except: - print node - raise - - def default(self, node): - mapping = MAP.get(node, MAP_DIRECT) - table = mapping[0] - key = node - - for i in mapping[1:]: - key = key[i] - - if table.has_key(key): - self.engine(table[key], node) - self.prune() - -def walk(ast, customize={}, indent=0, isLambda=0): - w = Walk(ast, indent, isLambda=isLambda) - # - # Special handling for opcodes that take a variable number - # of arguments -- we add a new entry for each in TABLE_R. - # - for k, v in customize.items(): - op = k[:string.rfind(k, '_')] - if op == 'BUILD_LIST': - TABLE_R[k] = ( '[%C]', (0,-1,', ') ) - elif op == 'BUILD_SLICE': - TABLE_R[k] = ( '%C', (0,-1,':') ) - elif op == 'BUILD_TUPLE': - TABLE_R[k] = ( '(%C%,)', (0,-1,', ') ) - elif op == 'CALL_FUNCTION': - TABLE_R[k] = ( '%c(%C)', 0, (1,-1,', ') ) - elif op in ('CALL_FUNCTION_VAR', - 'CALL_FUNCTION_VAR_KW', 'CALL_FUNCTION_KW'): - if v == 0: - str = '%c(%C' # '%C' is a dummy here ... - p2 = (0, 0, None) # .. because of this - else: - str = '%c(%C, ' - p2 = (1,-2, ', ') - if op == 'CALL_FUNCTION_VAR': - str = str + '*%c)' - entry = (str, 0, p2, -2) - elif op == 'CALL_FUNCTION_KW': - str = str + '**%c)' - entry = (str, 0, p2, -2) - else: - str = str + '*%c, **%c)' - if p2[2]: p2 = (1,-3, ', ') - entry = (str, 0, p2, -3, -2) - TABLE_R[k] = entry - result = w.traverse() - return result - -#-- end of (de-)compiler --- - -#-- start - -Showasm = 0 -Showast = 0 -__real_out = None - -def _tokenize(out, co): - """Disassemble code object into a token list""" - assert type(co) == types.CodeType - - tokens, customize = disassemble(co) - # See the disassembly.. - if Showasm and out is not None: - for t in tokens: - out.write('%s\n' % t) - out.write('\n') - return tokens, customize - -def _build_ast(out, tokens, customize): - assert type(tokens) == types.ListType - assert isinstance(tokens[0], Token) - - # Build AST from disassembly. - try: - ast = parse(tokens, customize) - except: # parser failed, dump disassembly - #if not Showasm: - __real_out.write('--- This code section failed: ---\n') - for t in tokens: - __real_out.write('%s\n' % t) - __real_out.write('\n') - raise - return ast - -def _gen_source(out, ast, customize, indent=0, isLambda=0): - """convert AST to source code""" - if Showast: - out.write(`ast`) - - # if code would be empty, append 'pass' - if len(ast[0]) == 0: - out.write(indent * TAB) - out.write('pass\n') - else: - out.write(walk(ast, customize, indent, isLambda=isLambda)) - - -def decompyle(co, out=None, indent=0, showasm=0, showast=0): - """ - diassembles a given code block 'co' - """ - assert type(co) == types.CodeType - - global Showasm, Showast - Showasm = showasm - Showast = showast - - if not out: - out = sys.stdout - global __real_out - __real_out = out # store final output stream for case of error - - tokens, customize = _tokenize(out, co) - ast = _build_ast(out, tokens, customize) - tokens = None # save memory - - assert ast == 'code' and ast[0] == 'stmts' - # convert leading '__doc__ = "..." into doc string - if ast[0][0] == ASSIGN_DOC_STRING(co.co_consts[0]): - out.writelines( [repr(co.co_consts[0]), '\n'] ) - del ast[0][0] - if ast[0][-1] == RETURN_NONE: - ast[0].pop() # remove last node - #todo: if empty, add 'pass' - - _gen_source(out, ast, customize, indent) - - -def decompyle_file(filename, outstream=None, showasm=0, showast=0): - """ - decompile Python byte-code file (.pyc) - """ - co = _load_module(filename) - decompyle(co, out=outstream, showasm=showasm, showast=showast) - co = None diff --git a/Scripts/ServerPython/python/system/difflib.py b/Scripts/ServerPython/python/system/difflib.py deleted file mode 100644 index 01dc2037..00000000 --- a/Scripts/ServerPython/python/system/difflib.py +++ /dev/null @@ -1,1083 +0,0 @@ -#! /usr/bin/env python - -from __future__ import generators - -""" -Module difflib -- helpers for computing deltas between objects. - -Function get_close_matches(word, possibilities, n=3, cutoff=0.6): - Use SequenceMatcher to return list of the best "good enough" matches. - -Function ndiff(a, b): - Return a delta: the difference between `a` and `b` (lists of strings). - -Function restore(delta, which): - Return one of the two sequences that generated an ndiff delta. - -Class SequenceMatcher: - A flexible class for comparing pairs of sequences of any type. - -Class Differ: - For producing human-readable deltas from sequences of lines of text. -""" - -__all__ = ['get_close_matches', 'ndiff', 'restore', 'SequenceMatcher', - 'Differ'] - -class SequenceMatcher: - - """ - SequenceMatcher is a flexible class for comparing pairs of sequences of - any type, so long as the sequence elements are hashable. The basic - algorithm predates, and is a little fancier than, an algorithm - published in the late 1980's by Ratcliff and Obershelp under the - hyperbolic name "gestalt pattern matching". The basic idea is to find - the longest contiguous matching subsequence that contains no "junk" - elements (R-O doesn't address junk). The same idea is then applied - recursively to the pieces of the sequences to the left and to the right - of the matching subsequence. This does not yield minimal edit - sequences, but does tend to yield matches that "look right" to people. - - SequenceMatcher tries to compute a "human-friendly diff" between two - sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the - longest *contiguous* & junk-free matching subsequence. That's what - catches peoples' eyes. The Windows(tm) windiff has another interesting - notion, pairing up elements that appear uniquely in each sequence. - That, and the method here, appear to yield more intuitive difference - reports than does diff. This method appears to be the least vulnerable - to synching up on blocks of "junk lines", though (like blank lines in - ordinary text files, or maybe "

    " lines in HTML files). That may be - because this is the only method of the 3 that has a *concept* of - "junk" . - - Example, comparing two strings, and considering blanks to be "junk": - - >>> s = SequenceMatcher(lambda x: x == " ", - ... "private Thread currentThread;", - ... "private volatile Thread currentThread;") - >>> - - .ratio() returns a float in [0, 1], measuring the "similarity" of the - sequences. As a rule of thumb, a .ratio() value over 0.6 means the - sequences are close matches: - - >>> print round(s.ratio(), 3) - 0.866 - >>> - - If you're only interested in where the sequences match, - .get_matching_blocks() is handy: - - >>> for block in s.get_matching_blocks(): - ... print "a[%d] and b[%d] match for %d elements" % block - a[0] and b[0] match for 8 elements - a[8] and b[17] match for 6 elements - a[14] and b[23] match for 15 elements - a[29] and b[38] match for 0 elements - - Note that the last tuple returned by .get_matching_blocks() is always a - dummy, (len(a), len(b), 0), and this is the only case in which the last - tuple element (number of elements matched) is 0. - - If you want to know how to change the first sequence into the second, - use .get_opcodes(): - - >>> for opcode in s.get_opcodes(): - ... print "%6s a[%d:%d] b[%d:%d]" % opcode - equal a[0:8] b[0:8] - insert a[8:8] b[8:17] - equal a[8:14] b[17:23] - equal a[14:29] b[23:38] - - See the Differ class for a fancy human-friendly file differencer, which - uses SequenceMatcher both to compare sequences of lines, and to compare - sequences of characters within similar (near-matching) lines. - - See also function get_close_matches() in this module, which shows how - simple code building on SequenceMatcher can be used to do useful work. - - Timing: Basic R-O is cubic time worst case and quadratic time expected - case. SequenceMatcher is quadratic time for the worst case and has - expected-case behavior dependent in a complicated way on how many - elements the sequences have in common; best case time is linear. - - Methods: - - __init__(isjunk=None, a='', b='') - Construct a SequenceMatcher. - - set_seqs(a, b) - Set the two sequences to be compared. - - set_seq1(a) - Set the first sequence to be compared. - - set_seq2(b) - Set the second sequence to be compared. - - find_longest_match(alo, ahi, blo, bhi) - Find longest matching block in a[alo:ahi] and b[blo:bhi]. - - get_matching_blocks() - Return list of triples describing matching subsequences. - - get_opcodes() - Return list of 5-tuples describing how to turn a into b. - - ratio() - Return a measure of the sequences' similarity (float in [0,1]). - - quick_ratio() - Return an upper bound on .ratio() relatively quickly. - - real_quick_ratio() - Return an upper bound on ratio() very quickly. - """ - - def __init__(self, isjunk=None, a='', b=''): - """Construct a SequenceMatcher. - - Optional arg isjunk is None (the default), or a one-argument - function that takes a sequence element and returns true iff the - element is junk. None is equivalent to passing "lambda x: 0", i.e. - no elements are considered to be junk. For example, pass - lambda x: x in " \\t" - if you're comparing lines as sequences of characters, and don't - want to synch up on blanks or hard tabs. - - Optional arg a is the first of two sequences to be compared. By - default, an empty string. The elements of a must be hashable. See - also .set_seqs() and .set_seq1(). - - Optional arg b is the second of two sequences to be compared. By - default, an empty string. The elements of b must be hashable. See - also .set_seqs() and .set_seq2(). - """ - - # Members: - # a - # first sequence - # b - # second sequence; differences are computed as "what do - # we need to do to 'a' to change it into 'b'?" - # b2j - # for x in b, b2j[x] is a list of the indices (into b) - # at which x appears; junk elements do not appear - # b2jhas - # b2j.has_key - # fullbcount - # for x in b, fullbcount[x] == the number of times x - # appears in b; only materialized if really needed (used - # only for computing quick_ratio()) - # matching_blocks - # a list of (i, j, k) triples, where a[i:i+k] == b[j:j+k]; - # ascending & non-overlapping in i and in j; terminated by - # a dummy (len(a), len(b), 0) sentinel - # opcodes - # a list of (tag, i1, i2, j1, j2) tuples, where tag is - # one of - # 'replace' a[i1:i2] should be replaced by b[j1:j2] - # 'delete' a[i1:i2] should be deleted - # 'insert' b[j1:j2] should be inserted - # 'equal' a[i1:i2] == b[j1:j2] - # isjunk - # a user-supplied function taking a sequence element and - # returning true iff the element is "junk" -- this has - # subtle but helpful effects on the algorithm, which I'll - # get around to writing up someday <0.9 wink>. - # DON'T USE! Only __chain_b uses this. Use isbjunk. - # isbjunk - # for x in b, isbjunk(x) == isjunk(x) but much faster; - # it's really the has_key method of a hidden dict. - # DOES NOT WORK for x in a! - - self.isjunk = isjunk - self.a = self.b = None - self.set_seqs(a, b) - - def set_seqs(self, a, b): - """Set the two sequences to be compared. - - >>> s = SequenceMatcher() - >>> s.set_seqs("abcd", "bcde") - >>> s.ratio() - 0.75 - """ - - self.set_seq1(a) - self.set_seq2(b) - - def set_seq1(self, a): - """Set the first sequence to be compared. - - The second sequence to be compared is not changed. - - >>> s = SequenceMatcher(None, "abcd", "bcde") - >>> s.ratio() - 0.75 - >>> s.set_seq1("bcde") - >>> s.ratio() - 1.0 - >>> - - SequenceMatcher computes and caches detailed information about the - second sequence, so if you want to compare one sequence S against - many sequences, use .set_seq2(S) once and call .set_seq1(x) - repeatedly for each of the other sequences. - - See also set_seqs() and set_seq2(). - """ - - if a is self.a: - return - self.a = a - self.matching_blocks = self.opcodes = None - - def set_seq2(self, b): - """Set the second sequence to be compared. - - The first sequence to be compared is not changed. - - >>> s = SequenceMatcher(None, "abcd", "bcde") - >>> s.ratio() - 0.75 - >>> s.set_seq2("abcd") - >>> s.ratio() - 1.0 - >>> - - SequenceMatcher computes and caches detailed information about the - second sequence, so if you want to compare one sequence S against - many sequences, use .set_seq2(S) once and call .set_seq1(x) - repeatedly for each of the other sequences. - - See also set_seqs() and set_seq1(). - """ - - if b is self.b: - return - self.b = b - self.matching_blocks = self.opcodes = None - self.fullbcount = None - self.__chain_b() - - # For each element x in b, set b2j[x] to a list of the indices in - # b where x appears; the indices are in increasing order; note that - # the number of times x appears in b is len(b2j[x]) ... - # when self.isjunk is defined, junk elements don't show up in this - # map at all, which stops the central find_longest_match method - # from starting any matching block at a junk element ... - # also creates the fast isbjunk function ... - # note that this is only called when b changes; so for cross-product - # kinds of matches, it's best to call set_seq2 once, then set_seq1 - # repeatedly - - def __chain_b(self): - # Because isjunk is a user-defined (not C) function, and we test - # for junk a LOT, it's important to minimize the number of calls. - # Before the tricks described here, __chain_b was by far the most - # time-consuming routine in the whole module! If anyone sees - # Jim Roskind, thank him again for profile.py -- I never would - # have guessed that. - # The first trick is to build b2j ignoring the possibility - # of junk. I.e., we don't call isjunk at all yet. Throwing - # out the junk later is much cheaper than building b2j "right" - # from the start. - b = self.b - self.b2j = b2j = {} - self.b2jhas = b2jhas = b2j.has_key - for i in xrange(len(b)): - elt = b[i] - if b2jhas(elt): - b2j[elt].append(i) - else: - b2j[elt] = [i] - - # Now b2j.keys() contains elements uniquely, and especially when - # the sequence is a string, that's usually a good deal smaller - # than len(string). The difference is the number of isjunk calls - # saved. - isjunk, junkdict = self.isjunk, {} - if isjunk: - for elt in b2j.keys(): - if isjunk(elt): - junkdict[elt] = 1 # value irrelevant; it's a set - del b2j[elt] - - # Now for x in b, isjunk(x) == junkdict.has_key(x), but the - # latter is much faster. Note too that while there may be a - # lot of junk in the sequence, the number of *unique* junk - # elements is probably small. So the memory burden of keeping - # this dict alive is likely trivial compared to the size of b2j. - self.isbjunk = junkdict.has_key - - def find_longest_match(self, alo, ahi, blo, bhi): - """Find longest matching block in a[alo:ahi] and b[blo:bhi]. - - If isjunk is not defined: - - Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where - alo <= i <= i+k <= ahi - blo <= j <= j+k <= bhi - and for all (i',j',k') meeting those conditions, - k >= k' - i <= i' - and if i == i', j <= j' - - In other words, of all maximal matching blocks, return one that - starts earliest in a, and of all those maximal matching blocks that - start earliest in a, return the one that starts earliest in b. - - >>> s = SequenceMatcher(None, " abcd", "abcd abcd") - >>> s.find_longest_match(0, 5, 0, 9) - (0, 4, 5) - - If isjunk is defined, first the longest matching block is - determined as above, but with the additional restriction that no - junk element appears in the block. Then that block is extended as - far as possible by matching (only) junk elements on both sides. So - the resulting block never matches on junk except as identical junk - happens to be adjacent to an "interesting" match. - - Here's the same example as before, but considering blanks to be - junk. That prevents " abcd" from matching the " abcd" at the tail - end of the second sequence directly. Instead only the "abcd" can - match, and matches the leftmost "abcd" in the second sequence: - - >>> s = SequenceMatcher(lambda x: x==" ", " abcd", "abcd abcd") - >>> s.find_longest_match(0, 5, 0, 9) - (1, 0, 4) - - If no blocks match, return (alo, blo, 0). - - >>> s = SequenceMatcher(None, "ab", "c") - >>> s.find_longest_match(0, 2, 0, 1) - (0, 0, 0) - """ - - # CAUTION: stripping common prefix or suffix would be incorrect. - # E.g., - # ab - # acab - # Longest matching block is "ab", but if common prefix is - # stripped, it's "a" (tied with "b"). UNIX(tm) diff does so - # strip, so ends up claiming that ab is changed to acab by - # inserting "ca" in the middle. That's minimal but unintuitive: - # "it's obvious" that someone inserted "ac" at the front. - # Windiff ends up at the same place as diff, but by pairing up - # the unique 'b's and then matching the first two 'a's. - - a, b, b2j, isbjunk = self.a, self.b, self.b2j, self.isbjunk - besti, bestj, bestsize = alo, blo, 0 - # find longest junk-free match - # during an iteration of the loop, j2len[j] = length of longest - # junk-free match ending with a[i-1] and b[j] - j2len = {} - nothing = [] - for i in xrange(alo, ahi): - # look at all instances of a[i] in b; note that because - # b2j has no junk keys, the loop is skipped if a[i] is junk - j2lenget = j2len.get - newj2len = {} - for j in b2j.get(a[i], nothing): - # a[i] matches b[j] - if j < blo: - continue - if j >= bhi: - break - k = newj2len[j] = j2lenget(j-1, 0) + 1 - if k > bestsize: - besti, bestj, bestsize = i-k+1, j-k+1, k - j2len = newj2len - - # Now that we have a wholly interesting match (albeit possibly - # empty!), we may as well suck up the matching junk on each - # side of it too. Can't think of a good reason not to, and it - # saves post-processing the (possibly considerable) expense of - # figuring out what to do with it. In the case of an empty - # interesting match, this is clearly the right thing to do, - # because no other kind of match is possible in the regions. - while besti > alo and bestj > blo and \ - isbjunk(b[bestj-1]) and \ - a[besti-1] == b[bestj-1]: - besti, bestj, bestsize = besti-1, bestj-1, bestsize+1 - while besti+bestsize < ahi and bestj+bestsize < bhi and \ - isbjunk(b[bestj+bestsize]) and \ - a[besti+bestsize] == b[bestj+bestsize]: - bestsize = bestsize + 1 - - return besti, bestj, bestsize - - def get_matching_blocks(self): - """Return list of triples describing matching subsequences. - - Each triple is of the form (i, j, n), and means that - a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in - i and in j. - - The last triple is a dummy, (len(a), len(b), 0), and is the only - triple with n==0. - - >>> s = SequenceMatcher(None, "abxcd", "abcd") - >>> s.get_matching_blocks() - [(0, 0, 2), (3, 2, 2), (5, 4, 0)] - """ - - if self.matching_blocks is not None: - return self.matching_blocks - self.matching_blocks = [] - la, lb = len(self.a), len(self.b) - self.__helper(0, la, 0, lb, self.matching_blocks) - self.matching_blocks.append( (la, lb, 0) ) - return self.matching_blocks - - # builds list of matching blocks covering a[alo:ahi] and - # b[blo:bhi], appending them in increasing order to answer - - def __helper(self, alo, ahi, blo, bhi, answer): - i, j, k = x = self.find_longest_match(alo, ahi, blo, bhi) - # a[alo:i] vs b[blo:j] unknown - # a[i:i+k] same as b[j:j+k] - # a[i+k:ahi] vs b[j+k:bhi] unknown - if k: - if alo < i and blo < j: - self.__helper(alo, i, blo, j, answer) - answer.append(x) - if i+k < ahi and j+k < bhi: - self.__helper(i+k, ahi, j+k, bhi, answer) - - def get_opcodes(self): - """Return list of 5-tuples describing how to turn a into b. - - Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple - has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the - tuple preceding it, and likewise for j1 == the previous j2. - - The tags are strings, with these meanings: - - 'replace': a[i1:i2] should be replaced by b[j1:j2] - 'delete': a[i1:i2] should be deleted. - Note that j1==j2 in this case. - 'insert': b[j1:j2] should be inserted at a[i1:i1]. - Note that i1==i2 in this case. - 'equal': a[i1:i2] == b[j1:j2] - - >>> a = "qabxcd" - >>> b = "abycdf" - >>> s = SequenceMatcher(None, a, b) - >>> for tag, i1, i2, j1, j2 in s.get_opcodes(): - ... print ("%7s a[%d:%d] (%s) b[%d:%d] (%s)" % - ... (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2])) - delete a[0:1] (q) b[0:0] () - equal a[1:3] (ab) b[0:2] (ab) - replace a[3:4] (x) b[2:3] (y) - equal a[4:6] (cd) b[3:5] (cd) - insert a[6:6] () b[5:6] (f) - """ - - if self.opcodes is not None: - return self.opcodes - i = j = 0 - self.opcodes = answer = [] - for ai, bj, size in self.get_matching_blocks(): - # invariant: we've pumped out correct diffs to change - # a[:i] into b[:j], and the next matching block is - # a[ai:ai+size] == b[bj:bj+size]. So we need to pump - # out a diff to change a[i:ai] into b[j:bj], pump out - # the matching block, and move (i,j) beyond the match - tag = '' - if i < ai and j < bj: - tag = 'replace' - elif i < ai: - tag = 'delete' - elif j < bj: - tag = 'insert' - if tag: - answer.append( (tag, i, ai, j, bj) ) - i, j = ai+size, bj+size - # the list of matching blocks is terminated by a - # sentinel with size 0 - if size: - answer.append( ('equal', ai, i, bj, j) ) - return answer - - def ratio(self): - """Return a measure of the sequences' similarity (float in [0,1]). - - Where T is the total number of elements in both sequences, and - M is the number of matches, this is 2,0*M / T. - Note that this is 1 if the sequences are identical, and 0 if - they have nothing in common. - - .ratio() is expensive to compute if you haven't already computed - .get_matching_blocks() or .get_opcodes(), in which case you may - want to try .quick_ratio() or .real_quick_ratio() first to get an - upper bound. - - >>> s = SequenceMatcher(None, "abcd", "bcde") - >>> s.ratio() - 0.75 - >>> s.quick_ratio() - 0.75 - >>> s.real_quick_ratio() - 1.0 - """ - - matches = reduce(lambda sum, triple: sum + triple[-1], - self.get_matching_blocks(), 0) - return 2.0 * matches / (len(self.a) + len(self.b)) - - def quick_ratio(self): - """Return an upper bound on ratio() relatively quickly. - - This isn't defined beyond that it is an upper bound on .ratio(), and - is faster to compute. - """ - - # viewing a and b as multisets, set matches to the cardinality - # of their intersection; this counts the number of matches - # without regard to order, so is clearly an upper bound - if self.fullbcount is None: - self.fullbcount = fullbcount = {} - for elt in self.b: - fullbcount[elt] = fullbcount.get(elt, 0) + 1 - fullbcount = self.fullbcount - # avail[x] is the number of times x appears in 'b' less the - # number of times we've seen it in 'a' so far ... kinda - avail = {} - availhas, matches = avail.has_key, 0 - for elt in self.a: - if availhas(elt): - numb = avail[elt] - else: - numb = fullbcount.get(elt, 0) - avail[elt] = numb - 1 - if numb > 0: - matches = matches + 1 - return 2.0 * matches / (len(self.a) + len(self.b)) - - def real_quick_ratio(self): - """Return an upper bound on ratio() very quickly. - - This isn't defined beyond that it is an upper bound on .ratio(), and - is faster to compute than either .ratio() or .quick_ratio(). - """ - - la, lb = len(self.a), len(self.b) - # can't have more matches than the number of elements in the - # shorter sequence - return 2.0 * min(la, lb) / (la + lb) - -def get_close_matches(word, possibilities, n=3, cutoff=0.6): - """Use SequenceMatcher to return list of the best "good enough" matches. - - word is a sequence for which close matches are desired (typically a - string). - - possibilities is a list of sequences against which to match word - (typically a list of strings). - - Optional arg n (default 3) is the maximum number of close matches to - return. n must be > 0. - - Optional arg cutoff (default 0.6) is a float in [0, 1]. Possibilities - that don't score at least that similar to word are ignored. - - The best (no more than n) matches among the possibilities are returned - in a list, sorted by similarity score, most similar first. - - >>> get_close_matches("appel", ["ape", "apple", "peach", "puppy"]) - ['apple', 'ape'] - >>> import keyword as _keyword - >>> get_close_matches("wheel", _keyword.kwlist) - ['while'] - >>> get_close_matches("apple", _keyword.kwlist) - [] - >>> get_close_matches("accept", _keyword.kwlist) - ['except'] - """ - - if not n > 0: - raise ValueError("n must be > 0: " + `n`) - if not 0.0 <= cutoff <= 1.0: - raise ValueError("cutoff must be in [0.0, 1.0]: " + `cutoff`) - result = [] - s = SequenceMatcher() - s.set_seq2(word) - for x in possibilities: - s.set_seq1(x) - if s.real_quick_ratio() >= cutoff and \ - s.quick_ratio() >= cutoff and \ - s.ratio() >= cutoff: - result.append((s.ratio(), x)) - # Sort by score. - result.sort() - # Retain only the best n. - result = result[-n:] - # Move best-scorer to head of list. - result.reverse() - # Strip scores. - return [x for score, x in result] - - -def _count_leading(line, ch): - """ - Return number of `ch` characters at the start of `line`. - - Example: - - >>> _count_leading(' abc', ' ') - 3 - """ - - i, n = 0, len(line) - while i < n and line[i] == ch: - i += 1 - return i - -class Differ: - r""" - Differ is a class for comparing sequences of lines of text, and - producing human-readable differences or deltas. Differ uses - SequenceMatcher both to compare sequences of lines, and to compare - sequences of characters within similar (near-matching) lines. - - Each line of a Differ delta begins with a two-letter code: - - '- ' line unique to sequence 1 - '+ ' line unique to sequence 2 - ' ' line common to both sequences - '? ' line not present in either input sequence - - Lines beginning with '? ' attempt to guide the eye to intraline - differences, and were not present in either input sequence. These lines - can be confusing if the sequences contain tab characters. - - Note that Differ makes no claim to produce a *minimal* diff. To the - contrary, minimal diffs are often counter-intuitive, because they synch - up anywhere possible, sometimes accidental matches 100 pages apart. - Restricting synch points to contiguous matches preserves some notion of - locality, at the occasional cost of producing a longer diff. - - Example: Comparing two texts. - - First we set up the texts, sequences of individual single-line strings - ending with newlines (such sequences can also be obtained from the - `readlines()` method of file-like objects): - - >>> text1 = ''' 1. Beautiful is better than ugly. - ... 2. Explicit is better than implicit. - ... 3. Simple is better than complex. - ... 4. Complex is better than complicated. - ... '''.splitlines(1) - >>> len(text1) - 4 - >>> text1[0][-1] - '\n' - >>> text2 = ''' 1. Beautiful is better than ugly. - ... 3. Simple is better than complex. - ... 4. Complicated is better than complex. - ... 5. Flat is better than nested. - ... '''.splitlines(1) - - Next we instantiate a Differ object: - - >>> d = Differ() - - Note that when instantiating a Differ object we may pass functions to - filter out line and character 'junk'. See Differ.__init__ for details. - - Finally, we compare the two: - - >>> result = list(d.compare(text1, text2)) - - 'result' is a list of strings, so let's pretty-print it: - - >>> from pprint import pprint as _pprint - >>> _pprint(result) - [' 1. Beautiful is better than ugly.\n', - '- 2. Explicit is better than implicit.\n', - '- 3. Simple is better than complex.\n', - '+ 3. Simple is better than complex.\n', - '? ++\n', - '- 4. Complex is better than complicated.\n', - '? ^ ---- ^\n', - '+ 4. Complicated is better than complex.\n', - '? ++++ ^ ^\n', - '+ 5. Flat is better than nested.\n'] - - As a single multi-line string it looks like this: - - >>> print ''.join(result), - 1. Beautiful is better than ugly. - - 2. Explicit is better than implicit. - - 3. Simple is better than complex. - + 3. Simple is better than complex. - ? ++ - - 4. Complex is better than complicated. - ? ^ ---- ^ - + 4. Complicated is better than complex. - ? ++++ ^ ^ - + 5. Flat is better than nested. - - Methods: - - __init__(linejunk=None, charjunk=None) - Construct a text differencer, with optional filters. - - compare(a, b) - Compare two sequences of lines; generate the resulting delta. - """ - - def __init__(self, linejunk=None, charjunk=None): - """ - Construct a text differencer, with optional filters. - - The two optional keyword parameters are for filter functions: - - - `linejunk`: A function that should accept a single string argument, - and return true iff the string is junk. The module-level function - `IS_LINE_JUNK` may be used to filter out lines without visible - characters, except for at most one splat ('#'). - - - `charjunk`: A function that should accept a string of length 1. The - module-level function `IS_CHARACTER_JUNK` may be used to filter out - whitespace characters (a blank or tab; **note**: bad idea to include - newline in this!). - """ - - self.linejunk = linejunk - self.charjunk = charjunk - - def compare(self, a, b): - r""" - Compare two sequences of lines; generate the resulting delta. - - Each sequence must contain individual single-line strings ending with - newlines. Such sequences can be obtained from the `readlines()` method - of file-like objects. The delta generated also consists of newline- - terminated strings, ready to be printed as-is via the writeline() - method of a file-like object. - - Example: - - >>> print ''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(1), - ... 'ore\ntree\nemu\n'.splitlines(1))), - - one - ? ^ - + ore - ? ^ - - two - - three - ? - - + tree - + emu - """ - - cruncher = SequenceMatcher(self.linejunk, a, b) - for tag, alo, ahi, blo, bhi in cruncher.get_opcodes(): - if tag == 'replace': - g = self._fancy_replace(a, alo, ahi, b, blo, bhi) - elif tag == 'delete': - g = self._dump('-', a, alo, ahi) - elif tag == 'insert': - g = self._dump('+', b, blo, bhi) - elif tag == 'equal': - g = self._dump(' ', a, alo, ahi) - else: - raise ValueError, 'unknown tag ' + `tag` - - for line in g: - yield line - - def _dump(self, tag, x, lo, hi): - """Generate comparison results for a same-tagged range.""" - for i in xrange(lo, hi): - yield '%s %s' % (tag, x[i]) - - def _plain_replace(self, a, alo, ahi, b, blo, bhi): - assert alo < ahi and blo < bhi - # dump the shorter block first -- reduces the burden on short-term - # memory if the blocks are of very different sizes - if bhi - blo < ahi - alo: - first = self._dump('+', b, blo, bhi) - second = self._dump('-', a, alo, ahi) - else: - first = self._dump('-', a, alo, ahi) - second = self._dump('+', b, blo, bhi) - - for g in first, second: - for line in g: - yield line - - def _fancy_replace(self, a, alo, ahi, b, blo, bhi): - r""" - When replacing one block of lines with another, search the blocks - for *similar* lines; the best-matching pair (if any) is used as a - synch point, and intraline difference marking is done on the - similar pair. Lots of work, but often worth it. - - Example: - - >>> d = Differ() - >>> d._fancy_replace(['abcDefghiJkl\n'], 0, 1, ['abcdefGhijkl\n'], 0, 1) - >>> print ''.join(d.results), - - abcDefghiJkl - ? ^ ^ ^ - + abcdefGhijkl - ? ^ ^ ^ - """ - - # don't synch up unless the lines have a similarity score of at - # least cutoff; best_ratio tracks the best score seen so far - best_ratio, cutoff = 0.74, 0.75 - cruncher = SequenceMatcher(self.charjunk) - eqi, eqj = None, None # 1st indices of equal lines (if any) - - # search for the pair that matches best without being identical - # (identical lines must be junk lines, & we don't want to synch up - # on junk -- unless we have to) - for j in xrange(blo, bhi): - bj = b[j] - cruncher.set_seq2(bj) - for i in xrange(alo, ahi): - ai = a[i] - if ai == bj: - if eqi is None: - eqi, eqj = i, j - continue - cruncher.set_seq1(ai) - # computing similarity is expensive, so use the quick - # upper bounds first -- have seen this speed up messy - # compares by a factor of 3. - # note that ratio() is only expensive to compute the first - # time it's called on a sequence pair; the expensive part - # of the computation is cached by cruncher - if cruncher.real_quick_ratio() > best_ratio and \ - cruncher.quick_ratio() > best_ratio and \ - cruncher.ratio() > best_ratio: - best_ratio, best_i, best_j = cruncher.ratio(), i, j - if best_ratio < cutoff: - # no non-identical "pretty close" pair - if eqi is None: - # no identical pair either -- treat it as a straight replace - for line in self._plain_replace(a, alo, ahi, b, blo, bhi): - yield line - return - # no close pair, but an identical pair -- synch up on that - best_i, best_j, best_ratio = eqi, eqj, 1.0 - else: - # there's a close pair, so forget the identical pair (if any) - eqi = None - - # a[best_i] very similar to b[best_j]; eqi is None iff they're not - # identical - - # pump out diffs from before the synch point - for line in self._fancy_helper(a, alo, best_i, b, blo, best_j): - yield line - - # do intraline marking on the synch pair - aelt, belt = a[best_i], b[best_j] - if eqi is None: - # pump out a '-', '?', '+', '?' quad for the synched lines - atags = btags = "" - cruncher.set_seqs(aelt, belt) - for tag, ai1, ai2, bj1, bj2 in cruncher.get_opcodes(): - la, lb = ai2 - ai1, bj2 - bj1 - if tag == 'replace': - atags += '^' * la - btags += '^' * lb - elif tag == 'delete': - atags += '-' * la - elif tag == 'insert': - btags += '+' * lb - elif tag == 'equal': - atags += ' ' * la - btags += ' ' * lb - else: - raise ValueError, 'unknown tag ' + `tag` - for line in self._qformat(aelt, belt, atags, btags): - yield line - else: - # the synch pair is identical - yield ' ' + aelt - - # pump out diffs from after the synch point - for line in self._fancy_helper(a, best_i+1, ahi, b, best_j+1, bhi): - yield line - - def _fancy_helper(self, a, alo, ahi, b, blo, bhi): - g = [] - if alo < ahi: - if blo < bhi: - g = self._fancy_replace(a, alo, ahi, b, blo, bhi) - else: - g = self._dump('-', a, alo, ahi) - elif blo < bhi: - g = self._dump('+', b, blo, bhi) - - for line in g: - yield line - - def _qformat(self, aline, bline, atags, btags): - r""" - Format "?" output and deal with leading tabs. - - Example: - - >>> d = Differ() - >>> d._qformat('\tabcDefghiJkl\n', '\t\tabcdefGhijkl\n', - ... ' ^ ^ ^ ', '+ ^ ^ ^ ') - >>> for line in d.results: print repr(line) - ... - '- \tabcDefghiJkl\n' - '? \t ^ ^ ^\n' - '+ \t\tabcdefGhijkl\n' - '? \t ^ ^ ^\n' - """ - - # Can hurt, but will probably help most of the time. - common = min(_count_leading(aline, "\t"), - _count_leading(bline, "\t")) - common = min(common, _count_leading(atags[:common], " ")) - atags = atags[common:].rstrip() - btags = btags[common:].rstrip() - - yield "- " + aline - if atags: - yield "? %s%s\n" % ("\t" * common, atags) - - yield "+ " + bline - if btags: - yield "? %s%s\n" % ("\t" * common, btags) - -# With respect to junk, an earlier version of ndiff simply refused to -# *start* a match with a junk element. The result was cases like this: -# before: private Thread currentThread; -# after: private volatile Thread currentThread; -# If you consider whitespace to be junk, the longest contiguous match -# not starting with junk is "e Thread currentThread". So ndiff reported -# that "e volatil" was inserted between the 't' and the 'e' in "private". -# While an accurate view, to people that's absurd. The current version -# looks for matching blocks that are entirely junk-free, then extends the -# longest one of those as far as possible but only with matching junk. -# So now "currentThread" is matched, then extended to suck up the -# preceding blank; then "private" is matched, and extended to suck up the -# following blank; then "Thread" is matched; and finally ndiff reports -# that "volatile " was inserted before "Thread". The only quibble -# remaining is that perhaps it was really the case that " volatile" -# was inserted after "private". I can live with that . - -import re - -def IS_LINE_JUNK(line, pat=re.compile(r"\s*#?\s*$").match): - r""" - Return 1 for ignorable line: iff `line` is blank or contains a single '#'. - - Examples: - - >>> IS_LINE_JUNK('\n') - 1 - >>> IS_LINE_JUNK(' # \n') - 1 - >>> IS_LINE_JUNK('hello\n') - 0 - """ - - return pat(line) is not None - -def IS_CHARACTER_JUNK(ch, ws=" \t"): - r""" - Return 1 for ignorable character: iff `ch` is a space or tab. - - Examples: - - >>> IS_CHARACTER_JUNK(' ') - 1 - >>> IS_CHARACTER_JUNK('\t') - 1 - >>> IS_CHARACTER_JUNK('\n') - 0 - >>> IS_CHARACTER_JUNK('x') - 0 - """ - - return ch in ws - -del re - -def ndiff(a, b, linejunk=IS_LINE_JUNK, charjunk=IS_CHARACTER_JUNK): - r""" - Compare `a` and `b` (lists of strings); return a `Differ`-style delta. - - Optional keyword parameters `linejunk` and `charjunk` are for filter - functions (or None): - - - linejunk: A function that should accept a single string argument, and - return true iff the string is junk. The default is module-level function - IS_LINE_JUNK, which filters out lines without visible characters, except - for at most one splat ('#'). - - - charjunk: A function that should accept a string of length 1. The - default is module-level function IS_CHARACTER_JUNK, which filters out - whitespace characters (a blank or tab; note: bad idea to include newline - in this!). - - Tools/scripts/ndiff.py is a command-line front-end to this function. - - Example: - - >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1), - ... 'ore\ntree\nemu\n'.splitlines(1)) - >>> print ''.join(diff), - - one - ? ^ - + ore - ? ^ - - two - - three - ? - - + tree - + emu - """ - return Differ(linejunk, charjunk).compare(a, b) - -def restore(delta, which): - r""" - Generate one of the two sequences that generated a delta. - - Given a `delta` produced by `Differ.compare()` or `ndiff()`, extract - lines originating from file 1 or 2 (parameter `which`), stripping off line - prefixes. - - Examples: - - >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1), - ... 'ore\ntree\nemu\n'.splitlines(1)) - >>> diff = list(diff) - >>> print ''.join(restore(diff, 1)), - one - two - three - >>> print ''.join(restore(diff, 2)), - ore - tree - emu - """ - try: - tag = {1: "- ", 2: "+ "}[int(which)] - except KeyError: - raise ValueError, ('unknown delta choice (must be 1 or 2): %r' - % which) - prefixes = (" ", tag) - for line in delta: - if line[:2] in prefixes: - yield line[2:] - -def _test(): - import doctest, difflib - return doctest.testmod(difflib) - -if __name__ == "__main__": - _test() diff --git a/Scripts/ServerPython/python/system/dircache.py b/Scripts/ServerPython/python/system/dircache.py deleted file mode 100644 index b95cb98a..00000000 --- a/Scripts/ServerPython/python/system/dircache.py +++ /dev/null @@ -1,44 +0,0 @@ -"""Read and cache directory listings. - -The listdir() routine returns a sorted list of the files in a directory, -using a cache to avoid reading the directory more often than necessary. -The annotate() routine appends slashes to directories.""" - -import os - -__all__ = ["listdir", "opendir", "annotate", "reset"] - -cache = {} - -def reset(): - """Reset the cache completely.""" - global cache - cache = {} - -def listdir(path): - """List directory contents, using cache.""" - try: - cached_mtime, list = cache[path] - del cache[path] - except KeyError: - cached_mtime, list = -1, [] - try: - mtime = os.stat(path)[8] - except os.error: - return [] - if mtime != cached_mtime: - try: - list = os.listdir(path) - except os.error: - return [] - list.sort() - cache[path] = mtime, list - return list - -opendir = listdir # XXX backward compatibility - -def annotate(head, list): - """Add '/' suffixes to directories.""" - for i in range(len(list)): - if os.path.isdir(os.path.join(head, list[i])): - list[i] = list[i] + '/' diff --git a/Scripts/ServerPython/python/system/dis.py b/Scripts/ServerPython/python/system/dis.py deleted file mode 100644 index e1e78ef6..00000000 --- a/Scripts/ServerPython/python/system/dis.py +++ /dev/null @@ -1,327 +0,0 @@ -"""Disassembler of Python byte code into mnemonics.""" - -import sys -import types - -__all__ = ["dis","disassemble","distb","disco","opname","cmp_op", - "hasconst","hasname","hasjrel","hasjabs","haslocal", - "hascompare", "hasfree"] - -def dis(x=None): - """Disassemble classes, methods, functions, or code. - - With no argument, disassemble the last traceback. - - """ - if not x: - distb() - return - if type(x) is types.InstanceType: - x = x.__class__ - if hasattr(x, 'im_func'): - x = x.im_func - if hasattr(x, 'func_code'): - x = x.func_code - if hasattr(x, '__dict__'): - items = x.__dict__.items() - items.sort() - for name, x1 in items: - if type(x1) in (types.MethodType, - types.FunctionType, - types.CodeType): - print "Disassembly of %s:" % name - try: - dis(x1) - except TypeError, msg: - print "Sorry:", msg - print - elif hasattr(x, 'co_code'): - disassemble(x) - else: - raise TypeError, \ - "don't know how to disassemble %s objects" % \ - type(x).__name__ - -def distb(tb=None): - """Disassemble a traceback (default: last traceback).""" - if not tb: - try: - tb = sys.last_traceback - except AttributeError: - raise RuntimeError, "no last traceback to disassemble" - while tb.tb_next: tb = tb.tb_next - disassemble(tb.tb_frame.f_code, tb.tb_lasti) - -def disassemble(co, lasti=-1): - """Disassemble a code object.""" - code = co.co_code - labels = findlabels(code) - n = len(code) - i = 0 - extended_arg = 0 - free = None - while i < n: - c = code[i] - op = ord(c) - if op == SET_LINENO and i > 0: print # Extra blank line - if i == lasti: print '-->', - else: print ' ', - if i in labels: print '>>', - else: print ' ', - print `i`.rjust(4), - print opname[op].ljust(20), - i = i+1 - if op >= HAVE_ARGUMENT: - oparg = ord(code[i]) + ord(code[i+1])*256 + extended_arg - extended_arg = 0 - i = i+2 - if op == EXTENDED_ARG: - extended_arg = oparg*65536L - print `oparg`.rjust(5), - if op in hasconst: - print '(' + `co.co_consts[oparg]` + ')', - elif op in hasname: - print '(' + co.co_names[oparg] + ')', - elif op in hasjrel: - print '(to ' + `i + oparg` + ')', - elif op in haslocal: - print '(' + co.co_varnames[oparg] + ')', - elif op in hascompare: - print '(' + cmp_op[oparg] + ')', - elif op in hasfree: - if free is None: - free = co.co_cellvars + co.co_freevars - print '(' + free[oparg] + ')', - print - -disco = disassemble # XXX For backwards compatibility - -def findlabels(code): - """Detect all offsets in a byte code which are jump targets. - - Return the list of offsets. - - """ - labels = [] - n = len(code) - i = 0 - while i < n: - c = code[i] - op = ord(c) - i = i+1 - if op >= HAVE_ARGUMENT: - oparg = ord(code[i]) + ord(code[i+1])*256 - i = i+2 - label = -1 - if op in hasjrel: - label = i+oparg - elif op in hasjabs: - label = oparg - if label >= 0: - if label not in labels: - labels.append(label) - return labels - -cmp_op = ('<', '<=', '==', '!=', '>', '>=', 'in', 'not in', 'is', - 'is not', 'exception match', 'BAD') - -hasconst = [] -hasname = [] -hasjrel = [] -hasjabs = [] -haslocal = [] -hascompare = [] -hasfree = [] - -opname = [''] * 256 -for op in range(256): opname[op] = '<' + `op` + '>' - -def def_op(name, op): - opname[op] = name - -def name_op(name, op): - opname[op] = name - hasname.append(op) - -def jrel_op(name, op): - opname[op] = name - hasjrel.append(op) - -def jabs_op(name, op): - opname[op] = name - hasjabs.append(op) - -# Instruction opcodes for compiled code - -def_op('STOP_CODE', 0) -def_op('POP_TOP', 1) -def_op('ROT_TWO', 2) -def_op('ROT_THREE', 3) -def_op('DUP_TOP', 4) -def_op('ROT_FOUR', 5) - -def_op('UNARY_POSITIVE', 10) -def_op('UNARY_NEGATIVE', 11) -def_op('UNARY_NOT', 12) -def_op('UNARY_CONVERT', 13) - -def_op('UNARY_INVERT', 15) - -def_op('BINARY_POWER', 19) - -def_op('BINARY_MULTIPLY', 20) -def_op('BINARY_DIVIDE', 21) -def_op('BINARY_MODULO', 22) -def_op('BINARY_ADD', 23) -def_op('BINARY_SUBTRACT', 24) -def_op('BINARY_SUBSCR', 25) -def_op('BINARY_FLOOR_DIVIDE', 26) -def_op('BINARY_TRUE_DIVIDE', 27) -def_op('INPLACE_FLOOR_DIVIDE', 28) -def_op('INPLACE_TRUE_DIVIDE', 29) - -def_op('SLICE+0', 30) -def_op('SLICE+1', 31) -def_op('SLICE+2', 32) -def_op('SLICE+3', 33) - -def_op('STORE_SLICE+0', 40) -def_op('STORE_SLICE+1', 41) -def_op('STORE_SLICE+2', 42) -def_op('STORE_SLICE+3', 43) - -def_op('DELETE_SLICE+0', 50) -def_op('DELETE_SLICE+1', 51) -def_op('DELETE_SLICE+2', 52) -def_op('DELETE_SLICE+3', 53) - -def_op('INPLACE_ADD', 55) -def_op('INPLACE_SUBTRACT', 56) -def_op('INPLACE_MULTIPLY', 57) -def_op('INPLACE_DIVIDE', 58) -def_op('INPLACE_MODULO', 59) -def_op('STORE_SUBSCR', 60) -def_op('DELETE_SUBSCR', 61) - -def_op('BINARY_LSHIFT', 62) -def_op('BINARY_RSHIFT', 63) -def_op('BINARY_AND', 64) -def_op('BINARY_XOR', 65) -def_op('BINARY_OR', 66) -def_op('INPLACE_POWER', 67) -def_op('GET_ITER', 68) - -def_op('PRINT_EXPR', 70) -def_op('PRINT_ITEM', 71) -def_op('PRINT_NEWLINE', 72) -def_op('PRINT_ITEM_TO', 73) -def_op('PRINT_NEWLINE_TO', 74) -def_op('INPLACE_LSHIFT', 75) -def_op('INPLACE_RSHIFT', 76) -def_op('INPLACE_AND', 77) -def_op('INPLACE_XOR', 78) -def_op('INPLACE_OR', 79) -def_op('BREAK_LOOP', 80) - -def_op('LOAD_LOCALS', 82) -def_op('RETURN_VALUE', 83) -def_op('IMPORT_STAR', 84) -def_op('EXEC_STMT', 85) -def_op('YIELD_STMT', 86) - -def_op('POP_BLOCK', 87) -def_op('END_FINALLY', 88) -def_op('BUILD_CLASS', 89) - -HAVE_ARGUMENT = 90 # Opcodes from here have an argument: - -name_op('STORE_NAME', 90) # Index in name list -name_op('DELETE_NAME', 91) # "" -def_op('UNPACK_SEQUENCE', 92) # Number of tuple items -jrel_op('FOR_ITER', 93) - -name_op('STORE_ATTR', 95) # Index in name list -name_op('DELETE_ATTR', 96) # "" -name_op('STORE_GLOBAL', 97) # "" -name_op('DELETE_GLOBAL', 98) # "" -def_op('DUP_TOPX', 99) # number of items to duplicate -def_op('LOAD_CONST', 100) # Index in const list -hasconst.append(100) -name_op('LOAD_NAME', 101) # Index in name list -def_op('BUILD_TUPLE', 102) # Number of tuple items -def_op('BUILD_LIST', 103) # Number of list items -def_op('BUILD_MAP', 104) # Always zero for now -name_op('LOAD_ATTR', 105) # Index in name list -def_op('COMPARE_OP', 106) # Comparison operator -hascompare.append(106) -name_op('IMPORT_NAME', 107) # Index in name list -name_op('IMPORT_FROM', 108) # Index in name list - -jrel_op('JUMP_FORWARD', 110) # Number of bytes to skip -jrel_op('JUMP_IF_FALSE', 111) # "" -jrel_op('JUMP_IF_TRUE', 112) # "" -jabs_op('JUMP_ABSOLUTE', 113) # Target byte offset from beginning of code -jrel_op('FOR_LOOP', 114) # Number of bytes to skip - -name_op('LOAD_GLOBAL', 116) # Index in name list - -jabs_op('CONTINUE_LOOP', 119) # Target address -jrel_op('SETUP_LOOP', 120) # Distance to target address -jrel_op('SETUP_EXCEPT', 121) # "" -jrel_op('SETUP_FINALLY', 122) # "" - -def_op('LOAD_FAST', 124) # Local variable number -haslocal.append(124) -def_op('STORE_FAST', 125) # Local variable number -haslocal.append(125) -def_op('DELETE_FAST', 126) # Local variable number -haslocal.append(126) - -def_op('SET_LINENO', 127) # Current line number -SET_LINENO = 127 - -def_op('RAISE_VARARGS', 130) # Number of raise arguments (1, 2, or 3) -def_op('CALL_FUNCTION', 131) # #args + (#kwargs << 8) -def_op('MAKE_FUNCTION', 132) # Number of args with default values -def_op('BUILD_SLICE', 133) # Number of items - -def_op('MAKE_CLOSURE', 134) -def_op('LOAD_CLOSURE', 135) -hasfree.append(135) -def_op('LOAD_DEREF', 136) -hasfree.append(136) -def_op('STORE_DEREF', 137) -hasfree.append(137) - -def_op('CALL_FUNCTION_VAR', 140) # #args + (#kwargs << 8) -def_op('CALL_FUNCTION_KW', 141) # #args + (#kwargs << 8) -def_op('CALL_FUNCTION_VAR_KW', 142) # #args + (#kwargs << 8) - -def_op('EXTENDED_ARG', 143) -EXTENDED_ARG = 143 - -def _test(): - """Simple test program to disassemble a file.""" - if sys.argv[1:]: - if sys.argv[2:]: - sys.stderr.write("usage: python dis.py [-|file]\n") - sys.exit(2) - fn = sys.argv[1] - if not fn or fn == "-": - fn = None - else: - fn = None - if not fn: - f = sys.stdin - else: - f = open(fn) - source = f.read() - if fn: - f.close() - else: - fn = "" - code = compile(source, fn, "exec") - dis(code) - -if __name__ == "__main__": - _test() diff --git a/Scripts/ServerPython/python/system/dospath.py b/Scripts/ServerPython/python/system/dospath.py deleted file mode 100644 index 83c40385..00000000 --- a/Scripts/ServerPython/python/system/dospath.py +++ /dev/null @@ -1,341 +0,0 @@ -"""Common operations on DOS pathnames.""" - -import os -import stat - -__all__ = ["normcase","isabs","join","splitdrive","split","splitext", - "basename","dirname","commonprefix","getsize","getmtime", - "getatime","islink","exists","isdir","isfile","ismount", - "walk","expanduser","expandvars","normpath","abspath"] - -def normcase(s): - """Normalize the case of a pathname. - On MS-DOS it maps the pathname to lowercase, turns slashes into - backslashes. - Other normalizations (such as optimizing '../' away) are not allowed - (this is done by normpath). - Previously, this version mapped invalid consecutive characters to a - single '_', but this has been removed. This functionality should - possibly be added as a new function.""" - - return s.replace("/", "\\").lower() - - -def isabs(s): - """Return whether a path is absolute. - Trivial in Posix, harder on the Mac or MS-DOS. - For DOS it is absolute if it starts with a slash or backslash (current - volume), or if a pathname after the volume letter and colon starts with - a slash or backslash.""" - - s = splitdrive(s)[1] - return s != '' and s[:1] in '/\\' - - -def join(a, *p): - """Join two (or more) paths.""" - - path = a - for b in p: - if isabs(b): - path = b - elif path == '' or path[-1:] in '/\\:': - path = path + b - else: - path = path + "\\" + b - return path - - -def splitdrive(p): - """Split a path into a drive specification (a drive letter followed - by a colon) and path specification. - It is always true that drivespec + pathspec == p.""" - - if p[1:2] == ':': - return p[0:2], p[2:] - return '', p - - -def split(p): - """Split a path into head (everything up to the last '/') and tail - (the rest). After the trailing '/' is stripped, the invariant - join(head, tail) == p holds. - The resulting head won't end in '/' unless it is the root.""" - - d, p = splitdrive(p) - # set i to index beyond p's last slash - i = len(p) - while i and p[i-1] not in '/\\': - i = i - 1 - head, tail = p[:i], p[i:] # now tail has no slashes - # remove trailing slashes from head, unless it's all slashes - head2 = head - while head2 and head2[-1] in '/\\': - head2 = head2[:-1] - head = head2 or head - return d + head, tail - - -def splitext(p): - """Split a path into root and extension. - The extension is everything starting at the first dot in the last - pathname component; the root is everything before that. - It is always true that root + ext == p.""" - - root, ext = '', '' - for c in p: - if c in '/\\': - root, ext = root + ext + c, '' - elif c == '.' or ext: - ext = ext + c - else: - root = root + c - return root, ext - - -def basename(p): - """Return the tail (basename) part of a path.""" - - return split(p)[1] - - -def dirname(p): - """Return the head (dirname) part of a path.""" - - return split(p)[0] - - -def commonprefix(m): - """Return the longest prefix of all list elements.""" - - if not m: return '' - prefix = m[0] - for item in m: - for i in range(len(prefix)): - if prefix[:i+1] != item[:i+1]: - prefix = prefix[:i] - if i == 0: return '' - break - return prefix - - -# Get size, mtime, atime of files. - -def getsize(filename): - """Return the size of a file, reported by os.stat().""" - st = os.stat(filename) - return st[stat.ST_SIZE] - -def getmtime(filename): - """Return the last modification time of a file, reported by os.stat().""" - st = os.stat(filename) - return st[stat.ST_MTIME] - -def getatime(filename): - """Return the last access time of a file, reported by os.stat().""" - st = os.stat(filename) - return st[stat.ST_ATIME] - - -def islink(path): - """Is a path a symbolic link? - This will always return false on systems where posix.lstat doesn't exist.""" - - return 0 - - -def exists(path): - """Does a path exist? - This is false for dangling symbolic links.""" - - try: - st = os.stat(path) - except os.error: - return 0 - return 1 - - -def isdir(path): - """Is a path a dos directory?""" - - try: - st = os.stat(path) - except os.error: - return 0 - return stat.S_ISDIR(st[stat.ST_MODE]) - - -def isfile(path): - """Is a path a regular file?""" - - try: - st = os.stat(path) - except os.error: - return 0 - return stat.S_ISREG(st[stat.ST_MODE]) - - -def ismount(path): - """Is a path a mount point?""" - # XXX This degenerates in: 'is this the root?' on DOS - - return isabs(splitdrive(path)[1]) - - -def walk(top, func, arg): - """Directory tree walk with callback function. - - For each directory in the directory tree rooted at top (including top - itself, but excluding '.' and '..'), call func(arg, dirname, fnames). - dirname is the name of the directory, and fnames a list of the names of - the files and subdirectories in dirname (excluding '.' and '..'). func - may modify the fnames list in-place (e.g. via del or slice assignment), - and walk will only recurse into the subdirectories whose names remain in - fnames; this can be used to implement a filter, or to impose a specific - order of visiting. No semantics are defined for, or required of, arg, - beyond that arg is always passed to func. It can be used, e.g., to pass - a filename pattern, or a mutable object designed to accumulate - statistics. Passing None for arg is common.""" - - try: - names = os.listdir(top) - except os.error: - return - func(arg, top, names) - exceptions = ('.', '..') - for name in names: - if name not in exceptions: - name = join(top, name) - if isdir(name): - walk(name, func, arg) - - -def expanduser(path): - """Expand paths beginning with '~' or '~user'. - '~' means $HOME; '~user' means that user's home directory. - If the path doesn't begin with '~', or if the user or $HOME is unknown, - the path is returned unchanged (leaving error reporting to whatever - function is called with the expanded path as argument). - See also module 'glob' for expansion of *, ? and [...] in pathnames. - (A function should also be defined to do full *sh-style environment - variable expansion.)""" - - if path[:1] != '~': - return path - i, n = 1, len(path) - while i < n and path[i] not in '/\\': - i = i+1 - if i == 1: - if not os.environ.has_key('HOME'): - return path - userhome = os.environ['HOME'] - else: - return path - return userhome + path[i:] - - -def expandvars(path): - """Expand paths containing shell variable substitutions. - The following rules apply: - - no expansion within single quotes - - no escape character, except for '$$' which is translated into '$' - - ${varname} is accepted. - - varnames can be made out of letters, digits and the character '_'""" - # XXX With COMMAND.COM you can use any characters in a variable name, - # XXX except '^|<>='. - - if '$' not in path: - return path - import string - varchars = string.ascii_letters + string.digits + "_-" - res = '' - index = 0 - pathlen = len(path) - while index < pathlen: - c = path[index] - if c == '\'': # no expansion within single quotes - path = path[index + 1:] - pathlen = len(path) - try: - index = path.index('\'') - res = res + '\'' + path[:index + 1] - except ValueError: - res = res + path - index = pathlen -1 - elif c == '$': # variable or '$$' - if path[index + 1:index + 2] == '$': - res = res + c - index = index + 1 - elif path[index + 1:index + 2] == '{': - path = path[index+2:] - pathlen = len(path) - try: - index = path.index('}') - var = path[:index] - if os.environ.has_key(var): - res = res + os.environ[var] - except ValueError: - res = res + path - index = pathlen - 1 - else: - var = '' - index = index + 1 - c = path[index:index + 1] - while c != '' and c in varchars: - var = var + c - index = index + 1 - c = path[index:index + 1] - if os.environ.has_key(var): - res = res + os.environ[var] - if c != '': - res = res + c - else: - res = res + c - index = index + 1 - return res - - -def normpath(path): - """Normalize a path, e.g. A//B, A/./B and A/foo/../B all become A/B. - Also, components of the path are silently truncated to 8+3 notation.""" - - path = path.replace("/", "\\") - prefix, path = splitdrive(path) - while path[:1] == "\\": - prefix = prefix + "\\" - path = path[1:] - comps = path.split("\\") - i = 0 - while i < len(comps): - if comps[i] == '.': - del comps[i] - elif comps[i] == '..' and i > 0 and \ - comps[i-1] not in ('', '..'): - del comps[i-1:i+1] - i = i - 1 - elif comps[i] == '' and i > 0 and comps[i-1] != '': - del comps[i] - elif '.' in comps[i]: - comp = comps[i].split('.') - comps[i] = comp[0][:8] + '.' + comp[1][:3] - i = i + 1 - elif len(comps[i]) > 8: - comps[i] = comps[i][:8] - i = i + 1 - else: - i = i + 1 - # If the path is now empty, substitute '.' - if not prefix and not comps: - comps.append('.') - return prefix + "\\".join(comps) - - - -def abspath(path): - """Return an absolute path.""" - if not isabs(path): - path = join(os.getcwd(), path) - return normpath(path) - -# realpath is a no-op on systems without islink support -realpath = abspath diff --git a/Scripts/ServerPython/python/system/filecmp.py b/Scripts/ServerPython/python/system/filecmp.py deleted file mode 100644 index 1d18fac2..00000000 --- a/Scripts/ServerPython/python/system/filecmp.py +++ /dev/null @@ -1,331 +0,0 @@ -"""Utilities for comparing files and directories. - -Classes: - dircmp - -Functions: - cmp(f1, f2, shallow=1, use_statcache=0) -> int - cmpfiles(a, b, common) -> ([], [], []) - -""" - -import os -import stat -import statcache - -__all__ = ["cmp","dircmp","cmpfiles"] - -_cache = {} -BUFSIZE=8*1024 - -def cmp(f1, f2, shallow=1, use_statcache=0): - """Compare two files. - - Arguments: - - f1 -- First file name - - f2 -- Second file name - - shallow -- Just check stat signature (do not read the files). - defaults to 1. - - use_statcache -- Do not stat() each file directly: go through - the statcache module for more efficiency. - - Return value: - - integer -- 1 if the files are the same, 0 otherwise. - - This function uses a cache for past comparisons and the results, - with a cache invalidation mechanism relying on stale signatures. - Of course, if 'use_statcache' is true, this mechanism is defeated, - and the cache will never grow stale. - - """ - if use_statcache: - stat_function = statcache.stat - else: - stat_function = os.stat - s1 = _sig(stat_function(f1)) - s2 = _sig(stat_function(f2)) - if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG: - return 0 - if shallow and s1 == s2: - return 1 - if s1[1] != s2[1]: - return 0 - - result = _cache.get((f1, f2)) - if result and (s1, s2) == result[:2]: - return result[2] - outcome = _do_cmp(f1, f2) - _cache[f1, f2] = s1, s2, outcome - return outcome - -def _sig(st): - return (stat.S_IFMT(st[stat.ST_MODE]), - st[stat.ST_SIZE], - st[stat.ST_MTIME]) - -def _do_cmp(f1, f2): - bufsize = BUFSIZE - fp1 = open(f1, 'rb') - fp2 = open(f2, 'rb') - while 1: - b1 = fp1.read(bufsize) - b2 = fp2.read(bufsize) - if b1 != b2: - return 0 - if not b1: - return 1 - -# Directory comparison class. -# -class dircmp: - """A class that manages the comparison of 2 directories. - - dircmp(a,b,ignore=None,hide=None) - A and B are directories. - IGNORE is a list of names to ignore, - defaults to ['RCS', 'CVS', 'tags']. - HIDE is a list of names to hide, - defaults to [os.curdir, os.pardir]. - - High level usage: - x = dircmp(dir1, dir2) - x.report() -> prints a report on the differences between dir1 and dir2 - or - x.report_partial_closure() -> prints report on differences between dir1 - and dir2, and reports on common immediate subdirectories. - x.report_full_closure() -> like report_partial_closure, - but fully recursive. - - Attributes: - left_list, right_list: The files in dir1 and dir2, - filtered by hide and ignore. - common: a list of names in both dir1 and dir2. - left_only, right_only: names only in dir1, dir2. - common_dirs: subdirectories in both dir1 and dir2. - common_files: files in both dir1 and dir2. - common_funny: names in both dir1 and dir2 where the type differs between - dir1 and dir2, or the name is not stat-able. - same_files: list of identical files. - diff_files: list of filenames which differ. - funny_files: list of files which could not be compared. - subdirs: a dictionary of dircmp objects, keyed by names in common_dirs. - """ - - def __init__(self, a, b, ignore=None, hide=None): # Initialize - self.left = a - self.right = b - if hide is None: - self.hide = [os.curdir, os.pardir] # Names never to be shown - else: - self.hide = hide - if ignore is None: - self.ignore = ['RCS', 'CVS', 'tags'] # Names ignored in comparison - else: - self.ignore = ignore - - def phase0(self): # Compare everything except common subdirectories - self.left_list = _filter(os.listdir(self.left), - self.hide+self.ignore) - self.right_list = _filter(os.listdir(self.right), - self.hide+self.ignore) - self.left_list.sort() - self.right_list.sort() - - __p4_attrs = ('subdirs',) - __p3_attrs = ('same_files', 'diff_files', 'funny_files') - __p2_attrs = ('common_dirs', 'common_files', 'common_funny') - __p1_attrs = ('common', 'left_only', 'right_only') - __p0_attrs = ('left_list', 'right_list') - - def __getattr__(self, attr): - if attr in self.__p4_attrs: - self.phase4() - elif attr in self.__p3_attrs: - self.phase3() - elif attr in self.__p2_attrs: - self.phase2() - elif attr in self.__p1_attrs: - self.phase1() - elif attr in self.__p0_attrs: - self.phase0() - else: - raise AttributeError, attr - return getattr(self, attr) - - def phase1(self): # Compute common names - a_only, b_only = [], [] - common = {} - b = {} - for fnm in self.right_list: - b[fnm] = 1 - for x in self.left_list: - if b.get(x, 0): - common[x] = 1 - else: - a_only.append(x) - for x in self.right_list: - if common.get(x, 0): - pass - else: - b_only.append(x) - self.common = common.keys() - self.left_only = a_only - self.right_only = b_only - - def phase2(self): # Distinguish files, directories, funnies - self.common_dirs = [] - self.common_files = [] - self.common_funny = [] - - for x in self.common: - a_path = os.path.join(self.left, x) - b_path = os.path.join(self.right, x) - - ok = 1 - try: - a_stat = statcache.stat(a_path) - except os.error, why: - # print 'Can\'t stat', a_path, ':', why[1] - ok = 0 - try: - b_stat = statcache.stat(b_path) - except os.error, why: - # print 'Can\'t stat', b_path, ':', why[1] - ok = 0 - - if ok: - a_type = stat.S_IFMT(a_stat[stat.ST_MODE]) - b_type = stat.S_IFMT(b_stat[stat.ST_MODE]) - if a_type != b_type: - self.common_funny.append(x) - elif stat.S_ISDIR(a_type): - self.common_dirs.append(x) - elif stat.S_ISREG(a_type): - self.common_files.append(x) - else: - self.common_funny.append(x) - else: - self.common_funny.append(x) - - def phase3(self): # Find out differences between common files - xx = cmpfiles(self.left, self.right, self.common_files) - self.same_files, self.diff_files, self.funny_files = xx - - def phase4(self): # Find out differences between common subdirectories - # A new dircmp object is created for each common subdirectory, - # these are stored in a dictionary indexed by filename. - # The hide and ignore properties are inherited from the parent - self.subdirs = {} - for x in self.common_dirs: - a_x = os.path.join(self.left, x) - b_x = os.path.join(self.right, x) - self.subdirs[x] = dircmp(a_x, b_x, self.ignore, self.hide) - - def phase4_closure(self): # Recursively call phase4() on subdirectories - self.phase4() - for x in self.subdirs.keys(): - self.subdirs[x].phase4_closure() - - def report(self): # Print a report on the differences between a and b - # Output format is purposely lousy - print 'diff', self.left, self.right - if self.left_only: - self.left_only.sort() - print 'Only in', self.left, ':', self.left_only - if self.right_only: - self.right_only.sort() - print 'Only in', self.right, ':', self.right_only - if self.same_files: - self.same_files.sort() - print 'Identical files :', self.same_files - if self.diff_files: - self.diff_files.sort() - print 'Differing files :', self.diff_files - if self.funny_files: - self.funny_files.sort() - print 'Trouble with common files :', self.funny_files - if self.common_dirs: - self.common_dirs.sort() - print 'Common subdirectories :', self.common_dirs - if self.common_funny: - self.common_funny.sort() - print 'Common funny cases :', self.common_funny - - def report_partial_closure(self): # Print reports on self and on subdirs - self.report() - for x in self.subdirs.keys(): - print - self.subdirs[x].report() - - def report_full_closure(self): # Report on self and subdirs recursively - self.report() - for x in self.subdirs.keys(): - print - self.subdirs[x].report_full_closure() - - -def cmpfiles(a, b, common, shallow=1, use_statcache=0): - """Compare common files in two directories. - - a, b -- directory names - common -- list of file names found in both directories - shallow -- if true, do comparison based solely on stat() information - use_statcache -- if true, use statcache.stat() instead of os.stat() - - Returns a tuple of three lists: - files that compare equal - files that are different - filenames that aren't regular files. - - """ - res = ([], [], []) - for x in common: - ax = os.path.join(a, x) - bx = os.path.join(b, x) - res[_cmp(ax, bx, shallow, use_statcache)].append(x) - return res - - -# Compare two files. -# Return: -# 0 for equal -# 1 for different -# 2 for funny cases (can't stat, etc.) -# -def _cmp(a, b, sh, st): - try: - return not abs(cmp(a, b, sh, st)) - except os.error: - return 2 - - -# Return a copy with items that occur in skip removed. -# -def _filter(list, skip): - result = [] - for item in list: - if item not in skip: result.append(item) - return result - - -# Demonstration and testing. -# -def demo(): - import sys - import getopt - options, args = getopt.getopt(sys.argv[1:], 'r') - if len(args) != 2: - raise getopt.error, 'need exactly two args' - dd = dircmp(args[0], args[1]) - if ('-r', '') in options: - dd.report_full_closure() - else: - dd.report() - -if __name__ == '__main__': - demo() diff --git a/Scripts/ServerPython/python/system/fileinput.py b/Scripts/ServerPython/python/system/fileinput.py deleted file mode 100644 index ebd873e3..00000000 --- a/Scripts/ServerPython/python/system/fileinput.py +++ /dev/null @@ -1,349 +0,0 @@ -"""Helper class to quickly write a loop over all standard input files. - -Typical use is: - - import fileinput - for line in fileinput.input(): - process(line) - -This iterates over the lines of all files listed in sys.argv[1:], -defaulting to sys.stdin if the list is empty. If a filename is '-' it -is also replaced by sys.stdin. To specify an alternative list of -filenames, pass it as the argument to input(). A single file name is -also allowed. - -Functions filename(), lineno() return the filename and cumulative line -number of the line that has just been read; filelineno() returns its -line number in the current file; isfirstline() returns true iff the -line just read is the first line of its file; isstdin() returns true -iff the line was read from sys.stdin. Function nextfile() closes the -current file so that the next iteration will read the first line from -the next file (if any); lines not read from the file will not count -towards the cumulative line count; the filename is not changed until -after the first line of the next file has been read. Function close() -closes the sequence. - -Before any lines have been read, filename() returns None and both line -numbers are zero; nextfile() has no effect. After all lines have been -read, filename() and the line number functions return the values -pertaining to the last line read; nextfile() has no effect. - -All files are opened in text mode. If an I/O error occurs during -opening or reading a file, the IOError exception is raised. - -If sys.stdin is used more than once, the second and further use will -return no lines, except perhaps for interactive use, or if it has been -explicitly reset (e.g. using sys.stdin.seek(0)). - -Empty files are opened and immediately closed; the only time their -presence in the list of filenames is noticeable at all is when the -last file opened is empty. - -It is possible that the last line of a file doesn't end in a newline -character; otherwise lines are returned including the trailing -newline. - -Class FileInput is the implementation; its methods filename(), -lineno(), fileline(), isfirstline(), isstdin(), nextfile() and close() -correspond to the functions in the module. In addition it has a -readline() method which returns the next input line, and a -__getitem__() method which implements the sequence behavior. The -sequence must be accessed in strictly sequential order; sequence -access and readline() cannot be mixed. - -Optional in-place filtering: if the keyword argument inplace=1 is -passed to input() or to the FileInput constructor, the file is moved -to a backup file and standard output is directed to the input file. -This makes it possible to write a filter that rewrites its input file -in place. If the keyword argument backup="." is also -given, it specifies the extension for the backup file, and the backup -file remains around; by default, the extension is ".bak" and it is -deleted when the output file is closed. In-place filtering is -disabled when standard input is read. XXX The current implementation -does not work for MS-DOS 8+3 filesystems. - -Performance: this module is unfortunately one of the slower ways of -processing large numbers of input lines. Nevertheless, a significant -speed-up has been obtained by using readlines(bufsize) instead of -readline(). A new keyword argument, bufsize=N, is present on the -input() function and the FileInput() class to override the default -buffer size. - -XXX Possible additions: - -- optional getopt argument processing -- specify open mode ('r' or 'rb') -- fileno() -- isatty() -- read(), read(size), even readlines() - -""" - -import sys, os, stat - -__all__ = ["input","close","nextfile","filename","lineno","filelineno", - "isfirstline","isstdin","FileInput"] - -_state = None - -DEFAULT_BUFSIZE = 8*1024 - -def input(files=None, inplace=0, backup="", bufsize=0): - """input([files[, inplace[, backup]]]) - - Create an instance of the FileInput class. The instance will be used - as global state for the functions of this module, and is also returned - to use during iteration. The parameters to this function will be passed - along to the constructor of the FileInput class. - """ - global _state - if _state and _state._file: - raise RuntimeError, "input() already active" - _state = FileInput(files, inplace, backup, bufsize) - return _state - -def close(): - """Close the sequence.""" - global _state - state = _state - _state = None - if state: - state.close() - -def nextfile(): - """ - Close the current file so that the next iteration will read the first - line from the next file (if any); lines not read from the file will - not count towards the cumulative line count. The filename is not - changed until after the first line of the next file has been read. - Before the first line has been read, this function has no effect; - it cannot be used to skip the first file. After the last line of the - last file has been read, this function has no effect. - """ - if not _state: - raise RuntimeError, "no active input()" - return _state.nextfile() - -def filename(): - """ - Return the name of the file currently being read. - Before the first line has been read, returns None. - """ - if not _state: - raise RuntimeError, "no active input()" - return _state.filename() - -def lineno(): - """ - Return the cumulative line number of the line that has just been read. - Before the first line has been read, returns 0. After the last line - of the last file has been read, returns the line number of that line. - """ - if not _state: - raise RuntimeError, "no active input()" - return _state.lineno() - -def filelineno(): - """ - Return the line number in the current file. Before the first line - has been read, returns 0. After the last line of the last file has - been read, returns the line number of that line within the file. - """ - if not _state: - raise RuntimeError, "no active input()" - return _state.filelineno() - -def isfirstline(): - """ - Returns true the line just read is the first line of its file, - otherwise returns false. - """ - if not _state: - raise RuntimeError, "no active input()" - return _state.isfirstline() - -def isstdin(): - """ - Returns true if the last line was read from sys.stdin, - otherwise returns false. - """ - if not _state: - raise RuntimeError, "no active input()" - return _state.isstdin() - -class FileInput: - """class FileInput([files[, inplace[, backup]]]) - - Class FileInput is the implementation of the module; its methods - filename(), lineno(), fileline(), isfirstline(), isstdin(), nextfile() - and close() correspond to the functions of the same name in the module. - In addition it has a readline() method which returns the next - input line, and a __getitem__() method which implements the - sequence behavior. The sequence must be accessed in strictly - sequential order; random access and readline() cannot be mixed. - """ - - def __init__(self, files=None, inplace=0, backup="", bufsize=0): - if type(files) == type(''): - files = (files,) - else: - if files is None: - files = sys.argv[1:] - if not files: - files = ('-',) - else: - files = tuple(files) - self._files = files - self._inplace = inplace - self._backup = backup - self._bufsize = bufsize or DEFAULT_BUFSIZE - self._savestdout = None - self._output = None - self._filename = None - self._lineno = 0 - self._filelineno = 0 - self._file = None - self._isstdin = 0 - self._backupfilename = None - self._buffer = [] - self._bufindex = 0 - - def __del__(self): - self.close() - - def close(self): - self.nextfile() - self._files = () - - def __getitem__(self, i): - try: - line = self._buffer[self._bufindex] - except IndexError: - pass - else: - self._bufindex += 1 - self._lineno += 1 - self._filelineno += 1 - return line - if i != self._lineno: - raise RuntimeError, "accessing lines out of order" - line = self.readline() - if not line: - raise IndexError, "end of input reached" - return line - - def nextfile(self): - savestdout = self._savestdout - self._savestdout = 0 - if savestdout: - sys.stdout = savestdout - - output = self._output - self._output = 0 - if output: - output.close() - - file = self._file - self._file = 0 - if file and not self._isstdin: - file.close() - - backupfilename = self._backupfilename - self._backupfilename = 0 - if backupfilename and not self._backup: - try: os.unlink(backupfilename) - except: pass - - self._isstdin = 0 - self._buffer = [] - self._bufindex = 0 - - def readline(self): - try: - line = self._buffer[self._bufindex] - except IndexError: - pass - else: - self._bufindex += 1 - self._lineno += 1 - self._filelineno += 1 - return line - if not self._file: - if not self._files: - return "" - self._filename = self._files[0] - self._files = self._files[1:] - self._filelineno = 0 - self._file = None - self._isstdin = 0 - self._backupfilename = 0 - if self._filename == '-': - self._filename = '' - self._file = sys.stdin - self._isstdin = 1 - else: - if self._inplace: - self._backupfilename = ( - self._filename + (self._backup or os.extsep+"bak")) - try: os.unlink(self._backupfilename) - except os.error: pass - # The next few lines may raise IOError - os.rename(self._filename, self._backupfilename) - self._file = open(self._backupfilename, "r") - try: - perm = os.fstat(self._file.fileno())[stat.ST_MODE] - except: - self._output = open(self._filename, "w") - else: - fd = os.open(self._filename, - os.O_CREAT | os.O_WRONLY | os.O_TRUNC, - perm) - self._output = os.fdopen(fd, "w") - try: - os.chmod(self._filename, perm) - except: - pass - self._savestdout = sys.stdout - sys.stdout = self._output - else: - # This may raise IOError - self._file = open(self._filename, "r") - self._buffer = self._file.readlines(self._bufsize) - self._bufindex = 0 - if not self._buffer: - self.nextfile() - # Recursive call - return self.readline() - - def filename(self): - return self._filename - - def lineno(self): - return self._lineno - - def filelineno(self): - return self._filelineno - - def isfirstline(self): - return self._filelineno == 1 - - def isstdin(self): - return self._isstdin - -def _test(): - import getopt - inplace = 0 - backup = 0 - opts, args = getopt.getopt(sys.argv[1:], "ib:") - for o, a in opts: - if o == '-i': inplace = 1 - if o == '-b': backup = a - for line in input(args, inplace=inplace, backup=backup): - if line[-1:] == '\n': line = line[:-1] - if line[-1:] == '\r': line = line[:-1] - print "%d: %s[%d]%s %s" % (lineno(), filename(), filelineno(), - isfirstline() and "*" or "", line) - print "%d: %s[%d]" % (lineno(), filename(), filelineno()) - -if __name__ == '__main__': - _test() diff --git a/Scripts/ServerPython/python/system/fnmatch.py b/Scripts/ServerPython/python/system/fnmatch.py deleted file mode 100644 index e3393ce4..00000000 --- a/Scripts/ServerPython/python/system/fnmatch.py +++ /dev/null @@ -1,107 +0,0 @@ -"""Filename matching with shell patterns. - -fnmatch(FILENAME, PATTERN) matches according to the local convention. -fnmatchcase(FILENAME, PATTERN) always takes case in account. - -The functions operate by translating the pattern into a regular -expression. They cache the compiled regular expressions for speed. - -The function translate(PATTERN) returns a regular expression -corresponding to PATTERN. (It does not compile it.) -""" - -import re - -__all__ = ["fnmatch","fnmatchcase","translate"] - -_cache = {} - -def fnmatch(name, pat): - """Test whether FILENAME matches PATTERN. - - Patterns are Unix shell style: - - * matches everything - ? matches any single character - [seq] matches any character in seq - [!seq] matches any char not in seq - - An initial period in FILENAME is not special. - Both FILENAME and PATTERN are first case-normalized - if the operating system requires it. - If you don't want this, use fnmatchcase(FILENAME, PATTERN). - """ - - import os - name = os.path.normcase(name) - pat = os.path.normcase(pat) - return fnmatchcase(name, pat) - -def filter(names, pat): - """Return the subset of the list NAMES that match PAT""" - import os,posixpath - result=[] - pat=os.path.normcase(pat) - if not _cache.has_key(pat): - res = translate(pat) - _cache[pat] = re.compile(res) - match=_cache[pat].match - if os.path is posixpath: - # normcase on posix is NOP. Optimize it away from the loop. - for name in names: - if match(name): - result.append(name) - else: - for name in names: - if match(os.path.normcase(name)): - result.append(name) - return result - -def fnmatchcase(name, pat): - """Test whether FILENAME matches PATTERN, including case. - - This is a version of fnmatch() which doesn't case-normalize - its arguments. - """ - - if not _cache.has_key(pat): - res = translate(pat) - _cache[pat] = re.compile(res) - return _cache[pat].match(name) is not None - -def translate(pat): - """Translate a shell PATTERN to a regular expression. - - There is no way to quote meta-characters. - """ - - i, n = 0, len(pat) - res = '' - while i < n: - c = pat[i] - i = i+1 - if c == '*': - res = res + '.*' - elif c == '?': - res = res + '.' - elif c == '[': - j = i - if j < n and pat[j] == '!': - j = j+1 - if j < n and pat[j] == ']': - j = j+1 - while j < n and pat[j] != ']': - j = j+1 - if j >= n: - res = res + '\\[' - else: - stuff = pat[i:j].replace('\\','\\\\') - i = j+1 - if stuff[0] == '!': - stuff = '^' + stuff[1:] - elif stuff[0] == '^': - stuff = '\\' + stuff - res = '%s[%s]' % (res, stuff) - else: - res = res + re.escape(c) - return res + "$" diff --git a/Scripts/ServerPython/python/system/fpformat.py b/Scripts/ServerPython/python/system/fpformat.py deleted file mode 100644 index 21d2489e..00000000 --- a/Scripts/ServerPython/python/system/fpformat.py +++ /dev/null @@ -1,142 +0,0 @@ -"""General floating point formatting functions. - -Functions: -fix(x, digits_behind) -sci(x, digits_behind) - -Each takes a number or a string and a number of digits as arguments. - -Parameters: -x: number to be formatted; or a string resembling a number -digits_behind: number of digits behind the decimal point -""" - -import re - -__all__ = ["fix","sci","NotANumber"] - -# Compiled regular expression to "decode" a number -decoder = re.compile(r'^([-+]?)0*(\d*)((?:\.\d*)?)(([eE][-+]?\d+)?)$') -# \0 the whole thing -# \1 leading sign or empty -# \2 digits left of decimal point -# \3 fraction (empty or begins with point) -# \4 exponent part (empty or begins with 'e' or 'E') - -try: - class NotANumber(ValueError): - pass -except TypeError: - NotANumber = 'fpformat.NotANumber' - -def extract(s): - """Return (sign, intpart, fraction, expo) or raise an exception: - sign is '+' or '-' - intpart is 0 or more digits beginning with a nonzero - fraction is 0 or more digits - expo is an integer""" - res = decoder.match(s) - if res is None: raise NotANumber, s - sign, intpart, fraction, exppart = res.group(1,2,3,4) - if sign == '+': sign = '' - if fraction: fraction = fraction[1:] - if exppart: expo = int(exppart[1:]) - else: expo = 0 - return sign, intpart, fraction, expo - -def unexpo(intpart, fraction, expo): - """Remove the exponent by changing intpart and fraction.""" - if expo > 0: # Move the point left - f = len(fraction) - intpart, fraction = intpart + fraction[:expo], fraction[expo:] - if expo > f: - intpart = intpart + '0'*(expo-f) - elif expo < 0: # Move the point right - i = len(intpart) - intpart, fraction = intpart[:expo], intpart[expo:] + fraction - if expo < -i: - fraction = '0'*(-expo-i) + fraction - return intpart, fraction - -def roundfrac(intpart, fraction, digs): - """Round or extend the fraction to size digs.""" - f = len(fraction) - if f <= digs: - return intpart, fraction + '0'*(digs-f) - i = len(intpart) - if i+digs < 0: - return '0'*-digs, '' - total = intpart + fraction - nextdigit = total[i+digs] - if nextdigit >= '5': # Hard case: increment last digit, may have carry! - n = i + digs - 1 - while n >= 0: - if total[n] != '9': break - n = n-1 - else: - total = '0' + total - i = i+1 - n = 0 - total = total[:n] + chr(ord(total[n]) + 1) + '0'*(len(total)-n-1) - intpart, fraction = total[:i], total[i:] - if digs >= 0: - return intpart, fraction[:digs] - else: - return intpart[:digs] + '0'*-digs, '' - -def fix(x, digs): - """Format x as [-]ddd.ddd with 'digs' digits after the point - and at least one digit before. - If digs <= 0, the point is suppressed.""" - if type(x) != type(''): x = `x` - try: - sign, intpart, fraction, expo = extract(x) - except NotANumber: - return x - intpart, fraction = unexpo(intpart, fraction, expo) - intpart, fraction = roundfrac(intpart, fraction, digs) - while intpart and intpart[0] == '0': intpart = intpart[1:] - if intpart == '': intpart = '0' - if digs > 0: return sign + intpart + '.' + fraction - else: return sign + intpart - -def sci(x, digs): - """Format x as [-]d.dddE[+-]ddd with 'digs' digits after the point - and exactly one digit before. - If digs is <= 0, one digit is kept and the point is suppressed.""" - if type(x) != type(''): x = `x` - sign, intpart, fraction, expo = extract(x) - if not intpart: - while fraction and fraction[0] == '0': - fraction = fraction[1:] - expo = expo - 1 - if fraction: - intpart, fraction = fraction[0], fraction[1:] - expo = expo - 1 - else: - intpart = '0' - else: - expo = expo + len(intpart) - 1 - intpart, fraction = intpart[0], intpart[1:] + fraction - digs = max(0, digs) - intpart, fraction = roundfrac(intpart, fraction, digs) - if len(intpart) > 1: - intpart, fraction, expo = \ - intpart[0], intpart[1:] + fraction[:-1], \ - expo + len(intpart) - 1 - s = sign + intpart - if digs > 0: s = s + '.' + fraction - e = `abs(expo)` - e = '0'*(3-len(e)) + e - if expo < 0: e = '-' + e - else: e = '+' + e - return s + 'e' + e - -def test(): - """Interactive test run.""" - try: - while 1: - x, digs = input('Enter (x, digs): ') - print x, fix(x, digs), sci(x, digs) - except (EOFError, KeyboardInterrupt): - pass diff --git a/Scripts/ServerPython/python/system/getopt.py b/Scripts/ServerPython/python/system/getopt.py deleted file mode 100644 index 961915df..00000000 --- a/Scripts/ServerPython/python/system/getopt.py +++ /dev/null @@ -1,144 +0,0 @@ -"""Parser for command line options. - -This module helps scripts to parse the command line arguments in -sys.argv. It supports the same conventions as the Unix getopt() -function (including the special meanings of arguments of the form `-' -and `--'). Long options similar to those supported by GNU software -may be used as well via an optional third argument. This module -provides a single function and an exception: - -getopt() -- Parse command line options -GetoptError -- exception (class) raised with 'opt' attribute, which is the -option involved with the exception. -""" - -# Long option support added by Lars Wirzenius . - -# Gerrit Holl moved the string-based exceptions -# to class-based exceptions. - -__all__ = ["GetoptError","error","getopt"] - -class GetoptError(Exception): - opt = '' - msg = '' - def __init__(self, msg, opt): - self.msg = msg - self.opt = opt - Exception.__init__(self, msg, opt) - - def __str__(self): - return self.msg - -error = GetoptError # backward compatibility - -def getopt(args, shortopts, longopts = []): - """getopt(args, options[, long_options]) -> opts, args - - Parses command line options and parameter list. args is the - argument list to be parsed, without the leading reference to the - running program. Typically, this means "sys.argv[1:]". shortopts - is the string of option letters that the script wants to - recognize, with options that require an argument followed by a - colon (i.e., the same format that Unix getopt() uses). If - specified, longopts is a list of strings with the names of the - long options which should be supported. The leading '--' - characters should not be included in the option name. Options - which require an argument should be followed by an equal sign - ('='). - - The return value consists of two elements: the first is a list of - (option, value) pairs; the second is the list of program arguments - left after the option list was stripped (this is a trailing slice - of the first argument). Each option-and-value pair returned has - the option as its first element, prefixed with a hyphen (e.g., - '-x'), and the option argument as its second element, or an empty - string if the option has no argument. The options occur in the - list in the same order in which they were found, thus allowing - multiple occurrences. Long and short options may be mixed. - - """ - - opts = [] - if type(longopts) == type(""): - longopts = [longopts] - else: - longopts = list(longopts) - while args and args[0].startswith('-') and args[0] != '-': - if args[0] == '--': - args = args[1:] - break - if args[0].startswith('--'): - opts, args = do_longs(opts, args[0][2:], longopts, args[1:]) - else: - opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:]) - - return opts, args - -def do_longs(opts, opt, longopts, args): - try: - i = opt.index('=') - except ValueError: - optarg = None - else: - opt, optarg = opt[:i], opt[i+1:] - - has_arg, opt = long_has_args(opt, longopts) - if has_arg: - if optarg is None: - if not args: - raise GetoptError('option --%s requires argument' % opt, opt) - optarg, args = args[0], args[1:] - elif optarg: - raise GetoptError('option --%s must not have an argument' % opt, opt) - opts.append(('--' + opt, optarg or '')) - return opts, args - -# Return: -# has_arg? -# full option name -def long_has_args(opt, longopts): - possibilities = [o for o in longopts if o.startswith(opt)] - if not possibilities: - raise GetoptError('option --%s not recognized' % opt, opt) - # Is there an exact match? - if opt in possibilities: - return 0, opt - elif opt + '=' in possibilities: - return 1, opt - # No exact match, so better be unique. - if len(possibilities) > 1: - # XXX since possibilities contains all valid continuations, might be - # nice to work them into the error msg - raise GetoptError('option --%s not a unique prefix' % opt, opt) - assert len(possibilities) == 1 - unique_match = possibilities[0] - has_arg = unique_match.endswith('=') - if has_arg: - unique_match = unique_match[:-1] - return has_arg, unique_match - -def do_shorts(opts, optstring, shortopts, args): - while optstring != '': - opt, optstring = optstring[0], optstring[1:] - if short_has_arg(opt, shortopts): - if optstring == '': - if not args: - raise GetoptError('option -%s requires argument' % opt, - opt) - optstring, args = args[0], args[1:] - optarg, optstring = optstring, '' - else: - optarg = '' - opts.append(('-' + opt, optarg)) - return opts, args - -def short_has_arg(opt, shortopts): - for i in range(len(shortopts)): - if opt == shortopts[i] != ':': - return shortopts.startswith(':', i+1) - raise GetoptError('option -%s not recognized' % opt, opt) - -if __name__ == '__main__': - import sys - print getopt(sys.argv[1:], "a:b", ["alpha=", "beta"]) diff --git a/Scripts/ServerPython/python/system/gettext.py b/Scripts/ServerPython/python/system/gettext.py deleted file mode 100644 index afa50ef9..00000000 --- a/Scripts/ServerPython/python/system/gettext.py +++ /dev/null @@ -1,304 +0,0 @@ -"""Internationalization and localization support. - -This module provides internationalization (I18N) and localization (L10N) -support for your Python programs by providing an interface to the GNU gettext -message catalog library. - -I18N refers to the operation by which a program is made aware of multiple -languages. L10N refers to the adaptation of your program, once -internationalized, to the local language and cultural habits. - -""" - -# This module represents the integration of work, contributions, feedback, and -# suggestions from the following people: -# -# Martin von Loewis, who wrote the initial implementation of the underlying -# C-based libintlmodule (later renamed _gettext), along with a skeletal -# gettext.py implementation. -# -# Peter Funk, who wrote fintl.py, a fairly complete wrapper around intlmodule, -# which also included a pure-Python implementation to read .mo files if -# intlmodule wasn't available. -# -# James Henstridge, who also wrote a gettext.py module, which has some -# interesting, but currently unsupported experimental features: the notion of -# a Catalog class and instances, and the ability to add to a catalog file via -# a Python API. -# -# Barry Warsaw integrated these modules, wrote the .install() API and code, -# and conformed all C and Python code to Python's coding standards. -# -# Francois Pinard and Marc-Andre Lemburg also contributed valuably to this -# module. -# -# TODO: -# - Lazy loading of .mo files. Currently the entire catalog is loaded into -# memory, but that's probably bad for large translated programs. Instead, -# the lexical sort of original strings in GNU .mo files should be exploited -# to do binary searches and lazy initializations. Or you might want to use -# the undocumented double-hash algorithm for .mo files with hash tables, but -# you'll need to study the GNU gettext code to do this. -# -# - Support Solaris .mo file formats. Unfortunately, we've been unable to -# find this format documented anywhere. - -import os -import sys -import struct -from errno import ENOENT - -__all__ = ["bindtextdomain","textdomain","gettext","dgettext", - "find","translation","install","Catalog"] - -_default_localedir = os.path.join(sys.prefix, 'share', 'locale') - - - -def _expand_lang(locale): - from locale import normalize - locale = normalize(locale) - COMPONENT_CODESET = 1 << 0 - COMPONENT_TERRITORY = 1 << 1 - COMPONENT_MODIFIER = 1 << 2 - # split up the locale into its base components - mask = 0 - pos = locale.find('@') - if pos >= 0: - modifier = locale[pos:] - locale = locale[:pos] - mask |= COMPONENT_MODIFIER - else: - modifier = '' - pos = locale.find('.') - if pos >= 0: - codeset = locale[pos:] - locale = locale[:pos] - mask |= COMPONENT_CODESET - else: - codeset = '' - pos = locale.find('_') - if pos >= 0: - territory = locale[pos:] - locale = locale[:pos] - mask |= COMPONENT_TERRITORY - else: - territory = '' - language = locale - ret = [] - for i in range(mask+1): - if not (i & ~mask): # if all components for this combo exist ... - val = language - if i & COMPONENT_TERRITORY: val += territory - if i & COMPONENT_CODESET: val += codeset - if i & COMPONENT_MODIFIER: val += modifier - ret.append(val) - ret.reverse() - return ret - - - -class NullTranslations: - def __init__(self, fp=None): - self._info = {} - self._charset = None - if fp: - self._parse(fp) - - def _parse(self, fp): - pass - - def gettext(self, message): - return message - - def ugettext(self, message): - return unicode(message) - - def info(self): - return self._info - - def charset(self): - return self._charset - - def install(self, unicode=0): - import __builtin__ - __builtin__.__dict__['_'] = unicode and self.ugettext or self.gettext - - -class GNUTranslations(NullTranslations): - # Magic number of .mo files - LE_MAGIC = 0x950412de - BE_MAGIC = 0xde120495 - - def _parse(self, fp): - """Override this method to support alternative .mo formats.""" - # We need to & all 32 bit unsigned integers with 0xffffffff for - # portability to 64 bit machines. - MASK = 0xffffffff - unpack = struct.unpack - filename = getattr(fp, 'name', '') - # Parse the .mo file header, which consists of 5 little endian 32 - # bit words. - self._catalog = catalog = {} - buf = fp.read() - buflen = len(buf) - # Are we big endian or little endian? - magic = unpack('4i', buf[4:20]) - ii = '>ii' - else: - raise IOError(0, 'Bad magic number', filename) - # more unsigned ints - msgcount &= MASK - masteridx &= MASK - transidx &= MASK - # Now put all messages from the .mo file buffer into the catalog - # dictionary. - for i in xrange(0, msgcount): - mlen, moff = unpack(ii, buf[masteridx:masteridx+8]) - moff &= MASK - mend = moff + (mlen & MASK) - tlen, toff = unpack(ii, buf[transidx:transidx+8]) - toff &= MASK - tend = toff + (tlen & MASK) - if mend < buflen and tend < buflen: - tmsg = buf[toff:tend] - catalog[buf[moff:mend]] = tmsg - else: - raise IOError(0, 'File is corrupt', filename) - # See if we're looking at GNU .mo conventions for metadata - if mlen == 0 and tmsg.lower().startswith('project-id-version:'): - # Catalog description - for item in tmsg.split('\n'): - item = item.strip() - if not item: - continue - k, v = item.split(':', 1) - k = k.strip().lower() - v = v.strip() - self._info[k] = v - if k == 'content-type': - self._charset = v.split('charset=')[1] - # advance to next entry in the seek tables - masteridx += 8 - transidx += 8 - - def gettext(self, message): - return self._catalog.get(message, message) - - def ugettext(self, message): - tmsg = self._catalog.get(message, message) - return unicode(tmsg, self._charset) - - - -# Locate a .mo file using the gettext strategy -def find(domain, localedir=None, languages=None): - # Get some reasonable defaults for arguments that were not supplied - if localedir is None: - localedir = _default_localedir - if languages is None: - languages = [] - for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'): - val = os.environ.get(envar) - if val: - languages = val.split(':') - break - if 'C' not in languages: - languages.append('C') - # now normalize and expand the languages - nelangs = [] - for lang in languages: - for nelang in _expand_lang(lang): - if nelang not in nelangs: - nelangs.append(nelang) - # select a language - for lang in nelangs: - if lang == 'C': - break - mofile = os.path.join(localedir, lang, 'LC_MESSAGES', '%s.mo' % domain) - if os.path.exists(mofile): - return mofile - return None - - - -# a mapping between absolute .mo file path and Translation object -_translations = {} - -def translation(domain, localedir=None, languages=None, - class_=None, fallback=0): - if class_ is None: - class_ = GNUTranslations - mofile = find(domain, localedir, languages) - if mofile is None: - if fallback: - return NullTranslations() - raise IOError(ENOENT, 'No translation file found for domain', domain) - key = os.path.abspath(mofile) - # TBD: do we need to worry about the file pointer getting collected? - # Avoid opening, reading, and parsing the .mo file after it's been done - # once. - t = _translations.get(key) - if t is None: - t = _translations.setdefault(key, class_(open(mofile, 'rb'))) - return t - - - -def install(domain, localedir=None, unicode=0): - translation(domain, localedir, fallback=1).install(unicode) - - - -# a mapping b/w domains and locale directories -_localedirs = {} -# current global domain, `messages' used for compatibility w/ GNU gettext -_current_domain = 'messages' - - -def textdomain(domain=None): - global _current_domain - if domain is not None: - _current_domain = domain - return _current_domain - - -def bindtextdomain(domain, localedir=None): - global _localedirs - if localedir is not None: - _localedirs[domain] = localedir - return _localedirs.get(domain, _default_localedir) - - -def dgettext(domain, message): - try: - t = translation(domain, _localedirs.get(domain, None)) - except IOError: - return message - return t.gettext(message) - - -def gettext(message): - return dgettext(_current_domain, message) - - -# dcgettext() has been deemed unnecessary and is not implemented. - -# James Henstridge's Catalog constructor from GNOME gettext. Documented usage -# was: -# -# import gettext -# cat = gettext.Catalog(PACKAGE, localedir=LOCALEDIR) -# _ = cat.gettext -# print _('Hello World') - -# The resulting catalog object currently don't support access through a -# dictionary API, which was supported (but apparently unused) in GNOME -# gettext. - -Catalog = translation diff --git a/Scripts/ServerPython/python/system/glob.py b/Scripts/ServerPython/python/system/glob.py deleted file mode 100644 index 62fd8f5f..00000000 --- a/Scripts/ServerPython/python/system/glob.py +++ /dev/null @@ -1,56 +0,0 @@ -"""Filename globbing utility.""" - -import os -import fnmatch -import re - -__all__ = ["glob"] - -def glob(pathname): - """Return a list of paths matching a pathname pattern. - - The pattern may contain simple shell-style wildcards a la fnmatch. - - """ - if not has_magic(pathname): - if os.path.exists(pathname): - return [pathname] - else: - return [] - dirname, basename = os.path.split(pathname) - if not dirname: - return glob1(os.curdir, basename) - elif has_magic(dirname): - list = glob(dirname) - else: - list = [dirname] - if not has_magic(basename): - result = [] - for dirname in list: - if basename or os.path.isdir(dirname): - name = os.path.join(dirname, basename) - if os.path.exists(name): - result.append(name) - else: - result = [] - for dirname in list: - sublist = glob1(dirname, basename) - for name in sublist: - result.append(os.path.join(dirname, name)) - return result - -def glob1(dirname, pattern): - if not dirname: dirname = os.curdir - try: - names = os.listdir(dirname) - except os.error: - return [] - if pattern[0]!='.': - names=filter(lambda x: x[0]!='.',names) - return fnmatch.filter(names,pattern) - - -magic_check = re.compile('[*?[]') - -def has_magic(s): - return magic_check.search(s) is not None diff --git a/Scripts/ServerPython/python/system/ihooks.py b/Scripts/ServerPython/python/system/ihooks.py deleted file mode 100644 index fa58cda2..00000000 --- a/Scripts/ServerPython/python/system/ihooks.py +++ /dev/null @@ -1,511 +0,0 @@ -"""Import hook support. - -Consistent use of this module will make it possible to change the -different mechanisms involved in loading modules independently. - -While the built-in module imp exports interfaces to the built-in -module searching and loading algorithm, and it is possible to replace -the built-in function __import__ in order to change the semantics of -the import statement, until now it has been difficult to combine the -effect of different __import__ hacks, like loading modules from URLs -by rimport.py, or restricted execution by rexec.py. - -This module defines three new concepts: - -1) A "file system hooks" class provides an interface to a filesystem. - -One hooks class is defined (Hooks), which uses the interface provided -by standard modules os and os.path. It should be used as the base -class for other hooks classes. - -2) A "module loader" class provides an interface to to search for a -module in a search path and to load it. It defines a method which -searches for a module in a single directory; by overriding this method -one can redefine the details of the search. If the directory is None, -built-in and frozen modules are searched instead. - -Two module loader class are defined, both implementing the search -strategy used by the built-in __import__ function: ModuleLoader uses -the imp module's find_module interface, while HookableModuleLoader -uses a file system hooks class to interact with the file system. Both -use the imp module's load_* interfaces to actually load the module. - -3) A "module importer" class provides an interface to import a -module, as well as interfaces to reload and unload a module. It also -provides interfaces to install and uninstall itself instead of the -default __import__ and reload (and unload) functions. - -One module importer class is defined (ModuleImporter), which uses a -module loader instance passed in (by default HookableModuleLoader is -instantiated). - -The classes defined here should be used as base classes for extended -functionality along those lines. - -If a module importer class supports dotted names, its import_module() -must return a different value depending on whether it is called on -behalf of a "from ... import ..." statement or not. (This is caused -by the way the __import__ hook is used by the Python interpreter.) It -would also do wise to install a different version of reload(). - -""" - - -import __builtin__ -import imp -import os -import sys - -__all__ = ["BasicModuleLoader","Hooks","ModuleLoader","FancyModuleLoader", - "BasicModuleImporter","ModuleImporter","install","uninstall"] - -VERBOSE = 0 - - -from imp import C_EXTENSION, PY_SOURCE, PY_COMPILED -from imp import C_BUILTIN, PY_FROZEN, PKG_DIRECTORY -BUILTIN_MODULE = C_BUILTIN -FROZEN_MODULE = PY_FROZEN - - -class _Verbose: - - def __init__(self, verbose = VERBOSE): - self.verbose = verbose - - def get_verbose(self): - return self.verbose - - def set_verbose(self, verbose): - self.verbose = verbose - - # XXX The following is an experimental interface - - def note(self, *args): - if self.verbose: - apply(self.message, args) - - def message(self, format, *args): - if args: - print format%args - else: - print format - - -class BasicModuleLoader(_Verbose): - - """Basic module loader. - - This provides the same functionality as built-in import. It - doesn't deal with checking sys.modules -- all it provides is - find_module() and a load_module(), as well as find_module_in_dir() - which searches just one directory, and can be overridden by a - derived class to change the module search algorithm when the basic - dependency on sys.path is unchanged. - - The interface is a little more convenient than imp's: - find_module(name, [path]) returns None or 'stuff', and - load_module(name, stuff) loads the module. - - """ - - def find_module(self, name, path = None): - if path is None: - path = [None] + self.default_path() - for dir in path: - stuff = self.find_module_in_dir(name, dir) - if stuff: return stuff - return None - - def default_path(self): - return sys.path - - def find_module_in_dir(self, name, dir): - if dir is None: - return self.find_builtin_module(name) - else: - try: - return imp.find_module(name, [dir]) - except ImportError: - return None - - def find_builtin_module(self, name): - # XXX frozen packages? - if imp.is_builtin(name): - return None, '', ('', '', BUILTIN_MODULE) - if imp.is_frozen(name): - return None, '', ('', '', FROZEN_MODULE) - return None - - def load_module(self, name, stuff): - file, filename, info = stuff - try: - return imp.load_module(name, file, filename, info) - finally: - if file: file.close() - - -class Hooks(_Verbose): - - """Hooks into the filesystem and interpreter. - - By deriving a subclass you can redefine your filesystem interface, - e.g. to merge it with the URL space. - - This base class behaves just like the native filesystem. - - """ - - # imp interface - def get_suffixes(self): return imp.get_suffixes() - def new_module(self, name): return imp.new_module(name) - def is_builtin(self, name): return imp.is_builtin(name) - def init_builtin(self, name): return imp.init_builtin(name) - def is_frozen(self, name): return imp.is_frozen(name) - def init_frozen(self, name): return imp.init_frozen(name) - def get_frozen_object(self, name): return imp.get_frozen_object(name) - def load_source(self, name, filename, file=None): - return imp.load_source(name, filename, file) - def load_compiled(self, name, filename, file=None): - return imp.load_compiled(name, filename, file) - def load_dynamic(self, name, filename, file=None): - return imp.load_dynamic(name, filename, file) - def load_package(self, name, filename, file=None): - return imp.load_module(name, file, filename, ("", "", PKG_DIRECTORY)) - - def add_module(self, name): - d = self.modules_dict() - if d.has_key(name): return d[name] - d[name] = m = self.new_module(name) - return m - - # sys interface - def modules_dict(self): return sys.modules - def default_path(self): return sys.path - - def path_split(self, x): return os.path.split(x) - def path_join(self, x, y): return os.path.join(x, y) - def path_isabs(self, x): return os.path.isabs(x) - # etc. - - def path_exists(self, x): return os.path.exists(x) - def path_isdir(self, x): return os.path.isdir(x) - def path_isfile(self, x): return os.path.isfile(x) - def path_islink(self, x): return os.path.islink(x) - # etc. - - def openfile(self, *x): return apply(open, x) - openfile_error = IOError - def listdir(self, x): return os.listdir(x) - listdir_error = os.error - # etc. - - -class ModuleLoader(BasicModuleLoader): - - """Default module loader; uses file system hooks. - - By defining suitable hooks, you might be able to load modules from - other sources than the file system, e.g. from compressed or - encrypted files, tar files or (if you're brave!) URLs. - - """ - - def __init__(self, hooks = None, verbose = VERBOSE): - BasicModuleLoader.__init__(self, verbose) - self.hooks = hooks or Hooks(verbose) - - def default_path(self): - return self.hooks.default_path() - - def modules_dict(self): - return self.hooks.modules_dict() - - def get_hooks(self): - return self.hooks - - def set_hooks(self, hooks): - self.hooks = hooks - - def find_builtin_module(self, name): - # XXX frozen packages? - if self.hooks.is_builtin(name): - return None, '', ('', '', BUILTIN_MODULE) - if self.hooks.is_frozen(name): - return None, '', ('', '', FROZEN_MODULE) - return None - - def find_module_in_dir(self, name, dir, allow_packages=1): - if dir is None: - return self.find_builtin_module(name) - if allow_packages: - fullname = self.hooks.path_join(dir, name) - if self.hooks.path_isdir(fullname): - stuff = self.find_module_in_dir("__init__", fullname, 0) - if stuff: - file = stuff[0] - if file: file.close() - return None, fullname, ('', '', PKG_DIRECTORY) - for info in self.hooks.get_suffixes(): - suff, mode, type = info - fullname = self.hooks.path_join(dir, name+suff) - try: - fp = self.hooks.openfile(fullname, mode) - return fp, fullname, info - except self.hooks.openfile_error: - pass - return None - - def load_module(self, name, stuff): - file, filename, info = stuff - (suff, mode, type) = info - try: - if type == BUILTIN_MODULE: - return self.hooks.init_builtin(name) - if type == FROZEN_MODULE: - return self.hooks.init_frozen(name) - if type == C_EXTENSION: - m = self.hooks.load_dynamic(name, filename, file) - elif type == PY_SOURCE: - m = self.hooks.load_source(name, filename, file) - elif type == PY_COMPILED: - m = self.hooks.load_compiled(name, filename, file) - elif type == PKG_DIRECTORY: - m = self.hooks.load_package(name, filename, file) - else: - raise ImportError, "Unrecognized module type (%s) for %s" % \ - (`type`, name) - finally: - if file: file.close() - m.__file__ = filename - return m - - -class FancyModuleLoader(ModuleLoader): - - """Fancy module loader -- parses and execs the code itself.""" - - def load_module(self, name, stuff): - file, filename, (suff, mode, type) = stuff - realfilename = filename - path = None - - if type == PKG_DIRECTORY: - initstuff = self.find_module_in_dir("__init__", filename, 0) - if not initstuff: - raise ImportError, "No __init__ module in package %s" % name - initfile, initfilename, initinfo = initstuff - initsuff, initmode, inittype = initinfo - if inittype not in (PY_COMPILED, PY_SOURCE): - if initfile: initfile.close() - raise ImportError, \ - "Bad type (%s) for __init__ module in package %s" % ( - `inittype`, name) - path = [filename] - file = initfile - realfilename = initfilename - type = inittype - - if type == FROZEN_MODULE: - code = self.hooks.get_frozen_object(name) - elif type == PY_COMPILED: - import marshal - file.seek(8) - code = marshal.load(file) - elif type == PY_SOURCE: - data = file.read() - code = compile(data, realfilename, 'exec') - else: - return ModuleLoader.load_module(self, name, stuff) - - m = self.hooks.add_module(name) - if path: - m.__path__ = path - m.__file__ = filename - exec code in m.__dict__ - return m - - -class BasicModuleImporter(_Verbose): - - """Basic module importer; uses module loader. - - This provides basic import facilities but no package imports. - - """ - - def __init__(self, loader = None, verbose = VERBOSE): - _Verbose.__init__(self, verbose) - self.loader = loader or ModuleLoader(None, verbose) - self.modules = self.loader.modules_dict() - - def get_loader(self): - return self.loader - - def set_loader(self, loader): - self.loader = loader - - def get_hooks(self): - return self.loader.get_hooks() - - def set_hooks(self, hooks): - return self.loader.set_hooks(hooks) - - def import_module(self, name, globals={}, locals={}, fromlist=[]): - if self.modules.has_key(name): - return self.modules[name] # Fast path - stuff = self.loader.find_module(name) - if not stuff: - raise ImportError, "No module named %s" % name - return self.loader.load_module(name, stuff) - - def reload(self, module, path = None): - name = module.__name__ - stuff = self.loader.find_module(name, path) - if not stuff: - raise ImportError, "Module %s not found for reload" % name - return self.loader.load_module(name, stuff) - - def unload(self, module): - del self.modules[module.__name__] - # XXX Should this try to clear the module's namespace? - - def install(self): - self.save_import_module = __builtin__.__import__ - self.save_reload = __builtin__.reload - if not hasattr(__builtin__, 'unload'): - __builtin__.unload = None - self.save_unload = __builtin__.unload - __builtin__.__import__ = self.import_module - __builtin__.reload = self.reload - __builtin__.unload = self.unload - - def uninstall(self): - __builtin__.__import__ = self.save_import_module - __builtin__.reload = self.save_reload - __builtin__.unload = self.save_unload - if not __builtin__.unload: - del __builtin__.unload - - -class ModuleImporter(BasicModuleImporter): - - """A module importer that supports packages.""" - - def import_module(self, name, globals=None, locals=None, fromlist=None): - parent = self.determine_parent(globals) - q, tail = self.find_head_package(parent, name) - m = self.load_tail(q, tail) - if not fromlist: - return q - if hasattr(m, "__path__"): - self.ensure_fromlist(m, fromlist) - return m - - def determine_parent(self, globals): - if not globals or not globals.has_key("__name__"): - return None - pname = globals['__name__'] - if globals.has_key("__path__"): - parent = self.modules[pname] - assert globals is parent.__dict__ - return parent - if '.' in pname: - i = pname.rfind('.') - pname = pname[:i] - parent = self.modules[pname] - assert parent.__name__ == pname - return parent - return None - - def find_head_package(self, parent, name): - if '.' in name: - i = name.find('.') - head = name[:i] - tail = name[i+1:] - else: - head = name - tail = "" - if parent: - qname = "%s.%s" % (parent.__name__, head) - else: - qname = head - q = self.import_it(head, qname, parent) - if q: return q, tail - if parent: - qname = head - parent = None - q = self.import_it(head, qname, parent) - if q: return q, tail - raise ImportError, "No module named " + qname - - def load_tail(self, q, tail): - m = q - while tail: - i = tail.find('.') - if i < 0: i = len(tail) - head, tail = tail[:i], tail[i+1:] - mname = "%s.%s" % (m.__name__, head) - m = self.import_it(head, mname, m) - if not m: - raise ImportError, "No module named " + mname - return m - - def ensure_fromlist(self, m, fromlist, recursive=0): - for sub in fromlist: - if sub == "*": - if not recursive: - try: - all = m.__all__ - except AttributeError: - pass - else: - self.ensure_fromlist(m, all, 1) - continue - if sub != "*" and not hasattr(m, sub): - subname = "%s.%s" % (m.__name__, sub) - submod = self.import_it(sub, subname, m) - if not submod: - raise ImportError, "No module named " + subname - - def import_it(self, partname, fqname, parent, force_load=0): - if not partname: - raise ValueError, "Empty module name" - if not force_load: - try: - return self.modules[fqname] - except KeyError: - pass - try: - path = parent and parent.__path__ - except AttributeError: - return None - stuff = self.loader.find_module(partname, path) - if not stuff: - return None - m = self.loader.load_module(fqname, stuff) - if parent: - setattr(parent, partname, m) - return m - - def reload(self, module): - name = module.__name__ - if '.' not in name: - return self.import_it(name, name, None, force_load=1) - i = name.rfind('.') - pname = name[:i] - parent = self.modules[pname] - return self.import_it(name[i+1:], name, parent, force_load=1) - - -default_importer = None -current_importer = None - -def install(importer = None): - global current_importer - current_importer = importer or default_importer or ModuleImporter() - current_importer.install() - -def uninstall(): - global current_importer - current_importer.uninstall() diff --git a/Scripts/ServerPython/python/system/imghdr.py b/Scripts/ServerPython/python/system/imghdr.py deleted file mode 100644 index 5fd57817..00000000 --- a/Scripts/ServerPython/python/system/imghdr.py +++ /dev/null @@ -1,154 +0,0 @@ -"""Recognize image file formats based on their first few bytes.""" - -__all__ = ["what"] - -#-------------------------# -# Recognize image headers # -#-------------------------# - -def what(file, h=None): - if h is None: - if type(file) == type(''): - f = open(file, 'rb') - h = f.read(32) - else: - location = file.tell() - h = file.read(32) - file.seek(location) - f = None - else: - f = None - try: - for tf in tests: - res = tf(h, f) - if res: - return res - finally: - if f: f.close() - return None - - -#---------------------------------# -# Subroutines per image file type # -#---------------------------------# - -tests = [] - -def test_rgb(h, f): - """SGI image library""" - if h[:2] == '\001\332': - return 'rgb' - -tests.append(test_rgb) - -def test_gif(h, f): - """GIF ('87 and '89 variants)""" - if h[:6] in ('GIF87a', 'GIF89a'): - return 'gif' - -tests.append(test_gif) - -def test_pbm(h, f): - """PBM (portable bitmap)""" - if len(h) >= 3 and \ - h[0] == 'P' and h[1] in '14' and h[2] in ' \t\n\r': - return 'pbm' - -tests.append(test_pbm) - -def test_pgm(h, f): - """PGM (portable graymap)""" - if len(h) >= 3 and \ - h[0] == 'P' and h[1] in '25' and h[2] in ' \t\n\r': - return 'pgm' - -tests.append(test_pgm) - -def test_ppm(h, f): - """PPM (portable pixmap)""" - if len(h) >= 3 and \ - h[0] == 'P' and h[1] in '36' and h[2] in ' \t\n\r': - return 'ppm' - -tests.append(test_ppm) - -def test_tiff(h, f): - """TIFF (can be in Motorola or Intel byte order)""" - if h[:2] in ('MM', 'II'): - return 'tiff' - -tests.append(test_tiff) - -def test_rast(h, f): - """Sun raster file""" - if h[:4] == '\x59\xA6\x6A\x95': - return 'rast' - -tests.append(test_rast) - -def test_xbm(h, f): - """X bitmap (X10 or X11)""" - s = '#define ' - if h[:len(s)] == s: - return 'xbm' - -tests.append(test_xbm) - -def test_jpeg(h, f): - """JPEG data in JFIF format""" - if h[6:10] == 'JFIF': - return 'jpeg' - -tests.append(test_jpeg) - -def test_bmp(h, f): - if h[:2] == 'BM': - return 'bmp' - -tests.append(test_bmp) - -def test_png(h, f): - if h[:8] == "\211PNG\r\n\032\n": - return 'png' - -tests.append(test_png) - -#--------------------# -# Small test program # -#--------------------# - -def test(): - import sys - recursive = 0 - if sys.argv[1:] and sys.argv[1] == '-r': - del sys.argv[1:2] - recursive = 1 - try: - if sys.argv[1:]: - testall(sys.argv[1:], recursive, 1) - else: - testall(['.'], recursive, 1) - except KeyboardInterrupt: - sys.stderr.write('\n[Interrupted]\n') - sys.exit(1) - -def testall(list, recursive, toplevel): - import sys - import os - for filename in list: - if os.path.isdir(filename): - print filename + '/:', - if recursive or toplevel: - print 'recursing down:' - import glob - names = glob.glob(os.path.join(filename, '*')) - testall(names, recursive, 0) - else: - print '*** directory (use -r) ***' - else: - print filename + ':', - sys.stdout.flush() - try: - print what(filename) - except IOError: - print '*** not found ***' diff --git a/Scripts/ServerPython/python/system/imputil.py b/Scripts/ServerPython/python/system/imputil.py deleted file mode 100644 index 2628e19c..00000000 --- a/Scripts/ServerPython/python/system/imputil.py +++ /dev/null @@ -1,720 +0,0 @@ -""" -Import utilities - -Exported classes: - ImportManager Manage the import process - - Importer Base class for replacing standard import functions - BuiltinImporter Emulate the import mechanism for builtin and frozen modules - - DynLoadSuffixImporter -""" - -# note: avoid importing non-builtin modules -import imp ### not available in JPython? -import sys -import __builtin__ - -# for the DirectoryImporter -import struct -import marshal - -__all__ = ["ImportManager","Importer","BuiltinImporter"] - -_StringType = type('') -_ModuleType = type(sys) ### doesn't work in JPython... - -class ImportManager: - "Manage the import process." - - def install(self, namespace=vars(__builtin__)): - "Install this ImportManager into the specified namespace." - - if isinstance(namespace, _ModuleType): - namespace = vars(namespace) - - # Note: we have no notion of "chaining" - - # Record the previous import hook, then install our own. - self.previous_importer = namespace['__import__'] - self.namespace = namespace - namespace['__import__'] = self._import_hook - - ### fix this - #namespace['reload'] = self._reload_hook - - def uninstall(self): - "Restore the previous import mechanism." - self.namespace['__import__'] = self.previous_importer - - def add_suffix(self, suffix, importFunc): - assert callable(importFunc) - self.fs_imp.add_suffix(suffix, importFunc) - - ###################################################################### - # - # PRIVATE METHODS - # - - clsFilesystemImporter = None - - def __init__(self, fs_imp=None): - # we're definitely going to be importing something in the future, - # so let's just load the OS-related facilities. - if not _os_stat: - _os_bootstrap() - - # This is the Importer that we use for grabbing stuff from the - # filesystem. It defines one more method (import_from_dir) for our use. - if not fs_imp: - cls = self.clsFilesystemImporter or _FilesystemImporter - fs_imp = cls() - self.fs_imp = fs_imp - - # Initialize the set of suffixes that we recognize and import. - # The default will import dynamic-load modules first, followed by - # .py files (or a .py file's cached bytecode) - for desc in imp.get_suffixes(): - if desc[2] == imp.C_EXTENSION: - self.add_suffix(desc[0], - DynLoadSuffixImporter(desc).import_file) - self.add_suffix('.py', py_suffix_importer) - - def _import_hook(self, fqname, globals=None, locals=None, fromlist=None): - """Python calls this hook to locate and import a module.""" - - parts = fqname.split('.') - - # determine the context of this import - parent = self._determine_import_context(globals) - - # if there is a parent, then its importer should manage this import - if parent: - module = parent.__importer__._do_import(parent, parts, fromlist) - if module: - return module - - # has the top module already been imported? - try: - top_module = sys.modules[parts[0]] - except KeyError: - - # look for the topmost module - top_module = self._import_top_module(parts[0]) - if not top_module: - # the topmost module wasn't found at all. - raise ImportError, 'No module named ' + fqname - - # fast-path simple imports - if len(parts) == 1: - if not fromlist: - return top_module - - if not top_module.__dict__.get('__ispkg__'): - # __ispkg__ isn't defined (the module was not imported by us), - # or it is zero. - # - # In the former case, there is no way that we could import - # sub-modules that occur in the fromlist (but we can't raise an - # error because it may just be names) because we don't know how - # to deal with packages that were imported by other systems. - # - # In the latter case (__ispkg__ == 0), there can't be any sub- - # modules present, so we can just return. - # - # In both cases, since len(parts) == 1, the top_module is also - # the "bottom" which is the defined return when a fromlist - # exists. - return top_module - - importer = top_module.__dict__.get('__importer__') - if importer: - return importer._finish_import(top_module, parts[1:], fromlist) - - # Grrr, some people "import os.path" - if len(parts) == 2 and hasattr(top_module, parts[1]): - return top_module - - # If the importer does not exist, then we have to bail. A missing - # importer means that something else imported the module, and we have - # no knowledge of how to get sub-modules out of the thing. - raise ImportError, 'No module named ' + fqname - - def _determine_import_context(self, globals): - """Returns the context in which a module should be imported. - - The context could be a loaded (package) module and the imported module - will be looked for within that package. The context could also be None, - meaning there is no context -- the module should be looked for as a - "top-level" module. - """ - - if not globals or not globals.get('__importer__'): - # globals does not refer to one of our modules or packages. That - # implies there is no relative import context (as far as we are - # concerned), and it should just pick it off the standard path. - return None - - # The globals refer to a module or package of ours. It will define - # the context of the new import. Get the module/package fqname. - parent_fqname = globals['__name__'] - - # if a package is performing the import, then return itself (imports - # refer to pkg contents) - if globals['__ispkg__']: - parent = sys.modules[parent_fqname] - assert globals is parent.__dict__ - return parent - - i = parent_fqname.rfind('.') - - # a module outside of a package has no particular import context - if i == -1: - return None - - # if a module in a package is performing the import, then return the - # package (imports refer to siblings) - parent_fqname = parent_fqname[:i] - parent = sys.modules[parent_fqname] - assert parent.__name__ == parent_fqname - return parent - - def _import_top_module(self, name): - # scan sys.path looking for a location in the filesystem that contains - # the module, or an Importer object that can import the module. - for item in sys.path: - if isinstance(item, _StringType): - module = self.fs_imp.import_from_dir(item, name) - else: - module = item.import_top(name) - if module: - return module - return None - - def _reload_hook(self, module): - "Python calls this hook to reload a module." - - # reloading of a module may or may not be possible (depending on the - # importer), but at least we can validate that it's ours to reload - importer = module.__dict__.get('__importer__') - if not importer: - ### oops. now what... - pass - - # okay. it is using the imputil system, and we must delegate it, but - # we don't know what to do (yet) - ### we should blast the module dict and do another get_code(). need to - ### flesh this out and add proper docco... - raise SystemError, "reload not yet implemented" - - -class Importer: - "Base class for replacing standard import functions." - - def import_top(self, name): - "Import a top-level module." - return self._import_one(None, name, name) - - ###################################################################### - # - # PRIVATE METHODS - # - def _finish_import(self, top, parts, fromlist): - # if "a.b.c" was provided, then load the ".b.c" portion down from - # below the top-level module. - bottom = self._load_tail(top, parts) - - # if the form is "import a.b.c", then return "a" - if not fromlist: - # no fromlist: return the top of the import tree - return top - - # the top module was imported by self. - # - # this means that the bottom module was also imported by self (just - # now, or in the past and we fetched it from sys.modules). - # - # since we imported/handled the bottom module, this means that we can - # also handle its fromlist (and reliably use __ispkg__). - - # if the bottom node is a package, then (potentially) import some - # modules. - # - # note: if it is not a package, then "fromlist" refers to names in - # the bottom module rather than modules. - # note: for a mix of names and modules in the fromlist, we will - # import all modules and insert those into the namespace of - # the package module. Python will pick up all fromlist names - # from the bottom (package) module; some will be modules that - # we imported and stored in the namespace, others are expected - # to be present already. - if bottom.__ispkg__: - self._import_fromlist(bottom, fromlist) - - # if the form is "from a.b import c, d" then return "b" - return bottom - - def _import_one(self, parent, modname, fqname): - "Import a single module." - - # has the module already been imported? - try: - return sys.modules[fqname] - except KeyError: - pass - - # load the module's code, or fetch the module itself - result = self.get_code(parent, modname, fqname) - if result is None: - return None - - module = self._process_result(result, fqname) - - # insert the module into its parent - if parent: - setattr(parent, modname, module) - return module - - def _process_result(self, (ispkg, code, values), fqname): - # did get_code() return an actual module? (rather than a code object) - is_module = isinstance(code, _ModuleType) - - # use the returned module, or create a new one to exec code into - if is_module: - module = code - else: - module = imp.new_module(fqname) - - ### record packages a bit differently?? - module.__importer__ = self - module.__ispkg__ = ispkg - - # insert additional values into the module (before executing the code) - module.__dict__.update(values) - - # the module is almost ready... make it visible - sys.modules[fqname] = module - - # execute the code within the module's namespace - if not is_module: - exec code in module.__dict__ - - # fetch from sys.modules instead of returning module directly. - # also make module's __name__ agree with fqname, in case - # the "exec code in module.__dict__" played games on us. - module = sys.modules[fqname] - module.__name__ = fqname - return module - - def _load_tail(self, m, parts): - """Import the rest of the modules, down from the top-level module. - - Returns the last module in the dotted list of modules. - """ - for part in parts: - fqname = "%s.%s" % (m.__name__, part) - m = self._import_one(m, part, fqname) - if not m: - raise ImportError, "No module named " + fqname - return m - - def _import_fromlist(self, package, fromlist): - 'Import any sub-modules in the "from" list.' - - # if '*' is present in the fromlist, then look for the '__all__' - # variable to find additional items (modules) to import. - if '*' in fromlist: - fromlist = list(fromlist) + \ - list(package.__dict__.get('__all__', [])) - - for sub in fromlist: - # if the name is already present, then don't try to import it (it - # might not be a module!). - if sub != '*' and not hasattr(package, sub): - subname = "%s.%s" % (package.__name__, sub) - submod = self._import_one(package, sub, subname) - if not submod: - raise ImportError, "cannot import name " + subname - - def _do_import(self, parent, parts, fromlist): - """Attempt to import the module relative to parent. - - This method is used when the import context specifies that - imported the parent module. - """ - top_name = parts[0] - top_fqname = parent.__name__ + '.' + top_name - top_module = self._import_one(parent, top_name, top_fqname) - if not top_module: - # this importer and parent could not find the module (relatively) - return None - - return self._finish_import(top_module, parts[1:], fromlist) - - ###################################################################### - # - # METHODS TO OVERRIDE - # - def get_code(self, parent, modname, fqname): - """Find and retrieve the code for the given module. - - parent specifies a parent module to define a context for importing. It - may be None, indicating no particular context for the search. - - modname specifies a single module (not dotted) within the parent. - - fqname specifies the fully-qualified module name. This is a - (potentially) dotted name from the "root" of the module namespace - down to the modname. - If there is no parent, then modname==fqname. - - This method should return None, or a 3-tuple. - - * If the module was not found, then None should be returned. - - * The first item of the 2- or 3-tuple should be the integer 0 or 1, - specifying whether the module that was found is a package or not. - - * The second item is the code object for the module (it will be - executed within the new module's namespace). This item can also - be a fully-loaded module object (e.g. loaded from a shared lib). - - * The third item is a dictionary of name/value pairs that will be - inserted into new module before the code object is executed. This - is provided in case the module's code expects certain values (such - as where the module was found). When the second item is a module - object, then these names/values will be inserted *after* the module - has been loaded/initialized. - """ - raise RuntimeError, "get_code not implemented" - - -###################################################################### -# -# Some handy stuff for the Importers -# - -# byte-compiled file suffix character -_suffix_char = __debug__ and 'c' or 'o' - -# byte-compiled file suffix -_suffix = '.py' + _suffix_char - -def _compile(pathname, timestamp): - """Compile (and cache) a Python source file. - - The file specified by is compiled to a code object and - returned. - - Presuming the appropriate privileges exist, the bytecodes will be - saved back to the filesystem for future imports. The source file's - modification timestamp must be provided as a Long value. - """ - codestring = open(pathname, 'r').read() - if codestring and codestring[-1] != '\n': - codestring = codestring + '\n' - code = __builtin__.compile(codestring, pathname, 'exec') - - # try to cache the compiled code - try: - f = open(pathname + _suffix_char, 'wb') - except IOError: - pass - else: - f.write('\0\0\0\0') - f.write(struct.pack('= t_py: - f = open(file, 'rb') - if f.read(4) == imp.get_magic(): - t = struct.unpack('>> import foo -# >>> foo -# -# -# ---- revamped import mechanism -# >>> import imputil -# >>> imputil._test_revamp() -# >>> import foo -# >>> foo -# -# -# -# from MAL: -# should BuiltinImporter exist in sys.path or hard-wired in ImportManager? -# need __path__ processing -# performance -# move chaining to a subclass [gjs: it's been nuked] -# deinstall should be possible -# query mechanism needed: is a specific Importer installed? -# py/pyc/pyo piping hooks to filter/process these files -# wish list: -# distutils importer hooked to list of standard Internet repositories -# module->file location mapper to speed FS-based imports -# relative imports -# keep chaining so that it can play nice with other import hooks -# -# from Gordon: -# push MAL's mapper into sys.path[0] as a cache (hard-coded for apps) -# -# from Guido: -# need to change sys.* references for rexec environs -# need hook for MAL's walk-me-up import strategy, or Tim's absolute strategy -# watch out for sys.modules[...] is None -# flag to force absolute imports? (speeds _determine_import_context and -# checking for a relative module) -# insert names of archives into sys.path (see quote below) -# note: reload does NOT blast module dict -# shift import mechanisms and policies around; provide for hooks, overrides -# (see quote below) -# add get_source stuff -# get_topcode and get_subcode -# CRLF handling in _compile -# race condition in _compile -# refactoring of os.py to deal with _os_bootstrap problem -# any special handling to do for importing a module with a SyntaxError? -# (e.g. clean up the traceback) -# implement "domain" for path-type functionality using pkg namespace -# (rather than FS-names like __path__) -# don't use the word "private"... maybe "internal" -# -# -# Guido's comments on sys.path caching: -# -# We could cache this in a dictionary: the ImportManager can have a -# cache dict mapping pathnames to importer objects, and a separate -# method for coming up with an importer given a pathname that's not yet -# in the cache. The method should do a stat and/or look at the -# extension to decide which importer class to use; you can register new -# importer classes by registering a suffix or a Boolean function, plus a -# class. If you register a new importer class, the cache is zapped. -# The cache is independent from sys.path (but maintained per -# ImportManager instance) so that rearrangements of sys.path do the -# right thing. If a path is dropped from sys.path the corresponding -# cache entry is simply no longer used. -# -# My/Guido's comments on factoring ImportManager and Importer: -# -# > However, we still have a tension occurring here: -# > -# > 1) implementing policy in ImportManager assists in single-point policy -# > changes for app/rexec situations -# > 2) implementing policy in Importer assists in package-private policy -# > changes for normal, operating conditions -# > -# > I'll see if I can sort out a way to do this. Maybe the Importer class will -# > implement the methods (which can be overridden to change policy) by -# > delegating to ImportManager. -# -# Maybe also think about what kind of policies an Importer would be -# likely to want to change. I have a feeling that a lot of the code -# there is actually not so much policy but a *necessity* to get things -# working given the calling conventions for the __import__ hook: whether -# to return the head or tail of a dotted name, or when to do the "finish -# fromlist" stuff. -# diff --git a/Scripts/ServerPython/python/system/inspect.py b/Scripts/ServerPython/python/system/inspect.py deleted file mode 100644 index f7ddd144..00000000 --- a/Scripts/ServerPython/python/system/inspect.py +++ /dev/null @@ -1,779 +0,0 @@ -"""Get useful information from live Python objects. - -This module encapsulates the interface provided by the internal special -attributes (func_*, co_*, im_*, tb_*, etc.) in a friendlier fashion. -It also provides some help for examining source code and class layout. - -Here are some of the useful functions provided by this module: - - ismodule(), isclass(), ismethod(), isfunction(), istraceback(), - isframe(), iscode(), isbuiltin(), isroutine() - check object types - getmembers() - get members of an object that satisfy a given condition - - getfile(), getsourcefile(), getsource() - find an object's source code - getdoc(), getcomments() - get documentation on an object - getmodule() - determine the module that an object came from - getclasstree() - arrange classes so as to represent their hierarchy - - getargspec(), getargvalues() - get info about function arguments - formatargspec(), formatargvalues() - format an argument spec - getouterframes(), getinnerframes() - get info about frames - currentframe() - get the current stack frame - stack(), trace() - get info about frames on the stack or in a traceback -""" - -# This module is in the public domain. No warranties. - -__author__ = 'Ka-Ping Yee ' -__date__ = '1 Jan 2001' - -import sys, os, types, string, re, dis, imp, tokenize - -# ----------------------------------------------------------- type-checking -def ismodule(object): - """Return true if the object is a module. - - Module objects provide these attributes: - __doc__ documentation string - __file__ filename (missing for built-in modules)""" - return isinstance(object, types.ModuleType) - -def isclass(object): - """Return true if the object is a class. - - Class objects provide these attributes: - __doc__ documentation string - __module__ name of module in which this class was defined""" - return isinstance(object, types.ClassType) or hasattr(object, '__bases__') - -def ismethod(object): - """Return true if the object is an instance method. - - Instance method objects provide these attributes: - __doc__ documentation string - __name__ name with which this method was defined - im_class class object in which this method belongs - im_func function object containing implementation of method - im_self instance to which this method is bound, or None""" - return isinstance(object, types.MethodType) - -def ismethoddescriptor(object): - """Return true if the object is a method descriptor. - - But not if ismethod() or isclass() or isfunction() are true. - - This is new in Python 2.2, and, for example, is true of int.__add__. - An object passing this test has a __get__ attribute but not a __set__ - attribute, but beyond that the set of attributes varies. __name__ is - usually sensible, and __doc__ often is. - - Methods implemented via descriptors that also pass one of the other - tests return false from the ismethoddescriptor() test, simply because - the other tests promise more -- you can, e.g., count on having the - im_func attribute (etc) when an object passes ismethod().""" - return (hasattr(object, "__get__") - and not hasattr(object, "__set__") # else it's a data descriptor - and not ismethod(object) # mutual exclusion - and not isfunction(object) - and not isclass(object)) - -def isfunction(object): - """Return true if the object is a user-defined function. - - Function objects provide these attributes: - __doc__ documentation string - __name__ name with which this function was defined - func_code code object containing compiled function bytecode - func_defaults tuple of any default values for arguments - func_doc (same as __doc__) - func_globals global namespace in which this function was defined - func_name (same as __name__)""" - return isinstance(object, types.FunctionType) - -def istraceback(object): - """Return true if the object is a traceback. - - Traceback objects provide these attributes: - tb_frame frame object at this level - tb_lasti index of last attempted instruction in bytecode - tb_lineno current line number in Python source code - tb_next next inner traceback object (called by this level)""" - return isinstance(object, types.TracebackType) - -def isframe(object): - """Return true if the object is a frame object. - - Frame objects provide these attributes: - f_back next outer frame object (this frame's caller) - f_builtins built-in namespace seen by this frame - f_code code object being executed in this frame - f_exc_traceback traceback if raised in this frame, or None - f_exc_type exception type if raised in this frame, or None - f_exc_value exception value if raised in this frame, or None - f_globals global namespace seen by this frame - f_lasti index of last attempted instruction in bytecode - f_lineno current line number in Python source code - f_locals local namespace seen by this frame - f_restricted 0 or 1 if frame is in restricted execution mode - f_trace tracing function for this frame, or None""" - return isinstance(object, types.FrameType) - -def iscode(object): - """Return true if the object is a code object. - - Code objects provide these attributes: - co_argcount number of arguments (not including * or ** args) - co_code string of raw compiled bytecode - co_consts tuple of constants used in the bytecode - co_filename name of file in which this code object was created - co_firstlineno number of first line in Python source code - co_flags bitmap: 1=optimized | 2=newlocals | 4=*arg | 8=**arg - co_lnotab encoded mapping of line numbers to bytecode indices - co_name name with which this code object was defined - co_names tuple of names of local variables - co_nlocals number of local variables - co_stacksize virtual machine stack space required - co_varnames tuple of names of arguments and local variables""" - return isinstance(object, types.CodeType) - -def isbuiltin(object): - """Return true if the object is a built-in function or method. - - Built-in functions and methods provide these attributes: - __doc__ documentation string - __name__ original name of this function or method - __self__ instance to which a method is bound, or None""" - return isinstance(object, types.BuiltinFunctionType) - -def isroutine(object): - """Return true if the object is any kind of function or method.""" - return (isbuiltin(object) - or isfunction(object) - or ismethod(object) - or ismethoddescriptor(object)) - -def getmembers(object, predicate=None): - """Return all members of an object as (name, value) pairs sorted by name. - Optionally, only return members that satisfy a given predicate.""" - results = [] - for key in dir(object): - value = getattr(object, key) - if not predicate or predicate(value): - results.append((key, value)) - results.sort() - return results - -def classify_class_attrs(cls): - """Return list of attribute-descriptor tuples. - - For each name in dir(cls), the return list contains a 4-tuple - with these elements: - - 0. The name (a string). - - 1. The kind of attribute this is, one of these strings: - 'class method' created via classmethod() - 'static method' created via staticmethod() - 'property' created via property() - 'method' any other flavor of method - 'data' not a method - - 2. The class which defined this attribute (a class). - - 3. The object as obtained directly from the defining class's - __dict__, not via getattr. This is especially important for - data attributes: C.data is just a data object, but - C.__dict__['data'] may be a data descriptor with additional - info, like a __doc__ string. - """ - - mro = getmro(cls) - names = dir(cls) - result = [] - for name in names: - # Get the object associated with the name. - # Getting an obj from the __dict__ sometimes reveals more than - # using getattr. Static and class methods are dramatic examples. - if name in cls.__dict__: - obj = cls.__dict__[name] - else: - obj = getattr(cls, name) - - # Figure out where it was defined. - homecls = getattr(obj, "__objclass__", None) - if homecls is None: - # search the dicts. - for base in mro: - if name in base.__dict__: - homecls = base - break - - # Get the object again, in order to get it from the defining - # __dict__ instead of via getattr (if possible). - if homecls is not None and name in homecls.__dict__: - obj = homecls.__dict__[name] - - # Also get the object via getattr. - obj_via_getattr = getattr(cls, name) - - # Classify the object. - if isinstance(obj, staticmethod): - kind = "static method" - elif isinstance(obj, classmethod): - kind = "class method" - elif isinstance(obj, property): - kind = "property" - elif (ismethod(obj_via_getattr) or - ismethoddescriptor(obj_via_getattr)): - kind = "method" - else: - kind = "data" - - result.append((name, kind, homecls, obj)) - - return result - -# ----------------------------------------------------------- class helpers -def _searchbases(cls, accum): - # Simulate the "classic class" search order. - if cls in accum: - return - accum.append(cls) - for base in cls.__bases__: - _searchbases(base, accum) - -def getmro(cls): - "Return tuple of base classes (including cls) in method resolution order." - if hasattr(cls, "__mro__"): - return cls.__mro__ - else: - result = [] - _searchbases(cls, result) - return tuple(result) - -# -------------------------------------------------- source code extraction -def indentsize(line): - """Return the indent size, in spaces, at the start of a line of text.""" - expline = string.expandtabs(line) - return len(expline) - len(string.lstrip(expline)) - -def getdoc(object): - """Get the documentation string for an object. - - All tabs are expanded to spaces. To clean up docstrings that are - indented to line up with blocks of code, any whitespace than can be - uniformly removed from the second line onwards is removed.""" - try: - doc = object.__doc__ - except AttributeError: - return None - if not isinstance(doc, (str, unicode)): - return None - try: - lines = string.split(string.expandtabs(doc), '\n') - except UnicodeError: - return None - else: - margin = None - for line in lines[1:]: - content = len(string.lstrip(line)) - if not content: continue - indent = len(line) - content - if margin is None: margin = indent - else: margin = min(margin, indent) - if margin is not None: - for i in range(1, len(lines)): lines[i] = lines[i][margin:] - return string.join(lines, '\n') - -def getfile(object): - """Work out which source or compiled file an object was defined in.""" - if ismodule(object): - if hasattr(object, '__file__'): - return object.__file__ - raise TypeError, 'arg is a built-in module' - if isclass(object): - object = sys.modules.get(object.__module__) - if hasattr(object, '__file__'): - return object.__file__ - raise TypeError, 'arg is a built-in class' - if ismethod(object): - object = object.im_func - if isfunction(object): - object = object.func_code - if istraceback(object): - object = object.tb_frame - if isframe(object): - object = object.f_code - if iscode(object): - return object.co_filename - raise TypeError, 'arg is not a module, class, method, ' \ - 'function, traceback, frame, or code object' - -def getmoduleinfo(path): - """Get the module name, suffix, mode, and module type for a given file.""" - filename = os.path.basename(path) - suffixes = map(lambda (suffix, mode, mtype): - (-len(suffix), suffix, mode, mtype), imp.get_suffixes()) - suffixes.sort() # try longest suffixes first, in case they overlap - for neglen, suffix, mode, mtype in suffixes: - if filename[neglen:] == suffix: - return filename[:neglen], suffix, mode, mtype - -def getmodulename(path): - """Return the module name for a given file, or None.""" - info = getmoduleinfo(path) - if info: return info[0] - -def getsourcefile(object): - """Return the Python source file an object was defined in, if it exists.""" - filename = getfile(object) - if string.lower(filename[-4:]) in ['.pyc', '.pyo']: - filename = filename[:-4] + '.py' - for suffix, mode, kind in imp.get_suffixes(): - if 'b' in mode and string.lower(filename[-len(suffix):]) == suffix: - # Looks like a binary file. We want to only return a text file. - return None - if os.path.exists(filename): - return filename - -def getabsfile(object): - """Return an absolute path to the source or compiled file for an object. - - The idea is for each object to have a unique origin, so this routine - normalizes the result as much as possible.""" - return os.path.normcase( - os.path.abspath(getsourcefile(object) or getfile(object))) - -modulesbyfile = {} - -def getmodule(object): - """Return the module an object was defined in, or None if not found.""" - if ismodule(object): - return object - if isclass(object): - return sys.modules.get(object.__module__) - try: - file = getabsfile(object) - except TypeError: - return None - if modulesbyfile.has_key(file): - return sys.modules[modulesbyfile[file]] - for module in sys.modules.values(): - if hasattr(module, '__file__'): - modulesbyfile[getabsfile(module)] = module.__name__ - if modulesbyfile.has_key(file): - return sys.modules[modulesbyfile[file]] - main = sys.modules['__main__'] - if hasattr(main, object.__name__): - mainobject = getattr(main, object.__name__) - if mainobject is object: - return main - builtin = sys.modules['__builtin__'] - if hasattr(builtin, object.__name__): - builtinobject = getattr(builtin, object.__name__) - if builtinobject is object: - return builtin - -def findsource(object): - """Return the entire source file and starting line number for an object. - - The argument may be a module, class, method, function, traceback, frame, - or code object. The source code is returned as a list of all the lines - in the file and the line number indexes a line in that list. An IOError - is raised if the source code cannot be retrieved.""" - try: - file = open(getsourcefile(object)) - except (TypeError, IOError): - raise IOError, 'could not get source code' - lines = file.readlines() - file.close() - - if ismodule(object): - return lines, 0 - - if isclass(object): - name = object.__name__ - pat = re.compile(r'^\s*class\s*' + name + r'\b') - for i in range(len(lines)): - if pat.match(lines[i]): return lines, i - else: raise IOError, 'could not find class definition' - - if ismethod(object): - object = object.im_func - if isfunction(object): - object = object.func_code - if istraceback(object): - object = object.tb_frame - if isframe(object): - object = object.f_code - if iscode(object): - if not hasattr(object, 'co_firstlineno'): - raise IOError, 'could not find function definition' - lnum = object.co_firstlineno - 1 - pat = re.compile(r'^\s*def\s') - while lnum > 0: - if pat.match(lines[lnum]): break - lnum = lnum - 1 - return lines, lnum - raise IOError, 'could not find code object' - -def getcomments(object): - """Get lines of comments immediately preceding an object's source code.""" - try: lines, lnum = findsource(object) - except IOError: return None - - if ismodule(object): - # Look for a comment block at the top of the file. - start = 0 - if lines and lines[0][:2] == '#!': start = 1 - while start < len(lines) and string.strip(lines[start]) in ['', '#']: - start = start + 1 - if start < len(lines) and lines[start][:1] == '#': - comments = [] - end = start - while end < len(lines) and lines[end][:1] == '#': - comments.append(string.expandtabs(lines[end])) - end = end + 1 - return string.join(comments, '') - - # Look for a preceding block of comments at the same indentation. - elif lnum > 0: - indent = indentsize(lines[lnum]) - end = lnum - 1 - if end >= 0 and string.lstrip(lines[end])[:1] == '#' and \ - indentsize(lines[end]) == indent: - comments = [string.lstrip(string.expandtabs(lines[end]))] - if end > 0: - end = end - 1 - comment = string.lstrip(string.expandtabs(lines[end])) - while comment[:1] == '#' and indentsize(lines[end]) == indent: - comments[:0] = [comment] - end = end - 1 - if end < 0: break - comment = string.lstrip(string.expandtabs(lines[end])) - while comments and string.strip(comments[0]) == '#': - comments[:1] = [] - while comments and string.strip(comments[-1]) == '#': - comments[-1:] = [] - return string.join(comments, '') - -class ListReader: - """Provide a readline() method to return lines from a list of strings.""" - def __init__(self, lines): - self.lines = lines - self.index = 0 - - def readline(self): - i = self.index - if i < len(self.lines): - self.index = i + 1 - return self.lines[i] - else: return '' - -class EndOfBlock(Exception): pass - -class BlockFinder: - """Provide a tokeneater() method to detect the end of a code block.""" - def __init__(self): - self.indent = 0 - self.started = 0 - self.last = 0 - - def tokeneater(self, type, token, (srow, scol), (erow, ecol), line): - if not self.started: - if type == tokenize.NAME: self.started = 1 - elif type == tokenize.NEWLINE: - self.last = srow - elif type == tokenize.INDENT: - self.indent = self.indent + 1 - elif type == tokenize.DEDENT: - self.indent = self.indent - 1 - if self.indent == 0: raise EndOfBlock, self.last - -def getblock(lines): - """Extract the block of code at the top of the given list of lines.""" - try: - tokenize.tokenize(ListReader(lines).readline, BlockFinder().tokeneater) - except EndOfBlock, eob: - return lines[:eob.args[0]] - -def getsourcelines(object): - """Return a list of source lines and starting line number for an object. - - The argument may be a module, class, method, function, traceback, frame, - or code object. The source code is returned as a list of the lines - corresponding to the object and the line number indicates where in the - original source file the first line of code was found. An IOError is - raised if the source code cannot be retrieved.""" - lines, lnum = findsource(object) - - if ismodule(object): return lines, 0 - else: return getblock(lines[lnum:]), lnum + 1 - -def getsource(object): - """Return the text of the source code for an object. - - The argument may be a module, class, method, function, traceback, frame, - or code object. The source code is returned as a single string. An - IOError is raised if the source code cannot be retrieved.""" - lines, lnum = getsourcelines(object) - return string.join(lines, '') - -# --------------------------------------------------- class tree extraction -def walktree(classes, children, parent): - """Recursive helper function for getclasstree().""" - results = [] - classes.sort(lambda a, b: cmp(a.__name__, b.__name__)) - for c in classes: - results.append((c, c.__bases__)) - if children.has_key(c): - results.append(walktree(children[c], children, c)) - return results - -def getclasstree(classes, unique=0): - """Arrange the given list of classes into a hierarchy of nested lists. - - Where a nested list appears, it contains classes derived from the class - whose entry immediately precedes the list. Each entry is a 2-tuple - containing a class and a tuple of its base classes. If the 'unique' - argument is true, exactly one entry appears in the returned structure - for each class in the given list. Otherwise, classes using multiple - inheritance and their descendants will appear multiple times.""" - children = {} - roots = [] - for c in classes: - if c.__bases__: - for parent in c.__bases__: - if not children.has_key(parent): - children[parent] = [] - children[parent].append(c) - if unique and parent in classes: break - elif c not in roots: - roots.append(c) - for parent in children.keys(): - if parent not in classes: - roots.append(parent) - return walktree(roots, children, None) - -# ------------------------------------------------ argument list extraction -# These constants are from Python's compile.h. -CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS = 1, 2, 4, 8 - -def getargs(co): - """Get information about the arguments accepted by a code object. - - Three things are returned: (args, varargs, varkw), where 'args' is - a list of argument names (possibly containing nested lists), and - 'varargs' and 'varkw' are the names of the * and ** arguments or None.""" - if not iscode(co): raise TypeError, 'arg is not a code object' - - code = co.co_code - nargs = co.co_argcount - names = co.co_varnames - args = list(names[:nargs]) - step = 0 - - # The following acrobatics are for anonymous (tuple) arguments. - for i in range(nargs): - if args[i][:1] in ['', '.']: - stack, remain, count = [], [], [] - while step < len(code): - op = ord(code[step]) - step = step + 1 - if op >= dis.HAVE_ARGUMENT: - opname = dis.opname[op] - value = ord(code[step]) + ord(code[step+1])*256 - step = step + 2 - if opname in ['UNPACK_TUPLE', 'UNPACK_SEQUENCE']: - remain.append(value) - count.append(value) - elif opname == 'STORE_FAST': - stack.append(names[value]) - remain[-1] = remain[-1] - 1 - while remain[-1] == 0: - remain.pop() - size = count.pop() - stack[-size:] = [stack[-size:]] - if not remain: break - remain[-1] = remain[-1] - 1 - if not remain: break - args[i] = stack[0] - - varargs = None - if co.co_flags & CO_VARARGS: - varargs = co.co_varnames[nargs] - nargs = nargs + 1 - varkw = None - if co.co_flags & CO_VARKEYWORDS: - varkw = co.co_varnames[nargs] - return args, varargs, varkw - -def getargspec(func): - """Get the names and default values of a function's arguments. - - A tuple of four things is returned: (args, varargs, varkw, defaults). - 'args' is a list of the argument names (it may contain nested lists). - 'varargs' and 'varkw' are the names of the * and ** arguments or None. - 'defaults' is an n-tuple of the default values of the last n arguments.""" - if not isfunction(func): raise TypeError, 'arg is not a Python function' - args, varargs, varkw = getargs(func.func_code) - return args, varargs, varkw, func.func_defaults - -def getargvalues(frame): - """Get information about arguments passed into a particular frame. - - A tuple of four things is returned: (args, varargs, varkw, locals). - 'args' is a list of the argument names (it may contain nested lists). - 'varargs' and 'varkw' are the names of the * and ** arguments or None. - 'locals' is the locals dictionary of the given frame.""" - args, varargs, varkw = getargs(frame.f_code) - return args, varargs, varkw, frame.f_locals - -def joinseq(seq): - if len(seq) == 1: - return '(' + seq[0] + ',)' - else: - return '(' + string.join(seq, ', ') + ')' - -def strseq(object, convert, join=joinseq): - """Recursively walk a sequence, stringifying each element.""" - if type(object) in [types.ListType, types.TupleType]: - return join(map(lambda o, c=convert, j=join: strseq(o, c, j), object)) - else: - return convert(object) - -def formatargspec(args, varargs=None, varkw=None, defaults=None, - formatarg=str, - formatvarargs=lambda name: '*' + name, - formatvarkw=lambda name: '**' + name, - formatvalue=lambda value: '=' + repr(value), - join=joinseq): - """Format an argument spec from the 4 values returned by getargspec. - - The first four arguments are (args, varargs, varkw, defaults). The - other four arguments are the corresponding optional formatting functions - that are called to turn names and values into strings. The ninth - argument is an optional function to format the sequence of arguments.""" - specs = [] - if defaults: - firstdefault = len(args) - len(defaults) - for i in range(len(args)): - spec = strseq(args[i], formatarg, join) - if defaults and i >= firstdefault: - spec = spec + formatvalue(defaults[i - firstdefault]) - specs.append(spec) - if varargs: - specs.append(formatvarargs(varargs)) - if varkw: - specs.append(formatvarkw(varkw)) - return '(' + string.join(specs, ', ') + ')' - -def formatargvalues(args, varargs, varkw, locals, - formatarg=str, - formatvarargs=lambda name: '*' + name, - formatvarkw=lambda name: '**' + name, - formatvalue=lambda value: '=' + repr(value), - join=joinseq): - """Format an argument spec from the 4 values returned by getargvalues. - - The first four arguments are (args, varargs, varkw, locals). The - next four arguments are the corresponding optional formatting functions - that are called to turn names and values into strings. The ninth - argument is an optional function to format the sequence of arguments.""" - def convert(name, locals=locals, - formatarg=formatarg, formatvalue=formatvalue): - return formatarg(name) + formatvalue(locals[name]) - specs = [] - for i in range(len(args)): - specs.append(strseq(args[i], convert, join)) - if varargs: - specs.append(formatvarargs(varargs) + formatvalue(locals[varargs])) - if varkw: - specs.append(formatvarkw(varkw) + formatvalue(locals[varkw])) - return '(' + string.join(specs, ', ') + ')' - -# -------------------------------------------------- stack frame extraction -def getframeinfo(frame, context=1): - """Get information about a frame or traceback object. - - A tuple of five things is returned: the filename, the line number of - the current line, the function name, a list of lines of context from - the source code, and the index of the current line within that list. - The optional second argument specifies the number of lines of context - to return, which are centered around the current line.""" - if istraceback(frame): - frame = frame.tb_frame - if not isframe(frame): - raise TypeError, 'arg is not a frame or traceback object' - - filename = getsourcefile(frame) - lineno = getlineno(frame) - if context > 0: - start = lineno - 1 - context//2 - try: - lines, lnum = findsource(frame) - except IOError: - lines = index = None - else: - start = max(start, 1) - start = min(start, len(lines) - context) - lines = lines[start:start+context] - index = lineno - 1 - start - else: - lines = index = None - - return (filename, lineno, frame.f_code.co_name, lines, index) - -def getlineno(frame): - """Get the line number from a frame object, allowing for optimization.""" - # Written by Marc-André Lemburg; revised by Jim Hugunin and Fredrik Lundh. - lineno = frame.f_lineno - code = frame.f_code - if hasattr(code, 'co_lnotab'): - table = code.co_lnotab - lineno = code.co_firstlineno - addr = 0 - for i in range(0, len(table), 2): - addr = addr + ord(table[i]) - if addr > frame.f_lasti: break - lineno = lineno + ord(table[i+1]) - return lineno - -def getouterframes(frame, context=1): - """Get a list of records for a frame and all higher (calling) frames. - - Each record contains a frame object, filename, line number, function - name, a list of lines of context, and index within the context.""" - framelist = [] - while frame: - framelist.append((frame,) + getframeinfo(frame, context)) - frame = frame.f_back - return framelist - -def getinnerframes(tb, context=1): - """Get a list of records for a traceback's frame and all lower frames. - - Each record contains a frame object, filename, line number, function - name, a list of lines of context, and index within the context.""" - framelist = [] - while tb: - framelist.append((tb.tb_frame,) + getframeinfo(tb, context)) - tb = tb.tb_next - return framelist - -def currentframe(): - """Return the frame object for the caller's stack frame.""" - try: - raise 'catch me' - except: - return sys.exc_traceback.tb_frame.f_back - -if hasattr(sys, '_getframe'): currentframe = sys._getframe - -def stack(context=1): - """Return a list of records for the stack above the caller's frame.""" - return getouterframes(currentframe().f_back, context) - -def trace(context=1): - """Return a list of records for the stack below the current exception.""" - return getinnerframes(sys.exc_traceback, context) diff --git a/Scripts/ServerPython/python/system/keyword.py b/Scripts/ServerPython/python/system/keyword.py deleted file mode 100644 index 54b68a79..00000000 --- a/Scripts/ServerPython/python/system/keyword.py +++ /dev/null @@ -1,97 +0,0 @@ -#! /usr/bin/env python - -"""Keywords (from "graminit.c") - -This file is automatically generated; please don't muck it up! - -To update the symbols in this file, 'cd' to the top directory of -the python source tree after building the interpreter and run: - - python Lib/keyword.py -""" - -__all__ = ["iskeyword"] - -kwlist = [ -#--start keywords-- - 'and', - 'assert', - 'break', - 'class', - 'continue', - 'def', - 'del', - 'elif', - 'else', - 'except', - 'exec', - 'finally', - 'for', - 'from', - 'global', - 'if', - 'import', - 'in', - 'is', - 'lambda', - 'not', - 'or', - 'pass', - 'print', - 'raise', - 'return', - 'try', - 'while', - 'yield', -#--end keywords-- - ] - -kwdict = {} -for keyword in kwlist: - kwdict[keyword] = 1 - -iskeyword = kwdict.has_key - -def main(): - import sys, re - - args = sys.argv[1:] - iptfile = args and args[0] or "Python/graminit.c" - if len(args) > 1: optfile = args[1] - else: optfile = "Lib/keyword.py" - - # scan the source file for keywords - fp = open(iptfile) - strprog = re.compile('"([^"]+)"') - lines = [] - while 1: - line = fp.readline() - if not line: break - if line.find('{1, "') > -1: - match = strprog.search(line) - if match: - lines.append(" '" + match.group(1) + "',\n") - fp.close() - lines.sort() - - # load the output skeleton from the target - fp = open(optfile) - format = fp.readlines() - fp.close() - - # insert the lines of keywords - try: - start = format.index("#--start keywords--\n") + 1 - end = format.index("#--end keywords--\n") - format[start:end] = lines - except ValueError: - sys.stderr.write("target does not contain format markers\n") - sys.exit(1) - - # write the output file - fp = open(optfile, 'w') - fp.write(''.join(format)) - fp.close() - -if __name__ == "__main__": - main() diff --git a/Scripts/ServerPython/python/system/knee.py b/Scripts/ServerPython/python/system/knee.py deleted file mode 100644 index 63dd2446..00000000 --- a/Scripts/ServerPython/python/system/knee.py +++ /dev/null @@ -1,126 +0,0 @@ -"""An Python re-implementation of hierarchical module import. - -This code is intended to be read, not executed. However, it does work --- all you need to do to enable it is "import knee". - -(The name is a pun on the klunkier predecessor of this module, "ni".) - -""" - -import sys, imp, __builtin__ - - -# Replacement for __import__() -def import_hook(name, globals=None, locals=None, fromlist=None): - parent = determine_parent(globals) - q, tail = find_head_package(parent, name) - m = load_tail(q, tail) - if not fromlist: - return q - if hasattr(m, "__path__"): - ensure_fromlist(m, fromlist) - return m - -def determine_parent(globals): - if not globals or not globals.has_key("__name__"): - return None - pname = globals['__name__'] - if globals.has_key("__path__"): - parent = sys.modules[pname] - assert globals is parent.__dict__ - return parent - if '.' in pname: - i = pname.rfind('.') - pname = pname[:i] - parent = sys.modules[pname] - assert parent.__name__ == pname - return parent - return None - -def find_head_package(parent, name): - if '.' in name: - i = name.find('.') - head = name[:i] - tail = name[i+1:] - else: - head = name - tail = "" - if parent: - qname = "%s.%s" % (parent.__name__, head) - else: - qname = head - q = import_module(head, qname, parent) - if q: return q, tail - if parent: - qname = head - parent = None - q = import_module(head, qname, parent) - if q: return q, tail - raise ImportError, "No module named " + qname - -def load_tail(q, tail): - m = q - while tail: - i = tail.find('.') - if i < 0: i = len(tail) - head, tail = tail[:i], tail[i+1:] - mname = "%s.%s" % (m.__name__, head) - m = import_module(head, mname, m) - if not m: - raise ImportError, "No module named " + mname - return m - -def ensure_fromlist(m, fromlist, recursive=0): - for sub in fromlist: - if sub == "*": - if not recursive: - try: - all = m.__all__ - except AttributeError: - pass - else: - ensure_fromlist(m, all, 1) - continue - if sub != "*" and not hasattr(m, sub): - subname = "%s.%s" % (m.__name__, sub) - submod = import_module(sub, subname, m) - if not submod: - raise ImportError, "No module named " + subname - -def import_module(partname, fqname, parent): - try: - return sys.modules[fqname] - except KeyError: - pass - try: - fp, pathname, stuff = imp.find_module(partname, - parent and parent.__path__) - except ImportError: - return None - try: - m = imp.load_module(fqname, fp, pathname, stuff) - finally: - if fp: fp.close() - if parent: - setattr(parent, partname, m) - return m - - -# Replacement for reload() -def reload_hook(module): - name = module.__name__ - if '.' not in name: - return import_module(name, name, None) - i = name.rfind('.') - pname = name[:i] - parent = sys.modules[pname] - return import_module(name[i+1:], name, parent) - - -# Save the original hooks -original_import = __builtin__.__import__ -original_reload = __builtin__.reload - -# Now install our hooks -__builtin__.__import__ = import_hook -__builtin__.reload = reload_hook diff --git a/Scripts/ServerPython/python/system/linecache.py b/Scripts/ServerPython/python/system/linecache.py deleted file mode 100644 index 0be8320f..00000000 --- a/Scripts/ServerPython/python/system/linecache.py +++ /dev/null @@ -1,101 +0,0 @@ -"""Cache lines from files. - -This is intended to read lines from modules imported -- hence if a filename -is not found, it will look down the module search path for a file by -that name. -""" - -import sys -import os -from stat import * - -__all__ = ["getline","clearcache","checkcache"] - -def getline(filename, lineno): - lines = getlines(filename) - if 1 <= lineno <= len(lines): - return lines[lineno-1] - else: - return '' - - -# The cache - -cache = {} # The cache - - -def clearcache(): - """Clear the cache entirely.""" - - global cache - cache = {} - - -def getlines(filename): - """Get the lines for a file from the cache. - Update the cache if it doesn't contain an entry for this file already.""" - - if cache.has_key(filename): - return cache[filename][2] - else: - return updatecache(filename) - - -def checkcache(): - """Discard cache entries that are out of date. - (This is not checked upon each call!)""" - - for filename in cache.keys(): - size, mtime, lines, fullname = cache[filename] - try: - stat = os.stat(fullname) - except os.error: - del cache[filename] - continue - if size != stat[ST_SIZE] or mtime != stat[ST_MTIME]: - del cache[filename] - - -def updatecache(filename): - """Update a cache entry and return its list of lines. - If something's wrong, print a message, discard the cache entry, - and return an empty list.""" - - if cache.has_key(filename): - del cache[filename] - if not filename or filename[0] + filename[-1] == '<>': - return [] - fullname = filename - try: - stat = os.stat(fullname) - except os.error, msg: - # Try looking through the module search path. - basename = os.path.split(filename)[1] - for dirname in sys.path: - # When using imputil, sys.path may contain things other than - # strings; ignore them when it happens. - try: - fullname = os.path.join(dirname, basename) - except (TypeError, AttributeError): - # Not sufficiently string-like to do anything useful with. - pass - else: - try: - stat = os.stat(fullname) - break - except os.error: - pass - else: - # No luck -## print '*** Cannot stat', filename, ':', msg - return [] - try: - fp = open(fullname, 'r') - lines = fp.readlines() - fp.close() - except IOError, msg: -## print '*** Cannot open', fullname, ':', msg - return [] - size, mtime = stat[ST_SIZE], stat[ST_MTIME] - cache[filename] = size, mtime, lines, fullname - return lines diff --git a/Scripts/ServerPython/python/system/locale.py b/Scripts/ServerPython/python/system/locale.py deleted file mode 100644 index d077372c..00000000 --- a/Scripts/ServerPython/python/system/locale.py +++ /dev/null @@ -1,734 +0,0 @@ -""" Locale support. - - The module provides low-level access to the C lib's locale APIs - and adds high level number formatting APIs as well as a locale - aliasing engine to complement these. - - The aliasing engine includes support for many commonly used locale - names and maps them to values suitable for passing to the C lib's - setlocale() function. It also includes default encodings for all - supported locale names. - -""" - -import sys - -# Try importing the _locale module. -# -# If this fails, fall back on a basic 'C' locale emulation. - -# Yuck: LC_MESSAGES is non-standard: can't tell whether it exists before -# trying the import. So __all__ is also fiddled at the end of the file. -__all__ = ["setlocale","Error","localeconv","strcoll","strxfrm", - "format","str","atof","atoi","LC_CTYPE","LC_COLLATE", - "LC_TIME","LC_MONETARY","LC_NUMERIC", "LC_ALL","CHAR_MAX"] - -try: - - from _locale import * - -except ImportError: - - # Locale emulation - - CHAR_MAX = 127 - LC_ALL = 6 - LC_COLLATE = 3 - LC_CTYPE = 0 - LC_MESSAGES = 5 - LC_MONETARY = 4 - LC_NUMERIC = 1 - LC_TIME = 2 - Error = ValueError - - def localeconv(): - """ localeconv() -> dict. - Returns numeric and monetary locale-specific parameters. - """ - # 'C' locale default values - return {'grouping': [127], - 'currency_symbol': '', - 'n_sign_posn': 127, - 'p_cs_precedes': 127, - 'n_cs_precedes': 127, - 'mon_grouping': [], - 'n_sep_by_space': 127, - 'decimal_point': '.', - 'negative_sign': '', - 'positive_sign': '', - 'p_sep_by_space': 127, - 'int_curr_symbol': '', - 'p_sign_posn': 127, - 'thousands_sep': '', - 'mon_thousands_sep': '', - 'frac_digits': 127, - 'mon_decimal_point': '', - 'int_frac_digits': 127} - - def setlocale(category, value=None): - """ setlocale(integer,string=None) -> string. - Activates/queries locale processing. - """ - if value is not None and value != 'C': - raise Error, '_locale emulation only supports "C" locale' - return 'C' - - def strcoll(a,b): - """ strcoll(string,string) -> int. - Compares two strings according to the locale. - """ - return cmp(a,b) - - def strxfrm(s): - """ strxfrm(string) -> string. - Returns a string that behaves for cmp locale-aware. - """ - return s - -### Number formatting APIs - -# Author: Martin von Loewis - -#perform the grouping from right to left -def _group(s): - conv=localeconv() - grouping=conv['grouping'] - if not grouping:return (s, 0) - result="" - seps = 0 - spaces = "" - if s[-1] == ' ': - sp = s.find(' ') - spaces = s[sp:] - s = s[:sp] - while s and grouping: - # if grouping is -1, we are done - if grouping[0]==CHAR_MAX: - break - # 0: re-use last group ad infinitum - elif grouping[0]!=0: - #process last group - group=grouping[0] - grouping=grouping[1:] - if result: - result=s[-group:]+conv['thousands_sep']+result - seps += 1 - else: - result=s[-group:] - s=s[:-group] - if s and s[-1] not in "0123456789": - # the leading string is only spaces and signs - return s+result+spaces,seps - if not result: - return s+spaces,seps - if s: - result=s+conv['thousands_sep']+result - seps += 1 - return result+spaces,seps - -def format(f,val,grouping=0): - """Formats a value in the same way that the % formatting would use, - but takes the current locale into account. - Grouping is applied if the third parameter is true.""" - result = f % val - fields = result.split(".") - seps = 0 - if grouping: - fields[0],seps=_group(fields[0]) - if len(fields)==2: - result = fields[0]+localeconv()['decimal_point']+fields[1] - elif len(fields)==1: - result = fields[0] - else: - raise Error, "Too many decimal points in result string" - - while seps: - # If the number was formatted for a specific width, then it - # might have been filled with spaces to the left or right. If - # so, kill as much spaces as there where separators. - # Leading zeroes as fillers are not yet dealt with, as it is - # not clear how they should interact with grouping. - sp = result.find(" ") - if sp==-1:break - result = result[:sp]+result[sp+1:] - seps -= 1 - - return result - -def str(val): - """Convert float to integer, taking the locale into account.""" - return format("%.12g",val) - -def atof(str,func=float): - "Parses a string as a float according to the locale settings." - #First, get rid of the grouping - ts = localeconv()['thousands_sep'] - if ts: - s=str.split(ts) - str="".join(s) - #next, replace the decimal point with a dot - dd = localeconv()['decimal_point'] - if dd: - s=str.split(dd) - str='.'.join(s) - #finally, parse the string - return func(str) - -def atoi(str): - "Converts a string to an integer according to the locale settings." - return atof(str, int) - -def _test(): - setlocale(LC_ALL, "") - #do grouping - s1=format("%d", 123456789,1) - print s1, "is", atoi(s1) - #standard formatting - s1=str(3.14) - print s1, "is", atof(s1) - -### Locale name aliasing engine - -# Author: Marc-Andre Lemburg, mal@lemburg.com -# Various tweaks by Fredrik Lundh - -# store away the low-level version of setlocale (it's -# overridden below) -_setlocale = setlocale - -def normalize(localename): - - """ Returns a normalized locale code for the given locale - name. - - The returned locale code is formatted for use with - setlocale(). - - If normalization fails, the original name is returned - unchanged. - - If the given encoding is not known, the function defaults to - the default encoding for the locale code just like setlocale() - does. - - """ - # Normalize the locale name and extract the encoding - fullname = localename.lower() - if ':' in fullname: - # ':' is sometimes used as encoding delimiter. - fullname = fullname.replace(':', '.') - if '.' in fullname: - langname, encoding = fullname.split('.')[:2] - fullname = langname + '.' + encoding - else: - langname = fullname - encoding = '' - - # First lookup: fullname (possibly with encoding) - code = locale_alias.get(fullname, None) - if code is not None: - return code - - # Second try: langname (without encoding) - code = locale_alias.get(langname, None) - if code is not None: - if '.' in code: - langname, defenc = code.split('.') - else: - langname = code - defenc = '' - if encoding: - encoding = encoding_alias.get(encoding, encoding) - else: - encoding = defenc - if encoding: - return langname + '.' + encoding - else: - return langname - - else: - return localename - -def _parse_localename(localename): - - """ Parses the locale code for localename and returns the - result as tuple (language code, encoding). - - The localename is normalized and passed through the locale - alias engine. A ValueError is raised in case the locale name - cannot be parsed. - - The language code corresponds to RFC 1766. code and encoding - can be None in case the values cannot be determined or are - unknown to this implementation. - - """ - code = normalize(localename) - if '.' in code: - return code.split('.')[:2] - elif code == 'C': - return None, None - raise ValueError, 'unknown locale: %s' % localename - -def _build_localename(localetuple): - - """ Builds a locale code from the given tuple (language code, - encoding). - - No aliasing or normalizing takes place. - - """ - language, encoding = localetuple - if language is None: - language = 'C' - if encoding is None: - return language - else: - return language + '.' + encoding - -def getdefaultlocale(envvars=('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')): - - """ Tries to determine the default locale settings and returns - them as tuple (language code, encoding). - - According to POSIX, a program which has not called - setlocale(LC_ALL, "") runs using the portable 'C' locale. - Calling setlocale(LC_ALL, "") lets it use the default locale as - defined by the LANG variable. Since we don't want to interfere - with the current locale setting we thus emulate the behavior - in the way described above. - - To maintain compatibility with other platforms, not only the - LANG variable is tested, but a list of variables given as - envvars parameter. The first found to be defined will be - used. envvars defaults to the search path used in GNU gettext; - it must always contain the variable name 'LANG'. - - Except for the code 'C', the language code corresponds to RFC - 1766. code and encoding can be None in case the values cannot - be determined. - - """ - - try: - # check if it's supported by the _locale module - import _locale - code, encoding = _locale._getdefaultlocale() - except (ImportError, AttributeError): - pass - else: - # make sure the code/encoding values are valid - if sys.platform == "win32" and code and code[:2] == "0x": - # map windows language identifier to language name - code = windows_locale.get(int(code, 0)) - # ...add other platform-specific processing here, if - # necessary... - return code, encoding - - # fall back on POSIX behaviour - import os - lookup = os.environ.get - for variable in envvars: - localename = lookup(variable,None) - if localename is not None: - break - else: - localename = 'C' - return _parse_localename(localename) - - -def getlocale(category=LC_CTYPE): - - """ Returns the current setting for the given locale category as - tuple (language code, encoding). - - category may be one of the LC_* value except LC_ALL. It - defaults to LC_CTYPE. - - Except for the code 'C', the language code corresponds to RFC - 1766. code and encoding can be None in case the values cannot - be determined. - - """ - localename = _setlocale(category) - if category == LC_ALL and ';' in localename: - raise TypeError, 'category LC_ALL is not supported' - return _parse_localename(localename) - -def setlocale(category, locale=None): - - """ Set the locale for the given category. The locale can be - a string, a locale tuple (language code, encoding), or None. - - Locale tuples are converted to strings the locale aliasing - engine. Locale strings are passed directly to the C lib. - - category may be given as one of the LC_* values. - - """ - if locale and type(locale) is not type(""): - # convert to string - locale = normalize(_build_localename(locale)) - return _setlocale(category, locale) - -def resetlocale(category=LC_ALL): - - """ Sets the locale for category to the default setting. - - The default setting is determined by calling - getdefaultlocale(). category defaults to LC_ALL. - - """ - _setlocale(category, _build_localename(getdefaultlocale())) - -### Database -# -# The following data was extracted from the locale.alias file which -# comes with X11 and then hand edited removing the explicit encoding -# definitions and adding some more aliases. The file is usually -# available as /usr/lib/X11/locale/locale.alias. -# - -# -# The encoding_alias table maps lowercase encoding alias names to C -# locale encoding names (case-sensitive). -# -encoding_alias = { - '437': 'C', - 'c': 'C', - 'iso8859': 'ISO8859-1', - '8859': 'ISO8859-1', - '88591': 'ISO8859-1', - 'ascii': 'ISO8859-1', - 'en': 'ISO8859-1', - 'iso88591': 'ISO8859-1', - 'iso_8859-1': 'ISO8859-1', - '885915': 'ISO8859-15', - 'iso885915': 'ISO8859-15', - 'iso_8859-15': 'ISO8859-15', - 'iso8859-2': 'ISO8859-2', - 'iso88592': 'ISO8859-2', - 'iso_8859-2': 'ISO8859-2', - 'iso88595': 'ISO8859-5', - 'iso88596': 'ISO8859-6', - 'iso88597': 'ISO8859-7', - 'iso88598': 'ISO8859-8', - 'iso88599': 'ISO8859-9', - 'iso-2022-jp': 'JIS7', - 'jis': 'JIS7', - 'jis7': 'JIS7', - 'sjis': 'SJIS', - 'tis620': 'TACTIS', - 'ajec': 'eucJP', - 'eucjp': 'eucJP', - 'ujis': 'eucJP', - 'utf-8': 'utf', - 'utf8': 'utf', - 'utf8@ucs4': 'utf', -} - -# -# The locale_alias table maps lowercase alias names to C locale names -# (case-sensitive). Encodings are always separated from the locale -# name using a dot ('.'); they should only be given in case the -# language name is needed to interpret the given encoding alias -# correctly (CJK codes often have this need). -# -locale_alias = { - 'american': 'en_US.ISO8859-1', - 'ar': 'ar_AA.ISO8859-6', - 'ar_aa': 'ar_AA.ISO8859-6', - 'ar_sa': 'ar_SA.ISO8859-6', - 'arabic': 'ar_AA.ISO8859-6', - 'bg': 'bg_BG.ISO8859-5', - 'bg_bg': 'bg_BG.ISO8859-5', - 'bulgarian': 'bg_BG.ISO8859-5', - 'c-french': 'fr_CA.ISO8859-1', - 'c': 'C', - 'c_c': 'C', - 'cextend': 'en_US.ISO8859-1', - 'chinese-s': 'zh_CN.eucCN', - 'chinese-t': 'zh_TW.eucTW', - 'croatian': 'hr_HR.ISO8859-2', - 'cs': 'cs_CZ.ISO8859-2', - 'cs_cs': 'cs_CZ.ISO8859-2', - 'cs_cz': 'cs_CZ.ISO8859-2', - 'cz': 'cz_CZ.ISO8859-2', - 'cz_cz': 'cz_CZ.ISO8859-2', - 'czech': 'cs_CS.ISO8859-2', - 'da': 'da_DK.ISO8859-1', - 'da_dk': 'da_DK.ISO8859-1', - 'danish': 'da_DK.ISO8859-1', - 'de': 'de_DE.ISO8859-1', - 'de_at': 'de_AT.ISO8859-1', - 'de_ch': 'de_CH.ISO8859-1', - 'de_de': 'de_DE.ISO8859-1', - 'dutch': 'nl_BE.ISO8859-1', - 'ee': 'ee_EE.ISO8859-4', - 'el': 'el_GR.ISO8859-7', - 'el_gr': 'el_GR.ISO8859-7', - 'en': 'en_US.ISO8859-1', - 'en_au': 'en_AU.ISO8859-1', - 'en_ca': 'en_CA.ISO8859-1', - 'en_gb': 'en_GB.ISO8859-1', - 'en_ie': 'en_IE.ISO8859-1', - 'en_nz': 'en_NZ.ISO8859-1', - 'en_uk': 'en_GB.ISO8859-1', - 'en_us': 'en_US.ISO8859-1', - 'eng_gb': 'en_GB.ISO8859-1', - 'english': 'en_EN.ISO8859-1', - 'english_uk': 'en_GB.ISO8859-1', - 'english_united-states': 'en_US.ISO8859-1', - 'english_us': 'en_US.ISO8859-1', - 'es': 'es_ES.ISO8859-1', - 'es_ar': 'es_AR.ISO8859-1', - 'es_bo': 'es_BO.ISO8859-1', - 'es_cl': 'es_CL.ISO8859-1', - 'es_co': 'es_CO.ISO8859-1', - 'es_cr': 'es_CR.ISO8859-1', - 'es_ec': 'es_EC.ISO8859-1', - 'es_es': 'es_ES.ISO8859-1', - 'es_gt': 'es_GT.ISO8859-1', - 'es_mx': 'es_MX.ISO8859-1', - 'es_ni': 'es_NI.ISO8859-1', - 'es_pa': 'es_PA.ISO8859-1', - 'es_pe': 'es_PE.ISO8859-1', - 'es_py': 'es_PY.ISO8859-1', - 'es_sv': 'es_SV.ISO8859-1', - 'es_uy': 'es_UY.ISO8859-1', - 'es_ve': 'es_VE.ISO8859-1', - 'et': 'et_EE.ISO8859-4', - 'et_ee': 'et_EE.ISO8859-4', - 'fi': 'fi_FI.ISO8859-1', - 'fi_fi': 'fi_FI.ISO8859-1', - 'finnish': 'fi_FI.ISO8859-1', - 'fr': 'fr_FR.ISO8859-1', - 'fr_be': 'fr_BE.ISO8859-1', - 'fr_ca': 'fr_CA.ISO8859-1', - 'fr_ch': 'fr_CH.ISO8859-1', - 'fr_fr': 'fr_FR.ISO8859-1', - 'fre_fr': 'fr_FR.ISO8859-1', - 'french': 'fr_FR.ISO8859-1', - 'french_france': 'fr_FR.ISO8859-1', - 'ger_de': 'de_DE.ISO8859-1', - 'german': 'de_DE.ISO8859-1', - 'german_germany': 'de_DE.ISO8859-1', - 'greek': 'el_GR.ISO8859-7', - 'hebrew': 'iw_IL.ISO8859-8', - 'hr': 'hr_HR.ISO8859-2', - 'hr_hr': 'hr_HR.ISO8859-2', - 'hu': 'hu_HU.ISO8859-2', - 'hu_hu': 'hu_HU.ISO8859-2', - 'hungarian': 'hu_HU.ISO8859-2', - 'icelandic': 'is_IS.ISO8859-1', - 'id': 'id_ID.ISO8859-1', - 'id_id': 'id_ID.ISO8859-1', - 'is': 'is_IS.ISO8859-1', - 'is_is': 'is_IS.ISO8859-1', - 'iso-8859-1': 'en_US.ISO8859-1', - 'iso-8859-15': 'en_US.ISO8859-15', - 'iso8859-1': 'en_US.ISO8859-1', - 'iso8859-15': 'en_US.ISO8859-15', - 'iso_8859_1': 'en_US.ISO8859-1', - 'iso_8859_15': 'en_US.ISO8859-15', - 'it': 'it_IT.ISO8859-1', - 'it_ch': 'it_CH.ISO8859-1', - 'it_it': 'it_IT.ISO8859-1', - 'italian': 'it_IT.ISO8859-1', - 'iw': 'iw_IL.ISO8859-8', - 'iw_il': 'iw_IL.ISO8859-8', - 'ja': 'ja_JP.eucJP', - 'ja.jis': 'ja_JP.JIS7', - 'ja.sjis': 'ja_JP.SJIS', - 'ja_jp': 'ja_JP.eucJP', - 'ja_jp.ajec': 'ja_JP.eucJP', - 'ja_jp.euc': 'ja_JP.eucJP', - 'ja_jp.eucjp': 'ja_JP.eucJP', - 'ja_jp.iso-2022-jp': 'ja_JP.JIS7', - 'ja_jp.jis': 'ja_JP.JIS7', - 'ja_jp.jis7': 'ja_JP.JIS7', - 'ja_jp.mscode': 'ja_JP.SJIS', - 'ja_jp.sjis': 'ja_JP.SJIS', - 'ja_jp.ujis': 'ja_JP.eucJP', - 'japan': 'ja_JP.eucJP', - 'japanese': 'ja_JP.SJIS', - 'japanese-euc': 'ja_JP.eucJP', - 'japanese.euc': 'ja_JP.eucJP', - 'jp_jp': 'ja_JP.eucJP', - 'ko': 'ko_KR.eucKR', - 'ko_kr': 'ko_KR.eucKR', - 'ko_kr.euc': 'ko_KR.eucKR', - 'korean': 'ko_KR.eucKR', - 'lt': 'lt_LT.ISO8859-4', - 'lv': 'lv_LV.ISO8859-4', - 'mk': 'mk_MK.ISO8859-5', - 'mk_mk': 'mk_MK.ISO8859-5', - 'nl': 'nl_NL.ISO8859-1', - 'nl_be': 'nl_BE.ISO8859-1', - 'nl_nl': 'nl_NL.ISO8859-1', - 'no': 'no_NO.ISO8859-1', - 'no_no': 'no_NO.ISO8859-1', - 'norwegian': 'no_NO.ISO8859-1', - 'pl': 'pl_PL.ISO8859-2', - 'pl_pl': 'pl_PL.ISO8859-2', - 'polish': 'pl_PL.ISO8859-2', - 'portuguese': 'pt_PT.ISO8859-1', - 'portuguese_brazil': 'pt_BR.ISO8859-1', - 'posix': 'C', - 'posix-utf2': 'C', - 'pt': 'pt_PT.ISO8859-1', - 'pt_br': 'pt_BR.ISO8859-1', - 'pt_pt': 'pt_PT.ISO8859-1', - 'ro': 'ro_RO.ISO8859-2', - 'ro_ro': 'ro_RO.ISO8859-2', - 'ru': 'ru_RU.ISO8859-5', - 'ru_ru': 'ru_RU.ISO8859-5', - 'rumanian': 'ro_RO.ISO8859-2', - 'russian': 'ru_RU.ISO8859-5', - 'serbocroatian': 'sh_YU.ISO8859-2', - 'sh': 'sh_YU.ISO8859-2', - 'sh_hr': 'sh_HR.ISO8859-2', - 'sh_sp': 'sh_YU.ISO8859-2', - 'sh_yu': 'sh_YU.ISO8859-2', - 'sk': 'sk_SK.ISO8859-2', - 'sk_sk': 'sk_SK.ISO8859-2', - 'sl': 'sl_CS.ISO8859-2', - 'sl_cs': 'sl_CS.ISO8859-2', - 'sl_si': 'sl_SI.ISO8859-2', - 'slovak': 'sk_SK.ISO8859-2', - 'slovene': 'sl_CS.ISO8859-2', - 'sp': 'sp_YU.ISO8859-5', - 'sp_yu': 'sp_YU.ISO8859-5', - 'spanish': 'es_ES.ISO8859-1', - 'spanish_spain': 'es_ES.ISO8859-1', - 'sr_sp': 'sr_SP.ISO8859-2', - 'sv': 'sv_SE.ISO8859-1', - 'sv_se': 'sv_SE.ISO8859-1', - 'swedish': 'sv_SE.ISO8859-1', - 'th_th': 'th_TH.TACTIS', - 'tr': 'tr_TR.ISO8859-9', - 'tr_tr': 'tr_TR.ISO8859-9', - 'turkish': 'tr_TR.ISO8859-9', - 'univ': 'en_US.utf', - 'universal': 'en_US.utf', - 'zh': 'zh_CN.eucCN', - 'zh_cn': 'zh_CN.eucCN', - 'zh_cn.big5': 'zh_TW.eucTW', - 'zh_cn.euc': 'zh_CN.eucCN', - 'zh_tw': 'zh_TW.eucTW', - 'zh_tw.euc': 'zh_TW.eucTW', -} - -# -# this maps windows language identifiers (as used on Windows 95 and -# earlier) to locale strings. -# -# NOTE: this mapping is incomplete. If your language is missing, send -# a note with the missing language identifier and the suggested locale -# code to Fredrik Lundh . Thanks /F - -windows_locale = { - 0x0404: "zh_TW", # Chinese (Taiwan) - 0x0804: "zh_CN", # Chinese (PRC) - 0x0406: "da_DK", # Danish - 0x0413: "nl_NL", # Dutch (Netherlands) - 0x0409: "en_US", # English (United States) - 0x0809: "en_UK", # English (United Kingdom) - 0x0c09: "en_AU", # English (Australian) - 0x1009: "en_CA", # English (Canadian) - 0x1409: "en_NZ", # English (New Zealand) - 0x1809: "en_IE", # English (Ireland) - 0x1c09: "en_ZA", # English (South Africa) - 0x040b: "fi_FI", # Finnish - 0x040c: "fr_FR", # French (Standard) - 0x080c: "fr_BE", # French (Belgian) - 0x0c0c: "fr_CA", # French (Canadian) - 0x100c: "fr_CH", # French (Switzerland) - 0x0407: "de_DE", # German (Standard) - 0x0408: "el_GR", # Greek - 0x040d: "iw_IL", # Hebrew - 0x040f: "is_IS", # Icelandic - 0x0410: "it_IT", # Italian (Standard) - 0x0411: "ja_JA", # Japanese - 0x0414: "no_NO", # Norwegian (Bokmal) - 0x0816: "pt_PT", # Portuguese (Standard) - 0x0c0a: "es_ES", # Spanish (Modern Sort) - 0x0441: "sw_KE", # Swahili (Kenya) - 0x041d: "sv_SE", # Swedish - 0x081d: "sv_FI", # Swedish (Finland) - 0x041f: "tr_TR", # Turkish -} - -def _print_locale(): - - """ Test function. - """ - categories = {} - def _init_categories(categories=categories): - for k,v in globals().items(): - if k[:3] == 'LC_': - categories[k] = v - _init_categories() - del categories['LC_ALL'] - - print 'Locale defaults as determined by getdefaultlocale():' - print '-'*72 - lang, enc = getdefaultlocale() - print 'Language: ', lang or '(undefined)' - print 'Encoding: ', enc or '(undefined)' - print - - print 'Locale settings on startup:' - print '-'*72 - for name,category in categories.items(): - print name, '...' - lang, enc = getlocale(category) - print ' Language: ', lang or '(undefined)' - print ' Encoding: ', enc or '(undefined)' - print - - print - print 'Locale settings after calling resetlocale():' - print '-'*72 - resetlocale() - for name,category in categories.items(): - print name, '...' - lang, enc = getlocale(category) - print ' Language: ', lang or '(undefined)' - print ' Encoding: ', enc or '(undefined)' - print - - try: - setlocale(LC_ALL, "") - except: - print 'NOTE:' - print 'setlocale(LC_ALL, "") does not support the default locale' - print 'given in the OS environment variables.' - else: - print - print 'Locale settings after calling setlocale(LC_ALL, ""):' - print '-'*72 - for name,category in categories.items(): - print name, '...' - lang, enc = getlocale(category) - print ' Language: ', lang or '(undefined)' - print ' Encoding: ', enc or '(undefined)' - print - -### - -try: - LC_MESSAGES -except: - pass -else: - __all__.append("LC_MESSAGES") - -if __name__=='__main__': - print 'Locale aliasing:' - print - _print_locale() - print - print 'Number formatting:' - print - _test() diff --git a/Scripts/ServerPython/python/system/mutex.py b/Scripts/ServerPython/python/system/mutex.py deleted file mode 100644 index 9b8b1a0c..00000000 --- a/Scripts/ServerPython/python/system/mutex.py +++ /dev/null @@ -1,51 +0,0 @@ -"""Mutual exclusion -- for use with module sched - -A mutex has two pieces of state -- a 'locked' bit and a queue. -When the mutex is not locked, the queue is empty. -Otherwise, the queue contains 0 or more (function, argument) pairs -representing functions (or methods) waiting to acquire the lock. -When the mutex is unlocked while the queue is not empty, -the first queue entry is removed and its function(argument) pair called, -implying it now has the lock. - -Of course, no multi-threading is implied -- hence the funny interface -for lock, where a function is called once the lock is aquired. -""" - -class mutex: - def __init__(self): - """Create a new mutex -- initially unlocked.""" - self.locked = 0 - self.queue = [] - - def test(self): - """Test the locked bit of the mutex.""" - return self.locked - - def testandset(self): - """Atomic test-and-set -- grab the lock if it is not set, - return true if it succeeded.""" - if not self.locked: - self.locked = 1 - return 1 - else: - return 0 - - def lock(self, function, argument): - """Lock a mutex, call the function with supplied argument - when it is acquired. If the mutex is already locked, place - function and argument in the queue.""" - if self.testandset(): - function(argument) - else: - self.queue.append((function, argument)) - - def unlock(self): - """Unlock a mutex. If the queue is not empty, call the next - function with its argument.""" - if self.queue: - function, argument = self.queue[0] - del self.queue[0] - function(argument) - else: - self.locked = 0 diff --git a/Scripts/ServerPython/python/system/netrc.py b/Scripts/ServerPython/python/system/netrc.py deleted file mode 100644 index c4182ba8..00000000 --- a/Scripts/ServerPython/python/system/netrc.py +++ /dev/null @@ -1,108 +0,0 @@ -"""An object-oriented interface to .netrc files.""" - -# Module and documentation by Eric S. Raymond, 21 Dec 1998 - -import os, shlex - -__all__ = ["netrc", "NetrcParseError"] - - -class NetrcParseError(Exception): - """Exception raised on syntax errors in the .netrc file.""" - def __init__(self, msg, filename=None, lineno=None): - self.filename = filename - self.lineno = lineno - self.msg = msg - Exception.__init__(self, msg) - - def __str__(self): - return "%s (%s, line %s)" % (self.msg, self.filename, self.lineno) - - -class netrc: - def __init__(self, file=None): - if not file: - file = os.path.join(os.environ['HOME'], ".netrc") - fp = open(file) - self.hosts = {} - self.macros = {} - lexer = shlex.shlex(fp) - # Allows @ in hostnames. Not a big deal... - lexer.wordchars = lexer.wordchars + '.-@' - while 1: - # Look for a machine, default, or macdef top-level keyword - toplevel = tt = lexer.get_token() - if not tt: - break - elif tt == 'machine': - entryname = lexer.get_token() - elif tt == 'default': - entryname = 'default' - elif tt == 'macdef': # Just skip to end of macdefs - entryname = lexer.get_token() - self.macros[entryname] = [] - lexer.whitespace = ' \t' - while 1: - line = lexer.instream.readline() - if not line or line == '\012': - lexer.whitespace = ' \t\r\n' - break - self.macros[entryname].append(line) - continue - else: - raise NetrcParseError( - "bad toplevel token %r" % tt, file, lexer.lineno) - - # We're looking at start of an entry for a named machine or default. - login = account = password = None - self.hosts[entryname] = {} - while 1: - tt = lexer.get_token() - if (tt=='' or tt == 'machine' or - tt == 'default' or tt =='macdef'): - if login and password: - self.hosts[entryname] = (login, account, password) - lexer.push_token(tt) - break - else: - raise NetrcParseError( - "malformed %s entry %s terminated by %s" - % (toplevel, entryname, repr(tt)), - file, lexer.lineno) - elif tt == 'login' or tt == 'user': - login = lexer.get_token() - elif tt == 'account': - account = lexer.get_token() - elif tt == 'password': - password = lexer.get_token() - else: - raise NetrcParseError("bad follower token %r" % tt, - file, lexer.lineno) - - def authenticators(self, host): - """Return a (user, account, password) tuple for given host.""" - if self.hosts.has_key(host): - return self.hosts[host] - elif self.hosts.has_key('default'): - return self.hosts['default'] - else: - return None - - def __repr__(self): - """Dump the class data in the format of a .netrc file.""" - rep = "" - for host in self.hosts.keys(): - attrs = self.hosts[host] - rep = rep + "machine "+ host + "\n\tlogin " + repr(attrs[0]) + "\n" - if attrs[1]: - rep = rep + "account " + repr(attrs[1]) - rep = rep + "\tpassword " + repr(attrs[2]) + "\n" - for macro in self.macros.keys(): - rep = rep + "macdef " + macro + "\n" - for line in self.macros[macro]: - rep = rep + line - rep = rep + "\n" - return rep - -if __name__ == '__main__': - print netrc() diff --git a/Scripts/ServerPython/python/system/ntpath.py b/Scripts/ServerPython/python/system/ntpath.py deleted file mode 100644 index bc7774a1..00000000 --- a/Scripts/ServerPython/python/system/ntpath.py +++ /dev/null @@ -1,481 +0,0 @@ -# Module 'ntpath' -- common operations on WinNT/Win95 pathnames -"""Common pathname manipulations, WindowsNT/95 version. - -Instead of importing this module directly, import os and refer to this -module as os.path. -""" - -import os -import stat - -__all__ = ["normcase","isabs","join","splitdrive","split","splitext", - "basename","dirname","commonprefix","getsize","getmtime", - "getatime","islink","exists","isdir","isfile","ismount", - "walk","expanduser","expandvars","normpath","abspath","splitunc"] - -# Normalize the case of a pathname and map slashes to backslashes. -# Other normalizations (such as optimizing '../' away) are not done -# (this is done by normpath). - -def normcase(s): - """Normalize case of pathname. - - Makes all characters lowercase and all slashes into backslashes.""" - return s.replace("/", "\\").lower() - - -# Return whether a path is absolute. -# Trivial in Posix, harder on the Mac or MS-DOS. -# For DOS it is absolute if it starts with a slash or backslash (current -# volume), or if a pathname after the volume letter and colon / UNC resource -# starts with a slash or backslash. - -def isabs(s): - """Test whether a path is absolute""" - s = splitdrive(s)[1] - return s != '' and s[:1] in '/\\' - - -# Join two (or more) paths. - -def join(a, *p): - """Join two or more pathname components, inserting "\\" as needed""" - path = a - for b in p: - b_wins = 0 # set to 1 iff b makes path irrelevant - if path == "": - b_wins = 1 - - elif isabs(b): - # This probably wipes out path so far. However, it's more - # complicated if path begins with a drive letter: - # 1. join('c:', '/a') == 'c:/a' - # 2. join('c:/', '/a') == 'c:/a' - # But - # 3. join('c:/a', '/b') == '/b' - # 4. join('c:', 'd:/') = 'd:/' - # 5. join('c:/', 'd:/') = 'd:/' - if path[1:2] != ":" or b[1:2] == ":": - # Path doesn't start with a drive letter, or cases 4 and 5. - b_wins = 1 - - # Else path has a drive letter, and b doesn't but is absolute. - elif len(path) > 3 or (len(path) == 3 and - path[-1] not in "/\\"): - # case 3 - b_wins = 1 - - if b_wins: - path = b - else: - # Join, and ensure there's a separator. - assert len(path) > 0 - if path[-1] in "/\\": - if b and b[0] in "/\\": - path += b[1:] - else: - path += b - elif path[-1] == ":": - path += b - elif b: - if b[0] in "/\\": - path += b - else: - path += "\\" + b - else: - # path is not empty and does not end with a backslash, - # but b is empty; since, e.g., split('a/') produces - # ('a', ''), it's best if join() adds a backslash in - # this case. - path += '\\' - - return path - - -# Split a path in a drive specification (a drive letter followed by a -# colon) and the path specification. -# It is always true that drivespec + pathspec == p -def splitdrive(p): - """Split a pathname into drive and path specifiers. Returns a 2-tuple -"(drive,path)"; either part may be empty""" - if p[1:2] == ':': - return p[0:2], p[2:] - return '', p - - -# Parse UNC paths -def splitunc(p): - """Split a pathname into UNC mount point and relative path specifiers. - - Return a 2-tuple (unc, rest); either part may be empty. - If unc is not empty, it has the form '//host/mount' (or similar - using backslashes). unc+rest is always the input path. - Paths containing drive letters never have an UNC part. - """ - if p[1:2] == ':': - return '', p # Drive letter present - firstTwo = p[0:2] - if firstTwo == '//' or firstTwo == '\\\\': - # is a UNC path: - # vvvvvvvvvvvvvvvvvvvv equivalent to drive letter - # \\machine\mountpoint\directories... - # directory ^^^^^^^^^^^^^^^ - normp = normcase(p) - index = normp.find('\\', 2) - if index == -1: - ##raise RuntimeError, 'illegal UNC path: "' + p + '"' - return ("", p) - index = normp.find('\\', index + 1) - if index == -1: - index = len(p) - return p[:index], p[index:] - return '', p - - -# Split a path in head (everything up to the last '/') and tail (the -# rest). After the trailing '/' is stripped, the invariant -# join(head, tail) == p holds. -# The resulting head won't end in '/' unless it is the root. - -def split(p): - """Split a pathname. - - Return tuple (head, tail) where tail is everything after the final slash. - Either part may be empty.""" - - d, p = splitdrive(p) - # set i to index beyond p's last slash - i = len(p) - while i and p[i-1] not in '/\\': - i = i - 1 - head, tail = p[:i], p[i:] # now tail has no slashes - # remove trailing slashes from head, unless it's all slashes - head2 = head - while head2 and head2[-1] in '/\\': - head2 = head2[:-1] - head = head2 or head - return d + head, tail - - -# Split a path in root and extension. -# The extension is everything starting at the last dot in the last -# pathname component; the root is everything before that. -# It is always true that root + ext == p. - -def splitext(p): - """Split the extension from a pathname. - - Extension is everything from the last dot to the end. - Return (root, ext), either part may be empty.""" - root, ext = '', '' - for c in p: - if c in ['/','\\']: - root, ext = root + ext + c, '' - elif c == '.': - if ext: - root, ext = root + ext, c - else: - ext = c - elif ext: - ext = ext + c - else: - root = root + c - return root, ext - - -# Return the tail (basename) part of a path. - -def basename(p): - """Returns the final component of a pathname""" - return split(p)[1] - - -# Return the head (dirname) part of a path. - -def dirname(p): - """Returns the directory component of a pathname""" - return split(p)[0] - - -# Return the longest prefix of all list elements. - -def commonprefix(m): - "Given a list of pathnames, returns the longest common leading component" - if not m: return '' - prefix = m[0] - for item in m: - for i in range(len(prefix)): - if prefix[:i+1] != item[:i+1]: - prefix = prefix[:i] - if i == 0: return '' - break - return prefix - - -# Get size, mtime, atime of files. - -def getsize(filename): - """Return the size of a file, reported by os.stat()""" - st = os.stat(filename) - return st[stat.ST_SIZE] - -def getmtime(filename): - """Return the last modification time of a file, reported by os.stat()""" - st = os.stat(filename) - return st[stat.ST_MTIME] - -def getatime(filename): - """Return the last access time of a file, reported by os.stat()""" - st = os.stat(filename) - return st[stat.ST_ATIME] - - -# Is a path a symbolic link? -# This will always return false on systems where posix.lstat doesn't exist. - -def islink(path): - """Test for symbolic link. On WindowsNT/95 always returns false""" - return 0 - - -# Does a path exist? -# This is false for dangling symbolic links. - -def exists(path): - """Test whether a path exists""" - try: - st = os.stat(path) - except os.error: - return 0 - return 1 - - -# Is a path a dos directory? -# This follows symbolic links, so both islink() and isdir() can be true -# for the same path. - -def isdir(path): - """Test whether a path is a directory""" - try: - st = os.stat(path) - except os.error: - return 0 - return stat.S_ISDIR(st[stat.ST_MODE]) - - -# Is a path a regular file? -# This follows symbolic links, so both islink() and isdir() can be true -# for the same path. - -def isfile(path): - """Test whether a path is a regular file""" - try: - st = os.stat(path) - except os.error: - return 0 - return stat.S_ISREG(st[stat.ST_MODE]) - - -# Is a path a mount point? Either a root (with or without drive letter) -# or an UNC path with at most a / or \ after the mount point. - -def ismount(path): - """Test whether a path is a mount point (defined as root of drive)""" - unc, rest = splitunc(path) - if unc: - return rest in ("", "/", "\\") - p = splitdrive(path)[1] - return len(p) == 1 and p[0] in '/\\' - - -# Directory tree walk. -# For each directory under top (including top itself, but excluding -# '.' and '..'), func(arg, dirname, filenames) is called, where -# dirname is the name of the directory and filenames is the list -# files files (and subdirectories etc.) in the directory. -# The func may modify the filenames list, to implement a filter, -# or to impose a different order of visiting. - -def walk(top, func, arg): - """Directory tree walk with callback function. - - For each directory in the directory tree rooted at top (including top - itself, but excluding '.' and '..'), call func(arg, dirname, fnames). - dirname is the name of the directory, and fnames a list of the names of - the files and subdirectories in dirname (excluding '.' and '..'). func - may modify the fnames list in-place (e.g. via del or slice assignment), - and walk will only recurse into the subdirectories whose names remain in - fnames; this can be used to implement a filter, or to impose a specific - order of visiting. No semantics are defined for, or required of, arg, - beyond that arg is always passed to func. It can be used, e.g., to pass - a filename pattern, or a mutable object designed to accumulate - statistics. Passing None for arg is common.""" - - try: - names = os.listdir(top) - except os.error: - return - func(arg, top, names) - exceptions = ('.', '..') - for name in names: - if name not in exceptions: - name = join(top, name) - if isdir(name): - walk(name, func, arg) - - -# Expand paths beginning with '~' or '~user'. -# '~' means $HOME; '~user' means that user's home directory. -# If the path doesn't begin with '~', or if the user or $HOME is unknown, -# the path is returned unchanged (leaving error reporting to whatever -# function is called with the expanded path as argument). -# See also module 'glob' for expansion of *, ? and [...] in pathnames. -# (A function should also be defined to do full *sh-style environment -# variable expansion.) - -def expanduser(path): - """Expand ~ and ~user constructs. - - If user or $HOME is unknown, do nothing.""" - if path[:1] != '~': - return path - i, n = 1, len(path) - while i < n and path[i] not in '/\\': - i = i + 1 - if i == 1: - if os.environ.has_key('HOME'): - userhome = os.environ['HOME'] - elif not os.environ.has_key('HOMEPATH'): - return path - else: - try: - drive = os.environ['HOMEDRIVE'] - except KeyError: - drive = '' - userhome = join(drive, os.environ['HOMEPATH']) - else: - return path - return userhome + path[i:] - - -# Expand paths containing shell variable substitutions. -# The following rules apply: -# - no expansion within single quotes -# - no escape character, except for '$$' which is translated into '$' -# - ${varname} is accepted. -# - varnames can be made out of letters, digits and the character '_' -# XXX With COMMAND.COM you can use any characters in a variable name, -# XXX except '^|<>='. - -def expandvars(path): - """Expand shell variables of form $var and ${var}. - - Unknown variables are left unchanged.""" - if '$' not in path: - return path - import string - varchars = string.ascii_letters + string.digits + '_-' - res = '' - index = 0 - pathlen = len(path) - while index < pathlen: - c = path[index] - if c == '\'': # no expansion within single quotes - path = path[index + 1:] - pathlen = len(path) - try: - index = path.index('\'') - res = res + '\'' + path[:index + 1] - except ValueError: - res = res + path - index = pathlen - 1 - elif c == '$': # variable or '$$' - if path[index + 1:index + 2] == '$': - res = res + c - index = index + 1 - elif path[index + 1:index + 2] == '{': - path = path[index+2:] - pathlen = len(path) - try: - index = path.index('}') - var = path[:index] - if os.environ.has_key(var): - res = res + os.environ[var] - except ValueError: - res = res + path - index = pathlen - 1 - else: - var = '' - index = index + 1 - c = path[index:index + 1] - while c != '' and c in varchars: - var = var + c - index = index + 1 - c = path[index:index + 1] - if os.environ.has_key(var): - res = res + os.environ[var] - if c != '': - res = res + c - else: - res = res + c - index = index + 1 - return res - - -# Normalize a path, e.g. A//B, A/./B and A/foo/../B all become A\B. -# Previously, this function also truncated pathnames to 8+3 format, -# but as this module is called "ntpath", that's obviously wrong! - -def normpath(path): - """Normalize path, eliminating double slashes, etc.""" - path = path.replace("/", "\\") - prefix, path = splitdrive(path) - while path[:1] == "\\": - prefix = prefix + "\\" - path = path[1:] - comps = path.split("\\") - i = 0 - while i < len(comps): - if comps[i] in ('.', ''): - del comps[i] - elif comps[i] == '..': - if i > 0 and comps[i-1] != '..': - del comps[i-1:i+1] - i -= 1 - elif i == 0 and prefix.endswith("\\"): - del comps[i] - else: - i += 1 - else: - i += 1 - # If the path is now empty, substitute '.' - if not prefix and not comps: - comps.append('.') - return prefix + "\\".join(comps) - - -# Return an absolute path. -def abspath(path): - """Return the absolute version of a path""" - try: - from nt import _getfullpathname - except ImportError: # Not running on Windows - mock up something sensible. - global abspath - def _abspath(path): - if not isabs(path): - path = join(os.getcwd(), path) - return normpath(path) - abspath = _abspath - return _abspath(path) - - if path: # Empty path must return current working directory. - try: - path = _getfullpathname(path) - except WindowsError: - pass # Bad path - return unchanged. - else: - path = os.getcwd() - return normpath(path) - -# realpath is a no-op on systems without islink support -realpath = abspath diff --git a/Scripts/ServerPython/python/system/os.py b/Scripts/ServerPython/python/system/os.py deleted file mode 100644 index 96a9fe5d..00000000 --- a/Scripts/ServerPython/python/system/os.py +++ /dev/null @@ -1,612 +0,0 @@ -r"""OS routines for Mac, DOS, NT, or Posix depending on what system we're on. - -This exports: - - all functions from posix, nt, dos, os2, mac, or ce, e.g. unlink, stat, etc. - - os.path is one of the modules posixpath, ntpath, macpath, or dospath - - os.name is 'posix', 'nt', 'dos', 'os2', 'mac', 'ce' or 'riscos' - - os.curdir is a string representing the current directory ('.' or ':') - - os.pardir is a string representing the parent directory ('..' or '::') - - os.sep is the (or a most common) pathname separator ('/' or ':' or '\\') - - os.extsep is the extension separator ('.' or '/') - - os.altsep is the alternate pathname separator (None or '/') - - os.pathsep is the component separator used in $PATH etc - - os.linesep is the line separator in text files ('\r' or '\n' or '\r\n') - - os.defpath is the default search path for executables - -Programs that import and use 'os' stand a better chance of being -portable between different platforms. Of course, they must then -only use functions that are defined by all platforms (e.g., unlink -and opendir), and leave all pathname manipulation to os.path -(e.g., split and join). -""" - -#' - -import sys - -_names = sys.builtin_module_names - -altsep = None - -__all__ = ["altsep", "curdir", "pardir", "sep", "pathsep", "linesep", - "defpath", "name"] - -def _get_exports_list(module): - try: - return list(module.__all__) - except AttributeError: - return [n for n in dir(module) if n[0] != '_'] - -if 'posix' in _names: - name = 'posix' - linesep = '\n' - curdir = '.'; pardir = '..'; sep = '/'; pathsep = ':' - defpath = ':/bin:/usr/bin' - from posix import * - try: - from posix import _exit - except ImportError: - pass - import posixpath - path = posixpath - del posixpath - - import posix - __all__.extend(_get_exports_list(posix)) - del posix - -elif 'nt' in _names: - name = 'nt' - linesep = '\r\n' - curdir = '.'; pardir = '..'; sep = '\\'; pathsep = ';' - defpath = '.;C:\\bin' - from nt import * - for i in ['_exit']: - try: - exec "from nt import " + i - except ImportError: - pass - import ntpath - path = ntpath - del ntpath - - import nt - __all__.extend(_get_exports_list(nt)) - del nt - -elif 'dos' in _names: - name = 'dos' - linesep = '\r\n' - curdir = '.'; pardir = '..'; sep = '\\'; pathsep = ';' - defpath = '.;C:\\bin' - from dos import * - try: - from dos import _exit - except ImportError: - pass - import dospath - path = dospath - del dospath - - import dos - __all__.extend(_get_exports_list(dos)) - del dos - -elif 'os2' in _names: - name = 'os2' - linesep = '\r\n' - curdir = '.'; pardir = '..'; sep = '\\'; pathsep = ';' - defpath = '.;C:\\bin' - from os2 import * - try: - from os2 import _exit - except ImportError: - pass - import ntpath - path = ntpath - del ntpath - - import os2 - __all__.extend(_get_exports_list(os2)) - del os2 - -elif 'mac' in _names: - name = 'mac' - linesep = '\r' - curdir = ':'; pardir = '::'; sep = ':'; pathsep = '\n' - defpath = ':' - from mac import * - try: - from mac import _exit - except ImportError: - pass - import macpath - path = macpath - del macpath - - import mac - __all__.extend(_get_exports_list(mac)) - del mac - -elif 'ce' in _names: - name = 'ce' - linesep = '\r\n' - curdir = '.'; pardir = '..'; sep = '\\'; pathsep = ';' - defpath = '\\Windows' - from ce import * - for i in ['_exit']: - try: - exec "from ce import " + i - except ImportError: - pass - # We can use the standard Windows path. - import ntpath - path = ntpath - del ntpath - - import ce - __all__.extend(_get_exports_list(ce)) - del ce - -elif 'riscos' in _names: - name = 'riscos' - linesep = '\n' - curdir = '@'; pardir = '^'; sep = '.'; pathsep = ',' - defpath = '' - from riscos import * - try: - from riscos import _exit - except ImportError: - pass - import riscospath - path = riscospath - del riscospath - - import riscos - __all__.extend(_get_exports_list(riscos)) - del riscos - -else: - raise ImportError, 'no os specific module found' - - -if sep=='.': - extsep = '/' -else: - extsep = '.' - -__all__.append("path") - -del _names - -sys.modules['os.path'] = path - -#' - -# Super directory utilities. -# (Inspired by Eric Raymond; the doc strings are mostly his) - -def makedirs(name, mode=0777): - """makedirs(path [, mode=0777]) -> None - - Super-mkdir; create a leaf directory and all intermediate ones. - Works like mkdir, except that any intermediate path segment (not - just the rightmost) will be created if it does not exist. This is - recursive. - - """ - head, tail = path.split(name) - if not tail: - head, tail = path.split(head) - if head and tail and not path.exists(head): - makedirs(head, mode) - mkdir(name, mode) - -def removedirs(name): - """removedirs(path) -> None - - Super-rmdir; remove a leaf directory and empty all intermediate - ones. Works like rmdir except that, if the leaf directory is - successfully removed, directories corresponding to rightmost path - segments will be pruned way until either the whole path is - consumed or an error occurs. Errors during this latter phase are - ignored -- they generally mean that a directory was not empty. - - """ - rmdir(name) - head, tail = path.split(name) - if not tail: - head, tail = path.split(head) - while head and tail: - try: - rmdir(head) - except error: - break - head, tail = path.split(head) - -def renames(old, new): - """renames(old, new) -> None - - Super-rename; create directories as necessary and delete any left - empty. Works like rename, except creation of any intermediate - directories needed to make the new pathname good is attempted - first. After the rename, directories corresponding to rightmost - path segments of the old name will be pruned way until either the - whole path is consumed or a nonempty directory is found. - - Note: this function can fail with the new directory structure made - if you lack permissions needed to unlink the leaf directory or - file. - - """ - head, tail = path.split(new) - if head and tail and not path.exists(head): - makedirs(head) - rename(old, new) - head, tail = path.split(old) - if head and tail: - try: - removedirs(head) - except error: - pass - -__all__.extend(["makedirs", "removedirs", "renames"]) - -# Make sure os.environ exists, at least -try: - environ -except NameError: - environ = {} - -def execl(file, *args): - """execl(file, *args) - - Execute the executable file with argument list args, replacing the - current process. """ - execv(file, args) - -def execle(file, *args): - """execle(file, *args, env) - - Execute the executable file with argument list args and - environment env, replacing the current process. """ - env = args[-1] - execve(file, args[:-1], env) - -def execlp(file, *args): - """execlp(file, *args) - - Execute the executable file (which is searched for along $PATH) - with argument list args, replacing the current process. """ - execvp(file, args) - -def execlpe(file, *args): - """execlpe(file, *args, env) - - Execute the executable file (which is searched for along $PATH) - with argument list args and environment env, replacing the current - process. """ - env = args[-1] - execvpe(file, args[:-1], env) - -def execvp(file, args): - """execp(file, args) - - Execute the executable file (which is searched for along $PATH) - with argument list args, replacing the current process. - args may be a list or tuple of strings. """ - _execvpe(file, args) - -def execvpe(file, args, env): - """execvpe(file, args, env) - - Execute the executable file (which is searched for along $PATH) - with argument list args and environment env , replacing the - current process. - args may be a list or tuple of strings. """ - _execvpe(file, args, env) - -__all__.extend(["execl","execle","execlp","execlpe","execvp","execvpe"]) - -def _execvpe(file, args, env=None): - from errno import ENOENT, ENOTDIR - - if env is not None: - func = execve - argrest = (args, env) - else: - func = execv - argrest = (args,) - env = environ - - head, tail = path.split(file) - if head: - apply(func, (file,) + argrest) - return - if env.has_key('PATH'): - envpath = env['PATH'] - else: - envpath = defpath - PATH = envpath.split(pathsep) - saved_exc = None - saved_tb = None - for dir in PATH: - fullname = path.join(dir, file) - try: - apply(func, (fullname,) + argrest) - except error, e: - tb = sys.exc_info()[2] - if (e.errno != ENOENT and e.errno != ENOTDIR - and saved_exc is None): - saved_exc = e - saved_tb = tb - if saved_exc: - raise error, saved_exc, saved_tb - raise error, e, tb - -# Change environ to automatically call putenv() if it exists -try: - # This will fail if there's no putenv - putenv -except NameError: - pass -else: - import UserDict - - # Fake unsetenv() for Windows - # not sure about os2 and dos here but - # I'm guessing they are the same. - - if name in ('os2', 'nt', 'dos'): - def unsetenv(key): - putenv(key, "") - - if name == "riscos": - # On RISC OS, all env access goes through getenv and putenv - from riscosenviron import _Environ - elif name in ('os2', 'nt', 'dos'): # Where Env Var Names Must Be UPPERCASE - # But we store them as upper case - class _Environ(UserDict.IterableUserDict): - def __init__(self, environ): - UserDict.UserDict.__init__(self) - data = self.data - for k, v in environ.items(): - data[k.upper()] = v - def __setitem__(self, key, item): - putenv(key, item) - self.data[key.upper()] = item - def __getitem__(self, key): - return self.data[key.upper()] - try: - unsetenv - except NameError: - def __delitem__(self, key): - del self.data[key.upper()] - else: - def __delitem__(self, key): - unsetenv(key) - del self.data[key.upper()] - def has_key(self, key): - return self.data.has_key(key.upper()) - def get(self, key, failobj=None): - return self.data.get(key.upper(), failobj) - def update(self, dict): - for k, v in dict.items(): - self[k] = v - - else: # Where Env Var Names Can Be Mixed Case - class _Environ(UserDict.IterableUserDict): - def __init__(self, environ): - UserDict.UserDict.__init__(self) - self.data = environ - def __setitem__(self, key, item): - putenv(key, item) - self.data[key] = item - def update(self, dict): - for k, v in dict.items(): - self[k] = v - try: - unsetenv - except NameError: - pass - else: - def __delitem__(self, key): - unsetenv(key) - del self.data[key] - - - environ = _Environ(environ) - - def getenv(key, default=None): - """Get an environment variable, return None if it doesn't exist. - The optional second argument can specify an alternate default.""" - return environ.get(key, default) - __all__.append("getenv") - -def _exists(name): - try: - eval(name) - return 1 - except NameError: - return 0 - -# Supply spawn*() (probably only for Unix) -if _exists("fork") and not _exists("spawnv") and _exists("execv"): - - P_WAIT = 0 - P_NOWAIT = P_NOWAITO = 1 - - # XXX Should we support P_DETACH? I suppose it could fork()**2 - # and close the std I/O streams. Also, P_OVERLAY is the same - # as execv*()? - - def _spawnvef(mode, file, args, env, func): - # Internal helper; func is the exec*() function to use - pid = fork() - if not pid: - # Child - try: - if env is None: - func(file, args) - else: - func(file, args, env) - except: - _exit(127) - else: - # Parent - if mode == P_NOWAIT: - return pid # Caller is responsible for waiting! - while 1: - wpid, sts = waitpid(pid, 0) - if WIFSTOPPED(sts): - continue - elif WIFSIGNALED(sts): - return -WTERMSIG(sts) - elif WIFEXITED(sts): - return WEXITSTATUS(sts) - else: - raise error, "Not stopped, signaled or exited???" - - def spawnv(mode, file, args): - """spawnv(mode, file, args) -> integer - -Execute file with arguments from args in a subprocess. -If mode == P_NOWAIT return the pid of the process. -If mode == P_WAIT return the process's exit code if it exits normally; -otherwise return -SIG, where SIG is the signal that killed it. """ - return _spawnvef(mode, file, args, None, execv) - - def spawnve(mode, file, args, env): - """spawnve(mode, file, args, env) -> integer - -Execute file with arguments from args in a subprocess with the -specified environment. -If mode == P_NOWAIT return the pid of the process. -If mode == P_WAIT return the process's exit code if it exits normally; -otherwise return -SIG, where SIG is the signal that killed it. """ - return _spawnvef(mode, file, args, env, execve) - - # Note: spawnvp[e] is't currently supported on Windows - - def spawnvp(mode, file, args): - """spawnvp(mode, file, args) -> integer - -Execute file (which is looked for along $PATH) with arguments from -args in a subprocess. -If mode == P_NOWAIT return the pid of the process. -If mode == P_WAIT return the process's exit code if it exits normally; -otherwise return -SIG, where SIG is the signal that killed it. """ - return _spawnvef(mode, file, args, None, execvp) - - def spawnvpe(mode, file, args, env): - """spawnvpe(mode, file, args, env) -> integer - -Execute file (which is looked for along $PATH) with arguments from -args in a subprocess with the supplied environment. -If mode == P_NOWAIT return the pid of the process. -If mode == P_WAIT return the process's exit code if it exits normally; -otherwise return -SIG, where SIG is the signal that killed it. """ - return _spawnvef(mode, file, args, env, execvpe) - -if _exists("spawnv"): - # These aren't supplied by the basic Windows code - # but can be easily implemented in Python - - def spawnl(mode, file, *args): - """spawnl(mode, file, *args) -> integer - -Execute file with arguments from args in a subprocess. -If mode == P_NOWAIT return the pid of the process. -If mode == P_WAIT return the process's exit code if it exits normally; -otherwise return -SIG, where SIG is the signal that killed it. """ - return spawnv(mode, file, args) - - def spawnle(mode, file, *args): - """spawnle(mode, file, *args, env) -> integer - -Execute file with arguments from args in a subprocess with the -supplied environment. -If mode == P_NOWAIT return the pid of the process. -If mode == P_WAIT return the process's exit code if it exits normally; -otherwise return -SIG, where SIG is the signal that killed it. """ - env = args[-1] - return spawnve(mode, file, args[:-1], env) - -if _exists("spawnvp"): - # At the moment, Windows doesn't implement spawnvp[e], - # so it won't have spawnlp[e] either. - def spawnlp(mode, file, *args): - """spawnlp(mode, file, *args, env) -> integer - -Execute file (which is looked for along $PATH) with arguments from -args in a subprocess with the supplied environment. -If mode == P_NOWAIT return the pid of the process. -If mode == P_WAIT return the process's exit code if it exits normally; -otherwise return -SIG, where SIG is the signal that killed it. """ - return spawnvp(mode, file, args) - - def spawnlpe(mode, file, *args): - """spawnlpe(mode, file, *args, env) -> integer - -Execute file (which is looked for along $PATH) with arguments from -args in a subprocess with the supplied environment. -If mode == P_NOWAIT return the pid of the process. -If mode == P_WAIT return the process's exit code if it exits normally; -otherwise return -SIG, where SIG is the signal that killed it. """ - env = args[-1] - return spawnvpe(mode, file, args[:-1], env) - - - __all__.extend(["spawnlp","spawnlpe","spawnv", "spawnve","spawnvp", - "spawnvpe","spawnl","spawnle",]) - - -# Supply popen2 etc. (for Unix) -if _exists("fork"): - if not _exists("popen2"): - def popen2(cmd, mode="t", bufsize=-1): - import popen2 - stdout, stdin = popen2.popen2(cmd, bufsize) - return stdin, stdout - __all__.append("popen2") - - if not _exists("popen3"): - def popen3(cmd, mode="t", bufsize=-1): - import popen2 - stdout, stdin, stderr = popen2.popen3(cmd, bufsize) - return stdin, stdout, stderr - __all__.append("popen3") - - if not _exists("popen4"): - def popen4(cmd, mode="t", bufsize=-1): - import popen2 - stdout, stdin = popen2.popen4(cmd, bufsize) - return stdin, stdout - __all__.append("popen4") - -import copy_reg as _copy_reg - -def _make_stat_result(tup, dict): - return stat_result(tup, dict) - -def _pickle_stat_result(sr): - (type, args) = sr.__reduce__() - return (_make_stat_result, args) - -try: - _copy_reg.pickle(stat_result, _pickle_stat_result, _make_stat_result) -except NameError: # stat_result may not exist - pass - -def _make_statvfs_result(tup, dict): - return statvfs_result(tup, dict) - -def _pickle_statvfs_result(sr): - (type, args) = sr.__reduce__() - return (_make_statvfs_result, args) - -try: - _copy_reg.pickle(statvfs_result, _pickle_statvfs_result, - _make_statvfs_result) -except NameError: # statvfs_result may not exist - pass diff --git a/Scripts/ServerPython/python/system/pdb.py b/Scripts/ServerPython/python/system/pdb.py deleted file mode 100644 index 4a2e9f6a..00000000 --- a/Scripts/ServerPython/python/system/pdb.py +++ /dev/null @@ -1,957 +0,0 @@ -#! /usr/bin/env python - -"""A Python debugger.""" - -# (See pdb.doc for documentation.) - -import sys -import linecache -import cmd -import bdb -from repr import Repr -import os -import re - -# Create a custom safe Repr instance and increase its maxstring. -# The default of 30 truncates error messages too easily. -_repr = Repr() -_repr.maxstring = 200 -_saferepr = _repr.repr - -__all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace", - "post_mortem", "help"] - -def find_function(funcname, filename): - cre = re.compile(r'def\s+%s\s*[(]' % funcname) - try: - fp = open(filename) - except IOError: - return None - # consumer of this info expects the first line to be 1 - lineno = 1 - answer = None - while 1: - line = fp.readline() - if line == '': - break - if cre.match(line): - answer = funcname, filename, lineno - break - lineno = lineno + 1 - fp.close() - return answer - - -# Interaction prompt line will separate file and call info from code -# text using value of line_prefix string. A newline and arrow may -# be to your liking. You can set it once pdb is imported using the -# command "pdb.line_prefix = '\n% '". -# line_prefix = ': ' # Use this to get the old situation back -line_prefix = '\n-> ' # Probably a better default - -class Pdb(bdb.Bdb, cmd.Cmd): - - def __init__(self): - bdb.Bdb.__init__(self) - cmd.Cmd.__init__(self) - self.prompt = '(Pdb) ' - self.aliases = {} - # Try to load readline if it exists - try: - import readline - except ImportError: - pass - - # Read $HOME/.pdbrc and ./.pdbrc - self.rcLines = [] - if os.environ.has_key('HOME'): - envHome = os.environ['HOME'] - try: - rcFile = open(os.path.join(envHome, ".pdbrc")) - except IOError: - pass - else: - for line in rcFile.readlines(): - self.rcLines.append(line) - rcFile.close() - try: - rcFile = open(".pdbrc") - except IOError: - pass - else: - for line in rcFile.readlines(): - self.rcLines.append(line) - rcFile.close() - - def reset(self): - bdb.Bdb.reset(self) - self.forget() - - def forget(self): - self.lineno = None - self.stack = [] - self.curindex = 0 - self.curframe = None - - def setup(self, f, t): - self.forget() - self.stack, self.curindex = self.get_stack(f, t) - self.curframe = self.stack[self.curindex][0] - self.execRcLines() - - # Can be executed earlier than 'setup' if desired - def execRcLines(self): - if self.rcLines: - # Make local copy because of recursion - rcLines = self.rcLines - # executed only once - self.rcLines = [] - for line in rcLines: - line = line[:-1] - if len (line) > 0 and line[0] != '#': - self.onecmd (line) - - # Override Bdb methods (except user_call, for now) - - def user_line(self, frame): - """This function is called when we stop or break at this line.""" - self.interaction(frame, None) - - def user_return(self, frame, return_value): - """This function is called when a return trap is set here.""" - frame.f_locals['__return__'] = return_value - print '--Return--' - self.interaction(frame, None) - - def user_exception(self, frame, (exc_type, exc_value, exc_traceback)): - """This function is called if an exception occurs, - but only if we are to stop at or just below this level.""" - frame.f_locals['__exception__'] = exc_type, exc_value - if type(exc_type) == type(''): - exc_type_name = exc_type - else: exc_type_name = exc_type.__name__ - print exc_type_name + ':', _saferepr(exc_value) - self.interaction(frame, exc_traceback) - - # General interaction function - - def interaction(self, frame, traceback): - self.setup(frame, traceback) - self.print_stack_entry(self.stack[self.curindex]) - self.cmdloop() - self.forget() - - def default(self, line): - if line[:1] == '!': line = line[1:] - locals = self.curframe.f_locals - globals = self.curframe.f_globals - try: - code = compile(line + '\n', '', 'single') - exec code in globals, locals - except: - t, v = sys.exc_info()[:2] - if type(t) == type(''): - exc_type_name = t - else: exc_type_name = t.__name__ - print '***', exc_type_name + ':', v - - def precmd(self, line): - """Handle alias expansion and ';;' separator.""" - if not line.strip(): - return line - args = line.split() - while self.aliases.has_key(args[0]): - line = self.aliases[args[0]] - ii = 1 - for tmpArg in args[1:]: - line = line.replace("%" + str(ii), - tmpArg) - ii = ii + 1 - line = line.replace("%*", ' '.join(args[1:])) - args = line.split() - # split into ';;' separated commands - # unless it's an alias command - if args[0] != 'alias': - marker = line.find(';;') - if marker >= 0: - # queue up everything after marker - next = line[marker+2:].lstrip() - self.cmdqueue.append(next) - line = line[:marker].rstrip() - return line - - # Command definitions, called by cmdloop() - # The argument is the remaining string on the command line - # Return true to exit from the command loop - - do_h = cmd.Cmd.do_help - - def do_EOF(self, arg): - return 0 # Don't die on EOF - - def do_break(self, arg, temporary = 0): - # break [ ([filename:]lineno | function) [, "condition"] ] - if not arg: - if self.breaks: # There's at least one - print "Num Type Disp Enb Where" - for bp in bdb.Breakpoint.bpbynumber: - if bp: - bp.bpprint() - return - # parse arguments; comma has lowest precedence - # and cannot occur in filename - filename = None - lineno = None - cond = None - comma = arg.find(',') - if comma > 0: - # parse stuff after comma: "condition" - cond = arg[comma+1:].lstrip() - arg = arg[:comma].rstrip() - # parse stuff before comma: [filename:]lineno | function - colon = arg.rfind(':') - if colon >= 0: - filename = arg[:colon].rstrip() - f = self.lookupmodule(filename) - if not f: - print '*** ', `filename`, - print 'not found from sys.path' - return - else: - filename = f - arg = arg[colon+1:].lstrip() - try: - lineno = int(arg) - except ValueError, msg: - print '*** Bad lineno:', arg - return - else: - # no colon; can be lineno or function - try: - lineno = int(arg) - except ValueError: - try: - func = eval(arg, - self.curframe.f_globals, - self.curframe.f_locals) - except: - func = arg - try: - if hasattr(func, 'im_func'): - func = func.im_func - code = func.func_code - lineno = code.co_firstlineno - filename = code.co_filename - except: - # last thing to try - (ok, filename, ln) = self.lineinfo(arg) - if not ok: - print '*** The specified object', - print `arg`, - print 'is not a function' - print ('or was not found ' - 'along sys.path.') - return - lineno = int(ln) - if not filename: - filename = self.defaultFile() - # Check for reasonable breakpoint - line = self.checkline(filename, lineno) - if line: - # now set the break point - err = self.set_break(filename, line, temporary, cond) - if err: print '***', err - else: - bp = self.get_breaks(filename, line)[-1] - print "Breakpoint %d at %s:%d" % (bp.number, - bp.file, - bp.line) - - # To be overridden in derived debuggers - def defaultFile(self): - """Produce a reasonable default.""" - filename = self.curframe.f_code.co_filename - if filename == '' and mainpyfile: - filename = mainpyfile - return filename - - do_b = do_break - - def do_tbreak(self, arg): - self.do_break(arg, 1) - - def lineinfo(self, identifier): - failed = (None, None, None) - # Input is identifier, may be in single quotes - idstring = identifier.split("'") - if len(idstring) == 1: - # not in single quotes - id = idstring[0].strip() - elif len(idstring) == 3: - # quoted - id = idstring[1].strip() - else: - return failed - if id == '': return failed - parts = id.split('.') - # Protection for derived debuggers - if parts[0] == 'self': - del parts[0] - if len(parts) == 0: - return failed - # Best first guess at file to look at - fname = self.defaultFile() - if len(parts) == 1: - item = parts[0] - else: - # More than one part. - # First is module, second is method/class - f = self.lookupmodule(parts[0]) - if f: - fname = f - item = parts[1] - answer = find_function(item, fname) - return answer or failed - - def checkline(self, filename, lineno): - """Return line number of first line at or after input - argument such that if the input points to a 'def', the - returned line number is the first - non-blank/non-comment line to follow. If the input - points to a blank or comment line, return 0. At end - of file, also return 0.""" - - line = linecache.getline(filename, lineno) - if not line: - print 'End of file' - return 0 - line = line.strip() - # Don't allow setting breakpoint at a blank line - if ( not line or (line[0] == '#') or - (line[:3] == '"""') or line[:3] == "'''" ): - print '*** Blank or comment' - return 0 - # When a file is read in and a breakpoint is at - # the 'def' statement, the system stops there at - # code parse time. We don't want that, so all breakpoints - # set at 'def' statements are moved one line onward - if line[:3] == 'def': - instr = '' - brackets = 0 - while 1: - skipone = 0 - for c in line: - if instr: - if skipone: - skipone = 0 - elif c == '\\': - skipone = 1 - elif c == instr: - instr = '' - elif c == '#': - break - elif c in ('"',"'"): - instr = c - elif c in ('(','{','['): - brackets = brackets + 1 - elif c in (')','}',']'): - brackets = brackets - 1 - lineno = lineno+1 - line = linecache.getline(filename, lineno) - if not line: - print 'end of file' - return 0 - line = line.strip() - if not line: continue # Blank line - if brackets <= 0 and line[0] not in ('#','"',"'"): - break - return lineno - - def do_enable(self, arg): - args = arg.split() - for i in args: - bp = bdb.Breakpoint.bpbynumber[int(i)] - if bp: - bp.enable() - - def do_disable(self, arg): - args = arg.split() - for i in args: - bp = bdb.Breakpoint.bpbynumber[int(i)] - if bp: - bp.disable() - - def do_condition(self, arg): - # arg is breakpoint number and condition - args = arg.split(' ', 1) - bpnum = int(args[0].strip()) - try: - cond = args[1] - except: - cond = None - bp = bdb.Breakpoint.bpbynumber[bpnum] - if bp: - bp.cond = cond - if not cond: - print 'Breakpoint', bpnum, - print 'is now unconditional.' - - def do_ignore(self,arg): - """arg is bp number followed by ignore count.""" - args = arg.split() - bpnum = int(args[0].strip()) - try: - count = int(args[1].strip()) - except: - count = 0 - bp = bdb.Breakpoint.bpbynumber[bpnum] - if bp: - bp.ignore = count - if (count > 0): - reply = 'Will ignore next ' - if (count > 1): - reply = reply + '%d crossings' % count - else: - reply = reply + '1 crossing' - print reply + ' of breakpoint %d.' % bpnum - else: - print 'Will stop next time breakpoint', - print bpnum, 'is reached.' - - def do_clear(self, arg): - """Three possibilities, tried in this order: - clear -> clear all breaks, ask for confirmation - clear file:lineno -> clear all breaks at file:lineno - clear bpno bpno ... -> clear breakpoints by number""" - if not arg: - try: - reply = raw_input('Clear all breaks? ') - except EOFError: - reply = 'no' - reply = reply.strip().lower() - if reply in ('y', 'yes'): - self.clear_all_breaks() - return - if ':' in arg: - # Make sure it works for "clear C:\foo\bar.py:12" - i = arg.rfind(':') - filename = arg[:i] - arg = arg[i+1:] - try: - lineno = int(arg) - except: - err = "Invalid line number (%s)" % arg - else: - err = self.clear_break(filename, lineno) - if err: print '***', err - return - numberlist = arg.split() - for i in numberlist: - err = self.clear_bpbynumber(i) - if err: - print '***', err - else: - print 'Deleted breakpoint %s ' % (i,) - do_cl = do_clear # 'c' is already an abbreviation for 'continue' - - def do_where(self, arg): - self.print_stack_trace() - do_w = do_where - do_bt = do_where - - def do_up(self, arg): - if self.curindex == 0: - print '*** Oldest frame' - else: - self.curindex = self.curindex - 1 - self.curframe = self.stack[self.curindex][0] - self.print_stack_entry(self.stack[self.curindex]) - self.lineno = None - do_u = do_up - - def do_down(self, arg): - if self.curindex + 1 == len(self.stack): - print '*** Newest frame' - else: - self.curindex = self.curindex + 1 - self.curframe = self.stack[self.curindex][0] - self.print_stack_entry(self.stack[self.curindex]) - self.lineno = None - do_d = do_down - - def do_step(self, arg): - self.set_step() - return 1 - do_s = do_step - - def do_next(self, arg): - self.set_next(self.curframe) - return 1 - do_n = do_next - - def do_return(self, arg): - self.set_return(self.curframe) - return 1 - do_r = do_return - - def do_continue(self, arg): - self.set_continue() - return 1 - do_c = do_cont = do_continue - - def do_quit(self, arg): - self.set_quit() - return 1 - do_q = do_quit - do_exit = do_quit - - def do_args(self, arg): - f = self.curframe - co = f.f_code - dict = f.f_locals - n = co.co_argcount - if co.co_flags & 4: n = n+1 - if co.co_flags & 8: n = n+1 - for i in range(n): - name = co.co_varnames[i] - print name, '=', - if dict.has_key(name): print dict[name] - else: print "*** undefined ***" - do_a = do_args - - def do_retval(self, arg): - if self.curframe.f_locals.has_key('__return__'): - print self.curframe.f_locals['__return__'] - else: - print '*** Not yet returned!' - do_rv = do_retval - - def do_p(self, arg): - try: - value = eval(arg, self.curframe.f_globals, - self.curframe.f_locals) - except: - t, v = sys.exc_info()[:2] - if type(t) == type(''): - exc_type_name = t - else: exc_type_name = t.__name__ - print '***', exc_type_name + ':', `v` - return - - print `value` - - def do_list(self, arg): - self.lastcmd = 'list' - last = None - if arg: - try: - x = eval(arg, {}, {}) - if type(x) == type(()): - first, last = x - first = int(first) - last = int(last) - if last < first: - # Assume it's a count - last = first + last - else: - first = max(1, int(x) - 5) - except: - print '*** Error in argument:', `arg` - return - elif self.lineno is None: - first = max(1, self.curframe.f_lineno - 5) - else: - first = self.lineno + 1 - if last is None: - last = first + 10 - filename = self.curframe.f_code.co_filename - breaklist = self.get_file_breaks(filename) - try: - for lineno in range(first, last+1): - line = linecache.getline(filename, lineno) - if not line: - print '[EOF]' - break - else: - s = `lineno`.rjust(3) - if len(s) < 4: s = s + ' ' - if lineno in breaklist: s = s + 'B' - else: s = s + ' ' - if lineno == self.curframe.f_lineno: - s = s + '->' - print s + '\t' + line, - self.lineno = lineno - except KeyboardInterrupt: - pass - do_l = do_list - - def do_whatis(self, arg): - try: - value = eval(arg, self.curframe.f_globals, - self.curframe.f_locals) - except: - t, v = sys.exc_info()[:2] - if type(t) == type(''): - exc_type_name = t - else: exc_type_name = t.__name__ - print '***', exc_type_name + ':', `v` - return - code = None - # Is it a function? - try: code = value.func_code - except: pass - if code: - print 'Function', code.co_name - return - # Is it an instance method? - try: code = value.im_func.func_code - except: pass - if code: - print 'Method', code.co_name - return - # None of the above... - print type(value) - - def do_alias(self, arg): - args = arg.split() - if len(args) == 0: - keys = self.aliases.keys() - keys.sort() - for alias in keys: - print "%s = %s" % (alias, self.aliases[alias]) - return - if self.aliases.has_key(args[0]) and len (args) == 1: - print "%s = %s" % (args[0], self.aliases[args[0]]) - else: - self.aliases[args[0]] = ' '.join(args[1:]) - - def do_unalias(self, arg): - args = arg.split() - if len(args) == 0: return - if self.aliases.has_key(args[0]): - del self.aliases[args[0]] - - # Print a traceback starting at the top stack frame. - # The most recently entered frame is printed last; - # this is different from dbx and gdb, but consistent with - # the Python interpreter's stack trace. - # It is also consistent with the up/down commands (which are - # compatible with dbx and gdb: up moves towards 'main()' - # and down moves towards the most recent stack frame). - - def print_stack_trace(self): - try: - for frame_lineno in self.stack: - self.print_stack_entry(frame_lineno) - except KeyboardInterrupt: - pass - - def print_stack_entry(self, frame_lineno, prompt_prefix=line_prefix): - frame, lineno = frame_lineno - if frame is self.curframe: - print '>', - else: - print ' ', - print self.format_stack_entry(frame_lineno, prompt_prefix) - - - # Help methods (derived from pdb.doc) - - def help_help(self): - self.help_h() - - def help_h(self): - print """h(elp) -Without argument, print the list of available commands. -With a command name as argument, print help about that command -"help pdb" pipes the full documentation file to the $PAGER -"help exec" gives help on the ! command""" - - def help_where(self): - self.help_w() - - def help_w(self): - print """w(here) -Print a stack trace, with the most recent frame at the bottom. -An arrow indicates the "current frame", which determines the -context of most commands. 'bt' is an alias for this command.""" - - help_bt = help_w - - def help_down(self): - self.help_d() - - def help_d(self): - print """d(own) -Move the current frame one level down in the stack trace -(to an older frame).""" - - def help_up(self): - self.help_u() - - def help_u(self): - print """u(p) -Move the current frame one level up in the stack trace -(to a newer frame).""" - - def help_break(self): - self.help_b() - - def help_b(self): - print """b(reak) ([file:]lineno | function) [, condition] -With a line number argument, set a break there in the current -file. With a function name, set a break at first executable line -of that function. Without argument, list all breaks. If a second -argument is present, it is a string specifying an expression -which must evaluate to true before the breakpoint is honored. - -The line number may be prefixed with a filename and a colon, -to specify a breakpoint in another file (probably one that -hasn't been loaded yet). The file is searched for on sys.path; -the .py suffix may be omitted.""" - - def help_clear(self): - self.help_cl() - - def help_cl(self): - print "cl(ear) filename:lineno" - print """cl(ear) [bpnumber [bpnumber...]] -With a space separated list of breakpoint numbers, clear -those breakpoints. Without argument, clear all breaks (but -first ask confirmation). With a filename:lineno argument, -clear all breaks at that line in that file. - -Note that the argument is different from previous versions of -the debugger (in python distributions 1.5.1 and before) where -a linenumber was used instead of either filename:lineno or -breakpoint numbers.""" - - def help_tbreak(self): - print """tbreak same arguments as break, but breakpoint is -removed when first hit.""" - - def help_enable(self): - print """enable bpnumber [bpnumber ...] -Enables the breakpoints given as a space separated list of -bp numbers.""" - - def help_disable(self): - print """disable bpnumber [bpnumber ...] -Disables the breakpoints given as a space separated list of -bp numbers.""" - - def help_ignore(self): - print """ignore bpnumber count -Sets the ignore count for the given breakpoint number. A breakpoint -becomes active when the ignore count is zero. When non-zero, the -count is decremented each time the breakpoint is reached and the -breakpoint is not disabled and any associated condition evaluates -to true.""" - - def help_condition(self): - print """condition bpnumber str_condition -str_condition is a string specifying an expression which -must evaluate to true before the breakpoint is honored. -If str_condition is absent, any existing condition is removed; -i.e., the breakpoint is made unconditional.""" - - def help_step(self): - self.help_s() - - def help_s(self): - print """s(tep) -Execute the current line, stop at the first possible occasion -(either in a function that is called or in the current function).""" - - def help_next(self): - self.help_n() - - def help_n(self): - print """n(ext) -Continue execution until the next line in the current function -is reached or it returns.""" - - def help_return(self): - self.help_r() - - def help_r(self): - print """r(eturn) -Continue execution until the current function returns.""" - - def help_continue(self): - self.help_c() - - def help_cont(self): - self.help_c() - - def help_c(self): - print """c(ont(inue)) -Continue execution, only stop when a breakpoint is encountered.""" - - def help_list(self): - self.help_l() - - def help_l(self): - print """l(ist) [first [,last]] -List source code for the current file. -Without arguments, list 11 lines around the current line -or continue the previous listing. -With one argument, list 11 lines starting at that line. -With two arguments, list the given range; -if the second argument is less than the first, it is a count.""" - - def help_args(self): - self.help_a() - - def help_a(self): - print """a(rgs) -Print the arguments of the current function.""" - - def help_p(self): - print """p expression -Print the value of the expression.""" - - def help_exec(self): - print """(!) statement -Execute the (one-line) statement in the context of -the current stack frame. -The exclamation point can be omitted unless the first word -of the statement resembles a debugger command. -To assign to a global variable you must always prefix the -command with a 'global' command, e.g.: -(Pdb) global list_options; list_options = ['-l'] -(Pdb)""" - - def help_quit(self): - self.help_q() - - def help_q(self): - print """q(uit) or exit - Quit from the debugger. -The program being executed is aborted.""" - - help_exit = help_q - - def help_whatis(self): - print """whatis arg -Prints the type of the argument.""" - - def help_EOF(self): - print """EOF -Handles the receipt of EOF as a command.""" - - def help_alias(self): - print """alias [name [command [parameter parameter ...] ]] -Creates an alias called 'name' the executes 'command'. The command -must *not* be enclosed in quotes. Replaceable parameters are -indicated by %1, %2, and so on, while %* is replaced by all the -parameters. If no command is given, the current alias for name -is shown. If no name is given, all aliases are listed. - -Aliases may be nested and can contain anything that can be -legally typed at the pdb prompt. Note! You *can* override -internal pdb commands with aliases! Those internal commands -are then hidden until the alias is removed. Aliasing is recursively -applied to the first word of the command line; all other words -in the line are left alone. - -Some useful aliases (especially when placed in the .pdbrc file) are: - -#Print instance variables (usage "pi classInst") -alias pi for k in %1.__dict__.keys(): print "%1.",k,"=",%1.__dict__[k] - -#Print instance variables in self -alias ps pi self -""" - - def help_unalias(self): - print """unalias name -Deletes the specified alias.""" - - def help_pdb(self): - help() - - def lookupmodule(self, filename): - """Helper function for break/clear parsing -- may be overridden.""" - root, ext = os.path.splitext(filename) - if ext == '': - filename = filename + '.py' - if os.path.isabs(filename): - return filename - for dirname in sys.path: - while os.path.islink(dirname): - dirname = os.readlink(dirname) - fullname = os.path.join(dirname, filename) - if os.path.exists(fullname): - return fullname - return None - -# Simplified interface - -def run(statement, globals=None, locals=None): - Pdb().run(statement, globals, locals) - -def runeval(expression, globals=None, locals=None): - return Pdb().runeval(expression, globals, locals) - -def runctx(statement, globals, locals): - # B/W compatibility - run(statement, globals, locals) - -def runcall(*args): - return apply(Pdb().runcall, args) - -def set_trace(): - Pdb().set_trace() - -# Post-Mortem interface - -def post_mortem(t): - p = Pdb() - p.reset() - while t.tb_next is not None: - t = t.tb_next - p.interaction(t.tb_frame, t) - -def pm(): - post_mortem(sys.last_traceback) - - -# Main program for testing - -TESTCMD = 'import x; x.main()' - -def test(): - run(TESTCMD) - -# print help -def help(): - for dirname in sys.path: - fullname = os.path.join(dirname, 'pdb.doc') - if os.path.exists(fullname): - sts = os.system('${PAGER-more} '+fullname) - if sts: print '*** Pager exit status:', sts - break - else: - print 'Sorry, can\'t find the help file "pdb.doc"', - print 'along the Python search path' - -mainmodule = '' -mainpyfile = '' - -# When invoked as main program, invoke the debugger on a script -if __name__=='__main__': - if not sys.argv[1:]: - print "usage: pdb.py scriptfile [arg] ..." - sys.exit(2) - - mainpyfile = filename = sys.argv[1] # Get script filename - if not os.path.exists(filename): - print 'Error:', `filename`, 'does not exist' - sys.exit(1) - mainmodule = os.path.basename(filename) - del sys.argv[0] # Hide "pdb.py" from argument list - - # Insert script directory in front of module search path - sys.path.insert(0, os.path.dirname(filename)) - - run('execfile(' + `filename` + ')') diff --git a/Scripts/ServerPython/python/system/pickle.py b/Scripts/ServerPython/python/system/pickle.py deleted file mode 100644 index 369dd749..00000000 --- a/Scripts/ServerPython/python/system/pickle.py +++ /dev/null @@ -1,986 +0,0 @@ -"""Create portable serialized representations of Python objects. - -See module cPickle for a (much) faster implementation. -See module copy_reg for a mechanism for registering custom picklers. - -Classes: - - Pickler - Unpickler - -Functions: - - dump(object, file) - dumps(object) -> string - load(file) -> object - loads(string) -> object - -Misc variables: - - __version__ - format_version - compatible_formats - -""" - -__version__ = "$Revision: 1.56.4.4 $" # Code version - -from types import * -from copy_reg import dispatch_table, safe_constructors -import marshal -import sys -import struct -import re - -__all__ = ["PickleError", "PicklingError", "UnpicklingError", "Pickler", - "Unpickler", "dump", "dumps", "load", "loads"] - -format_version = "1.3" # File format version we write -compatible_formats = ["1.0", "1.1", "1.2"] # Old format versions we can read - -mdumps = marshal.dumps -mloads = marshal.loads - -class PickleError(Exception): pass -class PicklingError(PickleError): pass -class UnpicklingError(PickleError): pass - -class _Stop(Exception): - def __init__(self, value): - self.value = value - -try: - from org.python.core import PyStringMap -except ImportError: - PyStringMap = None - -try: - UnicodeType -except NameError: - UnicodeType = None - - -MARK = '(' -STOP = '.' -POP = '0' -POP_MARK = '1' -DUP = '2' -FLOAT = 'F' -INT = 'I' -BININT = 'J' -BININT1 = 'K' -LONG = 'L' -BININT2 = 'M' -NONE = 'N' -PERSID = 'P' -BINPERSID = 'Q' -REDUCE = 'R' -STRING = 'S' -BINSTRING = 'T' -SHORT_BINSTRING = 'U' -UNICODE = 'V' -BINUNICODE = 'X' -APPEND = 'a' -BUILD = 'b' -GLOBAL = 'c' -DICT = 'd' -EMPTY_DICT = '}' -APPENDS = 'e' -GET = 'g' -BINGET = 'h' -INST = 'i' -LONG_BINGET = 'j' -LIST = 'l' -EMPTY_LIST = ']' -OBJ = 'o' -PUT = 'p' -BINPUT = 'q' -LONG_BINPUT = 'r' -SETITEM = 's' -TUPLE = 't' -EMPTY_TUPLE = ')' -SETITEMS = 'u' -BINFLOAT = 'G' - -__all__.extend([x for x in dir() if re.match("[A-Z][A-Z0-9_]+$",x)]) - -class Pickler: - - def __init__(self, file, bin = 0): - self.write = file.write - self.memo = {} - self.bin = bin - - def dump(self, object): - self.save(object) - self.write(STOP) - - def put(self, i): - if self.bin: - s = mdumps(i)[1:] - if i < 256: - return BINPUT + s[0] - - return LONG_BINPUT + s - - return PUT + `i` + '\n' - - def get(self, i): - if self.bin: - s = mdumps(i)[1:] - - if i < 256: - return BINGET + s[0] - - return LONG_BINGET + s - - return GET + `i` + '\n' - - def save(self, object, pers_save = 0): - memo = self.memo - - if not pers_save: - pid = self.persistent_id(object) - if pid is not None: - self.save_pers(pid) - return - - d = id(object) - - t = type(object) - - if (t is TupleType) and (len(object) == 0): - if self.bin: - self.save_empty_tuple(object) - else: - self.save_tuple(object) - return - - if memo.has_key(d): - self.write(self.get(memo[d][0])) - return - - try: - f = self.dispatch[t] - except KeyError: - pid = self.inst_persistent_id(object) - if pid is not None: - self.save_pers(pid) - return - - try: - issc = issubclass(t, TypeType) - except TypeError: # t is not a class - issc = 0 - if issc: - self.save_global(object) - return - - try: - reduce = dispatch_table[t] - except KeyError: - try: - reduce = object.__reduce__ - except AttributeError: - raise PicklingError, \ - "can't pickle %s object: %s" % (`t.__name__`, - `object`) - else: - tup = reduce() - else: - tup = reduce(object) - - if type(tup) is StringType: - self.save_global(object, tup) - return - - if type(tup) is not TupleType: - raise PicklingError, "Value returned by %s must be a " \ - "tuple" % reduce - - l = len(tup) - - if (l != 2) and (l != 3): - raise PicklingError, "tuple returned by %s must contain " \ - "only two or three elements" % reduce - - callable = tup[0] - arg_tup = tup[1] - - if l > 2: - state = tup[2] - else: - state = None - - if type(arg_tup) is not TupleType and arg_tup is not None: - raise PicklingError, "Second element of tuple returned " \ - "by %s must be a tuple" % reduce - - self.save_reduce(callable, arg_tup, state) - memo_len = len(memo) - self.write(self.put(memo_len)) - memo[d] = (memo_len, object) - return - - f(self, object) - - def persistent_id(self, object): - return None - - def inst_persistent_id(self, object): - return None - - def save_pers(self, pid): - if not self.bin: - self.write(PERSID + str(pid) + '\n') - else: - self.save(pid, 1) - self.write(BINPERSID) - - def save_reduce(self, callable, arg_tup, state = None): - write = self.write - save = self.save - - save(callable) - save(arg_tup) - write(REDUCE) - - if state is not None: - save(state) - write(BUILD) - - dispatch = {} - - def save_none(self, object): - self.write(NONE) - dispatch[NoneType] = save_none - - def save_int(self, object): - if self.bin: - # If the int is small enough to fit in a signed 4-byte 2's-comp - # format, we can store it more efficiently than the general - # case. - high_bits = object >> 31 # note that Python shift sign-extends - if high_bits == 0 or high_bits == -1: - # All high bits are copies of bit 2**31, so the value - # fits in a 4-byte signed int. - i = mdumps(object)[1:] - assert len(i) == 4 - if i[-2:] == '\000\000': # fits in 2-byte unsigned int - if i[-3] == '\000': # fits in 1-byte unsigned int - self.write(BININT1 + i[0]) - else: - self.write(BININT2 + i[:2]) - else: - self.write(BININT + i) - return - # Text pickle, or int too big to fit in signed 4-byte format. - self.write(INT + `object` + '\n') - dispatch[IntType] = save_int - - def save_long(self, object): - self.write(LONG + `object` + '\n') - dispatch[LongType] = save_long - - def save_float(self, object, pack=struct.pack): - if self.bin: - self.write(BINFLOAT + pack('>d', object)) - else: - self.write(FLOAT + `object` + '\n') - dispatch[FloatType] = save_float - - def save_string(self, object): - d = id(object) - memo = self.memo - - if self.bin: - l = len(object) - s = mdumps(l)[1:] - if l < 256: - self.write(SHORT_BINSTRING + s[0] + object) - else: - self.write(BINSTRING + s + object) - else: - self.write(STRING + `object` + '\n') - - memo_len = len(memo) - self.write(self.put(memo_len)) - memo[d] = (memo_len, object) - dispatch[StringType] = save_string - - def save_unicode(self, object): - d = id(object) - memo = self.memo - - if self.bin: - encoding = object.encode('utf-8') - l = len(encoding) - s = mdumps(l)[1:] - self.write(BINUNICODE + s + encoding) - else: - object = object.replace("\\", "\\u005c") - object = object.replace("\n", "\\u000a") - self.write(UNICODE + object.encode('raw-unicode-escape') + '\n') - - memo_len = len(memo) - self.write(self.put(memo_len)) - memo[d] = (memo_len, object) - dispatch[UnicodeType] = save_unicode - - if StringType == UnicodeType: - # This is true for Jython - def save_string(self, object): - d = id(object) - memo = self.memo - unicode = object.isunicode() - - if self.bin: - if unicode: - object = object.encode("utf-8") - l = len(object) - s = mdumps(l)[1:] - if l < 256 and not unicode: - self.write(SHORT_BINSTRING + s[0] + object) - else: - if unicode: - self.write(BINUNICODE + s + object) - else: - self.write(BINSTRING + s + object) - else: - if unicode: - object = object.replace("\\", "\\u005c") - object = object.replace("\n", "\\u000a") - object = object.encode('raw-unicode-escape') - self.write(UNICODE + object + '\n') - else: - self.write(STRING + `object` + '\n') - - memo_len = len(memo) - self.write(self.put(memo_len)) - memo[d] = (memo_len, object) - dispatch[StringType] = save_string - - def save_tuple(self, object): - - write = self.write - save = self.save - memo = self.memo - - d = id(object) - - write(MARK) - - for element in object: - save(element) - - if len(object) and memo.has_key(d): - if self.bin: - write(POP_MARK + self.get(memo[d][0])) - return - - write(POP * (len(object) + 1) + self.get(memo[d][0])) - return - - memo_len = len(memo) - self.write(TUPLE + self.put(memo_len)) - memo[d] = (memo_len, object) - dispatch[TupleType] = save_tuple - - def save_empty_tuple(self, object): - self.write(EMPTY_TUPLE) - - def save_list(self, object): - d = id(object) - - write = self.write - save = self.save - memo = self.memo - - if self.bin: - write(EMPTY_LIST) - else: - write(MARK + LIST) - - memo_len = len(memo) - write(self.put(memo_len)) - memo[d] = (memo_len, object) - - using_appends = (self.bin and (len(object) > 1)) - - if using_appends: - write(MARK) - - for element in object: - save(element) - - if not using_appends: - write(APPEND) - - if using_appends: - write(APPENDS) - dispatch[ListType] = save_list - - def save_dict(self, object): - d = id(object) - - write = self.write - save = self.save - memo = self.memo - - if self.bin: - write(EMPTY_DICT) - else: - write(MARK + DICT) - - memo_len = len(memo) - self.write(self.put(memo_len)) - memo[d] = (memo_len, object) - - using_setitems = (self.bin and (len(object) > 1)) - - if using_setitems: - write(MARK) - - items = object.items() - for key, value in items: - save(key) - save(value) - - if not using_setitems: - write(SETITEM) - - if using_setitems: - write(SETITEMS) - - dispatch[DictionaryType] = save_dict - if not PyStringMap is None: - dispatch[PyStringMap] = save_dict - - def save_inst(self, object): - d = id(object) - cls = object.__class__ - - memo = self.memo - write = self.write - save = self.save - - if hasattr(object, '__getinitargs__'): - args = object.__getinitargs__() - len(args) # XXX Assert it's a sequence - _keep_alive(args, memo) - else: - args = () - - write(MARK) - - if self.bin: - save(cls) - - for arg in args: - save(arg) - - memo_len = len(memo) - if self.bin: - write(OBJ + self.put(memo_len)) - else: - write(INST + cls.__module__ + '\n' + cls.__name__ + '\n' + - self.put(memo_len)) - - memo[d] = (memo_len, object) - - try: - getstate = object.__getstate__ - except AttributeError: - stuff = object.__dict__ - else: - stuff = getstate() - _keep_alive(stuff, memo) - save(stuff) - write(BUILD) - dispatch[InstanceType] = save_inst - - def save_global(self, object, name = None): - write = self.write - memo = self.memo - - if name is None: - name = object.__name__ - - try: - module = object.__module__ - except AttributeError: - module = whichmodule(object, name) - - try: - __import__(module) - mod = sys.modules[module] - klass = getattr(mod, name) - except (ImportError, KeyError, AttributeError): - raise PicklingError( - "Can't pickle %r: it's not found as %s.%s" % - (object, module, name)) - else: - if klass is not object: - raise PicklingError( - "Can't pickle %r: it's not the same object as %s.%s" % - (object, module, name)) - - memo_len = len(memo) - write(GLOBAL + module + '\n' + name + '\n' + - self.put(memo_len)) - memo[id(object)] = (memo_len, object) - dispatch[ClassType] = save_global - dispatch[FunctionType] = save_global - dispatch[BuiltinFunctionType] = save_global - dispatch[TypeType] = save_global - - -def _keep_alive(x, memo): - """Keeps a reference to the object x in the memo. - - Because we remember objects by their id, we have - to assure that possibly temporary objects are kept - alive by referencing them. - We store a reference at the id of the memo, which should - normally not be used unless someone tries to deepcopy - the memo itself... - """ - try: - memo[id(memo)].append(x) - except KeyError: - # aha, this is the first one :-) - memo[id(memo)]=[x] - - -classmap = {} # called classmap for backwards compatibility - -def whichmodule(func, funcname): - """Figure out the module in which a function occurs. - - Search sys.modules for the module. - Cache in classmap. - Return a module name. - If the function cannot be found, return __main__. - """ - if classmap.has_key(func): - return classmap[func] - - for name, module in sys.modules.items(): - if module is None: - continue # skip dummy package entries - if name != '__main__' and \ - hasattr(module, funcname) and \ - getattr(module, funcname) is func: - break - else: - name = '__main__' - classmap[func] = name - return name - - -class Unpickler: - - def __init__(self, file): - self.readline = file.readline - self.read = file.read - self.memo = {} - - def load(self): - self.mark = object() # any new unique object - self.stack = [] - self.append = self.stack.append - read = self.read - dispatch = self.dispatch - try: - while 1: - key = read(1) - dispatch[key](self) - except _Stop, stopinst: - return stopinst.value - - def marker(self): - stack = self.stack - mark = self.mark - k = len(stack)-1 - while stack[k] is not mark: k = k-1 - return k - - dispatch = {} - - def load_eof(self): - raise EOFError - dispatch[''] = load_eof - - def load_persid(self): - pid = self.readline()[:-1] - self.append(self.persistent_load(pid)) - dispatch[PERSID] = load_persid - - def load_binpersid(self): - stack = self.stack - - pid = stack[-1] - del stack[-1] - - self.append(self.persistent_load(pid)) - dispatch[BINPERSID] = load_binpersid - - def load_none(self): - self.append(None) - dispatch[NONE] = load_none - - def load_int(self): - data = self.readline() - try: - self.append(int(data)) - except ValueError: - self.append(long(data)) - dispatch[INT] = load_int - - def load_binint(self): - self.append(mloads('i' + self.read(4))) - dispatch[BININT] = load_binint - - def load_binint1(self): - self.append(mloads('i' + self.read(1) + '\000\000\000')) - dispatch[BININT1] = load_binint1 - - def load_binint2(self): - self.append(mloads('i' + self.read(2) + '\000\000')) - dispatch[BININT2] = load_binint2 - - def load_long(self): - self.append(long(self.readline()[:-1], 0)) - dispatch[LONG] = load_long - - def load_float(self): - self.append(float(self.readline()[:-1])) - dispatch[FLOAT] = load_float - - def load_binfloat(self, unpack=struct.unpack): - self.append(unpack('>d', self.read(8))[0]) - dispatch[BINFLOAT] = load_binfloat - - def load_string(self): - rep = self.readline()[:-1] - if not self._is_string_secure(rep): - raise ValueError, "insecure string pickle" - self.append(eval(rep, - {'__builtins__': {}})) # Let's be careful - dispatch[STRING] = load_string - - def _is_string_secure(self, s): - """Return true if s contains a string that is safe to eval - - The definition of secure string is based on the implementation - in cPickle. s is secure as long as it only contains a quoted - string and optional trailing whitespace. - """ - q = s[0] - if q not in ("'", '"'): - return 0 - # find the closing quote - offset = 1 - i = None - while 1: - try: - i = s.index(q, offset) - except ValueError: - # if there is an error the first time, there is no - # close quote - if offset == 1: - return 0 - if s[i-1] != '\\': - break - # check to see if this one is escaped - nslash = 0 - j = i - 1 - while j >= offset and s[j] == '\\': - j = j - 1 - nslash = nslash + 1 - if nslash % 2 == 0: - break - offset = i + 1 - for c in s[i+1:]: - if ord(c) > 32: - return 0 - return 1 - - def load_binstring(self): - len = mloads('i' + self.read(4)) - self.append(self.read(len)) - dispatch[BINSTRING] = load_binstring - - def load_unicode(self): - self.append(unicode(self.readline()[:-1],'raw-unicode-escape')) - dispatch[UNICODE] = load_unicode - - def load_binunicode(self): - len = mloads('i' + self.read(4)) - self.append(unicode(self.read(len),'utf-8')) - dispatch[BINUNICODE] = load_binunicode - - def load_short_binstring(self): - len = mloads('i' + self.read(1) + '\000\000\000') - self.append(self.read(len)) - dispatch[SHORT_BINSTRING] = load_short_binstring - - def load_tuple(self): - k = self.marker() - self.stack[k:] = [tuple(self.stack[k+1:])] - dispatch[TUPLE] = load_tuple - - def load_empty_tuple(self): - self.stack.append(()) - dispatch[EMPTY_TUPLE] = load_empty_tuple - - def load_empty_list(self): - self.stack.append([]) - dispatch[EMPTY_LIST] = load_empty_list - - def load_empty_dictionary(self): - self.stack.append({}) - dispatch[EMPTY_DICT] = load_empty_dictionary - - def load_list(self): - k = self.marker() - self.stack[k:] = [self.stack[k+1:]] - dispatch[LIST] = load_list - - def load_dict(self): - k = self.marker() - d = {} - items = self.stack[k+1:] - for i in range(0, len(items), 2): - key = items[i] - value = items[i+1] - d[key] = value - self.stack[k:] = [d] - dispatch[DICT] = load_dict - - def load_inst(self): - k = self.marker() - args = tuple(self.stack[k+1:]) - del self.stack[k:] - module = self.readline()[:-1] - name = self.readline()[:-1] - klass = self.find_class(module, name) - instantiated = 0 - if (not args and type(klass) is ClassType and - not hasattr(klass, "__getinitargs__")): - try: - value = _EmptyClass() - value.__class__ = klass - instantiated = 1 - except RuntimeError: - # In restricted execution, assignment to inst.__class__ is - # prohibited - pass - if not instantiated: - try: - if not hasattr(klass, '__safe_for_unpickling__'): - raise UnpicklingError('%s is not safe for unpickling' % - klass) - value = apply(klass, args) - except TypeError, err: - raise TypeError, "in constructor for %s: %s" % ( - klass.__name__, str(err)), sys.exc_info()[2] - self.append(value) - dispatch[INST] = load_inst - - def load_obj(self): - stack = self.stack - k = self.marker() - klass = stack[k + 1] - del stack[k + 1] - args = tuple(stack[k + 1:]) - del stack[k:] - instantiated = 0 - if (not args and type(klass) is ClassType and - not hasattr(klass, "__getinitargs__")): - try: - value = _EmptyClass() - value.__class__ = klass - instantiated = 1 - except RuntimeError: - # In restricted execution, assignment to inst.__class__ is - # prohibited - pass - if not instantiated: - value = apply(klass, args) - self.append(value) - dispatch[OBJ] = load_obj - - def load_global(self): - module = self.readline()[:-1] - name = self.readline()[:-1] - klass = self.find_class(module, name) - self.append(klass) - dispatch[GLOBAL] = load_global - - def find_class(self, module, name): - __import__(module) - mod = sys.modules[module] - klass = getattr(mod, name) - return klass - - def load_reduce(self): - stack = self.stack - - callable = stack[-2] - arg_tup = stack[-1] - del stack[-2:] - - if type(callable) is not ClassType: - if not safe_constructors.has_key(callable): - try: - safe = callable.__safe_for_unpickling__ - except AttributeError: - safe = None - - if not safe: - raise UnpicklingError, "%s is not safe for " \ - "unpickling" % callable - - if arg_tup is None: - value = callable.__basicnew__() - else: - value = apply(callable, arg_tup) - self.append(value) - dispatch[REDUCE] = load_reduce - - def load_pop(self): - del self.stack[-1] - dispatch[POP] = load_pop - - def load_pop_mark(self): - k = self.marker() - del self.stack[k:] - dispatch[POP_MARK] = load_pop_mark - - def load_dup(self): - self.append(self.stack[-1]) - dispatch[DUP] = load_dup - - def load_get(self): - self.append(self.memo[self.readline()[:-1]]) - dispatch[GET] = load_get - - def load_binget(self): - i = mloads('i' + self.read(1) + '\000\000\000') - self.append(self.memo[`i`]) - dispatch[BINGET] = load_binget - - def load_long_binget(self): - i = mloads('i' + self.read(4)) - self.append(self.memo[`i`]) - dispatch[LONG_BINGET] = load_long_binget - - def load_put(self): - self.memo[self.readline()[:-1]] = self.stack[-1] - dispatch[PUT] = load_put - - def load_binput(self): - i = mloads('i' + self.read(1) + '\000\000\000') - self.memo[`i`] = self.stack[-1] - dispatch[BINPUT] = load_binput - - def load_long_binput(self): - i = mloads('i' + self.read(4)) - self.memo[`i`] = self.stack[-1] - dispatch[LONG_BINPUT] = load_long_binput - - def load_append(self): - stack = self.stack - value = stack[-1] - del stack[-1] - list = stack[-1] - list.append(value) - dispatch[APPEND] = load_append - - def load_appends(self): - stack = self.stack - mark = self.marker() - list = stack[mark - 1] - for i in range(mark + 1, len(stack)): - list.append(stack[i]) - - del stack[mark:] - dispatch[APPENDS] = load_appends - - def load_setitem(self): - stack = self.stack - value = stack[-1] - key = stack[-2] - del stack[-2:] - dict = stack[-1] - dict[key] = value - dispatch[SETITEM] = load_setitem - - def load_setitems(self): - stack = self.stack - mark = self.marker() - dict = stack[mark - 1] - for i in range(mark + 1, len(stack), 2): - dict[stack[i]] = stack[i + 1] - - del stack[mark:] - dispatch[SETITEMS] = load_setitems - - def load_build(self): - stack = self.stack - value = stack[-1] - del stack[-1] - inst = stack[-1] - try: - setstate = inst.__setstate__ - except AttributeError: - try: - inst.__dict__.update(value) - except RuntimeError: - # XXX In restricted execution, the instance's __dict__ is not - # accessible. Use the old way of unpickling the instance - # variables. This is a semantic different when unpickling in - # restricted vs. unrestricted modes. - for k, v in value.items(): - setattr(inst, k, v) - else: - setstate(value) - dispatch[BUILD] = load_build - - def load_mark(self): - self.append(self.mark) - dispatch[MARK] = load_mark - - def load_stop(self): - value = self.stack[-1] - del self.stack[-1] - raise _Stop(value) - dispatch[STOP] = load_stop - -# Helper class for load_inst/load_obj - -class _EmptyClass: - pass - -# Shorthands - -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO - -def dump(object, file, bin = 0): - Pickler(file, bin).dump(object) - -def dumps(object, bin = 0): - file = StringIO() - Pickler(file, bin).dump(object) - return file.getvalue() - -def load(file): - return Unpickler(file).load() - -def loads(str): - file = StringIO(str) - return Unpickler(file).load() diff --git a/Scripts/ServerPython/python/system/popen2.py b/Scripts/ServerPython/python/system/popen2.py deleted file mode 100644 index 1d067ce7..00000000 --- a/Scripts/ServerPython/python/system/popen2.py +++ /dev/null @@ -1,199 +0,0 @@ -"""Spawn a command with pipes to its stdin, stdout, and optionally stderr. - -The normal os.popen(cmd, mode) call spawns a shell command and provides a -file interface to just the input or output of the process depending on -whether mode is 'r' or 'w'. This module provides the functions popen2(cmd) -and popen3(cmd) which return two or three pipes to the spawned command. -""" - -import os -import sys -import types - -__all__ = ["popen2", "popen3", "popen4"] - -MAXFD = 256 # Max number of file descriptors (os.getdtablesize()???) - -_active = [] - -def _cleanup(): - for inst in _active[:]: - inst.poll() - -class Popen3: - """Class representing a child process. Normally instances are created - by the factory functions popen2() and popen3().""" - - sts = -1 # Child not completed yet - - def __init__(self, cmd, capturestderr=0, bufsize=-1): - """The parameter 'cmd' is the shell command to execute in a - sub-process. The 'capturestderr' flag, if true, specifies that - the object should capture standard error output of the child process. - The default is false. If the 'bufsize' parameter is specified, it - specifies the size of the I/O buffers to/from the child process.""" - _cleanup() - p2cread, p2cwrite = os.pipe() - c2pread, c2pwrite = os.pipe() - if capturestderr: - errout, errin = os.pipe() - self.pid = os.fork() - if self.pid == 0: - # Child - os.dup2(p2cread, 0) - os.dup2(c2pwrite, 1) - if capturestderr: - os.dup2(errin, 2) - self._run_child(cmd) - os.close(p2cread) - self.tochild = os.fdopen(p2cwrite, 'w', bufsize) - os.close(c2pwrite) - self.fromchild = os.fdopen(c2pread, 'r', bufsize) - if capturestderr: - os.close(errin) - self.childerr = os.fdopen(errout, 'r', bufsize) - else: - self.childerr = None - _active.append(self) - - def _run_child(self, cmd): - if isinstance(cmd, types.StringTypes): - cmd = ['/bin/sh', '-c', cmd] - for i in range(3, MAXFD): - try: - os.close(i) - except: - pass - try: - os.execvp(cmd[0], cmd) - finally: - os._exit(1) - - def poll(self): - """Return the exit status of the child process if it has finished, - or -1 if it hasn't finished yet.""" - if self.sts < 0: - try: - pid, sts = os.waitpid(self.pid, os.WNOHANG) - if pid == self.pid: - self.sts = sts - _active.remove(self) - except os.error: - pass - return self.sts - - def wait(self): - """Wait for and return the exit status of the child process.""" - pid, sts = os.waitpid(self.pid, 0) - if pid == self.pid: - self.sts = sts - _active.remove(self) - return self.sts - - -class Popen4(Popen3): - childerr = None - - def __init__(self, cmd, bufsize=-1): - _cleanup() - p2cread, p2cwrite = os.pipe() - c2pread, c2pwrite = os.pipe() - self.pid = os.fork() - if self.pid == 0: - # Child - os.dup2(p2cread, 0) - os.dup2(c2pwrite, 1) - os.dup2(c2pwrite, 2) - self._run_child(cmd) - os.close(p2cread) - self.tochild = os.fdopen(p2cwrite, 'w', bufsize) - os.close(c2pwrite) - self.fromchild = os.fdopen(c2pread, 'r', bufsize) - _active.append(self) - - -if sys.platform[:3] == "win": - # Some things don't make sense on non-Unix platforms. - del Popen3, Popen4 - - def popen2(cmd, bufsize=-1, mode='t'): - """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is - specified, it sets the buffer size for the I/O pipes. The file objects - (child_stdout, child_stdin) are returned.""" - w, r = os.popen2(cmd, mode, bufsize) - return r, w - - def popen3(cmd, bufsize=-1, mode='t'): - """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is - specified, it sets the buffer size for the I/O pipes. The file objects - (child_stdout, child_stdin, child_stderr) are returned.""" - w, r, e = os.popen3(cmd, mode, bufsize) - return r, w, e - - def popen4(cmd, bufsize=-1, mode='t'): - """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is - specified, it sets the buffer size for the I/O pipes. The file objects - (child_stdout_stderr, child_stdin) are returned.""" - w, r = os.popen4(cmd, mode, bufsize) - return r, w -else: - def popen2(cmd, bufsize=-1, mode='t'): - """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is - specified, it sets the buffer size for the I/O pipes. The file objects - (child_stdout, child_stdin) are returned.""" - inst = Popen3(cmd, 0, bufsize) - return inst.fromchild, inst.tochild - - def popen3(cmd, bufsize=-1, mode='t'): - """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is - specified, it sets the buffer size for the I/O pipes. The file objects - (child_stdout, child_stdin, child_stderr) are returned.""" - inst = Popen3(cmd, 1, bufsize) - return inst.fromchild, inst.tochild, inst.childerr - - def popen4(cmd, bufsize=-1, mode='t'): - """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is - specified, it sets the buffer size for the I/O pipes. The file objects - (child_stdout_stderr, child_stdin) are returned.""" - inst = Popen4(cmd, bufsize) - return inst.fromchild, inst.tochild - - __all__.extend(["Popen3", "Popen4"]) - -def _test(): - cmd = "cat" - teststr = "ab cd\n" - if os.name == "nt": - cmd = "more" - # "more" doesn't act the same way across Windows flavors, - # sometimes adding an extra newline at the start or the - # end. So we strip whitespace off both ends for comparison. - expected = teststr.strip() - print "testing popen2..." - r, w = popen2(cmd) - w.write(teststr) - w.close() - got = r.read() - if got.strip() != expected: - raise ValueError("wrote %s read %s" % (`teststr`, `got`)) - print "testing popen3..." - try: - r, w, e = popen3([cmd]) - except: - r, w, e = popen3(cmd) - w.write(teststr) - w.close() - got = r.read() - if got.strip() != expected: - raise ValueError("wrote %s read %s" % (`teststr`, `got`)) - got = e.read() - if got: - raise ValueError("unexected %s on stderr" % `got`) - for inst in _active[:]: - inst.wait() - if _active: - raise ValueError("_active not empty") - print "All OK" - -if __name__ == '__main__': - _test() diff --git a/Scripts/ServerPython/python/system/posixpath.py b/Scripts/ServerPython/python/system/posixpath.py deleted file mode 100644 index b165aef5..00000000 --- a/Scripts/ServerPython/python/system/posixpath.py +++ /dev/null @@ -1,414 +0,0 @@ -"""Common operations on Posix pathnames. - -Instead of importing this module directly, import os and refer to -this module as os.path. The "os.path" name is an alias for this -module on Posix systems; on other systems (e.g. Mac, Windows), -os.path provides the same operations in a manner specific to that -platform, and is an alias to another module (e.g. macpath, ntpath). - -Some of this can actually be useful on non-Posix systems too, e.g. -for manipulation of the pathname component of URLs. -""" - -import os -import stat - -__all__ = ["normcase","isabs","join","splitdrive","split","splitext", - "basename","dirname","commonprefix","getsize","getmtime", - "getatime","islink","exists","isdir","isfile","ismount", - "walk","expanduser","expandvars","normpath","abspath", - "samefile","sameopenfile","samestat"] - -# Normalize the case of a pathname. Trivial in Posix, string.lower on Mac. -# On MS-DOS this may also turn slashes into backslashes; however, other -# normalizations (such as optimizing '../' away) are not allowed -# (another function should be defined to do that). - -def normcase(s): - """Normalize case of pathname. Has no effect under Posix""" - return s - - -# Return whether a path is absolute. -# Trivial in Posix, harder on the Mac or MS-DOS. - -def isabs(s): - """Test whether a path is absolute""" - return s[:1] == '/' - - -# Join pathnames. -# Ignore the previous parts if a part is absolute. -# Insert a '/' unless the first part is empty or already ends in '/'. - -def join(a, *p): - """Join two or more pathname components, inserting '/' as needed""" - path = a - for b in p: - if b[:1] == '/': - path = b - elif path == '' or path[-1:] == '/': - path = path + b - else: - path = path + '/' + b - return path - - -# Split a path in head (everything up to the last '/') and tail (the -# rest). If the path ends in '/', tail will be empty. If there is no -# '/' in the path, head will be empty. -# Trailing '/'es are stripped from head unless it is the root. - -def split(p): - """Split a pathname. Returns tuple "(head, tail)" where "tail" is - everything after the final slash. Either part may be empty.""" - i = p.rfind('/') + 1 - head, tail = p[:i], p[i:] - if head and head != '/'*len(head): - while head[-1] == '/': - head = head[:-1] - return head, tail - - -# Split a path in root and extension. -# The extension is everything starting at the last dot in the last -# pathname component; the root is everything before that. -# It is always true that root + ext == p. - -def splitext(p): - """Split the extension from a pathname. Extension is everything from the - last dot to the end. Returns "(root, ext)", either part may be empty.""" - root, ext = '', '' - for c in p: - if c == '/': - root, ext = root + ext + c, '' - elif c == '.': - if ext: - root, ext = root + ext, c - else: - ext = c - elif ext: - ext = ext + c - else: - root = root + c - return root, ext - - -# Split a pathname into a drive specification and the rest of the -# path. Useful on DOS/Windows/NT; on Unix, the drive is always empty. - -def splitdrive(p): - """Split a pathname into drive and path. On Posix, drive is always - empty.""" - return '', p - - -# Return the tail (basename) part of a path. - -def basename(p): - """Returns the final component of a pathname""" - return split(p)[1] - - -# Return the head (dirname) part of a path. - -def dirname(p): - """Returns the directory component of a pathname""" - return split(p)[0] - - -# Return the longest prefix of all list elements. - -def commonprefix(m): - "Given a list of pathnames, returns the longest common leading component" - if not m: return '' - prefix = m[0] - for item in m: - for i in range(len(prefix)): - if prefix[:i+1] != item[:i+1]: - prefix = prefix[:i] - if i == 0: return '' - break - return prefix - - -# Get size, mtime, atime of files. - -def getsize(filename): - """Return the size of a file, reported by os.stat().""" - st = os.stat(filename) - return st[stat.ST_SIZE] - -def getmtime(filename): - """Return the last modification time of a file, reported by os.stat().""" - st = os.stat(filename) - return st[stat.ST_MTIME] - -def getatime(filename): - """Return the last access time of a file, reported by os.stat().""" - st = os.stat(filename) - return st[stat.ST_ATIME] - - -# Is a path a symbolic link? -# This will always return false on systems where os.lstat doesn't exist. - -def islink(path): - """Test whether a path is a symbolic link""" - try: - st = os.lstat(path) - except (os.error, AttributeError): - return 0 - return stat.S_ISLNK(st[stat.ST_MODE]) - - -# Does a path exist? -# This is false for dangling symbolic links. - -def exists(path): - """Test whether a path exists. Returns false for broken symbolic links""" - try: - st = os.stat(path) - except os.error: - return 0 - return 1 - - -# Is a path a directory? -# This follows symbolic links, so both islink() and isdir() can be true -# for the same path. - -def isdir(path): - """Test whether a path is a directory""" - try: - st = os.stat(path) - except os.error: - return 0 - return stat.S_ISDIR(st[stat.ST_MODE]) - - -# Is a path a regular file? -# This follows symbolic links, so both islink() and isfile() can be true -# for the same path. - -def isfile(path): - """Test whether a path is a regular file""" - try: - st = os.stat(path) - except os.error: - return 0 - return stat.S_ISREG(st[stat.ST_MODE]) - - -# Are two filenames really pointing to the same file? - -def samefile(f1, f2): - """Test whether two pathnames reference the same actual file""" - s1 = os.stat(f1) - s2 = os.stat(f2) - return samestat(s1, s2) - - -# Are two open files really referencing the same file? -# (Not necessarily the same file descriptor!) - -def sameopenfile(fp1, fp2): - """Test whether two open file objects reference the same file""" - s1 = os.fstat(fp1) - s2 = os.fstat(fp2) - return samestat(s1, s2) - - -# Are two stat buffers (obtained from stat, fstat or lstat) -# describing the same file? - -def samestat(s1, s2): - """Test whether two stat buffers reference the same file""" - return s1[stat.ST_INO] == s2[stat.ST_INO] and \ - s1[stat.ST_DEV] == s2[stat.ST_DEV] - - -# Is a path a mount point? -# (Does this work for all UNIXes? Is it even guaranteed to work by Posix?) - -def ismount(path): - """Test whether a path is a mount point""" - try: - s1 = os.stat(path) - s2 = os.stat(join(path, '..')) - except os.error: - return 0 # It doesn't exist -- so not a mount point :-) - dev1 = s1[stat.ST_DEV] - dev2 = s2[stat.ST_DEV] - if dev1 != dev2: - return 1 # path/.. on a different device as path - ino1 = s1[stat.ST_INO] - ino2 = s2[stat.ST_INO] - if ino1 == ino2: - return 1 # path/.. is the same i-node as path - return 0 - - -# Directory tree walk. -# For each directory under top (including top itself, but excluding -# '.' and '..'), func(arg, dirname, filenames) is called, where -# dirname is the name of the directory and filenames is the list -# of files (and subdirectories etc.) in the directory. -# The func may modify the filenames list, to implement a filter, -# or to impose a different order of visiting. - -def walk(top, func, arg): - """Directory tree walk with callback function. - - For each directory in the directory tree rooted at top (including top - itself, but excluding '.' and '..'), call func(arg, dirname, fnames). - dirname is the name of the directory, and fnames a list of the names of - the files and subdirectories in dirname (excluding '.' and '..'). func - may modify the fnames list in-place (e.g. via del or slice assignment), - and walk will only recurse into the subdirectories whose names remain in - fnames; this can be used to implement a filter, or to impose a specific - order of visiting. No semantics are defined for, or required of, arg, - beyond that arg is always passed to func. It can be used, e.g., to pass - a filename pattern, or a mutable object designed to accumulate - statistics. Passing None for arg is common.""" - - try: - names = os.listdir(top) - except os.error: - return - func(arg, top, names) - for name in names: - name = join(top, name) - try: - st = os.lstat(name) - except os.error: - continue - if stat.S_ISDIR(st[stat.ST_MODE]): - walk(name, func, arg) - - -# Expand paths beginning with '~' or '~user'. -# '~' means $HOME; '~user' means that user's home directory. -# If the path doesn't begin with '~', or if the user or $HOME is unknown, -# the path is returned unchanged (leaving error reporting to whatever -# function is called with the expanded path as argument). -# See also module 'glob' for expansion of *, ? and [...] in pathnames. -# (A function should also be defined to do full *sh-style environment -# variable expansion.) - -def expanduser(path): - """Expand ~ and ~user constructions. If user or $HOME is unknown, - do nothing.""" - if path[:1] != '~': - return path - i, n = 1, len(path) - while i < n and path[i] != '/': - i = i + 1 - if i == 1: - if not os.environ.has_key('HOME'): - import pwd - userhome = pwd.getpwuid(os.getuid())[5] - else: - userhome = os.environ['HOME'] - else: - import pwd - try: - pwent = pwd.getpwnam(path[1:i]) - except KeyError: - return path - userhome = pwent[5] - if userhome[-1:] == '/': i = i + 1 - return userhome + path[i:] - - -# Expand paths containing shell variable substitutions. -# This expands the forms $variable and ${variable} only. -# Non-existent variables are left unchanged. - -_varprog = None - -def expandvars(path): - """Expand shell variables of form $var and ${var}. Unknown variables - are left unchanged.""" - global _varprog - if '$' not in path: - return path - if not _varprog: - import re - _varprog = re.compile(r'\$(\w+|\{[^}]*\})') - i = 0 - while 1: - m = _varprog.search(path, i) - if not m: - break - i, j = m.span(0) - name = m.group(1) - if name[:1] == '{' and name[-1:] == '}': - name = name[1:-1] - if os.environ.has_key(name): - tail = path[j:] - path = path[:i] + os.environ[name] - i = len(path) - path = path + tail - else: - i = j - return path - - -# Normalize a path, e.g. A//B, A/./B and A/foo/../B all become A/B. -# It should be understood that this may change the meaning of the path -# if it contains symbolic links! - -def normpath(path): - """Normalize path, eliminating double slashes, etc.""" - if path == '': - return '.' - initial_slashes = path.startswith('/') - # POSIX allows one or two initial slashes, but treats three or more - # as single slash. - if (initial_slashes and - path.startswith('//') and not path.startswith('///')): - initial_slashes = 2 - comps = path.split('/') - new_comps = [] - for comp in comps: - if comp in ('', '.'): - continue - if (comp != '..' or (not initial_slashes and not new_comps) or - (new_comps and new_comps[-1] == '..')): - new_comps.append(comp) - elif new_comps: - new_comps.pop() - comps = new_comps - path = '/'.join(comps) - if initial_slashes: - path = '/'*initial_slashes + path - return path or '.' - - -def abspath(path): - """Return an absolute path.""" - if not isabs(path): - path = join(os.getcwd(), path) - return normpath(path) - - -# Return a canonical path (i.e. the absolute location of a file on the -# filesystem). - -def realpath(filename): - """Return the canonical path of the specified filename, eliminating any -symbolic links encountered in the path.""" - filename = abspath(filename) - - bits = ['/'] + filename.split('/')[1:] - for i in range(2, len(bits)+1): - component = join(*bits[0:i]) - if islink(component): - resolved = os.readlink(component) - (dir, file) = split(component) - resolved = normpath(join(dir, resolved)) - newpath = join(*([resolved] + bits[i:])) - return realpath(newpath) - - return filename diff --git a/Scripts/ServerPython/python/system/pre.py b/Scripts/ServerPython/python/system/pre.py deleted file mode 100644 index a4c38e4c..00000000 --- a/Scripts/ServerPython/python/system/pre.py +++ /dev/null @@ -1,656 +0,0 @@ -# module 're' -- A collection of regular expression operations - -r"""Support for regular expressions (RE). - -This module provides regular expression matching operations similar to -those found in Perl. It's 8-bit clean: the strings being processed may -contain both null bytes and characters whose high bit is set. Regular -expression pattern strings may not contain null bytes, but can specify -the null byte using the \\number notation. Characters with the high -bit set may be included. - -Regular expressions can contain both special and ordinary -characters. Most ordinary characters, like "A", "a", or "0", are the -simplest regular expressions; they simply match themselves. You can -concatenate ordinary characters, so last matches the string 'last'. - -The special characters are: - "." Matches any character except a newline. - "^" Matches the start of the string. - "$" Matches the end of the string. - "*" Matches 0 or more (greedy) repetitions of the preceding RE. - Greedy means that it will match as many repetitions as possible. - "+" Matches 1 or more (greedy) repetitions of the preceding RE. - "?" Matches 0 or 1 (greedy) of the preceding RE. - *?,+?,?? Non-greedy versions of the previous three special characters. - {m,n} Matches from m to n repetitions of the preceding RE. - {m,n}? Non-greedy version of the above. - "\\" Either escapes special characters or signals a special sequence. - [] Indicates a set of characters. - A "^" as the first character indicates a complementing set. - "|" A|B, creates an RE that will match either A or B. - (...) Matches the RE inside the parentheses. - The contents can be retrieved or matched later in the string. - (?iLmsx) Set the I, L, M, S, or X flag for the RE. - (?:...) Non-grouping version of regular parentheses. - (?P...) The substring matched by the group is accessible by name. - (?P=name) Matches the text matched earlier by the group named name. - (?#...) A comment; ignored. - (?=...) Matches if ... matches next, but doesn't consume the string. - (?!...) Matches if ... doesn't match next. - -The special sequences consist of "\\" and a character from the list -below. If the ordinary character is not on the list, then the -resulting RE will match the second character. - \\number Matches the contents of the group of the same number. - \\A Matches only at the start of the string. - \\Z Matches only at the end of the string. - \\b Matches the empty string, but only at the start or end of a word. - \\B Matches the empty string, but not at the start or end of a word. - \\d Matches any decimal digit; equivalent to the set [0-9]. - \\D Matches any non-digit character; equivalent to the set [^0-9]. - \\s Matches any whitespace character; equivalent to [ \\t\\n\\r\\f\\v]. - \\S Matches any non-whitespace character; equiv. to [^ \\t\\n\\r\\f\\v]. - \\w Matches any alphanumeric character; equivalent to [a-zA-Z0-9_]. - With LOCALE, it will match the set [0-9_] plus characters defined - as letters for the current locale. - \\W Matches the complement of \\w. - \\\\ Matches a literal backslash. - -This module exports the following functions: - match Match a regular expression pattern to the beginning of a string. - search Search a string for the presence of a pattern. - sub Substitute occurrences of a pattern found in a string. - subn Same as sub, but also return the number of substitutions made. - split Split a string by the occurrences of a pattern. - findall Find all occurrences of a pattern in a string. - compile Compile a pattern into a RegexObject. - escape Backslash all non-alphanumerics in a string. - -This module exports the following classes: - RegexObject Holds a compiled regular expression pattern. - MatchObject Contains information about pattern matches. - -Some of the functions in this module takes flags as optional parameters: - I IGNORECASE Perform case-insensitive matching. - L LOCALE Make \w, \W, \b, \B, dependent on the current locale. - M MULTILINE "^" matches the beginning of lines as well as the string. - "$" matches the end of lines as well as the string. - S DOTALL "." matches any character at all, including the newline. - X VERBOSE Ignore whitespace and comments for nicer looking RE's. - -This module also defines an exception 'error'. - -""" - - -import sys -from pcre import * - -__all__ = ["match","search","sub","subn","split","findall","escape","compile", - "I","L","M","S","X","IGNORECASE","LOCALE","MULTILINE","DOTALL", - "VERBOSE","error"] - -# -# First, the public part of the interface: -# - -# pcre.error and re.error should be the same, since exceptions can be -# raised from either module. - -# compilation flags - -I = IGNORECASE -L = LOCALE -M = MULTILINE -S = DOTALL -X = VERBOSE - - -# -# -# - -_cache = {} -_MAXCACHE = 20 - -def _cachecompile(pattern, flags=0): - key = (pattern, flags) - try: - return _cache[key] - except KeyError: - pass - value = compile(pattern, flags) - if len(_cache) >= _MAXCACHE: - _cache.clear() - _cache[key] = value - return value - -def match(pattern, string, flags=0): - """match (pattern, string[, flags]) -> MatchObject or None - - If zero or more characters at the beginning of string match the - regular expression pattern, return a corresponding MatchObject - instance. Return None if the string does not match the pattern; - note that this is different from a zero-length match. - - Note: If you want to locate a match anywhere in string, use - search() instead. - - """ - - return _cachecompile(pattern, flags).match(string) - -def search(pattern, string, flags=0): - """search (pattern, string[, flags]) -> MatchObject or None - - Scan through string looking for a location where the regular - expression pattern produces a match, and return a corresponding - MatchObject instance. Return None if no position in the string - matches the pattern; note that this is different from finding a - zero-length match at some point in the string. - - """ - return _cachecompile(pattern, flags).search(string) - -def sub(pattern, repl, string, count=0): - """sub(pattern, repl, string[, count=0]) -> string - - Return the string obtained by replacing the leftmost - non-overlapping occurrences of pattern in string by the - replacement repl. If the pattern isn't found, string is returned - unchanged. repl can be a string or a function; if a function, it - is called for every non-overlapping occurrence of pattern. The - function takes a single match object argument, and returns the - replacement string. - - The pattern may be a string or a regex object; if you need to - specify regular expression flags, you must use a regex object, or - use embedded modifiers in a pattern; e.g. - sub("(?i)b+", "x", "bbbb BBBB") returns 'x x'. - - The optional argument count is the maximum number of pattern - occurrences to be replaced; count must be a non-negative integer, - and the default value of 0 means to replace all occurrences. - - """ - if type(pattern) == type(''): - pattern = _cachecompile(pattern) - return pattern.sub(repl, string, count) - -def subn(pattern, repl, string, count=0): - """subn(pattern, repl, string[, count=0]) -> (string, num substitutions) - - Perform the same operation as sub(), but return a tuple - (new_string, number_of_subs_made). - - """ - if type(pattern) == type(''): - pattern = _cachecompile(pattern) - return pattern.subn(repl, string, count) - -def split(pattern, string, maxsplit=0): - """split(pattern, string[, maxsplit=0]) -> list of strings - - Split string by the occurrences of pattern. If capturing - parentheses are used in pattern, then the text of all groups in - the pattern are also returned as part of the resulting list. If - maxsplit is nonzero, at most maxsplit splits occur, and the - remainder of the string is returned as the final element of the - list. - - """ - if type(pattern) == type(''): - pattern = _cachecompile(pattern) - return pattern.split(string, maxsplit) - -def findall(pattern, string): - """findall(pattern, string) -> list - - Return a list of all non-overlapping matches of pattern in - string. If one or more groups are present in the pattern, return a - list of groups; this will be a list of tuples if the pattern has - more than one group. Empty matches are included in the result. - - """ - if type(pattern) == type(''): - pattern = _cachecompile(pattern) - return pattern.findall(string) - -def escape(pattern): - """escape(string) -> string - - Return string with all non-alphanumerics backslashed; this is - useful if you want to match an arbitrary literal string that may - have regular expression metacharacters in it. - - """ - result = list(pattern) - for i in range(len(pattern)): - char = pattern[i] - if not char.isalnum(): - if char=='\000': result[i] = '\\000' - else: result[i] = '\\'+char - return ''.join(result) - -def compile(pattern, flags=0): - """compile(pattern[, flags]) -> RegexObject - - Compile a regular expression pattern into a regular expression - object, which can be used for matching using its match() and - search() methods. - - """ - groupindex={} - code=pcre_compile(pattern, flags, groupindex) - return RegexObject(pattern, flags, code, groupindex) - - -# -# Class definitions -# - -class RegexObject: - """Holds a compiled regular expression pattern. - - Methods: - match Match the pattern to the beginning of a string. - search Search a string for the presence of the pattern. - sub Substitute occurrences of the pattern found in a string. - subn Same as sub, but also return the number of substitutions made. - split Split a string by the occurrences of the pattern. - findall Find all occurrences of the pattern in a string. - - """ - - def __init__(self, pattern, flags, code, groupindex): - self.code = code - self.flags = flags - self.pattern = pattern - self.groupindex = groupindex - - def search(self, string, pos=0, endpos=None): - """search(string[, pos][, endpos]) -> MatchObject or None - - Scan through string looking for a location where this regular - expression produces a match, and return a corresponding - MatchObject instance. Return None if no position in the string - matches the pattern; note that this is different from finding - a zero-length match at some point in the string. The optional - pos and endpos parameters have the same meaning as for the - match() method. - - """ - if endpos is None or endpos>len(string): - endpos=len(string) - if endpos MatchObject or None - - If zero or more characters at the beginning of string match - this regular expression, return a corresponding MatchObject - instance. Return None if the string does not match the - pattern; note that this is different from a zero-length match. - - Note: If you want to locate a match anywhere in string, use - search() instead. - - The optional second parameter pos gives an index in the string - where the search is to start; it defaults to 0. This is not - completely equivalent to slicing the string; the '' pattern - character matches at the real beginning of the string and at - positions just after a newline, but not necessarily at the - index where the search is to start. - - The optional parameter endpos limits how far the string will - be searched; it will be as if the string is endpos characters - long, so only the characters from pos to endpos will be - searched for a match. - - """ - if endpos is None or endpos>len(string): - endpos=len(string) - if endpos string - - Return the string obtained by replacing the leftmost - non-overlapping occurrences of the compiled pattern in string - by the replacement repl. If the pattern isn't found, string is - returned unchanged. - - Identical to the sub() function, using the compiled pattern. - - """ - return self.subn(repl, string, count)[0] - - def subn(self, repl, source, count=0): - """subn(repl, string[, count=0]) -> tuple - - Perform the same operation as sub(), but return a tuple - (new_string, number_of_subs_made). - - """ - if count < 0: - raise error, "negative substitution count" - if count == 0: - count = sys.maxint - n = 0 # Number of matches - pos = 0 # Where to start searching - lastmatch = -1 # End of last match - results = [] # Substrings making up the result - end = len(source) - - if type(repl) is type(''): - # See if repl contains group references (if it does, - # pcre_expand will attempt to call _Dummy.group, which - # results in a TypeError) - try: - repl = pcre_expand(_Dummy, repl) - except (error, TypeError): - m = MatchObject(self, source, 0, end, []) - repl = lambda m, repl=repl, expand=pcre_expand: expand(m, repl) - else: - m = None - else: - m = MatchObject(self, source, 0, end, []) - - match = self.code.match - append = results.append - while n < count and pos <= end: - regs = match(source, pos, end, 0) - if not regs: - break - self._num_regs = len(regs) - i, j = regs[0] - if i == j == lastmatch: - # Empty match adjacent to previous match - pos = pos + 1 - append(source[lastmatch:pos]) - continue - if pos < i: - append(source[pos:i]) - if m: - m.pos = pos - m.regs = regs - append(repl(m)) - else: - append(repl) - pos = lastmatch = j - if i == j: - # Last match was empty; don't try here again - pos = pos + 1 - append(source[lastmatch:pos]) - n = n + 1 - append(source[pos:]) - return (''.join(results), n) - - def split(self, source, maxsplit=0): - """split(source[, maxsplit=0]) -> list of strings - - Split string by the occurrences of the compiled pattern. If - capturing parentheses are used in the pattern, then the text - of all groups in the pattern are also returned as part of the - resulting list. If maxsplit is nonzero, at most maxsplit - splits occur, and the remainder of the string is returned as - the final element of the list. - - """ - if maxsplit < 0: - raise error, "negative split count" - if maxsplit == 0: - maxsplit = sys.maxint - n = 0 - pos = 0 - lastmatch = 0 - results = [] - end = len(source) - match = self.code.match - append = results.append - while n < maxsplit: - regs = match(source, pos, end, 0) - if not regs: - break - i, j = regs[0] - if i == j: - # Empty match - if pos >= end: - break - pos = pos+1 - continue - append(source[lastmatch:i]) - rest = regs[1:] - if rest: - for a, b in rest: - if a == -1 or b == -1: - group = None - else: - group = source[a:b] - append(group) - pos = lastmatch = j - n = n + 1 - append(source[lastmatch:]) - return results - - def findall(self, source): - """findall(source) -> list - - Return a list of all non-overlapping matches of the compiled - pattern in string. If one or more groups are present in the - pattern, return a list of groups; this will be a list of - tuples if the pattern has more than one group. Empty matches - are included in the result. - - """ - pos = 0 - end = len(source) - results = [] - match = self.code.match - append = results.append - while pos <= end: - regs = match(source, pos, end, 0) - if not regs: - break - i, j = regs[0] - rest = regs[1:] - if not rest: - gr = source[i:j] - elif len(rest) == 1: - a, b = rest[0] - gr = source[a:b] - else: - gr = [] - for (a, b) in rest: - gr.append(source[a:b]) - gr = tuple(gr) - append(gr) - pos = max(j, pos+1) - return results - - # The following 3 functions were contributed by Mike Fletcher, and - # allow pickling and unpickling of RegexObject instances. - def __getinitargs__(self): - return (None,None,None,None) # any 4 elements, to work around - # problems with the - # pickle/cPickle modules not yet - # ignoring the __init__ function - def __getstate__(self): - return self.pattern, self.flags, self.groupindex - def __setstate__(self, statetuple): - self.pattern = statetuple[0] - self.flags = statetuple[1] - self.groupindex = statetuple[2] - self.code = apply(pcre_compile, statetuple) - -class _Dummy: - # Dummy class used by _subn_string(). Has 'group' to avoid core dump. - group = None - -class MatchObject: - """Holds a compiled regular expression pattern. - - Methods: - start Return the index of the start of a matched substring. - end Return the index of the end of a matched substring. - span Return a tuple of (start, end) of a matched substring. - groups Return a tuple of all the subgroups of the match. - group Return one or more subgroups of the match. - groupdict Return a dictionary of all the named subgroups of the match. - - """ - - def __init__(self, re, string, pos, endpos, regs): - self.re = re - self.string = string - self.pos = pos - self.endpos = endpos - self.regs = regs - - def start(self, g = 0): - """start([group=0]) -> int or None - - Return the index of the start of the substring matched by - group; group defaults to zero (meaning the whole matched - substring). Return -1 if group exists but did not contribute - to the match. - - """ - if type(g) == type(''): - try: - g = self.re.groupindex[g] - except (KeyError, TypeError): - raise IndexError, 'group %s is undefined' % `g` - return self.regs[g][0] - - def end(self, g = 0): - """end([group=0]) -> int or None - - Return the indices of the end of the substring matched by - group; group defaults to zero (meaning the whole matched - substring). Return -1 if group exists but did not contribute - to the match. - - """ - if type(g) == type(''): - try: - g = self.re.groupindex[g] - except (KeyError, TypeError): - raise IndexError, 'group %s is undefined' % `g` - return self.regs[g][1] - - def span(self, g = 0): - """span([group=0]) -> tuple - - Return the 2-tuple (m.start(group), m.end(group)). Note that - if group did not contribute to the match, this is (-1, - -1). Group defaults to zero (meaning the whole matched - substring). - - """ - if type(g) == type(''): - try: - g = self.re.groupindex[g] - except (KeyError, TypeError): - raise IndexError, 'group %s is undefined' % `g` - return self.regs[g] - - def groups(self, default=None): - """groups([default=None]) -> tuple - - Return a tuple containing all the subgroups of the match, from - 1 up to however many groups are in the pattern. The default - argument is used for groups that did not participate in the - match. - - """ - result = [] - for g in range(1, self.re._num_regs): - a, b = self.regs[g] - if a == -1 or b == -1: - result.append(default) - else: - result.append(self.string[a:b]) - return tuple(result) - - def group(self, *groups): - """group([group1, group2, ...]) -> string or tuple - - Return one or more subgroups of the match. If there is a - single argument, the result is a single string; if there are - multiple arguments, the result is a tuple with one item per - argument. Without arguments, group1 defaults to zero (i.e. the - whole match is returned). If a groupN argument is zero, the - corresponding return value is the entire matching string; if - it is in the inclusive range [1..99], it is the string - matching the the corresponding parenthesized group. If a group - number is negative or larger than the number of groups defined - in the pattern, an IndexError exception is raised. If a group - is contained in a part of the pattern that did not match, the - corresponding result is None. If a group is contained in a - part of the pattern that matched multiple times, the last - match is returned. - - If the regular expression uses the (?P...) syntax, the - groupN arguments may also be strings identifying groups by - their group name. If a string argument is not used as a group - name in the pattern, an IndexError exception is raised. - - """ - if len(groups) == 0: - groups = (0,) - result = [] - for g in groups: - if type(g) == type(''): - try: - g = self.re.groupindex[g] - except (KeyError, TypeError): - raise IndexError, 'group %s is undefined' % `g` - if g >= len(self.regs): - raise IndexError, 'group %s is undefined' % `g` - a, b = self.regs[g] - if a == -1 or b == -1: - result.append(None) - else: - result.append(self.string[a:b]) - if len(result) > 1: - return tuple(result) - elif len(result) == 1: - return result[0] - else: - return () - - def groupdict(self, default=None): - """groupdict([default=None]) -> dictionary - - Return a dictionary containing all the named subgroups of the - match, keyed by the subgroup name. The default argument is - used for groups that did not participate in the match. - - """ - dict = {} - for name, index in self.re.groupindex.items(): - a, b = self.regs[index] - if a == -1 or b == -1: - dict[name] = default - else: - dict[name] = self.string[a:b] - return dict diff --git a/Scripts/ServerPython/python/system/profile.py b/Scripts/ServerPython/python/system/profile.py deleted file mode 100644 index 2d999efc..00000000 --- a/Scripts/ServerPython/python/system/profile.py +++ /dev/null @@ -1,556 +0,0 @@ -#! /usr/bin/env python -# -# Class for profiling python code. rev 1.0 6/2/94 -# -# Based on prior profile module by Sjoerd Mullender... -# which was hacked somewhat by: Guido van Rossum -# -# See profile.doc for more information - -"""Class for profiling Python code.""" - -# Copyright 1994, by InfoSeek Corporation, all rights reserved. -# Written by James Roskind -# -# Permission to use, copy, modify, and distribute this Python software -# and its associated documentation for any purpose (subject to the -# restriction in the following sentence) without fee is hereby granted, -# provided that the above copyright notice appears in all copies, and -# that both that copyright notice and this permission notice appear in -# supporting documentation, and that the name of InfoSeek not be used in -# advertising or publicity pertaining to distribution of the software -# without specific, written prior permission. This permission is -# explicitly restricted to the copying and modification of the software -# to remain in Python, compiled Python, or other languages (such as C) -# wherein the modified or derived code is exclusively imported into a -# Python module. -# -# INFOSEEK CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS. IN NO EVENT SHALL INFOSEEK CORPORATION BE LIABLE FOR ANY -# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER -# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF -# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - - -import sys -import os -import time -import marshal - -__all__ = ["run","help","Profile"] - -# Sample timer for use with -#i_count = 0 -#def integer_timer(): -# global i_count -# i_count = i_count + 1 -# return i_count -#itimes = integer_timer # replace with C coded timer returning integers - -#************************************************************************** -# The following are the static member functions for the profiler class -# Note that an instance of Profile() is *not* needed to call them. -#************************************************************************** - -def run(statement, filename=None): - """Run statement under profiler optionally saving results in filename - - This function takes a single argument that can be passed to the - "exec" statement, and an optional file name. In all cases this - routine attempts to "exec" its first argument and gather profiling - statistics from the execution. If no file name is present, then this - function automatically prints a simple profiling report, sorted by the - standard name string (file/line/function-name) that is presented in - each line. - """ - prof = Profile() - try: - prof = prof.run(statement) - except SystemExit: - pass - if filename is not None: - prof.dump_stats(filename) - else: - return prof.print_stats() - -# print help -def help(): - for dirname in sys.path: - fullname = os.path.join(dirname, 'profile.doc') - if os.path.exists(fullname): - sts = os.system('${PAGER-more} ' + fullname) - if sts: print '*** Pager exit status:', sts - break - else: - print 'Sorry, can\'t find the help file "profile.doc"', - print 'along the Python search path.' - - -if os.name == "mac": - import MacOS - def _get_time_mac(timer=MacOS.GetTicks): - return timer() / 60.0 - -if hasattr(os, "times"): - def _get_time_times(timer=os.times): - t = timer() - return t[0] + t[1] - - -class Profile: - """Profiler class. - - self.cur is always a tuple. Each such tuple corresponds to a stack - frame that is currently active (self.cur[-2]). The following are the - definitions of its members. We use this external "parallel stack" to - avoid contaminating the program that we are profiling. (old profiler - used to write into the frames local dictionary!!) Derived classes - can change the definition of some entries, as long as they leave - [-2:] intact (frame and previous tuple). In case an internal error is - detected, the -3 element is used as the function name. - - [ 0] = Time that needs to be charged to the parent frame's function. - It is used so that a function call will not have to access the - timing data for the parent frame. - [ 1] = Total time spent in this frame's function, excluding time in - subfunctions (this latter is tallied in cur[2]). - [ 2] = Total time spent in subfunctions, excluding time executing the - frame's function (this latter is tallied in cur[1]). - [-3] = Name of the function that corresponds to this frame. - [-2] = Actual frame that we correspond to (used to sync exception handling). - [-1] = Our parent 6-tuple (corresponds to frame.f_back). - - Timing data for each function is stored as a 5-tuple in the dictionary - self.timings[]. The index is always the name stored in self.cur[-3]. - The following are the definitions of the members: - - [0] = The number of times this function was called, not counting direct - or indirect recursion, - [1] = Number of times this function appears on the stack, minus one - [2] = Total time spent internal to this function - [3] = Cumulative time that this function was present on the stack. In - non-recursive functions, this is the total execution time from start - to finish of each invocation of a function, including time spent in - all subfunctions. - [4] = A dictionary indicating for each function name, the number of times - it was called by us. - """ - - bias = 0 # calibration constant - - def __init__(self, timer=None, bias=None): - self.timings = {} - self.cur = None - self.cmd = "" - - if bias is None: - bias = self.bias - self.bias = bias # Materialize in local dict for lookup speed. - - if not timer: - if os.name == 'mac': - self.timer = MacOS.GetTicks - self.dispatcher = self.trace_dispatch_mac - self.get_time = _get_time_mac - elif hasattr(time, 'clock'): - self.timer = self.get_time = time.clock - self.dispatcher = self.trace_dispatch_i - elif hasattr(os, 'times'): - self.timer = os.times - self.dispatcher = self.trace_dispatch - self.get_time = _get_time_times - else: - self.timer = self.get_time = time.time - self.dispatcher = self.trace_dispatch_i - else: - self.timer = timer - t = self.timer() # test out timer function - try: - length = len(t) - except TypeError: - self.get_time = timer - self.dispatcher = self.trace_dispatch_i - else: - if length == 2: - self.dispatcher = self.trace_dispatch - else: - self.dispatcher = self.trace_dispatch_l - # This get_time() implementation needs to be defined - # here to capture the passed-in timer in the parameter - # list (for performance). Note that we can't assume - # the timer() result contains two values in all - # cases. - import operator - def get_time_timer(timer=timer, - reduce=reduce, reducer=operator.add): - return reduce(reducer, timer(), 0) - self.get_time = get_time_timer - self.t = self.get_time() - self.simulate_call('profiler') - - # Heavily optimized dispatch routine for os.times() timer - - def trace_dispatch(self, frame, event, arg): - timer = self.timer - t = timer() - t = t[0] + t[1] - self.t - self.bias - - if self.dispatch[event](self, frame,t): - t = timer() - self.t = t[0] + t[1] - else: - r = timer() - self.t = r[0] + r[1] - t # put back unrecorded delta - - # Dispatch routine for best timer program (return = scalar, fastest if - # an integer but float works too -- and time.clock() relies on that). - - def trace_dispatch_i(self, frame, event, arg): - timer = self.timer - t = timer() - self.t - self.bias - if self.dispatch[event](self, frame,t): - self.t = timer() - else: - self.t = timer() - t # put back unrecorded delta - - # Dispatch routine for macintosh (timer returns time in ticks of - # 1/60th second) - - def trace_dispatch_mac(self, frame, event, arg): - timer = self.timer - t = timer()/60.0 - self.t - self.bias - if self.dispatch[event](self, frame, t): - self.t = timer()/60.0 - else: - self.t = timer()/60.0 - t # put back unrecorded delta - - # SLOW generic dispatch routine for timer returning lists of numbers - - def trace_dispatch_l(self, frame, event, arg): - get_time = self.get_time - t = get_time() - self.t - self.bias - - if self.dispatch[event](self, frame, t): - self.t = get_time() - else: - self.t = get_time() - t # put back unrecorded delta - - # In the event handlers, the first 3 elements of self.cur are unpacked - # into vrbls w/ 3-letter names. The last two characters are meant to be - # mnemonic: - # _pt self.cur[0] "parent time" time to be charged to parent frame - # _it self.cur[1] "internal time" time spent directly in the function - # _et self.cur[2] "external time" time spent in subfunctions - - def trace_dispatch_exception(self, frame, t): - rpt, rit, ret, rfn, rframe, rcur = self.cur - if (rframe is not frame) and rcur: - return self.trace_dispatch_return(rframe, t) - self.cur = rpt, rit+t, ret, rfn, rframe, rcur - return 1 - - - def trace_dispatch_call(self, frame, t): - if self.cur and frame.f_back is not self.cur[-2]: - rpt, rit, ret, rfn, rframe, rcur = self.cur - if not isinstance(rframe, Profile.fake_frame): - assert rframe.f_back is frame.f_back, ("Bad call", rfn, - rframe, rframe.f_back, - frame, frame.f_back) - self.trace_dispatch_return(rframe, 0) - assert (self.cur is None or \ - frame.f_back is self.cur[-2]), ("Bad call", - self.cur[-3]) - fcode = frame.f_code - fn = (fcode.co_filename, fcode.co_firstlineno, fcode.co_name) - self.cur = (t, 0, 0, fn, frame, self.cur) - timings = self.timings - if timings.has_key(fn): - cc, ns, tt, ct, callers = timings[fn] - timings[fn] = cc, ns + 1, tt, ct, callers - else: - timings[fn] = 0, 0, 0, 0, {} - return 1 - - def trace_dispatch_return(self, frame, t): - if frame is not self.cur[-2]: - assert frame is self.cur[-2].f_back, ("Bad return", self.cur[-3]) - self.trace_dispatch_return(self.cur[-2], 0) - - # Prefix "r" means part of the Returning or exiting frame. - # Prefix "p" means part of the Previous or Parent or older frame. - - rpt, rit, ret, rfn, frame, rcur = self.cur - rit = rit + t - frame_total = rit + ret - - ppt, pit, pet, pfn, pframe, pcur = rcur - self.cur = ppt, pit + rpt, pet + frame_total, pfn, pframe, pcur - - timings = self.timings - cc, ns, tt, ct, callers = timings[rfn] - if not ns: - # This is the only occurrence of the function on the stack. - # Else this is a (directly or indirectly) recursive call, and - # its cumulative time will get updated when the topmost call to - # it returns. - ct = ct + frame_total - cc = cc + 1 - - if callers.has_key(pfn): - callers[pfn] = callers[pfn] + 1 # hack: gather more - # stats such as the amount of time added to ct courtesy - # of this specific call, and the contribution to cc - # courtesy of this call. - else: - callers[pfn] = 1 - - timings[rfn] = cc, ns - 1, tt + rit, ct, callers - - return 1 - - - dispatch = { - "call": trace_dispatch_call, - "exception": trace_dispatch_exception, - "return": trace_dispatch_return, - } - - - # The next few functions play with self.cmd. By carefully preloading - # our parallel stack, we can force the profiled result to include - # an arbitrary string as the name of the calling function. - # We use self.cmd as that string, and the resulting stats look - # very nice :-). - - def set_cmd(self, cmd): - if self.cur[-1]: return # already set - self.cmd = cmd - self.simulate_call(cmd) - - class fake_code: - def __init__(self, filename, line, name): - self.co_filename = filename - self.co_line = line - self.co_name = name - self.co_firstlineno = 0 - - def __repr__(self): - return repr((self.co_filename, self.co_line, self.co_name)) - - class fake_frame: - def __init__(self, code, prior): - self.f_code = code - self.f_back = prior - - def simulate_call(self, name): - code = self.fake_code('profile', 0, name) - if self.cur: - pframe = self.cur[-2] - else: - pframe = None - frame = self.fake_frame(code, pframe) - self.dispatch['call'](self, frame, 0) - - # collect stats from pending stack, including getting final - # timings for self.cmd frame. - - def simulate_cmd_complete(self): - get_time = self.get_time - t = get_time() - self.t - while self.cur[-1]: - # We *can* cause assertion errors here if - # dispatch_trace_return checks for a frame match! - self.dispatch['return'](self, self.cur[-2], t) - t = 0 - self.t = get_time() - t - - - def print_stats(self): - import pstats - pstats.Stats(self).strip_dirs().sort_stats(-1). \ - print_stats() - - def dump_stats(self, file): - f = open(file, 'wb') - self.create_stats() - marshal.dump(self.stats, f) - f.close() - - def create_stats(self): - self.simulate_cmd_complete() - self.snapshot_stats() - - def snapshot_stats(self): - self.stats = {} - for func in self.timings.keys(): - cc, ns, tt, ct, callers = self.timings[func] - callers = callers.copy() - nc = 0 - for func_caller in callers.keys(): - nc = nc + callers[func_caller] - self.stats[func] = cc, nc, tt, ct, callers - - - # The following two methods can be called by clients to use - # a profiler to profile a statement, given as a string. - - def run(self, cmd): - import __main__ - dict = __main__.__dict__ - return self.runctx(cmd, dict, dict) - - def runctx(self, cmd, globals, locals): - self.set_cmd(cmd) - sys.setprofile(self.dispatcher) - try: - exec cmd in globals, locals - finally: - sys.setprofile(None) - return self - - # This method is more useful to profile a single function call. - def runcall(self, func, *args, **kw): - self.set_cmd(`func`) - sys.setprofile(self.dispatcher) - try: - return apply(func, args, kw) - finally: - sys.setprofile(None) - - - #****************************************************************** - # The following calculates the overhead for using a profiler. The - # problem is that it takes a fair amount of time for the profiler - # to stop the stopwatch (from the time it receives an event). - # Similarly, there is a delay from the time that the profiler - # re-starts the stopwatch before the user's code really gets to - # continue. The following code tries to measure the difference on - # a per-event basis. - # - # Note that this difference is only significant if there are a lot of - # events, and relatively little user code per event. For example, - # code with small functions will typically benefit from having the - # profiler calibrated for the current platform. This *could* be - # done on the fly during init() time, but it is not worth the - # effort. Also note that if too large a value specified, then - # execution time on some functions will actually appear as a - # negative number. It is *normal* for some functions (with very - # low call counts) to have such negative stats, even if the - # calibration figure is "correct." - # - # One alternative to profile-time calibration adjustments (i.e., - # adding in the magic little delta during each event) is to track - # more carefully the number of events (and cumulatively, the number - # of events during sub functions) that are seen. If this were - # done, then the arithmetic could be done after the fact (i.e., at - # display time). Currently, we track only call/return events. - # These values can be deduced by examining the callees and callers - # vectors for each functions. Hence we *can* almost correct the - # internal time figure at print time (note that we currently don't - # track exception event processing counts). Unfortunately, there - # is currently no similar information for cumulative sub-function - # time. It would not be hard to "get all this info" at profiler - # time. Specifically, we would have to extend the tuples to keep - # counts of this in each frame, and then extend the defs of timing - # tuples to include the significant two figures. I'm a bit fearful - # that this additional feature will slow the heavily optimized - # event/time ratio (i.e., the profiler would run slower, fur a very - # low "value added" feature.) - #************************************************************** - - def calibrate(self, m, verbose=0): - if self.__class__ is not Profile: - raise TypeError("Subclasses must override .calibrate().") - - saved_bias = self.bias - self.bias = 0 - try: - return self._calibrate_inner(m, verbose) - finally: - self.bias = saved_bias - - def _calibrate_inner(self, m, verbose): - get_time = self.get_time - - # Set up a test case to be run with and without profiling. Include - # lots of calls, because we're trying to quantify stopwatch overhead. - # Do not raise any exceptions, though, because we want to know - # exactly how many profile events are generated (one call event, + - # one return event, per Python-level call). - - def f1(n): - for i in range(n): - x = 1 - - def f(m, f1=f1): - for i in range(m): - f1(100) - - f(m) # warm up the cache - - # elapsed_noprofile <- time f(m) takes without profiling. - t0 = get_time() - f(m) - t1 = get_time() - elapsed_noprofile = t1 - t0 - if verbose: - print "elapsed time without profiling =", elapsed_noprofile - - # elapsed_profile <- time f(m) takes with profiling. The difference - # is profiling overhead, only some of which the profiler subtracts - # out on its own. - p = Profile() - t0 = get_time() - p.runctx('f(m)', globals(), locals()) - t1 = get_time() - elapsed_profile = t1 - t0 - if verbose: - print "elapsed time with profiling =", elapsed_profile - - # reported_time <- "CPU seconds" the profiler charged to f and f1. - total_calls = 0.0 - reported_time = 0.0 - for (filename, line, funcname), (cc, ns, tt, ct, callers) in \ - p.timings.items(): - if funcname in ("f", "f1"): - total_calls += cc - reported_time += tt - - if verbose: - print "'CPU seconds' profiler reported =", reported_time - print "total # calls =", total_calls - if total_calls != m + 1: - raise ValueError("internal error: total calls = %d" % total_calls) - - # reported_time - elapsed_noprofile = overhead the profiler wasn't - # able to measure. Divide by twice the number of calls (since there - # are two profiler events per call in this test) to get the hidden - # overhead per event. - mean = (reported_time - elapsed_noprofile) / 2.0 / total_calls - if verbose: - print "mean stopwatch overhead per profile event =", mean - return mean - -#**************************************************************************** -def Stats(*args): - print 'Report generating functions are in the "pstats" module\a' - - -# When invoked as main program, invoke the profiler on a script -if __name__ == '__main__': - if not sys.argv[1:]: - print "usage: profile.py scriptfile [arg] ..." - sys.exit(2) - - filename = sys.argv[1] # Get script filename - - del sys.argv[0] # Hide "profile.py" from argument list - - # Insert script directory in front of module search path - sys.path.insert(0, os.path.dirname(filename)) - - run('execfile(' + `filename` + ')') diff --git a/Scripts/ServerPython/python/system/pstats.py b/Scripts/ServerPython/python/system/pstats.py deleted file mode 100644 index bdbaa6d6..00000000 --- a/Scripts/ServerPython/python/system/pstats.py +++ /dev/null @@ -1,641 +0,0 @@ -"""Class for printing reports on profiled python code.""" - -# Class for printing reports on profiled python code. rev 1.0 4/1/94 -# -# Based on prior profile module by Sjoerd Mullender... -# which was hacked somewhat by: Guido van Rossum -# -# see profile.doc and profile.py for more info. - -# Copyright 1994, by InfoSeek Corporation, all rights reserved. -# Written by James Roskind -# -# Permission to use, copy, modify, and distribute this Python software -# and its associated documentation for any purpose (subject to the -# restriction in the following sentence) without fee is hereby granted, -# provided that the above copyright notice appears in all copies, and -# that both that copyright notice and this permission notice appear in -# supporting documentation, and that the name of InfoSeek not be used in -# advertising or publicity pertaining to distribution of the software -# without specific, written prior permission. This permission is -# explicitly restricted to the copying and modification of the software -# to remain in Python, compiled Python, or other languages (such as C) -# wherein the modified or derived code is exclusively imported into a -# Python module. -# -# INFOSEEK CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS. IN NO EVENT SHALL INFOSEEK CORPORATION BE LIABLE FOR ANY -# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER -# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF -# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - -import os -import time -import marshal -import re - -__all__ = ["Stats"] - -class Stats: - """This class is used for creating reports from data generated by the - Profile class. It is a "friend" of that class, and imports data either - by direct access to members of Profile class, or by reading in a dictionary - that was emitted (via marshal) from the Profile class. - - The big change from the previous Profiler (in terms of raw functionality) - is that an "add()" method has been provided to combine Stats from - several distinct profile runs. Both the constructor and the add() - method now take arbitrarily many file names as arguments. - - All the print methods now take an argument that indicates how many lines - to print. If the arg is a floating point number between 0 and 1.0, then - it is taken as a decimal percentage of the available lines to be printed - (e.g., .1 means print 10% of all available lines). If it is an integer, - it is taken to mean the number of lines of data that you wish to have - printed. - - The sort_stats() method now processes some additional options (i.e., in - addition to the old -1, 0, 1, or 2). It takes an arbitrary number of quoted - strings to select the sort order. For example sort_stats('time', 'name') - sorts on the major key of "internal function time", and on the minor - key of 'the name of the function'. Look at the two tables in sort_stats() - and get_sort_arg_defs(self) for more examples. - - All methods now return "self", so you can string together commands like: - Stats('foo', 'goo').strip_dirs().sort_stats('calls').\ - print_stats(5).print_callers(5) - """ - - def __init__(self, *args): - if not len(args): - arg = None - else: - arg = args[0] - args = args[1:] - self.init(arg) - apply(self.add, args) - - def init(self, arg): - self.all_callees = None # calc only if needed - self.files = [] - self.fcn_list = None - self.total_tt = 0 - self.total_calls = 0 - self.prim_calls = 0 - self.max_name_len = 0 - self.top_level = {} - self.stats = {} - self.sort_arg_dict = {} - self.load_stats(arg) - trouble = 1 - try: - self.get_top_level_stats() - trouble = 0 - finally: - if trouble: - print "Invalid timing data", - if self.files: print self.files[-1], - print - - def load_stats(self, arg): - if not arg: self.stats = {} - elif type(arg) == type(""): - f = open(arg, 'rb') - self.stats = marshal.load(f) - f.close() - try: - file_stats = os.stat(arg) - arg = time.ctime(file_stats[8]) + " " + arg - except: # in case this is not unix - pass - self.files = [ arg ] - elif hasattr(arg, 'create_stats'): - arg.create_stats() - self.stats = arg.stats - arg.stats = {} - if not self.stats: - raise TypeError, "Cannot create or construct a " \ - + `self.__class__` \ - + " object from '" + `arg` + "'" - return - - def get_top_level_stats(self): - for func, (cc, nc, tt, ct, callers) in self.stats.items(): - self.total_calls += nc - self.prim_calls += cc - self.total_tt += tt - if callers.has_key(("jprofile", 0, "profiler")): - self.top_level[func] = None - if len(func_std_string(func)) > self.max_name_len: - self.max_name_len = len(func_std_string(func)) - - def add(self, *arg_list): - if not arg_list: return self - if len(arg_list) > 1: apply(self.add, arg_list[1:]) - other = arg_list[0] - if type(self) != type(other) or self.__class__ != other.__class__: - other = Stats(other) - self.files += other.files - self.total_calls += other.total_calls - self.prim_calls += other.prim_calls - self.total_tt += other.total_tt - for func in other.top_level.keys(): - self.top_level[func] = None - - if self.max_name_len < other.max_name_len: - self.max_name_len = other.max_name_len - - self.fcn_list = None - - for func in other.stats.keys(): - if self.stats.has_key(func): - old_func_stat = self.stats[func] - else: - old_func_stat = (0, 0, 0, 0, {},) - self.stats[func] = add_func_stats(old_func_stat, other.stats[func]) - return self - - # list the tuple indices and directions for sorting, - # along with some printable description - sort_arg_dict_default = { - "calls" : (((1,-1), ), "call count"), - "cumulative": (((3,-1), ), "cumulative time"), - "file" : (((4, 1), ), "file name"), - "line" : (((5, 1), ), "line number"), - "module" : (((4, 1), ), "file name"), - "name" : (((6, 1), ), "function name"), - "nfl" : (((6, 1),(4, 1),(5, 1),), "name/file/line"), - "pcalls" : (((0,-1), ), "call count"), - "stdname" : (((7, 1), ), "standard name"), - "time" : (((2,-1), ), "internal time"), - } - - def get_sort_arg_defs(self): - """Expand all abbreviations that are unique.""" - if not self.sort_arg_dict: - self.sort_arg_dict = dict = {} - bad_list = {} - for word in self.sort_arg_dict_default.keys(): - fragment = word - while fragment: - if not fragment: - break - if dict.has_key(fragment): - bad_list[fragment] = 0 - break - dict[fragment] = self.sort_arg_dict_default[word] - fragment = fragment[:-1] - for word in bad_list.keys(): - del dict[word] - return self.sort_arg_dict - - def sort_stats(self, *field): - if not field: - self.fcn_list = 0 - return self - if len(field) == 1 and type(field[0]) == type(1): - # Be compatible with old profiler - field = [ {-1: "stdname", - 0:"calls", - 1:"time", - 2: "cumulative" } [ field[0] ] ] - - sort_arg_defs = self.get_sort_arg_defs() - sort_tuple = () - self.sort_type = "" - connector = "" - for word in field: - sort_tuple = sort_tuple + sort_arg_defs[word][0] - self.sort_type += connector + sort_arg_defs[word][1] - connector = ", " - - stats_list = [] - for func in self.stats.keys(): - cc, nc, tt, ct, callers = self.stats[func] - stats_list.append((cc, nc, tt, ct) + func + - (func_std_string(func), func)) - - stats_list.sort(TupleComp(sort_tuple).compare) - - self.fcn_list = fcn_list = [] - for tuple in stats_list: - fcn_list.append(tuple[-1]) - return self - - def reverse_order(self): - if self.fcn_list: - self.fcn_list.reverse() - return self - - def strip_dirs(self): - oldstats = self.stats - self.stats = newstats = {} - max_name_len = 0 - for func in oldstats.keys(): - cc, nc, tt, ct, callers = oldstats[func] - newfunc = func_strip_path(func) - if len(func_std_string(newfunc)) > max_name_len: - max_name_len = len(func_std_string(newfunc)) - newcallers = {} - for func2 in callers.keys(): - newcallers[func_strip_path(func2)] = callers[func2] - - if newstats.has_key(newfunc): - newstats[newfunc] = add_func_stats( - newstats[newfunc], - (cc, nc, tt, ct, newcallers)) - else: - newstats[newfunc] = (cc, nc, tt, ct, newcallers) - old_top = self.top_level - self.top_level = new_top = {} - for func in old_top.keys(): - new_top[func_strip_path(func)] = None - - self.max_name_len = max_name_len - - self.fcn_list = None - self.all_callees = None - return self - - def calc_callees(self): - if self.all_callees: return - self.all_callees = all_callees = {} - for func in self.stats.keys(): - if not all_callees.has_key(func): - all_callees[func] = {} - cc, nc, tt, ct, callers = self.stats[func] - for func2 in callers.keys(): - if not all_callees.has_key(func2): - all_callees[func2] = {} - all_callees[func2][func] = callers[func2] - return - - #****************************************************************** - # The following functions support actual printing of reports - #****************************************************************** - - # Optional "amount" is either a line count, or a percentage of lines. - - def eval_print_amount(self, sel, list, msg): - new_list = list - if type(sel) == type(""): - new_list = [] - for func in list: - if re.search(sel, func_std_string(func)): - new_list.append(func) - else: - count = len(list) - if type(sel) == type(1.0) and 0.0 <= sel < 1.0: - count = int(count * sel + .5) - new_list = list[:count] - elif type(sel) == type(1) and 0 <= sel < count: - count = sel - new_list = list[:count] - if len(list) != len(new_list): - msg = msg + " List reduced from " + `len(list)` \ - + " to " + `len(new_list)` + \ - " due to restriction <" + `sel` + ">\n" - - return new_list, msg - - def get_print_list(self, sel_list): - width = self.max_name_len - if self.fcn_list: - list = self.fcn_list[:] - msg = " Ordered by: " + self.sort_type + '\n' - else: - list = self.stats.keys() - msg = " Random listing order was used\n" - - for selection in sel_list: - list, msg = self.eval_print_amount(selection, list, msg) - - count = len(list) - - if not list: - return 0, list - print msg - if count < len(self.stats): - width = 0 - for func in list: - if len(func_std_string(func)) > width: - width = len(func_std_string(func)) - return width+2, list - - def print_stats(self, *amount): - for filename in self.files: - print filename - if self.files: print - indent = ' ' * 8 - for func in self.top_level.keys(): - print indent, func_get_function_name(func) - - print indent, self.total_calls, "function calls", - if self.total_calls != self.prim_calls: - print "(%d primitive calls)" % self.prim_calls, - print "in %.3f CPU seconds" % self.total_tt - print - width, list = self.get_print_list(amount) - if list: - self.print_title() - for func in list: - self.print_line(func) - print - print - return self - - def print_callees(self, *amount): - width, list = self.get_print_list(amount) - if list: - self.calc_callees() - - self.print_call_heading(width, "called...") - for func in list: - if self.all_callees.has_key(func): - self.print_call_line(width, func, self.all_callees[func]) - else: - self.print_call_line(width, func, {}) - print - print - return self - - def print_callers(self, *amount): - width, list = self.get_print_list(amount) - if list: - self.print_call_heading(width, "was called by...") - for func in list: - cc, nc, tt, ct, callers = self.stats[func] - self.print_call_line(width, func, callers) - print - print - return self - - def print_call_heading(self, name_size, column_title): - print "Function ".ljust(name_size) + column_title - - def print_call_line(self, name_size, source, call_dict): - print func_std_string(source).ljust(name_size), - if not call_dict: - print "--" - return - clist = call_dict.keys() - clist.sort() - name_size = name_size + 1 - indent = "" - for func in clist: - name = func_std_string(func) - print indent*name_size + name + '(' \ - + `call_dict[func]`+')', \ - f8(self.stats[func][3]) - indent = " " - - def print_title(self): - print ' ncalls tottime percall cumtime percall', \ - 'filename:lineno(function)' - - def print_line(self, func): # hack : should print percentages - cc, nc, tt, ct, callers = self.stats[func] - c = str(nc) - if nc != cc: - c = c + '/' + str(cc) - print c.rjust(9), - print f8(tt), - if nc == 0: - print ' '*8, - else: - print f8(tt/nc), - print f8(ct), - if cc == 0: - print ' '*8, - else: - print f8(ct/cc), - print func_std_string(func) - - def ignore(self): - # Deprecated since 1.5.1 -- see the docs. - pass # has no return value, so use at end of line :-) - -class TupleComp: - """This class provides a generic function for comparing any two tuples. - Each instance records a list of tuple-indices (from most significant - to least significant), and sort direction (ascending or decending) for - each tuple-index. The compare functions can then be used as the function - argument to the system sort() function when a list of tuples need to be - sorted in the instances order.""" - - def __init__(self, comp_select_list): - self.comp_select_list = comp_select_list - - def compare (self, left, right): - for index, direction in self.comp_select_list: - l = left[index] - r = right[index] - if l < r: - return -direction - if l > r: - return direction - return 0 - -#************************************************************************** -# func_name is a triple (file:string, line:int, name:string) - -def func_strip_path(func_name): - file, line, name = func_name - return os.path.basename(file), line, name - -def func_get_function_name(func): - return func[2] - -def func_std_string(func_name): # match what old profile produced - return "%s:%d(%s)" % func_name - -#************************************************************************** -# The following functions combine statists for pairs functions. -# The bulk of the processing involves correctly handling "call" lists, -# such as callers and callees. -#************************************************************************** - -def add_func_stats(target, source): - """Add together all the stats for two profile entries.""" - cc, nc, tt, ct, callers = source - t_cc, t_nc, t_tt, t_ct, t_callers = target - return (cc+t_cc, nc+t_nc, tt+t_tt, ct+t_ct, - add_callers(t_callers, callers)) - -def add_callers(target, source): - """Combine two caller lists in a single list.""" - new_callers = {} - for func in target.keys(): - new_callers[func] = target[func] - for func in source.keys(): - if new_callers.has_key(func): - new_callers[func] = source[func] + new_callers[func] - else: - new_callers[func] = source[func] - return new_callers - -def count_calls(callers): - """Sum the caller statistics to get total number of calls received.""" - nc = 0 - for func in callers.keys(): - nc += callers[func] - return nc - -#************************************************************************** -# The following functions support printing of reports -#************************************************************************** - -def f8(x): - return "%8.3f" % x - -#************************************************************************** -# Statistics browser added by ESR, April 2001 -#************************************************************************** - -if __name__ == '__main__': - import cmd - try: - import readline - except ImportError: - pass - - class ProfileBrowser(cmd.Cmd): - def __init__(self, profile=None): - cmd.Cmd.__init__(self) - self.prompt = "% " - if profile: - self.stats = Stats(profile) - else: - self.stats = None - - def generic(self, fn, line): - args = line.split() - processed = [] - for term in args: - try: - processed.append(int(term)) - continue - except ValueError: - pass - try: - frac = float(term) - if frac > 1 or frac < 0: - print "Fraction argument mus be in [0, 1]" - continue - processed.append(frac) - continue - except ValueError: - pass - processed.append(term) - if self.stats: - apply(getattr(self.stats, fn), processed) - else: - print "No statistics object is loaded." - return 0 - def generic_help(self): - print "Arguments may be:" - print "* An integer maximum number of entries to print." - print "* A decimal fractional number between 0 and 1, controlling" - print " what fraction of selected entries to print." - print "* A regular expression; only entries with function names" - print " that match it are printed." - - def do_add(self, line): - self.stats.add(line) - return 0 - def help_add(self): - print "Add profile info from given file to current statistics object." - - def do_callees(self, line): - return self.generic('print_callees', line) - def help_callees(self): - print "Print callees statistics from the current stat object." - self.generic_help() - - def do_callers(self, line): - return self.generic('print_callers', line) - def help_callers(self): - print "Print callers statistics from the current stat object." - self.generic_help() - - def do_EOF(self, line): - print "" - return 1 - def help_EOF(self): - print "Leave the profile brower." - - def do_quit(self, line): - return 1 - def help_quit(self): - print "Leave the profile brower." - - def do_read(self, line): - if line: - try: - self.stats = Stats(line) - except IOError, args: - print args[1] - return - self.prompt = line + "% " - elif len(self.prompt) > 2: - line = self.prompt[-2:] - else: - print "No statistics object is current -- cannot reload." - return 0 - def help_read(self): - print "Read in profile data from a specified file." - - def do_reverse(self, line): - self.stats.reverse_order() - return 0 - def help_reverse(self): - print "Reverse the sort order of the profiling report." - - def do_sort(self, line): - abbrevs = self.stats.get_sort_arg_defs().keys() - if line and not filter(lambda x,a=abbrevs: x not in a,line.split()): - apply(self.stats.sort_stats, line.split()) - else: - print "Valid sort keys (unique prefixes are accepted):" - for (key, value) in Stats.sort_arg_dict_default.items(): - print "%s -- %s" % (key, value[1]) - return 0 - def help_sort(self): - print "Sort profile data according to specified keys." - print "(Typing `sort' without arguments lists valid keys.)" - def complete_sort(self, text, *args): - return [a for a in Stats.sort_arg_dict_default.keys() if a.startswith(text)] - - def do_stats(self, line): - return self.generic('print_stats', line) - def help_stats(self): - print "Print statistics from the current stat object." - self.generic_help() - - def do_strip(self, line): - self.stats.strip_dirs() - return 0 - def help_strip(self): - print "Strip leading path information from filenames in the report." - - def postcmd(self, stop, line): - if stop: - return stop - return None - - import sys - print "Welcome to the profile statistics browser." - if len(sys.argv) > 1: - initprofile = sys.argv[1] - else: - initprofile = None - try: - ProfileBrowser(initprofile).cmdloop() - print "Goodbye." - except KeyboardInterrupt: - pass - -# That's all, folks. diff --git a/Scripts/ServerPython/python/system/py_compile.py b/Scripts/ServerPython/python/system/py_compile.py deleted file mode 100644 index af473363..00000000 --- a/Scripts/ServerPython/python/system/py_compile.py +++ /dev/null @@ -1,82 +0,0 @@ -"""Routine to "compile" a .py file to a .pyc (or .pyo) file. - -This module has intimate knowledge of the format of .pyc files. -""" - -import imp -MAGIC = imp.get_magic() - -__all__ = ["compile"] - -def wr_long(f, x): - """Internal; write a 32-bit int to a file in little-endian order.""" - f.write(chr( x & 0xff)) - f.write(chr((x >> 8) & 0xff)) - f.write(chr((x >> 16) & 0xff)) - f.write(chr((x >> 24) & 0xff)) - -def compile(file, cfile=None, dfile=None): - """Byte-compile one Python source file to Python bytecode. - - Arguments: - - file: source filename - cfile: target filename; defaults to source with 'c' or 'o' appended - ('c' normally, 'o' in optimizing mode, giving .pyc or .pyo) - dfile: purported filename; defaults to source (this is the filename - that will show up in error messages) - - Note that it isn't necessary to byte-compile Python modules for - execution efficiency -- Python itself byte-compiles a module when - it is loaded, and if it can, writes out the bytecode to the - corresponding .pyc (or .pyo) file. - - However, if a Python installation is shared between users, it is a - good idea to byte-compile all modules upon installation, since - other users may not be able to write in the source directories, - and thus they won't be able to write the .pyc/.pyo file, and then - they would be byte-compiling every module each time it is loaded. - This can slow down program start-up considerably. - - See compileall.py for a script/module that uses this module to - byte-compile all installed files (or all files in selected - directories). - - """ - import os, marshal, __builtin__ - f = open(file) - try: - timestamp = long(os.fstat(f.fileno())[8]) - except AttributeError: - timestamp = long(os.stat(file)[8]) - codestring = f.read() - # If parsing from a string, line breaks are \n (see parsetok.c:tok_nextc) - # Replace will return original string if pattern is not found, so - # we don't need to check whether it is found first. - codestring = codestring.replace("\r\n","\n") - codestring = codestring.replace("\r","\n") - f.close() - if codestring and codestring[-1] != '\n': - codestring = codestring + '\n' - try: - codeobject = __builtin__.compile(codestring, dfile or file, 'exec') - except SyntaxError, detail: - import traceback, sys - lines = traceback.format_exception_only(SyntaxError, detail) - for line in lines: - sys.stderr.write(line.replace('File ""', - 'File "%s"' % (dfile or file))) - return - if not cfile: - cfile = file + (__debug__ and 'c' or 'o') - fc = open(cfile, 'wb') - fc.write('\0\0\0\0') - wr_long(fc, timestamp) - marshal.dump(codeobject, fc) - fc.flush() - fc.seek(0, 0) - fc.write(MAGIC) - fc.close() - if os.name == 'mac': - import macfs - macfs.FSSpec(cfile).SetCreatorType('Pyth', 'PYC ') diff --git a/Scripts/ServerPython/python/system/pyclbr.py b/Scripts/ServerPython/python/system/pyclbr.py deleted file mode 100644 index 90e5dc35..00000000 --- a/Scripts/ServerPython/python/system/pyclbr.py +++ /dev/null @@ -1,337 +0,0 @@ -"""Parse a Python file and retrieve classes and methods. - -Parse enough of a Python file to recognize class and method -definitions and to find out the superclasses of a class. - -The interface consists of a single function: - readmodule(module, path) -module is the name of a Python module, path is an optional list of -directories where the module is to be searched. If present, path is -prepended to the system search path sys.path. -The return value is a dictionary. The keys of the dictionary are -the names of the classes defined in the module (including classes -that are defined via the from XXX import YYY construct). The values -are class instances of the class Class defined here. - -A class is described by the class Class in this module. Instances -of this class have the following instance variables: - name -- the name of the class - super -- a list of super classes (Class instances) - methods -- a dictionary of methods - file -- the file in which the class was defined - lineno -- the line in the file on which the class statement occurred -The dictionary of methods uses the method names as keys and the line -numbers on which the method was defined as values. -If the name of a super class is not recognized, the corresponding -entry in the list of super classes is not a class instance but a -string giving the name of the super class. Since import statements -are recognized and imported modules are scanned as well, this -shouldn't happen often. - -BUGS -- Continuation lines are not dealt with at all, except inside strings. -- Nested classes and functions can confuse it. -- Code that doesn't pass tabnanny or python -t will confuse it, unless - you set the module TABWIDTH vrbl (default 8) to the correct tab width - for the file. - -PACKAGE RELATED BUGS -- If you have a package and a module inside that or another package - with the same name, module caching doesn't work properly since the - key is the base name of the module/package. -- The only entry that is returned when you readmodule a package is a - __path__ whose value is a list which confuses certain class browsers. -- When code does: - from package import subpackage - class MyClass(subpackage.SuperClass): - ... - It can't locate the parent. It probably needs to have the same - hairy logic that the import locator already does. (This logic - exists coded in Python in the freeze package.) -""" - -import sys -import imp -import re -import string - -__all__ = ["readmodule"] - -TABWIDTH = 8 - -_getnext = re.compile(r""" - (?P - \""" [^"\\]* (?: - (?: \\. | "(?!"") ) - [^"\\]* - )* - \""" - - | ''' [^'\\]* (?: - (?: \\. | '(?!'') ) - [^'\\]* - )* - ''' - - | " [^"\\\n]* (?: \\. [^"\\\n]*)* " - - | ' [^'\\\n]* (?: \\. [^'\\\n]*)* ' - ) - -| (?P - ^ - (?P [ \t]* ) - def [ \t]+ - (?P [a-zA-Z_] \w* ) - [ \t]* \( - ) - -| (?P - ^ - (?P [ \t]* ) - class [ \t]+ - (?P [a-zA-Z_] \w* ) - [ \t]* - (?P \( [^)\n]* \) )? - [ \t]* : - ) - -| (?P - ^ import [ \t]+ - (?P [^#;\n]+ ) - ) - -| (?P - ^ from [ \t]+ - (?P - [a-zA-Z_] \w* - (?: - [ \t]* \. [ \t]* [a-zA-Z_] \w* - )* - ) - [ \t]+ - import [ \t]+ - (?P [^#;\n]+ ) - ) -""", re.VERBOSE | re.DOTALL | re.MULTILINE).search - -_modules = {} # cache of modules we've seen - -# each Python class is represented by an instance of this class -class Class: - '''Class to represent a Python class.''' - def __init__(self, module, name, super, file, lineno): - self.module = module - self.name = name - if super is None: - super = [] - self.super = super - self.methods = {} - self.file = file - self.lineno = lineno - - def _addmethod(self, name, lineno): - self.methods[name] = lineno - -class Function(Class): - '''Class to represent a top-level Python function''' - def __init__(self, module, name, file, lineno): - Class.__init__(self, module, name, None, file, lineno) - def _addmethod(self, name, lineno): - assert 0, "Function._addmethod() shouldn't be called" - -def readmodule(module, path=[], inpackage=0): - '''Backwards compatible interface. - - Like readmodule_ex() but strips Function objects from the - resulting dictionary.''' - - dict = readmodule_ex(module, path, inpackage) - res = {} - for key, value in dict.items(): - if not isinstance(value, Function): - res[key] = value - return res - -def readmodule_ex(module, path=[], inpackage=0): - '''Read a module file and return a dictionary of classes. - - Search for MODULE in PATH and sys.path, read and parse the - module and return a dictionary with one entry for each class - found in the module.''' - - dict = {} - - i = module.rfind('.') - if i >= 0: - # Dotted module name - package = module[:i].strip() - submodule = module[i+1:].strip() - parent = readmodule_ex(package, path, inpackage) - child = readmodule_ex(submodule, parent['__path__'], 1) - return child - - if _modules.has_key(module): - # we've seen this module before... - return _modules[module] - if module in sys.builtin_module_names: - # this is a built-in module - _modules[module] = dict - return dict - - # search the path for the module - f = None - if inpackage: - try: - f, file, (suff, mode, type) = \ - imp.find_module(module, path) - except ImportError: - f = None - if f is None: - fullpath = list(path) + sys.path - f, file, (suff, mode, type) = imp.find_module(module, fullpath) - if type == imp.PKG_DIRECTORY: - dict['__path__'] = [file] - _modules[module] = dict - path = [file] + path - f, file, (suff, mode, type) = \ - imp.find_module('__init__', [file]) - if type != imp.PY_SOURCE: - # not Python source, can't do anything with this module - f.close() - _modules[module] = dict - return dict - - _modules[module] = dict - classstack = [] # stack of (class, indent) pairs - src = f.read() - f.close() - - # To avoid having to stop the regexp at each newline, instead - # when we need a line number we simply string.count the number of - # newlines in the string since the last time we did this; i.e., - # lineno = lineno + \ - # string.count(src, '\n', last_lineno_pos, here) - # last_lineno_pos = here - countnl = string.count - lineno, last_lineno_pos = 1, 0 - i = 0 - while 1: - m = _getnext(src, i) - if not m: - break - start, i = m.span() - - if m.start("Method") >= 0: - # found a method definition or function - thisindent = _indent(m.group("MethodIndent")) - meth_name = m.group("MethodName") - lineno = lineno + \ - countnl(src, '\n', - last_lineno_pos, start) - last_lineno_pos = start - # close all classes indented at least as much - while classstack and \ - classstack[-1][1] >= thisindent: - del classstack[-1] - if classstack: - # it's a class method - cur_class = classstack[-1][0] - cur_class._addmethod(meth_name, lineno) - else: - # it's a function - f = Function(module, meth_name, - file, lineno) - dict[meth_name] = f - - elif m.start("String") >= 0: - pass - - elif m.start("Class") >= 0: - # we found a class definition - thisindent = _indent(m.group("ClassIndent")) - # close all classes indented at least as much - while classstack and \ - classstack[-1][1] >= thisindent: - del classstack[-1] - lineno = lineno + \ - countnl(src, '\n', last_lineno_pos, start) - last_lineno_pos = start - class_name = m.group("ClassName") - inherit = m.group("ClassSupers") - if inherit: - # the class inherits from other classes - inherit = inherit[1:-1].strip() - names = [] - for n in inherit.split(','): - n = n.strip() - if dict.has_key(n): - # we know this super class - n = dict[n] - else: - c = n.split('.') - if len(c) > 1: - # super class - # is of the - # form module.class: - # look in - # module for class - m = c[-2] - c = c[-1] - if _modules.has_key(m): - d = _modules[m] - if d.has_key(c): - n = d[c] - names.append(n) - inherit = names - # remember this class - cur_class = Class(module, class_name, inherit, - file, lineno) - dict[class_name] = cur_class - classstack.append((cur_class, thisindent)) - - elif m.start("Import") >= 0: - # import module - for n in m.group("ImportList").split(','): - n = n.strip() - try: - # recursively read the imported module - d = readmodule_ex(n, path, inpackage) - except: - ##print 'module', n, 'not found' - pass - - elif m.start("ImportFrom") >= 0: - # from module import stuff - mod = m.group("ImportFromPath") - names = m.group("ImportFromList").split(',') - try: - # recursively read the imported module - d = readmodule_ex(mod, path, inpackage) - except: - ##print 'module', mod, 'not found' - continue - # add any classes that were defined in the - # imported module to our name space if they - # were mentioned in the list - for n in names: - n = n.strip() - if d.has_key(n): - dict[n] = d[n] - elif n == '*': - # only add a name if not - # already there (to mimic what - # Python does internally) - # also don't add names that - # start with _ - for n in d.keys(): - if n[0] != '_' and \ - not dict.has_key(n): - dict[n] = d[n] - else: - assert 0, "regexp _getnext found something unexpected" - - return dict - -def _indent(ws, _expandtabs=string.expandtabs): - return len(_expandtabs(ws, TABWIDTH)) diff --git a/Scripts/ServerPython/python/system/random.py b/Scripts/ServerPython/python/system/random.py deleted file mode 100644 index 09e750c3..00000000 --- a/Scripts/ServerPython/python/system/random.py +++ /dev/null @@ -1,777 +0,0 @@ -"""Random variable generators. - - integers - -------- - uniform within range - - sequences - --------- - pick random element - generate random permutation - - distributions on the real line: - ------------------------------ - uniform - normal (Gaussian) - lognormal - negative exponential - gamma - beta - - distributions on the circle (angles 0 to 2pi) - --------------------------------------------- - circular uniform - von Mises - -Translated from anonymously contributed C/C++ source. - -Multi-threading note: the random number generator used here is not thread- -safe; it is possible that two calls return the same random value. However, -you can instantiate a different instance of Random() in each thread to get -generators that don't share state, then use .setstate() and .jumpahead() to -move the generators to disjoint segments of the full period. For example, - -def create_generators(num, delta, firstseed=None): - ""\"Return list of num distinct generators. - Each generator has its own unique segment of delta elements from - Random.random()'s full period. - Seed the first generator with optional arg firstseed (default is - None, to seed from current time). - ""\" - - from random import Random - g = Random(firstseed) - result = [g] - for i in range(num - 1): - laststate = g.getstate() - g = Random() - g.setstate(laststate) - g.jumpahead(delta) - result.append(g) - return result - -gens = create_generators(10, 1000000) - -That creates 10 distinct generators, which can be passed out to 10 distinct -threads. The generators don't share state so can be called safely in -parallel. So long as no thread calls its g.random() more than a million -times (the second argument to create_generators), the sequences seen by -each thread will not overlap. - -The period of the underlying Wichmann-Hill generator is 6,953,607,871,644, -and that limits how far this technique can be pushed. - -Just for fun, note that since we know the period, .jumpahead() can also be -used to "move backward in time": - ->>> g = Random(42) # arbitrary ->>> g.random() -0.25420336316883324 ->>> g.jumpahead(6953607871644L - 1) # move *back* one ->>> g.random() -0.25420336316883324 -""" -# XXX The docstring sucks. - -from math import log as _log, exp as _exp, pi as _pi, e as _e -from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin -from math import floor as _floor - -__all__ = ["Random","seed","random","uniform","randint","choice", - "randrange","shuffle","normalvariate","lognormvariate", - "cunifvariate","expovariate","vonmisesvariate","gammavariate", - "stdgamma","gauss","betavariate","paretovariate","weibullvariate", - "getstate","setstate","jumpahead","whseed"] - -def _verify(name, computed, expected): - if abs(computed - expected) > 1e-7: - raise ValueError( - "computed value for %s deviates too much " - "(computed %g, expected %g)" % (name, computed, expected)) - -NV_MAGICCONST = 4 * _exp(-0.5)/_sqrt(2.0) -_verify('NV_MAGICCONST', NV_MAGICCONST, 1.71552776992141) - -TWOPI = 2.0*_pi -_verify('TWOPI', TWOPI, 6.28318530718) - -LOG4 = _log(4.0) -_verify('LOG4', LOG4, 1.38629436111989) - -SG_MAGICCONST = 1.0 + _log(4.5) -_verify('SG_MAGICCONST', SG_MAGICCONST, 2.50407739677627) - -del _verify - -# Translated by Guido van Rossum from C source provided by -# Adrian Baddeley. - -class Random: - """Random number generator base class used by bound module functions. - - Used to instantiate instances of Random to get generators that don't - share state. Especially useful for multi-threaded programs, creating - a different instance of Random for each thread, and using the jumpahead() - method to ensure that the generated sequences seen by each thread don't - overlap. - - Class Random can also be subclassed if you want to use a different basic - generator of your own devising: in that case, override the following - methods: random(), seed(), getstate(), setstate() and jumpahead(). - - """ - - VERSION = 1 # used by getstate/setstate - - def __init__(self, x=None): - """Initialize an instance. - - Optional argument x controls seeding, as for Random.seed(). - """ - - self.seed(x) - -## -------------------- core generator ------------------- - - # Specific to Wichmann-Hill generator. Subclasses wishing to use a - # different core generator should override the seed(), random(), - # getstate(), setstate() and jumpahead() methods. - - def seed(self, a=None): - """Initialize internal state from hashable object. - - None or no argument seeds from current time. - - If a is not None or an int or long, hash(a) is used instead. - - If a is an int or long, a is used directly. Distinct values between - 0 and 27814431486575L inclusive are guaranteed to yield distinct - internal states (this guarantee is specific to the default - Wichmann-Hill generator). - """ - - if a is None: - # Initialize from current time - import time - a = long(time.time() * 256) - - if type(a) not in (type(3), type(3L)): - a = hash(a) - - a, x = divmod(a, 30268) - a, y = divmod(a, 30306) - a, z = divmod(a, 30322) - self._seed = int(x)+1, int(y)+1, int(z)+1 - - self.gauss_next = None - - def random(self): - """Get the next random number in the range [0.0, 1.0).""" - - # Wichman-Hill random number generator. - # - # Wichmann, B. A. & Hill, I. D. (1982) - # Algorithm AS 183: - # An efficient and portable pseudo-random number generator - # Applied Statistics 31 (1982) 188-190 - # - # see also: - # Correction to Algorithm AS 183 - # Applied Statistics 33 (1984) 123 - # - # McLeod, A. I. (1985) - # A remark on Algorithm AS 183 - # Applied Statistics 34 (1985),198-200 - - # This part is thread-unsafe: - # BEGIN CRITICAL SECTION - x, y, z = self._seed - x = (171 * x) % 30269 - y = (172 * y) % 30307 - z = (170 * z) % 30323 - self._seed = x, y, z - # END CRITICAL SECTION - - # Note: on a platform using IEEE-754 double arithmetic, this can - # never return 0.0 (asserted by Tim; proof too long for a comment). - return (x/30269.0 + y/30307.0 + z/30323.0) % 1.0 - - def getstate(self): - """Return internal state; can be passed to setstate() later.""" - return self.VERSION, self._seed, self.gauss_next - - def setstate(self, state): - """Restore internal state from object returned by getstate().""" - version = state[0] - if version == 1: - version, self._seed, self.gauss_next = state - else: - raise ValueError("state with version %s passed to " - "Random.setstate() of version %s" % - (version, self.VERSION)) - - def jumpahead(self, n): - """Act as if n calls to random() were made, but quickly. - - n is an int, greater than or equal to 0. - - Example use: If you have 2 threads and know that each will - consume no more than a million random numbers, create two Random - objects r1 and r2, then do - r2.setstate(r1.getstate()) - r2.jumpahead(1000000) - Then r1 and r2 will use guaranteed-disjoint segments of the full - period. - """ - - if not n >= 0: - raise ValueError("n must be >= 0") - x, y, z = self._seed - x = int(x * pow(171, n, 30269)) % 30269 - y = int(y * pow(172, n, 30307)) % 30307 - z = int(z * pow(170, n, 30323)) % 30323 - self._seed = x, y, z - - def __whseed(self, x=0, y=0, z=0): - """Set the Wichmann-Hill seed from (x, y, z). - - These must be integers in the range [0, 256). - """ - - if not type(x) == type(y) == type(z) == type(0): - raise TypeError('seeds must be integers') - if not (0 <= x < 256 and 0 <= y < 256 and 0 <= z < 256): - raise ValueError('seeds must be in range(0, 256)') - if 0 == x == y == z: - # Initialize from current time - import time - t = long(time.time() * 256) - t = int((t&0xffffff) ^ (t>>24)) - t, x = divmod(t, 256) - t, y = divmod(t, 256) - t, z = divmod(t, 256) - # Zero is a poor seed, so substitute 1 - self._seed = (x or 1, y or 1, z or 1) - - self.gauss_next = None - - def whseed(self, a=None): - """Seed from hashable object's hash code. - - None or no argument seeds from current time. It is not guaranteed - that objects with distinct hash codes lead to distinct internal - states. - - This is obsolete, provided for compatibility with the seed routine - used prior to Python 2.1. Use the .seed() method instead. - """ - - if a is None: - self.__whseed() - return - a = hash(a) - a, x = divmod(a, 256) - a, y = divmod(a, 256) - a, z = divmod(a, 256) - x = (x + a) % 256 or 1 - y = (y + a) % 256 or 1 - z = (z + a) % 256 or 1 - self.__whseed(x, y, z) - -## ---- Methods below this point do not need to be overridden when -## ---- subclassing for the purpose of using a different core generator. - -## -------------------- pickle support ------------------- - - def __getstate__(self): # for pickle - return self.getstate() - - def __setstate__(self, state): # for pickle - self.setstate(state) - -## -------------------- integer methods ------------------- - - def randrange(self, start, stop=None, step=1, int=int, default=None): - """Choose a random item from range(start, stop[, step]). - - This fixes the problem with randint() which includes the - endpoint; in Python this is usually not what you want. - Do not supply the 'int' and 'default' arguments. - """ - - # This code is a bit messy to make it fast for the - # common case while still doing adequate error checking. - istart = int(start) - if istart != start: - raise ValueError, "non-integer arg 1 for randrange()" - if stop is default: - if istart > 0: - return int(self.random() * istart) - raise ValueError, "empty range for randrange()" - - # stop argument supplied. - istop = int(stop) - if istop != stop: - raise ValueError, "non-integer stop for randrange()" - if step == 1 and istart < istop: - try: - return istart + int(self.random()*(istop - istart)) - except OverflowError: - # This can happen if istop-istart > sys.maxint + 1, and - # multiplying by random() doesn't reduce it to something - # <= sys.maxint. We know that the overall result fits - # in an int, and can still do it correctly via math.floor(). - # But that adds another function call, so for speed we - # avoided that whenever possible. - return int(istart + _floor(self.random()*(istop - istart))) - if step == 1: - raise ValueError, "empty range for randrange()" - - # Non-unit step argument supplied. - istep = int(step) - if istep != step: - raise ValueError, "non-integer step for randrange()" - if istep > 0: - n = (istop - istart + istep - 1) / istep - elif istep < 0: - n = (istop - istart + istep + 1) / istep - else: - raise ValueError, "zero step for randrange()" - - if n <= 0: - raise ValueError, "empty range for randrange()" - return istart + istep*int(self.random() * n) - - def randint(self, a, b): - """Return random integer in range [a, b], including both end points. - """ - - return self.randrange(a, b+1) - -## -------------------- sequence methods ------------------- - - def choice(self, seq): - """Choose a random element from a non-empty sequence.""" - return seq[int(self.random() * len(seq))] - - def shuffle(self, x, random=None, int=int): - """x, random=random.random -> shuffle list x in place; return None. - - Optional arg random is a 0-argument function returning a random - float in [0.0, 1.0); by default, the standard random.random. - - Note that for even rather small len(x), the total number of - permutations of x is larger than the period of most random number - generators; this implies that "most" permutations of a long - sequence can never be generated. - """ - - if random is None: - random = self.random - for i in xrange(len(x)-1, 0, -1): - # pick an element in x[:i+1] with which to exchange x[i] - j = int(random() * (i+1)) - x[i], x[j] = x[j], x[i] - -## -------------------- real-valued distributions ------------------- - -## -------------------- uniform distribution ------------------- - - def uniform(self, a, b): - """Get a random number in the range [a, b).""" - return a + (b-a) * self.random() - -## -------------------- normal distribution -------------------- - - def normalvariate(self, mu, sigma): - """Normal distribution. - - mu is the mean, and sigma is the standard deviation. - - """ - # mu = mean, sigma = standard deviation - - # Uses Kinderman and Monahan method. Reference: Kinderman, - # A.J. and Monahan, J.F., "Computer generation of random - # variables using the ratio of uniform deviates", ACM Trans - # Math Software, 3, (1977), pp257-260. - - random = self.random - while 1: - u1 = random() - u2 = random() - z = NV_MAGICCONST*(u1-0.5)/u2 - zz = z*z/4.0 - if zz <= -_log(u2): - break - return mu + z*sigma - -## -------------------- lognormal distribution -------------------- - - def lognormvariate(self, mu, sigma): - """Log normal distribution. - - If you take the natural logarithm of this distribution, you'll get a - normal distribution with mean mu and standard deviation sigma. - mu can have any value, and sigma must be greater than zero. - - """ - return _exp(self.normalvariate(mu, sigma)) - -## -------------------- circular uniform -------------------- - - def cunifvariate(self, mean, arc): - """Circular uniform distribution. - - mean is the mean angle, and arc is the range of the distribution, - centered around the mean angle. Both values must be expressed in - radians. Returned values range between mean - arc/2 and - mean + arc/2 and are normalized to between 0 and pi. - - Deprecated in version 2.3. Use: - (mean + arc * (Random.random() - 0.5)) % Math.pi - - """ - # mean: mean angle (in radians between 0 and pi) - # arc: range of distribution (in radians between 0 and pi) - - return (mean + arc * (self.random() - 0.5)) % _pi - -## -------------------- exponential distribution -------------------- - - def expovariate(self, lambd): - """Exponential distribution. - - lambd is 1.0 divided by the desired mean. (The parameter would be - called "lambda", but that is a reserved word in Python.) Returned - values range from 0 to positive infinity. - - """ - # lambd: rate lambd = 1/mean - # ('lambda' is a Python reserved word) - - random = self.random - u = random() - while u <= 1e-7: - u = random() - return -_log(u)/lambd - -## -------------------- von Mises distribution -------------------- - - def vonmisesvariate(self, mu, kappa): - """Circular data distribution. - - mu is the mean angle, expressed in radians between 0 and 2*pi, and - kappa is the concentration parameter, which must be greater than or - equal to zero. If kappa is equal to zero, this distribution reduces - to a uniform random angle over the range 0 to 2*pi. - - """ - # mu: mean angle (in radians between 0 and 2*pi) - # kappa: concentration parameter kappa (>= 0) - # if kappa = 0 generate uniform random angle - - # Based upon an algorithm published in: Fisher, N.I., - # "Statistical Analysis of Circular Data", Cambridge - # University Press, 1993. - - # Thanks to Magnus Kessler for a correction to the - # implementation of step 4. - - random = self.random - if kappa <= 1e-6: - return TWOPI * random() - - a = 1.0 + _sqrt(1.0 + 4.0 * kappa * kappa) - b = (a - _sqrt(2.0 * a))/(2.0 * kappa) - r = (1.0 + b * b)/(2.0 * b) - - while 1: - u1 = random() - - z = _cos(_pi * u1) - f = (1.0 + r * z)/(r + z) - c = kappa * (r - f) - - u2 = random() - - if not (u2 >= c * (2.0 - c) and u2 > c * _exp(1.0 - c)): - break - - u3 = random() - if u3 > 0.5: - theta = (mu % TWOPI) + _acos(f) - else: - theta = (mu % TWOPI) - _acos(f) - - return theta - -## -------------------- gamma distribution -------------------- - - def gammavariate(self, alpha, beta): - """Gamma distribution. Not the gamma function! - - Conditions on the parameters are alpha > 0 and beta > 0. - - """ - - # alpha > 0, beta > 0, mean is alpha*beta, variance is alpha*beta**2 - - # Warning: a few older sources define the gamma distribution in terms - # of alpha > -1.0 - if alpha <= 0.0 or beta <= 0.0: - raise ValueError, 'gammavariate: alpha and beta must be > 0.0' - - random = self.random - if alpha > 1.0: - - # Uses R.C.H. Cheng, "The generation of Gamma - # variables with non-integral shape parameters", - # Applied Statistics, (1977), 26, No. 1, p71-74 - - ainv = _sqrt(2.0 * alpha - 1.0) - bbb = alpha - LOG4 - ccc = alpha + ainv - - while 1: - u1 = random() - u2 = random() - v = _log(u1/(1.0-u1))/ainv - x = alpha*_exp(v) - z = u1*u1*u2 - r = bbb+ccc*v-x - if r + SG_MAGICCONST - 4.5*z >= 0.0 or r >= _log(z): - return x * beta - - elif alpha == 1.0: - # expovariate(1) - u = random() - while u <= 1e-7: - u = random() - return -_log(u) * beta - - else: # alpha is between 0 and 1 (exclusive) - - # Uses ALGORITHM GS of Statistical Computing - Kennedy & Gentle - - while 1: - u = random() - b = (_e + alpha)/_e - p = b*u - if p <= 1.0: - x = pow(p, 1.0/alpha) - else: - # p > 1 - x = -_log((b-p)/alpha) - u1 = random() - if not (((p <= 1.0) and (u1 > _exp(-x))) or - ((p > 1) and (u1 > pow(x, alpha - 1.0)))): - break - return x * beta - - - def stdgamma(self, alpha, ainv, bbb, ccc): - # This method was (and shall remain) undocumented. - # This method is deprecated - # for the following reasons: - # 1. Returns same as .gammavariate(alpha, 1.0) - # 2. Requires caller to provide 3 extra arguments - # that are functions of alpha anyway - # 3. Can't be used for alpha < 0.5 - - # ainv = sqrt(2 * alpha - 1) - # bbb = alpha - log(4) - # ccc = alpha + ainv - import warnings - warnings.warn("The stdgamma function is deprecated; " - "use gammavariate() instead", - DeprecationWarning) - return self.gammavariate(alpha, 1.0) - - - -## -------------------- Gauss (faster alternative) -------------------- - - def gauss(self, mu, sigma): - """Gaussian distribution. - - mu is the mean, and sigma is the standard deviation. This is - slightly faster than the normalvariate() function. - - Not thread-safe without a lock around calls. - - """ - - # When x and y are two variables from [0, 1), uniformly - # distributed, then - # - # cos(2*pi*x)*sqrt(-2*log(1-y)) - # sin(2*pi*x)*sqrt(-2*log(1-y)) - # - # are two *independent* variables with normal distribution - # (mu = 0, sigma = 1). - # (Lambert Meertens) - # (corrected version; bug discovered by Mike Miller, fixed by LM) - - # Multithreading note: When two threads call this function - # simultaneously, it is possible that they will receive the - # same return value. The window is very small though. To - # avoid this, you have to use a lock around all calls. (I - # didn't want to slow this down in the serial case by using a - # lock here.) - - random = self.random - z = self.gauss_next - self.gauss_next = None - if z is None: - x2pi = random() * TWOPI - g2rad = _sqrt(-2.0 * _log(1.0 - random())) - z = _cos(x2pi) * g2rad - self.gauss_next = _sin(x2pi) * g2rad - - return mu + z*sigma - -## -------------------- beta -------------------- -## See -## http://sourceforge.net/bugs/?func=detailbug&bug_id=130030&group_id=5470 -## for Ivan Frohne's insightful analysis of why the original implementation: -## -## def betavariate(self, alpha, beta): -## # Discrete Event Simulation in C, pp 87-88. -## -## y = self.expovariate(alpha) -## z = self.expovariate(1.0/beta) -## return z/(y+z) -## -## was dead wrong, and how it probably got that way. - - def betavariate(self, alpha, beta): - """Beta distribution. - - Conditions on the parameters are alpha > -1 and beta} > -1. - Returned values range between 0 and 1. - - """ - - # This version due to Janne Sinkkonen, and matches all the std - # texts (e.g., Knuth Vol 2 Ed 3 pg 134 "the beta distribution"). - y = self.gammavariate(alpha, 1.) - if y == 0: - return 0.0 - else: - return y / (y + self.gammavariate(beta, 1.)) - -## -------------------- Pareto -------------------- - - def paretovariate(self, alpha): - """Pareto distribution. alpha is the shape parameter.""" - # Jain, pg. 495 - - u = self.random() - return 1.0 / pow(u, 1.0/alpha) - -## -------------------- Weibull -------------------- - - def weibullvariate(self, alpha, beta): - """Weibull distribution. - - alpha is the scale parameter and beta is the shape parameter. - - """ - # Jain, pg. 499; bug fix courtesy Bill Arms - - u = self.random() - return alpha * pow(-_log(u), 1.0/beta) - -## -------------------- test program -------------------- - -def _test_generator(n, funccall): - import time - print n, 'times', funccall - code = compile(funccall, funccall, 'eval') - sum = 0.0 - sqsum = 0.0 - smallest = 1e10 - largest = -1e10 - t0 = time.time() - for i in range(n): - x = eval(code) - sum = sum + x - sqsum = sqsum + x*x - smallest = min(x, smallest) - largest = max(x, largest) - t1 = time.time() - print round(t1-t0, 3), 'sec,', - avg = sum/n - stddev = _sqrt(sqsum/n - avg*avg) - print 'avg %g, stddev %g, min %g, max %g' % \ - (avg, stddev, smallest, largest) - -def _test(N=20000): - print 'TWOPI =', TWOPI - print 'LOG4 =', LOG4 - print 'NV_MAGICCONST =', NV_MAGICCONST - print 'SG_MAGICCONST =', SG_MAGICCONST - _test_generator(N, 'random()') - _test_generator(N, 'normalvariate(0.0, 1.0)') - _test_generator(N, 'lognormvariate(0.0, 1.0)') - _test_generator(N, 'cunifvariate(0.0, 1.0)') - _test_generator(N, 'expovariate(1.0)') - _test_generator(N, 'vonmisesvariate(0.0, 1.0)') - _test_generator(N, 'gammavariate(0.01, 1.0)') - _test_generator(N, 'gammavariate(0.1, 1.0)') - _test_generator(N, 'gammavariate(0.1, 2.0)') - _test_generator(N, 'gammavariate(0.5, 1.0)') - _test_generator(N, 'gammavariate(0.9, 1.0)') - _test_generator(N, 'gammavariate(1.0, 1.0)') - _test_generator(N, 'gammavariate(2.0, 1.0)') - _test_generator(N, 'gammavariate(20.0, 1.0)') - _test_generator(N, 'gammavariate(200.0, 1.0)') - _test_generator(N, 'gauss(0.0, 1.0)') - _test_generator(N, 'betavariate(3.0, 3.0)') - _test_generator(N, 'paretovariate(1.0)') - _test_generator(N, 'weibullvariate(1.0, 1.0)') - - # Test jumpahead. - s = getstate() - jumpahead(N) - r1 = random() - # now do it the slow way - setstate(s) - for i in range(N): - random() - r2 = random() - if r1 != r2: - raise ValueError("jumpahead test failed " + `(N, r1, r2)`) - -# Create one instance, seeded from current time, and export its methods -# as module-level functions. The functions are not threadsafe, and state -# is shared across all uses (both in the user's code and in the Python -# libraries), but that's fine for most programs and is easier for the -# casual user than making them instantiate their own Random() instance. -_inst = Random() -seed = _inst.seed -random = _inst.random -uniform = _inst.uniform -randint = _inst.randint -choice = _inst.choice -randrange = _inst.randrange -shuffle = _inst.shuffle -normalvariate = _inst.normalvariate -lognormvariate = _inst.lognormvariate -cunifvariate = _inst.cunifvariate -expovariate = _inst.expovariate -vonmisesvariate = _inst.vonmisesvariate -gammavariate = _inst.gammavariate -stdgamma = _inst.stdgamma -gauss = _inst.gauss -betavariate = _inst.betavariate -paretovariate = _inst.paretovariate -weibullvariate = _inst.weibullvariate -getstate = _inst.getstate -setstate = _inst.setstate -jumpahead = _inst.jumpahead -whseed = _inst.whseed - -if __name__ == '__main__': - _test() diff --git a/Scripts/ServerPython/python/system/re.py b/Scripts/ServerPython/python/system/re.py deleted file mode 100644 index 21839a13..00000000 --- a/Scripts/ServerPython/python/system/re.py +++ /dev/null @@ -1,33 +0,0 @@ -"""Minimal "re" compatibility wrapper""" - -# If your regexps don't work well under 2.0b1, you can switch -# to the old engine ("pre") down below. -# -# To help us fix any remaining bugs in the new engine, please -# report what went wrong. You can either use the following web -# page: -# -# http://sourceforge.net/bugs/?group_id=5470 -# -# or send a mail to SRE's author: -# -# Fredrik Lundh -# -# Make sure to include the pattern, the string SRE failed to -# match, and what result you expected. -# -# thanks /F -# - -engine = "sre" -# engine = "pre" - -if engine == "sre": - # New unicode-aware engine - from sre import * - from sre import __all__ -else: - # Old 1.5.2 engine. This one supports 8-bit strings only, - # and will be removed in 2.0 final. - from pre import * - from pre import __all__ diff --git a/Scripts/ServerPython/python/system/regex_syntax.py b/Scripts/ServerPython/python/system/regex_syntax.py deleted file mode 100644 index 47406930..00000000 --- a/Scripts/ServerPython/python/system/regex_syntax.py +++ /dev/null @@ -1,53 +0,0 @@ -"""Constants for selecting regexp syntaxes for the obsolete regex module. - -This module is only for backward compatibility. "regex" has now -been replaced by the new regular expression module, "re". - -These bits are passed to regex.set_syntax() to choose among -alternative regexp syntaxes. -""" - -# 1 means plain parentheses serve as grouping, and backslash -# parentheses are needed for literal searching. -# 0 means backslash-parentheses are grouping, and plain parentheses -# are for literal searching. -RE_NO_BK_PARENS = 1 - -# 1 means plain | serves as the "or"-operator, and \| is a literal. -# 0 means \| serves as the "or"-operator, and | is a literal. -RE_NO_BK_VBAR = 2 - -# 0 means plain + or ? serves as an operator, and \+, \? are literals. -# 1 means \+, \? are operators and plain +, ? are literals. -RE_BK_PLUS_QM = 4 - -# 1 means | binds tighter than ^ or $. -# 0 means the contrary. -RE_TIGHT_VBAR = 8 - -# 1 means treat \n as an _OR operator -# 0 means treat it as a normal character -RE_NEWLINE_OR = 16 - -# 0 means that a special characters (such as *, ^, and $) always have -# their special meaning regardless of the surrounding context. -# 1 means that special characters may act as normal characters in some -# contexts. Specifically, this applies to: -# ^ - only special at the beginning, or after ( or | -# $ - only special at the end, or before ) or | -# *, +, ? - only special when not after the beginning, (, or | -RE_CONTEXT_INDEP_OPS = 32 - -# ANSI sequences (\n etc) and \xhh -RE_ANSI_HEX = 64 - -# No GNU extensions -RE_NO_GNU_EXTENSIONS = 128 - -# Now define combinations of bits for the standard possibilities. -RE_SYNTAX_AWK = (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS) -RE_SYNTAX_EGREP = (RE_SYNTAX_AWK | RE_NEWLINE_OR) -RE_SYNTAX_GREP = (RE_BK_PLUS_QM | RE_NEWLINE_OR) -RE_SYNTAX_EMACS = 0 - -# (Python's obsolete "regexp" module used a syntax similar to awk.) diff --git a/Scripts/ServerPython/python/system/repr.py b/Scripts/ServerPython/python/system/repr.py deleted file mode 100644 index d5edda54..00000000 --- a/Scripts/ServerPython/python/system/repr.py +++ /dev/null @@ -1,95 +0,0 @@ -"""Redo the `...` (representation) but with limits on most sizes.""" - -__all__ = ["Repr","repr"] - -class Repr: - def __init__(self): - self.maxlevel = 6 - self.maxtuple = 6 - self.maxlist = 6 - self.maxdict = 4 - self.maxstring = 30 - self.maxlong = 40 - self.maxother = 20 - def repr(self, x): - return self.repr1(x, self.maxlevel) - def repr1(self, x, level): - typename = type(x).__name__ - if ' ' in typename: - parts = typename.split() - typename = '_'.join(parts) - if hasattr(self, 'repr_' + typename): - return getattr(self, 'repr_' + typename)(x, level) - else: - s = `x` - if len(s) > self.maxother: - i = max(0, (self.maxother-3)//2) - j = max(0, self.maxother-3-i) - s = s[:i] + '...' + s[len(s)-j:] - return s - def repr_tuple(self, x, level): - n = len(x) - if n == 0: return '()' - if level <= 0: return '(...)' - s = '' - for i in range(min(n, self.maxtuple)): - if s: s = s + ', ' - s = s + self.repr1(x[i], level-1) - if n > self.maxtuple: s = s + ', ...' - elif n == 1: s = s + ',' - return '(' + s + ')' - def repr_list(self, x, level): - n = len(x) - if n == 0: return '[]' - if level <= 0: return '[...]' - s = '' - for i in range(min(n, self.maxlist)): - if s: s = s + ', ' - s = s + self.repr1(x[i], level-1) - if n > self.maxlist: s = s + ', ...' - return '[' + s + ']' - def repr_dict(self, x, level): - n = len(x) - if n == 0: return '{}' - if level <= 0: return '{...}' - s = '' - keys = x.keys() - keys.sort() - for i in range(min(n, self.maxdict)): - if s: s = s + ', ' - key = keys[i] - s = s + self.repr1(key, level-1) - s = s + ': ' + self.repr1(x[key], level-1) - if n > self.maxdict: s = s + ', ...' - return '{' + s + '}' - def repr_str(self, x, level): - s = `x[:self.maxstring]` - if len(s) > self.maxstring: - i = max(0, (self.maxstring-3)//2) - j = max(0, self.maxstring-3-i) - s = `x[:i] + x[len(x)-j:]` - s = s[:i] + '...' + s[len(s)-j:] - return s - def repr_long(self, x, level): - s = `x` # XXX Hope this isn't too slow... - if len(s) > self.maxlong: - i = max(0, (self.maxlong-3)//2) - j = max(0, self.maxlong-3-i) - s = s[:i] + '...' + s[len(s)-j:] - return s - def repr_instance(self, x, level): - try: - s = `x` - # Bugs in x.__repr__() can cause arbitrary - # exceptions -- then make up something - except: - return '<' + x.__class__.__name__ + ' instance at ' + \ - hex(id(x))[2:] + '>' - if len(s) > self.maxstring: - i = max(0, (self.maxstring-3)//2) - j = max(0, self.maxstring-3-i) - s = s[:i] + '...' + s[len(s)-j:] - return s - -aRepr = Repr() -repr = aRepr.repr diff --git a/Scripts/ServerPython/python/system/shlex.py b/Scripts/ServerPython/python/system/shlex.py deleted file mode 100644 index 5d91c380..00000000 --- a/Scripts/ServerPython/python/system/shlex.py +++ /dev/null @@ -1,209 +0,0 @@ -"""A lexical analyzer class for simple shell-like syntaxes.""" - -# Module and documentation by Eric S. Raymond, 21 Dec 1998 -# Input stacking and error message cleanup added by ESR, March 2000 -# push_source() and pop_source() made explicit by ESR, January 2001. - -import os.path -import sys - -__all__ = ["shlex"] - -class shlex: - "A lexical analyzer class for simple shell-like syntaxes." - def __init__(self, instream=None, infile=None): - if instream: - self.instream = instream - self.infile = infile - else: - self.instream = sys.stdin - self.infile = None - self.commenters = '#' - self.wordchars = ('abcdfeghijklmnopqrstuvwxyz' - 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_') - self.whitespace = ' \t\r\n' - self.quotes = '\'"' - self.state = ' ' - self.pushback = [] - self.lineno = 1 - self.debug = 0 - self.token = '' - self.filestack = [] - self.source = None - if self.debug: - print 'shlex: reading from %s, line %d' \ - % (self.instream, self.lineno) - - def push_token(self, tok): - "Push a token onto the stack popped by the get_token method" - if self.debug >= 1: - print "shlex: pushing token " + `tok` - self.pushback = [tok] + self.pushback - - def push_source(self, newstream, newfile=None): - "Push an input source onto the lexer's input source stack." - self.filestack.insert(0, (self.infile, self.instream, self.lineno)) - self.infile = newfile - self.instream = newstream - self.lineno = 1 - if self.debug: - if newfile: - print 'shlex: pushing to file %s' % (self.infile,) - else: - print 'shlex: pushing to stream %s' % (self.instream,) - - def pop_source(self): - "Pop the input source stack." - self.instream.close() - (self.infile, self.instream, self.lineno) = self.filestack[0] - self.filestack = self.filestack[1:] - if self.debug: - print 'shlex: popping to %s, line %d' \ - % (self.instream, self.lineno) - self.state = ' ' - - def get_token(self): - "Get a token from the input stream (or from stack if it's nonempty)" - if self.pushback: - tok = self.pushback[0] - self.pushback = self.pushback[1:] - if self.debug >= 1: - print "shlex: popping token " + `tok` - return tok - # No pushback. Get a token. - raw = self.read_token() - # Handle inclusions - while raw == self.source: - spec = self.sourcehook(self.read_token()) - if spec: - (newfile, newstream) = spec - self.push_source(newstream, newfile) - raw = self.get_token() - # Maybe we got EOF instead? - while raw == "": - if len(self.filestack) == 0: - return "" - else: - self.pop_source() - raw = self.get_token() - # Neither inclusion nor EOF - if self.debug >= 1: - if raw: - print "shlex: token=" + `raw` - else: - print "shlex: token=EOF" - return raw - - def read_token(self): - "Read a token from the input stream (no pushback or inclusions)" - while 1: - nextchar = self.instream.read(1) - if nextchar == '\n': - self.lineno = self.lineno + 1 - if self.debug >= 3: - print "shlex: in state", repr(self.state), \ - "I see character:", repr(nextchar) - if self.state is None: - self.token = '' # past end of file - break - elif self.state == ' ': - if not nextchar: - self.state = None # end of file - break - elif nextchar in self.whitespace: - if self.debug >= 2: - print "shlex: I see whitespace in whitespace state" - if self.token: - break # emit current token - else: - continue - elif nextchar in self.commenters: - self.instream.readline() - self.lineno = self.lineno + 1 - elif nextchar in self.wordchars: - self.token = nextchar - self.state = 'a' - elif nextchar in self.quotes: - self.token = nextchar - self.state = nextchar - else: - self.token = nextchar - if self.token: - break # emit current token - else: - continue - elif self.state in self.quotes: - self.token = self.token + nextchar - if nextchar == self.state: - self.state = ' ' - break - elif not nextchar: # end of file - if self.debug >= 2: - print "shlex: I see EOF in quotes state" - # XXX what error should be raised here? - raise ValueError, "No closing quotation" - elif self.state == 'a': - if not nextchar: - self.state = None # end of file - break - elif nextchar in self.whitespace: - if self.debug >= 2: - print "shlex: I see whitespace in word state" - self.state = ' ' - if self.token: - break # emit current token - else: - continue - elif nextchar in self.commenters: - self.instream.readline() - self.lineno = self.lineno + 1 - elif nextchar in self.wordchars or nextchar in self.quotes: - self.token = self.token + nextchar - else: - self.pushback = [nextchar] + self.pushback - if self.debug >= 2: - print "shlex: I see punctuation in word state" - self.state = ' ' - if self.token: - break # emit current token - else: - continue - result = self.token - self.token = '' - if self.debug > 1: - if result: - print "shlex: raw token=" + `result` - else: - print "shlex: raw token=EOF" - return result - - def sourcehook(self, newfile): - "Hook called on a filename to be sourced." - if newfile[0] == '"': - newfile = newfile[1:-1] - # This implements cpp-like semantics for relative-path inclusion. - if type(self.infile) == type("") and not os.path.isabs(newfile): - newfile = os.path.join(os.path.dirname(self.infile), newfile) - return (newfile, open(newfile, "r")) - - def error_leader(self, infile=None, lineno=None): - "Emit a C-compiler-like, Emacs-friendly error-message leader." - if not infile: - infile = self.infile - if not lineno: - lineno = self.lineno - return "\"%s\", line %d: " % (infile, lineno) - - -if __name__ == '__main__': - if len(sys.argv) == 1: - lexer = shlex() - else: - file = sys.argv[1] - lexer = shlex(open(file), file) - while 1: - tt = lexer.get_token() - if tt: - print "Token: " + repr(tt) - else: - break diff --git a/Scripts/ServerPython/python/system/shutil.py b/Scripts/ServerPython/python/system/shutil.py deleted file mode 100644 index c11d46be..00000000 --- a/Scripts/ServerPython/python/system/shutil.py +++ /dev/null @@ -1,138 +0,0 @@ -"""Utility functions for copying files and directory trees. - -XXX The functions here don't copy the resource fork or other metadata on Mac. - -""" - -import os -import sys -import stat - -__all__ = ["copyfileobj","copyfile","copymode","copystat","copy","copy2", - "copytree","rmtree"] - -def copyfileobj(fsrc, fdst, length=16*1024): - """copy data from file-like object fsrc to file-like object fdst""" - while 1: - buf = fsrc.read(length) - if not buf: - break - fdst.write(buf) - - -def copyfile(src, dst): - """Copy data from src to dst""" - fsrc = None - fdst = None - try: - fsrc = open(src, 'rb') - fdst = open(dst, 'wb') - copyfileobj(fsrc, fdst) - finally: - if fdst: - fdst.close() - if fsrc: - fsrc.close() - -def copymode(src, dst): - """Copy mode bits from src to dst""" - if hasattr(os, 'chmod'): - st = os.stat(src) - mode = stat.S_IMODE(st[stat.ST_MODE]) - os.chmod(dst, mode) - -def copystat(src, dst): - """Copy all stat info (mode bits, atime and mtime) from src to dst""" - st = os.stat(src) - mode = stat.S_IMODE(st[stat.ST_MODE]) - if hasattr(os, 'utime'): - os.utime(dst, (st[stat.ST_ATIME], st[stat.ST_MTIME])) - if hasattr(os, 'chmod'): - os.chmod(dst, mode) - - -def copy(src, dst): - """Copy data and mode bits ("cp src dst"). - - The destination may be a directory. - - """ - if os.path.isdir(dst): - dst = os.path.join(dst, os.path.basename(src)) - copyfile(src, dst) - copymode(src, dst) - -def copy2(src, dst): - """Copy data and all stat info ("cp -p src dst"). - - The destination may be a directory. - - """ - if os.path.isdir(dst): - dst = os.path.join(dst, os.path.basename(src)) - copyfile(src, dst) - copystat(src, dst) - - -def copytree(src, dst, symlinks=0): - """Recursively copy a directory tree using copy2(). - - The destination directory must not already exist. - Error are reported to standard output. - - If the optional symlinks flag is true, symbolic links in the - source tree result in symbolic links in the destination tree; if - it is false, the contents of the files pointed to by symbolic - links are copied. - - XXX Consider this example code rather than the ultimate tool. - - """ - names = os.listdir(src) - os.mkdir(dst) - for name in names: - srcname = os.path.join(src, name) - dstname = os.path.join(dst, name) - try: - if symlinks and os.path.islink(srcname): - linkto = os.readlink(srcname) - os.symlink(linkto, dstname) - elif os.path.isdir(srcname): - copytree(srcname, dstname, symlinks) - else: - copy2(srcname, dstname) - # XXX What about devices, sockets etc.? - except (IOError, os.error), why: - print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why)) - -def rmtree(path, ignore_errors=0, onerror=None): - """Recursively delete a directory tree. - - If ignore_errors is set, errors are ignored; otherwise, if - onerror is set, it is called to handle the error; otherwise, an - exception is raised. - - """ - cmdtuples = [] - _build_cmdtuple(path, cmdtuples) - for cmd in cmdtuples: - try: - apply(cmd[0], (cmd[1],)) - except: - exc = sys.exc_info() - if ignore_errors: - pass - elif onerror: - onerror(cmd[0], cmd[1], exc) - else: - raise exc[0], (exc[1][0], exc[1][1] + ' removing '+cmd[1]) - -# Helper for rmtree() -def _build_cmdtuple(path, cmdtuples): - for f in os.listdir(path): - real_f = os.path.join(path,f) - if os.path.isdir(real_f) and not os.path.islink(real_f): - _build_cmdtuple(real_f, cmdtuples) - else: - cmdtuples.append((os.remove, real_f)) - cmdtuples.append((os.rmdir, path)) diff --git a/Scripts/ServerPython/python/system/site.py b/Scripts/ServerPython/python/system/site.py deleted file mode 100644 index 751b650d..00000000 --- a/Scripts/ServerPython/python/system/site.py +++ /dev/null @@ -1,330 +0,0 @@ -"""Append module search paths for third-party packages to sys.path. - -**************************************************************** -* This module is automatically imported during initialization. * -**************************************************************** - -In earlier versions of Python (up to 1.5a3), scripts or modules that -needed to use site-specific modules would place ``import site'' -somewhere near the top of their code. Because of the automatic -import, this is no longer necessary (but code that does it still -works). - -This will append site-specific paths to to the module search path. On -Unix, it starts with sys.prefix and sys.exec_prefix (if different) and -appends lib/python/site-packages as well as lib/site-python. -On other platforms (mainly Mac and Windows), it uses just sys.prefix -(and sys.exec_prefix, if different, but this is unlikely). The -resulting directories, if they exist, are appended to sys.path, and -also inspected for path configuration files. - -A path configuration file is a file whose name has the form -.pth; its contents are additional directories (one per line) -to be added to sys.path. Non-existing directories (or -non-directories) are never added to sys.path; no directory is added to -sys.path more than once. Blank lines and lines beginning with -'#' are skipped. Lines starting with 'import' are executed. - -For example, suppose sys.prefix and sys.exec_prefix are set to -/usr/local and there is a directory /usr/local/lib/python1.5/site-packages -with three subdirectories, foo, bar and spam, and two path -configuration files, foo.pth and bar.pth. Assume foo.pth contains the -following: - - # foo package configuration - foo - bar - bletch - -and bar.pth contains: - - # bar package configuration - bar - -Then the following directories are added to sys.path, in this order: - - /usr/local/lib/python1.5/site-packages/bar - /usr/local/lib/python1.5/site-packages/foo - -Note that bletch is omitted because it doesn't exist; bar precedes foo -because bar.pth comes alphabetically before foo.pth; and spam is -omitted because it is not mentioned in either path configuration file. - -After these path manipulations, an attempt is made to import a module -named sitecustomize, which can perform arbitrary additional -site-specific customizations. If this import fails with an -ImportError exception, it is silently ignored. - -""" - -import sys, os - - -def makepath(*paths): - dir = os.path.abspath(os.path.join(*paths)) - return dir, os.path.normcase(dir) - -for m in sys.modules.values(): - if hasattr(m, "__file__") and m.__file__: - m.__file__ = os.path.abspath(m.__file__) -del m - -# This ensures that the initial path provided by the interpreter contains -# only absolute pathnames, even if we're running from the build directory. -L = [] -_dirs_in_sys_path = {} -for dir in sys.path: - # Filter out paths that don't exist, but leave in the empty string - # since it's a special case. We also need to special-case the Mac, - # as file names are allowed on sys.path there. - if sys.platform != 'mac': - if dir and not os.path.isdir(dir): - continue - else: - if dir and not os.path.exists(dir): - continue - dir, dircase = makepath(dir) - if not _dirs_in_sys_path.has_key(dircase): - L.append(dir) - _dirs_in_sys_path[dircase] = 1 -sys.path[:] = L -del dir, L - -# Append ./build/lib. in case we're running in the build dir -# (especially for Guido :-) -if (os.name == "posix" and sys.path and - os.path.basename(sys.path[-1]) == "Modules"): - from distutils.util import get_platform - s = "build/lib.%s-%.3s" % (get_platform(), sys.version) - s = os.path.join(os.path.dirname(sys.path[-1]), s) - sys.path.append(s) - del get_platform, s - -def _init_pathinfo(): - global _dirs_in_sys_path - _dirs_in_sys_path = d = {} - for dir in sys.path: - if dir and not os.path.isdir(dir): - continue - dir, dircase = makepath(dir) - d[dircase] = 1 - -def addsitedir(sitedir): - global _dirs_in_sys_path - if _dirs_in_sys_path is None: - _init_pathinfo() - reset = 1 - else: - reset = 0 - sitedir, sitedircase = makepath(sitedir) - if not _dirs_in_sys_path.has_key(sitedircase): - sys.path.append(sitedir) # Add path component - try: - names = os.listdir(sitedir) - except os.error: - return - names.sort() - for name in names: - if name[-4:] == os.extsep + "pth": - addpackage(sitedir, name) - if reset: - _dirs_in_sys_path = None - -def addpackage(sitedir, name): - global _dirs_in_sys_path - if _dirs_in_sys_path is None: - _init_pathinfo() - reset = 1 - else: - reset = 0 - fullname = os.path.join(sitedir, name) - try: - f = open(fullname) - except IOError: - return - while 1: - dir = f.readline() - if not dir: - break - if dir[0] == '#': - continue - if dir.startswith("import"): - exec dir - continue - if dir[-1] == '\n': - dir = dir[:-1] - dir, dircase = makepath(sitedir, dir) - if not _dirs_in_sys_path.has_key(dircase) and os.path.exists(dir): - sys.path.append(dir) - _dirs_in_sys_path[dircase] = 1 - if reset: - _dirs_in_sys_path = None - -prefixes = [sys.prefix] -if sys.exec_prefix != sys.prefix: - prefixes.append(sys.exec_prefix) -for prefix in prefixes: - if prefix: - if os.sep == '/': - sitedirs = [os.path.join(prefix, - "lib", - "python" + sys.version[:3], - "site-packages"), - os.path.join(prefix, "lib", "site-python")] - else: - sitedirs = [prefix, os.path.join(prefix, "lib", "site-packages")] - for sitedir in sitedirs: - if os.path.isdir(sitedir): - addsitedir(sitedir) - -_dirs_in_sys_path = None - - -# Define new built-ins 'quit' and 'exit'. -# These are simply strings that display a hint on how to exit. -if os.sep == ':': - exit = 'Use Cmd-Q to quit.' -elif os.sep == '\\': - exit = 'Use Ctrl-Z plus Return to exit.' -else: - exit = 'Use Ctrl-D (i.e. EOF) to exit.' -import __builtin__ -__builtin__.quit = __builtin__.exit = exit -del exit - -# interactive prompt objects for printing the license text, a list of -# contributors and the copyright notice. -class _Printer: - MAXLINES = 23 - - def __init__(self, name, data, files=(), dirs=()): - self.__name = name - self.__data = data - self.__files = files - self.__dirs = dirs - self.__lines = None - - def __setup(self): - if self.__lines: - return - data = None - for dir in self.__dirs: - for file in self.__files: - file = os.path.join(dir, file) - try: - fp = open(file) - data = fp.read() - fp.close() - break - except IOError: - pass - if data: - break - if not data: - data = self.__data - self.__lines = data.split('\n') - self.__linecnt = len(self.__lines) - - def __repr__(self): - self.__setup() - if len(self.__lines) <= self.MAXLINES: - return "\n".join(self.__lines) - else: - return "Type %s() to see the full %s text" % ((self.__name,)*2) - - def __call__(self): - self.__setup() - prompt = 'Hit Return for more, or q (and Return) to quit: ' - lineno = 0 - while 1: - try: - for i in range(lineno, lineno + self.MAXLINES): - print self.__lines[i] - except IndexError: - break - else: - lineno += self.MAXLINES - key = None - while key is None: - key = raw_input(prompt) - if key not in ('', 'q'): - key = None - if key == 'q': - break - -__builtin__.copyright = _Printer("copyright", sys.copyright) -if sys.platform[:4] == 'java': - __builtin__.credits = _Printer( - "credits", - "Jython is maintained by the Jython developers (www.jython.org).") -else: - __builtin__.credits = _Printer("credits", """\ -Thanks to CWI, CNRI, BeOpen.com, Digital Creations and a cast of thousands -for supporting Python development. See www.python.org for more information.""") -here = os.path.dirname(os.__file__) -__builtin__.license = _Printer( - "license", "See http://www.python.org/%.3s/license.html" % sys.version, - ["LICENSE.txt", "LICENSE"], - [os.path.join(here, os.pardir), here, os.curdir]) - - -# Define new built-in 'help'. -# This is a wrapper around pydoc.help (with a twist). - -class _Helper: - def __repr__(self): - return "Type help() for interactive help, " \ - "or help(object) for help about object." - def __call__(self, *args, **kwds): - import pydoc - return pydoc.help(*args, **kwds) - -__builtin__.help = _Helper() - - -# Set the string encoding used by the Unicode implementation. The -# default is 'ascii', but if you're willing to experiment, you can -# change this. - -encoding = "ascii" # Default value set by _PyUnicode_Init() - -if 0: - # Enable to support locale aware default string encodings. - import locale - loc = locale.getdefaultlocale() - if loc[1]: - encoding = loc[1] - -if 0: - # Enable to switch off string to Unicode coercion and implicit - # Unicode to string conversion. - encoding = "undefined" - -if encoding != "ascii": - # On Non-Unicode builds this will raise an AttributeError... - sys.setdefaultencoding(encoding) # Needs Python Unicode build ! - -# -# Run custom site specific code, if available. -# -try: - import sitecustomize -except ImportError: - pass - -# -# Remove sys.setdefaultencoding() so that users cannot change the -# encoding after initialization. The test for presence is needed when -# this module is run as a script, because this code is executed twice. -# -if hasattr(sys, "setdefaultencoding"): - del sys.setdefaultencoding - -def _test(): - print "sys.path = [" - for dir in sys.path: - print " %s," % `dir` - print "]" - -if __name__ == '__main__': - _test() diff --git a/Scripts/ServerPython/python/system/spark.py b/Scripts/ServerPython/python/system/spark.py deleted file mode 100644 index a0c5bc84..00000000 --- a/Scripts/ServerPython/python/system/spark.py +++ /dev/null @@ -1,566 +0,0 @@ -# Copyright (c) 1998-2000 John Aycock -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -__version__ = 'SPARK-0.6.1' - -import re -import sys -import string - -def _namelist(instance): - namelist, namedict, classlist = [], {}, [instance.__class__] - for c in classlist: - for b in c.__bases__: - classlist.append(b) - for name in dir(c): - if not namedict.has_key(name): - namelist.append(name) - namedict[name] = 1 - return namelist - -class GenericScanner: - def __init__(self): - pattern = self.reflect() - self.re = re.compile(pattern, re.VERBOSE) - - self.index2func = {} - for name, number in self.re.groupindex.items(): - self.index2func[number-1] = getattr(self, 't_' + name) - - def makeRE(self, name): - doc = getattr(self, name).__doc__ - rv = '(?P<%s>%s)' % (name[2:], doc) - return rv - - def reflect(self): - rv = [] - for name in _namelist(self): - if name[:2] == 't_' and name != 't_default': - rv.append(self.makeRE(name)) - - rv.append(self.makeRE('t_default')) - return string.join(rv, '|') - - def error(self, s, pos): - print "Lexical error at position %s" % pos - raise SystemExit - - def tokenize(self, s): - pos = 0 - n = len(s) - while pos < n: - m = self.re.match(s, pos) - if m is None: - self.error(s, pos) - - groups = m.groups() - for i in range(len(groups)): - if groups[i] and self.index2func.has_key(i): - self.index2func[i](groups[i]) - pos = m.end() - - def t_default(self, s): - r'( . | \n )+' - pass - -class GenericParser: - def __init__(self, start): - self.rules = {} - self.rule2func = {} - self.rule2name = {} - self.collectRules() - self.startRule = self.augment(start) - self.ruleschanged = 1 - - _START = 'START' - _EOF = 'EOF' - - # - # A hook for GenericASTBuilder and GenericASTMatcher. - # - def preprocess(self, rule, func): return rule, func - - def addRule(self, doc, func): - rules = string.split(doc) - - index = [] - for i in range(len(rules)): - if rules[i] == '::=': - index.append(i-1) - index.append(len(rules)) - - for i in range(len(index)-1): - lhs = rules[index[i]] - rhs = rules[index[i]+2:index[i+1]] - rule = (lhs, tuple(rhs)) - - rule, fn = self.preprocess(rule, func) - - if self.rules.has_key(lhs): - self.rules[lhs].append(rule) - else: - self.rules[lhs] = [ rule ] - self.rule2func[rule] = fn - self.rule2name[rule] = func.__name__[2:] - self.ruleschanged = 1 - - def collectRules(self): - for name in _namelist(self): - if name[:2] == 'p_': - func = getattr(self, name) - doc = func.__doc__ - self.addRule(doc, func) - - def augment(self, start): - # - # Tempting though it is, this isn't made into a call - # to self.addRule() because the start rule shouldn't - # be subject to preprocessing. - # - startRule = (self._START, ( start, self._EOF )) - self.rule2func[startRule] = lambda args: args[0] - self.rules[self._START] = [ startRule ] - self.rule2name[startRule] = '' - return startRule - - def makeFIRST(self): - union = {} - self.first = {} - - for rulelist in self.rules.values(): - for lhs, rhs in rulelist: - if not self.first.has_key(lhs): - self.first[lhs] = {} - - if len(rhs) == 0: - self.first[lhs][None] = 1 - continue - - sym = rhs[0] - if not self.rules.has_key(sym): - self.first[lhs][sym] = 1 - else: - union[(sym, lhs)] = 1 - changes = 1 - while changes: - changes = 0 - for src, dest in union.keys(): - destlen = len(self.first[dest]) - self.first[dest].update(self.first[src]) - if len(self.first[dest]) != destlen: - changes = 1 - - # - # An Earley parser, as per J. Earley, "An Efficient Context-Free - # Parsing Algorithm", CACM 13(2), pp. 94-102. Also J. C. Earley, - # "An Efficient Context-Free Parsing Algorithm", Ph.D. thesis, - # Carnegie-Mellon University, August 1968, p. 27. - # - - def typestring(self, token): - return None - - def error(self, token): - print "Syntax error at or near `%s' token" % token - raise SystemExit - - def parse(self, tokens): - tree = {} - tokens.append(self._EOF) - states = { 0: [ (self.startRule, 0, 0) ] } - - if self.ruleschanged: - self.makeFIRST() - - for i in xrange(len(tokens)): - states[i+1] = [] - - if states[i] == []: - break - self.buildState(tokens[i], states, i, tree) - - #_dump(tokens, states) - - if i < len(tokens)-1 or states[i+1] != [(self.startRule, 2, 0)]: - del tokens[-1] - self.error(tokens[i-1]) - rv = self.buildTree(tokens, tree, ((self.startRule, 2, 0), i+1)) - del tokens[-1] - return rv - - def buildState(self, token, states, i, tree): - needsCompletion = {} - state = states[i] - predicted = {} - - for item in state: - rule, pos, parent = item - lhs, rhs = rule - - # - # A -> a . (completer) - # - if pos == len(rhs): - if len(rhs) == 0: - needsCompletion[lhs] = (item, i) - - for pitem in states[parent]: - if pitem is item: - break - - prule, ppos, pparent = pitem - plhs, prhs = prule - - if prhs[ppos:ppos+1] == (lhs,): - new = (prule, - ppos+1, - pparent) - if new not in state: - state.append(new) - tree[(new, i)] = [(item, i)] - else: - tree[(new, i)].append((item, i)) - continue - - nextSym = rhs[pos] - - # - # A -> a . B (predictor) - # - if self.rules.has_key(nextSym): - # - # Work on completer step some more; for rules - # with empty RHS, the "parent state" is the - # current state we're adding Earley items to, - # so the Earley items the completer step needs - # may not all be present when it runs. - # - if needsCompletion.has_key(nextSym): - new = (rule, pos+1, parent) - olditem_i = needsCompletion[nextSym] - if new not in state: - state.append(new) - tree[(new, i)] = [olditem_i] - else: - tree[(new, i)].append(olditem_i) - - # - # Has this been predicted already? - # - if predicted.has_key(nextSym): - continue - predicted[nextSym] = 1 - - ttype = token is not self._EOF and \ - self.typestring(token) or \ - None - if ttype is not None: - # - # Even smarter predictor, when the - # token's type is known. The code is - # grungy, but runs pretty fast. Three - # cases are looked for: rules with - # empty RHS; first symbol on RHS is a - # terminal; first symbol on RHS is a - # nonterminal (and isn't nullable). - # - for prule in self.rules[nextSym]: - new = (prule, 0, i) - prhs = prule[1] - if len(prhs) == 0: - state.append(new) - continue - prhs0 = prhs[0] - if not self.rules.has_key(prhs0): - if prhs0 != ttype: - continue - else: - state.append(new) - continue - first = self.first[prhs0] - if not first.has_key(None) and \ - not first.has_key(ttype): - continue - state.append(new) - continue - - for prule in self.rules[nextSym]: - # - # Smarter predictor, as per Grune & - # Jacobs' _Parsing Techniques_. Not - # as good as FIRST sets though. - # - prhs = prule[1] - if len(prhs) > 0 and \ - not self.rules.has_key(prhs[0]) and \ - token != prhs[0]: - continue - state.append((prule, 0, i)) - - # - # A -> a . c (scanner) - # - elif token == nextSym: - #assert new not in states[i+1] - states[i+1].append((rule, pos+1, parent)) - - def buildTree(self, tokens, tree, root): - stack = [] - self.buildTree_r(stack, tokens, -1, tree, root) - return stack[0] - - def buildTree_r(self, stack, tokens, tokpos, tree, root): - (rule, pos, parent), state = root - - while pos > 0: - want = ((rule, pos, parent), state) - if not tree.has_key(want): - # - # Since pos > 0, it didn't come from closure, - # and if it isn't in tree[], then there must - # be a terminal symbol to the left of the dot. - # (It must be from a "scanner" step.) - # - pos = pos - 1 - state = state - 1 - stack.insert(0, tokens[tokpos]) - tokpos = tokpos - 1 - else: - # - # There's a NT to the left of the dot. - # Follow the tree pointer recursively (>1 - # tree pointers from it indicates ambiguity). - # Since the item must have come about from a - # "completer" step, the state where the item - # came from must be the parent state of the - # item the tree pointer points to. - # - children = tree[want] - if len(children) > 1: - child = self.ambiguity(children) - else: - child = children[0] - - tokpos = self.buildTree_r(stack, - tokens, tokpos, - tree, child) - pos = pos - 1 - (crule, cpos, cparent), cstate = child - state = cparent - - lhs, rhs = rule - result = self.rule2func[rule](stack[:len(rhs)]) - stack[:len(rhs)] = [result] - return tokpos - - def ambiguity(self, children): - # - # XXX - problem here and in collectRules() if the same - # rule appears in >1 method. But in that case the - # user probably gets what they deserve :-) Also - # undefined results if rules causing the ambiguity - # appear in the same method. - # - sortlist = [] - name2index = {} - for i in range(len(children)): - ((rule, pos, parent), index) = children[i] - lhs, rhs = rule - name = self.rule2name[rule] - sortlist.append((len(rhs), name)) - name2index[name] = i - sortlist.sort() - list = map(lambda (a,b): b, sortlist) - return children[name2index[self.resolve(list)]] - - def resolve(self, list): - # - # Resolve ambiguity in favor of the shortest RHS. - # Since we walk the tree from the top down, this - # should effectively resolve in favor of a "shift". - # - return list[0] - -# -# GenericASTBuilder automagically constructs a concrete/abstract syntax tree -# for a given input. The extra argument is a class (not an instance!) -# which supports the "__setslice__" and "__len__" methods. -# -# XXX - silently overrides any user code in methods. -# - -class GenericASTBuilder(GenericParser): - def __init__(self, AST, start): - GenericParser.__init__(self, start) - self.AST = AST - - def preprocess(self, rule, func): - rebind = lambda lhs, self=self: \ - lambda args, lhs=lhs, self=self: \ - self.buildASTNode(args, lhs) - lhs, rhs = rule - return rule, rebind(lhs) - - def buildASTNode(self, args, lhs): - children = [] - for arg in args: - if isinstance(arg, self.AST): - children.append(arg) - else: - children.append(self.terminal(arg)) - return self.nonterminal(lhs, children) - - def terminal(self, token): return token - - def nonterminal(self, type, args): - rv = self.AST(type) - rv[:len(args)] = args - return rv - -# -# GenericASTTraversal is a Visitor pattern according to Design Patterns. For -# each node it attempts to invoke the method n_, falling -# back onto the default() method if the n_* can't be found. The preorder -# traversal also looks for an exit hook named n__exit (no default -# routine is called if it's not found). To prematurely halt traversal -# of a subtree, call the prune() method -- this only makes sense for a -# preorder traversal. Node type is determined via the typestring() method. -# - -class GenericASTTraversalPruningException: - pass - -class GenericASTTraversal: - def __init__(self, ast): - self.ast = ast - - def typestring(self, node): - return node.type - - def prune(self): - raise GenericASTTraversalPruningException - - def preorder(self, node=None): - if node is None: - node = self.ast - - try: - name = 'n_' + self.typestring(node) - if hasattr(self, name): - func = getattr(self, name) - func(node) - else: - self.default(node) - except GenericASTTraversalPruningException: - return - - for kid in node: - self.preorder(kid) - - name = name + '_exit' - if hasattr(self, name): - func = getattr(self, name) - func(node) - - def postorder(self, node=None): - if node is None: - node = self.ast - - for kid in node: - self.postorder(kid) - - name = 'n_' + self.typestring(node) - if hasattr(self, name): - func = getattr(self, name) - func(node) - else: - self.default(node) - - - def default(self, node): - pass - -# -# GenericASTMatcher. AST nodes must have "__getitem__" and "__cmp__" -# implemented. -# -# XXX - makes assumptions about how GenericParser walks the parse tree. -# - -class GenericASTMatcher(GenericParser): - def __init__(self, start, ast): - GenericParser.__init__(self, start) - self.ast = ast - - def preprocess(self, rule, func): - rebind = lambda func, self=self: \ - lambda args, func=func, self=self: \ - self.foundMatch(args, func) - lhs, rhs = rule - rhslist = list(rhs) - rhslist.reverse() - - return (lhs, tuple(rhslist)), rebind(func) - - def foundMatch(self, args, func): - func(args[-1]) - return args[-1] - - def match_r(self, node): - self.input.insert(0, node) - children = 0 - - for child in node: - if children == 0: - self.input.insert(0, '(') - children = children + 1 - self.match_r(child) - - if children > 0: - self.input.insert(0, ')') - - def match(self, ast=None): - if ast is None: - ast = self.ast - self.input = [] - - self.match_r(ast) - self.parse(self.input) - - def resolve(self, list): - # - # Resolve ambiguity in favor of the longest RHS. - # - return list[-1] - -def _dump(tokens, states): - for i in range(len(states)): - print 'state', i - for (lhs, rhs), pos, parent in states[i]: - print '\t', lhs, '::=', - print string.join(rhs[:pos]), - print '.', - print string.join(rhs[pos:]), - print ',', parent - if i < len(tokens): - print - print 'token', str(tokens[i]) - print diff --git a/Scripts/ServerPython/python/system/sre.py b/Scripts/ServerPython/python/system/sre.py deleted file mode 100644 index 5cfb754b..00000000 --- a/Scripts/ServerPython/python/system/sre.py +++ /dev/null @@ -1,311 +0,0 @@ -# -# Secret Labs' Regular Expression Engine -# -# re-compatible interface for the sre matching engine -# -# Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. -# -# This version of the SRE library can be redistributed under CNRI's -# Python 1.6 license. For any other use, please contact Secret Labs -# AB (info@pythonware.com). -# -# Portions of this engine have been developed in cooperation with -# CNRI. Hewlett-Packard provided funding for 1.6 integration and -# other compatibility work. -# - -r"""Support for regular expressions (RE). - -This module provides regular expression matching operations similar to -those found in Perl. It supports both 8-bit and Unicode strings; both -the pattern and the strings being processed can contain null bytes and -characters outside the US ASCII range. - -Regular expressions can contain both special and ordinary characters. -Most ordinary characters, like "A", "a", or "0", are the simplest -regular expressions; they simply match themselves. You can -concatenate ordinary characters, so last matches the string 'last'. - -The special characters are: - "." Matches any character except a newline. - "^" Matches the start of the string. - "$" Matches the end of the string. - "*" Matches 0 or more (greedy) repetitions of the preceding RE. - Greedy means that it will match as many repetitions as possible. - "+" Matches 1 or more (greedy) repetitions of the preceding RE. - "?" Matches 0 or 1 (greedy) of the preceding RE. - *?,+?,?? Non-greedy versions of the previous three special characters. - {m,n} Matches from m to n repetitions of the preceding RE. - {m,n}? Non-greedy version of the above. - "\\" Either escapes special characters or signals a special sequence. - [] Indicates a set of characters. - A "^" as the first character indicates a complementing set. - "|" A|B, creates an RE that will match either A or B. - (...) Matches the RE inside the parentheses. - The contents can be retrieved or matched later in the string. - (?iLmsux) Set the I, L, M, S, U, or X flag for the RE (see below). - (?:...) Non-grouping version of regular parentheses. - (?P...) The substring matched by the group is accessible by name. - (?P=name) Matches the text matched earlier by the group named name. - (?#...) A comment; ignored. - (?=...) Matches if ... matches next, but doesn't consume the string. - (?!...) Matches if ... doesn't match next. - -The special sequences consist of "\\" and a character from the list -below. If the ordinary character is not on the list, then the -resulting RE will match the second character. - \number Matches the contents of the group of the same number. - \A Matches only at the start of the string. - \Z Matches only at the end of the string. - \b Matches the empty string, but only at the start or end of a word. - \B Matches the empty string, but not at the start or end of a word. - \d Matches any decimal digit; equivalent to the set [0-9]. - \D Matches any non-digit character; equivalent to the set [^0-9]. - \s Matches any whitespace character; equivalent to [ \t\n\r\f\v]. - \S Matches any non-whitespace character; equiv. to [^ \t\n\r\f\v]. - \w Matches any alphanumeric character; equivalent to [a-zA-Z0-9_]. - With LOCALE, it will match the set [0-9_] plus characters defined - as letters for the current locale. - \W Matches the complement of \w. - \\ Matches a literal backslash. - -This module exports the following functions: - match Match a regular expression pattern to the beginning of a string. - search Search a string for the presence of a pattern. - sub Substitute occurrences of a pattern found in a string. - subn Same as sub, but also return the number of substitutions made. - split Split a string by the occurrences of a pattern. - findall Find all occurrences of a pattern in a string. - compile Compile a pattern into a RegexObject. - purge Clear the regular expression cache. - escape Backslash all non-alphanumerics in a string. - -Some of the functions in this module takes flags as optional parameters: - I IGNORECASE Perform case-insensitive matching. - L LOCALE Make \w, \W, \b, \B, dependent on the current locale. - M MULTILINE "^" matches the beginning of lines as well as the string. - "$" matches the end of lines as well as the string. - S DOTALL "." matches any character at all, including the newline. - X VERBOSE Ignore whitespace and comments for nicer looking RE's. - U UNICODE Make \w, \W, \b, \B, dependent on the Unicode locale. - -This module also defines an exception 'error'. - -""" - -import sys -import sre_compile -import sre_parse - -# public symbols -__all__ = [ "match", "search", "sub", "subn", "split", "findall", - "compile", "purge", "template", "escape", "I", "L", "M", "S", "X", - "U", "IGNORECASE", "LOCALE", "MULTILINE", "DOTALL", "VERBOSE", - "UNICODE", "error" ] - -__version__ = "2.2.1" - -# this module works under 1.5.2 and later. don't use string methods -import string - -# flags -I = IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE # ignore case -L = LOCALE = sre_compile.SRE_FLAG_LOCALE # assume current 8-bit locale -U = UNICODE = sre_compile.SRE_FLAG_UNICODE # assume unicode locale -M = MULTILINE = sre_compile.SRE_FLAG_MULTILINE # make anchors look for newline -S = DOTALL = sre_compile.SRE_FLAG_DOTALL # make dot match newline -X = VERBOSE = sre_compile.SRE_FLAG_VERBOSE # ignore whitespace and comments - -# sre extensions (experimental, don't rely on these) -T = TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE # disable backtracking -DEBUG = sre_compile.SRE_FLAG_DEBUG # dump pattern after compilation - -# sre exception -error = sre_compile.error - -# -------------------------------------------------------------------- -# public interface - -def match(pattern, string, flags=0): - """Try to apply the pattern at the start of the string, returning - a match object, or None if no match was found.""" - return _compile(pattern, flags).match(string) - -def search(pattern, string, flags=0): - """Scan through string looking for a match to the pattern, returning - a match object, or None if no match was found.""" - return _compile(pattern, flags).search(string) - -def sub(pattern, repl, string, count=0): - """Return the string obtained by replacing the leftmost - non-overlapping occurrences of the pattern in string by the - replacement repl""" - return _compile(pattern, 0).sub(repl, string, count) - -def subn(pattern, repl, string, count=0): - """Return a 2-tuple containing (new_string, number). - new_string is the string obtained by replacing the leftmost - non-overlapping occurrences of the pattern in the source - string by the replacement repl. number is the number of - substitutions that were made.""" - return _compile(pattern, 0).subn(repl, string, count) - -def split(pattern, string, maxsplit=0): - """Split the source string by the occurrences of the pattern, - returning a list containing the resulting substrings.""" - return _compile(pattern, 0).split(string, maxsplit) - -def findall(pattern, string): - """Return a list of all non-overlapping matches in the string. - - If one or more groups are present in the pattern, return a - list of groups; this will be a list of tuples if the pattern - has more than one group. - - Empty matches are included in the result.""" - return _compile(pattern, 0).findall(string) - -if sys.hexversion >= 0x02020000: - __all__.append("finditer") - def finditer(pattern, string): - """Return an iterator over all non-overlapping matches in the - string. For each match, the iterator returns a match object. - - Empty matches are included in the result.""" - return _compile(pattern, 0).finditer(string) - -def compile(pattern, flags=0): - "Compile a regular expression pattern, returning a pattern object." - return _compile(pattern, flags) - -def purge(): - "Clear the regular expression cache" - _cache.clear() - _cache_repl.clear() - -def template(pattern, flags=0): - "Compile a template pattern, returning a pattern object" - return _compile(pattern, flags|T) - -def escape(pattern): - "Escape all non-alphanumeric characters in pattern." - s = list(pattern) - for i in range(len(pattern)): - c = pattern[i] - if not ("a" <= c <= "z" or "A" <= c <= "Z" or "0" <= c <= "9"): - if c == "\000": - s[i] = "\\000" - else: - s[i] = "\\" + c - return _join(s, pattern) - -# -------------------------------------------------------------------- -# internals - -_cache = {} -_cache_repl = {} - -_pattern_type = type(sre_compile.compile("", 0)) - -_MAXCACHE = 100 - -def _join(seq, sep): - # internal: join into string having the same type as sep - return string.join(seq, sep[:0]) - -def _compile(*key): - # internal: compile pattern - p = _cache.get(key) - if p is not None: - return p - pattern, flags = key - if type(pattern) is _pattern_type: - return pattern - if type(pattern) not in sre_compile.STRING_TYPES: - raise TypeError, "first argument must be string or compiled pattern" - try: - p = sre_compile.compile(pattern, flags) - except error, v: - raise error, v # invalid expression - if len(_cache) >= _MAXCACHE: - _cache.clear() - _cache[key] = p - return p - -def _compile_repl(*key): - # internal: compile replacement pattern - p = _cache_repl.get(key) - if p is not None: - return p - repl, pattern = key - try: - p = sre_parse.parse_template(repl, pattern) - except error, v: - raise error, v # invalid expression - if len(_cache_repl) >= _MAXCACHE: - _cache_repl.clear() - _cache_repl[key] = p - return p - -def _expand(pattern, match, template): - # internal: match.expand implementation hook - template = sre_parse.parse_template(template, pattern) - return sre_parse.expand_template(template, match) - -def _subx(pattern, template): - # internal: pattern.sub/subn implementation helper - template = _compile_repl(template, pattern) - if not template[0] and len(template[1]) == 1: - # literal replacement - return template[1][0] - def filter(match, template=template): - return sre_parse.expand_template(template, match) - return filter - -# register myself for pickling - -import copy_reg - -def _pickle(p): - return _compile, (p.pattern, p.flags) - -copy_reg.pickle(_pattern_type, _pickle, _compile) - -# -------------------------------------------------------------------- -# experimental stuff (see python-dev discussions for details) - -class Scanner: - def __init__(self, lexicon, flags=0): - from sre_constants import BRANCH, SUBPATTERN - self.lexicon = lexicon - # combine phrases into a compound pattern - p = [] - s = sre_parse.Pattern() - s.flags = flags - for phrase, action in lexicon: - p.append(sre_parse.SubPattern(s, [ - (SUBPATTERN, (len(p)+1, sre_parse.parse(phrase, flags))), - ])) - p = sre_parse.SubPattern(s, [(BRANCH, (None, p))]) - s.groups = len(p) - self.scanner = sre_compile.compile(p) - def scan(self, string): - result = [] - append = result.append - match = self.scanner.scanner(string).match - i = 0 - while 1: - m = match() - if not m: - break - j = m.end() - if i == j: - break - action = self.lexicon[m.lastindex-1][1] - if callable(action): - self.match = m - action = action(self, m.group()) - if action is not None: - append(action) - i = j - return result, string[i:] diff --git a/Scripts/ServerPython/python/system/sre_compile.py b/Scripts/ServerPython/python/system/sre_compile.py deleted file mode 100644 index 1768a504..00000000 --- a/Scripts/ServerPython/python/system/sre_compile.py +++ /dev/null @@ -1,455 +0,0 @@ -# -# Secret Labs' Regular Expression Engine -# -# convert template to internal format -# -# Copyright (c) 1997-2001 by Secret Labs AB. All rights reserved. -# -# See the sre.py file for information on usage and redistribution. -# - -"""Internal support module for sre""" - -import _sre, sys - -from sre_constants import * - -assert _sre.MAGIC == MAGIC, "SRE module mismatch" - -MAXCODE = 65535 - -def _compile(code, pattern, flags): - # internal: compile a (sub)pattern - emit = code.append - for op, av in pattern: - if op in (LITERAL, NOT_LITERAL): - if flags & SRE_FLAG_IGNORECASE: - emit(OPCODES[OP_IGNORE[op]]) - emit(_sre.getlower(av, flags)) - else: - emit(OPCODES[op]) - emit(av) - elif op is IN: - if flags & SRE_FLAG_IGNORECASE: - emit(OPCODES[OP_IGNORE[op]]) - def fixup(literal, flags=flags): - return _sre.getlower(literal, flags) - else: - emit(OPCODES[op]) - fixup = lambda x: x - skip = len(code); emit(0) - _compile_charset(av, flags, code, fixup) - code[skip] = len(code) - skip - elif op is ANY: - if flags & SRE_FLAG_DOTALL: - emit(OPCODES[ANY_ALL]) - else: - emit(OPCODES[ANY]) - elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): - if flags & SRE_FLAG_TEMPLATE: - raise error, "internal: unsupported template operator" - emit(OPCODES[REPEAT]) - skip = len(code); emit(0) - emit(av[0]) - emit(av[1]) - _compile(code, av[2], flags) - emit(OPCODES[SUCCESS]) - code[skip] = len(code) - skip - elif _simple(av) and op == MAX_REPEAT: - emit(OPCODES[REPEAT_ONE]) - skip = len(code); emit(0) - emit(av[0]) - emit(av[1]) - _compile(code, av[2], flags) - emit(OPCODES[SUCCESS]) - code[skip] = len(code) - skip - else: - emit(OPCODES[REPEAT]) - skip = len(code); emit(0) - emit(av[0]) - emit(av[1]) - _compile(code, av[2], flags) - code[skip] = len(code) - skip - if op == MAX_REPEAT: - emit(OPCODES[MAX_UNTIL]) - else: - emit(OPCODES[MIN_UNTIL]) - elif op is SUBPATTERN: - if av[0]: - emit(OPCODES[MARK]) - emit((av[0]-1)*2) - # _compile_info(code, av[1], flags) - _compile(code, av[1], flags) - if av[0]: - emit(OPCODES[MARK]) - emit((av[0]-1)*2+1) - elif op in (SUCCESS, FAILURE): - emit(OPCODES[op]) - elif op in (ASSERT, ASSERT_NOT): - emit(OPCODES[op]) - skip = len(code); emit(0) - if av[0] >= 0: - emit(0) # look ahead - else: - lo, hi = av[1].getwidth() - if lo != hi: - raise error, "look-behind requires fixed-width pattern" - emit(lo) # look behind - _compile(code, av[1], flags) - emit(OPCODES[SUCCESS]) - code[skip] = len(code) - skip - elif op is CALL: - emit(OPCODES[op]) - skip = len(code); emit(0) - _compile(code, av, flags) - emit(OPCODES[SUCCESS]) - code[skip] = len(code) - skip - elif op is AT: - emit(OPCODES[op]) - if flags & SRE_FLAG_MULTILINE: - av = AT_MULTILINE.get(av, av) - if flags & SRE_FLAG_LOCALE: - av = AT_LOCALE.get(av, av) - elif flags & SRE_FLAG_UNICODE: - av = AT_UNICODE.get(av, av) - emit(ATCODES[av]) - elif op is BRANCH: - emit(OPCODES[op]) - tail = [] - for av in av[1]: - skip = len(code); emit(0) - # _compile_info(code, av, flags) - _compile(code, av, flags) - emit(OPCODES[JUMP]) - tail.append(len(code)); emit(0) - code[skip] = len(code) - skip - emit(0) # end of branch - for tail in tail: - code[tail] = len(code) - tail - elif op is CATEGORY: - emit(OPCODES[op]) - if flags & SRE_FLAG_LOCALE: - av = CH_LOCALE[av] - elif flags & SRE_FLAG_UNICODE: - av = CH_UNICODE[av] - emit(CHCODES[av]) - elif op is GROUPREF: - if flags & SRE_FLAG_IGNORECASE: - emit(OPCODES[OP_IGNORE[op]]) - else: - emit(OPCODES[op]) - emit(av-1) - else: - raise ValueError, ("unsupported operand type", op) - -def _compile_charset(charset, flags, code, fixup=None): - # compile charset subprogram - emit = code.append - if not fixup: - fixup = lambda x: x - for op, av in _optimize_charset(charset, fixup): - emit(OPCODES[op]) - if op is NEGATE: - pass - elif op is LITERAL: - emit(fixup(av)) - elif op is RANGE: - emit(fixup(av[0])) - emit(fixup(av[1])) - elif op is CHARSET: - code.extend(av) - elif op is BIGCHARSET: - code.extend(av) - elif op is CATEGORY: - if flags & SRE_FLAG_LOCALE: - emit(CHCODES[CH_LOCALE[av]]) - elif flags & SRE_FLAG_UNICODE: - emit(CHCODES[CH_UNICODE[av]]) - else: - emit(CHCODES[av]) - else: - raise error, "internal: unsupported set operator" - emit(OPCODES[FAILURE]) - -def _optimize_charset(charset, fixup): - # internal: optimize character set - out = [] - charmap = [0]*256 - try: - for op, av in charset: - if op is NEGATE: - out.append((op, av)) - elif op is LITERAL: - charmap[fixup(av)] = 1 - elif op is RANGE: - for i in range(fixup(av[0]), fixup(av[1])+1): - charmap[i] = 1 - elif op is CATEGORY: - # XXX: could append to charmap tail - return charset # cannot compress - except IndexError: - if sys.maxunicode != 65535: - # XXX: big charsets don't work in UCS-4 builds - return charset - # character set contains unicode characters - return _optimize_unicode(charset, fixup) - # compress character map - i = p = n = 0 - runs = [] - for c in charmap: - if c: - if n == 0: - p = i - n = n + 1 - elif n: - runs.append((p, n)) - n = 0 - i = i + 1 - if n: - runs.append((p, n)) - if len(runs) <= 2: - # use literal/range - for p, n in runs: - if n == 1: - out.append((LITERAL, p)) - else: - out.append((RANGE, (p, p+n-1))) - if len(out) < len(charset): - return out - else: - # use bitmap - data = _mk_bitmap(charmap) - out.append((CHARSET, data)) - return out - return charset - -def _mk_bitmap(bits): - data = [] - m = 1; v = 0 - for c in bits: - if c: - v = v + m - m = m << 1 - if m > MAXCODE: - data.append(v) - m = 1; v = 0 - return data - -# To represent a big charset, first a bitmap of all characters in the -# set is constructed. Then, this bitmap is sliced into chunks of 256 -# characters, duplicate chunks are eliminitated, and each chunk is -# given a number. In the compiled expression, the charset is -# represented by a 16-bit word sequence, consisting of one word for -# the number of different chunks, a sequence of 256 bytes (128 words) -# of chunk numbers indexed by their original chunk position, and a -# sequence of chunks (16 words each). - -# Compression is normally good: in a typical charset, large ranges of -# Unicode will be either completely excluded (e.g. if only cyrillic -# letters are to be matched), or completely included (e.g. if large -# subranges of Kanji match). These ranges will be represented by -# chunks of all one-bits or all zero-bits. - -# Matching can be also done efficiently: the more significant byte of -# the Unicode character is an index into the chunk number, and the -# less significant byte is a bit index in the chunk (just like the -# CHARSET matching). - -def _optimize_unicode(charset, fixup): - charmap = [0]*65536 - negate = 0 - for op, av in charset: - if op is NEGATE: - negate = 1 - elif op is LITERAL: - charmap[fixup(av)] = 1 - elif op is RANGE: - for i in range(fixup(av[0]), fixup(av[1])+1): - charmap[i] = 1 - elif op is CATEGORY: - # XXX: could expand category - return charset # cannot compress - if negate: - for i in range(65536): - charmap[i] = not charmap[i] - comps = {} - mapping = [0]*256 - block = 0 - data = [] - for i in range(256): - chunk = tuple(charmap[i*256:(i+1)*256]) - new = comps.setdefault(chunk, block) - mapping[i] = new - if new == block: - block = block + 1 - data = data + _mk_bitmap(chunk) - header = [block] - assert MAXCODE == 65535 - for i in range(128): - if sys.byteorder == 'big': - header.append(256*mapping[2*i]+mapping[2*i+1]) - else: - header.append(mapping[2*i]+256*mapping[2*i+1]) - data[0:0] = header - return [(BIGCHARSET, data)] - -def _simple(av): - # check if av is a "simple" operator - lo, hi = av[2].getwidth() - if lo == 0 and hi == MAXREPEAT: - raise error, "nothing to repeat" - return lo == hi == 1 and av[2][0][0] != SUBPATTERN - -def _compile_info(code, pattern, flags): - # internal: compile an info block. in the current version, - # this contains min/max pattern width, and an optional literal - # prefix or a character map - lo, hi = pattern.getwidth() - if lo == 0: - return # not worth it - # look for a literal prefix - prefix = [] - prefix_skip = 0 - charset = [] # not used - if not (flags & SRE_FLAG_IGNORECASE): - # look for literal prefix - for op, av in pattern.data: - if op is LITERAL: - if len(prefix) == prefix_skip: - prefix_skip = prefix_skip + 1 - prefix.append(av) - elif op is SUBPATTERN and len(av[1]) == 1: - op, av = av[1][0] - if op is LITERAL: - prefix.append(av) - else: - break - else: - break - # if no prefix, look for charset prefix - if not prefix and pattern.data: - op, av = pattern.data[0] - if op is SUBPATTERN and av[1]: - op, av = av[1][0] - if op is LITERAL: - charset.append((op, av)) - elif op is BRANCH: - c = [] - for p in av[1]: - if not p: - break - op, av = p[0] - if op is LITERAL: - c.append((op, av)) - else: - break - else: - charset = c - elif op is BRANCH: - c = [] - for p in av[1]: - if not p: - break - op, av = p[0] - if op is LITERAL: - c.append((op, av)) - else: - break - else: - charset = c - elif op is IN: - charset = av -## if prefix: -## print "*** PREFIX", prefix, prefix_skip -## if charset: -## print "*** CHARSET", charset - # add an info block - emit = code.append - emit(OPCODES[INFO]) - skip = len(code); emit(0) - # literal flag - mask = 0 - if prefix: - mask = SRE_INFO_PREFIX - if len(prefix) == prefix_skip == len(pattern.data): - mask = mask + SRE_INFO_LITERAL - elif charset: - mask = mask + SRE_INFO_CHARSET - emit(mask) - # pattern length - if lo < MAXCODE: - emit(lo) - else: - emit(MAXCODE) - prefix = prefix[:MAXCODE] - if hi < MAXCODE: - emit(hi) - else: - emit(0) - # add literal prefix - if prefix: - emit(len(prefix)) # length - emit(prefix_skip) # skip - code.extend(prefix) - # generate overlap table - table = [-1] + ([0]*len(prefix)) - for i in range(len(prefix)): - table[i+1] = table[i]+1 - while table[i+1] > 0 and prefix[i] != prefix[table[i+1]-1]: - table[i+1] = table[table[i+1]-1]+1 - code.extend(table[1:]) # don't store first entry - elif charset: - _compile_charset(charset, 0, code) - code[skip] = len(code) - skip - -STRING_TYPES = [type("")] - -try: - STRING_TYPES.append(type(unicode(""))) -except NameError: - pass - -def _code(p, flags): - - flags = p.pattern.flags | flags - code = [] - - # compile info block - _compile_info(code, p, flags) - - # compile the pattern - _compile(code, p.data, flags) - - code.append(OPCODES[SUCCESS]) - - return code - -def compile(p, flags=0): - # internal: convert pattern list to internal format - - if type(p) in STRING_TYPES: - import sre_parse - pattern = p - p = sre_parse.parse(p, flags) - else: - pattern = None - - code = _code(p, flags) - - # print code - - # XXX: get rid of this limitation! - assert p.pattern.groups <= 100,\ - "sorry, but this version only supports 100 named groups" - - # map in either direction - groupindex = p.pattern.groupdict - indexgroup = [None] * p.pattern.groups - for k, i in groupindex.items(): - indexgroup[i] = k - - return _sre.compile( - pattern, flags, code, - p.pattern.groups-1, - groupindex, indexgroup - ) diff --git a/Scripts/ServerPython/python/system/sre_constants.py b/Scripts/ServerPython/python/system/sre_constants.py deleted file mode 100644 index 1155f355..00000000 --- a/Scripts/ServerPython/python/system/sre_constants.py +++ /dev/null @@ -1,259 +0,0 @@ -# -# Secret Labs' Regular Expression Engine -# -# various symbols used by the regular expression engine. -# run this script to update the _sre include files! -# -# Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. -# -# See the sre.py file for information on usage and redistribution. -# - -"""Internal support module for sre""" - -# update when constants are added or removed - -MAGIC = 20010701 - -# max code word in this release - -MAXREPEAT = 65535 - -# SRE standard exception (access as sre.error) -# should this really be here? - -class error(Exception): - pass - -# operators - -FAILURE = "failure" -SUCCESS = "success" - -ANY = "any" -ANY_ALL = "any_all" -ASSERT = "assert" -ASSERT_NOT = "assert_not" -AT = "at" -BIGCHARSET = "bigcharset" -BRANCH = "branch" -CALL = "call" -CATEGORY = "category" -CHARSET = "charset" -GROUPREF = "groupref" -GROUPREF_IGNORE = "groupref_ignore" -IN = "in" -IN_IGNORE = "in_ignore" -INFO = "info" -JUMP = "jump" -LITERAL = "literal" -LITERAL_IGNORE = "literal_ignore" -MARK = "mark" -MAX_REPEAT = "max_repeat" -MAX_UNTIL = "max_until" -MIN_REPEAT = "min_repeat" -MIN_UNTIL = "min_until" -NEGATE = "negate" -NOT_LITERAL = "not_literal" -NOT_LITERAL_IGNORE = "not_literal_ignore" -RANGE = "range" -REPEAT = "repeat" -REPEAT_ONE = "repeat_one" -SUBPATTERN = "subpattern" - -# positions -AT_BEGINNING = "at_beginning" -AT_BEGINNING_LINE = "at_beginning_line" -AT_BEGINNING_STRING = "at_beginning_string" -AT_BOUNDARY = "at_boundary" -AT_NON_BOUNDARY = "at_non_boundary" -AT_END = "at_end" -AT_END_LINE = "at_end_line" -AT_END_STRING = "at_end_string" -AT_LOC_BOUNDARY = "at_loc_boundary" -AT_LOC_NON_BOUNDARY = "at_loc_non_boundary" -AT_UNI_BOUNDARY = "at_uni_boundary" -AT_UNI_NON_BOUNDARY = "at_uni_non_boundary" - -# categories -CATEGORY_DIGIT = "category_digit" -CATEGORY_NOT_DIGIT = "category_not_digit" -CATEGORY_SPACE = "category_space" -CATEGORY_NOT_SPACE = "category_not_space" -CATEGORY_WORD = "category_word" -CATEGORY_NOT_WORD = "category_not_word" -CATEGORY_LINEBREAK = "category_linebreak" -CATEGORY_NOT_LINEBREAK = "category_not_linebreak" -CATEGORY_LOC_WORD = "category_loc_word" -CATEGORY_LOC_NOT_WORD = "category_loc_not_word" -CATEGORY_UNI_DIGIT = "category_uni_digit" -CATEGORY_UNI_NOT_DIGIT = "category_uni_not_digit" -CATEGORY_UNI_SPACE = "category_uni_space" -CATEGORY_UNI_NOT_SPACE = "category_uni_not_space" -CATEGORY_UNI_WORD = "category_uni_word" -CATEGORY_UNI_NOT_WORD = "category_uni_not_word" -CATEGORY_UNI_LINEBREAK = "category_uni_linebreak" -CATEGORY_UNI_NOT_LINEBREAK = "category_uni_not_linebreak" - -OPCODES = [ - - # failure=0 success=1 (just because it looks better that way :-) - FAILURE, SUCCESS, - - ANY, ANY_ALL, - ASSERT, ASSERT_NOT, - AT, - BRANCH, - CALL, - CATEGORY, - CHARSET, BIGCHARSET, - GROUPREF, GROUPREF_IGNORE, - IN, IN_IGNORE, - INFO, - JUMP, - LITERAL, LITERAL_IGNORE, - MARK, - MAX_UNTIL, - MIN_UNTIL, - NOT_LITERAL, NOT_LITERAL_IGNORE, - NEGATE, - RANGE, - REPEAT, - REPEAT_ONE, - SUBPATTERN - -] - -ATCODES = [ - AT_BEGINNING, AT_BEGINNING_LINE, AT_BEGINNING_STRING, AT_BOUNDARY, - AT_NON_BOUNDARY, AT_END, AT_END_LINE, AT_END_STRING, - AT_LOC_BOUNDARY, AT_LOC_NON_BOUNDARY, AT_UNI_BOUNDARY, - AT_UNI_NON_BOUNDARY -] - -CHCODES = [ - CATEGORY_DIGIT, CATEGORY_NOT_DIGIT, CATEGORY_SPACE, - CATEGORY_NOT_SPACE, CATEGORY_WORD, CATEGORY_NOT_WORD, - CATEGORY_LINEBREAK, CATEGORY_NOT_LINEBREAK, CATEGORY_LOC_WORD, - CATEGORY_LOC_NOT_WORD, CATEGORY_UNI_DIGIT, CATEGORY_UNI_NOT_DIGIT, - CATEGORY_UNI_SPACE, CATEGORY_UNI_NOT_SPACE, CATEGORY_UNI_WORD, - CATEGORY_UNI_NOT_WORD, CATEGORY_UNI_LINEBREAK, - CATEGORY_UNI_NOT_LINEBREAK -] - -def makedict(list): - d = {} - i = 0 - for item in list: - d[item] = i - i = i + 1 - return d - -OPCODES = makedict(OPCODES) -ATCODES = makedict(ATCODES) -CHCODES = makedict(CHCODES) - -# replacement operations for "ignore case" mode -OP_IGNORE = { - GROUPREF: GROUPREF_IGNORE, - IN: IN_IGNORE, - LITERAL: LITERAL_IGNORE, - NOT_LITERAL: NOT_LITERAL_IGNORE -} - -AT_MULTILINE = { - AT_BEGINNING: AT_BEGINNING_LINE, - AT_END: AT_END_LINE -} - -AT_LOCALE = { - AT_BOUNDARY: AT_LOC_BOUNDARY, - AT_NON_BOUNDARY: AT_LOC_NON_BOUNDARY -} - -AT_UNICODE = { - AT_BOUNDARY: AT_UNI_BOUNDARY, - AT_NON_BOUNDARY: AT_UNI_NON_BOUNDARY -} - -CH_LOCALE = { - CATEGORY_DIGIT: CATEGORY_DIGIT, - CATEGORY_NOT_DIGIT: CATEGORY_NOT_DIGIT, - CATEGORY_SPACE: CATEGORY_SPACE, - CATEGORY_NOT_SPACE: CATEGORY_NOT_SPACE, - CATEGORY_WORD: CATEGORY_LOC_WORD, - CATEGORY_NOT_WORD: CATEGORY_LOC_NOT_WORD, - CATEGORY_LINEBREAK: CATEGORY_LINEBREAK, - CATEGORY_NOT_LINEBREAK: CATEGORY_NOT_LINEBREAK -} - -CH_UNICODE = { - CATEGORY_DIGIT: CATEGORY_UNI_DIGIT, - CATEGORY_NOT_DIGIT: CATEGORY_UNI_NOT_DIGIT, - CATEGORY_SPACE: CATEGORY_UNI_SPACE, - CATEGORY_NOT_SPACE: CATEGORY_UNI_NOT_SPACE, - CATEGORY_WORD: CATEGORY_UNI_WORD, - CATEGORY_NOT_WORD: CATEGORY_UNI_NOT_WORD, - CATEGORY_LINEBREAK: CATEGORY_UNI_LINEBREAK, - CATEGORY_NOT_LINEBREAK: CATEGORY_UNI_NOT_LINEBREAK -} - -# flags -SRE_FLAG_TEMPLATE = 1 # template mode (disable backtracking) -SRE_FLAG_IGNORECASE = 2 # case insensitive -SRE_FLAG_LOCALE = 4 # honour system locale -SRE_FLAG_MULTILINE = 8 # treat target as multiline string -SRE_FLAG_DOTALL = 16 # treat target as a single string -SRE_FLAG_UNICODE = 32 # use unicode locale -SRE_FLAG_VERBOSE = 64 # ignore whitespace and comments -SRE_FLAG_DEBUG = 128 # debugging - -# flags for INFO primitive -SRE_INFO_PREFIX = 1 # has prefix -SRE_INFO_LITERAL = 2 # entire pattern is literal (given by prefix) -SRE_INFO_CHARSET = 4 # pattern starts with character from given set - -if __name__ == "__main__": - import string - def dump(f, d, prefix): - items = d.items() - items.sort(lambda a, b: cmp(a[1], b[1])) - for k, v in items: - f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) - f = open("sre_constants.h", "w") - f.write("""\ -/* - * Secret Labs' Regular Expression Engine - * - * regular expression matching engine - * - * NOTE: This file is generated by sre_constants.py. If you need - * to change anything in here, edit sre_constants.py and run it. - * - * Copyright (c) 1997-2001 by Secret Labs AB. All rights reserved. - * - * See the _sre.c file for information on usage and redistribution. - */ - -""") - - f.write("#define SRE_MAGIC %d\n" % MAGIC) - - dump(f, OPCODES, "SRE_OP") - dump(f, ATCODES, "SRE") - dump(f, CHCODES, "SRE") - - f.write("#define SRE_FLAG_TEMPLATE %d\n" % SRE_FLAG_TEMPLATE) - f.write("#define SRE_FLAG_IGNORECASE %d\n" % SRE_FLAG_IGNORECASE) - f.write("#define SRE_FLAG_LOCALE %d\n" % SRE_FLAG_LOCALE) - f.write("#define SRE_FLAG_MULTILINE %d\n" % SRE_FLAG_MULTILINE) - f.write("#define SRE_FLAG_DOTALL %d\n" % SRE_FLAG_DOTALL) - f.write("#define SRE_FLAG_UNICODE %d\n" % SRE_FLAG_UNICODE) - f.write("#define SRE_FLAG_VERBOSE %d\n" % SRE_FLAG_VERBOSE) - - f.write("#define SRE_INFO_PREFIX %d\n" % SRE_INFO_PREFIX) - f.write("#define SRE_INFO_LITERAL %d\n" % SRE_INFO_LITERAL) - f.write("#define SRE_INFO_CHARSET %d\n" % SRE_INFO_CHARSET) - - f.close() - print "done" diff --git a/Scripts/ServerPython/python/system/sre_parse.py b/Scripts/ServerPython/python/system/sre_parse.py deleted file mode 100644 index 931a0317..00000000 --- a/Scripts/ServerPython/python/system/sre_parse.py +++ /dev/null @@ -1,738 +0,0 @@ -# -# Secret Labs' Regular Expression Engine -# -# convert re-style regular expression to sre pattern -# -# Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. -# -# See the sre.py file for information on usage and redistribution. -# - -"""Internal support module for sre""" - -# XXX: show string offset and offending character for all errors - -# this module works under 1.5.2 and later. don't use string methods -import string, sys - -from sre_constants import * - -SPECIAL_CHARS = ".\\[{()*+?^$|" -REPEAT_CHARS = "*+?{" - -DIGITS = tuple("0123456789") - -OCTDIGITS = tuple("01234567") -HEXDIGITS = tuple("0123456789abcdefABCDEF") - -WHITESPACE = tuple(" \t\n\r\v\f") - -ESCAPES = { - r"\a": (LITERAL, ord("\a")), - r"\b": (LITERAL, ord("\b")), - r"\f": (LITERAL, ord("\f")), - r"\n": (LITERAL, ord("\n")), - r"\r": (LITERAL, ord("\r")), - r"\t": (LITERAL, ord("\t")), - r"\v": (LITERAL, ord("\v")), - r"\\": (LITERAL, ord("\\")) -} - -CATEGORIES = { - r"\A": (AT, AT_BEGINNING_STRING), # start of string - r"\b": (AT, AT_BOUNDARY), - r"\B": (AT, AT_NON_BOUNDARY), - r"\d": (IN, [(CATEGORY, CATEGORY_DIGIT)]), - r"\D": (IN, [(CATEGORY, CATEGORY_NOT_DIGIT)]), - r"\s": (IN, [(CATEGORY, CATEGORY_SPACE)]), - r"\S": (IN, [(CATEGORY, CATEGORY_NOT_SPACE)]), - r"\w": (IN, [(CATEGORY, CATEGORY_WORD)]), - r"\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]), - r"\Z": (AT, AT_END_STRING), # end of string -} - -FLAGS = { - # standard flags - "i": SRE_FLAG_IGNORECASE, - "L": SRE_FLAG_LOCALE, - "m": SRE_FLAG_MULTILINE, - "s": SRE_FLAG_DOTALL, - "x": SRE_FLAG_VERBOSE, - # extensions - "t": SRE_FLAG_TEMPLATE, - "u": SRE_FLAG_UNICODE, -} - -# figure out best way to convert hex/octal numbers to integers -try: - int("10", 8) - atoi = int # 2.0 and later -except TypeError: - atoi = string.atoi # 1.5.2 - -class Pattern: - # master pattern object. keeps track of global attributes - def __init__(self): - self.flags = 0 - self.open = [] - self.groups = 1 - self.groupdict = {} - def opengroup(self, name=None): - gid = self.groups - self.groups = gid + 1 - if name: - ogid = self.groupdict.get(name, None) - if ogid is not None: - raise error, ("redefinition of group name %s as group %d; " - "was group %d" % (repr(name), gid, ogid)) - self.groupdict[name] = gid - self.open.append(gid) - return gid - def closegroup(self, gid): - self.open.remove(gid) - def checkgroup(self, gid): - return gid < self.groups and gid not in self.open - -class SubPattern: - # a subpattern, in intermediate form - def __init__(self, pattern, data=None): - self.pattern = pattern - if not data: - data = [] - self.data = data - self.width = None - def dump(self, level=0): - nl = 1 - for op, av in self.data: - print level*" " + op,; nl = 0 - if op == "in": - # member sublanguage - print; nl = 1 - for op, a in av: - print (level+1)*" " + op, a - elif op == "branch": - print; nl = 1 - i = 0 - for a in av[1]: - if i > 0: - print level*" " + "or" - a.dump(level+1); nl = 1 - i = i + 1 - elif type(av) in (type(()), type([])): - for a in av: - if isinstance(a, SubPattern): - if not nl: print - a.dump(level+1); nl = 1 - else: - print a, ; nl = 0 - else: - print av, ; nl = 0 - if not nl: print - def __repr__(self): - return repr(self.data) - def __len__(self): - return len(self.data) - def __delitem__(self, index): - del self.data[index] - def __getitem__(self, index): - return self.data[index] - def __setitem__(self, index, code): - self.data[index] = code - def __getslice__(self, start, stop): - return SubPattern(self.pattern, self.data[start:stop]) - def insert(self, index, code): - self.data.insert(index, code) - def append(self, code): - self.data.append(code) - def getwidth(self): - # determine the width (min, max) for this subpattern - if self.width: - return self.width - lo = hi = 0L - for op, av in self.data: - if op is BRANCH: - i = sys.maxint - j = 0 - for av in av[1]: - l, h = av.getwidth() - i = min(i, l) - j = max(j, h) - lo = lo + i - hi = hi + j - elif op is CALL: - i, j = av.getwidth() - lo = lo + i - hi = hi + j - elif op is SUBPATTERN: - i, j = av[1].getwidth() - lo = lo + i - hi = hi + j - elif op in (MIN_REPEAT, MAX_REPEAT): - i, j = av[2].getwidth() - lo = lo + long(i) * av[0] - hi = hi + long(j) * av[1] - elif op in (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY): - lo = lo + 1 - hi = hi + 1 - elif op == SUCCESS: - break - self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) - return self.width - -class Tokenizer: - def __init__(self, string): - self.string = string - self.index = 0 - self.__next() - def __next(self): - if self.index >= len(self.string): - self.next = None - return - char = self.string[self.index] - if char[0] == "\\": - try: - c = self.string[self.index + 1] - except IndexError: - raise error, "bogus escape (end of line)" - char = char + c - self.index = self.index + len(char) - self.next = char - def match(self, char, skip=1): - if char == self.next: - if skip: - self.__next() - return 1 - return 0 - def get(self): - this = self.next - self.__next() - return this - def tell(self): - return self.index, self.next - def seek(self, index): - self.index, self.next = index - -def isident(char): - return "a" <= char <= "z" or "A" <= char <= "Z" or char == "_" - -def isdigit(char): - return "0" <= char <= "9" - -def isname(name): - # check that group name is a valid string - if not isident(name[0]): - return 0 - for char in name: - if not isident(char) and not isdigit(char): - return 0 - return 1 - -def _group(escape, groups): - # check if the escape string represents a valid group - try: - gid = atoi(escape[1:]) - if gid and gid < groups: - return gid - except ValueError: - pass - return None # not a valid group - -def _class_escape(source, escape): - # handle escape code inside character class - code = ESCAPES.get(escape) - if code: - return code - code = CATEGORIES.get(escape) - if code: - return code - try: - if escape[1:2] == "x": - # hexadecimal escape (exactly two digits) - while source.next in HEXDIGITS and len(escape) < 4: - escape = escape + source.get() - escape = escape[2:] - if len(escape) != 2: - raise error, "bogus escape: %s" % repr("\\" + escape) - return LITERAL, atoi(escape, 16) & 0xff - elif str(escape[1:2]) in OCTDIGITS: - # octal escape (up to three digits) - while source.next in OCTDIGITS and len(escape) < 5: - escape = escape + source.get() - escape = escape[1:] - return LITERAL, atoi(escape, 8) & 0xff - if len(escape) == 2: - return LITERAL, ord(escape[1]) - except ValueError: - pass - raise error, "bogus escape: %s" % repr(escape) - -def _escape(source, escape, state): - # handle escape code in expression - code = CATEGORIES.get(escape) - if code: - return code - code = ESCAPES.get(escape) - if code: - return code - try: - if escape[1:2] == "x": - # hexadecimal escape - while source.next in HEXDIGITS and len(escape) < 4: - escape = escape + source.get() - if len(escape) != 4: - raise ValueError - return LITERAL, atoi(escape[2:], 16) & 0xff - elif escape[1:2] == "0": - # octal escape - while source.next in OCTDIGITS and len(escape) < 4: - escape = escape + source.get() - return LITERAL, atoi(escape[1:], 8) & 0xff - elif escape[1:2] in DIGITS: - # octal escape *or* decimal group reference (sigh) - here = source.tell() - if source.next in DIGITS: - escape = escape + source.get() - if (escape[1] in OCTDIGITS and escape[2] in OCTDIGITS and - source.next in OCTDIGITS): - # got three octal digits; this is an octal escape - escape = escape + source.get() - return LITERAL, atoi(escape[1:], 8) & 0xff - # got at least one decimal digit; this is a group reference - group = _group(escape, state.groups) - if group: - if not state.checkgroup(group): - raise error, "cannot refer to open group" - return GROUPREF, group - raise ValueError - if len(escape) == 2: - return LITERAL, ord(escape[1]) - except ValueError: - pass - raise error, "bogus escape: %s" % repr(escape) - -def _parse_sub(source, state, nested=1): - # parse an alternation: a|b|c - - items = [] - while 1: - items.append(_parse(source, state)) - if source.match("|"): - continue - if not nested: - break - if not source.next or source.match(")", 0): - break - else: - raise error, "pattern not properly closed" - - if len(items) == 1: - return items[0] - - subpattern = SubPattern(state) - - # check if all items share a common prefix - while 1: - prefix = None - for item in items: - if not item: - break - if prefix is None: - prefix = item[0] - elif item[0] != prefix: - break - else: - # all subitems start with a common "prefix". - # move it out of the branch - for item in items: - del item[0] - subpattern.append(prefix) - continue # check next one - break - - # check if the branch can be replaced by a character set - for item in items: - if len(item) != 1 or item[0][0] != LITERAL: - break - else: - # we can store this as a character set instead of a - # branch (the compiler may optimize this even more) - set = [] - for item in items: - set.append(item[0]) - subpattern.append((IN, set)) - return subpattern - - subpattern.append((BRANCH, (None, items))) - return subpattern - -def _parse(source, state): - # parse a simple pattern - - subpattern = SubPattern(state) - - while 1: - - if source.next in ("|", ")"): - break # end of subpattern - this = source.get() - if this is None: - break # end of pattern - - if state.flags & SRE_FLAG_VERBOSE: - # skip whitespace and comments - if this in WHITESPACE: - continue - if this == "#": - while 1: - this = source.get() - if this in (None, "\n"): - break - continue - - if this and this[0] not in SPECIAL_CHARS: - subpattern.append((LITERAL, ord(this))) - - elif this == "[": - # character set - set = [] -## if source.match(":"): -## pass # handle character classes - if source.match("^"): - set.append((NEGATE, None)) - # check remaining characters - start = set[:] - while 1: - this = source.get() - if this == "]" and set != start: - break - elif this and this[0] == "\\": - code1 = _class_escape(source, this) - elif this: - code1 = LITERAL, ord(this) - else: - raise error, "unexpected end of regular expression" - if source.match("-"): - # potential range - this = source.get() - if this == "]": - if code1[0] is IN: - code1 = code1[1][0] - set.append(code1) - set.append((LITERAL, ord("-"))) - break - else: - if this[0] == "\\": - code2 = _class_escape(source, this) - else: - code2 = LITERAL, ord(this) - if code1[0] != LITERAL or code2[0] != LITERAL: - raise error, "bad character range" - lo = code1[1] - hi = code2[1] - if hi < lo: - raise error, "bad character range" - set.append((RANGE, (lo, hi))) - else: - if code1[0] is IN: - code1 = code1[1][0] - set.append(code1) - - # XXX: should move set optimization to compiler! - if len(set)==1 and set[0][0] is LITERAL: - subpattern.append(set[0]) # optimization - elif len(set)==2 and set[0][0] is NEGATE and set[1][0] is LITERAL: - subpattern.append((NOT_LITERAL, set[1][1])) # optimization - else: - # XXX: should add charmap optimization here - subpattern.append((IN, set)) - - elif this and this[0] in REPEAT_CHARS: - # repeat previous item - if this == "?": - min, max = 0, 1 - elif this == "*": - min, max = 0, MAXREPEAT - - elif this == "+": - min, max = 1, MAXREPEAT - elif this == "{": - here = source.tell() - min, max = 0, MAXREPEAT - lo = hi = "" - while source.next in DIGITS: - lo = lo + source.get() - if source.match(","): - while source.next in DIGITS: - hi = hi + source.get() - else: - hi = lo - if not source.match("}"): - subpattern.append((LITERAL, ord(this))) - source.seek(here) - continue - if lo: - min = atoi(lo) - if hi: - max = atoi(hi) - if max < min: - raise error, "bad repeat interval" - else: - raise error, "not supported" - # figure out which item to repeat - if subpattern: - item = subpattern[-1:] - else: - item = None - if not item or (len(item) == 1 and item[0][0] == AT): - raise error, "nothing to repeat" - if item[0][0] in (MIN_REPEAT, MAX_REPEAT): - raise error, "multiple repeat" - if source.match("?"): - subpattern[-1] = (MIN_REPEAT, (min, max, item)) - else: - subpattern[-1] = (MAX_REPEAT, (min, max, item)) - - elif this == ".": - subpattern.append((ANY, None)) - - elif this == "(": - group = 1 - name = None - if source.match("?"): - group = 0 - # options - if source.match("P"): - # python extensions - if source.match("<"): - # named group: skip forward to end of name - name = "" - while 1: - char = source.get() - if char is None: - raise error, "unterminated name" - if char == ">": - break - name = name + char - group = 1 - if not isname(name): - raise error, "bad character in group name" - elif source.match("="): - # named backreference - name = "" - while 1: - char = source.get() - if char is None: - raise error, "unterminated name" - if char == ")": - break - name = name + char - if not isname(name): - raise error, "bad character in group name" - gid = state.groupdict.get(name) - if gid is None: - raise error, "unknown group name" - subpattern.append((GROUPREF, gid)) - continue - else: - char = source.get() - if char is None: - raise error, "unexpected end of pattern" - raise error, "unknown specifier: ?P%s" % char - elif source.match(":"): - # non-capturing group - group = 2 - elif source.match("#"): - # comment - while 1: - if source.next is None or source.next == ")": - break - source.get() - if not source.match(")"): - raise error, "unbalanced parenthesis" - continue - elif source.next in ("=", "!", "<"): - # lookahead assertions - char = source.get() - dir = 1 - if char == "<": - if source.next not in ("=", "!"): - raise error, "syntax error" - dir = -1 # lookbehind - char = source.get() - p = _parse_sub(source, state) - if not source.match(")"): - raise error, "unbalanced parenthesis" - if char == "=": - subpattern.append((ASSERT, (dir, p))) - else: - subpattern.append((ASSERT_NOT, (dir, p))) - continue - else: - # flags - if not FLAGS.has_key(source.next): - raise error, "unexpected end of pattern" - while FLAGS.has_key(source.next): - state.flags = state.flags | FLAGS[source.get()] - if group: - # parse group contents - if group == 2: - # anonymous group - group = None - else: - group = state.opengroup(name) - p = _parse_sub(source, state) - if not source.match(")"): - raise error, "unbalanced parenthesis" - if group is not None: - state.closegroup(group) - subpattern.append((SUBPATTERN, (group, p))) - else: - while 1: - char = source.get() - if char is None: - raise error, "unexpected end of pattern" - if char == ")": - break - raise error, "unknown extension" - - elif this == "^": - subpattern.append((AT, AT_BEGINNING)) - - elif this == "$": - subpattern.append((AT, AT_END)) - - elif this and this[0] == "\\": - code = _escape(source, this, state) - subpattern.append(code) - - else: - raise error, "parser error" - - return subpattern - -def parse(str, flags=0, pattern=None): - # parse 're' pattern into list of (opcode, argument) tuples - - source = Tokenizer(str) - - if pattern is None: - pattern = Pattern() - pattern.flags = flags - pattern.str = str - - p = _parse_sub(source, pattern, 0) - - tail = source.get() - if tail == ")": - raise error, "unbalanced parenthesis" - elif tail: - raise error, "bogus characters at end of regular expression" - - if flags & SRE_FLAG_DEBUG: - p.dump() - - if not (flags & SRE_FLAG_VERBOSE) and p.pattern.flags & SRE_FLAG_VERBOSE: - # the VERBOSE flag was switched on inside the pattern. to be - # on the safe side, we'll parse the whole thing again... - return parse(str, p.pattern.flags) - - return p - -def parse_template(source, pattern): - # parse 're' replacement string into list of literals and - # group references - s = Tokenizer(source) - p = [] - a = p.append - def literal(literal, p=p): - if p and p[-1][0] is LITERAL: - p[-1] = LITERAL, p[-1][1] + literal - else: - p.append((LITERAL, literal)) - sep = source[:0] - if type(sep) is type(""): - makechar = chr - else: - makechar = unichr - while 1: - this = s.get() - if this is None: - break # end of replacement string - if this and this[0] == "\\": - # group - if this == "\\g": - name = "" - if s.match("<"): - while 1: - char = s.get() - if char is None: - raise error, "unterminated group name" - if char == ">": - break - name = name + char - if not name: - raise error, "bad group name" - try: - index = atoi(name) - except ValueError: - if not isname(name): - raise error, "bad character in group name" - try: - index = pattern.groupindex[name] - except KeyError: - raise IndexError, "unknown group name" - a((MARK, index)) - elif len(this) > 1 and this[1] in DIGITS: - code = None - while 1: - group = _group(this, pattern.groups+1) - if group: - if (s.next not in DIGITS or - not _group(this + s.next, pattern.groups+1)): - code = MARK, group - break - elif s.next in OCTDIGITS: - this = this + s.get() - else: - break - if not code: - this = this[1:] - code = LITERAL, makechar(atoi(this[-6:], 8) & 0xff) - if code[0] is LITERAL: - literal(code[1]) - else: - a(code) - else: - try: - this = makechar(ESCAPES[this][1]) - except KeyError: - pass - literal(this) - else: - literal(this) - # convert template to groups and literals lists - i = 0 - groups = [] - literals = [] - for c, s in p: - if c is MARK: - groups.append((i, s)) - literals.append(None) - else: - literals.append(s) - i = i + 1 - return groups, literals - -def expand_template(template, match): - g = match.group - sep = match.string[:0] - groups, literals = template - literals = literals[:] - try: - for index, group in groups: - literals[index] = s = g(group) - if s is None: - raise IndexError - except IndexError: - raise error, "empty group" - return string.join(literals, sep) diff --git a/Scripts/ServerPython/python/system/stat.py b/Scripts/ServerPython/python/system/stat.py deleted file mode 100644 index 8bccf98e..00000000 --- a/Scripts/ServerPython/python/system/stat.py +++ /dev/null @@ -1,86 +0,0 @@ -"""Constants/functions for interpreting results of os.stat() and os.lstat(). - -Suggested usage: from stat import * -""" - -# XXX Strictly spoken, this module may have to be adapted for each POSIX -# implementation; in practice, however, the numeric constants used by -# stat() are almost universal (even for stat() emulations on non-UNIX -# systems like MS-DOS). - -# Indices for stat struct members in tuple returned by os.stat() - -ST_MODE = 0 -ST_INO = 1 -ST_DEV = 2 -ST_NLINK = 3 -ST_UID = 4 -ST_GID = 5 -ST_SIZE = 6 -ST_ATIME = 7 -ST_MTIME = 8 -ST_CTIME = 9 - -# Extract bits from the mode - -def S_IMODE(mode): - return mode & 07777 - -def S_IFMT(mode): - return mode & 0170000 - -# Constants used as S_IFMT() for various file types -# (not all are implemented on all systems) - -S_IFDIR = 0040000 -S_IFCHR = 0020000 -S_IFBLK = 0060000 -S_IFREG = 0100000 -S_IFIFO = 0010000 -S_IFLNK = 0120000 -S_IFSOCK = 0140000 - -# Functions to test for each file type - -def S_ISDIR(mode): - return S_IFMT(mode) == S_IFDIR - -def S_ISCHR(mode): - return S_IFMT(mode) == S_IFCHR - -def S_ISBLK(mode): - return S_IFMT(mode) == S_IFBLK - -def S_ISREG(mode): - return S_IFMT(mode) == S_IFREG - -def S_ISFIFO(mode): - return S_IFMT(mode) == S_IFIFO - -def S_ISLNK(mode): - return S_IFMT(mode) == S_IFLNK - -def S_ISSOCK(mode): - return S_IFMT(mode) == S_IFSOCK - -# Names for permission bits - -S_ISUID = 04000 -S_ISGID = 02000 -S_ENFMT = S_ISGID -S_ISVTX = 01000 -S_IREAD = 00400 -S_IWRITE = 00200 -S_IEXEC = 00100 -S_IRWXU = 00700 -S_IRUSR = 00400 -S_IWUSR = 00200 -S_IXUSR = 00100 -S_IRWXG = 00070 -S_IRGRP = 00040 -S_IWGRP = 00020 -S_IXGRP = 00010 -S_IRWXO = 00007 -S_IROTH = 00004 -S_IWOTH = 00002 -S_IXOTH = 00001 diff --git a/Scripts/ServerPython/python/system/statcache.py b/Scripts/ServerPython/python/system/statcache.py deleted file mode 100644 index 6d62ac34..00000000 --- a/Scripts/ServerPython/python/system/statcache.py +++ /dev/null @@ -1,77 +0,0 @@ -"""Maintain a cache of stat() information on files. - -There are functions to reset the cache or to selectively remove items. -""" - -import os as _os -from stat import * - -__all__ = ["stat","reset","forget","forget_prefix","forget_dir", - "forget_except_prefix","isdir"] - -# The cache. Keys are pathnames, values are os.stat outcomes. -# Remember that multiple threads may be calling this! So, e.g., that -# cache.has_key(path) returns 1 doesn't mean the cache will still contain -# path on the next line. Code defensively. - -cache = {} - -def stat(path): - """Stat a file, possibly out of the cache.""" - ret = cache.get(path, None) - if ret is None: - cache[path] = ret = _os.stat(path) - return ret - -def reset(): - """Clear the cache.""" - cache.clear() - -# For thread saftey, always use forget() internally too. -def forget(path): - """Remove a given item from the cache, if it exists.""" - try: - del cache[path] - except KeyError: - pass - -def forget_prefix(prefix): - """Remove all pathnames with a given prefix.""" - for path in cache.keys(): - if path.startswith(prefix): - forget(path) - -def forget_dir(prefix): - """Forget a directory and all entries except for entries in subdirs.""" - - # Remove trailing separator, if any. This is tricky to do in a - # x-platform way. For example, Windows accepts both / and \ as - # separators, and if there's nothing *but* a separator we want to - # preserve that this is the root. Only os.path has the platform - # knowledge we need. - from os.path import split, join - prefix = split(join(prefix, "xxx"))[0] - forget(prefix) - for path in cache.keys(): - # First check that the path at least starts with the prefix, so - # that when it doesn't we can avoid paying for split(). - if path.startswith(prefix) and split(path)[0] == prefix: - forget(path) - -def forget_except_prefix(prefix): - """Remove all pathnames except with a given prefix. - - Normally used with prefix = '/' after a chdir(). - """ - - for path in cache.keys(): - if not path.startswith(prefix): - forget(path) - -def isdir(path): - """Return 1 if directory, else 0.""" - try: - st = stat(path) - except _os.error: - return 0 - return S_ISDIR(st[ST_MODE]) diff --git a/Scripts/ServerPython/python/system/string.py b/Scripts/ServerPython/python/system/string.py deleted file mode 100644 index f25d94b8..00000000 --- a/Scripts/ServerPython/python/system/string.py +++ /dev/null @@ -1,382 +0,0 @@ -"""A collection of string operations (most are no longer used in Python 1.6). - -Warning: most of the code you see here isn't normally used nowadays. With -Python 1.6, many of these functions are implemented as methods on the -standard string object. They used to be implemented by a built-in module -called strop, but strop is now obsolete itself. - -Public module variables: - -whitespace -- a string containing all characters considered whitespace -lowercase -- a string containing all characters considered lowercase letters -uppercase -- a string containing all characters considered uppercase letters -letters -- a string containing all characters considered letters -digits -- a string containing all characters considered decimal digits -hexdigits -- a string containing all characters considered hexadecimal digits -octdigits -- a string containing all characters considered octal digits -punctuation -- a string containing all characters considered punctuation -printable -- a string containing all characters considered printable - -""" - -# Some strings for ctype-style character classification -whitespace = ' \t\n\r\v\f' -lowercase = 'abcdefghijklmnopqrstuvwxyz' -uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' -letters = lowercase + uppercase -ascii_lowercase = lowercase -ascii_uppercase = uppercase -ascii_letters = ascii_lowercase + ascii_uppercase -digits = '0123456789' -hexdigits = digits + 'abcdef' + 'ABCDEF' -octdigits = '01234567' -punctuation = """!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" -printable = digits + letters + punctuation + whitespace - -# Case conversion helpers -_idmap = '' -for i in range(256): _idmap = _idmap + chr(i) -del i - -# Backward compatible names for exceptions -index_error = ValueError -atoi_error = ValueError -atof_error = ValueError -atol_error = ValueError - -# convert UPPER CASE letters to lower case -def lower(s): - """lower(s) -> string - - Return a copy of the string s converted to lowercase. - - """ - return s.lower() - -# Convert lower case letters to UPPER CASE -def upper(s): - """upper(s) -> string - - Return a copy of the string s converted to uppercase. - - """ - return s.upper() - -# Swap lower case letters and UPPER CASE -def swapcase(s): - """swapcase(s) -> string - - Return a copy of the string s with upper case characters - converted to lowercase and vice versa. - - """ - return s.swapcase() - -# Strip leading and trailing tabs and spaces -def strip(s): - """strip(s) -> string - - Return a copy of the string s with leading and trailing - whitespace removed. - - """ - return s.strip() - -# Strip leading tabs and spaces -def lstrip(s): - """lstrip(s) -> string - - Return a copy of the string s with leading whitespace removed. - - """ - return s.lstrip() - -# Strip trailing tabs and spaces -def rstrip(s): - """rstrip(s) -> string - - Return a copy of the string s with trailing whitespace - removed. - - """ - return s.rstrip() - - -# Split a string into a list of space/tab-separated words -def split(s, sep=None, maxsplit=-1): - """split(s [,sep [,maxsplit]]) -> list of strings - - Return a list of the words in the string s, using sep as the - delimiter string. If maxsplit is given, splits at no more than - maxsplit places (resulting in at most maxsplit+1 words). If sep - is not specified, any whitespace string is a separator. - - (split and splitfields are synonymous) - - """ - return s.split(sep, maxsplit) -splitfields = split - -# Join fields with optional separator -def join(words, sep = ' '): - """join(list [,sep]) -> string - - Return a string composed of the words in list, with - intervening occurrences of sep. The default separator is a - single space. - - (joinfields and join are synonymous) - - """ - return sep.join(words) -joinfields = join - -# Find substring, raise exception if not found -def index(s, *args): - """index(s, sub [,start [,end]]) -> int - - Like find but raises ValueError when the substring is not found. - - """ - return s.index(*args) - -# Find last substring, raise exception if not found -def rindex(s, *args): - """rindex(s, sub [,start [,end]]) -> int - - Like rfind but raises ValueError when the substring is not found. - - """ - return s.rindex(*args) - -# Count non-overlapping occurrences of substring -def count(s, *args): - """count(s, sub[, start[,end]]) -> int - - Return the number of occurrences of substring sub in string - s[start:end]. Optional arguments start and end are - interpreted as in slice notation. - - """ - return s.count(*args) - -# Find substring, return -1 if not found -def find(s, *args): - """find(s, sub [,start [,end]]) -> in - - Return the lowest index in s where substring sub is found, - such that sub is contained within s[start,end]. Optional - arguments start and end are interpreted as in slice notation. - - Return -1 on failure. - - """ - return s.find(*args) - -# Find last substring, return -1 if not found -def rfind(s, *args): - """rfind(s, sub [,start [,end]]) -> int - - Return the highest index in s where substring sub is found, - such that sub is contained within s[start,end]. Optional - arguments start and end are interpreted as in slice notation. - - Return -1 on failure. - - """ - return s.rfind(*args) - -# for a bit of speed -_float = float -_int = int -_long = long -try: - _StringTypes = (str, unicode) -except NameError: - _StringTypes = (str,) - -# Convert string to float -def atof(s): - """atof(s) -> float - - Return the floating point number represented by the string s. - - """ - return _float(s) - - -# Convert string to integer -def atoi(s , base=10): - """atoi(s [,base]) -> int - - Return the integer represented by the string s in the given - base, which defaults to 10. The string s must consist of one - or more digits, possibly preceded by a sign. If base is 0, it - is chosen from the leading characters of s, 0 for octal, 0x or - 0X for hexadecimal. If base is 16, a preceding 0x or 0X is - accepted. - - """ - return _int(s, base) - - -# Convert string to long integer -def atol(s, base=10): - """atol(s [,base]) -> long - - Return the long integer represented by the string s in the - given base, which defaults to 10. The string s must consist - of one or more digits, possibly preceded by a sign. If base - is 0, it is chosen from the leading characters of s, 0 for - octal, 0x or 0X for hexadecimal. If base is 16, a preceding - 0x or 0X is accepted. A trailing L or l is not accepted, - unless base is 0. - - """ - return _long(s, base) - - -# Left-justify a string -def ljust(s, width): - """ljust(s, width) -> string - - Return a left-justified version of s, in a field of the - specified width, padded with spaces as needed. The string is - never truncated. - - """ - return s.ljust(width) - -# Right-justify a string -def rjust(s, width): - """rjust(s, width) -> string - - Return a right-justified version of s, in a field of the - specified width, padded with spaces as needed. The string is - never truncated. - - """ - return s.rjust(width) - -# Center a string -def center(s, width): - """center(s, width) -> string - - Return a center version of s, in a field of the specified - width. padded with spaces as needed. The string is never - truncated. - - """ - return s.center(width) - -# Zero-fill a number, e.g., (12, 3) --> '012' and (-3, 3) --> '-03' -# Decadent feature: the argument may be a string or a number -# (Use of this is deprecated; it should be a string as with ljust c.s.) -def zfill(x, width): - """zfill(x, width) -> string - - Pad a numeric string x with zeros on the left, to fill a field - of the specified width. The string x is never truncated. - - """ - if not isinstance(x, _StringTypes): - x = repr(x) - return x.zfill(width) - -# Expand tabs in a string. -# Doesn't take non-printing chars into account, but does understand \n. -def expandtabs(s, tabsize=8): - """expandtabs(s [,tabsize]) -> string - - Return a copy of the string s with all tab characters replaced - by the appropriate number of spaces, depending on the current - column, and the tabsize (default 8). - - """ - return s.expandtabs(tabsize) - -# Character translation through look-up table. -def translate(s, table, deletions=""): - """translate(s,table [,deletions]) -> string - - Return a copy of the string s, where all characters occurring - in the optional argument deletions are removed, and the - remaining characters have been mapped through the given - translation table, which must be a string of length 256. The - deletions argument is not allowed for Unicode strings. - - """ - if deletions: - return s.translate(table, deletions) - else: - # Add s[:0] so that if s is Unicode and table is an 8-bit string, - # table is converted to Unicode. This means that table *cannot* - # be a dictionary -- for that feature, use u.translate() directly. - return s.translate(table + s[:0]) - -# Capitalize a string, e.g. "aBc dEf" -> "Abc def". -def capitalize(s): - """capitalize(s) -> string - - Return a copy of the string s with only its first character - capitalized. - - """ - return s.capitalize() - -# Capitalize the words in a string, e.g. " aBc dEf " -> "Abc Def". -# See also regsub.capwords(). -def capwords(s, sep=None): - """capwords(s, [sep]) -> string - - Split the argument into words using split, capitalize each - word using capitalize, and join the capitalized words using - join. Note that this replaces runs of whitespace characters by - a single space. - - """ - return join(map(capitalize, s.split(sep)), sep or ' ') - -# Construct a translation string -_idmapL = None -def maketrans(fromstr, tostr): - """maketrans(frm, to) -> string - - Return a translation table (a string of 256 bytes long) - suitable for use in string.translate. The strings frm and to - must be of the same length. - - """ - if len(fromstr) != len(tostr): - raise ValueError, "maketrans arguments must have same length" - global _idmapL - if not _idmapL: - _idmapL = map(None, _idmap) - L = _idmapL[:] - fromstr = map(ord, fromstr) - for i in range(len(fromstr)): - L[fromstr[i]] = tostr[i] - return join(L, "") - -# Substring replacement (global) -def replace(s, old, new, maxsplit=-1): - """replace (str, old, new[, maxsplit]) -> string - - Return a copy of string str with all occurrences of substring - old replaced by new. If the optional argument maxsplit is - given, only the first maxsplit occurrences are replaced. - - """ - return s.replace(old, new, maxsplit) - - -# Try importing optional built-in module "strop" -- if it exists, -# it redefines some string operations that are 100-1000 times faster. -# It also defines values for whitespace, lowercase and uppercase -# that match 's definitions. - -try: - from strop import maketrans, lowercase, uppercase, whitespace - letters = lowercase + uppercase -except ImportError: - pass # Use the original versions diff --git a/Scripts/ServerPython/python/system/symbol.py b/Scripts/ServerPython/python/system/symbol.py deleted file mode 100644 index 0e8d7a03..00000000 --- a/Scripts/ServerPython/python/system/symbol.py +++ /dev/null @@ -1,95 +0,0 @@ -#! /usr/bin/env python - -"""Non-terminal symbols of Python grammar (from "graminit.h").""" - -# This file is automatically generated; please don't muck it up! -# -# To update the symbols in this file, 'cd' to the top directory of -# the python source tree after building the interpreter and run: -# -# python Lib/symbol.py - -#--start constants-- -single_input = 256 -file_input = 257 -eval_input = 258 -funcdef = 259 -parameters = 260 -varargslist = 261 -fpdef = 262 -fplist = 263 -stmt = 264 -simple_stmt = 265 -small_stmt = 266 -expr_stmt = 267 -augassign = 268 -print_stmt = 269 -del_stmt = 270 -pass_stmt = 271 -flow_stmt = 272 -break_stmt = 273 -continue_stmt = 274 -return_stmt = 275 -yield_stmt = 276 -raise_stmt = 277 -import_stmt = 278 -import_as_name = 279 -dotted_as_name = 280 -dotted_name = 281 -global_stmt = 282 -exec_stmt = 283 -assert_stmt = 284 -compound_stmt = 285 -if_stmt = 286 -while_stmt = 287 -for_stmt = 288 -try_stmt = 289 -except_clause = 290 -suite = 291 -test = 292 -and_test = 293 -not_test = 294 -comparison = 295 -comp_op = 296 -expr = 297 -xor_expr = 298 -and_expr = 299 -shift_expr = 300 -arith_expr = 301 -term = 302 -factor = 303 -power = 304 -atom = 305 -listmaker = 306 -lambdef = 307 -trailer = 308 -subscriptlist = 309 -subscript = 310 -sliceop = 311 -exprlist = 312 -testlist = 313 -testlist_safe = 314 -dictmaker = 315 -classdef = 316 -arglist = 317 -argument = 318 -list_iter = 319 -list_for = 320 -list_if = 321 -#--end constants-- - -sym_name = {} -for _name, _value in globals().items(): - if type(_value) is type(0): - sym_name[_value] = _name - - -def main(): - import sys - import token - if len(sys.argv) == 1: - sys.argv = sys.argv + ["Include/graminit.h", "Lib/symbol.py"] - token.main() - -if __name__ == "__main__": - main() diff --git a/Scripts/ServerPython/python/system/tabnanny.py b/Scripts/ServerPython/python/system/tabnanny.py deleted file mode 100644 index a883e591..00000000 --- a/Scripts/ServerPython/python/system/tabnanny.py +++ /dev/null @@ -1,327 +0,0 @@ -#! /usr/bin/env python - -"""The Tab Nanny despises ambiguous indentation. She knows no mercy. - -tabnanny -- Detection of ambiguous indentation - -For the time being this module is intended to be called as a script. -However it is possible to import it into an IDE and use the function -check() described below. - -Warning: The API provided by this module is likely to change in future -releases; such changes may not be backward compatible. -""" - -# Released to the public domain, by Tim Peters, 15 April 1998. - -# XXX Note: this is now a standard library module. -# XXX The API needs to undergo changes however; the current code is too -# XXX script-like. This will be addressed later. - -__version__ = "6" - -import os -import sys -import getopt -import tokenize -if not hasattr(tokenize, 'NL'): - raise ValueError("tokenize.NL doesn't exist -- tokenize module too old") - -__all__ = ["check", "NannyNag", "process_tokens"] - -verbose = 0 -filename_only = 0 - -def errprint(*args): - sep = "" - for arg in args: - sys.stderr.write(sep + str(arg)) - sep = " " - sys.stderr.write("\n") - -def main(): - global verbose, filename_only - try: - opts, args = getopt.getopt(sys.argv[1:], "qv") - except getopt.error, msg: - errprint(msg) - return - for o, a in opts: - if o == '-q': - filename_only = filename_only + 1 - if o == '-v': - verbose = verbose + 1 - if not args: - errprint("Usage:", sys.argv[0], "[-v] file_or_directory ...") - return - for arg in args: - check(arg) - -class NannyNag: - """ - Raised by tokeneater() if detecting an ambiguous indent. - Captured and handled in check(). - """ - def __init__(self, lineno, msg, line): - self.lineno, self.msg, self.line = lineno, msg, line - def get_lineno(self): - return self.lineno - def get_msg(self): - return self.msg - def get_line(self): - return self.line - -def check(file): - """check(file_or_dir) - - If file_or_dir is a directory and not a symbolic link, then recursively - descend the directory tree named by file_or_dir, checking all .py files - along the way. If file_or_dir is an ordinary Python source file, it is - checked for whitespace related problems. The diagnostic messages are - written to standard output using the print statement. - """ - - if os.path.isdir(file) and not os.path.islink(file): - if verbose: - print "%s: listing directory" % `file` - names = os.listdir(file) - for name in names: - fullname = os.path.join(file, name) - if (os.path.isdir(fullname) and - not os.path.islink(fullname) or - os.path.normcase(name[-3:]) == ".py"): - check(fullname) - return - - try: - f = open(file) - except IOError, msg: - errprint("%s: I/O Error: %s" % (`file`, str(msg))) - return - - if verbose > 1: - print "checking", `file`, "..." - - try: - process_tokens(tokenize.generate_tokens(f.readline)) - - except tokenize.TokenError, msg: - errprint("%s: Token Error: %s" % (`file`, str(msg))) - return - - except NannyNag, nag: - badline = nag.get_lineno() - line = nag.get_line() - if verbose: - print "%s: *** Line %d: trouble in tab city! ***" % ( - `file`, badline) - print "offending line:", `line` - print nag.get_msg() - else: - if ' ' in file: file = '"' + file + '"' - if filename_only: print file - else: print file, badline, `line` - return - - if verbose: - print "%s: Clean bill of health." % `file` - -class Whitespace: - # the characters used for space and tab - S, T = ' \t' - - # members: - # raw - # the original string - # n - # the number of leading whitespace characters in raw - # nt - # the number of tabs in raw[:n] - # norm - # the normal form as a pair (count, trailing), where: - # count - # a tuple such that raw[:n] contains count[i] - # instances of S * i + T - # trailing - # the number of trailing spaces in raw[:n] - # It's A Theorem that m.indent_level(t) == - # n.indent_level(t) for all t >= 1 iff m.norm == n.norm. - # is_simple - # true iff raw[:n] is of the form (T*)(S*) - - def __init__(self, ws): - self.raw = ws - S, T = Whitespace.S, Whitespace.T - count = [] - b = n = nt = 0 - for ch in self.raw: - if ch == S: - n = n + 1 - b = b + 1 - elif ch == T: - n = n + 1 - nt = nt + 1 - if b >= len(count): - count = count + [0] * (b - len(count) + 1) - count[b] = count[b] + 1 - b = 0 - else: - break - self.n = n - self.nt = nt - self.norm = tuple(count), b - self.is_simple = len(count) <= 1 - - # return length of longest contiguous run of spaces (whether or not - # preceding a tab) - def longest_run_of_spaces(self): - count, trailing = self.norm - return max(len(count)-1, trailing) - - def indent_level(self, tabsize): - # count, il = self.norm - # for i in range(len(count)): - # if count[i]: - # il = il + (i/tabsize + 1)*tabsize * count[i] - # return il - - # quicker: - # il = trailing + sum (i/ts + 1)*ts*count[i] = - # trailing + ts * sum (i/ts + 1)*count[i] = - # trailing + ts * sum i/ts*count[i] + count[i] = - # trailing + ts * [(sum i/ts*count[i]) + (sum count[i])] = - # trailing + ts * [(sum i/ts*count[i]) + num_tabs] - # and note that i/ts*count[i] is 0 when i < ts - - count, trailing = self.norm - il = 0 - for i in range(tabsize, len(count)): - il = il + i/tabsize * count[i] - return trailing + tabsize * (il + self.nt) - - # return true iff self.indent_level(t) == other.indent_level(t) - # for all t >= 1 - def equal(self, other): - return self.norm == other.norm - - # return a list of tuples (ts, i1, i2) such that - # i1 == self.indent_level(ts) != other.indent_level(ts) == i2. - # Intended to be used after not self.equal(other) is known, in which - # case it will return at least one witnessing tab size. - def not_equal_witness(self, other): - n = max(self.longest_run_of_spaces(), - other.longest_run_of_spaces()) + 1 - a = [] - for ts in range(1, n+1): - if self.indent_level(ts) != other.indent_level(ts): - a.append( (ts, - self.indent_level(ts), - other.indent_level(ts)) ) - return a - - # Return true iff self.indent_level(t) < other.indent_level(t) - # for all t >= 1. - # The algorithm is due to Vincent Broman. - # Easy to prove it's correct. - # XXXpost that. - # Trivial to prove n is sharp (consider T vs ST). - # Unknown whether there's a faster general way. I suspected so at - # first, but no longer. - # For the special (but common!) case where M and N are both of the - # form (T*)(S*), M.less(N) iff M.len() < N.len() and - # M.num_tabs() <= N.num_tabs(). Proof is easy but kinda long-winded. - # XXXwrite that up. - # Note that M is of the form (T*)(S*) iff len(M.norm[0]) <= 1. - def less(self, other): - if self.n >= other.n: - return 0 - if self.is_simple and other.is_simple: - return self.nt <= other.nt - n = max(self.longest_run_of_spaces(), - other.longest_run_of_spaces()) + 1 - # the self.n >= other.n test already did it for ts=1 - for ts in range(2, n+1): - if self.indent_level(ts) >= other.indent_level(ts): - return 0 - return 1 - - # return a list of tuples (ts, i1, i2) such that - # i1 == self.indent_level(ts) >= other.indent_level(ts) == i2. - # Intended to be used after not self.less(other) is known, in which - # case it will return at least one witnessing tab size. - def not_less_witness(self, other): - n = max(self.longest_run_of_spaces(), - other.longest_run_of_spaces()) + 1 - a = [] - for ts in range(1, n+1): - if self.indent_level(ts) >= other.indent_level(ts): - a.append( (ts, - self.indent_level(ts), - other.indent_level(ts)) ) - return a - -def format_witnesses(w): - import string - firsts = map(lambda tup: str(tup[0]), w) - prefix = "at tab size" - if len(w) > 1: - prefix = prefix + "s" - return prefix + " " + string.join(firsts, ', ') - -def process_tokens(tokens): - INDENT = tokenize.INDENT - DEDENT = tokenize.DEDENT - NEWLINE = tokenize.NEWLINE - JUNK = tokenize.COMMENT, tokenize.NL - indents = [Whitespace("")] - check_equal = 0 - - for (type, token, start, end, line) in tokens: - if type == NEWLINE: - # a program statement, or ENDMARKER, will eventually follow, - # after some (possibly empty) run of tokens of the form - # (NL | COMMENT)* (INDENT | DEDENT+)? - # If an INDENT appears, setting check_equal is wrong, and will - # be undone when we see the INDENT. - check_equal = 1 - - elif type == INDENT: - check_equal = 0 - thisguy = Whitespace(token) - if not indents[-1].less(thisguy): - witness = indents[-1].not_less_witness(thisguy) - msg = "indent not greater e.g. " + format_witnesses(witness) - raise NannyNag(start[0], msg, line) - indents.append(thisguy) - - elif type == DEDENT: - # there's nothing we need to check here! what's important is - # that when the run of DEDENTs ends, the indentation of the - # program statement (or ENDMARKER) that triggered the run is - # equal to what's left at the top of the indents stack - - # Ouch! This assert triggers if the last line of the source - # is indented *and* lacks a newline -- then DEDENTs pop out - # of thin air. - # assert check_equal # else no earlier NEWLINE, or an earlier INDENT - check_equal = 1 - - del indents[-1] - - elif check_equal and type not in JUNK: - # this is the first "real token" following a NEWLINE, so it - # must be the first token of the next program statement, or an - # ENDMARKER; the "line" argument exposes the leading whitespace - # for this statement; in the case of ENDMARKER, line is an empty - # string, so will properly match the empty string with which the - # "indents" stack was seeded - check_equal = 0 - thisguy = Whitespace(line) - if not indents[-1].equal(thisguy): - witness = indents[-1].not_equal_witness(thisguy) - msg = "indent not equal e.g. " + format_witnesses(witness) - raise NannyNag(start[0], msg, line) - - -if __name__ == '__main__': - main() diff --git a/Scripts/ServerPython/python/system/token.py b/Scripts/ServerPython/python/system/token.py deleted file mode 100644 index f1e94b7f..00000000 --- a/Scripts/ServerPython/python/system/token.py +++ /dev/null @@ -1,140 +0,0 @@ -#! /usr/bin/env python - -"""Token constants (from "token.h").""" - -# This file is automatically generated; please don't muck it up! -# -# To update the symbols in this file, 'cd' to the top directory of -# the python source tree after building the interpreter and run: -# -# python Lib/token.py - -#--start constants-- -ENDMARKER = 0 -NAME = 1 -NUMBER = 2 -STRING = 3 -NEWLINE = 4 -INDENT = 5 -DEDENT = 6 -LPAR = 7 -RPAR = 8 -LSQB = 9 -RSQB = 10 -COLON = 11 -COMMA = 12 -SEMI = 13 -PLUS = 14 -MINUS = 15 -STAR = 16 -SLASH = 17 -VBAR = 18 -AMPER = 19 -LESS = 20 -GREATER = 21 -EQUAL = 22 -DOT = 23 -PERCENT = 24 -BACKQUOTE = 25 -LBRACE = 26 -RBRACE = 27 -EQEQUAL = 28 -NOTEQUAL = 29 -LESSEQUAL = 30 -GREATEREQUAL = 31 -TILDE = 32 -CIRCUMFLEX = 33 -LEFTSHIFT = 34 -RIGHTSHIFT = 35 -DOUBLESTAR = 36 -PLUSEQUAL = 37 -MINEQUAL = 38 -STAREQUAL = 39 -SLASHEQUAL = 40 -PERCENTEQUAL = 41 -AMPEREQUAL = 42 -VBAREQUAL = 43 -CIRCUMFLEXEQUAL = 44 -LEFTSHIFTEQUAL = 45 -RIGHTSHIFTEQUAL = 46 -DOUBLESTAREQUAL = 47 -DOUBLESLASH = 48 -DOUBLESLASHEQUAL = 49 -OP = 50 -ERRORTOKEN = 51 -N_TOKENS = 52 -NT_OFFSET = 256 -#--end constants-- - -tok_name = {} -for _name, _value in globals().items(): - if type(_value) is type(0): - tok_name[_value] = _name - - -def ISTERMINAL(x): - return x < NT_OFFSET - -def ISNONTERMINAL(x): - return x >= NT_OFFSET - -def ISEOF(x): - return x == ENDMARKER - - -def main(): - import re - import sys - args = sys.argv[1:] - inFileName = args and args[0] or "Include/token.h" - outFileName = "Lib/token.py" - if len(args) > 1: - outFileName = args[1] - try: - fp = open(inFileName) - except IOError, err: - sys.stdout.write("I/O error: %s\n" % str(err)) - sys.exit(1) - lines = fp.read().split("\n") - fp.close() - prog = re.compile( - "#define[ \t][ \t]*([A-Z][A-Z_]*)[ \t][ \t]*([0-9][0-9]*)", - re.IGNORECASE) - tokens = {} - for line in lines: - match = prog.match(line) - if match: - name, val = match.group(1, 2) - val = int(val) - tokens[val] = name # reverse so we can sort them... - keys = tokens.keys() - keys.sort() - # load the output skeleton from the target: - try: - fp = open(outFileName) - except IOError, err: - sys.stderr.write("I/O error: %s\n" % str(err)) - sys.exit(2) - format = fp.read().split("\n") - fp.close() - try: - start = format.index("#--start constants--") + 1 - end = format.index("#--end constants--") - except ValueError: - sys.stderr.write("target does not contain format markers") - sys.exit(3) - lines = [] - for val in keys: - lines.append("%s = %d" % (tokens[val], val)) - format[start:end] = lines - try: - fp = open(outFileName, 'w') - except IOError, err: - sys.stderr.write("I/O error: %s\n" % str(err)) - sys.exit(4) - fp.write("\n".join(format)) - fp.close() - - -if __name__ == "__main__": - main() diff --git a/Scripts/ServerPython/python/system/tokenize.py b/Scripts/ServerPython/python/system/tokenize.py deleted file mode 100644 index abeffd5d..00000000 --- a/Scripts/ServerPython/python/system/tokenize.py +++ /dev/null @@ -1,286 +0,0 @@ -"""Tokenization help for Python programs. - -generate_tokens(readline) is a generator that breaks a stream of -text into Python tokens. It accepts a readline-like method which is called -repeatedly to get the next line of input (or "" for EOF). It generates -5-tuples with these members: - - the token type (see token.py) - the token (a string) - the starting (row, column) indices of the token (a 2-tuple of ints) - the ending (row, column) indices of the token (a 2-tuple of ints) - the original line (string) - -It is designed to match the working of the Python tokenizer exactly, except -that it produces COMMENT tokens for comments and gives type OP for all -operators - -Older entry points - tokenize_loop(readline, tokeneater) - tokenize(readline, tokeneater=printtoken) -are the same, except instead of generating tokens, tokeneater is a callback -function to which the 5 fields described above are passed as 5 arguments, -each time a new token is found.""" - -from __future__ import generators - -__author__ = 'Ka-Ping Yee ' -__credits__ = \ - 'GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip Montanaro' - -import string, re -from token import * - -import token -__all__ = [x for x in dir(token) if x[0] != '_'] + ["COMMENT", "tokenize", "NL"] -del token - -COMMENT = N_TOKENS -tok_name[COMMENT] = 'COMMENT' -NL = N_TOKENS + 1 -tok_name[NL] = 'NL' -N_TOKENS += 2 - -def group(*choices): return '(' + '|'.join(choices) + ')' -def any(*choices): return apply(group, choices) + '*' -def maybe(*choices): return apply(group, choices) + '?' - -Whitespace = r'[ \f\t]*' -Comment = r'#[^\r\n]*' -Ignore = Whitespace + any(r'\\\r?\n' + Whitespace) + maybe(Comment) -Name = r'[a-zA-Z_]\w*' - -Hexnumber = r'0[xX][\da-fA-F]*[lL]?' -Octnumber = r'0[0-7]*[lL]?' -Decnumber = r'[1-9]\d*[lL]?' -Intnumber = group(Hexnumber, Octnumber, Decnumber) -Exponent = r'[eE][-+]?\d+' -Pointfloat = group(r'\d+\.\d*', r'\.\d+') + maybe(Exponent) -Expfloat = r'\d+' + Exponent -Floatnumber = group(Pointfloat, Expfloat) -Imagnumber = group(r'\d+[jJ]', Floatnumber + r'[jJ]') -Number = group(Imagnumber, Floatnumber, Intnumber) - -# Tail end of ' string. -Single = r"[^'\\]*(?:\\.[^'\\]*)*'" -# Tail end of " string. -Double = r'[^"\\]*(?:\\.[^"\\]*)*"' -# Tail end of ''' string. -Single3 = r"[^'\\]*(?:(?:\\.|'(?!''))[^'\\]*)*'''" -# Tail end of """ string. -Double3 = r'[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*"""' -Triple = group("[uU]?[rR]?'''", '[uU]?[rR]?"""') -# Single-line ' or " string. -String = group(r"[uU]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'", - r'[uU]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"') - -# Because of leftmost-then-longest match semantics, be sure to put the -# longest operators first (e.g., if = came before ==, == would get -# recognized as two instances of =). -Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"<>", r"!=", - r"//=?", - r"[+\-*/%&|^=<>]=?", - r"~") - -Bracket = '[][(){}]' -Special = group(r'\r?\n', r'[:;.,`]') -Funny = group(Operator, Bracket, Special) - -PlainToken = group(Number, Funny, String, Name) -Token = Ignore + PlainToken - -# First (or only) line of ' or " string. -ContStr = group(r"[uU]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*" + - group("'", r'\\\r?\n'), - r'[uU]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*' + - group('"', r'\\\r?\n')) -PseudoExtras = group(r'\\\r?\n', Comment, Triple) -PseudoToken = Whitespace + group(PseudoExtras, Number, Funny, ContStr, Name) - -tokenprog, pseudoprog, single3prog, double3prog = map( - re.compile, (Token, PseudoToken, Single3, Double3)) -endprogs = {"'": re.compile(Single), '"': re.compile(Double), - "'''": single3prog, '"""': double3prog, - "r'''": single3prog, 'r"""': double3prog, - "u'''": single3prog, 'u"""': double3prog, - "ur'''": single3prog, 'ur"""': double3prog, - "R'''": single3prog, 'R"""': double3prog, - "U'''": single3prog, 'U"""': double3prog, - "uR'''": single3prog, 'uR"""': double3prog, - "Ur'''": single3prog, 'Ur"""': double3prog, - "UR'''": single3prog, 'UR"""': double3prog, - 'r': None, 'R': None, 'u': None, 'U': None} - -tabsize = 8 - -class TokenError(Exception): pass - -class StopTokenizing(Exception): pass - -def printtoken(type, token, (srow, scol), (erow, ecol), line): # for testing - print "%d,%d-%d,%d:\t%s\t%s" % \ - (srow, scol, erow, ecol, tok_name[type], repr(token)) - -def tokenize(readline, tokeneater=printtoken): - """ - The tokenize() function accepts two parameters: one representing the - input stream, and one providing an output mechanism for tokenize(). - - The first parameter, readline, must be a callable object which provides - the same interface as the readline() method of built-in file objects. - Each call to the function should return one line of input as a string. - - The second parameter, tokeneater, must also be a callable object. It is - called once for each token, with five arguments, corresponding to the - tuples generated by generate_tokens(). - """ - try: - tokenize_loop(readline, tokeneater) - except StopTokenizing: - pass - -# backwards compatible interface -def tokenize_loop(readline, tokeneater): - for token_info in generate_tokens(readline): - apply(tokeneater, token_info) - -def generate_tokens(readline): - """ - The generate_tokens() generator requires one argment, readline, which - must be a callable object which provides the same interface as the - readline() method of built-in file objects. Each call to the function - should return one line of input as a string. - - The generator produces 5-tuples with these members: the token type; the - token string; a 2-tuple (srow, scol) of ints specifying the row and - column where the token begins in the source; a 2-tuple (erow, ecol) of - ints specifying the row and column where the token ends in the source; - and the line on which the token was found. The line passed is the - logical line; continuation lines are included. - """ - lnum = parenlev = continued = 0 - namechars, numchars = string.ascii_letters + '_', '0123456789' - contstr, needcont = '', 0 - contline = None - indents = [0] - - while 1: # loop over lines in stream - line = readline() - lnum = lnum + 1 - pos, max = 0, len(line) - - if contstr: # continued string - if not line: - raise TokenError, ("EOF in multi-line string", strstart) - endmatch = endprog.match(line) - if endmatch: - pos = end = endmatch.end(0) - yield (STRING, contstr + line[:end], - strstart, (lnum, end), contline + line) - contstr, needcont = '', 0 - contline = None - elif needcont and line[-2:] != '\\\n' and line[-3:] != '\\\r\n': - yield (ERRORTOKEN, contstr + line, - strstart, (lnum, len(line)), contline) - contstr = '' - contline = None - continue - else: - contstr = contstr + line - contline = contline + line - continue - - elif parenlev == 0 and not continued: # new statement - if not line: break - column = 0 - while pos < max: # measure leading whitespace - if line[pos] == ' ': column = column + 1 - elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize - elif line[pos] == '\f': column = 0 - else: break - pos = pos + 1 - if pos == max: break - - if line[pos] in '#\r\n': # skip comments or blank lines - yield ((NL, COMMENT)[line[pos] == '#'], line[pos:], - (lnum, pos), (lnum, len(line)), line) - continue - - if column > indents[-1]: # count indents or dedents - indents.append(column) - yield (INDENT, line[:pos], (lnum, 0), (lnum, pos), line) - while column < indents[-1]: - indents = indents[:-1] - yield (DEDENT, '', (lnum, pos), (lnum, pos), line) - - else: # continued statement - if not line: - raise TokenError, ("EOF in multi-line statement", (lnum, 0)) - continued = 0 - - while pos < max: - pseudomatch = pseudoprog.match(line, pos) - if pseudomatch: # scan for tokens - start, end = pseudomatch.span(1) - spos, epos, pos = (lnum, start), (lnum, end), end - token, initial = line[start:end], line[start] - - if initial in numchars or \ - (initial == '.' and token != '.'): # ordinary number - yield (NUMBER, token, spos, epos, line) - elif initial in '\r\n': - yield (parenlev > 0 and NL or NEWLINE, - token, spos, epos, line) - elif initial == '#': - yield (COMMENT, token, spos, epos, line) - elif token in ("'''", '"""', # triple-quoted - "r'''", 'r"""', "R'''", 'R"""', - "u'''", 'u"""', "U'''", 'U"""', - "ur'''", 'ur"""', "Ur'''", 'Ur"""', - "uR'''", 'uR"""', "UR'''", 'UR"""'): - endprog = endprogs[token] - endmatch = endprog.match(line, pos) - if endmatch: # all on one line - pos = endmatch.end(0) - token = line[start:pos] - yield (STRING, token, spos, (lnum, pos), line) - else: - strstart = (lnum, start) # multiple lines - contstr = line[start:] - contline = line - break - elif initial in ("'", '"') or \ - token[:2] in ("r'", 'r"', "R'", 'R"', - "u'", 'u"', "U'", 'U"') or \ - token[:3] in ("ur'", 'ur"', "Ur'", 'Ur"', - "uR'", 'uR"', "UR'", 'UR"' ): - if token[-1] == '\n': # continued string - strstart = (lnum, start) - endprog = (endprogs[initial] or endprogs[token[1]] or - endprogs[token[2]]) - contstr, needcont = line[start:], 1 - contline = line - break - else: # ordinary string - yield (STRING, token, spos, epos, line) - elif initial in namechars: # ordinary name - yield (NAME, token, spos, epos, line) - elif initial == '\\': # continued stmt - continued = 1 - else: - if initial in '([{': parenlev = parenlev + 1 - elif initial in ')]}': parenlev = parenlev - 1 - yield (OP, token, spos, epos, line) - else: - yield (ERRORTOKEN, line[pos], - (lnum, pos), (lnum, pos+1), line) - pos = pos + 1 - - for indent in indents[1:]: # pop remaining indent levels - yield (DEDENT, '', (lnum, 0), (lnum, 0), '') - yield (ENDMARKER, '', (lnum, 0), (lnum, 0), '') - -if __name__ == '__main__': # testing - import sys - if len(sys.argv) > 1: tokenize(open(sys.argv[1]).readline) - else: tokenize(sys.stdin.readline) diff --git a/Scripts/ServerPython/python/system/traceback.py b/Scripts/ServerPython/python/system/traceback.py deleted file mode 100644 index 993252aa..00000000 --- a/Scripts/ServerPython/python/system/traceback.py +++ /dev/null @@ -1,301 +0,0 @@ -"""Extract, format and print information about Python stack traces.""" - -import linecache -import sys -import types - -__all__ = ['extract_stack', 'extract_tb', 'format_exception', - 'format_exception_only', 'format_list', 'format_stack', - 'format_tb', 'print_exc', 'print_exception', 'print_last', - 'print_stack', 'print_tb', 'tb_lineno'] - -def _print(file, str='', terminator='\n'): - file.write(str+terminator) - - -def print_list(extracted_list, file=None): - """Print the list of tuples as returned by extract_tb() or - extract_stack() as a formatted stack trace to the given file.""" - if not file: - file = sys.stderr - for filename, lineno, name, line in extracted_list: - _print(file, - ' File "%s", line %d, in %s' % (filename,lineno,name)) - if line: - _print(file, ' %s' % line.strip()) - -def format_list(extracted_list): - """Format a list of traceback entry tuples for printing. - - Given a list of tuples as returned by extract_tb() or - extract_stack(), return a list of strings ready for printing. - Each string in the resulting list corresponds to the item with the - same index in the argument list. Each string ends in a newline; - the strings may contain internal newlines as well, for those items - whose source text line is not None. - """ - list = [] - for filename, lineno, name, line in extracted_list: - item = ' File "%s", line %d, in %s\n' % (filename,lineno,name) - if line: - item = item + ' %s\n' % line.strip() - list.append(item) - return list - - -def print_tb(tb, limit=None, file=None): - """Print up to 'limit' stack trace entries from the traceback 'tb'. - - If 'limit' is omitted or None, all entries are printed. If 'file' - is omitted or None, the output goes to sys.stderr; otherwise - 'file' should be an open file or file-like object with a write() - method. - """ - if not file: - file = sys.stderr - if limit is None: - if hasattr(sys, 'tracebacklimit'): - limit = sys.tracebacklimit - n = 0 - while tb is not None and (limit is None or n < limit): - f = tb.tb_frame - lineno = tb_lineno(tb) - co = f.f_code - filename = co.co_filename - name = co.co_name - _print(file, - ' File "%s", line %d, in %s' % (filename,lineno,name)) - line = linecache.getline(filename, lineno) - if line: _print(file, ' ' + line.strip()) - tb = tb.tb_next - n = n+1 - -def format_tb(tb, limit = None): - """A shorthand for 'format_list(extract_stack(f, limit)).""" - return format_list(extract_tb(tb, limit)) - -def extract_tb(tb, limit = None): - """Return list of up to limit pre-processed entries from traceback. - - This is useful for alternate formatting of stack traces. If - 'limit' is omitted or None, all entries are extracted. A - pre-processed stack trace entry is a quadruple (filename, line - number, function name, text) representing the information that is - usually printed for a stack trace. The text is a string with - leading and trailing whitespace stripped; if the source is not - available it is None. - """ - if limit is None: - if hasattr(sys, 'tracebacklimit'): - limit = sys.tracebacklimit - list = [] - n = 0 - while tb is not None and (limit is None or n < limit): - f = tb.tb_frame - lineno = tb_lineno(tb) - co = f.f_code - filename = co.co_filename - name = co.co_name - line = linecache.getline(filename, lineno) - if line: line = line.strip() - else: line = None - list.append((filename, lineno, name, line)) - tb = tb.tb_next - n = n+1 - return list - - -def print_exception(etype, value, tb, limit=None, file=None): - """Print exception up to 'limit' stack trace entries from 'tb' to 'file'. - - This differs from print_tb() in the following ways: (1) if - traceback is not None, it prints a header "Traceback (most recent - call last):"; (2) it prints the exception type and value after the - stack trace; (3) if type is SyntaxError and value has the - appropriate format, it prints the line where the syntax error - occurred with a caret on the next line indicating the approximate - position of the error. - """ - if not file: - file = sys.stderr - if tb: - _print(file, 'Traceback (most recent call last):') - print_tb(tb, limit, file) - lines = format_exception_only(etype, value) - for line in lines[:-1]: - _print(file, line, ' ') - _print(file, lines[-1], '') - -def format_exception(etype, value, tb, limit = None): - """Format a stack trace and the exception information. - - The arguments have the same meaning as the corresponding arguments - to print_exception(). The return value is a list of strings, each - ending in a newline and some containing internal newlines. When - these lines are concatenated and printed, exactly the same text is - printed as does print_exception(). - """ - if tb: - list = ['Traceback (most recent call last):\n'] - list = list + format_tb(tb, limit) - else: - list = [] - list = list + format_exception_only(etype, value) - return list - -def format_exception_only(etype, value): - """Format the exception part of a traceback. - - The arguments are the exception type and value such as given by - sys.last_type and sys.last_value. The return value is a list of - strings, each ending in a newline. Normally, the list contains a - single string; however, for SyntaxError exceptions, it contains - several lines that (when printed) display detailed information - about where the syntax error occurred. The message indicating - which exception occurred is the always last string in the list. - """ - list = [] - if type(etype) == types.ClassType: - stype = etype.__name__ - else: - stype = etype - if value is None: - list.append(str(stype) + '\n') - else: - if etype is SyntaxError: - try: - msg, (filename, lineno, offset, line) = value - except: - pass - else: - if not filename: filename = "" - list.append(' File "%s", line %d\n' % - (filename, lineno)) - if line is not None: - i = 0 - while i < len(line) and line[i].isspace(): - i = i+1 - list.append(' %s\n' % line.strip()) - if offset is not None: - s = ' ' - for c in line[i:offset-1]: - if c.isspace(): - s = s + c - else: - s = s + ' ' - list.append('%s^\n' % s) - value = msg - s = _some_str(value) - if s: - list.append('%s: %s\n' % (str(stype), s)) - else: - list.append('%s\n' % str(stype)) - return list - -def _some_str(value): - try: - return str(value) - except: - return '' % type(value).__name__ - - -def print_exc(limit=None, file=None): - """Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'. - (In fact, it uses sys.exc_info() to retrieve the same information - in a thread-safe way.)""" - if not file: - file = sys.stderr - try: - etype, value, tb = sys.exc_info() - print_exception(etype, value, tb, limit, file) - finally: - etype = value = tb = None - -def print_last(limit=None, file=None): - """This is a shorthand for 'print_exception(sys.last_type, - sys.last_value, sys.last_traceback, limit, file)'.""" - if not file: - file = sys.stderr - print_exception(sys.last_type, sys.last_value, sys.last_traceback, - limit, file) - - -def print_stack(f=None, limit=None, file=None): - """Print a stack trace from its invocation point. - - The optional 'f' argument can be used to specify an alternate - stack frame at which to start. The optional 'limit' and 'file' - arguments have the same meaning as for print_exception(). - """ - if f is None: - try: - raise ZeroDivisionError - except ZeroDivisionError: - f = sys.exc_info()[2].tb_frame.f_back - print_list(extract_stack(f, limit), file) - -def format_stack(f=None, limit=None): - """Shorthand for 'format_list(extract_stack(f, limit))'.""" - if f is None: - try: - raise ZeroDivisionError - except ZeroDivisionError: - f = sys.exc_info()[2].tb_frame.f_back - return format_list(extract_stack(f, limit)) - -def extract_stack(f=None, limit = None): - """Extract the raw traceback from the current stack frame. - - The return value has the same format as for extract_tb(). The - optional 'f' and 'limit' arguments have the same meaning as for - print_stack(). Each item in the list is a quadruple (filename, - line number, function name, text), and the entries are in order - from oldest to newest stack frame. - """ - if f is None: - try: - raise ZeroDivisionError - except ZeroDivisionError: - f = sys.exc_info()[2].tb_frame.f_back - if limit is None: - if hasattr(sys, 'tracebacklimit'): - limit = sys.tracebacklimit - list = [] - n = 0 - while f is not None and (limit is None or n < limit): - lineno = f.f_lineno # XXX Too bad if -O is used - co = f.f_code - filename = co.co_filename - name = co.co_name - line = linecache.getline(filename, lineno) - if line: line = line.strip() - else: line = None - list.append((filename, lineno, name, line)) - f = f.f_back - n = n+1 - list.reverse() - return list - -def tb_lineno(tb): - """Calculate correct line number of traceback given in tb. - - Even works with -O on. - """ - # Coded by Marc-Andre Lemburg from the example of PyCode_Addr2Line() - # in compile.c. - # Revised version by Jim Hugunin to work with JPython too. - - c = tb.tb_frame.f_code - if not hasattr(c, 'co_lnotab'): - return tb.tb_lineno - - tab = c.co_lnotab - line = c.co_firstlineno - stopat = tb.tb_lasti - addr = 0 - for i in range(0, len(tab), 2): - addr = addr + ord(tab[i]) - if addr > stopat: - break - line = line + ord(tab[i+1]) - return line diff --git a/Scripts/ServerPython/python/system/types.py b/Scripts/ServerPython/python/system/types.py deleted file mode 100644 index e151e1b6..00000000 --- a/Scripts/ServerPython/python/system/types.py +++ /dev/null @@ -1,86 +0,0 @@ -"""Define names for all type symbols known in the standard interpreter. - -Types that are part of optional modules (e.g. array) are not listed. -""" -from __future__ import generators - -import sys - -# Iterators in Python aren't a matter of type but of protocol. A large -# and changing number of builtin types implement *some* flavor of -# iterator. Don't check the type! Use hasattr to check for both -# "__iter__" and "next" attributes instead. - -NoneType = type(None) -TypeType = type -ObjectType = object - -IntType = int -LongType = long -FloatType = float -try: - ComplexType = complex -except NameError: - pass - -StringType = str -try: - UnicodeType = unicode - StringTypes = (StringType, UnicodeType) -except NameError: - StringTypes = (StringType,) - -BufferType = type(buffer('')) - -TupleType = tuple -ListType = list -DictType = DictionaryType = dict - -def _f(): pass -FunctionType = type(_f) -LambdaType = type(lambda: None) # Same as FunctionType -try: - CodeType = type(_f.func_code) -except RuntimeError: - # Execution in restricted environment - pass - -def g(): - yield 1 -GeneratorType = type(g()) -del g - -class _C: - def _m(self): pass -ClassType = type(_C) -UnboundMethodType = type(_C._m) # Same as MethodType -_x = _C() -InstanceType = type(_x) -MethodType = type(_x._m) - -BuiltinFunctionType = type(len) -BuiltinMethodType = type([].append) # Same as BuiltinFunctionType - -ModuleType = type(sys) -FileType = file -XRangeType = type(xrange(0)) - -try: - raise TypeError -except TypeError: - try: - tb = sys.exc_info()[2] - TracebackType = type(tb) - FrameType = type(tb.tb_frame) - except AttributeError: - # In the restricted environment, exc_info returns (None, None, - # None) Then, tb.tb_frame gives an attribute error - pass - tb = None; del tb - -SliceType = type(slice(0)) -EllipsisType = type(Ellipsis) - -DictProxyType = type(TypeType.__dict__) - -del sys, _f, _C, _x, generators # Not for export diff --git a/Scripts/ServerPython/python/system/verify.py b/Scripts/ServerPython/python/system/verify.py deleted file mode 100644 index b4890bd9..00000000 --- a/Scripts/ServerPython/python/system/verify.py +++ /dev/null @@ -1,182 +0,0 @@ -# -# (C) Copyright 2000 by hartmut Goebel -# -# byte-code verifier for decompyle -# - -import types -import decompyle - -#--- exceptions --- - -class VerifyCmpError(Exception): - pass - -class CmpErrorConsts(VerifyCmpError): - """Exception to be raised when consts differ.""" - def __init__(self, name, index): - self.name = name - self.index = index - - def __str__(self): - return 'Compare Error within Consts of %s at index %i' % \ - (repr(self.name), self.index) - -class CmpErrorConstsLen(VerifyCmpError): - """Exception to be raised when length of co_consts differs.""" - def __init__(self, name, consts1, consts2): - self.name = name - self.consts = (consts1, consts2) - - def __str__(self): - return 'Consts length differs in %s:\n\n%i:\t%s\n\n%i:\t%s\n\n' % \ - (repr(self.name), - len(self.consts[0]), `self.consts[0]`, - len(self.consts[1]), `self.consts[1]`) - -class CmpErrorCode(VerifyCmpError): - """Exception to be raised when code differs.""" - def __init__(self, name, index, token1, token2): - self.name = name - self.index = index - self.token1 = token1 - self.token2 = token2 - - def __str__(self): - return 'Code differs in %s at offset %i [%s] != [%s]' % \ - (repr(self.name), self.index, - repr(self.token1), repr(self.token2)) #\ - # + ('%s %s') % (self.token1.pattr, self.token2.pattr) - -class CmpErrorCodeLen(VerifyCmpError): - """Exception to be raised when code length differs.""" - def __init__(self, name, tokens1, tokens2): - self.name = name - self.tokens = [tokens1, tokens2] - - def __str__(self): - return reduce(lambda s,t: "%s%-37s\t%-37s\n" % (s, t[0], t[1]), - map(lambda a,b: (a,b), - self.tokens[0], - self.tokens[1]), - 'Code len differs in %s\n' % str(self.name)) - -class CmpErrorMember(VerifyCmpError): - """Exception to be raised when other members differ.""" - def __init__(self, name, member, data1, data2): - self.name = name - self.member = member - self.data = (data1, data2) - - def __str__(self): - return 'Member %s differs in %s:\n\t%s\n\t%s\n' % \ - (repr(self.member), repr(self.name), - repr(self.data[0]), repr(self.data[1])) - -#--- compare --- - -# these members are ignored -__IGNORE_CODE_MEMBERS__ = ['co_filename', 'co_firstlineno', 'co_lnotab'] - -def cmp_code_objects(code_obj1, code_obj2, name=''): - """ - Compare two code-objects. - - This is the main part of this module. - """ - assert type(code_obj1) == types.CodeType - assert type(code_obj2) == types.CodeType - assert dir(code_obj1) == code_obj1.__members__ - assert dir(code_obj2) == code_obj2.__members__ - assert code_obj1.__members__ == code_obj2.__members__ - if name == '__main__': - name = code_obj1.co_name - else: - name = '%s.%s' % (name, code_obj1.co_name) - if name == '.?': name = '__main__' - - members = code_obj1.__members__; members.sort(); #members.reverse() - tokens1 = None - for member in members: - if member in __IGNORE_CODE_MEMBERS__: - pass - elif member == 'co_code': - # use changed Token class - __Token = decompyle.Token - decompyle.Token = Token - # tokenize both code-objects - tokens1, customize = decompyle._tokenize(None, code_obj1) - tokens2, customize = decompyle._tokenize(None, code_obj2) - del customize - decompyle.Token = __Token # restore Token class - - # compare length - if len(tokens1) != len(tokens2): - raise CmpErrorCodeLen(name, tokens1, tokens2) - # compare contents - #print len(tokens1), type(tokens1), type(tokens2) - for i in xrange(len(tokens1)): - if tokens1[i] != tokens2[i]: - #print '-->', i, type(tokens1[i]), type(tokens2[i]) - raise CmpErrorCode(name, i, tokens1[i], - tokens2[i]) - elif member == 'co_consts': - # compare length - if len(code_obj1.co_consts) != len(code_obj2.co_consts): - raise CmpErrorConstsLen(name, code_obj1.co_consts ,code_obj2.co_consts) - # compare contents - for idx in xrange(len(code_obj1.co_consts)): - const1 = code_obj1.co_consts[idx] - const2 = code_obj2.co_consts[idx] - # same type? - if type(const1) != type(const2): - raise CmpErrorContType(name, idx) - if type(const1) == types.CodeType: - # code object -> recursive compare - cmp_code_objects(const1, const2, - name) - elif cmp(const1, const2) != 0: - # content differs - raise CmpErrorConsts(name, idx) - else: - # all other members must be equal - if eval('code_obj1.%s != code_obj2.%s' % (member, member)): - data1 = eval('code_obj1.%s' % member) - data2 = eval('code_obj2.%s' % member) - raise CmpErrorMember(name, member, data1,data2) - - -class Token(decompyle.Token): - """Token class with changed semantics for 'cmp()'.""" - - def __cmp__(self, o): - if self.type in decompyle._JUMP_OPS_: - # ignore offset - return cmp(self.type, o.type) - else: - return cmp(self.type, o.type) \ - or cmp(self.pattr, o.pattr) - - def __repr__(self): - return '%s %s (%s)' % (str(self.type), str(self.attr), - str(self.pattr)) - - -def compare_code_with_srcfile(pyc_filename, src_filename): - """Compare a .pyc with a source code file.""" - code_obj1 = decompyle._load_module(pyc_filename) - code_obj2 = decompyle._load_file(src_filename) - cmp_code_objects(code_obj1, code_obj2) - -def compare_files(pyc_filename1, pyc_filename2): - """Compare two .pyc files.""" - code_obj1 = decompyle._load_module(pyc_filename1) - code_obj2 = decompyle._load_module(pyc_filename2) - cmp_code_objects(code_obj1, code_obj2) - -if __name__ == '__main__': - t1 = Token('LOAD_CONST', None, 'code_object _expandLang', 52) - t2 = Token('LOAD_CONST', -421, 'code_object _expandLang', 55) - print `t1` - print `t2` - print cmp(t1, t2), cmp(t1.type, t2.type), cmp(t1.attr, t2.attr) diff --git a/Scripts/ServerPython/python/system/warnings.py b/Scripts/ServerPython/python/system/warnings.py deleted file mode 100644 index 658e1a59..00000000 --- a/Scripts/ServerPython/python/system/warnings.py +++ /dev/null @@ -1,258 +0,0 @@ -"""Python part of the warnings subsystem.""" - -import sys, re, types - -__all__ = ["warn", "showwarning", "formatwarning", "filterwarnings", - "resetwarnings"] - -defaultaction = "default" -filters = [] -onceregistry = {} - -def warn(message, category=None, stacklevel=1): - """Issue a warning, or maybe ignore it or raise an exception.""" - # Check category argument - if category is None: - category = UserWarning - assert issubclass(category, Warning) - # Get context information - try: - caller = sys._getframe(stacklevel) - except ValueError: - globals = sys.__dict__ - lineno = 1 - else: - globals = caller.f_globals - lineno = caller.f_lineno - if globals.has_key('__name__'): - module = globals['__name__'] - else: - module = "" - filename = globals.get('__file__') - if filename: - fnl = filename.lower() - if fnl.endswith(".pyc") or fnl.endswith(".pyo"): - filename = filename[:-1] - else: - if module == "__main__": - filename = sys.argv[0] - if not filename: - filename = module - registry = globals.setdefault("__warningregistry__", {}) - warn_explicit(message, category, filename, lineno, module, registry) - -def warn_explicit(message, category, filename, lineno, - module=None, registry=None): - if module is None: - module = filename - if module[-3:].lower() == ".py": - module = module[:-3] # XXX What about leading pathname? - if registry is None: - registry = {} - key = (message, category, lineno) - # Quick test for common case - if registry.get(key): - return - # Search the filters - for item in filters: - action, msg, cat, mod, ln = item - if (msg.match(message) and - issubclass(category, cat) and - mod.match(module) and - (ln == 0 or lineno == ln)): - break - else: - action = defaultaction - # Early exit actions - if action == "ignore": - registry[key] = 1 - return - if action == "error": - raise category(message) - # Other actions - if action == "once": - registry[key] = 1 - oncekey = (message, category) - if onceregistry.get(oncekey): - return - onceregistry[oncekey] = 1 - elif action == "always": - pass - elif action == "module": - registry[key] = 1 - altkey = (message, category, 0) - if registry.get(altkey): - return - registry[altkey] = 1 - elif action == "default": - registry[key] = 1 - else: - # Unrecognized actions are errors - raise RuntimeError( - "Unrecognized action (%s) in warnings.filters:\n %s" % - (`action`, str(item))) - # Print message and context - showwarning(message, category, filename, lineno) - -def showwarning(message, category, filename, lineno, file=None): - """Hook to write a warning to a file; replace if you like.""" - if file is None: - file = sys.stderr - try: - file.write(formatwarning(message, category, filename, lineno)) - except IOError: - pass # the file (probably stderr) is invalid - this warning gets lost. - -def formatwarning(message, category, filename, lineno): - """Function to format a warning the standard way.""" - import linecache - s = "%s:%s: %s: %s\n" % (filename, lineno, category.__name__, message) - line = linecache.getline(filename, lineno).strip() - if line: - s = s + " " + line + "\n" - return s - -def filterwarnings(action, message="", category=Warning, module="", lineno=0, - append=0): - """Insert an entry into the list of warnings filters (at the front). - - Use assertions to check that all arguments have the right type.""" - assert action in ("error", "ignore", "always", "default", "module", - "once"), "invalid action: %s" % `action` - assert isinstance(message, types.StringType), "message must be a string" - assert isinstance(category, types.ClassType), "category must be a class" - assert issubclass(category, Warning), "category must be a Warning subclass" - assert type(module) is types.StringType, "module must be a string" - assert type(lineno) is types.IntType and lineno >= 0, \ - "lineno must be an int >= 0" - item = (action, re.compile(message, re.I), category, - re.compile(module), lineno) - if append: - filters.append(item) - else: - filters.insert(0, item) - -def resetwarnings(): - """Clear the list of warning filters, so that no filters are active.""" - filters[:] = [] - -class _OptionError(Exception): - """Exception used by option processing helpers.""" - pass - -# Helper to process -W options passed via sys.warnoptions -def _processoptions(args): - for arg in args: - try: - _setoption(arg) - except _OptionError, msg: - print >>sys.stderr, "Invalid -W option ignored:", msg - -# Helper for _processoptions() -def _setoption(arg): - parts = arg.split(':') - if len(parts) > 5: - raise _OptionError("too many fields (max 5): %s" % `arg`) - while len(parts) < 5: - parts.append('') - action, message, category, module, lineno = [s.strip() - for s in parts] - action = _getaction(action) - message = re.escape(message) - category = _getcategory(category) - module = re.escape(module) - if module: - module = module + '$' - if lineno: - try: - lineno = int(lineno) - if lineno < 0: - raise ValueError - except (ValueError, OverflowError): - raise _OptionError("invalid lineno %s" % `lineno`) - else: - lineno = 0 - filterwarnings(action, message, category, module, lineno) - -# Helper for _setoption() -def _getaction(action): - if not action: - return "default" - if action == "all": return "always" # Alias - for a in ['default', 'always', 'ignore', 'module', 'once', 'error']: - if a.startswith(action): - return a - raise _OptionError("invalid action: %s" % `action`) - -# Helper for _setoption() -def _getcategory(category): - if not category: - return Warning - if re.match("^[a-zA-Z0-9_]+$", category): - try: - cat = eval(category) - except NameError: - raise _OptionError("unknown warning category: %s" % `category`) - else: - i = category.rfind(".") - module = category[:i] - klass = category[i+1:] - try: - m = __import__(module, None, None, [klass]) - except ImportError: - raise _OptionError("invalid module name: %s" % `module`) - try: - cat = getattr(m, klass) - except AttributeError: - raise _OptionError("unknown warning category: %s" % `category`) - if (not isinstance(cat, types.ClassType) or - not issubclass(cat, Warning)): - raise _OptionError("invalid warning category: %s" % `category`) - return cat - -# Self-test -def _test(): - import getopt - testoptions = [] - try: - opts, args = getopt.getopt(sys.argv[1:], "W:") - except getopt.error, msg: - print >>sys.stderr, msg - return - for o, a in opts: - testoptions.append(a) - try: - _processoptions(testoptions) - except _OptionError, msg: - print >>sys.stderr, msg - return - for item in filters: print item - hello = "hello world" - warn(hello); warn(hello); warn(hello); warn(hello) - warn(hello, UserWarning) - warn(hello, DeprecationWarning) - for i in range(3): - warn(hello) - filterwarnings("error", "", Warning, "", 0) - try: - warn(hello) - except Exception, msg: - print "Caught", msg.__class__.__name__ + ":", msg - else: - print "No exception" - resetwarnings() - try: - filterwarnings("booh", "", Warning, "", 0) - except Exception, msg: - print "Caught", msg.__class__.__name__ + ":", msg - else: - print "No exception" - -# Module initialization -if __name__ == "__main__": - import __main__ - sys.modules['warnings'] = __main__ - _test() -else: - _processoptions(sys.warnoptions) - filterwarnings("ignore", category=OverflowWarning, append=1) diff --git a/Scripts/ServerPython/python/system/weakref.py b/Scripts/ServerPython/python/system/weakref.py deleted file mode 100644 index d3121baf..00000000 --- a/Scripts/ServerPython/python/system/weakref.py +++ /dev/null @@ -1,284 +0,0 @@ -"""Weak reference support for Python. - -This module is an implementation of PEP 205: - -http://python.sourceforge.net/peps/pep-0205.html -""" - -# Naming convention: Variables named "wr" are weak reference objects; -# they are called this instead of "ref" to avoid name collisions with -# the module-global ref() function imported from _weakref. - -import UserDict - -from _weakref import \ - getweakrefcount, \ - getweakrefs, \ - ref, \ - proxy, \ - CallableProxyType, \ - ProxyType, \ - ReferenceType - -from exceptions import ReferenceError - - -ProxyTypes = (ProxyType, CallableProxyType) - -__all__ = ["ref", "proxy", "getweakrefcount", "getweakrefs", - "WeakKeyDictionary", "ReferenceType", "ProxyType", - "CallableProxyType", "ProxyTypes", "WeakValueDictionary"] - - -class WeakValueDictionary(UserDict.UserDict): - """Mapping class that references values weakly. - - Entries in the dictionary will be discarded when no strong - reference to the value exists anymore - """ - # We inherit the constructor without worrying about the input - # dictionary; since it uses our .update() method, we get the right - # checks (if the other dictionary is a WeakValueDictionary, - # objects are unwrapped on the way out, and we always wrap on the - # way in). - - def __getitem__(self, key): - o = self.data[key]() - if o is None: - raise KeyError, key - else: - return o - - def __repr__(self): - return "" % id(self) - - def __setitem__(self, key, value): - self.data[key] = ref(value, self.__makeremove(key)) - - def copy(self): - new = WeakValueDictionary() - for key, wr in self.data.items(): - o = wr() - if o is not None: - new[key] = o - return new - - def get(self, key, default=None): - try: - wr = self.data[key] - except KeyError: - return default - else: - o = wr() - if o is None: - # This should only happen - return default - else: - return o - - def items(self): - L = [] - for key, wr in self.data.items(): - o = wr() - if o is not None: - L.append((key, o)) - return L - - def iteritems(self): - return WeakValuedItemIterator(self) - - def iterkeys(self): - return self.data.iterkeys() - __iter__ = iterkeys - - def itervalues(self): - return WeakValuedValueIterator(self) - - def popitem(self): - while 1: - key, wr = self.data.popitem() - o = wr() - if o is not None: - return key, o - - def setdefault(self, key, default): - try: - wr = self.data[key] - except KeyError: - self.data[key] = ref(default, self.__makeremove(key)) - return default - else: - return wr() - - def update(self, dict): - d = self.data - for key, o in dict.items(): - d[key] = ref(o, self.__makeremove(key)) - - def values(self): - L = [] - for wr in self.data.values(): - o = wr() - if o is not None: - L.append(o) - return L - - def __makeremove(self, key): - def remove(o, selfref=ref(self), key=key): - self = selfref() - if self is not None: - del self.data[key] - return remove - - -class WeakKeyDictionary(UserDict.UserDict): - """ Mapping class that references keys weakly. - - Entries in the dictionary will be discarded when there is no - longer a strong reference to the key. This can be used to - associate additional data with an object owned by other parts of - an application without adding attributes to those objects. This - can be especially useful with objects that override attribute - accesses. - """ - - def __init__(self, dict=None): - self.data = {} - def remove(k, selfref=ref(self)): - self = selfref() - if self is not None: - del self.data[k] - self._remove = remove - if dict is not None: self.update(dict) - - def __delitem__(self, key): - for ref in self.data.iterkeys(): - o = ref() - if o == key: - del self.data[ref] - return - - def __getitem__(self, key): - return self.data[ref(key)] - - def __repr__(self): - return "" % id(self) - - def __setitem__(self, key, value): - self.data[ref(key, self._remove)] = value - - def copy(self): - new = WeakKeyDictionary() - for key, value in self.data.items(): - o = key() - if o is not None: - new[o] = value - return new - - def get(self, key, default=None): - return self.data.get(ref(key),default) - - def has_key(self, key): - try: - wr = ref(key) - except TypeError: - return 0 - return self.data.has_key(wr) - - def items(self): - L = [] - for key, value in self.data.items(): - o = key() - if o is not None: - L.append((o, value)) - return L - - def iteritems(self): - return WeakKeyedItemIterator(self) - - def iterkeys(self): - return WeakKeyedKeyIterator(self) - __iter__ = iterkeys - - def itervalues(self): - return self.data.itervalues() - - def keys(self): - L = [] - for wr in self.data.keys(): - o = wr() - if o is not None: - L.append(o) - return L - - def popitem(self): - while 1: - key, value = self.data.popitem() - o = key() - if o is not None: - return o, value - - def setdefault(self, key, default): - return self.data.setdefault(ref(key, self._remove),default) - - def update(self, dict): - d = self.data - for key, value in dict.items(): - d[ref(key, self._remove)] = value - - -class BaseIter: - def __iter__(self): - return self - - -class WeakKeyedKeyIterator(BaseIter): - def __init__(self, weakdict): - self._next = weakdict.data.iterkeys().next - - def next(self): - while 1: - wr = self._next() - obj = wr() - if obj is not None: - return obj - - -class WeakKeyedItemIterator(BaseIter): - def __init__(self, weakdict): - self._next = weakdict.data.iteritems().next - - def next(self): - while 1: - wr, value = self._next() - key = wr() - if key is not None: - return key, value - - -class WeakValuedValueIterator(BaseIter): - def __init__(self, weakdict): - self._next = weakdict.data.itervalues().next - - def next(self): - while 1: - wr = self._next() - obj = wr() - if obj is not None: - return obj - - -class WeakValuedItemIterator(BaseIter): - def __init__(self, weakdict): - self._next = weakdict.data.iteritems().next - - def next(self): - while 1: - key, wr = self._next() - value = wr() - if value is not None: - return key, value - - -# no longer needed -del UserDict diff --git a/Scripts/ServerPython/python/system/whrandom.py b/Scripts/ServerPython/python/system/whrandom.py deleted file mode 100644 index f841e2d6..00000000 --- a/Scripts/ServerPython/python/system/whrandom.py +++ /dev/null @@ -1,140 +0,0 @@ -"""Wichman-Hill random number generator. - -Wichmann, B. A. & Hill, I. D. (1982) -Algorithm AS 183: -An efficient and portable pseudo-random number generator -Applied Statistics 31 (1982) 188-190 - -see also: - Correction to Algorithm AS 183 - Applied Statistics 33 (1984) 123 - - McLeod, A. I. (1985) - A remark on Algorithm AS 183 - Applied Statistics 34 (1985),198-200 - - -USE: -whrandom.random() yields double precision random numbers - uniformly distributed between 0 and 1. - -whrandom.seed(x, y, z) must be called before whrandom.random() - to seed the generator - -There is also an interface to create multiple independent -random generators, and to choose from other ranges. - - - -Multi-threading note: the random number generator used here is not -thread-safe; it is possible that nearly simultaneous calls in -different theads return the same random value. To avoid this, you -have to use a lock around all calls. (I didn't want to slow this -down in the serial case by using a lock here.) -""" - -# Translated by Guido van Rossum from C source provided by -# Adrian Baddeley. - - -class whrandom: - def __init__(self, x = 0, y = 0, z = 0): - """Initialize an instance. - Without arguments, initialize from current time. - With arguments (x, y, z), initialize from them.""" - self.seed(x, y, z) - - def seed(self, x = 0, y = 0, z = 0): - """Set the seed from (x, y, z). - These must be integers in the range [0, 256).""" - if not type(x) == type(y) == type(z) == type(0): - raise TypeError, 'seeds must be integers' - if not (0 <= x < 256 and 0 <= y < 256 and 0 <= z < 256): - raise ValueError, 'seeds must be in range(0, 256)' - if 0 == x == y == z: - # Initialize from current time - import time - t = long(time.time() * 256) - t = int((t&0xffffff) ^ (t>>24)) - t, x = divmod(t, 256) - t, y = divmod(t, 256) - t, z = divmod(t, 256) - # Zero is a poor seed, so substitute 1 - self._seed = (x or 1, y or 1, z or 1) - - def random(self): - """Get the next random number in the range [0.0, 1.0).""" - # This part is thread-unsafe: - # BEGIN CRITICAL SECTION - x, y, z = self._seed - # - x = (171 * x) % 30269 - y = (172 * y) % 30307 - z = (170 * z) % 30323 - # - self._seed = x, y, z - # END CRITICAL SECTION - # - return (x/30269.0 + y/30307.0 + z/30323.0) % 1.0 - - def uniform(self, a, b): - """Get a random number in the range [a, b).""" - return a + (b-a) * self.random() - - def randint(self, a, b): - """Get a random integer in the range [a, b] including - both end points. - - (Deprecated; use randrange below.)""" - return self.randrange(a, b+1) - - def choice(self, seq): - """Choose a random element from a non-empty sequence.""" - return seq[int(self.random() * len(seq))] - - def randrange(self, start, stop=None, step=1, int=int, default=None): - """Choose a random item from range(start, stop[, step]). - - This fixes the problem with randint() which includes the - endpoint; in Python this is usually not what you want. - Do not supply the 'int' and 'default' arguments.""" - # This code is a bit messy to make it fast for the - # common case while still doing adequate error checking - istart = int(start) - if istart != start: - raise ValueError, "non-integer arg 1 for randrange()" - if stop is default: - if istart > 0: - return int(self.random() * istart) - raise ValueError, "empty range for randrange()" - istop = int(stop) - if istop != stop: - raise ValueError, "non-integer stop for randrange()" - if step == 1: - if istart < istop: - return istart + int(self.random() * - (istop - istart)) - raise ValueError, "empty range for randrange()" - istep = int(step) - if istep != step: - raise ValueError, "non-integer step for randrange()" - if istep > 0: - n = (istop - istart + istep - 1) / istep - elif istep < 0: - n = (istop - istart + istep + 1) / istep - else: - raise ValueError, "zero step for randrange()" - - if n <= 0: - raise ValueError, "empty range for randrange()" - return istart + istep*int(self.random() * n) - - -# Initialize from the current time -_inst = whrandom() -seed = _inst.seed -random = _inst.random -uniform = _inst.uniform -randint = _inst.randint -choice = _inst.choice -randrange = _inst.randrange